#
# $Id: makefile.unx,v 1.19.2.1 2011/12/09 07:05:35 sfeam Exp $
#
#
############################################################
#
# GNUPLOT 3.0 Makefile (Unix X11 support) for
#  Apollo/Sun/Dec5000/IBM-RS6000/HP9000/SGI/3B1/386IX/Cray
#
# 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 (#>>>).
#

.NOEXPORT:

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/local/man/man1
# where to install help file gnuplot.gih (note: this doesn't include gnuplot.gih)
HELPDEST=/usr/local/lib
#HELPDEST=docs
# Where to send email about bugs and comments (locally)
EMAIL=gnuplot-bugs@lists.sourceforge.net

############################################################
#>>> Some machines may need MAKE to be defined explicitly
MAKE   = make
#>>> Choose your C compiler and basic compiler flags.
# the C compiler
CC     = cc
# -O if you trust your compiler's optimizer
COPTS  =
# default loading command
LD     = $(CC) $(CFLAGS)
NPROC  = 2
# default installion command. On some systems, this doesn't exist or is
# incompatible. In this case just use cp. This should be handeled by the
# system specific make commands below. Please report systems that need this,
# so this can be added as default. (I think most SysV systems need this, but
# I'm not sure)
INSTALL=install
#INSTALL=cp
#
############################################################
#>>> 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.
#   Note: problems with gnuplot prompts have been noted when this feature
#   is selected on IBM RS/6000 AIX, and compile errors are encountered on
#   Sequent Dynix 3 and Convex OS 9.0. If seems to work with ConvexOS 10.1.
# HAVE_LIBREADLINE
#   If you want to use the more complex gnu version of readline, you can
#   define HAVE_LIBREADLINE instead of READLINE and add the appropriate library
#   file(s) to LIBS below.
# USE_CWDRC:
#   If USE_CWDRC is defined, then any .gnuplot in the current directory
#   is read on startup. This is a security consideration
#   especially for root users ( we recommend you do not define this ).
OPTIONS = -DREADLINE

#>>> 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
X11LIBS = -lX11

#>>> List where the X11 include directory is found (if other than /usr/include)
X11INCLUDES =

#>>> List additional CFLAGS for X11 compilation
# -DBSD_TYPES if your system defines FD_* macros for select in
#   <sys/bsdtypes.h>
# -ISC22 to circumvent missing plots past the first on ISC 2.2
X11FLAGS =

#>>> 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
#       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.
#  -DHAVE_COPY if you have bcopy() and no memcpy()
#  -DHAVE_STRNICMP if you have strnicmp()
#  -DHAVE_STRNCASECMP if you have strncasecmp() (GNU Libc, bsd)
#  -DGAMMA=foo if your gamma function is called foo().
#    Linux has lgamma(3m). The default is -DGAMMA=gamma.
#  -DHAVE_GETCWD if your unix uses getcwd() instead of getwd()
#    this is needed by HP-UX and Cray Unicos systems.
#  -DHAVE_GETWD if you have getwd()
#  -DULTRIX_KLUDGE if you run X windows on Ultrix and experience the
#    "every other plot" problem.
#  -DCRIPPLED_SELECT if "select errors" are encountered with X. This
#    option is needed on SVR3 platforms with incomplete support for
#    the BSD select() system call
#  -DXPG3_LOCALE if your system uses the 'setlocale' function to
#    support foreign charactersets (currently only ISO8859-1).
#  -Dunix is required to explicitly define "unix" for SCO and IBM
#          RS/6000 running AIX 3.2
#  -DHAVE_UNISTD_H if you have unistd.h
#  -DHAVE_LIBC_H if you have libc.h (NeXT)
#  -fswitch if you are compiling on a Sun3 (or even -f68881)
#    (but -fswitch is buggy on some systems, so watch out)
#  -DRETSIGTYPE=int if the argument to signal is an int function
#  -DSIGFUNC_NO_INT_ARG if the signal function may not have an int argument

# Defaults in case the user types 'make All' directly
# Should match X11_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.
#
# -DCGI         SCO CGI
# -DSUN         Sun Microsystems Workstation
# -DLINUXVGA	Linux PC with SuperVGA library
# -DUNIXPC      unixpc (ATT 3b1 or ATT 7300)
# -DX11         X11 Window System (This is $(PLOTXFLAG))
TERMFLAGS = -I. -Iterm $(PLOTXFLAG)

