Codebase list dx / lintian-fixes/main acinclude.m4
lintian-fixes/main

Tree @lintian-fixes/main (Download .tar.gz)

acinclude.m4 @lintian-fixes/mainraw · history · blame

   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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
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=macos
	    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)
	    ;;
	macos)
	    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=macos ;;
	    *)         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&(.*$&&"`

dnl Cleanup the files that were created.
rm -f jdkpath.*

AC_MSG_RESULT($ac_cv_jdk_classes)
else

AC_MSG_RESULT([none])

fi
dx_find_jdk="yes"
])
if test -z "$dx_find_jdk" ; then
  AC_MSG_RESULT($ac_cv_jdk_classes)
fi
])


dnl
dnl DX_FIND_JNI([ACTION-IF-TRUE [, ACTION-IF-FALSE ]])
dnl  -------------------------------------------------------------
AC_DEFUN([DX_FIND_JNI], [

AC_CACHE_VAL([ac_cv_jdk_base],
[
dnl Now start the search using the java -verbose search algorithm.
dnl Continue on with the search of standard directories [/usr/include].

dnl Find out what system we are on to define $JAVA_ARCH
DX_JAVA_ARCHITECTURE

DX_FIND_JDK_CLASSES

if test -z "$ac_cv_jdk_classes" ; then

dnl Fallback to checking the default paths since it is empty.
  AC_MSG_RESULT([trying default path])
  ac_cv_jdk_base="/usr/include:/usr/include/$JAVA_ARCH"
else

dnl Get anything that isn't between "/"'s
DX_JDK_TRAILING=`echo $ac_cv_jdk_classes | sed -e "s&.*/&&"`

dnl Now trim off /lib/whatever to get to the base of the jdk installation
dnl The result should look something like /usr/jdk_base for 1.1.x and
dnl /usr/jdk_base/jre for 1.2.
DX_ALMOST_BASE=`echo $ac_cv_jdk_classes | sed -e "s&/lib/$DX_JDK_TRAILING&&"`
DX_JBASE=`echo $DX_ALMOST_BASE | sed -e "s&/jre&&"`

dnl Now we need to find the subdirectory within the include directory that
dnl has jni_md.h for the appropriate architecture.

dnl The path that should be used now is DX_JBASE/include and DX_JBASE/include/JAVA_ARCH.
DX_FOUND_PATH="$DX_JBASE/include:$DX_JBASE/include/$JAVA_ARCH"

if test "$JAVA_ARCH" = "macos" ; then
	DX_FOUND_PATH="/System/Library/Frameworks/JavaVM.framework/Headers"
fi

ac_cv_jdk_base="$DX_FOUND_PATH"

fi

dnl  Set a flag to say that we have already answered the MSG.
])
AC_MSG_CHECKING([for jni headers path])
AC_MSG_RESULT($ac_cv_jdk_base)

DX_FIND_JNI_WITH_PATH( $ac_cv_jdk_base, $1, $2)
])


dnl
dnl DX_FIND_COSMO(PATH [, ACTION-IF-TRUE [, ACTION-IF-FALSE ]])
dnl  -------------------------------------------------------------
AC_DEFUN([DX_FIND_COSMO], [
AC_MSG_CHECKING([for cosmo jar files])
AC_CACHE_VAL([ac_cv_class_cosmo],
[ 
if test -r $1; then
  ac_cv_class_cosmo=$1
fi
])
if test -n "$ac_cv_class_cosmo" ; then
  AC_MSG_RESULT(yes)
  ifelse([$2], , , [$2])
else
  AC_MSG_RESULT(no -- comso support will not be complete)
  ifelse([$3], , , [$3])
fi
])


dnl
dnl DX_FIND_DEFAULT_COSMO
dnl  -------------------------------------------------------------
AC_DEFUN([DX_FIND_DEFAULT_COSMO], [

dnl Set the default to be Netscape's default class directory.
dnl   You got a better idea--let us hear about it 
dnl   (opendx-dev@opendx.watson.ibm.com).

DX_FIND_COSMO(/usr/lib/netscape/java/classes/npcosmop211.jar)

])


