1 dnl @synopsis GP_CHECK_POPT(FLAG)
3 dnl Check whether libpopt is available.
4 dnl FLAG must be one of
9 AC_DEFUN([GP_CHECK_POPT],[
13 AC_REQUIRE([GP_CONFIG_MSG])dnl
14 m4_if([$1],[mandatory], [_GP_CHECK_POPT([mandatory])],
15 [$1],[default-enabled], [_GP_CHECK_POPT([disable])],
16 [$1],[default-disabled], [_GP_CHECK_POPT([enable])],
17 [m4_errprint(__file__:__line__:[ Error:
18 Illegal argument to $0: `$1'
19 Valid values are: mandatory, default-enabled, default-disabled
23 AC_DEFUN([_GP_CHECK_POPT],[
24 m4_if([$1],[mandatory],[
31 [AS_HELP_STRING([--$1-popt],[Do not use popt])],
32 [ if test "x$withval" = no \
33 || test "x$withval" = off \
34 || test "x$withval" = false;
38 elif test "x$withval" = yes \
39 || test "x$withval" = on \
40 || test "x$withval" = true
48 AC_MSG_CHECKING([whether popt is required])
49 AC_MSG_RESULT([${require_popt}])
51 if test "$require_popt" != yes; then
52 AC_MSG_CHECKING([whether popt is requested])
53 AC_MSG_RESULT([${try_popt}])
57 AC_ARG_VAR([POPT_CFLAGS],[cppflags to compile with libpopt])dnl
58 AC_ARG_VAR([POPT_LIBS],[location of libpopt to link against])dnl
62 if test "x$POPT_CFLAGS" = "x" && test "x$POPT_LIBS" = "x"; then
64 # try to find options to compile popt.h
65 CPPFLAGS_save="$CPPFLAGS"
67 for popt_prefix in "" /usr /usr/local
69 if test -n "${popt_prefix}"; then
71 elif test -d "${popt_prefix}/include"; then
72 CPPFLAGS="-I${popt_prefix}/include ${CPPFLAGS}"
76 ac_cv_header_popt_h=""
77 unset ac_cv_header_popt_h
78 AC_CHECK_HEADER([popt.h], [popth_found=yes])
79 if test "$popth_found" = yes; then break; fi
81 CPPFLAGS="$CPPFLAGS_save"
82 if test "$popth_found" = "yes"; then
83 if test "$popt_prefix" = ""; then
86 POPT_CFLAGS="-I${popt_prefix}/include"
90 * Cannot autodetect popt.h
92 * Set POPT_CFLAGS and POPT_LIBS correctly.
96 # try to find options to link against popt
97 LDFLAGS_save="$LDFLAGS"
99 for popt_prefix in /usr "" /usr/local; do
100 # We could have "/usr" and "lib64" at the beginning of the
101 # lists. Then the first tested location would
102 # incidentally be the right one on 64bit systems, and
103 # thus work around a bug in libtool on 32bit systems:
105 # 32bit libtool doesn't know about 64bit systems, and so the
106 # compilation will fail when linking a 32bit library from
107 # /usr/lib to a 64bit binary.
109 # This hack has been confirmed to workwith a
110 # 32bit Debian Sarge and 64bit Fedora Core 3 system.
111 for ldir in lib64 "" lib; do
112 popt_libdir="${popt_prefix}/${ldir}"
113 if test "${popt_libdir}" = "/"; then
115 elif test -d "${popt_libdir}"; then
116 LDFLAGS="-L${popt_libdir} ${LDFLAGS}"
120 # Avoid caching of results
121 ac_cv_lib_popt_poptStuffArgs=""
122 unset ac_cv_lib_popt_poptStuffArgs
123 AC_CHECK_LIB([popt], [poptStuffArgs], [popt_links=yes])
124 if test "$popt_links" = yes; then break; fi
126 if test "$popt_links" = yes; then break; fi
128 LDFLAGS="$LDFLAGS_save"
129 if test "$popt_links" = "yes"; then
130 if test "$popt_libdir" = ""; then
133 POPT_LIBS="-L${popt_libdir} -lpopt"
137 * Cannot autodetect library directory containing popt
139 * Set POPT_CFLAGS and POPT_LIBS correctly.
143 elif test "x$POPT_CFLAGS" != "x" && test "x$POPT_LIBS" != "x"; then
144 # just use the user specivied option
145 popt_msg="yes (user specified)"
149 * Fatal: Either set both POPT_CFLAGS and POPT_LIBS or neither.
153 AC_MSG_CHECKING([if popt is functional])
154 if test "$require_popt$have_popt" = "yesno"; then
155 AC_MSG_RESULT([no, but required])
157 * popt library not found
158 * Fatal: ${PACKAGE_NAME} (${PACKAGE_TARNAME}) requires popt
159 * Please install it and/or set POPT_CFLAGS and POPT_LIBS.
162 AC_MSG_RESULT([${have_popt}])
164 GP_CONFIG_MSG([use popt library], [${have_popt}])
165 if test "$have_popt" = "yes"; then
166 AC_DEFINE([HAVE_POPT],[1],[whether the popt library is available])
167 GP_CONFIG_MSG([popt libs],[${POPT_LIBS}])
168 GP_CONFIG_MSG([popt cppflags],[${POPT_CFLAGS}])
170 AM_CONDITIONAL([HAVE_POPT],[test "$have_popt" = "yes"])
173 dnl Please do not remove this:
174 dnl filetype: 7595380e-eff3-49e5-90ab-e40f1d544639
175 dnl I use this to find all the different instances of this file which
176 dnl are supposed to be synchronized.