summaryrefslogtreecommitdiff
path: root/configure.ac
blob: 86e26c517d6c07727ad8798f568f12badbe2e51e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
dnl -*- Mode: autoconf -*-
dnl
dnl configure.in - autoconf file for Raptor
dnl (Process this file with autoconf to produce a configure script.)
dnl
dnl $Id$
dnl
dnl Copyright (C) 2000-2004, David Beckett http://purl.org/net/dajobe/
dnl Institute for Learning and Research Technology http://www.ilrt.bristol.ac.uk/
dnl University of Bristol, UK http://www.bristol.ac.uk/
dnl 
dnl This package is Free Software and part of Redland http://librdf.org/
dnl 
dnl It is licensed under the following three licenses as alternatives:
dnl   1. GNU Lesser General Public License (LGPL) V2.1 or any newer version
dnl   2. GNU General Public License (GPL) V2 or any newer version
dnl   3. Apache License, V2.0 or any newer version
dnl 
dnl You may not use this file except in compliance with at least one of
dnl the above three licenses.
dnl 
dnl See LICENSE.html or LICENSE.txt at the top of this package for the
dnl complete terms and further detail along with the license texts for
dnl the licenses in COPYING.LIB, COPYING and LICENSE-2.0.txt respectively.
dnl 
dnl 


