#
# makefile for egcs
#
# Created by Klaus K"ampf, kkaempf@progis.de
#

# choose egcs or dec c
#CC = gcc
CC = cc

# With or withou haifa scheduler ?
#HAIFA=,"HAIFA"
HAIFA=

PWD=sys$$disk:[]
RM=delete/nolog

ifeq ($(CC),gcc)
ifeq ($(ARCH),ALPHA)
CFLAGS=/define=("HAVE_CONFIG_H=1","USE_COLLECT2" $(HAIFA))
LIBS=,gnu_cc_library:libgcc.olb/lib,sys$$library:vaxcrtl.olb/lib,gnu_cc_library:crt0.obj
else
CFLAGS=/define=("HAVE_CONFIG_H=1","USE_COLLECT2" $(HAIFA))
LIBS=,gnu_cc_library:libgcc.olb/lib,sys$$library:vaxcrtl.olb/lib
endif
LFLAGS=/map/full
#LFLAGS=
else
ifeq ($(ARCH),ALPHA)
CFLAGS=/names=as_is/float=ieee/noopt/debug/define=("HAVE_CONFIG_H=1","USE_COLLECT2" $(HAIFA))\
/warning=disable=(missingreturn,implicitfunc,ptrmismatch,undefescap,longextern,duptypespec)
else
CFLAGS=/noopt/debug/define=("HAVE_CONFIG_H=1","USE_COLLECT2" $(HAIFA))
endif
LFLAGS=/nomap
LIBS=,sys$$library:vaxcrtl.olb/lib
endif

BISON = bison
BISON_FLAGS=  /Yacc/Define/Verbose
RENAME=	rename/New_Version
LINK  =	link		#/noshare/nosysshr
EDIT  =	edit
SEARCH=	search
ABORT =	exit %x002C
echo  =	write sys$$output

CINCL1	=	/Incl=([],[.config])
CINCL2	=	/Incl=([],[.ginclude],[.config])
CINCL_SUB =	/Incl=([],[-],[-.ginclude],[-.config])
CINCL_CP=	/Incl=([],[.config],[.cp],[.cp.inc])

MDFILE = [.config.$(ARCH)]$(ARCH).md

ifeq ($(HAIFA),)
SCHED=sched
else
SCHED=haifa-sched
endif

GENOBJS=[]rtl.obj,obstack.obj

INDEPOBJS= []toplev.obj,version.obj,tree.obj,print-tree.obj,stor-layout.obj,\
fold-const.obj,function.obj,stmt.obj,except.obj,expr.obj,calls.obj,expmed.obj,\
explow.obj,optabs.obj,varasm.obj,rtl.obj,print-rtl.obj,rtlanal.obj,\
emit-rtl.obj,genrtl.obj,real.obj,regmove.obj,dbxout.obj,sdbout.obj,dwarfout.obj,\
dwarf2out.obj,xcoffout.obj,bitmap.obj,alias.obj,\
integrate.obj,jump.obj,cse.obj,loop.obj,unroll.obj,flow.obj,stupid.obj,\
combine.obj,regclass.obj,local-alloc.obj,global.obj,reload.obj,\
reload1.obj,caller-save.obj,insn-peep.obj,reorg.obj,$(SCHED).obj,\
final.obj,recog.obj,reg-stack.obj,insn-opinit.obj,insn-recog.obj,\
insn-extract.obj,insn-output.obj,insn-emit.obj,\
profile.obj,insn-attrtab.obj,\
aux-output.obj,getpwd.obj,convert.obj

CC1OBJS=[]c-parse.obj,c-lang.obj,c-lex.obj,c-pragma.obj,c-decl.obj,\
c-typeck.obj,c-convert.obj,c-aux-info.obj,c-common.obj,c-iterate.obj,\
obstack.obj

OBJCOBJS=

# list copied from cc1plus-objs.opt

