1dnl Process this file with autoconf to produce a configure script.
2dnl configure.in for gnuplot on Unix.
3dnl
4dnl NB: Change version/patchlevel immediately below
5dnl     and also in PATCHLEVEL and src/version.c
6dnl
7
8AC_INIT(gnuplot, 5.4.1)
9
10AC_CONFIG_SRCDIR(src/graphics.c)
11AC_PREREQ([2.69])
12AC_CONFIG_HEADERS(config.h:config.hin)
13
14dnl The line below is for use during development
15dnl AC_DEFINE(DEVELOPMENT_VERSION,1,[Provide contact info for gnuplot develoment])
16dnl The line below is for packaging a release version
17AM_CONDITIONAL([DEVELOPMENT_VERSION], 0)
18
19AM_INIT_AUTOMAKE([1.10 subdir-objects])
20
21AM_MAINTAINER_MODE
22
23VERSION_MAJOR="5.4"
24PATCHLEVEL="`cat $srcdir/PATCHLEVEL`"
25AC_DEFINE_UNQUOTED(VERSION_MAJOR,["$VERSION_MAJOR"],[The main version number])
26AC_DEFINE_UNQUOTED(PATCHLEVEL,["$PATCHLEVEL"],[The patch level, a.k.a. micro version number])
27
28dnl configure.in body
29
30dnl Compiler characteristics
31dnl Check for the const and inline keywords and ANSI style stringification
32AC_USE_SYSTEM_EXTENSIONS
33AC_PROG_CC
34AC_PROG_CPP
35AC_PROG_OBJC
36AC_C_CONST
37AC_C_INLINE
38AC_C_STRINGIZE
39AC_PROG_LN_S
40
41if test "${build}" != "${host}"
42then
43  CC=${CC-${host_alias-gcc}}
44  CFLAGS=${CFLAGS-"-g -O2"}
45  CXX=${CXX-${host_alias-c++}}
46  CXXFLAGS=${CXXFLAGS-"-g -O2"}
47  CC_FOR_BUILD=${CC_FOR_BUILD-gcc}
48else
49  # The cross-compilation patch originally had CC_FOR_BUILD = "\$(CC)"
50  # but that causes a recursive definition in docs/Makefile. EAM Dec 2009.
51  CC_FOR_BUILD="${CC}"
52  AC_PROG_CC
53
54  # We must set the default linker to the linker used by gcc for the correct
55  # operation of libtool.  If LD is not defined and we are using gcc, try to
56  # set the LD default to the ld used by gcc.
57  if test -z "$LD"
58  then
59    if test "$GCC" = yes
60    then
61      case $build in
62      *-*-mingw*)
63        gcc_prog_ld=`$CC -print-prog-name=ld 2>&1 | tr -d '\015'` ;;
64      *)
65        gcc_prog_ld=`$CC -print-prog-name=ld 2>&1` ;;
66      esac
67      case $gcc_prog_ld in
68      # Accept absolute paths.
69      [[\\/]* | [A-Za-z]:[\\/]*)]
70        LD="$gcc_prog_ld" ;;
71      esac
72    fi
73  fi
74
75  CXX=${CXX-"c++"}
76  CFLAGS=${CFLAGS-"-g -O2"}
77  CXXFLAGS=${CXXFLAGS-"-g -O2"}
78fi
79AM_PROG_CC_C_O
80AC_SUBST(CC_FOR_BUILD)
81
82dnl large file support
83AC_CHECK_TYPES([off_t])
84AC_FUNC_FSEEKO
85AC_SYS_LARGEFILE
86
87dnl timezone support
88AC_CHECK_MEMBERS([struct tm.tm_gmtoff, struct tm.__tm_gmtoff],,,[
89#include <sys/types.h>
90#include <time.h>])
91
92dnl explicit call to PKG_PROG_PKG_CONFIG because the first call to
93dnl PKG_CHECK_MODULES{,_NOFAIL} may not happen
94PKG_PROG_PKG_CONFIG
95
96AC_ARG_WITH(libcerf,dnl
97[  --without-libcerf       build without special functions from libcerf (default enabled)],,
98  [test -z "${with_libcerf}" && with_libcerf=yes])
99
100if test "${with_libcerf}" = yes ; then
101  dnl The libcerf library contains a set of complex-valued special functions
102  dnl related to the error function (cerf, erfi, Dawson's integral, Voigt profile).
103  dnl If libcerf is installed then we can use them.
104  PKG_CHECK_MODULES_NOFAIL([LIBCERF], [libcerf],
105      [
106      CPPFLAGS="$CPPFLAGS $LIBCERF_CFLAGS"
107      LDFLAGS="$LDFLAGS $LIBCERF_LIBS"
108      ],
109  )
110  AC_SEARCH_LIBS([cdawson], [cerf],
111      [AC_DEFINE([HAVE_LIBCERF], 1, [define if you have libcerf])
112      have_libcerf=yes]
113  )
114fi
115
116dnl Various programs
117dnl X/Emacs for building .texi version of docs
118test x"$EMACS" = xt && EMACS=
119AC_CHECK_PROGS(EMACS, emacs xemacs, no)
120
121dnl Allow manual specification of tex
122AC_ARG_WITH(latex,[  --without-latex         disable installation of latex support files],[],[with_latex="yes"])
123if test "$with_latex" = yes; then
124  AC_CHECK_PROGS(PLAINTEX, tex, no)
125  AC_CHECK_PROGS(LATEX, latex latex2e, no)
126  AC_CHECK_PROGS(PDFLATEX, pdflatex, no)
127  test "$PLAINTEX" = "no" -o "$LATEX" = no -o "$PDFLATEX" = "no" && with_latex="no"
128else
129    PLAINTEX="no"
130    LATEX="no"
131    PDFLATEX="no"
132fi
133AM_CONDITIONAL(HAVE_LATEX, test "$with_latex" != no)
134AC_CHECK_PROGS(DVIPS, dvips, no)
135AC_CHECK_PROGS(TROFF, troff, no)
136AC_CHECK_PROGS(LATEX2HTML, latex2html, no)
137
138AC_ARG_WITH(texdir,dnl
139  [--with-texdir=DIR       where to install latex style files (default: ask kpsexpand)],
140  TEXDIR="$withval",
141  TEXDIR="no")
142dnl Allow manual specification of kpsexpand
143AC_CHECK_PROGS(KPSEXPAND, kpsexpand, no)
144AC_CHECK_PROGS(TEXHASH, texhash, true)
145AC_ARG_WITH(kpsexpand,dnl
146  [--with-kpsexpand        search for kpsexpand at run-time (default disabled)],
147  [if test "$withval" = yes; then
148    test "$KPSEXPAND" != "no" || AC_MSG_ERROR(dnl
149      [You tell me to use kpsexpand, but there is no kpsexpand])
150    AC_DEFINE(HAVE_KPSEXPAND,1,[ Define if you want to use kpsexpand (TeX). ])
151  fi])
152
153dnl we only care about texdir if latex is enabled
154if test "$with_latex" = yes; then
155  test "$KPSEXPAND" = "no" -a "$TEXDIR" = "no" && AC_MSG_ERROR(dnl
156    [texdir is not given and there is no kpsexpand, please tell where to install])
157  dnl texdir has priority
158  if test "$TEXDIR" = "no"; then
159    TEXDIR=`$KPSEXPAND '$TEXMFLOCAL'`
160    if test "x$TEXDIR" = "x" -o "$TEXDIR" = "\$TEXMFLOCAL"; then
161      if test "x$prefix" != "xNONE"; then
162        TEXDIR=${prefix}/share/texmf
163      else
164        TEXDIR=${ac_default_prefix}/share/texmf
165      fi
166    fi
167    TEXDIR=${TEXDIR}/tex/latex/gnuplot
168  fi
169fi
170
171dnl X Window System files.
172AC_SUBST(LIBRARIES_FOR_X)
173AC_PATH_XTRA
174
175dnl Needed for LynxOS until AC_PATH_XTRA is fixed
176if test "$ac_cv_func_gethostbyname" = no; then
177  if test "$ac_cv_lib_nsl_gethostbyname" = no; then
178    AC_CHECK_LIB(bsd, gethostbyname, X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd")
179  fi
180fi
181
182if test "$no_x" != yes; then
183  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
184  LIBRARIES_FOR_X="$X_LIBS -lX11 $X_EXTRA_LIBS"
185  AC_DEFINE(X11,1,[ Define if you are using the X11 window system. ])
186  AC_ARG_WITH(x-dcop,dnl
187  [--with-x-dcop           gnuplot_x11 can use KDE3/DCOP for space-raises-console],
188  AC_DEFINE(USE_KDE3_DCOP,1,[ Define if gnuplot_x11 can use KDE3 DCOP to raise konsole]))
189fi
190AM_CONDITIONAL(BUILD_GNUPLOT_X11, test "$no_x" != yes)
191
192dnl Operating systems.
193dnl FIXME AC_DEFINE(ISC22)
194dnl FIXME AC_DEFINE(KSR)
195dnl Check for MSDOS and djgpp, Apple MacOsX, BeOS
196GP_MSDOS
197GP_APPLE
198GP_BEOS
199GP_ALPHA
200AM_CONDITIONAL(BUILD_SRC_BEOS_SUBDIR, test x$build_beos_subdir = xyes)
201
202dnl _instead_ of -lm ...
203AC_CHECK_FUNC(sin,,[AC_CHECK_LIB(m,sin)])
204
205dnl Header files. ANSI first
206dnl We prefer that the absense of a macro is the norm, so in syscfg.h
207dnl configure's HAVE_XXXX defines are translated into NO_XXXX for ANSI
208dnl headers and functions
209AC_HEADER_STDC
210
211dnl Header files
212dnl ANSI/ISO C, POSIX, others
213AC_CHECK_HEADERS(dirent.h errno.h float.h langinfo.h limits.h locale.h math.h \
214  stdlib.h string.h time.h sys/time.h sys/types.h \
215  sys/bsdtypes.h sys/ioctl.h sys/param.h sys/select.h sys/socket.h \
216  sys/stat.h sys/systeminfo.h sys/timeb.h sys/utsname.h \
217  libc.h malloc.h poll.h sgtty.h termios.h values.h dirent.h \
218  inttypes.h \
219  dlfcn.h dl.h
220)
221
222AC_HEADER_STDBOOL
223
224if test "$ac_cv_header_sys_stat_h" = yes; then
225  AC_HEADER_STAT
226fi
227
228AC_HEADER_SYS_WAIT
229
230dnl Check for external functions plugin infrastructure
231AC_ARG_ENABLE(plugins,dnl
232[  --disable-plugins       disable support for importing external functions],,)
233
234if test "$enable_plugins" != no; then
235  if test "$ac_cv_header_dl_h" = yes; then
236    AC_SEARCH_LIBS(shl_load, dld,
237      [AC_DEFINE(HAVE_EXTERNAL_FUNCTIONS,1,[ Define if external function plugins are to be supported. ])
238       have_external_functions=yes
239      ])
240  fi
241  if test "$ac_cv_header_dlfcn_h" = yes; then
242    AC_SEARCH_LIBS(dlopen, dl,
243      [AC_DEFINE(HAVE_EXTERNAL_FUNCTIONS,1,[ Define if external function plugins are to be supported. ])
244       have_external_functions=yes
245      ])
246  fi
247fi
248AM_CONDITIONAL(BUILD_PLUGIN, test "$have_external_functions" = yes)
249
250dnl check if unistd actually declares anything.
251AC_MSG_CHECKING(for unistd.h)
252AC_EGREP_HEADER(execv, unistd.h,
253  [AC_DEFINE(HAVE_UNISTD_H) AC_MSG_RESULT(yes)],
254   AC_MSG_RESULT(no))
255
256dnl check if errno.h header declares errno
257AC_MSG_CHECKING(if errno variable is declared)
258AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
259#ifdef HAVE_ERRNO_H
260#include <errno.h>
261#endif]], [[errno=0]])],[AC_MSG_RESULT(yes)],[AC_DEFINE(EXTERN_ERRNO,1,[ Define if <errno.h> declares errno. ])
262   AC_MSG_RESULT(no)])
263
264
265dnl Types.
266AC_TYPE_SIZE_T
267AC_MSG_CHECKING(for time_t in time.h)
268AC_EGREP_HEADER(time_t,time.h,
269  [AC_MSG_RESULT(yes)
270   AC_DEFINE(HAVE_TIME_T_IN_TIME_H,1,
271             [ Define if time_t is declared in time.h. ])])
272
273
274dnl Functions. Standard first, then others
275
276dnl ANSI/ISO and their predecessors
277dnl sunos 4 has on_exit() in place of atexit()
278dnl gamma is called lgamma linux
279dnl we prefer lgamma over gamma, see specfun.c
280dnl math lib is already available, see operating systems part
281AC_CHECK_FUNCS(atexit memcpy memmove memset \
282  on_exit bcopy bzero \
283  setvbuf strerror strchr strrchr strstr \
284  index rindex \
285  erf erfc gamma lgamma tgamma \
286  getcwd poll pclose popen fdopen select sleep stpcpy \
287  strcspn strdup strndup strnlen strcasecmp stricmp strncasecmp strnicmp \
288  sysinfo tcgetattr vfprintf doprnt uname usleep
289)
290
291dnl HBB 20030624: see if signgam is declared by math.h
292AC_CHECK_DECLS([signgam],,,
293[#if HAVE_MATH_H
294#include <math.h>
295#endif
296])
297
298dnl check, if we have sigsetjmp and siglongjmp.
299dnl a trivial AC_CHECK_FUNCS(sigsetjmp) won't do
300dnl because sigsetjmp() might be a macro declared
301dnl in <setjmp.h>. (joze)
302AC_MSG_CHECKING(for sigsetjmp)
303AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <setjmp.h>]], [[jmp_buf env; sigsetjmp(env, 1);]])],[AC_MSG_RESULT(yes)
304   AC_DEFINE(HAVE_SIGSETJMP,1,
305             [ Define if we have sigsetjmp(). ])],[AC_MSG_RESULT(no)])
306
307if test "$ac_cv_func_pclose" = yes -a "$ac_cv_func_popen" = yes ; then
308  AC_DEFINE(PIPES,1,[ Define if you do have the popen and pclose functions. ])
309fi
310
311AC_MSG_CHECKING(if malloc(0) returns 0)
312AC_RUN_IFELSE([AC_LANG_PROGRAM([[#ifdef HAVE_STDLIB_H
313#include <stdlib.h>
314#endif
315]],
316[[if(malloc(0)==0) return 1;]])],
317[malloc_zero_returns_zero=no],
318[malloc_zero_returns_zero=yes],
319[malloc_zero_returns_zero=yes])
320AC_MSG_RESULT([$malloc_zero_returns_zero])
321AS_IF([test x$malloc_zero_returns_zero = xyes],
322      [AC_DEFINE([MALLOC_ZERO_RETURNS_ZERO],[1],[Define to 1 if malloc(0)==0])])
323
324dnl Argument types of select()
325AC_FUNC_SELECT_ARGTYPES
326
327dnl On SVR3.
328dnl FIXME AC_DEFINE(CRIPPLED_SELECT)
329
330dnl .gih help file location
331eval gp_datadir=$datadir
332if test "$gp_datadir" = NONE/share; then
333  datadir="/usr/local/share"
334fi
335pkgdatadir="$datadir/$PACKAGE"
336AC_ARG_WITH(gihdir,dnl
337[  --with-gihdir=DIR       location of .gih help text file
338                          (default PREFIX/share/PACKAGE/VERSION)],
339  GIHDIR="$withval",
340  GIHDIR="$pkgdatadir/$VERSION_MAJOR")
341
342dnl TODO: simplify, update ggi support
343dnl new ggi driver
344GGI_SUPPORT=no
345AC_ARG_WITH(ggi,dnl
346[  --with-ggi[=DIR]          enable the ggi driver],
347  [if test "$withval" != no; then
348     if test -d $withval/include; then
349       CPPFLAGS="$CPPFLAGS -I$withval/include"
350     fi
351     if test -d $withval/lib; then
352       LDFLAGS="$LDFLAGS -L$withval/lib"
353     fi
354     AC_CHECK_LIB(ggi,ggiInit,
355       [TERMLIBS="-lggi $TERMLIBS"
356        AC_DEFINE(USE_GGI_DRIVER,1,
357                  [ Define this to build the General Graphics Interface (ggi) driver. ])
358        GGI_SUPPORT=yes
359	dnl check for customized libxmi (xmiInit not in normal libxmi)
360        AC_CHECK_LIB(xmi,xmiInit,
361          [TERMLIBS="-lxmi $TERMLIBS"
362           AC_CHECK_HEADERS(ggi/xmi.h)])
363        dnl check if libggiwmh and ggi/wmh.h are found
364        AC_CHECK_LIB(ggiwmh,ggiWmhInit,
365          [TERMLIBS="-lggiwmh $TERMLIBS"
366           AC_CHECK_HEADERS(ggi/wmh.h,,
367             AC_MSG_WARN([found ggiwmh library but not ggi/wmh.h
368please add path to ggi/wmh.h to CPPFLAGS in Makefile]))
369          ])])
370   fi])
371
372dnl Use builtin readline or GNU readline or NetBSD editline
373AC_ARG_WITH(readline,dnl
374[  --with-readline=builtin  use the built-in readline
375  --with-readline=gnu      use the GNU readline library (default if present)
376  --with-readline=bsd      use the NetBSD editline library (NB: does not handle UTF-8!)
377  --with-readline=DIR      specify the location of readline/editline
378  --without-readline       same as --with-readline=builtin], ,
379  test -z "$with_readline" && with_readline=gnu)
380
381AS_IF([test "x${with_readline}" = "xno"], with_readline="builtin", )
382
383dnl Gnuplot history
384AC_ARG_ENABLE(history-file,dnl
385[  --disable-history-file  do not use history file],,
386  test -z "$enable_history_file" && enable_history_file=yes)
387
388dnl GNU readline and the required terminal library
389if test "$with_readline" != no; then
390  _libs="$LIBS"
391  if test "$with_readline" != builtin; then
392
393    dnl check for terminal library
394    dnl this is a very cool solution from octave's configure.in
395    gp_tcap=""
396    for termlib in ncurses curses termcap terminfo termlib; do
397      AC_CHECK_LIB(${termlib}, tputs, [gp_tcap="$gp_tcap -l$termlib"])
398      case "$gp_tcap" in
399        *-l${termlib}*)
400          break
401        ;;
402      esac
403    done
404
405    dnl explicit path to readline/editline
406    if test "$with_readline" != gnu -a "$with_readline" != bsd; then
407      if test -d $with_readline/include; then
408        CPPFLAGS="$CPPFLAGS -I$with_readline/include"
409      fi
410      if test -d $with_readline/lib; then
411        LDFLAGS="$LDFLAGS -L$with_readline/lib"
412      fi
413      dnl Could be either libedit or readline!
414      if test ! -d $with_readline/include/readline; then
415        if test -d $with_readline/include/editline; then
416          AC_MSG_WARN([$with_readline contains libedit, not readline!])
417          with_readline=bsd
418        else
419          AC_MSG_ERROR([No readline found in $with_readline])
420        fi
421      fi
422    fi
423
424    if test "$with_readline" = bsd; then
425
426      AC_CHECK_LIB(edit, readline,
427        [TERMLIBS="-ledit $TERMLIBS"],
428	 [AC_MSG_WARN([Could not find BSD editline library ])
429	  with_readline=builtin],)
430
431      if test "$ac_cv_lib_edit_readline" = yes; then
432        AC_DEFINE(HAVE_LIBEDITLINE,1,
433                [ Define if you are using the BSD editline library. ])
434        AC_CHECK_HEADERS(editline/readline.h,,
435          AC_MSG_WARN([found BSD editline library but not readline.h please add path to readline.h to CPPFLAGS in Makefile]))
436
437        if test "$enable_history_file" = yes; then
438            AC_DEFINE(GNUPLOT_HISTORY,1,
439                      [ Define if you want to use a gnuplot history file. ])
440        fi
441      fi
442
443    else # !bsd
444
445    AC_CHECK_LIB(readline, remove_history,
446      [TERMLIBS="-lreadline $gp_tcap $TERMLIBS"],,[${gp_tcap}])
447    if test "$ac_cv_lib_readline_remove_history" = no; then
448      dnl OSX keeps history functions in a separate library
449      AC_CHECK_LIB(history, remove_history,
450        [TERMLIBS="-lreadline -lhistory $gp_tcap $TERMLIBS"],
451        [ AC_MSG_WARN([GNU readline not found - falling back to builtin readline])
452          with_readline=builtin ]
453        ,[${gp_tcap}])
454    fi
455
456    dnl Work around some functions missing from the OSX readline library.
457    dnl Would it be better to simply switch to with_readline=bsd in this case?
458    AC_SEARCH_LIBS(rl_ding, readline, ,
459	AC_DEFINE(MISSING_RL_DING,1,[ Define if your libreadline has no rl_ding]),
460        [${TERMLIBS}])
461    AC_SEARCH_LIBS(rl_forced_update_display, readline, ,
462	AC_DEFINE(MISSING_RL_FORCED_UPDATE_DISPLAY,1,[ Define if your libreadline has no rl_force_update_display]),
463        [${TERMLIBS}])
464    AC_SEARCH_LIBS(rl_reset_after_signal, readline,
465	AC_DEFINE(HAVE_READLINE_RESET,1,[ Define if your libreadline has rl_reset_after_signal]),
466	,
467        [${TERMLIBS}])
468    AC_SEARCH_LIBS(_rl_signal_handler, readline,
469	AC_DEFINE(HAVE_READLINE_SIGNAL_HANDLER,1,[ Define if your libreadline has _rl_signal_handler]),
470	,
471        [${TERMLIBS}])
472    AC_SEARCH_LIBS(rl_pending_signal, readline,
473	AC_DEFINE(HAVE_READLINE_PENDING_SIGNAL,1,[ Define if your libreadline has rl_pending_signal]),
474	,
475        [${TERMLIBS}])
476    # Warning: rl_complete_with_tilde_expansion is an int, not a function.
477    # I.e., it is not callable.  AC_CHECK_LIB seems to work anyhow, but...
478    AC_SEARCH_LIBS(rl_complete_with_tilde_expansion, readline, ,
479	AC_DEFINE(MISSING_RL_TILDE_EXPANSION,1,[ Define if your libreadline has no rl_complete_with_tilde_expansion]),
480        [${TERMLIBS}])
481
482    if [test "$ac_cv_lib_readline_remove_history" != no || test "$ac_cv_lib_history_remove_history" != no]; then
483      if test "$with_readline" = bsd; then
484          AC_DEFINE(HAVE_LIBEDITLINE,1,
485                [ Define if you are using the BSD editline library. ])
486      else
487          AC_DEFINE(HAVE_LIBREADLINE,1,
488                [ Define if you are using the GNU readline library. ])
489      fi
490      AC_CHECK_HEADERS(readline/readline.h,,
491        AC_MSG_WARN([found GNU readline library but not readline.h
492please add path to readline.h to CPPFLAGS in Makefile]))
493      AC_CHECK_HEADERS(readline/history.h,,
494        AC_MSG_WARN([found GNU readline library but not history.h
495please add path to history.h to CPPFLAGS in Makefile]))
496
497      if test "$enable_history_file" = yes; then
498          AC_DEFINE(GNUPLOT_HISTORY,1,
499                    [ Define if you want to use a gnuplot history file. ])
500      fi
501
502    fi # ! ac_cv_lib_readline_readline = no
503
504   fi # ! with_readline = bsd
505
506  fi # ! with_readline != builtin
507
508  if test "$with_readline" = builtin; then
509    AC_CHECK_FUNCS(wcwidth)
510    AC_CHECK_HEADERS(wchar.h,,
511        AC_MSG_WARN([please add path to wchar.h to CPPFLAGS in Makefile]))
512    AC_DEFINE(READLINE,1,
513              [ Define if you want to use the included readline function. ])
514    if test "$enable_history_file" = yes; then
515       AC_DEFINE(GNUPLOT_HISTORY,1,
516                [ Define if you want to use a gnuplot history file. ])
517    fi
518  fi
519
520  LIBS="$_libs"
521fi
522dnl end readline
523
524dnl check presence of z library
525dnl TODO: path to zlib includes; -lz -lm specified multiple times
526dnl       we don't do anything about missing png/gd includes either
527AC_CHECK_LIB(z,deflate,
528  [TERMLIBS="$TERMLIBS -lz"
529   AC_DEFINE(HAVE_LIBZ,1,[ Define if you have zlib. ])
530   AC_CHECK_HEADER(zlib.h,,
531     [AC_MSG_WARN([found z library but not zlib.h
532please add path to zlib.h to CPPFLAGS in Makefile])])],
533  AC_MSG_WARN([zlib is required - see http://www.gzip.org/zlib/]))
534
535dnl check presence of gd library
536dnl we don't check for libfreetype and libjpeg locations - if gd requires
537dnl them, the gdlib-config script or the gdlibc.pc contains all the required information
538AC_ARG_WITH(gd,dnl
539[  --with-gd[=DIR]           location of gd library (png jpeg gif terminals)],,
540  with_gd=yes)
541
542if test "$with_gd" != no; then
543  PKG_CHECK_MODULES_NOFAIL(libgd, [gdlib])
544  AC_PATH_PROG([GDLIB_CONFIG], [gdlib-config])
545  if test $pkg_failed == no && test -n "$GDLIB_CONFIG"; then
546    libgd_CPPFLAGS=`$GDLIB_CONFIG --cflags`
547    libgd_LDFLAGS=`$GDLIB_CONFIG --ldflags`
548    libgd_LIBS=`$GDLIB_CONFIG --libs`
549  elif test -d "$with_gd"; then
550    libgd_CPPFLAGS="-I$with_gd/include"
551    libgd_LDFLAGS="-L$with_gd/lib"
552    libgd_LIBS="-ljpeg -lpng -lfreetype -lz"
553  fi
554
555  _cppflags="$CPPFLAGS"
556  _ldflags="$LDFLAGS"
557  _libs="$LIBS"
558  CPPFLAGS="$CPPFLAGS $libgd_CPPFLAGS"
559  LDFLAGS="$LDFLAGS $libgd_LDFLAGS"
560  LIBS="$LIBS $libgd_LIBS"
561
562  AC_CHECK_LIB(gd,gdImageCreateTrueColor,
563    [dnl found gd library
564     AC_DEFINE(HAVE_LIBGD,1,[ Define if you have gd library. ])
565     AC_CHECK_HEADERS(gd.h,,
566       AC_MSG_WARN([please add path to gd.h to CPPFLAGS in Makefile]))
567
568     dnl gif support in libgd
569     AC_CHECK_LIB(gd,gdImageGif,
570       [AC_DEFINE(HAVE_GD_GIF,1,[ Define if libgd supports gif. ])])
571     AC_CHECK_LIB(gd,gdImageGifAnimBegin,
572       [AC_DEFINE(GIF_ANIMATION,1,[ Define if libgd supports animated gifs. ])])
573
574     dnl jpeg support in libgd
575     AC_CHECK_LIB(gd,gdImageJpeg,
576       [AC_DEFINE(HAVE_GD_JPEG,1,[ Define if libgd supports jpeg. ])])
577
578     dnl freetype support in libgd
579     AC_CHECK_LIB(gd,gdImageStringFT,
580       AC_DEFINE(HAVE_GD_TTF,1,
581           [ Define if libgd supports TrueType fonts through libfreetype. ]))
582
583     dnl png support in libgd
584     AC_CHECK_LIB(gd,gdImagePng,
585       [AC_DEFINE(HAVE_GD_PNG,1,[ Define if libgd supports png. ])])
586
587    ],[dnl gd library not found
588       AC_MSG_WARN([libgd not found or too old, version >= 2.0 is required])
589       with_gd=no
590    ])
591
592  dnl piece it all together
593  if test "$with_gd" = no; then
594    CPPFLAGS="$_cppflags"
595    LDFLAGS="$_ldflags"
596    LIBS="$_libs"
597  else
598    LIBS="$_libs"
599    TERMLIBS="$TERMLIBS -lgd $libgd_LIBS"
600  fi
601
602fi
603dnl end gd
604
605dnl The iconv library can be used to switch character encodings.
606dnl So far this is only used by gd.trm and emf.trm.
607AC_SEARCH_LIBS([iconv_open], [iconv],
608  [AC_CHECK_HEADER([iconv.h],
609    [AC_DEFINE([HAVE_ICONV], 1, [define if you have libiconv and iconv.h])]
610  )]
611)
612
613dnl check presence of lua/TikZ support
614AC_ARG_WITH(lua,dnl
615[  --without-lua           disable lua/TikZ terminal (default enabled)],,
616  [test -z "${with_lua}" && with_lua=yes])
617
618dnl Some distributions allow for parallel installation of different
619dnl lua versions.  We test for that in order of pereference.
620if test "${with_lua}" = yes ; then
621  LUA=lua
622  PKG_CHECK_MODULES([LUA], [lua], LUAFOUND=yes,
623    [PKG_CHECK_MODULES([LUA], [lua5.3], LUA=lua5.3,
624      [PKG_CHECK_MODULES([LUA], [lua5.2], LUA=lua5.2,
625        [PKG_CHECK_MODULES([LUA], [lua5.1], LUA=lua5.1,
626          [LUAFOUND=no])])])])
627  if test $pkg_failed != no; then
628    AC_MSG_WARN([Could not find support for lua using pkg-config.])
629    with_lua=no
630  fi
631
632  if test "$with_lua" != no; then
633    TERMLIBS="$TERMLIBS $LUA_LIBS"
634    CPPFLAGS="$CPPFLAGS $LUA_CFLAGS"
635  else
636    dnl if pkg-config didn't work, we migh still find it manually
637    AC_SEARCH_LIBS(luaL_openlibs, lua lua5.3 lua5.2 lua5.1,
638       with_lua=yes, with_lua=no)
639  fi
640  if test "$with_lua" = yes; then
641     AC_DEFINE(HAVE_LUA,1, [ Define if you want the lua/TikZ terminal. ])
642     AC_CHECK_HEADERS(lua.h,,
643       AC_MSG_WARN([please add path to lua.h to CPPFLAGS in Makefile]))
644  fi
645  AC_SUBST(LUA)
646fi
647AM_CONDITIONAL(BUILD_LUA, test "${with_lua}" = yes)
648dnl end lua
649
650dnl check presence of caca library
651AC_ARG_WITH(caca,dnl
652[  --with-caca[=DIR]         where to find the caca library],,
653  with_caca=no)
654
655if test "$with_caca" != no; then
656  if test -d "$with_caca"; then
657    dnl path to libcaca was specified manually
658    caca_CPPFLAGS="-I$with_caca/include"
659    caca_LDFLAGS="-L$with_caca/lib -Wl,-rpath -Wl,$with_caca/lib"
660    caca_LIBS="-lcaca"
661    with_caca=yes
662  else
663    dnl try to use pkg-config first
664    PKG_CHECK_MODULES(caca, [caca], [with_caca=yes], [with_caca=no])
665    if test $pkg_failed != no; then
666      dnl try to locate libcaca using its config tool
667      AC_PATH_PROG([CACA_CONFIG], [caca-config])
668      if test -n "$CACA_CONFIG"; then
669        caca_CPPFLAGS=`$CACA_CONFIG --cflags`
670        caca_LDFLAGS=`$CACA_CONFIG --ldflags`
671        caca_LIBS=`$CACA_CONFIG --libs`
672        with_caca=yes
673      else
674        dnl libcaca was not found
675        AC_MSG_WARN([libcaca not found or too old, version >= 0.99.beta15 is required])
676        with_caca=no
677      fi
678    fi
679  fi
680
681  dnl test usability
682  _cppflags="$CPPFLAGS"
683  _ldflags="$LDFLAGS"
684  CPPFLAGS="$caca_CPPFLAGS $CPPFLAGS"
685  LDFLAGS="$caca_LDFLAGS $LDFLAGS"
686  AC_CHECK_LIB(caca,caca_get_version,
687    [dnl found caca library, test for version >= 0.99.beta15 (libcucul merged back)
688     AC_CHECK_LIB([caca],[caca_export_canvas_to_memory],,
689       [AC_DEFINE(USE_CACA_EXPORT_MEMORY,1,[ Define if your libcaca does not have caca_export_canvas_to_memory but the old caca_export_memory])],[])
690     AC_CHECK_DECL([CACA_DEPRECATED],
691       [AC_DEFINE(HAVE_LIBCACA,1,[ Define if you have the caca library. ])],
692       [AC_MSG_WARN([libcaca header not found or too old, version >= 0.99.beta15 is required])
693        with_caca=no],
694       [[#include <caca.h>]])
695    ],
696    [dnl caca library not found
697       AC_MSG_WARN([libcaca not found or too old, version >= 0.99.beta15 is required])
698       with_caca=no
699    ])
700
701  dnl piece it all together
702  if test "$with_caca" = no; then
703    CPPFLAGS="$_cppflags"
704    LDFLAGS="$_ldflags"
705  else
706    TERMLIBS="$TERMLIBS $caca_LIBS"
707  fi
708fi
709dnl end caca
710
711dnl Process rest of with and enable options
712
713dnl Use .gnuplot file in current directory
714AC_ARG_WITH(cwdrc,dnl
715[  --with-cwdrc            check current directory for .gnuplot file,
716                          normally disabled for security reasons],,)
717if test "$with_cwdrc" = yes; then
718     AC_DEFINE(USE_CWDRC,1,
719               [ Define if you want to read .gnuplot from current directory (SECURITY RISK!).])
720fi
721
722dnl Sort help/subtopic tables by row or column
723AC_ARG_WITH(row-help,dnl
724[  --with-row-help         format help and subtopic tables by row (default)
725  --without-row-help      format help and subtopic tables by column],
726  [if test "$with_row_help" = no; then
727     AC_DEFINE(COLUMN_HELP,1,
728               [ Define if you want online help and subtopic tables sorted by column. ])
729   fi])
730
731dnl enable multi-byte font support in x11 terminal
732AC_ARG_ENABLE(x11-mbfonts,dnl
733[  --disable-x11-mbfonts   disable multi-byte font support for x11 ],,
734  test -z "$enable_x11_mbfonts" && enable_x11_mbfonts=yes)
735  if test "$enable_x11_mbfonts" = yes; then
736
737    _ldflags="$LDFLAGS"
738    LDFLAGS="$LDFLAGS $LIBRARIES_FOR_X"
739
740    AC_MSG_CHECKING([for multi-byte support in x11])
741    AC_CHECK_LIB(X11, XmbDrawString,
742      AC_DEFINE(USE_X11_MULTIBYTE,1,[ Define to enable multi-byte font support for x11 ]),
743      enable_x11_mbfonts=no )
744
745    LDFLAGS="$_ldflags"
746
747  fi
748
749dnl x11_external
750AC_ARG_ENABLE(x11_external,dnl
751[  --disable-x11-external  disable drawing to windows belonging to external apps],,
752  test -z "$enable_x11_external" && enable_x11_external=yes)
753
754if test "$enable_x11_external" = yes; then
755  AC_DEFINE(EXTERNAL_X11_WINDOW,1,[ Define if you want to supply pre-existing X11 windows. ])
756fi
757
758dnl disable the "space raises console" behaviour
759AC_ARG_ENABLE(raise-console,dnl
760[  --disable-raise-console spacebar in plot window does not raise console],,
761  test -z "$enable_raise_console" && enable_raise_console=yes)
762  if test "$enable_raise_console" != yes; then
763      AC_DEFINE(DISABLE_SPACE_RAISES_CONSOLE,1,
764                [ Define to treat spacebar like any other keystroke. ])
765  fi
766
767
768dnl  wxWidgets terminal
769
770dnl wxWidgets terminal needs C++
771dnl These tests cannot be called conditionally.
772dnl These tests are non-fatal on autoconf 2.58 and 2.59,
773dnl but it may change in future versions, so we redefine AC_MSG_ERROR.
774dnl Even if there is no C++ compiler on the system,
775dnl autoconf will set CXX as g++ : this must be reverted.
776
777m4_pushdef([AC_MSG_ERROR],[cxxerror=yes])
778AC_PROG_CXX
779m4_popdef([AC_MSG_ERROR])
780
781if test "x${cxxerror}" != "xyes"; then
782  AC_LANG_PUSH([C++])
783  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <iostream>]],
784	[[const char hw[] = "Hello, World\n"; std::cout << hw;]])],
785	[cxxerror=no
786	AC_PROG_CXXCPP],
787	[cxxerror=yes
788	CXX=$CC])
789  AC_LANG_POP([C++])
790fi
791
792AC_ARG_ENABLE(wxwidgets,dnl
793[  --disable-wxwidgets     wxWidgets terminal (default enabled)],,
794  [test -z "${enable_wxwidgets}" && enable_wxwidgets=yes])
795
796if test "${enable_wxwidgets}" = yes ; then
797  dnl variable used to determine if all checks pass
798  enable_wxwidgets_ok=yes
799
800  dnl Check for the C++ compiler
801  if test "x${cxxerror}" = "xyes"; then
802    AC_MSG_WARN([No C++ compiler found. The wxWidgets terminal will not be compiled.])
803      enable_wxwidgets_ok=no
804  fi
805
806  dnl The user can specify another path for wx-config
807  WXWIDGETS_PATH="${PATH}"
808  AC_ARG_WITH(wx,dnl
809  [--with-wx=DIR           Where to find wx-config, the wxWidgets configuration program
810    (default search in $PATH)],
811    [ if test "${with_wx}" != "no" ; then
812	WXWIDGETS_PATH="${with_wx}:${PATH}"
813     fi ])
814
815  dnl Look for wx-config in the path
816  AC_PATH_PROG(WX_CONFIG, wx-config, no, ${WXWIDGETS_PATH})
817  if test "${WX_CONFIG}" = "no"; then
818    AC_MSG_WARN([wxWidgets can't be found. You can try --with-wx=DIR to give the right path to wx-config. The wxWidgets terminal will not be compiled.])
819    enable_wxwidgets_ok=no
820  else
821
822    dnl Ckeck for wxWidgets version
823    WXWIDGETS_VERSION=`${WX_CONFIG} --release`
824    if expr 2.6 \> ${WXWIDGETS_VERSION} >/dev/null; then
825      AC_MSG_WARN([Your development package for wxWidgets is too old, you need at least version 2.6. The wxWidgets terminal will not be compiled.])
826      enable_wxwidgets_ok=no
827    fi
828    if expr ${WXWIDGETS_VERSION} \> 2.8 >/dev/null; then
829      AC_DEFINE(WX_NEEDS_XINITTHREADS, 1, [wxWidgets >= 2.9 wants calling program to invoke XInit()])
830    fi
831
832    dnl Make sure we're using more than the 'base' wxWidgets. Those
833    if expr `${WX_CONFIG} --basename` : '.*base' >/dev/null; then
834      AC_MSG_WARN([You only have the 'base' flavor of wxWidgets. A full wxWidgets library is required. On Debian/Ubuntu, please make sure that you have a 'libwx...-dev' package other than just 'libwxbase...-dev' installed. The wxWidgets terminal will not be compiled.])
835      enable_wxwidgets_ok=no
836    fi
837  fi
838
839  dnl Check for Cairo
840  PKG_CHECK_MODULES_NOFAIL(CAIROPANGO, [cairo >= 0.9.0 pango >= 1.22 pangocairo >= 1.10])
841  if test $pkg_failed != no; then
842    AC_MSG_WARN([The wxWidgets terminal will not be compiled.])
843    enable_wxwidgets_ok=no
844  fi
845fi
846
847if test "${enable_wxwidgets_ok}" = yes ; then
848  WX_CXXFLAGS="`$WX_CONFIG --cxxflags | sed 's/-fno-exceptions//'` $CAIROPANGO_CFLAGS"
849  WX_LIBS="`$WX_CONFIG --libs` $CAIROPANGO_LIBS $LIBRARIES_FOR_X"
850
851  dnl Check for fork(), used for the 'persist' effect
852  AC_FUNC_FORK
853
854  dnl Check if wxWidgets uses gtk on this platform
855  WX_TOOLKIT="`$WX_CONFIG --query-toolkit`"
856  if test "${WX_TOOLKIT}" = gtk2 ; then
857    PKG_CHECK_MODULES(GTK, [gtk+-2.0], have_gtk=yes, have_gtk=no)
858    want_gtk=yes
859  elif test "${WX_TOOLKIT}" = gtk3 ; then
860    PKG_CHECK_MODULES(GTK, [gtk+-3.0], have_gtk=yes, have_gtk=no)
861    want_gtk=yes
862  fi
863  if  test "${have_gtk}" = yes ; then
864    AC_DEFINE(HAVE_GTK, 1, [define if your wxWidgets uses the gtk toolkit])
865    WX_CXXFLAGS="$WX_CXXFLAGS $GTK_CFLAGS"
866    WX_LIBS="$WX_LIBS $GTK_LIBS"
867  fi
868
869  dnl Default to single-threaded
870  AC_ARG_WITH(wx-multithreaded, dnl
871  [--with-wx-multithreaded  use multithreaded wxgtk (known problems, not recommended)],
872  , WX_CXXFLAGS="$WX_CXXFLAGS -DWXT_MONOTHREADED"
873  )
874
875  CPPFLAGS="$CPPFLAGS $CAIROPANGO_CFLAGS"
876  CXXFLAGS="$CXXFLAGS $WX_CXXFLAGS"
877  AC_SUBST(WX_LIBS)
878  AC_DEFINE(WXWIDGETS, 1, [ Define if you want the wxwidgets terminal. ])
879fi
880
881AM_CONDITIONAL(BUILD_WXWIDGETS, test "${enable_wxwidgets_ok}" = yes)
882
883dnl  End wxWidgets terminal
884
885dnl  Allow to disable terminals requiring bitmap support.
886AC_ARG_WITH(bitmap_terminals,dnl
887[  --with-bitmap-terminals  dot-matrix printers and pbm])
888AS_IF([test "x${with_bitmap_terminals}" = "xyes"],,
889  AC_DEFINE(NO_BITMAP_SUPPORT,1,
890          [ Define to disable terminals that depend on code in bitmap.c ]))
891AM_CONDITIONAL(BUILD_BITMAP, test "${with_bitmap_terminals}" = yes)
892
893dnl  Allow to disable support for tektronix terminal emulators
894AC_ARG_WITH(tektronix,dnl
895[  --without-tektronix      tektronix terminal emulators (default enabled)])
896AS_IF([test "x${with_tektronix}" != "xno"],
897  AC_DEFINE(WITH_TEKTRONIX,1,
898          [ Define to include support for tektronix terminal emulators ],))
899
900dnl  Allow to include gpic terminal
901AC_ARG_WITH(gpic,dnl
902[  --with-gpic              gpic terminal])
903AS_IF([test "x${with_gpic}" = "xyes"],
904  AC_DEFINE(HAVE_GPIC,1,
905          [ Define to include support for gpic terminal ],))
906
907dnl  Allow to include tgif terminal
908AC_ARG_WITH(tgif,dnl
909[  --with-tgif              tgif terminal])
910AS_IF([test "x${with_tgif}" = "xyes"],
911  AC_DEFINE(HAVE_TGIF,1,
912          [ Define to include support for tgif terminal ],))
913
914dnl  Allow to include mif (FrameMaker 3) terminal
915AC_ARG_WITH(mif,dnl
916[  --with-mif               mif terminal (FrameMaker 3)])
917AS_IF([test "x${with_mif}" = "xyes"],
918  AC_DEFINE(HAVE_MIF,1,
919          [ Define to include support for mif terminal ],))
920
921dnl ReGIS terminal
922AC_ARG_WITH(regis,dnl
923[  --with-regis             ReGIS terminal])
924AS_IF([test "x${with_regis}" = "xyes"],
925  AC_DEFINE(HAVE_REGIS,1,
926          [ Define to include support for ReGIS terminal ],))
927
928AC_ARG_WITH(cairo,dnl
929[  --without-cairo          cairo-based terminals (default enabled)],,
930  [test -z "${with_cairo}" && with_cairo=yes])
931
932if test "${with_cairo}" = yes ; then
933  dnl cairo terminals
934  PKG_CHECK_MODULES_NOFAIL(CAIROPDF,dnl
935       [cairo >= 1.2 cairo-pdf >= 1.2 pango >= 1.22 pangocairo >= 1.10 glib-2.0 >= 2.28])
936  if test $pkg_failed != no; then
937    AC_MSG_WARN([The cairo terminals will not be compiled.])
938    with_cairo=no
939  else
940    AC_DEFINE(HAVE_CAIROPDF,1, [ Define if you want the cairo-based terminals. ])
941    CPPFLAGS="$CPPFLAGS $CAIROPDF_CFLAGS"
942    LIBS="$LIBS $CAIROPDF_LIBS"
943    with_cairo=yes
944    PKG_CHECK_MODULES(CAIROEPS, [cairo >= 1.6.0],
945        AC_DEFINE([HAVE_CAIROEPS], 1, [libcairo support for eps (cairo >= 1.6)]),
946        AC_MSG_WARN([Your version of cairo is too old to support epscairo output]))
947  fi
948fi
949
950build_gpcairo=no
951if test "${enable_wxwidgets_ok}" = yes; then
952  build_gpcairo=yes
953fi
954if test "${with_cairo}" = yes; then
955  build_gpcairo=yes
956fi
957
958AM_CONDITIONAL(BUILD_GPCAIRO, test "${build_gpcairo}" = yes)
959
960dnl Enable subsystem to generate statistical summary of file contents
961AC_ARG_ENABLE(stats,dnl
962[  --disable-stats         Omit calculation of statistical summary of data],
963  [if test "$enableval" != no; then
964    AC_DEFINE(USE_STATS,1,
965               [ Define to add support for generating a statistical summary of data])
966   fi],
967    AC_DEFINE(USE_STATS,1,
968               [ Define to add support for generating a statistical summary of data])
969   )
970
971dnl Enable parsing of deprecated syntax
972dnl AC_ARG_ENABLE(backwards-compatibility,dnl
973dnl [  --enable-backwards-compatibility       enable deprecated syntax ],
974dnl   [if test "$enableval" = yes; then
975dnl     AC_DEFINE(BACKWARDS_COMPATIBLE,1,
976dnl                [ Define to allow use of certain deprecated syntax. ])
977dnl   fi])
978
979dnl Qt terminal
980
981AC_ARG_WITH(qt,dnl
982[  --with-qt [=qt4 =qt5 =no]  Qt terminal (default autodetect)],
983  [if test "x${with_qt}" != "xno"; then
984     enable_qt=yes;
985   fi],
986  enable_qt=yes)
987
988if test "${enable_qt}" = yes ; then
989  dnl variable used to determine if all checks pass
990  enable_qt_ok=yes
991
992  dnl Check for the C++ compiler
993  if test "x${cxxerror}" = "xyes"; then
994    AC_MSG_WARN([No C++ compiler found. The Qt terminal will not be compiled.])
995      enable_qt_ok=no
996  fi
997
998  dnl First check for Qt5
999  if test "x${with_qt}" = "xqt5"; then
1000    try_qt4=no
1001  else
1002    try_qt4=yes
1003  fi
1004  if test "x${with_qt}" != "xqt4"; then
1005    PKG_CHECK_MODULES_NOFAIL(QT, [Qt5Core Qt5Gui Qt5Network Qt5Svg Qt5PrintSupport])
1006    if test $pkg_failed = no; then
1007      try_qt4=no
1008      QT5LOC=`$PKG_CONFIG --variable=host_bins Qt5Core`
1009      if test "x${QT5LOC}" != "x"; then
1010        UIC=${QT5LOC}/uic
1011        MOC=${QT5LOC}/moc
1012        RCC=${QT5LOC}/rcc
1013        LRELEASE=${QT5LOC}/lrelease
1014      fi
1015      CXXFLAGS="$CXXFLAGS -fPIC"
1016    fi
1017  fi
1018
1019  dnl No Qt5, check for Qt4.5 or greater
1020  if test ${try_qt4} != no; then
1021    PKG_CHECK_MODULES_NOFAIL(QT, [QtCore >= 4.5 QtGui >= 4.5 QtNetwork >= 4.5 QtSvg >= 4.5])
1022    if test $pkg_failed != no; then
1023      enable_qt_ok=no
1024      AC_MSG_RESULT([The Qt terminal will not be compiled.])
1025    else
1026      QT4LOC=`$PKG_CONFIG --variable=exec_prefix QtCore`
1027      UIC=`$PKG_CONFIG --variable=uic_location QtCore`
1028      MOC=`$PKG_CONFIG --variable=moc_location QtCore`
1029      RCC=`$PKG_CONFIG --variable=rcc_location QtCore`
1030      LRELEASE=`$PKG_CONFIG --variable=lrelease_location QtCore`
1031      AC_MSG_RESULT([The Qt terminal will use Qt4.])
1032      QTVER="4"
1033    fi
1034  else
1035    AC_MSG_RESULT([The Qt terminal will use Qt5.])
1036    QTVER="5"
1037  fi
1038fi
1039
1040if test "${enable_qt_ok}" = yes ; then
1041  dnl Check for fork()
1042  AC_FUNC_FORK
1043
1044  CPPFLAGS="$CPPFLAGS $QT_CFLAGS"
1045  CXXFLAGS="$CXXFLAGS $QT_CXXFLAGS"
1046
1047  if test x"$MOC" = x; then
1048    MOC=moc
1049  fi
1050  if test x"$UIC" = x; then
1051    UIC=uic
1052  fi
1053  if test x"$RCC" = x ; then
1054    if test x"$QT4LOC" != x ; then
1055        RCC=$QT4LOC/bin/rcc
1056    else
1057        RCC=rcc
1058    fi
1059  fi
1060  if test x"$LRELEASE" = x ; then
1061    if test x"$QT4LOC" != x ; then
1062        LRELEASE=$QT4LOC/bin/lrelease
1063    else
1064        LRELEASE=lrelease
1065    fi
1066  fi
1067  AC_SUBST(RCC)
1068  AC_SUBST(MOC)
1069  AC_SUBST(UIC)
1070  AC_SUBST(QT_LIBS)
1071  AC_SUBST(LRELEASE)
1072  AC_DEFINE(QTTERM,1, [ Define if you want the Qt terminal. ])
1073  AC_DEFINE_UNQUOTED(QTVER,$QTVER,[ only used for docs])
1074fi
1075AM_CONDITIONAL(BUILD_QT, test "${enable_qt_ok}" = yes)
1076
1077dnl build mouse support if any mouse-requiring terminal is selected
1078if test "${enable_qt_ok}" = yes \
1079  || test "${enable_wxwidgets_ok}" = yes \
1080  || test "$GGI_SUPPORT" = yes \
1081  || test "$no_x" != yes; then
1082    enable_mouse=yes;
1083fi
1084
1085if test "$enable_mouse" = yes; then
1086  AC_DEFINE(USE_MOUSE,1,
1087            [ Define if you have interactive terminals that use mouse support. ])
1088  AC_DEFINE(PIPE_IPC,1,
1089            [ Unix-type of Interprocess Communication is required for mouse support. ])
1090fi
1091
1092dnl translation tools
1093AM_CONDITIONAL(HAVE_LRELEASE, test "${LRELEASE}" != no)
1094
1095AC_ARG_VAR(DIST_CONTACT,[Contact address for modified and binary distributed gnuplot versions])
1096if test -n "${DIST_CONTACT}"; then
1097  AC_DEFINE_UNQUOTED([DIST_CONTACT],["$DIST_CONTACT"],[Contact address for modified and binary distributed gnuplot versions])
1098fi
1099
1100dnl Substitute variables
1101AC_SUBST(PACKAGE)
1102AC_SUBST(VERSION_MAJOR)
1103AC_SUBST(VERSION)
1104AC_SUBST(PATCHLEVEL)
1105AC_SUBST(GIHDIR)
1106AC_SUBST(TEXDIR)
1107AC_SUBST(TERMLIBS)
1108AC_SUBST(TERMXLIBS)
1109
1110dnl Write Makefiles and configuration header
1111AC_CONFIG_FILES([Makefile
1112           config/Makefile
1113           demo/Makefile
1114           demo/plugin/Makefile
1115           docs/Makefile
1116           m4/Makefile
1117           man/Makefile
1118           share/Makefile
1119           share/LaTeX/Makefile
1120           src/Makefile
1121           src/beos/Makefile
1122           src/wxterminal/Makefile
1123           src/qtterminal/Makefile
1124           term/Makefile])
1125AC_CONFIG_COMMANDS([default],[test -z "$CONFIG_HEADERS" || echo timestamp >stamp-h],[])
1126AC_OUTPUT
1127
1128dnl Report configuration
1129dnl Rationale:
1130dnl - if something is disabled by default, show arguments to use to enable.
1131dnl - if something has particular dependencies, show them all when they are
1132dnl missing (the detailed output will give more details anyway).
1133dnl The goal is to give sensible and easily accessible information to users
1134dnl and packagers.
1135
1136AC_MSG_RESULT([])
1137AC_MSG_RESULT([** Configuration summary for $PACKAGE $VERSION:])
1138AC_MSG_RESULT([])
1139
1140AC_MSG_RESULT([gnuplot will be compiled with the following terminals:])
1141AC_MSG_RESULT([])
1142
1143AC_MSG_RESULT([  Standalone terminals: yes (included by default)])
1144AC_MSG_RESULT([    canvas, cgm, context, dumb, dxf, emf, epslatex,])
1145AC_MSG_RESULT([    fig, hpgl, metafont, metapost, pcl5, postscript,])
1146AC_MSG_RESULT([    pict2e, pslatex, pstex, pstricks, svg, texdraw, tkcanvas])
1147AC_MSG_RESULT([])
1148
1149if test "$with_bitmap_terminals" == yes; then
1150  AC_MSG_RESULT([  dot-matrix terminals: yes ( --without-bitmap-terminals to disable)])
1151else
1152  AC_MSG_RESULT([  dot-matrix terminals: no (use --with-bitmap-terminals to enable)])
1153fi
1154AC_MSG_RESULT([    epson, nec, okidata, tandy, and seiko dp414 printers])
1155AC_MSG_RESULT([    hp500c, hpdj, hpljii, hppj, pbm, sixel, starc])
1156AC_MSG_RESULT([])
1157
1158if test "$with_tektronix" == no; then
1159  AC_MSG_RESULT([  tektronix terminal emulators: no ( --with-tektronix to enable)])
1160else
1161  AC_MSG_RESULT([  tektronix terminal emulators: yes ( --without-tektronix to disable)])
1162fi
1163AC_MSG_RESULT([    tek410x tek40 vttek xterm kc_tek40 km_tek40 selanar sixeltek bitgraph])
1164AC_MSG_RESULT([    note: not needed for sixel graphics output to vt100-series emulators])
1165
1166AC_MSG_RESULT([])
1167AC_MSG_RESULT([  Platform-specific, legacy, or specialized terminals omitted by default:])
1168
1169if test "$GGI_SUPPORT" = yes; then
1170  if test "$ac_cv_header_ggi_xmi_h" = yes; then
1171    AC_MSG_RESULT([    ggi terminal: yes (with pm3d support)])
1172  else
1173    AC_MSG_RESULT([    ggi terminal: yes (no pm3d support, requires ggi xmi library)])
1174  fi
1175else
1176  AC_MSG_RESULT([    ggi terminal:  no   (use --with-ggi to enable, requires libggi)])
1177fi
1178
1179if test "$with_gpic" == yes; then
1180  AC_MSG_RESULT([    gpic terminal: yes])
1181else
1182  AC_MSG_RESULT([    gpic terminal: no   (use --with-gpic to enable)])
1183fi
1184
1185if test "$with_tgif" == yes; then
1186  AC_MSG_RESULT([    tgif terminal: yes])
1187else
1188  AC_MSG_RESULT([    tgif terminal: no   (use --with-tgif to enable)])
1189fi
1190
1191if test "$with_mif" == yes; then
1192  AC_MSG_RESULT([    mif terminal (FrameMaker 3): yes])
1193else
1194  AC_MSG_RESULT([    mif terminal (FrameMaker 3): no   (use --with-mif to enable)])
1195fi
1196
1197if test "$with_regis" = yes; then
1198  AC_MSG_RESULT([    ReGIS terminal: yes])
1199else
1200  AC_MSG_RESULT([    ReGIS terminal: no  (use --with-regis to enable)])
1201fi
1202
1203if test "$is_msdos" = yes; then
1204  AC_MSG_RESULT([    svga terminal (MSDOS/djgpp): yes])
1205fi
1206
1207if test "$build_src_beos_subdir" = yes; then
1208  AC_MSG_RESULT([    be terminal (BeOS): yes])
1209fi
1210
1211if test "$with_caca" = yes; then
1212  AC_MSG_RESULT([    caca terminal: yes (EXPERIMENTAL)])
1213else
1214  AC_MSG_RESULT([    caca terminal:  no   (use --with-caca to enable)])
1215fi
1216
1217if test "$gnuplot_framework_AquaTerm" = yes; then
1218  AC_MSG_RESULT([    aqua terminal (OSX): yes])
1219else
1220  AC_MSG_RESULT([    aqua terminal (OSX): no])
1221fi
1222
1223AC_MSG_RESULT([])
1224AC_MSG_RESULT([  Other terminals that can be enabled but have no ./configure option:])
1225AC_MSG_RESULT([    eepic, emtex, hp2623a, hp2648, imagen, kyocera, latex, qms, tpic ])
1226AC_MSG_RESULT([    pm (makefile.os2), be (BeOS), svga (MSDOS/djgpp), windows])
1227
1228dnl These are the most common interactive terminal options
1229AC_MSG_RESULT([])
1230if test "$no_x" != yes; then
1231  if test "$enable_x11_mbfonts" = yes; then
1232    AC_MSG_RESULT([  X Window System terminal: yes  (multi-byte fonts OK)])
1233  else
1234    AC_MSG_RESULT([  X Window System terminal: yes  (multi-byte fonts not supported)])
1235  fi
1236
1237  if test "$enable_x11_external" = yes; then
1238    AC_MSG_RESULT([    (enable plotting to windows opened by external apps) ])
1239  else
1240    AC_MSG_RESULT([    (disable plotting to windows opened by external apps) ])
1241  fi
1242
1243  if test "$with_x_dcop" = yes; then
1244    AC_MSG_RESULT([    (gnuplot_x11 can use KDE3/DCOP to raise konsole) ])
1245  fi
1246else
1247  AC_MSG_RESULT([  X Window System terminal: no (requires X libraries)])
1248fi
1249
1250if test "$ac_cv_lib_gd_gdImageJpeg" = yes &&
1251   test "$ac_cv_lib_gd_gdImagePng" = yes &&
1252   test "$ac_cv_lib_gd_gdImageGif" = yes; then
1253    if test "$ac_cv_lib_gd_gdImageGifAnimBegin" = yes; then
1254      AC_MSG_RESULT([  libgd-based png, jpeg, and gif terminals: yes (with animated gif)])
1255    else
1256      AC_MSG_RESULT([  libgd-based png, jpeg, and gif terminals: yes (no animated gif)])
1257    fi
1258else
1259    AC_MSG_RESULT([  libgd-based png, jpeg, and gif terminals: no (requires libgd,  see config.log) ])
1260fi
1261
1262if test "$with_cairo" = yes; then
1263  AC_MSG_RESULT([  cairo-based pdf and png terminals: yes ])
1264else
1265  AC_MSG_RESULT([  cairo-based terminals: no (requires cairo>=1.2, pango>=1.22, glib>=2.28)])
1266fi
1267
1268if test "$with_lua" = yes; then
1269  AC_MSG_RESULT([  lua/TikZ terminal: yes ])
1270else
1271  AC_MSG_RESULT([  lua/TikZ terminal: no ])
1272fi
1273
1274if test "$enable_wxwidgets_ok" = yes; then
1275  if test "$with_wx_multithreaded" = yes; then
1276    AC_MSG_RESULT([  wxt terminal: yes (multithreaded)])
1277  else
1278    AC_MSG_RESULT([  wxt terminal: yes ])
1279  fi
1280else
1281  AC_MSG_RESULT([  wxt terminal: no (requires C++, wxWidgets>2.6, cairo>0.9, pango>1.22)])
1282fi
1283
1284if test "$enable_qt_ok" = yes; then
1285  if test "$QTVER" = 4; then
1286      AC_MSG_RESULT([  Qt terminal: yes (qt4)])
1287  fi
1288  if test "$QTVER" = 5; then
1289      AC_MSG_RESULT([  Qt terminal: yes (qt5)])
1290  fi
1291else
1292  AC_MSG_RESULT([  Qt terminal: no (use --with-qt or --with-qt=qt4 to enable])
1293fi
1294
1295AC_MSG_RESULT([])
1296AC_MSG_RESULT([gnuplot will be compiled with the following configurable features:])
1297AC_MSG_RESULT([])
1298
1299if test "$enable_mouse" = yes; then
1300  AC_MSG_RESULT([  Mouse support in interactive terminals: yes])
1301else
1302  AC_MSG_RESULT([  Mouse support in interactive terminals: no])
1303fi
1304
1305if test "$enable_raise_console" = yes; then
1306  AC_MSG_RESULT([  Typing <space> in plot window raises console: yes])
1307else
1308  AC_MSG_RESULT([  Typing <space> in plot window raises console: no])
1309fi
1310
1311if test "$with_readline" = no; then
1312  AC_MSG_RESULT([  No readline support (use --with-readline=gnu or --with-readline=builtin)])
1313fi
1314
1315  if test "$with_readline" = bsd; then
1316    if test -n "$gp_tcap"; then
1317      AC_MSG_RESULT([  Readline library: BSD editline with $gp_tcap])
1318    else
1319      AC_MSG_RESULT([  Readline library: BSD editline library])
1320    fi
1321    AC_MSG_RESULT(  [           WARNING:     editline cannot handle multi-byte characters!])
1322  else if test "$with_readline" != builtin; then
1323    if test -n "$gp_tcap"; then
1324      AC_MSG_RESULT([  Readline library: GNU readline library with $gp_tcap])
1325    else
1326      AC_MSG_RESULT([  Readline library: GNU readline library])
1327    fi
1328    if test "$ac_cv_lib_readline_rl_forced_update_display" = no; then
1329      AC_MSG_RESULT([                    missing some features (OSX version?)])
1330    fi
1331  else
1332    AC_MSG_RESULT([  Readline library: builtin minimal (use --with-readline=gnu for GNU readline)])
1333  fi
1334fi
1335
1336if test "$enable_history_file" = yes; then
1337  AC_MSG_RESULT([  Command-line history file: yes])
1338else
1339  AC_MSG_RESULT([  Command-line history file: no])
1340fi
1341
1342if test "$with_cwdrc" = yes; then
1343  AC_MSG_RESULT([  Check current directory for .gnuplot file: yes (warning: security risk)])
1344else
1345  AC_MSG_RESULT([  Check current directory for .gnuplot file: no (use --with-cwdrc to enable)])
1346fi
1347
1348if test "$with_row_help" = no; then
1349  AC_MSG_RESULT([  Sort help/subtopic tables by column: yes])
1350else
1351  AC_MSG_RESULT([  Sort help/subtopic tables by column: no (use --without-row-help to enable)])
1352fi
1353
1354if test "$have_libcerf" = yes; then
1355  AC_MSG_RESULT([  cerf() and other special functions from libcerf: yes])
1356else
1357  AC_MSG_RESULT([  cerf() and other special functions: no (libcerf not found)])
1358fi
1359
1360if test "$have_external_functions" = yes; then
1361  AC_MSG_RESULT([  plugin support for loading external functions: yes ])
1362else
1363  AC_MSG_RESULT([  plugin support for loading external functions: no ])
1364fi
1365
1366if test "$with_kpsexpand" = yes; then
1367  AC_MSG_RESULT([  Use TeX kpsexpand to search for fonts: yes])
1368else
1369  AC_MSG_RESULT([  Use TeX kpsexpand to search for fonts: no (use --with-kpsexpand to enable)])
1370fi
1371
1372dnl if test "$enable_backwards_compatibility" = yes; then
1373dnl   AC_MSG_RESULT([  Allow deprecated syntax: yes])
1374dnl else
1375dnl   AC_MSG_RESULT([  Allow deprecated syntax: no (use --enable-backwards-compatibility)])
1376dnl fi
1377
1378if test "$enable_stats" != no; then
1379  AC_MSG_RESULT([  Statistical summary of data ("stats" command): yes])
1380else
1381  AC_MSG_RESULT([  Statistical summary of data ("stats" command): no (use --enable-stats to enable)])
1382fi
1383
1384
1385AC_MSG_RESULT([])
1386AC_MSG_RESULT([gnuplot will install the following additional materials:])
1387AC_MSG_RESULT([])
1388
1389if test "$with_latex" != no; then
1390  AC_MSG_RESULT([  TeX files will be installed in $TEXDIR])
1391  AC_MSG_RESULT([                               (use --with-texdir=DIR to change)])
1392else
1393  AC_MSG_RESULT([  TeX files will not be installed])
1394fi
1395AC_MSG_RESULT([  PostScript prologue files: $GIHDIR/PostScript/])
1396AC_MSG_RESULT([  Help file: $GIHDIR/gnuplot.gih])
1397
1398AC_MSG_RESULT([])
1399
1400dnl end config report
1401
1402dnl end configure.in
1403