# Make GNU C native compiler for OS-9.
# Modified from Makefile of gcc-1.37.1
# by Julian Blake, CERN, July and December 1990, February 1991.

# Makefile for GNU C compiler.
#   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.


# edition number of cc1
CC1ED = 20

# edition number of cccp
CCCPED = 3

# edition number of gcc
GCCED = 4

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

OSKFLAGS = -DOSK # -DOSK_TARGET -DHAVE_SEPARATE_DATA_AREA
OPTFLAGS = -O -fcombine-regs -mgss -o68
CFLAGS = $(OSKFLAGS) $(OPTFLAGS) $(XCFLAGS)
CC = gccos9 -nostdinc
HCFLAGS = -g $(OSKFLAGS) $(XCFLAGS)
HCC = /usr/local/unix/gcc
BISON = bison
BISONFLAGS = -v
AR = ar
SHELL = /bin/sh
# on sysV, define this as cp.
INSTALL = install -c

# Compiler to use for compiling gnulib.
# OLDCC should not be the GNU C compiler.
OLDCC = cc68

# CFLAGS for use with OLDCC, for compiling gnulib.
# NOTE: -O does not work on some Unix systems!
# On them, you must take it out.
CCLIBFLAGS = -Q -S

# CFLAGS for use with CC, for compiling gnulib2.
CCLIB2FLAGS = -o68 -mnostack-check -fcombine-regs -fstrength-reduce \
   -Dalloca=__builtin_alloca

# CFLAGS for use with OLDCC, for compiling hard-params.
HARD_PARAMS_FLAGS=-O

# Directory where sources are, from where we are.
srcdir = .
# Directory in which to put the executable for the command `gcc'
bindir = $(prefix)/usr/local/unix
# Directory in which to put the subprograms used by the compiler.
libdir = $(prefix)/usr/local/lib
# Directory in which to put man pages.
mandir = $(prefix)/usr/man/manl
# Number to put in man-page filename.
manext = l

# Additional system libraries to link with.
CLIB=

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

# Directory to link to, when using the target `maketest'.
DIR = ../gcc-os9

# 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 -O
# HARD_PARAMS_FLAGS = -Wc,-Ns2000 -Wc,-Ne700
# For CCLIBFLAGS you might want to specify the switch that
# forces only 68000 instructions to be used.

# On the Sequent, you may need to set CCLIBFLAG to empty.

# On the 3b1, this line may help you compile gnulib
# if you already have a prior version of gcc installed.
# CCLIBFLAGS = -B/usr/local/lib/gcc- -tp -Wp,-traditional

# 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:
# 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 = -lc /usr/.attlib/libPW.a

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


# missing libraries for OSK
CLIB = perror.r getcd.r ldexp.r stat.r qsort.r
LCLIB = -l=perror.r -l=getcd.r -l=ldexp.r -l=stat.r -l=qsort.r

ALLOCA = alloca.r
LALLOCA = -l=alloca.r

MALLOC =
LMALLOC =

OBSTACK = obstack.r
LOBSTACK = -l=obstack.r

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

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

HOBSTACK = obstack.o
HALLOCA =
HMALLOC =
HCLIB =
HLIBDEPS = $(HOBSTACK) $(HALLOCA) $(HMALLOC) $(HCLIB)
HLIBS = $(HOBSTACK) $(HALLOCA) $(HMALLOC) $(HCLIB)

# 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 -I$(srcdir)/osksrc \
   -I/usr/local/lib/gccos9-include -I$${CDEF}
SUBDIR_INCLUDES = -I.. -I../$(srcdir) -I../$(srcdir)/config \
   -I../$(srcdir)/config \
   -I/usr/local/lib/gccos9-include -I$${CDEF}
LIBINCLUDES = -I$(srcdir)/osksrc \
   -I/usr/local/lib/gccos9-include -I$${CDEF}
HINCLUDES = -I. -I$(srcdir) -I$(srcdir)/config -I$(srcdir)/osksrc

# Always use -I$(srcdir)/config when compiling.
.SUFFIXES:
.SUFFIXES: .c .a .r .o
.c.r:
	$(CC) -c $(CFLAGS) $(CPPFLAGS) $(INCLUDES) $<
