obmc-console: Extract definition of _GNU_SOURCE

Avoid triggering bugprone-reserved-identifier

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I8b4d40c92c1e9633bdb078c3f8d6d97ffb248cc2
diff --git a/configure.ac b/configure.ac
index 6b0fb98..9278e62 100644
--- a/configure.ac
+++ b/configure.ac
@@ -19,7 +19,7 @@
 # Checks for header files.
 
 # Checks for typedefs, structures, and compiler characteristics.
-AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CFLAGS])
+AX_APPEND_COMPILE_FLAGS([-Wall -Werror -D_GNU_SOURCE], [CFLAGS])
 
 # Checks for library functions.
 LT_INIT # Removes 'unrecognized options: --with-libtool-sysroot'
diff --git a/console-server.c b/console-server.c
index 02219cf..273f3cd 100644
--- a/console-server.c
+++ b/console-server.c
@@ -16,8 +16,6 @@
  * limitations under the License.
  */
 
-#define _GNU_SOURCE
-
 #include <assert.h>
 #include <errno.h>
 #include <signal.h>
diff --git a/log-handler.c b/log-handler.c
index 233f41f..1212b52 100644
--- a/log-handler.c
+++ b/log-handler.c
@@ -14,7 +14,6 @@
  * limitations under the License.
  */
 
-#define _GNU_SOURCE
 #include <endian.h>
 #include <err.h>
 #include <fcntl.h>
diff --git a/meson.build b/meson.build
index 81f13a2..8787f2a 100644
--- a/meson.build
+++ b/meson.build
@@ -10,6 +10,8 @@
     meson_version: '>=0.63.0',
 )
 
+add_project_arguments('-D_GNU_SOURCE', language: 'c')
+
 systemdsystemunitdir = dependency('systemd').get_variable('systemdsystemunitdir')
 install_data('conf/obmc-console@.service.in',
              'conf/obmc-console@.socket.in',
diff --git a/ringbuffer.c b/ringbuffer.c
index 5c485fc..48c163a 100644
--- a/ringbuffer.c
+++ b/ringbuffer.c
@@ -14,8 +14,6 @@
  * limitations under the License.
  */
 
-#define _GNU_SOURCE
-
 #include <assert.h>
 #include <stdint.h>
 #include <stdlib.h>
diff --git a/socket-handler.c b/socket-handler.c
index 79e1641..d7aaa67 100644
--- a/socket-handler.c
+++ b/socket-handler.c
@@ -14,8 +14,6 @@
  * limitations under the License.
  */
 
-#define _GNU_SOURCE
-
 #include <assert.h>
 #include <err.h>
 #include <errno.h>
diff --git a/tty-handler.c b/tty-handler.c
index bdc0870..dd348b6 100644
--- a/tty-handler.c
+++ b/tty-handler.c
@@ -14,8 +14,6 @@
  * limitations under the License.
  */
 
-#define _GNU_SOURCE
-
 #include <assert.h>
 #include <err.h>
 #include <errno.h>