From f76fbff7c63674d8a6a058a7020769dbe7e69363 Mon Sep 17 00:00:00 2001 From: Michael Murphy Date: Tue, 21 Jan 2020 10:40:40 -0700 Subject: feat(build): Debian packaging support (#124) * build: Add Makefile for building on Linux with make * packaging: Add debian packaging to build on Debian platforms * Define `env CLEAN=0` to prevent from rebuilding sources * Define `env VENDOR=0` to prevent vendoring of sources To build in a schroot for bionic: ``` sbuild -d bionic --extra-repository='deb [trusted=yes] http://ppa.launchpad.net/mmstick76/rust/ubuntu bionic main' ``` Replace bionic with whichever Ubuntu release you are building for --- Makefile | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Makefile (limited to 'Makefile') diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6da0877 --- /dev/null +++ b/Makefile @@ -0,0 +1,50 @@ +prefix ?= /usr/local + +TARGET=debug +DEBUG ?= 0 +ifeq ($(DEBUG),0) + TARGET = release + ARGS = --release +endif + +VENDOR ?= 0 +ifeq ($(VENDOR),1) + ARGS += --frozen +endif + +APP=bandwhich +BIN=target/$(TARGET)/$(APP) +BIN_DST=$(DESTDIR)$(prefix)/bin/$(APP) +DOC_DST=$(DESTDIR)$(prefix)/share/man/man1/bandwhich.1 +LIC_DST=$(DESTDIR)$(prefix)/share/licenses/$(APP) +SRC = Makefile Cargo.lock Cargo.toml $(shell find src -type f -wholename 'src/*.rs') + +.PHONY: all clean distclean install uninstall vendor + +all: $(BIN) + +clean: + cargo clean + +distclean: + rm -rf .cargo vendor vendor.tar + +$(BIN): $(SRC) +ifeq ($(VENDOR),1) + tar pxf vendor.tar +endif + cargo build $(ARGS) + +install: + install -Dm755 $(BIN) $(BIN_DST) + install -Dm644 docs/bandwhich.1 $(DOC_DST) + install -Dm644 LICENSE.md $(LIC_DST)/LICENSE + +uninstall: + rm -rf $(BIN_DST) $(DOC_DST) $(LIC_DST) + +vendor: + mkdir -p .cargo + cargo vendor | head -n -1 > .cargo/config + echo 'directory = "vendor"' >> .cargo/config + tar pcf vendor.tar vendor -- cgit v1.2.3