# Top level makefile fragment for GNU Ada (GNAT).
#   Copyright (C) 1994, 1995, 1996, 1997, 1997, 1999, 2000, 2001
#   Free Software Foundation, Inc.

#This file is part of GNU CC.

#GNU CC is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2, or (at your option)
#any later version.

#GNU CC is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.

#You should have received a copy of the GNU General Public License
#along with GNU CC; see the file COPYING.  If not, write to
#the Free Software Foundation, 59 Temple Place - Suite 330,
#Boston, MA 02111-1307, USA.

# This file provides the language dependent support in the main Makefile.
# Each language makefile fragment must provide the following targets:
#
# foo.all.build, foo.all.cross, foo.start.encap, foo.rest.encap,
# foo.info, foo.dvi,
# foo.install-normal, foo.install-common, foo.install-info, foo.install-man,
# foo.uninstall, foo.mostlyclean, foo.clean, foo.distclean, foo.extraclean,
# foo.maintainer-clean, foo.stage1, foo.stage2, foo.stage3, foo.stage4
#
# where `foo' is the name of the language.
#
# It should also provide rules for:
#
# - making any compiler driver (eg: g++)
# - the compiler proper (eg: cc1plus)
# - define the names for selecting the language in LANGUAGES.
# tool definitions
CHMOD = chmod
CHMOD_AX_FLAGS = a+x
MV = mv
MKDIR = mkdir -p
RM = rm -f
RMDIR = rm -rf
# default extensions
shext  =

# Extra flags to pass to recursive makes.
BOOT_ADAFLAGS= $(ADAFLAGS)
ADAFLAGS= -W -Wall -gnatpg -gnata
GNATLIBFLAGS= -W -Wall -gnatpg
GNATLIBCFLAGS= -g -O2
ADA_INCLUDE_DIR = $(libsubdir)/adainclude
ADA_RTL_OBJ_DIR = $(libsubdir)/adalib
THREAD_KIND=native
GNATBIND = gnatbind
ADA_FLAGS_TO_PASS = \
	"ADA_FOR_BUILD=$(ADA_FOR_BUILD)" \
	"ADA_INCLUDE_DIR=$(ADA_INCLUDE_DIR)" \
	"ADA_RTL_OBJ_DIR=$(ADA_RTL_OBJ_DIR)" \
	"ADAFLAGS=$(ADAFLAGS)" \
	"ADA_FOR_TARGET=$(ADA_FOR_TARGET)" \
	"INSTALL_DATA=$(INSTALL_DATA)" \
	"INSTALL_PROGRAM=$(INSTALL_PROGRAM)"

# Define the names for selecting Ada in LANGUAGES.
Ada ada: gnat1$(exeext) gnatbind$(exeext)

# Tell GNU Make to ignore these, if they exist.
.PHONY: Ada ada

