;#include "mstconfig.h"
;#include "mstpaths.h"


;#ifndef DEFAULT_LIBRARIES
#define DEFAULT_LIBRARIES -lm
;#endif

#ifndef EXTRA_CC_FLAGS
#define EXTRA_CC_FLAGS
#endif


#ifndef OTHER_FILES
#define OTHER_FILES
#endif


#ifndef OBJECTS_SYSTEM
#define OBJECTS_SYSTEM
#endif

#ifndef OBJECTS_MACHINE
#define OBJECTS_MACHINE
#endif


#define HAVE_ALLOCA

MAINTAINER = 'sbb@Eng.sun.com'

CFLAGS_NORMAL   = -g $(EXTRA_CC_FLAGS)
CFLAGS_PROFILE  = -g -pg -DUSE_MONCONTROL $(EXTRA_CC_FLAGS)
CFLAGS_OPTIMIZE = -O2 -DOPTIMIZE $(EXTRA_CC_FLAGS)

;#undef PROFILE
;#undef NORMAL
;#define OPTIMIZE
;
;#ifdef PROFILE
;CFLAGS = $(CFLAGS_PROFILE) $(EXTRA_PACKAGES)
;#else
;#ifdef OPTIMIZE
;CFLAGS = $(CFLAGS_OPTIMIZE) $(EXTRA_PACKAGES)
;#else
;CFLAGS = $(CFLAGS_NORMAL) $(EXTRA_PACKAGES)
;#endif
;#endif
CFLAGS = 

OBJS =  mstmain.o   mstlib.o	mst.tab.o   mstlex.o    mststr.o \
	mstid.o     msttree.o   mstbyte.o   mstinterp.o mstcomp.o \
	mstsym.o    mstdict.o   mstoop.o    mstsave.o   mstcint.o \
	mstsysdep.o mstcallin.o $(USER_OBJS) $(ALLOCA)

SRCS =  mstmain.c   mstlib.c	mst.tab.c   mstlex.c    mststr.c \
	mstid.c	    msttree.c   mstbyte.c   mstinterp.c mstcomp.c \
	mstsym.c    mstdict.c   mstoop.c    mstsave.c   mstcint.c \
	mstsysdep.c mstcallin.c 


LIBS =  $(DEFAULT_LIBRARIES) $(USER_LIBS) $(READLINELIB) $(DLDLIB)


all: mst

mst: $(OBJS)
	$(CC) $(BINDING) -o mst $(CFLAGS) $(OBJS) $(LIBS) -lm

mst.tab.h mst.tab.c: mst.y
	bison -dv mst.y

mstlib.o mstlex.c: mst.tab.h

mstlex.o: mst.tab.h

mstsave.o mstoop.o mstlib.o mstsym.o: mstoop.h

mstlib.o: mst.h
mstlib.o: mstconfig.h
mstlib.o: mst.tab.h
mstlib.o: mstinterp.h
mstlib.o: mstcomp.h
mstlib.o: mstsave.h
mstlib.o: mstsym.h
mstlib.o: mstoop.h
mstlib.o: mstpaths.h
mstlib.o: mstlib.h

mst.tab.o: mst.h
mst.tab.o: mstconfig.h
mst.tab.o: mstsym.h
mst.tab.o: msttree.h
mst.tab.o: mstdict.h
mst.tab.o: mstcomp.h
mst.tab.o: mstinterp.h

mstlex.o: mst.h
mstlex.o: mstconfig.h
mstlex.o: mstlex.h
mstlex.o: mst.tab.h
mstlex.o: mststr.h
mstlex.o: mstid.h
mstlex.o: mstdict.h
mstlex.o: mstcomp.h
mstlex.o: mstinterp.h
mstlex.o: msttree.h
mstlex.o: mstsysdep.h

mststr.o: mststr.h

mstid.o: mststr.h
mstid.o: mstid.h

msttree.o: mst.h
msttree.o: mstconfig.h
msttree.o: mstsym.h
msttree.o: msttree.h

mstbyte.o: mst.h
mstbyte.o: mstconfig.h
mstbyte.o: mstbyte.h

mstinterp.o: mst.h
mstinterp.o: mstconfig.h
mstinterp.o: mstinterp.h
mstinterp.o: mstdict.h
mstinterp.o: mstsym.h
mstinterp.o: mstoop.h
mstinterp.o: mstsave.h
mstinterp.o: mstcomp.h
mstinterp.o: mstcint.h
mstinterp.o: mstsysdep.h

mstcomp.o: mst.h
mstcomp.o: mstconfig.h
mstcomp.o: mstsym.h
mstcomp.o: mstcomp.h
mstcomp.o: mstinterp.h
mstcomp.o: msttree.h
mstcomp.o: mstbyte.h
mstcomp.o: mstdict.h
mstcomp.o: mstoop.h
mstcomp.o: mstinterp.h
mstcomp.o: mstlex.h

mstsym.o: mst.h
mstsym.o: mstconfig.h
mstsym.o: mstsym.h
mstsym.o: mstoop.h
mstsym.o: mstcomp.h
mstsym.o: mstinterp.h
mstsym.o: mstdict.h
mstsym.o: msttree.h

mstdict.o: mst.h
mstdict.o: mstconfig.h
mstdict.o: mstdict.h
mstdict.o: mstoop.h
mstdict.o: mstinterp.h
mstdict.o: mststr.h
mstdict.o: mstsym.h

mstoop.o: mst.h
mstoop.o: mstconfig.h
mstoop.o: mstoop.h
mstoop.o: mstdict.h
mstoop.o: mstsave.h
mstoop.o: mstcomp.h
mstoop.o: mstinterp.h

mstsave.o: mst.h
mstsave.o: mstconfig.h
mstsave.o: mstsave.h
mstsave.o: mstcomp.h
mstsave.o: mstinterp.h
mstsave.o: mstinterp.h
mstsave.o: mstdict.h
mstsave.o: mstsym.h
mstsave.o: mstoop.h
mstsave.o: mstlib.h

mstcint.o: mstcint.c
mstcint.o: mst.h
mstcint.o: mstconfig.h
mstcint.o: mstinterp.h
mstcint.o: mstdict.h
mstcint.o: mstoop.h
mstcint.o: mstsym.h
mstcint.o: mstcallin.h

mstcallin.o: mst.h
mstcallin.o: mstinterp.h
mstcallin.o: mstcallin.h
mstcallin.o: mstdict.h
mstcallin.o: mstsym.h
mstcallin.o: mstoop.h


lint: $(SRCS)
	lint $(SRCS)

lexdebug:
	$(CC) -c $(XCFLAGS) -DLEXDEBUG mstlib.c
	$(MAKE) -f xmakefile mst

profile:
	make CFLAGS='$(CFLAGS) -pg -Dprofiling'

diffs:
	mk_mst_diffs

setup:
	@if [ -f ./orig ] ; then \
		echo "./orig exists, but is not a directory" ; \
		exit 1 ; \
	fi
	rm -rf ./orig
	mkdir ./orig
	tar cbf 20 - `cat mstfiles` | (cd ./orig; tar xbBf 20 -)






