1## This file is part of the GLTT library 2## Copyright (C) 1998-1999 Stephane Rehel 3 4## Portions grabbed from the KDE project: 5## Copyright (C) 1997 Janos Farkas (chexum@shadow.banki.hu) 6## (C) 1997 Stephan Kulow (coolo@kde.org) 7 8## This program is free software; you can redistribute it and/or modify 9## it under the terms of the GNU General Public License as published by 10## the Free Software Foundation; either version 2 of the License, or 11## (at your option) any later version. 12## 13## This program is distributed in the hope that it will be useful, 14## but WITHOUT ANY WARRANTY; without even the implied warranty of 15## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16## GNU General Public License for more details. 17## 18## You should have received a copy of the GNU General Public License 19## along with this program; if not, write to the Free Software 20## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21## 22 23 24# CHECK FOR COMPILERS 25 26AC_DEFUN(AC_CHECK_COMPILERS, 27[ 28 AC_ARG_ENABLE(debug,[ --enable-debug creates debugging code [default=no]], 29 [ 30 if test $enableval = "no"; dnl 31 then ac_use_debug_code="no" 32 else ac_use_debug_code="yes" 33 fi 34 ], [ac_use_debug_code="no"]) 35 36dnl this was AC_PROG_CC. I had to include it manualy, since I had to patch it 37 AC_MSG_CHECKING(for a C-Compiler) 38 dnl if there is one, print out. if not, don't matter 39 AC_MSG_RESULT($CC) 40 41 if test -z "$CC"; then AC_CHECK_PROG(CC, gcc, gcc) fi 42 if test -z "$CC"; then AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc) fi 43 if test -z "$CC"; then AC_CHECK_PROG(CC, xlc, xlc) fi 44 test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH]) 45 AC_PROVIDE([AC_PROG_CC]) 46 47 AC_PROG_CC_WORKS 48 AC_PROG_CC_GNU 49 50 if test $ac_cv_prog_gcc = yes; then 51 have_GCC=yes 52 else 53 have_GCC= 54 fi 55 56 if test -z "$CFLAGS"; then 57 if test "$ac_use_debug_code" = "yes"; then 58 AC_PROG_CC_G 59 if test $ac_cv_prog_cc_g = yes; then 60 CFLAGS="-g" 61 fi 62 else 63 if test "$have_GCC" = "yes"; then 64 CFLAGS="-O2 -g" 65 else 66 CFLAGS="" 67 fi 68 fi 69 70 if test "$have_GCC" = "yes"; then 71 CFLAGS="$CFLAGS -Wall" 72 fi 73 74 fi 75 76 if test -z "$LDFLAGS" && test "$ac_use_debug_code" = "no" && test "$have_GCC" = "yes"; then 77 LDFLAGS="" 78 fi 79 80 81dnl this is AC_PROG_CPP. I had to include it here, since autoconf checks 82dnl dependecies between AC_PROG_CPP and AC_PROG_CC (or is it automake?) 83 84 AC_MSG_CHECKING(how to run the C preprocessor) 85 # On Suns, sometimes $CPP names a directory. 86 if test -n "$CPP" && test -d "$CPP"; then 87 CPP= 88 fi 89 if test -z "$CPP"; then 90 AC_CACHE_VAL(ac_cv_prog_CPP, 91 [ # This must be in double quotes, not single quotes, because CPP may get 92 # substituted into the Makefile and "${CC-cc}" will confuse make. 93 CPP="${CC-cc} -E" 94 # On the NeXT, cc -E runs the code through the compiler's parser, 95 # not just through cpp. 96 dnl Use a header file that comes with gcc, so configuring glibc 97 dnl with a fresh cross-compiler works. 98 AC_TRY_CPP([#include <assert.h> 99 Syntax Error], , 100 CPP="${CC-cc} -E -traditional-cpp" 101 AC_TRY_CPP([#include <assert.h> 102 Syntax Error], , CPP=/lib/cpp)) 103 ac_cv_prog_CPP="$CPP"])dnl 104 CPP="$ac_cv_prog_CPP" 105 else 106 ac_cv_prog_CPP="$CPP" 107 fi 108 AC_MSG_RESULT($CPP) 109 AC_PROVIDE([AC_PROG_CPP]) 110 AC_SUBST(CPP)dnl 111 112 113 AC_MSG_CHECKING(for a C++-Compiler) 114 dnl if there is one, print out. if not, don't matter 115 AC_MSG_RESULT($CXX) 116 117 if test -z "$CXX"; then AC_CHECK_PROG(CXX, g++, g++) fi 118 if test -z "$CXX"; then AC_CHECK_PROG(CXX, CC, CC) fi 119 if test -z "$CXX"; then AC_CHECK_PROG(CXX, xlC, xlC) fi 120 if test -z "$CXX"; then AC_CHECK_PROG(CXX, DCC, DCC) fi 121 test -z "$CXX" && AC_MSG_ERROR([no acceptable C++-compiler found in \$PATH]) 122 123 AC_PROG_CXX_WORKS 124 AC_PROG_CXX_GNU 125 126 if test $ac_cv_prog_gxx = yes; then 127 have_GXX=yes 128 else 129 AC_MSG_CHECKING(whether we are using SPARC CC) 130 have_GXX= 131 cat > conftest.C << EOF 132#ifdef __SUNPRO_CC 133 yes; 134#endif 135EOF 136 137 ac_try="$CXX -E conftest.C" 138 if { (eval echo configure:__online__: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } | egrep yes >/dev/null 2>&1; then 139 ok_ac_cv_prog_CC=yes 140 else 141 ok_ac_cv_prog_CC=no 142 fi 143 AC_MSG_RESULT($ok_ac_cv_prog_CC) 144 fi 145 146 if test -z "$CXXFLAGS"; then 147 if test "$ac_use_debug_code" = "yes"; then 148 AC_PROG_CXX_G 149 if test $ac_cv_prog_cxx_g = yes; then 150 CXXFLAGS="-g" 151 fi 152 if test "$ok_ac_cv_prog_CC" = "yes"; then 153 CXXFLAGS="$CXXFLAGS -pto" 154 fi 155 else 156 if test "$have_GXX" = "yes"; then 157 CXXFLAGS="-O2 -g" 158 else 159 if test "$ok_ac_cv_prog_CC" = "yes"; then 160 CXXFLAGS="-pto -O2" 161 else 162 CXXFLAGS="" 163 fi 164 fi 165 fi 166 167 if test "$have_GXX" = "yes"; then 168 CXXFLAGS="$CXXFLAGS -Wall" 169 fi 170 fi 171 172]) 173 174 175## ------------------------------------------------------------------------ 176## Find a file (or one of more files in a list of dirs) 177## ------------------------------------------------------------------------ 178## 179AC_DEFUN(AC_FIND_FILE, 180[ 181$3=NO 182for i in $2; 183do 184 for j in $1; 185 do 186 if test -r "$i/$j"; then 187 $3=$i 188 break 2 189 fi 190 done 191done 192]) 193 194## ------------------------------------------------------------------------ 195## Find the header files and libraries for X-Windows. Extended the 196## macro AC_PATH_X 197## ------------------------------------------------------------------------ 198## 199AC_DEFUN(GLTT_PATH_X, 200[ 201AC_MSG_CHECKING(for X) 202AC_CACHE_VAL(ac_cv_have_x, 203[# One or both of the vars are not set, and there is no cached value. 204ac_x_includes=NO ac_x_libraries=NO 205dnl Seems these subfunctions or whatever are unavailable 206dnl AC_PATH_X_DIRECT 207dnl AC_PATH_X_XMKMF 208AC_PATH_X 209if test "$ac_x_includes" = NO || test "$ac_x_libraries" = NO; then 210 AC_MSG_ERROR([Can't find X includes. Please check your installation and add the correct paths!]) 211else 212 # Record where we found X for the cache. 213 ac_cv_have_x="have_x=yes \ 214 ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries" 215fi])dnl 216eval "$ac_cv_have_x" 217 218if test "$have_x" != yes; then 219 AC_MSG_RESULT($have_x) 220 no_x=yes 221else 222 # If each of the values was on the command line, it overrides each guess. 223 test "x$x_includes" = xNONE && x_includes=$ac_x_includes 224 test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries 225 226 # don't set -I/usr/X11R6/include please. It's boring. /S.Rehel 227 # IRIX test doesn't support -ef ! Aaah GNU ... Aah linux! 228 # 229 if test ! -z "$x_includes" ; then 230 xdir1=`cd $x_includes/X11 && /bin/pwd` 231 xdir2=`cd /usr/include/X11 && /bin/pwd` 232 if test "$xdir1" = "$xdir2" ; then 233 x_includes=/usr/include 234 fi 235 fi 236 237 # Update the cache value to reflect the command line values. 238 ac_cv_have_x="have_x=yes \ 239 ac_x_includes=$x_includes ac_x_libraries=$x_libraries" 240 AC_MSG_RESULT([libraries $x_libraries, headers $x_includes]) 241 242# CPPFLAGS="$CPPFLAGS -L$x_libraries" 243fi 244 245if test -z "$x_includes" || \ 246 test "$x_includes" = "/usr/include" || \ 247 test "x$x_includes" = xNONE; then 248 X_INCLUDES="" 249 x_includes="."; dnl better than nothing :- 250 else 251 X_INCLUDES="-I$x_includes" 252fi 253 254if test -z "$x_libraries" || test "$x_libraries" = xNONE; then 255 X_LDFLAGS="" 256# It does bad things under IRIX 6.4 /SR Mar.12.1999 257# x_libraries="/usr/lib"; dnl better than nothing :- 258 all_libraries="" 259 else 260 X_LDFLAGS="-L$x_libraries" 261 all_libraries=$X_LDFLAGS 262fi 263 264AC_SUBST(X_INCLUDES) 265AC_SUBST(X_LDFLAGS) 266all_includes=$X_INCLUDES 267]) 268 269 270## ------------------------------------------------------------------------ 271## Try to find the TTF headers and libraries. 272## $(TTF_LDFLAGS) will be -Lttfliblocation (if needed) 273## and $(TTF_INCLUDES) will be -Ittfhdrlocation (if needed) 274## ------------------------------------------------------------------------ 275## 276AC_DEFUN(AC_PATH_TTF, 277[ 278AC_MSG_CHECKING([for FreeType]) 279ac_ttf_includes=NO ac_ttf_libraries=NO 280ttf_libraries="" 281ttf_includes="" 282AC_ARG_WITH(ttf-dir, 283 [ --with-ttf-dir where the root of freetype is installed ], 284 [ ac_ttf_includes="$withval"/include 285 ac_ttf_libraries="$withval"/lib 286 ]) 287 288AC_ARG_WITH(ttf-includes, 289 [ --with-ttf-includes where the freetype includes are. ], 290 [ 291 ac_ttf_includes="$withval" 292 ]) 293 294AC_ARG_WITH(ttf-libraries, 295 [ --with-ttf-libraries where the freetype library is installed.], 296 [ ac_ttf_libraries="$withval" 297 ]) 298 299if test "$ac_ttf_includes" = NO || test "$ac_ttf_libraries" = NO; then 300 301AC_CACHE_VAL(ac_cv_have_ttf, 302[#try to guess ttf locations 303 304ttf_incdirs="$ac_ttf_includes /usr/lib/freetype/include /usr/local/freetype/include /usr/include/freetype /usr/include/freetype1 /usr/include/freetype2 /usr/include /usr/local/include /usr/local/ttf $TTF_INC" 305test -n "$TTFDIR" && ttf_incdirs="$TTFDIR/include $TTFDIR $ttf_incdirs" 306AC_FIND_FILE(freetype/freetype.h, $ttf_incdirs, ttf_incdir) 307ac_ttf_includes=$ttf_incdir 308 309ttf_libdirs="$ac_ttf_libraries /usr/lib/freetype/lib /usr/local/freetype/lib /usr/lib/freetype /usr/lib /usr/local/lib /usr/local/ttf/lib $TTFLIB" 310test -n "$TTFDIR" && ttf_libdirs="$TTFDIR/lib $TTFDIR $ttf_libdirs" 311AC_FIND_FILE(libttf.so libttf.so.1.0.0 libttt.so.1 libttf.a libttf.sl, $ttf_libdirs, ttf_libdir) 312ac_ttf_libraries=$ttf_libdir 313 314ac_cxxflags_safe=$CXXFLAGS 315ac_ldflags_safe=$LDFLAGS 316ac_libs_safe=$LIBS 317 318CXXFLAGS="$CXXFLAGS -I$ttf_incdir" 319LDFLAGS="-L$ttf_libdir" 320LIBS="$LIBS -lttf" 321 322AC_LANG_CPLUSPLUS 323cat > conftest.$ac_ext <<EOF 324#include "confdefs.h" 325#include "freetype/freetype.h" 326int main() { 327 TT_Engine engine; 328 TT_Init_FreeType(&engine); 329 return 0; 330} 331EOF 332 333if AC_TRY_EVAL(ac_link) && test -s conftest; then 334 rm -f conftest* 335else 336 echo "configure: failed program was:" >&AC_FD_CC 337 cat conftest.$ac_ext >&AC_FD_CC 338 ac_ttf_libraries="NO" 339fi 340rm -f conftest* 341CXXFLAGS=$ac_cxxflags_safe 342LDFLAGS=$ac_ldflags_safe 343LIBS=$ac_libs_safe 344 345# Don't give up just yet. Try freetype-config. 346freetype_config_cflags="`freetype-config --cflags`" 347freetype_config_libs="`freetype-config --libs`" 348 349CXXFLAGS="$CXXFLAGS $freetype_config_cflags" 350LIBS="$LIBS $freetype_config_libs" 351 352AC_LANG_CPLUSPLUS 353cat > conftest.$ac_ext <<EOF 354#include "confdefs.h" 355#include "freetype/freetype.h" 356int main() { 357 TT_Engine engine; 358 TT_Init_FreeType(&engine); 359 return 0; 360} 361EOF 362 363if AC_TRY_EVAL(ac_link) && test -s conftest; then 364 rm -f conftest* 365else 366 echo "configure: failed program was:" >&AC_FD_CC 367 cat conftest.$ac_ext >&AC_FD_CC 368 freetype_config_works="NO" 369fi 370rm -f conftest* 371CXXFLAGS=$ac_cxxflags_safe 372LDFLAGS=$ac_ldflags_safe 373LIBS=$ac_libs_safe 374 375if test "$freetype_config_works" = NO; then 376 if test "$ac_ttf_includes" = NO || test "$ac_ttf_libraries" = NO; then 377 ac_cv_have_ttf="have_ttf=no" 378 ac_ttf_notfound="" 379 if test "$ac_ttf_includes" = NO; then 380 if test "$ac_ttf_libraries" = NO; then 381 ac_ttf_notfound="(headers and libraries)"; 382 else 383 ac_ttf_notfound="(headers)"; 384 fi 385 else 386 ac_ttf_notfound="(libraries)"; 387 fi 388 389 AC_MSG_ERROR([FreeType $ac_ttf_notfound not found. Please check your installation! ]); 390 else 391 have_ttf="yes" 392 fi 393else 394 have_ttf="yes" 395fi 396]) 397else 398 have_ttf="yes" 399fi 400 401eval "$ac_cv_have_ttf" 402 403if test "$have_ttf" != yes; then 404 AC_MSG_RESULT([$have_ttf]); 405else 406 ac_cv_have_ttf="have_ttf=yes \ 407 ac_ttf_includes=$ac_ttf_includes ac_ttf_libraries=$ac_ttf_libraries" 408 AC_MSG_RESULT([libraries $ac_ttf_libraries, headers $ac_ttf_includes]) 409 410 ttf_libraries=$ac_ttf_libraries 411 ttf_includes=$ac_ttf_includes 412fi 413 414AC_SUBST(ttf_libraries) 415AC_SUBST(ttf_includes) 416 417if test "$ttf_includes" = "$x_includes" || \ 418 test "$ttf_includes" = "/usr/include" || \ 419 test -z "$ttf_includes"; then 420 TTF_INCLUDES=""; 421else 422 TTF_INCLUDES="-I$ttf_includes" 423 all_includes="$TTF_INCLUDES $all_includes" 424fi 425 426if test "$ttf_libraries" = "$x_libraries" || \ 427 test "$ttf_libraries" = "/usr/lib" || \ 428 test "$ttf_libraries" = "/usr/local/lib" || \ 429 test -z "$ttf_libraries"; then 430 TTF_LDFLAGS="" 431else 432 TTF_LDFLAGS="-L$ttf_libraries" 433 all_libraries="$TTF_LDFLAGS $all_libraries" 434fi 435 436if test "$freetype_config_works" != NO; then 437 TTF_INCLUDES="$TTF_INCLUDES $freetype_config_cflags" 438 TTF_LDFLAGS="$TTF_LDFLAGS $freetype_config_ldflags" 439fi 440 441AC_SUBST(TTF_INCLUDES) 442AC_SUBST(TTF_LDFLAGS) 443]) 444 445## ------------------------------------------------------------------------ 446## Try to find the GLUT headers and libraries. 447## $(GLUT_LDFLAGS) will be -Lglutliblocation (if needed) 448## and $(GLUT_INCLUDES) will be -Igluthdrlocation (if needed) 449## ------------------------------------------------------------------------ 450## 451AC_DEFUN(AC_PATH_GLUT, 452[ 453AC_MSG_CHECKING([for glut]) 454ac_glut_includes=NO ac_glut_libraries=NO 455glut_libraries="" 456glut_includes="" 457AC_ARG_WITH(glut-dir, 458 [ --with-glut-dir where the root of glut is installed ], 459 [ ac_glut_includes="$withval"/include 460 ac_glut_libraries="$withval"/lib/glut 461 ]) 462 463AC_ARG_WITH(glut-includes, 464 [ --with-glut-includes where the glut includes are. ], 465 [ 466 ac_glut_includes="$withval" 467 ]) 468 469AC_ARG_WITH(glut-libraries, 470 [ --with-glut-libraries where the glut library is installed.], 471 [ 472 ac_glut_libraries="$withval" 473 ]) 474 475if test "$ac_glut_includes" = NO || test "$ac_glut_libraries" = NO; then 476 477AC_CACHE_VAL(ac_cv_have_glut, 478[#try to guess glut locations 479 480GLTT_MAKE_TARGET=lib_and_demos 481 482glut_incdirs="$ac_glut_includes /usr/include /usr/local/include /usr/glut/include /usr/local/glut/include $HOME/glut/include $HOME/Mesa/include $GLUT_INC $gl_includes" 483test -n "$GLUTDIR" && glut_incdirs="$GLUTDIR/include $GLUTDIR $glut_incdirs" 484AC_FIND_FILE(GL/glut.h, $glut_incdirs, glut_incdir) 485ac_glut_includes=$glut_incdir 486 487glut_libdirs="$ac_glut_libraries /usr/lib /usr/local/lib /usr/glut/lib/glut /usr/local/glut/lib/glut $HOME/glut/lib/glut $HOME/Mesa/lib $GLUTLIB $gl_libraries" 488test -n "$GLUTDIR" && glut_libdirs="$GLUTDIR/lib/glut $GLUTDIR $glut_libdirs" 489AC_FIND_FILE(libglut.so libglut.so.3.6 libglut.so.3 libglut.a libglut.sl, $glut_libdirs, glut_libdir) 490ac_glut_libraries=$glut_libdir 491 492ac_cxxflags_safe=$CXXFLAGS 493ac_ldflags_safe=$LDFLAGS 494ac_libs_safe=$LIBS 495 496CXXFLAGS="$CXXFLAGS -I$glut_incdir -I$gl_includes" 497LDFLAGS="-L$glut_libdir" 498LIBS="-lglut -L$gl_libraries -l${GL_LIBNAME}GL -l${GL_LIBNAME}GLU $LIBSOCKET $LIBS" 499 500AC_LANG_CPLUSPLUS 501cat > conftest.$ac_ext <<EOF 502#include "confdefs.h" 503#include "GL/glut.h" 504int main( int argc, char** argv ) { 505 glutInit(&argc, argv); 506 return 0; 507} 508EOF 509 510if AC_TRY_EVAL(ac_link) && test -s conftest; then 511 rm -f conftest* 512else 513 echo "configure: failed program was:" >&AC_FD_CC 514 cat conftest.$ac_ext >&AC_FD_CC 515 ac_glut_libraries="NO" 516fi 517rm -f conftest* 518CXXFLAGS=$ac_cxxflags_safe 519LDFLAGS=$ac_ldflags_safe 520LIBS=$ac_libs_safe 521 522if test "$ac_glut_includes" = NO || test "$ac_glut_libraries" = NO; then 523 ac_cv_have_glut="have_glut=no" 524 ac_glut_notfound="" 525 if test "$ac_glut_includes" = NO; then 526 if test "$ac_glut_libraries" = NO; then 527 ac_glut_notfound="(headers and libraries)"; 528 else 529 ac_glut_notfound="(headers)"; 530 fi 531 else 532 ac_glut_notfound="(libraries)"; 533 fi 534 535 AC_MSG_WARN([glut $ac_glut_notfound not found. Demos won't be built! ]); 536 GLTT_MAKE_TARGET=lib_only 537else 538 have_glut="yes" 539fi 540ac_make_target=$GLTT_MAKE_TARGET 541]) 542else 543 have_glut="yes" 544fi 545 546eval "$ac_cv_have_glut" 547 548if test "$have_glut" != yes; then 549 AC_MSG_RESULT([$have_glut]); 550else 551 ac_cv_have_glut="have_glut=yes \ 552 ac_glut_includes=$ac_glut_includes ac_glut_libraries=$ac_glut_libraries ac_make_target=$GLTT_MAKE_TARGET" 553 AC_MSG_RESULT([libraries $ac_glut_libraries, headers $ac_glut_includes]) 554 555 glut_libraries=$ac_glut_libraries 556 glut_includes=$ac_glut_includes 557 GLTT_MAKE_TARGET=$ac_make_target 558fi 559 560AC_SUBST(glut_libraries) 561AC_SUBST(glut_includes) 562 563if test "$glut_includes" = "$x_includes" || \ 564 test "$glut_includes" = "/usr/include" || \ 565 test -z "$glut_includes"; then 566 GLUT_INCLUDES=""; 567else 568 GLUT_INCLUDES="-I$glut_includes" 569 all_includes="$GLUT_INCLUDES $all_includes" 570fi 571 572if test "$glut_libraries" = "$x_libraries" || \ 573 test "$glut_libraries" = "/usr/lib" || \ 574 test "$glut_libraries" = "/usr/local/lib" || \ 575 test -z "$glut_libraries"; then 576 GLUT_LDFLAGS="" 577else 578 GLUT_LDFLAGS="-L$glut_libraries" 579 all_libraries="$GLUT_LDFLAGS $all_libraries" 580fi 581 582AC_SUBST(GLUT_INCLUDES) 583AC_SUBST(GLUT_LDFLAGS) 584AC_SUBST(GLTT_MAKE_TARGET) 585]) 586 587## ------------------------------------------------------------------------ 588## Try to find the GL/MesaGL headers and libraries. 589## Try to find the GLU/MesaGLU headers and libraries. 590## ------------------------------------------------------------------------ 591 592AC_DEFUN(AC_HAVE_GL, 593[ 594AC_MSG_CHECKING([for GL]) 595ac_gl_includes=NO 596ac_gl_libraries=NO 597gl_libraries="" 598gl_includes="" 599AC_ARG_WITH(gl-dir, 600 [ --with-gl-dir where the root of OpenGL is installed ], 601 [ ac_gl_includes="$withval"/include 602 ac_gl_libraries="$withval"/lib 603 ]) 604 605AC_ARG_WITH(gl-includes, 606 [ --with-gl-includes where the OpenGL includes are. ], 607 [ 608 ac_gl_includes="$withval" 609 ]) 610 611AC_ARG_WITH(gl-libraries, 612 [ --with-gl-libraries where the OpenGL library is installed.], 613 [ ac_gl_libraries="$withval" 614 ]) 615 616if test "$ac_gl_includes" = NO || test "$ac_gl_libraries" = NO; then 617 618AC_CACHE_VAL(ac_cv_have_gl, 619[#try to guess gl locations 620 621gl_incdirs="$ac_gl_includes \ 622 /usr/include \ 623 /usr/X11R6/include \ 624 /usr/local/include \ 625 /usr/local/Mesa/include \ 626 $HOME/Mesa/include \ 627 $GL_INC" 628test -n "$GLDIR" && gl_incdirs="$GLDIR/include $GLDIR $gl_incdirs" 629AC_FIND_FILE(GL/gl.h, $gl_incdirs, gl_incdir) 630ac_gl_includes=$gl_incdir 631 632gl_libdirs="$ac_gl_libraries \ 633 /usr/lib \ 634 /usr/X11R6/lib \ 635 /usr/local/lib \ 636 /usr/local/Mesa/lib \ 637 $HOME/Mesa/lib \ 638 $GLLIB" 639test -n "$GLDIR" && gl_libdirs="$GLDIR/lib $GLDIR $gl_libdirs" 640 641GL_LIBNAME="" 642AC_FIND_FILE(libGL.so libGL.a, $gl_libdirs, gl_libdir) 643if test "$gl_libdir" = NO ; then 644 AC_FIND_FILE(libMesaGL.so libMesaGL.a, $gl_libdirs, gl_libdir) 645 ac_gl_libraries=$gl_libdir 646 GL_LIBNAME="Mesa" 647else 648 ac_gl_libraries=$gl_libdir 649 GL_LIBNAME="" 650fi 651 652AC_FIND_FILE(libGL.so libMesaGL.so libGL.a libMesaGL.a, $gl_libdirs, gl_libdir) 653ac_gl_libraries=$gl_libdir 654 655ac_cxxflags_safe=$CXXFLAGS 656ac_ldflags_safe=$LDFLAGS 657ac_libs_safe=$LIBS 658 659CXXFLAGS="$CXXFLAGS -I$gl_incdir" 660LDFLAGS="-L$gl_libdir" 661LIBS="-lGL $X_LDFLAGS $LIBS" 662 663AC_LANG_CPLUSPLUS 664cat > conftest.$ac_ext <<EOF 665#include "confdefs.h" 666#include "GL/gl.h" 667int main() { 668 glEnd(); 669 return 0; 670} 671EOF 672 673if AC_TRY_EVAL(ac_link) && test -s conftest; then 674 rm -f conftest* 675else 676 rm -f conftest* 677 LIBS="$ac_libs_safe -lMesaGL $X_LDFLAGS -lX11 -lXext -lm" 678 679cat > conftest.$ac_ext <<EOF 680#include "confdefs.h" 681#include "GL/gl.h" 682int main() { 683 glEnd(); 684 return 0; 685} 686EOF 687 688 if AC_TRY_EVAL(ac_link) && test -s conftest; then 689 rm -f conftest* 690 else 691 echo "configure: failed program was:" >&AC_FD_CC 692 cat conftest.$ac_ext >&AC_FD_CC 693 ac_gl_libraries="NO" 694 fi 695fi 696 697rm -f conftest* 698CXXFLAGS=$ac_cxxflags_safe 699LDFLAGS=$ac_ldflags_safe 700LIBS=$ac_libs_safe 701 702if test "$ac_gl_includes" = NO || test "$ac_gl_libraries" = NO; then 703 ac_cv_have_gl="have_gl=no" 704 ac_gl_notfound="" 705 if test "$ac_gl_includes" = NO; then 706 if test "$ac_gl_libraries" = NO; then 707 ac_gl_notfound="(headers and libraries)"; 708 else 709 ac_gl_notfound="(headers)"; 710 fi 711 else 712 ac_gl_notfound="(libraries)"; 713 fi 714 715 AC_MSG_ERROR([OpenGL $ac_gl_notfound not found. Please check your installation! ]); 716else 717 have_gl="yes" 718fi 719]) 720else 721 have_gl="yes" 722fi 723 724eval "$ac_cv_have_gl" 725 726if test "$have_gl" != yes; then 727 AC_MSG_RESULT([$have_gl]); 728else 729 ac_cv_have_gl="have_gl=yes \ 730 ac_gl_includes=$ac_gl_includes ac_gl_libraries=$ac_gl_libraries" 731 AC_MSG_RESULT([libraries $ac_gl_libraries/lib${GL_LIBNAME}GL*, headers $ac_gl_includes/GL]) 732 733 gl_libraries=$ac_gl_libraries 734 gl_includes=$ac_gl_includes 735fi 736 737AC_SUBST(gl_libraries) 738AC_SUBST(gl_includes) 739 740if test "$gl_includes" = "$x_includes" || \ 741 test "$gl_includes" = "/usr/include" || \ 742 test -z "$gl_includes"; then 743 GL_INCLUDES=""; 744else 745 GL_INCLUDES="-I$gl_includes" 746 all_includes="$GL_INCLUDES $all_includes" 747fi 748 749if test "$gl_libraries" = "$x_libraries" || \ 750 test "$gl_libraries" = "/usr/lib" || \ 751 test "$gl_libraries" = "/usr/local/lib" || \ 752 test -z "$gl_libraries"; then 753 GL_LDFLAGS="" 754else 755 GL_LDFLAGS="-L$gl_libraries" 756 all_libraries="$GL_LDFLAGS $all_libraries" 757fi 758 759AC_SUBST(GL_INCLUDES) 760AC_SUBST(GL_LDFLAGS) 761AC_SUBST(GL_LIBNAME) 762]) 763 764## ------------------------------------------------------------------------ 765## Check for libtool 766## ------------------------------------------------------------------------ 767## 768dnl just a wrapper to clean up configure.in 769AC_DEFUN(GLTT_PROG_LIBTOOL, 770[ 771dnl libtool is only for C, so I must force him 772dnl to find the correct flags for C++ 773 774ac_save_cc=$CC 775ac_save_cflags=$CFLAGS 776CC=$CXX 777CFLAGS=$CXXFLAGS 778AM_PROG_LIBTOOL dnl for libraries 779CC=$ac_save_cc 780CFLAGS=$ac_save_cflags 781]) 782