File: configure.in

package info (click to toggle)
lightlab 0.3-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 620 kB
  • ctags: 246
  • sloc: sh: 2,554; ansic: 1,843; makefile: 163
file content (810 lines) | stat: -rw-r--r-- 23,317 bytes parent folder | download
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
# configure.in --- lightlab, Copyright (c) 2002 Jamie Zawinski.
#

AC_PREREQ(2.53)
AC_INIT(lightlab.c)
AC_CONFIG_HEADER(config.h)

echo "current directory: `pwd`"
echo "command line was: $0 $@"


###############################################################################
#
#       Function to figure out how to run the compiler.
#
###############################################################################

AC_DEFUN(AC_PROG_CC_ANSI,
 [AC_PROG_CC

  if test -z "$GCC"; then
    AC_MSG_CHECKING(how to request ANSI compilation)
    case "$host" in
      *-hpux* )
        AC_MSG_RESULT(HPUX: adding -Ae)
        CC="$CC -Ae"
      ;;
      *-aix* )
        AC_MSG_RESULT(AIX: adding -qlanglvl=ansi -qhalt=e)
        CC="$CC -qlanglvl=ansi -qhalt=e"
      ;;

      *-dec-* )
        AC_MSG_RESULT(DEC: adding -std1 -ieee)
        CC="$CC -std1"
      ;;

      *)
        AC_MSG_RESULT(no idea)
      ;;
    esac
  fi

  AC_MSG_CHECKING([whether the compiler works on ANSI C])
  AC_TRY_RUN([ main(int ac, char **av) { return 0; } ],
     AC_MSG_RESULT(yes),
     AC_MSG_RESULT(no)
     AC_MSG_ERROR(Couldn't build even a trivial ANSI C program: check CC.),
     AC_MSG_ERROR(Couldn't build even a trivial ANSI C program: check CC.))

  if test -n "$GCC"; then
    AC_MSG_RESULT(Turning on gcc compiler warnings.)
#    CC="$CC -Wall -Wstrict-prototypes -Wnested-externs -Wno-format"
    CC="$CC -Wall -Wnested-externs -Wno-format"
  else
    case "$host" in
      *-irix5* |*-irix6.[0-3]* )
        AC_MSG_RESULT(Turning on SGI compiler warnings.)
        CC="$CC -fullwarn -use_readonly_const -rdata_shared -g3"
      ;;
#     *-dec-osf* )
#       if test -z "$GCC"; then
#         AC_MSG_RESULT(Turning on DEC C compiler warnings.)
#         CC="$CC -migrate -w0 -verbose -warnprotos"
#       fi
#     ;;
    esac
  fi
])


###############################################################################
#
#       Functions to figure out how to disable // comments in ANSI C code.
#
#       (With recent gcc, this is done with "-std=c89".  With older gcc, this
#       is done by passing "-lang-c89" to cpp, by passing "-Wp,-lang-c89" to
#       gcc.  Old gcc doesn't support -std, and new gcc doesn't support -lang.
#       so much for compatibility!)
#
###############################################################################

AC_DEFUN(AC_GCC_ACCEPTS_STD,
 [if test -n "$GCC"; then
   AC_CACHE_CHECK([whether gcc accepts -std],
     ac_cv_gcc_accepts_std,
    [if ( gcc -E -std=c89 - </dev/null >/dev/null 2>&1 | \
          grep unrecognized >/dev/null ); then
       ac_cv_gcc_accepts_std=no
     else
       ac_cv_gcc_accepts_std=yes
     fi])
   ac_gcc_accepts_std="$ac_cv_gcc_accepts_std"
  fi
])