dnl
dnl DX_FIND_NETSCAPE(PATH [, ACTION-IF-TRUE [, ACTION-IF-FALSE ]])
dnl  -------------------------------------------------------------
AC_DEFUN([DX_FIND_NETSCAPE], [
AC_MSG_CHECKING([for netscape jar files])
AC_CACHE_VAL([ac_cv_class_netscape],
[
if test -r $1; then
  ac_cv_class_netscape=$1
fi
])
if test -n "$ac_cv_class_netscape" ; then
  AC_MSG_RESULT(yes)
  ifelse([$2], , , [$2])
else
  AC_MSG_RESULT(no -- netscape support will not be complete)
  ifelse([$3], , , [$3])
fi
])


dnl
dnl DX_FIND_DEFAULT_NETSCAPE
dnl  -------------------------------------------------------------
AC_DEFUN([DX_FIND_DEFAULT_NETSCAPE], [

dnl Set the default to be Netscape's default class directory.
dnl   You got a better idea--let us hear about it 
dnl   (opendx-dev@opendx.watson.ibm.com).

DX_FIND_NETSCAPE(/usr/lib/netscape/java/classes/java40.jar)

])


dnl End of the JavaDX stuff -------------------------------------------------

dnl  
dnl  With the architecture determine flags needed to compile runtime loadable modules etc.
dnl  -------------------------------------------------------------
AC_DEFUN([DX_SET_RTL_FLAGS],
[
dnl autoconfigure variables for building runtime loadables / shared objects that are
dnl used in dx build. They also go into lib_$(ARCH)/arch.mak for building samples and user modules.
dnl These should make it trivial for dx builder or you to construct functional, platform-independent 
dnl makefiles for your modules.
dnl SHARED_LINK
dnl	allows override of default ($(CC)) with e.g. ld ; some cc's seem incapable of passing 
dnl	make-shared-object flags to ld.
dnl DX_RTL_CFLAGS 
dnl	ideally, this, $(DXABI) and -I's should be all $(CC) requires to make the .o .
dnl DX_RTL_ALDFLAGS 
dnl	ld flags (prefixed with cc-pass-these-to-ld if SHARED_LINK is a cc) for building any shared object
dnl DX_RTL_DXENTRY
dnl	flags, typically -e DXEntry , the runtime loadable dx module entry point
dnl	not generic to all shared objects
dnl DX_RTL_IMPORTS
dnl	frequently unnecessary, this flag is for declaring dxexec symbols to the runtime loadable module.
dnl	not generic to all shared objects

dnl don't require SHARED_LINK to be set going in, but if set, it overrides any selection here.
	ccld_defaulted=0
	if test "$SHARED_LINK" = "" ; then
		SHARED_LINK="$""(CC)"
		ccld_defaulted=1
	fi
	DX_RTL_SYSLIBS=""
        if test $ac_cv_c_compiler_gnu = "yes" ; then
                MDXLDFLAG="-Wl,"
        else
                MDXLDFLAG=""
        fi
        if test $ARCH = "intelnt" ; then
                DX_RTL_IMPORTS=
                DX_RTL_CFLAGS="-shared -e DXEntry"
        fi
        if test $ARCH = "cygwin" ; then
                DX_RTL_CFLAGS="-shared "
		DX_RTL_DXENTRY="${MDXLDFLAG}-e,DXEntry"
		DX_RTL_IMPORTS="\$(BASE)/lib_$ARCH/dxexec.a"
                DX_RTL_SYSLIBS="$SYSLIBS kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib wsock32.lib"
                DX_OUTBOARD_LIBS="$OLIBS \$(BASE)/lib/DXExport.lib"
        fi
        if test $ARCH = "hp700" ; then
                DX_RTL_CFLAGS="-Dhp700 -Aa +z"
                DX_RTL_ALDFLAGS="${MDXLDFLAG}-q ${MDXLDFLAG}-b ${MDXLDFLAG}-E "
		DX_RTL_DXENTRY="${MDXLDFLAG}-eDXEntry"
                DX_RTL_SYSLIBS="$SYSLIBS -ldld"
        fi
        if test $ARCH = "ibm6000" ; then
                DX_RTL_CFLAGS="-Dibm6000"
                DX_RTL_DXENTRY="${MDXLDFLAG}-eDXEntry "
		DX_RTL_ALDFLAGS=
		DX_RTL_IMPORT="${MDXLDFLAG}-bI:\$(BASE)/lib/dxexec.exp"
        fi
        if test $ARCH = "sgi" ; then
                DX_RTL_CFLAGS=" -Dsgi"
        	if test $ac_cv_c_compiler_gnu = "yes" ; then
			DX_RTL_CFLAGS=" -Dsgi -D_GNU_SOURCE"
                	DX_RTL_ALDFLAGS=" -shared"
			DX_RTL_DXENTRY=" -e DXEntry -exported_symbol DXEntry"
			if test $ccld_defaulted != 0 ; then 
				SHARED_LINK="ld"
			fi
        	else
                	DX_RTL_ALDFLAGS=" -shared -ignore_unresolved "
			if test $ccld_defaulted != 0 ; then
				SHARED_LINK=$CC
			fi
        	fi

        fi
        if test $ARCH = "solaris" ; then
                DX_RTL_CFLAGS=" -Dsolaris"
                # DX_RTL_ALDFLAGS=" ${MDXLDFLAG}-G ${MDXLDFLAG}-eDXEntry"
                DX_RTL_ALDFLAGS=" -G "
		SHARED_LINK="cc"
        fi
        if test $ARCH = "alphax" ; then
                DX_RTL_CFLAGS=" -Dalphax"
                DX_RTL_ALDFLAGS=" -shared -all -expect_unresolved main "
                DX_RTL_DXENTRY=" -e DXEntry"
                DX_RTL_IMPORTS=" -expect_unresolved DX\*"
        fi
        if test $ARCH = "linux" ; then
                DX_RTL_CFLAGS=" -D_GNU_SOURCE -Dlinux"
                DX_RTL_ALDFLAGS="-fPIC -shared"
		DX_RTL_DXENTRY=" -eDXEntry"
        fi
        if test $ARCH = "freebsd" ; then
                DX_RTL_CFLAGS="-D_GNU_SOURCE -Dfreebsd"
                DX_RTL_ALDFLAGS="--shared "
		DX_RTL_DXENTRY="-eDXEntry"
        fi
])

#
# autoconf macro to remove duplicated elements in a list, but to leave
# in place only the *last* occurence of each duplicate element.
# Intended for use with lists of -l args, and the like.
#
# usage: AC_UTILS_UNIQUIFY([list],[shell-var-to-set-to-uniquified-list])

AC_DEFUN([AC_UTILS_UNIQUIFY],
[
ac_u_bar=""
for arg in $1 ; do
changequote(<<,>>)dnl
	x=`echo $arg | tr -dc '[:alnum:]'`
changequote([,])dnl
	eval test x\${ac_u_$x} = x;
	if test $? = 0 ; then
		eval ac_u_$x=1
		export eval ac_u_$x
	else
		eval ac_u_$x=\`expr \${ac_u_$x} + 1\`
		export eval ac_u_$x
	fi
done

for arg in $1 ; do
changequote(<<,>>)dnl
	x=`echo $arg | tr -dc '[:alnum:]'`
changequote([,])dnl
	eval ac_u_${x}=\`expr \${ac_u_$x} - 1\`
	eval test \$ac_u_${x} = 0;
	if test $? = 0 ; then
		ac_u_bar="$ac_u_bar $arg"
	fi
done
$2="$ac_u_bar"
])