############################################################
# Library explanations.
#  You shouldn't need to adjust this; again, it is handled by the
# machine-dependent definitions below.
#
#  -lsuntool -lsunwindow -lpixrect  if you have -DSUN in TERMFLAGS
#  -lccgi if -DCGI in TERMFLAGS
#  -lvga if -DLINUXVGA in TERMFLAGS
#  -lreadline (or -Lsomewhere libreadline.a) if you use the gnu version
#  -ltermcap might be necessary after -lreadline
LIBS = -lm # -lplot is no longer shipped on SUNs

####################################################################
# 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 plot2d.o plot3d.o readline.o \
       scanner.o set.o show.o specfun.o standard.o stdfn.o term.o time.o \
       util.o binary.o interpol.o fit.o matrix.o datafile.o alloc.o \
       util3d.o hidden3d.o variable.o stats.o

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

DEC_OSF_FLAGS = \
           CFLAGS="$(COPTS) $(OPTIONS) -I/usr/sys/include -I/usr/sys/BINARY -DANSI -DGAMMA=lgamma -D_XOPEN_SOURCE" \
           LIBS="$(LIBS) -ldnet_stub" \
           X11FLAGS="$(X11FLAGS) -DMOTIF -D_NO_PROTO -D_OSF_SOURCE" \
           X11INCLUDES="$(X11INCLUDES) -I/usr/include/Xm" \
           X11LIBS="$(X11LIBS) -ldnet_stub" \
           PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
           X11INSTALL="$(X11INSTALL)" \
           TERMFLAGS="$(TERMFLAGS) "

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

HP8_FLAGS = \
           CFLAGS="$(COPTS) $(OPTIONS) -DHAVE_GETCWD" \
           LIBS=$(LIBS) X11FLAGS="$(X11FLAGS)" \
           X11INCLUDES="-I/usr/include/X11R4" \
           X11LIBS="-L/usr/lib/X11R4 -lX11" \
           PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
           X11INSTALL="$(X11INSTALL)" \
           TERMFLAGS="-I. -Iterm -DX11"

HP9_FLAGS = \
           CFLAGS="$(COPTS) $(OPTIONS) -Ae -DHAVE_GETCWD" \
           LIBS=$(LIBS) X11FLAGS="$(X11FLAGS)" \
           X11INCLUDES="-I/usr/include/X11R5" \
           X11LIBS="-L/usr/lib/X11R5 -lX11" \
           PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
           X11INSTALL="$(X11INSTALL)" \
           TERMFLAGS="-I. -Iterm -DX11" \
           MFLAGS="CFLAGS=\"-Ae -I.. -I../term\""

SOLARIS_X11_FLAGS = \
           CFLAGS="$(COPTS) $(OPTIONS) -DHAVE_UNISTD_H -DHAVE_GETCWD -DHAVE_SYS_SYSTEMINFO_H -DHAVE_SYSINFO" \
           X11FLAGS="$(X11FLAGS)" X11INCLUDES="$(X11INCLUDES)" \
           X11LIBS="$(X11LIBS) -lsocket" \
           X11INCLUDES="-I$$OPENWINHOME/include $(X11INCLUDES)" \
           PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
           X11INSTALL="$(X11INSTALL)" \
           TERMFLAGS="$(TERMFLAGS) -DHAVE_SYS_SYSTEMINFO_H -DHAVE_SYSINFO"

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

SUN_X11_FLAGS = \
           CFLAGS="$(COPTS) $(OPTIONS)" \
           LIBS="-L$$OPENWINHOME/lib $(LIBS)" \
           X11FLAGS="$(X11FLAGS)" \
           X11INCLUDES="-I$$OPENWINHOME/include $(X11INCLUDES)" \
           X11LIBS="$(X11LIBS)" \
           PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
           X11INSTALL="$(X11INSTALL)" \
           TERMFLAGS="$(TERMFLAGS)"

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

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

3B2_FLAGS = \
           CFLAGS="$(COPTS) $(OPTIONS) -DHAVE_GETCWD" \
           X11FLAGS=" " X11INCLUDES=" " \
           X11LIBS=" " \
           PLOTXFLAG=" " GNUPLOT_X11=" " X11INSTALL=x11_noinstall \
           TERMFLAGS="-I. -Iterm" LIBS="$(LIBS) -lplot"

