#
# Makefile for Little Smalltalk, version 2
#
CFLAGS = -g

COMMONc = memory.c names.c lex.c parser.c
COMMONo = memory.o names.o lex.o parser.o
PARSEc  = comp.c $(COMMONc) image.c
PARSEo  = comp.o $(COMMONo) image.o
STc     = main.c $(COMMONc) process.c primitive.c interp.c
STo     = main.o $(COMMONo) process.o primitive.o interp.o
classes = basic.st unix.st mult.st munix.st test.st
allfiles = READ_ME Bugs Makefile todo *.ms *.h *.c *.st *.ini

install: stest sunix
	echo "created single process version, see docs for more info"

#
# parse - the object image parser.  
# used to build the initial object image
#
parse: $(PARSEo)
	cc -o parse $(CFLAGS) $(PARSEo)

parseprint:
	pr *.h $(PARSEc) | lpr

parselint:
	lint $(PARSEc)

#
# st - the actual bytecode interpreter
# runs bytecodes from the initial image, or another image
#
st: $(STo)
	cc $(CFLAGS) -o st $(STo) -lm

stlint: 
	lint $(STc)

stprint:
	pr *.h $(STc) | lpr

#
# image - build the initial object image
#
classlpr:
	pr $(classes) | lpr

sunix: parse st
	parse basic.st unix.st
	st - - <script.ini

munix: parse st
	parse basic.st unix.st mult.st munix.st
	st - - <script.ini

stest: parse st
	parse -s basic.st unix.st test.st
	st - - <script.ini
	st <test.ini

mtest: parse st
	parse -s basic.st unix.st mult.st munix.st test.st mtest.st
	st - - <script.ini
	st <test.ini

#
# include file dependencies
#
comp.o: env.h memory.h names.h
image.o: env.h memory.h names.h lex.h
interp.o: env.h memory.h names.h process.h interp.h
lex.o: env.h memory.h lex.h
main.o: env.h memory.h names.h interp.h process.h
memory.o: env.h memory.h
names.o: env.h memory.h names.h
parser.o: env.h memory.h names.h interp.h lex.h
primitive.o: env.h memory.h names.h process.h
process.o: env.h memory.h names.h process.h

#
# distribution bundles
#

tar:
	tar cvf ../smalltalk.v2.tar .
	compress -c ../smalltalk.v2.tar >../smalltalk.v2.tar.Z

pack:
	packmail -o'small.v2' -h'head' $(allfiles)
