forked from mintty/wsltty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
262 lines (209 loc) · 7.8 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
#############################################################################
# build a wsltty installer package:
# configure ver=... and minttyver= in this makefile
# make targets:
# make [all] build a distributable installer (default)
# make pkg build an installer, bypassing the system checks
# make wsltty build the software, using the local copy of mintty
# wsltty release
ver=3.1.4
# wsltty appx release - must have 4 parts!
verx=3.1.4.0
# mintty release version
minttyver=3.1.4
# wslbridge2 release version
wslbridgever=0.5
##############################
# mintty branch or commit version
#minttyver=master
# wslbridge branch or commit to build from source;
wslbridge=wslbridge-frontend wslbridge-backend
##############################
# Windows SDK version for appx
WINSDKKEY=/HKEY_LOCAL_MACHINE/SOFTWARE/WOW6432Node/Microsoft/.NET Framework Platform/Setup/Multi-Targeting Pack
WINSDKVER=`regtool list '$(WINSDKKEY)' | sed -e '$$ q' -e d`
#############################################################################
# default target
all: all-$(notdir $(CURDIR))
all-wsltty: check pkg
all-wsltty.appx: appx
#############################################################################
# target checking and some defs
TARGET := $(shell $(CC) -dumpmachine)
ifeq ($(TARGET), i686-pc-cygwin)
sys := cygwin32
else ifeq ($(TARGET), x86_64-pc-cygwin)
sys := cygwin64
else ifeq ($(TARGET), i686-pc-msys)
sys := msys32
else ifeq ($(TARGET), x86_64-pc-msys)
sys := msys64
else
$(error Target '$(TARGET)' not supported)
endif
wget=curl -R -L --connect-timeout 55 -O
wgeto=curl -R -L --connect-timeout 55
#############################################################################
# system check:
# - ensure the path name drag-and-drop adaptation works (-> Cygwin, not MSYS)
# - 64 Bit (x86_64) for more stable invocation (avoid fork issues)
arch:=$(shell uname -m)
check: # checkarch
echo Building for:
echo $(arch) | grep .
# checking suitable host environment; run `make pkg` to bypass
# check cygwin (vs msys) for proper drag-and-drop paths:
uname | grep CYGWIN
checkarch:
# check 32 bit to ensure 32-Bit Windows support, just in case:
#uname -m | grep i686
# check 64 bit to provide 64-Bit stability support:
#uname -m | grep x86_64
#############################################################################
# patch version information for appx package configuration
fix-verx:
echo patching $(WINSDKVER) into Launcher config
cd Launcher; sed -i~ -e "/<supportedRuntime / s,Version=v[.0-9]*,Version=$(WINSDKVER)," app.config
echo patched app.config
cd Launcher; sed -i~ -e "/<TargetFrameworkVersion>/ s,v[.0-9]*,$(WINSDKVER)," Launcher.csproj
echo patched Launcher.csproj
echo patching $(verx) into app config
sed -i~ -e '/<Identity / s,Version="[.0-9]*",Version="$(verx)",' AppxManifest.xml
echo patched AppxManifest.xml
#############################################################################
# generation
wslbridge: $(wslbridge)
wslbridge2-$(wslbridgever).zip:
$(wgeto) https://github.com/Biswa96/wslbridge2/archive/v$(wslbridgever).zip -o wslbridge2-$(wslbridgever).zip
wslbridge-source: wslbridge2-$(wslbridgever).zip
unzip -ou wslbridge2-$(wslbridgever).zip
cp wslbridge2-$(wslbridgever)/LICENSE LICENSE.wslbridge2
wslbridge-frontend: wslbridge-source
echo ------------- Compiling wslbridge2 frontend
mkdir -p bin
# frontend build
cd wslbridge2-$(wslbridgever)/src; make -f Makefile.frontend RELEASE=1
# extract binaries
cp wslbridge2-$(wslbridgever)/bin/wslbridge2.exe bin/
# build backend on a musl-libc-based distribution
BuildDistr=Alpine
windir=$(shell cd "${WINDIR}"; pwd)
wslbridge-backend: wslbridge-source
echo ------------- Compiling wslbridge2 backend
#uname -m | grep x86_64
mkdir -p bin
# provide dependencies for backend build
PATH="$(windir)/Sysnative:${PATH}" cmd /C wsl.exe -u root -d $(BuildDistr) $(shell env | grep http_proxy=) apk add make g++ linux-headers < /dev/null
# invoke backend build
cd wslbridge2-$(wslbridgever)/src; PATH="$(windir)/Sysnative:${PATH}" cmd /C wsl.exe -d $(BuildDistr) make -f Makefile.backend RELEASE=1 < /dev/null
# extract binaries
cp wslbridge2-$(wslbridgever)/bin/wslbridge2-backend bin/
mintty-get:
$(wgeto) https://github.com/mintty/mintty/archive/$(minttyver).zip -o mintty-$(minttyver).zip
unzip -o mintty-$(minttyver).zip
cp mintty-$(minttyver)/icon/terminal.ico mintty.ico
wslbuild=LDFLAGS="-static -static-libgcc -s"
appxbuild=$(wslbuild) CCOPT=-DWSLTTY_APPX
wslversion=VERSION_SUFFIX="– wsltty $(ver)" WSLTTY_VERSION="$(ver)"
appxversion=VERSION_SUFFIX="– wsltty appx $(verx)" WSLTTY_VERSION="$(verx)"
mintty-build:
# ensure rebuild of version-specific check and message
rm -f mintty-$(minttyver)/bin/*/windialog.o
# build mintty
cd mintty-$(minttyver)/src; make $(wslbuild) $(wslversion)
mkdir -p bin
cp mintty-$(minttyver)/bin/mintty.exe bin/
strip bin/mintty.exe
mintty-build-appx:
# ensure rebuild of version-specific check and message
rm -f mintty-$(minttyver)/bin/*/windialog.o
# build mintty
cd mintty-$(minttyver)/src; make $(appxbuild) $(appxversion)
mkdir -p bin
cp mintty-$(minttyver)/bin/mintty.exe bin/
strip bin/mintty.exe
mintty-pkg:
cp mintty-$(minttyver)/LICENSE LICENSE.mintty
cd mintty-$(minttyver)/lang; zoo a lang *.po; mv lang.zoo ../../
cd mintty-$(minttyver)/themes; zoo a themes *[!~]; mv themes.zoo ../../
cd mintty-$(minttyver)/sounds; zoo a sounds *.wav *.WAV *.md; mv sounds.zoo ../../
# add charnames.txt to support "Character Info"
cd mintty-$(minttyver)/src; sh ./mknames
cp mintty-$(minttyver)/src/charnames.txt .
mintty-appx:
mkdir -p usr/share/mintty
cd usr/share/mintty; mkdir -p lang themes sounds info
cp mintty-$(minttyver)/lang/*.po usr/share/mintty/lang/
cp mintty-$(minttyver)/themes/*[!~] usr/share/mintty/themes/
cp mintty-$(minttyver)/sounds/*.wav usr/share/mintty/sounds/
cp mintty-$(minttyver)/sounds/*.WAV usr/share/mintty/sounds/
# add charnames.txt to support "Character Info"
cd mintty-$(minttyver)/src; sh ./mknames
cp mintty-$(minttyver)/src/charnames.txt usr/share/mintty/info/
cygwin: # mkshortcutexe
mkdir -p bin
cp /bin/cygwin1.dll bin/
cp /bin/cygwin-console-helper.exe bin/
cp /bin/dash.exe bin/
cp /bin/regtool.exe bin/
cp /bin/zoo.exe bin/
mkshortcutexe: bin/mkshortcut.exe
bin/mkshortcut.exe: mkshortcut.c
echo mksh
gcc -o bin/mkshortcut mkshortcut.c -lpopt -lole32 /usr/lib/w32api/libuuid.a
cp /bin/cygpopt-0.dll bin/
cp /bin/cygiconv-2.dll bin/
cp /bin/cygintl-8.dll bin/
appx-bin:
mkdir -p bin
cp /bin/cygwin1.dll bin/
cp /bin/cygwin-console-helper.exe bin/
cop: ver
mkdir -p rel
rm -f rel/wsltty-$(ver)-install-$(arch).exe
sed -e "s,%version%,$(ver)," -e "s,%arch%,$(arch)," makewinx.cfg > rel/wsltty.SED
cp bin/cygwin1.dll rel/
cp bin/cygwin-console-helper.exe rel/
cp bin/dash.exe rel/
cp bin/regtool.exe rel/
cp bin/mintty.exe rel/
cp bin/zoo.exe rel/
cp lang.zoo rel/
cp themes.zoo rel/
cp sounds.zoo rel/
cp charnames.txt rel/
cp bin/wslbridge2.exe rel/
cp bin/wslbridge2-backend rel/
cp mkshortcut.vbs rel/
#cp bin/mkshortcut.exe rel/
#cp bin/cygpopt-0.dll rel/
#cp bin/cygiconv-2.dll rel/
#cp bin/cygintl-8.dll rel/
cp LICENSE.* rel/
cp VERSION rel/
cp *.lnk rel/
cp *.ico rel/
cp *.url rel/
cp *.bat rel/
cp *.sh rel/
cp *.vbs rel/
cab: cop
cd rel; iexpress /n wsltty.SED
install: cop installbat
installbat:
cd rel; cmd /C install
ver:
echo $(ver) > VERSION
mintty: mintty-get mintty-build
mintty-usr: mintty-get mintty-appx
# local wsltty build target:
wsltty: wslbridge cygwin mintty-build mintty-pkg
# standalone wsltty package build target:
pkg: wslbridge cygwin mintty-get mintty-build mintty-pkg cab
# appx package contents target:
wsltty-appx: wslbridge appx-bin mintty-get mintty-build-appx mintty-appx
# appx package target:
appx: wsltty-appx fix-verx
sh ./build.sh
#############################################################################
# end