From 10242479cdafbc5dcb22bd1547be1ffdb38668d8 Mon Sep 17 00:00:00 2001 From: Jcomp Date: Thu, 25 Jan 2024 08:30:32 +0000 Subject: [PATCH 1/2] Add rule to create object file in Makefile --- .gitignore | 4 ++++ Makefile.in | 23 +++++++++++++++++------ src/notifications/dnotify.d | 6 +++--- src/notifications/notify.d | 2 +- src/{sync.d => syncEngine.d} | 0 5 files changed, 25 insertions(+), 10 deletions(-) rename src/{sync.d => syncEngine.d} (100%) diff --git a/.gitignore b/.gitignore index 05e6f9ee..e417cd8e 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,7 @@ config.status autom4te.cache/ contrib/pacman/PKGBUILD contrib/spec/onedrive.spec +contrib/systemd/onedrive.service +contrib/systemd/onedrive@.service + +*.o \ No newline at end of file diff --git a/Makefile.in b/Makefile.in index 3cab7aeb..6efeb550 100644 --- a/Makefile.in +++ b/Makefile.in @@ -34,7 +34,7 @@ DEBUG = @DEBUG@ DC = @DC@ DC_TYPE = @DC_TYPE@ DCFLAGS = @DCFLAGS@ -DCFLAGS += -w -g -O -J. +DCFLAGS += -w -g -O -J. -Isrc -Isrc/notifications ifeq ($(DEBUG),yes) ifeq ($(DC_TYPE),dmd) DCFLAGS += -debug -gs @@ -73,7 +73,7 @@ SOURCES = \ src/qxor.d \ src/curlEngine.d \ src/onedrive.d \ - src/sync.d \ + src/syncEngine.d \ src/itemdb.d \ src/sqlite.d \ src/clientSideFiltering.d \ @@ -84,10 +84,16 @@ ifeq ($(NOTIFICATIONS),yes) SOURCES += src/notifications/notify.d src/notifications/dnotify.d endif -all: onedrive +# Object file +OBJ = $(SOURCES:.d=.o) + +# Executable +EXE = onedrive + +all: version $(EXE) clean: - rm -f onedrive onedrive.o version + rm -f $(EXE) $(OBJ) version rm -rf autom4te.cache rm -f config.log config.status @@ -95,13 +101,18 @@ clean: distclean: clean rm -f Makefile contrib/pacman/PKGBUILD contrib/spec/onedrive.spec onedrive.1 $(system_unit_files) $(user_unit_files) -onedrive: $(SOURCES) +version: if [ -f .git/HEAD ] ; then \ git describe --tags > version ; \ else \ echo $(version) > version ; \ fi - $(DC) $(DCFLAGS) $(addprefix -L,$(curl_LIBS)) $(addprefix -L,$(sqlite_LIBS)) $(addprefix -L,$(notify_LIBS)) -L-ldl $(SOURCES) -of$@ + +$(EXE): $(OBJ) + $(DC) $(DCFLAGS) $(addprefix -L,$(curl_LIBS)) $(addprefix -L,$(sqlite_LIBS)) $(addprefix -L,$(notify_LIBS)) -L-ldl -of$@ $^ + +%.o: %.d + $(DC) $(DCFLAGS) -c $(addprefix -L,$(curl_LIBS)) $(addprefix -L,$(sqlite_LIBS)) $(addprefix -L,$(notify_LIBS)) -L-ldl -of=$@ $< install: all $(INSTALL) -D onedrive $(DESTDIR)$(bindir)/onedrive diff --git a/src/notifications/dnotify.d b/src/notifications/dnotify.d index 1cc09356..f8ab974e 100644 --- a/src/notifications/dnotify.d +++ b/src/notifications/dnotify.d @@ -1,4 +1,4 @@ -module dnotify; +module notifications.dnotify; private { import std.string : toStringz; @@ -7,10 +7,10 @@ private { import std.variant : Variant; import std.array : appender; - import deimos.notify.notify; + import notifications.notify; } -public import deimos.notify.notify : NOTIFY_EXPIRES_DEFAULT, NOTIFY_EXPIRES_NEVER, +public import notifications.notify : NOTIFY_EXPIRES_DEFAULT, NOTIFY_EXPIRES_NEVER, NotifyUrgency; diff --git a/src/notifications/notify.d b/src/notifications/notify.d index c549e397..e8a79a01 100644 --- a/src/notifications/notify.d +++ b/src/notifications/notify.d @@ -18,7 +18,7 @@ * Boston, MA 02111-1307, USA. */ -module deimos.notify.notify; +module notifications.notify; enum NOTIFY_VERSION_MAJOR = 0; diff --git a/src/sync.d b/src/syncEngine.d similarity index 100% rename from src/sync.d rename to src/syncEngine.d From 01ac5440537827af1b402603ab2e6bbf70adaafc Mon Sep 17 00:00:00 2001 From: Jcomp Date: Thu, 25 Jan 2024 11:01:10 +0000 Subject: [PATCH 2/2] 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