xref: /freebsd/stand/i386/zfsboot/Makefile (revision 9e5787d2284e187abb5b654d924394a65772e004)
1# $FreeBSD$
2
3.include <bsd.init.mk>
4
5.PATH:		${BOOTSRC}/i386/boot2 ${BOOTSRC}/i386/common ${BOOTSRC}/common
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	-DBOOT2 \
21	-DLOADER_GPT_SUPPORT \
22	-DLOADER_MBR_SUPPORT \
23	-DLOADER_ZFS_SUPPORT \
24	-DLOADER_UFS_SUPPORT \
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/libi386 \
31	-I${ZFSSRC} \
32	-I${SYSDIR}/crypto/skein \
33	-I${SYSDIR}/cddl/boot/zfs \
34	-I${SYSDIR}/cddl/contrib/opensolaris/uts/common \
35	-I${SYSDIR}/cddl/contrib/opensolaris/common/lz4 \
36	-I${BOOTSRC}/i386/boot2 \
37	-Wall -Waggregate-return -Wbad-function-cast -Wno-cast-align \
38	-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
39	-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings
40
41CFLAGS.part.c+= -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib
42
43CFLAGS.gcc+=	--param max-inline-insns-single=100
44
45LD_FLAGS+=${LD_FLAGS_BIN}
46
47CLEANFILES+=	zfsboot
48
49zfsboot: zfsboot1 zfsboot2
50	cat zfsboot1 zfsboot2 > zfsboot
51
52CLEANFILES+=	zfsboot1 zfsldr.out zfsldr.o
53
54zfsboot1: zfsldr.out
55	${OBJCOPY} -S -O binary zfsldr.out ${.TARGET}
56
57zfsldr.out: zfsldr.o
58	${LD} ${LD_FLAGS} -e start --defsym ORG=${ORG1} -T ${LDSCRIPT} -o ${.TARGET} zfsldr.o
59
60OBJS=	zfsboot.o sio.o cons.o bcache.o devopen.o disk.o part.o zfs_cmd.o
61CLEANFILES+=	zfsboot2 zfsboot.ld zfsboot.ldr zfsboot.bin zfsboot.out \
62		${OBJS}
63
64# We currently allow 256k bytes for zfsboot - in practice it could be
65# any size up to 3.5Mb but keeping it fixed size simplifies zfsldr.
66#
67BOOT2SIZE=	262144
68
69# i386 standalone support library
70LIBI386=	${BOOTOBJ}/i386/libi386/libi386.a
71
72zfsboot2: zfsboot.ld
73	@set -- `ls -l ${.ALLSRC}`; x=$$((${BOOT2SIZE}-$$5)); \
74	    echo "$$x bytes available"; test $$x -ge 0
75	${DD} if=${.ALLSRC} of=${.TARGET} bs=${BOOT2SIZE} conv=sync
76
77zfsboot.ld: zfsboot.ldr zfsboot.bin ${BTXKERN}
78	btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l zfsboot.ldr \
79	    -o ${.TARGET} -P 1 zfsboot.bin
80
81zfsboot.ldr:
82	cp /dev/null ${.TARGET}
83
84zfsboot.bin: zfsboot.out
85	${OBJCOPY} -S -O binary zfsboot.out ${.TARGET}
86
87zfsboot.out: ${BTXCRT} ${OBJS}
88	${LD} ${LD_FLAGS} --defsym ORG=${ORG2} -T ${LDSCRIPT} -o ${.TARGET} ${.ALLSRC} ${LIBI386} ${LIBSA32}
89
90SRCS=	zfsboot.c
91
92.include <bsd.prog.mk>
93