#### Makefile for Lily

CC = g++

LILYLIB =	liblily.a
LILYOBJS =	multarg.o read.o integer.o real.o function.o \
			fctmapvh.o fctmap.o fcthash.o symbol.o cons.o object.o friend.o

all: examples

examples:	match fchain interpreter testlily
testmatch: match
		match < match.dat
testfchain: fchain
		fchain < fchain.dat

match: mnmatch.o match.o $(LILYLIB)
		$(CC) mnmatch.o match.o $(LDFLAGS) $(LILYLIB) $(LIBS) -o $@

fchain: mnfchain.o fchain.o match.o $(LILYLIB)
		$(CC) mnfchain.o fchain.o match.o $(LDFLAGS) $(LILYLIB) $(LIBS) -o $@

interpreter: mninterp.o interp.o $(LILYLIB)
		$(CC) mninterp.o interp.o $(LDFLAGS) $(LILYLIB) $(LIBS) -o $@

testlily: testlily.o $(LILYLIB)
		$(CC) testlily.o $(LDFLAGS) $(LILYLIB) $(LIBS) -o $@

$(LILYLIB):	$(LILYOBJS)
			$(AR) r $(LILYLIB) $(LILYOBJS)

clean:
			rm -f *.o *.a *.tar *.gz match fchain interpreter testlily 

DISTFILES = *.c *.h *.dat lily.txt Makefile README COPYING*

# To make lily distribution (../lily-0.1.tar.gz):
# 1) make clean
# 2) cp Makefile ..
# 3) cd ..
# 4) rm lily-0.1.tar.gz
# 5) make lily-0.1.tar.gz

lily-0.1.tar.gz:
	tar cvf lily-0.1.tar lily-0.1
	gzip lily-0.1.tar
	gunzip -c lily-0.1.tar|tar tvf -

backup:
	rm -f *.tar *.gz
	make lily.tar
	gzip lily.tar
	gunzip -c lily.tar|tar tvf -

lily.tar:
	tar cvf lily.tar $(DISTFILES)
