-
Notifications
You must be signed in to change notification settings - Fork 56
/
Makefile
executable file
·125 lines (108 loc) · 3.98 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
VERSION=$(shell cat VERSION)
UNAME=$(shell uname)
EXTRA_FLAGS?=
ifneq ("$(wildcard /usr/bin/olpc-hwinfo)","")
# building on an OLPC; use SDL 1.2
SDL=$(shell sdl-config --cflags --libs)
SDL:=$(SDL) -lSDL_image
else
SDL=$(shell sdl2-config --cflags --libs)
SDL:=$(SDL) -lSDL2_image
endif
ifeq ($(UNAME),Darwin)
OPEN=open
COMPILER=clang
FLAGS=-Wall -Werror -Wextra -Wpedantic -Os -Wstrict-prototypes
# -Wno-misleading-indentation silences warnings which are entirely spurious.
FLAGS:=$(FLAGS) -Wno-misleading-indentation -Wno-unknown-warning-option
# FLAGS:=$(FLAGS) -fsanitize=undefined
# FLAGS:=$(FLAGS) -fsanitize=address
endif
ifeq ($(UNAME),Linux)
OPEN=xdg-open
COMPILER=gcc
# _BSD_SOURCE is required by older versions of GCC to find various posix extensions like realpath().
# _DEFAULT_SOURCE is the same deal, except newer versions of GCC need it
# _POSIX_C_SOURCE is also needed by bestline on older versions of GCC
# -lm is required for math.h
FLAGS=-std=c99 -D _BSD_SOURCE -D _DEFAULT_SOURCE -D _POSIX_C_SOURCE -lm -Wall -Wextra -O2
# -Wno-misleading-indentation silences warnings which are entirely spurious.
# -Wno-format-truncation likewise silences spurious warnings regarding snprintf() truncation.
FLAGS:=$(FLAGS) -Wno-misleading-indentation -Wno-format-truncation
endif
ifeq ($(UNAME),OpenBSD)
OPEN=xdg-open
COMPILER=clang
FLAGS=-Wall -Werror -Wextra -Wpedantic -O2
# -Wno-misleading-indentation silences warnings which are entirely spurious.
FLAGS:=$(FLAGS) -Wno-misleading-indentation -Wno-unknown-warning-option
FLAGS:=$(FLAGS) -lm
endif
ifneq ("$(EXTRA_FLAGS)","")
FLAGS:=$(FLAGS) $(EXTRA_FLAGS)
endif
# include potentially unsafe/nonportable scripting APIs
# FLAGS:=$(FLAGS) -DDANGER_ZONE
resources:
@chmod +x ./scripts/resources.sh
@./scripts/resources.sh examples/decks/tour.deck
lilt: resources
@mkdir -p c/build
@$(COMPILER) ./c/lilt.c -o ./c/build/lilt $(FLAGS) -DVERSION="\"$(VERSION)\""
decker: resources
@mkdir -p c/build
@$(COMPILER) ./c/decker.c -o ./c/build/decker $(SDL) $(FLAGS) -DVERSION="\"$(VERSION)\""
clean:
@rm -rf ./c/build/
@rm -rf ./js/build/
@rm -f docs/*.html
install:
@chmod +x ./scripts/install.sh
@./scripts/install.sh
uninstall:
@chmod +x ./scripts/uninstall.sh
@./scripts/uninstall.sh
test: lilt
@chmod +x ./scripts/test_interpreter.sh
@./scripts/test_interpreter.sh "./c/build/lilt "
@./c/build/lilt tests/dom/arrays.lil
@./c/build/lilt tests/dom/images.lil
@./c/build/lilt tests/dom/domtests.lil
@./c/build/lilt tests/dom/test_roundtrip.lil
@./c/build/lilt tests/puzzles/weeklychallenge.lil
run: lilt
@./c/build/lilt
rundecker: decker
./c/build/decker
.PHONY: jsres
js: jsres
@mkdir -p js/build/
@echo "VERSION=\"${VERSION}\"" > js/build/lilt.js
@cat js/lil.js js/repl.js >> js/build/lilt.js
testjs: js
@chmod +x ./scripts/test_interpreter.sh
@./scripts/test_interpreter.sh "node js/build/lilt.js"
@node js/build/lilt.js tests/dom/arrays.lil
@node js/build/lilt.js tests/dom/images.lil
@node js/build/lilt.js tests/dom/domtests.lil
@node js/build/lilt.js tests/dom/test_roundtrip.lil
@node js/build/lilt.js tests/puzzles/weeklychallenge.lil
testawk:
@chmod +x ./scripts/test_interpreter.sh
@./scripts/test_interpreter.sh "awk -f tools/awk/lila.awk"
@awk -f tools/awk/lila.awk tests/dom/arrays.lil
@awk -f tools/awk/lila.awk tests/dom/images.lil
@awk -f tools/awk/lila.awk tests/puzzles/weeklychallenge.lil
web-decker: js
@chmod +x ./scripts/web_decker.sh
@./scripts/web_decker.sh examples/decks/tour.deck js/build/decker.html $(VERSION)
runweb: web-decker
$(OPEN) js/build/decker.html
.PHONY: docs
docs:
@./c/build/lilt scripts/lildoc.lil docs/lil.md docs/lil.html
@./c/build/lilt scripts/lildoc.lil docs/lilt.md docs/lilt.html
@./c/build/lilt scripts/lildoc.lil docs/decker.md docs/decker.html
@./c/build/lilt scripts/lildoc.lil docs/format.md docs/format.html
@./c/build/lilt scripts/lildoc.lil docs/lilquickref.md docs/lilquickref.html
@./c/build/lilt scripts/lildoc.lil docs/learn.md docs/learn.html