
SUBDIRS = . tests

include $(top_srcdir)/Makefile.all.am

#----------------------------------------------------------------------------
# <tool>-<platform> stuff
#----------------------------------------------------------------------------

TOOL_DEPENDENCIES_@VGCONF_PLATFORM_PRI_CAPS@ = \
	$(top_builddir)/coregrind/libcoregrind-@VGCONF_ARCH_PRI@-@VGCONF_OS@.a \
	$(top_builddir)/VEX/libvex-@VGCONF_ARCH_PRI@-@VGCONF_OS@.a
if VGCONF_HAVE_PLATFORM_SEC
TOOL_DEPENDENCIES_@VGCONF_PLATFORM_SEC_CAPS@ = \
	$(top_builddir)/coregrind/libcoregrind-@VGCONF_ARCH_SEC@-@VGCONF_OS@.a \
	$(top_builddir)/VEX/libvex-@VGCONF_ARCH_SEC@-@VGCONF_OS@.a
endif

TOOL_LDADD_COMMON = -lgcc
TOOL_LDADD_@VGCONF_PLATFORM_PRI_CAPS@ = \
	$(TOOL_DEPENDENCIES_@VGCONF_PLATFORM_PRI_CAPS@) $(TOOL_LDADD_COMMON)
if VGCONF_HAVE_PLATFORM_SEC
TOOL_LDADD_@VGCONF_PLATFORM_SEC_CAPS@ = \
	$(TOOL_DEPENDENCIES_@VGCONF_PLATFORM_SEC_CAPS@) $(TOOL_LDADD_COMMON)
endif

if !COMPILER_IS_CLANG
TOOL_LDADD_@VGCONF_PLATFORM_PRI_CAPS@ += \
	$(top_builddir)/coregrind/libgcc-sup-@VGCONF_ARCH_PRI@-@VGCONF_OS@.a
if VGCONF_HAVE_PLATFORM_SEC
TOOL_LDADD_@VGCONF_PLATFORM_SEC_CAPS@ += \
	$(top_builddir)/coregrind/libgcc-sup-@VGCONF_ARCH_SEC@-@VGCONF_OS@.a
endif
else
if VGCONF_PLATFORMS_INCLUDE_ARM64_LINUX
TOOL_LDADD_@VGCONF_PLATFORM_PRI_CAPS@ += \
	$(top_builddir)/coregrind/libgcc-sup-@VGCONF_ARCH_PRI@-@VGCONF_OS@.a
if VGCONF_HAVE_PLATFORM_SEC
TOOL_LDADD_@VGCONF_PLATFORM_SEC_CAPS@ += \
	$(top_builddir)/coregrind/libgcc-sup-@VGCONF_ARCH_SEC@-@VGCONF_OS@.a
endif
endif
endif

# -Wl,--build-id=none is needed when linking tools with a linker that only
# knows -Ttext and not -Ttext-segment. Without this flag newer ld versions
# (2.20 and later) create a .note.gnu.build-id at the default text segment
# address, which of course means the resulting executable
# is unusable. So we have to tell ld not to generate that, with
# --build-id=none unless the linker supports -Ttext-segment.
TOOL_LDFLAGS_COMMON_LINUX = \
	-static -nodefaultlibs -nostartfiles -u _start @FLAG_NO_BUILD_ID@
TOOL_LDFLAGS_COMMON_DARWIN = \
	-nodefaultlibs -nostartfiles -Wl,-u,__start -Wl,-e,__start
TOOL_LDFLAGS_COMMON_SOLARIS = \
	-static -nodefaultlibs -nostartfiles -u _start \
	-Wl,-M,/usr/lib/ld/map.noexstk
TOOL_LDFLAGS_COMMON_FREEBSD = -static \
	-nodefaultlibs -nostartfiles -Wl,-u,_start @FLAG_NO_BUILD_ID@

TOOL_LDFLAGS_X86_LINUX = \
	$(TOOL_LDFLAGS_COMMON_LINUX) @FLAG_M32@

TOOL_LDFLAGS_X86_FREEBSD = \
	$(TOOL_LDFLAGS_COMMON_FREEBSD) @FLAG_M32@

TOOL_LDFLAGS_AMD64_LINUX = \
	$(TOOL_LDFLAGS_COMMON_LINUX) @FLAG_M64@

TOOL_LDFLAGS_AMD64_FREEBSD = \
	$(TOOL_LDFLAGS_COMMON_FREEBSD) @FLAG_M64@

TOOL_LDFLAGS_PPC32_LINUX = \
	$(TOOL_LDFLAGS_COMMON_LINUX) @FLAG_M32@

TOOL_LDFLAGS_PPC64BE_LINUX = \
	$(TOOL_LDFLAGS_COMMON_LINUX) @FLAG_M64@

TOOL_LDFLAGS_PPC64LE_LINUX = \
	$(TOOL_LDFLAGS_COMMON_LINUX) @FLAG_M64@

TOOL_LDFLAGS_ARM_LINUX = \
	$(TOOL_LDFLAGS_COMMON_LINUX) @FLAG_M32@

