Makefile revision 1.167
1#	$NetBSD: Makefile,v 1.167 2000/10/23 01:50:37 jmc 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# do this before bsd.own.mk so we get correct KERNSRCDIR
40.include "../Makefile.inc"
41
42# For NO_SENDMAIL, INSTPRIV, MKCRYPTO
43.include <bsd.own.mk>
44
45TZDIR=		/usr/share/zoneinfo
46LOCALTIME?=	UTC
47
48# Flags for creating ISO CDROM image
49# mkisofs is expected to be in $PATH, install via pkgsrc/sysutils/cdrecord
50MKISOFS?=	mkisofs
51MKISOFS_FLAGS+= -J -l \
52		-r -T -v \
53		-P "The NetBSD Project" \
54		-m "${RELEASEDIR}/installation/cdrom"
55
56# setting NOOBJ prevents "make obj" from doing anything;
57# an objdir would break the installation stuff below
58MKOBJ=	no
59
60# MD Makefile.inc may append MD targets to BIN[123].  Make sure all
61# are empty, to preserve the old semantics of setting them below with "=".
62BIN1=	
63BIN2=
64BIN3=
65
66# Directories to build in ${RELEASEDIR}.   MD Makefile.inc files can
67# add to this.
68# NOTE: Parent directories must be listed before subdirectories.
69INSTALLATION_DIRS= \
70	binary binary/sets binary/kernel installation
71
72.if exists(etc.${MACHINE}/Makefile.inc)
73.include "etc.${MACHINE}/Makefile.inc"
74.endif
75
76# Use multiple jobs for kernel builds, if NBUILDJOBS set.
77# (Taken from src/Makefile.)
78.if defined(NBUILDJOBS)
79_J= -j${NBUILDJOBS}
80.endif
81
82# -rw-r--r--
83BINOWN= root
84BINGRP= wheel
85BIN1+=	bootptab changelist csh.cshrc csh.login csh.logout daily \
86	daily.conf dm.conf floppytab ftpchroot ftpusers ftpwelcome \
87	gettytab group hosts hosts.lpd inetd.conf lkm.conf \
88	mailer.conf man.conf monthly monthly.conf mrouted.conf \
89	netconfig networks newsyslog.conf nsswitch.conf ntp.conf \
90	phones printcap profile protocols rbootd.conf rc rc.conf \
91	rc.lkm rc.local rc.subr rc.shutdown remote rpc \
92	security security.conf services shells sysctl.conf syslog.conf \
93	weekly weekly.conf wscons.conf \
94	etc.${MACHINE}/ttys etc.${MACHINE}/disktab
95
96.if	(${MACHINE_ARCH} == "m68k") || \
97	(${MACHINE_ARCH} == "ns32k") || \
98	(${MACHINE_ARCH} == "vax") || \
99	(${MACHINE_ARCH} == "arm32")
100BIN1+=	ld.so.conf
101.elif exists(etc.${MACHINE_ARCH}/ld.so.conf)
102BIN1+=	etc.${MACHINE_ARCH}/ld.so.conf
103.endif
104
105.if exists(etc.${MACHINE_ARCH}/ttyaction)
106BIN1+=	etc.${MACHINE_ARCH}/ttyaction
107.endif
108
109# IPv6
110BIN1+=	rtadvd.conf
111
112# -rw-rw-r--
113BIN2+=	motd
114
115# -rw-------
116BIN3+=	hosts.equiv
117
118NAMEDB=	127 root.cache named.conf localhost loopback.v6
119PCS=	pcs750.bin
120
121all clean cleandir depend distclean etc includes install lint:
122
123.include <bsd.kernobj.mk>
124
125obj:
126	mkdir -p ${KERNOBJDIR}
127
128.ifndef DESTDIR
129distribution distrib-dirs release snapshot snap_pre snap_md_pre \
130snap_md_post iso-image:
131	@echo setenv DESTDIR before doing that!
132	@false
133.else
134distribution: distrib-dirs
135.if !defined(INSTALL_DONE)
136	(cd ..; ${MAKE} _DISTRIB= includes)
137	(cd ..; ${MAKE} _DISTRIB= install)
138.endif
139	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 ${BIN1} \
140	    ${DESTDIR}/etc
141	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 ${BIN2} \
142	    ${DESTDIR}/etc
143	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 ${BIN3} \
144	    ${DESTDIR}/etc
145	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 aliases \
146	    ${DESTDIR}/etc/mail
147	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 crontab \
148	    ${DESTDIR}/var/cron/tabs/root
149	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 master.passwd \
150	    ${DESTDIR}/etc
151	pwd_mkdb -p -d ${DESTDIR}/ ${DESTDIR}/etc/master.passwd
152	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 555 \
153	     MAKEDEV.local etc.${MACHINE}/MAKEDEV ${DESTDIR}/dev
154	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 minfree \
155	    ${DESTDIR}/var/crash
156	(cd root; \
157		${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.cshrc \
158		    ${DESTDIR}/root/.cshrc; \
159		${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 dot.klogin \
160		    ${DESTDIR}/root/.klogin; \
161		${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.login \
162		    ${DESTDIR}/root/.login; \
163		${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.profile \
164		    ${DESTDIR}/root/.profile; \
165		${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.shrc \
166		    ${DESTDIR}/root/.shrc; \
167		rm -f ${DESTDIR}/.cshrc ${DESTDIR}/.profile; \
168		ln ${DESTDIR}/root/.cshrc ${DESTDIR}/.cshrc; \
169		ln ${DESTDIR}/root/.profile ${DESTDIR}/.profile)
170	(cd defaults; ${MAKE} install)
171	(cd mtree; ${MAKE} install)
172	(cd namedb; \
173		${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 \
174		    ${NAMEDB} ${DESTDIR}/etc/namedb)
175	(cd rc.d; ${MAKE} install)
176	/bin/rm -f ${DESTDIR}/etc/localtime
177	ln -s ${TZDIR}/${LOCALTIME} ${DESTDIR}/etc/localtime
178	/bin/rm -f ${DESTDIR}/etc/rmt
179	ln -s /usr/sbin/rmt ${DESTDIR}/etc/rmt
180	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g operator -m 664 /dev/null \
181		${DESTDIR}/etc/dumpdates
182	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g operator -m 600 /dev/null \
183		${DESTDIR}/etc/skeykeys
184	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 /dev/null \
185		${DESTDIR}/var/at/at.deny
186	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 /dev/null \
187		${DESTDIR}/var/cron/log
188	${INSTALL} ${INSTPRIV} -c -o nobody -g ${BINGRP} -m 664 /dev/null \
189		${DESTDIR}/var/db/locate.database
190	${INSTALL} ${INSTPRIV} -c -o uucp -g dialer -m 640 /dev/null \
191		${DESTDIR}/var/log/aculog
192	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
193		${DESTDIR}/var/log/authlog
194	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \
195		${DESTDIR}/var/log/lastlog
196	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 640 /dev/null \
197		${DESTDIR}/var/log/lpd-errs
198	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
199		${DESTDIR}/var/log/maillog
200	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
201		${DESTDIR}/var/log/messages
202	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
203		${DESTDIR}/var/log/secure
204	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
205		${DESTDIR}/var/log/sendmail.st
206	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
207		${DESTDIR}/var/log/wtmp
208	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
209		${DESTDIR}/var/log/xferlog
210	${INSTALL} ${INSTPRIV} -c -o daemon -g staff -m 664 /dev/null \
211		${DESTDIR}/var/msgs/bounds
212	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \
213		${DESTDIR}/var/run/utmp
214	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
215		${DESTDIR}/var/games/atc_scores
216	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
217		${DESTDIR}/var/games/battlestar.log
218	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
219		${DESTDIR}/var/games/cfscores
220	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
221		${DESTDIR}/var/games/criblog
222	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
223		${DESTDIR}/var/games/robots_roll
224	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
225		${DESTDIR}/var/games/rogue.scores
226	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
227		${DESTDIR}/var/games/saillog
228	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
229		${DESTDIR}/var/games/snakerawscores
230	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
231		${DESTDIR}/var/games/snake.log
232	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
233		${DESTDIR}/var/games/tetris.scores
234	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
235		${DESTDIR}/var/games/larn/llog12.0
236	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
237		${DESTDIR}/var/games/larn/lscore12.0
238	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
239		${DESTDIR}/var/games/larn/playerids
240	(cd etc.${MACHINE}; ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} \
241	    -g ${BINGRP} -m 444 fstab.* ${DESTDIR}/etc)
242	(cd ${DESTDIR}/dev; ./MAKEDEV all)
243	(cd skel; ${MAKE} distribution)
244	(cd ../usr.bin/mail; ${MAKE} distribution)
245	(cd ../usr.bin/ssh; ${MAKE} distribution)
246	(cd ../gnu/usr.sbin/postfix/; ${MAKE} distribution)
247.if (${MKCRYPTO} != "no")
248	(cd ../usr.bin/ssh; ${MAKE} distribution)
249.endif
250.ifndef NO_SENDMAIL
251	(cd ../gnu/usr.sbin/sendmail/cf/cf; ${MAKE} distribution)
252	${DESTDIR}/usr/libexec/sendmail/sendmail -C ${DESTDIR}/etc/mail/sendmail.cf -O AliasFile=${DESTDIR}/etc/mail/aliases -O DontBlameSendmail=MapInUnsafeDirPath -bi
253.endif
254
255distrib-dirs:
256	${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${DESTDIR}
257	-mtree -def mtree/NetBSD.dist -p ${DESTDIR}/ -u
258	cd ${DESTDIR}; rm -f sys; ln -s usr/src/sys sys
259
260.if !defined(RELEASEDIR)
261release snapshot snap_pre snap_md_pre snap_md_post iso-image:
262	@echo setenv RELEASEDIR before doing that!
263	@false
264.else
265release snapshot: distribution snap_pre snap_md_pre snap_kern snap_md_post
266	(cd ../distrib/sets; ${MAKE} sets)
267	sh ../distrib/sets/makesums -t ${RELEASEDIR}/binary/kernel '*.gz'
268
269# Standalone target to create a CDROM image after the release
270# was composed. Should be run after "make build" in both src and xsrc
271iso-image: iso-image_md_post
272
273iso-image_mi: iso-image_md_pre
274	@if ${MKISOFS} --version; then \
275		mkdir -p ${RELEASEDIR}/installation/cdrom ; \
276		${MKISOFS} ${MKISOFS_FLAGS} \
277			-o ${RELEASEDIR}/installation/cdrom/netbsd-${MACHINE}.iso \
278			${RELEASEDIR} ; \
279		sh ../distrib/sets/makesums -t ${RELEASEDIR}/installation/cdrom '*.iso' ; \
280	else \
281		echo "install pkgsrc/sysutils/cdrecord and type 'make iso-image'." ; \
282	fi
283
284# Setup the $RELEASEDIR to produce a bootable CD image:
285iso-image_md_pre:
286# nothing here -- look in the machine-dependent Makefile.inc
287
288# Fixup the  CD-image to be bootable
289iso-image_md_post: iso-image_mi
290# nothing here -- look in the machine-dependent Makefile.inc
291
292snap_pre:
293	# Could be a mount point, ignore the errors
294	-/bin/rm -rf ${RELEASEDIR}
295	${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${RELEASEDIR}
296.for dir in ${INSTALLATION_DIRS}
297	${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${RELEASEDIR}/${dir}
298.endfor
299
300
301# This target builds the GENERIC kernel (which must exist for all
302# ports) and puts it in binary/sets/kern.tgz, and also builds any
303# kernels specified in EXTRA_KERNELS. Since NetBSD's kernel build
304# system can create more than one kernel from a single configuration
305# we figure out how many there are, what they're named, and move them
306# to binary/kernel/${KERNEL}.${CONFIGFILE}.gz - most often KERNEL will
307# simply be "netbsd". If we don't find the "config" line, assume the
308# kernel will be "netbsd" (some config files are simple additions on
309# GENERIC, and just include it).
310#
311GETKERNELAWK=	awk '/^config/ {print $$2; found=1} \
312		END{ if (found == 0) print "netbsd"; }'
313#
314.if !target(snap_kern)
315snap_kern:
316.ifndef KERNELS_DONE
317.for configfile in GENERIC ${EXTRA_KERNELS} ${BUILD_KERNELS}
318	cd ${KERNCONFDIR} && ${CONFIG} \
319		-b ${KERNOBJDIR}/${configfile} -s ${KERNSRCDIR} ${configfile}
320.ifndef UPDATE
321	cd ${KERNOBJDIR}/${configfile} && ${MAKE} distclean 
322.endif
323	cd ${KERNOBJDIR}/${configfile} && ${MAKE} depend && ${MAKE} ${_J}
324.endfor # kernels
325	cd ${KERNOBJDIR}/GENERIC &&	\
326		tar cf - `${GETKERNELAWK} ${KERNCONFDIR}/GENERIC` |\
327		gzip -c -9 > ${RELEASEDIR}/binary/sets/kern.tgz
328.for configfile in GENERIC ${EXTRA_KERNELS}
329	cd ${KERNOBJDIR}/${configfile} &&	\
330		for kernel in `${GETKERNELAWK} \
331			${KERNCONFDIR}/${configfile}` ; {   \
332		gzip -c -9 < $${kernel} > \
333			${RELEASEDIR}/binary/kernel/$${kernel}.${configfile}.gz ; }
334.endfor # EXTRA_KERNELS
335.endif # KERNELS_DONE
336.endif # no target(snap_kern)
337
338.endif # RELEASEDIR check
339
340snap_md_pre:
341# nothing here -- look in the machine-dependent Makefile.inc
342
343snap_md_post:
344# nothing here -- look in the machine-dependent Makefile.inc
345
346.endif	# DESTDIR check
347
348.include <bsd.prog.mk>
349