From cfc746a5360d4ea95f9c65f150244f2f62c15c9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20E=2E=20=27Flameeyes=27=20Petten=C3=B2?= Date: Wed, 19 Nov 2008 02:23:34 +0100 Subject: Update the attributes.m4 file from lscube projects. This adds variants of CC_CHECK_CFLAGS that append the flags automatically, and a few comments. --- m4/attributes.m4 | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'm4') diff --git a/m4/attributes.m4 b/m4/attributes.m4 index 9c4a0c89a..45ea789ad 100644 --- a/m4/attributes.m4 +++ b/m4/attributes.m4 @@ -32,6 +32,9 @@ dnl distribute a modified version of the Autoconf Macro, you may extend dnl this special exception to the GPL to apply to your modified version as dnl well. +dnl Check if the flag is supported by compiler +dnl CC_CHECK_CFLAGS_SILENT([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND]) + AC_DEFUN([CC_CHECK_CFLAGS_SILENT], [ AC_CACHE_VAL(AS_TR_SH([cc_cv_cflags_$1]), [ac_save_CFLAGS="$CFLAGS" @@ -46,6 +49,9 @@ AC_DEFUN([CC_CHECK_CFLAGS_SILENT], [ [$2], [$3]) ]) +dnl Check if the flag is supported by compiler (cacheable) +dnl CC_CHECK_CFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND]) + AC_DEFUN([CC_CHECK_CFLAGS], [ AC_CACHE_CHECK([if $CC supports $1 flag], AS_TR_SH([cc_cv_cflags_$1]), @@ -56,6 +62,28 @@ AC_DEFUN([CC_CHECK_CFLAGS], [ [$2], [$3]) ]) +dnl CC_CHECK_CFLAG_APPEND(FLAG, [action-if-found], [action-if-not-found]) +dnl Check for CFLAG and appends them to CFLAGS if supported +AC_DEFUN([CC_CHECK_CFLAG_APPEND], [ + AC_CACHE_CHECK([if $CC supports $1 flag], + AS_TR_SH([cc_cv_cflags_$1]), + CC_CHECK_CFLAGS_SILENT([$1]) dnl Don't execute actions here! + ) + + AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes], + [CFLAGS="$CFLAGS $1"; $2], [$3]) +]) + +dnl CC_CHECK_CFLAGS_APPEND([FLAG1 FLAG2], [action-if-found], [action-if-not]) +AC_DEFUN([CC_CHECK_CFLAGS_APPEND], [ + for flag in $1; do + CC_CHECK_CFLAG_APPEND($flag, [$2], [$3]) + done +]) + +dnl Check if the flag is supported by linker (cacheable) +dnl CC_CHECK_LDFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND]) + AC_DEFUN([CC_CHECK_LDFLAGS], [ AC_CACHE_CHECK([if $CC supports $1 flag], AS_TR_SH([cc_cv_ldflags_$1]), -- cgit v1.2.3 From 164bbe5a9cf846903b166e37df087a4b9c8b363a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20E=2E=20=27Flameeyes=27=20Petten=C3=B2?= Date: Wed, 19 Nov 2008 02:40:09 +0100 Subject: Create a new macro CC_NOUNDEFINED to check for the -z defs flag or equivalent. I wanted this because I'm going to reuse attribute.m4 with that macro for a couple other projects. This also removes AC_TRY_LDFLAGS since it's not used any longer (replaced by CC_CHECK_LDFLAGS, which also caches results). --- m4/_xine.m4 | 15 --------------- m4/attributes.m4 | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 15 deletions(-) (limited to 'm4') diff --git a/m4/_xine.m4 b/m4/_xine.m4 index 3ebbb028d..900b57da5 100644 --- a/m4/_xine.m4 +++ b/m4/_xine.m4 @@ -157,21 +157,6 @@ AC_DEFUN([AC_TRY_CFLAGS], ifelse([$3],[],[:],[$3]) fi]) -dnl AC_TRY_LDFLAGS (CFLAGS, [ACTION-IF-WORKS], [ACTION-IF-FAILS]) -dnl check if $CC supports a given set of ldflags -AC_DEFUN([AC_TRY_LDFLAGS], - [AC_MSG_CHECKING([if $CC supports $1 flags]) - SAVE_LDFLAGS="$LDFLAGS" - LDFLAGS="$1" - AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[ac_cv_try_ldflags_ok=yes],[ac_cv_try_ldflags_ok=no]) - LDFLAGS="$SAVE_LDFLAGS" - AC_MSG_RESULT([$ac_cv_try_ldflags_ok]) - if test x"$ac_cv_try_ldflags_ok" = x"yes"; then - ifelse([$2],[],[:],[$2]) - else - ifelse([$3],[],[:],[$3]) - fi]) - dnl AC_CHECK_GENERATE_INTTYPES_H (INCLUDE-DIRECTORY) dnl generate a default inttypes.h if the header file does not exist already AC_DEFUN([AC_CHECK_GENERATE_INTTYPES], diff --git a/m4/attributes.m4 b/m4/attributes.m4 index 45ea789ad..e86456a46 100644 --- a/m4/attributes.m4 +++ b/m4/attributes.m4 @@ -99,6 +99,31 @@ AC_DEFUN([CC_CHECK_LDFLAGS], [ [$2], [$3]) ]) +dnl define the LDFLAGS_NOUNDEFINED variable with the correct value for +dnl the current linker to avoid undefined references in a shared object. +AC_DEFUN([CC_NOUNDEFINED], [ + dnl We check $host for which systems to enable this for. + AC_REQUIRE([AC_CANONICAL_HOST]) + + case $host in + dnl FreeBSD (et al.) does not complete linking for shared objects when pthreads + dnl are requested, as different implementations are present; to avoid problems + dnl use -Wl,-z,defs only for those platform not behaving this way. + *-freebsd*) ;; + *) + dnl First of all check for the --no-undefined variant of GNU ld. This allows + dnl for a much more readable commandline, so that people can understand what + dnl it does without going to look for what the heck -z defs does. + for possible_flags in "-Wl,--no-undefined" "-Wl,-z,defs"; do + CC_CHECK_LDFLAGS([$possible_flags], [LDFLAGS_NOUNDEFINED="$possible_flags"]) + break + done + ;; + esac + + AC_SUBST([LDFLAGS_NOUNDEFINED]) +]) + dnl Check for a -Werror flag or equivalent. -Werror is the GCC dnl and ICC flag that tells the compiler to treat all the warnings dnl as fatal. We usually need this option to make sure that some -- cgit v1.2.3 From 6f2a8f57aa686c68afa1a9a55d53746806a74a01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20E=2E=20=27Flameeyes=27=20Petten=C3=B2?= Date: Wed, 19 Nov 2008 02:46:31 +0100 Subject: Replace AC_TRY_CFLAGS usage with CC_CHECK_CFLAGS and remove the former. The CC_CHECK_CFLAGS macro is already present in attributes.m4, so no need to keep the old version we had around, especially since the new one caches its results too. --- m4/_xine.m4 | 15 --------------- m4/optimizations.m4 | 30 +++++++++++++++--------------- 2 files changed, 15 insertions(+), 30 deletions(-) (limited to 'm4') diff --git a/m4/_xine.m4 b/m4/_xine.m4 index 900b57da5..0c840cd9d 100644 --- a/m4/_xine.m4 +++ b/m4/_xine.m4 @@ -142,21 +142,6 @@ AC_DEFUN([AC_CHECK_DXR3], fi ]) -dnl AC_TRY_CFLAGS (CFLAGS, [ACTION-IF-WORKS], [ACTION-IF-FAILS]) -dnl check if $CC supports a given set of cflags -AC_DEFUN([AC_TRY_CFLAGS], - [AC_MSG_CHECKING([if $CC supports $1 flags]) - SAVE_CFLAGS="$CFLAGS" - CFLAGS="$1" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[ac_cv_try_cflags_ok=yes],[ac_cv_try_cflags_ok=no]) - CFLAGS="$SAVE_CFLAGS" - AC_MSG_RESULT([$ac_cv_try_cflags_ok]) - if test x"$ac_cv_try_cflags_ok" = x"yes"; then - ifelse([$2],[],[:],[$2]) - else - ifelse([$3],[],[:],[$3]) - fi]) - dnl AC_CHECK_GENERATE_INTTYPES_H (INCLUDE-DIRECTORY) dnl generate a default inttypes.h if the header file does not exist already AC_DEFUN([AC_CHECK_GENERATE_INTTYPES], diff --git a/m4/optimizations.m4 b/m4/optimizations.m4 index a1f2f2f00..ca329154e 100644 --- a/m4/optimizations.m4 +++ b/m4/optimizations.m4 @@ -17,30 +17,30 @@ AC_DEFUN([AC_OPTIMIZATIONS], [ if test "$GCC" = yes; then dnl dnl check cflags not supported by all gcc versions - AC_TRY_CFLAGS("-fschedule-insns2", f_si="-fschedule-insns2", f_si="") - AC_TRY_CFLAGS("-mwide-multiply", m_wm="-mwide-multiply", m_wm="") + CC_CHECK_CFLAGS([-fschedule-insns2], f_si="-fschedule-insns2", f_si="") + CC_CHECK_CFLAGS([-mwide-multiply], m_wm="-mwide-multiply", m_wm="") dnl dnl gcc 3.1 uses the -f version dnl - AC_TRY_CFLAGS("-falign-functions=4", f_af="-falign-functions=4", + CC_CHECK_CFLAGS([-falign-functions=4], f_af="-falign-functions=4", f_af="-malign-functions=4") - AC_TRY_CFLAGS("-falign-loops=4", f_al="-falign-loops=4", + CC_CHECK_CFLAGS([-falign-loops=4], f_al="-falign-loops=4", f_al="-malign-loops=4") - AC_TRY_CFLAGS("-falign-jumps=4", f_aj="-falign-jumps=4", + CC_CHECK_CFLAGS([-falign-jumps=4], f_aj="-falign-jumps=4", f_aj="-malign-jumps=4") dnl dnl Check for some optimization disabling dnl needed for win32 code dnl - AC_TRY_CFLAGS("-fno-omit-frame-pointer", W32_NO_OPTIMIZE="$W32_NO_OPTIMIZE -fno-omit-frame-pointer",) - AC_TRY_CFLAGS("-fno-inline-functions", W32_NO_OPTIMIZE="$W32_NO_OPTIMIZE -fno-inline-functions",) - AC_TRY_CFLAGS("-fno-rename-registers", W32_NO_OPTIMIZE="$W32_NO_OPTIMIZE -fno-rename-registers",) + CC_CHECK_CFLAGS([-fno-omit-frame-pointer], W32_NO_OPTIMIZE="$W32_NO_OPTIMIZE -fno-omit-frame-pointer",) + CC_CHECK_CFLAGS([-fno-inline-functions], W32_NO_OPTIMIZE="$W32_NO_OPTIMIZE -fno-inline-functions",) + CC_CHECK_CFLAGS([-fno-rename-registers], W32_NO_OPTIMIZE="$W32_NO_OPTIMIZE -fno-rename-registers",) AC_SUBST(W32_NO_OPTIMIZE) dnl dnl Multipass compilation dnl - AC_TRY_CFLAGS("-fprofile-arcs", PASS1_CFLAGS="-fprofile_arcs $PASS1_CFLAGS",) - AC_TRY_CFLAGS("-fbranch-probabilities", PASS2_CFLAGS="-fbranch-probabilities $PASS2_CFLAGS",) + CC_CHECK_CFLAGS([-fprofile-arcs], PASS1_CFLAGS="-fprofile_arcs $PASS1_CFLAGS",) + CC_CHECK_CFLAGS([-fbranch-probabilities], PASS2_CFLAGS="-fbranch-probabilities $PASS2_CFLAGS",) AC_SUBST(PASS1_CFLAGS) AC_SUBST(PASS2_CFLAGS) dnl @@ -69,7 +69,7 @@ AC_DEFUN([AC_OPTIMIZATIONS], [ fi dnl Flags not supported by all *cc* variants - AC_TRY_CFLAGS("-Wall", wall="-Wall", wall="") + CC_CHECK_CFLAGS([-Wall], wall="-Wall", wall="") CFLAGS="$wall ${CFLAGS}" DEBUG_CFLAGS="$wall ${DEBUG_CFLAGS}" @@ -80,11 +80,11 @@ AC_DEFUN([AC_OPTIMIZATIONS], [ if test "$GCC" = yes; then dnl Check for gcc cpu optimization support - AC_TRY_CFLAGS("-mtune=i386", + CC_CHECK_CFLAGS("-mtune=i386", sarchopt="-mtune", - AC_TRY_CFLAGS("-mcpu=i386", + CC_CHECK_CFLAGS("-mcpu=i386", sarchopt="-mcpu", - AC_TRY_CFLAGS("-march=i386", + CC_CHECK_CFLAGS("-march=i386", sarchopt="-march", [ AC_MSG_RESULT(** no cpu optimization supports **) sarchopt=no @@ -94,7 +94,7 @@ AC_DEFUN([AC_OPTIMIZATIONS], [ ) dnl special check for k7 cpu CC support - AC_TRY_CFLAGS("$sarchopt=athlon", k7cpu="athlon", k7cpu="i686") + CC_CHECK_CFLAGS([$sarchopt=athlon], k7cpu="athlon", k7cpu="i686") dnl add x86 specific gcc CFLAGS CFLAGS="-O3 -pipe -fomit-frame-pointer $f_af $f_al $f_aj $m_wm $m_psb -fexpensive-optimizations $f_si -ffast-math $INLINE_FUNCTIONS $CFLAGS" -- cgit v1.2.3 From 7df47df662414abf58b25d872c8f2ebf141072d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20E=2E=20=27Flameeyes=27=20Petten=C3=B2?= Date: Wed, 19 Nov 2008 02:47:24 +0100 Subject: Fix gcc version test when the CC variable needs not be quoted. When passing CC="ccache gcc", we don't want to quote "$CC" calls, otherwise the command won't be found. --- m4/optimizations.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'm4') diff --git a/m4/optimizations.m4 b/m4/optimizations.m4 index ca329154e..88ad99890 100644 --- a/m4/optimizations.m4 +++ b/m4/optimizations.m4 @@ -61,7 +61,7 @@ AC_DEFUN([AC_OPTIMIZATIONS], [ dnl -finline-functions. Use -fno-inline-functions for gcc < 3.4.0. AC_MSG_CHECKING(for gcc 3.4.0 or later) - newGCC="`"$CC" -dumpversion | + newGCC="`$CC -dumpversion | awk -F. '{ if ((@S|@1 * 10000 + @S|@2 * 100 + @S|@3) >= 30400) { print "yes" } }' `" AC_MSG_RESULT(${newGCC:-no - assuming bugginess in -finline-functions}) -- cgit v1.2.3 From 8ddba5b2d16ccf1505eb332717b02f5c5793802f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20E=2E=20=27Flameeyes=27=20Petten=C3=B2?= Date: Wed, 19 Nov 2008 02:59:39 +0100 Subject: Enable basic warnings even when optimisations are disabled. We don't want to have warnings conditional to extreme optimisations: if the compiler supports them, they should be enabled. The reason why they were conditional is that the code testing for GCC presence enabled both warnings and optimisations, and the warnings were carried over when the optimisations were made optional. --- m4/optimizations.m4 | 8 -------- 1 file changed, 8 deletions(-) (limited to 'm4') diff --git a/m4/optimizations.m4 b/m4/optimizations.m4 index 88ad99890..405672cca 100644 --- a/m4/optimizations.m4 +++ b/m4/optimizations.m4 @@ -43,11 +43,6 @@ AC_DEFUN([AC_OPTIMIZATIONS], [ CC_CHECK_CFLAGS([-fbranch-probabilities], PASS2_CFLAGS="-fbranch-probabilities $PASS2_CFLAGS",) AC_SUBST(PASS1_CFLAGS) AC_SUBST(PASS2_CFLAGS) - dnl - dnl Warnings - dnl - CFLAGS="-Wchar-subscripts -Wmissing-declarations -Wmissing-prototypes $CFLAGS" - CFLAGS="-Wnested-externs -Wcast-align $CFLAGS" dnl some combinations of gcc+glibc produce useless warnings on memset dnl when compiling with -Wpointer-arith, so we check for this first AC_MSG_CHECKING(for sane -Wpointer-arith) @@ -68,9 +63,6 @@ AC_DEFUN([AC_OPTIMIZATIONS], [ test "$newGCC" = yes || INLINE_FUNCTIONS=-fno-inline-functions fi - dnl Flags not supported by all *cc* variants - CC_CHECK_CFLAGS([-Wall], wall="-Wall", wall="") - CFLAGS="$wall ${CFLAGS}" DEBUG_CFLAGS="$wall ${DEBUG_CFLAGS}" -- cgit v1.2.3 From ea2b5508e35f5125fd65730822b30bb8895ad87d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Thu, 20 Nov 2008 20:56:19 +0100 Subject: Some warning fixes: XINE_FORMAT_SCANF, statics in headers, consts, ... Add warning flags to the DEBUG_CFLAGS too. --- m4/attributes.m4 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'm4') diff --git a/m4/attributes.m4 b/m4/attributes.m4 index e86456a46..ed52ba6d7 100644 --- a/m4/attributes.m4 +++ b/m4/attributes.m4 @@ -1,6 +1,6 @@ dnl Macros to check the presence of generic (non-typed) symbols. -dnl Copyright (c) 2006-2007 Diego Pettenò -dnl Copyright (c) 2006-2007 xine project +dnl Copyright (c) 2006-2008 Diego Pettenò +dnl Copyright (c) 2006-2008 xine project dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by @@ -71,7 +71,7 @@ AC_DEFUN([CC_CHECK_CFLAG_APPEND], [ ) AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes], - [CFLAGS="$CFLAGS $1"; $2], [$3]) + [CFLAGS="$CFLAGS $1"; DEBUG_CFLAGS="$DEBUG_CFLAGS $1"; $2], [$3]) ]) dnl CC_CHECK_CFLAGS_APPEND([FLAG1 FLAG2], [action-if-found], [action-if-not]) -- cgit v1.2.3