3c2205437941072ed5d2fc6ebf62718f72bc36f4
[swifty.git] / src / libswift_udp / mfold / build.default.sh
1 #!/bin/bash
2
3 if [ -e ~/.building_swift ]; then
4     exit 0
5 fi
6
7 touch ~/.building_swift
8
9 if ! which git || ! which g++ || ! which scons || ! which make ; then
10     sudo apt-get -y install make g++ scons git-core || exit 1
11 fi
12
13 if [ ! -e ~/include/event.h ]; then
14     echo installing libevent
15     mkdir tmp
16     cd tmp || exit 2
17     wget -c http://monkey.org/~provos/libevent-2.0.7-rc.tar.gz || exit 3
18     rm -rf libevent-2.0.7-rc
19     tar -xzf libevent-2.0.7-rc.tar.gz || exit 4
20     cd libevent-2.0.7-rc/ || exit 5
21     ./configure --prefix=$HOME || exit 6
22     make || exit 7
23     make install || exit 8
24     cd ~/
25     echo done libevent
26 fi
27
28 if [ ! -e ~/include/gtest/gtest.h ]; then
29     echo installing gtest
30     mkdir tmp
31     cd tmp || exit 9
32     wget -c http://googletest.googlecode.com/files/gtest-1.4.0.tar.bz2 || exit 10 
33     rm -rf gtest-1.4.0
34     tar -xjf gtest-1.4.0.tar.bz2 || exit 11
35     cd gtest-1.4.0 || exit 12
36     ./configure --prefix=$HOME || exit 13
37     make || exit 14
38     make install || exit 15
39     cd ~/
40     echo done gtest
41 fi
42
43 #if ! which pcregrep ; then
44 #    echo installing pcregrep
45 #    mkdir tmp
46 #    cd tmp
47 #    wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.01.tar.gz || exit 5
48 #    tar -xzf pcre-8.01.tar.gz 
49 #    cd pcre-8.01
50 #    ./configure --prefix=$HOME || exit 6
51 #    make -j4 || exit 7
52 #    make install || exit 8
53 #    echo done pcregrep
54 #fi
55
56 if [ ! -e swift ]; then
57     echo clone the repo
58     git clone $ORIGIN || exit 16
59 fi
60 cd swift
61 echo switching the branch
62 git checkout $BRANCH || exit 17
63 echo pulling updates
64 git pull origin $BRANCH:$BRANCH || exit 18
65
66 echo building
67 INCL=~/include LIB=~/lib
68 CPPPATH=$INCL LIBPATH=$LIB scons -j4 || exit 19
69 echo testing
70 LD_LIBRARY_PATH=$LIB tests/connecttest || exit 20
71
72 # TODO: one method
73 mv bingrep.cpp ext/
74 if [ ! -e bin ]; then mkdir bin; fi
75 g++ -I. -I$INCL *.cpp ext/seq_picker.cpp -pg -o bin/swift-pg -L$LIB -levent &
76 g++ -I. -I$INCL *.cpp ext/seq_picker.cpp -g -o bin/swift-dbg -L$LIB -levent &
77 g++ -I. -I$INCL *.cpp ext/seq_picker.cpp -O2 -o bin/swift-o2 -L$LIB -levent &
78 wait
79
80 rm ~/.building_swift
81
82 echo done