2
dnl Off-the-Record Messaging library
3
dnl Copyright (C) 2004-2007 Ian Goldberg, Chris Alexander, Nikita Borisov
4
dnl <otr@cypherpunks.ca>
6
dnl This library is free software; you can redistribute it and/or
7
dnl modify it under the terms of version 2.1 of the GNU Lesser General
8
dnl Public License as published by the Free Software Foundation.
10
dnl This library is distributed in the hope that it will be useful,
11
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
dnl Lesser General Public License for more details.
15
dnl You should have received a copy of the GNU Lesser General Public
16
dnl License along with this library; if not, write to the Free Software
17
dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
dnl AM_PATH_LIBOTR([MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
21
dnl Test for libotr, and define LIBOTR_CFLAGS and LIBOTR_LIBS as appropriate.
22
dnl enables arguments --with-libotr-prefix=
23
dnl --with-libotr-inc-prefix=
25
dnl You must already have found libgcrypt with AM_PATH_LIBGCRYPT
27
dnl Adapted from alsa.m4, originally by
28
dnl Richard Boulton <richard-alsa@tartarus.org>
29
dnl Christopher Lansdown <lansdoct@cs.alfred.edu>
30
dnl Jaroslav Kysela <perex@suse.cz>
32
AC_DEFUN([AM_PATH_LIBOTR],
33
[dnl Save the original CFLAGS, LDFLAGS, and LIBS
34
libotr_save_CFLAGS="$CFLAGS"
35
libotr_save_LDFLAGS="$LDFLAGS"
36
libotr_save_LIBS="$LIBS"
40
dnl Get the cflags and libraries for libotr
42
AC_ARG_WITH(libotr-prefix,
43
[ --with-libotr-prefix=PFX Prefix where libotr is installed(optional)],
44
[libotr_prefix="$withval"], [libotr_prefix=""])
46
AC_ARG_WITH(libotr-inc-prefix,
47
[ --with-libotr-inc-prefix=PFX Prefix where libotr includes are (optional)],
48
[libotr_inc_prefix="$withval"], [libotr_inc_prefix=""])
50
dnl Add any special include directories
51
AC_MSG_CHECKING(for libotr CFLAGS)
52
if test "$libotr_inc_prefix" != "" ; then
53
LIBOTR_CFLAGS="$LIBOTR_CFLAGS -I$libotr_inc_prefix"
54
CFLAGS="$CFLAGS $LIBOTR_CFLAGS"
56
AC_MSG_RESULT($LIBOTR_CFLAGS)
58
dnl add any special lib dirs
59
AC_MSG_CHECKING(for libotr LIBS)
60
if test "$libotr_prefix" != "" ; then
61
LIBOTR_LIBS="$LIBOTR_LIBS -L$libotr_prefix"
62
LDFLAGS="$LDFLAGS $LIBOTR_LIBS"
65
dnl add the libotr library
66
LIBOTR_LIBS="$LIBOTR_LIBS -lotr"
67
LIBS="$LIBOTR_LIBS $LIBS"
68
AC_MSG_RESULT($LIBOTR_LIBS)
70
dnl Check for a working version of libotr that is of the right version.
71
min_libotr_version=ifelse([$1], ,3.0.0,$1)
73
libotr_min_major_version=`echo $min_libotr_version | \
74
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
75
libotr_min_minor_version=`echo $min_libotr_version | \
76
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
77
libotr_min_sub_version=`echo $min_libotr_version | \
78
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
79
AC_MSG_CHECKING(for libotr headers version $libotr_min_major_version.x >= $min_libotr_version)
85
#include <libotr/version.h>
87
# if(OTRL_VERSION_MAJOR != $libotr_min_major_version)
91
# if(OTRL_VERSION_MINOR > $libotr_min_minor_version)
94
# if(OTRL_VERSION_MINOR < $libotr_min_minor_version)
98
# if(OTRL_VERSION_SUB < $libotr_min_sub_version)
105
[AC_MSG_RESULT(found.)],
106
[AC_MSG_RESULT(not present.)
107
ifelse([$3], , [AC_MSG_ERROR(Sufficiently new version of libotr not found.)])
112
dnl Now that we know that we have the right version, let's see if we have the library and not just the headers.
113
AC_CHECK_LIB([otr], [otrl_message_receiving],,
114
[ifelse([$3], , [AC_MSG_ERROR(No linkable libotr was found.)])
119
LDFLAGS="$libotr_save_LDFLAGS"
120
LIBS="$libotr_save_LIBS"
122
if test "x$libotr_found" = "xyes" ; then
123
ifelse([$2], , :, [$2])
127
ifelse([$3], , :, [$3])
130
dnl That should be it. Now just export our symbols:
131
AC_SUBST(LIBOTR_CFLAGS)
132
AC_SUBST(LIBOTR_LIBS)