Home | History | Annotate | Line # | Download | only in etc
Makefile revision 1.259
      1 #	$NetBSD: Makefile,v 1.259 2003/10/25 03:55:26 ross Exp $
      2 #	from: @(#)Makefile	8.7 (Berkeley) 5/25/95
      3 
      4 # Environment variables without default values:
      5 #   DESTDIR must be set before anything in this file will work.
      6 #   RELEASEDIR is where the tarred up stuff for a snapshot or
      7 #	release will be placed.
      8 #
      9 # Environment variables with default values:
     10 #   LOCALTIME will set the default local time for the system you
     11 #	build; it determines what /etc/localtime is symlink'd to.
     12 #   KERNSRCDIR points to kernel source; it is set by default to ../sys,
     13 #	but can be overridden.
     14 #   KERNOBJDIR is the kernel build directory, it defaults to
     15 #	${KERNSRCDIR}/arch/${MACHINE}/compile, but can be overridden.
     16 #   KERNCONFDIR is where the configuration files for kernels are found;
     17 #	default is ${KERNSRCDIR}/arch/${MACHINE}/conf but can be overridden.
     18 #   MKUPDATE; if not `no', don't do a 'make clean' before kernel compile
     19 #   NO_SENDMAIL is normally undefined; if defined, it will not do a
     20 #	`make distribution' in the sendmail config file source directory.
     21 #
     22 # Targets:
     23 #    distribution: makes a full NetBSD distribution in DESTDIR. If
     24 #	INSTALL_DONE is set, it will not do a `make install.'
     25 #	if DISTRIBUTION_DONE is set, it will not do anything.
     26 #    distrib-dirs: creates an empty NetBSD directory tree in DESTDIR.
     27 #	Called by distribution.
     28 #    snapshot: calls distribution, above, and then tars up the files
     29 #	into a release(7) format in RELEASEDIR/${MACHINE}.
     30 #	Any port-dependent stuff for this target is found in
     31 #	etc.${MACHINE}/Makefile.inc.
     32 #    release: a synonym for `snapshot'
     33 #
     34 
     35 # For NO_SENDMAIL, INSTPRIV, MKCRYPTO
     36 #
     37 .include <bsd.own.mk>
     38 
     39 # For KERNSRCDIR, KERNOBJDIR, ...
     40 #
     41 .include <bsd.kernobj.mk>
     42 
     43 # For TARGET_ENDIANNESS
     44 #
     45 .include <bsd.endian.mk>
     46 
     47 
     48 .MAKEOVERRIDES+=	USETOOLS
     49 
     50 TZDIR=		/usr/share/zoneinfo
     51 LOCALTIME?=	UTC
     52 MAKESUMS=	CKSUM=${TOOL_CKSUM:Q} ${HOST_SH} ${NETBSDSRCDIR}/distrib/sets/makesums
     53 
     54 # Flags for creating ISO CDROM image
     55 # mkisofs is expected to be in $PATH, install via pkgsrc/sysutils/cdrecord
     56 # Note: At least mkisofs 2.0 should be used.
     57 #
     58 MKISOFS?=	mkisofs
     59 DISTRIBREV!=	sh ${KERNSRCDIR}/conf/osrelease.sh -s
     60 # ISO 9660 volume ID.  Note that this can only contain [A-Z0-9_].
     61 ISO_VOLID!=	echo NETBSD_${MACHINE}_${DISTRIBREV} | tr a-z A-Z
     62 MKISOFS_FLAGS+= -J -l \
     63 		-r -T -v \
     64 		-V ${ISO_VOLID} \
     65 		-P "The NetBSD Project" \
     66 		-m "${RELEASEDIR}/${MACHINE}/installation/cdrom"
     67 
     68 # MD Makefile.inc may append MD targets to BIN[123].  Make sure all
     69 # are empty, to preserve the old semantics of setting them below with "=".
     70 #
     71 BIN1=
     72 BIN2=
     73 BIN3=
     74 
     75 # Directories to build in ${RELEASEDIR}/${MACHINE}.
     76 # MD Makefile.inc files can add to this.
     77 # NOTE: Parent directories must be listed before subdirectories.
     78 #
     79 INSTALLATION_DIRS=	binary binary/sets binary/kernel installation
     80 
     81 .if exists(etc.${MACHINE}/Makefile.inc)
     82 .include "etc.${MACHINE}/Makefile.inc"
     83 .endif
     84 
     85 # -rw-r--r--
     86 BINOWN= root
     87 BINGRP= wheel
     88 UTMPGRP= utmp
     89 BIN1+=	bootptab changelist csh.cshrc csh.login csh.logout daily \
     90 	daily.conf dm.conf floppytab ftpchroot ftpusers \
     91 	gettytab group hosts hosts.lpd inetd.conf lkm.conf \
     92 	mailer.conf man.conf monthly monthly.conf mrouted.conf \
     93 	netconfig networks newsyslog.conf nsswitch.conf ntp.conf \
     94 	passwd.conf phones printcap profile protocols rbootd.conf rc rc.conf \
     95 	rc.lkm rc.local rc.subr rc.shutdown remote rpc \
     96 	security security.conf services shells sysctl.conf syslog.conf \
     97 	weekly weekly.conf wscons.conf \
     98 	etc.${MACHINE}/ttys
     99 
    100 # Use machine-specific disktab if it exists, or the MI one otherwise
    101 .if exists(etc.${MACHINE}/disktab)
    102 BIN1+=	etc.${MACHINE}/disktab
    103 .else
    104 BIN1+=	disktab
    105 .endif
    106 
    107 .if exists(etc.${MACHINE}/ld.so.conf)
    108 BIN1+=	etc.${MACHINE}/ld.so.conf
    109 .endif
    110 
    111 .if exists(etc.${MACHINE}/ttyaction)
    112 BIN1+=	etc.${MACHINE}/ttyaction
    113 .endif
    114 
    115 # -rw-rw-r--
    116 BIN2+=	motd
    117 
    118 # -rw-------
    119 BIN3+=	hosts.equiv
    120 
    121 ETC_PKG=-T etc_pkg
    122 BASE_PKG=-T base_pkg
    123 ETC_INSTALL_FILE=cd ${.CURDIR} && ${INSTALL_FILE} ${ETC_PKG}
    124 ETC_INSTALL_OBJ_FILE=             ${INSTALL_FILE} ${ETC_PKG}
    125 ETC_INSTALL_LINK=cd ${.CURDIR} && ${INSTALL_LINK} ${ETC_PKG}
    126 ETC_INSTALL_SYMLINK=cd ${.CURDIR} && ${INSTALL_SYMLINK} ${ETC_PKG}
    127 
    128 NAMEDB=	127 root.cache named.conf localhost loopback.v6
    129 
    130 .if ${TARGET_ENDIANNESS} == "1234"
    131 PWD_MKDB_ENDIAN=	-L
    132 .elif ${TARGET_ENDIANNESS} == "4321"
    133 PWD_MKDB_ENDIAN=	-B
    134 .else
    135 PWD_MKDB_ENDIAN=
    136 .endif
    137 
    138 
    139 # distribution --
    140 #	Build a distribution
    141 #
    142 distribution: check_DESTDIR .WAIT distrib-dirs
    143 .if !defined(DISTRIBUTION_DONE)
    144 .if !defined(INSTALL_DONE)
    145 	(cd ${NETBSDSRCDIR}; ${MAKE} _DISTRIB= includes)
    146 	(cd ${NETBSDSRCDIR}; ${MAKE} _DISTRIB= install)
    147 .endif	# !INSTALL_DONE
    148 	(cd ${.CURDIR}; ${MAKE} install-etc-files)
    149 .endif	# !DISTRIBUTION_DONE
    150 
    151 .PHONY: MAKEDEV
    152 MAKEDEV:
    153 	awk -v ETCDIR="${.CURDIR}" -f ${.CURDIR}/MAKEDEV.awk ${.CURDIR}/MAKEDEV.tmpl > ${.TARGET}
    154 
    155 	
    156 
    157 # install-etc-files --
    158 #	Install etc (config) files; not performed by "make build"
    159 #
    160 install-etc-files: check_DESTDIR MAKEDEV
    161 	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
    162 	    ${BIN1} ${DESTDIR}/etc
    163 	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 664 \
    164 	    ${BIN2} ${DESTDIR}/etc
    165 	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 \
    166 	    ${BIN3} ${DESTDIR}/etc
    167 	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
    168 	    aliases ${DESTDIR}/etc/mail
    169 	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
    170 	    /dev/null ${DESTDIR}/etc/mail/local-host-names
    171 	${ETC_INSTALL_FILE} -o root -g wheel -m 600 \
    172 	    crontab ${DESTDIR}/var/cron/tabs/root
    173 	${ETC_INSTALL_FILE} -o root -g wheel -m 600 \
    174 	    master.passwd ${DESTDIR}/etc
    175 	${TOOL_PWD_MKDB} -p ${PWD_MKDB_ENDIAN} -d ${DESTDIR}/ \
    176 	    ${DESTDIR}/etc/master.passwd
    177 .if ${MKUNPRIVED} != "no"
    178 	( \
    179 		for metaent in passwd pwd.db spwd.db; do \
    180 	    		echo "./etc/$${metaent} type=file mode=0644 uname=root gname=wheel tags=etc_pkg"; \
    181 		done; \
    182 	) | ${METALOG.add}
    183 .endif	# MKUNPRIVED != no
    184 	${ETC_INSTALL_OBJ_FILE} -o ${BINOWN} -g ${BINGRP} -m 555 \
    185 	    MAKEDEV ${DESTDIR}/dev
    186 	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 555 \
    187 	    MAKEDEV.local ${DESTDIR}/dev
    188 	${ETC_INSTALL_FILE} -o root -g wheel -m 600 \
    189 	    minfree ${DESTDIR}/var/crash
    190 .for file in cshrc login profile shrc
    191 	${ETC_INSTALL_FILE} -o root -g wheel -m 644 \
    192 	    root/dot.${file} ${DESTDIR}/root/.${file}
    193 .endfor
    194 	${ETC_INSTALL_FILE} -o root -g wheel -m 600 \
    195 	    root/dot.klogin ${DESTDIR}/root/.klogin
    196 	rm -f ${DESTDIR}/.cshrc ${DESTDIR}/.profile
    197 	${ETC_INSTALL_LINK} ${DESTDIR}/root/.cshrc ${DESTDIR}/.cshrc
    198 	${ETC_INSTALL_LINK} ${DESTDIR}/root/.profile ${DESTDIR}/.profile
    199 	(cd ${.CURDIR}/defaults; ${MAKE} install)
    200 	(cd ${.CURDIR}/mtree; ${MAKE} install)
    201 .for file in ${NAMEDB}
    202 	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
    203 	    namedb/${file} ${DESTDIR}/etc/namedb
    204 .endfor
    205 	(cd ${.CURDIR}/powerd; ${MAKE} install)
    206 	(cd ${.CURDIR}/rc.d; ${MAKE} install)
    207 	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
    208 	    postinstall ${DESTDIR}/etc
    209 	${ETC_INSTALL_SYMLINK} -o root -g wheel -m 755 \
    210 	    ${TZDIR}/${LOCALTIME} ${DESTDIR}/etc/localtime
    211 	${ETC_INSTALL_SYMLINK} -o root -g wheel -m 755 \
    212 	    /usr/sbin/rmt ${DESTDIR}/etc/rmt
    213 	${ETC_INSTALL_FILE} -o ${BINOWN} -g operator -m 664 \
    214 	    /dev/null ${DESTDIR}/etc/dumpdates
    215 	${ETC_INSTALL_FILE} -o ${BINOWN} -g operator -m 600 \
    216 	    /dev/null ${DESTDIR}/etc/skeykeys
    217 	${ETC_INSTALL_FILE} -o root -g wheel -m 600 \
    218 	    /dev/null ${DESTDIR}/var/at/at.deny
    219 	${ETC_INSTALL_FILE} -o nobody -g ${BINGRP} -m 664 \
    220 	    /dev/null ${DESTDIR}/var/db/locate.database
    221 	${ETC_INSTALL_FILE} -o uucp -g dialer -m 640 \
    222 	    /dev/null ${DESTDIR}/var/log/aculog
    223 	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 \
    224 	    /dev/null ${DESTDIR}/var/log/authlog
    225 	${ETC_INSTALL_FILE} -o root -g wheel -m 600 \
    226 	    /dev/null ${DESTDIR}/var/log/cron
    227 	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 664 \
    228 	    /dev/null ${DESTDIR}/var/log/lastlog
    229 	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 640 \
    230 	    /dev/null ${DESTDIR}/var/log/lpd-errs
    231 	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 \
    232 	    /dev/null ${DESTDIR}/var/log/maillog
    233 	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
    234 	    /dev/null ${DESTDIR}/var/log/messages
    235 	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 \
    236 	    /dev/null ${DESTDIR}/var/log/secure
    237 	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
    238 	    /dev/null ${DESTDIR}/var/log/sendmail.st
    239 	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
    240 	    /dev/null ${DESTDIR}/var/log/wtmp
    241 	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
    242 	    /dev/null ${DESTDIR}/var/log/wtmpx
    243 	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 \
    244 	    /dev/null ${DESTDIR}/var/log/xferlog
    245 	${ETC_INSTALL_FILE} -o daemon -g staff -m 664 \
    246 	    /dev/null ${DESTDIR}/var/msgs/bounds
    247 	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${UTMPGRP} -m 664 \
    248 	    /dev/null ${DESTDIR}/var/run/utmp
    249 	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${UTMPGRP} -m 664 \
    250 	    /dev/null ${DESTDIR}/var/run/utmpx
    251 	${ETC_INSTALL_FILE} -o games -g games -m 664 \
    252 	    /dev/null ${DESTDIR}/var/games/atc_score
    253 	${ETC_INSTALL_FILE} -o games -g games -m 664 \
    254 	    /dev/null ${DESTDIR}/var/games/battlestar.log
    255 	${ETC_INSTALL_FILE} -o games -g games -m 664 \
    256 	    /dev/null ${DESTDIR}/var/games/cfscores
    257 	${ETC_INSTALL_FILE} -o games -g games -m 664 \
    258 	    /dev/null ${DESTDIR}/var/games/criblog
    259 	${ETC_INSTALL_FILE} -o games -g games -m 660 \
    260 	    /dev/null ${DESTDIR}/var/games/hackdir/perm
    261 	${ETC_INSTALL_FILE} -o games -g games -m 660 \
    262 	    /dev/null ${DESTDIR}/var/games/hackdir/record
    263 	${ETC_INSTALL_FILE} -o games -g games -m 664 \
    264 	    /dev/null ${DESTDIR}/var/games/larn/llog12.0
    265 	${ETC_INSTALL_FILE} -o games -g games -m 664 \
    266 	    /dev/null ${DESTDIR}/var/games/larn/lscore12.0
    267 	${ETC_INSTALL_FILE} -o games -g games -m 664 \
    268 	    /dev/null ${DESTDIR}/var/games/larn/playerids
    269 	${ETC_INSTALL_FILE} -o games -g games -m 664 \
    270 	    /dev/null ${DESTDIR}/var/games/robots_roll
    271 	${ETC_INSTALL_FILE} -o games -g games -m 664 \
    272 	    /dev/null ${DESTDIR}/var/games/rogue.scores
    273 	${ETC_INSTALL_FILE} -o games -g games -m 664 \
    274 	    /dev/null ${DESTDIR}/var/games/saillog
    275 	${ETC_INSTALL_FILE} -o games -g games -m 664 \
    276 	    /dev/null ${DESTDIR}/var/games/snakerawscores
    277 	${ETC_INSTALL_FILE} -o games -g games -m 664 \
    278 	    /dev/null ${DESTDIR}/var/games/snake.log
    279 	${ETC_INSTALL_FILE} -o games -g games -m 664 \
    280 	    /dev/null ${DESTDIR}/var/games/tetris.scores
    281 	(cd ${.CURDIR}/skel; ${MAKE} distribution)
    282 	(cd ${NETBSDSRCDIR}/usr.bin/mail; ${MAKE} distribution)
    283 	(cd ${NETBSDSRCDIR}/gnu/usr.sbin/postfix/; ${MAKE} distribution)
    284 .if (${MKCRYPTO} != "no")
    285 	(cd ${NETBSDSRCDIR}/usr.bin/ssh; ${MAKE} distribution)
    286 .endif
    287 .if !defined(NO_SENDMAIL) || ${NO_SENDMAIL} == "no"
    288 	(cd ${NETBSDSRCDIR}/gnu/usr.sbin/sendmail/cf/cf; ${MAKE} distribution)
    289 .endif
    290 
    291 
    292 # install-obsolete-lists --
    293 #	Install var/db/obsolete set lists; this is performed by "make build"
    294 #
    295 OBSOLETE.dir=		${.OBJDIR}/obsolete.dir
    296 OBSOLETE.files=		base comp etc games man misc text
    297 
    298 install-obsolete-lists:
    299 	mkdir -p ${OBSOLETE.dir}
    300 	(cd ${NETBSDSRCDIR}/distrib/sets && \
    301 	    MAKE=${MAKE:Q} ${HOST_SH} ./makeobsolete -t ${OBSOLETE.dir})
    302 .for file in ${OBSOLETE.files}
    303 	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
    304 	    ${OBSOLETE.dir}/${file} ${DESTDIR}/var/db/obsolete
    305 .endfor
    306 
    307 
    308 # distrib-dirs --
    309 #	Populate $DESTDIR with directories needed by NetBSD
    310 #
    311 .if ${MKUNPRIVED} == "no"
    312 TOOL_MTREE.unpriv=
    313 .else
    314 TOOL_MTREE.unpriv=	-W
    315 .endif
    316 
    317 distrib-dirs: check_DESTDIR
    318 .if !defined(DISTRIBUTION_DONE)
    319 	${INSTALL_DIR} -o root -g wheel -m 755 ${BASE_PKG} ${DESTDIR}
    320 .endif
    321 	${TOOL_MTREE} -def ${.CURDIR}/mtree/NetBSD.dist -N ${.CURDIR} \
    322 	    -p ${DESTDIR}/ -U ${TOOL_MTREE.unpriv}
    323 
    324 
    325 # release, snapshot --
    326 #	Build a full distribution including kernels & install media.
    327 #
    328 release snapshot: check_DESTDIR check_RELEASEDIR .WAIT \
    329 		    distribution .WAIT \
    330 		    snap_pre .WAIT snap_kern .WAIT \
    331 		    snap_post .WAIT snap_md_post
    332 	(cd ${NETBSDSRCDIR}/distrib/sets; ${MAKE} sets)
    333 	${MAKESUMS} -t ${RELEASEDIR}/${MACHINE}/binary/kernel '*.gz'
    334 
    335 
    336 # iso-image --
    337 #	Standalone target to create a CDROM image after the release
    338 #	was composed.  Should be run after "make release" in src and xsrc.
    339 #
    340 #	Note: At least mkisofs 2.0 should be used.
    341 #
    342 CDROM.image=${RELEASEDIR}/${MACHINE}/installation/cdrom/netbsd-${MACHINE}.iso
    343 CDROM.dir=	cdrom.dir
    344 CDROM.pathlist=	cdrom.pathlist
    345 
    346 iso-image: check_DESTDIR check_RELEASEDIR .WAIT iso-image-md-post
    347 	${MAKESUMS} -t ${RELEASEDIR}/${MACHINE}/installation/cdrom '*.iso'
    348 
    349 iso-image-setup: check_RELEASEDIR
    350 	rm -f ${CDROM.pathlist}
    351 	echo "${MACHINE}=${RELEASEDIR}/${MACHINE}" >> ${CDROM.pathlist}
    352 	mkdir -p ${CDROM.dir}
    353 	mkdir -p ${RELEASEDIR}/${MACHINE}/installation/cdrom
    354 
    355 # iso-image-mi --
    356 #	Create the image after the MD operations have completed.
    357 #
    358 iso-image-mi: check_DESTDIR check_RELEASEDIR .WAIT \
    359 		iso-image-setup .WAIT iso-image-md-pre
    360 	@if ! ${MKISOFS} --version; then \
    361 		echo "install pkgsrc/sysutils/cdrecord and run 'make iso-image'." ; \
    362 		false; \
    363 	fi
    364 	${MKISOFS} ${MKISOFS_FLAGS} -graft-points -path-list ${CDROM.pathlist} \
    365 	    -o ${CDROM.image} ${CDROM.dir}
    366 
    367 # iso-image-md-pre --
    368 #	Setup ${CDROM.dir} to produce a bootable CD image.
    369 #	Overridden by etc.$MACHINE/Makefile.inc
    370 #
    371 iso-image-md-pre: check_DESTDIR check_RELEASEDIR
    372 #	(empty -- look in the machine-dependent Makefile.inc)
    373 
    374 # iso-image-md-post --
    375 #	Fixup the CD-image to be bootable.
    376 #	Overridden by etc.$MACHINE/Makefile.inc
    377 #
    378 iso-image-md-post: check_DESTDIR check_RELEASEDIR .WAIT iso-image-mi
    379 #	(empty -- look in the machine-dependent Makefile.inc)
    380 
    381 
    382 # snap_pre --
    383 #	Create ${RELEASEDIR} and necessary subdirectories.
    384 #
    385 snap_pre: check_DESTDIR check_RELEASEDIR
    386 	${INSTALL} -d -m 755 ${RELEASEDIR}
    387 .if ${MKUPDATE} == "no"
    388 # Could be a mount point, ignore the errors
    389 	-/bin/rm -rf ${RELEASEDIR}/${MACHINE}
    390 .endif
    391 	${INSTALL} -d -m 755 ${RELEASEDIR}/${MACHINE}
    392 .for dir in ${INSTALLATION_DIRS}
    393 	${INSTALL} -d -m 755 ${RELEASEDIR}/${MACHINE}/${dir}
    394 .endfor
    395 
    396 # snap_post --
    397 #	Build the install media and notes from distrib
    398 #
    399 snap_post: check_DESTDIR check_RELEASEDIR
    400 .if ${MKUPDATE} == "no"
    401 	cd ${NETBSDSRCDIR}/distrib && ${MAKE} cleandir
    402 .endif
    403 	cd ${NETBSDSRCDIR}/distrib && ${MAKE} depend && ${MAKE} && \
    404 	    ${MAKE} release
    405 
    406 # snap_kern --
    407 #	This target builds the kernels specified by each port.
    408 #	A port may specify the following kernels:
    409 #
    410 #	KERNEL_SETS		The list of kernels that will be
    411 #				packaged into sets, named
    412 #				kern-${kernel}.tgz.  These kernels
    413 #				are also placed in the binary/kernel
    414 #				area of the release package as
    415 #				netbsd-${kernel}.gz.
    416 #
    417 #	EXTRA_KERNELS		Additional kernels to place in the
    418 #				binary/kernel area of the release
    419 #				package as netbsd-${kernel}.gz, but
    420 #				which are not placed into sets. This
    421 #				allows a port to provide e.g. a netbootable
    422 #				installation kernel containing a ramdisk.
    423 #
    424 #	BUILD_KERNELS		Additional kernels to build which are
    425 #				not placed into sets nor into the
    426 #				binary/kernel area of the release
    427 #				package.  These are typically kernels
    428 #				that are built for inclusion only in
    429 #				installation disk/CD-ROM/tape images.
    430 #
    431 #	A port may also specify KERNEL_SUFFIXES, which is an optional list
    432 #	of filename suffixes for kernels to include in the kernel sets and
    433 #	in the binary/kernel area of the release package (e.g. "netbsd" vs.
    434 #	"netbsd.ecoff" and "netbsd.srec").  It is not an error if kernels
    435 #	with these suffixes do not exist in the kernel build directory.
    436 #
    437 #
    438 # A list of all the kernels to build, which can be overridden from
    439 # external sources (such as make(1)'s environment or command line)
    440 #
    441 ALL_KERNELS?=	${KERNEL_SETS} ${EXTRA_KERNELS} ${BUILD_KERNELS}
    442 
    443 GETKERNELAWK=	awk '/^config/ {print $$2; found=1} \
    444 		END{ if (found == 0) print "netbsd"; }'
    445 
    446 .if !target(snap_kern)						# {
    447 
    448 # build_kernels --
    449 #	Configure & compile kernels listed in ${ALL_KERNELS}
    450 #
    451 .if !defined(KERNELS_DONE)						# {
    452 .for configfile in ${ALL_KERNELS}					# {
    453 _KERNELS_TO_BUILD+=kern-${configfile}
    454 kern-${configfile}:
    455 	cd ${KERNCONFDIR} && ${TOOL_CONFIG} -s ${KERNSRCDIR} \
    456 	    -b ${KERNOBJDIR}/${configfile:C/.*\///} ${configfile}
    457 .if ${MKUPDATE} == "no"
    458 	cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} distclean
    459 .endif
    460 	cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} depend && ${MAKE}
    461 .endfor	# ALL_KERNELS							# }
    462 .endif	# KERNELS_DONE							# }
    463 
    464 build_kernels: ${_KERNELS_TO_BUILD}
    465 
    466 # build_kernelsets --
    467 #	Create kernel sets from ${KERNEL_SETS} into
    468 #	${RELEASEDIR}/${MACHINE}/binary/sets
    469 #
    470 .for configfile in ${KERNEL_SETS}					# {
    471 _KERNELSETS_TO_BUILD+=kernset-${configfile}
    472 kernset-${configfile}:
    473 	@ kernlist=`${GETKERNELAWK} ${KERNCONFDIR}/${configfile}`; \
    474 	kerndir=${KERNOBJDIR}/${configfile:C/.*\///}; \
    475 	kernsuffixes="${KERNEL_SUFFIXES:S/^/./}"; \
    476 	kern_tgz=${RELEASEDIR}/${MACHINE}/binary/sets/kern-${configfile}.tgz; \
    477 	pax_cmd="GZIP=-9 ${TOOL_PAX} -O -zw -M -N ${NETBSDSRCDIR}/etc -f $${kern_tgz}"; \
    478 	cd $${kerndir} && { \
    479 		kernels=; newest=; \
    480 		for kernel in $${kernlist}; do \
    481 			for s in "" $${kernsuffixes}; do \
    482 				ks="$${kernel}$${s}"; \
    483 				[ -f $${ks} ] || continue; \
    484 				kernels="$${kernels} $${ks}"; \
    485 				[ -z "$${newest}" -o $${ks} -nt "$${newest}" ] && \
    486 					newest=$${ks}; \
    487 			done; \
    488 		done; \
    489 		[ $${kern_tgz} -nt "$${newest}" ] || { \
    490 			echo "echo $${kernels} | $${pax_cmd}"; \
    491 			( echo "/set uname=${BINOWN} gname=${BINGRP}"; \
    492 			echo ". type=dir optional"; \
    493 			for kernel in $${kernels}; do \
    494 				echo "./$${kernel} type=file"; \
    495 			done ) | eval $${pax_cmd}; \
    496 		} \
    497 	}
    498 .endfor	# KERNEL_SETS							# }
    499 
    500 build_kernelsets: ${_KERNELSETS_TO_BUILD}
    501 
    502 # build_releasekernels --
    503 #	Build kernel.gz from ${KERNEL_SETS} ${EXTRA_KERNELS} into
    504 #	${RELEASEDIR}/${MACHINE}/binary/kernel
    505 #
    506 .for configfile in ${KERNEL_SETS} ${EXTRA_KERNELS}			# {
    507 _RELEASEKERNELS_TO_BUILD+=releasekern-${configfile}
    508 releasekern-${configfile}:
    509 	@ kernlist=`${GETKERNELAWK} ${KERNCONFDIR}/${configfile:C/.*\///}`; \
    510 	kerndir=${KERNOBJDIR}/${configfile:C/.*\///}; \
    511 	kernsuffixes="${KERNEL_SUFFIXES:S/^/./}"; \
    512 	cd $${kerndir} && {	\
    513 		for kernel in $${kernlist}; do \
    514 			for s in "" $${kernsuffixes}; do \
    515 				ks="$${kernel}$${s}"; \
    516 				[ ! -f $${ks} ] && continue; \
    517 				knl_gz="${RELEASEDIR}/${MACHINE}/binary/kernel/$${ks}-${configfile:C/.*\///}.gz"; \
    518 				[ $${knl_gz} -nt $${ks} ] && continue; \
    519 				echo "gzip -c -9 < $${kerndir}/$${ks} > $${knl_gz}"; \
    520 				gzip -c -9 < $${ks} > $${knl_gz}; \
    521 			done; \
    522 		done; \
    523 	}
    524 .endfor	# KERNEL_SETS EXTRA_KERNELS					# }
    525 
    526 build_releasekernels: ${_RELEASEKERNELS_TO_BUILD}
    527 
    528 # snap_kern --
    529 #	build the kernels, then the sets & release kernels
    530 #
    531 snap_kern: check_DESTDIR check_RELEASEDIR .WAIT \
    532 	    build_kernels .WAIT \
    533 	    build_kernelsets build_releasekernels
    534 
    535 .endif # !target(snap_kern)					# }
    536 
    537 
    538 # snap_md_post --
    539 #	Machine dependent distribution media operations.
    540 #	Overridden by etc.$MACHINE/Makefile.inc
    541 #
    542 snap_md_post: check_DESTDIR check_RELEASEDIR
    543 #	(empty -- look in the machine-dependent Makefile.inc)
    544 
    545 
    546 clean:
    547 	-rm -rf ${CDROM.dir} ${CDROM.pathlist} ${OBSOLETE.dir}
    548 
    549 .include <bsd.prog.mk>
    550