clean: makefile clutter

This commit is contained in:
2026-01-20 00:30:19 +01:00
parent 08d1943247
commit 63add82d1b
3 changed files with 21 additions and 33 deletions

2
.gitignore vendored
View File

@@ -8,5 +8,3 @@ valgrind-out.txt
# nix build result
result
include/version.h

View File

@@ -8,34 +8,25 @@ ODIR=dist
PREFIX = /usr/local
CC?=gcc
INFO_GIT_REV ?= $(shell git describe --long --tags --always || echo '?')
INFO_BUILD_TS ?= $(shell date +%s)
CFLAGS ?= -O3 -Wall -Wextra -fdata-sections -ffunction-sections
# C PreProcessor flags, not C Plus Plus
CPPFLAGS ?=
ALLFLAGS=$(CFLAGS) $(CPPFLAGS) -I$(IDIR)
_DFLAGS?= \
-DLIDM_VERSION=\"$(VERSION)\" \
-DLIDM_GIT_REV=\"$(INFO_GIT_REV)\" \
-DLIDM_BUILD_TS=$(INFO_BUILD_TS)
ALLFLAGS = $(_DFLAGS) $(CFLAGS) $(CPPFLAGS) -I$(IDIR)
LDFLAGS ?= -Wl,--gc-sections
LIBS = -lpam
_DEPS = version.h log.h util.h ui.h ui_state.h config.h pam.h desktop.h desktop_exec.h auth.h ofield.h efield.h keys.h users.h sessions.h chvt.h macros.h launch_state.h signal_handler.h
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))
_OBJ = main.o log.o util.o ui.o ui_state.o config.o pam.o desktop.o desktop_exec.o auth.o ofield.o efield.o users.o sessions.o chvt.o launch_state.o signal_handler.o
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
INFO_GIT_REV?=$$(git describe --long --tags --always || echo '?')
INFO_BUILD_TS?=$$(date +%s)
$(IDIR)/version.h: Makefile
@tmp=$$(mktemp); \
printf '' > $$tmp; \
echo '#define LIDM_VERSION "'$(VERSION)'"' >> $$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; \
rm -f $$tmp;
# includes all headers in `$(IDIR)` and compiles everything in `$(CDIR)`
DEPS = $(wildcard $(IDIR)/*.h)
_SOURCES = $(notdir $(wildcard $(CDIR)/*.c))
OBJ = $(patsubst %.c,$(ODIR)/%.o,$(_SOURCES))
$(ODIR)/%.o: $(CDIR)/%.c $(DEPS)
@mkdir -p $(ODIR)

View File

@@ -16,7 +16,6 @@
#include "ui.h"
#include "users.h"
#include "util.h"
#include "version.h"
#define DATESTR_MAXBUFSIZE 0x20