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

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

Makeminimal target must remove the *.la files (in the OS/lib folder) since their presence causes compilation to fail on Lion (they contain hardcoded paths to where gnome-lib-min was compiled up). These files don't exist in the rata gnome-lib-minimal, so need to do the same for the Lion version of gnome-lib-min.

File size: 8.1 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-darwin-Lion-intel"
164 else
165 tarname="$tarname-darwin-intel"
166 fi
167 fi
168
169 # copy all the files except $OS/lib/pkconfig/.fixed-prefix.awk across. The absence of that last file will ensure that gnome-lib-minimal
170 # does not point to the path where it was compiled when compiling wvware against a gnome-lib-minimal in a GS2 located elsewhere
171 # http://www.gnu.org/software/tar/manual/html_node/exclude.html and http://www.tldp.org/LDP/abs/html/comparison-ops.html
172 # Also need to remove all the *.la files generated (in the OS/lib folder), as happens on darwin, since these contain fixed paths
173 tar cvzf $tarname.tar.gz --exclude='.fixed-prefix.awk' --exclude='*.la' $distlist
174 mv $tarname.tar.gz $dirname/.
175
176 popd
177}
178
179opt_run_untar()
180{
181 local force_untar=$1
182 local auto_untar=$2
183 local package=$3
184 local version=$4
185
186 local ext="";
187
188 if [ ! -z "$5" ] ; then
189 ext=$5
190 else
191 ext=".tar.gz"
192 fi
193
194 if [ $force_untar = "1" ] ; then
195 run_untar $package $version $ext
196 elif [ $auto_config = "1" ] ; then
197 if [ -d $package$version ] ; then
198 echo "Found untarred version of $package$version$ext => no need to untar"
199 else
200 run_untar $package $version $ext
201 fi
202 fi
203}
204
205
206opt_run_configure()
207{
208 local force_config=$1; shift
209 local auto_config=$1; shift
210 local package=$1; shift
211 local version=$1; shift
212 local prefix=$1; shift
213
214 if [ $force_config = "1" ] ; then
215 echo "[pushd $package$version]"
216 ( cd $package$version ; \
217 echo $CROSSCONFIGURE_VARS ./configure --prefix="$prefix" $CROSSCONFIGURE_ARGS $@ ;
218 eval $CROSSCONFIGURE_VARS ./configure --prefix="$prefix" $CROSSCONFIGURE_ARGS $@ )
219 if [ $? != 0 ] ; then
220 echo " Error encountered running *configure* stage of $progname"
221 exit 1
222 fi
223 echo "[popd]"
224 else
225 if [ $auto_config = "1" ] ; then
226 echo "Found top-level for ${progname%.*} => no need to run ./configure"
227 fi
228 fi
229}
230
231
232opt_run_perl_configure()
233{
234 local force_config=$1; shift
235 local auto_config=$1; shift
236 local package=$1; shift
237 local version=$1; shift
238 local prefix=$1; shift
239
240 if [ $force_config = "1" ] ; then
241 echo "[pushd $package$version]"
242 ( cd $package$version ; \
243 echo perl Makefile.PL PREFIX="$prefix" $CROSSCOMPILE $@ ;
244 perl Makefile.PL PREFIX="$prefix" $CROSSCOMPILE $@)
245 if [ $? != 0 ] ; then
246 echo " Error encountered running *configure* stage of $progname"
247 exit 1
248 fi
249 echo "[popd]"
250 else
251 if [ $auto_config = "1" ] ; then
252 echo "Found top-level for ${progname%.*} => no need to run perl configure"
253 fi
254 fi
255}
256
257
258opt_run_make()
259{
260 local type=$1; shift
261 local package=$1; shift
262 local version=$1; shift
263 local opt_target=""
264
265 if [ ! -z "$1" ] ; then
266 opt_target=$1; shift
267 fi
268
269 if [ $type = "1" ] ; then
270 ( cd $package$version ; \
271 make $opt_target $@)
272
273 if [ $? != 0 ] ; then
274 echo " Error encountered running *make $target* stage of $progname"
275 exit 1
276 fi
277 fi
278}
279
280
281opt_run_cmake()
282{
283 local type=$1
284 local package=$2
285 local version=$3
286 local subdir=$4
287 local opt_target=""
288
289 if [ ! -z "$5" ] ; then
290 opt_target=$5
291 fi
292
293 if [ $type = "1" ] ; then
294 ( cd $package$version/$subdir ; \
295 make $opt_target)
296
297 if [ $? != 0 ] ; then
298 echo " Error encountered running *make $target* stage of $progname"
299 exit 1
300 fi
301 fi
302}
303
304
305run_installclean()
306{
307 local fulldir="$exthome/$GSDLOS"
308 echo ""
309 read -p "Delete $fulldir [y/n]?" ans
310 if [ $ans = "y" ] ; then
311 /bin/rm -rf "$fulldir"
312 fi
313
314 exit 0
315}
316
317
318print_usage()
319{
320 echo "$0 [untar|configure|comiple|install|clean|distclean|tarclean|makedist|makeminimal]+"
321 echo " or"
322 echo "$0 [installclean|help]"
323 exit 0
324}
325
326force_untar=0
327auto_untar=0
328
329force_config=0
330auto_config=0
331
332compile=0
333install=0
334clean=0
335distclean=0
336tarclean=0
337makedist=0
338makeminimal=0
339
340if [ $# -gt 0 ] ; then
341 for cmd in $* ; do
342 echo $cmd
343 if [ $cmd = "untar" ] ; then force_untar=1
344 elif [ $cmd = "configure" ] ; then force_config=1
345 elif [ $cmd = "compile" ] ; then compile=1
346 elif [ $cmd = "install" ] ; then install=1
347 elif [ $cmd = "clean" ] ; then clean=1
348 elif [ $cmd = "distclean" ] ; then distclean=1
349 elif [ $cmd = "tarclean" ] ; then tarclean=1
350 elif [ $cmd = "makedist" ] ; then makedist=1
351 elif [ $cmd = "makeminimal" ] ; then makeminimal=1
352
353 elif [ $cmd = "installclean" ] ; then run_installclean
354 elif [ $cmd = "help" ] ; then print_usage
355 fi
356 done
357else
358 # defaults
359 auto_untar=1
360 auto_config=1
361 compile=1
362 install=1
363 clean=0
364 distclean=0
365 tarclean=0
366 makedist=0
367 makeminimal=0
368fi
369
370if [ $auto_config = "1" ] ; then
371 if [ ! -e $package$version/Makefile ] && [ ! -e $package$version/config.h ] ; then
372 force_config=1
373 fi
374fi
Note: See TracBrowser for help on using the repository browser.