File: configure.in

package info (click to toggle)
frama-c 20140301%2Bneon%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 19,548 kB
  • ctags: 28,183
  • sloc: ml: 181,252; ansic: 13,776; makefile: 2,452; sh: 1,085; lisp: 178
file content (1163 lines) | stat: -rw-r--r-- 36,208 bytes parent folder | download
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
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
##########################################################################
#                                                                        #
#  This file is part of Frama-C.                                         #
#                                                                        #
#  Copyright (C) 2007-2014                                               #
#    CEA   (Commissariat à l'énergie atomique et aux énergies            #
#           alternatives)                                                #
#    INRIA (Institut National de Recherche en Informatique et en         #
#           Automatique)                                                 #
#                                                                        #
#  you can redistribute it and/or modify it under the terms of the GNU   #
#  Lesser General Public License as published by the Free Software       #
#  Foundation, version 2.1.                                              #
#                                                                        #
#  It is distributed in the hope that it will be useful,                 #
#  but WITHOUT ANY WARRANTY; without even the implied warranty of        #
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         #
#  GNU Lesser General Public License for more details.                   #
#                                                                        #
#  See the GNU Lesser General Public License version 2.1                 #
#  for more details (enclosed in the file licenses/LGPLv2.1).            #
#                                                                        #
##########################################################################

# autoconf input for Objective Caml programs
# Copyright (C) 2001 Jean-Christophe Fillitre
#   from a first script by Georges Mariano

# the script generated by autoconf from this input will set the following
# variables:
#   OCAMLC        "ocamlc" if present in the path, or a failure
#                 or "ocamlc.opt" if present with same version number as ocamlc
#   OCAMLOPT      "ocamlopt" (or "ocamlopt.opt" if present), or "no"
#   OCAMLBEST     either "byte" if no native compiler was found,
#                 or "opt" otherwise
#   OCAMLDEP      "ocamldep"
#   OCAMLLEX      "ocamllex" (or "ocamllex.opt" if present)
#   OCAMLYACC     "ocamlyacc"
#   OCAMLLIB      the path to the ocaml standard library
#   OCAMLVERSION  the ocaml version number
#   OCAMLWIN32    "yes"/"no" depending on Sys.os_type = "Win32"
#   EXE           ".exe" if OCAMLWIN32=yes, "" otherwise

AC_INIT(src/kernel)

define([FRAMAC_MAIN_AUTOCONF])
m4_include(share/configure.ac)

AC_SUBST([FRAMAC_VERSION],[`cat VERSION`])

# export CYGWIN=nobinmode

##########################
# Check for Make version #
##########################

new_section "configure make"

AC_CHECK_PROG(MAKE,make,make,)
AC_MSG_CHECKING([version of make])
MAKE_DISTRIB=`sh -c "$MAKE -v | sed -n -e 's/\(.*\) Make.*$/\1/p'"`
MAKE_MAJOR=`sh -c "$MAKE -v | sed -n  -f bin/sed_get_make_major"`
MAKE_MINOR=`sh -c "$MAKE -v | sed -n -f bin/sed_get_make_minor"`
AC_MSG_RESULT($MAKE_MAJOR.$MAKE_MINOR)
if test "$MAKE_DISTRIB" != GNU -o "$MAKE_MAJOR" -lt 3 \
   -o "$MAKE_MAJOR" = 3 -a "$MAKE_MINOR" -lt 81
then
   AC_MSG_ERROR([unsupported version; GNU Make version 3.81
                 or higher is required.]);
fi

# verbosemake feature
AC_ARG_ENABLE(
  verbosemake,
  [  --enable-verbosemake    verbose makefile commands],
  VERBOSEMAKE=$enableval,
  VERBOSEMAKE=no
)

if test "$VERBOSEMAKE" = yes ; then
  AC_MSG_RESULT(Make will be verbose.)
fi

#############################
# Check for Ocaml compilers #
#############################

# Specifically allow 3.10.0
UNSUPPORTED_OCAML=no
AC_ARG_ENABLE(
  unsupported-ocaml,
  [  --enable-unsupported-ocaml attempt to compile even against unsupported ocaml version],
  UNSUPPORTED_OCAML=$enableval,
  UNSUPPORTED_OCAML=no)

new_section "configure ocaml compilers"

# we first look for ocamlc in the path; if not present, we fail
AC_CHECK_PROG(OCAMLC,ocamlc,ocamlc,no)
if test "$OCAMLC" = no ; then
        AC_MSG_ERROR(Cannot find ocamlc.)
fi

# Let user shoot himself in the foot if he so wishes
warn_or_die () {
if test "$UNSUPPORTED_OCAML" = "yes"; then
  echo "Compile at your own risks";
else
  echo "If you want to compile Frama-C with this version, use the \
--enable-unsupported-ocaml option of configure";
  exit 2;
fi
}

# we extract Ocaml version number and library path
# "sed -n" is the posix version of "sed --quiet"
AC_MSG_CHECKING([version of OCaml])
OCAMLVERSION=`$OCAMLC -v | sed -n -e 's|.*version *\(.*\)$|\1|p' `
AC_MSG_RESULT($OCAMLVERSION)
case $OCAMLVERSION in
  3.12.1*) OCAML_ANNOT_OPTION="-annot";;
  3.0*) echo "${ECHO_T}Incompatible version! Use at least OCaml 3.12.1.";
        exit 2;;
  3.10*) echo "${ECHO_T}Incompatible version! Use at least OCaml 3.12.1.";
         exit 2;;
  3.11*) echo "${ECHO_T}Incompatible version! Use at least OCaml 3.12.1.";
         exit 2;;
  3.12.0*) echo "${ECHO_T}Incompatible version! Use at least OCaml 3.12.1.";
           exit 2;;
  4.*) OCAML_ANNOT_OPTION="-annot -bin-annot";;
  *) echo "${ECHO_T}Incompatible version!"; exit 2;;
esac

# Ocaml library path
AC_MSG_CHECKING(OCaml library path)
OCAMLLIB=`$OCAMLC -where | tr -d '\\r'`
AC_MSG_RESULT($OCAMLLIB)

# then we look for ocamlopt; if not present, we issue a warning
# if the version or the stdlib directory is not the same, we also discard it
# we set OCAMLBEST to "opt" or "byte", whether ocamlopt is available or not
AC_CHECK_PROG(OCAMLOPT,ocamlopt,ocamlopt,no)
OCAMLBEST=byte
if test "$OCAMLOPT" = no ; then
        AC_MSG_WARN(Cannot find ocamlopt; bytecode compilation only.)
else
        AC_MSG_CHECKING(ocamlopt version and standard library)
        TMPVERSION=`$OCAMLOPT -v | sed -n -e 's|.*version *\(.*\)$|\1|p'`
        if test "$TMPVERSION" != "$OCAMLVERSION" \
                -o `$OCAMLOPT -where | tr -d '\\r'` != "$OCAMLLIB"; then
            AC_MSG_RESULT(differs from ocamlc; ocamlopt discarded.)
            OCAMLOPT=no
        else
            AC_MSG_RESULT(ok)
            OCAMLBEST=opt
        fi
fi

if test "$OCAMLBEST" = "opt"; then
   LIB_SUFFIX=cmxa
   OBJ_SUFFIX=cmx;
else
   LIB_SUFFIX=cma
   OBJ_SUFFIX=cmo;
fi

# checking for ocamlc.opt
AC_CHECK_PROG(OCAMLCDOTOPT,ocamlc.opt,ocamlc.opt,no)
if test "$OCAMLCDOTOPT" != no ; then
        AC_MSG_CHECKING(ocamlc.opt version and standard library)
        TMPVERSION=`$OCAMLCDOTOPT -v | sed -n -e 's|.*version *\(.*\)$|\1|p' `
        if test "$TMPVERSION" != "$OCAMLVERSION" \
                -o `$OCAMLCDOTOPT -where | tr -d '\\r'` != "$OCAMLLIB"; then
            AC_MSG_RESULT(differs from ocamlc; ocamlc.opt discarded.)
        else
            AC_MSG_RESULT(ok)
            OCAMLC=$OCAMLCDOTOPT
        fi
fi

# checking for ocamlopt.opt
if test "$OCAMLOPT" != no ; then
    AC_CHECK_PROG(OCAMLOPTDOTOPT,ocamlopt.opt,ocamlopt.opt,no)
    if test "$OCAMLOPTDOTOPT" != no ; then
        AC_MSG_CHECKING(ocamlc.opt version and standard library)
        TMPVER=`$OCAMLOPTDOTOPT -v | sed -n -e 's|.*version *\(.*\)$|\1|p' `
        if test "$TMPVER" != "$OCAMLVERSION" \
                -o `$OCAMLOPTDOTOPT -where | tr -d '\\r'` != "$OCAMLLIB"; then
            AC_MSG_RESULT(differs from ocamlc; ocamlopt.opt discarded.)
        else
            AC_MSG_RESULT(ok)
            OCAMLOPT=$OCAMLOPTDOTOPT
        fi
    fi
fi

##############################################
# Check for other mandatory tools/libraries #
##############################################

new_section "configure mandatory tools and libraries"

# ocamldep
AC_CHECK_PROG(OCAMLDEP,ocamldep,ocamldep,no)
if test "$OCAMLDEP" = no ; then
        AC_MSG_ERROR(Cannot find ocamldep.)
else
    AC_CHECK_PROG(OCAMLDEPDOTOPT,ocamldep.opt,ocamldep.opt,no)
    if test "$OCAMLDEPDOTOPT" != no ; then
        OCAMLDEP=$OCAMLDEPDOTOPT
    fi
fi

# ocamllex
AC_CHECK_PROG(OCAMLLEX,ocamllex,ocamllex,no)
if test "$OCAMLLEX" = no ; then
    AC_MSG_ERROR(Cannot find ocamllex.)
else
    AC_CHECK_PROG(OCAMLLEXDOTOPT,ocamllex.opt,ocamllex.opt,no)
    if test "$OCAMLLEXDOTOPT" != no ; then
        OCAMLLEX=$OCAMLLEXDOTOPT
    fi
fi

# ocamlyacc
AC_CHECK_PROG(OCAMLYACC,ocamlyacc,ocamlyacc,no)
if test "$OCAMLYACC" = no ; then
        AC_MSG_ERROR(Cannot find ocamlyacc.)
fi


#################################################
# Check for other (optional) tools/libraries    #
#################################################

new_section "configure optional tools and libraries"

AC_CHECK_PROG(OCAMLDOC,ocamldoc,ocamldoc,no)
if test "$OCAMLDOC" = no ; then
  AC_MSG_RESULT(ocamldoc discarded not present)
else
  AC_CHECK_PROG(OCAMLDOCOPT,ocamldoc.opt,ocamldoc.opt,no)
  # Strange quantic segfault with native ocamldoc in version 4.00.0
  if test "$OCAMLDOCOPT" != no -a "$OCAMLVERSION" != 4.00.0; then
     OCAMLDOC=$OCAMLDOCOPT;
  fi
fi

AC_CHECK_PROG(OCAMLMKTOP,ocamlmktop,ocamlmktop,no)
if test "$OCAMLMKTOP" = no ; then
  AC_MSG_RESULT(Cannot find ocamlmktop: toplevels cannot be built.)
fi

# ocamlcp
AC_CHECK_PROG(OCAMLCP,ocamlcp,ocamlcp,no)
if test "$OCAMLCP" = no ; then
  AC_MSG_ERROR(Cannot find ocamlcp.)
