Skip to content

Commit

Permalink
autoconf based build system (#287)
Browse files Browse the repository at this point in the history
* Add autoconf based build system
  • Loading branch information
norbusan authored and abraunegg committed Apr 17, 2019
1 parent 3b53389 commit c8e47a4
Show file tree
Hide file tree
Showing 14 changed files with 4,820 additions and 27 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ onedrive.o
onedrive.service
onedrive@.service
version
Makefile
config.log
config.status
autom4te.cache/
pacman/PKGBUILD
spec/onedrive.spec
9 changes: 6 additions & 3 deletions .travis-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ DEBIAN_MIRROR="http://httpredir.debian.org/debian"
HOST_DEPENDENCIES="qemu-user-static binfmt-support debootstrap sbuild wget"

# Debian package dependencies for the chrooted environment
GUEST_DEPENDENCIES="build-essential libcurl4-openssl-dev libsqlite3-dev libgnutls-openssl27 git libxml2"
GUEST_DEPENDENCIES="build-essential libcurl4-openssl-dev libsqlite3-dev libgnutls-openssl27 git pkg-config libxml2"

# LDC Version
# Different versions due to https://github.com/ldc-developers/ldc/issues/3027
Expand Down Expand Up @@ -122,16 +122,19 @@ function build_onedrive {
HOMEDIR=$(pwd)
if [ "${ARCH}" = "x64" ]; then
# Build on x86_64 as normal
./configure
make clean; make;
else
if [ "${ARCH}" = "x32" ]; then
# 32Bit DMD Build
./configure DC=${HOMEDIR}/dlang-${ARCH}/linux/bin32/dmd
make clean;
make DC=${HOMEDIR}/dlang-${ARCH}/linux/bin32/dmd
make
else
# LDC Build - ARM32, ARM64
./configure DC=${HOMEDIR}/dlang-${ARCH}/bin/ldmd2
make clean;
make DC=${HOMEDIR}/dlang-${ARCH}/bin/ldmd2
make
fi
fi
# Functional testing of built application
Expand Down
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM centos:7
ENV GOSU_VERSION=1.11

RUN yum install -y make git gcc libcurl-devel sqlite-devel && \
RUN yum install -y make git gcc libcurl-devel sqlite-devel pkg-config && \
rm -rf /var/cache/yum/ && \
curl -fsS -o install.sh https://dlang.org/install.sh && \
bash install.sh dmd && \
Expand All @@ -17,7 +17,9 @@ RUN yum install -y make git gcc libcurl-devel sqlite-devel && \
RUN mkdir -p /onedrive/conf /onedrive/data
COPY . /usr/src/onedrive
RUN . "$(bash install.sh -a)" && \
make -C /usr/src/onedrive install.noservice && \
/usr/src/onedrive/configure && \
make -C /usr/src/onedrive && \
make -C /usr/src/onedrive install && \
make -C /usr/src/onedrive clean
COPY entrypoint.sh /entrypoint.sh
VOLUME ["/onedrive/conf"]
Expand Down
131 changes: 131 additions & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
package = @PACKAGE_NAME@
version = @PACKAGE_VERSION@
prefix = @prefix@
# we don't use @exec_prefix@ because it usually contains '${prefix}' literally
# but we use @prefix@/bin/onedrive in the systemd unit files which are generated
# from the configure script.
# Thus, set exec_prefix unconditionally to prefix
# Alternative approach would be add dep on sed, and do manual generation in the Makefile.
# exec_prefix = @exec_prefix@
exec_prefix = @prefix@
datarootdir = @datarootdir@
datadir = @datadir@
srcdir = @srcdir@
bindir = @bindir@
mandir = @mandir@
sysconfdir = @sysconfdir@
docdir = $(datadir)/doc/$(package)
VPATH = @srcdir@
SED = @SED@
INSTALL = @INSTALL@

NOTIFICATIONS = @NOTIFICATIONS@
HAVE_SYSTEMD = @HAVE_SYSTEMD@
systemduserunitdir = @systemduserunitdir@
systemdsystemunitdir = @systemdsystemunitdir@
curl_LIBS = @curl_LIBS@
sqlite_LIBS = @sqlite_LIBS@
notify_LIBS = @notify_LIBS@
COMPLETIONS = @COMPLETIONS@
BASH_COMPLETION_DIR = @BASH_COMPLETION_DIR@
ZSH_COMPLETION_DIR = @ZSH_COMPLETION_DIR@
DEBUG = @DEBUG@

DC = @DC@
DC_TYPE = @DC_TYPE@
DCFLAGS = @DCFLAGS@
DCFLAGS += -w -g -O -J.
ifeq ($(DEBUG),yes)
ifeq ($(DC_TYPE),dmd)
DCFLAGS += -debug -gs
else
DCFLAGS += -d-debug -gc
endif
endif

ifeq ($(NOTIFICATIONS),yes)
NOTIF_VERSIONS=-version=NoPragma -version=NoGdk -version=Notifications
# support ldc2 which needs -d prefix for version specification
ifeq ($(DC_TYPE),ldc)
NOTIF_VERSIONS := $(addprefix -d,$(NOTIF_VERSIONS))
endif
DCFLAGS += $(NOTIF_VERSIONS)
endif

system_unit_files = systemd.units/onedrive@.service
user_unit_files = systemd.units/onedrive.service

DOCFILES = README.md README.Office365.md config LICENSE CHANGELOG.md

SOURCES = \
src/config.d \
src/itemdb.d \
src/log.d \
src/main.d \
src/monitor.d \
src/onedrive.d \
src/qxor.d \
src/selective.d \
src/sqlite.d \
src/sync.d \
src/upload.d \
src/util.d \
src/progress.d

ifeq ($(NOTIFICATIONS),yes)
SOURCES += src/notifications/notify.d src/notifications/dnotify.d
endif

all: onedrive

clean:
rm -f onedrive onedrive.o version
rm -rf autom4te.cache
rm -f config.log config.status

# also remove files generated via ./configure
distclean: clean
rm -f Makefile pacman/PKGBUILD spec/onedrive.spec onedrive.1 \
systemd.units/onedrive.service systemd.units/onedrive@.service

onedrive: version $(SOURCES)
$(DC) $(DCFLAGS) $(addprefix -L,$(curl_LIBS)) $(addprefix -L,$(sqlite_LIBS)) $(addprefix -L,$(notify_LIBS)) -L-ldl $(SOURCES) -of$@

install: all
$(INSTALL) -d -o root -g users -m 0775 $(DESTDIR)/var/log/onedrive
$(INSTALL) -D onedrive $(DESTDIR)$(bindir)/onedrive
$(INSTALL) -D onedrive.1 $(DESTDIR)$(mandir)/man1/onedrive.1
$(INSTALL) -D -m 644 logrotate/onedrive.logrotate $(DESTDIR)$(sysconfdir)/logrotate.d/onedrive
for i in $(DOCFILES) ; do $(INSTALL) -D -m 644 $$i $(DESTDIR)$(docdir)/$$i ; done
ifeq ($(HAVE_SYSTEMD),yes)
$(INSTALL) -d -o root -g root -m 0755 $(DESTDIR)$(systemduserunitdir) $(DESTDIR)$(systemdsystemunitdir)
$(INSTALL) -m 0644 $(system_unit_files) $(DESTDIR)$(systemdsystemunitdir)
$(INSTALL) -m 0644 $(user_unit_files) $(DESTDIR)$(systemduserunitdir)
endif
ifeq ($(COMPLETIONS),yes)
$(INSTALL) -D -m 644 completions/complete.zsh $(DESTDIR)$(ZSH_COMPLETION_DIR)/_onedrive
$(INSTALL) -D -m 644 completions/complete.bash $(DESTDIR)$(BASH_COMPLETION_DIR)/onedrive
endif


uninstall:
rm -f $(DESTDIR)$(bindir)/onedrive
rm -f $(DESTDIR)$(mandir)/man1/onedrive.1
rm -f $(DESTDIR)$(sysconfdir)/logrotate.d/onedrive
ifeq ($(HAVE_SYSTEMD),yes)
for i in $(system_unit_files) ; do rm -f $(DESTDIR)$(systemdsystemunitdir)/$$i ; done
for i in $(user_unit_files) ; do rm -f $(DESTDIR)$(systemduserunitdir)/$$i ; done
endif
for i in $(DOCFILES) ; do rm -f $(DESTDIR)$(DOCDIR)/$$i ; done
ifeq ($(COMPLETIONS),yes)
rm -f $(DESTDIR)$(ZSH_COMPLETION_DIR)/_onedrive
rm -f $(DESTDIR)$(BASH_COMPLETION_DIR)/onedrive
endif

version:
if [ -f .git/HEAD ] ; then \
echo $(shell git describe --tags) > version ; \
else \
echo $(version) > version ; \
fi

32 changes: 19 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,50 +181,56 @@ Without performing this step, the compilation process will fail.
```text
git clone https://github.com/abraunegg/onedrive.git
cd onedrive
./configure
make clean; make;
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.
Notifications can be enabled using the `configure` switch `--enable-notifications`.

By passing `NOTIFICATIONS=1` to the `make` call, notifications via
libnotify are enabled. If `pkg-config` is not used (see above), the necessary
libraries are `gmodule-2.0`, `glib-2.0`, and `notify`.
Systemd service files are installed in the appropriate directories on the system,
as provided by `pkg-config systemd` settings. If the need for overriding the
deduced path are necessary, the two options `--with-systemdsystemunitdir` (for
the Systemd system unit location), and `--with-systemduserunitdir` (for the
Systemd user unit location) can be specified. Passing in `no` to one of these
options disabled service file installation.

By passing `DEBUG=1` to the `make` call, `onedrive` gets built with additional debug
By passing `--enable-debug` to the `configure` call, `onedrive` gets built with additional debug
information, useful (for example) to get `perf`-issued figures.

By passing `COMPLETIONS=1` to the `make` call, shell completion functions are
By passing `--enable-completions` to the `configure` call, shell completion functions are
installed for `bash` and `zsh`. The installation directories are determined
as far as possible automatically, but can be overridden by setting the
environment variables `BASHCOMPLETIONDIR` and `ZSHCOMPLETIONDIR`.
as far as possible automatically, but can be overridden by passing
`--with-bash-completion-dir=<DIR>` and
`--with-zsh-completion-dir=<DIR>` to `configure`.

### Building using a different compiler (for example [LDC](https://wiki.dlang.org/LDC))
#### Debian - i386 / i686
```text
git clone https://github.com/abraunegg/onedrive.git
cd onedrive
make clean; make DC=/usr/bin/ldc2
./configure DC=ldc2
make clean; make
sudo make install
```

#### ARMHF Architecture
```text
git clone https://github.com/abraunegg/onedrive.git
cd onedrive
make clean; make DC=~/ldc2-1.13.0-linux-armhf/bin/ldmd2
./configure DC=~/ldc2-1.13.0-linux-armhf/bin/ldmd2
make clean; make
sudo make install
```

#### ARM64 Architecture
```text
git clone https://github.com/abraunegg/onedrive.git
cd onedrive
make clean; make DC=~/ldc2-1.14.0-linux-aarch64/bin/ldmd2
./configure DC=~/ldc2-1.14.0-linux-aarch64/bin/ldmd2
make clean; make
sudo make install
```

Expand Down
Loading

0 comments on commit c8e47a4

Please sign in to comment.