# Makefile for GNU C++ CROSS compiler for the atariST/TT series hosted
#  on a Sparc host (tested only on SunOS 4.0.3)
#  NOTE: requires alloca.c from the emacs dist.
#

# Makefile for GNU C compiler.
#   Copyright (C) 1987 Free Software Foundation, Inc.

#This file is part of GNU CC.

#GNU CC is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY.  No author or distributor
#accepts responsibility to anyone for the consequences of using it
#or for whether it serves any particular purpose or works at all,
#unless he says so in writing.  Refer to the GNU CC General Public
#License for full details.

#Everyone is granted permission to copy, modify and redistribute
#GNU CC, but only under the conditions described in the
#GNU CC General Public License.   A copy of this license is
#supposed to have been given to you along with GNU CC so you
#can know your rights and responsibilities.  It should be in a
#file named COPYING.  Among other things, the copyright notice
#and this notice must be preserved on all copies.

.NOEXPORT: # This tells GNU Make version 3
	   # not to put all the variables in the environment.

CROSSDIR = /net/acae127/home/bammi/atari/cross-gcc
CROSSBIN = $(CROSSDIR)/bin
CROSSLIB = $(CROSSDIR)/lib
CROSSINC = $(CROSSDIR)/include

GCC_INCLUDE_DIR = $(CROSSINC)
GPLUSPLUS_INCLUDE_DIR = $(CROSSDIR)/g++-inc

DFLAGS= -DCROSSDIR=\"$(CROSSDIR)\"
CFLAGS =  $(DFLAGS) -O -g -DCROSSATARI=1 -Usun -I./config -I. # -O
# LDFLAGS =
# host's cc (give full path to gcc is hosts gcc is not before . in your PATH)
CC = gcc

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

bindir = $(CROSSBIN)
libdir = $(CROSSLIB)

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

# 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) $(MALLOC1) $(CLIB)

# Language-specific object files for C++.
CPLUS_OBJS = cp-parse.o cp-decl.o cp-decl2.o \
   cp-typeck.o cp-type2.o cp-tree.o cp-ptree.o \
   cp-cvt.o cp-search.o cp-lex.o cp-gc.o cp-call.o \
   cp-class.o cp-init.o cp-method.o cp-except.o \
   cp-expr.o cp-pt.o cp-edsel.o cp-xref.o \
   $(CPLUS_INPUT) cp-spew.o c-common.o

# Language-independent object files.
OBJS = toplev.o version.o tree.o print-tree.o stor-layout.o fold-const.o \
 function.o stmt.o expr.o calls.o expmed.o explow.o optabs.o varasm.o \
 rtl.o print-rtl.o rtlanal.o emit-rtl.o real.o \
 dbxout.o sdbout.o dwarfout.o xcoffout.o \
 integrate.o jump.o cse.o loop.o unroll.o flow.o stupid.o combine.o \
 regclass.o local-alloc.o global.o reload.o reload1.o caller-save.o \
 insn-peep.o reorg.o sched.o final.o recog.o reg-stack.o \
 insn-opinit.o insn-recog.o insn-extract.o insn-output.o insn-emit.o \
 insn-attrtab.o aux-output.o getpwd.o convert.o $(EXTRA_OBJS)

GCC_PASSES=gcc cc1 cpp

# Files to be copied away after each stage in building.
STAGESTUFF = *.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 \
 insn-attr.h insn-attrtab.c insn-opinit.c \
 stamp-flags stamp-config stamp-codes \
 stamp-output stamp-recog stamp-emit stamp-extract stamp-peep \
 stamp-attr stamp-attrtab stamp-opinit stamp-proto \
 genemit genoutput genrecog genextract genflags gencodes genconfig genpeep \
 genattrtab genattr genopinit \
 $(GCC_PASSES) $(EXTRA_PARTS) $(EXTRA_PROGRAMS) gcc-cross cccp \
 cc1plus cc1obj enquire protoize unprotoize specs collect2 $(USE_COLLECT2)

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

# If you want to recompile everything, just do rm *.o.
# CONFIG_H = config.h tm.h
CONFIG_H =
RTL_H = rtl.h rtl.def machmode.h machmode.def
TREE_H = tree.h real.h tree.def machmode.h machmode.def
CPLUS_TREE_H = $(TREE_H) cp-tree.h cp-tree.def

ALL = cc1plus

all: $(ALL)

cc1plus: $(CPLUS_OBJS) $(OBJS) $(LIBDEPS)
	$(CC) $(CFLAGS) $(LDFLAGS) -o cc1plus $(CPLUS_OBJS) $(OBJS) $(LIBS)

# C++ language specific files.

