
# Makefile
SHELL = /bin/sh
SRCS = nsobj.c nsref.c utils.c main.c immed.c nsrefarr.c binary.c btree.c \
	array.c frame.c
OBJS = nsobj.o nsref.o utils.o main.o immed.o nsrefarr.o binary.o btree.o \
	array.o frame.o
INCLUDES = config.h nsobj.h nsref.h utils.h nsrefarr.h btree.h btreep.h

CC = gcc
LEX = flex -F
YACC = bison -d 

CFLAGS = -g $(INCLUDE) $(DEFINE)# -Wall

DEFINE =
INCLUDE =
CPP = $(CC) -E $(INCLUDE) $(DEFINE)
LFLAGS =
LIBS = 

all: nscript testlex

testlex: nslex.o btree.o utils.o
	$(CC) -g $(LFLAGS) -o testlex nslex.o btree.o utils.o $(LIBS)

nslex.c: lex.yy.c config.h
	cp lex.yy.c nslex.c

lex.yy.c: nslex.l
	$(LEX) nslex.l

nscript: $(OBJS)
	$(CC) -g $(LFLAGS) -o nscript $(OBJS) $(LIBS)

clean:
	\rm -f \#* *.o core Makefile.bak tmp_make *~ lex.yy.c
	-ln -s /tmp/core ./core

realclean: clean
	\rm testlex nscript

pack:
	-mv nscript.tar.Z /tmp/nscript.tar.Z.bak
	tar cf - . | compress > /tmp/nscript.tar.Z
	-mv /tmp/nscript.tar.Z.bak .
	mv /tmp/nscript.tar.Z .

dep:
	cp Makefile Makefile.bak
	sed '/\#\#\# Dependencies/q' < Makefile > tmp_make
	(for i in *.c; do $(CPP) -MM $$i; done) >> tmp_make
	cp tmp_make Makefile

### Dependencies
binary.o: binary.c config.h nsobj.h nsref.h nsrefarr.h utils.h btree.h
btree.o: btree.c btree.h btreep.h
immed.o: immed.c config.h nsobj.h
main.o: main.c config.h utils.h nsobj.h
nslex.o: nslex.c config.h
nsobj.o: nsobj.c config.h nsobj.h nsref.h nsrefarr.h utils.h
nsref.o: nsref.c config.h nsobj.h nsref.h nsrefarr.h utils.h
nsrefarr.o: nsrefarr.c config.h nsobj.h nsref.h nsrefarr.h
utils.o: utils.c config.h utils.h /usr/include/ctype.h
