Home | History | Annotate | Line # | Download | only in src
Makefile revision 1.193
      1  1.193     lukem #	$NetBSD: Makefile,v 1.193 2002/12/21 16:43:33 lukem Exp $
      2   1.95       cjs 
      3  1.193     lukem #
      4   1.95       cjs # This is the top-level makefile for building NetBSD. For an outline of
      5   1.95       cjs # how to build a snapshot or release, as well as other release engineering
      6   1.95       cjs # information, see http://www.netbsd.org/developers/releng/index.html
      7   1.95       cjs #
      8   1.95       cjs # Not everything you can set or do is documented in this makefile. In
      9   1.95       cjs # particular, you should review the files in /usr/share/mk (especially
     10   1.95       cjs # bsd.README) for general information on building programs and writing
     11   1.95       cjs # Makefiles within this structure, and see the comments in src/etc/Makefile
     12   1.95       cjs # for further information on installation and release set options.
     13   1.95       cjs #
     14   1.95       cjs # Variables listed below can be set on the make command line (highest
     15   1.95       cjs # priority), in /etc/mk.conf (middle priority), or in the environment
     16   1.95       cjs # (lowest priority).
     17   1.95       cjs #
     18   1.95       cjs # Variables:
     19  1.101  sommerfe #   DESTDIR is the target directory for installation of the compiled
     20  1.101  sommerfe #	software. It defaults to /. Note that programs are built against
     21  1.101  sommerfe #	libraries installed in DESTDIR.
     22   1.95       cjs #   MKMAN, if set to `no', will prevent building of manual pages.
     23  1.178     enami #   MKOBJDIRS, if not set to `no', will build object directories at
     24  1.101  sommerfe #	an appropriate point in a build.
     25   1.95       cjs #   MKSHARE, if set to `no', will prevent building and installing
     26   1.95       cjs #	anything in /usr/share.
     27  1.125       mrg #   UPDATE, if defined, will avoid a `make cleandir' at the start of
     28  1.178     enami #	`make build', as well as having the effects listed in
     29  1.178     enami #	/usr/share/mk/bsd.README.
     30  1.125       mrg #   NOCLEANDIR, if defined, will avoid a `make cleandir' at the start
     31  1.178     enami #	of the `make build'.
     32  1.119    toddpw #   NOINCLUDES will avoid the `make includes' usually done by `make build'.
     33   1.95       cjs #
     34   1.95       cjs # Targets:
     35  1.137        tv #   build:
     36  1.137        tv #	Builds a full release of NetBSD in DESTDIR.  If BUILD_DONE is
     37  1.110      jlam #	set, this is an empty target.
     38  1.137        tv #   release:
     39  1.137        tv #	Does a `make build,' and then tars up the DESTDIR files
     40   1.95       cjs #	into RELEASEDIR, in release(7) format. (See etc/Makefile for
     41   1.95       cjs #	more information on this.)
     42  1.137        tv #   regression-tests:
     43  1.137        tv #	Runs the regression tests in "regress" on this host.
     44  1.123       mrg #
     45  1.137        tv # Targets invoked by `make build,' in order:
     46  1.155        tv #   cleandir:        cleans the tree.
     47  1.137        tv #   obj:             creates object directories.
     48  1.152        tv #   do-tools:        builds host toolchain.
     49  1.131        tv #   do-distrib-dirs: creates the distribution directories.
     50  1.137        tv #   includes:        installs include files.
     51  1.168        tv #   do-lib-csu:      builds and installs prerequisites from lib/csu.
     52  1.186   thorpej #   do-lib-libc:     builds and installs prerequisites from lib/libc.
     53  1.143        tv #   do-lib:          builds and installs prerequisites from lib.
     54  1.143        tv #   do-gnu-lib:      builds and installs prerequisites from gnu/lib.
     55  1.189     itohy #   do-ld.so:        builds and installs prerequisites from libexec/ld.*_so.
     56  1.137        tv #   do-build:        builds and installs the entire system.
     57  1.193     lukem #
     58   1.32       cgd 
     59  1.146        tv .if ${.MAKEFLAGS:M${.CURDIR}/share/mk} == ""
     60  1.146        tv .MAKEFLAGS: -m ${.CURDIR}/share/mk
     61  1.146        tv .endif
     62  1.163        tv 
     63  1.193     lukem #
     64  1.163        tv # If _SRC_TOP_OBJ_ gets set here, we will end up with a directory that may
     65  1.163        tv # not be the top level objdir, because "make obj" can happen in the *middle*
     66  1.163        tv # of "make build" (long after <bsd.own.mk> is calculated it).  So, pre-set
     67  1.163        tv # _SRC_TOP_OBJ_ here so it will not be added to ${.MAKEOVERRIDES}.
     68  1.193     lukem #
     69  1.163        tv _SRC_TOP_OBJ_=
     70  1.148       jmc 
     71  1.146        tv .include <bsd.own.mk>
     72    1.4       cgd 
     73  1.193     lukem #
     74  1.137        tv # Sanity check: make sure that "make build" is not invoked simultaneously
     75  1.137        tv # with a standard recursive target.
     76  1.193     lukem #
     77  1.137        tv 
     78  1.137        tv .if make(build) || make(release) || make(snapshot)
     79  1.137        tv .for targ in ${TARGETS:Nobj:Ncleandir}
     80  1.137        tv .if make(${targ}) && !target(.BEGIN)
     81  1.137        tv .BEGIN:
     82  1.137        tv 	@echo 'BUILD ABORTED: "make build" and "make ${targ}" are mutually exclusive.'
     83  1.137        tv 	@false
     84  1.137        tv .endif
     85  1.137        tv .endfor
     86  1.137        tv .endif
     87   1.58        tv 
     88  1.166    simonb _SUBDIR=	tools lib include gnu bin games libexec sbin usr.bin
     89  1.183     lukem _SUBDIR+=	usr.sbin share rescue sys etc distrib regress
     90  1.105     assar 
     91  1.193     lukem #
     92  1.137        tv # Weed out directories that don't exist.
     93  1.193     lukem #
     94   1.36  explorer 
     95  1.137        tv .for dir in ${_SUBDIR}
     96  1.154        tv .if exists(${dir}/Makefile) && (${BUILD_${dir}:Uyes} != "no")
     97  1.137        tv SUBDIR+=	${dir}
     98   1.36  explorer .endif
     99  1.137        tv .endfor
    100   1.21       cgd 
    101   1.13    brezak .if exists(regress)
    102   1.10       cgd regression-tests:
    103   1.10       cgd 	@echo Running regression tests...
    104  1.152        tv 	@(cd ${.CURDIR}/regress && ${MAKE} regress)
    105   1.13    brezak .endif
    106   1.20       cgd 
    107  1.179   thorpej .if defined(UNPRIVED)
    108  1.179   thorpej NOPOSTINSTALL=	# defined
    109  1.179   thorpej .endif
    110  1.179   thorpej 
    111  1.176     lukem afterinstall:
    112  1.137        tv .if ${MKMAN} != "no"
    113  1.152        tv 	(cd ${.CURDIR}/share/man && ${MAKE} makedb)
    114  1.137        tv .endif
    115  1.159     perry .if defined(UNPRIVED) && (${MKINFO} != "no")
    116  1.164       jmc 	(cd ${.CURDIR}/gnu/usr.bin/texinfo/install-info && ${MAKE} infodir-meta)
    117  1.176     lukem .endif
    118  1.179   thorpej .if !defined(NOPOSTINSTALL)
    119  1.180  drochner 	(cd ${.CURDIR} && ${MAKE} postinstall-check)
    120  1.159     perry .endif
    121  1.170     lukem 
    122  1.170     lukem postinstall-check:
    123  1.169     lukem 	@echo "   === Post installation checks ==="
    124  1.175     lukem 	sh ${.CURDIR}/etc/postinstall -s ${.CURDIR} -d ${DESTDIR}/ check
    125  1.171     lukem 	@echo "   ================================"
    126  1.171     lukem 
    127  1.171     lukem postinstall-fix: .NOTMAIN
    128  1.171     lukem 	@echo "   === Post installation fixes ==="
    129  1.175     lukem 	sh ${.CURDIR}/etc/postinstall -s ${.CURDIR} -d ${DESTDIR}/ fix
    130  1.169     lukem 	@echo "   ================================"
    131  1.169     lukem 
    132  1.108       erh 
    133  1.193     lukem #
    134  1.137        tv # Targets (in order!) called by "make build".
    135  1.193     lukem #
    136  1.123       mrg 
    137  1.156        tv BUILDTARGETS+=	check-tools
    138  1.155        tv .if !defined(UPDATE) && !defined(NOCLEANDIR)
    139  1.155        tv BUILDTARGETS+=	cleandir
    140  1.155        tv .endif
    141  1.149        tv .if ${MKOBJDIRS} != "no"
    142  1.137        tv BUILDTARGETS+=	obj
    143  1.123       mrg .endif
    144  1.138        tv .if ${USETOOLS} == "yes"
    145  1.152        tv BUILDTARGETS+=	do-tools
    146  1.131        tv .endif
    147  1.137        tv .if !defined(NODISTRIBDIRS)
    148  1.137        tv BUILDTARGETS+=	do-distrib-dirs
    149  1.131        tv .endif
    150  1.137        tv .if !defined(NOINCLUDES)
    151  1.137        tv BUILDTARGETS+=	includes
    152  1.131        tv .endif
    153  1.189     itohy BUILDTARGETS+=	do-lib-csu do-lib-libc do-lib do-gnu-lib do-ld.so do-build
    154  1.131        tv 
    155  1.193     lukem #
    156  1.137        tv # Enforce proper ordering of some rules.
    157  1.193     lukem #
    158  1.123       mrg 
    159  1.137        tv .ORDER:		${BUILDTARGETS}
    160  1.137        tv includes-lib:	includes-include includes-sys
    161  1.137        tv includes-gnu:	includes-lib
    162  1.123       mrg 
    163  1.193     lukem #
    164  1.137        tv # Build the system and install into DESTDIR.
    165  1.193     lukem #
    166  1.123       mrg 
    167  1.191     lukem START_TIME!=	date
    168  1.191     lukem 
    169  1.137        tv build:
    170  1.137        tv .if defined(BUILD_DONE)
    171  1.137        tv 	@echo "Build already installed into ${DESTDIR}"
    172  1.137        tv .else
    173  1.191     lukem 	@echo "Build started at: ${START_TIME}"
    174  1.145        tv .for tgt in ${BUILDTARGETS}
    175  1.173  sommerfe 	@(cd ${.CURDIR} && ${MAKE} ${tgt})
    176  1.145        tv .endfor
    177  1.191     lukem 	@echo   "Build started at:  ${START_TIME}"
    178  1.172     bjh21 	@printf "Build finished at: " && date
    179   1.71   mycroft .endif
    180  1.160   thorpej 
    181  1.193     lukem #
    182  1.160   thorpej # Build a full distribution, but not a release (i.e. no sets into
    183  1.193     lukem # ${RELEASEDIR}).  "buildworld" enforces a build to ${DESTDIR} != /
    184  1.193     lukem #
    185  1.160   thorpej 
    186  1.193     lukem distribution buildworld:
    187  1.193     lukem .if make(buildworld) && (${DESTDIR} == "" || ${DESTDIR} == "/")
    188  1.193     lukem 	@echo "Won't make ${.TARGET} with DESTDIR=/"
    189  1.193     lukem 	@false
    190  1.193     lukem .endif
    191  1.182       uwe 	(cd ${.CURDIR} && ${MAKE} NOPOSTINSTALL=1 build)
    192  1.160   thorpej 	(cd ${.CURDIR}/etc && ${MAKE} INSTALL_DONE=1 distribution)
    193  1.181   thorpej .if defined(DESTDIR) && ${DESTDIR} != "" && ${DESTDIR} != "/"
    194  1.181   thorpej 	(cd ${.CURDIR}/distrib/sets && ${MAKE} checkflist)
    195  1.181   thorpej .endif
    196  1.192     lukem 	@echo   "make ${.TARGET} started at:  ${START_TIME}"
    197  1.185     lukem 	@printf "make ${.TARGET} finished at: " && date
    198  1.123       mrg 
    199  1.193     lukem #
    200  1.193     lukem # Install the distribution from $DESTDIR to $INSTALLWORLDDIR (defaults to `/')
    201  1.193     lukem # If installing to /, ensures that the host's operating system is NetBSD and
    202  1.193     lukem # the host's `uname -m` == ${MACHINE}.
    203  1.193     lukem #
    204  1.193     lukem 
    205  1.193     lukem HOST_UNAME_S!=	uname -s
    206  1.193     lukem HOST_UNAME_M!=	uname -m
    207  1.193     lukem 
    208  1.193     lukem installworld:
    209  1.193     lukem .if (${DESTDIR} == "" || ${DESTDIR} == "/")
    210  1.193     lukem 	@echo "Can't make ${.TARGET} to DESTDIR=/"
    211  1.193     lukem 	@false
    212  1.193     lukem .endif
    213  1.193     lukem .if !defined(INSTALLWORLDDIR) || \
    214  1.193     lukem     ${INSTALLWORLDDIR} == "" || ${INSTALLWORLDDIR} == "/"
    215  1.193     lukem .if (${HOST_UNAME_S} != "NetBSD")
    216  1.193     lukem 	@echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_S} to NetBSD with INSTALLWORLDDIR=/"
    217  1.193     lukem 	@false
    218  1.193     lukem .endif
    219  1.193     lukem .if (${HOST_UNAME_M} != ${MACHINE})
    220  1.193     lukem 	@echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_M} to ${MACHINE} with INSTALLWORLDDIR=/"
    221  1.193     lukem 	@false
    222  1.193     lukem .endif
    223  1.193     lukem .endif
    224  1.193     lukem 	(cd ${.CURDIR}/distrib/sets && \
    225  1.193     lukem 	    ${MAKE} INSTALLDIR=${INSTALLWORLDDIR:U/} INSTALLSETS= installsets)
    226  1.193     lukem 	(cd ${.CURDIR} && \
    227  1.193     lukem 	    ${MAKE} DESTDIR=${INSTALLWORLDDIR} postinstall-check)
    228  1.193     lukem 	@echo   "make ${.TARGET} started at:  ${START_TIME}"
    229  1.193     lukem 	@printf "make ${.TARGET} finished at: " && date
    230  1.193     lukem 
    231  1.193     lukem #
    232  1.181   thorpej # Build a release or snapshot (implies "make build").  Note that
    233  1.181   thorpej # in this case, the set lists will be checked before the tar files
    234  1.181   thorpej # are made.
    235  1.193     lukem #
    236  1.123       mrg 
    237  1.179   thorpej release snapshot:
    238  1.179   thorpej 	(cd ${.CURDIR} && ${MAKE} NOPOSTINSTALL=1 build)
    239  1.152        tv 	(cd ${.CURDIR}/etc && ${MAKE} INSTALL_DONE=1 release)
    240  1.192     lukem 	@echo   "make ${.TARGET} started at:  ${START_TIME}"
    241  1.185     lukem 	@printf "make ${.TARGET} finished at: " && date
    242  1.123       mrg 
    243  1.193     lukem #
    244  1.137        tv # Special components of the "make build" process.
    245  1.193     lukem #
    246  1.156        tv 
    247  1.156        tv check-tools:
    248  1.187   thorpej .if ${TOOLCHAIN_MISSING} == "yes" && !defined(EXTERNAL_TOOLCHAIN)
    249  1.187   thorpej 	@echo '*** WARNING:  Building on MACHINE=${MACHINE} with missing toolchain.'
    250  1.187   thorpej 	@echo '*** May result in a failed build or corrupt binaries!'
    251  1.187   thorpej .elif defined(EXTERNAL_TOOLCHAIN)
    252  1.187   thorpej 	@echo '*** Using external toolchain rooted at ${EXTERNAL_TOOLCHAIN}.'
    253  1.156        tv .endif
    254  1.173  sommerfe .if defined(NBUILDJOBS)
    255  1.173  sommerfe 	@echo '*** WARNING: NBUILDJOBS is obsolete; use -j directly instead!'
    256  1.173  sommerfe .endif
    257  1.123       mrg 
    258  1.137        tv do-distrib-dirs:
    259  1.147       jmc .if !defined(DESTDIR) || ${DESTDIR} == ""
    260  1.152        tv 	(cd ${.CURDIR}/etc && ${MAKE} DESTDIR=/ distrib-dirs)
    261  1.147       jmc .else
    262  1.152        tv 	(cd ${.CURDIR}/etc && ${MAKE} DESTDIR=${DESTDIR} distrib-dirs)
    263  1.147       jmc .endif
    264  1.190     lukem 
    265  1.190     lukem .for targ in cleandir obj includes
    266  1.190     lukem do-${targ}: ${targ}
    267  1.190     lukem 	@true
    268  1.190     lukem .endfor
    269  1.123       mrg 
    270  1.186   thorpej .for dir in tools lib/csu lib/libc lib gnu/lib
    271  1.143        tv do-${dir:S/\//-/}:
    272  1.137        tv .for targ in dependall install
    273  1.173  sommerfe 	(cd ${.CURDIR}/${dir} && ${MAKE} ${targ})
    274  1.137        tv .endfor
    275  1.184     lukem .endfor
    276  1.184     lukem 
    277  1.189     itohy do-ld.so:
    278  1.184     lukem .for targ in dependall install
    279  1.189     itohy .if (${OBJECT_FMT} == "a.out")
    280  1.189     itohy 	(cd ${.CURDIR}/libexec/ld.aout_so && ${MAKE} ${targ})
    281  1.189     itohy .endif
    282  1.189     itohy .if (${OBJECT_FMT} == "ELF")
    283  1.184     lukem 	(cd ${.CURDIR}/libexec/ld.elf_so && ${MAKE} ${targ})
    284  1.189     itohy .endif
    285  1.137        tv .endfor
    286  1.143        tv 
    287  1.143        tv do-build:
    288  1.154        tv .for targ in dependall install
    289  1.173  sommerfe 	(cd ${.CURDIR} && ${MAKE} ${targ} BUILD_tools=no BUILD_lib=no)
    290  1.154        tv .endfor
    291   1.87       cjs 
    292  1.193     lukem #
    293  1.137        tv # Speedup stubs for some subtrees that don't need to run these rules.
    294  1.137        tv # (Tells <bsd.subdir.mk> not to recurse for them.)
    295  1.193     lukem #
    296  1.129        tv 
    297  1.152        tv .for dir in bin etc distrib games libexec regress sbin usr.sbin tools
    298  1.152        tv includes-${dir}:
    299  1.152        tv 	@true
    300  1.152        tv .endfor
    301  1.152        tv .for dir in etc distrib regress
    302  1.152        tv install-${dir}:
    303  1.152        tv 	@true
    304  1.152        tv .endfor
    305  1.152        tv 
    306  1.193     lukem #
    307  1.152        tv # XXX this needs to change when distrib Makefiles are recursion compliant
    308  1.193     lukem # XXX many distrib subdirs need "cd etc && make snap_pre snap_kern" first...
    309  1.193     lukem #
    310  1.152        tv dependall-distrib depend-distrib all-distrib:
    311  1.136   nathanw 	@true
    312  1.130        tv 
    313  1.151        tv .include <bsd.obj.mk>
    314  1.146        tv .include <bsd.subdir.mk>
    315  1.144        tv 
    316  1.150        tv build-docs: ${.CURDIR}/BUILDING
    317  1.188     lukem ${.CURDIR}/BUILDING: doc/BUILDING.mdoc
    318  1.150        tv 	groff -mdoc -Tascii -P-b -P-u -P-o $> >$@
    319