Use cairo to draw everything.
[ntk.git] / configure.in
blob762d3f996af66a8bd3bd64d3dee824d1ba4de8d9
1 dnl -*- sh -*-
2 dnl the "configure" script is made from this by running GNU "autoconf"
3 dnl
4 dnl "$Id: configure.in 8511 2011-03-06 16:54:58Z manolo $"
5 dnl
6 dnl Configuration script for the Fast Light Tool Kit (FLTK).
7 dnl
8 dnl Copyright 1998-2010 by Bill Spitzak and others.
9 dnl
10 dnl This library is free software; you can redistribute it and/or
11 dnl modify it under the terms of the GNU Library General Public
12 dnl License as published by the Free Software Foundation; either
13 dnl version 2 of the License, or (at your option) any later version.
14 dnl
15 dnl This library is distributed in the hope that it will be useful,
16 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
17 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 dnl Library General Public License for more details.
19 dnl
20 dnl You should have received a copy of the GNU Library General Public
21 dnl License along with this library; if not, write to the Free Software
22 dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 dnl USA.
24 dnl
25 dnl Please report all bugs and problems on the following page:
26 dnl
27 dnl      http://www.fltk.org/str.php
28 dnl
30 dnl We need at least autoconf 2.50...
31 AC_PREREQ(2.50)
33 dnl Required file in package...
34 AC_INIT(src/Fl.cxx)
36 dnl So --with-archflags option is used during "checking size of long"
37 if test `uname` = Darwin; then
38   if test "x$with_archflags" != x ; then
39     CFLAGS="$CFLAGS $with_archflags"
40   fi
41   USEMMFILES="Yes"
42 else
43   USEMMFILES="No"
45 AC_SUBST(USEMMFILES)
47 dnl FLTK library versions...
48 FL_MAJOR_VERSION=1
49 FL_MINOR_VERSION=3
50 FL_PATCH_VERSION=0
51 FL_API_VERSION=${FL_MAJOR_VERSION}.${FL_MINOR_VERSION}
53 AC_SUBST(FL_MAJOR_VERSION)
54 AC_SUBST(FL_MINOR_VERSION)
55 AC_SUBST(FL_PATCH_VERSION)
56 AC_SUBST(FL_API_VERSION)
58 dnl Get the operating system and version number...
59 uname=`uname`
60 uversion=`uname -r | sed -e '1,$s/[[^0-9]]//g'`
61 if test "x$uname" = xIRIX64; then
62     uname="IRIX"
64 if test "x$uname" = x; then
65     # Older MinGW doesn't provide any output when uname is run, even with "-s".
66     # Current MinGW (as of Jan. 2011) however does, so this is not necessary anymore...
67     uname="MINGW"
70 dnl Do not automatically add "-g" to compiler options...
71 ARCHFLAGS="${ARCHFLAGS:=}"
72 CFLAGS="${CFLAGS:=}"
73 CPPFLAGS="${CPPFLAGS:=}"
74 CXXFLAGS="${CXXFLAGS:=}"
75 DSOFLAGS="${DSOFLAGS:=}"
76 LDFLAGS="${LDFLAGS:=}"
77 OPTIM="${OPTIM:=}"
79 AC_SUBST(ARCHFLAGS)
80 AC_SUBST(OPTIM)
82 dnl in case of cross-compiling mingw32 under linux we must change uname for Win32 GUI
83 dnl run ./configure --host=i686-pc-ming32 try use X11 without change uname
84 if test "x$cross_compiling" != xno ; then
85   case $host_alias in
86     *mingw*)
87     uname=MINGW
88     ;;
89   esac
92 dnl OS-specific pre-tests...
93 dnl uname_GUI equals $uname unless we target Cygwin in combination with X11.
94 uname_GUI=$uname
95 case $uname in
96     CYGWIN*)
97         # Handle Cygwin option *first*, before all other tests.
98         AC_ARG_ENABLE(cygwin, [  --enable-cygwin         use the Cygwin libraries [(default=no)]])
99         AC_ARG_ENABLE(x11,    [  --enable-x11            use Cygwin with X11 [(default=no)]])
100         if test x$enable_cygwin != xyes; then
101             # NOTE: We can't use ARCHFLAGS for this, since it does not work
102             #       with some of the function tests - Cygwin uses a
103             #       different C library...
104             CFLAGS="$CFLAGS -mno-cygwin"
105             CPPFLAGS="$CPPFLAGS -mno-cygwin"
106             CXXFLAGS="$CXXFLAGS -mno-cygwin"
107             LDFLAGS="$LDFLAGS -mno-cygwin"
108             DSOFLAGS="$DSOFLAGS -mno-cygwin"
109         else
110             # we target Cygwin in combination with X11
111             if test x$enable_x11 = xyes; then
112                 uname_GUI="X11$uname"
113             fi
114         fi
115         ;;
116 esac
118 dnl Define the libraries and link options we will need.
119 LINKFLTK="../lib/libfltk.a"
120 LINKFLTKFORMS="../lib/libfltk_forms.a"
121 LINKFLTKGL="../lib/libfltk_gl.a"
122 LINKFLTKIMG="../lib/libfltk_images.a"
123 GLDEMOS="gldemos"
125 LIBEXT=".a"
126 LIBNAME="../lib/libfltk.a"
127 FLLIBNAME="../lib/libfltk_forms.a"
128 GLLIBNAME="../lib/libfltk_gl.a"
129 IMGLIBNAME="../lib/libfltk_images.a"
130 CAIROLIBNAME="../lib/libfltk_cairo.a"
132 LIBBASENAME="libfltk.a"
133 FLLIBBASENAME="libfltk_forms.a"
134 GLLIBBASENAME="libfltk_gl.a"
135 IMGLIBBASENAME="libfltk_images.a"
136 CAIROLIBBASENAME="libfltk_cairo.a"
138 dnl Check for Cairo library unless disabled...
139 CAIRODIR=""
140 CAIROFLAGS=""
141 LINKFLTKCAIRO=""
142 FLTKCAIROOPTION=""
143 CAIROLIBS=""
145 AC_ARG_ENABLE(cairoext,[  --enable-cairoext       use fltk code instrumentation for cairo extended use (default=no)])
146 AC_ARG_ENABLE(cairo,[  --enable-cairo          use lib Cairo  (default=no)])
148 if test x$enable_cairoext = xyes; then
149           AC_DEFINE(FLTK_USE_CAIRO)
150           AC_DEFINE(FLTK_HAVE_CAIRO)
151           dnl FIXME This part should be fixed so configure do not depend on
152           dnl we do not rely on pkg-config .
153           CAIRODIR="cairo"
154           CAIROFLAGS="`pkg-config --cflags cairo`"
155           CAIROLIBS="-lcairo -lpixman-1"
156           CXXFLAGS="$CAIROFLAGS $CXXFLAGS"
157           LINKFLTKCAIRO="../lib/libfltk_cairo.a"
158           FLTKCAIROOPTION="-L ../cairo -lfltk_cairo$SHAREDSUFFIX"
159           LIBS="$CAIROLIBS $LIBS" 
160           dnl $LINKFLTKCAIRO 
161           LINKFLTK+=" $LINKFLTKCAIRO"
162 else 
163     if test x$enable_cairo = xyes; then
164           AC_DEFINE(FLTK_HAVE_CAIRO)
165           dnl FIXME This part should be fixed so configure do not depend on
166           dnl we do not rely on pkg-config .
167           CAIRODIR="cairo"
168           CAIROFLAGS="`pkg-config --cflags cairo`"
169           CAIROLIBS="-lcairo -lpixman-1"
170           CXXFLAGS="$CAIROFLAGS $CXXFLAGS"
171           LINKFLTKCAIRO="../lib/libfltk_cairo.a"
172           FLTKCAIROOPTION="-L ../cairo -lfltk_cairo$SHAREDSUFFIX"
173     fi
176 AC_SUBST(CAIRODIR)
177 AC_SUBST(CAIROFLAGS)
178 AC_SUBST(CAIROLIBS)
179 AC_SUBST(LINKFLTKCAIRO)
180 AC_SUBST(FLTKCAIROOPTION)
183 AC_SUBST(FLLIBNAME)
184 AC_SUBST(GLDEMOS)
185 AC_SUBST(GLLIBNAME)
186 AC_SUBST(IMGLIBNAME)
187 AC_SUBST(CAIROLIBNAME)
188 AC_SUBST(LIBEXT)
189 AC_SUBST(LIBNAME)
190 AC_SUBST(LINKFLTK)
191 AC_SUBST(LINKFLTKFORMS)
192 AC_SUBST(LINKFLTKGL)
193 AC_SUBST(LINKFLTKIMG)
195 AC_SUBST(LIBBASENAME)
196 AC_SUBST(FLLIBBASENAME)
197 AC_SUBST(GLLIBBASENAME)
198 AC_SUBST(IMGLIBBASENAME)
199 AC_SUBST(CAIROLIBBASENAME)
201 dnl Handle compile-time options...
202 AC_ARG_ENABLE(debug, [  --enable-debug          turn on debugging [default=no]])
203 if test x$enable_debug = xyes; then
204     DEBUGFLAG="-g "
205 else
206     DEBUGFLAG=""
209 AC_ARG_ENABLE(cp936, [  --enable-cp936          turn on CP936 [default=no]])
210 if test x$enable_cp936 = xyes; then
211     CFLAGS="$CFLAGS -DCP936"
215 AC_ARG_ENABLE(gl, [  --enable-gl             turn on OpenGL support [default=yes]])
217 AC_ARG_ENABLE(shared, [  --enable-shared         turn on shared libraries [default=no]])
218 if test x$enable_shared = xyes; then
219     PICFLAG=1
220     SHAREDSUFFIX=""
221     FLUID="fluid-shared"
223     case $uname in
224         Darwin*)
225             DSONAME="libfltk.$FL_API_VERSION.dylib"
226             FLDSONAME="libfltk_forms.$FL_API_VERSION.dylib"
227             GLDSONAME="libfltk_gl.$FL_API_VERSION.dylib"
228             IMGDSONAME="libfltk_images.$FL_API_VERSION.dylib"
229             CAIRODSONAME="libfltk_cairo.$FL_API_VERSION.dylib"
230             DSOCOMMAND="\$(CXX) \$(ARCHFLAGS) \$(DSOFLAGS) -dynamiclib -lc -o"
231             ;;
233         SunOS* | UNIX_S*)
234             DSONAME="libfltk.so.$FL_API_VERSION"
235             FLDSONAME="libfltk_forms.so.$FL_API_VERSION"
236             GLDSONAME="libfltk_gl.so.$FL_API_VERSION"
237             IMGDSONAME="libfltk_images.so.$FL_API_VERSION"
238             CAIRODSONAME="libfltk_cairo.so.$FL_API_VERSION"
239             DSOCOMMAND="\$(CXX) \$(DSOFLAGS) -h \$@ \$(LDLIBS) -G $DEBUGFLAG -o"
240             if test "x$libdir" != "x/usr/lib"; then
241                     DSOLINK="-R$libdir"
242             fi
243             ;;
244         HP-UX*)
245             DSONAME="libfltk.sl.$FL_API_VERSION"
246             FLDSONAME="libfltk_forms.sl.$FL_API_VERSION"
247             GLDSONAME="libfltk_gl.sl.$FL_API_VERSION"
248             IMGDSONAME="libfltk_images.sl.$FL_API_VERSION"
249             CAIRODSONAME="libfltk_cairo.sl.$FL_API_VERSION"
250             DSOCOMMAND="ld \$(DSOFLAGS) -b -z +h \$@ $DEBUGFLAG -o"
251             if test "x$libdir" != "x/usr/lib"; then
252                     DSOLINK="-Wl,-rpath,$libdir"
253             fi
254             ;;
255         IRIX*)
256             DSONAME="libfltk.so.$FL_API_VERSION"
257             FLDSONAME="libfltk_forms.so.$FL_API_VERSION"
258             GLDSONAME="libfltk_gl.so.$FL_API_VERSION"
259             IMGDSONAME="libfltk_images.so.$FL_API_VERSION"
260             CAIRODSONAME="libfltk_cairo.so.$FL_API_VERSION"
261             DSOCOMMAND="\$(CXX) \$(DSOFLAGS) -Wl,-soname,\$@,-set_version,sgi1.1 \$(LDLIBS) -shared $DEBUGFLAG -o"
262             if test "x$libdir" != "x/usr/lib" -a "x$libdir" != "x/usr/lib32" -a "x$libdir" != "x/usr/lib64"; then
263                     DSOLINK="-Wl,-rpath,$libdir"
264             fi
265             ;;
266         OSF1*)
267             DSONAME="libfltk.so.$FL_API_VERSION"
268             FLDSONAME="libfltk_forms.so.$FL_API_VERSION"
269             GLDSONAME="libfltk_gl.so.$FL_API_VERSION"
270             IMGDSONAME="libfltk_images.so.$FL_API_VERSION"
271             CAIRODSONAME="libfltk_cairo.so.$FL_API_VERSION"
272             DSOCOMMAND="\$(CXX) \$(DSOFLAGS) -Wl,-soname,\$@ \$(LDLIBS) -shared $DEBUGFLAG -o"
273             if test "x$libdir" != "x/usr/lib" -a "x$libdir" != "x/usr/lib32"; then
274                     DSOLINK="-Wl,-rpath,$libdir"
275             fi
276             ;;
277         Linux* | *BSD*)
278             DSONAME="libfltk.so.$FL_API_VERSION"
279             FLDSONAME="libfltk_forms.so.$FL_API_VERSION"
280             GLDSONAME="libfltk_gl.so.$FL_API_VERSION"
281             IMGDSONAME="libfltk_images.so.$FL_API_VERSION"
282             CAIRODSONAME="libfltk_cairo.so.$FL_API_VERSION"
283             DSOCOMMAND="\$(CXX) \$(DSOFLAGS) -Wl,-soname,\$@ \$(LDLIBS) -shared -fPIC $DEBUGFLAG -o"
284             if test "x$libdir" != "x/usr/lib" -a "x$libdir" != "x/usr/lib64"; then
285                     DSOLINK="-Wl,-rpath,$libdir"
286             fi
287             ;;
288         AIX*)
289             DSONAME="libfltk_s.a"
290             FLDSONAME="libfltk_forms_s.a"
291             GLDSONAME="libfltk_gl_s.a"
292             IMGDSONAME="libfltk_images_s.a"
293             CAIRODSONAME="libfltk_cairo_s.a"
294             DSOCOMMAND="\$(CXX) \$(DSOFLAGS) -Wl,-bexpall,-bM:SRE,-bnoentry -o"
295             SHAREDSUFFIX="_s"
296             ;;
297         CYGWIN* | MINGW*)
298             PICFLAG=0
299             if test x$enable_cygwin != xyes; then
300                 DSONAME="mgwfltknox-$FL_API_VERSION.dll"
301                 FLDSONAME="mgwfltknox_forms-$FL_API_VERSION.dll"
302                 GLDSONAME="mgwfltknox_gl-$FL_API_VERSION.dll"
303                 IMGDSONAME="mgwfltknox_images-$FL_API_VERSION.dll"
304                 CAIRODSONAME="mgwfltknox_cairo-$FL_API_VERSION.dll"
305             else
306                 if test x$enable_x11 = xyes; then
307                     DSONAME="cygfltk-$FL_API_VERSION.dll"
308                     FLDSONAME="cygfltk_forms-$FL_API_VERSION.dll"
309                     GLDSONAME="cygfltk_gl-$FL_API_VERSION.dll"
310                     IMGDSONAME="cygfltk_images-$FL_API_VERSION.dll"
311                     CAIRODSONAME="cygfltk_cairo-$FL_API_VERSION.dll"
312                 else
313                     DSONAME="cygfltknox-$FL_API_VERSION.dll"
314                     FLDSONAME="cygfltknox_forms-$FL_API_VERSION.dll"
315                     GLDSONAME="cygfltknox_gl-$FL_API_VERSION.dll"
316                     IMGDSONAME="cygfltknox_images-$FL_API_VERSION.dll"
317                     CAIRODSONAME="cygfltknox_cairo-$FL_API_VERSION.dll"
318                 fi
319             fi
320             #-----------------------------------------------------------
321             # -Wl,--enable-runtime-pseudo-reloc: See str 1585
322             # appears to be necessary for older binutils versions < 2.16
323             #-----------------------------------------------------------
324             LDFLAGS="$LDFLAGS -Wl,--enable-auto-import -Wl,--enable-runtime-pseudo-reloc"
325             DSOCOMMAND="\$(CXX) \$(DSOFLAGS) -shared \
326                 -Wl,--whole-archive -Wl,--export-all-symbols \
327                 -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-import \
328                 -Wl,--enable-auto-image-base -o \$@"
329             ;;
330         *)
331             AC_MSG_WARN(Shared libraries may not be supported.  Trying -shared option with compiler.)
332             DSONAME="libfltk.so.$FL_API_VERSION"
333             FLDSONAME="libfltk_forms.so.$FL_API_VERSION"
334             GLDSONAME="libfltk_gl.so.$FL_API_VERSION"
335             IMGDSONAME="libfltk_images.so.$FL_API_VERSION"
336             CAIRODSONAME="libfltk_cairo.so.$FL_API_VERSION"
337             DSOCOMMAND="\$(CXX) \$(DSOFLAGS) -Wl,-soname,\$@ \$(LDLIBS) -shared $DEBUGFLAG -o"
338             ;;
339     esac
341     LINKSHARED="-L../src $FLTKCAIROOPTION -lfltk_images$SHAREDSUFFIX -lfltk_forms$SHAREDSUFFIX -lfltk$SHAREDSUFFIX"
342 else
343     DSOCOMMAND="echo"
344     DSOLINK=""
345     DSONAME=""
346     FLDSONAME=""
347     GLDSONAME=""
348     IMGDSONAME=""
349     CAIRODSONAME=""
350     PICFLAG=0
351     SHAREDSUFFIX=""
352     FLUID="fluid"
353     LINKSHARED="$LINKFLTKCAIRO ../lib/libfltk_images.a ../lib/libfltk_forms.a ../lib/libfltk.a"
356 AC_SUBST(DSOCOMMAND)
357 AC_SUBST(DSOFLAGS)
358 AC_SUBST(DSOLINK)
359 AC_SUBST(DSONAME)
360 AC_SUBST(FLDSONAME)
361 AC_SUBST(GLDSONAME)
362 AC_SUBST(IMGDSONAME)
363 AC_SUBST(CAIRODSONAME)
364 AC_SUBST(SHAREDSUFFIX)
365 AC_SUBST(LINKSHARED)
366 AC_SUBST(FLUID)
368 AC_ARG_ENABLE(threads, [  --enable-threads        enable multi-threading support (default=yes)])
370 AC_ARG_WITH(optim, [  --with-optim="flags"    use custom optimization flags])
372 AC_ARG_WITH(archflags, [  --with-archflags="flags"
373                           use custom architecture flags 
374                           (possible Mac OS X values include -arch i386, -arch x86_64, -arch ppc)],
375     ARCHFLAGS="$withval")
376 case $uname in
377     Darwin*)
378 # QD is not supported anymore since 1.3
379         AC_DEFINE(__APPLE_QUARTZ__)
380         ;;
381 esac
383 dnl Find commands...
384 AC_PROG_CC
385 AC_PROG_CXX
386 AC_PROG_INSTALL
387 case $uname in
388     OSF1*)
389         INSTALL="`pwd`/install-sh -c"
390         ;;
391 esac
392 if test "$INSTALL" = "$ac_install_sh"; then
393     # Use full path to install-sh script...
394     INSTALL="`pwd`/install-sh -c"
396 AC_PATH_PROG(NROFF,nroff)
397 if test "x$NROFF" = "x:"; then
398     # Try groff instead of nroff...
399     AC_PATH_PROG(GROFF,groff)
400     if test "x$GROFF" = "x:"; then
401         NROFF="echo"
402     else
403         NROFF="$GROFF -T ascii"
404     fi
406 AC_PATH_PROG(HTMLDOC,htmldoc)
407 AC_PATH_PROG(DOXYDOC,doxygen)
409 dnl How do we make libraries?
410 AC_PROG_RANLIB
411 AC_PATH_TOOL(AR, ar)
413 if test "x$AR" = "x:"; then
414     AC_MSG_ERROR(Configure could not find the library archiver, aborting.)
417 if test "x$RANLIB" != "x:"; then
418     LIBCOMMAND="$AR cr"
419 else
420     LIBCOMMAND="$AR crs"
423 AC_SUBST(LIBCOMMAND)
425 dnl how to compile (Windows) resource files
426 dnl this will only be used to compile resources for Windows .exe files
427 AC_PATH_TOOL(RC,windres)
429 dnl Architecture checks...
430 if test "$uname" != Darwin; then
431   AC_C_BIGENDIAN
434 AC_CHECK_SIZEOF(short, 2)
435 AC_CHECK_SIZEOF(int, 4)
436 AC_CHECK_SIZEOF(long, 4)
437 if test $ac_cv_sizeof_short -eq 2; then
438     AC_DEFINE(U16,unsigned short)
440 if test $ac_cv_sizeof_int -eq 4; then
441     AC_DEFINE(U32,unsigned)
442 else
443     if test $ac_cv_sizeof_long -eq 4; then
444         AC_DEFINE(U32,unsigned long)
445     fi
447 if test "$uname" != Darwin; then
448         if test $ac_cv_sizeof_int -eq 8; then
449                 AC_DEFINE(U64,unsigned)
450         else
451                 if test $ac_cv_sizeof_long -eq 8; then
452                         AC_DEFINE(U64,unsigned long)
453                 fi
454         fi
457 dnl Does the C++ compiler support the bool type?
458 AC_CACHE_CHECK(whether the compiler recognizes bool as a built-in type,
459     ac_cv_cxx_bool,[
460         AC_LANG_SAVE
461         AC_LANG_CPLUSPLUS
462         AC_TRY_COMPILE([
463             int f(int  x){return 1;}
464             int f(char x){return 1;}
465             int f(bool x){return 1;}
466         ],[
467             bool b = true;
468             return f(b);
469         ], ac_cv_cxx_bool=yes, ac_cv_cxx_bool=no)
470         AC_LANG_RESTORE
471     ])
473 if test "$ac_cv_cxx_bool" != yes; then
474     CXXFLAGS="-Dbool=char -Dfalse=0 -Dtrue=1 $CXXFLAGS"
477 dnl Standard headers and functions...
478 AC_HEADER_DIRENT
479 AC_CHECK_HEADER(sys/select.h,AC_DEFINE(HAVE_SYS_SELECT_H))
480 AC_CHECK_HEADER(sys/stdtypes.h,AC_DEFINE(HAVE_SYS_SELECT_H))
482 dnl Do we have the POSIX compatible scandir() prototype?
483 AC_CACHE_CHECK([whether we have the POSIX compatible scandir() prototype],
484     ac_cv_cxx_scandir_posix,[
485         AC_LANG_SAVE
486         AC_LANG_CPLUSPLUS
487         AC_TRY_COMPILE([
488           #include <dirent.h>
489           int func (const char *d, dirent ***list, void *sort) {
490             int n = scandir(d, list, 0, (int(*)(const dirent **, const dirent **))sort);
491           }
492         ],[
493         ], ac_cv_cxx_scandir_posix=yes, ac_cv_cxx_scandir_posix=no)
494         AC_LANG_RESTORE
495     ])
497 dnl Define both HAVE_SCANDIR... macros, if the POSIX compatible function is
498 dnl available. Otherwise: check, whether any scandir prototype is available,
499 dnl but don't use it on SunOS and QNX because of an incompatibility in pre-Y2K
500 dnl SunOS scandir versions. We assume, though, that the POSIX compatible
501 dnl version on newer SunOS/Solaris versions works as expected.
502 if test "$ac_cv_cxx_scandir_posix" = yes; then
503     AC_DEFINE(HAVE_SCANDIR)
504     AC_DEFINE(HAVE_SCANDIR_POSIX)
505 else
506     AC_CHECK_FUNC(scandir,
507         if test "x$uname" = xSunOS -o "x$uname" = xQNX; then
508             AC_MSG_WARN(Not using $uname scandir emulation function.)
509         else
510             AC_DEFINE(HAVE_SCANDIR)
511         fi)
514 AC_CHECK_FUNC(vsnprintf,[
515     case "$uname" in
516         HP-UX*)
517             if test "$uversion" = "1020"; then
518                 AC_MSG_WARN(Not using built-in vsnprintf function because you are running HP-UX 10.20.)
519             else
520                 AC_DEFINE(HAVE_VSNPRINTF)
521             fi
522             ;;
524         OSF1*)
525             if test "$uversion" = "40"; then
526                 AC_MSG_WARN(Not using built-in vsnprintf function because you are running Tru64 4.0.)
527             else
528                 AC_DEFINE(HAVE_VSNPRINTF)
529             fi
530             ;;
532         *)
533             AC_DEFINE(HAVE_VSNPRINTF)
534             ;;
535     esac])
536 AC_CHECK_FUNC(snprintf,[
537     case "$uname" in
538         HP-UX*)
539             if test "$uversion" = "1020"; then
540                 AC_MSG_WARN(Not using built-in snprintf function because you are running HP-UX 10.20.)
541             else
542                 AC_DEFINE(HAVE_SNPRINTF)
543             fi
544             ;;
546         OSF1*)
547             if test "$uversion" = "40"; then
548                 AC_MSG_WARN(Not using built-in snprintf function because you are running Tru64 4.0.)
549             else
550                 AC_DEFINE(HAVE_SNPRINTF)
551             fi
552             ;;
554         *)
555             AC_DEFINE(HAVE_SNPRINTF)
556             ;;
557     esac])
558 AC_CHECK_HEADER(strings.h, AC_DEFINE(HAVE_STRINGS_H))
559 AC_CHECK_FUNCS(strcasecmp strlcat strlcpy)
561 AC_CHECK_HEADER(locale.h, AC_DEFINE(HAVE_LOCALE_H))
562 AC_CHECK_FUNCS(localeconv)
564 dnl FLTK library uses math library functions...
565 AC_SEARCH_LIBS(pow, m)
567 dnl Check for largefile support...
568 AC_SYS_LARGEFILE
570 dnl Define largefile options as needed...
571 LARGEFILE=""
572 if test x$enable_largefile != xno; then
573         LARGEFILE="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE"
575         if test x$ac_cv_sys_large_files = x1; then
576                 LARGEFILE="$LARGEFILE -D_LARGE_FILES"
577         fi
579         if test x$ac_cv_sys_file_offset_bits = x64; then
580                 LARGEFILE="$LARGEFILE -D_FILE_OFFSET_BITS=64"
581         fi
583 AC_SUBST(LARGEFILE)
585 dnl Check for "long long" support...
586 AC_CACHE_CHECK(for long long int, ac_cv_c_long_long,
587         [if test "$GCC" = yes; then
588                 ac_cv_c_long_long=yes
589         else
590                 AC_TRY_COMPILE(,[long long int i;],
591                         ac_cv_c_long_long=yes,
592                         ac_cv_c_long_long=no)
593         fi])
595 if test $ac_cv_c_long_long = yes; then
596         AC_DEFINE(HAVE_LONG_LONG)
599 AC_CHECK_FUNC(strtoll, AC_DEFINE(HAVE_STRTOLL))
601 dnl Check for dlopen/dlsym...
602 AC_SEARCH_LIBS(dlsym, dl, AC_DEFINE(HAVE_DLSYM))
603 AC_CHECK_HEADER(dlfcn.h, AC_DEFINE(HAVE_DLFCN_H))
605 dnl Check for audio libraries...
606 AUDIOLIBS=""
608 case $uname in
609     CYGWIN* | MINGW*)
610         dnl Cygwin environment...
611         AUDIOLIBS="-lwinmm"
612         ;;
614     Darwin*)
615         AUDIOLIBS="-framework CoreAudio"
616         ;;
618     *)
619         AC_CHECK_HEADER(alsa/asoundlib.h,
620             AC_DEFINE(HAVE_ALSA_ASOUNDLIB_H)
621             AUDIOLIBS="-lasound")
622         ;;
623 esac
625 AC_SUBST(AUDIOLIBS)
627 dnl Check for image libraries...
628 SAVELIBS="$LIBS"
629 IMAGELIBS=""
630 STATICIMAGELIBS=""
632 AC_SUBST(IMAGELIBS)
633 AC_SUBST(STATICIMAGELIBS)
635 # Handle the JPEG lib linking mode (use fltk local or system lib)
636 # If --enable-(resp. --disable-)localjpeg parameter is not set by user
637 # Then we check the JPEG lib usability, with result in sysjpeglib_ok variable
638 AC_ARG_ENABLE(localjpeg, [  --enable-localjpeg      use local JPEG library, default=auto])
639 # Check for System lib use if automatic mode or --disable-localjpeg is requested
640 sysjpeglib_ok=no
641 sysjpeginc_ok=no
642 if test x$enable_localjpeg != xyes; then
643     AC_CHECK_LIB(jpeg,jpeg_CreateCompress,
644         [AC_CHECK_HEADER(jpeglib.h,
645             sysjpeginc_ok=yes)
646             if test x$sysjpeginc_ok = xyes; then
647                 sysjpeglib_ok=yes
648                 fi])
650 # Now set the jpeg lib and include flags according to the requested mode and availability 
651 if test x$enable_localjpeg = xyes -o x$sysjpeglib_ok = xno; then
652     JPEGINC="-I../jpeg"
653     JPEG="jpeg"
654     IMAGELIBS="-lfltk_jpeg $IMAGELIBS"
655     STATICIMAGELIBS="\$libdir/libfltk_jpeg.a $STATICIMAGELIBS"
656     AC_DEFINE(HAVE_LIBJPEG)
657     #ac_cv_lib_jpeg_jpeg_CreateCompress=no # from ima: should not be necessary
658     # Finally, warn user if system lib was requested but not found
659     if test x$enable_localjpeg = xno; then
660         AC_MSG_WARN(Cannot find system jpeg lib or header: choosing the local lib mode.)
661     fi
662 else
663     JPEGINC=""
664     JPEG=""
665     IMAGELIBS="-ljpeg $IMAGELIBS"
666     STATICIMAGELIBS="-ljpeg $STATICIMAGELIBS"
667     AC_DEFINE(HAVE_LIBJPEG)
670 # Handle the ZLIB lib linking mode (use fltk local or system lib)
671 # If --enable-(resp. --disable-)localzlib parameter is not set by user
672 # Then we check the ZLIB lib usability, with result in syszlib_ok variable
673 AC_ARG_ENABLE(localzlib, [  --enable-localzlib      use local ZLIB library, default=auto])
674 # Check for System lib use if automatic mode or --disable-localzlib is requested
675 syszlib_ok=no
676 syszinc_ok=no
677 if test x$enable_localzlib != xyes; then
678     AC_CHECK_LIB(z,gzgets,
679         [AC_CHECK_HEADER(zlib.h, 
680                 syszinc_ok=yes)
681         if test x$syszinc_ok = xyes; then
682             syszlib_ok=yes
683             fi])
685 # Now set the Z lib and include flags according to the requested mode and availability 
686 if test x$enable_localzlib = xyes -o x$syszlib_ok = xno ; then
687     ZLIBINC="-I../zlib"
688     ZLIB="zlib"
689     LIBS="-lfltk_z $LIBS"
690     IMAGELIBS="-lfltk_z $IMAGELIBS"
691     STATICIMAGELIBS="\$libdir/libfltk_z.a $STATICIMAGELIBS"
692     AC_DEFINE(HAVE_LIBZ)
693     ac_cv_lib_z_gzgets=no # fc: is still necessary ?
694     # Finally, warn user if system lib was requested but not found
695     if test x$enable_localzlib = xno; then
696         AC_MSG_WARN(Cannot find system z lib or header: choosing the local lib mode.)
697     fi
698 else
699     ZLIBINC=""
700     ZLIB=""
701     LIBS="-lz $LIBS"
702     IMAGELIBS="-lz $IMAGELIBS"
703     STATICIMAGELIBS="-lz $STATICIMAGELIBS"
704     AC_DEFINE(HAVE_LIBZ)
707 # Handle the PNG lib linking mode (use fltk local or system lib)
708 # If --enable-(resp. --disable-)localpng parameter is not set by user
709 # Then we check the png lib usability with result in syspng_lib variable
710 AC_ARG_ENABLE(localpng, [  --enable-localpng       use local PNG library, default=auto])
712 # Now check if system lib is usable, we check Lib AND include availability with inc variant,
713 # but only, if the builtin lib is not requested
714 syspnglib_ok=no
715 syspnginc_ok=no
716 if test x$enable_localpng != xyes; then
717   AC_CHECK_LIB(png, png_read_info, 
718     [AC_CHECK_HEADER(png.h, 
719         AC_DEFINE(HAVE_PNG_H)
720         syspnginc_ok=yes)
721     AC_CHECK_HEADER(libpng/png.h, 
722         AC_DEFINE(HAVE_LIBPNG_PNG_H)
723         syspnginc_ok=yes)
724     if test x$syspnginc_ok = xyes; then
725         syspnglib_ok=yes
726     fi])
729 # The following is executed if the lib was not found usable or if local lib is required explicitly
730 if test x$enable_localpng = xyes -o x$syspnglib_ok = xno ; then
731     PNGINC="-I../png"
732     PNG="png"
733     IMAGELIBS="-lfltk_png $IMAGELIBS"
734     STATICIMAGELIBS="\$libdir/libfltk_png.a $STATICIMAGELIBS"
735     AC_DEFINE(HAVE_LIBPNG)
736     AC_DEFINE(HAVE_PNG_H)
737     AC_DEFINE(HAVE_PNG_GET_VALID)
738     AC_DEFINE(HAVE_PNG_SET_TRNS_TO_ALPHA)
739     # Finally, warn user if system lib was requested but not found
740     if test x$enable_localpng = xno; then
741         AC_MSG_WARN(Cannot find system png lib or header: choosing the local lib mode.)
742     fi
743 else
744     PNGINC=""
745     PNG=""
746     IMAGELIBS="-lpng $IMAGELIBS"
747     STATICIMAGELIBS="-lpng $STATICIMAGELIBS"
748     AC_DEFINE(HAVE_LIBPNG)
749     AC_CHECK_LIB(png,png_get_valid, AC_DEFINE(HAVE_PNG_GET_VALID))
750     AC_CHECK_LIB(png,png_set_tRNS_to_alpha, AC_DEFINE(HAVE_PNG_SET_TRNS_TO_ALPHA))
753 AC_SUBST(JPEG)
754 AC_SUBST(JPEGINC)
755 AC_SUBST(PNG)
756 AC_SUBST(PNGINC)
757 AC_SUBST(ZLIB)
758 AC_SUBST(ZLIBINC)
760 dnl Restore original LIBS settings...
761 LIBS="$SAVELIBS"
763 dnl See if we need a .exe extension on executables...
764 AC_EXEEXT
766 dnl Check for pthreads for multi-threaded apps...
767 have_pthread=no
768 PTHREAD_FLAGS=""
770 dnl Test whether we want to check for pthreads. We must not do it on Windows
771 dnl unless we run under Cygwin with --enable-cygwin, since we always use
772 dnl native threads on Windows (even if libpthread is available)
773 check_pthread=yes
774 case $uname in
775     MINGW*)
776         check_pthread=no
777         ;;
778     CYGWIN*)
779         if test "x$enable_cygwin" != xyes; then
780             check_pthread=no
781         fi
782         ;;
783     *)
784         ;;
785 esac
787 if test "x$enable_threads" != xno -a x$check_pthread = xyes; then
788     AC_CHECK_HEADER(pthread.h, AC_DEFINE(HAVE_PTHREAD_H))
790     if test x$ac_cv_header_pthread_h = xyes; then
791         dnl Check various threading options for the platforms we support
792         for flag in -lpthreads -lpthread -pthread; do
793             AC_MSG_CHECKING([for pthread_create using $flag])
794             SAVELIBS="$LIBS"
795             LIBS="$flag $LIBS"
796             AC_TRY_LINK([#include <pthread.h>],
797                 [pthread_create(0, 0, 0, 0);],
798                 have_pthread=yes,
799                 LIBS="$SAVELIBS")
800             AC_MSG_RESULT([$have_pthread])
802             if test $have_pthread = yes; then
803                 AC_DEFINE(HAVE_PTHREAD)
804                 PTHREAD_FLAGS="-D_THREAD_SAFE -D_REENTRANT"
806                 # Solaris requires -D_POSIX_PTHREAD_SEMANTICS to
807                 # be POSIX-compliant... :(
808                 if test $uname = SunOS; then
809                     PTHREAD_FLAGS="$PTHREAD_FLAGS -D_POSIX_PTHREAD_SEMANTICS"
810                 fi
811                 break
812             fi
813         done
814     fi
817 AC_SUBST(PTHREAD_FLAGS)
819 dnl Define OS-specific stuff...
820 HLINKS=
821 OSX_ONLY=:
822 THREADS=
824 AC_ARG_WITH(links, [  --with-links            make header links for common misspellings (default=no)])
826 INSTALL_DESKTOP=""
827 UNINSTALL_DESKTOP=""
829 case $uname_GUI in
830     CYGWIN* | MINGW*)
831         dnl Cygwin environment, using windows GDI ...
832         # Recent versions of Cygwin are seriously broken and the size
833         # checks don't work because the shell puts out \r\n instead of
834         # \n.  Here we just force U32 to be defined to "unsigned"...
835         AC_DEFINE(U32,unsigned)
836         CFLAGS="-mwindows -DWIN32 -DUSE_OPENGL32 $CFLAGS"
837         CXXFLAGS="-mwindows -DWIN32 -DUSE_OPENGL32 $CXXFLAGS"
838         LDFLAGS="-mwindows $LDFLAGS"
839         DSOFLAGS="-mwindows $DSOFLAGS"
840         LIBS="$LIBS -lole32 -luuid -lcomctl32"
841         if test "x$with_optim" = x; then
842             dnl Avoid -Os optimization on Cygwin/MinGW
843             with_optim="-O3"
844         fi
846         if test x$enable_gl != xno; then
847             AC_CHECK_HEADER(GL/gl.h,
848                 AC_DEFINE(HAVE_GL)
849                 GLLIB="-lopengl32")
850             AC_CHECK_HEADER(GL/glu.h,
851                 AC_DEFINE(HAVE_GL_GLU_H)
852                 GLLIB="-lglu32 $GLLIB")
853         else
854             LINKFLTKGL=""
855             GLLIBNAME=""
856             GLDSONAME=""
857             GLDEMOS=""
858         fi
860         if test "x$enable_threads" != xno; then
861             if test x$have_pthread = xyes; then
862                 AC_DEFINE(HAVE_PTHREAD)
863             fi
864         fi
866         THREADS="threads$EXEEXT"
868         # Don't make symlinks since Windows is not case sensitive.
869         if test "x$with_links" != xyes; then
870                 HLINKS="#"
871         fi
872         ;;
874     Darwin*)
875         # MacOS X uses Cocoa for graphics.
876         LIBS="$LIBS -framework Cocoa"
878         if test x$have_pthread = xyes; then
879             AC_DEFINE(HAVE_PTHREAD)
880             THREADS="threads$EXEEXT"
881         fi
883         if test x$enable_gl != xno; then
884             AC_DEFINE(HAVE_GL)
885             AC_DEFINE(HAVE_GL_GLU_H)
886             GLLIB="-framework AGL -framework OpenGL -framework ApplicationServices"
887         else
888             LINKFLTKGL=""
889             GLLIBNAME=""
890             GLDSONAME=""
891             GLDEMOS=""
892         fi
894         # Don't make symlinks because HFS+ is not case sensitive...
895         if test "x$with_links" != xyes; then
896                 HLINKS="#"
897         fi
899         # Some steps are only done for OS X package management
900         OSX_ONLY=
902         # Install/Uninstall FLUID application
903         INSTALL_DESKTOP="install-osx"
904         UNINSTALL_DESKTOP="uninstall-osx"
905         ;;
907     *)
908         # All others are UNIX/X11...
909         # This includes Cygwin target combined with X11
910         if test x$have_pthread = xyes; then
911             AC_DEFINE(HAVE_PTHREAD)
912             THREADS="threads$EXEEXT"
913         fi
915         dnl Check for X11...
916         AC_PATH_XTRA
918         if test x$no_x = xyes; then
919             AC_MSG_ERROR(Configure could not find required X11 libraries, aborting.)
920         fi
922         if test "x$X_PRE_LIBS" != x; then
923             AC_MSG_WARN(Ignoring libraries \"$X_PRE_LIBS\" requested by configure.)
924         fi
926         LIBS="$LIBS -lX11 $X_EXTRA_LIBS"
927         CFLAGS="$CFLAGS $X_CFLAGS"
928         CXXFLAGS="$CXXFLAGS $X_CFLAGS"
929         LDFLAGS="$X_LIBS $LDFLAGS"
930         DSOFLAGS="$X_LIBS $DSOFLAGS"
931         AC_DEFINE(USE_X11)
932         if test "x$x_includes" != x; then
933             ac_cpp="$ac_cpp -I$x_includes"
934         fi
936         dnl Check for OpenGL unless disabled...
937         GLLIB=
939         if test x$enable_gl != xno; then
940             AC_SEARCH_LIBS(dlopen, dl)
941             AC_CHECK_HEADER(GL/gl.h,
942                 AC_CHECK_LIB(GL, glXMakeCurrent, AC_DEFINE(HAVE_GL) GLLIB="-lGL",
943                     AC_CHECK_LIB(MesaGL,glXMakeCurrent, AC_DEFINE(HAVE_GL) GLLIB=" -lMesaGL",,
944                         -lm),
945                     -lm)
946                 AC_CHECK_LIB(GL, glXGetProcAddressARB,
947                              AC_DEFINE(HAVE_GLXGETPROCADDRESSARB),, -lm)
948             )
949             AC_CHECK_HEADER(GL/glu.h,
950                 AC_DEFINE(HAVE_GL_GLU_H)
951                 if test x$ac_cv_lib_GL_glXMakeCurrent = xyes; then
952                     GLLIB="-lGLU $GLLIB"
953                 fi
954                 if test x$ac_cv_lib_MesaGL_glXMakeCurrent = xyes; then
955                     GLLIB="-lMesaGLU $GLLIB"
956                 fi
957             )
959             if test x$ac_cv_lib_GL_glXMakeCurrent != xyes -a x$ac_cv_lib_MesaGL_glXMakeCurrent != xyes; then
960                     LINKFLTKGL=""
961                     GLLIBNAME=""
962                     GLDSONAME=""
963                     GLDEMOS=""
964             fi
965         else
966             LINKFLTKGL=""
967             GLLIBNAME=""
968             GLDSONAME=""
969             GLDEMOS=""
970         fi
972         dnl Check for Xinerama support unless disabled...
973         AC_ARG_ENABLE(xinerama, [  --enable-xinerama       turn on Xinerama support [default=yes]])
975         if test x$enable_xinerama != xno; then
976             AC_CHECK_LIB(Xinerama,XineramaIsActive,
977                     AC_DEFINE(HAVE_XINERAMA)
978                     LIBS="-lXinerama $LIBS")
979         fi
981         dnl Check for the Xft library unless disabled...
982         AC_ARG_ENABLE(xft, [  --enable-xft            turn on Xft support [default=yes]])
984         if test x$enable_xft != xno; then
985             AC_PATH_PROG(FTCONFIG,freetype-config)
987             if test "x$FTCONFIG" != x; then
988                 CPPFLAGS="`$FTCONFIG --cflags` $CPPFLAGS"
989                 CXXFLAGS="`$FTCONFIG --cflags` $CXXFLAGS"
991                 AC_CHECK_LIB(fontconfig, FcPatternCreate)
992                 AC_CHECK_HEADER(X11/Xft/Xft.h,
993                     AC_CHECK_LIB(Xft, XftDrawCreate,
994                         AC_DEFINE(USE_XFT)
995                         LIBS="-lXft $LIBS"))
996             fi
997         fi
999         dnl Check for the Xdbe extension unless disabled...
1000         AC_ARG_ENABLE(xdbe, [  --enable-xdbe           turn on Xdbe support [default=yes]])
1002         if test x$enable_xdbe != xno; then
1003             AC_CHECK_HEADER(X11/extensions/Xdbe.h, AC_DEFINE(HAVE_XDBE),,
1004                 [#include <X11/Xlib.h>])
1005             AC_CHECK_LIB(Xext, XdbeQueryExtension,
1006                 LIBS="-lXext $LIBS")
1007         fi
1009         dnl Check for overlay visuals...
1010         AC_PATH_PROG(XPROP, xprop)
1011         AC_CACHE_CHECK(for X overlay visuals, ac_cv_have_overlay,
1012             if test "x$XPROP" != x; then
1013                 if $XPROP -root 2>/dev/null | grep -c "SERVER_OVERLAY_VISUALS" >/dev/null; then
1014                     ac_cv_have_overlay=yes
1015                 else
1016                     ac_cv_have_overlay=no
1017                 fi
1018             else
1019                 ac_cv_have_overlay=no
1020             fi)
1022         if test x$ac_cv_have_overlay = xyes; then
1023             AC_DEFINE(HAVE_OVERLAY)
1024         fi
1026         # Make symlinks since UNIX/Linux is case sensitive,
1027         # but Cygwin in general not.
1028         case $uname in
1029             CYGWIN*)
1030                 HLINKS="#"
1031             ;;
1032             *)
1033             ;;
1034         esac
1035         # Make symlinks since UNIX/Linux is case sensitive,
1036         # but only if explicitly configured (default=no)
1037         if test "x$with_links" != xyes; then
1038                 HLINKS="#"
1039         fi
1041         # Install/Uninstall FLUID application support files
1042         INSTALL_DESKTOP="install-linux"
1043         UNINSTALL_DESKTOP="uninstall-linux"
1044         ;;
1045 esac
1047 AC_SUBST(GLDEMOS)
1048 AC_SUBST(GLLIB)
1049 AC_SUBST(HLINKS)
1050 AC_SUBST(OSX_ONLY)
1051 AC_SUBST(THREADS)
1053 AC_SUBST(INSTALL_DESKTOP)
1054 AC_SUBST(UNINSTALL_DESKTOP)
1056 dnl Figure out the appropriate formatted man page extension...
1057 case "$uname" in
1058     *BSD* | Darwin*)
1059         # *BSD
1060         CAT1EXT=0
1061         CAT3EXT=0
1062         CAT6EXT=0
1063         ;;
1064     IRIX*)
1065         # SGI IRIX
1066         CAT1EXT=z
1067         CAT3EXT=z
1068         CAT6EXT=z
1069         ;;
1070     *)
1071         # All others
1072         CAT1EXT=1
1073         CAT3EXT=3
1074         CAT6EXT=6
1075         ;;
1076 esac
1078 AC_SUBST(CAT1EXT)
1079 AC_SUBST(CAT3EXT)
1080 AC_SUBST(CAT6EXT)
1082 dnl Fix "mandir" variable...
1083 if test "$mandir" = "\${prefix}/man" -a "$prefix" = "/usr"; then
1084     case "$uname" in
1085         *BSD* | Darwin* | Linux*)
1086             # *BSD, Darwin, and Linux
1087             mandir="\${prefix}/share/man"
1088             ;;
1089         IRIX*)
1090             # SGI IRIX
1091             mandir="\${prefix}/share/catman"
1092             ;;
1093     esac
1096 dnl Fix "libdir" variable...
1097 if test "$prefix" = NONE; then
1098     prefix=/usr/local
1101 if test "$exec_prefix" = NONE; then
1102     exec_prefix="\${prefix}"
1105 if test "$uname" = "IRIX" -a $uversion -ge 62 -a "$libdir" = "\${exec_prefix}/lib" -a "$exec_prefix" = "\${prefix}" -a "$prefix" = "/usr"; then
1106     libdir="/usr/lib32"
1109 dnl Define the command used to update the dependencies (this option
1110 dnl mainly for FLTK core developers - not necessary for users)
1111 MAKEDEPEND="\$(CXX) -M"
1112 AC_SUBST(MAKEDEPEND)
1114 dnl Add warnings to compiler switches:
1115 dnl do this last so messing with switches does not break tests
1117 if test -n "$GCC"; then
1118     # Show all standard warnings + unused variables, conversion errors,
1119     # and inlining problems when compiling...
1120     OPTIM="-Wall -Wunused -Wno-format-y2k $OPTIM"
1122     # The following additional warnings are useful for tracking down problems...
1123     #OPTIM="-Wshadow -Wconversion $OPTIM"
1125     # We know that Carbon is deprecated on OS X 10.4. To avoid hundreds of warnings
1126     # we will temporarily disable 'deprecated' warnings on OS X.
1127     if test "$uname" = "Darwin" -a $uversion -ge 800; then
1128         OPTIM="-Wno-deprecated-declarations $OPTIM"
1129     fi
1131     # Set the default compiler optimizations...
1132     if test -z "$DEBUGFLAG"; then
1133         #
1134         # Note: Can't use -fomit-frame-pointer - prevents tools like
1135         #       libsafe from working!
1136         #
1137         #       Don't use -fforce-mem, -fforce-addr, or -fcaller-saves.
1138         #       They all seem to make either no difference or enlarge
1139         #       the code by a few hundred bytes.
1140         #
1141         #       "-Os" seems to be the best compromise between speed and
1142         #       code size.  "-O3" and higher seem to make no effective
1143         #       difference in the speed of the code, but does bloat the
1144         #       library 10+%.
1145         #
1147         if test "x$with_optim" != x; then
1148             OPTIM="$with_optim $OPTIM"
1149         else
1150             OPTIM="-Os $OPTIM"
1151         fi
1152     fi
1154     # Generate position-independent code when needed...
1155     if test $PICFLAG = 1; then
1156         OPTIM="$OPTIM -fPIC"
1157     fi
1159     # See if GCC supports -fno-exceptions...
1160     AC_MSG_CHECKING(if GCC supports -fno-exceptions)
1161     OLDCFLAGS="$CFLAGS"
1162     CFLAGS="$CFLAGS -fno-exceptions"
1163     AC_TRY_COMPILE(,,
1164         OPTIM="$OPTIM -fno-exceptions"
1165         AC_MSG_RESULT(yes),
1166         AC_MSG_RESULT(no))
1167     CFLAGS="$OLDCFLAGS"
1169     # See if GCC supports -fno-strict-aliasing...
1170     AC_MSG_CHECKING(if GCC supports -fno-strict-aliasing)
1171     OLDCFLAGS="$CFLAGS"
1172     CFLAGS="$CFLAGS -fno-strict-aliasing"
1173     AC_TRY_COMPILE(,,
1174         OPTIM="$OPTIM -fno-strict-aliasing"
1175         AC_MSG_RESULT(yes),
1176         AC_MSG_RESULT(no))
1177     CFLAGS="$OLDCFLAGS"
1179     # See if we are running Solaris; if so, try the -fpermissive option...
1180     # This option is required on some versions of Solaris to work around
1181     # bugs in the X headers up through Solaris 7.
1182     #
1183     # Unlike the other compiler/optimization settings, this one is placed
1184     # in CFLAGS and CXXFLAGS so that fltk-config will provide the option
1185     # to clients - otherwise client apps will not compile properly...
1186     if test "$uname" = SunOS; then
1187         AC_MSG_CHECKING(if GCC supports -fpermissive)
1189         OLDCFLAGS="$CFLAGS"
1190         CFLAGS="$CFLAGS -fpermissive"
1191         AC_TRY_COMPILE(,,
1192             CXXFLAGS="$CXXFLAGS -fpermissive"
1193             AC_MSG_RESULT(yes),
1194             CFLAGS="$OLDCFLAGS"
1195             AC_MSG_RESULT(no))
1196     fi
1197 else
1198     case "$uname" in
1199         IRIX*)
1200             # Running some flavor of IRIX; see which version and
1201             # set things up according...
1202             if test "$uversion" -ge 62; then
1203                 # We are running IRIX 6.2 or higher; uncomment the following
1204                 # lines if you don't have IDO 7.2 or higher:
1205                 #
1206                 #     CXX="CC -n32 -mips3"
1207                 #     CC="cc -n32 -mips3"
1208                 #     LD="ld -n32 -mips3"
1209                 #     MAKEDEPEND="CC -M"
1211                 if test "x`grep abi=n32 /etc/compiler.defaults`" = x; then
1212                         AC_MSG_WARN(FOR BEST RESULTS BEFORE COMPILING: setenv SGI_ABI \"-n32 -mips3\")
1213                 fi
1215                 OPTIM="-fullwarn $OPTIM"
1216             fi
1217             if test -z "$DEBUGFLAG"; then
1218                 if test "x$with_optim" != x; then
1219                     OPTIM="$with_optim $OPTIM"
1220                 else
1221                     OPTIM="-O2 $OPTIM"
1222                     if test $uversion -gt 62; then
1223                         OPTIM="-OPT:Olimit=4000 $OPTIM"
1224                     fi
1225                 fi
1226             fi
1227             ;;
1228         HP-UX*)
1229             # Running HP-UX; these options should work for the HP compilers.
1230             if test -z "$DEBUGFLAG"; then
1231                 if test "x$with_optim" != x; then
1232                     OPTIM="$with_optim $OPTIM"
1233                 else
1234                     OPTIM="+O2 $OPTIM"
1235                 fi
1236             fi
1238             if test $PICFLAG = 1; then
1239                 OPTIM="+z $OPTIM"
1240             fi
1242             CXXFLAGS="$CXXFLAGS +W336,501,736,740,749,829"
1243             ;;
1244         OSF1*)
1245             # Running Digital/Tru64 UNIX; these options should work for the
1246             # Digital/Compaq/NewHP compilers.
1247             if test -z "$DEBUGFLAG"; then
1248                 if test "x$with_optim" != x; then
1249                     OPTIM="$with_optim $OPTIM"
1250                 else
1251                     OPTIM="-O2 $OPTIM"
1252                 fi
1253             fi
1254             ;;
1255         SunOS*)
1256             # Solaris
1257             if test -z "$DEBUGFLAG"; then
1258                 if test "x$with_optim" != x; then
1259                     OPTIM="$with_optim $OPTIM"
1260                 else
1261                     OPTIM="-xO3 $OPTIM"
1262                 fi
1263             fi
1265             if test $PICFLAG = 1; then
1266                 OPTIM="-KPIC $OPTIM"
1267             fi
1268             ;;
1269         AIX*)
1270             if test -z "$DEBUGFLAG"; then
1271                 if test "x$with_optim" != x; then
1272                     OPTIM="$with_optim $OPTIM"
1273                 else
1274                     OPTIM="-O2 $OPTIM"
1275                 fi
1276             fi
1278             AC_MSG_WARN(The AIX C and C++ compilers are known not to correctly compile the FLTK library.)
1279             ;;
1280         *)
1281             # Running some other operating system; inform the user they
1282             # should contribute the necessary options via the STR form..
1283             AC_MSG_WARN(Building FLTK with default compiler optimizations)
1284             AC_MSG_WARN(Send the FLTK developers your uname and compiler options via http://www.fltk.org/str.php)
1285             ;;
1286     esac
1289 OPTIM="$DEBUGFLAG $OPTIM"
1291 dnl Take archflags away from CFLAGS (makefiles use ARCHFLAGS explicitly)
1292 if test `uname` = Darwin; then
1293   if test "x$with_archflags" != x ; then
1294     CFLAGS="`echo $CFLAGS | sed -e "s/$with_archflags//g"`"
1295   fi
1298 dnl Define the FLTK documentation directory...
1299 case $uname in
1300   MINGW*)
1301      # Determine the path where MSys has /usr installed
1302         msyspath=`mount | grep '\/usr' | grep -v '\/usr\/bin' | cut -d ' ' -f -1 | sed -e 's/\\\/\// g'`
1303      # Then substitute that in the WIN32 path instead of /usr
1304         AC_DEFINE_UNQUOTED(FLTK_DOCDIR, "$msyspath/local/share/doc/fltk")
1305     ;;
1306   *)
1307     if test x$prefix = xNONE; then
1308         AC_DEFINE_UNQUOTED(FLTK_DOCDIR, "/usr/local/share/doc/fltk")
1309     else
1310         AC_DEFINE_UNQUOTED(FLTK_DOCDIR, "$prefix/share/doc/fltk")
1311     fi
1312     ;;
1313 esac
1315 dnl Define the FLTK data directory...
1316 if test x$prefix = xNONE; then
1317     AC_DEFINE_UNQUOTED(FLTK_DATADIR, "/usr/local/share/fltk")
1318 else
1319     AC_DEFINE_UNQUOTED(FLTK_DATADIR, "$prefix/share/fltk")
1322 dnl Summarize results of configure tests...
1323 echo ""
1324 echo "Configuration Summary"
1325 echo "-------------------------------------------------------------------------"
1327 case $uname_GUI in
1328     CYGWIN* | MINGW*)
1329         graphics="GDI"
1330         ;;
1331     Darwin*)
1332         graphics="Quartz"
1333         ;;
1334     *)
1335         graphics="X11"
1336         if test x$enable_xft != xno; then
1337             graphics="$graphics+Xft"
1338         fi
1339         if test x$enable_xdbe != xno; then
1340             graphics="$graphics+Xdbe"
1341         fi
1342         if test x$enable_xinerama != xno; then
1343             graphics="$graphics+Xinerama"
1344         fi
1345         ;;
1346 esac
1348 echo "    Directories: prefix=$prefix"
1349 echo "                 bindir=$bindir"
1350 echo "                 datadir=$datadir"
1351 echo "                 datarootdir=$datarootdir"
1352 echo "                 exec_prefix=$exec_prefix"
1353 echo "                 includedir=$includedir"
1354 echo "                 libdir=$libdir"
1355 echo "                 mandir=$mandir"
1356 case $uname in
1357   MINGW*)
1358     echo "                 MSys docpath=$msyspath/local/share/doc/fltk"
1359   ;;
1360 esac
1361 echo "       Graphics: $graphics"
1363 if test x$JPEG = x; then
1364     echo "Image Libraries: JPEG=System"
1365 else
1366     echo "Image Libraries: JPEG=Builtin"
1368 if test x$PNG = x; then
1369     echo "                 PNG=System"
1370 else
1371     echo "                 PNG=Builtin"
1373 if test x$ZLIB = x; then
1374     echo "                 ZLIB=System"
1375 else
1376     echo "                 ZLIB=Builtin"
1378 if test x$enable_cairo = xyes; then
1379     echo "                 CAIRO=lib"
1381 if test x$enable_cairoext = xyes; then
1382     echo "                 CAIRO=internal_use"
1386 if test x$enable_largefile != xno; then
1387     echo "    Large Files: YES"
1388 else
1389     echo "    Large Files: NO"
1392 if test x$GLDEMOS = x; then
1393     echo "         OpenGL: NO"
1394 else
1395     echo "         OpenGL: YES"
1398 if test x$THREADS = x; then
1399     echo "        Threads: NO"
1400 else
1401     echo "        Threads: YES"
1404 dnl Write all of the files...
1405 AC_CONFIG_HEADER(config.h:configh.in)
1406 AC_OUTPUT(makeinclude fltk.list fltk-config fltk.spec FL/Makefile)
1408 dnl Make sure the fltk-config script is executable...
1409 chmod +x fltk-config
1412 dnl End of "$Id: configure.in 8511 2011-03-06 16:54:58Z manolo $".