Makefile revision 260096
1# $FreeBSD: stable/10/sys/boot/i386/boot2/Makefile 260096 2013-12-30 20:15:46Z dim $ 2 3.include <bsd.own.mk> 4 5FILES= boot boot1 boot2 6 7NM?= nm 8 9# A value of 0x80 enables LBA support. 10BOOT_BOOT1_FLAGS?= 0x80 11 12BOOT_COMCONSOLE_PORT?= 0x3f8 13BOOT_COMCONSOLE_SPEED?= 9600 14B2SIOFMT?= 0x3 15 16REL1= 0x700 17ORG1= 0x7c00 18ORG2= 0x2000 19 20# Decide level of UFS support. 21BOOT2_UFS?= UFS1_AND_UFS2 22#BOOT2_UFS?= UFS2_ONLY 23#BOOT2_UFS?= UFS1_ONLY 24 25CFLAGS= -Os \ 26 -fomit-frame-pointer \ 27 -mrtd \ 28 -mregparm=3 \ 29 -DUSE_XREAD \ 30 -D${BOOT2_UFS} \ 31 -DFLAGS=${BOOT_BOOT1_FLAGS} \ 32 -DSIOPRT=${BOOT_COMCONSOLE_PORT} \ 33 -DSIOFMT=${B2SIOFMT} \ 34 -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \ 35 -I${.CURDIR}/../../common \ 36 -I${.CURDIR}/../btx/lib -I. \ 37 -Wall -Waggregate-return -Wbad-function-cast -Wcast-align \ 38 -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ 39 -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \ 40 -Winline --param max-inline-insns-single=100 \ 41 ${CLANG_OPT_SMALL} 42 43CFLAGS.gcc+= -fno-guess-branch-probability \ 44 -fno-unit-at-a-time \ 45 -mno-align-long-strings \ 46 47LDFLAGS=-static -N --gc-sections 48 49# Pick up ../Makefile.inc early. 50.include <bsd.init.mk> 51 52CLEANFILES= boot 53 54boot: boot1 boot2 55 cat boot1 boot2 > boot 56 57CLEANFILES+= boot1 boot1.out boot1.o 58 59boot1: boot1.out 60 objcopy -S -O binary boot1.out ${.TARGET} 61 62boot1.out: boot1.o 63 ${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o 64 65CLEANFILES+= boot2 boot2.ld boot2.ldr boot2.bin boot2.out boot2.o \ 66 boot2.s boot2.s.tmp boot2.h sio.o 67 68boot2: boot2.ld 69 @set -- `ls -l boot2.ld`; x=$$((7680-$$5)); \ 70 echo "$$x bytes available"; test $$x -ge 0 71 dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync 72 73boot2.ld: boot2.ldr boot2.bin ${BTXKERN} 74 btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l boot2.ldr \ 75 -o ${.TARGET} -P 1 boot2.bin 76 77boot2.ldr: 78 dd if=/dev/zero of=${.TARGET} bs=512 count=1 79 80boot2.bin: boot2.out 81 objcopy -S -O binary boot2.out ${.TARGET} 82 83boot2.out: ${BTXCRT} boot2.o sio.o 84 ${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} 85 86boot2.o: boot2.s 87 ${CC} ${ACFLAGS} -c boot2.s 88 89SRCS= boot2.c boot2.h 90 91boot2.s: boot2.c boot2.h ${.CURDIR}/../../common/ufsread.c 92 ${CC} ${CFLAGS} -S -o boot2.s.tmp ${.CURDIR}/boot2.c 93 sed -e '/align/d' -e '/nop/d' < boot2.s.tmp > boot2.s 94 rm -f boot2.s.tmp 95 96boot2.h: boot1.out 97 ${NM} -t d ${.ALLSRC} | awk '/([0-9])+ T xread/ \ 98 { x = $$1 - ORG1; \ 99 printf("#define XREADORG %#x\n", REL1 + x) }' \ 100 ORG1=`printf "%d" ${ORG1}` \ 101 REL1=`printf "%d" ${REL1}` > ${.TARGET} 102 103.if ${MACHINE_CPUARCH} == "amd64" 104beforedepend boot2.s: machine 105CLEANFILES+= machine 106machine: 107 ln -sf ${.CURDIR}/../../../i386/include machine 108.endif 109 110.include <bsd.prog.mk> 111 112# XXX: clang integrated-as doesn't grok .codeNN directives yet 113CFLAGS.boot1.S= ${CLANG_NO_IAS} 114CFLAGS+= ${CFLAGS.${.IMPSRC:T}} 115