Makefile 6.0 KB

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