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