#
# Makefile to make the eag compiler and environment
#
# TOP = /usr/local/eag
TOP = $(HOME)/eag

# where go the include files and the predefines file 
# IDIR = /usr/local/include/eag
IDIR = $(TOP)/include

# where go the libraries
# LDIR = /usr/local/lib/eag
LDIR = $(TOP)/lib

# where goes the binary
# BDIR = /usr/local/bin
BDIR = $(TOP)/bin

# location of X11 tree
# X11TREE = /usr/local/X11
X11TREE = /usr/local/X11R6

# location of X11 include files
X11IDIR = $(X11TREE)/include

# location of X11 lib files
X11LDIR = $(X11TREE)/lib

# which compiler
CC = gcc

# default CFLAGS
# DCFL = '-g'
DCFL = '-O -Wall'

default: install

help:
	@echo "Possible make targets:"
	@echo "all	Create local libraries and program."
	@echo "install	Build and install libraries and program."
	@echo "clean	Free disk space."
	@echo "dist	Build a compressed tar file of this software."
	@echo "help	Dump this information."
	@echo "alib	Build and install example user extension."
	@echo "default	install."

install:
	cd libeag; make install LDIR=$(LDIR) IDIR=$(IDIR) DCFL=$(DCFL) CC=$(CC); cd ..
	cd libXedt; make install LDIR=$(LDIR) IDIR=$(IDIR) X11IDIR=$(X11IDIR) DCFL=$(DCFL) CC=$(CC); cd ..
	cd libedt; make install LDIR=$(LDIR) IDIR=$(IDIR) X11IDIR=$(X11IDIR) DCFL=$(DCFL) CC=$(CC); cd ..
	cd gen; make install LDIR=$(LDIR) IDIR=$(IDIR) BDIR=$(BDIR) X11LDIR=$(X11LDIR) DCFL=$(DCFL) CC=$(CC); cd ..

all:
	cd libeag; make all LDIR=$(LDIR) IDIR=$(IDIR) DCFL=$(DCFL) CC=$(CC); cd ..
	cd libXedt; make all LDIR=$(LDIR) IDIR=$(IDIR) X11IDIR=$(X11IDIR) DCFL=$(DCFL) CC=$(CC); cd ..
	cd libedt; make all LDIR=$(LDIR) IDIR=$(IDIR) X11IDIR=$(X11IDIR) DCFL=$(DCFL) CC=$(CC); cd ..
	cd gen; make all LDIR=$(LDIR) IDIR=$(IDIR) BDIR=$(BDIR) X11LDIR=$(X11LDIR) DCFL=$(DCFL) CC=$(CC); cd ..

clean:
	cd libeag; make clean; cd ..
	cd libXedt; make clean; cd ..
	cd libedt; make clean; cd ..
	cd gen; make clean; cd ..
	cd libalib; make clean; cd ..

alib:
	cd libalib; make all install LDIR=$(LDIR) IDIR=$(IDIR) DCFL=$(DCFL) CC=$(CC); cd ..

veryclean: clean testclean
	cd bin; rm -rf *; cd ..
	cd lib; rm -rf *; cd ..
	cd include; rm -rf *; cd ..

testclean:
	cd gen; rm -rf *_topdown* *_leftcorner* *_lr* *.rules; cd ..
	cd test; rm -rf *_topdown* *_leftcorner* *_lr* *.rules; cd ..
	cd examples; rm -rf *_topdown* *_leftcorner* *_lr* *.rules; cd ..
	cd ex; rm -rf *_topdown* *_leftcorner* *_lr* *.rules; cd ..
	cd doc; rm -rf *.log *.dvi *.ps; cd ..

dist:	veryclean
	cd ..; tar cvf eag.tar eag/bin eag/lib eag/include \
		eag/libeag eag/libedt eag/libXedt eag/libalib \
		eag/gen eag/examples eag/doc \
		eag/bugs eag/Install eag/Makefile \
		eag/History eag/Warranty eag/Copyright ; \
	gzip -9 eag.tar; cd eag
