Makefile revision 1.232
11.232Slukem# $NetBSD: Makefile,v 1.232 2004/04/13 12:43:12 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.227Slukem# do-x11: builds and installs X11R6 from src/x11 if ${MKX11} != "no" 801.222Slukem# do-obsolete: installs the obsolete sets (for the postinstall-* targets). 811.193Slukem# 821.32Scgd 831.146Stv.if ${.MAKEFLAGS:M${.CURDIR}/share/mk} == "" 841.146Stv.MAKEFLAGS: -m ${.CURDIR}/share/mk 851.146Stv.endif 861.163Stv 871.193Slukem# 881.163Stv# If _SRC_TOP_OBJ_ gets set here, we will end up with a directory that may 891.163Stv# not be the top level objdir, because "make obj" can happen in the *middle* 901.163Stv# of "make build" (long after <bsd.own.mk> is calculated it). So, pre-set 911.163Stv# _SRC_TOP_OBJ_ here so it will not be added to ${.MAKEOVERRIDES}. 921.193Slukem# 931.163Stv_SRC_TOP_OBJ_= 941.148Sjmc 951.146Stv.include <bsd.own.mk> 961.4Scgd 971.193Slukem# 981.137Stv# Sanity check: make sure that "make build" is not invoked simultaneously 991.137Stv# with a standard recursive target. 1001.193Slukem# 1011.137Stv 1021.137Stv.if make(build) || make(release) || make(snapshot) 1031.137Stv.for targ in ${TARGETS:Nobj:Ncleandir} 1041.137Stv.if make(${targ}) && !target(.BEGIN) 1051.137Stv.BEGIN: 1061.137Stv @echo 'BUILD ABORTED: "make build" and "make ${targ}" are mutually exclusive.' 1071.137Stv @false 1081.137Stv.endif 1091.137Stv.endfor 1101.137Stv.endif 1111.58Stv 1121.166Ssimonb_SUBDIR= tools lib include gnu bin games libexec sbin usr.bin 1131.205Sthorpej_SUBDIR+= usr.sbin share rescue sys etc .WAIT distrib regress 1141.105Sassar 1151.193Slukem# 1161.137Stv# Weed out directories that don't exist. 1171.193Slukem# 1181.36Sexplorer 1191.137Stv.for dir in ${_SUBDIR} 1201.154Stv.if exists(${dir}/Makefile) && (${BUILD_${dir}:Uyes} != "no") 1211.137StvSUBDIR+= ${dir} 1221.36Sexplorer.endif 1231.137Stv.endfor 1241.21Scgd 1251.13Sbrezak.if exists(regress) 1261.228Slukemregression-tests: .PHONY 1271.10Scgd @echo Running regression tests... 1281.232Slukem ${MAKEDIRTARGET} regress regress 1291.13Sbrezak.endif 1301.20Scgd 1311.214Slukem.if ${MKUNPRIVED} != "no" 1321.179SthorpejNOPOSTINSTALL= # defined 1331.179Sthorpej.endif 1341.179Sthorpej 1351.228Slukemafterinstall: .PHONY 1361.137Stv.if ${MKMAN} != "no" 1371.232Slukem ${MAKEDIRTARGET} share/man makedb 1381.137Stv.endif 1391.214Slukem.if (${MKUNPRIVED} != "no" && ${MKINFO} != "no") 1401.232Slukem ${MAKEDIRTARGET} gnu/usr.bin/texinfo/install-info infodir-meta 1411.176Slukem.endif 1421.179Sthorpej.if !defined(NOPOSTINSTALL) 1431.232Slukem ${MAKEDIRTARGET} . postinstall-check 1441.159Sperry.endif 1451.170Slukem 1461.228Slukempostinstall-check: .PHONY 1471.169Slukem @echo " === Post installation checks ===" 1481.212Slukem ${HOST_SH} ${.CURDIR}/etc/postinstall -s ${.CURDIR} -d ${DESTDIR}/ check 1491.171Slukem @echo " ================================" 1501.171Slukem 1511.228Slukempostinstall-fix: .NOTMAIN .PHONY 1521.171Slukem @echo " === Post installation fixes ===" 1531.212Slukem ${HOST_SH} ${.CURDIR}/etc/postinstall -s ${.CURDIR} -d ${DESTDIR}/ fix 1541.212Slukem @echo " ===============================" 1551.212Slukem 1561.228Slukempostinstall-fix-obsolete: .NOTMAIN .PHONY 1571.212Slukem @echo " === Removing obsolete files ===" 1581.212Slukem ${HOST_SH} ${.CURDIR}/etc/postinstall -s ${.CURDIR} -d ${DESTDIR}/ fix obsolete 1591.212Slukem @echo " ===============================" 1601.169Slukem 1611.108Serh 1621.193Slukem# 1631.137Stv# Targets (in order!) called by "make build". 1641.193Slukem# 1651.220Smrg.if ${USE_TOOLS_TOOLCHAIN} == "no" 1661.220SmrgLIBGCC_EXT=3 1671.220Smrg.else 1681.220SmrgLIBGCC_EXT= 1691.220Smrg.endif 1701.123Smrg 1711.156StvBUILDTARGETS+= check-tools 1721.214Slukem.if ${MKUPDATE} == "no" && !defined(NOCLEANDIR) 1731.155StvBUILDTARGETS+= cleandir 1741.155Stv.endif 1751.149Stv.if ${MKOBJDIRS} != "no" 1761.137StvBUILDTARGETS+= obj 1771.123Smrg.endif 1781.138Stv.if ${USETOOLS} == "yes" 1791.152StvBUILDTARGETS+= do-tools 1801.131Stv.endif 1811.137Stv.if !defined(NODISTRIBDIRS) 1821.137StvBUILDTARGETS+= do-distrib-dirs 1831.131Stv.endif 1841.137Stv.if !defined(NOINCLUDES) 1851.137StvBUILDTARGETS+= includes 1861.131Stv.endif 1871.202SthorpejBUILDTARGETS+= do-tools-compat 1881.231SskrllBUILDTARGETS+= do-lib-csu 1891.207Sdrochner.if ${MKGCC} != "no" 1901.220SmrgBUILDTARGETS+= do-gnu-lib-libgcc${LIBGCC_EXT} 1911.207Sdrochner.endif 1921.231SskrllBUILDTARGETS+= do-lib-libc 1931.224Slukem.if ${MKCRYPTO} != "no" 1941.224SlukemBUILDTARGETS+= do-lib-libdes 1951.224Slukem.endif 1961.224SlukemBUILDTARGETS+= do-lib do-gnu-lib 1971.224SlukemBUILDTARGETS+= do-ld.so 1981.224SlukemBUILDTARGETS+= do-build 1991.227Slukem.if ${MKX11} != "no" 2001.227SlukemBUILDTARGETS+= do-x11 2011.227Slukem.endif 2021.200SlukemBUILDTARGETS+= do-obsolete 2031.131Stv 2041.193Slukem# 2051.137Stv# Enforce proper ordering of some rules. 2061.193Slukem# 2071.123Smrg 2081.137Stv.ORDER: ${BUILDTARGETS} 2091.228Slukemincludes-lib: .PHONY includes-include includes-sys 2101.228Slukemincludes-gnu: .PHONY includes-lib 2111.123Smrg 2121.193Slukem# 2131.137Stv# Build the system and install into DESTDIR. 2141.193Slukem# 2151.123Smrg 2161.191SlukemSTART_TIME!= date 2171.191Slukem 2181.228Slukembuild: .PHONY 2191.137Stv.if defined(BUILD_DONE) 2201.137Stv @echo "Build already installed into ${DESTDIR}" 2211.137Stv.else 2221.191Slukem @echo "Build started at: ${START_TIME}" 2231.145Stv.for tgt in ${BUILDTARGETS} 2241.232Slukem ${MAKEDIRTARGET} . ${tgt} 2251.145Stv.endfor 2261.232Slukem ${MAKEDIRTARGET} etc install-etc-release 2271.191Slukem @echo "Build started at: ${START_TIME}" 2281.172Sbjh21 @printf "Build finished at: " && date 2291.71Smycroft.endif 2301.160Sthorpej 2311.193Slukem# 2321.160Sthorpej# Build a full distribution, but not a release (i.e. no sets into 2331.193Slukem# ${RELEASEDIR}). "buildworld" enforces a build to ${DESTDIR} != / 2341.193Slukem# 2351.160Sthorpej 2361.228Slukemdistribution buildworld: .PHONY 2371.194Slukem.if make(buildworld) && \ 2381.194Slukem (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/") 2391.193Slukem @echo "Won't make ${.TARGET} with DESTDIR=/" 2401.193Slukem @false 2411.193Slukem.endif 2421.232Slukem ${MAKEDIRTARGET} . build NOPOSTINSTALL=1 2431.232Slukem ${MAKEDIRTARGET} etc distribution INSTALL_DONE=1 2441.181Sthorpej.if defined(DESTDIR) && ${DESTDIR} != "" && ${DESTDIR} != "/" 2451.232Slukem ${MAKEDIRTARGET} . postinstall-fix-obsolete 2461.232Slukem ${MAKEDIRTARGET} distrib/sets checkflist 2471.181Sthorpej.endif 2481.192Slukem @echo "make ${.TARGET} started at: ${START_TIME}" 2491.185Slukem @printf "make ${.TARGET} finished at: " && date 2501.123Smrg 2511.193Slukem# 2521.193Slukem# Install the distribution from $DESTDIR to $INSTALLWORLDDIR (defaults to `/') 2531.193Slukem# If installing to /, ensures that the host's operating system is NetBSD and 2541.193Slukem# the host's `uname -m` == ${MACHINE}. 2551.193Slukem# 2561.193Slukem 2571.193SlukemHOST_UNAME_S!= uname -s 2581.193SlukemHOST_UNAME_M!= uname -m 2591.193Slukem 2601.228Slukeminstallworld: .PHONY 2611.194Slukem.if (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/") 2621.193Slukem @echo "Can't make ${.TARGET} to DESTDIR=/" 2631.193Slukem @false 2641.193Slukem.endif 2651.193Slukem.if !defined(INSTALLWORLDDIR) || \ 2661.193Slukem ${INSTALLWORLDDIR} == "" || ${INSTALLWORLDDIR} == "/" 2671.193Slukem.if (${HOST_UNAME_S} != "NetBSD") 2681.193Slukem @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_S} to NetBSD with INSTALLWORLDDIR=/" 2691.193Slukem @false 2701.193Slukem.endif 2711.193Slukem.if (${HOST_UNAME_M} != ${MACHINE}) 2721.193Slukem @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_M} to ${MACHINE} with INSTALLWORLDDIR=/" 2731.193Slukem @false 2741.193Slukem.endif 2751.193Slukem.endif 2761.232Slukem ${MAKEDIRTARGET} distrib/sets installsets \ 2771.232Slukem INSTALLDIR=${INSTALLWORLDDIR:U/} INSTALLSETS= 2781.232Slukem ${MAKEDIRTARGET} . postinstall-check DESTDIR=${INSTALLWORLDDIR} 2791.193Slukem @echo "make ${.TARGET} started at: ${START_TIME}" 2801.193Slukem @printf "make ${.TARGET} finished at: " && date 2811.199Slukem 2821.199Slukem# 2831.206Slukem# Create sets from $DESTDIR or $NETBSDSRCDIR into $RELEASEDIR 2841.199Slukem# 2851.199Slukem 2861.206Slukem.for tgt in sets sourcesets 2871.228Slukem${tgt}: .PHONY 2881.232Slukem ${MAKEDIRTARGET} distrib/sets ${tgt} 2891.206Slukem.endfor 2901.193Slukem 2911.193Slukem# 2921.181Sthorpej# Build a release or snapshot (implies "make build"). Note that 2931.181Sthorpej# in this case, the set lists will be checked before the tar files 2941.181Sthorpej# are made. 2951.193Slukem# 2961.123Smrg 2971.228Slukemrelease snapshot: .PHONY 2981.232Slukem ${MAKEDIRTARGET} . build NOPOSTINSTALL=1 2991.232Slukem ${MAKEDIRTARGET} etc release INSTALL_DONE=1 3001.192Slukem @echo "make ${.TARGET} started at: ${START_TIME}" 3011.185Slukem @printf "make ${.TARGET} finished at: " && date 3021.123Smrg 3031.193Slukem# 3041.137Stv# Special components of the "make build" process. 3051.193Slukem# 3061.156Stv 3071.228Slukemcheck-tools: .PHONY 3081.223Slukem.if ${TOOLCHAIN_MISSING} != "no" && !defined(EXTERNAL_TOOLCHAIN) 3091.187Sthorpej @echo '*** WARNING: Building on MACHINE=${MACHINE} with missing toolchain.' 3101.187Sthorpej @echo '*** May result in a failed build or corrupt binaries!' 3111.187Sthorpej.elif defined(EXTERNAL_TOOLCHAIN) 3121.187Sthorpej @echo '*** Using external toolchain rooted at ${EXTERNAL_TOOLCHAIN}.' 3131.156Stv.endif 3141.173Ssommerfe.if defined(NBUILDJOBS) 3151.173Ssommerfe @echo '*** WARNING: NBUILDJOBS is obsolete; use -j directly instead!' 3161.173Ssommerfe.endif 3171.123Smrg 3181.228Slukemdo-distrib-dirs: .PHONY 3191.147Sjmc.if !defined(DESTDIR) || ${DESTDIR} == "" 3201.232Slukem ${MAKEDIRTARGET} etc distrib-dirs DESTDIR=/ 3211.147Sjmc.else 3221.232Slukem ${MAKEDIRTARGET} etc distrib-dirs DESTDIR=${DESTDIR} 3231.147Sjmc.endif 3241.190Slukem 3251.190Slukem.for targ in cleandir obj includes 3261.228Slukemdo-${targ}: .PHONY ${targ} 3271.190Slukem @true 3281.190Slukem.endfor 3291.123Smrg 3301.220Smrg.for dir in tools tools/compat lib/csu gnu/lib/libgcc${LIBGCC_EXT} lib/libc lib/libdes lib gnu/lib 3311.228Slukemdo-${dir:S/\//-/g}: .PHONY 3321.137Stv.for targ in dependall install 3331.232Slukem ${MAKEDIRTARGET} ${dir} ${targ} 3341.137Stv.endfor 3351.184Slukem.endfor 3361.184Slukem 3371.228Slukemdo-ld.so: .PHONY 3381.184Slukem.for targ in dependall install 3391.189Sitohy.if (${OBJECT_FMT} == "a.out") 3401.232Slukem ${MAKEDIRTARGET} libexec/ld.aout_so ${targ} 3411.189Sitohy.endif 3421.189Sitohy.if (${OBJECT_FMT} == "ELF") 3431.232Slukem ${MAKEDIRTARGET} libexec/ld.elf_so ${targ} 3441.189Sitohy.endif 3451.137Stv.endfor 3461.143Stv 3471.228Slukemdo-build: .PHONY 3481.154Stv.for targ in dependall install 3491.232Slukem ${MAKEDIRTARGET} . ${targ} BUILD_tools=no BUILD_lib=no 3501.154Stv.endfor 3511.200Slukem 3521.228Slukemdo-x11: .PHONY 3531.232Slukem ${MAKEDIRTARGET} x11 build 3541.227Slukem 3551.228Slukemdo-obsolete: .PHONY 3561.232Slukem ${MAKEDIRTARGET} etc install-obsolete-lists 3571.87Scjs 3581.193Slukem# 3591.137Stv# Speedup stubs for some subtrees that don't need to run these rules. 3601.137Stv# (Tells <bsd.subdir.mk> not to recurse for them.) 3611.193Slukem# 3621.129Stv 3631.152Stv.for dir in bin etc distrib games libexec regress sbin usr.sbin tools 3641.228Slukemincludes-${dir}: .PHONY 3651.152Stv @true 3661.152Stv.endfor 3671.152Stv.for dir in etc distrib regress 3681.228Slukeminstall-${dir}: .PHONY 3691.152Stv @true 3701.152Stv.endfor 3711.152Stv 3721.193Slukem# 3731.152Stv# XXX this needs to change when distrib Makefiles are recursion compliant 3741.193Slukem# XXX many distrib subdirs need "cd etc && make snap_pre snap_kern" first... 3751.193Slukem# 3761.228Slukemdependall-distrib depend-distrib all-distrib: .PHONY 3771.136Snathanw @true 3781.130Stv 3791.211Slukem.include <bsd.sys.mk> 3801.151Stv.include <bsd.obj.mk> 3811.209Slukem.include <bsd.kernobj.mk> 3821.146Stv.include <bsd.subdir.mk> 3831.144Stv 3841.228Slukembuild-docs: .PHONY ${.CURDIR}/BUILDING 3851.188Slukem${.CURDIR}/BUILDING: doc/BUILDING.mdoc 3861.230Slukem ${_MKMSG_CREATE} ${.TARGET} 3871.216Slukem ${TOOL_GROFF} -mdoc -Tascii -P-bou $> >$@ 3881.209Slukem 3891.209Slukem 3901.209Slukem# 3911.209Slukem# Display current make(1) parameters 3921.209Slukem# 3931.228Slukemparams: .PHONY 3941.232Slukem ${MAKEDIRTARGET} etc params 395