diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2014-03-05 13:20:49 +0000 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2014-03-05 13:20:49 +0000 |
commit | 1087b3a1c465fb61a9b8782c383a9fd4e27d3ed6 (patch) | |
tree | 7defc8869cb7500e9cc78ad0dc46a315f92a25ae | |
parent | 461e56367f343dca3d0fe111c7c7242b8c28e6fb (diff) | |
download | libmicrohttpd-1087b3a1c465fb61a9b8782c383a9fd4e27d3ed6.tar.gz libmicrohttpd-1087b3a1c465fb61a9b8782c383a9fd4e27d3ed6.zip |
rewritten configure tests for OpenSSL, use OpenSSL flags only where required, updated libmicrospdy build flags
-rw-r--r-- | configure.ac | 71 | ||||
-rw-r--r-- | m4/ax_check_openssl.m4 | 124 | ||||
-rw-r--r-- | m4/openssl.m4 | 69 | ||||
-rw-r--r-- | src/microspdy/Makefile.am | 8 |
4 files changed, 174 insertions, 98 deletions
diff --git a/configure.ac b/configure.ac index 847aefcb..379756a6 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -380,24 +380,49 @@ AC_CHECK_LIB([[magic]], [[magic_open]], | |||
380 | 380 | ||
381 | # optional: libmicrospdy support. Enabled by default if not on W32 | 381 | # optional: libmicrospdy support. Enabled by default if not on W32 |
382 | AC_ARG_ENABLE([spdy], | 382 | AC_ARG_ENABLE([spdy], |
383 | AS_HELP_STRING([--disable-spdy], | 383 | AS_HELP_STRING([--enable-spdy], |
384 | [disable libmicrospdy]), | 384 | [enable build libmicrospdy (yes, no, auto) [auto]]), |
385 | [enable_spdy=${enableval}], | 385 | [enable_spdy=${enableval}], |
386 | [ AS_IF([[test "x$os_is_windows" = "xyes"]], [enable_spdy=no], [enable_spdy=yes]) ]) | 386 | [ AS_IF([[test "x$os_is_windows" = "xyes"]], [enable_spdy=no]) ]) |
387 | 387 | ||
388 | if test "$enable_spdy" = "yes" | 388 | if test "$enable_spdy" != "no" |
389 | then | 389 | then |
390 | AC_CHECK_HEADERS([openssl/err.h], | 390 | AX_CHECK_OPENSSL([ have_openssl=yes ],[ have_openssl=no ]) |
391 | AC_CHECK_LIB(ssl, SSL_CTX_set_next_protos_advertised_cb, | 391 | if test "x$have_openssl" = "xyes" |
392 | [AM_CONDITIONAL(HAVE_OPENSSL, true) | 392 | then |
393 | enable_spdy="yes"], | 393 | # check OpenSSL headers |
394 | [AM_CONDITIONAL(HAVE_OPENSSL, false) | 394 | SAVE_CPP_FLAGS="$CPPFLAGS" |
395 | enable_spdy="no"]), | 395 | CPPFLAGS="$OPENSSL_INCLUDES $CPPFLAGS" |
396 | [AM_CONDITIONAL(HAVE_OPENSSL, false) | 396 | AC_CHECK_HEADERS([openssl/evp.h openssl/rsa.h openssl/rand.h openssl/err.h openssl/sha.h openssl/pem.h openssl/engine.h], [ have_openssl=yes ],[ have_openssl=no ]) |
397 | enable_spdy="no"]) | 397 | if test "x$have_openssl" = "xyes" |
398 | then | ||
399 | # check OpenSSL libs | ||
400 | SAVE_LIBS="$LIBS" | ||
401 | SAVE_LD_FLAGS="$LDFLAGS" | ||
402 | LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS" | ||
403 | LIBS="$OPENSSL_LIBS $LIBS" | ||
404 | AC_CHECK_FUNC([SSL_CTX_set_next_protos_advertised_cb], | ||
405 | [ | ||
406 | AC_CHECK_FUNC([SSL_library_init], [ have_openssl=yes ],[ have_openssl=no ]) | ||
407 | ],[ have_openssl=no ]) | ||
408 | LIBS="$SAVE_LIBS" | ||
409 | LDFLAGS="$SAVE_LD_FLAGS" | ||
410 | fi | ||
411 | CPPFLAGS="$SAVE_CPP_FLAGS" | ||
412 | fi | ||
413 | if test "x$have_openssl" = "xyes" | ||
414 | then | ||
415 | enable_spdy=yes | ||
416 | else | ||
417 | AS_IF([[test "x$enable_spdy" = "xyes" ]], [AC_MSG_ERROR([[libmicrospdy cannot be enabled without OpenSSL.]])]) | ||
418 | have_openssl=no | ||
419 | enable_spdy=no | ||
420 | fi | ||
398 | else | 421 | else |
399 | AM_CONDITIONAL(HAVE_OPENSSL, false) | 422 | # OpenSSL is used only for libmicrospdy |
423 | have_openssl=no | ||
400 | fi | 424 | fi |
425 | AM_CONDITIONAL([HAVE_OPENSSL], [test "x$have_openssl" = "xyes"]) | ||
401 | 426 | ||
402 | if test "$enable_spdy" = "yes" | 427 | if test "$enable_spdy" = "yes" |
403 | then | 428 | then |
@@ -409,24 +434,20 @@ AM_CONDITIONAL(ENABLE_SPDY, [test "x$enable_spdy" != "xno"]) | |||
409 | AC_MSG_CHECKING(whether we have OpenSSL and thus can support libmicrospdy) | 434 | AC_MSG_CHECKING(whether we have OpenSSL and thus can support libmicrospdy) |
410 | AC_MSG_RESULT($enable_spdy) | 435 | AC_MSG_RESULT($enable_spdy) |
411 | 436 | ||
412 | SAVE_LIBS=$LIBS | ||
413 | spdy_OPENSSL | ||
414 | # for pkg-config | 437 | # for pkg-config |
415 | SPDY_LIBDEPS="" | 438 | SPDY_LIBDEPS="$OPENSSL_LIBS" |
416 | |||
417 | |||
418 | AC_CHECK_HEADERS([spdylay/spdylay.h], | ||
419 | [AM_CONDITIONAL(HAVE_SPDYLAY, true) | ||
420 | have_spdylay="yes"], | ||
421 | [AM_CONDITIONAL(HAVE_SPDYLAY, false) | ||
422 | have_spdylay="no"]) | ||
423 | 439 | ||
440 | SPDY_LIB_LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS" | ||
441 | SPDY_LIB_CFLAGS="$CFLAGS" | ||
442 | SPDY_LIB_CPPFLAGS="$OPENSSL_INCLUDES $CPPFLAGS" | ||
424 | AC_SUBST(SPDY_LIB_LDFLAGS) | 443 | AC_SUBST(SPDY_LIB_LDFLAGS) |
444 | AC_SUBST(SPDY_LIB_CFLAGS) | ||
445 | AC_SUBST(SPDY_LIB_CPPFLAGS) | ||
425 | # for pkg-config | 446 | # for pkg-config |
426 | AC_SUBST(SPDY_LIBDEPS) | 447 | AC_SUBST(SPDY_LIBDEPS) |
427 | 448 | ||
428 | 449 | AC_CHECK_HEADERS([spdylay/spdylay.h], [ have_spdylay="yes" ], [have_spdylay="no"]) | |
429 | LIBS=$SAVE_LIBS | 450 | AM_CONDITIONAL(HAVE_SPDYLAY, [test "x$have_spdylay" = "xyes"]) |
430 | 451 | ||
431 | # large file support (> 4 GB) | 452 | # large file support (> 4 GB) |
432 | AC_SYS_LARGEFILE | 453 | AC_SYS_LARGEFILE |
diff --git a/m4/ax_check_openssl.m4 b/m4/ax_check_openssl.m4 new file mode 100644 index 00000000..a87c5a6b --- /dev/null +++ b/m4/ax_check_openssl.m4 | |||
@@ -0,0 +1,124 @@ | |||
1 | # =========================================================================== | ||
2 | # http://www.gnu.org/software/autoconf-archive/ax_check_openssl.html | ||
3 | # =========================================================================== | ||
4 | # | ||
5 | # SYNOPSIS | ||
6 | # | ||
7 | # AX_CHECK_OPENSSL([action-if-found[, action-if-not-found]]) | ||
8 | # | ||
9 | # DESCRIPTION | ||
10 | # | ||
11 | # Look for OpenSSL in a number of default spots, or in a user-selected | ||
12 | # spot (via --with-openssl). Sets | ||
13 | # | ||
14 | # OPENSSL_INCLUDES to the include directives required | ||
15 | # OPENSSL_LIBS to the -l directives required | ||
16 | # OPENSSL_LDFLAGS to the -L or -R flags required | ||
17 | # | ||
18 | # and calls ACTION-IF-FOUND or ACTION-IF-NOT-FOUND appropriately | ||
19 | # | ||
20 | # This macro sets OPENSSL_INCLUDES such that source files should use the | ||
21 | # openssl/ directory in include directives: | ||
22 | # | ||
23 | # #include <openssl/hmac.h> | ||
24 | # | ||
25 | # LICENSE | ||
26 | # | ||
27 | # Copyright (c) 2009,2010 Zmanda Inc. <http://www.zmanda.com/> | ||
28 | # Copyright (c) 2009,2010 Dustin J. Mitchell <dustin@zmanda.com> | ||
29 | # | ||
30 | # Copying and distribution of this file, with or without modification, are | ||
31 | # permitted in any medium without royalty provided the copyright notice | ||
32 | # and this notice are preserved. This file is offered as-is, without any | ||
33 | # warranty. | ||
34 | |||
35 | #serial 8 | ||
36 | |||
37 | AU_ALIAS([CHECK_SSL], [AX_CHECK_OPENSSL]) | ||
38 | AC_DEFUN([AX_CHECK_OPENSSL], [ | ||
39 | found=false | ||
40 | AC_ARG_WITH([openssl], | ||
41 | [AS_HELP_STRING([--with-openssl=DIR], | ||
42 | [root of the OpenSSL directory])], | ||
43 | [ | ||
44 | case "$withval" in | ||
45 | "" | y | ye | yes | n | no) | ||
46 | AC_MSG_ERROR([Invalid --with-openssl value]) | ||
47 | ;; | ||
48 | *) ssldirs="$withval" | ||
49 | ;; | ||
50 | esac | ||
51 | ], [ | ||
52 | # if pkg-config is installed and openssl has installed a .pc file, | ||
53 | # then use that information and don't search ssldirs | ||
54 | AC_PATH_PROG([PKG_CONFIG], [pkg-config]) | ||
55 | if test x"$PKG_CONFIG" != x""; then | ||
56 | OPENSSL_LDFLAGS=`$PKG_CONFIG openssl --libs-only-L 2>/dev/null` | ||
57 | if test $? = 0; then | ||
58 | OPENSSL_LIBS=`$PKG_CONFIG openssl --libs-only-l 2>/dev/null` | ||
59 | OPENSSL_INCLUDES=`$PKG_CONFIG openssl --cflags-only-I 2>/dev/null` | ||
60 | found=true | ||
61 | fi | ||
62 | fi | ||
63 | |||
64 | # no such luck; use some default ssldirs | ||
65 | if ! $found; then | ||
66 | ssldirs="/usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr" | ||
67 | fi | ||
68 | ] | ||
69 | ) | ||
70 | |||
71 | |||
72 | # note that we #include <openssl/foo.h>, so the OpenSSL headers have to be in | ||
73 | # an 'openssl' subdirectory | ||
74 | |||
75 | if ! $found; then | ||
76 | OPENSSL_INCLUDES= | ||
77 | for ssldir in $ssldirs; do | ||
78 | AC_MSG_CHECKING([for openssl/ssl.h in $ssldir]) | ||
79 | if test -f "$ssldir/include/openssl/ssl.h"; then | ||
80 | OPENSSL_INCLUDES="-I$ssldir/include" | ||
81 | OPENSSL_LDFLAGS="-L$ssldir/lib" | ||
82 | OPENSSL_LIBS="-lssl -lcrypto" | ||
83 | found=true | ||
84 | AC_MSG_RESULT([yes]) | ||
85 | break | ||
86 | else | ||
87 | AC_MSG_RESULT([no]) | ||
88 | fi | ||
89 | done | ||
90 | |||
91 | # if the file wasn't found, well, go ahead and try the link anyway -- maybe | ||
92 | # it will just work! | ||
93 | fi | ||
94 | |||
95 | # try the preprocessor and linker with our new flags, | ||
96 | # being careful not to pollute the global LIBS, LDFLAGS, and CPPFLAGS | ||
97 | |||
98 | AC_MSG_CHECKING([whether compiling and linking against OpenSSL works]) | ||
99 | echo "Trying link with OPENSSL_LDFLAGS=$OPENSSL_LDFLAGS;" \ | ||
100 | "OPENSSL_LIBS=$OPENSSL_LIBS; OPENSSL_INCLUDES=$OPENSSL_INCLUDES" >&AS_MESSAGE_LOG_FD | ||
101 | |||
102 | save_LIBS="$LIBS" | ||
103 | save_LDFLAGS="$LDFLAGS" | ||
104 | save_CPPFLAGS="$CPPFLAGS" | ||
105 | LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS" | ||
106 | LIBS="$OPENSSL_LIBS $LIBS" | ||
107 | CPPFLAGS="$OPENSSL_INCLUDES $CPPFLAGS" | ||
108 | AC_LINK_IFELSE( | ||
109 | [AC_LANG_PROGRAM([#include <openssl/ssl.h>], [SSL_new(NULL)])], | ||
110 | [ | ||
111 | AC_MSG_RESULT([yes]) | ||
112 | $1 | ||
113 | ], [ | ||
114 | AC_MSG_RESULT([no]) | ||
115 | $2 | ||
116 | ]) | ||
117 | CPPFLAGS="$save_CPPFLAGS" | ||
118 | LDFLAGS="$save_LDFLAGS" | ||
119 | LIBS="$save_LIBS" | ||
120 | |||
121 | AC_SUBST([OPENSSL_INCLUDES]) | ||
122 | AC_SUBST([OPENSSL_LIBS]) | ||
123 | AC_SUBST([OPENSSL_LDFLAGS]) | ||
124 | ]) | ||
diff --git a/m4/openssl.m4 b/m4/openssl.m4 deleted file mode 100644 index 1317e7e4..00000000 --- a/m4/openssl.m4 +++ /dev/null | |||
@@ -1,69 +0,0 @@ | |||
1 | dnl Check to find the OpenSSL headers/libraries | ||
2 | |||
3 | AC_DEFUN([spdy_OPENSSL], | ||
4 | [ | ||
5 | AC_ARG_WITH(openssl, | ||
6 | AS_HELP_STRING([--with-openssl=DIR], [OpenSSL base directory, or:]), | ||
7 | [openssl="$withval" | ||
8 | CPPFLAGS="$CPPFLAGS -I$withval/include" | ||
9 | LDFLAGS="$LDFLAGS -L$withval/lib"] | ||
10 | ) | ||
11 | |||
12 | AC_ARG_WITH(openssl-include, | ||
13 | AS_HELP_STRING([--with-openssl-include=DIR], [OpenSSL headers directory (without trailing /openssl)]), | ||
14 | [openssl_include="$withval" | ||
15 | CPPFLAGS="$CPPFLAGS -I$withval"] | ||
16 | ) | ||
17 | |||
18 | AC_ARG_WITH(openssl-lib, | ||
19 | AS_HELP_STRING([--with-openssl-lib=DIR], [OpenSSL library directory]), | ||
20 | [openssl_lib="$withval" | ||
21 | LDFLAGS="$LDFLAGS -L$withval"] | ||
22 | ) | ||
23 | |||
24 | AC_CHECK_HEADERS(openssl/evp.h openssl/rsa.h openssl/rand.h openssl/err.h openssl/sha.h openssl/pem.h openssl/engine.h, | ||
25 | [], | ||
26 | [AC_MSG_WARN([OpenSSL header files not found.]); break] | ||
27 | ) | ||
28 | |||
29 | case $host_os in | ||
30 | *mingw*) | ||
31 | AC_CHECK_LIB(crypto, SHA1_Init, | ||
32 | [LIBS="$LIBS -lcrypto -lgdi32"], | ||
33 | [AC_MSG_WARN([OpenSSL libraries not found.])] | ||
34 | ) | ||
35 | ;; | ||
36 | *) | ||
37 | |||
38 | AC_CHECK_LIB(crypto, SHA1_Init, | ||
39 | [LIBS="$LIBS -lcrypto"], | ||
40 | [AC_MSG_WARN([OpenSSL libraries not found.])] | ||
41 | ) | ||
42 | |||
43 | AC_CHECK_FUNC(dlopen, | ||
44 | [], | ||
45 | [AC_CHECK_LIB(dl, dlopen, | ||
46 | [LIBS="$LIBS -ldl"], | ||
47 | [AC_MSG_WARN([OpenSSL depends on libdl.]); break] | ||
48 | )] | ||
49 | ) | ||
50 | |||
51 | AC_CHECK_FUNC(SSL_library_init, | ||
52 | [], | ||
53 | [AC_CHECK_LIB(ssl, SSL_library_init, | ||
54 | [LIBS="$LIBS -lssl"], | ||
55 | [AC_MSG_WARN([OpenSSL?.]); break] | ||
56 | )] | ||
57 | ) | ||
58 | ;; | ||
59 | esac | ||
60 | |||
61 | # AC_CHECK_FUNCS([RAND_pseudo_bytes EVP_EncryptInit_ex], , | ||
62 | # [AC_MSG_ERROR([Missing OpenSSL functionality, make sure you have installed the latest version.]); break], | ||
63 | # ) | ||
64 | |||
65 | # AC_CHECK_DECL([OpenSSL_add_all_algorithms], , | ||
66 | # [AC_MSG_ERROR([Missing OpenSSL functionality, make sure you have installed the latest version.]); break], | ||
67 | # [#include <openssl/evp.h>] | ||
68 | # ) | ||
69 | ]) | ||
diff --git a/src/microspdy/Makefile.am b/src/microspdy/Makefile.am index 32aa37a6..a1afb06c 100644 --- a/src/microspdy/Makefile.am +++ b/src/microspdy/Makefile.am | |||
@@ -21,17 +21,17 @@ libmicrospdy_la_SOURCES = \ | |||
21 | applicationlayer.c applicationlayer.h \ | 21 | applicationlayer.c applicationlayer.h \ |
22 | alstructures.c alstructures.h | 22 | alstructures.c alstructures.h |
23 | libmicrospdy_la_LIBADD = \ | 23 | libmicrospdy_la_LIBADD = \ |
24 | -lssl | 24 | $(SPDY_LIBDEPS) |
25 | 25 | ||
26 | libmicrospdy_la_LDFLAGS = \ | 26 | libmicrospdy_la_LDFLAGS = \ |
27 | $(SPDY_LIB_LDFLAGS) | 27 | $(SPDY_LIB_LDFLAGS) |
28 | 28 | ||
29 | libmicrospdy_la_CPPFLAGS = \ | 29 | libmicrospdy_la_CPPFLAGS = \ |
30 | $(AM_CPPFLAGS) \ | 30 | $(AM_CPPFLAGS) $(SPDY_LIB_CPPFLAGS) \ |
31 | -DBUILDING_MHD_LIB=1 | 31 | -DBUILDING_MHD_LIB=1 |
32 | 32 | ||
33 | libmicrospdy_la_CFLAGS = -Wextra \ | 33 | libmicrospdy_la_CFLAGS = -Wextra \ |
34 | $(SPDY_LIB_CFLAGS) | 34 | $(AM_CFLAGS) $(SPDY_LIB_CFLAGS) |
35 | 35 | ||
36 | 36 | ||
37 | if USE_COVERAGE | 37 | if USE_COVERAGE |