[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
|
---|
[32008] | 41 | echo "Launching with no args"
|
---|
[32004] | 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 |
|
---|
[32008] | 87 | # Get the imagemagick precompiled binary for the OS system if compilation was successful
|
---|
| 88 | if [[ "$status" == "0" && "x$getimagick" == "ximagemagick" ]]; then
|
---|
[27635] | 89 |
|
---|
[32008] | 90 | imgpkg=
|
---|
| 91 |
|
---|
| 92 | os=`uname`
|
---|
[27635] | 93 |
|
---|
[32003] | 94 | if [ "x$os" = "xDarwin" ]; then
|
---|
[32008] | 95 | # The imagemagick binary built on El Capitan (10.11) was made backwards compatible up to and including Mountain Lion (10.8) using the mmacosx-version-min flag.
|
---|
| 96 | # The kernel version of Mountain Lion is 12.6.0. For El Capitan it's 15.6.0
|
---|
| 97 | # So any kernel version less than 12, we'll use the Leopard (10.5) imagemagick binary, and for greater, we'll use the El Capitan imgmagick binary
|
---|
| 98 |
|
---|
| 99 | # by default on Macs, will resort to the MountainLion-and-later compatible ElCapitan binary
|
---|
| 100 | imgpkg=http://trac.greenstone.org/export/head/gs2-extensions/imagemagick/trunk/imagemagick-darwin-10.11.tar.gz
|
---|
[32003] | 101 |
|
---|
| 102 | kernelVersion=`uname -r`
|
---|
[32008] | 103 |
|
---|
| 104 | # kernel version is something like 15.6.0, need the major version number to do integer (not float) comparisons
|
---|
| 105 |
|
---|
| 106 | # https://stackoverflow.com/questions/20348097/bash-extract-string-before-a-colon
|
---|
| 107 | # doesn't work, even when put into backticks:
|
---|
| 108 | # majorKernelVersion=sed 's/\..*//'
|
---|
| 109 |
|
---|
| 110 | # Using pure bash solution to substring before first period mark
|
---|
| 111 | # NOTE: two percent signs gets chars up to the first occurrence of period mark. Single percent sign gets chars up to last period mark.
|
---|
| 112 | majorKernelVersion=${kernelVersion%%\.*}
|
---|
| 113 | echo "MacOS major kernel version: $majorKernelVersion"
|
---|
| 114 |
|
---|
| 115 | # bash evaluates string as integer/vice-versa depending on context
|
---|
| 116 | # https://unix.stackexchange.com/questions/232384/argument-string-to-integer-in-bash
|
---|
| 117 | # http://tldp.org/LDP/abs/html/comparison-ops.html
|
---|
| 118 |
|
---|
[32003] | 119 | # El Capitan is MacOS version 10.11 but its kernelVersion is 15.6.0
|
---|
[32008] | 120 | # For MacOS versions older than Mountain Lion/10.8 (kernel 12.6.0) use the Mac Leopard (10.5) imagemagick binary
|
---|
| 121 | if [ "$majorKernelVersion" -lt "12" ]; then
|
---|
| 122 | echo "Getting imagemagick built on Mac Leopard"
|
---|
| 123 | imgpkg=http://trac.greenstone.org/export/head/gs2-extensions/imagemagick/trunk/imagemagick-darwin-10.5.tar.gz
|
---|
[32003] | 124 | else
|
---|
[32008] | 125 | echo "Getting imagemagick built for El Capitan 10.11 (15.6.0) that's compatible with Mountain Lion 10.8 (kernel v 12.6.0) and onwards"
|
---|
[32003] | 126 | fi
|
---|
| 127 |
|
---|
| 128 | pushd ext
|
---|
| 129 | curl $imgpkg > imagemagick.tar.gz
|
---|
[32008] | 130 | tar -xzf imagemagick.tar.gz
|
---|
| 131 | rm -rf ../bin/darwin/imagemagick
|
---|
[32003] | 132 | mv imagemagick/darwin ../bin/darwin/imagemagick
|
---|
| 133 | popd
|
---|
| 134 |
|
---|
| 135 | else
|
---|
| 136 | # linux
|
---|
| 137 | pushd ext
|
---|
| 138 | if [[ $bitness == *"64"* ]]; then
|
---|
| 139 | echo "Getting 64 bit imagemagick precompiled binary"
|
---|
| 140 | wget http://trac.greenstone.org/export/head/gs2-extensions/imagemagick/trunk/imagemagick-linux-x64.tar.gz
|
---|
[32008] | 141 | tar -xzf imagemagick-linux-x64.tar.gz
|
---|
[32003] | 142 | else
|
---|
| 143 | echo "Getting 32 bit imagemagick precompiled binary"
|
---|
| 144 | wget http://trac.greenstone.org/export/head/gs2-extensions/imagemagick/trunk/imagemagick-linux.tar.gz
|
---|
[32008] | 145 | tar -xzf imagemagick-linux.tar.gz
|
---|
[32003] | 146 | fi
|
---|
[32008] | 147 |
|
---|
| 148 | rm -rf ../bin/linux/imagemagick
|
---|
[32003] | 149 | mv imagemagick/linux ../bin/linux/imagemagick
|
---|
| 150 | popd
|
---|
| 151 | fi
|
---|
[32005] | 152 |
|
---|
| 153 | # the setup script in the ext/imagemagick folder clashes with wget because it sets DYLD(_FALLBACK)_LIBRARY_PATH
|
---|
| 154 | # on sourcing GS2's setup.bash. Since we're not using the imagemagick in the ext folder for GS2, as the
|
---|
| 155 | # precompiled imagemagick binary is moved into GS2/bin/OS, in a GS2 bin release and now here too (in a compiled GS2),
|
---|
| 156 | # we can remove ext/imagemagick. The env vars it sets refer to the ext/imagemagick folder anyway, which we don't use
|
---|
| 157 | # for our GS2 binaries, or for GS2 compiled versions using the precompiled imagemagick binary, as imagemagick will
|
---|
| 158 | # live in GS2/bin/OS in such cases..
|
---|
| 159 | rm -rf ext/imagemagick
|
---|
[32014] | 160 | rm -rf ext/imagemagick.tar.gz
|
---|
[32003] | 161 | fi
|
---|