# $Header$
#	M A K E F I L E   F O R   A C K   C - C O M P I L E R

# Machine and environ dependent definitions
EMHOME =	/usr/em#			# ACK tree on this machine
DESTINATION =	/user1/$$USER/bin#		# where to put the stuff
MKDEP =		$(EMHOME)/bin/mkdep#		# dependency generator
MAP =
#MAP = -DInsertFile=ins_file -DInsertText=ins_text# bug in m68k2 back end
SIM =		/user1/dick/bin/sim#		# Dicks sim program
LINT =		/usr/new/lint

# Libraries and EM interface definitions
SYSLIB =	$(EMHOME)/modules/lib/libsystem.a
EMKLIB =	$(EMHOME)/modules/lib/libemk.a
EMELIB =	$(EMHOME)/modules/lib/libeme.a $(EMHOME)/lib/em_data.a
STRLIB =	$(EMHOME)/modules/lib/libstring.a
PRTLIB =	$(EMHOME)/modules/lib/libprint.a
EMMESLIB =	$(EMHOME)/modules/lib/libem_mes.a
INPLIB =	$(EMHOME)/modules/lib/libinput.a
ALLOCLIB =	$(EMHOME)/modules/lib/liballoc.a
MALLOC =	$(EMHOME)/modules/lib/malloc.o
#CH3LIB =	$(EMHOME)/modules/lib/libch3.a
CH3LIB =
LIBS =		$(INPLIB) $(CH3LIB) $(EMMESLIB) $(EMKLIB) \
		$(PRTLIB) $(STRLIB) $(ALLOCLIB) $(MALLOC) $(SYSLIB)
ELIBS =		$(INPLIB) $(CH3LIB) $(EMMESLIB) $(EMELIB) \
		$(PRTLIB) $(STRLIB) $(ALLOCLIB) $(MALLOC) $(SYSLIB)
LIB_INCLUDES =	-I$(EMHOME)/modules/h -I$(EMHOME)/modules/pkg
EM_INCLUDES =	-I$(EMHOME)/h
SYSLLIB =	$(EMHOME)/modules/lib/llib-lsys.ln
EMKLLIB =	$(EMHOME)/modules/lib/llib-lemk.ln
EMELLIB =	$(EMHOME)/modules/lib/llib-leme.ln
STRLLIB =	$(EMHOME)/modules/lib/llib-lstr.ln
PRTLLIB =	$(EMHOME)/modules/lib/llib-lprint.ln
EMMESLLIB =	$(EMHOME)/modules/lib/llib-lmes.ln
INPLLIB =	$(EMHOME)/modules/lib/llib-linput.ln
CH3LLIB =	$(EMHOME)/modules/lib/llib-lch3.ln
ALLOCLLIB =	$(EMHOME)/modules/lib/llib-alloc.ln
LINTLIBS =
#LINTLIBS =	$(CH3LLIB) $(INPLLIB) $(EMMESLLIB) $(EMKLLIB) \
#		$(PRTLLIB) $(STRLLIB) $(SYSLLIB) $(ALLOCLLIB)

# Where to install the compiler and its driver
CEMCOM =	$(DESTINATION)/cemcom
DRIVER =	$(DESTINATION)/cem

# What C compiler to use and how
# CC = $(ACK) -.c
# CC = CC
# CC = /bin/cc
COPTIONS =

# What parser generator to use and how
GEN =		$(EMHOME)/bin/LLgen
GENOPTIONS =	-vv

# Special #defines during compilation
CDEFS =		$(MAP) $(EM_INCLUDES) $(LIB_INCLUDES)
CFLAGS =	$(CDEFS) $(COPTIONS) -O# we cannot pass the COPTIONS to lint!

# Grammar files and their objects
LSRC =	tokenfile.g declar.g statement.g expression.g program.g ival.g
GLCSRC = tokenfile.c declar.c statement.c expression.c program.c Lpars.c ival.c
LOBJ =	tokenfile.o declar.o statement.o expression.o program.o Lpars.o ival.o

CSRC =  main.c idf.c declarator.c decspecs.c struct.c \
        expr.c ch7.c ch7bin.c cstoper.c arith.c \
        asm.c code.c dumpidf.c error.c field.c\
        tokenname.c LLlex.c LLmessage.c \
        input.c domacro.c replace.c init.c options.c \
        scan.c skip.c stack.c type.c ch7mon.c label.c eval.c \
        switch.c conversion.c util.c \
        blocks.c dataflow.c Version.c
# Objects of hand-written C files
COBJ =	main.o idf.o declarator.o decspecs.o struct.o \
	expr.o ch7.o ch7bin.o cstoper.o arith.o \
	asm.o code.o dumpidf.o error.o field.o\
	tokenname.o LLlex.o LLmessage.o \
	input.o domacro.o replace.o init.o options.o \
	scan.o skip.o stack.o type.o ch7mon.o label.o eval.o \
	switch.o conversion.o util.o \
	blocks.o dataflow.o Version.o

# Objects of other generated C files
GCSRC = char.c symbol2str.c next.c
GOBJ =	char.o symbol2str.o next.o

# generated source files
GSRC =	char.c symbol2str.c next.c \
	code.h declar.h decspecs.h def.h expr.h field.h  estack.h \
	idf.h macro.h stack.h stmt.h struct.h switch.h type.h util.h

# .h files generated by `make hfiles'; PLEASE KEEP THIS UP-TO-DATE!
GHSRC = botch_free.h dataflow.h debug.h density.h errout.h \
	idfsize.h ifdepth.h inputtype.h inumlength.h lapbuf.h \
	nobitfield.h nofloat.h nopp.h noRoption.h nocross.h \
	nparams.h numsize.h parbufsize.h pathlength.h \
	strsize.h target_sizes.h textsize.h use_tmp.h spec_arith.h static.h \
	reg_count.h

# Other generated files, for 'make clean' only
GENERATED = tab tokenfile.g Lpars.h LLfiles LL.output lint.out \
	print Xref lxref hfiles cfiles $(GLCSRC)

# include files containing ALLOCDEF specifications
NEXTFILES = code.str declar.str decspecs.str def.str expr.str field.str \
	estack.str util.str \
	idf.str macro.str stack.str stmt.str struct.str switch.str type.str

.SUFFIXES: .str .h
.str.h:
	./make.allocd <$*.str >$*.h

all:	cc

cc:
	make "EMHOME="$(EMHOME) "CC=$(CC)" hfiles
	make "EMHOME="$(EMHOME) "CC=$(CC)" LLfiles
	make "EMHOME="$(EMHOME) "CC=$(CC)" main

cem:	cem.c
	$(CC) -O cem.c $(SYSLIB) -o cem

lint.cem: cem.c
	$(LINT) -bx cem.c

hfiles: ./make.hfiles Parameters
	./make.hfiles Parameters
	@touch hfiles

LLfiles: $(LSRC)
	$(GEN) $(GENOPTIONS) $(LSRC)
	@touch LLfiles

tokenfile.g:	tokenname.c make.tokfile
	<tokenname.c ./make.tokfile >tokenfile.g

symbol2str.c:	tokenname.c make.tokcase
	<tokenname.c ./make.tokcase >symbol2str.c

char.c:	tab char.tab
	tab -fchar.tab >char.c

next.c:	make.next $(NEXTFILES)
	./make.next $(NEXTFILES) >next.c

code.h:		make.allocd
declar.h:	make.allocd
decspecs.h:	make.allocd
def.h:		make.allocd
estack.h:	make.allocd
expr.h:		make.allocd
field.h:	make.allocd
idf.h:		make.allocd
macro.h:	make.allocd
stack.h:	make.allocd
stmt.h:		make.allocd
struct.h:	make.allocd
switch.h:	make.allocd
type.h:		make.allocd
util.h:		make.allocd

