Rev Author Line No. Line
178 kaklik 1 dnl @synopsis ACX_BLAS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
2 dnl
3 dnl This macro looks for a library that implements the BLAS
4 dnl linear-algebra interface (see http://www.netlib.org/blas/). On
5 dnl success, it sets the BLAS_LIBS output variable to hold the
6 dnl requisite library linkages.
7 dnl
8 dnl To link with BLAS, you should link with:
9 dnl
10 dnl $BLAS_LIBS $LIBS $FLIBS
11 dnl
12 dnl in that order. FLIBS is the output variable of the
13 dnl AC_F77_LIBRARY_LDFLAGS macro (called if necessary by ACX_BLAS), and
14 dnl is sometimes necessary in order to link with F77 libraries. Users
15 dnl will also need to use AC_F77_DUMMY_MAIN (see the autoconf manual),
16 dnl for the same reason.
17 dnl
18 dnl Many libraries are searched for, from ATLAS to CXML to ESSL. The
19 dnl user may also use --with-blas=<lib> in order to use some specific
20 dnl BLAS library <lib>. In order to link successfully, however, be
21 dnl aware that you will probably need to use the same Fortran compiler
22 dnl (which can be set via the F77 env. var.) as was used to compile the
23 dnl BLAS library.
24 dnl
25 dnl ACTION-IF-FOUND is a list of shell commands to run if a BLAS
26 dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands to
27 dnl run it if it is not found. If ACTION-IF-FOUND is not specified, the
28 dnl default action will define HAVE_BLAS.
29 dnl
30 dnl This macro requires autoconf 2.50 or later.
31 dnl
32 dnl @category InstalledPackages
33 dnl @author Steven G. Johnson <stevenj@alum.mit.edu>
34 dnl @version 2001-12-13
35 dnl @license GPLWithACException
36  
37 AC_DEFUN([ACX_BLAS], [
38 AC_PREREQ(2.50)
39 AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])
40 acx_blas_ok=no
41  
42 AC_ARG_WITH(blas,
43 [AC_HELP_STRING([--with-blas=<lib>], [use BLAS library <lib>])])
44 case $with_blas in
45 yes | "") ;;
46 no) acx_blas_ok=disable ;;
47 -* | */* | *.a | *.so | *.so.* | *.o) BLAS_LIBS="$with_blas" ;;
48 *) BLAS_LIBS="-l$with_blas" ;;
49 esac
50  
51 # Get fortran linker names of BLAS functions to check for.
52 AC_F77_FUNC(sgemm)
53 AC_F77_FUNC(dgemm)
54  
55 acx_blas_save_LIBS="$LIBS"
56 LIBS="$LIBS $FLIBS"
57  
58 # First, check BLAS_LIBS environment variable
59 if test $acx_blas_ok = no; then
60 if test "x$BLAS_LIBS" != x; then
61 save_LIBS="$LIBS"; LIBS="$BLAS_LIBS $LIBS"
62 AC_MSG_CHECKING([for $sgemm in $BLAS_LIBS])
63 AC_TRY_LINK_FUNC($sgemm, [acx_blas_ok=yes], [BLAS_LIBS=""])
64 AC_MSG_RESULT($acx_blas_ok)
65 LIBS="$save_LIBS"
66 fi
67 fi
68  
69 # BLAS linked to by default? (happens on some supercomputers)
70 if test $acx_blas_ok = no; then
71 save_LIBS="$LIBS"; LIBS="$LIBS"
72 AC_CHECK_FUNC($sgemm, [acx_blas_ok=yes])
73 LIBS="$save_LIBS"
74 fi
75  
76 # BLAS in ATLAS library? (http://math-atlas.sourceforge.net/)
77 if test $acx_blas_ok = no; then
78 AC_CHECK_LIB(atlas, ATL_xerbla,
79 [AC_CHECK_LIB(f77blas, $sgemm,
80 [AC_CHECK_LIB(cblas, cblas_dgemm,
81 [acx_blas_ok=yes
82 BLAS_LIBS="-lcblas -lf77blas -latlas"],
83 [], [-lf77blas -latlas])],
84 [], [-latlas])])
85 fi
86  
87 # BLAS in PhiPACK libraries? (requires generic BLAS lib, too)
88 if test $acx_blas_ok = no; then
89 AC_CHECK_LIB(blas, $sgemm,
90 [AC_CHECK_LIB(dgemm, $dgemm,
91 [AC_CHECK_LIB(sgemm, $sgemm,
92 [acx_blas_ok=yes; BLAS_LIBS="-lsgemm -ldgemm -lblas"],
93 [], [-lblas])],
94 [], [-lblas])])
95 fi
96  
97 # BLAS in Alpha CXML library?
98 if test $acx_blas_ok = no; then
99 AC_CHECK_LIB(cxml, $sgemm, [acx_blas_ok=yes;BLAS_LIBS="-lcxml"])
100 fi
101  
102 # BLAS in Alpha DXML library? (now called CXML, see above)
103 if test $acx_blas_ok = no; then
104 AC_CHECK_LIB(dxml, $sgemm, [acx_blas_ok=yes;BLAS_LIBS="-ldxml"])
105 fi
106  
107 # BLAS in Sun Performance library?
108 if test $acx_blas_ok = no; then
109 if test "x$GCC" != xyes; then # only works with Sun CC
110 AC_CHECK_LIB(sunmath, acosp,
111 [AC_CHECK_LIB(sunperf, $sgemm,
112 [BLAS_LIBS="-xlic_lib=sunperf -lsunmath"
113 acx_blas_ok=yes],[],[-lsunmath])])
114 fi
115 fi
116  
117 # BLAS in SCSL library? (SGI/Cray Scientific Library)
118 if test $acx_blas_ok = no; then
119 AC_CHECK_LIB(scs, $sgemm, [acx_blas_ok=yes; BLAS_LIBS="-lscs"])
120 fi
121  
122 # BLAS in SGIMATH library?
123 if test $acx_blas_ok = no; then
124 AC_CHECK_LIB(complib.sgimath, $sgemm,
125 [acx_blas_ok=yes; BLAS_LIBS="-lcomplib.sgimath"])
126 fi
127  
128 # BLAS in IBM ESSL library? (requires generic BLAS lib, too)
129 if test $acx_blas_ok = no; then
130 AC_CHECK_LIB(blas, $sgemm,
131 [AC_CHECK_LIB(essl, $sgemm,
132 [acx_blas_ok=yes; BLAS_LIBS="-lessl -lblas"],
133 [], [-lblas $FLIBS])])
134 fi
135  
136 # Generic BLAS library?
137 if test $acx_blas_ok = no; then
138 AC_CHECK_LIB(blas, $sgemm, [acx_blas_ok=yes; BLAS_LIBS="-lblas"])
139 fi
140  
141 AC_SUBST(BLAS_LIBS)
142  
143 LIBS="$acx_blas_save_LIBS"
144  
145 # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
146 if test x"$acx_blas_ok" = xyes; then
147 ifelse([$1],,AC_DEFINE(HAVE_BLAS,1,[Define if you have a BLAS library.]),[$1])
148 :
149 else
150 acx_blas_ok=no
151 $2
152 fi
153 ])dnl ACX_BLAS
154 dnl @synopsis ACX_LAPACK([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
155 dnl
156 dnl This macro looks for a library that implements the LAPACK
157 dnl linear-algebra interface (see http://www.netlib.org/lapack/). On
158 dnl success, it sets the LAPACK_LIBS output variable to hold the
159 dnl requisite library linkages.
160 dnl
161 dnl To link with LAPACK, you should link with:
162 dnl
163 dnl $LAPACK_LIBS $BLAS_LIBS $LIBS $FLIBS
164 dnl
165 dnl in that order. BLAS_LIBS is the output variable of the ACX_BLAS
166 dnl macro, called automatically. FLIBS is the output variable of the
167 dnl AC_F77_LIBRARY_LDFLAGS macro (called if necessary by ACX_BLAS), and
168 dnl is sometimes necessary in order to link with F77 libraries. Users
169 dnl will also need to use AC_F77_DUMMY_MAIN (see the autoconf manual),
170 dnl for the same reason.
171 dnl
172 dnl The user may also use --with-lapack=<lib> in order to use some
173 dnl specific LAPACK library <lib>. In order to link successfully,
174 dnl however, be aware that you will probably need to use the same
175 dnl Fortran compiler (which can be set via the F77 env. var.) as was
176 dnl used to compile the LAPACK and BLAS libraries.
177 dnl
178 dnl ACTION-IF-FOUND is a list of shell commands to run if a LAPACK
179 dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands to
180 dnl run it if it is not found. If ACTION-IF-FOUND is not specified, the
181 dnl default action will define HAVE_LAPACK.
182 dnl
183 dnl @category InstalledPackages
184 dnl @author Steven G. Johnson <stevenj@alum.mit.edu>
185 dnl @version 2002-03-12
186 dnl @license GPLWithACException
187  
188 AC_DEFUN([ACX_LAPACK], [
189 AC_REQUIRE([ACX_BLAS])
190 acx_lapack_ok=no
191  
192 AC_ARG_WITH(lapack,
193 [AC_HELP_STRING([--with-lapack=<lib>], [use LAPACK library <lib>])])
194 case $with_lapack in
195 yes | "") ;;
196 no) acx_lapack_ok=disable ;;
197 -* | */* | *.a | *.so | *.so.* | *.o) LAPACK_LIBS="$with_lapack" ;;
198 *) LAPACK_LIBS="-l$with_lapack" ;;
199 esac
200  
201 # Get fortran linker name of LAPACK function to check for.
202 AC_F77_FUNC(cheev)
203  
204 # We cannot use LAPACK if BLAS is not found
205 if test "x$acx_blas_ok" != xyes; then
206 acx_lapack_ok=noblas
207 fi
208  
209 # First, check LAPACK_LIBS environment variable
210 if test "x$LAPACK_LIBS" != x; then
211 save_LIBS="$LIBS"; LIBS="$LAPACK_LIBS $BLAS_LIBS $LIBS $FLIBS"
212 AC_MSG_CHECKING([for $cheev in $LAPACK_LIBS])
213 AC_TRY_LINK_FUNC($cheev, [acx_lapack_ok=yes], [LAPACK_LIBS=""])
214 AC_MSG_RESULT($acx_lapack_ok)
215 LIBS="$save_LIBS"
216 if test acx_lapack_ok = no; then
217 LAPACK_LIBS=""
218 fi
219 fi
220  
221 # LAPACK linked to by default? (is sometimes included in BLAS lib)
222 if test $acx_lapack_ok = no; then
223 save_LIBS="$LIBS"; LIBS="$LIBS $BLAS_LIBS $FLIBS"
224 AC_CHECK_FUNC($cheev, [acx_lapack_ok=yes])
225 LIBS="$save_LIBS"
226 fi
227  
228 # Generic LAPACK library?
229 for lapack in lapack lapack_rs6k; do
230 if test $acx_lapack_ok = no; then
231 save_LIBS="$LIBS"; LIBS="$BLAS_LIBS $LIBS"
232 AC_CHECK_LIB($lapack, $cheev,
233 [acx_lapack_ok=yes; LAPACK_LIBS="-l$lapack"], [], [$FLIBS])
234 LIBS="$save_LIBS"
235 fi
236 done
237  
238 AC_SUBST(LAPACK_LIBS)
239  
240 # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
241 if test x"$acx_lapack_ok" = xyes; then
242 ifelse([$1],,AC_DEFINE(HAVE_LAPACK,1,[Define if you have LAPACK library.]),[$1])
243 :
244 else
245 acx_lapack_ok=no
246 $2
247 fi
248 ])dnl ACX_LAPACK
249 dnl @synopsis MDL_HAVE_OPENGL
250 dnl
251 dnl Search for OpenGL. We search first for Mesa (a GPL'ed version of
252 dnl Mesa) before a vendor's version of OpenGL, unless we were
253 dnl specifically asked not to with `--with-Mesa=no' or
254 dnl `--without-Mesa'.
255 dnl
256 dnl The four "standard" OpenGL libraries are searched for: "-lGL",
257 dnl "-lGLU", "-lGLX" (or "-lMesaGL", "-lMesaGLU" as the case may be)
258 dnl and "-lglut".
259 dnl
260 dnl All of the libraries that are found (since "-lglut" or "-lGLX"
261 dnl might be missing) are added to the shell output variable "GL_LIBS",
262 dnl along with any other libraries that are necessary to successfully
263 dnl link an OpenGL application (e.g. the X11 libraries). Care has been
264 dnl taken to make sure that all of the libraries in "GL_LIBS" are
265 dnl listed in the proper order.
266 dnl
267 dnl Additionally, the shell output variable "GL_CFLAGS" is set to any
268 dnl flags (e.g. "-I" flags) that are necessary to successfully compile
269 dnl an OpenGL application.
270 dnl
271 dnl The following shell variable (which are not output variables) are
272 dnl also set to either "yes" or "no" (depending on which libraries were
273 dnl found) to help you determine exactly what was found.
274 dnl
275 dnl have_GL
276 dnl have_GLU
277 dnl have_GLX
278 dnl have_glut
279 dnl
280 dnl A complete little toy "Automake `make distcheck'" package of how to
281 dnl use this macro is available at:
282 dnl
283 dnl ftp://ftp.slac.stanford.edu/users/langston/autoconf/ac_opengl-0.01.tar.gz
284 dnl
285 dnl Please note that as the ac_opengl macro and the toy example
286 dnl evolves, the version number increases, so you may have to adjust
287 dnl the above URL accordingly.
288 dnl
289 dnl minor bugfix by ahmet inan <auto@ainan.org>
290 dnl
291 dnl @category InstalledPackages
292 dnl @author Matthew D. Langston <langston@SLAC.Stanford.EDU>
293 dnl @version 2002-09-25
294 dnl @license GPLWithACException
295  
296 AC_DEFUN([MDL_HAVE_OPENGL],
297 [
298 AC_REQUIRE([AC_PROG_CC])
299 AC_REQUIRE([AC_PATH_X])
300 AC_REQUIRE([AC_PATH_XTRA])
301  
302 AC_CACHE_CHECK([for OpenGL], mdl_cv_have_OpenGL,
303 [
304 dnl Check for Mesa first, unless we were asked not to.
305 AC_ARG_WITH([--with-Mesa],
306 [Prefer the Mesa library over a vendors native OpenGL library (default=yes)],
307 with_Mesa_help_string)
308 AC_ARG_ENABLE(Mesa, $with_Mesa_help_string, use_Mesa=$enableval, use_Mesa=yes)
309  
310 if test x"$use_Mesa" = xyes; then
311 GL_search_list="MesaGL GL"
312 GLU_search_list="MesaGLU GLU"
313 GLX_search_list="MesaGLX GLX"
314 else
315 GL_search_list="GL MesaGL"
316 GLU_search_list="GLU MesaGLU"
317 GLX_search_list="GLX MesaGLX"
318 fi
319  
320 AC_LANG_SAVE
321 AC_LANG_C
322  
323 dnl If we are running under X11 then add in the appropriate libraries.
324 if test x"$no_x" != xyes; then
325 dnl Add everything we need to compile and link X programs to GL_X_CFLAGS
326 dnl and GL_X_LIBS.
327 GL_CFLAGS="$X_CFLAGS"
328 GL_X_LIBS="$X_PRE_LIBS $X_LIBS -lX11 -lXext -lXmu -lXt -lXi $X_EXTRA_LIBS"
329 fi
330 GL_save_CPPFLAGS="$CPPFLAGS"
331 CPPFLAGS="$GL_CFLAGS"
332  
333 GL_save_LIBS="$LIBS"
334 LIBS="$GL_X_LIBS"
335  
336  
337 # Save the "AC_MSG_RESULT file descriptor" to FD 8.
338 exec 8>&AC_FD_MSG
339  
340 # Temporarily turn off AC_MSG_RESULT so that the user gets pretty
341 # messages.
342 exec AC_FD_MSG>/dev/null
343  
344 AC_SEARCH_LIBS(glAccum, $GL_search_list, have_GL=yes, have_GL=no)
345 AC_SEARCH_LIBS(gluBeginCurve, $GLU_search_list, have_GLU=yes, have_GLU=no)
346 AC_SEARCH_LIBS(glXChooseVisual, $GLX_search_list, have_GLX=yes, have_GLX=no)
347 AC_SEARCH_LIBS(glutInit, glut, have_glut=yes, have_glut=no)
348  
349  
350  
351 # Restore pretty messages.
352 exec AC_FD_MSG>&8
353  
354 if test -n "$LIBS"; then
355 mdl_cv_have_OpenGL=yes
356 GL_LIBS="$LIBS"
357 AC_SUBST(GL_CFLAGS)
358 AC_SUBST(GL_LIBS)
359 else
360 mdl_cv_have_OpenGL=no
361 GL_CFLAGS=
362 fi
363  
364 dnl Reset GL_X_LIBS regardless, since it was just a temporary variable
365 dnl and we don't want to be global namespace polluters.
366 GL_X_LIBS=
367  
368 LIBS="$GL_save_LIBS"
369 CPPFLAGS="$GL_save_CPPFLAGS"
370  
371 AC_LANG_RESTORE
372  
373 dnl bugfix: dont forget to cache this variables, too
374 mdl_cv_GL_CFLAGS="$GL_CFLAGS"
375 mdl_cv_GL_LIBS="$GL_LIBS"
376 mdl_cv_have_GL="$have_GL"
377 mdl_cv_have_GLU="$have_GLU"
378 mdl_cv_have_GLX="$have_GLX"
379 mdl_cv_have_glut="$have_glut"
380 ])
381 GL_CFLAGS="$mdl_cv_GL_CFLAGS"
382 GL_LIBS="$mdl_cv_GL_LIBS"
383 have_GL="$mdl_cv_have_GL"
384 have_GLU="$mdl_cv_have_GLU"
385 have_GLX="$mdl_cv_have_GLX"
386 have_glut="$mdl_cv_have_glut"
387 ])
388 dnl endof bugfix -ainan