File: arb_compile.sh

package info (click to toggle)
arb 6.0.6-8
  • links: PTS, VCS
  • area: non-free
  • in suites: sid, trixie
  • size: 66,204 kB
  • sloc: ansic: 394,911; cpp: 250,290; makefile: 19,644; sh: 15,879; perl: 10,473; fortran: 6,019; ruby: 683; xml: 503; python: 53; awk: 32
file content (146 lines) | stat: -rwxr-xr-x 3,343 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/bash
#
# How to use:
#
# A. SETUP
# --------
#
# 1. create a new directory, e.g.
# mkdir my_arb_compile; cd my_arb_compile
# 
# 2. checkout arb, e.g. (the last argument is the name of the target directory) 
# svn co svn+ssh://USERNAME@svn.arb-home.de/svn/ARB/trunk myARB
# # or
# svn co http://vc.arb-home.de/readonly/trunk myARB
#
# 3. link the included compile script, e.g.
# ln -s myARB/util/arb_compile.sh compile_myARB.sh
#
# 4. call the script
# ./compile_myARB.sh
#
# 5. review the generated config
# vi compile_myARB.config
#
# 6. call the script again (this will generate config.makefile and fail)
# ./compile_myARB.sh
#
# 7. edit the generated config.makefile (default builds a openGL/64bit/linux-ARB)
# vi myARB/config.makefile
#
# 8. call the script again (this shall succeed)
# ./compile_myARB.sh
#
#
# B. UPGRADE
# -----------
#
# 1. simply call the script to upgrade ARB to newest revision
# ./compile_myARB.sh
#
#
# C. Multiple versions (in one 'my_arb_compile' directory)
# --------------------
#
# When you use a different name for the link target in step A.3. it
# is possible to work with multiple checkouts and multiple configs
# inside the same 'my_arb_compile' directory.
# The name used as checkout directory has to be changed for subsequent
# versions. Change 'myARB' to a different name in steps A.2., A.3. and A.7
#


default_config() {
    echo "# config to compile ARB via $BASENAME.sh"
    echo ""
    echo "# Subdirectory in which ARB is located:"
    echo "SUBDIR=myARB"
    echo ""
    echo "# Real CPU cores"
    echo "CORES=2"
    echo ""
    echo "# SVN revision to use (empty=newest)"
    echo "REVISION="
    echo ""
}

update() {
    set -x
    make clean && \
        svn revert -R . && \
        svn up --force $UPDATE_ARGS
}
build() {
    make -j$CORES tarfile
}

upgrade() {
    echo "Upgrading ARB checkout in '$ARBHOME'"
    echo ""
    echo "Starting build process"
    echo "(you may watch the output using"
    echo "     less +F $LOG"
    echo "in another terminal)"
    echo ""
    (update && build) >& $LOG
}

arbshell() {
    echo "ARBHOME now is '$ARBHOME'"
    $ARBHOME/bin/arb_ntree --help 2>&1 | grep version
    tcsh
    ARBHOME=$OLDARBHOME
    echo "ARBHOME now is again '$ARBHOME'"
}

# ---------------------------------------- 

if [ !$?ARBHOME ]; then
    ARBHOME=''
fi    
OLDARBHOME=$ARBHOME

BASEDIR=`pwd`
BASENAME=`basename $0 | perl -pne 's/.sh//'`

echo "BASENAME='$BASENAME'"

CONFIG=$BASENAME.config
LOG=$BASEDIR/$BASENAME.log

if [ -f $CONFIG ]; then
    source $CONFIG
else
    default_config > $CONFIG
    echo "$CONFIG has been generated"
    SUBDIR=
fi

if [ "$SUBDIR" = "" ]; then
    echo "Review config, then rerun this script"
else
    ARBHOME=$BASEDIR/$SUBDIR

    if [ ! -d $ARBHOME ]; then
        echo "ARBHOME='$ARBHOME' (no such directory)"
    else
        PATH=$ARBHOME/bin:$PATH
        if [ !$?LD_LIBRARY_PATH ]; then
            LD_LIBRARY_PATH=$ARBHOME/lib
        fi
        LD_LIBRARY_PATH=$ARBHOME/lib:$LD_LIBRARY_PATH

        export ARBHOME PATH LD_LIBRARY_PATH

        cd $ARBHOME

        if [ "$REVISION" = "" ]; then
            UPDATE_ARGS=
        else
            UPDATE_ARGS="-r $REVISION"
        fi

        (upgrade && echo "ARB upgrade succeeded" && arbshell) || ( echo "Error: Something failed (see $LOG)" && false)
    fi
fi