# Makefile for the lot

# LIBPREFIX is the directory where you want to install the lib,
# HEADERPREFIX is the directory where you want to install the header.
# Both are used with "make install" and "make uninstall", not with the
# simple "make compile"
LIBPREFIX = /usr/lib
HEADERPREFIX = /usr/g++-include

# VGALIB is the full path to Tommy Frandsen's vga.o. You'll want this
# object in this library too, to avoid linker problems. If you don't have
# this object yet, make it or get it.
VGA_O = /usr/src/vgalib/vga.o

# MANDIR is the directory where formatted man pages reside. A "make doc2man" 
# will copy the crude docs to this directory. 
MANDIR = /usr/man/cat2

# LIB is the library as known to this making process.. i.e,
# prior to installation.. don't change this
LIB = libgraph.a
# VER is the current version, don't change this
VER = 1.00

# Here are the making rules:
foo:
	@echo ""
	@echo "Make what? Choose either of:"
	@echo "    make compile   - compiles all, places objects in a library"
	@echo "    make test      - makes testprograms in test/"
	@echo "    make install   - installs library and headers"
	@echo "    make doc2man   - installs crude docs as man pages"
	@echo "    make package   - synonym for compile, install, doc2man"
	@echo "    make clean     - cleans up object files and test progs"
	@echo "    make uninstall - removes installed library and headers"
	@echo "    make dist      - makes distribution files for version $(VER)"
	@echo "Default installation, for \"make install\" is:"
	@echo "    library goes to     : " $(LIBPREFIX)
	@echo "    header file goes to : " $(HEADERPREFIX)
	@echo ""

compile:
	(cd graph; make objects; cd ..)
	(cd gwin; make objects; cd ..)
	(cd gbittext; make objects; cd ..)
	(cd grecwin; make objects; cd ..)
	ar r $(LIB) graph/*.o gwin/*.o gbittext/*.o grecwin/*.o $(VGA_O)
	ar s $(LIB)

test:
	(cd test; make; cd ..)
	
install: $(LIB)
	cp $(LIB) $(LIBPREFIX)
	cp graph.h gwin.h gbittext.h grecwin.h $(HEADERPREFIX)

doc2man:
	cp doc/* $(MANDIR)

package:
	make compile
	make install
	make doc2man

clean:
	rm -f $(LIB)
	(cd graph; make clean; cd ..)
	(cd gwin; make clean; cd ..)
	(cd gbittext; make clean; cd ..)
	(cd grecwin; make clean; cd ..)
	(cd test; make clean; cd ..)

uninstall:
	(cd $(LIBPREFIX) ; rm -f $(LIB)
	(cd $(HEADERPREFIX) ; rm $(HEADER)

dist:
	make clean
	rm -f graph$(VER).zip
	zip -ur graph-$(VER).zip *
	@echo "Distribution files:"
	@echo "    graph-$(VER).zip"
	@echo "    graph.README"
	
