diff options
Diffstat (limited to 'configure')
-rwxr-xr-x | configure | 129 |
1 files changed, 51 insertions, 78 deletions
@@ -1,87 +1,60 @@ -#!/usr/bin/env bash - -set -eu - -usage() { - echo "Usage: ./configure [OPTION]" - echo - echo "Configuration:" - echo " -h, --help display this help and exit" - echo - echo "Installation directories:" - echo " --destination=[local|global] install Python package locally or globally" -} - - -# -allow a command to fail with !’s side effect on errexit -# -use return value from ${PIPESTATUS[0]}, because ! hosed $? -! getopt --test > /dev/null -if [[ ${PIPESTATUS[0]} -ne 4 ]]; then - echo 'getopt not available' - exit 1 +#!/bin/sh + +# This file is part of GNU Taler. +# (C) 2020 Taler Systems S.A. +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE +# LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES +# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +# ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +# THIS SOFTWARE. +# +# SPDX-License-Identifier: 0BSD + +# This script checks if a suitable python3 executable is installed and then +# executes the actual configure logic written in Python. + +build_system_dir=build-system + +if ! test -d "$build_system_dir"; then + # Maybe this is not a top-level configure invocation + # For monorepos, try location from top-level + build_system_dir=../../build-system fi -LONGOPTS=destination:,help -OPTIONS=h - -! PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTS --name "$0" -- "$@") -if [[ ${PIPESTATUS[0]} -ne 0 ]]; then - # e.g. return value is 1 - # then getopt has complained about wrong arguments to stdout - exit 2 +if ! test -d "$build_system_dir"; then + echo "fatal error: build-system directory not found" >&2 + echo "hint: are you running this script from the right directory?" >&2 + exit 1 fi -# read getopt’s output this way to handle the quoting right: -eval set -- "$PARSED" - -destination="local" - -while true; do - case "$1" in - --destination) - destination="$2" - shift 2 - ;; - -h|--help) - usage - exit 1 - ;; - --) - shift - break - ;; - *) - echo "Programming error" - exit 3 - ;; - esac -done - -case "$destination" in - local) - install_global=false - ;; - global) - install_global=true - ;; - *) - echo "Destination (--destination) must be 'local' or 'global', paths are not allowed." - exit 3 - ;; -esac - -cat << EOF > config.mk -# this file is autogenerated by ./configure -install_global=$install_global -EOF - - -if ! python3 --version &>/dev/null; then - echo 'Error: python3 missing' +scriptpath=$build_system_dir/taler-build-scripts +if ! test -d "$build_system_dir"; then + echo "fatal error: taler-build-scripts directory not found at $scriptpath" >&2 + echo "hint: did you run './bootstrap'?" >&2 exit 1 fi -if ! pip3 --version &>/dev/null; then - echo 'Error: pip3 missing' +export TALERBUILDSYSTEMDIR=$build_system_dir + +# Check that the python3 executable is on the PATH. +# This follows PEP 394 (https://www.python.org/dev/peps/pep-0394/). +if ! python3 --version >/dev/null 2>&1; then + echo "error: python3 not found" >&2 exit 1 fi + +# Let python3 check that its own version is okay for us. +python3 "$scriptpath/pyvercheck.py" || exit $? + +# Allow Python to find libraries that are checked into the build system git. +export PYTHONPATH="$scriptpath:${PYTHONPATH:-}" + +# Call configure.py, assuming all went well. +python3 $TALERBUILDSYSTEMDIR/configure.py "$@" |