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