-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
47 lines (39 loc) · 1.16 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
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
BINARY_NAME=BiliDownloader
# Determine the OS and architecture
ifeq ($(OS),Windows_NT)
OSFLAG := windows
EXTENSION := .exe
else
OSFLAG := $(shell uname | tr '[:upper:]' '[:lower:]')
EXTENSION :=
endif
build: $(BINARY_NAME)
$(BINARY_NAME):
$(GOBUILD) -o $(BINARY_NAME)$(EXTENSION) -v ./cmd
# Build for Linux
linux:
go env -w CGO_ENABLED="0" GOOS="linux" GOARCH="amd64"
$(GOBUILD) -o $(BINARY_NAME)_linux_amd64 -v ./cmd
go env -w CGO_ENABLED="1" GOOS="windows" GOARCH="amd64"
# Build for Mac
darwin_x86:
go env -w CGO_ENABLED="0" GOOS="darwin" GOARCH="amd64"
$(GOBUILD) -o $(BINARY_NAME)_darwin_amd64 -v ./cmd
go env -w CGO_ENABLED="1" GOOS="windows" GOARCH="amd64"
darwin_arm:
go env -w CGO_ENABLED="0" GOOS="darwin" GOARCH="arm64"
$(GOBUILD) -o $(BINARY_NAME)_darwin_arm64 -v ./cmd
go env -w CGO_ENABLED="1" GOOS="windows" GOARCH="amd64"
# Build for Windows
windows:
go env -w CGO_ENABLED="1" GOOS="windows" GOARCH="amd64"
$(GOBUILD) -o $(BINARY_NAME)_windows_amd64$(EXTENSION) -v ./cmd
clean:
$(GOCLEAN)
rm -f $(BINARY_NAME)*$(EXTENSION)