1 |
|
---|
2 | if test $# -gt "0" ; then
|
---|
3 | if test -z ${1##GEXT*} ; then
|
---|
4 |
|
---|
5 | ext=$1 ; shift
|
---|
6 | reldir=$1 ; shift
|
---|
7 | eval exthome=`echo \\$$ext`
|
---|
8 | if test -z "$exthome" ; then
|
---|
9 | echo "Environment variable $1 for Greenstone extension not set"
|
---|
10 | echo "Sourcing $reldir/setup.bash"
|
---|
11 | source $reldir/setup.bash
|
---|
12 | fi
|
---|
13 | fi
|
---|
14 | fi
|
---|
15 |
|
---|
16 | if test -z $GSDLOS ; then
|
---|
17 | GSDLOS=`uname -s | tr '[A-Z]' '[a-z]'`
|
---|
18 | # check for running bash under Cygwin
|
---|
19 | if test "`echo $GSDLOS | sed 's/cygwin//'`" != "$GSDLOS" ;
|
---|
20 | then
|
---|
21 | GSDLOS=windows
|
---|
22 | fi
|
---|
23 | # check for running bash under MinGW/MSys
|
---|
24 | if test "`echo $GSDLOS | sed 's/mingw//'`" != "$GSDLOS" ;
|
---|
25 | then
|
---|
26 | GSDLOS=windows
|
---|
27 | fi
|
---|
28 | echo "GSDLOS was not set. Setting it to '$GSDLOS'"
|
---|
29 | export GSDLOS
|
---|
30 | fi
|
---|
31 |
|
---|
32 |
|
---|
33 | run_untar()
|
---|
34 | {
|
---|
35 | local package=$1
|
---|
36 | local version=$2
|
---|
37 | local ext=$3
|
---|
38 |
|
---|
39 | tar_args="";
|
---|
40 |
|
---|
41 | if [ $ext = ".tar.gz" ] ; then
|
---|
42 | tar_args="xvzf"
|
---|
43 | elif [ $ext = ".tgz" ] ; then
|
---|
44 | tar_args="xvzf"
|
---|
45 | elif [ $ext = ".tar.bz2" ] ; then
|
---|
46 | tar_args="xvjf"
|
---|
47 | elif [ $ext = ".tar.bz" ] ; then
|
---|
48 | tar_args="xvjf"
|
---|
49 | elif [ $ext = ".tar" ] ; then
|
---|
50 | tar_args="xvf"
|
---|
51 | else
|
---|
52 | echo "Warning: Unrecognized extension: $ext"
|
---|
53 | echo "Assuming tarred, gzipped file"
|
---|
54 | tar_args="xvjf"
|
---|
55 | fi
|
---|
56 |
|
---|
57 |
|
---|
58 | echo tar $tar_args $package$version$ext
|
---|
59 | tar $tar_args $package$version$ext
|
---|
60 |
|
---|
61 | if [ $? != 0 ] ; then
|
---|
62 | echo " Error encountered running *untar* stage of $progname"
|
---|
63 | exit 1
|
---|
64 | fi
|
---|
65 | }
|
---|
66 |
|
---|
67 | opt_run_tarclean()
|
---|
68 | {
|
---|
69 | local type=$1
|
---|
70 | local package=$2
|
---|
71 | local version=$3
|
---|
72 |
|
---|
73 | if [ $type = "1" ] ; then
|
---|
74 |
|
---|
75 | local dir=$package$version
|
---|
76 | if [ -d $dir ] ; then
|
---|
77 | echo /bin/rm -rf $dir
|
---|
78 | /bin/rm -rf $dir
|
---|
79 |
|
---|
80 | if [ $? != 0 ] ; then
|
---|
81 | echo " Error encountered running *tarclean* stage of $progname"
|
---|
82 | exit 1
|
---|
83 | fi
|
---|
84 | else
|
---|
85 | echo "Unable to find directory $dir"
|
---|
86 | fi
|
---|
87 | fi
|
---|
88 | }
|
---|
89 |
|
---|
90 | opt_run_untar()
|
---|
91 | {
|
---|
92 | local force_untar=$1
|
---|
93 | local auto_untar=$2
|
---|
94 | local package=$3
|
---|
95 | local version=$4
|
---|
96 |
|
---|
97 | local ext="";
|
---|
98 |
|
---|
99 | if [ ! -z "$5" ] ; then
|
---|
100 | ext=$5
|
---|
101 | else
|
---|
102 | ext=".tar.gz"
|
---|
103 | fi
|
---|
104 |
|
---|
105 | if [ $force_untar = "1" ] ; then
|
---|
106 | run_untar $package $version $ext
|
---|
107 | elif [ $auto_config = "1" ] ; then
|
---|
108 | if [ -d $package$version ] ; then
|
---|
109 | echo "Found untarred version of $package$version$ext => no need to untar"
|
---|
110 | else
|
---|
111 | run_untar $package $version $ext
|
---|
112 | fi
|
---|
113 | fi
|
---|
114 | }
|
---|
115 |
|
---|
116 |
|
---|
117 | opt_run_configure()
|
---|
118 | {
|
---|
119 | local force_config=$1; shift
|
---|
120 | local auto_config=$1; shift
|
---|
121 | local package=$1; shift
|
---|
122 | local version=$1; shift
|
---|
123 | local prefix=$1; shift
|
---|
124 |
|
---|
125 | if [ $force_config = "1" ] ; then
|
---|
126 | echo "[pushd $package$version]"
|
---|
127 | ( cd $package$version ; \
|
---|
128 | echo ./configure --prefix="$prefix" $CROSSCOMPILE $@ ; \
|
---|
129 | ./configure --prefix="$prefix" $CROSSCOMPILE $@ )
|
---|
130 | if [ $? != 0 ] ; then
|
---|
131 | echo " Error encountered running *configure* stage of $progname"
|
---|
132 | exit 1
|
---|
133 | fi
|
---|
134 | echo "[popd]"
|
---|
135 | else
|
---|
136 | if [ $auto_config = "1" ] ; then
|
---|
137 | echo "Found top-level for ${progname%.*} => no need to run ./configure"
|
---|
138 | fi
|
---|
139 | fi
|
---|
140 | }
|
---|
141 |
|
---|
142 |
|
---|
143 | opt_run_make()
|
---|
144 | {
|
---|
145 | local type=$1
|
---|
146 | local package=$2
|
---|
147 | local version=$3
|
---|
148 | local opt_target=""
|
---|
149 |
|
---|
150 | if [ ! -z "$4" ] ; then
|
---|
151 | opt_target=$4
|
---|
152 | fi
|
---|
153 |
|
---|
154 | if [ $type = "1" ] ; then
|
---|
155 | ( cd $package$version ; \
|
---|
156 | make $opt_target)
|
---|
157 |
|
---|
158 | if [ $? != 0 ] ; then
|
---|
159 | echo " Error encountered running *make $target* stage of $progname"
|
---|
160 | exit 1
|
---|
161 | fi
|
---|
162 | fi
|
---|
163 | }
|
---|
164 |
|
---|
165 |
|
---|
166 | force_untar=0
|
---|
167 | auto_untar=0
|
---|
168 |
|
---|
169 | force_config=0
|
---|
170 | auto_config=0
|
---|
171 |
|
---|
172 | compile=0
|
---|
173 | install=0
|
---|
174 | clean=0
|
---|
175 | distclean=0
|
---|
176 | tarclean=0
|
---|
177 |
|
---|
178 | if [ $# -gt 0 ] ; then
|
---|
179 | for cmd in $* ; do
|
---|
180 | echo $cmd
|
---|
181 | if [ $cmd = "untar" ] ; then force_untar=1
|
---|
182 | elif [ $cmd = "configure" ] ; then force_config=1
|
---|
183 | elif [ $cmd = "compile" ] ; then compile=1
|
---|
184 | elif [ $cmd = "install" ] ; then install=1
|
---|
185 | elif [ $cmd = "clean" ] ; then clean=1
|
---|
186 | elif [ $cmd = "distclean" ] ; then distclean=1
|
---|
187 | elif [ $cmd = "tarclean" ] ; then tarclean=1
|
---|
188 | fi
|
---|
189 | done
|
---|
190 | else
|
---|
191 | # defaults
|
---|
192 | auto_untar=1
|
---|
193 | auto_config=1
|
---|
194 | compile=1
|
---|
195 | install=1
|
---|
196 | clean=0
|
---|
197 | distclean=0
|
---|
198 | tarclean=0
|
---|
199 | fi
|
---|
200 |
|
---|
201 | if [ $auto_config = "1" ] ; then
|
---|
202 | if [ ! -e $package$version/Makefile ] && [ ! -e $package$version/config.h ] ; then
|
---|
203 | force_config=1
|
---|
204 | fi
|
---|
205 |
|
---|
206 | fi
|
---|
207 |
|
---|