AC_DEFUN(AC_NO_CPLUSPLUS_COMMENTS_IN_C_CODE,
 [if test -n "$GCC"; then
   AC_GCC_ACCEPTS_STD
   AC_MSG_RESULT(Disabling C++ comments in ANSI C code.)
   #
   # The reason that // comments are banned from xscreensaver is that gcc is
   # basically the only compiler in the world that supports them in C code.
   # All other vendors support them only in their C++ compilers, not in their
   # ANSI C compilers.  This means that it's a portability problem: every time
   # these comments have snuck into the xscreensaver source code, I've gotten
   # complaints about it the next day.  So we turn off support for them in gcc
   # as well to prevent them from accidentially slipping in.
   #
   if test "$ac_gcc_accepts_std" = yes ; then
     #
     # -std=c89 defines __STRICT_ANSI__, which we don't want.
     # (That appears to be the only additional preprocessor symbol
     # it defines, in addition to the syntax changes it makes.)
     #
     # -std=gnu89 is no good, because // comments were a GNU extension
     # before they were in the ANSI C 99 spec...  (gcc 2.96 permits //
     # with -std=gnu89 but not with -std=c89.)
     #
     CC="$CC -std=c89 -U__STRICT_ANSI__"
   else
     # The old way:
     CC="$CC -Wp,-lang-c89"
   fi
  fi
])


###############################################################################
#
#       Some utility functions to make checking for X things easier.
#
###############################################################################

# Like AC_CHECK_HEADER, but it uses the already-computed -I directories.
#
AC_DEFUN(AC_CHECK_X_HEADER, [
  ac_save_CPPFLAGS="$CPPFLAGS"
  if test \! -z "$includedir" ; then 
    CPPFLAGS="$CPPFLAGS -I$includedir"
  fi
  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
  AC_CHECK_HEADER([$1],[$2],[$3],[$4])
  CPPFLAGS="$ac_save_CPPFLAGS"])

# Like AC_EGREP_HEADER, but it uses the already-computed -I directories.
#
AC_DEFUN(AC_EGREP_X_HEADER, [
  ac_save_CPPFLAGS="$CPPFLAGS"
  if test \! -z "$includedir" ; then 
    CPPFLAGS="$CPPFLAGS -I$includedir"
  fi
  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
  AC_EGREP_HEADER([$1], [$2], [$3], [$4])
  CPPFLAGS="$ac_save_CPPFLAGS"])

# Like AC_TRY_COMPILE, but it uses the already-computed -I directories.
#
AC_DEFUN(AC_TRY_X_COMPILE, [
  ac_save_CPPFLAGS="$CPPFLAGS"
  if test \! -z "$includedir" ; then 
    CPPFLAGS="$CPPFLAGS -I$includedir"
  fi
  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
  AC_TRY_COMPILE([$1], [$2], [$3], [$4])
  CPPFLAGS="$ac_save_CPPFLAGS"])


# Like AC_CHECK_LIB, but it uses the already-computed -I and -L directories.
# Use this sparingly; it probably doesn't work very well on X programs.
#
AC_DEFUN(AC_CHECK_X_LIB, [
  ac_save_CPPFLAGS="$CPPFLAGS"
  ac_save_LDFLAGS="$LDFLAGS"
#  ac_save_LIBS="$LIBS"

  if test \! -z "$includedir" ; then 
    CPPFLAGS="$CPPFLAGS -I$includedir"
  fi
  # note: $X_CFLAGS includes $x_includes
  CPPFLAGS="$CPPFLAGS $X_CFLAGS"

  if test \! -z "$libdir" ; then
    LDFLAGS="$LDFLAGS -L$libdir"
  fi
  # note: $X_LIBS includes $x_libraries
  LDFLAGS="$LDFLAGS $X_LIBS $X_EXTRA_LIBS"

  AC_CHECK_LIB([$1], [$2], [$3], [$4], [$5])
  CPPFLAGS="$ac_save_CPPFLAGS"
  LDFLAGS="$ac_save_LDFLAGS"
#  LIBS="$ac_save_LIBS"
  ])


