1efi.mk(3) Library Functions Manual efi.mk(3)
2
3
4
6 efi.mk
7
9 include efi.mk
10
12 The gnu-efi library provides a set of makefiles which produce EFI
13 binaries on the supported platforms, as well as a number of make
14 variables which can be set to control how each step gets built. These
15 can be set in your makefile or on the command line, but are normally
16 set to reasonable defaults. Usually you'll just want to use the +=
17 operator, as shown in the EXAMPLES section below, rather than fully
18 replacing these.
19
20 make variables
21 EFI_ARCH_CFLAGS
22 Architecture specific gcc command line options for building
23 a .efi.o
24
25 EFI_ARCH_LDFLAGS
26 Architecture specific ld command line options for building
27 the .efi.so
28
29 EFI_ARCH_FORMAT
30 Architecture specific objcopy arguments for building the
31 final .efi binary
32
33 CROSS_COMPILE
34 Compiler prefix for cross-compilation. For example,
35 "aarch64-linux-gnu-".
36
37 EFI_CC
38 The C compiler. Defaults to either $(CROSS_COMPILE)gcc or
39 $(CROSS_COMPILE)clang, depending on what $(CC) was set to
40 when gnu-efi was built.
41
42 EFI_HOSTCC
43 Defaults to whatever $(CC) was set to when gnu-efi was
44 built.
45
46 EFI_HOSTARCH
47 One of aa64, arm, ia32, ia64, x64, or mips64el, representing
48 the EFI architecture name of the host machine during the
49 build.
50
51 EFI_ARCH
52 One of aa64, arm, ia32, ia64, x64, or mips64el, representing
53 the EFI architecture name of the target.
54
55 EFI_BFDARCH
56 The architecture name for the BFD target for objcopy.
57
58 EFI_ARCH_3264
59 Usually empty; if you're cross compiling, this will default
60 to e.g. -m64 if you're building for an x64 target on an i686
61 host.
62
63 EFI_CC_INCLUDES
64 The list of default include path for the compiler, as a gcc
65 command line argument. Defaults to the output of $(EFI_CC)
66 $(EFI_ARCH_3264) -print-file-name=include, for example
67 /usr/lib/gcc/x86_64-redhat-linux/9/include. Note that there
68 is no -I prefix on these.
69
70 EFI_INCLUDES
71 The gnu-efi include paths. Note that there is no -I prefix
72 on these.
73
74 EFI_CPPFLAGS
75 Flags passed to gcc regardless of the build target.
76
77 EFI_CFLAGS
78 Flags passed to gcc for building any binary target.
79 Defaults to $(EFI_CPPFLAGS) $(EFI_ARCH_CFLAGS).
80
81 EFI_LDSCRIPT
82 The linker script passed to ld -T for linking .efi.so build
83 targets. Defaults to /usr/lib/gnuefi/$(EFI_ARCH)/efi.lds.
84
85 EFI_LIBGCC
86 The path to libgcc. Defaults to the result of $(EFI_CC)
87 $(EFI_ARCH_3264) -print-libgcc-file-name
88
89 EFI_LDFLAGS
90 Other command line to pass to ld before object names.
91 Defaults to -nostdlib --warn-common --no-undefined --fatal-
92 warnings --build-id=sha1 -shared -Bsymbolic
93 -L/usr/lib/gnuefi/$(EFI_ARCH)
94 /usr/lib/gnuefi/$(EFI_ARCH)/crt0.o
95
96 EFI_CCLDFLAGS
97 Normally derived from $(EFI_LDFLAGS).
98
99 EFI_LDLIBS
100 Libraries to pass to ld after target object names. Defaults
101 to -lefi -lgnuefi $(EFI_LIBGCC) -T $(EFI_LDSCRIPT)
102
103 EFI_CCLDLIBS
104 Derived from $(EFI_LDLIBS).
105
106 EFI_ARFLAGS
107 Flags to pass to ar to make a .efi.a target. Defaults to
108 "rDv".
109
110 EFI_ASFLAGS
111 Flags to pass to gcc to make a .efi.o object from a .S file.
112
113 EFI_OBJCOPY_FLAGS
114 Flags to pass to objcopy to make a .efi binary target.
115 Defaults to --file-alignment 512 --section-alignment 4096 -D
116
117 EFI_BIN_SECTIONS
118 Names of sections to go into .efi binary targets. If you
119 have special sections, add them here.
120
121 EFI_DEBUG_SECTIONS
122 Names of sections to go into .efi.debug targets. If you
123 have special debug sections, add them here.
124
125 In addition, there are several make rules defined, which those
126 variables affect
127 as appropriate:
128
129 %.efi : %.efi.so
130 Build a .efi binary
131
132 %.efi.debug : %efi.so
133 Build debuginfo
134
135 %.efi.so :
136 Build the intermediate .efi.so to be linked as a .efi
137 binary. Add .o files as dependencies to a concrete .efi.so
138 rule in order to define targets.
139
140 %.efi.a :
141 Build an intermediate archive file for linking into a
142 .efi.so
143
144 %.efi.o : %.c
145 Build an object file from a .c file
146
147 %.efi.o : %.S
148 Build an object file from a .S file
149
150 efi_clean :
151 Remove all files in the current working directory with the
152 suffixes .efi, .efi.a, .efi.debug, .efi.o, or .efi.so.
153
155 This is a simple makefile used to build an EFI binary named foo.efi
156 from source files foo.c and bar.c. It includes the special section
157 .weird in the final binary, and the name of that is defined within the
158 .c source files using the macro WEIRD_SECTION_NAME:
159
160 include efi.mk
161
162 all : foo.efi
163
164 %.efi.o : | EFI_CFLAGS+=-DWEIRD_SECTION_NAME=\".weird\"
165
166 foo.efi : | EFI_BIN_SECTIONS+=.weird
167 foo.efi.so : foo.efi.o bar.efi.o
168
169 clean : efi_clean
170
171 The following example shows how to cross-compile a binary for another
172 architecture (in this case, ARM Aarch64, which EFI calls aa64). This
173 assumes that you have the crt0.o, efi.lds, libgnuefi.a, and libefi.a
174 files for Aarch64 installed in /usr/lib/gnuefi/aa64/.
175
176 $ make CROSS_COMPILE=aarch64-linux-gnu- EFI_ARCH=aa64 foo.efi
177
179 Peter Jones <pjones@redhat.com>
180
181
182
183 Thu Nov 21 2019 efi.mk(3)