Bill Allombert on Thu, 24 Dec 2009 12:31:31 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: A patch for native PARI/GP build on Windows (Mingw+Msys) |
On Wed, Dec 23, 2009 at 06:15:33PM +0200, Vasili Burdo wrote: >> Please check for any problem on the real thing > - implemented unzipping from .zip archives I mentioned in previous post. > See pari_get_infile(). If this function sees ".zip/" substring in > file name, it tries to pipe it through "unzip -p". > As result, it's possible it set GPDATADIR to something like > "/path/path/gpdata.zip". I would like to postpone that chnages for now. > - removed "-wb" option from diff command in dotest. Instead, "sed -e > 's/\r//'" used as you suggested. The same way dotest should be fixed in > gp2c sources Does that actually work ? if \r is part of the line ending, then sed will not see it. > - reimplemented -fno-omit-frame-pointer hack. See file config/get_cc done. > - added mingw support to config/get_modld - it's neccessary for gp2c > interoperability done ? >> I agree with your approach. I suggest to do things a bit differently: >> We define a special value DYNDATADIR for GPDATADIR (say DYNDATADIR="" ) and >> we test if GPDATADIR is equal to DYNDATADIR, and in that case we set >> datadir to win32_GPDATADIR instead of GPDATADIR. We change Configure to >> set GPDATADIR to DYNDATADIR by default. > I don't quite understand how it will work, so please, do it yourself. Please see the attached patch. Cheers, Bill.
diff --git a/config/get_install b/config/get_install index a485dea..821de34 100644 --- a/config/get_install +++ b/config/get_install @@ -24,7 +24,11 @@ echo $n "...for architecture-independent files (share-prefix) ? $c" dflt=$share_prefix; . ./myread; share_prefix=$ans dfltman=$share_prefix/man/man1 -dfltdata=$share_prefix/pari + +case $osname in + mingw) dfltdata="";; + *) dfltdata=$share_prefix/pari;; +esac echo "Installation directories for:" echo $n ..."executables (gp, gphelp) ? $c" diff --git a/src/gp/gp.c b/src/gp/gp.c index 71f2887..8fc8cf7 100644 --- a/src/gp/gp.c +++ b/src/gp/gp.c @@ -358,14 +358,16 @@ static void community(void) { pari_sp av = avma; - char *s = stackmalloc(strlen(GPDATADIR) + 1024); + char *gpdat= pari_gpdatadir(); + char *s = stackmalloc(strlen(gpdat) + 1024); (void)sprintf(s, "The standard distribution of GP/PARI includes a \ reference manual, a tutorial, a reference card and quite a few examples. They \ should have been installed in the directory '%s'. If not, ask the person \ who installed PARI on your system where they can be found. You can also \ download them from the PARI WWW site 'http://pari.math.u-bordeaux.fr/'.", -GPDATADIR); +gpdat); + free(gpdat); print_text(s); avma = av; pari_puts("\nThree mailing lists are devoted to PARI:\n\ diff --git a/src/headers/paridecl.h b/src/headers/paridecl.h index 4835278..b4fae4f 100644 --- a/src/headers/paridecl.h +++ b/src/headers/paridecl.h @@ -1398,6 +1398,7 @@ pariFILE* pari_fopen_or_fail(const char *s, const char *mode); pariFILE* pari_fopengz(const char *s); void pari_fprintf(FILE *file, const char *fmt, ...); char* pari_get_homedir(const char *user); +char * pari_gpdatadir(void); int pari_is_dir(const char *name); int pari_is_file(const char *name); void pari_printf(const char *fmt, ...); diff --git a/src/language/es.c b/src/language/es.c index 383c6fd..69944c9 100644 --- a/src/language/es.c +++ b/src/language/es.c @@ -4335,3 +4335,13 @@ pari_unique_dir(const char *s) pari_err(talker,"couldn't find a suitable name for a tempdir (%s)",s); return buf; } + +char * +pari_gpdatadir(void) +{ + const char *gpdat=GPDATADIR; +#ifdef _WIN32 + if (*gpdat==0) return win32_datadir(); +#endif + return strdup(gpdat); +} diff --git a/src/language/init.c b/src/language/init.c index d8c81b8..fdc0d90 100644 --- a/src/language/init.c +++ b/src/language/init.c @@ -493,8 +493,8 @@ pari_init_defaults(void) pari_logfile = NULL; pari_datadir = os_getenv("GP_DATA_DIR"); - if (!pari_datadir) pari_datadir = (char*)GPDATADIR; - if (pari_datadir) pari_datadir = pari_strdup(pari_datadir); + if (!pari_datadir) pari_datadir = pari_gpdatadir(); + else pari_datadir = pari_strdup(pari_datadir); next_block = 0; for (i=0; i<c_LAST; i++) gp_colors[i] = c_NONE; diff --git a/src/systems/mingw/mingw.c b/src/systems/mingw/mingw.c index 5f281de..688e8cc 100644 --- a/src/systems/mingw/mingw.c +++ b/src/systems/mingw/mingw.c @@ -19,6 +19,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <stdio.h> #include "mingw.h" +char* win32_datadir(void) +{ + char datadir[1024]; + char* slash; + GetModuleFileNameA(0, datadir, sizeof(datadir) ); + slash = strrchr(datadir, '\\'); + if( slash ) *(slash+1) = 0; + strcat(datadir, "gp-data"); + return strdup(datadir); +} + static WORD win32_console_color(unsigned long c) { diff --git a/src/systems/mingw/mingw.h b/src/systems/mingw/mingw.h index e3d6aa9..fb1d01a 100644 --- a/src/systems/mingw/mingw.h +++ b/src/systems/mingw/mingw.h @@ -15,6 +15,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* Written by Vasili Burdo */ +char* win32_datadir(void); void win32_ansi_fputs(const char* s, void* f); int win32_terminal_width(void); int win32_terminal_height(void);