# Objects needed for 'main'
OBJ =	$(COBJ) $(LOBJ) $(GOBJ)
SRC =	$(CSRC) $(LCSRC) $(GCSRC)

main:	$(OBJ) Makefile
	$(CC) $(COPTIONS) $(LFLAGS) $(OBJ) $(LIBS) -o main 
	size main

emain:	$(OBJ) Makefile
	$(CC) $(COPTIONS) $(LFLAGS) $(OBJ) $(ELIBS) -o emain 
	size emain

cfiles: hfiles LLfiles $(GSRC)
	@touch cfiles

install: main cem
	cp main $(CEMCOM)
	cp cem $(DRIVER)

print:	files
	pr `cat files` > print

tags:	cfiles
	ctags $(SRC)

shar:	files
	shar `cat files`

listcfiles:
	@echo $(SRC)

listobjects:
	@echo $(OBJ)

depend:	cfiles
	sed '/^#AUTOAUTO/,$$d' Makefile >Makefile.new
	echo '#AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO' >>Makefile.new
	$(MKDEP) $(SRC) | sed 's/\.c:/.o:/' >>Makefile.new
	mv Makefile Makefile.old
	mv Makefile.new Makefile
	
xref:
	ctags -x `grep "\.[ch]" files`|sed "s/).*/)/">Xref
	
lxref:
	lxref $(OBJ) -lc >lxref

lint:	lint.main lint.cem lint.tab

lint.main: cfiles
	$(LINT) -bx $(CDEFS) $(SRC) $(LINTLIBS) >lint.out

cchk:
	cchk $(SRC)

clean:
	rm -f $(LCSRC) $(OBJ) $(GENERATED) $(GSRC) $(GHSRC)

tab:
	$(CC) tab.c -o tab

lint.tab:
	$(LINT) -abx tab.c

sim:	cfiles
	$(SIM) $(SIMFLAGS) $(CSRC) $(GSRC) $(LSRC)

#AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO
main.o: LLlex.h
main.o: Lpars.h
main.o: align.h
main.o: arith.h
main.o: debug.h
main.o: declar.h
main.o: file_info.h
main.o: idf.h
main.o: input.h
main.o: inputtype.h
main.o: level.h
main.o: noRoption.h
main.o: nobitfield.h
main.o: nocross.h
main.o: nofloat.h
main.o: nopp.h
main.o: sizes.h
main.o: spec_arith.h
main.o: specials.h
main.o: target_sizes.h
main.o: tokenname.h
main.o: type.h
main.o: use_tmp.h
idf.o: LLlex.h
idf.o: Lpars.h
idf.o: align.h
idf.o: arith.h
idf.o: assert.h
idf.o: botch_free.h
idf.o: debug.h
idf.o: declar.h
idf.o: decspecs.h
idf.o: def.h
idf.o: file_info.h
idf.o: idf.h
idf.o: idfsize.h
idf.o: label.h
idf.o: level.h
idf.o: noRoption.h
idf.o: nobitfield.h
idf.o: nocross.h
idf.o: nofloat.h
idf.o: nopp.h
idf.o: sizes.h
idf.o: spec_arith.h
idf.o: specials.h
idf.o: stack.h
idf.o: struct.h
idf.o: target_sizes.h
idf.o: type.h
declarator.o: Lpars.h
declarator.o: arith.h
declarator.o: botch_free.h
declarator.o: declar.h
declarator.o: expr.h
declarator.o: idf.h
declarator.o: label.h
declarator.o: nobitfield.h
declarator.o: nocross.h
declarator.o: nofloat.h
declarator.o: nopp.h
declarator.o: sizes.h
declarator.o: spec_arith.h
declarator.o: target_sizes.h
declarator.o: type.h
decspecs.o: Lpars.h
decspecs.o: arith.h
decspecs.o: decspecs.h
decspecs.o: def.h
decspecs.o: level.h
decspecs.o: noRoption.h
decspecs.o: nobitfield.h
decspecs.o: nofloat.h
decspecs.o: spec_arith.h
decspecs.o: type.h
struct.o: LLlex.h
struct.o: Lpars.h
struct.o: align.h
struct.o: arith.h
struct.o: assert.h
struct.o: botch_free.h
struct.o: debug.h
struct.o: def.h
struct.o: field.h
struct.o: file_info.h
struct.o: idf.h
struct.o: level.h
struct.o: noRoption.h
struct.o: nobitfield.h
struct.o: nocross.h
struct.o: nofloat.h
struct.o: nopp.h
struct.o: sizes.h
struct.o: spec_arith.h
struct.o: stack.h
struct.o: struct.h
struct.o: target_sizes.h
struct.o: type.h
expr.o: LLlex.h
expr.o: Lpars.h
expr.o: arith.h
expr.o: botch_free.h
expr.o: declar.h
expr.o: decspecs.h
expr.o: def.h
expr.o: expr.h
expr.o: file_info.h
expr.o: idf.h
expr.o: label.h
expr.o: level.h
expr.o: noRoption.h
expr.o: nobitfield.h
expr.o: nocross.h
expr.o: nofloat.h
expr.o: nopp.h
expr.o: sizes.h
expr.o: spec_arith.h
expr.o: target_sizes.h
expr.o: type.h
ch7.o: Lpars.h
ch7.o: arith.h
ch7.o: assert.h
ch7.o: debug.h
ch7.o: def.h
ch7.o: expr.h
ch7.o: idf.h
ch7.o: label.h
ch7.o: nobitfield.h
ch7.o: nofloat.h
ch7.o: nopp.h
ch7.o: spec_arith.h
ch7.o: struct.h
ch7.o: type.h
ch7bin.o: Lpars.h
ch7bin.o: arith.h
ch7bin.o: botch_free.h
ch7bin.o: expr.h
ch7bin.o: idf.h
ch7bin.o: label.h
ch7bin.o: noRoption.h
ch7bin.o: nobitfield.h
ch7bin.o: nofloat.h
ch7bin.o: nopp.h
ch7bin.o: spec_arith.h
ch7bin.o: struct.h
ch7bin.o: type.h
cstoper.o: Lpars.h
cstoper.o: arith.h
cstoper.o: assert.h
cstoper.o: debug.h
cstoper.o: expr.h
cstoper.o: idf.h
cstoper.o: label.h
cstoper.o: nobitfield.h
cstoper.o: nocross.h
cstoper.o: nofloat.h
cstoper.o: nopp.h
cstoper.o: sizes.h
cstoper.o: spec_arith.h
cstoper.o: target_sizes.h
cstoper.o: type.h
arith.o: Lpars.h
arith.o: arith.h
arith.o: botch_free.h
arith.o: expr.h
arith.o: field.h
arith.o: idf.h
arith.o: label.h
arith.o: mes.h
arith.o: noRoption.h
arith.o: nobitfield.h
arith.o: nofloat.h
arith.o: nopp.h
arith.o: spec_arith.h
arith.o: type.h
code.o: LLlex.h
code.o: Lpars.h
code.o: align.h
code.o: arith.h
code.o: assert.h
code.o: atw.h
code.o: botch_free.h
code.o: code.h
code.o: dataflow.h
code.o: debug.h
code.o: declar.h
code.o: decspecs.h
code.o: def.h
code.o: expr.h
code.o: file_info.h
code.o: idf.h
code.o: label.h
code.o: level.h
code.o: mes.h
code.o: noRoption.h
code.o: nobitfield.h
code.o: nocross.h
code.o: nofloat.h
code.o: nopp.h
code.o: sizes.h
code.o: spec_arith.h
code.o: specials.h
code.o: stack.h
code.o: stmt.h
code.o: target_sizes.h
code.o: type.h
code.o: use_tmp.h
dumpidf.o: Lpars.h
dumpidf.o: arith.h
dumpidf.o: debug.h
dumpidf.o: def.h
dumpidf.o: expr.h
dumpidf.o: field.h
dumpidf.o: idf.h
dumpidf.o: label.h
dumpidf.o: nobitfield.h
dumpidf.o: nofloat.h
dumpidf.o: nopp.h
dumpidf.o: spec_arith.h
dumpidf.o: stack.h
dumpidf.o: static.h
dumpidf.o: struct.h
dumpidf.o: type.h
error.o: LLlex.h
error.o: arith.h
error.o: debug.h
error.o: errout.h
error.o: expr.h
error.o: file_info.h
error.o: label.h
error.o: nofloat.h
error.o: nopp.h
error.o: spec_arith.h
error.o: tokenname.h
field.o: Lpars.h
field.o: align.h
field.o: arith.h
field.o: assert.h
field.o: code.h
field.o: debug.h
field.o: expr.h
field.o: field.h
field.o: idf.h
field.o: label.h
field.o: nobitfield.h
field.o: nocross.h
field.o: nofloat.h
field.o: nopp.h
field.o: sizes.h
field.o: spec_arith.h
field.o: target_sizes.h
field.o: type.h
tokenname.o: LLlex.h
tokenname.o: Lpars.h
tokenname.o: arith.h
tokenname.o: file_info.h
tokenname.o: idf.h
tokenname.o: nofloat.h
tokenname.o: nopp.h
tokenname.o: spec_arith.h
tokenname.o: tokenname.h
LLlex.o: LLlex.h
LLlex.o: Lpars.h
LLlex.o: arith.h
LLlex.o: assert.h
LLlex.o: class.h
LLlex.o: debug.h
LLlex.o: def.h
LLlex.o: file_info.h
LLlex.o: idf.h
LLlex.o: idfsize.h
LLlex.o: input.h
LLlex.o: nocross.h
LLlex.o: nofloat.h
LLlex.o: nopp.h
LLlex.o: numsize.h
LLlex.o: sizes.h
LLlex.o: spec_arith.h
LLlex.o: strsize.h
LLlex.o: target_sizes.h
LLmessage.o: LLlex.h
LLmessage.o: Lpars.h
LLmessage.o: arith.h
LLmessage.o: file_info.h
LLmessage.o: idf.h
LLmessage.o: nofloat.h
LLmessage.o: nopp.h
LLmessage.o: spec_arith.h
input.o: file_info.h
input.o: input.h
input.o: inputtype.h
input.o: nopp.h
domacro.o: LLlex.h
domacro.o: Lpars.h
domacro.o: arith.h
domacro.o: assert.h
domacro.o: botch_free.h
domacro.o: class.h
domacro.o: debug.h
domacro.o: file_info.h
domacro.o: idf.h
domacro.o: idfsize.h
domacro.o: ifdepth.h
domacro.o: input.h
domacro.o: interface.h
domacro.o: macro.h
domacro.o: nofloat.h
domacro.o: nopp.h
domacro.o: nparams.h
domacro.o: parbufsize.h
domacro.o: spec_arith.h
domacro.o: textsize.h
replace.o: LLlex.h
replace.o: arith.h
replace.o: assert.h
replace.o: class.h
replace.o: debug.h
replace.o: file_info.h
replace.o: idf.h
replace.o: input.h
replace.o: interface.h
replace.o: macro.h
replace.o: nofloat.h
replace.o: nopp.h
replace.o: pathlength.h
replace.o: spec_arith.h
replace.o: static.h
replace.o: strsize.h
init.o: class.h
init.o: idf.h
init.o: interface.h
init.o: macro.h
init.o: nopp.h
options.o: align.h
options.o: arith.h
options.o: botch_free.h
options.o: class.h
options.o: dataflow.h
options.o: idf.h
options.o: idfsize.h
options.o: macro.h
options.o: noRoption.h
options.o: nobitfield.h
options.o: nocross.h
options.o: nofloat.h
options.o: nopp.h
options.o: sizes.h
options.o: spec_arith.h
options.o: target_sizes.h
options.o: use_tmp.h
scan.o: class.h
scan.o: idf.h
scan.o: input.h
scan.o: interface.h
scan.o: lapbuf.h
scan.o: macro.h
scan.o: nopp.h
scan.o: nparams.h
skip.o: LLlex.h
skip.o: arith.h
skip.o: class.h
skip.o: file_info.h
skip.o: input.h
skip.o: interface.h
skip.o: nofloat.h
skip.o: nopp.h
skip.o: spec_arith.h
stack.o: Lpars.h
stack.o: arith.h
stack.o: botch_free.h
stack.o: debug.h
stack.o: def.h
stack.o: idf.h
stack.o: level.h
stack.o: mes.h
stack.o: noRoption.h
stack.o: nobitfield.h
stack.o: nofloat.h
stack.o: nopp.h
stack.o: spec_arith.h
stack.o: stack.h
stack.o: struct.h
stack.o: type.h
type.o: Lpars.h
type.o: align.h
type.o: arith.h
type.o: botch_free.h
type.o: def.h
type.o: idf.h
type.o: nobitfield.h
type.o: nocross.h
type.o: nofloat.h
type.o: nopp.h
type.o: sizes.h
type.o: spec_arith.h
type.o: target_sizes.h
type.o: type.h
ch7mon.o: Lpars.h
ch7mon.o: arith.h
ch7mon.o: botch_free.h
ch7mon.o: def.h
ch7mon.o: expr.h
ch7mon.o: idf.h
ch7mon.o: label.h
ch7mon.o: nobitfield.h
ch7mon.o: nofloat.h
ch7mon.o: nopp.h
ch7mon.o: spec_arith.h
ch7mon.o: type.h
label.o: Lpars.h
label.o: arith.h
label.o: def.h
label.o: idf.h
label.o: label.h
label.o: level.h
label.o: noRoption.h
label.o: nobitfield.h
label.o: nofloat.h
label.o: nopp.h
label.o: spec_arith.h
label.o: type.h
eval.o: Lpars.h
eval.o: align.h
eval.o: arith.h
eval.o: assert.h
eval.o: atw.h
eval.o: code.h
eval.o: dataflow.h
eval.o: debug.h
eval.o: def.h
eval.o: expr.h
eval.o: idf.h
eval.o: label.h
eval.o: level.h
eval.o: mes.h
eval.o: nobitfield.h
eval.o: nocross.h
eval.o: nofloat.h
eval.o: nopp.h
eval.o: sizes.h
eval.o: spec_arith.h
eval.o: stack.h
eval.o: target_sizes.h
eval.o: type.h
switch.o: Lpars.h
switch.o: arith.h
switch.o: assert.h
switch.o: botch_free.h
switch.o: code.h
switch.o: debug.h
switch.o: density.h
switch.o: expr.h
switch.o: idf.h
switch.o: label.h
switch.o: noRoption.h
switch.o: nobitfield.h
switch.o: nofloat.h
switch.o: nopp.h
switch.o: spec_arith.h
switch.o: switch.h
switch.o: type.h
conversion.o: Lpars.h
conversion.o: arith.h
conversion.o: nobitfield.h
conversion.o: nocross.h
conversion.o: nofloat.h
conversion.o: sizes.h
conversion.o: spec_arith.h
conversion.o: target_sizes.h
conversion.o: type.h
util.o: align.h
util.o: nocross.h
util.o: nofloat.h
util.o: regcount.h
util.o: sizes.h
util.o: stack.h
util.o: target_sizes.h
util.o: use_tmp.h
util.o: util.h
blocks.o: align.h
blocks.o: arith.h
blocks.o: atw.h
blocks.o: label.h
blocks.o: nocross.h
blocks.o: nofloat.h
blocks.o: sizes.h
blocks.o: spec_arith.h
blocks.o: stack.h
blocks.o: target_sizes.h
dataflow.o: dataflow.h
char.o: class.h
symbol2str.o: Lpars.h
