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

Last change on this file since 22122 was 22122, checked in by davidb, 11 years ago

Initial import of cascade make, which supports compiling source code extensions to Greenstone

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