386IX_FLAGS = \
           CFLAGS="$(COPTS) $(OPTIONS) -DHAVE_GETCWD -DTCSETSW -DTCGETS" \
           LIBS="$(LIBS) -lcposix" X11FLAGS=" " X11INCLUDES=" " \
           X11LIBS=" " PLOTXFLAG=" " GNUPLOT_X11=" " \
           X11INSTALL=x11_noinstall \
           TERMFLAGS="-I. -Iterm"

386IX_X11_FLAGS = \
           CFLAGS="$(COPTS) $(OPTIONS) -DHAVE_GETCWD -DTCSETSW -DTCGETS" \
           LIBS="$(LIBS) -lcposix" X11FLAGS="$(X11FLAGS)" X11INCLUDES="$(X11INCLUDES)" \
           X11LIBS="$(X11LIBS)" PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11="$(GNUPLOT_X11)" \
           X11INSTALL= "$(X11INSTALL)" \
           TERMFLAGS="-I. -Iterm -DX11"

ISC22_X11_FLAGS = \
           CFLAGS="$(COPTS) $(OPTIONS) -DHAVE_GETCWD -DISC22" \
           LIBS="$(LIBS) -lplot -lcposix" X11FLAGS="$(X11FLAGS)" X11INCLUDES="$(X11INCLUDES)" \
           X11LIBS="$(X11LIBS) -linet -lpt -lcposix" PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11="$(GNUPLOT_X11)" \
           X11INSTALL= "$(X11INSTALL)" \
           TERMFLAGS="-I. -Iterm -DX11"

AIX_FLAGS = \
           CFLAGS="$(COPTS) $(OPTIONS) -DERF -DGAMMA=gamma -DXPG3_LOCALE -Dunix" \
           LIBS="$(LIBS) -lbsd" X11FLAGS="$(X11FLAGS)" \
           X11INCLUDES="$(X11INCLUDES)" \
           X11LIBS="$(X11LIBS)" \
           PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
           X11INSTALL="$(X11INSTALL)" \
           TERMFLAGS="$(TERMFLAGS) -qmaxmem=9000"

AIXO_FLAGS = \
           CFLAGS="$(COPTS) $(OPTIONS) -DGAMMA=gamma -DXPG3_LOCALE -Dunix" \
           LIBS="$(LIBS) -lbsd" X11FLAGS="$(X11FLAGS)" \
           X11INCLUDES="$(X11INCLUDES)" \
           X11LIBS="$(X11LIBS)" \
           PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
           X11INSTALL="$(X11INSTALL)" \
           TERMFLAGS="$(TERMFLAGS)"

NEXT_FLAGS = \
           CFLAGS="$(COPTS) -DGAMMA=lgamma -DNEXT -DREADLINE -DHAVE_SGTTY_H -DHAVE_STRNCASECMP -DHAVE_LIBC_H $(OPTIONS)" \
           LIBS="-lNeXT_s -lsys_s $(LIBS)" \
           X11FLAGS="$(X11FLAGS)" \
           X11INCLUDES=" " X11LIBS=" " PLOTXFLAG=" " \
           GNUPLOT_X11=" " X11INSTALL=x11_noinstall \
           TERMFLAGS="-I. -Iterm -ObjC -DANSI" OBJS=" $(OBJS) $(NEXTOBJS)"

NEXT_X11_FLAGS = \
           CFLAGS="$(COPTS) -DGAMMA=lgamma -DNEXT -DREADLINE -DHAVE_SGTTY_H -DHAVE_STRNCASECMP -DX_NOT_POSIX -DHAVE_LIBC_H $(OPTIONS)" \
           LIBS="-lNeXT_s -lsys_s $(LIBS)" \
           X11LIBS="-L/usr/lib/X11 -lX11" \
           X11INCLUDES="$(X11INCLUDES)" X11FLAGS="$(X11FLAGS)" \
           PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
           X11INSTALL="$(X11INSTALL)" \
           TERMFLAGS="-I. -Iterm -DX11 -ObjC -DANSI" OBJS=" $(OBJS) $(NEXTOBJS)"

CRAY_FLAGS = \
       CFLAGS="$(COPTS) $(OPTIONS) -DHAVE_GETCWD" \
       LIBS="$(LIBS)" X11FLAGS=" " \
       X11INCLUDES=" " \
       X11LIBS=" " \
       PLOTXFLAG=" " GNUPLOT_X11=" " \
       X11INSTALL=x11_noinstall \
       TERMFLAGS="-I. -Iterm"