TOOL_LDFLAGS_ARM64_LINUX = \
	$(TOOL_LDFLAGS_COMMON_LINUX) @FLAG_M64@

TOOL_LDFLAGS_ARM64_FREEBSD = \
	$(TOOL_LDFLAGS_COMMON_FREEBSD) @FLAG_M64@

TOOL_LDFLAGS_S390X_LINUX = \
	$(TOOL_LDFLAGS_COMMON_LINUX) @FLAG_M64@ @FLAG_S390_PGSTE@

TOOL_LDFLAGS_X86_DARWIN = \
	$(TOOL_LDFLAGS_COMMON_DARWIN) -arch i386

TOOL_LDFLAGS_AMD64_DARWIN = \
	$(TOOL_LDFLAGS_COMMON_DARWIN) -arch x86_64

# MIPS Linux default start symbol is __start, not _start like on x86 or amd
TOOL_LDFLAGS_MIPS32_LINUX = \
	-static -nodefaultlibs -nostartfiles -u __start @FLAG_NO_BUILD_ID@ \
	@FLAG_M32@

TOOL_LDFLAGS_NANOMIPS_LINUX = \
	-static -nodefaultlibs -nostartfiles -u __start @FLAG_NO_BUILD_ID@ \
	@FLAG_M32@ -Wl,-no-relax

TOOL_LDFLAGS_MIPS64_LINUX = \
	-static -nodefaultlibs -nostartfiles -u __start @FLAG_NO_BUILD_ID@ \
	@FLAG_M64@

TOOL_LDFLAGS_RISCV64_LINUX = \
	$(TOOL_LDFLAGS_COMMON_LINUX) @FLAG_M64@

TOOL_LDFLAGS_X86_SOLARIS = \
	$(TOOL_LDFLAGS_COMMON_SOLARIS) @FLAG_M32@

TOOL_LDFLAGS_AMD64_SOLARIS = \
	$(TOOL_LDFLAGS_COMMON_SOLARIS) @FLAG_M64@

# On Android we must ask for non-executable stack, not sure why.
if VGCONF_PLATFORMS_INCLUDE_ARM_LINUX
if VGCONF_PLATVARIANT_IS_ANDROID
TOOL_LDFLAGS_ARM_LINUX += -Wl,-z,noexecstack
endif
endif

# NB for 64-bit darwin.  We may want to set -Wl,-pagezero_size to
# something smaller than the default of 4G, so as to facilitate
# loading clients who are also linked thusly (currently m_ume.c
# will fail to load them).  Although such setting is probably
# better done in link_tool_exe.c.
#
#	-Wl,-pagezero_size,0x100000000


#----------------------------------------------------------------------------
# vgpreload_<tool>-<platform>.a stuff
#----------------------------------------------------------------------------

LIBREPLACEMALLOC_X86_LINUX = \
	$(top_builddir)/coregrind/libreplacemalloc_toolpreload-x86-linux.a

LIBREPLACEMALLOC_AMD64_LINUX = \
	$(top_builddir)/coregrind/libreplacemalloc_toolpreload-amd64-linux.a

LIBREPLACEMALLOC_PPC32_LINUX = \
	$(top_builddir)/coregrind/libreplacemalloc_toolpreload-ppc32-linux.a

LIBREPLACEMALLOC_PPC64BE_LINUX = \
	$(top_builddir)/coregrind/libreplacemalloc_toolpreload-ppc64be-linux.a

LIBREPLACEMALLOC_PPC64LE_LINUX = \
	$(top_builddir)/coregrind/libreplacemalloc_toolpreload-ppc64le-linux.a

LIBREPLACEMALLOC_X86_FREEBSD = \
	$(top_builddir)/coregrind/libreplacemalloc_toolpreload-x86-freebsd.a

LIBREPLACEMALLOC_ARM_LINUX = \
	$(top_builddir)/coregrind/libreplacemalloc_toolpreload-arm-linux.a

LIBREPLACEMALLOC_ARM64_LINUX = \
	$(top_builddir)/coregrind/libreplacemalloc_toolpreload-arm64-linux.a

LIBREPLACEMALLOC_AMD64_FREEBSD = \
	$(top_builddir)/coregrind/libreplacemalloc_toolpreload-amd64-freebsd.a

LIBREPLACEMALLOC_ARM64_FREEBSD = \
	$(top_builddir)/coregrind/libreplacemalloc_toolpreload-arm64-freebsd.a

LIBREPLACEMALLOC_X86_DARWIN = \
	$(top_builddir)/coregrind/libreplacemalloc_toolpreload-x86-darwin.a

LIBREPLACEMALLOC_AMD64_DARWIN = \
	$(top_builddir)/coregrind/libreplacemalloc_toolpreload-amd64-darwin.a

LIBREPLACEMALLOC_S390X_LINUX = \
	$(top_builddir)/coregrind/libreplacemalloc_toolpreload-s390x-linux.a

LIBREPLACEMALLOC_MIPS32_LINUX = \
	$(top_builddir)/coregrind/libreplacemalloc_toolpreload-mips32-linux.a

