Makefile revision 224131
117680Spst# $FreeBSD: head/sys/boot/i386/zfsboot/Makefile 224131 2011-07-17 13:50:21Z dim $ 217680Spst 317680Spst.PATH: ${.CURDIR}/../boot2 ${.CURDIR}/../common ${.CURDIR}/../../common 417680Spst 517680SpstFILES= zfsboot 617680Spst 717680SpstNM?= nm 817680Spst 917680SpstBOOT_COMCONSOLE_PORT?= 0x3f8 1017680SpstBOOT_COMCONSOLE_SPEED?= 9600 1117680SpstB2SIOFMT?= 0x3 1217680Spst 1317680SpstREL1= 0x700 1417680SpstORG1= 0x7c00 1517680SpstORG2= 0x2000 1617680Spst 1717680SpstCFLAGS= -DBOOTPROG=\"zfsboot\" \ 1817680Spst -Os \ 1917680Spst -fno-guess-branch-probability \ 2017680Spst -fomit-frame-pointer \ 21127668Sbms -fno-unit-at-a-time \ 2217680Spst -mno-align-long-strings \ 2317680Spst -mrtd \ 2417680Spst -DBOOT2 \ 2517680Spst -DSIOPRT=${BOOT_COMCONSOLE_PORT} \ 2617680Spst -DSIOFMT=${B2SIOFMT} \ 27127668Sbms -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \ 28127668Sbms -I${.CURDIR}/../../common \ 29127668Sbms -I${.CURDIR}/../common \ 30127668Sbms -I${.CURDIR}/../../zfs \ 31127668Sbms -I${.CURDIR}/../../../cddl/boot/zfs \ 32127668Sbms -I${.CURDIR}/../btx/lib -I. \ 33127668Sbms -I${.CURDIR}/../boot2 \ 34127668Sbms -Wall -Waggregate-return -Wbad-function-cast -Wcast-align \ 35127668Sbms -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ 36127668Sbms -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \ 37127668Sbms -Winline --param max-inline-insns-single=100 38127668Sbms 39127668Sbms.if ${CC:T:Mclang} == "clang" 40127668Sbms# XXX: clang integrated-as doesn't grok .codeNN directives yet 41127668SbmsCFLAGS+= ${.IMPSRC:T:Mzfsldr.S:C/^.+$/-no-integrated-as/} 42127668Sbms.endif 43127668Sbms 44127668SbmsLDFLAGS=-static -N --gc-sections 45127668Sbms 46127668Sbms# Pick up ../Makefile.inc early. 47127668Sbms.include <bsd.init.mk> 48127668Sbms 49127668SbmsCLEANFILES= zfsboot 50127668Sbms 51127668Sbmszfsboot: zfsboot1 zfsboot2 52127668Sbms cat zfsboot1 zfsboot2 > zfsboot 5317680Spst 54127668SbmsCLEANFILES+= zfsboot1 zfsldr.out zfsldr.o 5517680Spst 56127668Sbmszfsboot1: zfsldr.out 57127668Sbms objcopy -S -O binary zfsldr.out ${.TARGET} 58127668Sbms 59127668Sbmszfsldr.out: zfsldr.o 60127668Sbms ${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} zfsldr.o 61127668Sbms 62127668SbmsCLEANFILES+= zfsboot2 zfsboot.ld zfsboot.ldr zfsboot.bin zfsboot.out \ 6317680Spst zfsboot.o zfsboot.s zfsboot.s.tmp sio.o cons.o drv.o util.o 64127668Sbms 65127668Sbms# We currently allow 65536 bytes for zfsboot - in practice it could be 66127668Sbms# any size up to 3.5Mb but keeping it fixed size simplifies zfsldr. 67127668Sbms# 68127668SbmsBOOT2SIZE= 65536 69127668Sbms 70127668Sbmszfsboot2: zfsboot.ld 71127668Sbms @set -- `ls -l zfsboot.ld`; x=$$((${BOOT2SIZE}-$$5)); \ 72127668Sbms echo "$$x bytes available"; test $$x -ge 0 73127668Sbms dd if=zfsboot.ld of=${.TARGET} obs=${BOOT2SIZE} conv=osync 74127668Sbms 75127668Sbmszfsboot.ld: zfsboot.ldr zfsboot.bin ${BTXKERN} 76127668Sbms btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l zfsboot.ldr \ 77127668Sbms -o ${.TARGET} -P 1 zfsboot.bin 7898524Sfenner 7917680Spstzfsboot.ldr: 8098524Sfenner cp /dev/null ${.TARGET} 81127668Sbms 8217680Spstzfsboot.bin: zfsboot.out 8317680Spst objcopy -S -O binary zfsboot.out ${.TARGET} 84127668Sbms 85127668Sbmszfsboot.out: ${BTXCRT} zfsboot.o sio.o drv.o cons.o util.o 86127668Sbms ${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBSTAND} 8717680Spst 8817680Spstzfsboot.o: zfsboot.s 8917680Spst.if ${CC:T:Mclang} == "clang" 9017680Spst ${CC} ${ACFLAGS} -c zfsboot.s 9117680Spst.endif 92127668Sbms 93127668SbmsSRCS= zfsboot.c 9417680Spst 95127668Sbmszfsboot.s: zfsboot.c ${.CURDIR}/../../zfs/zfsimpl.c 96127668Sbms ${CC} ${CFLAGS} -S -o zfsboot.s.tmp ${.CURDIR}/zfsboot.c 97127668Sbms sed -e '/align/d' -e '/nop/d' < zfsboot.s.tmp > zfsboot.s 98127668Sbms rm -f zfsboot.s.tmp 99 100.if ${MACHINE_CPUARCH} == "amd64" 101beforedepend zfsboot.s: machine 102CLEANFILES+= machine 103machine: 104 ln -sf ${.CURDIR}/../../../i386/include machine 105.endif 106 107.include <bsd.prog.mk> 108