aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2022-03-28 01:27:46 +0200
committerTeddy Wing2022-03-28 01:27:46 +0200
commitbc3fa10c63082a2d70b1cec73268b8972ccfd243 (patch)
tree600b0e47516e383c5806a08af1a3c2ea6894b62e
parenta4ff3950de526c6a6325c47ce334acf9576028ef (diff)
downloadyaqlite-bc3fa10c63082a2d70b1cec73268b8972ccfd243.tar.bz2
Makefile: Add targets for binary packaging
-rw-r--r--Makefile37
1 files changed, 37 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 72c82c0..fcc6f5c 100644
--- a/Makefile
+++ b/Makefile
@@ -15,10 +15,24 @@
# You should have received a copy of the GNU General Public License
# along with Yaqlite. If not, see <https://www.gnu.org/licenses/>.
+VERSION := $(shell egrep '^version = ' Cargo.toml | head -n 1 | awk -F '"' '{ print $$2 }')
+TOOLCHAIN := $(shell fgrep default_host_triple $(HOME)/.rustup/settings.toml | awk -F '"' '{ print $$2 }')
+
+SOURCES := $(shell find src -name '*.rs')
+RELEASE_PRODUCT := target/release/yaqlite
+
MAN_PAGE := doc/yaqlite.1.txt
MAN_DIR := share/man/man1
MAN_PRODUCT := $(MAN_DIR)/yaqlite.1
+DIST := $(abspath dist)
+DIST_PRODUCT := $(DIST)/bin/yaqlite
+DIST_MAN_PAGE := $(DIST)/share/man/man1/yaqlite.1
+
+
+$(RELEASE_PRODUCT): $(SOURCES)
+ cargo build --release
+
.PHONY: doc
doc: $(MAN_PRODUCT)
@@ -28,3 +42,26 @@ $(MAN_PRODUCT): $(MAN_PAGE) | $(MAN_DIR)
$(MAN_DIR):
mkdir -p $@
+
+
+.PHONY: dist
+dist: $(DIST_PRODUCT) $(DIST_MAN_PAGE)
+
+$(DIST):
+ mkdir -p $@
+
+$(DIST)/bin: | $(DIST)
+ mkdir -p $@
+
+$(DIST_PRODUCT): $(RELEASE_PRODUCT) | $(DIST)/bin
+ cp $< $@
+
+$(DIST_MAN_PAGE): share
+ cp -R $< $(DIST)
+
+
+.PHONY: pkg
+pkg: yaqlite_$(VERSION)_$(TOOLCHAIN).tar.bz2
+
+yaqlite_$(VERSION)_$(TOOLCHAIN).tar.bz2: dist
+ tar cjv -s /dist/yaqlite_$(VERSION)_$(TOOLCHAIN)/ -f $@ dist