Makefile revision 1.187 1 # $NetBSD: Makefile,v 1.187 2001/10/26 06:45:33 jmc 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 # EXTRA_KERNELS has a machine-dependent list of kernels to build added
23 # to it, but you may also set this to have extra ones built.
24 # BUILD_KERNELS are a machine-dependent list of kernels that should just
25 # be built in place but not made into sets or installed, e.g., an
26 # INSTALL kernel used later in src/distrib/.
27 #
28 # Targets:
29 # distribution: makes a full NetBSD distribution in DESTDIR. If
30 # INSTALL_DONE is set, it will not do a `make install.'
31 # if DISTRIBUTION_DONE is set, it will not do anything.
32 # distrib-dirs: creates an empty NetBSD directory tree in DESTDIR.
33 # Called by distribution.
34 # snapshot: calls distribution, above, and then tars up the files
35 # into a release(7) format in RELEASEDIR. Any port-dependent
36 # stuff for this target is found in etc.${MACHINE}/Makefile.inc.
37 # release: a synonym for `snapshot'
38
39 # do this before bsd.own.mk so we get correct KERNSRCDIR
40 .include "../Makefile.inc"
41
42 # For NO_SENDMAIL, INSTPRIV, MKCRYPTO
43 .include <bsd.own.mk>
44
45 .MAKEOVERRIDES+= USETOOLS
46
47 TZDIR= /usr/share/zoneinfo
48 LOCALTIME?= UTC
49
50 # Flags for creating ISO CDROM image
51 # mkisofs is expected to be in $PATH, install via pkgsrc/sysutils/cdrecord
52 MKISOFS?= mkisofs
53 MKISOFS_FLAGS+= -J -l \
54 -r -T -v \
55 -P "The NetBSD Project" \
56 -m "${RELEASEDIR}/installation/cdrom"
57
58 # setting NOOBJ prevents "make obj" from doing anything;
59 # an objdir would break the installation stuff below
60 MKOBJ= no
61
62 # MD Makefile.inc may append MD targets to BIN[123]. Make sure all
63 # are empty, to preserve the old semantics of setting them below with "=".
64 BIN1=
65 BIN2=
66 BIN3=
67
68 # Directories to build in ${RELEASEDIR}. MD Makefile.inc files can
69 # add to this.
70 # NOTE: Parent directories must be listed before subdirectories.
71 INSTALLATION_DIRS= \
72 binary binary/sets binary/kernel installation
73
74 .if exists(etc.${MACHINE}/Makefile.inc)
75 .include "etc.${MACHINE}/Makefile.inc"
76 .endif
77
78 # Use multiple jobs for kernel builds, if NBUILDJOBS set.
79 # (Taken from src/Makefile.)
80 .if defined(NBUILDJOBS)
81 _J= -j${NBUILDJOBS}
82 .endif
83
84 # -rw-r--r--
85 BINOWN= root
86 BINGRP= wheel
87 BIN1+= bootptab changelist csh.cshrc csh.login csh.logout daily \
88 daily.conf dm.conf floppytab ftpchroot ftpusers ftpwelcome \
89 gettytab group hosts hosts.lpd inetd.conf lkm.conf \
90 mailer.conf man.conf monthly monthly.conf mrouted.conf \
91 netconfig networks newsyslog.conf nsswitch.conf ntp.conf \
92 phones printcap profile protocols rbootd.conf rc rc.conf \
93 rc.lkm rc.local rc.subr rc.shutdown remote rpc \
94 security security.conf services shells sysctl.conf syslog.conf \
95 weekly weekly.conf wscons.conf \
96 etc.${MACHINE}/ttys etc.${MACHINE}/disktab
97
98 .if (${MACHINE_ARCH} == "m68k") || \
99 (${MACHINE_ARCH} == "ns32k") || \
100 (${MACHINE_ARCH} == "vax") || \
101 (${MACHINE_ARCH} == "arm32")
102 BIN1+= ld.so.conf
103 .elif exists(etc.${MACHINE_ARCH}/ld.so.conf)
104 BIN1+= etc.${MACHINE_ARCH}/ld.so.conf
105 .endif
106
107 .if exists(etc.${MACHINE_ARCH}/ttyaction)
108 BIN1+= etc.${MACHINE_ARCH}/ttyaction
109 .endif
110
111 # -rw-rw-r--
112 BIN2+= motd
113
114 # -rw-------
115 BIN3+= hosts.equiv
116
117 NAMEDB= 127 root.cache named.conf localhost loopback.v6
118 PCS= pcs750.bin
119
120 # find out endianness of target and set proper flag for pwd_mkdb so that
121 # it creates database in same endianness
122 .if exists(${DESTDIR}/usr/include/machine/endian_machdep.h)
123 TARGET_ENDIANNESS!= \
124 ( echo "\#include <machine/endian_machdep.h>" ; echo _BYTE_ORDER ) | \
125 ${CC} -I${DESTDIR}/usr/include -E - | tail -1 | awk '{print $$1}'
126 .else
127 TARGET_ENDIANNESS=
128 .endif
129
130 .if ${TARGET_ENDIANNESS} == "_LITTLE_ENDIAN"
131 TARGET_ENDIANNESS= -L
132 .elif ${TARGET_ENDIANNESS} == "_BIG_ENDIAN"
133 TARGET_ENDIANNESS= -B
134 .else
135 # XXX sh3 should be split into sh3eb and sh3el
136 TARGET_ENDIANNESS=
137 .endif
138
139 .include <bsd.kernobj.mk>
140
141 obj:
142 mkdir -p ${KERNOBJDIR}
143
144 .ifndef DESTDIR
145 __warndestdir: .USE
146 @echo setenv DESTDIR before doing that!
147 @false
148 distribution distrib-dirs release snapshot snap_pre snap_md_pre \
149 iso-image: __warndestdir
150 .if !target(snap_md_post)
151 snap_md_post: __warndestdir
152 .endif
153 .else
154 distribution: distrib-dirs
155 .if !defined(DISTRIBUTION_DONE)
156 .if !defined(INSTALL_DONE)
157 (cd ..; ${MAKE} _DISTRIB= includes)
158 (cd ..; ${MAKE} _DISTRIB= install)
159 .endif
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 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 555 \
175 MAKEDEV.local etc.${MACHINE}/MAKEDEV ${DESTDIR}/dev
176 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 minfree \
177 ${DESTDIR}/var/crash
178 (cd root; \
179 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.cshrc \
180 ${DESTDIR}/root/.cshrc; \
181 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 dot.klogin \
182 ${DESTDIR}/root/.klogin; \
183 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.login \
184 ${DESTDIR}/root/.login; \
185 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.profile \
186 ${DESTDIR}/root/.profile; \
187 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.shrc \
188 ${DESTDIR}/root/.shrc; \
189 rm -f ${DESTDIR}/.cshrc ${DESTDIR}/.profile; \
190 ln ${DESTDIR}/root/.cshrc ${DESTDIR}/.cshrc; \
191 ln ${DESTDIR}/root/.profile ${DESTDIR}/.profile)
192 (cd defaults; ${MAKE} install)
193 (cd mtree; ${MAKE} install)
194 (cd namedb; \
195 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 \
196 ${NAMEDB} ${DESTDIR}/etc/namedb)
197 (cd rc.d; ${MAKE} install)
198 /bin/rm -f ${DESTDIR}/etc/localtime
199 ln -s ${TZDIR}/${LOCALTIME} ${DESTDIR}/etc/localtime
200 /bin/rm -f ${DESTDIR}/etc/rmt
201 ln -s /usr/sbin/rmt ${DESTDIR}/etc/rmt
202 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g operator -m 664 /dev/null \
203 ${DESTDIR}/etc/dumpdates
204 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g operator -m 600 /dev/null \
205 ${DESTDIR}/etc/skeykeys
206 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 /dev/null \
207 ${DESTDIR}/var/at/at.deny
208 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 /dev/null \
209 ${DESTDIR}/var/cron/log
210 ${INSTALL} ${INSTPRIV} -c -o nobody -g ${BINGRP} -m 664 /dev/null \
211 ${DESTDIR}/var/db/locate.database
212 ${INSTALL} ${INSTPRIV} -c -o uucp -g dialer -m 640 /dev/null \
213 ${DESTDIR}/var/log/aculog
214 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
215 ${DESTDIR}/var/log/authlog
216 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \
217 ${DESTDIR}/var/log/lastlog
218 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 640 /dev/null \
219 ${DESTDIR}/var/log/lpd-errs
220 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
221 ${DESTDIR}/var/log/maillog
222 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
223 ${DESTDIR}/var/log/messages
224 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
225 ${DESTDIR}/var/log/secure
226 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
227 ${DESTDIR}/var/log/sendmail.st
228 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
229 ${DESTDIR}/var/log/wtmp
230 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
231 ${DESTDIR}/var/log/xferlog
232 ${INSTALL} ${INSTPRIV} -c -o daemon -g staff -m 664 /dev/null \
233 ${DESTDIR}/var/msgs/bounds
234 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \
235 ${DESTDIR}/var/run/utmp
236 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
237 ${DESTDIR}/var/games/atc_scores
238 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
239 ${DESTDIR}/var/games/battlestar.log
240 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
241 ${DESTDIR}/var/games/cfscores
242 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
243 ${DESTDIR}/var/games/criblog
244 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
245 ${DESTDIR}/var/games/robots_roll
246 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
247 ${DESTDIR}/var/games/rogue.scores
248 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
249 ${DESTDIR}/var/games/saillog
250 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
251 ${DESTDIR}/var/games/snakerawscores
252 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
253 ${DESTDIR}/var/games/snake.log
254 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
255 ${DESTDIR}/var/games/tetris.scores
256 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
257 ${DESTDIR}/var/games/larn/llog12.0
258 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
259 ${DESTDIR}/var/games/larn/lscore12.0
260 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
261 ${DESTDIR}/var/games/larn/playerids
262 (cd etc.${MACHINE}; ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} \
263 -g ${BINGRP} -m 444 fstab.* ${DESTDIR}/etc)
264 (cd skel; ${MAKE} distribution)
265 (cd ../usr.bin/mail; ${MAKE} distribution)
266 (cd ../gnu/usr.sbin/postfix/; ${MAKE} distribution)
267 .if (${MKCRYPTO} != "no")
268 (cd ../usr.bin/ssh; ${MAKE} distribution)
269 .endif
270 .ifndef NO_SENDMAIL
271 (cd ../gnu/usr.sbin/sendmail/cf/cf; ${MAKE} distribution)
272 .endif
273 .endif
274
275 distrib-dirs:
276 ${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${DESTDIR}
277 ${MTREE} -def mtree/NetBSD.dist -p ${DESTDIR}/ -U
278 cd ${DESTDIR}/; rm -f sys; ln -s usr/src/sys sys
279
280 .if !defined(RELEASEDIR)
281 __warnreleasedir: .USE
282 @echo setenv RELEASEDIR before doing that!
283 @false
284 release snapshot snap_pre snap_md_pre iso-image: __warnreleasedir
285 .if !target(snap_md_post)
286 snap_md_post: __warnreleasedir
287 .endif
288 .else
289 release snapshot: distribution snap_pre snap_md_pre snap_kern snap_md_post
290 (cd ../distrib/sets; ${MAKE} sets)
291 sh ../distrib/sets/makesums -t ${RELEASEDIR}/binary/kernel '*.gz'
292
293 # Standalone target to create a CDROM image after the release
294 # was composed. Should be run after "make build" in both src and xsrc
295 iso-image: iso-image_md_post
296
297 iso-image_mi: iso-image_md_pre
298 @if ${MKISOFS} --version; then \
299 mkdir -p ${RELEASEDIR}/installation/cdrom ; \
300 ${MKISOFS} ${MKISOFS_FLAGS} \
301 -o ${RELEASEDIR}/installation/cdrom/netbsd-${MACHINE}.iso \
302 ${RELEASEDIR} ; \
303 sh ../distrib/sets/makesums -t ${RELEASEDIR}/installation/cdrom '*.iso' ; \
304 else \
305 echo "install pkgsrc/sysutils/cdrecord and type 'make iso-image'." ; \
306 fi
307
308 # Setup the $RELEASEDIR to produce a bootable CD image:
309 iso-image_md_pre:
310 # nothing here -- look in the machine-dependent Makefile.inc
311
312 # Fixup the CD-image to be bootable
313 iso-image_md_post: iso-image_mi
314 # nothing here -- look in the machine-dependent Makefile.inc
315
316 snap_pre:
317 # Could be a mount point, ignore the errors
318 -/bin/rm -rf ${RELEASEDIR}
319 ${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${RELEASEDIR}
320 .for dir in ${INSTALLATION_DIRS}
321 ${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${RELEASEDIR}/${dir}
322 .endfor
323
324
325 # This target builds the GENERIC kernel (which must exist for all
326 # ports) and puts it in binary/sets/kern.tgz, and also builds any
327 # kernels specified in EXTRA_KERNELS. Since NetBSD's kernel build
328 # system can create more than one kernel from a single configuration
329 # we figure out how many there are, what they're named, and move them
330 # to binary/kernel/${KERNEL}.${CONFIGFILE}.gz - most often KERNEL will
331 # simply be "netbsd". If we don't find the "config" line, assume the
332 # kernel will be "netbsd" (some config files are simple additions on
333 # GENERIC, and just include it).
334 #
335 GETKERNELAWK= awk '/^config/ {print $$2; found=1} \
336 END{ if (found == 0) print "netbsd"; }'
337 #
338 .if !target(snap_kern)
339 snap_kern:
340 .ifndef KERNELS_DONE
341 .for configfile in GENERIC ${EXTRA_KERNELS} ${BUILD_KERNELS}
342 cd ${KERNCONFDIR} && ${CONFIG} \
343 -b ${KERNOBJDIR}/${configfile:C/.*\///} -s ${KERNSRCDIR} ${configfile}
344 .ifndef UPDATE
345 cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} distclean
346 .endif
347 cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} depend && ${MAKE} ${_J}
348 .endfor # kernels
349 cd ${KERNOBJDIR}/GENERIC && \
350 tar cf - `${GETKERNELAWK} ${KERNCONFDIR}/GENERIC` |\
351 gzip -c -9 > ${RELEASEDIR}/binary/sets/kern.tgz
352 .for configfile in GENERIC ${EXTRA_KERNELS}
353 cd ${KERNOBJDIR}/${configfile:C/.*\///} && \
354 for kernel in `${GETKERNELAWK} \
355 ${KERNCONFDIR}/${configfile:C/.*\///}` ; do \
356 gzip -c -9 < $${kernel} > \
357 ${RELEASEDIR}/binary/kernel/$${kernel}.${configfile:C/.*\///}.gz ; done
358 .endfor # EXTRA_KERNELS
359 .endif # KERNELS_DONE
360 .endif # no target(snap_kern)
361
362 .endif # RELEASEDIR check
363
364 snap_md_pre:
365 # nothing here -- look in the machine-dependent Makefile.inc
366
367 snap_md_post:
368 # nothing here -- look in the machine-dependent Makefile.inc
369
370 .endif # DESTDIR check
371
372 .include <bsd.prog.mk>
373