Makefile revision 281156
1264391Snwhitehorn# $FreeBSD: head/sys/boot/efi/boot1/Makefile 281156 2015-04-06 15:50:20Z andrew $
2264391Snwhitehorn
3264925SimpMAN=
4264391Snwhitehorn
5264391Snwhitehorn.include <bsd.own.mk>
6264391Snwhitehorn
7264391Snwhitehorn# In-tree GCC does not support __attribute__((ms_abi)).
8264391Snwhitehorn.if ${COMPILER_TYPE} != "gcc"
9264391Snwhitehorn
10264391SnwhitehornMK_SSP=		no
11264391Snwhitehorn
12264391SnwhitehornPROG=		loader.sym
13264391SnwhitehornINTERNALPROG=
14264391Snwhitehorn
15264391Snwhitehorn# architecture-specific loader code
16264391SnwhitehornSRCS=	boot1.c reloc.c start.S
17264391Snwhitehorn
18264391SnwhitehornCFLAGS+=	-fPIC
19264391SnwhitehornCFLAGS+=	-I.
20280950SandrewCFLAGS+=	-I${.CURDIR}/../include
21280950SandrewCFLAGS+=	-I${.CURDIR}/../include/${MACHINE_CPUARCH}
22264391SnwhitehornCFLAGS+=	-I${.CURDIR}/../../../contrib/dev/acpica/include
23264391SnwhitehornCFLAGS+=	-I${.CURDIR}/../../..
24264391Snwhitehorn
25264403Snwhitehorn# Always add MI sources and REGULAR efi loader bits
26281027Sandrew.PATH:		${.CURDIR}/../loader/arch/${MACHINE_CPUARCH} ${.CURDIR}/../../common
27264391SnwhitehornCFLAGS+=	-I${.CURDIR}/../../common
28264391Snwhitehorn
29264975SnwhitehornFILES=	boot1.efi boot1.efifat
30264391SnwhitehornFILESMODE_boot1.efi=	${BINMODE}
31264391Snwhitehorn
32280950SandrewLDSCRIPT=	${.CURDIR}/../loader/arch/${MACHINE_CPUARCH}/ldscript.${MACHINE_CPUARCH}
33281027SandrewLDFLAGS=	-Wl,-T${LDSCRIPT} -Wl,-Bsymbolic -shared
34264391Snwhitehorn
35281027Sandrew.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
36281027SandrewLDFLAGS+=	-Wl,-znocombreloc
37281027Sandrew.endif
38281027Sandrew
39281156Sandrew.if ${MACHINE_CPUARCH} == "arm"
40281156Sandrew#
41281156Sandrew# Add libstand for the __aeabi_* functions used by the compiler
42281156Sandrew#
43281156SandrewDPADD+=		${LIBSTAND}
44281156SandrewLDADD+=		-lstand
45281156Sandrew.endif
46281156Sandrew
47264391Snwhitehorn${PROG}:	${LDSCRIPT}
48264391Snwhitehorn
49264391SnwhitehornOBJCOPY?=	objcopy
50264391SnwhitehornOBJDUMP?=	objdump
51264391Snwhitehorn
52264391Snwhitehorn.if ${MACHINE_CPUARCH} == "amd64"
53264391SnwhitehornEFI_TARGET=	efi-app-x86_64
54280950Sandrew.elif ${MACHINE_CPUARCH} == "i386"
55264391SnwhitehornEFI_TARGET=	efi-app-ia32
56281156Sandrew.else
57281156SandrewEFI_TARGET=	binary
58264391Snwhitehorn.endif
59264391Snwhitehorn
60264391Snwhitehornboot1.efi: loader.sym
61264391Snwhitehorn	if [ `${OBJDUMP} -t ${.ALLSRC} | fgrep '*UND*' | wc -l` != 0 ]; then \
62264391Snwhitehorn		${OBJDUMP} -t ${.ALLSRC} | fgrep '*UND*'; \
63264391Snwhitehorn		exit 1; \
64264391Snwhitehorn	fi
65281156Sandrew	${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \
66264391Snwhitehorn		-j .dynamic -j .dynsym -j .rel.dyn \
67264391Snwhitehorn		-j .rela.dyn -j .reloc -j .eh_frame -j set_Xcommand_set \
68276146Semaste		--output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET}
69264391Snwhitehorn
70264414Snwhitehornboot1.o: ${.CURDIR}/../../common/ufsread.c
71264414Snwhitehorn
72264975Snwhitehorn# The following inserts out objects into a template FAT file system
73264975Snwhitehorn# created by generate-fat.sh
74264975Snwhitehorn
75264975Snwhitehorn.include "${.CURDIR}/Makefile.fat"
76264975Snwhitehorn
77264975Snwhitehornboot1.efifat: boot1.efi
78264975Snwhitehorn	echo ${.OBJDIR}
79281156Sandrew	uudecode ${.CURDIR}/fat-${MACHINE_CPUARCH}.tmpl.bz2.uu
80281156Sandrew	mv fat-${MACHINE_CPUARCH}.tmpl.bz2 ${.TARGET}.bz2
81264975Snwhitehorn	bzip2 -f -d ${.TARGET}.bz2
82264975Snwhitehorn	dd if=boot1.efi of=${.TARGET} seek=${BOOT1_OFFSET} conv=notrunc
83264975Snwhitehorn
84281117SandrewCLEANFILES= boot1.efi boot1.efifat
85264975Snwhitehorn
86264391Snwhitehorn.endif # ${COMPILER_TYPE} != "gcc"
87264391Snwhitehorn
88264391Snwhitehorn.include <bsd.prog.mk>
89264391Snwhitehorn
90281027Sandrew.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
91264391Snwhitehornbeforedepend ${OBJS}: machine x86
92264391Snwhitehorn
93281117SandrewCLEANFILES+=   machine x86
94264391Snwhitehorn
95264391Snwhitehornmachine:
96264391Snwhitehorn	ln -sf ${.CURDIR}/../../../amd64/include machine
97264391Snwhitehorn
98264391Snwhitehornx86:
99264391Snwhitehorn	ln -sf ${.CURDIR}/../../../x86/include x86
100281027Sandrew.endif
101