diff --git a/configure b/configure index aadfee85..c2e1cc36 100755 --- a/configure +++ b/configure @@ -645,7 +645,6 @@ have_png have_libuvc have_lapack have_toon -have_shared_ptr have_videodisplay XMKMF have_qtbuffer @@ -4469,7 +4468,6 @@ minor=$cvd_minor - ################################################################################ # #Lists of optional components @@ -6796,80 +6794,6 @@ fi - if test "$with_shared_ptr" != no && test "$have_shared_ptr" != yes - then - if test "$with_shared_ptr" == "" - then - with_shared_ptr=yes - fi - - save_LIBS="$LIBS" - save_CXXFLAGS="$CXXFLAGS" - a= - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared_ptr" >&5 -$as_echo_n "checking for shared_ptr... " >&6; } - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - int main(){std::shared_ptr i; return 0;} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; }; a=1 -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - - if test x$a == x1 - then - a=0 - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tr1::shared_ptr" >&5 -$as_echo_n "checking for tr1::shared_ptr... " >&6; } - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - int main(){std::tr1::shared_ptr i; return 0;} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; }; a=1 -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - $as_echo "#define CVD_INTERNAL_NEED_TR1 1" >>confdefs.h - - dodginess_options="$dodginess_options tr1_shared_ptr" - fi - - - if test x$a == x - then - $as_echo "#define CVD_HAVE_SHARED_PTR 1" >>confdefs.h - - have_shared_ptr=yes - - options="$options shared_ptr" - - else - LIBS="$save_LIBS" - CXXFLAGS="$save_CXXFLAGS" - fi - fi - - if test "$have_shared_ptr" != yes - then - : - - fi - - - - if test "$with_toon" != no && test "$have_toon" != yes then if test "$with_toon" == "" @@ -6897,32 +6821,6 @@ $as_echo "no" >&6; }; a=1 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - if test x$a = x1 - then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for old TooN" >&5 -$as_echo_n "checking for old TooN... " >&6; } - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - int main(){TooN::Vector<2> v;return 0;} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; }; a=2 -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - - if test x$a = x1 - then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Your version of TooN is too old. You need version 2.0-beta3 or later." >&5 -$as_echo "$as_me: WARNING: Your version of TooN is too old. You need version 2.0-beta3 or later." >&2;} - fi - a=1 - fi - if test x$a == x then @@ -7690,60 +7588,6 @@ else a=1 fi - oldpng=0 - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for png_set_expand_gray_1_2_4_to_8 in -lpng" >&5 -$as_echo_n "checking for png_set_expand_gray_1_2_4_to_8 in -lpng... " >&6; } -if ${ac_cv_lib_png_png_set_expand_gray_1_2_4_to_8+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lpng $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* 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 png_set_expand_gray_1_2_4_to_8 (); -int -main () -{ -return png_set_expand_gray_1_2_4_to_8 (); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_lib_png_png_set_expand_gray_1_2_4_to_8=yes -else - ac_cv_lib_png_png_set_expand_gray_1_2_4_to_8=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_png_png_set_expand_gray_1_2_4_to_8" >&5 -$as_echo "$ac_cv_lib_png_png_set_expand_gray_1_2_4_to_8" >&6; } -if test "x$ac_cv_lib_png_png_set_expand_gray_1_2_4_to_8" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBPNG 1 -_ACEOF - - LIBS="-lpng $LIBS" - -else - oldpng=1 -fi - - if test $oldpng == 1 - then - dodginess_options="$dodginess_options oldpng" - $as_echo "#define CVD_INTERNAL_HAVE_OLD_PNG 1" >>confdefs.h - - fi if test x$a == x @@ -8980,6 +8824,9 @@ OFLAGS=$OFLAGS echo $CXXFLAGS echo $LIBS + +ac_config_headers="$ac_config_headers cvd/config.h" + ac_config_files="$ac_config_files Makefile" cat >confcache <<\_ACEOF @@ -9674,6 +9521,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 for ac_config_target in $ac_config_targets do case $ac_config_target in + "cvd/config.h") CONFIG_HEADERS="$CONFIG_HEADERS cvd/config.h" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; diff --git a/configure.ac b/configure.ac index 739f1387..30166749 100644 --- a/configure.ac +++ b/configure.ac @@ -23,7 +23,6 @@ AC_DEFINE_UNQUOTED(CVD_MINOR_VERSION,$cvd_minor) AC_SUBST(minor, $cvd_minor) - ################################################################################ # #Lists of optional components @@ -571,40 +570,10 @@ CHECK_FOR_OPTION(videodisplay,[ ]) -CHECK_FOR_OPTION(shared_ptr, [ - AC_MSG_CHECKING([for shared_ptr]) - AC_COMPILE_IFELSE([AC_LANG_SOURCE([#include - int main(){std::shared_ptr i; return 0;}])], [AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no); a=1]) - - if test x$a == x1 - then - a=0 - AC_MSG_CHECKING([for tr1::shared_ptr]) - AC_COMPILE_IFELSE([AC_LANG_SOURCE([#include - int main(){std::tr1::shared_ptr i; return 0;}])], [AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no); a=1]) - AC_DEFINE(CVD_INTERNAL_NEED_TR1) - APPEND(dodginess_options, tr1_shared_ptr) - fi -]) - - CHECK_FOR_OPTION(toon, [ AC_MSG_CHECKING([for TooN]) AC_COMPILE_IFELSE([AC_LANG_SOURCE([#include int main(){TooN::Vector<2, double> v=TooN::Zeros;return 0;}])], [AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no); a=1]) - - if test x$a = x1 - then - AC_MSG_CHECKING([for old TooN]) - AC_COMPILE_IFELSE([AC_LANG_SOURCE([#include - int main(){TooN::Vector<2> v;return 0;}])], [AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no); a=2]) - - if test x$a = x1 - then - AC_MSG_WARN([Your version of TooN is too old. You need version 2.0-beta3 or later.]) - fi - a=1 - fi ]) CHECK_FOR_OPTION(lapack, [ @@ -675,13 +644,6 @@ CHECK_FOR_OPTION(libuvc, [ CHECK_FOR_OPTION(png, [ AC_CHECK_HEADERS(png.h, [], [a=1]) AC_CHECK_LIB(png, png_init_io, [], [a=1]) - oldpng=0 - AC_CHECK_LIB(png, png_set_expand_gray_1_2_4_to_8, [], [oldpng=1]) - if test $oldpng == 1 - then - APPEND(dodginess_options, oldpng) - AC_DEFINE(CVD_INTERNAL_HAVE_OLD_PNG, 1) - fi ]) CHECK_FOR_OPTION(jpeg, [ @@ -1065,4 +1027,6 @@ AC_SUBST(OFLAGS, $OFLAGS) echo $CXXFLAGS echo $LIBS + +AC_CONFIG_HEADERS(cvd/config.h) AC_OUTPUT(Makefile) diff --git a/cvd/Linux/v4lbuffer.h b/cvd/Linux/v4lbuffer.h index dbf26dab..80c848dc 100644 --- a/cvd/Linux/v4lbuffer.h +++ b/cvd/Linux/v4lbuffer.h @@ -2,8 +2,6 @@ #ifndef CVD_V4LBUFFER_H #define CVD_V4LBUFFER_H -#include - #include #include diff --git a/cvd/config.h.in b/cvd/config.h.in new file mode 100644 index 00000000..c5275f42 --- /dev/null +++ b/cvd/config.h.in @@ -0,0 +1,8 @@ +#ifndef CVD_INCLUDE_CONFIG_H_3216ac8 +#define CVD_INCLUDE_CONFIG_H_3216ac8 + + #undef CVD_HAVE_TOON + #undef CVD_HAVE_JPEG + #undef CVD_HAVE_PNG + #undef CVD_HAVE_TIFF +#endif diff --git a/cvd/cpu_hacks.h b/cvd/cpu_hacks.h deleted file mode 100644 index cefbee6d..00000000 --- a/cvd/cpu_hacks.h +++ /dev/null @@ -1,92 +0,0 @@ -#ifndef CVD_CPU_HACKS_H -#define CVD_CPU_HACKS_H - - -#include - -#if CVD_HAVE_FENV_H - #include -#endif - -#if CVD_HAVE_MMXEXT - #include -#endif - -namespace CVD -{ - - - /// Enable floating point exceptions. This function may - /// do nothing, depending on the architecture - inline void enableFPE(); - - #ifndef DOXYGEN_IGNORE_INTERNAL - #ifdef CVD_HAVE_FENV_H - inline void enableFPE() - { - feclearexcept(FE_ALL_EXCEPT); - feenableexcept(FE_DIVBYZERO|FE_INVALID); - } - #else - /// Enable floating point exceptions. This function may - /// do nothing, depending on the architecture - inline void enableFPE() - { - } - #endif - #endif - - /// Prefetch memory. This function might do nothing, depending on the - /// architecture, or it might prefetch memory. Either way it will have - /// no effect on the computation except to (possibly) speed it up. - /// @param ptr The address of the memory to prefetch. - /// @param I The type of prefetch. This depends on the architecture. - /// - x86, MMXEXT - /// - 0: prefetcht0 - /// - 1: prefetcht1 - /// - 2: prefetcht2 - /// - *: prefetchnta (default) - /// - Everything else - /// - *: nothing - template inline void prefetch(const void* ptr); - - inline void prefetch(const void* ptr); - - - #ifndef DOXYGEN_IGNORE_INTERNAL - #ifdef CVD_HAVE_MMXEXT - template inline void prefetch(const void* ptr) - { - _mm_prefetch((char *)ptr, _MM_HINT_NTA); - } - - template<> inline void prefetch<0>(const void* ptr) - { - _mm_prefetch((char *)ptr, _MM_HINT_T0); - } - - template<> inline void prefetch<1>(const void* ptr) - { - _mm_prefetch((char *)ptr, _MM_HINT_T1); - } - - template<> inline void prefetch<2>(const void* ptr) - { - _mm_prefetch((char *)ptr, _MM_HINT_T2); - } - - inline void prefetch(const void* ptr) - { - prefetch<-1>(ptr); - } - - #else - template inline void prefetch(const void*){} - inline void prefetch(const void*){} - - #endif - #endif -} -#endif - - diff --git a/cvd/image_io.h b/cvd/image_io.h index 9d6f249e..1930e47b 100644 --- a/cvd/image_io.h +++ b/cvd/image_io.h @@ -80,16 +80,22 @@ namespace CVD PNM = 0 , /// JPEG image format. This is a compressed (lossy) image format, but defaults to 95% quality, which has very few compression artefacts. This image type is only present if libjpeg is available. /// RGB and Greyscale JPEGs are supported + #ifdef CVD_HAVE_JPEG JPEG = 1, + #endif /// Windows BMP (or DIB) format. Uncompressed 8 bit grey scale and 24 bit RGB are supported. BMP = 2, /// PNG image format. 1, 8 and 16 bit, Greyscale, RGB and RGBA images are supported. /// This image type is only present if libpng is available. + #ifdef CVD_HAVE_PNG PNG = 3, + #endif /// TIFF image format. 1, 8, 16, 32 (float) and 64 (double) suported. Greyscale, RGB and RGBA supported. /// This image type is only present if libtiff is available. G4 FAX encoding is used for bools, otherwise /// "Deflate" compression is used. + #ifdef CVD_HAVE_TIFF TIFF = 4, + #endif /// Postscript format. This outputs a bare PostScript image with the coordinate system set up /// to that (x,y) corresponds to pixel (x,y), with (0,0) being at the top left of the pixel (0,0). /// The Y axis is therefore inverted compared to normal postscript drawing, but is image aligned. diff --git a/m4/ax_prefix_config_h.m4 b/m4/ax_prefix_config_h.m4 new file mode 100644 index 00000000..22acbac6 --- /dev/null +++ b/m4/ax_prefix_config_h.m4 @@ -0,0 +1,203 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_prefix_config_h.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PREFIX_CONFIG_H [(OUTPUT-HEADER [,PREFIX [,ORIG-HEADER]])] +# +# DESCRIPTION +# +# Generate an installable config.h. +# +# A package should not normally install its config.h as a system header, +# but if it must, this macro can be used to avoid namespace pollution by +# making a copy of config.h with a prefix added to all the macro names. +# +# Each "#define SOMEDEF" line of the configuration header has the given +# prefix added, in the same case as the first character of the macro name. +# +# Defaults: +# +# OUTPUT-HEADER = $PACKAGE-config.h +# PREFIX = $PACKAGE +# ORIG-HEADER, from AM_CONFIG_HEADER(config.h) +# +# Your configure.ac script should contain both macros in this order. +# +# Example: +# +# AC_INIT(config.h.in) # config.h.in as created by "autoheader" +# AM_INIT_AUTOMAKE(testpkg, 0.1.1) # makes #undef VERSION and PACKAGE +# AM_CONFIG_HEADER(config.h) # prep config.h from config.h.in +# AX_PREFIX_CONFIG_H(mylib/_config.h) # prep mylib/_config.h from it.. +# AC_MEMORY_H # makes "#undef NEED_MEMORY_H" +# AC_C_CONST_H # makes "#undef const" +# AC_OUTPUT(Makefile) # creates the "config.h" now +# # and also mylib/_config.h +# +# If the argument to AX_PREFIX_CONFIG_H would have been omitted then the +# default output file would have been called simply "testpkg-config.h", +# but even under the name "mylib/_config.h" it contains prefix-defines +# like +# +# #ifndef TESTPKG_VERSION +# #define TESTPKG_VERSION "0.1.1" +# #endif +# #ifndef TESTPKG_NEED_MEMORY_H +# #define TESTPKG_NEED_MEMORY_H 1 +# #endif +# #ifndef _testpkg_const +# #define _testpkg_const _const +# #endif +# +# and this "mylib/_config.h" can be installed along with other header +# files, which is most convenient when creating a shared library (that has +# some headers) whose functionality depends on features detected at +# compile-time. No need to invent some "mylib-confdefs.h.in" manually. +# +# Note that some AC_DEFINEs that end up in the config.h file are actually +# self-referential - e.g. AC_C_INLINE, AC_C_CONST, and the AC_TYPE_OFF_T +# say that they "will define inline|const|off_t if the system does not do +# it by itself". You might want to clean up about these - consider an +# extra mylib/conf.h that reads something like: +# +# #include +# #ifndef _testpkg_const +# #define _testpkg_const const +# #endif +# +# and then start using _testpkg_const in the header files. That is also a +# good thing to differentiate whether some library-user has starting to +# take up with a different compiler, so perhaps it could read something +# like this: +# +# #ifdef _MSC_VER +# #include +# #else +# #include +# #endif +# #ifndef _testpkg_const +# #define _testpkg_const const +# #endif +# +# LICENSE +# +# Copyright (c) 2014 Reuben Thomas +# Copyright (c) 2008 Guido U. Draheim +# Copyright (c) 2008 Marten Svantesson +# Copyright (c) 2008 Gerald Point +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 16 + +AC_DEFUN([AX_PREFIX_CONFIG_H],[dnl +AC_PREREQ([2.62]) +AC_BEFORE([AC_CONFIG_HEADERS],[$0])dnl +AC_CONFIG_COMMANDS(m4_default([$1], [$PACKAGE-config.h]),[dnl +AS_VAR_PUSHDEF([_OUT],[ac_prefix_conf_OUT])dnl +AS_VAR_PUSHDEF([_DEF],[ac_prefix_conf_DEF])dnl +AS_VAR_PUSHDEF([_PKG],[ac_prefix_conf_PKG])dnl +AS_VAR_PUSHDEF([_LOW],[ac_prefix_conf_LOW])dnl +AS_VAR_PUSHDEF([_UPP],[ac_prefix_conf_UPP])dnl +AS_VAR_PUSHDEF([_INP],[ac_prefix_conf_INP])dnl +m4_pushdef([_script],[conftest.prefix])dnl +m4_pushdef([_symbol],[m4_cr_Letters[]m4_cr_digits[]_])dnl +_OUT=`echo m4_default([$1], [$PACKAGE-config.h])` +_DEF=`echo _$_OUT | sed -e "y:m4_cr_letters:m4_cr_LETTERS[]:" -e "s/@<:@^m4_cr_Letters@:>@/_/g"` +_PKG=`echo m4_default([$2], [$PACKAGE])` +_LOW=`echo _$_PKG | sed -e "y:m4_cr_LETTERS-:m4_cr_letters[]_:"` +_UPP=`echo $_PKG | sed -e "y:m4_cr_letters-:m4_cr_LETTERS[]_:" -e "/^@<:@m4_cr_digits@:>@/s/^/_/"` +_INP=`echo "$3" | sed -e 's/ *//'` +if test ".$_INP" = "."; then + for ac_file in : $CONFIG_HEADERS; do test "_$ac_file" = _: && continue + case "$ac_file" in + *.h) _INP=$ac_file ;; + *) + esac + test ".$_INP" != "." && break + done +fi +if test ".$_INP" = "."; then + case "$_OUT" in + */*) _INP=`basename "$_OUT"` + ;; + *-*) _INP=`echo "$_OUT" | sed -e "s/@<:@_symbol@:>@*-//"` + ;; + *) _INP=config.h + ;; + esac +fi +if test -z "$_PKG" ; then + AC_MSG_ERROR([no prefix for _PREFIX_PKG_CONFIG_H]) +else + if test ! -f "$_INP" ; then if test -f "$srcdir/$_INP" ; then + _INP="$srcdir/$_INP" + fi fi + AC_MSG_NOTICE(creating $_OUT - prefix $_UPP for $_INP defines) + if test -f $_INP ; then + AS_ECHO(["s/^@%:@undef *\\(@<:@m4_cr_LETTERS[]_@:>@\\)/@%:@undef $_UPP""_\\1/"]) > _script + AS_ECHO(["s/^@%:@undef *\\(@<:@m4_cr_letters@:>@\\)/@%:@undef $_LOW""_\\1/"]) >> _script + AS_ECHO(["s/^@%:@def[]ine *\\(@<:@m4_cr_LETTERS[]_@:>@@<:@_symbol@:>@*\\)\\(.*\\)/@%:@ifndef $_UPP""_\\1\\"]) >> _script + AS_ECHO(["@%:@def[]ine $_UPP""_\\1\\2\\"]) >> _script + AS_ECHO(["@%:@endif/"]) >> _script + AS_ECHO(["s/^@%:@def[]ine *\\(@<:@m4_cr_letters@:>@@<:@_symbol@:>@*\\)\\(.*\\)/@%:@ifndef $_LOW""_\\1\\"]) >> _script + AS_ECHO(["@%:@define $_LOW""_\\1\\2\\"]) >> _script + AS_ECHO(["@%:@endif/"]) >> _script + # now executing _script on _DEF input to create _OUT output file + echo "@%:@ifndef $_DEF" >$tmp/pconfig.h + echo "@%:@def[]ine $_DEF 1" >>$tmp/pconfig.h + echo ' ' >>$tmp/pconfig.h + echo /'*' $_OUT. Generated automatically at end of configure. '*'/ >>$tmp/pconfig.h + + sed -f _script $_INP >>$tmp/pconfig.h + echo ' ' >>$tmp/pconfig.h + echo '/* once:' $_DEF '*/' >>$tmp/pconfig.h + echo "@%:@endif" >>$tmp/pconfig.h + if cmp -s $_OUT $tmp/pconfig.h 2>/dev/null; then + AC_MSG_NOTICE([$_OUT is unchanged]) + else + ac_dir=`AS_DIRNAME(["$_OUT"])` + AS_MKDIR_P(["$ac_dir"]) + rm -f "$_OUT" + mv $tmp/pconfig.h "$_OUT" + fi + else + AC_MSG_ERROR([input file $_INP does not exist - skip generating $_OUT]) + fi + rm -f conftest.* +fi +m4_popdef([_symbol])dnl +m4_popdef([_script])dnl +AS_VAR_POPDEF([_INP])dnl +AS_VAR_POPDEF([_UPP])dnl +AS_VAR_POPDEF([_LOW])dnl +AS_VAR_POPDEF([_PKG])dnl +AS_VAR_POPDEF([_DEF])dnl +AS_VAR_POPDEF([_OUT])dnl +],[PACKAGE="$PACKAGE"])])