From 4ea89d03fc35f1a5e38427e2ee94951bf8bc1504 Mon Sep 17 00:00:00 2001 From: PA4WDH Date: Sat, 20 May 2023 22:49:21 +0200 Subject: Add automatic versioning --- .gitignore | 1 + Makefile | 5 ++++- cputemp2maxfreq.c | 5 ++++- generate_version_h.sh | 10 ++++++++++ 4 files changed, 19 insertions(+), 2 deletions(-) create mode 100755 generate_version_h.sh diff --git a/.gitignore b/.gitignore index 7b39e57..f12a347 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.o cputemp2maxfreq debug.h +version.h diff --git a/Makefile b/Makefile index 335d067..efcb459 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,7 @@ -cputemp2maxfreq: debug.o sysfs.o cpufreq.o failsafe.o +cputemp2maxfreq: version.h debug.o sysfs.o cpufreq.o failsafe.o + +version.h: generate_version_h.sh .git/index + ./generate_version_h.sh > version.h %.o: %.c %.h debug.h $(COMPILE.c) $(OUTPUT_OPTION) $< diff --git a/cputemp2maxfreq.c b/cputemp2maxfreq.c index 267c54e..4374ea4 100644 --- a/cputemp2maxfreq.c +++ b/cputemp2maxfreq.c @@ -8,6 +8,7 @@ #include "debug.h" #include "cputemp2maxfreq.h" #include "failsafe.h" +#include "version.h" struct s_cpudata cpudata; struct s_config config={"conservative",70000,"/sys/devices/virtual/thermal/thermal_zone0/temp",100000,2000000,10}; @@ -17,8 +18,10 @@ int main() long int diff; long int newfreq; + printf("Version %s, buildtime %s\n",VERSION_FULL,BUILDTIME); + // Print configuration - printf("Configuration:"); + printf("Configuration:\n"); printf("Governor: %s\n",config.governor); printf("Temperature: %ld\n",config.max_temp); printf("Temp input: %s\n",config.temp_input); diff --git a/generate_version_h.sh b/generate_version_h.sh new file mode 100755 index 0000000..1e90ced --- /dev/null +++ b/generate_version_h.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +VERSION=`git describe --abbrev=0` +HASH=`git show --format="%h" --no-patch master` + + +echo "#define VERSION \"$VERSION\"" +echo "#define HASH \"$HASH\"" +echo "#define VERSION_FULL VERSION\"-\"HASH" +echo "#define BUILDTIME \"`date -Isec`\"" -- cgit v1.2.3