CRAY_X11_FLAGS = \
       CFLAGS="$(COPTS) $(OPTIONS) -DHAVE_GETCWD" \
       LIBS="$(LIBS)" X11FLAGS="$(X11FLAGS)" \
       X11INCLUDES="$(X11INCLUDES)" \
       X11LIBS="$(X11LIBS)" \
       PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11="$(GNUPLOT_X11)" \
       X11INSTALL=$(X11INSTALL) \
       TERMFLAGS="-I. -Iterm -DX11"

PTX_X11_FLAGS = \
       CFLAGS="$(COPTS) $(OPTIONS) -DHAVE_GETCWD -DCRIPPLED_SELECT" \
       LIBS="$(LIBS) -lplot" X11FLAGS="$(X11FLAGS)" \
       X11INCLUDES="$(X11INCLUDES)" \
       X11LIBS="-lX11 -lseq -lsocket -linet -lnsl" \
       PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11="$(GNUPLOT_X11)" \
       X11INSTALL=$(X11INSTALL) \
       TERMFLAGS="$(TERMFLAGS)"

SEQUENT_X11_FLAGS = \
       CFLAGS="$(COPTS) $(OPTIONS) -DHAVE_SGTTY_H -DCRIPPLED_SELECT" \
       LIBS="$(LIBS) -lplot" X11FLAGS="$(X11FLAGS) -DX_WCHAR" \

       X11INCLUDES="$(X11INCLUDES)" \
       X11LIBS="-lX11 -lseq " \
       PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11="$(GNUPLOT_X11)" \
       X11INSTALL=$(X11INSTALL) \
       TERMFLAGS="$(TERMFLAGS)"

# Convex X11 uses -O1 for scalar optimization only

CONVEX_X11_FLAGS = \
           CFLAGS="$(COPTS) $(OPTIONS) -DHUGE=8.9e307 -O1" \
           LIBS="$(LIBS)" X11FLAGS="$(X11FLAGS)" X11INCLUDES="$(X11INCLUDES)" \
           X11LIBS="$(X11LIBS)" \
           PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
           X11INSTALL="$(X11INSTALL)" \
           TERMFLAGS="$(TERMFLAGS)"

OSF_FLAGS = \
           CFLAGS="$(COPTS) $(OPTIONS) -I/usr/sys/include -I/usr/sys/BINARY -DANSI -D_XOPEN_SOURCE -D__osf__" \
           LIBS="$(LIBS)" \
           X11FLAGS="$(X11FLAGS) -DMOTIF -D_NO_PROTO -D_OSF_SOURCE" \
           X11INCLUDES="$(X11INCLUDES) -I/usr/include/Xm" \
           X11LIBS="$(X11LIBS)" \
           PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
           X11INSTALL="$(X11INSTALL)" \
           TERMFLAGS="$(TERMFLAGS) "

LINUX_FLAGS = \
           CFLAGS="$(COPTS) $(OPTIONS) -DHAVE_STRNCASECMP -DGAMMA=lgamma -DHAVE_UNISTD_H -DLINUXVGA -D PROTOTYPE__P" \
           LIBS="-lvga $(LIBS)" \
           X11FLAGS="$(X11FLAGS)" \
           X11INCLUDES="-I/usr/X386/include $(X11INCLUDES)" \
           X11LIBS="-L/usr/X386/lib $(X11LIBS)" \
           PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
           X11INSTALL="$(X11INSTALL)" \
           TERMFLAGS="$(TERMFLAGS) -DX11"

####################################################################
# List of source files
# Used for making shar files, lint, and some dependencies.
DIRS = term demo docs docs/latextut

CSOURCE1 = bf_test.c binary.c command.c set.c show.c
CSOURCE2 = help.c graphics.c graph3d.c internal.c
CSOURCE3 = misc.c eval.c parse.c plot.c plot2d.o plot3d.o readline.c scanner.c standard.c stdfn.c
CSOURCE4 = bitmap.c term.c time.c util.c version.c fit.c matrix.c variable.c tabulate.c stats.c
CSOURCE5 = term/ai.trm term/aed.trm \
	term/cgi.trm term/corel.trm \
	term/djsvga.trm term/dumb.trm \
	term/dxf.trm term/dxy.trm term/debug.trm \
	term/emxvga.trm term/eepic.trm term/epson.trm term/excl.trm \
	term/fig.trm term/grass.trm term/hp26.trm term/hp2648.trm term/hpgl.trm \
	term/hp500c.trm term/hpljii.trm term/metafont.trm\
	term/hppj.trm
