#!/bin/bash # Copyright (C) 2019-2022, CNES and contributors (for the Euclid Science Ground Segment) # This file is part of EleFits # SPDX-License-Identifier: LGPL-3.0-or-later # Adapted from bash script template from https://github.com/leogtzr/minimal-safe-bash-template/blob/main/template-v1.sh set -o errexit set -o nounset set -o pipefail readonly script_name="${0##*/}" readonly error_parsing_options=81 trap clean_up ERR EXIT SIGINT SIGTERM # By default build in /tmp build_dir="/tmp/build_elefits" parallel_build=1 build_dir_option_flag=0 j_option_flag=0 usage() { cat < /dev/null) || { usage die "error: parsing options" "${error_parsing_options}" } eval set -- "${opts}" while true; do case "${1}" in --help|-h) usage exit 0 shift ;; -d|--build_dir) build_dir_option_flag=1 readonly d_arg="${2}" shift shift ;; -j|--parallel) j_option_flag=1 readonly j_arg="${2}" echo "parallel build with nb_jobs= ${2}" shift shift ;; --) shift break ;; *) break ;; esac done } parse_user_options "${@}" if ((build_dir_option_flag)); then echo "Using --build_dir option -> arg: [${d_arg}]" build_dir="${d_arg}" fi if ((j_option_flag)); then echo "Using -j option -> arg: [${j_arg}]" parallel_build="${j_arg}" fi mkdir -p "${build_dir}" cd "${build_dir}" cd "${build_dir}" git clone https://github.com/astrorama/Elements.git cd Elements git checkout 5.14.0 mkdir build ; cd build cmake -DCMAKE_INSTALL_PREFIX=/usr/local .. make -j "${parallel_build}" make install cd "${build_dir}" git clone -b release-4.0 https://github.com/CNES/EleFits.git cd EleFits mkdir build ; cd build cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_PREFIX_PATH=/usr/local .. make -j "${parallel_build}" make install exit 0