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