-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
73 lines (63 loc) · 2.21 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
70
71
72
73
NAME=xmlpaste
VERSION=1.1.0
GOCMD=go
GOBUILD=$(GOCMD) build
DIST_DIR=dist
MACOS_DIR=macos
MACOS_ALT_DIR=macos-alt
WINDOWS_DIR=windows-x64
DIST_MACOS_DIR=$(NAME)-$(VERSION)-$(MACOS_DIR)
DIST_WINDOWS_DIR=$(NAME)-$(VERSION)-$(WINDOWS_DIR)
all: build
.PHONY: clean
clean:
@rm -rf $(DIST_DIR)
build: build-macos build-windows
ifeq ($(shell uname -m),x86_64)
build-macos:
mkdir -p $(DIST_DIR)/$(MACOS_DIR)
GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 $(GOBUILD) -ldflags "-X main.version=$(VERSION)" -o $(DIST_DIR)/$(MACOS_DIR)/$(NAME)
else
build-macos:
mkdir -p $(DIST_DIR)/$(MACOS_DIR)
GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 $(GOBUILD) -ldflags "-X main.version=$(VERSION)" -o $(DIST_DIR)/$(MACOS_DIR)/$(NAME)
endif
ifeq ($(shell uname -m),x86_64)
build-macos-alt:
mkdir -p $(DIST_DIR)/$(MACOS_ALT_DIR)
GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 $(GOBUILD) -ldflags "-X main.version=$(VERSION)" -o $(DIST_DIR)/$(MACOS_ALT_DIR)/$(NAME)
else
build-macos-alt:
mkdir -p $(DIST_DIR)/$(MACOS_ALT_DIR)
GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 $(GOBUILD) -ldflags "-X main.version=$(VERSION)" -o $(DIST_DIR)/$(MACOS_ALT_DIR)/$(NAME)
endif
build-windows:
mkdir -p $(DIST_DIR)/$(WINDOWS_DIR)
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 $(GOBUILD) -ldflags "-X main.version=$(VERSION)" -o $(DIST_DIR)/$(WINDOWS_DIR)/$(NAME).exe
.PHONY: dist
dist-multiplatform: build
cd $(DIST_DIR) && \
mv $(MACOS_DIR) $(DIST_MACOS_DIR) && \
cp -p ../LICENSE.txt $(DIST_MACOS_DIR)/ && \
cp -p ../README.md $(DIST_MACOS_DIR)/ && \
cp -p ../release-notes.txt $(DIST_MACOS_DIR)/ && \
cd ..
cd $(DIST_DIR) && \
mv $(WINDOWS_DIR) $(DIST_WINDOWS_DIR) && \
cp -p ../LICENSE.txt $(DIST_WINDOWS_DIR)/ && \
cp -p ../README.md $(DIST_WINDOWS_DIR)/ && \
cp -p ../release-notes.txt $(DIST_WINDOWS_DIR)/ && \
zip -r $(DIST_WINDOWS_DIR).zip $(DIST_WINDOWS_DIR) && \
cd ..
ifeq ($(shell uname),Darwin)
dist: dist-multiplatform build-macos-alt
cd $(DIST_DIR) && \
mv $(DIST_MACOS_DIR)/$(NAME) $(DIST_MACOS_DIR)/$(NAME).tmp && \
lipo -create $(DIST_MACOS_DIR)/$(NAME).tmp $(MACOS_ALT_DIR)/$(NAME) -output $(DIST_MACOS_DIR)/$(NAME) && \
rm -f $(MACOS_ALT_DIR)/$(NAME) && \
rmdir $(MACOS_ALT_DIR) && \
rm -f $(DIST_MACOS_DIR)/$(NAME).tmp && \
cd ..
else
dist: dist-multiplatform
endif