dect
/
asterisk
Archived
13
0
Fork 0

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.


git-svn-id: http://svn.digium.com/svn/asterisk/trunk@96717 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
russell 2008-01-05 22:09:06 +00:00
parent 080a06a473
commit ab908a2a8b
11 changed files with 108 additions and 52 deletions

View File

@ -372,7 +372,7 @@ makeopts.embed_rules: menuselect.makeopts
@$(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 @@ defaults.h: makeopts
@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 @@ $(SUBDIRS_DIST_CLEAN):
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 @@ spec:
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 @@ pdf: asterisk.pdf
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

33
build_tools/make_version_c Executable file
View File

@ -0,0 +1,33 @@
#!/bin/sh
if [ ! -f ../.flavor ]; then
EXTRA=""
else
aadkver=`cat ../.version`
aadkflavor=`cat ../.flavor`
EXTRA=" (${aadkflavor} ${aadkver})"
fi
cat << END
/*
* version.c
* Automatically generated
*/
#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

View File

@ -1,17 +0,0 @@
#!/bin/sh
if [ ! -f ../.flavor ]; then
EXTRA=""
else
aadkver=`cat ../.version`
aadkflavor=`cat ../.flavor`
EXTRA=" (${aadkflavor} ${aadkver})"
fi
cat << END
/*
* version.h
* Automatically generated
*/
#define ASTERISK_VERSION "${ASTERISKVERSION}${EXTRA}"
#define ASTERISK_VERSION_NUM ${ASTERISKVERSIONNUM}
END

View File

@ -18371,8 +18371,8 @@ static int reload_config(enum channelreloadreason reason)
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));

View File

@ -34,39 +34,35 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#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);
snprintf(buffer, buflen, "%s", response_char);
return 0;

View File

@ -0,0 +1,44 @@
/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 2008, Digium, Inc.
*
* Russell Bryant <russell@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@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 */

View File

@ -29,7 +29,7 @@ OBJS= io.o sched.o logger.o frame.o loader.o config.o channel.o \
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

View File

@ -135,7 +135,7 @@ int daemon(int, int); /* defined in libresolv of all places */
/*! \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@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 @@ int daemon(int, int); /* defined in libresolv of all places */
"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 @@ static char *handle_show_settings(struct ast_cli_entry *e, int cmd, struct ast_c
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 @@ static void *netconsole(void *vconsole)
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 @@ static char *handle_version(struct ast_cli_entry *e, int cmd, struct ast_cli_arg
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 void ast_remotecontrol(char * data)
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");

View File

@ -186,7 +186,7 @@ static struct ast_str *static_callback(struct server_instance *ser, const char *
"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 @@ static void *httpd_helper_thread(void *data)
"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);

View File

@ -2222,7 +2222,7 @@ static int action_coresettings(struct mansession *s, const struct message *m)
,
idText,
AMI_VERSION,
ASTERISK_VERSION,
ast_get_version(),
ast_config_AST_SYSTEM_NAME,
option_maxcalls,
option_maxload,

View File

@ -744,7 +744,7 @@ static void setup_env(struct ast_channel *chan, char *request, int fd, int enhan
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"));