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