source: other-projects/cascade-make/trunk/lib/cascade-lib.bash@ 23095

Last change on this file since 23095 was 23095, checked in by sjm84, 14 years ago

Fixed installclean, makedist and the exthome variable not being set correctly

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