From c17609817aaebcc5a5659aaba4c915f54a958431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Fri, 5 Jun 2015 18:49:48 +0100 Subject: [PATCH] build: improve checks for stdbuf support * configure.ac: Actually run the test program to verify the constructor attribute is supported, or when cross compiling fail on warnings so that warnings about ignored attributes are significant. Fixes a build failure on AIX. --- configure.ac | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index c159983..4831dca 100644 --- a/configure.ac +++ b/configure.ac @@ -455,7 +455,7 @@ if test $gl_cv_list_mounted_fs = yes && test $gl_cv_fs_space = yes; then fi AC_MSG_CHECKING([whether this is system supports stdbuf]) -AC_COMPILE_IFELSE( +AC_RUN_IFELSE( [AC_LANG_PROGRAM([[ static int stdbuf = 0; @@ -471,7 +471,27 @@ AC_COMPILE_IFELSE( return !(stdbuf == 1);]]) ], [stdbuf_supported=yes], - [stdbuf_supported=no]) + [stdbuf_supported=no], + [ac_save_CFLAGS="$CFLAGS" + # Detect warnings about ignored "constructor" attributes + gl_WARN_ADD([-Werror], [STDBUF_WFLAGS]) + gl_WARN_ADD([-errwarn], [STDBUF_WFLAGS]) + CFLAGS="$CFLAGS $STDBUF_WFLAGS" + + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE([[ + void __attribute__ ((constructor)) + stdbuf_cross_test (void) + #if __ELF__ + {} + #endif + ]]) + ], + [stdbuf_supported=yes], + [stdbuf_supported=no]) + + CFLAGS="$ac_save_CFLAGS" + ]) AC_MSG_RESULT([$stdbuf_supported]) if test "$stdbuf_supported" = "yes" && test -z "$EXEEXT"; then gl_ADD_PROG([optional_bin_progs], [stdbuf]) -- 2.4.1