fi

AC_CHECK_PROG(OTAGS,otags,otags,)

AC_CHECK_PROG(OCAMLFIND,ocamlfind,ocamlfind,no)
if test "$OCAMLFIND" = "no" ; then
   echo "No ocamlfind detected"
else
   OCAMLLIB_BY_FINDLIB=`ocamlfind printconf stdlib | tr -d '\\r'`
   if test "$OCAMLLIB_BY_FINDLIB" = "$OCAMLLIB" ; then
      echo "OCamlfind detected and enabled"
   else
      echo "OCamlfind detected but disabled. Standard libraries differ:"
      echo "  ocamlc: '$OCAMLLIB'"
      echo "  ocamlfind: '$OCAMLLIB_BY_FINDLIB'"
      OCAMLFIND="no"
   fi
fi

##############
# ocamlgraph #
##############

OCAMLGRAPH_LOCAL=""
OCAMLGRAPH_HOME=$OCAMLLIB/ocamlgraph
OCAMLGRAPH_EXISTS=no
OCAMLGRAPH_INCLUDE=
OCAMLGRAPH_CUSTOM=no

AC_ARG_WITH(
        ocamlgraph,
        AC_HELP_STRING(
        [--with-ocamlgraph],
        [set the directory where ocamlgraph library is to be found
         (default: search through ocamlfind or in OCaml standard library)]),
        [OCAMLGRAPH_HOME=$withval
         OCAMLGRAPH_CUSTOM=yes],
        [])

if test "$OCAMLFIND" = "no" -o "$OCAMLGRAPH_CUSTOM" = "yes"; then

# check if any ocamlgraph is installed in the right place
  AC_CHECK_FILE($OCAMLGRAPH_HOME/graph.$OBJ_SUFFIX,
              OCAMLGRAPH_EXISTS="yes" OCAMLGRAPH_INCLUDE="-I +ocamlgraph")

  if test "$OCAMLGRAPH_EXISTS"="no" -a "$OCAMLGRAPH_CUSTOM" = "yes"; then
    AC_MSG_ERROR(
     [unable to find OCamlGraph in custom location $OCAMLGRAPH_HOME.
      Please give an appropriate value, or use default OCamlGraph library]);
  fi
else
  OCAMLGRAPH_HOME=$($OCAMLFIND query ocamlgraph 2>/dev/null \
                          | tr -d '\r\n');
  if test "$OCAMLGRAPH_HOME" != ""; then
     OCAMLGRAPH_INCLUDE="-I $OCAMLGRAPH_HOME";
     OCAMLGRAPH_EXISTS="yes";
  else
     AC_MSG_NOTICE(no package ocamlgraph in ocamlfind)
  fi;
fi

ocamlgraph_error() {
  if test "$OCAMLGRAPH_CUSTOM" = "yes"; then
  AC_MSG_ERROR(
   [Custom OCamlGraph library version $OCAMLGRAPH_VERSION is incompatible with
    Frama-C. Please provide another location or use default OCamlGraph]);
  else
  AC_MSG_NOTICE([OcamlGraph $OCAMLGRAPH_VERSION is incompatible with Frama-C.])
  OCAMLGRAPH_EXISTS=no
  OCAMLGRAPH_INCLUDE=
  :;
  fi
}

# if any, check if it is a compatible version
if test "$OCAMLGRAPH_EXISTS" = "yes"; then
  test_ocamlgraph_version='print_string Graph.Version.version;;'
  echo $test_ocamlgraph_version > test_ocamlgraph.ml
  if $OCAMLC -o test_ocamlgraph $OCAMLGRAPH_INCLUDE graph.cmo \
       test_ocamlgraph.ml 2> /dev/null; \
  then
    OCAMLGRAPH_VERSION=`./test_ocamlgraph`
    case $OCAMLGRAPH_VERSION in
    1.8.1) ocamlgraph_error;;
    1.8.2) ocamlgraph_error;;
    1.8.3) ocamlgraph_error;;
    1.8.4) AC_MSG_NOTICE([OcamlGraph $OCAMLGRAPH_VERSION found: great!]);;
    1.8.*) AC_MSG_NOTICE(
      [OcamlGraph $OCAMLGRAPH_VERSION > 1.8.4 found: should be compatible, but no warranty. Use it at your own risk!]);;
    *) ocamlgraph_error;;
    esac
    if test "$OCAMLGRAPH_EXISTS" = "yes"; then # current version is ok
      if test "$OCAMLBEST" = "opt"; then 
        if $OCAMLOPT -o test_ocamlgraph $OCAMLGRAPH_INCLUDE graph.cmxa \
          test_ocamlgraph.ml 2> /dev/null; \
        then
          AC_MSG_NOTICE([OcamlGraph native version is ok])
        else
          AC_MSG_NOTICE([OcamlGraph native version is not ok])
          ocamlgraph_error
        fi
      else
        echo "Upstream .oO(I'm too lazy to write a test for the pure bytecode case)"
      fi
    fi
  else
    ocamlgraph_error
  fi
  rm -f test_ocamlgraph test_ocamlgraph.ml test_ocamlgraph.cm*
fi

# allow local ocamlgraph
AC_ARG_ENABLE(
  local-ocamlgraph,
  [  --enable-local-ocamlgraph    allow the user to use the local OcamlGraph version],
  ENABLE_LOCAL_OCAMLGRAPH=$enableval,
  ENABLE_LOCAL_OCAMLGRAPH=yes, # default value
)

