Makefile revision 1.283
1# $NetBSD: Makefile,v 1.283 2011/06/15 09:45:58 mrg Exp $ 2 3# 4# This is the top-level makefile for building NetBSD. For an outline of 5# how to build a snapshot or release, as well as other release engineering 6# information, see http://www.NetBSD.org/developers/releng/index.html 7# 8# Not everything you can set or do is documented in this makefile. In 9# particular, you should review the files in /usr/share/mk (especially 10# bsd.README) for general information on building programs and writing 11# Makefiles within this structure, and see the comments in src/etc/Makefile 12# for further information on installation and release set options. 13# 14# Variables listed below can be set on the make command line (highest 15# priority), in /etc/mk.conf (middle priority), or in the environment 16# (lowest priority). 17# 18# Variables: 19# DESTDIR is the target directory for installation of the compiled 20# software. It defaults to /. Note that programs are built against 21# libraries installed in DESTDIR. 22# MKMAN, if `no', will prevent building of manual pages. 23# MKOBJDIRS, if not `no', will build object directories at 24# an appropriate point in a build. 25# MKSHARE, if `no', will prevent building and installing 26# anything in /usr/share. 27# MKUPDATE, if not `no', will avoid a `make cleandir' at the start of 28# `make build', as well as having the effects listed in 29# /usr/share/mk/bsd.README. 30# NOCLEANDIR, if defined, will avoid a `make cleandir' at the start 31# of the `make build'. 32# NOINCLUDES will avoid the `make includes' usually done by `make build'. 33# 34# See mk.conf(5) for more details. 35# 36# 37# Targets: 38# build: 39# Builds a full release of NetBSD in DESTDIR, except for the 40# /etc configuration files. 41# If BUILD_DONE is set, this is an empty target. 42# distribution: 43# Builds a full release of NetBSD in DESTDIR, including the /etc 44# configuration files. 45# buildworld: 46# As per `make distribution', except that it ensures that DESTDIR 47# is not the root directory. 48# installworld: 49# Install the distribution from DESTDIR to INSTALLWORLDDIR (which 50# defaults to the root directory). Ensures that INSTALLWORLDDIR 51# is the not root directory if cross compiling. 52# release: 53# Does a `make distribution', and then tars up the DESTDIR files 54# into ${RELEASEDIR}/${RELEASEMACHINEDIR}, in release(7) format. 55# (See etc/Makefile for more information on this.) 56# regression-tests: 57# Runs the regression tests in "regress" on this host. 58# sets: 59# Populate ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets 60# from ${DESTDIR} 61# sourcesets: 62# Populate ${RELEASEDIR}/source/sets from ${NETBSDSRCDIR} 63# syspkgs: 64# Populate ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/syspkgs 65# from ${DESTDIR} 66# iso-image: 67# Create CD-ROM image in RELEASEDIR/iso. 68# RELEASEDIR must already have been populated by `make release' 69# or equivalent. 70# iso-image-source: 71# Create CD-ROM image with source in RELEASEDIR/iso. 72# RELEASEDIR must already have been populated by 73# `make release sourcesets' or equivalent. 74# 75# Targets invoked by `make build,' in order: 76# cleandir: cleans the tree. 77# do-top-obj: creates the top level object directory. 78# do-tools-obj: creates object directories for the host toolchain. 79# do-tools: builds host toolchain. 80# obj: creates object directories. 81# do-distrib-dirs: creates the distribution directories. 82# includes: installs include files. 83# do-tools-compat: builds the "libnbcompat" library; needed for some 84# random host tool programs in the source tree. 85# do-lib-csu: builds and installs prerequisites from lib/csu. 86# do-libgcc: builds and installs prerequisites from 87# gnu/lib/crtstuff${LIBGCC_EXT} (if necessary) and 88# gnu/lib/libgcc${LIBGCC_EXT}. 89# do-libpcc: builds and install prerequisites from 90# external/bsd/pcc/crtstuff (if necessary) and 91# external/bsd/pcc/libpcc. 92# do-lib-libc: builds and installs prerequisites from lib/libc. 93# do-lib: builds and installs prerequisites from lib. 94# do-sys-rump-dev-lib: builds and installs prerequisites from sys/rump/dev/lib 95# do-sys-rump-fs-lib: builds and installs prerequisites from sys/rump/fs/lib 96# do-sys-rump-kern-lib: builds and installs prereq. from sys/rump/kern/lib 97# do-sys-rump-net-lib: builds and installs prerequisites from sys/rump/net/lib 98# do-sys-modules: builds and installs kernel modules (used by rump binaries) 99# do-ld.so: builds and installs prerequisites from libexec/ld.*_so. 100# do-compat-lib-csu: builds and installs prerequisites from compat/lib/csu 101# if ${MKCOMPAT} != "no". 102# do-compat-libgcc: builds and installs prerequisites from 103# compat/gnu/lib/crtstuff${LIBGCC_EXT} (if necessary) and 104# compat/gnu/lib/libgcc${LIBGCC_EXT} if ${MKCOMPAT} != "no". 105# do-compat-lib-libc: builds and installs prerequisites from compat/lib/libc 106# if ${MKCOMPAT} != "no". 107# do-build: builds and installs the entire system. 108# do-x11: builds and installs X11 if ${MKX11} != "no"; either 109# X11R7 from src/external/mit/xorg if ${X11FLAVOUR} == "Xorg" 110# or X11R6 from src/x11 111# do-extsrc: builds and installs extsrc if ${MKEXTSRC} != "no". 112# do-obsolete: installs the obsolete sets (for the postinstall-* targets). 113# 114 115.if ${.MAKEFLAGS:M${.CURDIR}/share/mk} == "" 116.MAKEFLAGS: -m ${.CURDIR}/share/mk 117.endif 118 119# 120# If _SRC_TOP_OBJ_ gets set here, we will end up with a directory that may 121# not be the top level objdir, because "make obj" can happen in the *middle* 122# of "make build" (long after <bsd.own.mk> is calculated it). So, pre-set 123# _SRC_TOP_OBJ_ here so it will not be added to ${.MAKEOVERRIDES}. 124# 125_SRC_TOP_OBJ_= 126 127.include <bsd.own.mk> 128 129# 130# Sanity check: make sure that "make build" is not invoked simultaneously 131# with a standard recursive target. 132# 133 134.if make(build) || make(release) || make(snapshot) 135.for targ in ${TARGETS:Nobj:Ncleandir} 136.if make(${targ}) && !target(.BEGIN) 137.BEGIN: 138 @echo 'BUILD ABORTED: "make build" and "make ${targ}" are mutually exclusive.' 139 @false 140.endif 141.endfor 142.endif 143 144# 145# _SUBDIR is used to set SUBDIR, after removing directories that have 146# BUILD_${dir}=no, or that have no ${dir}/Makefile. 147# 148_SUBDIR= tools lib include gnu external crypto/external bin games 149_SUBDIR+= libexec sbin usr.bin 150_SUBDIR+= usr.sbin share rescue sys etc tests compat .WAIT distrib regress 151 152.for dir in ${_SUBDIR} 153.if "${dir}" == ".WAIT" \ 154 || (${BUILD_${dir}:Uyes} != "no" && exists(${dir}/Makefile)) 155SUBDIR+= ${dir} 156.endif 157.endfor 158 159.if exists(regress) 160regression-tests: .PHONY .MAKE 161 @echo Running regression tests... 162 ${MAKEDIRTARGET} regress regress 163.endif 164 165.if ${MKUNPRIVED} != "no" 166NOPOSTINSTALL= # defined 167.endif 168 169afterinstall: .PHONY .MAKE 170.if ${MKMAN} != "no" 171 ${MAKEDIRTARGET} share/man makedb 172.endif 173.if (${MKUNPRIVED} != "no" && ${MKINFO} != "no") 174 ${MAKEDIRTARGET} gnu/usr.bin/texinfo/install-info infodir-meta 175.endif 176.if !defined(NOPOSTINSTALL) 177 ${MAKEDIRTARGET} . postinstall-check 178.endif 179 180_POSTINSTALL= ${.CURDIR}/usr.sbin/postinstall/postinstall 181 182postinstall-check: .PHONY 183 @echo " === Post installation checks ===" 184 AWK=${TOOL_AWK:Q} MAKE=${MAKE:Q} ${HOST_SH} ${_POSTINSTALL} -s ${.CURDIR} -d ${DESTDIR}/ check; if [ $$? -gt 1 ]; then exit 1; fi 185 @echo " ================================" 186 187postinstall-fix: .NOTMAIN .PHONY 188 @echo " === Post installation fixes ===" 189 AWK=${TOOL_AWK:Q} MAKE=${MAKE:Q} ${HOST_SH} ${_POSTINSTALL} -s ${.CURDIR} -d ${DESTDIR}/ fix 190 @echo " ===============================" 191 192postinstall-fix-obsolete: .NOTMAIN .PHONY 193 @echo " === Removing obsolete files ===" 194 AWK=${TOOL_AWK:Q} MAKE=${MAKE:Q} ${HOST_SH} ${_POSTINSTALL} -s ${.CURDIR} -d ${DESTDIR}/ fix obsolete 195 @echo " ===============================" 196 197 198# 199# Targets (in order!) called by "make build". 200# 201.if defined(HAVE_GCC) 202.if ${HAVE_GCC} == "3" 203LIBGCC_EXT=3 204.else 205LIBGCC_EXT=4 206.endif 207.endif 208 209BUILDTARGETS+= check-tools 210.if ${MKUPDATE} == "no" && !defined(NOCLEANDIR) 211BUILDTARGETS+= cleandir 212.endif 213.if ${MKOBJDIRS} != "no" 214BUILDTARGETS+= do-top-obj 215.endif 216.if ${USETOOLS} == "yes" # { 217.if ${MKOBJDIRS} != "no" 218BUILDTARGETS+= do-tools-obj 219.endif 220BUILDTARGETS+= do-tools 221.endif # USETOOLS # } 222.if ${MKOBJDIRS} != "no" 223BUILDTARGETS+= obj 224.endif 225BUILDTARGETS+= clean_METALOG 226.if !defined(NODISTRIBDIRS) 227BUILDTARGETS+= do-distrib-dirs 228.endif 229.if !defined(NOINCLUDES) 230BUILDTARGETS+= includes 231.endif 232BUILDTARGETS+= do-tools-compat 233BUILDTARGETS+= do-lib-csu 234.if ${MKGCC} != "no" 235BUILDTARGETS+= do-libgcc 236.endif 237.if ${MKPCC} != "no" 238BUILDTARGET+= do-libpcc 239.endif 240BUILDTARGETS+= do-lib-libc 241BUILDTARGETS+= do-lib 242.if ${MKKMOD} != "no" 243BUILDTARGETS+= do-sys-modules 244.endif 245BUILDTARGETS+= do-sys-rump-dev-lib do-sys-rump-fs-lib 246BUILDTARGETS+= do-sys-rump-kern-lib do-sys-rump-net-lib 247.if ${MKCOMPAT} != "no" 248BUILDTARGETS+= do-compat-lib-csu 249BUILDTARGETS+= do-compat-libgcc 250BUILDTARGETS+= do-compat-lib-libc 251.endif 252BUILDTARGETS+= do-ld.so 253BUILDTARGETS+= do-build 254.if ${MKX11} != "no" 255BUILDTARGETS+= do-x11 256.endif 257.if ${MKEXTSRC} != "no" 258BUILDTARGETS+= do-extsrc 259.endif 260BUILDTARGETS+= do-obsolete 261 262# 263# Enforce proper ordering of some rules. 264# 265 266.ORDER: ${BUILDTARGETS} 267includes-lib: .PHONY includes-include includes-sys 268includes-gnu: .PHONY includes-lib 269 270# 271# Build the system and install into DESTDIR. 272# 273 274START_TIME!= date 275 276build: .PHONY .MAKE 277.if defined(BUILD_DONE) 278 @echo "Build already installed into ${DESTDIR}" 279.else 280 @echo "Build started at: ${START_TIME}" 281.for tgt in ${BUILDTARGETS} 282 ${MAKEDIRTARGET} . ${tgt} 283.endfor 284 ${MAKEDIRTARGET} etc install-etc-release 285 @echo "Build started at: ${START_TIME}" 286 @printf "Build finished at: " && date 287.endif 288 289# 290# Build a full distribution, but not a release (i.e. no sets into 291# ${RELEASEDIR}). "buildworld" enforces a build to ${DESTDIR} != / 292# 293 294distribution buildworld: .PHONY .MAKE 295.if make(buildworld) && \ 296 (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/") 297 @echo "Won't make ${.TARGET} with DESTDIR=/" 298 @false 299.endif 300 ${MAKEDIRTARGET} . build NOPOSTINSTALL=1 301 ${MAKEDIRTARGET} etc distribution INSTALL_DONE=1 302.if defined(DESTDIR) && ${DESTDIR} != "" && ${DESTDIR} != "/" 303 ${MAKEDIRTARGET} . postinstall-fix-obsolete 304 ${MAKEDIRTARGET} distrib/sets checkflist 305.endif 306 @echo "make ${.TARGET} started at: ${START_TIME}" 307 @printf "make ${.TARGET} finished at: " && date 308 309# 310# Install the distribution from $DESTDIR to $INSTALLWORLDDIR (defaults to `/') 311# If installing to /, ensures that the host's operating system is NetBSD and 312# the host's `uname -m` == ${MACHINE}. 313# 314 315HOST_UNAME_S!= uname -s 316HOST_UNAME_M!= uname -m 317 318installworld: .PHONY .MAKE 319.if (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/") 320 @echo "Can't make ${.TARGET} to DESTDIR=/" 321 @false 322.endif 323.if !defined(INSTALLWORLDDIR) || \ 324 ${INSTALLWORLDDIR} == "" || ${INSTALLWORLDDIR} == "/" 325.if (${HOST_UNAME_S} != "NetBSD") 326 @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_S} to NetBSD with INSTALLWORLDDIR=/" 327 @false 328.endif 329.if (${HOST_UNAME_M} != ${MACHINE}) 330 @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_M} to ${MACHINE} with INSTALLWORLDDIR=/" 331 @false 332.endif 333.endif 334 ${MAKEDIRTARGET} distrib/sets installsets \ 335 INSTALLDIR=${INSTALLWORLDDIR:U/} INSTALLSETS=${INSTALLSETS:Q} 336 ${MAKEDIRTARGET} . postinstall-check DESTDIR=${INSTALLWORLDDIR} 337 @echo "make ${.TARGET} started at: ${START_TIME}" 338 @printf "make ${.TARGET} finished at: " && date 339 340# 341# Create sets from $DESTDIR or $NETBSDSRCDIR into $RELEASEDIR 342# 343 344.for tgt in sets sourcesets syspkgs 345${tgt}: .PHONY .MAKE 346 ${MAKEDIRTARGET} distrib/sets ${tgt} 347.endfor 348 349# 350# Build a release or snapshot (implies "make distribution"). Note that 351# in this case, the set lists will be checked before the tar files 352# are made. 353# 354 355release snapshot: .PHONY .MAKE 356 ${MAKEDIRTARGET} . distribution 357 ${MAKEDIRTARGET} etc release DISTRIBUTION_DONE=1 358 @echo "make ${.TARGET} started at: ${START_TIME}" 359 @printf "make ${.TARGET} finished at: " && date 360 361# 362# Create a CD-ROM image. 363# 364 365iso-image: .PHONY 366 ${MAKEDIRTARGET} distrib iso_image 367 ${MAKEDIRTARGET} etc iso-image 368 @echo "make ${.TARGET} started at: ${START_TIME}" 369 @printf "make ${.TARGET} finished at: " && date 370 371iso-image-source: .PHONY 372 ${MAKEDIRTARGET} distrib iso_image CDSOURCE=true 373 ${MAKEDIRTARGET} etc iso-image 374 @echo "make ${.TARGET} started at: ${START_TIME}" 375 @printf "make ${.TARGET} finished at: " && date 376 377# 378# Special components of the "make build" process. 379# 380 381check-tools: .PHONY 382.if ${TOOLCHAIN_MISSING} != "no" && !defined(EXTERNAL_TOOLCHAIN) 383 @echo '*** WARNING: Building on MACHINE=${MACHINE} with missing toolchain.' 384 @echo '*** May result in a failed build or corrupt binaries!' 385.elif defined(EXTERNAL_TOOLCHAIN) 386 @echo '*** Using external toolchain rooted at ${EXTERNAL_TOOLCHAIN}.' 387.endif 388.if defined(NBUILDJOBS) 389 @echo '*** WARNING: NBUILDJOBS is obsolete; use -j directly instead!' 390.endif 391 392# Delete or sanitise a leftover METALOG from a previous build. 393clean_METALOG: .PHONY .MAKE 394.if ${MKUPDATE} != "no" 395 ${MAKEDIRTARGET} distrib/sets clean_METALOG 396.endif 397 398do-distrib-dirs: .PHONY .MAKE 399.if !defined(DESTDIR) || ${DESTDIR} == "" 400 ${MAKEDIRTARGET} etc distrib-dirs DESTDIR=/ 401.else 402 ${MAKEDIRTARGET} etc distrib-dirs DESTDIR=${DESTDIR} 403.endif 404 405.for targ in cleandir obj includes 406do-${targ}: .PHONY ${targ} 407 @true 408.endfor 409 410.if defined(HAVE_GCC) 411.if ${USE_COMPILERCRTSTUFF} == "yes" 412BUILD_CC_LIB= gnu/lib/crtstuff${LIBGCC_EXT} 413.endif 414BUILD_CC_LIB+= gnu/lib/libgcc${LIBGCC_EXT} 415.elif defined(HAVE_PCC) 416BUILD_CC_LIB+= external/bsd/pcc/crtstuff 417BUILD_CC_LIB+= external/bsd/pcc/libpcc 418.endif 419 420.for dir in tools tools/compat lib/csu ${BUILD_CC_LIB} lib/libc lib sys/rump/dev/lib sys/rump/fs/lib sys/rump/kern/lib sys/rump/net/lib sys/modules 421do-${dir:S/\//-/g}: .PHONY .MAKE 422.for targ in dependall install 423 ${MAKEDIRTARGET} ${dir} ${targ} 424.endfor 425.endfor 426 427.if ${MKCOMPAT} != "no" 428COMPAT_SUBDIR_LIST=lib/csu ${BUILD_CC_LIB} lib/libc 429.for dir in ${COMPAT_SUBDIR_LIST} 430do-compat-${dir:S/\//-/g}: .PHONY .MAKE 431.for targ in dependall install 432 ${MAKEDIRTARGET} compat ${targ} BOOTSTRAP_SUBDIRS="../../../${dir}" 433.endfor 434.endfor 435.endif 436 437do-top-obj: .PHONY .MAKE 438 ${MAKEDIRTARGET} . obj NOSUBDIR= 439 440do-tools-obj: .PHONY .MAKE 441 ${MAKEDIRTARGET} tools obj 442 443do-libgcc: .PHONY .MAKE 444.if defined(HAVE_GCC) 445.if ${MKGCC} != "no" 446.if ${USE_COMPILERCRTSTUFF} == "yes" 447.if (${HAVE_GCC} == "3" || ${HAVE_GCC} == "4") 448 ${MAKEDIRTARGET} . do-gnu-lib-crtstuff${LIBGCC_EXT} 449.endif 450.endif 451 ${MAKEDIRTARGET} . do-gnu-lib-libgcc${LIBGCC_EXT} 452.endif 453.endif 454 455do-compat-libgcc: .PHONY .MAKE 456.if defined(HAVE_GCC) 457.if ${MKGCC} != "no" 458.if ${USE_COMPILERCRTSTUFF} == "yes" 459 ${MAKEDIRTARGET} . do-compat-gnu-lib-crtstuff${LIBGCC_EXT} 460.endif 461 ${MAKEDIRTARGET} . do-compat-gnu-lib-libgcc${LIBGCC_EXT} 462.endif 463.endif 464 465do-libpcc: .PHONY .MAKE 466.if defined(HAVE_PCC) 467.if ${MKPCC} != "no" 468.if ${USE_COMPILERCRTSTUFF} == "yes" 469 ${MAKEDIRTARGET} . do-pcc-lib-crtstuff 470.endif 471 ${MAKEDIRTARGET} . do-pcc-lib-libpcc 472.endif 473.endif 474 475do-ld.so: .PHONY .MAKE 476.for targ in dependall install 477 ${MAKEDIRTARGET} libexec/ld.elf_so ${targ} 478.endfor 479 480do-build: .PHONY .MAKE 481.for targ in dependall install 482 ${MAKEDIRTARGET} . ${targ} BUILD_tools=no BUILD_lib=no 483.endfor 484 485do-x11: .PHONY .MAKE 486.if ${MKX11} != "no" 487.if ${X11FLAVOUR} == "Xorg" 488 ${MAKEDIRTARGET} external/mit/xorg build 489.else 490 ${MAKEDIRTARGET} x11 build 491.endif 492.else 493 @echo "MKX11 is not enabled" 494 @false 495.endif 496 497do-extsrc: .PHONY .MAKE 498.if ${MKEXTSRC} != "no" 499 ${MAKEDIRTARGET} extsrc build 500.else 501 @echo "MKEXTSRC is not enabled" 502 @false 503.endif 504 505do-obsolete: .PHONY .MAKE 506 ${MAKEDIRTARGET} etc install-obsolete-lists 507 508# 509# Speedup stubs for some subtrees that don't need to run these rules. 510# (Tells <bsd.subdir.mk> not to recurse for them.) 511# 512 513.for dir in bin etc distrib games libexec regress sbin usr.sbin tools 514includes-${dir}: .PHONY 515 @true 516.endfor 517.for dir in etc distrib regress 518install-${dir}: .PHONY 519 @true 520.endfor 521 522# 523# XXX this needs to change when distrib Makefiles are recursion compliant 524# XXX many distrib subdirs need "cd etc && make snap_pre snap_kern" first... 525# 526dependall-distrib depend-distrib all-distrib: .PHONY 527 @true 528 529.include <bsd.sys.mk> 530.include <bsd.obj.mk> 531.include <bsd.kernobj.mk> 532.include <bsd.subdir.mk> 533 534build-docs: .PHONY ${.CURDIR}/BUILDING 535${.CURDIR}/BUILDING: doc/BUILDING.mdoc 536 ${_MKMSG_CREATE} ${.TARGET} 537 ${TOOL_GROFF} -mdoc -Tascii -P-bou $> >$@ 538 539 540# 541# Display current make(1) parameters 542# 543params: .PHONY .MAKE 544 ${MAKEDIRTARGET} etc params 545