LIBREPLACEMALLOC_MIPS64_LINUX = \
	$(top_builddir)/coregrind/libreplacemalloc_toolpreload-mips64-linux.a

LIBREPLACEMALLOC_RISCV64_LINUX = \
	$(top_builddir)/coregrind/libreplacemalloc_toolpreload-riscv64-linux.a

LIBREPLACEMALLOC_X86_SOLARIS = \
	$(top_builddir)/coregrind/libreplacemalloc_toolpreload-x86-solaris.a

LIBREPLACEMALLOC_AMD64_SOLARIS = \
	$(top_builddir)/coregrind/libreplacemalloc_toolpreload-amd64-solaris.a

LIBREPLACEMALLOC_LDFLAGS_X86_LINUX = \
	-Wl,--whole-archive \
	$(LIBREPLACEMALLOC_X86_LINUX) \
	-Wl,--no-whole-archive

LIBREPLACEMALLOC_LDFLAGS_AMD64_LINUX = \
	-Wl,--whole-archive \
	$(LIBREPLACEMALLOC_AMD64_LINUX) \
	-Wl,--no-whole-archive

LIBREPLACEMALLOC_LDFLAGS_PPC32_LINUX = \
	-Wl,--whole-archive \
	$(LIBREPLACEMALLOC_PPC32_LINUX) \
	-Wl,--no-whole-archive

LIBREPLACEMALLOC_LDFLAGS_PPC64BE_LINUX = \
	-Wl,--whole-archive \
	$(LIBREPLACEMALLOC_PPC64BE_LINUX) \
	-Wl,--no-whole-archive

LIBREPLACEMALLOC_LDFLAGS_PPC64LE_LINUX = \
	-Wl,--whole-archive \
	$(LIBREPLACEMALLOC_PPC64LE_LINUX) \
	-Wl,--no-whole-archive

LIBREPLACEMALLOC_LDFLAGS_ARM_LINUX = \
	-Wl,--whole-archive \
	$(LIBREPLACEMALLOC_ARM_LINUX) \
	-Wl,--no-whole-archive

LIBREPLACEMALLOC_LDFLAGS_ARM64_LINUX = \
	-Wl,--whole-archive \
	$(LIBREPLACEMALLOC_ARM64_LINUX) \
	-Wl,--no-whole-archive

LIBREPLACEMALLOC_LDFLAGS_X86_FREEBSD = \
	-Wl,--whole-archive \
	$(LIBREPLACEMALLOC_X86_FREEBSD) \
	-Wl,--no-whole-archive

LIBREPLACEMALLOC_LDFLAGS_AMD64_FREEBSD = \
	-Wl,--whole-archive \
	$(LIBREPLACEMALLOC_AMD64_FREEBSD) \
	-Wl,--no-whole-archive

LIBREPLACEMALLOC_LDFLAGS_ARM64_FREEBSD = \
	-Wl,--whole-archive \
	$(LIBREPLACEMALLOC_ARM64_FREEBSD) \
	-Wl,--no-whole-archive

LIBREPLACEMALLOC_LDFLAGS_X86_DARWIN = \
	$(LIBREPLACEMALLOC_X86_DARWIN)

LIBREPLACEMALLOC_LDFLAGS_AMD64_DARWIN = \
	$(LIBREPLACEMALLOC_AMD64_DARWIN)

LIBREPLACEMALLOC_LDFLAGS_S390X_LINUX = \
	-Wl,--whole-archive \
	$(LIBREPLACEMALLOC_S390X_LINUX) \
	-Wl,--no-whole-archive

LIBREPLACEMALLOC_LDFLAGS_MIPS32_LINUX = \
	-Wl,--whole-archive \
	$(LIBREPLACEMALLOC_MIPS32_LINUX) \
	-Wl,--no-whole-archive

LIBREPLACEMALLOC_LDFLAGS_MIPS64_LINUX = \
	-Wl,--whole-archive \
	$(LIBREPLACEMALLOC_MIPS64_LINUX) \
	-Wl,--no-whole-archive

LIBREPLACEMALLOC_LDFLAGS_RISCV64_LINUX = \
	-Wl,--whole-archive \
	$(LIBREPLACEMALLOC_RISCV64_LINUX) \
	-Wl,--no-whole-archive

LIBREPLACEMALLOC_LDFLAGS_X86_SOLARIS = \
	-Wl,--whole-archive \
	$(LIBREPLACEMALLOC_X86_SOLARIS) \
	-Wl,--no-whole-archive

LIBREPLACEMALLOC_LDFLAGS_AMD64_SOLARIS = \
	-Wl,--whole-archive \
	$(LIBREPLACEMALLOC_AMD64_SOLARIS) \
	-Wl,--no-whole-archive

#----------------------------------------------------------------------------
# General stuff
#----------------------------------------------------------------------------

all-local: inplace-noinst_PROGRAMS inplace-noinst_DSYMS

clean-local: clean-noinst_DSYMS

install-exec-local: install-noinst_PROGRAMS install-noinst_DSYMS

uninstall-local: uninstall-noinst_PROGRAMS uninstall-noinst_DSYMS

