[asterisk-commits] russell: trunk r96717 - in /trunk: ./ build_tools/ channels/ funcs/ include/a...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Jan 5 16:09:06 CST 2008


Author: russell
Date: Sat Jan  5 16:09:06 2008
New Revision: 96717

URL: http://svn.digium.com/view/asterisk?view=rev&rev=96717
Log:
Now that the version.h file was getting properly regenerated every time the svn
revision changed, every module that used the version was getting rebuilt after
every svn update.  This severly annoyed me pretty quickly, so I have improved
the situation.

Now, instead of generating version.h, main/version.c is generated.  version.c
includes the version information, as well as a couple of API calls for modules
to retrieve the version.  So now, only version.c will get rebuilt, and the main
asterisk binary relinked, which is must faster than rebuilding http.c, manager.c,
asterisk.c, relinking the asterisk binary, chan_sip.c, func_version.c, res_agi ...

The only minor change in behavior here is that the version information reported by
chan_sip, for example, is the version of the Asterisk core, and not necessarily the
Asterisk version that the chan_sip module came from.

Added:
    trunk/build_tools/make_version_c
      - copied, changed from r96691, trunk/build_tools/make_version_h
    trunk/include/asterisk/version.h   (with props)
Removed:
    trunk/build_tools/make_version_h
Modified:
    trunk/Makefile
    trunk/channels/chan_sip.c
    trunk/funcs/func_version.c
    trunk/include/asterisk/   (props changed)
    trunk/main/   (props changed)
    trunk/main/Makefile
    trunk/main/asterisk.c
    trunk/main/http.c
    trunk/main/manager.c
    trunk/res/res_agi.c

Modified: trunk/Makefile
URL: http://svn.digium.com/view/asterisk/trunk/Makefile?view=diff&rev=96717&r1=96716&r2=96717
==============================================================================
--- trunk/Makefile (original)
+++ trunk/Makefile Sat Jan  5 16:09:06 2008
@@ -372,7 +372,7 @@
 	@$(MAKE) $(PRINT_DIR) $(MOD_SUBDIRS_EMBED_LDFLAGS)
 	@$(MAKE) $(PRINT_DIR) $(MOD_SUBDIRS_EMBED_LIBS)
 
-$(SUBDIRS): 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:
@@ -403,8 +403,8 @@
 	@cmp -s $@.tmp $@ || mv $@.tmp $@
 	@rm -f $@.tmp
 
-include/asterisk/version.h:
-	@build_tools/make_version_h > $@.tmp
+main/version.c:
+	@build_tools/make_version_c > $@.tmp
 	@cmp -s $@.tmp $@ || mv $@.tmp $@
 	@rm -f $@.tmp
 
@@ -427,7 +427,7 @@
 clean: $(SUBDIRS_CLEAN)
 	rm -f defaults.h
 	rm -f include/asterisk/build.h
-	rm -f include/asterisk/version.h
+	rm -f main/version.c
 	@$(MAKE) -C menuselect clean
 	cp -f .cleancount .lastclean
 
@@ -695,7 +695,7 @@
 
 rpm: __rpm
 
-__rpm: include/asterisk/version.h include/asterisk/buildopts.h spec
+__rpm: main/version.c include/asterisk/buildopts.h spec
 	rm -rf /tmp/asterisk ; \
 	mkdir -p /tmp/asterisk/redhat/RPMS/i386 ; \
 	$(MAKE) DESTDIR=/tmp/asterisk install ; \
@@ -820,4 +820,4 @@
 asterisk.pdf:
 	$(MAKE) -C doc/tex asterisk.pdf
 
-.PHONY: menuselect main sounds clean dist-clean distclean all prereqs cleantest uninstall _uninstall uninstall-all pdf dont-optimize $(SUBDIRS_INSTALL) $(SUBDIRS_DIST_CLEAN) $(SUBDIRS_CLEAN) $(SUBDIRS_UNINSTALL) $(SUBDIRS) $(MOD_SUBDIRS_EMBED_LDSCRIPT) $(MOD_SUBDIRS_EMBED_LDFLAGS) $(MOD_SUBDIRS_EMBED_LIBS) include/asterisk/version.h
+.PHONY: menuselect main sounds clean dist-clean distclean all prereqs cleantest uninstall _uninstall uninstall-all pdf dont-optimize $(SUBDIRS_INSTALL) $(SUBDIRS_DIST_CLEAN) $(SUBDIRS_CLEAN) $(SUBDIRS_UNINSTALL) $(SUBDIRS) $(MOD_SUBDIRS_EMBED_LDSCRIPT) $(MOD_SUBDIRS_EMBED_LDFLAGS) $(MOD_SUBDIRS_EMBED_LIBS) main/version.c

Copied: trunk/build_tools/make_version_c (from r96691, trunk/build_tools/make_version_h)
URL: http://svn.digium.com/view/asterisk/trunk/build_tools/make_version_c?view=diff&rev=96717&p1=trunk/build_tools/make_version_h&r1=96691&p2=trunk/build_tools/make_version_c&r2=96717
==============================================================================
--- trunk/build_tools/make_version_h (original)
+++ trunk/build_tools/make_version_c Sat Jan  5 16:09:06 2008
@@ -8,10 +8,26 @@
 fi
 cat << END
 /*
- * version.h 
+ * version.c
  * Automatically generated
  */
-#define ASTERISK_VERSION "${ASTERISKVERSION}${EXTRA}"
-#define ASTERISK_VERSION_NUM ${ASTERISKVERSIONNUM}
+
+#include "asterisk.h"
+
+#include "asterisk/version.h"
+
+static const char asterisk_version[] = "${ASTERISKVERSION}${EXTRA}";
+
+static const char asterisk_version_num[] = "${ASTERISKVERSIONNUM}";
+
+const char *ast_get_version(void)
+{
+	return asterisk_version;
+}
+
+const char *ast_get_version_num(void)
+{
+	return asterisk_version_num;
+}
 
 END

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?view=diff&rev=96717&r1=96716&r2=96717
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Sat Jan  5 16:09:06 2008
@@ -18371,8 +18371,8 @@
 	global_directrtpsetup = FALSE;		/* Experimental feature, disabled by default */
 	global_alwaysauthreject = 0;
 	global_allowsubscribe = FALSE;
-	snprintf(global_useragent, sizeof(global_useragent), "%s %s", DEFAULT_USERAGENT, ASTERISK_VERSION);
-	snprintf(global_sdpsession, sizeof(global_sdpsession), "%s %s", DEFAULT_SDPSESSION, ASTERISK_VERSION);
+	snprintf(global_useragent, sizeof(global_useragent), "%s %s", DEFAULT_USERAGENT, ast_get_version());
+	snprintf(global_sdpsession, sizeof(global_sdpsession), "%s %s", DEFAULT_SDPSESSION, ast_get_version());
 	snprintf(global_sdpowner, sizeof(global_sdpowner), "%s", DEFAULT_SDPOWNER);
 	ast_copy_string(default_notifymime, DEFAULT_NOTIFYMIME, sizeof(default_notifymime));
 	ast_copy_string(global_realm, S_OR(ast_config_AST_SYSTEM_NAME, DEFAULT_REALM), sizeof(global_realm));

Modified: trunk/funcs/func_version.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_version.c?view=diff&rev=96717&r1=96716&r2=96717
==============================================================================
--- trunk/funcs/func_version.c (original)
+++ trunk/funcs/func_version.c Sat Jan  5 16:09:06 2008
@@ -34,39 +34,35 @@
 #include "asterisk/version.h"
 #include "asterisk/build.h"
 
