1 # SPDX-License-Identifier: BSD-2-Clause-Patent
3 # test.mk - makefile to make local test programs
13 OPTIMIZATIONS
=-O2
-ggdb
16 CFLAGS
= $(OPTIMIZATIONS
) -std
=gnu11 \
17 -isystem
$(TOPDIR
)/include/system \
20 -isystem
/usr
/include \
21 -isystem
$(shell $(CC
) $(ARCH_CFLAGS
) -print-file-name
=include) \
29 -fno-eliminate-unused-debug-types \
30 -fno-eliminate-unused-debug-symbols \
32 -grecord-gcc-switches \
33 $(if
$(findstring clang
,$(CC
)),-Wno-unknown-warning-option
) \
34 $(DEFAULT_WARNFLAGS
) \
36 -Wno-deprecated-declarations \
37 $(if
$(findstring gcc
,$(CC
)),-Wno-unused-but-set-variable
) \
38 -Wno-unused-variable \
40 $(DEFAULT_WERRFLAGS
) \
42 $(shell $(CC
) -Werror
=nonnull-compare
-E
-x c
/dev
/null
>/dev
/null
2>&1 && echo
-Werror
=nonnull-compare
) \
44 -DEFI_FUNCTION_WRAPPER \
45 -DGNU_EFI_USE_MS_ABI
-DPAGE_SIZE
=4096 \
47 "-DDEFAULT_DEBUG_PRINT_STATE=$(DEBUG_PRINTS)"
49 # On some systems (e.g. Arch Linux), limits.h is in the "include-fixed" instead
50 # of the "include" directory
51 CFLAGS
+= -isystem
$(shell $(CC
) $(ARCH_CFLAGS
) -print-file-name
=include-fixed
)
53 export CFLAGS_LTO CFLAGS_GCOV
57 COMPILER
="$(COMPILER)" \
60 TOPDIR
=$(TOPDIR
)/gnu-efi \
61 CFLAGS_LTO
="$(CFLAGS_LTO)" \
62 CFLAGS_GCOV
="$(CFLAGS_GCOV)" \
63 -f
$(TOPDIR
)/gnu-efi
/Makefile \
65 mv gnu-efi
/$(ARCH
)/lib
/libefi.a
$@
67 COMPILER
="$(COMPILER)" \
69 TOPDIR
=$(TOPDIR
)/gnu-efi \
70 CFLAGS_LTO
="$(CFLAGS_LTO)" \
71 CFLAGS_GCOV
="$(CFLAGS_GCOV)" \
72 -f
$(TOPDIR
)/gnu-efi
/Makefile \
76 dd if
=/dev
/urandom bs
=512 count
=17 of
=random.bin
77 xxd
-i random.bin test-random.h
79 $(wildcard test-
*.c
) :: %.c
: test-random.h
80 $(patsubst %.c
,%,$(wildcard test-
*.c
)) :: | test-random.h
81 $(patsubst %.c
,%.o
,$(wildcard test-
*.c
)) : | test-random.h
83 test-load-options_FILES
= lib
/guid.c
84 test-load-options
: CFLAGS
+=-DHAVE_SHIM_LOCK_GUID
86 test-mock-variables_FILES
= mok.c globals.c tpm.c lib
/guid.c lib
/variables.c mock-variables.c
87 test-mock-variables
: CFLAGS
+=-DHAVE_SHIM_LOCK_GUID
89 test-mok-mirror_FILES
= mok.c globals.c tpm.c lib
/guid.c lib
/variables.c mock-variables.c
90 test-mok-mirror
: CFLAGS
+=-DHAVE_START_IMAGE
-DHAVE_SHIM_LOCK_GUID
92 test-sbat_FILES
= csv.c lib
/variables.c lib
/guid.c
93 test-sbat
:: CFLAGS
+=-DHAVE_GET_VARIABLE
-DHAVE_GET_VARIABLE_ATTR
-DHAVE_SHIM_LOCK_GUID
95 test-str_FILES
= lib
/string.c
97 tests
:= $(patsubst %.c
,%,$(wildcard test-
*.c
))
99 $(tests
) :: test-
% : | libefi-test.a
101 $(tests
) :: test-
% : test.c test-
%.c
$(test-
%_FILES
)
102 $(CC
) $(CFLAGS
) -o
$@
$(sort $^
$(wildcard $*.c
) $(test-
$*_FILES
)) libefi-test.a
-lefivar
106 $(MAKE
) -f
include/test.mk test-clean
108 test-lto
: CFLAGS_LTO
+=-flto
110 $(MAKE
) -f
include/test.mk test-clean
112 test-coverage
: CFLAGS_GCOV
+=--coverage
113 test-coverage
: $(tests
)
116 @
rm -vf test-random.h random.bin libefi-test.a
117 @
rm -vf
*.gcda
*.gcno
*.gcov vgcore.
*
121 all : test-clean
test
123 .PHONY
: $(tests
) all test clean
124 .SECONDARY
: random.bin