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