Makefile revision 1.306
1# $NetBSD: Makefile,v 1.306 2014/06/13 01:17:45 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 not the 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# live-image: 75# Create bootable live image for emulators or USB stick etc. 76# in RELEASEDIR/liveimage. 77# RELEASEDIR must already have been populated by `make release' 78# or equivalent. 79# install-image: 80# Create bootable installation image for USB stick etc. 81# in RELEASEDIR/installimage. 82# RELEASEDIR must already have been populated by `make release' 83# or equivalent. 84# 85# Targets invoked by `make build,' in order: 86# cleandir: cleans the tree. 87# do-top-obj: creates the top level object directory. 88# do-tools-obj: creates object directories for the host toolchain. 89# do-tools: builds host toolchain. 90# params: record the values of variables that might affect the 91# build. 92# obj: creates object directories. 93# do-distrib-dirs: creates the distribution directories. 94# includes: installs include files. 95# do-lib: builds and installs prerequisites from lib 96# if ${MKCOMPAT} != "no". 97# do-compat-lib: builds and installs prerequisites from compat/lib 98# if ${MKCOMPAT} != "no". 99# do-build: builds and installs the entire system. 100# do-x11: builds and installs X11 if ${MKX11} != "no"; either 101# X11R7 from src/external/mit/xorg if ${X11FLAVOUR} == "Xorg" 102# or X11R6 from src/x11 103# do-extsrc: builds and installs extsrc if ${MKEXTSRC} != "no". 104# do-obsolete: installs the obsolete sets (for the postinstall-* targets). 105# 106 107.if ${.MAKEFLAGS:M${.CURDIR}/share/mk} == "" 108.MAKEFLAGS: -m ${.CURDIR}/share/mk 109.endif 110 111# 112# If _SRC_TOP_OBJ_ gets set here, we will end up with a directory that may 113# not be the top level objdir, because "make obj" can happen in the *middle* 114# of "make build" (long after <bsd.own.mk> is calculated it). So, pre-set 115# _SRC_TOP_OBJ_ here so it will not be added to ${.MAKEOVERRIDES}. 116# 117_SRC_TOP_OBJ_= 118 119.include <bsd.own.mk> 120 121# 122# Sanity check: make sure that "make build" is not invoked simultaneously 123# with a standard recursive target. 124# 125 126.if make(build) || make(release) || make(snapshot) 127.for targ in ${TARGETS:Nobj:Ncleandir} 128.if make(${targ}) && !target(.BEGIN) 129.BEGIN: 130 @echo 'BUILD ABORTED: "make build" and "make ${targ}" are mutually exclusive.' 131 @false 132.endif 133.endfor 134.endif 135 136# 137# _SUBDIR is used to set SUBDIR, after removing directories that have 138# BUILD_${dir}=no, or that have no ${dir}/Makefile. 139# 140_SUBDIR= tools lib include gnu external crypto/external bin games 141_SUBDIR+= libexec sbin usr.bin 142_SUBDIR+= usr.sbin share sys etc tests compat 143_SUBDIR+= .WAIT rescue .WAIT distrib regress 144 145.for dir in ${_SUBDIR} 146.if "${dir}" == ".WAIT" \ 147 || (${BUILD_${dir}:Uyes} != "no" && exists(${dir}/Makefile)) 148SUBDIR+= ${dir} 149.endif 150.endfor 151 152.if exists(regress) 153regression-tests: .PHONY .MAKE 154 @echo Running regression tests... 155 ${MAKEDIRTARGET} regress regress 156.endif 157 158.if ${MKUNPRIVED} != "no" 159NOPOSTINSTALL= # defined 160.endif 161 162afterinstall: .PHONY .MAKE 163.if ${MKMAN} != "no" 164 ${MAKEDIRTARGET} share/man makedb 165.endif 166.if (${MKUNPRIVED} != "no" && ${MKINFO} != "no") 167 ${MAKEDIRTARGET} gnu/usr.bin/texinfo/install-info infodir-meta 168.endif 169.if !defined(NOPOSTINSTALL) 170 ${MAKEDIRTARGET} . postinstall-check 171.endif 172 173_POSTINSTALL= ${.CURDIR}/usr.sbin/postinstall/postinstall 174_POSTINSTALL_ENV= \ 175 AWK=${TOOL_AWK:Q} \ 176 DB=${TOOL_DB:Q} \ 177 HOST_SH=${HOST_SH:Q} \ 178 MAKE=${MAKE:Q} \ 179 PWD_MKDB=${TOOL_PWD_MKDB:Q} \ 180 STAT=${TOOL_STAT:Q} 181 182postinstall-check: .PHONY 183 @echo " === Post installation checks ===" 184 ${_POSTINSTALL_ENV} ${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 ${_POSTINSTALL_ENV} ${HOST_SH} ${_POSTINSTALL} -s ${.CURDIR} -d ${DESTDIR}/ fix 190 @echo " ===============================" 191 192postinstall-fix-obsolete: .NOTMAIN .PHONY 193 @echo " === Removing obsolete files ===" 194 ${_POSTINSTALL_ENV} ${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) 202BUILD_CC_LIB_BASEDIR= external/gpl3/${EXTERNAL_GCC_SUBDIR}/lib 203BUILD_CC_LIB_BASETARGET= external-gpl3-gcc-lib 204.endif 205 206BUILDTARGETS+= check-tools 207.if ${MKUPDATE} == "no" && !defined(NOCLEANDIR) 208BUILDTARGETS+= cleandir 209.endif 210.if ${MKOBJDIRS} != "no" 211BUILDTARGETS+= do-top-obj 212.endif 213.if ${USETOOLS} == "yes" # { 214.if ${MKOBJDIRS} != "no" 215BUILDTARGETS+= do-tools-obj 216.endif 217BUILDTARGETS+= do-tools 218.endif # USETOOLS # } 219BUILDTARGETS+= params 220.if ${MKOBJDIRS} != "no" 221BUILDTARGETS+= obj 222.endif 223BUILDTARGETS+= clean_METALOG 224.if !defined(NODISTRIBDIRS) 225BUILDTARGETS+= do-distrib-dirs 226.endif 227.if !defined(NOINCLUDES) 228BUILDTARGETS+= includes 229.endif 230BUILDTARGETS+= do-lib 231BUILDTARGETS+= do-compat-lib 232BUILDTARGETS+= do-build 233.if ${MKX11} != "no" 234BUILDTARGETS+= do-x11 235.endif 236.if ${MKEXTSRC} != "no" 237BUILDTARGETS+= do-extsrc 238.endif 239BUILDTARGETS+= do-obsolete 240 241# 242# Enforce proper ordering of some rules. 243# 244 245.ORDER: ${BUILDTARGETS} 246includes-lib: .PHONY includes-include includes-sys 247includes-gnu: .PHONY includes-lib 248 249# 250# Record the values of variables that might affect the build. 251# If no values have changed, avoid updating the timestamp 252# of the params file. 253# 254# This is referenced by _NETBSD_VERSION_DEPENDS in <bsd.own.mk>. 255# 256.include "${NETBSDSRCDIR}/etc/Makefile.params" 257CLEANDIRFILES+= params 258params: .EXEC 259 ${_MKMSG_CREATE} params 260 @${PRINT_PARAMS} >${.TARGET}.new 261 @if cmp -s ${.TARGET}.new ${.TARGET} > /dev/null 2>&1; then \ 262 : "params is unchanged" ; \ 263 rm ${.TARGET}.new ; \ 264 else \ 265 : "params has changed or is new" ; \ 266 mv ${.TARGET}.new ${.TARGET} ; \ 267 fi 268 269# 270# Display current make(1) parameters 271# 272show-params: .PHONY .MAKE 273 @${PRINT_PARAMS} 274 275# 276# Build the system and install into DESTDIR. 277# 278 279START_TIME!= date 280 281build: .PHONY .MAKE 282.if defined(BUILD_DONE) 283 @echo "Build already installed into ${DESTDIR}" 284.else 285 @echo "Build started at: ${START_TIME}" 286.for tgt in ${BUILDTARGETS} 287 ${MAKEDIRTARGET} . ${tgt} 288.endfor 289 ${MAKEDIRTARGET} etc install-etc-release 290 @echo "Build started at: ${START_TIME}" 291 @printf "Build finished at: " && date 292.endif 293 294# 295# Build a full distribution, but not a release (i.e. no sets into 296# ${RELEASEDIR}). "buildworld" enforces a build to ${DESTDIR} != / 297# 298 299distribution buildworld: .PHONY .MAKE 300.if make(buildworld) && \ 301 (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/") 302 @echo "Won't make ${.TARGET} with DESTDIR=/" 303 @false 304.endif 305 ${MAKEDIRTARGET} . build NOPOSTINSTALL=1 306 ${MAKEDIRTARGET} etc distribution INSTALL_DONE=1 307.if defined(DESTDIR) && ${DESTDIR} != "" && ${DESTDIR} != "/" 308 ${MAKEDIRTARGET} . postinstall-fix-obsolete 309 ${MAKEDIRTARGET} distrib/sets checkflist 310.endif 311 @echo "make ${.TARGET} started at: ${START_TIME}" 312 @printf "make ${.TARGET} finished at: " && date 313 314# 315# Install the distribution from $DESTDIR to $INSTALLWORLDDIR (defaults to `/') 316# If installing to /, ensures that the host's operating system is NetBSD and 317# the host's `uname -m` == ${MACHINE}. 318# 319 320HOST_UNAME_S!= uname -s 321HOST_UNAME_M!= uname -m 322 323installworld: .PHONY .MAKE 324.if (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/") 325 @echo "Can't make ${.TARGET} to DESTDIR=/" 326 @false 327.endif 328.if !defined(INSTALLWORLDDIR) || \ 329 ${INSTALLWORLDDIR} == "" || ${INSTALLWORLDDIR} == "/" 330.if (${HOST_UNAME_S} != "NetBSD") 331 @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_S} to NetBSD with INSTALLWORLDDIR=/" 332 @false 333.endif 334.if (${HOST_UNAME_M} != ${MACHINE}) 335 @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_M} to ${MACHINE} with INSTALLWORLDDIR=/" 336 @false 337.endif 338.endif 339 ${MAKEDIRTARGET} distrib/sets installsets \ 340 INSTALLDIR=${INSTALLWORLDDIR:U/} INSTALLSETS=${INSTALLSETS:Q} 341 ${MAKEDIRTARGET} . postinstall-check DESTDIR=${INSTALLWORLDDIR} 342 @echo "make ${.TARGET} started at: ${START_TIME}" 343 @printf "make ${.TARGET} finished at: " && date 344 345# 346# Install modules from $DESTDIR to $INSTALLMODULESDIR 347# 348installmodules: .PHONY .MAKE 349.if (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/") 350 @echo "Can't make ${.TARGET} to DESTDIR=/" 351 @false 352.endif 353.if !defined(INSTALLMODULESDIR) || \ 354 ${INSTALLMODULESDIR} == "" || ${INSTALLMODULESDIR} == "/" 355.if (${HOST_UNAME_S} != "NetBSD") 356 @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_S} to NetBSD with INSTALLMODULESDIR=/" 357 @false 358.endif 359.if (${HOST_UNAME_M} != ${MACHINE}) 360 @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_M} to ${MACHINE} with INSTALLMODULESDIR=/" 361 @false 362.endif 363.endif 364 ${MAKEDIRTARGET} sys/modules install DESTDIR=${INSTALLMODULESDIR:U/} 365 @echo "make ${.TARGET} started at: ${START_TIME}" 366 @printf "make ${.TARGET} finished at: " && date 367 368# 369# Create sets from $DESTDIR or $NETBSDSRCDIR into $RELEASEDIR 370# 371 372.for tgt in sets sourcesets syspkgs 373${tgt}: .PHONY .MAKE 374 ${MAKEDIRTARGET} distrib/sets ${tgt} 375.endfor 376 377# 378# Build a release or snapshot (implies "make distribution"). Note that 379# in this case, the set lists will be checked before the tar files 380# are made. 381# 382 383release snapshot: .PHONY .MAKE 384 ${MAKEDIRTARGET} . distribution 385 ${MAKEDIRTARGET} etc release DISTRIBUTION_DONE=1 386 @echo "make ${.TARGET} started at: ${START_TIME}" 387 @printf "make ${.TARGET} finished at: " && date 388 389# 390# Create a CD-ROM image. 391# 392 393iso-image: .PHONY 394 ${MAKEDIRTARGET} distrib iso_image 395 ${MAKEDIRTARGET} etc iso-image 396 @echo "make ${.TARGET} started at: ${START_TIME}" 397 @printf "make ${.TARGET} finished at: " && date 398 399iso-image-source: .PHONY 400 ${MAKEDIRTARGET} distrib iso_image CDSOURCE=true 401 ${MAKEDIRTARGET} etc iso-image 402 @echo "make ${.TARGET} started at: ${START_TIME}" 403 @printf "make ${.TARGET} finished at: " && date 404 405# 406# Create bootable live images. 407# 408 409live-image: .PHONY 410 ${MAKEDIRTARGET} etc live-image 411 @echo "make ${.TARGET} started at: ${START_TIME}" 412 @printf "make ${.TARGET} finished at: " && date 413 414# 415# Create bootable installation images. 416# 417 418install-image: .PHONY 419 ${MAKEDIRTARGET} etc install-image 420 @echo "make ${.TARGET} started at: ${START_TIME}" 421 @printf "make ${.TARGET} finished at: " && date 422 423# 424# Special components of the "make build" process. 425# 426 427check-tools: .PHONY 428.if ${TOOLCHAIN_MISSING} != "no" && !defined(EXTERNAL_TOOLCHAIN) 429 @echo '*** WARNING: Building on MACHINE=${MACHINE} with missing toolchain.' 430 @echo '*** May result in a failed build or corrupt binaries!' 431.elif defined(EXTERNAL_TOOLCHAIN) 432 @echo '*** Using external toolchain rooted at ${EXTERNAL_TOOLCHAIN}.' 433.endif 434.if defined(NBUILDJOBS) 435 @echo '*** WARNING: NBUILDJOBS is obsolete; use -j directly instead!' 436.endif 437 438# Delete or sanitise a leftover METALOG from a previous build. 439clean_METALOG: .PHONY .MAKE 440.if ${MKUPDATE} != "no" 441 ${MAKEDIRTARGET} distrib/sets clean_METALOG 442.endif 443 444do-distrib-dirs: .PHONY .MAKE 445.if !defined(DESTDIR) || ${DESTDIR} == "" 446 ${MAKEDIRTARGET} etc distrib-dirs DESTDIR=/ 447.else 448 ${MAKEDIRTARGET} etc distrib-dirs DESTDIR=${DESTDIR} 449.endif 450 451.for targ in cleandir obj includes 452do-${targ}: .PHONY ${targ} 453 @true 454.endfor 455 456do-tools: .PHONY .MAKE 457 ${MAKEDIRTARGET} tools build_install 458 459do-lib: .PHONY .MAKE 460 ${MAKEDIRTARGET} lib build_install 461 462do-compat-lib: .PHONY .MAKE 463 ${MAKEDIRTARGET} compat build_install BOOTSTRAP_SUBDIRS="../../../lib" 464 465do-top-obj: .PHONY .MAKE 466 ${MAKEDIRTARGET} . obj NOSUBDIR= 467 468do-tools-obj: .PHONY .MAKE 469 ${MAKEDIRTARGET} tools obj 470 471do-build: .PHONY .MAKE 472.for targ in dependall install 473 ${MAKEDIRTARGET} . ${targ} BUILD_tools=no BUILD_lib=no 474.endfor 475 476do-x11: .PHONY .MAKE 477.if ${MKX11} != "no" 478.if ${X11FLAVOUR} == "Xorg" 479 ${MAKEDIRTARGET} external/mit/xorg build 480.else 481 ${MAKEDIRTARGET} x11 build 482.endif 483.else 484 @echo "MKX11 is not enabled" 485 @false 486.endif 487 488do-extsrc: .PHONY .MAKE 489.if ${MKEXTSRC} != "no" 490 ${MAKEDIRTARGET} extsrc build 491.else 492 @echo "MKEXTSRC is not enabled" 493 @false 494.endif 495 496do-obsolete: .PHONY .MAKE 497 ${MAKEDIRTARGET} etc install-obsolete-lists 498 499# 500# Speedup stubs for some subtrees that don't need to run these rules. 501# (Tells <bsd.subdir.mk> not to recurse for them.) 502# 503 504.for dir in bin etc distrib games libexec regress sbin usr.bin usr.sbin tools 505includes-${dir}: .PHONY 506 @true 507.endfor 508.for dir in etc distrib regress 509install-${dir}: .PHONY 510 @true 511.endfor 512 513# 514# XXX this needs to change when distrib Makefiles are recursion compliant 515# XXX many distrib subdirs need "cd etc && make snap_pre snap_kern" first... 516# 517dependall-distrib depend-distrib all-distrib: .PHONY 518 @true 519 520.include <bsd.obj.mk> 521.include <bsd.kernobj.mk> 522.include <bsd.subdir.mk> 523