==========
  MSYS
==========

De MSYS hay que describir lo minimo requerido. Hay que tomar notas desde la proxima instalacion.

export PATH=/C/Archivos\ de\ programa/R/R-3.1.2/bin:/C/Archivos\ de\ programa/Microsoft\ Visual\ Studio\ 10.0/VC/bin:${PATH}

==========
boost_1_57
==========

wget http://packages.tol-prj.org/win32/development/sources/boost_1_57_0.zip 

desde una ventana del DOS no MSYS ejecutar "bootstrap.bat mingw" ya que desde la ventana de msys da errores al no encontrar algunos .h, no entiendo bien 
por que.

Luego desde la ventana de msys podemos hacer

Compilacion Release: hay que modificar gcc.jam para cambiar -O3  por -O2

$ b2 --address-model=32 cxxflags=-mno-align-double variant=release runtime-link=shared threading=multi --layout=system --without-mpi  link=shared toolset=gcc --prefix=/c/users/toldevel/external/toldevel-rtools-m32/release  install
    
    -ftemplate-depth-128 -O2 -fno-inline -w -mthreads  -DBOOST_ALL_DYN_LINK=1 -DBOOST_ALL_NO_LIB=1 -DNDEBUG 
    
Compilacion Debug

$ b2 --address-model=32 cxxflags=-mno-align-double variant=debug   runtime-link=shared threading=multi --layout=system --without-mpi  link=shared toolset=gcc --prefix=/c/users/toldevel/external/toldevel-rtools-m32/debug install

   -ftemplate-depth-128 -O0 -fno-inline -w -g -mthreads  -DBOOST_ALL_DYN_LINK=1 -DBOOST_ALL_NO_LIB=1

Si la compilacion es correcta debe salir algo como esto:

The Boost C++ Libraries were successfully built!

The following directory should be added to compiler include paths:

    C:/users/toldevel/external/boost_1_57_0

The following directory should be added to linker library paths:

    C:\users\toldevel\external\boost_1_57_0\stage\lib
    
========================
    google sparsehash
========================
    
Descargar google sparsehash

wget http://packages.tol-prj.org/win32/development/sources/sparsehash-2.0.2.zip

Se configura con configure

CFLAGS='-m32 -m32 -O2 -mno-align-double' CXXFLAGS='-m32 -O2 -mno-align-double' configure --prefix=/c/users/toldevel/external/toldevel-rtools-m32/release
make
make install
make distclean
CFLAGS='-m32 -m32 -O0 -ggdb  -mno-align-double' CXXFLAGS='-m32 -O0 -ggdb  -mno-align-double' configure --prefix=/c/users/toldevel/external/toldevel-rtools-m32/debug
make 
make install

========
  bzip2
========

wget http://packages.tol-prj.org/win32/development/sources/bzip2-1.0.6.zip
unzip bzip2-1.0.6.zip
cd bzip2-1.0.6
mkdir Build
mkdir Build/Debug ; cd Build/Debug
cmake -DCMAKE_C_FLAGS_DEBUG='-O0 -ggdb -Wall -mno-align-double' -DCMAKE_INSTALL_PREFIX=/c/users/toldevel/external/toldevel-rtools-m32/debug -DCMAKE_BUILD_TYPE=Debug -G"MSYS Makefiles" ../..
make install
cd ../..
mkdir Build/Release ; cd Build/Release
cmake -DCMAKE_C_FLAGS_RELEASE='-O2 -Wall -DNDEBUG -mno-align-double' -DCMAKE_INSTALL_PREFIX=/c/users/toldevel/external/toldevel-rtools-m32/release -DCMAKE_BUILD_TYPE=Release -G"MSYS Makefiles" ../..
make install


