############################################################
#
# GNUPLOT 3.0 Makefile (Unix X11 Motif/Athena support) for
#  Apollo/Sun/Dec5000/IBMrs6000/HP9000/SGI/3B1/386IX
#
# Original version by:
#   oliveria@caen.engin.umich.edu (ROQUE DONIZETE DE OLIVEIRA)
#   Wed, 3 Jul 91 14:31:37 -0400
#
#>>> Customizing: You must customize part of this makefile for your site.
#>>> Then type 'make' for further instructions.
#>>> Customization instructions look like these lines do (#>>>).
#

TARGET = All # What to make by default

############################################################
#>>> Decide where the binaries and manuals will go. 
# directory where to install executables on 'make install'
DEST=/usr/local/bin
# directory for installing man page on 'make man_install'.
MANDEST=/usr/man/manl
# where to install help file gnuplot.gih
HELPDEST=~/gnuplot
#HELPDEST=docs/gnuplot.gih
# Where to send email about bugs and comments (locally)
EMAIL=hugo

############################################################
#>>> Choose your C compiler and basic compiler flags.
CC     = cc # the C compiler
COPTS  = -O # -O if you trust your compiler's optimizer
LD     =$(CC) $(CFLAGS)	    # default loading command

############################################################
#>>> Choose some optional features. 
#>>> At this point there are only two optional features:
# READLINE:
#   If READLINE is defined, then command-line editing is supported.
#   Otherwise, your normal terminal editing is all you get.
#   Some machines will not support this, and they will turn this
#   option off (for example, apollos running SR10.2 or SR10.3 and
#   loaded with BSD4.3 instead of SYS5). 
# NOCWDRC:
#   If NOCWDRC is defined, then any .gnuplot in the current directory
#   is not read on startup. This is a security consideration
#   especially for root users ( we recommend you define -DNOCWDRC ).
OPTIONS = -DREADLINE -DNOCWDRC

#>>> Optionally install the lasergnu script.
# Lasergnu is a handy shell script for creating a plot from the
# command line and sending it directly to the printer. It currently
# supports postscript and imagen printers, and probably would need
# tailoring to your site.
# Use lasergnu_install to install lasergnu.
# Use lasergnu_noinstall to not install lasergnu (default).
LASERGNU = lasergnu_noinstall

############################################################
# X11 support
#

#>>> List your X11 libraries#
# standard MIT X11 R4:                      -lXaw -lXmu -lXt -lXext -lX11
# Apollo DomainOS 10.3 (R3/Athena):         -L/usr/lib/X11 -lXaw -lXmu -lXt -lX11
# Apollo DomainOS 10.3 (R3/Motif):          -L/usr/lib/X11 -lXm -lXtm -lX11
# IBM RS/6000 AIX 3.1 (R3/Athena):          -L/usr/lpp/X11/Xamples/lib/Xmu \
#                                           -L/usr/lpp/X11/Xamples/lib/Xaw \
#                                           -lXaw -lXmu -lXt -lXext -lX11
# IBM RS/6000 AIX 3.1 (R3/Motif):           -lXm -lXt -lX11
# HP 9000/375 HP-UX 6.5 and 7.0 (R3/Motif): -lXm -lXt -lX11
# Interactive 386/ix with T.Roell X386 and network support:
#                                           -lXaw -lXm -lXt -lXext -lX11 -linet -lpt
X11LIBS = -lXaw -lXmu -lXt -lXext -lX11

#>>> List your X11 include directories
# standard MIT X11 R4: -I/usr/include/X11   -I/usr/include/X11/Xaw 
# Apollo DomainOS 10.3 (R3/Athena):         -I/usr/include/X11
# Apollo DomainOS 10.3 (R3/Motif):          -I/usr/include/Xm
# IBM RS/6000 AIX 3.1 (R3/Athena):          -I/usr/include/X11 \
#                                           -I/usr/lpp/X11/Xamples/lib/Xaw \
#                                           -I/usr/lpp/X11/Xamples/lib/Xaw/X11
# IBM RS/6000 AIX 3.1 (R3/Motif):           -I/usr/include/Xm
# HP 9000/375 HP-UX 6.5 and 7.0 (R3/Motif): -I/usr/include/Xm
# HP 9000/700 HP-UX 8.0 (R4):               -I/usr/include/X11R4 \
#                                           -I/usr/include/X11R4/X11/Xaw
X11INCLUDES = -I/usr/include/X11 -I/usr/include/X11/Xaw -I/zib/include_sun4/X11 -I/zib/include_sun4/X11/Xaw -I/zib/include_sun4

