File: configure.in

package info (click to toggle)
gretl 2016d-1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 48,620 kB
  • ctags: 22,779
  • sloc: ansic: 345,830; sh: 4,648; makefile: 2,712; xml: 570; perl: 364
file content (1124 lines) | stat: -rw-r--r-- 25,937 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
dnl
dnl Process this file with autoconf to produce a configure script.
dnl

AC_INIT(lib/src/version.h)
AC_PREREQ(2.12)
AC_CONFIG_HEADER(config.h)
AC_CONFIG_AUX_DIR($srcdir/tools)

PACKAGE=gretl

VERSION=`grep GRETL_VERSION $srcdir/lib/src/version.h | awk '{ print $NF }' | sed -e 's/\"//g'`
LIBGRETL_CURRENT=`grep LIBGRETL_CURRENT $srcdir/lib/src/version.h | awk '{ print $NF }'`
LIBGRETL_REVISION=`grep LIBGRETL_REVISION $srcdir/lib/src/version.h | awk '{ print $NF }'`
LIBGRETL_AGE=`grep LIBGRETL_AGE $srcdir/lib/src/version.h | awk '{ print $NF }'`
LIBVERSION="$LIBGRETL_CURRENT.$LIBGRETL_AGE.$LIBGRETL_REVISION"

AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
AC_DEFINE_UNQUOTED(LIBVERSION, "$LIBVERSION")
AC_SUBST(PACKAGE)
AC_SUBST(VERSION)
AC_SUBST(LIBVERSION)

AC_SUBST(LIBGRETL_CURRENT)
AC_SUBST(LIBGRETL_REVISION)
AC_SUBST(LIBGRETL_AGE)

echo "configuring for $PACKAGE $VERSION (library version $LIBVERSION)"

dnl
dnl Variables controlling the gretl build
dnl
build_gui="yes"
prefer_gtk2="no"
build_docs="no"
build_addons="no"
use_lucida="no"
build_po="no"
have_readline="no"
new_readline="no"
have_zlib="no"
gtk_version="none"
use_xdg="yes"
use_xdg_utils="no"
try_xdg_utils="yes"
use_gsf="no"
have_gmp="no"
have_mpfr="no"
have_lapack="no"
have_fftw3="no"
seek_inet_addr="no"
have_tramo="yes"
have_x12a="yes"
have_audio="no"
have_sourceview="no"
fake_gtkspinner="yes"
fake_mono_time="no"
have_gnu_regex="no"
have_libxml2="no"
have_xslt="no"
try_json_glib="yes"
have_json_glib="no"
try_odbc="no"
have_odbc="no"
try_mpi="yes"
try_libR="yes"
have_libR="no"
check_gnuplot="yes"
use_curl="yes"
darwin_build="no"
quiet_build="no"
swap_ends="no"
pkg_build="no"
mac_native="no"
have_mac_integration="no"
gui_disabled="no"
gp_3d="yes"
MAKE="make"
XML_LIBS=
FONTREQ="\\RequirePackage{ae}"

AC_CHECK_HEADERS(libintl.h,
	try_nls="yes",
	try_nls="no"
)

if test [ "$try_nls" = "yes" ]
then
   AM_GNU_GETTEXT([external],,)
fi

dnl
dnl Process options supplied to the configure script
dnl
AC_ARG_ENABLE(gui,
[  --enable-gui            Enable gui [[default=yes]]],
[if test "$enableval" = "yes"
then
  build_gui=yes
else
  build_gui=no
  gui_disabled=yes
fi])

AC_ARG_ENABLE(gtk2,
[  --enable-gtk2           Use GTK 2.0 in preference to GTK 3.0 [[default=no]]],
[if test "$enableval" = "yes"
then
  prefer_gtk2=yes
else
  prefer_gtk2=no
fi])

AC_ARG_ENABLE(build-doc,
[  --enable-build-doc      Enable building of gretl docs [[git only]]],
[if test "$enableval" = "yes"
then
  if ! test -d $srcdir/.git ; then
    echo "The --enable-build-doc option is valid only when building from git"
    exit 1
  else
    build_docs=yes
  fi
else
  build_docs=no
fi])

AC_ARG_ENABLE(build-addons,
[  --enable-build-addons   Enable building of gretl addons [[default=no]]],
[if test "$enableval" = "yes"
then
  build_addons=yes
else
  build_addons=no
fi])

AC_ARG_ENABLE(quiet-build,
[  --enable-quiet-build    Enable quiet building],
[if test "$enableval" = "yes"
then
  quiet_build=yes
fi])

