Commit 7833910c 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 c627379a 5c9176a9
...@@ -27,12 +27,15 @@ OBJDUMP = $(CROSS_COMPILE)objdump ...@@ -27,12 +27,15 @@ OBJDUMP = $(CROSS_COMPILE)objdump
# calculate endianness at compile time # calculate endianness at compile time
ENDIAN := $(shell ./check-endian $(CC)) ENDIAN := $(shell ./check-endian $(CC))
GIT_VERSION := $(shell git describe --dirty --long --tags)
CFLAGS = -Wall -ggdb -O2 CFLAGS = -Wall -ggdb -O2
CFLAGS += -I../kernel/include/linux # for <sdb.h> CFLAGS += -I../kernel/include/linux # for <sdb.h>
CFLAGS += -ffunction-sections -fdata-sections CFLAGS += -ffunction-sections -fdata-sections
CFLAGS += -Wno-pointer-sign CFLAGS += -Wno-pointer-sign
CFLAGS += $(ENDIAN) $(LINUXINCLUDE) CFLAGS += $(ENDIAN) $(LINUXINCLUDE)
CFLAGS += $(EXTRACFLAGS) CFLAGS += $(EXTRACFLAGS)
CFLAGS += -DGIT_VERSION="\"$(GIT_VERSION)\""
LIB = libsdbfs.a LIB = libsdbfs.a
OBJS = glue.o access.o OBJS = glue.o access.o
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "libsdbfs.h" #include "libsdbfs.h"
static struct sdbfs *sdbfs_list; static struct sdbfs *sdbfs_list;
const char * const libsdbfs_version_s = "libsdbfs version: " GIT_VERSION;
/* All fields unused by the caller are expected to be zeroed */ /* All fields unused by the caller are expected to be zeroed */
int sdbfs_dev_create(struct sdbfs *fs, int verbose) int sdbfs_dev_create(struct sdbfs *fs, int verbose)
......
...@@ -78,4 +78,6 @@ static inline uint64_t ntohll(uint64_t ll) ...@@ -78,4 +78,6 @@ static inline uint64_t ntohll(uint64_t ll)
return htonll(ll); return htonll(ll);
} }
extern const char * const libsdbfs_version_s;
#endif /* __LIBSDBFS_H__ */ #endif /* __LIBSDBFS_H__ */
...@@ -8,7 +8,9 @@ ...@@ -8,7 +8,9 @@
REPO_PARENT=../.. REPO_PARENT=../..
-include $(REPO_PARENT)/parent_common.mk -include $(REPO_PARENT)/parent_common.mk
GIT_VERSION := $(shell git describe --dirty --long --tags)
CFLAGS = -Wall -ggdb -O2 -I../kernel/include $(EXTRACFLAGS) CFLAGS = -Wall -ggdb -O2 -I../kernel/include $(EXTRACFLAGS)
CFLAGS += -DGIT_VERSION="\"$(GIT_VERSION)\""
PROGS = fru-dump fmc-mem PROGS = fru-dump fmc-mem
all: $(PROGS) all: $(PROGS)
......
...@@ -17,12 +17,15 @@ ...@@ -17,12 +17,15 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
static char git_version[] = "git version: " GIT_VERSION;
static void help(char *prgname) static void help(char *prgname)
{ {
fprintf(stderr, "%s: use " fprintf(stderr, "%s: use "
"\"%s <device> <addr> [<value>] [+<nbytes>]\"\n" "\"%s -V <device> <addr> [<value>] [+<nbytes>]\"\n"
" <device> is a file name, all others are hex numbers\n" " <device> is a file name, all others are hex numbers\n"
" bursts of \"nbytes\" use stdin/stdout (value ignored)\n", " bursts of \"nbytes\" use stdin/stdout (value ignored)\n"
" -V version\n",
prgname, prgname); prgname, prgname);
exit(1); exit(1);
} }
...@@ -67,6 +70,11 @@ static void r_loop(int fd, char **argv, int nbytes) ...@@ -67,6 +70,11 @@ static void r_loop(int fd, char **argv, int nbytes)
exit(0); exit(0);
} }
static void print_version(char *pname)
{
printf("%s %s\n", pname, git_version);
}
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int fd; int fd;
...@@ -75,6 +83,11 @@ int main(int argc, char **argv) ...@@ -75,6 +83,11 @@ int main(int argc, char **argv)
int dowrite = 0, doloop = 0; int dowrite = 0, doloop = 0;
char c; char c;
if ((argc == 2) && (!strcmp(argv[1], "-V"))) {
print_version(argv[0]);
exit(0);
}
if (argc < 3 || argv[1][0] == '-') /* -h, --help, whatever */ if (argc < 3 || argv[1][0] == '-') /* -h, --help, whatever */
help(argv[0]); help(argv[0]);
......
...@@ -18,11 +18,18 @@ ...@@ -18,11 +18,18 @@
#include "../kernel/fru-parse.c" /* Aaaargh!!!!! horrible hack... */ #include "../kernel/fru-parse.c" /* Aaaargh!!!!! horrible hack... */
static char git_version[] = "git version: " GIT_VERSION;
void *fru_alloc(size_t size) void *fru_alloc(size_t size)
{ {
return malloc(size); return malloc(size);
} }
static void print_version(char *pname)
{
printf("%s %s\n", pname, git_version);
}
#define EEPROM_SIZE 8192 #define EEPROM_SIZE 8192
int main(int argc, char **argv) int main(int argc, char **argv)
...@@ -35,8 +42,13 @@ int main(int argc, char **argv) ...@@ -35,8 +42,13 @@ int main(int argc, char **argv)
FILE *f = NULL; FILE *f = NULL;
int i, err = 0; int i, err = 0;
if ((argc == 2) && (!strcmp(argv[1], "-V"))) {
print_version(argv[0]);
exit(0);
}
if (argc < 2) { if (argc < 2) {
fprintf(stderr, "%s: Use \"%s <fru-image> [...]\"\n", fprintf(stderr, "%s: Use \"%s [-V] <fru-image> [...]\"\n",
argv[0], argv[0]); argv[0], argv[0]);
exit(1); exit(1);
} }
......
...@@ -12,7 +12,9 @@ OBJ=ipmi.o ...@@ -12,7 +12,9 @@ OBJ=ipmi.o
OUT=libipmi.a OUT=libipmi.a
OUT_SO=libipmi.so OUT_SO=libipmi.so
GIT_VERSION := $(shell git describe --dirty --long --tags)
CFLAGS+=-fPIC -shared -Wall -Wextra -ggdb $(EXTRACFLAGS) CFLAGS+=-fPIC -shared -Wall -Wextra -ggdb $(EXTRACFLAGS)
CFLAGS += -DGIT_VERSION="\"$(GIT_VERSION)\""
all: $(OUT) $(OUT_SO) all: $(OUT) $(OUT_SO)
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
const char * const libipmi_version_s = "libipmi version: " GIT_VERSION;
static FILE *f = NULL; static FILE *f = NULL;
struct common_header *ch = NULL; struct common_header *ch = NULL;
......
...@@ -136,4 +136,5 @@ int ipmi_oem_record_write(int); ...@@ -136,4 +136,5 @@ int ipmi_oem_record_write(int);
unsigned char *ipmi_get_internal_use_data(char *data, int *l); unsigned char *ipmi_get_internal_use_data(char *data, int *l);
int ipmi_get_mfg_date(char *data); int ipmi_get_mfg_date(char *data);
extern const char * const libipmi_version_s;
#endif #endif
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