source: branches/profile/util/arb_compile.sh

Last change on this file was 12527, checked in by westram, 10 years ago

use readonly svn url

  • Property svn:executable set to *
File size: 3.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://svn.mikro.biologie.tu-muenchen.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
53default_config() {
54    echo "# config to compile ARB via $BASENAME.sh"
55    echo ""
56    echo "# Subdirectory in which ARB is located:"
57    echo "SUBDIR=myARB"
58    echo ""
59    echo "# Real CPU cores"
60    echo "CORES=2"
61    echo ""
62    echo "# SVN revision to use (empty=newest)"
63    echo "REVISION="
64    echo ""
65}
66
67update() {
68    set -x
69    make clean && \
70        svn revert -R . && \
71        svn up --force $UPDATE_ARGS
72}
73build() {
74    make -j$CORES tarfile
75}
76
77upgrade() {
78    echo "Upgrading ARB checkout in '$ARBHOME'"
79    echo ""
80    echo "Starting build process"
81    echo "(you may watch the output using"
82    echo "     less +F $LOG"
83    echo "in another terminal)"
84    echo ""
85    (update && build) >& $LOG
86}
87
88arbshell() {
89    echo "ARBHOME now is '$ARBHOME'"
90    $ARBHOME/bin/arb_ntree --help 2>&1 | grep version
91    tcsh
92    ARBHOME=$OLDARBHOME
93    echo "ARBHOME now is again '$ARBHOME'"
94}
95
96# ----------------------------------------
97
98if [ !$?ARBHOME ]; then
99    ARBHOME=''
100fi   
101OLDARBHOME=$ARBHOME
102
103BASEDIR=`pwd`
104BASENAME=`basename $0 | perl -pne 's/.sh//'`
105
106echo "BASENAME='$BASENAME'"
107
108CONFIG=$BASENAME.config
109LOG=$BASEDIR/$BASENAME.log
110
111if [ -f $CONFIG ]; then
112    source $CONFIG
113else
114    default_config > $CONFIG
115    echo "$CONFIG has been generated"
116    SUBDIR=
117fi
118
119if [ "$SUBDIR" = "" ]; then
120    echo "Review config, then rerun this script"
121else
122    ARBHOME=$BASEDIR/$SUBDIR
123
124    if [ ! -d $ARBHOME ]; then
125        echo "ARBHOME='$ARBHOME' (no such directory)"
126    else
127        PATH=$ARBHOME/bin:$PATH
128        if [ !$?LD_LIBRARY_PATH ]; then
129            LD_LIBRARY_PATH=$ARBHOME/lib
130        fi
131        LD_LIBRARY_PATH=$ARBHOME/lib:$LD_LIBRARY_PATH
132
133        export ARBHOME PATH LD_LIBRARY_PATH
134
135        cd $ARBHOME
136
137        if [ "$REVISION" = "" ]; then
138            UPDATE_ARGS=
139        else
140            UPDATE_ARGS="-r $REVISION"
141        fi
142
143        (upgrade && echo "ARB upgrade succeeded" && arbshell) || ( echo "Error: Something failed (see $LOG)" && false)
144    fi
145fi
146
Note: See TracBrowser for help on using the repository browser.