Makefile revision 1.130
1#	$NetBSD: Makefile,v 1.130 2000/02/03 17:51:51 veego 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/KERNELNAME, but can be
16#	overridden.
17#   KERNCONFDIR is where the configuration files for kernels are found;
18#	default is ${KERNSRCDIR}/arch/${MACHINE}/conf but can be overridden.
19#   UPDATE is normally undefined; if defined, don't do a 'make clean'
20#	before kernel compile
21#   NO_SENDMAIL is normally undefined; if defined, it will not do a
22#	`make distribution' in the sendmail config file source directory.
23#   EXTRA_KERNELS has a machine-dependent list of kernels to build added
24#	to it, but you may also set this to have extra ones built.
25#   BUILD_KERNELS are a machine-dependent list of kernels that should just
26#	be built in place but not made into sets or installed, e.g., an
27#	INSTALL kernel used later in src/distrib/.
28# 
29# Targets:
30#    distribution: makes a full NetBSD distribution in DESTDIR. If
31#	INSTALL_DONE is set, it will not do a `make install.'
32#    distrib-dirs: creates an empty NetBSD directory tree in DESTDIR.
33#	Called by distribution.
34#    snapshot: calls distribution, above, and then tars up the files
35#	into a release(7) format in RELEASEDIR. Any port-dependent
36#	stuff for this target is found in etc.${MACHINE}/Makefile.inc.
37#    release: a synonym for `snapshot'
38
39# XXX: For NO_SENDMAIL and INSTPRIV
40.include <bsd.own.mk>
41
42TZDIR=		/usr/share/zoneinfo
43LOCALTIME?=	US/Pacific
44
45# setting NOOBJ prevents "make obj" from doing anything;
46# an objdir would break the installation stuff below
47MKOBJ=	no
48
49# MD Makefile.inc may append MD targets to BIN[123].  Make sure all
50# are empty, to preserve the old semantics of setting them below with "=".
51BIN1=	
52BIN2=
53BIN3=
54
55# Directories to build in ${RELEASEDIR}.   MD Makefile.inc files can
56# add to this.
57# NOTE: Parent directories must be listed before subdirectories.
58INSTALLATION_DIRS= \
59	binary binary/sets binary/kernel binary/security installation
60
61.if exists(etc.${MACHINE}/Makefile.inc)
62.include "etc.${MACHINE}/Makefile.inc"
63.endif
64
65# Use multiple jobs for kernel builds, if NBUILDJOBS set.
66# (Taken from src/Makefile.)
67.if defined(NBUILDJOBS)
68_J= -j${NBUILDJOBS}
69.endif
70
71# -rw-r--r--
72BINOWN= root
73BINGRP= wheel
74BIN1+=	bootptab changelist csh.cshrc csh.login \
75	csh.logout daily daily.conf dm.conf floppytab ftpchroot \
76	ftpusers ftpwelcome gettytab group hosts hosts.lpd \
77	inetd.conf lkm.conf mailer.conf man.conf \
78	monthly monthly.conf mrouted.conf netstart networks \
79	newsyslog.conf nsswitch.conf phones printcap profile protocols \
80	rbootd.conf rc rc.conf rc.lkm rc.local rc.subr \
81	rc.shutdown rc.wscons remote rpc security security.conf services \
82	shells syslog.conf weekly weekly.conf wscons.conf \
83	etc.${MACHINE}/ttys etc.${MACHINE}/disktab
84
85.if	(${MACHINE_ARCH} == "m68k") || \
86	(${MACHINE_ARCH} == "ns32k") || \
87	(${MACHINE_ARCH} == "vax") || \
88	(${MACHINE_ARCH} == "arm32")
89BIN1+=	ld.so.conf
90.elif exists(etc.${MACHINE_ARCH}/ld.so.conf)
91BIN1+=	ld.so.conf
92.endif
93
94# IPv6
95BIN1+=	rtadvd.conf
96
97# -rw-rw-r--
98BIN2+=	motd
99
100# -rw-------
101BIN3+=	hosts.equiv
102
103NAMEDB=	127 root.cache named.conf
104PCS=	pcs750.bin
105
106all clean cleandir depend distclean etc includes install lint:
107
108.ifndef DESTDIR
109distribution distrib-dirs release snapshot:
110	@echo setenv DESTDIR before doing that!
111	@false
112.else
113distribution: distrib-dirs
114.if !defined(INSTALL_DONE)
115	(cd ..; ${MAKE} _DISTRIB= includes)
116	(cd ..; ${MAKE} _DISTRIB= install)
117.endif
118	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 ${BIN1} \
119	    ${DESTDIR}/etc
120	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 ${BIN2} \
121	    ${DESTDIR}/etc
122	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 ${BIN3} \
123	    ${DESTDIR}/etc
124	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 aliases \
125	    ${DESTDIR}/etc
126	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 crontab \
127	    ${DESTDIR}/var/cron/tabs/root
128	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 master.passwd \
129	    ${DESTDIR}/etc
130	pwd_mkdb -p -d ${DESTDIR}/ ${DESTDIR}/etc/master.passwd
131	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 555 \
132	     MAKEDEV.local etc.${MACHINE}/MAKEDEV ${DESTDIR}/dev
133	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 minfree \
134	    ${DESTDIR}/var/crash
135	(cd root; \
136		${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.cshrc \
137		    ${DESTDIR}/root/.cshrc; \
138		${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 dot.klogin \
139		    ${DESTDIR}/root/.klogin; \
140		${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.login \
141		    ${DESTDIR}/root/.login; \
142		${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.profile \
143		    ${DESTDIR}/root/.profile; \
144		${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.shrc \
145		    ${DESTDIR}/root/.shrc; \
146		rm -f ${DESTDIR}/.cshrc ${DESTDIR}/.profile; \
147		ln ${DESTDIR}/root/.cshrc ${DESTDIR}/.cshrc; \
148		ln ${DESTDIR}/root/.profile ${DESTDIR}/.profile)
149	(cd mtree; ${MAKE} install)
150	(cd namedb; \
151		${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 \
152		    ${NAMEDB} ${DESTDIR}/etc/namedb)
153	/bin/rm -f ${DESTDIR}/etc/localtime
154	ln -s ${TZDIR}/${LOCALTIME} ${DESTDIR}/etc/localtime
155	/bin/rm -f ${DESTDIR}/etc/rmt
156	ln -s /usr/sbin/rmt ${DESTDIR}/etc/rmt
157	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g operator -m 664 /dev/null \
158		${DESTDIR}/etc/dumpdates
159	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g operator -m 600 /dev/null \
160		${DESTDIR}/etc/skeykeys
161	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 /dev/null \
162		${DESTDIR}/var/at/at.deny
163	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 /dev/null \
164		${DESTDIR}/var/cron/log
165	${INSTALL} ${INSTPRIV} -c -o nobody -g ${BINGRP} -m 664 /dev/null \
166		${DESTDIR}/var/db/locate.database
167	${INSTALL} ${INSTPRIV} -c -o uucp -g dialer -m 640 /dev/null \
168		${DESTDIR}/var/log/aculog
169	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
170		${DESTDIR}/var/log/authlog
171	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \
172		${DESTDIR}/var/log/lastlog
173	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 640 /dev/null \
174		${DESTDIR}/var/log/lpd-errs
175	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
176		${DESTDIR}/var/log/maillog
177	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
178		${DESTDIR}/var/log/messages
179	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
180		${DESTDIR}/var/log/secure
181	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
182		${DESTDIR}/var/log/wtmp
183	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
184		${DESTDIR}/var/log/xferlog
185	${INSTALL} ${INSTPRIV} -c -o daemon -g staff -m 664 /dev/null \
186		${DESTDIR}/var/msgs/bounds
187	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \
188		${DESTDIR}/var/run/utmp
189	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
190		${DESTDIR}/var/games/atc_scores
191	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
192		${DESTDIR}/var/games/battlestar.log
193	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
194		${DESTDIR}/var/games/cfscores
195	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
196		${DESTDIR}/var/games/criblog
197	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
198		${DESTDIR}/var/games/robots_roll
199	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
200		${DESTDIR}/var/games/rogue.scores
201	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
202		${DESTDIR}/var/games/saillog
203	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
204		${DESTDIR}/var/games/snakerawscores
205	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
206		${DESTDIR}/var/games/snake.log
207	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
208		${DESTDIR}/var/games/tetris.scores
209	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
210		${DESTDIR}/var/games/larn/llog12.0
211	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
212		${DESTDIR}/var/games/larn/lscore12.0
213	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
214		${DESTDIR}/var/games/larn/playerids
215	(cd etc.${MACHINE}; ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} \
216	    -g ${BINGRP} -m 444 fstab.* ${DESTDIR}/etc)
217	(cd ${DESTDIR}/dev; ./MAKEDEV all)
218	(cd ../usr.bin/mail; ${MAKE} distribution)
219.ifndef NO_SENDMAIL
220	(cd ../usr.sbin/sendmail/cf/cf; ${MAKE} distribution)
221	${DESTDIR}/usr/libexec/sendmail/sendmail -C ${DESTDIR}/etc/sendmail.cf -O AliasFile=${DESTDIR}/etc/aliases -bi
222.endif
223.ifdef BUILD_POSTFIX
224	(cd ../usr.sbin/postfix/etc; ${MAKE} distribution)
225.endif
226
227
228distrib-dirs:
229	${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${DESTDIR}
230	-mtree -def mtree/NetBSD.dist -p ${DESTDIR}/ -u
231	cd ${DESTDIR}; rm -f sys; ln -s usr/src/sys sys
232
233.if !defined(RELEASEDIR)
234release snapshot snap_pre snap_md_pre snap_md_post:
235	@echo setenv RELEASEDIR before doing that!
236	@false
237.else
238release snapshot: distribution snap_pre snap_md_pre snap_kern snap_md_post
239	sh ../distrib/sets/maketars -s ../distrib/sets \
240		-d ${DESTDIR} -t ${RELEASEDIR}/binary/sets
241.if exists(../domestic) && !defined(EXPORTABLE_SYSTEM)
242	sh ../distrib/sets/maketars -s ../distrib/sets \
243		-d ${DESTDIR} -t ${RELEASEDIR}/binary/security secr
244	sh ../distrib/sets/makesums -t ${RELEASEDIR}/binary/security
245.endif
246	sh ../distrib/sets/makesums -t ${RELEASEDIR}/binary/sets
247.ifdef EXTRA_KERNELS
248	sh ../distrib/sets/makesums -t ${RELEASEDIR}/binary/kernel '*.gz'
249.endif
250
251snap_pre:
252	/bin/rm -rf ${RELEASEDIR}
253	${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${RELEASEDIR}
254.for dir in ${INSTALLATION_DIRS}
255	${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${RELEASEDIR}/${dir}
256.endfor
257
258# the regular expression does a basename(1) on .CURDIR so that we don't
259# have to keep looking up .. at compile time.
260KERNSRCDIR?=	${.CURDIR:C/[^\/]+$//}sys
261KERNOBJDIR?=	${KERNSRCDIR}/arch/${MACHINE}/compile
262KERNCONFDIR?=	${KERNSRCDIR}/arch/${MACHINE}/conf
263
264# This target builds the GENERIC kernel (which must exist for all
265# ports) and puts it in binary/sets/kern.tgz, and also builds any
266# kernels specified in EXTRA_KERNELS. Since NetBSD's kernel build
267# system can create more than one kernel from a single configuration
268# we figure out how many there are, what they're named, and move them
269# to binary/kernel/${KERNEL}.${CONFIGFILE}.gz - most often KERNEL will
270# simply be "netbsd". If we don't find the "config" line, assume the
271# kernel will be "netbsd" (some config files are simple additions on
272# GENERIC, and just include it).
273#
274GETKERNELAWK=	awk '/^config/ {print $$2; found=1} \
275		END{ if (found == 0) print "netbsd"; }'
276#
277.if !target(snap_kern)
278snap_kern:
279	cd ${KERNCONFDIR} && ${CONFIG} \
280		-b ${KERNOBJDIR}/GENERIC -s ${KERNSRCDIR} GENERIC
281.ifndef UPDATE
282	cd ${KERNOBJDIR}/GENERIC && ${MAKE} clean 
283.endif
284	cd ${KERNOBJDIR}/GENERIC && ${MAKE} depend && ${MAKE} ${_J}
285	cd ${KERNOBJDIR}/GENERIC &&	\
286		tar cf - `${GETKERNELAWK} ${KERNCONFDIR}/GENERIC` |\
287		gzip -c -9 > ${RELEASEDIR}/binary/sets/kern.tgz
288# XXX use same loop for ${EXTRA_KERNELS} and ${BUILD_KERNELS} but
289# XXX only install ${EXTRA_KERNELS} in binary/kernel???
290.for configfile in ${EXTRA_KERNELS}
291	cd ${KERNCONFDIR} && ${CONFIG} \
292		-b ${KERNOBJDIR}/${configfile} -s ${KERNSRCDIR} ${configfile}
293.ifndef UPDATE
294	cd ${KERNOBJDIR}/${configfile} && ${MAKE} clean 
295.endif
296	cd ${KERNOBJDIR}/${configfile} && ${MAKE} depend && ${MAKE} ${_J}
297	cd ${KERNOBJDIR}/${configfile} &&	\
298		for kernel in `${GETKERNELAWK} \
299			${KERNCONFDIR}/${configfile}` ; {   \
300		gzip -c -9 < $${kernel} > \
301			${RELEASEDIR}/binary/kernel/$${kernel}.${configfile}.gz ; }
302.endfor # EXTRA_KERNELS
303.for configfile in ${BUILD_KERNELS}
304	cd ${KERNCONFDIR} && ${CONFIG} \
305		-b ${KERNOBJDIR}/${configfile} -s ${KERNSRCDIR} ${configfile}
306.ifndef UPDATE
307	cd ${KERNOBJDIR}/${configfile} && ${MAKE} clean 
308.endif
309	cd ${KERNOBJDIR}/${configfile} && ${MAKE} depend && ${MAKE} ${_J}
310.endfor # BUILD_KERNELS
311.endif # no target(snap_kern)
312
313.endif # RELEASEDIR check
314
315snap_md_pre:
316# nothing here -- look in the machine-dependent Makefile.inc
317
318snap_md_post:
319# nothing here -- look in the machine-dependent Makefile.inc
320
321.endif	# DESTDIR check
322
323.include <bsd.prog.mk>
324