# This makefile was originally the makefile for the GNU C compiler.
# It is now the makefile for the "generic coverage tool"
# It was extensively modified by B. Marick
# in early 1990.  Mail to marick@cs.uiuc.edu.

# One goal is to make installation is as easy as possible on
# both BSD and SysV systems.  For that reason, we use the least-common
# denominator:  Use C-alloca, install with cp, use 'cc' and $(CC), and so
# on.  That way, the user makes the fewest decisions.
# Look for spots marked LEAST COMMON DENOMINATOR if you want to use
# specialized-and-better options.

#   Copyright (C) 1987, 1988 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 1, 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, 675 Mass Ave, Cambridge, MA 02139, USA.


# Variables that exist for you to override.
# See below for how to change them for certain systems.

CFLAGS = -g $(XCFLAGS) -DUSE_C_ALLOCA

# LEAST COMMON DENOMINATOR:
CC = cc

# NOTE:  We cannot use yacc, c-parse.y uses non-yacc keywords.  
# The output files c-parse.tab.c and cexp.c are delivered with the system.

BISON = bison
BISONFLAGS = 
AR = ar
SHELL = /bin/sh


# LEAST COMMON DENOMINATOR:
# INSTALL = install -c
INSTALL = cp

# Directory where sources are, from where we are.
srcdir = .

# CHANGE:  Changed locations.
# Directory in which to put the executable for the command `gct'
bindir = $(prefix)/usr/port/bin
# Directory in which to put the subprograms used by the compiler.
libdir = $(prefix)/usr/port/lib
# Directory in which to put man pages.
mandir = $(prefix)/usr/man/manl
# Number to put in man-page filename.
manext = l
# This names the Perl executable.  Perl is required only for the
# user-contributed glist program.  GCT proper does not require it. 
# If Perl does not exist on your system, replace the pathname with NOPERL.
perlexec=/local/all/perl


# This selects the shell script to be called "gct".  That shell
# script should work with /bin/cc
gctscript = gct-trad


# Additional system libraries to link with.
CLIB=

# Change this to a null string if obstacks are installed in the
# system library.
OBSTACK=obstack.o

# End of variables for you to override.


# Variables you should change for certain systems.

# These are what you would need on HPUX:
# CFLAGS = -Wc,-Ns2000 -Wc,-Ne700 -Wc,-Np300
# If you are using the GNU assembler and linker on HPUX,
# add -I../hp-include to CFLAGS.
# -g is desirable in CFLAGS, but a compiler bug in HPUX version 5
# bites whenever tree.def, rtl.def or machmode.def is included
# (ie., on every source file).
# If you have a floating point accelerator, you might want -lsetjmp as well.
# CCLIBFLAGS = -Wc,-Ns2000 -Wc,-Ne700
# For CCLIBFLAGS you might want to specify the switch that
# forces only 68000 instructions to be used.

# If you are making gcc for the first time, and if you are compiling it with
# a non-gcc compiler, and if your system doesn't have a working alloca() in any
# of the standard libraries (as is true for HP/UX or Genix),
# then get alloca.c from GNU Emacs and un-comment the following line:
# LEAST COMMON DENOMINATOR:
ALLOCA = alloca.o
# But don't do that if compiling using GCC.

# If your system has alloca() in /lib/libPW.a, un-comment the following line:
# CLIB= -lPW

# On a pyramid, you need to uncomment the following line:
# CLIB= -lalloca

# If your system's malloc() routine fails for any reason (as it does on
# certain versions of Genix), try getting the files
# malloc.c and getpagesize.h from GNU Emacs and un-comment the following line:
# MALLOC = malloc.o

# If you are running GCC on an Apollo (SR10.x),
# go into a Berkeley environment and use this:
# CFLAGS = -g -A nansi -A cpu,3000 -A runtype,bsd4.3 -A systype,any -DSHORT_ENUM_BUG
# (Says vasta@apollo.com.)


# Dependency on obstack, alloca, malloc or whatever library facilities
# are not installed in the system libraries.
LIBDEPS= $(OBSTACK) $(ALLOCA) $(MALLOC)

# How to link with both our special library facilities
# and the system's installed libraries.
LIBS = $(OBSTACK) $(ALLOCA) $(MALLOC) $(CLIB)

# Specify the directories to be searched for header files.
# Both . and srcdir are used, in that order,
# so that tm.h and config.h will be found in the compilation
# subdirectory rather than in the source directory.
INCLUDES = -I. -I$(srcdir) -I$(srcdir)/config
SUBDIR_INCLUDES = -I.. -I../$(srcdir) -I../$(srcdir)/config

