[23111] | 1 | if 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
|
---|
[26627] | 13 | if test ! -z $crossOS ; then
|
---|
| 14 | # Override derived value with value explicitly provided in crossOS
|
---|
| 15 | GSDLOS=$crossOS
|
---|
| 16 | fi
|
---|
| 17 |
|
---|
[23111] | 18 | echo "GSDLOS was not set. Setting it to '$GSDLOS'"
|
---|
| 19 | export GSDLOS
|
---|
| 20 | fi
|
---|
[22122] | 21 |
|
---|
[22245] | 22 | if test $# -gt "0" ; then
|
---|
| 23 | if test -z ${1##GEXT*} ; then
|
---|
| 24 |
|
---|
| 25 | ext=$1 ; shift
|
---|
| 26 | reldir=$1 ; shift
|
---|
[23095] | 27 |
|
---|
[22245] | 28 | eval exthome=`echo \\$$ext`
|
---|
| 29 | if test -z "$exthome" ; then
|
---|
[26627] | 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
|
---|
[22245] | 39 | fi
|
---|
| 40 | fi
|
---|
| 41 | fi
|
---|
| 42 |
|
---|
[22122] | 43 | run_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"
|
---|
[26789] | 59 | elif [ $ext = ".tar.xz" ] ; then
|
---|
| 60 | tar_args="xvJf"
|
---|
[22122] | 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 |
|
---|
| 79 | opt_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 |
|
---|
[23077] | 102 | toplevel_make_dist()
|
---|
| 103 | {
|
---|
[23104] | 104 | local distos=$1 ; shift
|
---|
[23095] | 105 | local dirname=`basename $exthome`
|
---|
[23077] | 106 |
|
---|
[23104] | 107 | local checklist="$*"
|
---|
[23077] | 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 ..
|
---|
[28292] | 117 |
|
---|
[23104] | 118 | tar cvzf $dirname-$distos.tar.gz $distlist
|
---|
| 119 | mv $dirname-$distos.tar.gz $dirname/.
|
---|
[27619] | 120 | # mv $dirname-$distos.tar.gz $dirname/imagemagick-$distos.tar.gz
|
---|
[23077] | 121 |
|
---|
| 122 | popd
|
---|
| 123 | }
|
---|
| 124 |
|
---|
[23104] | 125 | default_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 |
|
---|
[28292] | 134 | toplevel_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"
|
---|
[28570] | 153 |
|
---|
[28292] | 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
|
---|
[28570] | 163 | tarname="$tarname-darwin-Lion-intel"
|
---|
[28292] | 164 | else
|
---|
| 165 | tarname="$tarname-darwin-intel"
|
---|
| 166 | fi
|
---|
| 167 | fi
|
---|
| 168 |
|
---|
[28570] | 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
|
---|
[28574] | 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
|
---|
[28292] | 174 | mv $tarname.tar.gz $dirname/.
|
---|
| 175 |
|
---|
| 176 | popd
|
---|
| 177 | }
|
---|
| 178 |
|
---|
[22122] | 179 | opt_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 |
|
---|
| 206 | opt_run_configure()
|
---|
| 207 | {
|
---|
[22130] | 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
|
---|
[22122] | 213 |
|
---|
| 214 | if [ $force_config = "1" ] ; then
|
---|
| 215 | echo "[pushd $package$version]"
|
---|
| 216 | ( cd $package$version ; \
|
---|
[26627] | 217 | echo $CROSSCONFIGURE_VARS ./configure --prefix="$prefix" $CROSSCONFIGURE_ARGS $@ ;
|
---|
| 218 | eval $CROSSCONFIGURE_VARS ./configure --prefix="$prefix" $CROSSCONFIGURE_ARGS $@ )
|
---|
[22122] | 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 |
|
---|
[24689] | 232 | opt_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 |
|
---|
[22122] | 258 | opt_run_make()
|
---|
| 259 | {
|
---|
[27273] | 260 | local type=$1; shift
|
---|
| 261 | local package=$1; shift
|
---|
| 262 | local version=$1; shift
|
---|
[22122] | 263 | local opt_target=""
|
---|
| 264 |
|
---|
[27273] | 265 | if [ ! -z "$1" ] ; then
|
---|
| 266 | opt_target=$1; shift
|
---|
[22122] | 267 | fi
|
---|
| 268 |
|
---|
| 269 | if [ $type = "1" ] ; then
|
---|
| 270 | ( cd $package$version ; \
|
---|
[27273] | 271 | make $opt_target $@)
|
---|
[22122] | 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 |
|
---|
[26720] | 281 | opt_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 |
|
---|
[23077] | 305 | run_installclean()
|
---|
| 306 | {
|
---|
[23095] | 307 | local fulldir="$exthome/$GSDLOS"
|
---|
| 308 | echo ""
|
---|
[23077] | 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 |
|
---|
| 318 | print_usage()
|
---|
| 319 | {
|
---|
[28292] | 320 | echo "$0 [untar|configure|comiple|install|clean|distclean|tarclean|makedist|makeminimal]+"
|
---|
[23077] | 321 | echo " or"
|
---|
| 322 | echo "$0 [installclean|help]"
|
---|
| 323 | exit 0
|
---|
| 324 | }
|
---|
| 325 |
|
---|
[22122] | 326 | force_untar=0
|
---|
| 327 | auto_untar=0
|
---|
| 328 |
|
---|
| 329 | force_config=0
|
---|
| 330 | auto_config=0
|
---|
| 331 |
|
---|
| 332 | compile=0
|
---|
| 333 | install=0
|
---|
| 334 | clean=0
|
---|
| 335 | distclean=0
|
---|
| 336 | tarclean=0
|
---|
[23077] | 337 | makedist=0
|
---|
[28292] | 338 | makeminimal=0
|
---|
[22122] | 339 |
|
---|
| 340 | if [ $# -gt 0 ] ; then
|
---|
| 341 | for cmd in $* ; do
|
---|
| 342 | echo $cmd
|
---|
[23077] | 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
|
---|
[28292] | 351 | elif [ $cmd = "makeminimal" ] ; then makeminimal=1
|
---|
[23077] | 352 |
|
---|
| 353 | elif [ $cmd = "installclean" ] ; then run_installclean
|
---|
| 354 | elif [ $cmd = "help" ] ; then print_usage
|
---|
[22122] | 355 | fi
|
---|
| 356 | done
|
---|
| 357 | else
|
---|
| 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
|
---|
[23077] | 366 | makedist=0
|
---|
[28292] | 367 | makeminimal=0
|
---|
[22122] | 368 | fi
|
---|
| 369 |
|
---|
| 370 | if [ $auto_config = "1" ] ; then
|
---|
| 371 | if [ ! -e $package$version/Makefile ] && [ ! -e $package$version/config.h ] ; then
|
---|
| 372 | force_config=1
|
---|
| 373 | fi
|
---|
[26627] | 374 | fi
|
---|