[vlc-commits] Only check optimization flags when useful
Rémi Denis-Courmont
git at videolan.org
Mon May 2 10:57:49 CEST 2011
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun May 1 20:39:50 2011 +0300| [2c9b0d37a05a1600f1cfdbdc75f9e12412b58b12] | committer: Rémi Denis-Courmont
Only check optimization flags when useful
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2c9b0d37a05a1600f1cfdbdc75f9e12412b58b12
---
configure.ac | 220 +++++++++++++++++++++++++++++++++++-------------------
m4/vlc.m4 | 6 +-
vlc-config.in.in | 16 +---
3 files changed, 148 insertions(+), 94 deletions(-)
diff --git a/configure.ac b/configure.ac
index b2547aa..fa18aec 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1050,79 +1050,157 @@ AS_IF([test "${enable_coverage}" != "no"], [
VLC_SAVE_FLAGS
+dnl
+dnl Enable/disable optimizations
+dnl
+AC_ARG_ENABLE(optimizations,
+ [AS_HELP_STRING([--disable-optimizations],
+ [disable compiler optimizations (default enabled)])],,
+ [enable_optimizations="yes"])
+AS_IF([test "${enable_optimizations}" != "no"], [
+ enable_optimizations="speed"
+])
+
dnl Check for various optimization flags
-AC_CACHE_CHECK([if \$CC accepts -O4],
- [ac_cv_c_o4],
- [CFLAGS="${CFLAGS_save} -O4"
- AC_TRY_COMPILE([],,ac_cv_c_o4=yes, ac_cv_c_o4=no)])
-if test "${ac_cv_c_o4}" != "no" -a "x${enable_debug}" = "xno"; then
- CFLAGS_OPTIM_SPEED="${CFLAGS_OPTIM_SPEED} -O4"
-else
- AC_CACHE_CHECK([if \$CC accepts -O3],
- [ac_cv_c_o3],
- [CFLAGS="${CFLAGS_save} -O3"
- AC_TRY_COMPILE([],,ac_cv_c_o3=yes, ac_cv_c_o3=no)])
- if test "${ac_cv_c_o3}" != "no" -a "x${enable_debug}" = "xno"; then
- CFLAGS_OPTIM_SPEED="${CFLAGS_OPTIM_SPEED} -O3"
- else
- AC_CACHE_CHECK([if \$CC accepts -O2],
- [ac_cv_c_o2],
- [CFLAGS="${CFLAGS_save} -O2"
- AC_TRY_COMPILE([],,ac_cv_c_o2=yes, ac_cv_c_o2=no)])
- if test "${ac_cv_c_o2}" != "no"; then
- CFLAGS_OPTIM_SPEED="${CFLAGS_OPTIM_SPEED} -O2"
- else
- AC_CACHE_CHECK([if \$CC accepts -O],
- [ac_cv_c_o],
- [CFLAGS="${CFLAGS_save} -O"
- AC_TRY_COMPILE([],,ac_cv_c_o=yes, ac_cv_c_o=no)])
- if test "${ac_cv_c_o}" != "no"; then
- CFLAGS_OPTIM_SPEED="${CFLAGS_OPTIM_SPEED} -O"
- fi
- fi
- fi
-fi
+AS_IF([test "${enable_optimizations}" != "no"], [
+
+ C_O=""
+ dnl -O4 and -O3 only in production builds
+ AS_IF([test "{enable_debug}" = "no"], [
+ AC_CACHE_CHECK([if $CC accepts -O4], [ac_cv_c_o4], [
+ CFLAGS="${CFLAGS_save} -O4"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
+ ac_cv_c_o4=yes
+ ], [
+ ac_cv_c_o4=no
+ ])
+ ])
+ AS_IF([test "${ac_cv_c_o4}" != "no"], [
+ C_O="-O4"
+ ], [
+ AC_CACHE_CHECK([if $CC accepts -O3], [ac_cv_c_o3], [
+ CFLAGS="${CFLAGS_save} -O3"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
+ ac_cv_c_o3=yes
+ ], [
+ ac_cv_c_o3=no
+ ])
+ ])
+ AS_IF([test "${ac_cv_c_o3}" != "no"], [
+ C_O="-O3"
+ ])
+ ])
+ ])
-dnl Check for -ffast-math
-AC_CACHE_CHECK([if \$CC accepts -ffast-math],
- [ac_cv_c_fast_math],
- [CFLAGS="${CFLAGS_save} -ffast-math"
- AC_TRY_COMPILE([],,ac_cv_c_fast_math=yes, ac_cv_c_fast_math=no)])
-if test "${ac_cv_c_fast_math}" != "no"; then
- CFLAGS_OPTIM_SPEED="${CFLAGS_OPTIM_SPEED} -ffast-math"
-fi
+ dnl -O2 and -O in both production and debug builds
+ AS_IF([test "x$C_O" = "x"], [
+ AC_CACHE_CHECK([if \$CC accepts -O2], [ac_cv_c_o2], [
+ CFLAGS="${CFLAGS_save} -O2"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
+ ac_cv_c_o2=yes
+ ], [
+ ac_cv_c_o2=no
+ ])
+ ])
+ AS_IF([test "${ac_cv_c_o2}" != "no"], [
+ C_O="-O2"
+ ], [
+ AC_CACHE_CHECK([if \$CC accepts -O], [ac_cv_c_o], [
+ CFLAGS="${CFLAGS_save} -O"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
+ ac_cv_c_o=yes
+ ], [
+ ac_cv_c_o=no
+ ])
+ ])
+ AS_IF([test "${ac_cv_c_o}" != "no"], [
+ C_O="-O"
+ ])
+ ])
+ ])
-dnl Check for -funroll-loops
-AC_CACHE_CHECK([if \$CC accepts -funroll-loops],
- [ac_cv_c_unroll_loops],
- [CFLAGS="${CFLAGS_save} -funroll-loops"
- AC_TRY_COMPILE([],,ac_cv_c_unroll_loops=yes, ac_cv_c_unroll_loops=no)])
-if test "${ac_cv_c_unroll_loops}" != "no"; then
- CFLAGS_OPTIM_SPEED="${CFLAGS_OPTIM_SPEED} -funroll-loops"
-fi
+ VLC_RESTORE_FLAGS
+ CFLAGS="${CFLAGS} ${C_O}"
+ CXXFLAGS="${CXXFLAGS} ${C_O}"
+ OBJCFLAGS="${OBJCFLAGS} ${C_O}"
+ VLC_SAVE_FLAGS
+
+ dnl Check for -ffast-math
+ AC_CACHE_CHECK([if $CC accepts -ffast-math], [ac_cv_c_fast_math], [
+ CFLAGS="${CFLAGS_save} -ffast-math"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
+ ac_cv_c_fast_math=yes
+ ], [
+ ac_cv_c_fast_math=no
+ ])
+ ])
+ AS_IF([test "${ac_cv_c_fast_math}" != "no"], [
+ VLC_RESTORE_FLAGS
+ CFLAGS="${CFLAGS} -ffast-math"
+ CXXFLAGS="${CXXFLAGS} -ffast-math"
+ OBJCFLAGS="${OBJCFLAGS} -ffast-math"
+ VLC_SAVE_FLAGS
+ ])
-dnl Check for -fomit-frame-pointer
-AC_CACHE_CHECK([if \$CC accepts -fomit-frame-pointer],
- [ac_cv_c_omit_frame_pointer],
- [CFLAGS="${CFLAGS_save} -fomit-frame-pointer"
- AC_TRY_COMPILE([],,ac_cv_c_omit_frame_pointer=yes, ac_cv_c_omit_frame_pointer=no)])
-if test "${ac_cv_c_omit_frame_pointer}" != "no"; then
- if test "${SYS}" != "darwin"; then
- CFLAGS_OPTIM_NODEBUG="${CFLAGS_OPTIM_NODEBUG} -fomit-frame-pointer"
- else
- dnl On darwin we explicitely disable it.
- CFLAGS_OPTIM_NODEBUG="${CFLAGS_OPTIM_NODEBUG} -fno-omit-frame-pointer"
- fi
-fi
+ dnl Check for -funroll-loops
+ AC_CACHE_CHECK([if $CC accepts -funroll-loops], [ac_cv_c_unroll_loops], [
+ CFLAGS="${CFLAGS_save} -funroll-loops"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
+ ac_cv_c_unroll_loops=yes
+ ], [
+ ac_cv_c_unroll_loops=no
+ ])
+ ])
+ AS_IF([test "${ac_cv_c_unroll_loops}" != "no"], [
+ VLC_RESTORE_FLAGS
+ CFLAGS="${CFLAGS} -funroll-loops"
+ CXXFLAGS="${CXXFLAGS} -funroll-loops"
+ OBJCFLAGS="${OBJCFLAGS} -funroll-loops"
+ VLC_SAVE_FLAGS
+ ])
+
+ AS_IF([test "$enable_debug" = "no"], [
+ dnl Check for -fomit-frame-pointer
+ AC_CACHE_CHECK([if $CC accepts -fomit-frame-pointer],
+ [ac_cv_c_omit_frame_pointer], [
+ CFLAGS="${CFLAGS_save} -fomit-frame-pointer"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
+ ac_cv_c_omit_frame_pointer=yes
+ ], [
+ ac_cv_c_omit_frame_pointer=no
+ ])
+ ])
+ AS_IF([test "${ac_cv_c_omit_frame_pointer}" != "no"], [
+ VLC_RESTORE_FLAGS
+ AS_IF([test "${SYS}" != "darwin"], [
+ CFLAGS="${CFLAGS} -fomit-frame-pointer"
+ CXXFLAGS="${CXXFLAGS} -fomit-frame-pointer"
+ ], [
+ dnl On darwin we explicitely disable it.
+ CFLAGS="${CFLAGS} -fno-omit-frame-pointer"
+ CXXFLAGS="${CXXFLAGS} -fno-omit-frame-pointer"
+ OBJCFLAGS="${OBJCFLAGS} -fno-omit-frame-pointer"
+ ])
+ VLC_SAVE_FLAGS
+ ])
+ ])
+])
dnl Check for Darwin plugin linking flags
-AC_CACHE_CHECK([if \$CC accepts -bundle -undefined error],
- [ac_cv_ld_darwin],
- [CFLAGS="${CFLAGS_save} -bundle -undefined error"
- AC_TRY_COMPILE([],,ac_cv_ld_darwin=yes, ac_cv_ld_darwin=no)])
-if test "${ac_cv_ld_darwin}" != "no"; then
+AS_IF([test "${SYS}" = "darwin"], [
+ AC_CACHE_CHECK([if $CC accepts -bundle -undefined error],
+ [ac_cv_ld_darwin], [
+ CFLAGS="${CFLAGS_save} -bundle -undefined error"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
+ ac_cv_ld_darwin=yes
+ ], [
+ ac_cv_ld_darwin=no
+ ])
+ ])
+ AS_IF([test "${ac_cv_ld_darwin}" != "no"], [
VLC_ADD_LDFLAGS([plugin],[-bundle -undefined error])
-fi
+ ])
+])
dnl Checks for __attribute__(aligned()) directive
AC_CACHE_CHECK([__attribute__ ((aligned ())) support],
@@ -1571,16 +1649,6 @@ if test "${enable_optimize_memory}" = "yes"; then
fi
dnl
-dnl Enable/disable optimizations
-dnl
-AC_ARG_ENABLE(optimizations,
- [AS_HELP_STRING([--disable-optimizations],
- [disable compiler optimizations (default enabled)])])
-if test "${enable_optimizations}" != "no"; then
- enable_optimizations="speed"
-fi
-
-dnl
dnl Allow running as root (useful for people running on embedded platforms)
dnl
AC_ARG_ENABLE(run-as-root,
diff --git a/m4/vlc.m4 b/m4/vlc.m4
index 61e309e..9ae566d 100644
--- a/m4/vlc.m4
+++ b/m4/vlc.m4
@@ -92,15 +92,11 @@ AC_DEFUN([VLC_OUTPUT_VLC_CONFIG_IN], [
rm -f vlc-config.in
sed -ne '/#@1@#/q;p' < "${srcdir}/vlc-config.in.in" \
- | sed -e "s/@gprof@/${enable_gprof}/" \
- -e "s/@cprof@/${enable_cprof}/" \
+ | sed \
-e "s/@optim@/${enable_optimizations}/" \
- -e "s/@debug@/${enable_debug}/" \
-e "s/@PLUGINS@/${PLUGINS}/" \
-e "s/@BUILTINS@/${BUILTINS}/" \
-e "s/@CFLAGS_TUNING@/${CFLAGS_TUNING}/" \
- -e "s/@CFLAGS_OPTIM_SPEED@/${CFLAGS_OPTIM_SPEED}/" \
- -e "s/@CFLAGS_OPTIM_NODEBUG@/${CFLAGS_OPTIM_NODEBUG}/" \
> vlc-config.in
dnl Switch/case loop
diff --git a/vlc-config.in.in b/vlc-config.in.in
index ac846a6..129c7b7 100644
--- a/vlc-config.in.in
+++ b/vlc-config.in.in
@@ -5,9 +5,6 @@ exec_prefix="@exec_prefix@"
exec_prefix_set=no
datarootdir="@datarootdir@"
-debug="@debug@"
-gprof="@gprof@"
-cprof="@cprof@"
optim="@optim@"
plugins="@PLUGINS@ "
@@ -21,8 +18,6 @@ ldflags=""
libs=""
cflags_tuning="@CFLAGS_TUNING@"
-cflags_optim_speed="@CFLAGS_OPTIM_SPEED@"
-cflags_optim_nodebug="@CFLAGS_OPTIM_NODEBUG@"
#
# Do not touch below this place unless you really know what you are doing
@@ -84,14 +79,9 @@ cppflags="${cppflags} -D_FILE_OFFSET_BITS=64 -D__USE_UNIX98 -D_REENTRANT -D_THRE
# Various additional defines
#
if [ "${optim}" = speed ]; then
- cflags="${cflags} ${cflags_optim_speed} ${cflags_tuning}"
- cxxflags="${cxxflags} ${cflags_optim_speed} ${cflags_tuning}"
- objcflags="${objcflags} ${cflags_optim_speed} ${cflags_tuning}"
- if [ "${debug}" != yes -a "${gprof}" != yes -a "${cprof}" != yes ]; then
- cflags="${cflags} ${cflags_optim_nodebug}"
- cxxflags="${cxxflags} ${cflags_optim_nodebug}"
- objcflags="${objcflags} ${cflags_optim_nodebug}"
- fi
+ cflags="${cflags} ${cflags_tuning}"
+ cxxflags="${cxxflags} ${cflags_tuning}"
+ objcflags="${objcflags} ${cflags_tuning}"
fi
#
More information about the vlc-commits
mailing list