Makefile revision 1.132
11.132Sjlam#	$NetBSD: Makefile,v 1.132 2000/02/05 18:25:01 jlam 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.96Scjs#	${KERNSRCDIR}/arch/${MACHINE}/compile/KERNELNAME, but can be
161.96Scjs#	overridden.
171.96Scjs#   KERNCONFDIR is where the configuration files for kernels are found;
181.96Scjs#	default is ${KERNSRCDIR}/arch/${MACHINE}/conf but can be overridden.
191.97Scjs#   UPDATE is normally undefined; if defined, don't do a 'make clean'
201.97Scjs#	before kernel compile
211.96Scjs#   NO_SENDMAIL is normally undefined; if defined, it will not do a
221.96Scjs#	`make distribution' in the sendmail config file source directory.
231.96Scjs#   EXTRA_KERNELS has a machine-dependent list of kernels to build added
241.96Scjs#	to it, but you may also set this to have extra ones built.
251.119Sross#   BUILD_KERNELS are a machine-dependent list of kernels that should just
261.119Sross#	be built in place but not made into sets or installed, e.g., an
271.119Sross#	INSTALL kernel used later in src/distrib/.
281.96Scjs# 
291.96Scjs# Targets:
301.96Scjs#    distribution: makes a full NetBSD distribution in DESTDIR. If
311.96Scjs#	INSTALL_DONE is set, it will not do a `make install.'
321.96Scjs#    distrib-dirs: creates an empty NetBSD directory tree in DESTDIR.
331.96Scjs#	Called by distribution.
341.96Scjs#    snapshot: calls distribution, above, and then tars up the files
351.96Scjs#	into a release(7) format in RELEASEDIR. Any port-dependent
361.96Scjs#	stuff for this target is found in etc.${MACHINE}/Makefile.inc.
371.106Scjs#    release: a synonym for `snapshot'
381.96Scjs
391.130Sveego# XXX: For NO_SENDMAIL and INSTPRIV
401.90Skim.include <bsd.own.mk>
411.90Skim
421.23ScgdTZDIR=		/usr/share/zoneinfo
431.90SkimLOCALTIME?=	US/Pacific
441.19Sderaadt
451.55Sperry# setting NOOBJ prevents "make obj" from doing anything;
461.55Sperry# an objdir would break the installation stuff below
471.101SlukemMKOBJ=	no
481.1Scgd
491.80Sjonathan# MD Makefile.inc may append MD targets to BIN[123].  Make sure all
501.80Sjonathan# are empty, to preserve the old semantics of setting them below with "=".
511.80SjonathanBIN1=	
521.80SjonathanBIN2=
531.80SjonathanBIN3=
541.80Sjonathan
551.117Ssimonb# Directories to build in ${RELEASEDIR}.   MD Makefile.inc files can
561.117Ssimonb# add to this.
571.117Ssimonb# NOTE: Parent directories must be listed before subdirectories.
581.117SsimonbINSTALLATION_DIRS= \
591.117Ssimonb	binary binary/sets binary/kernel binary/security installation
601.117Ssimonb
611.71Scjs.if exists(etc.${MACHINE}/Makefile.inc)
621.71Scjs.include "etc.${MACHINE}/Makefile.inc"
631.71Scjs.endif
641.32Sjtc
651.96Scjs# Use multiple jobs for kernel builds, if NBUILDJOBS set.
661.96Scjs# (Taken from src/Makefile.)
671.96Scjs.if defined(NBUILDJOBS)
681.96Scjs_J= -j${NBUILDJOBS}
691.96Scjs.endif
701.96Scjs
711.21Scgd# -rw-r--r--
721.21ScgdBINOWN= root
731.21ScgdBINGRP= wheel
741.131SveegoBIN1+=	bootptab changelist csh.cshrc csh.login csh.logout daily \
751.131Sveego	daily.conf dm.conf floppytab ftpchroot ftpusers ftpwelcome \
761.131Sveego	gettytab group hosts hosts.lpd inetd.conf lkm.conf \
771.131Sveego	mailer.conf man.conf monthly monthly.conf mrouted.conf \
781.131Sveego	netstart networks newsyslog.conf nsswitch.conf ntp.conf \
791.131Sveego	phones printcap profile protocols rbootd.conf rc rc.conf \
801.131Sveego	rc.lkm rc.local rc.subr rc.shutdown rc.wscons remote rpc \
811.131Sveego	security security.conf services shells syslog.conf weekly \
821.131Sveego	weekly.conf wscons.conf \
831.109Sdrochner	etc.${MACHINE}/ttys etc.${MACHINE}/disktab
841.105Smycroft
851.121Sfvdl.if	(${MACHINE_ARCH} == "m68k") || \
861.105Smycroft	(${MACHINE_ARCH} == "ns32k") || \
871.105Smycroft	(${MACHINE_ARCH} == "vax") || \
881.105Smycroft	(${MACHINE_ARCH} == "arm32")
891.129SchristosBIN1+=	ld.so.conf
901.129Schristos.elif exists(etc.${MACHINE_ARCH}/ld.so.conf)
911.132SjlamBIN1+=	etc.${MACHINE_ARCH}/ld.so.conf
921.105Smycroft.endif
931.120Sitojun
941.120Sitojun# IPv6
951.120SitojunBIN1+=	rtadvd.conf
961.1Scgd
971.46Sderaadt# -rw-rw-r--
981.80SjonathanBIN2+=	motd
991.1Scgd
1001.77Smycroft# -rw-------
1011.80SjonathanBIN3+=	hosts.equiv
1021.77Smycroft
1031.131SveegoNAMEDB=	127 root.cache named.conf 0000:0000:0000:0000:0000:0000:000
1041.1ScgdPCS=	pcs750.bin
1051.1Scgd
1061.88Slukemall clean cleandir depend distclean etc includes install lint:
1071.1Scgd
1081.34Scgd.ifndef DESTDIR
1091.106Scjsdistribution distrib-dirs release snapshot:
1101.36Scgd	@echo setenv DESTDIR before doing that!
1111.34Scgd	@false
1121.34Scgd.else
1131.7Scgddistribution: distrib-dirs
1141.87Sperry.if !defined(INSTALL_DONE)
1151.107Sscottr	(cd ..; ${MAKE} _DISTRIB= includes)
1161.107Sscottr	(cd ..; ${MAKE} _DISTRIB= install)
1171.87Sperry.endif
1181.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 ${BIN1} \
1191.124Ssimonb	    ${DESTDIR}/etc
1201.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 ${BIN2} \
1211.124Ssimonb	    ${DESTDIR}/etc
1221.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 ${BIN3} \
1231.124Ssimonb	    ${DESTDIR}/etc
1241.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 aliases \
1251.124Ssimonb	    ${DESTDIR}/etc
1261.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 crontab \
1271.56Sthorpej	    ${DESTDIR}/var/cron/tabs/root
1281.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 master.passwd \
1291.124Ssimonb	    ${DESTDIR}/etc
1301.68Sperry	pwd_mkdb -p -d ${DESTDIR}/ ${DESTDIR}/etc/master.passwd
1311.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 555 \
1321.1Scgd	     MAKEDEV.local etc.${MACHINE}/MAKEDEV ${DESTDIR}/dev
1331.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 minfree \
1341.73Sperry	    ${DESTDIR}/var/crash
1351.1Scgd	(cd root; \
1361.124Ssimonb		${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.cshrc \
1371.1Scgd		    ${DESTDIR}/root/.cshrc; \
1381.124Ssimonb		${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 dot.klogin \
1391.1Scgd		    ${DESTDIR}/root/.klogin; \
1401.124Ssimonb		${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.login \
1411.1Scgd		    ${DESTDIR}/root/.login; \
1421.124Ssimonb		${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.profile \
1431.1Scgd		    ${DESTDIR}/root/.profile; \
1441.128Smycroft		${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.shrc \
1451.128Smycroft		    ${DESTDIR}/root/.shrc; \
1461.1Scgd		rm -f ${DESTDIR}/.cshrc ${DESTDIR}/.profile; \
1471.1Scgd		ln ${DESTDIR}/root/.cshrc ${DESTDIR}/.cshrc; \
1481.1Scgd		ln ${DESTDIR}/root/.profile ${DESTDIR}/.profile)
1491.83Smrg	(cd mtree; ${MAKE} install)
1501.63Smikel	(cd namedb; \
1511.124Ssimonb		${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 \
1521.124Ssimonb		    ${NAMEDB} ${DESTDIR}/etc/namedb)
1531.19Sderaadt	/bin/rm -f ${DESTDIR}/etc/localtime
1541.19Sderaadt	ln -s ${TZDIR}/${LOCALTIME} ${DESTDIR}/etc/localtime
1551.48Sderaadt	/bin/rm -f ${DESTDIR}/etc/rmt
1561.48Sderaadt	ln -s /usr/sbin/rmt ${DESTDIR}/etc/rmt
1571.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g operator -m 664 /dev/null \
1581.32Sjtc		${DESTDIR}/etc/dumpdates
1591.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g operator -m 600 /dev/null \
1601.44Sderaadt		${DESTDIR}/etc/skeykeys
1611.127Sperry	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 /dev/null \
1621.127Sperry		${DESTDIR}/var/at/at.deny
1631.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 /dev/null \
1641.38Scgd		${DESTDIR}/var/cron/log
1651.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o nobody -g ${BINGRP} -m 664 /dev/null \
1661.32Sjtc		${DESTDIR}/var/db/locate.database
1671.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o uucp -g dialer -m 640 /dev/null \
1681.113Sfair		${DESTDIR}/var/log/aculog
1691.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
1701.69Sperry		${DESTDIR}/var/log/authlog
1711.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \
1721.32Sjtc		${DESTDIR}/var/log/lastlog
1731.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 640 /dev/null \
1741.32Sjtc		${DESTDIR}/var/log/lpd-errs
1751.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
1761.32Sjtc		${DESTDIR}/var/log/maillog
1771.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
1781.32Sjtc		${DESTDIR}/var/log/messages
1791.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
1801.58Slukem		${DESTDIR}/var/log/secure
1811.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
1821.32Sjtc		${DESTDIR}/var/log/wtmp
1831.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
1841.69Sperry		${DESTDIR}/var/log/xferlog
1851.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o daemon -g staff -m 664 /dev/null \
1861.39Scgd		${DESTDIR}/var/msgs/bounds
1871.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \
1881.32Sjtc		${DESTDIR}/var/run/utmp
1891.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
1901.81Smrg		${DESTDIR}/var/games/atc_scores
1911.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
1921.81Smrg		${DESTDIR}/var/games/battlestar.log
1931.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
1941.81Smrg		${DESTDIR}/var/games/cfscores
1951.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
1961.82Sperry		${DESTDIR}/var/games/criblog
1971.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
1981.81Smrg		${DESTDIR}/var/games/robots_roll
1991.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
2001.81Smrg		${DESTDIR}/var/games/rogue.scores
2011.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
2021.81Smrg		${DESTDIR}/var/games/saillog
2031.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
2041.81Smrg		${DESTDIR}/var/games/snakerawscores
2051.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
2061.81Smrg		${DESTDIR}/var/games/snake.log
2071.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
2081.81Smrg		${DESTDIR}/var/games/tetris.scores
2091.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
2101.81Smrg		${DESTDIR}/var/games/larn/llog12.0
2111.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
2121.81Smrg		${DESTDIR}/var/games/larn/lscore12.0
2131.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
2141.81Smrg		${DESTDIR}/var/games/larn/playerids
2151.124Ssimonb	(cd etc.${MACHINE}; ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} \
2161.124Ssimonb	    -g ${BINGRP} -m 444 fstab.* ${DESTDIR}/etc)
2171.49Stls	(cd ${DESTDIR}/dev; ./MAKEDEV all)
2181.62Sperry	(cd ../usr.bin/mail; ${MAKE} distribution)
2191.90Skim.ifndef NO_SENDMAIL
2201.35Scgd	(cd ../usr.sbin/sendmail/cf/cf; ${MAKE} distribution)
2211.126Smjl	${DESTDIR}/usr/libexec/sendmail/sendmail -C ${DESTDIR}/etc/sendmail.cf -O AliasFile=${DESTDIR}/etc/aliases -bi
2221.90Skim.endif
2231.112Sperry.ifdef BUILD_POSTFIX
2241.110Smrg	(cd ../usr.sbin/postfix/etc; ${MAKE} distribution)
2251.111Ssimonb.endif
2261.1Scgd
2271.1Scgd
2281.7Scgddistrib-dirs:
2291.124Ssimonb	${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${DESTDIR}
2301.67Sperry	-mtree -def mtree/NetBSD.dist -p ${DESTDIR}/ -u
2311.28Sjtc	cd ${DESTDIR}; rm -f sys; ln -s usr/src/sys sys
2321.99Scjs
2331.96Scjs.if !defined(RELEASEDIR)
2341.117Ssimonbrelease snapshot snap_pre snap_md_pre snap_md_post:
2351.96Scjs	@echo setenv RELEASEDIR before doing that!
2361.96Scjs	@false
2371.96Scjs.else
2381.117Ssimonbrelease snapshot: distribution snap_pre snap_md_pre snap_kern snap_md_post
2391.96Scjs	sh ../distrib/sets/maketars -s ../distrib/sets \
2401.96Scjs		-d ${DESTDIR} -t ${RELEASEDIR}/binary/sets
2411.104Sitohy.if exists(../domestic) && !defined(EXPORTABLE_SYSTEM)
2421.103Sfair	sh ../distrib/sets/maketars -s ../distrib/sets \
2431.103Sfair		-d ${DESTDIR} -t ${RELEASEDIR}/binary/security secr
2441.123Sis	sh ../distrib/sets/makesums -t ${RELEASEDIR}/binary/security
2451.103Sfair.endif
2461.123Sis	sh ../distrib/sets/makesums -t ${RELEASEDIR}/binary/sets
2471.104Sitohy.ifdef EXTRA_KERNELS
2481.123Sis	sh ../distrib/sets/makesums -t ${RELEASEDIR}/binary/kernel '*.gz'
2491.104Sitohy.endif
2501.41Scgd
2511.41Scgdsnap_pre:
2521.96Scjs	/bin/rm -rf ${RELEASEDIR}
2531.124Ssimonb	${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${RELEASEDIR}
2541.117Ssimonb.for dir in ${INSTALLATION_DIRS}
2551.124Ssimonb	${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${RELEASEDIR}/${dir}
2561.117Ssimonb.endfor
2571.96Scjs
2581.96Scjs# the regular expression does a basename(1) on .CURDIR so that we don't
2591.96Scjs# have to keep looking up .. at compile time.
2601.96ScjsKERNSRCDIR?=	${.CURDIR:C/[^\/]+$//}sys
2611.96ScjsKERNOBJDIR?=	${KERNSRCDIR}/arch/${MACHINE}/compile
2621.96ScjsKERNCONFDIR?=	${KERNSRCDIR}/arch/${MACHINE}/conf
2631.96Scjs
2641.96Scjs# This target builds the GENERIC kernel (which must exist for all
2651.96Scjs# ports) and puts it in binary/sets/kern.tgz, and also builds any
2661.114Sfair# kernels specified in EXTRA_KERNELS. Since NetBSD's kernel build
2671.114Sfair# system can create more than one kernel from a single configuration
2681.114Sfair# we figure out how many there are, what they're named, and move them
2691.114Sfair# to binary/kernel/${KERNEL}.${CONFIGFILE}.gz - most often KERNEL will
2701.116Sfair# simply be "netbsd". If we don't find the "config" line, assume the
2711.116Sfair# kernel will be "netbsd" (some config files are simple additions on
2721.116Sfair# GENERIC, and just include it).
2731.116Sfair#
2741.116SfairGETKERNELAWK=	awk '/^config/ {print $$2; found=1} \
2751.116Sfair		END{ if (found == 0) print "netbsd"; }'
2761.96Scjs#
2771.118Sgwr.if !target(snap_kern)
2781.96Scjssnap_kern:
2791.125Ssommerfe	cd ${KERNCONFDIR} && ${CONFIG} \
2801.96Scjs		-b ${KERNOBJDIR}/GENERIC -s ${KERNSRCDIR} GENERIC
2811.97Scjs.ifndef UPDATE
2821.96Scjs	cd ${KERNOBJDIR}/GENERIC && ${MAKE} clean 
2831.96Scjs.endif
2841.115Sfair	cd ${KERNOBJDIR}/GENERIC && ${MAKE} depend && ${MAKE} ${_J}
2851.96Scjs	cd ${KERNOBJDIR}/GENERIC &&	\
2861.116Sfair		tar cf - `${GETKERNELAWK} ${KERNCONFDIR}/GENERIC` |\
2871.96Scjs		gzip -c -9 > ${RELEASEDIR}/binary/sets/kern.tgz
2881.117Ssimonb# XXX use same loop for ${EXTRA_KERNELS} and ${BUILD_KERNELS} but
2891.117Ssimonb# XXX only install ${EXTRA_KERNELS} in binary/kernel???
2901.114Sfair.for configfile in ${EXTRA_KERNELS}
2911.125Ssommerfe	cd ${KERNCONFDIR} && ${CONFIG} \
2921.114Sfair		-b ${KERNOBJDIR}/${configfile} -s ${KERNSRCDIR} ${configfile}
2931.98Scjs.ifndef UPDATE
2941.114Sfair	cd ${KERNOBJDIR}/${configfile} && ${MAKE} clean 
2951.96Scjs.endif
2961.115Sfair	cd ${KERNOBJDIR}/${configfile} && ${MAKE} depend && ${MAKE} ${_J}
2971.114Sfair	cd ${KERNOBJDIR}/${configfile} &&	\
2981.116Sfair		for kernel in `${GETKERNELAWK} \
2991.114Sfair			${KERNCONFDIR}/${configfile}` ; {   \
3001.114Sfair		gzip -c -9 < $${kernel} > \
3011.114Sfair			${RELEASEDIR}/binary/kernel/$${kernel}.${configfile}.gz ; }
3021.96Scjs.endfor # EXTRA_KERNELS
3031.117Ssimonb.for configfile in ${BUILD_KERNELS}
3041.125Ssommerfe	cd ${KERNCONFDIR} && ${CONFIG} \
3051.117Ssimonb		-b ${KERNOBJDIR}/${configfile} -s ${KERNSRCDIR} ${configfile}
3061.117Ssimonb.ifndef UPDATE
3071.117Ssimonb	cd ${KERNOBJDIR}/${configfile} && ${MAKE} clean 
3081.117Ssimonb.endif
3091.117Ssimonb	cd ${KERNOBJDIR}/${configfile} && ${MAKE} depend && ${MAKE} ${_J}
3101.117Ssimonb.endfor # BUILD_KERNELS
3111.118Sgwr.endif # no target(snap_kern)
3121.108Sdrochner
3131.96Scjs.endif # RELEASEDIR check
3141.41Scgd
3151.117Ssimonbsnap_md_pre:
3161.117Ssimonb# nothing here -- look in the machine-dependent Makefile.inc
3171.117Ssimonb
3181.117Ssimonbsnap_md_post:
3191.41Scgd# nothing here -- look in the machine-dependent Makefile.inc
3201.41Scgd
3211.34Scgd.endif	# DESTDIR check
3221.7Scgd
3231.1Scgd.include <bsd.prog.mk>
324