source: main/trunk/greenstone2/build-src/packages/configure

Last change on this file was 37404, checked in by davidb, 14 months ago

Needed to add -DNEEDS_UNISTD_H to CFLAGS to keep new mac compile happy

  • Property svn:executable set to *
File size: 16.8 KB
Line 
1#!/bin/bash
2
3PACKAGES=`pwd`
4cd ../..
5GSDLHOME=`pwd`
6cd $PACKAGES
7
8GSDLOS=`uname -s |tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
9# check for running bash under cygwin
10if test "`echo $GSDLOS | sed 's/cygwin//'`" != "$GSDLOS" ;
11then
12 GSDLOS=windows
13fi
14if test "x$crossOS" != "x" ; then
15 # Override derived value with value explicitly provided in crossOS
16 GSDLOS=$crossOS
17fi
18
19prefix=""
20bindir=""
21HOSTTARGETFLAGS=""
22
23# only some of the packages can take environment variables as options to
24# configure
25# format is VAR=value, e.g "LDFLAGS=-static"
26ENVIRONMENT=""
27
28# WVWARE compilation enabled by default, can switch it off with --disable-wvware
29USE_WVWARE=true
30# GDBM compilation enabled by default, can switch it off with --disable-gdbm
31USE_GDBM=true
32# JDBM compilation enabled by default, can switch it off with --disable-jdbm
33USE_JDBM=true
34# SQLite support enabled by default, can switch it off with --disable-sqlite
35USE_SQLITE=true
36# yaz compilation enabled by default, can switch it off with --disable-yaz
37USE_YAZ=true
38# z3950 server disabled by default, switch it on with --enable-z3950
39USE_Z3950=false
40# CORBA support disabled by default, switch it on with --enable-corba
41USE_CORBA=false
42MICO_DIR=default
43
44# parse any arguments given from toplevel configure
45while test $# -ne 0; do
46 case "$1" in
47 --cache-file=*)
48 cache_filename=`echo $1 | sed s/--cache-file=//`
49 # turn relative path into an absolute path
50 cache_dir=`echo $cache_filename | sed 's@/[^/]*$@@'`
51 cache_dir=`cd $cache_dir 2>/dev/null && pwd`
52
53 cache_basefile=`echo $cache_filename | sed 's@.*/@@'`
54 cache_file="$cache_dir/$cache_basefile"
55 if test ! -f "$cache_file"; then
56 CACHE_FILE=""
57 else
58 CACHE_FILE="--cache-file=$cache_file"
59 fi
60 ;;
61 --disable-wvware)
62 USE_WVWARE=false
63 ;;
64 --disable-gdbm)
65 USE_GDBM=false
66 ;;
67 --disable-jdbm)
68 USE_JDBM=false
69 ;;
70 --disable-sqlite)
71 USE_SQLITE=false
72 ;;
73 --disable-yaz)
74 USE_YAZ=false
75 ;;
76 --enable-z3950)
77 USE_Z3950=true
78 ;;
79 --enable-corba)
80 USE_CORBA=true
81 ;;
82 --with-micodir=*)
83 if test $1 = ""; then
84 $1 = "default"
85 fi
86 MICO_DIR=$1
87 ;;
88 --prefix=*)
89 prefix=`echo $1 | sed s/--prefix=//`
90 ;;
91 --bindir=*)
92 # where to install binaries to
93 bindir=`echo $1 | sed s/--bindir=//`
94 # turn relative path into an absolute path
95 if test -d "$bindir" ; then
96 bindir=`cd "$bindir" ; pwd `
97 cd "$PACKAGES"
98 elif test -z `echo $bindir | sed '/^\// p;D'` ; then
99 rel_bindir="`echo $bindir | sed s@/.*@@`"
100 cd "$rel_bindir"
101 bindir="`pwd`/`echo $bindir | sed s@^[^/]*/@@`"
102 cd "$PACKAGES"
103 else
104 # bindir doesn't exist, and isn't relative
105 true
106 fi
107 ;;
108 --host=* | --target=* | --build=*)
109 HOSTTARGETFLAGS="$HOSTTARGETFLAGS $1"
110 ;;
111 *)
112 # ignore all other options for now
113 ;;
114 esac
115 shift
116done
117
118# note! Our GSDL package currently always installs into it's source
119# directory, ignoring any --prefix given to configure.
120# When this is fixed, uncomment the relevant lines below...
121
122##if test -z "$prefix" ; then
123prefix="${GSDLHOME}"
124##fi
125
126##if test -z "$bindir" ; then
127bindir="${prefix}/bin/$GSDLOS"
128##fi
129
130libdir="${prefix}/lib/$GSDLOS"
131
132# This loads the top configure's cache file, with variables already set.
133if test -f "$cache_file" ; then
134 . $cache_file
135fi
136
137# we assume that gzip and tar are on the search path.
138# non-GNU versions of tar don't take the -z option.
139
140
141# wget needs libz when it runs its configure
142# this used to be provided (incidentally) by gnome-lib
143# however, if the gnome-lib extension is off, this failes
144# => configure, compile up and install libz here
145# => co-opt the openssl directory for installation of libz
146# as this is where wget is directed to look for additional libraries
147
148# configure the libz converter
149echo ""
150echo "Configuring libz (AKA zlib)"
151echo ""
152
153cd "$PACKAGES/libz"
154echo "Supressing LDFLAGS global setting as values"
155echo "(rk2 setting this to 'LDFLAGS=-static' is not liked by libz"
156store_LDFLAGS="$LDFLAGS"
157export LDFLAGS=
158echo "****DEBUG: ENVIRONMENT = $ENVIRONMENT"
159
160gzip -dc zlib-1.2.11.tar.gz | tar -xf -
161cd zlib-1.2.11 && \
162./configure $CACHE_FILE --static --prefix="$PACKAGES/openssl" $HOSTTARGETFLAGS
163
164if test x$? != x0 ;
165then
166 echo "Configuration of libz failed."
167 exit 1
168fi
169
170# make
171echo Making libz
172make
173if test x$? != x0 ;
174then
175 echo "Compilation of libz failed."
176 exit 1
177fi
178
179echo make install
180make install
181if test x$? != x0 ;
182then
183 echo "Installation of libz failed."
184 exit 1
185fi
186
187echo "Restoring LDFLAGS=$store_LDFLAGS"
188export LDFLAGS="$store_LDFLAGS"
189
190# The way common-src compiles up expat during the configure stage itself,
191# configure openssl (needs to be done before wget)
192# and compile openssl during the configure stage itself.
193# Needed by wget for https support
194
195echo ""
196echo "Configuring openssl"
197echo ""
198cd "$PACKAGES/openssl"
199openssl_pkgname=openssl-1.0.2l
200#openssl_pkgname=openssl-1.1.0f
201if test ! -d $openssl_pkgname ;
202then
203 gzip -dc $openssl_pkgname.tar.gz | tar -xf -
204fi
205cd $openssl_pkgname
206
207# configure
208# see the INSTALL file for OpenSSL to see config options for openssl
209# --prefix indicates where the generated lib, include and bin folders will go
210# --openssldir will contain the manuals and other non-essentials
211# BEWARE: The defaults for --prefix and meaning of --openssldir differ between
212# versions of openssl. In the earlier version (1.0.* like 1.0.2l), if
213# --prefix is not supplied, then the generated lib, include and bin folders
214# will also go into --openssldir.
215# In the newer version 1.1.* 1.1.0f, if --prefix is not supplied, it will
216# try to install the generated lib, include and bin folders into a system place.
217# So better to provide both --openssldir and --prefix, for both openssl versions
218# to compile succesfully.
219# If you ever want to have the .a libraries that building openssl generates,
220# then point the --prefix to the $bindir. We currently don't need to put them
221# into $bindir/openssl for wget to use, since wget is built against openssl's
222# static libraries and therefore wget doesn't need these when running.
223
224# for 64 bit Macs, need to run ./Configure with darwin64-x86_64-cc, rather than ./config
225# To overcome an error in openssl's perl script determining the LLVM version, we also need force the
226# compilers to be GNU since Clang comes back with an LLVM version that doesn't work out
227stored_CC=$CC
228stored_CXX=$CXX
229ssl_status=-1
230if [[ "x$GSDLOS" == "xdarwin" ]] && [[ `uname -m` == *"64" ]] ; then
231 echo Darwin 64, using darwin64-x86_64-cc for OPENSSL_HOST
232 export CC="gcc"
233 export CXX="g++"
234 echo ./Configure --openssldir=$PACKAGES/openssl no-shared darwin64-x86_64-cc
235 #CC="gcc" CXX="g++" ./Configure --openssldir=$PACKAGES/openssl no-shared darwin64-x86_64-cc
236 ./Configure --openssldir=$PACKAGES/openssl no-shared darwin64-x86_64-cc
237 ssl_status=$?
238
239elif [[ "x$GS_OPENSSL_HOST" != "x" ]] ; then
240 echo "have found environment variable GS_OPENSSL_HOST - using that with Configure, instead of running config which will guess the host"
241 echo ./Configure --prefix=$PACKAGES/openssl --openssldir=$PACKAGES/openssl no-shared $GS_OPENSSL_HOST
242 # we found that the following needs bash to run as running it directly here (from within ant)
243 # as ./Configure had an error, even though the command worked fine on the command line
244 bash ./Configure --prefix=$PACKAGES/openssl --openssldir=$PACKAGES/openssl no-shared $GS_OPENSSL_HOST
245 ssl_status=$?
246
247else
248 # this will auto guess the system you are running on
249 echo ./config --prefix=$PACKAGES/openssl --openssldir=$PACKAGES/openssl no-shared
250 ./config --prefix=$PACKAGES/openssl --openssldir=$PACKAGES/openssl no-shared
251 ssl_status=$?
252fi
253
254if [ $ssl_status != 0 ] ; then
255 echo "ERROR: something went wrong with configuring openssl, returning $ssl_status"
256 exit $ssl_status
257fi
258
259# make
260echo Making OpenSSL
261
262make
263# make 'install_sw' is a target this package has for installing just the software,
264# skipping the installation of, for example, the man pages
265echo make install_sw
266make install_sw
267# restore the compile flags
268export CC=$stored_CC
269export CXX=$stored_CXX
270
271# GS3 needs the now-built openssl to set up https. So we copy (hardlink?) the necessary openssl stuff
272# Copying is perhaps OK: <12Mb without the manual or 14.4Mb with manuals.
273# to GSDL3SRCHOME/bin/$GSDLOS. Not sure if GSDL3SRCHOME is even set during configure
274# if this is a GS3 installation. But we have $GSDLHOME.
275cd $PACKAGES
276gs3_bin_osdir=../../../bin/$GSDLOS
277if [[ -f ../../../gs3-setup.sh ]] && [[ -d $gs3_bin_osdir ]] ; then
278 # get rid of any openssl copy from a previous installation
279 if [ -d $gs3_bin_osdir/openssl ] ; then
280 rm -rf $gs3_bin_osdir/openssl
281 fi
282 mkdir $gs3_bin_osdir/openssl
283 cp -r $PACKAGES/openssl/bin $PACKAGES/openssl/certs $PACKAGES/openssl/include $PACKAGES/openssl/lib $PACKAGES/openssl/misc $PACKAGES/openssl/private $gs3_bin_osdir/openssl/.
284fi
285
286# now move the include, lib and bin folders to the correct place
287
288# configure the wvWare Word document converter
289echo ""
290echo "Configuring wvWare"
291echo ""
292
293# datadir flag is for default location of wvHtml.xml config file
294if test x$USE_WVWARE = xtrue ;
295then
296
297 # Look to see if gnome-lib extension is present and if so, source its devel.bash file
298 if [ -d ../../ext/gnome-lib ] ; then
299 pushd ../../ext/gnome-lib
300 source ./devel.bash
301 popd
302 fi
303
304 if [ -d ../../../ext/gnome-lib-minimal ] ; then
305 pushd ../../../ext/gnome-lib-minimal
306 source ./devel.bash
307 popd
308 fi
309
310 cd "$PACKAGES/wv"
311 if [ "x$GSDLOS" = "xdarwin" ]; then
312 WV_LDFLAGS="$LDFLAGS -framework CoreFoundation -framework Carbon"
313 else
314 WV_LDFLAGS="$LDFLAGS"
315 fi
316 gzip -dc wv-1.2.4-gs.tar.gz | tar -xf -
317 cd wv-gs && \
318 ./configure $CACHE_FILE --prefix=$PACKAGES/wv --bindir="$bindir" --libdir="$libdir" --datadir="$prefix/etc/packages" $HOSTTARGETFLAGS --disable-shared --enable-static LDFLAGS="$WV_LDFLAGS"
319else
320 echo "wvWare support disabled."
321 echo " add '--enable-wvware' to the configure command to include wvWare support."
322 echo ""
323fi
324
325if test x$? = x1 ;
326then
327 echo "Configuration of wvWare failed."
328 exit 1
329fi
330
331# configure the pdftohtml converter
332echo ""
333echo "Configuring pdftohtml"
334echo ""
335
336cd "$PACKAGES/pdftohtml"
337gzip -dc pdftohtml_0_36_gs.tar.gz | tar -xf -
338cd pdftohtml_gs && \
339./configure $CACHE_FILE --prefix="$prefix" --bindir="$bindir" $HOSTTARGETFLAGS $ENVIRONMENT
340
341if test x$? = x1 ;
342then
343 echo "Configuration of pdftohtml failed."
344 exit 1
345fi
346
347# rtftohtml converter
348echo ""
349echo "Configuring rtftohtml"
350echo ""
351
352cd "$PACKAGES/rtftohtml"
353gzip -dc rtftohtml-gs.tar.gz | tar -xf -
354cd rtftohtml_src && \
355./configure $CACHE_FILE --prefix="$prefix" --bindir="$bindir" $HOSTTARGETFLAGS
356
357if test x$? = x1 ;
358then
359 echo "Configuration of rtftohtml failed."
360 exit 1
361fi
362
363# On darwin, the wget binary that we build (in $GSDLHOME/bin/$GSDLOS/wget)
364# finds a system libiconv, as you'll notice when you run "otool -L wget"
365# That's because we expressly don't compile up libiconv on Macs anymore,
366# as the Mac system will have the right libiconv installed.
367
368# configure wget
369#wget_pkgname=wget-1.15-gs
370wget_pkgname=wget-1.17.1-gs
371#wget_pkgname=wget-1.19-gs
372echo ""
373echo "Configuring wget"
374echo ""
375cd "$PACKAGES/wget"
376gzip -dc $wget_pkgname.tar.gz | tar -xf -
377if test x$crossOS = "xandroid" ;
378then
379 wget_extraargs="gl_cv_header_working_stdint_h=yes ac_cv_func_getopt_long_only=no"
380else
381 wget_extraargs=
382fi
383
384# When compiling wget-1.15-gs without openssl as before:
385#./configure $CACHE_FILE --prefix=$PACKAGES/wget --without-ssl --bindir="$bindir" -disable-nls $HOSTTARGETFLAGS $wget_extraargs
386
387# We weren't compiling up wget statically before either and we still aren't
388# However, to compile up wget (statically or not) with openssl, as we do now to support retrieving from https urls, see
389# https://stackoverflow.com/questions/9817337/compiling-wget-with-static-linking-self-compiled-openssl-library-linking-issu
390# Note: contrary to the instructions at the link, if the cppflags and ldflags are set during the
391# configure stage, as we now do, then the make command needn't additionally set them as well.
392# So just make, make install works thereafter
393
394echo copying "$PACKAGES/wget/wgetrc-gs.in" file to "$bindir/wgetrc"
395cp "$PACKAGES/wget/wgetrc-gs.in" "$bindir/wgetrc"
396echo cd "$PACKAGES/wget/$wget_pkgname"
397
398# for wget-1.15-gs. (can also try adding --localstatedir="$bindir/wget" --enable-iri)
399##echo CPPFLAGS="-I$PACKAGES/openssl/include $CPPFLAGS" LDFLAGS="-L$PACKAGES/openssl/lib $LDFLAGS" ./configure $CACHE_FILE --prefix=$PACKAGES/wget --with-ssl=openssl --bindir="$bindir" -disable-nls $HOSTTARGETFLAGS $wget_extraarg
400##cd "$PACKAGES/wget/$wget_pkgname" && \
401##CPPFLAGS="-I$PACKAGES/openssl/include $CPPFLAGS" LDFLAGS="-L$PACKAGES/openssl/lib $LDFLAGS" ./configure $CACHE_FILE --prefix=$PACKAGES/wget --with-ssl=openssl --bindir="$bindir" -disable-nls $HOSTTARGETFLAGS $wget_extraargs
402
403# for wget-1.17.1-gs and wget-1.19-gs (can also try adding --localstatedir="$bindir/wget" --enable-iri)
404# The following ran in to a problem on a Linux (centos) machine with lib32 and lib64 libraries. It tested for
405# openssl/lib64 when in fact the folder we produce is 'openssl/lib' causing ./configure to bail
406#echo OPENSSL_CFLAGS="-I$PACKAGES/openssl/include" OPENSSL_LIBS="-L$PACKAGES/openssl/lib -lssl -lcrypto" ./configure $CACHE_FILE --prefix=$PACKAGES/wget --with-ssl=openssl --with-openssl=auto --with-libssl-prefix="$PACKAGES/openssl" --bindir="$bindir" -disable-nls $HOSTTARGETFLAGS $wget_extraargs
407#cd "$PACKAGES/wget/$wget_pkgname" && \
408#OPENSSL_CFLAGS="-I$PACKAGES/openssl/include" OPENSSL_LIBS="-L$PACKAGES/openssl/lib -lssl -lcrypto" ./configure $CACHE_FILE --prefix=$PACKAGES/wget --with-ssl=openssl --with-openssl=auto --with-libssl-prefix="$PACKAGES/openssl" --bindir="$bindir" -disable-nls $HOSTTARGETFLAGS $wget_extraargs
409
410
411echo OPENSSL_CFLAGS="-I$PACKAGES/openssl/include" OPENSSL_LIBS="-L$PACKAGES/openssl/lib -lssl -lcrypto -lz -ldl" ./configure $CACHE_FILE --prefix=$PACKAGES/wget --with-ssl=openssl --with-openssl=auto --bindir="$bindir" -disable-nls $HOSTTARGETFLAGS $wget_extraargs
412cd "$PACKAGES/wget/$wget_pkgname" && \
413OPENSSL_CFLAGS="-I$PACKAGES/openssl/include" OPENSSL_LIBS="-L$PACKAGES/openssl/lib -lssl -lcrypto -lz -ldl" ./configure $CACHE_FILE --prefix=$PACKAGES/wget --with-ssl=openssl --with-openssl=auto --bindir="$bindir" -disable-nls $HOSTTARGETFLAGS $wget_extraargs
414
415
416
417if test x$? = x1 ;
418then
419 echo "Configuration of wget failed."
420 exit 1
421fi
422
423# configure XML::Parser perl module
424echo ""
425echo "Configuring XML::Parser"
426echo ""
427cd "$PACKAGES/cpan"
428
429perl_dir=`echo 'my $vn = sprintf("%vd", $^V); $vn =~ s/\.\d+?$//; print "perl-$vn";' | perl`
430
431gzip -dc XML-Parser-2.41.tar.gz | tar -xf -
432cd "$PACKAGES/cpan/XML-Parser-2.41" && \
433
434perl Makefile.PL \
435 PREFIX="$GSDLHOME/perllib/cpan/XML" \
436 INSTALLSITELIB="$GSDLHOME/perllib/cpan/$perl_dir" \
437 INSTALLSITEARCH="$GSDLHOME/perllib/cpan/$perl_dir" \
438 INSTALLMAN1DIR="$GSDLHOME/perllib/cpan/$perl_dir" \
439 INSTALLMAN3DIR="$GSDLHOME/perllib/cpan/$perl_dir" \
440 SITEPREFIX="$GSDLHOME/perllib/cpan" \
441 EXPATINCPATH="$GSDLHOME/common-src/packages/expat/include" \
442 EXPATLIBPATH="$GSDLHOME/common-src/packages/expat/lib"
443
444if test x$? = x1 ;
445then
446 echo "Configuration of XML-Parser failed."
447 exit 1
448fi
449
450cpan_extras=1
451if test $cpan_extras = 1 ;
452then
453
454 for pack in Digest-MD5-2.55 Digest-SHA-5.92 Text-CSV-1.99 ;
455 do
456 cd "$PACKAGES/cpan"
457 gzip -dc $pack.tar.gz | tar -xf -
458 cd "$PACKAGES/cpan/$pack" \
459 && \
460 perl Makefile.PL \
461 PREFIX="$GSDLHOME/perllib/cpan" \
462 INSTALLSITELIB="$GSDLHOME/perllib/cpan/$perl_dir" \
463 INSTALLSITEARCH="$GSDLHOME/perllib/cpan/$perl_dir" \
464 INSTALLMAN1DIR="$GSDLHOME/perllib/cpan/$perl_dir" \
465 INSTALLMAN3DIR="$GSDLHOME/perllib/cpan/$perl_dir" \
466 SITEPREFIX="$GSDLHOME/perllib/cpan"
467
468 if test x$? = x1 ;
469 then
470 echo "Configuration of $pack failed."
471 exit 1
472 fi
473 done
474fi
475
476# configure powerpoint converter
477echo ""
478echo "Configuring xlhtml (powerpoint & excel converter)"
479echo ""
480cd "$PACKAGES/xlhtml"
481gzip -dc xlhtml-0.4.9.0-gs.tar.gz | tar -xf -
482cd xlhtml-0.4.9.0 && \
483./configure $CACHE_FILE --prefix="$prefix" --bindir="$bindir" $HOSTTARGETFLAGS
484
485if test x$? = x1 ;
486then
487 echo "Configuration of xlhtml failed."
488 exit 1
489fi
490
491# configure IsisGdl program
492echo ""
493echo "Configuring IsisGdl (CDS/ISIS database reader)"
494echo ""
495cd "$PACKAGES/isis-gdl" && \
496./configure $CACHE_FILE --prefix="$prefix" --bindir="$bindir" $HOSTTARGETFLAGS $ENVIRONMENT
497
498if test x$? = x1 ;
499then
500 echo "Configuration of IsisGdl failed."
501 exit 1
502fi
503
504# configure HTMLTidy program
505echo ""
506echo "Configuring HTMLTidy"
507echo ""
508cd "$PACKAGES/html-tidy"
509CFLAGS_STORE=$CFLAGS
510export CFLAGS="$CFLAGS -DNEEDS_UNISTD_H"
511gzip -dc tidy.tgz | tar -xf -
512cd "$PACKAGES/html-tidy/tidy" && \
513./configure $CACHE_FILE --prefix="$prefix" --bindir="$bindir" $HOSTTARGETFLAGS $ENVIRONMENT
514export CFLAGS=$CFLAGS_STORE
515
516if test x$? = x1 ;
517then
518 echo "Configuration of HTMLTidy failed."
519 exit 1
520fi
Note: See TracBrowser for help on using the repository browser.