Makefile revision 1.357
11.343Schristos#	$NetBSD: Makefile,v 1.357 2008/07/27 19:31:03 joerg Exp $
21.110Sthorpej#	from: @(#)Makefile	8.7 (Berkeley) 5/25/95
31.110Sthorpej
41.211Sthorpej# Environment variables without default values:
51.110Sthorpej#   DESTDIR must be set before anything in this file will work.
61.110Sthorpej#   RELEASEDIR is where the tarred up stuff for a snapshot or
71.110Sthorpej#	release will be placed.
81.110Sthorpej#
91.110Sthorpej# Environment variables with default values:
101.110Sthorpej#   LOCALTIME will set the default local time for the system you
111.110Sthorpej#	build; it determines what /etc/localtime is symlink'd to.
121.110Sthorpej#   KERNSRCDIR points to kernel source; it is set by default to ../sys,
131.110Sthorpej#	but can be overridden.
141.110Sthorpej#   KERNOBJDIR is the kernel build directory, it defaults to
151.110Sthorpej#	${KERNSRCDIR}/arch/${MACHINE}/compile, but can be overridden.
161.110Sthorpej#   KERNCONFDIR is where the configuration files for kernels are found;
171.110Sthorpej#	default is ${KERNSRCDIR}/arch/${MACHINE}/conf but can be overridden.
181.110Sthorpej#   MKCRYPTO; if not `no', install crypto-related configuration
191.110Sthorpej#   MKPOSTFIX; if not `no', install postfix configuration
201.110Sthorpej#   MKUNPRIVED; if not `no', allow non-root installs.
211.110Sthorpej#   MKUPDATE; if not `no', don't do a 'make clean' before kernel compile
221.110Sthorpej#
231.110Sthorpej# Targets:
241.110Sthorpej#    distribution: makes a full NetBSD distribution in DESTDIR. If
251.110Sthorpej#	INSTALL_DONE is set, it will not do a `make install.'
261.110Sthorpej#	if DISTRIBUTION_DONE is set, it will not do anything.
271.110Sthorpej#    distrib-dirs: creates an empty NetBSD directory tree in DESTDIR.
281.110Sthorpej#	Called by distribution.
291.110Sthorpej#    snapshot: calls distribution, above, and then tars up the files
301.110Sthorpej#	into a release(7) format in RELEASEDIR/${RELEASEMACHINEDIR}.
311.110Sthorpej#	Any port-dependent stuff for this target is found in
321.1Scgd#	etc.${MACHINE}/Makefile.inc.
331.1Scgd#    release: a synonym for `snapshot'
341.16Scgd#
351.1Scgd
361.1Scgd# For MK* vars
371.1Scgd.include <bsd.own.mk>
381.337Smatt
391.1Scgd.include <bsd.sys.mk>		# for HOST_SH
401.1Scgd.include <bsd.kernobj.mk>	# For KERNSRCDIR, KERNOBJDIR, ...
411.1Scgd.include <bsd.endian.mk>	# For TARGET_ENDIANNESS
421.1Scgd
431.1Scgd.MAKEOVERRIDES+=	USETOOLS
441.337Smatt
451.337SmattTZDIR=		/usr/share/zoneinfo
461.337SmattLOCALTIME?=	UTC
471.1ScgdCKSUM?=		${TOOL_CKSUM}
481.337SmattMAKESUMS=	MAKE=${MAKE:Q} CKSUM=${CKSUM:Q} ${HOST_SH} ${NETBSDSRCDIR}/distrib/sets/makesums
491.1ScgdDISTRIBVER!=	${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh
501.1Scgd
511.1Scgd# Flags for creating ISO CDROM image
521.1Scgd# mkisofs is expected to be in $PATH, install via pkgsrc/sysutils/cdrtools
531.1Scgd# Note: At least mkisofs 2.0 should be used.
541.1Scgd#
551.1Scgd.if !defined(MKISOFS)
561.1ScgdMKISOFS!=       (which mkisofs || echo true)
571.1Scgd.endif
581.1ScgdDISTRIBREV!=	${HOST_SH} ${KERNSRCDIR}/conf/osrelease.sh -s
591.74Scgd# ISO 9660 volume ID.  Note that this can only contain [A-Z0-9_].
601.129SjonathanISO_VOLID!=	echo NETBSD_${DISTRIBREV} | tr a-z A-Z
611.244SlukemMKISOFS_FLAGS+= -J -l -hide-joliet-trans-tbl -r -T \
621.315Sapb		-V ${ISO_VOLID} \
631.147Sthorpej		-publisher "The NetBSD Project" \
641.123Sthorpej		-m "${RELEASEDIR}/${RELEASEMACHINEDIR}/installation/cdrom"
651.123Sthorpej.if ${MKISOFS_FLAGS:N-v}
661.127SthorpejMKISOFS_FLAGS+=	-quiet
671.250Sjdolecek.endif
681.112Sthorpej 
691.75Scgd
701.75Scgd# MD Makefile.inc may append MD targets to BIN[123].  Make sure all
711.343Schristos# are empty, to preserve the old semantics of setting them below with "+=".
721.1Scgd#
731.1ScgdBIN1=
741.1ScgdBIN2=
751.1ScgdBIN3=
761.1Scgd
771.297Syamt# Directories to build in ${RELEASEDIR}/${RELEASEMACHINEDIR}.
781.1Scgd# MD Makefile.inc files can add to this.
791.264Snathanw# NOTE: Parent directories must be listed before subdirectories.
801.207Sthorpej#
811.1ScgdINSTALLATION_DIRS=	binary binary/sets binary/kernel installation
821.28Scgd
831.1Scgd.if exists(etc.${RELEASEMACHINE}/Makefile.inc)
841.110Sthorpej.include "etc.${RELEASEMACHINE}/Makefile.inc"
851.1Scgd.endif
861.1Scgd
871.1Scgd# -rw-r--r--
881.1ScgdBINOWN= root
891.320SmattBINGRP= wheel
901.1ScgdUTMPGRP= utmp
911.43ScgdBIN1+=	audit-packages.conf bootptab changelist csh.cshrc csh.login \
921.43Scgd	csh.logout daily daily.conf dm.conf envsys.conf floppytab ftpchroot \
931.261Sthorpej	ftpusers gettytab group hosts hosts.lpd inetd.conf lkm.conf \
941.258Sgehenna	locate.conf login.conf mailer.conf man.conf monthly monthly.conf \
951.266Sragge	mrouted.conf named.conf netconfig networks newsyslog.conf \
961.290Selad	nsswitch.conf ntp.conf passwd.conf phones printcap profile protocols \
971.303Sad	rbootd.conf rc rc.conf rc.lkm rc.local rc.subr rc.shutdown remote rpc \
981.303Sad	security security.conf services shells shrc sysctl.conf syslog.conf \
991.303Sad	weekly weekly.conf wscons.conf
1001.43Scgd
1011.241Sross# Use machine-specific disktab if it exists, or the MI one otherwise
1021.1Scgd.if exists(etc.${MACHINE}/disktab)
1031.1ScgdBIN1+=	etc.${MACHINE}/disktab
1041.1Scgd.else
1051.1ScgdBIN1+=	disktab
1061.327Suebayasi.endif
1071.217Smrg
1081.112Sthorpej.if exists(etc.${MACHINE}/ld.so.conf)
1091.1ScgdBIN1+=	etc.${MACHINE}/ld.so.conf
1101.335Srmind.endif
1111.1Scgd
1121.81Sthorpej.if exists(etc.${MACHINE}/ttyaction)
1131.1ScgdBIN1+=	etc.${MACHINE}/ttyaction
1141.1Scgd.endif
1151.1Scgd
1161.258Sgehenna# -rw-rw-r--
1171.172Sross.if !empty(DISTRIBVER:M*.99.*)
1181.148SthorpejBIN2+=	motd.current
1191.81SthorpejFILESNAME_motd.current=	motd
1201.81Sthorpej.elif !empty(DISTRIBVER:M*BETA*)
1211.81SthorpejBIN2+=	motd.beta
1221.81SthorpejFILESNAME_motd.beta=	motd
1231.81Sthorpej.elif !empty(DISTRIBVER:M*RC*)
1241.81SthorpejBIN2+=	motd.rc
1251.233SthorpejFILESNAME_motd.rc=	motd
1261.233Sthorpej.elif !empty(DISTRIBVER:M*STABLE*)
1271.233SthorpejBIN2+=	motd.stable
1281.233SthorpejFILESNAME_motd.stable=	motd
1291.81Sthorpej.else
1301.81SthorpejBIN2+=	motd
1311.229Ssommerfe.endif
1321.229Ssommerfe
1331.229Ssommerfe# -rw-------
1341.229SsommerfeBIN3+=	hosts.equiv
1351.155Sross
1361.143SmattSYSPKG=	etc
1371.266SraggeETC_PKG=-T etc_pkg
1381.266SraggeBASE_PKG=-T base_pkg
1391.245SchsETC_INSTALL_FILE=cd ${.CURDIR} && ${INSTALL_FILE} ${ETC_PKG}
1401.1ScgdETC_INSTALL_OBJ_FILE=cd ${.OBJDIR} && ${INSTALL_FILE} ${ETC_PKG}
1411.295Schristos
1421.86Sleo.if ${TARGET_ENDIANNESS} == "1234"
1431.1ScgdPWD_MKDB_ENDIAN=	-L
1441.7Scgd.elif ${TARGET_ENDIANNESS} == "4321"
1451.7ScgdPWD_MKDB_ENDIAN=	-B
1461.1Scgd.else
1471.7ScgdPWD_MKDB_ENDIAN=
1481.7Scgd.endif
1491.1Scgd
1501.1Scgd
1511.210Sthorpej# distribution --
1521.210Sthorpej#	Build a distribution
1531.1Scgd#
1541.1Scgddistribution: .PHONY .MAKE check_DESTDIR distrib-dirs
1551.1Scgd.if !defined(DISTRIBUTION_DONE)
1561.1Scgd.if !defined(INSTALL_DONE)
1571.1Scgd	${MAKEDIRTARGET} ${NETBSDSRCDIR} include _DISTRIB=
1581.337Smatt	${MAKEDIRTARGET} ${NETBSDSRCDIR} install _DISTRIB=
1591.1Scgd.endif	# !INSTALL_DONE
1601.1Scgd	${MAKEDIRTARGET} . install-etc-files
1611.79Sveego.if ${MKX11} != "no"
1621.79Sveego	${MAKEDIRTARGET} ${NETBSDSRCDIR}/x11 distribution
1631.29Scgd.endif
1641.1Scgd	${MAKEDIRTARGET} ${NETBSDSRCDIR}/distrib/sets makesetfiles
1651.1Scgd.endif	# !DISTRIBUTION_DONE
1661.337Smatt
1671.1Scgd
1681.280SwizCLEANFILES+=	MAKEDEV
1691.7ScgdMAKEDEV: .EXEC
1701.7Scgd	${_MKTARGET_CREATE}
1711.102Scgd	MACHINE=${MACHINE:Q} MACHINE_ARCH=${MACHINE_ARCH:Q} \
1721.81Sthorpej	    NETBSDSRCDIR=${NETBSDSRCDIR:Q} \
1731.123Sthorpej	    awk -f ${.CURDIR}/MAKEDEV.awk ${.CURDIR}/MAKEDEV.tmpl > ${.TARGET}
1741.123Sthorpej
1751.337SmattRELEASEVARS=	BSDOBJDIR BSDSRCDIR BUILDID \
1761.123Sthorpej		DESTDIR EXTERNAL_TOOLCHAIN HAVE_GCC HAVE_GDB \
1771.123Sthorpej		INSTALLWORLDDIR \
1781.89Smjacob		KERNARCHDIR KERNCONFDIR KERNOBJDIR KERNSRCDIR \
1791.89Smjacob		MACHINE MACHINE_ARCH MAKE MAKECONF MAKEFLAGS \
1801.309Sad		MAKEOBJDIR MAKEOBJDIRPREFIX MAKEVERBOSE \
1811.81Sthorpej		MKBFD MKCATPAGES \
1821.81Sthorpej		MKCRYPTO MKCRYPTO_IDEA MKCRYPTO_MDC2 MKCRYPTO_RC5 MKCVS \
1831.81Sthorpej		MKDEBUG MKDEBUGLIB MKDOC MKDYNAMICROOT \
1841.81Sthorpej		MKGCC MKGCCCMDS MKGDB \
1851.30Scgd		MKHESIOD MKHOSTOBJ MKHTML MKIEEEFP MKINET6 MKINFO MKIPFILTER \
1861.36Scgd		MKKERBEROS MKLDAP MKLINKLIB MKLINT \
1871.36Scgd		MKMAN MKMANZ MKNLS MKNVI MKOBJ MKOBJDIRS \
1881.36Scgd		MKPAM MKPF MKPIC MKPICINSTALL MKPICLIB MKPOSTFIX MKPROFILE \
1891.241Sross		MKSHARE MKSKEY MKSOFTFLOAT MKSTATICLIB \
1901.30Scgd		MKUNPRIVED MKUPDATE MKX11 MKYP \
1911.110Sthorpej		NBUILDJOBS NETBSDSRCDIR \
1921.110Sthorpej		NOCLEANDIR NODISTRIBDIRS NOINCLUDES \
1931.110Sthorpej		OBJMACHINE \
1941.110Sthorpej		RELEASEDIR RELEASEMACHINEDIR TOOLCHAIN_MISSING TOOLDIR \
1951.110Sthorpej		USE_HESIOD USE_INET6 USE_JEMALLOC USE_KERBEROS USE_LDAP \
1961.110Sthorpej		USE_PAM USE_SKEY USE_YP \
1971.110Sthorpej		USETOOLS USR_OBJMACHINE \
1981.110Sthorpej		X11SRCDIR
1991.316Sdsl
2001.316Sdslparams: .PHONY
2011.316Sdsl.for var in ${RELEASEVARS}
2021.316Sdsl.if defined(${var})
2031.316Sdsl	@printf "%20s = '%-s'\n" ${var} ${${var}:Q}
2041.316Sdsl.else
2051.33Scgd	@printf "%20s = (undefined)\n" ${var}
2061.334Smatt.endif
2071.334Smatt.endfor
2081.334Smatt
2091.334SmattCLEANFILES+=	etc-release
2101.334Smattetc-release: .EXEC .MAKE
2111.334Smatt	${_MKTARGET_CREATE}
2121.334Smatt	@(	echo "NetBSD ${DISTRIBVER}/${MACHINE}"; \
2131.334Smatt		echo ; \
2141.334Smatt		cat ${NETBSDSRCDIR}/sys/conf/copyright; \
2151.334Smatt		echo ; \
2161.334Smatt		echo "Build settings:"; \
2171.55Scgd		printf "%20s   %s\n"  "Build date" "$$(date -u)"; \
2181.318Sdsl		printf "%20s   %s\n"  "Built by" "$${USER-root}@$$(hostname)"; \
2191.318Sdsl		echo ; \
2201.318Sdsl		(cd ${.CURDIR}; ${MAKE} ${MFLAGS} -j1 params); \
2211.318Sdsl	) >${.OBJDIR}/${.TARGET}
2221.318Sdsl
2231.318Sdslinstall-etc-release: .PHONY etc-release
2241.1Scgd	${_MKMSG_INSTALL} etc/release
2251.95Sthorpej	${ETC_INSTALL_OBJ_FILE} -o ${BINOWN} -g ${BINGRP} -m 444 \
2261.1Scgd	    etc-release ${DESTDIR}/etc/release
2271.110Sthorpej
2281.7Scgd
2291.110SthorpejFILESDIR=		/etc
2301.324SrmindCONFIGFILES=
2311.324SrmindCONFIGSYMLINKS=
2321.140Sthorpej
2331.211Sthorpej.for file in ${BIN1}
2341.211SthorpejCONFIGFILES+=		${file}
2351.1ScgdFILESMODE_${file:T}=	644
2361.209Sthorpej.endfor
2371.209Sthorpej
2381.106Scgd.for file in ${BIN2}
2391.106ScgdCONFIGFILES+=		${file}
2401.1ScgdFILESMODE_${file:T}=	664
2411.1Scgd.endfor
2421.77Scgd
2431.1Scgd.for file in ${BIN3}
2441.1ScgdCONFIGFILES+=		${file}
2451.77ScgdFILESMODE_${file:T}=	600
2461.32Scgd.endfor
2471.37Scgd
2481.32Scgd.if (${MKPOSTFIX} != "no")
2491.248SthorpejCONFIGFILES+=		aliases
2501.248SthorpejFILESDIR_aliases=	/etc/mail
2511.248SthorpejFILESMODE_aliases=	644
2521.1Scgd.endif
2531.211Sthorpej
2541.211SthorpejCONFIGFILES+=		MAKEDEV.local
2551.189SthorpejFILESDIR_MAKEDEV.local=	/dev
2561.189SthorpejFILESMODE_MAKEDEV.local=${BINMODE}
2571.189Sthorpej
2581.189SthorpejCONFIGFILES+=		crontab
2591.189SthorpejFILESDIR_crontab=	/var/cron/tabs
2601.237SthorpejFILESNAME_crontab=	root
2611.237SthorpejFILESMODE_crontab=	600
2621.189Sthorpej
2631.189SthorpejCONFIGFILES+=		minfree
2641.211SthorpejFILESDIR_minfree=	/var/crash
2651.211SthorpejFILESMODE_minfree=	600
2661.211Sthorpej
2671.1ScgdCONFIGSYMLINKS+=	${TZDIR}/${LOCALTIME}	/etc/localtime \
2681.106Scgd			/usr/sbin/rmt		/etc/rmt
2691.106Scgd
2701.81Sthorpej
2711.106Scgd# install-etc-files --
2721.81Sthorpej#	Install etc (config) files; not performed by "make build"
2731.102Scgd#
2741.102Scgdinstall-etc-files: .PHONY .MAKE check_DESTDIR MAKEDEV
2751.102Scgd	${_MKMSG_INSTALL} ${DESTDIR}/etc/master.passwd
2761.102Scgd	${ETC_INSTALL_FILE} -o root -g wheel -m 600 \
2771.102Scgd	    master.passwd ${DESTDIR}/etc
2781.102Scgd	${TOOL_PWD_MKDB} -p ${PWD_MKDB_ENDIAN} -d ${DESTDIR}/ \
2791.102Scgd	    ${DESTDIR}/etc/master.passwd
2801.102Scgd.if ${MKUNPRIVED} != "no"
2811.102Scgd	( \
2821.102Scgd		for metaent in passwd pwd.db spwd.db; do \
2831.106Scgd	    		echo "./etc/$${metaent} type=file mode=0644 uname=root gname=wheel tags=etc_pkg"; \
2841.106Scgd		done; \
2851.106Scgd	) | ${METALOG.add}
2861.106Scgd.endif	# MKUNPRIVED != no
2871.106Scgd	${_MKMSG_INSTALL} ${DESTDIR}/etc/ttys
2881.106Scgd	${ETC_INSTALL_OBJ_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
2891.106Scgd	    ${.CURDIR}/etc.${MACHINE}/ttys ${DESTDIR}/etc
2901.106Scgd.if exists(etc.${MACHINE}/boot.cfg)
2911.106Scgd	${_MKMSG_INSTALL} ${DESTDIR}/boot.cfg
2921.106Scgd	${ETC_INSTALL_OBJ_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
2931.106Scgd	    ${.CURDIR}/etc.${MACHINE}/boot.cfg ${DESTDIR}/
2941.247Sthorpej.endif
2951.102Scgd	${_MKMSG_INSTALL} ${DESTDIR}/dev/MAKEDEV
2961.102Scgd	${ETC_INSTALL_OBJ_FILE} -o ${BINOWN} -g ${BINGRP} -m 555 \
2971.247Sthorpej	    MAKEDEV ${DESTDIR}/dev
2981.102Scgd.for owner group mode file in \
2991.102Scgd		${BINOWN} operator	664	/etc/dumpdates  \
3001.106Scgd		${BINOWN} operator	600	/etc/skeykeys \
3011.106Scgd		root wheel		600	/var/at/at.deny \
3021.106Scgd		nobody ${BINGRP}	664	/var/db/locate.database \
3031.337Smatt		${BINOWN} ${BINGRP}	600	/var/log/authlog \
3041.102Scgd		root wheel		600	/var/log/cron \
3051.81Sthorpej		${BINOWN} ${UTMPGRP}	664	/var/log/lastlog \
3061.102Scgd		${BINOWN} ${UTMPGRP}	664	/var/log/lastlogx \
3071.81Sthorpej		${BINOWN} ${BINGRP}	640	/var/log/lpd-errs \
3081.106Scgd		${BINOWN} ${BINGRP}	600	/var/log/maillog \
3091.102Scgd		${BINOWN} ${BINGRP}	644	/var/log/messages \
3101.81Sthorpej		${BINOWN} ${BINGRP}	600	/var/log/secure \
3111.102Scgd		${BINOWN} ${UTMPGRP}	664	/var/log/wtmp \
3121.106Scgd		${BINOWN} ${UTMPGRP}	664	/var/log/wtmpx \
3131.102Scgd		${BINOWN} ${BINGRP}	600	/var/log/xferlog \
3141.102Scgd		daemon staff		664	/var/msgs/bounds \
3151.102Scgd		${BINOWN} ${UTMPGRP}	664	/var/run/utmp \
3161.106Scgd		${BINOWN} ${UTMPGRP}	664	/var/run/utmpx \
3171.106Scgd		games games		664	/var/games/atc_score \
3181.106Scgd		games games		664	/var/games/battlestar.log \
3191.102Scgd		games games		664	/var/games/cfscores \
3201.102Scgd		games games		664	/var/games/criblog \
3211.102Scgd		games games		660	/var/games/hackdir/perm \
3221.102Scgd		games games		660	/var/games/hackdir/record \
3231.102Scgd		games games		664	/var/games/larn/llog12.0 \
3241.102Scgd		games games		664	/var/games/larn/lscore12.0 \
3251.102Scgd		games games		664	/var/games/larn/playerids \
3261.102Scgd		games games		664	/var/games/robots_roll \
3271.81Sthorpej		games games		664	/var/games/rogue.scores \
3281.106Scgd		games games		664	/var/games/saillog \
3291.106Scgd		games games		664	/var/games/snakerawscores \
3301.106Scgd		games games		664	/var/games/snake.log \
3311.106Scgd		games games		664	/var/games/tetris.scores
3321.123Sthorpej	${_MKMSG_INSTALL} ${DESTDIR}${file}
3331.123Sthorpej	${ETC_INSTALL_FILE} -o ${owner} -g ${group} -m ${mode} \
3341.123Sthorpej	    	/dev/null ${DESTDIR}${file}
3351.123Sthorpej.endfor
3361.123Sthorpej.for subdir in . atf defaults bluetooth iscsi mtree namedb pam.d powerd rc.d root skel ssh
3371.123Sthorpej	${MAKEDIRTARGET} ${subdir} configinstall
3381.123Sthorpej.endfor
3391.123Sthorpej	${MAKEDIRTARGET} ${NETBSDSRCDIR}/external/bsd/dhcpcd/sbin/dhcpcd configinstall
3401.123Sthorpej	${MAKEDIRTARGET} ${NETBSDSRCDIR}/usr.bin/mail configinstall
3411.123Sthorpej.if (${MKPF} != "no")
3421.106Scgd	${MAKEDIRTARGET} ${NETBSDSRCDIR}/usr.sbin/pf configinstall
3431.106Scgd.endif
3441.337Smatt.if (${MKCRYPTO} != "no")
3451.106Scgd	${MAKEDIRTARGET} ${NETBSDSRCDIR}/usr.bin/ssh configinstall
3461.106Scgd.endif
3471.106Scgd.if (${MKPOSTFIX} != "no")
3481.106Scgd	${MAKEDIRTARGET} ${NETBSDSRCDIR}/gnu/usr.sbin/postfix configinstall
3491.106Scgd.endif
3501.251Swiz
3511.106Scgd
3521.106Scgd# install-obsolete-lists --
3531.106Scgd#	Install var/db/obsolete set lists; this is performed by "make build"
3541.106Scgd#
3551.106ScgdOBSOLETE.dir=		${.OBJDIR}/obsolete.dir
3561.106ScgdOBSOLETE.files=		base comp etc games man misc tests text
3571.106Scgd.if ${MKX11} != "no"
3581.106ScgdOBSOLETE.files+=	xbase xcomp xetc xfont xserver
3591.106Scgd.endif
3601.106Scgd
3611.106Scgdinstall-obsolete-lists: .PHONY .MAKE
3621.106Scgd	mkdir -p ${OBSOLETE.dir}
3631.147Sthorpej.if ${MKX11} != "no"
3641.147Sthorpej	(cd ${NETBSDSRCDIR}/distrib/sets && \
3651.1Scgd	    MAKE=${MAKE:Q} ${HOST_SH} ./makeobsolete -b -t ${OBSOLETE.dir})
3661.1Scgd.else
3671.263Sthorpej	(cd ${NETBSDSRCDIR}/distrib/sets && \
3681.263Sthorpej	    MAKE=${MAKE:Q} ${HOST_SH} ./makeobsolete -t ${OBSOLETE.dir})
3691.243Sthorpej.endif
3701.263Sthorpej.for file in ${OBSOLETE.files}
3711.263Sthorpej	${_MKMSG_INSTALL} ${DESTDIR}/var/db/obsolete/${file}
3721.263Sthorpej	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
3731.263Sthorpej	    ${OBSOLETE.dir}/${file} ${DESTDIR}/var/db/obsolete
3741.243Sthorpej.endfor
3751.243Sthorpej
3761.243Sthorpej
3771.106Scgd# distrib-dirs --
3781.106Scgd#	Populate $DESTDIR with directories needed by NetBSD
3791.106Scgd#
3801.167Scgd.if ${MKUNPRIVED} == "no"
3811.167ScgdTOOL_MTREE.unpriv=
3821.167Scgd.else
3831.167ScgdTOOL_MTREE.unpriv=	-W
3841.167Scgd.endif
3851.167Scgd
3861.167Scgddistrib-dirs: .PHONY check_DESTDIR
3871.167Scgd.if !defined(DISTRIBUTION_DONE)						# {
3881.209Sthorpej# XXX: If METALOG=${DESTDIR}/METALOG (as is normal), and if ${DESTDIR}
3891.209Sthorpej# does not yet exist (as often happens), then the INSTALL_DIR command
3901.106Scgd# immediately below will create ${DESTDIR} but will fail to register
3911.106Scgd# an entry for "." in the metalog.  We ignore the problem, because the
3921.106Scgd# TOOL_MTREE commands a little further below will soon register an entry
3931.209Sthorpej# for "." in the metalog.
3941.106Scgd	${INSTALL_DIR} -o root -g wheel -m 755 ${BASE_PKG} ${DESTDIR}
3951.106Scgd# XXX: It would be nice if a single mtree invocation could both
3961.106Scgd# append to the metalog and do real work.  Instead, we have to
3971.251Swiz# repeat the command twice in slightly different ways.
3981.106Scgd	${TOOL_MTREE} -def ${.CURDIR}/mtree/NetBSD.dist -N ${.CURDIR} \
3991.106Scgd	    -p ${DESTDIR}/ -U ${TOOL_MTREE.unpriv}
4001.169Sthorpej.if ${MKUNPRIVED} != "no"						# {
4011.106Scgd	${TOOL_MTREE} -def ${.CURDIR}/mtree/NetBSD.dist -N ${.CURDIR} \
4021.106Scgd	    -p ${DESTDIR}/ -C -k all | \
4031.106Scgd	    awk '/ optional/ {next} // {print}' | ${METALOG.add}
4041.106Scgd.endif	# MKUNPRIVED							# }
4051.199Ssoren.endif	# DISTRIBUTION_DONE						# }
4061.211Sthorpej
4071.106Scgd# release, snapshot --
4081.116Smjacob#	Build a full distribution including kernels & install media.
4091.116Smjacob#
4101.116Smjacobrelease snapshot: .PHONY .MAKE check_DESTDIR check_RELEASEDIR snap_md_post
4111.116Smjacob	${MAKEDIRTARGET} ${NETBSDSRCDIR}/distrib/sets sets
4121.116Smjacob	${MAKESUMS} -A -t ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets \
4131.106Scgd		${KERNEL_SETS:@.SETS.@kern-${.SETS.}.tgz@}
4141.106Scgd	${MAKESUMS} -t ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/kernel '*.gz'
4151.106Scgd
4161.106Scgd
4171.106Scgd# iso-image --
4181.106Scgd#	Standalone target to create a CDROM image after the release
4191.106Scgd#	was composed.  Should be run after "make release" in src and xsrc.
4201.106Scgd#	The do-iso-image is to be called from etc.$MACHINE/Makefile.inc
4211.106Scgd#
4221.106Scgd#	Note: At least mkisofs 2.0 should be used.
4231.106Scgd#
4241.95SthorpejCDROM_NAME_ADD?=
4251.95SthorpejCDROM.image?=${RELEASEDIR}/iso/${MACHINE}cd.iso
4261.101ScgdCDROM.dir=	${.OBJDIR}/cdrom.dir
4271.101ScgdCDROM.pathlist=	${.OBJDIR}/cdrom.pathlist
4281.101Scgd
4291.95Sthorpejiso-image:
4301.201Skleink
4311.309Sad.if ${MKISOFS} != true
4321.102Scgddo-iso-image: .PHONY check_DESTDIR check_RELEASEDIR iso-image-md-post
4331.102Scgd	${MAKESUMS} -t ${RELEASEDIR}/iso/ '*.iso'
4341.201Skleink	@echo "iso-image created as: ${CDROM.image}"
4351.102Scgd.else
4361.201Skleinkdo-iso-image:
4371.95Sthorpej	@echo iso-image: mkisofs not found
4381.95Sthorpej.endif
4391.110Sthorpej
4401.110Sthorpejiso-image-setup: .PHONY check_RELEASEDIR
4411.110Sthorpej	rm -f ${CDROM.pathlist}
4421.95Sthorpej.for extra in README SOURCE_DATE source
4431.1Scgd.if exists(${RELEASEDIR}/${extra})
4441.7Scgd	echo "${extra}=${RELEASEDIR}/${extra}" >> ${CDROM.pathlist}
4451.7Scgd.endif
4461.7Scgd.endfor
4471.1Scgd	echo "${MACHINE}/=${RELEASEDIR}/${RELEASEMACHINEDIR}/" >> ${CDROM.pathlist}
4481.296Syamt	mkdir -p ${CDROM.dir}
4491.7Scgd	mkdir -p ${RELEASEDIR}/${RELEASEMACHINEDIR}/installation/cdrom
4501.110Sthorpej
4511.7Scgd# iso-image-mi --
4521.110Sthorpej#	Create the image after the MD operations have completed.
4531.7Scgd#
4541.160Sthorpejiso-image-mi: .PHONY check_DESTDIR check_RELEASEDIR iso-image-md-pre
4551.110Sthorpej	@if ! ${MKISOFS} --version; then \
4561.7Scgd		echo "install pkgsrc/sysutils/cdrtools and run 'make iso-image'." ; \
4571.7Scgd		false; \
4581.110Sthorpej	fi
4591.110Sthorpej	${MKISOFS} ${MKISOFS_FLAGS} -graft-points -path-list ${CDROM.pathlist} \
4601.110Sthorpej	    -o ${CDROM.image} ${CDROM.dir}
4611.110Sthorpej
4621.110Sthorpej# iso-image-md-pre --
4631.110Sthorpej#	Setup ${CDROM.dir} to produce a bootable CD image.
4641.110Sthorpej#	Overridden by etc.$MACHINE/Makefile.inc
4651.110Sthorpej#
4661.110Sthorpejiso-image-md-pre: .PHONY check_DESTDIR check_RELEASEDIR iso-image-setup
4671.110Sthorpej#	(empty -- look in the machine-dependent Makefile.inc)
4681.110Sthorpej
4691.110Sthorpej# iso-image-md-post --
4701.110Sthorpej#	Fixup the CD-image to be bootable.
4711.110Sthorpej#	Overridden by etc.$MACHINE/Makefile.inc
4721.110Sthorpej#
4731.110Sthorpejiso-image-md-post: .PHONY check_DESTDIR check_RELEASEDIR iso-image-mi
4741.110Sthorpej#	(empty -- look in the machine-dependent Makefile.inc)
4751.110Sthorpej
4761.110Sthorpej
4771.110Sthorpej# snap_pre --
4781.110Sthorpej#	Create ${RELEASEDIR} and necessary subdirectories.
4791.110Sthorpej#
4801.110Sthorpejsnap_pre: .PHONY check_DESTDIR check_RELEASEDIR distribution
4811.110Sthorpej	${INSTALL} -d -m 755 ${RELEASEDIR}
4821.110Sthorpej.if ${MKUPDATE} == "no"
4831.110Sthorpej# Could be a mount point, ignore the errors
4841.110Sthorpej	-/bin/rm -rf ${RELEASEDIR}/${RELEASEMACHINEDIR}
4851.110Sthorpej.endif
4861.7Scgd	${INSTALL} -d -m 755 ${RELEASEDIR}/${RELEASEMACHINEDIR}
4871.110Sthorpej.for dir in ${INSTALLATION_DIRS}
4881.110Sthorpej	${INSTALL} -d -m 755 ${RELEASEDIR}/${RELEASEMACHINEDIR}/${dir}
4891.110Sthorpej.endfor
4901.110Sthorpej
4911.7Scgd# snap_post --
4921.110Sthorpej#	Build the install media and notes from distrib
4931.110Sthorpej#
4941.110Sthorpejsnap_post: .PHONY .MAKE build_kernelsets build_releasekernels
4951.110Sthorpej.if ${MKUPDATE} == "no"
4961.110Sthorpej	cd ${NETBSDSRCDIR}/distrib && ${MAKE} cleandir
4971.110Sthorpej.endif
4981.110Sthorpej	cd ${NETBSDSRCDIR}/distrib && ${MAKE} depend && ${MAKE} && \
4991.110Sthorpej	    ${MAKE} release
5001.110Sthorpej
5011.110Sthorpej# build kernels --
5021.110Sthorpej#	This target builds the kernels specified by each port.
5031.110Sthorpej#	A port may specify the following kernels:
5041.110Sthorpej#
5051.110Sthorpej#	KERNEL_SETS		The list of kernels that will be
5061.110Sthorpej#				packaged into sets, named
5071.110Sthorpej#				kern-${kernel}.tgz.  These kernels
5081.110Sthorpej#				are also placed in the binary/kernel
5091.110Sthorpej#				area of the release package as
5101.110Sthorpej#				netbsd-${kernel}.gz.
5111.110Sthorpej#
5121.110Sthorpej#	EXTRA_KERNELS		Additional kernels to place in the
5131.110Sthorpej#				binary/kernel area of the release
5141.110Sthorpej#				package as netbsd-${kernel}.gz, but
5151.110Sthorpej#				which are not placed into sets. This
5161.110Sthorpej#				allows a port to provide e.g. a netbootable
5171.110Sthorpej#				installation kernel containing a ramdisk.
5181.110Sthorpej#
5191.110Sthorpej#	BUILD_KERNELS		Additional kernels to build which are
5201.110Sthorpej#				not placed into sets nor into the
5211.110Sthorpej#				binary/kernel area of the release
5221.110Sthorpej#				package.  These are typically kernels
5231.110Sthorpej#				that are built for inclusion only in
5241.110Sthorpej#				installation disk/CD-ROM/tape images.
5251.110Sthorpej#
5261.110Sthorpej#	A port may also specify KERNEL_SUFFIXES, which is an optional list
5271.110Sthorpej#	of filename suffixes for kernels to include in the kernel sets and
5281.110Sthorpej#	in the binary/kernel area of the release package (e.g. "netbsd" vs.
5291.110Sthorpej#	"netbsd.ecoff" and "netbsd.srec").  It is not an error if kernels
5301.110Sthorpej#	with these suffixes do not exist in the kernel build directory.
5311.110Sthorpej#
5321.110Sthorpej#
5331.110Sthorpej# A list of all the kernels to build, which can be overridden from
5341.110Sthorpej# external sources (such as make(1)'s environment or command line)
5351.110Sthorpej#
5361.110SthorpejALL_KERNELS?=	${KERNEL_SETS} ${EXTRA_KERNELS} ${BUILD_KERNELS}
5371.110Sthorpej
5381.110SthorpejGETKERNELAWK=	awk '/^config/ {print $$2; found=1} \
5391.112Sthorpej		END{ if (found == 0) print "netbsd"; }'
5401.135Sthorpej
5411.110Sthorpejbuild_kernels: .PHONY
5421.110Sthorpej#	Configure & compile kernels listed in ${ALL_KERNELS}
5431.110Sthorpej#
5441.110Sthorpej# The 'sync' is so that all writes during the build are pushed back
5451.110Sthorpej# to the disk.  Not having it causes problems on some host systems
5461.110Sthorpej# (e.g. Linux) when building on NFS.
5471.110Sthorpej#
5481.110Sthorpej.if !defined(KERNELS_DONE)						# {
5491.110Sthorpej.for configfile in ${ALL_KERNELS}					# {
5501.110Sthorpejbuild_kernels: kern-${configfile}
5511.110Sthorpejkern-${configfile}: .PHONY .MAKE
5521.110Sthorpej	cd ${KERNCONFDIR} && ${TOOL_CONFIG} -s ${KERNSRCDIR} \
5531.112Sthorpej	    -b ${KERNOBJDIR}/${configfile:C/.*\///} ${configfile}
5541.135Sthorpej.if ${MKUPDATE} == "no"
5551.110Sthorpej	cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} distclean
5561.110Sthorpej.endif
5571.110Sthorpej	cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} depend && ${MAKE}
5581.110Sthorpej	sync
5591.110Sthorpej.endfor	# ALL_KERNELS							# }
5601.110Sthorpej.endif	# KERNELS_DONE							# }
5611.110Sthorpej
5621.110Sthorpejbuild_kernelsets: .PHONY
5631.110Sthorpej#	Create kernel sets from ${KERNEL_SETS} into
5641.135Sthorpej#	${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets
5651.135Sthorpej#
5661.7Scgd.for configfile in ${KERNEL_SETS}					# {
5671.110Sthorpejbuild_kernelsets: kernset-${configfile}
5681.110Sthorpejkernset-${configfile}: .PHONY build_kernels snap_pre
5691.110Sthorpej	@ kernlist=`${GETKERNELAWK} ${KERNCONFDIR}/${configfile}`; \
5701.7Scgd	kerndir=${KERNOBJDIR}/${configfile:C/.*\///}; \
5711.7Scgd	kernsuffixes="${KERNEL_SUFFIXES:S/^/./}"; \
5721.110Sthorpej	kern_tgz=${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets/kern-${configfile}.tgz; \
5731.110Sthorpej	pax_cmd="GZIP=-9 ${TOOL_PAX} -O -zw -M -N ${NETBSDSRCDIR}/etc -f $${kern_tgz}"; \
5741.110Sthorpej	cd $${kerndir} && { \
5751.7Scgd		kernels=; newest=; \
5761.46Schristos		for kernel in $${kernlist}; do \
5771.46Schristos			for s in "" $${kernsuffixes}; do \
5781.2Scgd				ks="$${kernel}$${s}"; \
5791.46Schristos				[ -f $${ks} ] || continue; \
5801.46Schristos				kernels="$${kernels} $${ks}"; \
5811.2Scgd				[ -z "$${newest}" -o $${ks} -nt "$${newest}" ] && \
5821.46Schristos					newest=$${ks}; \
5831.2Scgd			done; \
5841.46Schristos		done; \
5851.2Scgd		[ $${kern_tgz} -nt "$${newest}" ] || { \
5861.46Schristos			echo "echo $${kernels} | $${pax_cmd}"; \
5871.2Scgd			( echo "/set uname=${BINOWN} gname=${BINGRP}"; \
5881.46Schristos			echo ". type=dir optional"; \
5891.2Scgd			for kernel in $${kernels}; do \
5901.46Schristos				echo "./$${kernel} type=file"; \
5911.2Scgd			done ) | eval $${pax_cmd}; \
5921.46Schristos		} \
5931.2Scgd	}
5941.2Scgd.endfor	# KERNEL_SETS							# }
5951.46Schristos
5961.2Scgdbuild_releasekernels: .PHONY
5971.2Scgd#	Build kernel.gz from ${KERNEL_SETS} ${EXTRA_KERNELS} into
5981.7Scgd#	${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/kernel
5991.1Scgd#
6001.1Scgd.for configfile in ${KERNEL_SETS} ${EXTRA_KERNELS}			# {
6011.7Scgdbuild_releasekernels: releasekern-${configfile}
6021.46Schristosreleasekern-${configfile}: .PHONY build_kernels snap_pre
6031.46Schristos	@ kernlist=`${GETKERNELAWK} ${KERNCONFDIR}/${configfile:C/.*\///}`; \
6041.46Schristos	kerndir=${KERNOBJDIR}/${configfile:C/.*\///}; \
6051.46Schristos	kernsuffixes="${KERNEL_SUFFIXES:S/^/./}"; \
6061.46Schristos	cd $${kerndir} && {	\
6071.7Scgd		for kernel in $${kernlist}; do \
6081.7Scgd			for s in "" $${kernsuffixes}; do \
6091.1Scgd				ks="$${kernel}$${s}"; \
6101.1Scgd				[ ! -f $${ks} ] && continue; \
6111.1Scgd				knl_gz="${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/kernel/$${ks}-${configfile:C/.*\///}.gz"; \
6121.110Sthorpej				[ $${knl_gz} -nt $${ks} ] && continue; \
6131.204Senami				rm -f $${knl_gz}; \
6141.203Senami				echo "gzip -c -9 < $${kerndir}/$${ks} > $${knl_gz}"; \
6151.110Sthorpej				gzip -c -9 < $${ks} > $${knl_gz}; \
6161.328Suebayasi			done; \
6171.110Sthorpej		done; \
6181.110Sthorpej	}
6191.110Sthorpej.endfor	# KERNEL_SETS EXTRA_KERNELS					# }
6201.110Sthorpej
6211.110Sthorpej# snap_md_post --
6221.110Sthorpej#	Machine dependent distribution media operations.
6231.110Sthorpej#	Overridden by etc.$MACHINE/Makefile.inc
6241.295Schristos#
6251.110Sthorpejsnap_md_post: .PHONY check_DESTDIR check_RELEASEDIR snap_post
6261.110Sthorpej#	(empty -- look in the machine-dependent Makefile.inc)
6271.110Sthorpej
6281.110Sthorpej
6291.110Sthorpejclean:
6301.110Sthorpej	-rm -rf ${CDROM.dir} ${CDROM.pathlist} ${OBSOLETE.dir}
6311.110Sthorpej
6321.203Senami.include <bsd.prog.mk>
6331.203Senami
6341.203Senamitest:
6351.268Sthorpej	@echo ${OBSOLETE.files}
6361.110Sthorpej