Changed launcher to not have S3D_SERVER #defined to allow visible dialog messages
[scorched3d.git] / configure-fftw.m4
blob0ce31641e1887e28e77d8f705e346eb67ea2e981
1 dnl Check for FFTW3
3 FFTW_CFLAGS=
4 FFTW_LIBS=
6 AC_ARG_WITH(fftw,[  --with-fftw=PFX   Prefix where fftw is installed (optional)], fftw_prefix="$withval", fftw_prefix="")
7 AC_ARG_WITH(fftw-libraries,[  --with-fftw-libraries=DIR   Directory where fftw library is installed (optional)], fftw_libraries="$withval", fftw_libraries="")
8 AC_ARG_WITH(fftw-includes,[  --with-fftw-includes=DIR   Directory where fftw header files are installed (optional)], fftw_includes="$withval", fftw_includes="")
9 AC_ARG_ENABLE(fftwtest, [  --disable-fftwtest       Do not try to compile and run a test fftw program],, enable_fftwtest=yes)
11   if test "x$fftw_libraries" != "x" ; then
12     FFTW_LIBS="-L$fftw_libraries"
13   elif test "x$fftw_prefix" != "x" ; then
14     FFTW_LIBS="-L$fftw_prefix/lib"
15   elif test "x$prefix" != "xNONE"; then
16     FFTW_LIBS="-L$prefix/lib"
17   fi
19 if test `uname` == Darwin; then
20   FFTW_LIBS="$FFTW_LIBS -framework FFTW3"
21 else        
22   FFTW_LIBS="$FFTW_LIBS -lfftw3f"
25   if test "x$fftw_includes" != "x" ; then
26     FFTW_CFLAGS="-I$fftw_includes"
27   elif test "x$fftw_prefix" != "x" ; then
28     FFTW_CFLAGS="-I$fftw_prefix/include"
29   elif test "x$prefix" != "xNONE"; then
30     FFTW_CFLAGS="-I$prefix/include -I/usr/include"
31   fi
33   AC_MSG_CHECKING(for FFTW)
34   no_fftw=""
36   if test "x$enable_fftwtest" = "xyes" ; then
37     ac_save_CFLAGS="$CFLAGS"
38     ac_save_LIBS="$LIBS"
39     CFLAGS="$CFLAGS $FFTW_CFLAGS"
40     LIBS="$LIBS $FFTW_LIBS"
41 dnl
42 dnl Now check if the installed fftw is sufficiently new.
43 dnl
44       rm -f conf.fftwtest
45       AC_TRY_RUN([
46 #include <stdio.h>
47 #include <stdlib.h>
48 #include <string.h>
49 #ifdef __DARWIN__
50 #include <fftw3/fftw3.h>
51 #else
52 #include <fftw3.h>
53 #endif
55 #ifdef FFTW_USE_DOUBLE
56 #define FFT_COMPLEX_TYPE fftw_complex
57 #define FFT_REAL_TYPE double
58 #define FFT_PLAN_TYPE fftw_plan
59 #define FFT_CREATE_PLAN fftw_plan_dft_c2r_2d
60 #define FFT_DELETE_PLAN fftw_destroy_plan
61 #define FFT_EXECUTE_PLAN fftw_execute
62 #else
63 #define FFT_COMPLEX_TYPE fftwf_complex
64 #define FFT_REAL_TYPE float
65 #define FFT_PLAN_TYPE fftwf_plan
66 #define FFT_CREATE_PLAN fftwf_plan_dft_c2r_2d
67 #define FFT_DELETE_PLAN fftwf_destroy_plan
68 #define FFT_EXECUTE_PLAN fftwf_execute
69 #endif
71 #define N 10
73 int main ()
75         FFT_COMPLEX_TYPE fft_in[N*(N/2+1)];
76         FFT_REAL_TYPE fft_out[N*N];
77         FFT_PLAN_TYPE plan;
79         plan = FFT_CREATE_PLAN(N, N, fft_in, fft_out, 0);
82     system("touch conf.fftwtest");
83     return 0;
86 ],, no_fftw=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
87        CFLAGS="$ac_save_CFLAGS"
88        LIBS="$ac_save_LIBS"
89   fi
91   if test "x$no_fftw" = "x" ; then
92      AC_MSG_RESULT(yes)  
93   else
94      AC_MSG_RESULT(no)
95      if test -f conf.fftwtest ; then
96        :
97      else
98        echo "*** Could not run FFTW test program, checking why..."
99        CFLAGS="$CFLAGS $FFTW_CFLAGS"
100        LIBS="$LIBS $FFTW_LIBS"
101        AC_TRY_LINK([
102 #include <stdio.h>
103 #ifdef __DARWIN__
104 #include <fftw3/fftw3.h>
105 #else
106 #include <fftw3.h>
107 #endif
108 ],     [ return 0; ],
109        [ echo "*** The test program compiled, but did not run. This usually means"
110        echo "*** that the run-time linker is not finding FFTW or finding the wrong"
111        echo "*** version of FFTW. If it is not finding FFTW, you'll need to set your"
112        echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
113        echo "*** to the installed location  Also, make sure you have run ldconfig if that"
114        echo "*** is required on your system"
115        echo "***"
116        echo "*** If you have an old version installed, it is best to remove it, although"
117        echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
118        [ echo "*** The test program failed to compile or link. See the file config.log for the"
119        echo "*** exact error that occured. This usually means FFTW was incorrectly installed"
120        echo "*** or that you have moved FFTW since it was installed." ])
121        CFLAGS="$ac_save_CFLAGS"
122        LIBS="$ac_save_LIBS"
123      fi
124      FFTW_CFLAGS=""
125      FFTW_LIBS=""
126      
127             AC_MSG_ERROR([
128                 FFTW must be installed on your system but couldn't be found.
129                 Please check that FFTW is installed.
130                 FFTW version 3 is required.
131         ])
134   fi
135   rm -f conf.fftwtest
138 AC_SUBST(FFTW_CFLAGS)
139 AC_SUBST(FFTW_LIBS)