diff --git a/src/cf/cc.m4 b/src/cf/cc.m4 index 65965d8986..e5edc09f0e 100644 --- a/src/cf/cc.m4 +++ b/src/cf/cc.m4 @@ -77,6 +77,24 @@ AC_DEFUN([OPENAFS_PATH_CC], [ []) ]) +dnl OPENAFS_PATH_PROGS_GLOB(VARIABLE, PROGS-TO-CHECK-FOR, PATH-GLOB) +dnl +dnl Calls AC_PATH_PROGS(VARIABLE, PROGS-TO-CHECK-FOR, [], path), but build the +dnl path from a shell glob. If the glob doesn't match anything, don't run +dnl AC_PATH_PROGS. +AC_DEFUN([OPENAFS_PATH_PROGS_GLOB], + [path= + for item in $3 ; do + AS_IF([test -e "$item"], + [AS_IF([test x"$path" = x], + [path="$item"], + [path="$path:$item"])]) + done + AS_IF([test x"$path" != x], + [AC_PATH_PROGS([$1], [$2], [], [$path])]) + path= +]) + AC_DEFUN([AIX7_PATH_CC], [ # On AIX, we need to use the xlc compiler. Starting with AIX 7.2, a new # version of the compiler (17.1) is available, which is invoked via @@ -89,6 +107,15 @@ AC_DEFUN([AIX7_PATH_CC], [ AS_IF([test x"$CC" = x], [AC_PATH_PROGS([CC], [ibm-clang cc])]) + # If we haven't found anything, try to find ibm-clang in common locations. + AS_IF([test x"$CC" = x], + [OPENAFS_PATH_PROGS_GLOB([CC], [ibm-clang], [/opt/IBM/openxlC/*/bin])]) + + # If we haven't found anything, try to find the old xlc compiler in common + # locations. + AS_IF([test x"$CC" = x], + [OPENAFS_PATH_PROGS_GLOB([CC], [cc], [/opt/IBM/xlC/*/bin])]) + AS_IF([test x"$CC" = x], [AC_MSG_FAILURE([m4_join([ ], [Could not find the ibm-clang or cc compiler.], diff --git a/src/cf/osconf.m4 b/src/cf/osconf.m4 index 95958f988b..82c5d79505 100644 --- a/src/cf/osconf.m4 +++ b/src/cf/osconf.m4 @@ -405,7 +405,10 @@ case $AFS_SYSNAME in [ # Assume this is XL C 16.1 or earlier AC_MSG_RESULT([xlc]) - MT_CC="xlc_r" + + # Replace the last path component of $CC with xlc_r, whether + # $CC is cc, xlc, or /path/to/xlc, etc. + MT_CC="${CC%${CC##*/}}xlc_r" XCFLAGS="-K -D_NONSTD_TYPES -D_MBI=void" XCFLAGS64=-q64 ]