-
Notifications
You must be signed in to change notification settings - Fork 120
/
Makefile
91 lines (80 loc) · 2.18 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# installation paths
INSTALL_DIR=$(DESTDIR)/usr/bin
MOUNT_INSTALL_DIR=$(DESTDIR)/usr/sbin
MAN_INSTALL_DIR=$(DESTDIR)/usr/share/man/man1
ZSH_COMP_INSTALL_DIR=$(DESTDIR)/usr/share/zsh/site-functions
BASH_COMP_INSTALL_DIR=$(DESTDIR)/etc/bash_completion.d
# other vars
VER=$(shell grep -o "[0-9]\+\.[0-9]\+\.[0-9]\+" version/version.go)
SHELL=/bin/sh
ARCH=$(shell uname -m)
DIST_NAME=tmsu-$(ARCH)-$(VER)
DIST_DIR=$(DIST_NAME)
DIST_FILE=$(DIST_NAME).tgz
all: clean compile dist test
clean:
@echo
@echo "CLEANING"
@echo
go clean
rm -Rf bin
rm -Rf $(DIST_DIR)
rm -f $(DIST_FILE)
compile:
@echo
@echo "COMPILING"
@echo
@mkdir -p bin
go build -o bin/tmsu
test: unit-test integration-test
unit-test: compile
@echo
@echo "RUNNING UNIT TESTS"
@echo
go test ./...
integration-test: compile
@echo
@echo "RUNNING INTEGRATION TESTS"
@echo
@cd tests && ./runall
dist: compile
@echo
@echo "PACKAGING DISTRIBUTABLE"
@echo
@mkdir -p $(DIST_DIR)
@mkdir -p $(DIST_DIR)/bin
@mkdir -p $(DIST_DIR)/man
@mkdir -p $(DIST_DIR)/misc/zsh
@mkdir -p $(DIST_DIR)/misc/bash
cp -R bin -t $(DIST_DIR)
cp README.md -t $(DIST_DIR)
cp COPYING.md -t $(DIST_DIR)
cp misc/bin/* -t $(DIST_DIR)/bin/
gzip -fc misc/man/tmsu.1 >$(DIST_DIR)/man/tmsu.1.gz
cp misc/zsh/_tmsu -t $(DIST_DIR)/misc/zsh/
cp misc/bash/tmsu -t $(DIST_DIR)/misc/bash/
tar czf $(DIST_FILE) $(DIST_DIR)
install:
@echo
@echo "INSTALLING"
@echo
mkdir -p $(INSTALL_DIR)
mkdir -p $(MOUNT_INSTALL_DIR)
mkdir -p $(MAN_INSTALL_DIR)
mkdir -p $(ZSH_COMP_INSTALL_DIR)
mkdir -p $(BASH_COMP_INSTALL_DIR)
cp bin/tmsu -t $(INSTALL_DIR)
cp misc/bin/mount.tmsu -t $(MOUNT_INSTALL_DIR)
cp misc/bin/tmsu-* -t $(INSTALL_DIR)
gzip -fc misc/man/tmsu.1 >$(MAN_INSTALL_DIR)/tmsu.1.gz
cp misc/zsh/_tmsu -t $(ZSH_COMP_INSTALL_DIR)
cp misc/bash/tmsu -t $(BASH_COMP_INSTALL_DIR)
uninstall:
@echo "UNINSTALLING"
rm $(INSTALL_DIR)/tmsu
rm $(MOUNT_INSTALL_DIR)/mount.tmsu
rm $(INSTALL_DIR)/tmsu-*
rm $(MAN_INSTALL_DIR)/tmsu.1.gz
rm $(ZSH_COMP_INSTALL_DIR)/_tmsu
rm $(BASH_COMP_INSTALL_DIR)/tmsu
.PHONY: all clean compile test unit-test integration-test dist install uninstall