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