https://gitlab.com/nomadic-labs/mi-cho-coq
Raw File
Tip revision: a4e70ad0cc2cb7e5c4e9a89536f612c758a3ec56 authored by Raphaƫl Cauderlier on 25 April 2021, 13:09:08 UTC
Merge branch 'rafoo@unaxiomatize_operations' into 'dev'
Tip revision: a4e70ad
configure
#! /bin/sh

# Open Source License
# Copyright (c) 2019 Nomadic Labs. <contact@nomadic-labs.com>

# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

set -e

fail () {
    echo "$1"; exit 1
}

COMPONENTS="michocoq contracts_coq michocott"

if [ "$1" = "--help" ]; then
    echo "Usage: $0 [$(echo "$COMPONENTS" | tr ' ' '|')]*"
    echo
    echo "Configure building Mi-Cho-Coq with the specified list of components."
    echo "Several components can be given. By default all components are built."
    exit 1
fi

if [ $# -eq 0 ]; then
    # we actually want to split on space here
    # shellcheck disable=SC2086
    set -- $COMPONENTS
fi

DIRS="src"
echo "Generating the main Makefile"

echo "" > src/_CoqProject

while [ $# -gt 0 ]; do
    case "$1" in
        "michocoq")
            REQUIRES_MICHOCOQ=1
            ;;
        "contracts_coq")
            echo 'Build contracts'
            REQUIRES_MICHOCOQ=1
            DIRS="$DIRS src/contracts_coq"
            echo "contracts_coq" >> src/_CoqProject
            ;;
        "michocott")
            echo 'Build mi-cho-cott'
            DIRS="$DIRS src/michocott"
            echo "-R michocott/ Michocott" >> src/_CoqProject
            echo "michocott" >> src/_CoqProject
            ;;
        *)
            echo "Unrecognized component: '$1', expected one of: $COMPONENTS"
            exit 1
    esac
    shift
done

if [ -n "$REQUIRES_MICHOCOQ"  ]; then
    echo 'Build mi-cho-coq'

    tmp=$(mktemp);
    ( echo '-R michocoq/ Michocoq'; echo 'michocoq' ) | cat - src/_CoqProject > "$tmp" && mv "$tmp" src/_CoqProject
    DIRS="$DIRS src/michocoq src/michocoq/extraction"
fi

coq_makefile -f _CoqProject -o Makefile || fail "fail while building main makefile"

for i in $DIRS ; do
    echo "Generating Makefile in $i"
    (
        set -e
        cd "$i"
        if [ -x ./configure ] ; then sh configure ; fi
        coq_makefile -f _CoqProject -o Makefile
    )
done
back to top