xref: /freebsd/stand/i386/zfsboot/Makefile (revision b8902de147f46c9dcf7f54711b47d6b512fc5c1c)
1ca987d46SWarner Losh# $FreeBSD$
2ca987d46SWarner Losh
3ca987d46SWarner LoshHAVE_GELI=yes
4ca987d46SWarner Losh
5ca987d46SWarner Losh.include <bsd.init.mk>
6ca987d46SWarner Losh
7ca987d46SWarner Losh.PATH:		${BOOTSRC}/i386/boot2 ${BOOTSRC}/i386/common ${SASRC}
8ca987d46SWarner Losh
9ca987d46SWarner LoshFILES=		zfsboot
10ca987d46SWarner LoshMAN=		zfsboot.8
11ca987d46SWarner Losh
12ca987d46SWarner LoshNM?=		nm
13ca987d46SWarner Losh
14ca987d46SWarner LoshBOOT_COMCONSOLE_PORT?= 0x3f8
15ca987d46SWarner LoshBOOT_COMCONSOLE_SPEED?= 9600
16ca987d46SWarner LoshB2SIOFMT?=	0x3
17ca987d46SWarner Losh
18ca987d46SWarner LoshREL1=	0x700
19ca987d46SWarner LoshORG1=	0x7c00
20ca987d46SWarner LoshORG2=	0x2000
21ca987d46SWarner Losh
22ca987d46SWarner LoshCFLAGS+=-DBOOTPROG=\"zfsboot\" \
23ca987d46SWarner Losh	-O1 \
24ca987d46SWarner Losh	-DZFS -DBOOT2 \
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 \
30ca987d46SWarner Losh	-I${BOOTSRC}/i386 \
31ca987d46SWarner Losh	-I${ZFSSRC} \
3292a2b890SWarner Losh	-I${SYSDIR}/crypto/skein \
33ca987d46SWarner Losh	-I${SYSDIR}/cddl/boot/zfs \
34ca987d46SWarner Losh	-I${BOOTSRC}/i386/boot2 \
35ca987d46SWarner Losh	-Wall -Waggregate-return -Wbad-function-cast -Wno-cast-align \
36ca987d46SWarner Losh	-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
37073193edSDimitry Andric	-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings
38ca987d46SWarner Losh
39ca987d46SWarner LoshCFLAGS.gcc+=	--param max-inline-insns-single=100
40ca987d46SWarner Losh
41ca987d46SWarner LoshLD_FLAGS+=${LD_FLAGS_BIN}
42ca987d46SWarner Losh
43ca987d46SWarner LoshCLEANFILES+=	zfsboot
44ca987d46SWarner Losh
45ca987d46SWarner Loshzfsboot: zfsboot1 zfsboot2
46ca987d46SWarner Losh	cat zfsboot1 zfsboot2 > zfsboot
47ca987d46SWarner Losh
48ca987d46SWarner LoshCLEANFILES+=	zfsboot1 zfsldr.out zfsldr.o
49ca987d46SWarner Losh
50ca987d46SWarner Loshzfsboot1: zfsldr.out
51ca987d46SWarner Losh	${OBJCOPY} -S -O binary zfsldr.out ${.TARGET}
52ca987d46SWarner Losh
53ca987d46SWarner Loshzfsldr.out: zfsldr.o
54ca987d46SWarner Losh	${LD} ${LD_FLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} zfsldr.o
55ca987d46SWarner Losh
56ca987d46SWarner LoshCLEANFILES+=	zfsboot2 zfsboot.ld zfsboot.ldr zfsboot.bin zfsboot.out \
57ca987d46SWarner Losh		zfsboot.o zfsboot.s zfsboot.s.tmp sio.o cons.o drv.o
58ca987d46SWarner Losh
596f3d4ec8SAllan Jude# We currently allow 256k bytes for zfsboot - in practice it could be
60ca987d46SWarner Losh# any size up to 3.5Mb but keeping it fixed size simplifies zfsldr.
61ca987d46SWarner Losh#
626f3d4ec8SAllan JudeBOOT2SIZE=	262144
63ca987d46SWarner Losh
64ca987d46SWarner Loshzfsboot2: zfsboot.ld
65ca987d46SWarner Losh	@set -- `ls -l ${.ALLSRC}`; x=$$((${BOOT2SIZE}-$$5)); \
66ca987d46SWarner Losh	    echo "$$x bytes available"; test $$x -ge 0
67ca987d46SWarner Losh	${DD} if=${.ALLSRC} of=${.TARGET} obs=${BOOT2SIZE} conv=osync
68ca987d46SWarner Losh
69ca987d46SWarner Loshzfsboot.ld: zfsboot.ldr zfsboot.bin ${BTXKERN}
70ca987d46SWarner Losh	btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l zfsboot.ldr \
71ca987d46SWarner Losh	    -o ${.TARGET} -P 1 zfsboot.bin
72ca987d46SWarner Losh
73ca987d46SWarner Loshzfsboot.ldr:
74ca987d46SWarner Losh	cp /dev/null ${.TARGET}
75ca987d46SWarner Losh
76ca987d46SWarner Loshzfsboot.bin: zfsboot.out
77ca987d46SWarner Losh	${OBJCOPY} -S -O binary zfsboot.out ${.TARGET}
78ca987d46SWarner Losh
79ca987d46SWarner Loshzfsboot.out: ${BTXCRT} zfsboot.o sio.o drv.o cons.o
80*b8902de1SWarner Losh	${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBSA32}
81ca987d46SWarner Losh
82ca987d46SWarner LoshSRCS=	zfsboot.c
83ca987d46SWarner Losh
84ca987d46SWarner Losh.include <bsd.prog.mk>
85ca987d46SWarner Losh
86ca987d46SWarner Losh# XXX: clang integrated-as doesn't grok .codeNN directives yet
87ca987d46SWarner LoshCFLAGS.zfsldr.S=	${CLANG_NO_IAS}
88