Makefile revision 1.177
1# $NetBSD: Makefile,v 1.177 2001/08/04 18:41:18 tsutsui 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# EXTRA_KERNELS has a machine-dependent list of kernels to build added 23# to it, but you may also set this to have extra ones built. 24# BUILD_KERNELS are a machine-dependent list of kernels that should just 25# be built in place but not made into sets or installed, e.g., an 26# INSTALL kernel used later in src/distrib/. 27# 28# Targets: 29# distribution: makes a full NetBSD distribution in DESTDIR. If 30# INSTALL_DONE is set, it will not do a `make install.' 31# distrib-dirs: creates an empty NetBSD directory tree in DESTDIR. 32# Called by distribution. 33# snapshot: calls distribution, above, and then tars up the files 34# into a release(7) format in RELEASEDIR. Any port-dependent 35# stuff for this target is found in etc.${MACHINE}/Makefile.inc. 36# release: a synonym for `snapshot' 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 44TZDIR= /usr/share/zoneinfo 45LOCALTIME?= UTC 46 47# Flags for creating ISO CDROM image 48# mkisofs is expected to be in $PATH, install via pkgsrc/sysutils/cdrecord 49MKISOFS?= mkisofs 50MKISOFS_FLAGS+= -J -l \ 51 -r -T -v \ 52 -P "The NetBSD Project" \ 53 -m "${RELEASEDIR}/installation/cdrom" 54 55# setting NOOBJ prevents "make obj" from doing anything; 56# an objdir would break the installation stuff below 57MKOBJ= no 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") || \ 98 (${MACHINE_ARCH} == "arm32") 99BIN1+= ld.so.conf 100.elif exists(etc.${MACHINE_ARCH}/ld.so.conf) 101BIN1+= etc.${MACHINE_ARCH}/ld.so.conf 102.endif 103 104.if exists(etc.${MACHINE_ARCH}/ttyaction) 105BIN1+= etc.${MACHINE_ARCH}/ttyaction 106.endif 107 108# -rw-rw-r-- 109BIN2+= motd 110 111# -rw------- 112BIN3+= hosts.equiv 113 114NAMEDB= 127 root.cache named.conf localhost loopback.v6 115PCS= pcs750.bin 116 117# find out endianness of target and set proper flag for pwd_mkdb so that 118# it creates database in same endianness 119<<<<<<< Makefile 120.if (${MACHINE_ARCH} == "alpha") || \ 121 (${MACHINE_ARCH} == "arm26") || \ 122 (${MACHINE_ARCH} == "arm32") || \ 123 (${MACHINE_ARCH} == "i386") || \ 124 (${MACHINE_ARCH} == "mipsel") || \ 125 (${MACHINE_ARCH} == "ns32k") || \ 126 (${MACHINE_ARCH} == "vax") 127TARGET_ENDIANNESS?= -L 128.elif (${MACHINE_ARCH} == "m68k") || \ 129 (${MACHINE_ARCH} == "mipseb") || \ 130 (${MACHINE_ARCH} == "powerpc") || \ 131 (${MACHINE_ARCH} == "sparc") || \ 132 (${MACHINE_ARCH} == "sparc64") 133TARGET_ENDIANNESS?= -B 134======= 135.if exists(${DESTDIR}/usr/include/machine/endian_machdep.h) 136TARGET_ENDIANNESS!= \ 137 ( echo "\#include <machine/endian_machdep.h>" ; echo _BYTE_ORDER ) | \ 138 ${CC} -I${DESTDIR}/usr/include -E - | tail -1 | awk '{print $$1}' 139.else 140TARGET_ENDIANNESS= 141.endif 142 143.if ${TARGET_ENDIANNESS} == "_LITTLE_ENDIAN" 144TARGET_ENDIANNESS= -L 145.elif ${TARGET_ENDIANNESS} == "_BIG_ENDIAN" 146TARGET_ENDIANNESS= -B 147>>>>>>> 1.176 148.else 149# XXX sh3 should be split into sh3eb and sh3el 150TARGET_ENDIANNESS= 151.endif 152 153all clean cleandir depend distclean etc includes install lint: 154 155 156.include <bsd.kernobj.mk> 157 158obj: 159 mkdir -p ${KERNOBJDIR} 160 161.ifndef DESTDIR 162__warndestdir: .USE 163 @echo setenv DESTDIR before doing that! 164 @false 165distribution distrib-dirs release snapshot snap_pre snap_md_pre \ 166iso-image: __warndestdir 167.if !target(snap_md_post) 168snap_md_post: __warndestdir 169.endif 170.else 171distribution: distrib-dirs 172.if !defined(INSTALL_DONE) 173 (cd ..; ${MAKE} _DISTRIB= includes) 174 (cd ..; ${MAKE} _DISTRIB= install) 175.endif 176 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 ${BIN1} \ 177 ${DESTDIR}/etc 178 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 ${BIN2} \ 179 ${DESTDIR}/etc 180 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 ${BIN3} \ 181 ${DESTDIR}/etc 182 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 aliases \ 183 ${DESTDIR}/etc/mail 184 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 crontab \ 185 ${DESTDIR}/var/cron/tabs/root 186 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 master.passwd \ 187 ${DESTDIR}/etc 188 pwd_mkdb -p ${TARGET_ENDIANNESS} -d ${DESTDIR}/ \ 189 ${DESTDIR}/etc/master.passwd 190 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 555 \ 191 MAKEDEV.local etc.${MACHINE}/MAKEDEV ${DESTDIR}/dev 192 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 minfree \ 193 ${DESTDIR}/var/crash 194 (cd root; \ 195 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.cshrc \ 196 ${DESTDIR}/root/.cshrc; \ 197 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 dot.klogin \ 198 ${DESTDIR}/root/.klogin; \ 199 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.login \ 200 ${DESTDIR}/root/.login; \ 201 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.profile \ 202 ${DESTDIR}/root/.profile; \ 203 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.shrc \ 204 ${DESTDIR}/root/.shrc; \ 205 rm -f ${DESTDIR}/.cshrc ${DESTDIR}/.profile; \ 206 ln ${DESTDIR}/root/.cshrc ${DESTDIR}/.cshrc; \ 207 ln ${DESTDIR}/root/.profile ${DESTDIR}/.profile) 208 (cd defaults; ${MAKE} install) 209 (cd mtree; ${MAKE} install) 210 (cd namedb; \ 211 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 \ 212 ${NAMEDB} ${DESTDIR}/etc/namedb) 213 (cd rc.d; ${MAKE} install) 214 /bin/rm -f ${DESTDIR}/etc/localtime 215 ln -s ${TZDIR}/${LOCALTIME} ${DESTDIR}/etc/localtime 216 /bin/rm -f ${DESTDIR}/etc/rmt 217 ln -s /usr/sbin/rmt ${DESTDIR}/etc/rmt 218 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g operator -m 664 /dev/null \ 219 ${DESTDIR}/etc/dumpdates 220 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g operator -m 600 /dev/null \ 221 ${DESTDIR}/etc/skeykeys 222 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 /dev/null \ 223 ${DESTDIR}/var/at/at.deny 224 ${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 /dev/null \ 225 ${DESTDIR}/var/cron/log 226 ${INSTALL} ${INSTPRIV} -c -o nobody -g ${BINGRP} -m 664 /dev/null \ 227 ${DESTDIR}/var/db/locate.database 228 ${INSTALL} ${INSTPRIV} -c -o uucp -g dialer -m 640 /dev/null \ 229 ${DESTDIR}/var/log/aculog 230 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \ 231 ${DESTDIR}/var/log/authlog 232 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \ 233 ${DESTDIR}/var/log/lastlog 234 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 640 /dev/null \ 235 ${DESTDIR}/var/log/lpd-errs 236 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \ 237 ${DESTDIR}/var/log/maillog 238 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \ 239 ${DESTDIR}/var/log/messages 240 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \ 241 ${DESTDIR}/var/log/secure 242 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \ 243 ${DESTDIR}/var/log/sendmail.st 244 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \ 245 ${DESTDIR}/var/log/wtmp 246 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \ 247 ${DESTDIR}/var/log/xferlog 248 ${INSTALL} ${INSTPRIV} -c -o daemon -g staff -m 664 /dev/null \ 249 ${DESTDIR}/var/msgs/bounds 250 ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \ 251 ${DESTDIR}/var/run/utmp 252 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 253 ${DESTDIR}/var/games/atc_scores 254 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 255 ${DESTDIR}/var/games/battlestar.log 256 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 257 ${DESTDIR}/var/games/cfscores 258 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 259 ${DESTDIR}/var/games/criblog 260 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 261 ${DESTDIR}/var/games/robots_roll 262 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 263 ${DESTDIR}/var/games/rogue.scores 264 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 265 ${DESTDIR}/var/games/saillog 266 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 267 ${DESTDIR}/var/games/snakerawscores 268 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 269 ${DESTDIR}/var/games/snake.log 270 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 271 ${DESTDIR}/var/games/tetris.scores 272 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 273 ${DESTDIR}/var/games/larn/llog12.0 274 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 275 ${DESTDIR}/var/games/larn/lscore12.0 276 ${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \ 277 ${DESTDIR}/var/games/larn/playerids 278 (cd etc.${MACHINE}; ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} \ 279 -g ${BINGRP} -m 444 fstab.* ${DESTDIR}/etc) 280 (cd ${DESTDIR}/dev; ./MAKEDEV all) 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.ifndef 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 294 cd ${DESTDIR}; rm -f sys; ln -s usr/src/sys sys 295 296.if !defined(RELEASEDIR) 297__warnreleasedir: .USE 298 @echo setenv RELEASEDIR before doing that! 299 @false 300release snapshot snap_pre snap_md_pre iso-image: __warnreleasedir 301.if !target(snap_md_post) 302snap_md_post: __warnreleasedir 303.endif 304.else 305release snapshot: distribution snap_pre snap_md_pre snap_kern snap_md_post 306 (cd ../distrib/sets; ${MAKE} sets) 307 sh ../distrib/sets/makesums -t ${RELEASEDIR}/binary/kernel '*.gz' 308 309# Standalone target to create a CDROM image after the release 310# was composed. Should be run after "make build" in both src and xsrc 311iso-image: iso-image_md_post 312 313iso-image_mi: iso-image_md_pre 314 @if ${MKISOFS} --version; then \ 315 mkdir -p ${RELEASEDIR}/installation/cdrom ; \ 316 ${MKISOFS} ${MKISOFS_FLAGS} \ 317 -o ${RELEASEDIR}/installation/cdrom/netbsd-${MACHINE}.iso \ 318 ${RELEASEDIR} ; \ 319 sh ../distrib/sets/makesums -t ${RELEASEDIR}/installation/cdrom '*.iso' ; \ 320 else \ 321 echo "install pkgsrc/sysutils/cdrecord and type 'make iso-image'." ; \ 322 fi 323 324# Setup the $RELEASEDIR to produce a bootable CD image: 325iso-image_md_pre: 326# nothing here -- look in the machine-dependent Makefile.inc 327 328# Fixup the CD-image to be bootable 329iso-image_md_post: iso-image_mi 330# nothing here -- look in the machine-dependent Makefile.inc 331 332snap_pre: 333# Could be a mount point, ignore the errors 334 -/bin/rm -rf ${RELEASEDIR} 335 ${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${RELEASEDIR} 336.for dir in ${INSTALLATION_DIRS} 337 ${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${RELEASEDIR}/${dir} 338.endfor 339 340 341# This target builds the GENERIC kernel (which must exist for all 342# ports) and puts it in binary/sets/kern.tgz, and also builds any 343# kernels specified in EXTRA_KERNELS. Since NetBSD's kernel build 344# system can create more than one kernel from a single configuration 345# we figure out how many there are, what they're named, and move them 346# to binary/kernel/${KERNEL}.${CONFIGFILE}.gz - most often KERNEL will 347# simply be "netbsd". If we don't find the "config" line, assume the 348# kernel will be "netbsd" (some config files are simple additions on 349# GENERIC, and just include it). 350# 351GETKERNELAWK= awk '/^config/ {print $$2; found=1} \ 352 END{ if (found == 0) print "netbsd"; }' 353# 354.if !target(snap_kern) 355snap_kern: 356.ifndef KERNELS_DONE 357.for configfile in GENERIC ${EXTRA_KERNELS} ${BUILD_KERNELS} 358 cd ${KERNCONFDIR} && ${CONFIG} \ 359 -b ${KERNOBJDIR}/${configfile} -s ${KERNSRCDIR} ${configfile} 360.ifndef UPDATE 361 cd ${KERNOBJDIR}/${configfile} && ${MAKE} distclean 362.endif 363 cd ${KERNOBJDIR}/${configfile} && ${MAKE} depend && ${MAKE} ${_J} 364.endfor # kernels 365 cd ${KERNOBJDIR}/GENERIC && \ 366 tar cf - `${GETKERNELAWK} ${KERNCONFDIR}/GENERIC` |\ 367 gzip -c -9 > ${RELEASEDIR}/binary/sets/kern.tgz 368.for configfile in GENERIC ${EXTRA_KERNELS} 369 cd ${KERNOBJDIR}/${configfile} && \ 370 for kernel in `${GETKERNELAWK} \ 371 ${KERNCONFDIR}/${configfile}` ; { \ 372 gzip -c -9 < $${kernel} > \ 373 ${RELEASEDIR}/binary/kernel/$${kernel}.${configfile}.gz ; } 374.endfor # EXTRA_KERNELS 375.endif # KERNELS_DONE 376.endif # no target(snap_kern) 377 378.endif # RELEASEDIR check 379 380snap_md_pre: 381# nothing here -- look in the machine-dependent Makefile.inc 382 383snap_md_post: 384# nothing here -- look in the machine-dependent Makefile.inc 385 386.endif # DESTDIR check 387 388.include <bsd.prog.mk> 389