LEX = flex
YACC = bison

YFLAGS = -d

MAKEFILE = Makefile

ifeq ($(MINGW),foo)
CC = /usr/local/i386-mingw32-3.4.5/bin/i386-mingw32-gcc
CXX = /usr/local/i386-mingw32-3.4.5/bin/i386-mingw32-g++
AR = /usr/local/i386-mingw32-3.4.5/bin/i386-mingw32-ar
RANLIB = /usr/local/i386-mingw32-3.4.5/bin/i386-mingw32-ranlib
else
CC = gcc
RANLIB=ranlib
AR=ar
endif
CFLAGS = -g  -I$(HOME)/include
LIBCFLAGS = -c -O3 -I$(HOME)/include

.PHONY = all shar clean tags

LIBS = -lfl

TARGETS = all gbread


SRCS =  gb.y sfile.c seqreader.l 
OBJS =  seqreader.o gb.tab.o sfile.o

%.c: %.y

seqreader.o: gb.tab.h

sfile.o: gb.tab.h

%.tab.c %.tab.h: %.y
	$(YACC) $(YFLAGS) $<

all: libsfile.a

gbread: gbread.o libsfile.a
	$(CC) -o $@ $(CFLAGS) -L. -lsfile gbread.o $(OBJS) $(LIBS)

libsfile.a:  $(OBJS)
	$(CC) $(LIBCFLAGS) $(OBJS)
	$(AR) rcv $@ $(OBJS)
	$(RANLIB) $@

clean:
	$(RM) $(OBJS) $(PROG) $(PROG).shar tags Makefile.bak 
	$(RM) gb.output gb.tab.c seqreader.c gb.tab.h
	$(RM) gbread gbread.o libsfile.a

shar:
	shar Makefile $(INCS) $(SRCS) > $(PROG).shar

tags: $(SRCS)
	etags $(SRCS)

depend:
	makedepend -- $(CFLAGS) -- $(SRCS)

# DO NOT DELETE THIS LINE -- make depend depends on it.