************** NO HACE FALTA YA QUE CON CMAKE SE PUEDE COMPILAR ***********
wget http://skylink.dl.sourceforge.net/project/mingw/MinGW/Extension/bzip2/bzip2-1.0.6-4/libbz2-1.0.6-4-mingw32-dll-2.tar.lzma
wget http://skylink.dl.sourceforge.net/project/mingw/MinGW/Extension/bzip2/bzip2-1.0.6-4/bzip2-1.0.6-4-mingw32-dev.tar.lzma
tar -C /C/users/toldevel/external/install/release --lzma -xvf bzip2-1.0.6-4-mingw32-dev.tar.lzma
tar -C /C/users/toldevel/external/install/release --lzma -xvf libbz2-1.0.6-4-mingw32-dll-2.tar.lzma
tar -C /C/users/toldevel/external/install/debug --lzma -xvf bzip2-1.0.6-4-mingw32-dev.tar.lzma
tar -C /C/users/toldevel/external/install/debug --lzma -xvf libbz2-1.0.6-4-mingw32-dll-2.tar.lzma

========
  zlib
========

wget http://packages.tol-prj.org/win32/development/sources/zlib-1.2.8.zip
unzip zlib-1.2.8.zip
cd zlib-1.2.8
mkdir Build
mkdir Build/Release ; cd Build/Release
cmake -DCMAKE_C_FLAGS_RELEASE='-O2 -Wall -DNDEBUG -mno-align-double' -DCMAKE_INSTALL_PREFIX=/c/users/toldevel/external/toldevel-rtools-m32/release/ -DCMAKE_BUILD_TYPE=Release -G"MSYS Makefiles" ../..
make 
make install
cd ../..
mkdir Build/Debug ; cd Build/Debug
cmake -DCMAKE_C_FLAGS_DEBUG='-O0 -ggdb -Wall -mno-align-double'        -DCMAKE_INSTALL_PREFIX=/c/users/toldevel/external/toldevel-rtools-m32/debug/ -DCMAKE_BUILD_TYPE=Debug -G"MSYS Makefiles" ../..
make 
make install

================
   ZipArchive
================

wget http://packages.tol-prj.org/win32/development/sources/ZipArchive.zip
unzip ZipArchive.zip
cd ZipArchive
mkdir -p Build/Release ; cd Build/Release
cmake -DCMAKE_C_FLAGS_RELEASE='-O2 -Wall -DNDEBUG -mno-align-double' -DCMAKE_CXX_FLAGS_RELEASE='-O2 -Wall -DNDEBUG -mno-align-double' -DCMAKE_PREFIX_PATH=/c/users/toldevel/external/toldevel-rtools-m32/release -DCMAKE_INSTALL_PREFIX=/c/users/toldevel/external/toldevel-rtools-m32/release -DCMAKE_BUILD_TYPE=Release -G"MSYS Makefiles" -DBUILD_SHARED_LIBS:BOOL=ON ../..
make install
cd ../..
mkdir -p Build/Debug ; cd Build/Debug
cmake -DCMAKE_C_FLAGS_RELEASE='-O0 -ggdb -Wall -mno-align-double' -DCMAKE_CXX_FLAGS_RELEASE='-O0 -ggdb -Wall -mno-align-double' -DCMAKE_PREFIX_PATH=/c/users/toldevel/external/toldevel-rtools-m32/debug -DCMAKE_INSTALL_PREFIX=/c/users/toldevel/external/toldevel-rtools-m32/debug -DCMAKE_BUILD_TYPE=Debug -G"MSYS Makefiles" -DBUILD_SHARED_LIBS:BOOL=ON ../..
make install

=======
 fftw
=======

wget http://packages.tol-prj.org/linux/sources/fftw-3.3.1.tar.gz
tar zxf fftw-3.3.1.tar.gz
cd fftw-3.3.1

