# This is the Makefile for plot2ps, a plot file to postscript converter.
#
##############################################################################
#
# Uncomment DEF if you need verbose debugging information embeded in
# the postscript comments in the output file. You should still be
# able to both print the output on a postscript device or view it using
# idraw.
#
##############################################################################
#
#DEF = -DDEBUG
GETOPT=../getopt
CC=gcc
CFLAGS=-g
#
#----------------------------------------------------------------
.PHONY: dist clean install
# The toplevel make file uses these.
.PHONY: all install clean realclean

all : plot2ps

VERS=0.4
.c.o:
	$(CC) $(CFLAGS) $(DEF) -I$(GETOPT) -I../include -DVERS=\"$(VERS)\" -c $<

install : plot2ps
	install -c plot2ps $(BINDIR)
	install -c plot2ps.man $(MANDIR)/plot2ps.$(MANEXT)

#
# Type `make clean' to clean up after compilation.
#
clean:
	-rm -f *.o *~ \#* core TAGS
realclean : clean
	-rm -f plot2ps *.a
#----------------------------------------------------------------
#
# Type `make plot2ps' to compile plot2ps.
#

plot2ps : plot.o $(GETOPT)/getopt.o $(GETOPT)/getopt1.o libps.a
	$(CC) $(CFLAGS) -o plot2ps plot.o  $(GETOPT)/getopt.o $(GETOPT)/getopt1.o libps.a -lm

$(GETOPT)/getopt.o $(GETOPT)/getopt1.o : $(GETOPT)/getopt.c $(GETOPT)/getopt1.c
	cd $(GETOPT); make all CC="$(CC)" CFLAGS="$(CFLAGS)"
$(GETOPT)/getopt.o : $(GETOPT)/getopt.h $(GETOPT)/getopt.h
$(GETOPT)/getopt1.o : $(GETOPT)/getopt.h $(GETOPT)/getopt.h
#
# Type `make libps.a' to creaate the plot compatible library of
# functions for postscript output.
#
LSRC = open.c close.c space.c rotate.c dot.c point.c \
linemod.c line.c label.c alabel.c erase.c color.c move.c cont.c \
arc.c circle.c drawline.c header.c setfont.c fontsize.c fill.c \
range.c

LOBJ = open.o close.o space.o rotate.o dot.o point.o \
linemod.o line.o label.o alabel.o erase.o color.o move.o cont.o \
arc.o circle.o drawline.o header.o setfont.o fontsize.o fill.o \
range.o

libps.a : $(LOBJ)
	ar ru libps.a $?
	ranlib libps.a

#
# Type `make TAGS' to update the TAGS file for use with GNU emacs.
#
TAGS : plot.c $(LSRC) ../include/libplot.h
	etags plot.c $(LSRC) ../include/libplot.h

#
# This awk script can be used to build font width tables
# from the font metric file.
#
.fonttable.afm:
	echo >$@
	echo "int *${i}-width = {" >$@
	awk '/^C /{w[$2]= $5};END{for(i=0;i<256;i++){if (length(w[i])==0) printf ("0, "); else printf ("%d, ", w[i]);}}' <$< >$@
	echo "0};" >$@
	echo >$@
#
# Dependencies generated by gcc -MM *.c *.h:
#
alabel.o : alabel.c ../include/libplot.h
arc.o : arc.c ../include/libplot.h
box.o : box.c ../include/libplot.h
circle.o : circle.c ../include/libplot.h
close.o : close.c ../include/libplot.h
color.o : color.c ../include/libplot.h
cont.o : cont.c ../include/libplot.h
dot.o : dot.c ../include/libplot.h
drawline.o : drawline.c ../include/libplot.h
erase.o : erase.c ../include/libplot.h
header.o : header.c
label.o : label.c ../include/libplot.h
line.o : line.c ../include/libplot.h
linemod.o : linemod.c ../include/libplot.h
move.o : move.c ../include/libplot.h
open.o : open.c ../include/libplot.h
plot.o : plot.c ../include/libplot.h
point.o : point.c ../include/libplot.h
ppoint.o : ppoint.c ../include/libplot.h
rotate.o : rotate.c ../include/libplot.h
space.o : space.c ../include/libplot.h
range.o : range.c ../include/libplot.h
