-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
mbedtls.mk
97 lines (78 loc) · 3.38 KB
/
mbedtls.mk
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
## mbedtls
include $(SRCDIR)/mbedtls.version
ifneq ($(USE_BINARYBUILDER_MBEDTLS), 1)
MBEDTLS_SRC = mbedtls-$(MBEDTLS_VER)
MBEDTLS_URL = https://github.com/Mbed-TLS/mbedtls/archive/v$(MBEDTLS_VER).tar.gz
MBEDTLS_OPTS := $(CMAKE_COMMON) -DUSE_SHARED_MBEDTLS_LIBRARY=ON \
-DUSE_STATIC_MBEDTLS_LIBRARY=OFF -DENABLE_PROGRAMS=OFF -DCMAKE_BUILD_TYPE=Release
MBEDTLS_OPTS += -DENABLE_ZLIB_SUPPORT=OFF -DMBEDTLS_FATAL_WARNINGS=OFF
ifeq ($(BUILD_OS),WINNT)
MBEDTLS_OPTS += -G"MSYS Makefiles"
endif
ifneq (,$(findstring $(OS),Linux FreeBSD OpenBSD))
MBEDTLS_OPTS += -DCMAKE_INSTALL_RPATH="\$$ORIGIN"
endif
$(SRCCACHE)/$(MBEDTLS_SRC).tar.gz: | $(SRCCACHE)
$(JLDOWNLOAD) $@ $(MBEDTLS_URL)
$(SRCCACHE)/$(MBEDTLS_SRC)/source-extracted: $(SRCCACHE)/$(MBEDTLS_SRC).tar.gz
$(JLCHECKSUM) $<
mkdir -p $(dir $@) && \
$(TAR) -C $(dir $@) --strip-components 1 -xf $<
# Force-enable MD4
sed -i.org "s|//#define MBEDTLS_MD4_C|#define MBEDTLS_MD4_C|" $(SRCCACHE)/$(MBEDTLS_SRC)/include/mbedtls/config.h
touch -c $(SRCCACHE)/$(MBEDTLS_SRC)/CMakeLists.txt # old target
echo 1 > $@
checksum-mbedtls: $(SRCCACHE)/$(MBEDTLS_SRC).tar.gz
$(JLCHECKSUM) $<
$(BUILDDIR)/$(MBEDTLS_SRC)/build-configured: $(SRCCACHE)/$(MBEDTLS_SRC)/source-extracted
mkdir -p $(dir $@)
cd $(dir $@) && \
$(CMAKE) $(dir $<) $(MBEDTLS_OPTS)
echo 1 > $@
$(BUILDDIR)/$(MBEDTLS_SRC)/build-compiled: $(BUILDDIR)/$(MBEDTLS_SRC)/build-configured
$(MAKE) -C $(dir $<)
echo 1 > $@
$(BUILDDIR)/$(MBEDTLS_SRC)/build-checked: $(BUILDDIR)/$(MBEDTLS_SRC)/build-compiled
ifeq ($(OS),$(BUILD_OS))
$(MAKE) -C $(dir $@) test
endif
echo 1 > $@
ifeq ($(OS),WINNT)
define MBEDTLS_INSTALL
mkdir -p $2/$$(build_shlibdir)
cp $1/library/libmbedcrypto.$$(SHLIB_EXT) $2/$$(build_shlibdir)
cp $1/library/libmbedx509.$$(SHLIB_EXT) $2/$$(build_shlibdir)
cp $1/library/libmbedtls.$$(SHLIB_EXT) $2/$$(build_shlibdir)
endef
else
define MBEDTLS_INSTALL
$(call MAKE_INSTALL,$1,$2,)
endef
endif
$(eval $(call staged-install, \
mbedtls,$(MBEDTLS_SRC), \
MBEDTLS_INSTALL,,, \
$$(INSTALL_NAME_CMD)libmbedx509.$$(SHLIB_EXT) $$(build_shlibdir)/libmbedx509.$$(SHLIB_EXT) && \
$$(INSTALL_NAME_CMD)libmbedtls.$$(SHLIB_EXT) $$(build_shlibdir)/libmbedtls.$$(SHLIB_EXT) && \
$$(INSTALL_NAME_CHANGE_CMD) libmbedx509.1.dylib @rpath/libmbedx509.$$(SHLIB_EXT) $$(build_shlibdir)/libmbedtls.$$(SHLIB_EXT) && \
$$(INSTALL_NAME_CHANGE_CMD) libmbedcrypto.7.dylib @rpath/libmbedcrypto.$$(SHLIB_EXT) $$(build_shlibdir)/libmbedtls.$$(SHLIB_EXT) && \
$$(INSTALL_NAME_CHANGE_CMD) libmbedcrypto.7.dylib @rpath/libmbedcrypto.$$(SHLIB_EXT) $$(build_shlibdir)/libmbedx509.$$(SHLIB_EXT) && \
$$(INSTALL_NAME_CMD)libmbedcrypto.$$(SHLIB_EXT) $$(build_shlibdir)/libmbedcrypto.$$(SHLIB_EXT)))
clean-mbedtls:
-rm -f $(BUILDDIR)/$(MBEDTLS_SRC)/build-configured \
$(BUILDDIR)/$(MBEDTLS_SRC)/build-compiled
-$(MAKE) -C $(BUILDDIR)/$(MBEDTLS_SRC) clean
distclean-mbedtls:
rm -rf $(SRCCACHE)/$(MBEDTLS_SRC).tar.gz \
$(SRCCACHE)/$(MBEDTLS_SRC) \
$(BUILDDIR)/$(MBEDTLS_SRC)
get-mbedtls: $(SRCCACHE)/$(MBEDTLS_SRC).tar.gz
extract-mbedtls: $(SRCCACHE)/$(MBEDTLS_SRC)/source-extracted
configure-mbedtls: $(BUILDDIR)/$(MBEDTLS_SRC)/build-configured
compile-mbedtls: $(BUILDDIR)/$(MBEDTLS_SRC)/build-compiled
# tests disabled since they are known to fail
fastcheck-mbedtls: #check-mbedtls
check-mbedtls: $(BUILDDIR)/$(MBEDTLS_SRC)/build-checked
else # USE_BINARYBUILDER_MBEDTLS
$(eval $(call bb-install,mbedtls,MBEDTLS,false))
endif