1 dnl Autoconf/automake macros for the Gedcom parser library
3 dnl partly stolen from Manish Singh
4 dnl stolen back from Frank Belew
5 dnl stolen from Manish Singh
6 dnl Shamelessly stolen from Owen Taylor
11 dnl AM_PATH_GEDCOM_PARSER([MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
12 dnl Test for gedcom-parse, and define GEDCOM_CFLAGS and GEDCOM_LIBS
14 AC_DEFUN(AM_PATH_GEDCOM_PARSER, [
15 AC_ARG_WITH(gedcom-prefix,[ --with-gedcom-prefix=PFX Prefix where the Gedcom parser library is installed (optional)],
16 gedcom_config_prefix="$withval", gedcom_config_prefix="")
17 AC_ARG_WITH(gedcom-exec-prefix,[ --with-gedcom-exec-prefix=PFX Exec prefix where the Gedcom parser library is installed (optional)],
18 gedcom_config_exec_prefix="$withval", gedcom_config_exec_prefix="")
19 AC_ARG_ENABLE(gedcomtest, [ --disable-gedcomtest Do not try to compile and run a test program with the Gedcom parser library],
20 , enable_gedcomtest=yes)
26 gedcom_config_args="$gedcom_config_args gom"
31 if test x$gedcom_config_exec_prefix != x ; then
32 gedcom_config_args="$gedcom_config_args --exec-prefix=$gedcom_config_exec_prefix"
33 if test x${GEDCOM_CONFIG+set} != xset ; then
34 GEDCOM_CONFIG=$gedcom_config_exec_prefix/bin/gedcom-config
37 if test x$gedcom_config_prefix != x ; then
38 gedcom_config_args="$gedcom_config_args --prefix=$gedcom_config_prefix"
39 if test x${GEDCOM_CONFIG+set} != xset ; then
40 GEDCOM_CONFIG=$gedcom_config_prefix/bin/gedcom-config
44 AC_PATH_PROG(GEDCOM_CONFIG, gedcom-config, no)
45 min_gedcom_version=ifelse([$1], ,0.20.0,$1)
46 AC_MSG_CHECKING(for Gedcom parser library - version >= $min_gedcom_version)
48 if test "$GEDCOM_CONFIG" = "no" ; then
51 GEDCOM_CFLAGS=`$GEDCOM_CONFIG $gedcom_config_args --cflags`
52 GEDCOM_LIBS=`$GEDCOM_CONFIG $gedcom_config_args --libs`
53 gedcom_config_major_vers=`$GEDCOM_CONFIG $gedcom_config_args --version | \
54 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
55 gedcom_config_minor_vers=`$GEDCOM_CONFIG $gedcom_config_args --version | \
56 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
57 gedcom_config_patch_vers=`$GEDCOM_CONFIG $gedcom_config_args --version | \
58 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
59 if test "x$enable_gedcomtest" = "xyes" ; then
60 ac_save_CFLAGS="$CFLAGS"
62 CFLAGS="$CFLAGS $GEDCOM_CFLAGS"
63 LIBS="$GEDCOM_LIBS $LIBS"
65 dnl Now check if the installed Gedcom parser is sufficiently new. (Also sanity
66 dnl checks the results of gedcom-config to some extent
82 new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
83 strcpy (new_str, str);
94 int major, minor, micro;
97 system ("touch conf.gedcomtest");
99 /* HP/UX 9 (%@#!) writes to sscanf strings */
100 tmp_version = my_strdup("$min_gedcom_version");
101 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
102 printf("%s, bad version string\n", "$min_gedcom_version");
108 #ifdef GEDCOM_PARSE_VERSION_PATCH
109 else if ((GEDCOM_PARSE_VERSION_MAJOR != $gedcom_config_major_vers) ||
110 (GEDCOM_PARSE_VERSION_MINOR != $gedcom_config_minor_vers) ||
111 (GEDCOM_PARSE_VERSION_PATCH != $gedcom_config_patch_vers))
113 printf("\n*** 'gedcom-config --version' returned %d.%d.%d, but gedcom-parse (%d.%d.%d)\n",
114 $gedcom_config_major_vers, $gedcom_config_minor_vers, $gedcom_config_patch_vers,
115 GEDCOM_PARSE_VERSION_MAJOR, GEDCOM_PARSE_VERSION_MINOR,
116 GEDCOM_PARSE_VERSION_PATCH);
117 printf ("*** was found! If gedcom-config was correct, then it is best to remove the\n");
118 printf ("*** old version of gedcom-parse. You may also be able to fix the error\n");
119 printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
120 printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
121 printf("*** required on your system.\n");
122 printf("*** If gedcom-config was wrong, set the environment variable GEDCOM_CONFIG\n");
123 printf("*** to point to the correct copy of gedcom-config, and remove the file config.cache\n");
124 printf("*** before re-running configure\n");
128 else if (gedcom_check_version(major, minor, micro)) {
132 else if (GEDCOM_PARSE_VERSION >= major * 1000 + minor) {
139 printf("\n*** An old version of gedcom-parse (%d.%d.%d) was found.\n",
140 GEDCOM_PARSE_VERSION_MAJOR, GEDCOM_PARSE_VERSION_MINOR,
141 GEDCOM_PARSE_VERSION_PATCH);
142 printf("*** You need a version of gedcom-parse newer than %d.%d.%d. The latest version\n",
143 major, minor, micro);
144 printf("*** of gedcom-parse is always available from the following location:\n");
145 printf("*** https://sourceforge.net/projects/gedcom-parse\n");
147 printf("*** If you have already installed a sufficiently new version, this error\n");
148 printf("*** probably means that the wrong copy of the gedcom-config shell script is\n");
149 printf("*** being found. The easiest way to fix this is to remove the old version\n");
150 printf("*** of gedcom-parse, but you can also set the GEDCOM_CONFIG environment to\n");
151 printf("*** point to the correct copy of gedcom-config. (In this case, you will have\n");
152 printf("*** to modify your LD_LIBRARY_PATH environment var., or edit /etc/ld.so.conf\n");
153 printf("*** so that the correct libraries are found at run-time))\n");
157 ],, no_gedcom=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
158 CFLAGS="$ac_save_CFLAGS"
162 if test "x$no_gedcom" = x ; then
164 ifelse([$2], , :, [$2])
167 if test "$GEDCOM_CONFIG" = "no" ; then
168 echo "*** The gedcom-config script installed by gedcom-parse could not be found"
169 echo "*** If gedcom-parse was installed in PREFIX, make sure PREFIX/bin is in"
170 echo "*** your path, or set the GEDCOM_CONFIG environment variable to the"
171 echo "*** full path to gedcom-config."
172 echo "*** It could also be that your version of gedcom-parse is too old."
173 echo "*** You need at least version $min_gedcom_version. The latest version"
174 echo "*** of gedcom-parse can always be found at this location:"
175 echo "*** https://sourceforge.net/projects/gedcom-parse"
177 if test -f conf.gedcomtest ; then
180 echo "*** Could not run gedcom-parse test program, checking why..."
181 CFLAGS="$CFLAGS $GEDCOM_CFLAGS"
182 LIBS="$LIBS $GEDCOM_LIBS"
186 ], [ return ((GEDCOM_PARSE_VERSION_MAJOR) || (GEDCOM_PARSE_VERSION_MINOR) || (GEDCOM_PARSE_VERSION_PATCH)); ],
187 [ echo "*** The test program compiled, but did not run. This usually means"
188 echo "*** that the run-time linker is not finding gedcom-parse or finding the wrong"
189 echo "*** version of gedcom-parse. If it is not finding gedcom-parse, you'll need"
190 echo "*** to set your LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf"
191 echo "*** to point to the installed location Also, make sure you have run ldconfig"
192 echo "*** if that is required on your system"
194 echo "*** If you have an old version installed, it is best to remove it, although"
195 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
197 [ echo "*** The test program failed to compile or link. See the file config.log for the"
198 echo "*** exact error that occured. This usually means gedcom-parse was incorrectly"
199 echo "*** installed or that you have moved gedcom-parse since it was installed."
200 echo "*** In the latter case, you may want to edit the gedcom-config script: $GEDCOM_CONFIG" ])
201 CFLAGS="$ac_save_CFLAGS"
207 ifelse([$3], , :, [$3])
209 AC_SUBST(GEDCOM_CFLAGS)
210 AC_SUBST(GEDCOM_LIBS)
211 rm -f conf.gedcomtest