# Usage: HANDLE_X_PATH_ARG([variable_name],
#                          [--command-line-option],
#                          [descriptive string])
#
# All of the --with options take three forms:
#
#   --with-foo (or --with-foo=yes)
#   --without-foo (or --with-foo=no)
#   --with-foo=/DIR
#
# This function, HANDLE_X_PATH_ARG, deals with the /DIR case.  When it sees
# a directory (string beginning with a slash) it checks to see whether
# /DIR/include and /DIR/lib exist, and adds them to $X_CFLAGS and $X_LIBS
# as appropriate.
#
AC_DEFUN(HANDLE_X_PATH_ARG, [
   case "$[$1]" in
    yes) ;;
    no)  ;;

    /*)
     AC_MSG_CHECKING([for [$3] headers])
     d=$[$1]/include
     if test -d $d; then
       X_CFLAGS="-I$d $X_CFLAGS"
       AC_MSG_RESULT($d)
     else
       AC_MSG_RESULT(not found ($d: no such directory))
     fi

     AC_MSG_CHECKING([for [$3] libs])
     d=$[$1]/lib
     if test -d $d; then
       X_LIBS="-L$d $X_LIBS"
       AC_MSG_RESULT($d)
     else
       AC_MSG_RESULT(not found ($d: no such directory))
     fi

     # replace the directory string with "yes".
     [$1]_req="yes"
     [$1]=$[$1]_req
     ;;

    *)
     echo ""
     echo "error: argument to [$2] must be \"yes\", \"no\", or a directory."
     echo "       If it is a directory, then \`DIR/include' will be added to"
     echo "       the -I list, and \`DIR/lib' will be added to the -L list."
     exit 1
     ;;
   esac
  ])



###############################################################################
###############################################################################
#
#       End of function definitions.  Now start actually executing stuff.
#
###############################################################################
###############################################################################

# random compiler setup
AC_CANONICAL_HOST
AC_PROG_CC_ANSI
AC_NO_CPLUSPLUS_COMMENTS_IN_C_CODE
AC_PROG_CPP
AC_C_CONST
AC_C_INLINE

# stuff for Makefiles
AC_PROG_INSTALL
AC_PROG_MAKE_SET

# By default, autoconf sets INSTALL_SCRIPT to '${INSTALL_PROGRAM}'.
# That's wrong: it should be set to '${INSTALL}', so that one can
# implement the "install-strip" target properly (strip executables,
# but do not try to strip scripts.)
#
INSTALL_SCRIPT='${INSTALL}'

# random libc stuff
AC_HEADER_STDC
AC_CHECK_HEADERS(unistd.h)
AC_TYPE_SIGNAL
AC_HEADER_TIME
AC_HEADER_SYS_WAIT
AC_PATH_XTRA

if test "$have_x" != yes; then
  AC_MSG_ERROR(Couldn't find X11 headers/libs.  Try \`$0 --help'.)
fi


###############################################################################
#
#       Check for -lgtk (and Gnome stuff)
#
###############################################################################

have_gtk=no
with_gtk_req=unspecified
AC_ARG_WITH(gtk,
[  --with-gtk              Use the Gtk toolkit for the user interface.],
  [with_gtk="$withval"; with_gtk_req="$withval"],[with_gtk=yes])

# if --with-gtk=/directory/ was specified, remember that directory so that
# we can also look for the `gtk-config' program in that directory.
case "$with_gtk" in
  /*)
    gtk_dir="$with_gtk"
    ;;
  *)
    gtk_dir=""
    ;;
esac

HANDLE_X_PATH_ARG(with_gtk, --with-gtk, Gtk)

if test "$with_gtk" != yes -a "$with_gtk" != no ; then
  echo "error: must be yes or no: --with-gtk=$with_gtk"
  exit 1
fi

have_gnome=no
with_gnome_req=unspecified
AC_ARG_WITH(gnome,
[  --with-gnome            Include support for the Gnome Control Center.],
  [with_gnome="$withval"; with_gnome_req="$withval"],[with_gnome=yes])

# if --with-gnome=/directory/ was specified, remember that directory so that
# we can also look for the `gnome-config' program in that directory.
case "$with_gnome" in
  /*)
    gnome_dir="$with_gnome"
    ;;
  *)
    gnome_dir=""
    ;;
esac

HANDLE_X_PATH_ARG(with_gnome, --with-gnome, Gnome)

if test "$with_gnome" != yes -a "$with_gnome" != no ; then
  echo "error: must be yes or no: --with-gnome=$with_gnome"
  exit 1
fi


jurassic_gtk=no
if test "$with_gtk" = yes; then
  have_gtk=no
  
  # if the user specified --with-gtk=/foo/ or --with-gnome=/foo/ then
  # look in /foo/bin/ for glib-config, gtk-config, and gnome-config.
  #
  gtk_path="$PATH"

  if test ! -z "$gtk_dir"; then
    # canonicalize slashes.
    foo=`echo "${gtk_dir}/bin" | sed 's@//*@/@g'`
    gtk_path="$foo:$gtk_path"
  fi

  if test ! -z "$gnome_dir"; then
    # canonicalize slashes.
    foo=`echo "${gnome_dir}/bin" | sed 's@//*@/@g'`
    gtk_path="$foo:$gtk_path"
  fi

  AC_PATH_PROGS(glib_config,  glib12-config glib-config,,  $gtk_path)
  AC_PATH_PROGS(gtk_config,   gtk12-config  gtk-config,,   $gtk_path)

  if test "$with_gnome" = yes; then
    AC_PATH_PROGS(gnome_config, gnome-config,, $gtk_path)
  fi

  if test -n "$glib_config" -a  -n "$gtk_config" ; then
    have_gtk=yes
    if test "$with_gnome" = yes -a -n "$gnome_config" ; then
      have_gnome=yes
    fi
  fi

  if test "$have_gtk" = yes; then
    AC_CACHE_CHECK([Gtk version number], ac_cv_gtk_version_string,
                   [ac_cv_gtk_version_string=`$gtk_config --version`])
    ac_gtk_version_string=$ac_cv_gtk_version_string
    # M4 sucks!!
    changequote(X,Y)
    maj=`echo $ac_gtk_version_string | sed -n 's/\..*//p'`
    min=`echo $ac_gtk_version_string | sed -n 's/[^.]*\.\([^.]*\).*/\1/p'`
    changequote([,])
    ac_gtk_version=`echo "$maj * 1000 + $min" | bc`
    if test -z "$ac_gtk_version"; then
      ac_gtk_version=unknown
      ac_gtk_version_string=unknown
    fi
    if test "$ac_gtk_version" = "unknown" || test "$ac_gtk_version" -lt 1002
    then
      have_gtk=no
      have_gnome=no
      jurassic_gtk=yes
    fi
  fi

  if test "$have_gtk" = yes; then
    AC_CACHE_CHECK([for Gtk includes], ac_cv_gtk_config_cflags,
                   [ac_cv_gtk_config_cflags=`$gtk_config --cflags`])
    AC_CACHE_CHECK([for Gtk libs], ac_cv_gtk_config_libs,
                   [ac_cv_gtk_config_libs=`$gtk_config --libs`])
  fi
  ac_gtk_config_cflags=$ac_cv_gtk_config_cflags
  ac_gtk_config_libs=$ac_cv_gtk_config_libs

  # Check for Gnome support.
  #
  if test "$have_gnome" = yes -a "$have_gtk" = yes; then
    gnome_config_libs="gtk gnomeui gdk_pixbuf gdk_pixbuf_xlib"
    AC_MSG_CHECKING(for Gnome includes)
    AC_CACHE_VAL(ac_cv_gnome_config_cflags,
      [if ( $gnome_config --cflags $gnome_config_libs >/dev/null 2>&1 | \
            grep Unknown >/dev/null ) ; then
         ac_cv_gnome_config_cflags=''
       else
         ac_cv_gnome_config_cflags=`$gnome_config --cflags $gnome_config_libs`
       fi])
    ac_gnome_config_cflags=$ac_cv_gnome_config_cflags
    if test "$ac_gnome_config_cflags" = "" ; then
      have_gnome=no
      AC_MSG_RESULT(no)
    else
      AC_MSG_RESULT($ac_gnome_config_cflags)
    fi
  fi

  if test "$have_gnome" = yes -a "$have_gtk" = yes; then
    AC_MSG_CHECKING(for Gnome libs)
    AC_CACHE_VAL(ac_cv_gnome_config_libs,
      [if ( $gnome_config --libs $gnome_config_libs >/dev/null 2>&1 |
            grep Unknown >/dev/null ) ; then
         ac_cv_gnome_config_libs=''
       else
         ac_cv_gnome_config_libs=`$gnome_config --libs $gnome_config_libs`
       fi])
    ac_gnome_config_libs=$ac_cv_gnome_config_libs
    if test "$ac_gnome_config_libs" = "" ; then
      have_gnome=no
      AC_MSG_RESULT(no)
    else
      AC_MSG_RESULT($ac_gnome_config_libs)
    fi
  fi

  GNOME_DATADIR=""
  if test "$have_gnome" = yes -a "$have_gtk" = yes; then
    GNOME_DATADIR=`$gnome_config --datadir`
  fi


  # If we have Gnome, then override the gtk-config values with 
  # the gnome-config values.
  #
  if test "$have_gnome" = yes -a "$have_gtk" = yes; then
    ac_gtk_config_cflags=$ac_gnome_config_cflags
    ac_gtk_config_libs=$ac_gnome_config_libs
  fi


  if test "$have_gtk" = yes; then
    INCLUDES="$INCLUDES $ac_gtk_config_cflags"
    GTK_LIBS="$GTK_LIBS $ac_gtk_config_libs"
    AC_DEFINE(HAVE_GTK)
  fi

