1AM_CPPFLAGS = \
2	-DSUPPRESSION_DIR=\""$(datadir)/mono-$(API_VER)/mono/profiler"\" \
3	-I$(top_srcdir) \
4	$(GLIB_CFLAGS)
5
6if !HOST_WIN32
7if !DISABLE_LIBRARIES
8if !DISABLE_PROFILER
9
10bin_PROGRAMS = mprof-report
11
12if HAVE_VTUNE
13vtune_libs = \
14	libmono-profiler-vtune.la \
15	libmono-profiler-vtune-static.la
16endif
17
18lib_LTLIBRARIES = \
19	libmono-profiler-aot.la \
20	libmono-profiler-aot-static.la \
21	libmono-profiler-log.la \
22	libmono-profiler-log-static.la \
23	libmono-profiler-coverage.la \
24	libmono-profiler-coverage-static.la \
25	$(vtune_libs)
26
27suppressiondir = $(datadir)/mono-$(API_VER)/mono/profiler
28suppression_DATA = \
29	mono-profiler-coverage.suppression \
30	mono-profiler-log.suppression
31
32# FIXME: The profiler tests currently don't work with coop because the
33# sampling infrastructure depends on signals being available.
34#
35# See: https://bugzilla.xamarin.com/show_bug.cgi?id=57011
36if !ENABLE_COOP
37check_targets = testlog
38endif
39
40endif
41endif
42endif
43
44# On Apple hosts, we want to allow undefined symbols when building the
45# profiler modules as, just like on Linux, we don't link them to libmono,
46# but rather let the dynamic linker sort things out.
47#
48# Bitcode, specifically, doesn't allow undefined symbols at all, even for
49# shared libraries, so we want errors if the profiler modules contain any.
50if HOST_DARWIN
51if BITCODE
52prof_ldflags = -no-undefined
53else
54prof_ldflags = -Wl,-undefined -Wl,suppress -Wl,-flat_namespace
55endif
56endif
57
58# Versioned libraries are problematic on Android. In particular, we're not
59# allowed to place versioned libraries inside APKs, so if libmono and the
60# profiler modules contain versioned sonames, things will fail to resolve
61# at runtime.
62if HOST_ANDROID
63prof_ldflags = -avoid-version
64endif
65
66# Linking to libmono on desktop can cause problems when loading a profiler
67# module into a statically-linked mono executable, e.g. running library
68# constructors multiple times, which can easily break LLVM libraries. So,
69# we don't want to link to libmono on desktop. On Android, libmono is
70# always loaded dynamically, so we do need to link to libmono there or the
71# dynamic linker will have trouble resolving everything. On iOS, the story
72# is similar to Android when running in the simulator.
73if HOST_ANDROID
74libmono_dep = $(top_builddir)/mono/mini/$(LIBMONO_LA)
75else
76if HOST_IOS
77# Note that BITCODE implies HOST_IOS, so this case ensures that we link to
78# libmono when building a bitcode runtime.
79libmono_dep = $(top_builddir)/mono/mini/$(LIBMONO_LA)
80else
81if HOST_TIZEN
82libmono_dep = $(top_builddir)/mono/mini/$(LIBMONO_LA)
83else
84libmono_dep =
85endif
86endif
87endif
88
89if HAVE_ZLIB
90# The log profiler uses zlib for output compression when available.
91zlib_dep = -lz
92else
93zlib_dep =
94endif
95
96# We build a separate, static version of each profiler for use on targets
97# which do not support dynamic linking (e.g. iOS). We still want to build
98# the shared version on those targets since it's useful for e.g. simulator
99# builds.
100
101libmono_profiler_aot_la_SOURCES = aot.c
102libmono_profiler_aot_la_LIBADD =  $(libmono_dep) $(GLIB_LIBS) $(LIBICONV)
103libmono_profiler_aot_la_LDFLAGS = $(prof_ldflags)
104libmono_profiler_aot_static_la_SOURCES = aot.c
105libmono_profiler_aot_static_la_LDFLAGS = -static
106
107libmono_profiler_log_la_SOURCES = log.c log-args.c
108libmono_profiler_log_la_LIBADD = $(libmono_dep) $(GLIB_LIBS) $(zlib_dep)
109libmono_profiler_log_la_LDFLAGS = $(prof_ldflags)
110libmono_profiler_log_static_la_SOURCES = log.c log-args.c
111libmono_profiler_log_static_la_LDFLAGS = -static
112
113libmono_profiler_coverage_la_SOURCES = coverage.c
114libmono_profiler_coverage_la_LIBADD = $(libmono_dep) $(GLIB_LIBS)
115libmono_profiler_coverage_la_LDFLAGS = $(prof_ldflags)
116libmono_profiler_coverage_static_la_SOURCES = coverage.c
117libmono_profiler_coverage_static_la_LDFLAGS = -static
118
119if HAVE_VTUNE
120libmono_profiler_vtune_la_SOURCES = vtune.c
121libmono_profiler_vtune_la_CFLAGS = $(VTUNE_CFLAGS)
122libmono_profiler_vtune_la_LIBADD = $(VTUNE_LIBS) $(libmono_dep) $(GLIB_LIBS) $(LIBICONV)
123libmono_profiler_vtune_la_LDFLAGS = $(prof_ldflags)
124libmono_profiler_vtune_static_la_SOURCES = vtune.c
125libmono_profiler_vtune_static_la_LDFLAGS = -static
126libmono_profiler_vtune_static_la_CFLAGS = $(VTUNE_CFLAGS)
127libmono_profiler_vtune_static_la_LIBADD = $(VTUNE_LIBS)
128endif
129
130mprof_report_SOURCES = mprof-report.c
131mprof_report_LDADD = $(GLIB_LIBS) $(LIBICONV) $(zlib_dep)
132
133PLOG_TESTS_SRC = \
134	test-alloc.cs \
135	test-busy.cs \
136	test-monitor.cs \
137	test-excleave.cs \
138	test-heapshot.cs \
139	test-traces.cs
140
141PLOG_TESTS = $(PLOG_TESTS_SRC:.cs=.exe)
142
143CLASS = $(mcs_topdir)/class/lib/$(DEFAULT_PROFILE)
144TOOLS_RUNTIME = MONO_PATH=$(mcs_topdir)/class/lib/build $(top_builddir)/runtime/mono-wrapper
145MCS = $(TOOLS_RUNTIME) $(CSC) -lib:$(CLASS) -unsafe -nologo -noconfig -nowarn:0162 -nowarn:0168 -nowarn:0219 -debug:portable
146
147%.exe: %.cs
148	$(MCS) -out:$@ $<
149
150testlog: $(PLOG_TESTS)
151	MONO_PATH=$(CLASS) perl $(srcdir)/ptestrunner.pl $(top_builddir)
152
153check-local: $(check_targets)
154
155EXTRA_DIST = \
156	log.h \
157	aot.h \
158	$(PLOG_TESTS_SRC) \
159	ptestrunner.pl \
160	$(suppression_DATA)
161