* Makefile.am (AM_CFLAGS): Don't use += to append inside conditionals. Use ...
[mono.git] / mono / mini / Makefile.am
1 count=100000
2 mtest=for_loop
3 monodir=$(top_builddir)
4
5 # This is needed for automake dependency generation
6 if INCLUDED_LIBGC
7 libgc_libs=$(monodir)/libgc/libmonogc.la
8 libgc_static_libs=$(monodir)/libgc/libmonogc-static.la
9 else
10 libgc_libs=$(LIBGC_LIBS)
11 libgc_static_libs=$(LIBGC_STATIC_LIBS)
12 endif
13
14 libs=   \
15         $(monodir)/mono/metadata/libmonoruntime.la      \
16         $(monodir)/mono/io-layer/libwapi.la     \
17         $(monodir)/mono/utils/libmonoutils.la \
18         $(GMODULE_LIBS) \
19         $(GLIB_LIBS)    \
20         $(libgc_libs)   \
21         $(ICU_LIBS)
22
23 static_libs=    \
24         $(monodir)/mono/metadata/libmonoruntime-static.la       \
25         $(monodir)/mono/io-layer/libwapi.la     \
26         $(monodir)/mono/utils/libmonoutils.la \
27         $(GMODULE_LIBS) \
28         $(GLIB_LIBS)    \
29         $(libgc_static_libs) \
30         $(ICU_LIBS)
31
32 RUNTIME = MONO_PATH=$(mcs_topdir)/class/lib/default $(top_builddir)/runtime/mono-wrapper
33
34 MCS = $(RUNTIME) $(mcs_topdir)/class/lib/default/mcs.exe -unsafe -nowarn:0162
35 ILASM = $(RUNTIME) $(mcs_topdir)/ilasm/ilasm.exe
36
37 AM_CFLAGS = \
38         -I$(top_srcdir)         \
39         $(LIBGC_CFLAGS)         \
40         $(GMODULE_CFLAGS)               \
41         $(GLIB_CFLAGS)
42         $(PLATFORM_CFLAGS) $(ARCH_CFLAGS)
43
44 if PLATFORM_WIN32
45 export HOST_CC
46 # The mingw math.h has "extern inline" functions that dont appear in libs, so
47 # optimisation is required to actually inline them
48 PLATFORM_CFLAGS = -O
49 PLATFORM_LIB = ../os/libmonoos.la
50 endif
51
52 # hack for automake to have the same source file in a library and a bin
53 genmdesc_CFLAGS = $(AM_CFLAGS)
54
55 if NO_VERSION_SCRIPT
56 monoldflags=
57 monobinldflags=
58 else
59 monoldflags=-Wl,-version-script=$(srcdir)/ldscript
60 monobinldflags=-Wl,-version-script=$(srcdir)/ldscript.mono
61 endif
62
63 if PLATFORM_WIN32
64 libmono_la_LDFLAGS=-no-undefined -version-info 1:0:0 $(monoldflags)
65 else
66 libmono_la_LDFLAGS=$(monoldflags)
67 endif
68
69 if JIT_SUPPORTED
70 bin_PROGRAMS = mono
71
72 noinst_PROGRAMS = genmdesc
73
74 lib_LTLIBRARIES = libmono.la
75 noinst_LTLIBRARIES = libmono-static.la
76 endif
77
78 mono_SOURCES = \
79         main.c
80
81 if STATIC_MONO
82 # Link libmono into mono statically
83 # This leads to higher performance, especially with TLS
84 MONO_LIB=libmono-static.la
85 else 
86 MONO_LIB=libmono.la
87 endif
88
89 mono_LDADD = \
90         $(MONO_LIB)                     \
91         $(PLATFORM_LIB)         \
92         $(GLIB_LIBS)            \
93         $(GMODULE_LIBS) -lm     \
94         $(ICU_LIBS)
95
96 mono_LDFLAGS = \
97         $(static_flags) -export-dynamic $(monobinldflags)
98
99 genmdesc_SOURCES = \
100         mini.h          \
101         genmdesc.c      \
102         helpers.c
103
104 # Don't link this against libmonoruntime to speed up rebuilds
105 genmdesc_LDADD = \
106         $(monodir)/mono/utils/libmonoutils.la $(monodir)/mono/metadata/opcodes.lo -lm   \
107         $(PLATFORM_LIB)         \
108         $(GLIB_LIBS)            \
109         $(GMODULE_LIBS)
110
111 x86_sources = \
112         mini-x86.c              \
113         mini-x86.h              \
114         exceptions-x86.c        \
115         tramp-x86.c                     \
116         mini-codegen.c          \
117         mini-trampolines.c
118
119 amd64_sources = \
120         mini-amd64.c            \
121         mini-amd64.h            \
122         exceptions-amd64.c      \
123         tramp-amd64.c           \
124         mini-codegen.c          \
125         mini-trampolines.c
126
127 ppc_sources = \
128         mini-ppc.c              \
129         mini-ppc.h              \
130         exceptions-ppc.c        \
131         tramp-ppc.c
132
133 arm_sources = \
134         mini-arm.c              \
135         mini-arm.h              \
136         exceptions-arm.c        \
137         tramp-arm.c             \
138         mini-codegen.c
139
140 sparc_sources = \
141         mini-sparc.c            \
142         mini-sparc.h            \
143         exceptions-sparc.c      \
144         tramp-sparc.c           \
145         mini-codegen.c          \
146         mini-trampolines.c
147
148 s390_sources = \
149         mini-s390.c             \
150         mini-s390.h             \
151         exceptions-s390.c       \
152         tramp-s390.c
153
154 s390x_sources = \
155         mini-s390x.c            \
156         mini-s390x.h            \
157         exceptions-s390x.c      \
158         tramp-s390x.c
159
160 ia64_sources = \
161         mini-ia64.c                     \
162         mini-ia64.h                     \
163         exceptions-ia64.c       \
164         tramp-ia64.c            \
165         mini-codegen.c          \
166         mini-trampolines.c
167
168 common_sources = \
169         mini.c          \
170         mini.h          \
171         trace.c         \
172         trace.h         \
173         mini-ops.h      \
174         mini-arch.h     \
175         dominators.c    \
176         cfold.c         \
177         regalloc.c      \
178         regalloc.h      \
179         helpers.c       \
180         liveness.c      \
181         ssa.c           \
182         abcremoval.c    \
183         abcremoval.h    \
184         ssapre.c        \
185         ssapre.h        \
186         ssapre-cee-ops.h \
187         ssapre-mini-ops.h \
188         driver.c        \
189         debug-mini.c    \
190         linear-scan.c   \
191         aot.c           \
192         graph.c         \
193         mini-exceptions.c       \
194         declsec.c       \
195         declsec.h
196
197 test_sources =          \
198         basic-calls.cs  \
199         basic-long.cs   \
200         bench.cs                \
201         objects.cs              \
202         arrays.cs               \
203         basic-float.cs  \
204         basic-math.cs   \
205         basic.cs                \
206         exceptions.cs   \
207         iltests.il              \
208         test.cs
209
210 regtests=basic.exe arrays.exe basic-float.exe basic-math.exe basic-long.exe objects.exe basic-calls.exe iltests.exe exceptions.exe bench.exe
211
212 common_BURGSRC= $(srcdir)/inssel.brg $(srcdir)/inssel-float.brg
213
214 if X86
215 libmono_la_SOURCES = \
216         $(common_sources) $(x86_sources)
217
218 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-x86.brg
219 arch_built=cpu-pentium.h
220 endif
221
222 if AMD64
223 libmono_la_SOURCES = \
224         $(common_sources) $(amd64_sources)
225 arch_BURGSRC= $(srcdir)/inssel-long.brg $(srcdir)/inssel-amd64.brg
226 arch_built=cpu-amd64.h
227 endif
228
229 if POWERPC
230 libmono_la_SOURCES = \
231         $(common_sources) $(ppc_sources)
232
233 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-ppc.brg
234 arch_built=cpu-g4.h
235 endif
236
237 if ARM
238
239 # pick up arm_dpimacros.h and arm_fpamacros.h
240 ARCH_CFLAGS = -I../arch/arm
241
242 libmono_la_SOURCES = \
243         $(common_sources) $(arm_sources)
244
245 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-arm.brg
246 arch_built=cpu-arm.h
247 endif
248
249 if SPARC
250 libmono_la_SOURCES = \
251         $(common_sources) $(sparc_sources)
252
253 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-sparc.brg
254 arch_built=cpu-sparc.h
255 endif
256
257 if SPARC64
258 libmono_la_SOURCES = \
259         $(common_sources) $(sparc_sources)
260
261 arch_BURGSRC= $(srcdir)/inssel-long.brg $(srcdir)/inssel-sparc.brg
262 arch_built=cpu-sparc.h
263 endif
264
265 if S390
266 libmono_la_SOURCES = \
267         $(common_sources) $(s390_sources)
268
269 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-s390.brg
270 arch_built=cpu-s390.h
271 endif
272
273 if S390x
274 libmono_la_SOURCES = \
275         $(common_sources) $(s390x_sources)
276
277 arch_BURGSRC= $(srcdir)/inssel-long.brg $(srcdir)/inssel-s390x.brg
278 arch_built=cpu-s390x.h
279 endif
280
281 if IA64
282 libmono_la_SOURCES = \
283     $(common_sources) $(ia64_sources)
284
285 arch_BURGSRC = $(srcdir)/inssel-long.brg $(srcdir)/inssel-ia64.brg
286 arch_built = cpu-ia64.h
287 endif
288
289 nodist_libmono_la_SOURCES = inssel.c inssel.h
290
291 libmono_static_la_SOURCES = $(libmono_la_SOURCES)
292 nodist_libmono_static_la_SOURCES = $(nodist_libmono_la_SOURCES)
293 libmono_static_la_LDFLAGS = -static
294 libmono_static_la_LIBADD = $(static_libs) $(PLATFORM_LIB)
295
296 BURGSRC= $(common_BURGSRC) $(arch_BURGSRC)
297
298 libmonoincludedir = $(includedir)/mono/jit
299
300 libmonoinclude_HEADERS = jit.h
301
302 libmono_la_LIBADD = \
303         $(libs) \
304         $(PLATFORM_LIB)
305
306 %.exe: %.cs TestDriver.dll
307         $(MCS) /out:$*.exe /unsafe $< /r:TestDriver.dll
308
309 %.exe: %.il
310         $(ILASM) /output=$*.exe $<
311
312 TestDriver.dll: $(srcdir)/TestDriver.cs
313         $(MCS) /out:TestDriver.dll /target:library $(srcdir)/TestDriver.cs
314
315 if CROSS_COMPILING
316
317 cpu-pentium.h: cpu-pentium.md
318 cpu-amd64.h: cpu-amd64.md
319 cpu-g4.h: cpu-g4.md
320 cpu-arm.h: cpu-arm.md
321 cpu-sparc.h: cpu-sparc.md
322 cpu-s390.h: cpu-s390.md
323 cpu-s390x.h: cpu-s390x.md
324 cpu-ia64.h: cpu-ia64.md
325
326 ## Gross hack.  Making 'genmdesc' a host binary takes more effort
327 $(arch_built):
328         echo "*** please build $(arch_built) on a native build tree and copy it here"
329         exit 1
330
331 else !CROSS_COMPILING
332
333 cpu-pentium.h: cpu-pentium.md genmdesc$(EXEEXT)
334         ./genmdesc $(srcdir)/cpu-pentium.md cpu-pentium.h pentium_desc
335
336 cpu-amd64.h: cpu-amd64.md genmdesc$(EXEEXT)
337         ./genmdesc $(srcdir)/cpu-amd64.md cpu-amd64.h amd64_desc
338
339 cpu-g4.h: cpu-g4.md genmdesc$(EXEEXT)
340         ./genmdesc $(srcdir)/cpu-g4.md cpu-g4.h ppcg4
341
342 cpu-arm.h: cpu-arm.md genmdesc$(EXEEXT)
343         ./genmdesc $(srcdir)/cpu-arm.md cpu-arm.h arm_cpu_desc
344
345 cpu-sparc.h: cpu-sparc.md genmdesc$(EXEEXT)
346         ./genmdesc $(srcdir)/cpu-sparc.md cpu-sparc.h sparc_desc
347
348 cpu-s390.h: cpu-s390.md genmdesc$(EXEEXT)
349         ./genmdesc $(srcdir)/cpu-s390.md cpu-s390.h s390
350
351 cpu-s390x.h: cpu-s390x.md genmdesc$(EXEEXT)
352         ./genmdesc $(srcdir)/cpu-s390x.md cpu-s390x.h s390x
353
354 cpu-ia64.h: cpu-ia64.md genmdesc$(EXEEXT)
355         ./genmdesc $(srcdir)/cpu-ia64.md cpu-ia64.h ia64_desc
356
357 endif !CROSS_COMPILING
358
359 inssel.c inssel.h: $(BURGSRC)
360         $(monodir)/mono/monoburg/monoburg -c 1 -p -e $(BURGSRC) -d inssel.h -s inssel.c
361
362 testi: mono test.exe
363         $(RUNTIME) -v -v --ncompile 1 --compile Test:$(mtest) test.exe
364
365 # ensure the tests are actually correct
366 checktests: $(regtests)
367         for i in $(regtests); do $(RUNTIME) $$i; done
368
369 rcheck: mono $(regtests)
370         $(RUNTIME) --regression $(regtests)
371
372 aotcheck: mono $(regtests)
373         for i in $(regtests); do $(RUNTIME) --aot $$i; done
374         $(RUNTIME) --verbose --regression $(regtests)
375         rm -f *.exe.so
376
377 bench: mono test.exe
378         time env $(RUNTIME) --ncompile $(count) --compile Test:$(mtest) test.exe
379
380 mbench: test.exe
381         time $(monodir)/mono/jit/mono --ncompile $(count) --compile Test:$(mtest) test.exe
382
383 stat1: mono bench.exe
384         $(RUNTIME) --verbose --statfile stats.pl --regression bench.exe
385         perl viewstat.pl stats.pl
386
387 stat2: mono basic.exe
388         $(RUNTIME) --verbose --statfile stats.pl --regression basic.exe
389         perl viewstat.pl -e stats.pl
390
391 stat3: mono bench.exe
392         $(RUNTIME) --statfile stats.pl --ncompile 1000 --compile Tests:test_0_many_nested_loops bench.exe 
393         perl viewstat.pl stats.pl
394
395 docu: mini.sgm
396         docbook2txt mini.sgm
397
398 check-local: rcheck
399
400 clean-local:
401         rm -f mono a.out gmon.out *.o test.exe
402
403 pkgconfigdir = $(libdir)/pkgconfig
404
405 if JIT_SUPPORTED
406 BUILT_SOURCES= inssel.c inssel.h $(arch_built)
407 endif
408
409 CLEANFILES= $(BUILT_SOURCES) *.exe *.dll
410 EXTRA_DIST = $(common_BURGSRC) jit-icalls.c cprop.c TestDriver.cs ldscript ldscript.mono $(test_sources) \
411         inssel-long.brg inssel-long32.brg \
412         $(x86_sources) inssel-x86.brg cpu-pentium.md \
413         $(amd64_sources) inssel-amd64.brg cpu-amd64.md \
414         $(ppc_sources) inssel-ppc.brg cpu-g4.md \
415         $(arm_sources) inssel-arm.brg cpu-arm.md \
416         $(sparc_sources) inssel-sparc.brg cpu-sparc.md \
417         $(s390_sources) inssel-s390.brg cpu-s390.md \
418         $(s390x_sources) inssel-s390x.brg cpu-s390x.md \
419         $(ia64_sources) inssel-ia64.brg cpu-ia64.md