# Always use -I$(srcdir)/config when compiling.
.c.o:
	$(CC) -c $(CFLAGS) $(CPPFLAGS) $(INCLUDES) $<

# Language-specific object files for C.
C_OBJS = c-parse.tab.o c-decl.o c-typeck.o c-convert.o

# Language-specific object files for C++.
# (These are not yet released.)
CPLUS_OBJS = cplus-parse.o cplus-decl.o cplus-typeck.o \
   cplus-cvt.o cplus-search.o cplus-lex.o \
   cplus-class.o cplus-init.o cplus-method.o

# Language-independent object files.
OBJS = toplev.o version.o tree.o print-tree.o stor-layout.o fold-const.o \
 rtl.o rtlanal.o expr.o stmt.o expmed.o explow.o optabs.o varasm.o \
 symout.o dbxout.o sdbout.o emit-rtl.o insn-emit.o \
 integrate.o jump.o cse.o loop.o flow.o stupid.o combine.o \
 regclass.o local-alloc.o global-alloc.o reload.o reload1.o caller-save.o \
 insn-peep.o final.o recog.o insn-recog.o insn-extract.o insn-output.o

# Object files for GCT
GCT_OBJS = gct-build.o gct-decl.o gct-print.o \
	gct-trans.o gct-utrans.o gct-strans.o gct-race.o\
	gct-util.o gct-files.o gct-lookup.o gct-temps.o gct-tbuild.o \
	gct-tcompa.o gct-tgroup.o gct-exit.o \
	gct-contro.o gct-mapfil.o gct-macros.o regex.o

# Header files that are made available to programs compiled with gcc.
USER_H = stddef.h stdarg.h assert.h va-*.h limits.h

# The files that "belong" in CONFIG_H are deliberately omitted
# because having them there would not be useful in actual practice.
# All they would do is cause complete recompilation every time
# one of the machine description files is edited.
# That may or may not be what one wants to do.
# If it is, rm *.o is an easy way to do it.
# CONFIG_H = config.h tm.h
CONFIG_H =
RTL_H = rtl.h rtl.def machmode.def
TREE_H = tree.h real.h tree.def machmode.def
CPLUS_TREE_H = $(TREE_H) cplus-tree.h c-tree.h

GCTDEFS_H = gct-util.h gct-tree.def gct-opts.def
GCT_H = gct-assert.h gct-const.h gct-macros.h gct-contro.h

# Note that dependencies on obstack.h are not written
# because that file is not part of GCC.
# Dependencies on gvarargs.h are not written
# because all that file does, when not compiling with GCC,
# is include the system varargs.h.

GCTSCRIPTS = gct-trad gct-ansi gct-gcc gct-gcc2
EXECUTABLES = gct.exec cc1 cpp gct-init grestore gmerge greport gsummary \
	gedit gfilter gnewer gclean callcc passcc glist
REMOVABLE_EXECUTABLES = gct.exec cc1 cccp cpp gct-init grestore gmerge \
	greport gsummary gnewer gedit gfilter glist

all: config.status $(EXECUTABLES)

dbmalloc:
	/bin/rm -f g*.o $(REMOVABLE_EXECUTABLES)
	make CC=gcc-1.40 "CFLAGS=-g -DMALLOC_TESTING -DTESTING \
		-I/x/debug_include" "TESTLIBS=/x/lib/libdbmalloc.a"

config.status:
	@echo You must configure gcc.  Look at the INSTALL file for details.
	@false

compilations: ${OBJS}

gct.exec gct: gcc.o gct-contro.o gct-files.o version.o $(LIBDEPS)
	$(CC) $(CFLAGS) $(LDFLAGS) -o gct.exec gcc.o gct-contro.o \
		gct-files.o version.o $(TESTLIBS) $(LIBS)
	/bin/rm -f gct
	ln $(srcdir)/$(gctscript) gct

grestore: grestore.o $(GCT_H)
	$(CC) $(CFLAGS) $(LDFLAGS) -o grestore grestore.o $(TESTLIBS)
grestore.o: grestore.c $(GCT_H)


greport: greport.o gct-files.o g-tools.o regex.o $(ALLOCA)
	$(CC) $(CFLAGS) $(INCLUDES) $(LDFLAGS) -o greport greport.o \
		gct-files.o g-tools.o regex.o  $(TESTLIBS) $(ALLOCA)
greport.o: greport.c $(GCT_H) g-tools.h
 
gfilter: gfilter.o g-report.o
	$(CC) $(CFLAGS) $(LDFLAGS) -o gfilter gfilter.o g-report.o  $(TESTLIBS)
gfilter.o: gfilter.c $(GCT_H) g-report.h
 