AC_INIT(Raptor RDF Parser, 1.4.7, http://bugs.librdf.org/, raptor)
AC_PREREQ(2.50)
AC_CONFIG_SRCDIR(raptor_parse.c)
AC_REVISION($Revision$)

libxml_min_version=2.4.0
# Need XML Reader and node type enums for RSS Tag Soup parser
libxml_rss_min_version=2.5.10

libxslt_min_version=1.0.18

AM_INIT_AUTOMAKE([1.7 check-news std-options -Wall])
AM_CONFIG_HEADER(raptor_config.h)
AM_MAINTAINER_MODE

release_version=no
AC_ARG_ENABLE(release, [  --enable-release        Turn on optimizations (for maintainer).  ], \
 if test "$enableval" = "yes"; then \
	  release_version=yes
fi;)	

if test "$USE_MAINTAINER_MODE" = yes -a $release_version = no; then 
  CFLAGS=`echo $CFLAGS | sed s/-O2//`
  CXXFLAGS=`echo $CXXFLAGS | sed s/-O2//`
  CPPFLAGS=`echo $CPPFLAGS | sed s/-O2//`
fi

dnl Checks for programs.
AC_CANONICAL_HOST
AM_SANITY_CHECK
AM_PROG_CC_STDC
AC_PROG_LIBTOOL
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET

AC_PROG_LEX
if test "$LEX" != flex -a "$LEX" != ":"; then
  LEX="$SHELL $missing_dir/missing flex"
  AC_SUBST(LEX_OUTPUT_ROOT, lex.yy)
  AC_SUBST(LEXLIB, '')
fi

if test "$USE_MAINTAINER_MODE" = yes; then
  FLEX_MIN_VERSION=2.5.19
  FLEX_REC_VERSION=2.5.31
  AC_MSG_CHECKING(flex version)
  if test "X$LEX" != "X:"; then
    FLEX_VERSION=`$LEX -V 2>&1 | awk '{print $NF}'`
    FLEX_VERSION_DEC=`echo $FLEX_VERSION | $AWK -F. '{printf("%d\n", 10000*$1 + 100*$2 + $3)};'`

    FLEX_MIN_VERSION_DEC=`echo $FLEX_MIN_VERSION | $AWK -F. '{printf("%d\n", 10000*$1 + 100*$2 + $3)};'`

    if test $FLEX_VERSION_DEC -ge $FLEX_MIN_VERSION_DEC; then
      AC_MSG_RESULT($FLEX_VERSION - OK)
    else
      AC_MSG_WARN(Please get flex from http://lex.sourceforge.net/)
      AC_MSG_WARN(version $FLEX_MIN_VERSION ($FLEX_REC_VERSION recommended))
      AC_MSG_FAILURE(flex version $FLEX_VERSION is too old)
    fi
  else
    AC_MSG_WARN(Please get flex from http://lex.sourceforge.net/)
    AC_MSG_WARN(version $FLEX_MIN_VERSION ($FLEX_REC_VERSION recommended))
    AC_MSG_FAILURE(flex not present)
  fi
fi

AC_PROG_YACC
if test "$USE_MAINTAINER_MODE" = yes; then
  AC_MSG_CHECKING(for GNU bison)
  # Match these styles of versions
  # GNU Bison version 1.28
  # bison (GNU Bison) 1.875
dnl need to change quotes to allow square brackets
changequote(<<, >>)dnl
  YACC_VERSION=`$YACC --version 2>&1 | sed -ne 's/^.*GNU Bison[^0-9]*//p'`
changequote([, ])dnl
  if test "X$YACC_VERSION" != X; then
    AC_MSG_RESULT($YACC_VERSION - OK)
  else
    AC_MSG_FAILURE($YACC is not GNU bison)
  fi
fi


# Find a tar command for 'make dist'
AC_CHECK_PROGS(TAR, gnutar gtar tar)
AC_CHECK_PROGS(PERL, perl)

AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)



dnl compiler checks
# if using gcc...
if test "$ac_cv_prog_gcc" = yes; then
  STANDARD_CFLAGS=
  MAINTAINER_CFLAGS="-Wall -Wshadow -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Wredundant-decls -Wswitch-enum"
else
  STANDARD_CFLAGS=
  MAINTAINER_CFLAGS=
fi



dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(errno.h stdlib.h unistd.h string.h limits.h dmalloc.h getopt.h sys/stat.h curl/curl.h libxml/nanohttp.h sys/param.h)
dnl FreeBSD fetch.h needs stdio.h and sys/param.h first
AC_CHECK_HEADERS(fetch.h,,,
  [#include <stdio.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
])



dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_BIGENDIAN

AC_CHECK_TYPE([u8 u16 u32])

AC_CHECK_SIZEOF(unsigned char, 1)
AC_CHECK_SIZEOF(unsigned short, 2)
AC_CHECK_SIZEOF(unsigned int, 4)
AC_CHECK_SIZEOF(unsigned long, 4)
  

dnl need to change quotes to allow square brackets
changequote(<<, >>)dnl
version_major=`echo $VERSION | sed -e 's/^\([^\.]*\)\.\([^\.]*\)\.\(.*\)$/\1/'`
version_minor=`echo $VERSION | sed -e 's/^\([^\.]*\)\.\([^\.]*\)\.\(.*\)$/\2/'`
version_release=`echo $VERSION | sed -e 's/^\([^\.]*\)\.\([^\.]*\)\.\(.*\)$/\3/'`
changequote([, ])dnl

version_decimal=`expr $version_major \* 10000 + $version_minor \* 100 + $version_release`

AC_DEFINE_UNQUOTED(RAPTOR_VERSION_MAJOR, $version_major, [Major version number])
AC_DEFINE_UNQUOTED(RAPTOR_VERSION_MINOR, $version_minor, [Minor version number])
AC_DEFINE_UNQUOTED(RAPTOR_VERSION_RELEASE, $version_release, [Release version number])
AC_DEFINE_UNQUOTED(RAPTOR_VERSION_DECIMAL, $version_decimal, [Release version as a decimal])

# for raptor-config.in
RAPTOR_VERSION_DECIMAL=$version_decimal
AC_SUBST(RAPTOR_VERSION_DECIMAL)

# Libtool versioning
#
# CURRENT
#      The most recent interface number that this library implements.
# 
# REVISION
#      The implementation number of the CURRENT interface.
# 
# AGE
#      The difference between the newest and oldest interfaces that this
#      library implements.  In other words, the library implements all the
#      interface numbers in the range from number `CURRENT - AGE' to
#      `CURRENT'.
#
# Rules:
#  1. Start with version information of `0:0:0' for each libtool library.
#
#  2. Update the version information only immediately before a public
#     release of your software.  More frequent updates are unnecessary,
#     and only guarantee that the current interface number gets larger
#     faster.
#
#  3. If the library source code has changed at all since the last
#     update, then increment REVISION (`C:R:A' becomes `C:r+1:A').
#
#  4. If any interfaces have been added, removed, or changed since the
#     last update, increment CURRENT, and set REVISION to 0.
#
#  5. If any interfaces have been added since the last public release,
#     then increment AGE.
#
#  6. If any interfaces have been removed since the last public release,
#     then set AGE to 0.
#
# syntax: CURRENT[:REVISION[:AGE]]
RAPTOR_LIBTOOL_VERSION=2:0:1
AC_SUBST(RAPTOR_LIBTOOL_VERSION)


dnl Checks for library functions.
AC_CHECK_FUNCS(getopt getopt_long stricmp strcasecmp vsnprintf)

AM_CONDITIONAL(STRCASECMP, test $ac_cv_func_stricmp = no -a $ac_cv_func_stricmp = no)
AM_CONDITIONAL(GETOPT, test $ac_cv_func_getopt = no -a $ac_cv_func_getopt_long = no)


AC_MSG_CHECKING(whether need to declare optind)
AC_TRY_LINK([#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif], [int x=optind;],
            AC_MSG_RESULT(no),
            AC_DEFINE(NEED_OPTIND_DECLARATION, 1, [need 'extern int optind' declaration?])
            AC_MSG_RESULT(yes))



if test $ac_cv_func_vsnprintf = yes; then
  AC_MSG_CHECKING(vsnprintf has C99 compatible return value)
  AC_TRY_RUN([#include <stdarg.h>
int is_c99(char *s, ...) {
  char buffer[32];
  va_list args;
  int r;
  va_start(args, s);
  r = vsnprintf(buffer, 5, s, args);
  va_end(args);

  return (r == 7);
}

int main(int argc, char* argv) {
  return is_c99("1234567");
}], AC_MSG_RESULT(no),
    AC_DEFINE(HAVE_C99_VSNPRINTF, 1, [vsnprint has C99 compatible return value])
    AC_MSG_RESULT(yes))
fi


dnl Checks for XML parsers
have_expat=0
have_expat_lib=0
have_expat_source=0
need_expat=0
need_expat_source=0
expat_source_dir=
expat_obj_dir=

AC_ARG_WITH(expat-source, [  --with-expat-source=PATH  Location of expat source tree (default=auto)], expat_source="$withval", expat_source="auto")


AC_MSG_CHECKING(for expat sources)
if test "$expat_source" != "auto"; then
  have_expat_source=1
  have_expat=1
  expat_source_dir=$expat_source
  expat_obj_dir=$expat_source
  AC_MSG_RESULT(yes - $expat_source)
elif test -d $srcdir/expat; then
  expat_source=local
  have_expat_source=1
  have_expat=1
  expat_source_dir="\$(top_srcdir)/expat"
  expat_obj_dir="\$(top_builddir)/expat"
  AC_MSG_RESULT(yes - local source)
else
  expat_source=
  AC_MSG_RESULT(no)
fi

if test "X$expat_source" = X; then
  expat_source=auto
else
  if test -d "$expat_source_dir/xmlparse"; then
    # old expat
    CPPFLAGS="-I$expat_source_dir/xmlparse $CPPFLAGS"
  else
    # new expat
    CPPFLAGS="-I$expat_source_dir/lib $CPPFLAGS"
  fi
fi

AC_CHECK_HEADERS(expat.h xmlparse.h)


oLIBS="$LIBS"
AC_CHECK_LIB(xmltok, main, xmlt=1, xmlt=0)

# Raptor needs XML_ParserCreate expat function (not namespace one)
AC_CHECK_LIB(xmlparse, XML_ParserCreate, xmlp=1, xmlp=0, -lxmltok)

LIBS="$oLIBS"
AC_CHECK_LIB(expat, XML_ParserCreate, libexpat=1, libexpat=0)

LIBS="$oLIBS"
AC_MSG_CHECKING(for working expat in libxmlparse and libxmltok)
if test $xmlp = 1 -a $xmlt = 1 -a  $ac_cv_header_xmlparse_h = yes; then
  LIBS="$LIBS -lxmlparse -lxmltok"
  AC_TRY_RUN([#include <stdio.h>
	     main() {XML_ParserCreate(NULL); return(0);}],
             worked=yes, worked=no, worked=no)
  if test $worked = yes; then
    # Old expat
    have_expat_lib=1
    have_expat=1
    expat_libs="-lxmlparse -lxmltok"

    AC_MSG_RESULT(yes)
  else
    AC_MSG_RESULT(no)
  fi
else
  AC_MSG_RESULT(no)
fi

LIBS="$oLIBS"

AC_MSG_CHECKING(for working expat in libexpat)
if test $libexpat = 1 -a $ac_cv_header_expat_h = yes ; then
  LIBS="$LIBS -lexpat"
  AC_TRY_RUN([#include <stdio.h>
             main() {XML_ParserCreate(NULL); return(0);}],
             worked=yes, worked=no, worked=no)
  if test $worked = yes; then
    # New expat - expat-1.95.0 or later
    have_expat_lib=1
    have_expat=1
    expat_libs="-lexpat"

    AC_MSG_RESULT(yes)

    AC_MSG_CHECKING(for expat support of UTF-8 BOM)
    AC_TRY_RUN([
#include <stdio.h>
#include <string.h>
#include <stdarg.h>

#ifdef HAVE_EXPAT_H
#include <expat.h>
#else
#ifdef HAVE_XMLPARSE_H
#include <xmlparse.h>
#endif
#endif

int main(int argc, char **argv) {
  const char *xml_buffer=
     /* UTF-8 BOM */
     "\xef\xbb\xbf<?xml version='1.0' encoding='UTF-8'?><tag/>";
  XML_Parser xp=XML_ParserCreate(NULL);
  int  len=strlen(xml_buffer);
  
  /* This might cause an error on expat 1.95.1 */
  int rc=XML_Parse(xp, xml_buffer, len, 1);

  /* if expat gives an error ... */
  if(!rc) {
    /* then the next line will crash in normal_updatePosition  */
    int line=XML_GetCurrentLineNumber(xp);
  }
  XML_ParserFree(xp);

  return 0;
}
],
            AC_MSG_RESULT(yes),
            AC_DEFINE(EXPAT_UTF8_BOM_CRASH, 1, [does expat crash when it sees an initial UTF8 BOM?])
            AC_MSG_RESULT(no)
            AC_MSG_WARN(The available expat crashes on XML UTF-8 BOM in documents)
            AC_MSG_WARN(Fix either by using libxml or expat 1.95.2+))

  else
    AC_MSG_RESULT(no)
  fi
else
  AC_MSG_RESULT(no)
fi

LIBS="$oLIBS"

AC_ARG_WITH(xml2-config, [  --with-xml2-config=PATH   Location of libxml xml2-config []], xml2_config="$withval", xml2_config="")

if test "X$xml2_config" != "X" ; then
  AC_MSG_CHECKING(for $xml2_config)

  if test -f $xml2_config ; then
    XML_CONFIG=$xml2_config
    AC_MSG_RESULT(yes)
  else
    AC_MSG_RESULT(no - searching PATH)
  fi
fi
if test "X$XML_CONFIG" = "X"; then
  AC_CHECK_PROGS(XML_CONFIG, xml2-config)
fi

AC_ARG_WITH(xslt-config, [  --with-xslt-config=PATH   Location of libxslt xslt-config []], xslt_config="$withval", xslt_config="")

if test "X$xslt_config" != "X" ; then
  AC_MSG_CHECKING(for $xslt_config)

  if test -f $xslt_config ; then
    XSLT_CONFIG=$xslt_config
    AC_MSG_RESULT(yes)
  else
    AC_MSG_RESULT(no - searching PATH)
  fi
fi
if test "X$XSLT_CONFIG" = "X"; then
  AC_CHECK_PROGS(XSLT_CONFIG, xslt-config)
fi

AC_ARG_WITH(curl-config, [  --with-curl-config=PATH   Location of libcurl curl-config []], curl_config="$withval", curl_config="")

if test "X$curl_config" != "X" ; then
  AC_MSG_CHECKING(for $curl_config)

  if test -f $curl_config ; then
    CURL_CONFIG=$curl_config
    AC_MSG_RESULT(yes)
  else
    AC_MSG_RESULT(no - searching PATH)
  fi
fi
if test "X$CURL_CONFIG" = "X"; then
  AC_CHECK_PROGS(CURL_CONFIG, curl-config)
fi


oLIBS="$LIBS"

AC_ARG_ENABLE(nfc-check, [  --disable-nfc-check        Turn off Unicode NFC checking (default enabled).  ], nfc_check="no", nfc_check="yes")	
AC_MSG_CHECKING(using Unicode NFC checking)
AC_MSG_RESULT($nfc_check);


AC_ARG_WITH(www-config, [  --with-libwww-config=PATH Location of W3C libwww libwww-config []], libwww_config="$withval", libwww_config="")

if test "X$libwww_config" != "X" ; then
  AC_MSG_CHECKING(for $libwww_config)

  if test -f $libwww_config ; then
    LIBWWW_CONFIG=$libwww_config
    AC_MSG_RESULT(yes)
  else
    AC_MSG_RESULT(no - searching PATH)
  fi
fi
if test "X$LIBWWW_CONFIG" = "X"; then
  AC_CHECK_PROGS(LIBWWW_CONFIG, libwww-config)
fi


have_libxml=0
have_libxml_lib=0
have_libxml_source=0
need_libxml=0
need_libxml_source=0
AC_MSG_CHECKING(for libxml sources)
if test -d $srcdir/libxml -a -r $srcdir/libxml/libxml.spec ; then
  have_libxml_source=1
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
fi

oCPPFLAGS="$CPPFLAGS"
oLIBS="$LIBS"
if test "X$XML_CONFIG" != X; then
  LIBS="$LIBS `$XML_CONFIG --libs`"
  AC_CHECK_FUNC(xmlCreatePushParserCtxt, have_xmlCreatePushParserCtxt=yes, have_xmlCreatePushParserCtxt=no)
  AC_MSG_CHECKING(for system (GNOME) libxml library)
  if test $have_xmlCreatePushParserCtxt = yes; then
    have_libxml_lib=1
    have_libxml=1
    CPPFLAGS="`$XML_CONFIG --cflags` $CPPFLAGS"
    LIBXML_VERSION=`$XML_CONFIG --version`
    libxml_version_dec=`echo $LIBXML_VERSION | awk -F. '{printf("%d\n", 10000*$1 + 100*$2 + $3)};'`
    libxml_min_version_dec=`echo $libxml_min_version | awk -F. '{printf("%d\n", 10000*$1 + 100*$2 + $3)};'`
    AC_MSG_RESULT(yes - version $LIBXML_VERSION)
    if test $libxml_version_dec -lt $libxml_min_version_dec; then
       AC_MSG_WARN(Using libxml $LIBXML_VERSION is unsupported - $libxml_min_version or newer required.)
       have_libxml_lib=0
       have_libxml=0
    fi
  else
    AC_MSG_RESULT(no)
  fi

  AC_CHECK_HEADERS(libxml/parser.h)
  AC_CHECK_HEADERS(libxml/hash.h libxml/xmlreader.h libxml/SAX2.h,,,
  [#ifdef HAVE_LIBXML_PARSER_H
#include <libxml/parser.h>
#endif
])

  if test "$ac_cv_header_libxml_parser_h" = no -a "$ac_cv_header_gnome_xml_parser_h" = no; then
    AC_MSG_WARN(libxml library found but not headers - disabling)
    have_libxml_lib=0
    have_libxml=0
  else
    AC_MSG_CHECKING(if libxml xmlEntity has name_length field)
    AC_TRY_LINK([
#ifdef HAVE_LIBXML_PARSER_H
#include <libxml/parser.h>
#endif
], [xmlEntity foo; foo.name_length=0],
                AC_MSG_RESULT(yes)
		AC_DEFINE(RAPTOR_LIBXML_ENTITY_NAME_LENGTH,1,[does libxml struct xmlEntity have a field name_length]),
		AC_MSG_RESULT(no))

    AC_MSG_CHECKING(if libxml xmlEntity has etype field)
    AC_TRY_LINK([
#ifdef HAVE_LIBXML_PARSER_H
#include <libxml/parser.h>
#endif
], [xmlEntity foo; foo.etype=0],
                AC_MSG_RESULT(yes)
		AC_DEFINE(RAPTOR_LIBXML_ENTITY_ETYPE, 1, [does libxml struct xmlEntity have a field etype]),
		AC_MSG_RESULT(no))

    AC_MSG_CHECKING(if libxml xmlSAXHandler has initialized field)
    AC_TRY_LINK([
#ifdef HAVE_LIBXML_PARSER_H
#include <libxml/parser.h>
#endif
], [xmlSAXHandler foo; foo.initialized=0],
                AC_MSG_RESULT(yes)
		AC_DEFINE(RAPTOR_LIBXML_XMLSAXHANDLER_INITIALIZED, 1, [does libxml xmlSAXHandler have initialized field]),
		AC_MSG_RESULT(no))

    AC_MSG_CHECKING(if libxml xmlSAXHandler has externalSubset field)
    AC_TRY_LINK([
#ifdef HAVE_LIBXML_PARSER_H
#include <libxml/parser.h>
#endif
], [xmlSAXHandler foo; foo.externalSubset=NULL],
                AC_MSG_RESULT(yes)
		AC_DEFINE(RAPTOR_LIBXML_XMLSAXHANDLER_EXTERNALSUBSET, 1, [does libxml xmlSAXHandler have externalSubset field]),
		AC_MSG_RESULT(no))

    AC_CHECK_FUNC(xmlUseNewParser, AC_DEFINE(RAPTOR_LIBXML_XMLUSENEWPARSER, 1, [does libxml have xmlUseNewParser]))
    AC_CHECK_FUNC(xmlSAX2InternalSubset, AC_DEFINE(RAPTOR_LIBXML_XMLSAX2INTERNALSUBSET, 1, [does libxml have xmlSAX2InternalSubset]))
  fi

fi
CPPFLAGS="$oCPPFLAGS"
LIBS="$oLIBS"


have_libxslt=0

oCPPFLAGS="$CPPFLAGS"
oLIBS="$LIBS"
if test "X$XSLT_CONFIG" != X; then
  LIBS="$LIBS `$XSLT_CONFIG --libs`"
  AC_CHECK_FUNC(xsltSaveResultToString, have_xsltSaveResultToString=yes, have_xsltSaveResultToString=no)
  AC_MSG_CHECKING(for system libxslt library)
  if test $have_xsltSaveResultToString = yes; then
    have_libxslt=1
    CPPFLAGS="`$XSLT_CONFIG --cflags` $CPPFLAGS"
    LIBXSLT_VERSION=`$XSLT_CONFIG --version`
    libxslt_version_dec=`echo $LIBXSLT_VERSION | awk -F. '{printf("%d\n", 10000*$1 + 100*$2 + $3)};'`
    libxslt_min_version_dec=`echo $libxslt_min_version | awk -F. '{printf("%d\n", 10000*$1 + 100*$2 + $3)};'`
    AC_MSG_RESULT(yes - version $LIBXSLT_VERSION)
    if test $libxslt_version_dec -lt $libxslt_min_version_dec; then
       AC_MSG_WARN(Using libxslt $LIBXSLT_VERSION is unsupported - $libxslt_min_version or newer required.)
       have_libxslt=0
    fi
  else
    AC_MSG_RESULT(no)
  fi

  AC_CHECK_HEADERS(libxslt/xslt.h)
  if test "$ac_cv_header_libxslt_xslt_h" = no ; then
    AC_MSG_WARN(libxslt library found but not headers - disabling)
    have_libxslt_lib=0
    have_libxslt=0
  fi
fi
CPPFLAGS="$oCPPFLAGS"
LIBS="$oLIBS"


AC_ARG_WITH(xml-parser, [  --with-xml-parser=NAME    Use XML parser - libxml (default), expat], xml_parser="$withval", xml_parser="libxml") 

for xml_parser_name in $xml_parser libxml expat; do
  case $xml_parser_name in
    expat)
      if test "$expat_source" != "auto"; then
	need_expat=1
	need_expat_source=1
      elif test $have_expat_lib = 1; then
	need_expat=1
      elif test $have_expat_source = 1; then
	need_expat=1
	need_expat_source=1
      fi
      if test $need_expat; then
	AC_DEFINE(RAPTOR_XML_EXPAT, 1, [Use expat XML parser])
        break
      fi
      ;;

    libxml)
      if test $have_libxml_lib = 1; then
	need_libxml=1
      elif test $have_libxml_source = 1; then
	need_libxml=1
	need_libxml_source=1
      fi
      if test $need_libxml; then
	AC_DEFINE(RAPTOR_XML_LIBXML, 1, [Use libxml XML parser])
        break
      fi
      ;;

    *)
      AC_MSG_ERROR(No such XML parser $xml_parser_name)
      ;;
