Makefile 6.9 KB

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