Makefile revision 276146
1264391Snwhitehorn# $FreeBSD: head/sys/boot/amd64/boot1.efi/Makefile 276146 2014-12-23 15:58:45Z emaste $
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.
20264391SnwhitehornCFLAGS+=	-I${.CURDIR}/../../efi/include
21264391SnwhitehornCFLAGS+=	-I${.CURDIR}/../../efi/include/${MACHINE_CPUARCH}
22264391SnwhitehornCFLAGS+=	-I${.CURDIR}/../../../contrib/dev/acpica/include
23264391SnwhitehornCFLAGS+=	-I${.CURDIR}/../../..
24264391Snwhitehorn
25264403Snwhitehorn# Always add MI sources and REGULAR efi loader bits
26264403Snwhitehorn.PATH:		${.CURDIR}/../efi ${.CURDIR}/../../common
27264391SnwhitehornCFLAGS+=	-I${.CURDIR}/../../common
28264391Snwhitehorn
29264975SnwhitehornFILES=	boot1.efi boot1.efifat
30264391SnwhitehornFILESMODE_boot1.efi=	${BINMODE}
31264391Snwhitehorn
32264391SnwhitehornLDSCRIPT=	${.CURDIR}/../efi/ldscript.${MACHINE_CPUARCH}
33264391SnwhitehornLDFLAGS=	-Wl,-T${LDSCRIPT} -Wl,-Bsymbolic -shared -Wl,-znocombreloc
34264391Snwhitehorn
35264391Snwhitehorn${PROG}:	${LDSCRIPT}
36264391Snwhitehorn
37264391SnwhitehornOBJCOPY?=	objcopy
38264391SnwhitehornOBJDUMP?=	objdump
39264391Snwhitehorn
40264391Snwhitehorn.if ${MACHINE_CPUARCH} == "amd64"
41264391SnwhitehornEFI_TARGET=	efi-app-x86_64
42264391Snwhitehorn.else
43264391SnwhitehornEFI_TARGET=	efi-app-ia32
44264391Snwhitehorn.endif
45264391Snwhitehorn
46264391Snwhitehornboot1.efi: loader.sym
47264391Snwhitehorn	if [ `${OBJDUMP} -t ${.ALLSRC} | fgrep '*UND*' | wc -l` != 0 ]; then \
48264391Snwhitehorn		${OBJDUMP} -t ${.ALLSRC} | fgrep '*UND*'; \
49264391Snwhitehorn		exit 1; \
50264391Snwhitehorn	fi
51264391Snwhitehorn	${OBJCOPY} -j .text -j .sdata -j .data \
52264391Snwhitehorn		-j .dynamic -j .dynsym -j .rel.dyn \
53264391Snwhitehorn		-j .rela.dyn -j .reloc -j .eh_frame -j set_Xcommand_set \
54276146Semaste		--output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET}
55264391Snwhitehorn
56264391SnwhitehornCFLAGS+=	-I${.CURDIR}/../../common
57264391Snwhitehorn
58264414Snwhitehornboot1.o: ${.CURDIR}/../../common/ufsread.c
59264414Snwhitehorn
60264975Snwhitehorn# The following inserts out objects into a template FAT file system
61264975Snwhitehorn# created by generate-fat.sh
62264975Snwhitehorn
63264975Snwhitehorn.include "${.CURDIR}/Makefile.fat"
64264975Snwhitehorn
65264975Snwhitehornboot1.efifat: boot1.efi
66264975Snwhitehorn	echo ${.OBJDIR}
67264975Snwhitehorn	uudecode ${.CURDIR}/fat.tmpl.bz2.uu
68264975Snwhitehorn	mv fat.tmpl.bz2 ${.TARGET}.bz2
69264975Snwhitehorn	bzip2 -f -d ${.TARGET}.bz2
70264975Snwhitehorn	dd if=boot1.efi of=${.TARGET} seek=${BOOT1_OFFSET} conv=notrunc
71264975Snwhitehorn
72264975SnwhitehornCLEANFILES= boot1.efifat
73264975Snwhitehorn
74264391Snwhitehorn.endif # ${COMPILER_TYPE} != "gcc"
75264391Snwhitehorn
76264391Snwhitehorn.include <bsd.prog.mk>
77264391Snwhitehorn
78264391Snwhitehornbeforedepend ${OBJS}: machine x86
79264391Snwhitehorn
80268975SsbrunoCLEANFILES+=   machine x86 boot1.efi
81264391Snwhitehorn
82264391Snwhitehornmachine:
83264391Snwhitehorn	ln -sf ${.CURDIR}/../../../amd64/include machine
84264391Snwhitehorn
85264391Snwhitehornx86:
86264391Snwhitehorn	ln -sf ${.CURDIR}/../../../x86/include x86
87