esac
done

AM_CONDITIONAL(RAPTOR_XML_EXPAT, test $need_expat = 1)
AM_CONDITIONAL(RAPTOR_XML_LIBXML, test $need_libxml = 1)


AC_MSG_CHECKING(XML parser to use)
result=
if test $need_libxml = 1; then
  if test $need_libxml_source = 1; then
    result="$result libxml(source)"
  else
    result="$result libxml(system)"
  fi
elif test $need_expat = 1; then
  if test $need_expat_source = 1; then
    result="$result expat(source in $expat_source_dir)"
  else
    result="$result expat(system)"
  fi
else
  AC_MSG_ERROR(No XML parser available - please install expat or libxml)
fi
AC_MSG_RESULT($result)


dnl RDF Parsers
rdfxml_parser=no
ntriples_parser=no
turtle_parser=no
n3_parser=no
rss_parser=no
grddl_parser=no

rdf_parsers_available="rdfxml ntriples turtle"
if test "$USE_MAINTAINER_MODE" = yes; then
  rdf_parsers_available="$rdf_parsers_available n3"
fi
rdf_parsers_enabled=

rss_parser_ok=no
AC_MSG_CHECKING(RSS Tag Soup parser requirements)
if test $need_libxml = 1; then
  libxml_rss_min_version_dec=`echo $libxml_rss_min_version | awk -F. '{printf("%d\n", 10000*$1 + 100*$2 + $3)};'`
  if test $libxml_version_dec -ge $libxml_rss_min_version_dec; then
    AC_MSG_RESULT(yes - libxml2 $LIBXML_VERSION ok)
    rss_parser_ok=yes
    rdf_parsers_available="$rdf_parsers_available rss-tag-soup"
  else
    AC_MSG_RESULT(no - libxml2 $LIBXML_VERSION too old)
  fi
