-
Notifications
You must be signed in to change notification settings - Fork 3
/
acinclude.m4
3054 lines (2815 loc) · 142 KB
/
acinclude.m4
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
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# checkbuild.m4 -*- Autoconf -*-
#==============================================================================
# Copyright (C)2003 by Eric Sunshine <[email protected]>
#
# This library is free software; you can redistribute it and/or modify it
# under the terms of the GNU Library General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This library is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
# License for more details.
#
# You should have received a copy of the GNU Library General Public License
# along with this library; if not, write to the Free Software Foundation,
# Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#==============================================================================
AC_PREREQ([2.56])
#------------------------------------------------------------------------------
# CS_SPLIT_TUPLE(TUPLE, OUTPUT-VARIABLES)
# Split a build-tuple into its component parts. A build tuple is
# constructed by CS_CREATE_TUPLE() and is comprised of compiler flags,
# linker flags, and library references. OUTPUT-VARIABLES is a
# comma-delimited list of shell variables which should receive the
# extracted compiler flags, linker flags, and library references,
# respectively.
#------------------------------------------------------------------------------
AC_DEFUN([CS_SPLIT_TUPLE],
[CS_SPLIT([$1], [cs_dummy,$2], [@])
m4_map([_CS_SPLIT_TUPLE], [$2])])
AC_DEFUN([_CS_SPLIT_TUPLE],
[$1=`echo $$1 | sed 'y%@%:@% %'`
])
#------------------------------------------------------------------------------
# CS_CREATE_TUPLE([CFLAGS], [LFLAGS], [LIBS])
# Construct a build-tuple which is comprised of compiler flags, linker
# flags, and library references. Build tuples are encoded so as to
# preserve whitespace in each component. This makes it possible for
# macros (such as CS_BUILD_IFELSE) which employ build tuples to accept
# whitespace-delimited lists of tuples, and for shell "for" statements to
# iterate over tuple lists without compromising whitespace embedded
# within individual flags or library references.
#------------------------------------------------------------------------------
AC_DEFUN([CS_CREATE_TUPLE], [`echo @$1@$2@$3 | sed 'y% %@%:@%'`])
#------------------------------------------------------------------------------
# CS_LANG_CFLAGS
# Return the literal string CFLAGS if the current language is C. Return
# the literal string CXXFLAGS if the current language is C++. Generic
# compiler test macros which need to modify or save the compiler flags
# can invoke this macro to get the name of the compiler flags environment
# variable (either CFLAGS or CXXFLAGS) depending upon the current
# language. For example:
# CS_LANG_CFLAGS="$CS_LANG_CFLAGS -Wall"
# With C, this expands to:
# CFLAGS="$CFLAGS -Wall"
# With C++, it expands to:
# CXXFLAGS="$CXXFLAGS -Wall"
#------------------------------------------------------------------------------
AC_DEFUN([CS_LANG_CFLAGS], [AC_LANG_CASE([C], [CFLAGS], [C++], [CXXFLAGS])])
#------------------------------------------------------------------------------
# CS_BUILD_IFELSE([PROGRAM], [FLAGS], [LANGUAGE], [ACTION-IF-BUILT],
# [ACTION-IF-NOT-BUILT], [OTHER-CFLAGS], [OTHER-LFLAGS],
# [OTHER-LIBS], [INHIBIT-OTHER-FLAGS], [ERROR-REGEX])
# Try building a program using the supplied compiler flags, linker flags,
# and library references. PROGRAM is typically a program composed via
# AC_LANG_PROGRAM(). PROGRAM may be omitted if you are interested only
# in learning if the compiler or linker respects certain flags. LANGUAGE
# is typically either C or C++ and specifies which compiler to use for
# the test. If LANGUAGE is omitted, C is used. FLAGS is a whitespace
# delimited list of build tuples. Tuples are created with
# CS_CREATE_TUPLE() and are composed of up to three elements each. The
# first element represents compiler flags, the second linker flags, and
# the third libraries used when linking the program. Each tuple from
# FLAGS is attempted in order. If you want a build attempted with no
# special flags prior to builds with specialized flags, create an empty
# tuple with CS_CREATE_TUPLE() at the start of the FLAGS list. If the
# build is successful, then the shell variables cs_build_ok is set to
# "yes", cs_build_cflags, cs_build_lflags, and cs_build_libs are set to
# the tuple elements which resulted in the successful build, and
# ACTION-IF-BUILT is invoked. Upon successful build, no further tuples
# are consulted. If no tuple results in a successful build, then
# cs_build_ok is set to "no" and ACTION-IF-NOT-BUILT is invoked.
# OTHER-CFLAGS, OTHER-LFLAGS, and OTHER-LIBS specify additional compiler
# flags, linker flags, and libraries which should be used with each tuple
# build attempt. Upon successful build, these additional flags are also
# reflected in the variables cs_build_cflags, cs_build_lflags, and
# cs_build_libs unless INHIBIT-OTHER-FLAGS is a non-empty string. The
# optional ERROR-REGEX places an additional constraint upon the build
# check. If specified, ERROR-REGEX, which is a standard `grep' regular
# expression, is applied to output captured from the compiler and linker.
# If ERROR-REGEX matches, then the build is deemed a failure, and
# cs_build_ok is set to "no". This facility is useful for broken build
# tools which emit an error message yet still return success as a result.
# In such cases, it should be possible to detect the failure by scanning
# the tools' output.
#
# IMPLEMENTATION NOTES
#
# In Autoconf 2.57 and earlier, AC_LINK_IFELSE() invokes AC_TRY_EVAL(),
# which does not provide access to the captured output. To work around
# this limitation, we temporarily re-define AC_TRY_EVAL() as
# _AC_EVAL_STDERR(), which leaves the captured output in conftest.err
# (which we must also delete). In Autoconf 2.58, however,
# AC_LINK_IFELSE() instead already invokes _AC_EVAL_STDERR() on our
# behalf, however we must be careful to apply ERROR-REGEX within the
# invocation AC_LINK_IFELSE(), since AC_LINK_IFELSE() deletes
# conftest.err before it returns.
#------------------------------------------------------------------------------
AC_DEFUN([CS_BUILD_IFELSE],
[AC_LANG_PUSH(m4_default([$3],[C]))
cs_cflags_save="$CS_LANG_CFLAGS"
cs_lflags_save="$LDFLAGS"
cs_libs_save="$LIBS"
cs_build_ok=no
m4_ifval([$10], [m4_pushdef([AC_TRY_EVAL], [_AC_EVAL_STDERR]($$[1]))])
for cs_build_item in m4_default([$2],[CS_CREATE_TUPLE()])
do
CS_SPLIT_TUPLE(
[$cs_build_item],[cs_cflags_test,cs_lflags_test,cs_libs_test])
CS_LANG_CFLAGS="$cs_cflags_test $6 $cs_cflags_save"
LDFLAGS="$cs_lflags_test $7 $cs_lflags_save"
LIBS="$cs_libs_test $8 $cs_libs_save"
AC_LINK_IFELSE(m4_default([$1], [AC_LANG_PROGRAM([],[])]),
[m4_ifval([$10],
[AS_IF([AC_TRY_COMMAND(
[grep "AS_ESCAPE([$10])" conftest.err >/dev/null 2>&1])],
[cs_build_ok=no], [cs_build_ok=yes])],
[cs_build_ok=yes])])
AS_IF([test $cs_build_ok = yes], [break])
done
m4_ifval([$10], [m4_popdef([AC_TRY_EVAL]) rm -f conftest.err])
CS_LANG_CFLAGS=$cs_cflags_save
LDFLAGS=$cs_lflags_save
LIBS=$cs_libs_save
AC_LANG_POP(m4_default([$3],[C]))
AS_IF([test $cs_build_ok = yes],
[cs_build_cflags=CS_TRIM([$cs_cflags_test[]m4_ifval([$9],[],[ $6])])
cs_build_lflags=CS_TRIM([$cs_lflags_test[]m4_ifval([$9],[],[ $7])])
cs_build_libs=CS_TRIM([$cs_libs_test[]m4_ifval([$9],[],[ $8])])
$4],
[$5])])
#------------------------------------------------------------------------------
# CS_CHECK_BUILD(MESSAGE, CACHE-VAR, [PROGRAM], [FLAGS], [LANGUAGE],
# [ACTION-IF-BUILT], [ACTION-IF-NOT-BUILT], [IGNORE-CACHE],
# [OTHER-CFLAGS], [OTHER-LFLAGS], [OTHER-LIBS],
# [INHIBIT-OTHER-FLAGS], [ERROR-REGEX])
# Like CS_BUILD_IFELSE() but also prints "checking" and result messages,
# and optionally respects the cache. Sets CACHE-VAR to "yes" upon
# success, else "no" upon failure. Additionally, sets CACHE-VAR_cflags,
# CACHE-VAR_lflags, and CACHE-VAR_libs to the values which resulted in a
# successful build. If IGNORE-CACHE is "yes", then the cache variables
# are ignored upon entry to this macro, however they are still set to
# appropriate values upon exit.
#------------------------------------------------------------------------------
AC_DEFUN([CS_CHECK_BUILD],
[AS_IF([test "$8" != yes],
[AC_CACHE_CHECK([$1], [$2],
[CS_BUILD_IFELSE([$3], [$4], [$5],
[$2=yes
$2_cflags=$cs_build_cflags
$2_lflags=$cs_build_lflags
$2_libs=$cs_build_libs],
[$2=no], [$9], [$10], [$11], [$12], [$13])])],
[AC_MSG_CHECKING([$1])
CS_BUILD_IFELSE([$3], [$4], [$5],
[$2=yes
$2_cflags=$cs_build_cflags
$2_lflags=$cs_build_lflags
$2_libs=$cs_build_libs],
[$2=no], [$9], [$10], [$11], [$12], [$13])
AC_MSG_RESULT([$$2])])
AS_IF([test $$2 = yes], [$6],
[$2_cflags=''
$2_lflags=''
$2_libs=''
$7])])
#------------------------------------------------------------------------------
# CS_CHECK_BUILD_FLAGS(MESSAGE, CACHE-VAR, FLAGS, [LANGUAGE],
# [ACTION-IF-RECOGNIZED], [ACTION-IF-NOT-RECOGNIZED],
# [OTHER-CFLAGS], [OTHER-LFLAGS], [OTHER-LIBS],
# [ERROR-REGEX])
# Like CS_CHECK_BUILD(), but checks only if the compiler or linker
# recognizes a command-line option or options. MESSAGE is the "checking"
# message. CACHE-VAR is the shell cache variable which receives the flag
# or flags recognized by the compiler or linker. FLAGS is a
# whitespace-delimited list of build tuples created with
# CS_CREATE_TUPLE(). Each tuple from FLAGS is attempted in order until
# one is found which is recognized by the compiler. After that, no
# further flags are checked. LANGUAGE is typically either C or C++ and
# specifies which compiler to use for the test. If LANGUAGE is omitted,
# C is used. If a command-line option is recognized, then CACHE-VAR is
# set to the composite value of $cs_build_cflags, $cs_build_lflags, and
# $cs_build_libs of the FLAGS element which succeeded (not including the
# "other" flags) and ACTION-IF-RECOGNIZED is invoked. If no options are
# recognized, then CACHE-VAR is set to the empty string, and
# ACTION-IF-NOT-RECOGNIZED is invoked. As a convenience, in case
# comparing CACHE-VAR against the empty string to test for failure is
# undesirable, a second variable named CACHE-VAR_ok is set to the literal
# "no" upon failure, and to the same value as CACHE-VAR upon success.
#------------------------------------------------------------------------------
AC_DEFUN([CS_CHECK_BUILD_FLAGS],
[AC_CACHE_CHECK([$1], [$2_ok],
[CS_BUILD_IFELSE([], [$3], [$4],
[$2=CS_TRIM([$cs_build_cflags $cs_build_lflags $cs_build_libs])
$2_ok="$$2"],
[$2=''
$2_ok=no], [$7], [$8], [$9], [Y], [$10])])
AS_IF([test "$$2_ok" != no], [$5], [$6])])
#==============================================================================
# Copyright (C)2003-2006 by Eric Sunshine <[email protected]>
#
# This library is free software; you can redistribute it and/or modify it
# under the terms of the GNU Library General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This library is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
# License for more details.
#
# You should have received a copy of the GNU Library General Public License
# along with this library; if not, write to the Free Software Foundation,
# Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#==============================================================================
AC_PREREQ([2.56])
#------------------------------------------------------------------------------
# CS_CHECK_COMMON_TOOLS_LINK
# Checks for common tools related to linking.
#------------------------------------------------------------------------------
AC_DEFUN([CS_CHECK_COMMON_TOOLS_LINK],
[
# The default RANLIB in Jambase is wrong on some platforms, and is also
# unsuitable during cross-compilation, so we set the value unconditionally
# (sixth argument of CS_EMIT_BUILD_PROPERTY).
AC_PROG_RANLIB
CS_EMIT_BUILD_PROPERTY([RANLIB], [$RANLIB], [], [], [], [Y])
CS_CHECK_TOOLS([DLLTOOL], [dlltool])
CS_EMIT_BUILD_PROPERTY([CMD.DLLTOOL], [$DLLTOOL])
CS_CHECK_TOOLS([DLLWRAP], [dllwrap])
CS_EMIT_BUILD_PROPERTY([CMD.DLLWRAP], [$DLLWRAP])
CS_CHECK_TOOLS([WINDRES], [windres])
CS_EMIT_BUILD_PROPERTY([CMD.WINDRES], [$WINDRES])
CS_CHECK_TOOLS([STRINGS], [strings])
CS_EMIT_BUILD_PROPERTY([CMD.STRINGS], [$STRINGS])
CS_CHECK_TOOLS([OBJCOPY], [objcopy])
CS_EMIT_BUILD_PROPERTY([CMD.OBJCOPY], [$OBJCOPY])
CS_CHECK_LIBTOOL
CS_EMIT_BUILD_PROPERTY([LIBTOOL], [$LIBTOOL])
CS_EMIT_BUILD_PROPERTY([APPLE_LIBTOOL], [$APPLE_LIBTOOL])
])
#------------------------------------------------------------------------------
# CS_CHECK_COMMON_TOOLS_BASIC
# Checks for basic tools for building things.
#------------------------------------------------------------------------------
AC_DEFUN([CS_CHECK_COMMON_TOOLS_BASIC],
[CS_CHECK_MKDIR
CS_EMIT_BUILD_PROPERTY([CMD.MKDIR], [$MKDIR])
CS_EMIT_BUILD_PROPERTY([CMD.MKDIRS], [$MKDIRS])
CS_CHECK_PROGS([INSTALL], [install])
CS_EMIT_BUILD_PROPERTY([INSTALL], [$INSTALL])])
#------------------------------------------------------------------------------
# CS_CHECK_COMMON_TOOLS_DOC_TEXINFO
# Checks for tools to generate documentation from texinfo files.
#------------------------------------------------------------------------------
AC_DEFUN([CS_CHECK_COMMON_TOOLS_DOC_TEXINFO],
[CS_CHECK_PROGS([TEXI2DVI], [texi2dvi])
CS_EMIT_BUILD_PROPERTY([CMD.TEXI2DVI], [$TEXI2DVI])
CS_CHECK_PROGS([TEXI2PDF], [texi2pdf])
CS_EMIT_BUILD_PROPERTY([CMD.TEXI2PDF], [$TEXI2PDF])
CS_CHECK_PROGS([DVIPS], [dvips])
CS_EMIT_BUILD_PROPERTY([CMD.DVIPS], [$DVIPS])
CS_CHECK_PROGS([DVIPDF], [dvipdf])
CS_EMIT_BUILD_PROPERTY([CMD.DVIPDF], [$DVIPDF])
CS_CHECK_PROGS([MAKEINFO], [makeinfo])
CS_EMIT_BUILD_PROPERTY([CMD.MAKEINFO], [$MAKEINFO])])
#------------------------------------------------------------------------------
# CS_CHECK_COMMON_TOOLS_DOC_DOXYGEN
# Checks for tools to generate source documentation via doxygen.
#------------------------------------------------------------------------------
AC_DEFUN([CS_CHECK_COMMON_TOOLS_DOC_DOXYGEN],
[CS_CHECK_PROGS([DOXYGEN], [doxygen])
CS_EMIT_BUILD_PROPERTY([CMD.DOXYGEN], [$DOXYGEN])
CS_CHECK_TOOLS([DOT], [dot])
CS_EMIT_BUILD_PROPERTY([CMD.DOT], [$DOT])])
#------------------------------------------------------------------------------
# CS_CHECK_COMMON_LIBS
# Check for typical required libraries (libm, libmx, libdl, libnsl).
#------------------------------------------------------------------------------
AC_DEFUN([CS_CHECK_COMMON_LIBS],
[AC_LANG_PUSH([C])
AC_CHECK_LIB([m], [pow], [cs_cv_libm_libs=-lm], [cs_cv_libm_libs=])
AC_CHECK_LIB([m], [cosf], [cs_cv_libm_libs=-lm])
AC_CHECK_LIB([mx], [cosf])
AC_CHECK_LIB([dl], [dlopen], [cs_cv_libdl_libs=-ldl], [cs_cv_libdl_libs=])
AC_CHECK_LIB([nsl], [gethostbyname])
AC_LANG_POP([C])])
# checkcppunit.m4 -*- Autoconf -*-
#==============================================================================
# Copyright (C)2005 by Eric Sunshine <[email protected]>
#
# This library is free software; you can redistribute it and/or modify it
# under the terms of the GNU Library General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This library is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
# License for more details.
#
# You should have received a copy of the GNU Library General Public License
# along with this library; if not, write to the Free Software Foundation,
# Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#==============================================================================
AC_PREREQ([2.56])
#------------------------------------------------------------------------------
# CS_CHECK_CPPUNIT([EMITTER])
# Check if CppUnit (http://cppunit.sourceforge.net/), the unit-testing
# framework is available. The shell variable cs_cv_libcppunit is set to
# "yes" if CppUnit is discovered, else "no". If available, then the
# variables cs_cv_libcppunit_cflags, cs_cv_libcppunit_lflags, and
# cs_cv_libcppunit_libs are set. If EMITTER is provided, then
# CS_EMIT_BUILD_RESULT() is invoked with EMITTER in order to record the
# results in an output file. As a convenience, if EMITTER is the literal
# value "emit" or "yes", then CS_EMIT_BUILD_RESULT()'s default emitter
# will be used.
#------------------------------------------------------------------------------
AC_DEFUN([CS_CHECK_CPPUNIT],
[CS_CHECK_LIB_WITH([cppunit],
[AC_LANG_PROGRAM([[#include <cppunit/ui/text/TestRunner.h>]],
[CppUnit::TextUi::TestRunner r; r.run();])],
[], [C++])
AS_IF([test $cs_cv_libcppunit = yes],
[CS_CHECK_BUILD([if cppunit is sufficiently recent],
[cs_cv_libcppunit_recent],
[AC_LANG_PROGRAM(
[[#include <cppunit/BriefTestProgressListener.h>]],
[CppUnit::BriefTestProgressListener b; b.startTest(0);])],
[], [C++],
[CS_EMIT_BUILD_RESULT([cs_cv_libcppunit], [CPPUNIT],
CS_EMITTER_OPTIONAL([$1]))], [], [],
[$cs_cv_libcppunit_cflags],
[$cs_cv_libcppunit_lflags],
[$cs_cv_libcppunit_libs])])])
# checklib.m4 -*- Autoconf -*-
#==============================================================================
# Copyright (C)2003-2005 by Eric Sunshine <[email protected]>
#
# This library is free software; you can redistribute it and/or modify it
# under the terms of the GNU Library General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This library is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
# License for more details.
#
# You should have received a copy of the GNU Library General Public License
# along with this library; if not, write to the Free Software Foundation,
# Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#==============================================================================
AC_PREREQ([2.56])
#------------------------------------------------------------------------------
# cs_lib_paths_default
# Whitespace delimited list of directory tuples in which to search, by
# default, for external libraries. Each list item can specify an
# include|library directory tuple (for example, "/usr/include|/usr/lib"),
# or a single directory (for example, "/usr"). If the second form is
# used, then "include" and "lib" subdirectories of the directory are
# searched. If the library resources are not found, then the directory
# itself is searched. Thus, "/proj" is shorthand for
# "/proj/include|/proj/lib /proj|/proj".
#
# Present Cases:
# /usr/local -- Not all compilers search here by default, so we specify
# it manually.
# /sw -- Fink, the MacOS/X manager of Unix packages, installs here by
# default.
# /opt/local -- DarwinPorts installs here by default.
#------------------------------------------------------------------------------
m4_define([cs_lib_paths_default],
[/usr/local/include|/usr/local/lib \
/sw/include|/sw/lib \
/opt/local/include|/opt/local/lib \
/opt/include|/opt/lib])
#------------------------------------------------------------------------------
# cs_pkg_paths_default
# Comma delimited list of additional directories in which the
# `pkg-config' command should search for its `.pc' files.
#
# Present Cases:
# /usr/local/lib/pkgconfig -- Although a common location for .pc files
# installed by "make install", many `pkg-config' commands neglect
# to search here automatically.
# /sw/lib/pkgconfig -- Fink, the MacOS/X manager of Unix packages,
# installs .pc files here by default.
# /opt/local/lib/pkgconfig -- DarwinPorts installs .pc files here by
# default.
#------------------------------------------------------------------------------
m4_define([cs_pkg_paths_default],
[/usr/local/lib/pkgconfig,
/sw/lib/pkgconfig,
/opt/local/lib/pkgconfig,
/opt/lib/pkgconfig])
#------------------------------------------------------------------------------
# CS_CHECK_LIB_WITH(LIBRARY, PROGRAM, [SEARCH-LIST], [LANGUAGE],
# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [OTHER-CFLAGS],
# [OTHER-LFLAGS], [OTHER-LIBS], [ALIASES])
# Very roughly similar in concept to AC_CHECK_LIB(), but allows caller to
# to provide list of directories in which to search for LIBRARY; allows
# user to override library location via --with-LIBRARY=dir; and consults
# `pkg-config' (if present) and `LIBRARY-config' (if present, i.e.
# `sdl-config') in order to obtain compiler and linker flags. LIBRARY is
# the name of the library or MacOS/X framework which is to be located
# (for example, "readline" for `libreadline.a' or `readline.framework').
# PROGRAM, which is typically composed with AC_LANG_PROGRAM(), is a
# program which references at least one function or symbol in LIBRARY.
# SEARCH-LIST is a whitespace-delimited list of paths in which to search
# for the library and its header files, in addition to those searched by
# the compiler and linker by default, and those referenced by the
# cs_lib_paths_default macro. Each list item can specify an
# `include|library' directory tuple (for example,
# "/usr/include|/usr/lib"), or a single directory (for example, "/usr").
# If the second form is used, then "include" and "lib" subdirectories of
# the directory are searched. If the library resources are not found,
# then the directory itself is searched. Thus, "/proj" is shorthand for
# "/proj/include|/proj/lib /proj|/proj". Items in the search list can
# include wildcards. SEARCH-LIST can be overridden by the user with the
# --with-LIBRARY=dir option, in which case only "dir/include|dir/lib" and
# "dir|dir" are searched. If SEARCH-LIST is omitted and the user did not
# override the search list via --with-LIBRARY=dir, then only the
# directories normally searched by the compiler and the directories
# mentioned via cs_lib_paths_default are searched. LANGUAGE is typically
# either C or C++ and specifies which compiler to use for the test. If
# LANGUAGE is omitted, C is used. OTHER-CFLAGS, OTHER-LFLAGS, and
# OTHER-LIBS can specify additional compiler flags, linker flags, and
# libraries needed to successfully link with LIBRARY. The optional
# ALIASES is a comma-delimited list of library names for which to search
# in case LIBRARY is not located (for example "[sdl1.2, sdl12]" for
# libsdl1.2.a, sdl1.2.framework, libsdl12.a, and sdl12.framework). If
# the library or one of its aliases is found and can be successfully
# linked into a program, then the shell cache variable cs_cv_libLIBRARY
# is set to "yes"; cs_cv_libLIBRARY_cflags, cs_cv_libLIBRARY_lflags, and
# cs_cv_libLIBRARY_libs are set, respectively, to the compiler flags
# (including OTHER-CFLAGS), linker flags (including OTHER-LFLAGS), and
# library references (including OTHER-LIBS) which resulted in a
# successful build; and ACTION-IF-FOUND is invoked. If the library was
# not found or was unlinkable, or if the user disabled the library via
# --without-LIBRARY, then cs_cv_libLIBRARY is set to "no" and
# ACTION-IF-NOT-FOUND is invoked. Note that the exported shell variable
# names are always composed from LIBRARY regardless of whether the test
# succeeded because the primary library was discovered or one of the
# aliases.
#------------------------------------------------------------------------------
AC_DEFUN([CS_CHECK_LIB_WITH],
[AC_ARG_WITH([$1], [AC_HELP_STRING([--with-$1=dir],
[specify location of lib$1 if not detected automatically; searches
dir/include, dir/lib, and dir])])
# Backward compatibility: Recognize --with-lib$1 as alias for --with-$1.
AS_IF([test -n "$with_lib$1" && test -z "$with_$1"],
[with_$1="$with_lib$1"])
AS_IF([test -z "$with_$1"], [with_$1=yes])
AS_IF([test "$with_$1" != no],
[# If --with-$1 value is same as cached value, then assume other
# cached values are also valid; otherwise, ignore all cached values.
AS_IF([test "$with_$1" != "$cs_cv_with_$1"],
[cs_ignore_cache=yes], [cs_ignore_cache=no])
cs_check_lib_flags=''
AS_IF([test $with_$1 = yes],
[m4_foreach([cs_check_lib_alias], [$1, $10],
[_CS_CHECK_LIB_PKG_CONFIG_FLAGS([cs_check_lib_flags],
cs_check_lib_alias)
_CS_CHECK_LIB_CONFIG_FLAGS([cs_check_lib_flags],
cs_check_lib_alias)
])])
AS_IF([test $with_$1 != yes],
[cs_check_lib_paths=$with_$1],
[cs_check_lib_paths="| cs_lib_paths_default $3"])
m4_foreach([cs_check_lib_alias], [$1, $10],
[_CS_CHECK_LIB_CREATE_FLAGS([cs_check_lib_flags],
cs_check_lib_alias, [$cs_check_lib_paths])
])
CS_CHECK_BUILD([for lib$1], [cs_cv_lib$1], [$2], [$cs_check_lib_flags],
[$4], [], [], [$cs_ignore_cache], [$7], [$8], [$9])],
[cs_cv_lib$1=no])
cs_cv_with_$1="$with_$1"
AS_IF([test "$cs_cv_lib$1" = yes], [$5], [$6])])
#------------------------------------------------------------------------------
# CS_CHECK_PKG_CONFIG
# Check if the `pkg-config' command is available and reasonably recent.
# This program acts as a central repository of build flags for various
# packages. For example, to determine the compiler flags for FreeType2
# use, "pkg-config --cflags freetype2"; and "pkg-config --libs freetype2"
# to determine the linker flags. If `pkg-config' is found and is
# sufficiently recent, PKG_CONFIG is set and AC_SUBST() invoked.
#------------------------------------------------------------------------------
m4_define([CS_PKG_CONFIG_MIN], [0.9.0])
AC_DEFUN([CS_CHECK_PKG_CONFIG],
[AS_IF([test "$cs_prog_pkg_config_checked" != yes],
[CS_CHECK_TOOLS([PKG_CONFIG], [pkg-config])
_CS_CHECK_PKG_CONFIG_PREPARE_PATH
cs_prog_pkg_config_checked=yes])
AS_IF([test -z "$cs_cv_prog_pkg_config_ok"],
[AS_IF([test -n "$PKG_CONFIG"],
[AS_IF([$PKG_CONFIG --atleast-pkgconfig-version=CS_PKG_CONFIG_MIN],
[cs_cv_prog_pkg_config_ok=yes],
[cs_cv_prog_pkg_config_ok=no])],
[cs_cv_prog_pkg_config_ok=no])])])
AC_DEFUN([_CS_CHECK_PKG_CONFIG_PREPARE_PATH],
[PKG_CONFIG_PATH="m4_foreach([cs_pkg_path], [cs_pkg_paths_default],
[cs_pkg_path$PATH_SEPARATOR])$PKG_CONFIG_PATH"
export PKG_CONFIG_PATH])
#------------------------------------------------------------------------------
# _CS_CHECK_LIB_PKG_CONFIG_FLAGS(VARIABLE, LIBRARY)
# Helper macro for CS_CHECK_LIB_WITH(). Checks if `pkg-config' knows
# about LIBRARY and, if so, appends a build tuple consisting of the
# compiler and linker flags reported by `pkg-config' to the list of
# tuples stored in the shell variable VARIABLE.
#------------------------------------------------------------------------------
AC_DEFUN([_CS_CHECK_LIB_PKG_CONFIG_FLAGS],
[CS_CHECK_PKG_CONFIG
AS_IF([test $cs_cv_prog_pkg_config_ok = yes],
[AC_CACHE_CHECK([if $PKG_CONFIG recognizes $2], [_CS_CLPCF_CVAR([$2])],
[AS_IF([$PKG_CONFIG --exists $2],
[_CS_CLPCF_CVAR([$2])=yes], [_CS_CLPCF_CVAR([$2])=no])])
AS_IF([test $_CS_CLPCF_CVAR([$2]) = yes],
[_CS_CHECK_LIB_CONFIG_PROG_FLAGS([$1], [pkg_config_$2],
[$PKG_CONFIG], [$2])])])])
AC_DEFUN([_CS_CLPCF_CVAR], [AS_TR_SH([cs_cv_prog_pkg_config_$1])])
#------------------------------------------------------------------------------
# _CS_CHECK_LIB_CONFIG_FLAGS(VARIABLE, LIBRARY)
# Helper macro for CS_CHECK_LIB_WITH(). Checks if `LIBRARY-config'
# (i.e. `sdl-config') exists and, if so, appends a build tuple consisting
# of the compiler and linker flags reported by `LIBRARY-config' to the
# list of tuples stored in the shell variable VARIABLE.
#------------------------------------------------------------------------------
AC_DEFUN([_CS_CHECK_LIB_CONFIG_FLAGS],
[CS_CHECK_TOOLS(_CS_CLCF_SHVAR([$2]), [$2-config])
AS_IF([test -n "$_CS_CLCF_SHVAR([$2])"],
[AS_IF([test -z "$_CS_CLCF_CVAR([$2])"],
[AS_IF([$_CS_CLCF_SHVAR([$2]) --cflags --libs >/dev/null 2>&1],
[_CS_CLCF_CVAR([$2])=yes], [_CS_CLCF_CVAR([$2])=no])])
AS_IF([test $_CS_CLCF_CVAR([$2]) = yes],
[_CS_CHECK_LIB_CONFIG_PROG_FLAGS([$1], [config_$2],
[$_CS_CLCF_SHVAR([$2])])])])])
AC_DEFUN([_CS_CLCF_CVAR], [AS_TR_SH([cs_cv_prog_config_$1_ok])])
AC_DEFUN([_CS_CLCF_SHVAR], [m4_toupper(AS_TR_SH([CONFIG_$1]))])
#------------------------------------------------------------------------------
# _CS_CHECK_LIB_CONFIG_PROG_FLAGS(VARIABLE, TAG, CONFIG-PROGRAM, [ARGS])
# Helper macro for _CS_CHECK_LIB_PKG_CONFIG_FLAGS() and
# _CS_CHECK_LIB_CONFIG_FLAGS(). CONFIG-PROGRAM is a command which
# responds to the --cflags and --libs options and returns suitable
# compiler and linker flags for some package. ARGS, if supplied, is
# passed to CONFIG-PROGRAM after the --cflags or --libs argument. The
# results of the --cflags and --libs options are packed into a build
# tuple and appended to the list of tuples stored in the shell variable
# VARIABLE. TAG is used to compose the name of the cache variable. A good
# choice for TAG is some unique combination of the library name and
# configuration program.
#------------------------------------------------------------------------------
AC_DEFUN([_CS_CHECK_LIB_CONFIG_PROG_FLAGS],
[AS_IF([test -z "$_CS_CLCPF_CVAR([$2])"],
[cs_check_lib_cflag=CS_RUN_PATH_NORMALIZE([$3 --cflags $4])
cs_check_lib_lflag=''
cs_check_lib_libs=CS_RUN_PATH_NORMALIZE([$3 --libs $4])
_CS_CLCPF_CVAR([$2])=CS_CREATE_TUPLE(
[$cs_check_lib_cflag],
[$cs_check_lib_lflag],
[$cs_check_lib_libs])])
$1="$$1 $_CS_CLCPF_CVAR([$2])"])
AC_DEFUN([_CS_CLCPF_CVAR], [AS_TR_SH([cs_cv_prog_$1_flags])])
#------------------------------------------------------------------------------
# _CS_CHECK_LIB_CREATE_FLAGS(VARIABLE, LIBRARY, PATHS)
# Helper macro for CS_CHECK_LIB_WITH(). Constructs a list of build
# tuples suitable for CS_CHECK_BUILD() and appends the tuple list to the
# shell variable VARIABLE. LIBRARY and PATHS have the same meanings as
# the like-named arguments of CS_CHECK_LIB_WITH().
#------------------------------------------------------------------------------
AC_DEFUN([_CS_CHECK_LIB_CREATE_FLAGS],
[for cs_lib_item in $3
do
case $cs_lib_item in
*\|*) CS_SPLIT(
[$cs_lib_item], [cs_check_incdir,cs_check_libdir], [|])
_CS_CHECK_LIB_CREATE_FLAG([$1],
[$cs_check_incdir], [$cs_check_libdir], [$2])
;;
*) _CS_CHECK_LIB_CREATE_FLAG([$1],
[$cs_lib_item/include], [$cs_lib_item/lib], [$2])
_CS_CHECK_LIB_CREATE_FLAG(
[$1], [$cs_lib_item], [$cs_lib_item], [$2])
;;
esac
done])
#------------------------------------------------------------------------------
# _CS_CHECK_LIB_CREATE_FLAG(VARIABLE, HEADER-DIR, LIBRARY-DIR, LIBRARY)
# Helper macro for _CS_CHECK_LIB_CREATE_FLAGS(). Constructs build tuples
# suitable for CS_CHECK_BUILD() for given header and library directories,
# and appends the tuples to the shell variable VARIABLE. Synthesizes
# tuples which check for LIBRARY as a MacOS/X framework, and a standard
# link library.
#------------------------------------------------------------------------------
AC_DEFUN([_CS_CHECK_LIB_CREATE_FLAG],
[AS_IF([test -n "$2"], [cs_check_lib_cflag="-I$2"], [cs_check_lib_cflag=''])
AS_IF([test -n "$3"], [cs_check_lib_lflag="-L$3"], [cs_check_lib_lflag=''])
AS_IF([test -n "$4"],
[cs_check_lib_libs="-l$4"
cs_check_lib_framework="-framework $4"],
[cs_check_lib_libs=''
cs_check_lib_framework=''])
$1="$$1
CS_CREATE_TUPLE(
[$cs_check_lib_cflag],
[$cs_check_lib_lflag],
[$cs_check_lib_framework])
CS_CREATE_TUPLE(
[$cs_check_lib_cflag],
[$cs_check_lib_lflag],
[$cs_check_lib_libs])"])
# checklibtool.m4 -*- Autoconf -*-
#==============================================================================
# Copyright (C)2004 by Eric Sunshine <[email protected]>
#
# This library is free software; you can redistribute it and/or modify it
# under the terms of the GNU Library General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This library is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
# License for more details.
#
# You should have received a copy of the GNU Library General Public License
# along with this library; if not, write to the Free Software Foundation,
# Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#==============================================================================
AC_PREREQ([2.56])
#------------------------------------------------------------------------------
# CS_CHECK_LIBTOOL
# Find and identify the various implementations of libtool. In
# particular, this macro is aware of GNU libtool and Apple's libtool
# (which serves a completely different purpose). On MacOS/X, GNU libtool
# is typically named glibtool, however a user might also use Fink to
# install the unadorned libtool; and the Fink-installed version might
# shadow Apple's own libtool if it appears in the PATH before the Apple
# tool. This macro jumps through the necessary hoops to distinguish and
# locate the various implementations. Sets the shell variable LIBTOOL to
# the located GNU libtool (if any), and APPLE_LIBTOOL to the located
# Apple libtool. Invokes AC_SUBST() for LIBTOOL and APPLE_LIBTOOL.
#------------------------------------------------------------------------------
AC_DEFUN([CS_CHECK_LIBTOOL],
[# GNU: Search for libtool before glibtool since Fink version is likely newer.
m4_define([cs_lt_path_gnu],
[/sw/bin$PATH_SEPARATOR/usr/local/bin$PATH_SEPARATOR$PATH])
AS_IF([test -z "$LIBTOOL"],
[CS_CHECK_TOOLS([LIBTOOL_TEST], [libtool glibtool gnulibtool], [],
[cs_lt_path_gnu])
AS_IF([test -n "$LIBTOOL_TEST"],
[CS_PATH_PROG([LIBTOOL_PATH], [$LIBTOOL_TEST], [], [cs_lt_path_gnu])
CS_LIBTOOL_CLASSIFY([$LIBTOOL_PATH],
[LIBTOOL="$LIBTOOL_PATH"],
[AS_IF([test -z "$APPLE_LIBTOOL"], [APPLE_LIBTOOL="$LIBTOOL_PATH"])
CS_CHECK_TOOLS([LIBTOOL], [glibtool gnulibtool])])])])
AC_SUBST([LIBTOOL])
# Apple: Ensure that Apple libtool will be found before GNU libtool from Fink.
m4_define([cs_lt_path_apple],[/bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH])
AS_IF([test -z "$APPLE_LIBTOOL"],
[CS_PATH_PROG([CS_LT_APPLE], [libtool], [], [cs_lt_path_apple])
CS_LIBTOOL_CLASSIFY([$CS_LT_APPLE], [],
[APPLE_LIBTOOL="$CS_LT_APPLE"])])
AC_SUBST([APPLE_LIBTOOL])])
AC_DEFUN([CS_LIBTOOL_CLASSIFY],
[AS_IF([test -n "$1"],
[AC_MSG_CHECKING([classification of $1])
CS_LIBTOOL_GNU_IFELSE([$1],
[AC_MSG_RESULT([gnu])
$2],
[AC_MSG_RESULT([apple])
$3])])])
AC_DEFUN([CS_LIBTOOL_GNU_IFELSE],
[AS_IF([AC_RUN_LOG([$1 --version 1>&2])], [$2], [$3])])
#==============================================================================
# Copyright (C)2003-2006 by Eric Sunshine <[email protected]>
#
# This library is free software; you can redistribute it and/or modify it
# under the terms of the GNU Library General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This library is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
# License for more details.
#
# You should have received a copy of the GNU Library General Public License
# along with this library; if not, write to the Free Software Foundation,
# Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#==============================================================================
AC_PREREQ([2.56])
#------------------------------------------------------------------------------
# CS_CHECK_OPENGL
# Check for OpenGL.
#
# IMPLEMENTATION NOTES
#
# Some Mesa installations require pthread, so pthread flags are employed if
# available.
#
# The check for opengl32 needs to precede other checks because Cygwin users
# often have Mesa installed, and Mesa's OpenGL library is compiled without the
# __stdcall flags which results in link errors, whereas Microsoft's native
# opengl32 works fine. Conversely, some Unix implementations have Wine
# installed (Windows emulation layer) which includes an opengl32.so library.
# We need to avoid detection of this library on Unix since it would cause an
# undesirable dependence upon Wine.
#
# Many OpenGL libraries on Unix already contain GLX, so there is no separate
# GLX library, thus we first check for GLX using the discovered OpenGL library
# before attempting to locate a separate GLX-specific library.
#
# On MacOS/X, some users have XFree86 installed which creates a link from
# /usr/include/GL to /usr/X11R6/include/GL. We want to ignore this directory
# and instead check for Apple's OpenGL.framework, if we are not cross-building
# for Darwin. We accomplish this by placing the OpenGL.framework test ahead of
# the other tests.
#
# At least one user (Jorrit) has a strange installation in which inclusion of
# <windows.h> fails if an int32 is not present, thus we must take this into
# account.
#------------------------------------------------------------------------------
m4_define([cs_define_int32],
[[#if !HAVE_TYPE_INT32
typedef long int32;
#endif
]])
# CS_GL_INCLUDE(CPP-MACRO,FALLBACK,HEADER)
AC_DEFUN([CS_GL_INCLUDE],
[[#if HAVE_WINDOWS_H
#if !HAVE_TYPE_INT32
typedef long int32;
#endif
#include <windows.h>
#endif
#ifndef CS_HEADER_GLOBAL
#define CS_HEADER_GLOBAL(X,Y) CS_HEADER_GLOBAL_COMPOSE(X,Y)
#define CS_HEADER_GLOBAL_COMPOSE(X,Y) <X/Y>
#endif
#ifdef $1
#include CS_HEADER_GLOBAL($1,$3)
#else
#include <$2/$3>
#endif]])
AC_DEFUN([CS_CHECK_OPENGL],
[AC_REQUIRE([CS_CHECK_HOST])
AC_REQUIRE([CS_CHECK_COMMON_LIBS])
AC_REQUIRE([CS_CHECK_PTHREAD])
AC_REQUIRE([AC_PATH_X])
AC_REQUIRE([AC_PATH_XTRA])
AC_CHECK_TYPE([int32], [AC_DEFINE([HAVE_TYPE_INT32], [],
[Whether the int32 type is available])], [])
AC_CHECK_HEADERS([windows.h], [], [], [cs_define_int32])
# Apply plaform-specific flags if necessary.
cs_gl_plat_cflags=''
cs_gl_plat_lflags=''
cs_gl_plat_libs=''
AS_IF([test -n "$cs_cv_libm_cflags$cs_cv_libm_lflags$cs_cv_libm_libs"],
[cs_gl_plat_cflags="$cs_cv_libm_cflags $cs_gl_plat_cflags"
cs_gl_plat_lflags="$cs_cv_libm_lflags $cs_gl_plat_lflags"
cs_gl_plat_libs="$cs_cv_libm_libs $cs_gl_plat_libs"])
AS_IF([test $cs_cv_sys_pthread = yes],
[cs_gl_plat_cflags="$cs_cv_sys_pthread_cflags $cs_gl_plat_cflags"
cs_gl_plat_lflags="$cs_cv_sys_pthread_lflags $cs_gl_plat_lflags"
cs_gl_plat_libs="$cs_cv_sys_pthread_libs $cs_gl_plat_libs"])
AS_IF([test "$no_x" != yes],
[cs_gl_plat_cflags="$X_CFLAGS $cs_gl_plat_cflags"
cs_gl_plat_lflags="$cs_gl_plat_lflags"
cs_gl_plat_libs="
$X_PRE_LIBS $X_LIBS -lX11 -lXext $X_EXTRA_LIBS $cs_gl_plat_libs"])
# Mesa requested?
AC_ARG_WITH([mesa], [AC_HELP_STRING([--with-mesa],
[use Mesa OpenGL library if available (default YES)])],
[], [with_mesa=yes])
AS_IF([test $with_mesa != no],
[cs_mesa_gl=CS_CREATE_TUPLE([],[],[-lMesaGL])])
# MacOS/X or Darwin?
AS_IF([test "x$cs_host_macosx" = "xyes"],
[cs_osx_gl=CS_CREATE_TUPLE([-DCS_OPENGL_PATH=OpenGL],[],[-framework OpenGL])])
AS_IF([test "x$cs_host_macosx" = "xyes"],
[cs_gl_plat_lflags="$cs_plat_lflags -Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib"])
# Windows?
AS_IF([test $cs_host_family = windows],
[cs_win32_gl=CS_CREATE_TUPLE([],[],[-lopengl32])])
# Check for OpenGL.
CS_CHECK_BUILD([for OpenGL], [cs_cv_libgl],
[AC_LANG_PROGRAM([CS_GL_INCLUDE([CS_OPENGL_PATH],[GL],[gl.h])],[glEnd()])],
[$cs_win32_gl \
$cs_osx_gl \
CS_CREATE_TUPLE([],[],[-lGL]) \
CS_CREATE_TUPLE([],[],[-lgl]) \
$cs_mesa_gl], [],
[CS_EMIT_BUILD_RESULT([cs_cv_libgl], [GL])], [], [],
[$cs_gl_plat_cflags], [$cs_gl_plat_lflags], [$cs_gl_plat_libs])])
#------------------------------------------------------------------------------
# CS_CHECK_GLU
# Check for GLU.
#------------------------------------------------------------------------------
AC_DEFUN([CS_CHECK_GLU],
[AC_REQUIRE([CS_CHECK_OPENGL])
AS_IF([test $cs_cv_libgl = yes],
[AS_IF([test $with_mesa != no],
[cs_mesa_glu=CS_CREATE_TUPLE([],[],[-lMesaGLU])])
# MacOS/X or Darwin?
AS_IF([test "x$cs_host_macosx" = "xyes"],
[cs_osx_glu=CS_CREATE_TUPLE([-DCS_GLU_PATH=OpenGL],[],[-framework OpenGL])])
# Windows?
AS_IF([test $cs_host_family = windows],
[cs_win32_glu=CS_CREATE_TUPLE([],[],[-lglu32])])
# Check for GLU.
CS_CHECK_BUILD([for GLU], [cs_cv_libglu],
[AC_LANG_PROGRAM(
[CS_GL_INCLUDE([CS_GLU_PATH],[GL],[glu.h])], [gluNewQuadric()])],
[$cs_osx_glu \
CS_CREATE_TUPLE() \
$cs_win32_glu \
CS_CREATE_TUPLE([],[],[-lGLU]) \
CS_CREATE_TUPLE([],[],[-lglu]) \
$cs_mesa_glu], [],
[CS_EMIT_BUILD_RESULT([cs_cv_libglu], [GLU])], [], [],
[$cs_cv_libgl_cflags], [$cs_cv_libgl_lflags], [$cs_cv_libgl_libs])])])
#------------------------------------------------------------------------------
# CS_CHECK_GLX
# Check for GLX.
#------------------------------------------------------------------------------
AC_DEFUN([CS_CHECK_GLX],
[AC_REQUIRE([CS_CHECK_OPENGL])
AS_IF([test $cs_cv_libgl = yes],
[AS_IF([test $with_mesa != no],
[cs_mesa_glx=CS_CREATE_TUPLE([],[],[-lMesaGLX])])
# Check for GLX.
AS_IF([test "$no_x" != yes],
[CS_CHECK_BUILD([for GLX], [cs_cv_libglx],
[AC_LANG_PROGRAM([[#include <GL/glx.h>]], [glXWaitGL()])],
[CS_CREATE_TUPLE() \
CS_CREATE_TUPLE([],[],[-lGLX]) \
CS_CREATE_TUPLE([],[],[-lglx]) \
$cs_mesa_glx], [],
[CS_EMIT_BUILD_RESULT([cs_cv_libglx], [GLX])], [], [],
[$cs_cv_libgl_cflags], [$cs_cv_libgl_lflags], [$cs_cv_libgl_libs])])])])
#------------------------------------------------------------------------------
# CS_CHECK_GLXEXT([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
# Check for GLX extensions.
#------------------------------------------------------------------------------
AC_DEFUN([CS_CHECK_GLXEXT],
[AC_REQUIRE([CS_CHECK_GLX])
AS_IF([test x$cs_cv_libglx = "xyes"],
[# Check for GLX extensions.
CS_CHECK_BUILD([for GLX extensions], [cs_cv_libglx_extensions],
[AC_LANG_PROGRAM(
[[#define GLX_GLXEXT_PROTOTYPES
#include <GL/glx.h>]],
[glXGetProcAddressARB(0)])],
[CS_CREATE_TUPLE(
[$cs_cv_libglx_cflags],
[$cs_cv_libglx_lflags],
[$cs_cv_libglx_libs])],
[], [$1], [$2])])])
#------------------------------------------------------------------------------
# CS_CHECK_GLUT
# Check for GLUT.
#------------------------------------------------------------------------------
AC_DEFUN([CS_CHECK_GLUT],
[AC_REQUIRE([CS_CHECK_GLU])
AS_IF([test x$cs_cv_libglu = "xyes"],
[# MacOS/X or Darwin?
AS_IF([test "x$cs_host_macosx" = "xyes"],
[cs_osx_glut=CS_CREATE_TUPLE([-DCS_GLUT_PATH=GLUT],[],[-framework GLUT])])
# Windows?
AS_IF([test $cs_host_family = windows],
[cs_win32_glut=CS_CREATE_TUPLE([],[],[-lglut32])])
# Check for GLUT.
CS_CHECK_BUILD([for GLUT], [cs_cv_libglut],
[AC_LANG_PROGRAM(
[CS_GL_INCLUDE([CS_GLUT_PATH],[GL],[glut.h])], [glutSwapBuffers()])],
[$cs_osx_glut \