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