2023-12-22 11:40:58 +01:00
|
|
|
# To compile on SunOS: add "-lsocket -lnsl" to LDFLAGS
|
|
|
|
|
|
|
|
CFLAGS ?= -O2
|
|
|
|
WARNING_CFLAGS ?= -Wall -Wextra -Wformat=2 -Wno-format-nonliteral
|
|
|
|
WARNING_CXXFLAGS ?= -Wall -Wextra -Wformat=2 -Wno-format-nonliteral
|
|
|
|
LDFLAGS ?=
|
|
|
|
|
2024-01-02 18:11:10 +01:00
|
|
|
LOCAL_CFLAGS = $(WARNING_CFLAGS) -I$(MBEDTLS_TEST_PATH)/include -I../include -D_FILE_OFFSET_BITS=64
|
2023-12-22 11:40:58 +01:00
|
|
|
LOCAL_CXXFLAGS = $(WARNING_CXXFLAGS) -I../include -I../tests/include -D_FILE_OFFSET_BITS=64
|
|
|
|
LOCAL_LDFLAGS = ${MBEDTLS_TEST_OBJS} \
|
|
|
|
-L../library \
|
|
|
|
-lmbedtls$(SHARED_SUFFIX) \
|
|
|
|
-lmbedx509$(SHARED_SUFFIX) \
|
|
|
|
-lmbedcrypto$(SHARED_SUFFIX)
|
2023-12-22 11:45:53 +01:00
|
|
|
|
|
|
|
include ../3rdparty/Makefile.inc
|
|
|
|
LOCAL_CFLAGS+=$(THIRDPARTY_INCLUDES)
|
|
|
|
|
|
|
|
ifndef SHARED
|
|
|
|
MBEDLIBS=../library/libmbedcrypto.a ../library/libmbedx509.a ../library/libmbedtls.a
|
|
|
|
else
|
|
|
|
MBEDLIBS=../library/libmbedcrypto.$(DLEXT) ../library/libmbedx509.$(DLEXT) ../library/libmbedtls.$(DLEXT)
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef DEBUG
|
|
|
|
LOCAL_CFLAGS += -g3
|
|
|
|
endif
|
|
|
|
|
|
|
|
# if we're running on Windows, build for Windows
|
|
|
|
ifdef WINDOWS
|
|
|
|
WINDOWS_BUILD=1
|
|
|
|
endif
|
|
|
|
|
2023-12-22 18:30:37 +01:00
|
|
|
## Usage: $(call remove_enabled_options,PREPROCESSOR_INPUT)
|
|
|
|
## Remove the preprocessor symbols that are set in the current configuration
|
2023-12-22 11:49:50 +01:00
|
|
|
## from PREPROCESSOR_INPUT. Also normalize whitespace.
|
|
|
|
## Example:
|
2023-12-22 18:30:37 +01:00
|
|
|
## $(call remove_set_options,MBEDTLS_FOO MBEDTLS_BAR)
|
2023-12-22 11:49:50 +01:00
|
|
|
## This expands to an empty string "" if MBEDTLS_FOO and MBEDTLS_BAR are both
|
2023-12-22 18:30:37 +01:00
|
|
|
## enabled, to "MBEDTLS_FOO" if MBEDTLS_BAR is enabled but MBEDTLS_FOO is
|
2023-12-22 11:49:50 +01:00
|
|
|
## disabled, etc.
|
|
|
|
##
|
|
|
|
## This only works with a Unix-like shell environment (Bourne/POSIX-style shell
|
|
|
|
## and standard commands) and a Unix-like compiler (supporting -E). In
|
|
|
|
## other environments, the output is likely to be empty.
|
2023-12-22 18:30:37 +01:00
|
|
|
define remove_enabled_options
|
2023-12-22 11:49:50 +01:00
|
|
|
$(strip $(shell
|
|
|
|
exec 2>/dev/null;
|
|
|
|
{ echo '#include <mbedtls/build_info.h>'; echo $(1); } |
|
|
|
|
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) -E - |
|
|
|
|
tail -n 1
|
|
|
|
))
|
|
|
|
endef
|
|
|
|
|
2023-12-22 11:45:53 +01:00
|
|
|
ifdef WINDOWS_BUILD
|
|
|
|
DLEXT=dll
|
|
|
|
EXEXT=.exe
|
|
|
|
LOCAL_LDFLAGS += -lws2_32 -lbcrypt
|
|
|
|
ifdef SHARED
|
|
|
|
SHARED_SUFFIX=.$(DLEXT)
|
|
|
|
endif
|
|
|
|
|
|
|
|
else # Not building for Windows
|
|
|
|
DLEXT ?= so
|
|
|
|
EXEXT=
|
|
|
|
SHARED_SUFFIX=
|
2023-12-22 11:49:50 +01:00
|
|
|
ifndef THREADING
|
|
|
|
# Auto-detect configurations with pthread.
|
2023-12-22 18:30:37 +01:00
|
|
|
# If the call to remove_enabled_options returns "control", the symbols
|
2023-12-22 13:25:18 +01:00
|
|
|
# are confirmed set and we link with pthread.
|
|
|
|
# If the auto-detection fails, the result of the call is empty and
|
|
|
|
# we keep THREADING undefined.
|
2023-12-22 18:30:37 +01:00
|
|
|
ifeq (control,$(call remove_enabled_options,control MBEDTLS_THREADING_C MBEDTLS_THREADING_PTHREAD))
|
2023-12-22 11:49:50 +01:00
|
|
|
THREADING := pthread
|
|
|
|
endif
|
|
|
|
endif
|
2023-12-22 11:45:53 +01:00
|
|
|
|
|
|
|
ifeq ($(THREADING),pthread)
|
|
|
|
LOCAL_LDFLAGS += -lpthread
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef WINDOWS
|
|
|
|
PYTHON ?= python
|
|
|
|
else
|
|
|
|
PYTHON ?= $(shell if type python3 >/dev/null 2>/dev/null; then echo python3; else echo python; fi)
|
|
|
|
endif
|
|
|
|
|
|
|
|
# See root Makefile
|
|
|
|
GEN_FILES ?= yes
|
|
|
|
ifdef GEN_FILES
|
|
|
|
gen_file_dep =
|
|
|
|
else
|
|
|
|
gen_file_dep = |
|
|
|
|
endif
|
2023-12-22 11:49:35 +01:00
|
|
|
|
|
|
|
default: all
|
|
|
|
|
|
|
|
$(MBEDLIBS):
|
|
|
|
$(MAKE) -C ../library
|
|
|
|
|
|
|
|
neat: clean
|
|
|
|
ifndef WINDOWS
|
|
|
|
rm -f $(GENERATED_FILES)
|
|
|
|
else
|
|
|
|
for %f in ($(subst /,\,$(GENERATED_FILES))) if exist %f del /Q /F %f
|
|
|
|
endif
|