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