gsummary: gsummary.o gct-files.o g-tools.o regex.o $(ALLOCA)
	$(CC) $(CFLAGS) $(LDFLAGS) -o gsummary gsummary.o gct-files.o \
		g-tools.o regex.o  $(TESTLIBS) $(ALLOCA)
gsummary.o: gsummary.c $(GCT_H) g-tools.h

gedit: gedit.o gct-files.o g-tools.o g-report.o gct-files.o regex.o $(ALLOCA)
	$(CC) $(CFLAGS) $(LDFLAGS) -o gedit gedit.o gct-files.o \
		g-tools.o g-report.o regex.o  $(TESTLIBS) $(ALLOCA)
gedit.o: gedit.c $(GCT_H) g-tools.h g-report.h

gmerge: gmerge.o
	$(CC) $(CFLAGS) $(LDFLAGS) -o gmerge gmerge.o  $(TESTLIBS)
gmerge.o: gmerge.c $(GCT_H)

gnewer: gnewer.o
	$(CC) $(CFLAGS) $(LDFLAGS) -o gnewer gnewer.o  $(TESTLIBS)
gnewer.o: gnewer.c $(GCT_H)

gct-init: gct-init.sh Makefile
	-/bin/rm -f gct-init
	sed 's=LIBDIR=$(libdir)=' $(srcdir)/gct-init.sh > gct-init
	chmod a+x gct-init

glist: glist.src Makefile
	-/bin/rm -f glist
	if [ "$(perlexec)" = NOPERL ]; then\
 	 echo "echo GLIST is not installed because PERL is not installed." > glist;\
	else\
	 sed 's=PERLNAME=$(perlexec)=' $(srcdir)/glist.src > glist;\
        fi
	chmod a+x glist

cc1: $(C_OBJS) $(OBJS) $(LIBDEPS) $(GCT_OBJS)
	$(CC) $(CFLAGS) $(LDFLAGS) -o cc1 $(C_OBJS) $(OBJS) \
		$(GCT_OBJS) $(TESTLIBS) $(LIBS) 

path:
	echo $$PATH

lint: 
	make -n CFLAGS=$(XCFLAGS) CC=lint

# GCT Specific files.

# C language specific files.
gct-build.o: gct-build.c $(TREE_H) $(GCT_H) $(GCTDEFS_H)
gct-decl.o: gct-decl.c c-decl.h $(GCT_H) $(GCTDEFS_H)
gct-print.o: gct-print.c $(GCT_H) $(GCTDEFS_H)
gct-trans.o: gct-trans.c $(GCT_H) $(GCTDEFS_H) gct-tutil.h gct-files.h gct-trans.h
gct-utrans.o: gct-utrans.c $(GCT_H) $(GCTDEFS_H) gct-tutil.h gct-files.h gct-trans.h
gct-strans.o: gct-strans.c $(GCT_H) $(GCTDEFS_H) gct-tutil.h gct-files.h gct-trans.h
gct-race.o: gct-race.c $(GCT_H) $(GCTDEFS_H) gct-tutil.h gct-files.h gct-trans.h

# Turn time-consuming assertions off for this file.
gct-util.o: gct-util.c $(GCT_H) $(GCTDEFS_H)
	$(CC) -DNDEBUG -c $(CFLAGS) $(CPPFLAGS) $(INCLUDES) $<

gct-lookup.o: gct-lookup.c $(GCT_H) $(GCTDEFS_H) gct-tutil.h
gct-temps.o: gct-temps.c $(GCT_H) $(GCTDEFS_H) gct-tutil.h
gct-tbuild.o: gct-tbuild.c $(GCT_H) $(GCTDEFS_H) gct-tutil.h gct-files.h gct-trans.h
gct-tcompa.o: gct-tcompa.c $(GCT_H) $(GCTDEFS_H) gct-tutil.h
gct-tgroup.o: gct-tgroup.c $(GCT_H) $(GCTDEFS_H) gct-tutil.h
gct-exit.o: gct-exit.c
gct-contro.o: gct-contro.c gct-contro.h $(GCT_H) $(GCTDEFS_H)
gct-macros.o: gct-macros.c gct-macros.h gct-contro.h $(GCT_H) $(GCTDEFS_H)
gct-files.o: gct-files.c gct-files.h $(GCT_H) $(GCTDEFS_H)
gct-mapfil.o: gct-mapfil.c gct-contro.h $(GCT_H) $(GCTDEFS_H) gct-files.h
g-tools.o: g-tools.c gct-files.h $(GCT_H) $(GCTDEFS_H) g-tools.h regex.h

