|
| 1 | +# -*- shell-script ; indent-tabs-mode:nil -*- |
| 2 | +# |
| 3 | +# Copyright (c) 2016-2019 Intel, Inc. All rights reserved. |
| 4 | +# $COPYRIGHT$ |
| 5 | +# |
| 6 | +# Additional copyrights may follow |
| 7 | +# |
| 8 | +# $HEADER$ |
| 9 | +# |
| 10 | + |
| 11 | +# OPAL_CHECK_SINGULARITY() |
| 12 | +# -------------------------------------------------------- |
| 13 | +AC_DEFUN([OPAL_CHECK_SINGULARITY],[ |
| 14 | + OPAL_VAR_SCOPE_PUSH([spath have_singularity]) |
| 15 | +
|
| 16 | + AC_ARG_WITH([singularity], |
| 17 | + [AC_HELP_STRING([--with-singularity(=DIR)], |
| 18 | + [Build support for the Singularity container, optionally adding DIR to the search path])]) |
| 19 | + spath= |
| 20 | + AC_MSG_CHECKING([if Singularity is present]) |
| 21 | + AS_IF([test "$with_singularity" = "no"], |
| 22 | + [AC_MSG_RESULT([no])], |
| 23 | + [AC_MSG_RESULT([yes]) |
| 24 | + AS_IF([test -z "$with_singularity" || test "$with_singularity" = "yes"], |
| 25 | + [ # look for the singularity command in the default path |
| 26 | + AC_CHECK_PROG([SINGULARITY], [singularity], [singularity]) |
| 27 | + AS_IF([test "$SINGULARITY" != ""], |
| 28 | + [spath=DEFAULT], |
| 29 | + [AS_IF([test "$with_singularity" = "yes"], |
| 30 | + [AC_MSG_WARN([Singularity support requested, but required executable]) |
| 31 | + AC_MSG_WARN(["singularity" not found in default locations]) |
| 32 | + AC_MSG_ERROR([Cannot continue])])])], |
| 33 | + [ AC_MSG_CHECKING([for existence of $with_singularity/bin]) |
| 34 | + # look for the singularity command in the bin subdirectory |
| 35 | + AS_IF([test ! -d "$with_singularity/bin"], |
| 36 | + [AC_MSG_RESULT([not found]) |
| 37 | + AC_MSG_WARN([Directory $with_singularity/bin not found]) |
| 38 | + AC_MSG_ERROR([Cannot continue])], |
| 39 | + [AC_MSG_RESULT([found])]) |
| 40 | + save_path=$PATH |
| 41 | + PATH=$with_singularity/bin:$PATH |
| 42 | + AC_CHECK_PROG([SINGULARITY], [singularity], [singularity]) |
| 43 | + AS_IF([test "$SINGULARITY" != ""], |
| 44 | + [spath=$with_singularity/bin], |
| 45 | + [AC_MSG_WARN([Singularity support requested, but required executable]) |
| 46 | + AC_MSG_WARN(["singularity" not found in either default or specified path]) |
| 47 | + AC_MSG_ERROR([Cannot continue])]) |
| 48 | + PATH=$save_path |
| 49 | + ] |
| 50 | + )]) |
| 51 | +
|
| 52 | + AC_DEFINE_UNQUOTED(OPAL_SINGULARITY_PATH, "$spath", [Path to Singularity binaries]) |
| 53 | +
|
| 54 | + OPAL_VAR_SCOPE_POP |
| 55 | +]) |
0 commit comments