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