-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
41 lines (34 loc) · 1.07 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
BINARY_NAME := "deps-cleaner"
ARCH := $(or $(GOARCH),$(shell uname -m))
OS := $(or $(GOOS),$(shell uname))
ifneq (,$(filter $(OS),Darwin darwin MacOS macos))
OS := darwin
else ifneq (,$(filter $(OS),Linux linux))
OS := linux
else
OS := windows
endif
ifeq ($(ARCH),x86_64)
ARCH := amd64
else ifeq ($(ARCH),i386)
ARCH := 386
endif
build:
@echo "Building $(OS) $(ARCH) binary..."
@GOOS=$(OS) GOARCH=$(ARCH) go build $(ARGS) -o "bin/$(BINARY_NAME)" main.go
build_all:
@echo "Building linux amd64 binary..."
@GOOS=linux GOARCH=amd64 go build -o "bin/$(BINARY_NAME)-linux-amd64" main.go
@echo "Building darwin amd64 binary..."
@GOOS=darwin GOARCH=amd64 go build -o "bin/$(BINARY_NAME)-darwin-amd64" main.go
@echo "Building darwin arm64 binary..."
@GOOS=darwin GOARCH=arm64 go build -o "bin/$(BINARY_NAME)-darwin-arm64" main.go
@echo "Building windows amd64 binary..."
@GOOS=windows GOARCH=amd64 go build -o "bin/$(BINARY_NAME)-windows-amd64.exe" main.go
clean:
@echo "Cleaning..."
@go clean
@rm -rf bin/*
run: build
@echo "Running..."
@./bin/$(BINARY_NAME)-$(OS)-$(ARCH)