From 01ac5440537827af1b402603ab2e6bbf70adaafc Mon Sep 17 00:00:00 2001 From: Jcomp Date: Thu, 25 Jan 2024 11:01:10 +0000 Subject: [PATCH] Recompile version related files on codebase change --- Makefile.in | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Makefile.in b/Makefile.in index 6efeb550..526e0c6c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -65,6 +65,12 @@ RHEL = 0 RHEL_VERSION = 0 endif +ifneq ($(wildcard .git/HEAD),"") +VERSION = $(shell git describe --tags) +else +VERSION = $(version) +endif + SOURCES = \ src/main.d \ src/config.d \ @@ -101,12 +107,8 @@ clean: distclean: clean rm -f Makefile contrib/pacman/PKGBUILD contrib/spec/onedrive.spec onedrive.1 $(system_unit_files) $(user_unit_files) -version: - if [ -f .git/HEAD ] ; then \ - git describe --tags > version ; \ - else \ - echo $(version) > version ; \ - fi +version: $(SOURCES) + echo "$(VERSION)" > version; $(EXE): $(OBJ) $(DC) $(DCFLAGS) $(addprefix -L,$(curl_LIBS)) $(addprefix -L,$(sqlite_LIBS)) $(addprefix -L,$(notify_LIBS)) -L-ldl -of$@ $^ @@ -114,6 +116,9 @@ $(EXE): $(OBJ) %.o: %.d $(DC) $(DCFLAGS) -c $(addprefix -L,$(curl_LIBS)) $(addprefix -L,$(sqlite_LIBS)) $(addprefix -L,$(notify_LIBS)) -L-ldl -of=$@ $< +# ensure that version is ready +src/main.o: src/main.d version + install: all $(INSTALL) -D onedrive $(DESTDIR)$(bindir)/onedrive $(INSTALL) -D -m 0644 onedrive.1 $(DESTDIR)$(mandir)/man1/onedrive.1