Makefile
1.1 KB
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
BINDIR := bin
APPS := $(notdir $(wildcard cmd/*))
BUILD_TARGETS := $(filter-out build clean, $(MAKECMDGOALS))
.PHONY: build clean default
default: build
build:
@mkdir -p $(BINDIR)
@if [ -z "$(strip $(BUILD_TARGETS))" ]; then \
echo "No specific app provided. Building all apps..."; \
for app in $(APPS); do \
echo "Building $$app..."; \
go build -o $(BINDIR)/$$app ./cmd/$$app; \
done; \
else \
for arg in $(BUILD_TARGETS); do \
if echo $$arg | grep -q -- '-$$'; then \
prefix=$${arg%-}; \
echo "Building all apps starting with '$$prefix'..."; \
for app in $(APPS); do \
case "$$app" in \
$$prefix*) \
echo "Building $$app..."; \
go build -o $(BINDIR)/$$app ./cmd/$$app;; \
esac; \
done; \
else \
echo "Building $$arg..."; \
go build -o $(BINDIR)/$$arg ./cmd/$$arg; \
fi; \
done; \
fi
clean:
@echo "Cleaning up binaries..."
@rm -rf $(BINDIR)
codecheck:
@echo "checking code. Running vet and fmt"
@go vet ./...
@go fmt ./...
test:
@echo "Running test"
@go test ./...
%:
@: