# Unix Makefile for JACL Adventure Creation Language

CC = gcc
CFLAGS = -O2 -w -Wall

all : jacl garjacl bjorb

bjorb : bjorb.c
	$(CC) $(CFLAGS) -o bjorb bjorb.c

jacl : libglkterm.a jacl.c jacl.h glk_startup.c findroute.c interpreter.c loader.c glk_saver.c logging.c parser.c display.c utils.c jpp.c resolvers.c errors.c encapsulate.c types.h
	$(CC) $(CFLAGS) -o jacl jacl.c glk_startup.c findroute.c interpreter.c loader.c glk_saver.c logging.c parser.c display.c utils.c jpp.c resolvers.c errors.c encapsulate.c -Iglkterm -Lglkterm -lglkterm -lm -lncurses;
	
cjacl : libcheapglk.a jacl.c jacl.h glk_startup.c findroute.c interpreter.c loader.c glk_saver.c logging.c parser.c display.c utils.c jpp.c resolvers.c errors.c encapsulate.c types.h
	$(CC) $(CFLAGS) -o cjacl jacl.c glk_startup.c findroute.c interpreter.c loader.c glk_saver.c logging.c parser.c display.c utils.c jpp.c resolvers.c errors.c encapsulate.c -ICheapGlk -LCheapGlk -lm -lcheapglk;
	
garjacl : jacl.c jacl.h glk_startup.c findroute.c interpreter.c loader.c glk_saver.c Gargoyle/garglk_main.c logging.c parser.c display.c utils.c jpp.c resolvers.c errors.c encapsulate.c types.h
	$(CC) $(CFLAGS) -DGARGLK -o garjacl jacl.c glk_startup.c Gargoyle/garglk_main.c findroute.c interpreter.c loader.c glk_saver.c logging.c parser.c display.c utils.c jpp.c resolvers.c errors.c encapsulate.c -IGargoyle -LGargoyle -lm -lgarglk;

libcheapglk.a :
	cd CheapGlk; make libcheapglk.a

libglkterm.a :
	cd glkterm; make libglkterm.a

install: all
	mv garjacl ../bin
	mv jacl ../bin
	mv bjorb ../bin

clean:
	rm -f *.o
