Don't link to gmodule anymore.
[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         $(GLIB_LIBS)    \
19         $(libgc_libs)
20
21 static_libs=    \
22         $(monodir)/mono/metadata/libmonoruntime-static.la       \
23         $(monodir)/mono/io-layer/libwapi.la     \
24         $(monodir)/mono/utils/libmonoutils.la \
25         $(GLIB_LIBS)    \
26         $(libgc_static_libs)
27
28 CLASS1=$(mcs_topdir)/class/lib/default
29 CLASS2=$(mcs_topdir)/class/lib/net_2_0
30
31 RUNTIME = MONO_PATH=$(CLASS1) $(top_builddir)/runtime/mono-wrapper
32 RUNTIME2 = MONO_PATH=$(CLASS2) $(top_builddir)/runtime/mono-wrapper
33
34 MCS = $(RUNTIME) $(CLASS1)/mcs.exe -unsafe -nowarn:0162
35 GMCS = $(RUNTIME2) $(CLASS2)/gmcs.exe -unsafe -nowarn:0162
36 ILASM = $(RUNTIME) $(CLASS1)/ilasm.exe
37 ILASM2 = $(RUNTIME2) $(CLASS2)/ilasm.exe
38
39 AM_CFLAGS = \
40         -I$(top_srcdir)         \
41         $(LIBGC_CFLAGS)         \
42         $(GLIB_CFLAGS)
43         $(PLATFORM_CFLAGS) $(ARCH_CFLAGS)
44
45 if PLATFORM_WIN32
46 export HOST_CC
47 # The mingw math.h has "extern inline" functions that dont appear in libs, so
48 # optimisation is required to actually inline them
49 PLATFORM_CFLAGS = -O
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 -avoid-version $(monoldflags)
65 else
66 libmono_la_LDFLAGS=$(monoldflags)
67 endif
68
69 if JIT_SUPPORTED
70
71 if PLATFORM_WIN32
72 bin_PROGRAMS = mono monow
73 else
74 bin_PROGRAMS = mono
75 endif
76
77 noinst_PROGRAMS = genmdesc
78
79 lib_LTLIBRARIES = libmono.la
80 noinst_LTLIBRARIES = libmono-static.la
81 endif
82
83 mono_SOURCES = \
84         main.c
85
86 if STATIC_MONO
87 # Link libmono into mono statically
88 # This leads to higher performance, especially with TLS
89 MONO_LIB=libmono-static.la
90 else 
91 MONO_LIB=libmono.la
92 endif
93
94 mono_LDADD = \
95         $(MONO_LIB)                     \
96         $(GLIB_LIBS)            \
97         -lm
98
99 mono_LDFLAGS = \
100         $(static_flags) -export-dynamic $(monobinldflags)
101
102 # Create monow.exe, linked for the 'windows' subsystem
103 if PLATFORM_WIN32
104 monow_LDADD = $(mono_LDADD)
105 monow_LDFLAGS = $(mono_LDFLAGS) -mwindows
106 monow_SOURCES = $(mono_SOURCES)
107 endif
108
109 genmdesc_SOURCES = \
110         mini.h          \
111         genmdesc.c      \
112         helpers.c
113
114 # Don't link this against libmonoruntime to speed up rebuilds
115 genmdesc_LDADD = \
116         $(monodir)/mono/utils/libmonoutils.la $(monodir)/mono/metadata/opcodes.lo -lm   \
117         $(GLIB_LIBS)
118
119 x86_sources = \
120         mini-x86.c              \
121         mini-x86.h              \
122         exceptions-x86.c        \
123         tramp-x86.c                     \
124         mini-trampolines.c
125
126 amd64_sources = \
127         mini-amd64.c            \
128         mini-amd64.h            \
129         exceptions-amd64.c      \
130         tramp-amd64.c           \
131         mini-trampolines.c
132
133 ppc_sources = \
134         mini-ppc.c              \
135         mini-ppc.h              \
136         exceptions-ppc.c        \
137         tramp-ppc.c
138
139 arm_sources = \
140         mini-arm.c              \
141         mini-arm.h              \
142         exceptions-arm.c        \
143         tramp-arm.c
144
145 mips_sources = \
146         mini-mips.c             \
147         mini-mips.h             \
148         exceptions-mips.c       \
149         tramp-mips.c
150
151 sparc_sources = \
152         mini-sparc.c            \
153         mini-sparc.h            \
154         exceptions-sparc.c      \
155         tramp-sparc.c           \
156         mini-trampolines.c
157
158 s390_sources = \
159         mini-s390.c             \
160         mini-s390.h             \
161         exceptions-s390.c       \
162         tramp-s390.c
163
164 s390x_sources = \
165         mini-s390x.c            \
166         mini-s390x.h            \
167         exceptions-s390x.c      \
168         tramp-s390x.c
169
170 ia64_sources = \
171         mini-ia64.c                     \
172         mini-ia64.h                     \
173         exceptions-ia64.c       \
174         tramp-ia64.c            \
175         mini-trampolines.c
176
177 alpha_sources = \
178         mini-alpha.c    \
179         mini-alpha.h    \
180         exceptions-alpha.c      \
181         tramp-alpha.c   \
182         mini-trampolines.c
183
184 common_sources = \
185         mini.c          \
186         mini.h          \
187         optflags-def.h          \
188         jit-icalls.h \
189         jit-icalls.c \
190         trace.c         \
191         trace.h         \
192         patch-info.h    \
193         mini-ops.h      \
194         mini-arch.h     \
195         dominators.c    \
196         cfold.c         \
197         regalloc.c      \
198         regalloc.h      \
199         helpers.c       \
200         liveness.c      \
201         ssa.c           \
202         abcremoval.c    \
203         abcremoval.h    \
204         ssapre.c        \
205         ssapre.h        \
206         aliasing.c      \
207         aliasing.h      \
208         local-propagation.c     \
209         simple-cee-ops.h \
210         simple-mini-ops.h \
211         driver.c        \
212         debug-mini.c    \
213         linear-scan.c   \
214         aot-compiler.c          \
215         aot-runtime.c           \
216         graph.c         \
217         mini-exceptions.c       \
218         mini-codegen.c          \
219         declsec.c       \
220         declsec.h       \
221         wapihandles.c   \
222         branch-opts.c
223
224 test_sources =          \
225         basic-calls.cs  \
226         basic-long.cs   \
227         bench.cs                \
228         objects.cs              \
229         arrays.cs               \
230         basic-float.cs  \
231         basic-math.cs   \
232         basic.cs                \
233         exceptions.cs   \
234         iltests.il              \
235         test.cs
236
237 test_sources2 = generics.2.cs il2tests.2.il
238
239 if MONO_DEBUGGER_SUPPORTED
240 if AMD64
241 mono_debugger_arch_sources = mdb-debug-info64.s
242 else
243 if ALPHA
244 mono_debugger_arch_sources = mdb-debug-info64.s
245 else
246 mono_debugger_arch_sources = mdb-debug-info32.s
247 endif
248 endif
249 mono_debugger_sources = debug-debugger.c debug-debugger.h $(mono_debugger_arch_sources)
250 else
251 mono_debugger_sources =
252 endif
253
254 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
255 regtests2=generics.exe il2tests.exe
256
257 common_BURGSRC= $(srcdir)/inssel.brg $(srcdir)/inssel-float.brg
258
259 if X86
260 arch_sources = \
261         $(x86_sources) $(mono_debugger_sources)
262 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-x86.brg
263 arch_built=cpu-x86.h
264 endif
265
266 if AMD64
267 arch_sources = \
268         $(amd64_sources) $(mono_debugger_sources)
269 arch_BURGSRC= $(srcdir)/inssel-long.brg $(srcdir)/inssel-amd64.brg
270 arch_built=cpu-amd64.h
271 endif
272
273 if POWERPC
274 arch_sources = \
275         $(ppc_sources)
276 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-ppc.brg
277 arch_built=cpu-g4.h
278 endif
279
280 if MIPS
281 arch_sources = $(mips_sources)
282 arch_BURGSRC= $(srcdir)/inssel-long32-mips.brg $(srcdir)/inssel-mips.brg
283 arch_built=cpu-mips.h
284 endif
285
286 if ARM
287
288 # pick up arm_dpimacros.h and arm_fpamacros.h
289 ARCH_CFLAGS = -I../arch/arm
290
291 arch_sources = $(arm_sources)
292
293 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-arm.brg $(srcdir)/inssel-softfloat.brg
294 arch_built=cpu-arm.h
295 endif
296
297 if SPARC
298 arch_sources = \
299         $(sparc_sources)
300
301 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-sparc.brg
302 arch_built=cpu-sparc.h
303 endif
304
305 if SPARC64
306 arch_sources = \
307         $(sparc_sources)
308
309 arch_BURGSRC= $(srcdir)/inssel-long.brg $(srcdir)/inssel-sparc.brg
310 arch_built=cpu-sparc.h
311 endif
312
313 if S390
314 arch_sources = \
315         $(s390_sources)
316
317 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-s390.brg
318 arch_built=cpu-s390.h
319 endif
320
321 if S390x
322 arch_sources = \
323         $(s390x_sources)
324
325 arch_BURGSRC= $(srcdir)/inssel-long.brg $(srcdir)/inssel-s390x.brg
326 arch_built=cpu-s390x.h
327 endif
328
329 if IA64
330 arch_sources = \
331     $(ia64_sources)
332
333 arch_BURGSRC = $(srcdir)/inssel-long.brg $(srcdir)/inssel-ia64.brg
334 arch_built = cpu-ia64.h
335 endif
336
337 if ALPHA
338 arch_sources = \
339         $(alpha_sources) $(mono_debugger_sources)
340
341 arch_BURGSRC = $(srcdir)/inssel-long.brg $(srcdir)/inssel-alpha.brg
342 arch_built = cpu-alpha.h
343 endif
344
345 libmono_la_SOURCES = $(common_sources) $(arch_sources)
346
347 nodist_libmono_la_SOURCES = inssel.c inssel.h
348
349 libmono_static_la_SOURCES = $(libmono_la_SOURCES)
350 nodist_libmono_static_la_SOURCES = $(nodist_libmono_la_SOURCES)
351 libmono_static_la_LDFLAGS = -static
352 libmono_static_la_LIBADD = $(static_libs)
353
354 BURGSRC= $(common_BURGSRC) $(arch_BURGSRC)
355
356 libmonoincludedir = $(includedir)/mono-$(API_VER)/mono/jit
357
358 libmonoinclude_HEADERS = jit.h
359
360 libmono_la_LIBADD = \
361         $(libs)
362
363 %.exe: %.2.cs TestDriver.dll
364         $(GMCS) -out:$@ $< -r:TestDriver.dll 
365
366 %.exe: %.cs TestDriver.dll
367         $(MCS) -out:$@ -unsafe $< -r:TestDriver.dll
368
369 %.exe: %.2.il
370         $(ILASM2) -output=$@ $<
371
372 %.exe: %.il
373         $(ILASM) -output=$@ $<
374
375 TestDriver.dll: $(srcdir)/TestDriver.cs
376         $(MCS) -out:$@ -target:library $<
377
378 if CROSS_COMPILING
379
380 cpu-x86.h: cpu-x86.md
381 cpu-amd64.h: cpu-amd64.md
382 cpu-g4.h: cpu-g4.md
383 cpu-sparc.h: cpu-sparc.md
384 cpu-s390.h: cpu-s390.md
385 cpu-s390x.h: cpu-s390x.md
386 cpu-ia64.h: cpu-ia64.md
387 cpu-alpha.h: cpu-alpha.md
388 cpu-mips.h: cpu-mips.md
389
390 cpu-arm.h: cpu-arm.md
391         perl genmdesc.pl __arm__ $(srcdir) $(srcdir)/cpu-arm.md cpu-arm.h arm_cpu_desc
392
393 ## Gross hack.  Making 'genmdesc' a host binary takes more effort
394 #$(arch_built):
395 #       echo "*** please build $(arch_built) on a native build tree and copy it here"
396 #       exit 1
397
398 else !CROSS_COMPILING
399
400 cpu-x86.h: cpu-x86.md genmdesc$(EXEEXT)
401         ./genmdesc $(srcdir)/cpu-x86.md cpu-x86.h x86_desc
402
403 cpu-amd64.h: cpu-amd64.md genmdesc$(EXEEXT)
404         ./genmdesc $(srcdir)/cpu-amd64.md cpu-amd64.h amd64_desc
405
406 cpu-g4.h: cpu-g4.md genmdesc$(EXEEXT)
407         ./genmdesc $(srcdir)/cpu-g4.md cpu-g4.h ppcg4
408
409 cpu-arm.h: cpu-arm.md genmdesc$(EXEEXT)
410         ./genmdesc $(srcdir)/cpu-arm.md cpu-arm.h arm_cpu_desc
411
412 cpu-sparc.h: cpu-sparc.md genmdesc$(EXEEXT)
413         ./genmdesc $(srcdir)/cpu-sparc.md cpu-sparc.h sparc_desc
414
415 cpu-s390.h: cpu-s390.md genmdesc$(EXEEXT)
416         ./genmdesc $(srcdir)/cpu-s390.md cpu-s390.h s390_cpu_desc
417
418 cpu-s390x.h: cpu-s390x.md genmdesc$(EXEEXT)
419         ./genmdesc $(srcdir)/cpu-s390x.md cpu-s390x.h s390x_cpu_desc
420
421 cpu-ia64.h: cpu-ia64.md genmdesc$(EXEEXT)
422         ./genmdesc $(srcdir)/cpu-ia64.md cpu-ia64.h ia64_desc
423
424 cpu-alpha.h: cpu-alpha.md genmdesc$(EXEEXT)
425         ./genmdesc $(srcdir)/cpu-alpha.md cpu-alpha.h alpha_desc
426
427 cpu-mips.h: cpu-mips.md genmdesc$(EXEEXT)
428         ./genmdesc $(srcdir)/cpu-mips.md cpu-mips.h mips_desc
429
430 endif !CROSS_COMPILING
431
432 inssel.c inssel.h: $(BURGSRC)
433         $(monodir)/mono/monoburg/monoburg -c 1 -p -e $(BURGSRC) -d inssel.h -s inssel.c
434
435 testi: mono test.exe
436         $(RUNTIME) -v -v --ncompile 1 --compile Test:$(mtest) test.exe
437
438 # ensure the tests are actually correct
439 checktests: $(regtests)
440         for i in $(regtests); do $(RUNTIME) $$i; done
441
442 checktests2: $(regtests2)
443         for i in $(regtests); do $(RUNTIME2) $$i; done
444
445 rcheck: mono $(regtests) $(regtests2)
446         $(RUNTIME) --regression $(regtests)
447         $(RUNTIME2) --regression $(regtests2)
448
449 aotcheck: mono $(regtests)
450         for i in $(regtests); do $(RUNTIME) --aot $$i; done
451 #       for i in $(regtests2); do $(RUNTIME2) --aot $$i; done
452         $(RUNTIME) --regression $(regtests)
453 #       $(RUNTIME2) --verbose --regression $(regtests2)
454         rm -f *.exe.so
455
456 bench: mono test.exe
457         time env $(RUNTIME) --ncompile $(count) --compile Test:$(mtest) test.exe
458
459 mbench: test.exe
460         time $(monodir)/mono/jit/mono --ncompile $(count) --compile Test:$(mtest) test.exe
461
462 stat1: mono bench.exe
463         $(RUNTIME) --verbose --statfile stats.pl --regression bench.exe
464         perl viewstat.pl stats.pl
465
466 stat2: mono basic.exe
467         $(RUNTIME) --verbose --statfile stats.pl --regression basic.exe
468         perl viewstat.pl -e stats.pl
469
470 stat3: mono bench.exe
471         $(RUNTIME) --statfile stats.pl --ncompile 1000 --compile Tests:test_0_many_nested_loops bench.exe 
472         perl viewstat.pl stats.pl
473
474 docu: mini.sgm
475         docbook2txt mini.sgm
476
477 check-local: rcheck
478
479 clean-local:
480         rm -f mono a.out gmon.out *.o test.exe
481
482 pkgconfigdir = $(libdir)/pkgconfig
483
484 if JIT_SUPPORTED
485 BUILT_SOURCES= inssel.c inssel.h $(arch_built)
486 endif
487
488 CLEANFILES= $(BUILT_SOURCES) *.exe *.dll
489 EXTRA_DIST = $(common_BURGSRC) cprop.c TestDriver.cs ldscript ldscript.mono \
490         genmdesc.pl     \
491         $(test_sources) $(test_sources2) \
492         inssel-long.brg inssel-long32.brg \
493         inssel-softfloat.brg    \
494         $(x86_sources) inssel-x86.brg cpu-x86.md \
495         $(amd64_sources) inssel-amd64.brg cpu-amd64.md \
496         $(ppc_sources) inssel-ppc.brg cpu-g4.md \
497         $(arm_sources) inssel-arm.brg cpu-arm.md \
498         $(mips_sources) inssel-mips.brg inssel-long32-mips.brg cpu-mips.md \
499         $(sparc_sources) inssel-sparc.brg cpu-sparc.md \
500         $(s390_sources) inssel-s390.brg cpu-s390.md \
501         $(s390x_sources) inssel-s390x.brg cpu-s390x.md \
502         $(ia64_sources) inssel-ia64.brg cpu-ia64.md \
503         $(alpha_sources) inssel-alpha.brg cpu-alpha.md