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