added some precautionary checks in bdecoder
[libtorrent.git] / m4 / check_ssl.m4
blobbc1a3d0e459b53d9871391fac5c0afc9b75d0084
1 ##### http://autoconf-archive.cryp.to/check_ssl.html
3 # SYNOPSIS
5 #   CHECK_SSL
7 # DESCRIPTION
9 #   This macro will check various standard spots for OpenSSL including
10 #   a user-supplied directory. The user uses '--with-ssl' or
11 #   '--with-ssl=/path/to/ssl' as arguments to configure.
13 #   If OpenSSL is found the include directory gets added to CFLAGS and
14 #   CXXFLAGS as well as '-DHAVE_SSL', '-lssl' & '-lcrypto' get added to
15 #   LIBS, and the libraries location gets added to LDFLAGS. Finally
16 #   'HAVE_SSL' gets set to 'yes' for use in your Makefile.in I use it
17 #   like so (valid for gmake):
19 #       HAVE_SSL = @HAVE_SSL@
20 #       ifeq ($(HAVE_SSL),yes)
21 #           SRCS+= @srcdir@/my_file_that_needs_ssl.c
22 #       endif
24 #   For bsd 'bmake' use:
26 #       .if ${HAVE_SSL} == "yes"
27 #           SRCS+= @srcdir@/my_file_that_needs_ssl.c
28 #       .endif
30 # LAST MODIFICATION
32 #   2003-01-28
34 # COPYLEFT
36 #   Copyright (c) 2003 Mark Ethan Trostler <trostler@juniper.net>
38 #   Copying and distribution of this file, with or without
39 #   modification, are permitted in any medium without royalty provided
40 #   the copyright notice and this notice are preserved.
42 AC_DEFUN([CHECK_SSL],
44 dnl AC_MSG_CHECKING(if ssl is wanted)
45 AC_ARG_WITH(ssl,
46 [  --with-ssl enable ssl [will check /usr/local/ssl
47                             /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr ]
49 dnl [   AC_MSG_RESULT(yes)
50     for dir in $withval /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr; do
51         ssldir="$dir"
52         if test -f "$dir/include/openssl/ssl.h"; then
53             found_ssl="yes";
54             SSL_CFLAGS="$CFLAGS -I$ssldir/include/openssl -DHAVE_SSL";
55             AC_SUBST(SSL_CFLAGS)
56             SSL_CXXFLAGS="$CXXFLAGS -I$ssldir/include/openssl -DHAVE_SSL";
57             AC_SUBST(SSL_CXXFLAGS)
58             break;
59         fi
60         if test -f "$dir/include/ssl.h"; then
61             found_ssl="yes";
62             SSL_CFLAGS="$CFLAGS -I$ssldir/include/ -DHAVE_SSL";
63             AC_SUBST(SSL_CFLAGS)
64             SSL_CXXFLAGS="$CXXFLAGS -I$ssldir/include/ -DHAVE_SSL";
65             AC_SUBST(SSL_CXXFLAGS)
66             break
67         fi
68     done
69     if test x_$found_ssl != x_yes; then
70         AC_MSG_ERROR(Cannot find ssl libraries)
71     else
72         printf "OpenSSL found in $ssldir\n";
73         SSL_LIBS="$LIBS -lssl -lcrypto";
74         AC_SUBST(SSL_LIBS)
75         SSL_LDFLAGS="$LDFLAGS -L$ssldir/lib";
76         AC_SUBST(SSL_LDFLAGS)
77         HAVE_SSL=yes
78     fi
79     AC_SUBST(HAVE_SSL)
80 dnl ],
81 dnl [
82 dnl     AC_MSG_RESULT(no)
83 dnl ])
84 ])dnl