dev: automatic version.h generation

also added compiler information as a feature
This commit is contained in:
2025-07-04 15:19:25 +02:00
parent 3ec1eec56f
commit 19a1355b06
5 changed files with 66 additions and 17 deletions

View File

@@ -1,3 +1,6 @@
VERSION = 1.1.1
.DEFAULT_GOAL := lidm
CDIR=src
LDIR=lib
IDIR=include
@@ -8,7 +11,7 @@ PREFIX=/usr
CC?=gcc
CFLAGS?=-O3 -Wall
_CFLAGS=-I$(DIR)
BUILD_FLAGS=-DLIDM_GIT_DESCRIPTION="\"$(shell git describe --long --tags --always || echo ?)\"" -DLIDM_BUILD_DATE="\"$(shell date -u +"%Y-%m-%dT%H:%M:%SZ" || echo ?)\""
BUILD_FLAGS=
ALLFLAGS=$(CFLAGS) -I$(IDIR) $(BUILD_FLAGS)
LIBS=-lpam
@@ -19,6 +22,17 @@ 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))
$(IDIR)/version.h: Makefile .git/HEAD
@tmp=$$(mktemp); \
printf '' > $$tmp; \
echo '#define LIDM_VERSION "'$(VERSION)'"' >> $$tmp; \
echo '#define LIDM_GIT_REV "'$$(git describe --long --tags --always)'"' >> $$tmp; \
echo '#define LIDM_BUILD_TS '$$(date +%s) >> $$tmp; \
if ! cmp -s $$tmp $@; then \
mv $$tmp $@; \
fi; \
rm -f $$tmp;
$(ODIR)/%.o: $(CDIR)/%.c $(DEPS)
@mkdir -p $(ODIR)
$(CC) -c -o $@ $< $(ALLFLAGS)
@@ -26,7 +40,6 @@ $(ODIR)/%.o: $(CDIR)/%.c $(DEPS)
lidm: $(OBJ)
$(CC) -o $@ $^ $(ALLFLAGS) $(LIBS)
.PHONY: clean
clean:
rm -f $(ODIR)/*.o lidm
@@ -79,3 +92,13 @@ pre-commit:
find . -type f -name '*.sh' -not -path './assets/pkg/aur/*/src/*' | xargs shellcheck
clang-format -i $$(git ls-files "*.c" "*.h")
clang-tidy -p . $$(git ls-files "*.c" "*.h")
.PHONY: clean \
install uninstall \
install-service \
install-service-s6 \
install-service-dinit \
install-service-runit \
install-service-openrc \
install-service-systemd \
pre-commit