Skip to content

Commit

Permalink
Makefile: support building with ldc2 and usage of pkg-config for lib …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
norbusan authored Jan 7, 2019
1 parent bf43ecd commit d527b7e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
27 changes: 24 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
DC ?= dmd

ifdef PKGCONFIG
LIBS = $(shell pkg-config --libs sqlite3 libcurl)
else
LIBS = -lcurl -lsqlite3
endif
ifdef NOTIFICATIONS
DFLAGSNOTIFICATIONS ?= -version=NoPragma -version=NoGdk -version=Notifications \
-L-lgmodule-2.0 -L-lglib-2.0 -L-lnotify
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
DFLAGS += -w -g -ofonedrive -O -L-lcurl -L-lsqlite3 $(DFLAGSNOTIFICATIONS) -L-ldl -J.
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
Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d527b7e

Please sign in to comment.