# Top level makefile fragment for the GNU compiler for the KSI
# language.
#   Copyright (C) 2001, 2002 Free Software Foundation, Inc.
# This file is part of GCC.

#GCC 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.

#GCC 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 GCC; 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: jc1)
# - define the names for selecting the language in LANGUAGES.

# Actual names to use when installing a native compiler.
KSI_INSTALL_NAME = `t='$(program_transform_name)'; echo gksi | sed $$t`

# Actual names to use when installing a cross-compiler.
KSI_CROSS_NAME = `t='$(program_transform_cross_name)'; echo gksi | sed $$t`

KSI = ksi1

# Define the names for selecting ksi in LANGUAGES.
ksi: $(KSI)$(exeext)

# Define the name of target independant tools to be installed in $(bindir)
# Names are subject to changes
KSI_TARGET_INDEPENDENT_BIN_TOOLS =

# Tell GNU make to ignore these if they exist.
.PHONY: ksi

# Executables built by this Makefile:
KSI_OBJS = ksi/expr.o ksi/glue.o ksi/lex.o ksi/stmts.o ksi/unit.o \
	ksi/keyword.o ksi/types.o

#
# Build hooks:

ksi.all.build: $(KSI)$(exeext)
ksi.all.cross: $(KSI)-cross$(exeext)
ksi.start.encap: $(KSI)$(exeext)
ksi.rest.encap:

ksi.info: $(srcdir)/ksi/doc/ksi.info
ksi.dvi: $(srcdir)/ksi/doc/ksi.dvi
ksi.generated-manpages:

# ksi documentation.
$(srcdir)/ksi/doc/ksi.info: $(srcdir)/ksi/doc/ksi.texi 
	if [ x$(BUILD_INFO) = xinfo ]; then \
	  rm -f $(srcdir)/ksi/doc/ksi.info*; \
	  cd $(srcdir)/ksi/doc && \
	  	$(MAKEINFO) ksi.texi; \
	else true; fi

$(srcdir)/ksi/doc/ksi.dvi: $(srcdir)/ksi/doc/ksi.texi 
	cd $(srcdir)/ksi/doc && $(TEXI2DVI) ksi.texi

# Nothing to do here.

ksi.install-normal:
ksi.install-common:
ksi.install-man:
ksi.uninstall:

ksi.install-info:
	-rm -f $(infodir)/ksi.info*
	$(INSTALL_DATA) $(srcdir)/ksi/doc/ksi.info* $(infodir)

#
# Clean hooks:
# A lot of the ancillary files are deleted by the main makefile.
# We just have to delete files specific to us.

ksi.mostlyclean:
	-rm -f ksi/*$(objext) 
	
ksi.clean:
ksi.distclean:
ksi.extraclean:
ksi.maintainer-clean:
#
# Stage hooks:
# The main makefile has already created stage?/ksi.

ksi.stage1: stage1-start
	-mv ksi/*$(objext) stage1/ksi
ksi.stage2: stage2-start
	-mv ksi/*$(objext) stage2/ksi
ksi.stage3: stage3-start
	-mv ksi/*$(objext) stage3/ksi
ksi.stage4: stage4-start
	-mv ksi/*$(objext) stage4/ksi

#
# .o:.h dependencies.

#compiler: ksi1

ksi1$(exeext): $(P) $(KSI_OBJS) $(BACKEND) $(LIBDEPS)
	$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o ksi1$(exeext) \
	      $(KSI_OBJS) $(BACKEND) $(LIBS)

#TREE_H = $(srcdir)/tree.h $(srcdir)/real.h $(srcdir)/tree.def \
#	$(srcdir)/machmode.h $(srcdir)/machmode.def

ksi/keyword.h ksi/keyword.c : ksi/keyword.def ksi/scripts/mkkeyword
	sh $(srcdir)/ksi/scripts/mkkeyword $(srcdir)/ksi ksi

ksi/ksi-config.h :
	sh $(srcdir)/ksi/scripts/mkconfig $(srcdir) > ksi/ksi-config.h

$(KSI_OBJS) : $(CONFIG_H) $(TREE_H) flags.h ksi/ksi.h ksi/keyword.h ksi/ksi-config.h

