purple: replace our PURPLE_XFER macro
[siplcs.git] / m4macros / purple.m4
blobc3002a7ca2d0445efc1060a5ea9e1cc8f213da45
1 dnl ###########################################################################
2 dnl # Configure paths for libpurple
3 dnl # Gary Kramlich 2005
4 dnl #
5 dnl # Based off of glib-2.0.m4 by Owen Taylor
6 dnl ###########################################################################
8 dnl ###########################################################################
9 dnl # AM_PATH_PURPLE([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
10 dnl #
11 dnl # Test for purple and define PURPLE_CFLAGS, PURPLE_LIBS, PURPLE_DATADIR, and
12 dnl # PURPLE_LIBDIR
13 dnl ###########################################################################
14 AC_DEFUN([AM_PATH_PURPLE],
15 [dnl
16         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
18         no_purple=""
20         if test x"$PKG_CONFIG" != x"no" ; then
21                 if $PKG_CONFIG --atleast-pkgconfig-version 0.7 ; then
22                         :
23                 else
24                         echo "*** pkg-config is too old;  version 0.7 or newer is required."
25                         no_purple="yes"
26                         PKG_CONFIG="no"
27                 fi
28         else
29                 no_purple="yes"
30         fi
32         min_version=ifelse([$1], ,2.0.0,$1)
33         found_version=""
35         AC_MSG_CHECKING(for purple - version >= $min_version)
37         if test x"$no_purple" = x"" ; then
38                 PURPLE_DATADIR=`$PKG_CONFIG --variable=datadir purple`
39                 PURPLE_LIBDIR=`$PKG_CONFIG --variable=libdir purple`
41                 PURPLE_CFLAGS=`$PKG_CONFIG --cflags purple`
42                 PURPLE_LIBS=`$PKG_CONFIG --libs purple`
44                 purple_version=`$PKG_CONFIG --modversion purple`
45                 purple_major_version=`echo $purple_version | cut -d. -f 1`
46                 purple_minor_version=`echo $purple_version | cut -d. -f 2`
48                 dnl # stash the micro version in a temp variable.  Then stash
49                 dnl # the numeric for it in purple_micro_version and anything
50                 dnl # else in purple_extra_version.
51                 purple_micro_version_temp=`echo $purple_version | cut -d. -f 3`
52                 purple_micro_version=`echo $purple_micro_version_temp | sed 's/[[^0-9]]//g'`
53                 purple_extra_version=`echo $purple_micro_version_temp | sed 's/[[0-9]]//g'`
55                 dnl # get the major, minor, and macro that the user gave us
56                 min_major_version=`echo $min_version | cut -d. -f 1`
57                 min_minor_version=`echo $min_version | cut -d. -f 2`
58                 min_micro_version=`echo $min_version | cut -d. -f 3`
60                 dnl # check the users version against the version from pkg-config
61                 if test $purple_major_version -eq $min_major_version -a \
62                         $purple_minor_version -ge $min_minor_version -a \
63                         $purple_micro_version -ge $min_micro_version
64                 then
65                         :
66                 else
67                         no_purple="yes"
68                         found_version="$purple_major_version.$purple_minor_version.$purple_micro_version$purple_extra_version"
69                 fi
71                 dnl # Do we want a compile test here?
72         fi
74         if test x"$no_purple" = x"" ; then
75                 AC_MSG_RESULT(yes (version $purple_major_version.$purple_minor_version.$purple_micro_version$purple_extra_version))
76                 ifelse([$2], , :, [$2])
77         else
78                 AC_MSG_RESULT(no)
79                 if test x"$PKG_CONFIG" = x"no" ; then
80                         echo "*** A new enough version of pkg-config was not found."
81                         echo "*** See http://www.freedesktop.org/software/pkgconfig/"
82                 fi
84                 if test x"found_version" != x"" ; then
85                         echo "*** A new enough version of purple was not found."
86                         echo "*** You have version $found_version"
87                         echo "*** See http://pidgin.im/"
88                 fi
90                 PURPLE_CFLAGS=""
91                 PURPLE_LIBS=""
92                 PURPLE_DATADIR=""
93                 PURPLE_LIBDIR=""
95                 ifelse([$3], , :, [$3])
96         fi
98         AC_SUBST(PURPLE_CFLAGS)
99         AC_SUBST(PURPLE_LIBS)
100         AC_SUBST(PURPLE_DATADIR)
101         AC_SUBST(PURPLE_LIBDIR)