1ca987d46SWarner Losh# $FreeBSD$ 2ca987d46SWarner Losh 3ca987d46SWarner Losh.include <bsd.init.mk> 4ca987d46SWarner Losh 5ca987d46SWarner Losh.PATH: ${BOOTSRC}/i386/boot2 ${BOOTSRC}/i386/common ${SASRC} 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 \ 20ca987d46SWarner Losh -DZFS -DBOOT2 \ 21ca987d46SWarner Losh -DSIOPRT=${BOOT_COMCONSOLE_PORT} \ 22ca987d46SWarner Losh -DSIOFMT=${B2SIOFMT} \ 23ca987d46SWarner Losh -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \ 24ca987d46SWarner Losh -I${LDRSRC} \ 25ca987d46SWarner Losh -I${BOOTSRC}/i386/common \ 26ca987d46SWarner Losh -I${BOOTSRC}/i386 \ 27ca987d46SWarner Losh -I${ZFSSRC} \ 2892a2b890SWarner Losh -I${SYSDIR}/crypto/skein \ 29ca987d46SWarner Losh -I${SYSDIR}/cddl/boot/zfs \ 30*b1b93268SToomas Soome -I${SYSDIR}/cddl/contrib/opensolaris/uts/common \ 31ca987d46SWarner Losh -I${BOOTSRC}/i386/boot2 \ 32ca987d46SWarner Losh -Wall -Waggregate-return -Wbad-function-cast -Wno-cast-align \ 33ca987d46SWarner Losh -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ 34073193edSDimitry Andric -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings 35ca987d46SWarner Losh 36ca987d46SWarner LoshCFLAGS.gcc+= --param max-inline-insns-single=100 37ca987d46SWarner Losh 38ca987d46SWarner LoshLD_FLAGS+=${LD_FLAGS_BIN} 39ca987d46SWarner Losh 40ca987d46SWarner LoshCLEANFILES+= zfsboot 41ca987d46SWarner Losh 42ca987d46SWarner Loshzfsboot: zfsboot1 zfsboot2 43ca987d46SWarner Losh cat zfsboot1 zfsboot2 > zfsboot 44ca987d46SWarner Losh 45ca987d46SWarner LoshCLEANFILES+= zfsboot1 zfsldr.out zfsldr.o 46ca987d46SWarner Losh 47ca987d46SWarner Loshzfsboot1: zfsldr.out 48ca987d46SWarner Losh ${OBJCOPY} -S -O binary zfsldr.out ${.TARGET} 49ca987d46SWarner Losh 50ca987d46SWarner Loshzfsldr.out: zfsldr.o 51ca987d46SWarner Losh ${LD} ${LD_FLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} zfsldr.o 52ca987d46SWarner Losh 53ca987d46SWarner LoshCLEANFILES+= zfsboot2 zfsboot.ld zfsboot.ldr zfsboot.bin zfsboot.out \ 54ca987d46SWarner Losh zfsboot.o zfsboot.s zfsboot.s.tmp sio.o cons.o drv.o 55ca987d46SWarner Losh 566f3d4ec8SAllan Jude# We currently allow 256k bytes for zfsboot - in practice it could be 57ca987d46SWarner Losh# any size up to 3.5Mb but keeping it fixed size simplifies zfsldr. 58ca987d46SWarner Losh# 596f3d4ec8SAllan JudeBOOT2SIZE= 262144 60ca987d46SWarner Losh 61ca987d46SWarner Loshzfsboot2: zfsboot.ld 62ca987d46SWarner Losh @set -- `ls -l ${.ALLSRC}`; x=$$((${BOOT2SIZE}-$$5)); \ 63ca987d46SWarner Losh echo "$$x bytes available"; test $$x -ge 0 64ca987d46SWarner Losh ${DD} if=${.ALLSRC} of=${.TARGET} obs=${BOOT2SIZE} conv=osync 65ca987d46SWarner Losh 66ca987d46SWarner Loshzfsboot.ld: zfsboot.ldr zfsboot.bin ${BTXKERN} 67ca987d46SWarner Losh btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l zfsboot.ldr \ 68ca987d46SWarner Losh -o ${.TARGET} -P 1 zfsboot.bin 69ca987d46SWarner Losh 70ca987d46SWarner Loshzfsboot.ldr: 71ca987d46SWarner Losh cp /dev/null ${.TARGET} 72ca987d46SWarner Losh 73ca987d46SWarner Loshzfsboot.bin: zfsboot.out 74ca987d46SWarner Losh ${OBJCOPY} -S -O binary zfsboot.out ${.TARGET} 75ca987d46SWarner Losh 76ca987d46SWarner Loshzfsboot.out: ${BTXCRT} zfsboot.o sio.o drv.o cons.o 77b8902de1SWarner Losh ${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBSA32} 78ca987d46SWarner Losh 79ca987d46SWarner LoshSRCS= zfsboot.c 80ca987d46SWarner Losh 81ca987d46SWarner Losh.include <bsd.prog.mk> 82