Skip to content

Commit 234356a

Browse files
committed
configure.ac: Add workaround on MacOS for "readlink -f"
MacOS does not have "readlink -f" or "realpath", so use the MacOS-provided Python, which we know has os.path.realpath(). Signed-off-by: Jeff Squyres <[email protected]> (cherry picked from commit ddf216b)
1 parent 35e7d86 commit 234356a

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

configure.ac

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,29 @@ AC_DEFUN([OMPI_CHECK_DIR_FOR_SPACES],[
125125
AC_MSG_ERROR([Cannot continue.])])
126126
])
127127

128+
AC_DEFUN([OMPI_CANONICALIZE_PATH],[
129+
case $host_os in
130+
darwin*)
131+
# MacOS does not have "readlink -f" or realpath (at least as
132+
# of MacOS Cataline / 10.15). Instead, use Python, because we
133+
# know MacOS comes with a /usr/bin/python that has
134+
# os.path.realpath.
135+
$2=`/usr/bin/python -c 'import os; print os.path.realpath("'$1'")'`
136+
;;
137+
*)
138+
$2=`readlink -f $1`
139+
;;
140+
esac
141+
])
142+
128143
OMPI_CHECK_DIR_FOR_SPACES([$srcdir], [a], [source tree])
129-
OMPI_CHECK_DIR_FOR_SPACES([`readlink -f $srcdir`], [an], [absolute source tree])
130-
OMPI_CHECK_DIR_FOR_SPACES([`readlink -f .`], [a], [build tree])
144+
OMPI_CANONICALIZE_PATH([$srcdir], [ompi_dir])
145+
OMPI_CHECK_DIR_FOR_SPACES([$ompi_dir], [an], [absolute source tree])
146+
OMPI_CANONICALIZE_PATH([.], [ompi_dir])
147+
OMPI_CHECK_DIR_FOR_SPACES([$ompi_dir], [a], [build tree])
131148
OMPI_CHECK_DIR_FOR_SPACES([$prefix], [a], [prefix])
132-
OMPI_CHECK_DIR_FOR_SPACES([`readlink -f $prefix`], [an], [absolute prefix])
149+
OMPI_CANONICALIZE_PATH([$prefix], [ompi_dir])
150+
OMPI_CHECK_DIR_FOR_SPACES([$ompi_dir], [an], [absolute prefix])
133151

134152
opal_show_subtitle "Checking versions"
135153

0 commit comments

Comments
 (0)