1
2# This file should be included (directly or indirectly) by every
3# Makefile.am that builds programs.  And also the top-level Makefile.am.
4
5#----------------------------------------------------------------------------
6# Global stuff
7#----------------------------------------------------------------------------
8
9inplacedir = $(top_builddir)/.in_place
10
11# This used to be required when Vex had a handwritten Makefile.  It
12# shouldn't be needed any more, though.
13##.NOTPARALLEL:
14
15#----------------------------------------------------------------------------
16# noinst_PROGRAMS and noinst_DSYMS targets
17#----------------------------------------------------------------------------
18
19# On Darwin, for a program 'p', the DWARF debug info is stored in the
20# directory 'p.dSYM'.  This must be generated after the executable is
21# created, with 'dsymutil p'.  We could redefine LINK with a script that
22# executes 'dsymutil' after linking, but that's a pain.  Instead we use this
23# hook so that every time "make check" is run, we subsequently invoke
24# 'dsymutil' on all the executables that lack a .dSYM directory, or that are
25# newer than their corresponding .dSYM directory.
26build-noinst_DSYMS: $(noinst_DSYMS)
27	for f in $(noinst_DSYMS); do \
28	  if [ ! -e $$f.dSYM  -o  $$f -nt $$f.dSYM ] ; then \
29	      echo "dsymutil $$f"; \
30	      dsymutil $$f; \
31	  fi; \
32	done
33
34# This is used by coregrind/Makefile.am and Makefile.tool.am for doing
35# "in-place" installs.  It copies $(noinst_PROGRAMS) into $inplacedir.
36# It needs to be depended on by an 'all-local' rule.
37inplace-noinst_PROGRAMS: $(noinst_PROGRAMS)
38	mkdir -p $(inplacedir); \
39	for f in $(noinst_PROGRAMS) ; do \
40	  rm -f $(inplacedir)/$$f; \
41	  ln -f -s ../$(subdir)/$$f $(inplacedir); \
42	done
43
44# Similar to inplace-noinst_PROGRAMS
45inplace-noinst_DSYMS: build-noinst_DSYMS
46	mkdir -p $(inplacedir); \
47	for f in $(noinst_DSYMS); do \
48	  rm -f $(inplacedir)/$$f.dSYM; \
49	  ln -f -s ../$(subdir)/$$f.dSYM $(inplacedir); \
50	done
51
52# This is used by coregrind/Makefile.am and by <tool>/Makefile.am for doing
53# "make install".  It copies $(noinst_PROGRAMS) into $prefix/lib/valgrind/.
54# It needs to be depended on by an 'install-exec-local' rule.
55install-noinst_PROGRAMS: $(noinst_PROGRAMS)
56	$(mkinstalldirs) $(DESTDIR)$(pkglibdir); \
57	for f in $(noinst_PROGRAMS); do \
58	  $(INSTALL_PROGRAM) $$f $(DESTDIR)$(pkglibdir); \
59	done
60
61# This is used by coregrind/Makefile.am and by <tool>/Makefile.am for doing
62# "make uninstall".  It removes $(noinst_PROGRAMS) from $prefix/lib/valgrind/.
63# It needs to be depended on by an 'uninstall-local' rule.
64uninstall-noinst_PROGRAMS:
65	for f in $(noinst_PROGRAMS); do \
66	  rm -f $(DESTDIR)$(pkglibdir)/$$f; \
67	done
68
69# Similar to install-noinst_PROGRAMS.
70# Nb: we don't use $(INSTALL_PROGRAM) here because it doesn't work with
71# directories.  XXX: not sure whether the resulting permissions will be
72# correct when using 'cp -R'...
73install-noinst_DSYMS: build-noinst_DSYMS
74	$(mkinstalldirs) $(DESTDIR)$(pkglibdir); \
75	for f in $(noinst_DSYMS); do \
76	  cp -R $$f.dSYM $(DESTDIR)$(pkglibdir); \
77	done
78
79# Similar to uninstall-noinst_PROGRAMS.
80uninstall-noinst_DSYMS:
81	for f in $(noinst_DSYMS); do \
82	  rm -f $(DESTDIR)$(pkglibdir)/$$f.dSYM; \
83	done
84
85# This needs to be depended on by a 'clean-local' rule.
86clean-noinst_DSYMS:
87	for f in $(noinst_DSYMS); do \
88	  rm -rf $$f.dSYM; \
89	done
90
91#----------------------------------------------------------------------------
92# Flags
93#----------------------------------------------------------------------------
94
95# Baseline flags for all compilations.  Aim here is to maximise
96# performance and get whatever useful warnings we can out of gcc.
97# -fno-builtin is important for defeating LLVM's idiom recognition
98# that somehow causes VG_(memset) to get into infinite recursion.
99AM_CFLAGS_BASE = \
100	-O2 -g \
101	-std=gnu99 \
102	-Wall \
103	-Wmissing-prototypes \
104	-Wshadow \
105	-Wpointer-arith \
106	-Wstrict-prototypes \
107	-Wmissing-declarations \
108	@FLAG_W_CAST_ALIGN@ \
109	@FLAG_W_CAST_QUAL@ \
110	@FLAG_W_WRITE_STRINGS@ \
111	@FLAG_W_EMPTY_BODY@ \
112	@FLAG_W_FORMAT@ \
113	@FLAG_W_FORMAT_SIGNEDNESS@ \
114	@FLAG_W_FORMAT_SECURITY@ \
115	@FLAG_W_IGNORED_QUALIFIERS@ \
116	@FLAG_W_MISSING_PARAMETER_TYPE@ \
117	@FLAG_W_OLD_STYLE_DECLARATION@ \
118	@FLAG_FNO_STACK_PROTECTOR@ \
119	@FLAG_FSANITIZE@ \
120	-fno-strict-aliasing \
121	-fno-builtin
122
123if COMPILER_IS_CLANG
124AM_CFLAGS_BASE += -Wno-cast-align -Wno-self-assign \
125                  -Wno-tautological-compare
126endif
127
128# These flags are used for building the preload shared objects (PSOs).
129# The aim is to give reasonable performance but also to have good
130# stack traces, since users often see stack traces extending
131# into (and through) the preloads.  Also, we must use any
132# -mpreferred-stack-boundary flag to build the preload shared
133# objects, since that risks misaligning the client's stack and
134# results in segfaults like (eg) #324050.
135if VGCONF_OS_IS_DARWIN
136AM_CFLAGS_PSO_BASE = -dynamic \
137		     -O -g -fno-omit-frame-pointer -fno-strict-aliasing \
138		     -fpic -fPIC -fno-builtin @FLAG_FNO_IPA_ICF@
139else
140AM_CFLAGS_PSO_BASE = -O -g -fno-omit-frame-pointer -fno-strict-aliasing \
141		     -fpic -fno-builtin @FLAG_FNO_IPA_ICF@
142endif
143
144
145# Flags for specific targets.
146#
147# Nb: the AM_CPPFLAGS_* values are suitable for building tools and auxprogs.
148# For building the core, coregrind/Makefile.am files add some extra things.
149
150AM_CPPFLAGS_@VGCONF_PLATFORM_PRI_CAPS@ = \
151	-I$(top_srcdir) \
152	-I$(top_srcdir)/include \
153	-I$(top_srcdir)/VEX/pub \
154	-I$(top_builddir)/VEX/pub \
155	-DVGA_@VGCONF_ARCH_PRI@=1 \
156	-DVGO_@VGCONF_OS@=1 \
157	-DVGP_@VGCONF_ARCH_PRI@_@VGCONF_OS@=1 \
158	-DVGPV_@VGCONF_ARCH_PRI@_@VGCONF_OS@_@VGCONF_PLATVARIANT@=1
159if VGCONF_HAVE_PLATFORM_SEC
160AM_CPPFLAGS_@VGCONF_PLATFORM_SEC_CAPS@ = \
161	-I$(top_srcdir) \
162	-I$(top_srcdir)/include \
163	-I$(top_srcdir)/VEX/pub \
164	-I$(top_builddir)/VEX/pub \
165	-DVGA_@VGCONF_ARCH_SEC@=1 \
166	-DVGO_@VGCONF_OS@=1 \
167	-DVGP_@VGCONF_ARCH_SEC@_@VGCONF_OS@=1 \
168	-DVGPV_@VGCONF_ARCH_SEC@_@VGCONF_OS@_@VGCONF_PLATVARIANT@=1
169endif
170
171AM_FLAG_M3264_X86_LINUX   = @FLAG_M32@
172AM_CFLAGS_X86_LINUX       = @FLAG_M32@ @PREFERRED_STACK_BOUNDARY_2@ \
173				$(AM_CFLAGS_BASE) -fomit-frame-pointer
174AM_CFLAGS_PSO_X86_LINUX   = @FLAG_M32@ $(AM_CFLAGS_BASE) $(AM_CFLAGS_PSO_BASE)
175AM_CCASFLAGS_X86_LINUX    = @FLAG_M32@ -g
176
177AM_FLAG_M3264_AMD64_LINUX = @FLAG_M64@
178AM_CFLAGS_AMD64_LINUX     = @FLAG_M64@ \
179				$(AM_CFLAGS_BASE) -fomit-frame-pointer
180AM_CFLAGS_PSO_AMD64_LINUX = @FLAG_M64@ $(AM_CFLAGS_BASE) $(AM_CFLAGS_PSO_BASE)
181AM_CCASFLAGS_AMD64_LINUX  = @FLAG_M64@ -g
182
183AM_FLAG_M3264_PPC32_LINUX = @FLAG_M32@
184AM_CFLAGS_PPC32_LINUX     = @FLAG_M32@ $(AM_CFLAGS_BASE)
185AM_CFLAGS_PSO_PPC32_LINUX = @FLAG_M32@ $(AM_CFLAGS_BASE) $(AM_CFLAGS_PSO_BASE)
186AM_CCASFLAGS_PPC32_LINUX  = @FLAG_M32@ -g
187
188AM_FLAG_M3264_PPC64BE_LINUX = @FLAG_M64@
189AM_CFLAGS_PPC64BE_LINUX     = @FLAG_M64@ $(AM_CFLAGS_BASE)
190AM_CFLAGS_PSO_PPC64BE_LINUX = @FLAG_M64@ $(AM_CFLAGS_BASE) $(AM_CFLAGS_PSO_BASE)
191AM_CCASFLAGS_PPC64BE_LINUX  = @FLAG_M64@ -g
192
193AM_FLAG_M3264_PPC64LE_LINUX = @FLAG_M64@
194AM_CFLAGS_PPC64LE_LINUX     = @FLAG_M64@ $(AM_CFLAGS_BASE)
195AM_CFLAGS_PSO_PPC64LE_LINUX = @FLAG_M64@ $(AM_CFLAGS_BASE) $(AM_CFLAGS_PSO_BASE)
196AM_CCASFLAGS_PPC64LE_LINUX  = @FLAG_M64@ -g
197
198AM_FLAG_M3264_ARM_LINUX   = @FLAG_M32@
199AM_CFLAGS_ARM_LINUX       = @FLAG_M32@ \
200			 	$(AM_CFLAGS_BASE) -marm -mcpu=cortex-a8
201AM_CFLAGS_PSO_ARM_LINUX   = @FLAG_M32@ $(AM_CFLAGS_BASE) \
202				-marm -mcpu=cortex-a8 $(AM_CFLAGS_PSO_BASE)
203AM_CCASFLAGS_ARM_LINUX    = @FLAG_M32@ \
204				-marm -mcpu=cortex-a8 -g
205
206AM_FLAG_M3264_ARM64_LINUX = @FLAG_M64@
207AM_CFLAGS_ARM64_LINUX     = @FLAG_M64@ $(AM_CFLAGS_BASE)
208AM_CFLAGS_PSO_ARM64_LINUX = @FLAG_M64@ $(AM_CFLAGS_BASE) $(AM_CFLAGS_PSO_BASE)
209AM_CCASFLAGS_ARM64_LINUX  = @FLAG_M64@ -g
210
211AM_FLAG_M3264_X86_DARWIN = -arch i386
212AM_CFLAGS_X86_DARWIN     = $(WERROR) -arch i386 $(AM_CFLAGS_BASE) \
213				-mmacosx-version-min=10.5 \
214				-fno-stack-protector -fno-pic -fno-PIC
215
216AM_CFLAGS_PSO_X86_DARWIN = $(AM_CFLAGS_X86_DARWIN) $(AM_CFLAGS_PSO_BASE)
217AM_CCASFLAGS_X86_DARWIN  = -arch i386 -g
218
219AM_FLAG_M3264_AMD64_DARWIN = -arch x86_64
220AM_CFLAGS_AMD64_DARWIN     = $(WERROR) -arch x86_64 $(AM_CFLAGS_BASE) \
221			    -mmacosx-version-min=10.5 -fno-stack-protector
222AM_CFLAGS_PSO_AMD64_DARWIN = $(AM_CFLAGS_AMD64_DARWIN) $(AM_CFLAGS_PSO_BASE)
223AM_CCASFLAGS_AMD64_DARWIN  = -arch x86_64 -g
224
225AM_FLAG_M3264_S390X_LINUX = @FLAG_M64@
226AM_CFLAGS_S390X_LINUX     = @FLAG_M64@ $(AM_CFLAGS_BASE) -fomit-frame-pointer
227AM_CFLAGS_PSO_S390X_LINUX = @FLAG_M64@ $(AM_CFLAGS_BASE) $(AM_CFLAGS_PSO_BASE)
228AM_CCASFLAGS_S390X_LINUX  = @FLAG_M64@ -g -mzarch -march=z900
229
230AM_FLAG_M3264_MIPS32_LINUX = @FLAG_M32@
231AM_CFLAGS_MIPS32_LINUX     = @FLAG_M32@ $(AM_CFLAGS_BASE) @FLAG_MIPS32@
232AM_CFLAGS_PSO_MIPS32_LINUX = @FLAG_M32@ $(AM_CFLAGS_BASE) @FLAG_MIPS32@ \
233				$(AM_CFLAGS_PSO_BASE)
234AM_CCASFLAGS_MIPS32_LINUX  = @FLAG_M32@ -g @FLAG_MIPS32@
235
236AM_FLAG_M3264_MIPS64_LINUX = @FLAG_M64@
237AM_CFLAGS_MIPS64_LINUX     = @FLAG_M64@ $(AM_CFLAGS_BASE) @FLAG_MIPS64@
238AM_CFLAGS_PSO_MIPS64_LINUX = @FLAG_M64@ $(AM_CFLAGS_BASE) @FLAG_MIPS64@ \
239				$(AM_CFLAGS_PSO_BASE)
240AM_CCASFLAGS_MIPS64_LINUX  = @FLAG_M64@ -g @FLAG_MIPS64@
241
242AM_CFLAGS_TILEGX_LINUX     = @FLAG_M64@ $(AM_CFLAGS_BASE)
243AM_CFLAGS_PSO_TILEGX_LINUX = @FLAG_M64@ $(AM_CFLAGS_BASE) $(AM_CFLAGS_PSO_BASE)
244
245AM_FLAG_M3264_X86_SOLARIS   = @FLAG_M32@
246AM_CFLAGS_X86_SOLARIS       = @FLAG_M32@ @PREFERRED_STACK_BOUNDARY_2@ \
247			 	$(AM_CFLAGS_BASE) -fomit-frame-pointer
248AM_CFLAGS_PSO_X86_SOLARIS   = @FLAG_M32@ $(AM_CFLAGS_BASE) $(AM_CFLAGS_PSO_BASE)
249AM_CCASFLAGS_X86_SOLARIS    = @FLAG_M32@ -g -D_ASM
250
251AM_FLAG_M3264_AMD64_SOLARIS = @FLAG_M64@
252AM_CFLAGS_AMD64_SOLARIS     = @FLAG_M64@ \
253				$(AM_CFLAGS_BASE) -fomit-frame-pointer
254AM_CFLAGS_PSO_AMD64_SOLARIS  = @FLAG_M64@ $(AM_CFLAGS_BASE) $(AM_CFLAGS_PSO_BASE)
255AM_CCASFLAGS_AMD64_SOLARIS  = @FLAG_M64@ -g -D_ASM
256
257# Flags for the primary target.  These must be used to build the
258# regtests and performance tests.  In fact, these must be used to
259# build anything which is built only once on a dual-arch build.
260#
261AM_FLAG_M3264_PRI = $(AM_FLAG_M3264_@VGCONF_PLATFORM_PRI_CAPS@)
262AM_CPPFLAGS_PRI   = $(AM_CPPFLAGS_@VGCONF_PLATFORM_PRI_CAPS@)
263AM_CFLAGS_PRI     = $(AM_CFLAGS_@VGCONF_PLATFORM_PRI_CAPS@)
264AM_CCASFLAGS_PRI  = $(AM_CCASFLAGS_@VGCONF_PLATFORM_PRI_CAPS@)
265
266if VGCONF_HAVE_PLATFORM_SEC
267 AM_FLAG_M3264_SEC = $(AM_FLAG_M3264_@VGCONF_PLATFORM_SEC_CAPS@)
268else
269 AM_FLAG_M3264_SEC =
270endif
271
272
273# Baseline link flags for making vgpreload shared objects.
274#
275PRELOAD_LDFLAGS_COMMON_LINUX  = -nodefaultlibs -shared -Wl,-z,interpose,-z,initfirst
276PRELOAD_LDFLAGS_COMMON_DARWIN = -dynamic -dynamiclib -all_load
277PRELOAD_LDFLAGS_COMMON_SOLARIS = -nodefaultlibs -shared -Wl,-z,interpose,-z,initfirst
278if SOLARIS_XPG_SYMBOLS_PRESENT
279PRELOAD_LDFLAGS_COMMON_SOLARIS += -Wl,-M,$(top_srcdir)/solaris/vgpreload-solaris.mapfile
280endif
281
282if VGCONF_PLATVARIANT_IS_ANDROID
283# The Android toolchain includes all kinds of stdlib helpers present in
284# bionic which is bad because we are not linking with it and the Android
285# linker will panic.
286PRELOAD_LDFLAGS_COMMON_LINUX += -nostdlib
287endif
288
289PRELOAD_LDFLAGS_X86_LINUX      = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M32@
290PRELOAD_LDFLAGS_AMD64_LINUX    = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M64@
291PRELOAD_LDFLAGS_PPC32_LINUX    = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M32@
292PRELOAD_LDFLAGS_PPC64BE_LINUX  = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M64@
293PRELOAD_LDFLAGS_PPC64LE_LINUX  = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M64@
294PRELOAD_LDFLAGS_ARM_LINUX      = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M32@
295PRELOAD_LDFLAGS_ARM64_LINUX    = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M64@
296PRELOAD_LDFLAGS_X86_DARWIN     = $(PRELOAD_LDFLAGS_COMMON_DARWIN) -arch i386
297PRELOAD_LDFLAGS_AMD64_DARWIN   = $(PRELOAD_LDFLAGS_COMMON_DARWIN) -arch x86_64
298PRELOAD_LDFLAGS_S390X_LINUX    = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M64@
299PRELOAD_LDFLAGS_MIPS32_LINUX   = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M32@
300PRELOAD_LDFLAGS_MIPS64_LINUX   = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M64@
301PRELOAD_LDFLAGS_TILEGX_LINUX   = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M64@
302PRELOAD_LDFLAGS_X86_SOLARIS    = $(PRELOAD_LDFLAGS_COMMON_SOLARIS) @FLAG_M32@
303PRELOAD_LDFLAGS_AMD64_SOLARIS  = $(PRELOAD_LDFLAGS_COMMON_SOLARIS) @FLAG_M64@
304
305