#
#  makefile to make the eag library
#

# Name of this library
LIBID = edt
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

# Destination of application defaults
ADIR = $(HOME)/.app-defaults

# location of X11 include files
X11IDIR = /usr/local/X11R6/include

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

CC = gcc

DCFL = -Wall -O -ansi

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

SRCS  = initedit.c \
	templates.c \
	editorparsing.c \
	cpmerge.c \
	tuples.c \
	unparser.c \
	freegraph.c \
	focus.c \
	editmain.c

HDRS  = initedit.h \
	templates.h \
	editorparsing.h \
	cpmerge.h \
	focus.h \
	tuples.h \
	editor.h \
	unparser.h \
	freegraph.h \
	editmain.h

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

OBJS  = initedit.o \
	editor.o \
	editorparsing.o \
	focus.o \
	templates.o \
	cpmerge.o \
	tuples.o \
	unparser.o \
	freegraph.o \
	editmain.o

DOC   =

CLASS = Editor

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) $(CLASS).ad
	cp $(HDRS) $(IDIR)
	cp $(CLASS).ad $(LDIR)/$(CLASS)

install-ad: $(CLASS).ad
	cp $(CLASS).ad $(ADIR)/$(CLASS)

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

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

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)

initedit.o: initedit.h cpmerge.h tuples.h unparser.h focus.h templates.h
cpmerge.o: $(EXTHDRS) cpmerge.h
tuples.o: $(EXTHDRS) tuples.h
unparser.o: $(EXTHDRS) unparser.h editor.h cpmerge.h tuples.h
editor.o: $(EXTHDRS) editor.h
editmain.o: $(EXTHDRS) editmain.h editor.h tuples.h unparser.h templates.h
editorparsing.o: $(EXTHDRS) editorparsing.h freegraph.h focus.h unparser.h
freegraph.o: $(EXTHDRS) freegraph.h
focus.o: $(EXTHDRS) focus.h unparser.h
templates.o: $(EXTHDRS) templates.h
