changeset 3051:c5bd47edc667 octave-forge

Add compilation instructions for gnuplot
author goffioul
date Mon, 05 Feb 2007 09:38:24 +0000
parents 827b56b174c8
children 1185d9c2cf65
files admin/Windows/msvc/libs/gnuplot-4.2.rc4.diff admin/Windows/msvc/libs/gnuplot-4.2.rc4.txt
diffstat 2 files changed, 779 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/admin/Windows/msvc/libs/gnuplot-4.2.rc4.diff	Mon Feb 05 09:38:24 2007 +0000
@@ -0,0 +1,746 @@
+diff -ur gnuplot-4.2.rc4/config/makefile.nt gnuplot-4.2.rc4-mod/config/makefile.nt
+--- gnuplot-4.2.rc4/config/makefile.nt	2006-08-11 18:35:29.000000000 +0200
++++ gnuplot-4.2.rc4-mod/config/makefile.nt	2007-02-05 10:23:20.593750000 +0100
+@@ -31,8 +31,17 @@
+ # where to place gnuplot.gih helpfile
+ HELPFILE = wgnuplot.hlp
+ 
++# installation directory
++DESTDIR = C:\Software\Gnuplot4.2
++
++# wxWidgets source tree location
++WXLOCATION = C:\Software\wxWidgets
++
++# Support libraries location (cairo, pango...)
++VCLIBS_ROOT = C:\Software\VCLibs
++
+ # directory for PostScript prolog and associated files
+-GNUPLOT_PS_DIR = share\\PostScript
++GNUPLOT_PS_DIR = share\gnuplot\PostScript
+ 
+ TOP = .
+ 
+@@ -54,11 +63,17 @@
+ 
+ # compiler flags
+ OPTIONS = /DUSE_MOUSE
+-OPTIONS = $(OPTIONS) /DHAVE_LIBGD /DHAVE_GD_GIF /DHAVE_GD_PNG /DHAVE_GD_JPEG /DHAVE_GD_TTF
+-OPTIONS = $(OPTIONS) /DHAVE_LIBPDF
++#OPTIONS = $(OPTIONS) /DHAVE_LIBGD /DHAVE_GD_GIF /DHAVE_GD_PNG /DHAVE_GD_JPEG /DHAVE_GD_TTF
++OPTIONS = $(OPTIONS) /DHAVE_LIBPNG
++#OPTIONS = $(OPTIONS) /DHAVE_LIBPDF
+ OPTIONS = $(OPTIONS) /DGNUPLOT_HISTORY
+-CBASEFLAGS = /G5 /GX /GR /MD /O2 /nologo
++OPTIONS = $(OPTIONS) /DWXWIDGETS
++CBASEFLAGS = /EHsc /GR /MD /O2 /nologo /D_CRT_SECURE_NO_DEPRECATE
+ CFLAGS = $(CBASEFLAGS) /I$(TOP) /D_Windows /DWIN32 /DHAVE_CONFIG_H /D__MSC__ /DHELPFILE=\"$(HELPFILE)\" $(OPTIONS)
++CXXFLAGS = /D_WINDOWS /D__WXMSW__ /DNOPCH /I$(WXLOCATION)\include /I$(WXLOCATION)\lib\vc_lib\msw
++CAIRO_CFLAGS = /I$(VCLIBS_ROOT)\include\cairo
++PANGO_CFLAGS = /I$(VCLIBS_ROOT)\include\pango-1.0 /I$(VCLIBS_ROOT)\include\glib-2.0 /I$(VCLIBS_ROOT)\lib\glib-2.0\include
++CONSOLE_CFLAGS = /DCONSOLE /DOCTAVE_BUILD
+ 
+ !IF "$(PROCESSOR_ARCHITECTURE)" == "ALPHA"
+ MACHINE = $(PROCESSOR_ARCHITECTURE)
+@@ -67,11 +82,13 @@
+ !ENDIF
+ 
+ # paths for external libs added here... 
+-LDFLAGS = /subsystem:windows /nologo /MACHINE:$(MACHINE) /MAP:GNUPLOT /libpath:..\src\pdflib\pdflib /libpath:..\src\gdwin32 
++#LDFLAGS = /subsystem:windows /nologo /MACHINE:$(MACHINE) /MAP:GNUPLOT /libpath:..\src\pdflib\pdflib /libpath:..\src\gdwin32 
++LDFLAGS = /nologo /MACHINE:$(MACHINE) /MAP:GNUPLOT /LIBPATH:$(WXLOCATION)\lib\vc_lib
+ 
+ # ...and here.
+ # see other terminal defines in term.h
+-TERMFLAGS = /I..\\term /I..\\src\\pdflib\\pdflib /I..\\src\\gdwin32 /DGNUPLOT_PS_DIR=\"$(GNUPLOT_PS_DIR)\"
++#TERMFLAGS = /I..\\term /I..\\src\\pdflib\\pdflib /I..\\src\\gdwin32 /DGNUPLOT_PS_DIR=\"$(GNUPLOT_PS_DIR)\"
++TERMFLAGS = /I..\\term /DGNUPLOT_PS_DIR=\"$(GNUPLOT_PS_DIR:\=\\)\"
+ 
+ # macros for makefile.all
+ O=obj
+@@ -79,7 +96,7 @@
+ D=..\\docs\\
+ M=..\\demo\\
+ 
+-default: wgnuplot.exe $(HELPFILE) wgnuplot.mnu $(M)bf_test.exe pgnuplot.exe
++default: wgnuplot.exe wgnuplot.mnu $(M)bf_test.exe pgnuplot.exe pgnuplot_win.exe # $(HELPFILE) 
+ 
+ !INCLUDE makefile.all
+ 
+@@ -88,6 +105,8 @@
+ WINOBJS = winmain.obj wgnuplib.obj wgraph.obj wprinter.obj wtext.obj \
+ 	wpause.obj wmenu.obj gpexecute.obj
+ 
++WXOBJS = wxt_gui.obj gp_cairo.obj
++
+ WINDOWS = makefile.win makefile.nt README.win win\wcommon.h \
+ 	win\wgnuplib.c win\wgnuplib.def win\wgnuplib.h win\wgnuplib.rc \
+ 	win\wgnuplot.def win\wgnuplot.hpj win\wgnuplot.mnu win\wgraph.c \
+@@ -95,10 +114,15 @@
+ 	win\wresourc.h win\wtext.c win\wtext.h win\geticon.c \
+ 	$(D)doc2rtf.c $(T)win.trm win\grpicon.ico win\texticon.ico
+ 
++ALL_CONSOLE_OBJS = $(OBJS:.obj=.cobj) $(WINOBJS:.obj=.cobj) $(WXOBJS:.obj=.cobj)
++
+ # default rules
+ .c.obj:
+ 	$(CC) $(CFLAGS) $*.c
+ 
++.c.cobj:
++	$(CC) $(CFLAGS) $(CONSOLE_CFLAGS) $*.c /Fo$@
++
+ $(OBJS): config.h
+ 
+ linkopt1.msw: makefile.nt
+@@ -112,6 +136,8 @@
+ 	echo wpause >> linkopt1.msw
+ 	echo wgraph >> linkopt1.msw
+ 	echo wprinter >> linkopt1.msw
++	echo wxt_gui >> linkopt1.msw
++	echo gp_cairo >> linkopt1.msw
+ 	echo kernel32.lib >> linkopt1.msw
+ 	echo user32.lib >> linkopt1.msw
+ 	echo gdi32.lib >> linkopt1.msw
+@@ -119,8 +145,21 @@
+ 	echo comdlg32.lib >> linkopt1.msw
+ 	echo advapi32.lib >> linkopt1.msw
+ 	echo shell32.lib >> linkopt1.msw
+-	echo pdflib.lib >> linkopt1.msw
+-	echo bgd.lib >> linkopt1.msw
++	echo ole32.lib >> linkopt1.msw
++	echo oleaut32.lib >> linkopt1.msw
++	echo comctl32.lib >> linkopt1.msw
++#	echo pdflib.lib >> linkopt1.msw
++#	echo bgd.lib >> linkopt1.msw
++	echo wxmsw28.lib >> linkopt1.msw
++	echo wxtiff.lib >> linkopt1.msw
++	echo jpeg.lib >> linkopt1.msw
++	echo png.lib >> linkopt1.msw
++	echo glib-2.0.lib >> linkopt1.msw
++	echo gobject-2.0.lib >> linkopt1.msw
++	echo gmodule-2.0.lib >> linkopt1.msw
++	echo cairo.lib >> linkopt1.msw
++	echo pango-1.0.lib >> linkopt1.msw
++	echo pangocairo-1.0.lib >> linkopt1.msw
+ 	echo wgnuplot.res >> linkopt1.msw
+ 
+ makefile.nt: ..\config\makefile.nt
+@@ -129,45 +168,95 @@
+ config.h: ..\config\config.nt
+ 	copy ..\config\config.nt config.h
+ 
+-wgnuplot.exe: $(OBJS) $(WINOBJS) win\wgnuplot.def wgnuplot.res linkopt1.msw texticon.ico grpicon.ico
+-	$(LD) $(LDFLAGS) /out:wgnuplot.exe @linkopt1.msw
++wgnuplot.exe: $(OBJS) $(WINOBJS) $(WXOBJS) win\wgnuplot.def wgnuplot.res linkopt1.msw texticon.ico grpicon.ico
++	$(LD) /subsystem:windows $(LDFLAGS) /out:wgnuplot.exe @linkopt1.msw
++	mt -outputresource:$@ -manifest $@.manifest
+ 
+ # rules
+ 
+ wgnuplot.res :  win\wgnuplot.rc win\wgnuplib.rc win\wresourc.h texticon.ico grpicon.ico
+-	rc /l 0x409 /fowgnuplot.res /i "win" /d "NDEBUG" /d WIN32 /d MSRC win\wgnuplot.rc
++	rc /l 0x409 /fowgnuplot.res /i "win" /i "$(WXLOCATION)\include" /d "NDEBUG" /d WIN32 /d MSRC /d WXWIDGETS win\wgnuplot.rc
+ 
+ term.obj: term.c term.h plot.h setshow.h bitmap.h $(CORETERM)
+-	$(CC) $(CFLAGS) $(TERMFLAGS) term.c
++	$(CC) $(CFLAGS) $(TERMFLAGS) term.c /Fo$@
++
++term.cobj: term.c term.h plot.h setshow.h bitmap.h $(CORETERM)
++	$(CC) $(CFLAGS) $(CONSOLE_CFLAGS) $(TERMFLAGS) term.c /Fo$@
+ 
+ winmain.obj: win\winmain.c win\wgnuplib.h win\wtext.h plot.h
+-	$(CC) $(CFLAGS) win\winmain.c
++	$(CC) $(CFLAGS) win\winmain.c /Fo$@
++
++winmain.cobj: win\winmain.c win\wgnuplib.h win\wtext.h plot.h
++	$(CC) $(CFLAGS) $(CONSOLE_CFLAGS) win\winmain.c /Fo$@
+ 
+ WINDEPS = win\wgnuplib.h win\wcommon.h win\wresourc.h
+ 
+ wgnuplib.obj: win\wgnuplib.c $(WINDEPS)
+-	$(CC) $(CFLAGS) win\wgnuplib.c
++	$(CC) $(CFLAGS) win\wgnuplib.c /Fo$@
++
++wgnuplib.cobj: win\wgnuplib.c $(WINDEPS)
++	$(CC) $(CFLAGS) $(CONSOLE_CFLAGS) win\wgnuplib.c /Fo$@
+ 
+ wmenu.obj: win\wmenu.c $(WINDEPS)
+-	$(CC) $(CFLAGS) win\wmenu.c
++	$(CC) $(CFLAGS) win\wmenu.c /Fo$@
++
++wmenu.cobj: win\wmenu.c $(WINDEPS)
++	$(CC) $(CFLAGS) $(CONSOLE_CFLAGS) win\wmenu.c /Fo$@
+ 
+ wtext.obj: win\wtext.c $(WINDEPS)
+-	$(CC) $(CFLAGS) win\wtext.c
++	$(CC) $(CFLAGS) win\wtext.c /Fo$@
++
++wtext.cobj: win\wtext.c $(WINDEPS)
++	$(CC) $(CFLAGS) $(CONSOLE_CFLAGS) win\wtext.c /Fo$@
+ 
+ wpause.obj: win\wpause.c $(WINDEPS)
+-	$(CC) $(CFLAGS) win\wpause.c
++	$(CC) $(CFLAGS) win\wpause.c /Fo$@
++
++wpause.cobj: win\wpause.c $(WINDEPS)
++	$(CC) $(CFLAGS) $(CONSOLE_CFLAGS) win\wpause.c /Fo$@
+ 
+ wprinter.obj: win\wprinter.c $(WINDEPS)
+-	$(CC) $(CFLAGS) win\wprinter.c
++	$(CC) $(CFLAGS) win\wprinter.c /Fo$@
++
++wprinter.cobj: win\wprinter.c $(WINDEPS)
++	$(CC) $(CFLAGS) $(CONSOLE_CFLAGS) win\wprinter.c /Fo$@
+ 
+ wgraph.obj: win\wgraph.c $(WINDEPS)
+-	$(CC) $(CFLAGS) win\wgraph.c
++	$(CC) $(CFLAGS) win\wgraph.c /Fo$@
++
++wgraph.cobj: win\wgraph.c $(WINDEPS)
++	$(CC) $(CFLAGS) $(CONSOLE_CFLAGS) win\wgraph.c /Fo$@
++
++wxt_gui.obj: wxterminal\wxt_gui.cpp wxterminal\wxt_gui.h $(WXLOCATION)
++	$(CXX) -c $(CFLAGS) $(CXXFLAGS) $(CAIRO_CFLAGS) wxterminal\wxt_gui.cpp /Fo$@
++
++wxt_gui.cobj: wxterminal\wxt_gui.cpp wxterminal\wxt_gui.h $(WXLOCATION)
++	$(CXX) -c $(CFLAGS) $(CXXFLAGS) $(CAIRO_CFLAGS) $(CONSOLE_CFLAGS) wxterminal\wxt_gui.cpp /Fo$@
++
++gp_cairo.obj: wxterminal\gp_cairo.c wxterminal\gp_cairo.h
++	$(CC) -c $(CFLAGS) $(CXXFLAGS) $(CAIRO_CFLAGS) $(PANGO_CFLAGS) wxterminal\gp_cairo.c /Fo$@
++
++gp_cairo.cobj: wxterminal\gp_cairo.c wxterminal\gp_cairo.h
++	$(CC) -c $(CFLAGS) $(CXXFLAGS) $(CAIRO_CFLAGS) $(PANGO_CFLAGS) $(CONSOLE_CFLAGS) wxterminal\gp_cairo.c /Fo$@
+ 
+ wgnuplot.mnu: win\wgnuplot.mnu
+ 	copy win\wgnuplot.mnu wgnuplot.mnu
+ 
+-pgnuplot.exe: win\pgnuplot.c
+-	cl $(CBASEFLAGS) /I$(TOP) win\pgnuplot.c /link version.obj user32.lib
++pgnuplot_win.exe: win\pgnuplot.c
++	cl $(CBASEFLAGS) /I$(TOP) win\pgnuplot.c /Fe$@ /link version.obj user32.lib
++
++pgnuplot.exe: $(ALL_CONSOLE_OBJS) win\wgnuplot.def wgnuplot.res texticon.ico grpicon.ico
++	$(LD) /subsystem:console $(LDFLAGS) /out:$@ @<<
++$(ALL_CONSOLE_OBJS)
++kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib
++advapi32.lib shell32.lib ole32.lib oleaut32.lib comctl32.lib
++wxmsw28.lib wxtiff.lib
++jpeg.lib png.lib
++glib-2.0.lib gobject-2.0.lib gmodule-2.0.lib
++cairo.lib pango-1.0.lib pangocairo-1.0.lib
++wgnuplot.res
++<<
++	mt -outputresource:$@ -manifest $@.manifest
+ 
+ # extract icons from wgnuplot.rc
+ texticon.ico: grpicon.ico
+@@ -201,6 +290,7 @@
+ # clean up temporary files
+ clean:
+ 	if exist *.obj del *.obj
++	if exist *.cobj del *.cobj
+ 	if exist *.ico del *.ico
+ 	if exist wgnuplot.res del wgnuplot.res
+ 	if exist win\gnuplot.rtf del win\gnuplot.rtf
+@@ -216,6 +306,7 @@
+ 	if exist wgnuplot.hlp del wgnuplot.hlp
+ 	if exist wgnuplot.mnu del wgnuplot.mnu
+ 	if exist pgnuplot.exe del pgnuplot.exe
++	if exist pgnuplot_win.exe del pgnuplot_win.exe
+ 	if exist ..\demo\binary1 del ..\demo\binary1
+ 	if exist ..\demo\binary2 del ..\demo\binary2
+ 	if exist ..\demo\binary3 del ..\demo\binary3
+@@ -223,3 +314,18 @@
+ 	if exist ..\demo\soundfit.par del ..\demo\soundfit.par
+ 	if exist config.h del config.h
+ 	if exist makefile.nt del makefile.nt
++	if exist *.manifest del *.manifest
++
++install: default
++	if not exist $(DESTDIR) mkdir $(DESTDIR)\bin
++	copy /Y wgnuplot.exe $(DESTDIR)\bin\wgnuplot.exe
++	copy /Y win\wgnuplot.mnu $(DESTDIR)\bin\wgnuplot.mnu
++#	copy /Y wgnuplot.hlp $(DESTDIR)\bin\wgnuplot.hlp
++	copy /Y pgnuplot.exe $(DESTDIR)\bin\pgnuplot.exe
++	copy /Y pgnuplot.exe $(DESTDIR)\bin\pgnuplot_win.exe
++	if not exist $(DESTDIR)\$(GNUPLOT_PS_DIR) mkdir $(DESTDIR)\$(GNUPLOT_PS_DIR)
++	xcopy /Y ..\term\PostScript\*.ps $(DESTDIR)\$(GNUPLOT_PS_DIR)
++	if not exist $(DESTDIR) mkdir $(DESTDIR)
++	for %f in (BUGS README FAQ Copyright NEWS) do copy ..\%f $(DESTDIR)\%f
++	if not exist $(DESTDIR)\share\gnuplot\demo mkdir $(DESTDIR)\share\gnuplot\demo
++	xcopy /Y ..\demo $(DESTDIR)\share\gnuplot\demo
+diff -ur gnuplot-4.2.rc4/src/command.c gnuplot-4.2.rc4-mod/src/command.c
+--- gnuplot-4.2.rc4/src/command.c	2006-10-11 23:48:09.000000000 +0200
++++ gnuplot-4.2.rc4-mod/src/command.c	2007-02-05 08:29:59.734375000 +0100
+@@ -2605,6 +2605,8 @@
+ 	    if ('\n' == c) {
+ 		dest[i] = '\0';
+ 		return dest;
++            } else if ('\r' == c) {
++                dest[i] = '\0';
+ 	    } else if (EOF == c) {
+ 		return (char*) 0;
+ 	    } else {
+@@ -2658,7 +2660,7 @@
+ 	    /* normal line input */
+ 	    last = strlen(gp_input_line) - 1;
+ 	    if (last >= 0) {
+-		if (gp_input_line[last] == '\n') {	/* remove any newline */
++		if (gp_input_line[last] == '\n' || gp_input_line[last] == '\r') {	/* remove any newline */
+ 		    gp_input_line[last] = NUL;
+ 		    /* Watch out that we don't backup beyond 0 (1-1-1) */
+ 		    if (last > 0)
+diff -ur gnuplot-4.2.rc4/src/plot.c gnuplot-4.2.rc4-mod/src/plot.c
+--- gnuplot-4.2.rc4/src/plot.c	2006-11-10 23:49:37.000000000 +0100
++++ gnuplot-4.2.rc4-mod/src/plot.c	2007-02-05 08:29:59.750000000 +0100
+@@ -480,7 +480,7 @@
+     else
+ 	interactive = FALSE;
+ #else
+-# if (defined(__MSC__) && defined(_Windows)) || defined(__WIN32__)
++# if ((defined(__MSC__) && defined(_Windows)) || defined(__WIN32__)) && ! defined(CONSOLE)
+     interactive = TRUE;
+ # else
+     interactive = isatty(fileno(stdin));
+diff -ur gnuplot-4.2.rc4/src/readline.c gnuplot-4.2.rc4-mod/src/readline.c
+--- gnuplot-4.2.rc4/src/readline.c	2006-04-28 18:54:03.000000000 +0200
++++ gnuplot-4.2.rc4-mod/src/readline.c	2007-02-05 08:29:59.796875000 +0100
+@@ -259,7 +259,12 @@
+ #  include "win/winmain.h"
+ #  define TEXTUSER 0xf1
+ #  define TEXTGNUPLOT 0xf0
++#  ifdef CONSOLE
++#   define special_getc() win_getch()
++static char win_getch __PROTO((void));
++#  else
+ #  define special_getc() msdos_getch()
++#  endif /* CONSOLE */
+ static char msdos_getch __PROTO((void));	/* HBB 980308: PROTO'ed it */
+ # endif				/* _Windows */
+ 
+@@ -757,6 +762,7 @@
+ }
+ 
+ #if !defined(MSDOS) && !defined(ATARI) && !defined(MTOS) && !defined(_Windows) && !defined(DOS386) && !defined(OSK)
++
+ /* Convert ANSI arrow keys to control characters */
+ static int
+ ansi_getc()
+@@ -796,6 +802,17 @@
+ 
+ #if defined(MSDOS) || defined(_Windows) || defined(DOS386) || defined(OS2)
+ 
++#ifdef CONSOLE
++static char
++win_getch()
++{
++    if (term && term->waitforinput)
++        return term->waitforinput();
++    else
++        return ConsoleGetch();
++}
++#endif
++
+ /* Convert Arrow keystrokes to Control characters: */
+ static char
+ msdos_getch()
+diff -ur gnuplot-4.2.rc4/src/term.c gnuplot-4.2.rc4-mod/src/term.c
+--- gnuplot-4.2.rc4/src/term.c	2006-10-06 01:52:18.000000000 +0200
++++ gnuplot-4.2.rc4-mod/src/term.c	2007-02-05 08:29:59.812500000 +0100
+@@ -101,6 +101,7 @@
+ void close_printer __PROTO((FILE * outfile));
+ # ifdef __MSC__
+ #  include <malloc.h>
++#  include <io.h>
+ # else
+ #  include <alloc.h>
+ # endif                         /* MSC */
+diff -ur gnuplot-4.2.rc4/src/win/wgnuplib.h gnuplot-4.2.rc4-mod/src/win/wgnuplib.h
+--- gnuplot-4.2.rc4/src/win/wgnuplib.h	2006-03-05 02:15:56.000000000 +0100
++++ gnuplot-4.2.rc4-mod/src/win/wgnuplib.h	2007-02-05 08:29:59.828125000 +0100
+@@ -45,7 +45,9 @@
+ #include <windows.h>
+ 
+ #ifdef _WINDOWS
+-#define _Windows
++# ifndef _Windows
++#  define _Windows
++# endif
+ #endif
+ 
+ /* HBB 19990506: The following used to be #ifdef __DLL__.
+diff -ur gnuplot-4.2.rc4/src/win/winmain.c gnuplot-4.2.rc4-mod/src/win/winmain.c
+--- gnuplot-4.2.rc4/src/win/winmain.c	2006-03-28 11:55:22.000000000 +0200
++++ gnuplot-4.2.rc4-mod/src/win/winmain.c	2007-02-05 10:18:20.984375000 +0100
+@@ -101,6 +101,7 @@
+ PW pausewin;
+ MW menuwin;
+ LPSTR szModuleName;
++LPSTR szPackageDir;
+ LPSTR winhelpname;
+ LPSTR szMenuName;
+ #define MENUNAME "wgnuplot.mnu"
+@@ -245,12 +246,22 @@
+ 
+ #endif /* WIN32 */
+ 
++#ifndef CONSOLE
+ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
+ 		LPSTR lpszCmdLine, int nCmdShow)
++#else
++int main(int argc, char **argv)
++#endif
+ {
+ 	/*WNDCLASS wndclass;*/
+ 	LPSTR tail;
+ 
++#ifdef CONSOLE
++# define _argv argv
++# define _argc argc
++	HINSTANCE hInstance = NULL, hPrevInstance = NULL;
++	int nCmdShow = 0;
++#else	 
+ #ifdef __MSC__  /* MSC doesn't give us _argc and _argv[] so ...   */
+ # ifdef WIN32    /* WIN32 has __argc and __argv */
+ #  define _argv __argv
+@@ -265,6 +276,7 @@
+ 		_argv[++_argc] = _fstrtok( NULL, " ");
+ # endif /* WIN32 */
+ #endif /* __MSC__ */
++#endif /* CONSOLE */
+ 
+ #ifdef	__WATCOMC__
+ # define _argv __argv
+@@ -290,6 +302,17 @@
+ 	szModuleName = (LPSTR)farrealloc(szModuleName, _fstrlen(szModuleName)+1);
+ 	CheckMemory(szModuleName);
+ 
++	if (_fstrlen(szModuleName) >= 5 && _fstrnicmp(&szModuleName[_fstrlen(szModuleName)-5], "\\bin\\", 5) == 0)
++	{
++		int len = _fstrlen(szModuleName)-4;
++		szPackageDir = (LPSTR)farmalloc(len+1);
++		CheckMemory(szPackageDir);
++		_fstrncpy(szPackageDir, szModuleName, len);
++		szPackageDir[len] = '\0';
++	}
++	else
++		szPackageDir = szModuleName;
++
+ 	winhelpname = (LPSTR)farmalloc(_fstrlen(szModuleName)+_fstrlen(HELPFILE)+1);
+ 	CheckMemory(winhelpname);
+ 	_fstrcpy(winhelpname,szModuleName);
+@@ -346,6 +369,7 @@
+ 	graphwin.color=TRUE;
+ 	graphwin.fontsize = WINFONTSIZE;
+ 
++#ifndef CONSOLE
+ 	if (TextInit(&textwin))
+ 		exit(1);
+ 	textwin.hIcon = LoadIcon(hInstance, "TEXTICON");
+@@ -371,6 +395,7 @@
+ 		InvalidateRect(textwin.hWndParent, (LPRECT) &rect, 1);
+ 		UpdateWindow(textwin.hWndParent);
+ 	}
++#endif
+ 
+ 
+ 	atexit(WinExit);
+@@ -381,6 +406,8 @@
+ }
+ 
+ 
++#ifndef CONSOLE
++
+ /* replacement stdio routines that use Text Window for stdin/stdout */
+ /* WARNING: Do not write to stdout/stderr with functions not listed
+    in win/wtext.h */
+@@ -578,6 +605,83 @@
+     return fread(ptr, size, n, file);
+ }
+ 
++#else
++
++DWORD WINAPI stdin_pipe_reader(LPVOID param)
++{
++    HANDLE h = (HANDLE)_get_osfhandle(fileno(stdin));
++    char c;
++    DWORD cRead;
++
++    if (ReadFile(h, &c, 1, &cRead, NULL))
++        return c;
++}
++
++int ConsoleGetch()
++{
++    int fd = fileno(stdin);
++    HANDLE h;
++    DWORD waitResult;
++
++    if (!isatty(fd))
++        h = CreateThread(NULL, 0, stdin_pipe_reader, NULL, 0, NULL);
++    else
++        h = (HANDLE)_get_osfhandle(fd);
++
++    do
++    {
++        waitResult = MsgWaitForMultipleObjects(1, &h, FALSE, INFINITE, QS_ALLINPUT);
++        if (waitResult == WAIT_OBJECT_0)
++        {
++            if (isatty(fd))
++            {
++                INPUT_RECORD rec;
++                DWORD recRead;
++
++                ReadConsoleInput(h, &rec, 1, &recRead);
++                if (recRead == 1 && rec.EventType == KEY_EVENT && rec.Event.KeyEvent.bKeyDown &&
++                        (rec.Event.KeyEvent.wVirtualKeyCode < VK_SHIFT || 
++                         rec.Event.KeyEvent.wVirtualKeyCode > VK_MENU))
++                {
++                    if (rec.Event.KeyEvent.uChar.AsciiChar)
++                        return rec.Event.KeyEvent.uChar.AsciiChar;
++                    else
++                        switch (rec.Event.KeyEvent.wVirtualKeyCode)
++                        {
++                            case VK_UP: return 020;
++                            case VK_DOWN: return 016;
++                            case VK_LEFT: return 002;
++                            case VK_RIGHT: return 006;
++                            case VK_HOME: return 001;
++                            case VK_END: return 005;
++                            case VK_DELETE: return 004;
++                        }
++                }
++            }
++            else
++            {
++                DWORD c;
++                GetExitCodeThread(h, &c);
++                return c;
++            }
++        }
++        else if (waitResult == WAIT_OBJECT_0+1)
++        {
++            MSG msg;
++
++            while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
++            {
++                TranslateMessage(&msg);
++                DispatchMessage(&msg);
++            }
++        }
++        else
++            break;
++    } while (1);
++}
++
++#endif /* CONSOLE */
++
+ /* public interface to printer routines : Windows PRN emulation
+  * (formerly in win.trm)
+  */
+diff -ur gnuplot-4.2.rc4/src/win/winmain.h gnuplot-4.2.rc4-mod/src/win/winmain.h
+--- gnuplot-4.2.rc4/src/win/winmain.h	2006-07-16 04:50:56.000000000 +0200
++++ gnuplot-4.2.rc4-mod/src/win/winmain.h	2007-02-05 10:11:15.546875000 +0100
+@@ -55,6 +55,7 @@
+ 
+ extern LPSTR winhelpname;
+ extern LPSTR szModuleName;
++extern LPSTR szPackageDir;
+ 
+ int Pause __PROTO((LPSTR str));
+ void screen_dump __PROTO((void));
+diff -ur gnuplot-4.2.rc4/src/win/wtext.h gnuplot-4.2.rc4-mod/src/win/wtext.h
+--- gnuplot-4.2.rc4/src/win/wtext.h	2004-07-01 19:10:11.000000000 +0200
++++ gnuplot-4.2.rc4-mod/src/win/wtext.h	2007-02-05 08:29:59.875000000 +0100
+@@ -40,6 +40,8 @@
+ /* redefine functions that can talk to tty devices, to use
+  * implementation in winmain.c/wgnuplot.dll */
+ 
++#ifndef CONSOLE
++
+ #define kbhit()  MyKBHit()
+ #define getche() MyGetChE()
+ #define getch()  MyGetCh()
+@@ -102,3 +104,9 @@
+ size_t MyFWrite(const void *ptr, size_t size, size_t n, FILE *stream);
+ size_t MyFRead(void *ptr, size_t size, size_t n, FILE *stream);
+ 
++#else /* CONSOLE */
++
++#define getch ConsoleGetch
++int ConsoleGetch();
++
++#endif /* CONSOLE */
+diff -ur gnuplot-4.2.rc4/src/wxterminal/gp_cairo.c gnuplot-4.2.rc4-mod/src/wxterminal/gp_cairo.c
+--- gnuplot-4.2.rc4/src/wxterminal/gp_cairo.c	2006-09-10 19:49:44.000000000 +0200
++++ gnuplot-4.2.rc4-mod/src/wxterminal/gp_cairo.c	2007-02-05 08:29:59.890625000 +0100
+@@ -78,6 +78,10 @@
+ #include <pango/pangocairo.h>
+ #include <glib.h>
+ 
++#ifdef _MSC_VER
++#define rint(x) floor((x)+0.5L)
++#endif
++
+ /* undef this to see what happens without the Symbol-to-unicode processing */
+ #define MAP_SYMBOL
+ 
+@@ -703,6 +707,7 @@
+ 	cairo_translate(plot->cr, x, y);
+ 	cairo_rotate(plot->cr, -arg);
+ 
++	{
+ 	PangoRectangle ink, logical;
+ 	double lw = cairo_get_line_width (plot->cr);
+ 	pango_layout_get_extents (layout, &ink, &logical);
+@@ -722,6 +727,7 @@
+ 			(double)ink.width / PANGO_SCALE + lw,
+ 			(double)ink.height / PANGO_SCALE + lw);
+ 	cairo_stroke (plot->cr);
++	}
+ #endif /* helper boxes to understand how text is positionned */
+ 
+ 	/* free the layout object */
+diff -ur gnuplot-4.2.rc4/src/wxterminal/wxt_gui.cpp gnuplot-4.2.rc4-mod/src/wxterminal/wxt_gui.cpp
+--- gnuplot-4.2.rc4/src/wxterminal/wxt_gui.cpp	2006-11-28 21:26:55.000000000 +0100
++++ gnuplot-4.2.rc4-mod/src/wxterminal/wxt_gui.cpp	2007-02-05 08:29:59.906250000 +0100
+@@ -129,6 +129,7 @@
+ 	EVT_COMMAND( wxID_ANY, wxExitLoopEvent, wxtApp::OnExitLoop )
+ 	EVT_CLOSE( wxtFrame::OnClose )
+ 	EVT_SIZE( wxtFrame::OnSize )
++#ifndef OCTAVE_BUILD
+ 	EVT_TOOL( Toolbar_CopyToClipboard, wxtFrame::OnCopy )
+ #ifdef USE_MOUSE
+ 	EVT_TOOL( Toolbar_Replot, wxtFrame::OnReplot )
+@@ -139,6 +140,7 @@
+ #endif /*USE_MOUSE*/
+ 	EVT_TOOL( Toolbar_Config, wxtFrame::OnConfig )
+ 	EVT_TOOL( Toolbar_Help, wxtFrame::OnHelp )
++#endif
+ END_EVENT_TABLE()
+ 
+ BEGIN_EVENT_TABLE( wxtPanel, wxPanel )
+@@ -322,10 +324,11 @@
+ 	CreateStatusBar();
+ 	SetStatusText( wxT("") );
+ 
++#ifndef OCTAVE_BUILD
+ 	/* set up the toolbar */
+ 	wxToolBar * toolbar = CreateToolBar();
+ 	/* With wxMSW, default toolbar size is only 16x15. */
+-	toolbar->SetToolBitmapSize(wxSize(16,16));
++//	toolbar->SetToolBitmapSize(wxSize(16,16));
+ 
+ 	toolbar->AddTool(Toolbar_CopyToClipboard, wxT("Copy"),
+ 				*(toolBarBitmaps[0]), wxT("Copy the plot to clipboard"));
+@@ -348,6 +351,7 @@
+ 	toolbar->AddTool(Toolbar_Help, wxT("Help"),
+ 				*(toolBarBitmaps[7]), wxT("Open help dialog"));
+ 	toolbar->Realize();
++#endif
+ 
+ 	FPRINTF((stderr,"wxtFrame constructor 2\n"));
+ 
+@@ -356,6 +360,7 @@
+ 
+ 	/* setting minimum height and width for the window */
+ 	SetSizeHints(100, 100);
++	OnSize( wxSizeEvent( this->GetSize() ) );
+ 
+ 	FPRINTF((stderr,"wxtFrame constructor 3\n"));
+ }
+@@ -486,7 +491,7 @@
+ /* panel constructor
+  * Note : under Windows, wxDefaultPosition makes the panel hide the toolbar */
+ wxtPanel::wxtPanel( wxWindow *parent, wxWindowID id, const wxSize& size )
+-	: wxPanel( parent,  id,  wxPoint(0,0) /*wxDefaultPosition*/, size, wxWANTS_CHARS )
++	: wxPanel( parent,  id,  wxPoint(0,0) /* wxDefaultPosition */, size, wxWANTS_CHARS )
+ {
+ 	FPRINTF((stderr,"panel constructor\n"));
+ 
+@@ -1338,6 +1343,7 @@
+ 
+ #ifdef __WXMSW__
+ 		/* the following is done in wxEntry() with wxMSW only */
++		WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst);
+ 		wxSetInstance(GetModuleHandle(NULL));
+ 		wxApp::m_nCmdShow = SW_SHOW;
+ #endif
+diff -ur gnuplot-4.2.rc4/term/post.trm gnuplot-4.2.rc4-mod/term/post.trm
+--- gnuplot-4.2.rc4/term/post.trm	2006-11-19 21:40:49.000000000 +0100
++++ gnuplot-4.2.rc4-mod/term/post.trm	2007-02-05 10:19:55.093750000 +0100
+@@ -3135,9 +3135,9 @@
+ # if defined(_Windows)
+ 	/* retrieve prologues path relatively to gnuplot executable,
+ 	 * whose path is in szModuleName (winmain.c) */
+-	ps_prologue_dir = gp_alloc(strlen((char*) szModuleName)
++	ps_prologue_dir = gp_alloc(strlen((char*) szPackageDir)
+ 			+ strlen(GNUPLOT_PS_DIR) + 2, "Prolog path");
+-	strcpy(ps_prologue_dir, (char*) szModuleName);
++	strcpy(ps_prologue_dir, (char*) szPackageDir);
+ 	strcat(ps_prologue_dir, "\\");
+ 	/* GNUPLOT_PS_DIR is _relative_ path */
+ 	strcat(ps_prologue_dir, GNUPLOT_PS_DIR);
+diff -ur gnuplot-4.2.rc4/term/win.trm gnuplot-4.2.rc4-mod/term/win.trm
+--- gnuplot-4.2.rc4/term/win.trm	2006-07-21 04:35:48.000000000 +0200
++++ gnuplot-4.2.rc4-mod/term/win.trm	2007-02-05 08:29:59.937500000 +0100
+@@ -86,6 +86,7 @@
+ TERM_PUBLIC void WIN_set_cursor __PROTO((int, int, int));
+ TERM_PUBLIC void WIN_put_tmptext __PROTO((int, const char str[]));
+ TERM_PUBLIC void WIN_set_clipboard __PROTO((const char[]));
++TERM_PUBLIC int WIN_waitforinput __PROTO((void));
+ #endif
+ TERM_PUBLIC int WIN_make_palette __PROTO((t_sm_palette *palette));
+ TERM_PUBLIC void WIN_set_color __PROTO((t_colorspec *));
+@@ -454,6 +455,16 @@
+     Graph_set_clipboard(&graphwin, s);
+ }
+ 
++#ifdef CONSOLE
++
++TERM_PUBLIC int
++WIN_waitforinput  ()
++{
++    return ConsoleGetch();
++}
++
++#endif /* CONSOLE */
++
+ #endif /* USE_MOUSE */
+ 
+ 
+@@ -861,7 +872,11 @@
+     WIN_text /* suspend */ , WIN_resume,
+     WIN_boxfill, WIN_linewidth
+ #ifdef USE_MOUSE
++# ifdef CONSOLE
++    , WIN_waitforinput , 
++# else
+     , 0 /* WIN_waitforinput */,
++# endif /* CONSOLE */
+     WIN_put_tmptext, WIN_set_ruler, WIN_set_cursor, WIN_set_clipboard
+ #endif
+     , WIN_make_palette, 0 /* previous_palette */,
+diff -ur gnuplot-4.2.rc4/term/wxt.trm gnuplot-4.2.rc4-mod/term/wxt.trm
+--- gnuplot-4.2.rc4/term/wxt.trm	2006-09-15 16:09:36.000000000 +0200
++++ gnuplot-4.2.rc4-mod/term/wxt.trm	2007-02-05 08:29:59.953125000 +0100
+@@ -59,12 +59,20 @@
+ 
+ /* terminal state, defined extern in wxt_term.h */
+ int wxt_window_number = 0;
++#ifdef OCTAVE_BUILD
++TBOOLEAN wxt_enhanced_enabled = TRUE;
++#else
+ TBOOLEAN wxt_enhanced_enabled = FALSE;
++#endif
+ int wxt_persist = UNSET;
+ int wxt_raise = UNSET;
+ int wxt_ctrl = UNSET;
+ /* default text font family: */
++#ifdef OCTAVE_BUILD
++char wxt_set_fontname[MAX_ID_LEN + 1] = "courier";
++#else
+ char wxt_set_fontname[MAX_ID_LEN + 1] = "";
++#endif
+ /* default text size*/
+ int wxt_set_fontsize = 0;
+ /* window title */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/admin/Windows/msvc/libs/gnuplot-4.2.rc4.txt	Mon Feb 05 09:38:24 2007 +0000
@@ -0,0 +1,33 @@
+Package: Gnuplot
+Version: 4.2rc4
+Home page: http://www.gnuplot.info
+Download: http://sourceforge.net/projects/gnuplot
+License: Custom (BSD-like)
+
+Compilation: from Windows command shell with VS environment
+
+Requirements: wxWidgets(*), zlib, libpng, pango, cairo
+
+1) Apply the patch
+
+2) Edit config\makefile.nt and adapt the following variables:
+	. DESTDIR : the installation directory
+	. WXLOCATION : the wxWidgets source tree location
+	. VCLIBS_ROOT : the installation directory of support
+	  libraries (cairo, pango...)
+
+3) Enter src\ subdirectory
+
+4) nmake -f ..\config\makefile.nt (**)
+
+5) nmake -f ..\config\makefile.nt install
+
+-------------------------------------------------------------------
+
+(*) wxWidgets package should have been built and the source tree
+    left in place
+
+(**) The build of wgnuplot.hlp file has been disabled, because it
+     require MS Help Workshop installed, which is rarely the case.
+     The easiest is to grab the file from a pre-built binary on the
+     web and put it into the same directory as the gnuplot executables.
\ No newline at end of file