Remove "asterisk/version.h" in favor of "asterisk/ast_version.h".
authorKevin P. Fleming <kpfleming@digium.com>
Wed, 25 Jan 2012 21:31:28 +0000 (21:31 +0000)
committerKevin P. Fleming <kpfleming@digium.com>
Wed, 25 Jan 2012 21:31:28 +0000 (21:31 +0000)
A long time ago, in a land far far away, we added "asterisk/ast_version.h",
which provides the ast_get_version() and ast_get_version_num() functions. These
were added so that modules that needed the version information for the Asterisk
instance they were loaded in could actually get it (as opposed the version that
they were compiled against). We changed everything in the tree to use the
new mechanism (although later main/test.c was added using the old method).
However, the old mechanism was never removed, and as a result, new code is
still trying to use it.

This commit removes asterisk/version.h and replaces it with a header that
will generate a compile-time error if you try to use it (the error message
tells you which header you should use instead). It also removes the Makefile
and build_tools bits that generated the file, and it updates main/test.c to
use the 'proper' method of getting the Asterisk version information.

This is an API change and thus is being committed for trunk only, but it's
a fairly minor one and definitely improves the situation for out-of-tree
modules.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@352626 65c4cc65-6c06-0410-ace0-fbb531ad65f3

Makefile
build_tools/make_version_h [deleted file]
include/asterisk/version.h [new file with mode: 0644]
main/test.c

index dfa1757..e1abdd5 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -386,7 +386,7 @@ makeopts.embed_rules: menuselect.makeopts
        +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LDFLAGS)
        +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LIBS)
 
-$(SUBDIRS): main/version.c include/asterisk/version.h include/asterisk/build.h include/asterisk/buildopts.h defaults.h makeopts.embed_rules
+$(SUBDIRS): main/version.c include/asterisk/build.h include/asterisk/buildopts.h defaults.h makeopts.embed_rules
 
 ifeq ($(findstring $(OSARCH), mingw32 cygwin ),)
     # Non-windows:
@@ -422,11 +422,6 @@ main/version.c: FORCE
        @cmp -s $@.tmp $@ || mv $@.tmp $@
        @rm -f $@.tmp
 
-include/asterisk/version.h: FORCE
-       @build_tools/make_version_h > $@.tmp
-       @cmp -s $@.tmp $@ || mv $@.tmp $@
-       @rm -f $@.tmp
-
 include/asterisk/buildopts.h: menuselect.makeopts
        @build_tools/make_buildopts_h > $@.tmp
        @cmp -s $@.tmp $@ || mv $@.tmp $@
@@ -449,7 +444,6 @@ _clean:
        rm -f defaults.h
        rm -f include/asterisk/build.h
        rm -f main/version.c
-       rm -f include/asterisk/version.h
        @$(MAKE) -C menuselect clean
        cp -f .cleancount .lastclean
 
diff --git a/build_tools/make_version_h b/build_tools/make_version_h
deleted file mode 100755 (executable)
index 5c74716..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/bin/sh
-if test ! -f .flavor ; then
-    cat << END
-/*
- * version.h 
- * Automatically generated
- */
-#define ASTERISK_VERSION "${ASTERISKVERSION}"
-#define ASTERISK_VERSION_NUM ${ASTERISKVERSIONNUM}
-
-END
-elif test ! -f .version ; then
-    aadkflavor=`cat .flavor`
-    cat << END
-/*
- * version.h 
- * Automatically generated
- */
-#define ASTERISK_VERSION "${ASTERISKVERSION} (${aadkflavor})"
-#define ASTERISK_VERSION_NUM ${ASTERISKVERSIONNUM}
-
-END
-else
-    aadkver=`cat .version`
-    aadkflavor=`cat .flavor`
-    cat << END
-/*
- * version.h 
- * Automatically generated
- */
-#define ASTERISK_VERSION "${ASTERISKVERSION} (${aadkflavor} ${aadkver})"
-#define ASTERISK_VERSION_NUM ${ASTERISKVERSIONNUM}
-
-END
-fi
-
diff --git a/include/asterisk/version.h b/include/asterisk/version.h
new file mode 100644 (file)
index 0000000..0c6ecb3
--- /dev/null
@@ -0,0 +1 @@
+#error "Do not include 'asterisk/version.h'; use 'asterisk/ast_version.h' instead."
index 741c0f5..07ddc4d 100644 (file)
@@ -38,7 +38,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$");
 #include "asterisk/utils.h"
 #include "asterisk/cli.h"
 #include "asterisk/term.h"
-#include "asterisk/version.h"
+#include "asterisk/ast_version.h"
 #include "asterisk/paths.h"
 #include "asterisk/time.h"
 #include "asterisk/manager.h"
@@ -386,14 +386,14 @@ static int test_generate_results(const char *name, const char *category, const c
                                last_results.total_time / 1000, last_results.total_time % 1000,
                                last_results.total_tests);
                fprintf(f_xml, "\t<properties>\n");
-               fprintf(f_xml, "\t\t<property name=\"version\" value=\"%s\"/>\n", ASTERISK_VERSION);
+               fprintf(f_xml, "\t\t<property name=\"version\" value=\"%s\"/>\n", ast_get_version());
                fprintf(f_xml, "\t</properties>\n");
        }
 
        /* txt header information */
        if (f_txt) {
-               fprintf(f_txt, "Asterisk Version:         %s\n", ASTERISK_VERSION);
-               fprintf(f_txt, "Asterisk Version Number:  %d\n", ASTERISK_VERSION_NUM);
+               fprintf(f_txt, "Asterisk Version:         %s\n", ast_get_version());
+               fprintf(f_txt, "Asterisk Version Number:  %s\n", ast_get_version_num());
                fprintf(f_txt, "Number of Tests:          %d\n", last_results.total_tests);
                fprintf(f_txt, "Number of Tests Executed: %d\n", (last_results.total_passed + last_results.total_failed));
                fprintf(f_txt, "Passed Tests:             %d\n", last_results.total_passed);