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