cp-parse.o : cp-parse.c $(CONFIG_H) $(CPLUS_TREE_H) flags.h
	$(CC) -c $(CFLAGS) cp-parse.c

cp-parse.c cp-parse.h : cp-parse.y
	@echo expect 29 shift/reduce conflicts and 14 reduce/reduce conflicts
	$(BISON) $(BISONFLAGS) -d -o cp-parse.c cp-parse.y
	grep '^#define[ 	]*YYEMPTY' cp-parse.c >>cp-parse.h

cp-spew.o : cp-spew.c $(CONFIG_H) $(CPLUS_TREE_H) \
   cp-parse.h flags.h
cp-lex.o : cp-lex.c $(CONFIG_H) $(CPLUS_TREE_H) \
   cp-parse.h cp-input.c flags.h
cp-decl.o : cp-decl.c $(CONFIG_H) $(CPLUS_TREE_H) flags.h \
  cp-lex.h cp-decl.h stack.h
cp-decl2.o : cp-decl2.c $(CONFIG_H) $(CPLUS_TREE_H) flags.h \
  cp-lex.h cp-decl.h
cp-type2.o : cp-type2.c $(CONFIG_H) $(CPLUS_TREE_H) flags.h
cp-typeck.o : cp-typeck.c $(CONFIG_H) $(CPLUS_TREE_H) flags.h
cp-class.o : cp-class.c $(CONFIG_H) $(CPLUS_TREE_H) stack.h \
    cp-class.h flags.h
cp-call.o : cp-call.c $(CONFIG_H) $(CPLUS_TREE_H) stack.h cp-class.h \
    flags.h
cp-init.o : cp-init.c $(CONFIG_H) $(CPLUS_TREE_H) flags.h
cp-method.o : cp-method.c $(CONFIG_H) $(CPLUS_TREE_H)
cp-cvt.o : cp-cvt.c $(CONFIG_H) $(CPLUS_TREE_H)
cp-search.o : cp-search.c $(CONFIG_H) $(CPLUS_TREE_H) stack.h flags.h
cp-tree.o : cp-tree.c $(CONFIG_H) $(CPLUS_TREE_H) flags.h
cp-ptree.o : cp-ptree.c $(CONFIG_H) $(CPLUS_TREE_H)
cp-gc.o : cp-gc.c $(CONFIG_H) $(CPLUS_TREE_H) flags.h
cp-except.o : cp-except.c $(CONFIG_H) $(CPLUS_TREE_H) flags.h
cp-expr.o : cp-expr.c $(CONFIG_H) $(CPLUS_TREE_H) $(RTL_H) flags.h \
  expr.h insn-codes.h
cp-edsel.o : cp-edsel.c $(CONFIG_H) $(CPLUS_TREE_H) stack.h flags.h
cp-xref.o : cp-xref.c $(CONFIG_H) $(CPLUS_TREE_H)
cp-pt.o : cp-pt.c $(CONFIG_H) $(CPLUS_TREE_H) cp-decl.h cp-parse.h

# A file used by all variants of C.

c-common.o : c-common.c $(CONFIG_H) $(TREE_H) c-tree.h c-lex.h flags.h


# Language-independent files.
dumpvers: dumpvers.c

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

tree.o : tree.c $(CONFIG_H) $(TREE_H) gvarargs.h flags.h function.h
print-tree.o : print-tree.c $(CONFIG_H) $(TREE_H)
stor-layout.o : stor-layout.c $(CONFIG_H) $(TREE_H) function.h
fold-const.o : fold-const.c $(CONFIG_H) $(TREE_H) flags.h 
toplev.o : toplev.c $(CONFIG_H) $(TREE_H) $(RTL_H) flags.h input.h \
 insn-attr.h xcoffout.h

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

print-rtl.o : print-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 \
   insn-codes.h expr.h hard-reg-set.h regs.h xcoffout.h
function.o : function.c $(CONFIG_H) $(RTL_H) $(TREE_H) flags.h function.h  \
   insn-flags.h insn-codes.h expr.h regs.h hard-reg-set.h insn-config.h \
   recog.h output.h
stmt.o : stmt.c $(CONFIG_H) $(RTL_H) $(TREE_H) flags.h function.h  \
   insn-flags.h insn-config.h insn-codes.h hard-reg-set.h expr.h loop.h recog.h
expr.o : expr.c $(CONFIG_H) $(RTL_H) $(TREE_H) gvarargs.h flags.h function.h  \
   insn-flags.h insn-codes.h expr.h insn-config.h recog.h output.h typeclass.h
calls.o : calls.c $(CONFIG_H) $(RTL_H) $(TREE_H) flags.h expr.h insn-codes.h \
   insn-flags.h
