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