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