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