b3e2df519b4409bdb41ab8939ae6312caba05772
[sfrench/samba-autobuild/.git] / source4 / lib / popt / libpopt.m4
1 dnl Check to see if we should use the included popt
2
3 INCLUDED_POPT=auto
4 AC_ARG_WITH(included-popt,
5 [  --with-included-popt    use bundled popt library, not from system],
6 [ INCLUDED_POPT=$withval ])
7
8 AC_SUBST(POPT_LIBS)
9 AC_SUBST(POPT_CFLAGS)
10
11 if test x"$INCLUDED_POPT" != x"yes"; then
12         AC_CHECK_HEADERS(popt.h)
13         AC_CHECK_LIB(popt, poptGetContext, [ POPT_LIBS="-lpopt" ])
14         if test x"$ac_cv_header_popt_h" = x"no" -o x"$ac_cv_lib_popt_poptGetContext" = x"no"; then
15                 INCLUDED_POPT=yes
16                 POPT_CFLAGS=""
17         else
18                 INCLUDED_POPT=no
19         fi
20 fi
21
22 AC_MSG_CHECKING(whether to use included popt)
23 AC_MSG_RESULT($INCLUDED_POPT)
24 if test x"$INCLUDED_POPT" != x"no"; then
25         dnl find the popt sources. This is meant to work both for 
26         dnl popt standalone builds, and builds of packages using popt
27         poptdir=""
28         poptpaths="$srcdir $srcdir/lib/popt $srcdir/popt $srcdir/../popt"
29         for d in $poptpaths; do
30                 if test -f "$d/popt.c"; then
31                         poptdir="$d"            
32                         POPT_CFLAGS="-I$d"
33                         AC_SUBST(poptdir)
34                         break
35                 fi
36         done
37         if test x"$poptdir" = "x"; then
38                 AC_MSG_ERROR([cannot find popt source in $poptpaths])
39         fi
40         POPTOBJ="popt.o findme.o poptconfig.o popthelp.o poptparse.o"
41         AC_SUBST(POPTOBJ)
42         AC_CHECK_HEADERS([float.h alloca.h])
43 fi