Makefile.inc1 revision 127360
1#
2# $FreeBSD: head/Makefile.inc1 127360 2004-03-24 08:26:22Z ru $
3#
4# Make command line options:
5#	-DNO_DYNAMICROOT do not link /bin and /sbin dynamically
6#	-DNO_KERBEROS Do not build Heimdal (Kerberos 5)
7#	-DNO_RESCUE do not build rescue binaries
8#	-DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
9#	-DNOCLEAN do not clean at all
10#	-DNOCRYPT will prevent building of crypt versions
11#	-DNOMAN do not build the manual pages
12#	-DNOPROFILE do not build profiled libraries
13#	-DNOGAMES do not go into games subdir
14#	-DNOSHARE do not go into share subdir
15#	-DNOINFO do not make or install info files
16#	-DNOLIBC_R do not build libc_r.
17#	-DNO_FORTRAN do not build g77 and related libraries.
18#	-DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
19#	-DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
20#	-DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
21#	-DNO_PORTSUPDATE do not update ports in ${MAKE} update
22#	-DNO_DOCUPDATE do not update doc in ${MAKE} update
23#	LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
24#	TARGET_ARCH="arch" to crossbuild world to a different arch
25
26#
27# The intended user-driven targets are:
28# buildworld  - rebuild *everything*, including glue to help do upgrades
29# installworld- install everything built by "buildworld"
30# update      - convenient way to update your source tree (eg: sup/cvs)
31#
32# Standard targets (not defined here) are documented in the makefiles in
33# /usr/share/mk.  These include:
34#		obj depend all install clean cleandepend cleanobj
35
36# We must do share/info early so that installation of info `dir'
37# entries works correctly.  Do it first since it is less likely to
38# grow dependencies on include and lib than vice versa.
39#
40# We must do lib and libexec before bin, because if installworld
41# installs a new /bin/sh, the 'make' command will *immediately*
42# use that new version.  And the new (dynamically-linked) /bin/sh
43# will expect to find appropriate libraries in /lib and /libexec.
44#
45# We must do etc last for install/distribute to work.
46#
47SUBDIR=	share/info include lib libexec bin
48.if !defined(NOGAMES)
49SUBDIR+=games
50.endif
51SUBDIR+=gnu
52.if !defined(NO_KERBEROS) && !defined(NOCRYPT) && !defined(NO_OPENSSL)
53SUBDIR+=kerberos5
54.endif
55.if !defined(NO_RESCUE)
56SUBDIR+=rescue
57.endif
58SUBDIR+=sbin
59.if !defined(NOCRYPT)
60SUBDIR+=secure
61.endif
62.if !defined(NOSHARE)
63SUBDIR+=share
64.endif
65SUBDIR+=sys usr.bin usr.sbin etc
66
67# These are last, since it is nice to at least get the base system
68# rebuilt before you do them.
69.for _DIR in ${LOCAL_DIRS}
70.if exists(${.CURDIR}/${_DIR}/Makefile)
71SUBDIR+= ${_DIR}
72.endif
73.endfor
74
75.if defined(SUBDIR_OVERRIDE)
76SUBDIR=		${SUBDIR_OVERRIDE}
77.endif
78
79.if defined(NOCLEANDIR)
80CLEANDIR=	clean cleandepend
81.else
82CLEANDIR=	cleandir
83.endif
84
85CVS?=		cvs
86SUP?=		/usr/local/bin/cvsup
87SUPFLAGS?=	-g -L 2 -P -
88.if defined(SUPHOST)
89SUPFLAGS+=	-h ${SUPHOST}
90.endif
91
92MAKEOBJDIRPREFIX?=	/usr/obj
93.if !defined(OSRELDATE)
94.if exists(/usr/include/osreldate.h)
95OSRELDATE!=	awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
96		/usr/include/osreldate.h
97.else
98OSRELDATE=	0
99.endif
100.endif
101TARGET_ARCH?=	${MACHINE_ARCH}
102.if ${TARGET_ARCH} == ${MACHINE_ARCH}
103TARGET?=	${MACHINE}
104TARGET_CPUTYPE?=${CPUTYPE}
105.else
106TARGET?=	${TARGET_ARCH}
107TARGET_CPUTYPE?=
108.endif
109.if !empty(TARGET_CPUTYPE)
110_TARGET_CPUTYPE=${TARGET_CPUTYPE}
111.else
112_TARGET_CPUTYPE=dummy
113.endif
114_CPUTYPE!=	${MAKE} -f /dev/null -m ${.CURDIR}/share/mk \
115		CPUTYPE=${_TARGET_CPUTYPE} -V CPUTYPE
116.if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
117.error CPUTYPE global should be set with ?=.
118.endif
119.if make(buildworld)
120BUILD_ARCH!=	sysctl -n hw.machine_arch
121.if ${MACHINE_ARCH} != ${BUILD_ARCH}
122.error To cross-build, set TARGET_ARCH.
123.endif
124.endif
125.if ${MACHINE} == ${TARGET}
126OBJTREE=	${MAKEOBJDIRPREFIX}
127.else
128OBJTREE=	${MAKEOBJDIRPREFIX}/${TARGET}
129.endif
130WORLDTMP=	${OBJTREE}${.CURDIR}/${MACHINE_ARCH}
131# /usr/games added for fortune which depend on strfile
132BPATH=		${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
133XPATH=		${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
134STRICTTMPPATH=	${BPATH}:${XPATH}
135TMPPATH=	${STRICTTMPPATH}:${PATH}
136
137INSTALLTMP!=	/usr/bin/mktemp -d -u -t install
138
139#
140# Building a world goes through the following stages
141#
142# 1. legacy stage [BMAKE]
143#	This stage is responsible for creating compatibility
144#	shims that are needed by the bootstrap-tools,
145#	build-tools and cross-tools stages.
146# 1. bootstrap-tools stage [BMAKE]
147#	This stage is responsible for creating programs that
148#	are needed for backward compatibility reasons. They
149#	are not built as cross-tools.
150# 2. build-tools stage [TMAKE]
151#	This stage is responsible for creating the object
152#	tree and building any tools that are needed during
153#	the build process.
154# 3. cross-tools stage [XMAKE]
155#	This stage is responsible for creating any tools that
156#	are needed for cross-builds. A cross-compiler is one
157#	of them.
158# 4. world stage [WMAKE]
159#	This stage actually builds the world.
160# 5. install stage (optional) [IMAKE]
161#	This stage installs a previously built world.
162#
163
164BOOTSTRAPPING?=	0
165
166# Common environment for world related stages
167CROSSENV=	MAKEOBJDIRPREFIX=${OBJTREE} \
168		MACHINE_ARCH=${TARGET_ARCH} \
169		MACHINE=${TARGET} \
170		CPUTYPE=${TARGET_CPUTYPE} \
171		GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
172		GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
173		GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
174
175# bootstrap-tools stage
176BMAKEENV=	DESTDIR= \
177		INSTALL="sh ${.CURDIR}/tools/install.sh" \
178		PATH=${BPATH}:${PATH} \
179		WORLDTMP=${WORLDTMP} \
180		MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
181BMAKE=		MAKEOBJDIRPREFIX=${WORLDTMP} \
182		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
183		BOOTSTRAPPING=${OSRELDATE} \
184		-DNOHTML -DNOINFO -DNOLINT -DNOMAN -DNOPIC -DNOPROFILE \
185		-DNOSHARED -DNO_CPU_CFLAGS -DNO_WARNS
186
187# build-tools stage
188TMAKE=		MAKEOBJDIRPREFIX=${OBJTREE} \
189		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
190		BOOTSTRAPPING=${OSRELDATE} -DNOLINT -DNO_CPU_CFLAGS -DNO_WARNS
191
192# cross-tools stage
193XMAKE=		TOOLS_PREFIX=${WORLDTMP} ${BMAKE} -DNO_FORTRAN -DNO_GDB
194
195# world stage
196WMAKEENV=	${CROSSENV} \
197		DESTDIR=${WORLDTMP} \
198		_SHLIBDIRPREFIX=${WORLDTMP} \
199		INSTALL="sh ${.CURDIR}/tools/install.sh" \
200		PATH=${TMPPATH}
201WMAKE=		${WMAKEENV} ${MAKE} -f Makefile.inc1
202
203# install stage
204IMAKEENV=	${CROSSENV} \
205		PATH=${STRICTTMPPATH}:${INSTALLTMP}
206IMAKE=		${IMAKEENV} ${MAKE} -f Makefile.inc1
207
208# kernel stage
209KMAKEENV=	${WMAKEENV}
210
211#
212# buildworld
213#
214# Attempt to rebuild the entire system, with reasonable chance of
215# success, regardless of how old your existing system is.
216#
217_worldtmp:
218.if ${.CURDIR:C/[^,]//g} != ""
219#	The m4 build of sendmail files doesn't like it if ',' is used
220#	anywhere in the path of it's files.
221	@echo
222	@echo "*** Error: path to source tree contains a comma ','"
223	@echo
224	false
225.endif
226	@echo
227	@echo "--------------------------------------------------------------"
228	@echo ">>> Rebuilding the temporary build tree"
229	@echo "--------------------------------------------------------------"
230.if !defined(NOCLEAN)
231	rm -rf ${WORLDTMP}
232.else
233	rm -rf ${WORLDTMP}/legacy/usr/include
234	# XXX - These two can depend on any header file.
235	rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
236	rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
237.endif
238.for _dir in \
239    usr/bin usr/games usr/include/c++/3.3 usr/include/sys usr/lib \
240    usr/libexec usr/sbin usr/share/dict \
241    usr/share/groff_font/devX100 \
242    usr/share/groff_font/devX100-12 \
243    usr/share/groff_font/devX75 \
244    usr/share/groff_font/devX75-12 \
245    usr/share/groff_font/devascii \
246    usr/share/groff_font/devcp1047 \
247    usr/share/groff_font/devdvi \
248    usr/share/groff_font/devhtml \
249    usr/share/groff_font/devkoi8-r \
250    usr/share/groff_font/devlatin1 \
251    usr/share/groff_font/devlbp \
252    usr/share/groff_font/devlj4 \
253    usr/share/groff_font/devps \
254    usr/share/groff_font/devutf8 \
255    usr/share/tmac/mdoc usr/share/tmac/mm
256	mkdir -p ${WORLDTMP}/legacy/${_dir}
257.endfor
258.for _dir in \
259    lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
260    usr/libexec usr/sbin usr/share/misc \
261    usr/share/bsnmp/defs usr/share/bsnmp/mibs
262	mkdir -p ${WORLDTMP}/${_dir}
263.endfor
264	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
265	    -p ${WORLDTMP}/usr/include >/dev/null
266	ln -sf ${.CURDIR}/sys ${WORLDTMP}
267_legacy:
268	@echo
269	@echo "--------------------------------------------------------------"
270	@echo ">>> stage 1.1: legacy release compatibility shims"
271	@echo "--------------------------------------------------------------"
272	cd ${.CURDIR}; ${BMAKE} legacy
273_bootstrap-tools:
274	@echo
275	@echo "--------------------------------------------------------------"
276	@echo ">>> stage 1.2: bootstrap tools"
277	@echo "--------------------------------------------------------------"
278	cd ${.CURDIR}; ${BMAKE} bootstrap-tools
279_cleanobj:
280.if !defined(NOCLEAN)
281	@echo
282	@echo "--------------------------------------------------------------"
283	@echo ">>> stage 2.1: cleaning up the object tree"
284	@echo "--------------------------------------------------------------"
285	cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
286.endif
287_obj:
288	@echo
289	@echo "--------------------------------------------------------------"
290	@echo ">>> stage 2.2: rebuilding the object tree"
291	@echo "--------------------------------------------------------------"
292	cd ${.CURDIR}; ${WMAKE} par-obj
293_build-tools:
294	@echo
295	@echo "--------------------------------------------------------------"
296	@echo ">>> stage 2.3: build tools"
297	@echo "--------------------------------------------------------------"
298	cd ${.CURDIR}; ${TMAKE} build-tools
299_cross-tools:
300	@echo
301	@echo "--------------------------------------------------------------"
302	@echo ">>> stage 3: cross tools"
303	@echo "--------------------------------------------------------------"
304	cd ${.CURDIR}; ${XMAKE} cross-tools
305_includes:
306	@echo
307	@echo "--------------------------------------------------------------"
308	@echo ">>> stage 4.1: building includes"
309	@echo "--------------------------------------------------------------"
310	cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
311_libraries:
312	@echo
313	@echo "--------------------------------------------------------------"
314	@echo ">>> stage 4.2: building libraries"
315	@echo "--------------------------------------------------------------"
316	cd ${.CURDIR}; \
317	    ${WMAKE} -DNOFSCHG -DNOHTML -DNOINFO -DNOLINT -DNOMAN -DNOPROFILE \
318	    libraries
319_depend:
320	@echo
321	@echo "--------------------------------------------------------------"
322	@echo ">>> stage 4.3: make dependencies"
323	@echo "--------------------------------------------------------------"
324	cd ${.CURDIR}; ${WMAKE} par-depend
325everything:
326	@echo
327	@echo "--------------------------------------------------------------"
328	@echo ">>> stage 4.4: building everything"
329	@echo "--------------------------------------------------------------"
330	cd ${.CURDIR}; ${WMAKE} par-all
331
332
333WMAKE_TGTS=
334.if !defined(SUBDIR_OVERRIDE)
335WMAKE_TGTS+=	_worldtmp _legacy _bootstrap-tools
336.endif
337WMAKE_TGTS+=	_cleanobj _obj _build-tools
338.if !defined(SUBDIR_OVERRIDE)
339WMAKE_TGTS+=	_cross-tools
340.endif
341WMAKE_TGTS+=	_includes _libraries _depend everything
342
343buildworld: ${WMAKE_TGTS}
344.ORDER: ${WMAKE_TGTS}
345
346toolchain: ${WMAKE_TGTS:N_depend:Neverything}
347
348#
349# Use this to add checks to installworld/installkernel targets.
350#
351SPECIAL_INSTALLCHECKS=
352
353#
354# The following install-time check will see if the installation will
355# change the type used for time_t, and if it will, the target makes
356# sure that the user is expecting to make that change.
357#
358.if ${TARGET_ARCH} == "sparc64"
359SPECIAL_INSTALLCHECKS+=sparc64_installcheck
360
361CUR_TIMET!=	grep __time_t /usr/include/machine/_types.h | awk '{print $$2}'
362SRC_TIMET!=	grep __time_t ${.CURDIR}/sys/sparc64/include/_types.h | \
363		awk '{print $$2}'
364NEWSPARC_TIMETYPE?=${CUR_TIMET}
365THISHOST!=	hostname -s
366.if empty(THISHOST)
367THISHOST="name not set yet"
368.endif
369
370sparc64_installcheck:
371.if ${CUR_TIMET} != ${SRC_TIMET}
372	@echo
373.if ${NEWSPARC_TIMETYPE} != ${SRC_TIMET}
374	@echo "***  ERROR: This target would change the type used for time_t!"
375.else
376	@echo "* Note: This installation changes the type used for time_t."
377.endif
378	@echo "* "
379	@echo "* This host (${THISHOST}) has time_t defined as ${CUR_TIMET},"
380	@echo "* and this installation would change that to type ${SRC_TIMET}."
381.if ${NEWSPARC_TIMETYPE} != ${SRC_TIMET}
382	@echo "* "
383	@echo "* If that is *NOT* what you wanted, then you need to change the"
384	@echo "* typedef of __time_t in ${.CURDIR}/sys/sparc64/include/_types.h"
385	@echo "* from '${SRC_TIMET}' to '${CUR_TIMET}'.  After that you *MUST*"
386	@echo "* do a complete cleanworld, buildworld, buildkernel before you"
387	@echo "* retry the 'make' command.  Also read /usr/src/UPDATING.64BTT."
388	@echo "* "
389	@echo "* If that *is* what you want, then enter the commands:"
390	@echo "      NEWSPARC_TIMETYPE=${SRC_TIMET}"
391	@echo "      export NEWSPARC_TIMETYPE"
392	@echo "* and repeat your 'make' command."
393	@echo
394	false
395.endif
396	@echo
397.elif ${NEWSPARC_TIMETYPE} != ${SRC_TIMET}
398	@echo
399	@echo "***  ERROR: NEWSPARC_TIMETYPE is set to '${NEWSPARC_TIMETYPE}'"
400	@echo "***         but ${.CURDIR}/sys/sparc64/include/_types.h"
401	@echo "***         has __time_t defined as '${SRC_TIMET}'."
402	false
403.else
404	@# in sparc64_installcheck, all TIMETYPEs == '${CUR_TIMET}'
405.endif
406.endif
407
408#
409# installcheck
410#
411# Checks to be sure system is ready for installworld
412#
413CHECK_UIDS=
414CHECK_GIDS=
415.if !defined(NO_SENDMAIL)
416CHECK_UIDS+=	smmsp
417CHECK_GIDS+=	smmsp
418.endif
419.if !defined(NO_PF)
420CHECK_UIDS+=	proxy
421CHECK_GIDS+=	proxy authpf
422.endif
423installcheck: ${SPECIAL_INSTALLCHECKS}
424.for uid in ${CHECK_UIDS}
425	@if ! `id -u ${uid} >/dev/null 2>&1`; then \
426		echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
427		false; \
428	fi
429.endfor
430.for gid in ${CHECK_GIDS}
431	@if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
432		echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
433		false; \
434	fi
435.endfor
436
437#
438# distributeworld
439#
440# Distributes everything compiled by a `buildworld'.
441#
442# installworld
443#
444# Installs everything compiled by a 'buildworld'.
445#
446distributeworld installworld: installcheck
447	mkdir -p ${INSTALLTMP}
448	for prog in [ awk cap_mkdb cat chflags chmod chown \
449	    date echo egrep find grep \
450	    ln make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
451	    test true uname wc zic; do \
452		cp `which $$prog` ${INSTALLTMP}; \
453	done
454	cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
455	rm -rf ${INSTALLTMP}
456
457#
458# reinstall
459#
460# If you have a build server, you can NFS mount the source and obj directories
461# and do a 'make reinstall' on the *client* to install new binaries from the
462# most recent server build.
463#
464reinstall: ${SPECIAL_INSTALLCHECKS}
465	@echo "--------------------------------------------------------------"
466	@echo ">>> Making hierarchy"
467	@echo "--------------------------------------------------------------"
468	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
469	@echo
470	@echo "--------------------------------------------------------------"
471	@echo ">>> Installing everything"
472	@echo "--------------------------------------------------------------"
473	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
474
475redistribute:
476	@echo "--------------------------------------------------------------"
477	@echo ">>> Distributing everything"
478	@echo "--------------------------------------------------------------"
479	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
480
481#
482# buildkernel and installkernel
483#
484# Which kernels to build and/or install is specified by setting
485# KERNCONF. If not defined a GENERIC kernel is built/installed.
486# Only the existing (depending TARGET) config files are used
487# for building kernels and only the first of these is designated
488# as the one being installed.
489#
490# Note that we have to use TARGET instead of TARGET_ARCH when
491# we're in kernel-land. Since only TARGET_ARCH is (expected) to
492# be set to cross-build, we have to make sure TARGET is set
493# properly.
494
495.if !defined(KERNCONF) && defined(KERNEL)
496KERNCONF=	${KERNEL}
497KERNWARN=	yes
498.else
499KERNCONF?=	GENERIC
500.endif
501INSTKERNNAME?=	kernel
502
503KERNSRCDIR?=	${.CURDIR}/sys
504KRNLCONFDIR=	${KERNSRCDIR}/${TARGET}/conf
505KRNLOBJDIR=	${OBJTREE}${KERNSRCDIR}
506KERNCONFDIR?=	${KRNLCONFDIR}
507
508BUILDKERNELS=
509INSTALLKERNEL=
510.for _kernel in ${KERNCONF}
511.if exists(${KERNCONFDIR}/${_kernel})
512BUILDKERNELS+=	${_kernel}
513.if empty(INSTALLKERNEL)
514INSTALLKERNEL= ${_kernel}
515.endif
516.endif
517.endfor
518
519#
520# buildkernel
521#
522# Builds all kernels defined by BUILDKERNELS.
523#
524buildkernel:
525.if empty(BUILDKERNELS)
526	@echo "ERROR: Missing kernel configuration file(s) (${KERNCONF}).";
527	false
528.endif
529.if defined(KERNWARN)
530	@echo "--------------------------------------------------------------"
531	@echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
532	@echo "--------------------------------------------------------------"
533	@sleep 3
534.endif
535	@echo
536.for _kernel in ${BUILDKERNELS}
537	@echo "--------------------------------------------------------------"
538	@echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
539	@echo "--------------------------------------------------------------"
540	@echo "===> ${_kernel}"
541	mkdir -p ${KRNLOBJDIR}
542.if !defined(NO_KERNELCONFIG)
543	@echo
544	@echo "--------------------------------------------------------------"
545	@echo ">>> stage 1: configuring the kernel"
546	@echo "--------------------------------------------------------------"
547	cd ${KRNLCONFDIR}; \
548		PATH=${TMPPATH} \
549		    config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
550			${KERNCONFDIR}/${_kernel}
551.endif
552.if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
553	@echo
554	@echo "--------------------------------------------------------------"
555	@echo ">>> stage 2.1: cleaning up the object tree"
556	@echo "--------------------------------------------------------------"
557	cd ${KRNLOBJDIR}/${_kernel}; \
558	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} ${CLEANDIR}
559.endif
560	@echo
561	@echo "--------------------------------------------------------------"
562	@echo ">>> stage 2.2: rebuilding the object tree"
563	@echo "--------------------------------------------------------------"
564	cd ${KRNLOBJDIR}/${_kernel}; \
565	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} obj
566	@echo
567	@echo "--------------------------------------------------------------"
568	@echo ">>> stage 2.3: build tools"
569	@echo "--------------------------------------------------------------"
570	cd ${KRNLOBJDIR}/${_kernel}; \
571	    MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
572	    ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
573# XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
574.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
575.for target in obj depend all
576	cd ${.CURDIR}/sys/modules/aic7xxx/aicasm; \
577	    MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
578	    ${MAKE} -DNO_CPU_CFLAGS ${target}
579.endfor
580.endif
581.if !defined(NO_KERNELDEPEND)
582	@echo
583	@echo "--------------------------------------------------------------"
584	@echo ">>> stage 3.1: making dependencies"
585	@echo "--------------------------------------------------------------"
586	cd ${KRNLOBJDIR}/${_kernel}; \
587	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} depend -DNO_MODULES_OBJ
588.endif
589	@echo
590	@echo "--------------------------------------------------------------"
591	@echo ">>> stage 3.2: building everything"
592	@echo "--------------------------------------------------------------"
593	cd ${KRNLOBJDIR}/${_kernel}; \
594	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all -DNO_MODULES_OBJ
595	@echo "--------------------------------------------------------------"
596	@echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
597	@echo "--------------------------------------------------------------"
598.endfor
599
600#
601# installkernel, etc.
602#
603# Install the kernel defined by INSTALLKERNEL
604#
605installkernel installkernel.debug \
606reinstallkernel reinstallkernel.debug: ${SPECIAL_INSTALLCHECKS}
607.if empty(INSTALLKERNEL)
608	@echo "ERROR: No kernel \"${KERNCONF}\" to install."
609	false
610.endif
611	@echo "--------------------------------------------------------------"
612	@echo ">>> Making hierarchy"
613	@echo "--------------------------------------------------------------"
614	cd ${.CURDIR}; \
615	    ${CROSSENV} PATH=${TMPPATH} ${MAKE} -f Makefile.inc1 hierarchy
616	@echo
617	@echo "--------------------------------------------------------------"
618	@echo ">>> Installing kernel"
619	@echo "--------------------------------------------------------------"
620	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
621	    ${CROSSENV} PATH=${TMPPATH} \
622	    ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
623
624#
625# update
626#
627# Update the source tree, by running sup and/or running cvs to update to the
628# latest copy.
629#
630update:
631.if defined(SUP_UPDATE)
632	@echo "--------------------------------------------------------------"
633	@echo ">>> Running ${SUP}"
634	@echo "--------------------------------------------------------------"
635.if defined(SUPFILE)
636	@${SUP} ${SUPFLAGS} ${SUPFILE}
637.endif
638.if defined(SUPFILE1)
639	@${SUP} ${SUPFLAGS} ${SUPFILE1}
640.endif
641.if defined(SUPFILE2)
642	@${SUP} ${SUPFLAGS} ${SUPFILE2}
643.endif
644.if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
645	@${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
646.endif
647.if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
648	@${SUP} ${SUPFLAGS} ${DOCSUPFILE}
649.endif
650.endif
651.if defined(CVS_UPDATE)
652	@echo "--------------------------------------------------------------"
653	@echo ">>> Updating ${.CURDIR} from cvs repository" ${CVSROOT}
654	@echo "--------------------------------------------------------------"
655	cd ${.CURDIR}; ${CVS} -R -q update -A -P -d
656.endif
657
658#
659# ------------------------------------------------------------------------
660#
661# From here onwards are utility targets used by the 'make world' and
662# related targets.  If your 'world' breaks, you may like to try to fix
663# the problem and manually run the following targets to attempt to
664# complete the build.  Beware, this is *not* guaranteed to work, you
665# need to have a pretty good grip on the current state of the system
666# to attempt to manually finish it.  If in doubt, 'make world' again.
667#
668
669#
670# legacy: Build compatibility shims for the next three targets
671#
672legacy:
673.for _tool in tools/build
674	@${ECHODIR} "===> ${_tool}"; \
675	    cd ${.CURDIR}/${_tool}; \
676	    ${MAKE} DIRPRFX=${_tool}/ obj; \
677	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
678	    ${MAKE} DIRPRFX=${_tool}/ depend; \
679	    ${MAKE} DIRPRFX=${_tool}/ all; \
680	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
681.endfor
682
683#
684# bootstrap-tools: Build tools needed for compatibility
685#
686.if !defined(NOGAMES)
687_strfile=	games/fortune/strfile
688.endif
689
690.if !defined(NO_CXX)
691_gperf=	gnu/usr.bin/gperf
692.if ${BOOTSTRAPPING} < 500113
693_groff=		gnu/usr.bin/groff
694.else
695_groff=		gnu/usr.bin/groff/tmac
696.endif
697.endif
698
699.if ${BOOTSTRAPPING} < 502102
700_lex=		usr.bin/lex
701.endif
702
703.if ${BOOTSTRAPPING} < 450005 || \
704    ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500034
705_uudecode=	usr.bin/uudecode
706.endif
707
708.if ${BOOTSTRAPPING} < 430002 || \
709    ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500019
710_xargs=		usr.bin/xargs
711.endif
712
713.if ${BOOTSTRAPPING} < 430002 || \
714    ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500018
715_yacc=		usr.bin/yacc
716.endif
717
718.if !defined(NO_RESCUE) && \
719    ${BOOTSTRAPPING} < 501100
720_crunchgen=	usr.sbin/crunch/crunchgen
721.endif
722
723.if ${BOOTSTRAPPING} < 501114
724_gensnmptree=	usr.sbin/bsnmpd/gensnmptree
725.endif
726
727.if ${BOOTSTRAPPING} < 500019
728_kbdcontrol=	usr.sbin/kbdcontrol
729.endif
730
731bootstrap-tools:
732.for _tool in \
733    ${_strfile} \
734    ${_gperf} \
735    ${_groff} \
736    gnu/usr.bin/texinfo \
737    usr.bin/colldef \
738    ${_lex} \
739    usr.bin/makewhatis \
740    usr.bin/rpcgen \
741    ${_uudecode} \
742    ${_xargs} \
743    usr.bin/xinstall \
744    ${_yacc} \
745    usr.sbin/config \
746    ${_crunchgen} \
747    ${_gensnmptree} \
748    ${_kbdcontrol}
749	@${ECHODIR} "===> ${_tool}"; \
750		cd ${.CURDIR}/${_tool}; \
751		${MAKE} DIRPRFX=${_tool}/ obj; \
752		${MAKE} DIRPRFX=${_tool}/ depend; \
753		${MAKE} DIRPRFX=${_tool}/ all; \
754		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
755.endfor
756
757#
758# build-tools: Build special purpose build tools
759#
760.if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
761_aicasm= sys/modules/aic7xxx/aicasm
762.endif
763
764.if !defined(NOSHARE)
765_share=	share/syscons/scrnmaps
766.endif
767
768.if !defined(NO_FORTRAN)
769_fortran= gnu/usr.bin/cc/f771
770.endif
771
772.if !defined(NO_KERBEROS) && !defined(NOCRYPT) && !defined(NO_OPENSSL)
773_kerberos5_tools= kerberos5/tools
774.endif
775
776.if !defined(NO_RESCUE)
777_rescue= rescue/rescue
778.endif
779
780build-tools:
781.for _tool in \
782    bin/csh \
783    bin/sh \
784    ${_rescue} \
785    gnu/usr.bin/cc/cc_tools \
786    ${_fortran} \
787    lib/libncurses \
788    ${_share} \
789    ${_aicasm} \
790    usr.bin/awk \
791    usr.bin/file \
792    usr.sbin/sysinstall
793	@${ECHODIR} "===> ${_tool}"; \
794		cd ${.CURDIR}/${_tool}; \
795		${MAKE} DIRPRFX=${_tool}/ obj; \
796		${MAKE} DIRPRFX=${_tool}/ build-tools
797.endfor
798.for _tool in \
799    ${_kerberos5_tools}
800	@${ECHODIR} "===> ${_tool}"; \
801		cd ${.CURDIR}/${_tool}; \
802		${MAKE} DIRPRFX=${_tool}/ obj; \
803		${MAKE} DIRPRFX=${_tool}/ depend; \
804		${MAKE} DIRPRFX=${_tool}/ all
805.endfor
806
807#
808# cross-tools: Build cross-building tools
809#
810.if ${TARGET_ARCH} == "sparc64" && ${TARGET_ARCH} != ${MACHINE_ARCH} && \
811    ${BOOTSTRAPPING} < 500037
812_elf2aout=	usr.bin/elf2aout
813.endif
814
815.if ${TARGET_ARCH} == "i386" && ${TARGET_ARCH} != ${MACHINE_ARCH}
816_btxld=		usr.sbin/btxld
817.endif
818
819.if (!defined(NO_RESCUE) || \
820    defined(RELEASEDIR)) && \
821    (${TARGET_ARCH} != ${MACHINE_ARCH} || ${BOOTSTRAPPING} < 501101)
822_crunchide=	usr.sbin/crunch/crunchide
823.endif
824
825.if ${TARGET_ARCH} == "alpha" && ${TARGET_ARCH} != ${MACHINE_ARCH}
826_elf2exe=	usr.sbin/elf2exe
827.endif
828
829.if ${TARGET_ARCH} == "i386" && ${TARGET_ARCH} != ${MACHINE_ARCH} && \
830    defined(RELEASEDIR)
831_kgzip=		usr.sbin/kgzip
832.endif
833
834cross-tools:
835.for _tool in \
836    gnu/usr.bin/binutils \
837    gnu/usr.bin/cc \
838    ${_elf2aout} \
839    usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
840    ${_btxld} \
841    ${_crunchide} \
842    ${_elf2exe} \
843    ${_kgzip}
844	@${ECHODIR} "===> ${_tool}"; \
845		cd ${.CURDIR}/${_tool}; \
846		${MAKE} DIRPRFX=${_tool}/ obj; \
847		${MAKE} DIRPRFX=${_tool}/ depend; \
848		${MAKE} DIRPRFX=${_tool}/ all; \
849		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
850.endfor
851
852#
853# hierarchy - ensure that all the needed directories are present
854#
855hierarchy:
856	cd ${.CURDIR}/etc;		${MAKE} distrib-dirs
857
858#
859# libraries - build all libraries, and install them under ${DESTDIR}.
860#
861# The list of libraries with dependents (${_prebuild_libs}) and their
862# interdependencies (__L) are built automatically by the
863# ${.CURDIR}/tools/make_libdeps.sh script.
864#
865libraries:
866	cd ${.CURDIR}; \
867	    ${MAKE} -f Makefile.inc1 _startup_libs; \
868	    ${MAKE} -f Makefile.inc1 _prebuild_libs; \
869	    ${MAKE} -f Makefile.inc1 _generic_libs;
870
871# These dependencies are not automatically generated:
872#
873# gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
874# shared libraries for ELF.
875#
876_startup_libs=	gnu/lib/csu gnu/lib/libgcc
877.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
878_startup_libs+=	lib/csu/${MACHINE_ARCH}-elf
879.else
880_startup_libs+=	lib/csu/${MACHINE_ARCH}
881.endif
882
883_prebuild_libs=
884
885_generic_libs=	gnu/lib
886
887.if !defined(NO_KERBEROS) && !defined(NOCRYPT) && !defined(NO_OPENSSL)
888_prebuild_libs+=	kerberos5/lib/libasn1
889_prebuild_libs+=	kerberos5/lib/libgssapi
890_prebuild_libs+=	kerberos5/lib/libkrb5
891_prebuild_libs+=	kerberos5/lib/libroken
892_generic_libs+=	kerberos5/lib
893.endif
894
895_prebuild_libs+= lib/libcom_err lib/libcrypt lib/libexpat \
896		lib/libkvm lib/libmd \
897		lib/libncurses lib/libnetgraph lib/libopie lib/libpam \
898		lib/libradius lib/librpcsvc \
899		lib/libsbuf lib/libtacplus lib/libutil lib/libypclnt \
900		lib/libz lib/msun
901
902lib/libopie__L lib/libradius__L lib/libtacplus__L: lib/libmd__L
903lib/libypclnt__L: lib/librpcsvc__L
904
905_generic_libs+=	lib
906
907.if !defined(NOCRYPT)
908.if !defined(NO_OPENSSL)
909_prebuild_libs+=	secure/lib/libcrypto secure/lib/libssl
910.if !defined(NO_OPENSSH)
911_prebuild_libs+=	secure/lib/libssh
912secure/lib/libssh__L: secure/lib/libcrypto__L lib/libz__L
913.endif
914.endif
915_generic_libs+=	secure/lib
916.endif
917
918_generic_libs+=	usr.bin/lex/lib
919
920.if ${MACHINE_ARCH} == "i386"
921_generic_libs+=	usr.sbin/pcvt/keycap
922.endif
923
924.for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
925${_lib}__L: .PHONY
926.if exists(${.CURDIR}/${_lib})
927	@${ECHODIR} "===> ${_lib}"; \
928		cd ${.CURDIR}/${_lib}; \
929		${MAKE} DIRPRFX=${_lib}/ depend; \
930		${MAKE} DIRPRFX=${_lib}/ all; \
931		${MAKE} DIRPRFX=${_lib}/ install
932.endif
933.endfor
934
935# libpam is special: we need to build static PAM modules before
936# static PAM library, and dynamic PAM library before dynamic PAM
937# modules.
938lib/libpam__L: .PHONY
939	@${ECHODIR} "===> lib/libpam"; \
940		cd ${.CURDIR}/lib/libpam; \
941		${MAKE} DIRPRFX=lib/libpam/ depend; \
942		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
943		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
944
945_startup_libs: ${_startup_libs:S/$/__L/}
946_prebuild_libs: ${_prebuild_libs:S/$/__L/}
947_generic_libs: ${_generic_libs:S/$/__L/}
948
949.for __target in all clean cleandepend cleandir depend includes obj
950.for entry in ${SUBDIR}
951${entry}.${__target}__D: .PHONY
952	@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
953		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
954		edir=${entry}.${MACHINE_ARCH}; \
955		cd ${.CURDIR}/$${edir}; \
956	else \
957		${ECHODIR} "===> ${DIRPRFX}${entry}"; \
958		edir=${entry}; \
959		cd ${.CURDIR}/$${edir}; \
960	fi; \
961	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
962.endfor
963par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
964.endfor
965
966.include <bsd.subdir.mk>
967