aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorTeddy Wing2020-10-03 18:24:56 +0200
committerTeddy Wing2020-10-03 18:24:56 +0200
commitda94442fae40736859787575b65720382c1f231c (patch)
tree078a8f8748c2f307493ea46af0734ed39673d49c /Makefile
parent90969d5e9defcd593c7acc416247cd7a6b04e532 (diff)
downloadgit-todo-0.0.1.tar.bz2
Build for release and configure static linkingv0.0.1
Set up a release build and distribution packaging. Configure static linking for 'openssl' and 'libgit2'. Based on or copied from code from 'git-suggestion'.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile52
1 files changed, 50 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index c01ae66..8a4116d 100644
--- a/Makefile
+++ b/Makefile
@@ -14,15 +14,33 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
+VERSION := $(shell egrep '^version = ' Cargo.toml | awk -F '"' '{ print $$2 }')
+TOOLCHAIN := $(shell fgrep default_host_triple $(HOME)/.rustup/settings.toml | awk -F '"' '{ print $$2 }')
+
SOURCES := $(shell find . -name '*.rs')
DEPENDENCIES := Cargo.toml
+
+MAN_PAGE := doc/git-todo.1
+
DEBUG_PRODUCT := target/debug/git-todo
+RELEASE_PRODUCT := target/release/git-todo
+
+DIST := $(abspath dist)
+DIST_PRODUCT := $(DIST)/bin/git-todo
+DIST_MAN_PAGE := $(DIST)/share/man/man1/git-todo.1
+
+# Set STATIC=1 to build a static binary.
+STATIC ?= 0
+
+ifeq ($(STATIC), 1)
+BUILD_VARS += PKG_CONFIG_LIBDIR=''
+endif
.PHONY: doc
-doc: doc/git-todo.1
+doc: $(MAN_PAGE)
-doc/git-todo.1: doc/git-todo.1.txt
+$(MAN_PAGE): doc/git-todo.1.txt
sed 's/`/*/g' $< > $@.transformed
a2x --no-xmllint --format manpage $@.transformed
rm $@.transformed
@@ -34,3 +52,33 @@ test: $(DEBUG_PRODUCT)
$(DEBUG_PRODUCT): $(SOURCES) $(DEPENDENCIES)
cargo build
+
+
+$(RELEASE_PRODUCT): $(SOURCES) $(DEPENDENCIES)
+ $(BUILD_VARS) cargo build --release
+
+
+.PHONY: dist
+dist: $(DIST_PRODUCT) $(DIST_MAN_PAGE)
+
+$(DIST):
+ mkdir -p $@
+
+$(DIST)/bin: $(DIST)
+ mkdir -p $@
+
+$(DIST)/share/man/man1: $(DIST)
+ mkdir -p $@
+
+$(DIST_PRODUCT): $(DIST)/bin $(RELEASE_PRODUCT)
+ cp $(RELEASE_PRODUCT) $<
+
+$(DIST_MAN_PAGE): $(DIST)/share/man/man1 $(MAN_PAGE)
+ cp $(MAN_PAGE) $<
+
+
+.PHONY: pkg
+pkg: git-todo_$(VERSION)_$(TOOLCHAIN).tar.bz2
+
+git-todo_$(VERSION)_$(TOOLCHAIN).tar.bz2: dist
+ tar cjv -s /dist/git-todo_$(VERSION)_$(TOOLCHAIN)/ -f $@ dist