# File:    Makefile (~bevemyr/KAM/Emulator/Makefile)
# Author:  Johan Bevemyr
# Created: 23 March 1992
# Purpose: Example makefile

CC= gcc#      	# UNIX GNU compiler
YACC= bison#    # The GNU yacc
LEX= flex#	# The GNU lex
LDFLAGS= -lm#    # Math library

######################################################################
#
# OPT is the optimization level to be used with the compiler. 
# Uncomment the desired optimization level for your compiler.
#

#OPT= -fast#		# SUN ansi C
#OPT= -O +Obb1100#	# HP
#OPT= -O#		# SUN
#OPT= -O2#	        # SUN
#OPT= -O3#	        # SUN
#OPT= -O4#		# Apollo domain for example
OPT= -pipe -O4#  	# SUN vanilla C
#OPT= -pipe -O#		# gcc
#OPT= -g -O2#		# gcc
#OPT= -g -O -Wall#      # gcc with warnings
#OPT= -g -Wall#	        # gcc with warnings
#OPT= -g#    		# debug mode (HP & SUN)

######################################################################
#
# OS_TYPE is the type of operation system the target system has. 
# Uncomment the proper one.
#
# HP_UX		Used when compiling for HP 9000/720 
# SUN_BSD	Used when compiling for SUN 
#

OS_TYPE= -DSUN_BSD
#OS_TYPE= -DHP_UX

######################################################################
#
# The following flags are avaliable. Uncomment the desired options
#
# DEBUG         Compile with wamdebugger.
# PROTO		Compiler has prototypes
#

DEBUG=	-DDEBUG
PROTO= -DPROTOTYPES

CFLAGS = $(OPT) $(OS_TYPE) $(DEBUG) $(PROTO)

######################################################################
#
# add your .h files here
#

DEFS=	term.h instrdef.h init.h constants.h config.h builtin.h \
	include.h storage.h database.h atom_table.h inline.h engine.h \
        time.h

######################################################################
#
# add your object files here
#

OBJ=	init.o storage.o database.o  \
	atom_table.o engine.o builtin.o \
	inline.o parser.yy.o parser.tab.o time.o

######################################################################
#
# add your .c files here
#

SRC=	init.c storage.c database.c engine.c builtin.c \
	atom_table.c inline.c parser.y parser.l time.c

######################################################################
#
# An .o file is made from a .c file by compiling it with $(CC) using 
# the flags $(CFLAGS).
# 

.c.o:
	${CC} ${CFLAGS} -c $*.c

engine: objectfiles
	${CC} ${OBJ} ${LDFLAGS} -o engine

$(OBJ): $(DEFS)

objectfiles: $(OBJ)

parser.yy.c: parser.l parser.tab.h
	$(LEX) $(LFLAGS) parser.l 
	mv lex.yy.c parser.yy.c

parser.tab.c parser.tab.h: parser.y 
	$(YACC) $(YFLAGS) -d parser.y

parser.tab.bin: parser.tab.c
	$(CC) $(CFLAGS) -c parser.tab.c

TAGS: 
	etags ${DEFS} ${SRC}

remake: clean engine

clean:
	/bin/rm -f $(OBJ)

realclean: clean
	/bin/rm -f engine
	/bin/rm -f parser.yy.c parser.tab.h parser.tab.c

wipeout: realclean
	/bin/rm -f core TAGS 

