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