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

Revision 518, 9.4 KB checked in by marcus, 11 years ago (diff)

r291 | walther | 2012-01-26 16:52:06 +0100 (Do, 26. Jan 2012) | 2 Zeilen

  • upgraded setup script to filter set choice
  • 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 ggv gv xpdf pageview acroread)
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
89set filterset="iaspei"
90
91# enter setup menu
92
93set cmd=""
94while  ("$cmd" != "i")
95
96        echo "======================================================================"
97        echo ""
98        echo "(u)  user root path:           $userroot"
99        echo "(f)  filter set:               $filterset"
100        echo "(e)  window based texteditor:  $editor"
101        echo "(p)  postscript viewer:        $psview"
102        echo "(c)  linux colors:             $linux_colors"
103        echo "(i)  Start Installation"
104        echo "(q)  Quit Installation"
105        echo ""
106        echo "If all settings are ok, enter 'i'"
107        echo ""
108        echo -n "Your command: "
109        set cmd="$<"
110
111        if  ("$cmd" == "q")  exit 99
112        if  ("$cmd" == "r")  then
113                if  ("$displ_res" == "xga")  then
114                        set displ_res="wxga"
115                else if  ("$displ_res" == "wxga")  then
116                        set displ_res="sxga"
117                else
118                        set displ_res="xga"
119                endif
120        endif
121        if  ("$cmd" == "c")  then
122                if  ("$linux_colors" == "yes")  then
123                        set linux_colors="no"
124                else
125                        set linux_colors="yes"
126                endif
127        endif
128        if  ("$cmd" == "e")  then
129                echo -n "window based texteditor: "
130                set editor="$<"
131                if  (! -e $editor)  then
132                        echo "$editor does not exist."
133                        echo -n "Enter <Return> ..."
134                        set x="$<"
135                        set editor=""
136                endif
137        endif
138        if  ("$cmd" == "p")  then
139                echo -n "postscript viewer: "
140                set psview="$<"
141                if  (! -e $psview)  then
142                        echo "$psview does not exist."
143                        echo -n "Enter <Return> ..."
144                        set x="$<"
145                        set psview=""
146                endif
147        endif
148        if  ("$cmd" == "u")  then
149                echo -n "user root path: "
150                set userroot="$<"
151                if  (! -e $userroot)  then
152                        mkdir $userroot
153                        if  (! -e $userroot)  then
154                                echo "cannot create $userroot. Reset to default."
155                                echo -n "Enter <Return> ..."
156                                set x="$<"
157                                set userroot=$HOME/shfiles
158                        endif
159                endif
160        endif
161    if ("$cmd" == "f") then
162        echo -n "filter set (classic or iaspei): "
163        set filterset="$<"
164        if ("$filterset" != "classic") then
165            set filterset="iaspei"
166        endif
167    endif
168        if  ("$cmd" == "i")  then
169                if  ("$editor" == "")   then
170                        echo "Please specify window based texteditor executable."
171                        echo -n "Enter <Return> ..."
172                        set x="$<"
173                        set cmd="."
174                endif
175        if  ("$psview" == "")   then
176            echo "Please specify postscript viewer executable."
177            echo -n "Enter <Return> ..."
178            set x="$<"
179            set cmd="."
180        endif
181        endif
182end
183
184cd $dstpath
185
186# create setup file from template
187echo "prepare setup file"
188cd sh/setup
189if  ("`uname`" == "Linux")  then
190        set remstr="#OS-linux "
191else if  ("`uname`" == "SunOS")  then
192        set remstr="#OS-sol2 "
193else
194        echo "$0 : sorry, this operating system is not supported"
195        exit 3
196endif
197set locsatpath=$dstpath/sh/util/locsat
198set plth=`echo $locsatpath | wc -c`
199
200# check for write access in /usr/bin -> create link for LocSAT installation path
201if (-w /usr/local) then
202    if  (-e /usr/local/LocSAT) \rm /usr/bin/LocSAT
203    ln -s $locsatpath /usr/local/LocSAT
204    set locsatpath=/usr/local/LocSAT
205# otherwise create link directly from user dir
206else if ($plth > 25)  then
207        if  (-e $HOME/lcs) \rm $HOME/lcs
208        ln -s $locsatpath $HOME/lcs
209        set locsatpath=$HOME/lcs
210        set plth=`echo $locsatpath | wc -c`
211        if  ($plth > 25)  then
212                echo "$0 : cannot find short locsat path.  Abort."
213                exit 4
214        endif
215endif
216
217sed "s/$remstr//" shsetup.template | sed "s@##ROOTPATH##@$dstpath/sh@" | \
218        sed "s@##LOCSATPATH##@$locsatpath@" | sed "s@##EDITOR##@$editor@" | \
219    sed "s@##PSVIEW##@$psview@" | \
220        sed 's/-DSH_SETUP_SZGRF//' | sed "s@##USERROOT##@$userroot@" > shsetup
221sed "s/$remstr//" shsetup.sh.template | sed "s@##ROOTPATH##@$dstpath/sh@" | \
222        sed "s@##LOCSATPATH##@$locsatpath@" | sed "s@##EDITOR##@$editor@" | \
223    sed "s@##PSVIEW##@$psview@" | \
224        sed 's/-DSH_SETUP_SZGRF//' | sed "s@##USERROOT##@$userroot@" > shsetup.sh
225
226if  ($use_ah == 0)  then
227        sed --in-place 's/-DSH_SETUP_AH//' shsetup
228        sed --in-place 's/-lahio//' shsetup
229endif
230if  ($?MACHTYPE == 1)  then
231        if  ("`echo $MACHTYPE | grep 64`" != "")  then
232                if  (-d /usr/X11R6/lib64)  then
233                        sed --in-place 's/\/usr\/X11R6\/lib/\/usr\/X11R6\/lib64/' shsetup
234                        sed --in-place 's/\/usr\/X11R6\/lib/\/usr\/X11R6\/lib64/' shsetup.sh
235                endif
236        endif
237endif
238source shsetup
239
240# create directories for evt files
241if (! -e $SH_USERROOT/evt/evid ) mkdir -p $SH_USERROOT/evt/evid
242if (! -e $SH_USERROOT/evt/evtout ) mkdir -p $SH_USERROOT/evt/evtout
243
244# find screen resolution
245set displ_res=`$dstpath/sh/util/get_screen_resolution.csh`
246if  ($#displ_res != 3)  then
247        echo "cannot find screen resolution, please set manually"
248        set displ_res="sxga"
249else
250        echo "found screen resolution $displ_res"
251        set displ_res=$displ_res[3]
252endif
253
254set origsetup=$dstpath/sh/inputs/shm-config-default.txt
255if  (! -e $origsetup)  then
256        echo "Installation program error.  Sorry."
257        exit  5
258endif
259set thissetup=$dstpath/sh/inputs/shm-config.txt
260if  (-e $thissetup)  then
261    \mv $thissetup $dstpath/sh/inputs/shm-config.txt.yours
262    echo "A backup of your shm-config.txt has been saved under:"
263    echo $dstpath/sh/inputs/shm-config.txt.yours
264endif
265sed "s@##EDITOR##@$editor@" $origsetup > $thissetup
266
267# settings for small displays (laptops)
268if  ("$displ_res" != "" && "$displ_res" != "sxga")  then
269        sed --in-place "s/shm-cof-sxga-geometry/shm-conf-$displ_res-geometry/" $thissetup
270endif
271
272# linux colors
273if  ("$linux_colors" == "yes")  then
274        # do nothing, this is default
275else
276        sed --in-place 's/reverse_xors                 true/reverse_xors                 false/' $thissetup
277endif
278
279# filter set
280cp $SH_FILTER/$filterset/* $SH_FILTER
281
282echo "compiling SHM"
283cd $SH_ROOT
284# remove all o's and a's
285find . -name '*.o' -print0 | xargs -0 rm
286cd $SH_LIB
287if  (-e libahio.a)  mv libahio.a libahio.ax
288\rm *.a > /dev/null
289if  (-e libahio.ax)  mv libahio.ax libahio.a
290cd $SH_ROOT
291make depend_shm
292make shm
293make world
294
295# install FK
296echo "extract FK package"
297cd $SH_UTIL
298if  (-e fk_src)  \rm -rf fk_src
299cp $pack_fk .
300set pack_fk=$pack_fk:t
301gzip -d $pack_fk
302set pack_fk=$pack_fk:r
303chmod +w $pack_fk
304tar xf $pack_fk
305\rm $pack_fk
306if  (-e fk)  \rm fk
307ln -s fk_src/fk fk
308
309# install LocSAT
310echo "extract LocSAT package"
311cd $SH_UTIL
312if  (-e locsat)  \rm -rf locsat
313mkdir locsat
314cp $pack_locsat .
315set pack_locsat=$pack_locsat:t
316gzip -d $pack_locsat
317set pack_locsat=$pack_locsat:r
318chmod +w $pack_locsat
319tar xf $pack_locsat
320\rm $pack_locsat
321if  (-e LocSAT)  \rm LocSAT
322ln -s locsat/bin/LocSAT LocSAT
323
324# add SHM resources to .Xdefaults
325set resrc=""
326if  (-e ~/.Xdefaults)  set resrc=~/.Xdefaults
327if  ("$resrc" == "")  then
328        if  (-e ~/.Xresources)  set resrc=~/.Xresources
329endif
330if  ("$resrc" == "")  then
331        set resrc="~/.Xdefaults"
332        touch $resrc
333endif
334set res=`grep "SHM.locsat_prefix_text" $resrc`
335if  ("$res" == "")  then
336        echo "SHM*locsat_prefix_text.value:       tab"  >>$resrc
337        echo "SHM*fk_frqlo_text.value:            0.4"  >>$resrc
338        echo "SHM*fk_frqhi_text.value:            3.0"  >>$resrc
339        echo "SHM*fk_slowness_text.value:         15"   >>$resrc
340        echo "SHM*fk_resol_text.value:            51"   >>$resrc
341        echo "SHM*fk_colnum_text.value:           10"   >>$resrc
342        echo "SHM*filter_butpar_hi_text.value:    1Hz"  >>$resrc
343        echo "SHM*filter_butpar_lo_text.value:    100s" >>$resrc
344        echo "SHM*filter_butpar_order_text.value: 4"    >>$resrc
345        echo "SHM*opick_thresh_text.value:        10.0" >>$resrc
346        echo "SHM*opick_duration_text.value:      1.0"  >>$resrc
347        echo "SHM*opick_break_text.value:         0.00" >>$resrc
348endif
349xrdb $resrc
350
351echo "========================================================================"
352echo ""
353echo "Please update your environment before using SH or SHM!"
354echo ""
355echo "If you prefer csh or tcsh put this line into your ~/.cshrc file:"
356echo "source $dstpath/sh/setup/shsetup"
357echo ""
358echo "If you prefer bash put this line into your ~/.bashrc file:"
359echo "source $dstpath/sh/setup/shsetup.sh"
360echo ""
361echo "========================================================================"
Note: See TracBrowser for help on using the repository browser.