#
# $Id: Makefile.cygwin,v 1.9 2005/05/11 08:32:31 olafs Exp $
#

TOP = ../..
include $(TOP)/Makefile.cygwin.include

MACHDEP_HOST	= machdep.dos

all: agfl.exe agflmaint.exe agfl-coder.exe machdep.h
	cp agfl.exe $(TOP)/agfl-binary/bin
	cp agflmaint.exe $(TOP)/agfl-binary/bin
	cp agfl-coder.exe $(TOP)/agfl-binary/bin
	cp machdep.h $(TOP)/agfl-binary/include

clean:
	rm -f scanner.c
	rm -f *.o
	rm -f *.a
	rm -f agfl.exe
	rm -f agflmaint.exe
	rm -f agfl-coder.exe

SUFFIXES = .k3
%.c: %.k3 predef.k3 predef.h cdl3rts.h
	$(CDLC) $(CDLFLAGS) -c $<

cdl3rts.h: $(CDLDIR)/cdl3rts.h
	cp $(CDLDIR)/cdl3rts.h .

predef.h: $(CDLDIR)/predef.h
	cp $(CDLDIR)/predef.h .

predef.k3: $(CDLDIR)/predef.k3
	cp $(CDLDIR)/predef.k3 .

CDL3SRC = instructions.k3 \
          agfl.k3 \
          rule.k3 \
          token.k3 \
          io.k3 \
          id.k3 \
	  affix.k3 \
          set.k3 \
          code.k3 \
          options.k3 \
          transduction.k3 \
	  optimize.k3 \
          properties.k3 \
          parser.k3 \
          list.k3 \
          modules.k3 \
          intermediate.k3 \
          icoptimize.k3 \
          heap.k3 \
          general.k3

CSRC = util.c warshall.c imatrix.c agflpattern.c dfa.c
LSRC = scanner.l
scanner.c: scanner.l
	$(LEX) -oscanner.c scanner.l

agfl.exe: agfl
agfl: gen.o
	$(CC) -o $@ $^

agflmaint.exe: agflmaint
agflmaint: agflmaint.o
	$(CC) -o $@ $^ 

agflmaint.c: gen.c
	echo '#define MAINTAINER_MODE 1' > agflmaint.c
	cat gen.c >>agflmaint.c

agfl-coder.exe: agfl-coder
agfl-coder: $(CDL3SRC:.k3=.o) $(CSRC:.c=.o) $(LSRC:.l=.o)
	$(CC) -o $@ $^ $(CDLLIB) $(ABASELIB) $(LEXICONLIB)

machdep.h: $(MACHDEP_HOST) machdep.common
	cat $(MACHDEP_HOST) machdep.common > $@


