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

Last change on this file since 28570 was 28570, checked in by ak19, 10 years ago

Related to Dr Bainbridge's bugfix of 28569: shouldn't have the .fixed-prefix.awk fie in the final gnome-lib-minimal generated for distribution, else the file is not regenerated with local paths and then gs2/wvware can't be compiled against that gnome-lib-minimal

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