# Makefile for xyplot and associated files
#
# some of the lines below have to changed for your system
#

# set DIS to display (the XView preview) if you want it generated or
# to nothing if not
DIS = display
# this sets INC to be the xview include directory
INC:sh =  echo "$OPENWINHOME/include"

# where to put the prolog for xyps
PB:sh = echo /local/lib/xyplot

# where to install xyplot and friends
DBIN = /local/bin

# how to put the programs in DBIN.  Can be cp, mv, or ln.
CONNECT = cp 

# where to keep the manual pages
DMAN = /usr/man

# in what section of the manual to put things (usualy l or 1)
MSEC = l

#
#   normaly the lines below do not need to be changed
#

# flags to use when compiling
CFLAGS = -O

# name of the prolog file
POST = \"$(PB)/post\"
# scanner
SC = \"scanner\"

all: xyplot scanner xyps post $(DIS)

scanner : scanner.o unix_to_ugs.o ugs_strokes.o lowlevel.o g_to_ugs.o 
	cc $(CFLAGS) scanner.o unix_to_ugs.o ugs_strokes.o lowlevel.o \
	  g_to_ugs.o  -lm -o scanner

xyplot: xyplot.o plotcom.o digit.o patchlevel.h
	cc $(CFLAGS) xyplot.o plotcom.o digit.o -lm -o xyplot

xyplot.o: xyplot.c
	cc $(CFLAGS) -DSCANNER=$(SC) -c xyplot.c

xyps: xyps.o parser.o partbl.o getxyin.o patchlevel.h
	cc $(CFLAGS) -DLIBPRO=$(POST) \
          xyps.o parser.o partbl.o getxyin.o -o xyps

xyps.o: xyps.c 
	cc $(CFLAGS) -DLIBPRO=$(POST) -c xyps.c

xyai: xyai.o parser.o partbl.o getxyin.o patchlevel.h
	cc $(CFLAGS) xyai.o parser.o partbl.o getxyin.o -o xyai

post : post.ps squeeze
	cat post.ps | ./squeeze > post

squeeze: squeeze.o
	cc $(CFLAGS) squeeze.o -o squeeze

display: display.c
	cc $(CFLAGS) display.c -I$(INC) -lxview -lolgx -lX11 -o display
#	cc $(CFLAGS) display.o  -lcgi -lsunwindow -lpixrect -lm -o display

xyman: xyman.ps

xyman.ps:
	cd doc; make xyman.ps; mv xyman.ps ..

install: all maninstall
	test -d $(DBIN) || mkdir $(DBIN)
	/bin/rm -f $(DBIN)/xyplot && $(CONNECT) xyplot $(DBIN)
	/bin/rm -f $(DBIN)/xyps && $(CONNECT) xyps $(DBIN)
	/bin/rm -f $(DBIN)/scanner && $(CONNECT) scanner $(DBIN)
	test -f $(PB)/post || $(CONNECT) post $(PB)/post
	test -z $(DIS) || /bin/rm -f $(DBIN)/$(DIS) && $(CONNECT) $(DIS) $(DBIN)

maninstall: xyplot.1 xyps.1
	/bin/rm -f $(DMAN)/man$(MSEC)/xyps.$(MSEC) && $(CONNECT) xyps.1\
		 $(DMAN)/man$(MSEC)/xyps.$(MSEC)
	/bin/rm -f $(DMAN)/man$(MSEC)/xyplot.$(MSEC) && $(CONNECT) xyplot.1\
		 $(DMAN)/man$(MSEC)/xyplot.$(MSEC)

deinstall:
	-/bin/rm -f $(DBIN)/xyplot 
	-/bin/rm -f $(DBIN)/xyps 
	-/bin/rm -f $(DBIN)/scanner 
	-/bin/rm -f $(PB)/post 
	-test -n \"$(DIS)\" || /bin/rm -f $(DBIN)/$(DIS)
	-/bin/rm -f $(DMAN)/man$(MSEC)/xyplot.$(MSEC)
	-/bin/rm -f $(DMAN)/man$(MSEC)/xyps.$(MSEC)

# removes whatever can be built with make except post
clean :
	/bin/rm -f *.o xyman.ps xy.tar* $(DIS) xyplot xyps squeeze scanner
	cd doc; make clean

tar: xyman
	tar -cvFFfX xy.tar etc/excludefiles .
	compress xy.tar

