Ifeffit and Friends on Windows with MinGW and Strawberry Perl
Contents
This is my page of notes on how I built Ifeffit and Demeter to work with Strawberry Perl and how I managed to build the Demeter with Strawberry Perl installer package. It may not be completely coherent -- if you want to replicate what I have done, let me know and I'll clean this page right up.
Compiling Ifeffit
Here is a useful page on using pgplot and MinGW.
First, need to establish a build environment from which Strawberry+Demeter can be bootstrapped.
Removed readline from line 85 of the main Makefile:
SUBDIRS = readline src
Installed PDCurses and Readline from GnuWin32 into C:\GnuWin32\
Installed a full MinGW package because Strawberry does not come with the Fortran compiler. I put this into in C:\MinGW\.
Installed the pre-built pgplot and GrWin libraries available at http://spdg1.sci.shizuoka.ac.jp/grwinlib/english/ into C:\MinGW\lib\pgplot\
Correct value of PGPLOT_LIBS:
PGPLOT_LIBS = -L/c/MinGW/lib/pgplot -lcpgplot -lpgplot -lGrWin -lgdi32 -lg2c
Need to hack at iconf_pgplot to make this happen.
In src/cmdline/Makefile I used this for readline_LIB
readline_LIB = -L/c/GnuWin32/lib -lcurses -lreadline
Set the PGPLOT_DIR variable to /c/mingw/lib/pgplot, which is the location to which pgplot was installed in step 4.
In principle, PGPLOT_DEV should be set to /GW, but that does not seem to get picked up by Ifeffit. I have to $plot_device=/gw before plotting.
Compiling Ifeffit to be placed in C:/strawberry
Replace iconf_pgplot, iconf_term, and iconf_iff with the versions from win/ in the Demeter distribution
Modify line 85 of the main Makefile.in to read
SUBDIRS = src
(i.e. remove readline so it does not get compiled.)
Modify line 90 in src/cmdline/Makefile.in to read
readline_LIB = $(TERMCAP_LIB)
./configure --prefix='/c/source/Demeter.prereqs' (Note: this should be done in the MinGW window and not in the Windows command prompt.)
Edit src/lib/sys.h, changing the sysdir and pgdev lines like so:
c{sys.h -*-fortran-*- c system and build specific stuff goes here c to be included in iff_config.f sysdir = 'C:\strawberry\c\share\ifeffit' pgdev = '/gw' inifile= 'startup.iff .ifeffit' build = '1.2.11d'// $ ' Copyright (c) 2008 Matt Newville, Univ of Chicago' c}Note that this somewhat changes how the Ifeffit build procedure works. By setting the prefix at configuration time to be different from the sysdir, Ifeffit will get installed into a staging area. It will then be installed into its proper home when the Strawberry package is built.
Now make and make install
What goes into Demeter.prereqs
The MinGW fortran compiler and its .a and .dll libraries. The libraries must be placed into a folder tree named consistently with the version of MinGW used in Strawberry.
The entire contents of the GnuWin32 readline and ncurses packages. These come arranged in folders that fit obviously under c:\strawberry\c
All of PGPLOT, which goes into lib\pgplot\.
All of the binary folder from Gnuplot, which goes into bin\.
- And, of course, Ifeffit gets installed here.
Once everything is in place, zip up Demeter.prereqs in a zip file called Demeter.prereqs.zip and move that zip file to C:\git\demeter\win\.
Note that the Ifeffit wraper must be built against a properly built version of Ifeffit. This probably means ether building Demeter from source as part of the Strawberry build or:
- Build Ifeffit
- Build Strawberry
- Build Demeter using the Strawberry that just got built
- Build a Demeter par file
- Rebuild Strawberry
Compiling the SWIG wrapper
I found that the wrapper generated by SWIG 1.3.1 works well but that the wrappers from 1.3.4 or 2.0.2 do not. I have not investigated the cause yet and have the 1.3.1 wrapper committed to the git repo.
Here is the file defining the compilation and linking rules for the Ifeffit SWIG wrapper.
the linking order is important.
the locations of MinGW, GnuWin, and strawberry are currently hardwired
Using Gnuplot
Grab the latest version of gnuplot from http://sourceforge.net/projects/gnuplot/files/gnuplot/. There are zip files with Windows builds to be found there. In recent versions, there is a gnuplot.exe version that emulates pipes without opening a command window. Point the gnuplot -> program configuration variable at that and you should be able to use the gnuplot plotting backend. (Set plot -> plotwith to gnuplot.)
Using gnuplot on windows with Demeter requires a modified version of Graphics::GnuplotIF. I have passed a patch upstream to the author. Hopefully it will become available on CPAN.
Strawberry Perl + Demeter
The relocation of Perl does not seem to happen correctly when installing not in C:\strawberry. See http://www.perlmonks.org/?node_id=883855
Do this:
- Install Strawberry from the msi package. Click through the error that happens when relocation fails.
Remove the line
perl\lib\auto\Locale-Maketext\.packlist:backslash
from c:/source/strawberry/strawberry-merge-module.reloc.txt. This seems to be the reason that relocating fails during installation.
Run the relocation script in C:\source\strawberry by hand
Proceed with the instructions at http://strawberryperl.com/documentation/building.html although you will need to grap the latest Alien::WiX from Curtis Jewell's mercurial repository at http://hg.curtisjewell.name/Alien-WiX/ and install that instead. Also install WiX from that same repository.
To get things working with Perl 5.12.2 (the current version of Strawberry at this time), grab and install these:
PDWix uses LWP::UserAgent. So you have to put the http_proxy in the environment. In the MinGW shell, doing
export http_proxy=http://192.168.1.130:3128
before building did the trick.
Errors in simple script to build dependency tree:
Sub::Exporter must come before Dist::CheckConflicts
Test::Moose is part of Moose and need not be specified as a dependency
Getopt::Long is a core module and need not be in the list
Modifying the BAT files
At line 7 of each .batfile generated by Module::Build to run the perl scripts, you will find this invocation of perl:
perl -x -S %0 %*
This will call perl and feed it the perl code that follows the BAT code at the top of the file.
Each .bat file should be modified to capture STDOUT and STDERR to a file for the sake of bug reporting. This can be done like so:
perl -x -S %0 %* > "%APPDATA%\demeter\dathena.log" 2>&1
Each of Athena, Artemis, Hephaestus, and Atoms should get its own log file.
See this explanation of DOS batchfile redirection.