-
Notifications
You must be signed in to change notification settings - Fork 34
/
Makefile.am
374 lines (299 loc) · 8.87 KB
/
Makefile.am
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
#
# EFI Boot Guard
#
# Copyright (c) Siemens AG, 2017
#
# Authors:
# Claudius Heine <[email protected]>
#
# This work is licensed under the terms of the GNU GPL, version 2. See
# the COPYING file in the top-level directory.
#
# SPDX-License-Identifier: GPL-2.0-only
#
# Based on Makefile.am of gummiboot,
# Copyright (C) 2013 Karel Zak <[email protected]>
#
ACLOCAL_AMFLAGS = -I m4 --install ${ACLOCAL_FLAGS}
AM_MAKEFLAGS = --no-print-directory
efibootguarddir = $(libdir)/efibootguard
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir) -include config.h
AM_CFLAGS = \
-Wall \
-Wextra \
-pedantic \
-Wstrict-prototypes \
-Wold-style-definition \
-Wmissing-prototypes \
-fshort-wchar \
-DHAVE_ENDIAN_H \
-D_GNU_SOURCE \
-D_FILE_OFFSET_BITS=64 \
-Werror
AM_LDFLAGS = -L$(top_builddir)/
ARFLAGS = cr
EXTRA_DIST = autogen.sh README LICENSE
CLEANFILES =
define shtab
$(AM_V_GEN) $(MKDIR_P) $(@D); \
PYTHONPATH=${top_srcdir}/completion/shtab:${top_srcdir}/completion \
@PYTHON@ -m shtab -u --shell=$1 $2 >$@
endef
define filechk
$(AM_V_at)set -e; \
echo ' CHK $@'; \
mkdir -p $(dir $@); \
$(filechk_$(1)) < $< > [email protected]; \
if [ -r $@ ] && cmp -s $@ [email protected]; then \
rm -f [email protected]; \
else \
echo ' UPD $@'; \
mv -f [email protected] $@; \
fi
endef
#
# Version header
#
define filechk_version
$(top_srcdir)/gen_version_h $(top_srcdir)/
endef
GEN_VERSION_H := $(top_builddir)/version.h
$(GEN_VERSION_H): $(top_srcdir)/Makefile.in FORCE
$(call filechk,version)
CLEANFILES += $(GEN_VERSION_H)
#
# pkg-config
#
pkgconfig_DATA = libebgenv.pc
CLEANFILES += libebgenv.pc
#
# Static libraries
#
lib_LIBRARIES = libebgenv.a
libebgenv_a_SOURCES = \
env/@[email protected] \
env/env_api.c \
env/env_api_crc32.c \
env/env_config_file.c \
env/env_config_partitions.c \
env/env_disk_utils.c \
env/uservars.c \
tools/ebgpart.c \
tools/fat.c
libebgenv_a_CPPFLAGS = \
$(AM_CPPFLAGS) \
-I$(top_srcdir)/tools
libebgenv_a_CFLAGS = \
$(AM_CFLAGS) \
-fPIC
pkginclude_HEADERS = \
include/ebgenv.h
#
# Shared libraries
#
lib_LTLIBRARIES = libebgenv.la
libebgenv_la_SOURCES = $(libebgenv_a_SOURCES)
libebgenv_la_LDFLAGS = -version-info 1:0:1
if ARCH_ARM
libebgenv_la_LDFLAGS += -Wl,--no-wchar-size-warning
endif
#
# bg_setenv binary
#
bin_PROGRAMS = bg_setenv
bg_setenv_SOURCES = \
tools/bg_setenv.c \
tools/bg_printenv.c \
tools/bg_envtools.c \
tools/main.c
bg_setenv_CFLAGS = \
$(AM_CFLAGS) -static
if ARCH_ARM
bg_setenv_LDFLAGS = -Wl,--no-wchar-size-warning
endif
bg_setenv_LDADD = \
$(top_builddir)/libebgenv.a
install-exec-hook:
$(AM_V_at)$(LN_S) -f bg_setenv$(EXEEXT) \
$(DESTDIR)$(bindir)/bg_printenv$(EXEEXT)
$(RM) $(DESTDIR)$(libdir)/$(lib_LTLIBRARIES)
#
# Unified kernel image generator script
#
bin_SCRIPTS = tools/bg_gen_unified_kernel
#
# EFI compilation
#
# This part of the build system uses custom make rules and bypass regular
# automake to provide absolute control on compiler and linker flags.
#
efi_loadername = efibootguard$(MACHINE_TYPE_NAME).efi
if BOOTLOADER
if ARCH_IS_X86
# NOTE: wdat.c is placed first so it is tried before any other drivers
# NOTE: ipc4x7e_wdt.c must be *before* itco.c
# NOTE: ipmi_wdt.c must be *before* itco.c
efi_sources_watchdogs = \
drivers/watchdog/wdat.c \
drivers/watchdog/amdfch_wdt.c \
drivers/watchdog/i6300esb.c \
drivers/watchdog/atom-quark.c \
drivers/watchdog/ipc4x7e_wdt.c \
drivers/watchdog/w83627hf_wdt.c \
drivers/watchdog/ipmi_wdt.c \
drivers/watchdog/itco.c \
drivers/watchdog/hpwdt.c \
drivers/watchdog/eiois200_wdt.c \
drivers/utils/simatic.c \
drivers/utils/smbios.c
else
efi_sources_watchdogs =
endif
efi_sources = \
drivers/watchdog/wdfuncs_start.c \
$(efi_sources_watchdogs) \
drivers/watchdog/wdfuncs_end.c \
env/syspart.c \
env/fatvars.c \
utils.c \
loader_interface.c \
bootguard.c \
main.c
kernel_stub_name = kernel-stub$(MACHINE_TYPE_NAME).efi
kernel_stub_sources = \
loader_interface.c \
kernel-stub/fdt.c \
kernel-stub/initrd.c \
kernel-stub/main.c
efi_cppflags = \
-I$(top_builddir) -include config.h \
-I$(top_srcdir)/include \
-I$(GNUEFI_SYS_DIR)/usr/include \
-I$(GNUEFI_INC_DIR) \
-I$(GNUEFI_INC_DIR)/$(ARCH) \
$(LIBPCI_CFLAGS)
efi_cflags = \
-Wall \
-Wextra \
-std=gnu99 \
-ggdb -O0 \
-fpic \
-fshort-wchar \
-ffreestanding \
-fno-strict-aliasing \
-fno-stack-protector \
-Wsign-compare \
-DGNU_EFI_USE_MS_ABI \
-Werror \
$(CFLAGS_MGENERAL_REGS_ONLY) \
$(CFLAGS)
if ARCH_X86_64
efi_cflags += \
-mno-red-zone
endif
efi_ldflags = \
-T $(GNUEFI_LIB_DIR)/elf_$(ARCH)_efi.lds \
-shared \
-Bsymbolic \
-nostdlib \
-znoexecstack \
-znocombreloc \
--warn-common \
--no-undefined \
--fatal-warnings \
$(LDFLAGS_NO_WARN_RWX_SEGMENTS) \
-L $(GNUEFI_LIB_DIR) \
$(GNUEFI_LIB_DIR)/crt0-efi-$(ARCH).o
if ARCH_IS_X86
objcopy_format = --target=efi-app-$(ARCH)
else
if OBJCOPY_USE_BINARY_COPY
objcopy_format = -O binary
efi_ldflags += --defsym=EFI_SUBSYSTEM=0xa
else
objcopy_format = --target=efi-app-$(ARCH)
endif
endif
efi_objects_pre1 = $(efi_sources:.c=.o)
efi_objects_pre2 = $(efi_objects_pre1:.S=.o)
efi_objects = $(addprefix $(top_builddir)/,$(efi_objects_pre2))
efi_solib = $(top_builddir)/efibootguard$(MACHINE_TYPE_NAME).so
kernel_stub_objects_pre = $(kernel_stub_sources:.c=.o)
kernel_stub_objects = $(addprefix $(top_builddir)/,$(kernel_stub_objects_pre))
kernel_stub_solib = $(top_builddir)/kernel-stub/kernel-stub$(MACHINE_TYPE_NAME).so
# automake stuff
efibootguard_DATA = $(efi_loadername) $(kernel_stub_name)
CLEANFILES += $(efi_objects) $(efi_solib) $(efi_loadername)
CLEANFILES += $(kernel_stub_objects) $(kernel_stub_solib) $(kernel_stub_name)
EXTRA_DIST += $(efi_sources) $(kernel_stub_sources)
define gnuefi_compile
$(AM_V_CC) $(MKDIR_P) $(shell dirname $@)/; \
$(GNUEFI_CC) $(efi_cppflags) $(efi_cflags) -c $< -o $@
endef
$(top_builddir)/%.o: $(top_srcdir)/%.c
$(call gnuefi_compile)
$(top_builddir)/env/%.o: $(top_srcdir)/env/%.c
$(call gnuefi_compile)
$(top_builddir)/drivers/watchdog/%.o: $(top_srcdir)/drivers/watchdog/%.c
$(call gnuefi_compile)
$(top_builddir)/drivers/watchdog/%.o: $(top_srcdir)/drivers/watchdog/%.S
$(call gnuefi_compile)
$(top_builddir)/drivers/utils/%.o: $(top_srcdir)/drivers/utils/%.c
$(call gnuefi_compile)
$(top_builddir)/kernel-stub/%.o: $(top_srcdir)/kernel-stub/%.c
$(call gnuefi_compile)
$(top_builddir)/main.o $(top_builddir)/kernel-stub/main.o: $(GEN_VERSION_H)
$(efi_solib): $(efi_objects)
$(AM_V_CCLD)$(LD) $(efi_ldflags) $(efi_objects) \
-o $@ -lefi -lgnuefi $(shell $(CC) $(CFLAGS) -print-libgcc-file-name); \
nm -D -u $@ | grep ' U ' && exit 1 || :
$(efi_loadername): $(efi_solib)
$(AM_V_GEN) $(OBJCOPY) -j .text -j .wdfuncs -j .sdata -j .data -j .dynamic \
-j .dynsym -j .rodata -j .rel* $(objcopy_format) $< $@
$(kernel_stub_solib): $(kernel_stub_objects)
$(AM_V_CCLD)$(LD) $(efi_ldflags) $(kernel_stub_objects) \
-o $@ -lefi -lgnuefi $(shell $(CC) $(CFLAGS) -print-libgcc-file-name); \
nm -D -u $@ | grep ' U ' && exit 1 || :
$(kernel_stub_name): $(kernel_stub_solib)
$(AM_V_GEN) $(OBJCOPY) -j .text -j .sdata -j .data -j .dynamic \
-j .dynsym -j .rodata -j .rel* $(objcopy_format) $< $@
endif # BOOTLOADER
$(top_builddir)/tools/bg_setenv-bg_envtools.o: $(GEN_VERSION_H)
bg_printenvdir = $(top_srcdir)
bg_printenv: $(bg_setenv)
$(AM_V_at)$(LN_S) -f bg_setenv bg_printenv
if COMPLETION
BASH_COMPLETION_FILES := $(top_builddir)/completion/bash/bg_setenv.bash $(top_builddir)/completion/bash/bg_printenv.bash
ZSH_COMPLETION_FILES := $(top_builddir)/completion/zsh/_bg_setenv $(top_builddir)/completion/zsh/_bg_printenv
else
BASH_COMPLETION_FILES :=
ZSH_COMPLETION_FILES :=
endif
bashcompletiondir = ${datarootdir}/efibootguard/completion/bash
bashcompletion_DATA = $(BASH_COMPLETION_FILES)
zshcompletiondir = ${datarootdir}/efibootguard/completion/zsh
zshcompletion_DATA = $(ZSH_COMPLETION_FILES)
.PHONY: bash-completion
bash-completion: $(BASH_COMPLETION_FILES)
.PHONY: zsh-completion
zsh-completion: $(ZSH_COMPLETION_FILES)
$(top_builddir)/completion/bash/bg_setenv.bash: ${top_srcdir}/completion/bg_setenv/cli.py
$(call shtab,bash,bg_setenv.cli.bg_setenv)
$(top_builddir)/completion/zsh/_bg_setenv: ${top_srcdir}/completion/bg_setenv/cli.py
$(call shtab,zsh,bg_setenv.cli.bg_setenv)
$(top_builddir)/completion/bash/bg_printenv.bash: ${top_srcdir}/completion/bg_printenv/cli.py
$(call shtab,bash,bg_printenv.cli.bg_printenv)
$(top_builddir)/completion/zsh/_bg_printenv: ${top_srcdir}/completion/bg_printenv/cli.py
$(call shtab,zsh,bg_printenv.cli.bg_printenv)
all-local: bg_printenv bash-completion zsh-completion
CLEANFILES += bg_printenv $(BASH_COMPLETION_FILES) $(ZSH_COMPLETION_FILES)
clean-local: clean-local-completion-pycache
.PHONY: clean-local-completion-pycache
clean-local-completion-pycache:
rm -rf $(top_builddir)/completion/bg_printenv/__pycache__
rm -rf $(top_builddir)/completion/bg_setenv/__pycache__
check-valgrind-local: $(GEN_VERSION_H)
# Tests depend on libraries being built - start with "."
SUBDIRS = . tools/tests
FORCE:
.PHONY: FORCE