From 1a7db631deb1f7ab72e30343f87afb1e6a44f0ff Mon Sep 17 00:00:00 2001 From: Michele Guerini Rocco Date: Wed, 15 Dec 2021 02:30:48 +0100 Subject: [PATCH] actually use the configure script --- .gitignore | 1 + Makefile | 3 +++ configure | 69 ++++++++++++++++++++++++++++++++++++++++++++---------- 3 files changed, 61 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 1add2e3..a4aa7b8 100755 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .DS_store build +configure.mk diff --git a/Makefile b/Makefile index 37a6e60..b91823c 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,6 @@ +# Load the configure script variables +-include configure.mk + ## ## Directories ## diff --git a/configure b/configure index b9a0c0b..f34ffff 100755 --- a/configure +++ b/configure @@ -1,5 +1,53 @@ #!/bin/sh +set -e + +# Show the usage screen +show_help(){ + cat <> 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