AC_ARG_ENABLE(swap-ends,
[  --enable-swap-ends      Build FRED database with swapped endianness ],
[if test "$enableval" = "yes"
then
  swap_ends=yes
fi])

AC_ARG_ENABLE(xdg,
[  --disable-xdg           Don't Install XDG files],
[if test "$enableval" = "no"
then
  use_xdg=no
  try_xdg_utils=no
fi])

AC_ARG_ENABLE(json,
[  --disable-json          Don't try to include JSON support],
[if test "$enableval" = "no"
then
  try_json_glib=no
fi])

AC_ARG_ENABLE(xdg-utils,
[  --enable-xdg-utils      Use xdg-utils for installing XDG files [[default=auto]]],
[if test "$enableval" = "no"
then
  try_xdg_utils=no
fi])

AC_ARG_ENABLE(pkgbuild,
[  --enable-pkgbuild       For building relocatable package (e.g. OS X) ],
[if test "$enableval" = "yes"
then
  AC_DEFINE(PKGBUILD)
  pkg_build="yes"
fi])

AC_ARG_ENABLE(gnuplot-checks,
[  --disable-gnuplot-checks do not run checks for gnuplot],
[if test "$enableval" = "yes"
then
  check_gnuplot=yes
  echo "check_gnuplot = yes"
else
  check_gnuplot=no
  echo "check_gnuplot = no"
fi])

AC_ARG_ENABLE(gnuplot-3d,
[  --disable-gnuplot-3d     assume gnuplot can't do interactive 3D plots],
[if test "$enableval" = "yes"
then
  gp_3d=yes
  echo "test gp3d = yes"
else
  gp_3d=no
  echo "test gp3d = no"
fi])

AC_ARG_ENABLE(www,
[  --disable-www           do not link to libcurl for http],
[if test "$enableval" = "yes"
then
  use_curl=yes
else
  if test "$gui_disabled" = "no" ; then
    echo ""
    echo "The --disable-www option is available only if you also"
    echo "give the option --disable-gui"
    exit 1
  else
    use_curl=no
  fi
fi])

AC_ARG_WITH(lucida,
[  --with-lucida           Use Lucida fonts for manual [[git only]]],
[ case "$withval" in
  yes)
        FONTREQ="\\RequirePackage[[T1]]{fontenc,lucidabr}"
	use_lucida=yes
        ;;
  *)
        ;;
  esac ],
)
AC_SUBST(FONTREQ)

AC_ARG_WITH(gmake,
[  --with-gmake            Use GNU make explicitly [[default=no]]],
[ case "$withval" in
  yes)
        MAKE="gmake"
        ;;
  *)
        ;;
  esac ],
)
AC_SUBST(MAKE)

AC_ARG_WITH(readline,
[  --with-readline        Use readline library [[default=auto]]],
if test "x${withval}" = "xno"
then
  try_readline=no
else
  try_readline=yes
fi,
try_readline=yes)

AC_ARG_WITH(gsf,
[  --with-gsf             Use libgsf library [[default=no]]],
if test "x${withval}" = "xyes"
then
  try_gsf=yes
fi,
try_gsf=no)

AC_ARG_WITH(x-12-arima,
[  --with-x-12-arima      include X-12-ARIMA support [[default=yes]]],
if test "$withval" = "no"
then
  have_x12a="no"
else
  AC_DEFINE(HAVE_X12A)
  HAVE_X12A=1
fi,
AC_DEFINE(HAVE_X12A)
HAVE_X12A=1)
AC_SUBST(HAVE_X12A)

AC_ARG_WITH(tramo-seats,
[  --with-tramo-seats     include TRAMO/SEATS support [[default=yes]]],
if test "$withval" = "no"
then
  have_tramo="no"
else
  AC_DEFINE(HAVE_TRAMO)
  HAVE_TRAMO=1
fi,
AC_DEFINE(HAVE_TRAMO)
HAVE_TRAMO=1)
AC_SUBST(HAVE_TRAMO)

AC_ARG_WITH(libR,
[  --with-libR            include libR support [[default=auto]]],
if test "$withval" = "no"
then
  try_libR=no
fi,
try_libR=yes)

AC_ARG_WITH(mpi,
[  --with-mpi             include MPI support [[default=auto]]],
if test "$withval" = "no"
then
  try_mpi=no
fi,
try_mpi=yes)

AC_ARG_WITH(odbc,
[  --with-odbc            include ODBC support],
if test "$withval" = "yes"
then
  try_odbc=yes
fi,
try_odbc=no)

