# $Id: Makefile,v 1.7 89/09/20 17:59:48 mbp Exp $
#
# Makefile: for LGD's SunView device driver

# Do not run this Makefile by itself.  It is called automatically by
# the main LGD Makefile.  You should not need to change anything in
# this Makefile; the main LGD Makefile passes all the relevant macro
# values down to this one.  The explanations given here are just in
# case things don't go well and you need to figure out what's going
# on.

##############################################
#        BEGIN CONFIGUATION SECTION	     #
##############################################

# The following line must be hard-coded if not using csh.  If you are
# not using csh, remove the comment char from the beginning of this
# line and replace the pathname here with the pathname of the
# directory that LGD is in (the one containing this Makefile):
#PWD=/u/yourlogin/src/lgd

# Floating point option; should be one of
#	-f68881 for MC68881 coprocessor
#	-ffpa for FBA board
#	-fsoft (or null) for software operations (the default)
FOPTION=

# Additional compiler options (such as -O, -g, etc):
OPTIONS=-O

# AUXDIR should be the (complete) pathname of the directory where you
# want to install the files that LGD programs need at run-time. You
# should probably install these files in some permanent location
# (rather than with the source code), such as /usr/local/lib/lgd, so
# that LGD programs will not be dependent on the location of the LGD
# source code.
#
# When doing 'make install', AUXDIR is created if it does not exist,
# and the auxiliary files are copied into it.  You should be sure that
# you have write permission in AUXDIR, or in its parent if it does not
# yet exist.
#
# The path you give for AUXDIR should be one which is recognized by
# all workstations for which this installation is being done.
#
# To leave the auxiliary files in their current location (with the
# source code), specify AUXDIR=$(PWD).
AUXDIR=/usr/local/lib/lgd

# DEFAULTSDIR should be the directory in which you want to install the
# lgd SunView defaults file ('LGD.d').  This file must be installed in
# a directory (probably /usr/lib/defaults) that is searched by the
# program defaultsedit(1) if you want users to be able to use
# defaultsedit to set customized values for lgd parameters.  If you do
# not install this file, users can still set customized lgd parameter
# values by editing the file '.defaults' in their home directories
# manually.  (See the lgd manual page for more details.)
#
# The value you give for DEFAULTSDIR should be the pathname of an
# existing directory in which you have write permission.
#
# To prevent the Makefile from trying to install the defaults file,
# comment out the defition of DEFAULTSDIR.
DEFAULTSDIR=/usr/lib/defaults

# GR_HEADER should be the complete pathname of the GR header file
# "gr.h"
GR_HEADER=/usr/local/lib/gr/gr.h

##############################################
#         END CONFIGUATION SECTION	     #
#					     #
#     Don't change anything below here       #
##############################################

HELPFILE=$(AUXDIR)/sunview.help
OBJS = dev.o view.o dpu.o
CFILES = dev.c view.c dpu.c
OTHERFLAGS = -DGR_HEADER='"$(GR_HEADER)"'
CFLAGS = $(OPTIONS) $(FOPTION) $(OTHERFLAGS)
AUXFILES = sunview.help

lgddev.o: 	$(OBJS)
	ld -r -o lgddev.o $(OBJS)

dev.o:		dev.c dev.h ../lgd.h
	cc $(CFLAGS) \
		-DHELPFILE='"$(HELPFILE)"' \
		-c -o dev.o dev.c

view.o:		view.c ../lgd.h ../vector.h
	cc $(CFLAGS) -c -o view.o view.c

dpu.o:		dpu.c dpu.h dev.h ../internal.h ../lgd.h \
		../mf.h ../vector.h
	cc $(CFLAGS) -c -o dpu.o dpu.c

install:	install_aux install_defaults

install_aux:	sunview.help Makefile
	@if test "$(AUXDIR)" != "$(PWD)" ; then				\
	  if test -f $(AUXDIR) ; then					\
	    echo ERROR: AUXDIR \($(AUXDIR)\) is not a directory ;	\
	    exit 1 ;							\
	  fi ;								\
	  if test ! -d $(AUXDIR) ; then					\
	    echo mkdir $(AUXDIR) ;					\
	    mkdir $(AUXDIR) ;						\
	  fi ;								\
	    echo cp $(AUXFILES) $(AUXDIR) ;				\
	    cp $(AUXFILES) $(AUXDIR) ;					\
	fi

install_defaults:	LGD.d Makefile
	@if test "$(DEFAULTSDIR)" != "" ; then				\
	  if test ! \( -d $(DEFAULTSDIR) -a -w $(DEFAULTSDIR) \) ; then	\
	    echo '' ;							\
	    echo DEFAULTSDIR = $(DEFAULTSDIR) ;				\
	    echo is not an existing directory in which you have write ; \
	    echo permission.  Try installing again after making sure ;	\
	    echo that the directory you give for DEFAULTSDIR in the ;	\
	    echo Makefile exists and that you can write in it. ;	\
	    echo '' ;							\
	    exit 1 ;							\
	  fi ;								\
	  echo cp LGD.d $(DEFAULTSDIR) ;				\
	  cp LGD.d $(DEFAULTSDIR) ;					\
	fi

lintlib:
	lint -DHELPFILE='"$(HELPFILE)"' \
	  $(OTHERFLAGS) \
	  -Clgdsunview $(CFILES)

clean:
	/bin/rm -f *.o *~ *%

veryclean:	clean

