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