$ ! CONFIGURE.VMS -- configure command file for VMS
$ !
$ ! Writen by John.Hasstedt@sunysb.edu.  This command file creates config.h
$ ! and either a make file or a command file.  These files are based on the
$ ! makefile.vms and buildvms.com files distributed with previous versions
$ ! of gnuplot.
$ !
$ ! Options are specified on the command line.  I just set symbols on the
$ ! command line to 1.  This is rather crude, but it works.
$ !
$ ! The options are:
$ !
$ ! DECC, GNUC, VAXC -- The compiler.  I have only tested this with DECC.
$ ! MMS, MMK, MAK, COM -- The build procedure.  If you specify MMS or MMK,
$ !    you get DESCRIP.MMS in the [.SRC] directory; if you specify MAK,
$ !    you get MAKEFILE. in the [.SRC] directory; if you specify COM, you
$ !    get BUILD.COM in the [.SRC] directory.
$ ! Use MMS or MMK with /IGNORE to prevent warnings to stop the building
$ ! process.
$ ! DECC$CRTL -- Use the DECC$CRTL backport library.  See
$ !    SYS$LIBRARY:DECC$CRTL.README for information on it.
$ ! READLINE -- Use the included readline function.
$ ! USE_MOUSE -- Include the mouse code
$ !
$ ! For example,
$ !     @CONFIGURE.VMS GNUC MAK
$ ! will create [.SRC]MAKEFILE. with commands for building with GNUC.
$ !
$ ! makefile.vms had the comments:
$ ! -------------------------------------------------------------------------
$ ! use with the MAKE that was posted by Tony Ivanov (tony@gvgpvd.GVG.TEK.COM)
$ ! in comp.os.vms on 5 December 1988
$ !
$ ! Modified 23 June 1999 to work with MMK; it should also work with MMS.
$ ! John.Hasstedt@sunysb.edu.
$ ! -------------------------------------------------------------------------
$ !
$ ! buildvms.com had the comment:
$ ! -------------------------------------------------------------------------
$ ! lph: modified for compatibility with VMS 4.x (which lacks 'if ... endif'),
$ ! but made the default DECC
$ ! -------------------------------------------------------------------------
$ !
$ ! I have tried to maintain compatibility with V4.x--I have not used
$ ! 'if ... endif' or 'gosub'; however, I do not have a V4.x system to test
$ ! it on.
$ !
$ ! The comments below are from buildvms.com about defining CFLAGS on
$ ! different platforms.  If you have problems compiling, these comments
$ ! may help.  If you need to change CFLAGS, you can change it below, or
$ ! you can change it in the make file this file generates.  Most of the
$ ! defines are not necessary because I now use config.h.
$ !
$ !-----------------------------------------------------------------
$ ! A generic starting point
$ !
$ !$ CFLAGS = "/NOWARN/NOOP/DEFINE=(''x11'NO_GIH,PIPES,''rtl')''pfix'"
$ !
$ ! ----------------------------------------------------------------
$ !
$ ! For  VMS 4.7 and VAX C v2.4
$ ! ("Compiler abort - virtual memory limits exceeded" if attempt
$ !  to include all applicable terminals, but otherwise builds OK.
$ !  Runtime problem: an exit handler error, also w/ gcc build;
$ !  a VAXCRTL atexit bug?)
$ !
$ ! Note: VAX uses  D_FLOAT, maximum exponent ca 10e +/- 38;
$ !       will cause problems with some of the demos
$ !
$ !$ CFLAGS    = "/NOOP/DEFINE=(HAVE_GETCWD, HAVE_SLEEP, "-
$ !               +"SHORT_TERMLIST, NO_GIH,PIPES, ''rtl')"
$ !$ !
$ !
$ !-----------------------------------------------------------------
$ !
$ ! This will build with gcc v1.42 on VMS 4.7
$ ! (no virtual memory limit problem)
$ !
$ ! gcc v1.42 string.h can prefix str routines w/ gnu_ (ifdef GCC_STRINGS)
$ ! but the routines in GCCLIB are not prefixed w/ gcc_  :-(
$ ! link with GCCLIB, then ignore the link warnings about multiple
$ ! definitions of STR... in C$STRINGS
$ !
$ ! GCC v1.42 has a locale.h, but neither gcc nor VMS v4.7 VAXCRTL has
$ ! the  setlocale function
$ !
$ !
$ ! Note: _assert.c defines assert_gcc, if ndef NDEBUG, but
$ !        cgm.trm undefines NDEBUG, so we always compile/link  _assert.c
$ !
$ !$ CFLAGS    = "/NOOP/DEFINE=(''x11', HAVE_GETCWD,"-
$ !		+" HAVE_SLEEP, NO_GIH, PIPES, ''rtl')"
$ !
$ !-----------------------------------------------------------------
$ VAXC = 0
$ GNUC = 0
$ DECC = 0
$ MMS = 0
$ MMK = 0
$ MAK = 0
$ COM = 0
$ DECC$CRTL = 0
$ READLINE = 0
$ USE_MOUSE = 0
$ !
$ IF (P1 .NES. "") THEN 'P1' = 1
$ IF (P2 .NES. "") THEN 'P2' = 1
$ IF (P3 .NES. "") THEN 'P3' = 1
$ IF (P4 .NES. "") THEN 'P4' = 1
$ IF (P5 .NES. "") THEN 'P5' = 1
$ IF (P6 .NES. "") THEN 'P6' = 1
$ IF (P7 .NES. "") THEN 'P7' = 1
$ IF (P8 .NES. "") THEN 'P8' = 1
$ !
$ ! Get compiler.  I first check if the compiler was specified on the command
$ ! line.  If it wasn't, I check for what compiler is on the system.  If
$ ! there are several options, I use DECC, then GNUC, then VAXC.
$ !
$ COMPILER = ""
$ IF (VAXC) THEN COMPILER = "VAXC"
$ IF (GNUC) THEN COMPILER = "GNUC"
$ IF (DECC) THEN COMPILER = "DECC"
$ IF (COMPILER .NES. "") THEN GOTO HAVECOMPILER
$ VAXC = 1
$ GNUC = F$TRNLNM("GNU_CC") .NES. ""
$ DECC = F$SEARCH("SYS$SYSTEM:DECC$COMPILER.EXE") .NES. ""
$ IF (VAXC) THEN COMPILER = "VAXC"
$ IF (GNUC) THEN COMPILER = "GNUC"
$ IF (DECC) THEN COMPILER = "DECC"
$HAVECOMPILER:
$ !
$ ! Get the make tool.  I first check if the tool was specified on the command
$ ! line.  If it wasn't, I check for what tool is on the system.  If there are
$ ! several options, I use MMS, then MMK, then MAKE, then the command file.
$ !
$ MAKETOOL = ""
$ IF (COM) THEN MAKETOOL = "COM"
$ IF (MAK) THEN MAKETOOL = "MAKE"
$ IF (MMK) THEN MAKETOOL = "MMK"
$ IF (MMS) THEN MAKETOOL = "MMS"
$ IF (MAKETOOL .NES. "") THEN GOTO HAVEMAKETOOL
$ COM = 1
$ MAK = F$TYPE(MAKE) .NES. ""
$ MMK = F$TYPE(MMK) .NES. ""
$ MMS = F$SEARCH("SYS$SYSTEM:MMS.EXE") .NES. ""
$ IF (COM) THEN MAKETOOL = "COM"
$ IF (MAK) THEN MAKETOOL = "MAKE"
$ IF (MMK) THEN MAKETOOL = "MMK"
$ IF (MMS) THEN MAKETOOL = "MMS"
$HAVEMAKETOOL:
$ !
$ ! Check if the system has DECWindows.
$ ! Commented out because building "gnuplot_x11.exe" is currently
$ ! not successful.
$ !
$ ! DECW = F$TRNLNM("DECW$INCLUDE") .NES. ""
$ DECW = 0
$ !
$ ! Get the architecture.
$ !
$ ALPHA = F$GETSYI("HW_MODEL") .GE. 1024
$ !
$ ! Define symbols for things that vary with compiler:  RTL (run time library),
$ ! DPML (Digital Portable Math Library), and __CRTL_VER (DECC RTL version).
$ !
$ DECC = 0
$ GNUC = 0
$ VAXC = 0
$ GOTO 'COMPILER'
$ !
$DECC:
$ DECC = 1
$ RTL = "DECCRTL"
$ DPML = F$SEARCH("SYS$LIBRARY:DPML$SHR.EXE") .NES. ""
$ IF (DECC$CRTL) THEN DEFINE/NOLOG DECC$CRTLMAP SYS$LIBRARY:DECC$CRTL.EXE
$ EXTRALIB = ""
$ IF (DECC$CRTL) THEN EXTRALIB = ",SYS$LIBRARY:DECC$CRTL.OLB/LIBRARY"
$ CC/OBJECT=DEFINE_CRTL_VER.OBJ SYS$INPUT
      #include <stdlib.h>
      #include <stdio.h>
      #include <descrip.h>
      #include <lib$routines.h>
      #ifndef __CRTL_VER
      #   define __CRTL_VER __VMS_VER
      #endif
      main () {
      static $DESCRIPTOR(crtl,"__CRTL_VER");
      struct dsc$descriptor_s val = {0, DSC$K_DTYPE_T, DSC$K_CLASS_S, 0};
      static int tab = {1};
      char str[10];
      val.dsc$w_length = sprintf (str, "%d", __CRTL_VER);
      val.dsc$a_pointer = str;
      exit (lib$set_symbol (&crtl, &val, &tab));
      }
$ LINK/EXECUTABLE=DEFINE_CRTL_VER.EXE DEFINE_CRTL_VER.OBJ'EXTRALIB'
$ RUN DEFINE_CRTL_VER.EXE
$ DELETE/NOCONFIRM/NOLOG DEFINE_CRTL_VER.OBJ;*,DEFINE_CRTL_VER.EXE;*
$ IF (DECC$CRTL) THEN DEASSIGN DECC$CRTLMAP
$ __CRTL_VER = F$INTEGER(__CRTL_VER)
$ GOTO COMPILERDONE
$ !
$GNUC:
$ GNUC = 1
$ IF (ALPHA) THEN RTL = "DECCRTL"
$ IF (.NOT. ALPHA) THEN RTL = "VAXCRTL"
$ IF (ALPHA) THEN DPML = F$SEARCH("SYS$LIBRARY:DPML$SHR.EXE") .NES. ""
$ IF (.NOT. ALPHA) THEN DPML = 0
$ __CRTL_VER = 0
$ GOTO COMPILERDONE
$ !
$VAXC:
$ VAXC = 1
$ RTL = "VAXCRTL"
$ DPML = 0
$ __CRTL_VER = 0
$ GOTO COMPILERDONE
$ !
$COMPILERDONE:
$ !
$ WRITE SYS$OUTPUT "Compiler:         ", COMPILER
$ WRITE SYS$OUTPUT "Make Tool:        ", MAKETOOL
$ WRITE SYS$OUTPUT "Run time library: ", RTL
$ IF (__CRTL_VER .NE. 0) THEN WRITE SYS$OUTPUT "CRTL version:     ", __CRTL_VER
$ WRITE SYS$OUTPUT "Use DECC$CRTL:    ", DECC$CRTL
$ WRITE SYS$OUTPUT "Use readline:     ", READLINE
$ WRITE SYS$OUTPUT "Use mouse:        ", USE_MOUSE
$ !
$ ! Read in config.hin and write config.h.  Define DCL symbols for all the
$ ! symbols in config.hin, then write config.h, replacing the #undef with
$ ! #define where necessary.  Defining a symbol as 0 means to leave it #undef;
$ ! defining it as 1 means to define it; defining it as a string means it
$ ! should be defined as a string.
$ !
$ const = 0
$ HAVE_STRINGIZE = DECC
$ inline = 0
$ RETSIGTYPE = "void"
$ size_t = 0
$ STAT_MACROS_BROKEN = 0
$ STDC_HEADERS = DECC
$ X_DISPLAY_MISSING = 0
$ time_t = 0
$ HAVE_ATEXIT = DECC
$ HAVE_BCOPY = DECC
$ HAVE__BOOL = DECC
$ HAVE_BZERO = DECC
$ HAVE_DOPRNT = 0
$ HAVE_ERF = DPML
$ HAVE_ERFC = DPML
$ HAVE_GAMMA = 0
$ HAVE_GETCWD = 1
$ HAVE_INDEX = DECC
$ HAVE_LGAMMA = DECC .AND. ALPHA
$ HAVE_MEMCPY = DECC
$ HAVE_MEMMOVE = DECC
$ HAVE_MEMSET = DECC
$ HAVE_ON_EXIT = 0
$ HAVE_PCLOSE = __CRTL_VER .GE. 70000000
$ HAVE_POLL = 0
$ HAVE_POPEN = __CRTL_VER .GE. 70000000
$ HAVE_RINDEX = DECC
$ HAVE_SELECT = 0
$ HAVE_SETVBUF = DECC
$ HAVE_SLEEP = 1
$ HAVE_SNPRINTF = 0
$ HAVE_STPCPY = 0
$ HAVE_STRCASECMP = __CRTL_VER .GE. 70000000
$ HAVE_STRCHR = DECC
$ HAVE_STRCSPN = DECC
$ HAVE_STRDUP = __CRTL_VER .GE. 70000000
$ HAVE_STRERROR = DECC
$ HAVE_STRICMP = 0
$ HAVE_STRNCASECMP = __CRTL_VER .GE. 70000000
$ HAVE_STRNICMP = 0
$ HAVE_STRNLEN = DECC
$ HAVE_STRRCHR = DECC
$ HAVE_STRSTR = DECC
$ HAVE_SYSINFO = 0
$ HAVE_TCGETATTR = 0
$ HAVE_VFPRINTF = 0
$ HAVE_ERRNO_H = DECC
$ HAVE_FLOAT_H = DECC
$ HAVE_LIBC_H = 0
$ HAVE_LIMITS_H = DECC
$ HAVE_LOCALE_H = DECC
$ HAVE_MALLOC_H = 0
$ HAVE_MATH_H = DECC
$ HAVE_POLL_H = 0
$ HAVE_SGTTY_H = 0
$ HAVE_STDLIB_H = DECC
$ HAVE_STRING_H = DECC
$ HAVE_SYS_BSDTYPES_H = 0
$ HAVE_SYS_IOCTL_H = DECC
$ HAVE_SYS_PARAM_H = 0
$ HAVE_SYS_SELECT_H = 0
$ HAVE_SYS_SOCKET_H = DECC
$ HAVE_SYS_STAT_H = DECC
$ HAVE_SYS_SYSTEMINFO_H = 0
$ HAVE_SYS_TIME_H = DECC
$ HAVE_SYS_TIMEB_H = DECC
$ HAVE_SYS_TYPES_H = DECC
$ HAVE_SYS_UTSNAME_H = __CRTL_VER .GE. 70000000
$ HAVE_TERMIOS_H = 0
$ HAVE_TIME_H = DECC
$ HAVE_TIME_T_IN_TIME_H = DECC
$ HAVE_UNISTD_H = DECC
$ HAVE_VALUES_H = 0
$ HAVE_VFPRINTF = DECC
$ HAVE_LIBM = DECC
$ PACKAGE = 0
$ VERSION = 0
$ PROTOTYPES = DECC
$ X11 = DECW
$ GNUPLOT_X11 = 0
$ MSDOS = 0
$ DOS32 = 0
$ DJSVGA = 0
$ GRX21 = 0
$ EXTERN_ERRNO = 0
$ PIPES = __CRTL_VER .LT. 70000000
$ SELECT_TYPE_ARG1 = 0
$ SELECT_TYPE_ARG234 = 0
$ SELECT_TYPE_ARG5 = 0
$ LINUXVGA = 0
$ HAVE_LIBREADLINE = 0
$ GNUPLOT_HISTORY = 0
$ ! READLINE = 0    ! READLINE is defined above
$ HAVE_LIBGD = 0
$ HAVE_LIBPNG = 0
$ CGI = 0
$ SUN = 0
$ NOCWDRC = 0
$ THIN_PLATE_SPLINES_GRID = 0
$ COLUMN_HELP = 0
$ ! USE_MOUSE = 0   ! USE_MOUSE is defined above
$ MAX_PARALLEL_AXES = 7
$ !
$ OPEN/READ IN CONFIG.HIN
$ OPEN/WRITE OUT CONFIG.H
$CONFIGLOOP:
$ READ/END=CONFIGDONE IN REC
$ IF (F$ELEMENT(0," ",REC) .NES. "#undef") THEN GOTO WRITELINE
$ SYM = F$ELEMENT(1," ",REC)
$ IF (F$TYPE('SYM') .EQS. "") THEN GOTO NOSYMBOL
$ VAL = 'SYM'
$ IF (F$TYPE(VAL) .EQS. "STRING" .OR. VAL .NE. 0) THEN -
            REC = "#define " + SYM + " " + F$STRING(VAL)
$ GOTO WRITELINE
$NOSYMBOL:
$ WRITE SYS$OUTPUT "No DCL symbol for ", REC
$WRITELINE:
$ WRITE OUT REC
$ GOTO CONFIGLOOP
$CONFIGDONE:
$ CLOSE IN
$ CLOSE OUT
$ !
$ ! Get a list of files from [.src]makefile.all.  Skip lines until I find
$ ! COREOBJS =, then read and extract the file names until I find a line
$ ! that does not end in \.
$ !
$ OPEN/READ IN [.SRC]MAKEFILE.ALL
$FILELOOP1:
$ READ/END=DONE IN REC
$ IF (F$EXTRACT(0,8,REC) .NES. "COREOBJS") THEN GOTO FILELOOP1
$ REC = REC - "COREOBJS" - "="
$ REC = REC - ".$(O)" - ".$(O)" - ".$(O)" - ".$(O)" - ".$(O)" - ".$(O)"
$ COREOBJS = F$EDIT (REC-"\", "TRIM,COMPRESS")
$ IF (F$ELEMENT(1,"\",REC) .EQS. "\") THEN GOTO FILELOOPDONE
$FILELOOP2:
$ READ/END=DONE IN REC
$ REC = REC - ".$(O)" - ".$(O)" - ".$(O)" - ".$(O)" - ".$(O)" - ".$(O)"
$ COREOBJS = COREOBJS + " " + F$EDIT (REC-"\", "TRIM,COMPRESS")
$ IF (F$ELEMENT(1,"\",REC) .NES. "\") THEN GOTO FILELOOP2
$FILELOOPDONE:
$ CLOSE IN
$ IF (.NOT. READLINE) THEN COREOBJS = COREOBJS - "readline " - " readline"
$ !
$ ! List of terminal files; all are in [.term] and have an extension of .trm.
$ !
$ CORETERM = "dumb dxf dxy eepic epson fig hp26 hp2648 hpgl hpljii " -
           + "imagen kyo latex pbm pc post qms regis t410x tek x11"
$ OTHERTERM = "[-.term]impcodes.h [-.term]object.h gplt_x11.c"
$ !
$ ! Define CFLAGS. ("NO_GIH" may be omitted to generate and use "gnuplot.gih".)
$ !
$ CFLAGS = "/FLOAT=IEEE/IEEE_MODE=UNDERFLOW_TO_ZERO/DEFINE=(NO_GIH,HAVE_CONFIG_H,''RTL')/INCLUDE=[-]"
$ ! CFLAGS = "/DEFINE=(HAVE_CONFIG_H,''RTL')/INCLUDE=[-]"
$ IF (DECC) THEN CFLAGS = CFLAGS + "/PREFIX=ALL"
$ !
$ ! Write the make file.
$ !
$ GOTO 'MAKETOOL'
$MMS:
$MMK:
$ OPEN/WRITE MAKE [.SRC]DESCRIP.MMS
$ GOTO WRITEMAKE
$MAK:
$ OPEN/WRITE MAKE [.SRC]MAKEFILE.
$ GOTO WRITEMAKE
$COM:
$ OPEN/WRITE MAKE [.SRC]BUILD.COM
$ GOTO WRITECOM
$MAKEFILEDONE:
$ CLOSE MAKE
$ !
$ ! Write the option files
$ !
$ OPEN/WRITE OPT [.SRC]GNUPLOT.OPT
$ N = 0
$OPTLOOP:
$ FILE = F$ELEMENT (N, " ", COREOBJS)
$ IF (FILE .EQS. " ") THEN GOTO OPTDONE
$ WRITE OPT FILE, ".obj"
$ N = N + 1
$ GOTO OPTLOOP
$OPTDONE:
$ WRITE OPT "version.obj"
$ CLOSE OPT
$ IF (RTL .EQS. "DECCRTL") THEN GOTO NOVAXCOPT
$ OPEN/WRITE OPT [.SRC]VAXC.OPT
$ WRITE OPT "sys$library:vaxcrtl.exe/share"
$ CLOSE OPT
$NOVAXCOPT:
$ IF (.NOT. DECW) THEN GOTO NODECW
$ OPEN/WRITE OPT [.SRC]X11.OPT
$ WRITE OPT "sys$library:decw$xlibshr.exe/share"
$ CLOSE OPT
$NODECW:
$ EXIT
$ !
$WRITEMAKE:
$ WRITE MAKE "O = obj"
$ WRITE MAKE "X = exe"
$ IF (VAXC) THEN WRITE MAKE "CC = CC"
$ IF (VAXC) THEN WRITE MAKE "EXTRALIB ="
$ IF (GNUC) THEN WRITE MAKE "CC = GCC/NOCASE"
$ IF (GNUC) THEN WRITE MAKE "CRTL_SHARE ="
$ IF (GNUC) THEN WRITE MAKE "EXTRALIB = ,GNU_CC:[000000]GCCLIB/LIB"
$ IF (DECC) THEN WRITE MAKE "CC = CC"
$ IF (DECC .AND. .NOT. DECC$CRTL) THEN WRITE MAKE "EXTRALIB ="
$ IF (DECC .AND. DECC$CRTL) THEN -
    WRITE MAKE "EXTRALIB = ,SYS$LIBRARY:DECC$CRTL.OLB/LIBRARY"
$ IF (RTL .EQS. "VAXCRTL") THEN -
    WRITE MAKE "CRTL_SHARE = ,SYS$DISK:[]VAXC.OPT/OPT"
$ IF (RTL .NES. "VAXCRTL") THEN WRITE MAKE "CRTL_SHARE ="
$ WRITE MAKE "CFLAGS = ", CFLAGS
$ WRITE MAKE "TERMFLAGS = /INCLUDE=(""../"",""../term/"",""../src/"")"
$ WRITE MAKE ""
$ WRITE MAKE "OBJS = \"
$ N = 0
$WRITEMAKE_L1:
$ FILE = F$ELEMENT (N, " ", COREOBJS)
$ IF (FILE .EQS. " ") THEN GOTO WRITEMAKE_D1
$ WRITE MAKE "       ", FILE, ".$(O) \"
$ N = N + 1
$ GOTO WRITEMAKE_L1
$WRITEMAKE_D1:
$ WRITE MAKE "       version.$(O) vms.$(O)"
$ WRITE MAKE ""
$ WRITE MAKE "TERM = \"
$ N = 0
$WRITEMAKE_L2:
$ FILE = F$ELEMENT (N, " ", CORETERM)
$ IF (FILE .EQS. " ") THEN GOTO WRITEMAKE_D2
$ WRITE MAKE "       [-.term]", FILE, ".trm \"
$ N = N + 1
$ GOTO WRITEMAKE_L2
$WRITEMAKE_D2:
$ WRITE MAKE "       ", OTHERTERM
$ WRITE MAKE ""
$ ALL = ""
$ IF (DECC$CRTL) THEN ALL = ALL + " logicals"
$ ALL = ALL + " gnuplot.$(X)"
$ IF (DECW) THEN ALL = ALL + " gnuplot_x11.$(X)"
$ ALL = ALL + " gnuplot.hlp gnuplot.hlb gnuplot.gih\"
$ WRITE MAKE "all :  ", ALL
$ WRITE MAKE "        [-.demo]binary1. [-.demo]binary2. [-.demo]binary3."
$ WRITE MAKE "        @       ! a no-op to suppress a MMS warning"
$ WRITE MAKE ""
$ IF (DECC$CRTL) THEN WRITE MAKE "logicals :"
$ IF (DECC$CRTL) THEN -
    WRITE MAKE "        @ define/nolog decc$crtlmap sys$library:decc$crtl.exe"
$ WRITE MAKE ""
$ COPY SYS$INPUT: MAKE
$ DECK

gnuplot.$(X) : $(OBJS)
	link /executable=gnuplot.$(X) \
            vms.$(O),gnuplot.opt/option$(EXTRALIB)$(CRTL_SHARE)

gnuplot_x11.$(X) : gplt_x11.$(O) stdfn.$(O)
	link /executable=gnuplot_x11.$(X) \
            gplt_x11.$(O),stdfn.$(O),version.$(O),x11.opt/option$(EXTRALIB)$(CRTL_SHARE)

gplt_x11.$(O) : gplt_x11.c
	$(CC) $(CFLAGS) $(X11FLAGS) $<

[-.demo]binary1. [-.demo]binary2. [-.demo]binary3. : bf_test.$(X)
	set default [-.demo]
	run [-.src]bf_test.$(X)
	set default [-.src]

bf_test.$(X) : bf_test.$(O)
	link /executable=bf_test.$(X) bf_test.$(O)

gnuplot.hlb : gnuplot.hlp
	library/create/help gnuplot.hlb gnuplot.hlp

.IFDEF OLD_HLP
gnuplot.hlp : doc2hlp.$(X) [-.docs]gnuplot.doc
	define/user sys$input [-.docs]gnuplot.doc
	define/user sys$output []gnuplot.hlp
	run doc2hlp.$(X)

doc2hlp.$(X) : [-.docs]doc2hlp.c [-.docs]termdoc.c
	$(CC) /include=([-.docs],[],[-.term]) \
             [-.docs]doc2hlp.c,[-.docs]termdoc.c
	link /executable=doc2hlp.$(X) doc2hlp.$(O),termdoc.$(O)$(CRTL_SHARE)
.ELSE
gnuplot.hlp : [-.docs]gnuplot.rnh
	RUNOFF $< /OUTPUT=$@

[-.docs]gnuplot.rnh : [-.docs]doc2rnh.$(X) [-.docs]gnuplot.doc
	MCR $< [-.docs]gnuplot.doc $@

gnuplot.gih : [-.docs]doc2gih.$(X) [-.docs]gnuplot.doc
	MCR $< [-.docs]gnuplot.doc $@

[-.docs]doc2rnh.$(X) : [-.docs]doc2rnh.$(O) [-.docs]termdoc.$(O)
	link /executable=$@  $+ $(CRTL_SHARE)

[-.docs]doc2gih.$(X) : [-.docs]doc2gih.$(O) [-.docs]termdoc.$(O)
	link /executable=$@  $+ $(CRTL_SHARE)

[-.docs]doc2rnh.$(O) [-.docs]termdoc.$(O) : [-.docs]termdoc.c ![-.docs]allterm.h
	$(CC) /object=$@ $(CFLAGS) /include=([],[-],[-.term]) $*.c

[-.docs]doc2gih.$(O) : [-.docs]termdoc.c ![-.docs]allterm.h
	$(CC) /object=$@ $(CFLAGS) /include=([],[-],[-.term]) $*.c
.ENDIF

term.$(O) : term.h term.c $(TERM)
	$(CC) $(CFLAGS) $(TERMFLAGS) term.c /object=term.$(O)

$(OBJS) : plot.h

command.$(O) help.$(O) misc.$(O) : help.h

command.$(O) graphics.$(O) graph3d.$(O) misc.$(O) plot.$(O) set.$(O) show.$(O) term.O interpol.$(O) : setshow.h

command.$(O) fit.$(O) matrix.$(O) : fit.h

fit.$(O) matrix.$(O) : matrix.h

bitmap.$(O) term.$(O) : bitmap.h

clean :
	purge/log
	delete/log *.$(O);*
        delete/log *.$(X);*
        delete/log gnuplot.hlp;*,gnuplot.hlb;*,gnuplot.gih;*
        delete/log [-.docs]*.$(O);*,*.$(X);*,gnuplot.rnh;*
	delete/log [-.demo]binary1.;*,binary2.;*,binary3.;*
$EOD
$ GOTO MAKEFILEDONE
$ !
$WRITECOM:
$ WRITE MAKE -
    "$ ! Command file to compile/link gnuplot, gnuplot_x11, and make gnuplot.hlb"
$ WRITE MAKE "$ !"
$ WRITE MAKE "$ on error then goto finish"
$ WRITE MAKE "$ O = ""obj"""
$ WRITE MAKE "$ X = ""exe"""
$ IF (VAXC) THEN WRITE MAKE "$ CC = ""CC"""
$ IF (VAXC) THEN WRITE MAKE "$ EXTRALIB = """
$ IF (GNUC) THEN WRITE MAKE "$ CC = ""GCC/NOCASE"""
$ IF (GNUC) THEN WRITE MAKE "$ CRTL_SHARE = """
$ IF (GNUC) THEN WRITE MAKE "$ EXTRALIB = "",GNU_CC:[000000]GCCLIB/LIB"""
$ IF (DECC) THEN WRITE MAKE "$ CC = ""CC"""
$ IF (DECC .AND. .NOT. DECC$CRTL) THEN WRITE MAKE "$ EXTRALIB = """""
$ IF (DECC .AND. DECC$CRTL) THEN -
    WRITE MAKE "$ EXTRALIB = "",SYS$LIBRARY:DECC$CRTL.OLB/LIBRARY"""
$ IF (RTL .EQS. "VAXCRTL") THEN -
    WRITE MAKE "$ CRTL_SHARE = "",SYS$DISK:[]VAXC.OPT/OPT"""
$ IF (RTL .NES. "VAXCRTL") THEN WRITE MAKE "$ CRTL_SHARE = """""
$ WRITE MAKE "$ CFLAGS = ""''CFLAGS'"""
$ WRITE MAKE "$ TERMFLAGS = ""/INCLUDE=(""""../"""",""""../term/"""",""""../src/"""")"""
$ IF (VAXC .AND. DECW) THEN WRITE MAKE "$ define/nolog x11 decw$include"
$ IF (VAXC .AND. DECW) THEN WRITE MAKE "$ define/nolog sys sys$library"
$ WRITE MAKE "$ set verify"
$ IF (DECC$CRTL) THEN -
    WRITE MAKE "$ define/nolog decc$crtlmap sys$library:decc$crtl.exe"
$ N = 0
$WRITECOM_L1:
$ FILE = F$ELEMENT (N, " ", COREOBJS)
$ IF (FILE .EQS. " ") THEN GOTO WRITECOM_D1
$ IF (FILE .EQS. "term") THEN WRITE MAKE "$ cc 'CFLAGS' 'TERMFLAGS' ", FILE, ".c"
$ IF (FILE .NES. "term") THEN WRITE MAKE "$ cc 'CFLAGS' ", FILE, ".c"
$ N = N + 1
$ GOTO WRITECOM_L1
$WRITECOM_D1:
$ WRITE MAKE "$ cc 'CFLAGS' version.c"
$ WRITE MAKE "$ cc 'CFLAGS' vms.c"
$ IF (GNUC) THEN WRITE MAKE "$ cc 'CFLAGS' GNU_CC_INCLUDE:[000000]_assert.c"
$ WRITE MAKE "$ !"
$ WRITE MAKE "$ link /executable=gnuplot.exe -"
$ N = 0
$WRITECOM_L2:
$ FILE = F$ELEMENT (N, " ", COREOBJS)
$ IF (FILE .EQS. " ") THEN GOTO WRITECOM_D2
$ WRITE MAKE "     ", FILE, ".obj, -"
$ N = N + 1
$ GOTO WRITECOM_L2
$WRITECOM_D2:
$ WRITE MAKE "     version.obj,vms.obj'EXTRALIB' 'CTRL_SHARE'"
$ WRITE MAKE "$ cc 'CFLAGS' bf_test.c"
$ WRITE MAKE "$ link /executable=bf_test.exe -"
$ WRITE MAKE "    bf_test.obj'EXTRALIB' 'CTRL_SHARE'"
$ WRITE MAKE "$ cd [-.demo]"
$ WRITE MAKE "$ run [-.src]bf_test.exe"
$ WRITE MAKE "$ cd [-.src]"
$ IF (DECW) THEN WRITE MAKE "$ cc 'CFLAGS' gplt_x11.c"
$ IF (DECW) THEN WRITE MAKE "$ cc 'CFLAGS' stdfn.c"
$ IF (DECW) THEN WRITE MAKE "$ cc 'CFLAGS' version.c"
$ IF (DECW) THEN WRITE MAKE "$ link /executable=gnuplot_x11.exe -"
$ IF (DECW) THEN WRITE MAKE "    gplt_x11.obj,stdfn.obj,version.obj -"
$ IF (DECW) THEN WRITE MAKE "    'EXTRALIB' 'CTRL_SHARE',x11.opt/option"
$ COPY SYS$INPUT: MAKE
$ DECK
$ set def [-.docs]
$ if f$locate("ALL_TERM_DOC",CFLAGS).ne.f$length(CFLAGS) then -
	copy /concatenate [-.term]*.trm []allterm.h
$ cc 'CFLAGS' /OBJ=doc2rnh.obj/include=([],[-],[-.term],[-.src]) doc2rnh.c
$ cc 'CFLAGS' /OBJ=doc2gih.obj/include=([],[-],[-.term],[-.src]) doc2gih.c
$ cc 'CFLAGS' /OBJ=termdoc.obj/include=([],[-],[-.term],[-.src]) termdoc.c
$ SET DEF [-.src]		! CTRL_SHARE is defined as being in []
$ link [-.docs]doc2rnh.obj,termdoc.obj /exe=[-.docs]doc2rnh 'extralib''CTRL_SHARE'
$ link [-.docs]doc2gih.obj,termdoc.obj /exe=[-.docs]doc2gih 'extralib''CTRL_SHARE'
$ doc2rnh := $sys$disk:[-.docs]doc2rnh
$ doc2gih := $sys$disk:[-.docs]doc2gih
$ doc2rnh [-.docs]gnuplot.doc [-.docs]gnuplot.rnh
$ doc2gih [-.docs]gnuplot.doc []gnuplot.gih
$ ON SEVERE_ERROR THEN GOTO FINISH
$ RUNOFF [-.docs]gnuplot.rnh
$ library/create/help sys$disk:[]gnuplot.hlb gnuplot.hlp
$!
$FINISH:
$EOD
$ WRITE MAKE "$ set noverify"
$ IF (VAXC .AND. DECW) THEN WRITE MAKE "$ deassign x11"
$ IF (VAXC .AND. DECW) THEN WRITE MAKE "$ deassign sys"
$ WRITE MAKE "$ exit"
$ GOTO MAKEFILEDONE
