# Makefile for Alan interpreter to be built with Glk for Linux (using gcc)

# OS-specific definitions
OSDEFS = -D__unix__ -DUSE_READLINE -DHAVE_ANSI
#OSDEFS = -D__unix__


# -- Glk definitions. Comment all of these out to disable Glk.
#GLKPREFIX = /usr/local
#GLKPREFIX = ../../WindowsGLK
#GLKINCLUDEDIR = $(GLKPREFIX)/Include
#GLKLIBDIR = -L$(GLKPREFIX)/lib
#GLK = -DHAVE_GLK
#GLKLIB = -lglkterm -lcurses
#GLKLIB = $(GLKPREFIX)/Glk.lib
#GLKSRCS = glkstart.c glkio.c


# Define this to make interpreter log each crc calculation step
#CRCLOG = -DCRCLOG

# -- Where do you want to put it?
#
INSTALLDIR = /usr/local/bin

###  Do not edit below this line  ### 

TARGET = arun

# Define the program name
PROGNAME=-DPROGNAME=\"$(TARGET)\"

ARUNOPTS = $(CRCLOG) $(PROGNAME) $(GLK)

#CC = gcc
CFLAGS = -g -Wall -funsigned-char -I$(GLKINCLUDEDIR) $(ARUNOPTS) $(OSDEFS)

LINK = gcc
LINKFLAGS = -g $(ARUNOPTS)
LIBS = $(GLKLIB) $(LINKLIBS)

INSTALL = install
INSTFLAGS = -g 0 -o 0 -s

#--------------------------------------------------------------------
# Include common source list
include sources.mk


#--------------------------------------------------------------------
# Main targets
all: $(TARGET)

arun : $(ARUNOBJECTS)
	$(LINK) -o $(TARGET) $(ARUNOBJECTS) $(LINKFLAGS) $(LIBS)

glkarun : $(ARUNOBJECTS) $(GLKOBJECTS)
	$(LINK) -o glkarun $(ARUNOBJECTS) $(GLKOBJECTS) $(LINKFLAGS) $(LIBS)

termarun : $(TERMARUNOBJECTS)
	$(LINK) -o $(TARGET) $(TERMARUNOBJECTS) $(LINKFLAGS) $(LIBS)

dumpacd: dumpacd.c reverse.o ../compiler/spa.c acode.h sysdep.c
	$(LINK) -o dumpacd $(LDFLAGS) dumpacd.o reverse.o spa.o

install: $(TARGET)
	$(INSTALL) $(INSTFLAGS) $(TARGET) $(INSTALLDIR)
#	$(INSTALL) $(INSTFLAGS) dumpacd $(INSTALLDIR) 

clean:
	rm -f $(TARGET) dumpacd *.o *~ .arch

#----------------------------------------------------------------------
# unit tests
unit : $(TESTOBJECTS)
	gcc -o unit $(TESTOBJECTS) $(LDFLAGS) $(LIBS)

unitTest: unit
	@./unit


#---<< Glk objects >>---
glkstart.o: glkstart.c glkstart.h glkio.h
glkio.o: glkio.c glkio.h

#---<< GENERATED DEPENDENCIES FOLLOWS >>---
include dependencies.mk

