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