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 RHEL_VERSION = 0
endif endif
ifneq ($(wildcard .git/HEAD),"")
VERSION = $(shell git describe --tags)
else
VERSION = $(version)
endif
SOURCES = \ SOURCES = \
src/main.d \ src/main.d \
src/config.d \ src/config.d \
@ -101,12 +107,8 @@ clean:
distclean: clean distclean: clean
rm -f Makefile contrib/pacman/PKGBUILD contrib/spec/onedrive.spec onedrive.1 $(system_unit_files) $(user_unit_files) rm -f Makefile contrib/pacman/PKGBUILD contrib/spec/onedrive.spec onedrive.1 $(system_unit_files) $(user_unit_files)
version: version: $(SOURCES)
if [ -f .git/HEAD ] ; then \ echo "$(VERSION)" > version;
git describe --tags > version ; \
else \
echo $(version) > version ; \
fi
$(EXE): $(OBJ) $(EXE): $(OBJ)
$(DC) $(DCFLAGS) $(addprefix -L,$(curl_LIBS)) $(addprefix -L,$(sqlite_LIBS)) $(addprefix -L,$(notify_LIBS)) -L-ldl -of$@ $^ $(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 %.o: %.d
$(DC) $(DCFLAGS) -c $(addprefix -L,$(curl_LIBS)) $(addprefix -L,$(sqlite_LIBS)) $(addprefix -L,$(notify_LIBS)) -L-ldl -of=$@ $< $(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: all
$(INSTALL) -D onedrive $(DESTDIR)$(bindir)/onedrive $(INSTALL) -D onedrive $(DESTDIR)$(bindir)/onedrive
$(INSTALL) -D -m 0644 onedrive.1 $(DESTDIR)$(mandir)/man1/onedrive.1 $(INSTALL) -D -m 0644 onedrive.1 $(DESTDIR)$(mandir)/man1/onedrive.1