-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
262 lines (215 loc) · 5.79 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
#
# Identify environment information
#
FetchCmd=wget
ifeq ($(OS),Windows_NT)
OSName=windows
else ifeq ($(shell uname -s),Darwin)
OSName=macos
FetchCmd=curl -OL
else ifeq ($(shell uname -s),FreeBSD)
OSName=freebsd
FetchCmd=/usr/bin/fetch
else ifeq ($(shell uname -s),OpenBSD)
OSName=openbsd
FetchCmd=/usr/bin/ftp
else ifeq ($(shell uname -s),NetBSD)
OSName=netbsd
FetchCmd=/usr/bin/ftp -o $(KernelArchiveName)
else
OSName=linux
endif
GitVersion=$(shell git tag -l --contains HEAD)
ifeq ("$(GitVersion)","")
GitVersion=$(shell git rev-parse --short HEAD)
endif
#
# Set OS-specific variables
#
ifeq ($(OSName),windows)
Slash=\\\\
ArchiveSuffix=.zip
BinarySuffix=.exe
All=clisp ccl sbcl
PS=powershell.exe -Command
else
Slash=/
ArchiveSuffix=.tar.gz
BinarySuffix=
All=clisp ccl ecl sbcl
ifeq ($(OSName),freebsd)
All=ccl ecl sbcl
else ifeq ($(OSName),openbsd)
All=ecl sbcl
else ifeq ($(OSName),netbsd)
All=clisp ecl
endif
endif
CCL=ccl
CLISP=clisp
ECL=ecl
SBCL=sbcl
ifeq ($(TRAVIS_OS_NAME),windows)
SBCL="$(SBCL_PATH)/sbcl.exe" --core "$(SBCL_PATH)/sbcl.core"
endif
#
# Set shared variables
#
KernelVersion=22.3
UrlRoot=https://github.com/Shen-Language/shen-sources/releases/download
KernelTag=shen-$(KernelVersion)
KernelFolderName=ShenOSKernel-$(KernelVersion)
KernelArchiveName=$(KernelFolderName)$(ArchiveSuffix)
KernelArchiveUrl=$(UrlRoot)/$(KernelTag)/$(KernelArchiveName)
BinaryName=shen$(BinarySuffix)
ShenCLisp=.$(Slash)bin$(Slash)clisp$(Slash)$(BinaryName)
ShenCCL=.$(Slash)bin$(Slash)ccl$(Slash)$(BinaryName)
ShenECL=.$(Slash)bin$(Slash)ecl$(Slash)$(BinaryName)
ShenSBCL=.$(Slash)bin$(Slash)sbcl$(Slash)$(BinaryName)
RunCLisp=$(ShenCLisp) --clisp-m 10MB
RunCCL=$(ShenCCL)
RunECL=$(ShenECL)
RunSBCL=$(ShenSBCL)
Tests=eval -e "(cd \"kernel/tests\")" -l README.shen -l tests.shen
ReleaseArchiveName=shen-cl-$(GitVersion)-$(OSName)-prebuilt$(ArchiveSuffix)
SourceReleaseName=shen-cl-$(GitVersion)-sources
#
# Aggregates and defaults
#
.DEFAULT: all
.PHONY: all
all: $(All)
.PHONY: clisp
clisp: build-clisp test-clisp
.PHONY: ccl
ccl: build-ccl test-ccl
.PHONY: ecl
ecl: build-ecl test-ecl
.PHONY: sbcl
sbcl: build-sbcl test-sbcl
.PHONY: run
run: run-sbcl
#
# Dependency retrieval
#
.PHONY: fetch
fetch:
ifeq ($(OSName),windows)
$(PS) "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \
Invoke-WebRequest -Uri $(KernelArchiveUrl) -OutFile $(KernelArchiveName)"
$(PS) "Expand-Archive $(KernelArchiveName) -DestinationPath ."
$(PS) "if (Test-Path $(KernelArchiveName)) { Remove-Item $(KernelArchiveName) -Force -ErrorAction Ignore }"
$(PS) "if (Test-Path kernel) { Remove-Item kernel -Recurse -Force -ErrorAction Ignore }"
$(PS) "Rename-Item $(KernelFolderName) kernel -ErrorAction Ignore"
else
$(FetchCmd) $(KernelArchiveUrl)
tar zxf $(KernelArchiveName)
rm -f $(KernelArchiveName)
rm -rf kernel
mv $(KernelFolderName) kernel
endif
#
# Precompilation into Lisp code
#
.PHONY: precompile
precompile:
ifndef SHEN
$(info Usage: make precompile SHEN=path/to/shen.exe)
$(error SHEN variable is not defined)
else
mkdir -p compiled
$(SHEN) eval -l scripts/build.shen -e "(build)"
endif
#
# Build an implementation
#
.PHONY: build-clisp
build-clisp:
$(CLISP) -i boot.lsp
.PHONY: build-ccl
build-ccl:
$(CCL) -l boot.lsp
.PHONY: build-ecl
build-ecl:
$(ECL) -norc -load boot.lsp
.PHONY: build-sbcl
build-sbcl:
$(SBCL) --load boot.lsp
#
# Test an implementation
#
.PHONY: test-clisp
test-clisp:
$(RunCLisp) $(Tests)
.PHONY: test-ccl
test-ccl:
$(RunCCL) $(Tests)
.PHONY: test-ecl
test-ecl:
$(RunECL) $(Tests)
.PHONY: test-sbcl
test-sbcl:
$(RunSBCL) $(Tests)
#
# Run an implementation
#
.PHONY: run-clisp
run-clisp:
$(RunCLisp) $(Args)
.PHONY: run-ccl
run-ccl:
$(RunCCL) $(Args)
.PHONY: run-ecl
run-ecl:
$(RunECL) $(Args)
.PHONY: run-sbcl
run-sbcl:
$(RunSBCL) $(Args)
#
# Packaging
#
.PHONY: release
release:
ifeq ($(OSName),windows)
$(PS) "New-Item -Path release -Force -ItemType Directory"
$(PS) "Compress-Archive -Force -DestinationPath release\\$(ReleaseArchiveName) -LiteralPath $(ShenSBCL), LICENSE.txt"
else ifeq ($(OSName),linux)
mkdir -p release
tar -vczf release/$(ReleaseArchiveName) $(ShenSBCL) LICENSE.txt --transform 's?.*/??g'
else
mkdir -p release
tar -vczf release/$(ReleaseArchiveName) -s '?.*/??g' $(ShenSBCL) LICENSE.txt
endif
.PHONY: source-release
source-release:
ifeq ($(OSName),windows)
$(PS) "New-Item -Path release -Force -ItemType Directory"
$(PS) "New-Item -Path release\\$(SourceReleaseName) -Force -ItemType Directory"
$(PS) "Copy-Item -Path src, compiled, scripts, tests, assets, Makefile, boot.lsp, LICENSE.txt, README.md, CHANGELOG.md, INTEROP.md, PREREQUISITES.md -Recurse -Destination release\\$(SourceReleaseName)"
$(PS) "cd release; Compress-Archive -Force -DestinationPath $(SourceReleaseName)$(ArchiveSuffix) -LiteralPath $(SourceReleaseName)"
$(PS) "Remove-Item -LiteralPath release\\$(SourceReleaseName) -Force -Recurse"
else ifeq ($(OSName),linux)
mkdir -p release
tar -vczf release/$(SourceReleaseName)$(ArchiveSuffix) src compiled scripts tests assets Makefile boot.lsp LICENSE.txt README.md CHANGELOG.md INTEROP.md PREREQUISITES.md --transform "s?^?$(SourceReleaseName)/?g"
else
mkdir -p release
tar -vczf release/$(SourceReleaseName)$(ArchiveSuffix) -s "?^?$(SourceReleaseName)/?g" src compiled scripts tests assets Makefile boot.lsp LICENSE.txt README.md CHANGELOG.md INTEROP.md PREREQUISITES.md
endif
#
# Cleanup
#
.PHONY: clean
clean:
ifeq ($(OSName),windows)
$(PS) "if (Test-Path bin) { Remove-Item bin -Recurse -Force -ErrorAction Ignore }"
$(PS) "if (Test-Path release) { Remove-Item release -Recurse -Force -ErrorAction Ignore }"
else
rm -rf bin release
endif
.PHONY: pure
pure: clean
ifeq ($(OSName),windows)
$(PS) "if (Test-Path kernel) { Remove-Item kernel -Recurse -Force -ErrorAction Ignore }"
else
rm -rf kernel
endif