Makefile revision 104636
1# $FreeBSD: head/sys/boot/i386/gptboot/Makefile 104636 2002-10-07 22:21:16Z green $ 2 3PROG= boot2 4NOMAN= 5STRIP= 6BINDIR?= /boot 7BINMODE= 444 8CLEANFILES+= boot1 boot1.out boot1.o \ 9 boot2.ldr boot2.bin boot2.ld boot2.out boot2.o boot2.h \ 10 boot2.s sio.o divdi3.o moddi3.o qdivrem.o 11 12NM?= nm 13 14# A value of 0x80 enables LBA support. 15B1FLAGS= 0x80 16 17BOOT_COMCONSOLE_PORT?= 0x3f8 18BOOT_COMCONSOLE_SPEED?= 9600 19B2SIOFMT?= 0x3 20 21.if exists(${.OBJDIR}/../btx) 22BTX= ${.OBJDIR}/../btx 23.else 24BTX= ${.CURDIR}/../btx 25.endif 26 27REL1= 0x700 28ORG1= 0x7c00 29ORG2= 0x1000 30 31# Setting this to anything else gives UFS1+2 support and larger 32# boot2 binary. 33BOOT2_UFS?= UFS1_ONLY 34 35CFLAGS= -elf -ffreestanding -Os -fno-builtin \ 36 -fno-guess-branch-probability \ 37 -mrtd \ 38 -I${.CURDIR}/../../common \ 39 -I${.CURDIR}/../btx/lib -I. \ 40 -Wall -Waggregate-return -Wbad-function-cast -Wcast-align \ 41 -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ 42 -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings 43 44.if ${BOOT2_UFS} == "UFS1_ONLY" 45CFLAGS+= -D${BOOT2_UFS} 46.else 47 48.endif 49 50LDFLAGS=-nostdlib -static -N 51 52all: boot1 boot2 53 54boot1: boot1.out 55 objcopy -S -O binary boot1.out ${.TARGET} 56 57boot1.out: boot1.o 58 ${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o 59 60boot1.o: boot1.s 61 ${CPP} ${CFLAGS} ${.IMPSRC} | \ 62 ${AS} ${AFLAGS} --defsym FLAGS=${B1FLAGS} -o ${.TARGET} 63 64boot2.o: boot2.c ${.CURDIR}/../../common/ufsread.c 65 ${CC} ${CFLAGS} -S -o boot2.s.tmp ${.IMPSRC} 66 sed -e '/align/d' -e '/nop/d' < boot2.s.tmp > boot2.s 67 rm -f boot2.s.tmp 68 ${AS} ${AFLAGS} -o boot2.o boot2.s 69 70boot2.h: boot1.out 71 ${NM} -t d ${.ALLSRC} | awk '/([0-9])+ T xread/ \ 72 { x = $$1 - ORG1; \ 73 printf("#define XREADORG %#x\n", REL1 + x) }' \ 74 ORG1=`printf "%d" ${ORG1}` > boot2.h 75 76boot2: boot2.ldr boot2.bin ${BTX}/btx/btx 77 btxld -v -E ${ORG2} -f bin -b ${BTX}/btx/btx -l boot2.ldr \ 78 -o boot2.ld -P 1 boot2.bin 79.if ${BOOT2_UFS} == "UFS1_ONLY" 80 @ls -l boot2.ld | awk '{ x = 7680 - $$5; \ 81 print x " bytes available"; if (x < 0) exit 1 }' 82 dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync 2>/dev/null 83.else 84 @ls -l boot2.ld | awk '{ x = 9728 - $$5; \ 85 print x " bytes available"; if (x < 0) exit 1 }' 86 dd if=boot2.ld of=${.TARGET} obs=9728 conv=osync 2>/dev/null 87.endif 88 89boot2.ldr: 90 dd if=/dev/zero of=${.TARGET} bs=512 count=1 2>/dev/null 91 92boot2.bin: boot2.out 93 objcopy -S -O binary boot2.out ${.TARGET} 94 95.if ${BOOT2_UFS} == "UFS1_ONLY" 96boot2.out: boot2.o sio.o 97.else 98boot2.out: boot2.o sio.o divdi3.o moddi3.o qdivrem.o 99.endif 100 ${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} \ 101 ${BTX}/lib/crt0.o ${.ALLSRC} 102 103boot2.o: boot2.h 104 105sio.o: sio.s 106 ${AS} ${AFLAGS} --defsym SIOPRT=${BOOT_COMCONSOLE_PORT} \ 107 --defsym SIOFMT=${B2SIOFMT} \ 108 --defsym SIOSPD=${BOOT_COMCONSOLE_SPEED} \ 109 ${.IMPSRC} -o ${.TARGET} 110 111moddi3.o: ${.CURDIR}/../../../libkern/moddi3.c 112 ${CC} ${CFLAGS} -I${.CURDIR}/../../../ -c ${.IMPSRC} 113 114divdi3.o: ${.CURDIR}/../../../libkern/divdi3.c 115 ${CC} ${CFLAGS} -I${.CURDIR}/../../../ -c ${.IMPSRC} 116 117qdivrem.o: ${.CURDIR}/../../../libkern/qdivrem.c 118 ${CC} ${CFLAGS} -I${.CURDIR}/../../../ -c ${.IMPSRC} 119 120install: 121 ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 122 boot1 ${DESTDIR}${BINDIR}/boot1 123 ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 124 boot2 ${DESTDIR}${BINDIR}/boot2 125 126.include <bsd.prog.mk> 127