Home | History | Annotate | Line # | Download | only in src
Makefile revision 1.128
      1 #	$NetBSD: Makefile,v 1.128 2001/08/17 15:05:50 thorpej Exp $
      2 
      3 # This is the top-level makefile for building NetBSD. For an outline of
      4 # how to build a snapshot or release, as well as other release engineering
      5 # information, see http://www.netbsd.org/developers/releng/index.html
      6 #
      7 # Not everything you can set or do is documented in this makefile. In
      8 # particular, you should review the files in /usr/share/mk (especially
      9 # bsd.README) for general information on building programs and writing
     10 # Makefiles within this structure, and see the comments in src/etc/Makefile
     11 # for further information on installation and release set options.
     12 #
     13 # Variables listed below can be set on the make command line (highest
     14 # priority), in /etc/mk.conf (middle priority), or in the environment
     15 # (lowest priority).
     16 #
     17 # Variables:
     18 #   DESTDIR is the target directory for installation of the compiled
     19 #	software. It defaults to /. Note that programs are built against
     20 #	libraries installed in DESTDIR.
     21 #   MKMAN, if set to `no', will prevent building of manual pages.
     22 #   MKOBJDIRS, if not set to `no', will build object directories at 
     23 #	an appropriate point in a build.
     24 #   MKSHARE, if set to `no', will prevent building and installing
     25 #	anything in /usr/share.
     26 #   NBUILDJOBS is the number of jobs to start in parallel during a
     27 #	`make build'. It defaults to 1.
     28 #   UPDATE, if defined, will avoid a `make cleandir' at the start of
     29 #     `make build', as well as having the effects listed in
     30 #     /usr/share/mk/bsd.README.
     31 #   NOCLEANDIR, if defined, will avoid a `make cleandir' at the start
     32 #     of the `make build'.
     33 #   NOINCLUDES will avoid the `make includes' usually done by `make build'.
     34 
     35 #
     36 # Targets:
     37 #   build: builds a full release of netbsd in DESTDIR. If BUILD_DONE is
     38 #	set, this is an empty target.
     39 #   release: 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 #   snapshot: a synonym for release.
     43 #
     44 # Sub targets of `make build,' in order:
     45 #   buildstartmsg: displays the start time of the build.
     46 #   beforeinstall: creates the distribution directories.
     47 #   do-force-domestic: check's that FORCE_DOMESTIC isn't set (deprecated.)
     48 #   do-share-mk: installs /usr/share/mk files.
     49 #   do-cleandir: cleans the tree.
     50 #   do-make-obj: creates object directories if required.
     51 #   do-make-tools: builds host toolchain.
     52 #   do-make-includes: install include files.
     53 #   do-lib-csu: build & install startup object files.
     54 #   do-lib: build & install system libraries.
     55 #   do-gnu-lib: build & install gnu system libraries.
     56 #   do-dependall: builds & install the entire system.
     57 #   do-domestic: build & install the domestic tree (deprecated.)
     58 #   do-whatisdb: build & install the `whatis.db' man database.
     59 #   buildendmsg: displays the end time of the build.
     60 
     61 .include <bsd.own.mk>
     62 
     63 .if defined(USE_NEW_TOOLCHAIN)
     64 .include "${.CURDIR}/tools/Makefile.tools"
     65 .endif
     66 
     67 MKOBJDIRS ?= no
     68 
     69 .if defined(NBUILDJOBS)
     70 _J= -j${NBUILDJOBS}
     71 .endif
     72 
     73 .if defined(DESTDIR)
     74 _M=-m ${DESTDIR}/usr/share/mk
     75 .endif
     76 
     77 # NOTE THAT etc *DOES NOT* BELONG IN THE LIST BELOW
     78 
     79 SUBDIR+= lib include bin libexec sbin usr.bin usr.sbin share sys
     80 .if make(cleandir) || make(obj)
     81 SUBDIR+= distrib
     82 .ifdef MAKEOBJDIRPREFIX
     83 SUBDIR+= etc
     84 .endif
     85 .endif
     86 
     87 includes-lib: includes-include includes-sys
     88 
     89 .if exists(games)
     90 SUBDIR+= games
     91 .endif
     92 
     93 SUBDIR+= gnu
     94 # This is needed for libstdc++ and gen-params.
     95 includes-gnu: includes-include includes-sys
     96 
     97 .if exists(regress)
     98 .ifmake !(install)
     99 SUBDIR+= regress
    100 .endif
    101 
    102 regression-tests:
    103 	@echo Running regression tests...
    104 	@(cd ${.CURDIR}/regress && ${MAKE} ${_M} regress)
    105 .endif
    106 
    107 buildstartmsg:
    108 	@echo -n "Build started at: "
    109 	@date
    110 
    111 buildendmsg:
    112 	@echo -n "Build finished at: "
    113 	@date
    114 
    115 # If sharesrc is around, use its share/mk files to bootstrap until the
    116 # mk files are installed (first step of make build).  If installing to
    117 # DESTDIR, don't bother, since the build will fail later on anyway.
    118 
    119 beforeinstall:
    120 .ifndef NODISTRIBDIRS
    121 .ifndef DESTDIR
    122 .if exists(share/mk)
    123 	(cd ${.CURDIR}/etc && \
    124 	    ${MAKE} -m ${.CURDIR}/share/mk DESTDIR=/ distrib-dirs)
    125 .else
    126 	(cd ${.CURDIR}/etc && ${MAKE} DESTDIR=/ distrib-dirs)
    127 .endif
    128 .else
    129 	(cd ${.CURDIR}/etc && ${MAKE} DESTDIR=${DESTDIR} distrib-dirs)
    130 .endif
    131 .endif
    132 
    133 afterinstall:
    134 .if ${MKMAN} != "no" && !defined(_BUILD)
    135 	${MAKE} ${_M} whatis.db
    136 .endif
    137 
    138 whatis.db:
    139 	(cd ${.CURDIR}/share/man && ${MAKE} ${_M} makedb)
    140 
    141 # wrt info/dir below:  It's safe to move this over top of /usr/share/info/dir,
    142 # as the build will automatically remove/replace the non-pkg entries there.
    143 
    144 .if defined(BUILD_DONE)
    145 build:
    146 	@echo "Build installed into ${DESTDIR}"
    147 .else
    148 build:
    149 	@${MAKE} ${_M} buildstartmsg
    150 	@${MAKE} ${_M} beforeinstall
    151 	@${MAKE} ${_M} do-force-domestic
    152 	@${MAKE} ${_M} do-share-mk
    153 	@${MAKE} ${_M} do-cleandir
    154 	@${MAKE} ${_M} do-make-obj
    155 	@${MAKE} ${_M} do-make-tools
    156 	@${MAKE} ${_M} do-make-includes
    157 	@${MAKE} ${_M} do-lib-csu
    158 	@${MAKE} ${_M} do-lib
    159 	@${MAKE} ${_M} do-gnu-lib
    160 	@${MAKE} ${_M} do-dependall
    161 	@${MAKE} ${_M} do-domestic
    162 	@${MAKE} ${_M} do-whatisdb
    163 	@${MAKE} ${_M} buildendmsg
    164 .endif
    165 
    166 do-force-domestic:
    167 .if defined(FORCE_DOMESTIC)
    168 	@echo '*** CAPUTE!'
    169 	@echo '    The FORCE_DOMESTIC flag is not compatible with "make build".'
    170 	@echo '    Please correct the problem and try again.'
    171 	@false
    172 .endif
    173 
    174 do-share-mk:
    175 .if ${MKSHARE} != "no"
    176 	(cd ${.CURDIR}/share/mk && ${MAKE} install)
    177 .endif
    178 
    179 do-cleandir:
    180 .if !defined(UPDATE) && !defined(NOCLEANDIR)
    181 	${MAKE} ${_J} ${_M} cleandir
    182 .endif
    183 
    184 do-make-obj:
    185 .if ${MKOBJDIRS} != "no"
    186 	${MAKE} ${_J} ${_M} obj
    187 .if defined(USE_NEW_TOOLCHAIN)
    188 	cd ${.CURDIR}/tools && ${MAKE} ${_M} obj
    189 .endif
    190 .endif
    191 
    192 do-make-tools:
    193 .if defined(USE_NEW_TOOLCHAIN)
    194 	cd ${.CURDIR}/tools && ${MAKE} ${_M} build
    195 .endif
    196 
    197 do-make-includes:
    198 .if !defined(NOINCLUDES)
    199 	${MAKE} ${_M} includes
    200 .endif
    201 
    202 do-lib-csu:
    203 	(cd ${.CURDIR}/lib/csu && \
    204 	    ${MAKE} ${_M} ${_J} MKSHARE=no dependall && \
    205 	    ${MAKE} ${_M} MKSHARE=no install)
    206 
    207 do-lib:
    208 	(cd ${.CURDIR}/lib && \
    209 	    ${MAKE} ${_M} ${_J} MKSHARE=no dependall && \
    210 	    ${MAKE} ${_M} MKSHARE=no install)
    211 
    212 do-gnu-lib:
    213 	(cd ${.CURDIR}/gnu/lib && \
    214 	    ${MAKE} ${_M} ${_J} MKSHARE=no dependall && \
    215 	    ${MAKE} ${_M} MKSHARE=no install)
    216 
    217 do-dependall:
    218 	${MAKE} ${_M} ${_J} dependall && ${MAKE} ${_M} _BUILD= install
    219 
    220 do-domestic:
    221 .if defined(DOMESTIC) && !defined(EXPORTABLE_SYSTEM)
    222 	(cd ${.CURDIR}/${DOMESTIC} && ${MAKE} ${_M} ${_J} _SLAVE_BUILD= build)
    223 .endif
    224 
    225 do-whatisdb:
    226 	${MAKE} ${_M} whatis.db
    227 
    228 release snapshot: build
    229 	(cd ${.CURDIR}/etc && ${MAKE} ${_M} INSTALL_DONE=1 release)
    230 
    231 .include <bsd.subdir.mk>
    232