expmed.o : expmed.c $(CONFIG_H) $(RTL_H) $(TREE_H) flags.h  \
   insn-flags.h insn-config.h insn-codes.h expr.h recog.h real.h
explow.o : explow.c $(CONFIG_H) $(RTL_H) $(TREE_H) flags.h hard-reg-set.h \
   insn-config.h expr.h recog.h insn-flags.h insn-codes.h
optabs.o : optabs.c $(CONFIG_H) $(RTL_H) $(TREE_H) flags.h  \
   insn-flags.h insn-config.h insn-codes.h expr.h recog.h
dbxout.o : dbxout.c $(CONFIG_H) $(TREE_H) $(RTL_H) flags.h regs.h \
   insn-config.h reload.h gstab.h xcoffout.h
sdbout.o : sdbout.c $(CONFIG_H) $(TREE_H) $(RTL_H) gsyms.h flags.h \
   insn-config.h reload.h
dwarfout.o : dwarfout.c $(CONFIG_H) $(TREE_H) $(RTL_H) dwarf.h flags.h \
   insn-config.h reload.h output.h
xcoffout.o : xcoffout.c $(CONFIG_H) $(TREE_H) $(RTL_H) xcoffout.h flags.h
emit-rtl.o : emit-rtl.c $(CONFIG_H) $(RTL_H) flags.h gvarargs.h function.h  \
   regs.h insn-config.h insn-codes.h real.h expr.h

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

jump.o : jump.c $(CONFIG_H) $(RTL_H) flags.h hard-reg-set.h regs.h \
   insn-config.h insn-flags.h insn-codes.h expr.h real.h
stupid.o : stupid.c $(CONFIG_H) $(RTL_H) regs.h hard-reg-set.h flags.h

cse.o : cse.c $(CONFIG_H) $(RTL_H) regs.h hard-reg-set.h flags.h real.h \
   insn-config.h recog.h
loop.o : loop.c $(CONFIG_H) $(RTL_H) flags.h loop.h insn-config.h \
   insn-flags.h insn-codes.h regs.h hard-reg-set.h recog.h expr.h real.h
unroll.o : unroll.c $(CONFIG_H) $(RTL_H) insn-config.h insn-codes.h \
   integrate.h regs.h flags.h expr.h loop.h
flow.o : flow.c $(CONFIG_H) $(RTL_H) flags.h insn-config.h \
   basic-block.h regs.h hard-reg-set.h output.h
combine.o : combine.c $(CONFIG_H) $(RTL_H) gvarargs.h flags.h  \
   insn-config.h insn-flags.h insn-codes.h insn-attr.h regs.h expr.h \
   basic-block.h recog.h real.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 output.h
global.o : global.c $(CONFIG_H) $(RTL_H) flags.h  \
   basic-block.h regs.h hard-reg-set.h insn-config.h output.h

reload.o : reload.c $(CONFIG_H) $(RTL_H) flags.h \
   reload.h recog.h hard-reg-set.h insn-config.h insn-codes.h regs.h real.h
reload1.o : reload1.c $(CONFIG_H) $(RTL_H) flags.h expr.h \
   reload.h regs.h hard-reg-set.h insn-config.h insn-flags.h insn-codes.h \
   basic-block.h recog.h output.h
caller-save.o : caller-save.c $(CONFIG_H) $(RTL_H) flags.h \
   regs.h hard-reg-set.h insn-config.h basic-block.h recog.h reload.h expr.h
reorg.o : reorg.c $(CONFIG_H) $(RTL_H) conditions.h hard-reg-set.h \
   basic-block.h regs.h insn-config.h insn-attr.h insn-flags.h recog.h \
   flags.h output.h
sched.o : sched.c $(CONFIG_H) $(RTL_H) basic-block.h regs.h hard-reg-set.h \
   flags.h insn-config.h insn-attr.h
final.o : final.c $(CONFIG_H) $(RTL_H) gvarargs.h flags.h regs.h \
   recog.h conditions.h insn-config.h insn-attr.h real.h output.h \
   hard-reg-set.h insn-codes.h gstab.h xcoffout.h
recog.o : recog.c $(CONFIG_H) $(RTL_H)  \
   regs.h recog.h hard-reg-set.h flags.h insn-config.h insn-attr.h \
   insn-flags.h insn-codes.h real.h
reg-stack.o : reg-stack.c $(CONFIG_H) $(RTL_H) $(TREE_H) \
   regs.h hard-reg-set.h flags.h insn-config.h
   
aux-output.o : aux-output.c $(CONFIG_H) \
   $(RTL_H) regs.h hard-reg-set.h real.h insn-config.h conditions.h \
   insn-flags.h output.h insn-attr.h insn-codes.h

