]> git.draconx.ca Git - cdecl99.git/blob - m4/gsl.m4
Add a tool to generate random declarations.
[cdecl99.git] / m4 / gsl.m4
1 dnl Copyright © 2009-2011 Nick Bowler
2 dnl
3 dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2.
4 dnl This is free software: you are free to do what the fuck you want to.
5 dnl There is NO WARRANTY, to the extent permitted by law.
6
7 AC_DEFUN([_DX_CHECK_GSL_TEST], [dnl
8         DX_COMPUTE_C_STRING([gsl_version], [GSL_VERSION], [dnl
9 #include <gsl/gsl_version.h>
10 ], [gsl_version=0])
11
12         AS_VERSION_COMPARE([$gsl_version], [$1],
13                 [gsl_version_ok=no],
14                 [gsl_version_ok=yes],
15                 [gsl_version_ok=yes])
16
17         if test x"$gsl_version_ok" = x"yes"; then
18                 AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl
19 #include <gsl/gsl_matrix.h>
20 #include <gsl/gsl_blas.h>
21 ], [dnl
22 double m1buf@<:@16@:>@, m2buf@<:@16@:>@, m3buf@<:@16@:>@;
23
24 gsl_matrix_view m1 = gsl_matrix_view_array(m1buf, 4, 4);
25 gsl_matrix_view m2 = gsl_matrix_view_array(m2buf, 4, 4);
26 gsl_matrix_view m3 = gsl_matrix_view_array(m3buf, 4, 4);
27
28 gsl_matrix_set_identity(&m1.matrix);
29 gsl_matrix_set_identity(&m2.matrix);
30 gsl_blas_dgemm(CblasNoTrans, CblasNoTrans, 1, &m1.matrix, &m2.matrix,
31         0, &m3.matrix);
32
33 return 0;
34 ])], [$2])
35         fi
36 ])
37
38 dnl DX_CHECK_GSL([min-version], [action-if-found], [action-if-not-found])
39 AC_DEFUN([DX_CHECK_GSL], [dnl
40 DX_PKG_CONFIG([gsl], [gsl], [GSL])
41 AC_ARG_VAR([GSL_CONFIG], [path to gsl-config binary])
42 AC_PATH_PROG([GSL_CONFIG], [gsl-config])
43
44 if test x"$GSL_CONFIG" != x; then
45         gsl_config_cflags=`$GSL_CONFIG --cflags`
46         gsl_config_libs=`$GSL_CONFIG --libs`
47 fi
48
49 DX_CHECK_LIB_EXT([gsl],
50         [for GSL version at least ifelse([$1], [], [1.0], [$1])],
51         [m4_curry([_DX_CHECK_GSL_TEST], [ifelse([$1], [], [1.0], [$1])])],
52         [dnl
53                 [[$GSL_CFLAGS], [$GSL_LIBS]],
54                 [[$pkg_cv_gsl_cflags], [$pkg_cv_gsl_libs],
55                         [test x"$pkg_failed" != x"yes"]],
56                 [[$gsl_config_cflags], [$gsl_config_libs],
57                         [test x"$SDL_CONFIG" != x""]],
58                 ])
59
60 if test x"$dx_cv_gsl_found" = x"yes"; then
61         ifelse([$2], [], [:], [$2])
62 else
63         ifelse([$3], [], [AC_MSG_FAILURE([dnl
64 GSL version at least ifelse([$1], [], [1.0], [$1]) is required.  The
65 latest version can be optained from http://gnu.org/software/gsl/.
66
67 If GSL is installed but was not found by this configure script, consider
68 adjusting GSL_CFLAGS, GSL_LIBS and/or GSL_CONFIG as necessary.
69
70 If pkg-config is installed, it may help to adjust PKG_CONFIG_PATH
71 if GSL is installed in a non-standard prefix.
72 ])], [$3])
73 fi
74 ])