nvs_flash: link the host test against libbsd when building on Linux

...and clean up the linking rule
This commit is contained in:
Ivan Grokhotkov 2022-08-17 12:20:25 +02:00
parent 7a1e19edf1
commit 4e0fa26e64
No known key found for this signature in database
GPG Key ID: 1E050E141B280628

View File

@ -43,6 +43,10 @@ CFLAGS += -fprofile-arcs -ftest-coverage -DLINUX_TARGET -DLINUX_HOST_LEGACY_TEST
CXXFLAGS += -std=c++11 -Wall -Werror -DLINUX_TARGET -DLINUX_HOST_LEGACY_TEST
LDFLAGS += -lstdc++ -Wall -fprofile-arcs -ftest-coverage
ifeq ($(shell uname -s),Linux)
LDFLAGS += -lbsd
endif
ifeq ($(COMPILER),clang)
CFLAGS += -fsanitize=address
CXXFLAGS += -fsanitize=address
@ -53,13 +57,16 @@ OBJ_FILES = $(SOURCE_FILES:.cpp=.o)
OBJ_FILES_C = $(SOURCE_FILES_C:.c=.o)
COVERAGE_FILES = $(OBJ_FILES:.o=.gc*)
MBEDTLS_LIB := ../../mbedtls/mbedtls/library/libmbedcrypto.a
$(OBJ_FILES): %.o: %.cpp
$(OBJ_FILES_C): %.c: %.c
$(TEST_PROGRAM): clean-coverage $(OBJ_FILES) $(OBJ_FILES_C)
$(MBEDTLS_LIB):
$(MAKE) -C ../../mbedtls/mbedtls/ lib
g++ $(LDFLAGS) -o $(TEST_PROGRAM) $(OBJ_FILES) $(OBJ_FILES_C) ../../mbedtls/mbedtls/library/libmbedcrypto.a
$(TEST_PROGRAM): $(OBJ_FILES) $(OBJ_FILES_C) $(MBEDTLS_LIB) | clean-coverage
g++ -o $@ $^ $(LDFLAGS)
$(OUTPUT_DIR):
mkdir -p $(OUTPUT_DIR)