Makefile revision 1.9
1#	$NetBSD: Makefile,v 1.9 2002/04/06 18:16:12 tsutsui Exp $
2
3TOP=		${.CURDIR}/..
4
5# This include just sets DISTRIBREV=XX
6.include "${TOP}/Makefile.inc"
7.include <bsd.own.mk>
8
9DBG=	-Os
10
11IMAGE=	ramdisk
12CBIN=	rd_bin
13
14TREE=	${TOP}/common/${IMAGE}.tree
15
16LISTS=	${TOP}/common/${CBIN}.list \
17	${TOP}/common/${IMAGE}.list
18
19KERNEL  = ${KERNOBJDIR}/RAMDISK/netbsd
20
21MOUNT_POINT?=	/mnt
22VND?=		vnd1
23VND_DEV?=	/dev/${VND}a
24VND_RDEV?=	/dev/r${VND}a
25
26# These are all the parameters for the root fs:
27DISKTYPE=	rdroot
28SIZE=		400k
29# bigendian, minfree, opt, b/i , cpg
30NEWFSARGS= -B be -m 0 -o space -i 4096 -c 20
31MDSETIMAGE?=	mdsetimage
32MTREE?=		mtree
33
34KERNELS= netbsd.RAMDISK 
35CLEANFILES= $(KERNELS) ${IMAGE}.fs netbsd-tmp
36
37all: $(KERNELS)
38
39netbsd.RAMDISK : ${IMAGE}.fs
40	cp ${KERNEL} netbsd-tmp
41	${MDSETIMAGE} -v netbsd-tmp ${IMAGE}.fs
42	-mv -f netbsd-tmp $@
43
44${IMAGE}.fs: ${TREE} ${LISTS} ${CBIN}
45	dd if=/dev/zero of=${IMAGE}.fs bs=${SIZE} count=1
46	vnconfig -f ${DESTDIR}/etc/disktab -t ${DISKTYPE} -v \
47	  -c ${VND} ${IMAGE}.fs
48	disklabel -rw -f ${DESTDIR}/etc/disktab ${VND} ${DISKTYPE}
49	newfs ${NEWFSARGS} ${VND_RDEV}
50	mount ${VND_DEV} ${MOUNT_POINT}
51	${MTREE} -def ${TREE} -p ${MOUNT_POINT}/ -u
52	TOPDIR=${TOP} CURDIR=${.CURDIR} DESTDIR=${DESTDIR} \
53	  OBJDIR=${.OBJDIR} TARGDIR=${MOUNT_POINT} \
54	  sh ${TOP}/common/RunList.sh ${LISTS}
55	sync
56	@echo ""
57	@df -i ${MOUNT_POINT}
58	@echo ""
59	umount ${MOUNT_POINT}
60	dd if=${VND_DEV} of=${IMAGE}-tmp.fs bs=${SIZE} count=1
61	vnconfig -u ${VND}
62	mv ${IMAGE}-tmp.fs ${IMAGE}.fs
63
64unconfig:
65	-umount -f ${MOUNT_POINT}
66	-vnconfig -u ${VND}
67	-/bin/rm -f ${IMAGE}.fs
68
69# Do not delete this if I change my mind and kill make...
70.PRECIOUS: ${IMAGE}.fs
71
72# Rules for making ${CBIN} ...
73.include "${TOP}/common/Make.crunch"
74
75
76# Use stubs to eliminate some large stuff from libc
77HACKSRC=	${DISTRIBDIR}/utils/libhack
78HACKOBJS=	gethost.o
79.include	"${HACKSRC}/Makefile.inc"
80${CBIN}:	libhack.o
81CPPFLAGS+=-I${DESTDIR}/usr/include
82
83clean cleandir distclean:
84	-rm -f a.out core *.core *.o *.cro *.c
85	-rm -f ${CLEANFILES}
86
87.if !defined(RELEASEDIR)
88release:
89	@echo setenv RELEASEDIR before doing that!
90	@false
91.else	# RELEASEDIR
92release: $(KERNELS)
93.for x in ${KERNELS}
94	gzip -c -9 < ${x} > \
95	 ${RELEASEDIR}/binary/kernel/${x}.gz
96.endfor # KERNELS
97.endif	# RELEASEDIR
98
99# Standard rules needed by the above...
100.include <bsd.obj.mk>
101.include <bsd.sys.mk>
102.include <bsd.subdir.mk>
103