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