AC_ARG_WITH(audio,
[  --with-audio           include audio graph support (experimental)],
if test "$withval" = "yes"
then
  AC_DEFINE(HAVE_AUDIO)
  HAVE_AUDIO=1
  AC_SUBST(HAVE_AUDIO)
  have_audio=yes
fi,
have_audio=no)

AC_PROG_CC

AC_CANONICAL_HOST
AC_PROG_INSTALL

AC_DISABLE_STATIC
AC_LIBTOOL_DLOPEN
AC_PROG_LIBTOOL
AC_PROG_LN_S

AC_CHECK_LIB(m, sin)
AC_CHECK_LIB(c, fopen)

dnl Checks for header files, etc.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(stdint.h unistd.h dirent.h fnmatch.h fenv.h byteswap.h sys/times.h)
AC_CHECK_HEADERS(libproc.h sys/proc_info.h)
AC_C_CONST
AC_C_LONG_DOUBLE 
AC_CHECK_FUNCS(vasprintf)
AC_CHECK_FUNCS(posix_memalign)
AC_CHECK_SIZEOF(int)
AC_TYPE_SIGNAL 
AC_C_BIGENDIAN 

AC_ARG_VAR(HOSTCC, host compiler (for cross-build))
AC_ARG_VAR(MKLANG, builder for gtksourceview files (cross-build))
AC_ARG_VAR(MKNEWS, builder for NEWS file (cross-build))
AC_ARG_VAR(MPICC, path to MPI compiler wrapper)
AC_ARG_VAR(MPILINK, linker commands for MPI (cross-build))

AC_C_SSE2
AC_C_AVX
AC_C_OPENMP

dnl check for SIMD intrinsics headers
if test "x$sse2_result" = "xyes" || test "x$avx_result" = "xyes" ; then
  AC_CHECK_HEADERS(immintrin.h)
fi

dnl ensure that the source will get rebuilt if openmp
dnl is turned on or off, by flagging this in config.h
if test "$ac_openmp_result" = "yes" ; then
  AC_DEFINE(OPENMP_BUILD, 1)
fi

dnl Check for MPI apparatus?
if test "$try_mpi" = "yes" ; then
  if test x"${MPICC}" = x ; then 
    AC_DEFUN([AC_PROG_MPICC],
    [AC_CHECK_PROG(HAVE_MPICC,mpicc,yes)])

    AC_PROG_MPICC
  else
    HAVE_MPICC="yes"
  fi
  if test "x${HAVE_MPICC}" = "xyes" ; then
    AC_C_MPI
  else
    have_mpi="no"
  fi
else
  have_mpi="no"
fi

dnl try to build mailer plugin?
AC_CHECK_HEADERS(netdb.h sys/socket.h,
	build_mailer="yes" ; AC_DEFINE(ENABLE_MAILER),
	build_mailer="no"
)

if test "$build_mailer" = "yes" ; then
AC_CHECK_TYPE(struct sockaddr_in, 
  AC_DEFINE(HAVE_SOCKADDR_IN, 1, [Do we have sockaddr_in?]),,
  #include <sys/socket.h>
  #include <netdb.h>
)

AC_CHECK_TYPE(struct in_addr, 
  AC_DEFINE(HAVE_IN_ADDR, 1, [Do we have in_addr?]),,
  #include <sys/socket.h>
  #include <netdb.h>
)
fi

dnl
dnl Check for libreadline for use with gretlcli
dnl
if test "$try_readline" = "yes" ; then
   AM_PATH_READLINE(have_readline="yes", have_readline="no")
   if test "$have_readline" = "no" ; then
     READLINE_LIBS=""
     READLINE_CFLAGS=""
   fi
fi

dnl
dnl Check for XDG for handling of gretl mime-types
dnl
if test "$try_xdg_utils" = "yes" ; then
  AC_DEFUN([AC_PROG_XDG_MIME],
  [AC_CHECK_PROG(XDG_MIME,xdg-mime,yes)])

  AC_PROG_XDG_MIME
  if test x"${XDG_MIME}" = xyes ; then
    use_xdg_utils=yes
  fi
fi

dnl
dnl Is MMAP available?
dnl
AC_MSG_CHECKING([for mmap])
AC_CACHE_VAL(ac_cv_func_mmap_ok,
 [AC_TRY_LINK(
 changequote(<<, >>)dnl
 <<
#include <unistd.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>
 >>,
 changequote([, ])dnl
 [mmap((void *)0, 0, PROT_READ, 0, 0, 0);],
 ac_cv_func_mmap_ok=yes,
 ac_cv_func_mmap_ok=no)] )
