root/main/trunk/greenstone2/makegs2.sh @ 32004

Revision 32004, 3.8 KB (checked in by ak19, 2 years ago)

Additional changes to previous commit of makegs2.sh, to allow passing in the optional parameters in any order

  • Property svn:executable set to *
Line 
1#!/bin/bash
2
3# run as: ./makegs2.sh [gnome-lib] [imagemagick]
4# If gnome-lib passed in, will compile GS2 using gnome-lib
5# which checks out gnome-lib src from svn if possible and if needed (if no ext/gnome-lib-minimal)
6# If you pass in imagemagick, it will grab the appropriate linux/darwin binary, untar
7# this and put its OS subfolder renamed as imagemagick into the bin/os folder.
8
9getgnomelib=
10getimagick=
11
12# https://stackoverflow.com/questions/20449680/unix-boolean-operators-a-o
13if [[ "x$1" == "xgnome-lib" ]]; then
14    getgnomelib=$1
15elif [[ "x$1" == "ximagemagick" ]]; then
16    getimagick=$1
17fi
18
19if [[ "x$2" == "xgnome-lib" ]]; then
20    getgnomelib=$2
21elif [[ "x$2" == "ximagemagick" ]]; then
22    getimagick=$2
23fi
24
25if [ "x$getgnomelib" != "x" ]; then
26    echo "Will be getting gnomelib"
27fi
28if [ "x$getimagick" != "x" ]; then
29    echo "Will be getting imagemagick"
30fi
31
32if [[ "x$getgnomelib" == "x" && "x$getimagick" == "x" ]]; then
33    echo "No recognised args provided"
34fi
35
36gsdlhome=`pwd`
37echo "**** GSDLHOME: $gsdlhome"
38
39bitness=`uname -m`
40# if we're 64 bit, add -fPIC to CFLAGS. Check if bitness contains substring "64"
41if [[ $bitness == *"64"* ]]; then
42  export CFLAGS="-fPIC $CFLAGS"
43  echo "64 bit unix system, incl -fPIC in CFLAGS so it is now: $CFLAGS"
44fi
45
46# Compile by chaining the commands with && so it stops at that stage after an error
47cd $gsdlhome
48if [ "x$getgnomelib" = "xgnome-lib" ]; then
49    ./configure --enable-gnome-lib-ext --enable-apache-httpd \
50    && make \
51    && make install
52else
53    ./configure --enable-apache-httpd \
54    && make \
55    && make install
56fi
57
58status=$?
59echo "****************************************"
60if [ $status = 0 ] ; then
61    # 5. Message to warn user that the env of this x-term uses gnome-lib
62    # and GUIs may not work from this console
63    if [ "x$getgnomelib" = "xgnome-lib" ]; then
64    echo "*** The environment for this console has been set to compile Greenstone with gnome-lib."
65    echo "*** As a result, graphical applications may not work well."
66    echo "*** In such a case, open a new console."
67    else
68    echo "Finished compiling Greenstone2. (Compiled without gnome-lib)"
69    fi
70else
71    echo "@@@ Error compiling up Greenstone. Return status: $status"
72fi
73if [[ $bitness == *"64"* ]]; then
74    echo ""
75    echo "This unix is 64 bit. So added -fPIC to CFLAGS, which is now: $CFLAGS"
76fi
77echo "****************************************"   
78
79
80imgpkg=
81if [ "x$getimagick" = "ximagemagick" ]; then
82   os=`uname`
83
84   if [ "x$os" = "xDarwin" ]; then
85       # by default, resort to the Mac Leopard (10.5, kernel 12.6.0)'s imagemagick binary
86       imgpkg=http://trac.greenstone.org/export/head/gs2-extensions/imagemagick/trunk/imagemagick-darwin-10.5.tar.gz
87
88       kernelVersion=`uname -r`
89       # El Capitan is MacOS version 10.11 but its kernelVersion is 15.6.0
90       if [ "x$kernelVersion" = "x15.6.0" ]; then
91       echo "Getting imagemagick built for El Capitan"
92       imgpkg=http://trac.greenstone.org/export/head/gs2-extensions/imagemagick/trunk/imagemagick-darwin-10.11.tar.gz
93       else
94       echo "Getting imagemagick built on Mac Leopard"
95       fi
96
97       pushd ext
98       curl $imgpkg > imagemagick.tar.gz
99       tar -xvzf imagemagick.tar.gz
100       mv imagemagick/darwin ../bin/darwin/imagemagick
101       popd
102
103   else
104       # linux
105       pushd ext
106       if [[ $bitness == *"64"* ]]; then
107       echo "Getting 64 bit imagemagick precompiled binary"
108       wget http://trac.greenstone.org/export/head/gs2-extensions/imagemagick/trunk/imagemagick-linux-x64.tar.gz
109       tar -xvzf imagemagick-linux-x64.tar.gz
110       else
111       echo "Getting 32 bit imagemagick precompiled binary"
112       wget http://trac.greenstone.org/export/head/gs2-extensions/imagemagick/trunk/imagemagick-linux.tar.gz
113       tar -xvzf imagemagick-linux.tar.gz
114       fi
115
116       mv imagemagick/linux ../bin/linux/imagemagick
117       popd
118   fi
119   
120fi
Note: See TracBrowser for help on using the browser.