forked from smlsharp/smlsharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.in
370 lines (314 loc) · 12.2 KB
/
Makefile.in
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
srcdir = @srcdir@
VPATH = @srcdir@
include config.mk
include src/config.mk
include @srcdir@/files.mk
MLYACC = src/ml-yacc/smlyacc
MLLEX = src/ml-lex/smllex
SMLFORMAT = src/smlformat/smlformat
SMLSHARP_STAGE2 = src/compiler/smlsharp
SMLSHARP_ENV = SMLSHARP_HEAPSIZE=128M:1G
SML_TARGETS = \
$(MLLEX) \
$(MLYACC) \
$(SMLFORMAT) \
$(SMLSHARP_STAGE2)
ALL_GEN_SOURCES = \
$(GEN_SOURCES) \
src/config/main/Version.sml
HEAPIMPL_SOURCES = \
src/runtime/heap_cheney.c \
src/runtime/heap_bitmap.c \
src/runtime/heap_otomo.c \
src/runtime/heap_reppy.c \
src/runtime/heap_malloc.c
HEAP_SOURCE = src/runtime/heap_$(HEAPIMPL).c
NETLIB_CFLAGS = $(CFLAGS) -DIEEE_8087 -DMALLOC=xmalloc
NETLIB_SOURCES = src/runtime/netlib/dtoa.c
RUNTIME_SOURCES = \
src/runtime/control.c \
src/runtime/error.c \
src/runtime/exn.c \
src/runtime/init.c \
src/runtime/object.c \
src/runtime/objspace.c \
src/runtime/obstack.c \
src/runtime/prim.c \
src/runtime/splay.c \
src/runtime/counter.c \
src/runtime/event.c \
src/sql/main/builtintypes/timestamp/string_to_time_t.c \
src/sql/main/builtintypes/timestamp/timeval_to_string.c
CONCURRENT_RUNTIME_SOURCES = \
$(NETLIB_SOURCES) \
src/runtime/concurrent/control.c \
src/runtime/concurrent/counter.c \
src/runtime/error.c \
src/runtime/concurrent/event.c \
src/runtime/exn.c \
src/runtime/concurrent/heap_concurrent.c \
src/runtime/concurrent/init.c \
src/runtime/object.c \
src/runtime/concurrent/objspace.c \
src/runtime/obstack.c \
src/runtime/prim.c \
src/runtime/splay.c \
src/sql/main/builtintypes/timestamp/string_to_time_t.c \
src/sql/main/builtintypes/timestamp/timeval_to_string.c
LIBSMLSHARP_OBJECTS_COMMON = \
$(NETLIB_SOURCES:.c=.$(OBJEXT)) \
$(RUNTIME_SOURCES:.c=.$(OBJEXT))
LIBSMLSHARP_OBJECTS = \
$(HEAP_SOURCE:.c=.$(OBJEXT)) \
$(LIBSMLSHARP_OBJECTS_COMMON)
RUNTIME_TARGETS = \
src/runtime/libsmlsharp.$(LIBEXT) \
src/runtime/smlsharp_entry.$(OBJEXT)
COMPILER_SUPPORT_SOURCES = \
src/llvm/main/llvm_support.cpp \
src/llvm/main/SMLSharpGC.cpp
COMPILER_SUPPORT_OBJECTS = \
$(COMPILER_SUPPORT_SOURCES:.cpp=.$(OBJEXT))
LLVM_COMPILE_OBJFILES = \
src/llvm/main/llvm_support.$(OBJEXT) \
src/llvm/main/compile.$(OBJEXT) \
src/llvm/main/SMLSharpGC.$(OBJEXT)
ALL_TARGETS = \
Makefile \
config.mk \
src/config.mk \
$(RUNTIME_TARGETS) \
$(SML_TARGETS) \
$(INSTALL_FILES_SRC) \
$(INSTALL_FILES_OBJ)
all: $(ALL_TARGETS)
clean: PHONY
-rm -f $(RUNTIME_TARGETS) $(SML_TARGETS)
-rm -f $(LIBSMLSHARP_OBJECTS_COMMON)
-rm -f $(HEAPIMPL_SOURCES:.c=.$(OBJEXT))
-rm -f $(COMPILER_SUPPORT_OBJECTS)
-rm -f $(LLVM_COMPILE_OBJFILES) src/llvm/main/compile
-rm -f $(CONCURRENT_RUNTIME_SOURCES:.c=$(OBJEXT))
-rm -f $(ALL_OBJECTS)
-rm -f $(ALL_GEN_SOURCES) $(CLEAN_FILES)
-rm -f src/config.sed filemap
-rm -f minismlsharp
distclean: clean
-grep '[a-f]' RELEASE_DATE > /dev/null 2>&1 && rm -f RELEASE_DATE
-rm -rf autom4te.cache config.h config.log config.status
-rm -f Makefile config.mk src/config.mk stamp-h
-rm -f precompiled/fastbuild precompiled/minismlsharp-files
-rm -rf precompiled/$(NATIVE_TARGET)
sources: PHONY $(ALL_GEN_SOURCES)
runtime: PHONY $(RUNTIME_TARGETS)
install: $(ALL_TARGETS)
$(INSTALL) -m 755 -d '$(DESTDIR)$(libdir_smlsharp)'
$(INSTALL_PROGRAM) -m 644 src/config.mk \
'$(DESTDIR)$(libdir_smlsharp)/config.mk'
$(INSTALL) -m 755 -d '$(DESTDIR)$(libdir_smlsharp)/runtime'
$(INSTALL_PROGRAM) -m 644 src/runtime/libsmlsharp.$(LIBEXT) \
'$(DESTDIR)$(libdir_smlsharp)/runtime'
$(INSTALL_PROGRAM) -m 644 src/runtime/smlsharp_entry.$(OBJEXT) \
'$(DESTDIR)$(libdir_smlsharp)/runtime'
$(INSTALL_PROGRAM) -m 644 $(srcdir)/src/builtin.smi \
'$(DESTDIR)$(libdir_smlsharp)/builtin.smi'
if test -f src/compiler/smlsharp.lib; then \
$(INSTALL) -m 755 -d '$(DESTDIR)$(libdir_smlsharp)/compiler'; \
$(INSTALL_PROGRAM) -m 644 src/compiler/smlsharp.lib \
'$(DESTDIR)$(libdir_smlsharp)/compiler'; else :; fi
@copy () { \
if test ! -d "$$2"; then \
echo $(INSTALL) -m 755 -d "$$2"; \
$(INSTALL) -m 755 -d "$$2" || exit $?; \
fi; \
echo $(INSTALL_DATA) "$$1" "$$2"; \
$(INSTALL_DATA) "$$1" "$$2" || exit $?; \
}; \
for i in $(INSTALL_FILES_SRC); do \
d=`dirname "$$i" | sed 's,^src/*,,'`; \
copy '$(srcdir)/'"$$i" '$(DESTDIR)$(libdir_smlsharp)/'"$$d"; \
done; \
for i in $(INSTALL_FILES_OBJ); do \
d=`dirname "$$i" | sed 's,^src/*,,'`; \
copy "$$i" '$(DESTDIR)$(libdir_smlsharp)/'"$$d"; \
done
$(INSTALL) -m 755 -d '$(DESTDIR)$(bindir)'
$(INSTALL_PROGRAM) -m 755 $(MLLEX) '$(DESTDIR)$(bindir)'
$(INSTALL_PROGRAM) -m 755 $(MLYACC) '$(DESTDIR)$(bindir)'
$(INSTALL_PROGRAM) -m 755 $(SMLFORMAT) '$(DESTDIR)$(bindir)'
$(INSTALL_PROGRAM) -m 755 $(SMLSHARP_STAGE2) '$(DESTDIR)$(bindir)'
# -------- implicit rules --------
PHONY: # force to rebuild
.SUFFIXES: .c .h .o .a .sml .ppg .ppg.sml .lex .grm .lex.sml .grm.sml
.sml.o:
$(SMLSHARP_ENV) $(SMLSHARP_STAGE1) -Bsrc $(SMLFLAGS) -c -o $@ $<
.ppg.ppg.sml:
$(SMLFORMAT) --output=$@ $<
.lex.lex.sml:
SMLLEX_OUTPUT=$@ $(MLLEX) $<
.grm.grm.sml:
SMLYACC_OUTPUT=$@ $(MLYACC) $<
.c.o:
$(CC) $(CFLAGS) $(DEFS) $(CPPFLAGS) -c -o $@ $<
# -------- runtime --------
src/runtime/libsmlsharp.$(LIBEXT): $(LIBSMLSHARP_OBJECTS)
-rm -f $@
$(AR) cru $@ $(LIBSMLSHARP_OBJECTS)
-$(RANLIB) $@
# To build concurrent GC runtime, specify "-Isrc/runtime/concurrent -Isrc/runtime" to CPPFLAGS.
src/runtime/concurrent/libsmlsharp.$(LIBEXT): \
$(CONCURRENT_RUNTIME_SOURCES:.c=.$(OBJEXT))
-rm -f $@
$(AR) cru $@ $(CONCURRENT_RUNTIME_SOURCES:.c=.$(OBJEXT))
src/runtime/smlsharp_entry.$(OBJEXT): src/runtime/main.c
$(CC) $(CFLAGS) $(DEFS) $(CPPFLAGS) -c -o $@ $(srcdir)/src/runtime/main.c
src/runtime/netlib/dtoa.o: src/runtime/netlib/dtoa.c
$(CC) $(NETLIB_CFLAGS) -c -o $@ $(srcdir)/src/runtime/netlib/dtoa.c
src/runtime/exn.o: src/runtime/exn.c
$(CC) $(CFLAGS) -fexceptions $(DEFS) $(CPPFLAGS) -c -o src/runtime/exn.o src/runtime/exn.c
# -------- compiler support --------
src/llvm/main/llvm_support.$(OBJEXT): src/llvm/main/llvm_support.cpp
$(CXX) $(LLVM_CXXFLAGS) -c -o $@ $<
src/llvm/main/SMLSharpGC.$(OBJEXT): src/llvm/main/SMLSharpGC.cpp
$(CXX) $(LLVM_CXXFLAGS) -c -o $@ $<
src/llvm/main/compile.$(OBJEXT): src/llvm/main/compile.cpp
$(CXX) $(LLVM_CXXFLAGS) -c -o $@ $<
src/llvm/main/compile: $(LLVM_COMPILE_OBJFILES)
$(CXX) $(LLVM_LDFLAGS) -o $@ $(LLVM_COMPILE_OBJFILES) $(LLVM_LIBS)
# -------- link file map --------
filemap: files.mk
@echo "generating filemap ..."; \
for i in $(ALL_OBJECTS); do \
smi=`echo "$$i" | sed 's/o$$/smi/'`; \
echo '$(srcdir)/'"$$smi $$i"; \
done > $@
# -------- executables --------
src/ml-lex/smllex: $(MLLEX_OBJECTS) $(RUNTIME_TARGETS) filemap
$(SMLSHARP_STAGE1) -Bsrc -filemap=filemap \
$(srcdir)/src/ml-lex/ml-lex.smi -o $@
src/ml-yacc/smlyacc: $(MLYACC_OBJECTS) $(RUNTIME_TARGETS) filemap
$(SMLSHARP_STAGE1) -Bsrc -filemap=filemap \
$(srcdir)/src/ml-yacc/src/ml-yacc.smi -o $@
src/smlformat/smlformat: $(SMLFORMAT_OBJECTS) $(RUNTIME_TARGETS) filemap
$(SMLSHARP_STAGE1) -Bsrc -filemap=filemap \
$(srcdir)/src/smlformat/generator/main/call-main.smi -o $@
src/compiler/smlsharp: $(COMPILER_LIB_OBJECTS) $(RUNTIME_TARGETS) \
$(COMPILER_SUPPORT_OBJECTS) filemap
$(SMLSHARP_STAGE1) -Bsrc -filemap=filemap \
$(RDYNAMIC_LDFLAGS) \
$(LLVM_SMLSHARP_LDFLAGS) \
$(srcdir)/src/compiler/smlsharp.smi \
$(COMPILER_SUPPORT_OBJECTS) \
$(LLVM_LIBS) \
-o $@
src/compiler/minismlsharp: $(MINISMLSHARP_OBJECTS) $(RUNTIME_TARGETS) \
$(COMPILER_SUPPORT_OBJECTS) filemap
$(SMLSHARP_STAGE1) -Bsrc -filemap=filemap \
$(LLVM_SMLSHARP_LDFLAGS) \
$(srcdir)/src/compiler/minismlsharp.smi \
$(COMPILER_SUPPORT_OBJECTS) \
$(LLVM_LIBS) \
-o $@
precompiled/$(MINISMLSHARP_PRECOMPILED).$(OBJEXT): \
precompiled/$(MINISMLSHARP_PRECOMPILED).ll.xz \
src/llvm/main/compile
$(XZ) -c -d precompiled/$(MINISMLSHARP_PRECOMPILED).ll.xz \
| src/llvm/main/compile $(TARGET_TRIPLE) - $@
./minismlsharp: $(RUNTIME_TARGETS) $(COMPILER_SUPPORT_OBJECTS) \
precompiled/$(MINISMLSHARP_PRECOMPILED).$(OBJEXT)
$(CXX) $(LDFLAGS) $(LLVM_LDFLAGS) \
src/runtime/smlsharp_entry.$(OBJEXT) \
precompiled/$(MINISMLSHARP_PRECOMPILED).$(OBJEXT) \
$(COMPILER_SUPPORT_OBJECTS) \
src/runtime/libsmlsharp.$(LIBEXT) \
$(LIBS) $(LLVM_LIBS) \
-o $@
fixup: PHONY
@set -x; \
x=`$(SMLSHARP_STAGE1) -Bsrc -nostdpath -Isrc -filemap=filemap \
$(SMLSHARP_LDFLAGS) \
$(srcdir)/src/compiler/smlsharp.smi -o /dev/null 2>&1 \
| sed -e '/SMLmain[A-V0-9][A-V0-9]*/!d' \
-e 's,^.*SMLmain\([A-V0-9]*\).*$$,\1,' \
| awk '{r=r","$$0}END{sub("^,","^",r);gsub(",","|^",r);print r}'`; \
[ -z "$$x" ] && exit 0; \
eval \
`$(SMLSHARP_STAGE1) -Bsrc -nostdpath -Isrc -filemap=filemap \
$(SMLSHARP_LDFLAGS) \
-fprint-main-ids $(srcdir)/src/compiler/smlsharp.smi \
| awk "/$$x/"'{sub(".smi$$",".o",$$2);print "rm " $$2 ";"}'`
# -------- source code generation --------
@SNAPDATE_RULE_@RELEASE_DATE: $(srcdir)/../.hg/dirstate
@SNAPDATE_RULE_@ r=`HGPLAIN=1 hg summary | awk -F'[ :]+' '/^parent:/{print $$3;exit}'`; \
@SNAPDATE_RULE_@ d=`HGPLAIN=1 hg log -r"$${r:-tip}" --template '{date|isodatesec}' | sed s/+0900/JST/`; \
@SNAPDATE_RULE_@ echo "$$d $$r" > $@
src/config.sed: config.mk src/config.mk Makefile VERSION RELEASE_DATE
{ echo 'VERSION = '`cat VERSION`; \
echo 'RELEASE_DATE = '`cat RELEASE_DATE`; \
echo 'LIBDIR_SMLSHARP = $(libdir_smlsharp)'; \
cat src/config.mk; } \
| sed 's/["\\]/\\\\\\&/g;s/^/s"%/;s/ = /%"/;s/$$/";/' \
> $@
src/config/main/Version.sml: src/config.sed src/config/main/Version.sml.in
sed -f src/config.sed $(srcdir)/src/config/main/Version.sml.in > $@
# ---- autoconf ----
CHECK_GNUMAKE = \
if $(MAKE) --version 2> /dev/null | grep 'GNU Make' > /dev/null; \
then :; else echo 'Makefiles are updated, rerun make.'; exit 1; fi
Makefile: Makefile.in config.status
./config.status Makefile
@$(CHECK_GNUMAKE)
config.mk: config.mk.in config.status
./config.status config.mk
@$(CHECK_GNUMAKE)
src/config.mk: src/config.mk.in config.status
./config.status src/config.mk
@$(CHECK_GNUMAKE)
config.h: stamp-h
stamp-h: $(srcdir)/config.h.in config.status
./config.status config.h stamp-h
config.status: $(srcdir)/configure
./config.status --recheck
$(srcdir)/configure: $(srcdir)/configure.ac
cd '$(srcdir)' && autoconf
$(srcdir)/config.h.in: $(srcdir)/stamp-h.in
$(srcdir)/stamp-h.in: $(srcdir)/configure.ac
cd '$(srcdir)' && autoheader
echo timestamp > '$(srcdir)/stamp-h.in'
# -------- dependencies --------
depend: PHONY
-rm -f $(srcdir)/files.mk $(srcdir)/depend.mk
SMLSHARP='$(SMLSHARP_STAGE1)' \
OBJEXT='$(OBJEXT)' \
$(SHELL) mkdepend \
BASIS_LIB src/basis.smi \
MLLEX src/ml-lex/ml-lex.smi \
MLYACC_LIB src/ml-yacc-lib.smi \
MLYACC src/ml-yacc/src/ml-yacc.smi \
SMLFORMAT_LIB src/smlformat-lib.smi \
SMLUNIT_LIB src/smlunit-lib.smi \
SMLFORMAT src/smlformat/generator/main/call-main.smi \
MINISMLSHARP src/compiler/minismlsharp.smi \
COMPILER_LIB src/compiler/smlsharp.smi \
SQL_LIB src/sql.smi \
PRELUDE_LIB src/prelude.smi
for i in $(HEAPIMPL_SOURCES) $(NETLIB_SOURCES) $(RUNTIME_SOURCES) \
$(COMPILER_SUPPORT_SOURCES); do \
case "$$i" in *.cpp) cpp='$(CXXCPP)';; *) cpp='$(CPP)';; esac; \
echo $$cpp -MM $(DEFS) $(CPPFLAGS) $(srcdir)/$$i 1>&2; \
$$cpp -MM $(DEFS) $(CPPFLAGS) $(srcdir)/$$i \
| perl -ne 's,^[^:. ]*(\.[^: ]*: *)([^. ]*)\.c,\2\1\2\.c,; \
s, /[^ ]*\.(h|def)(?= |$$),,g; \
print unless /^ *\\$$/' \
>> $(srcdir)/depend.mk; \
done
for i in $(CONCURRENT_RUNTIME_SOURCES); do \
case "$$i" in */concurrent/*) ;; *) continue;; esac; \
echo $(CPP) -MM -I$(srcdir)/src/runtime/concurrent -I$(srcdir)/src/runtime $(DEFS) $(CPPFLAGS) $(srcdir)/$$i 1>&2; \
$(CPP) -MM -I$(srcdir)/src/runtime/concurrent -I$(srcdir)/src/runtime $(DEFS) $(CPPFLAGS) $(srcdir)/$$i \
| perl -npe 's,^[^:. ]*(\.[^: ]*: *)([^. ]*)\.c,\2\1\2\.c,; \
s, /[^ ]*\.h(?= ),,g' \
>> $(srcdir)/depend.mk; \
done
include @srcdir@/depend.mk
@INCLUDE_STAGE1@include @srcdir@/stage1.mk