# @(#) %M% %I%
# graph program
# Makefile created 11 July 1989 - Phil Farrell - Stanford Earth Sciences.
#
# This makes the Stanford Earth Sciences "graph" program for 2-d plotting.
# It uses the vplot.h definition file from the vplot source, Kroeger's
# GKS library, and the getpar functions (libloc.a).
# If vplot, libgks, and libloc are installed on your system, use the 
# following macro definitions
CFLAGS = -O -I/usr/local/include
LIBGKS = -lgks
LIBLOC = -lloc
# If you have created vplot and libgks in parallel directories, but 
# have not installed them, use these macro definitions:
#CFLAGS = -g -I../libgks/include -I../vplot/filters/include
#LIBGKS = ../libgks/libgks.a
#LIBLOC = ../vplot/filters/loclib/loclib.a

# Parameters for installation
OWNER=root
GROUP=graphics
# Location where program will be installed
BIN = /usr/local/bin
# If you want to rename the Berkeley "graph" program and its manual page
# in order to avoid conflict with this program, then set the BSDRENAME
# flag to the new name (e.g., "ucbgraph"), and set "BSDLOC" to the location
# of the BSD graph program (usually /usr/bin).  You must have write 
# permission in that directory and in /usr/man for this rename to take effect.
# This rename action is only done the first time "make install" is 
# executed, so multiple "installs" can be done without problems if graph
# is modified (a file BSDmovedflag is created to indicate this has been done).
BSDRENAME=ucbgraph
BSDLOC=/usr/bin

# Object files for graph proper.  The file err.o is also needed to
# override the non-standard version in the the vplot "loclib.a", if you
# are using that library for the "getpar" functions.
# If you use the standard libloc.a, reset ERR to a null string
#ERR = err.o
ERR =
OBJS = 	bufcat.o doaxes.o dolabels.o domessages.o doplots.o graphmain.o \
	miscsubs.o readdata.o scaledata.o storemesg.o readline.o

all: graph

# err.o must be loaded after LIBLOC, which calls for it if vplot 
# version is used.
graph: ${OBJS} $(ERR)
	cc -o graph ${CFLAGS} ${OBJS} ${LIBGKS} ${LIBLOC} $(ERR) -lm

install: graph
	-if test ! -f BSDmovedflag; then make installonce; fi
	install -c -s -o $(OWNER) -g $(GROUP) -m 755 graph $(BIN)
	addlocalman graph.1

installonce:
	-if test "$(BSDRENAME)" != ""; then \
		mv $(BSDLOC)/graph $(BSDLOC)/$(BSDRENAME); \
		mv /usr/man/man1/graph.1g /usr/man/man1/$(BSDRENAME).1g;\
		fi
	touch BSDmovedflag

clean:
	-rm *.o a.out
