Makefile revision 225530
1# $FreeBSD: head/sys/boot/i386/gptboot/Makefile 225530 2011-09-13 14:03:55Z avg $
2
3.PATH:		${.CURDIR}/../boot2 ${.CURDIR}/../common ${.CURDIR}/../../common
4
5FILES=		gptboot
6
7NM?=		nm
8
9BOOT_COMCONSOLE_PORT?= 0x3f8
10BOOT_COMCONSOLE_SPEED?= 9600
11B2SIOFMT?=	0x3
12
13REL1=	0x700
14ORG1=	0x7c00
15ORG2=	0x0
16
17# Decide level of UFS support.
18GPTBOOT_UFS?=	UFS1_AND_UFS2
19#GPTBOOT_UFS?=	UFS2_ONLY
20#GPTBOOT_UFS?=	UFS1_ONLY
21
22CFLAGS=	-DBOOTPROG=\"gptboot\" \
23	-O1 \
24	-DGPT \
25	-D${GPTBOOT_UFS} \
26	-DSIOPRT=${BOOT_COMCONSOLE_PORT} \
27	-DSIOFMT=${B2SIOFMT} \
28	-DSIOSPD=${BOOT_COMCONSOLE_SPEED} \
29	-I${.CURDIR}/../../common \
30	-I${.CURDIR}/../common \
31	-I${.CURDIR}/../btx/lib -I. \
32	-I${.CURDIR}/../boot2 \
33	-I${.CURDIR}/../../.. \
34	-Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
35	-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
36	-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \
37	-Winline --param max-inline-insns-single=100
38
39.if ${CC:T:Mclang} == "clang"
40# XXX: clang integrated-as doesn't grok .codeNN directives yet
41CFLAGS+=	${.IMPSRC:T:Mgptldr.S:C/^.+$/-no-integrated-as/}
42.endif
43
44LDFLAGS=-static -N --gc-sections
45
46# Pick up ../Makefile.inc early.
47.include <bsd.init.mk>
48
49CLEANFILES=	gptboot
50
51gptboot: gptldr.bin gptboot.bin ${BTXKERN}
52	btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l gptldr.bin \
53	    -o ${.TARGET} gptboot.bin
54
55CLEANFILES+=	gptldr.bin gptldr.out gptldr.o
56
57gptldr.bin: gptldr.out
58	objcopy -S -O binary gptldr.out ${.TARGET}
59
60gptldr.out: gptldr.o
61	${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} gptldr.o
62
63CLEANFILES+=	gptboot.bin gptboot.out gptboot.o sio.o gpt.o crc32.o drv.o \
64		cons.o util.o
65
66gptboot.bin: gptboot.out
67	objcopy -S -O binary gptboot.out ${.TARGET}
68
69gptboot.out: ${BTXCRT} gptboot.o sio.o gpt.o crc32.o drv.o cons.o util.o
70	${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBSTAND}
71
72gptboot.o: ${.CURDIR}/../../common/ufsread.c
73
74.if ${MACHINE_CPUARCH} == "amd64"
75beforedepend gptboot.o: machine
76CLEANFILES+=	machine
77machine:
78	ln -sf ${.CURDIR}/../../../i386/include machine
79.endif
80
81.include <bsd.prog.mk>
82