Makefile revision 260095
150477Speter# $FreeBSD: head/sys/boot/i386/boot2/Makefile 260095 2013-12-30 19:05:50Z dim $ 240269Srnordier 3211571Srpaulo.include <bsd.own.mk> 4211571Srpaulo 5125537SruFILES= boot boot1 boot2 640326Srnordier 780751SjhbNM?= nm 880751Sjhb 948919Srnordier# A value of 0x80 enables LBA support. 10134382SyarBOOT_BOOT1_FLAGS?= 0x80 1148919Srnordier 1242480SrnordierBOOT_COMCONSOLE_PORT?= 0x3f8 1342480SrnordierBOOT_COMCONSOLE_SPEED?= 9600 1440541SrnordierB2SIOFMT?= 0x3 1540541Srnordier 16104673SgreenREL1= 0x700 1740269SrnordierORG1= 0x7c00 18104683SjhbORG2= 0x2000 1940269Srnordier 20125537Sru# Decide level of UFS support. 21108000SimpBOOT2_UFS?= UFS1_AND_UFS2 22125537Sru#BOOT2_UFS?= UFS2_ONLY 23125537Sru#BOOT2_UFS?= UFS1_ONLY 24104635Sphk 25125566SruCFLAGS= -Os \ 26132870Skan -fomit-frame-pointer \ 2796327Sjhb -mrtd \ 28220337Srdivacky -mregparm=3 \ 29221177Sjhb -DUSE_XREAD \ 30107879Sphk -D${BOOT2_UFS} \ 31134382Syar -DFLAGS=${BOOT_BOOT1_FLAGS} \ 32125932Sru -DSIOPRT=${BOOT_COMCONSOLE_PORT} \ 33125932Sru -DSIOFMT=${B2SIOFMT} \ 34125932Sru -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \ 3597860Sphk -I${.CURDIR}/../../common \ 3696306Sobrien -I${.CURDIR}/../btx/lib -I. \ 3740269Srnordier -Wall -Waggregate-return -Wbad-function-cast -Wcast-align \ 3840269Srnordier -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ 39169732Skan -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \ 40232263Sdim -Winline --param max-inline-insns-single=100 \ 41232263Sdim ${CLANG_OPT_SMALL} 4240269Srnordier 43259913SdimCFLAGS.gcc+= -fno-guess-branch-probability \ 44259913Sdim -fno-unit-at-a-time \ 45259913Sdim -mno-align-long-strings \ 46259913Sdim 47260095SdimLD_FLAGS=-static -N --gc-sections 4840269Srnordier 49125537Sru# Pick up ../Makefile.inc early. 50125537Sru.include <bsd.init.mk> 5140269Srnordier 52125537SruCLEANFILES= boot 53125537Sru 54109886Sphkboot: boot1 boot2 55109886Sphk cat boot1 boot2 > boot 56109886Sphk 57125537SruCLEANFILES+= boot1 boot1.out boot1.o 58125537Sru 5940269Srnordierboot1: boot1.out 6040308Srnordier objcopy -S -O binary boot1.out ${.TARGET} 6140269Srnordier 6240269Srnordierboot1.out: boot1.o 63260095Sdim ${LD} ${LD_FLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o 6440269Srnordier 65125537SruCLEANFILES+= boot2 boot2.ld boot2.ldr boot2.bin boot2.out boot2.o \ 66125537Sru boot2.s boot2.s.tmp boot2.h sio.o 6796424Speter 68125537Sruboot2: boot2.ld 69125537Sru @set -- `ls -l boot2.ld`; x=$$((7680-$$5)); \ 70125537Sru echo "$$x bytes available"; test $$x -ge 0 71125537Sru dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync 7280751Sjhb 73125537Sruboot2.ld: boot2.ldr boot2.bin ${BTXKERN} 74125537Sru btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l boot2.ldr \ 75125537Sru -o ${.TARGET} -P 1 boot2.bin 7640269Srnordier 7740269Srnordierboot2.ldr: 78189500Smarcel dd if=/dev/zero of=${.TARGET} bs=512 count=1 7940269Srnordier 8040269Srnordierboot2.bin: boot2.out 8140308Srnordier objcopy -S -O binary boot2.out ${.TARGET} 8240269Srnordier 83125537Sruboot2.out: ${BTXCRT} boot2.o sio.o 84260095Sdim ${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} 8540269Srnordier 86125537Sruboot2.o: boot2.s 87224131Sdim ${CC} ${ACFLAGS} -c boot2.s 8880751Sjhb 89125564SruSRCS= boot2.c boot2.h 90125564Sru 91125537Sruboot2.s: boot2.c boot2.h ${.CURDIR}/../../common/ufsread.c 92125537Sru ${CC} ${CFLAGS} -S -o boot2.s.tmp ${.CURDIR}/boot2.c 93125537Sru sed -e '/align/d' -e '/nop/d' < boot2.s.tmp > boot2.s 94125537Sru rm -f boot2.s.tmp 9540404Srnordier 96125537Sruboot2.h: boot1.out 97125537Sru ${NM} -t d ${.ALLSRC} | awk '/([0-9])+ T xread/ \ 98125537Sru { x = $$1 - ORG1; \ 99125537Sru printf("#define XREADORG %#x\n", REL1 + x) }' \ 100125537Sru ORG1=`printf "%d" ${ORG1}` \ 101125537Sru REL1=`printf "%d" ${REL1}` > ${.TARGET} 10240326Srnordier 103211677Simp.if ${MACHINE_CPUARCH} == "amd64" 104125581Srubeforedepend boot2.s: machine 105125556SruCLEANFILES+= machine 106116864Spetermachine: 107116864Speter ln -sf ${.CURDIR}/../../../i386/include machine 108116864Speter.endif 109116864Speter 110125537Sru.include <bsd.prog.mk> 111232263Sdim 112232263Sdim# XXX: clang integrated-as doesn't grok .codeNN directives yet 113232263SdimCFLAGS.boot1.S= ${CLANG_NO_IAS} 114232263SdimCFLAGS+= ${CFLAGS.${.IMPSRC:T}} 115