CC1PLUSOBJS=[.cp]call.obj,[.cp]decl2.obj,\
[.cp]except.obj,[.cp]pt.obj,\
[.cp]spew.obj,[.cp]xref.obj,[.cp]class.obj,\
[.cp]expr.obj,[.cp]lex.obj,\
[.cp]ptree.obj,[.cp]tree.obj,[.cp]cvt.obj,\
[.cp]errfn.obj,[.cp]rtti.obj,[.cp]method.obj,\
[.cp]search.obj,[.cp]typeck.obj,[.cp]decl.obj,\
[.cp]error.obj,[.cp]friend.obj,[.cp]init.obj,[.cp]parse.obj,\
[.cp]sig.obj,[.cp]typeck2.obj,[.cp]repo.obj,\
[.cp]input.obj,\
[]obstack.obj,\
[]c-common.obj,[]c-pragma.obj

CCCPOBJS=[]cccp.obj,cexp.obj,version.obj,prefix.obj

ALLOCA=,[]alloca.obj

LIBIBERTY = [-.libiberty]libiberty.olb

CXX_LIB2FUNCS = [.cp]tinfo.obj,[.cp]tinfo2.obj,\
[.cp]new.obj,[.cp]new1.obj,[.cp]new2.obj,[.cp]exception.obj

.c.obj:
	$(CC) $(CFLAGS) $(CINCL1) $</obj=$@

.cc.obj:
	$(CC)/plus/CPP="-nostdinc++" $(CFLAGS) $(CINCL_CP) $</obj=$@

INSN_INCLUDES=insn-attr.h insn-codes.h insn-config.h insn-flags.h

#
#
#

all: cpp.exe cc1.exe float.h limits.h libgcc2.olb

allplus: cc1plus.exe libgccplus.olb

libplus: libgccplus.olb

cc1.exe: $(CC1OBJS) $(ALLOCA) $(INDEPOBJS)
	$(LINK)$(LFLAGS)/exe=$@ version.opt/opt,cc1-objs.opt/Opt,independent.opt/Opt$(ALLOCA)$(LIBS)

cpp.exe: $(CCCPOBJS) $(ALLOCA)
	$(LINK)$(LFLAGS)/exe=$@ $(CCCPOBJS),version.opt/opt$(ALLOCA)$(LIBS)

cc1plus.exe: $(CC1PLUSOBJS) $(ALLOCA) $(INDEPOBJS)
	$(LINK)$(LFLAGS)/exe=$@ version.opt/opt,cc1plus-objs.opt/Opt,independent.opt/Opt$(ALLOCA)$(LIBS)

gcc.exe: gcc.obj version.obj choose-temp.obj pexecute.obj prefix.obj obstack.obj
	$(LINK)$(LFLAGS)/exe=$@ $^$(ALLOCA)$(LIBS)
        
install: cpp.exe cc1.exe gcc.exe libgcc2.olb
	$(CP) $^ GNU_CC_LIBRARY

installplus: cc1plus.exe libgccplus.olb
	$(CP) $^ GNU_CC_LIBRARY

float.h: enquire.exe
	mcr $(PWD)enquire.exe -f > $@

limits.h: enquire.exe
	mcr $(PWD)enquire.exe -l > $@

enquire.exe: enquire.obj
	$(LINK)$(LFLAGS)/exe=$@ enquire.obj$(ALLOCA)$(LIBS)

libgcc2.olb:
	$$ @make-l2

libgccplus.olb: $(CXX_LIB2FUNCS)
	lib/create libgccplus $(CXX_LIB2FUNCS)

genattr.exe: genattr.obj,$(GENOBJS)$(ALLOCA)
	$(LINK) $(LFLAGS)/exe=$@ $^$(LIBS)

insn-attr.h: genattr.exe $(MDFILE)
	mcr $(PWD)genattr.exe $(MDFILE) > $@

genflags.exe: genflags.obj,$(GENOBJS)$(ALLOCA)
	$(LINK) $(LFLAGS)/exe=$@ $^$(LIBS)

