d2335731b674b0ba4bdd9202bf251459b516eac6
[gedcom-parse.git] / m4 / gedcom.m4
1 dnl Autoconf/automake macros for the Gedcom parser library
2 dnl Peter Verthez
3 dnl 
4 dnl $Id$
5 dnl $Name$
6
7 dnl AM_LIB_GEDCOM_PARSER([MINIMUM-MAJOR-VERSION, [MINIMUM-MINOR-VERSION]])
8 dnl Test for the availability of the Gedcom parser library, and check whether
9 dnl the required minimum version is available (parameters default to 0 if
10 dnl not given
11 AC_DEFUN(AM_LIB_GEDCOM_PARSER, [
12   AC_CHECK_LIB(gedcom, gedcom_parse_file,,
13      AC_MSG_ERROR([Cannot find libgedcom: Please install gedcom-parse]))
14   major_version=ifelse([$1], ,0,$1)
15   minor_version=ifelse([$2], ,0,$2)
16   AC_MSG_CHECKING(for libgedcom version >= $major_version.$minor_version)
17   AC_TRY_RUN([
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <gedcom.h>
21 int
22 main()
23 {
24 if (GEDCOM_PARSE_VERSION >= $major_version * 1000 + $minor_version) exit(0);
25 exit(1);
26 }],
27 ac_gedcom_version_ok='yes',
28 ac_gedcom_version_ok='no',
29 ac_gedcom_version_ok='no')
30 if test "$ac_gedcom_version_ok" = 'yes' ; then
31   AC_MSG_RESULT(ok)
32 else
33   AC_MSG_RESULT(not ok)
34   AC_MSG_ERROR(You need at least version $major_version.$minor_version of gedcom-parse)
35 fi
36 ])