forked from Shen-Language/shen-cl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
218 lines (176 loc) · 4.13 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
#
# Identify environment information
#
FetchCmd=wget
ifeq ($(OS),Windows_NT)
OSName=windows
else ifeq ($(shell uname -s),Darwin)
OSName=macos
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
#
# Set shared variables
#
KernelVersion=21.1
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=-e "(do (cd \"kernel/tests\") (load \"README.shen\") (load \"tests.shen\"))"
ReleaseArchiveName=shen-cl-$(GitVersion)-$(OSName)-prebuilt$(ArchiveSuffix)
#
# 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
#
# 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)
#
# Packging
#
.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
mkdir -p release
tar -vczf release/$(ReleaseArchiveName) $(ShenSBCL) LICENSE.txt --transform 's?.*/??g'
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