Skip to content
Snippets Groups Projects
make-package 938 B
Newer Older
Ralf Jung's avatar
Ralf Jung committed
#!/bin/bash
set -e
# Helper script to build and/or install just one package out of this repository.
# Assumes that all the other packages it depends on have been installed already!

PROJECT="$1"
shift

COQFILE="_CoqProject.$PROJECT"
MAKEFILE="Makefile.package.$PROJECT"

Ralf Jung's avatar
Ralf Jung committed
if ! grep -E -q "^$PROJECT/" _CoqProject; then
    echo "No files in $PROJECT/ found in _CoqProject; this does not seem to be a valid project name."
    exit 1
fi

Ralf Jung's avatar
Ralf Jung committed
# Generate _CoqProject file and Makefile
rm -f "$COQFILE"
# Get the right "-Q" line.
Ralf Jung's avatar
Ralf Jung committed
grep -E "^-Q $PROJECT[ /]" _CoqProject >> "$COQFILE"
Ralf Jung's avatar
Ralf Jung committed
# Get everything until the first empty line except for the "-Q" lines.
Ralf Jung's avatar
Ralf Jung committed
sed -n '/./!q;p' _CoqProject | grep -E -v "^-Q " >> "$COQFILE"
Ralf Jung's avatar
Ralf Jung committed
# Get the files.
Ralf Jung's avatar
Ralf Jung committed
grep -E "^$PROJECT/" _CoqProject >> "$COQFILE"
Ralf Jung's avatar
Ralf Jung committed
# Now we can run coq_makefile.
"${COQBIN}coq_makefile" -f "$COQFILE" -o "$MAKEFILE"

# Run build
make -f "$MAKEFILE" "$@"

# Cleanup
rm -f ".$MAKEFILE.d" "$MAKEFILE"*