aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKyle Russell <bkylerussell@gmail.com>2021-01-27 11:58:56 -0500
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2021-01-27 21:30:26 +0100
commita8183270c91b098ad819f02f510945a400ebbc40 (patch)
treec5e98042d2ff0af3316bd5b97a2cb865b23ac5f5
parent0fb77bb6e5429575f52b5e26f06db031f93de057 (diff)
downloadsparse-a8183270c91b098ad819f02f510945a400ebbc40.tar.gz
Makefile: fix version.h dependencies
This guarantees the generated version.h will exist before attempting to compile any c files that include it. Several source files include the generated version.h, but not all declare a proper make dependency. $ grep -r 'version\.h' *.c compile-i386.c:#include "version.h" lib.c:#include "version.h" options.c:#include "version.h" This allows a sufficiently parallelized make invocation to encounter ENOENT. CC compile-i386.o compile-i386.c:60:21: fatal error: version.h: No such file or directory compilation terminated. Makefile:253: recipe for target 'compile-i386.o' failed make: *** [compile-i386.o] Error 1 Signed-off-by: Kyle Russell <bkylerussell@gmail.com> [luc.vanoostenryck@gmail.com: modified so that only version.c depends on version.h] Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--Makefile3
-rw-r--r--compile-i386.c3
-rw-r--r--lib.c1
-rw-r--r--lib.h1
-rw-r--r--options.c3
-rw-r--r--version.c4
6 files changed, 9 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index 31366446..f9883da1 100644
--- a/Makefile
+++ b/Makefile
@@ -90,6 +90,7 @@ LIB_OBJS += target-xtensa.o
LIB_OBJS += tokenize.o
LIB_OBJS += unssa.o
LIB_OBJS += utils.o
+LIB_OBJS += version.o
PROGRAMS :=
PROGRAMS += compile
@@ -260,7 +261,7 @@ cflags += $($(*)-cflags) $(CPPFLAGS) $(CFLAGS)
selfcheck: $(OBJS:.o=.sc)
SPARSE_VERSION:=$(shell git describe --dirty 2>/dev/null || echo '$(VERSION)')
-lib.o: version.h
+version.o: version.h
version.h: FORCE
@echo '#define SPARSE_VERSION "$(SPARSE_VERSION)"' > version.h.tmp
@if cmp -s version.h version.h.tmp; then \
diff --git a/compile-i386.c b/compile-i386.c
index 2ee7b35e..16b3893a 100644
--- a/compile-i386.c
+++ b/compile-i386.c
@@ -57,7 +57,6 @@
#include "target.h"
#include "compile.h"
#include "bitmap.h"
-#include "version.h"
struct textbuf {
unsigned int len; /* does NOT include terminating null */
@@ -691,7 +690,7 @@ void emit_unit_begin(const char *basename)
void emit_unit_end(void)
{
textbuf_emit(&unit_post_text);
- printf("\t.ident\t\"sparse silly x86 backend (version %s)\"\n", SPARSE_VERSION);
+ printf("\t.ident\t\"sparse silly x86 backend (version %s)\"\n", sparse_version);
}
/* conditionally switch sections */
diff --git a/lib.c b/lib.c
index 4bc5cd02..e282a4fb 100644
--- a/lib.c
+++ b/lib.c
@@ -46,7 +46,6 @@
#include "linearize.h"
#include "target.h"
#include "machine.h"
-#include "version.h"
#include "bits.h"
static int prettify(const char **fnamep)
diff --git a/lib.h b/lib.h
index b4c3db93..b96e3192 100644
--- a/lib.h
+++ b/lib.h
@@ -48,6 +48,7 @@
#define PATH_MAX 4096 // Hurd doesn't define this
#endif
+extern const char *sparse_version;
struct position {
unsigned int type:6,
diff --git a/options.c b/options.c
index 17da5f36..6704fc8d 100644
--- a/options.c
+++ b/options.c
@@ -11,7 +11,6 @@
#include "lib.h"
#include "machine.h"
#include "target.h"
-#include "version.h"
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
@@ -974,7 +973,7 @@ static char **handle_os(char *arg, char **next)
static char **handle_version(char *arg, char **next)
{
- printf("%s\n", SPARSE_VERSION);
+ printf("%s\n", sparse_version);
exit(0);
}
diff --git a/version.c b/version.c
new file mode 100644
index 00000000..5d83167d
--- /dev/null
+++ b/version.c
@@ -0,0 +1,4 @@
+#include "lib.h"
+#include "version.h"
+
+const char *sparse_version = SPARSE_VERSION;