Makefile 7.0 KB

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