else
  AC_MSG_RESULT(no - libxml2 not available)
fi

grddl_parser_ok=no
AC_MSG_CHECKING(GRDDL parser requirements)
if test $need_libxml = 1 -a $have_libxslt = 1; then
  AC_MSG_RESULT(yes)
  grddl_parser_ok=yes
  rdf_parsers_available="$rdf_parsers_available grddl"
else
  AC_MSG_RESULT(no - libxml2 and libxslt are both not available)
fi


# This is needed because autoheader can't work out which computed
# symbols must be pulled from acconfig.h into config.h.in
if test "x" = "y"; then
  AC_DEFINE(RAPTOR_PARSER_RDFXML, 1, [Building RDF/XML parser])
  AC_DEFINE(RAPTOR_PARSER_NTRIPLES, 1, [Building N-Triples parser])
  AC_DEFINE(RAPTOR_PARSER_TURTLE, 1, [Building Turtle parser])
  AC_DEFINE(RAPTOR_PARSER_N3, 1, [Building Notation 3 parser])
  AC_DEFINE(RAPTOR_PARSER_RSS, 1, [Building RSS Tag Soup parser])
  AC_DEFINE(RAPTOR_PARSER_GRDDL, 1, [Building GRDDL parser])
fi

AC_MSG_CHECKING(RDF parsers required)
AC_ARG_ENABLE(parsers, [  --enable-parsers=LIST      Use RDF parsers (default=all)], parsers="$enableval") 
if test "X$parsers" = Xall -o "X$parsers" = X; then
  parsers="$rdf_parsers_available"
  AC_MSG_RESULT(all)