CFLAGS='-m32 -m32 -O0 -ggdb -Wall -mno-align-double' configure --prefix=/c/users/toldevel/external/toldevel-rtools-m32/debug --enable-shared
make
make install
make distclean
CFLAGS='-m32 -m32 -O2 -Wall -DNDEBUG -mno-align-double' configure --prefix=/c/users/toldevel/external/toldevel-rtools-m32/release --enable-shared
make
make install

=============
  ROOT CINT
=============

wget http://packages.tol-prj.org/win32/development/sources/include_cint_root_v5.34.24.zip
unzip include_cint_root_v5.34.24.zip
cp -r cint /c/users/toldevel/external/toldevel-rtools-m32/debug/include/.
cp -r cint /c/users/toldevel/external/toldevel-rtools-m32/release/include/.

Los includes de cint han sido extraidos desde http://root.cern.ch/download/root_v5.34.24.source.tar.gz

===================
   BLAS/LAPACK
===================

wget http://packages.tol-prj.org/win32/development/lapack-mingw.zip
unzip lapack-mingw.zip
cd lapack-mingw/win32/
cp  *.dll /c/users/toldevel/external/toldevel-rtools-m32/debug/bin
cp  *.lib /c/users/toldevel/external/toldevel-rtools-m32/debug/lib
cp  *.dll /c/users/toldevel/external/toldevel-rtools-m32/release/bin
cp  *.lib /c/users/toldevel/external/toldevel-rtools-m32/release/lib

========
  GBLA
========

export BLAPI_BLAS_LIB=/c/Archivos\ de\ programa/R/R-3.1.2/bin/i386/Rblas.dll
export BLAPI_LAPACK_LIB=/c/Archivos\ de\ programa/R/R-3.1.2/bin/i386/Rlapack.dll

svn co https://www.tol-prj.org/svn/gbla
cd gbla/trunk/libltdl
CFLAGS='-m32 -O0 -ggdb -Wall -mno-align-double' configure --prefix=/c/users/toldevel/external/toldevel-rtools-m32/debug
cd ..
bjam cflags=-mno-align-double cxxflags=-mno-align-double variant=debug   runtime-link=shared threading=multi link=shared toolset=gcc --prefix=/c/users/toldevel/external/toldevel-rtools-m32/debug install
cd examples/blas
bjam cflags=-mno-align-double cxxflags=-mno-align-double variant=debug   runtime-link=shared threading=multi link=shared toolset=gcc --prefix=/c/users/toldevel/external/toldevel-rtools-m32/debug

ejecutar los test generados dentro del directorio bin.

cd gbla/trunk/libltdl
make distclean
CFLAGS='-m32 -O2 -Wall -DNDEBUG -mno-align-double'  configure --prefix=/c/users/toldevel/external/toldevel-rtools-m32/release
cd ..
bjam cflags=-mno-align-double cxxflags=-mno-align-double variant=release   runtime-link=shared threading=multi link=shared toolset=gcc --prefix=/c/users/toldevel/external/toldevel-rtools-m32/release install
cd examples/blas
bjam cflags=-mno-align-double cxxflags=-mno-align-double variant=release   runtime-link=shared threading=multi link=shared toolset=gcc --prefix=/c/users/toldevel/external/toldevel-rtools-m32/release

===============
  SuiteSparse: esta esta poco automatizada, hay que trabajarla mas
===============

SuitSparse no compila bien con bjam, al menos lo que tenemos preparado.

Ver este: https://github.com/jlblancoc/suitesparse-metis-for-windows

wget http://packages.tol-prj.org/win32/development/sources/SuiteSparse-4.4.1.tar.gz

Hay que editar SuiteSparse_config/SuiteSparse_config.mk y modificarlo para que use nuestras blas y lapack

BLAS = /c/users/toldevel/external/rtools-x86/release/lib/libblas.lib
LAPACK = /c/users/toldevel/external/rtools-x86/release/lib/liblapack.lib

tambien hay que eliminarla opcion de enlace -lrt 

al compilar las libs hay que especificar CC=gcc

