This repository has been archived by the owner on Jun 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 61
/
Makefile
97 lines (79 loc) · 2.29 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
92
93
94
95
96
97
DIST := dist
IMPORT := github.com/countstarlight/homo
GO ?= env GO111MODULE=on go
SED_INPLACE := sed -i
ifeq ($(OS), Windows_NT)
EXECUTABLE_INTERACT := homo-interact.exe
EXECUTABLE_WEBVIEW := homo-webview.exe
else
EXECUTABLE_INTERACT := homo-interact
EXECUTABLE_WEBVIEW := homo-webview
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
SED_INPLACE := sed -i ''
endif
endif
GOFILES := $(shell find . -name "*.go" -type f ! -path "./vendor/*")
GOBINS := ${GOPATH}/bin
GOFMT ?= gofmt -s
GOFLAGS := -mod=vendor -v
PACKAGES ?= $(shell $(GO) list ./... | grep -v /vendor/)
SOURCES ?= $(shell find . -name "*.go" -type f)
.PHONY: all
all: build
.PHONY: deps
deps:
echo "Installing sphinxbase..."; \
git clone https://github.com/countstarlight/sphinxbase.git; \
cd sphinxbase && ./autogen.sh && ./configure && make -j 4 && sudo make install; \
cd .. && rm -rf sphinxbase; \
echo "Installing PocketSphinx..."; \
git clone https://github.com/countstarlight/pocketsphinx.git; \
cp -r pocketsphinx/model/en-us sphinx/; \
cd pocketsphinx && ./autogen.sh && ./configure && make -j 4 && sudo make install; \
cd .. && rm -rf pocketsphinx
.PHONY: gen
gen:
@hash go-bindata > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
$(GO) get -u github.com/jteeuwen/go-bindata; \
$(GO) get -u github.com/jteeuwen/go-bindata/...; \
fi
$(GO) generate github.com/countstarlight/homo/module/view
.PHONY: clean
clean:
$(GO) clean -i ./...
rm -f $(EXECUTABLE_INTERACT)
rm -f $(EXECUTABLE_WEBVIEW)
.PHONY: docker
docker:
docker build -t homo:v0.0.1 .
.PHONY: dockercn
dockercn:
docker-compose -f docker/homo-compose-zh.yml up -d --build
.PHONY: fmt
fmt:
$(GOFMT) -w $(GOFILES)
.PHONY: fmt-check
fmt-check:
# get all go files and run go fmt on them
@diff=$$($(GOFMT) -d $(GOFILES)); \
if [ -n "$$diff" ]; then \
echo "Please run 'make fmt' and commit the result:"; \
echo "$${diff}"; \
exit 1; \
fi;
.PHONY: webview
webview: $(EXECUTABLE_WEBVIEW)
.PHONY: watch
watch: gen $(EXECUTABLE_WEBVIEW)
./$(EXECUTABLE_WEBVIEW) -d
.PHONY: build
build: $(EXECUTABLE_INTERACT) $(EXECUTABLE_WEBVIEW)
$(EXECUTABLE_INTERACT): $(SOURCES)
cd ./cmd/interact; \
$(GO) build $(GOFLAGS) $(EXTRA_GOFLAGS) -o $@; \
mv $@ ../../
$(EXECUTABLE_WEBVIEW): $(SOURCES)
cd ./cmd/webview; \
$(GO) build $(GOFLAGS) $(EXTRA_GOFLAGS) -o $@; \
mv $@ ../../