Makefile 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. #
  2. # Copyright (C) 2006-2016 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. include $(TOPDIR)/rules.mk
  8. PKG_NAME:=openssl
  9. PKG_BASE:=1.0.2
  10. PKG_BUGFIX:=o
  11. PKG_VERSION:=$(PKG_BASE)$(PKG_BUGFIX)
  12. PKG_RELEASE:=1
  13. PKG_USE_MIPS16:=0
  14. PKG_BUILD_PARALLEL:=0
  15. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
  16. PKG_SOURCE_URL:= \
  17. http://ftp.fi.muni.cz/pub/openssl/source/ \
  18. http://ftp.linux.hr/pub/openssl/source/ \
  19. http://gd.tuwien.ac.at/infosys/security/openssl/source/ \
  20. http://www.openssl.org/source/ \
  21. http://www.openssl.org/source/old/$(PKG_BASE)/
  22. PKG_HASH:=ec3f5c9714ba0fd45cb4e087301eb1336c317e0d20b575a125050470e8089e4d
  23. PKG_LICENSE:=OpenSSL
  24. PKG_LICENSE_FILES:=LICENSE
  25. PKG_CPE_ID:=cpe:/a:openssl:openssl
  26. PKG_CONFIG_DEPENDS:= \
  27. CONFIG_OPENSSL_ENGINE_CRYPTO \
  28. CONFIG_OPENSSL_ENGINE_DIGEST \
  29. CONFIG_OPENSSL_WITH_EC \
  30. CONFIG_OPENSSL_WITH_EC2M \
  31. CONFIG_OPENSSL_WITH_SSL3 \
  32. CONFIG_OPENSSL_HARDWARE_SUPPORT \
  33. CONFIG_OPENSSL_WITH_DEPRECATED \
  34. CONFIG_OPENSSL_WITH_DTLS \
  35. CONFIG_OPENSSL_WITH_COMPRESSION \
  36. CONFIG_OPENSSL_WITH_NPN \
  37. CONFIG_OPENSSL_WITH_PSK \
  38. CONFIG_OPENSSL_WITH_SRP \
  39. CONFIG_OPENSSL_OPTIMIZE_SPEED
  40. include $(INCLUDE_DIR)/package.mk
  41. ifneq ($(CONFIG_CCACHE),)
  42. HOSTCC=$(HOSTCC_NOCACHE)
  43. HOSTCXX=$(HOSTCXX_NOCACHE)
  44. endif
  45. define Package/openssl/Default
  46. TITLE:=Open source SSL toolkit
  47. URL:=http://www.openssl.org/
  48. endef
  49. define Package/libopenssl/config
  50. source "$(SOURCE)/Config.in"
  51. endef
  52. define Package/openssl/Default/description
  53. The OpenSSL Project is a collaborative effort to develop a robust,
  54. commercial-grade, full-featured, and Open Source toolkit implementing the Secure
  55. Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) protocols as well
  56. as a full-strength general purpose cryptography library.
  57. endef
  58. define Package/libopenssl
  59. $(call Package/openssl/Default)
  60. SECTION:=libs
  61. SUBMENU:=SSL
  62. CATEGORY:=Libraries
  63. DEPENDS:=+OPENSSL_WITH_COMPRESSION:zlib
  64. TITLE+= (libraries)
  65. ABI_VERSION:=$(PKG_VERSION)
  66. MENU:=1
  67. endef
  68. define Package/libopenssl/description
  69. $(call Package/openssl/Default/description)
  70. This package contains the OpenSSL shared libraries, needed by other programs.
  71. endef
  72. define Package/openssl-util
  73. $(call Package/openssl/Default)
  74. SECTION:=utils
  75. CATEGORY:=Utilities
  76. DEPENDS:=+libopenssl
  77. TITLE+= (utility)
  78. endef
  79. define Package/openssl-util/conffiles
  80. /etc/ssl/openssl.cnf
  81. endef
  82. define Package/openssl-util/description
  83. $(call Package/openssl/Default/description)
  84. This package contains the OpenSSL command-line utility.
  85. endef
  86. OPENSSL_NO_CIPHERS:= no-idea no-md2 no-mdc2 no-rc5 no-sha0 no-camellia no-krb5 \
  87. no-whrlpool no-whirlpool no-seed no-jpake
  88. OPENSSL_OPTIONS:= shared no-err no-sse2 no-ssl2 no-ssl2-method no-heartbeats
  89. ifdef CONFIG_OPENSSL_ENGINE_CRYPTO
  90. OPENSSL_OPTIONS += -DHAVE_CRYPTODEV
  91. ifdef CONFIG_OPENSSL_ENGINE_DIGEST
  92. OPENSSL_OPTIONS += -DUSE_CRYPTODEV_DIGESTS
  93. endif
  94. else
  95. OPENSSL_OPTIONS += no-engines
  96. endif
  97. ifndef CONFIG_OPENSSL_WITH_EC
  98. OPENSSL_OPTIONS += no-ec
  99. endif
  100. ifndef CONFIG_OPENSSL_WITH_EC2M
  101. OPENSSL_OPTIONS += no-ec2m
  102. endif
  103. ifndef CONFIG_OPENSSL_WITH_SSL3
  104. OPENSSL_OPTIONS += no-ssl3 no-ssl3-method
  105. endif
  106. ifndef CONFIG_OPENSSL_HARDWARE_SUPPORT
  107. OPENSSL_OPTIONS += no-hw
  108. endif
  109. ifndef CONFIG_OPENSSL_WITH_DEPRECATED
  110. OPENSSL_OPTIONS += no-deprecated
  111. endif
  112. ifndef CONFIG_OPENSSL_WITH_DTLS
  113. OPENSSL_OPTIONS += no-dtls
  114. endif
  115. ifdef CONFIG_OPENSSL_WITH_COMPRESSION
  116. OPENSSL_OPTIONS += zlib-dynamic
  117. else
  118. OPENSSL_OPTIONS += no-comp
  119. endif
  120. ifndef CONFIG_OPENSSL_WITH_NPN
  121. OPENSSL_OPTIONS += no-nextprotoneg
  122. endif
  123. ifndef CONFIG_OPENSSL_WITH_PSK
  124. OPENSSL_OPTIONS += no-psk
  125. endif
  126. ifndef CONFIG_OPENSSL_WITH_SRP
  127. OPENSSL_OPTIONS += no-srp
  128. endif
  129. ifeq ($(CONFIG_OPENSSL_OPTIMIZE_SPEED),y)
  130. TARGET_CFLAGS := $(filter-out -Os,$(TARGET_CFLAGS)) -O3
  131. endif
  132. ifeq ($(CONFIG_x86_64),y)
  133. OPENSSL_TARGET:=linux-x86_64-openwrt
  134. OPENSSL_MAKEFLAGS += LIBDIR=lib
  135. else
  136. OPENSSL_OPTIONS+=no-sse2
  137. ifeq ($(CONFIG_mips)$(CONFIG_mipsel),y)
  138. OPENSSL_TARGET:=linux-mips-openwrt
  139. else ifeq ($(CONFIG_aarch64),y)
  140. OPENSSL_TARGET:=linux-aarch64-openwrt
  141. else ifeq ($(CONFIG_arm)$(CONFIG_armeb),y)
  142. OPENSSL_TARGET:=linux-armv4-openwrt
  143. else
  144. OPENSSL_TARGET:=linux-generic-openwrt
  145. OPENSSL_OPTIONS+=no-perlasm
  146. endif
  147. endif
  148. STAMP_CONFIGURED := $(STAMP_CONFIGURED)_$(shell echo $(OPENSSL_OPTIONS) | mkhash md5)
  149. define Build/Configure
  150. [ -f $(STAMP_CONFIGURED) ] || { \
  151. rm -f $(PKG_BUILD_DIR)/*.so.* $(PKG_BUILD_DIR)/*.a; \
  152. find $(PKG_BUILD_DIR) -name \*.o | xargs rm -f; \
  153. }
  154. (cd $(PKG_BUILD_DIR); \
  155. ./Configure $(OPENSSL_TARGET) \
  156. --prefix=/usr \
  157. --openssldir=/etc/ssl \
  158. $(TARGET_CPPFLAGS) \
  159. $(TARGET_LDFLAGS) -ldl \
  160. $(if $(CONFIG_OPENSSL_OPTIMIZE_SPEED),,-DOPENSSL_SMALL_FOOTPRINT) \
  161. $(OPENSSL_NO_CIPHERS) \
  162. $(OPENSSL_OPTIONS) \
  163. )
  164. +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
  165. CROSS_COMPILE="$(TARGET_CROSS)" \
  166. MAKEDEPPROG="$(TARGET_CROSS)gcc" \
  167. OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
  168. $(OPENSSL_MAKEFLAGS) \
  169. depend
  170. endef
  171. TARGET_CFLAGS += $(FPIC) -I$(CURDIR)/include -ffunction-sections -fdata-sections
  172. TARGET_LDFLAGS += -Wl,--gc-sections
  173. define Build/Compile
  174. +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
  175. CROSS_COMPILE="$(TARGET_CROSS)" \
  176. CC="$(TARGET_CC)" \
  177. ASFLAGS="$(TARGET_ASFLAGS) -I$(PKG_BUILD_DIR)/crypto -c" \
  178. AR="$(TARGET_CROSS)ar r" \
  179. RANLIB="$(TARGET_CROSS)ranlib" \
  180. OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
  181. $(OPENSSL_MAKEFLAGS) \
  182. all
  183. +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
  184. CROSS_COMPILE="$(TARGET_CROSS)" \
  185. CC="$(TARGET_CC)" \
  186. ASFLAGS="$(TARGET_ASFLAGS) -I$(PKG_BUILD_DIR)/crypto -c" \
  187. AR="$(TARGET_CROSS)ar r" \
  188. RANLIB="$(TARGET_CROSS)ranlib" \
  189. OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
  190. $(OPENSSL_MAKEFLAGS) \
  191. build-shared
  192. # Work around openssl build bug to link libssl.so with libcrypto.so.
  193. -rm $(PKG_BUILD_DIR)/libssl.so.*.*.*
  194. +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
  195. CROSS_COMPILE="$(TARGET_CROSS)" \
  196. CC="$(TARGET_CC)" \
  197. OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
  198. $(OPENSSL_MAKEFLAGS) \
  199. do_linux-shared
  200. $(MAKE) -C $(PKG_BUILD_DIR) \
  201. CROSS_COMPILE="$(TARGET_CROSS)" \
  202. CC="$(TARGET_CC)" \
  203. INSTALL_PREFIX="$(PKG_INSTALL_DIR)" \
  204. $(OPENSSL_MAKEFLAGS) \
  205. install
  206. endef
  207. define Build/InstallDev
  208. $(INSTALL_DIR) $(1)/usr/include
  209. $(CP) $(PKG_INSTALL_DIR)/usr/include/openssl $(1)/usr/include/
  210. $(INSTALL_DIR) $(1)/usr/lib/
  211. $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{crypto,ssl}.{a,so*} $(1)/usr/lib/
  212. $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
  213. $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc $(1)/usr/lib/pkgconfig/
  214. [ -n "$(TARGET_LDFLAGS)" ] && $(SED) 's#$(TARGET_LDFLAGS)##g' $(1)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc || true
  215. endef
  216. define Package/libopenssl/install
  217. $(INSTALL_DIR) $(1)/usr/lib
  218. $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libcrypto.so.* $(1)/usr/lib/
  219. $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libssl.so.* $(1)/usr/lib/
  220. endef
  221. define Package/openssl-util/install
  222. $(INSTALL_DIR) $(1)/etc/ssl
  223. $(CP) $(PKG_INSTALL_DIR)/etc/ssl/openssl.cnf $(1)/etc/ssl/
  224. $(INSTALL_DIR) $(1)/etc/ssl/certs
  225. $(INSTALL_DIR) $(1)/etc/ssl/private
  226. chmod 0700 $(1)/etc/ssl/private
  227. $(INSTALL_DIR) $(1)/usr/bin
  228. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/openssl $(1)/usr/bin/
  229. endef
  230. $(eval $(call BuildPackage,libopenssl))
  231. $(eval $(call BuildPackage,openssl-util))