home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / unix / vim-6.2.tar.bz2 / vim-6.2.tar / vim62 / src / configure.in < prev    next >
Encoding:
Text File  |  2003-05-31  |  73.1 KB  |  2,424 lines

  1. dnl configure.in: autoconf script for Vim
  2.  
  3. dnl Process this file with autoconf 2.12 or 2.13 to produce "configure".
  4. dnl Should also work with autoconf 2.54 and later.
  5.  
  6. AC_INIT(vim.h)
  7. AC_CONFIG_HEADER(auto/config.h:config.h.in)
  8.  
  9. dnl Being able to run configure means the system is Unix (compatible).
  10. AC_DEFINE(UNIX)
  11. AC_PROG_MAKE_SET
  12.  
  13. dnl Checks for programs.
  14. AC_PROG_CC    dnl required by almost everything
  15. AC_PROG_CPP    dnl required by header file checks
  16. AC_ISC_POSIX    dnl required by AC_C_CROSS
  17. AC_PROG_AWK    dnl required for "make html" in ../doc
  18.  
  19. dnl Don't strip if we don't have it
  20. AC_CHECK_PROG(STRIP, strip, strip, :)
  21.  
  22. dnl Check for extention of executables
  23. AC_EXEEXT
  24.  
  25. dnl Set default value for CFLAGS if none is defined or it's empty
  26. if test -z "$CFLAGS"; then
  27.   CFLAGS="-O"
  28.   test "$GCC" = yes && CFLAGS="-O2 -fno-strength-reduce -Wall"
  29. fi
  30. if test "$GCC" = yes; then
  31.   gccversion=`"$CC" --version | sed -e '2,$d;s/^[[^0-9]]*\([[0-9]]\.[[0-9.]]*\).*$/\1/g'`
  32.   if test "$gccversion" = "3.0.1" -o "$gccversion" = "3.0.2"; then
  33.     echo 'GCC 3.0.x has a bug in the optimizer, disabling "-O#"'
  34.     CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-O/'`
  35.   else
  36.     if test "$gccversion" = "3.1" -o "$gccversion" = "3.2" -o "$gccversion" = "3.2.1" && `echo "$CFLAGS" | grep -v fno-strength-reduce >/dev/null`; then
  37.       echo 'GCC 3.1 and 3.2 have a bug in the optimizer, adding "-fno-strength-reduce"'
  38.       CFLAGS="$CFLAGS -fno-strength-reduce"
  39.     fi
  40.   fi
  41. fi
  42.  
  43. dnl If configure thinks we are cross compiling, there is probably something
  44. dnl wrong with the CC or CFLAGS settings, give an understandable error message
  45. if test "$cross_compiling" = yes; then
  46.   AC_MSG_ERROR([cannot compile a simple program, check CC and CFLAGS
  47.   (cross compiling doesn't work)])
  48. fi
  49.  
  50. dnl gcc-cpp has the wonderful -MM option to produce nicer dependencies
  51. test "$GCC" = yes && CPP_MM=M; AC_SUBST(CPP_MM)
  52.  
  53. if test -f ./toolcheck; then
  54.   AC_CHECKING(for buggy tools)
  55.   sh ./toolcheck 1>&AC_FD_MSG
  56. fi
  57.  
  58. OS_EXTRA_SRC=""; OS_EXTRA_OBJ=""
  59.  
  60. dnl Check for BeOS, which needs an extra source file
  61. AC_MSG_CHECKING(for BeOS)
  62. case `uname` in
  63.     BeOS)    OS_EXTRA_SRC=os_beos.c; OS_EXTRA_OBJ=objects/os_beos.o
  64.         BEOS=yes; AC_MSG_RESULT(yes);;
  65.     *)        BEOS=no; AC_MSG_RESULT(no);;
  66. esac
  67.  
  68. dnl If QNX is found, assume we don't want to use Xphoton
  69. dnl unless it was specifically asked for (--with-x)
  70. AC_MSG_CHECKING(for QNX)
  71. case `uname` in
  72.     QNX)    OS_EXTRA_SRC=os_qnx.c; OS_EXTRA_OBJ=objects/os_qnx.o
  73.         test -z "$with_x" && with_x=no
  74.         QNX=yes; AC_MSG_RESULT(yes);;
  75.     *)        QNX=no; AC_MSG_RESULT(no);;
  76. esac
  77.  
  78. AC_SUBST(OS_EXTRA_SRC)
  79. AC_SUBST(OS_EXTRA_OBJ)
  80.  
  81. dnl Add /usr/local/lib to $LDFLAGS and /usr/local/include to CFLAGS.
  82. dnl Only when the directory exists and it wasn't there yet.
  83. dnl For gcc don't do this when it is already in the default search path.
  84. have_local_include=''
  85. have_local_lib=''
  86. if test "$GCC" = yes; then
  87.   echo 'void f(){}' > conftest.c
  88.   dnl -no-cpp-precomp is needed for OS X 10.2 (Ben Fowler)
  89.   have_local_include=`${CC-cc} -no-cpp-precomp -c -v conftest.c 2>&1 | grep '/usr/local/include'`
  90.   have_local_lib=`${CC-cc} -c -v conftest.c 2>&1 | grep '/usr/local/lib'`
  91.   rm -f conftest.c conftest.o
  92. fi
  93. if test -z "$have_local_lib" -a -d /usr/local/lib; then
  94.   tt=`echo "$LDFLAGS" | sed -e 's+-L/usr/local/lib ++g' -e 's+-L/usr/local/lib$++g'`
  95.   if test "$tt" = "$LDFLAGS"; then
  96.     LDFLAGS="$LDFLAGS -L/usr/local/lib"
  97.   fi
  98. fi
  99. if test -z "$have_local_include" -a -d /usr/local/include; then
  100.   tt=`echo "$CPPFLAGS" | sed -e 's+-I/usr/local/include ++g' -e 's+-I/usr/local/include$++g'`
  101.   if test "$tt" = "$CPPFLAGS"; then
  102.     CPPFLAGS="$CPPFLAGS -I/usr/local/include"
  103.   fi
  104. fi
  105.  
  106. AC_MSG_CHECKING(--with-vim-name argument)
  107. AC_ARG_WITH(vim-name, [  --with-vim-name=NAME    what to call the Vim executable],
  108.     VIMNAME="$withval"; AC_MSG_RESULT($VIMNAME),
  109.     VIMNAME="vim"; AC_MSG_RESULT(Defaulting to vim))
  110. AC_SUBST(VIMNAME)
  111. AC_MSG_CHECKING(--with-ex-name argument)
  112. AC_ARG_WITH(ex-name, [  --with-ex-name=NAME     what to call the Ex executable],
  113.     EXNAME="$withval"; AC_MSG_RESULT($EXNAME),
  114.     EXNAME="ex"; AC_MSG_RESULT(Defaulting to ex))
  115. AC_SUBST(EXNAME)
  116. AC_MSG_CHECKING(--with-view-name argument)
  117. AC_ARG_WITH(view-name, [  --with-view-name=NAME   what to call the View executable],
  118.     VIEWNAME="$withval"; AC_MSG_RESULT($VIEWNAME),
  119.     VIEWNAME="view"; AC_MSG_RESULT(Defaulting to view))
  120. AC_SUBST(VIEWNAME)
  121.  
  122. AC_MSG_CHECKING(--with-global-runtime argument)
  123. AC_ARG_WITH(global-runtime, [  --with-global-runtime=DIR    global runtime directory in 'runtimepath'],
  124.     AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL, "$withval"),
  125.     AC_MSG_RESULT(no))
  126.  
  127. AC_MSG_CHECKING(--with-modified-by argument)
  128. AC_ARG_WITH(modified-by, [  --with-modified-by=NAME       name of who modified a release version],
  129.     AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(MODIFIED_BY, "$withval"),
  130.     AC_MSG_RESULT(no))
  131.  
  132. dnl Check for EBCDIC stolen from the LYNX port to OS390 Unix
  133. AC_MSG_CHECKING(if character set is EBCDIC)
  134. AC_TRY_COMPILE([ ],
  135. [ /* TryCompile function for CharSet.
  136.    Treat any failure as ASCII for compatibility with existing art.
  137.    Use compile-time rather than run-time tests for cross-compiler
  138.    tolerance.  */
  139. #if '0'!=240
  140. make an error "Character set is not EBCDIC"
  141. #endif ],
  142. [ # TryCompile action if true
  143. cf_cv_ebcdic=yes ],
  144. [ # TryCompile action if false
  145. cf_cv_ebcdic=no])
  146. # end of TryCompile ])
  147. # end of CacheVal CvEbcdic
  148. AC_MSG_RESULT($cf_cv_ebcdic)
  149. case "$cf_cv_ebcdic" in  #(vi
  150.     yes)    AC_DEFINE(EBCDIC)
  151.         line_break='"\\n"'
  152.         ;;
  153.     *)        line_break='"\\012"';;
  154. esac
  155. AC_SUBST(line_break)
  156.  
  157. if test "$cf_cv_ebcdic" = "yes"; then
  158. dnl If we have EBCDIC we most likley have OS390 Unix, let's test it!
  159. AC_MSG_CHECKING(for OS/390 Unix)
  160. case `uname` in
  161.     OS/390)    OS390Unix="yes";
  162.         dnl If using cc the environment variable _CC_CCMODE must be
  163.         dnl set to "1", so that some compiler extensions are enabled.
  164.         dnl If using c89 the environment variable is named _CC_C89MODE.
  165.         dnl Note: compile with c89 never tested.
  166.         if test "$CC" = "cc"; then
  167.           ccm="$_CC_CCMODE"
  168.           ccn="CC"
  169.         else
  170.           if test "$CC" = "c89"; then
  171.             ccm="$_CC_C89MODE"
  172.             ccn="C89"
  173.           else
  174.             ccm=1
  175.           fi
  176.         fi
  177.         if test "$ccm" != "1"; then
  178.           echo ""
  179.           echo "------------------------------------------"
  180.           echo " On OS/390 Unix, the environment variable"
  181.           echo " __CC_${ccn}MODE must be set to \"1\"!"
  182.           echo " Do:"
  183.           echo "    export _CC_${ccn}MODE=1"
  184.           echo " and then call configure again."
  185.           echo "------------------------------------------"
  186.           exit 1
  187.         fi
  188.         CFLAGS="$CFLAGS -D_ALL_SOURCE"; LDFLAGS="$LDFLAGS -Wl,EDIT=NO"
  189.         AC_MSG_RESULT(yes)
  190.         ;;
  191.     *)        OS390Unix="no";
  192.         AC_MSG_RESULT(no)
  193.         ;;
  194. esac
  195. fi
  196.  
  197.  
  198. dnl Check user requested features.
  199.  
  200. AC_MSG_CHECKING(--with-features argument)
  201. AC_ARG_WITH(features, [  --with-features=TYPE    tiny, small, normal, big or huge (default: normal)],
  202.     features="$withval"; AC_MSG_RESULT($features),
  203.     features="normal"; AC_MSG_RESULT(Defaulting to normal))
  204.  
  205. dovimdiff=""
  206. dogvimdiff=""
  207. case "$features" in
  208.   tiny)        AC_DEFINE(FEAT_TINY) ;;
  209.   small)    AC_DEFINE(FEAT_SMALL) ;;
  210.   normal)    AC_DEFINE(FEAT_NORMAL) dovimdiff="installvimdiff";
  211.             dogvimdiff="installgvimdiff" ;;
  212.   big)        AC_DEFINE(FEAT_BIG) dovimdiff="installvimdiff";
  213.             dogvimdiff="installgvimdiff" ;;
  214.   huge)        AC_DEFINE(FEAT_HUGE) dovimdiff="installvimdiff";
  215.             dogvimdiff="installgvimdiff" ;;
  216.   *)        AC_MSG_RESULT([Sorry, $features is not supported]) ;;
  217. esac
  218.  
  219. AC_SUBST(dovimdiff)
  220. AC_SUBST(dogvimdiff)
  221.  
  222. AC_MSG_CHECKING(--with-compiledby argument)
  223. AC_ARG_WITH(compiledby, [  --with-compiledby=NAME  name to show in :version message],
  224.     compiledby="$withval"; AC_MSG_RESULT($withval),
  225.     compiledby=""; AC_MSG_RESULT(no))
  226. AC_SUBST(compiledby)
  227.  
  228. AC_MSG_CHECKING(--disable-xsmp argument)
  229. AC_ARG_ENABLE(xsmp,
  230.     [  --disable-xsmp          Disable XSMP session management],
  231.     , enable_xsmp="yes")
  232.  
  233. if test "$enable_xsmp" = "yes"; then
  234.   AC_MSG_RESULT(no)
  235.   AC_MSG_CHECKING(--disable-xsmp-interact argument)
  236.   AC_ARG_ENABLE(xsmp-interact,
  237.       [  --disable-xsmp-interact Disable XSMP interaction],
  238.       , enable_xsmp_interact="yes")
  239.   if test "$enable_xsmp_interact" = "yes"; then
  240.     AC_MSG_RESULT(no)
  241.     AC_DEFINE(USE_XSMP_INTERACT)
  242.   else
  243.     AC_MSG_RESULT(yes)
  244.   fi
  245. else
  246.   AC_MSG_RESULT(yes)
  247. fi
  248.  
  249. AC_MSG_CHECKING(--enable-perlinterp argument)
  250. AC_ARG_ENABLE(perlinterp,
  251.     [  --enable-perlinterp     Include Perl interpreter.], ,
  252.     [enable_perlinterp="no"])
  253. AC_MSG_RESULT($enable_perlinterp)
  254. if test "$enable_perlinterp" = "yes"; then
  255.   AC_SUBST(vi_cv_path_perl)
  256.   AC_PATH_PROG(vi_cv_path_perl, perl)
  257.   if test "X$vi_cv_path_perl" != "X"; then
  258.     AC_MSG_CHECKING(Perl version)
  259.     if $vi_cv_path_perl -e 'require 5.003_01' >/dev/null 2>/dev/null; then
  260.      eval `$vi_cv_path_perl -V:usethreads`
  261.      if test "X$usethreads" = "XUNKNOWN" -o "X$usethreads" = "Xundef"; then
  262.       AC_MSG_RESULT(OK)
  263.       eval `$vi_cv_path_perl -V:shrpenv`
  264.       if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04
  265.     shrpenv=""
  266.       fi
  267.       vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlibexp}'`
  268.       AC_SUBST(vi_cv_perllib)
  269.       perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
  270.           -e 'ccflags;perl_inc'`
  271.       if test "X$perlcppflags" != "X"; then
  272.     PERL_CFLAGS="$perlcppflags"
  273.       fi
  274.       dnl Remove "-lc", it breaks on FreeBSD when using "-pthread".
  275.       perllibs=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed -e 'ldopts' | \
  276.         sed -e '/Warning/d' -e '/Note (probably harmless)/d' \
  277.             -e 's/-bE:perl.exp//' -e 's/-lc //'`
  278.       AC_SUBST(perllibs)
  279.       dnl Don't add perl lib to $LIBS: if it's not in LD_LIBRARY_PATH
  280.       dnl a test in configure may fail because of that.
  281.       perlldflags=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed \
  282.         -e 'ccdlflags' | sed -e 's/-bE:perl.exp//'`
  283.       if test "X$perlldflags" != "X"; then
  284.     LDFLAGS="$perlldflags $LDFLAGS"
  285.       fi
  286.       PERL_SRC="auto/if_perl.c if_perlsfio.c"
  287.       PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o"
  288.       PERL_PRO="if_perl.pro if_perlsfio.pro"
  289.       AC_DEFINE(FEAT_PERL)
  290.      else
  291.       AC_MSG_RESULT(>>> Perl with threads cannot be used <<<)
  292.      fi
  293.     else
  294.       AC_MSG_RESULT(>>> too old; need Perl version 5.003_01 or later <<<)
  295.     fi
  296.   fi
  297. fi
  298. AC_SUBST(shrpenv)
  299. AC_SUBST(PERL_SRC)
  300. AC_SUBST(PERL_OBJ)
  301. AC_SUBST(PERL_PRO)
  302. AC_SUBST(PERL_CFLAGS)
  303.  
  304. AC_MSG_CHECKING(--enable-pythoninterp argument)
  305. AC_ARG_ENABLE(pythoninterp,
  306.     [  --enable-pythoninterp   Include Python interpreter.], ,
  307.     [enable_pythoninterp="no"])
  308. AC_MSG_RESULT($enable_pythoninterp)
  309. if test "$enable_pythoninterp" = "yes"; then
  310.   dnl -- find the python executable
  311.   AC_PATH_PROG(vi_cv_path_python, python)
  312.   if test "X$vi_cv_path_python" != "X"; then
  313.  
  314.     dnl -- get its version number
  315.     AC_CACHE_CHECK(Python version,vi_cv_var_python_version,
  316.     [[vi_cv_var_python_version=`
  317.         ${vi_cv_path_python} -c 'import sys; print sys.version[:3]'`
  318.     ]])
  319.  
  320.     dnl -- it must be at least version 1.4
  321.     AC_MSG_CHECKING(Python is 1.4 or better)
  322.     if ${vi_cv_path_python} -c \
  323.     "import sys; sys.exit(${vi_cv_var_python_version} < 1.4)"
  324.     then
  325.       AC_MSG_RESULT(yep)
  326.  
  327.       dnl -- find where python thinks it was installed
  328.       AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python_pfx,
  329.       [ vi_cv_path_python_pfx=`
  330.         ${vi_cv_path_python} -c \
  331.         "import sys; print sys.prefix"` ])
  332.  
  333.       dnl -- and where it thinks it runs
  334.       AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python_epfx,
  335.       [ vi_cv_path_python_epfx=`
  336.         ${vi_cv_path_python} -c \
  337.         "import sys; print sys.exec_prefix"` ])
  338.  
  339.       dnl -- python's internal library path
  340.  
  341.       AC_CACHE_VAL(vi_cv_path_pythonpath,
  342.       [ vi_cv_path_pythonpath=`
  343.         unset PYTHONPATH;
  344.         ${vi_cv_path_python} -c \
  345.         "import sys, string; print string.join(sys.path,':')"` ])
  346.  
  347.       dnl -- where the Python implementation library archives are
  348.  
  349.       AC_ARG_WITH(python-config-dir,
  350.     [  --with-python-config-dir=PATH  Python's config directory],
  351.     [ vi_cv_path_python_conf="${withval}" ] )
  352.  
  353.       AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python_conf,
  354.       [
  355.     vi_cv_path_python_conf=
  356.     for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
  357.       for subdir in lib share; do
  358.         d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
  359.         if test -d "$d" && test -f "$d/config.c"; then
  360.           vi_cv_path_python_conf="$d"
  361.         fi
  362.       done
  363.     done
  364.       ])
  365.  
  366.       PYTHON_CONFDIR="${vi_cv_path_python_conf}"
  367.  
  368.       if test "X$PYTHON_CONFDIR" = "X"; then
  369.     AC_MSG_RESULT([can't find it!])
  370.       else
  371.  
  372.     dnl -- we need to examine Python's config/Makefile too
  373.     dnl    see what the interpreter is built from
  374.     AC_CACHE_VAL(vi_cv_path_python_plibs,
  375.     [
  376.         tmp_mkf="/tmp/Makefile-conf$$"
  377.         cat ${PYTHON_CONFDIR}/Makefile - <<'eof' >${tmp_mkf}
  378. __:
  379.     @echo "python_MODLIBS='$(MODLIBS)'"
  380.     @echo "python_LIBS='$(LIBS)'"
  381.     @echo "python_SYSLIBS='$(SYSLIBS)'"
  382.     @echo "python_LINKFORSHARED='$(LINKFORSHARED)'"
  383. eof
  384.         dnl -- delete the lines from make about Entering/Leaving directory
  385.         eval "`cd ${PYTHON_CONFDIR} && make -f ${tmp_mkf} __ | sed '/ directory /d'`"
  386.         rm -f ${tmp_mkf}
  387.         if test "${vi_cv_var_python_version}" = "1.4"; then
  388.         vi_cv_path_python_plibs="${PYTHON_CONFDIR}/libModules.a ${PYTHON_CONFDIR}/libPython.a ${PYTHON_CONFDIR}/libObjects.a ${PYTHON_CONFDIR}/libParser.a"
  389.         else
  390.         vi_cv_path_python_plibs="-L${PYTHON_CONFDIR} -lpython${vi_cv_var_python_version}"
  391.         fi
  392.         vi_cv_path_python_plibs="${vi_cv_path_python_plibs} ${python_MODLIBS} ${python_LIBS} ${python_SYSLIBS} ${python_LINKFORSHARED}"
  393.         dnl remove -ltermcap, it can conflict with an earlier -lncurses
  394.         vi_cv_path_python_plibs=`echo $vi_cv_path_python_plibs | sed s/-ltermcap//`
  395.     ])
  396.  
  397.     PYTHON_LIBS="${vi_cv_path_python_plibs}"
  398.     if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
  399.       PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version}"
  400.     else
  401.       PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -I${vi_cv_path_python_epfx}/include/python${vi_cv_var_python_version}"
  402.     fi
  403.     PYTHON_SRC="if_python.c"
  404.     PYTHON_OBJ="objects/if_python.o objects/py_config.o"
  405.     if test "${vi_cv_var_python_version}" = "1.4"; then
  406.        PYTHON_OBJ="$PYTHON_OBJ objects/py_getpath.o"
  407.     fi
  408.     PYTHON_GETPATH_CFLAGS="-DPYTHONPATH='\"${vi_cv_path_pythonpath}\"' -DPREFIX='\"${vi_cv_path_python_pfx}\"' -DEXEC_PREFIX='\"${vi_cv_path_python_epfx}\"'"
  409.  
  410.     dnl On FreeBSD linking with "-pthread" is required to use threads.
  411.     dnl _THREAD_SAFE must be used for compiling then.
  412.     dnl The "-pthread" is added to $LIBS, so that the following check for
  413.     dnl sigaltstack() will look in libc_r (it's there in libc!).
  414.     dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS.  GCC
  415.     dnl will then define target-specific defines, e.g., -D_REENTRANT.
  416.     AC_MSG_CHECKING([if -pthread should be used])
  417.     threadsafe_flag=
  418.     thread_lib=
  419.     test "$GCC" = yes && threadsafe_flag="-pthread"
  420.     if test "`(uname) 2>/dev/null`" = FreeBSD; then
  421.       threadsafe_flag="-D_THREAD_SAFE"
  422.       thread_lib="-pthread"
  423.     fi
  424.     if test -n "$threadsafe_flag"; then
  425.       cflags_save=$CFLAGS
  426.       libs_save=$LIBS
  427.       CFLAGS="$CFLAGS $threadsafe_flag"
  428.       LIBS="$LIBS $thread_lib"
  429.       AC_TRY_LINK(,[ ],
  430.          AC_MSG_RESULT(yes); PYTHON_CFLAGS="$PYTHON_CFLAGS $threadsafe_flag",
  431.          AC_MSG_RESULT(no); LIBS=$libs_save
  432.          )
  433.       CFLAGS=$cflags_save
  434.     else
  435.       AC_MSG_RESULT(no)
  436.     fi
  437.  
  438.     AC_DEFINE(FEAT_PYTHON)
  439.  
  440.       fi
  441.     else
  442.       AC_MSG_RESULT(too old)
  443.     fi
  444.   fi
  445. fi
  446. AC_SUBST(PYTHON_CONFDIR)
  447. AC_SUBST(PYTHON_LIBS)
  448. AC_SUBST(PYTHON_GETPATH_CFLAGS)
  449. AC_SUBST(PYTHON_CFLAGS)
  450. AC_SUBST(PYTHON_SRC)
  451. AC_SUBST(PYTHON_OBJ)
  452.  
  453. AC_MSG_CHECKING(--enable-tclinterp argument)
  454. AC_ARG_ENABLE(tclinterp,
  455.     [  --enable-tclinterp      Include Tcl interpreter.], ,
  456.     [enable_tclinterp="no"])
  457. AC_MSG_RESULT($enable_tclinterp)
  458.  
  459. if test "$enable_tclinterp" = "yes"; then
  460.  
  461.   dnl on FreeBSD tclsh is a silly script, look for tclsh8.0 or tclsh8.2
  462.   AC_MSG_CHECKING(--with-tclsh argument)
  463.   AC_ARG_WITH(tclsh, [  --with-tclsh=PATH       which tclsh to use (default: tclsh8.0)],
  464.     tclsh_name="$withval"; AC_MSG_RESULT($tclsh_name),
  465.     tclsh_name="tclsh8.0"; AC_MSG_RESULT(no))
  466.   AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
  467.   AC_SUBST(vi_cv_path_tcl)
  468.  
  469.   dnl when no specific version specified, also try 8.2
  470.   if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.0"; then
  471.     tclsh_name="tclsh8.2"
  472.     AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
  473.   fi
  474.   dnl still didn't find it, try without version number
  475.   if test "X$vi_cv_path_tcl" = "X"; then
  476.     tclsh_name="tclsh"
  477.     AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
  478.   fi
  479.   if test "X$vi_cv_path_tcl" != "X"; then
  480.     AC_MSG_CHECKING(Tcl version)
  481.     if echo 'exit [[expr [info tclversion] < 8.0]]' | $vi_cv_path_tcl - ; then
  482.       tclver=`echo 'puts [[info tclversion]]' | $vi_cv_path_tcl -`
  483.       AC_MSG_RESULT($tclver - OK);
  484.       tclloc=`echo 'set l [[info library]];set i [[string last lib $l]];incr i -2;puts [[string range $l 0 $i]]' | $vi_cv_path_tcl -`
  485.  
  486.       AC_MSG_CHECKING(for location of Tcl include)
  487.       tclinc="$tclloc/include $tclloc/include/tcl $tclloc/include/tcl$tclver /usr/local/include"
  488.       for try in $tclinc; do
  489.     if test -f "$try/tcl.h"; then
  490.       AC_MSG_RESULT($try/tcl.h)
  491.       TCL_INC=$try
  492.       break
  493.     fi
  494.       done
  495.       if test -z "$TCL_INC"; then
  496.     AC_MSG_RESULT(<not found>)
  497.     SKIP_TCL=YES
  498.       fi
  499.       if test -z "$SKIP_TCL"; then
  500.     AC_MSG_CHECKING(for location of tclConfig.sh script)
  501.     tclcnf=`echo $tclinc | sed s/include/lib/g`
  502.     for try in $tclcnf; do
  503.       if test -f $try/tclConfig.sh; then
  504.         AC_MSG_RESULT($try/tclConfig.sh)
  505.         . $try/tclConfig.sh
  506.         dnl use eval, because tcl 8.2 includes ${TCL_DBGX}
  507.         TCL_LIBS=`eval echo "$TCL_LIB_SPEC $TCL_LIBS"`
  508.         break
  509.       fi
  510.     done
  511.     if test -z "$TCL_LIBS"; then
  512.       AC_MSG_RESULT(<not found>)
  513.       AC_MSG_CHECKING(for Tcl library by myself)
  514.       tcllib=`echo $tclinc | sed s/include/lib/g`
  515.       for ext in .so .a ; do
  516.         for ver in "" $tclver ; do
  517.           for try in $tcllib ; do
  518.         trylib=tcl$ver$ext
  519.         if test -f $try/lib$trylib ; then
  520.           AC_MSG_RESULT($try/lib$trylib)
  521.           TCL_LIBS="-L$try -ltcl$ver -ldl -lm"
  522.           if test "`(uname) 2>/dev/null`" = SunOS &&
  523.                      uname -r | grep '^5' >/dev/null; then
  524.             TCL_LIBS="$TCL_LIBS -R $try"
  525.           fi
  526.           break 3
  527.         fi
  528.           done
  529.         done
  530.       done
  531.       if test -z "$TCL_LIBS"; then
  532.         AC_MSG_RESULT(<not found>)
  533.         SKIP_TCL=YES
  534.       fi
  535.     fi
  536.     if test -z "$SKIP_TCL"; then
  537.       AC_DEFINE(FEAT_TCL)
  538.       TCL_SRC=if_tcl.c
  539.       TCL_OBJ=objects/if_tcl.o
  540.       TCL_PRO=if_tcl.pro
  541.       TCL_CFLAGS="-I$TCL_INC"
  542.     fi
  543.       fi
  544.     else
  545.       AC_MSG_RESULT(too old; need Tcl version 8.0 or later)
  546.     fi
  547.   fi
  548. fi
  549. AC_SUBST(TCL_SRC)
  550. AC_SUBST(TCL_OBJ)
  551. AC_SUBST(TCL_PRO)
  552. AC_SUBST(TCL_CFLAGS)
  553. AC_SUBST(TCL_LIBS)
  554.  
  555. AC_MSG_CHECKING(--enable-rubyinterp argument)
  556. AC_ARG_ENABLE(rubyinterp,
  557.     [  --enable-rubyinterp     Include Ruby interpreter.], ,
  558.     [enable_rubyinterp="no"])
  559. AC_MSG_RESULT($enable_rubyinterp)
  560. if test "$enable_rubyinterp" = "yes"; then
  561.   AC_SUBST(vi_cv_path_ruby)
  562.   AC_PATH_PROG(vi_cv_path_ruby, ruby)
  563.   if test "X$vi_cv_path_ruby" != "X"; then
  564.     AC_MSG_CHECKING(Ruby version)
  565.     if $vi_cv_path_ruby -e 'VERSION >= "1.6.0" or exit 1' >/dev/null 2>/dev/null; then
  566.       AC_MSG_RESULT(OK)
  567.       rubyhdrdir=`$vi_cv_path_ruby -r mkmf -e 'print Config::CONFIG[["archdir"]] || $hdrdir'`
  568.       RUBY_CFLAGS="-I$rubyhdrdir"
  569.       rubylibs=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG[["LIBS"]]'`
  570.       if test "X$rubylibs" != "X"; then
  571.     RUBY_LIBS="$rubylibs"
  572.       fi
  573.       librubyarg=`$vi_cv_path_ruby -r rbconfig -e 'print Config.expand(Config::CONFIG[["LIBRUBYARG"]])'`
  574.       if test -f "$rubyhdrdir/$librubyarg"; then
  575.     librubyarg="$rubyhdrdir/$librubyarg"
  576.       else
  577.     librubyarg=`$vi_cv_path_ruby -r rbconfig -e "print '$librubyarg'.gsub(/-L\./, %'-L#{Config.expand(Config::CONFIG[\"libdir\"])}')"`
  578.       fi
  579.  
  580.       if test "X$librubyarg" != "X"; then
  581.     RUBY_LIBS="$librubyarg $RUBY_LIBS"
  582.       fi
  583.       rubyldflags=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG[["LDFLAGS"]]'`
  584.       if test "X$rubyldflags" != "X"; then
  585.     LDFLAGS="$rubyldflags $LDFLAGS"
  586.       fi
  587.       RUBY_SRC="if_ruby.c"
  588.       RUBY_OBJ="objects/if_ruby.o"
  589.       RUBY_PRO="if_ruby.pro"
  590.       AC_DEFINE(FEAT_RUBY)
  591.     else
  592.       AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
  593.     fi
  594.   fi
  595. fi
  596. AC_SUBST(RUBY_SRC)
  597. AC_SUBST(RUBY_OBJ)
  598. AC_SUBST(RUBY_PRO)
  599. AC_SUBST(RUBY_CFLAGS)
  600. AC_SUBST(RUBY_LIBS)
  601.  
  602. AC_MSG_CHECKING(--enable-cscope argument)
  603. AC_ARG_ENABLE(cscope,
  604.     [  --enable-cscope         Include cscope interface.], ,
  605.     [enable_cscope="no"])
  606. AC_MSG_RESULT($enable_cscope)
  607. if test "$enable_cscope" = "yes"; then
  608.   AC_DEFINE(FEAT_CSCOPE)
  609. fi
  610.  
  611. AC_MSG_CHECKING(--enable-workshop argument)
  612. AC_ARG_ENABLE(workshop,
  613.     [  --enable-workshop       Include Sun Visual Workshop support.], ,
  614.     [enable_workshop="no"])
  615. AC_MSG_RESULT($enable_workshop)
  616. if test "$enable_workshop" = "yes"; then
  617.   AC_DEFINE(FEAT_SUN_WORKSHOP)
  618.   WORKSHOP_SRC="workshop.c integration.c"
  619.   AC_SUBST(WORKSHOP_SRC)
  620.   WORKSHOP_OBJ="objects/workshop.o objects/integration.o"
  621.   AC_SUBST(WORKSHOP_OBJ)
  622.   if test "${enable_gui-xxx}" = xxx; then
  623.     enable_gui=motif
  624.   fi
  625. fi
  626.  
  627. AC_MSG_CHECKING(--disable-netbeans argument)
  628. AC_ARG_ENABLE(netbeans,
  629.     [  --disable-netbeans      Disable NetBeans integration support.],
  630.     , [enable_netbeans="yes"])
  631. if test "$enable_netbeans" = "yes"; then
  632.   AC_MSG_RESULT(no)
  633.   dnl On Solaris we need the socket and nsl library.
  634.   AC_CHECK_LIB(socket, socket)
  635.   AC_CHECK_LIB(nsl, gethostbyname)
  636.   AC_MSG_CHECKING(whether compiling netbeans integration is possible)
  637.   AC_TRY_LINK([
  638. #include <stdio.h>
  639. #include <stdlib.h>
  640. #include <stdarg.h>
  641. #include <fcntl.h>
  642. #include <netdb.h>
  643. #include <netinet/in.h>
  644. #include <errno.h>
  645. #include <sys/types.h>
  646. #include <sys/socket.h>
  647.     /* Check bitfields */
  648.     struct nbbuf {
  649.     unsigned int  initDone:1;
  650.     ushort signmaplen;
  651.     };
  652.         ], [
  653.         /* Check creating a socket. */
  654.         struct sockaddr_in server;
  655.         (void)socket(AF_INET, SOCK_STREAM, 0);
  656.         (void)htons(100);
  657.         (void)gethostbyname("microsoft.com");
  658.         if (errno == ECONNREFUSED)
  659.           (void)connect(1, (struct sockaddr *)&server, sizeof(server));
  660.         ],
  661.     AC_MSG_RESULT(yes),
  662.     AC_MSG_RESULT(no); enable_netbeans="no")
  663. else
  664.   AC_MSG_RESULT(yes)
  665. fi
  666. if test "$enable_netbeans" = "yes"; then
  667.   AC_DEFINE(FEAT_NETBEANS_INTG)
  668.   NETBEANS_SRC="netbeans.c"
  669.   AC_SUBST(NETBEANS_SRC)
  670.   NETBEANS_OBJ="objects/netbeans.o"
  671.   AC_SUBST(NETBEANS_OBJ)
  672. fi
  673.  
  674. AC_MSG_CHECKING(--enable-sniff argument)
  675. AC_ARG_ENABLE(sniff,
  676.     [  --enable-sniff          Include Sniff interface.], ,
  677.     [enable_sniff="no"])
  678. AC_MSG_RESULT($enable_sniff)
  679. if test "$enable_sniff" = "yes"; then
  680.   AC_DEFINE(FEAT_SNIFF)
  681.   SNIFF_SRC="if_sniff.c"
  682.   AC_SUBST(SNIFF_SRC)
  683.   SNIFF_OBJ="objects/if_sniff.o"
  684.   AC_SUBST(SNIFF_OBJ)
  685. fi
  686.  
  687. AC_MSG_CHECKING(--enable-multibyte argument)
  688. AC_ARG_ENABLE(multibyte,
  689.     [  --enable-multibyte      Include multibyte editing support.], ,
  690.     [enable_multibyte="no"])
  691. AC_MSG_RESULT($enable_multibyte)
  692. if test "$enable_multibyte" = "yes"; then
  693.   AC_DEFINE(FEAT_MBYTE)
  694. fi
  695.  
  696. AC_MSG_CHECKING(--enable-hangulinput argument)
  697. AC_ARG_ENABLE(hangulinput,
  698.     [  --enable-hangulinput    Include Hangul input support.], ,
  699.     [enable_hangulinput="no"])
  700. AC_MSG_RESULT($enable_hangulinput)
  701.  
  702. AC_MSG_CHECKING(--enable-xim argument)
  703. AC_ARG_ENABLE(xim,
  704.     [  --enable-xim            Include XIM input support.],
  705.     AC_MSG_RESULT($enable_xim),
  706.     [enable_xim="auto"; AC_MSG_RESULT(defaulting to auto)])
  707. dnl defining FEAT_XIM is delayed, so that it can be disabled for older GTK
  708.  
  709. AC_MSG_CHECKING(--enable-fontset argument)
  710. AC_ARG_ENABLE(fontset,
  711.     [  --enable-fontset        Include X fontset output support.], ,
  712.     [enable_fontset="no"])
  713. AC_MSG_RESULT($enable_fontset)
  714. dnl defining FEAT_XFONTSET is delayed, so that it can be disabled for no GUI
  715.  
  716. test -z "$with_x" && with_x=yes
  717. test "${enable_gui-yes}" != no -a "x$QNX" != "xyes" && with_x=yes
  718. if test "$with_x" = no; then
  719.   AC_MSG_RESULT(defaulting to: don't HAVE_X11)
  720. else
  721.   dnl Do this check early, so that its failure can override user requests.
  722.  
  723.   AC_PATH_PROG(xmkmfpath, xmkmf)
  724.  
  725.   AC_PATH_XTRA
  726.  
  727.   dnl On OS390Unix the X libraries are DLLs. To use them the code must
  728.   dnl be compiled with a special option.
  729.   dnl Also add SM, ICE and Xmu to X_EXTRA_LIBS.
  730.   if test "$OS390Unix" = "yes"; then
  731.     CFLAGS="$CFLAGS -W c,dll"
  732.     LDFLAGS="$LDFLAGS -W l,dll"
  733.     X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE -lXmu"
  734.   fi
  735.  
  736.   dnl On my HPUX system the X include dir is found, but the lib dir not.
  737.   dnl This is a desparate try to fix this.
  738.  
  739.   if test -d "$x_includes" && test ! -d "$x_libraries"; then
  740.     x_libraries=`echo "$x_includes" | sed s/include/lib/`
  741.     AC_MSG_RESULT(Corrected X libraries to $x_libraries)
  742.     X_LIBS="$X_LIBS -L$x_libraries"
  743.     if test "`(uname) 2>/dev/null`" = SunOS &&
  744.                      uname -r | grep '^5' >/dev/null; then
  745.       X_LIBS="$X_LIBS -R $x_libraries"
  746.     fi
  747.   fi
  748.  
  749.   if test -d "$x_libraries" && test ! -d "$x_includes"; then
  750.     x_includes=`echo "$x_libraries" | sed s/lib/include/`
  751.     AC_MSG_RESULT(Corrected X includes to $x_includes)
  752.     X_CFLAGS="$X_CFLAGS -I$x_includes"
  753.   fi
  754.  
  755.   dnl Remove "-I/usr/include " from X_CFLAGS, should not be needed.
  756.   X_CFLAGS="`echo $X_CFLAGS\  | sed 's%-I/usr/include %%'`"
  757.   dnl Remove " -L/usr/lib" from X_LIBS, should not be needed.
  758.   X_LIBS="`echo $X_LIBS\  | sed 's% -L/usr/lib%%'`"
  759.  
  760.  
  761.   dnl Check if the X11 header files are correctly installed. On some systems
  762.   dnl Xlib.h includes files that don't exist
  763.   AC_MSG_CHECKING(if X11 header files can be found)
  764.   cflags_save=$CFLAGS
  765.   CFLAGS="$CFLAGS $X_CFLAGS"
  766.   AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
  767.     AC_MSG_RESULT(yes),
  768.     AC_MSG_RESULT(no); no_x=yes)
  769.   CFLAGS=$cflags_save
  770.  
  771.   if test "${no_x-no}" = yes; then
  772.     with_x=no
  773.   else
  774.     AC_DEFINE(HAVE_X11)
  775.     X_LIB="-lXt -lX11";
  776.     AC_SUBST(X_LIB)
  777.  
  778.     ac_save_LDFLAGS="$LDFLAGS"
  779.     LDFLAGS="-L$x_libraries $LDFLAGS"
  780.  
  781.     dnl Check for -lXdmcp (needed on SunOS 4.1.4)
  782.     dnl For HP-UX 10.20 it must be before -lSM -lICE
  783.     AC_CHECK_LIB(Xdmcp, _XdmcpAuthDoIt, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lXdmcp"],,
  784.         [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXdmcp])
  785.  
  786.     dnl Some systems need -lnsl -lsocket when testing for ICE.
  787.     dnl The check above doesn't do this, try here (again).  Also needed to get
  788.     dnl them after Xdmcp.  link.sh will remove them when not needed.
  789.     dnl Check for other function than above to avoid the cached value
  790.     AC_CHECK_LIB(ICE, IceOpenConnection,
  791.           [X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE"],, [$X_EXTRA_LIBS])
  792.  
  793.     dnl Check for -lXpm (needed for some versions of Motif)
  794.     LDFLAGS="$X_LIBS $ac_save_LDFLAGS"
  795.     AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [X_PRE_LIBS="$X_PRE_LIBS -lXpm"],,
  796.         [-lXt $X_PRE_LIBS -lXpm -lX11 $X_EXTRA_LIBS])
  797.  
  798.     dnl Check that the X11 header files don't use implicit declarations
  799.     AC_MSG_CHECKING(if X11 header files implicitly declare return values)
  800.     cflags_save=$CFLAGS
  801.     CFLAGS="$CFLAGS $X_CFLAGS -Werror"
  802.     AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
  803.     AC_MSG_RESULT(no),
  804.     CFLAGS="$CFLAGS -Wno-implicit-int"
  805.     AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
  806.         AC_MSG_RESULT(yes); cflags_save="$cflags_save -Wno-implicit-int",
  807.         AC_MSG_RESULT(test failed)
  808.     )
  809.     )
  810.     CFLAGS=$cflags_save
  811.  
  812.     LDFLAGS="$ac_save_LDFLAGS"
  813.  
  814.   fi
  815. fi
  816.  
  817. test "x$with_x" = xno -a "x$BEOS" != "xyes" -a "x$QNX" != "xyes" && enable_gui=no
  818.  
  819. AC_MSG_CHECKING(--enable-gui argument)
  820. AC_ARG_ENABLE(gui,
  821.  [  --enable-gui[=OPTS]     X11 GUI [default=auto] [OPTS=auto/no/gtk/gtk2/gnome/gnome2/motif/athena/neXtaw/beos/photon]], , enable_gui="auto")
  822.  
  823. ## Canonicalize the --enable-gui= argument so that it can be easily compared.
  824. ## Do not use character classes for portability with old tools.
  825. enable_gui_canon=`echo "_$enable_gui" | \
  826.     sed 's/[[ _+-]]//g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
  827.  
  828. if test "x$BEOS" = "xyes"; then
  829.  
  830.   SKIP_GTK=YES
  831.   SKIP_GTK2=YES
  832.   SKIP_GNOME=YES
  833.   SKIP_MOTIF=YES
  834.   SKIP_ATHENA=YES
  835.   SKIP_NEXTAW=YES
  836.   SKIP_PHOTON=YES
  837.   SKIP_BEOS=
  838.   GUITYPE=NONE
  839.  
  840.   case "$enable_gui_canon" in
  841.     no)        AC_MSG_RESULT(no GUI support)
  842.         SKIP_BEOS=YES ;;
  843.     yes|"")    AC_MSG_RESULT(yes - automatic GUI support) ;;
  844.     auto)    AC_MSG_RESULT(auto - automatic GUI support) ;;
  845.     beos)    AC_MSG_RESULT(BeOS GUI support) ;;
  846.     *)        AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
  847.   esac
  848.  
  849. elif test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
  850.   SKIP_GTK=YES
  851.   SKIP_GTK2=YES
  852.   SKIP_GNOME=YES
  853.   SKIP_MOTIF=YES
  854.   SKIP_ATHENA=YES
  855.   SKIP_NEXTAW=YES
  856.   SKIP_BEOS=YES
  857.   SKIP_PHOTON=
  858.   GUITYPE=NONE
  859.  
  860.   case "$enable_gui_canon" in
  861.     no)        AC_MSG_RESULT(no GUI support)
  862.         SKIP_PHOTON=YES ;;
  863.     yes|"")    AC_MSG_RESULT(yes - automatic GUI support) ;;
  864.     auto)    AC_MSG_RESULT(auto - automatic GUI support) ;;
  865.     photon)    AC_MSG_RESULT(Photon GUI support) ;;
  866.     *)        AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
  867.   esac
  868.  
  869. else
  870.  
  871.   SKIP_GTK=
  872.   SKIP_GTK2=
  873.   SKIP_GNOME=
  874.   SKIP_MOTIF=
  875.   SKIP_ATHENA=
  876.   SKIP_NEXTAW=
  877.   SKIP_BEOS=YES
  878.   SKIP_PHOTON=YES
  879.   GUITYPE=NONE
  880.  
  881.   case "$enable_gui_canon" in
  882.     no|none)    AC_MSG_RESULT(no GUI support)
  883.         SKIP_GTK=YES; SKIP_GTK2=YES; SKIP_GNOME=YES; SKIP_MOTIF=YES; SKIP_ATHENA=YES; SKIP_NEXTAW=YES ;;
  884.     yes|"")    AC_MSG_RESULT(yes - automatic GUI support) ;;
  885.     auto)    AC_MSG_RESULT(auto - automatic GUI support) ;;
  886.     gtk)    AC_MSG_RESULT(GTK+ 1.x GUI support)
  887.         SKIP_GTK2=YES; SKIP_GNOME=YES; SKIP_MOTIF=YES; SKIP_ATHENA=YES; SKIP_NEXTAW=YES ;;
  888.     gtk2)    AC_MSG_RESULT(GTK+ 2.x GUI support)
  889.         SKIP_GNOME=YES; SKIP_MOTIF=YES; SKIP_ATHENA=YES; SKIP_NEXTAW=YES ;;
  890.     gnome)    AC_MSG_RESULT(GNOME 1.x GUI support)
  891.         SKIP_GTK2=YES; SKIP_MOTIF=YES; SKIP_ATHENA=YES; SKIP_NEXTAW=YES ;;
  892.     gnome2)    AC_MSG_RESULT(GNOME 2.x GUI support)
  893.         SKIP_MOTIF=YES; SKIP_ATHENA=YES; SKIP_NEXTAW=YES ;;
  894.     motif)    AC_MSG_RESULT(Motif GUI support)
  895.         SKIP_GTK=YES; SKIP_GNOME=YES; SKIP_ATHENA=YES; SKIP_NEXTAW=YES ;;
  896.     athena)    AC_MSG_RESULT(Athena GUI support)
  897.         SKIP_GTK=YES; SKIP_GNOME=YES; SKIP_MOTIF=YES; SKIP_NEXTAW=YES ;;
  898.     nextaw)    AC_MSG_RESULT(neXtaw GUI support)
  899.         SKIP_GTK=YES; SKIP_GNOME=YES; SKIP_MOTIF=YES; SKIP_ATHENA=YES ;;
  900.     *)        AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
  901.   esac
  902.  
  903. fi
  904.  
  905. if test "x$SKIP_GTK" != "xYES" -a "$enable_gui_canon" != "gtk" -a "$enable_gui_canon" != "gtk2"; then
  906.   AC_MSG_CHECKING(whether or not to look for GTK)
  907.   AC_ARG_ENABLE(gtk-check,
  908.     [  --enable-gtk-check      If auto-select GUI, check for GTK [default=yes]],
  909.     , enable_gtk_check="yes")
  910.   AC_MSG_RESULT($enable_gtk_check)
  911.   if test "x$enable_gtk_check" = "xno"; then
  912.     SKIP_GTK=YES
  913.     SKIP_GNOME=YES
  914.   fi
  915. fi
  916.  
  917. if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \
  918.                 -a "$enable_gui_canon" != "gnome2"; then
  919.   AC_MSG_CHECKING(whether or not to look for GTK+ 2)
  920.   AC_ARG_ENABLE(gtk2-check,
  921.     [  --enable-gtk2-check     If GTK GUI, check for GTK+ 2 [default=yes]],
  922.     , enable_gtk2_check="yes")
  923.   AC_MSG_RESULT($enable_gtk2_check)
  924.   if test "x$enable_gtk2_check" = "xno"; then
  925.     SKIP_GTK2=YES
  926.   fi
  927. fi
  928.  
  929. if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome" \
  930.                  -a "$enable_gui_canon" != "gnome2"; then
  931.   AC_MSG_CHECKING(whether or not to look for GNOME)
  932.   AC_ARG_ENABLE(gnome-check,
  933.     [  --enable-gnome-check    If GTK GUI, check for GNOME [default=no]],
  934.     , enable_gnome_check="no")
  935.   AC_MSG_RESULT($enable_gnome_check)
  936.   if test "x$enable_gnome_check" = "xno"; then
  937.     SKIP_GNOME=YES
  938.   fi
  939. fi
  940.  
  941. if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then
  942.   AC_MSG_CHECKING(whether or not to look for Motif)
  943.   AC_ARG_ENABLE(motif-check,
  944.     [  --enable-motif-check    If auto-select GUI, check for Motif [default=yes]],
  945.     , enable_motif_check="yes")
  946.   AC_MSG_RESULT($enable_motif_check)
  947.   if test "x$enable_motif_check" = "xno"; then
  948.     SKIP_MOTIF=YES
  949.   fi
  950. fi
  951.  
  952. if test "x$SKIP_ATHENA" != "xYES" -a "$enable_gui_canon" != "athena"; then
  953.   AC_MSG_CHECKING(whether or not to look for Athena)
  954.   AC_ARG_ENABLE(athena-check,
  955.     [  --enable-athena-check   If auto-select GUI, check for Athena [default=yes]],
  956.     , enable_athena_check="yes")
  957.   AC_MSG_RESULT($enable_athena_check)
  958.   if test "x$enable_athena_check" = "xno"; then
  959.     SKIP_ATHENA=YES
  960.   fi
  961. fi
  962.  
  963. if test "x$SKIP_NEXTAW" != "xYES" -a "$enable_gui_canon" != "nextaw"; then
  964.   AC_MSG_CHECKING(whether or not to look for neXtaw)
  965.   AC_ARG_ENABLE(nextaw-check,
  966.     [  --enable-nextaw-check   If auto-select GUI, check for neXtaw [default=yes]],
  967.     , enable_nextaw_check="yes")
  968.   AC_MSG_RESULT($enable_nextaw_check);
  969.   if test "x$enable_nextaw_check" = "xno"; then
  970.     SKIP_NEXTAW=YES
  971.   fi
  972. fi
  973.  
  974.  
  975. dnl
  976. dnl Get the cflags and libraries from the gtk-config script
  977. dnl
  978.  
  979. dnl define an autoconf function to check for a specified version of GTK, and
  980. dnl try to compile/link a GTK program.  this gets used once for GTK 1.1.16.
  981. dnl
  982. dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
  983. dnl Test for GTK, and define GTK_CFLAGS and GTK_LIBS
  984. dnl
  985. AC_DEFUN(AM_PATH_GTK,
  986. [
  987.   if test "X$GTK_CONFIG" != "Xno" -o "X$PKG_CONFIG" != "Xno"; then
  988.   {
  989.     min_gtk_version=ifelse([$1], ,0.99.7,$1)
  990.     AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
  991.     no_gtk=""
  992.     if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
  993.       && $PKG_CONFIG --exists gtk+-2.0; then
  994.     {
  995.       dnl We should be using PKG_CHECK_MODULES() instead of this hack.
  996.       dnl But I guess the dependency on pkgconfig.m4 is not wanted or
  997.       dnl something like that.
  998.       GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0`
  999.       GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0`
  1000.       gtk_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
  1001.          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
  1002.       gtk_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
  1003.          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
  1004.       gtk_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
  1005.          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
  1006.     }
  1007.     elif test "X$GTK_CONFIG" != "Xno"; then
  1008.     {
  1009.       GTK_CFLAGS=`$GTK_CONFIG $gtk_config_args --cflags`
  1010.       GTK_LIBS=`$GTK_CONFIG $gtk_config_args --libs`
  1011.       gtk_major_version=`$GTK_CONFIG $gtk_config_args --version | \
  1012.          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
  1013.       gtk_minor_version=`$GTK_CONFIG $gtk_config_args --version | \
  1014.          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
  1015.       gtk_micro_version=`$GTK_CONFIG $gtk_config_args --version | \
  1016.          sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
  1017.     }
  1018.     else
  1019.       no_gtk=yes
  1020.     fi
  1021.  
  1022.     if test "x$enable_gtktest" = "xyes" -a "x$no_gtk" = "x"; then
  1023.     {
  1024.       ac_save_CFLAGS="$CFLAGS"
  1025.       ac_save_LIBS="$LIBS"
  1026.       CFLAGS="$CFLAGS $GTK_CFLAGS"
  1027.       LIBS="$LIBS $GTK_LIBS"
  1028.  
  1029.       dnl
  1030.       dnl Now check if the installed GTK is sufficiently new. (Also sanity
  1031.       dnl checks the results of gtk-config to some extent
  1032.       dnl
  1033.       rm -f conf.gtktest
  1034.       AC_TRY_RUN([
  1035. #include <gtk/gtk.h>
  1036. #include <stdio.h>
  1037.  
  1038. int
  1039. main ()
  1040. {
  1041. int major, minor, micro;
  1042. char *tmp_version;
  1043.  
  1044. system ("touch conf.gtktest");
  1045.  
  1046. /* HP/UX 9 (%@#!) writes to sscanf strings */
  1047. tmp_version = g_strdup("$min_gtk_version");
  1048. if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
  1049.    printf("%s, bad version string\n", "$min_gtk_version");
  1050.    exit(1);
  1051.  }
  1052.  
  1053. if ((gtk_major_version > major) ||
  1054.     ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
  1055.     ((gtk_major_version == major) && (gtk_minor_version == minor) &&
  1056.                      (gtk_micro_version >= micro)))
  1057. {
  1058.     return 0;
  1059. }
  1060. return 1;
  1061. }
  1062. ],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
  1063.       CFLAGS="$ac_save_CFLAGS"
  1064.       LIBS="$ac_save_LIBS"
  1065.     }
  1066.     fi
  1067.     if test "x$no_gtk" = x ; then
  1068.       if test "x$enable_gtktest" = "xyes"; then
  1069.     AC_MSG_RESULT(yes; found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
  1070.       else
  1071.     AC_MSG_RESULT(found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
  1072.       fi
  1073.       ifelse([$2], , :, [$2])
  1074.     else
  1075.     {
  1076.       AC_MSG_RESULT(no)
  1077.       GTK_CFLAGS=""
  1078.       GTK_LIBS=""
  1079.       ifelse([$3], , :, [$3])
  1080.     }
  1081.     fi
  1082.   }
  1083.   else
  1084.     GTK_CFLAGS=""
  1085.     GTK_LIBS=""
  1086.     ifelse([$3], , :, [$3])
  1087.   fi
  1088.   AC_SUBST(GTK_CFLAGS)
  1089.   AC_SUBST(GTK_LIBS)
  1090.   rm -f conf.gtktest
  1091. ])
  1092.  
  1093. dnl ---------------------------------------------------------------------------
  1094. dnl gnome
  1095. dnl ---------------------------------------------------------------------------
  1096. AC_DEFUN([GNOME_INIT_HOOK],
  1097. [
  1098.   AC_SUBST(GNOME_LIBS)
  1099.   AC_SUBST(GNOME_LIBDIR)
  1100.   AC_SUBST(GNOME_INCLUDEDIR)
  1101.  
  1102.   AC_ARG_WITH(gnome-includes,
  1103.     [  --with-gnome-includes=DIR Specify location of GNOME headers],
  1104.     [CFLAGS="$CFLAGS -I$withval"]
  1105.   )
  1106.  
  1107.   AC_ARG_WITH(gnome-libs,
  1108.     [  --with-gnome-libs=DIR   Specify location of GNOME libs],
  1109.     [LDFLAGS="$LDFLAGS -L$withval" gnome_prefix=$withval]
  1110.   )
  1111.  
  1112.   AC_ARG_WITH(gnome,
  1113.     [  --with-gnome            Specify prefix for GNOME files],
  1114.     if test x$withval = xyes; then
  1115.       want_gnome=yes
  1116.       ifelse([$1], [], :, [$1])
  1117.     else
  1118.       if test "x$withval" = xno; then
  1119.     want_gnome=no
  1120.       else
  1121.     want_gnome=yes
  1122.     LDFLAGS="$LDFLAGS -L$withval/lib"
  1123.     CFLAGS="$CFLAGS -I$withval/include"
  1124.     gnome_prefix=$withval/lib
  1125.       fi
  1126.     fi,
  1127.     want_gnome=yes)
  1128.  
  1129.   if test "x$want_gnome" = xyes -a "0$gtk_major_version" -ge 2; then
  1130.   {
  1131.     AC_MSG_CHECKING(for libgnomeui-2.0)
  1132.     if $PKG_CONFIG --exists libgnomeui-2.0; then
  1133.       AC_MSG_RESULT(yes)
  1134.       GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0`
  1135.       GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0`
  1136.       GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0`
  1137.       $1
  1138.     else
  1139.       AC_MSG_RESULT(not found)
  1140.       if test "x$2" = xfail; then
  1141.     AC_MSG_ERROR(Could not find libgnomeui-2.0 via pkg-config)
  1142.       fi
  1143.     fi
  1144.   }
  1145.   elif test "x$want_gnome" = xyes; then
  1146.   {
  1147.     AC_PATH_PROG(GNOME_CONFIG,gnome-config,no)
  1148.     if test "$GNOME_CONFIG" = "no"; then
  1149.       no_gnome_config="yes"
  1150.     else
  1151.       AC_MSG_CHECKING(if $GNOME_CONFIG works)
  1152.       if $GNOME_CONFIG --libs-only-l gnome >/dev/null 2>&1; then
  1153.     AC_MSG_RESULT(yes)
  1154.     GNOME_LIBS="`$GNOME_CONFIG --libs-only-l gnome gnomeui`"
  1155.     GNOME_LIBDIR="`$GNOME_CONFIG --libs-only-L gnorba gnomeui`"
  1156.     GNOME_INCLUDEDIR="`$GNOME_CONFIG --cflags gnorba gnomeui`"
  1157.     $1
  1158.       else
  1159.     AC_MSG_RESULT(no)
  1160.     no_gnome_config="yes"
  1161.       fi
  1162.     fi
  1163.  
  1164.     if test x$exec_prefix = xNONE; then
  1165.       if test x$prefix = xNONE; then
  1166.     gnome_prefix=$ac_default_prefix/lib
  1167.       else
  1168.     gnome_prefix=$prefix/lib
  1169.       fi
  1170.     else
  1171.       gnome_prefix=`eval echo \`echo $libdir\``
  1172.     fi
  1173.  
  1174.     if test "$no_gnome_config" = "yes"; then
  1175.       AC_MSG_CHECKING(for gnomeConf.sh file in $gnome_prefix)
  1176.       if test -f $gnome_prefix/gnomeConf.sh; then
  1177.     AC_MSG_RESULT(found)
  1178.     echo "loading gnome configuration from" \
  1179.       "$gnome_prefix/gnomeConf.sh"
  1180.     . $gnome_prefix/gnomeConf.sh
  1181.     $1
  1182.       else
  1183.     AC_MSG_RESULT(not found)
  1184.     if test x$2 = xfail; then
  1185.       AC_MSG_ERROR(Could not find the gnomeConf.sh file that is generated by gnome-libs install)
  1186.     fi
  1187.       fi
  1188.     fi
  1189.   }
  1190.   fi
  1191. ])
  1192.  
  1193. AC_DEFUN([GNOME_INIT],[
  1194.     GNOME_INIT_HOOK([],fail)
  1195. ])
  1196.  
  1197.  
  1198. dnl ---------------------------------------------------------------------------
  1199. dnl Check for GTK.  First checks for gtk-config, cause it needs that to get the
  1200. dnl correct compiler flags.  Then checks for GTK 1.1.16.  If that fails, then
  1201. dnl it checks for 1.0.6.  If both fail, then continue on for Motif as before...
  1202. dnl ---------------------------------------------------------------------------
  1203. if test -z "$SKIP_GTK"; then
  1204.  
  1205.   AC_MSG_CHECKING(--with-gtk-prefix argument)
  1206.   AC_ARG_WITH(gtk-prefix,[  --with-gtk-prefix=PFX   Prefix where GTK is installed (optional)],
  1207.     gtk_config_prefix="$withval"; AC_MSG_RESULT($gtk_config_prefix),
  1208.     gtk_config_prefix=""; AC_MSG_RESULT(no))
  1209.  
  1210.   AC_MSG_CHECKING(--with-gtk-exec-prefix argument)
  1211.   AC_ARG_WITH(gtk-exec-prefix,[  --with-gtk-exec-prefix=PFX Exec prefix where GTK is installed (optional)],
  1212.     gtk_config_exec_prefix="$withval"; AC_MSG_RESULT($gtk_config_prefix),
  1213.     gtk_config_exec_prefix=""; AC_MSG_RESULT(no))
  1214.  
  1215.   AC_MSG_CHECKING(--disable-gtktest argument)
  1216.   AC_ARG_ENABLE(gtktest, [  --disable-gtktest       Do not try to compile and run a test GTK program],
  1217.     , enable_gtktest=yes)
  1218.   if test "x$enable_gtktest" = "xyes" ; then
  1219.     AC_MSG_RESULT(gtk test enabled)
  1220.   else
  1221.     AC_MSG_RESULT(gtk test disabled)
  1222.   fi
  1223.  
  1224.   if test "x$gtk_config_prefix" != "x" ; then
  1225.     gtk_config_args="$gtk_config_args --prefix=$gtk_config_prefix"
  1226.     GTK_CONFIG=$gtk_config_prefix/bin/gtk-config
  1227.   fi
  1228.   if test "x$gtk_config_exec_prefix" != "x" ; then
  1229.     gtk_config_args="$gtk_config_args --exec-prefix=$gtk_config_exec_prefix"
  1230.     GTK_CONFIG=$gtk_config_exec_prefix/bin/gtk-config
  1231.   fi
  1232.   if test "X$GTK_CONFIG" = "X"; then
  1233.     AC_PATH_PROG(GTK_CONFIG, gtk-config, no)
  1234.     if test "X$GTK_CONFIG" = "Xno"; then
  1235.       dnl Some distributions call it gtk12-config, annoying!
  1236.       AC_PATH_PROG(GTK12_CONFIG, gtk12-config, no)
  1237.       GTK_CONFIG="$GTK12_CONFIG"
  1238.     fi
  1239.   else
  1240.     AC_MSG_RESULT(Using GTK configuration program $GTK_CONFIG)
  1241.   fi
  1242.   if test "X$PKG_CONFIG" = "X"; then
  1243.     AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  1244.   fi
  1245.  
  1246.   if test "x$GTK_CONFIG:$PKG_CONFIG" != "xno:no"; then
  1247.     dnl First try finding version 2.2.0 or later.  The 2.0.x series has
  1248.     dnl problems (bold fonts, --remote doesn't work).
  1249.     if test "X$SKIP_GTK2" != "XYES"; then
  1250.       AM_PATH_GTK(2.2.0,
  1251.           [GTK_LIBNAME="$GTK_LIBS"
  1252.           GUI_INC_LOC="$GTK_CFLAGS"], )
  1253.       if test "x$GTK_CFLAGS" != "x"; then
  1254.     SKIP_ATHENA=YES
  1255.     SKIP_NEXTAW=YES
  1256.     SKIP_MOTIF=YES
  1257.     GUITYPE=GTK
  1258.     AC_SUBST(GTK_LIBNAME)
  1259.       fi
  1260.     fi
  1261.  
  1262.     dnl If there is no 2.2.0 or later try the 1.x.x series.  We require at
  1263.     dnl least GTK 1.1.16.  1.0.6 doesn't work.  1.1.1 to 1.1.15
  1264.     dnl were test versions.
  1265.     if test "x$GUITYPE" != "xGTK"; then
  1266.       SKIP_GTK2=YES
  1267.       AM_PATH_GTK(1.1.16,
  1268.           [GTK_LIBNAME="$GTK_LIBS"
  1269.           GUI_INC_LOC="$GTK_CFLAGS"], )
  1270.       if test "x$GTK_CFLAGS" != "x"; then
  1271.     SKIP_ATHENA=YES
  1272.     SKIP_NEXTAW=YES
  1273.     SKIP_MOTIF=YES
  1274.     GUITYPE=GTK
  1275.     AC_SUBST(GTK_LIBNAME)
  1276.       fi
  1277.     fi
  1278.   fi
  1279.   dnl Give a warning if GTK is older than 1.2.3
  1280.   if test "x$GUITYPE" = "xGTK"; then
  1281.     if test "$gtk_major_version" = 1 -a "0$gtk_minor_version" -lt 2 \
  1282.      -o "$gtk_major_version" = 1 -a "$gtk_minor_version" = 2 -a "0$gtk_micro_version" -lt 3; then
  1283.       AC_MSG_RESULT(this GTK version is old; version 1.2.3 or later is recommended)
  1284.     else
  1285.     {
  1286.       if test "0$gtk_major_version" -ge 2; then
  1287.     AC_DEFINE(HAVE_GTK2)
  1288.     if test "$gtk_minor_version" = 1 -a "0$gtk_micro_version" -ge 1 \
  1289.         || test "0$gtk_minor_version" -ge 2 \
  1290.         || test "0$gtk_major_version" -gt 2; then
  1291.       AC_DEFINE(HAVE_GTK_MULTIHEAD)
  1292.     fi
  1293.       fi
  1294.       dnl
  1295.       dnl if GTK exists, and it's not the 1.0.x series, then check for GNOME.
  1296.       dnl
  1297.       if test -z "$SKIP_GNOME"; then
  1298.       {
  1299.     GNOME_INIT_HOOK([have_gnome=yes])
  1300.     if test x$have_gnome = xyes ; then
  1301.       AC_DEFINE(FEAT_GUI_GNOME)
  1302.       GUI_INC_LOC="$GUI_INC_LOC $GNOME_INCLUDEDIR"
  1303.       GTK_LIBNAME="$GTK_LIBNAME $GNOME_LIBDIR $GNOME_LIBS"
  1304.     fi
  1305.       }
  1306.       fi
  1307.     }
  1308.     fi
  1309.   fi
  1310. fi
  1311.  
  1312. dnl Check for Motif include files location.
  1313. dnl The LAST one found is used, this makes the highest version to be used,
  1314. dnl e.g. when Motif1.2 and Motif2.0 are both present.
  1315.  
  1316. if test -z "$SKIP_MOTIF"; then
  1317.   gui_XXX="/usr/XXX/Motif* /usr/Motif*/XXX /usr/XXX /usr/shlib /usr/X11*/XXX /usr/XXX/X11* /usr/dt/XXX /local/Motif*/XXX /local/XXX/Motif* /usr/local/Motif*/XXX /usr/local/XXX/Motif* /usr/local/XXX /usr/local/X11*/XXX /usr/local/LessTif/Motif*/XXX $MOTIFHOME/XXX"
  1318.   dnl Remove "-I" from before $GUI_INC_LOC if it's there
  1319.   GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`"
  1320.  
  1321.   AC_MSG_CHECKING(for location of Motif GUI includes)
  1322.   gui_includes="`echo $x_includes|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC"
  1323.   GUI_INC_LOC=
  1324.   for try in $gui_includes; do
  1325.     if test -f "$try/Xm/Xm.h"; then
  1326.       GUI_INC_LOC=$try
  1327.     fi
  1328.   done
  1329.   if test -n "$GUI_INC_LOC"; then
  1330.     if test "$GUI_INC_LOC" = /usr/include; then
  1331.       GUI_INC_LOC=
  1332.       AC_MSG_RESULT(in default path)
  1333.     else
  1334.       AC_MSG_RESULT($GUI_INC_LOC)
  1335.     fi
  1336.   else
  1337.     AC_MSG_RESULT(<not found>)
  1338.     SKIP_MOTIF=YES
  1339.   fi
  1340. fi
  1341.  
  1342. dnl Check for Motif library files location.  In the same order as the include
  1343. dnl files, to avoid a mixup if several versions are present
  1344.  
  1345. if test -z "$SKIP_MOTIF"; then
  1346.   AC_MSG_CHECKING(--with-motif-lib argument)
  1347.   AC_ARG_WITH(motif-lib,
  1348.   [  --with-motif-lib=STRING   Library for Motif ],
  1349.   [ MOTIF_LIBNAME="${withval}" ] )
  1350.  
  1351.   if test -n "$MOTIF_LIBNAME"; then
  1352.     AC_MSG_RESULT($MOTIF_LIBNAME)
  1353.     GUI_LIB_LOC=
  1354.   else
  1355.     AC_MSG_RESULT(no)
  1356.  
  1357.     dnl Remove "-L" from before $GUI_LIB_LOC if it's there
  1358.     GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
  1359.  
  1360.     AC_MSG_CHECKING(for location of Motif GUI libs)
  1361.     gui_libs="`echo $x_libraries|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/lib/g` `echo "$GUI_INC_LOC" | sed s/include/lib/` $GUI_LIB_LOC"
  1362.     GUI_LIB_LOC=
  1363.     for try in $gui_libs; do
  1364.       for libtry in "$try"/libXm.a "$try"/libXm.so* "$try"/libXm.sl; do
  1365.     if test -f "$libtry"; then
  1366.       GUI_LIB_LOC=$try
  1367.     fi
  1368.       done
  1369.     done
  1370.     if test -n "$GUI_LIB_LOC"; then
  1371.       dnl Remove /usr/lib, it causes trouble on some systems
  1372.       if test "$GUI_LIB_LOC" = /usr/lib; then
  1373.     GUI_LIB_LOC=
  1374.     AC_MSG_RESULT(in default path)
  1375.       else
  1376.     if test -n "$GUI_LIB_LOC"; then
  1377.       AC_MSG_RESULT($GUI_LIB_LOC)
  1378.       if test "`(uname) 2>/dev/null`" = SunOS &&
  1379.                      uname -r | grep '^5' >/dev/null; then
  1380.         GUI_LIB_LOC="$GUI_LIB_LOC -R $GUI_LIB_LOC"
  1381.       fi
  1382.     fi
  1383.       fi
  1384.       MOTIF_LIBNAME=-lXm
  1385.     else
  1386.       AC_MSG_RESULT(<not found>)
  1387.       SKIP_MOTIF=YES
  1388.     fi
  1389.   fi
  1390. fi
  1391.  
  1392. if test -z "$SKIP_MOTIF"; then
  1393.   SKIP_ATHENA=YES
  1394.   SKIP_NEXTAW=YES
  1395.   GUITYPE=MOTIF
  1396.   AC_SUBST(MOTIF_LIBNAME)
  1397. fi
  1398.  
  1399. dnl Check if the Athena files can be found
  1400.  
  1401. GUI_X_LIBS=
  1402.  
  1403. if test -z "$SKIP_ATHENA"; then
  1404.   AC_MSG_CHECKING(if Athena header files can be found)
  1405.   cflags_save=$CFLAGS
  1406.   CFLAGS="$CFLAGS $X_CFLAGS"
  1407.   AC_TRY_COMPILE([
  1408. #include <X11/Intrinsic.h>
  1409. #include <X11/Xaw/Paned.h>], ,
  1410.     AC_MSG_RESULT(yes),
  1411.     AC_MSG_RESULT(no); SKIP_ATHENA=YES )
  1412.   CFLAGS=$cflags_save
  1413. fi
  1414.  
  1415. if test -z "$SKIP_ATHENA"; then
  1416.   GUITYPE=ATHENA
  1417. fi
  1418.  
  1419. if test -z "$SKIP_NEXTAW"; then
  1420.   AC_MSG_CHECKING(if neXtaw header files can be found)
  1421.   cflags_save=$CFLAGS
  1422.   CFLAGS="$CFLAGS $X_CFLAGS"
  1423.   AC_TRY_COMPILE([
  1424. #include <X11/Intrinsic.h>
  1425. #include <X11/neXtaw/Paned.h>], ,
  1426.     AC_MSG_RESULT(yes),
  1427.     AC_MSG_RESULT(no); SKIP_NEXTAW=YES )
  1428.   CFLAGS=$cflags_save
  1429. fi
  1430.  
  1431. if test -z "$SKIP_NEXTAW"; then
  1432.   GUITYPE=NEXTAW
  1433. fi
  1434.  
  1435. if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
  1436.   dnl Prepend -I and -L to $GUI_INC_LOC and $GUI_LIB_LOC if not empty
  1437.   dnl Avoid adding it when it twice
  1438.   if test -n "$GUI_INC_LOC"; then
  1439.     GUI_INC_LOC=-I"`echo $GUI_INC_LOC|sed 's%-I%%'`"
  1440.   fi
  1441.   if test -n "$GUI_LIB_LOC"; then
  1442.     GUI_LIB_LOC=-L"`echo $GUI_LIB_LOC|sed 's%-L%%'`"
  1443.   fi
  1444.  
  1445.   dnl Check for -lXext and then for -lXmu
  1446.   ldflags_save=$LDFLAGS
  1447.   LDFLAGS="$X_LIBS $LDFLAGS"
  1448.   AC_CHECK_LIB(Xext, XShapeQueryExtension, [GUI_X_LIBS="-lXext"],,
  1449.         [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
  1450.   AC_CHECK_LIB(Xmu, XmuCreateStippledPixmap, [GUI_X_LIBS="-lXmu $GUI_X_LIBS"],,
  1451.         [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
  1452.   if test -z "$SKIP_MOTIF"; then
  1453.     AC_CHECK_LIB(Xp, XpEndJob, [GUI_X_LIBS="-lXp $GUI_X_LIBS"],,
  1454.         [$GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
  1455.   fi
  1456.   LDFLAGS=$ldflags_save
  1457.  
  1458.   dnl Execute xmkmf to figure out if -DNARROWPROTO is needed.
  1459.   AC_MSG_CHECKING(for extra X11 defines)
  1460.   NARROW_PROTO=
  1461.   rm -fr conftestdir
  1462.   if mkdir conftestdir; then
  1463.     cd conftestdir
  1464.     cat > Imakefile <<'EOF'
  1465. acfindx:
  1466.     @echo 'NARROW_PROTO="${PROTO_DEFINES}"'
  1467. EOF
  1468.     if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
  1469.       eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
  1470.     fi
  1471.     cd ..
  1472.     rm -fr conftestdir
  1473.   fi
  1474.   if test -z "$NARROW_PROTO"; then
  1475.     AC_MSG_RESULT(no)
  1476.   else
  1477.     AC_MSG_RESULT($NARROW_PROTO)
  1478.   fi
  1479.   AC_SUBST(NARROW_PROTO)
  1480. fi
  1481.  
  1482. dnl Look for XSMP support - but don't necessarily restrict it to X11 GUIs
  1483. dnl use the X11 include path
  1484. if test "$enable_xsmp" = "yes"; then
  1485.   cppflags_save=$CPPFLAGS
  1486.   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
  1487.   AC_CHECK_HEADERS(X11/SM/SMlib.h)
  1488.   CPPFLAGS=$cppflags_save
  1489. fi
  1490.  
  1491.  
  1492. if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF" -o -z "$SKIP_GTK"; then
  1493.   dnl Check for X11/xpm.h and X11/Sunkeysym.h with the GUI include path
  1494.   cppflags_save=$CPPFLAGS
  1495.   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
  1496.   AC_CHECK_HEADERS(X11/xpm.h X11/Sunkeysym.h)
  1497.  
  1498.   dnl automatically disable XIM when XIMtext isn't in X11/Xlib.h
  1499.   if test ! "$enable_xim" = "no"; then
  1500.     AC_MSG_CHECKING(for XIMText in X11/Xlib.h)
  1501.     AC_EGREP_CPP(XIMText, [#include <X11/Xlib.h>],
  1502.           AC_MSG_RESULT(yes),
  1503.           AC_MSG_RESULT(no; xim has been disabled); enable_xim = "no")
  1504.   fi
  1505.   CPPFLAGS=$cppflags_save
  1506.  
  1507.   dnl automatically enable XIM when hangul input isn't enabled
  1508.   if test "$enable_xim" = "auto" -a "$enable_hangulinput" != "yes" \
  1509.         -a "x$GUITYPE" != "xNONE" ; then
  1510.     AC_MSG_RESULT(X GUI selected; xim has been enabled)
  1511.     enable_xim="yes"
  1512.   fi
  1513. fi
  1514.  
  1515. if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
  1516.   cppflags_save=$CPPFLAGS
  1517.   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
  1518.   AC_CHECK_HEADERS(X11/Xmu/Editres.h)
  1519.   CPPFLAGS=$cppflags_save
  1520. fi
  1521.  
  1522. dnl Only use the Xm directory when compiling Motif, don't use it for Athena
  1523. if test -z "$SKIP_MOTIF"; then
  1524.   cppflags_save=$CPPFLAGS
  1525.   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
  1526.   AC_CHECK_HEADERS(Xm/Xm.h Xm/XpmP.h)
  1527.   CPPFLAGS=$cppflags_save
  1528. fi
  1529.  
  1530. if test "x$GUITYPE" = "xNONE" -a "$enable_xim" = "yes"; then
  1531.   AC_MSG_RESULT(no GUI selected; xim has been disabled)
  1532.   enable_xim="no"
  1533. fi
  1534. if test "x$GUITYPE" = "xNONE" -a "$enable_fontset" = "yes"; then
  1535.   AC_MSG_RESULT(no GUI selected; fontset has been disabled)
  1536.   enable_fontset="no"
  1537. fi
  1538. if test "x$GUITYPE:$enable_fontset" = "xGTK:yes" -a "0$gtk_major_version" -ge 2; then
  1539.   AC_MSG_RESULT(GTK+ 2 GUI selected; fontset has been disabled)
  1540.   enable_fontset="no"
  1541. fi
  1542.  
  1543. dnl There is no test for the BeOS GUI, if it's selected it's used
  1544. if test -z "$SKIP_BEOS"; then
  1545.   GUITYPE=BEOSGUI
  1546. fi
  1547.  
  1548. if test -z "$SKIP_PHOTON"; then
  1549.   GUITYPE=PHOTONGUI
  1550. fi
  1551.  
  1552. AC_SUBST(GUI_INC_LOC)
  1553. AC_SUBST(GUI_LIB_LOC)
  1554. AC_SUBST(GUITYPE)
  1555. AC_SUBST(GUI_X_LIBS)
  1556.  
  1557. if test "$enable_workshop" = "yes" -a -n "$SKIP_MOTIF"; then
  1558.   AC_MSG_ERROR([cannot use workshop without Motif])
  1559. fi
  1560.  
  1561. dnl defining FEAT_XIM and FEAT_XFONTSET is delayed, so that they can be disabled
  1562. if test "$enable_xim" = "yes"; then
  1563.   AC_DEFINE(FEAT_XIM)
  1564. fi
  1565. if test "$enable_fontset" = "yes"; then
  1566.   AC_DEFINE(FEAT_XFONTSET)
  1567. fi
  1568.  
  1569. dnl Only really enable hangul input when GUI and XFONTSET are available
  1570. if test "$enable_hangulinput" = "yes"; then
  1571.   if test "x$GUITYPE" = "xNONE"; then
  1572.     AC_MSG_RESULT(no GUI selected; hangul input has been disabled)
  1573.     enable_hangulinput=no
  1574.   else
  1575.     AC_DEFINE(FEAT_HANGULIN)
  1576.     HANGULIN_SRC=hangulin.c
  1577.     AC_SUBST(HANGULIN_SRC)
  1578.     HANGULIN_OBJ=objects/hangulin.o
  1579.     AC_SUBST(HANGULIN_OBJ)
  1580.   fi
  1581. fi
  1582.  
  1583. dnl Checks for libraries and include files.
  1584.  
  1585. AC_MSG_CHECKING(quality of toupper)
  1586. AC_TRY_RUN([#include <ctype.h>
  1587. main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); }],
  1588.     AC_DEFINE(BROKEN_TOUPPER) AC_MSG_RESULT(bad),
  1589.     AC_MSG_RESULT(good), AC_MSG_ERROR(failed to compile test program))
  1590.  
  1591. AC_MSG_CHECKING(whether __DATE__ and __TIME__ work)
  1592. AC_TRY_COMPILE(, [printf("(" __DATE__ " " __TIME__ ")");],
  1593.     AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DATE_TIME),
  1594.     AC_MSG_RESULT(no))
  1595.  
  1596. dnl Checks for header files.
  1597. AC_CHECK_HEADER(elf.h, HAS_ELF=1)
  1598. dnl AC_CHECK_HEADER(dwarf.h, SVR4=1)
  1599. if test "$HAS_ELF" = 1; then
  1600.   AC_CHECK_LIB(elf, main)
  1601. fi
  1602.  
  1603. AC_HEADER_DIRENT
  1604.  
  1605. dnl check for standard headers, we don't use this in Vim but other stuff
  1606. dnl in autoconf needs it
  1607. AC_HEADER_STDC
  1608. AC_HEADER_SYS_WAIT
  1609.  
  1610. dnl If sys/wait.h is not found it might still exist but not be POSIX
  1611. dnl compliant. In that case we define HAVE_UNION_WAIT (for NeXT)
  1612. if test $ac_cv_header_sys_wait_h = no; then
  1613.   AC_MSG_CHECKING([for sys/wait.h that defines union wait])
  1614.   AC_TRY_COMPILE([#include <sys/wait.h>],
  1615.             [union wait xx, yy; xx = yy],
  1616.         AC_MSG_RESULT(yes)
  1617.             AC_DEFINE(HAVE_SYS_WAIT_H)
  1618.             AC_DEFINE(HAVE_UNION_WAIT),
  1619.         AC_MSG_RESULT(no))
  1620. fi
  1621.  
  1622. AC_CHECK_HEADERS(stdarg.h stdlib.h string.h sys/select.h sys/utsname.h \
  1623.     termcap.h fcntl.h sgtty.h sys/ioctl.h sys/time.h termio.h \
  1624.     iconv.h langinfo.h unistd.h stropts.h errno.h strings.h \
  1625.     sys/resource.h sys/systeminfo.h locale.h \
  1626.     sys/stream.h sys/ptem.h termios.h libc.h sys/statfs.h \
  1627.     poll.h sys/poll.h pwd.h utime.h sys/param.h libintl.h \
  1628.     libgen.h util/debug.h util/msg18n.h frame.h \
  1629.     sys/acl.h sys/access.h sys/sysctl.h sys/sysinfo.h)
  1630.  
  1631. dnl Check if strings.h and string.h can both be included when defined.
  1632. AC_MSG_CHECKING([if strings.h can be included after string.h])
  1633. cppflags_save=$CPPFLAGS
  1634. CPPFLAGS="$CPPFLAGS $X_CFLAGS"
  1635. AC_TRY_COMPILE([
  1636. #if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO)
  1637. # define _NO_PROTO    /* like in os_unix.h, causes conflict for AIX (Winn) */
  1638.             /* but don't do it on AIX 5.1 (Uribarri) */
  1639. #endif
  1640. #ifdef HAVE_XM_XM_H
  1641. # include <Xm/Xm.h>    /* This breaks it for HP-UX 11 (Squassabia) */
  1642. #endif
  1643. #ifdef HAVE_STRING_H
  1644. # include <string.h>
  1645. #endif
  1646. #if defined(HAVE_STRINGS_H)
  1647. # include <strings.h>
  1648. #endif
  1649.         ], [int i; i = 0;],
  1650.         AC_MSG_RESULT(yes),
  1651.         AC_DEFINE(NO_STRINGS_WITH_STRING_H)
  1652.         AC_MSG_RESULT(no))
  1653. CPPFLAGS=$cppflags_save
  1654.  
  1655. dnl Checks for typedefs, structures, and compiler characteristics.
  1656. AC_PROG_GCC_TRADITIONAL
  1657. AC_C_CONST
  1658. AC_TYPE_MODE_T
  1659. AC_TYPE_OFF_T
  1660. AC_TYPE_PID_T
  1661. AC_TYPE_SIZE_T
  1662. AC_TYPE_UID_T
  1663. AC_HEADER_TIME
  1664. AC_CHECK_TYPE(ino_t, long)
  1665. AC_CHECK_TYPE(dev_t, unsigned)
  1666.  
  1667. AC_MSG_CHECKING(for rlim_t)
  1668. if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
  1669.   AC_MSG_RESULT([(cached) $ac_cv_type_rlim_t])
  1670. else
  1671.   AC_EGREP_CPP(dnl
  1672. changequote(<<,>>)dnl
  1673. <<(^|[^a-zA-Z_0-9])rlim_t[^a-zA-Z_0-9]>>dnl
  1674. changequote([,]),
  1675.   [
  1676. #include <sys/types.h>
  1677. #if STDC_HEADERS
  1678. #include <stdlib.h>
  1679. #include <stddef.h>
  1680. #endif
  1681. #ifdef HAVE_SYS_RESOURCE_H
  1682. #include <sys/resource.h>
  1683. #endif
  1684.       ], ac_cv_type_rlim_t=yes, ac_cv_type_rlim_t=no)
  1685.       AC_MSG_RESULT($ac_cv_type_rlim_t)
  1686. fi
  1687. if test $ac_cv_type_rlim_t = no; then
  1688.   cat >> confdefs.h <<\EOF
  1689. #define rlim_t unsigned long
  1690. EOF
  1691. fi
  1692.  
  1693. AC_MSG_CHECKING(for stack_t)
  1694. if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then
  1695.   AC_MSG_RESULT([(cached) $ac_cv_type_stack_t])
  1696. else
  1697.   AC_EGREP_CPP(stack_t,
  1698.   [
  1699. #include <sys/types.h>
  1700. #if STDC_HEADERS
  1701. #include <stdlib.h>
  1702. #include <stddef.h>
  1703. #endif
  1704. #include <signal.h>
  1705.       ], ac_cv_type_stack_t=yes, ac_cv_type_stack_t=no)
  1706.       AC_MSG_RESULT($ac_cv_type_stack_t)
  1707. fi
  1708. if test $ac_cv_type_stack_t = no; then
  1709.   cat >> confdefs.h <<\EOF
  1710. #define stack_t struct sigaltstack
  1711. EOF
  1712. fi
  1713.  
  1714. dnl BSDI uses ss_base while others use ss_sp for the stack pointer.
  1715. AC_MSG_CHECKING(whether stack_t has an ss_base field)
  1716. AC_TRY_COMPILE([
  1717. #include <sys/types.h>
  1718. #if STDC_HEADERS
  1719. #include <stdlib.h>
  1720. #include <stddef.h>
  1721. #endif
  1722. #include <signal.h>
  1723. #include "confdefs.h"
  1724.             ], [stack_t sigstk; sigstk.ss_base = 0; ],
  1725.     AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SS_BASE),
  1726.     AC_MSG_RESULT(no))
  1727.  
  1728. olibs="$LIBS"
  1729. AC_MSG_CHECKING(--with-tlib argument)
  1730. AC_ARG_WITH(tlib, [  --with-tlib=library     terminal library to be used ],)
  1731. if test -n "$with_tlib"; then
  1732.   AC_MSG_RESULT($with_tlib)
  1733.   LIBS="$LIBS -l$with_tlib"
  1734. else
  1735.   AC_MSG_RESULT([automatic terminal library selection])
  1736.   dnl  On HP-UX 10.10 termcap or termlib should be used instead of
  1737.   dnl  curses, because curses is much slower.
  1738.   dnl  Newer versions of ncurses are preferred over anything.
  1739.   dnl  Older versions of ncurses have bugs, get a new one!
  1740.   dnl  Digital Unix (OSF1) should use curses (Ronald Schild).
  1741.   case "`uname -s 2>/dev/null`" in
  1742.     OSF1)    tlibs="ncurses curses termlib termcap";;
  1743.     *)    tlibs="ncurses termlib termcap curses";;
  1744.   esac
  1745.   for libname in $tlibs; do
  1746.     AC_CHECK_LIB(${libname}, tgetent,,)
  1747.     if test "x$olibs" != "x$LIBS"; then
  1748.       dnl It's possible that a library is found but it doesn't work
  1749.       dnl e.g., shared library that cannot be found
  1750.       dnl compile and run a test program to be sure
  1751.       AC_TRY_RUN([
  1752. #ifdef HAVE_TERMCAP_H
  1753. # include <termcap.h>
  1754. #endif
  1755. main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }],
  1756.               res="OK", res="FAIL", res="FAIL")
  1757.       if test "$res" = "OK"; then
  1758.     break
  1759.       fi
  1760.       AC_MSG_RESULT($libname library is not usable)
  1761.       LIBS="$olibs"
  1762.     fi
  1763.   done
  1764. fi
  1765. if test "x$olibs" != "x$LIBS"; then
  1766.   AC_MSG_CHECKING(whether we talk terminfo)
  1767.   AC_TRY_RUN([
  1768. #ifdef HAVE_TERMCAP_H
  1769. # include <termcap.h>
  1770. #endif
  1771. main()
  1772. {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }],
  1773.       AC_MSG_RESULT([no -- we are in termcap land]),
  1774.       AC_MSG_RESULT([yes -- terminfo spoken here]); AC_DEFINE(TERMINFO),
  1775.       AC_MSG_ERROR(failed to compile test program.))
  1776. else
  1777.   AC_MSG_RESULT(none found)
  1778. fi
  1779.  
  1780. if test "x$olibs" != "x$LIBS"; then
  1781.   AC_MSG_CHECKING(what tgetent() returns for an unknown terminal)
  1782.   AC_TRY_RUN([
  1783. #ifdef HAVE_TERMCAP_H
  1784. # include <termcap.h>
  1785. #endif
  1786. main()
  1787. {char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }],
  1788.       AC_MSG_RESULT(zero); AC_DEFINE(TGETENT_ZERO_ERR, 0),
  1789.       AC_MSG_RESULT(non-zero),
  1790.       AC_MSG_ERROR(failed to compile test program.))
  1791. fi
  1792.  
  1793. AC_MSG_CHECKING(whether termcap.h contains ospeed)
  1794. AC_TRY_LINK([
  1795. #ifdef HAVE_TERMCAP_H
  1796. # include <termcap.h>
  1797. #endif
  1798.             ], [ospeed = 20000],
  1799.     AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED),
  1800.     [AC_MSG_RESULT(no)
  1801.     AC_MSG_CHECKING(whether ospeed can be extern)
  1802.     AC_TRY_LINK([
  1803. #ifdef HAVE_TERMCAP_H
  1804. # include <termcap.h>
  1805. #endif
  1806. extern short ospeed;
  1807.             ], [ospeed = 20000],
  1808.         AC_MSG_RESULT(yes); AC_DEFINE(OSPEED_EXTERN),
  1809.         AC_MSG_RESULT(no))]
  1810.     )
  1811.  
  1812. AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC])
  1813. AC_TRY_LINK([
  1814. #ifdef HAVE_TERMCAP_H
  1815. # include <termcap.h>
  1816. #endif
  1817.             ], [if (UP == 0 && BC == 0) PC = 1],
  1818.     AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UP_BC_PC),
  1819.     [AC_MSG_RESULT(no)
  1820.     AC_MSG_CHECKING([whether UP, BC and PC can be extern])
  1821.     AC_TRY_LINK([
  1822. #ifdef HAVE_TERMCAP_H
  1823. # include <termcap.h>
  1824. #endif
  1825. extern char *UP, *BC, PC;
  1826.             ], [if (UP == 0 && BC == 0) PC = 1],
  1827.         AC_MSG_RESULT(yes); AC_DEFINE(UP_BC_PC_EXTERN),
  1828.         AC_MSG_RESULT(no))]
  1829.     )
  1830.  
  1831. AC_MSG_CHECKING(whether tputs() uses outfuntype)
  1832. AC_TRY_COMPILE([
  1833. #ifdef HAVE_TERMCAP_H
  1834. # include <termcap.h>
  1835. #endif
  1836.             ], [extern int xx(); tputs("test", 1, (outfuntype)xx)],
  1837.     AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OUTFUNTYPE),
  1838.     AC_MSG_RESULT(no))
  1839.  
  1840. dnl On some SCO machines sys/select redefines struct timeval
  1841. AC_MSG_CHECKING([whether sys/select.h and sys/time.h may both be included])
  1842. AC_TRY_COMPILE([
  1843. #include <sys/types.h>
  1844. #include <sys/time.h>
  1845. #include <sys/select.h>], ,
  1846.       AC_MSG_RESULT(yes)
  1847.             AC_DEFINE(SYS_SELECT_WITH_SYS_TIME),
  1848.       AC_MSG_RESULT(no))
  1849.  
  1850. dnl AC_DECL_SYS_SIGLIST
  1851.  
  1852. dnl Checks for pty.c (copied from screen) ==========================
  1853. AC_MSG_CHECKING(for /dev/ptc)
  1854. if test -r /dev/ptc; then
  1855.   AC_DEFINE(HAVE_DEV_PTC)
  1856.   AC_MSG_RESULT(yes)
  1857. else
  1858.   AC_MSG_RESULT(no)
  1859. fi
  1860.  
  1861. AC_MSG_CHECKING(for SVR4 ptys)
  1862. if test -c /dev/ptmx ; then
  1863.   AC_TRY_LINK([], [ptsname(0);grantpt(0);unlockpt(0);],
  1864.     AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SVR4_PTYS),
  1865.     AC_MSG_RESULT(no))
  1866. else
  1867.   AC_MSG_RESULT(no)
  1868. fi
  1869.  
  1870. AC_MSG_CHECKING(for ptyranges)
  1871. if test -d /dev/ptym ; then
  1872.   pdir='/dev/ptym'
  1873. else
  1874.   pdir='/dev'
  1875. fi
  1876. dnl SCO uses ptyp%d
  1877. AC_EGREP_CPP(yes,
  1878. [#ifdef M_UNIX
  1879.    yes;
  1880. #endif
  1881.     ], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
  1882. dnl if test -c /dev/ptyp19; then
  1883. dnl ptys=`echo /dev/ptyp??`
  1884. dnl else
  1885. dnl ptys=`echo $pdir/pty??`
  1886. dnl fi
  1887. if test "$ptys" != "$pdir/pty??" ; then
  1888.   p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
  1889.   p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g'  | sort -u | tr -d '\012'`
  1890.   AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
  1891.   AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
  1892.   AC_MSG_RESULT([$p0 / $p1])
  1893. else
  1894.   AC_MSG_RESULT([don't know])
  1895. fi
  1896.  
  1897. dnl    ****  pty mode/group handling ****
  1898. dnl
  1899. dnl support provided by Luke Mewburn <lm@rmit.edu.au>, 931222
  1900. AC_MSG_CHECKING(default tty permissions/group)
  1901. rm -f conftest_grp
  1902. AC_TRY_RUN([
  1903. #include <sys/types.h>
  1904. #include <sys/stat.h>
  1905. #include <stdio.h>
  1906. main()
  1907. {
  1908.   struct stat sb;
  1909.   char *x,*ttyname();
  1910.   int om, m;
  1911.   FILE *fp;
  1912.  
  1913.   if (!(x = ttyname(0))) exit(1);
  1914.   if (stat(x, &sb)) exit(1);
  1915.   om = sb.st_mode;
  1916.   if (om & 002) exit(0);
  1917.   m = system("mesg y");
  1918.   if (m == -1 || m == 127) exit(1);
  1919.   if (stat(x, &sb)) exit(1);
  1920.   m = sb.st_mode;
  1921.   if (chmod(x, om)) exit(1);
  1922.   if (m & 002) exit(0);
  1923.   if (sb.st_gid == getgid()) exit(1);
  1924.   if (!(fp=fopen("conftest_grp", "w")))
  1925.     exit(1);
  1926.   fprintf(fp, "%d\n", sb.st_gid);
  1927.   fclose(fp);
  1928.   exit(0);
  1929. }
  1930. ],[
  1931.     if test -f conftest_grp; then
  1932.     ptygrp=`cat conftest_grp`
  1933.     AC_MSG_RESULT([pty mode: 0620, group: $ptygrp])
  1934.     AC_DEFINE(PTYMODE, 0620)
  1935.     AC_DEFINE_UNQUOTED(PTYGROUP,$ptygrp)
  1936.     else
  1937.     AC_MSG_RESULT([ptys are world accessable])
  1938.     fi
  1939. ],
  1940.     AC_MSG_RESULT([can't determine - assume ptys are world accessable]),
  1941.     AC_MSG_ERROR(failed to compile test program))
  1942. rm -f conftest_grp
  1943.  
  1944. dnl Checks for library functions. ===================================
  1945.  
  1946. AC_TYPE_SIGNAL
  1947.  
  1948. dnl find out what to use at the end of a signal function
  1949. if test $ac_cv_type_signal = void; then
  1950.   AC_DEFINE(SIGRETURN, [return])
  1951. else
  1952.   AC_DEFINE(SIGRETURN, [return 0])
  1953. fi
  1954.  
  1955. dnl check if struct sigcontext is defined (used for SGI only)
  1956. AC_MSG_CHECKING(for struct sigcontext)
  1957. AC_TRY_COMPILE([
  1958. #include <signal.h>
  1959. test_sig()
  1960. {
  1961.     struct sigcontext *scont;
  1962.     scont = (struct sigcontext *)0;
  1963.     return 1;
  1964. } ], ,
  1965.       AC_MSG_RESULT(yes)
  1966.         AC_DEFINE(HAVE_SIGCONTEXT),
  1967.       AC_MSG_RESULT(no))
  1968.  
  1969. dnl tricky stuff: try to find out if getcwd() is implemented with
  1970. dnl system("sh -c pwd")
  1971. AC_MSG_CHECKING(getcwd implementation)
  1972. AC_TRY_RUN([
  1973. char *dagger[] = { "IFS=pwd", 0 };
  1974. main()
  1975. {
  1976.   char buffer[500];
  1977.   extern char **environ;
  1978.   environ = dagger;
  1979.   return getcwd(buffer, 500) ? 0 : 1;
  1980. }],
  1981.     AC_MSG_RESULT(it is usable),
  1982.     AC_MSG_RESULT(it stinks)
  1983.         AC_DEFINE(BAD_GETCWD),
  1984.     AC_MSG_ERROR(failed to compile test program))
  1985.  
  1986. dnl Check for functions in one big call, to reduce the size of configure
  1987. AC_CHECK_FUNCS(bcmp fchdir fchown fseeko fsync ftello getcwd getpseudotty \
  1988.     getpwnam getpwuid getrlimit gettimeofday getwd lstat memcmp \
  1989.     memset nanosleep opendir putenv qsort readlink select setenv \
  1990.     setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
  1991.     sigvec snprintf strcasecmp strerror strftime stricmp strncasecmp \
  1992.     strnicmp strpbrk strtol tgetent towlower towupper usleep utime utimes)
  1993.  
  1994. dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible
  1995. AC_MSG_CHECKING(for st_blksize)
  1996. AC_TRY_COMPILE(
  1997. [#include <sys/types.h>
  1998. #include <sys/stat.h>],
  1999. [    struct stat st;
  2000.     int n;
  2001.  
  2002.     stat("/", &st);
  2003.     n = (int)st.st_blksize;],
  2004.     AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ST_BLKSIZE),
  2005.     AC_MSG_RESULT(no))
  2006.  
  2007. AC_MSG_CHECKING(whether stat() ignores a trailing slash)
  2008. AC_TRY_RUN(
  2009. [#include <sys/types.h>
  2010. #include <sys/stat.h>
  2011. main() {struct stat st;  exit(stat("configure/", &st) != 0); }],
  2012.     AC_MSG_RESULT(yes); AC_DEFINE(STAT_IGNORES_SLASH),
  2013.     AC_MSG_RESULT(no), AC_MSG_ERROR(failed to compile test program))
  2014.  
  2015. dnl Link with iconv for charset translation, if not found without library.
  2016. dnl check for iconv() requires including iconv.h
  2017. dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
  2018. dnl has been installed.
  2019. AC_MSG_CHECKING(for iconv_open())
  2020. save_LIBS="$LIBS"
  2021. LIBS="$LIBS -liconv"
  2022. AC_TRY_LINK([
  2023. #ifdef HAVE_ICONV_H
  2024. # include <iconv.h>
  2025. #endif
  2026.     ], [iconv_open("fr", "to");],
  2027.     AC_MSG_RESULT(yes; with -liconv); AC_DEFINE(HAVE_ICONV),
  2028.     LIBS="$save_LIBS"
  2029.     AC_TRY_LINK([
  2030. #ifdef HAVE_ICONV_H
  2031. # include <iconv.h>
  2032. #endif
  2033.     ], [iconv_open("fr", "to");],
  2034.     AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ICONV),
  2035.     AC_MSG_RESULT(no)))
  2036.  
  2037.  
  2038. AC_MSG_CHECKING(for nl_langinfo(CODESET))
  2039. AC_TRY_LINK([
  2040. #ifdef HAVE_LANGINFO_H
  2041. # include <langinfo.h>
  2042. #endif
  2043. ], [char *cs = nl_langinfo(CODESET);],
  2044.     AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET),
  2045.     AC_MSG_RESULT(no))
  2046.  
  2047. dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI
  2048. dnl when -lacl works, also try to use -lattr (required for Debian).
  2049. AC_MSG_CHECKING(--disable-acl argument)
  2050. AC_ARG_ENABLE(acl,
  2051.     [  --disable-acl           Don't check for ACL support.],
  2052.     , [enable_acl="yes"])
  2053. if test "$enable_acl" = "yes"; then
  2054. AC_MSG_RESULT(no)
  2055. AC_CHECK_LIB(posix1e, acl_get_file, [LIBS="$LIBS -lposix1e"],
  2056.     AC_CHECK_LIB(acl, acl_get_file, [LIBS="$LIBS -lacl"
  2057.           AC_CHECK_LIB(attr, fgetxattr, LIBS="$LIBS -lattr",,)],,),)
  2058.  
  2059. AC_MSG_CHECKING(for POSIX ACL support)
  2060. AC_TRY_LINK([
  2061. #include <sys/types.h>
  2062. #ifdef HAVE_SYS_ACL_H
  2063. # include <sys/acl.h>
  2064. #endif
  2065. acl_t acl;], [acl = acl_get_file("foo", ACL_TYPE_ACCESS);
  2066.     acl_set_file("foo", ACL_TYPE_ACCESS, acl);
  2067.     acl_free(acl);],
  2068.     AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_ACL),
  2069.     AC_MSG_RESULT(no))
  2070.  
  2071. AC_MSG_CHECKING(for Solaris ACL support)
  2072. AC_TRY_LINK([
  2073. #ifdef HAVE_SYS_ACL_H
  2074. # include <sys/acl.h>
  2075. #endif], [acl("foo", GETACLCNT, 0, NULL);
  2076.     ],
  2077.     AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOLARIS_ACL),
  2078.     AC_MSG_RESULT(no))
  2079.  
  2080. AC_MSG_CHECKING(for AIX ACL support)
  2081. AC_TRY_LINK([
  2082. #ifdef HAVE_SYS_ACL_H
  2083. # include <sys/acl.h>
  2084. #endif
  2085. #ifdef HAVE_SYS_ACCESS_H
  2086. # include <sys/access.h>
  2087. #endif
  2088. #define _ALL_SOURCE
  2089.  
  2090. #include <sys/stat.h>
  2091.  
  2092. int aclsize;
  2093. struct acl *aclent;], [aclsize = sizeof(struct acl);
  2094.     aclent = (void *)malloc(aclsize);
  2095.     statacl("foo", STX_NORMAL, aclent, aclsize);
  2096.     ],
  2097.     AC_MSG_RESULT(yes); AC_DEFINE(HAVE_AIX_ACL),
  2098.     AC_MSG_RESULT(no))
  2099. else
  2100.   AC_MSG_RESULT(yes)
  2101. fi
  2102.  
  2103. AC_MSG_CHECKING(--disable-gpm argument)
  2104. AC_ARG_ENABLE(gpm,
  2105.     [  --disable-gpm           Don't use gpm (Linux mouse daemon).], ,
  2106.     [enable_gpm="yes"])
  2107.  
  2108. if test "$enable_gpm" = "yes"; then
  2109.   AC_MSG_RESULT(no)
  2110.   dnl Checking if gpm support can be compiled
  2111.   AC_CACHE_CHECK([for gpm], vi_cv_have_gpm,
  2112.     [olibs="$LIBS" ; LIBS="-lgpm"]
  2113.     AC_TRY_LINK(
  2114.         [#include <gpm.h>
  2115.         #include <linux/keyboard.h>],
  2116.         [Gpm_GetLibVersion(NULL);],
  2117.         dnl Configure defines HAVE_GPM, if it is defined feature.h defines
  2118.         dnl FEAT_MOUSE_GPM if mouse support is included
  2119.         [vi_cv_have_gpm=yes],
  2120.         [vi_cv_have_gpm=no])
  2121.     [LIBS="$olibs"]
  2122.     )
  2123.   if test $vi_cv_have_gpm = yes; then
  2124.     LIBS="$LIBS -lgpm"
  2125.     AC_DEFINE(HAVE_GPM)
  2126.   fi
  2127. else
  2128.   AC_MSG_RESULT(yes)
  2129. fi
  2130.  
  2131. AC_MSG_CHECKING(for vsnprintf())
  2132. AC_TRY_RUN([
  2133. #include <stdio.h>
  2134. #include <stdarg.h>
  2135.     /* Check use of vsnprintf() */
  2136.     void warn(char *fmt, ...);
  2137.     void warn(char *fmt, ...)
  2138.     {
  2139.       va_list ap; char buf[20];
  2140.       va_start(ap, fmt);
  2141.       vsnprintf(buf, 20, fmt, ap);
  2142.       va_end(ap);
  2143.     }
  2144.     main()
  2145.     {
  2146.     warn("testing %s\n", "a very long string that won't fit");
  2147.     exit(0);
  2148.     }
  2149.         ],
  2150.     AC_DEFINE(HAVE_VSNPRINTF) AC_MSG_RESULT(yes),
  2151.     AC_MSG_RESULT(no),
  2152.     AC_MSG_ERROR(failed to compile test program))
  2153.  
  2154.  
  2155. dnl rename needs to be checked separately to work on Nextstep with cc
  2156. AC_MSG_CHECKING(for rename)
  2157. AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
  2158.     AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
  2159.     AC_MSG_RESULT(no))
  2160.  
  2161. dnl sysctl() may exist but not the arguments we use
  2162. AC_MSG_CHECKING(for sysctl)
  2163. AC_TRY_COMPILE(
  2164. [#include <sys/types.h>
  2165. #include <sys/sysctl.h>],
  2166. [    int mib[2], r;
  2167.     size_t len;
  2168.  
  2169.     mib[0] = CTL_HW;
  2170.     mib[1] = HW_USERMEM;
  2171.     len = sizeof(r);
  2172.     (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
  2173.     ],
  2174.     AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL),
  2175.     AC_MSG_RESULT(not usable))
  2176.  
  2177. dnl sysinfo() may exist but not be Linux compatible
  2178. AC_MSG_CHECKING(for sysinfo)
  2179. AC_TRY_COMPILE(
  2180. [#include <sys/types.h>
  2181. #include <sys/sysinfo.h>],
  2182. [    struct sysinfo sinfo;
  2183.     int t;
  2184.  
  2185.     (void)sysinfo(&sinfo);
  2186.     t = sinfo.totalram;
  2187.     ],
  2188.     AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
  2189.     AC_MSG_RESULT(not usable))
  2190.  
  2191. dnl sysconf() may exist but not support what we want to use
  2192. AC_MSG_CHECKING(for sysconf)
  2193. AC_TRY_COMPILE(
  2194. [#include <unistd.h>],
  2195. [    (void)sysconf(_SC_PAGESIZE);
  2196.     (void)sysconf(_SC_PHYS_PAGES);
  2197.     ],
  2198.     AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
  2199.     AC_MSG_RESULT(not usable))
  2200.  
  2201. dnl Our own version of AC_CHECK_SIZEOF(int); fixes a bug when sizeof() can't
  2202. dnl be printed with "%d", and avoids a warning for cross-compiling.
  2203.  
  2204. AC_MSG_CHECKING(size of int)
  2205. AC_CACHE_VAL(ac_cv_sizeof_int,
  2206.     [AC_TRY_RUN([#include <stdio.h>
  2207.         main()
  2208.         {
  2209.           FILE *f=fopen("conftestval", "w");
  2210.           if (!f) exit(1);
  2211.           fprintf(f, "%d\n", (int)sizeof(int));
  2212.           exit(0);
  2213.         }],
  2214.         ac_cv_sizeof_int=`cat conftestval`,
  2215.         ac_cv_sizeof_int=0,
  2216.         AC_MSG_ERROR(failed to compile test program))])
  2217. AC_MSG_RESULT($ac_cv_sizeof_int)
  2218. AC_DEFINE_UNQUOTED(SIZEOF_INT, $ac_cv_sizeof_int)
  2219.  
  2220. AC_MSG_CHECKING(whether memmove/bcopy/memcpy handle overlaps)
  2221. [bcopy_test_prog='
  2222. main() {
  2223.   char buf[10];
  2224.   strcpy(buf, "abcdefghi");
  2225.   mch_memmove(buf, buf + 2, 3);
  2226.   if (strncmp(buf, "ababcf", 6))
  2227.     exit(1);
  2228.   strcpy(buf, "abcdefghi");
  2229.   mch_memmove(buf + 2, buf, 3);
  2230.   if (strncmp(buf, "cdedef", 6))
  2231.     exit(1);
  2232.   exit(0); /* libc version works properly.  */
  2233. }']
  2234.  
  2235. dnl Check for memmove() before bcopy(), makes memmove() be used when both are
  2236. dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
  2237.  
  2238. AC_TRY_RUN([#define mch_memmove(s,d,l) memmove(d,s,l) $bcopy_test_prog],
  2239.     AC_DEFINE(USEMEMMOVE) AC_MSG_RESULT(memmove does),
  2240.     AC_TRY_RUN([#define mch_memmove(s,d,l) bcopy(d,s,l) $bcopy_test_prog],
  2241.     AC_DEFINE(USEBCOPY) AC_MSG_RESULT(bcopy does),
  2242.     AC_TRY_RUN([#define mch_memmove(s,d,l) memcpy(d,s,l) $bcopy_test_prog],
  2243.         AC_DEFINE(USEMEMCPY) AC_MSG_RESULT(memcpy does), AC_MSG_RESULT(no),
  2244.         AC_MSG_ERROR(failed to compile test program)),
  2245.     AC_MSG_ERROR(failed to compile test program)),
  2246.     AC_MSG_ERROR(failed to compile test program))
  2247.  
  2248. dnl Check for multibyte locale functions
  2249. dnl Find out if _Xsetlocale() is supported by libX11.
  2250. dnl Check if X_LOCALE should be defined.
  2251.  
  2252. if test "$enable_multibyte" = "yes"; then
  2253.   cflags_save=$CFLAGS
  2254.   ldflags_save=$LDFLAGS
  2255.   if test -n "$x_includes" ; then
  2256.     CFLAGS="$CFLAGS -I$x_includes"
  2257.     LDFLAGS="$X_LIBS $LDFLAGS -lX11"
  2258.     AC_MSG_CHECKING(whether X_LOCALE needed)
  2259.     AC_TRY_COMPILE([#include <X11/Xlocale.h>],,
  2260.     AC_TRY_LINK_FUNC([_Xsetlocale], [AC_MSG_RESULT(yes)
  2261.         AC_DEFINE(X_LOCALE)], AC_MSG_RESULT(no)),
  2262.     AC_MSG_RESULT(no))
  2263.   fi
  2264.   CFLAGS=$cflags_save
  2265.   LDFLAGS=$ldflags_save
  2266. fi
  2267.  
  2268. dnl Link with xpg4, it is said to make Korean locale working
  2269. AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,)
  2270.  
  2271. dnl Check how we can run ctags
  2272. dnl --version for Exuberant ctags (preferred)
  2273. dnl -t for typedefs (many ctags have this)
  2274. dnl -s for static functions (Elvis ctags only?)
  2275. dnl -v for variables. Dangerous, most ctags take this for 'vgrind style'.
  2276. dnl -i+m to test for older Exuberant ctags
  2277. AC_MSG_CHECKING(how to create tags)
  2278. test -f tags && mv tags tags.save
  2279. if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
  2280.   TAGPRG="ctags"
  2281. else
  2282.   (eval etags       /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags"
  2283.   (eval etags -c   /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags -c"
  2284.   (eval ctags       /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags"
  2285.   (eval ctags -t   /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -t"
  2286.   (eval ctags -ts  /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -ts"
  2287.   (eval ctags -tvs /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -tvs"
  2288.   (eval ctags -i+m /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -i+m"
  2289. fi
  2290. test -f tags.save && mv tags.save tags
  2291. AC_MSG_RESULT($TAGPRG) AC_SUBST(TAGPRG)
  2292.  
  2293. dnl Check how we can run man with a section number
  2294. AC_MSG_CHECKING(how to run man with a section nr)
  2295. MANDEF="man"
  2296. (eval man -s 2 read) < /dev/null > /dev/null 2>&AC_FD_CC && MANDEF="man -s"
  2297. AC_MSG_RESULT($MANDEF)
  2298. if test "$MANDEF" = "man -s"; then
  2299.   AC_DEFINE(USEMAN_S)
  2300. fi
  2301.  
  2302. dnl Check if gettext() is working and if it needs -lintl
  2303. AC_MSG_CHECKING(--disable-nls argument)
  2304. AC_ARG_ENABLE(nls,
  2305.     [  --disable-nls           Don't support NLS (gettext()).], ,
  2306.     [enable_nls="yes"])
  2307.  
  2308. if test "$enable_nls" = "yes"; then
  2309.   AC_MSG_RESULT(no)
  2310.   AC_CHECK_PROG(MSGFMT, msgfmt, msgfmt, )
  2311.   AC_MSG_CHECKING([for NLS])
  2312.   if test -d po; then
  2313.     have_gettext="no"
  2314.     if test -n "$MSGFMT"; then
  2315.       AC_TRY_LINK(
  2316.     [#include <libintl.h>],
  2317.     [gettext("Test");],
  2318.     AC_MSG_RESULT([gettext() works]); have_gettext="yes",
  2319.       olibs=$LIBS
  2320.       LIBS="$LIBS -lintl"
  2321.       AC_TRY_LINK(
  2322.           [#include <libintl.h>],
  2323.           [gettext("Test");],
  2324.           AC_MSG_RESULT([gettext() works with -lintl]); have_gettext="yes",
  2325.           AC_MSG_RESULT([gettext() doesn't work]);
  2326.           LIBS=$olibs))
  2327.     else
  2328.       AC_MSG_RESULT([msgfmt not found - disabled]);
  2329.     fi
  2330.     if test $have_gettext = "yes"; then
  2331.       AC_DEFINE(HAVE_GETTEXT)
  2332.       MAKEMO=yes
  2333.       AC_SUBST(MAKEMO)
  2334.       dnl this was added in GNU gettext 0.10.36
  2335.       AC_CHECK_FUNCS(bind_textdomain_codeset)
  2336.       dnl _nl_msg_cat_cntr is required for GNU gettext
  2337.       AC_MSG_CHECKING([for _nl_msg_cat_cntr])
  2338.       AC_TRY_LINK(
  2339.         [#include <libintl.h>
  2340.         extern int _nl_msg_cat_cntr;],
  2341.         [++_nl_msg_cat_cntr;],
  2342.         AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_NL_MSG_CAT_CNTR),
  2343.         AC_MSG_RESULT([no]))
  2344.     fi
  2345.   else
  2346.     AC_MSG_RESULT([no "po" directory - disabled]);
  2347.   fi
  2348. else
  2349.   AC_MSG_RESULT(yes)
  2350. fi
  2351.  
  2352. dnl Check for dynamic linking loader
  2353. AC_CHECK_HEADER(dlfcn.h, DLL=dlfcn.h, [AC_CHECK_HEADER(dl.h, DLL=dl.h)])
  2354. if test x${DLL} = xdlfcn.h; then
  2355.   AC_DEFINE(HAVE_DLFCN_H, 1, [ Define if we have dlfcn.h. ])
  2356.   AC_MSG_CHECKING([for dlopen()])
  2357.   AC_TRY_LINK(,[
  2358.         extern void* dlopen();
  2359.         dlopen();
  2360.       ],
  2361.       AC_MSG_RESULT(yes);
  2362.           AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
  2363.       AC_MSG_RESULT(no);
  2364.           AC_MSG_CHECKING([for dlopen() in -ldl])
  2365.           olibs=$LIBS
  2366.           LIBS="$LIBS -ldl"
  2367.           AC_TRY_LINK(,[
  2368.                 extern void* dlopen();
  2369.                 dlopen();
  2370.          ],
  2371.          AC_MSG_RESULT(yes);
  2372.               AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
  2373.          AC_MSG_RESULT(no);
  2374.               LIBS=$olibs))
  2375.   dnl ReliantUNIX has dlopen() in libc but everything else in libdl
  2376.   dnl ick :-)
  2377.   AC_MSG_CHECKING([for dlsym()])
  2378.   AC_TRY_LINK(,[
  2379.         extern void* dlsym();
  2380.         dlsym();
  2381.       ],
  2382.       AC_MSG_RESULT(yes);
  2383.           AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
  2384.       AC_MSG_RESULT(no);
  2385.           AC_MSG_CHECKING([for dlsym() in -ldl])
  2386.           olibs=$LIBS
  2387.           LIBS="$LIBS -ldl"
  2388.           AC_TRY_LINK(,[
  2389.                 extern void* dlsym();
  2390.                 dlsym();
  2391.          ],
  2392.          AC_MSG_RESULT(yes);
  2393.               AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
  2394.          AC_MSG_RESULT(no);
  2395.               LIBS=$olibs))
  2396. elif test x${DLL} = xdl.h; then
  2397.   AC_DEFINE(HAVE_DL_H, 1, [ Define if we have dl.h. ])
  2398.   AC_MSG_CHECKING([for shl_load()])
  2399.   AC_TRY_LINK(,[
  2400.         extern void* shl_load();
  2401.         shl_load();
  2402.      ],
  2403.      AC_MSG_RESULT(yes);
  2404.       AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
  2405.      AC_MSG_RESULT(no);
  2406.       AC_MSG_CHECKING([for shl_load() in -ldld])
  2407.       olibs=$LIBS
  2408.       LIBS="$LIBS -ldld"
  2409.       AC_TRY_LINK(,[
  2410.             extern void* shl_load();
  2411.             shl_load();
  2412.          ],
  2413.          AC_MSG_RESULT(yes);
  2414.           AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
  2415.          AC_MSG_RESULT(no);
  2416.           LIBS=$olibs))
  2417. fi
  2418. AC_CHECK_HEADERS(setjmp.h)
  2419.  
  2420. dnl write output files
  2421. AC_OUTPUT(auto/config.mk:config.mk.in)
  2422.  
  2423. dnl vim: set sw=2 tw=78 fo+=l:
  2424.