Makefile 6.8 KB

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