Blob Blame Raw
From a1c211c91c63e6ab7b1f3eaae8ed006a6fae1976 Mon Sep 17 00:00:00 2001
From: Dave Love <dave.love@manchester.ac.uk>
Date: Sun, 14 May 2017 23:52:02 +0100
Subject: [PATCH 21/30] Configure for _GNU_SOURCE and make config.h first
 header included Fixes build with -std=c11

---
 configure.ac            | 3 ++-
 src/get-section.c       | 3 +--
 src/image-bind.c        | 3 +--
 src/image-create.c      | 3 +--
 src/image-expand.c      | 3 +--
 src/image-mount.c       | 3 +--
 src/lib/config_parser.c | 3 +--
 src/lib/loop-control.c  | 3 +--
 src/lib/message.c       | 2 +-
 src/lib/privilege.c     | 3 +--
 src/lib/singularity.c   | 4 ++--
 src/sexec.c             | 2 +-
 src/util/file.c         | 4 +---
 src/util/util.c         | 4 +---
 14 files changed, 16 insertions(+), 27 deletions(-)

diff --git a/configure.ac b/configure.ac
index b843ce94..6f07a1aa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_PREREQ(2.59)
+AC_PREREQ(2.60)
 AC_INIT([singularity],[2.2.1],[gmkurtzer@lbl.gov])
 
 if test -z "$prefix" -o "$prefix" = "NONE" ; then
@@ -27,6 +27,7 @@ AC_SUBST(SINGULARITY_ARCH)
 # https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1232579.html
 #AM_INIT_AUTOMAKE([foreign subdir-objects])
 
+AC_USE_SYSTEM_EXTENSIONS([_GNU_SOURCE])
 AM_INIT_AUTOMAKE([foreign subdir-objects]) ## SEE ABOVE BEFORE CHANGING
 AC_CONFIG_SRCDIR([src])
 AC_CONFIG_HEADERS([src/config.h])
diff --git a/src/get-section.c b/src/get-section.c
index 6110a46f..00825cb6 100644
--- a/src/get-section.c
+++ b/src/get-section.c
@@ -18,7 +18,7 @@
  * 
  */
 
-#define _GNU_SOURCE
+#include "config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -29,7 +29,6 @@
 #include <fcntl.h>  
 #include <linux/limits.h>
 
-#include "config.h"
 #include "util/file.h"
 #include "util/util.h"
 #include "lib/singularity.h"
diff --git a/src/image-bind.c b/src/image-bind.c
index 509f958f..0fdaedc1 100644
--- a/src/image-bind.c
+++ b/src/image-bind.c
@@ -18,7 +18,7 @@
  * 
  */
 
-#define _GNU_SOURCE
+#include "config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -36,7 +36,6 @@
 #include <libgen.h>
 #include <linux/limits.h>
 
-#include "config.h"
 #include "lib/singularity.h"
 #include "util/file.h"
 #include "util/util.h"
diff --git a/src/image-create.c b/src/image-create.c
index b3cface0..a9968c7a 100644
--- a/src/image-create.c
+++ b/src/image-create.c
@@ -18,7 +18,7 @@
  * 
  */
 
-#define _GNU_SOURCE
+#include "config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -28,7 +28,6 @@
 #include <string.h>
 #include <fcntl.h>  
 
-#include "config.h"
 #include "lib/singularity.h"
 #include "util/util.h"
 #include "util/file.h"
diff --git a/src/image-expand.c b/src/image-expand.c
index 259af86b..90e99a8a 100644
--- a/src/image-expand.c
+++ b/src/image-expand.c
@@ -18,7 +18,7 @@
  * 
  */
 
-#define _GNU_SOURCE
+#include "config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -28,7 +28,6 @@
 #include <string.h>
 #include <fcntl.h>  
 
-#include "config.h"
 #include "lib/singularity.h"
 #include "util/file.h"
 #include "util/util.h"
diff --git a/src/image-mount.c b/src/image-mount.c
index 995bae09..feeee6b1 100644
--- a/src/image-mount.c
+++ b/src/image-mount.c
@@ -18,7 +18,7 @@
  * 
  */
 
