Makefile 6.8 KB

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