1*735d6239SKiyoung Kimdnl @synopsis GP_CHECK_POPT(FLAG) 2*735d6239SKiyoung Kimdnl 3*735d6239SKiyoung Kimdnl Check whether libpopt is available. 4*735d6239SKiyoung Kimdnl FLAG must be one of 5*735d6239SKiyoung Kimdnl "mandatory" 6*735d6239SKiyoung Kimdnl "default-enabled" 7*735d6239SKiyoung Kimdnl "default-disabled" 8*735d6239SKiyoung Kimdnl 9*735d6239SKiyoung KimAC_DEFUN([GP_CHECK_POPT],[ 10*735d6239SKiyoung Kim# 11*735d6239SKiyoung Kim# [GP_CHECK_POPT] 12*735d6239SKiyoung Kim# 13*735d6239SKiyoung KimAC_REQUIRE([GP_CONFIG_MSG])dnl 14*735d6239SKiyoung Kimm4_if([$1],[mandatory], [_GP_CHECK_POPT([mandatory])], 15*735d6239SKiyoung Kim [$1],[default-enabled], [_GP_CHECK_POPT([disable])], 16*735d6239SKiyoung Kim [$1],[default-disabled], [_GP_CHECK_POPT([enable])], 17*735d6239SKiyoung Kim [m4_errprint(__file__:__line__:[ Error: 18*735d6239SKiyoung KimIllegal argument to $0: `$1' 19*735d6239SKiyoung KimValid values are: mandatory, default-enabled, default-disabled 20*735d6239SKiyoung Kim])m4_exit(1)])dnl 21*735d6239SKiyoung Kim])dnl 22*735d6239SKiyoung Kimdnl 23*735d6239SKiyoung KimAC_DEFUN([_GP_CHECK_POPT],[ 24*735d6239SKiyoung Kimm4_if([$1],[mandatory],[ 25*735d6239SKiyoung Kimtry_popt=yes 26*735d6239SKiyoung Kimrequire_popt=yes 27*735d6239SKiyoung Kim],[ 28*735d6239SKiyoung Kimtry_popt=auto 29*735d6239SKiyoung Kimrequire_popt=no 30*735d6239SKiyoung KimAC_ARG_ENABLE([popt], 31*735d6239SKiyoung Kim[AS_HELP_STRING([--$1-popt],[Do not use popt])], 32*735d6239SKiyoung Kim[ if test "x$withval" = no \ 33*735d6239SKiyoung Kim || test "x$withval" = off \ 34*735d6239SKiyoung Kim || test "x$withval" = false; 35*735d6239SKiyoung Kim then 36*735d6239SKiyoung Kim try_popt=no 37*735d6239SKiyoung Kim require_popt=no 38*735d6239SKiyoung Kim elif test "x$withval" = yes \ 39*735d6239SKiyoung Kim || test "x$withval" = on \ 40*735d6239SKiyoung Kim || test "x$withval" = true 41*735d6239SKiyoung Kim then 42*735d6239SKiyoung Kim try_popt=yes 43*735d6239SKiyoung Kim require_popt=yes 44*735d6239SKiyoung Kim fi 45*735d6239SKiyoung Kim])dnl 46*735d6239SKiyoung Kim])dnl 47*735d6239SKiyoung Kim 48*735d6239SKiyoung KimAC_MSG_CHECKING([whether popt is required]) 49*735d6239SKiyoung KimAC_MSG_RESULT([${require_popt}]) 50*735d6239SKiyoung Kim 51*735d6239SKiyoung Kimif test "$require_popt" != yes; then 52*735d6239SKiyoung Kim AC_MSG_CHECKING([whether popt is requested]) 53*735d6239SKiyoung Kim AC_MSG_RESULT([${try_popt}]) 54*735d6239SKiyoung Kimfi 55*735d6239SKiyoung Kim 56*735d6239SKiyoung Kimdnl Implicit AC_SUBST 57*735d6239SKiyoung KimAC_ARG_VAR([POPT_CFLAGS],[CPPFLAGS to compile with libpopt])dnl 58*735d6239SKiyoung KimAC_ARG_VAR([POPT_LIBS],[LDFLAGS to link with libpopt])dnl 59*735d6239SKiyoung Kim 60*735d6239SKiyoung Kimhave_popt=no 61*735d6239SKiyoung Kim 62*735d6239SKiyoung Kimif test "x$POPT_CFLAGS" = "x" && test "x$POPT_LIBS" = "x"; then 63*735d6239SKiyoung Kim 64*735d6239SKiyoung Kim # try to find options to compile popt.h 65*735d6239SKiyoung Kim CPPFLAGS_save="$CPPFLAGS" 66*735d6239SKiyoung Kim popth_found=no 67*735d6239SKiyoung Kim for popt_prefix in "" /usr /usr/local 68*735d6239SKiyoung Kim do 69*735d6239SKiyoung Kim if test -n "${popt_prefix}"; then 70*735d6239SKiyoung Kim : 71*735d6239SKiyoung Kim elif test -d "${popt_prefix}/include"; then 72*735d6239SKiyoung Kim CPPFLAGS="-I${popt_prefix}/include ${CPPFLAGS}" 73*735d6239SKiyoung Kim else 74*735d6239SKiyoung Kim continue 75*735d6239SKiyoung Kim fi 76*735d6239SKiyoung Kim ac_cv_header_popt_h="" 77*735d6239SKiyoung Kim unset ac_cv_header_popt_h 78*735d6239SKiyoung Kim AC_CHECK_HEADER([popt.h], [popth_found=yes]) 79*735d6239SKiyoung Kim if test "$popth_found" = yes; then break; fi 80*735d6239SKiyoung Kim done 81*735d6239SKiyoung Kim CPPFLAGS="$CPPFLAGS_save" 82*735d6239SKiyoung Kim if test "$popth_found" = "yes"; then 83*735d6239SKiyoung Kim if test "$popt_prefix" = ""; then 84*735d6239SKiyoung Kim POPT_CFLAGS="" 85*735d6239SKiyoung Kim else 86*735d6239SKiyoung Kim POPT_CFLAGS="-I${popt_prefix}/include" 87*735d6239SKiyoung Kim fi 88*735d6239SKiyoung Kim else 89*735d6239SKiyoung Kim AC_MSG_ERROR([ 90*735d6239SKiyoung Kim* Cannot autodetect popt.h 91*735d6239SKiyoung Kim* 92*735d6239SKiyoung Kim* Set POPT_CFLAGS and POPT_LIBS correctly. 93*735d6239SKiyoung Kim]) 94*735d6239SKiyoung Kim fi 95*735d6239SKiyoung Kim 96*735d6239SKiyoung Kim # try to find options to link against popt 97*735d6239SKiyoung Kim LDFLAGS_save="$LDFLAGS" 98*735d6239SKiyoung Kim popt_links=no 99*735d6239SKiyoung Kim for popt_prefix in /usr "" /usr/local; do 100*735d6239SKiyoung Kim # We could have "/usr" and "lib64" at the beginning of the 101*735d6239SKiyoung Kim # lists. Then the first tested location would 102*735d6239SKiyoung Kim # incidentally be the right one on 64bit systems, and 103*735d6239SKiyoung Kim # thus work around a bug in libtool on 32bit systems: 104*735d6239SKiyoung Kim # 105*735d6239SKiyoung Kim # 32bit libtool doesn't know about 64bit systems, and so the 106*735d6239SKiyoung Kim # compilation will fail when linking a 32bit library from 107*735d6239SKiyoung Kim # /usr/lib to a 64bit binary. 108*735d6239SKiyoung Kim # 109*735d6239SKiyoung Kim # This hack has been confirmed to workwith a 110*735d6239SKiyoung Kim # 32bit Debian Sarge and 64bit Fedora Core 3 system. 111*735d6239SKiyoung Kim for ldir in lib64 "" lib; do 112*735d6239SKiyoung Kim popt_libdir="${popt_prefix}/${ldir}" 113*735d6239SKiyoung Kim if test "${popt_libdir}" = "/"; then 114*735d6239SKiyoung Kim popt_libdir="" 115*735d6239SKiyoung Kim elif test -d "${popt_libdir}"; then 116*735d6239SKiyoung Kim LDFLAGS="-L${popt_libdir} ${LDFLAGS}" 117*735d6239SKiyoung Kim else 118*735d6239SKiyoung Kim continue 119*735d6239SKiyoung Kim fi 120*735d6239SKiyoung Kim # Avoid caching of results 121*735d6239SKiyoung Kim ac_cv_lib_popt_poptStuffArgs="" 122*735d6239SKiyoung Kim unset ac_cv_lib_popt_poptStuffArgs 123*735d6239SKiyoung Kim AC_CHECK_LIB([popt], [poptStuffArgs], [popt_links=yes]) 124*735d6239SKiyoung Kim if test "$popt_links" = yes; then break; fi 125*735d6239SKiyoung Kim done 126*735d6239SKiyoung Kim if test "$popt_links" = yes; then break; fi 127*735d6239SKiyoung Kim done 128*735d6239SKiyoung Kim LDFLAGS="$LDFLAGS_save" 129*735d6239SKiyoung Kim if test "$popt_links" = "yes"; then 130*735d6239SKiyoung Kim if test "$popt_libdir" = ""; then 131*735d6239SKiyoung Kim POPT_LIBS="-lpopt" 132*735d6239SKiyoung Kim else 133*735d6239SKiyoung Kim POPT_LIBS="-L${popt_libdir} -lpopt" 134*735d6239SKiyoung Kim fi 135*735d6239SKiyoung Kim else 136*735d6239SKiyoung Kim AC_MSG_ERROR([ 137*735d6239SKiyoung Kim* Cannot autodetect library directory containing popt 138*735d6239SKiyoung Kim* 139*735d6239SKiyoung Kim* Set POPT_CFLAGS and POPT_LIBS correctly. 140*735d6239SKiyoung Kim]) 141*735d6239SKiyoung Kim fi 142*735d6239SKiyoung Kim have_popt=yes 143*735d6239SKiyoung Kimelif test "x$POPT_CFLAGS" != "x" && test "x$POPT_LIBS" != "x"; then 144*735d6239SKiyoung Kim # just use the user specivied option 145*735d6239SKiyoung Kim popt_msg="yes (user specified)" 146*735d6239SKiyoung Kim have_popt=yes 147*735d6239SKiyoung Kimelse 148*735d6239SKiyoung Kim AC_MSG_ERROR([ 149*735d6239SKiyoung Kim* Fatal: Either set both POPT_CFLAGS and POPT_LIBS or neither. 150*735d6239SKiyoung Kim]) 151*735d6239SKiyoung Kimfi 152*735d6239SKiyoung Kim 153*735d6239SKiyoung KimAC_MSG_CHECKING([if popt is functional]) 154*735d6239SKiyoung Kimif test "$require_popt$have_popt" = "yesno"; then 155*735d6239SKiyoung Kim AC_MSG_RESULT([no, but required]) 156*735d6239SKiyoung Kim AC_MSG_ERROR([ 157*735d6239SKiyoung Kim* popt library not found 158*735d6239SKiyoung Kim* Fatal: ${PACKAGE_NAME} (${PACKAGE_TARNAME}) requires popt 159*735d6239SKiyoung Kim* Please install it and/or set POPT_CFLAGS and POPT_LIBS. 160*735d6239SKiyoung Kim]) 161*735d6239SKiyoung Kimfi 162*735d6239SKiyoung KimAC_MSG_RESULT([${have_popt}]) 163*735d6239SKiyoung Kim 164*735d6239SKiyoung KimGP_CONFIG_MSG([use popt library], [${have_popt}]) 165*735d6239SKiyoung Kimif test "$have_popt" = "yes"; then 166*735d6239SKiyoung Kim AC_DEFINE([HAVE_POPT],[1],[whether the popt library is available]) 167*735d6239SKiyoung Kim GP_CONFIG_MSG([popt libs],[${POPT_LIBS}]) 168*735d6239SKiyoung Kim GP_CONFIG_MSG([popt cppflags],[${POPT_CFLAGS}]) 169*735d6239SKiyoung Kimfi 170*735d6239SKiyoung KimAM_CONDITIONAL([HAVE_POPT],[test "$have_popt" = "yes"]) 171*735d6239SKiyoung Kim])dnl 172*735d6239SKiyoung Kimdnl 173*735d6239SKiyoung Kimdnl Please do not remove this: 174*735d6239SKiyoung Kimdnl filetype: 7595380e-eff3-49e5-90ab-e40f1d544639 175*735d6239SKiyoung Kimdnl I use this to find all the different instances of this file which 176*735d6239SKiyoung Kimdnl are supposed to be synchronized. 177*735d6239SKiyoung Kimdnl 178*735d6239SKiyoung Kimdnl Local Variables: 179*735d6239SKiyoung Kimdnl mode: autoconf 180*735d6239SKiyoung Kimdnl End: 181