Makefile revision 1.154.2.5
1#	$NetBSD: Makefile,v 1.154.2.5 2000/10/02 03:06:38 lukem 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 and INSTPRIV
43.include <bsd.own.mk>
44
45TZDIR=		/usr/share/zoneinfo
46LOCALTIME?=	US/Pacific
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}/instalation/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 binary/security 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 iso-image:
130	@echo setenv DESTDIR before doing that!
131	@false
132.else
133distribution: distrib-dirs
134.if !defined(INSTALL_DONE)
135	(cd ..; ${MAKE} _DISTRIB= includes)
136	(cd ..; ${MAKE} _DISTRIB= install)
137.endif
138	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 ${BIN1} \
139	    ${DESTDIR}/etc
140	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 ${BIN2} \
141	    ${DESTDIR}/etc
142	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 ${BIN3} \
143	    ${DESTDIR}/etc
144	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 aliases \
145	    ${DESTDIR}/etc/mail
146	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 crontab \
147	    ${DESTDIR}/var/cron/tabs/root
148	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 master.passwd \
149	    ${DESTDIR}/etc
150	pwd_mkdb -p -d ${DESTDIR}/ ${DESTDIR}/etc/master.passwd
151	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 555 \
152	     MAKEDEV.local etc.${MACHINE}/MAKEDEV ${DESTDIR}/dev
153	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 minfree \
154	    ${DESTDIR}/var/crash
155	(cd root; \
156		${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.cshrc \
157		    ${DESTDIR}/root/.cshrc; \
158		${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 dot.klogin \
159		    ${DESTDIR}/root/.klogin; \
160		${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.login \
161		    ${DESTDIR}/root/.login; \
162		${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.profile \
163		    ${DESTDIR}/root/.profile; \
164		${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.shrc \
165		    ${DESTDIR}/root/.shrc; \
166		rm -f ${DESTDIR}/.cshrc ${DESTDIR}/.profile; \
167		ln ${DESTDIR}/root/.cshrc ${DESTDIR}/.cshrc; \
168		ln ${DESTDIR}/root/.profile ${DESTDIR}/.profile)
169	(cd defaults; ${MAKE} install)
170	(cd mtree; ${MAKE} install)
171	(cd namedb; \
172		${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 \
173		    ${NAMEDB} ${DESTDIR}/etc/namedb)
174	(cd rc.d; ${MAKE} install)
175	/bin/rm -f ${DESTDIR}/etc/localtime
176	ln -s ${TZDIR}/${LOCALTIME} ${DESTDIR}/etc/localtime
177	/bin/rm -f ${DESTDIR}/etc/rmt
178	ln -s /usr/sbin/rmt ${DESTDIR}/etc/rmt
179	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g operator -m 664 /dev/null \
180		${DESTDIR}/etc/dumpdates
181	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g operator -m 600 /dev/null \
182		${DESTDIR}/etc/skeykeys
183	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 /dev/null \
184		${DESTDIR}/var/at/at.deny
185	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 /dev/null \
186		${DESTDIR}/var/cron/log
187	${INSTALL} ${INSTPRIV} -c -o nobody -g ${BINGRP} -m 664 /dev/null \
188		${DESTDIR}/var/db/locate.database
189	${INSTALL} ${INSTPRIV} -c -o uucp -g dialer -m 640 /dev/null \
190		${DESTDIR}/var/log/aculog
191	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
192		${DESTDIR}/var/log/authlog
193	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \
194		${DESTDIR}/var/log/lastlog
195	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 640 /dev/null \
196		${DESTDIR}/var/log/lpd-errs
197	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
198		${DESTDIR}/var/log/maillog
199	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
200		${DESTDIR}/var/log/messages
201	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
202		${DESTDIR}/var/log/secure
203	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
204		${DESTDIR}/var/log/sendmail.st
205	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
206		${DESTDIR}/var/log/wtmp
207	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
208		${DESTDIR}/var/log/xferlog
209	${INSTALL} ${INSTPRIV} -c -o daemon -g staff -m 664 /dev/null \
210		${DESTDIR}/var/msgs/bounds
211	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \
212		${DESTDIR}/var/run/utmp
213	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
214		${DESTDIR}/var/games/atc_scores
215	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
216		${DESTDIR}/var/games/battlestar.log
217	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
218		${DESTDIR}/var/games/cfscores
219	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
220		${DESTDIR}/var/games/criblog
221	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
222		${DESTDIR}/var/games/robots_roll
223	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
224		${DESTDIR}/var/games/rogue.scores
225	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
226		${DESTDIR}/var/games/saillog
227	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
228		${DESTDIR}/var/games/snakerawscores
229	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
230		${DESTDIR}/var/games/snake.log
231	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
232		${DESTDIR}/var/games/tetris.scores
233	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
234		${DESTDIR}/var/games/larn/llog12.0
235	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
236		${DESTDIR}/var/games/larn/lscore12.0
237	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
238		${DESTDIR}/var/games/larn/playerids
239	(cd etc.${MACHINE}; ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} \
240	    -g ${BINGRP} -m 444 fstab.* ${DESTDIR}/etc)
241	(cd ${DESTDIR}/dev; ./MAKEDEV all)
242	(cd ../usr.bin/mail; ${MAKE} distribution)
243	(cd ../usr.bin/ssh; ${MAKE} distribution)
244	(cd ../gnu/usr.sbin/postfix/; ${MAKE} distribution)
245.ifndef NO_SENDMAIL
246	(cd ../gnu/usr.sbin/sendmail/cf/cf; ${MAKE} distribution)
247	${DESTDIR}/usr/libexec/sendmail/sendmail -C ${DESTDIR}/etc/mail/sendmail.cf -O AliasFile=${DESTDIR}/etc/mail/aliases -O DontBlameSendmail=MapInUnsafeDirPath -bi
248.endif
249
250distrib-dirs:
251	${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${DESTDIR}
252	-mtree -def mtree/NetBSD.dist -p ${DESTDIR}/ -u
253	cd ${DESTDIR}; rm -f sys; ln -s usr/src/sys sys
254
255.if !defined(RELEASEDIR)
256release snapshot snap_pre snap_md_pre snap_md_post iso-image:
257	@echo setenv RELEASEDIR before doing that!
258	@false
259.else
260release snapshot: distribution snap_pre snap_md_pre snap_kern snap_md_post
261	(cd ../distrib/sets; ${MAKE} sets)
262	sh ../distrib/sets/makesums -t ${RELEASEDIR}/binary/kernel '*.gz'
263
264# Standalone target to create a CDROM image after the release
265# was composed. Should be run after "make build" in both src and xsrc
266iso-image: iso-image_md_post
267
268iso-image_mi: iso-image_md_pre
269	@if ${MKISOFS} --version; then \
270		mkdir -p ${RELEASEDIR}/installation/cdrom ; \
271		${MKISOFS} ${MKISOFS_FLAGS} \
272			-o ${RELEASEDIR}/installation/cdrom/netbsd-${MACHINE}.iso \
273			${RELEASEDIR} ; \
274		sh ../distrib/sets/makesums -t ${RELEASEDIR}/installation/cdrom '*.iso' ; \
275	else \
276		echo "install pkgsrc/sysutils/cdrecord and type 'make iso-image'." ; \
277	fi
278
279# Setup the $RELEASEDIR to produce a bootable CD image:
280iso-image_md_pre:
281# nothing here -- look in the machine-dependent Makefile.inc
282
283# Fixup the  CD-image to be bootable
284iso-image_md_post: iso-image_mi
285# nothing here -- look in the machine-dependent Makefile.inc
286
287snap_pre:
288	/bin/rm -rf ${RELEASEDIR}
289	${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${RELEASEDIR}
290.for dir in ${INSTALLATION_DIRS}
291	${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${RELEASEDIR}/${dir}
292.endfor
293
294
295# This target builds the GENERIC kernel (which must exist for all
296# ports) and puts it in binary/sets/kern.tgz, and also builds any
297# kernels specified in EXTRA_KERNELS. Since NetBSD's kernel build
298# system can create more than one kernel from a single configuration
299# we figure out how many there are, what they're named, and move them
300# to binary/kernel/${KERNEL}.${CONFIGFILE}.gz - most often KERNEL will
301# simply be "netbsd". If we don't find the "config" line, assume the
302# kernel will be "netbsd" (some config files are simple additions on
303# GENERIC, and just include it).
304#
305GETKERNELAWK=	awk '/^config/ {print $$2; found=1} \
306		END{ if (found == 0) print "netbsd"; }'
307#
308.if !target(snap_kern)
309snap_kern:
310.ifndef KERNELS_DONE
311.for configfile in GENERIC ${EXTRA_KERNELS} ${BUILD_KERNELS}
312	cd ${KERNCONFDIR} && ${CONFIG} \
313		-b ${KERNOBJDIR}/${configfile} -s ${KERNSRCDIR} ${configfile}
314.ifndef UPDATE
315	cd ${KERNOBJDIR}/${configfile} && ${MAKE} clean 
316.endif
317	cd ${KERNOBJDIR}/${configfile} && ${MAKE} depend && ${MAKE} ${_J}
318.endfor # kernels
319	cd ${KERNOBJDIR}/GENERIC &&	\
320		tar cf - `${GETKERNELAWK} ${KERNCONFDIR}/GENERIC` |\
321		gzip -c -9 > ${RELEASEDIR}/binary/sets/kern.tgz
322.for configfile in GENERIC ${EXTRA_KERNELS}
323	cd ${KERNOBJDIR}/${configfile} &&	\
324		for kernel in `${GETKERNELAWK} \
325			${KERNCONFDIR}/${configfile}` ; {   \
326		gzip -c -9 < $${kernel} > \
327			${RELEASEDIR}/binary/kernel/$${kernel}.${configfile}.gz ; }
328.endfor # EXTRA_KERNELS
329.endif # KERNELS_DONE
330.endif # no target(snap_kern)
331
332.endif # RELEASEDIR check
333
334snap_md_pre:
335# nothing here -- look in the machine-dependent Makefile.inc
336
337snap_md_post:
338# nothing here -- look in the machine-dependent Makefile.inc
339
340.endif	# DESTDIR check
341
342.include <bsd.prog.mk>
343