AC_MSG_RESULT($ac_cv_func_mmap_ok)
if test $ac_cv_func_mmap_ok = yes
then
 AC_DEFINE(HAVE_MMAP)
fi

dnl
dnl Check for zlib
dnl
AC_CHECK_LIB(z, gzopen,have_zlib="yes" ; \
  ZLIB="-lz" ; AC_DEFINE(HAVE_ZLIB),,)
AC_SUBST(have_zlib)

dnl
dnl Check for GMP and MPFR
dnl
AM_PATH_GMP(4.0.1, have_gmp="yes")
AM_PATH_MPFR(2.2.0, have_mpfr="yes")

dnl
dnl Check for LAPACK
dnl
LAPACK_CFLAGS="-I${srcdir}/lib/src"
case $host_os in
  *arwin15*) 
    LAPACK_LIBS="-Wl,-framework -Wl,Accelerate"
    have_lapack="yes"
    darwin_build="yes"
    AC_DEFINE(OS_OSX)
  ;;   
  *arwin*) 
    LAPACK_LIBS="-Wl,-framework -Wl,vecLib"
    have_lapack="yes"
    darwin_build="yes"
    AC_DEFINE(OS_OSX)
  ;; 
  *cygwin*) 
    AM_PATH_LAPACK(, have_lapack="yes") 
    if test "$have_lapack" = "yes" ; then
      LAPACK_LIBS="${LAPACK_LIBS} -XCClinker,-lgfortran"
    fi
  ;;  
  *)
    AM_PATH_LAPACK(, have_lapack="yes") 
    if test "$have_lapack" = "yes" ; then
      SAVE_LIBS=$LIBS
      LIBS=$LAPACK_LIBS
      AC_CHECK_LIB(lapack, dgejsv_, AC_DEFINE(HAVE_LAPACK_3_2))
      LIBS=$SAVE_LIBS
    fi
  ;;
esac

dnl And while we're at it...
if test "$darwin_build" = "yes" ; then
  CARBONLIB="-Wl,-framework -Wl,Carbon"
  AC_SUBST(CARBONLIB)
  if test "$pkg_build" = "yes" ; then
    DARWIN_RPATH="@executable_path/../lib"
    AC_SUBST(DARWIN_RPATH)
  fi
fi

dnl
dnl Check for FLITE?
dnl
if test "$have_audio" = "yes" ; then
  AM_PATH_FLITE(, 
    have_flite="yes"
    AC_DEFINE(HAVE_FLITE)
  )
fi

dnl
dnl Check for unixODBC?
dnl
if test "$try_odbc" = "yes" ; then
  case $host_os in
    *arwin*) 
      ODBC_LIBS="-liodbc"
      have_odbc="yes"
    ;; 
    *)
      AM_PATH_ODBC(, 
        have_odbc="yes",
        have_odbc="no"
      )
    ;;
  esac
fi

dnl
dnl Check for gnuplot and its PNG capacity, unless the
dnl user has said not to
dnl
if test "$check_gnuplot" = "no" ; then
  have_gnuplot=yes
else
  AC_DEFUN([AC_PROG_GNUPLOT],
  [AC_CHECK_PROG(GNUPLOT,gnuplot,yes)])

  AC_PROG_GNUPLOT
  if test x"${GNUPLOT}" = xyes ; then
    have_gnuplot=yes
  fi

  if test "$build_gui" = "yes" ; then
    have_gnuplot=no
    AC_MSG_CHECKING(for gnuplot >= 4.6.0 with cairo support)
    echo "set term pngcairo" | GNUTERM=dumb gnuplot 2>/dev/null && have_gnuplot=yes
    if test "$have_gnuplot" = yes ; then
      GPVERSION=`gnuplot --version | awk '{print $2}'`
      if test "x$GPVERSION" = x ; then
        have_gnuplot=no
      else
        GPMAJOR=`echo $GPVERSION | cut -c1 2>/dev/null`
        GPMINOR=`echo $GPVERSION | cut -c3 2>/dev/null`
        if test $GPMAJOR -gt 4 ; then
          AC_MSG_RESULT(yes)
        elif test $GPMAJOR -eq 4 && test $GPMINOR -ge 6 ; then
          AC_MSG_RESULT(yes)
        else
          have_gnuplot=no
        fi
      fi
    fi
    if test "$have_gnuplot" = no ; then
      AC_MSG_RESULT(no)
      echo
      echo "* gretl needs gnuplot >= 4.6.0, with cairo support."
      echo "* The current version of gnuplot is available from www.gnuplot.info"
      exit 1
    fi
  fi
fi

