-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
39 lines (26 loc) · 1.4 KB
/
Makefile
File metadata and controls
39 lines (26 loc) · 1.4 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
NAME := trezord
PLATFORMS := linux-arm64 linux-x64 win-x64 # mac-x64
GITHASH := $(shell git rev-parse --short HEAD)
GOFLAGS := -a -ldflags="-X 'main.githash=$(GITHASH)'"
LINUX_CFLAGS := -Wno-deprecated-declarations
MAC_CFLAGS := -Wno-deprecated-declarations -Wno-unknown-warning-option
WIN_CFLAGS := -Wno-deprecated-declarations -Wno-implicit-function-declaration -Wno-stringop-overflow
BUILD_DIR := build
TARGETS := $(foreach platform,$(PLATFORMS),$(BUILD_DIR)/$(NAME)-$(platform))
all: $(TARGETS)
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
$(BUILD_DIR)/$(NAME)-linux-arm64: $(BUILD_DIR)
CC=aarch64-unknown-linux-gnu-gcc CGO_ENABLED=1 CGO_CFLAGS="$(LINUX_CFLAGS)" GOOS=linux GOARCH=arm64 go build $(GOFLAGS) -o $(BUILD_DIR)/$(NAME)-linux-arm64
$(BUILD_DIR)/$(NAME)-linux-x64: $(BUILD_DIR)
CC=gcc CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CGO_CFLAGS="$(LINUX_CFLAGS)" go build $(GOFLAGS) -o $(BUILD_DIR)/$(NAME)-linux-x64
$(BUILD_DIR)/$(NAME)-mac-x64: $(BUILD_DIR)
CC=x86_64-apple-darwin14-clang CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 CGO_CFLAGS="$(MAC_CFLAGS)" go build $(GOFLAGS) -o $(BUILD_DIR)/$(NAME)-mac-x64
$(BUILD_DIR)/$(NAME)-win-x64: $(BUILD_DIR)
CC=x86_64-w64-mingw32-gcc CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CGO_CFLAGS="$(WIN_CFLAGS)" go build $(GOFLAGS) -o $(BUILD_DIR)/$(NAME)-win-x64
native:
CGO_ENABLED=1 go build $(GOFLAGS)
check:
file $(TARGETS)
clean:
rm -f $(TARGETS)