mbedtls: update to 2.16.6
[librecmc/librecmc.git] / package / libs / mbedtls / Makefile
1 #
2 # Copyright (C) 2011-2015 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 include $(TOPDIR)/rules.mk
9
10 PKG_NAME:=mbedtls
11 PKG_VERSION:=2.16.6
12 PKG_RELEASE:=1
13 PKG_USE_MIPS16:=0
14
15 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-gpl.tgz
16 PKG_SOURCE_URL:=https://tls.mbed.org/download/
17 PKG_HASH:=80a484df42f32dbe95665cd4b18ce0dd14b6c67dfd561d36d1475802e41eb3ed
18
19 PKG_BUILD_PARALLEL:=1
20 PKG_LICENSE:=GPL-2.0+
21 PKG_CPE_ID:=cpe:/a:arm:mbed_tls
22
23 PKG_CONFIG_DEPENDS:=CONFIG_LIBMBEDTLS_DEBUG_C
24
25 include $(INCLUDE_DIR)/package.mk
26 include $(INCLUDE_DIR)/cmake.mk
27
28 define Package/mbedtls/Default
29   TITLE:=Embedded SSL
30   URL:=https://tls.mbed.org
31 endef
32
33 define Package/mbedtls/Default/description
34 The aim of the mbedtls project is to provide a quality, open-source
35 cryptographic library written in C and targeted at embedded systems.
36 endef
37
38 define Package/libmbedtls
39 $(call Package/mbedtls/Default)
40   SECTION:=libs
41   CATEGORY:=Libraries
42   SUBMENU:=SSL
43   TITLE+= (library)
44   ABI_VERSION:=12
45 endef
46
47 define Package/libmbedtls/config
48 config LIBMBEDTLS_DEBUG_C
49         depends on PACKAGE_libmbedtls
50         bool "Enable debug functions"
51         default n
52         help
53          This option enables mbedtls library's debug functions.
54
55          It increases the uncompressed libmbedtls binary size
56          by around 60 KiB (for an ARMv5 platform).
57
58          Usually, you don't need this, so don't select this if you're unsure.
59 endef
60
61 define Package/mbedtls-util
62 $(call Package/mbedtls/Default)
63   SECTION:=utils
64   CATEGORY:=Utilities
65   TITLE+= (utilities)
66   DEPENDS:=+libmbedtls
67 endef
68
69 define Package/libmbedtls/description
70 $(call Package/mbedtls/Default/description)
71 This package contains the mbedtls library.
72 endef
73
74 define Package/mbedtls-util/description
75 $(call Package/mbedtls/Default/description)
76 This package contains mbedtls helper programs for private key and
77 CSR generation (gen_key, cert_req)
78 endef
79
80 PKG_INSTALL:=1
81
82 TARGET_CFLAGS += -ffunction-sections -fdata-sections
83 TARGET_CFLAGS := $(filter-out -O%,$(TARGET_CFLAGS))
84
85 CMAKE_OPTIONS += \
86         -DUSE_SHARED_MBEDTLS_LIBRARY:Bool=ON \
87         -DENABLE_TESTING:Bool=OFF \
88         -DENABLE_PROGRAMS:Bool=ON
89
90 define Build/Configure
91         $(Build/Configure/Default)
92
93         awk 'BEGIN { rc = 1 } \
94              /#define MBEDTLS_DEBUG_C/ { $$$$0 = "$(if $(CONFIG_LIBMBEDTLS_DEBUG_C),,// )#define MBEDTLS_DEBUG_C"; rc = 0 } \
95              { print } \
96              END { exit(rc) }' $(PKG_BUILD_DIR)/include/mbedtls/config.h \
97              >$(PKG_BUILD_DIR)/include/mbedtls/config.h.new && \
98         mv $(PKG_BUILD_DIR)/include/mbedtls/config.h.new $(PKG_BUILD_DIR)/include/mbedtls/config.h
99 endef
100
101 define Build/InstallDev
102         $(INSTALL_DIR) $(1)/usr/include
103         $(CP) $(PKG_INSTALL_DIR)/usr/include/mbedtls $(1)/usr/include/
104         $(INSTALL_DIR) $(1)/usr/lib
105         $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib*.so* $(1)/usr/lib/
106         $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib*.a $(1)/usr/lib/
107 endef
108
109 define Package/libmbedtls/install
110         $(INSTALL_DIR) $(1)/usr/lib
111         $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib*.so.* $(1)/usr/lib/
112 endef
113
114 define Package/mbedtls-util/install
115         $(INSTALL_DIR) $(1)/usr/bin
116         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/gen_key $(1)/usr/bin/
117         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/cert_req $(1)/usr/bin/
118 endef
119
120 $(eval $(call BuildPackage,libmbedtls))
121 $(eval $(call BuildPackage,mbedtls-util))