2 ### Makefile used to three-stage build a tree of source code. Also used to
3 ### compile other bundles, first with cc, then with gcc.
7 ### USE OF THIS FILE REQUIRES GNU MAKE!!!
10 ### The first versions of the file were written by Rich Pixley (rich@cygnus.com).
11 ### Many subsequent additions (and current maintainance by) david d `zoo' zuhn,
14 ### Every invocation of this Makefile needs to have a variable set (host),
15 ### which is the named used for ./configure, and also the prefix for the
16 ### various files and directories used in a three stage.
20 @echo You must set the variable
\"host
\" to use this Makefile
; exit
1
23 ### from here to very near the end of the file is the real guts of this
24 ### Makefile, and it is not seen if the variable 'host' is not set
27 ### START EDITTING HERE!!!
28 ### These things will need to be set differently for each release.
31 ### from which cvs tree are we working?
34 ### binaries should be installed into?
35 ROOTING
:= /usr
/cygnus
37 ### When working from a tagged set of source, this should be the tag. If not,
38 ### then set the macro to be empty.
41 ### The name of the cvs module for this release. The intersection of
42 ### CVS_MODULE and CVS_TAG defines the source files in this release.
45 ### Historically, this was identical to CVS_TAG. This is changing.
46 RELEASE_TAG
:= latest-930319
48 ### Historically, binaries were installed here. This is changing.
49 release_root
:= $(ROOTING
)/$(RELEASE_TAG
)
51 ### STOP EDITTING HERE!!!
52 ### With luck, eventually, nothing else will need to be editted.
58 GNU_MAKE
:= /usr
/latest
/bin
/make
-w
62 #override MAKEFLAGS :=
74 FLAGS_TO_PASS
:= "CC=$(CC)" $(FLAGS_TO_PASS
)
78 prefixes
= --prefix=$(release_root
) --exec_prefix=$(release_root
)/H-
$(host
)
79 relbindir
= $(release_root
)/H-
$(host
)/bin
82 ### general config stuff
83 WORKING_DIR
:= $(host
)-objdir
84 STAGE1DIR
:= $(WORKING_DIR
).1
85 STAGE2DIR
:= $(WORKING_DIR
).2
86 STAGE3DIR
:= $(WORKING_DIR
).3
87 INPLACEDIR
:= $(host
)-in-place
88 HOLESDIR
:= $(host
)-holes
90 SET_NATIVE_HOLES
:= SHELL
=sh
; PATH
=`pwd`/$(HOLESDIR
) ; export PATH
; export SHELL
;
91 SET_CYGNUS_PATH
:= SHELL
=sh
; PATH
=$(relbindir
):`pwd`/$(HOLESDIR
) ; export PATH
; export SHELL
;
92 SET_LATEST_PATH
:= SHELL
=sh
; PATH
=/usr
/latest
/bin
:`pwd`/$(HOLESDIR
) ; export PATH
; export SHELL
;
99 ## This is a cross compilation
101 arch
= $(host
)-x-
$(target
)
102 config
= $(host
) -target
=$(target
)
103 FLAGS_TO_PASS
:= $(FLAGS_TO_PASS
) "target=$(target)"
105 all: do-native do-latest
106 build-all
: build-native build-latest
110 ## This is a native compilation
114 all: $(host
)-stamp-3stage-done
115 #all: in-place do1 do2 do3 comparison
118 NATIVEDIR
:= $(arch
)-native-objdir
119 CYGNUSDIR
:= $(arch
)-cygnus-objdir
120 LATESTDIR
:= $(arch
)-latest-objdir
124 #everything: in-place do1 do2 do3 comparison do-cygnus
127 do-native
: $(host
)-stamp-holes
$(arch
)-stamp-native
128 do-native-config
: $(arch
)-stamp-native-configured
129 build-native
: $(host
)-stamp-holes
$(arch
)-stamp-native-checked
130 config-native
: $(host
)-stamp-holes
$(arch
)-stamp-native-configured
132 $(arch
)-stamp-native
: $(host
)-stamp-holes
133 $(SET_NATIVE_HOLES
) $(TIME
) $(GNU_MAKE
) -f test-build.mk
$(arch
)-stamp-native-installed
$(FLAGS_TO_PASS
)
134 if
[ -f CLEAN_ALL
] ; then
rm -rf
$(NATIVEDIR
) ; else true
; fi
135 touch
$(arch
)-stamp-native
137 $(arch
)-stamp-native-installed
: $(host
)-stamp-holes
$(arch
)-stamp-native-checked
138 $(SET_NATIVE_HOLES
) cd
$(NATIVEDIR
) ; $(TIME
) $(MAKE
) $(FLAGS_TO_PASS
) install
139 $(SET_NATIVE_HOLES
) cd
$(NATIVEDIR
) ; $(TIME
) $(MAKE
) $(FLAGS_TO_PASS
) install-info
142 $(arch
)-stamp-native-checked
: $(arch
)-stamp-native-built
143 # cd $(NATIVEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) check
146 $(arch
)-stamp-native-built
: $(host
)-stamp-holes
$(arch
)-stamp-native-configured
147 $(SET_NATIVE_HOLES
) cd
$(NATIVEDIR
) ; $(TIME
) $(MAKE
) $(FLAGS_TO_PASS
) all
148 $(SET_NATIVE_HOLES
) cd
$(NATIVEDIR
) ; $(TIME
) $(MAKE
) $(FLAGS_TO_PASS
) info
151 $(arch
)-stamp-native-configured
: $(host
)-stamp-holes
152 [ -d
$(NATIVEDIR
) ] || mkdir
$(NATIVEDIR
)
153 $(SET_NATIVE_HOLES
) cd
$(NATIVEDIR
) ; $(TIME
) ..
/$(TREE
)/configure
$(config
) -v
--srcdir=..
/$(TREE
) $(prefixes
)
158 do-cygnus
: $(host
)-stamp-holes
$(arch
)-stamp-cygnus
159 build-cygnus
: $(host
)-stamp-holes
$(arch
)-stamp-cygnus-checked
160 config-cygnus
: $(host
)-stamp-holes
$(arch
)-stamp-cygnus-configured
162 $(arch
)-stamp-cygnus
:
163 [ -f
$(relbindir
)/gcc
] ||
(echo
"must have gcc available"; exit
1)
164 $(SET_CYGNUS_PATH
) $(TIME
) $(GNU_MAKE
) -f test-build.mk
$(arch
)-stamp-cygnus-installed
$(FLAGS_TO_PASS
)
165 if
[ -f CLEAN_ALL
] ; then
rm -rf
$(CYGNUSDIR
) ; else true
; fi
166 touch
$(arch
)-stamp-cygnus
168 $(arch
)-stamp-cygnus-installed
: $(host
)-stamp-holes
$(arch
)-stamp-cygnus-checked
169 $(SET_CYGNUS_PATH
) cd
$(CYGNUSDIR
) ; $(TIME
) $(MAKE
) $(FLAGS_TO_PASS
) $(GNUC
) install
170 $(SET_CYGNUS_PATH
) cd
$(CYGNUSDIR
) ; $(TIME
) $(MAKE
) $(FLAGS_TO_PASS
) $(GNUC
) install-info
173 $(arch
)-stamp-cygnus-checked
: $(host
)-stamp-holes
$(arch
)-stamp-cygnus-built
174 # cd $(CYGNUSDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) check
177 $(arch
)-stamp-cygnus-built
: $(host
)-stamp-holes
$(arch
)-stamp-cygnus-configured
178 $(SET_CYGNUS_PATH
) cd
$(CYGNUSDIR
) ; $(TIME
) $(MAKE
) $(FLAGS_TO_PASS
) $(GNUC
) all
179 $(SET_CYGNUS_PATH
) cd
$(CYGNUSDIR
) ; $(TIME
) $(MAKE
) $(FLAGS_TO_PASS
) $(GNUC
) info
182 $(arch
)-stamp-cygnus-configured
: $(host
)-stamp-holes
183 [ -d
$(CYGNUSDIR
) ] || mkdir
$(CYGNUSDIR
)
184 $(SET_CYGNUS_PATH
) cd
$(CYGNUSDIR
) ; $(GNUC
) $(TIME
) ..
/$(TREE
)/configure
$(config
) -v
--srcdir=..
/$(TREE
) $(prefixes
)
188 do-latest
: $(host
)-stamp-holes
$(arch
)-stamp-latest
189 build-latest
: $(host
)-stamp-holes
$(arch
)-stamp-latest-checked
191 $(arch
)-stamp-latest
:
192 $(SET_LATEST_PATH
) $(TIME
) $(GNU_MAKE
) -f test-build.mk
$(arch
)-stamp-latest-installed
$(FLAGS_TO_PASS
)
193 touch
$(arch
)-stamp-latest
196 $(SET_LATEST_PATH
) cd
$(LATESTDIR
) ; $(TIME
) $(MAKE
) $(FLAGS_TO_PASS
) $(GNUC
) install
197 $(SET_LATEST_PATH
) cd
$(LATESTDIR
) ; $(TIME
) $(MAKE
) $(FLAGS_TO_PASS
) $(GNUC
) install-info
200 $(arch
)-stamp-latest-checked
: $(arch
)-stamp-latest-built
201 # $(SET_LATEST_PATH) cd $(LATESTDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) check
204 $(arch
)-stamp-latest-built
: $(arch
)-stamp-latest-configured
205 $(SET_LATEST_PATH
) cd
$(LATESTDIR
) ; $(TIME
) $(MAKE
) $(FLAGS_TO_PASS
) $(GNUC
) all
206 $(SET_LATEST_PATH
) cd
$(LATESTDIR
) ; $(TIME
) $(MAKE
) $(FLAGS_TO_PASS
) $(GNUC
) info
209 $(arch
)-stamp-latest-configured
:
210 [ -d
$(LATESTDIR
) ] || mkdir
$(LATESTDIR
)
211 $(SET_LATEST_PATH
) cd
$(LATESTDIR
) ; $(GNUC
) $(TIME
) ..
/$(TREE
)/configure
$(config
) -v
--srcdir=..
/$(TREE
) $(prefixes
)
216 in-place
: $(host
)-stamp-in-place
218 $(host
)-stamp-in-place
:
219 PATH
=/bin
:/usr
/bin
:/usr
/ucb
; \
221 SHELL
=/bin
/sh
; export SHELL
; \
222 $(TIME
) $(GNU_MAKE
) -f test-build.mk
$(host
)-stamp-in-place-installed host
=$(host
) $(FLAGS_TO_PASS
)
224 if
[ -f CLEAN_ALL
] ; then \
225 rm -rf
$(INPLACEDIR
) ; \
227 mv
$(INPLACEDIR
) $(STAGE1DIR
) ; \
230 $(host
)-stamp-in-place-installed
: $(host
)-stamp-in-place-checked
231 cd
$(INPLACEDIR
) ; $(TIME
) $(MAKE
) $(FLAGS_TO_PASS
) "CFLAGS=$(CFLAGS)" install host
=$(host
)
232 cd
$(INPLACEDIR
) ; $(TIME
) $(MAKE
) $(FLAGS_TO_PASS
) "CFLAGS=$(CFLAGS)" install-info host
=$(host
)
235 $(host
)-stamp-in-place-checked
: $(host
)-stamp-in-place-built
236 # cd $(INPLACEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) "CFLAGS=$(CFLAGS)" check host=$(host)
239 $(host
)-stamp-in-place-built
: $(host
)-stamp-in-place-configured
240 cd
$(INPLACEDIR
) ; $(TIME
) $(MAKE
) $(FLAGS_TO_PASS
) "CFLAGS=$(CFLAGS)" all host
=$(host
)
241 cd
$(INPLACEDIR
) ; $(TIME
) $(MAKE
) $(FLAGS_TO_PASS
) "CFLAGS=$(CFLAGS)" info host
=$(host
)
244 $(host
)-stamp-in-place-configured
: $(host
)-stamp-in-place-cp
245 cd
$(INPLACEDIR
) ; $(TIME
) .
/configure
$(host
) -v
$(prefixes
)
248 $(host
)-stamp-in-place-cp
:
251 (cd
$(TREE
) ; tar cf
- .
) |
(cd
$(INPLACEDIR
) ; tar xf
-)
254 $(host
)-stamp-3stage-done
: do1 do2 do3 comparison
259 do1
: $(host
)-stamp-holes
$(host
)-stamp-stage1
260 do1-config
: $(host
)-stamp-holes
$(host
)-stamp-stage1-configured
261 do1-build
: $(host
)-stamp-holes
$(host
)-stamp-stage1-checked
263 $(host
)-stamp-stage1
:
264 if
[ -d
$(STAGE1DIR
) ] ; then \
265 mv
$(STAGE1DIR
) $(WORKING_DIR
) ; \
269 $(SET_NATIVE_HOLES
) $(TIME
) $(GNU_MAKE
) -f test-build.mk
$(FLAGS_TO_PASS
) host
=$(host
) $(host
)-stamp-stage1-installed
271 if
[ -f CLEAN_ALL
] ; then \
272 rm -rf
$(WORKING_DIR
) ; \
274 mv
$(WORKING_DIR
) $(STAGE1DIR
) ; \
277 $(host
)-stamp-stage1-installed
: $(host
)-stamp-stage1-checked
278 $(SET_NATIVE_HOLES
) cd
$(WORKING_DIR
) ; $(TIME
) $(MAKE
) $(FLAGS_TO_PASS
) "CFLAGS=$(CFLAGS)" install host
=$(host
)
279 $(SET_NATIVE_HOLES
) cd
$(WORKING_DIR
) ; $(TIME
) $(MAKE
) $(FLAGS_TO_PASS
) "CFLAGS=$(CFLAGS)" install-info host
=$(host
)
280 ifeq ($(host
),rs6000-ibm-aix
)
285 $(host
)-stamp-stage1-checked
: $(host
)-stamp-stage1-built
286 # $(SET_NATIVE_HOLES) cd $(WORKING_DIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) "CFLAGS=$(CFLAGS)" check host=$(host)
289 $(host
)-stamp-stage1-built
: $(host
)-stamp-stage1-configured
290 $(SET_NATIVE_HOLES
) cd
$(WORKING_DIR
) ; $(TIME
) $(MAKE
) $(FLAGS_TO_PASS
) "CFLAGS=$(CFLAGS)" all host
=$(host
)
291 $(SET_NATIVE_HOLES
) cd
$(WORKING_DIR
) ; $(TIME
) $(MAKE
) $(FLAGS_TO_PASS
) "CFLAGS=$(CFLAGS)" info host
=$(host
)
294 $(host
)-stamp-stage1-configured
:
295 [ -d
$(WORKING_DIR
) ] || mkdir
$(WORKING_DIR
)
296 $(SET_NATIVE_HOLES
) cd
$(WORKING_DIR
) ; \
297 $(TIME
) ..
/$(TREE
)/configure
$(host
) -v
--srcdir=..
/$(TREE
) $(prefixes
)
301 do2
: $(HOLESDIR
) $(host
)-stamp-stage2
303 $(host
)-stamp-stage2
:
304 if
[ -d
$(STAGE2DIR
) ] ; then \
305 mv
$(STAGE2DIR
) $(WORKING_DIR
) ; \
309 $(SET_CYGNUS_PATH
) $(TIME
) $(GNU_MAKE
) $(FLAGS_TO_PASS
) -f test-build.mk
-w
$(host
)-stamp-stage2-installed
310 mv
$(WORKING_DIR
) $(STAGE2DIR
)
314 $(host
)-stamp-stage2-installed
: $(host
)-stamp-stage2-checked
315 $(SET_CYGNUS_PATH
) cd
$(WORKING_DIR
) ; $(TIME
) $(MAKE
) -w
$(FLAGS_TO_PASS
) $(GNUC
) "CFLAGS=$(CFLAGS)" install host
=$(host
)
316 $(SET_CYGNUS_PATH
) cd
$(WORKING_DIR
) ; $(TIME
) $(MAKE
) -w
$(FLAGS_TO_PASS
) $(GNUC
) "CFLAGS=$(CFLAGS)" install-info host
=$(host
)
319 $(host
)-stamp-stage2-checked
: $(host
)-stamp-stage2-built
320 # $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" check host=$(host)
323 $(host
)-stamp-stage2-built
: $(host
)-stamp-stage2-configured
324 $(SET_CYGNUS_PATH
) cd
$(WORKING_DIR
) ; $(TIME
) $(MAKE
) -w
$(FLAGS_TO_PASS
) $(GNUC
) "CFLAGS=$(CFLAGS)" all host
=$(host
)
325 $(SET_CYGNUS_PATH
) cd
$(WORKING_DIR
) ; $(TIME
) $(MAKE
) -w
$(FLAGS_TO_PASS
) $(GNUC
) "CFLAGS=$(CFLAGS)" info host
=$(host
)
328 $(host
)-stamp-stage2-configured
:
329 [ -d
$(WORKING_DIR
) ] || mkdir
$(WORKING_DIR
)
330 $(SET_CYGNUS_PATH
) cd
$(WORKING_DIR
) ; \
331 $(GNUC
) $(TIME
) ..
/$(TREE
)/configure
$(host
) -v
--srcdir=..
/$(TREE
) $(prefixes
)
335 do3
: $(HOLESDIR
) $(host
)-stamp-stage3
337 $(host
)-stamp-stage3
:
338 if
[ -d
$(STAGE3DIR
) ] ; then \
339 mv
$(STAGE3DIR
) $(WORKING_DIR
) ; \
343 $(SET_CYGNUS_PATH
) $(TIME
) $(GNU_MAKE
) $(FLAGS_TO_PASS
) -f test-build.mk
-w
$(host
)-stamp-stage3-checked
344 mv
$(WORKING_DIR
) $(STAGE3DIR
)
348 $(host
)-stamp-stage3-installed
: $(host
)-stamp-stage3-checked
349 $(SET_CYGNUS_PATH
) cd
$(WORKING_DIR
) ; $(TIME
) $(MAKE
) -w
$(FLAGS_TO_PASS
) $(GNUC
) "CFLAGS=$(CFLAGS)" install host
=$(host
)
350 $(SET_CYGNUS_PATH
) cd
$(WORKING_DIR
) ; $(TIME
) $(MAKE
) -w
$(FLAGS_TO_PASS
) $(GNUC
) "CFLAGS=$(CFLAGS)" install-info host
=$(host
)
353 $(host
)-stamp-stage3-checked
: $(host
)-stamp-stage3-built
354 # $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" check host=$(host)
357 $(host
)-stamp-stage3-built
: $(host
)-stamp-stage3-configured
358 $(SET_CYGNUS_PATH
) cd
$(WORKING_DIR
) ; $(TIME
) $(MAKE
) -w
$(FLAGS_TO_PASS
) $(GNUC
) "CFLAGS=$(CFLAGS)" all host
=$(host
)
359 $(SET_CYGNUS_PATH
) cd
$(WORKING_DIR
) ; $(TIME
) $(MAKE
) -w
$(FLAGS_TO_PASS
) $(GNUC
) "CFLAGS=$(CFLAGS)" info host
=$(host
)
362 $(host
)-stamp-stage3-configured
:
363 [ -d
$(WORKING_DIR
) ] || mkdir
$(WORKING_DIR
)
364 $(SET_CYGNUS_PATH
) cd
$(WORKING_DIR
) ; \
365 $(GNUC
) $(TIME
) ..
/$(TREE
)/configure
$(host
) -v
--srcdir=..
/$(TREE
) $(prefixes
)
368 # These things are needed by a three-stage, but are not included locally.
419 ### so far only sun make supports VPATH
420 ifeq ($(subst sun3
,sun4
,$(host
)),sun4
)
426 ### solaris 2 -- don't use /usr/ucb/cc
427 ifeq (sparc-sun-solaris2
,$(host
))
428 SET_NATIVE_HOLES
:= SHELL
=sh
; PATH
=/opt
/SUNWspro
/bin
:`pwd`/$(HOLESDIR
) ; export PATH
; export SHELL
;
429 HOLE_DIRS
:= /usr
/ccs
/bin
434 ### rs6000 as is busted. We cache a patched version in unsupported.
435 ifeq ($(host
),rs6000-ibm-aix
)
441 ### These things are also needed by a three-stage, but in this case, the GNU version of the tool is required.
449 ### look in these directories for things missing from a three-stage
457 ### look in these directories for alternate versions of some tools.
458 PARTIAL_HOLE_DIRS
:= \
460 /usr
/progressive
/bin \
461 $(PARTIAL_HOLE_DIRS
) \
465 $(HOLESDIR
): $(host
)-stamp-holes
470 @for i in
$(HOLES
) ; do \
472 for j in
$(HOLE_DIRS
) ; do \
473 if
[ -x
$$j/$$i ] ; then \
474 ln
-s
$$j/$$i $(HOLESDIR
) || cp
$$j/$$i $(HOLESDIR
) ; \
475 echo
$$i from
$$j ; \
482 *) echo
$$i is NOT found
;; \
485 @for i in
$(PARTIAL_HOLES
) ; do \
487 for j in
$(PARTIAL_HOLE_DIRS
) ; do \
488 if
[ -x
$$j/$$i ] ; then \
489 rm -f
$(HOLESDIR
)/$$i ; \
490 cp
$$j/$$i $(HOLESDIR
)/$$i || exit
1; \
491 echo
$$i from
$$j ; \
498 *) echo
$$i is NOT found
;; \
502 cd
$(HOLESDIR
); rm -f
$(NUKEM
)
507 comparison
: $(host
)-stamp-3stage-compared
509 $(host
)-stamp-3stage-compared
:
511 ifeq ($(subst i386-sco3.2v4
,mips-sgi-irix4
,$(subst rs6000-ibm-aix
,mips-sgi-irix4
,$(subst mips-dec-ultrix
,mips-sgi-irix4
,$(host
)))),mips-sgi-irix4
)
512 for i in
`cd $(STAGE3DIR) ; find . -name \*.o -print` ; do \
513 tail
+10c
$(STAGE2DIR
)/$$i > foo1
; \
514 tail
+10c
$(STAGE3DIR
)/$$i > foo2
; \
515 if cmp foo1 foo2
; then \
519 touch .bad-compare
; \
524 for i in
`cd $(STAGE3DIR) ; find . -name \*.o -print` ; do \
525 cmp
$(STAGE2DIR
)/$$i $(STAGE3DIR
)/$$i || touch .bad-compare
; \
528 if
[ -f CLEAN_ALL
] ; then \
529 rm -rf
$(STAGE2DIR
) $(STAGE3DIR
) ; \
531 if
[ -f CLEAN_STAGES
] ; then \
532 if
[ -f .bad-compare
] ; then \
535 rm -rf
$(STAGE1DIR
) $(STAGE2DIR
) ; \
544 rm -rf
$(HOLESDIR
) $(INPLACEDIR
) $(WORKING_DIR
)* $(host
)-stamp-
* *~