dnl
dnl Check for pdflatex executable
dnl
AC_DEFUN([AC_PROG_LATEX],
[AC_CHECK_PROG(LATEX,pdflatex,yes)])

AC_PROG_LATEX
test x"${LATEX}" = xyes && AC_DEFINE(HAVE_LATEX)
if test x"${LATEX}" = xyes ; then
  have_latex="yes"
else
  have_latex="no"
fi

dnl
dnl Preliminary check for pkg-config
dnl
if test -z "$PKG_CONFIG"; then
   AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
fi
if test "$PKG_CONFIG" = "no" ; then
   echo "
Please install pkg-config and then reconfigure gretl.
pkg-config is available from http://www.freedesktop.org/
"
   exit 1
fi

orig_CFLAGS=$CFLAGS

dnl
dnl fftw3
dnl
PKG_CHECK_MODULES(FFTW, fftw3, have_fftw3="yes", have_fftw3="no")

dnl
dnl libcurl
dnl
if test "$use_curl" = "yes" ; then
  if test "x$CURL_CFLAGS" != "x" || test "x$CURL_LIBS" != "x" ; then
    have_curl="yes"
  else
    PKG_CHECK_MODULES(CURL, libcurl >= 7.13.0, have_curl="yes", have_curl="no")
  fi
  if test "$have_curl" = "yes" ; then
    AC_DEFINE(USE_CURL)
  fi
fi

dnl
dnl glib 2.0 (needed even if not building GUI; we need 2.14 for regexp functions)
dnl
PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.14.0, have_glib2="yes", have_glib2="no")
if test "${have_glib2}" = "no" ; then
   echo "
Please install glib-2.0 >= 2.14.0 and then reconfigure gretl.
glib-2.0 is available from http://www.gtk.org/
"
   exit 1
fi

dnl
dnl Do we need to "fake" g_get_monotonic_time() on Linux?
dnl
if test "$darwin_build" = "no" ; then
  PKG_CHECK_MODULES(GLIB28, glib-2.0 >= 2.28.0,
     fake_mono_time="no",
     fake_mono_time="yes",      
  )
fi
if test "$fake_mono_time" = "yes" ; then
   have_clock_gettime="no"
   AC_CHECK_LIB(c, clock_gettime, have_clock_gettime="yes",,)
   if test "$have_clock_gettime" = "no" ; then
      AC_CHECK_LIB(rt, clock_gettime, have_clock_gettime="yes"; \
       RT_LIB="-lrt" ; AC_SUBST(RT_LIB),,)
   fi
   if test "$have_clock_gettime" = "yes" ; then
      AC_DEFINE(HAVE_CLOCK_GETTIME)
   fi
fi

dnl
dnl see if we have json-glib-1.0 (not a hard dependency, yet)
dnl
if test "$try_json_glib" = "yes" ; then
   PKG_CHECK_MODULES(JSON_GLIB, json-glib-1.0 >= 0.14,
   have_json_glib="yes", 
   have_json_glib="no")
   if test $have_json_glib = "no" ; then
echo "
The json-glib-1.0 library was not found, or the version found
was not new enough. While we recommend including JSON support
you can disable this by using the option --disable-json when
running configure.
"
      exit 1
   fi 
fi

dnl
dnl Initial check for GTK availability
dnl
if test "$prefer_gtk2" = "yes" ; then
    PKG_CHECK_MODULES(GTK2, gtk+-2.0 >= 2.14.0,
      GTK_CFLAGS=$GTK2_CFLAGS
      GTK_LIBS=$GTK2_LIBS
      CFLAGS="$CFLAGS $GTK_CFLAGS"
      LIBS="$LIBS $GTK_LIBS"
      gtk_version="2.0",
      echo "GTK 2 >= 2.14.0 not found"     
    )
elif test "$build_gui" = "yes" ; then
    PKG_CHECK_MODULES(GTK3, gtk+-3.0 >= 3.0.1,
      GTK_CFLAGS=$GTK3_CFLAGS
      GTK_LIBS=$GTK3_LIBS
      CFLAGS="$CFLAGS $GTK_CFLAGS"
      LIBS="$LIBS $GTK_LIBS"
      AC_DEFINE(USE_GTK3)
      gtk_version="3.0"
      fake_gtkspinner="no",
      echo "GTK 3 >= 3.0.1 not found"     
    )
fi

