-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
47 lines (36 loc) · 935 Bytes
/
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
BINARY:=devbox
PREFIX:=/usr
ARCH := $(shell uname -p)
FMT_REQUIRED:=$(shell gofmt -l $(shell find . -type f -iname *.go))
LDFLAGS=-s -w -X github.com/shinyzenith/devbox/version.Version=$(shell git rev-parse HEAD) -linkmode external -extldflags "-static"
all: zig_static
build: tidy
go build ./cmd/$(BINARY)
strip $(BINARY)
zig_static: tidy
CGO_ENALBED=1 CC="zig cc -target ${ARCH}-linux-musl" go build -v \
-ldflags '${LDFLAGS}' \
./cmd/$(BINARY)/
strip $(BINARY)
musl_static: tidy
CGO_ENALBED=1 CC="musl-gcc" go build -v \
-ldflags '${LDFLAGS}' \
./cmd/$(BINARY)/
strip $(BINARY)
dependencies:
go get -u ./...
go mod tidy
install:
mv $(BINARY) $(PREFIX)/bin/$(BINARY)
check:
@echo $(FMT_REQUIRED)
@test -z $(FMT_REQUIRED)
go vet ./...
test:
go test ./...
tidy:
go mod tidy
clean:
go clean
$(RM) -f $(BINARY)
.PHONY:all build test install clean dependencies musl_static zig_static tidy check