1#!/bin/bash
  2
  3# This script sets up a CHART environment for running the command line tool from TCE or other machines.
  4
  5# This is only needed if you want a personal development environment. Most users can use the
  6# system install instead by running "source ~chart/Env/Chart3/activate".
  7
  8# First time this is run, everything is downloaded to the packages/ directory
  9# Subsequent runs do not need internet access and take everything from packages/
 10
 11# Recipe for openSues15.2 (sudo may be needed):
 12#  - Install gcc 10 with g++ and other dev packages:
 13#  $ sudo zypper install gcc10-c++ sqlite-devel xz-devel libopenssl-devel readline-devel libffi-devel libexpat-devel libbz2-devel zlib-devel libuuid-devel
 14# (libntirpc-devel? I'm not sure about that one)
 15#  - Make gcc 10 the default compiler because suse unhelpfully does not:
 16#  $ sudo ln -s /usr/bin/g++-10 /usr/bin/g++
 17#  $ sudo ln -s /usr/bin/gcc-10 /usr/bin/gcc
 18#  - Now build everything and hope. Take note of the displayed log file locations in case of problems. Change
 19#  the PREFIX if you want it built somewhere else. Use the right location of this script.
 20#  After compilation you can delete the build/ directory to save space. logs/ can also be deleted but I'd
 21#  leave it in case you need to check things later. packages/ can probably be deleted but I'd leave that too
 22#  in case you need to rebuild, then the downloads will be cached.
 23#  $ PREFIX=$HOME/Env/Chart3/opensuseleap15 MODS="openssl python postgres geos proj instantclient libs basemap node trang rlwrap" $HOME/chart/dist/prereq/bootstrap.sh
 24
 25# Recipe for running this script on epstools (results in packages that work on x2go machines):
 26# MODS="python postgres libs"
 27
 28# Recipe for running this script on csmbuild machine (results in packages that work on IPR machines:
 29# MODS="python postgres libs"
 30
 31# Recipe for Debian test:
 32# PREFIX=$PWD/env PACKAGES=$PWD/../packages BUILD=$PWD/../tmp/build MODS="gcc geos proj openssl python postgres libs" dist/prereq/bootstrap.sh
 33
 34# Available environment variables:
 35#  PREFIX
 36#    Target install location. Defualts to ../../env relative to this script location
 37#  PACKAGES
 38#    Location to cache downloaded sourced code packages. Defaults to ${PREFIX}/packages
 39#  BUILD
 40#    Temporary build area. Defaults to ${PREFIX}/build
 41#  LOGS
 42#    Logfiles directory. Defaults to ${BUILD}/logs
 43#  CFLAGS
 44#    C compiler flags. Defaults to "-O2 -mcpu=native". Faster builds are possible but can lead to a real
 45#    rabit hole of weird problems and will probably get you max 10% speed boost, probably less.
 46#  CXXFLAGS
 47#    C++ compiler flags. Defaults to "-O2 -mcpu=native"
 48#  LDFLAGS
 49#    Linker flags. Defaults to ""
 50#  CONFFLGAS
 51#    Python interpreter extra configuration flags. Try setting to "--enable-optimisations" if your
 52#    brave and very patient
 53#  CORES
 54#    Number of CPU cores to use to build
 55#  MODS
 56#    Comma separated list of modules to build. Select from: gcc atlas geos proj openssl python postgres libs basemap
 57#    Order is ignored.
 58
 59HERE=$(dirname $(realpath "$0"))
 60# Find project home directory (grandparent of this script directory)
 61PROJHOME=$(dirname $(dirname "${HERE}"))
 62# echo "HERE is ${HERE} HOME is ${HOME}"
 63# Location of dist/wrappers directory
 64WRAPPERS="${PROJHOME}/dist/wrappers"
 65
 66# Optional fixed version of pip
 67PIP=pip
 68# PIP=pip==20.2.3
 69
 70# Optional fixed version of wheel
 71WHEEL=wheel
 72# WHEEL=wheel==0.35.1
 73
 74# optional fixed version of cython
 75CYTHON=cython
 76# CYTHON=Cython==0.29.21
 77
 78# optional fixed version of numpy
 79NUMPY=numpy
 80# NUMPY=numpy==1.19.2
 81
 82# Main requirements file - can be switched for a fixed version file
 83# We use the private version in this directory rather than the one in the project root
 84# because I know this one works
 85REQUIREMENTS="${HERE}/requirements-unversioned.txt"
 86
 87# Required, version of Oracle client
 88INSTANTCLIENT=21.1.0.0.0
 89
 90# Location where we can find the instantclient source files
 91INSTANTCLIENT_SOURCE=~elson/Sources/instantclient/x64-21
 92
 93function show_config() {
 94    # Show the user a configuration variable name, value and description
 95    varname=$1
 96    value=$2
 97    description=$3
 98    # echo "${description}"
 99    echo "  ${varname}=${value}"
100    # echo ""
101}
102
103# Display configuration and read environment variables
104
105echo "Configuration:"
106if [[ -z "${PREFIX}" ]]; then
107    # Read this script location and up twice, handling symlinks
108    PREFIX="$(dirname $(realpath $0))/../../env"
109    mkdir -p "${PREFIX}"
110    # Normalise
111    PREFIX="$(cd ${PREFIX};pwd)"
112fi
113show_config "PREFIX" "${PREFIX}" "Target install location. Also holds downloads, logs and temporary build area"
114mkdir -p ${PREFIX}
115
116if [[ -z "${PACKAGES}" ]]; then
117    PACKAGES="\${PREFIX}/packages"
118fi
119show_config "PACKAGES" "${PACKAGES}" "Location to download all source packages to"
120# Expand variables in PACKAGES so if the user passes in PREFIX=/path/to/dir
121# if gets expanded properly to /path/to/dir/packages
122PACKAGES=$(echo $(eval echo \"${PACKAGES}\"))
123
124if [[ -z "${BUILD}" ]]; then
125    BUILD="\${PREFIX}/build"
126fi
127show_config "BUILD" "${BUILD}" "Temporary build area"
128BUILD=$(echo $(eval echo \"${BUILD}\"))
129
130if [[ -z "${LOGS}" ]]; then
131    LOGS="\${BUILD}/logs"
132fi
133show_config "LOGS" "${LOGS}" "Logs directory"
134LOGS=$(echo $(eval echo \"${LOGS}\"))
135
136if [[ -z "${CFLAGS}" ]]; then
137    # Safe defaults
138    CFLAGS="-O2 -mtune=native -pipe -I${PREFIX}/include -I${PREFIX}/include/openssl"
139    # Optional risky optimisations
140    # CFLAGS="-Ofast -fomit-frame-pointer -march=native -pipe -flto" LDFLAGS="-flto" CONFFLAGS="--with-lto --enable-optimizations"
141    # Some optimisations need LDFLAGS too. Python optimisations need CONFFLAGS too.
142    # march=x forced binaries for only a specific archetecture
143    # mtume=x optimises for an archetecture but avoids using too-specific instructions
144fi
145show_config "CFLAGS" "${CFLAGS}" "C compiler flags"
146
147if [[ -z "${CXXFLAGS}" ]]; then
148    CXXFLAGS="\${CFLAGS}"
149fi
150show_config "CXXFLAGS" "${CXXFLAGS}" "C compiler flags"
151CXXFLAGS=$(echo $(eval echo \"${CXXFLAGS}\"))
152
153if [[ -z "${LDFLAGS}" ]]; then
154    LDFLAGS="-L${PREFIX}/lib -L${PREFIX}/lib64"
155fi
156show_config "LDFLAGS" "${LDFLAGS}" "Linker flags"
157
158if [[ -z "${CONFFLAGS}" ]]; then
159    # --enable-optimizations switches on PGO which is supposed to work really well but compilation freezes when I try it
160    # CONFFLAGS="--enable-optimisations"
161    CONFFLAGS=""
162fi
163show_config "CONFFLAGS" "${CONFFLAGS}" "Python configure flags"
164
165# CPU cores for compile
166CORES=${CORES:-4}
167show_config "CORES" "${CORES}" "Number of CPU cores to use for build"
168
169echo ""
170# pip cache
171CACHE="${BUILD}/cache"
172
173# Give the user a moment to review the settings
174echo "Waiting 3s..."
175sleep 3
176echo ""
177
178# Write an activation file for the new environment
179ACTIVATE="${PREFIX}/activate"
180cat <<EOF > "${ACTIVATE}"
181#!/bin/bash
182export PATH=${PREFIX}/bin:\${PATH}
183export LD_LIBRARY_PATH=${PREFIX}/lib:${PREFIX}/lib64:${PREFIX}/instantclient:${LD_LIBRARY_PATH}
184export ORACLE_HOME=${PREFIX}/instantclient
185EOF
186chmod +x "${ACTIVATE}"
187
188# Activate before starting install as some of the scripts below check pip3 is on PATH
189source "${ACTIVATE}"
190echo "Wrote and sourced ${ACTIVATE}"
191echo ""
192
193function build_gcc() {
194    # Download, compile and install gcc c, c++ and fortran compilers
195    VERSION="11.1.0"
196    NAME="gcc-${VERSION}"
197    PACKAGE="${NAME}.tar.gz"
198    DOWNLOAD="${PACKAGES}/${PACKAGE}"
199    if [[ ! -f "${DOWNLOAD}" ]]; then
200        wget ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/${NAME}/${PACKAGE} -O ${DOWNLOAD}
201    fi
202    # we should cache them to packages/ dir here
203    cd ${BUILD}
204    rm -rf ${NAME}
205    tar xf ${DOWNLOAD}
206    cd ${NAME}
207    # this downloads extra files
208    contrib/download_prerequisites
209    mkdir build
210    cd build
211    CFLAGS=${CFLAGS} LDFLAGS=${LDFLAGS} ../configure --disable-multilib --with-system-zlib --enable-languages=c,c++,fortran --prefix ${PREFIX}
212    make -j ${CORES}
213    make install
214}
215
216function build_postgres() {
217    # Download, compile and install postgres server and client libraries and psql tool
218    VERSION="13.3"
219    NAME="postgresql-${VERSION}"
220    PACKAGE="${NAME}.tar.bz2"
221    DOWNLOAD="${PACKAGES}/${PACKAGE}"
222    if [[ ! -f "${DOWNLOAD}" ]]; then
223        wget --no-check-certificate "https://ftp.postgresql.org/pub/source/v${VERSION}/${PACKAGE}" -O ${DOWNLOAD}
224    fi
225    cd "${BUILD}"
226    rm -rf "${NAME}"
227    tar xf "${DOWNLOAD}"
228    cd "${NAME}"
229    CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" ./configure --prefix "${PREFIX}"
230    make -j "${CORES}"
231    make install
232}
233
234function build_atlas() {
235    # Download, compile and install ATLAS numerical library
236    VERSION="3.10.3"
237    NAME="atlas${VERSION}"
238    PACKAGE="${NAME}.tar.bz2"
239    DOWNLOAD="${PACKAGES}/${PACKAGE}"
240    if [[ ! -f "${DOWNLOAD}" ]]; then
241        wget https://downloads.sourceforge.net/project/math-atlas/Stable/${VERSION}/${PACKAGE} -O ${DOWNLOAD}
242    fi
243    cd ${BUILD}
244    rm -rf ATLAS
245    tar xf ${DOWNLOAD}
246    cd ATLAS
247    mkdir build
248    cd build
249    # don't use -pipe
250    CFLAGS='-O2 -fPIC' LDFLAGS='' ../configure --shared --cripple-atlas-performance
251    make -j ${CORES}
252    make DESTDIR=${PREFIX} install
253}
254
255function build_python() {
256    # Download, compile and install Python interpreter
257    VERSION="3.9.0"
258    NAME="Python-${VERSION}"
259    PACKAGE="${NAME}.tar.xz"
260    DOWNLOAD="${PACKAGES}/${PACKAGE}"
261    if [[ ! -f "${DOWNLOAD}" ]]; then
262        wget --no-check-certificate "https://www.python.org/ftp/python/${VERSION}/${PACKAGE}" -O "${DOWNLOAD}"
263    fi
264    cd "${BUILD}"
265    rm -rf "${NAME}"
266    tar xf "${DOWNLOAD}"
267    cd "${NAME}"
268    echo cflags "${CFLAGS}"
269    echo ldflags "${LDFLAGS}"
270    echo confflags "${CONFFLAGS}"
271    echo prefix "${PREFIX}"
272    echo cores "${CORES}"
273    CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" ./configure --with-system-expat --with-system-ffi --with-ensurepip=yes "${CONFFLAGS}" --prefix "${PREFIX}"
274    # make -j "${CORES}"
275    make -j "${CORES}" install
276    # Weird hack needed on openSUSE Leap 42.3
277    cd ${PREFIX}/lib/python3.9
278    if [[ ! -d "lib-dynload" ]]; then
279        ln -s ../../lib64/python3.9/lib-dynload .
280    fi
281}
282
283function build_openssl() {
284    # Download, compile and install openssl
285    # It'sprobably better to install openssl-devel OS package and comment out the call to this,
286    # but this function might hel pto run the script on machines where that's not possible
287    VERSION="1.1.1g"
288    NAME="openssl-${VERSION}"
289    PACKAGE="${NAME}.tar.gz"
290    DOWNLOAD="${PACKAGES}/${PACKAGE}"
291    if [[ ! -f "${DOWNLOAD}" ]]; then
292        wget https://www.openssl.org/source/${PACKAGE} -O ${DOWNLOAD}
293    fi
294    cd ${BUILD}
295    rm -rf ${NAME}
296    tar xf ${DOWNLOAD}
297    cd ${NAME}
298    CFLAGS=${CFLAGS} LDFLAGS=${LDFLAGS} ./config --prefix=${PREFIX}
299    make -j ${CORES}
300    make install
301}
302
303function build_geos() {
304    # Download, compile and install geos coordinate library
305    # For some distributions it's packages as an OS package.
306    # But we compile it here to ensure we get the same version everywhere, including on x2go machines
307    # where it's not available otherwise
308    VERSION="3.8.1"
309    NAME="geos-${VERSION}"
310    PACKAGE="${NAME}.tar.bz2"
311    DOWNLOAD="${PACKAGES}/${PACKAGE}"
312    if [[ ! -f "${DOWNLOAD}" ]]; then
313        wget https://download.osgeo.org/geos/${PACKAGE} -O ${DOWNLOAD}
314    fi
315    cd ${BUILD}
316    rm -rf ${NAME}
317    tar xf ${DOWNLOAD}
318    cd ${NAME}
319    CFLAGS=${CFLAGS} LDFLAGS=${LDFLAGS} ./configure ${CONFFLAGS} --prefix ${PREFIX}
320    make -j ${CORES}
321    make install
322}
323
324function build_proj() {
325    # Download, compile, install proj map projection library
326    VERSION="5.2.0"
327    NAME="proj-${VERSION}"
328    PACKAGE="${NAME}.tar.gz"
329    DOWNLOAD="${PACKAGES}/${PACKAGE}"
330    if [[ ! -f "${DOWNLOAD}" ]]; then
331        wget https://download.osgeo.org/proj/${PACKAGE} -O ${DOWNLOAD}
332    fi
333    cd ${BUILD}
334    rm -rf ${NAME}
335    tar xf ${DOWNLOAD}
336    cd ${NAME}
337    CFLAGS=${CFLAGS} LDFLAGS=${LDFLAGS} ./configure ${CONFFLAGS} --prefix ${PREFIX}
338    make -j ${CORES}
339    make install
340}
341
342function build_instantclient() {
343    # Copy Oracle instantclient libraries over
344    # We could unzip directly into the lib64 directory but Oracle dumps so much crap
345    # into their zipfiles I'd prefer to isolate them and set envs
346    SUBVERSION=21_1
347    cd "${PREFIX}"
348    unzip -o "${INSTANTCLIENT_SOURCE}/instantclient-basiclite-linux.x64-${INSTANTCLIENT}"
349    unzip -o "${INSTANTCLIENT_SOURCE}/instantclient-sdk-linux.x64-${INSTANTCLIENT}"
350    unzip -o "${INSTANTCLIENT_SOURCE}/instantclient-sqlplus-linux.x64-${INSTANTCLIENT}"
351    mv "instantclient_${SUBVERSION}" instantclient
352    # cd instantclient
353    # ln -sf libclntsh.so.12.1 libclntsh.so
354    cd bin
355    ln -sf ../instantclient/sqlplus .
356    cd ..
357}
358
359function build_libs() {
360    # Install python libraries
361    # Install pip before other python librares otherwise pip throws warnings that it should be upgraded
362    pip3 install --upgrade --cache-dir "${CACHE}" --find-links "${PACKAGES}" "${PIP}"
363    # A later library (numpy?) fails if we don't install wheel in advance of the main install
364    pip3 install --cache-dir "${CACHE}" --find-links "${PACKAGES}" "${WHEEL}"
365    # numpy build fails on csmbuild machine if we don't manually install Cython before numpy
366    pip3 install --cache-dir "${CACHE}" --find-links "${PACKAGES}" "${CYTHON}"
367    # cartopy fails if we don't install numpy in advance
368    BLAS=None LAPACK=None ATLAS=None CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" pip3 install --cache-dir "${CACHE}" --find-links "${PACKAGES}" "${NUMPY}"
369    # Now do the main install
370    CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" pip3 install --cache-dir "${CACHE}" --find-links "${PACKAGES}" -r "${REQUIREMENTS}"
371    # Download all source code packages to $PACKAGES so next time those will be automatically used
372    pip3 download --cache-dir "${CACHE}" --find-links "${PACKAGES}" --destination-dir "${PACKAGES}" -r "${REQUIREMENTS}"
373}
374
375function build_basemap() {
376    # Download and install basemap, which is no longer properly in pypi
377    # Requires numpy, matplotlib, geos and proj already installed
378    VERSION="1.2.2rel"
379    NAME="basemap-${VERSION}"
380    PACKAGE="${NAME}.tar.gz"
381    DOWNLOAD="${PACKAGES}/${PACKAGE}"
382    if [[ ! -f "${DOWNLOAD}" ]]; then
383        # wget --no-check-certificate "https://sourceforge.net/projects/matplotlib/files/matplotlib-toolkits/${NAME}/${PACKAGE}/download?use_mirror=netcologne" -O "${DOWNLOAD}"
384        wget --no-check-certificate "https://github.com/matplotlib/basemap/archive/refs/tags/v1.2.2rel.tar.gz" -O "${DOWNLOAD}"
385    fi
386    cd ${BUILD}
387    rm -rf ${NAME}
388    tar xf ${DOWNLOAD}
389    cd ${NAME}
390    cythonize --force src/_geoslib.pyx
391    GEOS_DIR="${PREFIX}" python3 setup.py build
392    GEOS_DIR="${PREFIX}" python3 setup.py install
393    # The install script has a bug so we manually complete the install
394    mkdir -p "${PREFIX}/lib/python3.9/site-packages/mpl_toolkits"
395    cp -r lib/mpl_toolkits/* "${PREFIX}/lib/python3.9/site-packages/mpl_toolkits"
396}
397
398function build_node() {
399    # Download and compile the node intepreter and npm package manager
400    VERSION="14.17.3"
401    NAME="node-v${VERSION}"
402    PACKAGE="${NAME}.tar.gz"
403    DOWNLOAD="${PACKAGES}/${PACKAGE}"
404    if [[ ! -f "${DOWNLOAD}" ]]; then
405        wget "https://nodejs.org/dist/v${VERSION}/${PACKAGE}" -O "${DOWNLOAD}"
406    fi
407    cd "${BUILD}"
408    rm -rf "${NAME}"
409    tar xf "${DOWNLOAD}"
410    cd "${NAME}"
411    LD_LIBRARY_PATH="${PREFIX}/lib:${PREFIX}/lib64:${LD_LIBRARY_PATH}" ./configure --prefix "${PREFIX}"
412    make -j "${CORES}"
413    make install
414    PATH="${PREFIX}/bin:${PATH}" LD_LIBRARY_PATH="${PREFIX}/lib:${PREFIX}/lib64:${LD_LIBRARY_PATH}" npm install -g @angular/cli
415    # npm upate
416    # PATH="${PREFIX}/bin:${PATH}" LD_LIBRARY_PATH="${PREFIX}/lib:${PREFIX}/lib64:${LD_LIBRARY_PATH}" ng update
417}
418
419function build_rlwrap() {
420    # Download and unpack the Java trang schema converter tool
421    VERSION="0.45.2"
422    NAME="rlwrap-${VERSION}"
423    PACKAGE="${NAME}.tar.gz"
424    DOWNLOAD="${PACKAGES}/${PACKAGE}"
425    if [[ ! -f "${DOWNLOAD}" ]]; then
426        # wget --no-check-certificate "https://github.com/hanslub42/rlwrap/archive/refs/tags/v${VERSION}.tar.gz" -O "${DOWNLOAD}"
427        wget --no-check-certificate "https://github.com/hanslub42/rlwrap/releases/download/v${VERSION}/${PACKAGE}" -O "${DOWNLOAD}"
428    fi
429    cd "${BUILD}"
430    rm -rf "${NAME}"
431    tar xf "${DOWNLOAD}"
432    cd "${NAME}"
433    ./configure --prefix="${PREFIX}"
434    make -j "${CORES}"
435    make install
436}
437
438
439function build_trang() {
440    # Download and unpack the Java trang schema converter tool
441    VERSION="20091111"
442    NAME="trang-${VERSION}"
443    PACKAGE="${NAME}.zip"
444    DOWNLOAD="${PACKAGES}/${PACKAGE}"
445    if [[ ! -f "${DOWNLOAD}" ]]; then
446        wget --no-check-certificate "https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/jing-trang/${PACKAGE}" -O "${DOWNLOAD}"
447    fi
448    cd "${BUILD}"
449    rm -rf "${NAME}"
450    unzip "${DOWNLOAD}"
451    mkdir -p "${PREFIX}/share/trang"
452    cp "${NAME}/trang.jar" "${PREFIX}/share/trang"
453    cp "${WRAPPERS}/trang/trang.tmpl" "${PREFIX}/bin/trang"
454    perl -p -i -e "s#TEMPLATE_SHARE#${PREFIX}\/share\/trang#" "${PREFIX}/bin/trang"
455}
456
457
458# Create standard directories
459mkdir -p "${LOGS}"
460mkdir -p "${CACHE}"
461mkdir -p "${BUILD}"
462mkdir -p "${PACKAGES}"
463
464# This probably shouldn't be used. It's just an option for one buidl machine that has gcc 4.8 installed
465# which is not enough to compile numpy. But in general it's much better to use the OS gcc package.
466# Building gcc requires GMP, MPFR and MPC installed which this script doesn't do
467if [[ "${MODS}" == *"gcc"* ]]; then
468    echo "Logging to ${LOGS}/build-gcc.log"
469    set -x
470    build_gcc > ${LOGS}/build-gcc.log 2>&1
471    set +x
472    echo "Checking for gcc"
473    ls -l ${PREFIX}/bin/gcc
474fi
475
476# install the ATLAS numerical computation library.
477# See https://numpy.org/doc/stable/user/building.html for notes. We attempt to disable use of
478# blas/lapack/atlas linear algebra libraries - I'm not sure what the impact is.
479# See https://numpy.org/devdocs/user/building.html for a list of required libraries - there are several
480# that fulfill the requirements, but ATLAS compiles easily on some systems
481# It can be installed from OS package instead
482if [[ "${MODS}" == *"atlas"* ]]; then
483    echo "Logging to ${LOGS}/build-atlas.log"
484    set -x
485    build_atlas > ${LOGS}/build-atlas.log 2>&1
486    set +x
487    echo "Checking for atlas"
488    ls -l ${PREFIX}/bin
489fi
490
491# build spacial library. Can installed from OS package instead,
492# however it's not available on EUM x2go machines
493if [[ "${MODS}" == *"geos"* ]]; then
494    echo "Logging to ${LOGS}/build-geos.log"
495    set -x
496    build_geos > ${LOGS}/build-geos.log 2>&1
497    set +x
498    echo "Checking for geos"
499    ls -l ${PREFIX}/lib64/libgeos.so
500fi
501
502# build coordinate transformation library. Can be skipped on some systems or installed from OS package
503# however it's not available on EUM x2go machines. We use an older version because newer ones
504# depend on a later version of sqlite than is availalbe on x2go
505if [[ "${MODS}" == *"proj"* ]]; then
506    echo "Logging to ${LOGS}/build-proj.log"
507    set -x
508    build_proj > ${LOGS}/build-proj.log 2>&1
509    set +x
510    echo "Checking for proj"
511    ls -l ${PREFIX}/bin/proj
512fi
513
514# Do confirm where this is actually needed
515# csmbuild05 needs this but I' not sure any other machine needs it. In general i
516if [[ "${MODS}" == *"openssl"* ]]; then
517    echo "Logging to ${LOGS}/build-openssl.log"
518    set -x
519    build_openssl > ${LOGS}/build-openssl.log 2>&1
520    set +x
521    echo "Checking for openssl"
522    ls -l ${PREFIX}/lib64/libssl.so
523fi
524
525# Build Python interpreter
526if [[ "${MODS}" == *"python"* ]]; then
527    echo "Logging to ${LOGS}/build-python.log"
528    set -x
529    build_python > "${LOGS}/build-python.log" 2>&1
530    set +x
531    echo "Checking for python"
532    ls -l "${PREFIX}/bin/python3"
533fi
534
535# Build postgres database
536if [[ "${MODS}" == *"postgres"* ]]; then
537    echo "Logging to ${LOGS}/build-postgres.log"
538    set -x
539    build_postgres > "${LOGS}/build-postgres.log" 2>&1
540    set +x
541    echo "Checking for postgres"
542    ls -l "${PREFIX}/bin/postgres"
543fi
544
545# Unpack Oracle instant client
546if [[ "${MODS}" == *"instantclient"* ]]; then
547    echo "Logging to ${LOGS}/build-instantclient.log"
548    set -x
549    build_instantclient > "${LOGS}/build-instantclient.log" 2>&1
550    set +x
551fi
552
553# Install Python modules
554if [[ "${MODS}" == *"libs"* ]]; then
555    echo "Logging to ${LOGS}/build-libs.log"
556    set -x
557    # Build preliminary libraries then the main list
558    build_libs > ${LOGS}/build-libs.log 2>&1
559    set +x
560fi
561
562# Compile basemap
563if [[ "${MODS}" == *"basemap"* ]]; then
564    echo "Logging to ${LOGS}/build-basemap.log"
565    set -x
566    build_basemap > "${LOGS}/build-basemap.log" 2>&1
567    set +x
568fi
569
570# Compile node + npm
571if [[ "${MODS}" == *"node"* ]]; then
572    echo "Logging to ${LOGS}/build-node.log"
573    set -x
574    build_node > "${LOGS}/build-node.log" 2>&1
575    set +x
576fi
577
578# Compile trang
579if [[ "${MODS}" == *"trang"* ]]; then
580    echo "Logging to ${LOGS}/build-trang.log"
581    set -x
582    build_trang > "${LOGS}/build-trang.log" 2>&1
583    set +x
584fi
585
586# Compile rlwrap
587if [[ "${MODS}" == *"rlwrap"* ]]; then
588    echo "Logging to ${LOGS}/build-rlwrap.log"
589    set -x
590    build_rlwrap > "${LOGS}/build-rlwrap.log" 2>&1
591    set +x
592fi
593
594
595echo "Build finished. Run 'source ${PREFIX}/activate' to start using, or run "
596echo "'chart/tests/prerequisites/test_prereq.py' to verify installation"