#>>> You shouldn't have to change these, since they are controlled by
#>>> Machine dependent definitions below.
#       Compile option for plot.c and TERMFLAGS, to include X11 support
PLOTXFLAG = -DX11
#   	   this can add to CFLAGS for X11 compilations. Probably needs no change.
X11FLAGS = 
#       make gnuplot_x11 by default
GNUPLOT_X11 = gnuplot_x11
#       install gnuplot_x11 by default
X11INSTALL = x11_install

############################################################
#>>> Okay, you've changed enough. Now type 'make'.

############################################################
# This is used to pass many of the above definitions to make
# subprocesses. Don't change this.
MY_FLAGS  = CC="$(CC)" 	COPTS="$(COPTS)" DEST="$(DEST)" \
		MANDEST="$(MANDEST)" HELPDEST="$(HELPDEST)" \
		EMAIL="$(EMAIL)" LASERGNU="$(LASERGNU)"

############################################################
# Explanations of CFLAGS definitions.
#  These should not need to be changed by you.
# They are set correctly for each machine below. If your machine
# doesn't fit the one of the patterns, override on the make command
# line or make a new target for it and a new _FLAGS definition. 
#  -DNOVFORK if you're unix and you have don't have vfork()
#  -DMEMSET if you need to use memset() instead of bzero() 
#  -DMEMCPY if your bcopy() is called memcpy()
#  -DNOCOPY if you don't have a memcpy() by any name
#  -DGAMMA=foo if your gamma function is called foo(). Apollos have
#    lgamma(3m). If you don't have gamma(), use -DNOGAMMA.
#    The default is -DGAMMA=gamma.
#  -DGETCWD if your unix uses getcwd() instead of getcd()
#    this is needed by HP-UX and Cray Unicos systems.
#  -DULTRIX_KLUDGE if you run X windows on Ultrix and experience the
#    "every other plot" problem.
#  -Dunix is required to explicitly define "unix" for SCO and IBM
#   	   RS/6000 running AIX 3.1 
#  -fswitch if you are compiling on a Sun3 (or even -f68881)
#    (but -fswitch is buggy on some systems, so watch out)

# Defaults in case the user types 'make All' directly
# Should match X11R4_FLAGS's CFLAGS definition
CFLAGS = $(COPTS) $(OPTIONS)

############################################################
# Terminal (device) support
#
# All devices available to a given machine are compiled in by default.
# This documents the flags available in TERMFLAGS, although TERMFLAGS
# is usually controlled by the machine-dependent definitions below.
# See other terminal defines in term.h.
# Define ULTRIX_KLUDGE if you have the every-other plot problem in Ultrix X11.
#
# -DAPOLLO      Apollo Graphics Primitive Resource (window resize after replot)
# -DGPR         Apollo Graphics Primitive Resource (fixed-size window)
# -DCGI         SCO CGI
# -DIRIS4D      IRIS4D series computer
# -DSUN         Sun Microsystems Workstation
# -DUNIXPC      unixpc (ATT 3b1 or ATT 7300)
# -DUNIXPLOT    unixplot
# -DX11         X11 Window System (This is $(PLOTXFLAG))
TERMFLAGS = -Iterm -DUNIXPLOT $(PLOTXFLAG)

############################################################
# Library explanations. 
#  You shouldn't need to adjust this; again, it is handled by the
# machine-dependent definitions below.
#
#  -lplot if you have -DUNIXPLOT in TERMFLAGS
#  -lsuntool -lsunwindow -lpixrect  if you have -DSUN in TERMFLAGS
#  -lgl_s if -DIRIS4D in TERMFLAGS
#  -lccgi if -DCGI in TERMFLAGS
LIBS = -lm -lplot

############################################################
# Machine-dependent settings.
#
X11R4_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS)" \
    	   LIBS="$(LIBS)" X11FLAGS="$(X11FLAGS)" X11INCLUDES="$(X11INCLUDES)" \
    	   X11LIBS="$(X11LIBS)" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="$(TERMFLAGS)"

X11R4_M_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS)" \
    	   LIBS="$(LIBS)" X11FLAGS="-DMOTIF -D_NO_PROTO" \
    	   X11INCLUDES="-I/usr/include/Xm" \
    	   X11LIBS="-lXm -lXt -lX11" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="$(TERMFLAGS)"

DEC_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS) " \
    	   LIBS="$(LIBS)" X11FLAGS="$(X11FLAGS)" X11INCLUDES="$(X11INCLUDES)" \
    	   X11LIBS="$(X11LIBS)" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="$(TERMFLAGS) -DULTRIX_KLUDGE"

DEC_M_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS)" \
    	   LIBS="$(LIBS)" X11FLAGS="-DMOTIF -D_NO_PROTO" \
    	   X11INCLUDES="-I/usr/include/Xm" \
    	   X11LIBS="-lXm -lXt -lX11" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="$(TERMFLAGS)  -DULTRIX_KLUDGE"

APOLLO_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS)  -DGAMMA=lgamma" \
    	   LIBS="$(LIBS)" X11FLAGS="$(X11FLAGS)" \
    	   X11INCLUDES="-I/usr/include/X11" \
    	   X11LIBS="-L/usr/lib/X11 -lXaw -lXmu -lXt -lX11" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="$(TERMFLAGS) -DAPOLLO -DGPR"

APOLLO_M_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS)  -DGAMMA=lgamma" \
    	   LIBS="$(LIBS)" X11FLAGS="-DMOTIF" X11INCLUDES="-I/usr/include/Xm" \
    	   X11LIBS="-L/usr/lib/X11 -lXm -lXt -lX11" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   TERMFLAGS="$(TERMFLAGS) -DAPOLLO -DGPR"

HP_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS) -DMEMSET -DMEMCPY  -DGETCWD" \
    	   LIBS="-lm" X11FLAGS="$(X11FLAGS)" \
    	   X11INCLUDES="-I/usr/include/X11R4 -I/usr/include/X11R4/X11/Xaw \
	   -I/usr/include/X11 -I/usr/include/X11/Xaw -I/zib/include_sun4/X11 \
           -I/zib/include_sun4/X11/Xaw -I/zib/include_sun4" \
    	   X11LIBS="-L/usr/lib/X11R4 -lXaw -lXmu -lXt -lXext -lX11" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="-Iterm -DX11"

SUN_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS)" \
    	   LIBS="-lsuntool -lsunwindow -lpixrect $(LIBS)" \
    	   X11FLAGS=" " X11INCLUDES=" " \
    	   X11LIBS=" " \
    	   PLOTXFLAG=" " GNUPLOT_X11=" " X11INSTALL=x11_noinstall \
    	   TERMFLAGS="-Iterm -DUNIXPLOT -DSUN"

SUN_X11_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS)" \
    	   LIBS="-lsuntool -lsunwindow -lpixrect $(LIBS)" \
    	   X11FLAGS="$(X11FLAGS)" X11INCLUDES="$(X11INCLUDES)" \
    	   X11LIBS="$(X11LIBS)" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="$(TERMFLAGS) -DSUN"

SGI_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS)" \
    	   LIBS="-lgl_s -lm" X11FLAGS=" " X11INCLUDES=" " \
    	   X11LIBS=" " \
    	   PLOTXFLAG=" " GNUPLOT_X11=" " X11INSTALL=x11_noinstall \
    	   TERMFLAGS="-Iterm -DIRIS4D"

SGIX11_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS)" \
    	   LIBS="-lm" X11FLAGS="$(X11FLAGS)" \
    	   X11INCLUDES="-I/usr/include/X11 -I/usr/include/X11/Xaw" \
    	   X11LIBS="-L/usr/lib/X11 -lXaw -lXmu -lXt -lXext -lX11" \
     	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
     	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="-Iterm -DX11"

CGI_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS) -Dunix" \
    	   LIBS="-lccgi $(LIBS)" X11FLAGS=" " X11INCLUDES=" " \
    	   X11LIBS=" " PLOTXFLAG=" " GNUPLOT_X11=" " X11INSTALL=x11_noinstall \
    	   TERMFLAGS="-Iterm -DUNIXPLOT -DCGI"

3B1_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS) -DGETCWD -DMEMSET -DMEMCPY -DNOVFORK" \
    	   LIBS="$(LIBS)" X11FLAGS=" " X11INCLUDES=" " \
    	   X11LIBS=" " \
    	   PLOTXFLAG=" " GNUPLOT_X11=" " X11INSTALL=x11_noinstall \
    	   LD="ld /lib/crt0s.o /lib/shlib.ifile" \
    	   TERMFLAGS="-Iterm -DUNIXPC"

