forked from sharkdp/hexyl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
51 lines (37 loc) · 1.04 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
ifeq ($(RUST_TARGET),)
TARGET :=
RELEASE_SUFFIX :=
else
TARGET := $(RUST_TARGET)
RELEASE_SUFFIX := -$(TARGET)
export CARGO_BUILD_TARGET = $(RUST_TARGET)
endif
PROJECT_NAME := hexyl
_HASH := \#
VERSION := $(lastword $(subst @, ,$(subst $(_HASH), ,$(shell cargo pkgid))))
RELEASE := $(PROJECT_NAME)-$(VERSION)$(RELEASE_SUFFIX)
DIST_DIR := dist
RELEASE_DIR := $(DIST_DIR)/$(RELEASE)
MANUAL_DIR := $(RELEASE_DIR)/manual
BINARY := target/$(TARGET)/release/$(PROJECT_NAME)
MAN1 := doc/$(PROJECT_NAME).1
RELEASE_BINARY := $(RELEASE_DIR)/$(PROJECT_NAME)
MANUAL := $(MANUAL_DIR)/$(PROJECT_NAME).1
ARTIFACT := $(RELEASE).tar.xz
.PHONY: all
all: $(ARTIFACT)
$(BINARY):
cargo build --locked --release
$(MAN1):
pandoc -s -f markdown -t man -o $@ $(@).md
$(DIST_DIR) $(RELEASE_DIR) $(MANUAL_DIR):
mkdir -p $@
$(RELEASE_BINARY): $(BINARY) $(RELEASE_DIR)
cp -f $< $@
$(MANUAL): $(MAN1) $(MANUAL_DIR)
cp -f $< $@
$(ARTIFACT): $(RELEASE_BINARY) $(MANUAL)
tar -C $(DIST_DIR) -Jcvf $@ $(RELEASE)
.PHONY: clean
clean:
$(RM) -rf $(ARTIFACT) $(DIST_DIR) $(MAN1)