Annotation of src/Makefile, Revision 1.193
1.193 ! lukem 1: # $NetBSD: Makefile,v 1.192 2002/12/02 08:27:03 lukem Exp $
1.95 cjs 2:
1.193 ! lukem 3: #
1.95 cjs 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:
1.101 sommerfe 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.
1.95 cjs 22: # MKMAN, if set to `no', will prevent building of manual pages.
1.178 enami 23: # MKOBJDIRS, if not set to `no', will build object directories at
1.101 sommerfe 24: # an appropriate point in a build.
1.95 cjs 25: # MKSHARE, if set to `no', will prevent building and installing
26: # anything in /usr/share.
1.125 mrg 27: # UPDATE, if defined, will avoid a `make cleandir' at the start of
1.178 enami 28: # `make build', as well as having the effects listed in
29: # /usr/share/mk/bsd.README.
1.125 mrg 30: # NOCLEANDIR, if defined, will avoid a `make cleandir' at the start
1.178 enami 31: # of the `make build'.
1.119 toddpw 32: # NOINCLUDES will avoid the `make includes' usually done by `make build'.
1.95 cjs 33: #
34: # Targets:
1.137 tv 35: # build:
36: # Builds a full release of NetBSD in DESTDIR. If BUILD_DONE is
1.110 jlam 37: # set, this is an empty target.
1.137 tv 38: # release:
39: # Does a `make build,' and then tars up the DESTDIR files
1.95 cjs 40: # into RELEASEDIR, in release(7) format. (See etc/Makefile for
41: # more information on this.)
1.137 tv 42: # regression-tests:
43: # Runs the regression tests in "regress" on this host.
1.123 mrg 44: #
1.137 tv 45: # Targets invoked by `make build,' in order:
1.155 tv 46: # cleandir: cleans the tree.
1.137 tv 47: # obj: creates object directories.
1.152 tv 48: # do-tools: builds host toolchain.
1.131 tv 49: # do-distrib-dirs: creates the distribution directories.
1.137 tv 50: # includes: installs include files.
1.168 tv 51: # do-lib-csu: builds and installs prerequisites from lib/csu.
1.186 thorpej 52: # do-lib-libc: builds and installs prerequisites from lib/libc.
1.143 tv 53: # do-lib: builds and installs prerequisites from lib.
54: # do-gnu-lib: builds and installs prerequisites from gnu/lib.
1.189 itohy 55: # do-ld.so: builds and installs prerequisites from libexec/ld.*_so.
1.137 tv 56: # do-build: builds and installs the entire system.
1.193 ! lukem 57: #
1.32 cgd 58:
1.146 tv 59: .if ${.MAKEFLAGS:M${.CURDIR}/share/mk} == ""
60: .MAKEFLAGS: -m ${.CURDIR}/share/mk
61: .endif
1.163 tv 62:
1.193 ! lukem 63: #
1.163 tv 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}.
1.193 ! lukem 68: #
1.163 tv 69: _SRC_TOP_OBJ_=
1.148 jmc 70:
1.146 tv 71: .include <bsd.own.mk>
1.4 cgd 72:
1.193 ! lukem 73: #
1.137 tv 74: # Sanity check: make sure that "make build" is not invoked simultaneously
75: # with a standard recursive target.
1.193 ! lukem 76: #
1.137 tv 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
1.58 tv 87:
1.166 simonb 88: _SUBDIR= tools lib include gnu bin games libexec sbin usr.bin
1.183 lukem 89: _SUBDIR+= usr.sbin share rescue sys etc distrib regress
1.105 assar 90:
1.193 ! lukem 91: #
1.137 tv 92: # Weed out directories that don't exist.
1.193 ! lukem 93: #
1.36 explorer 94:
1.137 tv 95: .for dir in ${_SUBDIR}
1.154 tv 96: .if exists(${dir}/Makefile) && (${BUILD_${dir}:Uyes} != "no")
1.137 tv 97: SUBDIR+= ${dir}
1.36 explorer 98: .endif
1.137 tv 99: .endfor
1.21 cgd 100:
1.13 brezak 101: .if exists(regress)
1.10 cgd 102: regression-tests:
103: @echo Running regression tests...
1.152 tv 104: @(cd ${.CURDIR}/regress && ${MAKE} regress)
1.13 brezak 105: .endif
1.20 cgd 106:
1.179 thorpej 107: .if defined(UNPRIVED)
108: NOPOSTINSTALL= # defined
109: .endif
110:
1.176 lukem 111: afterinstall:
1.137 tv 112: .if ${MKMAN} != "no"
1.152 tv 113: (cd ${.CURDIR}/share/man && ${MAKE} makedb)
1.137 tv 114: .endif
1.159 perry 115: .if defined(UNPRIVED) && (${MKINFO} != "no")
1.164 jmc 116: (cd ${.CURDIR}/gnu/usr.bin/texinfo/install-info && ${MAKE} infodir-meta)
1.176 lukem 117: .endif
1.179 thorpej 118: .if !defined(NOPOSTINSTALL)
1.180 drochner 119: (cd ${.CURDIR} && ${MAKE} postinstall-check)
1.159 perry 120: .endif
1.170 lukem 121:
122: postinstall-check:
1.169 lukem 123: @echo " === Post installation checks ==="
1.175 lukem 124: sh ${.CURDIR}/etc/postinstall -s ${.CURDIR} -d ${DESTDIR}/ check
1.171 lukem 125: @echo " ================================"
126:
127: postinstall-fix: .NOTMAIN
128: @echo " === Post installation fixes ==="
1.175 lukem 129: sh ${.CURDIR}/etc/postinstall -s ${.CURDIR} -d ${DESTDIR}/ fix
1.169 lukem 130: @echo " ================================"
131:
1.108 erh 132:
1.193 ! lukem 133: #
1.137 tv 134: # Targets (in order!) called by "make build".
1.193 ! lukem 135: #
1.123 mrg 136:
1.156 tv 137: BUILDTARGETS+= check-tools
1.155 tv 138: .if !defined(UPDATE) && !defined(NOCLEANDIR)
139: BUILDTARGETS+= cleandir
140: .endif
1.149 tv 141: .if ${MKOBJDIRS} != "no"
1.137 tv 142: BUILDTARGETS+= obj
1.123 mrg 143: .endif
1.138 tv 144: .if ${USETOOLS} == "yes"
1.152 tv 145: BUILDTARGETS+= do-tools
1.131 tv 146: .endif
1.137 tv 147: .if !defined(NODISTRIBDIRS)
148: BUILDTARGETS+= do-distrib-dirs
1.131 tv 149: .endif
1.137 tv 150: .if !defined(NOINCLUDES)
151: BUILDTARGETS+= includes
1.131 tv 152: .endif
1.189 itohy 153: BUILDTARGETS+= do-lib-csu do-lib-libc do-lib do-gnu-lib do-ld.so do-build
1.131 tv 154:
1.193 ! lukem 155: #
1.137 tv 156: # Enforce proper ordering of some rules.
1.193 ! lukem 157: #
1.123 mrg 158:
1.137 tv 159: .ORDER: ${BUILDTARGETS}
160: includes-lib: includes-include includes-sys
161: includes-gnu: includes-lib
1.123 mrg 162:
1.193 ! lukem 163: #
1.137 tv 164: # Build the system and install into DESTDIR.
1.193 ! lukem 165: #
1.123 mrg 166:
1.191 lukem 167: START_TIME!= date
168:
1.137 tv 169: build:
170: .if defined(BUILD_DONE)
171: @echo "Build already installed into ${DESTDIR}"
172: .else
1.191 lukem 173: @echo "Build started at: ${START_TIME}"
1.145 tv 174: .for tgt in ${BUILDTARGETS}
1.173 sommerfe 175: @(cd ${.CURDIR} && ${MAKE} ${tgt})
1.145 tv 176: .endfor
1.191 lukem 177: @echo "Build started at: ${START_TIME}"
1.172 bjh21 178: @printf "Build finished at: " && date
1.71 mycroft 179: .endif
1.160 thorpej 180:
1.193 ! lukem 181: #
1.160 thorpej 182: # Build a full distribution, but not a release (i.e. no sets into
1.193 ! lukem 183: # ${RELEASEDIR}). "buildworld" enforces a build to ${DESTDIR} != /
! 184: #
1.160 thorpej 185:
1.193 ! lukem 186: distribution buildworld:
! 187: .if make(buildworld) && (${DESTDIR} == "" || ${DESTDIR} == "/")
! 188: @echo "Won't make ${.TARGET} with DESTDIR=/"
! 189: @false
! 190: .endif
1.182 uwe 191: (cd ${.CURDIR} && ${MAKE} NOPOSTINSTALL=1 build)
1.160 thorpej 192: (cd ${.CURDIR}/etc && ${MAKE} INSTALL_DONE=1 distribution)
1.181 thorpej 193: .if defined(DESTDIR) && ${DESTDIR} != "" && ${DESTDIR} != "/"
194: (cd ${.CURDIR}/distrib/sets && ${MAKE} checkflist)
195: .endif
1.192 lukem 196: @echo "make ${.TARGET} started at: ${START_TIME}"
1.185 lukem 197: @printf "make ${.TARGET} finished at: " && date
1.123 mrg 198:
1.193 ! lukem 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:
! 205: HOST_UNAME_S!= uname -s
! 206: HOST_UNAME_M!= uname -m
! 207:
! 208: installworld:
! 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: #
1.181 thorpej 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.
1.193 ! lukem 235: #
1.123 mrg 236:
1.179 thorpej 237: release snapshot:
238: (cd ${.CURDIR} && ${MAKE} NOPOSTINSTALL=1 build)
1.152 tv 239: (cd ${.CURDIR}/etc && ${MAKE} INSTALL_DONE=1 release)
1.192 lukem 240: @echo "make ${.TARGET} started at: ${START_TIME}"
1.185 lukem 241: @printf "make ${.TARGET} finished at: " && date
1.123 mrg 242:
1.193 ! lukem 243: #
1.137 tv 244: # Special components of the "make build" process.
1.193 ! lukem 245: #
1.156 tv 246:
247: check-tools:
1.187 thorpej 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}.'
1.156 tv 253: .endif
1.173 sommerfe 254: .if defined(NBUILDJOBS)
255: @echo '*** WARNING: NBUILDJOBS is obsolete; use -j directly instead!'
256: .endif
1.123 mrg 257:
1.137 tv 258: do-distrib-dirs:
1.147 jmc 259: .if !defined(DESTDIR) || ${DESTDIR} == ""
1.152 tv 260: (cd ${.CURDIR}/etc && ${MAKE} DESTDIR=/ distrib-dirs)
1.147 jmc 261: .else
1.152 tv 262: (cd ${.CURDIR}/etc && ${MAKE} DESTDIR=${DESTDIR} distrib-dirs)
1.147 jmc 263: .endif
1.190 lukem 264:
265: .for targ in cleandir obj includes
266: do-${targ}: ${targ}
267: @true
268: .endfor
1.123 mrg 269:
1.186 thorpej 270: .for dir in tools lib/csu lib/libc lib gnu/lib
1.143 tv 271: do-${dir:S/\//-/}:
1.137 tv 272: .for targ in dependall install
1.173 sommerfe 273: (cd ${.CURDIR}/${dir} && ${MAKE} ${targ})
1.137 tv 274: .endfor
1.184 lukem 275: .endfor
276:
1.189 itohy 277: do-ld.so:
1.184 lukem 278: .for targ in dependall install
1.189 itohy 279: .if (${OBJECT_FMT} == "a.out")
280: (cd ${.CURDIR}/libexec/ld.aout_so && ${MAKE} ${targ})
281: .endif
282: .if (${OBJECT_FMT} == "ELF")
1.184 lukem 283: (cd ${.CURDIR}/libexec/ld.elf_so && ${MAKE} ${targ})
1.189 itohy 284: .endif
1.137 tv 285: .endfor
1.143 tv 286:
287: do-build:
1.154 tv 288: .for targ in dependall install
1.173 sommerfe 289: (cd ${.CURDIR} && ${MAKE} ${targ} BUILD_tools=no BUILD_lib=no)
1.154 tv 290: .endfor
1.87 cjs 291:
1.193 ! lukem 292: #
1.137 tv 293: # Speedup stubs for some subtrees that don't need to run these rules.
294: # (Tells <bsd.subdir.mk> not to recurse for them.)
1.193 ! lukem 295: #
1.129 tv 296:
1.152 tv 297: .for dir in bin etc distrib games libexec regress sbin usr.sbin tools
298: includes-${dir}:
299: @true
300: .endfor
301: .for dir in etc distrib regress
302: install-${dir}:
303: @true
304: .endfor
305:
1.193 ! lukem 306: #
1.152 tv 307: # XXX this needs to change when distrib Makefiles are recursion compliant
1.193 ! lukem 308: # XXX many distrib subdirs need "cd etc && make snap_pre snap_kern" first...
! 309: #
1.152 tv 310: dependall-distrib depend-distrib all-distrib:
1.136 nathanw 311: @true
1.130 tv 312:
1.151 tv 313: .include <bsd.obj.mk>
1.146 tv 314: .include <bsd.subdir.mk>
1.144 tv 315:
1.150 tv 316: build-docs: ${.CURDIR}/BUILDING
1.188 lukem 317: ${.CURDIR}/BUILDING: doc/BUILDING.mdoc
1.150 tv 318: groff -mdoc -Tascii -P-b -P-u -P-o $> >$@
CVSweb <webmaster@jp.NetBSD.org>