]> git.draconx.ca Git - cdecl99.git/blobdiff - m4/gsl.m4
Add a tool to generate random declarations.
[cdecl99.git] / m4 / gsl.m4
diff --git a/m4/gsl.m4 b/m4/gsl.m4
new file mode 100644 (file)
index 0000000..781fed5
--- /dev/null
+++ b/m4/gsl.m4
@@ -0,0 +1,74 @@
+dnl Copyright © 2009-2011 Nick Bowler
+dnl
+dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2.
+dnl This is free software: you are free to do what the fuck you want to.
+dnl There is NO WARRANTY, to the extent permitted by law.
+
+AC_DEFUN([_DX_CHECK_GSL_TEST], [dnl
+       DX_COMPUTE_C_STRING([gsl_version], [GSL_VERSION], [dnl
+#include <gsl/gsl_version.h>
+], [gsl_version=0])
+
+       AS_VERSION_COMPARE([$gsl_version], [$1],
+               [gsl_version_ok=no],
+               [gsl_version_ok=yes],
+               [gsl_version_ok=yes])
+
+       if test x"$gsl_version_ok" = x"yes"; then
+               AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl
+#include <gsl/gsl_matrix.h>
+#include <gsl/gsl_blas.h>
+], [dnl
+double m1buf@<:@16@:>@, m2buf@<:@16@:>@, m3buf@<:@16@:>@;
+
+gsl_matrix_view m1 = gsl_matrix_view_array(m1buf, 4, 4);
+gsl_matrix_view m2 = gsl_matrix_view_array(m2buf, 4, 4);
+gsl_matrix_view m3 = gsl_matrix_view_array(m3buf, 4, 4);
+
+gsl_matrix_set_identity(&m1.matrix);
+gsl_matrix_set_identity(&m2.matrix);
+gsl_blas_dgemm(CblasNoTrans, CblasNoTrans, 1, &m1.matrix, &m2.matrix,
+       0, &m3.matrix);
+
+return 0;
+])], [$2])
+       fi
+])
+
+dnl DX_CHECK_GSL([min-version], [action-if-found], [action-if-not-found])
+AC_DEFUN([DX_CHECK_GSL], [dnl
+DX_PKG_CONFIG([gsl], [gsl], [GSL])
+AC_ARG_VAR([GSL_CONFIG], [path to gsl-config binary])
+AC_PATH_PROG([GSL_CONFIG], [gsl-config])
+
+if test x"$GSL_CONFIG" != x; then
+       gsl_config_cflags=`$GSL_CONFIG --cflags`
+       gsl_config_libs=`$GSL_CONFIG --libs`
+fi
+
+DX_CHECK_LIB_EXT([gsl],
+       [for GSL version at least ifelse([$1], [], [1.0], [$1])],
+       [m4_curry([_DX_CHECK_GSL_TEST], [ifelse([$1], [], [1.0], [$1])])],
+       [dnl
+               [[$GSL_CFLAGS], [$GSL_LIBS]],
+               [[$pkg_cv_gsl_cflags], [$pkg_cv_gsl_libs],
+                       [test x"$pkg_failed" != x"yes"]],
+               [[$gsl_config_cflags], [$gsl_config_libs],
+                       [test x"$SDL_CONFIG" != x""]],
+               ])
+
+if test x"$dx_cv_gsl_found" = x"yes"; then
+       ifelse([$2], [], [:], [$2])
+else
+       ifelse([$3], [], [AC_MSG_FAILURE([dnl
+GSL version at least ifelse([$1], [], [1.0], [$1]) is required.  The
+latest version can be optained from http://gnu.org/software/gsl/.
+
+If GSL is installed but was not found by this configure script, consider
+adjusting GSL_CFLAGS, GSL_LIBS and/or GSL_CONFIG as necessary.
+
+If pkg-config is installed, it may help to adjust PKG_CONFIG_PATH
+if GSL is installed in a non-standard prefix.
+])], [$3])
+fi
+])