configure: get API info for a couple of OpenSSL functions
[platform/upstream/curl.git] / m4 / curl-openssl.m4
1 #***************************************************************************
2 #                                  _   _ ____  _
3 #  Project                     ___| | | |  _ \| |
4 #                             / __| | | | |_) | |
5 #                            | (__| |_| |  _ <| |___
6 #                             \___|\___/|_| \_\_____|
7 #
8 # Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
9 #
10 # This software is licensed as described in the file COPYING, which
11 # you should have received as part of this distribution. The terms
12 # are also available at http://curl.haxx.se/docs/copyright.html.
13 #
14 # You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 # copies of the Software, and permit persons to whom the Software is
16 # furnished to do so, under the terms of the COPYING file.
17 #
18 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 # KIND, either express or implied.
20 #
21 #***************************************************************************
22
23 # File version for 'aclocal' use. Keep it a single number.
24 # serial 1
25
26
27 dnl CURL_CHECK_OPENSSL_ADD_ALL_API
28 dnl -------------------------------------------------
29 dnl Link time verification check of which API is
30 dnl used for for the *_add_all_algorithms function.
31
32 AC_DEFUN([CURL_CHECK_OPENSSL_ADD_ALL_API], [
33   #
34   tst_links_add_all_api_091="unknown"
35   tst_links_add_all_api_095="unknown"
36   tst_links_add_all_api_097="unknown"
37   #
38   AC_MSG_CHECKING([if OpenSSL *_add_all_algorithms API is 0.9.1])
39   AC_LINK_IFELSE([
40     AC_LANG_PROGRAM([[
41     ]],[[
42       SSLeay_add_all_algorithms();
43     ]])
44   ],[
45     AC_MSG_RESULT([yes])
46     tst_links_add_all_api_091="yes"
47   ],[
48     AC_MSG_RESULT([no])
49     tst_links_add_all_api_091="no"
50   ])
51   if test "$tst_links_add_all_api_091" != "yes"; then
52     AC_MSG_CHECKING([if OpenSSL *_add_all_algorithms API is 0.9.5])
53     AC_LINK_IFELSE([
54       AC_LANG_PROGRAM([[
55       ]],[[
56         OpenSSL_add_all_algorithms();
57       ]])
58     ],[
59       AC_MSG_RESULT([yes])
60       tst_links_add_all_api_095="yes"
61     ],[
62       AC_MSG_RESULT([no])
63       tst_links_add_all_api_095="no"
64     ])
65   fi
66   if test "$tst_links_add_all_api_091" != "yes" &&
67      test "$tst_links_add_all_api_095" != "yes"; then
68     AC_MSG_CHECKING([if OpenSSL *_add_all_algorithms API is 0.9.7])
69     AC_LINK_IFELSE([
70       AC_LANG_PROGRAM([[
71       ]],[[
72         OPENSSL_add_all_algorithms_conf();
73         OPENSSL_add_all_algorithms_noconf();
74       ]])
75     ],[
76       AC_MSG_RESULT([yes])
77       tst_links_add_all_api_097="yes"
78     ],[
79       AC_MSG_RESULT([no])
80       tst_links_add_all_api_097="no"
81     ])
82   fi
83   #
84   if test "$tst_links_add_all_api_091" = "yes"; then
85     AC_DEFINE_UNQUOTED(HAVE_OPENSSL_ADD_ALL_API_091, 1,
86       [Define to 1 if OpenSSL *_add_all_algorithms API is 0.9.1])
87   elif test "$tst_links_add_all_api_095" = "yes"; then
88     AC_DEFINE_UNQUOTED(HAVE_OPENSSL_ADD_ALL_API_095, 1,
89       [Define to 1 if OpenSSL *_add_all_algorithms API is 0.9.5])
90   elif test "$tst_links_add_all_api_097" = "yes"; then
91     AC_DEFINE_UNQUOTED(HAVE_OPENSSL_ADD_ALL_API_097, 1,
92       [Define to 1 if OpenSSL *_add_all_algorithms API is 0.9.7])
93   fi
94 ])
95
96
97 dnl CURL_CHECK_OPENSSL_DESRANDKEY_API
98 dnl -------------------------------------------------
99 dnl Verify if DES_random_key or des_random_key can be
100 dnl linked. When true, define HAVE_DES_RANDOM_KEY_097
101 dnl or HAVE_DES_RANDOM_KEY_LOWER.
102
103 AC_DEFUN([CURL_CHECK_OPENSSL_DESRANDKEY_API], [
104   #
105   tst_links_des_random_key_api_097="unknown"
106   tst_links_des_random_key_api_095="unknown"
107   #
108   AC_MSG_CHECKING([if OpenSSL des_random_key API is 0.9.7])
109   AC_LINK_IFELSE([
110     AC_LANG_PROGRAM([[
111     ]],[[
112       if(0 != DES_random_key(0))
113         return 1;
114     ]])
115   ],[
116     AC_MSG_RESULT([yes])
117     tst_links_des_random_key_api_097="yes"
118   ],[
119     AC_MSG_RESULT([no])
120     tst_links_des_random_key_api_097="no"
121   ])
122   if test "$tst_links_des_random_key_api_097" != "yes"; then
123     AC_MSG_CHECKING([if OpenSSL des_random_key API is 0.9.5])
124     AC_LINK_IFELSE([
125       AC_LANG_PROGRAM([[
126       ]],[[
127         if(0 != des_random_key(0))
128           return 1;
129       ]])
130     ],[
131       AC_MSG_RESULT([yes])
132       tst_links_des_random_key_api_095="yes"
133     ],[
134       AC_MSG_RESULT([no])
135       tst_links_des_random_key_api_095="no"
136     ])
137   fi
138   #
139   if test "$tst_links_des_random_key_api_097" = "yes"; then
140     AC_DEFINE_UNQUOTED(HAVE_OPENSSL_DESRANDKEY_API_097, 1,
141       [Define to 1 if OpenSSL des_random_key API is 0.9.7])
142   elif test "$tst_links_des_random_key_api_095" = "yes"; then
143     AC_DEFINE_UNQUOTED(HAVE_OPENSSL_DESRANDKEY_API_095, 1,
144       [Define to 1 if OpenSSL des_random_key API is 0.9.5])
145   fi
146 ])