xref: /minix/etc/Makefile (revision 60299d87)
1#	$NetBSD: Makefile,v 1.424 2015/08/31 06:08:07 uebayasi 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#   MKCRYPTO; if not `no', install crypto-related configuration
19#   MKPOSTFIX; if not `no', install postfix configuration
20#   MKUNPRIVED; if not `no', allow non-root installs.
21#   MKUPDATE; if not `no', don't do a 'make clean' before kernel compile
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/${RELEASEMACHINEDIR}.
31#	Any port-dependent stuff for this target is found in
32#	etc.${MACHINE}/Makefile.inc.
33#    release: a synonym for `snapshot'
34#
35
36# For MK* vars
37.include <bsd.own.mk>
38
39.include <bsd.sys.mk>		# for HOST_SH, TOOL_AWK, ...
40.include <bsd.kernobj.mk>	# For KERNSRCDIR, KERNOBJDIR, ...
41.include <bsd.endian.mk>	# For TARGET_ENDIANNESS
42
43.MAKEOVERRIDES+=	USETOOLS
44
45TZDIR=		/usr/share/zoneinfo
46LOCALTIME?=	UTC
47CKSUM?=		${TOOL_CKSUM}
48MAKESUMS=	MAKE=${MAKE:Q} CKSUM=${CKSUM:Q} ${HOST_SH} ${NETBSDSRCDIR}/distrib/sets/makesums
49DISTRIBVER!=	${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh
50
51GZIP_FLAGS= -9 ${GZIP_N_FLAG}
52
53# Flags for creating ISO CDROM image
54# mkisofs is expected to be in $PATH, install via pkgsrc/sysutils/cdrtools
55# Note: At least mkisofs 2.0 should be used.
56#
57.if !defined(__MINIX)
58# LSC: We do not yet support iso creation anyway, then do not try to find it.
59.if !defined(MKISOFS)
60MKISOFS!=       (which mkisofs || echo true) 2>/dev/null
61.endif
62DISTRIBREV!=	${HOST_SH} ${KERNSRCDIR}/conf/osrelease.sh -s
63# ISO 9660 volume ID.  Note that this can only contain [A-Z0-9_].
64ISO_VOLID!=	echo NETBSD_${DISTRIBREV} | tr a-z A-Z
65MKISOFS_FLAGS+= -J -l -hide-joliet-trans-tbl -r -T \
66		-V ${ISO_VOLID} \
67		-publisher "The NetBSD Project" \
68		-m "${RELEASEDIR}/${RELEASEMACHINEDIR}/installation/cdrom"
69.if ${MKISOFS_FLAGS:N-v}
70MKISOFS_FLAGS+=	-quiet
71.endif
72.endif # !defined(__MINIX)
73
74
75# MD Makefile.inc may append MD targets to BIN[123].  Make sure all
76# are empty, to preserve the old semantics of setting them below with "+=".
77#
78BIN1=
79BIN2=
80BIN3=
81
82# Directories to build in ${RELEASEDIR}/${RELEASEMACHINEDIR}.
83# MD Makefile.inc files can add to this.
84# NOTE: Parent directories must be listed before subdirectories.
85#
86INSTALLATION_DIRS=	binary binary/sets binary/kernel installation
87
88.if exists(etc.${RELEASEMACHINE}/Makefile.inc)
89.include "etc.${RELEASEMACHINE}/Makefile.inc"
90.endif
91
92# -rw-r--r--
93BINOWN= root
94BINGRP= wheel
95UTMPGRP= utmp
96.if defined(__MINIX)
97BIN1+=	\
98	\
99	gettytab \
100	man.conf \
101	\
102	passwd.conf \
103	protocols rc rc.cd rc.subr \
104	rc.shutdown services shells \
105	syslog.conf
106# MINIX-only files:
107BIN1+=	boot.cfg.default rc.minix \
108	rs.lwip rs.single termcap utmp
109.else
110BIN1+=	bootptab changelist csh.cshrc csh.login \
111	csh.logout daily daily.conf dm.conf envsys.conf floppytab ftpchroot \
112	ftpusers gettytab gpio.conf group hosts hosts.lpd inetd.conf \
113	locate.conf login.conf mailer.conf man.conf monthly monthly.conf \
114	mrouted.conf named.conf netconfig networks newsyslog.conf \
115	nsswitch.conf ntp.conf passwd.conf pkgpath.conf phones printcap \
116	profile protocols rbootd.conf rc rc.conf rc.local rc.subr \
117	rc.shutdown remote rpc security security.conf services shells \
118	shrc sysctl.conf syslog.conf weekly weekly.conf wscons.conf
119
120# Use machine-specific disktab if it exists, or the MI one otherwise
121.if exists(etc.${MACHINE}/disktab)
122BIN1+=	etc.${MACHINE}/disktab
123.else
124BIN1+=	disktab
125.endif
126
127.if exists(etc.${MACHINE}/ld.so.conf) && empty(MACHINE_ARCH:M*arm*hf*)
128BIN1+=	etc.${MACHINE}/ld.so.conf
129.endif
130
131.if exists(etc.${MACHINE}/ttyaction)
132BIN1+=	etc.${MACHINE}/ttyaction
133.endif
134
135# -rw-rw-r--
136BIN2+=	motd
137FILESBUILD_motd=	YES
138
139# -rw-------
140BIN3+=	hosts.equiv
141.endif # defined(__MINIX)
142
143SYSPKG=	etc
144ETC_PKG=-T etc_pkg
145BASE_PKG=-T base_pkg
146ETC_INSTALL_FILE=cd ${.CURDIR} && ${INSTALL_FILE} ${ETC_PKG}
147ETC_INSTALL_OBJ_FILE=cd ${.OBJDIR} && ${INSTALL_FILE} ${ETC_PKG}
148
149.if ${TARGET_ENDIANNESS} == "1234"
150PWD_MKDB_ENDIAN=	-L
151.elif ${TARGET_ENDIANNESS} == "4321"
152PWD_MKDB_ENDIAN=	-B
153.else
154PWD_MKDB_ENDIAN=
155.endif
156
157
158# distribution --
159#	Build a distribution
160#
161distribution: .PHONY .MAKE check_DESTDIR distrib-dirs
162.if !defined(DISTRIBUTION_DONE)
163.if !defined(INSTALL_DONE)
164	${MAKEDIRTARGET} ${NETBSDSRCDIR} include _DISTRIB=
165	${MAKEDIRTARGET} ${NETBSDSRCDIR} install _DISTRIB=
166.endif	# !INSTALL_DONE
167	${MAKEDIRTARGET} . install-etc-files
168. if ${MKX11} != "no"
169	${MAKEDIRTARGET} ${NETBSDSRCDIR}/external/mit/xorg distribution
170. endif
171. if ${MKEXTSRC} != "no"
172	${MAKEDIRTARGET} ${NETBSDSRCDIR}/extsrc distribution
173. endif
174	${MAKEDIRTARGET} ${NETBSDSRCDIR}/distrib/sets makesetfiles
175.endif	# !DISTRIBUTION_DONE
176
177
178.if !defined(__MINIX)
179# motd is copied from a different ${MOTD_SOURCE} depending on DISTRIBVER
180#
181.if !empty(DISTRIBVER:M*.99.*)
182MOTD_SOURCE=	motd.current
183.elif !empty(DISTRIBVER:M*BETA*)
184MOTD_SOURCE=	motd.beta
185.elif !empty(DISTRIBVER:M*RC*)
186MOTD_SOURCE=	motd.rc
187.elif !empty(DISTRIBVER:M*STABLE*)
188MOTD_SOURCE=	motd.stable
189.else
190MOTD_SOURCE=	motd.default
191.endif
192CLEANFILES+= motd
193motd: ${.CURDIR}/${MOTD_SOURCE} ${_NETBSD_VERSION_DEPENDS}
194	${_MKTARGET_CREATE}
195	${HOST_INSTALL_FILE} ${.CURDIR}/${MOTD_SOURCE} ${.TARGET}
196.endif # !defined(__MINIX)
197
198CLEANFILES+=	MAKEDEV
199.if !defined(__MINIX)
200MAKEDEV_MACHINE=${"${MACHINE_CPU}" == "aarch64":?${MACHINE_CPU}:${MACHINE}}
201MAKEDEV: ${.CURDIR}/MAKEDEV.awk ${.CURDIR}/MAKEDEV.tmpl \
202    ${.CURDIR}/etc.${MAKEDEV_MACHINE}/MAKEDEV.conf
203	${_MKTARGET_CREATE}
204	MACHINE=${MAKEDEV_MACHINE:Q} MACHINE_ARCH=${MACHINE_ARCH:Q} \
205	    NETBSDSRCDIR=${NETBSDSRCDIR:Q} \
206	    ${TOOL_AWK} -f ${.CURDIR}/MAKEDEV.awk ${.CURDIR}/MAKEDEV.tmpl \
207	    > ${.TARGET}
208.else
209MAKEDEV: .PHONY
210	if [ ${MKUNPRIVED} != "yes" ]; then \
211		cd ${DESTDIR}/dev && sh ${NETBSDSRCDIR}/minix/commands/MAKEDEV/MAKEDEV.sh -s; \
212	else \
213		sh ${NETBSDSRCDIR}/minix/commands/MAKEDEV/MAKEDEV.sh -m -s >> ${DESTDIR}/METALOG; \
214	fi
215.endif # !defined(__MINIX)
216
217.include "${NETBSDSRCDIR}/etc/Makefile.params"
218CLEANFILES+=	etc-release
219etc-release: .EXEC .MAKE
220	${_MKTARGET_CREATE}
221	@(	echo "NetBSD ${DISTRIBVER}/${MACHINE}"; \
222		echo ; \
223		cat ${NETBSDSRCDIR}/sys/conf/copyright; \
224		echo ; \
225		echo "Build information:"; \
226		printf "%20s   %s\n" "Build date" "$$(date -u)"; \
227		printf "%20s   %s\n"  "Built by" "$${USER-root}@$$(hostname)"; \
228		if [ -n "${BUILDID}" ]; then \
229		    printf "%20s   %s\n"  "Build ID" "${BUILDID}" ; \
230		fi ; \
231		if [ -n "${BUILDINFO}" ]; then \
232		    echo ; \
233		    info="$$(printf "%b" ${BUILDINFO:Q})" ; \
234		    printf "%s\n" "$${info}" \
235		    | ${TOOL_SED} -e 's/^/        /' ; \
236		fi ; \
237		echo ; \
238		echo "Build settings:"; \
239		echo ; \
240		${PRINT_PARAMS} ; \
241	) >${.OBJDIR}/${.TARGET}
242
243install-etc-release: .PHONY etc-release
244	${_MKMSG_INSTALL} etc/release
245	${ETC_INSTALL_OBJ_FILE} -o ${BINOWN} -g ${BINGRP} -m 444 \
246	    etc-release ${DESTDIR}/etc/release
247
248
249FILESDIR=		/etc
250CONFIGFILES=
251CONFIGSYMLINKS=
252
253.for file in ${BIN1}
254CONFIGFILES+=		${file}
255FILESMODE_${file:T}=	644
256.endfor
257
258.for file in ${BIN2}
259CONFIGFILES+=		${file}
260FILESMODE_${file:T}=	664
261.endfor
262
263.for file in ${BIN3}
264CONFIGFILES+=		${file}
265FILESMODE_${file:T}=	600
266.endfor
267
268.if (${MKPOSTFIX} != "no")
269CONFIGFILES+=		aliases
270FILESDIR_aliases=	/etc/mail
271FILESMODE_aliases=	644
272.endif
273
274.if !defined(__MINIX)
275CONFIGFILES+=		MAKEDEV.local
276FILESDIR_MAKEDEV.local=	/dev
277FILESMODE_MAKEDEV.local=${BINMODE}
278
279CONFIGFILES+=		crontab
280FILESDIR_crontab=	/var/cron/tabs
281FILESNAME_crontab=	root
282FILESMODE_crontab=	600
283
284CONFIGFILES+=		minfree
285FILESDIR_minfree=	/var/crash
286FILESMODE_minfree=	600
287
288CONFIGSYMLINKS+=	${TZDIR}/${LOCALTIME}	/etc/localtime \
289			/usr/sbin/rmt		/etc/rmt
290.else
291CONFIGSYMLINKS+=	\
292			/usr/log		/var/log \
293			/usr/tmp		/var/tmp \
294			/proc/mounts		/etc/mtab \
295			/usr/service/asr	/service/asr
296
297.endif # !defined(__MINIX)
298
299
300# install-etc-files --
301#	Install etc (config) files; not performed by "make build"
302#
303install-etc-files: .PHONY .MAKE check_DESTDIR MAKEDEV
304	${_MKMSG_INSTALL} ${DESTDIR}/etc/master.passwd
305	${ETC_INSTALL_FILE} -o root -g wheel -m 600 \
306	    master.passwd ${DESTDIR}/etc
307	${TOOL_PWD_MKDB} -p ${PWD_MKDB_ENDIAN} -d ${DESTDIR}/ \
308	    ${DESTDIR}/etc/master.passwd
309.if ${MKUNPRIVED} != "no"
310	( \
311		mode=0600; \
312		for metaent in spwd.db passwd pwd.db; do \
313	    		echo "./etc/$${metaent} type=file mode=$${mode} uname=root gname=wheel tags=etc_pkg"; \
314			mode=0644; \
315		done; \
316	) | ${METALOG.add}
317.endif	# MKUNPRIVED != no
318.if defined(__MINIX)
319# BJG: Unsafe (i.e. user-editable) files for Minix
320.for owner group mode sdir tdir files in \
321		${BINOWN} ${BINGRP}	${BINMODE}	${NETBSDSRCDIR}/etc/ ${DESTDIR}/etc/ group \
322		${BINOWN} ${BINGRP}	${BINMODE}	${NETBSDSRCDIR}/etc/ ${DESTDIR}/etc/ hostname.file \
323		${BINOWN} ${BINGRP}	${BINMODE}	${NETBSDSRCDIR}/etc/ ${DESTDIR}/etc/ hosts \
324		${BINOWN} ${BINGRP}	${BINMODE}	${NETBSDSRCDIR}/etc/ ${DESTDIR}/etc/ inetd.conf \
325		${BINOWN} ${BINGRP}	${BINMODE}	${NETBSDSRCDIR}/etc/ ${DESTDIR}/etc/ mk.conf \
326		${BINOWN} ${BINGRP}	${BINMODE}	${NETBSDSRCDIR}/etc/ ${DESTDIR}/etc/ motd \
327		${BINOWN} ${BINGRP}	${BINMODE}	${NETBSDSRCDIR}/etc/ ${DESTDIR}/etc/ named.conf \
328		${BINOWN} ${BINGRP}	${BINMODE}	${NETBSDSRCDIR}/etc/ ${DESTDIR}/etc/ nsswitch.conf \
329		${BINOWN} ${BINGRP}	${BINMODE}	${NETBSDSRCDIR}/etc/ ${DESTDIR}/etc/ rc.conf \
330		${BINOWN} ${BINGRP}	${BINMODE}	${NETBSDSRCDIR}/etc/ ${DESTDIR}/etc/ shrc \
331		${BINOWN} ${BINGRP}	${BINMODE}	${NETBSDSRCDIR}/etc/ ${DESTDIR}/etc/ csh.cshrc \
332		${BINOWN} ${BINGRP}	${BINMODE}	${NETBSDSRCDIR}/etc/ ${DESTDIR}/etc/ csh.login \
333		${BINOWN} ${BINGRP}	${BINMODE}	${NETBSDSRCDIR}/etc/ ${DESTDIR}/etc/ csh.logout \
334		${BINOWN} ${BINGRP}	${BINMODE}	${NETBSDSRCDIR}/etc/ ${DESTDIR}/etc/ profile
335	${_MKMSG_INSTALL} ${DESTDIR}${tdir}${files:T}
336	if [ ! -e ${tdir} ]; then \
337		${INSTALL_DIR} ${tdir}; \
338	fi; \
339	${INSTALL_FILE} -o ${owner} -g ${group} -m ${mode} ${sdir}${files} ${tdir};
340.endfor
341.if ${MKX11} == "yes"
342	${INSTALL_DIR} -o ${BINOWN} -g ${BINGRP} -m 755 ${DESTDIR}/etc/X11
343	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 ${NETBSDSRCDIR}/etc/xorg.conf \
344		${DESTDIR}/etc/X11/xorg.conf
345.endif # ${MKX11} == "yes"
346# LSC: We need a safe install target for etc files, as this is expected from
347# our current user base. This safe version only leaves out the master.passwd
348# file in order not to loose any user account created.
349#
350# BJG: For Minix, the -safe target *is* performed by "make build"
351#
352# LSC: To ensure minimal modifications, the logic is a bit contrived, i.e. the
353# NetBSD build system expect install-etc-files to be unsafe, so what was done
354# is to separate that step into two steps, with the unsafe version refering
355# (not by dependency, to ensure correct order of actions) the safe step, and
356# use the following mapping in the main Makefile:
357#  etcforce -> install-etc-files (default NetBSD target)
358#  etcfiles -> install-etc-files-safe (new -safe- target)
359	${MAKEDIRTARGET} . install-etc-files-safe
360
361install-etc-files-safe: .PHONY .MAKE check_DESTDIR MAKEDEV
362.endif # defined(__MINIX)
363	${_MKMSG_INSTALL} ${DESTDIR}/etc/ttys
364.if !defined(__MINIX)
365.if exists(${.CURDIR}/etc.${MACHINE}/ttys)
366	${ETC_INSTALL_OBJ_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
367	    ${.CURDIR}/etc.${MACHINE}/ttys ${DESTDIR}/etc
368.else
369	${ETC_INSTALL_OBJ_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
370	    ${.CURDIR}/etc.${MACHINE_CPU}/ttys ${DESTDIR}/etc
371.endif
372.else
373	${ETC_INSTALL_OBJ_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
374	    ${.CURDIR}/ttys ${DESTDIR}/etc
375.endif # !defined(__MINIX)
376.if exists(etc.${MACHINE}/boot.cfg)
377	${_MKMSG_INSTALL} ${DESTDIR}/boot.cfg
378	${ETC_INSTALL_OBJ_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
379	    ${.CURDIR}/etc.${MACHINE}/boot.cfg ${DESTDIR}/
380.endif
381.if !defined(__MINIX)
382	${_MKMSG_INSTALL} ${DESTDIR}/dev/MAKEDEV
383	${ETC_INSTALL_OBJ_FILE} -o ${BINOWN} -g ${BINGRP} -m 555 \
384	    MAKEDEV ${DESTDIR}/dev
385.else
386# As /var/log is a symlink to /usr/log, we need to use /usr/log for files
387# in /var/log here.  The same applies to the distrib list entries.
388.for owner group mode file in \
389		${BINOWN} ${BINGRP}	644	/usr/log/messages \
390		${BINOWN} ${BINGRP}	644	/usr/log/syslog \
391		games games		664	/var/games/tetris.scores
392	${_MKMSG_INSTALL} ${DESTDIR}${file}
393	if [ ! -e ${DESTDIR}${file} -o -s ${DESTDIR}${file} ]; then \
394		${ETC_INSTALL_FILE} -o ${owner} -g ${group} -m ${mode} \
395    			/dev/null ${DESTDIR}${file}; \
396	else true; fi
397.endfor
398.endif # !defined(__MINIX)
399# TAC as software is imported, copy the files from the .for block below
400# TAC to the .for block above.
401.if !defined(__MINIX)
402.for owner group mode file in \
403		${BINOWN} operator	664	/etc/dumpdates  \
404		${BINOWN} operator	600	/etc/skeykeys \
405		root wheel		600	/var/at/at.deny \
406		root wheel		644	/var/db/locate.database \
407		${BINOWN} ${BINGRP}	600	/var/log/authlog \
408		root wheel		600	/var/log/cron \
409		${BINOWN} ${UTMPGRP}	664	/var/log/lastlog \
410		${BINOWN} ${UTMPGRP}	664	/var/log/lastlogx \
411		${BINOWN} ${BINGRP}	640	/var/log/lpd-errs \
412		${BINOWN} ${BINGRP}	600	/var/log/maillog \
413		${BINOWN} ${BINGRP}	644	/var/log/messages \
414		${BINOWN} ${BINGRP}	600	/var/log/secure \
415		${BINOWN} ${UTMPGRP}	664	/var/log/wtmp \
416		${BINOWN} ${UTMPGRP}	664	/var/log/wtmpx \
417		${BINOWN} ${BINGRP}	600	/var/log/xferlog \
418		daemon staff		664	/var/msgs/bounds \
419		${BINOWN} ${UTMPGRP}	664	/var/run/utmp \
420		${BINOWN} ${UTMPGRP}	664	/var/run/utmpx \
421		games games		664	/var/games/atc_score \
422		games games		664	/var/games/battlestar.log \
423		games games		664	/var/games/cfscores \
424		games games		664	/var/games/criblog \
425		games games		660	/var/games/hackdir/perm \
426		games games		660	/var/games/hackdir/record \
427		games games		664	/var/games/larn/llog12.0 \
428		games games		664	/var/games/larn/lscore12.0 \
429		games games		664	/var/games/larn/playerids \
430		games games		664	/var/games/robots_roll \
431		games games		664	/var/games/rogue.scores \
432		games games		664	/var/games/saillog \
433		games games		664	/var/games/snakerawscores \
434		games games		664	/var/games/snake.log \
435		games games		664	/var/games/tetris.scores
436	${_MKMSG_INSTALL} ${DESTDIR}${file}
437	if [ ! -e ${DESTDIR}${file} -o -s ${DESTDIR}${file} ]; then \
438		${ETC_INSTALL_FILE} -o ${owner} -g ${group} -m ${mode} \
439    			/dev/null ${DESTDIR}${file}; \
440	else true; fi
441.endfor
442.for subdir in . defaults bluetooth iscsi mtree namedb pam.d powerd rc.d root skel ssh
443	${MAKEDIRTARGET} ${subdir} configinstall
444.endfor
445	${MAKEDIRTARGET} ${NETBSDSRCDIR}/external/bsd/dhcpcd/sbin/dhcpcd configinstall
446	${MAKEDIRTARGET} ${NETBSDSRCDIR}/usr.bin/mail configinstall
447.if (${MKPF} != "no")
448	${MAKEDIRTARGET} ${NETBSDSRCDIR}/usr.sbin/pf configinstall
449.endif
450.if (${MKCRYPTO} != "no")
451	${MAKEDIRTARGET} ${NETBSDSRCDIR}/crypto/external/bsd/openssh/bin configinstall
452.endif
453.if (${MKPOSTFIX} != "no")
454	${MAKEDIRTARGET} ${NETBSDSRCDIR}/external/ibm-public/postfix configinstall
455.endif
456.if (${MKATF} != "no")
457	${MAKEDIRTARGET} ${NETBSDSRCDIR}/external/bsd/atf/etc/atf configinstall
458.endif
459.if (${MKKYUA} != "no")
460	${MAKEDIRTARGET} ${NETBSDSRCDIR}/external/bsd/kyua-cli/etc/kyua configinstall
461.endif
462.else # LSC Minix Specific
463.for owner group mode sdir tdir files in \
464		${BINOWN} ${BINGRP}	${BINMODE}	${NETBSDSRCDIR}/etc/usr/ ${DESTDIR}/usr/etc/ daily \
465		${BINOWN} ${BINGRP}	${BINMODE}	${NETBSDSRCDIR}/etc/usr/ ${DESTDIR}/usr/etc/ rc \
466		${BINOWN} ${BINGRP}	${BINMODE}	${NETBSDSRCDIR}/etc/ ${DESTDIR}/usr/lib/ crontab \
467		${BINOWN} ${BINGRP}	${BINMODE}	${NETBSDSRCDIR}/etc/ ${DESTDIR}/etc/ system.conf \
468		${BINOWN} ${BINGRP}	${NONBINMODE}	${NETBSDSRCDIR}/etc/usr/ ${DESTDIR}/usr/ Makefile \
469		${BINOWN} ${BINGRP}	${BINMODE}	${NETBSDSRCDIR}/etc/devmand/ ${DESTDIR}/etc/devmand/ usb_hub.cfg \
470		${BINOWN} ${BINGRP}	${BINMODE}	${NETBSDSRCDIR}/etc/devmand/ ${DESTDIR}/etc/devmand/ usb_storage.cfg \
471		${BINOWN} ${BINGRP}	${BINMODE}	${NETBSDSRCDIR}/etc/devmand/scripts/ ${DESTDIR}/etc/devmand/scripts/ block  \
472		${BINOWN} ${BINGRP}	${BINMODE}	${NETBSDSRCDIR}/etc/devmand/scripts/ ${DESTDIR}/etc/devmand/scripts/ singlechar \
473
474	${_MKMSG_INSTALL} ${DESTDIR}${tdir}${files:T}
475	if [ ! -e ${tdir} ]; then \
476		${INSTALL_DIR} ${tdir}; \
477	fi; \
478	${INSTALL_FILE} -o ${owner} -g ${group} -m ${mode} ${sdir}${files} ${tdir};
479.endfor
480.if ${MACHINE_ARCH} == "earm"
481	${_MKMSG_INSTALL} ${DESTDIR}/etc/rc.capes
482	${INSTALL_DIR} ${DESTDIR}/etc/rc.capes
483	${INSTALL_FILE} -m ${BINMODE} -o ${BINOWN} -g ${BINGRP} ${NETBSDSRCDIR}/etc/rc.capes/* ${DESTDIR}/etc/rc.capes
484	${INSTALL_FILE} -m ${BINMODE} -o ${BINOWN} -g ${BINGRP} ${NETBSDSRCDIR}/minix/drivers/usb/usbd/usbd.conf ${DESTDIR}/etc/system.conf.d/usbd
485.endif # Minix/earm specific
486.for subdir in . defaults mtree namedb rc.d root skel
487	${MAKEDIRTARGET} ${subdir} configinstall
488.endfor
489	${MAKEDIRTARGET} ${NETBSDSRCDIR}/external/bsd/dhcpcd/sbin/dhcpcd configinstall
490	${_MKMSG_INSTALL} ${DESTDIR}/usr/lib/fonts
491	${INSTALL_DIR} ${DESTDIR}/usr/lib/fonts
492	${INSTALL_FILE} -m ${BINMODE} -o ${BINOWN} -g ${BINGRP} ${NETBSDSRCDIR}/etc/fonts/*.fnt ${DESTDIR}/usr/lib/fonts/
493.endif # LSC Minix Specific
494
495
496# install-obsolete-lists --
497#	Install var/db/obsolete set lists; this is performed by "make build"
498#
499OBSOLETE.dir=		${.OBJDIR}/obsolete.dir
500.if !defined(__MINIX)
501OBSOLETE.files=		base comp etc games man misc text
502.else
503OBSOLETE.files=		minix-base minix-comp minix-games minix-kernel minix-man
504.endif # !defined(__MINIX)
505.if ${MKDEBUG} != "no"
506OBSOLETE.files+=	minix-debug
507.endif
508.if ${MKKMOD} != "no"
509OBSOLETE.files+=	modules
510.endif
511.if ${MKATF} != "no"
512OBSOLETE.files+=	minix-tests tests
513.endif
514.if ${MKX11} != "no"
515OBSOLETE.files+=	xbase xcomp xetc xfont xserver
516.endif
517
518# XXX make "makeobsolete" set wise; then generate files respectively
519install-obsolete-lists: .PHONY .MAKE
520	mkdir -p ${OBSOLETE.dir}
521.if ${MKX11} != "no"
522	(cd ${NETBSDSRCDIR}/distrib/sets && \
523	    AWK=${TOOL_AWK:Q} MAKE=${MAKE:Q} ${HOST_SH} ./makeobsolete -b -t ${OBSOLETE.dir})
524.else
525	(cd ${NETBSDSRCDIR}/distrib/sets && \
526	    AWK=${TOOL_AWK:Q} MAKE=${MAKE:Q} ${HOST_SH} ./makeobsolete -t ${OBSOLETE.dir})
527.endif
528.for file in ${OBSOLETE.files}
529	${_MKMSG_INSTALL} ${DESTDIR}/var/db/obsolete/${file}
530	if [ ! -e ${DESTDIR}/var/db/obsolete/${file} ] || \
531	    ! cmp -s ${OBSOLETE.dir}/${file} ${DESTDIR}/var/db/obsolete/${file}; then \
532		${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
533		    ${OBSOLETE.dir}/${file} ${DESTDIR}/var/db/obsolete; \
534	else true; fi
535.endfor
536
537
538# distrib-dirs --
539#	Populate $DESTDIR with directories needed by NetBSD
540#
541distrib-dirs: .PHONY check_DESTDIR
542	cd ${NETBSDSRCDIR}/etc/mtree && ${MAKE} distrib-dirs
543
544
545# release, snapshot --
546#	Build a full distribution including kernels & install media.
547#
548release snapshot: .PHONY .MAKE check_DESTDIR check_RELEASEDIR snap_md_post
549	${MAKEDIRTARGET} ${NETBSDSRCDIR}/distrib/sets sets
550	${MAKESUMS} -A -t ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets \
551		${KERNEL_SETS:@.SETS.@kern-${.SETS.}.tgz@}
552	${MAKESUMS} -t ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/kernel '*.gz'
553
554
555.if !defined(__MINIX)
556# iso-image --
557#	Standalone target to create a CDROM image after the release
558#	was composed.  Should be run after "make release" in src and xsrc.
559#	The do-iso-image is to be called from etc.$MACHINE/Makefile.inc
560#
561#	Note: At least mkisofs 2.0 should be used.
562#
563CDROM_NAME_ADD?=
564CDROM_IMAGE?=${RELEASEDIR}/images/NetBSD-${DISTRIBVER}-${MACHINE}.iso
565CDROM.dir=	${.OBJDIR}/cdrom.dir
566CDROM.pathlist=	${.OBJDIR}/cdrom.pathlist
567
568iso-image:
569
570.if ${MKISOFS} != true
571do-iso-image: .PHONY check_DESTDIR check_RELEASEDIR iso-image-md-post
572	${MAKESUMS} -t ${RELEASEDIR}/images/ '*.iso'
573	@echo "iso-image created as: ${CDROM_IMAGE}"
574.else
575do-iso-image:
576	@echo iso-image: mkisofs not found
577.endif
578
579iso-image-setup: .PHONY check_RELEASEDIR
580	rm -f ${CDROM.pathlist}
581.for extra in README SOURCE_DATE source
582.if exists(${RELEASEDIR}/${extra})
583	echo "${extra}=${RELEASEDIR}/${extra}" >> ${CDROM.pathlist}
584.endif
585.endfor
586	echo "${MACHINE}/=${RELEASEDIR}/${RELEASEMACHINEDIR}/" >> ${CDROM.pathlist}
587	mkdir -p ${CDROM.dir}
588
589check_imagedir:
590	mkdir -p ${RELEASEDIR}/images
591
592# iso-image-mi --
593#	Create the image after the MD operations have completed.
594#
595iso-image-mi: .PHONY check_DESTDIR check_RELEASEDIR iso-image-md-pre check_imagedir
596	@if ! ${MKISOFS} --version; then \
597		echo "install pkgsrc/sysutils/cdrtools and run 'make iso-image'." ; \
598		false; \
599	fi
600	${MKISOFS} ${MKISOFS_FLAGS} -graft-points -path-list ${CDROM.pathlist} \
601	    -o ${CDROM_IMAGE} ${CDROM.dir}
602
603# iso-image-md-pre --
604#	Setup ${CDROM.dir} to produce a bootable CD image.
605#	Overridden by etc.$MACHINE/Makefile.inc
606#
607iso-image-md-pre: .PHONY check_DESTDIR check_RELEASEDIR iso-image-setup
608#	(empty -- look in the machine-dependent Makefile.inc)
609
610# iso-image-md-post --
611#	Fixup the CD-image to be bootable.
612#	Overridden by etc.$MACHINE/Makefile.inc
613#
614iso-image-md-post: .PHONY check_DESTDIR check_RELEASEDIR iso-image-mi
615#	(empty -- look in the machine-dependent Makefile.inc)
616
617
618# live-image --
619#	Standalone target to create live images after the release was composed.
620#	Should be run after "make release" in src and xsrc.
621#	LIVEIMG_RELEASEDIR specifies where to install live images and
622#	it can be set in MD etc.${MACHINE}/Makefile.inc.
623#
624LIVEIMG_RELEASEDIR?= ${RELEASEDIR}/images
625
626live-image: .PHONY check_DESTDIR check_RELEASEDIR
627	${MAKEDIRTARGET} ${NETBSDSRCDIR}/distrib live_image \
628	    LIVEIMG_RELEASEDIR=${LIVEIMG_RELEASEDIR}
629	${MAKESUMS} -t ${LIVEIMG_RELEASEDIR} '*.img.gz'
630
631# install-image --
632#	Standalone target to create installation images
633#	after the release was composed.
634#	Should be run after "make release" in src and xsrc.
635#	INSTIMG_RELEASEDIR specifies where to install live images and
636#	it can be set in MD etc.${MACHINE}/Makefile.inc.
637#
638INSTIMG_RELEASEDIR?= ${RELEASEDIR}/images
639
640install-image: .PHONY check_DESTDIR check_RELEASEDIR
641	${MAKEDIRTARGET} ${NETBSDSRCDIR}/distrib install_image \
642	    INSTIMG_RELEASEDIR=${INSTIMG_RELEASEDIR}
643	${MAKESUMS} -t ${INSTIMG_RELEASEDIR} '*.img.gz'
644.endif # !defined(__MINIX)
645
646# snap_pre --
647#	Create ${RELEASEDIR} and necessary subdirectories.
648#
649snap_pre: .PHONY check_DESTDIR check_RELEASEDIR distribution
650	${INSTALL} -d -m 755 ${RELEASEDIR}
651.if ${MKUPDATE} == "no"
652# Could be a mount point, ignore the errors
653	-/bin/rm -rf ${RELEASEDIR}/${RELEASEMACHINEDIR}
654.endif
655	${INSTALL} -d -m 755 ${RELEASEDIR}/${RELEASEMACHINEDIR}
656.for dir in ${INSTALLATION_DIRS}
657	${INSTALL} -d -m 755 ${RELEASEDIR}/${RELEASEMACHINEDIR}/${dir}
658.endfor
659
660# snap_post --
661#	Build the install media and notes from distrib
662#
663snap_post: .PHONY .MAKE build_kernelsets build_releasekernels
664.if ${MKUPDATE} == "no"
665	cd ${NETBSDSRCDIR}/distrib && ${MAKE} cleandir
666.endif
667	cd ${NETBSDSRCDIR}/distrib && ${MAKE} depend && ${MAKE} && \
668	    ${MAKE} release
669
670# build kernels --
671#	This target builds the kernels specified by each port.
672#	A port may specify the following kernels:
673#
674#	KERNEL_SETS		The list of kernels that will be
675#				packaged into sets, named
676#				kern-${kernel}.tgz.  These kernels
677#				are also placed in the binary/kernel
678#				area of the release package as
679#				netbsd-${kernel}.gz.
680#
681#	EXTRA_KERNELS		Additional kernels to place in the
682#				binary/kernel area of the release
683#				package as netbsd-${kernel}.gz, but
684#				which are not placed into sets. This
685#				allows a port to provide e.g. a netbootable
686#				installation kernel containing a ramdisk.
687#
688#	BUILD_KERNELS		Additional kernels to build which are
689#				not placed into sets nor into the
690#				binary/kernel area of the release
691#				package.  These are typically kernels
692#				that are built for inclusion only in
693#				installation disk/CD-ROM/tape images.
694#
695#	A port may also specify KERNEL_SUFFIXES, which is an optional list
696#	of filename suffixes for kernels to include in the kernel sets and
697#	in the binary/kernel area of the release package (e.g. "netbsd" vs.
698#	"netbsd.ecoff" and "netbsd.srec").  It is not an error if kernels
699#	with these suffixes do not exist in the kernel build directory.
700#
701#
702# A list of all the kernels to build, which can be overridden from
703# external sources (such as make(1)'s environment or command line)
704#
705ALL_KERNELS?=	${KERNEL_SETS} ${EXTRA_KERNELS} ${BUILD_KERNELS}
706.export ALL_KERNELS
707
708GETKERNELAWK=	${TOOL_AWK} '/^config/ {print $$2; found=1} \
709		END{ if (found == 0) print "netbsd"; }'
710
711build_kernels: .PHONY
712#	Configure & compile kernels listed in ${ALL_KERNELS}
713#
714# The 'sync' is so that all writes during the build are pushed back
715# to the disk.  Not having it causes problems on some host systems
716# (e.g. Linux) when building on NFS.
717#
718.if !defined(KERNELS_DONE)						# {
719.for configfile in ${ALL_KERNELS:O:u}					# {
720build_kernels: kern-${configfile}
721kern-${configfile}: .PHONY .MAKE
722	cd ${KERNCONFDIR} && ${TOOL_CONFIG} ${CONFIGOPTS} -s ${KERNSRCDIR} \
723	    -U DEBUG -b ${KERNOBJDIR}/${configfile:C/.*\///} ${configfile}
724.if ${MKUPDATE} == "no"
725	cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} distclean
726.endif
727	cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} depend && ${MAKE}
728	sync
729.endfor	# ALL_KERNELS							# }
730.endif	# KERNELS_DONE							# }
731
732build_kernelsets: .PHONY
733#	Create kernel sets from ${KERNEL_SETS} into
734#	${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets
735#
736.for configfile in ${KERNEL_SETS:O:u}					# {
737.for configsel in ${ALL_KERNELS:O:u}
738.if ${configfile} == ${configsel}
739build_kernelsets: kernset-${configfile}
740kernset-${configfile}: .PHONY build_kernels snap_pre
741	@ kernlist=$$(${GETKERNELAWK} ${KERNCONFDIR}/${configfile}); \
742	kerndir=${KERNOBJDIR}/${configfile:C/.*\///}; \
743	kernsuffixes="${KERNEL_SUFFIXES:S/^/./}"; \
744	kern_tgz=${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets/kern-${configfile}.tgz; \
745	pax_cmd="GZIP=${GZIP_FLAGS:Q} ${TOOL_PAX} --use-compress-program ${TOOL_GZIP:Q} -O -w -M -N ${NETBSDSRCDIR}/etc -f $${kern_tgz}"; \
746	cd $${kerndir} && { \
747		kernels=; newest=; \
748		for kernel in $${kernlist}; do \
749			for s in "" $${kernsuffixes}; do \
750				ks="$${kernel}$${s}"; \
751				[ -f $${ks} ] || continue; \
752				kernels="$${kernels} $${ks}"; \
753				[ -z "$${newest}" -o $${ks} -nt "$${newest}" ] && \
754					newest=$${ks}; \
755			done; \
756		done; \
757		[ $${kern_tgz} -nt "$${newest}" ] || { \
758			echo "echo $${kernels} | $${pax_cmd}"; \
759			( echo "/set uname=${BINOWN} gname=${BINGRP}"; \
760			echo ". type=dir optional"; \
761			for kernel in $${kernels}; do \
762				echo "./$${kernel} type=file"; \
763			done ) | eval $${pax_cmd}; \
764		} \
765	}
766.endif
767.endfor
768.endfor	# KERNEL_SETS							# }
769
770build_releasekernels: .PHONY
771#	Build kernel.gz from ${KERNEL_SETS} ${EXTRA_KERNELS} into
772#	${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/kernel
773#
774.for configfile in ${KERNEL_SETS:O:u} ${EXTRA_KERNELS:O:u}		# {
775.for configsel in ${ALL_KERNELS:O:u}
776.if ${configfile} == ${configsel}
777build_releasekernels: releasekern-${configfile}
778releasekern-${configfile}: .PHONY build_kernels snap_pre
779	@ kernlist=$$(${GETKERNELAWK} ${KERNCONFDIR}/${configfile:C/.*\///}); \
780	kerndir=${KERNOBJDIR}/${configfile:C/.*\///}; \
781	kernsuffixes="${KERNEL_SUFFIXES:S/^/./}"; \
782	cd $${kerndir} && {	\
783		for kernel in $${kernlist}; do \
784			for s in "" $${kernsuffixes}; do \
785				ks="$${kernel}$${s}"; \
786				[ ! -f $${ks} ] && continue; \
787				knl_gz="${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/kernel/$${kernel}-${configfile:C/.*\///}$${s}.gz"; \
788				[ $${knl_gz} -nt $${ks} ] && continue; \
789				rm -f $${knl_gz}; \
790				echo "${TOOL_GZIP} ${GZIP_FLAGS} -c < $${kerndir}/$${ks} > $${knl_gz}"; \
791				${TOOL_GZIP} ${GZIP_FLAGS} -c < $${ks} > $${knl_gz}; \
792			done; \
793		done; \
794	}
795.endif
796.endfor
797.endfor	# KERNEL_SETS EXTRA_KERNELS					# }
798
799# snap_md_post --
800#	Machine dependent distribution media operations.
801#	Overridden by etc.$MACHINE/Makefile.inc
802#
803snap_md_post: .PHONY check_DESTDIR check_RELEASEDIR snap_post
804#	(empty -- look in the machine-dependent Makefile.inc)
805
806
807clean:
808	-rm -rf ${CDROM.dir} ${CDROM.pathlist} ${OBSOLETE.dir}
809
810.if !defined(__MINIX)
811SUBDIR=	defaults rc.d mtree
812.else
813SUBDIR=	devmand defaults mtree
814.endif # !defined(__MINIX)
815
816.include <bsd.prog.mk>
817.include <bsd.subdir.mk>
818
819test:
820	@echo ${OBSOLETE.files}
821