# Configure paths for PC # Stolen and modified by Mark Spencer # Stolen and modifed by Rob Flynn # Manish Singh 98-9-30 # stolen back from Frank Belew # stolen from Manish Singh # Shamelessly stolen from Owen Taylor dnl AM_PATH_GPC([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) dnl Test for Phonecore, and define PC_CFLAGS and PC_LIBS dnl AC_DEFUN(AM_PATH_GPC, [ AC_ARG_WITH(phonecore-prefix,[ --with-phonecore-prefix=PFX Prefix where Phonecore is installed (optional)], phonecore_prefix="$withval", phonecore_prefix="") AC_ARG_WITH(phonecore-exec-prefix,[ --with-phonecore-exec-prefix=PFX Exec prefix where Phonecore is installed (optional)], phonecore_exec_prefix="$withval", phonecore_exec_prefix="") AC_ARG_ENABLE(phonecoretest, [ --disable-phonecoretest Do not try to compile and run a test Phonecore program], , enable_phonecoretest=yes) if test x$phonecore_exec_prefix != x ; then phonecore_args="$phonecore_args --exec-prefix=$phonecore_exec_prefix" if test x${PC_CONFIG+set} != xset ; then PC_CONFIG=$phonecore_exec_prefix/bin/phonecore-config fi fi if test x$phonecore_prefix != x ; then phonecore_args="$phonecore_args --prefix=$phonecore_prefix" if test x${PC_CONFIG+set} != xset ; then PC_CONFIG=$phonecore_prefix/bin/phonecore-config fi fi AC_PATH_PROG(PC_CONFIG, phonecore-config, no) min_phonecore_version=ifelse([$1], ,0.3.0,$1) AC_MSG_CHECKING(for Phonecore - version >= $min_phonecore_version) no_phonecore="" if test "$PC_CONFIG" = "no" ; then no_phonecore=yes else PC_CFLAGS=`$PC_CONFIG $phonecoreconf_args --cflags` PC_LIBS=`$PC_CONFIG $phonecoreconf_args --libs` phonecore_major_version=`$PC_CONFIG $phonecore_args --version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` phonecore_minor_version=`$PC_CONFIG $phonecore_args --version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` phonecore_micro_version=`$PC_CONFIG $phonecore_config_args --version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` if test "x$enable_phonecoretest" = "xyes" ; then ac_save_CFLAGS="$CFLAGS" ac_save_LIBS="$LIBS" CFLAGS="$CFLAGS $PC_CFLAGS" LIBS="$LIBS $PC_LIBS" dnl dnl Now check if the installed Phonecore is sufficiently new. (Also sanity dnl checks the results of phonecore-config to some extent dnl rm -f conf.phonecoretest AC_TRY_RUN([ #include #include #include #include char* my_strdup (char *str) { char *new_str; if (str) { new_str = malloc ((strlen (str) + 1) * sizeof(char)); strcpy (new_str, str); } else new_str = NULL; return new_str; } int main () { int major, minor, micro; char *tmp_version; system ("touch conf.phonecoretest"); /* HP/UX 9 (%@#!) writes to sscanf strings */ tmp_version = my_strdup("$min_phonecore_version"); if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { printf("%s, bad version string\n", "$min_phonecore_version"); exit(1); } if (($phonecore_major_version > major) || (($phonecore_major_version == major) && ($phonecore_minor_version > minor)) || (($phonecore_major_version == major) && ($phonecore_minor_version == minor) && ($phonecore_micro_version >= micro))) { return 0; } else { printf("\n*** 'phonecore-config --version' returned %d.%d.%d, but the minimum version\n", $phonecore_major_version, $phonecore_minor_version, $phonecore_micro_version); printf("*** of Phonecore required is %d.%d.%d. If phonecore-config is correct, then it is\n", major, minor, micro); printf("*** best to upgrade to the required version.\n"); printf("*** If phonecore-config was wrong, set the environment variable PC_CONFIG\n"); printf("*** to point to the correct copy of phonecore-config, and remove the file\n"); printf("*** config.cache before re-running configure\n"); return 1; } } ],, no_phonecore=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) CFLAGS="$ac_save_CFLAGS" LIBS="$ac_save_LIBS" fi fi if test "x$no_phonecore" = x ; then AC_MSG_RESULT(yes) ifelse([$2], , :, [$2]) else AC_MSG_RESULT(no) if test "$PC_CONFIG" = "no" ; then echo "*** The phonecore-config script installed by Phonecore could not be found" echo "*** If Phonecore was installed in PREFIX, make sure PREFIX/bin is in" echo "*** your path, or set the PC_CONFIG environment variable to the" echo "*** full path to phonecore-config." else if test -f conf.phonecoretest ; then : else echo "*** Could not run Phonecore test program, checking why..." CFLAGS="$CFLAGS $PC_CFLAGS" LIBS="$LIBS $PC_LIBS" AC_TRY_LINK([ #include #include ], [ return 0; ], [ echo "*** The test program compiled, but did not run. This usually means" echo "*** that the run-time linker is not finding Phonecore or finding the wrong" echo "*** version of PC. If it is not finding Phonecore, you'll need to set your" echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" echo "*** to the installed location Also, make sure you have run ldconfig if that" echo "*** is required on your system" echo "***" echo "*** If you have an old version installed, it is best to remove it, although" echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], [ echo "*** The test program failed to compile or link. See the file config.log for the" echo "*** exact error that occured. This usually means Phonecore was incorrectly installed" echo "*** or that you have moved Phonecore since it was installed. In the latter case, you" echo "*** may want to edit the phonecore-config script: $PC_CONFIG" ]) CFLAGS="$ac_save_CFLAGS" LIBS="$ac_save_LIBS" fi fi PC_CFLAGS="" PC_LIBS="" ifelse([$3], , :, [$3]) fi AC_SUBST(PC_CFLAGS) AC_SUBST(PC_LIBS) rm -f conf.phonecoretest ])