1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 The GSL Team.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "GNU General Public License" and "Free Software
Needs Free Documentation", the Front-Cover text being "A GNU Manual",
and with the Back-Cover Text being (a) (see below). A copy of the
license is included in the section entitled "GNU Free Documentation
License".
(a) The Back-Cover Text is: "You have the freedom to copy and modify this
GNU Manual." -->
<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
<head>
<title>GNU Scientific Library – Reference Manual: Autoconf Macros</title>
<meta name="description" content="GNU Scientific Library – Reference Manual: Autoconf Macros">
<meta name="keywords" content="GNU Scientific Library – Reference Manual: Autoconf Macros">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Function-Index.html#Function-Index" rel="index" title="Function Index">
<link href="index.html#Top" rel="up" title="Top">
<link href="GSL-CBLAS-Library.html#GSL-CBLAS-Library" rel="next" title="GSL CBLAS Library">
<link href="Contributors-to-GSL.html#Contributors-to-GSL" rel="previous" title="Contributors to GSL">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Autoconf-Macros"></a>
<div class="header">
<p>
Next: <a href="GSL-CBLAS-Library.html#GSL-CBLAS-Library" accesskey="n" rel="next">GSL CBLAS Library</a>, Previous: <a href="Contributors-to-GSL.html#Contributors-to-GSL" accesskey="p" rel="previous">Contributors to GSL</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> [<a href="Function-Index.html#Function-Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="Autoconf-Macros-1"></a>
<h2 class="appendix">Appendix C Autoconf Macros</h2>
<a name="index-autoconf_002c-using-with-GSL"></a>
<p>For applications using <code>autoconf</code> the standard macro
<code>AC_CHECK_LIB</code> can be used to link with GSL automatically
from a <code>configure</code> script. The library itself depends on the
presence of a <small>CBLAS</small> and math library as well, so these must also be
located before linking with the main <code>libgsl</code> file. The following
commands should be placed in the <samp>configure.ac</samp> file to perform
these tests,
</p>
<div class="example">
<pre class="example">AC_CHECK_LIB([m],[cos])
AC_CHECK_LIB([gslcblas],[cblas_dgemm])
AC_CHECK_LIB([gsl],[gsl_blas_dgemm])
</pre></div>
<p>It is important to check for <code>libm</code> and <code>libgslcblas</code> before
<code>libgsl</code>, otherwise the tests will fail. Assuming the libraries
are found the output during the configure stage looks like this,
</p>
<div class="example">
<pre class="example">checking for cos in -lm... yes
checking for cblas_dgemm in -lgslcblas... yes
checking for gsl_blas_dgemm in -lgsl... yes
</pre></div>
<p>If the library is found then the tests will define the macros
<code>HAVE_LIBGSL</code>, <code>HAVE_LIBGSLCBLAS</code>, <code>HAVE_LIBM</code> and add
the options <code>-lgsl -lgslcblas -lm</code> to the variable <code>LIBS</code>.
</p>
<p>The tests above will find any version of the library. They are suitable
for general use, where the versions of the functions are not important.
An alternative macro is available in the file <samp>gsl.m4</samp> to test for
a specific version of the library. To use this macro simply add the
following line to your <samp>configure.in</samp> file instead of the tests
above:
</p>
<div class="example">
<pre class="example">AX_PATH_GSL(GSL_VERSION,
[action-if-found],
[action-if-not-found])
</pre></div>
<p>The argument <code>GSL_VERSION</code> should be the two or three digit
<small>MAJOR.MINOR</small> or <small>MAJOR.MINOR.MICRO</small> version number of the release
you require. A suitable choice for <code>action-if-not-found</code> is,
</p>
<div class="example">
<pre class="example">AC_MSG_ERROR(could not find required version of GSL)
</pre></div>
<p>Then you can add the variables <code>GSL_LIBS</code> and <code>GSL_CFLAGS</code> to
your Makefile.am files to obtain the correct compiler flags.
<code>GSL_LIBS</code> is equal to the output of the <code>gsl-config --libs</code>
command and <code>GSL_CFLAGS</code> is equal to <code>gsl-config --cflags</code>
command. For example,
</p>
<div class="example">
<pre class="example">libfoo_la_LDFLAGS = -lfoo $(GSL_LIBS) -lgslcblas
</pre></div>
<p>Note that the macro <code>AX_PATH_GSL</code> needs to use the C compiler so it
should appear in the <samp>configure.in</samp> file before the macro
<code>AC_LANG_CPLUSPLUS</code> for programs that use C++.
</p>
<p>To test for <code>inline</code> the following test should be placed in your
<samp>configure.in</samp> file,
</p>
<div class="example">
<pre class="example">AC_C_INLINE
if test "$ac_cv_c_inline" != no ; then
AC_DEFINE(HAVE_INLINE,1)
AC_SUBST(HAVE_INLINE)
fi
</pre></div>
<p>and the macro will then be defined in the compilation flags or by
including the file <samp>config.h</samp> before any library headers.
</p>
<p>The following autoconf test will check for <code>extern inline</code>,
</p>
<div class="smallexample">
<pre class="smallexample">dnl Check for "extern inline", using a modified version
dnl of the test for AC_C_INLINE from acspecific.mt
dnl
AC_CACHE_CHECK([for extern inline], ac_cv_c_extern_inline,
[ac_cv_c_extern_inline=no
AC_TRY_COMPILE([extern $ac_cv_c_inline double foo(double x);
extern $ac_cv_c_inline double foo(double x) { return x+1.0; };
double foo (double x) { return x + 1.0; };],
[ foo(1.0) ],
[ac_cv_c_extern_inline="yes"])
])
if test "$ac_cv_c_extern_inline" != no ; then
AC_DEFINE(HAVE_INLINE,1)
AC_SUBST(HAVE_INLINE)
fi
</pre></div>
<p>The substitution of portability functions can be made automatically if
you use <code>autoconf</code>. For example, to test whether the BSD function
<code>hypot</code> is available you can include the following line in the
configure file <samp>configure.in</samp> for your application,
</p>
<div class="example">
<pre class="example">AC_CHECK_FUNCS(hypot)
</pre></div>
<p>and place the following macro definitions in the file
<samp>config.h.in</samp>,
</p>
<div class="example">
<pre class="example">/* Substitute gsl_hypot for missing system hypot */
#ifndef HAVE_HYPOT
#define hypot gsl_hypot
#endif
</pre></div>
<p>The application source files can then use the include command
<code>#include <config.h></code> to substitute <code>gsl_hypot</code> for each
occurrence of <code>hypot</code> when <code>hypot</code> is not available.
</p>
<hr>
<div class="header">
<p>
Next: <a href="GSL-CBLAS-Library.html#GSL-CBLAS-Library" accesskey="n" rel="next">GSL CBLAS Library</a>, Previous: <a href="Contributors-to-GSL.html#Contributors-to-GSL" accesskey="p" rel="previous">Contributors to GSL</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> [<a href="Function-Index.html#Function-Index" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>
|