Makefile revision 221348
1217806Slstewart# $FreeBSD: head/sys/boot/i386/boot2/Makefile 221348 2011-05-02 21:13:08Z dim $ 2217806Slstewart 3217806Slstewart.include <bsd.own.mk> 4217806Slstewart 5217806SlstewartFILES= boot boot1 boot2 6217806Slstewart 7217806SlstewartNM?= nm 8217806Slstewart 9220560Slstewart# A value of 0x80 enables LBA support. 10220560SlstewartBOOT_BOOT1_FLAGS?= 0x80 11220560Slstewart 12217806SlstewartBOOT_COMCONSOLE_PORT?= 0x3f8 13217806SlstewartBOOT_COMCONSOLE_SPEED?= 9600 14217806SlstewartB2SIOFMT?= 0x3 15217806Slstewart 16217806SlstewartREL1= 0x700 17217806SlstewartORG1= 0x7c00 18217806SlstewartORG2= 0x2000 19217806Slstewart 20217806Slstewart# Decide level of UFS support. 21217806SlstewartBOOT2_UFS?= UFS1_AND_UFS2 22217806Slstewart#BOOT2_UFS?= UFS2_ONLY 23217806Slstewart#BOOT2_UFS?= UFS1_ONLY 24217806Slstewart 25217806SlstewartCFLAGS= -Os \ 26217806Slstewart -fno-guess-branch-probability \ 27217806Slstewart -fomit-frame-pointer \ 28217806Slstewart -fno-unit-at-a-time \ 29217806Slstewart -mno-align-long-strings \ 30217806Slstewart -mrtd \ 31217806Slstewart -mregparm=3 \ 32217806Slstewart -DUSE_XREAD \ 33217806Slstewart -D${BOOT2_UFS} \ 34217806Slstewart -DFLAGS=${BOOT_BOOT1_FLAGS} \ 35217806Slstewart -DSIOPRT=${BOOT_COMCONSOLE_PORT} \ 36217806Slstewart -DSIOFMT=${B2SIOFMT} \ 37217806Slstewart -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \ 38217806Slstewart -I${.CURDIR}/../../common \ 39217806Slstewart -I${.CURDIR}/../btx/lib -I. \ 40217806Slstewart -Wall -Waggregate-return -Wbad-function-cast -Wcast-align \ 41217806Slstewart -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ 42217806Slstewart -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \ 43217806Slstewart -Winline --param max-inline-insns-single=100 44217806Slstewart 45217806Slstewart.if ${CC:T:Mclang} == "clang" 46217806SlstewartCFLAGS+= -mllvm -stack-alignment=8 -mllvm -inline-threshold=3 47217806Slstewart# XXX: clang integrated-as doesn't grok .codeNN directives yet 48217806SlstewartCFLAGS+= ${.IMPSRC:T:Mboot1.S:C/^.+$/-no-integrated-as/} 49217806Slstewart.endif 50217806Slstewart 51217806SlstewartLDFLAGS=-static -N --gc-sections 52217806Slstewart 53217806Slstewart# Pick up ../Makefile.inc early. 54217806Slstewart.include <bsd.init.mk> 55217806Slstewart 56217806SlstewartCLEANFILES= boot 57217806Slstewart 58217806Slstewartboot: boot1 boot2 59217806Slstewart cat boot1 boot2 > boot 60217806Slstewart 61217806SlstewartCLEANFILES+= boot1 boot1.out boot1.o 62217806Slstewart 63217806Slstewartboot1: boot1.out 64217806Slstewart objcopy -S -O binary boot1.out ${.TARGET} 65217806Slstewart 66217806Slstewartboot1.out: boot1.o 67217806Slstewart ${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o 68217806Slstewart 69217806SlstewartCLEANFILES+= boot2 boot2.ld boot2.ldr boot2.bin boot2.out boot2.o \ 70217806Slstewart boot2.s boot2.s.tmp boot2.h sio.o 71217806Slstewart 72217806Slstewartboot2: boot2.ld 73217806Slstewart @set -- `ls -l boot2.ld`; x=$$((7680-$$5)); \ 74217806Slstewart echo "$$x bytes available"; test $$x -ge 0 75217806Slstewart dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync 76217806Slstewart 77217806Slstewartboot2.ld: boot2.ldr boot2.bin ${BTXKERN} 78217806Slstewart btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l boot2.ldr \ 79217806Slstewart -o ${.TARGET} -P 1 boot2.bin 80217806Slstewart 81217806Slstewartboot2.ldr: 82217806Slstewart dd if=/dev/zero of=${.TARGET} bs=512 count=1 83217806Slstewart 84217806Slstewartboot2.bin: boot2.out 85217806Slstewart objcopy -S -O binary boot2.out ${.TARGET} 86217806Slstewart 87217806Slstewartboot2.out: ${BTXCRT} boot2.o sio.o 88217806Slstewart ${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} 89217806Slstewart 90217806Slstewartboot2.o: boot2.s 91217806Slstewart 92217806SlstewartSRCS= boot2.c boot2.h 93217806Slstewart 94217806Slstewartboot2.s: boot2.c boot2.h ${.CURDIR}/../../common/ufsread.c 95217806Slstewart ${CC} ${CFLAGS} -S -o boot2.s.tmp ${.CURDIR}/boot2.c 96217806Slstewart sed -e '/align/d' -e '/nop/d' < boot2.s.tmp > boot2.s 97217806Slstewart rm -f boot2.s.tmp 98217806Slstewart 99217806Slstewartboot2.h: boot1.out 100217806Slstewart ${NM} -t d ${.ALLSRC} | awk '/([0-9])+ T xread/ \ 101217806Slstewart { x = $$1 - ORG1; \ 102217806Slstewart printf("#define XREADORG %#x\n", REL1 + x) }' \ 103217806Slstewart ORG1=`printf "%d" ${ORG1}` \ 104217806Slstewart REL1=`printf "%d" ${REL1}` > ${.TARGET} 105217806Slstewart 106217806Slstewart.if ${MACHINE_CPUARCH} == "amd64" 107217806Slstewartbeforedepend boot2.s: machine 108217806SlstewartCLEANFILES+= machine 109217806Slstewartmachine: 110217806Slstewart ln -sf ${.CURDIR}/../../../i386/include machine 111217806Slstewart.endif 112217806Slstewart 113217806Slstewart.include <bsd.prog.mk> 114217806Slstewart