#
# Makefile for kForth
#
# Copyright (c) 1998--2004 Creative Consulting for Research and Education
# Provided under the terms of the GNU General Public License
#
# Last Revised: 2004-06-20
#
# Possible invocations:
#
#	make		creates dynamically linked release executable
#	make clean	remove all object files belonging to this project
#	make debug	create statically linked debug executable
#	make archive	create a compressed tar file
#
# Notes:
#
#   1. If a debug version is being built, always invoke "make clean" 
#      before "make debug".
#
#
# Default debug option creates a release version of the executable.
# Invoke "make debug" if you want to create an executable
# that contains debugging information for the GNU debugger (gdb).

VERSION = 1.2.6
DEBUG = 

# location of gcc and g++
GCCDIR = /usr/bin

CPP = ${GCCDIR}/g++
CC  = ${GCCDIR}/gcc
OBJS = kforth.o ForthVM.o ForthCompiler.o vm.o vmc.o
LIBS = -lreadline -lncurses

all:	
	make kforth
	cd fast ; make kforth-fast
	mv fast/kforth-fast ./

kforth: ${OBJS} 
	${CPP} -o kforth ${DEBUG} ${OBJS} ${LIBS}

clean:
	- rm -f ${OBJS} kforth kforth-fast
	cd fast ; make clean

archive:
	mkdir kforth-${VERSION}
	mkdir kforth-${VERSION}/fast/
	cp --target-directory=kforth-${VERSION}/ *.s *.h *.c *.cpp\
	   *.4th *.xpm Makefile README
	cp --target-directory=kforth-${VERSION}/fast/ fast/*.s fast/*.h\
	   fast/*.c fast/*.cpp fast/Makefile
	tar -zcvf kforth-pclinux-${VERSION}.tar.gz kforth-${VERSION}
	rm -R kforth-${VERSION}

debug:
	make kforth "DEBUG = -g"

kforth.o: kforth.cpp ForthVM.h ForthCompiler.h
	${CPP} -c ${DEBUG} kforth.cpp

ForthVM.o: ForthVM.cpp ForthVM.h fbc.h ForthCompiler.h
	${CPP} -c ${DEBUG} ForthVM.cpp

ForthCompiler.o: ForthCompiler.cpp ForthCompiler.h fbc.h
	${CPP} -c ${DEBUG} ForthCompiler.cpp

vm.o: vm.s
	as -o vm.o vm.s

vmc.o: vmc.c
	${CC} -c ${DEBUG} vmc.c

# end of makefile

