Makefile revision 1.246
11.246Sdbj# $NetBSD: Makefile,v 1.246 2006/09/07 03:51:44 dbj 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.240Slukem# Does a `make distribution', 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.241Sapb# syspkgs: 631.241Sapb# Populate ${RELEASEDIR}/${MACHINE}/binary/syspkgs from ${DESTDIR} 641.243Sapb# iso-image: 651.243Sapb# Create CD-ROM image in RELEASEDIR/MACHINE/installation. 661.243Sapb# RELEASEDIR must already have been populated by `make release' 671.243Sapb# or equivalent. 681.123Smrg# 691.137Stv# Targets invoked by `make build,' in order: 701.155Stv# cleandir: cleans the tree. 711.137Stv# obj: creates object directories. 721.152Stv# do-tools: builds host toolchain. 731.208Slukem# do-distrib-dirs: creates the distribution directories. 741.208Slukem# includes: installs include files. 751.202Sthorpej# do-tools-compat: builds the "libnbcompat" library; needed for some 761.202Sthorpej# random host tool programs in the source tree. 771.238Slukem# do-lib-csu: builds and installs prerequisites from lib/csu. 781.236Sthorpej# do-gnu-lib-crtstuff3: builds and installs prerequisites from 791.236Sthorpej# gnu/lib/crtstuff3 801.222Slukem# do-gnu-lib-libgcc3: builds and installs prerequisites from gnu/lib/libgcc3 811.186Sthorpej# do-lib-libc: builds and installs prerequisites from lib/libc. 821.143Stv# do-lib: builds and installs prerequisites from lib. 831.143Stv# do-gnu-lib: builds and installs prerequisites from gnu/lib. 841.189Sitohy# do-ld.so: builds and installs prerequisites from libexec/ld.*_so. 851.137Stv# do-build: builds and installs the entire system. 861.227Slukem# do-x11: builds and installs X11R6 from src/x11 if ${MKX11} != "no" 871.222Slukem# do-obsolete: installs the obsolete sets (for the postinstall-* targets). 881.193Slukem# 891.32Scgd 901.146Stv.if ${.MAKEFLAGS:M${.CURDIR}/share/mk} == "" 911.146Stv.MAKEFLAGS: -m ${.CURDIR}/share/mk 921.146Stv.endif 931.163Stv 941.193Slukem# 951.163Stv# If _SRC_TOP_OBJ_ gets set here, we will end up with a directory that may 961.163Stv# not be the top level objdir, because "make obj" can happen in the *middle* 971.163Stv# of "make build" (long after <bsd.own.mk> is calculated it). So, pre-set 981.163Stv# _SRC_TOP_OBJ_ here so it will not be added to ${.MAKEOVERRIDES}. 991.193Slukem# 1001.163Stv_SRC_TOP_OBJ_= 1011.148Sjmc 1021.146Stv.include <bsd.own.mk> 1031.4Scgd 1041.193Slukem# 1051.137Stv# Sanity check: make sure that "make build" is not invoked simultaneously 1061.137Stv# with a standard recursive target. 1071.193Slukem# 1081.137Stv 1091.137Stv.if make(build) || make(release) || make(snapshot) 1101.137Stv.for targ in ${TARGETS:Nobj:Ncleandir} 1111.137Stv.if make(${targ}) && !target(.BEGIN) 1121.137Stv.BEGIN: 1131.137Stv @echo 'BUILD ABORTED: "make build" and "make ${targ}" are mutually exclusive.' 1141.137Stv @false 1151.137Stv.endif 1161.137Stv.endfor 1171.137Stv.endif 1181.58Stv 1191.166Ssimonb_SUBDIR= tools lib include gnu bin games libexec sbin usr.bin 1201.205Sthorpej_SUBDIR+= usr.sbin share rescue sys etc .WAIT distrib regress 1211.105Sassar 1221.193Slukem# 1231.137Stv# Weed out directories that don't exist. 1241.193Slukem# 1251.36Sexplorer 1261.137Stv.for dir in ${_SUBDIR} 1271.246Sdbj.if ("${dir}" == ".WAIT") || exists(${dir}/Makefile) && (${BUILD_${dir}:Uyes} != "no") 1281.137StvSUBDIR+= ${dir} 1291.36Sexplorer.endif 1301.137Stv.endfor 1311.21Scgd 1321.13Sbrezak.if exists(regress) 1331.242Sdslregression-tests: .PHONY .MAKE 1341.10Scgd @echo Running regression tests... 1351.232Slukem ${MAKEDIRTARGET} regress regress 1361.13Sbrezak.endif 1371.20Scgd 1381.214Slukem.if ${MKUNPRIVED} != "no" 1391.179SthorpejNOPOSTINSTALL= # defined 1401.179Sthorpej.endif 1411.179Sthorpej 1421.242Sdslafterinstall: .PHONY .MAKE 1431.137Stv.if ${MKMAN} != "no" 1441.232Slukem ${MAKEDIRTARGET} share/man makedb 1451.137Stv.endif 1461.214Slukem.if (${MKUNPRIVED} != "no" && ${MKINFO} != "no") 1471.232Slukem ${MAKEDIRTARGET} gnu/usr.bin/texinfo/install-info infodir-meta 1481.176Slukem.endif 1491.179Sthorpej.if !defined(NOPOSTINSTALL) 1501.232Slukem ${MAKEDIRTARGET} . postinstall-check 1511.159Sperry.endif 1521.170Slukem 1531.239Slukem_POSTINSTALL= ${.CURDIR}/usr.sbin/postinstall/postinstall 1541.239Slukem 1551.228Slukempostinstall-check: .PHONY 1561.169Slukem @echo " === Post installation checks ===" 1571.239Slukem ${HOST_SH} ${_POSTINSTALL} -s ${.CURDIR} -d ${DESTDIR}/ check 1581.171Slukem @echo " ================================" 1591.171Slukem 1601.228Slukempostinstall-fix: .NOTMAIN .PHONY 1611.171Slukem @echo " === Post installation fixes ===" 1621.239Slukem ${HOST_SH} ${_POSTINSTALL} -s ${.CURDIR} -d ${DESTDIR}/ fix 1631.212Slukem @echo " ===============================" 1641.212Slukem 1651.228Slukempostinstall-fix-obsolete: .NOTMAIN .PHONY 1661.212Slukem @echo " === Removing obsolete files ===" 1671.239Slukem ${HOST_SH} ${_POSTINSTALL} -s ${.CURDIR} -d ${DESTDIR}/ fix obsolete 1681.212Slukem @echo " ===============================" 1691.169Slukem 1701.108Serh 1711.193Slukem# 1721.137Stv# Targets (in order!) called by "make build". 1731.193Slukem# 1741.245Smrg.if ${HAVE_GCC} == "3" 1751.220SmrgLIBGCC_EXT=3 1761.245Smrg.else 1771.244SmrgLIBGCC_EXT=4 1781.220Smrg.endif 1791.123Smrg 1801.156StvBUILDTARGETS+= check-tools 1811.214Slukem.if ${MKUPDATE} == "no" && !defined(NOCLEANDIR) 1821.155StvBUILDTARGETS+= cleandir 1831.155Stv.endif 1841.149Stv.if ${MKOBJDIRS} != "no" 1851.137StvBUILDTARGETS+= obj 1861.123Smrg.endif 1871.138Stv.if ${USETOOLS} == "yes" 1881.152StvBUILDTARGETS+= do-tools 1891.131Stv.endif 1901.137Stv.if !defined(NODISTRIBDIRS) 1911.137StvBUILDTARGETS+= do-distrib-dirs 1921.131Stv.endif 1931.137Stv.if !defined(NOINCLUDES) 1941.137StvBUILDTARGETS+= includes 1951.131Stv.endif 1961.202SthorpejBUILDTARGETS+= do-tools-compat 1971.231SskrllBUILDTARGETS+= do-lib-csu 1981.207Sdrochner.if ${MKGCC} != "no" 1991.244Smrg.if (${HAVE_GCC} == "3" || ${HAVE_GCC} == "4") 2001.236SthorpejBUILDTARGETS+= do-gnu-lib-crtstuff${LIBGCC_EXT} 2011.237Stacha.endif 2021.220SmrgBUILDTARGETS+= do-gnu-lib-libgcc${LIBGCC_EXT} 2031.207Sdrochner.endif 2041.231SskrllBUILDTARGETS+= do-lib-libc 2051.224SlukemBUILDTARGETS+= do-lib do-gnu-lib 2061.224SlukemBUILDTARGETS+= do-ld.so 2071.224SlukemBUILDTARGETS+= do-build 2081.227Slukem.if ${MKX11} != "no" 2091.227SlukemBUILDTARGETS+= do-x11 2101.227Slukem.endif 2111.200SlukemBUILDTARGETS+= do-obsolete 2121.131Stv 2131.193Slukem# 2141.137Stv# Enforce proper ordering of some rules. 2151.193Slukem# 2161.123Smrg 2171.137Stv.ORDER: ${BUILDTARGETS} 2181.228Slukemincludes-lib: .PHONY includes-include includes-sys 2191.228Slukemincludes-gnu: .PHONY includes-lib 2201.123Smrg 2211.193Slukem# 2221.137Stv# Build the system and install into DESTDIR. 2231.193Slukem# 2241.123Smrg 2251.191SlukemSTART_TIME!= date 2261.191Slukem 2271.242Sdslbuild: .PHONY .MAKE 2281.137Stv.if defined(BUILD_DONE) 2291.137Stv @echo "Build already installed into ${DESTDIR}" 2301.137Stv.else 2311.191Slukem @echo "Build started at: ${START_TIME}" 2321.145Stv.for tgt in ${BUILDTARGETS} 2331.232Slukem ${MAKEDIRTARGET} . ${tgt} 2341.145Stv.endfor 2351.232Slukem ${MAKEDIRTARGET} etc install-etc-release 2361.191Slukem @echo "Build started at: ${START_TIME}" 2371.172Sbjh21 @printf "Build finished at: " && date 2381.71Smycroft.endif 2391.160Sthorpej 2401.193Slukem# 2411.160Sthorpej# Build a full distribution, but not a release (i.e. no sets into 2421.193Slukem# ${RELEASEDIR}). "buildworld" enforces a build to ${DESTDIR} != / 2431.193Slukem# 2441.160Sthorpej 2451.242Sdsldistribution buildworld: .PHONY .MAKE 2461.194Slukem.if make(buildworld) && \ 2471.194Slukem (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/") 2481.193Slukem @echo "Won't make ${.TARGET} with DESTDIR=/" 2491.193Slukem @false 2501.193Slukem.endif 2511.232Slukem ${MAKEDIRTARGET} . build NOPOSTINSTALL=1 2521.232Slukem ${MAKEDIRTARGET} etc distribution INSTALL_DONE=1 2531.181Sthorpej.if defined(DESTDIR) && ${DESTDIR} != "" && ${DESTDIR} != "/" 2541.232Slukem ${MAKEDIRTARGET} . postinstall-fix-obsolete 2551.232Slukem ${MAKEDIRTARGET} distrib/sets checkflist 2561.181Sthorpej.endif 2571.192Slukem @echo "make ${.TARGET} started at: ${START_TIME}" 2581.185Slukem @printf "make ${.TARGET} finished at: " && date 2591.123Smrg 2601.193Slukem# 2611.193Slukem# Install the distribution from $DESTDIR to $INSTALLWORLDDIR (defaults to `/') 2621.193Slukem# If installing to /, ensures that the host's operating system is NetBSD and 2631.193Slukem# the host's `uname -m` == ${MACHINE}. 2641.193Slukem# 2651.193Slukem 2661.193SlukemHOST_UNAME_S!= uname -s 2671.193SlukemHOST_UNAME_M!= uname -m 2681.193Slukem 2691.242Sdslinstallworld: .PHONY .MAKE 2701.194Slukem.if (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/") 2711.193Slukem @echo "Can't make ${.TARGET} to DESTDIR=/" 2721.193Slukem @false 2731.193Slukem.endif 2741.193Slukem.if !defined(INSTALLWORLDDIR) || \ 2751.193Slukem ${INSTALLWORLDDIR} == "" || ${INSTALLWORLDDIR} == "/" 2761.193Slukem.if (${HOST_UNAME_S} != "NetBSD") 2771.193Slukem @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_S} to NetBSD with INSTALLWORLDDIR=/" 2781.193Slukem @false 2791.193Slukem.endif 2801.193Slukem.if (${HOST_UNAME_M} != ${MACHINE}) 2811.193Slukem @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_M} to ${MACHINE} with INSTALLWORLDDIR=/" 2821.193Slukem @false 2831.193Slukem.endif 2841.193Slukem.endif 2851.232Slukem ${MAKEDIRTARGET} distrib/sets installsets \ 2861.232Slukem INSTALLDIR=${INSTALLWORLDDIR:U/} INSTALLSETS= 2871.232Slukem ${MAKEDIRTARGET} . postinstall-check DESTDIR=${INSTALLWORLDDIR} 2881.193Slukem @echo "make ${.TARGET} started at: ${START_TIME}" 2891.193Slukem @printf "make ${.TARGET} finished at: " && date 2901.199Slukem 2911.199Slukem# 2921.206Slukem# Create sets from $DESTDIR or $NETBSDSRCDIR into $RELEASEDIR 2931.199Slukem# 2941.199Slukem 2951.241Sapb.for tgt in sets sourcesets syspkgs 2961.242Sdsl${tgt}: .PHONY .MAKE 2971.232Slukem ${MAKEDIRTARGET} distrib/sets ${tgt} 2981.206Slukem.endfor 2991.193Slukem 3001.193Slukem# 3011.240Slukem# Build a release or snapshot (implies "make distribution"). Note that 3021.181Sthorpej# in this case, the set lists will be checked before the tar files 3031.181Sthorpej# are made. 3041.193Slukem# 3051.123Smrg 3061.242Sdslrelease snapshot: .PHONY .MAKE 3071.240Slukem ${MAKEDIRTARGET} . distribution 3081.240Slukem ${MAKEDIRTARGET} etc release DISTRIBUTION_DONE=1 3091.192Slukem @echo "make ${.TARGET} started at: ${START_TIME}" 3101.185Slukem @printf "make ${.TARGET} finished at: " && date 3111.123Smrg 3121.193Slukem# 3131.243Sapb# Create a CD-ROM image. 3141.243Sapb# 3151.243Sapb 3161.243Sapbiso-image: .PHONY 3171.243Sapb ${MAKEDIRTARGET} etc iso-image 3181.243Sapb @echo "make ${.TARGET} started at: ${START_TIME}" 3191.243Sapb @printf "make ${.TARGET} finished at: " && date 3201.243Sapb 3211.243Sapb# 3221.137Stv# Special components of the "make build" process. 3231.193Slukem# 3241.156Stv 3251.228Slukemcheck-tools: .PHONY 3261.223Slukem.if ${TOOLCHAIN_MISSING} != "no" && !defined(EXTERNAL_TOOLCHAIN) 3271.187Sthorpej @echo '*** WARNING: Building on MACHINE=${MACHINE} with missing toolchain.' 3281.187Sthorpej @echo '*** May result in a failed build or corrupt binaries!' 3291.187Sthorpej.elif defined(EXTERNAL_TOOLCHAIN) 3301.187Sthorpej @echo '*** Using external toolchain rooted at ${EXTERNAL_TOOLCHAIN}.' 3311.156Stv.endif 3321.173Ssommerfe.if defined(NBUILDJOBS) 3331.173Ssommerfe @echo '*** WARNING: NBUILDJOBS is obsolete; use -j directly instead!' 3341.173Ssommerfe.endif 3351.123Smrg 3361.242Sdsldo-distrib-dirs: .PHONY .MAKE 3371.147Sjmc.if !defined(DESTDIR) || ${DESTDIR} == "" 3381.232Slukem ${MAKEDIRTARGET} etc distrib-dirs DESTDIR=/ 3391.147Sjmc.else 3401.232Slukem ${MAKEDIRTARGET} etc distrib-dirs DESTDIR=${DESTDIR} 3411.147Sjmc.endif 3421.190Slukem 3431.190Slukem.for targ in cleandir obj includes 3441.228Slukemdo-${targ}: .PHONY ${targ} 3451.190Slukem @true 3461.190Slukem.endfor 3471.123Smrg 3481.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 3491.242Sdsldo-${dir:S/\//-/g}: .PHONY .MAKE 3501.137Stv.for targ in dependall install 3511.232Slukem ${MAKEDIRTARGET} ${dir} ${targ} 3521.137Stv.endfor 3531.184Slukem.endfor 3541.184Slukem 3551.242Sdsldo-ld.so: .PHONY .MAKE 3561.184Slukem.for targ in dependall install 3571.189Sitohy.if (${OBJECT_FMT} == "a.out") 3581.232Slukem ${MAKEDIRTARGET} libexec/ld.aout_so ${targ} 3591.189Sitohy.endif 3601.189Sitohy.if (${OBJECT_FMT} == "ELF") 3611.232Slukem ${MAKEDIRTARGET} libexec/ld.elf_so ${targ} 3621.189Sitohy.endif 3631.137Stv.endfor 3641.143Stv 3651.242Sdsldo-build: .PHONY .MAKE 3661.154Stv.for targ in dependall install 3671.232Slukem ${MAKEDIRTARGET} . ${targ} BUILD_tools=no BUILD_lib=no 3681.154Stv.endfor 3691.200Slukem 3701.242Sdsldo-x11: .PHONY .MAKE 3711.232Slukem ${MAKEDIRTARGET} x11 build 3721.227Slukem 3731.242Sdsldo-obsolete: .PHONY .MAKE 3741.232Slukem ${MAKEDIRTARGET} etc install-obsolete-lists 3751.87Scjs 3761.193Slukem# 3771.137Stv# Speedup stubs for some subtrees that don't need to run these rules. 3781.137Stv# (Tells <bsd.subdir.mk> not to recurse for them.) 3791.193Slukem# 3801.129Stv 3811.152Stv.for dir in bin etc distrib games libexec regress sbin usr.sbin tools 3821.228Slukemincludes-${dir}: .PHONY 3831.152Stv @true 3841.152Stv.endfor 3851.152Stv.for dir in etc distrib regress 3861.228Slukeminstall-${dir}: .PHONY 3871.152Stv @true 3881.152Stv.endfor 3891.152Stv 3901.193Slukem# 3911.152Stv# XXX this needs to change when distrib Makefiles are recursion compliant 3921.193Slukem# XXX many distrib subdirs need "cd etc && make snap_pre snap_kern" first... 3931.193Slukem# 3941.228Slukemdependall-distrib depend-distrib all-distrib: .PHONY 3951.136Snathanw @true 3961.130Stv 3971.211Slukem.include <bsd.sys.mk> 3981.151Stv.include <bsd.obj.mk> 3991.209Slukem.include <bsd.kernobj.mk> 4001.146Stv.include <bsd.subdir.mk> 4011.144Stv 4021.228Slukembuild-docs: .PHONY ${.CURDIR}/BUILDING 4031.188Slukem${.CURDIR}/BUILDING: doc/BUILDING.mdoc 4041.230Slukem ${_MKMSG_CREATE} ${.TARGET} 4051.216Slukem ${TOOL_GROFF} -mdoc -Tascii -P-bou $> >$@ 4061.209Slukem 4071.209Slukem 4081.209Slukem# 4091.209Slukem# Display current make(1) parameters 4101.209Slukem# 4111.242Sdslparams: .PHONY .MAKE 4121.232Slukem ${MAKEDIRTARGET} etc params 413