Home | History | Annotate | Line # | Download | only in etc
Makefile revision 1.185
      1 #	$NetBSD: Makefile,v 1.185 2001/10/19 15:07:48 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 #   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 #	if DISTRIBUTION_DONE is set, it will not do anything.
     32 #    distrib-dirs: creates an empty NetBSD directory tree in DESTDIR.
     33 #	Called by distribution.
     34 #    snapshot: calls distribution, above, and then tars up the files
     35 #	into a release(7) format in RELEASEDIR. Any port-dependent
     36 #	stuff for this target is found in etc.${MACHINE}/Makefile.inc.
     37 #    release: a synonym for `snapshot'
     38 
     39 # do this before bsd.own.mk so we get correct KERNSRCDIR
     40 .include "../Makefile.inc"
     41 
     42 # For NO_SENDMAIL, INSTPRIV, MKCRYPTO
     43 .include <bsd.own.mk>
     44 
     45 TZDIR=		/usr/share/zoneinfo
     46 LOCALTIME?=	UTC
     47 
     48 # Flags for creating ISO CDROM image
     49 # mkisofs is expected to be in $PATH, install via pkgsrc/sysutils/cdrecord
     50 MKISOFS?=	mkisofs
     51 MKISOFS_FLAGS+= -J -l \
     52 		-r -T -v \
     53 		-P "The NetBSD Project" \
     54 		-m "${RELEASEDIR}/installation/cdrom"
     55 
     56 # setting NOOBJ prevents "make obj" from doing anything;
     57 # an objdir would break the installation stuff below
     58 MKOBJ=	no
     59 
     60 # MD Makefile.inc may append MD targets to BIN[123].  Make sure all
     61 # are empty, to preserve the old semantics of setting them below with "=".
     62 BIN1=	
     63 BIN2=
     64 BIN3=
     65 
     66 # Directories to build in ${RELEASEDIR}.   MD Makefile.inc files can
     67 # add to this.
     68 # NOTE: Parent directories must be listed before subdirectories.
     69 INSTALLATION_DIRS= \
     70 	binary binary/sets binary/kernel installation
     71 
     72 .if exists(etc.${MACHINE}/Makefile.inc)
     73 .include "etc.${MACHINE}/Makefile.inc"
     74 .endif
     75 
     76 # Use multiple jobs for kernel builds, if NBUILDJOBS set.
     77 # (Taken from src/Makefile.)
     78 .if defined(NBUILDJOBS)
     79 _J= -j${NBUILDJOBS}
     80 .endif
     81 
     82 # -rw-r--r--
     83 BINOWN= root
     84 BINGRP= wheel
     85 BIN1+=	bootptab changelist csh.cshrc csh.login csh.logout daily \
     86 	daily.conf dm.conf floppytab ftpchroot ftpusers ftpwelcome \
     87 	gettytab group hosts hosts.lpd inetd.conf lkm.conf \
     88 	mailer.conf man.conf monthly monthly.conf mrouted.conf \
     89 	netconfig networks newsyslog.conf nsswitch.conf ntp.conf \
     90 	phones printcap profile protocols rbootd.conf rc rc.conf \
     91 	rc.lkm rc.local rc.subr rc.shutdown remote rpc \
     92 	security security.conf services shells sysctl.conf syslog.conf \
     93 	weekly weekly.conf wscons.conf \
     94 	etc.${MACHINE}/ttys etc.${MACHINE}/disktab
     95 
     96 .if	(${MACHINE_ARCH} == "m68k") || \
     97 	(${MACHINE_ARCH} == "ns32k") || \
     98 	(${MACHINE_ARCH} == "vax") || \
     99 	(${MACHINE_ARCH} == "arm32")
    100 BIN1+=	ld.so.conf
    101 .elif exists(etc.${MACHINE_ARCH}/ld.so.conf)
    102 BIN1+=	etc.${MACHINE_ARCH}/ld.so.conf
    103 .endif
    104 
    105 .if exists(etc.${MACHINE_ARCH}/ttyaction)
    106 BIN1+=	etc.${MACHINE_ARCH}/ttyaction
    107 .endif
    108 
    109 # -rw-rw-r--
    110 BIN2+=	motd
    111 
    112 # -rw-------
    113 BIN3+=	hosts.equiv
    114 
    115 NAMEDB=	127 root.cache named.conf localhost loopback.v6
    116 PCS=	pcs750.bin
    117 
    118 # find out endianness of target and set proper flag for pwd_mkdb so that
    119 # it creates database in same endianness
    120 .if exists(${DESTDIR}/usr/include/machine/endian_machdep.h)
    121 TARGET_ENDIANNESS!= \
    122 	( echo "\#include <machine/endian_machdep.h>" ; echo _BYTE_ORDER ) | \
    123 	${CC} -I${DESTDIR}/usr/include -E - | tail -1 | awk '{print $$1}'
    124 .else
    125 TARGET_ENDIANNESS=
    126 .endif
    127 
    128 .if ${TARGET_ENDIANNESS} == "_LITTLE_ENDIAN"
    129 TARGET_ENDIANNESS= -L
    130 .elif ${TARGET_ENDIANNESS} == "_BIG_ENDIAN"
    131 TARGET_ENDIANNESS= -B
    132 .else
    133 # XXX sh3 should be split into sh3eb and sh3el
    134 TARGET_ENDIANNESS=
    135 .endif
    136 
    137 all clean cleandir depend distclean etc includes install lint:
    138 
    139 
    140 .include <bsd.kernobj.mk>
    141 
    142 obj:
    143 	mkdir -p ${KERNOBJDIR}
    144 
    145 .ifndef DESTDIR
    146 __warndestdir: .USE
    147 	@echo setenv DESTDIR before doing that!
    148 	@false
    149 distribution distrib-dirs release snapshot snap_pre snap_md_pre \
    150 iso-image: __warndestdir
    151 .if !target(snap_md_post)
    152 snap_md_post: __warndestdir
    153 .endif
    154 .else
    155 distribution: distrib-dirs
    156 .if !defined(DISTRIBUTION_DONE)
    157 .if !defined(INSTALL_DONE)
    158 	(cd ..; ${MAKE} _DISTRIB= includes)
    159 	(cd ..; ${MAKE} _DISTRIB= install)
    160 .endif
    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 	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 555 \
    176 	     MAKEDEV.local etc.${MACHINE}/MAKEDEV ${DESTDIR}/dev
    177 	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 minfree \
    178 	    ${DESTDIR}/var/crash
    179 	(cd root; \
    180 		${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.cshrc \
    181 		    ${DESTDIR}/root/.cshrc; \
    182 		${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 dot.klogin \
    183 		    ${DESTDIR}/root/.klogin; \
    184 		${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.login \
    185 		    ${DESTDIR}/root/.login; \
    186 		${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.profile \
    187 		    ${DESTDIR}/root/.profile; \
    188 		${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 644 dot.shrc \
    189 		    ${DESTDIR}/root/.shrc; \
    190 		rm -f ${DESTDIR}/.cshrc ${DESTDIR}/.profile; \
    191 		ln ${DESTDIR}/root/.cshrc ${DESTDIR}/.cshrc; \
    192 		ln ${DESTDIR}/root/.profile ${DESTDIR}/.profile)
    193 	(cd defaults; ${MAKE} install)
    194 	(cd mtree; ${MAKE} install)
    195 	(cd namedb; \
    196 		${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 \
    197 		    ${NAMEDB} ${DESTDIR}/etc/namedb)
    198 	(cd rc.d; ${MAKE} install)
    199 	/bin/rm -f ${DESTDIR}/etc/localtime
    200 	ln -s ${TZDIR}/${LOCALTIME} ${DESTDIR}/etc/localtime
    201 	/bin/rm -f ${DESTDIR}/etc/rmt
    202 	ln -s /usr/sbin/rmt ${DESTDIR}/etc/rmt
    203 	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g operator -m 664 /dev/null \
    204 		${DESTDIR}/etc/dumpdates
    205 	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g operator -m 600 /dev/null \
    206 		${DESTDIR}/etc/skeykeys
    207 	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 /dev/null \
    208 		${DESTDIR}/var/at/at.deny
    209 	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 /dev/null \
    210 		${DESTDIR}/var/cron/log
    211 	${INSTALL} ${INSTPRIV} -c -o nobody -g ${BINGRP} -m 664 /dev/null \
    212 		${DESTDIR}/var/db/locate.database
    213 	${INSTALL} ${INSTPRIV} -c -o uucp -g dialer -m 640 /dev/null \
    214 		${DESTDIR}/var/log/aculog
    215 	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
    216 		${DESTDIR}/var/log/authlog
    217 	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \
    218 		${DESTDIR}/var/log/lastlog
    219 	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 640 /dev/null \
    220 		${DESTDIR}/var/log/lpd-errs
    221 	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
    222 		${DESTDIR}/var/log/maillog
    223 	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
    224 		${DESTDIR}/var/log/messages
    225 	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
    226 		${DESTDIR}/var/log/secure
    227 	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
    228 		${DESTDIR}/var/log/sendmail.st
    229 	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
    230 		${DESTDIR}/var/log/wtmp
    231 	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 600 /dev/null \
    232 		${DESTDIR}/var/log/xferlog
    233 	${INSTALL} ${INSTPRIV} -c -o daemon -g staff -m 664 /dev/null \
    234 		${DESTDIR}/var/msgs/bounds
    235 	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \
    236 		${DESTDIR}/var/run/utmp
    237 	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
    238 		${DESTDIR}/var/games/atc_scores
    239 	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
    240 		${DESTDIR}/var/games/battlestar.log
    241 	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
    242 		${DESTDIR}/var/games/cfscores
    243 	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
    244 		${DESTDIR}/var/games/criblog
    245 	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
    246 		${DESTDIR}/var/games/robots_roll
    247 	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
    248 		${DESTDIR}/var/games/rogue.scores
    249 	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
    250 		${DESTDIR}/var/games/saillog
    251 	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
    252 		${DESTDIR}/var/games/snakerawscores
    253 	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
    254 		${DESTDIR}/var/games/snake.log
    255 	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
    256 		${DESTDIR}/var/games/tetris.scores
    257 	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
    258 		${DESTDIR}/var/games/larn/llog12.0
    259 	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
    260 		${DESTDIR}/var/games/larn/lscore12.0
    261 	${INSTALL} ${INSTPRIV} -c -o games -g games -m 664 /dev/null \
    262 		${DESTDIR}/var/games/larn/playerids
    263 	(cd etc.${MACHINE}; ${INSTALL} ${INSTPRIV} -c -o ${BINOWN} \
    264 	    -g ${BINGRP} -m 444 fstab.* ${DESTDIR}/etc)
    265 	(cd skel; ${MAKE} distribution)
    266 	(cd ../usr.bin/mail; ${MAKE} distribution)
    267 	(cd ../gnu/usr.sbin/postfix/; ${MAKE} distribution)
    268 .if (${MKCRYPTO} != "no")
    269 	(cd ../usr.bin/ssh; ${MAKE} distribution)
    270 .endif
    271 .ifndef NO_SENDMAIL
    272 	(cd ../gnu/usr.sbin/sendmail/cf/cf; ${MAKE} distribution)
    273 .endif
    274 .endif
    275 
    276 distrib-dirs:
    277 	${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${DESTDIR}
    278 	${MTREE} -def mtree/NetBSD.dist -p ${DESTDIR}/ -U
    279 	cd ${DESTDIR}/; rm -f sys; ln -s usr/src/sys sys
    280 
    281 .if !defined(RELEASEDIR)
    282 __warnreleasedir: .USE
    283 	@echo setenv RELEASEDIR before doing that!
    284 	@false
    285 release snapshot snap_pre snap_md_pre iso-image: __warnreleasedir
    286 .if !target(snap_md_post)
    287 snap_md_post: __warnreleasedir
    288 .endif
    289 .else
    290 release snapshot: distribution snap_pre snap_md_pre snap_kern snap_md_post
    291 	(cd ../distrib/sets; ${MAKE} sets)
    292 	sh ../distrib/sets/makesums -t ${RELEASEDIR}/binary/kernel '*.gz'
    293 
    294 # Standalone target to create a CDROM image after the release
    295 # was composed. Should be run after "make build" in both src and xsrc
    296 iso-image: iso-image_md_post
    297 
    298 iso-image_mi: iso-image_md_pre
    299 	@if ${MKISOFS} --version; then \
    300 		mkdir -p ${RELEASEDIR}/installation/cdrom ; \
    301 		${MKISOFS} ${MKISOFS_FLAGS} \
    302 			-o ${RELEASEDIR}/installation/cdrom/netbsd-${MACHINE}.iso \
    303 			${RELEASEDIR} ; \
    304 		sh ../distrib/sets/makesums -t ${RELEASEDIR}/installation/cdrom '*.iso' ; \
    305 	else \
    306 		echo "install pkgsrc/sysutils/cdrecord and type 'make iso-image'." ; \
    307 	fi
    308 
    309 # Setup the $RELEASEDIR to produce a bootable CD image:
    310 iso-image_md_pre:
    311 # nothing here -- look in the machine-dependent Makefile.inc
    312 
    313 # Fixup the  CD-image to be bootable
    314 iso-image_md_post: iso-image_mi
    315 # nothing here -- look in the machine-dependent Makefile.inc
    316 
    317 snap_pre:
    318 # Could be a mount point, ignore the errors
    319 	-/bin/rm -rf ${RELEASEDIR}
    320 	${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${RELEASEDIR}
    321 .for dir in ${INSTALLATION_DIRS}
    322 	${INSTALL} ${INSTPRIV} -d -o root -g wheel -m 755 ${RELEASEDIR}/${dir}
    323 .endfor
    324 
    325 
    326 # This target builds the GENERIC kernel (which must exist for all
    327 # ports) and puts it in binary/sets/kern.tgz, and also builds any
    328 # kernels specified in EXTRA_KERNELS. Since NetBSD's kernel build
    329 # system can create more than one kernel from a single configuration
    330 # we figure out how many there are, what they're named, and move them
    331 # to binary/kernel/${KERNEL}.${CONFIGFILE}.gz - most often KERNEL will
    332 # simply be "netbsd". If we don't find the "config" line, assume the
    333 # kernel will be "netbsd" (some config files are simple additions on
    334 # GENERIC, and just include it).
    335 #
    336 GETKERNELAWK=	awk '/^config/ {print $$2; found=1} \
    337 		END{ if (found == 0) print "netbsd"; }'
    338 #
    339 .if !target(snap_kern)
    340 snap_kern:
    341 .ifndef KERNELS_DONE
    342 .for configfile in GENERIC ${EXTRA_KERNELS} ${BUILD_KERNELS}
    343 	cd ${KERNCONFDIR} && ${CONFIG} \
    344 		-b ${KERNOBJDIR}/${configfile:C/.*\///} -s ${KERNSRCDIR} ${configfile}
    345 .ifndef UPDATE
    346 	cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} distclean 
    347 .endif
    348 	cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} depend && ${MAKE} ${_J}
    349 .endfor # kernels
    350 	cd ${KERNOBJDIR}/GENERIC &&	\
    351 		tar cf - `${GETKERNELAWK} ${KERNCONFDIR}/GENERIC` |\
    352 		gzip -c -9 > ${RELEASEDIR}/binary/sets/kern.tgz
    353 .for configfile in GENERIC ${EXTRA_KERNELS}
    354 	cd ${KERNOBJDIR}/${configfile:C/.*\///} &&	\
    355 		for kernel in `${GETKERNELAWK} \
    356 			${KERNCONFDIR}/${configfile:C/.*\///}` ; do   \
    357 		gzip -c -9 < $${kernel} > \
    358 			${RELEASEDIR}/binary/kernel/$${kernel}.${configfile:C/.*\///}.gz ; done
    359 .endfor # EXTRA_KERNELS
    360 .endif # KERNELS_DONE
    361 .endif # no target(snap_kern)
    362 
    363 .endif # RELEASEDIR check
    364 
    365 snap_md_pre:
    366 # nothing here -- look in the machine-dependent Makefile.inc
    367 
    368 snap_md_post:
    369 # nothing here -- look in the machine-dependent Makefile.inc
    370 
    371 .endif	# DESTDIR check
    372 
    373 .include <bsd.prog.mk>
    374