https://gitlab.com/nomadic-labs/mi-cho-coq
Tip revision: 904746e64772b0bebfb70f3c3e04784c8d28f053 authored by Arvid Jakobsson on 10 May 2021, 07:35:53 UTC
Merge branch 'arvid@re-organize-contracts_coq' into 'dev'
Merge branch 'arvid@re-organize-contracts_coq' into 'dev'
Tip revision: 904746e
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
}
CONTRACT_DIRS_SRC=$(find src/contracts_coq -mindepth 1 -maxdepth 1 -type d)
CONTRACT_DIRS=$(echo "$CONTRACT_DIRS_SRC" | sed 's@src/@@g')
COMPONENTS="michocott michocoq contracts_coq $CONTRACT_DIRS"
if [ "$1" = "--help" ]; then
echo "Usage: $0 [$(echo "$COMPONENTS" | tr ' \n' '||')]*"
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
echo "Building all components"
set -- michocott michocoq contracts_coq
fi
DIRS="src"
echo "Generating the main Makefile"
echo "" > src/_CoqProject
while [ $# -gt 0 ]; do
case "$1" in
"michocoq")
echo 'Build michocoq'
REQUIRES_MICHOCOQ=1
;;
"contracts_coq")
echo "Build all contract components"
REQUIRES_MICHOCOQ=1
DIRS="$DIRS $CONTRACT_DIRS_SRC"
echo "$CONTRACT_DIRS" | tr ' ' '\n' >> src/_CoqProject
;;
contracts_coq/*)
echo "Build contract component: $1"
REQUIRES_MICHOCOQ=1
DIRS="$DIRS src/$1"
echo "$1" >> 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