Makefile revision 1.209
11.209Slukem# $NetBSD: Makefile,v 1.209 2003/07/06 13:04:01 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.95Scjs# 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.95Scjs# MKMAN, if set to `no', will prevent building of manual pages. 231.178Senami# MKOBJDIRS, if not set to `no', will build object directories at 241.101Ssommerfe# an appropriate point in a build. 251.95Scjs# MKSHARE, if set to `no', will prevent building and installing 261.95Scjs# anything in /usr/share. 271.125Smrg# UPDATE, if defined, 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.95Scjs# Targets: 351.137Stv# build: 361.196Slukem# Builds a full release of NetBSD in DESTDIR, except for the 371.196Slukem# /etc configuration files. 381.196Slukem# If BUILD_DONE is set, this is an empty target. 391.196Slukem# distribution: 401.196Slukem# Builds a full release of NetBSD in DESTDIR, including the /etc 411.196Slukem# configuration files. 421.196Slukem# buildworld: 431.196Slukem# As per `make distribution', except that it ensures that DESTDIR 441.196Slukem# is not the root directory. 451.196Slukem# installworld: 461.196Slukem# Install the distribution from DESTDIR to INSTALLWORLDDIR (which 471.196Slukem# defaults to the root directory). Ensures that INSTALLWORLDDIR 481.196Slukem# is the not root directory if cross compiling. 491.137Stv# release: 501.196Slukem# Does a `make build', and then tars up the DESTDIR files 511.196Slukem# into RELEASEDIR/${MACHINE}, in release(7) format. 521.196Slukem# (See etc/Makefile for more information on this.) 531.137Stv# regression-tests: 541.137Stv# Runs the regression tests in "regress" on this host. 551.206Slukem# sets: 561.206Slukem# Populate ${RELEASEDIR}/${MACHINE}/binary/sets from ${DESTDIR} 571.206Slukem# sourcesets: 581.206Slukem# Populate ${RELEASEDIR}/source/sets from ${NETBSDSRCDIR} 591.123Smrg# 601.137Stv# Targets invoked by `make build,' in order: 611.155Stv# cleandir: cleans the tree. 621.137Stv# obj: creates object directories. 631.152Stv# do-tools: builds host toolchain. 641.208Slukem# do-distrib-dirs: creates the distribution directories. 651.208Slukem# includes: installs include files. 661.202Sthorpej# do-tools-compat: builds the "libnbcompat" library; needed for some 671.202Sthorpej# random host tool programs in the source tree. 681.208Slukem# do-gnu-lib-libgcc: builds and installs prerequisites from gnu/lib/libgcc 691.168Stv# do-lib-csu: builds and installs prerequisites from lib/csu. 701.186Sthorpej# do-lib-libc: builds and installs prerequisites from lib/libc. 711.143Stv# do-lib: builds and installs prerequisites from lib. 721.143Stv# do-gnu-lib: builds and installs prerequisites from gnu/lib. 731.189Sitohy# do-ld.so: builds and installs prerequisites from libexec/ld.*_so. 741.137Stv# do-build: builds and installs the entire system. 751.208Slukem# do-obsolete: builds and installs the entire system. 761.193Slukem# 771.32Scgd 781.146Stv.if ${.MAKEFLAGS:M${.CURDIR}/share/mk} == "" 791.146Stv.MAKEFLAGS: -m ${.CURDIR}/share/mk 801.146Stv.endif 811.163Stv 821.193Slukem# 831.163Stv# If _SRC_TOP_OBJ_ gets set here, we will end up with a directory that may 841.163Stv# not be the top level objdir, because "make obj" can happen in the *middle* 851.163Stv# of "make build" (long after <bsd.own.mk> is calculated it). So, pre-set 861.163Stv# _SRC_TOP_OBJ_ here so it will not be added to ${.MAKEOVERRIDES}. 871.193Slukem# 881.163Stv_SRC_TOP_OBJ_= 891.148Sjmc 901.146Stv.include <bsd.own.mk> 911.4Scgd 921.193Slukem# 931.137Stv# Sanity check: make sure that "make build" is not invoked simultaneously 941.137Stv# with a standard recursive target. 951.193Slukem# 961.137Stv 971.137Stv.if make(build) || make(release) || make(snapshot) 981.137Stv.for targ in ${TARGETS:Nobj:Ncleandir} 991.137Stv.if make(${targ}) && !target(.BEGIN) 1001.137Stv.BEGIN: 1011.137Stv @echo 'BUILD ABORTED: "make build" and "make ${targ}" are mutually exclusive.' 1021.137Stv @false 1031.137Stv.endif 1041.137Stv.endfor 1051.137Stv.endif 1061.58Stv 1071.166Ssimonb_SUBDIR= tools lib include gnu bin games libexec sbin usr.bin 1081.205Sthorpej_SUBDIR+= usr.sbin share rescue sys etc .WAIT distrib regress 1091.105Sassar 1101.193Slukem# 1111.137Stv# Weed out directories that don't exist. 1121.193Slukem# 1131.36Sexplorer 1141.137Stv.for dir in ${_SUBDIR} 1151.154Stv.if exists(${dir}/Makefile) && (${BUILD_${dir}:Uyes} != "no") 1161.137StvSUBDIR+= ${dir} 1171.36Sexplorer.endif 1181.137Stv.endfor 1191.21Scgd 1201.13Sbrezak.if exists(regress) 1211.10Scgdregression-tests: 1221.10Scgd @echo Running regression tests... 1231.152Stv @(cd ${.CURDIR}/regress && ${MAKE} regress) 1241.13Sbrezak.endif 1251.20Scgd 1261.179Sthorpej.if defined(UNPRIVED) 1271.179SthorpejNOPOSTINSTALL= # defined 1281.179Sthorpej.endif 1291.179Sthorpej 1301.176Slukemafterinstall: 1311.137Stv.if ${MKMAN} != "no" 1321.152Stv (cd ${.CURDIR}/share/man && ${MAKE} makedb) 1331.137Stv.endif 1341.159Sperry.if defined(UNPRIVED) && (${MKINFO} != "no") 1351.164Sjmc (cd ${.CURDIR}/gnu/usr.bin/texinfo/install-info && ${MAKE} infodir-meta) 1361.176Slukem.endif 1371.179Sthorpej.if !defined(NOPOSTINSTALL) 1381.180Sdrochner (cd ${.CURDIR} && ${MAKE} postinstall-check) 1391.159Sperry.endif 1401.170Slukem 1411.170Slukempostinstall-check: 1421.169Slukem @echo " === Post installation checks ===" 1431.175Slukem sh ${.CURDIR}/etc/postinstall -s ${.CURDIR} -d ${DESTDIR}/ check 1441.171Slukem @echo " ================================" 1451.171Slukem 1461.171Slukempostinstall-fix: .NOTMAIN 1471.171Slukem @echo " === Post installation fixes ===" 1481.175Slukem sh ${.CURDIR}/etc/postinstall -s ${.CURDIR} -d ${DESTDIR}/ fix 1491.169Slukem @echo " ================================" 1501.169Slukem 1511.108Serh 1521.193Slukem# 1531.137Stv# Targets (in order!) called by "make build". 1541.193Slukem# 1551.123Smrg 1561.156StvBUILDTARGETS+= check-tools 1571.155Stv.if !defined(UPDATE) && !defined(NOCLEANDIR) 1581.155StvBUILDTARGETS+= cleandir 1591.155Stv.endif 1601.149Stv.if ${MKOBJDIRS} != "no" 1611.137StvBUILDTARGETS+= obj 1621.123Smrg.endif 1631.138Stv.if ${USETOOLS} == "yes" 1641.152StvBUILDTARGETS+= do-tools 1651.131Stv.endif 1661.137Stv.if !defined(NODISTRIBDIRS) 1671.137StvBUILDTARGETS+= do-distrib-dirs 1681.131Stv.endif 1691.137Stv.if !defined(NOINCLUDES) 1701.137StvBUILDTARGETS+= includes 1711.131Stv.endif 1721.202SthorpejBUILDTARGETS+= do-tools-compat 1731.207Sdrochner.if ${MKGCC} != "no" 1741.207SdrochnerBUILDTARGETS+= do-gnu-lib-libgcc 1751.207Sdrochner.endif 1761.204SthorpejBUILDTARGETS+= do-lib-csu do-lib-libc do-lib do-gnu-lib do-ld.so do-build 1771.200SlukemBUILDTARGETS+= do-obsolete 1781.131Stv 1791.193Slukem# 1801.137Stv# Enforce proper ordering of some rules. 1811.193Slukem# 1821.123Smrg 1831.137Stv.ORDER: ${BUILDTARGETS} 1841.137Stvincludes-lib: includes-include includes-sys 1851.137Stvincludes-gnu: includes-lib 1861.123Smrg 1871.193Slukem# 1881.137Stv# Build the system and install into DESTDIR. 1891.193Slukem# 1901.123Smrg 1911.191SlukemSTART_TIME!= date 1921.191Slukem 1931.137Stvbuild: 1941.137Stv.if defined(BUILD_DONE) 1951.137Stv @echo "Build already installed into ${DESTDIR}" 1961.137Stv.else 1971.191Slukem @echo "Build started at: ${START_TIME}" 1981.145Stv.for tgt in ${BUILDTARGETS} 1991.173Ssommerfe @(cd ${.CURDIR} && ${MAKE} ${tgt}) 2001.145Stv.endfor 2011.191Slukem @echo "Build started at: ${START_TIME}" 2021.172Sbjh21 @printf "Build finished at: " && date 2031.71Smycroft.endif 2041.160Sthorpej 2051.193Slukem# 2061.160Sthorpej# Build a full distribution, but not a release (i.e. no sets into 2071.193Slukem# ${RELEASEDIR}). "buildworld" enforces a build to ${DESTDIR} != / 2081.193Slukem# 2091.160Sthorpej 2101.193Slukemdistribution buildworld: 2111.194Slukem.if make(buildworld) && \ 2121.194Slukem (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/") 2131.193Slukem @echo "Won't make ${.TARGET} with DESTDIR=/" 2141.193Slukem @false 2151.193Slukem.endif 2161.182Suwe (cd ${.CURDIR} && ${MAKE} NOPOSTINSTALL=1 build) 2171.160Sthorpej (cd ${.CURDIR}/etc && ${MAKE} INSTALL_DONE=1 distribution) 2181.181Sthorpej.if defined(DESTDIR) && ${DESTDIR} != "" && ${DESTDIR} != "/" 2191.181Sthorpej (cd ${.CURDIR}/distrib/sets && ${MAKE} checkflist) 2201.181Sthorpej.endif 2211.192Slukem @echo "make ${.TARGET} started at: ${START_TIME}" 2221.185Slukem @printf "make ${.TARGET} finished at: " && date 2231.123Smrg 2241.193Slukem# 2251.193Slukem# Install the distribution from $DESTDIR to $INSTALLWORLDDIR (defaults to `/') 2261.193Slukem# If installing to /, ensures that the host's operating system is NetBSD and 2271.193Slukem# the host's `uname -m` == ${MACHINE}. 2281.193Slukem# 2291.193Slukem 2301.193SlukemHOST_UNAME_S!= uname -s 2311.193SlukemHOST_UNAME_M!= uname -m 2321.193Slukem 2331.193Slukeminstallworld: 2341.194Slukem.if (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/") 2351.193Slukem @echo "Can't make ${.TARGET} to DESTDIR=/" 2361.193Slukem @false 2371.193Slukem.endif 2381.193Slukem.if !defined(INSTALLWORLDDIR) || \ 2391.193Slukem ${INSTALLWORLDDIR} == "" || ${INSTALLWORLDDIR} == "/" 2401.193Slukem.if (${HOST_UNAME_S} != "NetBSD") 2411.193Slukem @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_S} to NetBSD with INSTALLWORLDDIR=/" 2421.193Slukem @false 2431.193Slukem.endif 2441.193Slukem.if (${HOST_UNAME_M} != ${MACHINE}) 2451.193Slukem @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_M} to ${MACHINE} with INSTALLWORLDDIR=/" 2461.193Slukem @false 2471.193Slukem.endif 2481.193Slukem.endif 2491.193Slukem (cd ${.CURDIR}/distrib/sets && \ 2501.193Slukem ${MAKE} INSTALLDIR=${INSTALLWORLDDIR:U/} INSTALLSETS= installsets) 2511.193Slukem (cd ${.CURDIR} && \ 2521.193Slukem ${MAKE} DESTDIR=${INSTALLWORLDDIR} postinstall-check) 2531.193Slukem @echo "make ${.TARGET} started at: ${START_TIME}" 2541.193Slukem @printf "make ${.TARGET} finished at: " && date 2551.199Slukem 2561.199Slukem# 2571.206Slukem# Create sets from $DESTDIR or $NETBSDSRCDIR into $RELEASEDIR 2581.199Slukem# 2591.199Slukem 2601.206Slukem.for tgt in sets sourcesets 2611.206Slukem${tgt}: 2621.206Slukem (cd ${.CURDIR}/distrib/sets && ${MAKE} $@) 2631.206Slukem.endfor 2641.193Slukem 2651.193Slukem# 2661.181Sthorpej# Build a release or snapshot (implies "make build"). Note that 2671.181Sthorpej# in this case, the set lists will be checked before the tar files 2681.181Sthorpej# are made. 2691.193Slukem# 2701.123Smrg 2711.179Sthorpejrelease snapshot: 2721.179Sthorpej (cd ${.CURDIR} && ${MAKE} NOPOSTINSTALL=1 build) 2731.152Stv (cd ${.CURDIR}/etc && ${MAKE} INSTALL_DONE=1 release) 2741.192Slukem @echo "make ${.TARGET} started at: ${START_TIME}" 2751.185Slukem @printf "make ${.TARGET} finished at: " && date 2761.123Smrg 2771.193Slukem# 2781.137Stv# Special components of the "make build" process. 2791.193Slukem# 2801.156Stv 2811.156Stvcheck-tools: 2821.187Sthorpej.if ${TOOLCHAIN_MISSING} == "yes" && !defined(EXTERNAL_TOOLCHAIN) 2831.187Sthorpej @echo '*** WARNING: Building on MACHINE=${MACHINE} with missing toolchain.' 2841.187Sthorpej @echo '*** May result in a failed build or corrupt binaries!' 2851.187Sthorpej.elif defined(EXTERNAL_TOOLCHAIN) 2861.187Sthorpej @echo '*** Using external toolchain rooted at ${EXTERNAL_TOOLCHAIN}.' 2871.156Stv.endif 2881.173Ssommerfe.if defined(NBUILDJOBS) 2891.173Ssommerfe @echo '*** WARNING: NBUILDJOBS is obsolete; use -j directly instead!' 2901.173Ssommerfe.endif 2911.123Smrg 2921.137Stvdo-distrib-dirs: 2931.147Sjmc.if !defined(DESTDIR) || ${DESTDIR} == "" 2941.152Stv (cd ${.CURDIR}/etc && ${MAKE} DESTDIR=/ distrib-dirs) 2951.147Sjmc.else 2961.152Stv (cd ${.CURDIR}/etc && ${MAKE} DESTDIR=${DESTDIR} distrib-dirs) 2971.147Sjmc.endif 2981.190Slukem 2991.190Slukem.for targ in cleandir obj includes 3001.190Slukemdo-${targ}: ${targ} 3011.190Slukem @true 3021.190Slukem.endfor 3031.123Smrg 3041.207Sdrochner.for dir in tools tools/compat lib/csu gnu/lib/libgcc lib/libc lib gnu/lib 3051.207Sdrochnerdo-${dir:S/\//-/g}: 3061.137Stv.for targ in dependall install 3071.173Ssommerfe (cd ${.CURDIR}/${dir} && ${MAKE} ${targ}) 3081.137Stv.endfor 3091.184Slukem.endfor 3101.184Slukem 3111.189Sitohydo-ld.so: 3121.184Slukem.for targ in dependall install 3131.189Sitohy.if (${OBJECT_FMT} == "a.out") 3141.189Sitohy (cd ${.CURDIR}/libexec/ld.aout_so && ${MAKE} ${targ}) 3151.189Sitohy.endif 3161.189Sitohy.if (${OBJECT_FMT} == "ELF") 3171.184Slukem (cd ${.CURDIR}/libexec/ld.elf_so && ${MAKE} ${targ}) 3181.189Sitohy.endif 3191.137Stv.endfor 3201.143Stv 3211.143Stvdo-build: 3221.154Stv.for targ in dependall install 3231.173Ssommerfe (cd ${.CURDIR} && ${MAKE} ${targ} BUILD_tools=no BUILD_lib=no) 3241.154Stv.endfor 3251.200Slukem 3261.200Slukemdo-obsolete: 3271.200Slukem (cd ${.CURDIR}/etc && ${MAKE} install-obsolete-lists) 3281.87Scjs 3291.193Slukem# 3301.137Stv# Speedup stubs for some subtrees that don't need to run these rules. 3311.137Stv# (Tells <bsd.subdir.mk> not to recurse for them.) 3321.193Slukem# 3331.129Stv 3341.152Stv.for dir in bin etc distrib games libexec regress sbin usr.sbin tools 3351.152Stvincludes-${dir}: 3361.152Stv @true 3371.152Stv.endfor 3381.152Stv.for dir in etc distrib regress 3391.152Stvinstall-${dir}: 3401.152Stv @true 3411.152Stv.endfor 3421.152Stv 3431.193Slukem# 3441.152Stv# XXX this needs to change when distrib Makefiles are recursion compliant 3451.193Slukem# XXX many distrib subdirs need "cd etc && make snap_pre snap_kern" first... 3461.193Slukem# 3471.152Stvdependall-distrib depend-distrib all-distrib: 3481.136Snathanw @true 3491.130Stv 3501.151Stv.include <bsd.obj.mk> 3511.209Slukem.include <bsd.kernobj.mk> 3521.146Stv.include <bsd.subdir.mk> 3531.144Stv 3541.150Stvbuild-docs: ${.CURDIR}/BUILDING 3551.188Slukem${.CURDIR}/BUILDING: doc/BUILDING.mdoc 3561.150Stv groff -mdoc -Tascii -P-b -P-u -P-o $> >$@ 3571.209Slukem 3581.209Slukem 3591.209Slukem# 3601.209Slukem# Display current make(1) parameters 3611.209Slukem# 3621.209Slukemparams: 3631.209Slukem.for var in BSDSRCDIR BSDOBJDIR BUILDID DESTDIR EXTERNAL_TOOLCHAIN \ 3641.209Slukem KERNARCHDIR KERNCONFDIR KERNOBJDIR KERNSRCDIR \ 3651.209Slukem MACHINE MACHINE_ARCH MAKEFLAGS MAKEOBJDIR MAKEOBJDIRPREFIX \ 3661.209Slukem MKOBJDIRS RELEASEDIR TOOLCHAIN_MISSING TOOLDIR \ 3671.209Slukem UNPRIVED UPDATE USETOOLS 3681.209Slukem.if defined(${var}) 3691.209Slukem @printf "%20s = '%-s'\n" ${var} ${${var}:Q} 3701.209Slukem.else 3711.209Slukem @printf "%20s = (undefined)\n" ${var} 3721.209Slukem.endif 3731.209Slukem.endfor 374