Makefile revision 1.239
11.239Slukem# $NetBSD: Makefile,v 1.239 2005/04/17 15:18:34 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.238Slukem# do-lib-csu: builds and installs prerequisites from lib/csu. 721.236Sthorpej# do-gnu-lib-crtstuff3: builds and installs prerequisites from 731.236Sthorpej# gnu/lib/crtstuff3 741.222Slukem# do-gnu-lib-libgcc3: builds and installs prerequisites from gnu/lib/libgcc3 751.186Sthorpej# do-lib-libc: builds and installs prerequisites from lib/libc. 761.143Stv# do-lib: builds and installs prerequisites from lib. 771.143Stv# do-gnu-lib: builds and installs prerequisites from gnu/lib. 781.189Sitohy# do-ld.so: builds and installs prerequisites from libexec/ld.*_so. 791.137Stv# do-build: builds and installs the entire system. 801.227Slukem# do-x11: builds and installs X11R6 from src/x11 if ${MKX11} != "no" 811.222Slukem# do-obsolete: installs the obsolete sets (for the postinstall-* targets). 821.193Slukem# 831.32Scgd 841.146Stv.if ${.MAKEFLAGS:M${.CURDIR}/share/mk} == "" 851.146Stv.MAKEFLAGS: -m ${.CURDIR}/share/mk 861.146Stv.endif 871.163Stv 881.193Slukem# 891.163Stv# If _SRC_TOP_OBJ_ gets set here, we will end up with a directory that may 901.163Stv# not be the top level objdir, because "make obj" can happen in the *middle* 911.163Stv# of "make build" (long after <bsd.own.mk> is calculated it). So, pre-set 921.163Stv# _SRC_TOP_OBJ_ here so it will not be added to ${.MAKEOVERRIDES}. 931.193Slukem# 941.163Stv_SRC_TOP_OBJ_= 951.148Sjmc 961.146Stv.include <bsd.own.mk> 971.4Scgd 981.193Slukem# 991.137Stv# Sanity check: make sure that "make build" is not invoked simultaneously 1001.137Stv# with a standard recursive target. 1011.193Slukem# 1021.137Stv 1031.137Stv.if make(build) || make(release) || make(snapshot) 1041.137Stv.for targ in ${TARGETS:Nobj:Ncleandir} 1051.137Stv.if make(${targ}) && !target(.BEGIN) 1061.137Stv.BEGIN: 1071.137Stv @echo 'BUILD ABORTED: "make build" and "make ${targ}" are mutually exclusive.' 1081.137Stv @false 1091.137Stv.endif 1101.137Stv.endfor 1111.137Stv.endif 1121.58Stv 1131.166Ssimonb_SUBDIR= tools lib include gnu bin games libexec sbin usr.bin 1141.205Sthorpej_SUBDIR+= usr.sbin share rescue sys etc .WAIT distrib regress 1151.105Sassar 1161.193Slukem# 1171.137Stv# Weed out directories that don't exist. 1181.193Slukem# 1191.36Sexplorer 1201.137Stv.for dir in ${_SUBDIR} 1211.154Stv.if exists(${dir}/Makefile) && (${BUILD_${dir}:Uyes} != "no") 1221.137StvSUBDIR+= ${dir} 1231.36Sexplorer.endif 1241.137Stv.endfor 1251.21Scgd 1261.13Sbrezak.if exists(regress) 1271.228Slukemregression-tests: .PHONY 1281.10Scgd @echo Running regression tests... 1291.232Slukem ${MAKEDIRTARGET} regress regress 1301.13Sbrezak.endif 1311.20Scgd 1321.214Slukem.if ${MKUNPRIVED} != "no" 1331.179SthorpejNOPOSTINSTALL= # defined 1341.179Sthorpej.endif 1351.179Sthorpej 1361.228Slukemafterinstall: .PHONY 1371.137Stv.if ${MKMAN} != "no" 1381.232Slukem ${MAKEDIRTARGET} share/man makedb 1391.137Stv.endif 1401.214Slukem.if (${MKUNPRIVED} != "no" && ${MKINFO} != "no") 1411.232Slukem ${MAKEDIRTARGET} gnu/usr.bin/texinfo/install-info infodir-meta 1421.176Slukem.endif 1431.179Sthorpej.if !defined(NOPOSTINSTALL) 1441.232Slukem ${MAKEDIRTARGET} . postinstall-check 1451.159Sperry.endif 1461.170Slukem 1471.239Slukem_POSTINSTALL= ${.CURDIR}/usr.sbin/postinstall/postinstall 1481.239Slukem 1491.228Slukempostinstall-check: .PHONY 1501.169Slukem @echo " === Post installation checks ===" 1511.239Slukem ${HOST_SH} ${_POSTINSTALL} -s ${.CURDIR} -d ${DESTDIR}/ check 1521.171Slukem @echo " ================================" 1531.171Slukem 1541.228Slukempostinstall-fix: .NOTMAIN .PHONY 1551.171Slukem @echo " === Post installation fixes ===" 1561.239Slukem ${HOST_SH} ${_POSTINSTALL} -s ${.CURDIR} -d ${DESTDIR}/ fix 1571.212Slukem @echo " ===============================" 1581.212Slukem 1591.228Slukempostinstall-fix-obsolete: .NOTMAIN .PHONY 1601.212Slukem @echo " === Removing obsolete files ===" 1611.239Slukem ${HOST_SH} ${_POSTINSTALL} -s ${.CURDIR} -d ${DESTDIR}/ fix obsolete 1621.212Slukem @echo " ===============================" 1631.169Slukem 1641.108Serh 1651.193Slukem# 1661.137Stv# Targets (in order!) called by "make build". 1671.193Slukem# 1681.220Smrg.if ${USE_TOOLS_TOOLCHAIN} == "no" 1691.220SmrgLIBGCC_EXT=3 1701.220Smrg.else 1711.220SmrgLIBGCC_EXT= 1721.220Smrg.endif 1731.123Smrg 1741.156StvBUILDTARGETS+= check-tools 1751.214Slukem.if ${MKUPDATE} == "no" && !defined(NOCLEANDIR) 1761.155StvBUILDTARGETS+= cleandir 1771.155Stv.endif 1781.149Stv.if ${MKOBJDIRS} != "no" 1791.137StvBUILDTARGETS+= obj 1801.123Smrg.endif 1811.138Stv.if ${USETOOLS} == "yes" 1821.152StvBUILDTARGETS+= do-tools 1831.131Stv.endif 1841.137Stv.if !defined(NODISTRIBDIRS) 1851.137StvBUILDTARGETS+= do-distrib-dirs 1861.131Stv.endif 1871.137Stv.if !defined(NOINCLUDES) 1881.137StvBUILDTARGETS+= includes 1891.131Stv.endif 1901.202SthorpejBUILDTARGETS+= do-tools-compat 1911.231SskrllBUILDTARGETS+= do-lib-csu 1921.207Sdrochner.if ${MKGCC} != "no" 1931.237Stacha.if ${HAVE_GCC3} != "no" 1941.236SthorpejBUILDTARGETS+= do-gnu-lib-crtstuff${LIBGCC_EXT} 1951.237Stacha.endif 1961.220SmrgBUILDTARGETS+= do-gnu-lib-libgcc${LIBGCC_EXT} 1971.207Sdrochner.endif 1981.231SskrllBUILDTARGETS+= do-lib-libc 1991.224SlukemBUILDTARGETS+= do-lib do-gnu-lib 2001.224SlukemBUILDTARGETS+= do-ld.so 2011.224SlukemBUILDTARGETS+= do-build 2021.227Slukem.if ${MKX11} != "no" 2031.227SlukemBUILDTARGETS+= do-x11 2041.227Slukem.endif 2051.200SlukemBUILDTARGETS+= do-obsolete 2061.131Stv 2071.193Slukem# 2081.137Stv# Enforce proper ordering of some rules. 2091.193Slukem# 2101.123Smrg 2111.137Stv.ORDER: ${BUILDTARGETS} 2121.228Slukemincludes-lib: .PHONY includes-include includes-sys 2131.228Slukemincludes-gnu: .PHONY includes-lib 2141.123Smrg 2151.193Slukem# 2161.137Stv# Build the system and install into DESTDIR. 2171.193Slukem# 2181.123Smrg 2191.191SlukemSTART_TIME!= date 2201.191Slukem 2211.228Slukembuild: .PHONY 2221.137Stv.if defined(BUILD_DONE) 2231.137Stv @echo "Build already installed into ${DESTDIR}" 2241.137Stv.else 2251.191Slukem @echo "Build started at: ${START_TIME}" 2261.145Stv.for tgt in ${BUILDTARGETS} 2271.232Slukem ${MAKEDIRTARGET} . ${tgt} 2281.145Stv.endfor 2291.232Slukem ${MAKEDIRTARGET} etc install-etc-release 2301.191Slukem @echo "Build started at: ${START_TIME}" 2311.172Sbjh21 @printf "Build finished at: " && date 2321.71Smycroft.endif 2331.160Sthorpej 2341.193Slukem# 2351.160Sthorpej# Build a full distribution, but not a release (i.e. no sets into 2361.193Slukem# ${RELEASEDIR}). "buildworld" enforces a build to ${DESTDIR} != / 2371.193Slukem# 2381.160Sthorpej 2391.228Slukemdistribution buildworld: .PHONY 2401.194Slukem.if make(buildworld) && \ 2411.194Slukem (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/") 2421.193Slukem @echo "Won't make ${.TARGET} with DESTDIR=/" 2431.193Slukem @false 2441.193Slukem.endif 2451.232Slukem ${MAKEDIRTARGET} . build NOPOSTINSTALL=1 2461.232Slukem ${MAKEDIRTARGET} etc distribution INSTALL_DONE=1 2471.181Sthorpej.if defined(DESTDIR) && ${DESTDIR} != "" && ${DESTDIR} != "/" 2481.232Slukem ${MAKEDIRTARGET} . postinstall-fix-obsolete 2491.232Slukem ${MAKEDIRTARGET} distrib/sets checkflist 2501.181Sthorpej.endif 2511.192Slukem @echo "make ${.TARGET} started at: ${START_TIME}" 2521.185Slukem @printf "make ${.TARGET} finished at: " && date 2531.123Smrg 2541.193Slukem# 2551.193Slukem# Install the distribution from $DESTDIR to $INSTALLWORLDDIR (defaults to `/') 2561.193Slukem# If installing to /, ensures that the host's operating system is NetBSD and 2571.193Slukem# the host's `uname -m` == ${MACHINE}. 2581.193Slukem# 2591.193Slukem 2601.193SlukemHOST_UNAME_S!= uname -s 2611.193SlukemHOST_UNAME_M!= uname -m 2621.193Slukem 2631.228Slukeminstallworld: .PHONY 2641.194Slukem.if (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/") 2651.193Slukem @echo "Can't make ${.TARGET} to DESTDIR=/" 2661.193Slukem @false 2671.193Slukem.endif 2681.193Slukem.if !defined(INSTALLWORLDDIR) || \ 2691.193Slukem ${INSTALLWORLDDIR} == "" || ${INSTALLWORLDDIR} == "/" 2701.193Slukem.if (${HOST_UNAME_S} != "NetBSD") 2711.193Slukem @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_S} to NetBSD with INSTALLWORLDDIR=/" 2721.193Slukem @false 2731.193Slukem.endif 2741.193Slukem.if (${HOST_UNAME_M} != ${MACHINE}) 2751.193Slukem @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_M} to ${MACHINE} with INSTALLWORLDDIR=/" 2761.193Slukem @false 2771.193Slukem.endif 2781.193Slukem.endif 2791.232Slukem ${MAKEDIRTARGET} distrib/sets installsets \ 2801.232Slukem INSTALLDIR=${INSTALLWORLDDIR:U/} INSTALLSETS= 2811.232Slukem ${MAKEDIRTARGET} . postinstall-check DESTDIR=${INSTALLWORLDDIR} 2821.193Slukem @echo "make ${.TARGET} started at: ${START_TIME}" 2831.193Slukem @printf "make ${.TARGET} finished at: " && date 2841.199Slukem 2851.199Slukem# 2861.206Slukem# Create sets from $DESTDIR or $NETBSDSRCDIR into $RELEASEDIR 2871.199Slukem# 2881.199Slukem 2891.206Slukem.for tgt in sets sourcesets 2901.228Slukem${tgt}: .PHONY 2911.232Slukem ${MAKEDIRTARGET} distrib/sets ${tgt} 2921.206Slukem.endfor 2931.193Slukem 2941.193Slukem# 2951.181Sthorpej# Build a release or snapshot (implies "make build"). Note that 2961.181Sthorpej# in this case, the set lists will be checked before the tar files 2971.181Sthorpej# are made. 2981.193Slukem# 2991.123Smrg 3001.228Slukemrelease snapshot: .PHONY 3011.232Slukem ${MAKEDIRTARGET} . build NOPOSTINSTALL=1 3021.232Slukem ${MAKEDIRTARGET} etc release INSTALL_DONE=1 3031.192Slukem @echo "make ${.TARGET} started at: ${START_TIME}" 3041.185Slukem @printf "make ${.TARGET} finished at: " && date 3051.123Smrg 3061.193Slukem# 3071.137Stv# Special components of the "make build" process. 3081.193Slukem# 3091.156Stv 3101.228Slukemcheck-tools: .PHONY 3111.223Slukem.if ${TOOLCHAIN_MISSING} != "no" && !defined(EXTERNAL_TOOLCHAIN) 3121.187Sthorpej @echo '*** WARNING: Building on MACHINE=${MACHINE} with missing toolchain.' 3131.187Sthorpej @echo '*** May result in a failed build or corrupt binaries!' 3141.187Sthorpej.elif defined(EXTERNAL_TOOLCHAIN) 3151.187Sthorpej @echo '*** Using external toolchain rooted at ${EXTERNAL_TOOLCHAIN}.' 3161.156Stv.endif 3171.173Ssommerfe.if defined(NBUILDJOBS) 3181.173Ssommerfe @echo '*** WARNING: NBUILDJOBS is obsolete; use -j directly instead!' 3191.173Ssommerfe.endif 3201.123Smrg 3211.228Slukemdo-distrib-dirs: .PHONY 3221.147Sjmc.if !defined(DESTDIR) || ${DESTDIR} == "" 3231.232Slukem ${MAKEDIRTARGET} etc distrib-dirs DESTDIR=/ 3241.147Sjmc.else 3251.232Slukem ${MAKEDIRTARGET} etc distrib-dirs DESTDIR=${DESTDIR} 3261.147Sjmc.endif 3271.190Slukem 3281.190Slukem.for targ in cleandir obj includes 3291.228Slukemdo-${targ}: .PHONY ${targ} 3301.190Slukem @true 3311.190Slukem.endfor 3321.123Smrg 3331.236Sthorpej.for dir in tools tools/compat lib/csu gnu/lib/crtstuff${LIBGCC_EXT} gnu/lib/libgcc${LIBGCC_EXT} lib/libc lib/libdes lib gnu/lib 3341.228Slukemdo-${dir:S/\//-/g}: .PHONY 3351.137Stv.for targ in dependall install 3361.232Slukem ${MAKEDIRTARGET} ${dir} ${targ} 3371.137Stv.endfor 3381.184Slukem.endfor 3391.184Slukem 3401.228Slukemdo-ld.so: .PHONY 3411.184Slukem.for targ in dependall install 3421.189Sitohy.if (${OBJECT_FMT} == "a.out") 3431.232Slukem ${MAKEDIRTARGET} libexec/ld.aout_so ${targ} 3441.189Sitohy.endif 3451.189Sitohy.if (${OBJECT_FMT} == "ELF") 3461.232Slukem ${MAKEDIRTARGET} libexec/ld.elf_so ${targ} 3471.189Sitohy.endif 3481.137Stv.endfor 3491.143Stv 3501.228Slukemdo-build: .PHONY 3511.154Stv.for targ in dependall install 3521.232Slukem ${MAKEDIRTARGET} . ${targ} BUILD_tools=no BUILD_lib=no 3531.154Stv.endfor 3541.200Slukem 3551.228Slukemdo-x11: .PHONY 3561.232Slukem ${MAKEDIRTARGET} x11 build 3571.227Slukem 3581.228Slukemdo-obsolete: .PHONY 3591.232Slukem ${MAKEDIRTARGET} etc install-obsolete-lists 3601.87Scjs 3611.193Slukem# 3621.137Stv# Speedup stubs for some subtrees that don't need to run these rules. 3631.137Stv# (Tells <bsd.subdir.mk> not to recurse for them.) 3641.193Slukem# 3651.129Stv 3661.152Stv.for dir in bin etc distrib games libexec regress sbin usr.sbin tools 3671.228Slukemincludes-${dir}: .PHONY 3681.152Stv @true 3691.152Stv.endfor 3701.152Stv.for dir in etc distrib regress 3711.228Slukeminstall-${dir}: .PHONY 3721.152Stv @true 3731.152Stv.endfor 3741.152Stv 3751.193Slukem# 3761.152Stv# XXX this needs to change when distrib Makefiles are recursion compliant 3771.193Slukem# XXX many distrib subdirs need "cd etc && make snap_pre snap_kern" first... 3781.193Slukem# 3791.228Slukemdependall-distrib depend-distrib all-distrib: .PHONY 3801.136Snathanw @true 3811.130Stv 3821.211Slukem.include <bsd.sys.mk> 3831.151Stv.include <bsd.obj.mk> 3841.209Slukem.include <bsd.kernobj.mk> 3851.146Stv.include <bsd.subdir.mk> 3861.144Stv 3871.228Slukembuild-docs: .PHONY ${.CURDIR}/BUILDING 3881.188Slukem${.CURDIR}/BUILDING: doc/BUILDING.mdoc 3891.230Slukem ${_MKMSG_CREATE} ${.TARGET} 3901.216Slukem ${TOOL_GROFF} -mdoc -Tascii -P-bou $> >$@ 3911.209Slukem 3921.209Slukem 3931.209Slukem# 3941.209Slukem# Display current make(1) parameters 3951.209Slukem# 3961.228Slukemparams: .PHONY 3971.232Slukem ${MAKEDIRTARGET} etc params 398