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