xref: /freebsd/stand/i386/zfsboot/Makefile (revision b9f654b163bce26de79705e77b872427c9f2afa1)
1# $FreeBSD$
2
3.include <bsd.init.mk>
4
5.PATH:		${BOOTSRC}/i386/boot2 ${BOOTSRC}/i386/common ${SASRC}
6
7FILES=		zfsboot
8MAN=		zfsboot.8
9
10BOOT_COMCONSOLE_PORT?= 0x3f8
11BOOT_COMCONSOLE_SPEED?= 9600
12B2SIOFMT?=	0x3
13
14REL1=	0x700
15ORG1=	0x7c00
16ORG2=	0x2000
17
18CFLAGS+=-DBOOTPROG=\"zfsboot\" \
19	-O1 \
20	-DZFS -DBOOT2 \
21	-DSIOPRT=${BOOT_COMCONSOLE_PORT} \
22	-DSIOFMT=${B2SIOFMT} \
23	-DSIOSPD=${BOOT_COMCONSOLE_SPEED} \
24	-I${LDRSRC} \
25	-I${BOOTSRC}/i386/common \
26	-I${BOOTSRC}/i386 \
27	-I${ZFSSRC} \
28	-I${SYSDIR}/crypto/skein \
29	-I${SYSDIR}/cddl/boot/zfs \
30	-I${BOOTSRC}/i386/boot2 \
31	-Wall -Waggregate-return -Wbad-function-cast -Wno-cast-align \
32	-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
33	-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings
34
35CFLAGS.gcc+=	--param max-inline-insns-single=100
36
37LD_FLAGS+=${LD_FLAGS_BIN}
38
39CLEANFILES+=	zfsboot
40
41zfsboot: zfsboot1 zfsboot2
42	cat zfsboot1 zfsboot2 > zfsboot
43
44CLEANFILES+=	zfsboot1 zfsldr.out zfsldr.o
45
46zfsboot1: zfsldr.out
47	${OBJCOPY} -S -O binary zfsldr.out ${.TARGET}
48
49zfsldr.out: zfsldr.o
50	${LD} ${LD_FLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} zfsldr.o
51
52CLEANFILES+=	zfsboot2 zfsboot.ld zfsboot.ldr zfsboot.bin zfsboot.out \
53		zfsboot.o zfsboot.s zfsboot.s.tmp sio.o cons.o drv.o
54
55# We currently allow 256k bytes for zfsboot - in practice it could be
56# any size up to 3.5Mb but keeping it fixed size simplifies zfsldr.
57#
58BOOT2SIZE=	262144
59
60zfsboot2: zfsboot.ld
61	@set -- `ls -l ${.ALLSRC}`; x=$$((${BOOT2SIZE}-$$5)); \
62	    echo "$$x bytes available"; test $$x -ge 0
63	${DD} if=${.ALLSRC} of=${.TARGET} obs=${BOOT2SIZE} conv=osync
64
65zfsboot.ld: zfsboot.ldr zfsboot.bin ${BTXKERN}
66	btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l zfsboot.ldr \
67	    -o ${.TARGET} -P 1 zfsboot.bin
68
69zfsboot.ldr:
70	cp /dev/null ${.TARGET}
71
72zfsboot.bin: zfsboot.out
73	${OBJCOPY} -S -O binary zfsboot.out ${.TARGET}
74
75zfsboot.out: ${BTXCRT} zfsboot.o sio.o drv.o cons.o
76	${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBSA32}
77
78SRCS=	zfsboot.c
79
80.include <bsd.prog.mk>
81