Makefile revision 1.208 1 # $NetBSD: Makefile,v 1.208 2002/04/07 15:52:27 wiz 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 #
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. Any port-dependent
31 # stuff for this target is found in etc.${MACHINE}/Makefile.inc.
32 # release: a synonym for `snapshot'
33
34 # setting NOOBJ prevents "make obj" from doing anything;
35 # an objdir would break the installation stuff below
36 NOOBJ= # defined
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
44 .MAKEOVERRIDES+= USETOOLS
45
46 TZDIR= /usr/share/zoneinfo
47 LOCALTIME?= UTC
48 PWD_MKDB?= pwd_mkdb
49 MAKESUMS= CKSUM=${CKSUM:Q} sh ../distrib/sets/makesums
50
51 # Flags for creating ISO CDROM image
52 # mkisofs is expected to be in $PATH, install via pkgsrc/sysutils/cdrecord
53 MKISOFS?= mkisofs
54 MKISOFS_FLAGS+= -J -l \
55 -r -T -v \
56 -P "The NetBSD Project" \
57 -m "${RELEASEDIR}/installation/cdrom"
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 "=".
61 BIN1=
62 BIN2=
63 BIN3=
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.
68 INSTALLATION_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--
82 BINOWN= root
83 BINGRP= wheel
84 BIN1+= 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 BIN1+= ld.so.conf
99 .elif exists(etc.${MACHINE_ARCH}/ld.so.conf)
100 BIN1+= etc.${MACHINE_ARCH}/ld.so.conf
101 .endif
102
103 .if exists(etc.${MACHINE_ARCH}/ttyaction)
104 BIN1+= etc.${MACHINE_ARCH}/ttyaction
105 .endif
106
107 # -rw-rw-r--
108 BIN2+= motd
109
110 # -rw-------
111 BIN3+= hosts.equiv
112
113 NAMEDB= 127 root.cache named.conf localhost loopback.v6
114 PCS= pcs750.bin
115
116 .if make(release) || make(snapshot) || make(distribution) # {
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/sys/endian.h)
120 TARGET_ENDIANNESS!= \
121 printf '\#include <sys/endian.h>\n_BYTE_ORDER\n' | \
122 ${CC} -I${DESTDIR}/usr/include -E - | tail -1 | awk '{print $$1}'
123 .else
124 TARGET_ENDIANNESS=
125 .endif
126
127 .if ${TARGET_ENDIANNESS} == "1234"
128 TARGET_ENDIANNESS= -L
129 .elif ${TARGET_ENDIANNESS} == "4321"
130 TARGET_ENDIANNESS= -B
131 .else
132 TARGET_ENDIANNESS=
133 .endif
134 .endif # release || snapshot || distribution # }
135
136 .include <bsd.kernobj.mk>
137
138 obj:
139 mkdir -p ${KERNOBJDIR}
140
141 distribution: check_DESTDIR .WAIT distrib-dirs
142 .if !defined(DISTRIBUTION_DONE)
143 .if !defined(INSTALL_DONE)
144 (cd ..; ${MAKE} _DISTRIB= includes)
145 (cd ..; ${MAKE} _DISTRIB= install)
146 .endif # !INSTALL_DONE
147 ${MAKE} install-etc-files
148 .endif # !DISTRIBUTION_DONE
149
150 install-etc-files: check_DESTDIR
151 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 ${BIN1} ${DESTDIR}/etc
152 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 664 ${BIN2} ${DESTDIR}/etc
153 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 ${BIN3} ${DESTDIR}/etc
154 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 aliases \
155 ${DESTDIR}/etc/mail
156 ${INSTALL_FILE} -o root -g wheel -m 600 crontab \
157 ${DESTDIR}/var/cron/tabs/root
158 ${INSTALL_FILE} -o root -g wheel -m 600 master.passwd ${DESTDIR}/etc
159 ${PWD_MKDB} -p ${TARGET_ENDIANNESS} -d ${DESTDIR}/ \
160 ${DESTDIR}/etc/master.passwd
161 .if defined(UNPRIVED)
162 echo "${DESTDIR}/etc/passwd type=file mode=0644 uname=root gname=wheel" \
163 | sed -e 's|^/|./|g' -e 's|//|/|g' >>${METALOG}
164 echo "${DESTDIR}/etc/pwd.db type=file mode=0644 uname=root gname=wheel" \
165 | sed -e 's|^/|./|g' -e 's|//|/|g' >>${METALOG}
166 echo "${DESTDIR}/etc/spwd.db type=file mode=0600 uname=root gname=wheel" \
167 | sed -e 's|^/|./|g' -e 's|//|/|g' >>${METALOG}
168 .endif # UNPRIVED
169 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 555 \
170 MAKEDEV.local etc.${MACHINE}/MAKEDEV ${DESTDIR}/dev
171 ${INSTALL_FILE} -o root -g wheel -m 600 minfree ${DESTDIR}/var/crash
172 (cd root; \
173 ${INSTALL_FILE} -o root -g wheel -m 644 dot.cshrc \
174 ${DESTDIR}/root/.cshrc; \
175 ${INSTALL_FILE} -o root -g wheel -m 600 dot.klogin \
176 ${DESTDIR}/root/.klogin; \
177 ${INSTALL_FILE} -o root -g wheel -m 644 dot.login \
178 ${DESTDIR}/root/.login; \
179 ${INSTALL_FILE} -o root -g wheel -m 644 dot.profile \
180 ${DESTDIR}/root/.profile; \
181 ${INSTALL_FILE} -o root -g wheel -m 644 dot.shrc \
182 ${DESTDIR}/root/.shrc; \
183 rm -f ${DESTDIR}/.cshrc ${DESTDIR}/.profile; \
184 ${INSTALL_LINK} ${DESTDIR}/root/.cshrc ${DESTDIR}/.cshrc; \
185 ${INSTALL_LINK} ${DESTDIR}/root/.profile ${DESTDIR}/.profile)
186 (cd defaults; ${MAKE} install)
187 (cd mtree; ${MAKE} install)
188 (cd namedb; \
189 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
190 ${NAMEDB} ${DESTDIR}/etc/namedb)
191 .if ${MACHINE_ARCH} == "vax"
192 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 ${PCS} \
193 ${DESTDIR}/${PCS}
194 .endif
195 (cd rc.d; ${MAKE} install)
196 ${INSTALL_SYMLINK} -o root -g wheel -m 755 \
197 ${TZDIR}/${LOCALTIME} ${DESTDIR}/etc/localtime
198 ${INSTALL_SYMLINK} -o root -g wheel -m 755 \
199 /usr/sbin/rmt ${DESTDIR}/etc/rmt
200 ${INSTALL_FILE} -o ${BINOWN} -g operator -m 664 /dev/null \
201 ${DESTDIR}/etc/dumpdates
202 ${INSTALL_FILE} -o ${BINOWN} -g operator -m 600 /dev/null \
203 ${DESTDIR}/etc/skeykeys
204 ${INSTALL_FILE} -o root -g wheel -m 600 /dev/null \
205 ${DESTDIR}/var/at/at.deny
206 ${INSTALL_FILE} -o root -g wheel -m 600 /dev/null \
207 ${DESTDIR}/var/cron/log
208 ${INSTALL_FILE} -o nobody -g ${BINGRP} -m 664 /dev/null \
209 ${DESTDIR}/var/db/locate.database
210 ${INSTALL_FILE} -o uucp -g dialer -m 640 /dev/null \
211 ${DESTDIR}/var/log/aculog
212 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
213 ${DESTDIR}/var/log/authlog
214 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \
215 ${DESTDIR}/var/log/lastlog
216 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 640 /dev/null \
217 ${DESTDIR}/var/log/lpd-errs
218 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
219 ${DESTDIR}/var/log/maillog
220 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
221 ${DESTDIR}/var/log/messages
222 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
223 ${DESTDIR}/var/log/secure
224 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
225 ${DESTDIR}/var/log/sendmail.st
226 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
227 ${DESTDIR}/var/log/wtmp
228 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
229 ${DESTDIR}/var/log/xferlog
230 ${INSTALL_FILE} -o daemon -g staff -m 664 /dev/null \
231 ${DESTDIR}/var/msgs/bounds
232 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \
233 ${DESTDIR}/var/run/utmp
234 ${INSTALL_FILE} -o games -g games -m 664 /dev/null \
235 ${DESTDIR}/var/games/atc_scores
236 ${INSTALL_FILE} -o games -g games -m 664 /dev/null \
237 ${DESTDIR}/var/games/battlestar.log
238 ${INSTALL_FILE} -o games -g games -m 664 /dev/null \
239 ${DESTDIR}/var/games/cfscores
240 ${INSTALL_FILE} -o games -g games -m 664 /dev/null \
241 ${DESTDIR}/var/games/criblog
242 ${INSTALL_FILE} -o games -g games -m 664 /dev/null \
243 ${DESTDIR}/var/games/robots_roll
244 ${INSTALL_FILE} -o games -g games -m 664 /dev/null \
245 ${DESTDIR}/var/games/rogue.scores
246 ${INSTALL_FILE} -o games -g games -m 664 /dev/null \
247 ${DESTDIR}/var/games/saillog
248 ${INSTALL_FILE} -o games -g games -m 664 /dev/null \
249 ${DESTDIR}/var/games/snakerawscores
250 ${INSTALL_FILE} -o games -g games -m 664 /dev/null \
251 ${DESTDIR}/var/games/snake.log
252 ${INSTALL_FILE} -o games -g games -m 664 /dev/null \
253 ${DESTDIR}/var/games/tetris.scores
254 ${INSTALL_FILE} -o games -g games -m 664 /dev/null \
255 ${DESTDIR}/var/games/larn/llog12.0
256 ${INSTALL_FILE} -o games -g games -m 664 /dev/null \
257 ${DESTDIR}/var/games/larn/lscore12.0
258 ${INSTALL_FILE} -o games -g games -m 664 /dev/null \
259 ${DESTDIR}/var/games/larn/playerids
260 (cd etc.${MACHINE}; ${INSTALL_FILE} -o ${BINOWN} \
261 -g ${BINGRP} -m 444 fstab.* ${DESTDIR}/etc)
262 (cd skel; ${MAKE} distribution)
263 (cd ../usr.bin/mail; ${MAKE} distribution)
264 (cd ../gnu/usr.sbin/postfix/; ${MAKE} distribution)
265 .if (${MKCRYPTO} != "no")
266 (cd ../usr.bin/ssh; ${MAKE} distribution)
267 .endif
268 .if !defined(NO_SENDMAIL)
269 (cd ../gnu/usr.sbin/sendmail/cf/cf; ${MAKE} distribution)
270 .endif
271
272 distrib-dirs: check_DESTDIR
273 ${INSTALL_DIR} -o root -g wheel -m 755 ${DESTDIR}
274 ${MTREE} -def mtree/NetBSD.dist -p ${DESTDIR}/ -U ${UNPRIVED:D-W}
275 rm -f ${DESTDIR}/sys
276 ${INSTALL_SYMLINK} -o root -g wheel -m 755 usr/src/sys ${DESTDIR}/sys
277
278 release snapshot: check_DESTDIR check_RELEASEDIR .WAIT \
279 distribution snap_pre snap_md_pre snap_kern snap_md_post
280 (cd ../distrib/sets; ${MAKE} sets)
281 ${MAKESUMS} -t ${RELEASEDIR}/binary/kernel '*.gz'
282
283 # Standalone target to create a CDROM image after the release
284 # was composed. Should be run after "make build" in both src and xsrc
285 iso-image: check_DESTDIR check_RELEASEDIR .WAIT iso-image_md_post
286
287 iso-image_mi: check_DESTDIR check_RELEASEDIR .WAIT iso-image_md_pre
288 @if ${MKISOFS} --version; then \
289 mkdir -p ${RELEASEDIR}/installation/cdrom ; \
290 ${MKISOFS} ${MKISOFS_FLAGS} \
291 -o ${RELEASEDIR}/installation/cdrom/netbsd-${MACHINE}.iso \
292 ${RELEASEDIR} ; \
293 ${MAKESUMS} -t ${RELEASEDIR}/installation/cdrom '*.iso' ; \
294 else \
295 echo "install pkgsrc/sysutils/cdrecord and type 'make iso-image'." ; \
296 fi
297
298 # Setup the $RELEASEDIR to produce a bootable CD image:
299 iso-image_md_pre: check_DESTDIR check_RELEASEDIR
300 # nothing here -- look in the machine-dependent Makefile.inc
301
302 # Fixup the CD-image to be bootable
303 iso-image_md_post: check_DESTDIR check_RELEASEDIR .WAIT iso-image_mi
304 # nothing here -- look in the machine-dependent Makefile.inc
305
306 snap_pre: check_DESTDIR check_RELEASEDIR
307 # Could be a mount point, ignore the errors
308 -/bin/rm -rf ${RELEASEDIR}
309 ${INSTALL} -d -m 755 ${RELEASEDIR}
310 .for dir in ${INSTALLATION_DIRS}
311 ${INSTALL} -d -m 755 ${RELEASEDIR}/${dir}
312 .endfor
313
314 # This target builds the kernels specified by each port. A port may
315 # specify the following kernels:
316 #
317 # KERNEL_SETS The list of kernels that will be
318 # packaged into sets, named
319 # kern-${kernel}.tgz. These kernels
320 # are also placed in the binary/kernel
321 # area of the release package as
322 # netbsd-${kernel}.gz.
323 #
324 # EXTRA_KERNELS Additional kernels to place in the
325 # binary/kernel area of the release
326 # package as netbsd-${kernel}.gz, but
327 # which are not placed into sets. This
328 # allows a port to provide e.g. a netbootable
329 # installation kernel containing a ramdisk.
330 #
331 # BUILD_KERNELS Additional kernels to build which are
332 # not placed into sets nor into the
333 # binary/kernel area of the release
334 # package. These are typically kernels
335 # that are built for inclusion only in
336 # installation disk/CD-ROM/tape images.
337 #
338 # A port may also specify KERNEL_SUFFIXES, which is an optional list
339 # of filename suffixes for kernels to include in the kernel sets and
340 # in the binary/kernel area of the release package (e.g. "netbsd" vs.
341 # "netbsd.ecoff" and "netbsd.srec"). It is not an error if kernels
342 # with these suffixes do not exist in the kernel build directory.
343 #
344 GETKERNELAWK= awk '/^config/ {print $$2; found=1} \
345 END{ if (found == 0) print "netbsd"; }'
346 #
347 .if !target(snap_kern)
348 snap_kern: check_DESTDIR check_RELEASEDIR
349 .if !defined(KERNELS_DONE) # {
350 .for configfile in ${KERNEL_SETS} ${EXTRA_KERNELS} ${BUILD_KERNELS}
351 cd ${KERNCONFDIR} && ${CONFIG} \
352 -b ${KERNOBJDIR}/${configfile:C/.*\///} -s ${KERNSRCDIR} ${configfile}
353 .if !defined(UPDATE)
354 cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} distclean
355 .endif
356 cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} depend && ${MAKE} ${_J}
357 .endfor # build kernels
358 .endif # KERNELS_DONE # }
359 .for configfile in ${KERNEL_SETS}
360 kernlist=`${GETKERNELAWK} ${KERNCONFDIR}/${configfile}`; \
361 kerndir=${KERNOBJDIR}/${configfile:C/.*\///}; \
362 kernsuffixes="${KERNEL_SUFFIXES}"; \
363 cd $${kerndir} && \
364 tarlist=`for kernel in $${kernlist}; do \
365 echo "$${kernel}"; \
366 for s in $${kernsuffixes}; do \
367 if [ -f $${kernel}.$${s} ]; then \
368 echo "$${kernel}.$${s}"; \
369 fi; \
370 done; \
371 done`; \
372 GZIP=-9 ${PAX} -zwf \
373 ${RELEASEDIR}/binary/sets/kern-${configfile}.tgz $${tarlist}
374 .endfor # make kernel sets
375 .for configfile in ${KERNEL_SETS} ${EXTRA_KERNELS}
376 kernlist=`${GETKERNELAWK} ${KERNCONFDIR}/${configfile:C/.*\///}`; \
377 kerndir=${KERNOBJDIR}/${configfile:C/.*\///}; \
378 kernsuffixes="${KERNEL_SUFFIXES}"; \
379 cd $${kerndir} && \
380 gziplist=`for kernel in $${kernlist}; do \
381 echo "$${kernel}"; \
382 for s in $${kernsuffixes}; do \
383 if [ -f $${kernel}.$${s} ]; then \
384 echo "$${kernel}.$${s}"; \
385 fi; \
386 done; \
387 done`; \
388 for kernel in $${gziplist} ; do \
389 gzip -c -9 < $${kernel} > \
390 ${RELEASEDIR}/binary/kernel/$${kernel}-${configfile:C/.*\///}.gz ; done
391 .endfor # place KERNEL_SETS kernels + EXTRA_KERNELS in binary/kernel/...
392 .endif # no target(snap_kern)
393
394 snap_md_pre: check_DESTDIR check_RELEASEDIR
395 # nothing here -- look in the machine-dependent Makefile.inc
396
397 snap_md_post: check_DESTDIR check_RELEASEDIR
398 # nothing here -- look in the machine-dependent Makefile.inc
399
400 .include <bsd.prog.mk>
401