#!/bin/sh set -e # Show the usage screen show_help(){ cat < configure.mk # 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) ;; --enable-deterministic) printf 'DETERMINISTIC=1\n' >> configure.mk ;; --with-katex=*) printf 'KATEX_URL==file://%s/\n' "${arg#*=}" >> configure.mk ;; *=*) printf '%s\n' "${arg?}" >> configure.mk printf 'set %s\n' "$arg" ;; *) show_help; exit 1 ;; esac done # Platform information printf 'Running on ' case $(uname -s) in Linux*) echo 'Linux' ;; Darwin*) echo 'Mac' ;; CYGWIN*|MSYS*|MINGW*) echo 'Windows' ;; *) echo 'unknown OS' ;; esac os=$(uname -r) printf 'OS version %s\n' "$os" # Architecture information arch=$(uname -m) printf 'Processor architecture %s\n' "$arch" # Variables with a default printf '%s=%s\n' PREFIX "${PREFIX:-/usr/local}" >> configure.mk # 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' exit 1 fi printf 'using %s as Fortran compiler\n' "$FC" printf '%s=%s\n' FC "$FC" >> configure.mk # Check whether ar is deterministic by default if ar h | grep -q '\[D\].*(default)' 2>/dev/null; then printf 'AR_DEFAULT_DETERMINISTIC=1\n' >> configure.mk fi