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