Makefile revision 1.201
1# $NetBSD: Makefile,v 1.201 2002/01/27 06:49:22 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, 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 36NOOBJ= # defined 37 38# do this before bsd.own.mk so we get correct KERNSRCDIR 39.include "../Makefile.inc" 40 41# For NO_SENDMAIL, INSTPRIV, MKCRYPTO 42.include <bsd.own.mk> 43 44.MAKEOVERRIDES+= USETOOLS 45 46TZDIR= /usr/share/zoneinfo 47LOCALTIME?= UTC 48PWD_MKDB?= pwd_mkdb 49 50# Flags for creating ISO CDROM image 51# mkisofs is expected to be in $PATH, install via pkgsrc/sysutils/cdrecord 52MKISOFS?= mkisofs 53MKISOFS_FLAGS+= -J -l \ 54 -r -T -v \ 55 -P "The NetBSD Project" \ 56 -m "${RELEASEDIR}/installation/cdrom" 57 58# MD Makefile.inc may append MD targets to BIN[123]. Make sure all 59# are empty, to preserve the old semantics of setting them below with "=". 60BIN1= 61BIN2= 62BIN3= 63 64# Directories to build in ${RELEASEDIR}. MD Makefile.inc files can 65# add to this. 66# NOTE: Parent directories must be listed before subdirectories. 67INSTALLATION_DIRS= \ 68 binary binary/sets binary/kernel installation 69 70.if exists(etc.${MACHINE}/Makefile.inc) 71.include "etc.${MACHINE}/Makefile.inc" 72.endif 73 74# Use multiple jobs for kernel builds, if NBUILDJOBS set. 75# (Taken from src/Makefile.) 76.if defined(NBUILDJOBS) 77_J= -j${NBUILDJOBS} 78.endif 79 80# -rw-r--r-- 81BINOWN= root 82BINGRP= wheel 83BIN1+= bootptab changelist csh.cshrc csh.login csh.logout daily \ 84 daily.conf dm.conf floppytab ftpchroot ftpusers ftpwelcome \ 85 gettytab group hosts hosts.lpd inetd.conf lkm.conf \ 86 mailer.conf man.conf monthly monthly.conf mrouted.conf \ 87 netconfig networks newsyslog.conf nsswitch.conf ntp.conf \ 88 phones printcap profile protocols rbootd.conf rc rc.conf \ 89 rc.lkm rc.local rc.subr rc.shutdown remote rpc \ 90 security security.conf services shells sysctl.conf syslog.conf \ 91 weekly weekly.conf wscons.conf \ 92 etc.${MACHINE}/ttys etc.${MACHINE}/disktab 93 94.if (${MACHINE_ARCH} == "m68k") || \ 95 (${MACHINE_ARCH} == "ns32k") || \ 96 (${MACHINE_ARCH} == "vax") || \ 97 (${MACHINE_ARCH} == "arm32") 98BIN1+= ld.so.conf 99.elif exists(etc.${MACHINE_ARCH}/ld.so.conf) 100BIN1+= etc.${MACHINE_ARCH}/ld.so.conf 101.endif 102 103.if exists(etc.${MACHINE_ARCH}/ttyaction) 104BIN1+= etc.${MACHINE_ARCH}/ttyaction 105.endif 106 107# -rw-rw-r-- 108BIN2+= motd 109 110# -rw------- 111BIN3+= hosts.equiv 112 113NAMEDB= 127 root.cache named.conf localhost loopback.v6 114PCS= pcs750.bin 115 116.if make(release) || make(snapshot) || make(distribution) # { 117# find out endianness of target and set proper flag for pwd_mkdb so that 118# it creates database in same endianness 119.if exists(${DESTDIR}/usr/include/sys/endian.h) 120TARGET_ENDIANNESS!= \ 121 printf '\#include <sys/endian.h>\n_BYTE_ORDER\n' | \ 122 ${CC} -I${DESTDIR}/usr/include -E - | tail -1 | awk '{print $$1}' 123.else 124TARGET_ENDIANNESS= 125.endif 126 127.if ${TARGET_ENDIANNESS} == "1234" 128TARGET_ENDIANNESS= -L 129.elif ${TARGET_ENDIANNESS} == "4321" 130TARGET_ENDIANNESS= -B 131.else 132TARGET_ENDIANNESS= 133.endif 134.endif # release || snapshot || distribution # } 135 136.include <bsd.kernobj.mk> 137 138obj: 139 mkdir -p ${KERNOBJDIR} 140 141.if !defined(DESTDIR) || ${DESTDIR} == "" # { 142__warndestdir: .USE 143 @echo setenv DESTDIR before doing that! 144 @false 145distribution install-etc-files distrib-dirs \ 146 release snapshot iso-image iso_image_mi iso-image_md_pre iso-image_md_post \ 147 snap_pre snap_md_pre: __warndestdir 148.if !target(snap_md_post) 149snap_md_post: __warndestdir 150.endif 151.if !target(snap_kern) 152snap_kern: __warndestdir 153.endif 154 155.else # DESTDIR != "" # } { 156 157distribution: distrib-dirs 158.if !defined(DISTRIBUTION_DONE) 159.if !defined(INSTALL_DONE) 160 (cd ..; ${MAKE} _DISTRIB= includes) 161 (cd ..; ${MAKE} _DISTRIB= install) 162.endif # !INSTALL_DONE 163 ${MAKE} install-etc-files 164.endif # !DISTRIBUTION_DONE 165 166install-etc-files: 167 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 ${BIN1} \ 168 ${DESTDIR}/etc 169 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 ${BIN2} \ 170 ${DESTDIR}/etc 171 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 ${BIN3} \ 172 ${DESTDIR}/etc 173 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 aliases \ 174 ${DESTDIR}/etc/mail 175 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 crontab \ 176 ${DESTDIR}/var/cron/tabs/root 177 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 master.passwd \ 178 ${DESTDIR}/etc 179 ${PWD_MKDB} -p ${TARGET_ENDIANNESS} -d ${DESTDIR}/ \ 180 ${DESTDIR}/etc/master.passwd 181.if defined(UNPRIVED) 182 echo "${DESTDIR}/etc/passwd type=file mode=0644 uname=root gname=wheel" \ 183 | sed -e 's|^/|./|g' -e 's|//|/|g' >>${METALOG} 184 echo "${DESTDIR}/etc/pwd.db type=file mode=0644 uname=root gname=wheel" \ 185 | sed -e 's|^/|./|g' -e 's|//|/|g' >>${METALOG} 186 echo "${DESTDIR}/etc/spwd.db type=file mode=0600 uname=root gname=wheel" \ 187 | sed -e 's|^/|./|g' -e 's|//|/|g' >>${METALOG} 188.endif # UNPRIVED 189 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 555 \ 190 MAKEDEV.local etc.${MACHINE}/MAKEDEV ${DESTDIR}/dev 191 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 minfree \ 192 ${DESTDIR}/var/crash 193 (cd root; \ 194 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.cshrc \ 195 ${DESTDIR}/root/.cshrc; \ 196 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 dot.klogin \ 197 ${DESTDIR}/root/.klogin; \ 198 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.login \ 199 ${DESTDIR}/root/.login; \ 200 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.profile \ 201 ${DESTDIR}/root/.profile; \ 202 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.shrc \ 203 ${DESTDIR}/root/.shrc; \ 204 rm -f ${DESTDIR}/.cshrc ${DESTDIR}/.profile; \ 205 ${INSTALL} ${INSTPRIV} -l h \ 206 ${DESTDIR}/root/.cshrc ${DESTDIR}/.cshrc; \ 207 ${INSTALL} ${INSTPRIV} -l h \ 208 ${DESTDIR}/root/.profile ${DESTDIR}/.profile) 209 (cd defaults; ${MAKE} install) 210 (cd mtree; ${MAKE} install) 211 (cd namedb; \ 212 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 \ 213 ${NAMEDB} ${DESTDIR}/etc/namedb) 214 (cd rc.d; ${MAKE} install) 215 ${INSTALL} ${INSTPRIV} -l s -o root -g wheel -m 755 \ 216 ${TZDIR}/${LOCALTIME} ${DESTDIR}/etc/localtime 217 ${INSTALL} ${INSTPRIV} -l s -o root -g wheel -m 755 \ 218 /usr/sbin/rmt ${DESTDIR}/etc/rmt 219 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g operator -m 664 /dev/null \ 220 ${DESTDIR}/etc/dumpdates 221 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g operator -m 600 /dev/null \ 222 ${DESTDIR}/etc/skeykeys 223 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 /dev/null \ 224 ${DESTDIR}/var/at/at.deny 225 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 /dev/null \ 226 ${DESTDIR}/var/cron/log 227 ${INSTALL} ${INSTPRIV} -c -o nobody -g ${BINGRP} -m 664 /dev/null \ 228 ${DESTDIR}/var/db/locate.database 229 ${INSTALL} ${INSTPRIV} -c -o uucp -g dialer -m 640 /dev/null \ 230 ${DESTDIR}/var/log/aculog 231 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \ 232 ${DESTDIR}/var/log/authlog 233 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \ 234 ${DESTDIR}/var/log/lastlog 235 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 640 /dev/null \ 236 ${DESTDIR}/var/log/lpd-errs 237 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \ 238 ${DESTDIR}/var/log/maillog 239 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \ 240 ${DESTDIR}/var/log/messages 241 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \ 242 ${DESTDIR}/var/log/secure 243 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \ 244 ${DESTDIR}/var/log/sendmail.st 245 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \ 246 ${DESTDIR}/var/log/wtmp 247 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \ 248 ${DESTDIR}/var/log/xferlog 249 ${INSTALL} ${INSTPRIV} -c -o daemon -g staff -m 664 /dev/null \ 250 ${DESTDIR}/var/msgs/bounds 251 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \ 252 ${DESTDIR}/var/run/utmp 253 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 254 ${DESTDIR}/var/games/atc_scores 255 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 256 ${DESTDIR}/var/games/battlestar.log 257 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 258 ${DESTDIR}/var/games/cfscores 259 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 260 ${DESTDIR}/var/games/criblog 261 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 262 ${DESTDIR}/var/games/robots_roll 263 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 264 ${DESTDIR}/var/games/rogue.scores 265 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 266 ${DESTDIR}/var/games/saillog 267 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 268 ${DESTDIR}/var/games/snakerawscores 269 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 270 ${DESTDIR}/var/games/snake.log 271 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 272 ${DESTDIR}/var/games/tetris.scores 273 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 274 ${DESTDIR}/var/games/larn/llog12.0 275 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 276 ${DESTDIR}/var/games/larn/lscore12.0 277 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 278 ${DESTDIR}/var/games/larn/playerids 279 (cd etc.${MACHINE}; ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} \ 280 -g ${BINGRP} -m 444 fstab.* ${DESTDIR}/etc) 281 (cd skel; ${MAKE} distribution) 282 (cd ../usr.bin/mail; ${MAKE} distribution) 283 (cd ../gnu/usr.sbin/postfix/; ${MAKE} distribution) 284.if (${MKCRYPTO} != "no") 285 (cd ../usr.bin/ssh; ${MAKE} distribution) 286.endif 287.if !defined(NO_SENDMAIL) 288 (cd ../gnu/usr.sbin/sendmail/cf/cf; ${MAKE} distribution) 289.endif 290 291distrib-dirs: 292 ${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${DESTDIR} 293 ${MTREE} -def mtree/NetBSD.dist -p ${DESTDIR}/ -U ${UNPRIVED:D-W} 294 rm -f ${DESTDIR}/sys 295 ${INSTALL} ${INSTPRIV} -l s -o root -g wheel -m 755 \ 296 usr/src/sys ${DESTDIR}/sys 297 298.if !defined(RELEASEDIR) # { 299__warnreleasedir: .USE 300 @echo setenv RELEASEDIR before doing that! 301 @false 302release snapshot iso-image iso_image_mi iso-image_md_pre iso-image_md_post \ 303 snap_pre snap_md_pre: __warnreleasedir 304.if !target(snap_md_post) 305snap_md_post: __warnreleasedir 306.endif 307.if !target(snap_kern) 308snap_kern: __warnreleasedir 309.endif 310 311.else # RELEASEDIR # } { 312 313release snapshot: distribution snap_pre snap_md_pre snap_kern snap_md_post 314 (cd ../distrib/sets; ${MAKE} sets) 315 sh ../distrib/sets/makesums -t ${RELEASEDIR}/binary/kernel '*.gz' 316 317# Standalone target to create a CDROM image after the release 318# was composed. Should be run after "make build" in both src and xsrc 319iso-image: iso-image_md_post 320 321iso-image_mi: iso-image_md_pre 322 @if ${MKISOFS} --version; then \ 323 mkdir -p ${RELEASEDIR}/installation/cdrom ; \ 324 ${MKISOFS} ${MKISOFS_FLAGS} \ 325 -o ${RELEASEDIR}/installation/cdrom/netbsd-${MACHINE}.iso \ 326 ${RELEASEDIR} ; \ 327 sh ../distrib/sets/makesums -t ${RELEASEDIR}/installation/cdrom '*.iso' ; \ 328 else \ 329 echo "install pkgsrc/sysutils/cdrecord and type 'make iso-image'." ; \ 330 fi 331 332# Setup the $RELEASEDIR to produce a bootable CD image: 333iso-image_md_pre: 334# nothing here -- look in the machine-dependent Makefile.inc 335 336# Fixup the CD-image to be bootable 337iso-image_md_post: iso-image_mi 338# nothing here -- look in the machine-dependent Makefile.inc 339 340snap_pre: 341# Could be a mount point, ignore the errors 342 -/bin/rm -rf ${RELEASEDIR} 343 ${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${RELEASEDIR} 344.for dir in ${INSTALLATION_DIRS} 345 ${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${RELEASEDIR}/${dir} 346.endfor 347 348# This target builds the kernels specified by each port. A port may 349# specify the following kernels: 350# 351# KERNEL_SETS The list of kernels that will be 352# packaged into sets, named 353# kern-${kernel}.tgz. These kernels 354# are also placed in the binary/kernels 355# area of the release package as 356# netbsd-${kernel}.gz. 357# 358# EXTRA_KERNELS Additional kernels to place in the 359# binary/kernels area of the release 360# package as netbsd-${kernel}.gz, but 361# which are not placed into sets. This 362# allows a port to provide e.g. a netbootable 363# installation kernel containing a ramdisk. 364# 365# BUILD_KERNELS Additional kernels to build which are 366# not placed into sets nor into the 367# binary/kernels area of the release 368# package. These are typically kernels 369# that are built for inclusion only in 370# installation disk/CD-ROM/tape images. 371# 372# A port may also specify KERNEL_SUFFIXES, which is an optional list 373# of filename suffixes for kernels to include in the kernel sets and 374# in the binary/kernels area of the release package (e.g. "netbsd" vs. 375# "netbsd.ecoff" and "netbsd.srec"). It is not an error if kernels 376# with these suffixes do not exist in the kernel build directory. 377# 378GETKERNELAWK= awk '/^config/ {print $$2; found=1} \ 379 END{ if (found == 0) print "netbsd"; }' 380# 381.if !target(snap_kern) 382snap_kern: 383.if !defined(KERNELS_DONE) # { 384.for configfile in ${KERNEL_SETS} ${EXTRA_KERNELS} ${BUILD_KERNELS} 385 cd ${KERNCONFDIR} && ${CONFIG} \ 386 -b ${KERNOBJDIR}/${configfile:C/.*\///} -s ${KERNSRCDIR} ${configfile} 387.if !defined(UPDATE) 388 cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} distclean 389.endif 390 cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} depend && ${MAKE} ${_J} 391.endfor # build kernels 392.for configfile in ${KERNEL_SETS} 393 kernlist=`${GETKERNELAWK} ${KERNCONFDIR}/${configfile}`; \ 394 kerndir=${KERNOBJDIR}/${configfile:C/.*\///}; \ 395 cd $${kerndir} && \ 396 tarlist=`for kernel in $${kernlist}; do \ 397 echo "$${kernel}"; \ 398 for s in ${KERNEL_SUFFIXES}; do \ 399 if [ -f $${kernel}.$${s} ]; then \ 400 echo "$${kernel}.$${s}"; \ 401 fi; \ 402 done; \ 403 done`; \ 404 GZIP=-9 ${PAX} -zwf \ 405 ${RELEASEDIR}/binary/sets/kern-${configfile}.tgz $${tarlist} 406.endfor # make kernel sets 407.for configfile in ${KERNEL_SETS} ${EXTRA_KERNELS} 408 kernlist=`${GETKERNELAWK} ${KERNCONFDIR}/${configfile:C/.*\///}`; \ 409 kerndir=${KERNOBJDIR}/${configfile:C/.*\///}; \ 410 cd $${kerndir} && \ 411 gziplist=`for kernel in $${kernlist}; do \ 412 echo "$${kernel}"; \ 413 for s in ${KERNEL_SUFFIXES}; do \ 414 if [ -f $${kernel}.$${s} ]; then \ 415 echo "$${kernel}.$${s}"; \ 416 fi; \ 417 done; \ 418 done`; \ 419 for kernel in $${gziplist} ; do \ 420 gzip -c -9 < $${kernel} > \ 421 ${RELEASEDIR}/binary/kernel/$${kernel}-${configfile:C/.*\///}.gz ; done 422.endfor # place KERNEL_SETS kernels + EXTRA_KERNELS in binary/kernel/... 423.endif # KERNELS_DONE # } 424.endif # no target(snap_kern) 425 426.endif # RELEASEDIR # } 427 428snap_md_pre: 429# nothing here -- look in the machine-dependent Makefile.inc 430 431snap_md_post: 432# nothing here -- look in the machine-dependent Makefile.inc 433 434.endif # DESTDIR # } 435 436.include <bsd.prog.mk> 437