Makefile 5.9 KB

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