-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathacinclude.m4
1278 lines (1162 loc) · 36.6 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
dnl
dnl Check for the CYGWIN environment
dnl -------------------------------------------------------------
AC_DEFUN([DX_CYGWIN],
[AC_CACHE_CHECK(for Cygwin environment, ac_cv_cygwin,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
#ifndef __CYGWIN__
#define __CYGWIN__ __CYGWIN32__
#endif
return __CYGWIN__;]])],[ac_cv_cygwin=yes],[ac_cv_cygwin=no])
rm -f conftest*])
CYGWIN=
test "$ac_cv_cygwin" = yes && CYGWIN=yes])
dnl
dnl For intel link, list X libs
dnl ------------------------------------------------------------
AC_DEFUN([DX_XLIBS],
[
AC_SUBST(DX_XLIBS_LIST)
if test "$ARCH" = "intelnt" ; then
DX_XLIBS_LIST="hclglx.lib xm.lib xt.lib xlibcon.lib xlib.lib"
else
DX_XLIBS_LIST=""
fi
])
dnl
dnl If using CYGWIN, then the extensions to the filenames need to be
dnl different than that of UN*X. This sets that up.
dnl
AC_DEFUN([DX_EXEEXT],
[AC_REQUIRE([AC_CANONICAL_HOST])[]dnl
case $host_os in
*cygwin* ) CYGWIN=yes;;
* ) CYGWIN=no;;
esac
AC_MSG_CHECKING([for executable suffix])
AC_PROVIDE([AC_EXEEXT])
AC_CACHE_VAL(ac_cv_exeext,
[if test "$CYGWIN" = yes || test "$MINGW32" = yes; then
ac_cv_exeext=.exe
else
rm -f conftest*
echo 'int main () { return 0; }' > conftest.$ac_ext
ac_cv_exeext=
if AC_TRY_EVAL(ac_link); then
for file in conftest.*; do
case $file in
*.c | *.o | *.obj | *.ilk | *.pdb) ;;
*) ac_cv_exeext=`echo $file | sed -e s/conftest//` ;;
esac
done
else
AC_MSG_ERROR([installation or configuration problem: compiler cannot create executables.])
fi
rm -f conftest*
test x"${ac_cv_exeext}" = x && ac_cv_exeext=no
fi])
EXEEXT=""
test x"${ac_cv_exeext}" != xno && EXEEXT=${ac_cv_exeext}
AC_MSG_RESULT(${ac_cv_exeext})
dnl Setting ac_exeext will implicitly change the ac_link command.
ac_exeext=$EXEEXT
AC_SUBST(EXEEXT)])
dnl
dnl Learn what an object files extension is.
dnl -------------------------------------------------------------
AC_DEFUN([DX_OBJEXT],
[AC_MSG_CHECKING([for object file suffix])
AC_CACHE_VAL(ac_cv_objext,
[
rm -f conftest*
echo 'int main () { return 0; }' > conftest.$ac_ext
ac_cv_objext=
if AC_TRY_EVAL(ac_compile); then
for file in conftest.*; do
case $file in
*.c ) ;;
*) ac_cv_objext=`echo $file | sed -e s/conftest.//` ;;
esac
done
else
AC_MSG_ERROR([installation or configuration problem: compiler cannot create executables.])
fi
rm -f conftest*
test x"${ac_cv_objext}" = x && ac_cv_objext=no
])
OBJEXT=""
test x"${ac_cv_objext}" != xno && OBJEXT=${ac_cv_objext}
AC_MSG_RESULT(${ac_cv_objext})
ac_objext=$OBJEXT
AC_SUBST(OBJEXT)])
dnl
dnl Check the headers for the DX build. This is similar to AC_CHECK_HEADER, but
dnl avoids putting every header in the dxconfig.h file.
dnl -------------------------------------------------------------
AC_DEFUN([DX_CHECK_HEADER],
[dnl Do the transliteration at runtime so arg 1 can be a shell variable.
ac_safe=`echo "$1" | sed 'y%./+-%__p_%'`
AC_MSG_CHECKING([for $1])
AC_CACHE_VAL(ac_cv_header_$ac_safe,
[AC_PREPROC_IFELSE([AC_LANG_SOURCE([[ [#]line __oline__ "configure"
#include "confdefs.h"
#include <$1> ]])],[ eval "ac_cv_header_$ac_safe=yes" ],[ eval "ac_cv_header_$ac_safe=no" ])])dnl
if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
AC_MSG_RESULT(yes)
ifelse([$2], , :, [$2])
else
AC_MSG_RESULT(no)
ifelse([$3], , , [$3
])dnl
fi
])
dnl
dnl Check the headers for the DX build. This is similar to AC_CHECK_HEADERS, but
dnl avoids putting every header in the dxconfig.h file.
dnl -------------------------------------------------------------
AC_DEFUN([DX_CHECK_HEADERS],
[for ac_hdr in $1
do
DX_CHECK_HEADER($ac_hdr,
[changequote(, )dnl
ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
changequote([, ])dnl
AC_DEFINE_UNQUOTED($ac_tr_hdr) $2], $3)dnl
done
])
dnl
dnl Check whether using glibc tgmath, if so add -D_GNU_SOURCE to CFLAGS
dnl -------------------------------------------------------------
AC_DEFUN([DX_CHECK_TGMATH],
[AC_CACHE_CHECK(whether we are using GNU glibc math, ac_cv_lib_glibcmath,
[dnl The semicolon is to pacify NeXT's syntax-checking cpp.
cat > conftest.c <<EOF
/* Because certain platforms using glibc and gcc will not use certain
math functions correctly unless they are using the ISO C 9X standard
we check. If we get a yes, then the define _GNU_SOURCE makes the
compiler add the ISO C 9X support. */
#if defined __GNUC__ && (__GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ >= 7)
yes;
#endif
EOF
if AC_TRY_COMMAND(${CC-cc} -E conftest.c) | egrep yes > foo 2>&1; then
ac_cv_lib_glibcmath=-D_GNU_SOURCE
fi
rm foo
])
if test -n "$ac_cv_lib_glibcmath" ; then
CFLAGS="$CFLAGS $ac_cv_lib_glibcmath"
fi
])
dnl
dnl Determine the architecture that this is being run on.
dnl -------------------------------------------------------------
AC_DEFUN([DX_ARCHITECTURE],
[
AC_MSG_CHECKING(architecture type)
AC_CACHE_VAL(ac_cv_dx_arch,
[
ac_cv_dx_arch=$ARCH
if test "$ARCH" = "" ; then
unameS=`uname -s`
unameM="`uname -m`"
ac_cv_dx_arch=unknown
if test $unameS = "FreeBSD" ; then
ac_cv_dx_arch=freebsd
elif test `echo $unameS | tr A-Z a-z | sed "s/^.*cygwin.*$/yes/"` = "yes" ; then
ac_cv_dx_arch=cygwin
elif test $unameS = "Linux" ; then
ac_cv_dx_arch=linux
elif test $unameS = "IRIX" || test $unameS = "IRIX64" ; then
ac_cv_dx_arch=sgi
elif test $unameS = "AIX" ; then
ac_cv_dx_arch=ibm6000
elif test "$unameM" = "alpha" ; then
ac_cv_dx_arch=alphax
elif test $unameS = "HP-UX" ; then
ac_cv_dx_arch=hp700
elif test $unameS = "SunOS" ; then
ac_cv_dx_arch=solaris
elif test $unameS = "Darwin" ; then
ac_cv_dx_arch=applemacos
fi
fi
])
ARCH=$ac_cv_dx_arch
AC_MSG_RESULT($ARCH)
AC_SUBST(ARCH)
AC_DEFINE_UNQUOTED($ARCH)
AC_DEFINE_UNQUOTED(DXD_ARCHNAME, "$ARCH", [define architecture name])
])
dnl
dnl Set up some architecture specific, primarily to handle AIX's
dnl export flags. (This needs to be fixed if using gcc)
dnl (I added the gcc case)
dnl -------------------------------------------------------------
AC_DEFUN([DX_ARCH_SPECIFIC],
[
AC_MSG_CHECKING(architecture specific stuff)
case $ARCH in
ibm6000)
a=`echo $CC | sed "s/.*gcc.*/YES/"`
if test "$a" = "YES" ; then
CFLAGS="$CFLAGS -mminimal-toc"
CXXFLAGS="$CXXFLAGS -mminimal-toc"
DXEXEC_EXP='-Wl,-bexpall'
DXEXEC_IMP=''
else
DXEXEC_EXP='-bE:$(EXP)'
DXEXEC_IMP='-bI:$(EXP)'
fi
AC_DEFINE_UNQUOTED(DXEXEC_EXP, $DXEXEC_EXP, [Architecture exports])
AC_DEFINE_UNQUOTED(DXEXEC_IMP, $DXEXEC_IMP, [Architecture imports])
;;
cygwin)
DXEXEC_EXP='$(WEXP) -Wl,--out-implib,dxexec.a'
AC_DEFINE_UNQUOTED(DXEXEC_EXP, $DXEXEC_EXP)
;;
intelnt)
DXEXEC_EXP='-def $(WEXP)'
AC_DEFINE_UNQUOTED(DXEXEC_EXP, $DXEXEC_EXP)
;;
linux)
DXEXEC_EXP='-Wl,-export-dynamic'
AC_DEFINE_UNQUOTED(DXEXEC_EXP, $DXEXEC_EXP)
;;
freebsd)
DXEXEC_EXP='-Wl,-export-dynamic'
AC_DEFINE_UNQUOTED(DXEXEC_EXP, $DXEXEC_EXP)
;;
applemacos)
DXUI_ALDFLAGS='-framework CoreFoundation -framework ApplicationServices'
AC_DEFINE_UNQUOTED(DXUI_ALDFLAGS, $DXUI_ALDFLAGS, [Added arch specific LDFLAGS])
;;
esac
AC_MSG_RESULT(done)
])
dnl
dnl It is possible that the optimizer can cause problems with fstream.
dnl Check for this problem.
dnl -------------------------------------------------------------
AC_DEFUN([DX_STREAM_O2],
[
AC_MSG_CHECKING(whether -O2 interferes with fstream in C++)
AC_LANG_PUSH([C++])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <stdio.h>
#include <stdarg.h>
#if HAVE_FSTREAM
#include <fstream>
#elif HAVE_FSTREAM_H
#include <fstream.h>
#endif
using namespace std;
]], [[
ifstream *i = new ifstream("foo");
]])],[AC_MSG_RESULT(no)
],[CXXFLAGS=`echo $CXXFLAGS | sed "s/-O2//"`
AC_MSG_RESULT(yes)
])
AC_LANG_POP([])
])
dnl
dnl See if the lexer produces a file with yylineno defined or if
dnl yylineno should be defined.
dnl -------------------------------------------------------------
AC_DEFUN([DX_LEX_YYLINENO],
[
AC_CACHE_CHECK(lex output file root, ac_cv_prog_lex_root,
[# The minimal lex program is just a single line: %%. But some broken lexes
# (Solaris, I think it was) want two %% lines, so accommodate them.
echo '%%
%%' | $LEX
if test -f lex.yy.c; then
ac_cv_prog_lex_root=lex.yy
elif test -f lexyy.c; then
ac_cv_prog_lex_root=lexyy
else
AC_MSG_ERROR([cannot find output from $LEX; giving up])
fi])
LEX_OUTPUT_ROOT=$ac_cv_prog_lex_root
AC_SUBST(LEX_OUTPUT_ROOT)dnl
AC_MSG_CHECKING(whether yylineno is defined)
cat > conftest.lex <<EOF
%%
test printf( "testing for yylineno" );
%%
int yywrap()
{
return (1);
}
int main()
{
yylineno = 1;
}
EOF
$LEX conftest.lex
ac_save_LIBS=$LIBS
LIBS="$LIBS $LEXLIB"
AC_LINK_IFELSE([`cat $LEX_OUTPUT_ROOT.c`],
[AC_MSG_RESULT(yes)
AC_DEFINE(YYLINENO_DEFINED, 1, [set to 1 if lexer adds yylineno])],
[AC_MSG_RESULT(no)])
LIBS=$ac_save_LIBS
rm -f "${LEX_OUTPUT_ROOT}.c"
rm -f "conftesst.lex"
])
dnl
dnl Check whether header file contains a symbol.
dnl DX_HEADER_HAS_SYMBOL[ header-file, symbol ]
dnl -------------------------------------------------------------
AC_DEFUN([DX_HEADER_HAS_SYMBOL],
[
AC_MSG_CHECKING(whether header file $1 contains symbol $2)
ac_ext=C
found="no"
for i in $1
do
AC_EGREP_CPP(yes,
[#include <$i>
#ifdef $2
yes
#endif
], found="yes")
done
if test $found = "no" ; then
for i in $1
do
AC_EGREP_HEADER($2, $1, found="yes")
done
fi
if test $found = "yes" ; then
AC_DEFINE_UNQUOTED(HAS_$2, 1, [Define to 1 if have symbol $2])
AC_MSG_RESULT("yes")
else
AC_MSG_RESULT("no")
fi
])
dnl
dnl Borrowed from acspecific and modified to add paths to Xm headers
dnl and libs if different from X11
dnl Set xm_includes and/or xm_libraries.
dnl -------------------------------------------------------------
AC_DEFUN([DX_PATH_XM],
[
AC_ARG_WITH(motif-includes, [ --with-motif-includes set path for motif includes (default none)],[with_motif_includes=$withval], [with_motif_includes=''])
if test "$with_motif_includes" != "yes" && test -z "$with_motif_includes"
then
with_motif_includes=''
fi
AC_ARG_WITH(motif-libs, [ --with-motif-libs set path for motif libraries (default none)],[with_motif_libs=$withval], [with_motif_libs=''])
if test "$with_motif_libs" != "yes" && test -z "$with_motif_libs"
then
with_motif_libs=''
fi
# Guess where to find include files, by looking for this one Xm .h file.
test -z "$xm_direct_test_include" && xm_direct_test_include=Xm/Xm.h
# First, try using that file with no special directory specified.
AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <$xm_direct_test_include>]])],[# We can compile using X headers with no special include directory.
xm_includes=],[# Look for the header file in a standard set of common directories.
# Check X11 before X11Rn because it is often a symlink to the current release.
for ac_dir in \
/usr/X11/include \
/usr/X11R6/include \
/usr/X11R5/include \
/usr/X11R4/include \
\
/usr/include/X11 \
/usr/include/X11R6 \
/usr/include/X11R5 \
/usr/include/X11R4 \
\
/usr/local/X11/include \
/usr/local/X11R6/include \
/usr/local/X11R5/include \
/usr/local/X11R4/include \
\
/usr/local/include/X11 \
/usr/local/include/X11R6 \
/usr/local/include/X11R5 \
/usr/local/include/X11R4 \
\
/usr/X386/include \
/usr/x386/include \
/usr/XFree86/include/X11 \
\
/usr/include \
/usr/local/include \
/usr/unsupported/include \
/usr/athena/include \
/usr/local/x11r5/include \
/usr/lpp/Xamples/include \
\
/usr/openwin/include \
/usr/openwin/share/include \
"$with_motif_includes" \
; \
do
if test -r "$ac_dir/$xm_direct_test_include"; then
xm_includes=$ac_dir
break
fi
done])
# Check for the libraries.
test -z "$xm_direct_test_library" && xm_direct_test_library=Xm
test -z "$xm_direct_test_function" && xm_direct_test_function=XmGetDestination
# See if we find them without any special options.
# Don't add to $LIBS permanently.
ac_save_LIBS="$LIBS"
LIBS="-l$xm_direct_test_library $LIBS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[${xm_direct_test_function}()]])],[LIBS="$ac_save_LIBS"
# We can link Motif programs with no special library path.
xm_libraries=],[LIBS="$ac_save_LIBS"
# First see if replacing the include by lib works.
# Check X11 before X11Rn because it is often a symlink to the current release.
for ac_dir in `echo "$xm_includes" | sed s/include/lib/` \
/usr/X11/lib \
/usr/X11R6/lib \
/usr/X11R5/lib \
/usr/X11R4/lib \
\
/usr/lib/X11 \
/usr/lib/X11R6 \
/usr/lib/X11R5 \
/usr/lib/X11R4 \
\
/usr/local/X11/lib \
/usr/local/X11R6/lib \
/usr/local/X11R5/lib \
/usr/local/X11R4/lib \
\
/usr/local/lib/X11 \
/usr/local/lib/X11R6 \
/usr/local/lib/X11R5 \
/usr/local/lib/X11R4 \
\
/usr/X386/lib \
/usr/x386/lib \
/usr/XFree86/lib/X11 \
\
/usr/lib \
/usr/local/lib \
/usr/unsupported/lib \
/usr/athena/lib \
/usr/local/x11r5/lib \
/usr/lpp/Xamples/lib \
/lib/usr/lib/X11 \
\
/usr/openwin/lib \
/usr/openwin/share/lib \
; \
do
dnl Don't even attempt the hair of trying to link an X program!
for ac_extension in a so sl; do
if test -r $ac_dir/lib${xm_direct_test_library}.$ac_extension; then
xm_libraries=$ac_dir
break 2
fi
done
done])
])
dnl
dnl What is the correct function name and structure def stat... stat, or _stat?
dnl
dnl What is the correct function name and structure def stat... stat, or _stat?
dnl -------------------------------------------------------------
AC_DEFUN([DX_CHECK_STAT],
[
AC_LANG_PUSH([C++])
echo "/* */" > statHdrs.h
AC_CHECK_HEADER(windows.h, [ echo "#include <windows.h>" >> statHdrs.h ])
AC_CHECK_HEADER(unistd.h, [ echo "#include <unistd.h>" >> statHdrs.h ])
AC_CHECK_HEADER(sys/types.h, [ echo "#include <sys/types.h>" >> statHdrs.h ])
AC_CHECK_HEADER(sys/stat.h, [ echo "#include <sys/stat.h>" >> statHdrs.h ])
fnc="X"
str="X"
for f in stat _stat ; do
for s in stat _stat ; do
AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <stdlib.h>
#include "statHdrs.h"
]], [[
$f("foo", (struct $s *)0);
]])],[
fnc=$f
str=$s
],[])
done
done
if test "$fnc" = "X" -o "$str" = "X" ; then
echo could not find working combination of stat function and structure
exit
fi
AC_DEFINE_UNQUOTED(STATFUNC, $fnc, [What is the defined stat func])
AC_DEFINE_UNQUOTED(STATSTRUCT, $str, [What is the stat struct])
echo stat function is: $fnc
echo stat structure is: $str
AC_LANG_POP([])
])
dnl
dnl Figure out what the type is needed for the select function.
dnl -------------------------------------------------------------
AC_DEFUN([DX_CHECK_SELECT_ARG],
[
AC_LANG_PUSH([C++])
select_argtype=
cat > selectHdrs.h << EOF
EOF
AC_CHECK_HEADER(windows.h, [ echo "#include <windows.h>" >> selectHdrs.h ])
AC_CHECK_HEADER(unistd.h, [ echo "#include <unistd.h>" >> selectHdrs.h ])
AC_CHECK_HEADER(sys/types.h, [ echo "#include <sys/types.h>" >> selectHdrs.h ])
AC_CHECK_HEADER(select.h, [ echo "#include <select.h>" >> selectHdrs.h ])
AC_CHECK_HEADER(sys/select.h, [ echo "#include <sys/select.h>" >> selectHdrs.h ])
AC_LANG_POP([])
for try in sellist fd_set int void
do
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <stdio.h>
#include "selectHdrs.h"
]], [[
int i = select(1, ($try *)NULL, ($try *)NULL, ($try *)NULL, (struct timeval *)NULL)
]])],[
select_argtype=$try
AC_DEFINE_UNQUOTED(SELECT_ARG_TYPE, $try, [Arguments for select])
],[])
if test ! -z "$select_argtype" ; then
break
fi
done
echo the second third and fourth args to select are pointers to $select_argtype
rm selectHdrs.h
])
dnl
dnl Figure out what the type is needed for getsockname.
dnl -------------------------------------------------------------
AC_DEFUN([DX_CHECK_SOCK_LENGTH_TYPE],
[
AC_LANG_PUSH([C])
socket_argtype=
cat > socketHdrs.h << EOF
EOF
AC_CHECK_HEADER(unistd.h, [ echo "#include <unistd.h>" >> socketHdrs.h ])
AC_CHECK_HEADER(sys/types.h, [ echo "#include <sys/types.h>" >> socketHdrs.h ])
AC_CHECK_HEADER(sys/socket.h, [ echo "#include <sys/socket.h>" >> socketHdrs.h ])
if test "$ARCH" = "intelnt" ; then
AC_CHECK_HEADER(winsock2.h, [ echo "#include <winsock2.h>" >> socketHdrs.h ])
fi
AC_LANG_POP([])
AC_LANG_PUSH([C++])
for try in socklen_t size_t int "unsigned int"
do
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <stdio.h>
#include "socketHdrs.h"
]], [[
$try *foo = NULL;
int i = getsockname(1, (struct sockaddr *)NULL, foo);
]])],[
socket_argtype=$try
AC_DEFINE_UNQUOTED(SOCK_LENGTH_TYPE, $try, [socket length type])
],[])
if test ! -z "$socket_argtype" ; then
break
fi
done
echo the third arg to getsockname is pointer to $socket_argtype
rm socketHdrs.h
AC_LANG_POP([])
])
dnl
dnl More information for setting up CYGWIN
dnl -------------------------------------------------------------
AC_DEFUN([DX_CYGWIN_MOUNTS],
[
changequote(<<,>>)dnl
AC_MSG_CHECKING(if intelnt on cygwin, check for mounts)
mnts="none"
if test "$ARCH" = "intelnt" ; then
tt=`uname -s | tr A-Z a-z | sed "s/^.*cygwin.*$/yes/"`
if test "$tt" = "yes" ; then
AC_MSG_RESULT(yes)
AC_MSG_CHECKING(mounted disks)
mnts="`mount | sed '1d' | grep "^[^cC]:" | sed "s?\(.:\)[ ]*\([^ ][^ ]*\).*?-mount:\2=\1?"`"
if test ! -z "$mnts" ; then
CFLAGS="$CFLAGS $mnts"
CPPFLAGS="$CPPFLAGS $mnts"
CXXFLAGS="$CXXFLAGS $mnts"
else
mnts="none"
fi
AC_MSG_RESULT($mnts)
fi
AC_MSG_RESULT(no)
else
AC_MSG_RESULT(no)
fi
changequote([,])dnl
])
dnl
dnl this is AC_CHECK_TYPE with windows.h for DX intelnt port
dnl -------------------------------------------------------------
AC_DEFUN([DX_CHECK_TYPE],
[
AC_REQUIRE([AC_HEADER_STDC])dnl
AC_MSG_CHECKING(for $1)
AC_CACHE_VAL(ac_cv_type_$1,
[
if test "$ac_cv_header_windows_h" = "yes" ; then
AC_EGREP_CPP(dnl
changequote(<<,>>)dnl
<<[^a-zA-Z_0-9]$1[^a-zA-Z_0-9]>>dnl
changequote([,]),
[
#include <sys/types.h>
#if STDC_HEADERS
#include <stdlib.h>
#include <stddef.h>
#endif
#include <windows.h>
],
ac_cv_type_$1=yes, ac_cv_type_$1=no)
else
AC_EGREP_CPP(dnl
changequote(<<,>>)dnl
<<[^a-zA-Z_0-9]$1[^a-zA-Z_0-9]>>dnl
changequote([,]),
[
#include <sys/types.h>
#if STDC_HEADERS
#include <stdlib.h>
#include <stddef.h>
#endif
],
ac_cv_type_$1=yes, ac_cv_type_$1=no)
fi
if test $ac_cv_type_$1 = no; then
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[$1 foo;]])],[ac_cv_type_$1=yes],[ac_cv_type_$1=no])
fi
])
AC_MSG_RESULT($ac_cv_type_$1)
if test $ac_cv_type_$1 = no; then
AC_DEFINE($1, $2, [Do not define $1 if already have type $1])
fi
])
dnl
dnl Determine whether the stdc++ libraries are needed to compile successfully.
dnl -------------------------------------------------------------
AC_DEFUN([DX_NEEDS_STDCXX],
[
AC_MSG_CHECKING(whether -lstdc++ is needed)
tmpLIBS=$LIBS
AC_CACHE_VAL(ac_cv_requires_lstdcxx,
[
AC_LANG_PUSH([C++])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#ifdef HAVE_IOSTREAM
#include <iostream>
#elif HAVE_IOSTREAM_H
#include <iostream.h>
#endif
]], [[
std::cout << "foo";
]])],[ac_cv_requires_lstdcxx="no"],[
LIBS="$LIBS -lstdc++"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#ifdef HAVE_IOSTREAM
#include <iostream>
#elif HAVE_IOSTREAM_H
#include <iostream.h>
#endif
]],
[[
std::cout << "foo";
]])],
[ac_cv_requires_lstdcxx="yes"],
[
AC_MSG_RESULT(failed even with lstdc++)
exit 1
]
)
])
AC_LANG_POP([])
])
AC_MSG_RESULT(${ac_cv_requires_lstdcxx})
])
dnl Java Stuff ----------------------------------------------------------
dnl Adding the functionality to locate the appropriate Java Architecture
dnl information to compile JavaDX. These functions have been proposed on the
dnl autoconf mailing list.
dnl
dnl For compiling the javadx stuff, we need to have available, the compiler,
dnl the jar packager, the javah generator, the appropriate classes,
dnl and the jni headers.
dnl
dnl After much discussion as to how this info needs to be found, I propose
dnl the following:
dnl JavaC, Jar, and JavaH are being found appropriately--if an appropriate
dnl program exists for one of these types that I'm not checking, please
dnl let me know and it can be added.
dnl The big debate is what to do for the jni and jars. For the jni, the list
dnl has propsed (from my conclusion) the following (LOSE the prompting):
dnl a configure path flag,
dnl search for an environment variable,
dnl then use Pete's old code for searching for it,
dnl then try some standard location (I guesss /usr/include).
dnl As for the jars, Pete had not finished that: so I suggest
dnl a configure path flag,
dnl an environment variable set,
dnl search for standard location (/usr/lib/netscape/java/classes?)
dnl
dnl DX_PROG_JAVAC([ACTION-IF-TRUE [, ACTION-IF-FALSE ]])
dnl -------------------------------------------------------------
AC_DEFUN([DX_PROG_JAVAC],[
AS_MESSAGE([checking for java compiler...])
if test -n "$JAVAC"; then
AC_MSG_WARN(JAVAC was preset)
AC_CHECK_PROG(JAVAC, $JAVAC)
else
AC_CHECK_PROGS(JAVAC, javac "gcj -C" guavac jikes)
fi
if test -z "$JAVAC"; then
AC_MSG_WARN(No java compiler found)
ifelse([$2], , , [$2])
else
DX_PROG_JAVAC_WORKS($JAVAC, $1, $2)
fi
])
dnl
dnl DX_PROG_JAVAC_WORKS(JAVA-COMPILER, [ACTION-IF-TRUE [, ACTION-IF-FALSE]])
dnl This will fail if the CLASSPATH is bad--that is what we want.
dnl -------------------------------------------------------------
AC_DEFUN([DX_PROG_JAVAC_WORKS],[
AC_MSG_CHECKING([if $1 works...])
dx_test_java_classname="dx_conf"
dx_test_java_prog=$dx_test_java_classname".java"
dx_test_java_class=$dx_test_java_classname".class"
cat << EOF_JAVA > $dx_test_java_prog
public class $dx_test_java_classname extends Object {
public static void main() {
}
}
EOF_JAVA
if AC_TRY_COMMAND($1 $dx_test_java_prog) >/dev/null 2>&1; then
AC_MSG_RESULT(yes)
ifelse([$2], , , [$2])
else
AC_MSG_RESULT(no)
ifelse([$3], , , [$3])
AC_MSG_WARN([$1 failed to compile (see config.log, check your CLASSPATH?)])
fi
rm -f $dx_test_java_prog $dx_test_java_class
])
dnl
dnl DX_PROG_JAR([ACTION-IF-TRUE [, ACTION-IF-FALSE ]])
dnl -------------------------------------------------------------
AC_DEFUN([DX_PROG_JAR],[
AS_MESSAGE([checking for jar...])
if test -n "$JAR"; then
AC_MSG_WARN(JAR was preset)
AC_CHECK_PROG(JAR, $JAR)
else
AC_CHECK_PROGS(JAR, jar)
fi
if test -z "$JAR"; then
AC_MSG_WARN([jar class packager not found in \$PATH])
ifelse([$2], , , [$2])
else
ifelse([$1], , , [$1])
fi
])
dnl
dnl DX_PROG_JAVAH([ACTION-IF-TRUE [, ACTION-IF-FALSE ]])
dnl -------------------------------------------------------------
AC_DEFUN([DX_PROG_JAVAH],[
AS_MESSAGE([checking for javah...])
if test -n "$JAVAH"; then
AC_MSG_WARN(JAVAH was preset)
AC_CHECK_PROG(JAVAH, $JAVAH)
else
AC_CHECK_PROGS(JAVAH, javah gcjh)
fi
if test -z "$JAVAH"; then
AC_MSG_WARN([no acceptable jni header generator found in \$PATH])
ifelse([$2], , , [$2])
else
ifelse([$1], , , [$1])
fi
])
dnl
dnl DX_PATH_JAVA([ACTION-IF-TRUE [, ACTION-IF-FALSE ]])
dnl -------------------------------------------------------------
AC_DEFUN([DX_PATH_JAVA],[
if test -n "$JAVA"; then
AC_MSG_WARN(JAVA was preset)
AC_PATH_PROG(JAVA, $JAVAH)
else
AC_PATH_PROGS(JAVA, java)
fi
if test -z "$JAVA"; then
AC_MSG_WARN([no java executable found in \$PATH])
ifelse([$2], , , [$2])
else
DX_JBASE_TRAILING=`echo $JAVA | sed -e "s&.*/&&"`
JBASE=`echo $JAVA | sed -e "s&/$DX_JBASE_TRAILING&&"`
ifelse([$1], , , [$1])
fi
])
dnl
dnl DX_FIND_JNI_WITH_PATH(JNI-PATH,[ACTION-IF-TRUE [, ACTION-IF-FALSE ]])
dnl -------------------------------------------------------------
AC_DEFUN([DX_FIND_JNI_WITH_PATH],
[
AC_MSG_CHECKING([for valid jni headers path])
AC_CACHE_VAL([ac_cv_include_jni],
[
dnl Now we need to perform the search starting at the specified path root.
dnl Need to construct JINC from the given colon separated path, ie $1="/path:/path2" now
dnl needs JINC = "-I/path -I/path ...". Test the directories to see if they exist; if not,
dnl then don't include them. Then look for jni.h and jni_md.h within these directories.
dnl If they don't exist, then do ACTION-IF-FALSE.
dx_jniinc=''
dx_jnimdinc=''
list=`echo $1 | sed -e "s/:/ /g"`
for i in $list
do
if test -r "$i/jni.h" ; then
dx_jniinc=$i
fi
if test -r "$i/jni_md.h" ; then
dx_jnimdinc=$i
fi
done
dnl Now determine how successful the search was and return to configure
if test -n "$dx_jniinc" && test -n "$dx_jnimdinc" ; then
JINC="-I$dx_jniinc -I$dx_jnimdinc"
ac_cv_include_jni="$JINC"
fi
])
if test -z "$ac_cv_include_jni" ; then
AC_MSG_RESULT(no)
ifelse([$3], , , [$3])
else
AC_MSG_RESULT(yes)
ifelse([$2], , , [$2])
if test -z "$JINC"; then
JINC="$ac_cv_include_jni"
fi
fi
])
dnl
dnl DX_JAVA_ARCHITECTURE is similar to DX_ARCHITECTURE, but the result
dnl is used for part of the search path when looking for jni_md.h
dnl This is a problem, since the pathname for linux may not always be
dnl genunix. Workaround is to set JAVA_ARCH (to e.g. linux) before configure.
dnl Could there be a better solution here?
dnl -------------------------------------------------------------
AC_DEFUN([DX_JAVA_ARCHITECTURE],
[
AC_MSG_CHECKING(java architecture type)
if test "$JAVA_ARCH" = "linux" ; then
JNI_CFLAGS=-DIBM_LINUX
fi
# NLS nuisances.
# Needed e.g. for some versions of `tr' so that character classes in `[]' work.
if test "${LC_ALL+set}" = 'set'; then LC_ALL=C ; export LC_ALL ; fi
if test "${LANG+set}" = 'set'; then LANG=C ; export LANG ; fi
changequote(, )dnl
if test "`echo ABC | tr '[A-Z]' '[a-z]'`" = "abc" ; then
tolower="tr '[A-Z]' '[a-z]'"
else
tolower="tr A-Z a-z"
fi
changequote([, ])dnl
if test "$JAVA_ARCH" = "" ; then
lc=`uname -s | $tolower`
case $lc in
irix*) JAVA_ARCH=irix ;;
cygwin*) JAVA_ARCH=win32 ;;
aix) JAVA_ARCH=aix ;;
alpha) JAVA_ARCH=alpha ;;
osf1) JAVA_ARCH=alpha ;;
hp-ux) JAVA_ARCH=hp-ux ;;
sunos) JAVA_ARCH=solaris ;;
linux) JAVA_ARCH=genunix
JNI_CFLAGS=-DIBM_LINUX;;
darwin) JAVA_ARCH=applemacos ;;
*) JAVA_ARCH=$lc ;;
esac
fi
AC_MSG_RESULT($JAVA_ARCH)
])
dnl
dnl DX_FIND_JDK_CLASSES
dnl Only works for sun java. Skips if not "javac".
dnl -------------------------------------------------------------
AC_DEFUN([DX_FIND_JDK_CLASSES], [
dx_find_jdk=""
AC_MSG_CHECKING([for jdk classes])
AC_CACHE_VAL([ac_cv_jdk_classes],
[
ac_cv_jdk_classes=""
dnl We cannot perform the check if not using Sun's javac, so check if javac.
if test "$JAVAC" = "javac" ; then
AC_MSG_RESULT([trying javac -verbose])
dnl Create a basic program and run javac -verbose on it. Only works if
dnl we are using javac, thus test which java.
dnl This should work for both 1.1.x and 1.2.
AC_MSG_CHECKING([for jdk classes verbosely])
cat > jdkpath.java <<EOF
// used to find jdk path via -verbose option to javac
public class jdkpath extends Object {
public static void main() {
}
}
EOF
javac -verbose jdkpath.java >jdkpath.out 2>jdkpath.err
dnl Examine "loaded" line for default classes. Output is similar to
dnl [loaded /usr/jdk_base/lib/classes.zip(java/lang/Object.class) in 738 ms]
dnl Trim off leading stuff and stuff trailing after the left paren to get classes
dnl (classes.zip, rt.jar, whatever) DX_JDK_CLASSES now contains the class
dnl libraries typically used to run and compile with the JRE or JDK. Because
dnl of a bug in some Javas, we need to include this with CLASSPATH environment
dnl variable. (As Of Now--this is IBM's J1.1.8 for rh linux). This appears to be
dnl a problem as it shouldn't need to be included. This will hardcode the
dnl path into runtime areas and could cause problems with upgrades of java.
dnl But as for now this is the way we are going to do it.
ac_cv_jdk_classes=`egrep "loaded|loading" jdkpath.err | tr '\134' '\057' | sed -e "s/.loaded //" -e "s/.loading //" -e "s&(.*$&&"`