dnl GTK 2.0 fallback in case preference not given
if test "$prefer_gtk2" = "no" && test "$gtk_version" = "none" ; then
   if test "$build_gui" = "yes" ; then
      PKG_CHECK_MODULES(GTK2, gtk+-2.0 >= 2.14.0,
        GTK_CFLAGS=$GTK2_CFLAGS
        GTK_LIBS=$GTK2_LIBS
        CFLAGS="$CFLAGS $GTK_CFLAGS"
        LIBS="$LIBS $GTK_LIBS"
        gtk_version="2.0",
        build_gui="no"
        echo "GTK 2 >= 2.14.0 not found"     
    )
   fi
fi     

dnl
dnl Mac: check for Quartz version of GTK
dnl
if test "$darwin_build" = "yes" ; then
  if test "$gtk_version" = "3.0" ; then
    PKG_CHECK_EXISTS(gtk+-quartz-3.0,
     echo "Found quartz-based GTK"
     AC_DEFINE(MAC_NATIVE)
     mac_native="yes", 
     mac_native="no")
  elif test "$gtk_version" = "2.0" ; then
    PKG_CHECK_EXISTS(gtk+-quartz-2.0,
     echo "Found quartz-based GTK"
     AC_DEFINE(MAC_NATIVE)
     mac_native="yes", 
     mac_native="no")
  fi
fi

dnl
dnl Mac: if using Quartz GTK, require mac-integration
dnl
if test "$mac_native" = "yes" ; then
    PKG_CHECK_MODULES(GTKMAC, gtk-mac-integration >= 2.0.1,
      have_mac_integration="no",
      have_mac_integration="yes",      
    )
fi

dnl
dnl For native gtkspinner: check for GTK 2.20 or higher
dnl
if test "$gtk_version" = "2.0" ; then
    PKG_CHECK_MODULES(GTKSPINNER, gtk+-2.0 >= 2.20.0,
      fake_gtkspinner="no",
      fake_gtkspinner="yes",      
    )
fi

dnl
dnl Check for installed gtksourceview (GTK 2 variant)
dnl
if test "$gtk_version" = "2.0" ; then
    PKG_CHECK_MODULES(GTKSOURCEVIEW, gtksourceview-2.0 >= 2.2.2,
      AC_DEFINE(USE_GTKSOURCEVIEW_2)
      have_sourceview="2.0",
      echo "version 2.0 >= 2.2.2 not found"
    )
    if test "$have_sourceview" = "2.0" ; then
      PKG_CHECK_MODULES(GSVWORDS, gtksourceview-2.0 >= 2.10.5,
        AC_DEFINE(HAVE_GTKSOURCEVIEW_210),
	echo "gtksourceview: word completion not supported"
      )
    fi
fi

dnl
dnl Check for installed gtksourceview (GTK 3 variant)
dnl
if test "$gtk_version" = "3.0" ; then
    PKG_CHECK_MODULES(GTKSOURCEVIEW, gtksourceview-3.0,
      AC_DEFINE(USE_GTKSOURCEVIEW_3)
      have_sourceview="3.0",
      echo "version 3.0 not found"
    )
fi

if test x"${MSGFMT}" != x ; then
   build_po="yes"
else
   echo "*** msgfmt not found, can't build message catalogs"
fi

dnl countermand any positive results for xdg if we're not
dnl building the gretl GUI
if test "$gui_disabled" = "yes" ; then
  use_xdg=no
  use_xdg_utils=no
fi

dnl record the results of the above tests
AC_SUBST(build_gui)
AC_SUBST(gtk_version)
AC_SUBST(mac_native)
AC_SUBST(have_sourceview)
AC_SUBST(fake_gtkspinner)
AC_SUBST(have_gnu_regex)
AC_SUBST(have_audio)
AC_SUBST(have_odbc)
AC_SUBST(have_mpi)
AC_SUBST(build_mailer)
AC_SUBST(build_po)
AC_SUBST(use_curl)
AC_SUBST(use_xdg)
AC_SUBST(use_xdg_utils)
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)
AC_SUBST(CURL_CFLAGS)
AC_SUBST(CURL_LIBS)

dnl Check for gdk-pixbuf support
if test ${build_gui} = "yes" ; then
    PKG_CHECK_MODULES(GDK_PIXBUF, gdk-pixbuf-2.0 >= 0.7.0,
        pixbuf_failed="no",
	pixbuf_failed="yes"
   )
fi
if test "${pixbuf_failed}" = "yes" ; then
    echo "* gretl needs but did not find the gdk-pixbuf library."
    exit 1
fi

dnl Check for libxml2
PKG_CHECK_MODULES(XML, libxml-2.0 >= 2.5.0)

dnl Check for libxslt (for the helpfiles)
if test "${build_docs}" = "yes" ; then
  PKG_CHECK_MODULES(XSLT, libxslt >= 1.0.15,	
    have_xslt="yes",
    have_xslt="no"
  )
fi

dnl Check for libR (optional)
if test "$try_libR" = "yes" ; then
    PKG_CHECK_MODULES(RLIB, libR,
      AC_DEFINE(USE_RLIB)
      if echo "$RLIB_LIBS" | grep ^-L > /dev/null ; then
        RLIBDIR=`echo $RLIB_LIBS | cut -b 3- | awk '{ print $1 }'`
      else 
        RLIBDIR="/usr/lib"
      fi 
      if test "$darwin_build" = "yes" ; then
        RLIBNAME="libR.dylib"
      else 
        RLIBNAME="libR.so"
      fi
      RLIB="${RLIBDIR}/${RLIBNAME}"
      AC_DEFINE_UNQUOTED(RLIBPATH, "$RLIB") 
      have_libR="yes",
      have_libR="no"
    )
fi

dnl
dnl Check for libgsf-1, if requested
dnl
if test "$try_gsf" = "yes" ; then
    PKG_CHECK_MODULES(GSF, libgsf-1 >= 1.14.31,
      CFLAGS="$CFLAGS $GSF_CFLAGS"
      LIBS="$LIBS $GSF_LIBS"
      AC_DEFINE(USE_GSF)
      use_gsf="yes",
      echo "libgsf >= 1.14.31 not found"     
    )
fi

dnl If building docs was requested, see if we can do it
if test "${build_docs}" = "yes" ; then
   if test "$have_xslt" = "no" || test "$have_latex" = "no" ; then
      build_docs="no"
      echo "*** Can't build gretl docs: XSLT and/or pdflatex not found"
   fi
fi

dnl If building addons was requested, see if we can do it
if test "${build_addons}" = "yes" ; then
   if test "$have_latex" = "no" ; then
      build_addons="no"
      echo "*** Can't build gretl addons: pdflatex not found"
   fi
fi

AC_SUBST(build_docs)
AC_SUBST(build_addons)
AC_SUBST(quiet_build)
AC_SUBST(pkg_build)
AC_SUBST(swap_ends)
AC_SUBST(use_gsf)

GTK_HUSH=""
CFLAGS=-Wno-deprecated-declarations
AC_MSG_CHECKING([whether CC supports -Wno-deprecated-declarations])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
   [AC_MSG_RESULT([yes])]
   [GTK_HUSH=-Wno-deprecated-declarations],
   [AC_MSG_RESULT([no])]
)
AC_SUBST(GTK_HUSH)

if test "$gtk_version" = "3.0" ; then
   plugsub="gretl-gtk3"
else 
   plugsub="gretl-gtk2"
fi
AC_SUBST(plugsub)

dnl record results on various libraries
AC_SUBST(XML_CFLAGS)
AC_SUBST(XML_LIBS)
AC_SUBST(XSLT_CFLAGS)
AC_SUBST(XSLT_LIBS)
AC_SUBST(GDK_PIXBUF_CFLAGS)
AC_SUBST(GDK_PIXBUF_LIBS)
AC_SUBST(RLIB_CFLAGS)
AC_SUBST(RLIB_LIBS)
AC_SUBST(RLIB)
AC_SUBST(USE_SSE2)
AC_SUBST(USE_AVX)

dnl Determine installation prefix
if test "${prefix}" = "NONE" ; then
   prefix="/usr/local"
fi
AC_DEFINE_UNQUOTED(GRETL_PREFIX, "${prefix}")

if test "${gp_3d}" = "yes" ; then
  AC_DEFINE(GNUPLOT3D)
fi

dnl Create output
CFLAGS="$orig_CFLAGS"
AC_OUTPUT([ 
Makefile 
gretl_sh
gretl.pc 
gui2/Makefile
gui2/debug
xdg/gretl.desktop
xdg/Makefile
cli/Makefile 
cli/debug
lib/Makefile 
plugin/Makefile
po/Makefile.in 
share/Makefile
share/bcih/Makefile
tests/Makefile
extra/Makefile
osx/Makefile
osx/gretl.sh
osx/fixlinks.sh
osx/Info.plist
redhat/gretl.spec
utils/emacs/Makefile
])

if test "${build_docs}" = "yes" ; then
  AC_OUTPUT([
    doc/Makefile
    doc/commands/Makefile
    doc/tex/Makefile
    doc/tex_it/Makefile
    doc/tex_es/Makefile
    doc/tex_pt/Makefile
    doc/reference/Makefile
  ])
fi

AC_OUTPUT([
  doc/gretl.sty
  doc/gretl-lite.sty
])