.a.r:
	$(OLDCC) -R $<
.c.o:
	$(HCC) $(HCFLAGS) $(HINCLUDES) -c $<

# Language-specific object files for C.
C_OBJS = c_parse.tab.r c_decl.r c_typeck.r c_convert.r

# Language-specific object files for C++.
# (These are not yet released.)
CPLUS_OBJS = cplus_parse.r cplus_decl.r cplus_typeck.r \
   cplus_cvt.r cplus_search.r cplus_lex.r \
   cplus_class.r cplus_init.r cplus_method.r

# Language-independent object files.
OBJS = toplev.r version.r tree.r print_tree.r stor_layout.r fold_const.r \
 rtl.r rtlanal.r expr.r stmt.r expmed.r explow.r optabs.r varasm.r \
 symout.r dbxout.r sdbout.r emit_rtl.r insn_emit.r \
 integrate.r jump.r cse.r loop.r flow.r stupid.r combine.r \
 regclass.r local_alloc.r global_alloc.r reload.r reload1.r caller_save.r \
 insn_peep.r final.r recog.r insn_recog.r insn_extract.r insn_output.r

# Files to be copied away after each stage in building.
STAGE_GCC=gcc
STAGESTUFF = *.a *.o *.r *.stb 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_extract.c stamp_peep.c \
 genemit genoutput genrecog genextract genflags gencodes genconfig genpeep \
 gnulib.l gnulib gnulib1 gnulib2 \
 cc1 cpp cccp # cc1plus

# Library members defined in gnulib.c
# Don't change order of names.  (A.S.)
# Fortunately, output of MicroWare's c68 does not use d2 and d3 in 
# _eprintf, _builtin_new, _builtin_gNew and _builtin_del.
LIBFUNCS = _eprintf _umulsi3 _mulsi3 _udivsi3 _divsi3 _umodsi3 _modsi3 \
  _lshrsi3 _lshlsi3 _ashrsi3 _ashlsi3 _divdf3 _muldf3 _negdf2 _adddf3 \
  _subdf3 _cmpdf2 _fixunsdfsi _fixdfsi _floatsidf _truncdfsf2 _extendsfdf2 \
  _addsf3 _negsf2 _subsf3 _cmpsf2 _mulsf3 _divsf3 _builtin_new _builtin_gNew \
  _builtin_del _stack_check

# Library members defined in gnulib2.c.
# Don't change order of names.  (A.S.)
LIB2FUNCS = _anddi3 _ashldi3 _divdi3 _udivdi3 _fixdfdi _fixunsdfdi _adddi3 \
  _floatdidf _ashrdi3 _lshldi3 _subdi3 _iordi3 _lshrdi3 _moddi3 _cmpdi2 \
  _negdi2 _umoddi3 _bdiv _muldi3 _one_cmpldi2 _ucmpdi2 _varargs _xordi3

# 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 *.r 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

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

all: config.status gnulib gnulib2 gcc cc1 cpp # float.h cc1plus

lang-c: config.status gnulib gnulib2 gcc cc1 cpp
# lang-cplus: config.status gnulib gnulib2 gcc cc1plus cpp

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

doc: $(srcdir)/cpp.info $(srcdir)/gplus.info $(srcdir)/gcc.info

compilations: ${OBJS}

gcc: gccosk.r version.r $(LIBDEPS)
	l68 -o=gcc -ga -e=$(GCCED) -M=32K \
	$${CLIB}/cstart.r gccosk.r version.r $(LLIBS) -l=gnulib.l \
	-l=$${CLIB}/cio.l -l=$${CLIB}/clibn.l \
	-l=$${CLIB}/math.l -l=$${CLIB}/sys.l

cc1: $(C_OBJS) $(OBJS) $(LIBDEPS)
	l68 -o=cc1 -ga -e=$(CC1ED) -M=7K \
	$${CLIB}/cstart.r $(C_OBJS) $(OBJS) $(LLIBS) -l=gnulib.l \
	-l=$${CLIB}/cio.l -l=$${CLIB}/clibn.l \
	-l=$${CLIB}/math.l -l=$${CLIB}/sys.l

