Showing
3 changed files
with
219 additions
and
0 deletions
m4/ax_check_openssl.m4
0 → 100644
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 | +]) |
m4/gcov.m4
0 → 100644
1 | +# Checks for existence of coverage tools: | ||
2 | +# * gcov | ||
3 | +# * lcov | ||
4 | +# * genhtml | ||
5 | +# * gcovr | ||
6 | +# | ||
7 | +# Sets ac_cv_check_gcov to yes if tooling is present | ||
8 | +# and reports the executables to the variables LCOV, GCOVR and GENHTML. | ||
9 | +AC_DEFUN([AC_TDD_GCOV], | ||
10 | +[ | ||
11 | + AC_ARG_ENABLE(gcov, | ||
12 | + AS_HELP_STRING([--enable-gcov], | ||
13 | + [enable coverage testing with gcov]), | ||
14 | + [use_gcov=$enableval], [use_gcov=no]) | ||
15 | + AM_CONDITIONAL(HAVE_GCOV, test "x$use_gcov" = "xyes") | ||
16 | + | ||
17 | + if test "x$use_gcov" = "xyes"; then | ||
18 | + # we need gcc: | ||
19 | + if test "$GCC" != "yes"; then | ||
20 | + AC_MSG_ERROR([GCC is required for --enable-gcov]) | ||
21 | + fi | ||
22 | + | ||
23 | + # Check if ccache is being used | ||
24 | + AC_CHECK_PROG(SHTOOL, shtool, shtool) | ||
25 | + case `$SHTOOL path $CC` in | ||
26 | + *ccache*[)] gcc_ccache=yes;; | ||
27 | + *[)] gcc_ccache=no;; | ||
28 | + esac | ||
29 | + | ||
30 | + if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then | ||
31 | + AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.]) | ||
32 | + fi | ||
33 | + | ||
34 | + lcov_version_list="1.6 1.7 1.8 1.9 1.10" | ||
35 | + AC_CHECK_PROG(LCOV, lcov, lcov) | ||
36 | + AC_CHECK_PROG(GENHTML, genhtml, genhtml) | ||
37 | + | ||
38 | + if test "$LCOV"; then | ||
39 | + AC_CACHE_CHECK([for lcov version], glib_cv_lcov_version, [ | ||
40 | + glib_cv_lcov_version=invalid | ||
41 | + lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'` | ||
42 | + for lcov_check_version in $lcov_version_list; do | ||
43 | + if test "$lcov_version" = "$lcov_check_version"; then | ||
44 | + glib_cv_lcov_version="$lcov_check_version (ok)" | ||
45 | + fi | ||
46 | + done | ||
47 | + ]) | ||
48 | + else | ||
49 | + lcov_msg="To enable code coverage reporting you must have one of the following lcov versions installed: $lcov_version_list" | ||
50 | + AC_MSG_ERROR([$lcov_msg]) | ||
51 | + fi | ||
52 | + | ||
53 | + case $glib_cv_lcov_version in | ||
54 | + ""|invalid[)] | ||
55 | + lcov_msg="You must have one of the following versions of lcov: $lcov_version_list (found: $lcov_version)." | ||
56 | + AC_MSG_ERROR([$lcov_msg]) | ||
57 | + LCOV="exit 0;" | ||
58 | + ;; | ||
59 | + esac | ||
60 | + | ||
61 | + if test -z "$GENHTML"; then | ||
62 | + AC_MSG_ERROR([Could not find genhtml from the lcov package]) | ||
63 | + fi | ||
64 | + | ||
65 | + # Remove all optimization flags from CFLAGS | ||
66 | + changequote({,}) | ||
67 | + CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'` | ||
68 | + changequote([,]) | ||
69 | + | ||
70 | + # Add the special gcc flags | ||
71 | + COVERAGE_CFLAGS="-O0 -fprofile-arcs -ftest-coverage" | ||
72 | + COVERAGE_CXXFLAGS="-O0 -fprofile-arcs -ftest-coverage" | ||
73 | + COVERAGE_LDFLAGS="-lgcov" | ||
74 | + AC_SUBST(COVERAGE_CFLAGS) | ||
75 | + AC_SUBST(COVERAGE_CXXFLAGS) | ||
76 | + AC_SUBST(COVERAGE_LDFLAGS) | ||
77 | + | ||
78 | +fi | ||
79 | +]) # AC_TDD_GCOV | ||
80 | + |
m4/openssl.m4
0 → 100644
1 | +AC_DEFUN([AC_OPENSSL], | ||
2 | +[ | ||
3 | + AC_ARG_ENABLE(openssl, | ||
4 | + AC_HELP_STRING([--disable-openssl], | ||
5 | + [disable usage of openssl])) | ||
6 | + | ||
7 | + AS_IF([test "x$enable_openssl" != "xno"], [ | ||
8 | + AC_MSG_NOTICE("Use openssl if available") | ||
9 | + m4_include([m4/ax_check_openssl.m4]) | ||
10 | + AX_CHECK_OPENSSL([OPENSSL="-DHAS_OPENSSL"],[OPENSSL=""]) | ||
11 | + AC_SUBST([OPENSSL]) | ||
12 | + ]) | ||
13 | +]) | ||
14 | + | ||
15 | +# vim: set ft=m4 ts=2 sw=2: |
Please
register
or
login
to post a comment