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

Last change on this file since 28292 was 28292, checked in by ak19, 8 years ago

Adding in the makeminimal command for gnomelib, to produce the minimal package

File size: 7.5 KB
Line 
1if test -z $GSDLOS ; then
2 GSDLOS=`uname -s | tr '[A-Z]' '[a-z]'`
3 # check for running bash under Cygwin
4 if test "`echo $GSDLOS | sed 's/cygwin//'`" != "$GSDLOS" ;
5 then
6 GSDLOS=windows
7 fi
8 # check for running bash under MinGW/MSys
9 if test "`echo $GSDLOS | sed 's/mingw//'`" != "$GSDLOS" ;
10 then
11 GSDLOS=windows
12 fi
13 if test ! -z $crossOS ; then
14 # Override derived value with value explicitly provided in crossOS
15 GSDLOS=$crossOS
16 fi
17
18 echo "GSDLOS was not set. Setting it to '$GSDLOS'"
19 export GSDLOS
20fi
21
22if test $# -gt "0" ; then
23 if test -z ${1##GEXT*} ; then
24
25 ext=$1 ; shift
26 reldir=$1 ; shift
27
28 eval exthome=`echo \\$$ext`
29 if test -z "$exthome" ; then
30 if test -f $reldir/setup.bash ; then
31 echo "Environment variable $ext for Greenstone extension not set"
32 echo "Sourcing $reldir/setup.bash"
33 source $reldir/setup.bash
34
35 eval exthome=`echo \\$$ext`
36 else
37 echo "Did not detect $reldir/setup.bash, Skipping"
38 fi
39 fi
40 fi
41fi
42
43run_untar()
44{
45 local package=$1
46 local version=$2
47 local ext=$3
48
49 tar_args="";
50
51 if [ $ext = ".tar.gz" ] ; then
52 tar_args="xvzf"
53 elif [ $ext = ".tgz" ] ; then
54 tar_args="xvzf"
55 elif [ $ext = ".tar.bz2" ] ; then
56 tar_args="xvjf"
57 elif [ $ext = ".tar.bz" ] ; then
58 tar_args="xvjf"
59 elif [ $ext = ".tar.xz" ] ; then
60 tar_args="xvJf"
61 elif [ $ext = ".tar" ] ; then
62 tar_args="xvf"
63 else
64 echo "Warning: Unrecognized extension: $ext"
65 echo "Assuming tarred, gzipped file"
66 tar_args="xvjf"
67 fi
68
69
70 echo tar $tar_args $package$version$ext
71 tar $tar_args $package$version$ext
72
73 if [ $? != 0 ] ; then
74 echo " Error encountered running *untar* stage of $progname"
75 exit 1
76 fi
77}
78
79opt_run_tarclean()
80{
81 local type=$1
82 local package=$2
83 local version=$3
84
85 if [ $type = "1" ] ; then
86
87 local dir=$package$version
88 if [ -d $dir ] ; then
89 echo /bin/rm -rf $dir
90 /bin/rm -rf $dir
91
92 if [ $? != 0 ] ; then
93 echo " Error encountered running *tarclean* stage of $progname"
94 exit 1
95 fi
96 else
97 echo "Unable to find directory $dir"
98 fi
99 fi
100}
101
102toplevel_make_dist()
103{
104 local distos=$1 ; shift
105 local dirname=`basename $exthome`
106
107 local checklist="$*"
108 local distlist=""
109
110 for d in $checklist ; do
111 if [ -e $d ] ; then
112 distlist="$distlist $dirname/$d"
113 fi
114 done
115
116 pushd ..
117
118 tar cvzf $dirname-$distos.tar.gz $distlist
119 mv $dirname-$distos.tar.gz $dirname/.
120# mv $dirname-$distos.tar.gz $dirname/imagemagick-$distos.tar.gz
121
122 popd
123}
124
125default_toplevel_make_dist()
126{
127 local distos=$1 ; shift
128 local dirname=`basename $exthome`
129
130 local checklist="setup.bash setup.bat perllib $GSDLOS lib $*"
131 toplevel_make_dist $distos $checklist
132}
133
134toplevel_make_minimal()
135{
136 local distos=$1 ; shift
137 local dirname=`basename $exthome`
138
139 local checklist="devel.bash setup.bash_old setup.bat_old $GSDLOS/lib $GSDLOS/bin $GSDLOS/include $*"
140 local distlist=""
141
142 for d in $checklist ; do
143 if [ -e $d ] ; then
144 distlist="$distlist $dirname/$d"
145 fi
146 done
147
148 pushd ..
149
150 echo "@@@@ LIST: $distlist"
151
152 local tarname="gnome-lib-minimal"
153
154 if [ $distos = "linux" ] ; then
155 tarname="$tarname-linux"
156
157 arch=`uname -m`
158 if [[ "$arch" == *"64"* ]]; then
159 tarname="$tarname-x64";
160 fi
161 elif [ $distos = "darwin" ] ; then
162 if [ $OSTYPE != "darwin9.0" ] ; then
163 tarname="$tarname-$OSTYPE-intel"
164 else
165 tarname="$tarname-darwin-intel"
166 fi
167 fi
168
169 tar cvzf $tarname.tar.gz $distlist
170 mv $tarname.tar.gz $dirname/.
171
172 popd
173}
174
175opt_run_untar()
176{
177 local force_untar=$1
178 local auto_untar=$2
179 local package=$3
180 local version=$4
181
182 local ext="";
183
184 if [ ! -z "$5" ] ; then
185 ext=$5
186 else
187 ext=".tar.gz"
188 fi
189
190 if [ $force_untar = "1" ] ; then
191 run_untar $package $version $ext
192 elif [ $auto_config = "1" ] ; then
193 if [ -d $package$version ] ; then
194 echo "Found untarred version of $package$version$ext => no need to untar"
195 else
196 run_untar $package $version $ext
197 fi
198 fi
199}
200
201
202opt_run_configure()
203{
204 local force_config=$1; shift
205 local auto_config=$1; shift
206 local package=$1; shift
207 local version=$1; shift
208 local prefix=$1; shift
209
210 if [ $force_config = "1" ] ; then
211 echo "[pushd $package$version]"
212 ( cd $package$version ; \
213 echo $CROSSCONFIGURE_VARS ./configure --prefix="$prefix" $CROSSCONFIGURE_ARGS $@ ;
214 eval $CROSSCONFIGURE_VARS ./configure --prefix="$prefix" $CROSSCONFIGURE_ARGS $@ )
215 if [ $? != 0 ] ; then
216 echo " Error encountered running *configure* stage of $progname"
217 exit 1
218 fi
219 echo "[popd]"
220 else
221 if [ $auto_config = "1" ] ; then
222 echo "Found top-level for ${progname%.*} => no need to run ./configure"
223 fi
224 fi
225}
226
227
228opt_run_perl_configure()
229{
230 local force_config=$1; shift
231 local auto_config=$1; shift
232 local package=$1; shift
233 local version=$1; shift
234 local prefix=$1; shift
235
236 if [ $force_config = "1" ] ; then
237 echo "[pushd $package$version]"
238 ( cd $package$version ; \
239 echo perl Makefile.PL PREFIX="$prefix" $CROSSCOMPILE $@ ;
240 perl Makefile.PL PREFIX="$prefix" $CROSSCOMPILE $@)
241 if [ $? != 0 ] ; then
242 echo " Error encountered running *configure* stage of $progname"
243 exit 1
244 fi
245 echo "[popd]"
246 else
247 if [ $auto_config = "1" ] ; then
248 echo "Found top-level for ${progname%.*} => no need to run perl configure"
249 fi
250 fi
251}
252
253
254opt_run_make()
255{
256 local type=$1; shift
257 local package=$1; shift
258 local version=$1; shift
259 local opt_target=""
260
261 if [ ! -z "$1" ] ; then
262 opt_target=$1; shift
263 fi
264
265 if [ $type = "1" ] ; then
266 ( cd $package$version ; \
267 make $opt_target $@)
268
269 if [ $? != 0 ] ; then
270 echo " Error encountered running *make $target* stage of $progname"
271 exit 1
272 fi
273 fi
274}
275
276
277opt_run_cmake()
278{
279 local type=$1
280 local package=$2
281 local version=$3
282 local subdir=$4
283 local opt_target=""
284
285 if [ ! -z "$5" ] ; then
286 opt_target=$5
287 fi
288
289 if [ $type = "1" ] ; then
290 ( cd $package$version/$subdir ; \
291 make $opt_target)
292
293 if [ $? != 0 ] ; then
294 echo " Error encountered running *make $target* stage of $progname"
295 exit 1
296 fi
297 fi
298}
299
300
301run_installclean()
302{
303 local fulldir="$exthome/$GSDLOS"
304 echo ""
305 read -p "Delete $fulldir [y/n]?" ans
306 if [ $ans = "y" ] ; then
307 /bin/rm -rf "$fulldir"
308 fi
309
310 exit 0
311}
312
313
314print_usage()
315{
316 echo "$0 [untar|configure|comiple|install|clean|distclean|tarclean|makedist|makeminimal]+"
317 echo " or"
318 echo "$0 [installclean|help]"
319 exit 0
320}
321
322force_untar=0
323auto_untar=0
324
325force_config=0
326auto_config=0
327
328compile=0
329install=0
330clean=0
331distclean=0
332tarclean=0
333makedist=0
334makeminimal=0
335
336if [ $# -gt 0 ] ; then
337 for cmd in $* ; do
338 echo $cmd
339 if [ $cmd = "untar" ] ; then force_untar=1
340 elif [ $cmd = "configure" ] ; then force_config=1
341 elif [ $cmd = "compile" ] ; then compile=1
342 elif [ $cmd = "install" ] ; then install=1
343 elif [ $cmd = "clean" ] ; then clean=1
344 elif [ $cmd = "distclean" ] ; then distclean=1
345 elif [ $cmd = "tarclean" ] ; then tarclean=1
346 elif [ $cmd = "makedist" ] ; then makedist=1
347 elif [ $cmd = "makeminimal" ] ; then makeminimal=1
348
349 elif [ $cmd = "installclean" ] ; then run_installclean
350 elif [ $cmd = "help" ] ; then print_usage
351 fi
352 done
353else
354 # defaults
355 auto_untar=1
356 auto_config=1
357 compile=1
358 install=1
359 clean=0
360 distclean=0
361 tarclean=0
362 makedist=0
363 makeminimal=0
364fi
365
366if [ $auto_config = "1" ] ; then
367 if [ ! -e $package$version/Makefile ] && [ ! -e $package$version/config.h ] ; then
368 force_config=1
369 fi
370fi
Note: See TracBrowser for help on using the repository browser.