-#define _GNU_SOURCE
+#include "config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -36,7 +36,6 @@
 #include <libgen.h>
 #include <linux/limits.h>
 
-#include "config.h"
 #include "lib/singularity.h"
 #include "util/file.h"
 #include "util/util.h"
diff --git a/src/lib/config_parser.c b/src/lib/config_parser.c
index b9ef97b6..8a36d67f 100644
--- a/src/lib/config_parser.c
+++ b/src/lib/config_parser.c
@@ -18,7 +18,7 @@
  * 
  */
 
-#define _GNU_SOURCE
+#include "config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -29,7 +29,6 @@
 #include <fcntl.h>  
 #include <limits.h>
 
-#include "config.h"
 #include "util/util.h"
 #include "lib/message.h"
 #include "util/file.h"
diff --git a/src/lib/loop-control.c b/src/lib/loop-control.c
index cf60b756..f13b4408 100644
--- a/src/lib/loop-control.c
+++ b/src/lib/loop-control.c
@@ -18,7 +18,7 @@
  * 
  */
 
-#define _GNU_SOURCE
+#include "config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <linux/loop.h>
@@ -31,7 +31,6 @@
 #include <fcntl.h>
 #include <sys/ioctl.h>
 
-#include "config.h"
 #include "lib/loop-control.h"
 #include "lib/image-util.h"
 #include "util/util.h"
diff --git a/src/lib/message.c b/src/lib/message.c
index f84537c7..1036b052 100644
--- a/src/lib/message.c
+++ b/src/lib/message.c
@@ -19,6 +19,7 @@
  */
 
 
+#include "config.h"
 #include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -28,7 +29,6 @@
 #include <syslog.h>
 #include <limits.h>
 
-#include "config.h"
 #include "util/util.h"
 #include "lib/message.h"
 
diff --git a/src/lib/privilege.c b/src/lib/privilege.c
index 412756d1..1f688506 100644
--- a/src/lib/privilege.c
+++ b/src/lib/privilege.c
@@ -19,7 +19,7 @@
  */
 
 
-#define _GNU_SOURCE
+#include "config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -35,7 +35,6 @@
 #include <sched.h>
 
 #include "lib/privilege.h"
-#include "config.h"
 #include "util/file.h"
 #include "util/util.h"
 #include "lib/message.h"
diff --git a/src/lib/singularity.c b/src/lib/singularity.c
index db71d3a1..8987b271 100644
--- a/src/lib/singularity.c
+++ b/src/lib/singularity.c
@@ -18,12 +18,12 @@
  * 
  */
 
+#include "config.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 
-#include "config.h"
-
 
 
 
diff --git a/src/sexec.c b/src/sexec.c
index 1d0b7b69..f0ce1b98 100644
--- a/src/sexec.c
+++ b/src/sexec.c
@@ -18,6 +18,7 @@
  * 
  */
 
+#include "config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -26,7 +27,6 @@
 #include <errno.h>
 #include <string.h>
 
-#include "config.h"
 #include "lib/singularity.h"
 #include "util/util.h"
 #include "util/file.h"
diff --git a/src/util/file.c b/src/util/file.c
index 67e262e3..f43e11f1 100644
--- a/src/util/file.c
+++ b/src/util/file.c
@@ -19,8 +19,7 @@
  */
 
 
-#define _XOPEN_SOURCE 500 // For nftw
-#define _GNU_SOURCE
+#include "config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -35,7 +34,6 @@
 #include <ftw.h>
 #include <time.h>
 
-#include "config.h"
 #include "util/util.h"
 #include "lib/message.h"
 #include "lib/privilege.h"
diff --git a/src/util/util.c b/src/util/util.c
index 8bd0de36..1202b142 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -19,8 +19,7 @@
  */
 
 
-#define _XOPEN_SOURCE 500 // For nftw
-#define _GNU_SOURCE
+#include "config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -37,7 +36,6 @@
 #include <linux/limits.h>
 #include <ctype.h>
 
-#include "config.h"
 #include "util/util.h"
 #include "lib/message.h"
 
-- 
2.11.0