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