CC: curl: detect the library as renamed wolfssl
[15.05/openwrt.git] / package / network / utils / curl / patches / 110-cyassl-detect-the-library-as-renamed-wolfssl.patch
1 From 7868dc7103b40484d177985bb04270250a50e262 Mon Sep 17 00:00:00 2001
2 From: Dan Fandrich <dan@coneharvesters.com>
3 Date: Thu, 19 Mar 2015 23:41:10 +0100
4 Subject: [PATCH] cyassl: detect the library as renamed wolfssl
5
6 This change was made in CyaSSL/WolfSSL ver. 3.4.0
7 ---
8  configure.ac | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
9  1 file changed, 57 insertions(+), 3 deletions(-)
10
11 --- a/configure.ac
12 +++ b/configure.ac
13 @@ -1578,8 +1578,10 @@ if test "$curl_ssl_msg" = "$init_ssl_msg
14                  AC_CHECK_FUNCS( ENGINE_load_builtin_engines )
15                ])
16  
17 -    dnl these can only exist if openssl exists
18 -    dnl yassl doesn't have SSL_get_shutdown
19 +    dnl These can only exist if OpenSSL exists
20 +    dnl Older versions of Cyassl (some time before 2.9.4) don't have
21 +    dnl SSL_get_shutdown (but this check won't actually detect it there
22 +    dnl as it's a macro that needs the header files be included)
23  
24      AC_CHECK_FUNCS( RAND_status \
25                      RAND_screen \
26 @@ -1943,6 +1945,10 @@ if test "$curl_ssl_msg" = "$init_ssl_msg
27        OPT_CYASSL=""
28      fi
29  
30 +    dnl This should be reworked to use pkg-config instead
31 +
32 +    cyassllibname=cyassl
33 +
34      if test -z "$OPT_CYASSL" ; then
35        dnl check for lib in system default first
36  
37 @@ -1984,7 +1990,55 @@ if test "$curl_ssl_msg" = "$init_ssl_msg
38         [
39           CPPFLAGS=$_cppflags
40           LDFLAGS=$_ldflags
41 +         cyassllib=""
42 +       ])
43 +    fi
44 +
45 +    addld=""
46 +    addlib=""
47 +    addcflags=""
48 +
49 +    if test "x$USE_CYASSL" != "xyes"; then
50 +      dnl libcyassl renamed to libwolfssl as of 3.4.0
51 +      addld=-L$OPT_CYASSL/lib$libsuff
52 +      addcflags=-I$OPT_CYASSL/include
53 +      cyassllib=$OPT_CYASSL/lib$libsuff
54 +
55 +      LDFLAGS="$LDFLAGS $addld"
56 +      if test "$addcflags" != "-I/usr/include"; then
57 +         CPPFLAGS="$CPPFLAGS $addcflags"
58 +      fi
59 +
60 +      cyassllibname=wolfssl
61 +      my_ac_save_LIBS="$LIBS"
62 +      LIBS="-l$cyassllibname -lm $LIBS"
63 +
64 +      AC_MSG_CHECKING([for CyaSSL_Init in -lwolfssl])
65 +      AC_LINK_IFELSE([
66 +       AC_LANG_PROGRAM([[
67 +/* These aren't needed for detection and confuse WolfSSL.
68 +   They are set up properly later if it is detected.  */
69 +#undef SIZEOF_LONG
70 +#undef SIZEOF_LONG_LONG
71 +#include <cyassl/ssl.h>
72 +       ]],[[
73 +         return CyaSSL_Init();
74 +       ]])
75 +      ],[
76 +         AC_MSG_RESULT(yes)
77 +         AC_DEFINE(USE_CYASSL, 1, [if CyaSSL is enabled])
78 +         AC_SUBST(USE_CYASSL, [1])
79 +         CYASSL_ENABLED=1
80 +         USE_CYASSL="yes"
81 +         curl_ssl_msg="enabled (CyaSSL)"
82 +       ],
83 +       [
84 +         AC_MSG_RESULT(no)
85 +         CPPFLAGS=$_cppflags
86 +         LDFLAGS=$_ldflags
87 +         cyassllib=""
88         ])
89 +      LIBS="$my_ac_save_LIBS"
90      fi
91  
92      if test "x$USE_CYASSL" = "xyes"; then
93 @@ -1996,7 +2050,7 @@ if test "$curl_ssl_msg" = "$init_ssl_msg
94        dnl Versions since at least 2.9.4 renamed error.h to error-ssl.h
95        AC_CHECK_HEADERS(cyassl/error-ssl.h)
96  
97 -      LIBS="-lcyassl -lm $LIBS"
98 +      LIBS="-l$cyassllibname -lm $LIBS"
99  
100        if test -n "$cyassllib"; then
101          dnl when shared libs were found in a path that the run-time