xref: /unit/auto/ssltls (revision 0:a63ceefd6ab0)
1
2# Copyright (C) Igor Sysoev
3# Copyright (C) NGINX, Inc.
4
5
6NXT_OPENSSL_CFLAGS=
7NXT_OPENSSL_LIBS=
8NXT_GNUTLS_CFLAGS=
9NXT_GNUTLS_LIBS=
10NXT_OPENSSL_LIBS=
11NXT_CYASSL_CFLAGS=
12NXT_CYASSL_LIBS=
13NXT_POLARSSL_CFLAGS=
14NXT_POLARSSL_LIBS=
15
16
17if [ $NXT_OPENSSL = YES ]; then
18
19    nxt_feature="OpenSSL library"
20    nxt_feature_name=NXT_HAVE_OPENSSL
21    nxt_feature_run=yes
22    nxt_feature_incs=
23    nxt_feature_libs="-lssl -lcrypto"
24    nxt_feature_test="#include <openssl/ssl.h>
25
26                      int main() {
27                          SSL_library_init();
28                          return 0;
29                      }"
30    . auto/feature
31
32
33    if [ $nxt_found = yes ]; then
34        NXT_SSLTLS=YES
35        NXT_OPENSSL_LIBS="$nxt_feature_libs"
36
37        nxt_feature="OpenSSL version"
38        nxt_feature_name=NXT_HAVE_OPENSSL_VERSION
39        nxt_feature_run=value
40        nxt_feature_test="#include <openssl/ssl.h>
41
42                          int main() {
43                              printf(\"\\\"%s\\\"\",
44                                     SSLeay_version(SSLEAY_VERSION));
45                              return 0;
46                          }"
47        . auto/feature
48
49    else
50        $echo
51        $echo $0: error: no OpenSSL library found.
52        $echo
53        exit 1;
54    fi
55fi
56
57
58if [ $NXT_GNUTLS = YES ]; then
59
60    if /bin/sh -c "(pkg-config gnutls --exists)" >> $NXT_AUTOCONF_ERR 2>&1;
61    then
62        NXT_GNUTLS_CFLAGS=`pkg-config gnutls --cflags`
63        NXT_GNUTLS_LIBS=`pkg-config gnutls --libs`
64
65        nxt_feature="GnuTLS library"
66        nxt_feature_name=NXT_HAVE_GNUTLS
67        nxt_feature_run=yes
68        nxt_feature_incs=$NXT_GNUTLS_CFLAGS
69        nxt_feature_libs=$NXT_GNUTLS_LIBS
70        nxt_feature_test="#include <gnutls/gnutls.h>
71
72                          int main() {
73                              gnutls_global_init();
74                              gnutls_global_deinit();
75                              return 0;
76                          }"
77        . auto/feature
78
79
80        if [ $nxt_found = yes ]; then
81            NXT_SSLTLS=YES
82
83            $echo " + GnuTLS version: `pkg-config gnutls --modversion`"
84
85
86            nxt_feature="gnutls_transport_set_vec_push_function"
87            nxt_feature_name=NXT_HAVE_GNUTLS_VEC_PUSH
88            nxt_feature_run=no
89            nxt_feature_incs=$NXT_GNUTLS_CFLAGS
90            nxt_feature_libs=$NXT_GNUTLS_LIBS
91            nxt_feature_test="#include <gnutls/gnutls.h>
92
93                      int main() {
94                          gnutls_transport_set_vec_push_function(NULL, NULL);
95                          return 0;
96                      }"
97            . auto/feature
98
99
100            nxt_feature="gnutls_global_set_time_function"
101            nxt_feature_name=NXT_HAVE_GNUTLS_SET_TIME
102            nxt_feature_run=no
103            nxt_feature_incs=$NXT_GNUTLS_CFLAGS
104            nxt_feature_libs=$NXT_GNUTLS_LIBS
105            nxt_feature_test="#include <gnutls/gnutls.h>
106
107                      int main() {
108                          gnutls_global_set_time_function(NULL);
109                          return 0;
110                      }"
111            . auto/feature
112
113        else
114            $echo
115            $echo $0: error: no GnuTLS library found.
116            $echo
117            exit 1;
118        fi
119    fi
120fi
121
122
123if [ $NXT_CYASSL = YES ]; then
124
125    nxt_feature="CyaSSL library"
126    nxt_feature_name=NXT_HAVE_CYASSL
127    nxt_feature_run=yes
128    nxt_feature_incs=
129    nxt_feature_libs="-lcyassl"
130    nxt_feature_test="#include <cyassl/ssl.h>
131
132                      int main() {
133                          CyaSSL_Init();
134                          CyaSSL_Cleanup();
135                          return 0;
136                      }"
137    . auto/feature
138
139
140    if [ $nxt_found = yes ]; then
141        NXT_SSLTLS=YES
142        NXT_CYASSL_CFLAGS="$nxt_feature_incs"
143        NXT_CYASSL_LIBS="$nxt_feature_libs"
144
145    else
146        $echo
147        $echo $0: error: no CyaSSL library found.
148        $echo
149        exit 1;
150    fi
151fi
152
153
154if [ $NXT_POLARSSL = YES ]; then
155
156    nxt_feature="PolarSSL library"
157    nxt_feature_name=NXT_HAVE_POLARSSL
158    nxt_feature_run=yes
159    nxt_feature_incs=
160    nxt_feature_libs="-lpolarssl"
161    nxt_feature_test="#include <polarssl/ssl.h>
162
163                      int main() {
164                          ssl_context  ssl;
165                          memset(&ssl, '\0', sizeof(ssl));
166                          ssl_init(&ssl);
167                          ssl_free(&ssl);
168                          return 0;
169                      }"
170    . auto/feature
171
172
173    if [ $nxt_found = yes ]; then
174        NXT_SSLTLS=YES
175        NXT_POLARSSL_CFLAGS="$nxt_feature_incs"
176        NXT_POLARSSL_LIBS="$nxt_feature_libs"
177
178    else
179        $echo
180        $echo $0: error: no PolarSSL library found.
181        $echo
182        exit 1;
183    fi
184fi
185