[Client] Print version info with -V

This commit is contained in:
Matteo Cypriani 2011-04-12 23:28:18 +02:00
parent 7123f02e82
commit 82d1041ab2
4 changed files with 39 additions and 2 deletions

View File

@ -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)

View File

@ -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 ##

View File

@ -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 ##

View File

@ -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
) ;
}