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