-
Notifications
You must be signed in to change notification settings - Fork 41
/
Makefile
146 lines (128 loc) · 4.16 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
#
# Identify environment information
#
ifeq ($(OS),Windows_NT)
OSName=windows
else ifeq ($(shell uname -s),Darwin)
OSName=macos
else
OSName=linux
endif
Tag=$(shell git tag -l --contains HEAD)
ifeq ("$(Tag)","")
GitVersion=$(shell git rev-parse --short HEAD)
else
GitVersion=$(Tag:shen-%=%)
endif
#
# Set OS-specific variables
#
ifeq ($(OSName),windows)
Slash=\\\\
ArchiveSuffix=.zip
BinarySuffix=.exe
PS=powershell.exe -Command
else
Slash=/
ArchiveSuffix=.tar.gz
BinarySuffix=
endif
#
# Set shared variables
#
ShenSchemeVersion=0.35
UrlRoot=https://github.com/tizoc/shen-scheme/releases/download
ShenSchemeTag=v$(ShenSchemeVersion)
ShenSchemeFolderName=shen-scheme-$(ShenSchemeTag)-$(OSName)-bin
ShenSchemeArchiveName=$(ShenSchemeFolderName)$(ArchiveSuffix)
ShenSchemeArchiveUrl=$(UrlRoot)/$(ShenSchemeTag)/$(ShenSchemeArchiveName)
ifndef Shen
Shen=.$(Slash)shen-scheme$(Slash)bin$(Slash)shen-scheme$(BinarySuffix)
endif
ReleaseFolderName=ShenOSKernel-$(GitVersion)
ReleaseZip=$(ReleaseFolderName).zip
ReleaseTar=$(ReleaseFolderName).tar
ReleaseTarGz=$(ReleaseTar).gz
#
# KLambda rendering
#
.DEFAULT: klambda
.PHONY: klambda
klambda:
ifeq ($(OSName),windows)
$(PS) "if (Test-Path klambda) { Remove-Item klambda -Recurse -Force -ErrorAction Ignore }"
$(PS) "New-Item -Path klambda -Force -ItemType Directory"
else
rm -rf klambda
mkdir -p klambda
endif
$(Shen) eval -l make.shen -e "(make)"
#
# Dependency retrieval
#
.PHONY: fetch
fetch:
ifeq ($(OSName),windows)
$(PS) "Invoke-WebRequest -Uri $(ShenSchemeArchiveUrl) -OutFile $(ShenSchemeArchiveName)"
$(PS) "Expand-Archive $(ShenSchemeArchiveName) -DestinationPath $(ShenSchemeFolderName)"
$(PS) "if (Test-Path $(ShenSchemeArchiveName)) { Remove-Item $(ShenSchemeArchiveName) -Force -ErrorAction Ignore }"
$(PS) "if (Test-Path shen-scheme) { Remove-Item shen-scheme -Recurse -Force -ErrorAction Ignore }"
$(PS) "Rename-Item $(ShenSchemeFolderName)$(Slash)$(ShenSchemeFolderName) shen-scheme -ErrorAction Ignore"
$(PS) "Remove-Item $(ShenSchemeFolderName) -Recurse -Force -ErrorAction Ignore"
else
wget $(ShenSchemeArchiveUrl)
mkdir -p $(ShenSchemeFolderName)
tar xf $(ShenSchemeArchiveName)
rm -f $(ShenSchemeArchiveName)
rm -rf shen-scheme
mv $(ShenSchemeFolderName) shen-scheme
endif
#
# Packging
#
.PHONY: release
release:
ifeq ($(OSName),windows)
$(PS) "New-Item -Path release -Force -ItemType Directory"
$(PS) "if (Test-Path $(ReleaseFolderName)) { Remove-Item $(ReleaseFolderName) -Recurse -Force -ErrorAction Ignore }"
$(PS) "New-Item -Path $(ReleaseFolderName) -Force -ItemType Directory"
$(PS) "Copy-Item -Recurse assets $(ReleaseFolderName)"
$(PS) "Copy-Item -Recurse doc $(ReleaseFolderName)"
$(PS) "Copy-Item -Recurse extensions $(ReleaseFolderName)"
$(PS) "Copy-Item -Recurse klambda $(ReleaseFolderName)"
$(PS) "Copy-Item -Recurse sources $(ReleaseFolderName)"
$(PS) "Copy-Item -Recurse stlib $(ReleaseFolderName)"
$(PS) "Copy-Item -Recurse tests $(ReleaseFolderName)"
$(PS) "Copy-Item CHANGELOG.md $(ReleaseFolderName)"
$(PS) "Copy-Item LICENSE.txt $(ReleaseFolderName)"
$(PS) "Copy-Item README.md $(ReleaseFolderName)"
$(PS) "Compress-Archive -Force -DestinationPath release\\$(ReleaseZip) -LiteralPath $(ReleaseFolderName)"
7z a -ttar -so $(ReleaseTar) $(ReleaseFolderName) | 7z a -si release\\\\$(ReleaseTarGz)
$(PS) "if (Test-Path $(ReleaseFolderName)) { Remove-Item $(ReleaseFolderName) -Recurse -Force -ErrorAction Ignore }"
else
mkdir -p release
rm -rf $(ReleaseFolderName)
mkdir -p $(ReleaseFolderName)
cp -rf assets doc extensions klambda sources stlib tests CHANGELOG.md LICENSE.txt README.md $(ReleaseFolderName)
zip -r release/$(ReleaseZip) $(ReleaseFolderName)
tar -vczf release/$(ReleaseTarGz) $(ReleaseFolderName)
rm -rf $(ReleaseFolderName)
endif
#
# Cleanup
#
.PHONY: clean
clean:
ifeq ($(OSName),windows)
$(PS) "if (Test-Path klambda) { Remove-Item klambda -Recurse -Force -ErrorAction Ignore }"
$(PS) "if (Test-Path release) { Remove-Item release -Recurse -Force -ErrorAction Ignore }"
else
rm -rf klambda release
endif
.PHONY: pure
pure: clean
ifeq ($(OSName),windows)
$(PS) "if (Test-Path shen-scheme) { Remove-Item shen-scheme -Recurse -Force -ErrorAction Ignore }"
else
rm -rf shen-scheme
endif