Tizen 2.0 Release
[external/vim.git] / src / configure.in
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_PROGRAM_EGREP dnl required by AC_EGREP_CPP
17 AC_ISC_POSIX    dnl required by AC_C_CROSS
18 AC_PROG_AWK     dnl required for "make html" in ../doc
19
20 dnl Don't strip if we don't have it
21 AC_CHECK_PROG(STRIP, strip, strip, :)
22
23 dnl Check for extension of executables
24 AC_EXEEXT
25
26 dnl Check for standard headers.  We don't use this in Vim but other stuff
27 dnl in autoconf needs it, where it uses STDC_HEADERS.
28 AC_HEADER_STDC
29 AC_HEADER_SYS_WAIT
30
31 dnl Check for the flag that fails if stuff are missing.
32
33 AC_MSG_CHECKING(--enable-fail-if-missing argument)
34 AC_ARG_ENABLE(fail_if_missing,
35         [  --enable-fail-if-missing    Fail if dependencies on additional features
36      specified on the command line are missing.], 
37         [fail_if_missing="yes"],
38         [fail_if_missing="no"])
39 AC_MSG_RESULT($fail_if_missing)
40
41 dnl Set default value for CFLAGS if none is defined or it's empty
42 if test -z "$CFLAGS"; then
43   CFLAGS="-O"
44   test "$GCC" = yes && CFLAGS="-O2 -fno-strength-reduce -Wall"
45 fi
46 if test "$GCC" = yes; then
47   dnl method that should work for nearly all versions
48   gccversion=`"$CC" -dumpversion`
49   if test "x$gccversion" = "x"; then
50     dnl old method; fall-back for when -dumpversion doesn't work
51     gccversion=`"$CC" --version | sed -e '2,$d' -e 's/darwin.//' -e 's/^[[^0-9]]*\([[0-9]]\.[[0-9.]]*\).*$/\1/g'`
52   fi
53   dnl version 4.0.1 was reported to cause trouble on Macintosh by Marcin Dalecki
54   if test "$gccversion" = "3.0.1" -o "$gccversion" = "3.0.2" -o "$gccversion" = "4.0.1"; then
55     echo 'GCC [[34]].0.[[12]] has a bug in the optimizer, disabling "-O#"'
56     CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-O/'`
57   else
58     if test "$gccversion" = "3.1" -o "$gccversion" = "3.2" -o "$gccversion" = "3.2.1" && `echo "$CFLAGS" | grep -v fno-strength-reduce >/dev/null`; then
59       echo 'GCC 3.1 and 3.2 have a bug in the optimizer, adding "-fno-strength-reduce"'
60       CFLAGS="$CFLAGS -fno-strength-reduce"
61     fi
62   fi
63 fi
64
65 dnl If configure thinks we are cross compiling, there might be something
66 dnl wrong with the CC or CFLAGS settings, give a useful warning message
67 if test "$cross_compiling" = yes; then
68   AC_MSG_RESULT([cannot compile a simple program; if not cross compiling check CC and CFLAGS])
69 fi
70
71 dnl gcc-cpp has the wonderful -MM option to produce nicer dependencies.
72 dnl But gcc 3.1 changed the meaning!  See near the end.
73 test "$GCC" = yes && CPP_MM=M; AC_SUBST(CPP_MM)
74
75 if test -f ./toolcheck; then
76   AC_CHECKING(for buggy tools)
77   sh ./toolcheck 1>&AC_FD_MSG
78 fi
79
80 OS_EXTRA_SRC=""; OS_EXTRA_OBJ=""
81
82 dnl Check for BeOS, which needs an extra source file
83 AC_MSG_CHECKING(for BeOS)
84 case `uname` in
85     BeOS)       OS_EXTRA_SRC=os_beos.c; OS_EXTRA_OBJ=objects/os_beos.o
86                 BEOS=yes; AC_MSG_RESULT(yes);;
87     *)          BEOS=no; AC_MSG_RESULT(no);;
88 esac
89
90 dnl If QNX is found, assume we don't want to use Xphoton
91 dnl unless it was specifically asked for (--with-x)
92 AC_MSG_CHECKING(for QNX)
93 case `uname` in
94     QNX)        OS_EXTRA_SRC=os_qnx.c; OS_EXTRA_OBJ=objects/os_qnx.o
95                 test -z "$with_x" && with_x=no
96                 QNX=yes; AC_MSG_RESULT(yes);;
97     *)          QNX=no; AC_MSG_RESULT(no);;
98 esac
99
100 dnl Check for Darwin and MacOS X
101 dnl We do a check for MacOS X in the very beginning because there
102 dnl are a lot of other things we need to change besides GUI stuff
103 AC_MSG_CHECKING([for Darwin (Mac OS X)])
104 if test "`(uname) 2>/dev/null`" = Darwin; then
105   AC_MSG_RESULT(yes)
106
107   AC_MSG_CHECKING(--disable-darwin argument)
108   AC_ARG_ENABLE(darwin,
109           [  --disable-darwin        Disable Darwin (Mac OS X) support.],
110           , [enable_darwin="yes"])
111   if test "$enable_darwin" = "yes"; then
112     AC_MSG_RESULT(no)
113     AC_MSG_CHECKING(if Darwin files are there)
114     if test -f os_macosx.m; then
115       AC_MSG_RESULT(yes)
116     else
117       AC_MSG_RESULT([no, Darwin support disabled])
118       enable_darwin=no
119     fi
120   else
121     AC_MSG_RESULT([yes, Darwin support excluded])
122   fi
123
124   AC_MSG_CHECKING(--with-mac-arch argument)
125   AC_ARG_WITH(mac-arch, [  --with-mac-arch=ARCH    current, intel, ppc or both],
126         MACARCH="$withval"; AC_MSG_RESULT($MACARCH),
127         MACARCH="current"; AC_MSG_RESULT(defaulting to $MACARCH))
128
129   AC_MSG_CHECKING(--with-developer-dir argument)
130   AC_ARG_WITH(developer-dir, [  --with-developer-dir=PATH    use PATH as location for Xcode developer tools],
131         DEVELOPER_DIR="$withval"; AC_MSG_RESULT($DEVELOPER_DIR),
132         DEVELOPER_DIR=""; AC_MSG_RESULT(not present))
133   
134   if test "x$DEVELOPER_DIR" = "x"; then
135     AC_PATH_PROG(XCODE_SELECT, xcode-select)
136     if test "x$XCODE_SELECT" != "x"; then
137       AC_MSG_CHECKING(for developer dir using xcode-select)
138       DEVELOPER_DIR=`$XCODE_SELECT -print-path`
139       AC_MSG_RESULT([$DEVELOPER_DIR])
140     else
141       DEVELOPER_DIR=/Developer
142     fi
143   fi
144
145   if test "x$MACARCH" = "xboth"; then
146     AC_MSG_CHECKING(for 10.4 universal SDK)
147     dnl There is a terrible inconsistency (but we appear to get away with it):
148     dnl $CFLAGS uses the 10.4u SDK library for the headers, while $CPPFLAGS
149     dnl doesn't, because "gcc -E" doesn't grok it.  That means the configure
150     dnl tests using the preprocessor are actually done with the wrong header
151     dnl files. $LDFLAGS is set at the end, because configure uses it together
152     dnl with $CFLAGS and we can only have one -sysroot argument.
153     save_cppflags="$CPPFLAGS"
154     save_cflags="$CFLAGS"
155     save_ldflags="$LDFLAGS"
156     CFLAGS="$CFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
157     AC_TRY_LINK([ ], [ ],
158         AC_MSG_RESULT(found, will make universal binary),
159
160         AC_MSG_RESULT(not found)
161         CFLAGS="$save_cflags"
162         AC_MSG_CHECKING(if Intel architecture is supported)
163         CPPFLAGS="$CPPFLAGS -arch i386"
164         LDFLAGS="$save_ldflags -arch i386"
165         AC_TRY_LINK([ ], [ ],
166             AC_MSG_RESULT(yes); MACARCH="intel",
167             AC_MSG_RESULT(no, using PowerPC)
168                 MACARCH="ppc"
169                 CPPFLAGS="$save_cppflags -arch ppc"
170                 LDFLAGS="$save_ldflags -arch ppc"))
171   elif test "x$MACARCH" = "xintel"; then
172     CPPFLAGS="$CPPFLAGS -arch intel"
173     LDFLAGS="$LDFLAGS -arch intel"
174   elif test "x$MACARCH" = "xppc"; then
175     CPPFLAGS="$CPPFLAGS -arch ppc"
176     LDFLAGS="$LDFLAGS -arch ppc"
177   fi
178
179   if test "$enable_darwin" = "yes"; then
180     MACOSX=yes
181     OS_EXTRA_SRC="os_macosx.m os_mac_conv.c";
182     OS_EXTRA_OBJ="objects/os_macosx.o objects/os_mac_conv.o"
183     dnl TODO: use -arch i386 on Intel machines
184     CPPFLAGS="$CPPFLAGS -DMACOS_X_UNIX -no-cpp-precomp"
185
186     dnl If Carbon is found, assume we don't want X11
187     dnl unless it was specifically asked for (--with-x)
188     dnl or Motif, Athena or GTK GUI is used.
189     AC_CHECK_HEADER(Carbon/Carbon.h, CARBON=yes)
190     if test "x$CARBON" = "xyes"; then
191       if test -z "$with_x" -a "X$enable_gui" != Xmotif -a "X$enable_gui" != Xathena -a "X$enable_gui" != Xgtk2; then
192         with_x=no
193       fi
194     fi
195   fi
196
197   dnl Avoid a bug with -O2 with gcc 4.0.1.  Symptom: malloc() reports double
198   dnl free.  This happens in expand_filename(), because the optimizer swaps
199   dnl two blocks of code, both using "repl", that can't be swapped.
200   if test "$MACARCH" = "intel" -o "$MACARCH" = "both"; then
201     CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-Oz/'`
202   fi
203
204 else
205   AC_MSG_RESULT(no)
206 fi
207
208 AC_SUBST(OS_EXTRA_SRC)
209 AC_SUBST(OS_EXTRA_OBJ)
210
211 dnl Add /usr/local/lib to $LDFLAGS and /usr/local/include to CFLAGS.
212 dnl Only when the directory exists and it wasn't there yet.
213 dnl For gcc don't do this when it is already in the default search path.
214 dnl Skip all of this when cross-compiling.
215 if test "$cross_compiling" = no; then
216   AC_MSG_CHECKING(--with-local-dir argument)
217   have_local_include=''
218   have_local_lib=''
219   AC_ARG_WITH([local-dir], [  --with-local-dir=PATH   search PATH instead of /usr/local for local libraries.
220   --without-local-dir     do not search /usr/local for local libraries.], [
221     local_dir="$withval"
222     case "$withval" in
223     */*) ;;
224     no)
225       # avoid adding local dir to LDFLAGS and CPPFLAGS
226       have_local_include=yes
227       have_local_lib=yes
228       ;;
229     *) AC_MSG_ERROR(must pass path argument to --with-local-dir) ;;
230     esac
231         AC_MSG_RESULT($local_dir)
232   ], [
233     local_dir=/usr/local
234     AC_MSG_RESULT(Defaulting to $local_dir)
235   ])
236   if test "$GCC" = yes -a "$local_dir" != no; then
237     echo 'void f(){}' > conftest.c
238     dnl -no-cpp-precomp is needed for OS X 10.2 (Ben Fowler)
239     have_local_include=`${CC-cc} -no-cpp-precomp -c -v conftest.c 2>&1 | grep "${local_dir}/include"`
240     have_local_lib=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/lib"`
241     rm -f conftest.c conftest.o
242   fi
243   if test -z "$have_local_lib" -a -d "${local_dir}/lib"; then
244     tt=`echo "$LDFLAGS" | sed -e "s+-L${local_dir}/lib ++g" -e "s+-L${local_dir}/lib$++g"`
245     if test "$tt" = "$LDFLAGS"; then
246       LDFLAGS="$LDFLAGS -L${local_dir}/lib"
247     fi
248   fi
249   if test -z "$have_local_include" -a -d "${local_dir}/include"; then
250     tt=`echo "$CPPFLAGS" | sed -e "s+-I${local_dir}/include ++g" -e "s+-I${local_dir}/include$++g"`
251     if test "$tt" = "$CPPFLAGS"; then
252       CPPFLAGS="$CPPFLAGS -I${local_dir}/include"
253     fi
254   fi
255 fi
256
257 AC_MSG_CHECKING(--with-vim-name argument)
258 AC_ARG_WITH(vim-name, [  --with-vim-name=NAME    what to call the Vim executable],
259         VIMNAME="$withval"; AC_MSG_RESULT($VIMNAME),
260         VIMNAME="vim"; AC_MSG_RESULT(Defaulting to $VIMNAME))
261 AC_SUBST(VIMNAME)
262 AC_MSG_CHECKING(--with-ex-name argument)
263 AC_ARG_WITH(ex-name, [  --with-ex-name=NAME     what to call the Ex executable],
264         EXNAME="$withval"; AC_MSG_RESULT($EXNAME),
265         EXNAME="ex"; AC_MSG_RESULT(Defaulting to ex))
266 AC_SUBST(EXNAME)
267 AC_MSG_CHECKING(--with-view-name argument)
268 AC_ARG_WITH(view-name, [  --with-view-name=NAME   what to call the View executable],
269         VIEWNAME="$withval"; AC_MSG_RESULT($VIEWNAME),
270         VIEWNAME="view"; AC_MSG_RESULT(Defaulting to view))
271 AC_SUBST(VIEWNAME)
272
273 AC_MSG_CHECKING(--with-global-runtime argument)
274 AC_ARG_WITH(global-runtime, [  --with-global-runtime=DIR    global runtime directory in 'runtimepath'],
275         AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL, "$withval"),
276         AC_MSG_RESULT(no))
277
278 AC_MSG_CHECKING(--with-modified-by argument)
279 AC_ARG_WITH(modified-by, [  --with-modified-by=NAME       name of who modified a release version],
280         AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(MODIFIED_BY, "$withval"),
281         AC_MSG_RESULT(no))
282
283 dnl Check for EBCDIC stolen from the LYNX port to z/OS Unix
284 AC_MSG_CHECKING(if character set is EBCDIC)
285 AC_TRY_COMPILE([ ],
286 [ /* TryCompile function for CharSet.
287    Treat any failure as ASCII for compatibility with existing art.
288    Use compile-time rather than run-time tests for cross-compiler
289    tolerance.  */
290 #if '0'!=240
291 make an error "Character set is not EBCDIC"
292 #endif ],
293 [ # TryCompile action if true
294 cf_cv_ebcdic=yes ],
295 [ # TryCompile action if false
296 cf_cv_ebcdic=no])
297 # end of TryCompile ])
298 # end of CacheVal CvEbcdic
299 AC_MSG_RESULT($cf_cv_ebcdic)
300 case "$cf_cv_ebcdic" in  #(vi
301     yes)        AC_DEFINE(EBCDIC)
302                 line_break='"\\n"'
303                 ;;
304     *)          line_break='"\\012"';;
305 esac
306 AC_SUBST(line_break)
307
308 if test "$cf_cv_ebcdic" = "yes"; then
309 dnl If we have EBCDIC we most likley have z/OS Unix, let's test it!
310 AC_MSG_CHECKING(for z/OS Unix)
311 case `uname` in
312     OS/390)     zOSUnix="yes";
313                 dnl If using cc the environment variable _CC_CCMODE must be
314                 dnl set to "1", so that some compiler extensions are enabled.
315                 dnl If using c89 the environment variable is named _CC_C89MODE.
316                 dnl Note: compile with c89 never tested.
317                 if test "$CC" = "cc"; then
318                   ccm="$_CC_CCMODE"
319                   ccn="CC"
320                 else
321                   if test "$CC" = "c89"; then
322                     ccm="$_CC_C89MODE"
323                     ccn="C89"
324                   else
325                     ccm=1
326                   fi
327                 fi
328                 if test "$ccm" != "1"; then
329                   echo ""
330                   echo "------------------------------------------"
331                   echo " On z/OS Unix, the environment variable"
332                   echo " __CC_${ccn}MODE must be set to \"1\"!"
333                   echo " Do:"
334                   echo "    export _CC_${ccn}MODE=1"
335                   echo " and then call configure again."
336                   echo "------------------------------------------"
337                   exit 1
338                 fi
339                 CFLAGS="$CFLAGS -D_ALL_SOURCE -Wc,float\\(IEEE\\)";
340                 LDFLAGS="$LDFLAGS -Wl,EDIT=NO"
341                 AC_MSG_RESULT(yes)
342                 ;;
343     *)          zOSUnix="no";
344                 AC_MSG_RESULT(no)
345                 ;;
346 esac
347 fi
348
349 dnl Set QUOTESED. Needs additional backslashes on zOS
350 if test "$zOSUnix" = "yes"; then
351     QUOTESED="sed -e 's/[[\\\\\"]]/\\\\\\\\&/g' -e 's/\\\\\\\\\"/\"/' -e 's/\\\\\\\\\";\$\$/\";/'"
352 else
353     QUOTESED="sed -e 's/[[\\\\\"]]/\\\\&/g' -e 's/\\\\\"/\"/' -e 's/\\\\\";\$\$/\";/'"
354 fi
355 AC_SUBST(QUOTESED)
356
357
358 dnl Link with -lselinux for SELinux stuff; if not found
359 AC_MSG_CHECKING(--disable-selinux argument)
360 AC_ARG_ENABLE(selinux,
361         [  --disable-selinux      Don't check for SELinux support.],
362         , enable_selinux="yes")
363 if test "$enable_selinux" = "yes"; then
364   AC_MSG_RESULT(no)
365   AC_CHECK_LIB(selinux, is_selinux_enabled,
366           [LIBS="$LIBS -lselinux"
367            AC_DEFINE(HAVE_SELINUX)])
368 else
369    AC_MSG_RESULT(yes)
370 fi
371
372 dnl Check user requested features.
373
374 AC_MSG_CHECKING(--with-features argument)
375 AC_ARG_WITH(features, [  --with-features=TYPE    tiny, small, normal, big or huge (default: normal)],
376         features="$withval"; AC_MSG_RESULT($features),
377         features="normal"; AC_MSG_RESULT(Defaulting to normal))
378
379 dovimdiff=""
380 dogvimdiff=""
381 case "$features" in
382   tiny)         AC_DEFINE(FEAT_TINY) ;;
383   small)        AC_DEFINE(FEAT_SMALL) ;;
384   normal)       AC_DEFINE(FEAT_NORMAL) dovimdiff="installvimdiff";
385                         dogvimdiff="installgvimdiff" ;;
386   big)          AC_DEFINE(FEAT_BIG) dovimdiff="installvimdiff";
387                         dogvimdiff="installgvimdiff" ;;
388   huge)         AC_DEFINE(FEAT_HUGE) dovimdiff="installvimdiff";
389                         dogvimdiff="installgvimdiff" ;;
390   *)            AC_MSG_RESULT([Sorry, $features is not supported]) ;;
391 esac
392
393 AC_SUBST(dovimdiff)
394 AC_SUBST(dogvimdiff)
395
396 AC_MSG_CHECKING(--with-compiledby argument)
397 AC_ARG_WITH(compiledby, [  --with-compiledby=NAME  name to show in :version message],
398         compiledby="$withval"; AC_MSG_RESULT($withval),
399         compiledby=""; AC_MSG_RESULT(no))
400 AC_SUBST(compiledby)
401
402 AC_MSG_CHECKING(--disable-xsmp argument)
403 AC_ARG_ENABLE(xsmp,
404         [  --disable-xsmp          Disable XSMP session management],
405         , enable_xsmp="yes")
406
407 if test "$enable_xsmp" = "yes"; then
408   AC_MSG_RESULT(no)
409   AC_MSG_CHECKING(--disable-xsmp-interact argument)
410   AC_ARG_ENABLE(xsmp-interact,
411           [  --disable-xsmp-interact Disable XSMP interaction],
412           , enable_xsmp_interact="yes")
413   if test "$enable_xsmp_interact" = "yes"; then
414     AC_MSG_RESULT(no)
415     AC_DEFINE(USE_XSMP_INTERACT)
416   else
417     AC_MSG_RESULT(yes)
418   fi
419 else
420   AC_MSG_RESULT(yes)
421 fi
422
423 dnl Check for Lua feature.
424 AC_MSG_CHECKING(--enable-luainterp argument)
425 AC_ARG_ENABLE(luainterp,
426         [  --enable-luainterp[=OPTS]     Include Lua interpreter.  [default=no] [OPTS=no/yes/dynamic]], ,
427         [enable_luainterp="no"])
428 AC_MSG_RESULT($enable_luainterp)
429
430 if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then
431   dnl -- find the lua executable
432   AC_SUBST(vi_cv_path_lua)
433
434   AC_MSG_CHECKING(--with-lua-prefix argument)
435   AC_ARG_WITH(lua_prefix,
436         [  --with-lua-prefix=PFX   Prefix where Lua is installed.],
437         with_lua_prefix="$withval"; AC_MSG_RESULT($with_lua_prefix),
438         with_lua_prefix="";AC_MSG_RESULT(no))
439
440   if test "X$with_lua_prefix" != "X"; then
441        vi_cv_path_lua_pfx="$with_lua_prefix"
442   else
443     AC_MSG_CHECKING(LUA_PREFIX environment var)
444     if test "X$LUA_PREFIX" != "X"; then
445         AC_MSG_RESULT("$LUA_PREFIX")
446         vi_cv_path_lua_pfx="$LUA_PREFIX"
447     else
448         AC_MSG_RESULT([not set, default to /usr])
449         vi_cv_path_lua_pfx="/usr"
450     fi
451   fi
452
453   LUA_INC=
454   if test "X$vi_cv_path_lua_pfx" != "X"; then
455     AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)
456     if test -f $vi_cv_path_lua_pfx/include/lua.h; then
457       AC_MSG_RESULT(yes)
458     else
459       AC_MSG_RESULT(no)
460       dnl -- try to find Lua executable
461       AC_PATH_PROG(vi_cv_path_lua, lua)
462       if test "X$vi_cv_path_lua" != "X"; then
463         dnl -- find Lua version
464         AC_CACHE_CHECK(Lua version, vi_cv_version_lua,
465         [ vi_cv_version_lua=`${vi_cv_path_lua} -e "print(_VERSION)" | sed 's/.* //'` ])
466         AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua)
467         if test -f $vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h; then
468           AC_MSG_RESULT(yes)
469           LUA_INC=/lua$vi_cv_version_lua
470         else
471           AC_MSG_RESULT(no)
472           vi_cv_path_lua_pfx=
473         fi
474       fi
475     fi
476   fi
477
478   if test "X$vi_cv_path_lua_pfx" != "X"; then
479     if test "X$vi_cv_version_lua" != "X"; then
480       dnl Test alternate location using version
481       LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua$vi_cv_version_lua"
482     else
483       LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua"
484     fi
485     LUA_CFLAGS="-I${vi_cv_path_lua_pfx}/include${LUA_INC}"
486     LUA_SRC="if_lua.c"
487     LUA_OBJ="objects/if_lua.o"
488     LUA_PRO="if_lua.pro"
489     AC_DEFINE(FEAT_LUA)
490     if test "$enable_luainterp" = "dynamic"; then
491       dnl Determine the SONAME for the current version, but fallback to
492       dnl liblua${vi_cv_version_lua}.so if no SONAME-versioned file is found.
493       for i in 0 1 2 3 4 5 6 7 8 9; do
494         if test -f "${vi_cv_path_lua_pfx}/lib/liblua${vi_cv_version_lua}.so.$i"; then
495           LUA_SONAME=".$i"
496           break
497         fi
498       done
499       AC_DEFINE(DYNAMIC_LUA)
500       LUA_LIBS=""
501       LUA_CFLAGS="-DDYNAMIC_LUA_DLL=\\\"liblua${vi_cv_version_lua}.so$LUA_SONAME\\\" $LUA_CFLAGS"
502     fi
503   fi
504   if test "$fail_if_missing" = "yes" -a -z "$LUA_SRC"; then
505     AC_MSG_ERROR([could not configure lua])
506   fi
507   AC_SUBST(LUA_SRC)
508   AC_SUBST(LUA_OBJ)
509   AC_SUBST(LUA_PRO)
510   AC_SUBST(LUA_LIBS)
511   AC_SUBST(LUA_CFLAGS)
512 fi
513
514
515 dnl Check for MzScheme feature.
516 AC_MSG_CHECKING(--enable-mzschemeinterp argument)
517 AC_ARG_ENABLE(mzschemeinterp,
518         [  --enable-mzschemeinterp   Include MzScheme interpreter.], ,
519         [enable_mzschemeinterp="no"])
520 AC_MSG_RESULT($enable_mzschemeinterp)
521
522 if test "$enable_mzschemeinterp" = "yes"; then
523   dnl -- find the mzscheme executable
524   AC_SUBST(vi_cv_path_mzscheme)
525
526   AC_MSG_CHECKING(--with-plthome argument)
527   AC_ARG_WITH(plthome,
528         [  --with-plthome=PLTHOME   Use PLTHOME.],
529         with_plthome="$withval"; AC_MSG_RESULT($with_plthome),
530         with_plthome="";AC_MSG_RESULT("no"))
531
532   if test "X$with_plthome" != "X"; then
533        vi_cv_path_mzscheme_pfx="$with_plthome"
534   else
535     AC_MSG_CHECKING(PLTHOME environment var)
536     if test "X$PLTHOME" != "X"; then
537         AC_MSG_RESULT("$PLTHOME")
538         vi_cv_path_mzscheme_pfx="$PLTHOME"
539     else
540         AC_MSG_RESULT(not set)
541         dnl -- try to find MzScheme executable
542         AC_PATH_PROG(vi_cv_path_mzscheme, mzscheme)
543
544         dnl resolve symbolic link, the executable is often elsewhere and there
545         dnl are no links for the include files.
546         if test "X$vi_cv_path_mzscheme" != "X"; then
547           lsout=`ls -l $vi_cv_path_mzscheme`
548           if echo "$lsout" | grep -e '->' >/dev/null 2>/dev/null; then
549             vi_cv_path_mzscheme=`echo "$lsout" | sed 's/.*-> \(.*\)/\1/'`
550           fi
551         fi
552
553         if test "X$vi_cv_path_mzscheme" != "X"; then
554             dnl -- find where MzScheme thinks it was installed
555             AC_CACHE_CHECK(MzScheme install prefix,vi_cv_path_mzscheme_pfx,
556             dnl different versions of MzScheme differ in command line processing
557             dnl use universal approach
558             echo "(display (simplify-path               \
559                (build-path (call-with-values    \
560                 (lambda () (split-path (find-system-path (quote exec-file)))) \
561                 (lambda (base name must-be-dir?) base)) (quote up))))" > mzdirs.scm
562             dnl Remove a trailing slash
563             [ vi_cv_path_mzscheme_pfx=`${vi_cv_path_mzscheme} -r mzdirs.scm | \
564                 sed -e 's+/$++'` ])
565             rm -f mzdirs.scm
566         fi
567     fi
568   fi
569
570   SCHEME_INC=
571   if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
572     AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include)
573     if test -f $vi_cv_path_mzscheme_pfx/include/scheme.h; then
574       SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include
575       AC_MSG_RESULT(yes)
576     else
577       AC_MSG_RESULT(no)
578       AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt)
579       if test -f $vi_cv_path_mzscheme_pfx/include/plt/scheme.h; then
580         AC_MSG_RESULT(yes)
581         SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt
582       else
583         AC_MSG_RESULT(no)
584         AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket)
585         if test -f $vi_cv_path_mzscheme_pfx/include/racket/scheme.h; then
586           AC_MSG_RESULT(yes)
587           SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket
588         else
589           AC_MSG_RESULT(no)
590           AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/)
591           if test -f /usr/include/plt/scheme.h; then
592             AC_MSG_RESULT(yes)
593             SCHEME_INC=/usr/include/plt
594           else
595             AC_MSG_RESULT(no)
596             AC_MSG_CHECKING(if scheme.h can be found in /usr/include/racket/)
597             if test -f /usr/include/racket/scheme.h; then
598               AC_MSG_RESULT(yes)
599               SCHEME_INC=/usr/include/racket
600             else
601               AC_MSG_RESULT(no)
602               vi_cv_path_mzscheme_pfx=
603             fi
604           fi
605         fi
606       fi
607     fi
608   fi
609
610   if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
611     if test "x$MACOSX" = "xyes"; then
612       MZSCHEME_LIBS="-framework PLT_MzScheme"
613     elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"; then
614       MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"
615       MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
616     elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket3m.a"; then
617       MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libracket3m.a"
618       MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
619     elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket.a"; then
620       MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libracket.a ${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a"
621     elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme.a"; then
622       MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libmzscheme.a ${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a"
623     else
624       dnl Using shared objects
625       if test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.so"; then
626         MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lmzscheme3m"
627         MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
628       elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket3m.so"; then
629         MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lracket3m"
630         MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
631       elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket.so"; then
632         MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lracket -lmzgc"
633       else
634         MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lmzscheme -lmzgc"
635       fi
636       if test "$GCC" = yes; then
637         dnl Make Vim remember the path to the library.  For when it's not in
638         dnl $LD_LIBRARY_PATH.
639         MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${vi_cv_path_mzscheme_pfx}/lib"
640       elif test "`(uname) 2>/dev/null`" = SunOS &&
641                                uname -r | grep '^5' >/dev/null; then
642         MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${vi_cv_path_mzscheme_pfx}/lib"
643       fi
644     fi
645     if test -d $vi_cv_path_mzscheme_pfx/lib/plt/collects; then
646       SCHEME_COLLECTS=lib/plt/
647     else
648       if test -d $vi_cv_path_mzscheme_pfx/lib/racket/collects; then
649         SCHEME_COLLECTS=lib/racket/
650       fi
651     fi
652     if test -f "${vi_cv_path_mzscheme_pfx}/${SCHEME_COLLECTS}collects/scheme/base.ss" ; then
653       MZSCHEME_EXTRA="mzscheme_base.c"
654     else
655       if test -f "${vi_cv_path_mzscheme_pfx}/${SCHEME_COLLECTS}collects/scheme/base.rkt" ; then
656         MZSCHEME_EXTRA="mzscheme_base.c"
657       fi
658     fi
659     if test "X$MZSCHEME_EXTRA" != "X" ; then
660       dnl need to generate bytecode for MzScheme base
661       MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE"
662       MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
663     fi
664     MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -I${SCHEME_INC} \
665       -DMZSCHEME_COLLECTS='\"${vi_cv_path_mzscheme_pfx}/${SCHEME_COLLECTS}collects\"'"
666     MZSCHEME_SRC="if_mzsch.c"
667     MZSCHEME_OBJ="objects/if_mzsch.o"
668     MZSCHEME_PRO="if_mzsch.pro"
669     AC_DEFINE(FEAT_MZSCHEME)
670   fi
671   AC_SUBST(MZSCHEME_SRC)
672   AC_SUBST(MZSCHEME_OBJ)
673   AC_SUBST(MZSCHEME_PRO)
674   AC_SUBST(MZSCHEME_LIBS)
675   AC_SUBST(MZSCHEME_CFLAGS)
676   AC_SUBST(MZSCHEME_EXTRA)
677   AC_SUBST(MZSCHEME_MZC)
678 fi
679
680
681 AC_MSG_CHECKING(--enable-perlinterp argument)
682 AC_ARG_ENABLE(perlinterp,
683         [  --enable-perlinterp[=OPTS]     Include Perl interpreter.  [default=no] [OPTS=no/yes/dynamic]], ,
684         [enable_perlinterp="no"])
685 AC_MSG_RESULT($enable_perlinterp)
686 if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then
687   AC_SUBST(vi_cv_path_perl)
688   AC_PATH_PROG(vi_cv_path_perl, perl)
689   if test "X$vi_cv_path_perl" != "X"; then
690     AC_MSG_CHECKING(Perl version)
691     if $vi_cv_path_perl -e 'require 5.003_01' >/dev/null 2>/dev/null; then
692      eval `$vi_cv_path_perl -V:usethreads`
693      eval `$vi_cv_path_perl -V:libperl`
694      if test "X$usethreads" = "XUNKNOWN" -o "X$usethreads" = "Xundef"; then
695        badthreads=no
696      else
697        if $vi_cv_path_perl -e 'require 5.6.0' >/dev/null 2>/dev/null; then
698          eval `$vi_cv_path_perl -V:use5005threads`
699          if test "X$use5005threads" = "XUNKNOWN" -o "X$use5005threads" = "Xundef"; then
700            badthreads=no
701          else
702            badthreads=yes
703            AC_MSG_RESULT(>>> Perl > 5.6 with 5.5 threads cannot be used <<<)
704          fi
705        else
706          badthreads=yes
707          AC_MSG_RESULT(>>> Perl 5.5 with threads cannot be used <<<)
708        fi
709      fi
710      if test $badthreads = no; then
711       AC_MSG_RESULT(OK)
712       eval `$vi_cv_path_perl -V:shrpenv`
713       if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04
714         shrpenv=""
715       fi
716       vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlibexp}'`
717       AC_SUBST(vi_cv_perllib)
718       dnl Remove "-fno-something", it breaks using cproto.
719       perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
720               -e 'ccflags;perl_inc;print"\n"' | sed -e 's/-fno[[^ ]]*//'`
721       dnl Remove "-lc", it breaks on FreeBSD when using "-pthread".
722       perllibs=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed -e 'ldopts' | \
723                 sed -e '/Warning/d' -e '/Note (probably harmless)/d' \
724                         -e 's/-bE:perl.exp//' -e 's/-lc //'`
725       dnl Don't add perl lib to $LIBS: if it's not in LD_LIBRARY_PATH
726       dnl a test in configure may fail because of that.
727       perlldflags=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed \
728                 -e 'ccdlflags' | sed -e 's/-bE:perl.exp//'`
729
730       dnl check that compiling a simple program still works with the flags
731       dnl added for Perl.
732       AC_MSG_CHECKING([if compile and link flags for Perl are sane])
733       cflags_save=$CFLAGS
734       libs_save=$LIBS
735       ldflags_save=$LDFLAGS
736       CFLAGS="$CFLAGS $perlcppflags"
737       LIBS="$LIBS $perllibs"
738       LDFLAGS="$perlldflags $LDFLAGS"
739       AC_TRY_LINK(,[ ],
740              AC_MSG_RESULT(yes); perl_ok=yes,
741              AC_MSG_RESULT(no: PERL DISABLED); perl_ok=no)
742       CFLAGS=$cflags_save
743       LIBS=$libs_save
744       LDFLAGS=$ldflags_save
745       if test $perl_ok = yes; then
746         if test "X$perlcppflags" != "X"; then
747           dnl remove -pipe and -Wxxx, it confuses cproto
748           PERL_CFLAGS=`echo "$perlcppflags" | sed -e 's/-pipe //' -e 's/-W[[^ ]]*//'`
749         fi
750         if test "X$perlldflags" != "X"; then
751           LDFLAGS="$perlldflags $LDFLAGS"
752         fi
753         PERL_LIBS=$perllibs
754         PERL_SRC="auto/if_perl.c if_perlsfio.c"
755         PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o"
756         PERL_PRO="if_perl.pro if_perlsfio.pro"
757         AC_DEFINE(FEAT_PERL)
758       fi
759      fi
760     else
761       AC_MSG_RESULT(>>> too old; need Perl version 5.003_01 or later <<<)
762     fi
763   fi
764
765   if test "x$MACOSX" = "xyes"; then
766     dnl Mac OS X 10.2 or later
767     dir=/System/Library/Perl
768     darwindir=$dir/darwin
769     if test -d $darwindir; then
770       PERL=/usr/bin/perl
771     else
772       dnl Mac OS X 10.3
773       dir=/System/Library/Perl/5.8.1
774       darwindir=$dir/darwin-thread-multi-2level
775       if test -d $darwindir; then
776         PERL=/usr/bin/perl
777       fi
778     fi
779     if test -n "$PERL"; then
780       PERL_DIR="$dir"
781       PERL_CFLAGS="-DFEAT_PERL -I$darwindir/CORE"
782       PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o $darwindir/auto/DynaLoader/DynaLoader.a"
783       PERL_LIBS="-L$darwindir/CORE -lperl"
784     fi
785     dnl Perl on Mac OS X 10.5 adds "-arch" flags but these should only
786     dnl be included if requested by passing --with-mac-arch to
787     dnl configure, so strip these flags first (if present)
788     PERL_LIBS=`echo "$PERL_LIBS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
789     PERL_CFLAGS=`echo "$PERL_CFLAGS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
790   fi
791   if test "$enable_perlinterp" = "dynamic"; then
792     if test "$perl_ok" = "yes" -a "X$libperl" != "X"; then
793       AC_DEFINE(DYNAMIC_PERL)
794       PERL_CFLAGS="-DDYNAMIC_PERL_DLL=\\\"$libperl\\\" $PERL_CFLAGS"
795     fi
796   fi
797
798   if test "$fail_if_missing" = "yes" -a "$perl_ok" != "yes"; then
799     AC_MSG_ERROR([could not configure perl])
800   fi
801 fi
802 AC_SUBST(shrpenv)
803 AC_SUBST(PERL_SRC)
804 AC_SUBST(PERL_OBJ)
805 AC_SUBST(PERL_PRO)
806 AC_SUBST(PERL_CFLAGS)
807 AC_SUBST(PERL_LIBS)
808
809 AC_MSG_CHECKING(--enable-pythoninterp argument)
810 AC_ARG_ENABLE(pythoninterp,
811         [  --enable-pythoninterp[=OPTS]   Include Python interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
812         [enable_pythoninterp="no"])
813 AC_MSG_RESULT($enable_pythoninterp)
814 if test "$enable_pythoninterp" = "yes" -o "$enable_pythoninterp" = "dynamic"; then
815   dnl -- find the python executable
816   AC_PATH_PROG(vi_cv_path_python, python)
817   if test "X$vi_cv_path_python" != "X"; then
818
819     dnl -- get its version number
820     AC_CACHE_CHECK(Python version,vi_cv_var_python_version,
821     [[vi_cv_var_python_version=`
822             ${vi_cv_path_python} -c 'import sys; print sys.version[:3]'`
823     ]])
824
825     dnl -- it must be at least version 1.4
826     AC_MSG_CHECKING(Python is 1.4 or better)
827     if ${vi_cv_path_python} -c \
828         "import sys; sys.exit(${vi_cv_var_python_version} < 1.4)"
829     then
830       AC_MSG_RESULT(yep)
831
832       dnl -- find where python thinks it was installed
833       AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python_pfx,
834       [ vi_cv_path_python_pfx=`
835             ${vi_cv_path_python} -c \
836                 "import sys; print sys.prefix"` ])
837
838       dnl -- and where it thinks it runs
839       AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python_epfx,
840       [ vi_cv_path_python_epfx=`
841             ${vi_cv_path_python} -c \
842                 "import sys; print sys.exec_prefix"` ])
843
844       dnl -- python's internal library path
845
846       AC_CACHE_VAL(vi_cv_path_pythonpath,
847       [ vi_cv_path_pythonpath=`
848             unset PYTHONPATH;
849             ${vi_cv_path_python} -c \
850                 "import sys, string; print string.join(sys.path,':')"` ])
851
852       dnl -- where the Python implementation library archives are
853
854       AC_ARG_WITH(python-config-dir,
855         [  --with-python-config-dir=PATH  Python's config directory],
856         [ vi_cv_path_python_conf="${withval}" ] )
857
858       AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python_conf,
859       [
860         vi_cv_path_python_conf=
861         for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
862           for subdir in lib64 lib share; do
863             d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
864             if test -d "$d" && test -f "$d/config.c"; then
865               vi_cv_path_python_conf="$d"
866             fi
867           done
868         done
869       ])
870
871       PYTHON_CONFDIR="${vi_cv_path_python_conf}"
872
873       if test "X$PYTHON_CONFDIR" = "X"; then
874         AC_MSG_RESULT([can't find it!])
875       else
876
877         dnl -- we need to examine Python's config/Makefile too
878         dnl    see what the interpreter is built from
879         AC_CACHE_VAL(vi_cv_path_python_plibs,
880         [
881             pwd=`pwd`
882             tmp_mkf="$pwd/config-PyMake$$"
883             cat -- "${PYTHON_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
884 __:
885         @echo "python_BASEMODLIBS='$(BASEMODLIBS)'"
886         @echo "python_LIBS='$(LIBS)'"
887         @echo "python_SYSLIBS='$(SYSLIBS)'"
888         @echo "python_LINKFORSHARED='$(LINKFORSHARED)'"
889         @echo "python_INSTSONAME='$(INSTSONAME)'"
890 eof
891             dnl -- delete the lines from make about Entering/Leaving directory
892             eval "`cd ${PYTHON_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
893             rm -f -- "${tmp_mkf}"
894             if test "x$MACOSX" = "xyes" && ${vi_cv_path_python} -c \
895                 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then
896               vi_cv_path_python_plibs="-framework Python"
897             else
898               if test "${vi_cv_var_python_version}" = "1.4"; then
899                   vi_cv_path_python_plibs="${PYTHON_CONFDIR}/libModules.a ${PYTHON_CONFDIR}/libPython.a ${PYTHON_CONFDIR}/libObjects.a ${PYTHON_CONFDIR}/libParser.a"
900               else
901                   vi_cv_path_python_plibs="-L${PYTHON_CONFDIR} -lpython${vi_cv_var_python_version}"
902               fi
903               vi_cv_path_python_plibs="${vi_cv_path_python_plibs} ${python_BASEMODLIBS} ${python_LIBS} ${python_SYSLIBS} ${python_LINKFORSHARED}"
904               dnl remove -ltermcap, it can conflict with an earlier -lncurses
905               vi_cv_path_python_plibs=`echo $vi_cv_path_python_plibs | sed s/-ltermcap//`
906             fi
907         ])
908
909         PYTHON_LIBS="${vi_cv_path_python_plibs}"
910         if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
911           PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME=\\\"${vi_cv_path_python_pfx}\\\""
912         else
913           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} -DPYTHON_HOME=\\\"${vi_cv_path_python_pfx}\\\""
914         fi
915         PYTHON_SRC="if_python.c"
916         dnl For Mac OSX 10.2 config.o is included in the Python library.
917         if test "x$MACOSX" = "xyes"; then
918           PYTHON_OBJ="objects/if_python.o"
919         else
920           PYTHON_OBJ="objects/if_python.o objects/py_config.o"
921         fi
922         if test "${vi_cv_var_python_version}" = "1.4"; then
923            PYTHON_OBJ="$PYTHON_OBJ objects/py_getpath.o"
924         fi
925     PYTHON_GETPATH_CFLAGS="-DPYTHONPATH='\"${vi_cv_path_pythonpath}\"' -DPREFIX='\"${vi_cv_path_python_pfx}\"' -DEXEC_PREFIX='\"${vi_cv_path_python_epfx}\"'"
926
927         dnl On FreeBSD linking with "-pthread" is required to use threads.
928         dnl _THREAD_SAFE must be used for compiling then.
929         dnl The "-pthread" is added to $LIBS, so that the following check for
930         dnl sigaltstack() will look in libc_r (it's there in libc!).
931         dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS.  GCC
932         dnl will then define target-specific defines, e.g., -D_REENTRANT.
933         dnl Don't do this for Mac OSX, -pthread will generate a warning.
934         AC_MSG_CHECKING([if -pthread should be used])
935         threadsafe_flag=
936         thread_lib=
937         dnl if test "x$MACOSX" != "xyes"; then
938         if test "`(uname) 2>/dev/null`" != Darwin; then
939           test "$GCC" = yes && threadsafe_flag="-pthread"
940           if test "`(uname) 2>/dev/null`" = FreeBSD; then
941             threadsafe_flag="-D_THREAD_SAFE"
942             thread_lib="-pthread"
943           fi
944         fi
945         libs_save_old=$LIBS
946         if test -n "$threadsafe_flag"; then
947           cflags_save=$CFLAGS
948           CFLAGS="$CFLAGS $threadsafe_flag"
949           LIBS="$LIBS $thread_lib"
950           AC_TRY_LINK(,[ ],
951              AC_MSG_RESULT(yes); PYTHON_CFLAGS="$PYTHON_CFLAGS $threadsafe_flag",
952              AC_MSG_RESULT(no); LIBS=$libs_save_old
953              )
954           CFLAGS=$cflags_save
955         else
956           AC_MSG_RESULT(no)
957         fi
958
959         dnl Check that compiling a simple program still works with the flags
960         dnl added for Python.
961         AC_MSG_CHECKING([if compile and link flags for Python are sane])
962         cflags_save=$CFLAGS
963         libs_save=$LIBS
964         CFLAGS="$CFLAGS $PYTHON_CFLAGS"
965         LIBS="$LIBS $PYTHON_LIBS"
966         AC_TRY_LINK(,[ ],
967                AC_MSG_RESULT(yes); python_ok=yes,
968                AC_MSG_RESULT(no: PYTHON DISABLED); python_ok=no)
969         CFLAGS=$cflags_save
970         LIBS=$libs_save
971         if test $python_ok = yes; then
972           AC_DEFINE(FEAT_PYTHON)
973         else
974           LIBS=$libs_save_old
975           PYTHON_SRC=
976           PYTHON_OBJ=
977           PYTHON_LIBS=
978           PYTHON_CFLAGS=
979         fi
980
981       fi
982     else
983       AC_MSG_RESULT(too old)
984     fi
985   fi
986
987   if test "$fail_if_missing" = "yes" -a "$python_ok" != "yes"; then
988     AC_MSG_ERROR([could not configure python])
989   fi
990 fi
991
992 AC_SUBST(PYTHON_CONFDIR)
993 AC_SUBST(PYTHON_LIBS)
994 AC_SUBST(PYTHON_GETPATH_CFLAGS)
995 AC_SUBST(PYTHON_CFLAGS)
996 AC_SUBST(PYTHON_SRC)
997 AC_SUBST(PYTHON_OBJ)
998
999
1000 AC_MSG_CHECKING(--enable-python3interp argument)
1001 AC_ARG_ENABLE(python3interp,
1002         [  --enable-python3interp[=OPTS]   Include Python3 interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
1003         [enable_python3interp="no"])
1004 AC_MSG_RESULT($enable_python3interp)
1005 if test "$enable_python3interp" = "yes" -o "$enable_python3interp" = "dynamic"; then
1006   dnl -- find the python3 executable
1007   AC_PATH_PROG(vi_cv_path_python3, python3)
1008   if test "X$vi_cv_path_python3" != "X"; then
1009
1010     dnl -- get its version number
1011     AC_CACHE_CHECK(Python version,vi_cv_var_python3_version,
1012     [[vi_cv_var_python3_version=`
1013           ${vi_cv_path_python3} -c 'import sys; print(sys.version[:3])'`
1014     ]])
1015
1016     dnl -- get abiflags for python 3.2 or higher (PEP 3149)
1017     AC_CACHE_CHECK(Python's abiflags,vi_cv_var_python3_abiflags,
1018     [
1019      vi_cv_var_python3_abiflags=
1020      if ${vi_cv_path_python3} -c \
1021          "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)"
1022      then
1023        vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \    
1024          "import sys; print(sys.abiflags)"`
1025      fi ])
1026
1027     dnl -- find where python3 thinks it was installed
1028     AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx,
1029     [ vi_cv_path_python3_pfx=`
1030      ${vi_cv_path_python3} -c \
1031      "import sys; print(sys.prefix)"` ])
1032
1033     dnl -- and where it thinks it runs
1034     AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx,
1035     [ vi_cv_path_python3_epfx=`
1036      ${vi_cv_path_python3} -c \
1037      "import sys; print(sys.exec_prefix)"` ])
1038
1039     dnl -- python3's internal library path
1040
1041     AC_CACHE_VAL(vi_cv_path_python3path,
1042     [ vi_cv_path_python3path=`
1043      unset PYTHONPATH;
1044      ${vi_cv_path_python3} -c \
1045      "import sys, string; print(':'.join(sys.path))"` ])
1046
1047     dnl -- where the Python implementation library archives are
1048
1049     AC_ARG_WITH(python3-config-dir,
1050      [  --with-python3-config-dir=PATH  Python's config directory],
1051      [ vi_cv_path_python3_conf="${withval}" ] )
1052
1053     AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf,
1054     [
1055      vi_cv_path_python3_conf=
1056      config_dir="config"
1057      if test "${vi_cv_var_python3_abiflags}" != ""; then
1058        config_dir="${config_dir}-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
1059      fi
1060      for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do
1061        for subdir in lib64 lib share; do
1062          d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}"
1063          if test -d "$d" && test -f "$d/config.c"; then
1064            vi_cv_path_python3_conf="$d"
1065          fi
1066        done
1067      done
1068     ])
1069
1070     PYTHON3_CONFDIR="${vi_cv_path_python3_conf}"
1071
1072     if test "X$PYTHON3_CONFDIR" = "X"; then
1073       AC_MSG_RESULT([can't find it!])
1074     else
1075
1076       dnl -- we need to examine Python's config/Makefile too
1077       dnl    see what the interpreter is built from
1078       AC_CACHE_VAL(vi_cv_path_python3_plibs,
1079       [
1080           pwd=`pwd`
1081           tmp_mkf="$pwd/config-PyMake$$"
1082           cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
1083 __:
1084         @echo "python3_BASEMODLIBS='$(BASEMODLIBS)'"
1085         @echo "python3_LIBS='$(LIBS)'"
1086         @echo "python3_SYSLIBS='$(SYSLIBS)'"
1087         @echo "python3_INSTSONAME='$(INSTSONAME)'"
1088 eof
1089           dnl -- delete the lines from make about Entering/Leaving directory
1090           eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1091           rm -f -- "${tmp_mkf}"
1092           vi_cv_path_python3_plibs="-L${PYTHON3_CONFDIR} -lpython${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
1093           vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}"
1094           dnl remove -ltermcap, it can conflict with an earlier -lncurses
1095           vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//`
1096           vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//`
1097       ])
1098
1099       PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
1100       if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
1101         PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -DPYTHON3_HOME=L\\\"${vi_cv_path_python3_pfx}\\\""
1102       else
1103         PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -I${vi_cv_path_python3_epfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -DPYTHON3_HOME=L\\\"${vi_cv_path_python3_pfx}\\\""
1104       fi
1105       PYTHON3_SRC="if_python3.c"
1106       dnl For Mac OSX 10.2 config.o is included in the Python library.
1107       if test "x$MACOSX" = "xyes"; then
1108         PYTHON3_OBJ="objects/if_python3.o"
1109       else
1110         PYTHON3_OBJ="objects/if_python3.o objects/py3_config.o"
1111       fi
1112
1113       dnl On FreeBSD linking with "-pthread" is required to use threads.
1114       dnl _THREAD_SAFE must be used for compiling then.
1115       dnl The "-pthread" is added to $LIBS, so that the following check for
1116       dnl sigaltstack() will look in libc_r (it's there in libc!).
1117       dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS.  GCC
1118       dnl will then define target-specific defines, e.g., -D_REENTRANT.
1119       dnl Don't do this for Mac OSX, -pthread will generate a warning.
1120       AC_MSG_CHECKING([if -pthread should be used])
1121       threadsafe_flag=
1122       thread_lib=
1123       dnl if test "x$MACOSX" != "xyes"; then
1124       if test "`(uname) 2>/dev/null`" != Darwin; then
1125         test "$GCC" = yes && threadsafe_flag="-pthread"
1126         if test "`(uname) 2>/dev/null`" = FreeBSD; then
1127           threadsafe_flag="-D_THREAD_SAFE"
1128           thread_lib="-pthread"
1129         fi
1130       fi
1131       libs_save_old=$LIBS
1132       if test -n "$threadsafe_flag"; then
1133         cflags_save=$CFLAGS
1134         CFLAGS="$CFLAGS $threadsafe_flag"
1135         LIBS="$LIBS $thread_lib"
1136         AC_TRY_LINK(,[ ],
1137            AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag",
1138            AC_MSG_RESULT(no); LIBS=$libs_save_old
1139            )
1140         CFLAGS=$cflags_save
1141       else
1142         AC_MSG_RESULT(no)
1143       fi
1144
1145       dnl check that compiling a simple program still works with the flags
1146       dnl added for Python.
1147       AC_MSG_CHECKING([if compile and link flags for Python 3 are sane])
1148       cflags_save=$CFLAGS
1149       libs_save=$LIBS
1150       CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1151       LIBS="$LIBS $PYTHON3_LIBS"
1152       AC_TRY_LINK(,[ ],
1153              AC_MSG_RESULT(yes); python3_ok=yes,
1154              AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no)
1155       CFLAGS=$cflags_save
1156       LIBS=$libs_save
1157       if test "$python3_ok" = yes; then
1158         AC_DEFINE(FEAT_PYTHON3)
1159       else
1160         LIBS=$libs_save_old
1161         PYTHON3_SRC=
1162         PYTHON3_OBJ=
1163         PYTHON3_LIBS=
1164         PYTHON3_CFLAGS=
1165       fi
1166     fi
1167   fi
1168 fi
1169
1170 AC_SUBST(PYTHON3_CONFDIR)
1171 AC_SUBST(PYTHON3_LIBS)
1172 AC_SUBST(PYTHON3_CFLAGS)
1173 AC_SUBST(PYTHON3_SRC)
1174 AC_SUBST(PYTHON3_OBJ)
1175
1176 dnl if python2.x and python3.x are enabled one can only link in code
1177 dnl with dlopen(), dlsym(), dlclose() 
1178 if test "$python_ok" = yes && test "$python3_ok" = yes; then
1179   AC_DEFINE(DYNAMIC_PYTHON)
1180   AC_DEFINE(DYNAMIC_PYTHON3)
1181   AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python)
1182   cflags_save=$CFLAGS
1183   CFLAGS="$CFLAGS $PYTHON_CFLAGS"
1184   ldflags_save=$LDFLAGS
1185   dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
1186   LDFLAGS="-ldl $LDFLAGS"
1187   AC_RUN_IFELSE([
1188     #include <dlfcn.h>
1189     /* If this program fails, then RTLD_GLOBAL is needed.
1190      * RTLD_GLOBAL will be used and then it is not possible to
1191      * have both python versions enabled in the same vim instance.
1192      * Only the first pyhton version used will be switched on.
1193      */
1194
1195     int no_rtl_global_needed_for(char *python_instsoname, char *prefix)
1196     {
1197       int needed = 0;
1198       void* pylib = dlopen(python_instsoname, RTLD_LAZY);
1199       if (pylib != 0)
1200       {
1201           void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome");
1202           void (*init)(void) = dlsym(pylib, "Py_Initialize");
1203           int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1204           void (*final)(void) = dlsym(pylib, "Py_Finalize");
1205           (*pfx)(prefix);
1206           (*init)();
1207           needed = (*simple)("import termios") == -1;
1208           (*final)();
1209           dlclose(pylib);
1210       }
1211       return !needed;
1212     }
1213
1214     int main(int argc, char** argv)
1215     {
1216       int not_needed = 0;
1217       if (no_rtl_global_needed_for("${python_INSTSONAME}", "${vi_cv_path_python_pfx}"))
1218             not_needed = 1;
1219       return !not_needed;
1220     }],
1221     [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
1222
1223   CFLAGS=$cflags_save
1224   LDFLAGS=$ldflags_save
1225
1226   AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python3)
1227   cflags_save=$CFLAGS
1228   CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1229   ldflags_save=$LDFLAGS
1230   dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
1231   LDFLAGS="-ldl $LDFLAGS"
1232   AC_RUN_IFELSE([
1233     #include <dlfcn.h>
1234     #include <wchar.h>
1235     /* If this program fails, then RTLD_GLOBAL is needed.
1236      * RTLD_GLOBAL will be used and then it is not possible to
1237      * have both python versions enabled in the same vim instance.
1238      * Only the first pyhton version used will be switched on.
1239      */
1240
1241     int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix)
1242     {
1243       int needed = 0;
1244       void* pylib = dlopen(python_instsoname, RTLD_LAZY);
1245       if (pylib != 0)
1246       {
1247           void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome");
1248           void (*init)(void) = dlsym(pylib, "Py_Initialize");
1249           int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1250           void (*final)(void) = dlsym(pylib, "Py_Finalize");
1251           (*pfx)(prefix);
1252           (*init)();
1253           needed = (*simple)("import termios") == -1;
1254           (*final)();
1255           dlclose(pylib);
1256       }
1257       return !needed;
1258     }
1259
1260     int main(int argc, char** argv)
1261     {
1262       int not_needed = 0;
1263       if (no_rtl_global_needed_for("${python3_INSTSONAME}", L"${vi_cv_path_python3_pfx}"))
1264             not_needed = 1;
1265       return !not_needed;
1266     }],
1267     [AC_MSG_RESULT(yes);AC_DEFINE(PY3_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
1268
1269   CFLAGS=$cflags_save
1270   LDFLAGS=$ldflags_save
1271
1272   PYTHON_SRC="if_python.c"
1273   PYTHON_OBJ="objects/if_python.o"
1274   PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${python_INSTSONAME}\\\""
1275   PYTHON_LIBS=
1276   PYTHON3_SRC="if_python3.c"
1277   PYTHON3_OBJ="objects/if_python3.o"
1278   PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${python3_INSTSONAME}\\\""
1279   PYTHON3_LIBS=
1280 elif test "$python_ok" = yes && test "$enable_pythoninterp" = "dynamic"; then
1281   AC_DEFINE(DYNAMIC_PYTHON)
1282   PYTHON_SRC="if_python.c"
1283   PYTHON_OBJ="objects/if_python.o"
1284   PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${python_INSTSONAME}\\\""
1285   PYTHON_LIBS=
1286 elif test "$python3_ok" = yes && test "$enable_python3interp" = "dynamic"; then
1287   AC_DEFINE(DYNAMIC_PYTHON3)
1288   PYTHON3_SRC="if_python3.c"
1289   PYTHON3_OBJ="objects/if_python3.o"
1290   PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${python3_INSTSONAME}\\\""
1291   PYTHON3_LIBS=
1292 fi
1293
1294 AC_MSG_CHECKING(--enable-tclinterp argument)
1295 AC_ARG_ENABLE(tclinterp,
1296         [  --enable-tclinterp      Include Tcl interpreter.], ,
1297         [enable_tclinterp="no"])
1298 AC_MSG_RESULT($enable_tclinterp)
1299
1300 if test "$enable_tclinterp" = "yes"; then
1301
1302   dnl on FreeBSD tclsh is a silly script, look for tclsh8.[5420]
1303   AC_MSG_CHECKING(--with-tclsh argument)
1304   AC_ARG_WITH(tclsh, [  --with-tclsh=PATH       which tclsh to use (default: tclsh8.0)],
1305         tclsh_name="$withval"; AC_MSG_RESULT($tclsh_name),
1306         tclsh_name="tclsh8.5"; AC_MSG_RESULT(no))
1307   AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1308   AC_SUBST(vi_cv_path_tcl)
1309
1310   dnl when no specific version specified, also try 8.4, 8.2 and 8.0
1311   if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.5"; then
1312     tclsh_name="tclsh8.4"
1313     AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1314   fi
1315   if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.4"; then
1316     tclsh_name="tclsh8.2"
1317     AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1318   fi
1319   if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.2"; then
1320     tclsh_name="tclsh8.0"
1321     AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1322   fi
1323   dnl still didn't find it, try without version number
1324   if test "X$vi_cv_path_tcl" = "X"; then
1325     tclsh_name="tclsh"
1326     AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1327   fi
1328   if test "X$vi_cv_path_tcl" != "X"; then
1329     AC_MSG_CHECKING(Tcl version)
1330     if echo 'exit [[expr [info tclversion] < 8.0]]' | $vi_cv_path_tcl - ; then
1331       tclver=`echo 'puts [[info tclversion]]' | $vi_cv_path_tcl -`
1332       AC_MSG_RESULT($tclver - OK);
1333       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 -`
1334
1335       AC_MSG_CHECKING(for location of Tcl include)
1336       if test "x$MACOSX" != "xyes"; then
1337         tclinc="$tclloc/include $tclloc/include/tcl $tclloc/include/tcl$tclver /usr/local/include /usr/local/include/tcl$tclver /usr/include /usr/include/tcl$tclver"
1338       else
1339         dnl For Mac OS X 10.3, use the OS-provided framework location
1340         tclinc="/System/Library/Frameworks/Tcl.framework/Headers"
1341       fi
1342       TCL_INC=
1343       for try in $tclinc; do
1344         if test -f "$try/tcl.h"; then
1345           AC_MSG_RESULT($try/tcl.h)
1346           TCL_INC=$try
1347           break
1348         fi
1349       done
1350       if test -z "$TCL_INC"; then
1351         AC_MSG_RESULT(<not found>)
1352         SKIP_TCL=YES
1353       fi
1354       if test -z "$SKIP_TCL"; then
1355         AC_MSG_CHECKING(for location of tclConfig.sh script)
1356         if test "x$MACOSX" != "xyes"; then
1357           tclcnf=`echo $tclinc | sed s/include/lib/g`
1358           tclcnf="$tclcnf `echo $tclinc | sed s/include/lib64/g`"
1359         else
1360           dnl For Mac OS X 10.3, use the OS-provided framework location
1361           tclcnf="/System/Library/Frameworks/Tcl.framework"
1362         fi
1363         for try in $tclcnf; do
1364           if test -f $try/tclConfig.sh; then
1365             AC_MSG_RESULT($try/tclConfig.sh)
1366             . $try/tclConfig.sh
1367             dnl use eval, because tcl 8.2 includes ${TCL_DBGX}
1368             TCL_LIBS=`eval echo "$TCL_LIB_SPEC $TCL_LIBS"`
1369             dnl Use $TCL_DEFS for -D_THREAD_SAFE et al.  But only use the
1370             dnl "-D_ABC" items.  Watch out for -DFOO=long\ long.
1371             TCL_DEFS=`echo $TCL_DEFS | sed -e 's/\\\\ /\\\\X/g' | tr ' ' '\012' | sed -e '/^[[^-]]/d' -e '/^-[[^D]]/d' -e '/-D[[^_]]/d' -e 's/-D_/ -D_/' | tr '\012' ' ' | sed -e 's/\\\\X/\\\\ /g'`
1372             break
1373           fi
1374         done
1375         if test -z "$TCL_LIBS"; then
1376           AC_MSG_RESULT(<not found>)
1377           AC_MSG_CHECKING(for Tcl library by myself)
1378           tcllib=`echo $tclinc | sed s/include/lib/g`
1379           tcllib="$tcllib `echo $tclinc | sed s/include/lib64/g`"
1380           for ext in .so .a ; do
1381             for ver in "" $tclver ; do
1382               for try in $tcllib ; do
1383                 trylib=tcl$ver$ext
1384                 if test -f $try/lib$trylib ; then
1385                   AC_MSG_RESULT($try/lib$trylib)
1386                   TCL_LIBS="-L$try -ltcl$ver -ldl -lm"
1387                   if test "`(uname) 2>/dev/null`" = SunOS &&
1388                                          uname -r | grep '^5' >/dev/null; then
1389                     TCL_LIBS="$TCL_LIBS -R $try"
1390                   fi
1391                   break 3
1392                 fi
1393               done
1394             done
1395           done
1396           if test -z "$TCL_LIBS"; then
1397             AC_MSG_RESULT(<not found>)
1398             SKIP_TCL=YES
1399           fi
1400         fi
1401         if test -z "$SKIP_TCL"; then
1402           AC_DEFINE(FEAT_TCL)
1403           TCL_SRC=if_tcl.c
1404           TCL_OBJ=objects/if_tcl.o
1405           TCL_PRO=if_tcl.pro
1406           TCL_CFLAGS="-I$TCL_INC $TCL_DEFS"
1407         fi
1408       fi
1409     else
1410       AC_MSG_RESULT(too old; need Tcl version 8.0 or later)
1411     fi
1412   fi
1413   if test "$fail_if_missing" = "yes" -a -z "$TCL_SRC"; then
1414     AC_MSG_ERROR([could not configure Tcl])
1415   fi
1416 fi
1417 AC_SUBST(TCL_SRC)
1418 AC_SUBST(TCL_OBJ)
1419 AC_SUBST(TCL_PRO)
1420 AC_SUBST(TCL_CFLAGS)
1421 AC_SUBST(TCL_LIBS)
1422
1423 AC_MSG_CHECKING(--enable-rubyinterp argument)
1424 AC_ARG_ENABLE(rubyinterp,
1425         [  --enable-rubyinterp[=OPTS]     Include Ruby interpreter.  [default=no] [OPTS=no/yes/dynamic]], ,
1426         [enable_rubyinterp="no"])
1427 AC_MSG_RESULT($enable_rubyinterp)
1428 if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then
1429   AC_MSG_CHECKING(--with-ruby-command argument)
1430   AC_SUBST(vi_cv_path_ruby)
1431   AC_ARG_WITH(ruby-command, [  --with-ruby-command=RUBY  name of the Ruby command (default: ruby)],
1432         RUBY_CMD="$withval"; vi_cv_path_ruby="$withval"; AC_MSG_RESULT($RUBY_CMD),
1433         RUBY_CMD="ruby"; AC_MSG_RESULT(defaulting to $RUBY_CMD))
1434   AC_PATH_PROG(vi_cv_path_ruby, $RUBY_CMD)
1435   if test "X$vi_cv_path_ruby" != "X"; then
1436     AC_MSG_CHECKING(Ruby version)
1437     if $vi_cv_path_ruby -e '(VERSION rescue RUBY_VERSION) >= "1.6.0" or exit 1' >/dev/null 2>/dev/null; then
1438       AC_MSG_RESULT(OK)
1439       AC_MSG_CHECKING(Ruby header files)
1440       rubyhdrdir=`$vi_cv_path_ruby -r mkmf -e 'print Config::CONFIG[["rubyhdrdir"]] || Config::CONFIG[["archdir"]] || $hdrdir' 2>/dev/null`
1441       if test "X$rubyhdrdir" != "X"; then
1442         AC_MSG_RESULT($rubyhdrdir)
1443         RUBY_CFLAGS="-I$rubyhdrdir"
1444         rubyarch=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG[["arch"]]'`
1445         if test -d "$rubyhdrdir/$rubyarch"; then
1446           RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyhdrdir/$rubyarch"
1447         fi
1448         rubyversion=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG[["ruby_version"]].gsub(/\./, "")[[0,2]]'`
1449         RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
1450         rubylibs=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG[["LIBS"]]'`
1451         if test "X$rubylibs" != "X"; then
1452           RUBY_LIBS="$rubylibs"
1453         fi
1454         librubyarg=`$vi_cv_path_ruby -r rbconfig -e 'print Config.expand(Config::CONFIG[["LIBRUBYARG"]])'`
1455         librubya=`$vi_cv_path_ruby -r rbconfig -e 'print Config.expand(Config::CONFIG[["LIBRUBY_A"]])'`
1456   rubylibdir=`$vi_cv_path_ruby -r rbconfig -e 'print Config.expand(Config::CONFIG[["libdir"]])'`
1457         if test -f "$rubylibdir/$librubya"; then
1458           librubyarg="$librubyarg"
1459     RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
1460   elif test "$librubyarg" = "libruby.a"; then
1461     dnl required on Mac OS 10.3 where libruby.a doesn't exist
1462     librubyarg="-lruby"
1463     RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
1464         fi
1465
1466         if test "X$librubyarg" != "X"; then
1467           RUBY_LIBS="$librubyarg $RUBY_LIBS"
1468         fi
1469         rubyldflags=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG[["LDFLAGS"]]'`
1470         if test "X$rubyldflags" != "X"; then
1471           dnl Ruby on Mac OS X 10.5 adds "-arch" flags but these should only
1472           dnl be included if requested by passing --with-mac-arch to
1473           dnl configure, so strip these flags first (if present)
1474           rubyldflags=`echo "$rubyldflags" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
1475           if test "X$rubyldflags" != "X"; then
1476             LDFLAGS="$rubyldflags $LDFLAGS"
1477           fi
1478         fi
1479         RUBY_SRC="if_ruby.c"
1480         RUBY_OBJ="objects/if_ruby.o"
1481         RUBY_PRO="if_ruby.pro"
1482         AC_DEFINE(FEAT_RUBY)
1483         if test "$enable_rubyinterp" = "dynamic"; then
1484           libruby=`$vi_cv_path_ruby -r rbconfig -e 'printf "lib%s.%s\n", Config::CONFIG[["RUBY_SO_NAME"]], Config::CONFIG[["DLEXT"]]'`
1485           AC_DEFINE(DYNAMIC_RUBY)
1486           RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby\\\" -DDYNAMIC_RUBY_VER=$rubyversion $RUBY_CFLAGS"
1487           RUBY_LIBS=
1488         fi
1489       else
1490         AC_MSG_RESULT(not found; disabling Ruby)
1491       fi
1492     else
1493       AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
1494     fi
1495   fi
1496
1497   if test "$fail_if_missing" = "yes" -a -z "$RUBY_OBJ"; then
1498     AC_MSG_ERROR([could not configure Ruby])
1499   fi
1500 fi
1501 AC_SUBST(RUBY_SRC)
1502 AC_SUBST(RUBY_OBJ)
1503 AC_SUBST(RUBY_PRO)
1504 AC_SUBST(RUBY_CFLAGS)
1505 AC_SUBST(RUBY_LIBS)
1506
1507 AC_MSG_CHECKING(--enable-cscope argument)
1508 AC_ARG_ENABLE(cscope,
1509         [  --enable-cscope         Include cscope interface.], ,
1510         [enable_cscope="no"])
1511 AC_MSG_RESULT($enable_cscope)
1512 if test "$enable_cscope" = "yes"; then
1513   AC_DEFINE(FEAT_CSCOPE)
1514 fi
1515
1516 AC_MSG_CHECKING(--enable-workshop argument)
1517 AC_ARG_ENABLE(workshop,
1518         [  --enable-workshop       Include Sun Visual Workshop support.], ,
1519         [enable_workshop="no"])
1520 AC_MSG_RESULT($enable_workshop)
1521 if test "$enable_workshop" = "yes"; then
1522   AC_DEFINE(FEAT_SUN_WORKSHOP)
1523   WORKSHOP_SRC="workshop.c integration.c"
1524   AC_SUBST(WORKSHOP_SRC)
1525   WORKSHOP_OBJ="objects/workshop.o objects/integration.o"
1526   AC_SUBST(WORKSHOP_OBJ)
1527   if test "${enable_gui-xxx}" = xxx; then
1528     enable_gui=motif
1529   fi
1530 fi
1531
1532 AC_MSG_CHECKING(--disable-netbeans argument)
1533 AC_ARG_ENABLE(netbeans,
1534         [  --disable-netbeans      Disable NetBeans integration support.],
1535         , [enable_netbeans="yes"])
1536 if test "$enable_netbeans" = "yes"; then
1537   AC_MSG_RESULT(no)
1538   dnl On Solaris we need the socket and nsl library.
1539   AC_CHECK_LIB(socket, socket)
1540   AC_CHECK_LIB(nsl, gethostbyname)
1541   AC_MSG_CHECKING(whether compiling netbeans integration is possible)
1542   AC_TRY_LINK([
1543 #include <stdio.h>
1544 #include <stdlib.h>
1545 #include <stdarg.h>
1546 #include <fcntl.h>
1547 #include <netdb.h>
1548 #include <netinet/in.h>
1549 #include <errno.h>
1550 #include <sys/types.h>
1551 #include <sys/socket.h>
1552         /* Check bitfields */
1553         struct nbbuf {
1554         unsigned int  initDone:1;
1555         ushort signmaplen;
1556         };
1557             ], [
1558                 /* Check creating a socket. */
1559                 struct sockaddr_in server;
1560                 (void)socket(AF_INET, SOCK_STREAM, 0);
1561                 (void)htons(100);
1562                 (void)gethostbyname("microsoft.com");
1563                 if (errno == ECONNREFUSED)
1564                   (void)connect(1, (struct sockaddr *)&server, sizeof(server));
1565             ],
1566         AC_MSG_RESULT(yes),
1567         AC_MSG_RESULT(no); enable_netbeans="no")
1568 else
1569   AC_MSG_RESULT(yes)
1570 fi
1571 if test "$enable_netbeans" = "yes"; then
1572   AC_DEFINE(FEAT_NETBEANS_INTG)
1573   NETBEANS_SRC="netbeans.c"
1574   AC_SUBST(NETBEANS_SRC)
1575   NETBEANS_OBJ="objects/netbeans.o"
1576   AC_SUBST(NETBEANS_OBJ)
1577 fi
1578
1579 AC_MSG_CHECKING(--enable-sniff argument)
1580 AC_ARG_ENABLE(sniff,
1581         [  --enable-sniff          Include Sniff interface.], ,
1582         [enable_sniff="no"])
1583 AC_MSG_RESULT($enable_sniff)
1584 if test "$enable_sniff" = "yes"; then
1585   AC_DEFINE(FEAT_SNIFF)
1586   SNIFF_SRC="if_sniff.c"
1587   AC_SUBST(SNIFF_SRC)
1588   SNIFF_OBJ="objects/if_sniff.o"
1589   AC_SUBST(SNIFF_OBJ)
1590 fi
1591
1592 AC_MSG_CHECKING(--enable-multibyte argument)
1593 AC_ARG_ENABLE(multibyte,
1594         [  --enable-multibyte      Include multibyte editing support.], ,
1595         [enable_multibyte="no"])
1596 AC_MSG_RESULT($enable_multibyte)
1597 if test "$enable_multibyte" = "yes"; then
1598   AC_DEFINE(FEAT_MBYTE)
1599 fi
1600
1601 AC_MSG_CHECKING(--enable-hangulinput argument)
1602 AC_ARG_ENABLE(hangulinput,
1603         [  --enable-hangulinput    Include Hangul input support.], ,
1604         [enable_hangulinput="no"])
1605 AC_MSG_RESULT($enable_hangulinput)
1606
1607 AC_MSG_CHECKING(--enable-xim argument)
1608 AC_ARG_ENABLE(xim,
1609         [  --enable-xim            Include XIM input support.],
1610         AC_MSG_RESULT($enable_xim),
1611         [enable_xim="auto"; AC_MSG_RESULT(defaulting to auto)])
1612
1613 AC_MSG_CHECKING(--enable-fontset argument)
1614 AC_ARG_ENABLE(fontset,
1615         [  --enable-fontset        Include X fontset output support.], ,
1616         [enable_fontset="no"])
1617 AC_MSG_RESULT($enable_fontset)
1618 dnl defining FEAT_XFONTSET is delayed, so that it can be disabled for no GUI
1619
1620 test -z "$with_x" && with_x=yes
1621 test "${enable_gui-yes}" != no -a "x$MACOSX" != "xyes" -a "x$QNX" != "xyes" && with_x=yes
1622 if test "$with_x" = no; then
1623   AC_MSG_RESULT(defaulting to: don't HAVE_X11)
1624 else
1625   dnl Do this check early, so that its failure can override user requests.
1626
1627   AC_PATH_PROG(xmkmfpath, xmkmf)
1628
1629   AC_PATH_XTRA
1630
1631   dnl On z/OS Unix the X libraries are DLLs. To use them the code must
1632   dnl be compiled with a special option.
1633   dnl Also add SM, ICE and Xmu to X_EXTRA_LIBS.
1634   if test "$zOSUnix" = "yes"; then
1635     CFLAGS="$CFLAGS -W c,dll"
1636     LDFLAGS="$LDFLAGS -W l,dll"
1637     X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE -lXmu"
1638   fi
1639
1640   dnl On my HPUX system the X include dir is found, but the lib dir not.
1641   dnl This is a desparate try to fix this.
1642
1643   if test -d "$x_includes" && test ! -d "$x_libraries"; then
1644     x_libraries=`echo "$x_includes" | sed s/include/lib/`
1645     AC_MSG_RESULT(Corrected X libraries to $x_libraries)
1646     X_LIBS="$X_LIBS -L$x_libraries"
1647     if test "`(uname) 2>/dev/null`" = SunOS &&
1648                                          uname -r | grep '^5' >/dev/null; then
1649       X_LIBS="$X_LIBS -R $x_libraries"
1650     fi
1651   fi
1652
1653   if test -d "$x_libraries" && test ! -d "$x_includes"; then
1654     x_includes=`echo "$x_libraries" | sed s/lib/include/`
1655     AC_MSG_RESULT(Corrected X includes to $x_includes)
1656     X_CFLAGS="$X_CFLAGS -I$x_includes"
1657   fi
1658
1659   dnl Remove "-I/usr/include " from X_CFLAGS, should not be needed.
1660   X_CFLAGS="`echo $X_CFLAGS\  | sed 's%-I/usr/include %%'`"
1661   dnl Remove "-L/usr/lib " from X_LIBS, should not be needed.
1662   X_LIBS="`echo $X_LIBS\  | sed 's%-L/usr/lib %%'`"
1663   dnl Same for "-R/usr/lib ".
1664   X_LIBS="`echo $X_LIBS\  | sed -e 's%-R/usr/lib %%' -e 's%-R /usr/lib %%'`"
1665
1666
1667   dnl Check if the X11 header files are correctly installed. On some systems
1668   dnl Xlib.h includes files that don't exist.  On some systems X11/Intrinsic.h
1669   dnl is missing.
1670   AC_MSG_CHECKING(if X11 header files can be found)
1671   cflags_save=$CFLAGS
1672   CFLAGS="$CFLAGS $X_CFLAGS"
1673   AC_TRY_COMPILE([#include <X11/Xlib.h>
1674 #include <X11/Intrinsic.h>], ,
1675         AC_MSG_RESULT(yes),
1676         AC_MSG_RESULT(no); no_x=yes)
1677   CFLAGS=$cflags_save
1678
1679   if test "${no_x-no}" = yes; then
1680     with_x=no
1681   else
1682     AC_DEFINE(HAVE_X11)
1683     X_LIB="-lXt -lX11";
1684     AC_SUBST(X_LIB)
1685
1686     ac_save_LDFLAGS="$LDFLAGS"
1687     LDFLAGS="-L$x_libraries $LDFLAGS"
1688
1689     dnl Check for -lXdmcp (needed on SunOS 4.1.4)
1690     dnl For HP-UX 10.20 it must be before -lSM -lICE
1691     AC_CHECK_LIB(Xdmcp, _XdmcpAuthDoIt, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lXdmcp"],,
1692                 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXdmcp])
1693
1694     dnl Some systems need -lnsl -lsocket when testing for ICE.
1695     dnl The check above doesn't do this, try here (again).  Also needed to get
1696     dnl them after Xdmcp.  link.sh will remove them when not needed.
1697     dnl Check for other function than above to avoid the cached value
1698     AC_CHECK_LIB(ICE, IceOpenConnection,
1699                   [X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE"],, [$X_EXTRA_LIBS])
1700
1701     dnl Check for -lXpm (needed for some versions of Motif)
1702     LDFLAGS="$X_LIBS $ac_save_LDFLAGS"
1703     AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [X_PRE_LIBS="$X_PRE_LIBS -lXpm"],,
1704                 [-lXt $X_PRE_LIBS -lXpm -lX11 $X_EXTRA_LIBS])
1705
1706     dnl Check that the X11 header files don't use implicit declarations
1707     AC_MSG_CHECKING(if X11 header files implicitly declare return values)
1708     cflags_save=$CFLAGS
1709     CFLAGS="$CFLAGS $X_CFLAGS -Werror"
1710     AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
1711         AC_MSG_RESULT(no),
1712         CFLAGS="$CFLAGS -Wno-implicit-int"
1713         AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
1714             AC_MSG_RESULT(yes); cflags_save="$cflags_save -Wno-implicit-int",
1715             AC_MSG_RESULT(test failed)
1716         )
1717     )
1718     CFLAGS=$cflags_save
1719
1720     LDFLAGS="$ac_save_LDFLAGS"
1721
1722     AC_MSG_CHECKING(size of wchar_t is 2 bytes)
1723     AC_CACHE_VAL(ac_cv_small_wchar_t,
1724         [AC_TRY_RUN([
1725 #include <X11/Xlib.h>
1726 #if STDC_HEADERS
1727 # include <stdlib.h>
1728 # include <stddef.h>
1729 #endif
1730                 main()
1731                 {
1732                   if (sizeof(wchar_t) <= 2)
1733                     exit(1);
1734                   exit(0);
1735                 }],
1736                 ac_cv_small_wchar_t="no",
1737                 ac_cv_small_wchar_t="yes",
1738                 AC_MSG_ERROR(failed to compile test program))])
1739     AC_MSG_RESULT($ac_cv_small_wchar_t)
1740     if test "x$ac_cv_small_wchar_t" = "xyes" ; then
1741       AC_DEFINE(SMALL_WCHAR_T)
1742     fi
1743
1744   fi
1745 fi
1746
1747 test "x$with_x" = xno -a "x$MACOSX" != "xyes" -a "x$QNX" != "xyes" && enable_gui=no
1748
1749 AC_MSG_CHECKING(--enable-gui argument)
1750 AC_ARG_ENABLE(gui,
1751  [  --enable-gui[=OPTS]     X11 GUI [default=auto] [OPTS=auto/no/gtk2/gnome2/motif/athena/neXtaw/photon/carbon]], , enable_gui="auto")
1752
1753 dnl Canonicalize the --enable-gui= argument so that it can be easily compared.
1754 dnl Do not use character classes for portability with old tools.
1755 enable_gui_canon=`echo "_$enable_gui" | \
1756         sed 's/[[ _+-]]//g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
1757
1758 dnl Skip everything by default.
1759 SKIP_GTK2=YES
1760 SKIP_GNOME=YES
1761 SKIP_MOTIF=YES
1762 SKIP_ATHENA=YES
1763 SKIP_NEXTAW=YES
1764 SKIP_PHOTON=YES
1765 SKIP_CARBON=YES
1766 GUITYPE=NONE
1767
1768 if test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
1769   SKIP_PHOTON=
1770   case "$enable_gui_canon" in
1771     no)         AC_MSG_RESULT(no GUI support)
1772                 SKIP_PHOTON=YES ;;
1773     yes|"")     AC_MSG_RESULT(yes - automatic GUI support) ;;
1774     auto)       AC_MSG_RESULT(auto - automatic GUI support) ;;
1775     photon)     AC_MSG_RESULT(Photon GUI support) ;;
1776     *)          AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
1777                 SKIP_PHOTON=YES ;;
1778   esac
1779
1780 elif test "x$MACOSX" = "xyes" -a "x$with_x" = "xno" ; then
1781   SKIP_CARBON=
1782   case "$enable_gui_canon" in
1783     no)         AC_MSG_RESULT(no GUI support)
1784                 SKIP_CARBON=YES ;;
1785     yes|"")     AC_MSG_RESULT(yes - automatic GUI support) ;;
1786     auto)       AC_MSG_RESULT(auto - Carbon GUI is outdated - disable GUI support)
1787                 SKIP_CARBON=YES ;;
1788     carbon)     AC_MSG_RESULT(Carbon GUI support) ;;
1789     *)          AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
1790                 SKIP_CARBON=YES ;;
1791   esac
1792
1793 else
1794
1795   case "$enable_gui_canon" in
1796     no|none)    AC_MSG_RESULT(no GUI support) ;;
1797     yes|""|auto)        AC_MSG_RESULT(yes/auto - automatic GUI support)
1798                 SKIP_GTK2=
1799                 SKIP_GNOME=
1800                 SKIP_MOTIF=
1801                 SKIP_ATHENA=
1802                 SKIP_NEXTAW=
1803                 SKIP_CARBON=;;
1804     gtk2)       AC_MSG_RESULT(GTK+ 2.x GUI support)
1805                 SKIP_GTK2=;;
1806     gnome2)     AC_MSG_RESULT(GNOME 2.x GUI support)
1807                 SKIP_GNOME=
1808                 SKIP_GTK2=;;
1809     motif)      AC_MSG_RESULT(Motif GUI support)
1810                 SKIP_MOTIF=;;
1811     athena)     AC_MSG_RESULT(Athena GUI support)
1812                 SKIP_ATHENA=;;
1813     nextaw)     AC_MSG_RESULT(neXtaw GUI support)
1814                 SKIP_NEXTAW=;;
1815     *)          AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
1816   esac
1817
1818 fi
1819
1820 if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \
1821                                 -a "$enable_gui_canon" != "gnome2"; then
1822   AC_MSG_CHECKING(whether or not to look for GTK+ 2)
1823   AC_ARG_ENABLE(gtk2-check,
1824         [  --enable-gtk2-check     If auto-select GUI, check for GTK+ 2 [default=yes]],
1825         , enable_gtk2_check="yes")
1826   AC_MSG_RESULT($enable_gtk2_check)
1827   if test "x$enable_gtk2_check" = "xno"; then
1828     SKIP_GTK2=YES
1829     SKIP_GNOME=YES
1830   fi
1831 fi
1832
1833 if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome2"; then
1834   AC_MSG_CHECKING(whether or not to look for GNOME)
1835   AC_ARG_ENABLE(gnome-check,
1836         [  --enable-gnome-check    If GTK GUI, check for GNOME [default=no]],
1837         , enable_gnome_check="no")
1838   AC_MSG_RESULT($enable_gnome_check)
1839   if test "x$enable_gnome_check" = "xno"; then
1840     SKIP_GNOME=YES
1841   fi
1842 fi
1843
1844 if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then
1845   AC_MSG_CHECKING(whether or not to look for Motif)
1846   AC_ARG_ENABLE(motif-check,
1847         [  --enable-motif-check    If auto-select GUI, check for Motif [default=yes]],
1848         , enable_motif_check="yes")
1849   AC_MSG_RESULT($enable_motif_check)
1850   if test "x$enable_motif_check" = "xno"; then
1851     SKIP_MOTIF=YES
1852   fi
1853 fi
1854
1855 if test "x$SKIP_ATHENA" != "xYES" -a "$enable_gui_canon" != "athena"; then
1856   AC_MSG_CHECKING(whether or not to look for Athena)
1857   AC_ARG_ENABLE(athena-check,
1858         [  --enable-athena-check   If auto-select GUI, check for Athena [default=yes]],
1859         , enable_athena_check="yes")
1860   AC_MSG_RESULT($enable_athena_check)
1861   if test "x$enable_athena_check" = "xno"; then
1862     SKIP_ATHENA=YES
1863   fi
1864 fi
1865
1866 if test "x$SKIP_NEXTAW" != "xYES" -a "$enable_gui_canon" != "nextaw"; then
1867   AC_MSG_CHECKING(whether or not to look for neXtaw)
1868   AC_ARG_ENABLE(nextaw-check,
1869         [  --enable-nextaw-check   If auto-select GUI, check for neXtaw [default=yes]],
1870         , enable_nextaw_check="yes")
1871   AC_MSG_RESULT($enable_nextaw_check);
1872   if test "x$enable_nextaw_check" = "xno"; then
1873     SKIP_NEXTAW=YES
1874   fi
1875 fi
1876
1877 if test "x$SKIP_CARBON" != "xYES" -a "$enable_gui_canon" != "carbon"; then
1878   AC_MSG_CHECKING(whether or not to look for Carbon)
1879   AC_ARG_ENABLE(carbon-check,
1880         [  --enable-carbon-check   If auto-select GUI, check for Carbon [default=yes]],
1881         , enable_carbon_check="yes")
1882   AC_MSG_RESULT($enable_carbon_check);
1883   if test "x$enable_carbon_check" = "xno"; then
1884     SKIP_CARBON=YES
1885   fi
1886 fi
1887
1888
1889 if test "x$MACOSX" = "xyes" -a -z "$SKIP_CARBON" -a "x$CARBON" = "xyes"; then
1890   AC_MSG_CHECKING(for Carbon GUI)
1891   dnl already did the check, just give the message
1892   AC_MSG_RESULT(yes);
1893   GUITYPE=CARBONGUI
1894   if test "$VIMNAME" = "vim"; then
1895     VIMNAME=Vim
1896   fi
1897
1898   if test "x$MACARCH" = "xboth"; then
1899     CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk/Developer/Headers/FlatCarbon"
1900   else
1901     CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/Headers/FlatCarbon"
1902   fi
1903
1904   dnl Default install directory is not /usr/local
1905   if test x$prefix = xNONE; then
1906     prefix=/Applications
1907   fi
1908
1909   dnl Sorry for the hard coded default
1910   datadir='${prefix}/Vim.app/Contents/Resources'
1911
1912   dnl skip everything else
1913   SKIP_GTK2=YES;
1914   SKIP_GNOME=YES;
1915   SKIP_MOTIF=YES;
1916   SKIP_ATHENA=YES;
1917   SKIP_NEXTAW=YES;
1918   SKIP_PHOTON=YES;
1919   SKIP_CARBON=YES
1920 fi
1921
1922 dnl define an autoconf function to check for a specified version of GTK, and
1923 dnl try to compile/link a GTK program.
1924 dnl
1925 dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
1926 dnl Test for GTK, and define GTK_CFLAGS, GTK_LIBDIR and GTK_LIBS
1927 dnl
1928 AC_DEFUN(AM_PATH_GTK,
1929 [
1930   if test "X$GTK_CONFIG" != "Xno" -o "X$PKG_CONFIG" != "Xno"; then
1931   {
1932     min_gtk_version=ifelse([$1], ,2.2.0,$1)
1933     AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
1934     no_gtk=""
1935     if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
1936           && $PKG_CONFIG --exists gtk+-2.0; then
1937     {
1938       dnl We should be using PKG_CHECK_MODULES() instead of this hack.
1939       dnl But I guess the dependency on pkgconfig.m4 is not wanted or
1940       dnl something like that.
1941       GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0`
1942       GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-2.0`
1943       GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0`
1944       gtk_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
1945              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
1946       gtk_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
1947              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
1948       gtk_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
1949              sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
1950     }
1951     else
1952       no_gtk=yes
1953     fi
1954
1955     if test "x$enable_gtktest" = "xyes" -a "x$no_gtk" = "x"; then
1956     {
1957       ac_save_CFLAGS="$CFLAGS"
1958       ac_save_LIBS="$LIBS"
1959       CFLAGS="$CFLAGS $GTK_CFLAGS"
1960       LIBS="$LIBS $GTK_LIBS"
1961
1962       dnl
1963       dnl Now check if the installed GTK is sufficiently new.
1964       dnl
1965       rm -f conf.gtktest
1966       AC_TRY_RUN([
1967 #include <gtk/gtk.h>
1968 #include <stdio.h>
1969 #if STDC_HEADERS
1970 # include <stdlib.h>
1971 # include <stddef.h>
1972 #endif
1973
1974 int
1975 main ()
1976 {
1977 int major, minor, micro;
1978 char *tmp_version;
1979
1980 system ("touch conf.gtktest");
1981
1982 /* HP/UX 9 (%@#!) writes to sscanf strings */
1983 tmp_version = g_strdup("$min_gtk_version");
1984 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
1985    printf("%s, bad version string\n", "$min_gtk_version");
1986    exit(1);
1987  }
1988
1989 if ((gtk_major_version > major) ||
1990     ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
1991     ((gtk_major_version == major) && (gtk_minor_version == minor) &&
1992                                      (gtk_micro_version >= micro)))
1993 {
1994     return 0;
1995 }
1996 return 1;
1997 }
1998 ],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
1999       CFLAGS="$ac_save_CFLAGS"
2000       LIBS="$ac_save_LIBS"
2001     }
2002     fi
2003     if test "x$no_gtk" = x ; then
2004       if test "x$enable_gtktest" = "xyes"; then
2005         AC_MSG_RESULT(yes; found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2006       else
2007         AC_MSG_RESULT(found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2008       fi
2009       ifelse([$2], , :, [$2])
2010     else
2011     {
2012       AC_MSG_RESULT(no)
2013       GTK_CFLAGS=""
2014       GTK_LIBS=""
2015       ifelse([$3], , :, [$3])
2016     }
2017     fi
2018   }
2019   else
2020     GTK_CFLAGS=""
2021     GTK_LIBS=""
2022     ifelse([$3], , :, [$3])
2023   fi
2024   AC_SUBST(GTK_CFLAGS)
2025   AC_SUBST(GTK_LIBS)
2026   rm -f conf.gtktest
2027 ])
2028
2029 dnl ---------------------------------------------------------------------------
2030 dnl gnome
2031 dnl ---------------------------------------------------------------------------
2032 AC_DEFUN([GNOME_INIT_HOOK],
2033 [
2034   AC_SUBST(GNOME_LIBS)
2035   AC_SUBST(GNOME_LIBDIR)
2036   AC_SUBST(GNOME_INCLUDEDIR)
2037
2038   AC_ARG_WITH(gnome-includes,
2039     [  --with-gnome-includes=DIR Specify location of GNOME headers],
2040     [CFLAGS="$CFLAGS -I$withval"]
2041   )
2042
2043   AC_ARG_WITH(gnome-libs,
2044     [  --with-gnome-libs=DIR   Specify location of GNOME libs],
2045     [LDFLAGS="$LDFLAGS -L$withval" gnome_prefix=$withval]
2046   )
2047
2048   AC_ARG_WITH(gnome,
2049     [  --with-gnome            Specify prefix for GNOME files],
2050     if test x$withval = xyes; then
2051       want_gnome=yes
2052       ifelse([$1], [], :, [$1])
2053     else
2054       if test "x$withval" = xno; then
2055         want_gnome=no
2056       else
2057         want_gnome=yes
2058         LDFLAGS="$LDFLAGS -L$withval/lib"
2059         CFLAGS="$CFLAGS -I$withval/include"
2060         gnome_prefix=$withval/lib
2061       fi
2062     fi,
2063     want_gnome=yes)
2064
2065   if test "x$want_gnome" = xyes; then
2066   {
2067     AC_MSG_CHECKING(for libgnomeui-2.0)
2068     if $PKG_CONFIG --exists libgnomeui-2.0; then
2069       AC_MSG_RESULT(yes)
2070       GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0`
2071       GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0`
2072       GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0`
2073
2074       dnl On FreeBSD we need -pthread but pkg-config doesn't include it.
2075       dnl This might not be the right way but it works for me...
2076       AC_MSG_CHECKING(for FreeBSD)
2077       if test "`(uname) 2>/dev/null`" = FreeBSD; then
2078         AC_MSG_RESULT(yes, adding -pthread)
2079         GNOME_INCLUDEDIR="$GNOME_INCLUDEDIR -D_THREAD_SAFE"
2080         GNOME_LIBS="$GNOME_LIBS -pthread"
2081       else
2082         AC_MSG_RESULT(no)
2083       fi
2084       $1
2085     else
2086       AC_MSG_RESULT(not found)
2087       if test "x$2" = xfail; then
2088         AC_MSG_ERROR(Could not find libgnomeui-2.0 via pkg-config)
2089       fi
2090     fi
2091   }
2092   fi
2093 ])
2094
2095 AC_DEFUN([GNOME_INIT],[
2096         GNOME_INIT_HOOK([],fail)
2097 ])
2098
2099
2100 dnl ---------------------------------------------------------------------------
2101 dnl Check for GTK2.  If it fails, then continue on for Motif as before...
2102 dnl ---------------------------------------------------------------------------
2103 if test -z "$SKIP_GTK2"; then
2104
2105   AC_MSG_CHECKING(--disable-gtktest argument)
2106   AC_ARG_ENABLE(gtktest, [  --disable-gtktest       Do not try to compile and run a test GTK program],
2107         , enable_gtktest=yes)
2108   if test "x$enable_gtktest" = "xyes" ; then
2109     AC_MSG_RESULT(gtk test enabled)
2110   else
2111     AC_MSG_RESULT(gtk test disabled)
2112   fi
2113
2114   if test "X$PKG_CONFIG" = "X"; then
2115     AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
2116   fi
2117
2118   if test "x$PKG_CONFIG" != "xno"; then
2119     dnl First try finding version 2.2.0 or later.  The 2.0.x series has
2120     dnl problems (bold fonts, --remote doesn't work).
2121     AM_PATH_GTK(2.2.0,
2122                 [GUI_LIB_LOC="$GTK_LIBDIR"
2123                  GTK_LIBNAME="$GTK_LIBS"
2124                 GUI_INC_LOC="$GTK_CFLAGS"], )
2125     if test "x$GTK_CFLAGS" != "x"; then
2126       SKIP_ATHENA=YES
2127       SKIP_NEXTAW=YES
2128       SKIP_MOTIF=YES
2129       GUITYPE=GTK
2130       AC_SUBST(GTK_LIBNAME)
2131     fi
2132   fi
2133   if test "x$GUITYPE" = "xGTK"; then
2134     if test "$gtk_minor_version" = 1 -a "0$gtk_micro_version" -ge 1 \
2135         || test "0$gtk_minor_version" -ge 2; then
2136       AC_DEFINE(HAVE_GTK_MULTIHEAD)
2137     fi
2138     dnl
2139     dnl if GTK exists, then check for GNOME.
2140     dnl
2141     if test -z "$SKIP_GNOME"; then
2142     {
2143       GNOME_INIT_HOOK([have_gnome=yes])
2144       if test "x$have_gnome" = xyes ; then
2145         AC_DEFINE(FEAT_GUI_GNOME)
2146         GUI_INC_LOC="$GUI_INC_LOC $GNOME_INCLUDEDIR"
2147         GTK_LIBNAME="$GTK_LIBNAME $GNOME_LIBDIR $GNOME_LIBS"
2148       fi
2149     }
2150     fi
2151   fi
2152 fi
2153
2154 dnl Check for Motif include files location.
2155 dnl The LAST one found is used, this makes the highest version to be used,
2156 dnl e.g. when Motif1.2 and Motif2.0 are both present.
2157
2158 if test -z "$SKIP_MOTIF"; then
2159   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"
2160   dnl Remove "-I" from before $GUI_INC_LOC if it's there
2161   GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`"
2162
2163   AC_MSG_CHECKING(for location of Motif GUI includes)
2164   gui_includes="`echo $x_includes|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC"
2165   GUI_INC_LOC=
2166   for try in $gui_includes; do
2167     if test -f "$try/Xm/Xm.h"; then
2168       GUI_INC_LOC=$try
2169     fi
2170   done
2171   if test -n "$GUI_INC_LOC"; then
2172     if test "$GUI_INC_LOC" = /usr/include; then
2173       GUI_INC_LOC=
2174       AC_MSG_RESULT(in default path)
2175     else
2176       AC_MSG_RESULT($GUI_INC_LOC)
2177     fi
2178   else
2179     AC_MSG_RESULT(<not found>)
2180     SKIP_MOTIF=YES
2181   fi
2182 fi
2183
2184 dnl Check for Motif library files location.  In the same order as the include
2185 dnl files, to avoid a mixup if several versions are present
2186
2187 if test -z "$SKIP_MOTIF"; then
2188   AC_MSG_CHECKING(--with-motif-lib argument)
2189   AC_ARG_WITH(motif-lib,
2190   [  --with-motif-lib=STRING   Library for Motif ],
2191   [ MOTIF_LIBNAME="${withval}" ] )
2192
2193   if test -n "$MOTIF_LIBNAME"; then
2194     AC_MSG_RESULT($MOTIF_LIBNAME)
2195     GUI_LIB_LOC=
2196   else
2197     AC_MSG_RESULT(no)
2198
2199     dnl Remove "-L" from before $GUI_LIB_LOC if it's there
2200     GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
2201
2202     AC_MSG_CHECKING(for location of Motif GUI libs)
2203     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"
2204     GUI_LIB_LOC=
2205     for try in $gui_libs; do
2206       for libtry in "$try"/libXm.a "$try"/libXm.so* "$try"/libXm.sl "$try"/libXm.dylib; do
2207         if test -f "$libtry"; then
2208           GUI_LIB_LOC=$try
2209         fi
2210       done
2211     done
2212     if test -n "$GUI_LIB_LOC"; then
2213       dnl Remove /usr/lib, it causes trouble on some systems
2214       if test "$GUI_LIB_LOC" = /usr/lib; then
2215         GUI_LIB_LOC=
2216         AC_MSG_RESULT(in default path)
2217       else
2218         if test -n "$GUI_LIB_LOC"; then
2219           AC_MSG_RESULT($GUI_LIB_LOC)
2220           if test "`(uname) 2>/dev/null`" = SunOS &&
2221                                          uname -r | grep '^5' >/dev/null; then
2222             GUI_LIB_LOC="$GUI_LIB_LOC -R $GUI_LIB_LOC"
2223           fi
2224         fi
2225       fi
2226       MOTIF_LIBNAME=-lXm
2227     else
2228       AC_MSG_RESULT(<not found>)
2229       SKIP_MOTIF=YES
2230     fi
2231   fi
2232 fi
2233
2234 if test -z "$SKIP_MOTIF"; then
2235   SKIP_ATHENA=YES
2236   SKIP_NEXTAW=YES
2237   GUITYPE=MOTIF
2238   AC_SUBST(MOTIF_LIBNAME)
2239 fi
2240
2241 dnl Check if the Athena files can be found
2242
2243 GUI_X_LIBS=
2244
2245 if test -z "$SKIP_ATHENA"; then
2246   AC_MSG_CHECKING(if Athena header files can be found)
2247   cflags_save=$CFLAGS
2248   CFLAGS="$CFLAGS $X_CFLAGS"
2249   AC_TRY_COMPILE([
2250 #include <X11/Intrinsic.h>
2251 #include <X11/Xaw/Paned.h>], ,
2252         AC_MSG_RESULT(yes),
2253         AC_MSG_RESULT(no); SKIP_ATHENA=YES )
2254   CFLAGS=$cflags_save
2255 fi
2256
2257 if test -z "$SKIP_ATHENA"; then
2258   GUITYPE=ATHENA
2259 fi
2260
2261 if test -z "$SKIP_NEXTAW"; then
2262   AC_MSG_CHECKING(if neXtaw header files can be found)
2263   cflags_save=$CFLAGS
2264   CFLAGS="$CFLAGS $X_CFLAGS"
2265   AC_TRY_COMPILE([
2266 #include <X11/Intrinsic.h>
2267 #include <X11/neXtaw/Paned.h>], ,
2268         AC_MSG_RESULT(yes),
2269         AC_MSG_RESULT(no); SKIP_NEXTAW=YES )
2270   CFLAGS=$cflags_save
2271 fi
2272
2273 if test -z "$SKIP_NEXTAW"; then
2274   GUITYPE=NEXTAW
2275 fi
2276
2277 if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
2278   dnl Prepend -I and -L to $GUI_INC_LOC and $GUI_LIB_LOC if not empty
2279   dnl Avoid adding it when it twice
2280   if test -n "$GUI_INC_LOC"; then
2281     GUI_INC_LOC=-I"`echo $GUI_INC_LOC|sed 's%-I%%'`"
2282   fi
2283   if test -n "$GUI_LIB_LOC"; then
2284     GUI_LIB_LOC=-L"`echo $GUI_LIB_LOC|sed 's%-L%%'`"
2285   fi
2286
2287   dnl Check for -lXext and then for -lXmu
2288   ldflags_save=$LDFLAGS
2289   LDFLAGS="$X_LIBS $LDFLAGS"
2290   AC_CHECK_LIB(Xext, XShapeQueryExtension, [GUI_X_LIBS="-lXext"],,
2291                 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2292   dnl For Solaris we need -lw and -ldl before linking with -lXmu works.
2293   AC_CHECK_LIB(w, wslen, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lw"],,
2294                 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2295   AC_CHECK_LIB(dl, dlsym, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldl"],,
2296                 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2297   AC_CHECK_LIB(Xmu, XmuCreateStippledPixmap, [GUI_X_LIBS="-lXmu $GUI_X_LIBS"],,
2298                 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2299   if test -z "$SKIP_MOTIF"; then
2300     AC_CHECK_LIB(Xp, XpEndJob, [GUI_X_LIBS="-lXp $GUI_X_LIBS"],,
2301                 [$GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2302   fi
2303   LDFLAGS=$ldflags_save
2304
2305   dnl Execute xmkmf to figure out if -DNARROWPROTO is needed.
2306   AC_MSG_CHECKING(for extra X11 defines)
2307   NARROW_PROTO=
2308   rm -fr conftestdir
2309   if mkdir conftestdir; then
2310     cd conftestdir
2311     cat > Imakefile <<'EOF'
2312 acfindx:
2313         @echo 'NARROW_PROTO="${PROTO_DEFINES}"'
2314 EOF
2315     if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
2316       eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
2317     fi
2318     cd ..
2319     rm -fr conftestdir
2320   fi
2321   if test -z "$NARROW_PROTO"; then
2322     AC_MSG_RESULT(no)
2323   else
2324     AC_MSG_RESULT($NARROW_PROTO)
2325   fi
2326   AC_SUBST(NARROW_PROTO)
2327 fi
2328
2329 dnl Look for XSMP support - but don't necessarily restrict it to X11 GUIs
2330 dnl use the X11 include path
2331 if test "$enable_xsmp" = "yes"; then
2332   cppflags_save=$CPPFLAGS
2333   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2334   AC_CHECK_HEADERS(X11/SM/SMlib.h)
2335   CPPFLAGS=$cppflags_save
2336 fi
2337
2338
2339 if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF" -o -z "$SKIP_GTK2"; then
2340   dnl Check for X11/xpm.h and X11/Sunkeysym.h with the GUI include path
2341   cppflags_save=$CPPFLAGS
2342   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2343   AC_CHECK_HEADERS(X11/xpm.h X11/Sunkeysym.h)
2344
2345   dnl automatically disable XIM when XIMtext isn't in X11/Xlib.h
2346   if test ! "$enable_xim" = "no"; then
2347     AC_MSG_CHECKING(for XIMText in X11/Xlib.h)
2348     AC_EGREP_CPP(XIMText, [#include <X11/Xlib.h>],
2349                   AC_MSG_RESULT(yes),
2350                   AC_MSG_RESULT(no; xim has been disabled); enable_xim = "no")
2351   fi
2352   CPPFLAGS=$cppflags_save
2353
2354   dnl automatically enable XIM when hangul input isn't enabled
2355   if test "$enable_xim" = "auto" -a "$enable_hangulinput" != "yes" \
2356                 -a "x$GUITYPE" != "xNONE" ; then
2357     AC_MSG_RESULT(X GUI selected; xim has been enabled)
2358     enable_xim="yes"
2359   fi
2360 fi
2361
2362 if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
2363   cppflags_save=$CPPFLAGS
2364   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2365 dnl Xmu/Editres.h may exist but can only be used after including Intrinsic.h
2366   AC_MSG_CHECKING([for X11/Xmu/Editres.h])
2367   AC_TRY_COMPILE([
2368 #include <X11/Intrinsic.h>
2369 #include <X11/Xmu/Editres.h>],
2370                       [int i; i = 0;],
2371               AC_MSG_RESULT(yes)
2372                       AC_DEFINE(HAVE_X11_XMU_EDITRES_H),
2373               AC_MSG_RESULT(no))
2374   CPPFLAGS=$cppflags_save
2375 fi
2376
2377 dnl Only use the Xm directory when compiling Motif, don't use it for Athena
2378 if test -z "$SKIP_MOTIF"; then
2379   cppflags_save=$CPPFLAGS
2380   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2381   AC_CHECK_HEADERS(Xm/Xm.h Xm/XpmP.h Xm/JoinSideT.h Xm/TraitP.h Xm/Manager.h \
2382                    Xm/UnhighlightT.h Xm/Notebook.h)
2383
2384   if test $ac_cv_header_Xm_XpmP_h = yes; then
2385     dnl Solaris uses XpmAttributes_21, very annoying.
2386     AC_MSG_CHECKING([for XpmAttributes_21 in Xm/XpmP.h])
2387     AC_TRY_COMPILE([#include <Xm/XpmP.h>], [XpmAttributes_21 attr;],
2388         AC_MSG_RESULT(yes); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes_21),
2389         AC_MSG_RESULT(no); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
2390         )
2391   else
2392     AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
2393   fi
2394   CPPFLAGS=$cppflags_save
2395 fi
2396
2397 if test "x$GUITYPE" = "xNONE" -a "$enable_xim" = "yes"; then
2398   AC_MSG_RESULT(no GUI selected; xim has been disabled)
2399   enable_xim="no"
2400 fi
2401 if test "x$GUITYPE" = "xNONE" -a "$enable_fontset" = "yes"; then
2402   AC_MSG_RESULT(no GUI selected; fontset has been disabled)
2403   enable_fontset="no"
2404 fi
2405 if test "x$GUITYPE:$enable_fontset" = "xGTK:yes"; then
2406   AC_MSG_RESULT(GTK+ 2 GUI selected; fontset has been disabled)
2407   enable_fontset="no"
2408 fi
2409
2410 if test -z "$SKIP_PHOTON"; then
2411   GUITYPE=PHOTONGUI
2412 fi
2413
2414 AC_SUBST(GUI_INC_LOC)
2415 AC_SUBST(GUI_LIB_LOC)
2416 AC_SUBST(GUITYPE)
2417 AC_SUBST(GUI_X_LIBS)
2418
2419 if test "$enable_workshop" = "yes" -a -n "$SKIP_MOTIF"; then
2420   AC_MSG_ERROR([cannot use workshop without Motif])
2421 fi
2422
2423 dnl defining FEAT_XIM and FEAT_XFONTSET is delayed, so that they can be disabled
2424 if test "$enable_xim" = "yes"; then
2425   AC_DEFINE(FEAT_XIM)
2426 fi
2427 if test "$enable_fontset" = "yes"; then
2428   AC_DEFINE(FEAT_XFONTSET)
2429 fi
2430
2431
2432 dnl ---------------------------------------------------------------------------
2433 dnl end of GUI-checking
2434 dnl ---------------------------------------------------------------------------
2435
2436
2437 dnl Only really enable hangul input when GUI and XFONTSET are available
2438 if test "$enable_hangulinput" = "yes"; then
2439   if test "x$GUITYPE" = "xNONE"; then
2440     AC_MSG_RESULT(no GUI selected; hangul input has been disabled)
2441     enable_hangulinput=no
2442   else
2443     AC_DEFINE(FEAT_HANGULIN)
2444     HANGULIN_SRC=hangulin.c
2445     AC_SUBST(HANGULIN_SRC)
2446     HANGULIN_OBJ=objects/hangulin.o
2447     AC_SUBST(HANGULIN_OBJ)
2448   fi
2449 fi
2450
2451 dnl Checks for libraries and include files.
2452
2453 AC_CACHE_CHECK([whether toupper is broken], [vim_cv_toupper_broken],
2454   [
2455     AC_RUN_IFELSE([[
2456 #include "confdefs.h"
2457 #include <ctype.h>
2458 #if STDC_HEADERS
2459 # include <stdlib.h>
2460 # include <stddef.h>
2461 #endif
2462 main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); }
2463   ]],[
2464     vim_cv_toupper_broken=yes
2465   ],[
2466     vim_cv_toupper_broken=no
2467   ],[
2468     AC_MSG_ERROR(cross-compiling: please set 'vim_cv_toupper_broken')
2469   ])])
2470
2471 if test "x$vim_cv_toupper_broken" = "xyes" ; then
2472   AC_DEFINE(BROKEN_TOUPPER)
2473 fi
2474
2475 AC_MSG_CHECKING(whether __DATE__ and __TIME__ work)
2476 AC_TRY_COMPILE([#include <stdio.h>], [printf("(" __DATE__ " " __TIME__ ")");],
2477         AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DATE_TIME),
2478         AC_MSG_RESULT(no))
2479
2480 AC_MSG_CHECKING(whether __attribute__((unused)) is allowed)
2481 AC_TRY_COMPILE([#include <stdio.h>], [int x __attribute__((unused));],
2482         AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ATTRIBUTE_UNUSED),
2483         AC_MSG_RESULT(no))
2484
2485 dnl Checks for header files.
2486 AC_CHECK_HEADER(elf.h, HAS_ELF=1)
2487 dnl AC_CHECK_HEADER(dwarf.h, SVR4=1)
2488 if test "$HAS_ELF" = 1; then
2489   AC_CHECK_LIB(elf, main)
2490 fi
2491
2492 AC_HEADER_DIRENT
2493
2494 dnl If sys/wait.h is not found it might still exist but not be POSIX
2495 dnl compliant. In that case we define HAVE_UNION_WAIT (for NeXT)
2496 if test $ac_cv_header_sys_wait_h = no; then
2497   AC_MSG_CHECKING([for sys/wait.h that defines union wait])
2498   AC_TRY_COMPILE([#include <sys/wait.h>],
2499                         [union wait xx, yy; xx = yy],
2500                 AC_MSG_RESULT(yes)
2501                         AC_DEFINE(HAVE_SYS_WAIT_H)
2502                         AC_DEFINE(HAVE_UNION_WAIT),
2503                 AC_MSG_RESULT(no))
2504 fi
2505
2506 AC_CHECK_HEADERS(stdarg.h stdint.h stdlib.h string.h \
2507         sys/select.h sys/utsname.h termcap.h fcntl.h \
2508         sgtty.h sys/ioctl.h sys/time.h sys/types.h \
2509         termio.h iconv.h inttypes.h langinfo.h math.h \
2510         unistd.h stropts.h errno.h sys/resource.h \
2511         sys/systeminfo.h locale.h sys/stream.h termios.h \
2512         libc.h sys/statfs.h poll.h sys/poll.h pwd.h \
2513         utime.h sys/param.h libintl.h libgen.h \
2514         util/debug.h util/msg18n.h frame.h sys/acl.h \
2515         sys/access.h sys/sysinfo.h wchar.h wctype.h)
2516
2517 dnl sys/ptem.h depends on sys/stream.h on Solaris
2518 AC_CHECK_HEADERS(sys/ptem.h, [], [],
2519 [#if defined HAVE_SYS_STREAM_H
2520 #  include <sys/stream.h>
2521 #endif])
2522
2523 dnl sys/sysctl.h depends on sys/param.h on OpenBSD
2524 AC_CHECK_HEADERS(sys/sysctl.h, [], [],
2525 [#if defined HAVE_SYS_PARAM_H
2526 #  include <sys/param.h>
2527 #endif])
2528
2529
2530 dnl pthread_np.h may exist but can only be used after including pthread.h
2531 AC_MSG_CHECKING([for pthread_np.h])
2532 AC_TRY_COMPILE([
2533 #include <pthread.h>
2534 #include <pthread_np.h>],
2535                       [int i; i = 0;],
2536               AC_MSG_RESULT(yes)
2537                       AC_DEFINE(HAVE_PTHREAD_NP_H),
2538               AC_MSG_RESULT(no))
2539
2540 AC_CHECK_HEADERS(strings.h)
2541 if test "x$MACOSX" = "xyes"; then
2542   dnl The strings.h file on OS/X contains a warning and nothing useful.
2543   AC_DEFINE(NO_STRINGS_WITH_STRING_H)
2544 else
2545
2546 dnl Check if strings.h and string.h can both be included when defined.
2547 AC_MSG_CHECKING([if strings.h can be included after string.h])
2548 cppflags_save=$CPPFLAGS
2549 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2550 AC_TRY_COMPILE([
2551 #if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO)
2552 # define _NO_PROTO      /* like in os_unix.h, causes conflict for AIX (Winn) */
2553                         /* but don't do it on AIX 5.1 (Uribarri) */
2554 #endif
2555 #ifdef HAVE_XM_XM_H
2556 # include <Xm/Xm.h>     /* This breaks it for HP-UX 11 (Squassabia) */
2557 #endif
2558 #ifdef HAVE_STRING_H
2559 # include <string.h>
2560 #endif
2561 #if defined(HAVE_STRINGS_H)
2562 # include <strings.h>
2563 #endif
2564                 ], [int i; i = 0;],
2565                 AC_MSG_RESULT(yes),
2566                 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
2567                 AC_MSG_RESULT(no))
2568 CPPFLAGS=$cppflags_save
2569 fi
2570
2571 dnl Checks for typedefs, structures, and compiler characteristics.
2572 AC_PROG_GCC_TRADITIONAL
2573 AC_C_CONST
2574 AC_C_VOLATILE
2575 AC_TYPE_MODE_T
2576 AC_TYPE_OFF_T
2577 AC_TYPE_PID_T
2578 AC_TYPE_SIZE_T
2579 AC_TYPE_UID_T
2580 AC_TYPE_UINT32_T
2581
2582 AC_HEADER_TIME
2583 AC_CHECK_TYPE(ino_t, long)
2584 AC_CHECK_TYPE(dev_t, unsigned)
2585 AC_C_BIGENDIAN(,,,)
2586
2587 AC_MSG_CHECKING(for rlim_t)
2588 if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
2589   AC_MSG_RESULT([(cached) $ac_cv_type_rlim_t])
2590 else
2591   AC_EGREP_CPP(dnl
2592 changequote(<<,>>)dnl
2593 <<(^|[^a-zA-Z_0-9])rlim_t[^a-zA-Z_0-9]>>dnl
2594 changequote([,]),
2595   [
2596 #include <sys/types.h>
2597 #if STDC_HEADERS
2598 # include <stdlib.h>
2599 # include <stddef.h>
2600 #endif
2601 #ifdef HAVE_SYS_RESOURCE_H
2602 # include <sys/resource.h>
2603 #endif
2604           ], ac_cv_type_rlim_t=yes, ac_cv_type_rlim_t=no)
2605           AC_MSG_RESULT($ac_cv_type_rlim_t)
2606 fi
2607 if test $ac_cv_type_rlim_t = no; then
2608   cat >> confdefs.h <<\EOF
2609 #define rlim_t unsigned long
2610 EOF
2611 fi
2612
2613 AC_MSG_CHECKING(for stack_t)
2614 if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then
2615   AC_MSG_RESULT([(cached) $ac_cv_type_stack_t])
2616 else
2617   AC_EGREP_CPP(stack_t,
2618   [
2619 #include <sys/types.h>
2620 #if STDC_HEADERS
2621 # include <stdlib.h>
2622 # include <stddef.h>
2623 #endif
2624 #include <signal.h>
2625           ], ac_cv_type_stack_t=yes, ac_cv_type_stack_t=no)
2626           AC_MSG_RESULT($ac_cv_type_stack_t)
2627 fi
2628 if test $ac_cv_type_stack_t = no; then
2629   cat >> confdefs.h <<\EOF
2630 #define stack_t struct sigaltstack
2631 EOF
2632 fi
2633
2634 dnl BSDI uses ss_base while others use ss_sp for the stack pointer.
2635 AC_MSG_CHECKING(whether stack_t has an ss_base field)
2636 AC_TRY_COMPILE([
2637 #include <sys/types.h>
2638 #if STDC_HEADERS
2639 # include <stdlib.h>
2640 # include <stddef.h>
2641 #endif
2642 #include <signal.h>
2643 #include "confdefs.h"
2644                         ], [stack_t sigstk; sigstk.ss_base = 0; ],
2645         AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SS_BASE),
2646         AC_MSG_RESULT(no))
2647
2648 olibs="$LIBS"
2649 AC_MSG_CHECKING(--with-tlib argument)
2650 AC_ARG_WITH(tlib, [  --with-tlib=library     terminal library to be used ],)
2651 if test -n "$with_tlib"; then
2652   AC_MSG_RESULT($with_tlib)
2653   LIBS="$LIBS -l$with_tlib"
2654   AC_MSG_CHECKING(for linking with $with_tlib library)
2655   AC_TRY_LINK([], [], AC_MSG_RESULT(OK), AC_MSG_ERROR(FAILED))
2656   dnl Need to check for tgetent() below.
2657   olibs="$LIBS"
2658 else
2659   AC_MSG_RESULT([empty: automatic terminal library selection])
2660   dnl  On HP-UX 10.10 termcap or termlib should be used instead of
2661   dnl  curses, because curses is much slower.
2662   dnl  Newer versions of ncurses are preferred over anything, except
2663   dnl  when tinfo has been split off, it contains all we need.
2664   dnl  Older versions of ncurses have bugs, get a new one!
2665   dnl  Digital Unix (OSF1) should use curses (Ronald Schild).
2666   dnl  On SCO Openserver should prefer termlib (Roger Cornelius).
2667   case "`uname -s 2>/dev/null`" in
2668         OSF1|SCO_SV)    tlibs="tinfo ncurses curses termlib termcap";;
2669         *)      tlibs="tinfo ncurses termlib termcap curses";;
2670   esac
2671   for libname in $tlibs; do
2672     AC_CHECK_LIB(${libname}, tgetent,,)
2673     if test "x$olibs" != "x$LIBS"; then
2674       dnl It's possible that a library is found but it doesn't work
2675       dnl e.g., shared library that cannot be found
2676       dnl compile and run a test program to be sure
2677       AC_TRY_RUN([
2678 #ifdef HAVE_TERMCAP_H
2679 # include <termcap.h>
2680 #endif
2681 #if STDC_HEADERS
2682 # include <stdlib.h>
2683 # include <stddef.h>
2684 #endif
2685 main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }],
2686                           res="OK", res="FAIL", res="FAIL")
2687       if test "$res" = "OK"; then
2688         break
2689       fi
2690       AC_MSG_RESULT($libname library is not usable)
2691       LIBS="$olibs"
2692     fi
2693   done
2694   if test "x$olibs" = "x$LIBS"; then
2695     AC_MSG_RESULT(no terminal library found)
2696   fi
2697 fi
2698
2699 if test "x$olibs" = "x$LIBS"; then
2700   AC_MSG_CHECKING([for tgetent()])
2701   AC_TRY_LINK([],
2702       [char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");],
2703         AC_MSG_RESULT(yes),
2704         AC_MSG_ERROR([NOT FOUND!
2705       You need to install a terminal library; for example ncurses.
2706       Or specify the name of the library with --with-tlib.]))
2707 fi
2708
2709 AC_CACHE_CHECK([whether we talk terminfo], [vim_cv_terminfo],
2710   [
2711     AC_RUN_IFELSE([[
2712 #include "confdefs.h"
2713 #ifdef HAVE_TERMCAP_H
2714 # include <termcap.h>
2715 #endif
2716 #ifdef HAVE_STRING_H
2717 # include <string.h>
2718 #endif
2719 #if STDC_HEADERS
2720 # include <stdlib.h>
2721 # include <stddef.h>
2722 #endif
2723 main()
2724 {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }
2725     ]],[
2726       vim_cv_terminfo=no
2727     ],[
2728       vim_cv_terminfo=yes
2729     ],[
2730       AC_MSG_ERROR(cross-compiling: please set 'vim_cv_terminfo')
2731     ])
2732   ])
2733
2734 if test "x$vim_cv_terminfo" = "xyes" ; then
2735   AC_DEFINE(TERMINFO)
2736 fi
2737
2738 if test "x$olibs" != "x$LIBS"; then
2739   AC_CACHE_CHECK([what tgetent() returns for an unknown terminal], [vim_cv_tgent],
2740     [
2741       AC_RUN_IFELSE([[
2742 #include "confdefs.h"
2743 #ifdef HAVE_TERMCAP_H
2744 # include <termcap.h>
2745 #endif
2746 #if STDC_HEADERS
2747 # include <stdlib.h>
2748 # include <stddef.h>
2749 #endif
2750 main()
2751 {char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
2752       ]],[
2753         vim_cv_tgent=zero
2754       ],[
2755         vim_cv_tgent=non-zero
2756       ],[
2757         AC_MSG_ERROR(failed to compile test program.)
2758       ])
2759     ])
2760   
2761   if test "x$vim_cv_tgent" = "xzero" ; then
2762     AC_DEFINE(TGETENT_ZERO_ERR, 0)
2763   fi
2764 fi
2765
2766 AC_MSG_CHECKING(whether termcap.h contains ospeed)
2767 AC_TRY_LINK([
2768 #ifdef HAVE_TERMCAP_H
2769 # include <termcap.h>
2770 #endif
2771                         ], [ospeed = 20000],
2772         AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED),
2773         [AC_MSG_RESULT(no)
2774         AC_MSG_CHECKING(whether ospeed can be extern)
2775         AC_TRY_LINK([
2776 #ifdef HAVE_TERMCAP_H
2777 # include <termcap.h>
2778 #endif
2779 extern short ospeed;
2780                         ], [ospeed = 20000],
2781                 AC_MSG_RESULT(yes); AC_DEFINE(OSPEED_EXTERN),
2782                 AC_MSG_RESULT(no))]
2783         )
2784
2785 AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC])
2786 AC_TRY_LINK([
2787 #ifdef HAVE_TERMCAP_H
2788 # include <termcap.h>
2789 #endif
2790                         ], [if (UP == 0 && BC == 0) PC = 1],
2791         AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UP_BC_PC),
2792         [AC_MSG_RESULT(no)
2793         AC_MSG_CHECKING([whether UP, BC and PC can be extern])
2794         AC_TRY_LINK([
2795 #ifdef HAVE_TERMCAP_H
2796 # include <termcap.h>
2797 #endif
2798 extern char *UP, *BC, PC;
2799                         ], [if (UP == 0 && BC == 0) PC = 1],
2800                 AC_MSG_RESULT(yes); AC_DEFINE(UP_BC_PC_EXTERN),
2801                 AC_MSG_RESULT(no))]
2802         )
2803
2804 AC_MSG_CHECKING(whether tputs() uses outfuntype)
2805 AC_TRY_COMPILE([
2806 #ifdef HAVE_TERMCAP_H
2807 # include <termcap.h>
2808 #endif
2809                         ], [extern int xx(); tputs("test", 1, (outfuntype)xx)],
2810         AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OUTFUNTYPE),
2811         AC_MSG_RESULT(no))
2812
2813 dnl On some SCO machines sys/select redefines struct timeval
2814 AC_MSG_CHECKING([whether sys/select.h and sys/time.h may both be included])
2815 AC_TRY_COMPILE([
2816 #include <sys/types.h>
2817 #include <sys/time.h>
2818 #include <sys/select.h>], ,
2819           AC_MSG_RESULT(yes)
2820                         AC_DEFINE(SYS_SELECT_WITH_SYS_TIME),
2821           AC_MSG_RESULT(no))
2822
2823 dnl AC_DECL_SYS_SIGLIST
2824
2825 dnl Checks for pty.c (copied from screen) ==========================
2826 AC_MSG_CHECKING(for /dev/ptc)
2827 if test -r /dev/ptc; then
2828   AC_DEFINE(HAVE_DEV_PTC)
2829   AC_MSG_RESULT(yes)
2830 else
2831   AC_MSG_RESULT(no)
2832 fi
2833
2834 AC_MSG_CHECKING(for SVR4 ptys)
2835 if test -c /dev/ptmx ; then
2836   AC_TRY_LINK([], [ptsname(0);grantpt(0);unlockpt(0);],
2837         AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SVR4_PTYS),
2838         AC_MSG_RESULT(no))
2839 else
2840   AC_MSG_RESULT(no)
2841 fi
2842
2843 AC_MSG_CHECKING(for ptyranges)
2844 if test -d /dev/ptym ; then
2845   pdir='/dev/ptym'
2846 else
2847   pdir='/dev'
2848 fi
2849 dnl SCO uses ptyp%d
2850 AC_EGREP_CPP(yes,
2851 [#ifdef M_UNIX
2852    yes;
2853 #endif
2854         ], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
2855 dnl if test -c /dev/ptyp19; then
2856 dnl ptys=`echo /dev/ptyp??`
2857 dnl else
2858 dnl ptys=`echo $pdir/pty??`
2859 dnl fi
2860 if test "$ptys" != "$pdir/pty??" ; then
2861   p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
2862   p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g'  | sort -u | tr -d '\012'`
2863   AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
2864   AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
2865   AC_MSG_RESULT([$p0 / $p1])
2866 else
2867   AC_MSG_RESULT([don't know])
2868 fi
2869
2870 dnl    ****  pty mode/group handling ****
2871 dnl
2872 dnl support provided by Luke Mewburn <lm@rmit.edu.au>, 931222
2873 rm -f conftest_grp
2874 AC_CACHE_CHECK([default tty permissions/group], [vim_cv_tty_group],
2875   [
2876     AC_RUN_IFELSE([[
2877 #include "confdefs.h"
2878 #include <sys/types.h>
2879 #if STDC_HEADERS
2880 # include <stdlib.h>
2881 # include <stddef.h>
2882 #endif
2883 #ifdef HAVE_UNISTD_H
2884 #include <unistd.h>
2885 #endif
2886 #include <sys/stat.h>
2887 #include <stdio.h>
2888 main()
2889 {
2890   struct stat sb;
2891   char *x,*ttyname();
2892   int om, m;
2893   FILE *fp;
2894
2895   if (!(x = ttyname(0))) exit(1);
2896   if (stat(x, &sb)) exit(1);
2897   om = sb.st_mode;
2898   if (om & 002) exit(0);
2899   m = system("mesg y");
2900   if (m == -1 || m == 127) exit(1);
2901   if (stat(x, &sb)) exit(1);
2902   m = sb.st_mode;
2903   if (chmod(x, om)) exit(1);
2904   if (m & 002) exit(0);
2905   if (sb.st_gid == getgid()) exit(1);
2906   if (!(fp=fopen("conftest_grp", "w")))
2907     exit(1);
2908   fprintf(fp, "%d\n", sb.st_gid);
2909   fclose(fp);
2910   exit(0);
2911 }
2912     ]],[
2913       if test -f conftest_grp; then
2914         vim_cv_tty_group=`cat conftest_grp`
2915         if test "x$vim_cv_tty_mode" = "x" ; then
2916           vim_cv_tty_mode=0620
2917         fi
2918         AC_MSG_RESULT([pty mode: $vim_cv_tty_mode, group: $vim_cv_tty_group])
2919       else
2920         vim_cv_tty_group=world
2921         AC_MSG_RESULT([ptys are world accessible])
2922       fi
2923     ],[
2924       vim_cv_tty_group=world
2925       AC_MSG_RESULT([can't determine - assume ptys are world accessible])
2926     ],[
2927       AC_MSG_ERROR(cross-compiling: please set 'vim_cv_tty_group' and 'vim_cv_tty_mode')
2928     ])
2929   ])
2930 rm -f conftest_grp
2931
2932 if test "x$vim_cv_tty_group" != "xworld" ; then
2933   AC_DEFINE_UNQUOTED(PTYGROUP,$vim_cv_tty_group)
2934   if test "x$vim_cv_tty_mode" = "x" ; then
2935     AC_MSG_ERROR([It seems you're cross compiling and have 'vim_cv_tty_group' set, please also set the environment variable 'vim_cv_tty_mode' to the correct mode (propably 0620)])
2936   else
2937     AC_DEFINE(PTYMODE, 0620)
2938   fi
2939 fi
2940
2941 dnl Checks for library functions. ===================================
2942
2943 AC_TYPE_SIGNAL
2944
2945 dnl find out what to use at the end of a signal function
2946 if test $ac_cv_type_signal = void; then
2947   AC_DEFINE(SIGRETURN, [return])
2948 else
2949   AC_DEFINE(SIGRETURN, [return 0])
2950 fi
2951
2952 dnl check if struct sigcontext is defined (used for SGI only)
2953 AC_MSG_CHECKING(for struct sigcontext)
2954 AC_TRY_COMPILE([
2955 #include <signal.h>
2956 test_sig()
2957 {
2958     struct sigcontext *scont;
2959     scont = (struct sigcontext *)0;
2960     return 1;
2961 } ], ,
2962           AC_MSG_RESULT(yes)
2963                 AC_DEFINE(HAVE_SIGCONTEXT),
2964           AC_MSG_RESULT(no))
2965
2966 dnl tricky stuff: try to find out if getcwd() is implemented with
2967 dnl system("sh -c pwd")
2968 AC_CACHE_CHECK([getcwd implementation is broken], [vim_cv_getcwd_broken],
2969   [
2970     AC_RUN_IFELSE([[
2971 #include "confdefs.h"
2972 #ifdef HAVE_UNISTD_H
2973 #include <unistd.h>
2974 #endif
2975 char *dagger[] = { "IFS=pwd", 0 };
2976 main()
2977 {
2978   char buffer[500];
2979   extern char **environ;
2980   environ = dagger;
2981   return getcwd(buffer, 500) ? 0 : 1;
2982 }
2983     ]],[
2984       vim_cv_getcwd_broken=no
2985     ],[
2986       vim_cv_getcwd_broken=yes
2987     ],[
2988       AC_MSG_ERROR(cross-compiling: please set 'vim_cv_getcwd_broken')
2989     ])
2990   ])
2991
2992 if test "x$vim_cv_getcwd_broken" = "xyes" ; then
2993   AC_DEFINE(BAD_GETCWD)
2994 fi
2995
2996 dnl Check for functions in one big call, to reduce the size of configure.
2997 dnl Can only be used for functions that do not require any include.
2998 AC_CHECK_FUNCS(bcmp fchdir fchown fsync getcwd getpseudotty \
2999         getpwnam getpwuid getrlimit gettimeofday getwd lstat memcmp \
3000         memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
3001         setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
3002         sigvec strcasecmp strerror strftime stricmp strncasecmp \
3003         strnicmp strpbrk strtol tgetent towlower towupper iswupper \
3004         usleep utime utimes)
3005 AC_FUNC_FSEEKO
3006
3007 dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when
3008 dnl appropriate, so that off_t is 64 bits when needed.
3009 AC_SYS_LARGEFILE
3010
3011 dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible
3012 AC_MSG_CHECKING(for st_blksize)
3013 AC_TRY_COMPILE(
3014 [#include <sys/types.h>
3015 #include <sys/stat.h>],
3016 [       struct stat st;
3017         int n;
3018
3019         stat("/", &st);
3020         n = (int)st.st_blksize;],
3021         AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ST_BLKSIZE),
3022         AC_MSG_RESULT(no))
3023
3024 AC_CACHE_CHECK([whether stat() ignores a trailing slash], [vim_cv_stat_ignores_slash],
3025   [
3026     AC_RUN_IFELSE([[
3027 #include "confdefs.h"
3028 #if STDC_HEADERS
3029 # include <stdlib.h>
3030 # include <stddef.h>
3031 #endif
3032 #include <sys/types.h>
3033 #include <sys/stat.h>
3034 main() {struct stat st;  exit(stat("configure/", &st) != 0); }
3035     ]],[
3036       vim_cv_stat_ignores_slash=yes
3037     ],[
3038       vim_cv_stat_ignores_slash=no
3039     ],[
3040       AC_MSG_ERROR(cross-compiling: please set 'vim_cv_stat_ignores_slash')
3041     ])
3042   ])
3043
3044 if test "x$vim_cv_stat_ignores_slash" = "xyes" ; then
3045   AC_DEFINE(STAT_IGNORES_SLASH)
3046 fi
3047   
3048 dnl Link with iconv for charset translation, if not found without library.
3049 dnl check for iconv() requires including iconv.h
3050 dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
3051 dnl has been installed.
3052 AC_MSG_CHECKING(for iconv_open())
3053 save_LIBS="$LIBS"
3054 LIBS="$LIBS -liconv"
3055 AC_TRY_LINK([
3056 #ifdef HAVE_ICONV_H
3057 # include <iconv.h>
3058 #endif
3059     ], [iconv_open("fr", "to");],
3060     AC_MSG_RESULT(yes; with -liconv); AC_DEFINE(HAVE_ICONV),
3061     LIBS="$save_LIBS"
3062     AC_TRY_LINK([
3063 #ifdef HAVE_ICONV_H
3064 # include <iconv.h>
3065 #endif
3066         ], [iconv_open("fr", "to");],
3067         AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ICONV),
3068         AC_MSG_RESULT(no)))
3069
3070
3071 AC_MSG_CHECKING(for nl_langinfo(CODESET))
3072 AC_TRY_LINK([
3073 #ifdef HAVE_LANGINFO_H
3074 # include <langinfo.h>
3075 #endif
3076 ], [char *cs = nl_langinfo(CODESET);],
3077         AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET),
3078         AC_MSG_RESULT(no))
3079
3080 dnl Need various functions for floating point support.  Only enable
3081 dnl floating point when they are all present.
3082 AC_CHECK_LIB(m, strtod)
3083 AC_MSG_CHECKING([for strtod() and other floating point functions])
3084 AC_TRY_LINK([
3085 #ifdef HAVE_MATH_H
3086 # include <math.h>
3087 #endif
3088 #if STDC_HEADERS
3089 # include <stdlib.h>
3090 # include <stddef.h>
3091 #endif
3092 ], [char *s; double d;
3093     d = strtod("1.1", &s);
3094     d = fabs(1.11);
3095     d = ceil(1.11);
3096     d = floor(1.11);
3097     d = log10(1.11);
3098     d = pow(1.11, 2.22);
3099     d = sqrt(1.11);
3100     d = sin(1.11);
3101     d = cos(1.11);
3102     d = atan(1.11);
3103     ],
3104         AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT_FUNCS),
3105         AC_MSG_RESULT(no))
3106
3107 dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI
3108 dnl when -lacl works, also try to use -lattr (required for Debian).
3109 AC_MSG_CHECKING(--disable-acl argument)
3110 AC_ARG_ENABLE(acl,
3111         [  --disable-acl           Don't check for ACL support.],
3112         , [enable_acl="yes"])
3113 if test "$enable_acl" = "yes"; then
3114 AC_MSG_RESULT(no)
3115 AC_CHECK_LIB(posix1e, acl_get_file, [LIBS="$LIBS -lposix1e"],
3116         AC_CHECK_LIB(acl, acl_get_file, [LIBS="$LIBS -lacl"
3117                   AC_CHECK_LIB(attr, fgetxattr, LIBS="$LIBS -lattr",,)],,),)
3118
3119 AC_MSG_CHECKING(for POSIX ACL support)
3120 AC_TRY_LINK([
3121 #include <sys/types.h>
3122 #ifdef HAVE_SYS_ACL_H
3123 # include <sys/acl.h>
3124 #endif
3125 acl_t acl;], [acl = acl_get_file("foo", ACL_TYPE_ACCESS);
3126         acl_set_file("foo", ACL_TYPE_ACCESS, acl);
3127         acl_free(acl);],
3128         AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_ACL),
3129         AC_MSG_RESULT(no))
3130
3131 AC_MSG_CHECKING(for Solaris ACL support)
3132 AC_TRY_LINK([
3133 #ifdef HAVE_SYS_ACL_H
3134 # include <sys/acl.h>
3135 #endif], [acl("foo", GETACLCNT, 0, NULL);
3136         ],
3137         AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOLARIS_ACL),
3138         AC_MSG_RESULT(no))
3139
3140 AC_MSG_CHECKING(for AIX ACL support)
3141 AC_TRY_LINK([
3142 #if STDC_HEADERS
3143 # include <stdlib.h>
3144 # include <stddef.h>
3145 #endif
3146 #ifdef HAVE_SYS_ACL_H
3147 # include <sys/acl.h>
3148 #endif
3149 #ifdef HAVE_SYS_ACCESS_H
3150 # include <sys/access.h>
3151 #endif
3152 #define _ALL_SOURCE
3153
3154 #include <sys/stat.h>
3155
3156 int aclsize;
3157 struct acl *aclent;], [aclsize = sizeof(struct acl);
3158         aclent = (void *)malloc(aclsize);
3159         statacl("foo", STX_NORMAL, aclent, aclsize);
3160         ],
3161         AC_MSG_RESULT(yes); AC_DEFINE(HAVE_AIX_ACL),
3162         AC_MSG_RESULT(no))
3163 else
3164   AC_MSG_RESULT(yes)
3165 fi
3166
3167 AC_MSG_CHECKING(--disable-gpm argument)
3168 AC_ARG_ENABLE(gpm,
3169         [  --disable-gpm           Don't use gpm (Linux mouse daemon).], ,
3170         [enable_gpm="yes"])
3171
3172 if test "$enable_gpm" = "yes"; then
3173   AC_MSG_RESULT(no)
3174   dnl Checking if gpm support can be compiled
3175   AC_CACHE_CHECK([for gpm], vi_cv_have_gpm,
3176         [olibs="$LIBS" ; LIBS="-lgpm"]
3177         AC_TRY_LINK(
3178             [#include <gpm.h>
3179             #include <linux/keyboard.h>],
3180             [Gpm_GetLibVersion(NULL);],
3181             dnl Configure defines HAVE_GPM, if it is defined feature.h defines
3182             dnl FEAT_MOUSE_GPM if mouse support is included
3183             [vi_cv_have_gpm=yes],
3184             [vi_cv_have_gpm=no])
3185         [LIBS="$olibs"]
3186     )
3187   if test $vi_cv_have_gpm = yes; then
3188     LIBS="$LIBS -lgpm"
3189     AC_DEFINE(HAVE_GPM)
3190   fi
3191 else
3192   AC_MSG_RESULT(yes)
3193 fi
3194
3195 AC_MSG_CHECKING(--disable-sysmouse argument)
3196 AC_ARG_ENABLE(sysmouse,
3197         [  --disable-sysmouse    Don't use sysmouse (mouse in *BSD console).], ,
3198         [enable_sysmouse="yes"])
3199
3200 if test "$enable_sysmouse" = "yes"; then
3201   AC_MSG_RESULT(no)
3202   dnl Checking if sysmouse support can be compiled
3203   dnl Configure defines HAVE_SYSMOUSE, if it is defined feature.h
3204   dnl defines FEAT_SYSMOUSE if mouse support is included
3205   AC_CACHE_CHECK([for sysmouse], vi_cv_have_sysmouse,
3206         AC_TRY_LINK(
3207             [#include <sys/consio.h>
3208              #include <signal.h>
3209              #include <sys/fbio.h>],
3210             [struct mouse_info   mouse;
3211              mouse.operation = MOUSE_MODE;
3212              mouse.operation = MOUSE_SHOW;
3213              mouse.u.mode.mode = 0;
3214              mouse.u.mode.signal = SIGUSR2;],
3215             [vi_cv_have_sysmouse=yes],
3216             [vi_cv_have_sysmouse=no])
3217     )
3218   if test $vi_cv_have_sysmouse = yes; then
3219     AC_DEFINE(HAVE_SYSMOUSE)
3220   fi
3221 else
3222   AC_MSG_RESULT(yes)
3223 fi
3224
3225 dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
3226 AC_MSG_CHECKING(for FD_CLOEXEC)
3227 AC_TRY_COMPILE(
3228 [#if HAVE_FCNTL_H
3229 # include <fcntl.h>
3230 #endif],
3231 [       int flag = FD_CLOEXEC;],
3232         AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
3233         AC_MSG_RESULT(not usable))
3234
3235 dnl rename needs to be checked separately to work on Nextstep with cc
3236 AC_MSG_CHECKING(for rename)
3237 AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
3238         AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
3239         AC_MSG_RESULT(no))
3240
3241 dnl sysctl() may exist but not the arguments we use
3242 AC_MSG_CHECKING(for sysctl)
3243 AC_TRY_COMPILE(
3244 [#include <sys/types.h>
3245 #include <sys/sysctl.h>],
3246 [       int mib[2], r;
3247         size_t len;
3248
3249         mib[0] = CTL_HW;
3250         mib[1] = HW_USERMEM;
3251         len = sizeof(r);
3252         (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
3253         ],
3254         AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL),
3255         AC_MSG_RESULT(not usable))
3256
3257 dnl sysinfo() may exist but not be Linux compatible
3258 AC_MSG_CHECKING(for sysinfo)
3259 AC_TRY_COMPILE(
3260 [#include <sys/types.h>
3261 #include <sys/sysinfo.h>],
3262 [       struct sysinfo sinfo;
3263         int t;
3264
3265         (void)sysinfo(&sinfo);
3266         t = sinfo.totalram;
3267         ],
3268         AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
3269         AC_MSG_RESULT(not usable))
3270
3271 dnl struct sysinfo may have the mem_unit field or not
3272 AC_MSG_CHECKING(for sysinfo.mem_unit)
3273 AC_TRY_COMPILE(
3274 [#include <sys/types.h>
3275 #include <sys/sysinfo.h>],
3276 [       struct sysinfo sinfo;
3277         sinfo.mem_unit = 1;
3278         ],
3279         AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_MEM_UNIT),
3280         AC_MSG_RESULT(no))
3281
3282 dnl sysconf() may exist but not support what we want to use
3283 AC_MSG_CHECKING(for sysconf)
3284 AC_TRY_COMPILE(
3285 [#include <unistd.h>],
3286 [       (void)sysconf(_SC_PAGESIZE);
3287         (void)sysconf(_SC_PHYS_PAGES);
3288         ],
3289         AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
3290         AC_MSG_RESULT(not usable))
3291
3292 AC_CHECK_SIZEOF([int])
3293 AC_CHECK_SIZEOF([long])
3294 AC_CHECK_SIZEOF([time_t])
3295 AC_CHECK_SIZEOF([off_t])
3296
3297 dnl Make sure that uint32_t is really 32 bits unsigned.
3298 AC_MSG_CHECKING([uint32_t is 32 bits])
3299 AC_TRY_RUN([
3300 #ifdef HAVE_STDINT_H
3301 # include <stdint.h>
3302 #endif
3303 #ifdef HAVE_INTTYPES_H
3304 # include <inttypes.h>
3305 #endif
3306 main() {
3307   uint32_t nr1 = (uint32_t)-1;
3308   uint32_t nr2 = (uint32_t)0xffffffffUL;
3309   if (sizeof(uint32_t) != 4 || nr1 != 0xffffffffUL || nr2 + 1 != 0) exit(1);
3310   exit(0);
3311 }],
3312 AC_MSG_RESULT(ok),
3313 AC_MSG_ERROR([WRONG!  uint32_t not defined correctly.]),
3314 AC_MSG_WARN([cannot check uint32_t when cross-compiling.]))
3315
3316 dnl Check for memmove() before bcopy(), makes memmove() be used when both are
3317 dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
3318
3319 [bcopy_test_prog='
3320 #include "confdefs.h"
3321 #ifdef HAVE_STRING_H
3322 # include <string.h>
3323 #endif
3324 #if STDC_HEADERS
3325 # include <stdlib.h>
3326 # include <stddef.h>
3327 #endif
3328 main() {
3329   char buf[10];
3330   strcpy(buf, "abcdefghi");
3331   mch_memmove(buf, buf + 2, 3);
3332   if (strncmp(buf, "ababcf", 6))
3333     exit(1);
3334   strcpy(buf, "abcdefghi");
3335   mch_memmove(buf + 2, buf, 3);
3336   if (strncmp(buf, "cdedef", 6))
3337     exit(1);
3338   exit(0); /* libc version works properly.  */
3339 }']
3340
3341 AC_CACHE_CHECK([whether memmove handles overlaps],[vim_cv_memmove_handles_overlap],
3342   [
3343     AC_RUN_IFELSE([[#define mch_memmove(s,d,l) memmove(d,s,l) $bcopy_test_prog]],
3344       [
3345         vim_cv_memmove_handles_overlap=yes
3346       ],[
3347         vim_cv_memmove_handles_overlap=no
3348       ],[
3349         AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memmove_handles_overlap')
3350       ])
3351   ])
3352
3353 if test "x$vim_cv_memmove_handles_overlap" = "xyes" ; then
3354   AC_DEFINE(USEMEMMOVE)
3355 else
3356   AC_CACHE_CHECK([whether bcopy handles overlaps],[vim_cv_bcopy_handles_overlap],
3357     [
3358       AC_RUN_IFELSE([[#define mch_bcopy(s,d,l) bcopy(d,s,l) $bcopy_test_prog]],
3359       [
3360         vim_cv_bcopy_handles_overlap=yes
3361       ],[
3362         vim_cv_bcopy_handles_overlap=no
3363       ],[
3364         AC_MSG_ERROR(cross-compiling: please set 'vim_cv_bcopy_handles_overlap')
3365       ])
3366     ])
3367
3368   if test "x$vim_cv_bcopy_handles_overlap" = "xyes" ; then
3369     AC_DEFINE(USEBCOPY)
3370   else
3371     AC_CACHE_CHECK([whether memcpy handles overlaps],[vim_cv_memcpy_handles_overlap],
3372       [
3373         AC_RUN_IFELSE([[#define mch_memcpy(s,d,l) memcpy(d,s,l) $bcopy_test_prog]],
3374           [
3375             vim_cv_memcpy_handles_overlap=yes
3376           ],[
3377             vim_cv_memcpy_handles_overlap=no
3378           ],[
3379             AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memcpy_handles_overlap')
3380           ])
3381       ])
3382
3383     if test "x$vim_cv_memcpy_handles_overlap" = "xyes" ; then
3384       AC_DEFINE(USEMEMCPY)
3385     fi
3386   fi
3387 fi
3388
3389
3390 dnl Check for multibyte locale functions
3391 dnl Find out if _Xsetlocale() is supported by libX11.
3392 dnl Check if X_LOCALE should be defined.
3393
3394 if test "$enable_multibyte" = "yes"; then
3395   cflags_save=$CFLAGS
3396   ldflags_save=$LDFLAGS
3397   if test "x$x_includes" != "xNONE" ; then
3398     CFLAGS="$CFLAGS -I$x_includes"
3399     LDFLAGS="$X_LIBS $LDFLAGS -lX11"
3400     AC_MSG_CHECKING(whether X_LOCALE needed)
3401     AC_TRY_COMPILE([#include <X11/Xlocale.h>],,
3402         AC_TRY_LINK_FUNC([_Xsetlocale], [AC_MSG_RESULT(yes)
3403                 AC_DEFINE(X_LOCALE)], AC_MSG_RESULT(no)),
3404         AC_MSG_RESULT(no))
3405   fi
3406   CFLAGS=$cflags_save
3407   LDFLAGS=$ldflags_save
3408 fi
3409
3410 dnl Link with xpg4, it is said to make Korean locale working
3411 AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,)
3412
3413 dnl Check how we can run ctags.  Default to "ctags" when nothing works.
3414 dnl Use --version to detect Exuberant ctags (preferred)
3415 dnl       Add --fields=+S to get function signatures for omni completion.
3416 dnl -t for typedefs (many ctags have this)
3417 dnl -s for static functions (Elvis ctags only?)
3418 dnl -v for variables. Dangerous, most ctags take this for 'vgrind style'.
3419 dnl -i+m to test for older Exuberant ctags
3420 AC_MSG_CHECKING(how to create tags)
3421 test -f tags && mv tags tags.save
3422 if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
3423   TAGPRG="ctags -I INIT+ --fields=+S"
3424 elif (eval exctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
3425   TAGPRG="exctags -I INIT+ --fields=+S"
3426 elif (eval exuberant-ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
3427   TAGPRG="exuberant-ctags -I INIT+ --fields=+S"
3428 else
3429   TAGPRG="ctags"
3430   (eval etags      /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags"
3431   (eval etags -c   /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags -c"
3432   (eval ctags      /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags"
3433   (eval ctags -t   /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -t"
3434   (eval ctags -ts  /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -ts"
3435   (eval ctags -tvs /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -tvs"
3436   (eval ctags -i+m /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -i+m"
3437 fi
3438 test -f tags.save && mv tags.save tags
3439 AC_MSG_RESULT($TAGPRG) AC_SUBST(TAGPRG)
3440
3441 dnl Check how we can run man with a section number
3442 AC_MSG_CHECKING(how to run man with a section nr)
3443 MANDEF="man"
3444 (eval MANPAGER=cat PAGER=cat man -s 2 read) < /dev/null > /dev/null 2>&AC_FD_CC && MANDEF="man -s"
3445 AC_MSG_RESULT($MANDEF)
3446 if test "$MANDEF" = "man -s"; then
3447   AC_DEFINE(USEMAN_S)
3448 fi
3449
3450 dnl Check if gettext() is working and if it needs -lintl
3451 AC_MSG_CHECKING(--disable-nls argument)
3452 AC_ARG_ENABLE(nls,
3453         [  --disable-nls           Don't support NLS (gettext()).], ,
3454         [enable_nls="yes"])
3455
3456 if test "$enable_nls" = "yes"; then
3457   AC_MSG_RESULT(no)
3458
3459   INSTALL_LANGS=install-languages
3460   AC_SUBST(INSTALL_LANGS)
3461   INSTALL_TOOL_LANGS=install-tool-languages
3462   AC_SUBST(INSTALL_TOOL_LANGS)
3463
3464   AC_CHECK_PROG(MSGFMT, msgfmt, msgfmt, )
3465   AC_MSG_CHECKING([for NLS])
3466   if test -f po/Makefile; then
3467     have_gettext="no"
3468     if test -n "$MSGFMT"; then
3469       AC_TRY_LINK(
3470         [#include <libintl.h>],
3471         [gettext("Test");],
3472         AC_MSG_RESULT([gettext() works]); have_gettext="yes",
3473           olibs=$LIBS
3474           LIBS="$LIBS -lintl"
3475           AC_TRY_LINK(
3476               [#include <libintl.h>],
3477               [gettext("Test");],
3478               AC_MSG_RESULT([gettext() works with -lintl]); have_gettext="yes",
3479               AC_MSG_RESULT([gettext() doesn't work]);
3480               LIBS=$olibs))
3481     else
3482       AC_MSG_RESULT([msgfmt not found - disabled]);
3483     fi
3484     if test $have_gettext = "yes"; then
3485       AC_DEFINE(HAVE_GETTEXT)
3486       MAKEMO=yes
3487       AC_SUBST(MAKEMO)
3488       dnl this was added in GNU gettext 0.10.36
3489       AC_CHECK_FUNCS(bind_textdomain_codeset)
3490       dnl _nl_msg_cat_cntr is required for GNU gettext
3491       AC_MSG_CHECKING([for _nl_msg_cat_cntr])
3492       AC_TRY_LINK(
3493                 [#include <libintl.h>
3494                 extern int _nl_msg_cat_cntr;],
3495                 [++_nl_msg_cat_cntr;],
3496                 AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_NL_MSG_CAT_CNTR),
3497                 AC_MSG_RESULT([no]))
3498     fi
3499   else
3500     AC_MSG_RESULT([no "po/Makefile" - disabled]);
3501   fi
3502 else
3503   AC_MSG_RESULT(yes)
3504 fi
3505
3506 dnl Check for dynamic linking loader
3507 AC_CHECK_HEADER(dlfcn.h, DLL=dlfcn.h, [AC_CHECK_HEADER(dl.h, DLL=dl.h)])
3508 if test x${DLL} = xdlfcn.h; then
3509   AC_DEFINE(HAVE_DLFCN_H, 1, [ Define if we have dlfcn.h. ])
3510   AC_MSG_CHECKING([for dlopen()])
3511   AC_TRY_LINK(,[
3512                 extern void* dlopen();
3513                 dlopen();
3514       ],
3515       AC_MSG_RESULT(yes);
3516               AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
3517       AC_MSG_RESULT(no);
3518               AC_MSG_CHECKING([for dlopen() in -ldl])
3519               olibs=$LIBS
3520               LIBS="$LIBS -ldl"
3521               AC_TRY_LINK(,[
3522                                 extern void* dlopen();
3523                                 dlopen();
3524                  ],
3525                  AC_MSG_RESULT(yes);
3526                           AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
3527                  AC_MSG_RESULT(no);
3528                           LIBS=$olibs))
3529   dnl ReliantUNIX has dlopen() in libc but everything else in libdl
3530   dnl ick :-)
3531   AC_MSG_CHECKING([for dlsym()])
3532   AC_TRY_LINK(,[
3533                 extern void* dlsym();
3534                 dlsym();
3535       ],
3536       AC_MSG_RESULT(yes);
3537               AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
3538       AC_MSG_RESULT(no);
3539               AC_MSG_CHECKING([for dlsym() in -ldl])
3540               olibs=$LIBS
3541               LIBS="$LIBS -ldl"
3542               AC_TRY_LINK(,[
3543                                 extern void* dlsym();
3544                                 dlsym();
3545                  ],
3546                  AC_MSG_RESULT(yes);
3547                           AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
3548                  AC_MSG_RESULT(no);
3549                           LIBS=$olibs))
3550 elif test x${DLL} = xdl.h; then
3551   AC_DEFINE(HAVE_DL_H, 1, [ Define if we have dl.h. ])
3552   AC_MSG_CHECKING([for shl_load()])
3553   AC_TRY_LINK(,[
3554                 extern void* shl_load();
3555                 shl_load();
3556      ],
3557      AC_MSG_RESULT(yes);
3558           AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
3559      AC_MSG_RESULT(no);
3560           AC_MSG_CHECKING([for shl_load() in -ldld])
3561           olibs=$LIBS
3562           LIBS="$LIBS -ldld"
3563           AC_TRY_LINK(,[
3564                         extern void* shl_load();
3565                         shl_load();
3566              ],
3567              AC_MSG_RESULT(yes);
3568                   AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
3569              AC_MSG_RESULT(no);
3570                   LIBS=$olibs))
3571 fi
3572 AC_CHECK_HEADERS(setjmp.h)
3573
3574 if test "x$MACOSX" = "xyes" -a -n "$PERL"; then
3575   dnl -ldl must come after DynaLoader.a
3576   if echo $LIBS | grep -e '-ldl' >/dev/null; then
3577     LIBS=`echo $LIBS | sed s/-ldl//`
3578     PERL_LIBS="$PERL_LIBS -ldl"
3579   fi
3580 fi
3581
3582 if test "x$MACOSX" = "xyes"; then
3583   AC_MSG_CHECKING(whether we need -framework Cocoa)
3584   dnl Cocoa is needed with FEAT_CLIPBOARD or FEAT_MBYTE (the former is
3585   dnl disabled during tiny build)
3586   if test "x$features" != "xtiny" || test "x$enable_multibyte" = "xyes"; then
3587     LIBS=$"$LIBS -framework Cocoa"
3588     AC_MSG_RESULT(yes)
3589   else
3590     AC_MSG_RESULT(no)
3591   fi
3592 fi
3593 if test "x$MACARCH" = "xboth" && test "x$GUITYPE" = "xCARBONGUI"; then
3594   LDFLAGS="$LDFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
3595 fi
3596
3597 dnl gcc 3.1 changed the meaning of -MM.  The only solution appears to be to
3598 dnl use "-isystem" instead of "-I" for all non-Vim include dirs.
3599 dnl But only when making dependencies, cproto and lint don't take "-isystem".
3600 dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
3601 dnl the number before the version number.
3602 DEPEND_CFLAGS_FILTER=
3603 if test "$GCC" = yes; then
3604   AC_MSG_CHECKING(for GCC 3 or later)
3605   gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]]\)\..*$/\1/g'`
3606   if test "$gccmajor" -gt "2"; then
3607     DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
3608     AC_MSG_RESULT(yes)
3609   else
3610     AC_MSG_RESULT(no)
3611   fi
3612   dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
3613   dnl declared as char x[1] but actually longer.  Introduced in gcc 4.0.
3614   dnl Also remove duplicate _FORTIFY_SOURCE arguments.
3615   dnl And undefine it first to avoid a warning.
3616   AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
3617   if test "$gccmajor" -gt "3"; then
3618     CFLAGS=`echo "$CFLAGS" | sed -e 's/-Wp,-D_FORTIFY_SOURCE=.//g' -e 's/-D_FORTIFY_SOURCE=.//g' -e 's/$/ -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1/'`
3619     AC_MSG_RESULT(yes)
3620   else
3621     AC_MSG_RESULT(no)
3622   fi
3623 fi
3624 AC_SUBST(DEPEND_CFLAGS_FILTER)
3625
3626 dnl link.sh tries to avoid overlinking in a hackish way.
3627 dnl At least GNU ld supports --as-needed which provides the same functionality
3628 dnl at linker level. Let's use it.
3629 AC_MSG_CHECKING(linker --as-needed support)
3630 LINK_AS_NEEDED=
3631 # Check if linker supports --as-needed and --no-as-needed options
3632 if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
3633   LDFLAGS="$LDFLAGS -Wl,--as-needed"
3634   LINK_AS_NEEDED=yes
3635 fi
3636 if test "$LINK_AS_NEEDED" = yes; then
3637   AC_MSG_RESULT(yes)
3638 else
3639   AC_MSG_RESULT(no)
3640 fi
3641 AC_SUBST(LINK_AS_NEEDED)
3642
3643 dnl write output files
3644 AC_OUTPUT(auto/config.mk:config.mk.in)
3645
3646 dnl vim: set sw=2 tw=78 fo+=l: