Makefile revision 104632
1199482Srdivacky# $FreeBSD: head/sys/boot/i386/gptboot/Makefile 104632 2002-10-07 20:56:09Z phk $ 2199482Srdivacky 3199482SrdivackyPROG= boot2 4199482SrdivackyNOMAN= 5199482SrdivackySTRIP= 6199482SrdivackyBINDIR?= /boot 7199482SrdivackyBINMODE= 444 8199482SrdivackyCLEANFILES+= boot1 boot1.out boot1.o \ 9199482Srdivacky boot2.ldr boot2.bin boot2.ld boot2.out boot2.o boot2.h \ 10199482Srdivacky boot2.s sio.o 11199482Srdivacky 12199482SrdivackyNM?= nm 13199482Srdivacky 14199482Srdivacky# A value of 0x80 enables LBA support. 15199482SrdivackyB1FLAGS= 0x80 16199482Srdivacky 17199482SrdivackyBOOT_COMCONSOLE_PORT?= 0x3f8 18199482SrdivackyBOOT_COMCONSOLE_SPEED?= 9600 19199482SrdivackyB2SIOFMT?= 0x3 20199482Srdivacky 21199482Srdivacky.if exists(${.OBJDIR}/../btx) 22199482SrdivackyBTX= ${.OBJDIR}/../btx 23199482Srdivacky.else 24199482SrdivackyBTX= ${.CURDIR}/../btx 25199482Srdivacky.endif 26199482Srdivacky 27199482SrdivackyORG1= 0x7c00 28199482SrdivackyORG2= 0x1000 29199482Srdivacky 30199482SrdivackyCFLAGS= -elf -ffreestanding -Os -fno-builtin \ 31199482Srdivacky -fno-guess-branch-probability \ 32199482Srdivacky -mrtd \ 33199482Srdivacky -I${.CURDIR}/../../common \ 34199482Srdivacky -I${.CURDIR}/../btx/lib -I. \ 35199482Srdivacky -Wall -Waggregate-return -Wbad-function-cast -Wcast-align \ 36199482Srdivacky -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ 37199482Srdivacky -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings 38 39CFLAGS+= -DUFS1_ONLY 40 41LDFLAGS=-nostdlib -static -N 42 43all: boot1 boot2 44 45boot1: boot1.out 46 objcopy -S -O binary boot1.out ${.TARGET} 47 48boot1.out: boot1.o 49 ${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o 50 51boot1.o: boot1.s 52 ${CPP} ${CFLAGS} ${.IMPSRC} | \ 53 ${AS} ${AFLAGS} --defsym FLAGS=${B1FLAGS} -o ${.TARGET} 54 55boot2.o: boot2.c ${.CURDIR}/../../common/ufsread.c 56 ${CC} ${CFLAGS} -S -o boot2.s.tmp ${.IMPSRC} 57 sed -e '/align/d' -e '/nop/d' < boot2.s.tmp > boot2.s 58 rm -f boot2.s.tmp 59 ${AS} ${AFLAGS} -o boot2.o boot2.s 60 61boot2.h: boot1.out 62 ${NM} -t d ${.ALLSRC} | awk '/([0-9])+ T xread/ \ 63 { x = $$1 - ORG1; printf("#define XREADORG 0x7%x\n", x) }' \ 64 ORG1=`printf "%d" ${ORG1}` > boot2.h 65 66boot2: boot2.ldr boot2.bin ${BTX}/btx/btx 67 btxld -v -E ${ORG2} -f bin -b ${BTX}/btx/btx -l boot2.ldr \ 68 -o boot2.ld -P 1 boot2.bin 69 @ls -l boot2.ld | awk '{ x = 7680 - $$5; \ 70 print x " bytes available"; if (x < 0) exit 1 }' 71 dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync 2>/dev/null 72 73boot2.ldr: 74 dd if=/dev/zero of=${.TARGET} bs=512 count=1 2>/dev/null 75 76boot2.bin: boot2.out 77 objcopy -S -O binary boot2.out ${.TARGET} 78 79boot2.out: boot2.o sio.o 80 ${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} \ 81 ${BTX}/lib/crt0.o boot2.o sio.o 82 83boot2.o: boot2.h 84 85sio.o: sio.s 86 ${AS} ${AFLAGS} --defsym SIOPRT=${BOOT_COMCONSOLE_PORT} \ 87 --defsym SIOFMT=${B2SIOFMT} \ 88 --defsym SIOSPD=${BOOT_COMCONSOLE_SPEED} \ 89 ${.IMPSRC} -o ${.TARGET} 90 91install: 92 ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 93 boot1 ${DESTDIR}${BINDIR}/boot1 94 ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 95 boot2 ${DESTDIR}${BINDIR}/boot2 96 97.include <bsd.prog.mk> 98