386IX_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS) -DGETCWD -DMEMSET -DMEMCPY -DNOVFORK -DTCSETSW -DTCGETS" \
    	   LIBS="$(LIBS) -lcposix" X11FLAGS=" " X11INCLUDES=" " \
    	   X11LIBS=" " PLOTXFLAG=" " GNUPLOT_X11=" " \
    	   X11INSTALL=x11_noinstall \
    	   TERMFLAGS="-Iterm -DUNIXPLOT"
386IX_X11_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS) -DGETCWD -DMEMSET -DMEMCPY -DNOVFORK -DTCSETSW -DTCGETS" \
    	   LIBS="$(LIBS) -lcposix" X11FLAGS="$(X11FLAGS)" X11INCLUDES="$(X11INCLUDES)" \
    	   X11LIBS="$(X11LIBS)" PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11="$(GNUPLOT_X11)" \
    	   X11INSTALL= "$(X11INSTALL)" \
    	   TERMFLAGS="-Iterm -DUNIXPLOT -DX11"
 	
AIX_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS) -Dunix -DNOVFORK" \
    	   LIBS="$(LIBS)" X11FLAGS="$(X11FLAGS)" \
    	   X11INCLUDES="-I/usr/include/X11 -I/usr/lpp/X11/Xamples/lib/Xaw -I/usr/lpp/X11/Xamples/lib/Xaw/X11" \
    	   X11LIBS="-L/usr/lpp/X11/Xamples/lib/Xmu -L/usr/lpp/X11/Xamples/lib/Xaw -lXaw -lXmu -lXt -lXext -lX11" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="$(TERMFLAGS)"

AIX_M_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS) -Dunix -DNOVFORK" \
    	   LIBS="$(LIBS)" X11FLAGS="-DMOTIF" X11INCLUDES="-I/usr/include/Xm" \
    	   X11LIBS="-lXm -lXt -lX11" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="$(TERMFLAGS)"

NEXT_FLAGS = \
    	   CFLAGS="$(COPTS) -DNOCWDRC -DGAMMA=lgamma -DNEXT" \
    	   LIBS="-lm" X11FLAGS="$(X11FLAGS)" \
    	   X11INCLUDES=" " X11LIBS=" " PLOTXFLAG=" " \
    	   GNUPLOT_X11=" " X11INSTALL=x11_noinstall \
    	   TERMFLAGS="-Iterm"

####################################################################
# List of object files except version.o
OBJS = bitmap.o command.o contour.o eval.o graphics.o graph3d.o help.o \
	   internal.o misc.o parse.o plot.o readline.o scanner.o \
	   setshow.o standard.o term.o util.o  
####################################################################
# List of source files
# Used for makeing shar files, lint, and some dependencies.
DIRS = term demo docs docs/latextut

CSOURCE1 = command.c setshow.c 
CSOURCE2 = help.c graphics.c graph3d.c internal.c 
CSOURCE3 = misc.c eval.c parse.c plot.c readline.c scanner.c standard.c 
CSOURCE4 = bitmap.c term.c util.c version.c
CSOURCE5 = term/amiga.trm term/aed.trm term/cgi.trm term/dumb.trm term/dxf.trm \
	term/dxy.trm term/eepic.trm term/epson.trm term/fig.trm \
	term/hp26.trm term/hp2648.trm term/hpgl.trm term/hpljii.trm \
	term/apollo.trm term/gpr.trm
CSOURCE6 = term/impcodes.h term/imagen.trm term/object.h \
	term/iris4d.trm term/kyo.trm term/latex.trm term/pc.trm 
CSOURCE7 = term/post.trm term/qms.trm term/regis.trm term/sun.trm \
	term/t410x.trm term/tek.trm term/unixpc.trm term/unixplot.trm \
	term/v384.trm term/x11.trm term/bigfig.trm term/vws.trm gnuplot_x11.c
CSOURCE8 = contour.c
# not C code, but still needed

DEMOS = demo/1.dat demo/2.dat demo/3.dat demo/contours.demo demo/controls.demo \
	demo/electron.demo demo/glass.dat demo/param.demo demo/polar.demo \
	demo/simple.demo demo/surface1.demo demo/surface2.demo demo/using.dat \
	demo/using.demo demo/world.cor demo/world.dat demo/world.demo \
	demo/err.dat demo/poldat.demo demo/polar.dat demo/errorbar.demo \
	demo/antenna.dat demo/all.demo demo/bivariat.demo

