-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile.gnu
144 lines (106 loc) · 3.07 KB
/
Makefile.gnu
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
# Standard GNU Makefile for the generic development environment at
# Phorward Software (no autotools, etc. wanted in here).
CFLAGS = -g -DUTF8 -DUNICODE -DDEBUG -Wall -I. $(CLOCAL)
SOURCES = \
lib/phorward.c \
src/build.c \
src/debug.c \
src/error.c \
src/first.c \
src/integrity.c \
src/lalr.c \
src/lex.c \
src/list.c \
src/main.c \
src/mem.c \
src/parse.c \
src/rewrite.c \
src/string.c \
src/utils.c \
src/virtual.c \
src/xml.c
OBJECTS = $(patsubst %.c,%.o,$(SOURCES))
all: unicc
clean:
-rm src/*.o
-rm unicc
src/proto.h:
lib/pproto src/*.c | awk "/int _parse/ { next } { print }" >$@
src/parse.c src/parse.h: src/parse.par
unicc -o src/parse src/parse.par
make_install:
cp Makefile.gnu Makefile
make_uninstall:
-rm -f Makefile
# --- UniCC --------------------------------------------------------------------
unicc: $(OBJECTS)
$(CC) -o $@ $(OBJECTS)
# --- UniCC Documentation ------------------------------------------------------
#
# Now documentation generation follows, using txt2tags.
#
doc: unicc.man
unicc.man: unicc.t2t
txt2tags -t man -o $@ $?
# --- UniCC CI Test Suite ------------------------------------------------------
TESTPREFIX=test_
TESTEXPR="42 * 23 + 1337"
TESTRESULT="= 2303"
# C
$(TESTPREFIX)c_expr:
./unicc -o $@ examples/expr.c.par
cc -o $@ [email protected]
test "`echo $(TESTEXPR) | ./$@ -sl`" = $(TESTRESULT)
$(TESTPREFIX)c_ast:
./unicc -o $@ examples/expr.ast.par
cc -o $@ [email protected]
echo $(TESTEXPR) | ./$@ -sl
test_c: $(TESTPREFIX)c_expr $(TESTPREFIX)c_ast
@echo "--- $@ succeeded ---"
@rm $(TESTPREFIX)*
# C++
$(TESTPREFIX)cpp_expr:
./unicc -o $@ examples/expr.cpp.par
g++ -o $@ [email protected]
test "`echo $(TESTEXPR) | ./$@ -sl`" = $(TESTRESULT)
$(TESTPREFIX)cpp_ast:
./unicc -l C++ -o $@ examples/expr.ast.par
g++ -o $@ [email protected]
echo $(TESTEXPR) | ./$@ -sl
test_cpp: $(TESTPREFIX)cpp_expr $(TESTPREFIX)cpp_ast
@echo "--- $@ succeeded ---"
@rm $(TESTPREFIX)*
# Python
$(TESTPREFIX)py_expr:
./unicc -o $@ examples/expr.py.par
-test "`python2 [email protected] $(TESTEXPR) | head -n 1`" = $(TESTRESULT)
test "`python3 [email protected] $(TESTEXPR) | head -n 1`" = $(TESTRESULT)
$(TESTPREFIX)py_ast:
./unicc -l Python -o $@ examples/expr.ast.par
-python2 [email protected] $(TESTEXPR)
python3 [email protected] $(TESTEXPR)
test_py: $(TESTPREFIX)py_expr $(TESTPREFIX)py_ast
@echo "--- $@ succeeded ---"
@rm $(TESTPREFIX)*
# JavaScript
$(TESTPREFIX)js_expr:
./unicc -wt examples/expr.js.par >[email protected]
@echo "var p = new Parser(); p.parse(process.argv[2]);" >>[email protected]
test "`node [email protected] $(TESTEXPR) | head -n 1`" = $(TESTRESULT)
$(TESTPREFIX)js_ast:
./unicc -wtl JavaScript examples/expr.ast.par >[email protected]
@echo "var p = new Parser(); var t = p.parse(process.argv[2]); t.dump();" >>[email protected]
node [email protected] $(TESTEXPR)
test_js: $(TESTPREFIX)js_expr $(TESTPREFIX)js_ast
@echo "--- $@ succeded ---"
@rm $(TESTPREFIX)*
# JSON
$(TESTPREFIX)json_ast:
./unicc -wtl json examples/expr.ast.par >[email protected]
jq . [email protected]
test_json: $(TESTPREFIX)js_expr $(TESTPREFIX)json_ast
@echo "--- $@ succeded ---"
@rm $(TESTPREFIX)*
# Test
test: test_c test_cpp test_py test_js test_json
@echo "=== $+ succeeded ==="