Skip to content
Snippets Groups Projects
Commit 3e31012e authored by Nate Rini's avatar Nate Rini Committed by Tim Wickberg
Browse files

autoconf - search in system path for libnvml

Bug 11883
parent 1d35f60e
No related branches found
No related tags found
No related merge requests found
...@@ -23,32 +23,43 @@ AC_DEFUN([X_AC_NVML], ...@@ -23,32 +23,43 @@ AC_DEFUN([X_AC_NVML],
if [test "x$with_nvml" = xno]; then if [test "x$with_nvml" = xno]; then
AC_MSG_WARN([support for nvml disabled]) AC_MSG_WARN([support for nvml disabled])
else else
for d in $_x_ac_nvml_dirs; do # Check if libnvml is already in the system paths
if [ ! test -d "$d" ]; then AC_CHECK_HEADER([nvml.h], [ac_nvml_h=yes], [ac_nvml_h=no])
continue AC_CHECK_LIB([nvidia-ml], [nvmlInit], [ac_nvml=yes], [ac_nvml=no])
fi
for bit in $_x_ac_nvml_libs; do if [ test "$ac_nvml" = "yes" && test "$ac_nvml_h" = "yes" ]; then
if [ ! test -d "$d/$bit" || ! test -d "$d/include" ]; then # found in system path
nvml_includes=""
nvml_libs="-lnvidia-ml"
else
#try to find libnvml
for d in $_x_ac_nvml_dirs; do
if [ ! test -d "$d" ]; then
continue continue
fi fi
_x_ac_nvml_ldflags_save="$LDFLAGS" for bit in $_x_ac_nvml_libs; do
_x_ac_nvml_cppflags_save="$CPPFLAGS" if [ ! test -d "$d/$bit" || ! test -d "$d/include" ]; then
LDFLAGS="-L$d/$bit -lnvidia-ml" continue
CPPFLAGS="-I$d/include $CPPFLAGS" fi
AC_CHECK_HEADER([nvml.h], [ac_nvml_h=yes], [ac_nvml_h=no]) _x_ac_nvml_ldflags_save="$LDFLAGS"
AC_CHECK_LIB([nvidia-ml], [nvmlInit], [ac_nvml=yes], [ac_nvml=no]) _x_ac_nvml_cppflags_save="$CPPFLAGS"
LDFLAGS="$_x_ac_nvml_ldflags_save" LDFLAGS="-L$d/$bit -lnvidia-ml"
CPPFLAGS="$_x_ac_nvml_cppflags_save" CPPFLAGS="-I$d/include $CPPFLAGS"
AC_CHECK_HEADER([nvml.h], [ac_nvml_h=yes], [ac_nvml_h=no])
AC_CHECK_LIB([nvidia-ml], [nvmlInit], [ac_nvml=yes], [ac_nvml=no])
LDFLAGS="$_x_ac_nvml_ldflags_save"
CPPFLAGS="$_x_ac_nvml_cppflags_save"
if [ test "$ac_nvml" = "yes" && test "$ac_nvml_h" = "yes" ]; then
nvml_includes="-I$d/include"
nvml_libs="-L$d/$bit -lnvidia-ml"
break
fi
done
if [ test "$ac_nvml" = "yes" && test "$ac_nvml_h" = "yes" ]; then if [ test "$ac_nvml" = "yes" && test "$ac_nvml_h" = "yes" ]; then
nvml_includes="-I$d/include"
nvml_libs="-L$d/$bit -lnvidia-ml"
break break
fi fi
done done
if [ test "$ac_nvml" = "yes" && test "$ac_nvml_h" = "yes" ]; then fi
break
fi
done
if [ test "$ac_nvml" = "yes" && test "$ac_nvml_h" = "yes" ]; then if [ test "$ac_nvml" = "yes" && test "$ac_nvml_h" = "yes" ]; then
NVML_LIBS="$nvml_libs" NVML_LIBS="$nvml_libs"
......
...@@ -21344,19 +21344,77 @@ fi ...@@ -21344,19 +21344,77 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: support for nvml disabled" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: support for nvml disabled" >&5
$as_echo "$as_me: WARNING: support for nvml disabled" >&2;} $as_echo "$as_me: WARNING: support for nvml disabled" >&2;}
else else
for d in $_x_ac_nvml_dirs; do # Check if libnvml is already in the system paths
if ! test -d "$d" ; then ac_fn_c_check_header_mongrel "$LINENO" "nvml.h" "ac_cv_header_nvml_h" "$ac_includes_default"
continue if test "x$ac_cv_header_nvml_h" = xyes; then :
fi ac_nvml_h=yes
for bit in $_x_ac_nvml_libs; do else
if ! test -d "$d/$bit" || ! test -d "$d/include" ; then ac_nvml_h=no
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for nvmlInit in -lnvidia-ml" >&5
$as_echo_n "checking for nvmlInit in -lnvidia-ml... " >&6; }
if ${ac_cv_lib_nvidia_ml_nvmlInit+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lnvidia-ml $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char nvmlInit ();
int
main ()
{
return nvmlInit ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_nvidia_ml_nvmlInit=yes
else
ac_cv_lib_nvidia_ml_nvmlInit=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nvidia_ml_nvmlInit" >&5
$as_echo "$ac_cv_lib_nvidia_ml_nvmlInit" >&6; }
if test "x$ac_cv_lib_nvidia_ml_nvmlInit" = xyes; then :
ac_nvml=yes
else
ac_nvml=no
fi
if test "$ac_nvml" = "yes" && test "$ac_nvml_h" = "yes" ; then
# found in system path
nvml_includes=""
nvml_libs="-lnvidia-ml"
else
#try to find libnvml
for d in $_x_ac_nvml_dirs; do
if ! test -d "$d" ; then
continue continue
fi fi
_x_ac_nvml_ldflags_save="$LDFLAGS" for bit in $_x_ac_nvml_libs; do
_x_ac_nvml_cppflags_save="$CPPFLAGS" if ! test -d "$d/$bit" || ! test -d "$d/include" ; then
LDFLAGS="-L$d/$bit -lnvidia-ml" continue
CPPFLAGS="-I$d/include $CPPFLAGS" fi
ac_fn_c_check_header_mongrel "$LINENO" "nvml.h" "ac_cv_header_nvml_h" "$ac_includes_default" _x_ac_nvml_ldflags_save="$LDFLAGS"
_x_ac_nvml_cppflags_save="$CPPFLAGS"
LDFLAGS="-L$d/$bit -lnvidia-ml"
CPPFLAGS="-I$d/include $CPPFLAGS"
ac_fn_c_check_header_mongrel "$LINENO" "nvml.h" "ac_cv_header_nvml_h" "$ac_includes_default"
if test "x$ac_cv_header_nvml_h" = xyes; then : if test "x$ac_cv_header_nvml_h" = xyes; then :
ac_nvml_h=yes ac_nvml_h=yes
else else
...@@ -21364,7 +21422,7 @@ else ...@@ -21364,7 +21422,7 @@ else
fi fi
   
   
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for nvmlInit in -lnvidia-ml" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for nvmlInit in -lnvidia-ml" >&5
$as_echo_n "checking for nvmlInit in -lnvidia-ml... " >&6; } $as_echo_n "checking for nvmlInit in -lnvidia-ml... " >&6; }
if ${ac_cv_lib_nvidia_ml_nvmlInit+:} false; then : if ${ac_cv_lib_nvidia_ml_nvmlInit+:} false; then :
$as_echo_n "(cached) " >&6 $as_echo_n "(cached) " >&6
...@@ -21406,18 +21464,19 @@ else ...@@ -21406,18 +21464,19 @@ else
ac_nvml=no ac_nvml=no
fi fi
   
LDFLAGS="$_x_ac_nvml_ldflags_save" LDFLAGS="$_x_ac_nvml_ldflags_save"
CPPFLAGS="$_x_ac_nvml_cppflags_save" CPPFLAGS="$_x_ac_nvml_cppflags_save"
if test "$ac_nvml" = "yes" && test "$ac_nvml_h" = "yes" ; then
nvml_includes="-I$d/include"
nvml_libs="-L$d/$bit -lnvidia-ml"
break
fi
done
if test "$ac_nvml" = "yes" && test "$ac_nvml_h" = "yes" ; then if test "$ac_nvml" = "yes" && test "$ac_nvml_h" = "yes" ; then
nvml_includes="-I$d/include"
nvml_libs="-L$d/$bit -lnvidia-ml"
break break
fi fi
done done
if test "$ac_nvml" = "yes" && test "$ac_nvml_h" = "yes" ; then fi
break
fi
done
   
if test "$ac_nvml" = "yes" && test "$ac_nvml_h" = "yes" ; then if test "$ac_nvml" = "yes" && test "$ac_nvml_h" = "yes" ; then
NVML_LIBS="$nvml_libs" NVML_LIBS="$nvml_libs"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment