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