From d527b7ef26afb1f376a4d2a9d0a0cedeef38c2b6 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 7 Jan 2019 11:03:47 +0900 Subject: [PATCH] Makefile: support building with ldc2 and usage of pkg-config for lib finding (#334) * ldc2 support the pragma versions passed to the compiler need an additional `-d` prefix in case of ldc2. Add it if the compiler component looks like ldc2. * pkg-config support By passing `PKGCONFIG=1` to the make call libraries are searched via `pkg-config` instead of hard-coded values. --- Makefile | 29 +++++++++++++++++++++++++---- README.md | 11 +++++++---- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 0164631a..5d1827cb 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,30 @@ DC ?= dmd -ifdef NOTIFICATIONS - DFLAGSNOTIFICATIONS ?= -version=NoPragma -version=NoGdk -version=Notifications \ - -L-lgmodule-2.0 -L-lglib-2.0 -L-lnotify + +ifdef PKGCONFIG + LIBS = $(shell pkg-config --libs sqlite3 libcurl) +else + LIBS = -lcurl -lsqlite3 endif -DFLAGS += -w -g -ofonedrive -O -L-lcurl -L-lsqlite3 $(DFLAGSNOTIFICATIONS) -L-ldl -J. +ifdef NOTIFICATIONS + NOTIF_VERSIONS = -version=NoPragma -version=NoGdk -version=Notifications +ifdef PKGCONFIG + LIBS += $(shell pkg-config --libs libnotify) +else + LIBS += -lgmodule-2.0 -lglib-2.0 -lnotify +endif +endif +LIBS += -ldl + +# add the necessary prefix for the D compiler +LIBS := $(addprefix -L,$(LIBS)) + +# support ldc2 which needs -d prefix for version specification +ifeq ($(notdir $(DC)),ldc2) + NOTIF_VERSIONS := $(addprefix -d,$(NOTIF_VERSIONS)) +endif + +DFLAGS += -w -g -ofonedrive -O $(NOTIF_VERSIONS) $(LIBS) -J. + PREFIX ?= /usr/local DOCDIR ?= $(PREFIX)/share/doc/onedrive MANDIR ?= $(PREFIX)/share/man/man1 diff --git a/README.md b/README.md index a5ad22b2..0db6cbc1 100644 --- a/README.md +++ b/README.md @@ -169,11 +169,14 @@ sudo make install ``` ### Build options + +By passing `PKGCONFIG=1` to the `make` call, necessary libraries (`sqlite3`, +`curl`, and `libnotify` for notifications) are searched for using `pkg-config` +instead of using the hard-coded values. + By passing `NOTIFICATIONS=1` to the `make` call, notifications via -libnotify are enabled. Necessary libraries are -`gmodule-2.0`, `glib-2.0`, and `notify`. If these libraries are -named differently on the build system, the make variable -`DFLAGSNOTIFICATIONS` can be adjusted. +libnotify are enabled. If `pkg-config` is not used (see above), the necessary +libraries are `gmodule-2.0`, `glib-2.0`, and `notify`. ### Building using a different compiler (for example [LDC](https://wiki.dlang.org/LDC)) #### Debian - i386 / i686