Commit 7a7ffa73 authored by Adam Wujek's avatar Adam Wujek 💬

Merge branch 'adam-version'

Add version to libraries and programs.
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parents 065ab2cf 9b5ff175
...@@ -16,8 +16,12 @@ LIB = libfmctdc.a ...@@ -16,8 +16,12 @@ LIB = libfmctdc.a
LOBJ := fmctdc-lib.o LOBJ := fmctdc-lib.o
LOBJ += fmctdc-lib-math.o LOBJ += fmctdc-lib-math.o
CFLAGS = -Wall -ggdb -O2 -I../kernel -I$(ZIO_ABS)/include $(EXTRACFLAGS) GIT_VERSION := $(shell git describe --dirty --long --tags)
ZIO_GIT_VERSION := $(shell cd $(ZIO_ABS); git describe --dirty --long --tags)
CFLAGS = -Wall -ggdb -O2 -I../kernel -I$(ZIO_ABS)/include $(EXTRACFLAGS)
CFLAGS += -DGIT_VERSION="\"$(GIT_VERSION)\""
CFLAGS += -DZIO_GIT_VERSION="\"$(ZIO_GIT_VERSION)\""
DESTDIR ?= /usr/local DESTDIR ?= /usr/local
modules all: lib modules all: lib
......
...@@ -30,6 +30,9 @@ ...@@ -30,6 +30,9 @@
#include "fmctdc-lib.h" #include "fmctdc-lib.h"
#include "fmctdc-lib-private.h" #include "fmctdc-lib-private.h"
const char * const libfmctdc_version_s = "libfmctdc version: " GIT_VERSION;
const char * const libfmctdc_zio_version_s = "libfmctdc is using zio version: " ZIO_GIT_VERSION;
#define NSAMPLE 1 /* fake number of samples for the TDC */ #define NSAMPLE 1 /* fake number of samples for the TDC */
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
......
...@@ -175,4 +175,14 @@ extern void ft_ts_add(struct fmctdc_time *a, struct fmctdc_time *b); ...@@ -175,4 +175,14 @@ extern void ft_ts_add(struct fmctdc_time *a, struct fmctdc_time *b);
extern int _fmctdc_tscmp(struct fmctdc_time *a, struct fmctdc_time *b); extern int _fmctdc_tscmp(struct fmctdc_time *a, struct fmctdc_time *b);
/**@}*/ /**@}*/
/**
* libfmctdc version string
*/
extern const char * const libfmctdc_version_s;
/**
* zio version string used during compilation of libfmctdc
*/
extern const char * const libfmctdc_zio_version_s;
#endif /* __FMCTDC_LIB_H__ */ #endif /* __FMCTDC_LIB_H__ */
...@@ -17,6 +17,8 @@ TESTS = fmc-tdc-list \ ...@@ -17,6 +17,8 @@ TESTS = fmc-tdc-list \
fmc-tdc-tstamp fmc-tdc-tstamp
CFLAGS = -I. -I$(LIBTDC) -I../kernel -Wall $(EXTRACFLAGS) CFLAGS = -I. -I$(LIBTDC) -I../kernel -Wall $(EXTRACFLAGS)
GIT_VERSION := $(shell git describe --dirty --long --tags)
CFLAGS += -DGIT_VERSION="\"$(GIT_VERSION)\""
COMMON_SRCS = test-common.c COMMON_SRCS = test-common.c
LDFLAGS = -L$(LIBTDC) LDFLAGS = -L$(LIBTDC)
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include "test-common.h" #include "test-common.h"
char git_version[] = "git version: " GIT_VERSION;
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int i; int i;
...@@ -21,7 +23,7 @@ int main(int argc, char **argv) ...@@ -21,7 +23,7 @@ int main(int argc, char **argv)
init(argc, argv); init(argc, argv);
check_help(argc, argv, 1, check_help(argc, argv, 1,
"[-h]", "lists all installed fmc-tdc boards.", ""); "[-h] [-V]", "lists all installed fmc-tdc boards.", "");
printf("Found %i board(s): \n", n_boards); printf("Found %i board(s): \n", n_boards);
......
...@@ -13,12 +13,14 @@ ...@@ -13,12 +13,14 @@
#include "test-common.h" #include "test-common.h"
char git_version[] = "git version: " GIT_VERSION;
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
init(argc, argv); init(argc, argv);
check_help(argc, argv, 2, check_help(argc, argv, 2,
"[-h] <device>", "[-h] [-V] <device>",
"Displays current temperature of the mezzanine.\n", ""); "Displays current temperature of the mezzanine.\n", "");
open_board(argv[1]); open_board(argv[1]);
......
...@@ -13,12 +13,14 @@ ...@@ -13,12 +13,14 @@
#include "test-common.h" #include "test-common.h"
char git_version[] = "git version: " GIT_VERSION;
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
init(argc, argv); init(argc, argv);
check_help(argc, argv, 2, check_help(argc, argv, 2,
"[-h] <device> <channel> [on/off]", "[-h] [-V] <device> <channel> [on/off]",
"Enables or disables the 50 Ohm termination of a given input channel.\n" "Enables or disables the 50 Ohm termination of a given input channel.\n"
"No on/off command returns the current state of termination resistor.", "No on/off command returns the current state of termination resistor.",
"");; "");;
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
#include "test-common.h" #include "test-common.h"
char git_version[] = "git version: " GIT_VERSION;
void perror_hint ( const char *func ) void perror_hint ( const char *func )
{ {
perror(func); perror(func);
...@@ -27,7 +29,7 @@ int main(int argc, char **argv) ...@@ -27,7 +29,7 @@ int main(int argc, char **argv)
init(argc, argv); init(argc, argv);
check_help(argc, argv, 3, check_help(argc, argv, 3,
"[-h] <device> <command> [timeval]", "[-h] [-V] <device> <command> [timeval]",
"Gets/sets the mezzanine TAI time and controls White Rabbit timing.", "Gets/sets the mezzanine TAI time and controls White Rabbit timing.",
"Commands are:\n" "Commands are:\n"
" get - shows current time and White Rabbit status.\n" " get - shows current time and White Rabbit status.\n"
......
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
#include "fmctdc-lib.h" #include "fmctdc-lib.h"
char git_version[] = "git_version: " GIT_VERSION;
/* Previous time stamp for each channel */ /* Previous time stamp for each channel */
struct fmctdc_time ts_prev[FMCTDC_NUM_CHANNELS]; struct fmctdc_time ts_prev[FMCTDC_NUM_CHANNELS];
static unsigned int stop = 0, fmt_wr = 0; static unsigned int stop = 0, fmt_wr = 0;
...@@ -83,6 +85,15 @@ void dump(unsigned int ch, struct fmctdc_time *ts, int diff_mode) ...@@ -83,6 +85,15 @@ void dump(unsigned int ch, struct fmctdc_time *ts, int diff_mode)
fprintf(stdout, " [%f Hz]\n", hz); fprintf(stdout, " [%f Hz]\n", hz);
} }
/* We could use print_version from test-common.c, but to avoid creating
* dependencies use local copy */
static void print_version(char *pname)
{
printf("%s %s\n", pname, git_version);
printf("%s\n", libfmctdc_version_s);
printf("%s\n", libfmctdc_zio_version_s);
}
/* Print help message */ /* Print help message */
static void help(char *name) static void help(char *name)
{ {
...@@ -101,6 +112,7 @@ static void help(char *name) ...@@ -101,6 +112,7 @@ static void help(char *name)
fprintf(stderr, " -l: maximum buffer lenght\n"); fprintf(stderr, " -l: maximum buffer lenght\n");
fprintf(stderr, " -L:\tkeep reading from the last hardware timestamp instead than from the proper buffer\n"); fprintf(stderr, " -L:\tkeep reading from the last hardware timestamp instead than from the proper buffer\n");
fprintf(stderr, " -h: print this message\n\n"); fprintf(stderr, " -h: print this message\n\n");
fprintf(stderr, " -V: print version info\n\n");
fprintf(stderr, " channels enumerations go from %d to %d \n\n", fprintf(stderr, " channels enumerations go from %d to %d \n\n",
FMCTDC_CH_1, FMCTDC_CH_LAST); FMCTDC_CH_1, FMCTDC_CH_LAST);
} }
...@@ -151,13 +163,16 @@ int main(int argc, char **argv) ...@@ -151,13 +163,16 @@ int main(int argc, char **argv)
ref[i] = -1; ref[i] = -1;
/* Parse Options */ /* Parse Options */
while ((opt = getopt(argc, argv, "hwns:d:frm:l:Lc:")) != -1) { while ((opt = getopt(argc, argv, "hwns:d:frm:l:Lc:V")) != -1) {
switch (opt) { switch (opt) {
case 'h': case 'h':
case '?': case '?':
help(argv[0]); help(argv[0]);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
break; break;
case 'V':
print_version(argv[0]);
exit(EXIT_SUCCESS);
case 'f': case 'f':
flush = 1; flush = 1;
break; break;
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "test-common.h" #include "test-common.h"
extern char git_version[];
int n_boards; int n_boards;
struct fmctdc_board *brd = NULL; struct fmctdc_board *brd = NULL;
...@@ -39,6 +40,13 @@ void open_board(char *dev_id_str) ...@@ -39,6 +40,13 @@ void open_board(char *dev_id_str)
} }
} }
static void print_version(char *pname)
{
printf("%s %s\n", pname, git_version);
printf("%s\n", libfmctdc_version_s);
printf("%s\n", libfmctdc_zio_version_s);
}
void check_help(int argc, char **argv, int min_args, char *usage, char *desc, void check_help(int argc, char **argv, int min_args, char *usage, char *desc,
char *options) char *options)
{ {
...@@ -47,6 +55,9 @@ void check_help(int argc, char **argv, int min_args, char *usage, char *desc, ...@@ -47,6 +55,9 @@ void check_help(int argc, char **argv, int min_args, char *usage, char *desc,
printf("usage: %s %s\n", argv[0], usage); printf("usage: %s %s\n", argv[0], usage);
printf("%s\n", options); printf("%s\n", options);
exit(0); exit(0);
} else if ((argc >= 2) && (!strcmp(argv[1], "-V"))) {
print_version(argv[0]);
exit(0);
} else if (argc < min_args) { } else if (argc < min_args) {
printf("usage: %s %s\n", argv[0], usage); printf("usage: %s %s\n", argv[0], usage);
exit(0); exit(0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment