Makefile revision 1.7
1#	$NetBSD: Makefile,v 1.7 2002/03/26 23:09:40 fredette Exp $
2
3TOP=		${.CURDIR}/..
4
5# This include just sets DISTRIBREV=XX
6.include "${TOP}/Makefile.inc"
7.include <bsd.own.mk>
8
9IMAGE=	ramdisk
10CBIN=	rd_bin
11
12TREE=	${TOP}/common/${IMAGE}.tree
13
14LISTS=	${TOP}/common/${CBIN}.list \
15	${TOP}/common/${IMAGE}.list
16
17KERNEL  = ${KERNOBJDIR}/RAMDISK/netbsd
18
19MOUNT_POINT?=	/mnt
20VND?=		vnd1
21VND_DEV?=	/dev/${VND}a
22VND_RDEV?=	/dev/r${VND}a
23
24# These are all the parameters for the root fs:
25DISKTYPE=	rdroot
26SIZE=		400k
27# bigendian, minfree, opt, b/i , cpg
28NEWFSARGS= -B be -m 0 -o space -i 4096 -c 20
29MDSETIMAGE?=	mdsetimage
30MTREE?=		mtree
31
32KERNELS= netbsd.RAMDISK 
33CLEANFILES= $(KERNELS) ${IMAGE}.fs netbsd-tmp
34
35all: $(KERNELS)
36
37netbsd.RAMDISK : ${IMAGE}.fs
38	cp ${KERNEL} netbsd-tmp
39	${MDSETIMAGE} -v netbsd-tmp ${IMAGE}.fs
40	-mv -f netbsd-tmp $@
41
42${IMAGE}.fs: ${TREE} ${LISTS} ${CBIN}
43	dd if=/dev/zero of=${IMAGE}.fs bs=${SIZE} count=1
44	vnconfig -f ${DESTDIR}/etc/disktab -t ${DISKTYPE} -v \
45	  -c ${VND} ${IMAGE}.fs
46	disklabel -rw -f ${DESTDIR}/etc/disktab ${VND} ${DISKTYPE}
47	newfs ${NEWFSARGS} ${VND_RDEV}
48	mount ${VND_DEV} ${MOUNT_POINT}
49	${MTREE} -def ${TREE} -p ${MOUNT_POINT}/ -u
50	TOPDIR=${TOP} CURDIR=${.CURDIR} DESTDIR=${DESTDIR} \
51	  OBJDIR=${.OBJDIR} TARGDIR=${MOUNT_POINT} \
52	  sh ${TOP}/common/RunList.sh ${LISTS}
53	sync
54	@echo ""
55	@df -i ${MOUNT_POINT}
56	@echo ""
57	umount ${MOUNT_POINT}
58	dd if=${VND_DEV} of=${IMAGE}-tmp.fs bs=${SIZE} count=1
59	vnconfig -u ${VND}
60	mv ${IMAGE}-tmp.fs ${IMAGE}.fs
61
62unconfig:
63	-umount -f ${MOUNT_POINT}
64	-vnconfig -u ${VND}
65	-/bin/rm -f ${IMAGE}.fs
66
67# Do not delete this if I change my mind and kill make...
68.PRECIOUS: ${IMAGE}.fs
69
70# Rules for making ${CBIN} ...
71.include "${TOP}/common/Make.crunch"
72
73# This is listed in rd_bin.conf but is built here.
74${CBIN} : libhack.o
75
76# Use stubs to eliminate some large stuff from libc
77HACKSRC=${TOP}/../utils/libhack
78CPPFLAGS+=-I${DESTDIR}/usr/include
79.include "${HACKSRC}/Makefile.inc"
80HACKOBJS+=	gethost.o
81libhack.o: gethost.o
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