-
Notifications
You must be signed in to change notification settings - Fork 35
/
Makefile
151 lines (125 loc) · 2.99 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# Allow packagers to override PREFIX with their distribution standard
PREFIX?=${HOME}/.local
# Do magic to turn make arguments into command line arguments for executable invocation
ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
$(eval $(ARGS):;@:)
# Do some magic to figure out host's OS and ARCH.
# This will be used later to build RID for publishing of a self-contained binary.
OS_ID :=
ARCH_ID :=
ifeq ($(OS),Windows_NT)
OS_ID := win
ifeq ($(PROCESSOR_ARCHITEW6432),AMD64)
ARCH_ID := x64
else
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
ARCH_ID := x64
endif
ifeq ($(PROCESSOR_ARCHITECTURE),x86)
ARCH_ID := x32
endif
endif
else
UNAME_S := $(shell uname -s)
TARGET := $(shell uname -m)
ifeq ($(UNAME_S),Linux)
OS_ID := linux
endif
ifeq ($(UNAME_S),Darwin)
OS_ID := osx
endif
ifeq ($(UNAME_S),FreeBSD)
OS_ID := freebsd
endif
ifeq ($(TARGET),x86_64)
ARCH_ID := x64
endif
ifeq ($(TARGET),amd64)
ARCH_ID := x64
endif
ifeq ($(TARGET),x86)
ARCH_ID := x86
endif
ifeq ($(TARGET),arm)
ARCH_ID := arm
endif
ifeq ($(TARGET),arm64)
ARCH_ID := arm64
endif
ifeq ($(TARGET),aarch64)
ARCH_ID := arm64
endif
endif
RID := $(OS_ID)-$(ARCH_ID)
.PHONY: setup
setup:
dotnet tool restore
.PHONY: check
check: setup
dotnet fantomas --check Marksman
.PHONY: build
build:
dotnet build Marksman/Marksman.fsproj
.PHONY: test
test:
dotnet test
.PHONY: clean
clean:
dotnet clean
.PHONY: run
run:
dotnet run --project Marksman -- $(ARGS)
.PHONY: bench
bench:
dotnet run -c Release --project Benchmarks -- $(ARGS)
.PHONY: fmt
fmt: setup
dotnet fantomas Marksman
dotnet fantomas Tests
dotnet fantomas Benchmarks
ifneq ($(OS_ID),win)
xmllint Marksman/Marksman.fsproj -o Marksman/Marksman.fsproj
endif
.PHONY: publish
publish:
dotnet publish -c Release -r $(RID) --self-contained true \
-p:PublishSingleFile=true \
-p:PublishTrimmed=true \
-p:TrimMode=partial \
-p:DebugType=embedded \
-p:EnableCompressionInSingleFile=true \
-p:UseAppHost=true \
Marksman/Marksman.fsproj
.PHONY: publishTo
publishTo:
dotnet publish -c Release -r $(RID) --self-contained true \
-p:PublishSingleFile=true \
-p:PublishTrimmed=true \
-p:TrimMode=partial \
-p:DebugType=embedded \
-p:EnableCompressionInSingleFile=true \
-p:VersionString=$(VERSIONSTRING) \
-p:UseAppHost=true \
Marksman/Marksman.fsproj \
-o $(DEST)
.PHONY: macosUniversalBinary
macosUniversalBinary:
$(MAKE) publishTo DEST=$(DEST) RID=osx-x64
mv $(DEST)/marksman $(DEST)/marksman-x64
$(MAKE) publishTo DEST=$(DEST) RID=osx-arm64
mv $(DEST)/marksman $(DEST)/marksman-arm64
lipo -create -output $(DEST)/marksman $(DEST)/marksman-x64 $(DEST)/marksman-arm64
# Install the binary to $HOME/.local/bin folder
.PHONY: install
ifeq ($(OS_ID),win)
install: publish
cmd /C scripts\install.bat
else
install: publish
mkdir -p $(PREFIX)/bin
install -m755 Marksman/bin/Release/net8.0/$(RID)/publish/marksman $(PREFIX)/bin
endif
.PHONY: uninstall
uninstall:
rm -rf $(PREFIX)/bin/marksman
.DEFAULT_GOAL := build