diff mbox

[i-g-t,01/12] build: Define _GNU_SOURCE in Makefile.am

Message ID 20170902170406.8271-1-daniel.vetter@ffwll.ch (mailing list archive)
State New, archived
Headers show

Commit Message

Daniel Vetter Sept. 2, 2017, 5:03 p.m. UTC
In meson I want to just set this everywhere (no reason not to), and
doing so will allow us to clean up a few things.

But that means autofoo needs to follow suit.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 benchmarks/Makefile.am | 2 +-
 lib/Makefile.am        | 1 +
 lib/tests/Makefile.am  | 1 +
 tests/Makefile.am      | 1 +
 tools/Makefile.am      | 2 +-
 5 files changed, 5 insertions(+), 2 deletions(-)

Comments

Chris Wilson Sept. 3, 2017, 9:27 a.m. UTC | #1
Quoting Daniel Vetter (2017-09-02 18:03:55)
> In meson I want to just set this everywhere (no reason not to), and
> doing so will allow us to clean up a few things.

GNU_SOURCE is defined in config.h, which should be included from all
files (at least those that depend on system library foibles). I presume
you intend to move all of config.h onto the command line?
-Chris
Daniel Vetter Sept. 4, 2017, 8:48 a.m. UTC | #2
On Sun, Sep 03, 2017 at 10:27:03AM +0100, Chris Wilson wrote:
> Quoting Daniel Vetter (2017-09-02 18:03:55)
> > In meson I want to just set this everywhere (no reason not to), and
> > doing so will allow us to clean up a few things.
> 
> GNU_SOURCE is defined in config.h, which should be included from all
> files (at least those that depend on system library foibles). I presume
> you intend to move all of config.h onto the command line?

Wrt including config.h, we seem to be rather inconsistent with that. So
what I opted for is to put stuff like that onto the cmdline, and generate
a minimal config.h with just the few #defines we actually use in the meson
build. That seems a robust approach, since if you use such a #define
without including config.h, you'll get a complain. GNU_SOURCE otoh doesn't
result in any complaints if you don't set it, but it is rather surprising
to have it in some files, but not in others. Hence why I figured it's best
to just add it to the gcc cmdline.
-Daniel
diff mbox

Patch

diff --git a/benchmarks/Makefile.am b/benchmarks/Makefile.am
index 1232753917af..9d1838db1178 100644
--- a/benchmarks/Makefile.am
+++ b/benchmarks/Makefile.am
@@ -8,7 +8,7 @@  endif
 
 AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/lib
 AM_CFLAGS = $(DRM_CFLAGS) $(CWARNFLAGS) $(CAIRO_CFLAGS) $(LIBUNWIND_CFLAGS) \
-	    $(WERROR_CFLAGS)
+	    $(WERROR_CFLAGS) -D_GNU_SOURCE
 LDADD = $(top_builddir)/lib/libigt.la
 
 benchmarks_LTLIBRARIES = gem_exec_tracer.la
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 40399be12da9..abc61640dda4 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -64,6 +64,7 @@  AM_CFLAGS = \
 	    $(ALSA_CFLAGS) \
 	    -DIGT_SRCDIR=\""$(abs_top_srcdir)/tests"\" \
 	    -DIGT_DATADIR=\""$(pkgdatadir)"\" \
+	    -D_GNU_SOURCE \
 	    -DIGT_LOG_DOMAIN=\""$(subst _,-,$*)"\" \
 	    -pthread
 
diff --git a/lib/tests/Makefile.am b/lib/tests/Makefile.am
index 91440a27a5e8..661292a16446 100644
--- a/lib/tests/Makefile.am
+++ b/lib/tests/Makefile.am
@@ -12,6 +12,7 @@  AM_CFLAGS = $(DRM_CFLAGS) $(CWARNFLAGS) $(DEBUG_CFLAGS) \
 	-I$(srcdir)/.. \
 	-include "$(srcdir)/../../lib/check-ndebug.h" \
 	-DIGT_DATADIR=\""$(abs_srcdir)"\" \
+	-D_GNU_SOURCE
 	$(NULL)
 
 LDADD = ../libigt.la $(PCIACCESS_LIBS) $(DRM_LIBS) $(LIBUNWIND_LIBS) $(TIMER_LIBS)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3d9ea87ef4ee..c7447e1fdafe 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -76,6 +76,7 @@  AM_CFLAGS = $(DRM_CFLAGS) $(CWARNFLAGS) -Wno-unused-result $(DEBUG_CFLAGS)\
 	-include "$(srcdir)/../lib/check-ndebug.h" \
 	-DIGT_SRCDIR=\""$(abs_srcdir)"\" \
 	-DIGT_DATADIR=\""$(pkgdatadir)"\" \
+	-D_GNU_SOURCE \
 	$(LIBUNWIND_CFLAGS) $(WERROR_CFLAGS) \
 	$(NULL)
 
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 5991b4988865..6307a4bd54d7 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -18,7 +18,7 @@  SUBDIRS = null_state_gen registers
 AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/lib
 AM_CFLAGS = $(DEBUG_CFLAGS) $(DRM_CFLAGS) $(PCIACCESS_CFLAGS) $(CWARNFLAGS) \
 	    $(CAIRO_CFLAGS) $(LIBUNWIND_CFLAGS) -DPKGDATADIR=\"$(pkgdatadir)\" \
-	    $(WERROR_CFLAGS)
+	    $(WERROR_CFLAGS) -D_GNU_SOURCE
 LDADD = $(top_builddir)/lib/libigt.la
 AM_LDFLAGS = -Wl,--as-needed