146283Sdfrdnl written by Rob Savoye <rob@cygnus.com> for Cygnus Support
246283Sdfrdnl major rewriting for Tcl 7.5 by Don Libes <libes@nist.gov>
346283Sdfr
446283Sdfrdnl gdb/configure.in uses BFD_NEED_DECLARATION, so get its definition.
546283Sdfrsinclude(../bfd/acinclude.m4)
646283Sdfr
746283Sdfrdnl This gets the standard macros, like the TCL, TK, etc ones.
846283Sdfrsinclude(../config/acinclude.m4)
946283Sdfr
1046283Sdfrdnl CYGNUS LOCAL: This gets the right posix flag for gcc
1146283SdfrAC_DEFUN(CY_AC_TCL_LYNX_POSIX,
1246283Sdfr[AC_REQUIRE([AC_PROG_CC])AC_REQUIRE([AC_PROG_CPP])
1346283SdfrAC_MSG_CHECKING([if running LynxOS])
1446283SdfrAC_CACHE_VAL(ac_cv_os_lynx,
1546283Sdfr[AC_EGREP_CPP(yes,
1646283Sdfr[/*
1746283Sdfr * The old Lynx "cc" only defines "Lynx", but the newer one uses "__Lynx__"
1846283Sdfr */
1946283Sdfr#if defined(__Lynx__) || defined(Lynx)
2046283Sdfryes
2146283Sdfr#endif
2246283Sdfr], ac_cv_os_lynx=yes, ac_cv_os_lynx=no)])
2346283Sdfr#
2446283Sdfrif test "$ac_cv_os_lynx" = "yes" ; then
2546283Sdfr  AC_MSG_RESULT(yes)
2646283Sdfr  AC_DEFINE(LYNX)
2746283Sdfr  AC_MSG_CHECKING([whether -mposix or -X is available])
2846283Sdfr  AC_CACHE_VAL(ac_cv_c_posix_flag,
2946283Sdfr  [AC_TRY_COMPILE(,[
3046283Sdfr  /*
3146283Sdfr   * This flag varies depending on how old the compiler is.
3246283Sdfr   * -X is for the old "cc" and "gcc" (based on 1.42).
3346283Sdfr   * -mposix is for the new gcc (at least 2.5.8).
3446283Sdfr   */
3546283Sdfr  #if defined(__GNUC__) && __GNUC__ >= 2
3646283Sdfr  choke me
3746283Sdfr  #endif
3846283Sdfr  ], ac_cv_c_posix_flag=" -mposix", ac_cv_c_posix_flag=" -X")])
3946283Sdfr  CC="$CC $ac_cv_c_posix_flag"
4046283Sdfr  AC_MSG_RESULT($ac_cv_c_posix_flag)
4146283Sdfr  else
4246283Sdfr  AC_MSG_RESULT(no)
4346283Sdfrfi
4446283Sdfr])
4546283Sdfr
4646283Sdfr#
4746283Sdfr# Sometimes the native compiler is a bogus stub for gcc or /usr/ucb/cc. This
4846283Sdfr# makes configure think it's cross compiling. If --target wasn't used, then
4946283Sdfr# we can't configure, so something is wrong. We don't use the cache
5046283Sdfr# here cause if somebody fixes their compiler install, we want this to work.
5146283SdfrAC_DEFUN(CY_AC_C_WORKS,
5246283Sdfr[# If we cannot compile and link a trivial program, we can't expect anything to work
5346283SdfrAC_MSG_CHECKING(whether the compiler ($CC) actually works)
5446283SdfrAC_TRY_COMPILE(, [/* don't need anything here */],
5546283Sdfr        c_compiles=yes, c_compiles=no)
5646283Sdfr
5746283SdfrAC_TRY_LINK(, [/* don't need anything here */],
5846283Sdfr        c_links=yes, c_links=no)
5946283Sdfr
6046283Sdfrif test x"${c_compiles}" = x"no" ; then
6146283Sdfr  AC_MSG_ERROR(the native compiler is broken and won't compile.)
6246283Sdfrfi
6346283Sdfr
6446283Sdfrif test x"${c_links}" = x"no" ; then
6546283Sdfr  AC_MSG_ERROR(the native compiler is broken and won't link.)
6646283Sdfrfi
6746283SdfrAC_MSG_RESULT(yes)
6846283Sdfr])
6946283Sdfr
7046283SdfrAC_DEFUN(CY_AC_PATH_TCLH, [
7146283Sdfr#
7246283Sdfr# Ok, lets find the tcl source trees so we can use the headers
7346283Sdfr# Warning: transition of version 9 to 10 will break this algorithm
7446283Sdfr# because 10 sorts before 9. We also look for just tcl. We have to
7546283Sdfr# be careful that we don't match stuff like tclX by accident.
7646283Sdfr# the alternative search directory is involked by --with-tclinclude
7746283Sdfr#
7846283Sdfr
7946283Sdfrno_tcl=true
8046283SdfrAC_MSG_CHECKING(for Tcl private headers. dir=${configdir})
8146283SdfrAC_ARG_WITH(tclinclude, [  --with-tclinclude=DIR   Directory where tcl private headers are], with_tclinclude=${withval})
8246283SdfrAC_CACHE_VAL(ac_cv_c_tclh,[
8346283Sdfr# first check to see if --with-tclinclude was specified
8446283Sdfrif test x"${with_tclinclude}" != x ; then
8546283Sdfr  if test -f ${with_tclinclude}/tclInt.h ; then
8646283Sdfr    ac_cv_c_tclh=`(cd ${with_tclinclude}; pwd)`
8746283Sdfr  elif test -f ${with_tclinclude}/generic/tclInt.h ; then
8846283Sdfr    ac_cv_c_tclh=`(cd ${with_tclinclude}/generic; pwd)`
8946283Sdfr  else
9046283Sdfr    AC_MSG_ERROR([${with_tclinclude} directory doesn't contain private headers])
9146283Sdfr  fi
9246283Sdfrfi
9346283Sdfr
9446283Sdfr# next check if it came with Tcl configuration file
9546283Sdfrif test x"${ac_cv_c_tclconfig}" = x ; then
9646283Sdfr  if test -f $ac_cv_c_tclconfig/../generic/tclInt.h ; then
9746283Sdfr    ac_cv_c_tclh=`(cd $ac_cv_c_tclconfig/..; pwd)`
9846283Sdfr  fi
9946283Sdfrfi
10046283Sdfr
10146283Sdfr# next check in private source directory
10246283Sdfr#
10346283Sdfr# since ls returns lowest version numbers first, reverse its output
10446283Sdfrif test x"${ac_cv_c_tclh}" = x ; then
10546283Sdfr  for i in \
10646283Sdfr		${srcdir}/../tcl \
10746283Sdfr		`ls -dr ${srcdir}/../tcl[[7-9]]* 2>/dev/null` \
10846283Sdfr		${srcdir}/../../tcl \
10946283Sdfr		`ls -dr ${srcdir}/../../tcl[[7-9]]* 2>/dev/null` \
11046283Sdfr		${srcdir}/../../../tcl \
11146283Sdfr		`ls -dr ${srcdir}/../../../tcl[[7-9]]* 2>/dev/null ` ; do
11246283Sdfr    if test -f $i/generic/tclInt.h ; then
11346283Sdfr      ac_cv_c_tclh=`(cd $i/generic; pwd)`
11446283Sdfr      break
11546283Sdfr    fi
11646283Sdfr  done
11746283Sdfrfi
11846283Sdfr# finally check in a few common install locations
11946283Sdfr#
12046283Sdfr# since ls returns lowest version numbers first, reverse its output
12146283Sdfrif test x"${ac_cv_c_tclh}" = x ; then
12246283Sdfr  for i in \
12346283Sdfr		`ls -dr /usr/local/src/tcl[[7-9]]* 2>/dev/null` \
12446283Sdfr		`ls -dr /usr/local/lib/tcl[[7-9]]* 2>/dev/null` \
12546283Sdfr		/usr/local/src/tcl \
12646283Sdfr		/usr/local/lib/tcl \
12746283Sdfr		${prefix}/include ; do
12846283Sdfr    if test -f $i/generic/tclInt.h ; then
12946283Sdfr      ac_cv_c_tclh=`(cd $i/generic; pwd)`
13046283Sdfr      break
13146283Sdfr    fi
13246283Sdfr  done
13346283Sdfrfi
13446283Sdfr# see if one is installed
13546283Sdfrif test x"${ac_cv_c_tclh}" = x ; then
13646283Sdfr   AC_HEADER_CHECK(tclInt.h, ac_cv_c_tclh=installed, ac_cv_c_tclh="")
13746283Sdfrfi
13846283Sdfr])
13946283Sdfrif test x"${ac_cv_c_tclh}" = x ; then
14046283Sdfr  TCLHDIR="# no Tcl private headers found"
14146283Sdfr  AC_MSG_ERROR([Can't find Tcl private headers])
14246283Sdfrfi
14346283Sdfrif test x"${ac_cv_c_tclh}" != x ; then
14446283Sdfr  no_tcl=""
14546283Sdfr  if test x"${ac_cv_c_tclh}" = x"installed" ; then
14646283Sdfr    AC_MSG_RESULT([is installed])
14746283Sdfr    TCLHDIR=""
14846283Sdfr  else
14946283Sdfr    AC_MSG_RESULT([found in ${ac_cv_c_tclh}])
15046283Sdfr    # this hack is cause the TCLHDIR won't print if there is a "-I" in it.
15146283Sdfr    TCLHDIR="-I${ac_cv_c_tclh}"
15246283Sdfr  fi
15346283Sdfrfi
15446283Sdfr
15546283SdfrAC_SUBST(TCLHDIR)
15646283Sdfr])
15746283Sdfr
15846283Sdfr
15946283SdfrAC_DEFUN(CY_AC_PATH_TCLCONFIG, [
16046283Sdfr#
16146283Sdfr# Ok, lets find the tcl configuration
16246283Sdfr# First, look for one uninstalled.  
16346283Sdfr# the alternative search directory is invoked by --with-tclconfig
16446283Sdfr#
16546283Sdfr
16646283Sdfrif test x"${no_tcl}" = x ; then
16746283Sdfr  # we reset no_tcl in case something fails here
16846283Sdfr  no_tcl=true
16946283Sdfr  AC_ARG_WITH(tclconfig, [  --with-tclconfig=DIR    Directory containing tcl configuration (tclConfig.sh)],
17046283Sdfr         with_tclconfig=${withval})
17146283Sdfr  AC_MSG_CHECKING([for Tcl configuration])
17246283Sdfr  AC_CACHE_VAL(ac_cv_c_tclconfig,[
17346283Sdfr
17446283Sdfr  # First check to see if --with-tclconfig was specified.
17546283Sdfr  if test x"${with_tclconfig}" != x ; then
17646283Sdfr    if test -f "${with_tclconfig}/tclConfig.sh" ; then
17746283Sdfr      ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
17846283Sdfr    else
17946283Sdfr      AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh])
18046283Sdfr    fi
18146283Sdfr  fi
18246283Sdfr
18346283Sdfr  # then check for a private Tcl installation
18446283Sdfr  if test x"${ac_cv_c_tclconfig}" = x ; then
18546283Sdfr    for i in \
18646283Sdfr		../tcl \
18746283Sdfr		`ls -dr ../tcl[[7-9]]* 2>/dev/null` \
18846283Sdfr		../../tcl \
18946283Sdfr		`ls -dr ../../tcl[[7-9]]* 2>/dev/null` \
19046283Sdfr		../../../tcl \
19146283Sdfr		`ls -dr ../../../tcl[[7-9]]* 2>/dev/null` ; do
19246283Sdfr      if test -f "$i/${configdir}/tclConfig.sh" ; then
19346283Sdfr        ac_cv_c_tclconfig=`(cd $i/${configdir}; pwd)`
19446283Sdfr	break
19546283Sdfr      fi
19646283Sdfr    done
19746283Sdfr  fi
19846283Sdfr  # check in a few common install locations
19946283Sdfr  if test x"${ac_cv_c_tclconfig}" = x ; then
20046283Sdfr    for i in `ls -d ${prefix}/lib /usr/local/lib 2>/dev/null` ; do
20146283Sdfr      if test -f "$i/tclConfig.sh" ; then
20246283Sdfr        ac_cv_c_tclconfig=`(cd $i; pwd)`
20346283Sdfr	break
20446283Sdfr      fi
20546283Sdfr    done
20646283Sdfr  fi
20746283Sdfr  # check in a few other private locations
20846283Sdfr  if test x"${ac_cv_c_tclconfig}" = x ; then
20946283Sdfr    for i in \
21046283Sdfr		${srcdir}/../tcl \
21146283Sdfr		`ls -dr ${srcdir}/../tcl[[7-9]]* 2>/dev/null` ; do
21246283Sdfr      if test -f "$i/${configdir}/tclConfig.sh" ; then
21346283Sdfr        ac_cv_c_tclconfig=`(cd $i/${configdir}; pwd)`
21446283Sdfr	break
21546283Sdfr      fi
21646283Sdfr    done
21746283Sdfr  fi
21846283Sdfr  ])
21946283Sdfr  if test x"${ac_cv_c_tclconfig}" = x ; then
22046283Sdfr    TCLCONFIG="# no Tcl configs found"
22146283Sdfr    AC_MSG_WARN(Can't find Tcl configuration definitions)
22246283Sdfr  else
22346283Sdfr    no_tcl=
22446283Sdfr    TCLCONFIG=${ac_cv_c_tclconfig}/tclConfig.sh
22546283Sdfr    AC_MSG_RESULT(found $TCLCONFIG)
22646283Sdfr  fi
22746283Sdfrfi
22846283Sdfr])
22946283Sdfr
23046283Sdfr# Defined as a separate macro so we don't have to cache the values
23146283Sdfr# from PATH_TCLCONFIG (because this can also be cached).
23246283SdfrAC_DEFUN(CY_AC_LOAD_TCLCONFIG, [
23346283Sdfr    . $TCLCONFIG
23446283Sdfr
23546283Sdfr    AC_SUBST(TCL_VERSION)
23646283Sdfr    AC_SUBST(TCL_MAJOR_VERSION)
23746283Sdfr    AC_SUBST(TCL_MINOR_VERSION)
23846283Sdfr    AC_SUBST(TCL_CC)
23946283Sdfr    AC_SUBST(TCL_DEFS)
24046283Sdfr
24146283Sdfrdnl not used, don't export to save symbols
24246283Sdfrdnl    AC_SUBST(TCL_LIB_FILE)
24346283Sdfr
24446283Sdfrdnl don't export, not used outside of configure
24546283Sdfrdnl     AC_SUBST(TCL_LIBS)
24646283Sdfrdnl not used, don't export to save symbols
24746283Sdfrdnl    AC_SUBST(TCL_PREFIX)
24846283Sdfr
24946283Sdfrdnl not used, don't export to save symbols
25046283Sdfrdnl    AC_SUBST(TCL_EXEC_PREFIX)
25146283Sdfr
25246283Sdfr    AC_SUBST(TCL_SHLIB_CFLAGS)
25346283Sdfr    AC_SUBST(TCL_SHLIB_LD)
25446283Sdfrdnl don't export, not used outside of configure
25546283Sdfr    AC_SUBST(TCL_SHLIB_LD_LIBS)
25646283Sdfr    AC_SUBST(TCL_SHLIB_SUFFIX)
25746283Sdfrdnl not used, don't export to save symbols
25846283Sdfr    AC_SUBST(TCL_DL_LIBS)
25946283Sdfr    AC_SUBST(TCL_LD_FLAGS)
26046283Sdfrdnl don't export, not used outside of configure
26146283Sdfr    AC_SUBST(TCL_LD_SEARCH_FLAGS)
262130803Smarcel    AC_SUBST(TCL_CC_SEARCH_FLAGS)
26346283Sdfr    AC_SUBST(TCL_COMPAT_OBJS)
26446283Sdfr    AC_SUBST(TCL_RANLIB)
26546283Sdfr    AC_SUBST(TCL_BUILD_LIB_SPEC)
26646283Sdfr    AC_SUBST(TCL_LIB_SPEC)
26746283Sdfr    AC_SUBST(TCL_LIB_VERSIONS_OK)
26846283Sdfr
26946283Sdfrdnl not used, don't export to save symbols
27046283Sdfrdnl    AC_SUBST(TCL_SHARED_LIB_SUFFIX)
27146283Sdfr
27246283Sdfrdnl not used, don't export to save symbols
27346283Sdfrdnl    AC_SUBST(TCL_UNSHARED_LIB_SUFFIX)
27446283Sdfr])
27546283Sdfr
27646283Sdfr# Warning: Tk definitions are very similar to Tcl definitions but
27746283Sdfr# are not precisely the same.  There are a couple of differences,
27846283Sdfr# so don't do changes to Tcl thinking you can cut and paste it do 
27946283Sdfr# the Tk differences and later simply substitute "Tk" for "Tcl".
28046283Sdfr# Known differences:
28146283Sdfr#  - Acceptable Tcl major version #s is 7-9 while Tk is 4-9
28246283Sdfr#  - Searching for Tcl includes looking for tclInt.h, Tk looks for tk.h
28346283Sdfr#  - Computing major/minor versions is different because Tk depends on
28446283Sdfr#    headers to Tcl, Tk, and X.
28546283Sdfr#  - Symbols in tkConfig.sh are different than tclConfig.sh
28646283Sdfr#  - Acceptable for Tk to be missing but not Tcl.
28746283Sdfr
28846283SdfrAC_DEFUN(CY_AC_PATH_TKH, [
28946283Sdfr#
29046283Sdfr# Ok, lets find the tk source trees so we can use the headers
29146283Sdfr# If the directory (presumably symlink) named "tk" exists, use that one
29246283Sdfr# in preference to any others.  Same logic is used when choosing library
29346283Sdfr# and again with Tcl. The search order is the best place to look first, then in
29446283Sdfr# decreasing significance. The loop breaks if the trigger file is found.
29546283Sdfr# Note the gross little conversion here of srcdir by cd'ing to the found
29646283Sdfr# directory. This converts the path from a relative to an absolute, so
29746283Sdfr# recursive cache variables for the path will work right. We check all
29846283Sdfr# the possible paths in one loop rather than many seperate loops to speed
29946283Sdfr# things up.
30046283Sdfr# the alternative search directory is involked by --with-tkinclude
30146283Sdfr#
30246283Sdfrno_tk=true
30346283SdfrAC_MSG_CHECKING(for Tk private headers)
30446283SdfrAC_ARG_WITH(tkinclude, [  --with-tkinclude=DIR    Directory where tk private headers are], with_tkinclude=${withval})
30546283SdfrAC_CACHE_VAL(ac_cv_c_tkh,[
30646283Sdfr# first check to see if --with-tkinclude was specified
30746283Sdfrif test x"${with_tkinclude}" != x ; then
30846283Sdfr  if test -f ${with_tkinclude}/tk.h ; then
30946283Sdfr    ac_cv_c_tkh=`(cd ${with_tkinclude}; pwd)`
31046283Sdfr  elif test -f ${with_tkinclude}/generic/tk.h ; then
31146283Sdfr    ac_cv_c_tkh=`(cd ${with_tkinclude}/generic; pwd)`
31246283Sdfr  else
31346283Sdfr    AC_MSG_ERROR([${with_tkinclude} directory doesn't contain private headers])
31446283Sdfr  fi
31546283Sdfrfi
31646283Sdfr
31746283Sdfr# next check if it came with Tk configuration file
31846283Sdfrif test x"${ac_cv_c_tkconfig}" = x ; then
31946283Sdfr  if test -f $ac_cv_c_tkconfig/../generic/tk.h ; then
32046283Sdfr    ac_cv_c_tkh=`(cd $ac_cv_c_tkconfig/..; pwd)`
32146283Sdfr  fi
32246283Sdfrfi
32346283Sdfr
32446283Sdfr# next check in private source directory
32546283Sdfr#
32646283Sdfr# since ls returns lowest version numbers first, reverse its output
32746283Sdfrif test x"${ac_cv_c_tkh}" = x ; then
32846283Sdfr  for i in \
32946283Sdfr		${srcdir}/../tk \
33046283Sdfr		`ls -dr ${srcdir}/../tk[[4-9]]* 2>/dev/null` \
33146283Sdfr		${srcdir}/../../tk \
33246283Sdfr		`ls -dr ${srcdir}/../../tk[[4-9]]* 2>/dev/null` \
33346283Sdfr		${srcdir}/../../../tk \
33446283Sdfr		`ls -dr ${srcdir}/../../../tk[[4-9]]* 2>/dev/null ` ; do
33546283Sdfr    if test -f $i/generic/tk.h ; then
33646283Sdfr      ac_cv_c_tkh=`(cd $i/generic; pwd)`
33746283Sdfr      break
33846283Sdfr    fi
33946283Sdfr  done
34046283Sdfrfi
34146283Sdfr# finally check in a few common install locations
34246283Sdfr#
34346283Sdfr# since ls returns lowest version numbers first, reverse its output
34446283Sdfrif test x"${ac_cv_c_tkh}" = x ; then
34546283Sdfr  for i in \
34646283Sdfr		`ls -dr /usr/local/src/tk[[4-9]]* 2>/dev/null` \
34746283Sdfr		`ls -dr /usr/local/lib/tk[[4-9]]* 2>/dev/null` \
34846283Sdfr		/usr/local/src/tk \
34946283Sdfr		/usr/local/lib/tk \
35046283Sdfr		${prefix}/include ; do
35146283Sdfr    if test -f $i/generic/tk.h ; then
35246283Sdfr      ac_cv_c_tkh=`(cd $i/generic; pwd)`
35346283Sdfr      break
35446283Sdfr    fi
35546283Sdfr  done
35646283Sdfrfi
35746283Sdfr# see if one is installed
35846283Sdfrif test x"${ac_cv_c_tkh}" = x ; then
35946283Sdfr   AC_HEADER_CHECK(tk.h, ac_cv_c_tkh=installed, ac_cv_c_tkh="")
36046283Sdfrfi
36146283Sdfr])
36246283Sdfrif test x"${ac_cv_c_tkh}" != x ; then
36346283Sdfr  no_tk=""
36446283Sdfr  if test x"${ac_cv_c_tkh}" = x"installed" ; then
36546283Sdfr    AC_MSG_RESULT([is installed])
36646283Sdfr    TKHDIR=""
36746283Sdfr  else
36846283Sdfr    AC_MSG_RESULT([found in ${ac_cv_c_tkh}])
36946283Sdfr    # this hack is cause the TKHDIR won't print if there is a "-I" in it.
37046283Sdfr    TKHDIR="-I${ac_cv_c_tkh}"
37146283Sdfr  fi
37246283Sdfrelse
37346283Sdfr  TKHDIR="# no Tk directory found"
37446283Sdfr  AC_MSG_WARN([Can't find Tk private headers])
37546283Sdfr  no_tk=true
37646283Sdfrfi
37746283Sdfr
37846283SdfrAC_SUBST(TKHDIR)
37946283Sdfr])
38046283Sdfr
38146283Sdfr
38246283SdfrAC_DEFUN(CY_AC_PATH_TKCONFIG, [
38346283Sdfr#
38446283Sdfr# Ok, lets find the tk configuration
38546283Sdfr# First, look for one uninstalled.  
38646283Sdfr# the alternative search directory is invoked by --with-tkconfig
38746283Sdfr#
38846283Sdfr
38946283Sdfrif test x"${no_tk}" = x ; then
39046283Sdfr  # we reset no_tk in case something fails here
39146283Sdfr  no_tk=true
39246283Sdfr  AC_ARG_WITH(tkconfig, [  --with-tkconfig=DIR     Directory containing tk configuration (tkConfig.sh)],
39346283Sdfr         with_tkconfig=${withval})
39446283Sdfr  AC_MSG_CHECKING([for Tk configuration])
39546283Sdfr  AC_CACHE_VAL(ac_cv_c_tkconfig,[
39646283Sdfr
39746283Sdfr  # First check to see if --with-tkconfig was specified.
39846283Sdfr  if test x"${with_tkconfig}" != x ; then
39946283Sdfr    if test -f "${with_tkconfig}/tkConfig.sh" ; then
40046283Sdfr      ac_cv_c_tkconfig=`(cd ${with_tkconfig}; pwd)`
40146283Sdfr    else
40246283Sdfr      AC_MSG_ERROR([${with_tkconfig} directory doesn't contain tkConfig.sh])
40346283Sdfr    fi
40446283Sdfr  fi
40546283Sdfr
40646283Sdfr  # then check for a private Tk library
40746283Sdfr  if test x"${ac_cv_c_tkconfig}" = x ; then
40846283Sdfr    for i in \
40946283Sdfr		../tk \
41046283Sdfr		`ls -dr ../tk[[4-9]]* 2>/dev/null` \
41146283Sdfr		../../tk \
41246283Sdfr		`ls -dr ../../tk[[4-9]]* 2>/dev/null` \
41346283Sdfr		../../../tk \
41446283Sdfr		`ls -dr ../../../tk[[4-9]]* 2>/dev/null` ; do
41546283Sdfr      if test -f "$i/${configdir}/tkConfig.sh" ; then
41646283Sdfr        ac_cv_c_tkconfig=`(cd $i/${configdir}; pwd)`
41746283Sdfr	break
41846283Sdfr      fi
41946283Sdfr    done
42046283Sdfr  fi
42146283Sdfr  # check in a few common install locations
42246283Sdfr  if test x"${ac_cv_c_tkconfig}" = x ; then
42346283Sdfr    for i in `ls -d ${prefix}/lib /usr/local/lib 2>/dev/null` ; do
42446283Sdfr      if test -f "$i/tkConfig.sh" ; then
42546283Sdfr        ac_cv_c_tkconfig=`(cd $i; pwd)`
42646283Sdfr	break
42746283Sdfr      fi
42846283Sdfr    done
42946283Sdfr  fi
43046283Sdfr  # check in a few other private locations
43146283Sdfr  if test x"${ac_cv_c_tkconfig}" = x ; then
43246283Sdfr    for i in \
43346283Sdfr		${srcdir}/../tk \
43446283Sdfr		`ls -dr ${srcdir}/../tk[[4-9]]* 2>/dev/null` ; do
43546283Sdfr      if test -f "$i/${configdir}/tkConfig.sh" ; then
43646283Sdfr        ac_cv_c_tkconfig=`(cd $i/${configdir}; pwd)`
43746283Sdfr	break
43846283Sdfr      fi
43946283Sdfr    done
44046283Sdfr  fi
44146283Sdfr  ])
44246283Sdfr  if test x"${ac_cv_c_tkconfig}" = x ; then
44346283Sdfr    TKCONFIG="# no Tk configs found"
44446283Sdfr    AC_MSG_WARN(Can't find Tk configuration definitions)
44546283Sdfr  else
44646283Sdfr    no_tk=
44746283Sdfr    TKCONFIG=${ac_cv_c_tkconfig}/tkConfig.sh
44846283Sdfr    AC_MSG_RESULT(found $TKCONFIG)
44946283Sdfr  fi
45046283Sdfrfi
45146283Sdfr
45246283Sdfr])
45346283Sdfr
45446283Sdfr# Defined as a separate macro so we don't have to cache the values
45546283Sdfr# from PATH_TKCONFIG (because this can also be cached).
45646283SdfrAC_DEFUN(CY_AC_LOAD_TKCONFIG, [
45746283Sdfr    if test -f "$TKCONFIG" ; then
45846283Sdfr      . $TKCONFIG
45946283Sdfr    fi
46046283Sdfr
46146283Sdfr    AC_SUBST(TK_VERSION)
46246283Sdfrdnl not actually used, don't export to save symbols
46346283Sdfrdnl    AC_SUBST(TK_MAJOR_VERSION)
46446283Sdfrdnl    AC_SUBST(TK_MINOR_VERSION)
46546283Sdfr    AC_SUBST(TK_DEFS)
46646283Sdfr
46746283Sdfrdnl not used, don't export to save symbols
46846283Sdfr    dnl AC_SUBST(TK_LIB_FILE)
46946283Sdfr
47046283Sdfrdnl not used outside of configure
47146283Sdfrdnl    AC_SUBST(TK_LIBS)
47246283Sdfrdnl not used, don't export to save symbols
47346283Sdfrdnl    AC_SUBST(TK_PREFIX)
47446283Sdfr
47546283Sdfrdnl not used, don't export to save symbols
47646283Sdfrdnl    AC_SUBST(TK_EXEC_PREFIX)
47746283Sdfr
47846283Sdfr    AC_SUBST(TK_BUILD_INCLUDES)
47946283Sdfr    AC_SUBST(TK_XINCLUDES)
48046283Sdfr    AC_SUBST(TK_XLIBSW)
48146283Sdfr    AC_SUBST(TK_BUILD_LIB_SPEC)
48246283Sdfr    AC_SUBST(TK_LIB_SPEC)
48346283Sdfr])
48446283Sdfr
48546283Sdfr# check for Itcl headers. 
48646283Sdfr
48746283SdfrAC_DEFUN(CY_AC_PATH_ITCLCONFIG, [
48846283Sdfr#
48946283Sdfr# Ok, lets find the itcl configuration
49046283Sdfr# First, look for one uninstalled.  
49146283Sdfr# the alternative search directory is invoked by --with-itclconfig
49246283Sdfr#
49346283Sdfr
49446283Sdfrif test x"${no_itcl}" = x ; then
49546283Sdfr  # we reset no_itcl in case something fails here
49646283Sdfr  no_itcl=true
49798944Sobrien  AC_ARG_WITH(itclconfig, [  --with-itclconfig       Directory containing itcl configuration (itclConfig.sh)],
49846283Sdfr         with_itclconfig=${withval})
49946283Sdfr  AC_MSG_CHECKING([for Itcl configuration])
50046283Sdfr  AC_CACHE_VAL(ac_cv_c_itclconfig,[
50146283Sdfr
50246283Sdfr  # First check to see if --with-itclconfig was specified.
50346283Sdfr  if test x"${with_itclconfig}" != x ; then
50446283Sdfr    if test -f "${with_itclconfig}/itclConfig.sh" ; then
50546283Sdfr      ac_cv_c_itclconfig=`(cd ${with_itclconfig}; pwd)`
50646283Sdfr    else
50746283Sdfr      AC_MSG_ERROR([${with_itclconfig} directory doesn't contain itclConfig.sh])
50846283Sdfr    fi
50946283Sdfr  fi
51046283Sdfr
51146283Sdfr  # then check for a private Itcl library
51246283Sdfr  if test x"${ac_cv_c_itclconfig}" = x ; then
51346283Sdfr    for i in \
51446283Sdfr		../itcl/itcl \
51546283Sdfr		`ls -dr ../itcl[[4-9]]*/itcl 2>/dev/null` \
51646283Sdfr		../../itcl \
51746283Sdfr		`ls -dr ../../itcl[[4-9]]*/itcl 2>/dev/null` \
51846283Sdfr		../../../itcl \
51946283Sdfr		`ls -dr ../../../itcl[[4-9]]*/itcl 2>/dev/null` ; do
52046283Sdfr      if test -f "$i/itclConfig.sh" ; then
52146283Sdfr        ac_cv_c_itclconfig=`(cd $i; pwd)`
52246283Sdfr	break
52346283Sdfr      fi
52446283Sdfr    done
52546283Sdfr  fi
52646283Sdfr  # check in a few common install locations
52746283Sdfr  if test x"${ac_cv_c_itclconfig}" = x ; then
52846283Sdfr    for i in `ls -d ${prefix}/lib /usr/local/lib 2>/dev/null` ; do
52946283Sdfr      if test -f "$i/itclConfig.sh" ; then
53046283Sdfr        ac_cv_c_itclconfig=`(cd $i; pwd)`
53146283Sdfr	break
53246283Sdfr      fi
53346283Sdfr    done
53446283Sdfr  fi
53546283Sdfr  # check in a few other private locations
53646283Sdfr  if test x"${ac_cv_c_itclconfig}" = x ; then
53746283Sdfr    for i in \
53846283Sdfr		${srcdir}/../itcl/itcl \
53946283Sdfr		`ls -dr ${srcdir}/../itcl[[4-9]]*/itcl 2>/dev/null` ; do
54046283Sdfr      if test -f "$i/itclConfig.sh" ; then
54146283Sdfr        ac_cv_c_itclconfig=`(cd $i; pwd)`
54246283Sdfr	break
54346283Sdfr      fi
54446283Sdfr    done
54546283Sdfr  fi
54646283Sdfr  ])
54746283Sdfr  if test x"${ac_cv_c_itclconfig}" = x ; then
54846283Sdfr    ITCLCONFIG="# no Itcl configs found"
54946283Sdfr    AC_MSG_WARN(Can't find Itcl configuration definitions)
55046283Sdfr  else
55146283Sdfr    no_itcl=
55246283Sdfr    ITCLCONFIG=${ac_cv_c_itclconfig}/itclConfig.sh
55346283Sdfr    AC_MSG_RESULT(found $ITCLCONFIG)
55446283Sdfr  fi
55546283Sdfrfi
55646283Sdfr])
55746283Sdfr
55846283Sdfr# Defined as a separate macro so we don't have to cache the values
55946283Sdfr# from PATH_ITCLCONFIG (because this can also be cached).
56046283SdfrAC_DEFUN(CY_AC_LOAD_ITCLCONFIG, [
56146283Sdfr    if test -f "$ITCLCONFIG" ; then
56246283Sdfr      . $ITCLCONFIG
56346283Sdfr    fi
56446283Sdfr
56546283Sdfr    AC_SUBST(ITCL_VERSION)
56646283Sdfrdnl not actually used, don't export to save symbols
56746283Sdfrdnl    AC_SUBST(ITCL_MAJOR_VERSION)
56846283Sdfrdnl    AC_SUBST(ITCL_MINOR_VERSION)
56946283Sdfr    AC_SUBST(ITCL_DEFS)
57046283Sdfr
57146283Sdfrdnl not used, don't export to save symbols
57246283Sdfr    dnl AC_SUBST(ITCL_LIB_FILE)
57346283Sdfr
57446283Sdfrdnl not used outside of configure
57546283Sdfrdnl    AC_SUBST(ITCL_LIBS)
57646283Sdfrdnl not used, don't export to save symbols
57746283Sdfrdnl    AC_SUBST(ITCL_PREFIX)
57846283Sdfr
57946283Sdfrdnl not used, don't export to save symbols
58046283Sdfrdnl    AC_SUBST(ITCL_EXEC_PREFIX)
58146283Sdfr
58246283Sdfr    AC_SUBST(ITCL_BUILD_INCLUDES)
58346283Sdfr    AC_SUBST(ITCL_BUILD_LIB_SPEC)
58446283Sdfr    AC_SUBST(ITCL_LIB_SPEC)
58546283Sdfr])
58646283Sdfr
58746283Sdfr# check for Itcl headers. 
58846283Sdfr
58946283SdfrAC_DEFUN(CY_AC_PATH_ITCLH, [
59046283SdfrAC_MSG_CHECKING(for Itcl private headers. srcdir=${srcdir})
59146283Sdfrif test x"${ac_cv_c_itclh}" = x ; then
59246283Sdfr  for i in ${srcdir}/../itcl ${srcdir}/../../itcl ${srcdir}/../../../itcl ${srcdir}/../itcl/itcl; do
59346283Sdfr    if test -f $i/generic/itcl.h ; then
59446283Sdfr      ac_cv_c_itclh=`(cd $i/generic; pwd)`
59546283Sdfr      break
59646283Sdfr    fi
59746283Sdfr  done
59846283Sdfrfi
59946283Sdfrif test x"${ac_cv_c_itclh}" = x ; then
60046283Sdfr  ITCLHDIR="# no Itcl private headers found"
60146283Sdfr  AC_MSG_ERROR([Can't find Itcl private headers])
60246283Sdfrfi
60346283Sdfrif test x"${ac_cv_c_itclh}" != x ; then
60446283Sdfr     ITCLHDIR="-I${ac_cv_c_itclh}"
60546283Sdfrfi
60646283Sdfr# should always be here
60746283Sdfr#     ITCLLIB="../itcl/itcl/unix/libitcl.a"
60846283SdfrAC_SUBST(ITCLHDIR)
60946283Sdfr#AC_SUBST(ITCLLIB)
61046283Sdfr])
61146283Sdfr
61246283Sdfr
61346283SdfrAC_DEFUN(CY_AC_PATH_ITKCONFIG, [
61446283Sdfr#
61546283Sdfr# Ok, lets find the itk configuration
61646283Sdfr# First, look for one uninstalled.  
61746283Sdfr# the alternative search directory is invoked by --with-itkconfig
61846283Sdfr#
61946283Sdfr
62046283Sdfrif test x"${no_itk}" = x ; then
62146283Sdfr  # we reset no_itk in case something fails here
62246283Sdfr  no_itk=true
62398944Sobrien  AC_ARG_WITH(itkconfig, [  --with-itkconfig        Directory containing itk configuration (itkConfig.sh)],
62446283Sdfr         with_itkconfig=${withval})
62546283Sdfr  AC_MSG_CHECKING([for Itk configuration])
62646283Sdfr  AC_CACHE_VAL(ac_cv_c_itkconfig,[
62746283Sdfr
62846283Sdfr  # First check to see if --with-itkconfig was specified.
62946283Sdfr  if test x"${with_itkconfig}" != x ; then
63046283Sdfr    if test -f "${with_itkconfig}/itkConfig.sh" ; then
63146283Sdfr      ac_cv_c_itkconfig=`(cd ${with_itkconfig}; pwd)`
63246283Sdfr    else
63346283Sdfr      AC_MSG_ERROR([${with_itkconfig} directory doesn't contain itkConfig.sh])
63446283Sdfr    fi
63546283Sdfr  fi
63646283Sdfr
63746283Sdfr  # then check for a private Itk library
63846283Sdfr  if test x"${ac_cv_c_itkconfig}" = x ; then
63946283Sdfr    for i in \
64046283Sdfr		../itcl/itk \
64146283Sdfr		`ls -dr ../itcl[[4-9]]*/itk 2>/dev/null` \
64246283Sdfr		../../itk \
64346283Sdfr		`ls -dr ../../itcl[[4-9]]*/itk 2>/dev/null` \
64446283Sdfr		../../../itk \
64546283Sdfr		`ls -dr ../../../itcl[[4-9]]*/itk 2>/dev/null` ; do
64646283Sdfr      if test -f "$i/itkConfig.sh" ; then
64746283Sdfr        ac_cv_c_itkconfig=`(cd $i; pwd)`
64846283Sdfr	break
64946283Sdfr      fi
65046283Sdfr    done
65146283Sdfr  fi
65246283Sdfr  # check in a few common install locations
65346283Sdfr  if test x"${ac_cv_c_itkconfig}" = x ; then
65446283Sdfr    for i in `ls -d ${prefix}/lib /usr/local/lib 2>/dev/null` ; do
65546283Sdfr      if test -f "$i/itkConfig.sh" ; then
65646283Sdfr        ac_cv_c_itkconfig=`(cd $i; pwd)`
65746283Sdfr	break
65846283Sdfr      fi
65946283Sdfr    done
66046283Sdfr  fi
66146283Sdfr  # check in a few other private locations
66246283Sdfr  if test x"${ac_cv_c_itkconfig}" = x ; then
66346283Sdfr    for i in \
66446283Sdfr		${srcdir}/../itcl/itk \
66546283Sdfr		`ls -dr ${srcdir}/../itcl[[4-9]]*/itk 2>/dev/null` ; do
66646283Sdfr      if test -f "$i/itkConfig.sh" ; then
66746283Sdfr        ac_cv_c_itkconfig=`(cd $i; pwd)`
66846283Sdfr	break
66946283Sdfr      fi
67046283Sdfr    done
67146283Sdfr  fi
67246283Sdfr  ])
67346283Sdfr  if test x"${ac_cv_c_itkconfig}" = x ; then
67446283Sdfr    ITKCONFIG="# no Itk configs found"
67546283Sdfr    AC_MSG_WARN(Can't find Itk configuration definitions)
67646283Sdfr  else
67746283Sdfr    no_itk=
67846283Sdfr    ITKCONFIG=${ac_cv_c_itkconfig}/itkConfig.sh
67946283Sdfr    AC_MSG_RESULT(found $ITKCONFIG)
68046283Sdfr  fi
68146283Sdfrfi
68246283Sdfr
68346283Sdfr])
68446283Sdfr
68546283Sdfr# Defined as a separate macro so we don't have to cache the values
68646283Sdfr# from PATH_ITKCONFIG (because this can also be cached).
68746283SdfrAC_DEFUN(CY_AC_LOAD_ITKCONFIG, [
68846283Sdfr    if test -f "$ITKCONFIG" ; then
68946283Sdfr      . $ITKCONFIG
69046283Sdfr    fi
69146283Sdfr
69246283Sdfr    AC_SUBST(ITK_VERSION)
69346283Sdfrdnl not actually used, don't export to save symbols
69446283Sdfrdnl    AC_SUBST(ITK_MAJOR_VERSION)
69546283Sdfrdnl    AC_SUBST(ITK_MINOR_VERSION)
69646283Sdfr    AC_SUBST(ITK_DEFS)
69746283Sdfr
69846283Sdfrdnl not used, don't export to save symbols
69946283Sdfr    dnl AC_SUBST(ITK_LIB_FILE)
70046283Sdfr
70146283Sdfrdnl not used outside of configure
70246283Sdfrdnl    AC_SUBST(ITK_LIBS)
70346283Sdfrdnl not used, don't export to save symbols
70446283Sdfrdnl    AC_SUBST(ITK_PREFIX)
70546283Sdfr
70646283Sdfrdnl not used, don't export to save symbols
70746283Sdfrdnl    AC_SUBST(ITK_EXEC_PREFIX)
70846283Sdfr
70946283Sdfr    AC_SUBST(ITK_BUILD_INCLUDES)
71046283Sdfr    AC_SUBST(ITK_BUILD_LIB_SPEC)
71146283Sdfr    AC_SUBST(ITK_LIB_SPEC)
71246283Sdfr])
71346283Sdfr
71446283SdfrAC_DEFUN(CY_AC_PATH_ITKH, [
71546283SdfrAC_MSG_CHECKING(for Itk private headers. srcdir=${srcdir})
71646283Sdfrif test x"${ac_cv_c_itkh}" = x ; then
71746283Sdfr  for i in ${srcdir}/../itcl ${srcdir}/../../itcl ${srcdir}/../../../itcl ${srcdir}/../itcl/itk; do
71846283Sdfr    if test -f $i/generic/itk.h ; then
71946283Sdfr      ac_cv_c_itkh=`(cd $i/generic; pwd)`
72046283Sdfr      break
72146283Sdfr    fi
72246283Sdfr  done
72346283Sdfrfi
72446283Sdfrif test x"${ac_cv_c_itkh}" = x ; then
72546283Sdfr  ITKHDIR="# no Itk private headers found"
72646283Sdfr  AC_MSG_ERROR([Can't find Itk private headers])
72746283Sdfrfi
72846283Sdfrif test x"${ac_cv_c_itkh}" != x ; then
72946283Sdfr     ITKHDIR="-I${ac_cv_c_itkh}"
73046283Sdfrfi
73146283Sdfr# should always be here
73246283Sdfr#     ITKLIB="../itcl/itk/unix/libitk.a"
73346283SdfrAC_SUBST(ITKHDIR)
73446283Sdfr#AC_SUBST(ITKLIB)
73546283Sdfr])
73646283Sdfr
73746283Sdfr
73898944Sobriendnl sinclude(../gettext.m4) already included by bfd/acinclude.m4
73998944Sobriendnl The lines below arrange for aclocal not to bring gettext.m4's
74098944Sobriendnl CY_GNU_GETTEXT into aclocal.m4.
74198944Sobrienifelse(yes,no,[
74298944SobrienAC_DEFUN([CY_GNU_GETTEXT],)
74398944Sobrien])
74498944Sobrien
74598944Sobrien## ----------------------------------------- ##
74698944Sobrien## ANSIfy the C compiler whenever possible.  ##
74798944Sobrien## From Franc,ois Pinard                     ##
74898944Sobrien## ----------------------------------------- ##
74998944Sobrien
75098944Sobrien# Copyright 1996, 1997, 1999, 2000, 2001 Free Software Foundation, Inc.
75198944Sobrien
75298944Sobrien# This program is free software; you can redistribute it and/or modify
75398944Sobrien# it under the terms of the GNU General Public License as published by
75498944Sobrien# the Free Software Foundation; either version 2, or (at your option)
75598944Sobrien# any later version.
75698944Sobrien
75798944Sobrien# This program is distributed in the hope that it will be useful,
75898944Sobrien# but WITHOUT ANY WARRANTY; without even the implied warranty of
75998944Sobrien# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
76098944Sobrien# GNU General Public License for more details.
76198944Sobrien
76298944Sobrien# You should have received a copy of the GNU General Public License
76398944Sobrien# along with this program; if not, write to the Free Software
76498944Sobrien# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
76598944Sobrien# 02111-1307, USA.
76698944Sobrien
76798944Sobrien# serial 1
76898944Sobrien
76998944Sobrien# @defmac AC_PROG_CC_STDC
77098944Sobrien# @maindex PROG_CC_STDC
77198944Sobrien# @ovindex CC
77298944Sobrien# If the C compiler in not in ANSI C mode by default, try to add an option
77398944Sobrien# to output variable @code{CC} to make it so.  This macro tries various
77498944Sobrien# options that select ANSI C on some system or another.  It considers the
77598944Sobrien# compiler to be in ANSI C mode if it handles function prototypes correctly.
77698944Sobrien#
77798944Sobrien# If you use this macro, you should check after calling it whether the C
77898944Sobrien# compiler has been set to accept ANSI C; if not, the shell variable
77998944Sobrien# @code{am_cv_prog_cc_stdc} is set to @samp{no}.  If you wrote your source
78098944Sobrien# code in ANSI C, you can make an un-ANSIfied copy of it by using the
78198944Sobrien# program @code{ansi2knr}, which comes with Ghostscript.
78298944Sobrien# @end defmac
78398944Sobrien
78498944SobrienAC_DEFUN([AM_PROG_CC_STDC],
78598944Sobrien[AC_REQUIRE([AC_PROG_CC])
78698944SobrienAC_BEFORE([$0], [AC_C_INLINE])
78798944SobrienAC_BEFORE([$0], [AC_C_CONST])
78898944Sobriendnl Force this before AC_PROG_CPP.  Some cpp's, eg on HPUX, require
78998944Sobriendnl a magic option to avoid problems with ANSI preprocessor commands
79098944Sobriendnl like #elif.
79198944Sobriendnl FIXME: can't do this because then AC_AIX won't work due to a
79298944Sobriendnl circular dependency.
79398944Sobriendnl AC_BEFORE([$0], [AC_PROG_CPP])
79498944SobrienAC_MSG_CHECKING([for ${CC-cc} option to accept ANSI C])
79598944SobrienAC_CACHE_VAL(am_cv_prog_cc_stdc,
79698944Sobrien[am_cv_prog_cc_stdc=no
79798944Sobrienac_save_CC="$CC"
79898944Sobrien# Don't try gcc -ansi; that turns off useful extensions and
79998944Sobrien# breaks some systems' header files.
80098944Sobrien# AIX			-qlanglvl=ansi
80198944Sobrien# Ultrix and OSF/1	-std1
80298944Sobrien# HP-UX 10.20 and later	-Ae
80398944Sobrien# HP-UX older versions	-Aa -D_HPUX_SOURCE
80498944Sobrien# SVR4			-Xc -D__EXTENSIONS__
80598944Sobrienfor ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
80698944Sobriendo
80798944Sobrien  CC="$ac_save_CC $ac_arg"
80898944Sobrien  AC_TRY_COMPILE(
80998944Sobrien[#include <stdarg.h>
81098944Sobrien#include <stdio.h>
81198944Sobrien#include <sys/types.h>
81298944Sobrien#include <sys/stat.h>
81398944Sobrien/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
81498944Sobrienstruct buf { int x; };
81598944SobrienFILE * (*rcsopen) (struct buf *, struct stat *, int);
81698944Sobrienstatic char *e (p, i)
81798944Sobrien     char **p;
81898944Sobrien     int i;
81998944Sobrien{
82098944Sobrien  return p[i];
82198944Sobrien}
82298944Sobrienstatic char *f (char * (*g) (char **, int), char **p, ...)
82398944Sobrien{
82498944Sobrien  char *s;
82598944Sobrien  va_list v;
82698944Sobrien  va_start (v,p);
82798944Sobrien  s = g (p, va_arg (v,int));
82898944Sobrien  va_end (v);
82998944Sobrien  return s;
83098944Sobrien}
83198944Sobrienint test (int i, double x);
83298944Sobrienstruct s1 {int (*f) (int a);};
83398944Sobrienstruct s2 {int (*f) (double a);};
83498944Sobrienint pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
83598944Sobrienint argc;
83698944Sobrienchar **argv;
83798944Sobrien], [
83898944Sobrienreturn f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
83998944Sobrien],
84098944Sobrien[am_cv_prog_cc_stdc="$ac_arg"; break])
84198944Sobriendone
84298944SobrienCC="$ac_save_CC"
84398944Sobrien])
84498944Sobrienif test -z "$am_cv_prog_cc_stdc"; then
84598944Sobrien  AC_MSG_RESULT([none needed])
84698944Sobrienelse
84798944Sobrien  AC_MSG_RESULT([$am_cv_prog_cc_stdc])
84898944Sobrienfi
84998944Sobriencase "x$am_cv_prog_cc_stdc" in
85098944Sobrien  x|xno) ;;
85198944Sobrien  *) CC="$CC $am_cv_prog_cc_stdc" ;;
85298944Sobrienesac
85398944Sobrien])
854130803Smarcel
855130803Smarceldnl From Bruno Haible.
856130803Smarcel
857130803SmarcelAC_DEFUN([AM_ICONV],
858130803Smarcel[
859130803Smarcel  dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
860130803Smarcel  dnl those with the standalone portable GNU libiconv installed).
861130803Smarcel
862130803Smarcel  AC_ARG_WITH([libiconv-prefix],
863130803Smarcel[  --with-libiconv-prefix=DIR  search for libiconv in DIR/include and DIR/lib], [
864130803Smarcel    for dir in `echo "$withval" | tr : ' '`; do
865130803Smarcel      if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
866130803Smarcel      if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
867130803Smarcel    done
868130803Smarcel   ])
869130803Smarcel
870130803Smarcel  AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
871130803Smarcel    am_cv_func_iconv="no, consider installing GNU libiconv"
872130803Smarcel    am_cv_lib_iconv=no
873130803Smarcel    AC_TRY_LINK([#include <stdlib.h>
874130803Smarcel#include <iconv.h>],
875130803Smarcel      [iconv_t cd = iconv_open("","");
876130803Smarcel       iconv(cd,NULL,NULL,NULL,NULL);
877130803Smarcel       iconv_close(cd);],
878130803Smarcel      am_cv_func_iconv=yes)
879130803Smarcel    if test "$am_cv_func_iconv" != yes; then
880130803Smarcel      am_save_LIBS="$LIBS"
881130803Smarcel      LIBS="$LIBS -liconv"
882130803Smarcel      AC_TRY_LINK([#include <stdlib.h>
883130803Smarcel#include <iconv.h>],
884130803Smarcel        [iconv_t cd = iconv_open("","");
885130803Smarcel         iconv(cd,NULL,NULL,NULL,NULL);
886130803Smarcel         iconv_close(cd);],
887130803Smarcel        am_cv_lib_iconv=yes
888130803Smarcel        am_cv_func_iconv=yes)
889130803Smarcel      LIBS="$am_save_LIBS"
890130803Smarcel    fi
891130803Smarcel  ])
892130803Smarcel  if test "$am_cv_func_iconv" = yes; then
893130803Smarcel    AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
894130803Smarcel    AC_MSG_CHECKING([for iconv declaration])
895130803Smarcel    AC_CACHE_VAL(am_cv_proto_iconv, [
896130803Smarcel      AC_TRY_COMPILE([
897130803Smarcel#include <stdlib.h>
898130803Smarcel#include <iconv.h>
899130803Smarcelextern
900130803Smarcel#ifdef __cplusplus
901130803Smarcel"C"
902130803Smarcel#endif
903130803Smarcel#if defined(__STDC__) || defined(__cplusplus)
904130803Smarcelsize_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
905130803Smarcel#else
906130803Smarcelsize_t iconv();
907130803Smarcel#endif
908130803Smarcel], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
909130803Smarcel      am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
910130803Smarcel    am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
911130803Smarcel    AC_MSG_RESULT([$]{ac_t:-
912130803Smarcel         }[$]am_cv_proto_iconv)
913130803Smarcel    AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
914130803Smarcel      [Define as const if the declaration of iconv() needs const.])
915130803Smarcel  fi
916130803Smarcel  LIBICONV=
917130803Smarcel  if test "$am_cv_lib_iconv" = yes; then
918130803Smarcel    LIBICONV="-liconv"
919130803Smarcel  fi
920130803Smarcel  AC_SUBST(LIBICONV)
921130803Smarcel])
922130803Smarcel
923130803Smarcel# AC_GNU_SOURCE
924130803Smarcel# -------------
925130803Smarcel# FIXME: Remove thise once we start using Autoconf 2.5x (x>=4).
926130803SmarcelAC_DEFUN([AC_GNU_SOURCE],
927130803Smarcel[AC_BEFORE([$0], [AC_TRY_COMPILE])dnl
928130803SmarcelAC_BEFORE([$0], [AC_TRY_RUN])dnl
929130803SmarcelAC_DEFINE([_GNU_SOURCE])
930130803Smarcel])
931130803Smarcel
932130803Smarceldnl written by Guido Draheim <guidod@gmx.de>, original by Alexandre Oliva 
933130803Smarceldnl Version 1.3 (2001/03/02)
934130803Smarceldnl source http://www.gnu.org/software/ac-archive/Miscellaneous/ac_define_dir.html
935130803Smarcel
936130803SmarcelAC_DEFUN([AC_DEFINE_DIR], [
937130803Smarcel  test "x$prefix" = xNONE && prefix="$ac_default_prefix"
938130803Smarcel  test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
939130803Smarcel  ac_define_dir=`eval echo [$]$2`
940130803Smarcel  ac_define_dir=`eval echo [$]ac_define_dir`
941130803Smarcel  ifelse($3, ,
942130803Smarcel    AC_DEFINE_UNQUOTED($1, "$ac_define_dir"),
943130803Smarcel    AC_DEFINE_UNQUOTED($1, "$ac_define_dir", $3))
944130803Smarcel])
945130803Smarcel
946130803Smarceldnl See whether we need a declaration for a function.
947130803Smarceldnl The result is highly dependent on the INCLUDES passed in, so make sure
948130803Smarceldnl to use a different cache variable name in this macro if it is invoked
949130803Smarceldnl in a different context somewhere else.
950130803Smarceldnl gcc_AC_CHECK_DECL(SYMBOL,
951130803Smarceldnl 	[ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, INCLUDES]]])
952130803SmarcelAC_DEFUN(gcc_AC_CHECK_DECL,
953130803Smarcel[AC_MSG_CHECKING([whether $1 is declared])
954130803SmarcelAC_CACHE_VAL(gcc_cv_have_decl_$1,
955130803Smarcel[AC_TRY_COMPILE([$4],
956130803Smarcel[#ifndef $1
957130803Smarcelchar *(*pfn) = (char *(*)) $1 ;
958130803Smarcel#endif], eval "gcc_cv_have_decl_$1=yes", eval "gcc_cv_have_decl_$1=no")])
959130803Smarcelif eval "test \"`echo '$gcc_cv_have_decl_'$1`\" = yes"; then
960130803Smarcel  AC_MSG_RESULT(yes) ; ifelse([$2], , :, [$2])
961130803Smarcelelse
962130803Smarcel  AC_MSG_RESULT(no) ; ifelse([$3], , :, [$3])
963130803Smarcelfi
964130803Smarcel])dnl
965130803Smarcel
966130803Smarceldnl Check multiple functions to see whether each needs a declaration.
967130803Smarceldnl Arrange to define HAVE_DECL_<FUNCTION> to 0 or 1 as appropriate.
968130803Smarceldnl gcc_AC_CHECK_DECLS(SYMBOLS,
969130803Smarceldnl 	[ACTION-IF-NEEDED [, ACTION-IF-NOT-NEEDED [, INCLUDES]]])
970130803SmarcelAC_DEFUN(gcc_AC_CHECK_DECLS,
971130803Smarcel[for ac_func in $1
972130803Smarceldo
973130803Smarcelchangequote(, )dnl
974130803Smarcel  ac_tr_decl=HAVE_DECL_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
975130803Smarcelchangequote([, ])dnl
976130803Smarcelgcc_AC_CHECK_DECL($ac_func,
977130803Smarcel  [AC_DEFINE_UNQUOTED($ac_tr_decl, 1) $2],
978130803Smarcel  [AC_DEFINE_UNQUOTED($ac_tr_decl, 0) $3],
979130803Smarceldnl It is possible that the include files passed in here are local headers
980130803Smarceldnl which supply a backup declaration for the relevant prototype based on
981130803Smarceldnl the definition of (or lack of) the HAVE_DECL_ macro.  If so, this test
982130803Smarceldnl will always return success.  E.g. see libiberty.h's handling of
983130803Smarceldnl `basename'.  To avoid this, we define the relevant HAVE_DECL_ macro to
984130803Smarceldnl 1 so that any local headers used do not provide their own prototype
985130803Smarceldnl during this test.
986130803Smarcel#undef $ac_tr_decl
987130803Smarcel#define $ac_tr_decl 1
988130803Smarcel  $4
989130803Smarcel)
990130803Smarceldone
991130803Smarceldnl Automatically generate config.h entries via autoheader.
992130803Smarcelif test x = y ; then
993130803Smarcel  patsubst(translit([$1], [a-z], [A-Z]), [\w+],
994130803Smarcel    [AC_DEFINE([HAVE_DECL_\&], 1,
995130803Smarcel      [Define to 1 if we found this declaration otherwise define to 0.])])dnl
996130803Smarcelfi
997130803Smarcel])
998130803Smarcel
999