else
  AC_MSG_RESULT($parsers)
fi

for parser in $parsers; do
  p=$parser
  if test $p = rss-tag-soup; then
    if test $rss_parser_ok != yes; then
      AC_MSG_WARN(RSS tag soup parser is not available)
      continue
    fi
    p=rss
  fi

  if test $p = grddl; then
    if test $grddl_parser_ok != yes; then
      AC_MSG_WARN(GRDDL parser is not available)
      continue
    fi
  fi

  eval $p'_parser=yes'
  NAME=`echo $p | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
  n=RAPTOR_PARSER_${NAME}
  AC_DEFINE_UNQUOTED($n)
  rdf_parsers_enabled="$rdf_parsers_enabled $parser"
done

nfc_needed=no
if test $rdfxml_parser = yes; then
  nfc_needed=yes
fi

need_libxslt=0
if test $grddl_parser = yes; then
  need_libxslt=1
fi

AM_CONDITIONAL(RAPTOR_PARSER_RDFXML, test $rdfxml_parser = yes)
AM_CONDITIONAL(RAPTOR_PARSER_NTRIPLES, test $ntriples_parser = yes)
AM_CONDITIONAL(RAPTOR_PARSER_TURTLE, test $turtle_parser = yes)
AM_CONDITIONAL(RAPTOR_PARSER_N3, test $n3_parser = yes)
AM_CONDITIONAL(RAPTOR_PARSER_RSS, test $rss_parser = yes)
AM_CONDITIONAL(RAPTOR_PARSER_GRDDL, test $grddl_parser = yes)


dnl RDF Serializers
rdfxml_serializer=no
ntriples_serializer=no
rdfxml_abbrev_serializer=no

rdf_serializers_available="rdfxml rdfxml-abbrev ntriples"

# This is needed because autoheader can't work out which computed
# symbols must be pulled from acconfig.h into config.h.in
if test "x" = "y"; then
  AC_DEFINE(RAPTOR_SERIALIZER_RDFXML, 1, [Building RDF/XML serializer])
  AC_DEFINE(RAPTOR_SERIALIZER_NTRIPLES, 1, [Building N-Triples serializer])
  AC_DEFINE(RAPTOR_SERIALIZER_RDFXML_ABBREV, 1, [Building RDF/XML-abbreviated serializer])
fi

AC_MSG_CHECKING(RDF serializers required)
AC_ARG_ENABLE(serializers, [  --enable-serializers=LIST  Use RDF serializers (default=all)], serializers="$enableval") 
if test "X$serializers" = Xall -o "X$serializers" = X; then
  serializers="$rdf_serializers_available"
  AC_MSG_RESULT(all)
else
  AC_MSG_RESULT($serializers)
fi

for serializer in $serializers; do
  s=`echo $serializer | tr '-' '_'`

  eval $s'_serializer=yes'
  NAME=`echo $s | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
  n=RAPTOR_SERIALIZER_${NAME}
  AC_DEFINE_UNQUOTED($n)
  rdf_serializers_enabled="$rdf_serializers_enabled $serializer"