regex.o: regex.c regex.h config.h
	$(CC) -c $(CFLAGS) -DC_ALLOCA $(INCLUDES) $(srcdir)/regex.c

g-report.o: g-report.c $(GCT_H) $(GCTDEFS_H) g-report.h

c-parse.tab.o : $(srcdir)/c-parse.tab.c $(CONFIG_H) $(TREE_H) \
		c-parse.h c-tree.h input.h $(GCT_H) $(GCTDEFS_H)
$(srcdir)/c-parse.tab.c : $(srcdir)/c-parse.y
	$(BISON) $(BISONFLAGS) $(srcdir)/c-parse.y -o $@

c-decl.o : c-decl.c $(CONFIG_H) $(TREE_H) c-tree.h c-parse.h flags.h \
		c-decl.h $(GCTDEFS_H)
c-typeck.o : c-typeck.c $(CONFIG_H) $(TREE_H) c-tree.h flags.h
c-convert.o : c-convert.c $(CONFIG_H) $(TREE_H)

# C++ language specific files.

cplus-parse.o : $(srcdir)/cplus-parse.c $(CONFIG_H) $(CPLUS_TREE_H) flags.h
	$(CC) -c $(CFLAGS) $(INCLUDES) \
  -DPARSE_OUTPUT=\"$(PWD)/cplus-parse.output\" \
  `echo $(srcdir)/cplus-parse.c | sed 's,^\./,,'`

$(srcdir)/cplus-parse.h $(srcdir)/cplus-parse.c : $(srcdir)/cplus-parse.y
	@echo expect 49 shift/reduce conflicts and 4 reduce/reduce conflicts
	$(BISON) $(BISONFLAGS) -d -o $(srcdir)/cplus-parse.c $(srcdir)/cplus-parse.y

cplus-lex.o : cplus-lex.c $(CONFIG_H) $(CPLUS_TREE_H) $(srcdir)/cplus-parse.h
cplus-decl.o : cplus-decl.c $(CONFIG_H) $(CPLUS_TREE_H) flags.h
cplus-typeck.o : cplus-typeck.c $(CONFIG_H) $(CPLUS_TREE_H) flags.h
cplus-class.o : cplus-class.c $(CONFIG_H) $(CPLUS_TREE_H)
cplus-init.o : cplus-init.c $(CONFIG_H) $(CPLUS_TREE_H)
cplus-method.o : cplus-method.c $(CONFIG_H) $(CPLUS_TREE_H)
cplus-cvt.o : cplus-cvt.c $(CONFIG_H) $(CPLUS_TREE_H)
cplus-search.o : cplus-search.c $(CONFIG_H) $(CPLUS_TREE_H)
new-method.o : new-method.c $(CONFIG_H) $(CPLUS_TREE_H)

# Language-independent files.

gcc.o: gcc.c $(CONFIG_H) Makefile $(GCTDEFS_H) gct-files.h
	$(CC) $(CFLAGS) $(INCLUDES) \
  -DSTANDARD_STARTFILE_PREFIX=\"$(libdir)/\" \
  -DSTANDARD_EXEC_PREFIX=\"$(libdir)/gct-\" -c \
  `echo $(srcdir)/gcc.c | sed 's,^\./,,'`

version.o: version.c
obstack.o: obstack.c

tree.o : tree.c $(CONFIG_H) $(TREE_H) flags.h
print-tree.o : print-tree.c $(CONFIG_H) $(TREE_H)
stor-layout.o : stor-layout.c $(CONFIG_H) $(TREE_H) $(RTL_H)
fold-const.o : fold-const.c $(CONFIG_H) $(TREE_H)
toplev.o : toplev.c $(CONFIG_H) $(TREE_H) flags.h input.h $(GCT_H)

rtl.o : rtl.c $(CONFIG_H) $(RTL_H)

rtlanal.o : rtlanal.c $(CONFIG_H) $(RTL_H)

varasm.o : varasm.c $(CONFIG_H) $(TREE_H) $(RTL_H) flags.h expr.h \
   insn-codes.h hard-reg-set.h
stmt.o : stmt.c $(CONFIG_H) $(RTL_H) $(TREE_H) flags.h  \
   insn-flags.h expr.h insn-config.h regs.h hard-reg-set.h insn-codes.h
expr.o : expr.c $(CONFIG_H) $(RTL_H) $(TREE_H) flags.h  \
   insn-flags.h insn-codes.h expr.h insn-config.h recog.h
expmed.o : expmed.c $(CONFIG_H) $(RTL_H) $(TREE_H) flags.h  \
   insn-flags.h insn-codes.h expr.h insn-config.h recog.h
