source: main/trunk/greenstone2/makegs2.sh@ 32012

Last change on this file since 32012 was 32008, checked in by ak19, 7 years ago

Rewriting the part of makegs2.sh that grabs the imagemagick binary, as the El Cap binary (10.11) was made backwards compatible with Mountain Lion (10.5). And we also want the untarring to be silent.

  • Property svn:executable set to *
File size: 6.7 KB
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
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
17getgnomelib=
18getimagick=
19
20# https://stackoverflow.com/questions/20449680/unix-boolean-operators-a-o
21if [[ "x$1" == "xgnome-lib" ]]; then
22 getgnomelib=$1
23elif [[ "x$1" == "ximagemagick" ]]; then
24 getimagick=$1
25fi
26
27if [[ "x$2" == "xgnome-lib" ]]; then
28 getgnomelib=$2
29elif [[ "x$2" == "ximagemagick" ]]; then
30 getimagick=$2
31fi
32
33if [ "x$getgnomelib" != "x" ]; then
34 echo "Will be getting gnomelib"
35fi
36if [ "x$getimagick" != "x" ]; then
37 echo "Will be getting imagemagick"
38fi
39
40if [[ "x$getgnomelib" == "x" && "x$getimagick" == "x" ]]; then
41 echo "Launching with no args"
42fi
43
44gsdlhome=`pwd`
45echo "**** GSDLHOME: $gsdlhome"
46
47bitness=`uname -m`
48# if we're 64 bit, add -fPIC to CFLAGS. Check if bitness contains substring "64"
49if [[ $bitness == *"64"* ]]; then
50 export CFLAGS="-fPIC $CFLAGS"
51 echo "64 bit unix system, incl -fPIC in CFLAGS so it is now: $CFLAGS"
52fi
53
54# Compile by chaining the commands with && so it stops at that stage after an error
55cd $gsdlhome
56if [ "x$getgnomelib" = "xgnome-lib" ]; then
57 ./configure --enable-gnome-lib-ext --enable-apache-httpd \
58 && make \
59 && make install
60else
61 ./configure --enable-apache-httpd \
62 && make \
63 && make install
64fi
65
66status=$?
67echo "****************************************"
68if [ $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
71 if [ "x$getgnomelib" = "xgnome-lib" ]; then
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
78else
79 echo "@@@ Error compiling up Greenstone. Return status: $status"
80fi
81if [[ $bitness == *"64"* ]]; then
82 echo ""
83 echo "This unix is 64 bit. So added -fPIC to CFLAGS, which is now: $CFLAGS"
84fi
85echo "****************************************"
86
87# Get the imagemagick precompiled binary for the OS system if compilation was successful
88if [[ "$status" == "0" && "x$getimagick" == "ximagemagick" ]]; then
89
90 imgpkg=
91
92 os=`uname`
93
94 if [ "x$os" = "xDarwin" ]; then
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
101
102 kernelVersion=`uname -r`
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
119 # El Capitan is MacOS version 10.11 but its kernelVersion is 15.6.0
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
124 else
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"
126 fi
127
128 pushd ext
129 curl $imgpkg > imagemagick.tar.gz
130 tar -xzf imagemagick.tar.gz
131 rm -rf ../bin/darwin/imagemagick
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
141 tar -xzf imagemagick-linux-x64.tar.gz
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
145 tar -xzf imagemagick-linux.tar.gz
146 fi
147
148 rm -rf ../bin/linux/imagemagick
149 mv imagemagick/linux ../bin/linux/imagemagick
150 popd
151 fi
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
160
161fi
Note: See TracBrowser for help on using the repository browser.