Raed Rizqie f09e534fe3
gnuplot: fix path translation (#24723)
- rebase patches
- fix path translation
- fix parallel build
2025-07-12 19:10:15 +03:00

161 lines
4.7 KiB
Diff

--- a/configure.ac
+++ b/configure.ac
@@ -38,6 +38,8 @@
AC_C_STRINGIZE
AC_PROG_LN_S
+AC_CANONICAL_HOST
+
if test "${build}" != "${host}"
then
CC=${CC-${host_alias-gcc}}
@@ -51,6 +53,8 @@
CC_FOR_BUILD="${CC}"
AC_PROG_CC
+ build_mingw=no
+
# We must set the default linker to the linker used by gcc for the correct
# operation of libtool. If LD is not defined and we are using gcc, try to
# set the LD default to the ld used by gcc.
@@ -60,7 +64,9 @@
then
case $build in
*-*-mingw*)
- gcc_prog_ld=`$CC -print-prog-name=ld 2>&1 | tr -d '\015'` ;;
+ gcc_prog_ld=`$CC -print-prog-name=ld 2>&1 | tr -d '\015'`
+ AC_MSG_NOTICE([MINGW environment detected, executing MINGW type build])
+ build_mingw=yes ;;
*)
gcc_prog_ld=`$CC -print-prog-name=ld 2>&1` ;;
esac
@@ -78,6 +84,7 @@
fi
AM_PROG_CC_C_O
AC_SUBST(CC_FOR_BUILD)
+AM_CONDITIONAL(BUILD_MINGW, test "${build_mingw}" = yes)
dnl large file support
AC_CHECK_TYPES([off_t])
--- a/demo/plugin/Makefile.am
+++ b/demo/plugin/Makefile.am
@@ -4,7 +4,7 @@
noinst_PROGRAMS = demo_plugin.so
demo_plugin_so_SOURCES = demo_plugin.c gnuplot_plugin.h
-demo_plugin_so_CFLAGS = -rdynamic -fPIC -I$(top_srcdir)/src
+demo_plugin_so_CFLAGS = -fPIC -I$(top_srcdir)/src
demo_plugin_so_LDFLAGS = -shared
# Note: Solaris SunPro C compiler needs these flags instead
--- a/docs/Makefile.am
+++ b/docs/Makefile.am
@@ -38,6 +38,11 @@
AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/term \
-I./ja/term
+if BUILD_MINGW
+AM_CPPFLAGS += -DWINDOWS_NO_GUI
+dist_doc_DATA = gnuplot.pdf
+endif
+
# Documentation will be prepared for all terminals in CORETERM
# even if the terminal itself is not included in the build.
--- a/Makefile.am
+++ b/Makefile.am
@@ -7,6 +7,8 @@
PATCHLEVEL PGPKEYS README RELEASE_NOTES \
win
+dist_doc_DATA = FAQ.pdf README RELEASE_NOTES Copyright NEWS BUGS
+
DISTCLEANFILES = stamp-h
ACLOCAL_AMFLAGS = -I m4
--- a/src/command.c
+++ b/src/command.c
@@ -107,7 +107,7 @@
static TBOOLEAN pause_internal; /* flag to indicate not to use a dialog box */
#endif /* OS2_IPC */
-#ifndef _WIN32
+#ifndef _MSC_VER
# include "help.h"
#endif
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -99,6 +99,60 @@
# Hercules and original pc graphics driver code
# corgraph.asm header.mac hrcgraph.asm pcgraph.asm lineproc.mac
+# MINGW specific build section
+if BUILD_MINGW
+
+AM_CPPFLAGS += -DHAVE_GDIPLUS -DHAVE_DWRITE -DHAVE_D2D -DHAVE_D2D11 -DHAVE_PRNTVPT -DWIN32
+AM_CPPFLAGS += -O2 -pipe -DUNICODE -D_UNICODE -Wno-unused-function
+AM_CPPFLAGS += -D_Windows -DHAVE_CONFIG_H
+AM_CPPFLAGS += -D__USE_MINGW_ANSI_STDIO=1
+AM_CPPFLAGS += -DUSE_MOUSE=1 -DWIN_IPC
+
+AM_LDFLAGS =
+
+gnuplot_SOURCES += win/winmain.c win/wgnuplib.c win/wgraph.c win/wprinter.c \
+win/wpause.c win/wgdiplus.cpp win/wd2d.cpp win/wtext.h plot.h gpexecute.c
+
+gnuplot_CPPFLAGS = $(AM_CPPFLAGS) -DPIPES -DWGP_CONSOLE
+gnuplot_LDADD += -lkernel32 -lgdi32 -lwinspool -lcomdlg32 -lcomctl32 \
+ -ladvapi32 -lshell32 -lmsimg32 -lgdiplus -lshlwapi -ld2d1 -ld3d11 -ldwrite \
+ -lprntvpt -lwindowscodecs -lole32 -lgobject-2.0
+gnuplot_LDFLAGS = $(AM_LDFLAGS) -mconsole -municode
+
+#wgnuplot section
+bin_PROGRAMS += wgnuplot
+
+menudir = $(prefix)/bin
+menu_DATA = win/wgnuplot.mnu
+
+wgnuplot_SOURCES = $(gnuplot_SOURCES)
+wgnuplot_SOURCES += win/wtext.c win/screenbuf.c win/wmenu.c win/wredirect.cpp
+wgnuplot_CPPFLAGS = $(AM_CPPFLAGS) -DPIPES
+wgnuplot_LDADD = $(gnuplot_LDADD) wgplt_res.$(O)
+wgnuplot_LDFLAGS = $(AM_LDFLAGS) -mwindows -municode
+
+#wgnuplot_pipes section
+bin_PROGRAMS += wgnuplot_pipes
+
+wgnuplot_pipes_SOURCES = $(gnuplot_SOURCES)
+wgnuplot_pipes_SOURCES += win/wtext.c win/screenbuf.c win/wmenu.c win/wredirect.cpp
+wgnuplot_pipes_CPPFLAGS = $(AM_CPPFLAGS) -DPIPES
+wgnuplot_pipes_LDADD = $(gnuplot_LDADD) wgplt_res.$(O)
+wgnuplot_pipes_LDFLAGS = $(AM_LDFLAGS) -mwindows -municode
+
+RCFLAGS = --include-dir=$(srcdir)/win \
+ --define __WIN32__ --define __WIN95__ \
+ --define __GNUWIN32__ --use-temp-file
+RCOUT = wgplt_res.$(O)
+RES2COFF = echo wgplt_res.$(O)
+
+wgplt_res.$(O): win/wgnuplot.rc win/wgnuplib.rc win/wresourc.h win/texticon.ico win/grpicon.ico win/wgnuplot.exe.manifest win/wgnuplot.exe.manifest64
+ echo Making RESOURCE FILE
+ windres $(RCFLAGS) $< wgplt_res.$(O)
+ echo wgplt_res.$(O)
+
+endif # BUILD_MINGW
+
if BUILD_WXWIDGETS
gnuplot_SOURCES += wxterminal/wxt_gui.cpp
endif
--- a/src/win/winmain.c
+++ b/src/win/winmain.c
@@ -372,7 +372,7 @@
else
lang = GetLanguageCode();
- filename = (LPTSTR) malloc((_tcslen(szModuleName) + _tcslen(name) + _tcslen(lang) + _tcslen(ext) + 1) * sizeof(TCHAR));
+ filename = (LPTSTR) malloc(1024 * sizeof(TCHAR));
if (filename) {
_tcscpy(filename, szModuleName);
_tcscat(filename, name);