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