Makefile revision 117229
12061Sjkh#
250479Speter# $FreeBSD: head/Makefile 117229 2003-07-04 14:27:06Z ru $
32061Sjkh#
438666Sjb# The user-driven targets are:
532427Sjb#
6111131Sru# universe            - *Really* build *everything* (buildworld and
7111131Sru#                       all kernels on all architectures).
838666Sjb# buildworld          - Rebuild *everything*, including glue to help do
938666Sjb#                       upgrades.
1038666Sjb# installworld        - Install everything built by "buildworld".
1138666Sjb# world               - buildworld + installworld.
1264049Salex# buildkernel         - Rebuild the kernel and the kernel-modules.
1364049Salex# installkernel       - Install the kernel and the kernel-modules.
14116679Ssimokawa# installkernel.debug
1566071Smarkm# reinstallkernel     - Reinstall the kernel and the kernel-modules.
16116679Ssimokawa# reinstallkernel.debug
1773504Sobrien# kernel              - buildkernel + installkernel.
1838666Sjb# update              - Convenient way to update your source tree (cvs).
1938666Sjb# most                - Build user commands, no libraries or include files.
2038666Sjb# installmost         - Install user commands, no libraries or include files.
2132427Sjb#
2238666Sjb# This makefile is simple by design. The FreeBSD make automatically reads
23108451Sschweikh# the /usr/share/mk/sys.mk unless the -m argument is specified on the
2438666Sjb# command line. By keeping this makefile simple, it doesn't matter too
2538666Sjb# much how different the installed mk files are from those in the source
2638666Sjb# tree. This makefile executes a child make process, forcing it to use
2738666Sjb# the mk files from the source tree which are supposed to DTRT.
2817308Speter#
2991606Skeramida# The user-driven targets (as listed above) are implemented in Makefile.inc1.
3019175Sbde#
3196205Sjwd# If you want to build your system from source be sure that /usr/obj has
3296205Sjwd# at least 400MB of diskspace available.
3338042Sbde#
3496205Sjwd# For individuals wanting to build from the sources currently on their
3596205Sjwd# system, the simple instructions are:
3638042Sbde#
3796205Sjwd# 1.  `cd /usr/src'  (or to the directory containing your source tree).
3896205Sjwd# 2.  `make world'
3917308Speter#
4096205Sjwd# For individuals wanting to upgrade their sources (even if only a
4196205Sjwd# delta of a few days):
4217308Speter#
4396205Sjwd# 1.  `cd /usr/src'       (or to the directory containing your source tree).
4496205Sjwd# 2.  `make buildworld'
4596205Sjwd# 3.  `make buildkernel KERNCONF=YOUR_KERNEL_HERE'     (default is GENERIC).
4696205Sjwd# 4.  `make installkernel KERNCONF=YOUR_KERNEL_HERE'   (default is GENERIC).
4796205Sjwd# 5.  `reboot'        (in single user mode: boot -s from the loader prompt).
4896205Sjwd# 6.  `mergemaster -p'
4996205Sjwd# 7.  `make installworld'
5096205Sjwd# 8.  `mergemaster'
5196205Sjwd# 9.  `reboot'
5296205Sjwd#
5396205Sjwd# See src/UPDATING `COMMON ITEMS' for more complete information.
5496205Sjwd#
5598775Sdillon# If TARGET_ARCH=arch (e.g. ia64, sparc64, ...) is specified you can
5698723Sdillon# cross build world for other architectures using the buildworld target,
5798723Sdillon# and once the world is built you can cross build a kernel using the
5898723Sdillon# buildkernel target.
5998723Sdillon#
6038666Sjb# Define the user-driven targets. These are listed here in alphabetical
6138666Sjb# order, but that's not important.
6217308Speter#
6395509SruTGTS=	all all-man buildkernel buildworld checkdpadd clean \
6495793Sru	cleandepend cleandir depend distribute distributeworld everything \
65116679Ssimokawa	hierarchy install installcheck installkernel installkernel.debug\
66116679Ssimokawa	reinstallkernel reinstallkernel.debug installmost installworld \
67116679Ssimokawa	libraries lint maninstall \
6895146Sgshapiro	mk most obj objlink regress rerelease tags update
692061Sjkh
7097769SruBITGTS=	files includes
7197252SruBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
7297252Sru
7395730Sru.ORDER: buildworld installworld
7495793Sru.ORDER: buildworld distributeworld
75111617Sru.ORDER: buildworld buildkernel
7695730Sru.ORDER: buildkernel installkernel
77116679Ssimokawa.ORDER: buildkernel installkernel.debug
7895730Sru.ORDER: buildkernel reinstallkernel
79116679Ssimokawa.ORDER: buildkernel reinstallkernel.debug
8095730Sru
81110035SruPATH=	/sbin:/bin:/usr/sbin:/usr/bin
82107516SruMAKEOBJDIRPREFIX?=	/usr/obj
83110035SruMAKEPATH=	${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}
84117229SruBINMAKE=	PATH=${PATH} \
85110035Sru	`if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \
86117229Sru	-m ${.CURDIR}/share/mk
87117229Sru_MAKE=	${BINMAKE} -f Makefile.inc1
8854324Smarcel
8917308Speter#
9038666Sjb# Handle the user-driven targets, using the source relative mk files.
9117308Speter#
9297252Sru${TGTS} ${BITGTS}: upgrade_checks
9338666Sjb	@cd ${.CURDIR}; \
94110035Sru		${_MAKE} ${.TARGET}
952302Spaul
9639206Sjkh# Set a reasonable default
9739206Sjkh.MAIN:	all
9839206Sjkh
9973349SruSTARTTIME!= LC_ALL=C date
10017308Speter#
10154324Smarcel# world
10254324Smarcel#
10354324Smarcel# Attempt to rebuild and reinstall *everything*, with reasonable chance of
10454324Smarcel# success, regardless of how old your existing system is.
10554324Smarcel#
10654324Smarcelworld: upgrade_checks
10754324Smarcel	@echo "--------------------------------------------------------------"
108103436Speter	@echo ">>> elf make world started on ${STARTTIME}"
10954324Smarcel	@echo "--------------------------------------------------------------"
11054324Smarcel.if target(pre-world)
11154324Smarcel	@echo
11254324Smarcel	@echo "--------------------------------------------------------------"
11354324Smarcel	@echo ">>> Making 'pre-world' target"
11454324Smarcel	@echo "--------------------------------------------------------------"
115110035Sru	@cd ${.CURDIR}; ${_MAKE} pre-world
11654324Smarcel.endif
117110035Sru	@cd ${.CURDIR}; ${_MAKE} buildworld
118110035Sru	@cd ${.CURDIR}; ${_MAKE} -B installworld
11954324Smarcel.if target(post-world)
12054324Smarcel	@echo
12154324Smarcel	@echo "--------------------------------------------------------------"
12254324Smarcel	@echo ">>> Making 'post-world' target"
12354324Smarcel	@echo "--------------------------------------------------------------"
124110035Sru	@cd ${.CURDIR}; ${_MAKE} post-world
12554324Smarcel.endif
12654324Smarcel	@echo
12754324Smarcel	@echo "--------------------------------------------------------------"
128103436Speter	@printf ">>> elf make world completed on `LC_ALL=C date`\n                       (started ${STARTTIME})\n"
12954324Smarcel	@echo "--------------------------------------------------------------"
13054324Smarcel
13154324Smarcel#
13295730Sru# kernel
13395730Sru#
13495730Sru# Short hand for `make buildkernel installkernel'
13595730Sru#
13695730Srukernel: buildkernel installkernel
13795730Sru
13895730Sru#
13938666Sjb# Perform a few tests to determine if the installed tools are adequate
140107374Sru# for building the world.
14117308Speter#
14255678Smarcelupgrade_checks:
143110035Sru	@if ! (cd ${.CURDIR}/tools/regression/usr.bin/make && \
144116696Sru	    PATH=${PATH} ${MAKE} >/dev/null 2>&1); \
145110035Sru	then \
146110035Sru	    (cd ${.CURDIR} && make make); \
147110035Sru	fi
1482061Sjkh
14917308Speter#
150107516Sru# Upgrade make(1) to the current version using the installed
151107374Sru# headers, libraries and tools.
15255678Smarcel#
153107516SruMMAKEENV=	MAKEOBJDIRPREFIX=${MAKEPATH} \
154107516Sru		DESTDIR= \
155107516Sru		INSTALL="sh ${.CURDIR}/tools/install.sh"
156107516SruMMAKE=		${MMAKEENV} make \
157107516Sru		-D_UPGRADING \
158107516Sru		-DNOMAN -DNOSHARED \
159107516Sru		-DNO_CPU_CFLAGS -DNO_WERROR
160107516Sru
16155678Smarcelmake:
16255678Smarcel	@echo
16355678Smarcel	@echo "--------------------------------------------------------------"
164116696Sru	@echo ">>> Building an up-to-date make(1)"
16555678Smarcel	@echo "--------------------------------------------------------------"
16655678Smarcel	@cd ${.CURDIR}/usr.bin/make; \
167107516Sru		${MMAKE} obj && \
168107516Sru		${MMAKE} depend && \
169107516Sru		${MMAKE} all && \
170107516Sru		${MMAKE} install DESTDIR=${MAKEPATH} BINDIR=
17155678Smarcel
17255678Smarcel#
173111131Sru# universe
174111131Sru#
175111131Sru# Attempt to rebuild *everything* for all supported architectures,
176111131Sru# with reasonable chance of success, regardless of how old your
177111131Sru# existing system is.
178111131Sru#
179111131Srui386_mach=	pc98
180103985Sphkuniverse:
181103985Sphk	@echo "--------------------------------------------------------------"
182103985Sphk	@echo ">>> make universe started on ${STARTTIME}"
183103985Sphk	@echo "--------------------------------------------------------------"
184111089Sphk.for arch in i386 sparc64 alpha ia64
185111131Sru.for mach in ${arch} ${${arch}_mach}
186111131Sru	@echo ">> ${mach} started on `LC_ALL=C date`"
187111131Sru	-cd ${.CURDIR} && ${MAKE} buildworld \
188111131Sru	    TARGET_ARCH=${arch} TARGET=${mach} \
189111131Sru	    __MAKE_CONF=/dev/null \
190111131Sru	    > _.${mach}.buildworld 2>&1
191111131Sru	@echo ">> ${mach} buildworld completed on `LC_ALL=C date`"
192111131Sru.if exists(${.CURDIR}/sys/${mach}/conf/NOTES)
193111131Sru	-cd ${.CURDIR}/sys/${mach}/conf && ${MAKE} LINT \
194111133Sru	    > ${.CURDIR}/_.${mach}.makeLINT 2>&1
195103985Sphk.endif
196111131Sru	cd ${.CURDIR} && ${MAKE} buildkernels TARGET_ARCH=${arch} TARGET=${mach}
197111131Sru	@echo ">> ${mach} completed on `LC_ALL=C date`"
198103985Sphk.endfor
199111131Sru.endfor
200103985Sphk	@echo "--------------------------------------------------------------"
201107884Simp	@printf ">>> make universe completed on `LC_ALL=C date`\n                      (started ${STARTTIME})\n"
202103985Sphk	@echo "--------------------------------------------------------------"
203103985Sphk
204111131SruKERNCONFS!=	cd ${.CURDIR}/sys/${TARGET}/conf && \
205111131Sru		find [A-Z]*[A-Z] -type f -maxdepth 0 ! -name NOTES
206103985Sphk
207103985Sphkbuildkernels:
208111131Sru.for kernel in ${KERNCONFS}
209111131Sru	-cd ${.CURDIR} && ${MAKE} buildkernel \
210111131Sru	    KERNCONF=${kernel} \
211111131Sru	    __MAKE_CONF=/dev/null \
212111131Sru	    > _.${TARGET}.${kernel} 2>&1
213103985Sphk.endfor
214