actually use the configure script
This commit is contained in:
parent
8dfb214ea0
commit
1a7db631de
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
.DS_store
|
||||
build
|
||||
configure.mk
|
||||
|
3
Makefile
3
Makefile
@ -1,3 +1,6 @@
|
||||
# Load the configure script variables
|
||||
-include configure.mk
|
||||
|
||||
##
|
||||
## Directories
|
||||
##
|
||||
|
69
configure
vendored
69
configure
vendored
@ -1,5 +1,53 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
# Show the usage screen
|
||||
show_help(){
|
||||
cat <<EOF
|
||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||
|
||||
To assign environment variables (e.g., FC, FFLAGS...), specify them as
|
||||
VAR=VALUE. Defaults for the options are specified in brackets.
|
||||
|
||||
Options:
|
||||
-h, --help display this help and exit
|
||||
--prefix=PREFIX install files in PREFIX [/usr/local]
|
||||
--enable-static statically link programs and libraries [no]
|
||||
--disable-static dynamically link programs and libraries [yes]
|
||||
EOF
|
||||
}
|
||||
|
||||
# Check whether a command exists
|
||||
check() {
|
||||
test -z "$1" && return 1
|
||||
printf 'checking for %s... ' "$1"
|
||||
command -v "$1" || (echo 'not found'; exit 1)
|
||||
return $?
|
||||
}
|
||||
|
||||
# Parse command line options
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
-h|--help) show_help; exit 0 ;;
|
||||
--prefix=*)
|
||||
PREFIX="${arg#*=}"
|
||||
printf 'install prefix set to %s\n' "$PREFIX"
|
||||
;;
|
||||
--enable-static) printf 'STATIC=1\n' >> configure.mk ;;
|
||||
--disable-static) ;;
|
||||
*=*)
|
||||
printf '%s\n' "${arg?}" >> configure.mk
|
||||
printf 'set %s\n' "$arg"
|
||||
;;
|
||||
*) show_help; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Truncate the current configuration
|
||||
: > configure.mk
|
||||
|
||||
# Platform information
|
||||
printf 'Running on '
|
||||
case $(uname -s) in
|
||||
Linux*) echo 'Linux' ;;
|
||||
@ -11,24 +59,21 @@ esac
|
||||
os=$(uname -r)
|
||||
printf 'OS version %s\n' "$os"
|
||||
|
||||
# Architecture information
|
||||
arch=$(uname -m)
|
||||
printf 'Processor architecture %s\n' "$arch"
|
||||
|
||||
check() {
|
||||
printf 'Looking for %s... ' "$1"
|
||||
command -v "$1" || (echo 'not found'; exit 1)
|
||||
return $?
|
||||
}
|
||||
# Variables with a default
|
||||
printf '%s=%s\n' PREFIX "${PREFIX:-/usr/local}" >> configure.mk
|
||||
|
||||
for FC in ifort gfortran f77; do
|
||||
check $FC && break
|
||||
# Detect the Fortran compiler
|
||||
for FC in "$FC" ifort gfortran f77; do
|
||||
check "$FC" && break
|
||||
done
|
||||
# shellcheck disable=SC2181
|
||||
if [ $? -ne 0 ]; then
|
||||
printf 'Fortran compiler not found. Cannot proceed\n'
|
||||
printf 'Fortran compiler not found: cannot proceed\n'
|
||||
exit 1
|
||||
else
|
||||
printf 'Use %s as Fortran compiler\n' "$FC"
|
||||
fi
|
||||
|
||||
# $FC --version
|
||||
printf 'using %s as Fortran compiler\n' "$FC"
|
||||
printf '%s=%s\n' FC "$FC" >> configure.mk
|
||||
|
Loading…
Reference in New Issue
Block a user