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