Merge pull request #23 from weetmuts/master

Add version number based on git tag and -V to print version number.
pull/33/head
Xael South 2021-05-06 11:43:34 +02:00 zatwierdzone przez GitHub
commit a07541f904
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 52 dodań i 7 usunięć

Wyświetl plik

@ -10,15 +10,49 @@ CFLAGS_WARNINGS?=-Wall -W -Waggregate-return -Wbad-function-cast -Wcast-align -W
LIB?=-lm
SRC=rtl_wmbus.c
all: $(OUTDIR) release
$(shell $(MKDIR) -p $(OUTDIR))
$(OUTDIR):
$(MKDIR) -p "$(OUTDIR)"
# Create a version number based on the latest git tag.
COMMIT_HASH?=$(shell git log --pretty=format:'%H' -n 1)
TAG?=$(shell git describe --tags)
BRANCH?=$(shell git rev-parse --abbrev-ref HEAD)
CHANGES?=$(shell git status -s | grep -v '?? ')
release: $(OUTDIR)
# Prefix with any development branch.
ifeq ($(BRANCH),master)
BRANCH:=
else
BRANCH:=$(BRANCH)_
endif
# The version is the git tag or tag-N-hash if there are N commits after the tag.
VERSION:=$(BRANCH)$(TAG)
ifneq ($(strip $(CHANGES)),)
# There are local non-committed changes! Add this to the version string as well!
VERSION:=$(VERSION) with local changes
COMMIT_HASH:=$(COMMIT_HASH) with local changes
endif
$(shell echo "#define VERSION \"$(VERSION)\"" > $(OUTDIR)/version.h.tmp)
$(shell echo "#define COMMIT \"$(COMMIT_HASH)\"" >> $(OUTDIR)/version.h.tmp)
PREV_VERSION=$(shell cat -n $(OUTDIR)/version.h 2> /dev/null)
CURR_VERSION=$(shell cat -n $(OUTDIR)/version.h.tmp 2>/dev/null)
ifneq ($(PREV_VERSION),$(CURR_VERSION))
$(shell mv $(OUTDIR)/version.h.tmp $(OUTDIR)/version.h)
else
$(shell rm $(OUTDIR)/version.h.tmp)
endif
$(info Building $(VERSION))
all: release
release:
$(CC) -DNDEBUG -O3 $(CFLAGS) $(CFLAGS_WARNINGS) -o $(OUTFILE) $(SRC) $(LIB)
debug: $(OUTDIR)
debug:
$(CC) -DDEBUG -O0 -g3 -ggdb -p -pg $(CFLAGS) $(CFLAGS_WARNINGS) -o $(OUTFILE) $(SRC) $(LIB)
# Will build on Raspberry Pi 1 only

Wyświetl plik

@ -33,6 +33,7 @@
#include <errno.h>
#include <fcntl.h>
#include <fixedptc/fixedptc.h>
#include "build/version.h"
#include "fir.h"
#include "iir.h"
#include "ppf.h"
@ -796,21 +797,28 @@ static const unsigned opts_CLOCK_LOCK_THRESHOLD_S1 = 2; // Is not implemented as
static void print_usage(const char *program_name)
{
fprintf(stdout, "rtl_wmbus: " VERSION "\n\n");
fprintf(stdout, "Usage %s:\n", program_name);
fprintf(stdout, "\t-a accelerate (use an inaccurate atan version)\n");
fprintf(stdout, "\t-r 0 to disable run length algorithm\n");
fprintf(stdout, "\t-t 0 to disable time2 algorithm\n");
fprintf(stdout, "\t-d 2 set decimation rate to 2 (defaults to 2 if omitted)\n");
fprintf(stdout, "\t-v show used algorithm in the output\n");
fprintf(stdout, "\t-V show version\n");
fprintf(stdout, "\t-s receive S1 and T1/C1 datagrams simultaneously. rtl_sdr _MUST_ be set to 868.625MHz (-f 868.625M)\n");
}
static void print_version(void)
{
fprintf(stdout, "rtl_wmbus: " VERSION "\n");
fprintf(stdout, COMMIT "\n");
}
static void process_options(int argc, char *argv[])
{
int option;
while ((option = getopt(argc, argv, "ad:r:vst:")) != -1)
while ((option = getopt(argc, argv, "ad:r:vVst:")) != -1)
{
switch (option)
{
@ -848,6 +856,10 @@ static void process_options(int argc, char *argv[])
case 'v':
opts_show_used_algorithm = 1;
break;
case 'V':
print_version();
exit(EXIT_SUCCESS);
break;
default:
print_usage(argv[0]);
exit(EXIT_FAILURE);
@ -1150,4 +1162,3 @@ int main(int argc, char *argv[])
free(LUT_FREQUENCY_TRANSLATION_PLUS_SINE);
return EXIT_SUCCESS;
}