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