+# --with-cuda {{{
+# only CUDA provides the nvml.h header
+AC_ARG_WITH([cuda],
+ [AS_HELP_STRING([--with-cuda@<:@=PREFIX@:>@], [Path to cuda.])],
+ [
+ if test "x$withval" = "xyes"; then
+ with_cuda="yes"
+ else if test "x$withval" = "xno"; then
+ with_cuda="no"
+ else
+ with_cuda="yes"
+ CUDA_CFLAGS="$CUDA_CFLAGS -I$withval/include"
+ CUDA_LDFLAGS="$CUDA_LDFLAGS -L$withval/lib"
+ fi; fi
+ ],
+ [ with_cuda="yes"
+ CUDA_CFLAGS="$CUDA_CFLAGS -I/opt/cuda/include"
+ CUDA_LDFLAGS="$CUDA_LDFLAGS -L/opt/cuda/lib64"
+ ]
+)
+
+SAVE_CFLAGS="$CFLAGS"
+SAVE_LDFLAGS="$LDFLAGS"
+CFLAGS="$CFLAGS $CUDA_CFLAGS"
+LDFLAGS="$LDFLAGS $CUDA_LDFLAGS"
+
+if test "x$with_cuda" = "xyes"; then
+ AC_CHECK_HEADERS([nvml.h],
+ [with_cuda="yes"],
+ [with_cuda="no (header file missing)"]
+ )
+fi
+
+if test "x$with_cuda" = "xpkgconfig"; then
+ AC_CHECK_HEADERS([nvml.h],
+ [],
+ [with_cuda="no (header file missing)"]
+ )
+fi
+
+if test "x$with_cuda" = "xyes"; then
+ BUILD_WITH_CUDA_CFLAGS="$CUDA_CFLAGS"
+ BUILD_WITH_CUDA_LDFLAGS="$CUDA_LDFLAGS"
+ BUILD_WITH_CUDA_LIBS="-lnvidia-ml"
+fi
+
+AC_SUBST([BUILD_WITH_CUDA_CFLAGS])
+AC_SUBST([BUILD_WITH_CUDA_LDFLAGS])
+AC_SUBST([BUILD_WITH_CUDA_LIBS])
+
+# }}}
+