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