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