                 Notes on building PCP for Windows

The following is a series of steps which should get you setup to
do Windows builds of the PCP toolkit.

In the recipe below, "DOS>" refers to commands to be entered into
Windows "Command Prompt" (aka DOS shell).  The "GIT>" lines refer
to commands to be entered into the (msys, bash) shell which comes
with your git installation.

If you have issues with these instructions (good chance you will)
drop in on the #pcp channel on irc.freenode.net for pointers and/
or a shoulder to cry on.  A list of known issues and resolutions,
for specific applications or Windows versions, can be found at the
end of this document.


Step 1 -- download bootstrap environment

DOS> mkdir C:\package
DOS> cd C:\package
DOS> ftp oss.sgi.com
User: anonymous
> binary
> prompt
> cd /projects/pcp/package
> mget *
...
> bye


Step 2 -- install initial bootstrap tools

DOS> msiexec /i bootperl*.msi
[ graphical installer ]
  - accept all the defaults
  - should have a populated C:\bootperl\* at the end.

DOS> Git*.exe
[ graphical installer ]
  - accept most of the defaults
  - set the Destination Location to be C:\Git
  - choose "Use Git Bash only" option (do not modify PATH)
  - choose "Use Unix style line endings"

DOS> qt-win-*.exe
[ graphical installer ]
  - install to C:\Qt
  - enter the "Previously installed MinGW" at:
	C:\bootperl\c
  - ignore warning about mismatched versions (moving to a
    newer version of Qt will probably fix this up).

DOS> Coin*.exe
[ graphical installer ]
  - set the Install Location to be C:\Coin3D
  - accept other defaults

DOS> Soqt*.exe
[ graphical installer ]
  - set the Install Location to be C:\Coin3D (yep, same as above)
  - accept other defaults

DOS> isetup*.exe
[ graphical installer ]
  - accept all defaults
  - especially, installing to default location


Step 3 -- unpack secondary bootstrap tools

GIT> mkdir /c/MSYS
GIT> cd /c/MSYS
GIT> for file in `echo /c/package/*.gz`
   > do
   >     echo $file
   >     tar zxf $file
   > done
GIT> cp etc/fstab.sample etc/fstab
GIT> vi etc/fstab
[ edit, add these lines: ]
  c:/bootperl/c      /mingw
  c:/bootperl/perl   /perl
  d:/source          /source
GIT> mkdir -p /d/source/git
GIT> cd /d/source/git
GIT> git clone git://oss.sgi.com/nathans/pcp.git
GIT> git clone git://oss.sgi.com/nathans/pcpqa.git
GIT> git clone git://oss.sgi.com/nathans/pcp-gui.git


Step 4 -- building PCP from the git tree

DOS> set PATH=C:\MSYS\bin;C:\MSYS\local\bin;%PATH%
DOS> cd D:\source\git\pcp
[ we have no working autoconf yet, copy ./configure from elsewhere ]
DOS> make
[ if all goes well, try creating some tarballs ]
DOS> sh ./Makepkgs -verbose pcp


Step 5 -- installing PCP libraries and headers

DOS> set DIST_ROOT=C:\MSYS
DOS> make install
[ OR ]
DOS> cd C:\MSYS
DOS> tar zxf D:\source\git\pcp\pcp-*\build\tar\pcp-*.tar.gz


Step 6 -- building the PCP GUI tree

DOS> set QTDIR=C:\Qt
DOS> set PCP_DIR=C:\MSYS
DOS> set COIN3DDIR=C:\Coin3D
DOS> set PCP_CONF=C:\MSYS\etc\pcp.conf
DOS> set PCP_CONFIG=C:\MSYS\local\bin\pmconfig.exe
DOS> cd D:\source\git\pcp-gui
DOS> make
DOS> sh ./Makepkgs -verbose pcp-gui


Step 7 -- packaging it all up

DOS> cpan
cpan> install File::Copy::Recursive File::PathList File::ShareDir
cpan> install Object::Tiny IO::Capture::Stdout Process::Delegatable
cpan> install LWP::UserAgent::WithCache Cache::Cache Cache::FileCache
cpan> install Module::CoreList Template
[ answer 'n' to any/all questions about Template module ]
cpan> install Portable::Dist
cpan> install Perl::Dist::Strawberry
cpan> quit

DOS> cd D:\source\git\pcp\src\cpan\Glider
DOS> copy D:\source\git\pcp\pcp*\build\tar\pcp*.tar.gz C:\package
DOS> copy D:\source\git\pcp-gui\pcp-gui*\build\tar\pcp-gui*.tar.gz C:\package
DOS> vim Glider.pm
  - check that Glider.pm uses the versions of pcp and pcp-gui just built
DOS> Glider.bat
  - wrapper around Glider.pm Perl module.
  - produces pcp-glider*.msi


Step 8 -- installation and post-install setup

DOS> msiexec /i pcp-glider*.msi
[ graphical installer ]
  - accept all defaults

DOS> cd C:\Glider\scripts
DOS> .\postinst.bat
DOS> sc query pcp
  - when the pcp service lists as "RUNNING", pmcd is up and ready
  - if it says STOPPED, start with C:\Glider\var\log\pmcd\pmcd.log
  - should also have a "Start" menu entry for "Performance Co-Pilot"
    with "PCP Charts" and "PCP Shell" entries, amongst others.


Troubleshooting -- Known Problems

0.  To permanently set environment variables under Windows:

    Control Panel -> System -> Advanced systems settings (on the left)

    Select [Environment Variables] at the bottom of the Advanced tab of
    the System Properties window, and launch the Environment Variables
    window.

    In the System variables pane, select the Path variable and click
    [Edit...] then add the following before the first element of the
    path C:\MSYS\bin;C:\MSYS\local\bin;

    You might as well set up the necessary PCP environment variables
    at the same time ...

    In the System variables pane, click [New...] and repeat for
    Variable		Value
    PCP_CONFIG		C:\MSYS\local\bin\pmconfig.exe
    PCP_DIR		C:\MSYS

    Click [OK] to close the Environment Variables window.

    Close all DOS Command Prompt windows.

    Launch a new DOS Command Prompt window.

1.  If you're using git in Windows-mode, and depending on where
    your configure script was generated (typically not on Win32
    at this stage, usually have to pull this from a Linux host)
    you may see a build failure ultimately due to line-endings
    causing configure confusion.  Symptoms are build failure in
    libpcp (1st thing compiled), and its because no macros in
    platform_defs.h are expanded.  You can fix this by converting
    the git-checked-out platform_defs.h.in to UNIX line endings:

    $ tr -d '\r' < src/include/platform_defs.h.in

2.  If you're running a virus scanner with real-time checking
    (like McAfee), then it may believe that the following file
         D:\source\git\pcpqa\src-oss\pmpost-exploit.c
    is a "trojan" (don't even ask why) and quarrantine the file.
    If you want to run PCP QA, then you'll need to reinstante this
    file using your virus scanner administrative services.

3.  Installing Coin3D fails on Vista with:
        Program Compatibiliy Assistant
        This program might not have been installed correctly
        (a) Reinstall using recommended settings
        (b) This program is installed correctly
    Choose (a).

