
# Baseline flags for all compilations.  Aim here is to maximise
# performance and get whatever useful warnings we can out of gcc.
AM_CFLAGS_BASE = -O2 -g -Wmissing-prototypes -Wall -Wshadow \
                 -Wpointer-arith -Wstrict-prototypes -Wmissing-declarations \
		 @FLAG_W_NO_FORMAT_ZERO_LENGTH@ \
                 -fno-strict-aliasing

# These flags are used for building the preload shared objects.
# The aim is to give reasonable performance but also to have good
# stack traces, since users often see stack traces extending 
# into (and through) the preloads.
AM_CFLAGS_PIC = -O -g -fpic -fno-omit-frame-pointer -fno-strict-aliasing

# Flags for specific targets.
#
# Nb: the AM_CPPFLAGS_* values are suitable for building tools and auxprogs.
# For building the core, coregrind/Makefile.am files add some extra things.
#
# Also: in newer versions of automake (1.10 onwards?) asm files ending with
# '.S' are considered "pre-processed" (as opposed to those ending in '.s')
# and so the CPPFLAGS are passed to the assembler.  But this is not true for
# older automakes (e.g. 1.8.5, 1.9.6), sigh.  So we include
# AM_CPPFLAGS_<PLATFORM> in each AM_CCASFLAGS_<PLATFORM> variable.  This
# means some of the flags are duplicated on systems with newer versions of
# automake, but this does not really matter and seems hard to avoid.

AM_CPPFLAGS_COMMON = \
		-I$(top_srcdir) \
		-I$(top_srcdir)/include \
		-I@VEX_DIR@/pub

AM_FLAG_M3264_X86_LINUX   = @FLAG_M32@
AM_CPPFLAGS_X86_LINUX 	  = $(AM_CPPFLAGS_COMMON) \
			    -DVGA_x86=1 \
			    -DVGO_linux=1 \
			    -DVGP_x86_linux=1
AM_CFLAGS_X86_LINUX       = @FLAG_M32@ @PREFERRED_STACK_BOUNDARY@ \
			 	$(AM_CFLAGS_BASE)
AM_CCASFLAGS_X86_LINUX    = $(AM_CPPFLAGS_X86_LINUX) @FLAG_M32@ -g

AM_FLAG_M3264_AMD64_LINUX = @FLAG_M64@
AM_CPPFLAGS_AMD64_LINUX   = $(AM_CPPFLAGS_COMMON) \
			    -DVGA_amd64=1 \
			    -DVGO_linux=1 \
			    -DVGP_amd64_linux=1
AM_CFLAGS_AMD64_LINUX     = @FLAG_M64@ -fomit-frame-pointer \
				@PREFERRED_STACK_BOUNDARY@ $(AM_CFLAGS_BASE)
AM_CCASFLAGS_AMD64_LINUX  = $(AM_CPPFLAGS_AMD64_LINUX) @FLAG_M64@ -g

AM_FLAG_M3264_PPC32_LINUX = @FLAG_M32@
AM_CPPFLAGS_PPC32_LINUX = $(AM_CPPFLAGS_COMMON) \
		-DVGA_ppc32=1 \
		-DVGO_linux=1 \
		-DVGP_ppc32_linux=1
AM_CFLAGS_PPC32_LINUX     = @FLAG_M32@ $(AM_CFLAGS_BASE)
AM_CCASFLAGS_PPC32_LINUX  = $(AM_CPPFLAGS_PPC32_LINUX) @FLAG_M32@ -g

AM_FLAG_M3264_PPC64_LINUX = @FLAG_M64@
AM_CPPFLAGS_PPC64_LINUX   = $(AM_CPPFLAGS_COMMON) \
			    -DVGA_ppc64=1 \
			    -DVGO_linux=1 \
			    -DVGP_ppc64_linux=1
AM_CFLAGS_PPC64_LINUX     = @FLAG_M64@ $(AM_CFLAGS_BASE)
AM_CCASFLAGS_PPC64_LINUX  = $(AM_CPPFLAGS_PPC64_LINUX) @FLAG_M64@ -g

AM_FLAG_M3264_PPC32_AIX5  = @FLAG_MAIX32@
AM_CPPFLAGS_PPC32_AIX5 	  = $(AM_CPPFLAGS_COMMON) \
			    -DVGA_ppc32=1 \
			    -DVGO_aix5=1 \
			    -DVGP_ppc32_aix5=1
AM_CFLAGS_PPC32_AIX5      = @FLAG_MAIX32@ -mcpu=powerpc $(AM_CFLAGS_BASE)
AM_CCASFLAGS_PPC32_AIX5   = $(AM_CPPFLAGS_PPC32_AIX5) \
			    @FLAG_MAIX32@ -mcpu=powerpc -g

AM_FLAG_M3264_PPC64_AIX5  = @FLAG_MAIX64@
AM_CPPFLAGS_PPC64_AIX5    = $(AM_CPPFLAGS_COMMON) \
			    -DVGA_ppc64=1 \
			    -DVGO_aix5=1 \
			    -DVGP_ppc64_aix5=1
AM_CFLAGS_PPC64_AIX5      = @FLAG_MAIX64@ -mcpu=powerpc64 $(AM_CFLAGS_BASE)
AM_CCASFLAGS_PPC64_AIX5   = $(AM_CPPFLAGS_PPC64_AIX5) \
			    @FLAG_MAIX64@ -mcpu=powerpc64 -g

# Flags for the primary target.  These must be used to build the
# regtests and performance tests.  In fact, these must be used to
# build anything which is built only once on a dual-arch build.
#
AM_FLAG_M3264_PRI = $(AM_FLAG_M3264_@VGCONF_PLATFORM_PRI_CAPS@)
AM_CPPFLAGS_PRI   = $(AM_CPPFLAGS_@VGCONF_PLATFORM_PRI_CAPS@)
AM_CFLAGS_PRI     = $(AM_CFLAGS_@VGCONF_PLATFORM_PRI_CAPS@)
AM_CCASFLAGS_PRI  = $(AM_CCASFLAGS_@VGCONF_PLATFORM_PRI_CAPS@)

if VGCONF_HAVE_PLATFORM_SEC_CAPS
 AM_FLAG_M3264_SEC = $(AM_FLAG_M3264_@VGCONF_PLATFORM_SEC_CAPS@)
else
 AM_FLAG_M3264_SEC = 
endif


# Baseline link flags for making dynamic shared objects.
#
PRELOAD_LDFLAGS_COMMON_LINUX = -nodefaultlibs -shared -Wl,-z,interpose,-z,initfirst
PRELOAD_LDFLAGS_COMMON_AIX5  = -nodefaultlibs -shared -Wl,-G -Wl,-bnogc
PRELOAD_LDFLAGS_X86_LINUX   = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M32@
PRELOAD_LDFLAGS_AMD64_LINUX = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M64@
PRELOAD_LDFLAGS_PPC32_LINUX = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M32@
PRELOAD_LDFLAGS_PPC64_LINUX = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M64@
PRELOAD_LDFLAGS_PPC32_AIX5  = $(PRELOAD_LDFLAGS_COMMON_AIX5)  @FLAG_MAIX32@
PRELOAD_LDFLAGS_PPC64_AIX5  = $(PRELOAD_LDFLAGS_COMMON_AIX5)  @FLAG_MAIX64@
