From f3bf89ebfecb54cb3fc246ccbc19ffd9a6233679 Mon Sep 17 00:00:00 2001
From: Alberto Chiusole <bebosudo@users.noreply.github.com>
Date: Wed, 3 Jul 2019 23:07:51 +0200
Subject: [PATCH] OpenMPI: add support for pbs/tm at configure. (#10620)

---
 .../repos/builtin/packages/openmpi/package.py | 25 ++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/var/spack/repos/builtin/packages/openmpi/package.py b/var/spack/repos/builtin/packages/openmpi/package.py
index 4b054cf610..ef5a788c5e 100644
--- a/var/spack/repos/builtin/packages/openmpi/package.py
+++ b/var/spack/repos/builtin/packages/openmpi/package.py
@@ -45,6 +45,18 @@ def _mxm_dir():
         return None
 
 
+def _tm_dir():
+    """Look for default directory where the PBS/TM package is
+    installed. Return None if not found.
+    """
+    # /opt/pbs from PBS 18+; make this more flexible in the future
+    paths_list = ("/opt/pbs", )
+    for path in paths_list:
+        if os.path.isdir(path) and os.path.isfile(path + "/include/tm.h"):
+            return path
+    return None
+
+
 class Openmpi(AutotoolsPackage):
     """An open source Message Passing Interface implementation.
 
@@ -344,7 +356,18 @@ def with_or_without_mxm(self, activated):
             return '--without-{0}'.format(opt)
         line = '--with-{0}'.format(opt)
         path = _mxm_dir()
-        if (path is not None):
+        if path is not None:
+            line += '={0}'.format(path)
+        return line
+
+    def with_or_without_tm(self, activated):
+        opt = 'tm'
+        # If the option has not been activated return --without-tm
+        if not activated:
+            return '--without-{0}'.format(opt)
+        line = '--with-{0}'.format(opt)
+        path = _tm_dir()
+        if path is not None:
             line += '={0}'.format(path)
         return line
 
-- 
GitLab