@@ -50,6 +50,7 @@
#
# Generated include files
#
+/include/version.h
# stgit generated dirs
patches-*
@@ -1,6 +1,8 @@
# -*- sh -*-
+VERSION = 1.4.5
+
CPPFLAGS += -I./include -I./ubi-utils/include $(ZLIBCPPFLAGS) $(LZOCPPFLAGS)
ifeq ($(WITHOUT_XATTR), 1)
@@ -36,6 +38,8 @@ TARGETS = $(BINS)
TARGETS += lib/libmtd.a
TARGETS += ubi-utils/libubi.a
+OBJDEPS = $(BUILDDIR)/include/version.h
+
include common.mk
clean::
@@ -49,6 +53,7 @@ endif
find $(BUILDDIR)/ -xdev \
'(' -name '*.[ao]' -o -name '.*.c.dep' ')' \
-exec rm -f {} +
+ rm -f $(BUILDDIR)/include/version.h
$(MAKE) -C $(TESTS) clean
install:: ${BINS} ${SCRIPTS}
@@ -63,6 +68,11 @@ tests::
cscope:
cscope -bR
+$(BUILDDIR)/include/version.h: $(BUILDDIR)/include/version.h.tmp
+ $(Q)cmp -s $@ $@.tmp && rm -f $@.tmp || mv $@.tmp $@
+$(BUILDDIR)/include/version.h.tmp:
+ $(Q)echo '#define VERSION "$(VERSION)"' > $@
+
#
# Utils in top level
#
@@ -75,7 +75,7 @@ $(BUILDDIR)/%.a:
$(Q)$(AR) cr $@ $^
$(Q)$(RANLIB) $@
-$(BUILDDIR)/%.o: %.c
+$(BUILDDIR)/%.o: %.c $(OBJDEPS)
ifneq ($(BUILDDIR),$(CURDIR))
$(Q)mkdir -p $(dir $@)
endif
@@ -19,7 +19,6 @@
*/
#define PROGRAM_NAME "flash_erase"
-#define VERSION "2.1.0"
#include <inttypes.h>
#include <stdio.h>
@@ -25,6 +25,7 @@
#include <string.h>
#include <fcntl.h>
#include <errno.h>
+#include "version.h"
#ifndef PROGRAM_NAME
# error "You must define PROGRAM_NAME before including this header"
@@ -14,7 +14,6 @@
*/
#define PROGRAM_NAME "nanddump"
-#define VERSION "1.31"
#define _GNU_SOURCE
#include <ctype.h>
@@ -20,7 +20,6 @@
*/
#define PROGRAM_NAME "nandwrite"
-#define VERSION "$Revision: 1.32 $"
#define _GNU_SOURCE
#include <ctype.h>
Signed-off-by: Mike Frysinger <vapier@gentoo.org> --- v2 - only add the version.h dep to *.o in the toplevel Makefile so tests/ subdirs can work without it .gitignore | 1 + Makefile | 10 ++++++++++ common.mk | 2 +- flash_erase.c | 1 - include/common.h | 1 + nanddump.c | 1 - nandwrite.c | 1 - 7 files changed, 13 insertions(+), 4 deletions(-)