Makefile revision 127360
1215976Sjmallett# 2232812Sjmallett# $FreeBSD: head/Makefile 127360 2004-03-24 08:26:22Z ru $ 3215976Sjmallett# 4215976Sjmallett# The user-driven targets are: 5215976Sjmallett# 6215976Sjmallett# universe - *Really* build *everything* (buildworld and 7215976Sjmallett# all kernels on all architectures). 8215976Sjmallett# buildworld - Rebuild *everything*, including glue to help do 9215976Sjmallett# upgrades. 10215976Sjmallett# installworld - Install everything built by "buildworld". 11215976Sjmallett# world - buildworld + installworld. 12215976Sjmallett# buildkernel - Rebuild the kernel and the kernel-modules. 13215976Sjmallett# installkernel - Install the kernel and the kernel-modules. 14215976Sjmallett# installkernel.debug 15215976Sjmallett# reinstallkernel - Reinstall the kernel and the kernel-modules. 16215976Sjmallett# reinstallkernel.debug 17215976Sjmallett# kernel - buildkernel + installkernel. 18232812Sjmallett# update - Convenient way to update your source tree (cvs). 19215976Sjmallett# 20215976Sjmallett# This makefile is simple by design. The FreeBSD make automatically reads 21215976Sjmallett# the /usr/share/mk/sys.mk unless the -m argument is specified on the 22215976Sjmallett# command line. By keeping this makefile simple, it doesn't matter too 23215976Sjmallett# much how different the installed mk files are from those in the source 24215976Sjmallett# tree. This makefile executes a child make process, forcing it to use 25215976Sjmallett# the mk files from the source tree which are supposed to DTRT. 26215976Sjmallett# 27215976Sjmallett# The user-driven targets (as listed above) are implemented in Makefile.inc1. 28215976Sjmallett# 29232812Sjmallett# If you want to build your system from source be sure that /usr/obj has 30215976Sjmallett# at least 400MB of diskspace available. 31215976Sjmallett# 32215976Sjmallett# For individuals wanting to build from the sources currently on their 33215976Sjmallett# system, the simple instructions are: 34215976Sjmallett# 35215976Sjmallett# 1. `cd /usr/src' (or to the directory containing your source tree). 36215976Sjmallett# 2. `make world' 37215976Sjmallett# 38215976Sjmallett# For individuals wanting to upgrade their sources (even if only a 39215976Sjmallett# delta of a few days): 40215976Sjmallett# 41215976Sjmallett# 1. `cd /usr/src' (or to the directory containing your source tree). 42215976Sjmallett# 2. `make buildworld' 43215976Sjmallett# 3. `make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 44215976Sjmallett# 4. `make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC). 45215976Sjmallett# 5. `reboot' (in single user mode: boot -s from the loader prompt). 46215976Sjmallett# 6. `mergemaster -p' 47215976Sjmallett# 7. `make installworld' 48215976Sjmallett# 8. `mergemaster' 49215976Sjmallett# 9. `reboot' 50215976Sjmallett# 51215976Sjmallett# See src/UPDATING `COMMON ITEMS' for more complete information. 52232812Sjmallett# 53232812Sjmallett# If TARGET_ARCH=arch (e.g. ia64, sparc64, ...) is specified you can 54215976Sjmallett# cross build world for other architectures using the buildworld target, 55215976Sjmallett# and once the world is built you can cross build a kernel using the 56215976Sjmallett# buildkernel target. 57215976Sjmallett# 58215976Sjmallett# Define the user-driven targets. These are listed here in alphabetical 59232812Sjmallett# order, but that's not important. 60215976Sjmallett# 61215976Sjmallett# Targets that begin with underscore are internal targets intended for 62215976Sjmallett# developer convenience only. They are intentionally not documented and 63215976Sjmallett# completely subject to change without notice. 64215976Sjmallett# 65215976SjmallettTGTS= all all-man buildkernel buildworld checkdpadd clean \ 66215976Sjmallett cleandepend cleandir depend distribute distributeworld everything \ 67215976Sjmallett hierarchy install installcheck installkernel installkernel.debug\ 68215976Sjmallett reinstallkernel reinstallkernel.debug installworld \ 69215976Sjmallett libraries lint maninstall \ 70232812Sjmallett obj objlink regress rerelease tags toolchain update \ 71215976Sjmallett _worldtmp _legacy _bootstrap-tools _cleanobj _obj \ 72215976Sjmallett _build-tools _cross-tools _includes _libraries _depend 73215976Sjmallett 74215976SjmallettBITGTS= files includes 75215976SjmallettBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/} 76215976SjmallettTGTS+= ${BITGTS} 77215976Sjmallett 78215976Sjmallett.ORDER: buildworld installworld 79215976Sjmallett.ORDER: buildworld distributeworld 80215976Sjmallett.ORDER: buildworld buildkernel 81215976Sjmallett.ORDER: buildkernel installkernel 82215976Sjmallett.ORDER: buildkernel installkernel.debug 83215976Sjmallett.ORDER: buildkernel reinstallkernel 84215976Sjmallett.ORDER: buildkernel reinstallkernel.debug 85215976Sjmallett 86215976SjmallettPATH= /sbin:/bin:/usr/sbin:/usr/bin 87215976SjmallettMAKEOBJDIRPREFIX?= /usr/obj 88215976SjmallettMAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE} 89215976SjmallettBINMAKE= \ 90215976Sjmallett `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \ 91215976Sjmallett -m ${.CURDIR}/share/mk 92215976Sjmallett_MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1 93215976Sjmallett 94215976Sjmallett# 95215976Sjmallett# Make sure we have an up-to-date make(1). Only world and buildworld 96215976Sjmallett# should do this as those are the initial targets used for upgrades. 97215976Sjmallett# The user can define ALWAYS_CHECK_MAKE to have this check performed 98215976Sjmallett# for all targets. 99215976Sjmallett# 100215976Sjmallett.if defined(ALWAYS_CHECK_MAKE) 101215976Sjmallett${TGTS}: upgrade_checks 102215976Sjmallett.else 103215976Sjmallettbuildworld: upgrade_checks 104215976Sjmallett.endif 105232812Sjmallett 106232812Sjmallett# 107232812Sjmallett# This 'cleanworld' target is not included in TGTS, because it is not a 108232812Sjmallett# recursive target. All of the work for it is done right here. It is 109215976Sjmallett# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be 110215976Sjmallett# created by bsd.obj.mk, except that we don't want to .include that file 111215976Sjmallett# in this makefile. 112215976Sjmallett# 113215976Sjmallett# In the following, the first 'rm' in a series will usually remove all 114215976Sjmallett# files and directories. If it does not, then there are probably some 115215976Sjmallett# files with chflags set, so this unsets them and tries the 'rm' a 116215976Sjmallett# second time. There are situations where this target will be cleaning 117215976Sjmallett# some directories via more than one method, but that duplication is 118215976Sjmallett# needed to correctly handle all the possible situations. 119215976Sjmallett# 120215976SjmallettBW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR} 121232812Sjmallettcleanworld: 122232812Sjmallett.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR} 123232812Sjmallett.if exists(${BW_CANONICALOBJDIR}/) 124232812Sjmallett -rm -rf ${BW_CANONICALOBJDIR}/* 125215976Sjmallett chflags -R 0 ${BW_CANONICALOBJDIR} 126215976Sjmallett rm -rf ${BW_CANONICALOBJDIR}/* 127215976Sjmallett.endif 128215976Sjmallett # To be safe in this case, fall back to a 'make cleandir' 129215976Sjmallett @cd ${.CURDIR}; ${_MAKE} cleandir 130215976Sjmallett.else 131215976Sjmallett -rm -rf ${.OBJDIR}/* 132215976Sjmallett chflags -R 0 ${.OBJDIR} 133215976Sjmallett rm -rf ${.OBJDIR}/* 134215976Sjmallett.endif 135215976Sjmallett 136215976Sjmallett# 137232812Sjmallett# Handle the user-driven targets, using the source relative mk files. 138232812Sjmallett# 139232812Sjmallett 140232812Sjmallett${TGTS}: 141215976Sjmallett @cd ${.CURDIR}; \ 142215976Sjmallett ${_MAKE} ${.TARGET} 143215976Sjmallett 144215976Sjmallett# Set a reasonable default 145215976Sjmallett.MAIN: all 146215976Sjmallett 147215976Sjmallett.if make(world) 148215976SjmallettSTARTTIME!= LC_ALL=C date 149215976Sjmallett.endif 150215976Sjmallett# 151215976Sjmallett# world 152215976Sjmallett# 153232812Sjmallett# Attempt to rebuild and reinstall *everything*, with reasonable chance of 154232812Sjmallett# success, regardless of how old your existing system is. 155232812Sjmallett# 156232812Sjmallettworld: upgrade_checks 157215976Sjmallett @echo "--------------------------------------------------------------" 158215976Sjmallett @echo ">>> make world started on ${STARTTIME}" 159215976Sjmallett @echo "--------------------------------------------------------------" 160215976Sjmallett.if target(pre-world) 161215976Sjmallett @echo 162215976Sjmallett @echo "--------------------------------------------------------------" 163215976Sjmallett @echo ">>> Making 'pre-world' target" 164215976Sjmallett @echo "--------------------------------------------------------------" 165215976Sjmallett @cd ${.CURDIR}; ${_MAKE} pre-world 166215976Sjmallett.endif 167215976Sjmallett @cd ${.CURDIR}; ${_MAKE} buildworld 168215976Sjmallett @cd ${.CURDIR}; ${_MAKE} -B installworld 169232812Sjmallett.if target(post-world) 170232812Sjmallett @echo 171232812Sjmallett @echo "--------------------------------------------------------------" 172232812Sjmallett @echo ">>> Making 'post-world' target" 173215976Sjmallett @echo "--------------------------------------------------------------" 174215976Sjmallett @cd ${.CURDIR}; ${_MAKE} post-world 175215976Sjmallett.endif 176215976Sjmallett @echo 177215976Sjmallett @echo "--------------------------------------------------------------" 178215976Sjmallett @echo ">>> make world completed on `LC_ALL=C date`" 179215976Sjmallett @echo " (started ${STARTTIME})" 180215976Sjmallett @echo "--------------------------------------------------------------" 181215976Sjmallett 182215976Sjmallett# 183215976Sjmallett# kernel 184215976Sjmallett# 185232812Sjmallett# Short hand for `make buildkernel installkernel' 186232812Sjmallett# 187232812Sjmallettkernel: buildkernel installkernel 188232812Sjmallett 189215976Sjmallett# 190215976Sjmallett# Perform a few tests to determine if the installed tools are adequate 191215976Sjmallett# for building the world. 192215976Sjmallett# 193215976Sjmallettupgrade_checks: 194215976Sjmallett @if ! (cd ${.CURDIR}/tools/regression/usr.bin/make && \ 195215976Sjmallett PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \ 196215976Sjmallett then \ 197215976Sjmallett (cd ${.CURDIR} && make make); \ 198215976Sjmallett fi 199215976Sjmallett 200215976Sjmallett# 201232812Sjmallett# Upgrade make(1) to the current version using the installed 202232812Sjmallett# headers, libraries and tools. 203232812Sjmallett# 204232812SjmallettMMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \ 205215976Sjmallett DESTDIR= \ 206215976Sjmallett INSTALL="sh ${.CURDIR}/tools/install.sh" 207215976SjmallettMMAKE= ${MMAKEENV} make \ 208215976Sjmallett -D_UPGRADING \ 209215976Sjmallett -DNOMAN -DNOSHARED \ 210215976Sjmallett -DNO_CPU_CFLAGS -DNO_WERROR 211215976Sjmallett 212215976Sjmallettmake: .PHONY 213215976Sjmallett @echo 214215976Sjmallett @echo "--------------------------------------------------------------" 215215976Sjmallett @echo ">>> Building an up-to-date make(1)" 216215976Sjmallett @echo "--------------------------------------------------------------" 217232812Sjmallett @cd ${.CURDIR}/usr.bin/make; \ 218232812Sjmallett ${MMAKE} obj && \ 219232812Sjmallett ${MMAKE} depend && \ 220232812Sjmallett ${MMAKE} all && \ 221215976Sjmallett ${MMAKE} install DESTDIR=${MAKEPATH} BINDIR= 222215976Sjmallett 223215976Sjmallett# 224215976Sjmallett# universe 225215976Sjmallett# 226215976Sjmallett# Attempt to rebuild *everything* for all supported architectures, 227215976Sjmallett# with reasonable chance of success, regardless of how old your 228215976Sjmallett# existing system is. 229215976Sjmallett# 230215976Sjmalletti386_mach= pc98 231215976Sjmallettuniverse: 232215976Sjmallett @echo "--------------------------------------------------------------" 233232812Sjmallett @echo ">>> make universe started on ${STARTTIME}" 234232812Sjmallett @echo "--------------------------------------------------------------" 235232812Sjmallett.for arch in i386 sparc64 alpha ia64 amd64 236232812Sjmallett.for mach in ${arch} ${${arch}_mach} 237215976Sjmallett @echo ">> ${mach} started on `LC_ALL=C date`" 238215976Sjmallett -cd ${.CURDIR} && ${MAKE} buildworld \ 239215976Sjmallett TARGET_ARCH=${arch} TARGET=${mach} \ 240215976Sjmallett __MAKE_CONF=/dev/null \ 241215976Sjmallett > _.${mach}.buildworld 2>&1 242215976Sjmallett @echo ">> ${mach} buildworld completed on `LC_ALL=C date`" 243215976Sjmallett.if exists(${.CURDIR}/sys/${mach}/conf/NOTES) 244215976Sjmallett -cd ${.CURDIR}/sys/${mach}/conf && ${MAKE} LINT \ 245215976Sjmallett > ${.CURDIR}/_.${mach}.makeLINT 2>&1 246215976Sjmallett.endif 247215976Sjmallett cd ${.CURDIR} && ${MAKE} buildkernels TARGET_ARCH=${arch} TARGET=${mach} 248215976Sjmallett @echo ">> ${mach} completed on `LC_ALL=C date`" 249232812Sjmallett.endfor 250232812Sjmallett.endfor 251232812Sjmallett @echo "--------------------------------------------------------------" 252232812Sjmallett @echo ">>> make universe completed on `LC_ALL=C date`" 253215976Sjmallett @echo " (started ${STARTTIME})" 254215976Sjmallett @echo "--------------------------------------------------------------" 255215976Sjmallett 256215976Sjmallett.if make(buildkernels) 257215976SjmallettKERNCONFS!= cd ${.CURDIR}/sys/${TARGET}/conf && \ 258215976Sjmallett find [A-Z]*[A-Z] -type f -maxdepth 0 ! -name NOTES 259215976Sjmallett.endif 260215976Sjmallett 261215976Sjmallettbuildkernels: 262215976Sjmallett.for kernel in ${KERNCONFS} 263215976Sjmallett -cd ${.CURDIR} && ${MAKE} buildkernel \ 264215976Sjmallett KERNCONF=${kernel} \ 265232812Sjmallett __MAKE_CONF=/dev/null \ 266232812Sjmallett > _.${TARGET}.${kernel} 2>&1 267232812Sjmallett.endfor 268232812Sjmallett