.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 \
  insn-attr.h insn-attrtab.c

insn-config.h : md genconfig
	./genconfig md > tmp-insn-config.h
	./move-if-change tmp-insn-config.h insn-config.h

insn-flags.h : md genflags
	./genflags md > tmp-insn-flags.h
	./move-if-change tmp-insn-flags.h insn-flags.h

insn-codes.h : md gencodes
	./gencodes md > tmp-insn-codes.h
	./move-if-change tmp-insn-codes.h insn-codes.h

insn-emit.o : insn-emit.c $(CONFIG_H) $(RTL_H) expr.h insn-config.h
	$(CC) $(CFLAGS) -c insn-emit.c

insn-emit.c : md genemit
	./genemit md > tmp-insn-emit.c
	./move-if-change tmp-insn-emit.c insn-emit.c

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

insn-recog.c : md genrecog
	./genrecog md > tmp-insn-recog.c
	./move-if-change tmp-insn-recog.c insn-recog.c

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

insn-extract.c : md genextract
	./genextract md > tmp-insn-extract.c
	./move-if-change tmp-insn-extract.c insn-extract.c

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

insn-peep.c : md genpeep
	./genpeep md > tmp-insn-peep.c
	./move-if-change tmp-insn-peep.c insn-peep.c

insn-output.o : insn-output.c $(CONFIG_H) $(RTL_H) regs.h insn-config.h insn-flags.h conditions.h output.h aux-output.c
	$(CC) $(CFLAGS) -c insn-output.c

insn-output.c : md genoutput
	./genoutput md > tmp-insn-output.c
	./move-if-change tmp-insn-output.c insn-output.c

insn-attrtab.o : insn-attrtab.c $(CONFIG_H) $(RTL_H) regs.h real.h output.h \
     insn-attr.h insn-config.h
	$(CC) $(CFLAGS) -c insn-attrtab.c

insn-attr.h: md genattr
	./genattr md > tmp-attr.h
	./move-if-change tmp-attr.h insn-attr.h

insn-attrtab.c: md genattrtab
	./genattrtab md > tmp-attrtab.c
	./move-if-change tmp-attrtab.c insn-attrtab.c

# Now the programs that generate those files.

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

genconfig.o : genconfig.c $(RTL_H)
	$(CC) $(CFLAGS) -c genconfig.c

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

genflags.o : genflags.c $(RTL_H)
	$(CC) $(CFLAGS) -c genflags.c

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

gencodes.o : gencodes.c $(RTL_H)
	$(CC) $(CFLAGS) -c gencodes.c

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

genemit.o : genemit.c $(RTL_H)
	$(CC) $(CFLAGS) -c genemit.c

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

genrecog.o : genrecog.c $(RTL_H)
	$(CC) $(CFLAGS) -c genrecog.c

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

genextract.o : genextract.c $(RTL_H)
	$(CC) $(CFLAGS) -c genextract.c

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

genpeep.o : genpeep.c $(RTL_H)
	$(CC) $(CFLAGS) -c genpeep.c

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

genoutput.o : genoutput.c $(RTL_H)
	$(CC) $(CFLAGS) -c genoutput.c

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

genattr.o : genattr.c $(RTL_H) config.h
	$(CC) -c $(CFLAGS) genattr.c

genattrtab : genattrtab.o rtl.o rtlanal.o $(LIBDEPS)
	$(CC) $(CFLAGS) $(LDFLAGS) -o genattrtab \
	 genattrtab.o rtl.o rtlanal.o $(LIBS)

genattrtab.o : genattrtab.c $(RTL_H) config.h insn-config.h
	$(CC) -c $(CFLAGS) genattrtab.c

# gnulib is not deleted because deleting it would be inconvenient
# for most uses of this target.
clean:
	-rm -f *.o *.oo $(STAGESTUFF)
	-rm -f *.s *.s[0-9] *.co *.greg *.lreg *.combine *.flow *.cse *.jump *.rtl *.tree *.loop
	-rm -f core

# Get rid of every file that's generated from some other file (except INSTALL).
realclean: clean
	-rm -f $(ALL)
	-rm -f cpp.aux cpp.cps cpp.fns cpp.info cpp.kys cpp.pgs cpp.tps cpp.vrs
	-rm -f errs gnulib TAGS 
	-rm -f core report
	-rm -f internals internals-* internals.?? internals.??s

# Copy the files into directories where they will be run.
install: all
	cp cc1plus $(libdir)/gcc-cc1plus

force:
#In GNU Make, ignore whether `stage*' exists.
.PHONY: clean realclean
