Makefile revision 1.476
1#	$OpenBSD: Makefile,v 1.476 2019/12/21 21:40:00 espie Exp $
2
3.include <bsd.own.mk>
4
5TZDIR=		/usr/share/zoneinfo
6LOCALTIME=	Canada/Mountain
7MTREEDIR=	/etc/mtree
8
9NOOBJ=
10
11KERNELS = GENERIC bsd
12
13.if exists(etc.${MACHINE}/Makefile.inc)
14.include "etc.${MACHINE}/Makefile.inc"
15.endif
16
17.for CONF K in ${KERNELS}
18.  if !target($K)
19$K:
20	cd ../sys/arch/${MACHINE}/compile/${CONF} && \
21		{ [[ -n "${KEEPKERNELS}" ]] || ${MAKE} cleandir; } && \
22		${MAKE} config && ${MAKE} clean && exec ${MAKE};
23.  endif
24ALL_KERNELS += $K
25.endfor
26
27kernels: ${ALL_KERNELS}
28.for CONF K in ${KERNELS}
29	cp ../sys/arch/${MACHINE}/compile/${CONF}/obj/bsd ${RELEASEDIR}/$K
30	chmod a+r ${RELEASEDIR}/$K
31.endfor
32	cd ${.CURDIR}/../sys/arch/${MACHINE}/compile/ && \
33		tar -chzf ${DESTDIR}/usr/share/relink/kernel.tgz -s ',/obj/,/,' \
34		GENERIC*/obj/*.o GENERIC*/obj/Makefile \
35		GENERIC*/obj/ld.script GENERIC*/obj/makegap.sh
36	chown root:wheel ${DESTDIR}/usr/share/relink/kernel.tgz
37	chmod 644 ${DESTDIR}/usr/share/relink/kernel.tgz
38
39# -rw-r--r--
40BINOWN= root
41BINGRP= wheel
42MUTABLE=changelist daily etc.${MACHINE}/disktab \
43	etc.${MACHINE}/login.conf ftpusers gettytab group ksh.kshrc locate.rc \
44	mailer.conf moduli monthly netstart newsyslog.conf ntpd.conf \
45	pf.os protocols rc rc.conf rpc services shells syslog.conf weekly
46
47# -rw-r--r--
48EXAMPLES=acme-client.conf chio.conf dhclient.conf dhcpd.conf exports \
49	httpd.conf ifstated.conf inetd.conf man.conf mixerctl.conf \
50	mrouted.conf ntpd.conf printcap rad.conf rbootd.conf \
51	remote sensorsd.conf wsconsctl.conf
52
53# -rw-------
54EXAMPLES_600=bgpd.conf doas.conf dvmrpd.conf eigrpd.conf hostapd.conf \
55	iked.conf ipsec.conf ldapd.conf ldpd.conf ospf6d.conf ospfd.conf \
56	pf.conf radiusd.conf rc.local rc.securelevel rc.shutdown relayd.conf \
57	ripd.conf sasyncd.conf snmpd.conf vm.conf ypldap.conf
58
59# -r-xr-xr-x
60RCDAEMONS=amd apmd bgpd bootparamd cron dhcpd dhcrelay dhcrelay6 dvmrpd \
61	eigrpd ftpd ftpproxy ftpproxy6 hostapd hotplugd httpd identd ifstated \
62	iked inetd isakmpd iscsid ldapd ldattach ldomd ldpd lockd \
63	lpd mopd mountd mrouted nfsd npppd nsd ntpd ospf6d ospfd \
64	pflogd portmap rad radiusd rarpd rbootd rebound relayd ripd route6d \
65	sasyncd sensorsd slowcgi slaacd smtpd sndiod snmpd spamd \
66	spamlogd sshd statd switchd syslogd tftpd tftpproxy unbound \
67	unwind vmd watchdogd wsmoused xenodm ypbind ypldap ypserv
68
69MISETS=	base${OSrev}.tgz comp${OSrev}.tgz man${OSrev}.tgz game${OSrev}.tgz
70
71all clean cleandir etc install:
72
73install-mtree:
74	${INSTALL} -c -o root -g wheel -m 600 mtree/special \
75	    ${DESTDIR}${MTREEDIR}
76	${INSTALL} -c -o root -g wheel -m 444 mtree/4.4BSD.dist \
77	    ${DESTDIR}${MTREEDIR}
78	${INSTALL} -c -o root -g wheel -m 444 mtree/BSD.x11.dist \
79	    ${DESTDIR}${MTREEDIR}
80
81.ifndef DESTDIR
82distribution-etc-root-var distribution distrib-dirs release:
83	@echo setenv DESTDIR before doing that!
84	@false
85.else
86distribution-etc-root-var: distrib-dirs
87	${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 644 ${MUTABLE} ${DESTDIR}/etc
88	sh ttys.pty | cat etc.${MACHINE}/ttys - > ${DESTDIR}/etc/ttys && \
89	    chown ${BINOWN}:${BINGRP} ${DESTDIR}/etc/ttys && \
90	    chmod 644 ${DESTDIR}/etc/ttys
91	cat examples/sysctl.conf etc.${MACHINE}/sysctl.conf > \
92	    ${DESTDIR}/etc/examples/sysctl.conf && \
93	    chown ${BINOWN}:${BINGRP} ${DESTDIR}/etc/examples/sysctl.conf && \
94	    chmod 644 ${DESTDIR}/etc/examples/sysctl.conf
95	cat fbtab.head etc.${MACHINE}/fbtab fbtab.tail > ${DESTDIR}/etc/fbtab && \
96	    chown ${BINOWN}:${BINGRP} ${DESTDIR}/etc/fbtab && \
97	    chmod 644 ${DESTDIR}/etc/fbtab
98	${INSTALL} -c -o ${BINOWN} -g operator -m 664 motd ${DESTDIR}/etc
99	${INSTALL} -c -o root -g crontab -m 600 crontab ${DESTDIR}/var/cron/tabs/root
100	${INSTALL} -c -o root -g wheel -m 600 master.passwd ${DESTDIR}/etc
101	pwd_mkdb -p -d ${DESTDIR}/etc /etc/master.passwd
102	chown root:wheel ${DESTDIR}/etc/passwd ${DESTDIR}/etc/pwd.db
103	chown root:_shadow ${DESTDIR}/etc/spwd.db
104	${INSTALL} -c -o root -g wheel -m 600 pf.conf ${DESTDIR}/etc
105	${INSTALL} -c -o root -g _nsd -m 640 nsd.conf ${DESTDIR}/var/nsd/etc
106	${INSTALL} -c -o root -g wheel -m 644 unbound.conf ${DESTDIR}/var/unbound/etc
107	${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 555 \
108	    etc.${MACHINE}/MAKEDEV ${DESTDIR}/dev
109	cd root; \
110		${INSTALL} -c -o root -g wheel -m 644 dot.cshrc \
111		    ${DESTDIR}/root/.cshrc; \
112		${INSTALL} -c -o root -g wheel -m 644 dot.login \
113		    ${DESTDIR}/root/.login; \
114		${INSTALL} -c -o root -g wheel -m 644 dot.profile \
115		    ${DESTDIR}/root/.profile; \
116		${INSTALL} -c -o root -g wheel -m 644 dot.Xdefaults \
117		    ${DESTDIR}/root/.Xdefaults; \
118		${INSTALL} -c -o root -g wheel -m 644 dot.cvsrc \
119		    ${DESTDIR}/root/.cvsrc; \
120		${INSTALL} -c -o root -g wheel -m 600 /dev/null \
121		    ${DESTDIR}/root/.ssh/authorized_keys; \
122		rm -f ${DESTDIR}/.cshrc ${DESTDIR}/.profile; \
123		${INSTALL} -c -o root -g wheel -m 644 dot.cshrc \
124		    ${DESTDIR}/.cshrc; \
125		${INSTALL} -c -o root -g wheel -m 644 dot.profile \
126		    ${DESTDIR}/.profile
127	cd skel; \
128		${INSTALL} -c -o root -g wheel -m 644 dot.cshrc \
129		    ${DESTDIR}/etc/skel/.cshrc; \
130		${INSTALL} -c -o root -g wheel -m 644 dot.login \
131		    ${DESTDIR}/etc/skel/.login; \
132		${INSTALL} -c -o root -g wheel -m 644 dot.mailrc \
133		    ${DESTDIR}/etc/skel/.mailrc; \
134		${INSTALL} -c -o root -g wheel -m 644 dot.profile \
135		    ${DESTDIR}/etc/skel/.profile; \
136		${INSTALL} -c -o root -g wheel -m 644 dot.Xdefaults \
137		    ${DESTDIR}/etc/skel/.Xdefaults; \
138		${INSTALL} -c -o root -g wheel -m 644 dot.cvsrc \
139		    ${DESTDIR}/etc/skel/.cvsrc; \
140		${INSTALL} -c -o root -g wheel -m 600 /dev/null \
141		    ${DESTDIR}/etc/skel/.ssh/authorized_keys
142	cd amd; \
143		${INSTALL} -c -o root -g wheel -m 644 master.sample \
144		    ${DESTDIR}/etc/amd
145	cd ppp; \
146		${INSTALL} -c -o root -g wheel -m 600 chap-secrets \
147		    ${DESTDIR}/etc/ppp; \
148		${INSTALL} -c -o root -g wheel -m 600 options \
149		    ${DESTDIR}/etc/ppp; \
150		${INSTALL} -c -o root -g wheel -m 600 options.sample \
151		    ${DESTDIR}/etc/ppp; \
152		${INSTALL} -c -o root -g wheel -m 600 chatscript.sample \
153		    ${DESTDIR}/etc/ppp; \
154		${INSTALL} -c -o root -g wheel -m 600 pap-secrets \
155		    ${DESTDIR}/etc/ppp
156	cd rpki; \
157		${INSTALL} -c -o root -g wheel -m 644 \
158		    afrinic.tal apnic.tal lacnic.tal ripe.tal \
159		    ${DESTDIR}/etc/rpki
160	cd examples; \
161		${INSTALL} -c -o root -g wheel -m 644 ${EXAMPLES} \
162		    ${DESTDIR}/etc/examples; \
163		${INSTALL} -c -o root -g wheel -m 600 ${EXAMPLES_600} \
164		    ${DESTDIR}/etc/examples; \
165		chgrp operator ${DESTDIR}/etc/examples/chio.conf
166	cd signify; \
167		${INSTALL} -c -o root -g wheel -m 644 *.pub \
168		    ${DESTDIR}/etc/signify
169	ln -fs ${TZDIR}/${LOCALTIME} ${DESTDIR}/etc/localtime
170	chown -h root:wheel ${DESTDIR}/etc/localtime
171	ln -fs /usr/sbin/rmt ${DESTDIR}/etc/rmt
172	chown -h root:wheel ${DESTDIR}/etc/rmt
173	${INSTALL} -c -o root -g wheel -m 644 minfree \
174	    ${DESTDIR}/var/crash
175	${INSTALL} -c -o ${BINOWN} -g operator -m 664 /dev/null \
176	    ${DESTDIR}/etc/dumpdates
177	${INSTALL} -c -o root -g crontab -m 660 /dev/null \
178	    ${DESTDIR}/var/cron/at.deny
179	${INSTALL} -c -o root -g crontab -m 660 /dev/null \
180	    ${DESTDIR}/var/cron/cron.deny
181	${INSTALL} -c -o root -g wheel -m 600 /dev/null \
182	    ${DESTDIR}/var/cron/log
183	${INSTALL} -c -o root -g wheel -m 444 /dev/null \
184	    ${DESTDIR}/var/db/locate.database
185	${INSTALL} -c -o _rpki-client -g wheel -m 644 /dev/null \
186	    ${DESTDIR}/var/db/rpki-client/openbgpd
187	${INSTALL} -c -o ${BINOWN} -g wheel -m 640 /dev/null \
188	    ${DESTDIR}/var/log/authlog
189	${INSTALL} -c -o ${BINOWN} -g wheel -m 640 /dev/null \
190	    ${DESTDIR}/var/log/daemon
191	${INSTALL} -c -o ${BINOWN} -g wheel -m 600 /dev/null \
192	    ${DESTDIR}/var/log/failedlogin
193	${INSTALL} -c -o ${BINOWN} -g wheel -m 640 /dev/null \
194	    ${DESTDIR}/var/log/ftpd
195	${INSTALL} -c -o ${BINOWN} -g wheel -m 644 /dev/null \
196	    ${DESTDIR}/var/log/lastlog
197	${INSTALL} -c -o ${BINOWN} -g wheel -m 640 /dev/null \
198	    ${DESTDIR}/var/log/lpd-errs
199	${INSTALL} -c -o ${BINOWN} -g wheel -m 640 /dev/null \
200	    ${DESTDIR}/var/log/maillog
201	${INSTALL} -c -o ${BINOWN} -g wheel -m 644 /dev/null \
202	    ${DESTDIR}/var/log/messages
203	${INSTALL} -c -o ${BINOWN} -g wheel -m 600 /dev/null \
204	    ${DESTDIR}/var/log/secure
205	${INSTALL} -c -o ${BINOWN} -g wheel -m 644 /dev/null \
206	    ${DESTDIR}/var/log/wtmp
207	${INSTALL} -c -o ${BINOWN} -g wheel -m 640 /dev/null \
208	    ${DESTDIR}/var/log/xferlog
209	cd ../usr.sbin/ypserv/ypinit && exec ${MAKE} distribution
210	cd ../usr.bin/ssh && exec ${MAKE} distribution
211	cd ../lib/libcrypto && exec ${MAKE} distribution
212	cd ../usr.bin/bgplg && exec ${MAKE} distribution
213	cd ../usr.bin/mail && exec ${MAKE} distribution
214	cd ../usr.sbin/ikectl && exec ${MAKE} distribution
215	cd ../usr.sbin/ldapd && exec ${MAKE} distribution
216	cd ../usr.sbin/npppd && exec ${MAKE} distribution
217	cd mail && exec ${MAKE} distribution
218	${INSTALL} -c -o root -g wheel -m 600 root/root.mail \
219	    ${DESTDIR}/var/mail/root
220	cd rc.d; \
221		${INSTALL} -c -o root -g wheel -m 644 rc.subr \
222		    ${DESTDIR}/etc/rc.d && \
223		${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 555 ${RCDAEMONS} \
224		    ${DESTDIR}/etc/rc.d
225	cd ${DESTDIR}/var; ln -fs ../tmp
226	chown -h root:wheel ${DESTDIR}/var/tmp
227	touch ${DESTDIR}/var/sysmerge/etcsum
228	chown root:wheel ${DESTDIR}/var/sysmerge/etcsum
229	chmod 644 ${DESTDIR}/var/sysmerge/etcsum
230	cd ${DESTDIR}/ && \
231		sort ${.CURDIR}/../distrib/sets/lists/etc/{mi,md.${MACHINE}} | \
232		xargs sha256 -h ${DESTDIR}/var/sysmerge/etcsum || true
233	cd ${DESTDIR}/ && \
234		sort ${.CURDIR}/../distrib/sets/lists/etc/{mi,md.${MACHINE}} | \
235		pax -w -d | gzip -9 > ${DESTDIR}/var/sysmerge/etc.tgz
236	chown root:wheel ${DESTDIR}/var/sysmerge/etc.tgz
237	chmod 644 ${DESTDIR}/var/sysmerge/etc.tgz
238
239distribution:
240	exec ${MAKE} distribution-etc-root-var
241	cd .. && exec ${MAKE} install
242
243distrib-dirs:
244	if [ ! -d ${DESTDIR}/. ]; then \
245		${INSTALL} -d -o root -g wheel -m 755 ${DESTDIR}; \
246	fi
247	mtree -qdef mtree/4.4BSD.dist -p ${DESTDIR}/ -U
248	cd ${DESTDIR}/; ln -fhs usr/src/sys sys
249	chown -h root:wheel ${DESTDIR}/sys
250
251.ifndef RELEASEDIR
252release:
253	@echo setenv RELEASEDIR before building a release.
254	@false
255.else
256release:
257	umask ${WOBJUMASK}; exec ${MAKE} do-release
258
259do-release:
260	@if [[ `id -u` -ne 0 ]]; then \
261		echo $@ must be called by root >&2; \
262		false; \
263	fi
264	@destmp=`df -P ${DESTDIR} | awk 'END { print $$6 }'`; \
265	if ! mount | grep -q " $${destmp} .*noperm"; then \
266		echo ${DESTDIR} must be on a noperm filesystem >&2; \
267		false; \
268	fi; \
269	if [[ `stat -f '%Su %Lp' $${destmp}` != '${BUILDUSER} 700' ]]; then \
270		echo $${destmp} must have owner BUILDUSER and mode 700 >&2; \
271		false; \
272	fi
273	${MAKE} release-sets
274	${MAKE} distrib
275	su ${BUILDUSER} -c 'exec ${MAKE} sha'
276	-cd ${RELEASEDIR} && chmod g-w,a+rX *
277
278release-sets:
279	su ${BUILDUSER} -c 'exec ${MAKE} distribution'
280	su ${BUILDUSER} -c 'exec ${MAKE} kernels'
281	cp -p ${DESTDIR}/usr/share/relink/kernel.tgz /usr/share/relink/kernel.tgz
282	${MAKE} bootblocks
283	cd ${RELEASEDIR} && rm -f SHA256
284	cd ../distrib/sets && exec su ${BUILDUSER} -c 'exec sh maketars ${OSrev}'
285
286sha:
287	-cd ${RELEASEDIR}; \
288	    date -u "+Build date: %s - %+" > BUILDINFO; \
289	    cksum -a sha256 BUILDINFO INSTALL.`arch -ks` \
290	    ${ALL_KERNELS} ${MDEXT} ${MISETS} | sort > SHA256
291
292.endif
293
294.endif	# DESTDIR check
295
296distrib:
297	umask 022; cd ../distrib && \
298	    ${MAKE} && exec ${MAKE} install
299
300.PHONY: distribution-etc-root-var distribution distrib-dirs \
301	release allarchs kernels release-sets m4 install-mtree \
302	bootblocks do-release ${ALL_KERNELS}
303
304SUBDIR+= etc.alpha etc.amd64 etc.arm64 etc.armv7
305SUBDIR+= etc.hppa etc.i386 etc.landisk etc.loongson etc.luna88k
306SUBDIR+= etc.macppc etc.octeon
307SUBDIR+= etc.sgi etc.sparc64
308
309.include <bsd.subdir.mk>
310.include <bsd.prog.mk>
311