Makefile 6.0 KB

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