done

AM_CONDITIONAL(RAPTOR_SERIALIZER_RDFXML, test $rdfxml_serializer = yes)
AM_CONDITIONAL(RAPTOR_SERIALIZER_NTRIPLES, test $ntriples_serializer = yes)
AM_CONDITIONAL(RAPTOR_SERIALIZER_RDFXML_ABBREV, test $rdfxml_abbrev_serializer = yes)


dnl Enable NFC code only if needed and the check is enabled
if test $nfc_needed = yes; then
  if test $nfc_check != yes; then
    nfc_needed=no
  else
    AC_DEFINE([RAPTOR_NFC_CHECK], 1, [Provide a Unicode NFC check])
  fi
fi
AM_CONDITIONAL(RAPTOR_NFC_CHECK, test $nfc_needed = yes)



AC_MSG_CHECKING(XML names version)
AC_ARG_WITH(xml-names, [  --with-xml-names=1.1|1.0  Select XML version name checking (default=1.0)], xml_names="$withval", xml_names="1.0")
if test $xml_names = 1.1; then
  AC_DEFINE(RAPTOR_XML_1_1, 1, [Check XML 1.1 Names])
fi
AC_MSG_RESULT($xml_names)


have_libcurl=0
have_libwww=0
have_libfetch=0
need_libcurl=0
need_libxml_www=0
need_libwww=0
need_libfetch=0

