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 | getgnomelib=
|
---|
10 | getimagick=
|
---|
11 |
|
---|
12 | # https://stackoverflow.com/questions/20449680/unix-boolean-operators-a-o
|
---|
13 | if [[ "x$1" == "xgnome-lib" ]]; then
|
---|
14 | getgnomelib=$1
|
---|
15 | elif [[ "x$1" == "ximagemagick" ]]; then
|
---|
16 | getimagick=$1
|
---|
17 | fi
|
---|
18 |
|
---|
19 | if [[ "x$2" == "xgnome-lib" ]]; then
|
---|
20 | getgnomelib=$2
|
---|
21 | elif [[ "x$2" == "ximagemagick" ]]; then
|
---|
22 | getimagick=$2
|
---|
23 | fi
|
---|
24 |
|
---|
25 | if [ "x$getgnomelib" != "x" ]; then
|
---|
26 | echo "Will be getting gnomelib"
|
---|
27 | fi
|
---|
28 | if [ "x$getimagick" != "x" ]; then
|
---|
29 | echo "Will be getting imagemagick"
|
---|
30 | fi
|
---|
31 |
|
---|
32 | if [[ "x$getgnomelib" == "x" && "x$getimagick" == "x" ]]; then
|
---|
33 | echo "No recognised args provided"
|
---|
34 | fi
|
---|
35 |
|
---|
36 | gsdlhome=`pwd`
|
---|
37 | echo "**** GSDLHOME: $gsdlhome"
|
---|
38 |
|
---|
39 | bitness=`uname -m`
|
---|
40 | # if we're 64 bit, add -fPIC to CFLAGS. Check if bitness contains substring "64"
|
---|
41 | if [[ $bitness == *"64"* ]]; then
|
---|
42 | export CFLAGS="-fPIC $CFLAGS"
|
---|
43 | echo "64 bit unix system, incl -fPIC in CFLAGS so it is now: $CFLAGS"
|
---|
44 | fi
|
---|
45 |
|
---|
46 | # Compile by chaining the commands with && so it stops at that stage after an error
|
---|
47 | cd $gsdlhome
|
---|
48 | if [ "x$getgnomelib" = "xgnome-lib" ]; then
|
---|
49 | ./configure --enable-gnome-lib-ext --enable-apache-httpd \
|
---|
50 | && make \
|
---|
51 | && make install
|
---|
52 | else
|
---|
53 | ./configure --enable-apache-httpd \
|
---|
54 | && make \
|
---|
55 | && make install
|
---|
56 | fi
|
---|
57 |
|
---|
58 | status=$?
|
---|
59 | echo "****************************************"
|
---|
60 | if [ $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
|
---|
70 | else
|
---|
71 | echo "@@@ Error compiling up Greenstone. Return status: $status"
|
---|
72 | fi
|
---|
73 | if [[ $bitness == *"64"* ]]; then
|
---|
74 | echo ""
|
---|
75 | echo "This unix is 64 bit. So added -fPIC to CFLAGS, which is now: $CFLAGS"
|
---|
76 | fi
|
---|
77 | echo "****************************************"
|
---|
78 |
|
---|
79 |
|
---|
80 | imgpkg=
|
---|
81 | if [ "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 |
|
---|
120 | fi
|
---|