- AC_MSG_RESULT([no])
- AC_MSG_NOTICE( TARGET=$target )
- case $target in
- i*86-apple-*)
- if test x"$ac_cv_c_compiler_gnu" = "xyes"; then
- # apples g++ fails with '-march=i686' and there are no apple machines older than prescott/core anyway
- DEFAULT_CXXFLAGS="-g -march=prescott -ffast-math -fomit-frame-pointer $DEFAULT_CXXFLAGS"
- fi
- ;;
- i686-*-*)
- if test x"$ac_cv_c_compiler_gnu" = "xyes"; then
- # default to i686/pentiumpro -- people can override this
- DEFAULT_CXXFLAGS="-g -march=i686 -ffast-math -fomit-frame-pointer $DEFAULT_CXXFLAGS"
- fi
- ;;
+ AC_MSG_RESULT([no])
+fi
+AC_SUBST(DEBUG_CPPFLAGS)
+AC_SUBST(DEBUG_CXXFLAGS)
+
+
+## see if the user wants aggressive optimizations of the code
+AC_MSG_CHECKING([whether to enable aggressive optimization flags])
+OPTIMIZATION_CPPFLAGS=""
+OPTIMIZATION_CXXFLAGS=""
+FLOAT_STORE_CFLAGS=""
+if test x"$enable_optimization" = "xyes"; then
+ AC_MSG_RESULT([yes])
+
+ # cure annoying default arguments for CFLAGS and CXXFLAGS
+ # that autoconf automatically sets in GNU environments if
+ # no CFLAGS or CXXFLAGS were manually given
+ #
+ # this is a more or less a hack ...
+ if test x"$CFLAGS" = x"-g -O2" ; then
+ CFLAGS=""
+ fi
+ if test x"$CXXFLAGS" = x"-g -O2" ; then
+ CXXFLAGS=""
+ fi
+
+ if test x"$ac_cv_c_compiler_gnu" = "xyes"; then
+
+ # special flag for gcc to work around excess precision bug in cLapack
+ FLOAT_STORE_CFLAGS="-ffloat-store"
+
+ # Due to a misconception, until SVN revision r1713, the case statement
+ # used the value of '--target', not of '--host'
+ case $host in
+ i386-apple-*)
+ # all intel macs have at least prescott instruction set
+ OPTIMIZATION_CXXFLAGS="-fast -g"
+ ;;
+ x86_64-apple-*)
+ # all 64bit intel macs have at least nocona instruction set
+ OPTIMIZATION_CXXFLAGS="-fast -g -march=nocona"
+ ;;
+ i?86-*-*)
+ # okay, we use this default together with the specification of the target architecture
+ # let us just assume, a Pentium 4 would be the minimum platform for OpenCV,
+ # then SSE2 instruction set is available also
+ OPTIMIZATION_CXXFLAGS="-O3 -g -march=pentium4 -ffast-math -fomit-frame-pointer"
+ ;;
+ amd64-*-* | x86_64-*-*)
+ OPTIMIZATION_CXXFLAGS="-O3 -g -march=x86-64 -ffast-math -fomit-frame-pointer"
+ ;;
+ powerpc-apple-*)
+ # Mac OS X 10.4 runs on CPUs >= G4 only
+ OPTIMIZATION_CXXFLAGS="-O3 -falign-loops-max-skip=15 -falign-jumps-max-skip=15 -falign-loops=16 -falign-jumps=16 -falign-functions=16 -ffast-math -fstrict-aliasing -funroll-loops -ftree-loop-linear -ftree-loop-memset -mcpu=G4 -mpowerpc-gpopt -mtune=G5 -fsched-interblock -fgcse-sm -g"
+ ;;
+ powerpc64-apple-*)
+ # There are no 64bit Macs with a CPU that's not a G5
+ OPTIMIZATION_CXXFLAGS="-O3 -falign-loops-max-skip=15 -falign-jumps-max-skip=15 -falign-loops=16 -falign-jumps=16 -falign-functions=16 -ffast-math -fstrict-aliasing -funroll-loops -ftree-loop-linear -ftree-loop-memset -mcpu=G5 -mpowerpc-gpopt -fsched-interblock -fgcse-sm -m64 -g"
+ ;;