From 947c92ce3f9f4fa16957648899a4088954d5bf5c Mon Sep 17 00:00:00 2001 From: javalsai Date: Mon, 21 Jul 2025 18:30:28 +0200 Subject: [PATCH] build: allow to override git-rev and timestamp build info --- Makefile | 9 +++++---- docs/PACKAGERS.md | 11 +++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 7b48488..59f8799 100644 --- a/Makefile +++ b/Makefile @@ -22,14 +22,15 @@ DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS)) _OBJ = main.o log.o util.o ui.o ui_state.o config.o desktop.o auth.o ofield.o efield.o users.o sessions.o chvt.o launch_state.o OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ)) -.git/HEAD: +INFO_GIT_REV?=$$(git describe --long --tags --always || echo '?') +INFO_BUILD_TS?=$$(date +%s) -$(IDIR)/version.h: Makefile .git/HEAD +$(IDIR)/version.h: Makefile @tmp=$$(mktemp); \ printf '' > $$tmp; \ echo '#define LIDM_VERSION "'$(VERSION)'"' >> $$tmp; \ - echo '#define LIDM_GIT_REV "'$$(git describe --long --tags --always || echo '?')'"' >> $$tmp; \ - echo '#define LIDM_BUILD_TS '$$(date +%s) >> $$tmp; \ + echo '#define LIDM_GIT_REV "'$(INFO_GIT_REV)'"' >> $$tmp; \ + echo '#define LIDM_BUILD_TS '$(INFO_BUILD_TS) >> $$tmp; \ if ! cmp -s $$tmp $@; then \ mv $$tmp $@; \ fi; \ diff --git a/docs/PACKAGERS.md b/docs/PACKAGERS.md index a94d835..5e41e2b 100644 --- a/docs/PACKAGERS.md +++ b/docs/PACKAGERS.md @@ -38,6 +38,17 @@ Lidm attempts to support being built by `gcc` and `clang` with preference over t Compiler flags should be passed with `CFLAGS`, its `-O3 -Wall` by default so adding anything will overwrite this. +## Build Metadata + +`lidm -v` outputs some information about the build version, this can be weaked with `INFO_GIT_REV` and `INFO_BUILD_TS`, by default they are: + +```make +INFO_GIT_REV?=$$(git describe --long --tags --always || echo '?') +INFO_BUILD_TS?=$$(date +%s) +``` + +But this can be changed by just passing those env variables, for example, in the case git is not applicable in the build environment of the package. + ## Target Directory `DESTDIR` can be used to for installation recipes to install on alternative root directories. Along with `PREFIX` (defaults to `/usr`) for systems which don't use the common `/usr` structure. e.g. `make install DESTDIR=$out PREFIX=`