# revert back to local version of ocamlgraph
if test "$OCAMLGRAPH_EXISTS" = "no"; then
  if test "$ENABLE_LOCAL_OCAMLGRAPH" = "yes"; then
    AC_MSG_NOTICE([switching to OcamlGraph provided by Frama-C])
    OCAMLGRAPH_LOCAL=ocamlgraph
    OCAMLGRAPH_HOME=

    AC_CHECK_FILE($OCAMLGRAPH_LOCAL,OCAMLGRAPH_EXISTS=yes)
    if test "$OCAMLGRAPH_EXISTS" = "no"; then
      AC_CHECK_FILE(ocamlgraph.tar.gz,OCAMLGRAPH_EXISTS=yes)
      if test "$OCAMLGRAPH_EXISTS" = "yes"; then
        # ocamlgraph.tar.gz exists, but no directory ocamlgraph
        AC_MSG_NOTICE([unarchiving ocamlgraph.tar.gz])
        tar zxf ocamlgraph.tar.gz
      else
        # neither directory ocamlgraph, nor ocamlgraph.tar.gz exists
        # broken distrib indeed
        AC_MSG_ERROR([cannot find OcamlGraph in the current directory.
   Quite strange: would your Frama-C distribution be corrupted?
   Anyway:
   1. download the latest version from http://ocamlgraph.lri.fr/download
   2. install it by './configure && make && make install'
   3. rerun ./configure here])
      fi
    else
      AC_CHECK_FILE(ocamlgraph.tar.gz,OCAMLGRAPH_TAR=yes)
      if test "$OCAMLGRAPH_TAR" = "yes"; then
        # both directory ocamlgraph and ocamlgraph.tar.gz exist at the same time
        # untar only if the tar is newer than the directory
        if test ocamlgraph.tar.gz -nt ocamlgraph; then
          AC_MSG_NOTICE([find a newer OcamlGraph version: OcamlGraph updated!])
          rm -rf ocamlgraph
          tar zxf ocamlgraph.tar.gz
        fi
      fi
    fi

    # Anyway reconfigure OcamlGraph while reconfiguring Frama-C
    AC_MSG_NOTICE([configuring ocamlgraph...])
    (cd $OCAMLGRAPH_LOCAL && ./configure > /dev/null)
  else # --disable-local-ocamlgraph
    AC_MSG_ERROR([cannot find a compatible OCamlGraph version on your system \
and usage of local version explicitely prohibited by \
--disable-local-ocamlgraph option.
Please consider allowing local compilation of ocamlgraph \
or use --with-ocamlgraph to explicitely \
point to an appropriate installation directory.])
  fi
fi

# zarith
########

AC_ARG_ENABLE(
  zarith,
  [  --enable-zarith=<dir> use ZArith library],
  ZARITH_PATH=$enableval,)

if test -z "$ZARITH_PATH"; then
  # standard installation procedure of zarith diverges according to
  # ocamlfind installation (see zarith's README)
  if test "$OCAMLFIND" = no ; then
    ZARITH_PATH=$OCAMLLIB
    AC_CHECK_FILE($ZARITH_PATH/zarith.$LIB_SUFFIX,HAS_ZARITH=yes,HAS_ZARITH=no)
  else
    ZARITH_PATH=$($OCAMLFIND query zarith 2>/dev/null | tr -d '\r\n')
    if test -z "$ZARITH_PATH"; then
      HAS_ZARITH="no";
    else
      HAS_ZARITH="yes";
    fi;
  fi
  if test "$HAS_ZARITH" = "no"; then
    AC_MSG_WARN(Zarith not found: will use the default less efficient library instead)
  fi
else
  AC_CHECK_FILE($ZARITH_PATH/zarith.$LIB_SUFFIX,HAS_ZARITH=yes,HAS_ZARITH=no)
  if test "$HAS_ZARITH" = "no"; then
    AC_MSG_ERROR(Zarith: file $ZARITH_PATH/zarith.$LIB_SUFFIX not found.)
  fi
fi

############
# Platform #
############

new_section "configure platform"

AC_MSG_CHECKING(platform)
# get Sys.os_type as OCAML_OS_TYPE
echo "let () = print_string Sys.os_type;;" > test_os_type.ml
$OCAMLC -o test_os_type test_os_type.ml
OCAML_OS_TYPE=$(./test_os_type)
rm -f test_os_type.cmi  test_os_type.cmo  test_os_type.ml test_os_type

if test "$OCAML_OS_TYPE" = "Win32"; then
  AC_MSG_RESULT(Win32)
  AC_CHECK_PROG(CYGPATH,cygpath,cygpath,no)
  OCAMLWIN32=yes
  EXE=.exe
  # OCaml on Win32 does not support vmthreads, use native ones.
  HAS_NATIVE_THREADS=yes
else
  OCAMLWIN32=no
  if test "$OCAML_OS_TYPE" = "Cygwin"; then
    AC_MSG_RESULT(Cygwin)
    EXE=.exe
  else
    AC_MSG_RESULT(Unix)
    EXE=
  fi

  # OCaml native threads
  AC_MSG_CHECKING([OCaml native threads])
  echo "let f = Thread.create (fun () -> ())" > test_native_threads.ml
  if ($OCAMLOPT -thread -o test_native_threads unix.cmxa threads.cmxa \
      test_native_threads.ml) 2> /dev/null ; \
  then
    HAS_NATIVE_THREADS=yes
    AC_MSG_RESULT([ok.])
  else
    HAS_NATIVE_THREADS=no
    AC_MSG_WARN([unsupported.])
  fi
  rm -f test_native_threads*
fi

# C and POSIX standard headers used by C bindings.
AC_LANG([C])

AC_ARG_WITH(cc,[specifies a custom C compiler and pre-processor],[CC=$withval])

AC_PROG_CC

AC_CHECK_HEADERS(stdlib.h)
AC_CHECK_HEADERS(assert.h)
AC_CHECK_HEADERS(float.h)
AC_CHECK_HEADERS(math.h)

AC_CHECK_HEADERS(signal.h)

