Sunday, August 16, 2009

little script to compil all open-cobol and dependencies

Because some regular update with Open-cobol, I have created a little script to update automatically new binaries in Linux (Kubuntu 9.04 32 bits).
Ths script (called 'compil-oc.sh') is on $HOME/open-cobol/ folder




#!/bin/bash
prefix=$(date +%Y%m%d%H%M)
current_folder=`pwd`
db_berkeley_path=$current_folder/bin_db-4.5.20.NC-${prefix}
gmp_path=$current_folder/bin_gmp-4.2.4-${prefix}
open_cobol_path=$current_folder/bin_open_cobol-${prefix}

# gmp exist ?
if [ -f gmp-4.2.4.tar.gz ];then
rm -f gmp-4.2.4.tar.gz
fi
wget ftp://ftp.gmplib.org/pub/gmp-4.2.4/gmp-4.2.4.tar.gz
tar -xzvf gmp-4.2.4.tar.gz
cd gmp-4.2.4
./configure --prefix=${gmp_path} --enable-shared --disable-static
echo "./configure --prefix=${gmp_path} --enable-shared --disable-static"
make
make check
make install
cd ..

# db berkeley ?
if [ -f db-4.5.20.NC.tar.gz ];then
rm -f db-4.5.20.NC.tar.gz
fi
wget http://download.oracle.com/berkeley-db/db-4.5.20.NC.tar.gz
tar -xzvf db-4.5.20.NC.tar.gz
cd db-4.5.20.NC/build_unix/
../dist/configure --prefix=${db_berkeley_path}
make
make install
cd ../..


rm -rf ./open-cobol

cvs -d:pserver:anonymous@open-cobol.cvs.sourceforge.net:/cvsroot/open-cobol login
cvs -z3 -d:pserver:anonymous@open-cobol.cvs.sourceforge.net:/cvsroot/open-cobol co -P open-cobol
cd open-cobol
export LD_LIBRARY_PATH=${gmp_path}/lib:${db_berkeley_path}/lib
export PATH=${gmp_path}/bin:${db_berkeley_path}/bin:$PATH
export CPPFLAGS="-I${gmp_path}/include/ -I${db_berkeley_path}/include/"
export LDFLAGS="-L${gmp_path}/lib/ -lgmp -L${db_berkeley_path}/lib/ -ldb"


echo "export LD_LIBRARY_PATH=${gmp_path}/lib:${db_berkeley_path}/lib"
echo "export PATH=${gmp_path}/bin:${db_berkeley_path}/bin:$PATH"
echo "export CPPFLAGS=\"-I${gmp_path}/include/ -I${db_berkeley_path}/include/\"""
echo "export LDFLAGS=\"-L${gmp_path}/lib/ -lgmp -L${db_berkeley_path}/lib/ -ldb\"""
./configure --prefix=${open_cobol_path}
make
make check
make install

# generate script profile
mv $HOME/cobol_profile $HOME/cobol_profile.old
echo "export LD_LIBRARY_PATH=${gmp_path}/lib:${db_berkeley_path}/lib:${open_cobol_path}/lib:\$LD_LIBRARY_PATH" >>$HOME/cobol_profile
echo "export PATH=${gmp_path}/bin:${db_berkeley_path}/bin:${open_cobol_path}/bin:${open_cobol_path}/bin:\$PATH" >>$HOME/cobol_profile
chmod u+x $HOME/cobol_profile




In the 'CVS Password',just or give your email address.
You should certainly install specific package like gcc, g++,make,texinfo for compil successfull.

to add environment variable, just execute . $HOME/cobol_profile