Recompile version related files on codebase change

This commit is contained in:
Jcomp 2024-01-25 11:01:10 +00:00
parent 10242479cd
commit 01ac544053

View file

@ -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