ETC = Copyright README README.gnutex README.amiga makefile.unx makefile.vms  \
	linkopt.amg makefile.amg makefile.ami linkopt.vms buildvms.com \
	plot.h help.h setshow.h bitmap.h term.h lasergnu \
	term/README History gnuplot.el Intergraph.x11 README.Install

#BETA files (not standard distribution files)
BETA = BETA10
# PC-specific files
PC = corgraph.asm corplot.c header.mac hrcgraph.asm lineproc.mac \
	linkopt.msc linkopt.tc linkopt.tco makefile.msc makefile.tc \
	pcgraph.asm 

# Documentation and help files
DOCS1 = docs/Makefile docs/README docs/checkdoc.c docs/doc2gih.c \
	docs/doc2hlp.c docs/doc2hlp.com docs/doc2ms.c docs/doc2tex.c \
	docs/gnuplot.1 docs/lasergnu.1 docs/toc_entry.sty \
	docs/titlepage.ms docs/titlepage.tex docs/Makefile.ami
DOCS2 = docs/gnuplot.doc
DOCS3 = docs/latextut/Makefile docs/latextut/eg1.plt \
	docs/latextut/eg2.plt docs/latextut/eg3.dat docs/latextut/eg3.plt \
	docs/latextut/eg4.plt docs/latextut/eg5.plt docs/latextut/eg6.plt \
	docs/latextut/header.tex docs/latextut/tutorial.tex \
	docs/latextut/linepoint.plt

#########################################################################
# Default target (informational)
info:
	@echo "Please do a 'make <MACHINE>' where <MACHINE> is one of the following:"
	@echo 
	@echo "apollo, apollo_motif       for Apollo running SR10.3 with Apollo's X11R3"
	@echo "dec, dec_motif             for Dec3100/5000 running Ultrix 3.1d with MIT's X11R4"
	@echo "hp                         for HP/9000 700 series running HP/UX 8.0 with MIT's X11R4"
	@echo "sun                        for Sun sparcstation running SunOS 4.1 with suntools (no X11R4) "
	@echo "sun_x11                    for Sun sparcstation running SunOS 4.1 with suntools and X11R4 "
	@echo "sgi                        for Silicon Graphics IRIS4D machines (no X11R4) "
	@echo "sgix11                     for Silicon Graphics IRIS4D machines (X11R4) "
	@echo "next                       for NeXT Cube and Slab running NeXTOS 2.0+ (no X11R4) "
	@echo "3b1                        for ATT 3b1 machines (no X11R4) "
	@echo "386ix                      for 386 machines running 386/ix (no X11)"
	@echo "386ix_x11                  for 386 machines running 386/ix with T.Roell X386"
	@echo "ibmrs6000, ibmrs6000_motif for IBM RS/6000 running Aix 3.1 with IBM's X11R3"
	@echo "x11r4, x11r4_motif         for a generic machine (like a sun or dec) with MIT's X11R4"
	@echo 
	@echo "Examples:"
	@echo
	@echo "         make x11r4"
	@echo "         make x11r4_motif"
	@echo "         make apollo"
	@echo "         make apollo       OPTIONS='-DNOCWDRC' "
	@echo "         make apollo_motif DEST='/usr/um/misc/bin' "
	@echo "         make dec"
	@echo "         make hp"
	@echo "         make next"
	@echo "         make sun          HELPDEST='/usr/um/misc/lib/gnuplot.gih' "
	@echo "         make sun          X11INCLUDES='-I/usr/local/include -I/usr/local/include/X11 -I/usr/local/include/X11/Xaw' "
	@echo "         make sun_x11"
	@echo "         make sgi"
	@echo "         make 3b1"
	@echo "         make 386ix"
	@echo "         make ibmrs6000    MANDEST='/usr/usr/misc/man/man1' COPTS='-O' "
	@echo 
	@echo "If you just type 'make All' , it will build gnuplot for Unix X11R4/Athena"
	@echo "and the following variables will be used as default:"
	@echo 
	@echo " DEST                     " $(DEST)
	@echo " MANDEST                  " $(MANDEST)
	@echo " HELPDEST                 " $(HELPDEST)
	@echo " EMAIL                    " $(EMAIL)
	@echo " CC                       " $(CC)
	@echo " COPTS                    " $(COPTS)
	@echo " OPTIONS                  " $(OPTIONS)
	@echo " CFLAGS                   " $(CFLAGS)
	@echo " LIBS                     " $(LIBS)
	@echo " X11FLAGS                 " $(X11FLAGS)
	@echo " X11LIBS                  " $(X11LIBS)
	@echo " X11INCLUDES              " $(X11INCLUDES)
	@echo " TERMFLAGS                " $(TERMFLAGS)
	@echo " LASERGNU                 " $(LASERGNU)
	@echo 
	@echo "If you are not familiar with makefiles or just want to know what"
	@echo " 'make <MACHINE>' would  do without actually doing anything, then type"
	@echo " 'make <MACHINE> -n' "
	@echo 

