# Makefile for the INTERCAL compiler

# Set BINDIR, INCDIR, LIBDIR to the locations where you want "make install"
# to install the executable, include files, and library for the compiler.
# The compiler will look there for the stuff it needs when you compile
# INTERCAL programs.  INCDIR and LIBDIR can be this directory if you don't
# want to "make install", e.g., if you don't trust makefiles moving stuff
# all over creation behind your back.


DVMT=$(PROG_USE)

BINDIR = $(DVMT)
INCDIR = $(DVMT)include_
LIBDIR = $(DVMT)lib_

YACC = bison -y -d
YDEBUG = -v
SYSTYPE = -DATT
#DEBUG  = -g -DDEBUG
CFLAGS = -Qwarn=1 -I. $(SYSTYPE) -O $(DEBUG) -DICKINCLUDEDIR="$(INCDIR)" \
        -DICKLIBDIR="$(LIBDIR)" -DYYDEBUG
LDFLAGS = -bufp200K

CSOURCES = ick_y lexer_l feh_c lose_c fiddle_c perpetrate_c
ISOURCES = cesspool_c arrgghh_c ick-wrap_c
HEADERS = ick_h lose_h sizes_h
SOURCES = $(CSOURCES) $(ISOURCES) $(HEADERS)

all: ick libick_a

ick: ick_o lexer_o feh_o lose_o fiddle_o perpetrate_o
        $(CC) perpetrate_o ick_o lexer_o feh_o lose_o fiddle_o $(LDFLAGS) -o ick


ick_o: ick_c ick_h lose_h sizes_h
lexer_o: lexer_c y_tab_h ick_h
feh_o: feh_c y_tab_h ick_h lose_h sizes_h
perpetrate_o: perpetrate_c y_tab_h ick_h lose_h
cesspool_o: cesspool_c cesspool_h lose_h sizes_h
lose_o: lose_h
fiddle_o: sizes_h

libick_a: cesspool_o lose_o fiddle_o arrgghh_o slblist
        slb -crvk -mslblist libick_a
        rm -f wlist tlist slblist_tmp

wlist: slblist
        @slb -v -Wwlist -mslblist

ylist: slblist
        @slb -v -Yylist -mslblist

slblist:  cesspool_o lose_o fiddle_o arrgghh_o
        @slb -v -Lslblist_tmp cesspool_o lose_o fiddle_o arrgghh_o
        tsort slblist_tmp > slblist
        rm -f libick_a

install: all remove
        cp ick $(BINDIR)
        cp lose_h cesspool_h $(INCDIR)
        cp ick-wrap_c $(INCDIR)ick-wrap_c
        cp libick_a $(LIBDIR)

clean:
        rm -f ick *_o libick_a slblist tlist wlist slblist_tmp

remove:
        rm -f $(BINDIR)ick $(INCDIR)lose_h $(INCDIR)cesspool_h \
              $(INCDIR)ick-wrap_c $(LIBDIR)libick_a
