xref: /freebsd/stand/i386/zfsboot/Makefile (revision 0bd5d367989b3d2de0e8d8ceaa2e31d3f0d96536)
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${SYSDIR}/cddl/contrib/opensolaris/uts/common \
31	-I${BOOTSRC}/i386/boot2 \
32	-Wall -Waggregate-return -Wbad-function-cast -Wno-cast-align \
33	-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
34	-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings
35
36CFLAGS.gcc+=	--param max-inline-insns-single=100
37
38LD_FLAGS+=${LD_FLAGS_BIN}
39
40CLEANFILES+=	zfsboot
41
42zfsboot: zfsboot1 zfsboot2
43	cat zfsboot1 zfsboot2 > zfsboot
44
45CLEANFILES+=	zfsboot1 zfsldr.out zfsldr.o
46
47zfsboot1: zfsldr.out
48	${OBJCOPY} -S -O binary zfsldr.out ${.TARGET}
49
50zfsldr.out: zfsldr.o
51	${LD} ${LD_FLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} zfsldr.o
52
53CLEANFILES+=	zfsboot2 zfsboot.ld zfsboot.ldr zfsboot.bin zfsboot.out \
54		zfsboot.o zfsboot.s zfsboot.s.tmp sio.o cons.o drv.o
55
56# We currently allow 256k bytes for zfsboot - in practice it could be
57# any size up to 3.5Mb but keeping it fixed size simplifies zfsldr.
58#
59BOOT2SIZE=	262144
60
61zfsboot2: zfsboot.ld
62	@set -- `ls -l ${.ALLSRC}`; x=$$((${BOOT2SIZE}-$$5)); \
63	    echo "$$x bytes available"; test $$x -ge 0
64	${DD} if=${.ALLSRC} of=${.TARGET} obs=${BOOT2SIZE} conv=osync
65
66zfsboot.ld: zfsboot.ldr zfsboot.bin ${BTXKERN}
67	btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l zfsboot.ldr \
68	    -o ${.TARGET} -P 1 zfsboot.bin
69
70zfsboot.ldr:
71	cp /dev/null ${.TARGET}
72
73zfsboot.bin: zfsboot.out
74	${OBJCOPY} -S -O binary zfsboot.out ${.TARGET}
75
76zfsboot.out: ${BTXCRT} zfsboot.o sio.o drv.o cons.o
77	${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBSA32}
78
79SRCS=	zfsboot.c
80
81.include <bsd.prog.mk>
82