explow.o : explow.c $(CONFIG_H) $(RTL_H) $(TREE_H) flags.h expr.h insn-codes.h
optabs.o : optabs.c $(CONFIG_H) $(RTL_H) $(TREE_H) flags.h  \
   insn-flags.h insn-codes.h expr.h insn-config.h recog.h
symout.o : symout.c $(CONFIG_H) $(TREE_H) $(RTL_H) symseg.h gdbfiles.h
dbxout.o : dbxout.c $(CONFIG_H) $(TREE_H) $(RTL_H) flags.h
sdbout.o : sdbout.c $(CONFIG_H) $(TREE_H) $(RTL_H)

emit-rtl.o : emit-rtl.c $(CONFIG_H) $(RTL_H) regs.h insn-config.h real.h

integrate.o : integrate.c $(CONFIG_H) $(RTL_H) $(TREE_H) flags.h expr.h \
   insn-flags.h insn-codes.h

jump.o : jump.c $(CONFIG_H) $(RTL_H) flags.h regs.h
stupid.o : stupid.c $(CONFIG_H) $(RTL_H) regs.h hard-reg-set.h

cse.o : cse.c $(CONFIG_H) $(RTL_H) regs.h hard-reg-set.h flags.h real.h
loop.o : loop.c $(CONFIG_H) $(RTL_H) insn-config.h insn-codes.h \
   regs.h hard-reg-set.h recog.h flags.h expr.h
flow.o : flow.c $(CONFIG_H) $(RTL_H) basic-block.h regs.h hard-reg-set.h
combine.o : combine.c $(CONFIG_H) $(RTL_H) flags.h  \
   insn-config.h regs.h basic-block.h recog.h
regclass.o : regclass.c $(CONFIG_H) $(RTL_H) hard-reg-set.h flags.h \
   basic-block.h regs.h insn-config.h recog.h 
local-alloc.o : local-alloc.c $(CONFIG_H) $(RTL_H) flags.h basic-block.h regs.h \
   hard-reg-set.h insn-config.h recog.h
global-alloc.o : global-alloc.c $(CONFIG_H) $(RTL_H) flags.h  \
   basic-block.h regs.h hard-reg-set.h insn-config.h

reload.o : reload.c $(CONFIG_H) $(RTL_H) flags.h \
   reload.h recog.h hard-reg-set.h insn-config.h regs.h
reload1.o : reload1.c $(CONFIG_H) $(RTL_H) flags.h  \
   reload.h regs.h hard-reg-set.h insn-config.h basic-block.h recog.h
caller-save.o : caller-save.c $(CONFIG_H) $(RTL_H) flags.h \
   reload.h regs.h hard-reg-set.h insn-config.h basic-block.h recog.h
final.o : final.c $(CONFIG_H) $(RTL_H) flags.h regs.h recog.h conditions.h \
   gdbfiles.h insn-config.h real.h output.h
recog.o : recog.c $(CONFIG_H) $(RTL_H)  \
   regs.h recog.h hard-reg-set.h insn-config.h real.h

# Normally this target is not used; but it is used if you
# define ALLOCA=alloca.o.  In that case, you must get a suitable alloca.c
# from the GNU Emacs distribution.
# Note some machines won't allow $(CC) without -S on this source file.
alloca.o:	alloca.c
	$(CC) $(CFLAGS) -c `echo $(srcdir)/alloca.c | sed 's,^\./,,'`

# Now the source files that are generated from the machine description.

.PRECIOUS: insn-config.h insn-flags.h insn-codes.h \
  insn-emit.c insn-recog.c insn-extract.c insn-output.c insn-peep.c

# The following pair of rules has this effect:
# genconfig is run only if the md has changed since genconfig was last run;
# but the file insn-config.h is touched only when its contents actually change.

# Each of the other insn-* files is handled by a similar pair of rules.

# BEM:  Posix requires error when trying to create too-long filename.
# Hence all the names like tmp-insn-config.h have been changed to
# Tinsn-config.h 
insn-config.h: stamp-config.h ;
stamp-config.h : md genconfig
	./genconfig md > Tinsn-config.h
	$(srcdir)/move-if-change Tinsn-config.h insn-config.h
	touch stamp-config.h

insn-flags.h: stamp-flags.h ;
stamp-flags.h : md genflags
	./genflags md > Tinsn-flags.h
	$(srcdir)/move-if-change Tinsn-flags.h insn-flags.h
	touch stamp-flags.h

insn-codes.h: stamp-codes.h ;
stamp-codes.h : md gencodes
	./gencodes md > Tinsn-codes.h
	$(srcdir)/move-if-change Tinsn-codes.h insn-codes.h
	touch stamp-codes.h

