From a05e4467dee55248f2135dcb532b4729154d69c5 Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Sat, 15 Dec 2007 12:03:08 +0000 Subject: [PATCH] include configure and compiler details in version output Organization: Straylight/Edgeware From: Richard Kettlewell --- .bzrignore | 2 ++ clients/disorder.c | 2 +- clients/disorderfm.c | 2 +- clients/playrtp.c | 2 +- disobedience/disobedience.c | 2 +- lib/Makefile.am | 17 +++++++++++++++-- lib/defs.c | 4 +++- lib/defs.h | 1 + scripts/make-version-string | 31 +++++++++++++++++++++++++++++++ scripts/text2c | 7 ++++++- server/dbupgrade.c | 2 +- server/dcgi.c | 2 +- server/deadlock.c | 2 +- server/decode.c | 2 +- server/disorderd.c | 2 +- server/dump.c | 2 +- server/normalize.c | 2 +- server/rescan.c | 2 +- server/server.c | 2 +- server/speaker.c | 2 +- server/stats.c | 2 +- server/trackname.c | 2 +- tests/udplog.c | 2 +- 23 files changed, 75 insertions(+), 21 deletions(-) create mode 100755 scripts/make-version-string diff --git a/.bzrignore b/.bzrignore index e34c30c..0ca950c 100644 --- a/.bzrignore +++ b/.bzrignore @@ -140,3 +140,5 @@ lib/index.html server/index.html .DS_Store tests/disorder-udplog +lib/version-string +lib/version.h diff --git a/clients/disorder.c b/clients/disorder.c index 6278295..7ee9865 100644 --- a/clients/disorder.c +++ b/clients/disorder.c @@ -84,7 +84,7 @@ static void help(void) { /* display version number and terminate */ static void version(void) { - xprintf("disorder version %s\n", disorder_version_string); + xprintf("%s", disorder_version_string); xfclose(stdout); exit(0); } diff --git a/clients/disorderfm.c b/clients/disorderfm.c index ccb2472..d8dffb6 100644 --- a/clients/disorderfm.c +++ b/clients/disorderfm.c @@ -129,7 +129,7 @@ static void help(void) { /* display version number and terminate */ static void version(void) { - xprintf("disorderfm version %s\n", disorder_version_string); + xprintf("%s", disorder_version_string); xfclose(stdout); exit(0); } diff --git a/clients/playrtp.c b/clients/playrtp.c index 54107da..484d265 100644 --- a/clients/playrtp.c +++ b/clients/playrtp.c @@ -533,7 +533,7 @@ static void help(void) { /* display version number and terminate */ static void version(void) { - xprintf("disorder-playrtp version %s\n", disorder_version_string); + xprintf("%s", disorder_version_string); xfclose(stdout); exit(0); } diff --git a/disobedience/disobedience.c b/disobedience/disobedience.c index 5efcc00..de71101 100644 --- a/disobedience/disobedience.c +++ b/disobedience/disobedience.c @@ -409,7 +409,7 @@ static void help(void) { /* display version number and terminate */ static void version(void) { - xprintf("disorder version %s\n", disorder_version_string); + xprintf("%s", disorder_version_string); xfclose(stdout); exit(0); } diff --git a/lib/Makefile.am b/lib/Makefile.am index ab856a7..cf53878 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -71,6 +71,19 @@ libdisorder_a_SOURCES=charset.c charset.h \ wstat.c wstat.h \ disorder.h +version-string: ../config.status ${top_srcdir}/scripts/make-version-string + CC="${CC}" ${top_srcdir}/scripts/make-version-string > $@.new + @if cmp $@.new $@; then \ + echo rm -f $@.new; rm -f $@.new; else \ + echo mv $@.new $@; mv $@.new $@; fi + +version.h: version-string ${top_srcdir}/scripts/text2c + ${top_srcdir}/scripts/text2c -extern disorder_version_string \ + version-string > $@.new + @if cmp $@.new $@; then \ + echo rm -f $@.new; rm -f $@.new; else \ + echo mv $@.new $@; mv $@.new $@; fi + definitions.h: Makefile rm -f $@.new echo "#define PKGLIBDIR \"${pkglibdir}\"" > $@.new @@ -84,8 +97,8 @@ definitions.h: Makefile @if cmp $@.new $@; then \ echo rm -f $@.new; rm -f $@.new; else \ echo mv $@.new $@; mv $@.new $@; fi -defs.o: definitions.h -defs.lo: definitions.h +defs.o: definitions.h version.h +defs.lo: definitions.h version.h test_SOURCES=test.c memgc.c test_LDADD=libdisorder.a $(LIBPCRE) $(LIBICONV) $(LIBGC) diff --git a/lib/defs.c b/lib/defs.c index c9668c0..19987cb 100644 --- a/lib/defs.c +++ b/lib/defs.c @@ -30,7 +30,7 @@ #include "definitions.h" /** @brief Software version number */ -const char disorder_version_string[] = VERSION; +const char disorder_short_version_string[] = VERSION; /** @brief Package library directory */ const char pkglibdir[] = PKGLIBDIR; @@ -59,6 +59,8 @@ const char finkbindir[] = FINKBINDIR; /** @brief Package documentation directory */ const char docdir[] = DOCDIR; +#include "version.h" + /* Local Variables: c-basic-offset:2 diff --git a/lib/defs.h b/lib/defs.h index c340e8e..dd75209 100644 --- a/lib/defs.h +++ b/lib/defs.h @@ -21,6 +21,7 @@ #ifndef DEFS_H #define DEFS_H +extern const char disorder_short_version_string[]; extern const char disorder_version_string[]; extern const char pkglibdir[]; extern const char pkgconfdir[]; diff --git a/scripts/make-version-string b/scripts/make-version-string new file mode 100755 index 0000000..210e84f --- /dev/null +++ b/scripts/make-version-string @@ -0,0 +1,31 @@ +#! /usr/bin/perl -w +use strict; +sub output { + print @_ or die "$0: stdout: $!\n"; +} +my @csv = `../config.status --version`; +my $version; +my $options; +my $cc; +my $compiler; +for(@csv) { + chomp; + if(/disorder config\.status (\S+)/) { + $version = $1; + } + if(/with options \"(.*)\"/) { + $options = $1; + } +} +if(exists $ENV{CC}) { + $cc = $ENV{CC}; + $cc =~ s/\s+/ /g; + my @cv = `$cc --version`; + $compiler = $cv[0]; +} +die "no version found\n" unless defined $version; +output("DisOrder $version\n"); +output(" configure options: $options\n") if defined $options; +output(" compiler: $cc\n") if defined $compiler; +output(" version: $compiler\n") if defined $cc; +close STDOUT or die "$0: stdout: $!\n"; diff --git a/scripts/text2c b/scripts/text2c index 46b2276..95d2181 100755 --- a/scripts/text2c +++ b/scripts/text2c @@ -1,7 +1,12 @@ #! /usr/bin/perl -w +my $class = "static"; +if($ARGV[0] eq '-extern') { + $class = ""; + shift; +} my $name = shift; push(@out, "/* autogenerated file, do not edit */\n\n"); -push(@out, "static const char $name\[] = \n"); +push(@out, "$class const char $name\[] = \n"); while(<>) { next if /arch-tag/; s/[\\\"\?]/\\$&/g; diff --git a/server/dbupgrade.c b/server/dbupgrade.c index b856ae5..b4cf58e 100644 --- a/server/dbupgrade.c +++ b/server/dbupgrade.c @@ -86,7 +86,7 @@ static void help(void) { /* display version number and terminate */ static void version(void) { - xprintf("disorder-dbupgrade version %s\n", disorder_version_string); + xprintf("%s", disorder_version_string); xfclose(stdout); exit(0); } diff --git a/server/dcgi.c b/server/dcgi.c index 07e1825..6e71ef0 100644 --- a/server/dcgi.c +++ b/server/dcgi.c @@ -446,7 +446,7 @@ static void exp_version(int attribute((unused)) nargs, char attribute((unused)) **args, cgi_sink *output, void attribute((unused)) *u) { - cgi_output(output, "%s", disorder_version_string); + cgi_output(output, "%s", disorder_short_version_string); } static void exp_nonce(int attribute((unused)) nargs, diff --git a/server/deadlock.c b/server/deadlock.c index e45694f..bce3eee 100644 --- a/server/deadlock.c +++ b/server/deadlock.c @@ -72,7 +72,7 @@ static void help(void) { /* display version number and terminate */ static void version(void) { - xprintf("disorder-deadlock version %s\n", disorder_version_string); + xprintf("%s", disorder_version_string); xfclose(stdout); exit(0); } diff --git a/server/decode.c b/server/decode.c index 47227a2..639ad15 100644 --- a/server/decode.c +++ b/server/decode.c @@ -440,7 +440,7 @@ static void help(void) { /* Display version number and terminate. */ static void version(void) { - xprintf("disorder-decode version %s\n", disorder_version_string); + xprintf("%s", disorder_version_string); xfclose(stdout); exit(0); } diff --git a/server/disorderd.c b/server/disorderd.c index b8f8010..ba18c23 100644 --- a/server/disorderd.c +++ b/server/disorderd.c @@ -94,7 +94,7 @@ static void help(void) { /* display version number and terminate */ static void version(void) { - xprintf("disorderd version %s\n", disorder_version_string); + xprintf("%s", disorder_version_string); xfclose(stdout); exit(0); } diff --git a/server/dump.c b/server/dump.c index 7e49111..119875f 100644 --- a/server/dump.c +++ b/server/dump.c @@ -82,7 +82,7 @@ static void help(void) { /* display version number and terminate */ static void version(void) { - xprintf("disorder-dump version %s\n", disorder_version_string); + xprintf("%s", disorder_version_string); xfclose(stdout); exit(0); } diff --git a/server/normalize.c b/server/normalize.c index 085d4df..87b0f3d 100644 --- a/server/normalize.c +++ b/server/normalize.c @@ -73,7 +73,7 @@ static void help(void) { /* display version number and terminate */ static void version(void) { - xprintf("disorder-normalize version %s\n", disorder_version_string); + xprintf("%s", disorder_version_string); xfclose(stdout); exit(0); } diff --git a/server/rescan.c b/server/rescan.c index b878929..e45eaa6 100644 --- a/server/rescan.c +++ b/server/rescan.c @@ -84,7 +84,7 @@ static void help(void) { /* display version number and terminate */ static void version(void) { - xprintf("disorder-rescan version %s\n", disorder_version_string); + xprintf("%s", disorder_version_string); xfclose(stdout); exit(0); } diff --git a/server/server.c b/server/server.c index 413b43e..a369964 100644 --- a/server/server.c +++ b/server/server.c @@ -346,7 +346,7 @@ static int c_version(struct conn *c, char attribute((unused)) **vec, int attribute((unused)) nvec) { /* VERSION had better only use the basic character set */ - sink_printf(ev_writer_sink(c->w), "251 %s\n", disorder_version_string); + sink_printf(ev_writer_sink(c->w), "251 %s\n", disorder_short_version_string); return 1; /* completed */ } diff --git a/server/speaker.c b/server/speaker.c index a6c5f43..d21ad7c 100644 --- a/server/speaker.c +++ b/server/speaker.c @@ -142,7 +142,7 @@ static void help(void) { /* Display version number and terminate. */ static void version(void) { - xprintf("disorder-speaker version %s\n", disorder_version_string); + xprintf("%s", disorder_version_string); xfclose(stdout); exit(0); } diff --git a/server/stats.c b/server/stats.c index a12b8f6..c397be8 100644 --- a/server/stats.c +++ b/server/stats.c @@ -65,7 +65,7 @@ static void help(void) { /* display version number and terminate */ static void version(void) { - xprintf("disorder-stats version %s\n", disorder_version_string); + xprintf("%s", disorder_version_string); xfclose(stdout); exit(0); } diff --git a/server/trackname.c b/server/trackname.c index 1e0bb45..b14e9e5 100644 --- a/server/trackname.c +++ b/server/trackname.c @@ -57,7 +57,7 @@ static void help(void) { /* display version number and terminate */ static void version(void) { - xprintf("disorder version %s\n", disorder_version_string); + xprintf("%s", disorder_version_string); xfclose(stdout); exit(0); } diff --git a/tests/udplog.c b/tests/udplog.c index 4d52efc..eb87651 100644 --- a/tests/udplog.c +++ b/tests/udplog.c @@ -61,7 +61,7 @@ static void help(void) { /* display version number and terminate */ static void version(void) { - xprintf("disorder-udplog version %s\n", disorder_version_string); + xprintf("%s", disorder_version_string); xfclose(stdout); exit(0); } -- [mdw]