Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
e93769b3a17aee55e3c83e328be8834eb0c0043a
[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/buildtools/scripts/cchange-svn-wc-format.py ${SIMGRID_SVN_ROOT} 1.5
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 -C src libgras.la
48     make -C tools/gras
49     make dist
50
51     echo "Copy the archive in position"
52     mkdir -p ${SIMGRID_BASEDIR}
53     mv ${version}.tar.gz ${SIMGRID_BASEDIR}
54   else
55     echo "${SIMGRID_BASEDIR}/${version}.tar.gz already exists. Don't rebuild"
56   fi
57 }
58
59 # clean_node: remove everything about this node
60 clean_node() {
61   OS=`uname`
62   node=`uname -n`
63   # OS specific working directory 
64   BUILDDIR=${SIMGRID_BASEDIR}/$OS/$node/$version
65   export BUILDDIR
66   
67   # Clean any leftover from previous install
68   if [ -e $BUILDDIR ] ; then
69     echo "remove old directory $BUILDDIR"
70     rm -rf $BUILDDIR
71   fi
72   mkdir -p $BUILDDIR
73 }
74
75 # open_archive: wait for archive to be built, cleanup previous
76 open_archive() {
77   get_version
78   clean_node
79   wait_archive
80   cd $BUILDDIR/..
81   tar xfz ${SIMGRID_BASEDIR}/${version}.tar.gz
82   cd $BUILDDIR
83 }
84