]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/boot/efi/loader/Makefile
MFC Loader Fixes 2017q2: r316437,r316577,r316578,r316585,r316590,r316612,
[FreeBSD/FreeBSD.git] / sys / boot / efi / loader / Makefile
1 # $FreeBSD$
2
3 MAN=
4
5 .include <src.opts.mk>
6
7 MK_SSP=         no
8
9 PROG=           loader.sym
10 INTERNALPROG=
11 WARNS?=         3
12 LOADER_NET_SUPPORT?=    yes
13
14 # architecture-specific loader code
15 SRCS=   autoload.c \
16         bootinfo.c \
17         conf.c \
18         copy.c \
19         devicename.c \
20         main.c \
21         self_reloc.c \
22         smbios.c \
23         vers.c
24
25 .if ${MK_ZFS} != "no"
26 SRCS+=          zfs.c
27 .PATH:          ${.CURDIR}/../../zfs
28 SRCS+=          skein.c skein_block.c
29 # Do not unroll skein loops, reduce code size
30 CFLAGS+=        -DSKEIN_LOOP=111
31 .PATH:          ${.CURDIR}/../../../crypto/skein
32
33 # Disable warnings that are currently incompatible with the zfs boot code
34 CWARNFLAGS.zfs.c+=      -Wno-sign-compare
35 CWARNFLAGS.zfs.c+=      -Wno-array-bounds
36 CWARNFLAGS.zfs.c+=      -Wno-missing-prototypes
37 .endif
38
39 .if defined(LOADER_NET_SUPPORT)
40 CFLAGS+=        -I${.CURDIR}/../../../../lib/libstand
41 .endif
42
43 .if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} > 40201
44 CWARNFLAGS.self_reloc.c+=       -Wno-error=maybe-uninitialized
45 .endif
46
47 # We implement a slightly non-standard %S in that it always takes a
48 # CHAR16 that's common in UEFI-land instead of a wchar_t. This only
49 # seems to matter on arm64 where wchar_t defaults to an int instead
50 # of a short. There's no good cast to use here so just ignore the
51 # warnings for now.
52 CWARNFLAGS.main.c+=     -Wno-format
53
54 .PATH: ${.CURDIR}/arch/${MACHINE}
55 # For smbios.c
56 .PATH: ${.CURDIR}/../../i386/libi386
57 .include "${.CURDIR}/arch/${MACHINE}/Makefile.inc"
58
59 CFLAGS+=        -I${.CURDIR}
60 CFLAGS+=        -I${.CURDIR}/arch/${MACHINE}
61 CFLAGS+=        -I${.CURDIR}/../include
62 CFLAGS+=        -I${.CURDIR}/../include/${MACHINE}
63 CFLAGS+=        -I${.CURDIR}/../../../contrib/dev/acpica/include
64 CFLAGS+=        -I${.CURDIR}/../../..
65 CFLAGS+=        -I${.CURDIR}/../../i386/libi386
66 .if ${MK_ZFS} != "no"
67 CFLAGS+=        -I${.CURDIR}/../../zfs
68 CFLAGS+=        -I${.CURDIR}/../../../cddl/boot/zfs
69 CFLAGS+=        -I${.CURDIR}/../../../crypto/skein
70 CFLAGS+=        -DEFI_ZFS_BOOT
71 .endif
72 CFLAGS+=        -DNO_PCI -DEFI
73
74 # make buildenv doesn't set DESTDIR, this means LIBSTAND
75 # will be wrong when crossbuilding.
76 .if exists(${.OBJDIR}/../../../../lib/libstand/libstand.a)
77 LIBSTAND=       ${.OBJDIR}/../../../../lib/libstand/libstand.a
78 .endif
79
80 .if !defined(BOOT_HIDE_SERIAL_NUMBERS)
81 # Export serial numbers, UUID, and asset tag from loader.
82 CFLAGS+= -DSMBIOS_SERIAL_NUMBERS
83 .if defined(BOOT_LITTLE_ENDIAN_UUID)
84 # Use little-endian UUID format as defined in SMBIOS 2.6.
85 CFLAGS+= -DSMBIOS_LITTLE_ENDIAN_UUID
86 .elif defined(BOOT_NETWORK_ENDIAN_UUID)
87 # Use network-endian UUID format for backward compatibility.
88 CFLAGS+= -DSMBIOS_NETWORK_ENDIAN_UUID
89 .endif
90 .endif
91
92 .if ${MK_FORTH} != "no"
93 BOOT_FORTH=     yes
94 CFLAGS+=        -DBOOT_FORTH
95 CFLAGS+=        -I${.CURDIR}/../../ficl
96 CFLAGS+=        -I${.CURDIR}/../../ficl/${MACHINE_CPUARCH}
97 LIBFICL=        ${.OBJDIR}/../../ficl/libficl.a
98 .endif
99
100 LOADER_FDT_SUPPORT?=    no
101 .if ${MK_FDT} != "no" && ${LOADER_FDT_SUPPORT} != "no"
102 CFLAGS+=        -I${.CURDIR}/../../fdt
103 CFLAGS+=        -I${.OBJDIR}/../../fdt
104 CFLAGS+=        -DLOADER_FDT_SUPPORT
105 LIBEFI_FDT=     ${.OBJDIR}/../../efi/fdt/libefi_fdt.a
106 LIBFDT=         ${.OBJDIR}/../../fdt/libfdt.a
107 .endif
108
109 # Include bcache code.
110 HAVE_BCACHE=    yes
111
112 .if defined(EFI_STAGING_SIZE)
113 CFLAGS+=        -DEFI_STAGING_SIZE=${EFI_STAGING_SIZE}
114 .endif
115
116 # Always add MI sources
117 .PATH:          ${.CURDIR}/../../common
118 .include        "${.CURDIR}/../../common/Makefile.inc"
119 CFLAGS+=        -I${.CURDIR}/../../common
120
121 FILES+= loader.efi
122 FILESMODE_loader.efi=   ${BINMODE}
123
124 LDSCRIPT=       ${.CURDIR}/arch/${MACHINE}/ldscript.${MACHINE}
125 LDFLAGS+=       -Wl,-T${LDSCRIPT} -Wl,-Bsymbolic -shared
126
127 CLEANFILES+=    loader.efi
128
129 NEWVERSWHAT=    "EFI loader" ${MACHINE}
130
131 NM?=            nm
132 OBJCOPY?=       objcopy
133
134 .if ${MACHINE_CPUARCH} == "amd64"
135 EFI_TARGET=     efi-app-x86_64
136 .elif ${MACHINE_CPUARCH} == "i386"
137 EFI_TARGET=     efi-app-ia32
138 .else
139 EFI_TARGET=     binary
140 .endif
141
142 # Arbitrarily set the PE/COFF header timestamps to 1 Jan 2016 00:00:00
143 # for build reproducibility.
144 SOURCE_DATE_EPOCH?=1451606400
145 loader.efi: ${PROG}
146         if ${NM} ${.ALLSRC} | grep ' U '; then \
147                 echo "Undefined symbols in ${.ALLSRC}"; \
148                 exit 1; \
149         fi
150         SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \
151         ${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \
152                 -j .dynamic -j .dynsym -j .rel.dyn \
153                 -j .rela.dyn -j .reloc -j .eh_frame -j set_Xcommand_set \
154                 -j set_Xficl_compile_set \
155                 --output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET}
156
157 LIBEFI=         ${.OBJDIR}/../libefi/libefi.a
158
159 DPADD=          ${LIBFICL} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} ${LIBSTAND} \
160                 ${LDSCRIPT}
161 LDADD=          ${LIBFICL} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} ${LIBSTAND}
162
163 .include <bsd.prog.mk>
164
165 beforedepend ${OBJS}: machine
166
167 CLEANFILES+=   machine
168
169 machine: .NOMETA
170         ln -sf ${.CURDIR}/../../../${MACHINE}/include machine
171
172 .if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
173 beforedepend ${OBJS}: x86
174 CLEANFILES+=   x86
175
176 x86: .NOMETA
177         ln -sf ${.CURDIR}/../../../x86/include x86
178 .endif