cc1plus: $(CPLUS_OBJS) $(OBJS) $(LIBDEPS)
	l68 -o=cc1plus -ga -e=$(CC1ED) -M=7K \
	$${CLIB}/cstart.r $(CPLUS_OBJS) $(OBJS) $(LLIBS) -l=gnulib.l \
	-l=$${CLIB}/cio.l -l=$${CLIB}/clibn.l \
	-l=$${CLIB}/math.l -l=$${CLIB}/sys.l

# missing libraries for OSK.

qsort.r: osksrc/qsort.c
	$(CC) -c $(CFLAGS) $(LIBINCLUDES) osksrc/qsort.c

perror.r: osksrc/perror.c
	$(CC) -c $(CFLAGS) $(LIBINCLUDES) osksrc/perror.c

getcd.r: osksrc/getcd.c
	$(CC) -c $(CFLAGS) $(LIBINCLUDES) osksrc/getcd.c

ldexp.r: osksrc/ldexp.c
	$(CC) -c $(CFLAGS) $(LIBINCLUDES) osksrc/ldexp.c

stat.r: osksrc/stat.c
	$(CC) -c $(CFLAGS) $(LIBINCLUDES) osksrc/stat.c

alloca.r: osksrc/alloca.a
	$(OLDCC) -R osksrc/alloca.a
	mv osksrc/alloca.r alloca.r

#Library of arithmetic subroutines
# Don't compile this with gcc!
# (That would cause most arithmetic functions to call themselves.)
gnulib: gnulib.c $(CONFIG_H)
	-rm -f stamp_gnulib2
	rm -f tmpgnulib gnulib; \
	for name in $(LIBFUNCS); \
	do \
	  echo $${name}; \
	  rm -f $${name}.c; \
	  cp $(srcdir)/gnulibosk.c $${name}.c; \
	  $(OLDCC) $(CCLIBFLAGS) -R -DL$${name} $${name}.c; \
	  cat >> tmpgnulib $${name}.r; \
	  rm -f $${name}.[cr]; \
	done
# Actually build it in tmpgnulib above, then rename now,
# so that gnulib itself remains nonexistent if compilation is aborted.
	mv tmpgnulib gnulib
# On HPUX, if you are working with the GNU assembler and linker,
# the previous two command lines must be replaced with the following line.
# No change is needed here if you are using the HPUX assembler and linker.
#	../hp-bin/hpxt tmpgnulib gnulib
	cp gnulib gnulib1

gnulib2: stamp_gnulib2;
stamp_gnulib2: gnulib2.c gnulib # cc1 gcc cpp $(CONFIG_H)
	rm -f gnulib2; \
	for name in $(LIB2FUNCS); \
	do \
	  echo $${name}; \
	  rm -f $${name}.c; \
	  cp $(srcdir)/gnulib2.c $${name}.c; \
	  $(CC) $(INCLUDES) $(CCLIB2FLAGS) -c \
	    -DL$${name} $${name}.c -o $${name}.r; \
	  cat >> gnulib2 $${name}.r; \
	  rm -f $${name}.[cr]; \
	done
# On HPUX, if you are working with the GNU assembler and linker,
# the previous line must be commented out.
# No change is needed here if you are using the HPUX assembler and linker.
	cat > gnulib gnulib2 gnulib1
	touch stamp_gnulib2

gnulib.l: gnulib gnulib2
	-rm -f gnulib.l
	ln gnulib gnulib.l

float.h:
# Originally, we used `make' rather than $(MAKE), to avoid propagating
# a CC=gcc command option.  However, since hard_params is now made
# with $(OLDCC) explicitly, this is no longer important.
# However, $(MAKE) fails on some systems where it isn't defined.
# `make' has the disadvantage of sometimes running the system's make,
# instead of GNU make.  And the system's make might not support VPATH.
# However, the compilation of hard_params should not need to use VPATH,
# due to the explicit use of `$(srcdir)'.
	make hard_params
	_./hard_params -f > float.h

# Compile hard_params with standard cc.  It avoids some headaches.
hard_params: hard_params.r
	$(OLDCC) $(HARD_PARAMS_FLAGS) $(LDFLAGS) hard_params.r -o $@
hard_params.r: $(srcdir)/hard_params.c
	-cp $(srcdir)/hard_params.c . > /dev/null 2>&1
	$(OLDCC) $(HARD_PARAMS_FLAGS) $(CPPFLAGS) -DNO_SC -R hard_params.c

