source: SH_SHM/trunk/setup/SHM-install.csh @ 1237

Revision 899, 9.6 KB checked in by marcus, 10 years ago (diff)

r407 | walther | 2013-02-07 16:33:46 +0100 (Do, 07. Feb 2013) | 2 Zeilen

  • added support for rlwrap tool (readline support for SH)
  • Property svn:executable set to *
Line 
1#! /bin/csh
2#
3# file install.csh
4#      ===========
5#
6# version 5, 17-Feb-2011
7#
8# Installation script for SH/SHM package
9
10set ext="undefined"
11if  ("`uname`" == "Linux")  then
12        set ext="linux"
13else if  ("`uname`" == "SunOS")  then
14        set ext="sol2.5.1"
15endif
16
17if  ("$1" == "")  then
18        echo "To be only used from self-extracting setup process!"
19else
20        # get parameters
21        set dstpath=$1
22endif
23
24# check parameters
25if  (! -w $dstpath)  then
26        echo "$0 : cannot write to installation path $dstpath.  Abort."
27        exit 1
28endif
29
30# find input files
31set pack_fk=""
32set pack_locsat=""
33
34if  ("`uname`" == "Linux")  then
35        if  (-e $dstpath/fk-linux.tar.gz)  set pack_fk=$dstpath/fk-linux.tar.gz
36        if  (-e $dstpath/locsat-linux.tar.gz)  set pack_locsat=$dstpath/locsat-linux.tar.gz
37else if  ("`uname`" == "SunOS")  then
38        if  (-e $dstpath/fk-sol2.5.1.tar.gz)  set pack_fk=$dstpath/fk-sol2.5.1.tar.gz
39        if  (-e $dstpath/locsat-sol2.5.1.tar.gz)  set pack_locsat=$dstpath/locsat-sol2.5.1.tar.gz
40else
41endif
42
43if  (-e $dstpath/libahio.a.$ext)  then
44        set use_ah=1
45else
46        set use_ah=0
47endif
48
49
50# default values
51set displ_res="undef"
52set userroot='$HOME/shfiles'
53if  ("`uname`" == "Linux")  then
54        set linux_colors="yes"
55else
56        set linux_colors="no"
57endif
58
59# find text editor
60set editor=""
61foreach  ed  (kate kwrite gedit textedit vuepad leafpad mousepad nedit xedit)
62        set res=`which $ed`
63        if  (-e "$res")  then
64                set editor=$ed
65                break
66        endif
67end
68
69# find ps viewer
70set psview=""
71foreach  psv (kghostview kpdf okular evince epdfview acroread xpdf ggv gv pageview)
72    set res=`which $psv`
73    if  (-e "$res")  then
74        set psview=$psv
75        break
76    endif
77end
78
79# check for some programs in search path
80set plist = ( gzip make gccmakedep gcc uil ar ranlib xterm )
81foreach p ($plist)
82        set res=`which $p`
83        if  (! -e "$res")  then
84                echo "Program $p not found in search path.  Please add."
85                exit 2
86        endif
87end
88
89# check for rlwrap tool
90set rlwrap=""
91set res=`which rlwrap`
92if  (-e "$res")  then
93    set rlwrap="rlwrap "
94endif
95
96set filterset="iaspei"
97
98# enter setup menu
99
100set cmd=""
101while  ("$cmd" != "i")
102
103        echo "======================================================================"
104        echo ""
105        echo "(u)  user root path:           $userroot"
106        echo "(f)  filter set:               $filterset"
107        echo "(e)  window based texteditor:  $editor"
108        echo "(p)  postscript viewer:        $psview"
109        echo "(c)  linux colors:             $linux_colors"
110        echo "(i)  Start Installation"
111        echo "(q)  Quit Installation"
112        echo ""
113        echo "If all settings are ok, enter 'i'"
114        echo ""
115        echo -n "Your command: "
116        set cmd="$<"
117
118        if  ("$cmd" == "q")  exit 99
119        if  ("$cmd" == "r")  then
120                if  ("$displ_res" == "xga")  then
121                        set displ_res="wxga"
122                else if  ("$displ_res" == "wxga")  then
123                        set displ_res="sxga"
124                else
125                        set displ_res="xga"
126                endif
127        endif
128        if  ("$cmd" == "c")  then
129                if  ("$linux_colors" == "yes")  then
130                        set linux_colors="no"
131                else
132                        set linux_colors="yes"
133                endif
134        endif
135        if  ("$cmd" == "e")  then
136                echo -n "window based texteditor: "
137                set editor="$<"
138                if  (! -e $editor)  then
139                        echo "$editor does not exist."
140                        echo -n "Enter <Return> ..."
141                        set x="$<"
142                        set editor=""
143                endif
144        endif
145        if  ("$cmd" == "p")  then
146                echo -n "postscript viewer: "
147                set psview="$<"
148                if  (! -e $psview)  then
149                        echo "$psview does not exist."
150                        echo -n "Enter <Return> ..."
151                        set x="$<"
152                        set psview=""
153                endif
154        endif
155        if  ("$cmd" == "u")  then
156                echo -n "user root path: "
157                set userroot="$<"
158                if  (! -e $userroot)  then
159                        mkdir $userroot
160                        if  (! -e $userroot)  then
161                                echo "cannot create $userroot. Reset to default."
162                                echo -n "Enter <Return> ..."
163                                set x="$<"
164                                set userroot=$HOME/shfiles
165                        endif
166                endif
167        endif
168    if ("$cmd" == "f") then
169        echo -n "filter set (classic or iaspei): "
170        set filterset="$<"
171        if ("$filterset" != "classic") then
172            set filterset="iaspei"
173        endif
174    endif
175        if  ("$cmd" == "i")  then
176                if  ("$editor" == "")   then
177                        echo "Please specify window based texteditor executable."
178                        echo -n "Enter <Return> ..."
179                        set x="$<"
180                        set cmd="."
181                endif
182        if  ("$psview" == "")   then
183            echo "Please specify postscript viewer executable."
184            echo -n "Enter <Return> ..."
185            set x="$<"
186            set cmd="."
187        endif
188        endif
189end
190
191cd $dstpath
192
193# create setup file from template
194echo "prepare setup file"
195cd sh/setup
196if  ("`uname`" == "Linux")  then
197        set remstr="#OS-linux "
198else if  ("`uname`" == "SunOS")  then
199        set remstr="#OS-sol2 "
200else
201        echo "$0 : sorry, this operating system is not supported"
202        exit 3
203endif
204set locsatpath=$dstpath/sh/util/locsat
205set plth=`echo $locsatpath | wc -c`
206
207# check for write access in /usr/bin -> create link for LocSAT installation path
208if (-w /usr/local) then
209    if  (-e /usr/local/LocSAT) \rm /usr/bin/LocSAT
210    ln -s $locsatpath /usr/local/LocSAT
211    set locsatpath=/usr/local/LocSAT
212# otherwise create link directly from user dir
213else if ($plth > 25)  then
214        if  (-e $HOME/lcs) \rm $HOME/lcs
215        ln -s $locsatpath $HOME/lcs
216        set locsatpath=$HOME/lcs
217        set plth=`echo $locsatpath | wc -c`
218        if  ($plth > 25)  then
219                echo "$0 : cannot find short locsat path.  Abort."
220                exit 4
221        endif
222endif
223
224sed "s/$remstr//" shsetup.template | sed "s@##ROOTPATH##@$dstpath/sh@" | \
225        sed "s@##LOCSATPATH##@$locsatpath@" | sed "s@##EDITOR##@$editor@" | \
226    sed "s@##PSVIEW##@$psview@" | \
227    sed "s@##RLWRAP##@$rlwrap@" | \
228        sed 's/-DSH_SETUP_SZGRF//' | sed "s@##USERROOT##@$userroot@" > shsetup
229sed "s/$remstr//" shsetup.sh.template | sed "s@##ROOTPATH##@$dstpath/sh@" | \
230        sed "s@##LOCSATPATH##@$locsatpath@" | sed "s@##EDITOR##@$editor@" | \
231    sed "s@##PSVIEW##@$psview@" | \
232    sed "s@##RLWRAP##@$rlwrap@" | \
233        sed 's/-DSH_SETUP_SZGRF//' | sed "s@##USERROOT##@$userroot@" > shsetup.sh
234
235if  ($use_ah == 0)  then
236        sed --in-place 's/-DSH_SETUP_AH//' shsetup
237        sed --in-place 's/-lahio//' shsetup
238endif
239if  ($?MACHTYPE == 1)  then
240        if  ("`echo $MACHTYPE | grep 64`" != "")  then
241                if  (-d /usr/X11R6/lib64)  then
242                        sed --in-place 's/\/usr\/X11R6\/lib/\/usr\/X11R6\/lib64/' shsetup
243                        sed --in-place 's/\/usr\/X11R6\/lib/\/usr\/X11R6\/lib64/' shsetup.sh
244                endif
245        endif
246endif
247source shsetup
248
249# create directories for evt files
250if (! -e $SH_USERROOT/evt/evid ) mkdir -p $SH_USERROOT/evt/evid
251if (! -e $SH_USERROOT/evt/evtout ) mkdir -p $SH_USERROOT/evt/evtout
252
253# find screen resolution
254set displ_res=`$dstpath/sh/util/get_screen_resolution.csh`
255if  ($#displ_res != 3)  then
256        echo "cannot find screen resolution, please set manually"
257        set displ_res="sxga"
258else
259        echo "found screen resolution $displ_res"
260        set displ_res=$displ_res[3]
261endif
262
263set origsetup=$dstpath/sh/inputs/shm-config-default.txt
264if  (! -e $origsetup)  then
265        echo "Installation program error.  Sorry."
266        exit  5
267endif
268set thissetup=$dstpath/sh/inputs/shm-config.txt
269if  (-e $thissetup)  then
270    \mv $thissetup $dstpath/sh/inputs/shm-config.txt.yours
271    echo "A backup of your shm-config.txt has been saved under:"
272    echo $dstpath/sh/inputs/shm-config.txt.yours
273endif
274sed "s@##EDITOR##@$editor@" $origsetup > $thissetup
275
276# settings for small displays (laptops)
277if  ("$displ_res" != "" && "$displ_res" != "sxga")  then
278        sed --in-place "s/shm-cof-sxga-geometry/shm-conf-$displ_res-geometry/" $thissetup
279endif
280
281# linux colors
282if  ("$linux_colors" == "yes")  then
283        # do nothing, this is default
284else
285        sed --in-place 's/reverse_xors                 true/reverse_xors                 false/' $thissetup
286endif
287
288# filter set
289cp $SH_FILTER/$filterset/* $SH_FILTER
290
291echo "compiling SHM"
292cd $SH_ROOT
293# remove all o's and a's
294find . -name '*.o' -print0 | xargs -0 rm
295cd $SH_LIB
296if  (-e libahio.a)  mv libahio.a libahio.ax
297\rm *.a > /dev/null
298if  (-e libahio.ax)  mv libahio.ax libahio.a
299cd $SH_ROOT
300make depend_shm
301make shm
302make world
303
304# install FK
305echo "extract FK package"
306cd $SH_UTIL
307if  (-e fk_src)  \rm -rf fk_src
308cp $pack_fk .
309set pack_fk=$pack_fk:t
310gzip -d $pack_fk
311set pack_fk=$pack_fk:r
312chmod +w $pack_fk
313tar xf $pack_fk
314\rm $pack_fk
315if  (-e fk)  \rm fk
316ln -s fk_src/fk fk
317
318# install LocSAT
319echo "extract LocSAT package"
320cd $SH_UTIL
321if  (-e locsat)  \rm -rf locsat
322mkdir locsat
323cp $pack_locsat .
324set pack_locsat=$pack_locsat:t
325gzip -d $pack_locsat
326set pack_locsat=$pack_locsat:r
327chmod +w $pack_locsat
328tar xf $pack_locsat
329\rm $pack_locsat
330if  (-e LocSAT)  \rm LocSAT
331ln -s locsat/bin/LocSAT LocSAT
332
333# add SHM resources to .Xdefaults
334set resrc=""
335if  (-e ~/.Xdefaults)  set resrc=~/.Xdefaults
336if  ("$resrc" == "")  then
337        if  (-e ~/.Xresources)  set resrc=~/.Xresources
338endif
339if  ("$resrc" == "")  then
340        set resrc="~/.Xdefaults"
341        touch $resrc
342endif
343set res=`grep "SHM.locsat_prefix_text" $resrc`
344if  ("$res" == "")  then
345        echo "SHM*locsat_prefix_text.value:       tab"  >>$resrc
346        echo "SHM*fk_frqlo_text.value:            0.4"  >>$resrc
347        echo "SHM*fk_frqhi_text.value:            3.0"  >>$resrc
348        echo "SHM*fk_slowness_text.value:         15"   >>$resrc
349        echo "SHM*fk_resol_text.value:            51"   >>$resrc
350        echo "SHM*fk_colnum_text.value:           10"   >>$resrc
351        echo "SHM*filter_butpar_hi_text.value:    1Hz"  >>$resrc
352        echo "SHM*filter_butpar_lo_text.value:    100s" >>$resrc
353        echo "SHM*filter_butpar_order_text.value: 4"    >>$resrc
354        echo "SHM*opick_thresh_text.value:        10.0" >>$resrc
355        echo "SHM*opick_duration_text.value:      1.0"  >>$resrc
356        echo "SHM*opick_break_text.value:         0.00" >>$resrc
357endif
358xrdb $resrc
359
360echo "========================================================================"
361echo ""
362echo "Please update your environment before using SH or SHM!"
363echo ""
364echo "If you prefer csh or tcsh put this line into your ~/.cshrc file:"
365echo "source $dstpath/sh/setup/shsetup"
366echo ""
367echo "If you prefer bash put this line into your ~/.bashrc file:"
368echo "source $dstpath/sh/setup/shsetup.sh"
369echo ""
370echo "========================================================================"
Note: See TracBrowser for help on using the repository browser.