oCPPFLAGS="$CPPFLAGS"
if test "X$CURL_CONFIG" != X; then
  oLIBS="$LIBS"
  LIBS="$LIBS `$CURL_CONFIG --libs`"
  AC_CHECK_FUNC(curl_easy_init, have_curl_easy_init=yes, have_curl_easy_init=no)
  LIBS="$oLIBS"
  AC_MSG_CHECKING(for libcurl library)
  if test $have_curl_easy_init = yes; then
    have_libcurl=1
    LIBCURL_VERSION=`$CURL_CONFIG --version | sed -e 's/^libcurl *//'`
    AC_MSG_RESULT(yes - version $LIBCURL_VERSION)
  else
    AC_MSG_RESULT(no)
  fi
fi


if test "X$LIBWWW_CONFIG" != X; then
  oLIBS="$LIBS"
  LIBS="$LIBS `$LIBWWW_CONFIG --libs`"
  AC_CHECK_FUNC(HTLibInit, have_libwww_htlibinit=yes, have_libwww_htlibinit=no)
  LIBS="$oLIBS"
  AC_MSG_CHECKING(for W3C libwww library)
  if test $have_libwww_htlibinit = yes; then
    have_libwww=1
    LIBWWW_VERSION=`$LIBWWW_CONFIG --version`
    AC_MSG_RESULT(yes - version $LIBWWW_VERSION)
  else
    AC_MSG_RESULT(no)
  fi
fi

if test $ac_cv_header_fetch_h = yes; then
  oLIBS="$LIBS"
  AC_CHECK_LIB(fetch, fetchXGetURL, have_libfetch=1)
  LIBS="$oLIBS"
fi


AC_ARG_WITH(www, [  --with-www=NAME           Use WWW library - curl (default), xml, libwww, libfetch, none], www="$withval", www="curl") 

for www_name in $www curl xml libwww libfetch none; do
  case $www_name in
    curl)
      if test $have_libcurl = 1; then
        need_libcurl=1
        AC_DEFINE([RAPTOR_WWW_LIBCURL], 1, [Have libcurl WWW library])
        break
      fi
      ;;

    xml)
      if test $have_libxml = 1; then
        need_libxml=1
        need_libxml_www=1
	AC_DEFINE([RAPTOR_WWW_LIBXML], 1, [Have libxml available as a WWW library])
        break
      fi
      ;;

    libwww)
      if test $have_libwww = 1; then
        need_libwww=1
	AC_DEFINE([RAPTOR_WWW_LIBWWW], 1, [Have W3C libwww WWW library])
        break
      fi
      ;;

    libfetch)
      if test $have_libfetch = 1; then
        need_libfetch=1
	AC_DEFINE([RAPTOR_WWW_LIBFETCH], 1, [Have libfetch WWW library])
        break
      fi
      ;;

    none)
      need_libcurl=0
      need_libxml_www=0
      need_libwww=0
      AC_DEFINE([RAPTOR_WWW_NONE], 1, [No WWW library])
      break
      ;;

    *)
      AC_MSG_ERROR(No such WWW library $www_name)
      ;;
esac
done

AC_MSG_CHECKING(WWW libraries available)
www_libraries_available=
if test $have_libcurl = 1; then
  www_libraries_available="$www_libraries_available libcurl $LIBCURL_VERSION"
fi
if test $have_libxml = 1; then
  if test $need_libxml_source = 1; then
    www_libraries_available="$www_libraries_available libxml(source)"
  else
    www_libraries_available="$www_libraries_available libxml(system $LIBXML_VERSION)"
  fi
fi
if test $have_libwww = 1; then
  www_libraries_available="$www_libraries_available libwww $LIBWWW_VERSION"
fi
if test $have_libfetch = 1; then
  www_libraries_available="$www_libraries_available libfetch"
fi
AC_MSG_RESULT($www_libraries_available)


AC_MSG_CHECKING(WWW library to use)
www_library=
if test $need_libcurl = 1; then
  www_library="libcurl $LIBCURL_VERSION"
elif test $need_libxml_www = 1; then
  if test $need_libxml_source = 1; then
    www_library="libxml(source)"
  else
    www_library="libxml(system $LIBXML_VERSION)"
  fi
elif test $need_libwww = 1; then
  www_library="libwww $LIBWWW_VERSION"
elif test $need_libfetch = 1; then
  www_library="libfetch"
else
  www_library=none
fi
AC_MSG_RESULT($www_library)
if test "X$www_library" = Xnone; then
  AC_MSG_WARN([No WWW library in use - only file: URLs will work])
  AC_MSG_WARN([Install libcurl, libxml2, W3C libwww or libfetch for WWW access])
fi


if test $need_libcurl = 1; then
  CPPFLAGS="$CPPFLAGS `$CURL_CONFIG --cflags`"
  LIBS="$LIBS `$CURL_CONFIG --libs`"
  AC_LIBOBJ(raptor_www_curl)
fi

if test $need_libwww = 1; then
  CPPFLAGS="$CPPFLAGS `$LIBWWW_CONFIG --cflags`"
  LIBS="$LIBS `$LIBWWW_CONFIG --libs`"
  AC_LIBOBJ(raptor_www_libwww)
fi