# There are too many Ada sources to check against here.  Let's
# always force the recursive make.
gnat1$(exeext): prefix.o attribs.o $(LIBDEPS) $(BACKEND) force
	$(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \
		../gnat1$(exeext)

gnatbind$(exeext): $(CONFIG_H) prefix.o force
	$(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \
		../gnatbind$(exeext)

gnatmake$(exeext): $(CONFIG_H) prefix.o force
	$(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \
		../gnatmake$(exeext)

gnatbl$(exeext): $(CONFIG_H) prefix.o force
	$(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \
		../gnatbl$(exeext)

gnatchop$(exeext): $(CONFIG_H) prefix.o force
	$(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \
		../gnatchop$(exeext)

gnatcmd$(exeext): $(CONFIG_H) prefix.o force
	$(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \
		../gnatcmd$(exeext)

gnatlink$(exeext): $(CONFIG_H) prefix.o force
	$(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \
		../gnatlink$(exeext)

gnatkr$(exeext): $(CONFIG_H) prefix.o force
	$(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \
		../gnatkr$(exeext)

gnatls$(exeext): $(CONFIG_H) prefix.o force
	$(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \
		../gnatls$(exeext)

gnatmem$(exeext): $(CONFIG_H) prefix.o force
	$(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \
		../gnatmem$(exeext)

gnatprep$(exeext): $(CONFIG_H) prefix.o force
	$(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \
		../gnatprep$(exeext)

gnatpsta$(exeext): $(CONFIG_H) prefix.o force
	$(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \
		../gnatpsta$(exeext)

gnatpsys$(exeext): $(CONFIG_H) prefix.o force
	$(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \
		../gnatpsys$(exeext)

gnatxref$(exeext): $(CONFIG_H) prefix.o force
	$(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \
		../gnatxref$(exeext)

gnatfind$(exeext): $(CONFIG_H) prefix.o force
	$(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \
		../gnatfind$(exeext)

# Gnatlbr is extra tool only used on VMS

gnatlbr$(exeext): $(CONFIG_H) prefix.o force
	$(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \
		../gnatlbr$(exeext)

# use target-gcc
gnattools: $(GCC_PARTS) force
	$(MAKE) $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \
	   CC="../xgcc -B../" STAGE_PREFIX=../ \
	   gnatbl$(exeext) gnatchop$(exeext) gnatcmd$(exeext) \
	   gnatkr$(exeext) gnatlink$(exeext) \
	   gnatls$(exeext) gnatmake$(exeext) \
	   gnatprep$(exeext) gnatpsta$(exeext) gnatpsys$(exeext) \
	   gnatxref$(exeext) gnatfind$(exeext) $(EXTRA_GNATTOOLS)

# use host-gcc
cross-gnattools: force
	$(MAKE) $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \
	   gnatbl$(exeext) gnatchop$(exeext) gnatcmd$(exeext) \
	   gnatkr$(exeext) gnatlink$(exeext) \
	   gnatls$(exeext) gnatmake$(exeext) \
	   gnatprep$(exeext) \
	   gnatxref$(exeext) gnatfind$(exeext) $(EXTRA_GNATTOOLS)

# use target-gcc
gnatlib: force
	$(MAKE) -C ada $(FLAGS_TO_PASS)  \
	   CC="../xgcc -B../" ADAC="../xgcc -B../" STAGE_PREFIX=../ \
	   GNATLIBFLAGS="$(GNATLIBFLAGS)" \
	   GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \
	   TARGET_LIBGCC2_CFLAGS="$(TARGET_LIBGCC2_CFLAGS)" \
	   THREAD_KIND="$(THREAD_KIND)" \
	   gnatlib

# use target-gcc
gnatlib-shared: force
	$(MAKE) -C ada $(FLAGS_TO_PASS)  \
	   CC="../xgcc -B../" ADAC="../xgcc -B../" STAGE_PREFIX=../ \
	   GNATLIBFLAGS="$(GNATLIBFLAGS)" \
	   GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \
	   GNATLIBLDFLAGS="$(GNATLIBLDFLAGS)" \
	   TARGET_LIBGCC2_CFLAGS="$(TARGET_LIBGCC2_CFLAGS)" \
	   THREAD_KIND="$(THREAD_KIND)" \
	   gnatlib-shared

# use only for native compiler
gnatlib_and_tools: gnatlib gnattools

# use cross-gcc
gnat-cross: force
	$(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) gnat-cross

# Build hooks:

ada.all.build: 
ada.all.cross:
	-if [ -f gnatbind$(exeext) ] ; \
	then \
	  $(MV) gnatbind$(exeext)  gnatbind-cross$(exeext); \
	fi
	-if [ -f gnatbl$(exeext) ] ; \
	then \
	  $(MV) gnatbl$(exeext)    gnatbl-cross$(exeext); \
	fi
	-if [ -f gnatchop$(exeext) ] ; \
	then \
	  $(MV) gnatchop$(exeext)   gnatchop-cross$(exeext); \
	fi
	-if [ -f gnatcmd$(exeext) ] ; \
	then \
	   $(MV) gnatcmd$(exeext)  gnatcmd-cross$(exeext); \
	fi
	-if [ -f gnatkr$(exeext) ] ; \
	then \
	  $(MV) gnatkr$(exeext)    gnatkr-cross$(exeext); \
	fi
	-if [ -f gnatlink$(exeext) ] ; \
	then \
	   $(MV) gnatlink$(exeext)  gnatlink-cross$(exeext); \
	fi
	-if [ -f gnatls$(exeext) ] ; \
	then \
	  $(MV) gnatls$(exeext)    gnatls-cross$(exeext); \
	fi
	-if [ -f gnatmake$(exeext) ] ; \
	then \
	   $(MV) gnatmake$(exeext)  gnatmake-cross$(exeext); \
	fi
	-if [ -f gnatmem$(exeext) ] ; \
	then \
	   $(MV) gnatmem$(exeext)  gnatmem-cross$(exeext); \
	fi
	-if [ -f gnatprep$(exeext) ] ; \
	then \
	   $(MV) gnatprep$(exeext)  gnatprep-cross$(exeext); \
	fi
	-if [ -f gnatpsta$(exeext) ] ; \
	then \
	   $(MV) gnatpsta$(exeext)  gnatpsta-cross$(exeext); \
	fi
	-if [ -f gnatpsys$(exeext) ] ; \
	then \
	   $(MV) gnatpsys$(exeext)  gnatpsys-cross$(exeext); \
	fi
	-if [ -f gnatxref$(exeext) ] ; \
	then \
	   $(MV) gnatxref$(exeext)  gnatxref-cross$(exeext); \
	fi
	-if [ -f gnatfind$(exeext) ] ; \
	then \
	   $(MV) gnatfind$(exeext)  gnatfind-cross$(exeext); \
	fi

ada.start.encap: 
ada.rest.encap: 
ada.info:
ada.dvi:
ada.generated-manpages:

# Install hooks:
# gnat1 is installed elsewhere as part of $(COMPILERS).

ada.install-normal:

# Install the binder program as $(target_alias)-gnatbind
# and also as either gnatbind (if native) or $(tooldir)/bin/gnatbind
# likewise for gnatf, gnatchop, and gnatlink, gnatkr, gnatmake, gnatcmd,
# gnatprep, gnatbl, gnatls, gnatxref, gnatfind
ada.install-common:
	$(MKDIR) $(DESTDIR)$(bindir)
	-if [ -f gnat1$(exeext) ] ; \
	 then \
	  if [ -f gnatbind-cross$(exeext) ] ; \
	  then \
	    $(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatbind$(exeext); \
	    $(INSTALL_PROGRAM) gnatbind-cross$(exeext) $(DESTDIR)$(bindir)/$(target_alias)-gnatbind$(exeext); \
	    if [ -d $(DESTDIR)$(tooldir)/bin/. ] ; then \
	      rm -f $(DESTDIR)$(tooldir)/bin/gnatbind$(exeext); \
	      $(INSTALL_PROGRAM) gnatbind-cross$(exeext) $(DESTDIR)$(tooldir)/bin/gnatbind$(exeext); \
	    fi; \
	  else \
	    $(RM) $(DESTDIR)$(bindir)/gnatbind$(exeext); \
	    $(INSTALL_PROGRAM) gnatbind$(exeext) $(DESTDIR)$(bindir)/gnatbind$(exeext); \
	  fi ; \
	fi
	-if [ -f gnat1$(exeext) ] ; \
	then \
	  if [ -f gnatbl-cross$(exeext) ] ; \
	  then \
	    $(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatbl$(exeext); \
	    $(INSTALL_PROGRAM) gnatbl-cross$(exeext) $(DESTDIR)$(bindir)/$(target_alias)-gnatbl$(exeext); \
	    if [ -d $(DESTDIR)$(tooldir)/bin/. ] ; then \
	       rm -f $(DESTDIR)$(tooldir)/bin/gnatbl$(exeext); \
	       $(INSTALL_PROGRAM) gnatbl-cross$(exeext) $(DESTDIR)$(tooldir)/bin/gnatbl$(exeext); \
	    fi; \
	  else \
	    $(RM) $(DESTDIR)$(bindir)/gnatbl$(exeext); \
	    $(INSTALL_PROGRAM) gnatbl$(exeext) $(DESTDIR)$(bindir)/gnatbl$(exeext); \
	  fi ; \
	fi
	-if [ -f gnat1$(exeext) ] ; \
	then \
	  if [ -f gnatchop-cross$(exeext) ] ; \
	  then \
	    $(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatchop$(exeext); \
	    $(INSTALL_PROGRAM) gnatchop-cross$(exeext) $(DESTDIR)$(bindir)/$(target_alias)-gnatchop$(exeext); \
	    if [ -d $(DESTDIR)$(tooldir)/bin/. ] ; then \
	       rm -f $(DESTDIR)$(tooldir)/bin/gnatchop$(exeext); \
	       $(INSTALL_PROGRAM) gnatchop-cross$(exeext) $(DESTDIR)$(tooldir)/bin/gnatchop$(exeext); \
	    fi; \
	  else \
	    $(RM) $(DESTDIR)$(bindir)/gnatchop$(exeext); \
	    $(INSTALL_PROGRAM) gnatchop$(exeext) $(DESTDIR)$(bindir)/gnatchop$(exeext); \
	  fi ; \
	fi
	-if [ -f gnat1$(exeext) ] ; \
	then \
	  if [ -f gnatcmd-cross$(exeext) ] ; \
	  then \
	    $(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnat$(exeext); \
	    $(INSTALL_PROGRAM) gnatcmd-cross$(exeext) $(DESTDIR)$(bindir)/$(target_alias)-gnat$(exeext); \
	    if [ -d $(DESTDIR)$(tooldir)/bin/. ] ; then \
	       rm -f $(DESTDIR)$(tooldir)/bin/gnat$(exeext); \
	       $(INSTALL_PROGRAM) gnatcmd-cross$(exeext) $(DESTDIR)$(tooldir)/bin/gnat$(exeext); \
	    fi; \
	  else \
	    $(RM) $(DESTDIR)$(bindir)/gnat$(exeext); \
	    $(INSTALL_PROGRAM) gnatcmd$(exeext) $(DESTDIR)$(bindir)/gnat$(exeext); \
	  fi ; \
	fi
	-if [ -f gnat1$(exeext) ] ; \
	then \
	  if [ -f gnatkr-cross$(exeext) ] ; \
	  then \
	    $(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatkr$(exeext); \
	    $(INSTALL_PROGRAM) gnatkr-cross$(exeext) $(DESTDIR)$(bindir)/$(target_alias)-gnatkr$(exeext); \
	    if [ -d $(DESTDIR)$(tooldir)/bin/. ] ; then \
	       rm -f $(DESTDIR)$(tooldir)/bin/gnatkr$(exeext); \
	       $(INSTALL_PROGRAM) gnatkr-cross$(exeext) $(DESTDIR)$(tooldir)/bin/gnatkr$(exeext); \
	    fi; \
	  else \
	    $(RM) $(DESTDIR)$(bindir)/gnatkr$(exeext); \
	    $(INSTALL_PROGRAM) gnatkr$(exeext) $(DESTDIR)$(bindir)/gnatkr$(exeext); \
	  fi ; \
	fi
	-if [ -f gnat1$(exeext) ] ; \
	then \
	  if [ -f gnatlink-cross$(exeext) ] ; \
	  then \
	    $(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatlink$(exeext); \
	    $(INSTALL_PROGRAM) gnatlink-cross$(exeext) $(DESTDIR)$(bindir)/$(target_alias)-gnatlink$(exeext); \
	    if [ -d $(DESTDIR)$(tooldir)/bin/. ] ; then \
	       rm -f $(DESTDIR)$(tooldir)/bin/gnatlink$(exeext); \
	       $(INSTALL_PROGRAM) gnatlink-cross$(exeext) $(DESTDIR)$(tooldir)/bin/gnatlink$(exeext); \
	    fi; \
	  else \
	    $(RM) $(DESTDIR)$(bindir)/gnatlink$(exeext); \
	    $(INSTALL_PROGRAM) gnatlink$(exeext) $(DESTDIR)$(bindir)/gnatlink$(exeext); \
	  fi ; \
	fi
	-if [ -f gnat1$(exeext) ] ; \
	then \
	  if [ -f gnatls-cross$(exeext) ] ; \
	  then \
	    $(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatls$(exeext); \
	    $(INSTALL_PROGRAM) gnatls-cross$(exeext) $(DESTDIR)$(bindir)/$(target_alias)-gnatls$(exeext); \
	    if [ -d $(DESTDIR)$(tooldir)/bin/. ] ; then \
	       rm -f $(DESTDIR)$(tooldir)/bin/gnatls$(exeext); \
	       $(INSTALL_PROGRAM) gnatls-cross$(exeext) $(DESTDIR)$(tooldir)/bin/gnatls$(exeext); \
	    fi; \
	  else \
	    $(RM) $(DESTDIR)$(bindir)/gnatls$(exeext); \
	    $(INSTALL_PROGRAM) gnatls$(exeext) $(DESTDIR)$(bindir)/gnatls$(exeext); \
	  fi ; \
	fi
	-if [ -f gnat1$(exeext) ] ; \
	then \
	  if [ -f gnatmake-cross$(exeext) ] ; \
	  then \
	    $(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatmake$(exeext); \
	    $(INSTALL_PROGRAM) gnatmake-cross$(exeext) $(DESTDIR)$(bindir)/$(target_alias)-gnatmake$(exeext); \
	    if [ -d $(DESTDIR)$(tooldir)/bin/. ] ; then \
	       rm -f $(DESTDIR)$(tooldir)/bin/gnatmake$(exeext); \
	       $(INSTALL_PROGRAM) gnatmake-cross$(exeext) $(DESTDIR)$(tooldir)/bin/gnatmake$(exeext); \
	    fi; \
	  else \
	    $(RM) $(DESTDIR)$(bindir)/gnatmake$(exeext); \
	    $(INSTALL_PROGRAM) gnatmake$(exeext) $(DESTDIR)$(bindir)/gnatmake$(exeext); \
	  fi ; \
	fi
	-if [ -f gnat1$(exeext) ] ; \
	then \
	  if [ -f gnatmem-cross$(exeext) ] ; \
	  then \
	    $(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatmem$(exeext); \
	    $(INSTALL_PROGRAM) gnatmem-cross$(exeext) $(DESTDIR)$(bindir)/$(target_alias)-gnatmem$(exeext); \
	  else \
	    $(RM) $(DESTDIR)$(bindir)/gnatmem$(exeext); \
	    $(INSTALL_PROGRAM) gnatmem$(exeext) $(DESTDIR)$(bindir)/gnatmem$(exeext); \
	  fi ; \
	fi
	-if [ -f gnat1$(exeext) ] ; \
	then \
	  if [ -f gnatprep-cross$(exeext) ] ; \
	  then \
	    $(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatprep$(exeext); \
	    $(INSTALL_PROGRAM) gnatprep-cross$(exeext) $(DESTDIR)$(bindir)/$(target_alias)-gnatprep$(exeext); \
	    if [ -d $(DESTDIR)$(tooldir)/bin/. ] ; then \
	       rm -f $(DESTDIR)$(tooldir)/bin/gnatprep$(exeext); \
	       $(INSTALL_PROGRAM) gnatprep-cross$(exeext) $(DESTDIR)$(tooldir)/bin/gnatprep$(exeext); \
	    fi; \
	  else \
	    $(RM) $(DESTDIR)$(bindir)/gnatprep$(exeext); \
	    $(INSTALL_PROGRAM) gnatprep$(exeext) $(DESTDIR)$(bindir)/gnatprep$(exeext); \
	  fi ; \
	fi
	-if [ -f gnat1$(exeext) ] ; \
	then \
	  if [ -f gnatpsta-cross$(exeext) ] ; \
	  then \
	    $(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatpsta$(exeext); \
	    $(INSTALL_PROGRAM) gnatpsta-cross$(exeext) $(DESTDIR)$(bindir)/$(target_alias)-gnatpsta$(exeext); \
	    if [ -d $(DESTDIR)$(tooldir)/bin/. ] ; then \
	       rm -f $(DESTDIR)$(tooldir)/bin/gnatpsta$(exeext); \
	       $(INSTALL_PROGRAM) gnatpsta-cross$(exeext) $(DESTDIR)$(tooldir)/bin/gnatpsta$(exeext); \
	    fi; \
	  else \
	    $(RM) $(DESTDIR)$(bindir)/gnatpsta$(exeext); \
	    $(INSTALL_PROGRAM) gnatpsta$(exeext) $(DESTDIR)$(bindir)/gnatpsta$(exeext); \
	  fi ; \
	fi
	-if [ -f gnat1$(exeext) ] ; \
	then \
	  if [ -f gnatpsys-cross$(exeext) ] ; \
	  then \
	    $(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatpsys$(exeext); \
	    $(INSTALL_PROGRAM) gnatpsys-cross$(exeext) $(DESTDIR)$(bindir)/$(target_alias)-gnatpsys$(exeext); \
	    if [ -d $(DESTDIR)$(tooldir)/bin/. ] ; then \
	       rm -f $(DESTDIR)$(tooldir)/bin/gnatpsys$(exeext); \
	       $(INSTALL_PROGRAM) gnatpsys-cross$(exeext) $(DESTDIR)$(tooldir)/bin/gnatpsys$(exeext); \
	    fi; \
	  else \
	    $(RM) $(DESTDIR)$(bindir)/gnatpsys$(exeext); \
	    $(INSTALL_PROGRAM) gnatpsys$(exeext) $(DESTDIR)$(bindir)/gnatpsys$(exeext); \
	  fi ; \
	fi
	-if [ -f gnat1$(exeext) ] ; \
	then \
	  if [ -f gnatxref-cross$(exeext) ] ; \
	  then \
	    $(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatxref$(exeext); \
	    $(INSTALL_PROGRAM) gnatxref-cross$(exeext) $(DESTDIR)$(bindir)/$(target_alias)-gnatxref$(exeext); \
	  else \
	    $(RM) $(DESTDIR)$(bindir)/gnatxref$(exeext); \
	    $(INSTALL_PROGRAM) gnatxref$(exeext) $(DESTDIR)$(bindir)/gnatxref$(exeext); \
	  fi ; \
	fi
	-if [ -f gnat1$(exeext) ] ; \
	then \
	  if [ -f gnatfind-cross$(exeext) ] ; \
	  then \
	    $(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatfind$(exeext); \
	    $(INSTALL_PROGRAM) gnatfind-cross$(exeext) $(DESTDIR)$(bindir)/$(target_alias)-gnatfind$(exeext); \
	  else \
	    $(RM) $(DESTDIR)$(bindir)/gnatfind$(exeext); \
	    $(INSTALL_PROGRAM) gnatfind$(exeext) $(DESTDIR)$(bindir)/gnatfind$(exeext); \
	  fi ; \
	fi
#
# Gnatlbr is only use on VMS
#
	-if [ -f gnat1$(exeext) ] ; \
	then \
	  if [ -f gnatlbr$(exeext) ] ; \
	  then \
	    $(RM) $(DESTDIR)$(bindir)/gnatlbr$(exeext); \
	    $(INSTALL_PROGRAM) gnatlbr$(exeext) $(DESTDIR)$(bindir)/gnatlbr$(exeext); \
	  fi ; \
	fi
#
# Gnatdll is only use on Windows
#
	-if [ -f gnat1$(exeext) ] ; \
	then \
	  if [ -f gnatdll$(exeext) ] ; \
	  then \
	    $(RM) $(DESTDIR)$(bindir)/gnatdll$(exeext); \
	    $(INSTALL_PROGRAM) gnatdll$(exeext) $(DESTDIR)$(bindir)/gnatdll$(exeext); \
	  fi ; \
	fi
#
# Finally, install the library
#
	-if [ -f gnat1$(exeext) ] ; \
	then \
	  $(MAKE) $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) install-gnatlib; \
	fi

install-gnatlib:
	$(MAKE) -f ada/Makefile $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) install-gnatlib

ada.install-info:
ada.install-man:

ada.uninstall:
	-$(RM) $(DESTDIR)$(bindir)/gnatbind$(exeext)
	-$(RM) $(DESTDIR)$(bindir)/gnatbl$(exeext)
	-$(RM) $(DESTDIR)$(bindir)/gnatchop$(exeext)
	-$(RM) $(DESTDIR)$(bindir)/gnat$(exeext)
	-$(RM) $(DESTDIR)$(bindir)/gnatdll$(exeext)
	-$(RM) $(DESTDIR)$(bindir)/gnatfind$(exeext)
	-$(RM) $(DESTDIR)$(bindir)/gnatkr$(exeext)
	-$(RM) $(DESTDIR)$(bindir)/gnatlbr$(exeext)
	-$(RM) $(DESTDIR)$(bindir)/gnatlink$(exeext)
	-$(RM) $(DESTDIR)$(bindir)/gnatls$(exeext)
	-$(RM) $(DESTDIR)$(bindir)/gnatmake$(exeext)
	-$(RM) $(DESTDIR)$(bindir)/gnatmem$(exeext)
	-$(RM) $(DESTDIR)$(bindir)/gnatprep$(exeext)
	-$(RM) $(DESTDIR)$(bindir)/gnatpsta$(exeext)
	-$(RM) $(DESTDIR)$(bindir)/gnatpsys$(exeext)
	-$(RM) $(DESTDIR)$(bindir)/gnatxref$(exeext)
	-$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatbind$(exeext)
	-$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatbl$(exeext)
	-$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatchop$(exeext)
	-$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnat$(exeext)
	-$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatdll$(exeext)
	-$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatfind$(exeext)
	-$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatkr(exeext)
	-$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatlbr$(exeext)
	-$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatlink$(exeext)
	-$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatls$(exeext)
	-$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatmake$(exeext)
	-$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatmem$(exeext)
	-$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatprep$(exeext)
	-$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatpsta$(exeext)
	-$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatpsys$(exeext)
	-$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatxref$(exeext)
	-$(RM) $(DESTDIR)$(tooldir)/bin/gnatbind$(exeext)
	-$(RM) $(DESTDIR)$(tooldir)/bin/gnatbl$(exeext)
	-$(RM) $(DESTDIR)$(tooldir)/bin/gnatchop$(exeext)
	-$(RM) $(DESTDIR)$(tooldir)/bin/gnat$(exeext)
	-$(RM) $(DESTDIR)$(tooldir)/bin/gnatdll$(exeext)
	-$(RM) $(DESTDIR)$(tooldir)/bin/gnatfind$(exeext)
	-$(RM) $(DESTDIR)$(tooldir)/bin/gnatkr$(exeext)
	-$(RM) $(DESTDIR)$(tooldir)/bin/gnatlbr$(exeext)
	-$(RM) $(DESTDIR)$(tooldir)/bin/gnatlink$(exeext)
	-$(RM) $(DESTDIR)$(tooldir)/bin/gnatls$(exeext)
	-$(RM) $(DESTDIR)$(tooldir)/bin/gnatmake$(exeext)
	-$(RM) $(DESTDIR)$(tooldir)/bin/gnatmem$(exeext)
	-$(RM) $(DESTDIR)$(tooldir)/bin/gnatprep$(exeext)
	-$(RM) $(DESTDIR)$(tooldir)/bin/gnatpsta$(exeext)
	-$(RM) $(DESTDIR)$(tooldir)/bin/gnatpsys$(exeext)
	-$(RM) $(DESTDIR)$(tooldir)/bin/gnatxref$(exeext)

# Clean hooks:
# A lot of the ancillary files are deleted by the main makefile.
# We just have to delete files specific to us.

ada.mostlyclean:
	-$(RM) ada/*$(objext) ada/*.ali ada/b_*.c
	-$(RM) ada/sdefault.adb ada/stamp-sdefault
	-$(RMDIR) ada/tools
ada.clean:
ada.distclean:
	-$(RM) ada/Makefile
	-$(RM) gnatbl$(exeext)
	-$(RM) gnatchop$(exeext)
	-$(RM) gnatcmd$(exeext)
	-$(RM) gnatdll$(exeext)
	-$(RM) gnatkr$(exeext)
	-$(RM) gnatlink$(exeext)
	-$(RM) gnatls$(exeext)
	-$(RM) gnatmake$(exeext)
	-$(RM) gnatmem$(exeext)
	-$(RM) gnatprep$(exeext)
	-$(RM) gnatpsta$(exeext)
	-$(RM) gnatpsys$(exeext)
	-$(RM) gnatfind$(exeext)
	-$(RM) gnatxref$(exeext)
# Gnatlbr and Gnatchop are only used on VMS
	-$(RM) gnatchop$(exeext) gnatlbr$(exeext)
	-$(RM) ada/rts/*
	-$(RMDIR) ada/rts
	-$(RMDIR) ada/tools
ada.extraclean:
ada.maintainer-clean:
	-$(RM) ada/a-sinfo.h
	-$(RM) ada/a-einfo.h
	-$(RM) ada/nmake.adb
	-$(RM) ada/nmake.ads
	-$(RM) ada/treeprs.ads

# Stage hooks:
# The main makefile has already created stage?/ada

ada.stage1:
	-$(MV) ada/*$(objext) ada/*.ali ada/b_*.c stage1/ada
	-$(MV) ada/stamp-* stage1/ada
ada.stage2:
	-$(MV) ada/*$(objext) ada/*.ali ada/b_*.c stage2/ada
	-$(MV) ada/stamp-* stage2/ada
ada.stage3:
	-$(MV) ada/*$(objext) ada/*.ali ada/b_*.c stage3/ada
	-$(MV) ada/stamp-* stage3/ada
ada.stage4:
	-$(MV) ada/*$(objext) ada/*.ali ada/b_*.c stage4/ada
	-$(MV) ada/stamp-* stage4/ada

check-ada:

# Bootstrapping targets for just GNAT - use the same stage directories
gnatboot: force
	-$(RM) gnatboot3
	$(MAKE) gnat1$(exeext) gnatbind$(exeext) CC="$(CC)" \
		CFLAGS="$(CFLAGS)"
	$(MAKE) gnatboot2 BOOT_CFLAGS="$(BOOT_CFLAGS)" \
	                  BOOT_ADAFLAGS="$(BOOT_ADAFLAGS)" \
	                  LDFLAGS="$(BOOT_LDFLAGS)"

gnatboot2: force
	$(MAKE) gnatstage1
	$(MAKE) gnat1$(exeext) gnatbind$(exeext)  CC="gcc -B../stage1/"\
				CFLAGS="$(BOOT_CFLAGS)" \
	        		ADAFLAGS="$(BOOT_ADAFLAGS)"\
				LDFLAGS="$(BOOT_LDFLAGS)" \
				STAGE_PREFIX=../stage1/
	$(MAKE) gnatboot3 BOOT_CFLAGS="$(BOOT_CFLAGS)" \
			    BOOT_ADAFLAGS="$(BOOT_ADAFLAGS)" \
			    LDFLAGS="$(BOOT_LDFLAGS)"

gnatboot3:
	$(MAKE) gnatstage2
	$(MAKE) gnat1$(exeext) gnatbind$(exeext)  CC="gcc -B../stage2/"\
				CFLAGS="$(BOOT_CFLAGS)" \
	        		ADAFLAGS="$(BOOT_ADAFLAGS)"\
				LDFLAGS="$(BOOT_LDFLAGS)" \
				STAGE_PREFIX=../stage2/

gnatstage1: force
	-$(MKDIR) stage1
	-$(MKDIR) stage1/ada
	-$(MV) gnat1$(exeext) gnatbind$(exeext) stage1
	-$(MV) ada/*$(objext) ada/*.ali stage1/ada
	-$(MV) ada/stamp-* stage1/ada

gnatstage2: force
	-$(MKDIR) stage2
	-$(MKDIR) stage2/ada
	-$(MV) gnat1$(exeext) gnatbind$(exeext) stage2
	-$(MV) ada/*$(objext) ada/*.ali stage2/ada
	-$(MV) ada/stamp-* stage2/ada