AC_CHECK_HEADERS(unistd.h)

# Local machdep feature (to generate new platforms)

if test "$LOCAL_MACHDEP" = yes ; then

AC_CONFIG_HEADER(config.h)
AC_CHECK_HEADERS(wchar.h)

# Find out the true definitions of some integer types
# checkIntegerype(size_t) will echo "int" or "long"
checkIntegerType() {
  fn="testtype.c"
  fo="testtype.o"
  for t in "int" "unsigned int" "long" "unsigned long" "short" "unsigned short" "char" "unsigned  char" ;do
     echo "#include <stddef.h>" >$fn
     echo "#include <wchar.h>" >>$fn
     # We define a prototype with one type and the function with
     # another type. This will result in compilation error
     # unless the types are really identical
     echo "$t foo($t x);"      >>$fn
     echo "$1 foo($1 x) { return x;}" >>$fn
     if gcc -c $fn 2>/dev/null ;then
        # Found it
        echo $t
        rm -f $fn $fo
        return
     fi
  done
  rm -f $fn $fo
}

AC_MSG_CHECKING([definition of size_t])
TYPE_SIZE_T=`checkIntegerType "size_t"`
if test "x$TYPE_SIZE_T" = "x" ;then
  AC_MSG_ERROR([Cannot find definition of size_t])
fi
AC_DEFINE_UNQUOTED(TYPE_SIZE_T, "$TYPE_SIZE_T")
AC_MSG_RESULT([$TYPE_SIZE_T])

AC_MSG_CHECKING([definition of wchar_t])
TYPE_WCHAR_T=`checkIntegerType "wchar_t"`
if test "x$TYPE_WCHAR_T" = "x" ;then
  AC_MSG_ERROR([Cannot find definition of wchar_t])
fi
AC_DEFINE_UNQUOTED(TYPE_WCHAR_T, "$TYPE_WCHAR_T")
AC_MSG_RESULT([$TYPE_WCHAR_T])

AC_MSG_CHECKING([definition of ptrdiff_t])
TYPE_PTRDIFF_T=`checkIntegerType "ptrdiff_t"`
if test "x$TYPE_PTRDIFF_T" = "x" ;then
  AC_MSG_ERROR([Cannot find definition of ptrdiff_t])
fi
AC_DEFINE_UNQUOTED(TYPE_PTRDIFF_T, "$TYPE_PTRDIFF_T")
AC_MSG_RESULT([$TYPE_PTRDIFF_T])

AC_MSG_CHECKING([for gcc version])
AC_CHECK_TYPE(__builtin_va_list,
              HAVE_BUILTIN_VA_LIST=true,
              HAVE_BUILTIN_VA_LIST=false)
AC_MSG_CHECKING([if __thread is a keyword])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(int __thread) { return 0; }])],
                  THREAD_IS_KEYWORD=false,
                  THREAD_IS_KEYWORD=true)
AC_MSG_RESULT($THREAD_IS_KEYWORD)

# Does gcc add underscores to identifiers to make assembly labels?
# (I think MSVC always does)
AC_MSG_CHECKING([if gcc adds underscores to assembly labels.])
AC_LINK_IFELSE([AC_LANG_SOURCE([int main() { __asm__("jmp _main"); }])],
                  UNDERSCORE_NAME=true,
                  UNDERSCORE_NAME=false)
AC_MSG_RESULT($UNDERSCORE_NAME)

fi # local machdep configuration

###################################
# Frama-C's pre-processor support #
###################################

# mcpp support. Very experimental

