[27131] | 1 | #!/bin/bash
|
---|
| 2 |
|
---|
[32004] | 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.
|
---|
[27131] | 8 |
|
---|
[32005] | 9 | # Note, Mac (darwin) machines don't always display all env vars on doing env/printenv,
|
---|
| 10 | # e.g. DYLD_LIBRARY_PATH and DYLD_FALLBACK_LIBRARY_PATH are hidden
|
---|
| 11 | # To display hidden vars follow:
|
---|
| 12 | # http://www.commandlinefu.com/commands/view/6899/print-all-environment-variables-including-hidden-ones
|
---|
| 13 | # but remove capital T from command, making: for _a in {A..Z} {a..z};do _z=\${!${_a}*};for _i in `eval echo "${_z}"`;do echo -e "$_i: ${!_i}";done;done|cat -Tsv
|
---|
| 14 | # into: for _a in {A..Z} {a..z};do _z=\${!${_a}*};for _i in `eval echo "${_z}"`;do echo -e "$_i: ${!_i}";done;done|cat -sv
|
---|
| 15 | # Can redirect the output of the command into files and do a diff to see difference in environment.
|
---|
| 16 |
|
---|
[32004] | 17 | getgnomelib=
|
---|
| 18 | getimagick=
|
---|
| 19 |
|
---|
| 20 | # https://stackoverflow.com/questions/20449680/unix-boolean-operators-a-o
|
---|
| 21 | if [[ "x$1" == "xgnome-lib" ]]; then
|
---|
| 22 | getgnomelib=$1
|
---|
| 23 | elif [[ "x$1" == "ximagemagick" ]]; then
|
---|
| 24 | getimagick=$1
|
---|
| 25 | fi
|
---|
| 26 |
|
---|
| 27 | if [[ "x$2" == "xgnome-lib" ]]; then
|
---|
| 28 | getgnomelib=$2
|
---|
| 29 | elif [[ "x$2" == "ximagemagick" ]]; then
|
---|
| 30 | getimagick=$2
|
---|
| 31 | fi
|
---|
| 32 |
|
---|
| 33 | if [ "x$getgnomelib" != "x" ]; then
|
---|
| 34 | echo "Will be getting gnomelib"
|
---|
| 35 | fi
|
---|
| 36 | if [ "x$getimagick" != "x" ]; then
|
---|
| 37 | echo "Will be getting imagemagick"
|
---|
| 38 | fi
|
---|
| 39 |
|
---|
| 40 | if [[ "x$getgnomelib" == "x" && "x$getimagick" == "x" ]]; then
|
---|
| 41 | echo "No recognised args provided"
|
---|
| 42 | fi
|
---|
| 43 |
|
---|
[27131] | 44 | gsdlhome=`pwd`
|
---|
| 45 | echo "**** GSDLHOME: $gsdlhome"
|
---|
| 46 |
|
---|
[31732] | 47 | bitness=`uname -m`
|
---|
| 48 | # if we're 64 bit, add -fPIC to CFLAGS. Check if bitness contains substring "64"
|
---|
| 49 | if [[ $bitness == *"64"* ]]; then
|
---|
| 50 | export CFLAGS="-fPIC $CFLAGS"
|
---|
| 51 | echo "64 bit unix system, incl -fPIC in CFLAGS so it is now: $CFLAGS"
|
---|
| 52 | fi
|
---|
| 53 |
|
---|
[28513] | 54 | # Compile by chaining the commands with && so it stops at that stage after an error
|
---|
| 55 | cd $gsdlhome
|
---|
[32004] | 56 | if [ "x$getgnomelib" = "xgnome-lib" ]; then
|
---|
[28513] | 57 | ./configure --enable-gnome-lib-ext --enable-apache-httpd \
|
---|
| 58 | && make \
|
---|
| 59 | && make install
|
---|
| 60 | else
|
---|
| 61 | ./configure --enable-apache-httpd \
|
---|
| 62 | && make \
|
---|
| 63 | && make install
|
---|
[27131] | 64 | fi
|
---|
| 65 |
|
---|
[27635] | 66 | status=$?
|
---|
| 67 | echo "****************************************"
|
---|
| 68 | if [ $status = 0 ] ; then
|
---|
| 69 | # 5. Message to warn user that the env of this x-term uses gnome-lib
|
---|
| 70 | # and GUIs may not work from this console
|
---|
[32004] | 71 | if [ "x$getgnomelib" = "xgnome-lib" ]; then
|
---|
[28513] | 72 | echo "*** The environment for this console has been set to compile Greenstone with gnome-lib."
|
---|
| 73 | echo "*** As a result, graphical applications may not work well."
|
---|
| 74 | echo "*** In such a case, open a new console."
|
---|
| 75 | else
|
---|
| 76 | echo "Finished compiling Greenstone2. (Compiled without gnome-lib)"
|
---|
| 77 | fi
|
---|
[27635] | 78 | else
|
---|
| 79 | echo "@@@ Error compiling up Greenstone. Return status: $status"
|
---|
| 80 | fi
|
---|
[31732] | 81 | if [[ $bitness == *"64"* ]]; then
|
---|
| 82 | echo ""
|
---|
| 83 | echo "This unix is 64 bit. So added -fPIC to CFLAGS, which is now: $CFLAGS"
|
---|
| 84 | fi
|
---|
[27635] | 85 | echo "****************************************"
|
---|
| 86 |
|
---|
| 87 |
|
---|
[32003] | 88 | imgpkg=
|
---|
| 89 | if [ "x$getimagick" = "ximagemagick" ]; then
|
---|
| 90 | os=`uname`
|
---|
[27635] | 91 |
|
---|
[32003] | 92 | if [ "x$os" = "xDarwin" ]; then
|
---|
[32007] | 93 | # by default, resort to the Mac Leopard (10.5) imagemagick binary
|
---|
[32003] | 94 | imgpkg=http://trac.greenstone.org/export/head/gs2-extensions/imagemagick/trunk/imagemagick-darwin-10.5.tar.gz
|
---|
| 95 |
|
---|
| 96 | kernelVersion=`uname -r`
|
---|
| 97 | # El Capitan is MacOS version 10.11 but its kernelVersion is 15.6.0
|
---|
| 98 | if [ "x$kernelVersion" = "x15.6.0" ]; then
|
---|
| 99 | echo "Getting imagemagick built for El Capitan"
|
---|
| 100 | imgpkg=http://trac.greenstone.org/export/head/gs2-extensions/imagemagick/trunk/imagemagick-darwin-10.11.tar.gz
|
---|
| 101 | else
|
---|
| 102 | echo "Getting imagemagick built on Mac Leopard"
|
---|
| 103 | fi
|
---|
| 104 |
|
---|
| 105 | pushd ext
|
---|
| 106 | curl $imgpkg > imagemagick.tar.gz
|
---|
| 107 | tar -xvzf imagemagick.tar.gz
|
---|
| 108 | mv imagemagick/darwin ../bin/darwin/imagemagick
|
---|
| 109 | popd
|
---|
| 110 |
|
---|
| 111 | else
|
---|
| 112 | # linux
|
---|
| 113 | pushd ext
|
---|
| 114 | if [[ $bitness == *"64"* ]]; then
|
---|
| 115 | echo "Getting 64 bit imagemagick precompiled binary"
|
---|
| 116 | wget http://trac.greenstone.org/export/head/gs2-extensions/imagemagick/trunk/imagemagick-linux-x64.tar.gz
|
---|
| 117 | tar -xvzf imagemagick-linux-x64.tar.gz
|
---|
| 118 | else
|
---|
| 119 | echo "Getting 32 bit imagemagick precompiled binary"
|
---|
| 120 | wget http://trac.greenstone.org/export/head/gs2-extensions/imagemagick/trunk/imagemagick-linux.tar.gz
|
---|
| 121 | tar -xvzf imagemagick-linux.tar.gz
|
---|
| 122 | fi
|
---|
| 123 |
|
---|
| 124 | mv imagemagick/linux ../bin/linux/imagemagick
|
---|
| 125 | popd
|
---|
| 126 | fi
|
---|
[32005] | 127 |
|
---|
| 128 | # the setup script in the ext/imagemagick folder clashes with wget because it sets DYLD(_FALLBACK)_LIBRARY_PATH
|
---|
| 129 | # on sourcing GS2's setup.bash. Since we're not using the imagemagick in the ext folder for GS2, as the
|
---|
| 130 | # precompiled imagemagick binary is moved into GS2/bin/OS, in a GS2 bin release and now here too (in a compiled GS2),
|
---|
| 131 | # we can remove ext/imagemagick. The env vars it sets refer to the ext/imagemagick folder anyway, which we don't use
|
---|
| 132 | # for our GS2 binaries, or for GS2 compiled versions using the precompiled imagemagick binary, as imagemagick will
|
---|
| 133 | # live in GS2/bin/OS in such cases..
|
---|
| 134 | rm -rf ext/imagemagick
|
---|
[32003] | 135 |
|
---|
| 136 | fi
|
---|