#
#  makefile to make the eag library
#

# Name of this library
LIBID = eag
ARLIB = lib$(LIBID).a

# Location of libraries and include files
TOP = $(HOME)/eag

# Destination of library when installing
LDIR = $(TOP)/lib

# Destination of header files when installing
IDIR = $(TOP)/include

# Version number of the library
MAJORVERSION = 1
MINORVERSION = 3

CC = gcc

DCFL = -Wall -O -ansi

CFLAGS = $(DCFL) -I.

SRCS  = textstorage.c \
	stddefs.c \
	trace.c \
	init.c \
	c_interface.c \
	textparsing.c \
	memalloc.c \
	buildtree.c \
	buildaffixgraph.c \
	propagate.c \
	error.c \
	ds.c

HDRS  = textstorage.h \
	nodenrs.h \
	trace.h \
	c_interface.h \
	stddefs.h \
	textparsing.h \
	memalloc.h \
	init.h \
	buildtree.h \
	buildaffixgraph.h \
	propagate.h \
	error.h \
	ds.h \
	export.h

OBJS  =	textstorage.o \
	stddefs.o \
	trace.o \
	textparsing.o \
	memalloc.o \
	c_interface.o \
	init.o \
	buildtree.o \
	buildaffixgraph.o \
	propagate.o \
	error.o \
	ds.o

DEFS  = stddefs.eag

DOC   =

MAKEFILE = Makefile

JUNK = core

DISTFILES = $(SRCS) $(DOC) $(MAKEFILE) $(SKELFILES)

help :
	@echo " Possible make targets:"
	@echo "all              Create local library."
	@echo "clean            Free disk space."
	@echo "distfiles        List distribution files."
	@echo "install          Install relevant files."
	@echo "instlib          Install only updated library."

all: $(ARLIB)

install: instlib $(HDRS)
	cp $(HDRS) $(IDIR)
	cp $(DEFS) $(IDIR)

instlib: $(ARLIB)
	rm -f $(LDIR)/$(ARLIB)
	cp $(ARLIB) $(LDIR)
	ranlib $(LDIR)/$(ARLIB)

clean:
	rm -f $(JUNK) $(OBJS) $(ARLIB) $(TESTPROGS)

distfiles:
	@echo $(DISTFILES) | tr ' ' '\012'

# Non-standard make rules
###
$(ARLIB): $(OBJS)
	ar cru $(ARLIB) $(OBJS)
	ranlib $(ARLIB)

textstorage.o: memalloc.h textstorage.h
memalloc.o: memalloc.h
ds.o: memalloc.h ds.h
error.o: error.h
textparsing.o: textparsing.h memalloc.h ds.h textstorage.h trace.h
buildaffixgraph.o: buildaffixgraph.h ds.h textstorage.h propagate.h
buildtree.o: buildtree.h buildaffixgraph.h ds.h textparsing.h \
		nodenrs.h textstorage.h propagate.h
propagate.o: buildtree.h buildaffixgraph.h propagate.h \
		ds.h trace.h textstorage.h textparsing.h
init.o: init.h ds.h textstorage.h textparsing.h buildaffixgraph.h buildtree.h
trace.o: trace.h ds.h textparsing.h nodenrs.h
c_interface.o: ds.h textparsing.h textstorage.h c_interface.h
stddefs.o: buildtree.h buildaffixgraph.h propagate.h nodenrs.h \
		ds.h stddefs.h textstorage.h textparsing.h
