# Change the value of the VM variable to match the name you used
#  when you ran VM generate.  This will help in having multiple
#  different versions of the vm and sources around while testing
#  changes.

slateroot=../../../../..
VM=vm
install-mode=-m 644

include $(slateroot)/Makefile.inc

OBJS=../boot.o ../ansifile.o ../extprim.o directory.o windows-extprim.o file.o main.o ${slateroot}/$(VM).o
LOBJS=../boot.lo ../ansifile.lo ../extprim.lo directory.lo windows-extprim.lo file.lo main.lo ${slateroot}/$(VM).lo

default: all

all: $(VM)

clean:
	-rm -r -f ${slateroot}/.libs ../.libs .libs
	-rm -f $(OBJS) $(LOBJS) ${slateroot}/$(VM) ../includes/slatevm.h

$(VM): $(OBJS)
	$(CC) $(CFLAGS) -o $(slateroot)/$(VM) $(OBJS) $(LIBS)

install: ${slateroot}/$(VM) ${slateroot}/$(VM).h
	install ${slateroot}/$(VM) $(exec_prefix)/$(execname)
	install -d $(lispdir)/
	install $(install-mode) $(slateroot)/etc/slate-mode.el $(lispdir)/
	install $(install-mode) ${slateroot}/$(VM).h $(includedir)/slatevm.h
	install -d ${datadir}/
	install $(install-mode) ${slateroot}/big.image $(datadir)/
	install $(install-mode) ${slateroot}/little.image $(datadir)/

uninstall:
	-rm $(exec_prefix)/$(execname)
	-rm $(lispdir)/slate-mode.el
	-rm $(includedir)/slatevm.h
	-rm $(datadir)

$(OBJS) : ../includes/slatevm.h

../includes/slatevm.h : ${slateroot}/$(VM).h
	$(LN) $< $@

%.o: %.c
	$(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -o $@ -c $<
