3 .PATH: ${.CURDIR}/../boot2 ${.CURDIR}/../common ${.CURDIR}/../../common
9 BOOT_COMCONSOLE_PORT?= 0x3f8
10 BOOT_COMCONSOLE_SPEED?= 9600
17 CFLAGS= -DBOOTPROG=\"zfsboot\" \
20 -DSIOPRT=${BOOT_COMCONSOLE_PORT} \
21 -DSIOFMT=${B2SIOFMT} \
22 -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \
23 -I${.CURDIR}/../../common \
24 -I${.CURDIR}/../common \
25 -I${.CURDIR}/../../zfs \
26 -I${.CURDIR}/../../../cddl/boot/zfs \
27 -I${.CURDIR}/../btx/lib -I. \
28 -I${.CURDIR}/../boot2 \
29 -Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
30 -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
31 -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \
32 -Winline --param max-inline-insns-single=100
34 LDFLAGS=-static -N --gc-sections
36 # Pick up ../Makefile.inc early.
37 .include <bsd.init.mk>
41 zfsboot: zfsboot1 zfsboot2
42 cat zfsboot1 zfsboot2 > zfsboot
44 CLEANFILES+= zfsboot1 zfsldr.out zfsldr.o
47 objcopy -S -O binary zfsldr.out ${.TARGET}
50 ${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} zfsldr.o
52 CLEANFILES+= zfsboot2 zfsboot.ld zfsboot.ldr zfsboot.bin zfsboot.out \
53 zfsboot.o zfsboot.s zfsboot.s.tmp sio.o cons.o drv.o util.o
55 # We currently allow 65536 bytes for zfsboot - in practice it could be
56 # any size up to 3.5Mb but keeping it fixed size simplifies zfsldr.
61 @set -- `ls -l zfsboot.ld`; x=$$((${BOOT2SIZE}-$$5)); \
62 echo "$$x bytes available"; test $$x -ge 0
63 dd if=zfsboot.ld of=${.TARGET} obs=${BOOT2SIZE} conv=osync
65 zfsboot.ld: zfsboot.ldr zfsboot.bin ${BTXKERN}
66 btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l zfsboot.ldr \
67 -o ${.TARGET} -P 1 zfsboot.bin
70 cp /dev/null ${.TARGET}
72 zfsboot.bin: zfsboot.out
73 objcopy -S -O binary zfsboot.out ${.TARGET}
75 zfsboot.out: ${BTXCRT} zfsboot.o sio.o drv.o cons.o util.o
76 ${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBSTAND}
80 .if ${MACHINE_CPUARCH} == "amd64"
81 beforedepend zfsboot.o: machine
84 ln -sf ${.CURDIR}/../../../i386/include machine
87 .include <bsd.prog.mk>
89 # XXX: clang integrated-as doesn't grok .codeNN directives yet
90 CFLAGS.zfsldr.S= ${CLANG_NO_IAS}
91 CFLAGS+= ${CFLAGS.${.IMPSRC:T}}