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