source: gs2-extensions/ocr/trunk/lib/cascade-lib.bash@ 30197

Last change on this file since 30197 was 30197, checked in by davidb, 9 years ago

Added support for Python and CMake

File size: 4.0 KB
Line 
1
2run_untar()
3{
4 local package=$1
5 local version=$2
6 local ext=$3
7
8 tar_args="";
9
10 if [ $ext = ".tar.gz" ] ; then
11 tar_args="xvzf"
12 elif [ $ext = ".tgz" ] ; then
13 tar_args="xvzf"
14 elif [ $ext = ".tar.bz2" ] ; then
15 tar_args="xvjf"
16 elif [ $ext = ".tar.bz" ] ; then
17 tar_args="xvjf"
18 elif [ $ext = ".tar" ] ; then
19 tar_args="xvf"
20 else
21 echo "Warning: Unrecognized extension: $ext"
22 echo "Assuming tarred, gzipped file"
23 tar_args="xvjf"
24 fi
25
26
27 echo tar $tar_args $package$version$ext
28 tar $tar_args $package$version$ext
29
30 if [ $? != 0 ] ; then
31 echo " Error encountered running *untar* stage of $progname"
32 exit 1
33 fi
34}
35
36opt_run_tarclean()
37{
38 local type=$1
39 local package=$2
40 local version=$3
41
42 if [ $type = "1" ] ; then
43
44 local dir=$package$version
45 if [ -d $dir ] ; then
46 echo /bin/rm -rf $dir
47 /bin/rm -rf $dir
48
49 if [ $? != 0 ] ; then
50 echo " Error encountered running *tarclean* stage of $progname"
51 exit 1
52 fi
53 else
54 echo "Unable to find directory $dir"
55 fi
56 fi
57}
58
59opt_run_untar()
60{
61 local force_untar=$1
62 local auto_untar=$2
63 local package=$3
64 local version=$4
65
66 local ext="";
67
68 if [ ! -z "$5" ] ; then
69 ext=$5
70 else
71 ext=".tar.gz"
72 fi
73
74 if [ $force_untar = "1" ] ; then
75 run_untar $package $version $ext
76 elif [ $auto_config = "1" ] ; then
77 if [ -d $package$version ] ; then
78 echo "Found untarred version of $package$version$ext => no need to untar"
79 else
80 run_untar $package $version $ext
81 fi
82 fi
83}
84
85
86opt_run_configure()
87{
88 local force_config=$1
89 local auto_config=$2
90 local package=$3
91 local version=$4
92 local prefix=$5
93 local opt_args="";
94
95 if [ ! -z "$6" ] ; then
96 opt_args=$6
97 fi
98
99 if [ $force_config = "1" ] ; then
100 ( echo "[pushd $package$version]"
101 cd $package$version ; \
102 echo ./configure --prefix="$prefix" $opt_args ; \
103 ./configure --prefix="$prefix" $opt_args )
104 echo "[popd]"
105 if [ $? != 0 ] ; then
106 echo " Error encountered running *configure* stage of $progname"
107 exit 1
108 fi
109 else
110 if [ $auto_config = "1" ] ; then
111 echo "Found top-level for ${progname%.*} => no need to run ./configure"
112 fi
113 fi
114}
115
116opt_run_setuppy()
117{
118 local type=$1
119 local package=$2
120 local version=$3
121 local opt_target=""
122
123 if [ ! -z "$4" ] ; then
124 opt_target=$4
125 fi
126
127 if [ $type = "1" ] ; then
128 ( cd $package$version ; \
129 python setup.py $opt_target)
130
131 if [ $? != 0 ] ; then
132 echo " Error encountered running *setup.py $target* stage of $progname"
133 exit 1
134 fi
135 fi
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
160opt_run_cmake()
161{
162 local type=$1
163 local package=$2
164 local version=$3
165 local subdir=$4
166 local opt_target=""
167
168 if [ ! -z "$5" ] ; then
169 opt_target=$5
170 fi
171
172 if [ $type = "1" ] ; then
173 ( cd $package$version/$subdir ; \
174 make $opt_target)
175
176 if [ $? != 0 ] ; then
177 echo " Error encountered running *make $target* stage of $progname"
178 exit 1
179 fi
180 fi
181}
182
183force_untar=0
184auto_untar=0
185
186force_config=0
187auto_config=0
188
189compile=0
190install=0
191clean=0
192distclean=0
193tarclean=0
194
195if [ $# -gt 0 ] ; then
196 for cmd in $* ; do
197 echo $cmd
198 if [ $cmd = "untar" ] ; then force_untar=1
199 elif [ $cmd = "configure" ] ; then force_config=1
200 elif [ $cmd = "compile" ] ; then compile=1
201 elif [ $cmd = "install" ] ; then install=1
202 elif [ $cmd = "clean" ] ; then clean=1
203 elif [ $cmd = "distclean" ] ; then distclean=1
204 elif [ $cmd = "tarclean" ] ; then tarclean=1
205 fi
206 done
207else
208 # defaults
209 auto_untar=1
210 auto_config=1
211 compile=1
212 install=1
213 clean=0
214 distclean=0
215 tarclean=0
216fi
217
218if [ $auto_config = "1" ] ; then
219 if [ ! -e $package$version/Makefile ] ; then
220 force_config=1
221 fi
222fi
223
Note: See TracBrowser for help on using the repository browser.