Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Install the libraries carefully so that we have a link from .so to .so.version
[simgrid.git] / buildtools / scripts / simgrid_build.functions
1 # This file defines a bunch of useful functions to automatize the build of SimGrid.
2
3
4
5 # get_version: define the version number of the svn into a version variable
6 get_version() {
7   if [ x$version = x ] ; then
8     cd ${SIMGRID_SVN_ROOT}
9     if [ -e .svn ] ; then
10       set +e
11       svn up 2>/dev/null
12       if [ $? != 0 ] ; then
13         set -e
14         ${SIMGRID_SVN_ROOT}/buildtools/scripts/change-svn-wc-format.py ${SIMGRID_SVN_ROOT} 1.4
15         svn up
16       fi
17       set -e
18       version="simgrid-3.3.4-svn-r"`svnversion`
19     else if [ -e .git ] ; then
20       version="simgrid-3.3.4-git-r"`git log --oneline -1 | sed 's| .*||'`
21     fi fi
22     export version
23   fi
24 }
25
26 # wait_archive: wait until the archive gets defined into the right position
27 wait_archive() {
28   while [ ! -e ${SIMGRID_BASEDIR}/${version}.tar.gz ] ; do
29     echo ${SIMGRID_BASEDIR}/${version}.tar.gz not found. Wait five seconds.
30     sleep 5
31   done
32 }
33
34 # make_dist: rebuild an archive from the svn
35 make_dist() {
36   get_version
37   if [ ! -e ${SIMGRID_BASEDIR}/${version}.tar.gz ] ; then
38     cd ${SIMGRID_SVN_ROOT}
39     echo "rebuild the missing files for compilation"
40     if [ ! -e configure ] ; then
41       ./bootstrap
42     fi
43     # Reconfigure in any case or the svn version won't get updated
44     # (disable compilation optim to make it built faster)
45     ./configure --enable-maintainer-mode --disable-compile-optimizations
46     echo "Make the archive"
47     make clean
48     make -C src libgras.la
49     make -C tools/gras
50     make dist
51
52     echo "Copy the archive in position"
53     mkdir -p ${SIMGRID_BASEDIR}
54     mv ${version}.tar.gz ${SIMGRID_BASEDIR}
55   else
56     echo "${SIMGRID_BASEDIR}/${version}.tar.gz already exists. Don't rebuild"
57   fi
58 }
59
60 # clean_node: remove everything about this node
61 clean_node() {
62   OS=`uname`
63   node=`uname -n`
64   # OS specific working directory 
65   BUILDDIR=${SIMGRID_BASEDIR}/$OS/$node/$version
66   export BUILDDIR
67   
68   # Clean any leftover from previous install
69   if [ -e $BUILDDIR ] ; then
70     echo "remove old directory $BUILDDIR"
71     rm -rf $BUILDDIR
72   fi
73   mkdir -p $BUILDDIR
74 }
75
76 # open_archive: wait for archive to be built, cleanup previous
77 open_archive() {
78   get_version
79   clean_node
80   wait_archive
81   cd $BUILDDIR/..
82   tar xfz ${SIMGRID_BASEDIR}/${version}.tar.gz
83   cd $BUILDDIR
84 }
85