Added script front-end for primer-design code
[htsworkflow.git] / htswanalysis / MACS / lib / gsl / gsl-1.11 / doc / autoconf.texi
1 @cindex autoconf, using with GSL
2
3 For applications using @code{autoconf} the standard macro
4 @code{AC_CHECK_LIB} can be used to link with GSL automatically
5 from a @code{configure} script.  The library itself depends on the
6 presence of a @sc{cblas} and math library as well, so these must also be
7 located before linking with the main @code{libgsl} file.  The following
8 commands should be placed in the @file{configure.ac} file to perform
9 these tests,
10
11 @example
12 AC_CHECK_LIB([m],[cos])
13 AC_CHECK_LIB([gslcblas],[cblas_dgemm])
14 AC_CHECK_LIB([gsl],[gsl_blas_dgemm])
15 @end example
16
17 @noindent
18 It is important to check for @code{libm} and @code{libgslcblas} before
19 @code{libgsl}, otherwise the tests will fail.  Assuming the libraries
20 are found the output during the configure stage looks like this,
21
22 @example
23 checking for cos in -lm... yes
24 checking for cblas_dgemm in -lgslcblas... yes
25 checking for gsl_blas_dgemm in -lgsl... yes
26 @end example
27
28 @noindent
29 If the library is found then the tests will define the macros
30 @code{HAVE_LIBGSL}, @code{HAVE_LIBGSLCBLAS}, @code{HAVE_LIBM} and add
31 the options @code{-lgsl -lgslcblas -lm} to the variable @code{LIBS}.
32
33 The tests above will find any version of the library.  They are suitable
34 for general use, where the versions of the functions are not important.
35 An alternative macro is available in the file @file{gsl.m4} to test for
36 a specific version of the library.  To use this macro simply add the
37 following line to your @file{configure.in} file instead of the tests
38 above:
39
40 @example
41 AX_PATH_GSL(GSL_VERSION,
42            [action-if-found],
43            [action-if-not-found])
44 @end example
45
46 @noindent
47 The argument @code{GSL_VERSION} should be the two or three digit
48 @sc{major.minor} or @sc{major.minor.micro} version number of the release
49 you require. A suitable choice for @code{action-if-not-found} is,
50
51 @example
52 AC_MSG_ERROR(could not find required version of GSL)
53 @end example
54
55 @noindent
56 Then you can add the variables @code{GSL_LIBS} and @code{GSL_CFLAGS} to
57 your Makefile.am files to obtain the correct compiler flags.
58 @code{GSL_LIBS} is equal to the output of the @code{gsl-config --libs}
59 command and @code{GSL_CFLAGS} is equal to @code{gsl-config --cflags}
60 command. For example,
61
62 @example
63 libfoo_la_LDFLAGS = -lfoo $(GSL_LIBS) -lgslcblas
64 @end example
65
66 @noindent
67 Note that the macro @code{AX_PATH_GSL} needs to use the C compiler so it
68 should appear in the @file{configure.in} file before the macro
69 @code{AC_LANG_CPLUSPLUS} for programs that use C++.
70
71 To test for @code{inline} the following test should be placed in your
72 @file{configure.in} file,
73
74 @example
75 AC_C_INLINE
76
77 if test "$ac_cv_c_inline" != no ; then
78   AC_DEFINE(HAVE_INLINE,1)
79   AC_SUBST(HAVE_INLINE)
80 fi
81 @end example
82
83 @noindent
84 and the macro will then be defined in the compilation flags or by
85 including the file @file{config.h} before any library headers.  
86
87 The following autoconf test will check for @code{extern inline},
88
89 @smallexample
90 dnl Check for "extern inline", using a modified version
91 dnl of the test for AC_C_INLINE from acspecific.mt
92 dnl
93 AC_CACHE_CHECK([for extern inline], ac_cv_c_extern_inline,
94 [ac_cv_c_extern_inline=no
95 AC_TRY_COMPILE([extern $ac_cv_c_inline double foo(double x);
96 extern $ac_cv_c_inline double foo(double x) @{ return x+1.0; @};
97 double foo (double x) @{ return x + 1.0; @};], 
98 [  foo(1.0)  ],
99 [ac_cv_c_extern_inline="yes"])
100 ])
101
102 if test "$ac_cv_c_extern_inline" != no ; then
103   AC_DEFINE(HAVE_INLINE,1)
104   AC_SUBST(HAVE_INLINE)
105 fi
106 @end smallexample
107
108 The substitution of portability functions can be made automatically if
109 you use @code{autoconf}. For example, to test whether the BSD function
110 @code{hypot} is available you can include the following line in the
111 configure file @file{configure.in} for your application,
112
113 @example
114 AC_CHECK_FUNCS(hypot)
115 @end example
116
117 @noindent
118 and place the following macro definitions in the file
119 @file{config.h.in},
120
121 @example
122 /* Substitute gsl_hypot for missing system hypot */
123
124 #ifndef HAVE_HYPOT
125 #define hypot gsl_hypot
126 #endif
127 @end example
128
129 @noindent
130 The application source files can then use the include command
131 @code{#include <config.h>} to substitute @code{gsl_hypot} for each
132 occurrence of @code{hypot} when @code{hypot} is not available.