@@ -83,78 +83,81 @@ AC_C_BIGENDIAN
83
83
dnl check for how to do large files
84
84
AC_SYS_LARGEFILE
85
85
86
- found_crypto=none
87
-
88
86
# Configure parameters
89
- AC_ARG_WITH ( openssl ,
90
- AC_HELP_STRING ( [ --with-openssl] ,[ Use OpenSSL for crypto] ) ,
91
- use_openssl=$withval ,use_openssl=auto )
92
- AC_ARG_WITH ( libgcrypt ,
93
- AC_HELP_STRING ( [ --with-libgcrypt] ,[ Use libgcrypt for crypto] ) ,
94
- [ use_libgcrypt=$withval
95
- LIBSSH2_CHECKFOR_GCRYPT
96
- ] , use_libgcrypt=auto )
97
- AC_ARG_WITH ( wincng ,
98
- AC_HELP_STRING ( [ --with-wincng] ,[ Use Windows CNG for crypto] ) ,
99
- [ use_wincng=$withval
100
- LIBSSH2_CHECKFOR_WINCNG
101
- ] ,use_wincng=auto )
102
- AC_ARG_WITH ( [ mbedtls] ,
103
- AC_HELP_STRING ( [ --with-mbedtls] ,[ Use mbedTLS for crypto] ) ,
104
- [ use_mbedtls=$withval
105
- LIBSSH2_CHECKFOR_MBEDTLS
106
- ] , use_mbedtls=auto
107
- )
108
- AC_ARG_WITH ( libz ,
109
- AC_HELP_STRING ( [ --with-libz] ,[ Use zlib for compression] ) ,
110
- use_libz=$withval ,use_libz=auto )
111
87
88
+
89
+ # Crypto backends
90
+
91
+ found_crypto=none
92
+ found_crypto_str=""
112
93
support_clear_memory=no
94
+ crypto_errors=""
95
+
96
+ m4_set_add ( [ crypto_backends] , [ openssl] )
97
+ m4_set_add ( [ crypto_backends] , [ libgcrypt] )
98
+ m4_set_add ( [ crypto_backends] , [ mbedtls] )
99
+ m4_set_add ( [ crypto_backends] , [ wincng] )
100
+
101
+ AC_ARG_WITH ( [ crypto] ,
102
+ AC_HELP_STRING ( [ --with-crypto=auto|] m4_set_contents ( [ crypto_backends] , [ |] ) ,
103
+ [ Select crypto backend (default: auto)] ) ,
104
+ use_crypto=$withval ,
105
+ use_crypto=auto
106
+ )
113
107
114
- # Look for OpenSSL
115
- if test "$found_crypto" = "none" && test "$use_openssl" != "no"; then
116
- AC_LIB_HAVE_LINKFLAGS([ ssl] , [ crypto] , [ #include <openssl/ssl.h>] )
117
- fi
118
- if test "$ac_cv_libssl" = "yes"; then
119
- AC_DEFINE ( LIBSSH2_OPENSSL , 1 , [ Use OpenSSL] )
120
- LIBSREQUIRED=libssl,libcrypto
108
+ case "${use_crypto}" in
109
+ auto|m4_set_contents ( [ crypto_backends] , [ |] ) )
110
+ m4_set_map ( [ crypto_backends] , [ LIBSSH2_CHECK_CRYPTO] )
111
+ ;;
112
+ yes|"")
113
+ crypto_errors="No crypto backend specified!"
114
+ ;;
115
+ *)
116
+ crypto_errors="Unknown crypto backend '${use_crypto}' specified!"
117
+ ;;
118
+ esac
121
119
122
- # Not all OpenSSL have AES-CTR functions.
123
- save_LIBS="$LIBS"
124
- LIBS="$LIBS $LIBSSL"
125
- AC_CHECK_FUNCS ( EVP_aes_128_ctr )
126
- LIBS="$save_LIBS"
120
+ if test "$found_crypto" = "none"; then
121
+ crypto_errors="${crypto_errors}
122
+ Specify --with-crypto=\$backend and/or the neccessary library search prefix.
127
123
128
- found_crypto="OpenSSL (AES-CTR: ${ac_cv_func_EVP_aes_128_ctr:-N/A})"
124
+ Known crypto backends: auto, m4_set_contents ( [ crypto_backends] , [ , ] ) "
125
+ AS_MESSAGE([ ERROR: ${crypto_errors}] )
126
+ else
127
+ test "$found_crypto_str" = "" && found_crypto_str="$found_crypto"
129
128
fi
130
129
131
- AM_CONDITIONAL(OPENSSL, test "$ac_cv_libssl" = "yes")
132
- AM_CONDITIONAL(WINCNG , test "$ac_cv_libbcrypt " = "yes")
133
- AM_CONDITIONAL(LIBGCRYPT, test "$ac_cv_libgcrypt" = "yes" )
134
- AM_CONDITIONAL(MBEDTLS, test "$ac_cv_libmbedtls" = "yes" )
130
+ m4_set_foreach ( [ crypto_backends ] , [ backend ] ,
131
+ [ AM_CONDITIONAL(m4_toupper ( backend ) , test "$found_crypto " = "backend") ]
132
+ )
133
+ m4_undefine ( [ backend ] )
135
134
136
- # Check if crypto library was found
137
- if test "$found_crypto" = "none"; then
138
- AC_MSG_ERROR ( [ No crypto library found!
139
- Try --with-libssl-prefix=PATH
140
- or --with-libgcrypt-prefix=PATH
141
- or --with-libmbedtls-prefix=PATH
142
- or --with-wincng on Windows\
143
- ] )
144
- fi
145
135
146
- # Look for Libz
147
- if test "$use_libz" != "no"; then
136
+ # libz
137
+
138
+ AC_ARG_WITH ( [ libz] ,
139
+ AC_HELP_STRING ( [ --with-libz] ,[ Use libz for compression] ) ,
140
+ use_libz=$withval ,
141
+ use_libz=auto )
142
+
143
+ found_libz=no
144
+ libz_errors=""
145
+
146
+ if test "$use_libz" != no; then
148
147
AC_LIB_HAVE_LINKFLAGS([ z] , [ ] , [ #include <zlib.h>] )
149
148
if test "$ac_cv_libz" != yes; then
150
- AC_MSG_NOTICE ( [ Cannot find zlib, disabling compression] )
151
- AC_MSG_NOTICE ( [ Try --with-libz-prefix=PATH if you know you have it] )
149
+ if test "$use_libz" = auto; then
150
+ AC_MSG_NOTICE ( [ Cannot find libz, disabling compression] )
151
+ found_libz="disabled; no libz found"
152
+ else
153
+ libz_errors="No libz found!
154
+ Try --with-libz-prefix=PATH if you know that you have it."
155
+ AS_MESSAGE([ ERROR: $libz_errors] )
156
+ fi
152
157
else
153
158
AC_DEFINE ( LIBSSH2_HAVE_ZLIB , 1 , [ Compile in zlib support] )
154
- if test "${LIBSREQUIRED}" != ""; then
155
- LIBSREQUIRED="${LIBSREQUIRED},"
156
- fi
157
- LIBSREQUIRED="${LIBSREQUIRED}zlib"
159
+ LIBSREQUIRED="$LIBSREQUIRED${LIBSREQUIRED:+ }zlib"
160
+ found_libz="yes"
158
161
fi
159
162
fi
160
163
@@ -351,6 +354,22 @@ AC_C_INLINE
351
354
352
355
CURL_CHECK_NONBLOCKING_SOCKET
353
356
357
+ missing_required_deps=0
358
+
359
+ if test "${libz_errors}" != ""; then
360
+ AS_MESSAGE([ ERROR: ${libz_errors}] )
361
+ missing_required_deps=1
362
+ fi
363
+
364
+ if test "$found_crypto" = "none"; then
365
+ AS_MESSAGE([ ERROR: ${crypto_errors}] )
366
+ missing_required_deps=1
367
+ fi
368
+
369
+ if test $missing_required_deps = 1; then
370
+ AC_MSG_ERROR ( [ Required dependencies are missing!] )
371
+ fi
372
+
354
373
AC_CONFIG_FILES ( [ Makefile
355
374
src/Makefile
356
375
tests/Makefile
@@ -367,10 +386,10 @@ AC_MSG_NOTICE([summary of build options:
367
386
Compiler: ${CC}
368
387
Compiler flags: ${CFLAGS}
369
388
Library types: Shared=${enable_shared}, Static=${enable_static}
370
- Crypto library: ${found_crypto }
389
+ Crypto library: ${found_crypto_str }
371
390
Clear memory: $enable_clear_memory
372
391
Debug build: $enable_debug
373
392
Build examples: $build_examples
374
393
Path to sshd: $ac_cv_path_SSHD (only for self-tests)
375
- zlib compression: $ac_cv_libz
394
+ zlib compression: ${found_libz}
376
395
] )
0 commit comments