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