xref: /freebsd/stand/i386/zfsboot/Makefile (revision a03411e84728e9b267056fd31c7d1d9d1dc1b01e)
1
2.include <bsd.init.mk>
3
4.PATH:		${BOOTSRC}/i386/boot2 ${BOOTSRC}/i386/common ${BOOTSRC}/common
5
6FILES=		zfsboot
7MAN=		zfsboot.8
8
9BOOT_COMCONSOLE_PORT?= 0x3f8
10BOOT_COMCONSOLE_SPEED?= 115200
11B2SIOFMT?=	0x3
12
13REL1=	0x700
14ORG1=	0x7c00
15ORG2=	0x2000
16
17CFLAGS+=-DBOOTPROG=\"zfsboot\" \
18	-O1 \
19	-DBOOT2 \
20	-DLOADER_GPT_SUPPORT \
21	-DLOADER_MBR_SUPPORT \
22	-DLOADER_ZFS_SUPPORT \
23	-DLOADER_UFS_SUPPORT \
24	-DSIOPRT=${BOOT_COMCONSOLE_PORT} \
25	-DSIOFMT=${B2SIOFMT} \
26	-DSIOSPD=${BOOT_COMCONSOLE_SPEED} \
27	-I${LDRSRC} \
28	-I${BOOTSRC}/i386/common \
29	-I${BOOTSRC}/i386/libi386 \
30	-I${ZFSSRC} \
31	-I${SYSDIR}/crypto/skein \
32	-I${SYSDIR}/cddl/boot/zfs \
33	-I${SYSDIR}/contrib/openzfs/include \
34	-I${SYSDIR}/contrib/openzfs/include/os/freebsd/spl \
35	-I${SYSDIR}/contrib/openzfs/include/os/freebsd/zfs \
36	-I${SYSDIR}/cddl/contrib/opensolaris/common/lz4 \
37	-I${BOOTSRC}/i386/boot2 \
38	-Wall -Waggregate-return -Wbad-function-cast -Wno-cast-align \
39	-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
40	-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings
41
42CFLAGS.part.c+= -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib
43
44CFLAGS.gcc+=	--param max-inline-insns-single=100
45
46LD_FLAGS+=${LD_FLAGS_BIN}
47
48CLEANFILES+=	zfsboot
49
50zfsboot: zfsboot1 zfsboot2
51	cat zfsboot1 zfsboot2 > zfsboot
52
53CLEANFILES+=	zfsboot1 zfsldr.out zfsldr.o
54
55zfsboot1: zfsldr.out
56	${OBJCOPY} -S -O binary zfsldr.out ${.TARGET}
57
58zfsldr.out: zfsldr.o
59	${LD} ${LD_FLAGS} -e start --defsym ORG=${ORG1} -T ${LDSCRIPT} -o ${.TARGET} zfsldr.o
60
61OBJS=	zfsboot.o sio.o cons.o bcache.o devopen.o disk.o part.o zfs_cmd.o misc.o
62CLEANFILES+=	zfsboot2 zfsboot.ld zfsboot.ldr zfsboot.bin zfsboot.out \
63		${OBJS}
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
70# i386 standalone support library
71LIBI386=	${BOOTOBJ}/i386/libi386/libi386.a
72
73zfsboot2: zfsboot.ld
74	@set -- `ls -l ${.ALLSRC}`; x=$$((${BOOT2SIZE}-$$5)); \
75	    echo "$$x bytes available"; test $$x -ge 0
76	${DD} if=${.ALLSRC} of=${.TARGET} bs=${BOOT2SIZE} conv=sync
77
78zfsboot.ld: zfsboot.ldr zfsboot.bin ${BTXKERN}
79	btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l zfsboot.ldr \
80	    -o ${.TARGET} -P 1 zfsboot.bin
81
82zfsboot.ldr:
83	:> ${.TARGET}
84
85zfsboot.bin: zfsboot.out
86	${OBJCOPY} -S -O binary zfsboot.out ${.TARGET}
87
88zfsboot.out: ${BTXCRT} ${OBJS}
89	${LD} ${LD_FLAGS} --defsym ORG=${ORG2} -T ${LDSCRIPT} -o ${.TARGET} ${.ALLSRC} ${LIBI386} ${LIBSA32}
90
91SRCS=	zfsboot.c
92
93.include <bsd.prog.mk>
94