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