added --version for git releases

This commit is contained in:
Manuel Domke
2018-03-01 21:57:21 +01:00
parent b97c5452bf
commit 7cd47ee970
3 changed files with 22 additions and 1 deletions

View File

@@ -1,6 +1,15 @@
GIT_VERSION := $(shell git --no-pager describe --tags --always)
GIT_COMMIT := $(shell git rev-parse --verify HEAD)
GIT_DATE := $(firstword $(shell git --no-pager show --date=iso-strict --format="%ad" --name-only))
BUILD_DATE := $(shell date --iso=seconds)
PREFIX = $(DESTDIR)/usr/local
CFLAGS = -Wall -Wextra -Werror -std=c99 -O3 -I Keccak -I /usr/include/libftdi1
CFLAGS = -Wall -Wextra -Werror -std=c99 -O3 -I Keccak -I /usr/include/libftdi1 \
-DGIT_VERSION=\"$(GIT_VERSION)\"\
-DGIT_COMMIT=\"$(GIT_COMMIT)\"\
-DGIT_DATE=\"$(GIT_DATE)\"\
-DBUILD_DATE=\"$(BUILD_DATE)\"
FOUND = $(shell ldconfig -p | grep --silent libftdi.so && echo found)
ifeq ($(FOUND), found)

View File

@@ -299,6 +299,8 @@ int main(int argc, char **argv)
opts.daemon = true;
} else if(!strcmp(argv[xArg], "--list-devices")) {
opts.listDevices = true;
} else if(!strcmp(argv[xArg], "--version")) {
opts.version = true;
} else if(!strcmp(argv[xArg], "--help") || !strcmp(argv[xArg], "-h")) {
opts.help = true;
} else {
@@ -320,6 +322,7 @@ int main(int argc, char **argv)
" --daemon - run in the background\n"
" --serial <serial> - use specified device\n"
" --list-devices - list available devices\n"
" --version - show version information\n"
" --help - this help output\n", stdout);
if (opts.none) {
return 1;
@@ -360,6 +363,14 @@ int main(int argc, char **argv)
opts.outputMultiplier = 2u; // Don't throw away entropy when writing to /dev/random unless told to do so
}
if (opts.version) {
printf("GIT VERSION - %s\n", GIT_VERSION);
printf("GIT COMMIT - %s\n", GIT_COMMIT);
printf("GIT DATE - %s\n", GIT_DATE);
printf("BUILD DATE - %s\n", BUILD_DATE);
return 0;
}
if (opts.listDevices) {
listUSBDevices(&ftdic);
return 0;

View File

@@ -41,6 +41,7 @@ struct opt_struct {
bool help; // Show help
bool none; // set to true when no valid arguments where detected
bool raw; // No whitening?
bool version; // Show version
char *pidFileName; // Name of optional PID-file
char *serial; // Name of selected device
};