#
# Type 'make' with this 'makefile' file in your current directory to compile
# the KPL compiler components.  It will execute the following commands
# as needed, based on file most-recent-update times.
# 

CC=g++

# The "-arch ppc" flag is only needed when compiling for the MAC.
CFLAGS=-g -arch ppc

all:    kpl

#
# For MAC OS-X, the default stack size may be inadequate for the amount of
#   recursion in larger runs of the KPL compiler, since it recurses
#   in proportion to the depth of the abstract syntax tree.  This is the reason
#   for the "-Xlinker -stack_size -Xlinker MMM -Xlinker -stack_addr -Xlinker NNN"
#   options.  The -Xlinker option passes the next thing through to the linker, so
#   the linker ends up seeing "-stack_size MMM -stack_addr NNN".
# For Sun/SPARC, these options are not needed or allowed, so they must be
#   commented out.
#

kpl:	main.o lexer.o ast.o printAst.o parser.o mapping.o check.o ir.o gen.o
	$(CC) $(CFLAGS) main.o lexer.o ast.o printAst.o parser.o\
            mapping.o check.o ir.o  gen.o -o kpl\
            -Xlinker -stack_size -Xlinker 4000000 -Xlinker -stack_addr -Xlinker c0000000

main.o: main.cc main.h ast.h ir.h
	$(CC) $(CFLAGS) -c main.cc

lexer.o: lexer.cc main.h ast.h
	$(CC) $(CFLAGS) -c lexer.cc

ast.o: ast.cc main.h ast.h
	$(CC) $(CFLAGS) -c ast.cc

printAst.o: printAst.cc main.h ast.h
	$(CC) $(CFLAGS) -c printAst.cc

parser.o: parser.cc main.h ast.h
	$(CC) $(CFLAGS) -c parser.cc

mapping.o: mapping.cc main.h ast.h
	$(CC) $(CFLAGS) -c mapping.cc

check.o: check.cc main.h ast.h
	$(CC) $(CFLAGS) -c check.cc

ir.o: ir.cc main.h ast.h ir.h
	$(CC) $(CFLAGS) -c ir.cc

gen.o: gen.cc main.h ast.h ir.h
	$(CC) $(CFLAGS) -c gen.cc
