Makefile revision 1.216 1 # $NetBSD: Makefile,v 1.216 2002/04/26 16:23:14 lukem 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 # For NO_SENDMAIL, INSTPRIV, MKCRYPTO
39 .include <bsd.own.mk>
40
41 # For KERNSRCDIR, KERNOBJDIR, ...
42 .include <bsd.kernobj.mk>
43
44
45 .MAKEOVERRIDES+= USETOOLS
46
47 TZDIR= /usr/share/zoneinfo
48 LOCALTIME?= UTC
49 PWD_MKDB?= pwd_mkdb
50 MAKESUMS= CKSUM=${CKSUM:Q} sh ../distrib/sets/makesums
51
52 # Flags for creating ISO CDROM image
53 # mkisofs is expected to be in $PATH, install via pkgsrc/sysutils/cdrecord
54 MKISOFS?= mkisofs
55 MKISOFS_FLAGS+= -J -l \
56 -r -T -v \
57 -P "The NetBSD Project" \
58 -m "${RELEASEDIR}/installation/cdrom"
59
60 # MD Makefile.inc may append MD targets to BIN[123]. Make sure all
61 # are empty, to preserve the old semantics of setting them below with "=".
62 BIN1=
63 BIN2=
64 BIN3=
65
66 # Directories to build in ${RELEASEDIR}. MD Makefile.inc files can
67 # add to this.
68 # NOTE: Parent directories must be listed before subdirectories.
69 INSTALLATION_DIRS= \
70 binary binary/sets binary/kernel installation
71
72 .if exists(etc.${MACHINE}/Makefile.inc)
73 .include "etc.${MACHINE}/Makefile.inc"
74 .endif
75
76 # Use multiple jobs for kernel builds, if NBUILDJOBS set.
77 # (Taken from src/Makefile.)
78 .if defined(NBUILDJOBS)
79 _J= -j${NBUILDJOBS}
80 .endif
81
82 # -rw-r--r--
83 BINOWN= root
84 BINGRP= wheel
85 BIN1+= bootptab changelist csh.cshrc csh.login csh.logout daily \
86 daily.conf dm.conf floppytab ftpchroot ftpusers ftpwelcome \
87 gettytab group hosts hosts.lpd inetd.conf lkm.conf \
88 mailer.conf man.conf monthly monthly.conf mrouted.conf \
89 netconfig networks newsyslog.conf nsswitch.conf ntp.conf \
90 passwd.conf phones printcap profile protocols rbootd.conf rc rc.conf \
91 rc.lkm rc.local rc.subr rc.shutdown remote rpc \
92 security security.conf services shells sysctl.conf syslog.conf \
93 weekly weekly.conf wscons.conf \
94 etc.${MACHINE}/ttys etc.${MACHINE}/disktab
95
96 .if (${MACHINE_ARCH} == "m68k") || \
97 (${MACHINE_ARCH} == "ns32k") || \
98 (${MACHINE_ARCH} == "vax")
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
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 obj:
137 mkdir -p ${KERNOBJDIR}
138
139 distribution: check_DESTDIR .WAIT distrib-dirs
140 .if !defined(DISTRIBUTION_DONE)
141 .if !defined(INSTALL_DONE)
142 (cd ..; ${MAKE} _DISTRIB= includes)
143 (cd ..; ${MAKE} _DISTRIB= install)
144 .endif # !INSTALL_DONE
145 ${MAKE} install-etc-files
146 .endif # !DISTRIBUTION_DONE
147
148 install-etc-files: check_DESTDIR
149 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 ${BIN1} ${DESTDIR}/etc
150 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 664 ${BIN2} ${DESTDIR}/etc
151 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 ${BIN3} ${DESTDIR}/etc
152 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 aliases \
153 ${DESTDIR}/etc/mail
154 ${INSTALL_FILE} -o root -g wheel -m 600 crontab \
155 ${DESTDIR}/var/cron/tabs/root
156 ${INSTALL_FILE} -o root -g wheel -m 600 master.passwd ${DESTDIR}/etc
157 ${PWD_MKDB} -p ${TARGET_ENDIANNESS} -d ${DESTDIR}/ \
158 ${DESTDIR}/etc/master.passwd
159 .if defined(UNPRIVED)
160 echo "${DESTDIR}/etc/passwd type=file mode=0644 uname=root gname=wheel" \
161 | sed -e 's|^/|./|g' -e 's|//|/|g' >>${METALOG}
162 echo "${DESTDIR}/etc/pwd.db type=file mode=0644 uname=root gname=wheel" \
163 | sed -e 's|^/|./|g' -e 's|//|/|g' >>${METALOG}
164 echo "${DESTDIR}/etc/spwd.db type=file mode=0600 uname=root gname=wheel" \
165 | sed -e 's|^/|./|g' -e 's|//|/|g' >>${METALOG}
166 .endif # UNPRIVED
167 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 555 \
168 MAKEDEV.local etc.${MACHINE}/MAKEDEV ${DESTDIR}/dev
169 ${INSTALL_FILE} -o root -g wheel -m 600 minfree ${DESTDIR}/var/crash
170 (cd root; \
171 ${INSTALL_FILE} -o root -g wheel -m 644 dot.cshrc \
172 ${DESTDIR}/root/.cshrc; \
173 ${INSTALL_FILE} -o root -g wheel -m 600 dot.klogin \
174 ${DESTDIR}/root/.klogin; \
175 ${INSTALL_FILE} -o root -g wheel -m 644 dot.login \
176 ${DESTDIR}/root/.login; \
177 ${INSTALL_FILE} -o root -g wheel -m 644 dot.profile \
178 ${DESTDIR}/root/.profile; \
179 ${INSTALL_FILE} -o root -g wheel -m 644 dot.shrc \
180 ${DESTDIR}/root/.shrc; \
181 rm -f ${DESTDIR}/.cshrc ${DESTDIR}/.profile; \
182 ${INSTALL_LINK} ${DESTDIR}/root/.cshrc ${DESTDIR}/.cshrc; \
183 ${INSTALL_LINK} ${DESTDIR}/root/.profile ${DESTDIR}/.profile)
184 (cd defaults; ${MAKE} install)
185 (cd mtree; ${MAKE} install)
186 (cd namedb; \
187 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
188 ${NAMEDB} ${DESTDIR}/etc/namedb)
189 (cd rc.d; ${MAKE} install)
190 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
191 postinstall ${DESTDIR}/etc
192 ${INSTALL_SYMLINK} -o root -g wheel -m 755 \
193 ${TZDIR}/${LOCALTIME} ${DESTDIR}/etc/localtime
194 ${INSTALL_SYMLINK} -o root -g wheel -m 755 \
195 /usr/sbin/rmt ${DESTDIR}/etc/rmt
196 ${INSTALL_FILE} -o ${BINOWN} -g operator -m 664 /dev/null \
197 ${DESTDIR}/etc/dumpdates
198 ${INSTALL_FILE} -o ${BINOWN} -g operator -m 600 /dev/null \
199 ${DESTDIR}/etc/skeykeys
200 ${INSTALL_FILE} -o root -g wheel -m 600 /dev/null \
201 ${DESTDIR}/var/at/at.deny
202 ${INSTALL_FILE} -o root -g wheel -m 600 /dev/null \
203 ${DESTDIR}/var/cron/log
204 ${INSTALL_FILE} -o nobody -g ${BINGRP} -m 664 /dev/null \
205 ${DESTDIR}/var/db/locate.database
206 ${INSTALL_FILE} -o uucp -g dialer -m 640 /dev/null \
207 ${DESTDIR}/var/log/aculog
208 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
209 ${DESTDIR}/var/log/authlog
210 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \
211 ${DESTDIR}/var/log/lastlog
212 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 640 /dev/null \
213 ${DESTDIR}/var/log/lpd-errs
214 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
215 ${DESTDIR}/var/log/maillog
216 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
217 ${DESTDIR}/var/log/messages
218 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
219 ${DESTDIR}/var/log/secure
220 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
221 ${DESTDIR}/var/log/sendmail.st
222 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
223 ${DESTDIR}/var/log/wtmp
224 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
225 ${DESTDIR}/var/log/xferlog
226 ${INSTALL_FILE} -o daemon -g staff -m 664 /dev/null \
227 ${DESTDIR}/var/msgs/bounds
228 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \
229 ${DESTDIR}/var/run/utmp
230 ${INSTALL_FILE} -o games -g games -m 664 /dev/null \
231 ${DESTDIR}/var/games/atc_scores
232 ${INSTALL_FILE} -o games -g games -m 664 /dev/null \
233 ${DESTDIR}/var/games/battlestar.log
234 ${INSTALL_FILE} -o games -g games -m 664 /dev/null \
235 ${DESTDIR}/var/games/cfscores
236 ${INSTALL_FILE} -o games -g games -m 664 /dev/null \
237 ${DESTDIR}/var/games/criblog
238 ${INSTALL_FILE} -o games -g games -m 664 /dev/null \
239 ${DESTDIR}/var/games/robots_roll
240 ${INSTALL_FILE} -o games -g games -m 664 /dev/null \
241 ${DESTDIR}/var/games/rogue.scores
242 ${INSTALL_FILE} -o games -g games -m 664 /dev/null \
243 ${DESTDIR}/var/games/saillog
244 ${INSTALL_FILE} -o games -g games -m 664 /dev/null \
245 ${DESTDIR}/var/games/snakerawscores
246 ${INSTALL_FILE} -o games -g games -m 664 /dev/null \
247 ${DESTDIR}/var/games/snake.log
248 ${INSTALL_FILE} -o games -g games -m 664 /dev/null \
249 ${DESTDIR}/var/games/tetris.scores
250 ${INSTALL_FILE} -o games -g games -m 664 /dev/null \
251 ${DESTDIR}/var/games/larn/llog12.0
252 ${INSTALL_FILE} -o games -g games -m 664 /dev/null \
253 ${DESTDIR}/var/games/larn/lscore12.0
254 ${INSTALL_FILE} -o games -g games -m 664 /dev/null \
255 ${DESTDIR}/var/games/larn/playerids
256 (cd etc.${MACHINE}; ${INSTALL_FILE} -o ${BINOWN} \
257 -g ${BINGRP} -m 444 fstab.* ${DESTDIR}/etc)
258 (cd skel; ${MAKE} distribution)
259 (cd ../usr.bin/mail; ${MAKE} distribution)
260 (cd ../gnu/usr.sbin/postfix/; ${MAKE} distribution)
261 .if (${MKCRYPTO} != "no")
262 (cd ../usr.bin/ssh; ${MAKE} distribution)
263 .endif
264 .if !defined(NO_SENDMAIL)
265 (cd ../gnu/usr.sbin/sendmail/cf/cf; ${MAKE} distribution)
266 .endif
267
268 distrib-dirs: check_DESTDIR
269 ${INSTALL_DIR} -o root -g wheel -m 755 ${DESTDIR}
270 ${MTREE} -def mtree/NetBSD.dist -p ${DESTDIR}/ -U ${UNPRIVED:D-W}
271 rm -f ${DESTDIR}/sys
272 ${INSTALL_SYMLINK} -o root -g wheel -m 755 usr/src/sys ${DESTDIR}/sys
273
274 release snapshot: check_DESTDIR check_RELEASEDIR .WAIT \
275 distribution snap_pre snap_md_pre snap_kern snap_md_post
276 (cd ../distrib/sets; ${MAKE} sets)
277 ${MAKESUMS} -t ${RELEASEDIR}/binary/kernel '*.gz'
278
279 # Standalone target to create a CDROM image after the release
280 # was composed. Should be run after "make build" in both src and xsrc
281 iso-image: check_DESTDIR check_RELEASEDIR .WAIT iso-image_md_post
282
283 iso-image_mi: check_DESTDIR check_RELEASEDIR .WAIT iso-image_md_pre
284 @if ${MKISOFS} --version; then \
285 mkdir -p ${RELEASEDIR}/installation/cdrom ; \
286 ${MKISOFS} ${MKISOFS_FLAGS} \
287 -o ${RELEASEDIR}/installation/cdrom/netbsd-${MACHINE}.iso \
288 ${RELEASEDIR} ; \
289 ${MAKESUMS} -t ${RELEASEDIR}/installation/cdrom '*.iso' ; \
290 else \
291 echo "install pkgsrc/sysutils/cdrecord and type 'make iso-image'." ; \
292 fi
293
294 # Setup the $RELEASEDIR to produce a bootable CD image:
295 iso-image_md_pre: check_DESTDIR check_RELEASEDIR
296 # nothing here -- look in the machine-dependent Makefile.inc
297
298 # Fixup the CD-image to be bootable
299 iso-image_md_post: check_DESTDIR check_RELEASEDIR .WAIT iso-image_mi
300 # nothing here -- look in the machine-dependent Makefile.inc
301
302 snap_pre: check_DESTDIR check_RELEASEDIR
303 # Could be a mount point, ignore the errors
304 -/bin/rm -rf ${RELEASEDIR}
305 ${INSTALL} -d -m 755 ${RELEASEDIR}
306 .for dir in ${INSTALLATION_DIRS}
307 ${INSTALL} -d -m 755 ${RELEASEDIR}/${dir}
308 .endfor
309
310 # This target builds the kernels specified by each port. A port may
311 # specify the following kernels:
312 #
313 # KERNEL_SETS The list of kernels that will be
314 # packaged into sets, named
315 # kern-${kernel}.tgz. These kernels
316 # are also placed in the binary/kernel
317 # area of the release package as
318 # netbsd-${kernel}.gz.
319 #
320 # EXTRA_KERNELS Additional kernels to place in the
321 # binary/kernel area of the release
322 # package as netbsd-${kernel}.gz, but
323 # which are not placed into sets. This
324 # allows a port to provide e.g. a netbootable
325 # installation kernel containing a ramdisk.
326 #
327 # BUILD_KERNELS Additional kernels to build which are
328 # not placed into sets nor into the
329 # binary/kernel area of the release
330 # package. These are typically kernels
331 # that are built for inclusion only in
332 # installation disk/CD-ROM/tape images.
333 #
334 # A port may also specify KERNEL_SUFFIXES, which is an optional list
335 # of filename suffixes for kernels to include in the kernel sets and
336 # in the binary/kernel area of the release package (e.g. "netbsd" vs.
337 # "netbsd.ecoff" and "netbsd.srec"). It is not an error if kernels
338 # with these suffixes do not exist in the kernel build directory.
339 #
340 GETKERNELAWK= awk '/^config/ {print $$2; found=1} \
341 END{ if (found == 0) print "netbsd"; }'
342 #
343 .if !target(snap_kern)
344 snap_kern: check_DESTDIR check_RELEASEDIR
345 .if !defined(KERNELS_DONE) # {
346 .for configfile in ${KERNEL_SETS} ${EXTRA_KERNELS} ${BUILD_KERNELS}
347 cd ${KERNCONFDIR} && ${CONFIG} \
348 -b ${KERNOBJDIR}/${configfile:C/.*\///} -s ${KERNSRCDIR} ${configfile}
349 .if !defined(UPDATE)
350 cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} distclean
351 .endif
352 cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} depend && ${MAKE} ${_J}
353 .endfor # build kernels
354 .endif # KERNELS_DONE # }
355 .for configfile in ${KERNEL_SETS}
356 kernlist=`${GETKERNELAWK} ${KERNCONFDIR}/${configfile}`; \
357 kerndir=${KERNOBJDIR}/${configfile:C/.*\///}; \
358 kernsuffixes="${KERNEL_SUFFIXES}"; \
359 cd $${kerndir} && ( \
360 echo "/set uname=${BINOWN} gname=${BINGRP}"; \
361 echo ". type=dir optional"; \
362 for kernel in $${kernlist}; do \
363 echo "./$${kernel} type=file"; \
364 for s in $${kernsuffixes}; do \
365 if [ -f $${kernel}.$${s} ]; then \
366 echo "./$${kernel}.$${s} type=file"; \
367 fi; \
368 done; \
369 done ) | GZIP=-9 ${PAX} -zw \
370 -M ${UNPRIVED:D-N${NETBSDSRCDIR}/etc} \
371 -f ${RELEASEDIR}/binary/sets/kern-${configfile}.tgz
372 .endfor # make kernel sets
373 .for configfile in ${KERNEL_SETS} ${EXTRA_KERNELS}
374 kernlist=`${GETKERNELAWK} ${KERNCONFDIR}/${configfile:C/.*\///}`; \
375 kerndir=${KERNOBJDIR}/${configfile:C/.*\///}; \
376 kernsuffixes="${KERNEL_SUFFIXES}"; \
377 cd $${kerndir} && \
378 gziplist=`for kernel in $${kernlist}; do \
379 echo "$${kernel}"; \
380 for s in $${kernsuffixes}; do \
381 if [ -f $${kernel}.$${s} ]; then \
382 echo "$${kernel}.$${s}"; \
383 fi; \
384 done; \
385 done`; \
386 for kernel in $${gziplist} ; do \
387 gzip -c -9 < $${kernel} > \
388 ${RELEASEDIR}/binary/kernel/$${kernel}-${configfile:C/.*\///}.gz ; done
389 .endfor # place KERNEL_SETS kernels + EXTRA_KERNELS in binary/kernel/...
390 .endif # no target(snap_kern)
391
392 snap_md_pre: check_DESTDIR check_RELEASEDIR
393 # nothing here -- look in the machine-dependent Makefile.inc
394
395 snap_md_post: check_DESTDIR check_RELEASEDIR
396 # nothing here -- look in the machine-dependent Makefile.inc
397
398 .include <bsd.prog.mk>
399