Makefile revision 1.204
1# $NetBSD: Makefile,v 1.204 2003/04/17 00:33:44 thorpej 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 set to `no', will prevent building of manual pages. 23# MKOBJDIRS, if not set to `no', will build object directories at 24# an appropriate point in a build. 25# MKSHARE, if set to `no', will prevent building and installing 26# anything in /usr/share. 27# UPDATE, if defined, 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# Targets: 35# build: 36# Builds a full release of NetBSD in DESTDIR, except for the 37# /etc configuration files. 38# If BUILD_DONE is set, this is an empty target. 39# distribution: 40# Builds a full release of NetBSD in DESTDIR, including the /etc 41# configuration files. 42# buildworld: 43# As per `make distribution', except that it ensures that DESTDIR 44# is not the root directory. 45# installworld: 46# Install the distribution from DESTDIR to INSTALLWORLDDIR (which 47# defaults to the root directory). Ensures that INSTALLWORLDDIR 48# is the not root directory if cross compiling. 49# release: 50# Does a `make build', and then tars up the DESTDIR files 51# into RELEASEDIR/${MACHINE}, in release(7) format. 52# (See etc/Makefile for more information on this.) 53# regression-tests: 54# Runs the regression tests in "regress" on this host. 55# 56# Targets invoked by `make build,' in order: 57# cleandir: cleans the tree. 58# obj: creates object directories. 59# do-tools: builds host toolchain. 60# do-tools-compat: builds the "libnbcompat" library; needed for some 61# random host tool programs in the source tree. 62# do-distrib-dirs: creates the distribution directories. 63# includes: installs include files. 64# do-lib-csu: builds and installs prerequisites from lib/csu. 65# do-lib-libc: builds and installs prerequisites from lib/libc. 66# do-lib: builds and installs prerequisites from lib. 67# do-gnu-lib: builds and installs prerequisites from gnu/lib. 68# do-ld.so: builds and installs prerequisites from libexec/ld.*_so. 69# do-build: builds and installs the entire system. 70# 71 72.if ${.MAKEFLAGS:M${.CURDIR}/share/mk} == "" 73.MAKEFLAGS: -m ${.CURDIR}/share/mk 74.endif 75 76# 77# If _SRC_TOP_OBJ_ gets set here, we will end up with a directory that may 78# not be the top level objdir, because "make obj" can happen in the *middle* 79# of "make build" (long after <bsd.own.mk> is calculated it). So, pre-set 80# _SRC_TOP_OBJ_ here so it will not be added to ${.MAKEOVERRIDES}. 81# 82_SRC_TOP_OBJ_= 83 84.include <bsd.own.mk> 85 86# 87# Sanity check: make sure that "make build" is not invoked simultaneously 88# with a standard recursive target. 89# 90 91.if make(build) || make(release) || make(snapshot) 92.for targ in ${TARGETS:Nobj:Ncleandir} 93.if make(${targ}) && !target(.BEGIN) 94.BEGIN: 95 @echo 'BUILD ABORTED: "make build" and "make ${targ}" are mutually exclusive.' 96 @false 97.endif 98.endfor 99.endif 100 101_SUBDIR= tools lib include gnu bin games libexec sbin usr.bin 102_SUBDIR+= usr.sbin share rescue sys etc distrib regress 103 104# 105# Weed out directories that don't exist. 106# 107 108.for dir in ${_SUBDIR} 109.if exists(${dir}/Makefile) && (${BUILD_${dir}:Uyes} != "no") 110SUBDIR+= ${dir} 111.endif 112.endfor 113 114.if exists(regress) 115regression-tests: 116 @echo Running regression tests... 117 @(cd ${.CURDIR}/regress && ${MAKE} regress) 118.endif 119 120.if defined(UNPRIVED) 121NOPOSTINSTALL= # defined 122.endif 123 124afterinstall: 125.if ${MKMAN} != "no" 126 (cd ${.CURDIR}/share/man && ${MAKE} makedb) 127.endif 128.if defined(UNPRIVED) && (${MKINFO} != "no") 129 (cd ${.CURDIR}/gnu/usr.bin/texinfo/install-info && ${MAKE} infodir-meta) 130.endif 131.if !defined(NOPOSTINSTALL) 132 (cd ${.CURDIR} && ${MAKE} postinstall-check) 133.endif 134 135postinstall-check: 136 @echo " === Post installation checks ===" 137 sh ${.CURDIR}/etc/postinstall -s ${.CURDIR} -d ${DESTDIR}/ check 138 @echo " ================================" 139 140postinstall-fix: .NOTMAIN 141 @echo " === Post installation fixes ===" 142 sh ${.CURDIR}/etc/postinstall -s ${.CURDIR} -d ${DESTDIR}/ fix 143 @echo " ================================" 144 145 146# 147# Targets (in order!) called by "make build". 148# 149 150BUILDTARGETS+= check-tools 151.if !defined(UPDATE) && !defined(NOCLEANDIR) 152BUILDTARGETS+= cleandir 153.endif 154.if ${MKOBJDIRS} != "no" 155BUILDTARGETS+= obj 156.endif 157.if ${USETOOLS} == "yes" 158BUILDTARGETS+= do-tools 159.endif 160.if !defined(NODISTRIBDIRS) 161BUILDTARGETS+= do-distrib-dirs 162.endif 163.if !defined(NOINCLUDES) 164BUILDTARGETS+= includes 165.endif 166BUILDTARGETS+= do-tools-compat 167BUILDTARGETS+= do-lib-csu do-lib-libc do-lib do-gnu-lib do-ld.so do-build 168BUILDTARGETS+= do-obsolete 169 170# 171# Enforce proper ordering of some rules. 172# 173 174.ORDER: ${BUILDTARGETS} 175includes-lib: includes-include includes-sys 176includes-gnu: includes-lib 177 178# 179# Build the system and install into DESTDIR. 180# 181 182START_TIME!= date 183 184build: 185.if defined(BUILD_DONE) 186 @echo "Build already installed into ${DESTDIR}" 187.else 188 @echo "Build started at: ${START_TIME}" 189.for tgt in ${BUILDTARGETS} 190 @(cd ${.CURDIR} && ${MAKE} ${tgt}) 191.endfor 192 @echo "Build started at: ${START_TIME}" 193 @printf "Build finished at: " && date 194.endif 195 196# 197# Build a full distribution, but not a release (i.e. no sets into 198# ${RELEASEDIR}). "buildworld" enforces a build to ${DESTDIR} != / 199# 200 201distribution buildworld: 202.if make(buildworld) && \ 203 (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/") 204 @echo "Won't make ${.TARGET} with DESTDIR=/" 205 @false 206.endif 207 (cd ${.CURDIR} && ${MAKE} NOPOSTINSTALL=1 build) 208 (cd ${.CURDIR}/etc && ${MAKE} INSTALL_DONE=1 distribution) 209.if defined(DESTDIR) && ${DESTDIR} != "" && ${DESTDIR} != "/" 210 (cd ${.CURDIR}/distrib/sets && ${MAKE} checkflist) 211.endif 212 @echo "make ${.TARGET} started at: ${START_TIME}" 213 @printf "make ${.TARGET} finished at: " && date 214 215# 216# Install the distribution from $DESTDIR to $INSTALLWORLDDIR (defaults to `/') 217# If installing to /, ensures that the host's operating system is NetBSD and 218# the host's `uname -m` == ${MACHINE}. 219# 220 221HOST_UNAME_S!= uname -s 222HOST_UNAME_M!= uname -m 223 224installworld: 225.if (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/") 226 @echo "Can't make ${.TARGET} to DESTDIR=/" 227 @false 228.endif 229.if !defined(INSTALLWORLDDIR) || \ 230 ${INSTALLWORLDDIR} == "" || ${INSTALLWORLDDIR} == "/" 231.if (${HOST_UNAME_S} != "NetBSD") 232 @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_S} to NetBSD with INSTALLWORLDDIR=/" 233 @false 234.endif 235.if (${HOST_UNAME_M} != ${MACHINE}) 236 @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_M} to ${MACHINE} with INSTALLWORLDDIR=/" 237 @false 238.endif 239.endif 240 (cd ${.CURDIR}/distrib/sets && \ 241 ${MAKE} INSTALLDIR=${INSTALLWORLDDIR:U/} INSTALLSETS= installsets) 242 (cd ${.CURDIR} && \ 243 ${MAKE} DESTDIR=${INSTALLWORLDDIR} postinstall-check) 244 @echo "make ${.TARGET} started at: ${START_TIME}" 245 @printf "make ${.TARGET} finished at: " && date 246 247# 248# Create sets from $DESTDIR into $RELEASEDIR 249# 250 251sets: 252 (cd ${.CURDIR}/distrib/sets && ${MAKE} maketars) 253 254# 255# Build a release or snapshot (implies "make build"). Note that 256# in this case, the set lists will be checked before the tar files 257# are made. 258# 259 260release snapshot: 261 (cd ${.CURDIR} && ${MAKE} NOPOSTINSTALL=1 build) 262 (cd ${.CURDIR}/etc && ${MAKE} INSTALL_DONE=1 release) 263 @echo "make ${.TARGET} started at: ${START_TIME}" 264 @printf "make ${.TARGET} finished at: " && date 265 266# 267# Special components of the "make build" process. 268# 269 270check-tools: 271.if ${TOOLCHAIN_MISSING} == "yes" && !defined(EXTERNAL_TOOLCHAIN) 272 @echo '*** WARNING: Building on MACHINE=${MACHINE} with missing toolchain.' 273 @echo '*** May result in a failed build or corrupt binaries!' 274.elif defined(EXTERNAL_TOOLCHAIN) 275 @echo '*** Using external toolchain rooted at ${EXTERNAL_TOOLCHAIN}.' 276.endif 277.if defined(NBUILDJOBS) 278 @echo '*** WARNING: NBUILDJOBS is obsolete; use -j directly instead!' 279.endif 280 281do-distrib-dirs: 282.if !defined(DESTDIR) || ${DESTDIR} == "" 283 (cd ${.CURDIR}/etc && ${MAKE} DESTDIR=/ distrib-dirs) 284.else 285 (cd ${.CURDIR}/etc && ${MAKE} DESTDIR=${DESTDIR} distrib-dirs) 286.endif 287 288.for targ in cleandir obj includes 289do-${targ}: ${targ} 290 @true 291.endfor 292 293.for dir in tools tools/compat lib/csu lib/libc lib gnu/lib 294do-${dir:S/\//-/}: 295.for targ in dependall install 296 (cd ${.CURDIR}/${dir} && ${MAKE} ${targ}) 297.endfor 298.endfor 299 300do-ld.so: 301.for targ in dependall install 302.if (${OBJECT_FMT} == "a.out") 303 (cd ${.CURDIR}/libexec/ld.aout_so && ${MAKE} ${targ}) 304.endif 305.if (${OBJECT_FMT} == "ELF") 306 (cd ${.CURDIR}/libexec/ld.elf_so && ${MAKE} ${targ}) 307.endif 308.endfor 309 310do-build: 311.for targ in dependall install 312 (cd ${.CURDIR} && ${MAKE} ${targ} BUILD_tools=no BUILD_lib=no) 313.endfor 314 315do-obsolete: 316 (cd ${.CURDIR}/etc && ${MAKE} install-obsolete-lists) 317 318# 319# Speedup stubs for some subtrees that don't need to run these rules. 320# (Tells <bsd.subdir.mk> not to recurse for them.) 321# 322 323.for dir in bin etc distrib games libexec regress sbin usr.sbin tools 324includes-${dir}: 325 @true 326.endfor 327.for dir in etc distrib regress 328install-${dir}: 329 @true 330.endfor 331 332# 333# XXX this needs to change when distrib Makefiles are recursion compliant 334# XXX many distrib subdirs need "cd etc && make snap_pre snap_kern" first... 335# 336dependall-distrib depend-distrib all-distrib: 337 @true 338 339.include <bsd.obj.mk> 340.include <bsd.subdir.mk> 341 342build-docs: ${.CURDIR}/BUILDING 343${.CURDIR}/BUILDING: doc/BUILDING.mdoc 344 groff -mdoc -Tascii -P-b -P-u -P-o $> >$@ 345