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