if test $need_libfetch = 1; then
  LIBS="$LIBS -lfetch"
  AC_LIBOBJ(raptor_www_libfetch)
fi


if test $need_libxml = 1; then

  if test $need_libxml_www = 1; then
    AC_LIBOBJ(raptor_www_libxml)
  fi
  if test $need_libxml_source = 1; then
    SD="$SD libxml"
    (cd libxml && ./configure --cache=../config.cache --enable-shared=no)
    CPPFLAGS="-I$srcdir/libxml $CPPFLAGS"
    LIBS="$LIBS -Llibxml -llibxml"
  else
    LIBS="$LIBS `$XML_CONFIG --libs`"
    CPPFLAGS="`$XML_CONFIG --cflags` $CPPFLAGS"
  fi
fi


if test $need_expat = 1; then
  if test $need_expat_source = 1; then
    # Only build local copy if it is needed
    if test "X$expat_source" = local; then
      SD="$SD expat"
    fi
    if test -d "$expat_source_dir/xmlparse"; then
      # old expat
      LIBS="$LIBS $expat_obj_dir/xmlparse/xmlparse.o $expat_obj_dir/xmlparse/hashtable.o $expat_obj_dir/xmltok/xmlrole.o $expat_obj_dir/xmltok/xmltok.o"
    else
      # new expat
      LIBS="$LIBS $expat_obj_dir/lib/xmlparse.o $expat_obj_dir/lib/xmlrole.o $expat_obj_dir/lib/xmltok.o"
    fi
  else
    LIBS="$LIBS $expat_libs"
  fi
fi

if test $need_libxslt = 1; then
  LIBS="$LIBS `$XSLT_CONFIG --libs`"
  CPPFLAGS="`$XSLT_CONFIG --cflags` $CPPFLAGS"
fi

RAPTOR_LIBTOOLLIBS=libraptor.la
AC_SUBST(RAPTOR_LIBTOOLLIBS)


xml_parsers_available=
if test $need_libxml = 1; then
  if test $need_libxml_source = 1; then
    xml_parsers_available="$xml_parsers_available libxml(source)"
  else
    xml_parsers_available="$xml_parsers_available libxml(system $LIBXML_VERSION)"
  fi
fi
if test $need_expat = 1; then
  if test $need_expat_source = 1; then
    xml_parsers_available="$xml_parsers_available expat(source in $expat_source_dir)"
  else
    if test $libexpat = 1; then
      xml_parsers_available="$xml_parsers_available expat(system libexpat)"
    else
      xml_parsers_available="$xml_parsers_available expat(system libxmlparse,libxmltok)"
    fi
  fi
fi


# Make final changes to cflags
MEM=
MEM_LIBS=
CPPFLAGS="-DRAPTOR_INTERNAL=1 $CPPFLAGS"
AC_ARG_WITH(dmalloc, [  --with-dmalloc            Use dmalloc debugging library (default=no)], use_dmalloc="$withval", use_dmalloc="no") 
AC_MSG_CHECKING(using dmalloc library)
if test "$USE_MAINTAINER_MODE" = yes; then
  if test "$ac_cv_header_dmalloc_h" = yes; then
    if test "X$use_dmalloc" = Xauto; then
      use_dmalloc=yes
    fi
  else
    use_dmalloc=no
  fi
  CPPFLAGS="-g -DRAPTOR_DEBUG=1 $CPPFLAGS"
else
  use_dmalloc=no
fi
AC_MSG_RESULT($use_dmalloc);
if test $use_dmalloc = yes; then
  MEM=-DRAPTOR_MEMORY_DEBUG_DMALLOC=1
  MEM_LIBS=-ldmalloc
fi
AC_ARG_WITH(memory-signing, [  --with-memory-signing     Sign allocated memory (default=no)], use_memory_signing="$withval", use_memory_signing="no") 
AC_MSG_CHECKING(using memory signing)
AC_MSG_RESULT($use_memory_signing);
if test $use_memory_signing = yes; then
  MEM=-DRAPTOR_MEMORY_SIGN=1
  MEM_LIBS=
fi

STANDARD_CFLAGS="$STANDARD_CFLAGS $CFLAGS"
if test "$USE_MAINTAINER_MODE" = yes; then
  CFLAGS="$MAINTAINER_CFLAGS $CFLAGS"
fi

AC_SUBST(MEM)
AC_SUBST(MEM_LIBS)
AC_SUBST(STANDARD_CFLAGS)

ECHO_N="$ECHO_N"
ECHO_C="$ECHO_C"
AC_SUBST(ECHO_N)
AC_SUBST(ECHO_C)

abs_top_srcdir=`cd $srcdir; pwd`
AC_SUBST(abs_top_srcdir)
abs_top_builddir=`pwd`
AC_SUBST(abs_top_builddir)

AC_CONFIG_FILES([Makefile
raptor.spec
raptor.rdf
examples/Makefile
tests/Makefile
tests/turtle/Makefile
win32/Makefile
raptor.pc])
AC_CONFIG_FILES([raptor-config], [chmod +x raptor-config])
AC_CONFIG_FILES([raptor-src-config], [chmod +x raptor-src-config])

AC_OUTPUT

AC_MSG_RESULT([
Raptor build summary:
  RDF parsers available     : $rdf_parsers_available
  RDF parsers enabled       :$rdf_parsers_enabled
  RDF serializers available : $rdf_serializers_available
  RDF serializers enabled   :$rdf_serializers_enabled
  XML parser                :$xml_parsers_available
  WWW library               : $www_library
])