xref: /freebsd/stand/i386/zfsboot/Makefile (revision 3830659e99640001c09d26dfc0e1bbd77d919a62)
1ca987d46SWarner Losh# $FreeBSD$
2ca987d46SWarner Losh
3ca987d46SWarner Losh.include <bsd.init.mk>
4ca987d46SWarner Losh
5*3830659eSToomas Soome.PATH:		${BOOTSRC}/i386/boot2 ${BOOTSRC}/i386/common ${BOOTSRC}/common
6ca987d46SWarner Losh
7ca987d46SWarner LoshFILES=		zfsboot
8ca987d46SWarner LoshMAN=		zfsboot.8
9ca987d46SWarner Losh
10ca987d46SWarner LoshBOOT_COMCONSOLE_PORT?= 0x3f8
11ca987d46SWarner LoshBOOT_COMCONSOLE_SPEED?= 9600
12ca987d46SWarner LoshB2SIOFMT?=	0x3
13ca987d46SWarner Losh
14ca987d46SWarner LoshREL1=	0x700
15ca987d46SWarner LoshORG1=	0x7c00
16ca987d46SWarner LoshORG2=	0x2000
17ca987d46SWarner Losh
18ca987d46SWarner LoshCFLAGS+=-DBOOTPROG=\"zfsboot\" \
19ca987d46SWarner Losh	-O1 \
20*3830659eSToomas Soome	-DBOOT2 \
21*3830659eSToomas Soome	-DLOADER_GPT_SUPPORT \
22*3830659eSToomas Soome	-DLOADER_MBR_SUPPORT \
23*3830659eSToomas Soome	-DLOADER_ZFS_SUPPORT \
24*3830659eSToomas Soome	-DLOADER_UFS_SUPPORT \
25ca987d46SWarner Losh	-DSIOPRT=${BOOT_COMCONSOLE_PORT} \
26ca987d46SWarner Losh	-DSIOFMT=${B2SIOFMT} \
27ca987d46SWarner Losh	-DSIOSPD=${BOOT_COMCONSOLE_SPEED} \
28ca987d46SWarner Losh	-I${LDRSRC} \
29ca987d46SWarner Losh	-I${BOOTSRC}/i386/common \
30*3830659eSToomas Soome	-I${BOOTSRC}/i386/libi386 \
31ca987d46SWarner Losh	-I${ZFSSRC} \
3292a2b890SWarner Losh	-I${SYSDIR}/crypto/skein \
33ca987d46SWarner Losh	-I${SYSDIR}/cddl/boot/zfs \
34b1b93268SToomas Soome	-I${SYSDIR}/cddl/contrib/opensolaris/uts/common \
35e499793eSToomas Soome	-I${SYSDIR}/cddl/contrib/opensolaris/common/lz4 \
36ca987d46SWarner Losh	-I${BOOTSRC}/i386/boot2 \
37ca987d46SWarner Losh	-Wall -Waggregate-return -Wbad-function-cast -Wno-cast-align \
38ca987d46SWarner Losh	-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
39073193edSDimitry Andric	-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings
40ca987d46SWarner Losh
41*3830659eSToomas SoomeCFLAGS.part.c+= -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib
42*3830659eSToomas Soome
43ca987d46SWarner LoshCFLAGS.gcc+=	--param max-inline-insns-single=100
44ca987d46SWarner Losh
45ca987d46SWarner LoshLD_FLAGS+=${LD_FLAGS_BIN}
46ca987d46SWarner Losh
47ca987d46SWarner LoshCLEANFILES+=	zfsboot
48ca987d46SWarner Losh
49ca987d46SWarner Loshzfsboot: zfsboot1 zfsboot2
50ca987d46SWarner Losh	cat zfsboot1 zfsboot2 > zfsboot
51ca987d46SWarner Losh
52ca987d46SWarner LoshCLEANFILES+=	zfsboot1 zfsldr.out zfsldr.o
53ca987d46SWarner Losh
54ca987d46SWarner Loshzfsboot1: zfsldr.out
55ca987d46SWarner Losh	${OBJCOPY} -S -O binary zfsldr.out ${.TARGET}
56ca987d46SWarner Losh
57ca987d46SWarner Loshzfsldr.out: zfsldr.o
58a2037dbaSDimitry Andric	${LD} ${LD_FLAGS} -e start --defsym ORG=${ORG1} -T ${LDSCRIPT} -o ${.TARGET} zfsldr.o
59ca987d46SWarner Losh
60*3830659eSToomas SoomeOBJS=	zfsboot.o sio.o cons.o bcache.o devopen.o disk.o part.o zfs_cmd.o
61ca987d46SWarner LoshCLEANFILES+=	zfsboot2 zfsboot.ld zfsboot.ldr zfsboot.bin zfsboot.out \
62*3830659eSToomas Soome		${OBJS}
63ca987d46SWarner Losh
646f3d4ec8SAllan Jude# We currently allow 256k bytes for zfsboot - in practice it could be
65ca987d46SWarner Losh# any size up to 3.5Mb but keeping it fixed size simplifies zfsldr.
66ca987d46SWarner Losh#
676f3d4ec8SAllan JudeBOOT2SIZE=	262144
68ca987d46SWarner Losh
69*3830659eSToomas Soome# i386 standalone support library
70*3830659eSToomas SoomeLIBI386=	${BOOTOBJ}/i386/libi386/libi386.a
71*3830659eSToomas Soome
72ca987d46SWarner Loshzfsboot2: zfsboot.ld
73ca987d46SWarner Losh	@set -- `ls -l ${.ALLSRC}`; x=$$((${BOOT2SIZE}-$$5)); \
74ca987d46SWarner Losh	    echo "$$x bytes available"; test $$x -ge 0
7587c5e64cSAlex Richardson	${DD} if=${.ALLSRC} of=${.TARGET} bs=${BOOT2SIZE} conv=sync
76ca987d46SWarner Losh
77ca987d46SWarner Loshzfsboot.ld: zfsboot.ldr zfsboot.bin ${BTXKERN}
78ca987d46SWarner Losh	btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l zfsboot.ldr \
79ca987d46SWarner Losh	    -o ${.TARGET} -P 1 zfsboot.bin
80ca987d46SWarner Losh
81ca987d46SWarner Loshzfsboot.ldr:
82ca987d46SWarner Losh	cp /dev/null ${.TARGET}
83ca987d46SWarner Losh
84ca987d46SWarner Loshzfsboot.bin: zfsboot.out
85ca987d46SWarner Losh	${OBJCOPY} -S -O binary zfsboot.out ${.TARGET}
86ca987d46SWarner Losh
87*3830659eSToomas Soomezfsboot.out: ${BTXCRT} ${OBJS}
88*3830659eSToomas Soome	${LD} ${LD_FLAGS} --defsym ORG=${ORG2} -T ${LDSCRIPT} -o ${.TARGET} ${.ALLSRC} ${LIBI386} ${LIBSA32}
89ca987d46SWarner Losh
90ca987d46SWarner LoshSRCS=	zfsboot.c
91ca987d46SWarner Losh
92ca987d46SWarner Losh.include <bsd.prog.mk>
93