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