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