source: main/trunk/greenstone2/makegs2.sh

Last change on this file was 37603, checked in by anupama, 13 months ago

Attempting to set CFLAGS to contain the recent Wno-error=implicit-function-declaration in makegs2.sh for all GS2 compilation, not just in release-kits compilation, to convert compile errors about missing extern function declarations back into warnings on Darwin machines. This appeared to work to compile GS3 (the release-kit couldn't get past a different, new error about zconst compiling up build-src/zlib, but a similar change in the release-kits is to be removed to avoid duplication). CXXFLAGS won't need to be set to contain this flag too.

  • Property svn:executable set to *
File size: 7.8 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"
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
54# Ever since around MacOS version Monterey, warnings about functions not pre-declared with extern
55# are turned into errors instead when compiling. We want them behaving like warnings again.
56# To do so, we set -Wno-error=implicit-function-declaration
57if test "$GSDLOS" = "darwin"; then
58 if test "x$CFLAGS" = "x" ; then
59 CFLAGS="-Wno-error=implicit-function-declaration"
60 else
61 CFLAGS="-Wno-error=implicit-function-declaration $CFLAGS"
62 fi
63 export CFLAGS
64fi
65
66# Compile by chaining the commands with && so it stops at that stage after an error
67cd $gsdlhome
68if [ "x$getgnomelib" = "xgnome-lib" ]; then
69 ./configure --enable-gnome-lib-ext --enable-apache-httpd \
70 && make \
71 && make install
72else
73 ./configure --enable-apache-httpd \
74 && make \
75 && make install
76fi
77
78status=$?
79echo "****************************************"
80if [ $status = 0 ] ; then
81 # 5. Message to warn user that the env of this x-term uses gnome-lib
82 # and GUIs may not work from this console
83 if [ "x$getgnomelib" = "xgnome-lib" ]; then
84 echo "*** The environment for this console has been set to compile Greenstone with gnome-lib."
85 echo "*** As a result, graphical applications may not work well."
86 echo "*** In such a case, open a new console."
87 else
88 echo "Finished compiling Greenstone2. (Compiled without gnome-lib)"
89 fi
90else
91 echo "@@@ Error compiling up Greenstone. Return status: $status"
92fi
93#if [[ $bitness == *"64"* ]]; then
94# echo ""
95# echo "This unix is 64 bit. So added -fPIC to CFLAGS, which is now: $CFLAGS"
96#fi
97echo "****************************************"
98
99# Get the imagemagick precompiled binary for the OS system if compilation was successful
100if [[ "$status" == "0" && "x$getimagick" == "ximagemagick" ]]; then
101
102 imgpkg=
103
104 os=`uname`
105
106 if [ "x$os" = "xDarwin" ]; then
107 # 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.
108 # The kernel version of Mountain Lion is 12.6.0. For El Capitan it's 15.6.0
109 # 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
110
111 # by default on Macs, will resort to the MountainLion-and-later compatible ElCapitan binary
112 imgpkg=http://trac.greenstone.org/export/head/gs2-extensions/imagemagick/trunk/imagemagick-darwin-10.11.tar.gz
113
114 kernelVersion=`uname -r`
115
116 # kernel version is something like 15.6.0, need the major version number to do integer (not float) comparisons
117
118 # https://stackoverflow.com/questions/20348097/bash-extract-string-before-a-colon
119 # doesn't work, even when put into backticks:
120 # majorKernelVersion=sed 's/\..*//'
121
122 # Using pure bash solution to substring before first period mark
123 # NOTE: two percent signs gets chars up to the first occurrence of period mark. Single percent sign gets chars up to last period mark.
124 majorKernelVersion=${kernelVersion%%\.*}
125 echo "MacOS major kernel version: $majorKernelVersion"
126
127 # bash evaluates string as integer/vice-versa depending on context
128 # https://unix.stackexchange.com/questions/232384/argument-string-to-integer-in-bash
129 # http://tldp.org/LDP/abs/html/comparison-ops.html
130
131 # El Capitan is MacOS version 10.11 but its kernelVersion is 15.6.0
132 # For MacOS versions older than Mountain Lion/10.8 (kernel 12.6.0) use the Mac Leopard (10.5) imagemagick binary
133 if [ "$majorKernelVersion" -lt "12" ]; then
134 echo "Getting imagemagick built on Mac Leopard"
135 imgpkg=http://trac.greenstone.org/export/head/gs2-extensions/imagemagick/trunk/imagemagick-darwin-10.5.tar.gz
136 else
137 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"
138 fi
139
140 pushd ext
141 curl $imgpkg > imagemagick.tar.gz
142 tar -xzf imagemagick.tar.gz
143 rm -rf ../bin/darwin/imagemagick
144 mv imagemagick/darwin ../bin/darwin/imagemagick
145 popd
146
147 else
148 # linux
149 pushd ext
150 if [[ $bitness == *"64"* ]]; then
151 echo "Getting 64 bit imagemagick precompiled binary"
152 wget http://trac.greenstone.org/export/head/gs2-extensions/imagemagick/trunk/imagemagick-linux-x64.tar.gz
153 tar -xzf imagemagick-linux-x64.tar.gz
154 else
155 echo "Getting 32 bit imagemagick precompiled binary"
156 wget http://trac.greenstone.org/export/head/gs2-extensions/imagemagick/trunk/imagemagick-linux.tar.gz
157 tar -xzf imagemagick-linux.tar.gz
158 fi
159
160 rm -rf ../bin/linux/imagemagick
161 mv imagemagick/linux ../bin/linux/imagemagick
162 popd
163 fi
164
165 # the setup script in the ext/imagemagick folder clashes with wget because it sets DYLD(_FALLBACK)_LIBRARY_PATH
166 # on sourcing GS2's setup.bash. Since we're not using the imagemagick in the ext folder for GS2, as the
167 # precompiled imagemagick binary is moved into GS2/bin/OS, in a GS2 bin release and now here too (in a compiled GS2),
168 # we can remove ext/imagemagick. The env vars it sets refer to the ext/imagemagick folder anyway, which we don't use
169 # for our GS2 binaries, or for GS2 compiled versions using the precompiled imagemagick binary, as imagemagick will
170 # live in GS2/bin/OS in such cases..
171 rm -rf ext/imagemagick
172 rm -rf ext/imagemagick.tar.gz
173fi
174
175
176# PDFv2Plugin needs PDFBoxConverter extension, which doesn't come installed in GS2 by default
177# But without it, the PDFv2Plugin won't work and pluginfo.pl -describeall will break,
178# GLI will have issues launching. So repeat what the GS2 installer does:
179# rename PDFv2Plugin.pm to PDFv2Plugin.tmp and show user a message on how to make it functional.
180echo ""
181echo " Renaming PDFv2Plugin to make it unfunctional."
182echo " To make it functional, install the PDFBoxConverter extension for Greenstone"
183echo " and then rename the PDFv2Plugin.tmp file to PDFv2Plugin.pm"
184echo ""
185mv perllib/plugins/PDFv2Plugin.pm perllib/plugins/PDFv2Plugin.tmp
186
Note: See TracBrowser for help on using the repository browser.