Home | History | Annotate | Line # | Download | only in etc
Makefile revision 1.306.2.9
      1 #	$NetBSD: Makefile,v 1.306.2.9 2006/08/06 11:50:27 tron 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 #   MKCRYPTO; if not `no', install crypto-related configuration
     19 #   MKPOSTFIX; if not `no', install postfix configuration
     20 #   MKSENDMAIL; if not `no', install sendmail configuration
     21 #   MKUNPRIVED; if not `no', allow non-root installs.
     22 #   MKUPDATE; if not `no', don't do a 'make clean' before kernel compile
     23 #
     24 # Targets:
     25 #    distribution: makes a full NetBSD distribution in DESTDIR. If
     26 #	INSTALL_DONE is set, it will not do a `make install.'
     27 #	if DISTRIBUTION_DONE is set, it will not do anything.
     28 #    distrib-dirs: creates an empty NetBSD directory tree in DESTDIR.
     29 #	Called by distribution.
     30 #    snapshot: calls distribution, above, and then tars up the files
     31 #	into a release(7) format in RELEASEDIR/${RELEASEMACHINEDIR}.
     32 #	Any port-dependent stuff for this target is found in
     33 #	etc.${MACHINE}/Makefile.inc.
     34 #    release: a synonym for `snapshot'
     35 #
     36 
     37 # For MK* vars
     38 .include <bsd.own.mk>
     39 
     40 .include <bsd.sys.mk>		# for HOST_SH
     41 .include <bsd.kernobj.mk>	# For KERNSRCDIR, KERNOBJDIR, ...
     42 .include <bsd.endian.mk>	# For TARGET_ENDIANNESS
     43 
     44 
     45 .MAKEOVERRIDES+=	USETOOLS
     46 
     47 TZDIR=		/usr/share/zoneinfo
     48 LOCALTIME?=	UTC
     49 CKSUM?=		${TOOL_CKSUM}
     50 MAKESUMS=	CKSUM=${CKSUM:Q} ${HOST_SH} ${NETBSDSRCDIR}/distrib/sets/makesums
     51 DISTRIBVER!=	${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh
     52 
     53 # Flags for creating ISO CDROM image
     54 # mkisofs is expected to be in $PATH, install via pkgsrc/sysutils/cdrecord
     55 # Note: At least mkisofs 2.0 should be used.
     56 #
     57 MKISOFS?=	mkisofs
     58 DISTRIBREV!=	${HOST_SH} ${KERNSRCDIR}/conf/osrelease.sh -s
     59 # ISO 9660 volume ID.  Note that this can only contain [A-Z0-9_].
     60 ISO_VOLID!=	echo NETBSD_${DISTRIBREV} | tr a-z A-Z
     61 MKISOFS_FLAGS+= -J -l -hide-joliet-trans-tbl -r -T \
     62 		-V ${ISO_VOLID} \
     63 		-P "The NetBSD Project" \
     64 		-m "${RELEASEDIR}/${RELEASEMACHINEDIR}/installation/cdrom"
     65 .if ${MKISOFS_FLAGS:N-v}
     66 MKISOFS_FLAGS+=	-quiet
     67 .endif
     68  
     69 
     70 # MD Makefile.inc may append MD targets to BIN[123].  Make sure all
     71 # are empty, to preserve the old semantics of setting them below with "=".
     72 #
     73 BIN1=
     74 BIN2=
     75 BIN3=
     76 
     77 # Directories to build in ${RELEASEDIR}/${RELEASEMACHINEDIR}.
     78 # MD Makefile.inc files can add to this.
     79 # NOTE: Parent directories must be listed before subdirectories.
     80 #
     81 INSTALLATION_DIRS=	binary binary/sets binary/kernel installation
     82 
     83 .if exists(etc.${RELEASEMACHINE}/Makefile.inc)
     84 .include "etc.${RELEASEMACHINE}/Makefile.inc"
     85 .endif
     86 
     87 # -rw-r--r--
     88 BINOWN= root
     89 BINGRP= wheel
     90 UTMPGRP= utmp
     91 BIN1+=	bootptab changelist csh.cshrc csh.login csh.logout daily \
     92 	daily.conf dm.conf floppytab ftpchroot ftpusers \
     93 	gettytab group hosts hosts.lpd inetd.conf lkm.conf locate.conf \
     94 	mailer.conf man.conf monthly monthly.conf mrouted.conf named.conf \
     95 	netconfig networks newsyslog.conf nsswitch.conf ntp.conf \
     96 	passwd.conf phones printcap profile protocols \
     97 	rbootd.conf rc rc.conf rc.lkm rc.local rc.subr rc.shutdown remote rpc \
     98 	security security.conf services shells sysctl.conf syslog.conf \
     99 	weekly weekly.conf wscons.conf
    100 
    101 # Use machine-specific disktab if it exists, or the MI one otherwise
    102 .if exists(etc.${MACHINE}/disktab)
    103 BIN1+=	etc.${MACHINE}/disktab
    104 .else
    105 BIN1+=	disktab
    106 .endif
    107 
    108 .if exists(etc.${MACHINE}/ld.so.conf)
    109 BIN1+=	etc.${MACHINE}/ld.so.conf
    110 .endif
    111 
    112 .if exists(etc.${MACHINE}/ttyaction)
    113 BIN1+=	etc.${MACHINE}/ttyaction
    114 .endif
    115 
    116 # -rw-rw-r--
    117 .if !empty(DISTRIBVER:M*.99.*)
    118 BIN2+=	motd.current
    119 FILESNAME_motd.current=	motd
    120 .elif !empty(DISTRIBVER:M*BETA*)
    121 BIN2+=	motd.beta
    122 FILESNAME_motd.beta=	motd
    123 .elif !empty(DISTRIBVER:M*RC*)
    124 BIN2+=	motd.rc
    125 FILESNAME_motd.rc=	motd
    126 .else
    127 BIN2+=	motd
    128 .endif
    129 
    130 # -rw-------
    131 BIN3+=	hosts.equiv
    132 
    133 SYSPKG=	etc
    134 ETC_PKG=-T etc_pkg
    135 BASE_PKG=-T base_pkg
    136 ETC_INSTALL_FILE=cd ${.CURDIR} && ${INSTALL_FILE} ${ETC_PKG}
    137 ETC_INSTALL_OBJ_FILE=cd ${.OBJDIR} && ${INSTALL_FILE} ${ETC_PKG}
    138 
    139 .if ${TARGET_ENDIANNESS} == "1234"
    140 PWD_MKDB_ENDIAN=	-L
    141 .elif ${TARGET_ENDIANNESS} == "4321"
    142 PWD_MKDB_ENDIAN=	-B
    143 .else
    144 PWD_MKDB_ENDIAN=
    145 .endif
    146 
    147 
    148 # distribution --
    149 #	Build a distribution
    150 #
    151 distribution: .PHONY check_DESTDIR .WAIT distrib-dirs
    152 .if !defined(DISTRIBUTION_DONE)
    153 .if !defined(INSTALL_DONE)
    154 	${MAKEDIRTARGET} ${NETBSDSRCDIR} include _DISTRIB=
    155 	${MAKEDIRTARGET} ${NETBSDSRCDIR} install _DISTRIB=
    156 .endif	# !INSTALL_DONE
    157 	${MAKEDIRTARGET} . install-etc-files
    158 .if ${MKX11} != "no"
    159 	${MAKEDIRTARGET} ${NETBSDSRCDIR}/x11 distribution
    160 .endif
    161 	${MAKEDIRTARGET} ${NETBSDSRCDIR}/distrib/sets makesetfiles
    162 .endif	# !DISTRIBUTION_DONE
    163 
    164 
    165 CLEANFILES+=	MAKEDEV
    166 MAKEDEV: .EXEC
    167 	${_MKTARGET_CREATE}
    168 	MACHINE=${MACHINE:Q} MACHINE_ARCH=${MACHINE_ARCH:Q} \
    169 	    NETBSDSRCDIR=${NETBSDSRCDIR:Q} \
    170 	    awk -f ${.CURDIR}/MAKEDEV.awk ${.CURDIR}/MAKEDEV.tmpl > ${.TARGET}
    171 
    172 RELEASEVARS=	BSDOBJDIR BSDSRCDIR BUILDID \
    173 		DESTDIR EXTERNAL_TOOLCHAIN \
    174 		INSTALLWORLDDIR \
    175 		KERNARCHDIR KERNCONFDIR KERNOBJDIR KERNSRCDIR \
    176 		MACHINE MACHINE_ARCH MAKE MAKECONF MAKEFLAGS \
    177 		MAKEOBJDIR MAKEOBJDIRPREFIX MAKEVERBOSE \
    178 		MKBFD MKCATPAGES \
    179 		MKCRYPTO MKCRYPTO_IDEA MKCRYPTO_MDC2 MKCRYPTO_RC5 MKCVS \
    180 		MKDOC MKDYNAMICROOT MKGCC MKGCCCMDS MKGDB \
    181 		MKHESIOD MKHOSTOBJ MKHTML MKIEEEFP MKINET6 MKINFO MKIPFILTER \
    182 		MKKERBEROS4 MKKERBEROS MKLINKLIB MKLINT \
    183 		MKMAN MKMANZ MKNLS MKOBJ MKOBJDIRS \
    184 		MKPAM MKPF MKPIC MKPICINSTALL MKPICLIB MKPOSTFIX MKPROFILE \
    185 		MKSENDMAIL MKSHARE MKSKEY MKSOFTFLOAT MKSTATICLIB \
    186 		MKUNPRIVED MKUPDATE MKUUCP MKX11 MKYP \
    187 		NBUILDJOBS NETBSDSRCDIR \
    188 		NOCLEANDIR NODISTRIBDIRS NOINCLUDES \
    189 		OBJMACHINE \
    190 		RELEASEDIR TOOLCHAIN_MISSING TOOLDIR \
    191 		USETOOLS USR_OBJMACHINE \
    192 		X11SRCDIR
    193 
    194 params: .PHONY
    195 .for var in ${RELEASEVARS}
    196 .if defined(${var})
    197 	@printf "%20s = '%-s'\n" ${var} ${${var}:Q}
    198 .else
    199 	@printf "%20s = (undefined)\n" ${var}
    200 .endif
    201 .endfor
    202 
    203 CLEANFILES+=	etc-release
    204 etc-release: .EXEC
    205 	${_MKTARGET_CREATE}
    206 	@(	echo "NetBSD ${DISTRIBVER}/${MACHINE}"; \
    207 		echo ; \
    208 		cat ${NETBSDSRCDIR}/sys/conf/copyright; \
    209 		echo ; \
    210 		echo "Build settings:"; \
    211 		printf "%20s   %s\n"  "Build date" "$$(date -u)"; \
    212 		printf "%20s   %s\n"  "Built by" "$${USER-root}@$$(hostname)"; \
    213 		echo ; \
    214 		(cd ${.CURDIR}; ${MAKE} ${MFLAGS} -j1 params); \
    215 	) >${.OBJDIR}/${.TARGET}
    216 
    217 install-etc-release: .PHONY etc-release
    218 	${_MKMSG_INSTALL} etc/release
    219 	${ETC_INSTALL_OBJ_FILE} -o ${BINOWN} -g ${BINGRP} -m 444 \
    220 	    etc-release ${DESTDIR}/etc/release
    221 
    222 
    223 FILESDIR=		/etc
    224 CONFIGFILES=
    225 CONFIGSYMLINKS=
    226 
    227 .for file in ${BIN1}
    228 CONFIGFILES+=		${file}
    229 FILESMODE_${file:T}=	644
    230 .endfor
    231 
    232 .for file in ${BIN2}
    233 CONFIGFILES+=		${file}
    234 FILESMODE_${file:T}=	664
    235 .endfor
    236 
    237 .for file in ${BIN3}
    238 CONFIGFILES+=		${file}
    239 FILESMODE_${file:T}=	600
    240 .endfor
    241 
    242 CONFIGFILES+=		aliases
    243 FILESDIR_aliases=	/etc/mail
    244 FILESMODE_aliases=	644
    245 
    246 CONFIGFILES+=		MAKEDEV.local
    247 FILESDIR_MAKEDEV.local=	/dev
    248 FILESMODE_MAKEDEV.local=${BINMODE}
    249 
    250 CONFIGFILES+=		crontab
    251 FILESDIR_crontab=	/var/cron/tabs
    252 FILESNAME_crontab=	root
    253 FILESMODE_crontab=	600
    254 
    255 CONFIGFILES+=		minfree
    256 FILESDIR_minfree=	/var/crash
    257 FILESMODE_minfree=	600
    258 
    259 CONFIGSYMLINKS+=	${TZDIR}/${LOCALTIME}	/etc/localtime \
    260 			/usr/sbin/rmt		/etc/rmt
    261 
    262 
    263 # install-etc-files --
    264 #	Install etc (config) files; not performed by "make build"
    265 #
    266 install-etc-files: .PHONY check_DESTDIR MAKEDEV
    267 	${_MKMSG_INSTALL} ${DESTDIR}/etc/master.passwd
    268 	${ETC_INSTALL_FILE} -o root -g wheel -m 600 \
    269 	    master.passwd ${DESTDIR}/etc
    270 	${TOOL_PWD_MKDB} -p ${PWD_MKDB_ENDIAN} -d ${DESTDIR}/ \
    271 	    ${DESTDIR}/etc/master.passwd
    272 .if ${MKUNPRIVED} != "no"
    273 	( \
    274 		for metaent in passwd pwd.db spwd.db; do \
    275 	    		echo "./etc/$${metaent} type=file mode=0644 uname=root gname=wheel tags=etc_pkg"; \
    276 		done; \
    277 	) | ${METALOG.add}
    278 .endif	# MKUNPRIVED != no
    279 	${_MKMSG_INSTALL} ${DESTDIR}/etc/ttys
    280 	${ETC_INSTALL_OBJ_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
    281 	    ${.CURDIR}/etc.${MACHINE}/ttys ${DESTDIR}/etc
    282 	${_MKMSG_INSTALL} ${DESTDIR}/dev/MAKEDEV
    283 	${ETC_INSTALL_OBJ_FILE} -o ${BINOWN} -g ${BINGRP} -m 555 \
    284 	    MAKEDEV ${DESTDIR}/dev
    285 .for owner group mode file in \
    286 		${BINOWN} operator	664	/etc/dumpdates  \
    287 		${BINOWN} ${BINGRP}	644	/etc/mail/local-host-names \
    288 		${BINOWN} operator	600	/etc/skeykeys \
    289 		root wheel		600	/var/at/at.deny \
    290 		nobody ${BINGRP}	664	/var/db/locate.database \
    291 		uucp dialer		640	/var/log/aculog \
    292 		${BINOWN} ${BINGRP}	600	/var/log/authlog \
    293 		root wheel		600	/var/log/cron \
    294 		${BINOWN} ${UTMPGRP}	664	/var/log/lastlog \
    295 		${BINOWN} ${UTMPGRP}	664	/var/log/lastlogx \
    296 		${BINOWN} ${BINGRP}	640	/var/log/lpd-errs \
    297 		${BINOWN} ${BINGRP}	600	/var/log/maillog \
    298 		${BINOWN} ${BINGRP}	644	/var/log/messages \
    299 		${BINOWN} ${BINGRP}	600	/var/log/secure \
    300 		${BINOWN} ${BINGRP}	644	/var/log/sendmail.st \
    301 		${BINOWN} ${UTMPGRP}	664	/var/log/wtmp \
    302 		${BINOWN} ${UTMPGRP}	664	/var/log/wtmpx \
    303 		${BINOWN} ${BINGRP}	600	/var/log/xferlog \
    304 		daemon staff		664	/var/msgs/bounds \
    305 		${BINOWN} ${UTMPGRP}	664	/var/run/utmp \
    306 		${BINOWN} ${UTMPGRP}	664	/var/run/utmpx \
    307 		games games		664	/var/games/atc_score \
    308 		games games		664	/var/games/battlestar.log \
    309 		games games		664	/var/games/cfscores \
    310 		games games		664	/var/games/criblog \
    311 		games games		660	/var/games/hackdir/perm \
    312 		games games		660	/var/games/hackdir/record \
    313 		games games		664	/var/games/larn/llog12.0 \
    314 		games games		664	/var/games/larn/lscore12.0 \
    315 		games games		664	/var/games/larn/playerids \
    316 		games games		664	/var/games/robots_roll \
    317 		games games		664	/var/games/rogue.scores \
    318 		games games		664	/var/games/saillog \
    319 		games games		664	/var/games/snakerawscores \
    320 		games games		664	/var/games/snake.log \
    321 		games games		664	/var/games/tetris.scores
    322 	${_MKMSG_INSTALL} ${DESTDIR}${file}
    323 	${ETC_INSTALL_FILE} -o ${owner} -g ${group} -m ${mode} \
    324 	    	/dev/null ${DESTDIR}${file}
    325 .endfor
    326 .for subdir in . defaults mtree namedb pam.d powerd rc.d root skel ssh
    327 	${MAKEDIRTARGET} ${subdir} configinstall
    328 .endfor
    329 	${MAKEDIRTARGET} ${NETBSDSRCDIR}/usr.bin/mail configinstall
    330 .if (${MKPF} != "no")
    331 	${MAKEDIRTARGET} ${NETBSDSRCDIR}/usr.sbin/pf configinstall
    332 .endif
    333 .if (${MKCRYPTO} != "no")
    334 	${MAKEDIRTARGET} ${NETBSDSRCDIR}/usr.bin/ssh configinstall
    335 .endif
    336 .if (${MKPOSTFIX} != "no")
    337 	${MAKEDIRTARGET} ${NETBSDSRCDIR}/gnu/usr.sbin/postfix configinstall
    338 .endif
    339 .if (${MKSENDMAIL} != "no")
    340 	${MAKEDIRTARGET} ${NETBSDSRCDIR}/gnu/usr.sbin/sendmail/cf/cf configinstall
    341 .endif
    342 
    343 
    344 # install-obsolete-lists --
    345 #	Install var/db/obsolete set lists; this is performed by "make build"
    346 #
    347 OBSOLETE.dir=		${.OBJDIR}/obsolete.dir
    348 OBSOLETE.files=		base comp etc games man misc text
    349 .if ${MKX11} != "no"
    350 OBSOLETE.files+=	xbase xcomp xetc xfont xserver
    351 .endif
    352 
    353 install-obsolete-lists: .PHONY
    354 	mkdir -p ${OBSOLETE.dir}
    355 .if ${MKX11} != "no"
    356 	(cd ${NETBSDSRCDIR}/distrib/sets && \
    357 	    MAKE=${MAKE:Q} ${HOST_SH} ./makeobsolete -b -t ${OBSOLETE.dir})
    358 .else
    359 	(cd ${NETBSDSRCDIR}/distrib/sets && \
    360 	    MAKE=${MAKE:Q} ${HOST_SH} ./makeobsolete -t ${OBSOLETE.dir})
    361 .endif
    362 .for file in ${OBSOLETE.files}
    363 	${_MKMSG_INSTALL} ${DESTDIR}/var/db/obsolete/${file}
    364 	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
    365 	    ${OBSOLETE.dir}/${file} ${DESTDIR}/var/db/obsolete
    366 .endfor
    367 
    368 
    369 # distrib-dirs --
    370 #	Populate $DESTDIR with directories needed by NetBSD
    371 #
    372 .if ${MKUNPRIVED} == "no"
    373 TOOL_MTREE.unpriv=
    374 .else
    375 TOOL_MTREE.unpriv=	-W
    376 .endif
    377 
    378 distrib-dirs: .PHONY check_DESTDIR
    379 .if !defined(DISTRIBUTION_DONE)
    380 	${INSTALL_DIR} -o root -g wheel -m 755 ${BASE_PKG} ${DESTDIR}
    381 .endif
    382 	${TOOL_MTREE} -def ${.CURDIR}/mtree/NetBSD.dist -N ${.CURDIR} \
    383 	    -p ${DESTDIR}/ -U ${TOOL_MTREE.unpriv}
    384 
    385 
    386 # release, snapshot --
    387 #	Build a full distribution including kernels & install media.
    388 #
    389 release snapshot: .PHONY check_DESTDIR check_RELEASEDIR .WAIT \
    390 		    distribution .WAIT \
    391 		    snap_pre .WAIT snap_kern .WAIT \
    392 		    snap_post .WAIT snap_md_post
    393 	${MAKEDIRTARGET} ${NETBSDSRCDIR}/distrib/sets sets
    394 	${MAKESUMS} -t ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/kernel '*.gz'
    395 
    396 
    397 # iso-image --
    398 #	Standalone target to create a CDROM image after the release
    399 #	was composed.  Should be run after "make release" in src and xsrc.
    400 #
    401 #	Note: At least mkisofs 2.0 should be used.
    402 #
    403 CDROM_NAME_ADD?=
    404 CDROM.image=${RELEASEDIR}/${RELEASEMACHINEDIR}/installation/cdrom/netbsd-${MACHINE}${CDROM_NAME_ADD}.iso
    405 CDROM.dir=	cdrom.dir
    406 CDROM.pathlist=	cdrom.pathlist
    407 
    408 iso-image: .PHONY check_DESTDIR check_RELEASEDIR .WAIT iso-image-md-post
    409 	${MAKESUMS} -t ${RELEASEDIR}/${RELEASEMACHINEDIR}/installation/cdrom '*.iso'
    410 	@echo "iso-image created as: ${CDROM.image}"
    411 
    412 iso-image-setup: .PHONY check_RELEASEDIR
    413 	rm -f ${CDROM.pathlist}
    414 .for extra in README SOURCE_DATE source
    415 .if exists(${RELEASEDIR}/${extra})
    416 	echo "${extra}=${RELEASEDIR}/${extra}" >> ${CDROM.pathlist}
    417 .endif
    418 .endfor
    419 	echo "${MACHINE}=${RELEASEDIR}/${RELEASEMACHINEDIR}" >> ${CDROM.pathlist}
    420 	mkdir -p ${CDROM.dir}
    421 	mkdir -p ${RELEASEDIR}/${RELEASEMACHINEDIR}/installation/cdrom
    422 
    423 # iso-image-mi --
    424 #	Create the image after the MD operations have completed.
    425 #
    426 iso-image-mi: .PHONY check_DESTDIR check_RELEASEDIR .WAIT \
    427 		iso-image-setup .WAIT iso-image-md-pre
    428 	@if ! ${MKISOFS} --version; then \
    429 		echo "install pkgsrc/sysutils/cdrecord and run 'make iso-image'." ; \
    430 		false; \
    431 	fi
    432 	${MKISOFS} ${MKISOFS_FLAGS} -graft-points -path-list ${CDROM.pathlist} \
    433 	    -o ${CDROM.image} ${CDROM.dir}
    434 
    435 # iso-image-md-pre --
    436 #	Setup ${CDROM.dir} to produce a bootable CD image.
    437 #	Overridden by etc.$MACHINE/Makefile.inc
    438 #
    439 iso-image-md-pre: .PHONY check_DESTDIR check_RELEASEDIR
    440 #	(empty -- look in the machine-dependent Makefile.inc)
    441 
    442 # iso-image-md-post --
    443 #	Fixup the CD-image to be bootable.
    444 #	Overridden by etc.$MACHINE/Makefile.inc
    445 #
    446 iso-image-md-post: .PHONY check_DESTDIR check_RELEASEDIR .WAIT iso-image-mi
    447 #	(empty -- look in the machine-dependent Makefile.inc)
    448 
    449 
    450 # snap_pre --
    451 #	Create ${RELEASEDIR} and necessary subdirectories.
    452 #
    453 snap_pre: .PHONY check_DESTDIR check_RELEASEDIR
    454 	${INSTALL} -d -m 755 ${RELEASEDIR}
    455 .if ${MKUPDATE} == "no"
    456 # Could be a mount point, ignore the errors
    457 	-/bin/rm -rf ${RELEASEDIR}/${RELEASEMACHINEDIR}
    458 .endif
    459 	${INSTALL} -d -m 755 ${RELEASEDIR}/${RELEASEMACHINEDIR}
    460 .for dir in ${INSTALLATION_DIRS}
    461 	${INSTALL} -d -m 755 ${RELEASEDIR}/${RELEASEMACHINEDIR}/${dir}
    462 .endfor
    463 
    464 # snap_post --
    465 #	Build the install media and notes from distrib
    466 #
    467 snap_post: .PHONY check_DESTDIR check_RELEASEDIR
    468 .if ${MKUPDATE} == "no"
    469 	cd ${NETBSDSRCDIR}/distrib && ${MAKE} cleandir
    470 .endif
    471 	cd ${NETBSDSRCDIR}/distrib && ${MAKE} depend && ${MAKE} && \
    472 	    ${MAKE} release
    473 
    474 # snap_kern --
    475 #	This target builds the kernels specified by each port.
    476 #	A port may specify the following kernels:
    477 #
    478 #	KERNEL_SETS		The list of kernels that will be
    479 #				packaged into sets, named
    480 #				kern-${kernel}.tgz.  These kernels
    481 #				are also placed in the binary/kernel
    482 #				area of the release package as
    483 #				netbsd-${kernel}.gz.
    484 #
    485 #	EXTRA_KERNELS		Additional kernels to place in the
    486 #				binary/kernel area of the release
    487 #				package as netbsd-${kernel}.gz, but
    488 #				which are not placed into sets. This
    489 #				allows a port to provide e.g. a netbootable
    490 #				installation kernel containing a ramdisk.
    491 #
    492 #	BUILD_KERNELS		Additional kernels to build which are
    493 #				not placed into sets nor into the
    494 #				binary/kernel area of the release
    495 #				package.  These are typically kernels
    496 #				that are built for inclusion only in
    497 #				installation disk/CD-ROM/tape images.
    498 #
    499 #	A port may also specify KERNEL_SUFFIXES, which is an optional list
    500 #	of filename suffixes for kernels to include in the kernel sets and
    501 #	in the binary/kernel area of the release package (e.g. "netbsd" vs.
    502 #	"netbsd.ecoff" and "netbsd.srec").  It is not an error if kernels
    503 #	with these suffixes do not exist in the kernel build directory.
    504 #
    505 #
    506 # A list of all the kernels to build, which can be overridden from
    507 # external sources (such as make(1)'s environment or command line)
    508 #
    509 ALL_KERNELS?=	${KERNEL_SETS} ${EXTRA_KERNELS} ${BUILD_KERNELS}
    510 
    511 GETKERNELAWK=	awk '/^config/ {print $$2; found=1} \
    512 		END{ if (found == 0) print "netbsd"; }'
    513 
    514 .if !target(snap_kern)						# {
    515 
    516 # build_kernels --
    517 #	Configure & compile kernels listed in ${ALL_KERNELS}
    518 #
    519 # The 'sync' is so that all writes during the build are pushed back
    520 # to the disk.  Not having it causes problems on some host systems
    521 # (e.g. Linux) when building on NFS.
    522 #
    523 .if !defined(KERNELS_DONE)						# {
    524 .for configfile in ${ALL_KERNELS}					# {
    525 _KERNELS_TO_BUILD+=kern-${configfile}
    526 kern-${configfile}: .PHONY
    527 	cd ${KERNCONFDIR} && ${TOOL_CONFIG} -s ${KERNSRCDIR} \
    528 	    -b ${KERNOBJDIR}/${configfile:C/.*\///} ${configfile}
    529 .if ${MKUPDATE} == "no"
    530 	cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} distclean
    531 .endif
    532 	cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} depend && ${MAKE}
    533 	sync
    534 .endfor	# ALL_KERNELS							# }
    535 .endif	# KERNELS_DONE							# }
    536 
    537 build_kernels: .PHONY ${_KERNELS_TO_BUILD}
    538 
    539 # build_kernelsets --
    540 #	Create kernel sets from ${KERNEL_SETS} into
    541 #	${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets
    542 #
    543 .for configfile in ${KERNEL_SETS}					# {
    544 _KERNELSETS_TO_BUILD+=kernset-${configfile}
    545 kernset-${configfile}: .PHONY
    546 	@ kernlist=`${GETKERNELAWK} ${KERNCONFDIR}/${configfile}`; \
    547 	kerndir=${KERNOBJDIR}/${configfile:C/.*\///}; \
    548 	kernsuffixes="${KERNEL_SUFFIXES:S/^/./}"; \
    549 	kern_tgz=${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets/kern-${configfile}.tgz; \
    550 	pax_cmd="GZIP=-9 ${TOOL_PAX} -O -zw -M -N ${NETBSDSRCDIR}/etc -f $${kern_tgz}"; \
    551 	cd $${kerndir} && { \
    552 		kernels=; newest=; \
    553 		for kernel in $${kernlist}; do \
    554 			for s in "" $${kernsuffixes}; do \
    555 				ks="$${kernel}$${s}"; \
    556 				[ -f $${ks} ] || continue; \
    557 				kernels="$${kernels} $${ks}"; \
    558 				[ -z "$${newest}" -o $${ks} -nt "$${newest}" ] && \
    559 					newest=$${ks}; \
    560 			done; \
    561 		done; \
    562 		[ $${kern_tgz} -nt "$${newest}" ] || { \
    563 			echo "echo $${kernels} | $${pax_cmd}"; \
    564 			( echo "/set uname=${BINOWN} gname=${BINGRP}"; \
    565 			echo ". type=dir optional"; \
    566 			for kernel in $${kernels}; do \
    567 				echo "./$${kernel} type=file"; \
    568 			done ) | eval $${pax_cmd}; \
    569 		} \
    570 	}
    571 .endfor	# KERNEL_SETS							# }
    572 
    573 build_kernelsets: ${_KERNELSETS_TO_BUILD}
    574 
    575 # build_releasekernels --
    576 #	Build kernel.gz from ${KERNEL_SETS} ${EXTRA_KERNELS} into
    577 #	${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/kernel
    578 #
    579 .for configfile in ${KERNEL_SETS} ${EXTRA_KERNELS}			# {
    580 _RELEASEKERNELS_TO_BUILD+=releasekern-${configfile}
    581 releasekern-${configfile}: .PHONY
    582 	@ kernlist=`${GETKERNELAWK} ${KERNCONFDIR}/${configfile:C/.*\///}`; \
    583 	kerndir=${KERNOBJDIR}/${configfile:C/.*\///}; \
    584 	kernsuffixes="${KERNEL_SUFFIXES:S/^/./}"; \
    585 	cd $${kerndir} && {	\
    586 		for kernel in $${kernlist}; do \
    587 			for s in "" $${kernsuffixes}; do \
    588 				ks="$${kernel}$${s}"; \
    589 				[ ! -f $${ks} ] && continue; \
    590 				knl_gz="${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/kernel/$${ks}-${configfile:C/.*\///}.gz"; \
    591 				[ $${knl_gz} -nt $${ks} ] && continue; \
    592 				echo "gzip -c -9 < $${kerndir}/$${ks} > $${knl_gz}"; \
    593 				gzip -c -9 < $${ks} > $${knl_gz}; \
    594 			done; \
    595 		done; \
    596 	}
    597 .endfor	# KERNEL_SETS EXTRA_KERNELS					# }
    598 
    599 build_releasekernels: ${_RELEASEKERNELS_TO_BUILD}
    600 
    601 # snap_kern --
    602 #	build the kernels, then the sets & release kernels
    603 #
    604 snap_kern: check_DESTDIR check_RELEASEDIR .WAIT \
    605 	    build_kernels .WAIT \
    606 	    build_kernelsets build_releasekernels
    607 
    608 .endif # !target(snap_kern)					# }
    609 
    610 
    611 # snap_md_post --
    612 #	Machine dependent distribution media operations.
    613 #	Overridden by etc.$MACHINE/Makefile.inc
    614 #
    615 snap_md_post: check_DESTDIR check_RELEASEDIR
    616 #	(empty -- look in the machine-dependent Makefile.inc)
    617 
    618 
    619 clean:
    620 	-rm -rf ${CDROM.dir} ${CDROM.pathlist} ${OBSOLETE.dir}
    621 
    622 .include <bsd.prog.mk>
    623 
    624 test:
    625 	@echo ${OBSOLETE.files}
    626