Makefile revision 1.155
11.155Sthorpej#	$NetBSD: Makefile,v 1.155 2000/07/25 19:07:39 thorpej 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.154Sthorpej#
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.149Ssjg# do this before bsd.own.mk so we get correct KERNSRCDIR
401.145Ssjg.include "../Makefile.inc"
411.145Ssjg
421.155Sthorpej# For NO_SENDMAIL, INSTPRIV, MKCRYPTO
431.90Skim.include <bsd.own.mk>
441.90Skim
451.23ScgdTZDIR=		/usr/share/zoneinfo
461.90SkimLOCALTIME?=	US/Pacific
471.19Sderaadt
481.55Sperry# setting NOOBJ prevents "make obj" from doing anything;
491.55Sperry# an objdir would break the installation stuff below
501.101SlukemMKOBJ=	no
511.1Scgd
521.80Sjonathan# MD Makefile.inc may append MD targets to BIN[123].  Make sure all
531.80Sjonathan# are empty, to preserve the old semantics of setting them below with "=".
541.80SjonathanBIN1=	
551.80SjonathanBIN2=
561.80SjonathanBIN3=
571.80Sjonathan
581.117Ssimonb# Directories to build in ${RELEASEDIR}.   MD Makefile.inc files can
591.117Ssimonb# add to this.
601.117Ssimonb# NOTE: Parent directories must be listed before subdirectories.
611.117SsimonbINSTALLATION_DIRS= \
621.117Ssimonb	binary binary/sets binary/kernel binary/security installation
631.117Ssimonb
641.71Scjs.if exists(etc.${MACHINE}/Makefile.inc)
651.71Scjs.include "etc.${MACHINE}/Makefile.inc"
661.71Scjs.endif
671.32Sjtc
681.96Scjs# Use multiple jobs for kernel builds, if NBUILDJOBS set.
691.96Scjs# (Taken from src/Makefile.)
701.96Scjs.if defined(NBUILDJOBS)
711.96Scjs_J= -j${NBUILDJOBS}
721.96Scjs.endif
731.96Scjs
741.21Scgd# -rw-r--r--
751.21ScgdBINOWN= root
761.21ScgdBINGRP= wheel
771.131SveegoBIN1+=	bootptab changelist csh.cshrc csh.login csh.logout daily \
781.131Sveego	daily.conf dm.conf floppytab ftpchroot ftpusers ftpwelcome \
791.131Sveego	gettytab group hosts hosts.lpd inetd.conf lkm.conf \
801.131Sveego	mailer.conf man.conf monthly monthly.conf mrouted.conf \
811.151Sfvdl	netconfig networks newsyslog.conf nsswitch.conf ntp.conf \
821.131Sveego	phones printcap profile protocols rbootd.conf rc rc.conf \
831.131Sveego	rc.lkm rc.local rc.subr rc.shutdown rc.wscons remote rpc \
841.142Stsarna	security security.conf services shells sysctl.conf syslog.conf \
851.142Stsarna	weekly weekly.conf wscons.conf \
861.109Sdrochner	etc.${MACHINE}/ttys etc.${MACHINE}/disktab
871.105Smycroft
881.121Sfvdl.if	(${MACHINE_ARCH} == "m68k") || \
891.105Smycroft	(${MACHINE_ARCH} == "ns32k") || \
901.105Smycroft	(${MACHINE_ARCH} == "vax") || \
911.105Smycroft	(${MACHINE_ARCH} == "arm32")
921.129SchristosBIN1+=	ld.so.conf
931.129Schristos.elif exists(etc.${MACHINE_ARCH}/ld.so.conf)
941.132SjlamBIN1+=	etc.${MACHINE_ARCH}/ld.so.conf
951.152Sperry.endif
961.152Sperry
971.152Sperry.if exists(etc.${MACHINE_ARCH}/ttyaction)
981.152SperryBIN1+=	etc.${MACHINE_ARCH}/ttyaction
991.105Smycroft.endif
1001.120Sitojun
1011.120Sitojun# IPv6
1021.120SitojunBIN1+=	rtadvd.conf
1031.1Scgd
1041.46Sderaadt# -rw-rw-r--
1051.80SjonathanBIN2+=	motd
1061.1Scgd
1071.77Smycroft# -rw-------
1081.80SjonathanBIN3+=	hosts.equiv
1091.77Smycroft
1101.144SthorpejNAMEDB=	127 root.cache named.conf localhost loopback.v6
1111.1ScgdPCS=	pcs750.bin
1121.1Scgd
1131.88Slukemall clean cleandir depend distclean etc includes install lint:
1141.1Scgd
1151.149Ssjg.include <bsd.kernobj.mk>
1161.149Ssjg
1171.149Ssjgobj:
1181.149Ssjg	mkdir -p ${KERNOBJDIR}
1191.149Ssjg
1201.34Scgd.ifndef DESTDIR
1211.106Scjsdistribution distrib-dirs release snapshot:
1221.36Scgd	@echo setenv DESTDIR before doing that!
1231.34Scgd	@false
1241.34Scgd.else
1251.7Scgddistribution: distrib-dirs
1261.87Sperry.if !defined(INSTALL_DONE)
1271.107Sscottr	(cd ..; ${MAKE} _DISTRIB= includes)
1281.107Sscottr	(cd ..; ${MAKE} _DISTRIB= install)
1291.87Sperry.endif
1301.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 ${BIN1} \
1311.124Ssimonb	    ${DESTDIR}/etc
1321.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 ${BIN2} \
1331.124Ssimonb	    ${DESTDIR}/etc
1341.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 ${BIN3} \
1351.124Ssimonb	    ${DESTDIR}/etc
1361.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 aliases \
1371.147Sitojun	    ${DESTDIR}/etc/mail
1381.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 crontab \
1391.56Sthorpej	    ${DESTDIR}/var/cron/tabs/root
1401.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 master.passwd \
1411.124Ssimonb	    ${DESTDIR}/etc
1421.68Sperry	pwd_mkdb -p -d ${DESTDIR}/ ${DESTDIR}/etc/master.passwd
1431.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 555 \
1441.1Scgd	     MAKEDEV.local etc.${MACHINE}/MAKEDEV ${DESTDIR}/dev
1451.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 minfree \
1461.73Sperry	    ${DESTDIR}/var/crash
1471.1Scgd	(cd root; \
1481.124Ssimonb		${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.cshrc \
1491.1Scgd		    ${DESTDIR}/root/.cshrc; \
1501.124Ssimonb		${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 dot.klogin \
1511.1Scgd		    ${DESTDIR}/root/.klogin; \
1521.124Ssimonb		${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.login \
1531.1Scgd		    ${DESTDIR}/root/.login; \
1541.124Ssimonb		${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.profile \
1551.1Scgd		    ${DESTDIR}/root/.profile; \
1561.128Smycroft		${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.shrc \
1571.128Smycroft		    ${DESTDIR}/root/.shrc; \
1581.1Scgd		rm -f ${DESTDIR}/.cshrc ${DESTDIR}/.profile; \
1591.1Scgd		ln ${DESTDIR}/root/.cshrc ${DESTDIR}/.cshrc; \
1601.1Scgd		ln ${DESTDIR}/root/.profile ${DESTDIR}/.profile)
1611.83Smrg	(cd mtree; ${MAKE} install)
1621.63Smikel	(cd namedb; \
1631.124Ssimonb		${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 \
1641.124Ssimonb		    ${NAMEDB} ${DESTDIR}/etc/namedb)
1651.140Slukem	(cd rc.d; ${MAKE} install)
1661.19Sderaadt	/bin/rm -f ${DESTDIR}/etc/localtime
1671.19Sderaadt	ln -s ${TZDIR}/${LOCALTIME} ${DESTDIR}/etc/localtime
1681.48Sderaadt	/bin/rm -f ${DESTDIR}/etc/rmt
1691.48Sderaadt	ln -s /usr/sbin/rmt ${DESTDIR}/etc/rmt
1701.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g operator -m 664 /dev/null \
1711.32Sjtc		${DESTDIR}/etc/dumpdates
1721.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g operator -m 600 /dev/null \
1731.44Sderaadt		${DESTDIR}/etc/skeykeys
1741.127Sperry	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 /dev/null \
1751.127Sperry		${DESTDIR}/var/at/at.deny
1761.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 /dev/null \
1771.38Scgd		${DESTDIR}/var/cron/log
1781.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o nobody -g ${BINGRP} -m 664 /dev/null \
1791.32Sjtc		${DESTDIR}/var/db/locate.database
1801.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o uucp -g dialer -m 640 /dev/null \
1811.113Sfair		${DESTDIR}/var/log/aculog
1821.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
1831.69Sperry		${DESTDIR}/var/log/authlog
1841.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \
1851.32Sjtc		${DESTDIR}/var/log/lastlog
1861.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 640 /dev/null \
1871.32Sjtc		${DESTDIR}/var/log/lpd-errs
1881.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
1891.32Sjtc		${DESTDIR}/var/log/maillog
1901.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
1911.32Sjtc		${DESTDIR}/var/log/messages
1921.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
1931.58Slukem		${DESTDIR}/var/log/secure
1941.137Smycroft	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
1951.137Smycroft		${DESTDIR}/var/log/sendmail.st
1961.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
1971.32Sjtc		${DESTDIR}/var/log/wtmp
1981.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
1991.69Sperry		${DESTDIR}/var/log/xferlog
2001.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o daemon -g staff -m 664 /dev/null \
2011.39Scgd		${DESTDIR}/var/msgs/bounds
2021.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \
2031.32Sjtc		${DESTDIR}/var/run/utmp
2041.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
2051.81Smrg		${DESTDIR}/var/games/atc_scores
2061.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
2071.81Smrg		${DESTDIR}/var/games/battlestar.log
2081.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
2091.81Smrg		${DESTDIR}/var/games/cfscores
2101.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
2111.82Sperry		${DESTDIR}/var/games/criblog
2121.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
2131.81Smrg		${DESTDIR}/var/games/robots_roll
2141.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
2151.81Smrg		${DESTDIR}/var/games/rogue.scores
2161.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
2171.81Smrg		${DESTDIR}/var/games/saillog
2181.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
2191.81Smrg		${DESTDIR}/var/games/snakerawscores
2201.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
2211.81Smrg		${DESTDIR}/var/games/snake.log
2221.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
2231.81Smrg		${DESTDIR}/var/games/tetris.scores
2241.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
2251.81Smrg		${DESTDIR}/var/games/larn/llog12.0
2261.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
2271.81Smrg		${DESTDIR}/var/games/larn/lscore12.0
2281.124Ssimonb	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
2291.81Smrg		${DESTDIR}/var/games/larn/playerids
2301.124Ssimonb	(cd etc.${MACHINE}; ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} \
2311.124Ssimonb	    -g ${BINGRP} -m 444 fstab.* ${DESTDIR}/etc)
2321.49Stls	(cd ${DESTDIR}/dev; ./MAKEDEV all)
2331.62Sperry	(cd ../usr.bin/mail; ${MAKE} distribution)
2341.143Sperry	(cd ../gnu/usr.sbin/postfix/; ${MAKE} distribution)
2351.155Sthorpej.if (${MKCRYPTO} != "no")
2361.155Sthorpej	(cd ../usr.bin/ssh; ${MAKE} distribution)
2371.155Sthorpej.endif
2381.90Skim.ifndef NO_SENDMAIL
2391.133Stron	(cd ../gnu/usr.sbin/sendmail/cf/cf; ${MAKE} distribution)
2401.153Sfredb	${DESTDIR}/usr/libexec/sendmail/sendmail -C ${DESTDIR}/etc/mail/sendmail.cf -O AliasFile=${DESTDIR}/etc/mail/aliases -O DontBlameSendmail=MapInUnsafeDirPath -bi
2411.90Skim.endif
2421.1Scgd
2431.7Scgddistrib-dirs:
2441.124Ssimonb	${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${DESTDIR}
2451.67Sperry	-mtree -def mtree/NetBSD.dist -p ${DESTDIR}/ -u
2461.28Sjtc	cd ${DESTDIR}; rm -f sys; ln -s usr/src/sys sys
2471.99Scjs
2481.96Scjs.if !defined(RELEASEDIR)
2491.117Ssimonbrelease snapshot snap_pre snap_md_pre snap_md_post:
2501.96Scjs	@echo setenv RELEASEDIR before doing that!
2511.96Scjs	@false
2521.96Scjs.else
2531.117Ssimonbrelease snapshot: distribution snap_pre snap_md_pre snap_kern snap_md_post
2541.141Sthorpej	(cd ../distrib/sets; ${MAKE} sets)
2551.123Sis	sh ../distrib/sets/makesums -t ${RELEASEDIR}/binary/kernel '*.gz'
2561.41Scgd
2571.41Scgdsnap_pre:
2581.96Scjs	/bin/rm -rf ${RELEASEDIR}
2591.124Ssimonb	${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${RELEASEDIR}
2601.117Ssimonb.for dir in ${INSTALLATION_DIRS}
2611.124Ssimonb	${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${RELEASEDIR}/${dir}
2621.117Ssimonb.endfor
2631.96Scjs
2641.96Scjs
2651.96Scjs# This target builds the GENERIC kernel (which must exist for all
2661.96Scjs# ports) and puts it in binary/sets/kern.tgz, and also builds any
2671.114Sfair# kernels specified in EXTRA_KERNELS. Since NetBSD's kernel build
2681.114Sfair# system can create more than one kernel from a single configuration
2691.114Sfair# we figure out how many there are, what they're named, and move them
2701.114Sfair# to binary/kernel/${KERNEL}.${CONFIGFILE}.gz - most often KERNEL will
2711.116Sfair# simply be "netbsd". If we don't find the "config" line, assume the
2721.116Sfair# kernel will be "netbsd" (some config files are simple additions on
2731.116Sfair# GENERIC, and just include it).
2741.116Sfair#
2751.116SfairGETKERNELAWK=	awk '/^config/ {print $$2; found=1} \
2761.116Sfair		END{ if (found == 0) print "netbsd"; }'
2771.96Scjs#
2781.118Sgwr.if !target(snap_kern)
2791.96Scjssnap_kern:
2801.145Ssjg.ifndef KERNELS_DONE
2811.135Smycroft.for configfile in GENERIC ${EXTRA_KERNELS} ${BUILD_KERNELS}
2821.125Ssommerfe	cd ${KERNCONFDIR} && ${CONFIG} \
2831.135Smycroft		-b ${KERNOBJDIR}/${configfile} -s ${KERNSRCDIR} ${configfile}
2841.97Scjs.ifndef UPDATE
2851.135Smycroft	cd ${KERNOBJDIR}/${configfile} && ${MAKE} clean 
2861.96Scjs.endif
2871.135Smycroft	cd ${KERNOBJDIR}/${configfile} && ${MAKE} depend && ${MAKE} ${_J}
2881.135Smycroft.endfor # kernels
2891.96Scjs	cd ${KERNOBJDIR}/GENERIC &&	\
2901.116Sfair		tar cf - `${GETKERNELAWK} ${KERNCONFDIR}/GENERIC` |\
2911.96Scjs		gzip -c -9 > ${RELEASEDIR}/binary/sets/kern.tgz
2921.135Smycroft.for configfile in GENERIC ${EXTRA_KERNELS}
2931.114Sfair	cd ${KERNOBJDIR}/${configfile} &&	\
2941.116Sfair		for kernel in `${GETKERNELAWK} \
2951.114Sfair			${KERNCONFDIR}/${configfile}` ; {   \
2961.114Sfair		gzip -c -9 < $${kernel} > \
2971.114Sfair			${RELEASEDIR}/binary/kernel/$${kernel}.${configfile}.gz ; }
2981.96Scjs.endfor # EXTRA_KERNELS
2991.145Ssjg.endif # KERNELS_DONE
3001.118Sgwr.endif # no target(snap_kern)
3011.108Sdrochner
3021.96Scjs.endif # RELEASEDIR check
3031.41Scgd
3041.117Ssimonbsnap_md_pre:
3051.117Ssimonb# nothing here -- look in the machine-dependent Makefile.inc
3061.117Ssimonb
3071.117Ssimonbsnap_md_post:
3081.41Scgd# nothing here -- look in the machine-dependent Makefile.inc
3091.41Scgd
3101.34Scgd.endif	# DESTDIR check
3111.7Scgd
3121.1Scgd.include <bsd.prog.mk>
313