Logo AND Algorithmique Numérique Distribuée

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