CSOURCE6 = term/impcodes.h term/imagen.trm term/next.trm term/object.h \
	term/kyo.trm term/latex.trm term/mif.trm \
	term/pbm.trm term/pslatex.trm term/gpic.trm
CSOURCE7 = term/post.trm term/pstricks.trm term/qms.trm term/regis.trm \
	term/sun.trm\
	term/t410x.trm term/tek.trm term/texdraw.trm \
	term/tgif.trm term/tpic.trm \
	term/unixpc.trm \
	term/v384.trm term/vws.trm term/x11.trm term/xlib.trm term/linux.trm
CSOURCE8 = contour.c specfun.c gplt_x11.c interpol.c
CONFIGURE = configure configure.in Makefile.in docs/Makefile.in\
	docs/latextut/Makefile.in
NEXTSRC  = epsviewe.m epsviewe.h
# not C code, but still needed

DEMOS = demo/1.dat demo/2.dat demo/3.dat demo/contours.dem \
	demo/controls.dem demo/electron.dem demo/glass.dat demo/param.dem \
	demo/polar.dem demo/simple.dem demo/surface1.dem \
	demo/surface2.dem demo/using.dat demo/using.dem demo/world.cor \
	demo/world.dat demo/world.dem \
	demo/err.dat demo/poldat.dem demo/errorbar.dem \
	demo/all.dem demo/animate.dem demo/bivariat.dem \
	demo/prob.dem demo/stat.inc demo/prob2.dem demo/random.dem \
	demo/discrete.dem demo/hidden.dem demo/airfoil.dem demo/gnuplot.rot\
	demo/binary.dem demo/spline.dem demo/steps.dem demo/steps.dat \
	demo/multimsh.dem demo/whale.dat demo/hemisphr.dat \
	demo/scatter.dem demo/scatter2.dat demo/singulr.dem demo/klein.dat

ETC = Copyright 0README README.gnu makefile.unx makefile.vms \
	linkopt.amg makefile.amg linkopt.vms buildvms.com \
	lasergnu makefile.r makefile.nt makefile.g 0FAQ 0BUGS\
	term/README History gnuplot.el intergra.x11 0INSTALL README.3p1\
	README.3p2 README.3p3 README.3p4 README.pro README.nex README.x11 \
	README.3d README.mf README.win README.iso README.3p5 README.pic \
	README.xli $(CONFIGURE)

#BETA files (not standard distribution files)
BETA = 
# PC-specific files
PC = corgraph.asm corplot.c header.mac hrcgraph.asm lineproc.mac \
	makefile.djg pcgraph.asm makefile.emx term/pc.trm 
WINDOWS = makefile.win makefile.msw README.win win/wcommon.h \
	win/wgnuplib.c win/wgnuplib.h win/wgnuplib.rc \
	win/wgnuplot.hpj win/wgnuplot.mnu win/wgnuplot.rc \
	win/wgraph.c win/winmain.c win/wmenu.c win/wpause.c \
	win/wprinter.c win/wresourc.h win/wtext.c win/wtext.h \
	win/geticon.c docs/doc2rtf.c term/win.trm
OS2 = makefile.os2 os2/makefile os2/dialogs.c os2/dialogs.h os2/gclient.c \
	os2/gnuicon.uue os2/gnupmdrv.c os2/gnupmdrv.def os2/gnupmdrv.h \
	os2/gnupmdrv.itl os2/gnupmdrv.rc os2/print.c docs/doc2ipf.c \
	README.os2 term/pm.trm

# Documentation and help files
DOCS1 = docs/makefile docs/README docs/checkdoc.c docs/doc2gih.c \
	docs/doc2hlp.c docs/doc2hlp.vms docs/doc2ms.c docs/doc2tex.c \
	docs/gnuplot.1 docs/lasergnu.1 docs/toc_entr.sty docs/doc2info.pl \
	docs/titlepag.ms docs/titlepag.tex \
	docs/doc2rtf.c
DOCS2 = docs/gnuplot.doc docs/gpcard.tex
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/linepoin.plt

