From c23bddffae792a52380bfaa23da2d316721b7057 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Tue, 12 Apr 2011 22:03:08 +0200 Subject: [PATCH] [Listener] print_version(): print version number Use git describe to generate a version label. One can also specify a label: make OWLPS_VERSION=v3.14alpha --- owlps-listener/Makefile | 8 +++++++- owlps-listener/Makefile_atheros | 8 +++++++- owlps-listener/owlps-listenerd.c | 12 +++++++++--- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/owlps-listener/Makefile b/owlps-listener/Makefile index 5d536c7..fd217dd 100644 --- a/owlps-listener/Makefile +++ b/owlps-listener/Makefile @@ -1,3 +1,8 @@ +# Source version +ifndef OWLPS_VERSION + OWLPS_VERSION = $$(git describe || echo 'UNKNOWN_VERSION') +endif + # RĂ©pertoire d'installation PREFIX=/usr/local INSTALL_DIR= $(PREFIX)/sbin @@ -27,7 +32,8 @@ CFLAGS = -O2 -Wall -Wextra -Wstrict-prototypes \ DEPFLAGS = -MMD XCFLAGS = $(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) PICFLAG = -fPIC -OWLPSFLAGS = -D USE_CONFIG_FILE -lconfuse -D USE_PTHREAD -pthread +OWLPSFLAGS = -D OWLPS_VERSION=\"$(OWLPS_VERSION)\" \ + -D USE_CONFIG_FILE -lconfuse -D USE_PTHREAD -pthread LIBS = -L$(LIBOWLPS_DIR) -lowlps \ -L$(LIBOWLPSCLIENT_DIR) -lowlps-client \ -lpcap diff --git a/owlps-listener/Makefile_atheros b/owlps-listener/Makefile_atheros index 02ca335..2604b04 100644 --- a/owlps-listener/Makefile_atheros +++ b/owlps-listener/Makefile_atheros @@ -1,3 +1,8 @@ +# Source version +ifndef OWLPS_VERSION + OWLPS_VERSION = $$(git describe) +endif + # Emplacement de la suite de cross-compilation TOOLCHAIN_PREFIX = $$HOME/openwrt/atheros/8.09 TOOLCHAIN_BIN = $(TOOLCHAIN_PREFIX)/staging_dir/toolchain-mips_gcc4.1.2/bin @@ -36,7 +41,8 @@ LOWLPSCLIENTA = $(LIBOWLPSCLIENT_DIR)/libowlps-client.a LIBS = -lpcap -liw -lm $(LOWLPSCLIENTA) LATHEROS = -L$(TOOLCHAIN_USR)/lib -L$(TOOLCHAIN_USR_2)/lib IATHEROS = -I$(TOOLCHAIN_USR)/include -I$(TOOLCHAIN_USR_2)/include -OWLPSFLAGS = -D USE_PTHREAD -pthread +OWLPSFLAGS = -D OWLPS_VERSION=\"$(OWLPS_VERSION)\" \ + -D USE_PTHREAD -pthread #OWLPSFLAGS += -D USE_CONFIG_FILE -lconfuse LDFLAGS = $(OWLPSFLAGS) $(LIBS) diff --git a/owlps-listener/owlps-listenerd.c b/owlps-listener/owlps-listenerd.c index 186de37..812ecc1 100644 --- a/owlps-listener/owlps-listenerd.c +++ b/owlps-listener/owlps-listenerd.c @@ -1346,7 +1346,7 @@ void print_usage() "Main options:\n" "\t-h\t\tPrint this help.\n" - "\t-V\t\tShow version.\n" + "\t-V\t\tShow version information.\n" "\t-f config_file\tUse 'config_file' instead of the default" " configuration file (%s). Available only if program was" " compiled with libconfuse.\n" @@ -1411,12 +1411,18 @@ void print_usage() void print_version() { - printf("This is OWLPS Listener, part of the Open Wireless Positioning" + printf("This is OwlPS Listener, part of the Open Wireless Positioning" " System project.\n" - "\n" + "Version: %s.\n" "Compilation-time options:\n" "\tSupport for POSIX threads: %s.\n" "\tSupport for configuration file (libconfuse): %s.\n", +#ifdef OWLPS_VERSION + OWLPS_VERSION +#else // OWLPS_VERSION + "unknown version" +#endif // OWLPS_VERSION + , #ifdef USE_PTHREAD "YES" #else // USE_PTHREAD