From f1852cd22274d9c6223bb2ba99f1ab27e894bc4b Mon Sep 17 00:00:00 2001 From: Extravagant Date: Sun, 12 Feb 2012 22:23:40 +0000 Subject: [PATCH] Updated with AC_LANG_SOURCE directives Please see this informative thread on bug-autoconf: http://www.mail-archive.com/bug-autoconf@gnu.org/msg03052.html --- scripts/attributes.m4 | 28 +++++++++++++------------- scripts/checks.m4 | 36 ++++++++++++++++----------------- scripts/common.m4 | 47 +++++++++++++++++++++---------------------- 3 files changed, 55 insertions(+), 56 deletions(-) diff --git a/scripts/attributes.m4 b/scripts/attributes.m4 index 183d48b9..b121fcdc 100644 --- a/scripts/attributes.m4 +++ b/scripts/attributes.m4 @@ -3,10 +3,10 @@ AC_DEFUN([CC_ATTRIBUTE_CONSTRUCTOR], [ AC_CACHE_CHECK([if compiler supports __attribute__((constructor))], [cc_cv_attribute_constructor], - [AC_COMPILE_IFELSE([ + [AC_COMPILE_IFELSE([AC_LANG_SOURCE([ void ctor() __attribute__((constructor)); void ctor() { }; - ], + ])], [cc_cv_attribute_constructor=yes], [cc_cv_attribute_constructor=no]) ]) @@ -23,9 +23,9 @@ AC_DEFUN([CC_ATTRIBUTE_CONSTRUCTOR], [ AC_DEFUN([CC_ATTRIBUTE_FORMAT], [ AC_CACHE_CHECK([if compiler supports __attribute__((format(printf, n, n)))], [cc_cv_attribute_format], - [AC_COMPILE_IFELSE([ + [AC_COMPILE_IFELSE([AC_LANG_SOURCE([ void __attribute__((format(printf, 1, 2))) printflike(const char *fmt, ...) { } - ], + ])], [cc_cv_attribute_format=yes], [cc_cv_attribute_format=no]) ]) @@ -42,9 +42,9 @@ AC_DEFUN([CC_ATTRIBUTE_FORMAT], [ AC_DEFUN([CC_ATTRIBUTE_INTERNAL], [ AC_CACHE_CHECK([if compiler supports __attribute__((visibility("internal")))], [cc_cv_attribute_internal], - [AC_COMPILE_IFELSE([ + [AC_COMPILE_IFELSE([AC_LANG_SOURCE([ void __attribute__((visibility("internal"))) internal_function() { } - ], + ])], [cc_cv_attribute_internal=yes], [cc_cv_attribute_internal=no]) ]) @@ -66,9 +66,9 @@ AC_DEFUN([CC_ATTRIBUTE_VISIBILITY], [ AC_CACHE_CHECK([if compiler supports __attribute__((visibility("default")))], [cc_cv_attribute_visibility], - [AC_COMPILE_IFELSE([ + [AC_COMPILE_IFELSE([AC_LANG_SOURCE([ void __attribute__((visibility("default"))) visibility_function() { } - ], + ])], [cc_cv_attribute_visibility=yes], [cc_cv_attribute_visibility=no]) ]) @@ -90,10 +90,10 @@ AC_DEFUN([CC_ATTRIBUTE_VISIBILITY], [ AC_DEFUN([CC_ATTRIBUTE_NONNULL], [ AC_CACHE_CHECK([if compiler supports __attribute__((nonnull()))], [cc_cv_attribute_nonnull], - [AC_COMPILE_IFELSE([ + [AC_COMPILE_IFELSE([AC_LANG_SOURCE([ void some_function(void *foo, void *bar) __attribute__((nonnull())); void some_function(void *foo, void *bar) { } - ], + ])], [cc_cv_attribute_nonnull=yes], [cc_cv_attribute_nonnull=no]) ]) @@ -110,9 +110,9 @@ AC_DEFUN([CC_ATTRIBUTE_NONNULL], [ AC_DEFUN([CC_ATTRIBUTE_UNUSED], [ AC_CACHE_CHECK([if compiler supports __attribute__((unused))], [cc_cv_attribute_unused], - [AC_COMPILE_IFELSE([ + [AC_COMPILE_IFELSE([AC_LANG_SOURCE([ void some_function(void *foo, __attribute__((unused)) void *bar); - ], + ])], [cc_cv_attribute_unused=yes], [cc_cv_attribute_unused=no]) ]) @@ -129,13 +129,13 @@ AC_DEFUN([CC_ATTRIBUTE_UNUSED], [ AC_DEFUN([CC_FUNC_EXPECT], [ AC_CACHE_CHECK([if compiler has __builtin_expect function], [cc_cv_func_expect], - [AC_COMPILE_IFELSE([ + [AC_COMPILE_IFELSE([AC_LANG_SOURCE([ int some_function() { int a = 3; return (int)__builtin_expect(a, 3); } - ], + ])], [cc_cv_func_expect=yes], [cc_cv_func_expect=no]) ]) diff --git a/scripts/checks.m4 b/scripts/checks.m4 index f32bd3b0..9bc7a85d 100644 --- a/scripts/checks.m4 +++ b/scripts/checks.m4 @@ -1,15 +1,15 @@ AC_DEFUN([TORRENT_CHECK_XFS], [ AC_MSG_CHECKING(for XFS support) - AC_COMPILE_IFELSE( - [[#include + AC_COMPILE_IFELSE([AC_LANG_SOURCE([ + #include #include int main() { struct xfs_flock64 l; ioctl(0, XFS_IOC_RESVSP64, &l); return 0; } - ]], + ])], [ AC_DEFINE(USE_XFS, 1, Use XFS filesystem stuff.) AC_MSG_RESULT(yes) @@ -46,13 +46,13 @@ AC_DEFUN([TORRENT_WITH_XFS], [ AC_DEFUN([TORRENT_CHECK_EPOLL], [ AC_MSG_CHECKING(for epoll support) - AC_COMPILE_IFELSE( - [[#include + AC_COMPILE_IFELSE([AC_LANG_SOURCE([ + #include int main() { int fd = epoll_create(100); return 0; } - ]], + ])], [ AC_DEFINE(USE_EPOLL, 1, Use epoll.) AC_MSG_RESULT(yes) @@ -77,14 +77,14 @@ AC_DEFUN([TORRENT_WITHOUT_EPOLL], [ AC_DEFUN([TORRENT_CHECK_KQUEUE], [ AC_MSG_CHECKING(for kqueue support) - AC_LINK_IFELSE( - [[#include /* Because OpenBSD's sys/event.h fails to compile otherwise. Yeah... */ + AC_LINK_IFELSE([AC_LANG_SOURCE([ + #include /* Because OpenBSD's sys/event.h fails to compile otherwise. Yeah... */ #include int main() { int fd = kqueue(); return 0; } - ]], + ])], [ AC_DEFINE(USE_KQUEUE, 1, Use kqueue.) AC_MSG_RESULT(yes) @@ -96,8 +96,8 @@ AC_DEFUN([TORRENT_CHECK_KQUEUE], [ AC_DEFUN([TORRENT_CHECK_KQUEUE_SOCKET_ONLY], [ AC_MSG_CHECKING(whether kqueue supports pipes and ptys) - AC_RUN_IFELSE( - [[#include + AC_RUN_IFELSE([AC_LANG_SOURCE([ + #include #include #include #include @@ -122,7 +122,7 @@ AC_DEFUN([TORRENT_CHECK_KQUEUE_SOCKET_ONLY], [ if ((n = kevent(kfd, NULL, 0, ev_out, 2, &ts)) < 1) return 9; return 0; } - ]], + ])], [ AC_MSG_RESULT(yes) ], [ @@ -364,11 +364,11 @@ AC_DEFUN([TORRENT_CHECK_TR1], [ AC_LANG_PUSH(C++) AC_MSG_CHECKING(for TR1 support) - AC_COMPILE_IFELSE( - [[#include + AC_COMPILE_IFELSE([AC_LANG_SOURCE([ + #include class Foo; typedef std::tr1::unordered_map Bar; - ]], + ])], [ AC_MSG_RESULT(yes) AC_DEFINE(HAVE_TR1, 1, Define to 1 if your C++ library supports the extensions from Technical Report 1) @@ -385,14 +385,14 @@ AC_DEFUN([TORRENT_CHECK_CXX11], [ AC_LANG_PUSH(C++) AC_MSG_CHECKING(for C++11 support) - AC_COMPILE_IFELSE( - [[#include + AC_COMPILE_IFELSE([AC_LANG_SOURCE([ + #include #include class Foo; typedef std::unordered_map Bar; union test { Bar b1; }; - ]], + ])], [ AC_MSG_RESULT(yes) AC_DEFINE(HAVE_CXX11, 1, Define to 1 if your C++ compiler has support for C++11.) diff --git a/scripts/common.m4 b/scripts/common.m4 index f875c71a..ad4edad4 100644 --- a/scripts/common.m4 +++ b/scripts/common.m4 @@ -99,11 +99,11 @@ AC_DEFUN([TORRENT_OTFD], [ AC_LANG_PUSH(C++) AC_MSG_CHECKING(for proper overloaded template function disambiguation) - AC_COMPILE_IFELSE( - [[template void f(T&) {} + AC_COMPILE_IFELSE([AC_LANG_SOURCE([ + template void f(T&) {} template void f(T*) {} int main() { int *i = 0; f(*i); f(i); } - ]], + ])], [ AC_MSG_RESULT(yes) ], [ @@ -119,24 +119,24 @@ AC_DEFUN([TORRENT_MINCORE_SIGNEDNESS], [ AC_LANG_PUSH(C++) AC_MSG_CHECKING(signedness of mincore parameter) - AC_COMPILE_IFELSE( - [[#include + AC_COMPILE_IFELSE([AC_LANG_SOURCE([ + #include #include #include void f() { mincore((char*)0, 0, (unsigned char*)0); } - ]], + ])], [ AC_DEFINE(USE_MINCORE, 1, Use mincore) AC_DEFINE(USE_MINCORE_UNSIGNED, 1, use unsigned char* in mincore) AC_MSG_RESULT(unsigned) ], [ - AC_COMPILE_IFELSE( - [[#include + AC_COMPILE_IFELSE([AC_LANG_SOURCE([ + #include #include #include void f() { mincore((char*)0, 0, (char*)0); } - ]], + ])], [ AC_DEFINE(USE_MINCORE, 1, Use mincore) AC_DEFINE(USE_MINCORE_UNSIGNED, 0, use char* in mincore) @@ -168,11 +168,11 @@ AC_DEFUN([TORRENT_MINCORE], [ AC_DEFUN([TORRENT_CHECK_MADVISE], [ AC_MSG_CHECKING(for madvise) - AC_COMPILE_IFELSE( - [[#include + AC_COMPILE_IFELSE([AC_LANG_SOURCE([ + #include #include void f() { static char test[1024]; madvise((void *)test, sizeof(test), MADV_NORMAL); } - ]], + ])], [ AC_MSG_RESULT(yes) AC_DEFINE(USE_MADVISE, 1, Use madvise) @@ -184,10 +184,9 @@ AC_DEFUN([TORRENT_CHECK_MADVISE], [ AC_DEFUN([TORRENT_CHECK_POPCOUNT], [ AC_MSG_CHECKING(for __builtin_popcount) - AC_COMPILE_IFELSE( - [[ + AC_COMPILE_IFELSE([AC_LANG_SOURCE([ void f() { __builtin_popcount(0); } - ]], + ])], [ AC_MSG_RESULT(yes) AC_DEFINE(USE_BUILTIN_POPCOUNT, 1, Use __builtin_popcount.) @@ -199,12 +198,12 @@ AC_DEFUN([TORRENT_CHECK_POPCOUNT], [ AC_DEFUN([TORRENT_CHECK_CACHELINE], [ AC_MSG_CHECKING(for cacheline) - AC_COMPILE_IFELSE( - [[#include + AC_COMPILE_IFELSE([AC_LANG_SOURCE([ + #include #include void* vptr __cacheline_aligned; void f() { posix_memalign(&vptr, SMP_CACHE_BYTES, 42); } - ]], + ])], [ AC_MSG_RESULT(found builtin) dnl AC_DEFINE(LT_SMP_CACHE_BYTES, SMP_CACHE_BYTES, Largest L1 cache size we know of, should work on all archs.) @@ -224,10 +223,10 @@ dnl Need to fix this so that it uses the stuff defined by the system. AC_DEFUN([TORRENT_CHECK_EXECINFO], [ AC_MSG_CHECKING(for execinfo.h) - AC_RUN_IFELSE( - [[#include + AC_RUN_IFELSE([AC_LANG_SOURCE([ + #include int main() { backtrace((void**)0, 0); backtrace_symbols((char**)0, 0); return 0;} - ]], + ])], [ AC_MSG_RESULT(yes) AC_DEFINE(USE_EXECINFO, 1, Use execinfo.h) @@ -239,8 +238,8 @@ AC_DEFUN([TORRENT_CHECK_EXECINFO], [ AC_DEFUN([TORRENT_CHECK_ALIGNED], [ AC_MSG_CHECKING(the byte alignment) - AC_RUN_IFELSE( - [[#include + AC_RUN_IFELSE([AC_LANG_SOURCE([ + #include int main() { char buf[8] = { 0, 0, 0, 0, 1, 0, 0, 0 }; int i; @@ -248,7 +247,7 @@ AC_DEFUN([TORRENT_CHECK_ALIGNED], [ if (*(uint32_t*)(buf + i) == 0) return -1; return 0; } - ]], + ])], [ AC_MSG_RESULT(none needed) ], [