#########################################################################
# Default target (informational)
info:
	@echo "Please do a 'make <MACHINE>' where <MACHINE> is one of the following:"
	@echo
	@echo "dec_osf      for Dec3100/5000 running DEC OSF/1 v1.0"
	@echo "dec          for Dec3100/5000 running Ultrix 3.1d with MIT's X11"
	@echo "hp8          for HP/9000 700 series running HP/UX 8.0 with MIT's X11R4"
	@echo "hp           for HP/9000 700 series running HP/UX 9.01 with MIT's X11R5"
	@echo "sun          for Sun sparcstation running SunOS 4.1 with suntools (no X11) "
	@echo "sun_x11      for Sun sparcstation running SunOS 4.1 with suntools and X11 "
	@echo "solaris_x11  for Sun Sparcstation running Solaris 2 with X11 "
	@echo "next         for NeXT Cube and Slab running NeXTOS 2.0+ (no X11)"
	@echo "next_x11     for NeXT Cube and Slab running NeXTOS 2.0+ with X11"
	@echo "3b1          for ATT 3b1 machines (no X11) "
	@echo "3b2          for ATT 3b2 machines (no X11) "
	@echo "386ix        for 386 machines running 386/ix (no X11)"
	@echo "386ix_x11    for 386 machines running 386/ix with T.Roell X386"
	@echo "isc22_x11    for 386 machines running ISC 2.2 with T.Roell X386"
	@echo "aix32        for IBM RS/6000 running AIX 3.2 with xlc 1.2"
	@echo "aix32o       for IBM RS/6000 running AIX 3.2 with xlc 1.1"
	@echo "x11          for a generic machine (like a sun or dec) with MIT's X11"
	@echo "cray         for Cray Y-MP or Cray-2 running Unicos 6.0 or 6.1 (no X11)"
	@echo "cray_x11     for Cray Y-MP or Cray-2 running Unicos 6.0 or 6.1 with X11"
	@echo "ptx_x11      for Sequent Dynix/PTX with MIT X11"
	@echo "sequent_x11  for Sequent Symmetry (DYNIX 3) with X11"
	@echo "convex_x11   for Convex 9.0 or up with MIT X11"
	@echo "osf          for KSR1 running DEC OSF/1 v1.0 (use make -j 16)"
	@echo "linux        for LINUX with XFree86 or vgalib"
	@echo
	@echo "Examples:"
	@echo
	@echo "         make x11"
	@echo "         make dec"
	@echo "         make hp"
	@echo "         make next"
	@echo "         make solaris_x11"
	@echo "         make sun          HELPDEST='/usr/um/misc/lib' "
	@echo "         make sun          X11INCLUDES='-I/usr/local/include' "
	@echo "         make sun_x11"
	@echo "         make sgi"
	@echo "         make 3b1"
	@echo "         make 386ix"
	@echo "         make 386ix_x11"
	@echo "         make isc22_x11"
	@echo "         make aix32        MANDEST='/usr/um/misc/man/man1' COPTS='-O' "
	@echo "         make cray"
	@echo "         make cray_x11"
	@echo
	@echo "If you just type 'make All' , it will build gnuplot for Unix X11"
	@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

x11:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(X11_FLAGS)      $(TARGET)

dec_osf:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(DEC_OSF_FLAGS)  $(TARGET)

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

hp8:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(HP8_FLAGS)       $(TARGET)

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

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

next_x11:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(NEXT_X11_FLAGS) $(TARGET)

solaris_x11:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(SOLARIS_X11_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)

3b2:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(3B2_FLAGS)      $(TARGET)

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

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

isc22_x11:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(ISC22_X11_FLAGS) $(TARGET)

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

aix32o:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(AIXO_FLAGS)     $(TARGET)

cray:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(CRAY_FLAGS)     $(TARGET)

cray_x11:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(CRAY_X11_FLAGS) $(TARGET)

ptx_x11:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(PTX_X11_FLAGS)  $(TARGET)

sequent_x11:
	make $(MFLAGS) $(MY_FLAGS) $(SEQUENT_X11_FLAGS) $(TARGET)

convex_x11:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(CONVEX_X11_FLAGS) $(TARGET)

osf:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(OSF_FLAGS)  $(TARGET)