editar "SuiteSparse_config.mk" para instalar en toldevel-rtools-m32/debug
CFLAGS='-m32 -O0 -ggdb -Wall -mno-align-double' CPPFLAGS='-O0 -ggdb -Wall -mno-align-double' CC=gcc make
make install
make distclean
editar "SuiteSparse_config.mk" para instalar en toldevel-rtools-m32/release
CFLAGS='-m32 -O2 -Wall -DNDEBUG -mno-align-double' CPPFLAGS='-O2 -Wall -DNDEBUG -mno-align-double' CC=gcc make
make install

======
 GSL
======

wget http://packages.tol-prj.org/win32/development/sources/gsl-1.16.tar.gz
tar zxf gsl-1.16.tar.gz
cd gsl-1.16

CFLAGS='-m32 -O0 -ggdb -Wall -mno-align-double' configure --prefix=/c/users/toldevel/external/toldevel-rtools-m32/debug --enable-shared
make
make install
make distclean
CFLAGS='-m32 -O2 -Wall -DNDEBUG -mno-align-double' configure --prefix=/c/users/toldevel/external/toldevel-rtools-m32/release --enable-shared
make
make install

./configure --prefix=/usr/local --enable-shared
make
make install

===================
   CBLAS/CLAPACK
===================

wget http://packages.tol-prj.org/win32/development/atlas-windows.zip
cd atlas-windows
cp -r include/* /c/users/toldevel/external/toldevel-rtools-m32/debug/include/.
cp  lib/* /c/users/toldevel/external/toldevel-rtools-m32/debug/lib/.
cp -r include/* /c/users/toldevel/external/toldevel-rtools-m32/release/include/.
cp  lib/* /c/users/toldevel/external/toldevel-rtools-m32/release/lib/.

===========
   ltdl
===========

wget http://packages.tol-prj.org/win32/development/sources/libtool-2.4.4.tar.gz
tar zxf libtool-2.4.4.tar.gz
cd libtool-2.4.4
CFLAGS='-m32 -O0 -ggdb -mno-align-double' CXXFLAGS='-m32 -O0 -ggdb -mno-align-double' configure --prefix=/c/users/toldevel/external/toldevel-rtools-m32/debug --enable-shared
make
make install
make distclean
CFLAGS='-m32 -O2 -Wall -DNDEBUG -mno-align-double' CXXFLAGS='-m32 -O2 -Wall -DNDEBUG -mno-align-double' ./configure --prefix=/c/users/toldevel/external/toldevel-rtools-m32/release --enable-shared
make
make install

============================
PostgreSQL client libraries
============================
see: https://pgolub.wordpress.com/2008/12/15/building-postgresql-client-library-using-mingw-under-winxp-sp3/

wget http://packages.tol-prj.org/win32/development/sources/postgresql-9.4.1.tar.gz 
tar zxf postgresql-9.4.1.tar.gz
cd postgresql-9.4.1

CFLAGS='-m32 -m32 -O0 -ggdb -mno-align-double' CXXFLAGS='-m32 -O0 -ggdb -mno-align-double' ./configure --without-zlib --prefix=/c/users/toldevel/external/toldevel-rtools-m32/debug
make -C src/common
make -C src/interfaces/libpq install
cp src/include/postgres_ext.h src/include/pg_config_ext.h /c/users/toldevel/external/toldevel-rtools-m32/debug/include/.

make distclean
CFLAGS='-m32 -m32 -O2 -Wall -DNDEBUG -mno-align-double' CXXFLAGS='-m32 -O2 -Wall -DNDEBUG -mno-align-double' ./configure --without-zlib --prefix=/c/users/toldevel/external/toldevel-rtools-m32/release
make -C src/common
make -C src/interfaces/libpq install
cp src/include/postgres_ext.h src/include/pg_config_ext.h /c/users/toldevel/external/toldevel-rtools-m32/release/include/.

Compilar Tcl
=============

wget http://packages.tol-prj.org/win32/development/sources/tcl8.4.20.zip
unzip tcl8.4.20.zip
cd tcl8.4.20
mkdir build-debug
mkdir build-release
cd build-debug
CFLAGS='-m32 -O0 -ggdb -mno-align-double' CXXFLAGS='-m32 -O0 -ggdb -mno-align-double' ../win/configure --prefix=/c/users/toldevel/external/toldevel-rtools-m32/debug --enable-threads --enable-shared
make
make install
make install-private-headers
cd ../build-release
CFLAGS='-m32 -O2 -Wall -DNDEBUG -mno-align-double' CXXFLAGS='-m32 -O2 -Wall -DNDEBUG -mno-align-double' ../win/configure --prefix=/c/users/toldevel/external/toldevel-rtools-m32/release --enable-threads --enable-shared
make
make install
make install-private-headers

Compilar Tk
============

wget http://packages.tol-prj.org/win32/development/sources/tk8.4.20.zip
unzip tk8.4.20.zip
cd tcl8.4.20
mkdir build-debug
mkdir build-release
cd build-debug
PATH=/c/users/toldevel/external/toldevel-rtools-m32/debug/bin:${PATH} CFLAGS='-m32 -O0 -ggdb -mno-align-double' CXXFLAGS='-m32 -O0 -ggdb -mno-align-double' ../win/configure --prefix=/c/users/toldevel/external/toldevel-rtools-m32/debug --enable-threads --enable-shared --with-tcl=/c/users/toldevel/external/toldevel-rtools-m32/debug/lib
make
make install
make install-private-headers
cd ../build-release
PATH=/c/users/toldevel/external/toldevel-rtools-m32/release/bin:${PATH} CFLAGS='-m32 -O2 -Wall -DNDEBUG -mno-align-double' CXXFLAGS='-m32 -O2 -Wall -DNDEBUG -mno-align-double' ../win/configure --prefix=/c/users/toldevel/external/toldevel-rtools-m32/release --enable-threads --enable-shared --with-tcl=/c/users/toldevel/external/toldevel-rtools-m32/release/lib
make
make install
make install-private-headers

================
   libcurl
================

wget http://packages.tol-prj.org/win32/development/sources/curl-7.40.0.tar.gz
tar zxf curl-7.40.0.tar.gz
cd curl-7.40.0 
CFLAGS='-m32 -O0 -ggdb -mno-align-double' CXXFLAGS='-m32 -O0 -ggdb -mno-align-double' ./configure --prefix=/c/users/toldevel/external/toldevel-rtools-m32/debug --enable-shared
make
make install
make distclean
CFLAGS='-m32 -O2 -Wall -mno-align-double' CPPFLAGS=-DNDEBUG CXXFLAGS='-m32 -O2 -Wall -mno-align-double' ./configure --prefix=/c/users/toldevel/external/toldevel-rtools-m32/release --enable-shared
make
make install

================
   TclCurl
================

OJO: UnxUtils/usr/local/wbin/bc.exe si esta en el path puede hacer que el configure falle. Renombrarlo. Hay que usar el que esta en /c/MinGW/bin, para eso incluir la ruta anterior en el path.

wget http://packages.tol-prj.org/win32/development/sources/tclcurl-7.22.0.zip
unzip tclcurl-7.22.0.zip
cd tclcurl-7.22.0
CFLAGS='-m32 -O0 -ggdb -mno-align-double' CXXFLAGS='-m32 -O0 -ggdb -mno-align-double' ./configure --with-tcl=/c/users/toldevel/external/toldevel-rtools-m32/debug/lib --with-curlprefix=/c/users/toldevel/external/toldevel-rtools-m32/debug --enable-threads --enable-symbols
make install
make distclean
CFLAGS='-m32 -O2 -Wall -mno-align-double' CPPFLAGS=-DNDEBUG CXXFLAGS='-m32 -O2 -Wall -mno-align-double' ./configure --with-tcl=/c/users/toldevel/external/toldevel-rtools-m32/release/lib --with-curlprefix=/c/users/toldevel/external/toldevel-rtools-m32/release --enable-threads

=======
  TOL
=======

cd tolp/trunk/tol
mkdir BUILD_CMAKE
cd BUILD_CMAKE
cmake -DFFTW_ROOT:PATH=c:/MinGW/msys/1.0/local -DFFTW_USE_STATIC_LIBS=1 -DCINT_ROOT_DIR:PATH=c:/users/toldevel/external/root_v5.34.24.source/root/cint/cint -DZIPARCHIVE_AS_STATIC=1 -DCBLAS_DIR=c:/users/toldevel/external/atlas-windows -DCLAPACK_DIR=c:/users/toldevel/external/atlas-windows -DCMAKE_BUILD_TYPE=Debug -G"MSYS Makefiles" ..

cmake -DCMAKE_C_FLAGS_DEBUG="-O0 -g2" -DCMAKE_CXX_FLAGS_RELEASE="-O0 -g2" -DTOL_EXTERNAL_DEVEL_DIR=C:\users\toldevel\external\TOL_DEVEL_MINGW32 -DCMAKE_BUILD_TYPE=Debug -G"CodeLite - MinGW Makefiles" ../..

cmake -DCMAKE_C_FLAGS_RELEASE='-O2 -Wall -DNDEBUG' -DCMAKE_CXX_FLAGS_RELEASE='-O2 -Wall -DNDEBUG' -DTOL_EXTERNAL_DIR=C:/users/toldevel/external/install -DCMAKE_BUILD_TYPE=Release -G"CodeLite - MinGW Makefiles" ../..

Para tolsh se require Tcl/Tk y otros paquetes como TclCurl

=============
   TclCurl
=============

download from https://bitbucket.org/smh377/tclcurl/downloads

Compilar MatQuery

mkdir CodeLite\Debug
cd CodeLite\Debug

cmake -DTOL_INCLUDE_DIR=c:\users\toldevel\tolp\trunk\tol\CodeLite\Debug -DTOL_LIBRARY=C:\users\toldevel\tolp\trunk\tol\CodeLite\Debug\libtol.dll -DGSL_INCLUDE_SEARCH=C:\users\toldevel\external\TOL_DEVEL_MINGW32\debug\include -DGSL_LIBS_SEARCH=C:\users\toldevel\external\TOL_DEVEL_MINGW32\debug\lib -DCMAKE_BUILD_TYPE=Debug -G"CodeLite - MinGW Makefiles" ../..

==================
  Compilar NLOPT
==================

==================
  Compilar IPOPT
==================

wget http://www.coin-or.org/download/source/Ipopt/Ipopt-3.12.2.tgz
tar zxf http://www.coin-or.org/download/source/Ipopt/Ipopt-3.12.2.tgz
cd Ipopt-3.12.2/ThirdParty/Blas
./get.Blas
cd Ipopt-3.12.2/ThirdParty/Lapack
./get.Lapack
cd Ipopt-3.12.2/ThirdParty/
cd Ipopt-3.12.2/Mumps
./get.Mumps
mkdir build
cd build
CFLAGS='-m32 -O2 -Wall -mno-align-double' CPPFLAGS=-DNDEBUG CXXFLAGS='-m32 -O2 -Wall -mno-align-double' ../configure --prefix=/usr/local/Ipopt-3-12.2 --enable-shared --enable-dependency-linking LD=ld
make

Mumps falla la compilacion hay que copiar el paso link y anadirle la opcion -Wl,--allow-multiple-definition luego retomar el paso make

El resultado de esta compilacion debe ir a TolIpopt\CppTools\MinGW_32 y TolIpopt\CppTools\Ipopt-mingw32