# C language specific files.

c_parse.tab.r : $(srcdir)/c_parse.tab.c $(CONFIG_H) $(TREE_H) c_parse.h c_tree.h input.h
	$(CC) $(CFLAGS) $(CPPFLAGS) $(INCLUDES) -c $(srcdir)/c_parse.tab.c
$(srcdir)/c_parse.tab.c : $(srcdir)/c_parse.y
	$(BISON) $(BISONFLAGS) $(srcdir)/c_parse.y -o $@

c_decl.r : c_decl.c $(CONFIG_H) $(TREE_H) c_tree.h c_parse.h flags.h
c_typeck.r : c_typeck.c $(CONFIG_H) $(TREE_H) c_tree.h flags.h
c_convert.r : c_convert.c $(CONFIG_H) $(TREE_H)

# C++ language specific files.

cplus_parse.r : $(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.r : cplus_lex.c $(CONFIG_H) $(CPLUS_TREE_H) $(srcdir)/cplus_parse.h
cplus_decl.r : cplus_decl.c $(CONFIG_H) $(CPLUS_TREE_H) flags.h
cplus_typeck.r : cplus_typeck.c $(CONFIG_H) $(CPLUS_TREE_H) flags.h
cplus_class.r : cplus_class.c $(CONFIG_H) $(CPLUS_TREE_H)
cplus_init.r : cplus_init.c $(CONFIG_H) $(CPLUS_TREE_H)
cplus_method.r : cplus_method.c $(CONFIG_H) $(CPLUS_TREE_H)
cplus_cvt.r : cplus_cvt.c $(CONFIG_H) $(CPLUS_TREE_H)
cplus_search.r : cplus_search.c $(CONFIG_H) $(CPLUS_TREE_H)
new_method.r : new_method.c $(CONFIG_H) $(CPLUS_TREE_H)

# Language-independent files.

gccosk.r: gccosk.c $(CONFIG_H)
	$(CC) $(CFLAGS) $(INCLUDES) -c \
  `echo $(srcdir)/gccosk.c | sed 's,^\./,,'`

version.r: version.c
obstack.r: obstack.c

tree.r : tree.c $(CONFIG_H) $(TREE_H) flags.h
print_tree.r : print_tree.c $(CONFIG_H) $(TREE_H)
stor_layout.r : stor_layout.c $(CONFIG_H) $(TREE_H) $(RTL_H)
fold_const.r : fold_const.c $(CONFIG_H) $(TREE_H)
toplev.r : toplev.c $(CONFIG_H) $(TREE_H) flags.h input.h

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

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

varasm.r : varasm.c $(CONFIG_H) $(TREE_H) $(RTL_H) flags.h expr.h \
   insn_codes.h hard_reg_set.h
stmt.r : stmt.c $(CONFIG_H) $(RTL_H) $(TREE_H) flags.h  \
   insn_flags.h insn_config.h insn_codes.h expr.h regs.h hard_reg_set.h recog.h
expr.r : expr.c $(CONFIG_H) $(RTL_H) $(TREE_H) flags.h  \
   insn_flags.h insn_codes.h expr.h insn_config.h recog.h
expmed.r : expmed.c $(CONFIG_H) $(RTL_H) $(TREE_H) flags.h  \
   insn_flags.h insn_codes.h expr.h insn_config.h recog.h
explow.r : explow.c $(CONFIG_H) $(RTL_H) $(TREE_H) flags.h expr.h insn_codes.h
optabs.r : optabs.c $(CONFIG_H) $(RTL_H) $(TREE_H) flags.h  \
   insn_flags.h insn_codes.h expr.h insn_config.h recog.h
symout.r : symout.c $(CONFIG_H) $(TREE_H) $(RTL_H) symseg.h gdbfiles.h
dbxout.r : dbxout.c $(CONFIG_H) $(TREE_H) $(RTL_H) flags.h
sdbout.r : sdbout.c $(CONFIG_H) $(TREE_H) $(RTL_H)

emit_rtl.r : emit_rtl.c $(CONFIG_H) $(RTL_H) regs.h insn_config.h real.h

integrate.r : integrate.c $(CONFIG_H) $(RTL_H) $(TREE_H) flags.h expr.h \
   insn_flags.h insn_codes.h

jump.r : jump.c $(CONFIG_H) $(RTL_H) flags.h regs.h
stupid.r : stupid.c $(CONFIG_H) $(RTL_H) regs.h hard_reg_set.h

cse.r : cse.c $(CONFIG_H) $(RTL_H) regs.h hard_reg_set.h flags.h real.h
loop.r : 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.r : flow.c $(CONFIG_H) $(RTL_H) basic_block.h regs.h hard_reg_set.h
combine.r : combine.c $(CONFIG_H) $(RTL_H) flags.h  \
   insn_config.h regs.h basic_block.h recog.h
regclass.r : regclass.c $(CONFIG_H) $(RTL_H) hard_reg_set.h flags.h \
   basic_block.h regs.h insn_config.h recog.h
local_alloc.r : 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.r : global_alloc.c $(CONFIG_H) $(RTL_H) flags.h  \
   basic_block.h regs.h hard_reg_set.h insn_config.h

reload.r : reload.c $(CONFIG_H) $(RTL_H) flags.h \
   reload.h recog.h hard_reg_set.h insn_config.h regs.h
reload1.r : 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.r : 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.r : final.c $(CONFIG_H) $(RTL_H) flags.h regs.h recog.h conditions.h \
   gdbfiles.h insn_config.h real.h output.h
recog.r : 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.r.  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.

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

insn_config.h: stamp_config.h ;
stamp_config.h : md genconfig
	./genconfig md > tmp_config.h
	$(srcdir)/move_if_change tmp_config.h insn_config.h
	touch stamp_config.h

insn_flags.h: stamp_flags.h ;
stamp_flags.h : md genflags
	./genflags md > tmp_flags.h
	$(srcdir)/move_if_change tmp_flags.h insn_flags.h
	touch stamp_flags.h

insn_codes.h: stamp_codes.h ;
stamp_codes.h : md gencodes
	./gencodes md > tmp_codes.h
	$(srcdir)/move_if_change tmp_codes.h insn_codes.h
	touch stamp_codes.h

insn_emit.r : insn_emit.c $(CONFIG_H) $(RTL_H) expr.h real.h insn_codes.h \
  insn_config.h insn_flags.h

insn_emit.c: stamp_emit.c ;
stamp_emit.c : md genemit
	./genemit md > tmp_emit.c
	$(srcdir)/move_if_change tmp_emit.c insn_emit.c
	touch stamp_emit.c

insn_recog.r : insn_recog.c $(CONFIG_H) $(RTL_H) insn_config.h real.h recog.h

insn_recog.c: stamp_recog.c ;
stamp_recog.c : md genrecog
	./genrecog md > tmp_recog.c
	$(srcdir)/move_if_change tmp_recog.c insn_recog.c
	touch stamp_recog.c

insn_extract.r : insn_extract.c $(CONFIG_H) $(RTL_H)

insn_extract.c: stamp_extract.c ;
stamp_extract.c : md genextract
	./genextract md > tmp_extract.c
	$(srcdir)/move_if_change tmp_extract.c insn_extract.c
	touch stamp_extract.c

insn_peep.r : insn_peep.c $(CONFIG_H) $(RTL_H) regs.h real.h

insn_peep.c: stamp_peep.c ;
stamp_peep.c : md genpeep
	./genpeep md > tmp_peep.c
	$(srcdir)/move_if_change tmp_peep.c insn_peep.c
	touch stamp_peep.c

insn_output.r : 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

insn_output.c: stamp_output.c ;
stamp_output.c : md genoutput
	./genoutput md > tmp_output.c
	$(srcdir)/move_if_change tmp_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 $(HLIBDEPS)
	$(HCC) $(HCFLAGS) $(HLDFLAGS) -o genconfig genconfig.o rtl.o $(HLIBS)

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

genflags : genflags.o rtl.o $(HLIBDEPS)
	$(HCC) $(HCFLAGS) $(HLDFLAGS) -o genflags genflags.o rtl.o $(HLIBS)

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

gencodes : gencodes.o rtl.o $(HLIBDEPS)
	$(HCC) $(HCFLAGS) $(HLDFLAGS) -o gencodes gencodes.o rtl.o $(HLIBS)

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

genemit : genemit.o rtl.o $(HLIBDEPS)
	$(HCC) $(HCFLAGS) $(HLDFLAGS) -o genemit genemit.o rtl.o $(HLIBS)

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

genrecog : genrecog.o rtl.o $(HLIBDEPS)
	$(HCC) $(HCFLAGS) $(HLDFLAGS) -o genrecog genrecog.o rtl.o $(HLIBS)

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

genextract : genextract.o rtl.o $(HLIBDEPS)
	$(HCC) $(HCFLAGS) $(HLDFLAGS) -o genextract genextract.o rtl.o $(HLIBS)

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

genpeep : genpeep.o rtl.o $(HLIBDEPS)
	$(HCC) $(HCFLAGS) $(HLDFLAGS) -o genpeep genpeep.o rtl.o $(HLIBS)

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

genoutput : genoutput.o rtl.o $(HLIBDEPS)
	$(HCC) $(HCFLAGS) $(HLDFLAGS) -o genoutput genoutput.o rtl.o $(HLIBS)

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

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

# Making the preprocessor
cpp: cccp
	-rm -f cpp
	ln cccp cpp
cccp: cccp.r cexp.r version.r $(LIBDEPS)
	l68 -o=cccp -ga -e=$(CCCPED) -M=32K \
	$${CLIB}/cstart.r cccp.r cexp.r version.r $(LLIBS) \
	-l=gnulib.l -l=$${CLIB}/cio.l -l=$${CLIB}/clibn.l \
	-l=$${CLIB}/math.l -l=$${CLIB}/sys.l
cexp.r: $(srcdir)/cexp.c $(CONFIG_H)
	$(CC) $(CFLAGS) $(CPPFLAGS) $(INCLUDES) -c $(srcdir)/cexp.c
$(srcdir)/cexp.c: $(srcdir)/cexp.y
	$(BISON) -o $(srcdir)/cexp.c $(srcdir)/cexp.y
cccp.r: cccp.c $(CONFIG_H)
	$(CC) $(CFLAGS) $(INCLUDES) \
	  -c `echo $(srcdir)/cccp.c | sed 's,^\./,,'`

$(srcdir)/cpp.info: $(srcdir)/cpp.texinfo
	makeinfo `echo $(srcdir)/cpp.texinfo | sed 's,^\./,,'`

$(srcdir)/gplus.info: $(srcdir)/gplus.texinfo
	makeinfo `echo $(srcdir)/gplus.texinfo | sed 's,^\./,,'`

$(srcdir)/gcc.info: $(srcdir)/gcc.texinfo
	makeinfo `echo $(srcdir)/gcc.texinfo | sed 's,^\./,,'`

# gnulib is not deleted because deleting it would be inconvenient
# for most uses of this target.
clean:
	-rm -f $(STAGESTUFF) $(STAGE_GCC)
# Delete the temp files made in the course of building gnulib.
	-rm -f tmpgnulib
	for name in $(LIBFUNCS); do rm -f $${name}.c; done
	for name in $(LIB2FUNCS); do rm -f $${name}.c; done
	-rm -f stamp_*.[ch] tmp_*
	-rm -f *.s *.s[0-9] *.co *.greg *.lreg *.combine *.flow *.cse \
	   *.jump *.rtl *.tree *.loop *.dbr *.jump2
	-rm -f core float.h hard_params

# Like clean but also delete the links made to configure gcc.
# Also removes gnulib, since that is desirable if you are changing cpus.
cleanconfig: clean
	-rm -f tm.h aux_output.c config.h md config.status \
	   gnulib.l gnulib gnulib1 gnulib2 stamp_gnulib2

# Get rid of every file that's generated from some other file (except INSTALL).
realclean: cleanconfig
	-rm -f cpp.aux cpp.cps cpp.fns cpp.info cpp.kys cpp.pgs cpp.tps cpp.vrs
#       -rm -f cplus_parse.tab.c cplus_parse.output
	-rm -f c_parse.tab.c c_parse.output c_parse.tab.output
	-rm -f gnulib cexp.c TAGS
	-rm -f cpp.info* cpp.?? cpp.??s cpp.log cpp.toc cpp.*aux
	-rm -f gcc.info* gcc.?? gcc.??s gcc.log gcc.toc gcc.*aux
	-rm -f gplus.info* gplus.?? gplus.??s gplus.log gplus.toc gplus.*aux
	-rm -f *.dvi

# Copy the files into directories where they will be run.
install: all
#       -mkdir $(libdir)
#       -if [ -f cc1 ] ; then $(INSTALL) cc1 $(libdir)/gccos9-cc1 ;fi
#       -if [ -f cc1plus ] ; then $(INSTALL) cc1plus $(libdir)/gccos9-cc1plus ;fi
#       $(INSTALL) gnulib $(libdir)/gccos9-gnulib
#       -if [ -f /usr/bin/ranlib ] ; then (cd $(libdir); ranlib gccos9-gnulib) ;fi
#       $(INSTALL) cpp $(libdir)/gccos9-cpp
#       $(INSTALL) gcc $(bindir)/gccos9
#       -mkdir $(libdir)/gccos9-include
#       -chmod ugo+rx $(libdir)/gccos9-include
#       for file in $(USER_H); do \
#            for eachfile in  $(srcdir)/$${file} ; do \
#               $(INSTALL) $${eachfile} $(libdir)/gccos9-include; \
#            done ; done
#       $(INSTALL) float.h $(libdir)/gccos9-include/float.h
#       $(INSTALL) $(srcdir)/gvarargs.h $(libdir)/gccos9-include/varargs.h
#       $(INSTALL) $(srcdir)/gcc.1 $(mandir)/gccos9.$(manext)

# do make -f ../gcc-os9/Makefile maketest DIR=../gcc-os9
# in the intended test directory to make it a suitable test directory.
maketest:
	ln -s $(DIR)/*.[chy] .
	ln -s $(DIR)/config .
	ln -s $(DIR)/*.def .
	-rm -f =*
	ln -s $(DIR)/.gdbinit .
	-ln -s $(DIR)/bison.simple .
	ln -s $(DIR)/config.gcc .
	ln -s $(DIR)/move_if_change .
# The then and else were swapped to avoid a problem on Ultrix.
	if [ ! -f Makefile ] ; then ln -s $(DIR)/Makefile . ; else false; fi
	-rm tm.h aux_output.c config.h md
	make clean
# You must then run config.gcc to set up for compilation.

bootstrap: all force
#       $(MAKE) stage1
#       $(MAKE) CC="stage1/gcc -Bstage1/" CFLAGS="-O $(CFLAGS)" libdir=$(libdir)
#       $(MAKE) stage2
#       $(MAKE) CC="stage2/gcc -Bstage2/" CFLAGS="-O $(CFLAGS)" libdir=$(libdir)

bootstrap2: force
#       $(MAKE) CC="stage1/gcc -Bstage1/" CFLAGS="-O $(CFLAGS)" libdir=$(libdir)
#       $(MAKE) stage2
#       $(MAKE) CC="stage2/gcc -Bstage2/" CFLAGS="-O $(CFLAGS)" libdir=$(libdir)

bootstrap3: force
#       $(MAKE) CC="stage2/gcc -Bstage2/" CFLAGS="-O $(CFLAGS)" libdir=$(libdir)

# Copy the object files from a particular stage into a subdirectory.
stage1: force
	-mkdir stage1
	-mv $(STAGESTUFF) $(STAGE_GCC) stage1

stage2: force
	-mkdir stage2
	-mv $(STAGESTUFF) $(STAGE_GCC) stage2

stage3: force
	-mkdir stage3
	-mv $(STAGESTUFF) $(STAGE_GCC) stage3

stage4: force
	-mkdir stage4
	-mv $(STAGESTUFF) $(STAGE_GCC) stage4

TAGS: force
	mkdir temp
	-mv c_parse.tab.c cplus_parse.c cplus_parse.h cexp.c temp
	etags *.y *.h *.c
	mv temp/* .
	rmdir temp

includes: force
	LIB=$(libdir) ./fixincludes

#In GNU Make, ignore whether `stage*' exists.
.PHONY: stage1 stage2 stage3 stage4 clean realclean TAGS bootstrap

force:
