1##############################################################################
2#
3# configure.ac
4#
5# Process this file with autoconf to produce the configure script.
6#
7# ---------------------------------------------------------------------------
8#
9# Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
10# Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd.
11#
12# POV-Ray is free software: you can redistribute it and/or modify
13# it under the terms of the GNU Affero General Public License as
14# published by the Free Software Foundation, either version 3 of the
15# License, or (at your option) any later version.
16#
17# POV-Ray is distributed in the hope that it will be useful,
18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20# GNU Affero General Public License for more details.
21#
22# You should have received a copy of the GNU Affero General Public License
23# along with this program.  If not, see <http://www.gnu.org/licenses/>.
24#
25#---------------------------------------------------------------------------
26#
27# POV-Ray is based on the popular DKB raytracer version 2.12.
28# DKBTrace was originally written by David K. Buck.
29# DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
30#
31##############################################################################
32
33# configure.ac for the source distribution of POV-Ray v3.8 for UNIX
34# Report bugs via https://github.com/POV-Ray/povray/issues
35#
36# Based on configure.ac from POV-Ray v3.7
37# Written by Nicolas Calimet <nicolas.calimet@povray.org>
38# Based on configure.ac from POV-Ray v3.6
39
40# Required autoconf version.
41AC_PREREQ(2.68)
42
43# Inits.
44
45# The file VERSION must contain only the version string MAJOR.MINOR.REVISION(.PATCHLEVEL)(-PRERELEASE)
46AC_INIT([POV-Ray], m4_normalize(m4_include([VERSION])), [unix-bugreports-2011@povray.org], [povray])
47
48# VERSION_BASE is then defined as MAJOR.MINOR
49VERSION_BASE=`echo $PACKAGE_VERSION | sed 's,\([[0-9]]*.[[0-9]]*\).*,\1,g'`
50AC_SUBST([VERSION_BASE])
51AC_DEFINE_UNQUOTED([VERSION_BASE], ["$VERSION_BASE"], [Base version number of package.])
52AC_CONFIG_AUX_DIR([unix/config])
53AC_CONFIG_HEADERS([unix/config.h])
54AC_CONFIG_SRCDIR([unix/disp_text.cpp])
55
56# Additional autoconf macros.
57# Those required by other macros go first.
58m4_include([unix/config/ax_require_defined.m4])
59# The remainder we're sorting alphabetically.
60m4_include([unix/config/ax_pthread.m4])
61m4_include([unix/config/ax_arg_enable.m4])
62m4_include([unix/config/ax_arg_with.m4])
63m4_include([unix/config/ax_boost_base.m4])
64m4_include([unix/config/ax_boost_thread.m4])
65m4_include([unix/config/ax_test_compiler_flags.m4])
66m4_include([unix/config/ax_check_compile_flag.m4])
67m4_include([unix/config/ax_check_lib.m4])
68m4_include([unix/config/ax_check_libjpeg.m4])
69m4_include([unix/config/ax_check_libsdl.m4])
70m4_include([unix/config/ax_check_libtiff.m4])
71m4_include([unix/config/ax_check_openexr.m4])
72m4_include([unix/config/ax_compare_version.m4])
73m4_include([unix/config/ax_compiler_vendor.m4])
74m4_include([unix/config/ax_compiler_version.m4])
75m4_include([unix/config/ax_cxx_compile_stdcxx.m4])
76m4_include([unix/config/ax_fix_incorrect_path.m4])
77m4_include([unix/config/ax_prog_ld_static.m4])
78m4_include([unix/config/ax_x86_arch.m4])
79
80# Required versions of the support libraries.
81# Must be declared after AC_INIT.
82required_libboost_version="1.38"
83required_libz_version="1.2.1"
84required_libpng_version="1.2.5"
85required_libjpeg_version="6b"
86required_libtiff_version="3.6.1"
87required_libsdl_version="1.2"
88required_openexr_version="1.2"
89
90# Supported options.
91# AX_ARG_ENABLE([--enable-avx2],             [enable AVX2 features and compiler optmization])
92AX_ARG_ENABLE([--enable-watch-cursor],     [enable a watch cursor over the display while rendering (X Window only)])
93AX_ARG_ENABLE([--enable-debug],            [enable compiler debugging mode])
94AX_ARG_ENABLE([--enable-profile],          [enable program execution profiling])
95AX_ARG_ENABLE([--enable-static],           [enable the linker to create static executable (no run-time dependancy to external libraries, larger binary)])
96AX_ARG_ENABLE([--disable-optimiz],         [disable all compiler optimizations])
97AX_ARG_ENABLE([--disable-optimiz-arch],    [disable architecture-specific compiler optimizations])
98AX_ARG_ENABLE([--disable-pipe],            [disable usage of pipes during compilation (use temporary files instead)])
99AX_ARG_ENABLE([--disable-strip],           [disable stripping all symbols from the object files (larger binary)])
100AX_ARG_ENABLE([--disable-shared],          [disable linking with shared libraries (same as --enable-static)])
101AX_ARG_ENABLE([--disable-io-restrictions], [disable POV-Ray's mechanism for control of I/O operations])
102
103AX_ARG_WITH([--without-cygwin-dll], [],    [don't link with the Cygwin DLL (MinGW required)])
104AX_ARG_WITH([--with-zlib],          [DIR], [use the ZLIB library (in directory DIR)])
105AX_ARG_WITH([--with-libpng],        [DIR], [use the PNG library (in directory DIR)])
106AX_ARG_WITH([--with-libjpeg],       [DIR], [use the JPEG library (in directory DIR)])
107AX_ARG_WITH([--with-libtiff],       [DIR], [use the TIFF library (in directory DIR)])
108AX_ARG_WITH([--with-libsdl],        [DIR], [use the SDL library (in directory DIR)])
109AX_ARG_WITH([--with-libmkl],        [DIR], [use the Intel(R) Math Kernel Library (in directory DIR)])
110AX_ARG_WITH([--with-openexr],       [DIR], [use the OpenEXR library (in directory DIR)])
111
112AC_ARG_VAR([COMPILED_BY], [customize the "unofficial version" message])
113AC_ARG_VAR([NON_REDISTRIBUTABLE_BUILD], [see the installation documentation])
114AC_ARG_VAR([C99_COMPATIBLE_RADIOSITY], [adapt radiosity code to non-IEEE 754 floating point, requires ISO C99 compiler and library (see octree.cpp for details)])
115
116
117###############################################################################
118
119# Remove povray.ini unconditionally.
120rm -f ./povray.ini
121
122
123# Instruction message.
124if test x"$COMPILED_BY" = x""; then
125  COMPILED_BY="$USER <no contact address>"
126fi
127
128pov_no_distrib="${NON_REDISTRIBUTABLE_BUILD:-no}"
129
130# Don't use 'echo' (not saved into config.log / doesn't honor --silent).
131# Don't use AC_MSG_NOTICE which prints things first.
132AC_MSG_RESULT([
133===============================================================================
134Configure $PACKAGE_NAME version $PACKAGE_VERSION
135===============================================================================
136
137This is an unofficial version compiled by:
138 $COMPILED_BY
139The POV-Ray Team(tm) is not responsible for supporting this version.])
140
141AC_DEFINE_UNQUOTED([BUILT_BY], ["$COMPILED_BY"], [Who compiled this binary.])
142
143
144###############################################################################
145
146AC_MSG_RESULT([
147Environment
148-----------])
149
150AC_CANONICAL_BUILD
151AC_CANONICAL_HOST
152
153AM_INIT_AUTOMAKE([1.9 dist-bzip2 subdir-objects])
154AM_MAINTAINER_MODE
155
156AX_FIX_INCORRECT_PATH(C_INCLUDE_PATH, ".", [pov_warn_path="$pov_warn_path C_INCLUDE_PATH"])
157AX_FIX_INCORRECT_PATH(CPLUS_INCLUDE_PATH, ".", [pov_warn_path="$pov_warn_path CPLUS_INCLUDE_PATH"])
158
159AM_PROG_AR
160
161
162###############################################################################
163
164AC_MSG_RESULT([
165Programs
166--------])
167
168# Check for the C compiler (used in some library checks).
169# Init compiler flags to avoid defaults such as '-g -O2'.
170CFLAGS="$CFLAGS"
171AC_PROG_CC
172AC_PROG_CPP
173
174# Force checking essential (ANSI-compliant) headers.
175AC_CHECK_HEADERS([stdlib.h])
176
177
178# Check for the C++ compiler and version.
179# Init compiler flags to avoid defaults such as '-g -O2'.
180AC_LANG([C++])
181CXXFLAGS="$CXXFLAGS"
182AC_PROG_CXX
183AC_MSG_CHECKING([whether the $CXX compiler works])
184AC_LINK_IFELSE([AC_LANG_PROGRAM],
185  [AC_MSG_RESULT([yes])],
186  [
187    AC_MSG_RESULT([no])
188    AC_MSG_FAILURE([C++ compiler cannot create executables])
189  ]
190)
191AC_PROG_CXXCPP
192AX_CXX_COMPILE_STDCXX(11)
193
194AX_COMPILER_VENDOR
195AX_COMPILER_VERSION
196pov_compiler=`echo $CXX | sed 's,.*/,,'`  # equivalent to `basename $CXX`
197pov_compiler_vendor="$ax_cv_cxx_compiler_vendor"
198pov_compiler_version="$pov_compiler"
199if test "$ax_compiler_version"; then
200  pov_compiler_version="$pov_compiler $ax_compiler_version"
201fi
202
203pov_built_for="$host"  # default
204AC_DEFINE_UNQUOTED([BUILD_ARCH], ["$build"], [Build architecture.])
205AC_DEFINE_UNQUOTED([COMPILER_VENDOR], ["$pov_compiler_vendor"], [Compiler vendor.])
206AC_DEFINE_UNQUOTED([COMPILER_VERSION], ["$pov_compiler_version"], [Compiler version.])
207AC_DEFINE_UNQUOTED([POV_COMPILER_INFO], ["$pov_compiler_version @ $build"], [Compiler version (processed).])
208
209
210# Not necessary when AM_MAINTAINER_MODE is called above.
211###AC_PROG_MAKE_SET
212
213AC_PROG_RANLIB
214
215
216AC_MSG_CHECKING([for stat format option])
217echo "trying stat --format='%u,%g' ." >>config.log
218if stat --format='%u,%g' . >>config.log 2>>config.log && test x`stat --format=Foo .` = x"Foo"; then
219  stat_format="--format="
220else
221  echo "trying stat --f '%u,%g' ." >>config.log
222  if stat -f '%u,%g' . >>config.log 2>>config.log && test x`stat -f Foo .` = x"Foo"; then
223    stat_format="-f "
224  else
225    AC_MSG_FAILURE([stat command does not behave as required])
226  fi
227fi
228AC_MSG_RESULT([$stat_format])
229
230
231###############################################################################
232
233AC_MSG_RESULT([
234Libraries
235---------])
236
237# Link with or without the cygwin DLL.
238AC_MSG_CHECKING([whether to link with cygwin DLL])
239if test x"$with_cygwin_dll" = x"no"; then
240  AC_MSG_RESULT([no])
241  case "$build" in
242    *cygwin*)
243      pov_flags="-mno-cygwin"
244      pov_cygwin_save_cxxflags="$CXXFLAGS"
245      AX_TEST_COMPILER_FLAGS([$pov_flags],
246        [
247          AC_CHECK_LIB([mingw32], [main],
248            [
249              LDFLAGS="$LDFLAGS $pov_flags"
250              # -D__CYGWIN is required for tiffio.h (incl. in tiff_pov.cpp)
251              CPPFLAGS="$CPPFLAGS -D__CYGWIN $pov_flags"
252            ],
253            [with_cygwin_dll="yes"]
254          )
255        ],
256        [with_cygwin_dll="yes"]
257      )
258      if test x"$with_cygwin_dll" != x"no"; then
259        AC_MSG_WARN([Cannot link without Cygwin DLL])
260        CXXFLAGS="$pov_cygwin_save_cxxflags"
261      fi
262    ;;
263  esac
264else
265  case "$build" in
266    *cygwin*)
267      AC_MSG_RESULT([yes])
268    ;;
269    *)
270      AC_MSG_RESULT([no])
271    ;;
272  esac
273fi
274
275# Link with static library, update LDFLAGS.
276if test x"$enable_static" = x"yes" && test x"$enable_shared" != x"yes"; then
277  enable_shared="no"
278fi
279AC_MSG_CHECKING([whether to enable static linking])
280if test x"$enable_shared" = x"no"; then
281  AC_MSG_RESULT([yes])
282  AX_PROG_LD_STATIC
283else
284  AC_MSG_RESULT([no])
285fi
286
287# Try to use the -v compiler flag for better debugging.
288if test ! `$CXX -v < /dev/null 2> /dev/null`; then
289  pov_lib_save_cxxflags="$CXXFLAGS"
290  CXXFLAGS="$CXXFLAGS -v"
291  AC_LINK_IFELSE([AC_LANG_PROGRAM()])
292  CXXFLAGS="$pov_lib_save_cxxflags"
293fi
294
295# Posix threads
296AX_PTHREAD
297CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"  # append
298LIBS="$LIBS $PTHREAD_CFLAGS $PTHREAD_LIBS"  # append
299
300# Boost; required library
301# the following macro stops with error when boost is not found
302AX_BOOST_BASE([$required_libboost_version])
303AX_BOOST_THREAD
304if test x"$ax_cv_boost_thread" != x"yes"; then
305  AC_MSG_ERROR([cannot find a suitable boost thread library])
306else
307  CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"  # append
308  LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"     # append
309  LIBS="$BOOST_THREAD_LIB $LIBS"
310fi
311AC_MSG_CHECKING([whether the boost thread library is usable])
312SAVED_LIBS=$LIBS
313boost_thread_links=0
314for extralib in '' '-lboost_system'
315do
316  LIBS=$SAVED_LIBS
317  LIBS="$LIBS $extralib"
318  AC_RUN_IFELSE([
319    AC_LANG_PROGRAM([[
320      #include <boost/thread/thread.hpp>
321    ]],[[
322      boost::mutex m;
323      boost::defer_lock_t();
324      return 0;
325    ]])
326  ],[
327    AC_MSG_RESULT([yes])
328    BOOST_THREAD_LIB="$BOOST_THREAD_LIB $extralib"
329    boost_thread_links=1
330  ],,[
331    AC_MSG_RESULT([cross-compiling])  # FIXME
332  ])
333  if test $boost_thread_links = '1'; then
334    break
335  fi
336done
337if test $boost_thread_links != '1'; then
338  AC_MSG_RESULT([no])
339  AC_MSG_FAILURE([cannot link with the boost thread library])
340fi
341
342AC_DEFINE([USE_OFFICIAL_BOOST], [], [Use the official Boost libraries.])
343
344# Intel Math Kernel library
345pov_save_ldflags="$LDFLAGS"
346test x"$with_libmkl" != x"" && test x"$with_libmkl" != x"no" && LDFLAGS="-L$with_libmkl $LDFLAGS"
347AC_CHECK_LIB([mkl], [sin])
348test x"$ac_cv_lib_mkl_sin" = x"no" && LDFLAGS="$pov_save_ldflags"
349
350# libm
351AC_CHECK_LIB([m], [sin])
352
353# real-time clock
354AC_CHECK_LIB([rt], [clock_gettime])
355
356# libz; required library for distributable builds
357AC_MSG_CHECKING([whether to use the ZLIB library])
358if test x"$pov_no_distrib" = x"yes" && test x"$with_zlib" = x"no"; then
359  AC_MSG_RESULT([no (NON DISTRIBUTABLE BUILD)])
360  AC_MSG_WARN([all program features using the ZLIB library are disabled])
361  AC_DEFINE([LIBZ_MISSING], [], [Don't use libz.])
362else
363  if test x"$with_zlib" = x"no"; then
364    AC_MSG_ERROR([disabling support for ZLIB requires NON_REDISTRIBUTABLE_BUILD=yes])
365  fi
366  AC_MSG_RESULT([yes])
367  AX_CHECK_LIB([z], [$required_libz_version], [z], [zlibVersion], [zlib.h], [zlibVersion()], [$with_zlib])
368  if test x"$ax_check_lib" != x"ok"; then
369    AC_MSG_ERROR([cannot find a suitable ZLIB library])
370  else
371    pov_libz=ok
372  fi
373fi
374
375# libpng; required library for distributable builds
376AC_MSG_CHECKING([whether to use the PNG library])
377if test x"$pov_no_distrib" = x"yes" && test x"$with_libpng" = x"no"; then
378  AC_MSG_RESULT([no (NON DISTRIBUTABLE BUILD)])
379  AC_MSG_WARN([all program features using the PNG library are disabled])
380  AC_DEFINE([LIBPNG_MISSING], [], [Don't use libpng.])
381else
382  if test x"$with_libpng" = x"no"; then
383    AC_MSG_ERROR([disabling support for PNG requires NON_REDISTRIBUTABLE_BUILD=yes])
384  fi
385  AC_MSG_RESULT([yes])
386  AX_CHECK_LIB([png], [$required_libpng_version], [png14 png png12 png], [png_get_libpng_ver], [png.h], [png_get_libpng_ver(NULL)], [$with_libpng])
387  ### FIXME: do not allow for 1.4.x
388	# This doesn't appear to be needed now that we're allowing 1.4 (jh)
389  # AC_MSG_CHECKING([for libpng version < 1.4 (not supported at the moment!)])
390  # AX_COMPARE_VERSION([$ax_check_lib_version], [ge], [1.4], [ax_check_lib="bad"], [ax_check_lib="ok"])
391  # AC_MSG_RESULT([$ax_check_lib])
392  ###
393  if test x"$ax_check_lib" != x"ok"; then
394    AC_MSG_ERROR([cannot find a suitable PNG library])
395  else
396    pov_libpng=ok
397  fi
398fi
399
400# FIXME: what about cygwin?
401# libjpeg; required library for distributable builds
402AC_MSG_CHECKING([whether to use the JPEG library])
403if test x"$pov_no_distrib" = x"yes" && test x"$with_libjpeg" = x"no"; then
404  AC_MSG_RESULT([no (NON DISTRIBUTABLE BUILD)])
405  AC_MSG_WARN([all program features using the JPEG library are disabled])
406  AC_DEFINE([LIBJPEG_MISSING], [], [Don't use libjpeg.])
407else
408  if test x"$with_libjpeg" = x"no"; then
409    AC_MSG_ERROR([disabling support for JPEG requires NON_REDISTRIBUTABLE_BUILD=yes])
410  fi
411  AC_MSG_RESULT([yes])
412  AX_CHECK_LIBJPEG([$required_libjpeg_version], [$with_libjpeg])
413  if test x"$ax_check_libjpeg" != x"ok"; then
414    AC_MSG_ERROR([cannot find a suitable JPEG library])
415  else
416    pov_libjpeg=ok
417  fi
418fi
419
420# libtiff; required library for distributable builds
421AC_MSG_CHECKING([whether to use the TIFF library])
422if test x"$pov_no_distrib" = x"yes" && test x"$with_libtiff" = x"no"; then
423  AC_MSG_RESULT([no (NON DISTRIBUTABLE BUILD)])
424  AC_MSG_WARN([all program features using the TIFF library are disabled])
425  AC_DEFINE([LIBTIFF_MISSING], [], [Don't use libtiff.])
426else
427  if test x"$with_libtiff" = x"no"; then
428    AC_MSG_ERROR([disabling support for TIFF requires NON_REDISTRIBUTABLE_BUILD=yes])
429  fi
430  AC_MSG_RESULT([yes])
431  AX_CHECK_LIBTIFF([$required_libtiff_version], [$with_libtiff])
432  if test x"$ax_check_libtiff" != x"ok"; then
433    AC_MSG_ERROR([cannot find a suitable TIFF library])
434  else
435    pov_libtiff=ok
436  fi
437fi
438
439# OpenEXR; optional library
440AC_MSG_CHECKING([whether to use the OpenEXR library])
441if test x"$with_openexr" = x"no"; then
442  AC_MSG_RESULT([no])
443else
444  AC_MSG_RESULT([yes])
445  AX_CHECK_OPENEXR([$required_openexr_version])
446  if test x"$ax_check_openexr" = x"ok"; then
447    pov_libopenexr=ok
448  fi
449fi
450if test x"$pov_libopenexr" != x"ok"; then
451  AC_MSG_WARN([all program features using the OpenEXR library are disabled])
452  AC_DEFINE([OPENEXR_MISSING], [], [Don't use OpenEXR.])
453fi
454
455# Unix-specific display libraries.
456if test x"$with_cygwin_dll" = x"no"; then
457
458  # disable preview displays under Cygwin/MinGW
459  AC_MSG_NOTICE([X Window display will be disabled])
460  AC_MSG_NOTICE([SVGAlib display will be disabled])
461  AC_DEFINE([X_DISPLAY_MISSING], [], [Don't use the X Window System.])
462  pov_xwin_msg="disabled"
463
464else
465
466  # libX11
467  # first add default paths to help finding X11
468  test x"$x_includes"  = x"NONE" && x_includes="/usr/include"
469  test x"$x_libraries" = x"NONE" && x_libraries="/usr/lib"
470
471  pov_xwin_msg="disabled"
472  AC_PATH_XTRA
473  if test x"$have_x" = x"yes"; then
474    AC_CHECK_HEADER([X11/Xlib.h],
475      [
476        AC_CHECK_LIB([X11], [XFlush],
477          [
478            # X_CFLAGS should actually be X_CPPFLAGS since it only adds -Idir
479            CPPFLAGS="$CPPFLAGS $X_CFLAGS"  # append
480            LDFLAGS="$LDFLAGS $X_LIBS"      # append
481            LIBS="$X_PRE_LIBS -lX11 $X_EXTRA_LIBS $LIBS"  # $PTHREAD_LIBS is already in $LIBS
482            pov_xwin_msg="enabled"
483          ],
484          [
485            AC_MSG_NOTICE([X Window display will be disabled])
486            AC_DEFINE([X_DISPLAY_MISSING],[1])
487          ],
488          [$X_PRE_LIBS $X_EXTRA_LIBS $PTHREAD_LIBS]
489        )
490      ]
491    )
492  else
493    AC_MSG_NOTICE([X Window display will be disabled])
494  fi
495
496  # color icon (libXpm) and X Window cursor
497  if test x"$pov_xwin_msg" = x"enabled"; then
498    AC_CHECK_HEADER([X11/xpm.h], [AC_CHECK_LIB([Xpm], [XpmCreatePixmapFromData])])
499    AC_MSG_CHECKING([whether to enable the watch cursor])
500    if test x"$enable_watch_cursor" = x"yes"; then
501      AC_MSG_RESULT([yes])
502      AC_CHECK_HEADER([X11/cursorfont.h],
503        [
504          AC_CHECK_FUNC([XCreateFontCursor],
505            [AC_DEFINE([USE_CURSOR], [], [Use a watch cursor while rendering.])],
506            [AC_MSG_NOTICE([watch cursor will be disabled])]
507          )
508        ]
509      )
510    else
511      AC_MSG_RESULT([no])
512    fi
513  fi
514
515#  AM_CONDITIONAL([BUILD_AVX2], [test x$enable_avx2 = xyes])
516#  if test x"$enable_avx2" = x"yes"; then
517#    AC_MSG_RESULT([yes])
518#    AC_DEFINE([ENABLE_AVX2], [],[Enable AVX2 features and compiler optimization])
519#
520#    CXXFLAGS="$CXXFLAGS -mavx2 -mfma"  # append
521#  else
522#    AC_MSG_RESULT([no])
523#  fi
524
525  ### Note from Warp <warp@tag.povray.org> :
526  # Using "-static" for static linking in Solaris causes a linkage error.
527  # For some reason the X libraries in Solaris are not designed for static
528  # linking. [...] So at least for Solaris the '-static' flag should
529  # definitely be turned off by default.
530  if test x"$ax_cv_prog_ld_static" != x"" && test x"$ac_cv_lib_X11_XFlush" = x"yes"; then
531    case "$build" in
532      sparc-*)
533        AC_MSG_WARN([Using $ax_cv_prog_ld_static might cause a linkage error])
534      ;;
535    esac
536  fi
537
538  # libSDL
539  if test x"$pov_xwin_msg" = x"enabled"; then
540    AX_CHECK_LIBSDL([$required_libsdl_version])
541    if test x"$ax_check_libsdl" = x"ok"; then
542      pov_libsdl=ok
543      pov_xwin_msg="$pov_xwin_msg (using SDL)"
544    else
545      AC_MSG_WARN([the preview display is disabled])
546      pov_xwin_msg="disabled"  # FIXME
547    fi
548  fi
549
550fi  # with_cygwin_dll
551
552
553###############################################################################
554
555AC_MSG_RESULT([
556Language constructs and functions
557---------------------------------])
558
559# Compiling on the mingw32 platform (e.g. using MSYS) also requires
560# the -D__CYGWIN flag for tiff_pov.cpp
561case "$build" in
562  *mingw32*)  CPPFLAGS="$CPPFLAGS -D__CYGWIN";;
563esac
564
565
566# Language constructs.
567
568AC_HEADER_TIME
569AC_CHECK_HEADERS([time.h limits.h sys/resource.h sys/time.h sys/wait.h unistd.h])
570
571AC_TYPE_INT8_T
572AC_TYPE_INT16_T
573AC_TYPE_INT32_T
574AC_TYPE_INT64_T
575AC_TYPE_SIZE_T
576AC_STRUCT_TM
577
578AC_CHECK_SIZEOF([int])
579AC_CHECK_SIZEOF([long int])	# check for 64 bit support
580AC_CHECK_SIZEOF([size_t])	# check for 64 bit support
581AC_CHECK_SIZEOF([float])
582
583
584# Checks for functions.
585
586# the test for memcmp does not work well with C++
587AC_LANG_PUSH([C])
588AC_FUNC_MEMCMP
589AC_LANG_POP([C])
590
591#AC_FUNC_STRFTIME  # FIXME
592#AC_FUNC_VPRINTF   # FIXME
593
594# getcwd or its equivalent with getenv <unistd.h>
595AC_LANG_PUSH([C])
596AC_CHECK_FUNCS([getcwd],
597  [],
598  [
599    AC_MSG_CHECKING([for working getenv("PWD")])
600    AC_RUN_IFELSE(
601      [
602        AC_LANG_SOURCE(
603[#include <stdlib.h>
604int main(void) { return (getenv("PWD") == NULL); }]
605        )
606      ],
607      [AC_MSG_RESULT([yes])],
608      [
609        AC_MSG_RESULT([no])
610        AC_MSG_NOTICE([I/O restriction code will be disabled])
611        enable_io_restrictions="no"
612      ],
613      [
614        AC_MSG_RESULT([cross-compiling])
615        AC_MSG_NOTICE([I/O restriction code will be disabled])
616        enable_io_restrictions="no"
617      ]
618    )
619  ]
620)
621AC_LANG_POP([C])
622
623# readlink <unistd.h>
624if test x"$enable_io_restrictions" != x"no"; then
625  AC_CHECK_FUNCS([readlink],
626    [],
627    [
628      AC_MSG_NOTICE([I/O restriction code will be disabled])
629      enable_io_restrictions="no"
630    ]
631  )
632fi
633
634# nanosleep <time.h>
635AC_CHECK_FUNCS([nanosleep])
636
637# usleep and related <unistd.h>
638AC_CHECK_FUNCS([usleep])
639AC_CHECK_TYPES([useconds_t])
640
641# clock_gettime and related <time.h>
642AC_CHECK_FUNCS([clock_gettime])
643AC_CHECK_DECLS([CLOCK_MONOTONIC, CLOCK_REALTIME, CLOCK_PROCESS_CPUTIME_ID, CLOCK_THREAD_CPUTIME_ID],
644  [], [], [[#include <time.h>]]
645)
646AC_CHECK_TYPES([clockid_t], [], [], [[#include <time.h>]])
647
648# getrusage and related <sys/resource.h>
649AC_CHECK_FUNCS([getrusage])
650AC_CHECK_DECLS([RUSAGE_SELF, RUSAGE_THREAD, RUSAGE_LWP],
651  [], [], [[#include <sys/resource.h>]]
652)
653
654# gettimeofday <sys/time.h>
655AC_CHECK_FUNCS([gettimeofday])
656
657# asinh and friends (requires libm)
658AC_CHECK_FUNCS([asinh],
659  [],
660  [AC_DEFINE([NEED_INVHYP], [], [Inverse hyperbolic functions.])]
661)
662
663# support for non-IEEE compilers (requires libm)
664if test x"$C99_COMPATIBLE_RADIOSITY" != x"" || test x"$ac_cv_sizeof_int" != x"4" || test x"$ac_cv_sizeof_float" != x"4"; then
665  AC_CHECK_FUNCS([copysign],
666    [],
667    [AC_MSG_ERROR([
668*** Cannot find the 'copysign' function required for non-ieee platform
669])]
670  )
671  if test x"$C99_COMPATIBLE_RADIOSITY" = x""; then  # auto-detection
672    AC_CHECK_FUNCS([ilogbf],
673      [AC_DEFINE([C99_COMPATIBLE_RADIOSITY], [2], [See source/backend/support/octree.cpp for details.])],
674      [AC_CHECK_FUNCS([ilogb],
675         [AC_DEFINE([C99_COMPATIBLE_RADIOSITY], [4], [See source/backend/support/octree.cpp for details.])],
676         [AC_CHECK_FUNCS([logbf],
677            [AC_DEFINE([C99_COMPATIBLE_RADIOSITY], [1], [See source/backend/support/octree.cpp for details.])],
678            [AC_CHECK_FUNCS([logb],
679               [AC_DEFINE([C99_COMPATIBLE_RADIOSITY], [3], [See source/backend/support/octree.cpp for details.])],
680               [AC_MSG_ERROR([
681*** Cannot find a 'logb' or equivalent function required for non-ieee platform
682])]
683             )]
684          )]
685       )]
686    )
687  else  # check value of C99_COMPATIBLE_RADIOSITY and function presence
688    case "$C99_COMPATIBLE_RADIOSITY" in
689      1) AC_CHECK_FUNCS([logbf],  [], [AC_MSG_ERROR([logbf not found])]) ;;
690      2) AC_CHECK_FUNCS([ilogbf], [], [AC_MSG_ERROR([ilogbf not found])]) ;;
691      3) AC_CHECK_FUNCS([logb],   [], [AC_MSG_ERROR([logb not found])]) ;;
692      4) AC_CHECK_FUNCS([ilogb],  [], [AC_MSG_ERROR([ilogb not found])]) ;;
693      *) AC_MSG_ERROR([Unsupported C99_COMPATIBLE_RADIOSITY value]) ;;
694    esac
695    AC_DEFINE_UNQUOTED([C99_COMPATIBLE_RADIOSITY],
696      [$C99_COMPATIBLE_RADIOSITY],
697      [See source/backend/support/octree.cpp for details.]
698    )
699  fi
700fi
701
702
703###############################################################################
704
705AC_MSG_RESULT([
706Compiling
707---------])
708
709# Start with no flags at all, so back them up first.
710pov_save_cxxflags="$CXXFLAGS"
711CXXFLAGS=
712
713
714# Use pipes for communication between compilation stages.
715AC_MSG_CHECKING([whether to enable pipes for communications])
716if test x"$enable_pipe" = x"no"; then
717  AC_MSG_RESULT([no])
718else
719  AC_MSG_RESULT([yes])
720  AX_TEST_COMPILER_FLAGS([-pipe])
721fi
722
723
724# Language.
725
726# don't use -ansi since it can make compilation fail (e.g. on cygwin).
727#AX_TEST_COMPILER_FLAGS([-ansi], [], [AX_TEST_COMPILER_FLAGS([-Aa])])
728
729# -w would prevent all warning messages, even if -W... is given later on.
730# we don't want to clutter the compiling with lots of warnings.
731#AX_TEST_COMPILER_FLAGS([-W])
732#AX_TEST_COMPILER_FLAGS([-Wall], [], [AX_TEST_COMPILER_FLAGS([-fullwarn])])
733AX_TEST_COMPILER_FLAGS([-Wno-multichar])
734AX_TEST_COMPILER_FLAGS([-Wno-write-strings])
735if test x"$pov_compiler_vendor" = x"gnu"; then
736  AX_TEST_COMPILER_FLAGS([-fno-enforce-eh-specs])
737  AX_TEST_COMPILER_FLAGS([-Wno-non-template-friend])
738fi
739
740
741# I/O restrictions.
742AC_MSG_CHECKING([whether to enable I/O restrictions])
743if test x"$enable_io_restrictions" = x"no"; then
744  AC_MSG_RESULT([no])
745  AC_DEFINE([IO_RESTRICTIONS_DISABLED], [1], [I/O restrictions.])
746else
747  AC_MSG_RESULT([yes])
748  AC_DEFINE([IO_RESTRICTIONS_DISABLED], [0], [I/O restrictions.])
749fi
750
751
752# Compile with debugging code.
753
754AC_MSG_CHECKING([whether to enable debugging])
755
756if test x"$enable_debug" = x"yes"; then
757  AC_MSG_RESULT([yes])
758  AX_TEST_COMPILER_FLAGS([-g], [], [AC_MSG_WARN([Cannot set debugging mode])])
759  AC_DEFINE([UNIX_DEBUG], [], [Unix-specific debug messages.])
760else
761  AC_MSG_RESULT([no])
762fi
763
764
765# Compile for profiling.
766
767AC_MSG_CHECKING([whether to enable profiling])
768
769if test x"$enable_profile" = x"yes"; then
770  AC_MSG_RESULT([yes])
771  if test x"$ax_cv_prog_cxx_flags_g" = x""; then
772    AX_TEST_COMPILER_FLAGS([-g], [], [AC_MSG_WARN([Cannot set debugging mode])])
773  fi
774  AX_TEST_COMPILER_FLAGS([-pg], [], [AC_MSG_WARN([Cannot set profiling mode])])
775else
776  AC_MSG_RESULT([no])
777fi
778
779
780# Strip object files.
781
782AC_MSG_CHECKING([whether to enable stripping])
783
784if test x"$enable_strip" = x"no"; then
785  AC_MSG_RESULT([no])
786else
787  if test x"$enable_debug" = x"yes" || test x"$enable_profile" = x"yes"; then
788    AC_MSG_RESULT([no, debugging/profiling mode is on])
789  else
790    AC_MSG_RESULT([yes])
791    AX_TEST_COMPILER_FLAGS([-s], [], [AC_MSG_WARN([Cannot set stripping mode])])
792  fi
793fi
794
795
796# Compile with optimizations.
797
798AC_MSG_CHECKING([whether to enable optimizations])
799
800if test x"$enable_optimiz" != x"no"; then
801
802  AC_MSG_RESULT([yes])
803
804  # don't try -fast (makes ICC fail when linking due to implied -ipo flag).
805  AX_TEST_COMPILER_FLAGS([-O3], [], [AX_TEST_COMPILER_FLAGS([-O2], [], [AX_TEST_COMPILER_FLAGS([-O])])])
806
807  # compiler-specific flags.
808  case "$pov_compiler_vendor" in
809    gnu)
810      if test x"$ax_cv_prog_cxx_flags_O" = x"yes"; then  # -O was set
811        for pov_flags in "-fexpensive-optimizations" "-finline-functions" "-foptimize-sibling-calls"
812        do
813          AX_TEST_COMPILER_FLAGS([$pov_flags])
814        done
815      elif test x"$ax_cv_prog_cxx_flags_O2" = x"yes"; then  # -O2 was set
816        AX_TEST_COMPILER_FLAGS([-finline-functions])
817      fi
818      AX_TEST_COMPILER_FLAGS([-ffast-math])
819      ;;
820
821    intel)
822      AX_TEST_COMPILER_FLAGS([-ip])
823      ;;
824  esac
825
826  # Arch-specific tuning, alphabetically ordered for conveniency.
827  # Perform checks only when not cross-compiling.
828  AC_MSG_CHECKING([whether to enable architecture-specific optimizations])
829  if test x"$cross_compiling" != x"no"; then
830    AC_MSG_RESULT([no, cross-compiling])
831    pov_built_for="$pov_built_for (cross-compiled)"
832  elif test x"$enable_optimiz_arch" != x"no"; then
833    AC_MSG_RESULT([yes])
834
835    case "$build" in
836
837      alphaev*6*)
838        ### Suggested by Christopher Endsley <endsley@yokuts.csustan.edu>
839        for pov_flags in "-mcpu=ev56" "-mno-soft-float"
840        do
841          AX_TEST_COMPILER_FLAGS([$pov_flags])
842        done
843        case "$CXXFLAGS" in
844          *-mcpu=ev56*)  pov_built_for="$pov_built_for | DEC Alpha EV5 with BWX extensions" ;;
845        esac
846        ;;
847
848      i?86-* | k?-* | *86*64*)
849        case "$build" in
850          i?86-* | k?-*)  AX_TEST_COMPILER_FLAGS([-malign-double]);;
851        esac
852        AX_TEST_COMPILER_FLAGS([-xHost],            # ICC >= 11.0
853          [pov_built_for="$pov_built_for (using -xHost)"],
854          [AX_TEST_COMPILER_FLAGS([-march=native],  # GCC >= 4.2
855            [pov_built_for="$pov_built_for (using -march=native)"],
856            [AC_MSG_CHECKING([processor type])
857            AX_X86_ARCH
858            AC_MSG_RESULT([$ax_x86_cpumodel_nofreq])
859            AC_MSG_CHECKING([whether SSE instruction sets are supported])
860            test x"$ax_x86_cpuflags_SSE_list" = x"" && ax_x86_cpuflags_SSE_list=no
861            AC_MSG_RESULT([$ax_x86_cpuflags_SSE_list])
862            if test x"$ax_x86_arch" != x"unknown"; then
863              if test x"$pov_compiler_vendor" = x"intel"; then
864                case "$ax_x86_arch" in
865                  core2)
866                    AX_TEST_COMPILER_FLAGS([-xT]) ;;
867                  prescott|pentium4)  # Prescott, Northwood, Willamette
868                    AX_TEST_COMPILER_FLAGS([-xP], [], [AX_TEST_COMPILER_FLAGS([-xN], [], [AX_TEST_COMPILER_FLAGS([-xW])])]) ;;
869                  #pentium-m)  # Banias; option deprecated in ICC >= 10.0
870                  #  AX_TEST_COMPILER_FLAGS([-xB]) ;;
871                  pentium3)
872                    AX_TEST_COMPILER_FLAGS([-xK]) ;;
873                  pentium2)
874                    AX_TEST_COMPILER_FLAGS([-march=pentiumii]) ;;
875                esac
876              else
877                AX_TEST_COMPILER_FLAGS([-march=$ax_x86_arch],
878                  [],
879                  [
880                    if test x"$ax_x86_arch_fallback" != x""; then
881                      AX_TEST_COMPILER_FLAGS([-march=$ax_x86_arch_fallback], [ax_x86_arch=$ax_x86_arch_fallback], [ax_x86_arch=])
882                    fi
883                  ]
884                )
885                if test x"$pov_compiler_vendor" = x"gnu"; then
886                  for sse_flag in $ax_x86_cpuflags_SSE_list
887                  do
888                    sse_flag=`echo $sse_flag | tr A-Z a-z`
889                    AX_TEST_COMPILER_FLAGS([-m$sse_flag])
890                  done
891                  case "$ax_x86_cpuflags_SSE_list" in
892                    *SSE2*|*SSE3*|*SSSE3*|*SSE4*)  AX_TEST_COMPILER_FLAGS([-mfpmath=sse]);;  # -march or -msse required
893                  esac
894                fi
895              fi
896            else
897              ax_x86_arch=
898            fi
899            if test x"$ax_x86_arch" != x""; then
900              pov_built_for="$pov_built_for | $ax_x86_cpumodel_nofreq"
901            fi
902          ])])
903        ;;
904
905      *irix*)
906        AX_TEST_COMPILER_FLAGS([-mips4],
907          [pov_built_for="$pov_built_for | MIPS 4"],
908          [AX_TEST_COMPILER_FLAGS([-mips2], [pov_built_for="$pov_built_for | MIPS 2"])]
909        )
910        ;;
911
912      powerpc*)
913        ### Suggested by Thorsten Froehlich <thorsten@trf.de> :
914        # Note that the different parameters for mcpu and mtune are intentional:
915        # The PPC 7450 processor has a much longer pipeline and thus scheduling
916        # for that pipeline always yields good results even on processors with
917        # a shorter pipeline.  On the other hand, most PowerPC processors only
918        # support the instructions also found in the PPC 750 processor (aka G3).
919        # That is why it is selected in the mcpu parameter.  Using 7450 (aka G4+)
920        # in mcpu would make the code incompatible with anything prior to the
921        # PPC 7400 (aka G4).  To be precise, the vector instructions are new
922        # in the four digit model number PowerPC processors (aka G4), but gcc
923        # cannot (as of February 2003) use them automatically anyway! [trf]
924        #
925        # 2007-01-24 after gentoo patch for powerpc64 (http://bugs.gentoo.org/show_bug.cgi?id=118156)
926        if "$build" != powerpc64* ; then
927          for pov_flags in "-mpowerpc" "-mcpu=750 -mtune=7450"
928          do
929            AX_TEST_COMPILER_FLAGS([$pov_flags])
930          done
931          case "$CXXFLAGS" in
932            *-mcpu=750*)  pov_built_for="$pov_built_for | PowerPC G3/G4" ;;
933            *)            pov_built_for="$pov_built_for | PowerPC" ;;
934          esac
935        else
936          pov_built_for="$pov_built_for | PowerPC G5"
937        fi
938        for pov_flags in "-mmultiple" "-mstring" "-mfused-madd"
939        do
940          AX_TEST_COMPILER_FLAGS([$pov_flags])
941        done
942        ;;
943
944      sparc-*)
945        # Commented out for now.
946        #AX_TEST_COMPILER_FLAGS([-march=ultrasparc])
947        #AX_TEST_COMPILER_FLAGS([-mvis])
948        ;;
949
950    esac
951
952    AC_MSG_CHECKING([which architecture to optimize for])
953    AC_MSG_RESULT([$pov_built_for])
954  else
955    AC_MSG_RESULT([no])  # no arch-specific optimizations
956  fi
957
958else
959  AC_MSG_RESULT([no])  # no optimizations
960fi
961
962AC_DEFINE_UNQUOTED([BUILT_FOR], ["$pov_built_for"], [Host platform.])
963
964case "$pov_built_for" in
965  i?86-* | x86_64-*)
966    pov_cpu='x86'
967    AC_DEFINE([BUILD_X86], [], [Build for x86 or x86-64 architecture])
968    AX_CHECK_COMPILE_FLAG([-mavx],  [pov_avx='-mavx'],   [pov_avx=''])
969    AX_CHECK_COMPILE_FLAG([-mavx2], [pov_avx2='-mavx2'], [pov_avx2=''])
970    AX_CHECK_COMPILE_FLAG([-mfma],  [pov_fma3='-mfma'],  [pov_fma3=''])
971    AX_CHECK_COMPILE_FLAG([-mfma4], [pov_fma4='-mfma4'], [pov_fma4=''])
972    ;;
973  *)
974    pov_cpu=''
975    ;;
976esac
977AM_CONDITIONAL([BUILD_x86], [test x"$pov_cpu" = x"x86"])
978AM_CONDITIONAL([BUILD_x86avx], [test x"$pov_avx" != x""])
979AM_CONDITIONAL([BUILD_x86avxfma4], [test x"$pov_avx" != x"" -a x"$pov_fma4" != x"" ])
980AM_CONDITIONAL([BUILD_x86avx2fma3], [test x"$pov_avx2" != x"" -a x"$pov_fma3" != x"" ])
981
982
983# Add flags specified at the command line.
984CXXFLAGS=`echo $CXXFLAGS $pov_save_cxxflags`
985AC_DEFINE_UNQUOTED([CXXFLAGS], ["$CXXFLAGS"], [Compiler flags.])
986
987
988###############################################################################
989
990# NOTE: It is highly important that this block of tests is run AFTER compiler optimization settings have been chosen.
991
992AC_MSG_RESULT([
993Floating Point Features
994-----------------------])
995
996AC_CHECK_HEADERS([limits])
997
998AC_MSG_CHECKING([whether NaNs are supported])
999AC_RUN_IFELSE([
1000  AC_LANG_PROGRAM([[
1001    #ifdef HAVE_LIMITS
1002    #include <limits>
1003    #endif
1004  ]],[[
1005    if (!std::numeric_limits<double>::has_quiet_NaN) return 1;
1006    if (!std::numeric_limits<float>::has_quiet_NaN)  return 2;
1007  ]])
1008],[
1009  AC_MSG_RESULT([yes])
1010
1011  AC_CHECK_HEADERS([cmath])
1012
1013  AC_MSG_CHECKING([whether NaNs can be identified using std::isnan()])
1014  AC_RUN_IFELSE([
1015    AC_LANG_PROGRAM([[
1016      #ifdef HAVE_CMATH
1017      #include <cmath>
1018      #endif
1019      #ifdef HAVE_LIMITS
1020      #include <limits>
1021      #endif
1022    ]],[[
1023      volatile double d;
1024      volatile float f;
1025      d = std::numeric_limits<double>::quiet_NaN(); if (!std::isnan(d)) return 1;
1026      f = d;                                        if (!std::isnan(f)) return 2;
1027      f = std::numeric_limits<float>::quiet_NaN();  if (!std::isnan(f)) return 3;
1028      d = f;                                        if (!std::isnan(d)) return 4;
1029      d = 0.0; if (std::isnan(d)) return 5;
1030      f = 0.0; if (std::isnan(f)) return 6;
1031    ]])
1032  ],[
1033    AC_MSG_RESULT([yes])
1034    AC_DEFINE([HAVE_NAN],      [],[NaN floating point values are supported])
1035    AC_DEFINE([HAVE_STD_ISNAN],[],[NaNs can be identified using std::isnan()])
1036  ],[
1037    AC_MSG_RESULT([no])
1038
1039    AC_MSG_CHECKING([whether NaNs can be identified using global isnan()])
1040    AC_RUN_IFELSE([
1041      AC_LANG_PROGRAM([[
1042        #ifdef HAVE_CMATH
1043        #include <cmath>
1044        #endif
1045        #ifdef HAVE_LIMITS
1046        #include <limits>
1047        #endif
1048      ]],[[
1049        volatile double d;
1050        volatile float f;
1051        d = std::numeric_limits<double>::quiet_NaN(); if (!isnan(d)) return 1;
1052        f = d;                                        if (!isnan(f)) return 2;
1053        f = std::numeric_limits<float>::quiet_NaN();  if (!isnan(f)) return 3;
1054        d = f;                                        if (!isnan(d)) return 4;
1055        d = 0.0; if (isnan(d)) return 5;
1056        f = 0.0; if (isnan(f)) return 6;
1057      ]])
1058    ],[
1059      AC_MSG_RESULT([yes])
1060      AC_DEFINE([HAVE_NAN],  [],[NaN floating point values are supported])
1061      AC_DEFINE([HAVE_ISNAN],[],[NaNs can be identified using global isnan()])
1062    ],[
1063      AC_MSG_RESULT([no])
1064
1065      AC_MSG_CHECKING([whether NaNs can be identified by comparison to themselves])
1066      AC_RUN_IFELSE([
1067        AC_LANG_PROGRAM([[
1068          #ifdef HAVE_LIMITS
1069          #include <limits>
1070          #endif
1071          template<typename T> inline bool emulated_isnan(T x) { volatile T v = x; return (v != x); }
1072        ]],[[
1073          volatile double d;
1074          volatile float f;
1075          d = std::numeric_limits<double>::quiet_NaN(); if (!emulated_isnan(d)) return 1;
1076          f = d;                                        if (!emulated_isnan(f)) return 2;
1077          f = std::numeric_limits<float>::quiet_NaN();  if (!emulated_isnan(f)) return 3;
1078          d = f;                                        if (!emulated_isnan(d)) return 4;
1079          d = 0.0; if (emulated_isnan(d)) return 5;
1080          f = 0.0; if (emulated_isnan(f)) return 6;
1081        ]])
1082      ],[
1083        AC_MSG_RESULT([yes])
1084        AC_DEFINE([HAVE_NAN],           [],[NaN floating point values are supported])
1085        AC_DEFINE([HAVE_EMULATED_ISNAN],[],[NaNs can be identified by comparison to themselves])
1086      ],[
1087        # although double and float support NaN values, they are no use to us as we can't properly test for them,
1088        # so we're not setting HAVE_NAN.
1089        AC_MSG_RESULT([no])
1090      ],[
1091        AC_MSG_RESULT([cross-compiling])  # FIXME
1092      ])
1093    ],[
1094      AC_MSG_RESULT([cross-compiling])  # FIXME
1095    ])
1096  ],[
1097    AC_MSG_RESULT([cross-compiling])  # FIXME
1098  ])
1099],[
1100  AC_MSG_RESULT([no])
1101],[
1102  AC_MSG_RESULT([cross-compiling])  # FIXME
1103])
1104
1105AC_MSG_CHECKING([whether infinite values are supported])
1106AC_RUN_IFELSE([
1107  AC_LANG_PROGRAM([[
1108    #ifdef HAVE_LIMITS
1109    #include <limits>
1110    #endif
1111  ]],[[
1112    if (!std::numeric_limits<double>::has_infinity) return 1;
1113    if (!std::numeric_limits<float>::has_infinity)  return 2;
1114  ]])
1115],[
1116  AC_MSG_RESULT([yes])
1117
1118  AC_CHECK_HEADERS([cmath])
1119
1120  AC_MSG_CHECKING([whether infinities can be identified using std::isinf()])
1121  AC_RUN_IFELSE([
1122    AC_LANG_PROGRAM([[
1123      #ifdef HAVE_CMATH
1124      #include <cmath>
1125      #endif
1126      #ifdef HAVE_LIMITS
1127      #include <limits>
1128      #endif
1129    ]],[[
1130      volatile double d;
1131      volatile float f;
1132      d = std::numeric_limits<double>::infinity();  if (!std::isinf(d)) return 1;
1133      f = d;                                        if (!std::isinf(f)) return 2;
1134      f = std::numeric_limits<float>::infinity();   if (!std::isinf(f)) return 3;
1135      d = f;                                        if (!std::isinf(d)) return 4;
1136      d = -std::numeric_limits<double>::infinity(); if (!std::isinf(d)) return 5;
1137      f = d;                                        if (!std::isinf(f)) return 6;
1138      f = -std::numeric_limits<float>::infinity();  if (!std::isinf(f)) return 7;
1139      d = f;                                        if (!std::isinf(d)) return 8;
1140      d = 0.0; if (std::isinf(d)) return 9;
1141      f = 0.0; if (std::isinf(f)) return 10;
1142    ]])
1143  ],[
1144    AC_MSG_RESULT([yes])
1145    AC_DEFINE([HAVE_INF],      [],[infinite floating point values are supported])
1146    AC_DEFINE([HAVE_STD_ISINF],[],[intinities can be identified using std::isinf()])
1147  ],[
1148    AC_MSG_RESULT([no])
1149
1150    AC_MSG_CHECKING([whether infinities can be identified using global isinf()])
1151    AC_RUN_IFELSE([
1152      AC_LANG_PROGRAM([[
1153        #ifdef HAVE_CMATH
1154        #include <cmath>
1155        #endif
1156        #ifdef HAVE_LIMITS
1157        #include <limits>
1158        #endif
1159      ]],[[
1160        volatile double d;
1161        volatile float f;
1162        d = std::numeric_limits<double>::infinity();  if (!isinf(d)) return 1;
1163        f = d;                                        if (!isinf(f)) return 2;
1164        f = std::numeric_limits<float>::infinity();   if (!isinf(f)) return 3;
1165        d = f;                                        if (!isinf(d)) return 4;
1166        d = -std::numeric_limits<double>::infinity(); if (!isinf(d)) return 5;
1167        f = d;                                        if (!isinf(f)) return 6;
1168        f = -std::numeric_limits<float>::infinity();  if (!isinf(f)) return 7;
1169        d = f;                                        if (!isinf(d)) return 8;
1170        d = 0.0; if (isinf(d)) return 9;
1171        f = 0.0; if (isinf(f)) return 10;
1172      ]])
1173    ],[
1174      AC_MSG_RESULT([yes])
1175      AC_DEFINE([HAVE_INF],  [],[infinite floating point values are supported])
1176      AC_DEFINE([HAVE_ISINF],[],[intinities can be identified using global isinf()])
1177    ],[
1178      AC_MSG_RESULT([no])
1179
1180      AC_MSG_CHECKING([whether infinities can be identified by comparison to the maximum value])
1181      AC_RUN_IFELSE([
1182        AC_LANG_PROGRAM([[
1183          #ifdef HAVE_CMATH
1184          #include <cmath>
1185          #endif
1186          #ifdef HAVE_LIMITS
1187          #include <limits>
1188          #endif
1189          template<typename T> inline bool emulated_isinf(T x) { volatile T v = std::numeric_limits<T>::max(); return std::fabs(x) > v; }
1190        ]],[[
1191          volatile double d;
1192          volatile float f;
1193          d = std::numeric_limits<double>::infinity();  if (!emulated_isinf(d)) return 1;
1194          f = d;                                        if (!emulated_isinf(f)) return 2;
1195          f = std::numeric_limits<float>::infinity();   if (!emulated_isinf(f)) return 3;
1196          d = f;                                        if (!emulated_isinf(d)) return 4;
1197          d = -std::numeric_limits<double>::infinity(); if (!emulated_isinf(d)) return 5;
1198          f = d;                                        if (!emulated_isinf(f)) return 6;
1199          f = -std::numeric_limits<float>::infinity();  if (!emulated_isinf(f)) return 7;
1200          d = f;                                        if (!emulated_isinf(d)) return 8;
1201          d = 0.0; if (emulated_isinf(d)) return 9;
1202          f = 0.0; if (emulated_isinf(f)) return 10;
1203        ]])
1204      ],[
1205        AC_MSG_RESULT([yes])
1206        AC_DEFINE([HAVE_INF],           [],[infinite floating point values are supported])
1207        AC_DEFINE([HAVE_EMULATED_ISINF],[],[infinities can be identified by comparison to the maximum value])
1208      ],[
1209        # although double and float support infinite values, they are no use to us as we can't properly test for them,
1210        # so we're not setting HAVE_INF.
1211        AC_MSG_RESULT([no])
1212      ],[
1213        AC_MSG_RESULT([cross-compiling])  # FIXME
1214      ])
1215    ],[
1216      AC_MSG_RESULT([cross-compiling])  # FIXME
1217    ])
1218  ],[
1219    AC_MSG_RESULT([cross-compiling])  # FIXME
1220  ])
1221],[
1222  AC_MSG_RESULT([no])
1223],[
1224  AC_MSG_RESULT([cross-compiling])  # FIXME
1225])
1226
1227
1228###############################################################################
1229
1230AC_MSG_RESULT([
1231Makefiles
1232---------])
1233
1234AC_CONFIG_FILES([\
1235  Makefile \
1236  source/Makefile \
1237  vfe/Makefile \
1238  platform/Makefile \
1239  unix/Makefile \
1240])
1241
1242
1243###############################################################################
1244
1245if test x"$enable_io_restrictions" = x"no"; then
1246  pov_io_msg="disabled"
1247else
1248  pov_io_msg="enabled"
1249fi
1250
1251# image format support
1252pov_img_fmt_builtin="gif tga iff ppm pgm hdr"
1253
1254for format in png jpeg tiff openexr
1255do
1256  eval fmt=\$pov_lib$format
1257  if test x"$fmt" != x""; then
1258    pov_img_fmt_enabled="$pov_img_fmt_enabled $format"
1259  else
1260    pov_img_fmt_disabled="$pov_img_fmt_disabled $format"
1261  fi
1262done
1263pov_img_fmt_enabled=`echo $pov_img_fmt_enabled`
1264pov_img_fmt_disabled=`echo $pov_img_fmt_disabled`
1265test x"$pov_img_fmt_disabled" = x"" && pov_img_fmt_disabled="-"
1266
1267
1268AC_DEFINE_UNQUOTED([BUILTIN_IO_RESTRICTIONS], ["$pov_io_msg"], [I/O restrictions.])
1269AC_DEFINE_UNQUOTED([BUILTIN_XWIN_DISPLAY], ["$pov_xwin_msg"], [X Window display.])
1270AC_DEFINE_UNQUOTED([BUILTIN_IMG_FORMATS], ["$pov_img_fmt_builtin $pov_img_fmt_enabled"], [Supported image formats.])
1271AC_DEFINE_UNQUOTED([MISSING_IMG_FORMATS], ["$pov_img_fmt_disabled"], [Unsupported image formats.])
1272
1273povowner=`stat ${stat_format}%u ${HOME}`
1274povgroup=`stat ${stat_format}%g ${HOME}`
1275AC_SUBST([povowner])
1276AC_SUBST([povgroup])
1277
1278AC_OUTPUT
1279
1280
1281###############################################################################
1282
1283# recursively expand the following variables for displaying
1284for i in bindir sysconfdir datadir mandir
1285do
1286  eval povtemp=\$$i
1287  while test x"$povtemp" != x"$oldpovtemp"
1288  do
1289    oldpovtemp=$povtemp
1290    eval povtemp=$povtemp
1291  done
1292  eval pov$i=$povtemp
1293done
1294
1295AC_MSG_RESULT([
1296===============================================================================
1297$PACKAGE_NAME $PACKAGE_VERSION has been configured.
1298])
1299
1300if test x"$pov_no_distrib" = x"yes"; then
1301  AC_MSG_WARN([the resulting binary is NOT REDISTRIBUTABLE.
1302])
1303fi
1304
1305if test x"$pov_warn_path" != x""; then
1306  AC_MSG_WARN(
1307[configure has detected that the list of search paths
1308specified by the following environment variable(s)
1309 $pov_warn_path
1310erroneously contain the "." directory, which may cause a build failure.
1311In order to build POV-Ray successfully, the package has been configured
1312with all "." directory entries removed from the variables above.  You're
1313strongly advised to correct your configuration accordingly.
1314])
1315fi
1316
1317AC_MSG_RESULT([Built-in features:
1318  I/O restrictions:          ${pov_io_msg}
1319  X Window display:          ${pov_xwin_msg}
1320  Supported image formats:   $pov_img_fmt_builtin $pov_img_fmt_enabled
1321  Unsupported image formats: $pov_img_fmt_disabled
1322
1323Compilation settings:
1324  Build architecture:  $build
1325  Built/Optimized for: $pov_built_for
1326  Compiler vendor:     $pov_compiler_vendor
1327  Compiler version:    $pov_compiler_version
1328  Compiler flags:      $CXXFLAGS
1329  Libraries:           $LIBS
1330
1331Type 'make check' to build the program and run a test render.
1332Type 'make install' to install $PACKAGE_NAME on your system.
1333
1334The $PACKAGE_NAME components will be installed in the following directories:
1335  Program (executable):       ${povbindir}
1336  System configuration files: ${povsysconfdir}/$PACKAGE/$VERSION_BASE
1337  User configuration files:   ${HOME}/.$PACKAGE/$VERSION_BASE
1338  Standard include files:     ${povdatadir}/$PACKAGE-$VERSION_BASE/include
1339  Standard INI files:         ${povdatadir}/$PACKAGE-$VERSION_BASE/ini
1340  Standard demo scene files:  ${povdatadir}/$PACKAGE-$VERSION_BASE/scenes
1341  Documentation (text, HTML): ${povdatadir}/doc/$PACKAGE-$VERSION_BASE
1342  Unix man page:              ${povmandir}
1343===============================================================================
1344])
1345