Makefile revision 1.219.2.3
1#	$NetBSD: Makefile,v 1.219.2.3 2002/06/11 16:15:57 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, but can be overridden.
16#   KERNCONFDIR is where the configuration files for kernels are found;
17#	default is ${KERNSRCDIR}/arch/${MACHINE}/conf but can be overridden.
18#   UPDATE is normally undefined; if defined, don't do a 'make clean'
19#	before kernel compile
20#   NO_SENDMAIL is normally undefined; if defined, it will not do a
21#	`make distribution' in the sendmail config file source directory.
22#
23# Targets:
24#    distribution: makes a full NetBSD distribution in DESTDIR. If
25#	INSTALL_DONE is set, it will not do a `make install.'
26#	if DISTRIBUTION_DONE is set, it will not do anything.
27#    distrib-dirs: creates an empty NetBSD directory tree in DESTDIR.
28#	Called by distribution.
29#    snapshot: calls distribution, above, and then tars up the files
30#	into a release(7) format in RELEASEDIR. Any port-dependent
31#	stuff for this target is found in etc.${MACHINE}/Makefile.inc.
32#    release: a synonym for `snapshot'
33
34# setting NOOBJ prevents "make obj" from doing anything;
35# an objdir would break the installation stuff below
36NOOBJ=		# defined
37
38# For NO_SENDMAIL, INSTPRIV, MKCRYPTO
39.include <bsd.own.mk>
40
41# For KERNSRCDIR, KERNOBJDIR, ...
42.include <bsd.kernobj.mk>
43
44
45.MAKEOVERRIDES+=	USETOOLS
46
47TZDIR=		/usr/share/zoneinfo
48LOCALTIME?=	UTC
49PWD_MKDB?=	pwd_mkdb
50MAKESUMS=	CKSUM=${CKSUM:Q} sh ../distrib/sets/makesums
51
52# Flags for creating ISO CDROM image
53# mkisofs is expected to be in $PATH, install via pkgsrc/sysutils/cdrecord
54MKISOFS?=	mkisofs
55MKISOFS_FLAGS+= -J -l \
56		-r -T -v \
57		-P "The NetBSD Project" \
58		-m "${RELEASEDIR}/installation/cdrom"
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=	binary binary/sets binary/kernel installation
70
71.if exists(etc.${MACHINE}/Makefile.inc)
72.include "etc.${MACHINE}/Makefile.inc"
73.endif
74
75# -rw-r--r--
76BINOWN= root
77BINGRP= wheel
78BIN1+=	bootptab changelist csh.cshrc csh.login csh.logout daily \
79	daily.conf dm.conf floppytab ftpchroot ftpusers ftpwelcome \
80	gettytab group hosts hosts.lpd inetd.conf lkm.conf \
81	mailer.conf man.conf monthly monthly.conf mrouted.conf \
82	netconfig networks newsyslog.conf nsswitch.conf ntp.conf \
83	passwd.conf phones printcap profile protocols rbootd.conf rc rc.conf \
84	rc.lkm rc.local rc.subr rc.shutdown remote rpc \
85	security security.conf services shells sysctl.conf syslog.conf \
86	weekly weekly.conf wscons.conf \
87	etc.${MACHINE}/ttys etc.${MACHINE}/disktab
88
89.if	(${MACHINE_ARCH} == "m68k") || \
90	(${MACHINE_ARCH} == "ns32k") || \
91	(${MACHINE_ARCH} == "vax")
92BIN1+=	ld.so.conf
93.elif exists(etc.${MACHINE_ARCH}/ld.so.conf)
94BIN1+=	etc.${MACHINE_ARCH}/ld.so.conf
95.endif
96
97.if exists(etc.${MACHINE_ARCH}/ttyaction)
98BIN1+=	etc.${MACHINE_ARCH}/ttyaction
99.endif
100
101# -rw-rw-r--
102BIN2+=	motd
103
104# -rw-------
105BIN3+=	hosts.equiv
106
107NAMEDB=	127 root.cache named.conf localhost loopback.v6
108
109.if make(install-etc-files)						# {
110.include <bsd.endian.mk>
111.if ${TARGET_ENDIANNESS} == "1234"
112TARGET_ENDIANNESS=	-L
113.elif ${TARGET_ENDIANNESS} == "4321"
114TARGET_ENDIANNESS=	-B
115.else
116TARGET_ENDIANNESS=
117.endif
118.endif	# install-etc-files						# }
119
120obj:
121	mkdir -p ${KERNOBJDIR}
122
123distribution: check_DESTDIR .WAIT distrib-dirs
124.if !defined(DISTRIBUTION_DONE)
125.if !defined(INSTALL_DONE)
126	(cd ..; ${MAKE} _DISTRIB= includes)
127	(cd ..; ${MAKE} _DISTRIB= install)
128.endif	# !INSTALL_DONE
129	${MAKE} install-etc-files
130.endif	# !DISTRIBUTION_DONE
131
132install-etc-files: check_DESTDIR
133	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 ${BIN1} ${DESTDIR}/etc
134	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 664 ${BIN2} ${DESTDIR}/etc
135	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 ${BIN3} ${DESTDIR}/etc
136	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 aliases \
137	    ${DESTDIR}/etc/mail
138	${INSTALL_FILE} -o root -g wheel -m 600 crontab \
139	    ${DESTDIR}/var/cron/tabs/root
140	${INSTALL_FILE} -o root -g wheel -m 600 master.passwd ${DESTDIR}/etc
141	${PWD_MKDB} -p ${TARGET_ENDIANNESS} -d ${DESTDIR}/ \
142		${DESTDIR}/etc/master.passwd
143.if defined(UNPRIVED)
144	( \
145	    echo "/etc/passwd type=file mode=0644 uname=root gname=wheel"; \
146	    echo "/etc/pwd.db type=file mode=0644 uname=root gname=wheel"; \
147	    echo "/etc/spwd.db type=file mode=0600 uname=root gname=wheel"; \
148	) | \
149	    sed -e "s|^/|./${DESTDIR}/|g" -e "s|//|/|g" | ${CAT} -l >>${METALOG}
150.endif	# UNPRIVED
151	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 555 \
152	     MAKEDEV.local etc.${MACHINE}/MAKEDEV ${DESTDIR}/dev
153	${INSTALL_FILE} -o root -g wheel -m 600 minfree ${DESTDIR}/var/crash
154	(cd root; \
155		${INSTALL_FILE} -o root -g wheel -m 644 dot.cshrc \
156		    ${DESTDIR}/root/.cshrc; \
157		${INSTALL_FILE} -o root -g wheel -m 600 dot.klogin \
158		    ${DESTDIR}/root/.klogin; \
159		${INSTALL_FILE} -o root -g wheel -m 644 dot.login \
160		    ${DESTDIR}/root/.login; \
161		${INSTALL_FILE} -o root -g wheel -m 644 dot.profile \
162		    ${DESTDIR}/root/.profile; \
163		${INSTALL_FILE} -o root -g wheel -m 644 dot.shrc \
164		    ${DESTDIR}/root/.shrc; \
165		rm -f ${DESTDIR}/.cshrc ${DESTDIR}/.profile; \
166		${INSTALL_LINK} ${DESTDIR}/root/.cshrc ${DESTDIR}/.cshrc; \
167		${INSTALL_LINK} ${DESTDIR}/root/.profile ${DESTDIR}/.profile)
168	(cd defaults; ${MAKE} install)
169	(cd mtree; ${MAKE} install)
170	(cd namedb; \
171		${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
172		    ${NAMEDB} ${DESTDIR}/etc/namedb)
173	(cd rc.d; ${MAKE} install)
174	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
175		postinstall ${DESTDIR}/etc
176	${INSTALL_SYMLINK} -o root -g wheel -m 755 \
177		${TZDIR}/${LOCALTIME} ${DESTDIR}/etc/localtime
178	${INSTALL_SYMLINK} -o root -g wheel -m 755 \
179		/usr/sbin/rmt ${DESTDIR}/etc/rmt
180	${INSTALL_FILE} -o ${BINOWN} -g operator -m 664 /dev/null \
181		${DESTDIR}/etc/dumpdates
182	${INSTALL_FILE} -o ${BINOWN} -g operator -m 600 /dev/null \
183		${DESTDIR}/etc/skeykeys
184	${INSTALL_FILE} -o root -g wheel -m 600 /dev/null \
185		${DESTDIR}/var/at/at.deny
186	${INSTALL_FILE} -o root -g wheel -m 600 /dev/null \
187		${DESTDIR}/var/cron/log
188	${INSTALL_FILE} -o nobody -g ${BINGRP} -m 664 /dev/null \
189		${DESTDIR}/var/db/locate.database
190	${INSTALL_FILE} -o uucp -g dialer -m 640 /dev/null \
191		${DESTDIR}/var/log/aculog
192	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
193		${DESTDIR}/var/log/authlog
194	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \
195		${DESTDIR}/var/log/lastlog
196	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 640 /dev/null \
197		${DESTDIR}/var/log/lpd-errs
198	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
199		${DESTDIR}/var/log/maillog
200	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
201		${DESTDIR}/var/log/messages
202	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
203		${DESTDIR}/var/log/secure
204	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
205		${DESTDIR}/var/log/sendmail.st
206	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
207		${DESTDIR}/var/log/wtmp
208	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
209		${DESTDIR}/var/log/xferlog
210	${INSTALL_FILE} -o daemon -g staff -m 664 /dev/null \
211		${DESTDIR}/var/msgs/bounds
212	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \
213		${DESTDIR}/var/run/utmp
214	${INSTALL_FILE} -o games -g games -m 664 /dev/null \
215		${DESTDIR}/var/games/atc_scores
216	${INSTALL_FILE} -o games -g games -m 664 /dev/null \
217		${DESTDIR}/var/games/battlestar.log
218	${INSTALL_FILE} -o games -g games -m 664 /dev/null \
219		${DESTDIR}/var/games/cfscores
220	${INSTALL_FILE} -o games -g games -m 664 /dev/null \
221		${DESTDIR}/var/games/criblog
222	${INSTALL_FILE} -o games -g games -m 664 /dev/null \
223		${DESTDIR}/var/games/robots_roll
224	${INSTALL_FILE} -o games -g games -m 664 /dev/null \
225		${DESTDIR}/var/games/rogue.scores
226	${INSTALL_FILE} -o games -g games -m 664 /dev/null \
227		${DESTDIR}/var/games/saillog
228	${INSTALL_FILE} -o games -g games -m 664 /dev/null \
229		${DESTDIR}/var/games/snakerawscores
230	${INSTALL_FILE} -o games -g games -m 664 /dev/null \
231		${DESTDIR}/var/games/snake.log
232	${INSTALL_FILE} -o games -g games -m 664 /dev/null \
233		${DESTDIR}/var/games/tetris.scores
234	${INSTALL_FILE} -o games -g games -m 664 /dev/null \
235		${DESTDIR}/var/games/larn/llog12.0
236	${INSTALL_FILE} -o games -g games -m 664 /dev/null \
237		${DESTDIR}/var/games/larn/lscore12.0
238	${INSTALL_FILE} -o games -g games -m 664 /dev/null \
239		${DESTDIR}/var/games/larn/playerids
240	(cd skel; ${MAKE} distribution)
241	(cd ../usr.bin/mail; ${MAKE} distribution)
242	(cd ../gnu/usr.sbin/postfix/; ${MAKE} distribution)
243.if (${MKCRYPTO} != "no")
244	(cd ../usr.bin/ssh; ${MAKE} distribution)
245.endif
246.if !defined(NO_SENDMAIL)
247	(cd ../gnu/usr.sbin/sendmail/cf/cf; ${MAKE} distribution)
248.endif
249
250distrib-dirs: check_DESTDIR
251	${INSTALL_DIR} -o root -g wheel -m 755 ${DESTDIR}
252	${MTREE} -def mtree/NetBSD.dist -p ${DESTDIR}/ -U ${UNPRIVED:D-W}
253	rm -f ${DESTDIR}/sys
254	${INSTALL_SYMLINK} -o root -g wheel -m 755 usr/src/sys ${DESTDIR}/sys
255
256release snapshot: check_DESTDIR check_RELEASEDIR .WAIT \
257    distribution .WAIT snap_pre snap_md_pre .WAIT snap_kern .WAIT snap_md_post
258	(cd ../distrib/sets; ${MAKE} sets)
259	${MAKESUMS} -t ${RELEASEDIR}/binary/kernel '*.gz'
260
261# Standalone target to create a CDROM image after the release
262# was composed. Should be run after "make build" in both src and xsrc
263iso-image: check_DESTDIR check_RELEASEDIR .WAIT iso-image_md_post
264
265iso-image_mi: check_DESTDIR check_RELEASEDIR .WAIT iso-image_md_pre
266	@if ${MKISOFS} --version; then \
267		mkdir -p ${RELEASEDIR}/installation/cdrom ; \
268		${MKISOFS} ${MKISOFS_FLAGS} \
269			-o ${RELEASEDIR}/installation/cdrom/netbsd-${MACHINE}.iso \
270			${RELEASEDIR} ; \
271		${MAKESUMS} -t ${RELEASEDIR}/installation/cdrom '*.iso' ; \
272	else \
273		echo "install pkgsrc/sysutils/cdrecord and type 'make iso-image'." ; \
274	fi
275
276# Setup the $RELEASEDIR to produce a bootable CD image:
277iso-image_md_pre: check_DESTDIR check_RELEASEDIR
278# nothing here -- look in the machine-dependent Makefile.inc
279
280# Fixup the  CD-image to be bootable
281iso-image_md_post: check_DESTDIR check_RELEASEDIR .WAIT iso-image_mi
282# nothing here -- look in the machine-dependent Makefile.inc
283
284snap_pre: check_DESTDIR check_RELEASEDIR
285# Could be a mount point, ignore the errors
286	-/bin/rm -rf ${RELEASEDIR}
287	${INSTALL} -d -m 755 ${RELEASEDIR}
288.for dir in ${INSTALLATION_DIRS}
289	${INSTALL} -d -m 755 ${RELEASEDIR}/${dir}
290.endfor
291
292# This target builds the kernels specified by each port.  A port may
293# specify the following kernels:
294#
295#	KERNEL_SETS		The list of kernels that will be
296#				packaged into sets, named
297#				kern-${kernel}.tgz.  These kernels
298#				are also placed in the binary/kernel
299#				area of the release package as
300#				netbsd-${kernel}.gz.
301#
302#	EXTRA_KERNELS		Additional kernels to place in the
303#				binary/kernel area of the release
304#				package as netbsd-${kernel}.gz, but
305#				which are not placed into sets. This
306#				allows a port to provide e.g. a netbootable
307#				installation kernel containing a ramdisk.
308#
309#	BUILD_KERNELS		Additional kernels to build which are
310#				not placed into sets nor into the
311#				binary/kernel area of the release
312#				package.  These are typically kernels
313#				that are built for inclusion only in
314#				installation disk/CD-ROM/tape images.
315#
316# A port may also specify KERNEL_SUFFIXES, which is an optional list
317# of filename suffixes for kernels to include in the kernel sets and
318# in the binary/kernel area of the release package (e.g. "netbsd" vs.
319# "netbsd.ecoff" and "netbsd.srec").  It is not an error if kernels
320# with these suffixes do not exist in the kernel build directory.
321#
322GETKERNELAWK=	awk '/^config/ {print $$2; found=1} \
323		END{ if (found == 0) print "netbsd"; }'
324#
325.if !target(snap_kern)
326snap_kern: check_DESTDIR check_RELEASEDIR
327.if !defined(KERNELS_DONE)						# {
328.for configfile in ${KERNEL_SETS} ${EXTRA_KERNELS} ${BUILD_KERNELS}
329	cd ${KERNCONFDIR} && ${CONFIG} \
330		-b ${KERNOBJDIR}/${configfile:C/.*\///} -s ${KERNSRCDIR} ${configfile}
331.if !defined(UPDATE)
332	cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} distclean
333.endif
334	cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} depend && ${MAKE}
335.endfor # build kernels
336.endif # KERNELS_DONE							# }
337.for configfile in ${KERNEL_SETS}
338	kernlist=`${GETKERNELAWK} ${KERNCONFDIR}/${configfile}`; \
339	kerndir=${KERNOBJDIR}/${configfile:C/.*\///}; \
340	kernsuffixes="${KERNEL_SUFFIXES}"; \
341	cd $${kerndir} && ( \
342		echo "/set uname=${BINOWN} gname=${BINGRP}"; \
343		echo ". type=dir optional"; \
344		for kernel in $${kernlist}; do \
345			echo "./$${kernel} type=file"; \
346			for s in $${kernsuffixes}; do \
347				if [ -f $${kernel}.$${s} ]; then \
348					echo "./$${kernel}.$${s} type=file"; \
349				fi; \
350			done; \
351		done ) | GZIP=-9 ${PAX} -zw \
352		    -M ${UNPRIVED:D-N${NETBSDSRCDIR}/etc} \
353		    -f ${RELEASEDIR}/binary/sets/kern-${configfile}.tgz
354.endfor # make kernel sets
355.for configfile in ${KERNEL_SETS} ${EXTRA_KERNELS}
356	kernlist=`${GETKERNELAWK} ${KERNCONFDIR}/${configfile:C/.*\///}`; \
357	kerndir=${KERNOBJDIR}/${configfile:C/.*\///}; \
358	kernsuffixes="${KERNEL_SUFFIXES}"; \
359	cd $${kerndir} &&	\
360		gziplist=`for kernel in $${kernlist}; do \
361			echo "$${kernel}"; \
362			for s in $${kernsuffixes}; do \
363				if [ -f $${kernel}.$${s} ]; then \
364					echo "$${kernel}.$${s}"; \
365				fi; \
366			done; \
367		done`; \
368		for kernel in $${gziplist} ; do \
369		gzip -c -9 < $${kernel} > \
370		    ${RELEASEDIR}/binary/kernel/$${kernel}-${configfile:C/.*\///}.gz ; done
371.endfor # place KERNEL_SETS kernels + EXTRA_KERNELS in binary/kernel/...
372.endif # no target(snap_kern)
373
374snap_md_pre: check_DESTDIR check_RELEASEDIR
375# nothing here -- look in the machine-dependent Makefile.inc
376
377snap_md_post: check_DESTDIR check_RELEASEDIR
378# nothing here -- look in the machine-dependent Makefile.inc
379
380.include <bsd.prog.mk>
381