insn-emit.o : insn-emit.c $(CONFIG_H) $(RTL_H) expr.h real.h insn-codes.h \
  insn-config.h insn-flags.h
	$(CC) $(CFLAGS) $(INCLUDES) -c insn-emit.c

insn-emit.c: stamp-emit.c ;
stamp-emit.c : md genemit
	./genemit md > Tinsn-emit.c
	$(srcdir)/move-if-change Tinsn-emit.c insn-emit.c
	touch stamp-emit.c

insn-recog.o : insn-recog.c $(CONFIG_H) $(RTL_H) insn-config.h real.h recog.h
	$(CC) $(CFLAGS) $(INCLUDES) -c insn-recog.c

insn-recog.c: stamp-recog.c ;
stamp-recog.c : md genrecog
	./genrecog md > Tinsn-recog.c
	$(srcdir)/move-if-change Tinsn-recog.c insn-recog.c
	touch stamp-recog.c

insn-extract.o : insn-extract.c $(CONFIG_H) $(RTL_H)
	$(CC) $(CFLAGS) $(INCLUDES) -c insn-extract.c

insn-extract.c: stamp-xtrct.c ;
stamp-xtrct.c : md genextract
	./genextract md > Tinsn-extr.c
	$(srcdir)/move-if-change Tinsn-extr.c insn-extract.c
	touch stamp-xtrct.c

insn-peep.o : insn-peep.c $(CONFIG_H) $(RTL_H) regs.h real.h
	$(CC) $(CFLAGS) $(INCLUDES) -c insn-peep.c

insn-peep.c: stamp-peep.c ;
stamp-peep.c : md genpeep
	./genpeep md > Tinsn-peep.c
	$(srcdir)/move-if-change Tinsn-peep.c insn-peep.c
	touch stamp-peep.c

insn-output.o : insn-output.c $(CONFIG_H) $(RTL_H) regs.h real.h conditions.h \
    hard-reg-set.h insn-config.h insn-flags.h output.h aux-output.c
	$(CC) $(CFLAGS) $(INCLUDES) -c insn-output.c

insn-output.c: stamp-output.c ;
stamp-output.c : md genoutput
	./genoutput md > Tinsn-output.c
	$(srcdir)/move-if-change Tinsn-output.c insn-output.c
	touch stamp-output.c

# Now the programs that generate those files.
# $(CONFIG_H) is omitted from the deps of the gen*.o
# because these programs don't really depend on anything 
# about the target machine.  They do depend on config.h itself,
# since that describes the host machine.

genconfig : genconfig.o rtl.o $(LIBDEPS)
	$(CC) $(CFLAGS) $(LDFLAGS) -o genconfig genconfig.o rtl.o $(LIBS)

genconfig.o : genconfig.c $(RTL_H) config.h

genflags : genflags.o rtl.o $(LIBDEPS)
	$(CC) $(CFLAGS) $(LDFLAGS) -o genflags genflags.o rtl.o $(LIBS)

genflags.o : genflags.c $(RTL_H) config.h

gencodes : gencodes.o rtl.o $(LIBDEPS)
	$(CC) $(CFLAGS) $(LDFLAGS) -o gencodes gencodes.o rtl.o $(LIBS)

gencodes.o : gencodes.c $(RTL_H) config.h

genemit : genemit.o rtl.o $(LIBDEPS)
	$(CC) $(CFLAGS) $(LDFLAGS) -o genemit genemit.o rtl.o $(LIBS)

genemit.o : genemit.c $(RTL_H) config.h

genrecog : genrecog.o rtl.o $(LIBDEPS)
	$(CC) $(CFLAGS) $(LDFLAGS) -o genrecog genrecog.o rtl.o $(LIBS)

genrecog.o : genrecog.c $(RTL_H) config.h

genextract : genextract.o rtl.o $(LIBDEPS)
	$(CC) $(CFLAGS) $(LDFLAGS) -o genextract genextract.o rtl.o $(LIBS)

genextract.o : genextract.c $(RTL_H) config.h

genpeep : genpeep.o rtl.o $(LIBDEPS)
	$(CC) $(CFLAGS) $(LDFLAGS) -o genpeep genpeep.o rtl.o $(LIBS)

genpeep.o : genpeep.c $(RTL_H) config.h

genoutput : genoutput.o rtl.o $(LIBDEPS)
	$(CC) $(CFLAGS) $(LDFLAGS) -o genoutput genoutput.o rtl.o $(LIBS)

genoutput.o : genoutput.c $(RTL_H) config.h

# Making the preprocessor
cpp: cccp
	-rm -f cpp
	-ln cccp cpp
