| 1 |
|
# Copyright 2002 Cyril Picard |
| 2 |
|
# |
| 3 |
|
# This file is part of the GEDCOMParser library |
| 4 |
|
# (developed within the Genealogy Free Software Tools project). |
| 5 |
|
# |
| 6 |
|
# The GEDCOMParser library is free software; you can redistribute it and/or modify |
| 7 |
|
# it under the terms of the GNU General Public License as published by |
| 8 |
|
# the Free Software Foundation; either version 2 of the License, or |
| 9 |
|
# (at your option) any later version. |
| 10 |
|
# |
| 11 |
|
# The GEDCOMParser library is distributed in the hope that it will be useful, |
| 12 |
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
|
# GNU General Public License for more details. |
| 15 |
|
# |
| 16 |
|
# You should have received a copy of the GNU General Public License |
| 17 |
|
# along with the GEDCOMParser library ; if not, write to the Free Software |
| 18 |
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 |
|
# |
| 20 |
|
# |
| 21 |
|
|
| 22 |
|
dnl Test for GEDCOMPARSER, and define GEDCOMPARSER_CFLAGS and GEDCOMPARSER_LIBS |
| 23 |
|
dnl to be used as follows: |
| 24 |
|
dnl AM_PATH_GEDCOMPARSER([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) |
| 25 |
|
dnl |
| 26 |
|
AC_DEFUN(AM_PATH_GEDCOMPARSER, |
| 27 |
|
[dnl |
| 28 |
|
dnl Get the cflags and libraries from the gedcomparser-config script |
| 29 |
|
dnl |
| 30 |
|
AC_ARG_WITH(gedcomparser-prefix,[ --with-gedcomparser-prefix=PREFIX |
| 31 |
|
Prefix where GEDCOMPARSER is installed (optional)], |
| 32 |
|
gedcomparser_config_prefix="$withval", gedcomparser_config_prefix="") |
| 33 |
|
AC_ARG_WITH(gedcomparser-exec-prefix,[ --with-gedcomparser-exec-prefix=PREFIX |
| 34 |
|
Exec prefix where GEDCOMPARSER is installed (optional)], |
| 35 |
|
gedcomparser_config_exec_prefix="$withval", gedcomparser_config_exec_prefix="") |
| 36 |
|
AC_ARG_ENABLE(gedcomparsertest, [ --disable-gedcomparsertest Do not try to compile and run a test GEDCOMPARSER program], |
| 37 |
|
, enable_gedcomparsertest=yes) |
| 38 |
|
|
| 39 |
|
if test x$gedcomparser_config_exec_prefix != x ; then |
| 40 |
|
gedcomparser_config_args="$gedcomparser_config_args --exec-prefix=$gedcomparser_config_exec_prefix" |
| 41 |
|
if test x${GEDCOMPARSER_CONFIG+set} != xset ; then |
| 42 |
|
GEDCOMPARSER_CONFIG=$gedcomparser_config_exec_prefix/bin/gedcomparser-config |
| 43 |
|
fi |
| 44 |
|
fi |
| 45 |
|
if test x$gedcomparser_config_prefix != x ; then |
| 46 |
|
gedcomparser_config_args="$gedcomparser_config_args --prefix=$gedcomparser_config_prefix" |
| 47 |
|
if test x${GEDCOMPARSER_CONFIG+set} != xset ; then |
| 48 |
|
GEDCOMPARSER_CONFIG=$gedcomparser_config_prefix/bin/gedcomparser-config |
| 49 |
|
fi |
| 50 |
|
fi |
| 51 |
|
|
| 52 |
|
AC_PATH_PROG(GEDCOMPARSER_CONFIG, gedcomparser-config, no) |
| 53 |
|
min_gedcomparser_version=ifelse([$1], ,0.1.0,$1) |
| 54 |
|
|
| 55 |
|
AC_MSG_CHECKING(for GEDCOMPARSER - version >= $min_gedcomparser_version) |
| 56 |
|
AC_LANG_SAVE |
| 57 |
|
no_gedcomparser="" |
| 58 |
|
if test "$GEDCOMPARSER_CONFIG" = "no" ; then |
| 59 |
|
no_gedcomparser=yes |
| 60 |
|
else |
| 61 |
|
AC_LANG_CPLUSPLUS |
| 62 |
|
|
| 63 |
|
GEDCOMPARSER_CFLAGS=`$GEDCOMPARSER_CONFIG $gedcomparser_config_args --cflags` |
| 64 |
|
GEDCOMPARSER_LIBS=`$GEDCOMPARSER_CONFIG $gedcomparser_config_args --libs` |
| 65 |
|
gedcomparser_config_major_version=`$GEDCOMPARSER_CONFIG $gedcomparser_config_args --version | \ |
| 66 |
|
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` |
| 67 |
|
gedcomparser_config_minor_version=`$GEDCOMPARSER_CONFIG $gedcomparser_config_args --version | \ |
| 68 |
|
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` |
| 69 |
|
gedcomparser_config_micro_version=`$GEDCOMPARSER_CONFIG $gedcomparser_config_args --version | \ |
| 70 |
|
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` |
| 71 |
|
if test "x$enable_gedcomparsertest" = "xyes" ; then |
| 72 |
|
ac_save_CXXFLAGS="$CXXFLAGS" |
| 73 |
|
ac_save_LIBS="$LIBS" |
| 74 |
|
CXXFLAGS="$CXXFLAGS $GEDCOMPARSER_CFLAGS" |
| 75 |
|
LIBS="$LIBS $GEDCOMPARSER_LIBS" |
| 76 |
|
dnl |
| 77 |
|
dnl Now check if the installed GEDCOMPARSER is sufficiently new. (Also sanity |
| 78 |
|
dnl checks the results of gedcomparser-config to some extent |
| 79 |
|
dnl |
| 80 |
|
rm -f conf.gedcomparsertest |
| 81 |
|
AC_TRY_RUN([ |
| 82 |
|
|
| 83 |
|
#include "GEDCOMParser/Parser.hh" |
| 84 |
|
#include "GEDCOMParser/GEDCOMFactory.hh" |
| 85 |
|
|
| 86 |
|
int |
| 87 |
|
main () |
| 88 |
|
{ |
| 89 |
|
system ("touch conf.gtkmmtest"); |
| 90 |
|
GEDCOMParser::GEDCOMFactory factory; |
| 91 |
|
GEDCOMParser::Parser viewparser(&factory); |
| 92 |
|
return 0; |
| 93 |
|
} |
| 94 |
|
],, no_gedcomparser=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) |
| 95 |
|
CXXFLAGS="$ac_save_CXXFLAGS" |
| 96 |
|
LIBS="$ac_save_LIBS" |
| 97 |
|
fi |
| 98 |
|
fi |
| 99 |
|
if test "x$no_gedcomparser" = x ; then |
| 100 |
|
AC_MSG_RESULT(yes) |
| 101 |
|
ifelse([$2], , :, [$2]) |
| 102 |
|
else |
| 103 |
|
AC_MSG_RESULT(no) |
| 104 |
|
if test "$GEDCOMPARSER_CONFIG" = "no" ; then |
| 105 |
|
echo "*** The gedcomparser-config script installed by GEDCOMPARSER could not be found" |
| 106 |
|
echo "*** If GEDCOMPARSER was installed in PREFIX, make sure PREFIX/bin is in" |
| 107 |
|
echo "*** your path, or set the GEDCOMPARSER_CONFIG environment variable to the" |
| 108 |
|
echo "*** full path to gedcomparser-config." |
| 109 |
|
echo "*** The gedcomparser-config script was not available in GEDCOMPARSER versions" |
| 110 |
|
echo "*** prior to 0.1.2. Perhaps you need to update your installed" |
| 111 |
|
echo "*** version to 0.1.2 or later" |
| 112 |
|
else |
| 113 |
|
if test -f conf.gedcomparsertest ; then |
| 114 |
|
: |
| 115 |
|
else |
| 116 |
|
echo "*** Could not run GEDCOMPARSER test program, checking why..." |
| 117 |
|
CXXFLAGS="$CXXFLAGS $GEDCOMPARSER_CFLAGS" |
| 118 |
|
LIBS="$LIBS $GEDCOMPARSER_LIBS" |
| 119 |
|
AC_TRY_LINK([ |
| 120 |
|
|
| 121 |
|
#include "GEDCOMParser/Parser.hh" |
| 122 |
|
#include "GEDCOMParser/GEDCOMFactory.hh" |
| 123 |
|
#include <stdio.h> |
| 124 |
|
],, |
| 125 |
|
[ echo "*** The test program compiled, but did not run. This usually means" |
| 126 |
|
echo "*** that the run-time linker is not finding GEDCOMPARSER or finding the wrong" |
| 127 |
|
echo "*** version of GEDCOMPARSER. If it is not finding GEDCOMPARSER, you'll need to set your" |
| 128 |
|
echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" |
| 129 |
|
echo "*** to the installed location Also, make sure you have run ldconfig if that" |
| 130 |
|
echo "*** is required on your system" |
| 131 |
|
echo "***" |
| 132 |
|
echo "*** If you have an old version installed, it is best to remove it, although" |
| 133 |
|
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ], |
| 134 |
|
[ echo "*** The test program failed to compile or link. See the file config.log for the" |
| 135 |
|
echo "*** exact error that occured. This usually means GEDCOMPARSER was incorrectly installed" |
| 136 |
|
echo "*** or that you have moved GEDCOMPARSER since it was installed. In the latter case, you" |
| 137 |
|
echo "*** may want to edit the gedcomparser-config script: $GEDCOMPARSER_CONFIG" ]) |
| 138 |
|
CXXFLAGS="$ac_save_CXXFLAGS" |
| 139 |
|
LIBS="$ac_save_LIBS" |
| 140 |
|
fi |
| 141 |
|
fi |
| 142 |
|
GEDCOMPARSER_CFLAGS="" |
| 143 |
|
GEDCOMPARSER_LIBS="" |
| 144 |
|
ifelse([$3], , :, [$3]) |
| 145 |
|
fi |
| 146 |
|
AC_LANG_RESTORE |
| 147 |
|
AC_SUBST(GEDCOMPARSER_CFLAGS) |
| 148 |
|
AC_SUBST(GEDCOMPARSER_LIBS) |
| 149 |
|
rm -f conf.gedcomparsertest |
| 150 |
|
]) |
| 151 |
|
|