build: generate version.c during configure
authorOron Peled <oron.peled@xorcom.com>
Sun, 14 Dec 2014 22:37:33 +0000 (17:37 -0500)
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>
Tue, 19 May 2015 11:32:44 +0000 (14:32 +0300)
The TOOLSVERSION was inconsistent in configure.ac and Makefile:
* Rename the second parameter to AC_INIT() into short_version
* Calculate TOOLSVERSION during configure and use it to
  generate version.c from version.c.in
* For now, leave duplicate TOOLSVERSION in Makefile (for make dist)

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>

Makefile
build_tools/make_version_c [deleted file]
configure.ac
version.c.in [new file with mode: 0644]

index 69741e6..e7e8612 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -143,13 +143,6 @@ programs: libs utils
 
 utils: $(BINS) utils-subdirs
 
-version.c: FORCE
-       @TOOLSVERSION="${TOOLSVERSION}" build_tools/make_version_c > $@.tmp
-       @if cmp -s $@.tmp $@ ; then :; else \
-               mv $@.tmp $@ ; \
-       fi
-       @rm -f $@.tmp
-
 tests: $(TEST_BINS)
 
 $(UTILS): %: %.o
diff --git a/build_tools/make_version_c b/build_tools/make_version_c
deleted file mode 100755 (executable)
index 7382f3f..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/sh
-cat << END
-/*
- * version.c
- * Automatically generated
- */
-
-const char dahdi_tools_version[] = "DAHDI Tools Version - ${TOOLSVERSION}";
-
-END
index 4fa396b..9e75f09 100644 (file)
@@ -2,11 +2,11 @@
 
 AC_PREREQ(2.59)
  
-m4_define([TOOLSVERSION],
+m4_define([short_version],
           m4_bpatsubst(m4_esyscmd([build_tools/make_version . dahdi/tools]),
                        [\([0-9.]*\)\(\w\|\W\)*],
                        [\1]))
-AC_INIT(dahdi, TOOLSVERSION, www.asterisk.org)
+AC_INIT(dahdi, short_version, www.asterisk.org)
 
 # check existence of the package
 AC_CONFIG_SRCDIR([dahdi_cfg.c])
@@ -211,7 +211,12 @@ fi
 
 AC_SUBST(PPPD_VERSION)
 
-AC_CONFIG_FILES([makeopts])
+AC_SUBST([TOOLSVERSION], m4_esyscmd([build_tools/make_version . dahdi/tools]))
+
+AC_CONFIG_FILES([
+       makeopts
+       version.c
+       ])
 AC_OUTPUT
 
 AC_MSG_NOTICE(*** dahdi-tools build successfully configured ***)
diff --git a/version.c.in b/version.c.in
new file mode 100644 (file)
index 0000000..8a65a84
--- /dev/null
@@ -0,0 +1,6 @@
+/*
+ * version.c.in
+ */
+
+const char dahdi_tools_version[] = "DAHDI Tools Version - @TOOLSVERSION@";
+