150477Speter# $FreeBSD$ 240269Srnordier 3213136Spjd.PATH: ${.CURDIR}/../boot2 ${.CURDIR}/../common ${.CURDIR}/../../common 440326Srnordier 5172940SjhbFILES= gptboot 6253211SwblockMAN= gptboot.8 7172940Sjhb 880751SjhbNM?= nm 980751Sjhb 1042480SrnordierBOOT_COMCONSOLE_PORT?= 0x3f8 1142480SrnordierBOOT_COMCONSOLE_SPEED?= 9600 1240541SrnordierB2SIOFMT?= 0x3 1340541Srnordier 14104673SgreenREL1= 0x700 1540269SrnordierORG1= 0x7c00 16172940SjhbORG2= 0x0 1740269Srnordier 18125537Sru# Decide level of UFS support. 19172940SjhbGPTBOOT_UFS?= UFS1_AND_UFS2 20172940Sjhb#GPTBOOT_UFS?= UFS2_ONLY 21172940Sjhb#GPTBOOT_UFS?= UFS1_ONLY 22104635Sphk 23213136SpjdCFLAGS= -DBOOTPROG=\"gptboot\" \ 24225530Savg -O1 \ 25213136Spjd -DGPT \ 26172940Sjhb -D${GPTBOOT_UFS} \ 27125932Sru -DSIOPRT=${BOOT_COMCONSOLE_PORT} \ 28125932Sru -DSIOFMT=${B2SIOFMT} \ 29125932Sru -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \ 3097860Sphk -I${.CURDIR}/../../common \ 31213136Spjd -I${.CURDIR}/../common \ 32173026Sjhb -I${.CURDIR}/../btx/lib -I. \ 33172940Sjhb -I${.CURDIR}/../boot2 \ 34213568Spho -I${.CURDIR}/../../.. \ 3540269Srnordier -Wall -Waggregate-return -Wbad-function-cast -Wcast-align \ 3640269Srnordier -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ 37169732Skan -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \ 38260497Sdim -Winline 3940269Srnordier 40260497SdimCFLAGS.gcc+= --param max-inline-insns-single=100 41260497Sdim 42260291SdimLD_FLAGS=-static -N --gc-sections 4340269Srnordier 44125537Sru# Pick up ../Makefile.inc early. 45125537Sru.include <bsd.init.mk> 4640269Srnordier 47172940SjhbCLEANFILES= gptboot 48125537Sru 49172940Sjhbgptboot: gptldr.bin gptboot.bin ${BTXKERN} 50172940Sjhb btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l gptldr.bin \ 51172940Sjhb -o ${.TARGET} gptboot.bin 52109886Sphk 53172940SjhbCLEANFILES+= gptldr.bin gptldr.out gptldr.o 54125537Sru 55172940Sjhbgptldr.bin: gptldr.out 56172940Sjhb objcopy -S -O binary gptldr.out ${.TARGET} 5740269Srnordier 58172940Sjhbgptldr.out: gptldr.o 59260291Sdim ${LD} ${LD_FLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} gptldr.o 6040269Srnordier 61219483SjhbCLEANFILES+= gptboot.bin gptboot.out gptboot.o sio.o gpt.o crc32.o drv.o \ 62219483Sjhb cons.o util.o 6396424Speter 64172940Sjhbgptboot.bin: gptboot.out 65172940Sjhb objcopy -S -O binary gptboot.out ${.TARGET} 6680751Sjhb 67213136Spjdgptboot.out: ${BTXCRT} gptboot.o sio.o gpt.o crc32.o drv.o cons.o util.o 68260291Sdim ${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBSTAND} 6940269Srnordier 70172940Sjhbgptboot.o: ${.CURDIR}/../../common/ufsread.c 7180751Sjhb 72211677Simp.if ${MACHINE_CPUARCH} == "amd64" 73172940Sjhbbeforedepend gptboot.o: machine 74125556SruCLEANFILES+= machine 75116864Spetermachine: 76116864Speter ln -sf ${.CURDIR}/../../../i386/include machine 77116864Speter.endif 78116864Speter 79125537Sru.include <bsd.prog.mk> 80232930Sdim 81232930Sdim# XXX: clang integrated-as doesn't grok .codeNN directives yet 82232930SdimCFLAGS.gptldr.S= ${CLANG_NO_IAS} 83232930SdimCFLAGS+= ${CFLAGS.${.IMPSRC:T}} 84