insn-flags.h: genflags.exe $(MDFILE)
	mcr $(PWD)genflags.exe $(MDFILE) > $@

gencodes.exe: gencodes.obj,$(GENOBJS)$(ALLOCA)
	$(LINK) $(LFLAGS)/exe=$@ $^$(LIBS)

insn-codes.h: gencodes.exe $(MDFILE)
	mcr $(PWD)gencodes.exe $(MDFILE) > $@

genconfig.exe: genconfig.obj,$(GENOBJS)$(ALLOCA)
	$(LINK) $(LFLAGS)/exe=$@ $^$(LIBS)

insn-config.h: genconfig.exe $(MDFILE)
	mcr $(PWD)genconfig.exe $(MDFILE) > $@

genpeep.exe: genpeep.obj,$(GENOBJS)$(ALLOCA)
	$(LINK) $(LFLAGS)/exe=$@ $^$(LIBS)

insn-peep.c: genpeep.exe $(MDFILE)
	mcr $(PWD)genpeep.exe $(MDFILE) > $@

genopinit.exe: genopinit.obj,$(GENOBJS)$(ALLOCA)
	$(LINK) $(LFLAGS)/exe=$@ $^$(LIBS)

insn-opinit.c: genopinit.exe $(MDFILE)
	mcr $(PWD)genopinit.exe $(MDFILE) > $@

genrecog.exe: genrecog.obj,$(GENOBJS)$(ALLOCA)
	$(LINK) $(LFLAGS)/exe=$@ $^$(LIBS)

insn-recog.c: genrecog.exe $(MDFILE)
	mcr $(PWD)genrecog.exe $(MDFILE) > $@

genextract.exe: genextract.obj,$(GENOBJS)$(ALLOCA)
	$(LINK) $(LFLAGS)/exe=$@ $^$(LIBS)

insn-extract.c: genextract.exe $(MDFILE)
	mcr $(PWD)genextract.exe $(MDFILE) > $@

genoutput.exe: genoutput.obj,$(GENOBJS)$(ALLOCA)
	$(LINK) $(LFLAGS)/exe=$@ $^$(LIBS)

insn-output.c: genoutput.exe $(MDFILE)
	mcr $(PWD)genoutput.exe $(MDFILE) > $@

genemit.exe: genemit.obj,$(GENOBJS)$(ALLOCA)
	$(LINK) $(LFLAGS)/exe=$@ $^$(LIBS)

insn-emit.c: genemit.exe $(MDFILE)
	mcr $(PWD)genemit.exe $(MDFILE) > $@

genattrtab.exe: genattrtab.obj,rtlanal.obj,$(GENOBJS)$(ALLOCA)
	$(LINK) $(LFLAGS)/exe=$@ $^$(LIBS)

insn-attrtab.c: genattrtab.exe $(MDFILE)
	mcr $(PWD)genattrtab.exe $(MDFILE) > $@

gengenrtl.exe: gengenrtl.obj,obstack.obj,$(ALLOCA)
	$(LINK) $(LFLAGS)/exe=$@ $^$(LIBS)

genrtl.h genrtl.c: gengenrtl.exe
	mcr $(PWD)gengenrtl.exe	genrtl.h genrtl.c

cccp.obj: cccp.c config.h
aux-output.obj: aux-output.c insn-attr.h insn-flags.h insn-config.h
caller-save.obj: caller-save.c insn-config.h
calls.obj: calls.c insn-flags.h
combine.obj: combine.c insn-attr.h insn-flags.h insn-codes.h insn-config.h
cse.obj: cse.c insn-config.h
c-decl.obj: c-decl.c expr.h integrate.h insn-codes.h insn-config.h
c-lex.obj: c-lex.c genrtl.h
c-typeck.obj: c-typeck.c
dbxout.obj: dbxout.c insn-config.h
dwarfout.obj: dwarfout.c insn-config.h
dwarf2out.obj: dwarf2out.c insn-config.h
emit-rtl.obj: emit-rtl.c insn-config.h
except.obj: except.c insn-flags.h insn-codes.h insn-config.h
explow.obj: explow.c insn-flags.h insn-codes.h insn-config.h
expmed.obj: expmed.c insn-flags.h insn-codes.h insn-config.h
expr.obj: expr.c insn-flags.h insn-config.h
final.obj: final.c tm.h insn-attr.h insn-flags.h insn-codes.h insn-config.h
flow.obj: flow.c insn-config.h
function.obj: function.c insn-flags.h insn-codes.h insn-config.h insn-codes.h insn-config.h
genattrtab.obj: genattrtab.c insn-config.h
genextract.obj: genextract.c insn-config.h
global.obj: global.c insn-config.h
integrate.obj: integrate.c integrate.h insn-flags.h insn-config.h
jump.obj: jump.c insn-flags.h insn-config.h
local-alloc.obj: local-alloc.c insn-config.h
loop.obj: loop.c insn-flags.h insn-config.h
optabs.obj: optabs.c insn-flags.h insn-codes.h insn-config.h
print-rtl.obj: print-rtl.c
profile.obj: profile.c insn-flags.h insn-config.h
recog.obj: recog.c insn-attr.h insn-flags.h insn-codes.h insn-config.h
regclass.obj: regclass.c insn-config.h
reg-stack.obj: reg-stack.c insn-config.h
reload.obj: reload.c insn-codes.h insn-config.h
reload1.obj: reload1.c insn-flags.h insn-codes.h insn-config.h
reorg.obj: reorg.c insn-attr.h insn-flags.h insn-config.h
sched.obj: sched.c insn-attr.h insn-config.h
haifa-sched.obj: haifa-sched.c insn-attr.h insn-config.h
stmt.obj: stmt.c insn-flags.h insn-codes.h insn-config.h
stor-layout.obj: stor-layout.c
stupid.obj: stupid.c
toplev.obj: toplev.c insn-attr.h insn-config.h
unroll.obj: unroll.c insn-config.h

insn-attrtab.obj: insn-attrtab.c insn-attr.h insn-config.h
insn-output.obj: insn-output.c insn-attr.h insn-flags.h insn-codes.h
insn-emit.obj: insn-emit.c insn-flags.h insn-codes.h insn-config.h
insn-opinit.obj: insn-opinit.c insn-flags.h insn-codes.h insn-config.h
insn-output.obj: insn-config.h
insn-recog.obj: insn-config.h

varasm.obj: varasm.c tm.h
toplev.obj: toplev.c tm.h

cexp.c: cexp.y
	$(BISON) $(BISON_FLAGS)/output=$@ $<
c-parse.c: c-parse.y
	$(BISON) $(BISON_FLAGS)/output=$@ $<
[.cp]parse.c: [.cp]parse.y
	$(BISON) $(BISON_FLAGS)/output=$@ $<
[.cp]parse.h: [.cp]parse.c
	@$(ECHO) "Must copy YYEMPTY from [.cp]parse.c to [.cp]parse.h"
	$$ stop
aux-output.c: [.config.$(ARCH)]$(ARCH).c
	copy $< $@

expr.h: insn-codes.h
reload.h: insn-config.h
integrate.h: insn-config.h

config.h:
	$$ @vmsconfig

cleancccp:
	$$ purge
	$(RM) cccp.obj;,cexp.obj;
	$(RM) cpp.exe;

cleanlib:
	$$ purge
	$(RM) libgcc2.olb;

cleanlibplus:
	$$ purge
	$(RM) [.cp]tinfo.obj;
	$(RM) [.cp]tinfo2.obj;
	$(RM) [.cp]new.obj;
	$(RM) [.cp]new1.obj;
	$(RM) [.cp]new2.obj;
	$(RM) [.cp]exception.obj;
	$(RM) libgccplus.olb;

clean:
	$$ purge
	$$ purge [.cp]
	$(RM) *.obj;*
	$(RM) [.cp]*.obj;*
	$(RM) [.cp]parse.output;*
	$(RM) *.cpp;*
	$(RM) *.s;*
	$(RM) *.rtl;*
	$(RM) a.out;
	$(RM) *.combine;
	$(RM) *.cpp;
	$(RM) *.cse;
	$(RM) *.cse2;
	$(RM) *.dbr;
	$(RM) *.flow;
	$(RM) *.greg;
	$(RM) *.jump;
	$(RM) *.jump2;
	$(RM) *.loop;
	$(RM) *.lreg;
	$(RM) *.rtl;
	$(RM) *.sched;
	$(RM) *.sched2;
	$(RM) *.map;
	$(RM) genattr.exe;,insn-attr.h;
	$(RM) genflags.exe;,insn-flags.h;
	$(RM) gencodes.exe;,insn-codes.h;
	$(RM) genconfig.exe;,insn-config.h;
	$(RM) genpeep.exe;,insn-peep.c;
	$(RM) genopinit.exe;,insn-opinit.c;
	$(RM) genrecog.exe;,insn-recog.c;
	$(RM) genextract.exe;,insn-extract.c;
	$(RM) genoutput.exe;,insn-output.c;
	$(RM) genemit.exe;,insn-emit.c;
	$(RM) genattrtab.exe;,insn-attrtab.c;
	$(RM) gengenrtl.exe;,genrtl.c;,genrtl.h;
	$(RM) cc1.exe;
	$(RM) cpp.exe;
	$(RM) cc1plus.exe;
	$(RM) libgcc2.olb;
	$(RM) libgccplus.olb;
	$(RM) enquire.exe;,float.h;,limits.h;
#
# clean everything axpconfig.com creates
#
distclean: clean cleancccp
	purge [...]
	$(RM) config.h;
	$(RM) tconfig.h;
	$(RM) hconfig.h;
	$(RM) tm.h;
	$(RM) options.h;
	$(RM) specs.h;
	$(RM) aux-output.c;

[.cp]call.obj: [.cp]call.c
[.cp]decl2.obj: [.cp]decl2.c
[.cp]except.obj: [.cp]except.c insn-codes.h insn-flags.h
[.cp]pt.obj: [.cp]pt.c
[.cp]spew.obj: [.cp]spew.c
[.cp]xref.obj: [.cp]xref.c
[.cp]class.obj: [.cp]class.c
[.cp]expr.obj: [.cp]expr.c insn-codes.h
[.cp]lex.obj: [.cp]lex.c [.cp]parse.h
[.cp]ptree.obj: [.cp]ptree.c
[.cp]tree.obj: [.cp]tree.c
[.cp]cvt.obj: [.cp]cvt.c
[.cp]errfn.obj: [.cp]errfn.c
[.cp]rtti.obj: [.cp]rtti.c
[.cp]method.obj: [.cp]method.c insn-codes.h
[.cp]search.obj: [.cp]search.c
[.cp]typeck.obj: [.cp]typeck.c
[.cp]decl.obj: [.cp]decl.c
[.cp]error.obj: [.cp]error.c
[.cp]friend.obj: [.cp]friend.c
[.cp]init.obj: [.cp]init.c
[.cp]parse.obj: [.cp]parse.c
	$(CC) $(CFLAGS) $(CINCL_CP) $^/obj=$@
[.cp]sig.obj: [.cp]sig.c
[.cp]typeck2.obj: [.cp]typeck2.c
[.cp]repo.obj: [.cp]repo.c
[.cp]input.obj: [.cp]input.c
	$(TOUCH) $@
# g++ library
[.cp]tinfo.obj: [.cp]tinfo.cc
[.cp]tinfo2.obj: [.cp]tinfo2.cc
[.cp]new.obj: [.cp]new.cc
[.cp]new1.obj: [.cp]new1.cc
[.cp]new2.obj: [.cp]new2.cc
[.cp]exception.obj: [.cp]exception.cc

#EOF