cccp: cccp.o cexp.o version.o $(LIBDEPS)
	$(CC) $(CFLAGS) $(LDFLAGS) -o cccp cccp.o cexp.o version.o \
		$(TESTLIBS) $(LIBS)

cexp.o: $(srcdir)/cexp.c $(CONFIG_H)
$(srcdir)/cexp.c: $(srcdir)/cexp.y
	$(BISON) -o $(srcdir)/cexp.c $(srcdir)/cexp.y
cccp.o: cccp.c $(CONFIG_H) gct-macros.h Makefile
	$(CC) $(CFLAGS) $(INCLUDES) \
          -DGCC_INCLUDE_DIR=\"$(libdir)/gct-include\" \
          -DGCT_INCLUDE_DEFAULT=\"$(libdir)/gct-include/default\" \
	  -DSTANDARD_STARTFILE_PREFIX=\"$(libdir)/\" \
          -DGPLUSPLUS_INCLUDE_DIR=\"$(libdir)/gct++-include\" \
	  -c `echo $(srcdir)/cccp.c | sed 's,^\./,,'`


CLEANSTUFF = *.o insn-flags.h insn-config.h insn-codes.h \
 insn-output.c insn-recog.c insn-emit.c insn-extract.c insn-peep.c \
 stamp-flags.h stamp-config.h stamp-codes.h \
 stamp-output.c stamp-recog.c stamp-emit.c stamp-xtrct.c stamp-peep.c \
 genemit genoutput genrecog genextract genflags gencodes genconfig genpeep

clean:
	-rm -f $(REMOVABLE_EXECUTABLES) $(CLEANSTUFF) cccp
	-rm -f stamp-*.[ch] Tinsn-*
	-rm -f *.s *.s[0-9] *.co *.greg *.lreg *.combine *.flow *.cse *.jump *.rtl *.tree *.loop *.dbr *.jump2
	-rm -f core
	-cd varargs; make clean

# Remove only executables.
cleanexec:
	-/bin/rm -f $(REMOVABLE_EXECUTABLES)

# Like clean but also delete the links made to configure gcc.
cleanconfig: clean
	-rm -f tm.h aux-output.c config.h md config.status 

# Get rid of every file that's generated from some other file (except INSTALL).
# We do not delete cexp.c and c-parse.tab.c, because we want gct to
# be compilable on systems that don't run bison.  They are deleted in 
# bisonclean.

realclean: cleanconfig
	-rm -f TAGS c-parse.output gct-map gct-map.*

bisonclean:	realclean
#	-rm -f cplus-parse.tab.c cplus-parse.output
	-rm -f c-parse.tab.c c-parse.output c-parse.tab.output
	-rm -f cexp.c

bindist:
	if [ '${tarfile}' = '' ]; then exit 1; fi
	mkdir /usr/tmp/prefix
	mkdir /usr/tmp/prefix/proj
	mkdir /usr/tmp/prefix/proj/systest
	mkdir /usr/tmp/prefix/proj/systest/bin
	mkdir /usr/tmp/prefix/proj/systest/lib
	make install prefix=/usr/tmp/prefix
	cd /usr/tmp/prefix/proj/systest; tar cf /usr/tmp/${tarfile} .
	/bin/rm -rf /usr/tmp/prefix


# Copy the files into directories where they will be run.
# Uninstall is run first, because the default least-common-denominator
# $(INSTALL) will fail if the files are not writable.
install:
	make uninstall libdir=$(libdir) bindir=$(bindir)
	if [ ! -d $(libdir) ]; then mkdir $(libdir); fi
	if [ ! -d $(libdir)/gct-include ]; then mkdir $(libdir)/gct-include; fi
	if [ ! -d $(bindir) ]; then mkdir $(bindir); fi
	-if [ -f cc1 ] ; then $(INSTALL) cc1 $(libdir)/gct-cc1 ;fi
	$(INSTALL) cpp $(libdir)/gct-cpp
	$(INSTALL) callcc $(libdir)/gct-callcc
	$(INSTALL) passcc $(libdir)/gct-passcc
	$(INSTALL) gedit.el $(libdir)
	$(INSTALL) $(gctscript) $(bindir)/gct
	$(INSTALL) gct.exec $(bindir)
# ADD INSTALLATION OF OTHER COMPILER SCRIPTS HERE.  EXAMPLE:
#	$(INSTALL) gct-mycc $(bindir)
	$(INSTALL) greport $(bindir)
	$(INSTALL) gfilter $(bindir)
	$(INSTALL) gsummary $(bindir)
	$(INSTALL) grestore $(bindir)
	$(INSTALL) gmerge $(bindir)
	$(INSTALL) gedit $(bindir)
	$(INSTALL) gct-init $(bindir)
	$(INSTALL) gnewer $(bindir)
	$(INSTALL) gclean $(bindir)
	$(INSTALL) glist $(bindir)
