#
#  makefile to make the eag library
#

# Name of this library
LIBID = alib
ARLIB = lib$(LIBID).a
LINTLIB = llib-l$(LIBID).ln

# 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 = 1

CC = cc

DCFL = -O -Wall -ansi

CFLAGS = $(DCFL) -I$(IDIR) -I.

LINTFLAGS = -DDebug -I$(IDIR)
LINTLIBS = $(LDIR)/llib-leag.ln

SRCS  = alib.c

HDRS  = alib.h

EXTHDRS = $(IDIR)/ds.h \
	  $(IDIR)/memalloc.h \
	  $(IDIR)/buildaffixgraph.h \
	  $(IDIR)/buildtree.h \
	  $(IDIR)/textstorage.h \
	  $(IDIR)/textparsing.h \
	  $(IDIR)/propagate.h \
	  $(IDIR)/nodenrs.h

OBJS  = alib.o

DOC   =

MAKEFILE = Makefile

JUNK = core Version.h testlib testlib.o

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

help :
	@echo " Possible make targets:"
	@echo "all              Create local library."
	@echo "clean            Free disk space."
	@echo "lint             Type check source files."
	@echo "distfiles        List distribution files."
	@echo "install          Install relevant files."
	@echo "instlib          Install only updated library."
	@echo "instlint         Install lint library."
	@echo "test             Run tests."

all: $(ARLIB)

test: 
	@echo "No test set available."

install: instlib $(HDRS) alib.eag
	cp $(HDRS) $(IDIR)
	cp alib.eag $(IDIR)

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

instlint: $(LINTLIB)
	rm -f $(LDIR)/$(LINTLIB)
	cp $(LINTLIB) $(LDIR)

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

lint:
	lint $(LINTFLAGS) $(SRCS) $(LINTLIBS)

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

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

$(LINTLIB): $(SRCS) $(HDRS) $(EXTHDRS)
	lint -C$(LIBID) $(LINTFLAGS) $(SRCS)

alib.o: $(EXTHDRS) alib.h
