# $Id: Makefile%v 1.1 1993/08/06 05:15:40 woo Exp woo $
#
# GPLOTLIB Makefile for Unix machines
#
# $Log: Makefile%v $
# Revision 1.1  1993/08/06  05:15:40  woo
# Initial revision
#
# Revision 1.11  1993/06/15  17:11:34  jack
# Added Id and Log.
#

# path to gnuplot source
GNUPLOT = /a/woo/src/gwork
INSTALLLIB = /usr/local/lib

# -O if you trust your compiler's optimizer
CC = cc 

# -DRLAB if the library is being generated for RLAB
# -DDEAULTTERN="term" to define a default device
# -DBCOPY if your memcpy() is called bcopy() (a Berkeleyism, right?)
# -DBZERO if you need to use bzero() (another BSD feature) instead of memset()
# -DNOCOPY if you don't have a memcpy() by any name
#CFLAGS = -I. -I$(GNUPLOT) -DDEFAULTTERM=\"rlab\" -DRLAB -DBCOPY -DBZERO -O2 
# use following for 'make bar'
# CFLAGS = -I$(GNUPLOT) -DDEFAULTTERM=\"x11\" -DBCOPY -DBZERO -O 
 CFLAGS = -I. -I$(GNUPLOT) -DDEFAULTTERM=\"next\" -DGAMMA=lgamma -DNEXT -DREADLINE -DSGTTY -DX_NOT_POSIX -DX11 -ObjC -O

# -lplot iff you have -DUNIXPLOT
# -lsuntool -lsunwindow -lpixrect  iff you have -DSUN
# -lgl_s if IRIS4D
LIBS = -L/a/woo/lib -lgplot -lNeXT_s -lsys_s -lm

# Thing different systems might want to change
# INSTALL = cp
INSTALL = install
# RANLIB = touch
RANLIB = ranlib
AR = ar

OBJS  = version.o bitmap.o gscanner.o gsr.o gterm.o gutil.o epsviewe.o

#  make the libary
libgplot.a: $(OBJS)
	rm -f libgplot.a
	$(AR) q libgplot.a $(OBJS)
	$(RANLIB) libgplot.a

# install library
install: libgplot.a
	$(INSTALL) libgplot.a $(INSTALLLIB)
	$(RANLIB) $(INSTALLLIB)/libgplot.a

# make distribution kit
Part01:  gplotlib.uu
	split -625 gplotlib.uu gplot_
	makekit -nPart -t"cat gplot_* > tmp; uudecode tmp; rm tmp; gunzip gplotlib.tar.gz; tar xf gplotlib.tar" gplot_*

GPLIB_DEST = 000alpha.notes 000announce Makefile bar.c bar.doc bar.t1 \
bar.t2 bar.t3 bar.t4 bar.t5 bar.t6 bar.t7 bars.c cpr.1 cpr.c docu.c getopt.c \
gscanner.c gsr.c gsr.h gterm.c gtplot.h gutil.c intro.doc \
makefile.3b1 makefile.ult makefile.unx rlab.trm README.RLAB

gplotlib.uu: $(GPLIB_DEST)
	rm -f gplotlib.tar
	tar -cf gplotlib.tar $(GPLIB_DEST)
	gzip gplotlib.tar
	uuencode < gplotlib.tar.gz gplotlib.tar.gz > gplotlib.uu
	rm -f gplotlib.tar.gz

bar: $(OBJS) bar.o
	cc bar.o $(OBJS) $(LIBS) -o bar

bars: $(OBJS) bars.o
	cc bars.o $(LIBS) -o bars
#	cc bars.o -lgtplot $(LIBS) -o bars

bars.o: bars.c
	$(CC) -c bars.c $(CFLAGS)

pie: $(OBJS) pie.o
	cc pie.o $(OBJ) $(LIBS) -o pie

all:    bar bars pie

gterm.o: $(GNUPLOT)/term/*.trm gterm.c rlab.trm
	cc $(CFLAGS) -c gterm.c

bitmap.o: $(GNUPLOT)/bitmap.c
	cc $(CFLAGS) -c $(GNUPLOT)/bitmap.c

epsviewe.o: $(GNUPLOT)/epsviewe.m
	cc $(CFLAGS) -c $(GNUPLOT)/epsviewe.m

version.o: $(GNUPLOT)/version.c
	cc $(CFLAGS) -c $(GNUPLOT)/version.c

gscanner.o: gscanner.c
	cc $(CFLAGS) -c gscanner.c

$(OBJS): gtplot.h gsr.h

clean:
	rm -f *.o *~ *.*_doc Part* gplotlib.tar.gz gplotlib.uu gplot_* libgplot.a

spotless:
	rm -f *.o *~ TAGS bar bars pie cpr docu *.*_doc gplotlib.doc

doc:	docu cpr intro.doc gsr.c gsr.h gterm.c gtplot.h
	docu <gsr.c >gsr.c_doc
	docu <gsr.h >gsr.h_doc
	docu <gterm.c >gterm.c_doc
	docu <gtplot.h >gtplot.h_doc
	cpr -ac -C -PBACKSPACE \
	   intro.doc gterm.c_doc gtplot.h_doc gsr.c_doc gsr.h_doc >gplotlib.doc
	rm -f gsr.c_doc gsr.h_doc gterm.c_doc gtplot.h_doc

docu:	docu.c
	cc docu.c -o docu

cpr:	cpr.c
	cc cpr.c -o cpr

ci: $(GPLIB_DEST)
	ci -l$(RCSVER) $(GPLIB_DEST)

co: $(GPLIB_DEST)
	co -l$(RCSVER) $(GPLIB_DEST)

rcs: $(GPLIB_DEST)
	rcs -b$(RCSVER) $(GPLIB_DEST)
