-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
204 lines (160 loc) · 4.6 KB
/
Makefile
File metadata and controls
204 lines (160 loc) · 4.6 KB
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
#CONFIG_PROFILE=y
#CONFIG_X86_32=y
#CONFIG_ARM32=y
#CONFIG_WIN32=y
#CONFIG_SOFTFLOAT=y
#CONFIG_ASAN=y
#CONFIG_GPROF=y
CONFIG_SMALL=y
# consider warnings as errors (for development)
#CONFIG_WERROR=y
ifdef CONFIG_ARM32
CROSS_PREFIX=arm-linux-gnu-
endif
ifdef CONFIG_WIN32
ifdef CONFIG_X86_32
CROSS_PREFIX?=i686-w64-mingw32-
else
CROSS_PREFIX?=x86_64-w64-mingw32-
endif
EXE=.exe
else
CROSS_PREFIX?=
EXE=
endif
HOST_CC=gcc
CC=$(CROSS_PREFIX)gcc
CFLAGS=-Wall -g -MMD -D_GNU_SOURCE -fno-math-errno -fno-trapping-math
HOST_CFLAGS=-Wall -g -MMD -D_GNU_SOURCE -fno-math-errno -fno-trapping-math
ifdef CONFIG_WERROR
CFLAGS+=-Werror
HOST_CFLAGS+=-Werror
endif
ifdef CONFIG_ARM32
CFLAGS+=-mthumb
endif
ifdef CONFIG_SMALL
CFLAGS+=-Os
else
CFLAGS+=-O2
endif
#CFLAGS+=-fstack-usage
ifdef CONFIG_SOFTFLOAT
CFLAGS+=-msoft-float
CFLAGS+=-DUSE_SOFTFLOAT
endif # CONFIG_SOFTFLOAT
HOST_CFLAGS+=-O2
LDFLAGS=-g
HOST_LDFLAGS=-g
ifdef CONFIG_GPROF
CFLAGS+=-p
LDFLAGS+=-p
endif
ifdef CONFIG_ASAN
CFLAGS+=-fsanitize=address -fno-omit-frame-pointer
LDFLAGS+=-fsanitize=address -fno-omit-frame-pointer
endif
ifdef CONFIG_X86_32
CFLAGS+=-m32
LDFLAGS+=-m32
endif
ifdef CONFIG_PROFILE
CFLAGS+=-p
LDFLAGS+=-p
endif
# when cross compiling from a 64 bit system to a 32 bit system, force
# a 32 bit output
ifdef CONFIG_X86_32
MQJS_BUILD_FLAGS=-m32
endif
ifdef CONFIG_ARM32
MQJS_BUILD_FLAGS=-m32
endif
PROGS=mqjs$(EXE) example$(EXE) gauntlet_pro$(EXE) ustatic$(EXE) ubrain$(EXE) uchip8$(EXE) useries$(EXE)
TEST_PROGS=dtoa_test libm_test
all: $(PROGS)
COMMON_OBJS=mquickjs.o dtoa.o libm.o cutils.o
MQJS_OBJS=mqjs.o readline_tty.o readline.o $(COMMON_OBJS)
LIBS=-lm
mqjs$(EXE): $(MQJS_OBJS)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
mquickjs.o: mquickjs_atom.h
mqjs_stdlib: mqjs_stdlib.host.o mquickjs_build.host.o
$(HOST_CC) $(HOST_LDFLAGS) -o $@ $^
mquickjs_atom.h: mqjs_stdlib
./mqjs_stdlib -a $(MQJS_BUILD_FLAGS) > $@
mqjs_stdlib.h: mqjs_stdlib
./mqjs_stdlib $(MQJS_BUILD_FLAGS) > $@
mqjs.o: mqjs_stdlib.h
# µGauntlet Pro
gauntlet_pro.o: gauntlet_pro_stdlib.h
gauntlet_pro$(EXE): gauntlet_pro.o $(COMMON_OBJS)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
gauntlet_pro_stdlib: gauntlet_pro_stdlib.host.o mquickjs_build.host.o
$(HOST_CC) $(HOST_LDFLAGS) -o $@ $^
gauntlet_pro_stdlib.h: gauntlet_pro_stdlib
./gauntlet_pro_stdlib $(MQJS_BUILD_FLAGS) > $@
# µStatic
ustatic.o: ustatic_stdlib.h
ustatic$(EXE): ustatic.o $(COMMON_OBJS)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
ustatic_stdlib: ustatic_stdlib.host.o mquickjs_build.host.o
$(HOST_CC) $(HOST_LDFLAGS) -o $@ $^
ustatic_stdlib.h: ustatic_stdlib
./ustatic_stdlib $(MQJS_BUILD_FLAGS) > $@
# µBrain
ubrain$(EXE): ubrain.o $(COMMON_OBJS)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
ubrain.o: mqjs_stdlib.h
# µCHIP-8
uchip8$(EXE): uchip8.o $(COMMON_OBJS)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
uchip8.o: gauntlet_pro_stdlib.h
# µSeries Multiplexer
useries.o: useries_stdlib.h
useries$(EXE): useries.o $(COMMON_OBJS)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
useries_stdlib: useries_stdlib.host.o mquickjs_build.host.o
$(HOST_CC) $(HOST_LDFLAGS) -o $@ $^
useries_stdlib.h: useries_stdlib
./useries_stdlib $(MQJS_BUILD_FLAGS) > $@
# C API example
example.o: example_stdlib.h
example$(EXE): example.o $(COMMON_OBJS)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
example_stdlib: example_stdlib.host.o mquickjs_build.host.o
$(HOST_CC) $(HOST_LDFLAGS) -o $@ $^
example_stdlib.h: example_stdlib
./example_stdlib $(MQJS_BUILD_FLAGS) > $@
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
%.host.o: %.c
$(HOST_CC) $(HOST_CFLAGS) -c -o $@ $<
test: mqjs example
./mqjs tests/test_closure.js
./mqjs tests/test_language.js
./mqjs tests/test_loop.js
./mqjs tests/test_builtin.js
# test bytecode generation and loading
./mqjs -o test_builtin.bin tests/test_builtin.js
# @sha256sum -c test_builtin.sha256
./mqjs -b test_builtin.bin
./example tests/test_rect.js
microbench: mqjs
./mqjs tests/microbench.js
octane: mqjs
./mqjs --memory-limit 256M tests/octane/run.js
size: mqjs
size mqjs mqjs.o readline.o cutils.o dtoa.o libm.o mquickjs.o
dtoa_test: tests/dtoa_test.o dtoa.o cutils.o tests/gay-fixed.o tests/gay-precision.o tests/gay-shortest.o
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
libm_test: tests/libm_test.o libm.o
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
rempio2_test: tests/rempio2_test.o libm.o
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
clean:
rm -f *.o *.d *~ tests/*.o tests/*.d tests/*~ test_builtin.bin
rm -f mqjs_stdlib mqjs_stdlib.h mquickjs_build_atoms mquickjs_atom.h mqjs_example example_stdlib example_stdlib.h
rm -f gauntlet_pro_stdlib gauntlet_pro_stdlib.h ustatic_stdlib ustatic_stdlib.h useries_stdlib useries_stdlib.h
rm -f $(PROGS) $(TEST_PROGS)
-include $(wildcard *.d)