## Autoconf macros

For applications using `autoconf` the standard macro `AC_CHECK_LIB` can be used to link with the library automatically from a `configure` script. The library itself depends on the presence of a CBLAS and math library as well, so these must also be located before linking with the main `libgsl` file. The following commands should be placed in the ``configure.in'` file to perform these tests,

    AC_CHECK_LIB(m,main)
    AC_CHECK_LIB(gslcblas,main)
    AC_CHECK_LIB(gsl,main)

Assuming the libraries are found the output during the configure stage looks like this,

    checking for main in -lm... yes
    checking for main in -lgslcblas... yes
    checking for main in -lgsl... yes

If the library is found then the tests will define the macros `HAVE_LIBGSL`, `HAVE_LIBGSLCBLAS`, `HAVE_LIBM` and add the options `-lgsl -lgslcblas -lm` to the variable `LIBS`.

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 ``gsl.m4'` to test for a specific version of the library. To use this macro simply add the following line to your ``configure.in'` file instead of the tests above:

    AM_PATH_GSL(GSL_VERSION,
               [action-if-found],
               [action-if-not-found])

The argument `GSL_VERSION` should be the two or three digit MAJOR.MINOR or MAJOR.MINOR.MICRO version number of the release you require. A suitable choice for `action-if-not-found` is,

    AC_MSG_ERROR(could not find required version of GSL)

Then you can add the variables `GSL_LIBS` and `GSL_CFLAGS` to your Makefile.am files to obtain the correct compiler flags. `GSL_LIBS` is equal to the output of the `gsl-config --libs` command and `GSL_CFLAGS` is equal to `gsl-config --cflags` command. For example,

    libgsdv_la_LDFLAGS =    \
            $(GTK_LIBDIR) \
            $(GTK_LIBS) -lgsdvgsl $(GSL_LIBS) -lgslcblas

Note that the macro `AM_PATH_GSL` needs to use the C compiler so it should appear in the ``configure.in'` file before the macro `AC_LANG_CPLUSPLUS` for programs that use C++.