Makefile revision 1.171 1 # $NetBSD: Makefile,v 1.171 2000/11/30 11:31:05 simonb 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/KERNELNAME, but can be
16 # overridden.
17 # KERNCONFDIR is where the configuration files for kernels are found;
18 # default is ${KERNSRCDIR}/arch/${MACHINE}/conf but can be overridden.
19 # UPDATE is normally undefined; if defined, don't do a 'make clean'
20 # before kernel compile
21 # NO_SENDMAIL is normally undefined; if defined, it will not do a
22 # `make distribution' in the sendmail config file source directory.
23 # EXTRA_KERNELS has a machine-dependent list of kernels to build added
24 # to it, but you may also set this to have extra ones built.
25 # BUILD_KERNELS are a machine-dependent list of kernels that should just
26 # be built in place but not made into sets or installed, e.g., an
27 # INSTALL kernel used later in src/distrib/.
28 #
29 # Targets:
30 # distribution: makes a full NetBSD distribution in DESTDIR. If
31 # INSTALL_DONE is set, it will not do a `make install.'
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 TZDIR= /usr/share/zoneinfo
46 LOCALTIME?= UTC
47
48 # Flags for creating ISO CDROM image
49 # mkisofs is expected to be in $PATH, install via pkgsrc/sysutils/cdrecord
50 MKISOFS?= mkisofs
51 MKISOFS_FLAGS+= -J -l \
52 -r -T -v \
53 -P "The NetBSD Project" \
54 -m "${RELEASEDIR}/installation/cdrom"
55
56 # setting NOOBJ prevents "make obj" from doing anything;
57 # an objdir would break the installation stuff below
58 MKOBJ= no
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 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 (${MACHINE_ARCH} == "arm32")
100 BIN1+= ld.so.conf
101 .elif exists(etc.${MACHINE_ARCH}/ld.so.conf)
102 BIN1+= etc.${MACHINE_ARCH}/ld.so.conf
103 .endif
104
105 .if exists(etc.${MACHINE_ARCH}/ttyaction)
106 BIN1+= etc.${MACHINE_ARCH}/ttyaction
107 .endif
108
109 # IPv6
110 BIN1+= rtadvd.conf
111
112 # -rw-rw-r--
113 BIN2+= motd
114
115 # -rw-------
116 BIN3+= hosts.equiv
117
118 NAMEDB= 127 root.cache named.conf localhost loopback.v6
119 PCS= pcs750.bin
120
121 # find out endianness of target and set proper flag for pwd_mkdb so that
122 # it creates database in same endianness
123 .if exists(${DESTDIR}/usr/include/machine/endian_machdep.h)
124 TARGET_ENDIANNESS!= \
125 ( echo "\#include <machine/endian_machdep.h>" ; echo _BYTE_ORDER ) | \
126 ${CC} -I${DESTDIR}/usr/include -E - | tail -1 | awk '{print $$1}'
127 .else
128 TARGET_ENDIANNESS=
129 .endif
130
131 .if ${TARGET_ENDIANNESS} == "_LITTLE_ENDIAN"
132 TARGET_ENDIANNESS= -L
133 .elif ${TARGET_ENDIANNESS} == "_BIG_ENDIAN"
134 TARGET_ENDIANNESS= -B
135 .else
136 TARGET_ENDIANNESS=
137 .endif
138
139 all clean cleandir depend distclean etc includes install lint:
140
141
142 .include <bsd.kernobj.mk>
143
144 obj:
145 mkdir -p ${KERNOBJDIR}
146
147 .ifndef DESTDIR
148 distribution distrib-dirs release snapshot snap_pre snap_md_pre \
149 snap_md_post iso-image:
150 @echo setenv DESTDIR before doing that!
151 @false
152 .else
153 distribution: distrib-dirs
154 .if !defined(INSTALL_DONE)
155 (cd ..; ${MAKE} _DISTRIB= includes)
156 (cd ..; ${MAKE} _DISTRIB= install)
157 .endif
158 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 ${BIN1} \
159 ${DESTDIR}/etc
160 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 ${BIN2} \
161 ${DESTDIR}/etc
162 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 ${BIN3} \
163 ${DESTDIR}/etc
164 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 aliases \
165 ${DESTDIR}/etc/mail
166 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 crontab \
167 ${DESTDIR}/var/cron/tabs/root
168 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 master.passwd \
169 ${DESTDIR}/etc
170 pwd_mkdb -p ${TARGET_ENDIANNESS} -d ${DESTDIR}/ \
171 ${DESTDIR}/etc/master.passwd
172 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 555 \
173 MAKEDEV.local etc.${MACHINE}/MAKEDEV ${DESTDIR}/dev
174 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 minfree \
175 ${DESTDIR}/var/crash
176 (cd root; \
177 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.cshrc \
178 ${DESTDIR}/root/.cshrc; \
179 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 dot.klogin \
180 ${DESTDIR}/root/.klogin; \
181 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.login \
182 ${DESTDIR}/root/.login; \
183 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.profile \
184 ${DESTDIR}/root/.profile; \
185 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.shrc \
186 ${DESTDIR}/root/.shrc; \
187 rm -f ${DESTDIR}/.cshrc ${DESTDIR}/.profile; \
188 ln ${DESTDIR}/root/.cshrc ${DESTDIR}/.cshrc; \
189 ln ${DESTDIR}/root/.profile ${DESTDIR}/.profile)
190 (cd defaults; ${MAKE} install)
191 (cd mtree; ${MAKE} install)
192 (cd namedb; \
193 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 \
194 ${NAMEDB} ${DESTDIR}/etc/namedb)
195 (cd rc.d; ${MAKE} install)
196 /bin/rm -f ${DESTDIR}/etc/localtime
197 ln -s ${TZDIR}/${LOCALTIME} ${DESTDIR}/etc/localtime
198 /bin/rm -f ${DESTDIR}/etc/rmt
199 ln -s /usr/sbin/rmt ${DESTDIR}/etc/rmt
200 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g operator -m 664 /dev/null \
201 ${DESTDIR}/etc/dumpdates
202 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g operator -m 600 /dev/null \
203 ${DESTDIR}/etc/skeykeys
204 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 /dev/null \
205 ${DESTDIR}/var/at/at.deny
206 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 /dev/null \
207 ${DESTDIR}/var/cron/log
208 ${INSTALL} ${INSTPRIV} -c -o nobody -g ${BINGRP} -m 664 /dev/null \
209 ${DESTDIR}/var/db/locate.database
210 ${INSTALL} ${INSTPRIV} -c -o uucp -g dialer -m 640 /dev/null \
211 ${DESTDIR}/var/log/aculog
212 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
213 ${DESTDIR}/var/log/authlog
214 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \
215 ${DESTDIR}/var/log/lastlog
216 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 640 /dev/null \
217 ${DESTDIR}/var/log/lpd-errs
218 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
219 ${DESTDIR}/var/log/maillog
220 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
221 ${DESTDIR}/var/log/messages
222 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
223 ${DESTDIR}/var/log/secure
224 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
225 ${DESTDIR}/var/log/sendmail.st
226 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
227 ${DESTDIR}/var/log/wtmp
228 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
229 ${DESTDIR}/var/log/xferlog
230 ${INSTALL} ${INSTPRIV} -c -o daemon -g staff -m 664 /dev/null \
231 ${DESTDIR}/var/msgs/bounds
232 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \
233 ${DESTDIR}/var/run/utmp
234 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
235 ${DESTDIR}/var/games/atc_scores
236 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
237 ${DESTDIR}/var/games/battlestar.log
238 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
239 ${DESTDIR}/var/games/cfscores
240 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
241 ${DESTDIR}/var/games/criblog
242 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
243 ${DESTDIR}/var/games/robots_roll
244 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
245 ${DESTDIR}/var/games/rogue.scores
246 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
247 ${DESTDIR}/var/games/saillog
248 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
249 ${DESTDIR}/var/games/snakerawscores
250 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
251 ${DESTDIR}/var/games/snake.log
252 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
253 ${DESTDIR}/var/games/tetris.scores
254 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
255 ${DESTDIR}/var/games/larn/llog12.0
256 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
257 ${DESTDIR}/var/games/larn/lscore12.0
258 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
259 ${DESTDIR}/var/games/larn/playerids
260 (cd etc.${MACHINE}; ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} \
261 -g ${BINGRP} -m 444 fstab.* ${DESTDIR}/etc)
262 (cd ${DESTDIR}/dev; ./MAKEDEV all)
263 (cd skel; ${MAKE} distribution)
264 (cd ../usr.bin/mail; ${MAKE} distribution)
265 (cd ../usr.bin/ssh; ${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
274 distrib-dirs:
275 ${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${DESTDIR}
276 -mtree -def mtree/NetBSD.dist -p ${DESTDIR}/ -u
277 cd ${DESTDIR}; rm -f sys; ln -s usr/src/sys sys
278
279 .if !defined(RELEASEDIR)
280 release snapshot snap_pre snap_md_pre snap_md_post iso-image:
281 @echo setenv RELEASEDIR before doing that!
282 @false
283 .else
284 release snapshot: distribution snap_pre snap_md_pre snap_kern snap_md_post
285 (cd ../distrib/sets; ${MAKE} sets)
286 sh ../distrib/sets/makesums -t ${RELEASEDIR}/binary/kernel '*.gz'
287
288 # Standalone target to create a CDROM image after the release
289 # was composed. Should be run after "make build" in both src and xsrc
290 iso-image: iso-image_md_post
291
292 iso-image_mi: iso-image_md_pre
293 @if ${MKISOFS} --version; then \
294 mkdir -p ${RELEASEDIR}/installation/cdrom ; \
295 ${MKISOFS} ${MKISOFS_FLAGS} \
296 -o ${RELEASEDIR}/installation/cdrom/netbsd-${MACHINE}.iso \
297 ${RELEASEDIR} ; \
298 sh ../distrib/sets/makesums -t ${RELEASEDIR}/installation/cdrom '*.iso' ; \
299 else \
300 echo "install pkgsrc/sysutils/cdrecord and type 'make iso-image'." ; \
301 fi
302
303 # Setup the $RELEASEDIR to produce a bootable CD image:
304 iso-image_md_pre:
305 # nothing here -- look in the machine-dependent Makefile.inc
306
307 # Fixup the CD-image to be bootable
308 iso-image_md_post: iso-image_mi
309 # nothing here -- look in the machine-dependent Makefile.inc
310
311 snap_pre:
312 # Could be a mount point, ignore the errors
313 -/bin/rm -rf ${RELEASEDIR}
314 ${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${RELEASEDIR}
315 .for dir in ${INSTALLATION_DIRS}
316 ${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${RELEASEDIR}/${dir}
317 .endfor
318
319
320 # This target builds the GENERIC kernel (which must exist for all
321 # ports) and puts it in binary/sets/kern.tgz, and also builds any
322 # kernels specified in EXTRA_KERNELS. Since NetBSD's kernel build
323 # system can create more than one kernel from a single configuration
324 # we figure out how many there are, what they're named, and move them
325 # to binary/kernel/${KERNEL}.${CONFIGFILE}.gz - most often KERNEL will
326 # simply be "netbsd". If we don't find the "config" line, assume the
327 # kernel will be "netbsd" (some config files are simple additions on
328 # GENERIC, and just include it).
329 #
330 GETKERNELAWK= awk '/^config/ {print $$2; found=1} \
331 END{ if (found == 0) print "netbsd"; }'
332 #
333 .if !target(snap_kern)
334 snap_kern:
335 .ifndef KERNELS_DONE
336 .for configfile in GENERIC ${EXTRA_KERNELS} ${BUILD_KERNELS}
337 cd ${KERNCONFDIR} && ${CONFIG} \
338 -b ${KERNOBJDIR}/${configfile} -s ${KERNSRCDIR} ${configfile}
339 .ifndef UPDATE
340 cd ${KERNOBJDIR}/${configfile} && ${MAKE} distclean
341 .endif
342 cd ${KERNOBJDIR}/${configfile} && ${MAKE} depend && ${MAKE} ${_J}
343 .endfor # kernels
344 cd ${KERNOBJDIR}/GENERIC && \
345 tar cf - `${GETKERNELAWK} ${KERNCONFDIR}/GENERIC` |\
346 gzip -c -9 > ${RELEASEDIR}/binary/sets/kern.tgz
347 .for configfile in GENERIC ${EXTRA_KERNELS}
348 cd ${KERNOBJDIR}/${configfile} && \
349 for kernel in `${GETKERNELAWK} \
350 ${KERNCONFDIR}/${configfile}` ; { \
351 gzip -c -9 < $${kernel} > \
352 ${RELEASEDIR}/binary/kernel/$${kernel}.${configfile}.gz ; }
353 .endfor # EXTRA_KERNELS
354 .endif # KERNELS_DONE
355 .endif # no target(snap_kern)
356
357 .endif # RELEASEDIR check
358
359 snap_md_pre:
360 # nothing here -- look in the machine-dependent Makefile.inc
361
362 snap_md_post:
363 # nothing here -- look in the machine-dependent Makefile.inc
364
365 .endif # DESTDIR check
366
367 .include <bsd.prog.mk>
368