Logo AND Algorithmique Numérique Distribuée

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