blob: 1f69802c227757ada9d35f9b1bd48c51fdbe0426 [file] [log] [blame]
nethercote4388a402004-09-01 23:20:49 +00001
njn8b68b642009-06-24 00:37:09 +00002# This file should be included (directly or indirectly) by every
3# Makefile.am that builds programs. And also the top-level Makefile.am.
nethercote4388a402004-09-01 23:20:49 +00004
njn8b68b642009-06-24 00:37:09 +00005#----------------------------------------------------------------------------
6# Global stuff
7#----------------------------------------------------------------------------
8
nethercote4388a402004-09-01 23:20:49 +00009inplacedir = $(top_builddir)/.in_place
10
njn8b68b642009-06-24 00:37:09 +000011# This used to be required when Vex had a handwritten Makefile. It
12# shouldn't be needed any more, though.
13##.NOTPARALLEL:
nethercote4388a402004-09-01 23:20:49 +000014
njn8b68b642009-06-24 00:37:09 +000015#----------------------------------------------------------------------------
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)
njn609f25d2009-06-24 08:32:07 +000038 mkdir -p $(inplacedir); \
39 for f in $(noinst_PROGRAMS) ; do \
njnb169a8c2010-06-22 06:46:15 +000040 rm -f $(inplacedir)/$$f; \
41 ln -f -s ../$(subdir)/$$f $(inplacedir); \
njn609f25d2009-06-24 08:32:07 +000042 done
njn8b68b642009-06-24 00:37:09 +000043
44# Similar to inplace-noinst_PROGRAMS
45inplace-noinst_DSYMS: build-noinst_DSYMS
njn609f25d2009-06-24 08:32:07 +000046 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
njn8b68b642009-06-24 00:37:09 +000051
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)
njn609f25d2009-06-24 08:32:07 +000056 $(mkinstalldirs) $(DESTDIR)$(pkglibdir); \
57 for f in $(noinst_PROGRAMS); do \
njnb169a8c2010-06-22 06:46:15 +000058 $(INSTALL_PROGRAM) $$f $(DESTDIR)$(pkglibdir); \
njn609f25d2009-06-24 08:32:07 +000059 done
njn8b68b642009-06-24 00:37:09 +000060
61# Similar to install-noinst_PROGRAMS.
62# Nb: we don't use $(INSTALL_PROGRAM) here because it doesn't work with
63# directories. XXX: not sure whether the resulting permissions will be
64# correct when using 'cp -R'...
65install-noinst_DSYMS: build-noinst_DSYMS
njn609f25d2009-06-24 08:32:07 +000066 $(mkinstalldirs) $(DESTDIR)$(pkglibdir); \
67 for f in $(noinst_DSYMS); do \
68 cp -R $$f.dSYM $(DESTDIR)$(pkglibdir); \
69 done
njn8b68b642009-06-24 00:37:09 +000070
71# This needs to be depended on by a 'clean-local' rule.
72clean-noinst_DSYMS:
73 for f in $(noinst_DSYMS); do \
74 rm -rf $$f.dSYM; \
75 done
76
77#----------------------------------------------------------------------------
78# Flags
79#----------------------------------------------------------------------------
80
81# Baseline flags for all compilations. Aim here is to maximise
82# performance and get whatever useful warnings we can out of gcc.
sewardjbd9b7312011-09-29 17:29:53 +000083# -fno-builtin is important for defeating LLVM's idiom recognition
84# that somehow causes VG_(memset) to get into infinite recursion.
njn8b68b642009-06-24 00:37:09 +000085AM_CFLAGS_BASE = \
86 -O2 -g \
87 -Wall \
88 -Wmissing-prototypes \
89 -Wshadow \
90 -Wpointer-arith \
91 -Wstrict-prototypes \
92 -Wmissing-declarations \
93 @FLAG_W_NO_FORMAT_ZERO_LENGTH@ \
sewardjbd9b7312011-09-29 17:29:53 +000094 -fno-strict-aliasing \
95 -fno-builtin
njn8b68b642009-06-24 00:37:09 +000096
97# These flags are used for building the preload shared objects.
98# The aim is to give reasonable performance but also to have good
99# stack traces, since users often see stack traces extending
100# into (and through) the preloads.
101if VGCONF_OS_IS_DARWIN
njnea2d6fd2010-07-01 00:20:20 +0000102AM_CFLAGS_PIC = -dynamic -O -g -fno-omit-frame-pointer -fno-strict-aliasing \
sewardjbd9b7312011-09-29 17:29:53 +0000103 -mno-dynamic-no-pic -fpic -fPIC \
104 -fno-builtin
njn8b68b642009-06-24 00:37:09 +0000105else
sewardjbd9b7312011-09-29 17:29:53 +0000106AM_CFLAGS_PIC = -fpic -O -g -fno-omit-frame-pointer -fno-strict-aliasing \
107 -fno-builtin
njn8b68b642009-06-24 00:37:09 +0000108endif
109
110
111# Flags for specific targets.
112#
113# Nb: the AM_CPPFLAGS_* values are suitable for building tools and auxprogs.
114# For building the core, coregrind/Makefile.am files add some extra things.
njn8b68b642009-06-24 00:37:09 +0000115
116AM_CPPFLAGS_@VGCONF_PLATFORM_PRI_CAPS@ = \
sewardj59570ff2010-01-01 11:59:33 +0000117 -I$(top_srcdir) \
118 -I$(top_srcdir)/include \
njn8b68b642009-06-24 00:37:09 +0000119 -I$(top_srcdir)/VEX/pub \
120 -DVGA_@VGCONF_ARCH_PRI@=1 \
121 -DVGO_@VGCONF_OS@=1 \
sewardjcb495c82011-07-11 20:42:34 +0000122 -DVGP_@VGCONF_ARCH_PRI@_@VGCONF_OS@=1 \
123 -DVGPV_@VGCONF_ARCH_PRI@_@VGCONF_OS@_@VGCONF_PLATVARIANT@=1
njn8b68b642009-06-24 00:37:09 +0000124if VGCONF_HAVE_PLATFORM_SEC
125AM_CPPFLAGS_@VGCONF_PLATFORM_SEC_CAPS@ = \
sewardj59570ff2010-01-01 11:59:33 +0000126 -I$(top_srcdir) \
127 -I$(top_srcdir)/include \
njn8b68b642009-06-24 00:37:09 +0000128 -I$(top_srcdir)/VEX/pub \
129 -DVGA_@VGCONF_ARCH_SEC@=1 \
130 -DVGO_@VGCONF_OS@=1 \
sewardjcb495c82011-07-11 20:42:34 +0000131 -DVGP_@VGCONF_ARCH_SEC@_@VGCONF_OS@=1 \
132 -DVGPV_@VGCONF_ARCH_SEC@_@VGCONF_OS@_@VGCONF_PLATVARIANT@=1
njn8b68b642009-06-24 00:37:09 +0000133endif
134
135AM_FLAG_M3264_X86_LINUX = @FLAG_M32@
philippea5e13e52012-05-15 21:04:31 +0000136AM_CFLAGS_X86_LINUX = @FLAG_M32@ @PREFERRED_STACK_BOUNDARY@ \
137 $(AM_CFLAGS_BASE) -fomit-frame-pointer
florianef0bca62012-05-06 03:37:25 +0000138AM_CCASFLAGS_X86_LINUX = @FLAG_M32@ -g
njn8b68b642009-06-24 00:37:09 +0000139
140AM_FLAG_M3264_AMD64_LINUX = @FLAG_M64@
philippea5e13e52012-05-15 21:04:31 +0000141AM_CFLAGS_AMD64_LINUX = @FLAG_M64@ @PREFERRED_STACK_BOUNDARY@ \
142 $(AM_CFLAGS_BASE) -fomit-frame-pointer
florianef0bca62012-05-06 03:37:25 +0000143AM_CCASFLAGS_AMD64_LINUX = @FLAG_M64@ -g
njn8b68b642009-06-24 00:37:09 +0000144
145AM_FLAG_M3264_PPC32_LINUX = @FLAG_M32@
146AM_CFLAGS_PPC32_LINUX = @FLAG_M32@ $(AM_CFLAGS_BASE)
florianef0bca62012-05-06 03:37:25 +0000147AM_CCASFLAGS_PPC32_LINUX = @FLAG_M32@ -g
njn8b68b642009-06-24 00:37:09 +0000148
149AM_FLAG_M3264_PPC64_LINUX = @FLAG_M64@
150AM_CFLAGS_PPC64_LINUX = @FLAG_M64@ $(AM_CFLAGS_BASE)
florianef0bca62012-05-06 03:37:25 +0000151AM_CCASFLAGS_PPC64_LINUX = @FLAG_M64@ -g
njn8b68b642009-06-24 00:37:09 +0000152
sewardj59570ff2010-01-01 11:59:33 +0000153AM_FLAG_M3264_ARM_LINUX = @FLAG_M32@
154AM_CFLAGS_ARM_LINUX = @FLAG_M32@ @PREFERRED_STACK_BOUNDARY@ \
sewardjfc5ff1f2011-05-31 07:17:54 +0000155 $(AM_CFLAGS_BASE) -marm -mcpu=cortex-a8
florianef0bca62012-05-06 03:37:25 +0000156AM_CCASFLAGS_ARM_LINUX = @FLAG_M32@ \
sewardjfc5ff1f2011-05-31 07:17:54 +0000157 -marm -mcpu=cortex-a8 -g
sewardj59570ff2010-01-01 11:59:33 +0000158
njn8b68b642009-06-24 00:37:09 +0000159AM_FLAG_M3264_X86_DARWIN = -arch i386
160AM_CFLAGS_X86_DARWIN = $(WERROR) -arch i386 $(AM_CFLAGS_BASE) \
njnea2d6fd2010-07-01 00:20:20 +0000161 -mmacosx-version-min=10.5 \
162 -fno-stack-protector -fno-pic -fno-PIC
163
florianef0bca62012-05-06 03:37:25 +0000164AM_CCASFLAGS_X86_DARWIN = -arch i386 -g
njn8b68b642009-06-24 00:37:09 +0000165
166AM_FLAG_M3264_AMD64_DARWIN = -arch x86_64
167AM_CFLAGS_AMD64_DARWIN = $(WERROR) -arch x86_64 $(AM_CFLAGS_BASE) \
168 -mmacosx-version-min=10.5 -fno-stack-protector
florianef0bca62012-05-06 03:37:25 +0000169AM_CCASFLAGS_AMD64_DARWIN = -arch x86_64 -g
njn8b68b642009-06-24 00:37:09 +0000170
sewardjb5b87402011-03-07 16:05:35 +0000171AM_FLAG_M3264_S390X_LINUX = @FLAG_M64@
florian88430312012-05-21 16:18:23 +0000172AM_CFLAGS_S390X_LINUX = @FLAG_M64@ $(AM_CFLAGS_BASE) -fomit-frame-pointer
florianef0bca62012-05-06 03:37:25 +0000173AM_CCASFLAGS_S390X_LINUX = @FLAG_M64@ -g -mzarch -march=z900
174
sewardj5db15402012-06-07 09:13:21 +0000175AM_FLAG_M3264_MIPS32_LINUX = @FLAG_M32@
176AM_CFLAGS_MIPS32_LINUX = @FLAG_M32@ $(AM_CFLAGS_BASE) -mips32
177AM_CCASFLAGS_MIPS32_LINUX = @FLAG_M32@ -mips32 -g
178
petarj4df0bfc2013-02-27 23:17:33 +0000179AM_FLAG_M3264_MIPS64_LINUX = @FLAG_M64@
180AM_CFLAGS_MIPS64_LINUX = @FLAG_M64@ $(AM_CFLAGS_BASE) -mips64
181AM_CCASFLAGS_MIPS64_LINUX = @FLAG_M64@ -mips64 -g
sewardjb5b87402011-03-07 16:05:35 +0000182
njn8b68b642009-06-24 00:37:09 +0000183# Flags for the primary target. These must be used to build the
184# regtests and performance tests. In fact, these must be used to
185# build anything which is built only once on a dual-arch build.
186#
187AM_FLAG_M3264_PRI = $(AM_FLAG_M3264_@VGCONF_PLATFORM_PRI_CAPS@)
188AM_CPPFLAGS_PRI = $(AM_CPPFLAGS_@VGCONF_PLATFORM_PRI_CAPS@)
189AM_CFLAGS_PRI = $(AM_CFLAGS_@VGCONF_PLATFORM_PRI_CAPS@)
190AM_CCASFLAGS_PRI = $(AM_CCASFLAGS_@VGCONF_PLATFORM_PRI_CAPS@)
191
192if VGCONF_HAVE_PLATFORM_SEC
193 AM_FLAG_M3264_SEC = $(AM_FLAG_M3264_@VGCONF_PLATFORM_SEC_CAPS@)
194else
195 AM_FLAG_M3264_SEC =
196endif
197
198
199# Baseline link flags for making vgpreload shared objects.
200#
201PRELOAD_LDFLAGS_COMMON_LINUX = -nodefaultlibs -shared -Wl,-z,interpose,-z,initfirst
njn8b68b642009-06-24 00:37:09 +0000202PRELOAD_LDFLAGS_COMMON_DARWIN = -dynamic -dynamiclib -all_load
203
philippe5d5dd8e2012-08-05 00:08:25 +0000204if VGCONF_PLATVARIANT_IS_ANDROID
205# The Android toolchain includes all kinds of stdlib helpers present in
206# bionic which is bad because we are not linking with it and the Android
207# linker will panic.
208PRELOAD_LDFLAGS_COMMON_LINUX += -nostdlib
209endif
210
njn8b68b642009-06-24 00:37:09 +0000211PRELOAD_LDFLAGS_X86_LINUX = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M32@
212PRELOAD_LDFLAGS_AMD64_LINUX = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M64@
213PRELOAD_LDFLAGS_PPC32_LINUX = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M32@
214PRELOAD_LDFLAGS_PPC64_LINUX = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M64@
sewardj59570ff2010-01-01 11:59:33 +0000215PRELOAD_LDFLAGS_ARM_LINUX = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M32@
njn8b68b642009-06-24 00:37:09 +0000216PRELOAD_LDFLAGS_X86_DARWIN = $(PRELOAD_LDFLAGS_COMMON_DARWIN) -arch i386
217PRELOAD_LDFLAGS_AMD64_DARWIN = $(PRELOAD_LDFLAGS_COMMON_DARWIN) -arch x86_64
sewardjb5b87402011-03-07 16:05:35 +0000218PRELOAD_LDFLAGS_S390X_LINUX = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M64@
sewardj5db15402012-06-07 09:13:21 +0000219PRELOAD_LDFLAGS_MIPS32_LINUX = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M32@
petarj4df0bfc2013-02-27 23:17:33 +0000220PRELOAD_LDFLAGS_MIPS64_LINUX = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M64@
sewardjf5cc6b32005-11-11 18:35:32 +0000221