1
2#--------------------------------------------------------------------
3#
4# MODULE      : configure.in
5# DESCRIPTION : TeXmacs configuration file for autoconf
6# COPYRIGHT   : (C) 2000  Joris van der Hoeven
7#
8# This software falls under the GNU general public license version 3 or later.
9# It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
10# in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
11#
12#--------------------------------------------------------------------
13
14AC_INIT
15AC_CONFIG_HEADERS([src/System/config.h:src/System/config.in])
16AC_CANONICAL_HOST
17
18#--------------------------------------------------------------------
19# Retrieve SVN revision number from working dir or fallback file
20#--------------------------------------------------------------------
21
22AC_MSG_CHECKING(current Subversion revision number)
23SVNREV=`svnversion -n . 2>/dev/null`
24SVNREV=${SVNREV/:/_}
25if { test "$SVNREV" = "" || test "$SVNREV" = "exported" ; } ; then
26  SVNREV=`cat $srcdir/SVNREV`
27  AC_MSG_RESULT($SVNREV, read from $srcdir/SVNREV)
28else
29  echo "$SVNREV" > $srcdir/SVNREV
30  AC_MSG_RESULT($SVNREV)
31fi
32
33AC_SUBST(SVNREV)
34
35#--------------------------------------------------------------------
36# Export version and package name
37#--------------------------------------------------------------------
38
39PACKAGE="TeXmacs"
40DEBIAN_NAME="texmacs"
41DEVEL_VERSION="1.99.4"
42DEVEL_RELEASE="1"         # I think we should use SVNREV here
43STABLE_VERSION="1.99.4"
44STABLE_RELEASE="1"
45
46DEVEL_VERSION_MAJOR="1"   #testing
47DEVEL_VERSION_MINOR="8"
48AC_SUBST(DEVEL_VERSION_MINOR)
49AC_SUBST(DEVEL_VERSION_MAJOR)
50
51AC_SUBST(PACKAGE)
52AC_SUBST(DEVEL_VERSION)
53AC_SUBST(DEVEL_RELEASE)
54AC_SUBST(STABLE_VERSION)
55AC_SUBST(STABLE_RELEASE)
56
57#--------------------------------------------------------------------
58# Checks for C++ compiler
59#--------------------------------------------------------------------
60
61AC_PROG_CC
62AC_PROG_CXX
63AC_PROG_OBJC([clang gcc])
64AC_PROG_OBJCXX([clang++ g++])
65AC_LANG_CPLUSPLUS
66AH_TEMPLATE([OLD_GNU_COMPILER],[Use g++ strictly prior to g++ 3.0])
67AC_MSG_CHECKING(whether GNU C++ compiler is default)
68case "$GXX" in
69  yes )
70    GCC_VERSION=`$CC -dumpversion`
71    GXX_VERSION=`$CXX -dumpversion`
72    AC_MSG_RESULT(yes)
73    AC_MSG_CHECKING(version of gcc)
74    AC_MSG_RESULT($GCC_VERSION)
75    AC_MSG_CHECKING(version of g++)
76    AC_MSG_RESULT($GXX_VERSION)
77    case "$GXX_VERSION" in
78      0* | 1* | 2*)
79        echo "old style GNU compiler"
80        AC_DEFINE([OLD_GNU_COMPILER],[])
81      ;;
82    esac
83  ;;
84  *)
85    GCC_VERSION="none"
86    GXX_VERSION="none"
87    AC_MSG_RESULT(no)
88    AC_MSG_WARN(cannot find GNU C++ compiler)
89  ;;
90esac
91AC_CPLUSPLUS_STACK
92
93#--------------------------------------------------------------------
94# Checks for Guile
95#--------------------------------------------------------------------
96
97AC_ARG_ENABLE(guile2,
98[  --enable-guile2         enable compilation with Guile 2, for development purposes],
99    [], [enable_guile2="no"])
100
101if test -z "$GUILE_CFLAGS" -a -z "$GUILE_LDFLAGS"; then
102  GUILE_FLAGS
103fi
104
105AC_MSG_CHECKING(version of guile)
106if test -z "$GUILE_EFFECTIVE_VERSION" ; then
107  GUILE_EFFECTIVE_VERSION=`$GUILE_BIN -c '(display (version))'`
108fi
109AC_MSG_RESULT($GUILE_EFFECTIVE_VERSION)
110
111case "$GUILE_EFFECTIVE_VERSION" in
112  1.0* | 1.1* | 1.2* | 1.3* | 1.4* | 1.5*)
113    CONFIG_GUILE_SERIAL="A"
114  ;;
115  1.6* | 1.7*)
116    CONFIG_GUILE_SERIAL="B"
117  ;;
118  2.*)
119    CONFIG_GUILE_SERIAL="D"
120    if test "$enable_guile2" != "yes"; then
121      AC_MSG_ERROR([TeXmacs is incompatible with Guile 2.
122If you know what you are doing, run configure with --enable-guile2=yes])
123    fi
124  ;;
125  *)
126    CONFIG_GUILE_SERIAL="C"
127  ;;
128esac
129
130AC_MSG_CHECKING(guile data path)
131if test -z "$GUILE_DATA_PATH" ; then
132  GUILE_DATA_PATH=`$GUILE_CONFIG info pkgdatadir`
133fi
134AC_MSG_RESULT($GUILE_DATA_PATH)
135
136AC_SUBST(GUILE_BIN)
137AC_SUBST(CONFIG_GUILE_SERIAL)
138AC_SUBST(GUILE_DATA_PATH)
139
140#--------------------------------------------------------------------
141# Checks for standard functionality
142#--------------------------------------------------------------------
143
144CPP_X_HEADERS
145AC_CHECK_TYPES(FILE)
146AC_CHECK_TYPES(intptr_t)
147AC_CHECK_TYPES(time_t)
148AC_PATH_X
149AC_PATH_XTRA
150AC_CHECK_HEADERS(pty.h util.h)
151AC_CHECK_FUNCS(gettimeofday)
152
153#--------------------------------------------------------------------
154# Checks for dl library
155#--------------------------------------------------------------------
156
157AC_CHECK_FUNC(dlopen)
158if test "$ac_cv_func_dl" = "yes"; then
159  AC_DEFINE(DYNAMIC_LINKING, 1, [Dynamic linking works])
160else
161  AC_CHECK_LIB(dl,dlopen)
162  if test "$ac_cv_lib_dl_dlopen" = "yes"; then
163    AC_CHECK_FUNCS(dlopen)
164    CONFIG_BDL="-ldl"
165    AC_DEFINE(DYNAMIC_LINKING, 1, [Dynamic linking works])
166  else
167    AC_CHECK_LIB(dld,dld_link)
168    if test "$ac_cv_lib_dld_dld_link" = "yes"; then
169      CONFIG_BDL="-ldl"
170      AC_DEFINE(DYNAMIC_LINKING, 1, [Dynamic linking works])
171    else
172      AC_CHECK_FUNCS(shl_load)
173      if test "$ac_cv_func_shl_load" = "yes"; then
174        CONFIG_BDL="-ldl"
175        AC_DEFINE(DYNAMIC_LINKING, 1, [Dynamic linking works])
176      else
177        AC_CHECK_FUNCS(dlopen)
178        if test "$ac_cv_func_dlopen" = "yes"; then
179          AC_DEFINE(DYNAMIC_LINKING, 1, [Dynamic linking works])
180        fi
181      fi
182    fi
183  fi
184fi
185AC_SUBST(CONFIG_BDL)
186
187#--------------------------------------------------------------------
188# Checks for iconv library
189#--------------------------------------------------------------------
190
191AC_ARG_WITH(iconv,
192AS_HELP_STRING([--with-iconv@<:@=DIR@:>@], [where to find iconv [system]]))
193
194# Check for iconv
195# Modified from GNOME's libxml2 configure.in
196AC_LANG_SAVE
197AC_LANG_C  # compile C to avoid the 'const char**' problem
198
199SAVE_CPPFLAGS="$CPPFLAGS"
200SAVE_LDFLAGS="$LDFLAGS"
201SAVE_LIBS="$LIBS"
202if test "$with_iconv" = "no" ; then
203    AC_MSG_RESULT([disabling iconv support])
204else
205    if test -n "$ICONV_CFLAGS" -a -n "$ICONV_LDFLAGS"; then
206       CPPFLAGS="$ICONV_CFLAGS" # for AC_TRY_LINK
207       LDFLAGS="$ICONV_LDFLAGS"
208    fi
209    if test "$with_iconv" != "yes" -a "$with_iconv" != "" ; then
210       CPPFLAGS="-I$with_iconv/include" # for AC_TRY_LINK
211       LDFLAGS="-L$with_iconv/lib"
212       ICONV_CFLAGS="-I$with_iconv/include"
213       ICONV_LDFLAGS="-L$with_iconv/lib"
214    fi
215
216    AC_CHECK_HEADER(iconv.h,
217    AC_MSG_CHECKING(for iconv)
218    AC_TRY_LINK(
219[
220#include <stdlib.h>
221#include <iconv.h>
222],[
223    iconv_t cd = iconv_open ("","");
224    iconv (cd, NULL, NULL, NULL, NULL);
225],[
226    AC_MSG_RESULT(yes)
227    AC_DEFINE(USE_ICONV, 1, [Use iconv library])
228],[
229    AC_MSG_RESULT(no)
230    AC_MSG_CHECKING(for iconv in -liconv)
231#    LDFLAGS="${ICONV_LDFLAGS}"    # for AC_TRY_LINK
232    LIBS="-liconv"                # for AC_TRY_LINK
233    AC_TRY_LINK(
234[
235#include <stdlib.h>
236#include <iconv.h>
237],[
238      iconv_t cd = iconv_open ("","");
239      iconv (cd, NULL, NULL, NULL, NULL);
240],[
241      AC_MSG_RESULT(yes)
242      AC_DEFINE(USE_ICONV, 1, [Use iconv library])
243      ICONV_LDFLAGS="${ICONV_LDFLAGS/-liconv} -liconv"
244],[
245      AC_MSG_RESULT(no)
246      AC_MSG_WARN([absence of iconv may crash HTML import])
247  ])]))
248fi
249
250CPPFLAGS="$SAVE_CPPFLAGS"
251LDFLAGS="$SAVE_LDFLAGS"
252LIBS="$SAVE_LIBS"
253AC_LANG_RESTORE  # restore C++ language
254AC_SUBST(ICONV_CFLAGS)
255AC_SUBST(ICONV_LDFLAGS)
256
257#--------------------------------------------------------------------
258# Checks for freetype library
259#--------------------------------------------------------------------
260
261AC_ARG_ENABLE(freetype,
262[  --disable-freetype      enable compilation without freetype],
263    [disable_freetype="yes"], [disable_freetype="no"])
264
265AC_ARG_WITH(freetype,
266AS_HELP_STRING([--with-freetype@<:@=ARG@:>@],
267[with freetype support [ARG=linked]]))
268
269SAVE_CPPFLAGS="$CPPFLAGS"
270SAVE_LDFLAGS="$LDFLAGS"
271SAVE_LIBS="$LIBS"
272if test -z "$FREETYPE_CFLAGS"; then
273  FREETYPE_CFLAGS=`freetype-config --cflags`
274fi
275CPPFLAGS="$CPPFLAGS $FREETYPE_CFLAGS"
276if test -z "$FREETYPE_LDFLAGS"; then
277  FREETYPE_LDFLAGS=`freetype-config --libs`
278fi
279LIBS="$LDFLAGS $FREETYPE_LDFLAGS"
280AC_CHECK_HEADER(ft2build.h,
281AC_MSG_CHECKING(for freetype)
282AC_TRY_LINK(
283[
284#include <ft2build.h>
285#include FT_FREETYPE_H
286],[
287    FT_Library ft_library;
288    (void) FT_Init_FreeType (&ft_library);
289],[
290    AC_MSG_RESULT(yes)
291    AC_DEFINE(USE_FREETYPE, 1, [Use freetype library])
292    FREETYPE_CFLAGS="$CPPFLAGS"
293    if test "$with_freetype" = "linked" -o "$with_freetype" = "" ; then
294      FREETYPE_LDFLAGS="$LIBS"
295      AC_DEFINE(LINKED_FREETYPE, 1, [Link freetype library with TeXmacs])
296    fi
297],[
298    AC_MSG_RESULT(no)
299    AC_MSG_ERROR([cannot link freetype library])
300]),
301[
302    if test "$disable_freetype" != "yes"; then
303      AC_MSG_ERROR([Cannot find freetype library.
304TeXmacs almost need freetype library to work properly.
305If you know what you are doing, you can configure with --disable-freetype])
306    fi
307]
308)
309
310CPPFLAGS="$SAVE_CPPFLAGS"
311LDFLAGS="$SAVE_LDFLAGS"
312LIBS="$SAVE_LIBS"
313
314AC_SUBST(FREETYPE_CFLAGS)
315AC_SUBST(FREETYPE_LDFLAGS)
316
317#--------------------------------------------------------------------
318# Checks for Cairo library
319#--------------------------------------------------------------------
320
321AC_ARG_WITH(cairo,
322AS_HELP_STRING([--with-cairo@<:@=ARG@:>@],
323[with cairo support [ARG=no]]))
324
325SAVE_CPPFLAGS="$CPPFLAGS"
326SAVE_LDFLAGS="$LDFLAGS"
327SAVE_LIBS="$LIBS"
328if test "$with_cairo" = "no" -o "$with_cairo" = "" ; then
329    AC_MSG_RESULT([disabling cairo support])
330else
331    CPPFLAGS=`pkg-config --cflags cairo`
332    LIBS=`pkg-config --libs cairo`
333    AC_CHECK_HEADER(cairo.h,
334    AC_MSG_CHECKING(for cairo)
335    AC_TRY_LINK(
336[
337#include <cairo.h>
338],[
339    cairo_surface_t *surface;
340    surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 120, 120);
341],[
342    AC_MSG_RESULT(yes)
343    AC_DEFINE(USE_CAIRO, 1, [Use cairo library])
344    CAIRO_CFLAGS="$CPPFLAGS"
345    if test "$with_cairo" = "linked" ; then
346      CAIRO_LDFLAGS="$LIBS"
347      AC_DEFINE(LINKED_CAIRO, 1, [Link cairo library with TeXmacs])
348    fi
349],[
350    AC_MSG_RESULT(no)]))
351fi
352
353CPPFLAGS="$SAVE_CPPFLAGS"
354LDFLAGS="$SAVE_LDFLAGS"
355LIBS="$SAVE_LIBS"
356
357AC_SUBST(CAIRO_CFLAGS)
358AC_SUBST(CAIRO_LDFLAGS)
359
360#--------------------------------------------------------------------
361# Checks for Imlib2 library
362#--------------------------------------------------------------------
363
364AC_ARG_WITH(imlib2,
365AS_HELP_STRING([--with-imlib2@<:@=ARG@:>@],
366[with imlib2 support [ARG=no]]))
367
368SAVE_CPPFLAGS="$CPPFLAGS"
369SAVE_LDFLAGS="$LDFLAGS"
370SAVE_LIBS="$LIBS"
371if test "$with_imlib2" = "no" -o "$with_imlib2" = "" ; then
372    AC_MSG_RESULT([disabling imlib2 support])
373else
374    CPPFLAGS=`imlib2-config --cflags`
375    LIBS=`imlib2-config --libs`
376    AC_CHECK_HEADER(Imlib2.h,
377    AC_MSG_CHECKING(for imlib2)
378    AC_TRY_LINK(
379[
380#include <X11/Xlib.h>
381#include <Imlib2.h>
382#include <stdio.h>
383#include <string.h>
384],[
385    Imlib_Image image= imlib_load_image("");
386],[
387    AC_MSG_RESULT(yes)
388    AC_DEFINE(USE_IMLIB2, 1, [Use imlib2 library])
389    IMLIB2_CFLAGS="$CPPFLAGS"
390    if test "$with_imlib2" = "linked" ; then
391      IMLIB2_LDFLAGS="$LIBS"
392      AC_DEFINE(LINKED_IMLIB2, 1, [Link imlib2 library with TeXmacs])
393    fi
394],[
395    AC_MSG_RESULT(no)]))
396fi
397
398CPPFLAGS="$SAVE_CPPFLAGS"
399LDFLAGS="$SAVE_LDFLAGS"
400LIBS="$SAVE_LIBS"
401
402AC_SUBST(IMLIB2_CFLAGS)
403AC_SUBST(IMLIB2_LDFLAGS)
404
405#--------------------------------------------------------------------
406# Checks for Axel library
407#--------------------------------------------------------------------
408
409AC_ARG_WITH(axel,
410AS_HELP_STRING([--with-axel@<:@=ARG@:>@],
411[with axel support [ARG=no]]))
412
413SAVE_CPPFLAGS="$CPPFLAGS"
414SAVE_LDFLAGS="$LDFLAGS"
415SAVE_LIBS="$LIBS"
416if test "$with_axel" = "no" -o "$with_axel" = "" ; then
417    AC_MSG_RESULT([disabling axel support])
418else
419    CPPFLAGS=`axel-config --cflags`
420    LIBS=`axel-config --libs`
421    AC_CHECK_HEADER(QGui/Viewer.h,
422    AC_MSG_CHECKING(for axel)
423    AC_TRY_LINK(
424[
425#include <QGui/Viewer.h>
426],[
427    Viewer viewer(0);
428],[
429    AC_MSG_RESULT(yes)
430    AC_DEFINE(USE_AXEL, 1, [Use axel library])
431    AXEL_CFLAGS="$CPPFLAGS"
432    if test "$with_axel" = "linked" ; then
433      AXEL_LDFLAGS="$LIBS"
434      AC_DEFINE(LINKED_AXEL, 1, [Link axel library with TeXmacs])
435    fi
436],[
437    AC_MSG_RESULT(no)]))
438fi
439
440CPPFLAGS="$SAVE_CPPFLAGS"
441LDFLAGS="$SAVE_LDFLAGS"
442LIBS="$SAVE_LIBS"
443
444AC_SUBST(AXEL_CFLAGS)
445AC_SUBST(AXEL_LDFLAGS)
446
447#--------------------------------------------------------------------
448# Checks for ghostscript library
449#--------------------------------------------------------------------
450
451AC_ARG_WITH(gs,
452AS_HELP_STRING([--with-gs@<:@=ARG@:>@],
453[with ghostscript support [ARG=yes]]))
454
455if test "$with_gs" = "no" ; then
456    AC_MSG_RESULT([disabling ghostscript support])
457else
458case "${host}" in
459  *mingw*)
460    GS_EXE="gswin32c.exe"
461    GS_DLL="gsdll32.dll"
462    AC_CHECK_PROG([HAS_GS_EXE], [${GS_EXE}], [yes], [no])
463    AC_CHECK_PROG([HAS_GS_LIB], [${GS_DLL}], [yes], [no])
464  ;;
465  *)
466    AC_CHECK_PROG([HAS_GS_EXE], [gs], [yes], [no])
467    HAS_GS_LIB="yes"
468  ;;
469esac
470if test "x${HAS_GS_EXE}" = "xyes" -a "x${HAS_GS_LIB}" = "xyes"; then
471  AC_DEFINE([USE_GS], [1], [Use ghostscript])
472  CONFIG_GS="Ghostscript"
473  AC_SUBST([CONFIG_GS])
474  AC_SUBST([GS_EXE])
475  AC_SUBST([GS_DLL])
476else
477  AC_MSG_RESULT([disabling ghostscript support])
478fi
479fi
480
481#--------------------------------------------------------------------
482# Checks for sqlite3 library
483#--------------------------------------------------------------------
484
485AC_ARG_WITH(sqlite3,
486AS_HELP_STRING([--with-sqlite3@<:@=ARG@:>@],
487[with sqlite3 support [ARG=no]]))
488
489SAVE_CPPFLAGS="$CPPFLAGS"
490SAVE_LDFLAGS="$LDFLAGS"
491SAVE_LIBS="$LIBS"
492if test "$with_sqlite3" = "no" -o "$with_sqlite3" = "" ; then
493    AC_MSG_RESULT([disabling sqlite3 support])
494else
495    CPPFLAGS=`pkg-config --cflags sqlite3`
496    LIBS=`pkg-config --libs sqlite3`
497    AC_CHECK_HEADER(sqlite3.h,
498    AC_MSG_CHECKING(for sqlite3)
499    AC_TRY_LINK(
500[
501#include <sqlite3.h>
502],[
503    int res= sqlite3_threadsafe ();
504],[
505    AC_MSG_RESULT(yes)
506    AC_DEFINE(USE_SQLITE3, 1, [Use sqlite3 library])
507    SQLITE3_CFLAGS="$CPPFLAGS"
508    if test "$with_sqlite3" = "linked" ; then
509      SQLITE3_LDFLAGS="$LIBS"
510      AC_DEFINE(LINKED_SQLITE3, 1, [Link sqlite3 library with TeXmacs])
511    fi
512],[
513    AC_MSG_RESULT(no)]))
514fi
515
516CPPFLAGS="$SAVE_CPPFLAGS"
517LDFLAGS="$SAVE_LDFLAGS"
518LIBS="$SAVE_LIBS"
519
520AC_SUBST(SQLITE3_CFLAGS)
521AC_SUBST(SQLITE3_LDFLAGS)
522
523#--------------------------------------------------------------------
524# Checks for (Win)Sparkle framework
525#--------------------------------------------------------------------
526
527AC_ARG_WITH(sparkle,
528AS_HELP_STRING([--with-sparkle@<:@=ARG@:>@],
529[with (Win)Sparkle autoupdater [ARG=no]]))
530
531SAVE_OBJCFLAGS="$OBJCFLAGS"
532SAVE_LDFLAGS="$LDFLAGS"
533SAVE_LIBS="$LIBS"
534if test "$with_sparkle" = "no" -o "$with_sparkle" = "" ; then
535    AC_MSG_RESULT([disabling Sparkle usage])
536else
537  case "${host}" in
538  *mingw*)
539    AC_MSG_CHECKING([whether we can use the WinSparkle library])
540    AC_LANG_PUSH([C])
541    CFLAGS="-I $with_sparkle"
542    LDFLAGS="-L $with_sparkle"
543    LIBS="-lwinsparkle"
544    AC_TRY_LINK(
545[
546#include <winsparkle.h>
547#include <winsparkle.h>
548],[
549win_sparkle_init();
550],[
551    AC_MSG_RESULT(yes)
552    AC_DEFINE(USE_SPARKLE, 1, [Use WinSparkle library])
553    SPARKLE_CFLAGS="$CFLAGS"
554    SPARKLE_LDFLAGS="$LDFLAGS $LIBS"
555    WINSPARKLE_PATH="$with_sparkle"
556    WINSPARKLE_DLL="WinSparkle*.dll"
557],[
558    AC_MSG_RESULT(no) ])
559    AC_LANG_POP([C])
560    ;;
561  *apple*darwin*)
562    AC_MSG_CHECKING([whether we can use the Sparkle framework])
563    AC_LANG_PUSH([Objective C])
564    OBJCFLAGS="-F $with_sparkle"
565    LDFLAGS="-F $with_sparkle -framework Sparkle"
566    AC_TRY_LINK(
567[
568#include <Cocoa/Cocoa.h>
569#include <Sparkle/Sparkle.h>
570],[
571SUUpdater* updater;
572],[
573    AC_MSG_RESULT(yes)
574    AC_DEFINE(USE_SPARKLE, 1, [Use Sparkle framework])
575    SPARKLE_CFLAGS="$OBJCFLAGS"
576    SPARKLE_LDFLAGS="$LDFLAGS"
577    SPARKLE_FRAMEWORK_PATH="$with_sparkle"
578    CONFIG_SPARKLE="Updater"
579],[
580    AC_MSG_RESULT(no)]
581    CONFIG_SPARKLE="")
582    AC_LANG_POP([Objective C])
583    ;;
584  esac
585fi
586
587OBJFLAGS="$SAVE_CPPFLAGS"
588LDFLAGS="$SAVE_LDFLAGS"
589LIBS="$SAVE_LIBS"
590
591AC_SUBST(SPARKLE_CFLAGS)
592AC_SUBST(SPARKLE_LDFLAGS)
593AC_SUBST(SPARKLE_FRAMEWORK_PATH)
594AC_SUBST(CONFIG_SPARKLE)
595AC_SUBST(WINSPARKLE_DLL)
596AC_SUBST(WINSPARKLE_PATH)
597
598
599#--------------------------------------------------------------------
600# Fixes for erroneous behaviour of gcc/g++ and guile on some systems
601#--------------------------------------------------------------------
602
603AC_MSG_CHECKING(whether ... arguments behave correctly)
604if test -z "$GUILE_CFLAGS"; then
605  CXXFLAGS="`$GUILE_CONFIG compile`"
606else
607  CXXFLAGS="$GUILE_CFLAGS"
608fi
609AC_TRY_COMPILE([
610  #include <guile/gh.h>
611  #include <libguile.h>
612  typedef SCM (*FN)(...);
613  static SCM identity (SCM x) { return x; }
614  void declare () { gh_new_procedure ("identity", (FN) identity, 1, 0, 0); }
615],[
616],[
617  AC_DEFINE(DOTS_OK, 1, [Defined if ...-style argument passing works])
618  AC_MSG_RESULT(yes)
619],[
620  AC_MSG_RESULT(no)
621])
622CXXFLAGS=""
623
624AC_MSG_CHECKING(the size_t of guile strings)
625if test -z "$GUILE_CFLAGS"; then
626  CXXFLAGS="`$GUILE_CONFIG compile`"
627else
628  CXXFLAGS="$GUILE_CFLAGS"
629fi
630AC_TRY_COMPILE([
631  #include <guile/gh.h>
632  #include <libguile.h>
633  void print_string (SCM s) {
634    int len_r;
635    char* r= gh_scm2newstr (s, &len_r); }
636],[
637],[
638  AC_DEFINE(guile_str_size_t, int, [Guile string size type])
639  AC_MSG_RESULT(int)
640],[
641  AC_DEFINE(guile_str_size_t, size_t, [Guile string size type])
642  AC_MSG_RESULT(size_t)
643])
644CXXFLAGS=""
645
646AC_MSG_CHECKING([if statically linking with guile works])
647SAVE_CPPFLAGS="$CPPFLAGS"
648SAVE_LDFLAGS="$LDFLAGS"
649SAVE_LIBS="$LIBS"
650CPPFLAGS="$GUILE_CFLAGS"
651LDFLAGS="-static"
652LIBS="$GUILE_LDFLAGS"
653TEXMACS_LINK_GUILE([tm_link_guile_static="yes"],
654		   [tm_link_guile_static="no"])
655AC_MSG_RESULT(["$tm_link_guile_static"])
656if test "$tm_link_guile_static" = "no" ; then
657   AC_MSG_CHECKING([if it works with -lltdl])
658   LIBS="$GUILE_LDFLAGS -lltdl"
659   TEXMACS_LINK_GUILE([tm_link_guile_static_ltdl="yes"],
660		      [tm_link_guile_static_ltdl="no"])
661   AC_MSG_RESULT(["$tm_link_guile_static_ltdl"])
662   if test "$tm_link_guile_static_ltdl" = "yes" ; then
663      GUILE_LDFLAGS="$GUILE_LDFLAGS -lltdl"
664   else
665      AC_MSG_CHECKING([if it works with -lltdl -ldl])
666      LIBS="$GUILE_LDFLAGS -lltdl -ldl"
667      TEXMACS_LINK_GUILE([tm_link_guile_static_ltdl_ldl="yes"],
668			 [tm_link_guile_static_ltdl_ldl="no"])
669      AC_MSG_RESULT(["$tm_link_guile_static_ltdl_ldl"])
670      if test "$tm_link_guile_static_ltdl_ldl" = "yes" ; then
671	 GUILE_LDFLAGS="$GUILE_LDFLAGS -lltdl -ldl"
672      else
673         AC_MSG_WARN([unable to link statically with guile])
674      fi
675   fi
676fi
677CPPFLAGS="$SAVE_CPPFLAGS"
678LDFLAGS="$SAVE_LDFLAGS"
679LIBS="$SAVE_LIBS"
680
681#--------------------------------------------------------------------
682# Handle different systems case by case
683#--------------------------------------------------------------------
684
685CONFIG_OS="GNU_LINUX"
686CONFIG_OS_SUFFIX="${host}"
687CONFIG_OS_COMPAT="Unix"
688CONFIG_MACOS=""
689CONFIG_CXXFLAGS=""
690CONFIG_CXXTEMPLATE=""
691CONFIG_STD_SETENV="#define STD_SETENV"
692CONFIG_SO="so"
693CONFIG_LIB_PATH="LD_LIBRARY_PATH"
694CONFIG_CHMOD="chmod -f"
695CONFIG_CXXOPTIMIZE="-O2"
696CONFIG_BSTATIC="-lXdmcp -lXau -lXrender"
697CONFIG_BSHARED="-Wl,-Bdynamic"
698CONFIG_BFLAGS=""
699CONFIG_BPATH="-Wl,-rpath,"
700CONFIG_LDRT=""
701CONFIG_WORD_LENGTH="4"
702CONFIG_WORD_LENGTH_INC="3"
703CONFIG_WORD_MASK="0xfffffffc"
704CONFIG_MAX_FAST="260 // WORD_LENGTH more than power of 2"
705CONFIG_HOST_OS="$host_os"
706CONFIG_HOST_VENDOR="$host_vendor"
707CONFIG_HOST_CPU="$host_cpu"
708CONFIG_USER="$USER"
709CONFIG_DATE="`date`"
710CONFIG_QTPIPES="no"
711# tweak for XCode project
712CONFIG_ARCHS='$(NATIVE_ARCH)'
713
714X11_CFLAGS="$X_CFLAGS"
715X11_LDFLAGS="$X_LIBS -lXext -lX11"
716
717AC_CHECK_SIZEOF(void *)
718AC_MSG_CHECKING(if we are on a 64-bits computer)
719if test "$ac_cv_sizeof_void_p" = "8"; then
720  AC_MSG_RESULT([yes])
721  CONFIG_WORD_LENGTH="8"
722  CONFIG_WORD_LENGTH_INC="7"
723  CONFIG_WORD_MASK="0xfffffffffffffff8"
724  CONFIG_MAX_FAST="264 // WORD_LENGTH more than power of 2"
725else
726  AC_MSG_RESULT([no])
727fi
728
729case "${host}" in
730  i*86-*-linux* | x86_64-*-linux*)
731    AC_MSG_RESULT(final adjustments for an Intel or AMD GNU/Linux host)
732    CONFIG_OS_SUFFIX="i386-pc-linux-gnu"
733    CONFIG_CXXOPTIMIZE="-O3 -fexpensive-optimizations"
734    CONFIG_QTPIPES="yes"
735  ;;
736  i*86-*-freebsd* | x86_64-*-freebsd*)
737    AC_MSG_RESULT(final adjustments for an Intel or AMD GNU/BSD host)
738    CONFIG_CXXOPTIMIZE="-O3 -fexpensive-optimizations"
739  ;;
740  i*86-*-solaris*)
741    AC_MSG_RESULT(final adjustments for an Intel or AMS Solaris host)
742    CONFIG_CXXOPTIMIZE="-O3"
743    CONFIG_BPATH="-Wl,-R,"
744    X11_LDFLAGS="$X_LIBS -lXext -lX11 -lsocket"
745  ;;
746  *mingw*)
747    AC_MSG_RESULT([final adjustments for mingw host])
748    CONFIG_OS=MINGW
749    CONFIG_QTPIPES="yes"
750    CONFIG_OS_COMPAT="Windows"
751    CPPFLAGS="$CPPFLAGS -I/usr/local/include -I."
752    CONFIG_LDRT="-L/mingw/lib -lmingw32 -lmingwex"
753    GUILE_LDFLAGS="-lmingwex $GUILE_LDFLAGS -lintl" #added mingwex to mask the internal guile readdir function
754  ;;
755  *-*-cygwin)
756    AC_MSG_RESULT(final adjustments for cygwin host)
757    CONFIG_OS="CYGWIN"
758    CONFIG_BFLAGS="-Wl,-stack,8388608"
759#    CXX="export CYGWIN=check_case:strict; $CXX"
760#    AC_SUBST(CXX)
761  ;;
762  *apple*darwin*)
763    echo "$ac_t""final adjustments for a MacOS host" 1>&6
764    CONFIG_OS="MACOS"
765    CONFIG_QTPIPES="yes"
766    CONFIG_CXXFLAGS="-I${prefix}/include"
767    CONFIG_BSHARED=""
768    CONFIG_BFLAGS="-framework Cocoa -framework IOKit"
769    CONFIG_BPATH=""
770    CONFIG_SO="dylib"
771    CONFIG_LIB_PATH="DYLD_LIBRARY_PATH"
772    GUILE_LDFLAGS=""
773    for l in $($GUILE_CONFIG link)
774    do if [[[ $l =~ ^-L ]]]
775       then GuileLibPath=${l#-L}
776       elif [[[ $l =~ ^-l ]]]
777       then lib="$GuileLibPath/lib${l#-l}.a"
778            [[[ -f $lib ]]] && GUILE_LDFLAGS+="$lib " || GUILE_LDFLAGS+="${l} " #try to use dynamic lib
779       fi
780   done
781#        done
782# guile-config doesn't return the need of libnintl
783        [[[ -z $LibIntl ]]] && LibIntl="$GuileLibPath/libintl.a" && [[[ -f $LibIntl ]]] && GUILE_LDFLAGS+="$LibIntl "
784# We must also modify the iconv library, that should be in same place than guile's lib
785        [[[ -z $LibIconv ]]] && LibIconv="$GuileLibPath/libiconv.a" && [[[ -f $LibIconv ]]] && ICONV_LDFLAGS="$LibIconv "
786;;
787  *darwin*)
788    echo "$ac_t""final adjustments for a generic Darwin host" 1>&6
789    CONFIG_CXXFLAGS="-I${prefix}/include"
790    CONFIG_BSHARED=""
791    CONFIG_BPATH=""
792    CONFIG_SO="dylib"
793    CONFIG_LIB_PATH="DYLD_LIBRARY_PATH"
794  ;;
795  powerpc-*-linux*)
796    AC_MSG_RESULT(final adjustments for a PowerPC/GNU-linux host)
797    CONFIG_OS="POWERPC_GNU_LINUX"
798    CONFIG_CXXOPTIMIZE="-O3 -fexpensive-optimizations"
799  ;;
800  *sun*)
801    AC_MSG_RESULT(final adjustments for a SUN/solaris host)
802    CONFIG_OS="SUN"
803    CONFIG_BSTATIC=""
804    CONFIG_BSHARED=""
805    CONFIG_BPATH="-Wl,-R,"
806    X11_LDFLAGS="$X_LIBS -lXext -lX11 -lsocket"
807    CONFIG_WORD_LENGTH="8"
808    CONFIG_WORD_LENGTH_INC="7"
809    CONFIG_WORD_MASK="0xfffffff8"
810    CONFIG_MAX_FAST="264 // WORD_LENGTH more than power of 2"
811    CONFIG_STD_SETENV=""
812  ;;
813  sparc*-*-linux*)
814    AC_MSG_RESULT(final adjustments for a Sparc host running GNU/Linux)
815    CONFIG_CXXOPTIMIZE="-O3 -fexpensive-optimizations"
816    CONFIG_WORD_LENGTH="8"
817    CONFIG_WORD_LENGTH_INC="7"
818    CONFIG_WORD_MASK="0xfffffff8"
819    CONFIG_MAX_FAST="264 // WORD_LENGTH more than power of 2"
820    CONFIG_STD_SETENV=""
821  ;;
822  *dec*)
823    AC_MSG_RESULT(final adjustments for a DEC/alpha host)
824    CONFIG_BSTATIC=""
825    CONFIG_BSHARED="-shared"
826    CONFIG_STD_SETENV=""
827  ;;
828  *alpha*-*-linux*)
829    AC_MSG_RESULT(final adjustments for an Alpha GNU/Linux host)
830    CONFIG_BSTATIC=""
831    CONFIG_BSHARED="-shared"
832  ;;
833  s390-*-linux*)
834    AC_MSG_RESULT(final adjustments for an IBM S/390 GNU/Linux host)
835    CONFIG_STD_SETENV=""
836  ;;
837  ia64-*-linux*)
838    AC_MSG_RESULT(final adjustments for an Itanium GNU/Linux host)
839    CONFIG_BSTATIC=""
840    CONFIG_BSHARED="-shared"
841  ;;
842  hppa*-*-linux*)
843    AC_MSG_RESULT(final adjustments for an HP PA_RISC GNU/Linux host)
844    CONFIG_CXXFLAGS="$CONFIG_CXXFLAGS -fPIC"
845    CONFIG_BSTATIC=""
846    CONFIG_BSHARED="-shared"
847  ;;
848  *sgi-irix*)
849    echo "$ac_t""final adjustments for a SGI/Irix host" 1>&6
850    CONFIG_OS="IRIX"
851    CONFIG_CXXFLAGS=""
852    X_LIBS=-L/usr/lib32
853    CONFIG_BSTATIC=""
854    CONFIG_BSHARED=""
855    CONFIG_BPATH=""
856    X11_LDFLAGS="$X_LIBS -lX11"
857    CONFIG_WORD_MASK="0xfffffff8"
858    CONFIG_STD_SETENV=""
859    CONFIG_CHMOD="chmod"
860    CONFIG_LIB_PATH="LD_LIBRARYN32_PATH"
861  ;;
862  m68k-*-linux* | mips-*-linux* | mipsel-*-linux* | arm*-*-linux*)
863    AC_MSG_RESULT(final adjustments for a supported GNU/Linux host)
864  ;;
865  *-linux*)
866    AC_MSG_RESULT(final adjustments for a generic GNU/Linux host)
867  ;;
868  *)
869    AC_MSG_RESULT(final adjustments for a generic host)
870  ;;
871esac
872
873case "${host}" in
874  *apple*darwin10*)
875    echo "$ac_t""Xcode 3.2 project tweak (only MacOSX 10.6)" 1>&6
876    CONFIG_ARCHS='$(NATIVE_ARCH_ACTUAL)'
877  ;;
878esac
879
880#--------------------------------------------------------------------
881# Temporary fix for link problem
882#--------------------------------------------------------------------
883
884case "$GXX_VERSION" in
885     3.* | 4.*)
886#	 CONFIG_BSTATIC="-static"
887	 CONFIG_BSHARED="-dynamic"
888     ;;
889esac
890
891#--------------------------------------------------------------------
892# Check for expat and xcb libraries which exist only on certain OS
893#--------------------------------------------------------------------
894
895AC_CHECK_LIB(expat,XML_ParserCreate,[CONFIG_BSTATIC="-lexpat $CONFIG_BSTATIC";CONFIG_STYPE=A])
896AC_CHECK_LIB(xcb,xcb_disconnect,[CONFIG_BSTATIC="-lxcb $CONFIG_BSTATIC";CONFIG_STYPE=B])
897
898#--------------------------------------------------------------------
899# Memory allocation options
900#--------------------------------------------------------------------
901
902AC_ARG_ENABLE(fastalloc,
903[  --disable-fastalloc     omit fast allocator for small objects],
904    [], [enable_fastalloc="yes"])
905case "$enable_fastalloc" in
906    yes)
907        ;;
908    no)
909	AC_MSG_RESULT([disabling fast allocator for small objects])
910        AC_DEFINE(NO_FAST_ALLOC, 1, [Disable fast memory allocator])
911	;;
912    *)
913	AC_MSG_ERROR([bad option --enable-fastalloc=$enable_fastalloc])
914	;;
915esac
916
917#--------------------------------------------------------------------
918# Experimental options
919#--------------------------------------------------------------------
920
921AC_ARG_ENABLE(experimental,
922[  --enable-experimental   support new style rewriting code],
923    [], [enable_experimental="no"])
924case "$enable_experimental" in
925    yes)
926	AC_MSG_RESULT([enabling experimental style rewriting code])
927        AC_DEFINE(EXPERIMENTAL, 1, [Enable experimental style rewriting code])
928        CONFIG_EXPERIMENTAL="Memorizer Environment Evaluate"
929        ;;
930    no)
931	AC_MSG_RESULT([disabling experimental style rewriting code])
932        CONFIG_EXPERIMENTAL=""
933	;;
934    *)
935	AC_MSG_ERROR([bad option --enable-experimental=$enable_experimental])
936	;;
937esac
938AC_SUBST(CONFIG_EXPERIMENTAL)
939
940#--------------------------------------------------------------------
941# MacOS X extensions (spellchecker, image loading)
942#--------------------------------------------------------------------
943
944if test x"$CONFIG_OS" = xMACOS; then
945
946AC_ARG_ENABLE(macosx-extensions,
947AS_HELP_STRING([--disable-macosx-extensions],
948[do not use Mac specific services (spellchecker, image handling, ...)]),
949    [], [enable_macosx_extensions="yes"])
950case "$enable_macosx_extensions" in
951    yes)
952	AC_MSG_RESULT([enabling Mac OSX extensions])
953        AC_DEFINE(MACOSX_EXTENSIONS, 1, [Enabling Mac OSX extensions])
954        CONFIG_MACOS="MacOS"
955#        CONFIG_BFLAGS="$CONFIG_BFLAGS -framework IOKit"
956        ;;
957    no)
958	AC_MSG_RESULT([disabling Mac OSX extensions])
959        CONFIG_MACOS=""
960	;;
961    *)
962	AC_MSG_ERROR([bad option --enable-macosx-extensions=$enable_macosx_extensions])
963	;;
964esac
965AC_SUBST(CONFIG_MACOS)
966
967fi
968
969#--------------------------------------------------------------------
970# Native PDF renderer based on Hummus
971#--------------------------------------------------------------------
972
973AC_ARG_ENABLE(pdf-renderer,
974             [  --enable-pdf-renderer   use native PDF renderer for pdf export],
975             [], [enable_pdf_renderer="yes"])
976case "$enable_pdf_renderer" in
977    yes)
978        SAVE_CPPFLAGS="$CPPFLAGS"
979        SAVE_LDFLAGS="$LDFLAGS"
980        SAVE_LIBS="$LIBS"
981        if test -z "$FREETYPE_CFLAGS"; then
982            FREETYPE_CFLAGS=`freetype-config --cflags`
983        fi
984        CPPFLAGS="$CPPFLAGS $FREETYPE_CFLAGS"
985        if test -z "$FREETYPE_LDFLAGS"; then
986            FREETYPE_LDFLAGS=`freetype-config --libs`
987        fi
988        LIBS="$LDFLAGS $FREETYPE_LDFLAGS"
989        AC_CHECK_HEADER(ft2build.h,
990        AC_MSG_CHECKING(whether freetype defines T1_EncodingType)
991        AC_TRY_LINK(
992[
993#include <ft2build.h>
994#include FT_FREETYPE_H
995#include FT_TYPE1_TABLES_H
996],[
997FT_Library ft_library;
998T1_EncodingType t;
999(void) FT_Init_FreeType (&ft_library);
1000],[
1001        AC_MSG_RESULT(yes)
1002   	AC_MSG_RESULT([enabling native PDF renderer])
1003        AC_DEFINE(PDF_RENDERER, 1, [Enabling native PDF renderer])
1004#        CONFIG_PDF="Pdf Pdf/dvipdfmx"
1005#        CONFIG_PDF="Pdf Pdf/PDFWriter"
1006        CONFIG_PDF="Pdf"
1007      	PDF_CFLAGS="-DPDFHUMMUS_NO_TIFF -DPDFHUMMUS_NO_DCT"
1008],[
1009        AC_MSG_RESULT(no)
1010        AC_MSG_ERROR([cannot find FreeType or your version is < 2.4.8.
1011If you have several versions installed please use the proper freetype-config script to set
1012the environment variables FREETYPE_CFLAGS and FREETYPE_LDFLAGS.
1013                     ])
1014        CONFIG_PDF=""
1015]))
1016        CPPFLAGS="$SAVE_CPPFLAGS"
1017        LDFLAGS="$SAVE_LDFLAGS"
1018        LIBS="$SAVE_LIBS"
1019        ;;
1020    no)
1021    	AC_MSG_RESULT([disabling native PDF renderer])
1022        CONFIG_PDF=""
1023	;;
1024    *)
1025	AC_MSG_ERROR([bad option --enable-pdf-renderer=$enable_pdf_renderer])
1026	;;
1027esac
1028AC_SUBST(CONFIG_PDF)
1029
1030#--------------------------------------------------------------------
1031# Windows console
1032#--------------------------------------------------------------------
1033
1034if test x"$CONFIG_OS" = xMINGW; then
1035
1036AC_ARG_ENABLE(console,
1037[  --enable-console        enable windows console], [], [])
1038case "$enable_console" in
1039    yes)
1040	AC_MSG_RESULT([enabling Windows console])
1041        ;;
1042    *)
1043	AC_MSG_RESULT([disabling Windows console])
1044	CONFIG_LDRT="$CONFIG_LDRT -mwindows"
1045	;;
1046esac
1047
1048fi
1049
1050#--------------------------------------------------------------------
1051# Gui selection
1052#--------------------------------------------------------------------
1053
1054CONFIG_X11=""
1055CONFIG_COCOA=""
1056CONFIG_GUI="X11"
1057
1058AC_ARG_ENABLE(qt,
1059[  --disable-qt            replace Qt by X11 interface],
1060    [], [enable_qt="yes"])
1061
1062case "$enable_qt" in
1063    yes)
1064        HACKED_AT_WITH_QT
1065	if test x"$at_cv_qt_build" = xko; then
1066	   AC_MSG_ERROR([cannot find Qt!])
1067	else
1068	   AC_MSG_RESULT([enabling Qt port])
1069           CONFIG_GUI="QT"
1070           if test x"$CONFIG_OS" = xMACOS; then
1071              # on Mac we rely on some ObjC code contained in
1072              # src/Plugins/MacOS
1073              CONFIG_MACOS="MacOS"
1074           fi
1075        fi
1076        ;;
1077    no)
1078	CONFIG_QTPIPES="no"
1079	AC_MSG_RESULT([enabling X11 port])
1080	;;
1081    *)
1082	CONFIG_QTPIPES="no"
1083	AC_MSG_ERROR([bad option --enable-qt=$enable_qt])
1084	;;
1085esac
1086
1087# Qt Plugins list
1088define([PLUGINS_LIST],[imageformats,accessible])
1089QT_PLUGINS_LIST=PLUGINS_LIST
1090AC_ARG_ENABLE(QtPlugins,
1091	AS_HELP_STRING([--enable-QtPlugins@<:@=list@:>@],
1092		[defauts plugins: PLUGINS_LIST]),
1093  [QT_PLUGINS_LIST=$enableval],[QT_PLUGINS_LIST=PLUGINS_LIST])
1094case $QT_PLUGINS_LIST in
1095yes) QT_PLUGINS_LIST=PLUGINS_LIST;;
1096no) unset QT_PLUGINS_LIST
1097esac
1098
1099[[[ $enable_qt == no ]]] &&  unset QT_PLUGINS_LIST
1100for p in ${QT_PLUGINS_LIST/,/ }
1101do [[ -d $QT_PLUGINS_PATH/$p ]] || AC_MSG_ERROR(QT plugins not found!)
1102done
1103
1104# Qt Pipes
1105AC_ARG_ENABLE(qtpipes,
1106[  --enable-qtpipes        replace UNIX pipes by Qt pipes],
1107    [], [enable_qtpipes=$CONFIG_QTPIPES])
1108
1109case "$enable_qtpipes" in
1110    yes)
1111        if test x"$CONFIG_GUI" = xQT; then
1112           AC_DEFINE(QTPIPES, 1, [Enabling Qt pipes])
1113           AC_MSG_RESULT([enabling Qt pipes])
1114        else
1115           AC_MSG_ERROR([QT not enabled!])
1116        fi
1117        ;;
1118    no)
1119        if test x"$CONFIG_GUI" = xQT; then
1120           AC_MSG_RESULT([disabling Qt pipes])
1121        fi
1122	;;
1123    *)
1124	AC_MSG_ERROR([bad option --enable-qtpipes=$enable_qtpipes])
1125	;;
1126esac
1127
1128AC_ARG_ENABLE(cocoa,
1129[  --enable-cocoa          replace X11 by Cocoa interface],
1130    [], [enable_cocoa="no"])
1131case "$enable_cocoa" in
1132    yes)
1133	AC_MSG_RESULT([enabling experimental Cocoa port])
1134	COCOA_CFLAGS=""
1135	COCOA_LDFLAGS="-framework Cocoa"
1136        CONFIG_GUI="COCOA"
1137        ;;
1138    no)
1139	AC_MSG_RESULT([disabling experimental Cocoa port])
1140	;;
1141    *)
1142	AC_MSG_ERROR([bad option --enable-cocoa=$enable_cocoa])
1143	;;
1144esac
1145
1146case "$CONFIG_GUI" in
1147    X11)
1148	CONFIG_X11="X11 Widkit"
1149        if test "x${CONFIG_GS}" != "xGhostscript"; then
1150          CONFIG_X11="$CONFIG_X11 Ghostscript"
1151        fi
1152        CONFIG_GUI_DEFINE="X11TEXMACS"
1153#        AC_DEFINE(X11TEXMACS, 1, [Use standard X11 port])
1154	;;
1155    COCOA)
1156        CONFIG_COCOA="Cocoa"
1157        CONFIG_GUI_DEFINE="AQUATEXMACS"
1158#        AC_DEFINE(AQUATEXMACS, 1, [Enable experimental Cocoa port])
1159	;;
1160    QT)
1161        CONFIG_QT="Qt"
1162        CONFIG_GUI_DEFINE="QTTEXMACS"
1163#        AC_DEFINE(QTTEXMACS, 1, [Enable experimental Qt port])
1164	;;
1165esac
1166
1167AC_SUBST(CPPFLAGS)
1168AC_SUBST(LDFLAGS)
1169AC_SUBST(LIBS)
1170AC_SUBST(X11_CFLAGS)
1171AC_SUBST(X11_LDFLAGS)
1172AC_SUBST(COCOA_CFLAGS)
1173AC_SUBST(COCOA_LDFLAGS)
1174AC_SUBST(PDF_CFLAGS)
1175
1176AC_SUBST(CONFIG_X11)
1177AC_SUBST(CONFIG_COCOA)
1178AC_SUBST(CONFIG_QT)
1179AC_SUBST(CONFIG_GUI)
1180AC_SUBST(CONFIG_GUI_DEFINE)
1181
1182AC_SUBST(QT_FRAMEWORKS_PATH)
1183AC_SUBST(QT_PLUGINS_PATH)
1184AC_SUBST(QT_PLUGINS_LIST)
1185
1186#--------------------------------------------------------------------
1187# Debugging options
1188#--------------------------------------------------------------------
1189
1190#STD_DEBUG_FLAGS="-fno-rtti -fno-exceptions"
1191#if test "$enable_cocoa" = "yes"; then
1192#    STD_DEBUG_FLAGS="-fno-exceptions"
1193#fi
1194
1195STD_DEBUG_FLAGS="-fno-rtti"
1196if test "$enable_cocoa" = "yes"; then
1197    STD_DEBUG_FLAGS=""
1198fi
1199
1200AC_MSG_CHECKING(if compiler supports $STD_DEBUG_FLAGS)
1201CXXFLAGS="$STD_DEBUG_FLAGS"
1202AC_TRY_COMPILE([
1203  int some_variable = 0;
1204],[
1205],[
1206    CONFIG_CXXDIALECT="$STD_DEBUG_FLAGS"
1207    AC_MSG_RESULT(yes)
1208],[
1209    CONFIG_CXXDIALECT=""
1210    AC_MSG_RESULT(no)
1211])
1212CXXFLAGS=""
1213AC_SUBST(CONFIG_CXXDIALECT)
1214
1215AC_ARG_ENABLE(profile,
1216[  --enable-profile        enable gcc compilation flag for profiling with gprof],
1217    [], [enable_profile="no"])
1218
1219if test "$enable_profile" = "yes"; then
1220    if test "$GXX" = "yes"; then
1221        enable_profile="yes"
1222    else
1223        enable_profile="none"
1224    fi
1225fi
1226
1227case "$enable_profile" in
1228    yes)
1229	AC_MSG_RESULT([enabling gcc profiling compilation flag -pg])
1230        CONFIG_CXXPROFILE="-pg"
1231        ;;
1232    none)
1233	AC_MSG_RESULT([disabling gcc profiling compilation flag])
1234        CONFIG_CXXPROFILE=""
1235	;;
1236    *)
1237        CONFIG_CXXPROFILE=""
1238	;;
1239esac
1240
1241AC_ARG_ENABLE(debug,
1242AS_HELP_STRING([--enable-debug@<:@=ARG@:>@],
1243[install a debugging enable executable [-ggdb]]),
1244[], [enable_debug="no"])
1245
1246if test "$enable_debug" = "yes"; then
1247    if test "$GXX" = "yes"; then
1248        enable_debug="-ggdb"
1249    else
1250        enable_debug="-g3"
1251    fi
1252fi
1253
1254if test "$enable_debug" = "no"; then
1255    AC_MSG_RESULT([disabling debugging])
1256    CONFIG_STRIP="strip"
1257    CONFIG_CXXDEBUG=""
1258    optimize_default="yes"
1259else
1260    AC_MSG_RESULT([enabling debugging, $enable_debug])
1261    CONFIG_STRIP="true"
1262    CONFIG_CXXDEBUG="$enable_debug"
1263    optimize_default="no"
1264fi
1265
1266AC_ARG_ENABLE(assert,
1267AS_HELP_STRING([--enable-assert],
1268[exit on failed assertions in code]),
1269[], [enable_assert="yes"])
1270
1271if test "$enable_assert" = "no"; then
1272    AC_MSG_RESULT([disabling assertion checking])
1273else
1274    AC_MSG_RESULT([enabling assertion checking])
1275    AC_DEFINE(DEBUG_ASSERT, 1, [check assertions in code])
1276fi
1277
1278#--------------------------------------------------------------------
1279# Warning options
1280#--------------------------------------------------------------------
1281
1282case "$GXX_VERSION" in
1283  none)
1284    CONFIG_CXXWARNING="";
1285  ;;
1286  *)
1287    CONFIG_CXXWARNING="-Wall -Wno-return-type"
1288  ;;
1289esac
1290
1291AC_ARG_ENABLE(warnings,
1292[  --enable-warnings       print warning messages during compilation],
1293    [], [enable_warnings="yes"])
1294case "$enable_warnings" in
1295    yes)
1296	AC_MSG_RESULT([enabling warning flags $CONFIG_CXXWARNING]) ;;
1297    no)
1298        CONFIG_CXXWARNING=""
1299	AC_MSG_RESULT([disabling warning flags]) ;;
1300    *)
1301        CONFIG_CXXWARNING="$enable_warnings"
1302	AC_MSG_RESULT([enabling warning flags $CONFIG_CXXWARNING]) ;;
1303esac
1304
1305#--------------------------------------------------------------------
1306# Optimization options
1307#--------------------------------------------------------------------
1308
1309if test "$optimize_default" = "yes"; then
1310  case "$GXX_VERSION" in
1311    3.3.3 | 3.3.4 | 4.*)
1312      ;;
1313    2.96 | 3.0 | 3.0.* | 3.1 | 3.1.* | 3.2 | 3.2.* | 3.3 | 3.3.*)
1314      case "${host}" in
1315	i*86-*-linux-gnu* | i*86-*-freebsd*)
1316	  AC_MSG_WARN([using g++ 3.*, optimize without inline by default])
1317	  optimize_default="no-inline"
1318	;;
1319	*)
1320	  AC_MSG_WARN([using g++ 3.*, optimize without inline by default])
1321	  optimize_default="no-inline"
1322	;;
1323      esac
1324    ;;
1325  esac
1326fi
1327
1328AC_ARG_ENABLE(optimize,
1329AS_HELP_STRING([--enable-optimize@<:@=ARG@:>@],
1330[compile with optimizations [guessed]]),
1331[], [enable_optimize="$optimize_default"])
1332
1333case "$enable_optimize" in
1334    yes)
1335	# keep optimization options
1336  	AC_MSG_RESULT([enabling optimizations, $CONFIG_CXXOPTIMIZE]) ;;
1337    no-inline)
1338	optimize_no_inline="-fno-default-inline -fno-inline"
1339	CONFIG_CXXOPTIMIZE="$CONFIG_CXXOPTIMIZE $optimize_no_inline"
1340  	AC_MSG_RESULT([enabling optimizations, $CONFIG_CXXOPTIMIZE]) ;;
1341    no)
1342	CONFIG_CXXOPTIMIZE=""
1343	AC_MSG_RESULT([disabling optimizations]) ;;
1344    *)
1345	CONFIG_CXXOPTIMIZE="$enable_optimize"
1346	AC_MSG_RESULT([customizing optimizations, $enable_optimize]) ;;
1347esac
1348
1349#--------------------------------------------------------------------
1350# Fix for Mac OS X with genuine GCC and Qt framework
1351#--------------------------------------------------------------------
1352
1353AC_DEFUN([AC_TEXMACS_CXXFLAG_Xarch_x86_64], [
1354  AC_REQUIRE([AC_PROG_CXX])
1355  AC_LANG_PUSH([C++])
1356  OLDCXXFLAGS=$CXXFLAGS
1357  CXXFLAGS="$CXXFLAGS -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.8"
1358  AC_COMPILE_CHECK([whether C++ compiler supports -Xarch_x86_64],[],[], [
1359    AC_MSG_RESULT(yes)
1360    Xarch_x86_64="yes"
1361  ], [
1362    AC_MSG_RESULT(no)
1363    Xarch_x86_64="no"])
1364  CXXFLAGS=$OLDCXXFLAGS
1365  AC_LANG_POP([C++])
1366])
1367
1368case "${host}" in
1369  *apple*darwin*)
1370    AC_TEXMACS_CXXFLAG_Xarch_x86_64
1371    if test "$Xarch_x86_64" = "no"; then
1372      QT_CXXFLAGS=`echo $QT_CXXFLAGS | sed "s/ -Xarch_x86_64//g"`
1373      QT_LDFLAGS=`echo $QT_LDFLAGS | sed "s/ -Xarch_x86_64//g"`
1374    fi;;
1375esac
1376
1377
1378
1379AC_DEFUN([AC_QT_CXXFLAG_stdlib], [
1380  AC_REQUIRE([AC_PROG_CXX])
1381  AC_LANG_PUSH([C++])
1382  OLDCXXFLAGS=$CXXFLAGS
1383  CXXFLAGS="$CXXFLAGS -stdlib=libc++"
1384  AC_COMPILE_CHECK([whether C++ compiler supports -stdlib],[],[], [
1385    AC_MSG_RESULT(yes)
1386    Stdlib="yes"
1387  ], [
1388    AC_MSG_RESULT(no)
1389    Stdlib="no"])
1390  CXXFLAGS=$OLDCXXFLAGS
1391  AC_LANG_POP([C++])
1392])
1393
1394case "${host}" in
1395  *apple*darwin*)
1396    AC_QT_CXXFLAG_stdlib
1397    if test "$Stdlib" = "no"; then
1398      QT_CXXFLAGS=`echo $QT_CXXFLAGS | sed 's/ -stdlib=@<:@^@<:@:space:]]*//g'`
1399      QT_LDFLAGS=`echo $QT_LDFLAGS | sed 's/ -stdlib=@<:@^@<:@:space:]]*//g'`
1400    fi;;
1401esac
1402
1403#--------------------------------------------------------------------
1404# Substitute TeXmacs specific configuration parameters
1405#--------------------------------------------------------------------
1406
1407AC_SUBST(CONFIG_OS)
1408AC_SUBST(CONFIG_OS_SUFFIX)
1409AC_SUBST(CONFIG_OS_COMPAT)
1410AC_SUBST(CONFIG_CXXWARNING)
1411AC_SUBST(CONFIG_CXXTEMPLATE)
1412AC_SUBST(CONFIG_CXXOPTIMIZE)
1413AC_SUBST(CONFIG_CXXDEBUG)
1414AC_SUBST(CONFIG_CXXPROFILE)
1415AC_SUBST(CONFIG_BFLAGS)
1416AC_SUBST(CONFIG_BSTATIC)
1417AC_SUBST(CONFIG_STYPE)
1418AC_SUBST(CONFIG_BSHARED)
1419AC_SUBST(CONFIG_BPATH)
1420AC_SUBST(CONFIG_WORD_LENGTH)
1421AC_SUBST(CONFIG_WORD_LENGTH_INC)
1422AC_SUBST(CONFIG_WORD_MASK)
1423AC_SUBST(CONFIG_MAX_FAST)
1424AC_SUBST(CONFIG_CXXFLAGS)
1425AC_SUBST(CONFIG_STD_SETENV)
1426AC_SUBST(CONFIG_SO)
1427AC_SUBST(CONFIG_LIB_PATH)
1428AC_SUBST(CONFIG_STRIP)
1429AC_SUBST(CONFIG_CHMOD)
1430AC_SUBST(CONFIG_LDRT)
1431AC_SUBST(CONFIG_HOST_OS)
1432AC_SUBST(CONFIG_HOST_VENDOR)
1433AC_SUBST(CONFIG_HOST_CPU)
1434AC_SUBST(CONFIG_USER)
1435AC_SUBST(CONFIG_DATE)
1436AC_SUBST(CONFIG_ARCHS)
1437
1438#--------------------------------------------------------------------
1439# Default paths for installation
1440#--------------------------------------------------------------------
1441
1442if test "$prefix" = ""; then
1443  prefix=/usr/local
1444fi
1445if test "$prefix" = "NONE"; then
1446  prefix=/usr/local
1447fi
1448if test "$exec_prefix" = ""; then
1449  exec_prefix='${prefix}'
1450fi
1451if test "$exec_prefix" = "NONE"; then
1452  exec_prefix='${prefix}'
1453fi
1454if test "$exec_prefix" = '${prefix}'; then
1455  exec_prefix='${prefix}'
1456fi
1457if test "$includedir" = ""; then
1458  includedir='${prefix}/include'
1459fi
1460if test "$includedir" = "NONE"; then
1461  includedir='${prefix}/include'
1462fi
1463if test "$includedir" = '${prefix}/include'; then
1464  includedir='${prefix}/include'
1465fi
1466if test "$libdir" = ""; then
1467  libdir='${exec_prefix}/lib'
1468fi
1469if test "$libdir" = "NONE"; then
1470  libdir='${exec_prefix}/lib'
1471fi
1472if test "$libdir" = '${exec_prefix}/lib'; then
1473  libdir='${exec_prefix}/lib'
1474fi
1475if test "$bindir" = ""; then
1476  bindir='${exec_prefix}/bin'
1477fi
1478if test "$bindir" = "NONE"; then
1479  bindir=${exec_prefix}/bin
1480fi
1481if test "$bindir" = '${exec_prefix}/bin'; then
1482  bindir='${exec_prefix}/bin'
1483fi
1484if test "$datarootdir" = ""; then
1485  datarootdir='${prefix}/share'
1486fi
1487if test "$datarootdir" = "NONE"; then
1488  datarootdir='${prefix}/share'
1489fi
1490if test "$datarootdir" = '${prefix}/share'; then
1491  datarootdir='${prefix}/share'
1492fi
1493if test "$datadir" = ""; then
1494  datadir='${prefix}/share'
1495fi
1496if test "$datadir" = "NONE"; then
1497  datadir='${prefix}/share'
1498fi
1499if test "$datadir" = '${prefix}/share'; then
1500  datadir='${prefix}/share'
1501fi
1502if test "$mandir" = ""; then
1503  mandir='${datarootdir}/man'
1504fi
1505if test "$mandir" = "NONE"; then
1506  mandir='${datarootdir}/man'
1507fi
1508if test "$mandir" = '${datarootdir}/man'; then
1509  mandir='${datarootdir}/man'
1510fi
1511if test "$libexecdir" = ""; then
1512  libexecdir='${exec_prefix}/libexec'
1513fi
1514if test "$libexecdir" = "NONE"; then
1515  libexecdir='${exec_prefix}/libexec'
1516fi
1517if test "$libexecdir" = '${exec_prefix}/libexec'; then
1518  libexecdir='${exec_prefix}/libexec'
1519fi
1520
1521curdir="`pwd`"
1522tmorig=${curdir}
1523tmdir=${PACKAGE}
1524tmsrc=${curdir}/${tmdir}
1525tmbin=${libexecdir}/${tmdir}
1526tmdata=${datadir}/${tmdir}
1527AC_SUBST(tmorig)
1528AC_SUBST(tmdir)
1529AC_SUBST(tmsrc)
1530AC_SUBST(tmbin)
1531AC_SUBST(tmdata)
1532
1533if test "$DEVEL_RELEASE" = "1"; then
1534  tm_devel=${PACKAGE}-${DEVEL_VERSION}
1535else
1536  tm_devel=${PACKAGE}-${DEVEL_VERSION}-R${DEVEL_RELEASE}
1537fi
1538tm_devel_release=${PACKAGE}-${DEVEL_VERSION}-${DEVEL_RELEASE}
1539tm_underscore_devel=${PACKAGE}_${DEVEL_VERSION}
1540tm_debian_name_devel=${DEBIAN_NAME}_${DEVEL_VERSION}
1541
1542AC_SUBST(tm_devel)
1543AC_SUBST(tm_devel_release)
1544AC_SUBST(tm_underscore_devel)
1545AC_SUBST(tm_debian_name_devel)
1546
1547if test "$STABLE_RELEASE" = "1"; then
1548  tm_stable=${PACKAGE}-${STABLE_VERSION}
1549else
1550  tm_stable=${PACKAGE}-${STABLE_VERSION}-R${STABLE_RELEASE}
1551fi
1552tm_stable_release=${PACKAGE}-${STABLE_VERSION}-${STABLE_RELEASE}
1553tm_underscore_stable=${PACKAGE}_${STABLE_VERSION}
1554
1555AC_SUBST(tm_stable)
1556AC_SUBST(tm_stable_release)
1557AC_SUBST(tm_underscore_stable)
1558
1559#--------------------------------------------------------------------
1560# Done
1561#--------------------------------------------------------------------
1562AC_OUTPUT(Makefile:Makefile.in src/makefile:src/makefile.in src/System/tm_configure.hpp:src/System/tm_configure.in misc/admin/admin.makefile:misc/admin/admin.makefile.in misc/doxygen/Doxyfile:misc/doxygen/Doxyfile.in misc/man/texmacs.1:misc/man/texmacs.1.in packages/redhat/TeXmacs.spec:packages/redhat/TeXmacs.spec.in misc/scripts/fig2ps:misc/scripts/fig2ps.in misc/scripts/texmacs:misc/scripts/texmacs.in TeXmacs/examples/plugins/dynlink/Makefile:TeXmacs/examples/plugins/dynlink/Makefile.in packages/macos/Base.xcconfig:packages/macos/Base.xcconfig.in packages/macos/Info-Xcode.plist:packages/macos/Info-Xcode.plist.in packages/macos/Info.plist:packages/macos/Info.plist.in packages/fedora/TeXmacs.spec:packages/fedora/TeXmacs.spec.in packages/mandriva/TeXmacs.spec:packages/mandriva/TeXmacs.spec.in packages/centos/TeXmacs.spec:packages/centos/TeXmacs.spec.in packages/windows/TeXmacs.iss:packages/windows/TeXmacs.iss.in packages/windows/resource.rc:packages/windows/resource.rc.in packages/debian/changelog:packages/debian/changelog.in packages/debian/control:packages/debian/control.in)
1563