Makefile revision 1.224
11.224Slukem# $NetBSD: Makefile,v 1.224 2004/01/04 00:27:15 lukem Exp $ 21.95Scjs 31.193Slukem# 41.95Scjs# This is the top-level makefile for building NetBSD. For an outline of 51.95Scjs# how to build a snapshot or release, as well as other release engineering 61.221Ssalo# information, see http://www.NetBSD.org/developers/releng/index.html 71.95Scjs# 81.95Scjs# Not everything you can set or do is documented in this makefile. In 91.95Scjs# particular, you should review the files in /usr/share/mk (especially 101.95Scjs# bsd.README) for general information on building programs and writing 111.95Scjs# Makefiles within this structure, and see the comments in src/etc/Makefile 121.95Scjs# for further information on installation and release set options. 131.95Scjs# 141.95Scjs# Variables listed below can be set on the make command line (highest 151.95Scjs# priority), in /etc/mk.conf (middle priority), or in the environment 161.95Scjs# (lowest priority). 171.95Scjs# 181.95Scjs# Variables: 191.101Ssommerfe# DESTDIR is the target directory for installation of the compiled 201.101Ssommerfe# software. It defaults to /. Note that programs are built against 211.101Ssommerfe# libraries installed in DESTDIR. 221.214Slukem# MKMAN, if `no', will prevent building of manual pages. 231.214Slukem# MKOBJDIRS, if not `no', will build object directories at 241.101Ssommerfe# an appropriate point in a build. 251.214Slukem# MKSHARE, if `no', will prevent building and installing 261.95Scjs# anything in /usr/share. 271.214Slukem# MKUPDATE, if not `no', will avoid a `make cleandir' at the start of 281.178Senami# `make build', as well as having the effects listed in 291.178Senami# /usr/share/mk/bsd.README. 301.125Smrg# NOCLEANDIR, if defined, will avoid a `make cleandir' at the start 311.178Senami# of the `make build'. 321.119Stoddpw# NOINCLUDES will avoid the `make includes' usually done by `make build'. 331.95Scjs# 341.214Slukem# See mk.conf(5) for more details. 351.214Slukem# 361.214Slukem# 371.95Scjs# Targets: 381.137Stv# build: 391.196Slukem# Builds a full release of NetBSD in DESTDIR, except for the 401.196Slukem# /etc configuration files. 411.196Slukem# If BUILD_DONE is set, this is an empty target. 421.196Slukem# distribution: 431.196Slukem# Builds a full release of NetBSD in DESTDIR, including the /etc 441.196Slukem# configuration files. 451.196Slukem# buildworld: 461.196Slukem# As per `make distribution', except that it ensures that DESTDIR 471.196Slukem# is not the root directory. 481.196Slukem# installworld: 491.196Slukem# Install the distribution from DESTDIR to INSTALLWORLDDIR (which 501.196Slukem# defaults to the root directory). Ensures that INSTALLWORLDDIR 511.196Slukem# is the not root directory if cross compiling. 521.137Stv# release: 531.196Slukem# Does a `make build', and then tars up the DESTDIR files 541.196Slukem# into RELEASEDIR/${MACHINE}, in release(7) format. 551.196Slukem# (See etc/Makefile for more information on this.) 561.137Stv# regression-tests: 571.137Stv# Runs the regression tests in "regress" on this host. 581.206Slukem# sets: 591.206Slukem# Populate ${RELEASEDIR}/${MACHINE}/binary/sets from ${DESTDIR} 601.206Slukem# sourcesets: 611.206Slukem# Populate ${RELEASEDIR}/source/sets from ${NETBSDSRCDIR} 621.123Smrg# 631.137Stv# Targets invoked by `make build,' in order: 641.155Stv# cleandir: cleans the tree. 651.137Stv# obj: creates object directories. 661.152Stv# do-tools: builds host toolchain. 671.208Slukem# do-distrib-dirs: creates the distribution directories. 681.208Slukem# includes: installs include files. 691.202Sthorpej# do-tools-compat: builds the "libnbcompat" library; needed for some 701.202Sthorpej# random host tool programs in the source tree. 711.222Slukem# do-gnu-lib-libgcc3: builds and installs prerequisites from gnu/lib/libgcc3 721.168Stv# do-lib-csu: builds and installs prerequisites from lib/csu. 731.186Sthorpej# do-lib-libc: builds and installs prerequisites from lib/libc. 741.219Slukem# do-lib-libdes: builds and installs prerequisites from lib/libdes. 751.143Stv# do-lib: builds and installs prerequisites from lib. 761.143Stv# do-gnu-lib: builds and installs prerequisites from gnu/lib. 771.189Sitohy# do-ld.so: builds and installs prerequisites from libexec/ld.*_so. 781.137Stv# do-build: builds and installs the entire system. 791.222Slukem# do-obsolete: installs the obsolete sets (for the postinstall-* targets). 801.193Slukem# 811.32Scgd 821.146Stv.if ${.MAKEFLAGS:M${.CURDIR}/share/mk} == "" 831.146Stv.MAKEFLAGS: -m ${.CURDIR}/share/mk 841.146Stv.endif 851.163Stv 861.193Slukem# 871.163Stv# If _SRC_TOP_OBJ_ gets set here, we will end up with a directory that may 881.163Stv# not be the top level objdir, because "make obj" can happen in the *middle* 891.163Stv# of "make build" (long after <bsd.own.mk> is calculated it). So, pre-set 901.163Stv# _SRC_TOP_OBJ_ here so it will not be added to ${.MAKEOVERRIDES}. 911.193Slukem# 921.163Stv_SRC_TOP_OBJ_= 931.148Sjmc 941.146Stv.include <bsd.own.mk> 951.4Scgd 961.193Slukem# 971.137Stv# Sanity check: make sure that "make build" is not invoked simultaneously 981.137Stv# with a standard recursive target. 991.193Slukem# 1001.137Stv 1011.137Stv.if make(build) || make(release) || make(snapshot) 1021.137Stv.for targ in ${TARGETS:Nobj:Ncleandir} 1031.137Stv.if make(${targ}) && !target(.BEGIN) 1041.137Stv.BEGIN: 1051.137Stv @echo 'BUILD ABORTED: "make build" and "make ${targ}" are mutually exclusive.' 1061.137Stv @false 1071.137Stv.endif 1081.137Stv.endfor 1091.137Stv.endif 1101.58Stv 1111.166Ssimonb_SUBDIR= tools lib include gnu bin games libexec sbin usr.bin 1121.205Sthorpej_SUBDIR+= usr.sbin share rescue sys etc .WAIT distrib regress 1131.105Sassar 1141.193Slukem# 1151.137Stv# Weed out directories that don't exist. 1161.193Slukem# 1171.36Sexplorer 1181.137Stv.for dir in ${_SUBDIR} 1191.154Stv.if exists(${dir}/Makefile) && (${BUILD_${dir}:Uyes} != "no") 1201.137StvSUBDIR+= ${dir} 1211.36Sexplorer.endif 1221.137Stv.endfor 1231.21Scgd 1241.13Sbrezak.if exists(regress) 1251.10Scgdregression-tests: 1261.10Scgd @echo Running regression tests... 1271.152Stv @(cd ${.CURDIR}/regress && ${MAKE} regress) 1281.13Sbrezak.endif 1291.20Scgd 1301.214Slukem.if ${MKUNPRIVED} != "no" 1311.179SthorpejNOPOSTINSTALL= # defined 1321.179Sthorpej.endif 1331.179Sthorpej 1341.176Slukemafterinstall: 1351.137Stv.if ${MKMAN} != "no" 1361.152Stv (cd ${.CURDIR}/share/man && ${MAKE} makedb) 1371.137Stv.endif 1381.214Slukem.if (${MKUNPRIVED} != "no" && ${MKINFO} != "no") 1391.164Sjmc (cd ${.CURDIR}/gnu/usr.bin/texinfo/install-info && ${MAKE} infodir-meta) 1401.176Slukem.endif 1411.179Sthorpej.if !defined(NOPOSTINSTALL) 1421.180Sdrochner (cd ${.CURDIR} && ${MAKE} postinstall-check) 1431.159Sperry.endif 1441.170Slukem 1451.170Slukempostinstall-check: 1461.169Slukem @echo " === Post installation checks ===" 1471.212Slukem ${HOST_SH} ${.CURDIR}/etc/postinstall -s ${.CURDIR} -d ${DESTDIR}/ check 1481.171Slukem @echo " ================================" 1491.171Slukem 1501.171Slukempostinstall-fix: .NOTMAIN 1511.171Slukem @echo " === Post installation fixes ===" 1521.212Slukem ${HOST_SH} ${.CURDIR}/etc/postinstall -s ${.CURDIR} -d ${DESTDIR}/ fix 1531.212Slukem @echo " ===============================" 1541.212Slukem 1551.212Slukempostinstall-fix-obsolete: .NOTMAIN 1561.212Slukem @echo " === Removing obsolete files ===" 1571.212Slukem ${HOST_SH} ${.CURDIR}/etc/postinstall -s ${.CURDIR} -d ${DESTDIR}/ fix obsolete 1581.212Slukem @echo " ===============================" 1591.169Slukem 1601.108Serh 1611.193Slukem# 1621.137Stv# Targets (in order!) called by "make build". 1631.193Slukem# 1641.220Smrg.if ${USE_TOOLS_TOOLCHAIN} == "no" 1651.220SmrgLIBGCC_EXT=3 1661.220Smrg.else 1671.220SmrgLIBGCC_EXT= 1681.220Smrg.endif 1691.123Smrg 1701.156StvBUILDTARGETS+= check-tools 1711.214Slukem.if ${MKUPDATE} == "no" && !defined(NOCLEANDIR) 1721.155StvBUILDTARGETS+= cleandir 1731.155Stv.endif 1741.149Stv.if ${MKOBJDIRS} != "no" 1751.137StvBUILDTARGETS+= obj 1761.123Smrg.endif 1771.138Stv.if ${USETOOLS} == "yes" 1781.152StvBUILDTARGETS+= do-tools 1791.131Stv.endif 1801.137Stv.if !defined(NODISTRIBDIRS) 1811.137StvBUILDTARGETS+= do-distrib-dirs 1821.131Stv.endif 1831.137Stv.if !defined(NOINCLUDES) 1841.137StvBUILDTARGETS+= includes 1851.131Stv.endif 1861.202SthorpejBUILDTARGETS+= do-tools-compat 1871.207Sdrochner.if ${MKGCC} != "no" 1881.220SmrgBUILDTARGETS+= do-gnu-lib-libgcc${LIBGCC_EXT} 1891.207Sdrochner.endif 1901.224SlukemBUILDTARGETS+= do-lib-csu do-lib-libc 1911.224Slukem.if ${MKCRYPTO} != "no" 1921.224SlukemBUILDTARGETS+= do-lib-libdes 1931.224Slukem.endif 1941.224SlukemBUILDTARGETS+= do-lib do-gnu-lib 1951.224SlukemBUILDTARGETS+= do-ld.so 1961.224SlukemBUILDTARGETS+= do-build 1971.200SlukemBUILDTARGETS+= do-obsolete 1981.131Stv 1991.193Slukem# 2001.137Stv# Enforce proper ordering of some rules. 2011.193Slukem# 2021.123Smrg 2031.137Stv.ORDER: ${BUILDTARGETS} 2041.137Stvincludes-lib: includes-include includes-sys 2051.137Stvincludes-gnu: includes-lib 2061.123Smrg 2071.193Slukem# 2081.137Stv# Build the system and install into DESTDIR. 2091.193Slukem# 2101.123Smrg 2111.191SlukemSTART_TIME!= date 2121.191Slukem 2131.137Stvbuild: 2141.137Stv.if defined(BUILD_DONE) 2151.137Stv @echo "Build already installed into ${DESTDIR}" 2161.137Stv.else 2171.191Slukem @echo "Build started at: ${START_TIME}" 2181.145Stv.for tgt in ${BUILDTARGETS} 2191.173Ssommerfe @(cd ${.CURDIR} && ${MAKE} ${tgt}) 2201.145Stv.endfor 2211.191Slukem @echo "Build started at: ${START_TIME}" 2221.172Sbjh21 @printf "Build finished at: " && date 2231.71Smycroft.endif 2241.160Sthorpej 2251.193Slukem# 2261.160Sthorpej# Build a full distribution, but not a release (i.e. no sets into 2271.193Slukem# ${RELEASEDIR}). "buildworld" enforces a build to ${DESTDIR} != / 2281.193Slukem# 2291.160Sthorpej 2301.193Slukemdistribution buildworld: 2311.194Slukem.if make(buildworld) && \ 2321.194Slukem (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/") 2331.193Slukem @echo "Won't make ${.TARGET} with DESTDIR=/" 2341.193Slukem @false 2351.193Slukem.endif 2361.182Suwe (cd ${.CURDIR} && ${MAKE} NOPOSTINSTALL=1 build) 2371.160Sthorpej (cd ${.CURDIR}/etc && ${MAKE} INSTALL_DONE=1 distribution) 2381.181Sthorpej.if defined(DESTDIR) && ${DESTDIR} != "" && ${DESTDIR} != "/" 2391.217Slukem (cd ${.CURDIR} && ${MAKE} postinstall-fix-obsolete) 2401.181Sthorpej (cd ${.CURDIR}/distrib/sets && ${MAKE} checkflist) 2411.181Sthorpej.endif 2421.192Slukem @echo "make ${.TARGET} started at: ${START_TIME}" 2431.185Slukem @printf "make ${.TARGET} finished at: " && date 2441.123Smrg 2451.193Slukem# 2461.193Slukem# Install the distribution from $DESTDIR to $INSTALLWORLDDIR (defaults to `/') 2471.193Slukem# If installing to /, ensures that the host's operating system is NetBSD and 2481.193Slukem# the host's `uname -m` == ${MACHINE}. 2491.193Slukem# 2501.193Slukem 2511.193SlukemHOST_UNAME_S!= uname -s 2521.193SlukemHOST_UNAME_M!= uname -m 2531.193Slukem 2541.193Slukeminstallworld: 2551.194Slukem.if (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/") 2561.193Slukem @echo "Can't make ${.TARGET} to DESTDIR=/" 2571.193Slukem @false 2581.193Slukem.endif 2591.193Slukem.if !defined(INSTALLWORLDDIR) || \ 2601.193Slukem ${INSTALLWORLDDIR} == "" || ${INSTALLWORLDDIR} == "/" 2611.193Slukem.if (${HOST_UNAME_S} != "NetBSD") 2621.193Slukem @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_S} to NetBSD with INSTALLWORLDDIR=/" 2631.193Slukem @false 2641.193Slukem.endif 2651.193Slukem.if (${HOST_UNAME_M} != ${MACHINE}) 2661.193Slukem @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_M} to ${MACHINE} with INSTALLWORLDDIR=/" 2671.193Slukem @false 2681.193Slukem.endif 2691.193Slukem.endif 2701.193Slukem (cd ${.CURDIR}/distrib/sets && \ 2711.193Slukem ${MAKE} INSTALLDIR=${INSTALLWORLDDIR:U/} INSTALLSETS= installsets) 2721.193Slukem (cd ${.CURDIR} && \ 2731.193Slukem ${MAKE} DESTDIR=${INSTALLWORLDDIR} postinstall-check) 2741.193Slukem @echo "make ${.TARGET} started at: ${START_TIME}" 2751.193Slukem @printf "make ${.TARGET} finished at: " && date 2761.199Slukem 2771.199Slukem# 2781.206Slukem# Create sets from $DESTDIR or $NETBSDSRCDIR into $RELEASEDIR 2791.199Slukem# 2801.199Slukem 2811.206Slukem.for tgt in sets sourcesets 2821.206Slukem${tgt}: 2831.206Slukem (cd ${.CURDIR}/distrib/sets && ${MAKE} $@) 2841.206Slukem.endfor 2851.193Slukem 2861.193Slukem# 2871.181Sthorpej# Build a release or snapshot (implies "make build"). Note that 2881.181Sthorpej# in this case, the set lists will be checked before the tar files 2891.181Sthorpej# are made. 2901.193Slukem# 2911.123Smrg 2921.179Sthorpejrelease snapshot: 2931.179Sthorpej (cd ${.CURDIR} && ${MAKE} NOPOSTINSTALL=1 build) 2941.152Stv (cd ${.CURDIR}/etc && ${MAKE} INSTALL_DONE=1 release) 2951.192Slukem @echo "make ${.TARGET} started at: ${START_TIME}" 2961.185Slukem @printf "make ${.TARGET} finished at: " && date 2971.123Smrg 2981.193Slukem# 2991.137Stv# Special components of the "make build" process. 3001.193Slukem# 3011.156Stv 3021.156Stvcheck-tools: 3031.223Slukem.if ${TOOLCHAIN_MISSING} != "no" && !defined(EXTERNAL_TOOLCHAIN) 3041.187Sthorpej @echo '*** WARNING: Building on MACHINE=${MACHINE} with missing toolchain.' 3051.187Sthorpej @echo '*** May result in a failed build or corrupt binaries!' 3061.187Sthorpej.elif defined(EXTERNAL_TOOLCHAIN) 3071.187Sthorpej @echo '*** Using external toolchain rooted at ${EXTERNAL_TOOLCHAIN}.' 3081.156Stv.endif 3091.173Ssommerfe.if defined(NBUILDJOBS) 3101.173Ssommerfe @echo '*** WARNING: NBUILDJOBS is obsolete; use -j directly instead!' 3111.173Ssommerfe.endif 3121.123Smrg 3131.137Stvdo-distrib-dirs: 3141.147Sjmc.if !defined(DESTDIR) || ${DESTDIR} == "" 3151.152Stv (cd ${.CURDIR}/etc && ${MAKE} DESTDIR=/ distrib-dirs) 3161.147Sjmc.else 3171.152Stv (cd ${.CURDIR}/etc && ${MAKE} DESTDIR=${DESTDIR} distrib-dirs) 3181.147Sjmc.endif 3191.190Slukem 3201.190Slukem.for targ in cleandir obj includes 3211.190Slukemdo-${targ}: ${targ} 3221.190Slukem @true 3231.190Slukem.endfor 3241.123Smrg 3251.220Smrg.for dir in tools tools/compat lib/csu gnu/lib/libgcc${LIBGCC_EXT} lib/libc lib/libdes lib gnu/lib 3261.207Sdrochnerdo-${dir:S/\//-/g}: 3271.137Stv.for targ in dependall install 3281.173Ssommerfe (cd ${.CURDIR}/${dir} && ${MAKE} ${targ}) 3291.137Stv.endfor 3301.184Slukem.endfor 3311.184Slukem 3321.189Sitohydo-ld.so: 3331.184Slukem.for targ in dependall install 3341.189Sitohy.if (${OBJECT_FMT} == "a.out") 3351.189Sitohy (cd ${.CURDIR}/libexec/ld.aout_so && ${MAKE} ${targ}) 3361.189Sitohy.endif 3371.189Sitohy.if (${OBJECT_FMT} == "ELF") 3381.184Slukem (cd ${.CURDIR}/libexec/ld.elf_so && ${MAKE} ${targ}) 3391.189Sitohy.endif 3401.137Stv.endfor 3411.143Stv 3421.143Stvdo-build: 3431.154Stv.for targ in dependall install 3441.173Ssommerfe (cd ${.CURDIR} && ${MAKE} ${targ} BUILD_tools=no BUILD_lib=no) 3451.154Stv.endfor 3461.200Slukem 3471.200Slukemdo-obsolete: 3481.200Slukem (cd ${.CURDIR}/etc && ${MAKE} install-obsolete-lists) 3491.87Scjs 3501.193Slukem# 3511.137Stv# Speedup stubs for some subtrees that don't need to run these rules. 3521.137Stv# (Tells <bsd.subdir.mk> not to recurse for them.) 3531.193Slukem# 3541.129Stv 3551.152Stv.for dir in bin etc distrib games libexec regress sbin usr.sbin tools 3561.152Stvincludes-${dir}: 3571.152Stv @true 3581.152Stv.endfor 3591.152Stv.for dir in etc distrib regress 3601.152Stvinstall-${dir}: 3611.152Stv @true 3621.152Stv.endfor 3631.152Stv 3641.193Slukem# 3651.152Stv# XXX this needs to change when distrib Makefiles are recursion compliant 3661.193Slukem# XXX many distrib subdirs need "cd etc && make snap_pre snap_kern" first... 3671.193Slukem# 3681.152Stvdependall-distrib depend-distrib all-distrib: 3691.136Snathanw @true 3701.130Stv 3711.211Slukem.include <bsd.sys.mk> 3721.151Stv.include <bsd.obj.mk> 3731.209Slukem.include <bsd.kernobj.mk> 3741.146Stv.include <bsd.subdir.mk> 3751.144Stv 3761.150Stvbuild-docs: ${.CURDIR}/BUILDING 3771.188Slukem${.CURDIR}/BUILDING: doc/BUILDING.mdoc 3781.216Slukem ${TOOL_GROFF} -mdoc -Tascii -P-bou $> >$@ 3791.209Slukem 3801.209Slukem 3811.209Slukem# 3821.209Slukem# Display current make(1) parameters 3831.209Slukem# 3841.209Slukemparams: 3851.209Slukem.for var in BSDSRCDIR BSDOBJDIR BUILDID DESTDIR EXTERNAL_TOOLCHAIN \ 3861.209Slukem KERNARCHDIR KERNCONFDIR KERNOBJDIR KERNSRCDIR \ 3871.210Slukem MACHINE MACHINE_ARCH MAKECONF MAKEFLAGS \ 3881.214Slukem MAKEOBJDIR MAKEOBJDIRPREFIX \ 3891.214Slukem MKOBJDIRS MKUNPRIVED MKUPDATE \ 3901.210Slukem RELEASEDIR TOOLCHAIN_MISSING TOOLDIR \ 3911.214Slukem USETOOLS 3921.209Slukem.if defined(${var}) 3931.209Slukem @printf "%20s = '%-s'\n" ${var} ${${var}:Q} 3941.209Slukem.else 3951.209Slukem @printf "%20s = (undefined)\n" ${var} 3961.209Slukem.endif 3971.209Slukem.endfor 398