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