1#	$OpenBSD: Makefile,v 1.21 2023/06/11 14:00:04 krw Exp $
2
3FS=		floppy${OSrev}.img
4FSSIZE=		2880
5MOUNT_POINT=	/mnt
6MTREE=		${UTILS}/mtree.conf
7RAMDISK=	RAMDISK
8
9LISTS=		${.CURDIR}/list
10UTILS=		${.CURDIR}/../../miniroot
11
12EFIBOOT=	${DESTDIR}/usr/mdec/BOOTX64.EFI ${DESTDIR}/usr/mdec/BOOTIA32.EFI
13
14all: ${FS}
15
16${FS}: bsd.gz
17	dd if=/dev/zero of=${FS} bs=512 count=${FSSIZE}
18	vnconfig -v ${FS} > vnd
19	echo '/ *' | disklabel -wAT- `cat vnd`
20	newfs -O 1 -m 0 -o space -i 524288 -c ${FSSIZE} -b 4096 -f 512 /dev/r`cat vnd`a
21	mount /dev/`cat vnd`a ${MOUNT_POINT}
22	objcopy -S -R .comment ${DESTDIR}/usr/mdec/fdboot ${.OBJDIR}/boot
23	installboot -v -r ${MOUNT_POINT} `cat vnd` \
24	    ${DESTDIR}/usr/mdec/biosboot ${.OBJDIR}/boot
25	install -c -m 555 -o root -g wheel bsd.gz ${MOUNT_POINT}/bsd
26	df -i ${MOUNT_POINT}
27	umount ${MOUNT_POINT}
28	vnconfig -u `cat vnd`
29	rm -f vnd
30
31MRDISKTYPE=	rdroot
32MRMAKEFSARGS=	-o disklabel=${MRDISKTYPE},minfree=0,density=4096
33
34bsd.gz: bsd.rd
35	objcopy -S -R .comment -R .SUNW_ctf \
36	    -K rd_root_size -K rd_root_image \
37	    bsd.rd bsd.strip
38	gzip -9cn bsd.strip > bsd.gz
39
40bsd.rd: mr.fs
41	cp bsd bsd.rd
42	rdsetroot bsd.rd mr.fs
43
44bsd:
45	cd ${.CURDIR}/../../../sys/arch/${MACHINE}/compile/${RAMDISK} && \
46	    su ${BUILDUSER} -c '${MAKE} config && ${MAKE} clean && exec ${MAKE} ${MFLAGS}'
47	cp -p ${.CURDIR}/../../../sys/arch/${MACHINE}/compile/${RAMDISK}/obj/bsd bsd
48
49mr.fs: instbin bsd
50	rm -rf $@.d
51	install -d -o root -g wheel $@.d
52	mtree -def ${MTREE} -p $@.d -u
53	CURDIR=${.CURDIR} OBJDIR=${.OBJDIR} OSrev=${OSrev} \
54	    TARGDIR=$@.d UTILS=${UTILS} RELEASEDIR=${RELEASEDIR} \
55	    sh ${UTILS}/runlist.sh ${LISTS}
56	rm $@.d/instbin
57	makefs ${MRMAKEFSARGS} $@ $@.d
58
59instbin.mk instbin.cache instbin.c: instbin.conf
60	crunchgen -E -D ${.CURDIR}/../../.. -L ${DESTDIR}/usr/lib \
61	    -c instbin.c -e instbin -m instbin.mk instbin.conf
62
63instbin: instbin.mk instbin.cache instbin.c
64	${MAKE} ${MFLAGS} -f instbin.mk SRCLIBDIR=${.CURDIR}/../../../lib all
65
66instbin.conf: ${LISTS}
67	awk -f ${UTILS}/makeconf.awk  ${LISTS} > instbin.conf
68
69unconfig:
70	-umount -f ${MOUNT_POINT}
71	-[ -f vnd ] && vnconfig -u `cat vnd` && rm -f vnd
72
73.ifdef RELEASEDIR
74install:
75	cp ${FS} ${RELEASEDIR}
76.endif
77
78clean cleandir:
79	rm -f *.core mr.fs instbin instbin.mk instbin*.cache \
80	    *.o *.lo *.c bsd bsd.rd bsd.gz bsd.strip floppy*.img \
81	    lib*.a lib*.olist instbin.map boot instbin.conf ${FS}
82	rm -rf mr.fs.d
83
84.include <bsd.obj.mk>
85