forked from mintty/mintty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
470 lines (375 loc) · 15 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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
#############################################################################
# Interesting make targets:
# - exe: Just the executable. This is the default.
# - zip: Zip for standalone release.
# - clean: Delete generated files.
# make parameter CCOPT, e.g. for make CCOPT=-Wno-unused
# make parameter LDOPT, e.g. for make LDOPT=-lnew-library
#############################################################################
# Variables intended for setting on the make command line.
# - RELEASE: release number for packaging
# - VERSION_SUFFIX: suffix for version information
# - WSLTTY_VERSION: wsltty version to be checked for updates
# - TARGET: target triple for cross compiling
# values: i686-pc-cygwin, x86_64-pc-cygwin, i686-pc-msys, x86_64-pc-msys
# - DEBUG: define to enable debug build
# - DMALLOC: define to enable the dmalloc heap debugging library
#
# The values of DEBUG and DMALLOC variables do not matter, it's just about
# whether they're defined; a debug build can be built with
# make DEBUG=1
#############################################################################
NAME := mintty
.PHONY: exe src pkg zip pdf clean
BINFOLDER = ../bin
#BINDIR = $(BINFOLDER)/$(TARGET)
BINDIR = $(BINFOLDER)/$(platform)
ifdef TARGET
CC := $(TARGET)-gcc
RC := $(TARGET)-windres
else
CC := gcc
RC := windres
TARGET := $(shell $(CC) -dumpmachine)
endif
ifeq ($(TARGET), i686-pc-cygwin)
platform := cygwin32
cygport_opts := --32
zip_files := ../docs/readme.html ../scripts/create_shortcut.js
else ifeq ($(TARGET), x86_64-pc-cygwin)
platform := cygwin64
cygport_opts := --64
zip_files := ../docs/readme.html ../scripts/create_shortcut.js
else ifeq ($(TARGET), i686-pc-msys)
MSYS=$(shell uname -r | sed -e 's,\..*,,')
ifeq ("$(MSYS)", "1")
platform := msys
else
platform := msys32
endif
zip_files := ../docs/readme-msys.html
else ifeq ($(TARGET), x86_64-pc-msys)
platform := msys64
zip_files := ../docs/readme-msys.html
else
# just warning to support cross-generation of data files
warn=[30;48;5;11m
norm=[m
$(warning $(warn) Target '$(TARGET)' not supported $(norm))
endif
CPPFLAGS := -DTARGET=$(TARGET)
ifdef VERSION_SUFFIX
CPPFLAGS += -DVERSION_SUFFIX="$(VERSION_SUFFIX)"
endif
ifdef WSLTTY_VERSION
CPPFLAGS += -DWSLTTY_VERSION="$(WSLTTY_VERSION)"
endif
ifndef RELEASE
svn_rev := $(shell svn info 2>/dev/null | grep ^Revision: | sed 's/Revision: //')
ifneq ($(svn_rev),)
CPPFLAGS += -DSVN_DIR=$(shell basename "`svn info | grep ^URL:`") \
-DSVN_REV=$(svn_rev)
endif
endif
srcversion := \
$(shell echo $(shell echo VERSION | cpp -P $(CPPFLAGS) --include appinfo.h))
name_ver := $(NAME)-$(srcversion)
#############################################################################
# compilation parameters
c_srcs := $(wildcard *.c)
rc_srcs := $(wildcard *.rc)
objs := $(c_srcs:.c=.o) $(rc_srcs:.rc=.o)
bins := $(patsubst %.o,$(BINDIR)/%.o,$(objs))
ifneq ($(platform), msys)
# ensure avoidance of trampolines (a gcc mechanism to implement
# some nested functions) as they cause some security software to choke
SECUR=-Wtrampolines
endif
# support cygwin debug package (use += to accept injected options)
CFLAGS += -std=gnu99 -include std.h -Wall -Wextra -Wundef -Werror
# verify additional flags that are also injected into pkg build by cygport
CFLAGS += -Wformat-security
ifeq ($(shell VER=`$(CC) -dumpversion`; expr $${VER%%.*} '>=' 5), 1)
CFLAGS += -mtune=atom $(SECUR)
endif
scriptlib=-lusp10
#downldlib=-lurlmon
#downldlib="${SYSTEMROOT}/System32/urlmon.dll"
downldlib=
ifneq ($(platform), msys)
emojilib=-lgdiplus
endif
extralibs=$(scriptlib) $(downldlib) $(emojilib) -lshlwapi
LDFLAGS := -L$(shell $(CC) -print-file-name=w32api) -static-libgcc
LDLIBS := -mwindows $(extralibs) -lcomctl32 -limm32 -lwinmm -lwinspool -lole32 -luuid -lmpr
#override LDFLAGS += -L$(shell $(CC) -print-file-name=w32api) -static-libgcc
#override LDLIBS += -mwindows $(extralibs) -lcomctl32 -limm32 -lwinmm -lwinspool -lole32 -luuid
ifdef DEBUG
# CPPFLAGS += -Wno-trampolines
CFLAGS += -g -Wno-error
else
CPPFLAGS += -DNDEBUG
CFLAGS += -fomit-frame-pointer -O2
# support cygwin debug package:
# CFLAGS += -g # not needed; -ggdb and more injected by cygport
# do not LDFLAGS += -s
endif
ifdef DMALLOC
CPPFLAGS += -DDMALLOC
LDLIBS += -ldmallocth
endif
#############################################################################
# build
all: bin
DEPOPT=-MMD -MP
#DEPOPT=
CCOPT=
CCFLAGS:=$(CFLAGS) $(CCOPT)
$(BINDIR)/term%.o: term%.c
$(CC) -c $(DEPOPT) $(CCFLAGS) $(CPPFLAGS) $< -o $(BINDIR)/term$*.o
$(BINDIR)/term.o: term.c emojibase.t emojiseqs.t
$(CC) -c $(DEPOPT) $(CCFLAGS) $(CPPFLAGS) -fstack-check $< -o $(BINDIR)/term.o
# do not optimize wintext.c; this causes a mysterious delay if
# win_char_width is called with a non-BMP character
$(BINDIR)/wintext.o: wintext.c
$(CC) -c $(DEPOPT) $(CCFLAGS) -O0 $(CPPFLAGS) -fstack-check $< -o $(BINDIR)/wintext.o
$(BINDIR)/appinfo.o: appinfo.c appinfo.h appinfo.t
$(CC) -c $(DEPOPT) -O0 $(CPPFLAGS) -fstack-check $< -o $(BINDIR)/appinfo.o
$(BINDIR)/%.o: %.c
$(CC) -c $(DEPOPT) $(CCFLAGS) $(CPPFLAGS) -fstack-check $< -o $(BINDIR)/$*.o
$(BINDIR)/%.o: %.rc %.h %.mft
#$(RC) -c 65001 --preprocessor '$(CC) -E -xc -DRC_INVOKED $(DEPOPT) $(CPPFLAGS)' $< $(BINDIR)/$*.o
# broken in binutils 2.36; workaround:
$(CC) -E -xc -DRC_INVOKED $(DEPOPT) $(CPPFLAGS) $< | $(RC) -c 65001 -o $(BINDIR)/$*.o
-mv $*.d $(BINDIR)/
gitversion := $(shell ./mkvertag "$(srcversion)")
appinfo.t: stamp
stamp:
echo "#define VERSION_STAMP \"$(gitversion)\"" > appinfo.n
cmp appinfo.n appinfo.t && rm -f appinfo.n || /bin/mv appinfo.n appinfo.t
exe := $(NAME).exe
exe: $(exe)
$(exe): $(objs)
$(CC) $(LDFLAGS) $^ $(LDLIBS) $(LDOPT) -o $@
#-du -b $@
bin := $(BINDIR)/$(NAME).exe
bin: stamp $(BINDIR) $(bin)
$(BINDIR):
mkdir -p $(BINDIR)
$(bin): $(bins)
$(CC) $(LDFLAGS) $^ $(LDLIBS) $(LDOPT) -o $@
cp -f $@ $(BINFOLDER)/ # for 'dobin' install in .cygport
# support simpler debugging:
-test -f `basename $@` && cp -fp $@ ./ || true
# report size of exe:
#-type du && du -b $@ || true
#-include $(wildcard *.d)
-include $(wildcard $(BINDIR)/*.d)
#############################################################################
# generate
#WGET=wget -N -t 1 --timeout=55
WGET=curl -R -O --connect-timeout 55
WGET+=-z $@
clean-x11:
rm -f rgb.t composed.t
rgb.t: # /usr/share/X11/rgb.txt # X11 color names, from package 'rgb'
# 255 250 250 snow
# ->
# {255, 250, 250, "snow"},
sed -e 's, , ,g' -e 's/ *\([0-9][0-9]*\) *\([0-9][0-9]*\) *\([0-9][0-9]*\) *\([^ ].*[^ ]\) */ {\1, \2, \3, "\4"},/' /usr/share/X11/rgb.txt > rgb.t
combdata=combining.t combdouble.t combined.t formatting.t
unidata=$(combdata) ambiguous.t scripts.t blocks.t casefold.t bidiclasses.t mirroring.t brackets.t canonical.t wide.t unicodever.t
emojidata=emojibase.t emojiseqs.t
unicodedata=UnicodeData.txt EastAsianWidth.txt Blocks.txt Scripts.txt CaseFolding.txt BidiMirroring.txt BidiBrackets.txt BidiCharacterTest.txt BidiTest.txt NameAliases.txt
unicodeemoji=emoji-data.txt emoji-sequences.txt emoji-variation-sequences.txt emoji-zwj-sequences.txt emoji-test.txt
clean-unicode:
rm -f $(unidata) $(emojidata)
clean-unicode-data: clean-unicode
rm -f $(unicodedata) $(unicodeemoji)
unicode-update: clean-unicode-data bin
combining.t: # UnicodeData.txt Blocks.txt
uniset +cat=Me +cat=Mn +cat=Cf -00AD +1160-11FF +200B +D7B0-D7C6 +D7CB-D7FB c > combining.t
# xterm 373:
#uniset +cat=Me +cat=Mn +0600-0605 +061C +06DD +070F +1160-11FF +D7B0-D7C6 +D7CB-D7FB c > combining.t
formatting.t: # UnicodeData.txt Blocks.txt
# xterm 373:
#uniset +cat=Cf -00AD -0600-0605 -061C -06DD -070F c > formatting.t
ambiguous.t: # WIDTH-A # UnicodeData.txt Blocks.txt
sh ./mkwidthA
uniset +WIDTH-A -cat=Me -cat=Mn -cat=Cf c > ambiguous.t
combdouble=$(shell sed -e "s,^\([^;]*\);.*Mn;23[34];.*, +\1," -e t -e d UnicodeData.txt )
combdouble.t: # UnicodeData.txt Blocks.txt
uniset $(combdouble) c > combdouble.t
WIDTH-A: # UnicodeData.txt Blocks.txt EastAsianWidth.txt
sh ./mkwidthA
wide.t: # UnicodeData.txt Blocks.txt EastAsianWidth.txt
sh ./mkwide
scripts.t: # Scripts.txt
sh ./mkscripts
blocks.t: # Blocks.txt
sh ./mkblocks
casefold.t: # CaseFolding.txt
sh ./mkcasefold > casefold.t
combined.t: # UnicodeData.txt
sh ./mkcombinedt > combined.t
bidiclasses.t: # UnicodeData.txt
sh ./mkbidiclasses > bidiclasses.t
mirroring.t: # BidiMirroring.txt
sh ./mkmirroring > mirroring.t
brackets.t: # BidiBrackets.txt
sh ./mkbrackets
canonical.t: # BidiBrackets.txt UnicodeData.txt
sh ./mkbrackets
testbidi.exe: testbidi.tc minibidi.c # BidiCharacterTest.txt BidiTest.txt
$(CC) -x c testbidi.tc -DTEST_BIDI --include std.h minibidi.c -o testbidi.exe
unicode: UnicodeData.txt Blocks.txt EastAsianWidth.txt
#full-emoji-list.html:
# $(WGET) http://www.unicode.org/emoji/charts/$@
univer = `sed -e '/^\# Blocks-/ s,[^0-9]*\([0-9]*\)\.\([0-9]\)\.\([0-9]\)[^0-9]*,\1.\2.\3,' -e t -e d Blocks.txt`
unibasever = `sed -e '/^\# Blocks-/ s,[^0-9]*\([0-9]*\)\..*,\1.0,' -e t -e d Blocks.txt`
# Emoji version may advance Unicode version
#emojiver = $(unibasever)
# extract Emoji version from emoji-data.txt
emojiver = `sed -e 's,^\#.*Emoji Version \([0-9][0-9.]*\).*,\1,' -e t -e d emoji-data.txt`
# override Emoji version if not in sync
##emojiver = 15.0
# until 12.0:
#emoji-%.txt: Blocks.txt
# $(WGET) http://www.unicode.org/Public/emoji/$(unibasever)/$@
# from 13.0:
emoji-sequences.txt: Blocks.txt
$(WGET) http://www.unicode.org/Public/emoji/$(emojiver)/$@
emoji-zwj-sequences.txt: Blocks.txt
$(WGET) http://www.unicode.org/Public/emoji/$(emojiver)/$@
emoji-test.txt: Blocks.txt
$(WGET) http://www.unicode.org/Public/emoji/$(emojiver)/$@
emoji-data.txt: Blocks.txt
$(WGET) http://www.unicode.org/Public/$(univer)/ucd/emoji/$@
emoji-variation-sequences.txt: Blocks.txt
$(WGET) http://www.unicode.org/Public/$(univer)/ucd/emoji/$@
unicodever = $(shell sed -e '/^\# Blocks-/ s,[^0-9]*\([0-9]*\)\.\([0-9]\)\.\([0-9]\)[^0-9]*,\1\2\3,' -e t -e d Blocks.txt)
univer = $(shell sed -e '/^\# Blocks-/ s,[^0-9]*\([0-9]*\)\.\([0-9]\)\.\([0-9]\)[^0-9]*,\1.\2.\3,' -e t -e d Blocks.txt)
x11ver = $(shell cygcheck -f /usr/share/X11/locale/en_US.UTF-8/Compose | sed -e "s,^[^-]*-,," -e "s,-.*,,")
releasever:
sed -e 's,\(Mintty .*\)`.*`,\1`$(srcversion)`,' -i ../wiki/Versions.md
unicodever.t: Blocks.txt
echo "#define UNICODE_VERSION $(unicodever)" > unicodever.t
sed -e 's,\(Unicode .*\)`.*`,\1`$(univer)`,' -i ../wiki/Versions.md
univer: Blocks.txt
echo univer: $(univer)
echo unibasever: $(unibasever)
echo unicodever: $(unicodever)
echo emojiver: $(emojiver)
%.txt:
$(WGET) http://www.unicode.org/Public/UNIDATA/$@
emojibase.t: # emoji-data.txt emoji-variation-sequences.txt emoji-sequences.txt emoji-zwj-sequences.txt
bash ./mkemojis base > $@
emojiseqs.t: # emoji-sequences.txt emoji-zwj-sequences.txt emoji-test.txt
bash ./mkemojis seqs > $@
#compose_list=/usr/share/X11/locale/en_US.UTF-8/Compose
#keysymdefs=/usr/include/X11/keysymdef.h
composed.t: # $(compose_list) $(keysymdefs)
sh ./mkcomposedt > composed.t
sed -e 's,\(X11 .*\)`.*`,\1`$(x11ver)`,' -i ../wiki/Versions.md
XGETTEXT_OPTS=--package-name=mintty #--package-version=$(srcversion)
XGETTEXT_OPTS+=--msgid-bugs-address=https://github.com/mintty/mintty/issues/700
_: localization checkloc
localization: pot po
pot:
mkdir -p ../lang
xgettext --from-code=UTF-8 -k_ -k_W -k__ -c__ $(XGETTEXT_OPTS) *.c appinfo.h -o- | grep -v "^#, c-format" > ../lang/messages.pott
cd ../lang; if diff -I POT-Creation-Date messages.pot messages.pott | grep . > /dev/null; then /bin/mv messages.pott messages.pot; else /bin/rm messages.pott; fi
po:
cd ../lang; for po in *.po; do [ "$$po" = en.po ] || msgmerge -U "$$po" messages.pot; done
checkloc:
cd ../lang; ! grep "^#, fuzzy" *.po
#############################################################################
# release targets
DIST := ../release
ifndef RELEASE
RELEASE=0
endif
ifdef RELEASE
pkg := $(name_ver)-$(RELEASE)
cygport := ../cygwin/mintty.cygport
pkg: $(pkg)
$(pkg): $(cygport) $(src)
cp $(cygport) $(pkg).cygport
cygport $(cygport_opts) $(pkg).cygport almostall
endif
zip := $(DIST)/$(name_ver)-$(platform).zip
zip: $(zip)
$(zip): $(exe) $(zip_files)
mkdir -p $(DIST)
zip -9 -j $@ $^
#-du -b $@
pdf := $(DIST)/$(name_ver).pdf
pdf: $(pdf)
$(pdf): ../docs/$(NAME).1
(echo .fp 5 CR; echo .fp 7 CB; cat $<) | groff -t -man -Tps | ps2pdf - $@
html := ../docs/$(NAME).1.html
html: $(html)
$(html): ../docs/$(NAME).1 htmlroff.sed htmlhtml.sed
sed -f htmlroff.sed $< | groff -t -man -mwww -Thtml | sed -f htmlhtml.sed | tr -d '\003\004' > $@
clean:
#rm -rf *.d *.o $(NAME)*
rm -rf $(BINDIR)/*.d $(BINDIR)/*.o $(BINDIR)/$(NAME)*
check: checksrc checkresource checkloc
# check whether supportedOS Id list is up-to-date
stripsupp=sed -e "/supportedOS/ s,>.*,>," -e t -e d
defsupp=/usr/lib/default-manifest.o
checkresource:
$(stripsupp) res.mft > .osmin
cat "$(defsupp)" /dev/null | strings | $(stripsupp) > .osdef
if [ -f "$(defsupp)" ]; then diff .osdef .osmin; else true; fi
rm -f .osdef .osmin
# check whether sources are free of remaining debugging code
SRCDEBUG:= -e "^(f*printf|\#define debug)" # \# make-escape to #
SRCDEBUG+= -e "^(if|do|for|while) *[({]"
SRCDEBUG+= -e "\((false|0) *&"
SRCDEBUG+= -e "\((true|1) *\|"
#SRCDEBUG+= -e "& 0($|[^bx])"
SRCDEBUG+= -e "\(0 &"
SRCDEBUG+= -e "^///"
checksrc:
if egrep -an $(SRCDEBUG) *.[hc]; then false; fi
if sed -e "s,.*IDM_.*0x\([0-9A-F]*\) *,\1," -e t -e d winids.h | sort | uniq -d | grep .; then false; fi
#############################################################################
# development and debug targets
tags: *.c *.h
ctags -w *.c *.h
_wm.t: # Windows Message names, only for debugging
# #define WM_NULL 0x0000
# ->
# {0x0000, "WM_NULL"},
sed -e 's/^#define \(WM_[^ ]*\) *\(0x[0-9A-Fa-f]*\)$$/ {\2, "\1"},/' -e t -e d /usr/include/w32api/winuser.h | tr 'abcdef' 'ABCDEF' > _wm.t
echo ' {0x02E0, "WM_DPICHANGED"},' >> _wm.t
echo ' {0x02E2, "WM_DPICHANGED_BEFOREPARENT"},' >> _wm.t
echo ' {0x02E3, "WM_DPICHANGED_AFTERPARENT"},' >> _wm.t
echo ' {0x02E4, "WM_GETDPISCALEDSIZE"},' >> _wm.t
# or, with include file copied from Windows SDK:
#sed -e 's/^#define \(WM_[^ ]*\) *\(0x[0-9A-Fa-f]*\)$$/ {\2, "\1"},/' -e t -e d etc/WinUser.h | tr 'abcdef' 'ABCDEF' > _wm.t
_vk.t: # Windows Virtual Key Code names, only for debugging
# #define VK_TAB 0x09
# ->
# {0x09, "VK_TAB"},
sed -e 's/^#define \(VK_[^ ]*\) \(0x[0-9A-Fa-f]*\)$$/ {\2, "\1"},/' -e t -e d /usr/include/w32api/winuser.h > _vk.t
_winidm.t: winids.h
sed -e '$$ d' -e '/#ifdef/ b' -e '/#endif/ b' -e 's/#define *\(IDM_[^ ]*\).*/ {\1, "\1"},/' -e t -e d winids.h > _winidm.t
_wstyles.t: # Windows GWL_STYLE and GWL_EXSTYLE values
./mkstyles > $@
target:
echo TARGET $(TARGET)
echo platform $(platform)
echo BINDIR $(BINDIR)
echo $(bins)
getappinfo=$(shell echo "$(1)" ; echo "$(1)" | cpp -P $(CPPFLAGS) --include appinfo.h)
ver:
echo "$(call getappinfo,VERSION)"
echo "$(call getappinfo,POINT_VERSION)"
echo "$(call getappinfo,COMMA_VERSION)"
echo "$(call getappinfo,DECIMAL_VERSION)"
echo src version $(srcversion)
echo version_stamp $(gitversion)
#############################################################################
# end