From: Mike Frysinger Date: Fri, 9 Oct 2015 21:47:40 +0000 (-0400) Subject: fix _GNU_SOURCE handling & header inclusion X-Git-Tag: v1.1.0~16 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=99dc70f023cf118f1e23125301d9fd38fb805f6d;p=alsa-lib.git fix _GNU_SOURCE handling & header inclusion The configure script blindly adds -D_GNU_SOURCE to all build settings, even on non-GNU systems. This isn't too much of a big deal (even if it uses the wrong variable -- CFLAGS instead of CPPFLAGS), except that the alsa-lib source itself determines whether to use GNU features when this is defined (such as versionsort). So when we build on non-glibc systems, we get build failures like: src/ucm/parser.c:1268:18: error: 'versionsort' undeclared (first use in this function) #define SORTFUNC versionsort ^ src/ucm/parser.c:1272:54: note: in expansion of macro 'SORTFUNC' err = scandir(filename, &namelist, filename_filter, SORTFUNC); ^ The correct way to add these flags is to use the autoconf helper AC_USE_SYSTEM_EXTENSIONS. Unfortunately, that triggers some more bugs in the alsa build. This macro adds defines to config.h and not directly to CPPFLAGS, so it relies on files correctly including config.h before anything else. A number of alsa files do not do this leading to build failures. The fix there is to shuffle the includes around so that the local ones come first. Signed-off-by: Mike Frysinger Signed-off-by: Takashi Iwai --- diff --git a/configure.ac b/configure.ac index a14e52de..9cb86142 100644 --- a/configure.ac +++ b/configure.ac @@ -27,11 +27,9 @@ AC_PREFIX_DEFAULT(/usr) dnl Checks for programs. -CFLAGS="$CFLAGS -D_GNU_SOURCE" - - AC_PROG_CC AC_PROG_CPP +AC_USE_SYSTEM_EXTENSIONS AC_PROG_INSTALL AC_PROG_LN_S AC_DISABLE_STATIC diff --git a/src/conf.c b/src/conf.c index c6a83eef..91fca255 100644 --- a/src/conf.c +++ b/src/conf.c @@ -414,12 +414,12 @@ beginning:

*/ +#include "local.h" #include #include #include #include #include -#include "local.h" #ifdef HAVE_LIBPTHREAD #include #endif diff --git a/src/timer/timer.c b/src/timer/timer.c index b71a9f8b..a25e4f79 100644 --- a/src/timer/timer.c +++ b/src/timer/timer.c @@ -67,15 +67,10 @@ This example shows opening a timer device and reading of timer events. * \anchor example_test_timer */ -#include -#include -#include -#include -#include -#include -#include #include "timer_local.h" +#include + static int snd_timer_open_conf(snd_timer_t **timer, const char *name, snd_config_t *timer_root, snd_config_t *timer_conf, int mode) diff --git a/src/timer/timer_hw.c b/src/timer/timer_hw.c index e833fc8c..e61b994d 100644 --- a/src/timer/timer_hw.c +++ b/src/timer/timer_hw.c @@ -19,12 +19,6 @@ * */ -#include -#include -#include -#include -#include -#include #include "timer_local.h" #ifndef PIC diff --git a/src/timer/timer_local.h b/src/timer/timer_local.h index 8040b05c..eef3b061 100644 --- a/src/timer/timer_local.h +++ b/src/timer/timer_local.h @@ -19,10 +19,9 @@ * */ -#include -#include -#include #include "local.h" +#include +#include #ifndef DOC_HIDDEN typedef struct { diff --git a/src/timer/timer_query.c b/src/timer/timer_query.c index 50b098a8..93d2455d 100644 --- a/src/timer/timer_query.c +++ b/src/timer/timer_query.c @@ -26,12 +26,6 @@ * */ -#include -#include -#include -#include -#include -#include #include "timer_local.h" static int snd_timer_query_open_conf(snd_timer_query_t **timer, diff --git a/src/timer/timer_query_hw.c b/src/timer/timer_query_hw.c index 289ca52f..d0c43916 100644 --- a/src/timer/timer_query_hw.c +++ b/src/timer/timer_query_hw.c @@ -19,12 +19,6 @@ * */ -#include -#include -#include -#include -#include -#include #include "timer_local.h" #ifndef PIC diff --git a/src/ucm/ucm_local.h b/src/ucm/ucm_local.h index c1655c70..3a5d2c2b 100644 --- a/src/ucm/ucm_local.h +++ b/src/ucm/ucm_local.h @@ -36,8 +36,8 @@ #define UC_MGR_DEBUG #endif -#include #include "local.h" +#include #include "use-case.h" #define MAX_FILE 256