From 7306cea52f69df550a21b3256803064da9544e39 Mon Sep 17 00:00:00 2001 From: Matthias Kramm Date: Tue, 1 Dec 2009 17:06:16 -0800 Subject: [PATCH] added configure check for fftw3 --- config.h.in | 4 + configure | 271 +++++++++++++++++++++++++++++++++++++++++++++++++++++ configure.in | 2 + lib/devices/swf.c | 5 - lib/graphcut.h | 6 +- m4/fftw.m4 | 52 ++++++++++ 6 files changed, 334 insertions(+), 6 deletions(-) create mode 100644 m4/fftw.m4 diff --git a/config.h.in b/config.h.in index c486e83..3b4d045 100644 --- a/config.h.in +++ b/config.h.in @@ -203,6 +203,10 @@ #undef HAVE_FONTCONFIG_H #undef HAVE_FONTCONFIG +#undef HAVE_FFTW3_H + +#undef HAVE_FFTW3 + /* have/use internal l.a.m.e. mp3 library */ #undef HAVE_LAME diff --git a/configure b/configure index 3f72af7..c888a9b 100755 --- a/configure +++ b/configure @@ -8967,6 +8967,277 @@ if test "x${HAVE_FONTCONFIG}" "!=" "x1"; then fi + + OLDCPPFLAGS="${CPPFLAGS}" + OLDLIBS="${LIBS}" + + { $as_echo "$as_me:$LINENO: checking for fftw_plan_dft_r2c_2d in -lfftw3" >&5 +$as_echo_n "checking for fftw_plan_dft_r2c_2d in -lfftw3... " >&6; } +if test "${ac_cv_lib_fftw3_fftw_plan_dft_r2c_2d+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lfftw3 $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char fftw_plan_dft_r2c_2d (); +int +main () +{ +return fftw_plan_dft_r2c_2d (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + ac_cv_lib_fftw3_fftw_plan_dft_r2c_2d=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_fftw3_fftw_plan_dft_r2c_2d=no +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_fftw3_fftw_plan_dft_r2c_2d" >&5 +$as_echo "$ac_cv_lib_fftw3_fftw_plan_dft_r2c_2d" >&6; } +if test "x$ac_cv_lib_fftw3_fftw_plan_dft_r2c_2d" = x""yes; then + HAVE_LIBFFTW3=1 +fi + + +for ac_header in fftw3.h +do +as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 +$as_echo_n "checking $ac_header usability... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 +$as_echo_n "checking $ac_header presence... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + +fi +as_val=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + HAVE_FFTW3_H=1 +fi + +done + + + if test "x${HAVE_LIBFFTW3}" != "x";then + if test "x${HAVE_FFTW3_H}" != "x";then + HAVE_FFTW3=1 + fi + fi + + if test "x${HAVE_FFTW3}" = "x1"; then + LIBS="$LIBS -lfftw3" + { $as_echo "$as_me:$LINENO: checking whether we can compile the fftw3 test program" >&5 +$as_echo_n "checking whether we can compile the fftw3 test program... " >&6; } + + cat > conftest.c << EOF + #include + + int main() + { + char*data = 0; + fftw_plan plan = fftw_plan_dft_2d(600, 800, (fftw_complex*)data, (fftw_complex*)data, FFTW_FORWARD, FFTW_ESTIMATE); + plan = fftw_plan_dft_r2c_2d(600, 800, (double*)data, (fftw_complex*)data, FFTW_ESTIMATE); + plan = fftw_plan_dft_c2r_2d(600, 800, (fftw_complex*)data, (double*)data, FFTW_ESTIMATE); + fftw_execute(plan); + fftw_destroy_plan(plan); + } +EOF + + ac_link='$CC $CPPFLAGS $CFLAGS conftest.c $LDFLAGS $LIBS -o conftest${ac_exeext}' + if { (eval echo fftw3.m4:71: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } + +cat >>confdefs.h <<\_ACEOF +#define HAVE_FFTW3 1 +_ACEOF + + else + echo "configure: failed program was:" >&5 + cat conftest.c >&5 + HAVE_FFTW3=0 + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } + fi + rm -f conftest* + fi + + # if the above didn't work out, reset all changes to the compiler variables. + if test "x${HAVE_FFTW3}" "!=" "x1"; then + CPPFLAGS=$OLDCPPFLAGS + LIBS=$OLDLIBS + fi + + # RFX_CHECK_OPENGL # if test "$HAVE_OPENGL";then # DEVICE_OPENGL='devices/opengl.$(O)' diff --git a/configure.in b/configure.in index 11e6629..d32235f 100644 --- a/configure.in +++ b/configure.in @@ -273,6 +273,8 @@ RFX_CHECK_FREETYPE RFX_CHECK_FONTCONFIG +RFX_CHECK_FFTW + # RFX_CHECK_OPENGL # if test "$HAVE_OPENGL";then # DEVICE_OPENGL='devices/opengl.$(O)' diff --git a/lib/devices/swf.c b/lib/devices/swf.c index 182aa55..ad21d78 100644 --- a/lib/devices/swf.c +++ b/lib/devices/swf.c @@ -2970,11 +2970,6 @@ static void swf_addfont(gfxdevice_t*dev, gfxfont_t*font) l->swffont->layout->bounds[iii].xmax/20.0, l->swffont->layout->bounds[iii].ymax/20.0 ); - int t; - for(t=0;tswffont->maxascii;t++) { - if(l->swffont->ascii2glyph[t] == iii) - msg(" | - maps to %d",t); - } } } } diff --git a/lib/graphcut.h b/lib/graphcut.h index 39b96c0..9b15a44 100644 --- a/lib/graphcut.h +++ b/lib/graphcut.h @@ -38,7 +38,11 @@ struct _halfedge { struct _node { halfedge_t*edges; - int tmp; + union { + int tmp; + int component; + int color; + }; int nr; }; diff --git a/m4/fftw.m4 b/m4/fftw.m4 new file mode 100644 index 0000000..e26434b --- /dev/null +++ b/m4/fftw.m4 @@ -0,0 +1,52 @@ +AC_DEFUN([RFX_CHECK_FFTW], +[ + OLDCPPFLAGS="${CPPFLAGS}" + OLDLIBS="${LIBS}" + + AC_CHECK_LIB(fftw3, fftw_plan_dft_r2c_2d, [HAVE_LIBFFTW3=1],) + AC_CHECK_HEADERS(fftw3.h,[HAVE_FFTW3_H=1]) + + if test "x${HAVE_LIBFFTW3}" != "x";then + if test "x${HAVE_FFTW3_H}" != "x";then + HAVE_FFTW3=1 + fi + fi + + if test "x${HAVE_FFTW3}" = "x1"; then + LIBS="$LIBS -lfftw3" + AC_MSG_CHECKING([whether we can compile the fftw3 test program]) + + cat > conftest.c << EOF + #include + + int main() + { + char*data = 0; + fftw_plan plan = fftw_plan_dft_2d(600, 800, (fftw_complex*)data, (fftw_complex*)data, FFTW_FORWARD, FFTW_ESTIMATE); + plan = fftw_plan_dft_r2c_2d(600, 800, (double*)data, (fftw_complex*)data, FFTW_ESTIMATE); + plan = fftw_plan_dft_c2r_2d(600, 800, (fftw_complex*)data, (double*)data, FFTW_ESTIMATE); + fftw_execute(plan); + fftw_destroy_plan(plan); + } +EOF + + ac_link='$CC $CPPFLAGS $CFLAGS conftest.c $LDFLAGS $LIBS -o conftest${ac_exeext}' + if { (eval echo fftw3.m4:71: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + AC_MSG_RESULT(yes) + AC_DEFINE([HAVE_FFTW3], [1], [Define if fftw3 is available]) + else + echo "configure: failed program was:" >&5 + cat conftest.c >&5 + HAVE_FFTW3=0 + AC_MSG_RESULT(no) + fi + rm -f conftest* + fi + + # if the above didn't work out, reset all changes to the compiler variables. + if test "x${HAVE_FFTW3}" "!=" "x1"; then + CPPFLAGS=$OLDCPPFLAGS + LIBS=$OLDLIBS + fi +]) + -- 1.7.10.4