~ubuntu-branches/ubuntu/karmic/gnustep-base/karmic

« back to all changes in this revision

Viewing changes to config/pathxml.m4

  • Committer: Bazaar Package Importer
  • Author(s): Eric Heintzmann
  • Date: 2005-04-17 00:14:38 UTC
  • mfrom: (1.2.1 upstream) (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050417001438-enf0y07c9tku85z1
Tags: 1.10.3-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
dnl Code shamelessly stolen from glib-config by Sebastian Rittau
 
2
dnl AM_PATH_XML([MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
 
3
AC_DEFUN(AM_PATH_XML,[
 
4
AC_ARG_WITH(xml-prefix,
 
5
            [  --with-xml-prefix=PFX    Prefix where libxml is installed (optional)],
 
6
            xml_config_prefix="$withval", xml_config_prefix="")
 
7
AC_ARG_ENABLE(xmltest,
 
8
              [  --disable-xmltest              Do not try to compile and run a test XML program],,
 
9
              enable_xmltest=yes)
 
10
 
 
11
  if test x$xml_config_prefix != x ; then
 
12
    xml_config_args="$xml_config_args --prefix=$xml_config_prefix"
 
13
    if test x${XML_CONFIG+set} != xset ; then
 
14
      XML_CONFIG=$xml_config_prefix/bin/xml-config
 
15
    fi
 
16
  fi
 
17
 
 
18
  AC_PATH_PROG(XML2_CONFIG, xml2-config, no)
 
19
  if test "$XML2_CONFIG" = "no" ; then
 
20
    AC_PATH_PROG(XML_CONFIG, xml-config, no)
 
21
  else
 
22
    XML_CONFIG=$XML2_CONFIG
 
23
  fi
 
24
  min_xml_version=ifelse([$1], ,2.0.0, [$1])
 
25
  AC_MSG_CHECKING(for libxml - version >= $min_xml_version)
 
26
  no_xml=""
 
27
  if test "$XML_CONFIG" = "no" ; then
 
28
    XML_CFLAGS=""
 
29
    XML_LIBS="-lxml2"
 
30
 
 
31
    ac_save_CFLAGS="$CFLAGS"
 
32
    ac_save_LIBS="$LIBS"
 
33
    CFLAGS="$CFLAGS $XML_CFLAGS"
 
34
    LIBS="$XML_LIBS $LIBS"
 
35
dnl
 
36
dnl Now check if the installed libxml is sufficiently new.
 
37
dnl
 
38
    rm -f conf.xmltest
 
39
    AC_TRY_RUN([
 
40
#include <stdlib.h>
 
41
#include <stdio.h>
 
42
#include <libxml/xmlversion.h>
 
43
#include <libxml/parser.h>
 
44
 
 
45
int
 
46
main()
 
47
{
 
48
  int xml_major_version, xml_minor_version, xml_micro_version;
 
49
  int major, minor, micro;
 
50
  char *tmp_version;
 
51
 
 
52
  system("touch conf.xmltest");
 
53
 
 
54
  tmp_version = xmlStrdup("$min_xml_version");
 
55
  if(sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
 
56
    printf("%s, bad version string\n", "$min_xml_version");
 
57
    exit(1);
 
58
  }
 
59
 
 
60
  tmp_version = xmlStrdup(LIBXML_DOTTED_VERSION);
 
61
  if(sscanf(tmp_version, "%d.%d.%d", &xml_major_version, &xml_minor_version, &xml_micro_version) != 3) {
 
62
    printf("%s, bad version string\n", "$min_xml_version");
 
63
    exit(1);
 
64
  }
 
65
 
 
66
  if ((xml_major_version > major) ||
 
67
      ((xml_major_version == major) && (xml_minor_version > minor)) ||
 
68
      ((xml_major_version == major) && (xml_minor_version == minor) &&
 
69
       (xml_micro_version >= micro)))
 
70
    {
 
71
      return 0;
 
72
    }
 
73
  else
 
74
    {
 
75
      printf("\n*** An old version of libxml (%d.%d.%d) was found.\n",
 
76
        xml_major_version, xml_minor_version, xml_micro_version);
 
77
      printf("*** You need a version of libxml newer than %d.%d.%d. The latest version of\n",
 
78
        major, minor, micro);
 
79
      printf("*** libxml is always available from ftp://ftp.gnome.org.\n");
 
80
      printf("***\n");
 
81
      printf("*** If you have already installed a sufficiently new version, this error\n");
 
82
      printf("*** probably means that the wrong copy of the xml-config shell script is\n");
 
83
      printf("*** being found. The easiest way to fix this is to remove the old version\n");
 
84
      printf("*** of libxml, but you can also set the XML_CONFIG environment to point to the\n");
 
85
      printf("*** correct copy of xml-config. (In this case, you will have to\n");
 
86
      printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
 
87
      printf("*** so that the correct libraries are found at run-time))\n");
 
88
    }
 
89
  return 1;
 
90
}
 
91
],, no_xml=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
 
92
 
 
93
    CFLAGS="$ac_save_CFLAGS"
 
94
    LIBS="$ac_save_LIBS"
 
95
  else
 
96
    XML_CFLAGS=`$XML_CONFIG $xml_config_args --cflags`
 
97
    XML_LIBS=`$XML_CONFIG $xml_config_args --libs`
 
98
    xml_config_major_version=`$XML_CONFIG $xml_config_args --version | \
 
99
      sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
 
100
    xml_config_minor_version=`$XML_CONFIG $xml_config_args --version | \
 
101
      sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
 
102
    xml_config_micro_version=`$XML_CONFIG $xml_config_args --version | \
 
103
      sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
 
104
    # Strip '-L/usr/lib' off since this is always in the link path.
 
105
    XML_LIBS=`echo $XML_LIBS | sed -e 's|-L/usr/lib||'`
 
106
 
 
107
    if test "x$enable_xmltest" = "xyes" ; then
 
108
      ac_save_CFLAGS="$CFLAGS"
 
109
      ac_save_LIBS="$LIBS"
 
110
      CFLAGS="$CFLAGS $XML_CFLAGS"
 
111
      LIBS="$XML_LIBS $LIBS"
 
112
dnl
 
113
dnl Now check if the installed libxml is sufficiently new.
 
114
dnl
 
115
      rm -f conf.xmltest
 
116
      AC_TRY_RUN([
 
117
#include <stdlib.h>
 
118
#include <stdio.h>
 
119
#include <libxml/xmlversion.h>
 
120
#include <libxml/parser.h>
 
121
 
 
122
int
 
123
main()
 
124
{
 
125
  int xml_major_version, xml_minor_version, xml_micro_version;
 
126
  int major, minor, micro;
 
127
  char *tmp_version;
 
128
 
 
129
  system("touch conf.xmltest");
 
130
 
 
131
  tmp_version = xmlStrdup("$min_xml_version");
 
132
  if(sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
 
133
    printf("%s, bad version string\n", "$min_xml_version");
 
134
    exit(1);
 
135
  }
 
136
 
 
137
  tmp_version = xmlStrdup(LIBXML_DOTTED_VERSION);
 
138
  if(sscanf(tmp_version, "%d.%d.%d", &xml_major_version, &xml_minor_version, &xml_micro_version) != 3) {
 
139
    printf("%s, bad version string\n", "$min_xml_version");
 
140
    exit(1);
 
141
  }
 
142
 
 
143
  if((xml_major_version != $xml_config_major_version) ||
 
144
     (xml_minor_version != $xml_config_minor_version) ||
 
145
     (xml_micro_version != $xml_config_micro_version))
 
146
    {
 
147
      printf("\n*** 'xml-config --version' returned %d.%d.%d, but libxml (%d.%d.%d)\n", 
 
148
             $xml_config_major_version, $xml_config_minor_version, $xml_config_micro_version,
 
149
             xml_major_version, xml_minor_version, xml_micro_version);
 
150
      printf("*** was found! If xml-config was correct, then it is best\n");
 
151
      printf("*** to remove the old version of libxml. You may also be able to fix the error\n");
 
152
      printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
 
153
      printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
 
154
      printf("*** required on your system.\n");
 
155
      printf("*** If xml-config was wrong, set the environment variable XML_CONFIG\n");
 
156
      printf("*** to point to the correct copy of xml-config, and remove the file config.cache\n");
 
157
      printf("*** before re-running configure\n");
 
158
    }
 
159
  else
 
160
    {
 
161
      if ((xml_major_version > major) ||
 
162
          ((xml_major_version == major) && (xml_minor_version > minor)) ||
 
163
          ((xml_major_version == major) && (xml_minor_version == minor) &&
 
164
           (xml_micro_version >= micro)))
 
165
        {
 
166
          return 0;
 
167
        }
 
168
      else
 
169
        {
 
170
          printf("\n*** An old version of libxml (%d.%d.%d) was found.\n",
 
171
            xml_major_version, xml_minor_version, xml_micro_version);
 
172
          printf("*** You need a version of libxml newer than %d.%d.%d. The latest version of\n",
 
173
            major, minor, micro);
 
174
          printf("*** libxml is always available from ftp://ftp.gnome.org.\n");
 
175
          printf("***\n");
 
176
          printf("*** If you have already installed a sufficiently new version, this error\n");
 
177
          printf("*** probably means that the wrong copy of the xml-config shell script is\n");
 
178
          printf("*** being found. The easiest way to fix this is to remove the old version\n");
 
179
          printf("*** of libxml, but you can also set the XML_CONFIG environment to point to the\n");
 
180
          printf("*** correct copy of xml-config. (In this case, you will have to\n");
 
181
          printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
 
182
          printf("*** so that the correct libraries are found at run-time))\n");
 
183
        }
 
184
    }
 
185
  return 1;
 
186
}
 
187
],, no_xml=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
 
188
 
 
189
      CFLAGS="$ac_save_CFLAGS"
 
190
      LIBS="$ac_save_LIBS"
 
191
    fi
 
192
  fi
 
193
 
 
194
  if test "x$no_xml" = x ; then
 
195
    AC_MSG_RESULT(yes)
 
196
    ifelse([$2], , :, [$2])
 
197
  else
 
198
    AC_MSG_RESULT(no)
 
199
    if test "$XML_CONFIG" = "no" ; then
 
200
      echo "*** The xml-config script installed by libxml could not be found"
 
201
      echo "*** If libxml was installed in PREFIX, make sure PREFIX/bin is in"
 
202
      echo "*** your path, or set the XML_CONFIG environment variable to the"
 
203
      echo "*** full path to xml-config."
 
204
    else
 
205
      if test -f conf.xmltest ; then
 
206
        :
 
207
      else
 
208
        echo "*** Could not run libxml test program, checking why..."
 
209
        CFLAGS="$CFLAGS $XML_CFLAGS"
 
210
        LIBS="$LIBS $XML_LIBS"
 
211
        dnl FIXME: AC_TRY_LINK
 
212
      fi
 
213
    fi
 
214
 
 
215
    XML_CFLAGS=""
 
216
    XML_LIBS=""
 
217
    ifelse([$3], , :, [$3])
 
218
  fi
 
219
  AC_SUBST(XML_CFLAGS)
 
220
  AC_SUBST(XML_LIBS)
 
221
  rm -f conf.xmltest
 
222
])
 
223