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

Last change on this file since 22245 was 22245, checked in by davidb, 14 years ago

Tweaks to Unix and Dos support files

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