Subject: xsrc/7542: xsrc only builds every second time
To: None <gnats-bugs@gnats.netbsd.org>
From: None <arnej@math.ntnu.no>
List: netbsd-bugs
Date: 05/09/1999 13:20:59
>Number:         7542
>Category:       xsrc
>Synopsis:       xsrc only builds every second time
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    xsrc-manager (NetBSD X11 bug manager)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun May  9 13:20:01 1999
>Last-Modified:
>Originator:     Arne H Juul
>Organization:
	NUTS (Norwegian University of Technology and Science)
>Release:        NetBSD 1.4 (aka sup-of-the-day)
>Environment:
	
System: NetBSD fimfpc30.math.ntnu.no 1.4 NetBSD 1.4 (GENERIC) #0: Fri May 7 11:46:56 CEST 1999 root@fimfpc30.math.ntnu.no:/usr/src/sys/arch/i386/compile/GENERIC i386


>Description:
	I have been building the full NetBSD 1.4 (pre)release from
source a couple of times during the last weeks, and the second time
I wanted to rebuild xsrc I just did "make" from /usr/xsrc, and very
quickly got unexpected problems.  Doing "make clean" first helps,
and doing another "make" (or "make World" if in xc) works too.
So it's not a big deal, but it's very confusing at first (and the
tangle of imake and bootstrap Makefiles doesn't help).

	The second make gave the following output:
==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ====
cd xc ; make World
Building Release 6.3 of the X Window System.
I hope you checked the configuration parameters in ./config/cf
to see if you need to pass BOOTSTRAPCFLAGS.
Sun May  9 20:54:43 CEST 1999
cd ./config/imake && make   -f Makefile.ini BOOTSTRAPCFLAGS="" clean
rm -f ccimake imake.o imake
rm -f *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a  tags TAGS make.log \#*
rm -f -r Makefile.proto Makefile Makefile.dep bootstrap
make   Makefile.boot
cd ./config/imake && make   -f Makefile.ini BOOTSTRAPCFLAGS=""
making imake with BOOTSTRAPCFLAGS= in config/imake
cc -o ccimake  -O -I../../include -I../../imports/x11/include/X11 ccimake.c
cc -c  -O -I../../include -I../../imports/x11/include/X11 `./ccimake` imake.c
cc -o imake  -O -I../../include -I../../imports/x11/include/X11 imake.o
imake.o: warning: mktemp() possibly used unsafely, use mkstemp() or mkdtemp()
rm -f ./config/makedepend/Makefile.proto
cd ./config/makedepend && rm -f -r Makefile Makefile.dep makedepend *.o bootstrap
cd ./config/makedepend && make -f Makefile.proto bootstrap
make: cannot open Makefile.proto.
*** Error code 2
[..]
==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ====

Well of course make can't open it, it was just removed!
If one runs a make clean between, or the first time make is run, there's
some stuff between that builds a new Makefile.proto:

==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ====
[..]
imake.o: warning: mktemp() possibly used unsafely, use mkstemp() or mkdtemp()
rm -f ./config/makedepend/Makefile.proto
./config/imake/imake -I./config/cf  -s ./config/makedepend/Makefile.proto -f ./config/makedepend/Imakefile -DTOPDIR=../.. -DCURDIR=./config/makedepend
cd ./config/makedepend && rm -f -r Makefile Makefile.dep makedepend *.o bootstrap
cd ./config/makedepend && make -f Makefile.proto bootstrap
./config/imake/imake -I./config/cf  -s ./config/imake/Makefile.proto -f ./config/imake/Imakefile -DTOPDIR=../.. -DCURDIR=./config/imake
[..]
==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ====
The top-level Makefile contains this:
==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ====
# This is just a sequence of bootstrapping steps we have to do.
# The steps are listed as separate targets so clearmake can wink in
# the Makefile.proto files.
Makefile.boot: imake.proto $(DEPENDSRC)/Makefile.proto depend.bootstrap $(IMAKES
RC)/Makefile.proto imake.bootstrap

imake.proto:
        cd $(IMAKESRC) && $(MAKE) $(FLAGS)
        $(RM) $(DEPENDSRC)/Makefile.proto

$(DEPENDSRC)/Makefile.proto:
        $(IMAKE_CMD) -s $(DEPENDSRC)/Makefile.proto -f $(DEPENDSRC)/Imakefile -D
TOPDIR=$(DEPENDTOP) -DCURDIR=$(DEPENDSRC)
==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ====
This works OK if make checks imake.proto, decides it has to remake it
(and removes $(DEPENDSRC)/Makefile.proto in the process), then checks
$(DEPENDSRC)/Makefile.proto and finds it gone, and rebuilds it.

However, our make apparently checks $(DEPENDSRC)/Makefile.proto (and
finds it up-to-date) before doing the remake of imake.proto target.
(This is perfectly valid and wanted for parallelism, if I've understood
things right.)

I don't understand the "clearmake" comment at all, what does it mean to
"wink in the Makefile.proto files"??  Also, $(IMAKESRC)/Makefile.proto
is never rudely removed the way $(DEPENDSRC)/Makefile.proto is.  Maybe
the "$(RM) $(DEPENDSRC)/Makefile.proto" should be removed, or put into
a "clean" target?  Since I can't guess what the original intentions were,
I propose just an explicit remake, this should be as close to the original
idea as possible.

>How-To-Repeat:
	# cd /usr/xsrc; make ; make
>Fix:

--- xsrc/xc/Makefile.orig	Tue Nov 24 13:43:55 1998
+++ xsrc/xc/Makefile	Sun May  9 22:00:27 1999
@@ -81,6 +81,7 @@
 imake.proto:
 	cd $(IMAKESRC) && $(MAKE) $(FLAGS)
 	$(RM) $(DEPENDSRC)/Makefile.proto
+	$(MAKE) $(DEPENDSRC)/Makefile.proto
 
 $(DEPENDSRC)/Makefile.proto:
 	$(IMAKE_CMD) -s $(DEPENDSRC)/Makefile.proto -f $(DEPENDSRC)/Imakefile -DTOPDIR=$(DEPENDTOP) -DCURDIR=$(DEPENDSRC)
>Audit-Trail:
>Unformatted: