Makefile 6.1 KB

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