source: tags/ms_r16q2/util/arb_compile.sh

Last change on this file was 14630, checked in by westram, 8 years ago
  • compile-script:
    • allow to configure
      • cleanup (before update and build)
      • revert (before update)
    • use $SHELL instead of hardcoded tcsh
  • Property svn:executable set to *
File size: 4.3 KB
Line 
1#!/bin/bash
2#
3# How to use:
4#
5# A. SETUP
6# --------
7#
8# 1. create a new directory, e.g.
9# mkdir my_arb_compile; cd my_arb_compile
10#
11# 2. checkout arb, e.g. (the last argument is the name of the target directory)
12# svn co svn+ssh://USERNAME@svn.arb-home.de/svn/ARB/trunk myARB
13# # or
14# svn co http://vc.arb-home.de/readonly/trunk myARB
15#
16# 3. link the included compile script, e.g.
17# ln -s myARB/util/arb_compile.sh compile_myARB.sh
18#
19# 4. call the script
20# ./compile_myARB.sh
21#
22# 5. review the generated config
23# vi compile_myARB.config
24#
25# 6. call the script again (this will generate config.makefile and fail)
26# ./compile_myARB.sh
27#
28# 7. edit the generated config.makefile (default builds a openGL/64bit/linux-ARB)
29# vi myARB/config.makefile
30#
31# 8. call the script again (this shall succeed)
32# ./compile_myARB.sh
33#
34#
35# B. UPGRADE
36# -----------
37#
38# 1. simply call the script to upgrade ARB to newest revision
39# ./compile_myARB.sh
40#
41#
42# C. Multiple versions (in one 'my_arb_compile' directory)
43# --------------------
44#
45# When you use a different name for the link target in step A.3. it
46# is possible to work with multiple checkouts and multiple configs
47# inside the same 'my_arb_compile' directory.
48# The name used as checkout directory has to be changed for subsequent
49# versions. Change 'myARB' to a different name in steps A.2., A.3. and A.7
50#
51
52# -------------------------------------------
53# default values for optional config entries:
54
55REVERT=1
56CLEAN=1
57
58# -------------------------------------------
59
60default_config() {
61    echo "# config to compile ARB via $BASENAME.sh"
62    echo ""
63    echo "# Subdirectory in which ARB is located:"
64    echo "SUBDIR=myARB"
65    echo ""
66    echo "# Real CPU cores"
67    echo "CORES=2"
68    echo ""
69    echo "# SVN revision to use (empty=newest)"
70    echo "REVISION="
71    echo ""
72    echo "# normally this script reverts all local changes (uncomment the next line to avoid that)"
73    echo "#REVERT=0"
74    echo ""
75    echo "# normally this script always does a complete rebuild (uncomment the next line to avoid that)"
76    echo "#CLEAN=0"
77}
78
79clean() {
80    if [ "$CLEAN" = "1" ]; then
81        make clean
82    else
83        echo "No cleanup done before update"
84        true
85    fi
86}
87
88revert() {
89    if [ "$REVERT" = "1" ]; then
90        svn revert -R .
91    else
92        echo "Did not revert local changes"
93        echo "Current local changes are:"
94        echo "-----------------------------"
95        svn diff
96        echo "-----------------------------"
97        true
98    fi
99}
100
101update() {
102    set -x
103    clean && \
104        revert && \
105        svn up --force $UPDATE_ARGS
106}
107build() {
108    if [ "$CLEAN" = "1" ]; then
109        make -j$CORES tarfile
110    else
111        echo "No cleanup done before compilation"
112        make -j$CORES tarfile_quick
113    fi
114}
115
116upgrade() {
117    echo "Upgrading ARB checkout in '$ARBHOME'"
118    echo ""
119    echo "Starting build process"
120    echo "(you may watch the output using"
121    echo "     less +F $LOG"
122    echo "in another terminal)"
123    echo ""
124    (update && build) >& $LOG
125}
126
127arbshell() {
128    echo "ARBHOME now is '$ARBHOME'"
129    $ARBHOME/bin/arb_ntree --help 2>&1 | grep version
130    echo "Opening a new shell ('$SHELL'). Run arb here. Press ctrl-d to close this shell."
131    $SHELL
132    ARBHOME=$OLDARBHOME
133    echo "ARBHOME now is again '$ARBHOME'"
134}
135
136# ----------------------------------------
137
138if [ !$?ARBHOME ]; then
139    ARBHOME=''
140fi   
141OLDARBHOME=$ARBHOME
142
143BASEDIR=`pwd`
144BASENAME=`basename $0 | perl -pne 's/.sh//'`
145
146echo "BASENAME='$BASENAME'"
147
148CONFIG=$BASENAME.config
149LOG=$BASEDIR/$BASENAME.log
150
151if [ -f $CONFIG ]; then
152    source $CONFIG
153else
154    default_config > $CONFIG
155    echo "$CONFIG has been generated"
156    SUBDIR=
157fi
158
159if [ "$SUBDIR" = "" ]; then
160    echo "Review config, then rerun this script"
161else
162    ARBHOME=$BASEDIR/$SUBDIR
163
164    if [ ! -d $ARBHOME ]; then
165        echo "ARBHOME='$ARBHOME' (no such directory)"
166    else
167        PATH=$ARBHOME/bin:$PATH
168        if [ !$?LD_LIBRARY_PATH ]; then
169            LD_LIBRARY_PATH=$ARBHOME/lib
170        fi
171        LD_LIBRARY_PATH=$ARBHOME/lib:$LD_LIBRARY_PATH
172
173        export ARBHOME PATH LD_LIBRARY_PATH
174
175        cd $ARBHOME
176
177        if [ "$REVISION" = "" ]; then
178            UPDATE_ARGS=
179        else
180            UPDATE_ARGS="-r $REVISION"
181        fi
182
183        (upgrade && echo "ARB upgrade succeeded" && arbshell) || ( echo "Error: Something failed (see $LOG)" && false)
184    fi
185fi
186
Note: See TracBrowser for help on using the repository browser.