###############################################################
# Targets for each machine

x11r4:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(X11R4_FLAGS)    $(TARGET)

x11r4_motif:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(X11R4_M_FLAGS)  $(TARGET)

dec:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(DEC_FLAGS)      $(TARGET)

dec_motif:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(DEC_M_FLAGS)    $(TARGET)

apollo:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(APOLLO_FLAGS)   $(TARGET)

apollo_motif:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(APOLLO_M_FLAGS) $(TARGET)

hp:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(HP_FLAGS)       $(TARGET)

next:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(NEXT_FLAGS)     $(TARGET)

sun:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(SUN_FLAGS)      $(TARGET)

sun_x11:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(SUN_X11_FLAGS)  $(TARGET)

sgi:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(SGI_FLAGS)      $(TARGET)

sgix11:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(SGIX11_FLAGS)   $(TARGET)

cgi:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(CGI_FLAGS)      $(TARGET)

3b1:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(3B1_FLAGS)      $(TARGET)

386ix:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(386IX_FLAGS)    $(TARGET)

386ix_x11: 
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(386IX_X11_FLAGS) $(TARGET)

ibmrs6000:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(AIX_FLAGS)      $(TARGET)

ibmrs6000_motif:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(AIX_M_FLAGS)    $(TARGET)

#############################################################
# Targets that really do something

all:
	@echo "Please just type  'make'  in order to get some information on "
	@echo "how to build gnuplot under Unix and the X Window System."

All:	gnuplot $(GNUPLOT_X11) doc

gnuplot: $(OBJS) version.o
	$(LD) $(OBJS) version.o $(LIBS) -o gnuplot

doc:
	( cd docs; make $(MFLAGS) gnuplot.gih )

gnuplot_x11: gnuplot_x11.c
	$(CC) $(CFLAGS) $(X11FLAGS) $(X11INCLUDES) -o gnuplot_x11 gnuplot_x11.c $(X11LIBS)

################################################################
# Installation instructions

install:
	@echo 
	@echo "Please do a 'make <MACHINE> TARGET=Install' where <MACHINE> is one of the following:"
	@echo 
	@echo "apollo, apollo_motif, dec, dec_motif, hp, sun, sun_x11, sgi, sgix11"
	@echo "next, 3b1, 386ix, ibmrs6000, ibmrs6000_motif, x11r4, x11r4_motif"
	@echo 
	@echo "Examples:"
	@echo
	@echo "         make x11r4        TARGET=Install "
	@echo "         make apollo       TARGET=Install "
	@echo "         make apollo_motif TARGET=Install DEST='/usr/um/misc/bin' "
	@echo "         make dec          TARGET=Install "
	@echo "         make hp           TARGET=Install "
	@echo "         make sun          TARGET=Install HELPDEST='/usr/um/misc/lib/gnuplot.gih' "
	@echo "         make ibmrs6000    TARGET=Install MANDEST='/usr/um/misc/man/man1' COPTS='-O' "
	@echo 
################################################################
# Installation targets

Install: All man_install $(X11INSTALL) $(LASERGNU)
	cp gnuplot     $(DEST)
	strip $(DEST)/gnuplot
	(cd docs; make $(MFLAGS) install-unix HELPDEST=$(HELPDEST))

x11_install: gnuplot_x11
	cp gnuplot_x11 $(DEST)
	strip $(DEST)/gnuplot_x11

x11_noinstall: 
	@echo "X11 not requested, so gnuplot_x11 program not installed"

man_install: docs/gnuplot.1
	cp docs/gnuplot.1 $(MANDEST)

lasergnu_install: lasergnu docs/lasergnu.1
	cp lasergnu $(DEST)
	chmod 755 $(DEST)/lasergnu
	cp docs/lasergnu.1 $(MANDEST)

