# Makefile fragment for AmigaOS target.

# Extra object file linked to the cc1* executables.
amigaos.o: $(srcdir)/config/m68k/amigaos.c $(CONFIG_H)
	$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<

# We don't need a libgcc1, it's all in ixemul.library and LibNIX

LIBGCC1 = libgcc1.null
CROSS_LIBGCC1 = libgcc1.null

# Additional target dependent options for compiling libgcc.a.
# 1) Ensure that we don't compile libgcc* with anything other than a fixed
#    stack.
# 2) Do not require C standard library headers to compile libgcc.a
TARGET_LIBGCC2_CFLAGS = -mfixedstack -Dinhibit_libc

MULTILIB_OPTIONS = resident/resident32 m68000/m68020
MULTILIB_DIRNAMES = libb libb32 . libm020
MULTILIB_EXCEPTIONS = m68000 resident32 resident*/m68000

# Support for building multiple version of libgcc.
# Note: this is taken from the toplevel Makefile.in multilib support.
LIBGCC = stmp-libgcc-multi
INSTALL_LIBGCC = install-libgcc-multi

LIBGCC_MULTI =	".;" \
		"libb;@resident" \
		"libm020;@m68020" \
		"libb/libm020;@resident@m68020" \
		"libb32/libm020;@resident32@m68020"

# Build multiple copies of libgcc.a, one for each target switch.
stmp-libgcc-multi: $(LIBGCC1) libgcc2.c libgcc2.ready $(CONFIG_H) \
   frame.h \
   $(LIB2ADD) machmode.h longlong.h gbl-ctors.h config.status
	# We need the following explicit mkdir, since the toplevel
	# Makefile.in attempts to create only the last directory
	# of a path.
	if [ -d libb32 ]; then true; else mkdir libb32; fi
	for i in $(LIBGCC_MULTI); do \
	  dir=`echo $$i | sed -e 's/;.*$$//'`; \
	  flags=`echo $$i | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`; \
	  $(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \
	    AR_FOR_TARGET="$(AR_FOR_TARGET)" \
	    AR_FLAGS_FOR_TARGET="$(AR_FLAGS_FOR_TARGET)" \
	    CC="$(CC)" CFLAGS="$(CFLAGS)" \
	    RANLIB_FOR_TARGET="$(RANLIB_FOR_TARGET)" \
	    RANLIB_TEST_FOR_TARGET="$(RANLIB_TEST_FOR_TARGET)" \
	    LANGUAGES="$(LANGUAGES)" \
	    HOST_PREFIX="$(HOST_PREFIX)" HOST_PREFIX_1="$(HOST_PREFIX_1)" \
	    LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS) $${flags}" \
	    MULTILIB_CFLAGS="$${flags}" \
	    LIBGCC1="$(LIBGCC1)" LIBGCC2="$(LIBGCC2)" \
	    dir="$${dir}" stmp-multilib-sub; \
	  if [ $$? -eq 0 ] ; then true; else exit 1; fi; \
	done
	touch stmp-libgcc-multi

# Install multiple versions of libgcc.a.
install-libgcc-multi: stmp-libgcc-multi installdirs
	# We need the following explicit mkdir, since below we attempt to
	# create only the last directory of a path.
	if [ -d $(libsubdir)/libb32 ]; then true; else mkdir $(libsubdir)/libb32; fi
	for i in $(LIBGCC_MULTI); do \
	  dir=`echo $$i | sed -e 's/;.*$$//'`; \
	  if [ -d $(libsubdir)/$${dir} ]; then true; else mkdir $(libsubdir)/$${dir}; fi; \
	  for f in libgcc.a $(EXTRA_MULTILIB_PARTS); do \
	    rm -f $(libsubdir)/$${dir}/$${f}; \
	    $(INSTALL_DATA) $${dir}/$${f} $(libsubdir)/$${dir}/$${f}; \
	  done; \
	  if $(RANLIB_TEST_FOR_TARGET); then \
	    (cd $(libsubdir)/$${dir}; $(RANLIB_FOR_TARGET) libgcc.a); \
	  else true; fi; \
	  chmod a-x $(libsubdir)/$${dir}/libgcc.a; \
	done
