-
Notifications
You must be signed in to change notification settings - Fork 61
/
configure
executable file
·736 lines (656 loc) · 25.3 KB
/
configure
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
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
#!/bin/sh
set -e
# --- Global settings -------------------------------------------------------
VERSION=0.9
FILEFORMAT=8
WINCC=${WINCC:-i686-w64-mingw32-gcc}
WINCXX=${WINCC:-i686-w64-mingw32-g++}
WINLINK=${WINLINK:-i686-w64-mingw32-g++}
WINSTRIP=${WINSTRIP:-strip}
WINDRES=${WINDRES:-windres}
MAKENSIS=${MAKENSIS:-makensis}
DATE=${DATE:-$(date +'%-d %B %Y')}
PREFIX=${PREFIX:-$HOME}
PKG_CONFIG=${PKG_CONFIG:-pkg-config}
DEFCC=${CC:-cc}
DEFCXX=${CC:-c++}
DEFSTRIP=${STRIP:-strip}
# Must match the Makefile
OBJDIR=.obj
# --- Setup boilerplate -----------------------------------------------------
if [ $# = 0 ]; then
echo "Autodetecting a sensible configuration..."
if [ "$OS" = "Windows_NT" ]; then
echo "Autoconfiguring for Windows"
set release wincon windows test \
-and release glfw windows -nsis
elif type $($PKG_CONFIG --exists glfw3) > /dev/null; then
echo "Autoconfiguring a basic Unix build with glfw"
set debug ncurses test \
-and release ncurses test install=wordgrinder \
-and debug glfw \
-and release glfw install=xwordgrinder \
-install
else
echo "Autoconfiguring a basic Unix build without glfw"
set debug ncurses test -and release ncurses test -install
fi
fi
if [ "$*" = "dev" ]; then
echo "Development build"
set debug ncurses test \
-and release ncurses test \
-and debug glfw test \
-and release glfw test
fi
rm -rf $OBJDIR
mkdir -p $OBJDIR
exec 3> $OBJDIR/build.ninja
cat >&3 <<"EOF"
rule cc
depfile = $out.d
command = $cc -MMD -MF $out.d $cflags -c $in -o $out
rule ld
command = $cc $in -o $out $ldflags
rule multibin
command = sh tools/multibin2c.sh $sym $in > $out
rule wordgrindertest
command = $exe --lua $in > $out 2>&1 || (cat $out && rm -f $out && false)
rule rcfile
command = $windres $in $out
rule makensis
command = $makensis -v2 -nocd -dVERSION=$version -dOUTFILE=$out $in
rule makeicon
command = sh tools/makeicon.sh $in > $out
rule strip
command = cp $in $out && $strip $out
rule install
command = install -m $mode $in $out
rule manpage
command = sed 's/@@@DATE@@@/$date/g; s/@@@VERSION@@@/$version/g' $in > $out
pool test-pool
depth = 1
EOF
add() {
var=$1
shift
eval "$var=\$$var' $*'"
}
# --- Building common stuff -------------------------------------------------
build_luascripts() {
local srcs
srcs=
add srcs src/lua/_prologue.lua
add srcs src/lua/events.lua
add srcs src/lua/main.lua
add srcs src/lua/xml.lua
add srcs src/lua/utils.lua
add srcs src/lua/redraw.lua
add srcs src/lua/settings.lua
add srcs src/lua/document.lua
add srcs src/lua/forms.lua
add srcs src/lua/ui.lua
add srcs src/lua/browser.lua
add srcs src/lua/html.lua
add srcs src/lua/margin.lua
add srcs src/lua/xpattern.lua
add srcs src/lua/fileio.lua
add srcs src/lua/export.lua
add srcs src/lua/export/text.lua
add srcs src/lua/export/html.lua
add srcs src/lua/export/latex.lua
add srcs src/lua/export/troff.lua
add srcs src/lua/export/opendocument.lua
add srcs src/lua/export/org.lua
add srcs src/lua/export/markdown.lua
add srcs src/lua/import.lua
add srcs src/lua/import/html.lua
add srcs src/lua/import/text.lua
add srcs src/lua/import/opendocument.lua
add srcs src/lua/import/markdown.lua
add srcs src/lua/navigate.lua
add srcs src/lua/addons/goto.lua
add srcs src/lua/addons/autosave.lua
add srcs src/lua/addons/docsetman.lua
add srcs src/lua/addons/gui.lua
add srcs src/lua/addons/scrapbook.lua
add srcs src/lua/addons/statusbar_charstyle.lua
add srcs src/lua/addons/statusbar_pagecount.lua
add srcs src/lua/addons/statusbar_position.lua
add srcs src/lua/addons/statusbar_wordcount.lua
add srcs src/lua/addons/debug.lua
add srcs src/lua/addons/look-and-feel.lua
add srcs src/lua/addons/keymapoverride.lua
add srcs src/lua/addons/smartquotes.lua
add srcs src/lua/addons/undo.lua
add srcs src/lua/addons/spillchocker.lua
add srcs src/lua/addons/templates.lua
add srcs src/lua/addons/directories.lua
add srcs src/lua/addons/recents.lua
add srcs src/lua/colours.lua
add srcs src/lua/menu.lua
add srcs src/lua/cli.lua
#add srcs src/lua/lunamark/util.lua
#add srcs src/lua/lunamark/entities.lua
#add srcs src/lua/lunamark/markdown.lua
echo "build $OBJDIR/luascripts.cc : multibin $srcs" >&3
echo " sym = script_table" >&3
}
build_luascripts
build_fonts() {
local src
srcs=
add srcs extras/fonts/FantasqueSansMono-Regular.ttf
add srcs extras/fonts/FantasqueSansMono-Italic.ttf
add srcs extras/fonts/FantasqueSansMono-Bold.ttf
add srcs extras/fonts/FantasqueSansMono-BoldItalic.ttf
echo "build $OBJDIR/fonts.cc : multibin $srcs" >&3
echo " sym = font_table" >&3
}
if [ -e extras/fonts/FantasqueSansMono-Regular.ttf ]; then
build_fonts
fi
build_icon() {
echo "build $OBJDIR/icon.cc : makeicon extras/icon.png | tools/makeicon.sh" >&3
}
build_icon
# --- Building per-configuration stuff --------------------------------------
INSTALLABLES=
reset_configuration() {
CC=$DEFCC
CXX=$DEFCXX
LINKCC=
STRIP=$DEFSTRIP
BOTHFLAGS=
CFLAGS=
CXXFLAGS=
LDFLAGS=
PACKAGES=zlib
FRONTEND=
SRCS=
OBJS=
BUILTIN_LUA=y
BUILTIN_LPEG=y
BUILTIN_MINIZIP=y
BUILTIN_LIBSTB=y
BUILTIN_LIBCLIP=y
DEBUG=
LUA=builtin
TEST=n
WINDOWS=n
INSTALL=
STRIPPING=y
X=
add BOTHFLAGS -g
add BOTHFLAGS -DVERSION=$VERSION
add BOTHFLAGS -DFILEFORMAT=$FILEFORMAT
add BOTHFLAGS -DNOUNCRYPT
add BOTHFLAGS -DNOCRYPT
add BOTHFLAGS -Isrc/c
add BOTHFLAGS -Wall
add BOTHFLAGS -Wno-unused-function
add BOTHFLAGS -Wno-unused-variable
add BOTHFLAGS -Wno-misleading-indentation
add BOTHFLAGS -ffunction-sections
add BOTHFLAGS -fdata-sections
add CFLAGS -Werror=implicit-function-declaration
add CFLAGS --std=gnu99
add CFLAGS -pthread
add LDFLAGS -g
add LDFLAGS -lm
add LDFLAGS -lz
add LDFLAGS -lpthread
}
set_frontend() {
if [ "$FRONTEND" != "" ]; then
echo "You can only set one frontend."
exit 1
fi
FRONTEND=$1
}
install_file() {
echo "build $2 : install $1" >&3
echo " mode=$3" >&3
add INSTALLABLES $2
}
add_configuration() {
if [ "$FRONTEND" = "" ]; then
echo "No frontend specified"
exit 1
fi
if [ "$DEBUG" = "" ]; then
echo "You must specify 'debug' or 'release'"
exit 1
fi
PROFILE=$LUA-$FRONTEND-$DEBUG
EXE=bin/wordgrinder-$PROFILE
O=$OBJDIR/$PROFILE
mkdir -p $O
# Windows special stuff
if [ "$WINDOWS" = "y" ]; then
add BOTHFLAGS -DEMULATED_WCWIDTH
add BOTHFLAGS -DWINSHIM
add BOTHFLAGS -DARCH=windows
add LDFLAGS -static -lssp
add OBJS $OBJDIR/wordgrinder.rc.o
add SRCS src/c/emu/wcwidth.c
add SRCS src/c/emu/lua-5.1.5/winshim.c
CC=$WINCC
CXX=$WINCXX
LINKCC=$WINLINK
STRIP=$WINSTRIP
X=.exe
if [ "$done_common_windows" != "y" ]; then
done_common_windows=y
echo "build $OBJDIR/wordgrinder.rc.o: rcfile src/c/arch/win32/wordgrinder.rc | src/c/arch/win32/manifest.xml" >&3
echo " windres = $WINDRES" >&3
fi
else
add BOTHFLAGS -DARCH=normal
fi
# External dependencies
if [ "$BUILTIN_LUA" = "y" ]; then
add BOTHFLAGS \
-I. \
-I./src/c/luau/Analysis/include \
-I./src/c/luau/Ast/include \
-I./src/c/luau/CodeGen/include \
-I./src/c/luau/Common/include \
-I./src/c/luau/Compiler/include \
-I./src/c/luau/VM/include \
-I./src/c/luau/VM/src
LUAU_SRCS=
add LUAU_SRCS src/c/luau/Analysis/src/Anyification.cpp
add LUAU_SRCS src/c/luau/Analysis/src/ApplyTypeFunction.cpp
add LUAU_SRCS src/c/luau/Analysis/src/AstJsonEncoder.cpp
add LUAU_SRCS src/c/luau/Analysis/src/AstQuery.cpp
add LUAU_SRCS src/c/luau/Analysis/src/Autocomplete.cpp
add LUAU_SRCS src/c/luau/Analysis/src/BuiltinDefinitions.cpp
add LUAU_SRCS src/c/luau/Analysis/src/Clone.cpp
add LUAU_SRCS src/c/luau/Analysis/src/Config.cpp
add LUAU_SRCS src/c/luau/Analysis/src/Constraint.cpp
add LUAU_SRCS src/c/luau/Analysis/src/ConstraintGraphBuilder.cpp
add LUAU_SRCS src/c/luau/Analysis/src/ConstraintSolver.cpp
add LUAU_SRCS src/c/luau/Analysis/src/DataFlowGraph.cpp
add LUAU_SRCS src/c/luau/Analysis/src/DcrLogger.cpp
add LUAU_SRCS src/c/luau/Analysis/src/Def.cpp
add LUAU_SRCS src/c/luau/Analysis/src/EmbeddedBuiltinDefinitions.cpp
add LUAU_SRCS src/c/luau/Analysis/src/Error.cpp
add LUAU_SRCS src/c/luau/Analysis/src/Frontend.cpp
add LUAU_SRCS src/c/luau/Analysis/src/Instantiation.cpp
add LUAU_SRCS src/c/luau/Analysis/src/IostreamHelpers.cpp
add LUAU_SRCS src/c/luau/Analysis/src/JsonEmitter.cpp
add LUAU_SRCS src/c/luau/Analysis/src/LValue.cpp
add LUAU_SRCS src/c/luau/Analysis/src/Linter.cpp
add LUAU_SRCS src/c/luau/Analysis/src/Module.cpp
add LUAU_SRCS src/c/luau/Analysis/src/Normalize.cpp
add LUAU_SRCS src/c/luau/Analysis/src/Quantify.cpp
add LUAU_SRCS src/c/luau/Analysis/src/Refinement.cpp
add LUAU_SRCS src/c/luau/Analysis/src/RequireTracer.cpp
add LUAU_SRCS src/c/luau/Analysis/src/Scope.cpp
add LUAU_SRCS src/c/luau/Analysis/src/Substitution.cpp
add LUAU_SRCS src/c/luau/Analysis/src/Symbol.cpp
add LUAU_SRCS src/c/luau/Analysis/src/ToDot.cpp
add LUAU_SRCS src/c/luau/Analysis/src/ToString.cpp
add LUAU_SRCS src/c/luau/Analysis/src/TopoSortStatements.cpp
add LUAU_SRCS src/c/luau/Analysis/src/Transpiler.cpp
add LUAU_SRCS src/c/luau/Analysis/src/TxnLog.cpp
add LUAU_SRCS src/c/luau/Analysis/src/Type.cpp
add LUAU_SRCS src/c/luau/Analysis/src/TypeArena.cpp
add LUAU_SRCS src/c/luau/Analysis/src/TypeAttach.cpp
add LUAU_SRCS src/c/luau/Analysis/src/TypeChecker2.cpp
add LUAU_SRCS src/c/luau/Analysis/src/TypeInfer.cpp
add LUAU_SRCS src/c/luau/Analysis/src/TypePack.cpp
add LUAU_SRCS src/c/luau/Analysis/src/TypeReduction.cpp
add LUAU_SRCS src/c/luau/Analysis/src/TypeUtils.cpp
add LUAU_SRCS src/c/luau/Analysis/src/TypedAllocator.cpp
add LUAU_SRCS src/c/luau/Analysis/src/Unifiable.cpp
add LUAU_SRCS src/c/luau/Analysis/src/Unifier.cpp
add LUAU_SRCS src/c/luau/Ast/src/Ast.cpp
add LUAU_SRCS src/c/luau/Ast/src/Confusables.cpp
add LUAU_SRCS src/c/luau/Ast/src/Lexer.cpp
add LUAU_SRCS src/c/luau/Ast/src/Location.cpp
add LUAU_SRCS src/c/luau/Ast/src/Parser.cpp
add LUAU_SRCS src/c/luau/Ast/src/StringUtils.cpp
add LUAU_SRCS src/c/luau/Ast/src/TimeTrace.cpp
add LUAU_SRCS src/c/luau/CodeGen/src/AssemblyBuilderA64.cpp
add LUAU_SRCS src/c/luau/CodeGen/src/AssemblyBuilderX64.cpp
add LUAU_SRCS src/c/luau/CodeGen/src/CodeAllocator.cpp
add LUAU_SRCS src/c/luau/CodeGen/src/CodeBlockUnwind.cpp
add LUAU_SRCS src/c/luau/CodeGen/src/CodeGen.cpp
add LUAU_SRCS src/c/luau/CodeGen/src/CodeGenUtils.cpp
add LUAU_SRCS src/c/luau/CodeGen/src/CodeGenX64.cpp
add LUAU_SRCS src/c/luau/CodeGen/src/EmitBuiltinsX64.cpp
add LUAU_SRCS src/c/luau/CodeGen/src/EmitCommonX64.cpp
add LUAU_SRCS src/c/luau/CodeGen/src/EmitInstructionX64.cpp
add LUAU_SRCS src/c/luau/CodeGen/src/Fallbacks.cpp
add LUAU_SRCS src/c/luau/CodeGen/src/IrAnalysis.cpp
add LUAU_SRCS src/c/luau/CodeGen/src/IrBuilder.cpp
add LUAU_SRCS src/c/luau/CodeGen/src/IrDump.cpp
add LUAU_SRCS src/c/luau/CodeGen/src/IrLoweringX64.cpp
add LUAU_SRCS src/c/luau/CodeGen/src/IrRegAllocX64.cpp
add LUAU_SRCS src/c/luau/CodeGen/src/IrTranslateBuiltins.cpp
add LUAU_SRCS src/c/luau/CodeGen/src/IrTranslation.cpp
add LUAU_SRCS src/c/luau/CodeGen/src/IrUtils.cpp
add LUAU_SRCS src/c/luau/CodeGen/src/NativeState.cpp
add LUAU_SRCS src/c/luau/CodeGen/src/OptimizeConstProp.cpp
add LUAU_SRCS src/c/luau/CodeGen/src/OptimizeFinalX64.cpp
add LUAU_SRCS src/c/luau/CodeGen/src/UnwindBuilderDwarf2.cpp
add LUAU_SRCS src/c/luau/CodeGen/src/UnwindBuilderWin.cpp
add LUAU_SRCS src/c/luau/Compiler/src/BuiltinFolding.cpp
add LUAU_SRCS src/c/luau/Compiler/src/Builtins.cpp
add LUAU_SRCS src/c/luau/Compiler/src/BytecodeBuilder.cpp
add LUAU_SRCS src/c/luau/Compiler/src/Compiler.cpp
add LUAU_SRCS src/c/luau/Compiler/src/ConstantFolding.cpp
add LUAU_SRCS src/c/luau/Compiler/src/CostModel.cpp
add LUAU_SRCS src/c/luau/Compiler/src/TableShape.cpp
add LUAU_SRCS src/c/luau/Compiler/src/ValueTracking.cpp
add LUAU_SRCS src/c/luau/Compiler/src/lcode.cpp
add LUAU_SRCS src/c/luau/VM/src/lapi.cpp
add LUAU_SRCS src/c/luau/VM/src/laux.cpp
add LUAU_SRCS src/c/luau/VM/src/lbaselib.cpp
add LUAU_SRCS src/c/luau/VM/src/lbitlib.cpp
add LUAU_SRCS src/c/luau/VM/src/lbuiltins.cpp
add LUAU_SRCS src/c/luau/VM/src/lcorolib.cpp
add LUAU_SRCS src/c/luau/VM/src/ldblib.cpp
add LUAU_SRCS src/c/luau/VM/src/ldebug.cpp
add LUAU_SRCS src/c/luau/VM/src/ldo.cpp
add LUAU_SRCS src/c/luau/VM/src/lfunc.cpp
add LUAU_SRCS src/c/luau/VM/src/lgc.cpp
add LUAU_SRCS src/c/luau/VM/src/lgcdebug.cpp
add LUAU_SRCS src/c/luau/VM/src/linit.cpp
add LUAU_SRCS src/c/luau/VM/src/lmathlib.cpp
add LUAU_SRCS src/c/luau/VM/src/lmem.cpp
add LUAU_SRCS src/c/luau/VM/src/lnumprint.cpp
add LUAU_SRCS src/c/luau/VM/src/lobject.cpp
add LUAU_SRCS src/c/luau/VM/src/loslib.cpp
add LUAU_SRCS src/c/luau/VM/src/lperf.cpp
add LUAU_SRCS src/c/luau/VM/src/lstate.cpp
add LUAU_SRCS src/c/luau/VM/src/lstring.cpp
add LUAU_SRCS src/c/luau/VM/src/lstrlib.cpp
add LUAU_SRCS src/c/luau/VM/src/ltable.cpp
add LUAU_SRCS src/c/luau/VM/src/ltablib.cpp
add LUAU_SRCS src/c/luau/VM/src/ltm.cpp
add LUAU_SRCS src/c/luau/VM/src/ludata.cpp
add LUAU_SRCS src/c/luau/VM/src/lutf8lib.cpp
add LUAU_SRCS src/c/luau/VM/src/lvmexecute.cpp
add LUAU_SRCS src/c/luau/VM/src/lvmload.cpp
add LUAU_SRCS src/c/luau/VM/src/lvmutils.cpp
add SRCS $LUAU_SRCS
echo "build $OBJDIR/luau_analyse : cc $LUAU_SRCS" >&3
echo " cflags = $CXXFLAGS" >&3
echo " cc = $CXX" >&3
echo "default $OBJDIR/luau_analyse" >&3
fi
#if [ "$BUILTIN_LPEG" = "y" ]; then
# add BOTHFLAGS -Isrc/c/emu/lpeg
# add SRCS src/c/emu/lpeg/lpvm.c
# add SRCS src/c/emu/lpeg/lpcap.c
# add SRCS src/c/emu/lpeg/lptree.c
# add SRCS src/c/emu/lpeg/lpcode.c
# add SRCS src/c/emu/lpeg/lpprint.c
#fi
if [ "$BUILTIN_MINIZIP" = "y" ]; then
add BOTHFLAGS -Isrc/c/emu/minizip
add SRCS src/c/emu/minizip/ioapi.c
add SRCS src/c/emu/minizip/zip.c
add SRCS src/c/emu/minizip/unzip.c
fi
if [ "$BUILTIN_LIBSTB" = "y" ]; then
add BOTHFLAGS -Isrc/c/emu/libstb
add SRCS src/c/emu/libstb/stb.c
fi
if [ "$BUILTIN_LIBCLIP" = "y" ]; then
add BOTHFLAGS -Isrc/c/emu/clip
add SRCS src/c/emu/clip/clip.cpp
add SRCS src/c/emu/clip/image.cpp
if [ "$(uname)" = "Darwin" ]; then
add SRCS src/c/emu/clip/clip_osx.mm
add LDFLAGS -framework Cocoa
elif [ "$OS" = "Windows_NT" ]; then
add SRCS src/c/emu/clip/clip_win.cpp
elif [ "$FRONTEND" = "ncurses" ]; then
add SRCS src/c/emu/clip/clip_none.cpp
else
add SRCS src/c/emu/clip/clip_x11.cpp
add LDFLAGS -lxcb
fi
fi
# This must go *after* any other include or library path configuration,
# to make sure any builtin headers get found before the system ones.
if [ "$PACKAGES" != "" ]; then
add BOTHFLAGS $($PKG_CONFIG --cflags $PACKAGES)
add LDFLAGS $($PKG_CONFIG --libs $PACKAGES)
fi
# Main core
add SRCS src/c/utils.cc
add SRCS src/c/filesystem.cc
add SRCS src/c/zip.cc
add SRCS src/c/main.cc
add SRCS src/c/lua.cc
add SRCS src/c/word.cc
add SRCS src/c/screen.cc
add SRCS src/c/clipboard.cc
add SRCS $OBJDIR/luascripts.cc
# Frontends
case $FRONTEND in
ncurses)
add SRCS src/c/arch/ncurses/dpy.cc
add BOTHFLAGS -DFRONTEND=ncurses
;;
wincon)
add SRCS src/c/arch/win32/console/dpy.cc
add SRCS src/c/arch/win32/console/realmain.cc
add BOTHFLAGS -Dmain=appMain
add BOTHFLAGS -mconsole
add BOTHFLAGS -DFRONTEND=wincon
add LDFLAGS -mconsole -lole32 -lshlwapi -lwindowscodecs
;;
glfw)
add SRCS src/c/arch/glfw/main.cc
add SRCS src/c/arch/glfw/font.cc
add SRCS src/c/arch/glfw/utils.cc
add SRCS $OBJDIR/fonts.cc
add SRCS $OBJDIR/icon.cc
add BOTHFLAGS -DFRONTEND=glfw
add CFLAGS $($PKG_CONFIG --cflags glfw3)
add LDFLAGS $($PKG_CONFIG --libs glfw3)
if $($PKG_CONFIG --exists opengl); then
add CFLAGS $($PKG_CONFIG --cflags opengl)
add LDFLAGS $($PKG_CONFIG --libs opengl)
elif [ "$(uname)" = "Darwin" ]; then
add LDFLAGS -framework OpenGL
elif [ "$OS" = "Windows_NT" ]; then
add LDFLAGS -lopengl32 -lgdi32 -lole32 -lshlwapi -lwindowscodecs -mwindows
else
echo "No OpenGL found"
exit 1
fi
;;
esac
local objs
for f in $SRCS; do
obj=$O/${f%*.[cm]?}.o
add OBJS $obj
case $f in
*.c)
echo "build $obj : cc $f" >&3
echo " cflags = $BOTHFLAGS $CFLAGS" >&3
echo " cc = $CC" >&3
;;
*.cc|*.cpp|*.mm)
echo "build $obj : cc $f" >&3
echo " cflags = $BOTHFLAGS $CXXFLAGS" >&3
echo " cc = $CXX" >&3
;;
esac
done
if [ "$LINKCC" = "" ]; then
LINKCC=$CXX
fi
if [ "$STRIPPING" = "y" ]; then
echo "build $EXE-unstripped$X : ld $OBJS" >&3
echo " ldflags = $LDFLAGS" >&3
echo " cc = $LINKCC" >&3
echo "build $EXE$X : strip $EXE-unstripped$X" >&3
echo " strip = $STRIP" >&3
echo "default $EXE$X" >&3
else
echo "build $EXE$X : ld $OBJS" >&3
echo " ldflags = $LDFLAGS" >&3
echo " cc = $LINKCC" >&3
fi
if [ "$INSTALL" != "" ]; then
install_file $EXE $PREFIX/bin/$INSTALL 755
fi
if [ "$TEST" = "y" ]; then
local tests
tests=
local testdeps
testdeps=
add tests tests/apply-markup.lua
add tests tests/argument-parser.lua
add tests tests/change-paragraph-style.lua
add tests tests/clipboard.lua
add tests tests/delete-selection.lua
add tests tests/escape-strings.lua
add tests tests/export-to-html.lua
add tests tests/export-to-latex.lua
add tests tests/export-to-markdown.lua
add tests tests/export-to-opendocument.lua
add tests tests/export-to-text.lua
add tests tests/export-to-troff.lua
add tests tests/filesystem.lua
add tests tests/find-and-replace.lua
add tests tests/get-style-from-word.lua
add tests tests/immutable-paragraphs.lua
add tests tests/import-from-html.lua
#add tests tests/import-from-markdown.lua
add tests tests/import-from-opendocument.lua
add tests tests/import-from-text.lua
add tests tests/insert-space-with-style-hint.lua
add tests tests/line-down-into-style.lua
add tests tests/line-up.lua
add tests tests/line-wrapping.lua
add tests tests/load-0.1.lua
add tests tests/load-0.2.lua
add tests tests/load-0.3.3.lua
add tests tests/load-0.4.1.lua
add tests tests/load-0.5.3.lua
add tests tests/load-0.6-v6.lua
add tests tests/load-0.6.lua
add tests tests/load-0.7.2.lua
add tests tests/load-0.8.crlf.lua
add tests tests/load-0.8.lua
add tests tests/load-failed.lua
add tests tests/lowlevelclipboard.lua
add tests tests/move-while-selected.lua
add tests tests/numbered-lists.lua
add tests tests/parse-string-into-words.lua
add tests tests/save-format-escaped-strings.lua
add tests tests/simple-editing.lua
add tests tests/smartquotes-selection.lua
add tests tests/smartquotes-typing.lua
add tests tests/spellchecker.lua
add tests tests/tableio.lua
add tests tests/type-while-selected.lua
add tests tests/undo.lua
add tests tests/utf8.lua
add tests tests/utils.lua
add tests tests/weirdness-cannot-save-settings.lua
add tests tests/weirdness-combining-words.lua
add tests tests/weirdness-delete-word.lua
add tests tests/weirdness-deletion-with-multiple-spaces.lua
add tests tests/weirdness-end-of-lines.lua
add tests tests/weirdness-forward-delete.lua
add tests tests/weirdness-globals-applied-on-startup.lua
add tests tests/weirdness-missing-clipboard.lua
add tests tests/weirdness-replacing-words.lua
add tests tests/weirdness-save-new-document.lua
add tests tests/weirdness-splitting-lines-before-space.lua
add tests tests/weirdness-stray-control-char-in-export.lua
add tests tests/weirdness-style-bleeding-on-deletion.lua
add tests tests/weirdness-styled-clipboard.lua
add tests tests/weirdness-styling-unicode.lua
add tests tests/weirdness-upgrade-0.6-with-clipboard.lua
add tests tests/weirdness-word-left-from-end-of-line.lua
add tests tests/weirdness-word-right-to-last-word-in-doc.lua
add tests tests/windows-installdir.lua
add tests tests/word.lua
add tests tests/xpattern.lua
add testdeps tests/testsuite.lua
for f in testdocs/*; do
add testdeps $f
done
for f in $tests; do
stampfile=$O/${f%*.lua}.stamp
echo "build $stampfile : wordgrindertest $f | $EXE$X $testdeps" >&3
echo " exe = $EXE$X" >&3
echo " pool = test-pool" >&3
echo "default $stampfile" >&3
done
fi
}
add_nsis() {
echo "build bin/WordGrinder-$VERSION-setup.exe : makensis extras/windows-installer.nsi | bin/wordgrinder-builtin-glfw-release.exe bin/wordgrinder-builtin-wincon-release.exe" >&3
echo " makensis = $MAKENSIS" >&3
echo "default bin/WordGrinder-$VERSION-setup.exe" >&3
}
add_install() {
install_file extras/wordgrinder.desktop $PREFIX/share/applications/wordgrinder.desktop 644
install_file extras/wordgrinder.xml $PREFIX/share/mime/packages/wordgrinder.xml 644
install_file extras/icon.png $PREFIX/share/icons/hicolor/256x256/apps/wordgrinder.png 644
install_file README.wg $PREFIX/doc/wordgrinder/README.wg 644
install_file $OBJDIR/wordgrinder.1 $PREFIX/man/man1/wordgrinder.1 644
install_file $OBJDIR/xwordgrinder.1 $PREFIX/man/man1/xwordgrinder.1 644
echo "build $OBJDIR/wordgrinder.1 : manpage wordgrinder.man" >&3
echo " date = $DATE" >&3
echo " version = $VERSION" >&3
echo "default $OBJDIR/wordgrinder.1" >&3
echo "build $OBJDIR/xwordgrinder.1 : manpage xwordgrinder.man" >&3
echo " date = $DATE" >&3
echo " version = $VERSION" >&3
echo "default $OBJDIR/xwordgrinder.1" >&3
}
reset_configuration
while [ $# != 0 ]; do
case $1 in
-and)
add_configuration
reset_configuration
;;
debug) add BOTHFLAGS -O0; add LDFLAGS -O0; DEBUG=debug ;;
release) add BOTHFLAGS -Os -DNDEBUG; add LDFLAGS -Os; DEBUG=release ;;
profile) add BOTHFLAGS -pg -Os -DNDEBUG; add LDFLAGS -pg -Os; DEBUG=release ;;
lua=*) BUILTIN_LUA=n; add PACKAGES ${1#*=}; LUA=${1#*=} ;;
lpeg=*) BUILTIN_LPEG=n; add PACKAGES ${1#*=} ;;
minizip=*) BUILTIN_MINIZIP=n; add PACKAGES ${1#*=} ;;
libstb=*) BUILTIN_LIBSTB=n; add PACKAGES ${1#*=} ;;
libclip=*) BUILTIN_LIBCLIP=n; add PACKAGES ${1#*=} ;;
wincon) set_frontend wincon ;;
glfw) set_frontend glfw ;;
ncurses) set_frontend ncurses; add PACKAGES ncursesw ;;
ncurses=*) set_frontend ncurses; add PACKAGES ${1#*=} ;;
test) TEST=y ;;
windows) WINDOWS=y ;;
install=*) INSTALL=${1#*=} ;;
nostrip) STRIPPING=n ;;
-nsis)
add_nsis
;;
-install)
add_install
;;
*)
echo "Unknown keyword '$1'"
exit 1
;;
esac
shift
done
add_configuration
if [ "$INSTALLABLES" != "" ]; then
echo "build install : phony $INSTALLABLES" >&3
echo "Configured for prefix $PREFIX"
fi
# vim: sw=4 ts=4 et