Makefile revision 1.170 1 # $NetBSD: Makefile,v 1.170 2000/11/09 20:01:54 jdolecek 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!= awk '/_BYTE_ORDER/{print $$3}' \
125 ${DESTDIR}/usr/include/machine/endian_machdep.h
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 TARGET_ENDIANNESS=
136 .endif
137
138 all clean cleandir depend distclean etc includes install lint:
139
140
141 .include <bsd.kernobj.mk>
142
143 obj:
144 mkdir -p ${KERNOBJDIR}
145
146 .ifndef DESTDIR
147 distribution distrib-dirs release snapshot snap_pre snap_md_pre \
148 snap_md_post iso-image:
149 @echo setenv DESTDIR before doing that!
150 @false
151 .else
152 distribution: distrib-dirs
153 .if !defined(INSTALL_DONE)
154 (cd ..; ${MAKE} _DISTRIB= includes)
155 (cd ..; ${MAKE} _DISTRIB= install)
156 .endif
157 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 ${BIN1} \
158 ${DESTDIR}/etc
159 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 ${BIN2} \
160 ${DESTDIR}/etc
161 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 ${BIN3} \
162 ${DESTDIR}/etc
163 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 aliases \
164 ${DESTDIR}/etc/mail
165 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 crontab \
166 ${DESTDIR}/var/cron/tabs/root
167 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 master.passwd \
168 ${DESTDIR}/etc
169 pwd_mkdb -p ${TARGET_ENDIANNESS} -d ${DESTDIR}/ ${DESTDIR}/etc/master.passwd
170 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 555 \
171 MAKEDEV.local etc.${MACHINE}/MAKEDEV ${DESTDIR}/dev
172 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 minfree \
173 ${DESTDIR}/var/crash
174 (cd root; \
175 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.cshrc \
176 ${DESTDIR}/root/.cshrc; \
177 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 dot.klogin \
178 ${DESTDIR}/root/.klogin; \
179 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.login \
180 ${DESTDIR}/root/.login; \
181 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.profile \
182 ${DESTDIR}/root/.profile; \
183 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.shrc \
184 ${DESTDIR}/root/.shrc; \
185 rm -f ${DESTDIR}/.cshrc ${DESTDIR}/.profile; \
186 ln ${DESTDIR}/root/.cshrc ${DESTDIR}/.cshrc; \
187 ln ${DESTDIR}/root/.profile ${DESTDIR}/.profile)
188 (cd defaults; ${MAKE} install)
189 (cd mtree; ${MAKE} install)
190 (cd namedb; \
191 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 \
192 ${NAMEDB} ${DESTDIR}/etc/namedb)
193 (cd rc.d; ${MAKE} install)
194 /bin/rm -f ${DESTDIR}/etc/localtime
195 ln -s ${TZDIR}/${LOCALTIME} ${DESTDIR}/etc/localtime
196 /bin/rm -f ${DESTDIR}/etc/rmt
197 ln -s /usr/sbin/rmt ${DESTDIR}/etc/rmt
198 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g operator -m 664 /dev/null \
199 ${DESTDIR}/etc/dumpdates
200 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g operator -m 600 /dev/null \
201 ${DESTDIR}/etc/skeykeys
202 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 /dev/null \
203 ${DESTDIR}/var/at/at.deny
204 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 /dev/null \
205 ${DESTDIR}/var/cron/log
206 ${INSTALL} ${INSTPRIV} -c -o nobody -g ${BINGRP} -m 664 /dev/null \
207 ${DESTDIR}/var/db/locate.database
208 ${INSTALL} ${INSTPRIV} -c -o uucp -g dialer -m 640 /dev/null \
209 ${DESTDIR}/var/log/aculog
210 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
211 ${DESTDIR}/var/log/authlog
212 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \
213 ${DESTDIR}/var/log/lastlog
214 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 640 /dev/null \
215 ${DESTDIR}/var/log/lpd-errs
216 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
217 ${DESTDIR}/var/log/maillog
218 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
219 ${DESTDIR}/var/log/messages
220 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
221 ${DESTDIR}/var/log/secure
222 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
223 ${DESTDIR}/var/log/sendmail.st
224 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
225 ${DESTDIR}/var/log/wtmp
226 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
227 ${DESTDIR}/var/log/xferlog
228 ${INSTALL} ${INSTPRIV} -c -o daemon -g staff -m 664 /dev/null \
229 ${DESTDIR}/var/msgs/bounds
230 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \
231 ${DESTDIR}/var/run/utmp
232 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
233 ${DESTDIR}/var/games/atc_scores
234 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
235 ${DESTDIR}/var/games/battlestar.log
236 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
237 ${DESTDIR}/var/games/cfscores
238 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
239 ${DESTDIR}/var/games/criblog
240 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
241 ${DESTDIR}/var/games/robots_roll
242 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
243 ${DESTDIR}/var/games/rogue.scores
244 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
245 ${DESTDIR}/var/games/saillog
246 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
247 ${DESTDIR}/var/games/snakerawscores
248 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
249 ${DESTDIR}/var/games/snake.log
250 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
251 ${DESTDIR}/var/games/tetris.scores
252 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
253 ${DESTDIR}/var/games/larn/llog12.0
254 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
255 ${DESTDIR}/var/games/larn/lscore12.0
256 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
257 ${DESTDIR}/var/games/larn/playerids
258 (cd etc.${MACHINE}; ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} \
259 -g ${BINGRP} -m 444 fstab.* ${DESTDIR}/etc)
260 (cd ${DESTDIR}/dev; ./MAKEDEV all)
261 (cd skel; ${MAKE} distribution)
262 (cd ../usr.bin/mail; ${MAKE} distribution)
263 (cd ../usr.bin/ssh; ${MAKE} distribution)
264 (cd ../gnu/usr.sbin/postfix/; ${MAKE} distribution)
265 .if (${MKCRYPTO} != "no")
266 (cd ../usr.bin/ssh; ${MAKE} distribution)
267 .endif
268 .ifndef NO_SENDMAIL
269 (cd ../gnu/usr.sbin/sendmail/cf/cf; ${MAKE} distribution)
270 .endif
271
272 distrib-dirs:
273 ${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${DESTDIR}
274 -mtree -def mtree/NetBSD.dist -p ${DESTDIR}/ -u
275 cd ${DESTDIR}; rm -f sys; ln -s usr/src/sys sys
276
277 .if !defined(RELEASEDIR)
278 release snapshot snap_pre snap_md_pre snap_md_post iso-image:
279 @echo setenv RELEASEDIR before doing that!
280 @false
281 .else
282 release snapshot: distribution snap_pre snap_md_pre snap_kern snap_md_post
283 (cd ../distrib/sets; ${MAKE} sets)
284 sh ../distrib/sets/makesums -t ${RELEASEDIR}/binary/kernel '*.gz'
285
286 # Standalone target to create a CDROM image after the release
287 # was composed. Should be run after "make build" in both src and xsrc
288 iso-image: iso-image_md_post
289
290 iso-image_mi: iso-image_md_pre
291 @if ${MKISOFS} --version; then \
292 mkdir -p ${RELEASEDIR}/installation/cdrom ; \
293 ${MKISOFS} ${MKISOFS_FLAGS} \
294 -o ${RELEASEDIR}/installation/cdrom/netbsd-${MACHINE}.iso \
295 ${RELEASEDIR} ; \
296 sh ../distrib/sets/makesums -t ${RELEASEDIR}/installation/cdrom '*.iso' ; \
297 else \
298 echo "install pkgsrc/sysutils/cdrecord and type 'make iso-image'." ; \
299 fi
300
301 # Setup the $RELEASEDIR to produce a bootable CD image:
302 iso-image_md_pre:
303 # nothing here -- look in the machine-dependent Makefile.inc
304
305 # Fixup the CD-image to be bootable
306 iso-image_md_post: iso-image_mi
307 # nothing here -- look in the machine-dependent Makefile.inc
308
309 snap_pre:
310 # Could be a mount point, ignore the errors
311 -/bin/rm -rf ${RELEASEDIR}
312 ${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${RELEASEDIR}
313 .for dir in ${INSTALLATION_DIRS}
314 ${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${RELEASEDIR}/${dir}
315 .endfor
316
317
318 # This target builds the GENERIC kernel (which must exist for all
319 # ports) and puts it in binary/sets/kern.tgz, and also builds any
320 # kernels specified in EXTRA_KERNELS. Since NetBSD's kernel build
321 # system can create more than one kernel from a single configuration
322 # we figure out how many there are, what they're named, and move them
323 # to binary/kernel/${KERNEL}.${CONFIGFILE}.gz - most often KERNEL will
324 # simply be "netbsd". If we don't find the "config" line, assume the
325 # kernel will be "netbsd" (some config files are simple additions on
326 # GENERIC, and just include it).
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:
333 .ifndef KERNELS_DONE
334 .for configfile in GENERIC ${EXTRA_KERNELS} ${BUILD_KERNELS}
335 cd ${KERNCONFDIR} && ${CONFIG} \
336 -b ${KERNOBJDIR}/${configfile} -s ${KERNSRCDIR} ${configfile}
337 .ifndef UPDATE
338 cd ${KERNOBJDIR}/${configfile} && ${MAKE} distclean
339 .endif
340 cd ${KERNOBJDIR}/${configfile} && ${MAKE} depend && ${MAKE} ${_J}
341 .endfor # kernels
342 cd ${KERNOBJDIR}/GENERIC && \
343 tar cf - `${GETKERNELAWK} ${KERNCONFDIR}/GENERIC` |\
344 gzip -c -9 > ${RELEASEDIR}/binary/sets/kern.tgz
345 .for configfile in GENERIC ${EXTRA_KERNELS}
346 cd ${KERNOBJDIR}/${configfile} && \
347 for kernel in `${GETKERNELAWK} \
348 ${KERNCONFDIR}/${configfile}` ; { \
349 gzip -c -9 < $${kernel} > \
350 ${RELEASEDIR}/binary/kernel/$${kernel}.${configfile}.gz ; }
351 .endfor # EXTRA_KERNELS
352 .endif # KERNELS_DONE
353 .endif # no target(snap_kern)
354
355 .endif # RELEASEDIR check
356
357 snap_md_pre:
358 # nothing here -- look in the machine-dependent Makefile.inc
359
360 snap_md_post:
361 # nothing here -- look in the machine-dependent Makefile.inc
362
363 .endif # DESTDIR check
364
365 .include <bsd.prog.mk>
366