Makefile revision 1.199
1# $NetBSD: Makefile,v 1.199 2001/12/12 00:07:46 tv 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 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 distrib-dirs release snapshot snap_pre snap_md_pre \ 146iso-image: __warndestdir 147.if !target(snap_md_post) 148snap_md_post: __warndestdir 149.endif 150.else 151distribution: distrib-dirs 152.if !defined(DISTRIBUTION_DONE) 153.if !defined(INSTALL_DONE) 154 (cd ..; ${MAKE} _DISTRIB= includes) 155 (cd ..; ${MAKE} _DISTRIB= install) 156.endif 157 ${MAKE} install-etc-files 158.endif 159 160install-etc-files: 161 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 ${BIN1} \ 162 ${DESTDIR}/etc 163 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 ${BIN2} \ 164 ${DESTDIR}/etc 165 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 ${BIN3} \ 166 ${DESTDIR}/etc 167 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 aliases \ 168 ${DESTDIR}/etc/mail 169 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 crontab \ 170 ${DESTDIR}/var/cron/tabs/root 171 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 master.passwd \ 172 ${DESTDIR}/etc 173 ${PWD_MKDB} -p ${TARGET_ENDIANNESS} -d ${DESTDIR}/ \ 174 ${DESTDIR}/etc/master.passwd 175.if defined(UNPRIVED) 176 echo "${DESTDIR}/etc/passwd type=file mode=0644 uname=root gname=wheel" \ 177 | sed -e 's|^/|./|g' -e 's|//|/|g' >>${METALOG} 178 echo "${DESTDIR}/etc/pwd.db type=file mode=0644 uname=root gname=wheel" \ 179 | sed -e 's|^/|./|g' -e 's|//|/|g' >>${METALOG} 180 echo "${DESTDIR}/etc/spwd.db type=file mode=0600 uname=root gname=wheel" \ 181 | sed -e 's|^/|./|g' -e 's|//|/|g' >>${METALOG} 182.endif 183 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 555 \ 184 MAKEDEV.local etc.${MACHINE}/MAKEDEV ${DESTDIR}/dev 185 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 minfree \ 186 ${DESTDIR}/var/crash 187 (cd root; \ 188 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.cshrc \ 189 ${DESTDIR}/root/.cshrc; \ 190 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 dot.klogin \ 191 ${DESTDIR}/root/.klogin; \ 192 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.login \ 193 ${DESTDIR}/root/.login; \ 194 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.profile \ 195 ${DESTDIR}/root/.profile; \ 196 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.shrc \ 197 ${DESTDIR}/root/.shrc; \ 198 rm -f ${DESTDIR}/.cshrc ${DESTDIR}/.profile; \ 199 ${INSTALL} ${INSTPRIV} -l h \ 200 ${DESTDIR}/root/.cshrc ${DESTDIR}/.cshrc; \ 201 ${INSTALL} ${INSTPRIV} -l h \ 202 ${DESTDIR}/root/.profile ${DESTDIR}/.profile) 203 (cd defaults; ${MAKE} install) 204 (cd mtree; ${MAKE} install) 205 (cd namedb; \ 206 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 \ 207 ${NAMEDB} ${DESTDIR}/etc/namedb) 208 (cd rc.d; ${MAKE} install) 209 ${INSTALL} ${INSTPRIV} -l s -o root -g wheel -m 755 \ 210 ${TZDIR}/${LOCALTIME} ${DESTDIR}/etc/localtime 211 ${INSTALL} ${INSTPRIV} -l s -o root -g wheel -m 755 \ 212 /usr/sbin/rmt ${DESTDIR}/etc/rmt 213 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g operator -m 664 /dev/null \ 214 ${DESTDIR}/etc/dumpdates 215 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g operator -m 600 /dev/null \ 216 ${DESTDIR}/etc/skeykeys 217 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 /dev/null \ 218 ${DESTDIR}/var/at/at.deny 219 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 /dev/null \ 220 ${DESTDIR}/var/cron/log 221 ${INSTALL} ${INSTPRIV} -c -o nobody -g ${BINGRP} -m 664 /dev/null \ 222 ${DESTDIR}/var/db/locate.database 223 ${INSTALL} ${INSTPRIV} -c -o uucp -g dialer -m 640 /dev/null \ 224 ${DESTDIR}/var/log/aculog 225 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \ 226 ${DESTDIR}/var/log/authlog 227 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \ 228 ${DESTDIR}/var/log/lastlog 229 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 640 /dev/null \ 230 ${DESTDIR}/var/log/lpd-errs 231 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \ 232 ${DESTDIR}/var/log/maillog 233 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \ 234 ${DESTDIR}/var/log/messages 235 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \ 236 ${DESTDIR}/var/log/secure 237 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \ 238 ${DESTDIR}/var/log/sendmail.st 239 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \ 240 ${DESTDIR}/var/log/wtmp 241 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \ 242 ${DESTDIR}/var/log/xferlog 243 ${INSTALL} ${INSTPRIV} -c -o daemon -g staff -m 664 /dev/null \ 244 ${DESTDIR}/var/msgs/bounds 245 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \ 246 ${DESTDIR}/var/run/utmp 247 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 248 ${DESTDIR}/var/games/atc_scores 249 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 250 ${DESTDIR}/var/games/battlestar.log 251 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 252 ${DESTDIR}/var/games/cfscores 253 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 254 ${DESTDIR}/var/games/criblog 255 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 256 ${DESTDIR}/var/games/robots_roll 257 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 258 ${DESTDIR}/var/games/rogue.scores 259 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 260 ${DESTDIR}/var/games/saillog 261 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 262 ${DESTDIR}/var/games/snakerawscores 263 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 264 ${DESTDIR}/var/games/snake.log 265 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 266 ${DESTDIR}/var/games/tetris.scores 267 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 268 ${DESTDIR}/var/games/larn/llog12.0 269 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 270 ${DESTDIR}/var/games/larn/lscore12.0 271 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 272 ${DESTDIR}/var/games/larn/playerids 273 (cd etc.${MACHINE}; ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} \ 274 -g ${BINGRP} -m 444 fstab.* ${DESTDIR}/etc) 275 (cd skel; ${MAKE} distribution) 276 (cd ../usr.bin/mail; ${MAKE} distribution) 277 (cd ../gnu/usr.sbin/postfix/; ${MAKE} distribution) 278.if (${MKCRYPTO} != "no") 279 (cd ../usr.bin/ssh; ${MAKE} distribution) 280.endif 281.ifndef NO_SENDMAIL 282 (cd ../gnu/usr.sbin/sendmail/cf/cf; ${MAKE} distribution) 283.endif 284 285distrib-dirs: 286 ${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${DESTDIR} 287 ${MTREE} -def mtree/NetBSD.dist -p ${DESTDIR}/ -U ${UNPRIVED:D-W} 288 rm -f ${DESTDIR}/sys 289 ${INSTALL} ${INSTPRIV} -l s -o root -g wheel -m 755 \ 290 usr/src/sys ${DESTDIR}/sys 291 292.if !defined(RELEASEDIR) 293__warnreleasedir: .USE 294 @echo setenv RELEASEDIR before doing that! 295 @false 296release snapshot snap_pre snap_md_pre iso-image: __warnreleasedir 297.if !target(snap_md_post) 298snap_md_post: __warnreleasedir 299.endif 300.else 301release snapshot: distribution snap_pre snap_md_pre snap_kern snap_md_post 302 (cd ../distrib/sets; ${MAKE} sets) 303 sh ../distrib/sets/makesums -t ${RELEASEDIR}/binary/kernel '*.gz' 304 305# Standalone target to create a CDROM image after the release 306# was composed. Should be run after "make build" in both src and xsrc 307iso-image: iso-image_md_post 308 309iso-image_mi: iso-image_md_pre 310 @if ${MKISOFS} --version; then \ 311 mkdir -p ${RELEASEDIR}/installation/cdrom ; \ 312 ${MKISOFS} ${MKISOFS_FLAGS} \ 313 -o ${RELEASEDIR}/installation/cdrom/netbsd-${MACHINE}.iso \ 314 ${RELEASEDIR} ; \ 315 sh ../distrib/sets/makesums -t ${RELEASEDIR}/installation/cdrom '*.iso' ; \ 316 else \ 317 echo "install pkgsrc/sysutils/cdrecord and type 'make iso-image'." ; \ 318 fi 319 320# Setup the $RELEASEDIR to produce a bootable CD image: 321iso-image_md_pre: 322# nothing here -- look in the machine-dependent Makefile.inc 323 324# Fixup the CD-image to be bootable 325iso-image_md_post: iso-image_mi 326# nothing here -- look in the machine-dependent Makefile.inc 327 328snap_pre: 329# Could be a mount point, ignore the errors 330 -/bin/rm -rf ${RELEASEDIR} 331 ${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${RELEASEDIR} 332.for dir in ${INSTALLATION_DIRS} 333 ${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${RELEASEDIR}/${dir} 334.endfor 335 336# This target builds the kernels specified by each port. A port may 337# specify the following kernels: 338# 339# KERNEL_SETS The list of kernels that will be 340# packaged into sets, named 341# kern-${kernel}.tgz. These kernels 342# are also placed in the binary/kernels 343# area of the release package as 344# netbsd-${kernel}.gz. 345# 346# EXTRA_KERNELS Additional kernels to place in the 347# binary/kernels area of the release 348# package as netbsd-${kernel}.gz, but 349# which are not placed into sets. This 350# allows a port to provide e.g. a netbootable 351# installation kernel containing a ramdisk. 352# 353# BUILD_KERNELS Additional kernels to build which are 354# not placed into sets nor into the 355# binary/kernels area of the release 356# package. These are typically kernels 357# that are built for inclusion only in 358# installation disk/CD-ROM/tape images. 359# 360# A port may also specify KERNEL_SUFFIXES, which is an optional list 361# of filename suffixes for kernels to include in the kernel sets and 362# in the binary/kernels area of the release package (e.g. "netbsd" vs. 363# "netbsd.ecoff" and "netbsd.srec"). It is not an error if kernels 364# with these suffixes do not exist in the kernel build directory. 365# 366GETKERNELAWK= awk '/^config/ {print $$2; found=1} \ 367 END{ if (found == 0) print "netbsd"; }' 368# 369.if !target(snap_kern) 370snap_kern: 371.ifndef KERNELS_DONE 372.for configfile in ${KERNEL_SETS} ${EXTRA_KERNELS} ${BUILD_KERNELS} 373 cd ${KERNCONFDIR} && ${CONFIG} \ 374 -b ${KERNOBJDIR}/${configfile:C/.*\///} -s ${KERNSRCDIR} ${configfile} 375.ifndef UPDATE 376 cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} distclean 377.endif 378 cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} depend && ${MAKE} ${_J} 379.endfor # build kernels 380.for configfile in ${KERNEL_SETS} 381 kernlist=`${GETKERNELAWK} ${KERNCONFDIR}/${configfile}`; \ 382 kerndir=${KERNOBJDIR}/${configfile:C/.*\///}; \ 383 cd $${kerndir} && \ 384 tarlist=`for kernel in $${kernlist}; do \ 385 echo "$${kernel}"; \ 386 for s in ${KERNEL_SUFFIXES}; do \ 387 if [ -f $${kernel}.$${s} ]; then \ 388 echo "$${kernel}.$${s}"; \ 389 fi; \ 390 done; \ 391 done`; \ 392 tar cf - $${tarlist} | \ 393 gzip -c -9 > ${RELEASEDIR}/binary/sets/kern-${configfile}.tgz 394.endfor # make kernel sets 395.for configfile in ${KERNEL_SETS} ${EXTRA_KERNELS} 396 kernlist=`${GETKERNELAWK} ${KERNCONFDIR}/${configfile:C/.*\///}`; \ 397 kerndir=${KERNOBJDIR}/${configfile:C/.*\///}; \ 398 cd $${kerndir} && \ 399 gziplist=`for kernel in $${kernlist}; do \ 400 echo "$${kernel}"; \ 401 for s in ${KERNEL_SUFFIXES}; do \ 402 if [ -f $${kernel}.$${s} ]; then \ 403 echo "$${kernel}.$${s}"; \ 404 fi; \ 405 done; \ 406 done`; \ 407 for kernel in $${gziplist} ; do \ 408 gzip -c -9 < $${kernel} > \ 409 ${RELEASEDIR}/binary/kernel/$${kernel}-${configfile:C/.*\///}.gz ; done 410.endfor # place KERNEL_SETS kernels + EXTRA_KERNELS in binary/kernel/... 411.endif # KERNELS_DONE 412.endif # no target(snap_kern) 413 414.endif # RELEASEDIR check 415 416snap_md_pre: 417# nothing here -- look in the machine-dependent Makefile.inc 418 419snap_md_post: 420# nothing here -- look in the machine-dependent Makefile.inc 421 422.endif # DESTDIR check 423 424.include <bsd.prog.mk> 425