1# $FreeBSD$ 2 3.PATH: ${.CURDIR}/../boot2 ${.CURDIR}/../common ${.CURDIR}/../../common 4 5FILES= zfsboot 6 7NM?= nm 8 9BOOT_COMCONSOLE_PORT?= 0x3f8 10BOOT_COMCONSOLE_SPEED?= 9600 11B2SIOFMT?= 0x3 12 13REL1= 0x700 14ORG1= 0x7c00 15ORG2= 0x2000 16 17CFLAGS= -DBOOTPROG=\"zfsboot\" \ 18 -O1 \ 19 -DBOOT2 \ 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 33 34CFLAGS.gcc+= --param max-inline-insns-single=100 35 36LD_FLAGS=-static -N --gc-sections 37 38LIBSTAND= ${.OBJDIR}/../../libstand32/libstand.a 39 40# Pick up ../Makefile.inc early. 41.include <bsd.init.mk> 42 43CLEANFILES= zfsboot 44 45zfsboot: zfsboot1 zfsboot2 46 cat zfsboot1 zfsboot2 > zfsboot 47 48CLEANFILES+= zfsboot1 zfsldr.out zfsldr.o 49 50zfsboot1: zfsldr.out 51 objcopy -S -O binary zfsldr.out ${.TARGET} 52 53zfsldr.out: zfsldr.o 54 ${LD} ${LD_FLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} zfsldr.o 55 56CLEANFILES+= zfsboot2 zfsboot.ld zfsboot.ldr zfsboot.bin zfsboot.out \ 57 zfsboot.o zfsboot.s zfsboot.s.tmp sio.o cons.o drv.o util.o 58 59# We currently allow 65536 bytes for zfsboot - in practice it could be 60# any size up to 3.5Mb but keeping it fixed size simplifies zfsldr. 61# 62BOOT2SIZE= 65536 63 64zfsboot2: zfsboot.ld 65 @set -- `ls -l zfsboot.ld`; x=$$((${BOOT2SIZE}-$$5)); \ 66 echo "$$x bytes available"; test $$x -ge 0 67 dd if=zfsboot.ld of=${.TARGET} obs=${BOOT2SIZE} conv=osync 68 69zfsboot.ld: zfsboot.ldr zfsboot.bin ${BTXKERN} 70 btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l zfsboot.ldr \ 71 -o ${.TARGET} -P 1 zfsboot.bin 72 73zfsboot.ldr: 74 cp /dev/null ${.TARGET} 75 76zfsboot.bin: zfsboot.out 77 objcopy -S -O binary zfsboot.out ${.TARGET} 78 79zfsboot.out: ${BTXCRT} zfsboot.o sio.o drv.o cons.o util.o 80 ${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBSTAND} 81 82SRCS= zfsboot.c 83 84.if ${MACHINE_CPUARCH} == "amd64" 85beforedepend zfsboot.o: machine 86CLEANFILES+= machine 87machine: 88 ln -sf ${.CURDIR}/../../../i386/include machine 89.endif 90 91.include <bsd.prog.mk> 92 93# XXX: clang integrated-as doesn't grok .codeNN directives yet 94CFLAGS.zfsldr.S= ${CLANG_NO_IAS} 95CFLAGS+= ${CFLAGS.${.IMPSRC:T}} 96