From 35bde472b5455bab19157922dab06a5c2864bced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Tue, 20 May 2008 21:14:36 +0200 Subject: Add check for const attribute (for mathematical functions). Add CC_ATTRIBUTE_CONST macro to the attributes.h. Run CC_ATTRIBUTE_CONST in configure. Define SUPPORT_ATTRIBUTE_CONST for GCC 3. Define XINE_CONST to __attribute__((__const__)) if supported. --HG-- extra : transplant_source : /26%26%DF%C0%3C%AC%27%5C%B7%B1y%FEQ%8Ay%EE%F1%BD --- m4/attributes.m4 | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'm4') diff --git a/m4/attributes.m4 b/m4/attributes.m4 index fa379a2fe..f71b3d0d0 100644 --- a/m4/attributes.m4 +++ b/m4/attributes.m4 @@ -188,6 +188,14 @@ AC_DEFUN([CC_ATTRIBUTE_PACKED], [ [$2]) ]) +AC_DEFUN([CC_ATTRIBUTE_CONST], [ + CC_CHECK_ATTRIBUTE( + [const], , + [int __attribute__((const)) twopow(int n) { return 1 << n; } ], + [$1], + [$2]) +]) + AC_DEFUN([CC_FLAG_VISIBILITY], [ AC_REQUIRE([CC_CHECK_WERROR]) AC_CACHE_CHECK([if $CC supports -fvisibility=hidden], -- cgit v1.2.3 From 157f5234c463abe1b23a2f86dd182f40f99020fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Fri, 23 May 2008 23:31:33 +0200 Subject: Check for MIN/MAX macro and include the header for them if found. The MIN/MAX macro are quite often used on the source code to find the minimum or maximum value between two, instead of defining it per-unit, check if the system provides them include the right header, otherwise define them during configure run. --- m4/Makefile.am | 1 + m4/misc.m4 | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 m4/misc.m4 (limited to 'm4') diff --git a/m4/Makefile.am b/m4/Makefile.am index ddf3a9425..bcaa78a49 100644 --- a/m4/Makefile.am +++ b/m4/Makefile.am @@ -24,6 +24,7 @@ EXTRA_DIST = glibc2.m4 intdiv0.m4 intmax.m4 inttypes.m4 inttypes_h.m4 inttypes-p lcmessage.m4 \ libFLAC.m4 \ libfame.m4 \ + misc.m4 \ opengl.m4 \ optimizations.m4 \ pkg.m4 \ diff --git a/m4/misc.m4 b/m4/misc.m4 new file mode 100644 index 000000000..ab0d55510 --- /dev/null +++ b/m4/misc.m4 @@ -0,0 +1,58 @@ +dnl Miscellaneous M4 macros for configure +dnl Copyright (c) 2008 Diego Pettenò +dnl Copyright (c) 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 +dnl the Free Software Foundation; either version 2, or (at your option) +dnl any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +dnl 02110-1301, USA. +dnl +dnl As a special exception, the copyright owners of the +dnl macro gives unlimited permission to copy, distribute and modify the +dnl configure scripts that are the output of Autoconf when processing the +dnl Macro. You need not follow the terms of the GNU General Public +dnl License when using or distributing such scripts, even though portions +dnl of the text of the Macro appear in them. The GNU General Public +dnl License (GPL) does govern all other use of the material that +dnl constitutes the Autoconf Macro. +dnl +dnl This special exception to the GPL applies to versions of the +dnl Autoconf Macro released by this project. When you make and +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. + +AC_DEFUN([XINE_CHECK_MINMAX], [ + AC_CHECK_HEADERS([sys/param.h]) + AC_CACHE_CHECK([for MIN()/MAX() macros], + xine_cv_minmax, + [ + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([ + #ifdef HAVE_SYS_PARAM_H + # include + #endif + ], [ + int a = MIN(1, 3); + int b = MAX(2, 3); + ])], + [xine_cv_minmax=yes], + [xine_cv_minmax=no]) + ]) + + if test x$xine_cv_minmax = xyes; then + ifelse([$1], , [:], [$1]) + else + ifelse([$2], , [:], [$2]) + fi +]) -- cgit v1.2.3 From fc24f6446e014c087e4a84ec2934784f89a6bbb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Sat, 24 May 2008 00:34:56 +0200 Subject: Use M4sh AS_IF rather than sh if statements for common macros. Instead of using directly the sh if statement, use AS_IF, which makes it possible for autotools to identify conditionally-called macros, and allows to avoid M4 ifelse macros. --- m4/attributes.m4 | 118 ++++++++++++++++++++++--------------------------------- m4/misc.m4 | 7 +--- 2 files changed, 50 insertions(+), 75 deletions(-) (limited to 'm4') diff --git a/m4/attributes.m4 b/m4/attributes.m4 index f71b3d0d0..49f71bddc 100644 --- a/m4/attributes.m4 +++ b/m4/attributes.m4 @@ -42,11 +42,8 @@ AC_DEFUN([CC_CHECK_CFLAGS_SILENT], [ CFLAGS="$ac_save_CFLAGS" ]) - if eval test [x$]AS_TR_SH([cc_cv_cflags_$1]) = xyes; then - ifelse([$2], , [:], [$2]) - else - ifelse([$3], , [:], [$3]) - fi + AS_IF([test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes], + [$2], [$3]) ]) AC_DEFUN([CC_CHECK_CFLAGS], [ @@ -55,11 +52,8 @@ AC_DEFUN([CC_CHECK_CFLAGS], [ CC_CHECK_CFLAGS_SILENT([$1]) dnl Don't execute actions here! ) - if eval test [x$]AS_TR_SH([cc_cv_cflags_$1]) = xyes; then - ifelse([$2], , [:], [$2]) - else - ifelse([$3], , [:], [$3]) - fi + AS_IF([test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes], + [$2], [$3]) ]) dnl Check for a -Werror flag or equivalent. -Werror is the GCC @@ -91,76 +85,69 @@ AC_DEFUN([CC_CHECK_ATTRIBUTE], [ CFLAGS="$ac_save_CFLAGS" ]) - if eval test [x$]AS_TR_SH([cc_cv_attribute_$1]) = xyes; then - AC_DEFINE(AS_TR_CPP([SUPPORT_ATTRIBUTE_$1]), 1, [Define this if the compiler supports __attribute__(( ifelse([$2], , [$1], [$2]) ))]) - ifelse([$4], , [:], [$4]) - else - ifelse([$5], , [:], [$5]) - fi + AS_IF([test x$]AS_TR_SH([cc_cv_attribute_$1])[ = xyes], + [AC_DEFINE( + AS_TR_CPP([SUPPORT_ATTRIBUTE_$1]), 1, + [Define this if the compiler supports __attribute__(( ifelse([$2], , [$1], [$2]) ))] + ) + $4], + [$5]) ]) AC_DEFUN([CC_ATTRIBUTE_CONSTRUCTOR], [ CC_CHECK_ATTRIBUTE( [constructor],, [void __attribute__((constructor)) ctor() { int a; }], - [$1], - [$2]) + [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_FORMAT], [ CC_CHECK_ATTRIBUTE( [format], [format(printf, n, n)], [void __attribute__((format(printf, 1, 2))) printflike(const char *fmt, ...) { fmt = (void *)0; }], - [$1], - [$2]) + [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_FORMAT_ARG], [ CC_CHECK_ATTRIBUTE( [format_arg], [format_arg(printf)], [char *__attribute__((format_arg(1))) gettextlike(const char *fmt) { fmt = (void *)0; }], - [$1], - [$2]) + [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_VISIBILITY], [ CC_CHECK_ATTRIBUTE( [visibility_$1], [visibility("$1")], [void __attribute__((visibility("$1"))) $1_function() { }], - [$2], - [$3]) + [$2], [$3]) ]) AC_DEFUN([CC_ATTRIBUTE_NONNULL], [ CC_CHECK_ATTRIBUTE( [nonnull], [nonnull()], [void __attribute__((nonnull())) some_function(void *foo, void *bar) { foo = (void*)0; bar = (void*)0; }], - [$1], - [$2]) + [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_UNUSED], [ CC_CHECK_ATTRIBUTE( [unused], , [void some_function(void *foo, __attribute__((unused)) void *bar);], - [$1], - [$2]) + [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_SENTINEL], [ CC_CHECK_ATTRIBUTE( [sentinel], , [void some_function(void *foo, ...) __attribute__((sentinel));], - [$1], - [$2]) + [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_DEPRECATED], [ CC_CHECK_ATTRIBUTE( [deprecated], , [void some_function(void *foo, ...) __attribute__((deprecated));], - [$1], - [$2]) + [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_ALIAS], [ @@ -168,32 +155,28 @@ AC_DEFUN([CC_ATTRIBUTE_ALIAS], [ [alias], [weak, alias], [void other_function(void *foo) { } void some_function(void *foo) __attribute__((weak, alias("other_function")));], - [$1], - [$2]) + [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_MALLOC], [ CC_CHECK_ATTRIBUTE( [malloc], , [void * __attribute__((malloc)) my_alloc(int n);], - [$1], - [$2]) + [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_PACKED], [ CC_CHECK_ATTRIBUTE( [packed], , [struct astructure { char a; int b; long c; void *d; } __attribute__((packed));], - [$1], - [$2]) + [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_CONST], [ CC_CHECK_ATTRIBUTE( [const], , [int __attribute__((const)) twopow(int n) { return 1 << n; } ], - [$1], - [$2]) + [$1], [$2]) ]) AC_DEFUN([CC_FLAG_VISIBILITY], [ @@ -207,39 +190,34 @@ AC_DEFUN([CC_FLAG_VISIBILITY], [ cc_cv_flag_visibility='no') CFLAGS="$cc_flag_visibility_save_CFLAGS"]) - if test "x$cc_cv_flag_visibility" = "xyes"; then - AC_DEFINE([SUPPORT_FLAG_VISIBILITY], 1, [Define this if the compiler supports the -fvisibility flag]) - ifelse([$1], , [:], [$1]) - else - ifelse([$2], , [:], [$2]) - fi + AS_IF([test "x$cc_cv_flag_visibility" = "xyes"], + [AC_DEFINE([SUPPORT_FLAG_VISIBILITY], 1, + [Define this if the compiler supports the -fvisibility flag]) + $1], + [$2]) ]) AC_DEFUN([CC_FUNC_EXPECT], [ - AC_REQUIRE([CC_CHECK_WERROR]) - ac_save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $cc_cv_werror" - AC_CACHE_CHECK([if compiler has __builtin_expect function], - [cc_cv_func_expect], - [AC_COMPILE_IFELSE([ - int some_function() - { - int a = 3; - return (int)__builtin_expect(a, 3); - } - ], - [cc_cv_func_expect=yes], - [cc_cv_func_expect=no]) - ]) - CFLAGS="$ac_save_CFLAGS" - - if test "x$cc_cv_func_expect" = "xyes"; then - AC_DEFINE([SUPPORT__BUILTIN_EXPECT], 1, [Define this if the compiler supports __builtin_expect() function]) - $1 - else - true - $2 - fi + AC_REQUIRE([CC_CHECK_WERROR]) + AC_CACHE_CHECK([if compiler has __builtin_expect function], + [cc_cv_func_expect], + [ac_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $cc_cv_werror" + AC_COMPILE_IFELSE( + [int some_function() { + int a = 3; + return (int)__builtin_expect(a, 3); + }], + [cc_cv_func_expect=yes], + [cc_cv_func_expect=no]) + CFLAGS="$ac_save_CFLAGS" + ]) + + AS_IF([test "x$cc_cv_func_expect" = "xyes"], + [AC_DEFINE([SUPPORT__BUILTIN_EXPECT], 1, + [Define this if the compiler supports __builtin_expect() function]) + $1], + [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_ALIGNED], [ diff --git a/m4/misc.m4 b/m4/misc.m4 index ab0d55510..83246f36c 100644 --- a/m4/misc.m4 +++ b/m4/misc.m4 @@ -50,9 +50,6 @@ AC_DEFUN([XINE_CHECK_MINMAX], [ [xine_cv_minmax=no]) ]) - if test x$xine_cv_minmax = xyes; then - ifelse([$1], , [:], [$1]) - else - ifelse([$2], , [:], [$2]) - fi + AS_IF([test x$xine_cv_minmax = xyes], + [$1], [$2]) ]) -- cgit v1.2.3 From a2583761573b98127ae9396785875a88a4a4b8ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Sat, 24 May 2008 02:01:21 +0200 Subject: Backport CC_CHECK_LDFLAGS macro from 1.2 branch. --- m4/attributes.m4 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'm4') diff --git a/m4/attributes.m4 b/m4/attributes.m4 index 49f71bddc..3fee49ab5 100644 --- a/m4/attributes.m4 +++ b/m4/attributes.m4 @@ -56,6 +56,21 @@ AC_DEFUN([CC_CHECK_CFLAGS], [ [$2], [$3]) ]) +AC_DEFUN([CC_CHECK_LDFLAGS], [ + AC_CACHE_CHECK([if $CC supports $1 flag], + AS_TR_SH([cc_cv_ldflags_$1]), + [ac_save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $1" + AC_LINK_IFELSE([int main() { return 1; }], + [eval "AS_TR_SH([cc_cv_ldflags_$1])='yes'"], + [eval "AS_TR_SH([cc_cv_ldflags_$1])="]) + LDFLAGS="$ac_save_LDFLAGS" + ]) + + AS_IF([test x$]AS_TR_SH([cc_cv_ldflags_$1])[ = xyes], + [$2], [$3]) +]) + 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 0cb95cb5ae7e494f0ba776eeeceec3225ff15a28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Sat, 24 May 2008 02:04:27 +0200 Subject: Backport pthreads.m4 from 1.2. Both attributes.m4 and pthread.m4 are two reusable M4 macro files, which can eaily be shared between different projects. For this reason it's better if they are kept identical between branches. --- m4/pthreads.m4 | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'm4') diff --git a/m4/pthreads.m4 b/m4/pthreads.m4 index fb1adaab8..facac076f 100644 --- a/m4/pthreads.m4 +++ b/m4/pthreads.m4 @@ -73,3 +73,28 @@ AC_DEFUN([CC_PTHREAD_FLAGS], [ ifelse([$2], , [:], [$2]) fi ]) + +AC_DEFUN([CC_PTHREAD_RECURSIVE_MUTEX], [ + AC_REQUIRE([CC_PTHREAD_FLAGS]) + AC_MSG_CHECKING([for recursive mutex support in pthread]) + + ac_save_LIBS="$LIBS" + LIBS="$LIBS $PTHREAD_LIBS" + AC_COMPILE_IFELSE(AC_LANG_SOURCE([#include + +int main() { + pthread_mutexattr_t attr; + pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); + return 0; +} + ]), [have_recursive_mutex=yes], [have_recursive_mutex=no]) + LIBS="$ac_save_LIBS" + + AC_MSG_RESULT([$have_recursive_mutex]) + + if test x"$have_recursive_mutex" = x"yes"; then + ifelse([$1], , [:], [$1]) + else + ifelse([$2], , [:], [$2]) + fi +]) -- cgit v1.2.3 From c9ad18a7e3b147c95c8b9132831259722aa95c18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Sat, 24 May 2008 02:08:29 +0200 Subject: Rewrite CC_PTHREAD_RECURSIVE_MUTEX to use M4sh and AC_CACHE_CHECK. --- m4/pthreads.m4 | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'm4') diff --git a/m4/pthreads.m4 b/m4/pthreads.m4 index facac076f..653a496da 100644 --- a/m4/pthreads.m4 +++ b/m4/pthreads.m4 @@ -75,26 +75,28 @@ AC_DEFUN([CC_PTHREAD_FLAGS], [ ]) AC_DEFUN([CC_PTHREAD_RECURSIVE_MUTEX], [ - AC_REQUIRE([CC_PTHREAD_FLAGS]) - AC_MSG_CHECKING([for recursive mutex support in pthread]) - - ac_save_LIBS="$LIBS" - LIBS="$LIBS $PTHREAD_LIBS" - AC_COMPILE_IFELSE(AC_LANG_SOURCE([#include - + AC_REQUIRE([CC_PTHREAD_FLAGS]) + AC_CACHE_CHECK( + [for recursive mutex support in pthread], + [cc_cv_pthread_recursive_mutex], + [ac_save_LIBS="$LIBS" + LIBS="$LIBS $PTHREAD_LIBS" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([ +#include + ], [ int main() { pthread_mutexattr_t attr; pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); return 0; } - ]), [have_recursive_mutex=yes], [have_recursive_mutex=no]) - LIBS="$ac_save_LIBS" - - AC_MSG_RESULT([$have_recursive_mutex]) + ]) + ], + [cc_cv_pthread_recursive_mutex=yes], + [cc_cv_pthread_recursive_mutex=no]) + LIBS="$ac_save_LIBS" + ]) - if test x"$have_recursive_mutex" = x"yes"; then - ifelse([$1], , [:], [$1]) - else - ifelse([$2], , [:], [$2]) - fi + AS_IF([test x"$cc_cv_pthread_recursive_mutex" = x"yes"], + [$1], [$2]) ]) -- cgit v1.2.3