aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Cargo.lock10
-rw-r--r--Cargo.toml2
-rw-r--r--Makefile52
4 files changed, 62 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
index ea8c4bf..48681a4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
+/dist/
/target
diff --git a/Cargo.lock b/Cargo.lock
index abaac2e..b0ca986 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -155,6 +155,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de"
[[package]]
+name = "openssl-src"
+version = "111.11.0+1.1.1h"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "380fe324132bea01f45239fadfec9343adb044615f29930d039bec1ae7b9fa5b"
+dependencies = [
+ "cc",
+]
+
+[[package]]
name = "openssl-sys"
version = "0.9.58"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -163,6 +172,7 @@ dependencies = [
"autocfg",
"cc",
"libc",
+ "openssl-src",
"pkg-config",
"vcpkg",
]
diff --git a/Cargo.toml b/Cargo.toml
index 69bbb52..961de83 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -6,5 +6,5 @@ edition = "2018"
[dependencies]
exitcode = "1.1.2"
getopts = "0.2.21"
-git2 = "0.13.11"
+git2 = { version = "0.13.11", features = ["vendored-openssl"] }
thiserror = "1.0.20"
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