Makefile revision 1.304
11.304Slukem#	$NetBSD: Makefile,v 1.304 2005/02/23 02:10:33 lukem Exp $
21.66Smikel#	from: @(#)Makefile	8.7 (Berkeley) 5/25/95
31.1Scgd
41.96Scjs# Environment variables without default values:
51.96Scjs#   DESTDIR must be set before anything in this file will work.
61.96Scjs#   RELEASEDIR is where the tarred up stuff for a snapshot or
71.96Scjs#	release will be placed.
81.96Scjs#
91.96Scjs# Environment variables with default values:
101.96Scjs#   LOCALTIME will set the default local time for the system you
111.96Scjs#	build; it determines what /etc/localtime is symlink'd to.
121.96Scjs#   KERNSRCDIR points to kernel source; it is set by default to ../sys,
131.96Scjs#	but can be overridden.
141.96Scjs#   KERNOBJDIR is the kernel build directory, it defaults to
151.172Sjlam#	${KERNSRCDIR}/arch/${MACHINE}/compile, but can be overridden.
161.96Scjs#   KERNCONFDIR is where the configuration files for kernels are found;
171.96Scjs#	default is ${KERNSRCDIR}/arch/${MACHINE}/conf but can be overridden.
181.270Slukem#   MKCRYPTO; if not `no', install crypto-related configuration
191.304Slukem#   MKPOSTFIX; if not `no', install postfix configuration
201.270Slukem#   MKSENDMAIL; if not `no', install sendmail configuration
211.270Slukem#   MKUNPRIVED; if not `no', allow non-root installs.
221.255Slukem#   MKUPDATE; if not `no', don't do a 'make clean' before kernel compile
231.154Sthorpej#
241.96Scjs# Targets:
251.96Scjs#    distribution: makes a full NetBSD distribution in DESTDIR. If
261.96Scjs#	INSTALL_DONE is set, it will not do a `make install.'
271.182Schs#	if DISTRIBUTION_DONE is set, it will not do anything.
281.96Scjs#    distrib-dirs: creates an empty NetBSD directory tree in DESTDIR.
291.96Scjs#	Called by distribution.
301.96Scjs#    snapshot: calls distribution, above, and then tars up the files
311.286Scl#	into a release(7) format in RELEASEDIR/${RELEASEMACHINEDIR}.
321.241Slukem#	Any port-dependent stuff for this target is found in
331.241Slukem#	etc.${MACHINE}/Makefile.inc.
341.106Scjs#    release: a synonym for `snapshot'
351.242Slukem#
361.199Stv
371.270Slukem# For MK* vars
381.90Skim.include <bsd.own.mk>
391.187Sjmc
401.260Slukem.include <bsd.sys.mk>		# for HOST_SH
411.260Slukem.include <bsd.kernobj.mk>	# For KERNSRCDIR, KERNOBJDIR, ...
421.260Slukem.include <bsd.endian.mk>	# For TARGET_ENDIANNESS
431.252Slukem
441.211Slukem
451.187Sjmc.MAKEOVERRIDES+=	USETOOLS
461.90Skim
471.23ScgdTZDIR=		/usr/share/zoneinfo
481.157SkleinkLOCALTIME?=	UTC
491.283SagcCKSUM?=		${TOOL_CKSUM}
501.283SagcMAKESUMS=	CKSUM=${CKSUM:Q} ${HOST_SH} ${NETBSDSRCDIR}/distrib/sets/makesums
511.266SlukemDISTRIBVER!=	${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh
521.19Sderaadt
531.161Shubertf# Flags for creating ISO CDROM image
541.161Shubertf# mkisofs is expected to be in $PATH, install via pkgsrc/sysutils/cdrecord
551.242Slukem# Note: At least mkisofs 2.0 should be used.
561.242Slukem#
571.161ShubertfMKISOFS?=	mkisofs
581.260SlukemDISTRIBREV!=	${HOST_SH} ${KERNSRCDIR}/conf/osrelease.sh -s
591.224Sbjh21# ISO 9660 volume ID.  Note that this can only contain [A-Z0-9_].
601.224Sbjh21ISO_VOLID!=	echo NETBSD_${MACHINE}_${DISTRIBREV} | tr a-z A-Z
611.161ShubertfMKISOFS_FLAGS+= -J -l \
621.161Shubertf		-r -T -v \
631.224Sbjh21		-V ${ISO_VOLID} \
641.161Shubertf		-P "The NetBSD Project" \
651.286Scl		-m "${RELEASEDIR}/${RELEASEMACHINEDIR}/installation/cdrom"
661.1Scgd
671.80Sjonathan# MD Makefile.inc may append MD targets to BIN[123].  Make sure all
681.80Sjonathan# are empty, to preserve the old semantics of setting them below with "=".
691.242Slukem#
701.200SlukemBIN1=
711.80SjonathanBIN2=
721.80SjonathanBIN3=
731.80Sjonathan
741.286Scl# Directories to build in ${RELEASEDIR}/${RELEASEMACHINEDIR}.
751.241Slukem# MD Makefile.inc files can add to this.
761.117Ssimonb# NOTE: Parent directories must be listed before subdirectories.
771.242Slukem#
781.217SlukemINSTALLATION_DIRS=	binary binary/sets binary/kernel installation
791.117Ssimonb
801.286Scl.if exists(etc.${RELEASEMACHINE}/Makefile.inc)
811.286Scl.include "etc.${RELEASEMACHINE}/Makefile.inc"
821.71Scjs.endif
831.32Sjtc
841.21Scgd# -rw-r--r--
851.21ScgdBINOWN= root
861.21ScgdBINGRP= wheel
871.227SperryUTMPGRP= utmp
881.184SlukemBIN1+=	bootptab changelist csh.cshrc csh.login csh.logout daily \
891.223Sfredette	daily.conf dm.conf floppytab ftpchroot ftpusers \
901.280Sitohy	gettytab group hosts hosts.lpd inetd.conf lkm.conf locate.conf \
911.131Sveego	mailer.conf man.conf monthly monthly.conf mrouted.conf \
921.151Sfvdl	netconfig networks newsyslog.conf nsswitch.conf ntp.conf \
931.291Slukem	passwd.conf phones printcap profile protocols \
941.291Slukem	rbootd.conf rc rc.conf rc.lkm rc.local rc.subr rc.shutdown remote rpc \
951.142Stsarna	security security.conf services shells sysctl.conf syslog.conf \
961.291Slukem	weekly weekly.conf wscons.conf
971.291Slukem
981.242Slukem# Use machine-specific disktab if it exists, or the MI one otherwise
991.236Sjdolecek.if exists(etc.${MACHINE}/disktab)
1001.236SjdolecekBIN1+=	etc.${MACHINE}/disktab
1011.236Sjdolecek.else
1021.236SjdolecekBIN1+=	disktab
1031.236Sjdolecek.endif
1041.105Smycroft
1051.234Sjdolecek.if exists(etc.${MACHINE}/ld.so.conf)
1061.234SjdolecekBIN1+=	etc.${MACHINE}/ld.so.conf
1071.152Sperry.endif
1081.152Sperry
1091.234Sjdolecek.if exists(etc.${MACHINE}/ttyaction)
1101.234SjdolecekBIN1+=	etc.${MACHINE}/ttyaction
1111.105Smycroft.endif
1121.1Scgd
1131.46Sderaadt# -rw-rw-r--
1141.80SjonathanBIN2+=	motd
1151.1Scgd
1161.77Smycroft# -rw-------
1171.80SjonathanBIN3+=	hosts.equiv
1181.77Smycroft
1191.291SlukemSYSPKG=	etc
1201.230SperryETC_PKG=-T etc_pkg
1211.230SperryBASE_PKG=-T base_pkg
1221.242SlukemETC_INSTALL_FILE=cd ${.CURDIR} && ${INSTALL_FILE} ${ETC_PKG}
1231.261SclETC_INSTALL_OBJ_FILE=cd ${.OBJDIR} && ${INSTALL_FILE} ${ETC_PKG}
1241.230Sperry
1251.191Stv.if ${TARGET_ENDIANNESS} == "1234"
1261.252SlukemPWD_MKDB_ENDIAN=	-L
1271.191Stv.elif ${TARGET_ENDIANNESS} == "4321"
1281.252SlukemPWD_MKDB_ENDIAN=	-B
1291.170Sjdolecek.else
1301.252SlukemPWD_MKDB_ENDIAN=
1311.191Stv.endif
1321.149Ssjg
1331.149Ssjg
1341.242Slukem# distribution --
1351.242Slukem#	Build a distribution
1361.242Slukem#
1371.275Slukemdistribution: .PHONY check_DESTDIR .WAIT distrib-dirs
1381.182Schs.if !defined(DISTRIBUTION_DONE)
1391.87Sperry.if !defined(INSTALL_DONE)
1401.285Slukem	${MAKEDIRTARGET} ${NETBSDSRCDIR} include _DISTRIB=
1411.285Slukem	${MAKEDIRTARGET} ${NETBSDSRCDIR} install _DISTRIB=
1421.200Slukem.endif	# !INSTALL_DONE
1431.285Slukem	${MAKEDIRTARGET} . install-etc-files
1441.288Slukem.if ${MKX11} != "no"
1451.288Slukem	${MAKEDIRTARGET} ${NETBSDSRCDIR}/x11 distribution
1461.288Slukem.endif
1471.285Slukem	${MAKEDIRTARGET} ${NETBSDSRCDIR}/distrib/sets makesetfiles
1481.200Slukem.endif	# !DISTRIBUTION_DONE
1491.193Sthorpej
1501.266Slukem
1511.295SchristosCLEANFILES+=	MAKEDEV
1521.275SlukemMAKEDEV: .EXEC
1531.263Slukem	${_MKTARGET_CREATE}
1541.264Slukem	MACHINE=${MACHINE:Q} MACHINE_ARCH=${MACHINE_ARCH:Q} \
1551.264Slukem	    NETBSDSRCDIR=${NETBSDSRCDIR:Q} \
1561.264Slukem	    awk -f ${.CURDIR}/MAKEDEV.awk ${.CURDIR}/MAKEDEV.tmpl > ${.TARGET}
1571.257Sjdolecek
1581.266SlukemRELEASEVARS=	BSDOBJDIR BSDSRCDIR BUILDID \
1591.266Slukem		DESTDIR EXTERNAL_TOOLCHAIN \
1601.266Slukem		INSTALLWORLDDIR \
1611.266Slukem		KERNARCHDIR KERNCONFDIR KERNOBJDIR KERNSRCDIR \
1621.266Slukem		MACHINE MACHINE_ARCH MAKE MAKECONF MAKEFLAGS \
1631.266Slukem		MAKEOBJDIR MAKEOBJDIRPREFIX MAKEVERBOSE \
1641.273Slukem		MKBFD MKCATPAGES \
1651.273Slukem		MKCRYPTO MKCRYPTO_IDEA MKCRYPTO_MDC2 MKCRYPTO_RC5 MKCVS \
1661.273Slukem		MKDOC MKDYNAMICROOT MKGCC MKGCCCMDS MKGDB \
1671.303Speter		MKHESIOD MKHOSTOBJ MKHTML MKIEEEFP MKINET6 MKINFO MKIPFILTER \
1681.273Slukem		MKKERBEROS4 MKKERBEROS MKLINKLIB MKLINT \
1691.273Slukem		MKMAN MKMANZ MKNLS MKOBJ MKOBJDIRS \
1701.303Speter		MKPAM MKPF MKPIC MKPICINSTALL MKPICLIB MKPOSTFIX MKPROFILE \
1711.273Slukem		MKSENDMAIL MKSHARE MKSKEY MKSOFTFLOAT MKSTATICLIB \
1721.273Slukem		MKUNPRIVED MKUPDATE MKUUCP MKX11 MKYP \
1731.276Slukem		NBUILDJOBS NETBSDSRCDIR \
1741.266Slukem		NOCLEANDIR NODISTRIBDIRS NOINCLUDES \
1751.276Slukem		OBJMACHINE \
1761.276Slukem		RELEASEDIR TOOLCHAIN_MISSING TOOLDIR \
1771.276Slukem		USETOOLS USR_OBJMACHINE \
1781.276Slukem		X11SRCDIR
1791.276Slukem
1801.276Slukemparams: .PHONY
1811.276Slukem.for var in ${RELEASEVARS}
1821.276Slukem.if defined(${var})
1831.276Slukem	@printf "%20s = '%-s'\n" ${var} ${${var}:Q}
1841.276Slukem.else
1851.276Slukem	@printf "%20s = (undefined)\n" ${var}
1861.276Slukem.endif
1871.276Slukem.endfor
1881.266Slukem
1891.272SlukemCLEANFILES+=	etc-release
1901.275Slukemetc-release: .EXEC
1911.266Slukem	${_MKTARGET_CREATE}
1921.266Slukem	@(	echo "NetBSD ${DISTRIBVER}/${MACHINE}"; \
1931.266Slukem		echo ; \
1941.269Slukem		cat ${NETBSDSRCDIR}/sys/conf/copyright; \
1951.266Slukem		echo ; \
1961.266Slukem		echo "Build settings:"; \
1971.281Slukem		printf "%20s   %s\n"  "Build date" "$$(date -u)"; \
1981.281Slukem		printf "%20s   %s\n"  "Built by" "$${USER-root}@$$(hostname)"; \
1991.281Slukem		echo ; \
2001.282Senami		(cd ${.CURDIR}; ${MAKE} ${MFLAGS} -j1 params); \
2011.276Slukem	) >${.OBJDIR}/${.TARGET}
2021.266Slukem
2031.275Slukeminstall-etc-release: .PHONY etc-release
2041.272Slukem	${_MKMSG_INSTALL} etc/release
2051.266Slukem	${ETC_INSTALL_OBJ_FILE} -o ${BINOWN} -g ${BINGRP} -m 444 \
2061.272Slukem	    etc-release ${DESTDIR}/etc/release
2071.242Slukem
2081.291Slukem
2091.291SlukemFILESDIR=		/etc
2101.291SlukemCONFIGFILES=
2111.291SlukemCONFIGSYMLINKS=
2121.291Slukem
2131.291Slukem.for file in ${BIN1}
2141.291SlukemCONFIGFILES+=		${file}
2151.291SlukemFILESMODE_${file:T}=	644
2161.291Slukem.endfor
2171.291Slukem
2181.291Slukem.for file in ${BIN2}
2191.291SlukemCONFIGFILES+=		${file}
2201.291SlukemFILESMODE_${file:T}=	664
2211.291Slukem.endfor
2221.291Slukem
2231.291Slukem.for file in ${BIN3}
2241.291SlukemCONFIGFILES+=		${file}
2251.291SlukemFILESMODE_${file:T}=	600
2261.291Slukem.endfor
2271.291Slukem
2281.291SlukemCONFIGFILES+=		postinstall
2291.291SlukemFILESMODE_postinstall=	${BINMODE}
2301.291Slukem
2311.291SlukemCONFIGFILES+=		aliases
2321.291SlukemFILESDIR_aliases=	/etc/mail
2331.291SlukemFILESMODE_aliases=	644
2341.291Slukem
2351.291SlukemCONFIGFILES+=		MAKEDEV.local
2361.291SlukemFILESDIR_MAKEDEV.local=	/dev
2371.291SlukemFILESMODE_MAKEDEV.local=${BINMODE}
2381.291Slukem
2391.291SlukemCONFIGFILES+=		crontab
2401.291SlukemFILESDIR_crontab=	/var/cron/tabs
2411.291SlukemFILESNAME_crontab=	root
2421.291SlukemFILESMODE_crontab=	600
2431.291Slukem
2441.291SlukemCONFIGFILES+=		minfree
2451.291SlukemFILESDIR_minfree=	/var/crash
2461.291SlukemFILESMODE_minfree=	600
2471.291Slukem
2481.291SlukemCONFIGSYMLINKS+=	${TZDIR}/${LOCALTIME}	/etc/localtime \
2491.291Slukem			/usr/sbin/rmt		/etc/rmt
2501.291Slukem
2511.291Slukem
2521.242Slukem# install-etc-files --
2531.242Slukem#	Install etc (config) files; not performed by "make build"
2541.242Slukem#
2551.297Schristosinstall-etc-files: .PHONY check_DESTDIR MAKEDEV
2561.291Slukem	${_MKMSG_INSTALL} ${DESTDIR}/etc/master.passwd
2571.230Sperry	${ETC_INSTALL_FILE} -o root -g wheel -m 600 \
2581.230Sperry	    master.passwd ${DESTDIR}/etc
2591.254Slukem	${TOOL_PWD_MKDB} -p ${PWD_MKDB_ENDIAN} -d ${DESTDIR}/ \
2601.230Sperry	    ${DESTDIR}/etc/master.passwd
2611.255Slukem.if ${MKUNPRIVED} != "no"
2621.222Slukem	( \
2631.246Slukem		for metaent in passwd pwd.db spwd.db; do \
2641.246Slukem	    		echo "./etc/$${metaent} type=file mode=0644 uname=root gname=wheel tags=etc_pkg"; \
2651.246Slukem		done; \
2661.239Slukem	) | ${METALOG.add}
2671.255Slukem.endif	# MKUNPRIVED != no
2681.291Slukem	${_MKMSG_INSTALL} ${DESTDIR}/etc/ttys
2691.289Schristos	${ETC_INSTALL_OBJ_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
2701.298Schristos	    ${.CURDIR}/etc.${MACHINE}/ttys ${DESTDIR}/etc
2711.291Slukem	${_MKMSG_INSTALL} ${DESTDIR}/dev/MAKEDEV
2721.259Sross	${ETC_INSTALL_OBJ_FILE} -o ${BINOWN} -g ${BINGRP} -m 555 \
2731.257Sjdolecek	    MAKEDEV ${DESTDIR}/dev
2741.291Slukem.for owner group mode file in \
2751.291Slukem		${BINOWN} operator	664	/etc/dumpdates  \
2761.291Slukem		${BINOWN} ${BINGRP}	644	/etc/mail/local-host-names \
2771.291Slukem		${BINOWN} operator	600	/etc/skeykeys \
2781.291Slukem		root wheel		600	/var/at/at.deny \
2791.291Slukem		nobody ${BINGRP}	664	/var/db/locate.database \
2801.291Slukem		uucp dialer		640	/var/log/aculog \
2811.291Slukem		${BINOWN} ${BINGRP}	600	/var/log/authlog \
2821.291Slukem		root wheel		600	/var/log/cron \
2831.291Slukem		${BINOWN} ${BINGRP}	664	/var/log/lastlog \
2841.291Slukem		${BINOWN} ${BINGRP}	640	/var/log/lpd-errs \
2851.291Slukem		${BINOWN} ${BINGRP}	600	/var/log/maillog \
2861.291Slukem		${BINOWN} ${BINGRP}	644	/var/log/messages \
2871.291Slukem		${BINOWN} ${BINGRP}	600	/var/log/secure \
2881.291Slukem		${BINOWN} ${BINGRP}	644	/var/log/sendmail.st \
2891.291Slukem		${BINOWN} ${BINGRP}	644	/var/log/wtmp \
2901.291Slukem		${BINOWN} ${BINGRP}	644	/var/log/wtmpx \
2911.291Slukem		${BINOWN} ${BINGRP}	600	/var/log/xferlog \
2921.291Slukem		daemon staff		664	/var/msgs/bounds \
2931.291Slukem		${BINOWN} ${UTMPGRP}	664	/var/run/utmp \
2941.291Slukem		${BINOWN} ${UTMPGRP}	664	/var/run/utmpx \
2951.291Slukem		games games		664	/var/games/atc_score \
2961.291Slukem		games games		664	/var/games/battlestar.log \
2971.291Slukem		games games		664	/var/games/cfscores \
2981.291Slukem		games games		664	/var/games/criblog \
2991.291Slukem		games games		660	/var/games/hackdir/perm \
3001.291Slukem		games games		660	/var/games/hackdir/record \
3011.291Slukem		games games		664	/var/games/larn/llog12.0 \
3021.291Slukem		games games		664	/var/games/larn/lscore12.0 \
3031.291Slukem		games games		664	/var/games/larn/playerids \
3041.291Slukem		games games		664	/var/games/robots_roll \
3051.291Slukem		games games		664	/var/games/rogue.scores \
3061.291Slukem		games games		664	/var/games/saillog \
3071.291Slukem		games games		664	/var/games/snakerawscores \
3081.291Slukem		games games		664	/var/games/snake.log \
3091.291Slukem		games games		664	/var/games/tetris.scores
3101.291Slukem	${_MKMSG_INSTALL} ${DESTDIR}${file}
3111.291Slukem	${ETC_INSTALL_FILE} -o ${owner} -g ${group} -m ${mode} \
3121.291Slukem	    	/dev/null ${DESTDIR}${file}
3131.291Slukem.endfor
3141.300Slukem.for subdir in . defaults mtree namedb pam.d powerd rc.d root skel ssh
3151.291Slukem	${MAKEDIRTARGET} ${subdir} configinstall
3161.291Slukem.endfor
3171.287Slukem	${MAKEDIRTARGET} ${NETBSDSRCDIR}/usr.bin/mail configinstall
3181.303Speter.if (${MKPF} != "no")
3191.294Syamt	${MAKEDIRTARGET} ${NETBSDSRCDIR}/usr.sbin/pf configinstall
3201.303Speter.endif
3211.155Sthorpej.if (${MKCRYPTO} != "no")
3221.287Slukem	${MAKEDIRTARGET} ${NETBSDSRCDIR}/usr.bin/ssh configinstall
3231.155Sthorpej.endif
3241.304Slukem.if (${MKPOSTFIX} != "no")
3251.304Slukem	${MAKEDIRTARGET} ${NETBSDSRCDIR}/gnu/usr.sbin/postfix configinstall
3261.304Slukem.endif
3271.270Slukem.if (${MKSENDMAIL} != "no")
3281.287Slukem	${MAKEDIRTARGET} ${NETBSDSRCDIR}/gnu/usr.sbin/sendmail/cf/cf configinstall
3291.90Skim.endif
3301.247Slukem
3311.247Slukem
3321.247Slukem# install-obsolete-lists --
3331.247Slukem#	Install var/db/obsolete set lists; this is performed by "make build"
3341.247Slukem#
3351.247SlukemOBSOLETE.dir=		${.OBJDIR}/obsolete.dir
3361.247SlukemOBSOLETE.files=		base comp etc games man misc text
3371.247Slukem
3381.275Slukeminstall-obsolete-lists: .PHONY
3391.246Slukem	mkdir -p ${OBSOLETE.dir}
3401.253Slukem	(cd ${NETBSDSRCDIR}/distrib/sets && \
3411.253Slukem	    MAKE=${MAKE:Q} ${HOST_SH} ./makeobsolete -t ${OBSOLETE.dir})
3421.246Slukem.for file in ${OBSOLETE.files}
3431.291Slukem	${_MKMSG_INSTALL} ${DESTDIR}/var/db/obsolete/${file}
3441.246Slukem	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
3451.247Slukem	    ${OBSOLETE.dir}/${file} ${DESTDIR}/var/db/obsolete
3461.246Slukem.endfor
3471.1Scgd
3481.242Slukem
3491.242Slukem# distrib-dirs --
3501.242Slukem#	Populate $DESTDIR with directories needed by NetBSD
3511.242Slukem#
3521.255Slukem.if ${MKUNPRIVED} == "no"
3531.255SlukemTOOL_MTREE.unpriv=
3541.255Slukem.else
3551.255SlukemTOOL_MTREE.unpriv=	-W
3561.255Slukem.endif
3571.255Slukem
3581.275Slukemdistrib-dirs: .PHONY check_DESTDIR
3591.256Sdsl.if !defined(DISTRIBUTION_DONE)
3601.230Sperry	${INSTALL_DIR} -o root -g wheel -m 755 ${BASE_PKG} ${DESTDIR}
3611.256Sdsl.endif
3621.254Slukem	${TOOL_MTREE} -def ${.CURDIR}/mtree/NetBSD.dist -N ${.CURDIR} \
3631.255Slukem	    -p ${DESTDIR}/ -U ${TOOL_MTREE.unpriv}
3641.200Slukem
3651.242Slukem
3661.242Slukem# release, snapshot --
3671.242Slukem#	Build a full distribution including kernels & install media.
3681.242Slukem#
3691.275Slukemrelease snapshot: .PHONY check_DESTDIR check_RELEASEDIR .WAIT \
3701.233Slukem		    distribution .WAIT \
3711.233Slukem		    snap_pre .WAIT snap_kern .WAIT \
3721.233Slukem		    snap_post .WAIT snap_md_post
3731.285Slukem	${MAKEDIRTARGET} ${NETBSDSRCDIR}/distrib/sets sets
3741.286Scl	${MAKESUMS} -t ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/kernel '*.gz'
3751.161Shubertf
3761.242Slukem
3771.242Slukem# iso-image --
3781.242Slukem#	Standalone target to create a CDROM image after the release
3791.242Slukem#	was composed.  Should be run after "make release" in src and xsrc.
3801.242Slukem#
3811.245Slukem#	Note: At least mkisofs 2.0 should be used.
3821.242Slukem#
3831.292SheCDROM_NAME_ADD?=
3841.292SheCDROM.image=${RELEASEDIR}/${RELEASEMACHINEDIR}/installation/cdrom/netbsd-${MACHINE}${CDROM_NAME_ADD}.iso
3851.242SlukemCDROM.dir=	cdrom.dir
3861.242SlukemCDROM.pathlist=	cdrom.pathlist
3871.242Slukem
3881.275Slukemiso-image: .PHONY check_DESTDIR check_RELEASEDIR .WAIT iso-image-md-post
3891.286Scl	${MAKESUMS} -t ${RELEASEDIR}/${RELEASEMACHINEDIR}/installation/cdrom '*.iso'
3901.265Slukem	@echo "iso-image created as: ${CDROM.image}"
3911.161Shubertf
3921.275Slukemiso-image-setup: .PHONY check_RELEASEDIR
3931.242Slukem	rm -f ${CDROM.pathlist}
3941.302Sfredb.for extra in README SOURCE_DATE source
3951.302Sfredb.if exists(${RELEASEDIR}/${extra})
3961.302Sfredb	echo "${extra}=${RELEASEDIR}/${extra}" >> ${CDROM.pathlist}
3971.302Sfredb.endif
3981.302Sfredb.endfor
3991.286Scl	echo "${MACHINE}=${RELEASEDIR}/${RELEASEMACHINEDIR}" >> ${CDROM.pathlist}
4001.242Slukem	mkdir -p ${CDROM.dir}
4011.286Scl	mkdir -p ${RELEASEDIR}/${RELEASEMACHINEDIR}/installation/cdrom
4021.242Slukem
4031.248Slukem# iso-image-mi --
4041.242Slukem#	Create the image after the MD operations have completed.
4051.248Slukem#
4061.275Slukemiso-image-mi: .PHONY check_DESTDIR check_RELEASEDIR .WAIT \
4071.248Slukem		iso-image-setup .WAIT iso-image-md-pre
4081.242Slukem	@if ! ${MKISOFS} --version; then \
4091.242Slukem		echo "install pkgsrc/sysutils/cdrecord and run 'make iso-image'." ; \
4101.242Slukem		false; \
4111.161Shubertf	fi
4121.242Slukem	${MKISOFS} ${MKISOFS_FLAGS} -graft-points -path-list ${CDROM.pathlist} \
4131.242Slukem	    -o ${CDROM.image} ${CDROM.dir}
4141.242Slukem
4151.248Slukem# iso-image-md-pre --
4161.242Slukem#	Setup ${CDROM.dir} to produce a bootable CD image.
4171.242Slukem#	Overridden by etc.$MACHINE/Makefile.inc
4181.242Slukem#
4191.275Slukemiso-image-md-pre: .PHONY check_DESTDIR check_RELEASEDIR
4201.242Slukem#	(empty -- look in the machine-dependent Makefile.inc)
4211.161Shubertf
4221.248Slukem# iso-image-md-post --
4231.242Slukem#	Fixup the CD-image to be bootable.
4241.242Slukem#	Overridden by etc.$MACHINE/Makefile.inc
4251.242Slukem#
4261.275Slukemiso-image-md-post: .PHONY check_DESTDIR check_RELEASEDIR .WAIT iso-image-mi
4271.242Slukem#	(empty -- look in the machine-dependent Makefile.inc)
4281.41Scgd
4291.242Slukem
4301.242Slukem# snap_pre --
4311.242Slukem#	Create ${RELEASEDIR} and necessary subdirectories.
4321.242Slukem#
4331.275Slukemsnap_pre: .PHONY check_DESTDIR check_RELEASEDIR
4341.241Slukem	${INSTALL} -d -m 755 ${RELEASEDIR}
4351.255Slukem.if ${MKUPDATE} == "no"
4361.168Sjmc# Could be a mount point, ignore the errors
4371.286Scl	-/bin/rm -rf ${RELEASEDIR}/${RELEASEMACHINEDIR}
4381.240Slukem.endif
4391.286Scl	${INSTALL} -d -m 755 ${RELEASEDIR}/${RELEASEMACHINEDIR}
4401.117Ssimonb.for dir in ${INSTALLATION_DIRS}
4411.286Scl	${INSTALL} -d -m 755 ${RELEASEDIR}/${RELEASEMACHINEDIR}/${dir}
4421.117Ssimonb.endfor
4431.96Scjs
4441.242Slukem# snap_post --
4451.242Slukem#	Build the install media and notes from distrib
4461.242Slukem#
4471.275Slukemsnap_post: .PHONY check_DESTDIR check_RELEASEDIR
4481.255Slukem.if ${MKUPDATE} == "no"
4491.233Slukem	cd ${NETBSDSRCDIR}/distrib && ${MAKE} cleandir
4501.233Slukem.endif
4511.233Slukem	cd ${NETBSDSRCDIR}/distrib && ${MAKE} depend && ${MAKE} && \
4521.233Slukem	    ${MAKE} release
4531.233Slukem
4541.232Slukem# snap_kern --
4551.242Slukem#	This target builds the kernels specified by each port.
4561.242Slukem#	A port may specify the following kernels:
4571.196Sthorpej#
4581.196Sthorpej#	KERNEL_SETS		The list of kernels that will be
4591.196Sthorpej#				packaged into sets, named
4601.196Sthorpej#				kern-${kernel}.tgz.  These kernels
4611.203Schs#				are also placed in the binary/kernel
4621.196Sthorpej#				area of the release package as
4631.196Sthorpej#				netbsd-${kernel}.gz.
4641.196Sthorpej#
4651.196Sthorpej#	EXTRA_KERNELS		Additional kernels to place in the
4661.203Schs#				binary/kernel area of the release
4671.196Sthorpej#				package as netbsd-${kernel}.gz, but
4681.196Sthorpej#				which are not placed into sets. This
4691.196Sthorpej#				allows a port to provide e.g. a netbootable
4701.196Sthorpej#				installation kernel containing a ramdisk.
4711.196Sthorpej#
4721.196Sthorpej#	BUILD_KERNELS		Additional kernels to build which are
4731.196Sthorpej#				not placed into sets nor into the
4741.203Schs#				binary/kernel area of the release
4751.196Sthorpej#				package.  These are typically kernels
4761.196Sthorpej#				that are built for inclusion only in
4771.196Sthorpej#				installation disk/CD-ROM/tape images.
4781.116Sfair#
4791.242Slukem#	A port may also specify KERNEL_SUFFIXES, which is an optional list
4801.242Slukem#	of filename suffixes for kernels to include in the kernel sets and
4811.242Slukem#	in the binary/kernel area of the release package (e.g. "netbsd" vs.
4821.242Slukem#	"netbsd.ecoff" and "netbsd.srec").  It is not an error if kernels
4831.242Slukem#	with these suffixes do not exist in the kernel build directory.
4841.197Sthorpej#
4851.229Slukem#
4861.229Slukem# A list of all the kernels to build, which can be overridden from
4871.229Slukem# external sources (such as make(1)'s environment or command line)
4881.229Slukem#
4891.229SlukemALL_KERNELS?=	${KERNEL_SETS} ${EXTRA_KERNELS} ${BUILD_KERNELS}
4901.242Slukem
4911.116SfairGETKERNELAWK=	awk '/^config/ {print $$2; found=1} \
4921.116Sfair		END{ if (found == 0) print "netbsd"; }'
4931.242Slukem
4941.232Slukem.if !target(snap_kern)						# {
4951.232Slukem
4961.232Slukem# build_kernels --
4971.232Slukem#	Configure & compile kernels listed in ${ALL_KERNELS}
4981.232Slukem#
4991.284Scgd# The 'sync' is so that all writes during the build are pushed back
5001.284Scgd# to the disk.  Not having it causes problems on some host systems
5011.284Scgd# (e.g. Linux) when building on NFS.
5021.284Scgd#
5031.201Slukem.if !defined(KERNELS_DONE)						# {
5041.232Slukem.for configfile in ${ALL_KERNELS}					# {
5051.232Slukem_KERNELS_TO_BUILD+=kern-${configfile}
5061.275Slukemkern-${configfile}: .PHONY
5071.254Slukem	cd ${KERNCONFDIR} && ${TOOL_CONFIG} -s ${KERNSRCDIR} \
5081.232Slukem	    -b ${KERNOBJDIR}/${configfile:C/.*\///} ${configfile}
5091.255Slukem.if ${MKUPDATE} == "no"
5101.200Slukem	cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} distclean
5111.96Scjs.endif
5121.218Ssommerfe	cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} depend && ${MAKE}
5131.284Scgd	sync
5141.232Slukem.endfor	# ALL_KERNELS							# }
5151.232Slukem.endif	# KERNELS_DONE							# }
5161.232Slukem
5171.275Slukembuild_kernels: .PHONY ${_KERNELS_TO_BUILD}
5181.232Slukem
5191.232Slukem# build_kernelsets --
5201.241Slukem#	Create kernel sets from ${KERNEL_SETS} into
5211.286Scl#	${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets
5221.232Slukem#
5231.232Slukem.for configfile in ${KERNEL_SETS}					# {
5241.232Slukem_KERNELSETS_TO_BUILD+=kernset-${configfile}
5251.275Slukemkernset-${configfile}: .PHONY
5261.256Sdsl	@ kernlist=`${GETKERNELAWK} ${KERNCONFDIR}/${configfile}`; \
5271.197Sthorpej	kerndir=${KERNOBJDIR}/${configfile:C/.*\///}; \
5281.256Sdsl	kernsuffixes="${KERNEL_SUFFIXES:S/^/./}"; \
5291.286Scl	kern_tgz=${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets/kern-${configfile}.tgz; \
5301.256Sdsl	pax_cmd="GZIP=-9 ${TOOL_PAX} -O -zw -M -N ${NETBSDSRCDIR}/etc -f $${kern_tgz}"; \
5311.256Sdsl	cd $${kerndir} && { \
5321.256Sdsl		kernels=; newest=; \
5331.210Slukem		for kernel in $${kernlist}; do \
5341.256Sdsl			for s in "" $${kernsuffixes}; do \
5351.256Sdsl				ks="$${kernel}$${s}"; \
5361.256Sdsl				[ -f $${ks} ] || continue; \
5371.256Sdsl				kernels="$${kernels} $${ks}"; \
5381.256Sdsl				[ -z "$${newest}" -o $${ks} -nt "$${newest}" ] && \
5391.256Sdsl					newest=$${ks}; \
5401.197Sthorpej			done; \
5411.256Sdsl		done; \
5421.256Sdsl		[ $${kern_tgz} -nt "$${newest}" ] || { \
5431.256Sdsl			echo "echo $${kernels} | $${pax_cmd}"; \
5441.256Sdsl			( echo "/set uname=${BINOWN} gname=${BINGRP}"; \
5451.256Sdsl			echo ". type=dir optional"; \
5461.256Sdsl			for kernel in $${kernels}; do \
5471.256Sdsl				echo "./$${kernel} type=file"; \
5481.256Sdsl			done ) | eval $${pax_cmd}; \
5491.256Sdsl		} \
5501.256Sdsl	}
5511.232Slukem.endfor	# KERNEL_SETS							# }
5521.232Slukem
5531.232Slukembuild_kernelsets: ${_KERNELSETS_TO_BUILD}
5541.232Slukem
5551.232Slukem# build_releasekernels --
5561.232Slukem#	Build kernel.gz from ${KERNEL_SETS} ${EXTRA_KERNELS} into
5571.286Scl#	${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/kernel
5581.232Slukem#
5591.232Slukem.for configfile in ${KERNEL_SETS} ${EXTRA_KERNELS}			# {
5601.232Slukem_RELEASEKERNELS_TO_BUILD+=releasekern-${configfile}
5611.275Slukemreleasekern-${configfile}: .PHONY
5621.256Sdsl	@ kernlist=`${GETKERNELAWK} ${KERNCONFDIR}/${configfile:C/.*\///}`; \
5631.197Sthorpej	kerndir=${KERNOBJDIR}/${configfile:C/.*\///}; \
5641.256Sdsl	kernsuffixes="${KERNEL_SUFFIXES:S/^/./}"; \
5651.256Sdsl	cd $${kerndir} && {	\
5661.256Sdsl		for kernel in $${kernlist}; do \
5671.256Sdsl			for s in "" $${kernsuffixes}; do \
5681.256Sdsl				ks="$${kernel}$${s}"; \
5691.256Sdsl				[ ! -f $${ks} ] && continue; \
5701.286Scl				knl_gz="${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/kernel/$${ks}-${configfile:C/.*\///}.gz"; \
5711.256Sdsl				[ $${knl_gz} -nt $${ks} ] && continue; \
5721.256Sdsl				echo "gzip -c -9 < $${kerndir}/$${ks} > $${knl_gz}"; \
5731.256Sdsl				gzip -c -9 < $${ks} > $${knl_gz}; \
5741.197Sthorpej			done; \
5751.256Sdsl		done; \
5761.256Sdsl	}
5771.232Slukem.endfor	# KERNEL_SETS EXTRA_KERNELS					# }
5781.232Slukem
5791.232Slukembuild_releasekernels: ${_RELEASEKERNELS_TO_BUILD}
5801.232Slukem
5811.232Slukem# snap_kern --
5821.232Slukem#	build the kernels, then the sets & release kernels
5831.242Slukem#
5841.232Slukemsnap_kern: check_DESTDIR check_RELEASEDIR .WAIT \
5851.232Slukem	    build_kernels .WAIT \
5861.232Slukem	    build_kernelsets build_releasekernels
5871.232Slukem
5881.232Slukem.endif # !target(snap_kern)					# }
5891.232Slukem
5901.108Sdrochner
5911.242Slukem# snap_md_post --
5921.242Slukem#	Machine dependent distribution media operations.
5931.242Slukem#	Overridden by etc.$MACHINE/Makefile.inc
5941.242Slukem#
5951.204Slukemsnap_md_post: check_DESTDIR check_RELEASEDIR
5961.242Slukem#	(empty -- look in the machine-dependent Makefile.inc)
5971.242Slukem
5981.242Slukem
5991.242Slukemclean:
6001.246Slukem	-rm -rf ${CDROM.dir} ${CDROM.pathlist} ${OBSOLETE.dir}
6011.7Scgd
6021.1Scgd.include <bsd.prog.mk>
603