2 # To compile on SunOS: add "-lsocket -lnsl" to LDFLAGS
3 # To compile with PKCS11: add "-lpkcs11-helper" to LDFLAGS
6 WARNING_CFLAGS ?= -Wall -W -Wdeclaration-after-statement -Wno-unused-function -Wno-unused-value
9 LOCAL_CFLAGS = $(WARNING_CFLAGS) -I../include -D_FILE_OFFSET_BITS=64
10 LOCAL_LDFLAGS = -L../library \
11 -lmbedtls$(SHARED_SUFFIX) \
12 -lmbedx509$(SHARED_SUFFIX) \
13 -lmbedcrypto$(SHARED_SUFFIX)
15 LOCAL_LDFLAGS += -L../crypto/library
16 LOCAL_CFLAGS += -I../crypto/include
17 CRYPTO := ../crypto/library/
19 # Enable definition of various functions used throughout the testsuite
20 # (gethostname, strdup, fileno...) even when compiling with -std=c99. Harmless
21 # on non-POSIX platforms.
22 LOCAL_CFLAGS += -D_POSIX_C_SOURCE=200809L
25 DEP=$(CRYPTO)libmbedcrypto.a ../library/libmbedx509.a ../library/libmbedtls.a
27 DEP=$(CRYPTO)libmbedcrypto.$(DLEXT) ../library/libmbedx509.$(DLEXT) ../library/libmbedtls.$(DLEXT)
34 # if we're running on Windows, build for Windows
42 LOCAL_LDFLAGS += -lws2_32
44 SHARED_SUFFIX=.$(DLEXT)
51 # python2 for POSIX since FreeBSD has only python2 as default.
55 # Zlib shared library extensions:
60 # A test application is built for each suites/test_suite_*.data file.
61 # Application name is same as .data file's base name and can be
62 # constructed by stripping path 'suites/' and extension .data.
63 APPS = $(basename $(subst suites/,,$(wildcard suites/test_suite_*.data)))
65 APPS := $(filter-out \
69 test_suite_asn1write \
75 test_suite_chachapoly \
89 test_suite_hmac_drbg.% \
92 test_suite_memory_buffer_alloc \
98 test_suite_pkcs1_v15 \
99 test_suite_pkcs1_v21 \
103 test_suite_poly1305 \
110 # Construct executable name by adding OS specific suffix $(EXEXT).
111 BINARIES := $(addsuffix $(EXEXT),$(APPS))
115 .PHONY: all check test clean
120 $(MAKE) -C ../library
122 C_FILES := $(addsuffix .c,$(APPS))
124 # Wildcard target for test code generation:
125 # A .c file is generated for each .data file in the suites/ directory. Each .c
126 # file depends on a .data and .function file from suites/ directory. Following
127 # nameing convention is followed:
129 # C file | Depends on
130 #-----------------------------------------------------------------------------
131 # foo.c | suites/foo.function suites/foo.data
132 # foo.bar.c | suites/foo.function suites/foo.bar.data
134 # Note above that .c and .data files have same base name.
135 # However, corresponding .function file's base name is the word before first
136 # dot in .c file's base name.
139 %.c: suites/$$(firstword $$(subst ., ,$$*)).function suites/%.data scripts/generate_test_code.py suites/helpers.function suites/main_test.function suites/host_test.function
141 $(PYTHON) scripts/generate_test_code.py -f suites/$(firstword $(subst ., ,$*)).function \
143 -t suites/main_test.function \
144 -p suites/host_test.function \
146 --helpers-file suites/helpers.function \
150 $(BINARIES): %$(EXEXT): %.c $(DEP)
152 $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
157 rm -rf $(BINARIES) *.c *.datax TESTS
159 del /Q /F *.c *.exe *.datax
160 ifneq ($(wildcard TESTS/.*),)
165 # Test suites caught by SKIP_TEST_SUITES are built but not executed.
167 perl scripts/run-test-suites.pl --skip=$(SKIP_TEST_SUITES)
171 # Create separate targets for generating embedded tests.
172 EMBEDDED_TESTS := $(addprefix embedded_,$(APPS))
174 # Generate test code for target.
177 $(EMBEDDED_TESTS): embedded_%: suites/$$(firstword $$(subst ., ,$$*)).function suites/%.data scripts/generate_test_code.py suites/helpers.function suites/main_test.function suites/target_test.function
178 echo " Gen ./TESTS/mbedtls/$*/$*.c"
179 $(PYTHON) scripts/generate_test_code.py -f suites/$(firstword $(subst ., ,$*)).function \
181 -t suites/main_test.function \
182 -p suites/target_test.function \
184 --helpers-file suites/helpers.function \
185 -o ./TESTS/mbedtls/$*
187 generate-target-tests: $(EMBEDDED_TESTS)