#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

######################################################################
# HPPA
######################################################################
#
# HP-UX/PA32
#
# for gas and gcc, check comment in xptcinvoke_asm_pa32.s
ifeq ($(OS_ARCH),HP-UX)
ifneq ($(CC),gcc)
# #18875  Building the CPP's (CXX) optimized causes a crash
CXXFLAGS 	:=  $(filter-out $(MOZ_OPTIMIZE_FLAGS), $(CXXFLAGS))
endif
endif

#
# Linux/HPPA/gcc
#
ifeq ($(OS_ARCH),Linux)
ifneq (,$(filter hppa hppa2.0 hppa1.1,$(OS_TEST)))
ifndef GNU_CXX
else
# #434190 optimized builds crash
CXXFLAGS 	:=  $(filter-out $(MOZ_OPTIMIZE_FLAGS), $(CXXFLAGS))
endif
endif
endif


######################################################################
# M68k
######################################################################

ifeq ($(OS_ARCH),Linux)
ifneq (,$(findstring mips, $(OS_TEST)))
ASFLAGS		+= -I$(DIST)/include
endif
endif

######################################################################
# PowerPC
######################################################################
#
# AIX/PPC
#
ifeq ($(OS_ARCH),AIX)
# #24617  Building the CPP's (CXX) optimized causes a crash
CXXFLAGS 	:=  $(filter-out $(MOZ_OPTIMIZE_FLAGS), $(CXXFLAGS))
endif

######################################################################
# SPARC
######################################################################
#
# Solaris/SPARC
#
ifeq ($(OS_ARCH),SunOS)
ifneq (86,$(findstring 86,$(OS_TEST)))
ifdef HAVE_64BIT_OS
ASFLAGS		+= -xarch=v9
endif
endif
endif

include $(topsrcdir)/config/rules.mk

ifeq ($(OS_ARCH),Linux)
ifneq (,$(findstring mips, $(OS_TEST)))
xptcstubs_asm_mips.o: $(DIST)/include/xptcstubsdef.inc
endif
endif

ifeq ($(OS_ARCH),Darwin)
xptcstubs_asm_ppc_darwin.s: xptcstubs_asm_ppc_darwin.s.m4 $(DIST)/include/xptcstubsdef.inc Makefile
	gm4 $(INCLUDES) $< > $@
endif

ifeq ($(OS_ARCH),AIX)
ifdef HAVE_64BIT_OS
xptcstubs_asm_ppc_aix64.s: xptcstubs_asm_ppc_aix64.s.m4 $(DIST)/include/xptcstubsdef.inc Makefile
	m4 -DAIX_OBJMODEL=$(AIX_OBJMODEL) $(INCLUDES) -I. $< > $@
else
xptcstubs_asm_ppc_aix.s: xptcstubs_asm_ppc_aix.s.m4 $(DIST)/include/xptcstubsdef.inc Makefile
	m4 -DAIX_OBJMODEL=$(AIX_OBJMODEL) $(INCLUDES) -I. $< > $@
endif
endif

ifeq ($(OS_ARCH),SunOS)
ifeq (86,$(findstring 86,$(OS_TEST)))
ifndef GNU_CC
xptcstubsdef_asm.solx86: $(DIST)/include/xptcstubsdef.inc
	sed \
	  -e 's/^\(STUB_ENTRY\)(\([0-9]\))/\11\(\2\)/' \
	  -e 's/^\(STUB_ENTRY\)(\([0-9][0-9]\))/\12\(\2\)/' \
	  -e 's/^\(STUB_ENTRY\)(\([0-9][0-9][0-9]\))/\13\(\2\)/' \
	$(DIST)/include/xptcstubsdef.inc > $@
ifeq (x86_64,$(OS_TEST))
ASFLAGS += -xarch=amd64
endif

endif
endif
endif
