Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
b366288124c2fc4b754da057e16fe1d5ea82a45c
[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     svn up
10     version="simgrid-3.3.4-svn-r"`svnversion`
11     export version
12   fi
13 }
14
15 # wait_archive: wait until the archive gets defined into the right position
16 wait_archive() {
17   while [ ! -e ${SIMGRID_BASEDIR}/${version}.tar.gz ] ; do
18     echo ${SIMGRID_BASEDIR}/${version}.tar.gz not found. Wait five seconds.
19     sleep 5
20   done
21 }
22
23 # make_dist: rebuild an archive from the svn
24 make_dist() {
25   get_version
26   if [ ! -e ${SIMGRID_BASEDIR}/${version}.tar.gz ] ; then
27     cd ${SIMGRID_SVN_ROOT}
28     echo "rebuild the missing files for compilation"
29     if [ ! -e configure ] ; then
30       ./bootstrap
31     fi
32     # Reconfigure in any case or the svn version won't get updated
33     # (disable compilation optim to make it built faster)
34     ./configure --enable-maintainer-mode --disable-compile-optimizations
35     echo "Make the archive"
36     make all dist
37
38     echo "Copy the archive in position"
39     mkdir -p ${SIMGRID_BASEDIR}
40     mv ${version}.tar.gz ${SIMGRID_BASEDIR}
41   else
42     echo "${SIMGRID_BASEDIR}/${version}.tar.gz already exists. Don't rebuild"
43   fi
44 }
45
46 # clean_node: remove everything about this node
47 clean_node() {
48   OS=`uname`
49   node=`uname -n`
50   # OS specific working directory 
51   BUILDDIR=${SIMGRID_BASEDIR}/$OS/$node/$version
52   export BUILDDIR
53   
54   # Clean any leftover from previous install
55   if [ -e $BUILDDIR ] ; then
56     echo "remove old directory $BUILDDIR"
57     rm -rf $BUILDDIR
58   fi
59   mkdir -p $BUILDDIR
60 }
61
62 # open_archive: wait for archive to be built, cleanup previous
63 open_archive() {
64   get_version
65   clean_node
66   wait_archive
67   cd $BUILDDIR/..
68   tar xfz ${SIMGRID_BASEDIR}/${version}.tar.gz
69   cd $BUILDDIR
70 }
71