1293297Semaste# $FreeBSD$
2293297Semaste
3293297SemasteMAN=
4293297Semaste
5293297Semaste.include <bsd.own.mk>
6293297Semaste
7293297SemasteMK_SSP=		no
8293297Semaste
9293297SemastePROG=		loader.sym
10293297SemasteINTERNALPROG=
11294981SsmhWARNS?=		3
12293297Semaste
13293297Semaste# architecture-specific loader code
14293297SemasteSRCS=	autoload.c \
15293297Semaste	bootinfo.c \
16293297Semaste	conf.c \
17293297Semaste	copy.c \
18293297Semaste	devicename.c \
19293297Semaste	main.c \
20293303Semaste	smbios.c \
21293297Semaste	vers.c
22293297Semaste
23294999Ssmh.if ${MK_ZFS} != "no"
24294999SsmhSRCS+=		zfs.c
25294999Ssmh.PATH:		${.CURDIR}/../../zfs
26294999Ssmh
27294999Ssmh# Disable warnings that are currently incompatible with the zfs boot code
28294999SsmhCWARNFLAGS.zfs.c+=	-Wno-sign-compare
29294999SsmhCWARNFLAGS.zfs.c+=	-Wno-array-bounds
30294999SsmhCWARNFLAGS.zfs.c+=	-Wno-missing-prototypes
31294999Ssmh.endif
32294999Ssmh
33293347Semaste.PATH: ${.CURDIR}/arch/${MACHINE}
34293303Semaste# For smbios.c
35293303Semaste.PATH: ${.CURDIR}/../../i386/libi386
36293347Semaste.include "${.CURDIR}/arch/${MACHINE}/Makefile.inc"
37293297Semaste
38293297SemasteCFLAGS+=	-fPIC
39293297SemasteCFLAGS+=	-I${.CURDIR}
40293347SemasteCFLAGS+=	-I${.CURDIR}/arch/${MACHINE}
41293297SemasteCFLAGS+=	-I${.CURDIR}/../include
42293347SemasteCFLAGS+=	-I${.CURDIR}/../include/${MACHINE}
43293297SemasteCFLAGS+=	-I${.CURDIR}/../../../contrib/dev/acpica/include
44293297SemasteCFLAGS+=	-I${.CURDIR}/../../..
45293303SemasteCFLAGS+=	-I${.CURDIR}/../../i386/libi386
46294999Ssmh.if ${MK_ZFS} != "no"
47294999SsmhCFLAGS+=	-I${.CURDIR}/../../zfs
48294999SsmhCFLAGS+=	-I${.CURDIR}/../../../cddl/boot/zfs
49294999SsmhCFLAGS+=	-DEFI_ZFS_BOOT
50294999Ssmh.endif
51293303SemasteCFLAGS+=	-DNO_PCI -DEFI
52293297Semaste
53304507Sjhb.if !defined(BOOT_HIDE_SERIAL_NUMBERS)
54304507Sjhb# Export serial numbers, UUID, and asset tag from loader.
55304507SjhbCFLAGS+= -DSMBIOS_SERIAL_NUMBERS
56304507Sjhb.if defined(BOOT_LITTLE_ENDIAN_UUID)
57304507Sjhb# Use little-endian UUID format as defined in SMBIOS 2.6.
58304507SjhbCFLAGS+= -DSMBIOS_LITTLE_ENDIAN_UUID
59304507Sjhb.elif defined(BOOT_NETWORK_ENDIAN_UUID)
60304507Sjhb# Use network-endian UUID format for backward compatibility.
61304507SjhbCFLAGS+= -DSMBIOS_NETWORK_ENDIAN_UUID
62304507Sjhb.endif
63304507Sjhb.endif
64304507Sjhb
65293297Semaste.if ${MK_FORTH} != "no"
66293297SemasteBOOT_FORTH=	yes
67293297SemasteCFLAGS+=	-DBOOT_FORTH
68293297SemasteCFLAGS+=	-I${.CURDIR}/../../ficl
69293347SemasteCFLAGS+=	-I${.CURDIR}/../../ficl/${MACHINE}
70293297SemasteLIBFICL=	${.OBJDIR}/../../ficl/libficl.a
71293297Semaste.endif
72293297Semaste
73293297Semaste# Include bcache code.
74293297SemasteHAVE_BCACHE=    yes
75293297Semaste
76293297Semaste.if defined(EFI_STAGING_SIZE)
77293297SemasteCFLAGS+=	-DEFI_STAGING_SIZE=${EFI_STAGING_SIZE}
78293297Semaste.endif
79293297Semaste
80297555Smarius# Always add MI sources
81293297Semaste.PATH:		${.CURDIR}/../../common
82293297Semaste.include	"${.CURDIR}/../../common/Makefile.inc"
83293297SemasteCFLAGS+=	-I${.CURDIR}/../../common
84293297Semaste
85293297SemasteFILES=	loader.efi
86293297SemasteFILESMODE_loader.efi=	${BINMODE}
87293297Semaste
88293347SemasteLDSCRIPT=	${.CURDIR}/arch/${MACHINE}/ldscript.${MACHINE}
89293297SemasteLDFLAGS=	-Wl,-T${LDSCRIPT} -Wl,-Bsymbolic -shared -Wl,-znocombreloc
90293297Semaste
91293297SemasteCLEANFILES=	vers.c loader.efi
92293297Semaste
93293347SemasteNEWVERSWHAT=	"EFI loader" ${MACHINE}
94293297Semaste
95293297Semastevers.c:	${.CURDIR}/../../common/newvers.sh ${.CURDIR}/../../efi/loader/version
96293297Semaste	sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT}
97293297Semaste
98297821SemasteNM?=		nm
99293297SemasteOBJCOPY?=	objcopy
100293297Semaste
101293297Semaste.if ${MACHINE_CPUARCH} == "amd64"
102293297SemasteEFI_TARGET=	efi-app-x86_64
103293297Semaste.elif ${MACHINE_CPUARCH} == "i386"
104293297SemasteEFI_TARGET=	efi-app-ia32
105293297Semaste.endif
106293297Semaste
107294268Semasteloader.efi: ${PROG}
108297821Semaste	if ${NM} ${.ALLSRC} | grep ' U '; then \
109297821Semaste		echo "Undefined symbols in ${.ALLSRC}"; \
110293297Semaste		exit 1; \
111293297Semaste	fi
112293297Semaste	${OBJCOPY} -j .text -j .sdata -j .data \
113293297Semaste		-j .dynamic -j .dynsym -j .rel.dyn \
114293297Semaste		-j .rela.dyn -j .reloc -j .eh_frame -j set_Xcommand_set \
115293297Semaste		--output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET}
116293297Semaste
117293297SemasteLIBEFI=		${.OBJDIR}/../libefi/libefi.a
118293297Semaste
119293297SemasteDPADD=		${LIBFICL} ${LIBEFI} ${LIBSTAND} ${LDSCRIPT}
120293297SemasteLDADD=		${LIBFICL} ${LIBEFI} ${LIBSTAND}
121293297Semaste
122293297Semaste.include <bsd.prog.mk>
123293297Semaste
124293297Semastebeforedepend ${OBJS}: machine x86
125293297Semaste
126293297SemasteCLEANFILES+=   machine x86
127293297Semaste
128293297Semastemachine:
129293297Semaste	ln -sf ${.CURDIR}/../../../amd64/include machine
130293297Semaste
131293297Semastex86:
132293297Semaste	ln -sf ${.CURDIR}/../../../x86/include x86
133