if test "${build_addons}" = "yes" ; then
  AC_OUTPUT([
    addons/Makefile
    addons/gig/Makefile
    addons/gig/pkg.inp
    addons/gig/doc/Makefile
    addons/HIP/Makefile
    addons/HIP/pkg.inp
    addons/HIP/doc/Makefile
    addons/ivpanel/Makefile
    addons/ivpanel/pkg.inp
    addons/ivpanel/doc/Makefile
    addons/SVAR/Makefile
    addons/SVAR/pkg.inp
    addons/SVAR/doc/Makefile
  ])
fi

if test "${have_zlib}" = "no" ; then
echo "
Please install zlib (compression library) and then reconfigure gretl.
zlib is available via http://www.info-zip.org/pub/infozip/zlib/
"

elif test x"${XML_LIBS}" = x ; then
echo "
Please install libxml2 and then reconfigure gretl.
libxml2 is available from http://xmlsoft.org/
"

elif test "${have_lapack}" = "no" ; then
echo "
Please install lapack and then reconfigure gretl.
Lapack is available from http://www.netlib.org/lapack/
"

elif test "${have_fftw3}" = "no" ; then
echo "
Please install fftw3 and then reconfigure gretl.
fftw3 is available from http://www.fftw.org/
"

elif test "${have_gmp}" = "no" ; then
echo "
Please install GMP and then reconfigure gretl.
GMP is available from http://gmplib.org/
"

elif test "${have_mpfr}" = "no" ; then
echo "
Please install MPFR and then reconfigure gretl.
MPFR is available from http://www.mpfr.org/
"

elif test "${have_curl}" = "no" ; then
echo "
Please install libcurl and then reconfigure gretl.
libcurl is available from http://curl.haxx.se/libcurl/
"

elif test "${have_glib2}" = "no" ; then
echo "
Please install glib-2.0 >= 2.14.0 and then reconfigure gretl.
glib-2.0 is available from http://www.gtk.org/
"

elif test "${gtk_version}" = "2.0" && test "${have_sourceview}" != "2.0" ; then
echo "
Please install gtksourceview-2.0 and then reconfigure gretl.
gtksourceview-2.0 is available from http://www.gnome.org/
"

elif test "${gtk_version}" = "3.0" && test "${have_sourceview}" != "3.0" ; then
echo "
Please install gtksourceview-3.0 and then reconfigure gretl.
gtksourceview-3.0 is available from http://www.gnome.org/
"

else
  if test "${use_xdg_utils}" = "yes" ; then
    xdg_utils_msg="if DESTDIR not set"
  else
    xdg_utils_msg="no"
  fi
echo "
Configuration:
  
  Installation path:                      ${prefix}
  Use readline library:                   ${have_readline}
  Use gnuplot for graphs:                 ${have_gnuplot}
  Use pdflatex for typesetting:           ${have_latex}
  Use libgsf for zip/unzip:               ${use_gsf}
  sse2 support for RNG:                   ${sse2_result}
  OpenMP support:                         ${ac_openmp_result}
  MPI support:                            ${have_mpi}
  AVX support for arithmetic:             ${avx_result}
  Build with GTK version:                 ${gtk_version}
  Build gretl documentation:              ${build_docs}
  Use Lucida fonts:                       ${use_lucida}
  Build message catalogs:                 ${build_po}
  Build gretl addons:                     ${build_addons}
  X-12-ARIMA support:                     ${have_x12a}
  TRAMO/SEATS support:                    ${have_tramo}
  libR support:                           ${have_libR}
  ODBC support:                           ${have_odbc}
  JSON parsing support:                   ${have_json_glib}
  Experimental audio support:             ${have_audio}
  Use xdg-utils in installation:          ${xdg_utils_msg}
  
  LAPACK libraries:
    ${LAPACK_LIBS}

Now type '$MAKE' to build gretl."

  if test "${build_docs}" = "yes" ; then
    echo "You can also do 'make pdfdocs' to build the PDF documentation."
  fi
  echo

  if test "${gui_disabled}" = "no" && test "${gtk_version}" = "none" ; then
    echo "*** Warning: since GTK is not available the gretl GUI will"
    echo "*** not be built, only the library and command-line program."
    echo
  fi

  if test "$ac_openmp_result" = "yes" && test "x${blas_pthreads}" != "x"; then
    echo "*** Warning: you are building gretl with OpenMP, but linking"
    echo "*** against an OpenBLAS library that uses pthreads. This mixture"
    echo "*** is not recommended. Ideally, OpenBLAS should use OpenMP."
    echo
  fi
fi