ifndef __ltp-target_detect_mk__
__ltp-target_detect_mk__ = included

ifneq ($(findstring gcc,$(CC)),)
	TARGET_ARCH	:= $(word 1,$(subst -,$(sp),$(shell $(CC) -dumpmachine)))
endif

TARGET_ARCH		?= $(shell uname -m)

override TARGET_ARCH	:= $(TARGET:i%86,i386)

override TARGET_ARCH	:= $(TARGET:amd64,x86_64)

ifeq ($(TARGET_ARCH),i386)	# x86

else
ifeq ($(TARGET_ARCH),x86_64)	# amd64 / x86_64

else
ifeq ($(TARGET_ARCH),ia64)	# itanium

else
ifeq ($(TARGET_ARCH),mips)	# mips

else
ifeq ($(TARGET_ARCH),mips64)	# mips64

else
ifeq ($(TARGET_ARCH),ppc)	# ppc

else
ifeq ($(TARGET_ARCH),ppc64)	# ppc64

else
ifeq ($(TARGET_ARCH),s390x)	# s390x

else				# Unknown target
	# If the detected arch is this result, feel free to email the
	# maintainers with more info so they can add the def / detection
	# heuristic for you.
	TARGET_ARCH	:= unknown-$(TARGET_ARCH)
endif	# s390x
# END OTHER ARCHS
endif	# ppc64
endif	# ppc
# END PPC-COMPAT ARCHS
endif	# mips64
endif	# mips
# END MIPS-COMPAT ARCHS
endif
endif
endif
# END INTEL-COMPAT ARCHS

export TARGET_ARCH
#export CFLAGS CXXFLAGS LDFLAGS LDLIBES

endif