#	$(INSTALL) gcorefrom $(bindir)
	$(INSTALL) gct-defs.h $(libdir)
	$(INSTALL) gct-ps-defs.G $(libdir)
	$(INSTALL) gct-write.G $(libdir)



man_install:
	make man_uninstall mandir=$(mandir)
	$(INSTALL) ../doc/manpages/gct.1 $(mandir)/gct.$(manext)
	$(INSTALL) ../doc/manpages/gct-init.1 $(mandir)/gct-init.$(manext)
	$(INSTALL) ../doc/manpages/gmerge.1 $(mandir)/gmerge.$(manext)
	$(INSTALL) ../doc/manpages/gedit.1 $(mandir)/gedit.$(manext)
	$(INSTALL) ../doc/manpages/greport.1 $(mandir)/greport.$(manext)
	$(INSTALL) ../doc/manpages/gfilter.1 $(mandir)/gfilter.$(manext)
	$(INSTALL) ../doc/manpages/gsummary.1 $(mandir)/gsummary.$(manext)
	$(INSTALL) ../doc/manpages/grestore.1 $(mandir)/grestore.$(manext)
	$(INSTALL) ../doc/manpages/gnewer.1 $(mandir)/gnewer.$(manext)
	$(INSTALL) ../doc/manpages/gclean.1 $(mandir)/gclean.$(manext)
	$(INSTALL) ../doc/manpages/glist.1 $(mandir)/glist.$(manext)
	$(INSTALL) ../doc/manpages/gct-remap.1 $(mandir)/gct-remap.$(manext)
	$(INSTALL) ../doc/manpages/gct-newlog.1 $(mandir)/gct-newlog.$(manext)
#	$(INSTALL) ../doc/manpages/gcorefrom.1 $(mandir)/gcorefrom.$(manext)
	if [ ! -f $(mandir)/gcc.$(manext) ]; then $(INSTALL) ../doc/manpages/gcc.1 $(mandir)/gcc.$(manext); fi

uninstall:
	-/bin/rm -f $(libdir)/gct-cc1
	-/bin/rm -f $(libdir)/gedit.el
	-/bin/rm -f $(libdir)/gct-cpp
	-/bin/rm -f $(libdir)/gct-callcc
	-/bin/rm -f $(libdir)/gct-passcc
	-/bin/rm -f $(bindir)/gct
# ADD UNINSTALLATION OF OTHER COMPILER SCRIPTS HERE.  EXAMPLE:
#	-/bin/rm -f $(bindir)/gct-mycc
	-/bin/rm -f $(bindir)/gct.exec
	-/bin/rm -f $(bindir)/greport
	-/bin/rm -f $(bindir)/gfilter
	-/bin/rm -f $(bindir)/gsummary
	-/bin/rm -f $(bindir)/grestore 
	-/bin/rm -f $(bindir)/gnewer
	-/bin/rm -f $(bindir)/gclean
	-/bin/rm -f $(bindir)/glist
	-/bin/rm -f $(bindir)/gmerge 
	-/bin/rm -f $(bindir)/gedit
	-/bin/rm -f $(bindir)/gct-init
	-/bin/rm -f $(bindir)/gcorefrom
	-/bin/rm -f $(libdir)/gct-defs.h
	-/bin/rm -f $(libdir)/gct-ps-defs.G
	-/bin/rm -f $(libdir)/gct-write.G

man_uninstall:
	-/bin/rm -f $(mandir)/gct.$(manext)
	-/bin/rm -f $(mandir)/gct-init.$(manext)
	-/bin/rm -f $(mandir)/gmerge.$(manext)
	-/bin/rm -f $(mandir)/gedit.$(manext)
	-/bin/rm -f $(mandir)/greport.$(manext)
	-/bin/rm -f $(mandir)/gfilter.$(manext)
	-/bin/rm -f $(mandir)/gsummary.$(manext)
	-/bin/rm -f $(mandir)/grestore.$(manext)
	-/bin/rm -f $(mandir)/gnewer.$(manext)
	-/bin/rm -f $(mandir)/gclean.$(manext)
	-/bin/rm -f $(mandir)/glist.$(manext)
	-/bin/rm -f $(mandir)/gct-remap.$(manext)
	-/bin/rm -f $(mandir)/gct-newlog.$(manext)
#	-/bin/rm -f $(mandir)/gcorefrom.$(manext)

force:
