forked from orbitalquark/scintillua
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
124 lines (107 loc) · 4.06 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
# Copyright 2010-2020 Mitchell. See LICENSE.
# Make file for LexLPeg external lexer for Scintilla.
ifeq (win, $(MAKECMDGOALS))
CC = x86_64-w64-mingw32-gcc
CXX = x86_64-w64-mingw32-g++
plat_flag =
LUA_CFLAGS = -D_WIN32 -DWIN32
LDFLAGS = -g -static -mwindows -s LexLPeg.def -Wl,--enable-stdcall-fixup
lexer = lexers/LexLPeg.dll
luadoc = luadoc_start.bat
else
CC = gcc -fPIC
CXX = g++ -fPIC
plat_flag = -DGTK
LUA_CFLAGS = -DLUA_USE_LINUX
LDFLAGS = -g -Wl,-soname,liblexlpeg.so.0 -Wl,-fvisibility=hidden
lexer = lexers/liblexlpeg.so
luadoc = luadoc
endif
# Scintilla.
sci_flags = --std=c++17 -g -pedantic $(plat_flag) -Iscintilla/include \
-Iscintilla/lexlib -DSCI_LEXER -W -Wall -Wno-unused
lex_objs = PropSetSimple.o WordList.o LexerModule.o LexerSimple.o LexerBase.o \
Accessor.o DefaultLexer.o
# Lua.
lua_objs = lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o \
linit.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o \
lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o \
lauxlib.o lbaselib.o lbitlib.o lcorolib.o ldblib.o liolib.o \
lmathlib.o loadlib.o loslib.o lstrlib.o ltablib.o lutf8lib.o
lua_lib_objs = lpcap.o lpcode.o lpprint.o lptree.o lpvm.o
# Build.
all: $(lexer)
win: $(lexer)
deps: scintilla lua lua/src/lib/lpeg
$(lex_objs): %.o: scintilla/lexlib/%.cxx
$(CXX) $(sci_flags) -c $<
$(lua_objs): %.o: lua/src/%.c
$(CC) -Os -std=c99 -Ilua/src $(LUA_CFLAGS) -c $<
$(lua_lib_objs): %.o: lua/src/lib/%.c
$(CC) -std=c99 -Os -Ilua/src $(LUA_CFLAGS) -c $<
LexLPeg.o: LexLPeg.cxx
$(CXX) $(sci_flags) $(LUA_CFLAGS) -Ilua/src -c $<
$(lexer): $(lex_objs) $(lua_objs) $(lua_lib_objs) LexLPeg.o
$(CXX) -shared $(LDFLAGS) -o $@ $^
clean: ; rm -f *.o
# Documentation.
docs: docs/index.md docs/api.md $(wildcard docs/*.md) | \
docs/_layouts/default.html
for file in $(basename $^); do \
cat $| | docs/fill_layout.lua $$file.md > $$file.html; \
done
docs/index.md: README.md
sed -e 's/^\# [[:alpha:]]\+/## Introduction/;' -e \
's|https://[[:alpha:]]\+\.github\.io/[[:alpha:]]\+/||;' $< > $@
docs/api.md: lexers/lexer.lua scintillua.luadoc
$(luadoc) --doclet docs/markdowndoc $^ > $@
cleandocs: ; rm -f docs/*.html docs/index.md docs/api.md
# Releases.
basedir = scintillua_$(shell grep '^\#\#\#' docs/changelog.md | head -1 | \
cut -d ' ' -f 2)
ifneq (, $(shell hg summary 2>/dev/null))
archive = hg archive -X ".hg*" $(1)
else
archive = git archive HEAD --prefix $(1)/ | tar -xf -
endif
$(basedir): ; $(call archive,$@)
release: $(basedir)
make clean deps docs
make -j4
make clean && make -j4 CC=i686-w64-mingw32-gcc CXX=i686-w64-mingw32-g++ \
win && mv lexers/LexLPeg.dll lexers/LexLPeg32.dll
make clean && make -j4 win
cp -r docs $<
cp lexers/*.so lexers/*.dll $</lexers/
zip -r $<.zip $< && rm -r $<
# Tests.
tests: test-lexers test-scite test-wscite
test-lexers: tests.lua ; lua5.1 $<
# Tests SciTE GTK using ~/.SciTEUser.properties.
test-scite: scintilla
make -C scintilla/gtk -j4
make -C scite/gtk -j4
scite/bin/SciTE
# Tests, via Wine, SciTE Win64 using SciTEGlobal.properties.
wscite_zip = wscite445.zip
/tmp/$(wscite_zip): ; wget -O $@ https://www.scintilla.org/$(wscite_zip)
/tmp/wscite: /tmp/$(wscite_zip)
unzip -d /tmp $<
ln -s `pwd`/lexers /tmp/wscite
sed -i 's/technology=1/technology=0/;' /tmp/wscite/SciTEGlobal.properties
echo "import lexers/lpeg" >> /tmp/wscite/SciTEGlobal.properties
echo "lexilla.context.lpeg.color.theme=light" >> \
/tmp/wscite/SciTEGlobal.properties
test-wscite: /tmp/wscite
cd /tmp/wscite && WINEPREFIX=`pwd`/.wine WINEARCH=win64 wine SciTE
# External dependencies.
scintilla_tgz = scintilla445.tgz
lua_tgz = lua-5.3.5.tar.gz
lpeg_tgz = lpeg-1.0.2.tar.gz
$(scintilla_tgz): ; wget https://www.scintilla.org/$@
scintilla: | $(scintilla_tgz) ; tar xzf $|
$(lua_tgz): ; wget http://www.lua.org/ftp/$@
$(lpeg_tgz): ; wget http://www.inf.puc-rio.br/~roberto/lpeg/$@
lua: | $(lua_tgz) ; mkdir $@ && tar xzf $| -C $@ && mv $@/*/* $@
lua/src/lib/lpeg: | $(lpeg_tgz)
mkdir -p $@ && tar xzf $| -C $@ && mv $@/*/*.c $@/*/*.h $(dir $@)