AC_ARG_ENABLE(
  mcpp,
  [  --enable-mcpp           use Frama-C's mcpp], #' making emacs mode happy
  FC_MCPP=$enableval,
  FC_MCPP=no)

if test "$FC_MCPP" = yes ; then
new_section "configure Frama-C-mcpp"
(cd mcpp ; ./configure --prefix=$prefix --datarootdir=$datarootdir \
        --exec_prefix=$exec_prefix --bindir=$bindir --libdir=$datadir/frama-c \
        --host=$host --build=$build --mandir=$mandir > /dev/null \
      || \
      AC_MSG_ERROR([cannot configure Frama-C-mcpp]))
FRAMAC_DEFAULT_CPP="frama-c-mcpp$EXE -C -I- -I$datadir/frama-c/libc -I."
fi

# Specific preprocessor support
AC_ARG_WITH(
        cpp,
        [  --with-cpp             customize defaut preprocessor for Frama-C],
        [FRAMAC_DEFAULT_CPP=$withval],
        [FRAMAC_DEFAULT_CPP=])

if test "$FC_MCPP" = no; then
# if no specific pre-processor has been given, check whether we can use
# $CC. Note that we want to keep comments in the output, so that AC_PROG_CPP
# alone is not sufficient.
  if test -z "$FRAMAC_DEFAULT_CPP"; then
# We should use AC_CHECK_PROG_CPP, but then we would end up with a slightly
# different command line than before for pre-processing (swapping -C and -E)
# and since we have the brilliant idea to put this command line in our 
# test oracles, changing that would be painful.
    CPP=$CC
    CPPFLAGS="-C -E -I.";
  else
    CPP=$FRAMAC_DEFAULT_CPP;
    CPPFLAGS=
  fi
  AC_PREPROC_IFELSE(
    [AC_LANG_SOURCE([/* Check whether comments are kept in output */])],
    [if grep -e kept conftest.i; then
      FRAMAC_DEFAULT_CPP="$CPP $CPPFLAGS";
      DEFAULT_CPP_KEEP_COMMENTS=true;
     else
      AC_MSG_WARN([Default pre-processing command '$CPP' do not preserve
                   comments. Please use define an appropriate pre-processor 
                   with --with-cpp, or you will only be able to use ACSL
                   annotations in already pre-processed files])
      FRAMAC_DEFAULT_CPP=$CPP;
      DEFAULT_CPP_KEEP_COMMENTS=false;
     fi],
     [AC_MSG_WARN([Unable to find a working pre-processor.
                   Please define one with --with-cpp, or you will be able
                   to launch Frama-C only on pre-processed files])];
      FRAMAC_DEFAULT_CPP="";
      DEFAULT_CPP_KEEP_COMMENTS=false;
    )
fi # test FC_MCPP

AC_MSG_RESULT(Default preprocessor is '$FRAMAC_DEFAULT_CPP'.)

#################
# Plugin wished #
#################

new_section "wished frama-c plug-ins"

# Option -with-all-static
#######################

define([ALL_STATIC_HELP],
       AC_HELP_STRING([--with-all-static],
                      [link all plug-ins statically (default: no)]))
AC_ARG_WITH(all-static,ALL_STATIC_HELP,IS_ALL_STATIC=$withval)

# Option -with-no-plugin
#######################

define([NO_PLUGIN_HELP],
       AC_HELP_STRING([--with-no-plugin],
                      [disable all plug-ins (default: no)]))

AC_ARG_WITH(no-plugin,NO_PLUGIN_HELP,[ONLY_KERNEL=$withval],[ONLY_KERNEL=no])

# library declarations
######################

# REQUIRE_LIBRARY: library *must* be present in order to build plugins
# USE_LIBRARY: better for plugins if library is present, but not required
# HAS_LIBRARY: is the library available?

REQUIRE_LABLGTK=
USE_LABLGTK=
HAS_LABLGTK=

REQUIRE_NATIVE_DYNLINK=
USE_NATIVE_DYNLINK=
HAS_NATIVE_DYNLINK=uncheck

# Tool declarations
####################

DOT=
REQUIRE_DOT=
USE_DOT=
HAS_DOT=

### Now plugin declarations

PLUGINS_FORCE_LIST=

###############################################################################
#                                                                             #
####################                                                          #
# Plug-in sections #                                                          #
####################                                                          #
#                                                                             #
# For 'internal' developpers:                                                 #
# Add your own plug-in here                                                   #
#                                                                             #
###############################################################################

# constant propagation
######################

check_plugin(semantic_constant_folding, src/constant_propagation,
             [support for constant propagation plugin], yes, no)

plugin_require(semantic_constant_folding,value_analysis)

# from
######

check_plugin(from_analysis,src/from,[support for from analysis],yes,no)

plugin_require(from_analysis,value_analysis)
plugin_require(from_analysis,semantic_callgraph)

# gui
#####

check_plugin(gui,src/gui,[support for gui],yes,no)

plugin_require_external(gui,lablgtk)
plugin_require_external(gui,gnomecanvas)
plugin_use_external(gui,dot)

# impact
########

check_plugin(impact,src/impact,[support for impact plugin],yes,no)

plugin_use(impact,gui)
plugin_use(impact,slicing)
plugin_require(impact,pdg)
plugin_require(impact,value_analysis)
plugin_require(impact,inout)

# inout
#######

check_plugin(inout,src/inout,[support for inout analysis],yes,no)
plugin_require(inout,from_analysis)
plugin_require(inout,value_analysis)
plugin_require(inout,semantic_callgraph)

# metrics
#########

check_plugin(metrics,src/metrics,[support for metrics analysis],yes,no)
plugin_use(metrics,value_analysis)
plugin_use(metrics,gui)

# occurrence
############

check_plugin(occurrence,src/occurrence,[support for occurrence analysis],yes,no)
plugin_use(occurrence,gui)
plugin_require(occurrence,value_analysis)

# pdg
#####

check_plugin(pdg,src/pdg,[support for pdg plugin],yes,no,pdg_types)
plugin_require(pdg,from_analysis)
plugin_require(pdg,value_analysis)

# postdominators
################

check_plugin(postdominators,src/postdominators,
             [support for postdominators plugin],yes,no)

# rte
#####

check_plugin(rte_annotation,src/rte,
             [support for runtime error annotation],yes,no)

# scope
############

check_plugin(scope,src/scope,[support for scope plugin],yes,no)
plugin_require(scope,postdominators)
plugin_require(scope,value_analysis)
plugin_require(scope,from_analysis)
plugin_require(scope,pdg)
plugin_use(scope,gui)

# semantic callgraph
####################

check_plugin(semantic_callgraph,src/semantic_callgraph,
             [support for semantic callgraph],yes,no)
plugin_require(semantic_callgraph,value_analysis)
plugin_require(semantic_callgraph,users)

# slicing
#########

check_plugin(slicing,src/slicing,[support for slicing plugin],yes,no,
             src/slicing_types)
plugin_require(slicing,from_analysis)
plugin_require(slicing,pdg)
plugin_require(slicing,value_analysis)
plugin_use(slicing,gui)

# spare code
############

check_plugin(sparecode,src/sparecode,[support for sparecode plugin],yes,no)
plugin_require(sparecode,pdg)
plugin_require(sparecode,value_analysis)

# syntactic callgraph
#####################

check_plugin(syntactic_callgraph, src/syntactic_callgraph,
             [support for callgraph plugin], yes, no)

plugin_use_external(syntactic_callgraph,dot)
plugin_use(syntactic_callgraph,gui)

# users
#######

check_plugin(users,src/users,[support for users analysis],yes,no)
plugin_require(users,value_analysis)

# value
#######

check_plugin(value_analysis,src/value,[support for value analysis],yes,no,
             [src/ai src/buckx])
plugin_use(value_analysis,gui)
plugin_use(value_analysis,scope)

####################
# External plugins #
####################

EXTRA_EXTERNAL_PLUGINS=

AC_ARG_ENABLE(external,
[[  --enable-external=plugin
                          allows to compile directly from Frama-C kernel
                          some external plug-ins.]],
[ if test -d $enableval; then
    AC_MSG_NOTICE([external plug-in $enableval found.])
    EXTRA_EXTERNAL_PLUGINS="$EXTRA_EXTERNAL_PLUGINS $enableval"
    olddir=`pwd`
    cd $enableval;
    if test -x ./configure; then
      new_section "configure plug-in $enableval"
      ./configure --prefix=$prefix --datarootdir=$datarootdir \
        --exec_prefix=$exec_prefix --bindir=$bindir --libdir=$datadir/frama-c \
        --host=$host --build=$build --mandir=$mandir \
      || \
      AC_MSG_ERROR([cannot configure requested external plugin in $enableval])
     fi;
     cd $olddir
  else
    AC_MSG_ERROR([--enable-external expects an existing directory as argument.])
  fi
])

define([KNOWN_SRC_DIRS],
       KNOWN_SRC_DIRS src/kernel src/project src/logic src/dummy src/toplevel \
       src/lib src/misc src/qed src/type src/printer)

AC_FOREACH([__plugin],m4_esyscmd([ls src]),
  [ m4_if(m4_index(KNOWN_SRC_DIRS,__plugin),[-1],
      [ m4_syscmd(test -r src/__plugin/configure.in)
        m4_define([is_configure_in],m4_sysval)
        m4_syscmd(test -r src/__plugin/configure.ac)
        m4_define([is_configure_ac],m4_sysval)
        m4_define([config_file],
          [m4_if(is_configure_in,0,src/__plugin/configure.in,
             m4_if(is_configure_ac,0,src/__plugin/configure.ac,no))])
        m4_if(config_file,[no],
          [ m4_syscmd(test -r src/__plugin/Makefile)
            m4_if(m4_sysval,[0],
              [ check_plugin(__plugin,src/__plugin,
                             [support for __plugin plug-in],yes,yes)
                if test "$[ENABLE_]tovarname(__plugin)" != "no"; then
                  EXTERNAL_PLUGINS="$EXTERNAL_PLUGINS src/__plugin";
                fi])],
          [ m4_define([plugin_prefix],src/__plugin)
            m4_include(config_file)
            m4_syscmd(cd src/__plugin && [FRAMAC_SHARE]=../../share autoconf)
            ])
      ])
  ])

#####################################################
# Check for tools/libraries requirements of plugins #
#####################################################

new_section "configure tools and libraries used by some plug-ins"

# lablgtk2
##########

REQUIRE_LABLGTK="$REQUIRE_LABLGTK$REQUIRE_GNOMECANVAS"
USE_LABLGTK="$USE_LABLGTK$USE_GNOMECANVAS"

if test "$OCAMLFIND" = "no" ; then
  echo "No Ocamlfind. Using +lablgtk2."
  LABLGTK_PATH=+lablgtk2
  LABLGTKPATH_FOR_CONFIGURE=$OCAMLLIB/lablgtk2
else
  LABLGTK_PATH=`ocamlfind query lablgtk2 | tr -d '\\r\\n'`
  if test "$LABLGTK_PATH" = "" -o "$LABLGTK_PATH" -ef "$OCAMLLIB/lablgtk2" ; then
     echo "Ocamlfind -> using +lablgtk2.($LABLGTK_PATH,$OCAMLLIB/lablgtk2)"
     LABLGTK_PATH=+lablgtk2
     LABLGTKPATH_FOR_CONFIGURE=$OCAMLLIB/lablgtk2
  else
     echo "Ocamlfind -> using $LABLGTK_PATH"
     LABLGTKPATH_FOR_CONFIGURE=$LABLGTK_PATH
  fi
fi

configure_library([LABLGTK],[$LABLGTKPATH_FOR_CONFIGURE/lablgtk.$LIB_SUFFIX],
                  [$LABLGTKPATH_FOR_CONFIGURE/lablgtk.$LIB_SUFFIX not found.],no)

if test "$HAS_LABLGTK" = "yes"; then


  # Gtksourceview
  ###############
  REQUIRE_GTKSOURCEVIEW=
  USE_GTKSOURCEVIEW=
  HAS_GTKSOURCEVIEW=
  FORCE_GTKSOURCEVIEW="yes"

  if test "$FORCE_GTKSOURCEVIEW" = "yes"; then
    REQUIRE_GTKSOURCEVIEW="$REQUIRE_LABLGTK"
    USE_GTKSOURCEVIEW="$USE_LABLGTK"
  else
    if test "$has" = "yes"; then
      USE_GTKSOURCEVIEW="$REQUIRE_LABLGTK$USE_LABLGTK"
    fi
  fi

  configure_library([GTKSOURCEVIEW],
                    [$LABLGTKPATH_FOR_CONFIGURE/lablgtksourceview2.$LIB_SUFFIX],
                    [lablgtksourceview2.$LIB_SUFFIX not found],
                    no)

  # Gnomecanvas
  #############
  configure_library([GNOMECANVAS],[$LABLGTKPATH_FOR_CONFIGURE/lablgnomecanvas.$LIB_SUFFIX],
                    [lablgnomecanvas.$LIB_SUFFIX not found],
                    no)

fi # $HAS_LABLGTK=yes

# dot and xdot tools
####################

configure_tool([DOT],[dot],[dot not found: you should install GraphViz],no)

# Native dynlink
################

define([force_static_plugins],
  [# compile statically all dynamic plug-ins
   # except contrary instructions
   [USE_NATIVE_DYNLINK]="";
   for plugin in m4_flatten(PLUGINS_LIST); do
     n=NAME_$plugin
     d=DYNAMIC_$plugin
     s=STATIC_$plugin
     eval np=\$$n
     eval dp=\$$d
     eval sp=\$$s
     if test "$dp" = "yes"; then
       if test "$sp" = "no"; then
         # force to be dynamic
         USE_NATIVE_DYNLINK="${USE_NATIVE_DYNLINK} $np";
       else
         eval STATIC_$plugin=yes;
         eval DYNAMIC_$plugin=no;
       fi
     fi
   done])

configure_library([NATIVE_DYNLINK],
                  [$OCAMLLIB/dynlink.cmxa],
                  [native dynlink unavailable],
                  yes,
                  [force_static_plugins])

# Checking some other things which cannot be done too early
###########################################################

# Usable native dynlink

# Checking internal invariant
if test "$HAS_NATIVE_DYNLINK" = "uncheck"; then
   AC_MSG_ERROR([Internal error with check of native dynlink. Please report.])
fi

HAS_USABLE_NATIVE_DYNLINK=no

if test "$HAS_NATIVE_DYNLINK" != "no" ; then
  echo "let f x y = Dynlink.loadfile \"foo\"; ignore (Dynlink.is_native); abs_float (x -. y)" > test_dynlink.ml
  if ($OCAMLOPT -shared -linkall -o test_dynlink.cmxs test_dynlink.ml) \
    2> /dev/null ; \
  then
    HAS_USABLE_NATIVE_DYNLINK=yes
    AC_MSG_RESULT([native dynlink works fine. Great.])
  else
    REQUIRE_USABLE_NATIVE_DYNLINK=$REQUIRE_NATIVE_DYNLINK
    USE_USABLE_NATIVE_DYNLINK=$USE_NATIVE_DYNLINK
    HAS_USABLE_NATIVE_DYNLINK=no
#   we know that dynlink does not work:
#   configure a dummy library "dynlink" in order to
#   configure plug-ins depending on dynlink in a proper way
    configure_library([USABLE_NATIVE_DYNLINK],
                      [dynlink],
                      [native dynlink unsupported on this platform],
                      yes,
                      [force_static_plugins])
  fi
  rm -f test_dynlink.*
fi

# Native version of ptests can be used only if
# - a native compiler exists
# - native dynlink is usable
# - native threads are usable

PTESTSBEST=byte
if test \
     "$OCAMLBEST" = "opt" -a \
     "$HAS_USABLE_NATIVE_DYNLINK" = "yes" -a \
     "$HAS_NATIVE_THREADS" = "yes"; \
then
   PTESTSBEST=opt;
fi

########################
# Plug-in dependencies #
########################

new_section "checking for plug-in dependencies"

check_frama_c_dependencies

############################
# Substitutions to perform #
############################

EXTERNAL_PLUGINS="${EXTERNAL_PLUGINS} ${EXTRA_EXTERNAL_PLUGINS}"

AC_SUBST(VERBOSEMAKE)
AC_SUBST(DOT)
AC_SUBST(HAS_DOT)
AC_SUBST(HAS_ZARITH)
AC_SUBST(ZARITH_PATH)
AC_SUBST(OCAMLGRAPH_INCLUDE)
AC_SUBST(OCAMLGRAPH_LOCAL)
AC_SUBST(OCAMLGRAPH_HOME)
AC_SUBST(OCAMLBEST)
AC_SUBST(OCAMLVERSION)
AC_SUBST(OCAMLLIB)
AC_SUBST(OCAMLWIN32)
AC_SUBST(OCAML_ANNOT_OPTION)
AC_SUBST(EXE)

AC_SUBST(HAVE_STDLIB_H)
AC_SUBST(HAVE_WCHAR_H)
AC_SUBST(HAVE_PTRDIFF_H)
AC_SUBST(HAVE_BUILTIN_VA_LIST)
AC_SUBST(THREAD_IS_KEYWORD)
AC_SUBST(UNDERSCORE_NAME)
AC_SUBST(CYCLES_PER_USEC)
AC_SUBST(LOCAL_MACHDEP)
AC_SUBST(datarootdir)
AC_SUBST(FRAMAC_DEFAULT_CPP)
AC_SUBST(DEFAULT_CPP_KEEP_COMMENTS)
AC_SUBST(FC_MCPP)

AC_SUBST(EXTERNAL_PLUGINS)

AC_SUBST(HAS_USABLE_NATIVE_DYNLINK)
AC_SUBST(HAS_NATIVE_THREADS)
AC_SUBST(PTESTSBEST)
AC_SUBST(LABLGTK_PATH)

# m4_foreach_w is not supported in some old autoconf versions.
# Sadly AC_FOREACH is deprecated now...
AC_FOREACH([p],PLUGINS_LIST,
        [AC_SUBST([ENABLE_]p)
        AC_SUBST([DYNAMIC_]p)
        ])

################################################
# Finally create the Makefile from Makefile.in #
################################################

new_section "creating makefile"

AC_CONFIG_FILES([share/Makefile.config], [chmod a-w share/Makefile.config])

AC_OUTPUT()

###########
# Summary #
###########

new_section "summary: plug-ins available"

for plugin in m4_flatten(PLUGINS_LIST); do
  n=NAME_$plugin
  e=ENABLE_$plugin
  d=DYNAMIC_$plugin
  s=STATIC_$plugin
  i=INFO_$plugin
  eval nv=\$$n
  eval ev=\$$e
  eval dv=\$$d
  eval sv=\$$s
  eval iv=\$$i
  if test "$ev" = "no"; then
    res=$ev;
  elif test "$dv" = "yes"; then
    res="$ev, dynamic";
  elif test "$sv" = "yes"; then
    res="$ev, static";
  else
    res=$ev;
  fi
  AC_MSG_NOTICE([$nv: $res$iv])
done

if test "$EXTRA_EXTERNAL_PLUGINS" != ""; then
  new_section "summary: requested external plugins"
fi

for plugin in $EXTRA_EXTERNAL_PLUGINS; do
  AC_MSG_NOTICE([$plugin])
done