# Makefile fragment for AmigaOS target.

# Each compilation environment (Manx, Dice, GCC, SAS/C, etc) provides its
# own equivalent of the UNIX /usr/include tree.  For gcc, the standard headers
# are in /gg/include and system specific headers are in /gg/os-include.
# Use these paths for fixincludes.

SYSTEM_HEADER_DIR = /gg/include

# 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.  This just
# ensures that we don't compile libgcc* with anything other than a
# fixed stack.

TARGET_LIBGCC2_CFLAGS = -mfixedstack

# 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

### begin-GG-local: dynamic libraries
# Extra objects that get compiled and linked to collect2

EXTRA_COLLECT2_OBJS = amigacollect2.o

# Build supplimentary AmigaOS target support file for collect2
amigacollect2.o: amigacollect2.c
	$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
	-DA2IXDIR_PREFIX=\"$(prefix)/share/a2ixlibrary\" $(srcdir)/amigacollect2.c
### end-GG-local
