Makefile revision 1.256
1# $NetBSD: Makefile,v 1.256 2008/08/24 05:56:20 gmcgarry 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# obj: creates object directories. 78# do-tools: builds host toolchain. 79# do-distrib-dirs: creates the distribution directories. 80# includes: installs include files. 81# do-tools-compat: builds the "libnbcompat" library; needed for some 82# random host tool programs in the source tree. 83# do-lib-csu: builds and installs prerequisites from lib/csu. 84# do-libgcc: builds and installs prerequisites from 85# gnu/lib/crtstuff${LIBGCC_EXT} (if necessary) and 86# gnu/lib/libgcc${LIBGCC_EXT}. 87# do-libpcc: builds and install prerequisites from 88# external/bsd/pcc/crtstuff and external/bsd/pcc/libpcc. 89# do-lib-libc: builds and installs prerequisites from lib/libc. 90# do-lib: builds and installs prerequisites from lib. 91# do-gnu-lib: builds and installs prerequisites from gnu/lib. 92# do-external-lib: builds and installs prerequisites from external/lib. 93# do-sys-rump-fs-lib: builds and installs prerequisites from sys/rump/fs/lib 94# do-ld.so: builds and installs prerequisites from libexec/ld.*_so. 95# do-build: builds and installs the entire system. 96# do-x11: builds and installs X11R6 from src/x11 if ${MKX11} != "no" 97# do-obsolete: installs the obsolete sets (for the postinstall-* targets). 98# 99 100.if ${.MAKEFLAGS:M${.CURDIR}/share/mk} == "" 101.MAKEFLAGS: -m ${.CURDIR}/share/mk 102.endif 103 104# 105# If _SRC_TOP_OBJ_ gets set here, we will end up with a directory that may 106# not be the top level objdir, because "make obj" can happen in the *middle* 107# of "make build" (long after <bsd.own.mk> is calculated it). So, pre-set 108# _SRC_TOP_OBJ_ here so it will not be added to ${.MAKEOVERRIDES}. 109# 110_SRC_TOP_OBJ_= 111 112.include <bsd.own.mk> 113 114# 115# Sanity check: make sure that "make build" is not invoked simultaneously 116# with a standard recursive target. 117# 118 119.if make(build) || make(release) || make(snapshot) 120.for targ in ${TARGETS:Nobj:Ncleandir} 121.if make(${targ}) && !target(.BEGIN) 122.BEGIN: 123 @echo 'BUILD ABORTED: "make build" and "make ${targ}" are mutually exclusive.' 124 @false 125.endif 126.endfor 127.endif 128 129_SUBDIR= tools lib include gnu external bin games libexec sbin usr.bin 130_SUBDIR+= usr.sbin share rescue sys etc tests .WAIT distrib regress 131 132# 133# Weed out directories that don't exist. 134# 135 136.for dir in ${_SUBDIR} 137.if ("${dir}" == ".WAIT") || exists(${dir}/Makefile) && (${BUILD_${dir}:Uyes} != "no") 138SUBDIR+= ${dir} 139.endif 140.endfor 141 142.if exists(regress) 143regression-tests: .PHONY .MAKE 144 @echo Running regression tests... 145 ${MAKEDIRTARGET} regress regress 146.endif 147 148.if ${MKUNPRIVED} != "no" 149NOPOSTINSTALL= # defined 150.endif 151 152afterinstall: .PHONY .MAKE 153.if ${MKMAN} != "no" 154 ${MAKEDIRTARGET} share/man makedb 155.endif 156.if (${MKUNPRIVED} != "no" && ${MKINFO} != "no") 157 ${MAKEDIRTARGET} gnu/usr.bin/texinfo/install-info infodir-meta 158.endif 159.if !defined(NOPOSTINSTALL) 160 ${MAKEDIRTARGET} . postinstall-check 161.endif 162 163_POSTINSTALL= ${.CURDIR}/usr.sbin/postinstall/postinstall 164 165postinstall-check: .PHONY 166 @echo " === Post installation checks ===" 167 ${HOST_SH} ${_POSTINSTALL} -s ${.CURDIR} -d ${DESTDIR}/ check; if [ $$? -gt 1 ]; then exit 1; fi 168 @echo " ================================" 169 170postinstall-fix: .NOTMAIN .PHONY 171 @echo " === Post installation fixes ===" 172 ${HOST_SH} ${_POSTINSTALL} -s ${.CURDIR} -d ${DESTDIR}/ fix 173 @echo " ===============================" 174 175postinstall-fix-obsolete: .NOTMAIN .PHONY 176 @echo " === Removing obsolete files ===" 177 ${HOST_SH} ${_POSTINSTALL} -s ${.CURDIR} -d ${DESTDIR}/ fix obsolete 178 @echo " ===============================" 179 180 181# 182# Targets (in order!) called by "make build". 183# 184.if defined(HAVE_GCC) 185.if ${HAVE_GCC} == "3" 186LIBGCC_EXT=3 187.else 188LIBGCC_EXT=4 189.endif 190.endif 191 192BUILDTARGETS+= check-tools 193.if ${MKUPDATE} == "no" && !defined(NOCLEANDIR) 194BUILDTARGETS+= cleandir 195.endif 196.if ${MKOBJDIRS} != "no" 197BUILDTARGETS+= obj 198.endif 199.if ${USETOOLS} == "yes" 200BUILDTARGETS+= do-tools 201.endif 202.if !defined(NODISTRIBDIRS) 203BUILDTARGETS+= do-distrib-dirs 204.endif 205.if !defined(NOINCLUDES) 206BUILDTARGETS+= includes 207.endif 208BUILDTARGETS+= do-tools-compat 209BUILDTARGETS+= do-lib-csu 210.if ${MKGCC} != "no" 211BUILDTARGETS+= do-libgcc 212.endif 213.if ${MKPCC} != "no" 214BUILDTARGET+= do-libpcc 215.endif 216BUILDTARGETS+= do-lib-libc 217BUILDTARGETS+= do-lib do-gnu-lib do-external-lib 218BUILDTARGETS+= do-sys-rump-fs-lib 219BUILDTARGETS+= do-ld.so 220BUILDTARGETS+= do-build 221.if ${MKX11} != "no" 222BUILDTARGETS+= do-x11 223.endif 224BUILDTARGETS+= do-obsolete 225 226# 227# Enforce proper ordering of some rules. 228# 229 230.ORDER: ${BUILDTARGETS} 231includes-lib: .PHONY includes-include includes-sys 232includes-gnu: .PHONY includes-lib 233 234# 235# Build the system and install into DESTDIR. 236# 237 238START_TIME!= date 239 240build: .PHONY .MAKE 241.if defined(BUILD_DONE) 242 @echo "Build already installed into ${DESTDIR}" 243.else 244 @echo "Build started at: ${START_TIME}" 245.for tgt in ${BUILDTARGETS} 246 ${MAKEDIRTARGET} . ${tgt} 247.endfor 248 ${MAKEDIRTARGET} etc install-etc-release 249 @echo "Build started at: ${START_TIME}" 250 @printf "Build finished at: " && date 251.endif 252 253# 254# Build a full distribution, but not a release (i.e. no sets into 255# ${RELEASEDIR}). "buildworld" enforces a build to ${DESTDIR} != / 256# 257 258distribution buildworld: .PHONY .MAKE 259.if make(buildworld) && \ 260 (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/") 261 @echo "Won't make ${.TARGET} with DESTDIR=/" 262 @false 263.endif 264 ${MAKEDIRTARGET} . build NOPOSTINSTALL=1 265 ${MAKEDIRTARGET} etc distribution INSTALL_DONE=1 266.if defined(DESTDIR) && ${DESTDIR} != "" && ${DESTDIR} != "/" 267 ${MAKEDIRTARGET} . postinstall-fix-obsolete 268 ${MAKEDIRTARGET} distrib/sets checkflist 269.endif 270 @echo "make ${.TARGET} started at: ${START_TIME}" 271 @printf "make ${.TARGET} finished at: " && date 272 273# 274# Install the distribution from $DESTDIR to $INSTALLWORLDDIR (defaults to `/') 275# If installing to /, ensures that the host's operating system is NetBSD and 276# the host's `uname -m` == ${MACHINE}. 277# 278 279HOST_UNAME_S!= uname -s 280HOST_UNAME_M!= uname -m 281 282installworld: .PHONY .MAKE 283.if (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/") 284 @echo "Can't make ${.TARGET} to DESTDIR=/" 285 @false 286.endif 287.if !defined(INSTALLWORLDDIR) || \ 288 ${INSTALLWORLDDIR} == "" || ${INSTALLWORLDDIR} == "/" 289.if (${HOST_UNAME_S} != "NetBSD") 290 @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_S} to NetBSD with INSTALLWORLDDIR=/" 291 @false 292.endif 293.if (${HOST_UNAME_M} != ${MACHINE}) 294 @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_M} to ${MACHINE} with INSTALLWORLDDIR=/" 295 @false 296.endif 297.endif 298 ${MAKEDIRTARGET} distrib/sets installsets \ 299 INSTALLDIR=${INSTALLWORLDDIR:U/} INSTALLSETS= 300 ${MAKEDIRTARGET} . postinstall-check DESTDIR=${INSTALLWORLDDIR} 301 @echo "make ${.TARGET} started at: ${START_TIME}" 302 @printf "make ${.TARGET} finished at: " && date 303 304# 305# Create sets from $DESTDIR or $NETBSDSRCDIR into $RELEASEDIR 306# 307 308.for tgt in sets sourcesets syspkgs 309${tgt}: .PHONY .MAKE 310 ${MAKEDIRTARGET} distrib/sets ${tgt} 311.endfor 312 313# 314# Build a release or snapshot (implies "make distribution"). Note that 315# in this case, the set lists will be checked before the tar files 316# are made. 317# 318 319release snapshot: .PHONY .MAKE 320 ${MAKEDIRTARGET} . distribution 321 ${MAKEDIRTARGET} etc release DISTRIBUTION_DONE=1 322 @echo "make ${.TARGET} started at: ${START_TIME}" 323 @printf "make ${.TARGET} finished at: " && date 324 325# 326# Create a CD-ROM image. 327# 328 329iso-image: .PHONY 330 ${MAKEDIRTARGET} distrib iso_image 331 ${MAKEDIRTARGET} etc iso-image 332 @echo "make ${.TARGET} started at: ${START_TIME}" 333 @printf "make ${.TARGET} finished at: " && date 334 335iso-image-source: .PHONY 336 ${MAKEDIRTARGET} distrib iso_image CDSOURCE=true 337 ${MAKEDIRTARGET} etc iso-image 338 @echo "make ${.TARGET} started at: ${START_TIME}" 339 @printf "make ${.TARGET} finished at: " && date 340 341# 342# Special components of the "make build" process. 343# 344 345check-tools: .PHONY 346.if ${TOOLCHAIN_MISSING} != "no" && !defined(EXTERNAL_TOOLCHAIN) 347 @echo '*** WARNING: Building on MACHINE=${MACHINE} with missing toolchain.' 348 @echo '*** May result in a failed build or corrupt binaries!' 349.elif defined(EXTERNAL_TOOLCHAIN) 350 @echo '*** Using external toolchain rooted at ${EXTERNAL_TOOLCHAIN}.' 351.endif 352.if defined(NBUILDJOBS) 353 @echo '*** WARNING: NBUILDJOBS is obsolete; use -j directly instead!' 354.endif 355 356do-distrib-dirs: .PHONY .MAKE 357.if !defined(DESTDIR) || ${DESTDIR} == "" 358 ${MAKEDIRTARGET} etc distrib-dirs DESTDIR=/ 359.else 360 ${MAKEDIRTARGET} etc distrib-dirs DESTDIR=${DESTDIR} 361.endif 362 363.for targ in cleandir obj includes 364do-${targ}: .PHONY ${targ} 365 @true 366.endfor 367 368.if defined(HAVE_GCC) 369BUILD_CC_LIB= gnu/lib/crtstuff${LIBGCC_EXT} 370BUILD_CC_LIB+= gnu/lib/libgcc${LIBGCC_EXT} 371.elif defined(HAVE_PCC) 372BUILD_CC_LIB+= external/bsd/pcc/crtstuff 373BUILD_CC_LIB+= external/bsd/pcc/libpcc 374.endif 375 376.for dir in tools tools/compat lib/csu ${BUILD_CC_LIB} lib/libc lib/libdes lib gnu/lib external/lib sys/rump/fs/lib 377do-${dir:S/\//-/g}: .PHONY .MAKE 378.for targ in dependall install 379 ${MAKEDIRTARGET} ${dir} ${targ} 380.endfor 381.endfor 382 383do-libgcc: .PHONY .MAKE 384.if defined(HAVE_GCC) 385.if ${MKGCC} != "no" 386.if (${HAVE_GCC} == "3" || ${HAVE_GCC} == "4") 387 ${MAKEDIRTARGET} . do-gnu-lib-crtstuff${LIBGCC_EXT} 388.endif 389 ${MAKEDIRTARGET} . do-gnu-lib-libgcc${LIBGCC_EXT} 390.endif 391.endif 392 393do-libpcc: .PHONY .MAKE 394.if defined(HAVE_PCC) 395.if ${MKPCC} != "no" 396 ${MAKEDIRTARGET} . do-pcc-lib-crtstuff 397 ${MAKEDIRTARGET} . do-pcc-lib-libpcc 398.endif 399.endif 400 401do-ld.so: .PHONY .MAKE 402.for targ in dependall install 403.if (${OBJECT_FMT} == "a.out") 404 ${MAKEDIRTARGET} libexec/ld.aout_so ${targ} 405.endif 406.if (${OBJECT_FMT} == "ELF") 407 ${MAKEDIRTARGET} libexec/ld.elf_so ${targ} 408.endif 409.endfor 410 411do-build: .PHONY .MAKE 412.for targ in dependall install 413 ${MAKEDIRTARGET} . ${targ} BUILD_tools=no BUILD_lib=no 414.endfor 415 416do-x11: .PHONY .MAKE 417.if ${MKXORG} != "no" 418 ${MAKEDIRTARGET} external/mit/xorg build 419.else 420 ${MAKEDIRTARGET} x11 build 421.endif 422 423do-obsolete: .PHONY .MAKE 424 ${MAKEDIRTARGET} etc install-obsolete-lists 425 426# 427# Speedup stubs for some subtrees that don't need to run these rules. 428# (Tells <bsd.subdir.mk> not to recurse for them.) 429# 430 431.for dir in bin etc distrib games libexec regress sbin usr.sbin tools 432includes-${dir}: .PHONY 433 @true 434.endfor 435.for dir in etc distrib regress 436install-${dir}: .PHONY 437 @true 438.endfor 439 440# 441# XXX this needs to change when distrib Makefiles are recursion compliant 442# XXX many distrib subdirs need "cd etc && make snap_pre snap_kern" first... 443# 444dependall-distrib depend-distrib all-distrib: .PHONY 445 @true 446 447.include <bsd.sys.mk> 448.include <bsd.obj.mk> 449.include <bsd.kernobj.mk> 450.include <bsd.subdir.mk> 451 452build-docs: .PHONY ${.CURDIR}/BUILDING 453${.CURDIR}/BUILDING: doc/BUILDING.mdoc 454 ${_MKMSG_CREATE} ${.TARGET} 455 ${TOOL_GROFF} -mdoc -Tascii -P-bou $> >$@ 456 457 458# 459# Display current make(1) parameters 460# 461params: .PHONY .MAKE 462 ${MAKEDIRTARGET} etc params 463