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