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