-#define STRING_IT(vernum) STRING_IT2(vernum)
-#define STRING_IT2(vernum) #vernum
-
 static int acf_version_exec(struct ast_channel *chan, const char *cmd,
 			 char *parse, char *buffer, size_t buflen)
 {
-	char *response_char = ASTERISK_VERSION;
+	const char *response_char = ast_get_version();
 	AST_DECLARE_APP_ARGS(args,
-			     AST_APP_ARG(info);
+		AST_APP_ARG(info);
 	);
 
 	AST_STANDARD_APP_ARGS(args, parse);
 
 	if (!ast_strlen_zero(args.info) ) {
-		if (strcasecmp(args.info,"ASTERISK_VERSION_NUM") == 0)
-			response_char = STRING_IT(ASTERISK_VERSION_NUM);
-		else if (strcasecmp(args.info,"BUILD_USER") == 0)
+		if (!strcasecmp(args.info,"ASTERISK_VERSION_NUM"))
+			response_char = ast_get_version_num();
+		else if (!strcasecmp(args.info,"BUILD_USER"))
 			response_char = BUILD_USER;
-		else if (strcasecmp(args.info,"BUILD_HOSTNAME") == 0)
+		else if (!strcasecmp(args.info,"BUILD_HOSTNAME"))
 			response_char = BUILD_HOSTNAME;
-		else if (strcasecmp(args.info,"BUILD_MACHINE") == 0)
+		else if (!strcasecmp(args.info,"BUILD_MACHINE"))
 			response_char = BUILD_MACHINE;
-		else if (strcasecmp(args.info,"BUILD_KERNEL") == 0)
+		else if (!strcasecmp(args.info,"BUILD_KERNEL"))
 			response_char = BUILD_KERNEL;
-		else if (strcasecmp(args.info,"BUILD_OS") == 0)
+		else if (!strcasecmp(args.info,"BUILD_OS"))
 			response_char = BUILD_OS;
-		else if (strcasecmp(args.info,"BUILD_DATE") == 0)
+		else if (!strcasecmp(args.info,"BUILD_DATE"))
 			response_char = BUILD_DATE;
-
 	}
 
+	ast_debug(1, "VERSION returns %s result, given %s argument\n", response_char, args.info);
 
-	ast_debug(1, "VERSION returns %s result, given %s argument\n", response_char, args.info);
 	snprintf(buffer, buflen, "%s", response_char);
 
 	return 0;

Propchange: trunk/include/asterisk/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Sat Jan  5 16:09:06 2008
@@ -1,4 +1,3 @@
 build.h
-version.h
 buildopts.h
 autoconfig.h

Added: trunk/include/asterisk/version.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/version.h?view=auto&rev=96717
==============================================================================
--- trunk/include/asterisk/version.h (added)
+++ trunk/include/asterisk/version.h Sat Jan  5 16:09:06 2008
@@ -1,0 +1,44 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2008, Digium, Inc.
+ *
+ * Russell Bryant <russell at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*!
+ * \file
+ * \brief Asterisk version information
+ * \author Russell Bryant <russell at digium.com>
+ */
+
+#ifndef __AST_VERSION_H
+#define __AST_VERSION_H
+
+/*!
+ * \brief Retrieve the Asterisk version string.
+ */
+const char *ast_get_version(void);
+
+/*!
+ * \brief Retrieve the numeric Asterisk version
+ *
+ * Format ABBCC
+ * AABB - Major version (1.4 would be 104)
+ * CC - Minor version
+ *
+ * 1.4.17 would be 10417.
+ */
+const char *ast_get_version_num(void);
+
+#endif /* __AST_VERSION_H */

Propchange: trunk/include/asterisk/version.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/include/asterisk/version.h
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: trunk/include/asterisk/version.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Propchange: trunk/main/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Sat Jan  5 16:09:06 2008
@@ -2,3 +2,4 @@
 *.s
 asterisk
 *.d
+version.c

Modified: trunk/main/Makefile
URL: http://svn.digium.com/view/asterisk/trunk/main/Makefile?view=diff&rev=96717&r1=96716&r2=96717
==============================================================================
--- trunk/main/Makefile (original)
+++ trunk/main/Makefile Sat Jan  5 16:09:06 2008
@@ -29,7 +29,7 @@
 	netsock.o slinfactory.o ast_expr2.o ast_expr2f.o \
 	cryptostub.o sha1.o http.o fixedjitterbuf.o abstract_jb.o \
 	strcompat.o threadstorage.o dial.o event.o adsistub.o audiohook.o \
-	astobj2.o hashtab.o global_datastores.o $(RESAMPLE_OBJS)
+	astobj2.o hashtab.o global_datastores.o $(RESAMPLE_OBJS) version.o
 
 # we need to link in the objects statically, not as a library, because
 # otherwise modules will not have them available if none of the static

Modified: trunk/main/asterisk.c
URL: http://svn.digium.com/view/asterisk/trunk/main/asterisk.c?view=diff&rev=96717&r1=96716&r2=96717
==============================================================================
--- trunk/main/asterisk.c (original)
+++ trunk/main/asterisk.c Sat Jan  5 16:09:06 2008
@@ -135,7 +135,7 @@
 
 /*! \brief Welcome message when starting a CLI interface */
 #define WELCOME_MESSAGE \
-    ast_verbose("Asterisk " ASTERISK_VERSION ", Copyright (C) 1999 - 2007 Digium, Inc. and others.\n" \
+    ast_verbose("Asterisk %s, Copyright (C) 1999 - 2007 Digium, Inc. and others.\n" \
                 "Created by Mark Spencer <markster at digium.com>\n" \
                 "Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.\n" \
                 "This is free software, with components licensed under the GNU General Public\n" \
@@ -143,7 +143,7 @@
                 "certain conditions. Type 'core show license' for details.\n" \
                 "=========================================================================\n" \
                 "NOTE: This is a development version of Asterisk, and should not be used in\n" \
-                "production installations.\n");
+                "production installations.\n", ast_get_version());
 
 /*! \defgroup main_options Main Configuration Options
  * \brief Main configuration options from asterisk.conf or OS command line on starting Asterisk.
@@ -394,7 +394,7 @@
 
 	ast_cli(a->fd, "\nPBX Core settings\n");
 	ast_cli(a->fd, "-----------------\n");
-	ast_cli(a->fd, "  Version:                     %s\n", "" ASTERISK_VERSION "" );
+	ast_cli(a->fd, "  Version:                     %s\n", ast_get_version());
 	if (option_maxcalls)
 		ast_cli(a->fd, "  Max. calls:                  %d (Current %d)\n", option_maxcalls, ast_active_channels());
 	else
@@ -980,7 +980,7 @@
 	
 	if (gethostname(hostname, sizeof(hostname)-1))
 		ast_copy_string(hostname, "<Unknown>", sizeof(hostname));
-	snprintf(tmp, sizeof(tmp), "%s/%ld/%s\n", hostname, (long)ast_mainpid, ASTERISK_VERSION);
+	snprintf(tmp, sizeof(tmp), "%s/%ld/%s\n", hostname, (long)ast_mainpid, ast_get_version());
 	fdprint(con->fd, tmp);
 	for (;;) {
 		fds[0].fd = con->fd;
@@ -1515,7 +1515,7 @@
 	if (a->argc != 3)
 		return CLI_SHOWUSAGE;
 	ast_cli(a->fd, "Asterisk %s built by %s @ %s on a %s running %s on %s\n",
-		ASTERISK_VERSION, ast_build_user, ast_build_hostname,
+		ast_get_version(), ast_build_user, ast_build_hostname,
 		ast_build_machine, ast_build_os, ast_build_date);
 	return CLI_SUCCESS;
 }
@@ -2387,12 +2387,12 @@
 
 static int show_version(void)
 {
-	printf("Asterisk " ASTERISK_VERSION "\n");
+	printf("Asterisk %s\n", ast_get_version());
 	return 0;
 }
 
 static int show_cli_help(void) {
-	printf("Asterisk " ASTERISK_VERSION ", Copyright (C) 1999 - 2007, Digium, Inc. and others.\n");
+	printf("Asterisk %s, Copyright (C) 1999 - 2007, Digium, Inc. and others.\n", ast_get_version());
 	printf("Usage: asterisk [OPTIONS]\n");
 	printf("Valid Options:\n");
 	printf("   -V              Display version number and exit\n");

Modified: trunk/main/http.c
URL: http://svn.digium.com/view/asterisk/trunk/main/http.c?view=diff&rev=96717&r1=96716&r2=96717
==============================================================================
--- trunk/main/http.c (original)
+++ trunk/main/http.c Sat Jan  5 16:09:06 2008
@@ -186,7 +186,7 @@
 		"Cache-Control: no-cache, no-store\r\n"
 		"Content-Length: %d\r\n"
 		"Content-type: %s\r\n\r\n",
-		ASTERISK_VERSION, buf, (int) st.st_size, mtype);
+		ast_get_version(), buf, (int) st.st_size, mtype);
 
 	while ((len = read(fd, buf, sizeof(buf))) > 0)
 		fwrite(buf, 1, len, ser->f);
@@ -847,7 +847,7 @@
 				"Date: %s\r\n"
 				"Connection: close\r\n"
 				"%s",
-			status, title ? title : "OK", ASTERISK_VERSION, timebuf,
+			status, title ? title : "OK", ast_get_version(), timebuf,
 			static_content ? "" : "Cache-Control: no-cache, no-store\r\n");
 		if (!contentlength) {	/* opaque body ? just dump it hoping it is properly formatted */
 			fprintf(ser->f, "%s", out->str);

Modified: trunk/main/manager.c
URL: http://svn.digium.com/view/asterisk/trunk/main/manager.c?view=diff&rev=96717&r1=96716&r2=96717
==============================================================================
--- trunk/main/manager.c (original)
+++ trunk/main/manager.c Sat Jan  5 16:09:06 2008
@@ -2222,7 +2222,7 @@
 			,
 		        idText,
 			AMI_VERSION,
-			ASTERISK_VERSION, 
+			ast_get_version(), 
 			ast_config_AST_SYSTEM_NAME,
 			option_maxcalls,
 			option_maxload,

Modified: trunk/res/res_agi.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_agi.c?view=diff&rev=96717&r1=96716&r2=96717
==============================================================================
--- trunk/res/res_agi.c (original)
+++ trunk/res/res_agi.c Sat Jan  5 16:09:06 2008
@@ -744,7 +744,7 @@
 	ast_agi_fdprintf(chan, fd, "agi_language: %s\n", chan->language);
 	ast_agi_fdprintf(chan, fd, "agi_type: %s\n", chan->tech->type);
 	ast_agi_fdprintf(chan, fd, "agi_uniqueid: %s\n", chan->uniqueid);
-	ast_agi_fdprintf(chan, fd, "agi_version: %s\n", ASTERISK_VERSION);
+	ast_agi_fdprintf(chan, fd, "agi_version: %s\n", ast_get_version());
 
 	/* ANI/DNIS */
 	ast_agi_fdprintf(chan, fd, "agi_callerid: %s\n", S_OR(chan->cid.cid_num, "unknown"));




More information about the asterisk-commits mailing list