1# -*- shell-script -*-
2#
3# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
4#                         University Research and Technology
5#                         Corporation.  All rights reserved.
6# Copyright (c) 2004-2005 The University of Tennessee and The University
7#                         of Tennessee Research Foundation.  All rights
8#                         reserved.
9# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
10#                         University of Stuttgart.  All rights reserved.
11# Copyright (c) 2004-2005 The Regents of the University of California.
12#                         All rights reserved.
13# Copyright (c) 2009-2016 Cisco Systems, Inc.  All rights reserved.
14# Copyright (c) 2016      Los Alamos National Security, LLC. All rights
15#                         reserved.
16# Copyright (c) 2017      Intel, Inc. All rights reserved.
17# $COPYRIGHT$
18#
19# Additional copyrights may follow
20#
21# $HEADER$
22#
23
24# ORTE_CHECK_SLURM(prefix, [action-if-found], [action-if-not-found])
25# --------------------------------------------------------
26AC_DEFUN([ORTE_CHECK_SLURM],[
27    if test -z "$orte_check_slurm_happy" ; then
28	AC_ARG_WITH([slurm],
29           [AC_HELP_STRING([--with-slurm],
30                           [Build SLURM scheduler component (default: yes)])])
31
32	if test "$with_slurm" = "no" ; then
33            orte_check_slurm_happy="no"
34	elif test "$with_slurm" = "" ; then
35            # unless user asked, only build slurm component on linux, AIX,
36            # and OS X systems (these are the platforms that SLURM
37            # supports)
38            case $host in
39		*-linux*|*-aix*|*-apple-darwin*)
40                    orte_check_slurm_happy="yes"
41                    ;;
42		*)
43                    AC_MSG_CHECKING([for SLURM srun in PATH])
44		    OPAL_WHICH([srun], [ORTE_CHECK_SLURM_SRUN])
45                    if test "$ORTE_CHECK_SLURM_SRUN" = ""; then
46			orte_check_slurm_happy="no"
47                    else
48			orte_check_slurm_happy="yes"
49                    fi
50                    AC_MSG_RESULT([$orte_check_slurm_happy])
51                    ;;
52            esac
53        else
54            orte_check_slurm_happy="yes"
55        fi
56
57        AS_IF([test "$orte_check_slurm_happy" = "yes"],
58              [AC_CHECK_FUNC([fork],
59                             [orte_check_slurm_happy="yes"],
60                             [orte_check_slurm_happy="no"])])
61
62        AS_IF([test "$orte_check_slurm_happy" = "yes"],
63              [AC_CHECK_FUNC([execve],
64                             [orte_check_slurm_happy="yes"],
65                             [orte_check_slurm_happy="no"])])
66
67        AS_IF([test "$orte_check_slurm_happy" = "yes"],
68              [AC_CHECK_FUNC([setpgid],
69                             [orte_check_slurm_happy="yes"],
70                             [orte_check_slurm_happy="no"])])
71
72        # check to see if this is a Cray nativized slurm env.
73
74        slurm_cray_env=0
75        OPAL_CHECK_ALPS([orte_slurm_cray],
76                        [slurm_cray_env=1])
77
78        AC_DEFINE_UNQUOTED([SLURM_CRAY_ENV],[$slurm_cray_env],
79                           [defined to 1 if slurm cray env, 0 otherwise])
80
81        OPAL_SUMMARY_ADD([[Resource Managers]],[[Slurm]],[$1],[$orte_check_slurm_happy])
82    fi
83
84    AS_IF([test "$orte_check_slurm_happy" = "yes"],
85          [$2],
86          [$3])
87])
88