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