This repository has been archived by the owner on Jan 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
69 lines (54 loc) · 1.96 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
BINARY := lilbib
VERSION ?= $(shell git describe --always --dirty --tags 2> /dev/null)
.PHONY: all
all: clean release run
.PHONY: build
build:
go build -ldflags "-X main.Version=$(VERSION)" -o $(BINARY) cmd/lilbib/main.go
.PHONY: test
test:
go test -ldflags "-X main.Version=$(VERSION)" ./...
sandbox/config: config | sandbox/
mkdir $@
cp $^/config_test.toml $@/config.toml
.PHONY: sandbox/web
sandbox/web: | sandbox/
rm -rf $@
cp -r web $@
sandbox/$(BINARY): build | sandbox/
cp $(BINARY) $@
.PHONY: sandbox
sandbox: sandbox/web sandbox/config sandbox/$(BINARY)
/tmp/lilbib-database.lock: database/lilbib_example.sql
echo 'Starting database... (if it does not work add yourself to the group "docker")'
./database/example-database.sh
.PHONY: database
database: /tmp/lilbib-database.lock
.PHONY: run
run: build sandbox database
cd sandbox; ./$(BINARY)
.PHONY: release
release: linux windows
.PHONY: clean
clean:
rm -rf sandbox $(BINARY) release
.PHONY: linux
linux:
mkdir -p release/$(BINARY)-$(VERSION)-$@-amd64
mkdir -p release/$(BINARY)-$(VERSION)-$@-amd64/config
cp config/config.toml release/$(BINARY)-$(VERSION)-$@-amd64/config
cp -r web release/$(BINARY)-$(VERSION)-$@-amd64
cp database/lilbib.sql release/$(BINARY)-$(VERSION)-$@-amd64
GOOS=$@ GOARCH=amd64 go build -ldflags "-X main.Version=$(VERSION)" -o release/$(BINARY)-$(VERSION)-$@-amd64/ ./...
cd release; tar -czf $(BINARY)-$(VERSION)[email protected] $(BINARY)-$(VERSION)-$@-amd64
.PHONY: windows
windows:
mkdir -p release/$(BINARY)-$(VERSION)-$@-amd64
mkdir -p release/$(BINARY)-$(VERSION)-$@-amd64/config
cp config/config.toml release/$(BINARY)-$(VERSION)-$@-amd64/config
cp -r web release/$(BINARY)-$(VERSION)-$@-amd64
cp database/lilbib.sql release/$(BINARY)-$(VERSION)-$@-amd64
GOOS=$@ GOARCH=amd64 go build -ldflags "-X main.Version=$(VERSION)" -o release/$(BINARY)-$(VERSION)-$@-amd64/ ./...
cd release; zip -qr $(BINARY)-$(VERSION)[email protected] $(BINARY)-$(VERSION)-$@-amd64
%/:
mkdir -p $*