# Makefile fragment for AmigaOS host

# Note: It doesn't do any good to try to define prefix or local_prefix
# in the host overrides because configure will just change them back.
# You either have to give an appropriate option to configure or live with
# an Amiga specific patch to configure.  See the note in configure.  -fnf

# Building under amigaos almost certainly requires an already working gcc.
# To bootstrap without "-pipe" do "make PIPE=".

CC = gcc

# Build residentable versions of the gcc executables by default.  Use
# "make RESIDENT=" to build non-residentable versions.
# Note:  This failed during bootstrapping of 2.5.5.

#RESIDENT = -resident

# Disable -pipe for now since I had problems bootstrapping gcc 2.5.5 with
# it. (fnf)
#PIPE = -pipe

# Allow the user to override the default host optimization with gcc, or if the
# host compiler is not gcc and doesn't understand -O<N>.

X_OPTIMIZE = -O2 -fomit-frame-pointer

# The standard additional host flags for the compiler.

X_CFLAGS = $(X_OPTIMIZE) $(RESIDENT) $(PIPE)

# Additional host flags that are not used when compiling with GCC_FOR_TARGET,
# such as when compiling the libgcc* runtime archives.

XCFLAGS = -mstackextend

# Ranlib does exist, but may not be in a path where the default RANLIB_TEST
# expects it, so just force it to true.

RANLIB_TEST = true

# Extra objects that get compiled and linked to the C preprocessor

EXTRA_CPP_OBJS = amigacpp.o

# Build supplimentary Amiga host support file for C preprocessor
amigacpp.o: amigacpp.c

# AmigaOS supports "AmigaGuide(R)" hypertext files. For GCC, these are
# build with a custom "makeinfo".

EXTRA_DOC_TARGETS = guide gcc-amigaos-doc

# Actually build guides

guide: cpp.guide gcc.guide

cpp.guide: cpp.texi
	$(MAKEINFO) -I$(srcdir) $(srcdir)/cpp.texi --output=$@ --amiga

gcc.guide: gcc.texi extend.texi install.texi invoke.texi \
		md.texi rtl.texi tm.texi
	$(MAKEINFO) -I$(srcdir) $(srcdir)/gcc.texi --output=$@ --amiga

# Arrange for guides to be installed with GCC.

INSTALL_TARGET=install-normal install-guide install-gcc-amigaos-doc

# Where the guide files go

guidedir = $(prefix)/guide

# Actually install guides.

install-guide: doc install-dir
	-if [ -d $(guidedir) ] ; then true ; else mkdir $(guidedir) ; chmod a+rx $(guidedir) ; fi
	-rm -f $(guidedir)/cpp.guide $(guidedir)/gcc.guide
	for f in cpp.guide gcc.guide; \
	do $(INSTALL_DATA) $$f $(guidedir)/$$f; done
	-chmod a-x $(guidedir)/cpp.guide $(guidedir)/gcc.guide

# Build and install gcc-amigaos.guide - documentation specific to the
# AmigaOS port of GCC.

gcc-amigaos-doc: gcc-amigaos.info gcc-amigaos.guide

gcc-amigaos.info: gcc-amigaos.texi
	$(MAKEINFO) -I$(srcdir) $(srcdir)/gcc-amigaos.texi --output=$@

gcc-amigaos.guide: gcc-amigaos.texi
	$(MAKEINFO) -I$(srcdir) $(srcdir)/gcc-amigaos.texi --output=$@ --amiga

install-gcc-amigaos-doc: doc install-dir
	-if [ -d $(guidedir) ] ; then true ; else mkdir $(guidedir) ; chmod a+rx $(guidedir) ; fi
	-rm -f $(infodir)/gcc-amigaos.info* $(guidedir)/gcc-amigaos.guide
	for f in gcc-amigaos.info*; \
	do $(INSTALL_DATA) $$f $(infodir)/$$f; done
	$(INSTALL_DATA) gcc-amigaos.guide $(guidedir)
	-chmod a-x $(infodir)/gcc-amigaos.info* $(guidedir)/gcc-amigaos.guide
