Home | History | Annotate | Line # | Download | only in etc
Makefile revision 1.229
      1 #	$NetBSD: Makefile,v 1.229 2002/10/16 02:30:48 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
     36 NOOBJ=		# defined
     37 
     38 # For NO_SENDMAIL, INSTPRIV, MKCRYPTO
     39 .include <bsd.own.mk>
     40 
     41 # For KERNSRCDIR, KERNOBJDIR, ...
     42 .include <bsd.kernobj.mk>
     43 
     44 
     45 .MAKEOVERRIDES+=	USETOOLS
     46 
     47 TZDIR=		/usr/share/zoneinfo
     48 LOCALTIME?=	UTC
     49 PWD_MKDB?=	pwd_mkdb
     50 MAKESUMS=	CKSUM=${CKSUM:Q} sh ../distrib/sets/makesums
     51 
     52 # Flags for creating ISO CDROM image
     53 # mkisofs is expected to be in $PATH, install via pkgsrc/sysutils/cdrecord
     54 MKISOFS?=	mkisofs
     55 DISTRIBREV!=	sh ${NETBSDSRCDIR}/sys/conf/osrelease.sh -s
     56 # ISO 9660 volume ID.  Note that this can only contain [A-Z0-9_].
     57 ISO_VOLID!=	echo NETBSD_${MACHINE}_${DISTRIBREV} | tr a-z A-Z
     58 MKISOFS_FLAGS+= -J -l \
     59 		-r -T -v \
     60 		-V ${ISO_VOLID} \
     61 		-P "The NetBSD Project" \
     62 		-m "${RELEASEDIR}/installation/cdrom"
     63 
     64 # MD Makefile.inc may append MD targets to BIN[123].  Make sure all
     65 # are empty, to preserve the old semantics of setting them below with "=".
     66 BIN1=
     67 BIN2=
     68 BIN3=
     69 
     70 # Directories to build in ${RELEASEDIR}.   MD Makefile.inc files can
     71 # add to this.
     72 # NOTE: Parent directories must be listed before subdirectories.
     73 INSTALLATION_DIRS=	binary binary/sets binary/kernel installation
     74 
     75 .if exists(etc.${MACHINE}/Makefile.inc)
     76 .include "etc.${MACHINE}/Makefile.inc"
     77 .endif
     78 
     79 # -rw-r--r--
     80 BINOWN= root
     81 BINGRP= wheel
     82 UTMPGRP= utmp
     83 BIN1+=	bootptab changelist csh.cshrc csh.login csh.logout daily \
     84 	daily.conf dm.conf floppytab ftpchroot ftpusers \
     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 	passwd.conf 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 BIN1+=	ld.so.conf
     98 .elif exists(etc.${MACHINE_ARCH}/ld.so.conf)
     99 BIN1+=	etc.${MACHINE_ARCH}/ld.so.conf
    100 .endif
    101 
    102 .if exists(etc.${MACHINE_ARCH}/ttyaction)
    103 BIN1+=	etc.${MACHINE_ARCH}/ttyaction
    104 .endif
    105 
    106 # -rw-rw-r--
    107 BIN2+=	motd
    108 
    109 # -rw-------
    110 BIN3+=	hosts.equiv
    111 
    112 NAMEDB=	127 root.cache named.conf localhost loopback.v6
    113 
    114 .if make(install-etc-files)						# {
    115 .include <bsd.endian.mk>
    116 .if ${TARGET_ENDIANNESS} == "1234"
    117 TARGET_ENDIANNESS=	-L
    118 .elif ${TARGET_ENDIANNESS} == "4321"
    119 TARGET_ENDIANNESS=	-B
    120 .else
    121 TARGET_ENDIANNESS=
    122 .endif
    123 .endif	# install-etc-files						# }
    124 
    125 obj:
    126 	mkdir -p ${KERNOBJDIR}
    127 
    128 distribution: check_DESTDIR .WAIT distrib-dirs
    129 .if !defined(DISTRIBUTION_DONE)
    130 .if !defined(INSTALL_DONE)
    131 	(cd ..; ${MAKE} _DISTRIB= includes)
    132 	(cd ..; ${MAKE} _DISTRIB= install)
    133 .endif	# !INSTALL_DONE
    134 	${MAKE} install-etc-files
    135 .endif	# !DISTRIBUTION_DONE
    136 
    137 install-etc-files: check_DESTDIR
    138 	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 ${BIN1} ${DESTDIR}/etc
    139 	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 664 ${BIN2} ${DESTDIR}/etc
    140 	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 ${BIN3} ${DESTDIR}/etc
    141 	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 aliases \
    142 	    ${DESTDIR}/etc/mail
    143 	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
    144 	    ${DESTDIR}/etc/mail/local-host-names
    145 	${INSTALL_FILE} -o root -g wheel -m 600 crontab \
    146 	    ${DESTDIR}/var/cron/tabs/root
    147 	${INSTALL_FILE} -o root -g wheel -m 600 master.passwd ${DESTDIR}/etc
    148 	${PWD_MKDB} -p ${TARGET_ENDIANNESS} -d ${DESTDIR}/ \
    149 		${DESTDIR}/etc/master.passwd
    150 .if defined(UNPRIVED)
    151 	( \
    152 	    echo "/etc/passwd type=file mode=0644 uname=root gname=wheel"; \
    153 	    echo "/etc/pwd.db type=file mode=0644 uname=root gname=wheel"; \
    154 	    echo "/etc/spwd.db type=file mode=0600 uname=root gname=wheel"; \
    155 	) | \
    156 	    sed -e "s|^/|./${DESTDIR}/|g" -e "s|//|/|g" | ${CAT} -l >>${METALOG}
    157 .endif	# UNPRIVED
    158 	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 555 \
    159 	     MAKEDEV.local etc.${MACHINE}/MAKEDEV ${DESTDIR}/dev
    160 	${INSTALL_FILE} -o root -g wheel -m 600 minfree ${DESTDIR}/var/crash
    161 	(cd root; \
    162 		${INSTALL_FILE} -o root -g wheel -m 644 dot.cshrc \
    163 		    ${DESTDIR}/root/.cshrc; \
    164 		${INSTALL_FILE} -o root -g wheel -m 600 dot.klogin \
    165 		    ${DESTDIR}/root/.klogin; \
    166 		${INSTALL_FILE} -o root -g wheel -m 644 dot.login \
    167 		    ${DESTDIR}/root/.login; \
    168 		${INSTALL_FILE} -o root -g wheel -m 644 dot.profile \
    169 		    ${DESTDIR}/root/.profile; \
    170 		${INSTALL_FILE} -o root -g wheel -m 644 dot.shrc \
    171 		    ${DESTDIR}/root/.shrc; \
    172 		rm -f ${DESTDIR}/.cshrc ${DESTDIR}/.profile; \
    173 		${INSTALL_LINK} ${DESTDIR}/root/.cshrc ${DESTDIR}/.cshrc; \
    174 		${INSTALL_LINK} ${DESTDIR}/root/.profile ${DESTDIR}/.profile)
    175 	(cd defaults; ${MAKE} install)
    176 	(cd mtree; ${MAKE} install)
    177 	(cd namedb; \
    178 		${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \
    179 		    ${NAMEDB} ${DESTDIR}/etc/namedb)
    180 	(cd rc.d; ${MAKE} install)
    181 	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
    182 		postinstall ${DESTDIR}/etc
    183 	${INSTALL_SYMLINK} -o root -g wheel -m 755 \
    184 		${TZDIR}/${LOCALTIME} ${DESTDIR}/etc/localtime
    185 	${INSTALL_SYMLINK} -o root -g wheel -m 755 \
    186 		/usr/sbin/rmt ${DESTDIR}/etc/rmt
    187 	${INSTALL_FILE} -o ${BINOWN} -g operator -m 664 /dev/null \
    188 		${DESTDIR}/etc/dumpdates
    189 	${INSTALL_FILE} -o ${BINOWN} -g operator -m 600 /dev/null \
    190 		${DESTDIR}/etc/skeykeys
    191 	${INSTALL_FILE} -o root -g wheel -m 600 /dev/null \
    192 		${DESTDIR}/var/at/at.deny
    193 	${INSTALL_FILE} -o root -g wheel -m 600 /dev/null \
    194 		${DESTDIR}/var/cron/log
    195 	${INSTALL_FILE} -o nobody -g ${BINGRP} -m 664 /dev/null \
    196 		${DESTDIR}/var/db/locate.database
    197 	${INSTALL_FILE} -o uucp -g dialer -m 640 /dev/null \
    198 		${DESTDIR}/var/log/aculog
    199 	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
    200 		${DESTDIR}/var/log/authlog
    201 	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \
    202 		${DESTDIR}/var/log/lastlog
    203 	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 640 /dev/null \
    204 		${DESTDIR}/var/log/lpd-errs
    205 	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
    206 		${DESTDIR}/var/log/maillog
    207 	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
    208 		${DESTDIR}/var/log/messages
    209 	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
    210 		${DESTDIR}/var/log/secure
    211 	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
    212 		${DESTDIR}/var/log/sendmail.st
    213 	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
    214 		${DESTDIR}/var/log/wtmp
    215 	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
    216 		${DESTDIR}/var/log/wtmpx
    217 	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
    218 		${DESTDIR}/var/log/xferlog
    219 	${INSTALL_FILE} -o daemon -g staff -m 664 /dev/null \
    220 		${DESTDIR}/var/msgs/bounds
    221 	${INSTALL_FILE} -o ${BINOWN} -g ${UTMPGRP} -m 664 /dev/null \
    222 		${DESTDIR}/var/run/utmp
    223 	${INSTALL_FILE} -o ${BINOWN} -g ${UTMPGRP} -m 664 /dev/null \
    224 		${DESTDIR}/var/run/utmpx
    225 	${INSTALL_FILE} -o games -g games -m 664 /dev/null \
    226 		${DESTDIR}/var/games/atc_scores
    227 	${INSTALL_FILE} -o games -g games -m 664 /dev/null \
    228 		${DESTDIR}/var/games/battlestar.log
    229 	${INSTALL_FILE} -o games -g games -m 664 /dev/null \
    230 		${DESTDIR}/var/games/cfscores
    231 	${INSTALL_FILE} -o games -g games -m 664 /dev/null \
    232 		${DESTDIR}/var/games/criblog
    233 	${INSTALL_FILE} -o games -g games -m 664 /dev/null \
    234 		${DESTDIR}/var/games/robots_roll
    235 	${INSTALL_FILE} -o games -g games -m 664 /dev/null \
    236 		${DESTDIR}/var/games/rogue.scores
    237 	${INSTALL_FILE} -o games -g games -m 664 /dev/null \
    238 		${DESTDIR}/var/games/saillog
    239 	${INSTALL_FILE} -o games -g games -m 664 /dev/null \
    240 		${DESTDIR}/var/games/snakerawscores
    241 	${INSTALL_FILE} -o games -g games -m 664 /dev/null \
    242 		${DESTDIR}/var/games/snake.log
    243 	${INSTALL_FILE} -o games -g games -m 664 /dev/null \
    244 		${DESTDIR}/var/games/tetris.scores
    245 	${INSTALL_FILE} -o games -g games -m 664 /dev/null \
    246 		${DESTDIR}/var/games/larn/llog12.0
    247 	${INSTALL_FILE} -o games -g games -m 664 /dev/null \
    248 		${DESTDIR}/var/games/larn/lscore12.0
    249 	${INSTALL_FILE} -o games -g games -m 664 /dev/null \
    250 		${DESTDIR}/var/games/larn/playerids
    251 	(cd skel; ${MAKE} distribution)
    252 	(cd ../usr.bin/mail; ${MAKE} distribution)
    253 	(cd ../gnu/usr.sbin/postfix/; ${MAKE} distribution)
    254 .if (${MKCRYPTO} != "no")
    255 	(cd ../usr.bin/ssh; ${MAKE} distribution)
    256 .endif
    257 .if !defined(NO_SENDMAIL)
    258 	(cd ../gnu/usr.sbin/sendmail/cf/cf; ${MAKE} distribution)
    259 .endif
    260 
    261 distrib-dirs: check_DESTDIR
    262 	${INSTALL_DIR} -o root -g wheel -m 755 ${DESTDIR}
    263 	${MTREE} -def mtree/NetBSD.dist -p ${DESTDIR}/ -U ${UNPRIVED:D-W}
    264 	rm -f ${DESTDIR}/sys
    265 	${INSTALL_SYMLINK} -o root -g wheel -m 755 usr/src/sys ${DESTDIR}/sys
    266 
    267 release snapshot: check_DESTDIR check_RELEASEDIR .WAIT \
    268     distribution .WAIT snap_pre snap_md_pre .WAIT snap_kern .WAIT snap_md_post
    269 	(cd ../distrib/sets; ${MAKE} sets)
    270 	${MAKESUMS} -t ${RELEASEDIR}/binary/kernel '*.gz'
    271 
    272 # Standalone target to create a CDROM image after the release
    273 # was composed. Should be run after "make build" in both src and xsrc
    274 iso-image: check_DESTDIR check_RELEASEDIR .WAIT iso-image_md_post
    275 
    276 iso-image_mi: check_DESTDIR check_RELEASEDIR .WAIT iso-image_md_pre
    277 	@if ${MKISOFS} --version; then \
    278 		mkdir -p ${RELEASEDIR}/installation/cdrom ; \
    279 		${MKISOFS} ${MKISOFS_FLAGS} \
    280 			-o ${RELEASEDIR}/installation/cdrom/netbsd-${MACHINE}.iso \
    281 			${RELEASEDIR} ; \
    282 		${MAKESUMS} -t ${RELEASEDIR}/installation/cdrom '*.iso' ; \
    283 	else \
    284 		echo "install pkgsrc/sysutils/cdrecord and type 'make iso-image'." ; \
    285 	fi
    286 
    287 # Setup the $RELEASEDIR to produce a bootable CD image:
    288 iso-image_md_pre: check_DESTDIR check_RELEASEDIR
    289 # nothing here -- look in the machine-dependent Makefile.inc
    290 
    291 # Fixup the  CD-image to be bootable
    292 iso-image_md_post: check_DESTDIR check_RELEASEDIR .WAIT iso-image_mi
    293 # nothing here -- look in the machine-dependent Makefile.inc
    294 
    295 snap_pre: check_DESTDIR check_RELEASEDIR
    296 # Could be a mount point, ignore the errors
    297 	-/bin/rm -rf ${RELEASEDIR}
    298 	${INSTALL} -d -m 755 ${RELEASEDIR}
    299 .for dir in ${INSTALLATION_DIRS}
    300 	${INSTALL} -d -m 755 ${RELEASEDIR}/${dir}
    301 .endfor
    302 
    303 # This target builds the kernels specified by each port.  A port may
    304 # specify the following kernels:
    305 #
    306 #	KERNEL_SETS		The list of kernels that will be
    307 #				packaged into sets, named
    308 #				kern-${kernel}.tgz.  These kernels
    309 #				are also placed in the binary/kernel
    310 #				area of the release package as
    311 #				netbsd-${kernel}.gz.
    312 #
    313 #	EXTRA_KERNELS		Additional kernels to place in the
    314 #				binary/kernel area of the release
    315 #				package as netbsd-${kernel}.gz, but
    316 #				which are not placed into sets. This
    317 #				allows a port to provide e.g. a netbootable
    318 #				installation kernel containing a ramdisk.
    319 #
    320 #	BUILD_KERNELS		Additional kernels to build which are
    321 #				not placed into sets nor into the
    322 #				binary/kernel area of the release
    323 #				package.  These are typically kernels
    324 #				that are built for inclusion only in
    325 #				installation disk/CD-ROM/tape images.
    326 #
    327 # A port may also specify KERNEL_SUFFIXES, which is an optional list
    328 # of filename suffixes for kernels to include in the kernel sets and
    329 # in the binary/kernel area of the release package (e.g. "netbsd" vs.
    330 # "netbsd.ecoff" and "netbsd.srec").  It is not an error if kernels
    331 # with these suffixes do not exist in the kernel build directory.
    332 #
    333 #
    334 # A list of all the kernels to build, which can be overridden from
    335 # external sources (such as make(1)'s environment or command line)
    336 #
    337 ALL_KERNELS?=	${KERNEL_SETS} ${EXTRA_KERNELS} ${BUILD_KERNELS}
    338 #
    339 GETKERNELAWK=	awk '/^config/ {print $$2; found=1} \
    340 		END{ if (found == 0) print "netbsd"; }'
    341 #
    342 .if !target(snap_kern)
    343 snap_kern: check_DESTDIR check_RELEASEDIR
    344 .if !defined(KERNELS_DONE)						# {
    345 .for configfile in ${ALL_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}
    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 "/set uname=${BINOWN} gname=${BINGRP}"; \
    360 		echo ". type=dir optional"; \
    361 		for kernel in $${kernlist}; do \
    362 			echo "./$${kernel} type=file"; \
    363 			for s in $${kernsuffixes}; do \
    364 				if [ -f $${kernel}.$${s} ]; then \
    365 					echo "./$${kernel}.$${s} type=file"; \
    366 				fi; \
    367 			done; \
    368 		done ) | GZIP=-9 ${PAX} -zw \
    369 		    -M ${UNPRIVED:D-N${NETBSDSRCDIR}/etc} \
    370 		    -f ${RELEASEDIR}/binary/sets/kern-${configfile}.tgz
    371 .endfor # make kernel sets
    372 .for configfile in ${KERNEL_SETS} ${EXTRA_KERNELS}
    373 	kernlist=`${GETKERNELAWK} ${KERNCONFDIR}/${configfile:C/.*\///}`; \
    374 	kerndir=${KERNOBJDIR}/${configfile:C/.*\///}; \
    375 	kernsuffixes="${KERNEL_SUFFIXES}"; \
    376 	cd $${kerndir} &&	\
    377 		gziplist=`for kernel in $${kernlist}; do \
    378 			echo "$${kernel}"; \
    379 			for s in $${kernsuffixes}; do \
    380 				if [ -f $${kernel}.$${s} ]; then \
    381 					echo "$${kernel}.$${s}"; \
    382 				fi; \
    383 			done; \
    384 		done`; \
    385 		for kernel in $${gziplist} ; do \
    386 		gzip -c -9 < $${kernel} > \
    387 		    ${RELEASEDIR}/binary/kernel/$${kernel}-${configfile:C/.*\///}.gz ; done
    388 .endfor # place KERNEL_SETS kernels + EXTRA_KERNELS in binary/kernel/...
    389 .endif # no target(snap_kern)
    390 
    391 snap_md_pre: check_DESTDIR check_RELEASEDIR
    392 # nothing here -- look in the machine-dependent Makefile.inc
    393 
    394 snap_md_post: check_DESTDIR check_RELEASEDIR
    395 # nothing here -- look in the machine-dependent Makefile.inc
    396 
    397 .include <bsd.prog.mk>
    398