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