1414# flags that are needed. (The user can also force certain compiler
1515# flags/libs to be tested by setting these environment variables.)
1616#
17- # Also sets PTHREAD_CC to any special C compiler that is needed for
18- # multi-threaded programs (defaults to the value of CC otherwise). (This
19- # is necessary on AIX to use the special cc_r compiler alias.)
17+ # Also sets PTHREAD_CC and PTHREAD_CXX to any special C compiler that is
18+ # needed for multi-threaded programs (defaults to the value of CC
19+ # respectively CXX otherwise). (This is necessary on e.g. AIX to use the
20+ # special cc_r/CC_r compiler alias.)
2021#
2122# NOTE: You are assumed to not only compile your program with these flags,
2223# but also to link with them as well. For example, you might link with
2324# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
25+ # $PTHREAD_CXX $CXXFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
2426#
2527# If you are only building threaded programs, you may wish to use these
2628# variables in your default LIBS, CFLAGS, and CC:
2729#
2830# LIBS="$PTHREAD_LIBS $LIBS"
2931# CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
32+ # CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"
3033# CC="$PTHREAD_CC"
34+ # CXX="$PTHREAD_CXX"
3135#
3236# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
3337# has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to
8387# modified version of the Autoconf Macro, you may extend this special
8488# exception to the GPL to apply to your modified version as well.
8589
86- # serial 27
90+ # serial 31
8791
8892AU_ALIAS ( [ ACX_PTHREAD] , [ AX_PTHREAD ] )
8993AC_DEFUN ( [ AX_PTHREAD ] , [
@@ -105,6 +109,7 @@ if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then
105109 ax_pthread_save_CFLAGS="$CFLAGS"
106110 ax_pthread_save_LIBS="$LIBS"
107111 AS_IF ( [ test "x$PTHREAD_CC" != "x"] , [ CC="$PTHREAD_CC"] )
112+ AS_IF ( [ test "x$PTHREAD_CXX" != "x"] , [ CXX="$PTHREAD_CXX"] )
108113 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
109114 LIBS="$PTHREAD_LIBS $LIBS"
110115 AC_MSG_CHECKING ( [ for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS] )
@@ -386,7 +391,7 @@ if test "x$ax_pthread_clang" = "xyes"; then
386391 # step
387392 ax_pthread_save_ac_link="$ac_link"
388393 ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g'
389- ax_pthread_link_step=`$as_echo "$ac_link" | sed "$ax_pthread_sed"`
394+ ax_pthread_link_step=`AS_ECHO ( [ "$ac_link"] ) | sed "$ax_pthread_sed"`
390395 ax_pthread_2step_ac_link="($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)"
391396 ax_pthread_save_CFLAGS="$CFLAGS"
392397 for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do
@@ -482,18 +487,28 @@ if test "x$ax_pthread_ok" = "xyes"; then
482487 [ #handle absolute path differently from PATH based program lookup
483488 AS_CASE ( [ "x$CC"] ,
484489 [ x/*] ,
485- [ AS_IF ( [ AS_EXECUTABLE_P([ ${CC}_r] )] ,[ PTHREAD_CC="${CC}_r"] ) ] ,
486- [ AC_CHECK_PROGS ( [ PTHREAD_CC] ,[ ${CC}_r] ,[ $CC] ) ] ) ] )
490+ [
491+ AS_IF ( [ AS_EXECUTABLE_P([ ${CC}_r] )] ,[ PTHREAD_CC="${CC}_r"] )
492+ AS_IF ( [ test "x${CXX}" != "x"] , [ AS_IF ( [ AS_EXECUTABLE_P([ ${CXX}_r] )] ,[ PTHREAD_CXX="${CXX}_r"] ) ] )
493+ ] ,
494+ [
495+ AC_CHECK_PROGS ( [ PTHREAD_CC] ,[ ${CC}_r] ,[ $CC] )
496+ AS_IF ( [ test "x${CXX}" != "x"] , [ AC_CHECK_PROGS ( [ PTHREAD_CXX] ,[ ${CXX}_r] ,[ $CXX] ) ] )
497+ ]
498+ )
499+ ] )
487500 ;;
488501 esac
489502 fi
490503fi
491504
492505test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"
506+ test -n "$PTHREAD_CXX" || PTHREAD_CXX="$CXX"
493507
494508AC_SUBST ( [ PTHREAD_LIBS] )
495509AC_SUBST ( [ PTHREAD_CFLAGS] )
496510AC_SUBST ( [ PTHREAD_CC] )
511+ AC_SUBST ( [ PTHREAD_CXX] )
497512
498513# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
499514if test "x$ax_pthread_ok" = "xyes"; then
0 commit comments