From a1c089b997ebf705a9023b4f0f97327e5bd2814e Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Wed, 1 Jul 2020 22:41:28 +0200 Subject: Makefile: Major refactoring, add install and uninstall targets. Honor BUILD_DOCDIR and DESTDIR variables. Also, remove the `use lib` statement from our executables. --- Changelog | 3 +++ Makefile | 52 ++++++++++++++++++++++++++++++++------------- interimap | 1 - pullimap | 1 - tests/db-exclusive-lock/t | 4 ++-- tests/db-no-create--watch/t | 2 +- 6 files changed, 43 insertions(+), 20 deletions(-) diff --git a/Changelog b/Changelog index 4207069..6b3be44 100644 --- a/Changelog +++ b/Changelog @@ -2,6 +2,9 @@ interimap (0.5.1) UNRELEASED; + pullimap: also compare RFC 5322 date and envelope information in mailbox comparison tests. + + interimap, pullimap: remove `use lib` statement. + * Makefile: major refactoring, add install and uninstall targets, honor + BUILD_DOCDIR and DESTDIR variables. -- Guilhem Moulin Wed, 01 Jul 2020 21:24:50 +0200 diff --git a/Makefile b/Makefile index b232602..35f1334 100644 --- a/Makefile +++ b/Makefile @@ -1,24 +1,25 @@ +DESTDIR ?= /usr/local +BUILD_DOCDIR ?= ./doc +CSS ?= /usr/share/javascript/bootstrap4/css/bootstrap.css +HTML_TEMPLATE ?= ./doc/template.html + +HTML_FILES = $(addprefix $(BUILD_DOCDIR)/,$(patsubst ./doc/%.md,%.html,$(wildcard ./doc/*.md))) +MANUAL_FILES = $(addprefix $(BUILD_DOCDIR)/,$(patsubst ./doc/%.md,%,$(wildcard ./doc/*.[1-9].md))) + all: manual -MANUALS = $(patsubst %.md,%,$(wildcard ./doc/*.[1-9].md)) -manual: $(MANUALS) +manual: $(MANUAL_FILES) +html: $(HTML_FILES) # upper case the headers and remove the links -$(MANUALS): %: %.md +$(MANUAL_FILES): $(BUILD_DOCDIR)/%: ./doc/%.md pandoc -f markdown -t json -- "$<" | ./pandoc2man.jq | pandoc -s -f json -t man+smart -o "$@" test: @./tests/run-all -HTML_ROOTDIR ?= ./doc -CSS ?= /usr/share/javascript/bootstrap/css/bootstrap.min.css -HTML_TEMPLATE ?= ./doc/template.html - -HTML_FILES = $(addprefix $(HTML_ROOTDIR)/,$(patsubst ./doc/%.md,%.html,$(wildcard ./doc/*.md))) -html: $(HTML_FILES) - -## CSS="https://guilhem.org/static/css/bootstrap.min.css" HTML_ROOTDIR="$XDG_RUNTIME_DIR/Downloads" make html -$(HTML_ROOTDIR)/%.html: ./doc/%.md $(HTML_TEMPLATE) +## make html CSS="https://guilhem.org/static/css/bootstrap.min.css" BUILD_DOCDIR="$XDG_RUNTIME_DIR/Downloads" +$(HTML_FILES): $(BUILD_DOCDIR)/%.html: ./doc/%.md $(HTML_TEMPLATE) mtime="$$(git --no-pager log -1 --pretty="format:%ct" -- "$<" 2>/dev/null)"; \ [ -n "$$mtime" ] || mtime="$$(date +%s -r "$<")"; \ [ "$<" = "doc/index.md" ] && parent="" || parent="./index.html"; \ @@ -31,9 +32,30 @@ $(HTML_ROOTDIR)/%.html: ./doc/%.md $(HTML_TEMPLATE) doc: manual html -install: +prefix ?= $(DESTDIR) +exec_prefix ?= $(prefix) +bindir ?= $(exec_prefix)/bin +libdir ?= $(exec_prefix)/lib +datarootdir ?= $(DESTDIR)/share +mandir ?= $(datarootdir)/man +man1dir ?= $(mandir)/man1 + +install: all + install -m0755 -vDt $(bindir) ./interimap ./pullimap + install -m0644 -vDT ./lib/Net/IMAP/InterIMAP.pm $(datarootdir)/perl5/Net/IMAP/InterIMAP.pm + install -m0644 -vDt $(man1dir) $(BUILD_DOCDIR)/interimap.1 $(BUILD_DOCDIR)/pullimap.1 + install -m0644 -vDt $(datarootdir)/doc/pullimap ./pullimap.sample + install -m0644 -vDt $(datarootdir)/doc/interimap ./interimap.sample ./doc/getting-started.md ./doc/multi-account.md README + install -m0644 -vDt $(libdir)/systemd/user ./*.service + +uninstall: + rm -vf -- $(bindir)/interimap $(man1dir)/interimap.1 $(libdir)/systemd/user/interimap*.service + rm -vf -- $(bindir)/pullimap $(man1dir)/pullimap.1 $(libdir)/systemd/user/pullimap*.service + rm -vf -- $(datarootdir)/perl5/Net/IMAP/InterIMAP.pm + rm -rvf -- $(datarootdir)/doc/interimap $(datarootdir)/doc/pullimap + rm -vf -- $(BUILD_DOCDIR)/interimap.1 $(BUILD_DOCDIR)/pullimap.1 clean: - rm -f $(MANUALS) $(HTML_FILES) + rm -vf -- $(MANUAL_FILES) $(HTML_FILES) -.PHONY: all manual html doc test install clean +.PHONY: all manual html doc test install uninstall clean diff --git a/interimap b/interimap index 7fce80e..6448d2b 100755 --- a/interimap +++ b/interimap @@ -32,7 +32,6 @@ use DBD::SQLite::Constants ':file_open'; use Fcntl qw/F_GETFD F_SETFD FD_CLOEXEC/; use List::Util 'first'; -use lib 'lib'; use Net::IMAP::InterIMAP 0.0.5 qw/xdg_basedir read_config compact_set/; # Clean up PATH diff --git a/pullimap b/pullimap index b7a62e9..d1c607a 100755 --- a/pullimap +++ b/pullimap @@ -31,7 +31,6 @@ use Getopt::Long qw/:config posix_default no_ignore_case gnu_getopt auto_version use List::Util 'first'; use Socket qw/PF_INET PF_INET6 SOCK_STREAM IPPROTO_TCP/; -use lib 'lib'; use Net::IMAP::InterIMAP 0.0.5 qw/xdg_basedir read_config compact_set/; # Clean up PATH diff --git a/tests/db-exclusive-lock/t b/tests/db-exclusive-lock/t index 88172c9..c2df4b5 100644 --- a/tests/db-exclusive-lock/t +++ b/tests/db-exclusive-lock/t @@ -10,7 +10,7 @@ sleep .5 # subsequent runs fail as we can't acquire the exclusive lock ! interimap || error -grep -Fx "DBD::SQLite::db do failed: database is locked at ./interimap line 177." <"$STDERR" \ - || error "Is \$DBH->do(\"PRAGMA locking_mode = EXCLUSIVE\"); at line 177?" +grep -Fx "DBD::SQLite::db do failed: database is locked at ./interimap line 176." <"$STDERR" \ + || error "Is \$DBH->do(\"PRAGMA locking_mode = EXCLUSIVE\"); at line 176?" # vim: set filetype=sh : diff --git a/tests/db-no-create--watch/t b/tests/db-no-create--watch/t index 89f1e3e..a8ea07e 100644 --- a/tests/db-no-create--watch/t +++ b/tests/db-no-create--watch/t @@ -1,6 +1,6 @@ ! interimap --watch=60 || error -grep -Ex "DBI connect\(.*\) failed: unable to open database file at \./interimap line 173\." <"$STDERR" || error +grep -Ex "DBI connect\(.*\) failed: unable to open database file at \./interimap line 172\." <"$STDERR" || error test \! -e "$XDG_DATA_HOME/interimap/remote.db" || error # vim: set filetype=sh : -- cgit v1.2.3