lasergnu_noinstall:
	@echo 
	@echo "Lasergnu will not be installed by default."
	@echo "If you think you need the lasergnu script to print"
	@echo " files on the imagen or postscript printers, then"
	@echo " type"
	@echo "      'make <MACHINE> TARGET=Install LASERGNU='lasergnu_install' "
	@echo
	@echo "Lasergnu is really not needed since within gnuplot you can"
	@echo " can create files (in impress or postscript language) and"
	@echo " print them through your favorite print command (lpr, lp, prf, ipr)."
	@echo 

################################################################
# Dependencies

plot.o: plot.c
	$(CC) $(CFLAGS) $(PLOTXFLAG) -c plot.c

term.o: term.h term.c $(CSOURCE5) $(CSOURCE6) $(CSOURCE7)
	$(CC) $(CFLAGS) $(TERMFLAGS) -c term.c

version.o:
	$(CC) $(CFLAGS) -DCONTACT=\"$(EMAIL)\" -c version.c

$(OBJS): plot.h

command.o:
	$(CC) $(CFLAGS) -c command.c -DHELPFILE=\"$(HELPDEST)\"

command.o help.o misc.o: help.h

command.o graphics.o graph3d.o misc.o plot.o setshow.o term.o: setshow.h

bitmap.o term.o: bitmap.h

################################################################
# Miscellaneous targets

SOURCES=plot.h help.h setshow.h bitmap.h term.h $(CSOURCE1) $(CSOURCE2) \
	$(CSOURCE3) $(CSOURCE4) $(CSOURCE5) $(CSOURCE6) $(CSOURCE7) $(CSOURCE8)

lint:
	lint -hx $(SOURCES)

clean:
	rm -f *.o *~ *.bak term/*~ term/*.bak
	(cd docs; make $(MFLAGS) clean)
	(cd docs/latextut; make $(MFLAGS) clean)

spotless:
	rm -f *.o *~ *.bak term/*~ term/*.bak TAGS gnuplot gnuplot_x11
	(cd docs; make $(MFLAGS) clean)
	(cd docs/latextut; make $(MFLAGS) spotless)

################################################################
# Making shar files for mailing gnuplot

shar: gnuplot.sh00 gnuplot.sh01 gnuplot.sh02 gnuplot.sh03 gnuplot.sh04 \
	gnuplot.sh05 gnuplot.sh06 gnuplot.sh07 gnuplot.sh08 \
	gnuplot.sh09 gnuplot.sh10 gnuplot.sh11 gnuplot.sh12 \
	gnuplot.sh13 gnuplot.sh14 gnuplot.sh15 

gnuplot.sh00:
	echo '#!/bin/sh' > gnuplot.sh00
	echo '# This is a shell file to make directories' >> gnuplot.sh00
	echo mkdir $(DIRS) >> gnuplot.sh00

gnuplot.sh01: $(ETC)
	shar $(ETC) > gnuplot.sh01

gnuplot.sh02: $(DOCS1)
	shar $(DOCS1) > gnuplot.sh02

gnuplot.sh03: $(DOCS2)
	shar $(DOCS2) > gnuplot.sh03

gnuplot.sh04: $(DOCS3)
	shar $(DOCS3) > gnuplot.sh04

gnuplot.sh05: $(CSOURCE1)
	shar $(CSOURCE1) > gnuplot.sh05

gnuplot.sh06: $(CSOURCE2)
	shar $(CSOURCE2) > gnuplot.sh06

gnuplot.sh07: $(CSOURCE3)
	shar $(CSOURCE3) > gnuplot.sh07

gnuplot.sh08: $(CSOURCE4)
	shar $(CSOURCE4) > gnuplot.sh08

gnuplot.sh09: $(CSOURCE5)
	shar $(CSOURCE5) > gnuplot.sh09

gnuplot.sh10: $(CSOURCE6)
	shar $(CSOURCE6) > gnuplot.sh10

gnuplot.sh11: $(CSOURCE7)
	shar $(CSOURCE7) > gnuplot.sh11

gnuplot.sh12: $(PC)
	shar $(PC) > gnuplot.sh12

gnuplot.sh13: $(CSOURCE8)
	shar $(CSOURCE8) > gnuplot.sh13

gnuplot.sh14: $(DEMOS)
	shar $(DEMOS) > gnuplot.sh14

gnuplot.sh15: $(BETA)
	shar $(BETA) > gnuplot.sh15

