]> git.alsa-project.org Git - alsa-lib.git/commitdiff
fix _GNU_SOURCE handling & header inclusion
authorMike Frysinger <vapier@chromium.org>
Fri, 9 Oct 2015 21:47:40 +0000 (17:47 -0400)
committerTakashi Iwai <tiwai@suse.de>
Mon, 12 Oct 2015 08:36:15 +0000 (10:36 +0200)
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 <vapier@gentoo.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
configure.ac
src/conf.c
src/timer/timer.c
src/timer/timer_hw.c
src/timer/timer_local.h
src/timer/timer_query.c
src/timer/timer_query_hw.c
src/ucm/ucm_local.h

index a14e52de5e3b2d6e7198efa63837149a7ad8720c..9cb861421077c701610b59d60e997ec7d619f349 100644 (file)
@@ -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
index c6a83eef7d2fb9c64c5029cde5c787d790083b48..91fca25545f1cbb824f18d7b07f1ba7b44f50921 100644 (file)
@@ -414,12 +414,12 @@ beginning:</P>
 */
 
 
+#include "local.h"
 #include <stdarg.h>
 #include <limits.h>
 #include <sys/stat.h>
 #include <dirent.h>
 #include <locale.h>
-#include "local.h"
 #ifdef HAVE_LIBPTHREAD
 #include <pthread.h>
 #endif
index b71a9f8bc2918924a6d17767237f4d1ca2b2a03f..a25e4f797ce4e35a5112bc161245f3fe4e1b4eee 100644 (file)
@@ -67,15 +67,10 @@ This example shows opening a timer device and reading of timer events.
  * \anchor example_test_timer
  */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <sys/ioctl.h>
 #include "timer_local.h"
 
+#include <signal.h>
+
 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)
index e833fc8cbb4124e4139dd0bbc87cc75f8f765706..e61b994d78bcd458f3d8521c66d020ad7e3f27b4 100644 (file)
  *
  */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
 #include "timer_local.h"
 
 #ifndef PIC
index 8040b05cae190a600e2c5ef7f7bc2d36e465c699..eef3b0617717866718a7678785f90d8b4a65bfbe 100644 (file)
  *
  */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <limits.h>
 #include "local.h"
+#include <limits.h>
+#include <sys/ioctl.h>
 
 #ifndef DOC_HIDDEN
 typedef struct {
index 50b098a8f29eef01211a65fe99c347633555c691..93d2455d07fc33329d19e5552899ac4931968c28 100644 (file)
  *
  */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
 #include "timer_local.h"
 
 static int snd_timer_query_open_conf(snd_timer_query_t **timer,
index 289ca52f2afa8b9ffea312e7139e50df434f5a7d..d0c43916d6b9148880b0c70beebe8674b1a6c4c2 100644 (file)
  *
  */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
 #include "timer_local.h"
 
 #ifndef PIC
index c1655c70504f0fb9c99b1324b8e0a071c9375f0e..3a5d2c2b77b55cbf5ab147106819b120468efe82 100644 (file)
@@ -36,8 +36,8 @@
 #define UC_MGR_DEBUG
 #endif
 
-#include <pthread.h>
 #include "local.h"
+#include <pthread.h>
 #include "use-case.h"
 
 #define MAX_FILE               256