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