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