From 82d1041ab2c465c4f465cef882c151ababa1a5ef Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Tue, 12 Apr 2011 23:28:18 +0200 Subject: [PATCH] [Client] Print version info with -V --- owlps-client/Makefile | 8 +++++++- owlps-client/Makefile_atheros | 6 ++++++ owlps-client/Makefile_atheros_openwrt-10.03 | 6 ++++++ owlps-client/owlps-client.c | 21 ++++++++++++++++++++- 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/owlps-client/Makefile b/owlps-client/Makefile index 92578b6..dd00660 100644 --- a/owlps-client/Makefile +++ b/owlps-client/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)/bin @@ -27,6 +32,7 @@ CFLAGS = -O2 -Wall -Wextra -Wstrict-prototypes \ DEPFLAGS = -MMD XCFLAGS = $(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) PICFLAG = -fPIC +OWLPSFLAGS = -D OWLPS_VERSION=\"$(OWLPS_VERSION)\" LIBS = -L$(LIBOWLPS_DIR) -lowlps -L$(LIBOWLPSCLIENT_DIR) -lowlps-client STATIC_LIBS = -liw -lm -lrt @@ -42,7 +48,7 @@ all : dynamic static % : %.o $(CC) $(LDFLAGS) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS) %.o : %.c $(HEADER) - $(CC) $(XCFLAGS) -c $< + $(CC) $(XCFLAGS) $(OWLPSFLAGS) -c $< # Compilation du programme $(TARGET) : $(TARGET).o $(HEADER) diff --git a/owlps-client/Makefile_atheros b/owlps-client/Makefile_atheros index feeaeeb..8cb08e9 100644 --- a/owlps-client/Makefile_atheros +++ b/owlps-client/Makefile_atheros @@ -1,3 +1,8 @@ +# Source version +ifndef OWLPS_VERSION + OWLPS_VERSION = $$(git describe || echo 'UNKNOWN_VERSION') +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 @@ -40,6 +45,7 @@ STATIC_LIBS = $(LOWLPSA) $(LIBS) LATHEROS = -L$(TOOLCHAIN_USR)/lib -L$(TOOLCHAIN_USR_2)/lib IATHEROS = -I$(TOOLCHAIN_USR)/include -I$(TOOLCHAIN_USR_2)/include LDFLAGS = $(IATHEROS) $(LATHEROS) +OWLPSFLAGS = -D OWLPS_VERSION=\"$(OWLPS_VERSION)\" ## Cibles de compilation standard ## diff --git a/owlps-client/Makefile_atheros_openwrt-10.03 b/owlps-client/Makefile_atheros_openwrt-10.03 index 69cabdc..9b57248 100644 --- a/owlps-client/Makefile_atheros_openwrt-10.03 +++ b/owlps-client/Makefile_atheros_openwrt-10.03 @@ -1,3 +1,8 @@ +# Source version +ifndef OWLPS_VERSION + OWLPS_VERSION = $$(git describe || echo 'UNKNOWN_VERSION') +endif + # Emplacement de la suite de cross-compilation TOOLCHAIN_PREFIX = $$HOME/openwrt/atheros/10.03 TOOLCHAIN_BIN = $(TOOLCHAIN_PREFIX)/staging_dir/toolchain-mips_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/bin @@ -40,6 +45,7 @@ STATIC_LIBS = $(LOWLPSA) $(LIBS) LATHEROS = -L$(TOOLCHAIN_USR)/lib -L$(TOOLCHAIN_USR_2)/lib IATHEROS = -I$(TOOLCHAIN_USR)/include -I$(TOOLCHAIN_USR_2)/include LDFLAGS = $(IATHEROS) $(LATHEROS) +OWLPSFLAGS = -D OWLPS_VERSION=\"$(OWLPS_VERSION)\" ## Cibles de compilation standard ## diff --git a/owlps-client/owlps-client.c b/owlps-client/owlps-client.c index 3b6c224..f9d7c2e 100644 --- a/owlps-client/owlps-client.c +++ b/owlps-client/owlps-client.c @@ -26,7 +26,7 @@ #define DEFAULT_DELAY_NORMAL 25000 // Localisation request /* Program arguments (getopt string) */ -#define OPTIONS "d:hi:l::n:p:t:" +#define OPTIONS "d:hi:l::n:p:t:V" /* Function headers */ @@ -43,6 +43,7 @@ void make_packet(void) ; void send_request(void) ; void receive_position(void) ; void print_usage(void) ; +void print_version(void) ; /* Options */ @@ -162,6 +163,9 @@ void parse_main_options(int argc, char **argv) case 't' : options.delay = strtol(optarg, NULL, 0) ; break ; + case 'V' : + print_version() ; + exit(0) ; default : print_usage() ; exit(ERR_BAD_USAGE) ; @@ -408,6 +412,7 @@ void print_usage() "\n" "Options:\n" "\t-h\t\tPrint this help.\n" + "\t-V\t\tPrint version information.\n" "\t-d dest_ip\tDestination IP address of the localisation request.\n" "\t-p dest_port\tDestination port of the localisation request" " (default: %d).\n" @@ -434,3 +439,17 @@ void print_usage() MOBILE_DEFAULT_PORT ) ; } + + +void print_version() +{ + printf("This is OwlPS Client, part of the Open Wireless" + " Positioning System project.\n" + "Version: %s.\n", +#ifdef OWLPS_VERSION + OWLPS_VERSION +#else // OWLPS_VERSION + "unknown version" +#endif // OWLPS_VERSION + ) ; +}