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