diff --git a/src/Makefile.in b/src/Makefile.in index 37a8018..e43098f 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -16,9 +16,11 @@ CFGFILE= /opt/aprsc/etc/aprsc.conf # generate version strings VERSION:=$(shell cat VERSION) SVNVERSION:=$(shell if test -x /usr/bin/svnversion -a -d ../.svn ; then /usr/bin/svnversion | sed -e 's/^.*://' | tee SVNVERSION ; else cat SVNVERSION; fi) -DATE:=$(shell date +"%Y %B %d") -RFCDATE:=$(shell date +"%a, %d %b %Y %H:%M:%S %z") +DATE:=$(shell TZ=UTC date +"%Y %B %d") +RFCDATE:=$(shell TZ=UTC date +"%a, %d %b %Y %H:%M:%S %z") +BUILD_TIME:=$(shell TZ=UTC date +"%Y-%m-%d %H:%M:%S %z") LINUXDIST:=$(shell if test -f /etc/lsb-release ; then . /etc/lsb-release && echo "$$DISTRIB_ID-$$DISTRIB_RELEASE-$$DISTRIB_CODENAME"; fi) +BUILD_USER:=$(shell whoami) # -------------------------------------------------------------------- # @@ -101,6 +103,22 @@ testinstall: # -------------------------------------------------------------------- # +.PHONY: version_data.h +version_data.h: + @echo "Generating version_data.h" + @echo "/* generated automatically by Makefile - mark your branch in version_branch.h */" > version_data.h.new + @echo "#ifndef VERSIONDATA_H" >> version_data.h.new + @echo "#define VERSIONDATA_H" >> version_data.h.new + @echo "#define SVNVERSION \"$(SVNVERSION)\"" >> version_data.h.new + @echo "#define BUILD_TIME \"$(BUILD_TIME)\"" >> version_data.h.new + @echo "#define BUILD_USER \"$(BUILD_USER)\"" >> version_data.h.new + @echo "#endif" >> version_data.h.new + @if test ! -f /version_data.h; then cp version_data.h.new version_data.h; fi + @diff -q version_data.h.new version_data.h || mv version_data.h.new version_data.h + @rm -f version_data.h.new + +# -------------------------------------------------------------------- # + OBJS = aprsc.o accept.o worker.o \ login.o incoming.o dupecheck.o outgoing.o \ clientlist.o client_heard.o \ @@ -111,7 +129,7 @@ OBJS = aprsc.o accept.o worker.o \ keyhash.o \ filter.o cellmalloc.o historydb.o \ counterdata.o status.o cJSON.o \ - http.o \ + http.o version.o \ @LIBOBJS@ clean: diff --git a/src/aprsc.c b/src/aprsc.c index ac8c634..79b9157 100644 --- a/src/aprsc.c +++ b/src/aprsc.c @@ -37,6 +37,7 @@ #include "worker.h" #include "status.h" #include "http.h" +#include "version.h" #include "dupecheck.h" #include "filter.h" @@ -116,7 +117,7 @@ void parse_cmdline(int argc, char *argv[]) break; case '?': case 'h': - fprintf(stderr, "%s\n", VERSTR); + fprintf(stderr, "%s\n", verstr); failed = 1; } } diff --git a/src/config.h b/src/config.h index 66ded0d..2da532c 100644 --- a/src/config.h +++ b/src/config.h @@ -12,9 +12,6 @@ #define CONFIG_H #define PROGNAME "aprsc" -#define VERSION "0.5.5" -#define VERSTR PROGNAME " v" VERSION -#define SERVERID PROGNAME " " VERSION #define CRLF "\r\n" #include diff --git a/src/http.c b/src/http.c index d594010..4ea3a90 100644 --- a/src/http.c +++ b/src/http.c @@ -26,6 +26,7 @@ #include "http.h" #include "config.h" +#include "version.h" #include "hlog.h" #include "hmalloc.h" #include "worker.h" diff --git a/src/status.c b/src/status.c index c097ac2..2dd50e8 100644 --- a/src/status.c +++ b/src/status.c @@ -18,6 +18,7 @@ #include "cellmalloc.h" #include "hmalloc.h" #include "config.h" +#include "version.h" #include "hlog.h" #include "worker.h" #include "historydb.h" @@ -90,7 +91,7 @@ char *status_json_string(int no_cache, int periodical) cJSON_AddStringToObject(server, "admin", myadmin); cJSON_AddStringToObject(server, "email", myemail); cJSON_AddStringToObject(server, "software", "aprsc"); - cJSON_AddStringToObject(server, "software_version", VERSION); + cJSON_AddStringToObject(server, "software_version", verstr); cJSON_AddNumberToObject(server, "uptime", tick - startup_tick); cJSON_AddNumberToObject(server, "t_started", startup_tick); cJSON_AddNumberToObject(server, "t_now", tick); diff --git a/src/uplink.c b/src/uplink.c index 6823241..ee5a8f7 100644 --- a/src/uplink.c +++ b/src/uplink.c @@ -28,6 +28,7 @@ #include #include "config.h" +#include "version.h" #include "uplink.h" #include "hmalloc.h" #include "hlog.h" @@ -269,7 +270,7 @@ int uplink_login_handler(struct worker_t *self, struct client_t *c, int l4proto, } // TODO: The uplink login command here could maybe be improved to send a filter command. - len = sprintf(buf, "user %s pass %d vers %s\r\n", c->username, passcode, VERSTR); + len = sprintf(buf, "user %s pass %d vers %s\r\n", c->username, passcode, verstr_aprsis); hlog(LOG_DEBUG, "%s: my login string: \"%.*s\"", c->addr_rem, len-2, buf, len); diff --git a/src/version_branch.h b/src/version_branch.h new file mode 100644 index 0000000..1dff821 --- /dev/null +++ b/src/version_branch.h @@ -0,0 +1,24 @@ + +#ifndef VERSION_BRANCH_H +#define VERSION_BRANCH_H + +/* + * If you're building your own version of aprsc, and have actually + * made modifications in the code, please insert a branch ID here + * so that your variant can be identified. + * + * Examples: + * + * #define VERSION_BRANCH "-mycall-5" + * (for version 5 of modified tree made by MYCALL) + * + * Don't forget to put a - in the beginning, as the string will be + * concated with the version string (aprsc 1.0-725-mycall-5). + * + * Thanks! + */ + +#define VERSION_BRANCH "" + +#endif + diff --git a/src/worker.c b/src/worker.c index 5c2a72c..b3c1ebf 100644 --- a/src/worker.c +++ b/src/worker.c @@ -33,6 +33,7 @@ #include "clientlist.h" #include "client_heard.h" #include "cellmalloc.h" +#include "version.h" time_t now; /* current time, updated by the main thread, MAY be spun around by the simulator */ time_t tick; /* real monotonous clock, may or may not be wallclock */ @@ -1135,7 +1136,7 @@ void collect_new_clients(struct worker_t *self) /* According to http://www.aprs-is.net/ServerDesign.aspx, the server must * initially transmit it's software name and version string. */ - client_printf(self, c, "# " SERVERID "\r\n"); + client_printf(self, c, "# %s\r\n", verstr_aprsis); /* If the write failed immediately, c is already invalid at this point. Don't touch it. */ } @@ -1168,7 +1169,7 @@ void send_keepalives(struct worker_t *self) // Example message: // # javAPRSSrvr 3.12b12 1 Mar 2008 15:11:20 GMT T2FINLAND 85.188.1.32:14580 - sprintf(buf, "# %.40s ",SERVERID); + sprintf(buf, "# %.40s ", verstr_aprsis); s = buf + strlen(buf); memset(&t, 0, sizeof(t));