fi


# Check for the Gnome Help Browser.
#
if test "$have_gnome" = yes; then
  AC_CHECK_PROG(have_gnome_help, gnome-help-browser, yes, no)
else
  have_gnome_help=no
fi


###############################################################################
#
#       Check for -lGL or -lMesaGL.
#
###############################################################################

have_gl=no
ac_have_mesa_gl=no
with_gl_req=unspecified
gl_halfassed=no
AC_ARG_WITH(gl,[
Graphics options:

  --with-gl               Build those demos which depend on OpenGL.],
  [with_gl="$withval"; with_gl_req="$withval"],[with_gl=yes])

HANDLE_X_PATH_ARG(with_gl, --with-gl, GL)

ac_mesagl_version=unknown
ac_mesagl_version_string=unknown

if test "$with_gl" = yes; then
  AC_CHECK_X_HEADER(GL/gl.h, have_gl=yes, have_gl=no)
  if test "$have_gl" = yes ; then
    AC_CHECK_X_HEADER(GL/glx.h, have_gl=yes, have_gl=no,
                      [#include <GL/gl.h>])
  fi

  # If we have the headers, try and figure out which vendor it's from.
  #
  if test "$have_gl" = yes ; then

    # We need to know whether it's MesaGL so that we know which libraries
    # to link against.
    #
    AC_CACHE_CHECK([whether GL is really MesaGL], ac_cv_have_mesa_gl,
      [ac_cv_have_mesa_gl=no
       AC_EGREP_X_HEADER(Mesa|MESA, GL/glx.h, [ac_cv_have_mesa_gl=yes])
      ])
    ac_have_mesa_gl=$ac_cv_have_mesa_gl
 

    gl_lib_1=""
    GL_LIBS=""


    # Some versions of MesaGL are compiled to require -lpthread.
    # So if the Mesa headers exist, and -lpthread exists, then always
    # link -lpthread after the Mesa libs (be they named -lGL or -lMesaGL.)
    #
    if test "$ac_have_mesa_gl" = yes; then
      AC_CHECK_LIB(pthread, pthread_create, [GL_LIBS="-lpthread"], [],)
    fi


    # If we have Mesa headers, check to see if we can link against -lMesaGL.
    # If we don't have Mesa headers, or we don't have -lMesaGL, try -lGL.
    # Else, warn that GL is busted.  (We have the headers, but no libs.)
    #

    if test "$ac_have_mesa_gl" = yes ; then
      AC_CHECK_X_LIB(MesaGL, glXCreateContext, 
                     [gl_lib_1="MesaGL"
                      GL_LIBS="-lMesaGL -lMesaGLU $GL_LIBS"],
                     [], -lMesaGLU $GL_LIBS -lX11 -lXext -lm)
    fi

    if test "$gl_lib_1" = "" ; then
      AC_CHECK_X_LIB(GL, glXCreateContext, 
                     [gl_lib_1="GL"
                      GL_LIBS="-lGL -lGLU $GL_LIBS"],
                     [], -lGLU $GL_LIBS -lX11 -lXext -lm)
    fi

    if test "$gl_lib_1" = "" ; then
      # we have headers, but no libs -- bail.
      have_gl=no
      ac_have_mesa_gl=no
      gl_halfassed=yes
    else
      # linking works -- we can build the GL hacks.
      AC_DEFINE(HAVE_GL)
      if test "$ac_have_mesa_gl" = yes ; then
        AC_DEFINE(HAVE_MESA_GL)
      fi
    fi
  fi


  # Now that we know we have GL headers and libs, do some more GL testing.
  #

  if test "$have_gl" = yes ; then
    # If it's MesaGL, we'd like to issue a warning if the version number
    # is less than or equal to 2.6, because that version had a security bug.
    #
    if test "$ac_have_mesa_gl" = yes; then

      AC_CACHE_CHECK([MesaGL version number], ac_cv_mesagl_version_string,
        [cat > conftest.$ac_ext <<EOF
#line __oline__ "configure"
#include "confdefs.h"
#include <GL/gl.h>
#ifndef MESA_MAJOR_VERSION
# include <GL/xmesa.h>
# define MESA_MAJOR_VERSION XMESA_MAJOR_VERSION
# define MESA_MINOR_VERSION XMESA_MINOR_VERSION
#endif
configure: MESA_MAJOR_VERSION MESA_MINOR_VERSION
EOF

         ac_save_CPPFLAGS="$CPPFLAGS"
         if test \! -z "$includedir" ; then 
           CPPFLAGS="$CPPFLAGS -I$includedir"
         fi
         CPPFLAGS="$CPPFLAGS $X_CFLAGS"

# With autoconf 2.13 we could do this:
#
#        changequote(X,Y)
#        mglv=`(eval "$ac_cpp conftest.$ac_ext") 2>&AC_FD_CC | sed -n \
#             's/^configure:.*\([0-9][0-9]*\).*\([0-9][0-9]*\).*$/\1.\2/p'`
#        changequote([,])
#
# but with autoconf 2.52+ (m4 1.4) that causes an error:
#   m4: ERROR: Recursion limit of 1024 exceeded, use -L<N> to change it
#
# So, we need to use the autoconf line-noise macros @<:@ for [ and @:>@ for ]
#
         mglv=`(eval "$ac_cpp conftest.$ac_ext") 2>&AC_FD_CC | sed -n \
              's/^configure:.*\(@<:@0-9@:>@@<:@0-9@:>@*\).*\(@<:@0-9@:>@@<:@0-9@:>@*\).*$/\1.\2/p'`


         rm -f conftest.$ac_ext

         CPPFLAGS="$ac_save_CPPFLAGS"

         if test "$mglv" = ""; then
           ac_mesagl_version=unknown
           ac_mesagl_version_string=unknown
         else
           ac_mesagl_version_string=$mglv
           maj=`echo $mglv | sed -n 's/\..*//p'`
           min=`echo $mglv | sed -n 's/.*\.//p'`
           ac_mesagl_version=`echo "$maj * 1000 + $min" | bc`
           if test -z "$ac_mesagl_version"; then
             ac_mesagl_version=unknown
             ac_mesagl_version_string=unknown
           fi
         fi
         ac_cv_mesagl_version=$ac_mesagl_version
         ac_cv_mesagl_version_string=$ac_mesagl_version_string
      ])
      ac_mesagl_version=$ac_cv_mesagl_version
      ac_mesagl_version_string=$ac_cv_mesagl_version_string
    fi


    # Check for OpenGL 1.1 features.
    #
    AC_CHECK_X_LIB($gl_lib_1, glBindTexture, [AC_DEFINE(HAVE_GLBINDTEXTURE)],
                   [true], $GL_LIBS -lX11 -lXext -lm)
  fi

elif test "$with_gl" != no; then
  echo "error: must be yes or no: --with-gl=$with_gl"
  exit 1
fi


###############################################################################
#
#       Done testing.  Now, set up the various -I and -L variables,
#       and decide which GUI program to build by default.
#
###############################################################################

DEPEND=makedepend
DEPEND_FLAGS=
DEPEND_DEFINES=


if test \! -z "$includedir" ; then 
  INCLUDES="$INCLUDES -I$includedir"
fi

if test \! -z "$libdir" ; then
  LDFLAGS="$LDFLAGS -L$libdir"
fi


###############################################################################
#
#       Perform substitutions and write Makefiles.
#
###############################################################################

AC_SUBST(INCLUDES)
AC_SUBST(GTK_LIBS)
AC_SUBST(GL_LIBS)

AC_OUTPUT(Makefile)

###############################################################################
#
#       Print some warnings at the end.
#
###############################################################################

warn_prefix_1="    Warning:"
warn_prefix_2="       Note:"
warn_prefix="$warn_prefix_1"

warning=no
warnsep='    #################################################################'

warnpre() {
  if test "$warning" = no ; then
    echo '' ; echo "$warnsep" ; echo ''
    warning=yes
  fi
}

warn() {
  warnpre
  if test "$warning" = long ; then echo '' ; fi
  warning=yes
  rest="$@"
  echo "$warn_prefix $rest"
}

warnL() {
  was=$warning
  warnpre
  warning=yes
  if test "$was" != no ; then echo '' ; fi
  rest="$@"
  echo "$warn_prefix $rest"
}

warn2() {
  rest="$@"
  echo "             $rest"
  warning=long
}

note() {
  warn_prefix="$warn_prefix_2"
  warn $@
  warn_prefix="$warn_prefix_1"
}

noteL() {
  warn_prefix="$warn_prefix_2"
  warnL $@
  warn_prefix="$warn_prefix_1"
}


if test "$jurassic_gtk" = yes ; then

  pref_gtk=1.2

  v="$ac_gtk_version_string"
  if test "$with_gtk_req" = yes -a "$ac_gtk_version" = "unknown" ; then
    warnL "Use of Gtk was requested, but its version number is unknown;"
  elif test "$with_gtk_req" = yes ; then
    warnL "Use of Gtk was requested, but it is version $v;"
  else
    warnL "Gtk was found on this system, but it is version $v;"
  fi

  warn2 "Gtk $pref_gtk or newer is required.  Motif will be used instead."

elif test "$with_gtk_req" = yes -a "$have_gtk" = no ; then
  warnL "Use of Gtk was requested, but it wasn't found."
fi


if test "$have_gl" = yes -a "$ac_have_mesa_gl" = yes ; then
  preferred_mesagl=3.4
  mgv="$ac_mesagl_version_string"
  pgl="$preferred_mesagl"

  if test "$ac_mesagl_version" = unknown; then
    warnL "Unable to determine the MesaGL version number!"
    warn2 "Make sure you are using version $preferred_mesagl or newer."

  elif test \! "$ac_mesagl_version" -gt 2006; then
    warnL "MesaGL version $mgv is being used.  MesaGL 2.6 and earlier"
    warn2 "have a security bug.  It is strongly recommended that you"
    warn2 "upgrade to at least version $preferred_mesagl."

  elif test \! "$ac_mesagl_version" -gt 3003; then
    warnL "MesaGL version $mgv is being used.  That version has some"
    warn2 "bugs; it is recommended that you upgrade to $pgl or newer."
  fi
fi

if test "$have_gl" = no ; then
  if test "$with_gl_req" = yes ; then
    warnL 'Use of GL was requested, but it was not found.'
  elif test "$with_gl_req" = no ; then
    noteL 'The OpenGL 3D library is not being used.'
  else
    noteL 'The OpenGL 3D library was not found.'
  fi

  if test "$gl_halfassed" = yes ; then
    echo ''
    warn2 'More specifically, we found the headers, but not the'
    warn2 'libraries; so either GL is half-installed on this'
    warn2 "system, or something else went wrong.  The \`config.log'"
    warn2 'file might contain some clues.'
  fi

  echo ''
  warn2 'Those demos which use 3D will not be built or installed.'
  warn2 'You might want to consider installing OpenGL and'
  warn2 're-running configure.  (Remember to delete the'
  warn2 "config.cache file first.)  If your vendor doesn't ship"
  warn2 'their own implementation of OpenGL, you can get a free'
  warn2 'version at <http://www.mesa3d.org/>.  For general OpenGL'
  warn2 'info, see <http://www.opengl.org/>.'

fi