procd: make mDNS TXT record parsing more solid
[openwrt/openwrt.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.28.7
12 PKG_RELEASE:=1
13 PKG_USE_MIPS16:=0
14
15 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
16 PKG_SOURCE_URL:=https://codeload.github.com/ARMmbed/mbedtls/tar.gz/v$(PKG_VERSION)?
17 PKG_HASH:=1df6073f0cf6a4e1953890bf5e0de2a8c7e6be50d6d6c69fa9fefcb1d14e981a
18
19 PKG_LICENSE:=GPL-2.0-or-later
20 PKG_LICENSE_FILES:=gpl-2.0.txt
21 PKG_CPE_ID:=cpe:/a:arm:mbed_tls
22
23 PKG_CONFIG_DEPENDS := \
24 CONFIG_LIBMBEDTLS_DEBUG_C \
25 CONFIG_LIBMBEDTLS_HKDF_C
26
27 include $(INCLUDE_DIR)/package.mk
28 include $(INCLUDE_DIR)/cmake.mk
29
30 define Package/mbedtls/Default
31 TITLE:=Embedded SSL
32 URL:=https://tls.mbed.org
33 endef
34
35 define Package/mbedtls/Default/description
36 The aim of the mbedtls project is to provide a quality, open-source
37 cryptographic library written in C and targeted at embedded systems.
38 endef
39
40 define Package/libmbedtls
41 $(call Package/mbedtls/Default)
42 SECTION:=libs
43 CATEGORY:=Libraries
44 SUBMENU:=SSL
45 TITLE+= (library)
46 ABI_VERSION:=12
47 endef
48
49 define Package/libmbedtls/config
50 config LIBMBEDTLS_DEBUG_C
51 depends on PACKAGE_libmbedtls
52 bool "Enable debug functions"
53 default n
54 help
55 This option enables mbedtls library's debug functions.
56
57 It increases the uncompressed libmbedtls binary size
58 by around 60 KiB (for an ARMv5 platform).
59
60 Usually, you don't need this, so don't select this if you're unsure.
61
62 config LIBMBEDTLS_HKDF_C
63 depends on PACKAGE_libmbedtls
64 bool "Enable the HKDF algorithm (RFC 5869)"
65 default n
66 help
67 This option adds support for the Hashed Message Authentication Code
68 (HMAC)-based key derivation function (HKDF).
69 endef
70
71 define Package/mbedtls-util
72 $(call Package/mbedtls/Default)
73 SECTION:=utils
74 CATEGORY:=Utilities
75 TITLE+= (utilities)
76 DEPENDS:=+libmbedtls
77 endef
78
79 define Package/libmbedtls/description
80 $(call Package/mbedtls/Default/description)
81 This package contains the mbedtls library.
82 endef
83
84 define Package/mbedtls-util/description
85 $(call Package/mbedtls/Default/description)
86 This package contains mbedtls helper programs for private key and
87 CSR generation (gen_key, cert_req)
88 endef
89
90 TARGET_CFLAGS += -ffunction-sections -fdata-sections
91 TARGET_CFLAGS := $(filter-out -O%,$(TARGET_CFLAGS))
92
93 CMAKE_OPTIONS += \
94 -DUSE_SHARED_MBEDTLS_LIBRARY:Bool=ON \
95 -DENABLE_TESTING:Bool=OFF \
96 -DENABLE_PROGRAMS:Bool=ON
97
98 define Build/Configure
99 $(Build/Configure/Default)
100
101 awk 'BEGIN { rc = 1 } \
102 /#define MBEDTLS_DEBUG_C/ { $$$$0 = "$(if $(CONFIG_LIBMBEDTLS_DEBUG_C),,// )#define MBEDTLS_DEBUG_C"; rc = 0 } \
103 { print } \
104 END { exit(rc) }' $(PKG_BUILD_DIR)/include/mbedtls/config.h \
105 >$(PKG_BUILD_DIR)/include/mbedtls/config.h.new && \
106 mv $(PKG_BUILD_DIR)/include/mbedtls/config.h.new $(PKG_BUILD_DIR)/include/mbedtls/config.h
107
108 awk 'BEGIN { rc = 1 } \
109 /#define MBEDTLS_HKDF_C/ { $$$$0 = "$(if $(CONFIG_LIBMBEDTLS_HKDF_C),,// )#define MBEDTLS_HKDF_C"; rc = 0 } \
110 { print } \
111 END { exit(rc) }' $(PKG_BUILD_DIR)/include/mbedtls/config.h \
112 >$(PKG_BUILD_DIR)/include/mbedtls/config.h.new && \
113 mv $(PKG_BUILD_DIR)/include/mbedtls/config.h.new $(PKG_BUILD_DIR)/include/mbedtls/config.h
114 endef
115
116 define Build/InstallDev
117 $(INSTALL_DIR) $(1)/usr/include
118 $(CP) $(PKG_INSTALL_DIR)/usr/include/mbedtls $(1)/usr/include/
119 $(INSTALL_DIR) $(1)/usr/lib
120 $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib*.so* $(1)/usr/lib/
121 $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib*.a $(1)/usr/lib/
122 endef
123
124 define Package/libmbedtls/install
125 $(INSTALL_DIR) $(1)/usr/lib
126 $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib*.so.* $(1)/usr/lib/
127 endef
128
129 define Package/mbedtls-util/install
130 $(INSTALL_DIR) $(1)/usr/bin
131 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/gen_key $(1)/usr/bin/
132 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/cert_req $(1)/usr/bin/
133 endef
134
135 $(eval $(call BuildPackage,libmbedtls))
136 $(eval $(call BuildPackage,mbedtls-util))