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