linux:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(LINUX_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 demo/binary1

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

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

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

demo/binary1 demo/binary2 demo/binary3: bf_test
	( cd demo; ../bf_test )

bf_test: bf_test.o binary.o alloc.o
	$(CC) $(CFLAGS) bf_test.o binary.o alloc.o -lm -o bf_test
################################################################
# Installation instructions

install:
	@echo
	@echo "Please do a 'make <MACHINE> TARGET=Install' where <MACHINE> is one of the following:"
	@echo
	@echo "dec, hp, sun, sun_x11, sgi, sgix11, cgi,"
	@echo "next, next_x11, 3b1, 386ix, 386ix_x11, aix32, aix32o,"
	@echo "x11, cray, cray_x11, ptx_x11, sequent_x11, convex_x11"
	@echo
	@echo "Examples:"
	@echo
	@echo "         make x11          TARGET=Install "
	@echo "         make dec          TARGET=Install "
	@echo "         make hp           TARGET=Install "
	@echo "         make sun          TARGET=Install HELPDEST='/usr/um/misc/lib BINDIR='/usr/um/misc/bin' "
	@echo "         make aix32        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) $(MY_FLAGS) install-unix HELPDEST=$(HELPDEST) INSTALL="$(INSTALL)")

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: version.c
	$(CC) $(CFLAGS) -DCONTACT=\"$(EMAIL)\" -c version.c

epsviewe.o : epsviewe.h epsviewe.m
	$(CC) -ObjC -c epsviewe.m

$(OBJS): plot.h

command.o: command.c binary.h fit.h plot.h
	$(CC) $(CFLAGS) -c command.c -DHELPFILE=\"$(HELPDEST)/gnuplot.gih\"

show.o: show.c plot.h setshow.h
	$(CC) $(CFLAGS) -DHELPFILE=\"$(HELPFILE)\" -DBINDIR=\"$(DEST)\" -c $<


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

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

fit.o: fit.c fit.h matrix.h plot.h

matrix.o: matrix.c matrix.h fit.h

bitmap.o term.o: bitmap.h

variable.o: variable.c plot.h variable.h

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

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

DOCS  = $(DOCS1) $(DOCS2) $(DOCS3)

lint:
	lint -hx $(SOURCES)

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

spotless:
	rm -f *.o *~ *.orig *.rej *.bak term/*~ term/*.orig term/*.bak \
	TAGS gnuplot gnuplot_x11 bf_test demo/binary[1-3] \
	demo/temp.set demo/defaults.ini
	( 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.sh16

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: $(WINDOWS)
	shar $(WINDOWS) > gnuplot.sh15

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

tar: $(ETC) $(SOURCES) $(PC) $(DEMOS) $(BETA) $(DOCS) 
	$(TAR) cvf /tmp/gnuplot.tar $(ETC) $(SOURCES) $(PC)\
	     $(DEMOS) $(BETA) $(DOCS) 
#
# the following uses Rick Saltz's makekit shar generation tools
#

kit: $(ETC) $(SOURCES) $(PC) $(DEMOS) $(BETA) $(DOCS) 
	makekit -s135k -k30 $(ETC) $(SOURCES) $(PC)\
	     $(DEMOS) $(BETA) $(DOCS) 

branch: rcs rcsdoc rcsdemo

rcs:
	rcs -b$(RCSVER) $(ETC) $(SOURCES) $(PC) 

rcsdoc:
	rcs -b$(RCSVER) $(DOCS)

rcsdemo:
	rcs -b$(RCSVER) $(DEMOS)

ciall: ci cidoc cidemo

ci:
	ci -l$(RCSVER) -m$(RCSCOM) -t-$(RCSCOM) $(SOURCES) $(PC) $(ETC) 

cidoc:
	ci -l$(RCSVER) -m$(RCSCOM) -t-$(RCSCOM) $(DOCS)

cidemo:
	ci -l$(RCSVER) -m$(RCSCOM) -t-$(RCSCOM) $(DEMOS)

ciforce:
	ci -f$(RCSVER) -m$(RCSCOM) -t-$(RCSCOM) $(SOURCES) $(ETC) $(DOCS) $(DEMOS) $(PC)

coall: co codoc codemo

co:
	co -l -r$(RCSVER) $(ETC) $(SOURCES) $(PC)

codoc:
	co -l -r$(RCSVER) $(DOCS)

codemo:
	co -l -r$(RCSVER) $(DEMOS)
