blob: a6fbc8540abcc081bc0949880bd4b6d1c90b9a59 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001dnl configure.in: autoconf script for Vim
2
3dnl Process this file with autoconf 2.12 or 2.13 to produce "configure".
4dnl Should also work with autoconf 2.54 and later.
5
6AC_INIT(vim.h)
7AC_CONFIG_HEADER(auto/config.h:config.h.in)
8
9dnl Being able to run configure means the system is Unix (compatible).
10AC_DEFINE(UNIX)
11AC_PROG_MAKE_SET
12
13dnl Checks for programs.
14AC_PROG_CC dnl required by almost everything
15AC_PROG_CPP dnl required by header file checks
16AC_PROGRAM_EGREP dnl required by AC_EGREP_CPP
17AC_ISC_POSIX dnl required by AC_C_CROSS
18AC_PROG_AWK dnl required for "make html" in ../doc
19
20dnl Don't strip if we don't have it
21AC_CHECK_PROG(STRIP, strip, strip, :)
22
Bram Moolenaar325b7a22004-07-05 15:58:32 +000023dnl Check for extension of executables
Bram Moolenaar071d4272004-06-13 20:20:40 +000024AC_EXEEXT
25
Bram Moolenaar446cb832008-06-24 21:56:24 +000026dnl Check for standard headers. We don't use this in Vim but other stuff
27dnl in autoconf needs it, where it uses STDC_HEADERS.
28AC_HEADER_STDC
29AC_HEADER_SYS_WAIT
30
Bram Moolenaar071d4272004-06-13 20:20:40 +000031dnl Set default value for CFLAGS if none is defined or it's empty
32if test -z "$CFLAGS"; then
33 CFLAGS="-O"
34 test "$GCC" = yes && CFLAGS="-O2 -fno-strength-reduce -Wall"
35fi
36if test "$GCC" = yes; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +000037 dnl method that should work for nearly all versions
38 gccversion=`"$CC" -dumpversion`
39 if test "x$gccversion" = "x"; then
40 dnl old method; fall-back for when -dumpversion doesn't work
41 gccversion=`"$CC" --version | sed -e '2,$d' -e 's/darwin.//' -e 's/^[[^0-9]]*\([[0-9]]\.[[0-9.]]*\).*$/\1/g'`
42 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +000043 dnl version 4.0.1 was reported to cause trouble on Macintosh by Marcin Dalecki
44 if test "$gccversion" = "3.0.1" -o "$gccversion" = "3.0.2" -o "$gccversion" = "4.0.1"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +000045 echo 'GCC [[34]].0.[[12]] has a bug in the optimizer, disabling "-O#"'
Bram Moolenaar071d4272004-06-13 20:20:40 +000046 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-O/'`
47 else
48 if test "$gccversion" = "3.1" -o "$gccversion" = "3.2" -o "$gccversion" = "3.2.1" && `echo "$CFLAGS" | grep -v fno-strength-reduce >/dev/null`; then
49 echo 'GCC 3.1 and 3.2 have a bug in the optimizer, adding "-fno-strength-reduce"'
50 CFLAGS="$CFLAGS -fno-strength-reduce"
51 fi
52 fi
53fi
54
Bram Moolenaar446cb832008-06-24 21:56:24 +000055dnl If configure thinks we are cross compiling, there might be something
56dnl wrong with the CC or CFLAGS settings, give a useful warning message
Bram Moolenaar071d4272004-06-13 20:20:40 +000057if test "$cross_compiling" = yes; then
Bram Moolenaar446cb832008-06-24 21:56:24 +000058 AC_MSG_RESULT([cannot compile a simple program; if not cross compiling check CC and CFLAGS])
Bram Moolenaar071d4272004-06-13 20:20:40 +000059fi
60
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +000061dnl gcc-cpp has the wonderful -MM option to produce nicer dependencies.
62dnl But gcc 3.1 changed the meaning! See near the end.
Bram Moolenaar071d4272004-06-13 20:20:40 +000063test "$GCC" = yes && CPP_MM=M; AC_SUBST(CPP_MM)
64
65if test -f ./toolcheck; then
66 AC_CHECKING(for buggy tools)
67 sh ./toolcheck 1>&AC_FD_MSG
68fi
69
70OS_EXTRA_SRC=""; OS_EXTRA_OBJ=""
71
72dnl Check for BeOS, which needs an extra source file
73AC_MSG_CHECKING(for BeOS)
74case `uname` in
75 BeOS) OS_EXTRA_SRC=os_beos.c; OS_EXTRA_OBJ=objects/os_beos.o
76 BEOS=yes; AC_MSG_RESULT(yes);;
77 *) BEOS=no; AC_MSG_RESULT(no);;
78esac
79
80dnl If QNX is found, assume we don't want to use Xphoton
81dnl unless it was specifically asked for (--with-x)
82AC_MSG_CHECKING(for QNX)
83case `uname` in
84 QNX) OS_EXTRA_SRC=os_qnx.c; OS_EXTRA_OBJ=objects/os_qnx.o
85 test -z "$with_x" && with_x=no
86 QNX=yes; AC_MSG_RESULT(yes);;
87 *) QNX=no; AC_MSG_RESULT(no);;
88esac
89
90dnl Check for Darwin and MacOS X
91dnl We do a check for MacOS X in the very beginning because there
92dnl are a lot of other things we need to change besides GUI stuff
Bram Moolenaar071d4272004-06-13 20:20:40 +000093AC_MSG_CHECKING([for Darwin (Mac OS X)])
94if test "`(uname) 2>/dev/null`" = Darwin; then
95 AC_MSG_RESULT(yes)
96
97 AC_MSG_CHECKING(--disable-darwin argument)
98 AC_ARG_ENABLE(darwin,
99 [ --disable-darwin Disable Darwin (Mac OS X) support.],
100 , [enable_darwin="yes"])
101 if test "$enable_darwin" = "yes"; then
102 AC_MSG_RESULT(no)
103 AC_MSG_CHECKING(if Darwin files are there)
Bram Moolenaar164fca32010-07-14 13:58:07 +0200104 if test -f os_macosx.m; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000105 AC_MSG_RESULT(yes)
106 else
107 AC_MSG_RESULT([no, Darwin support disabled])
108 enable_darwin=no
109 fi
110 else
111 AC_MSG_RESULT([yes, Darwin support excluded])
112 fi
113
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000114 AC_MSG_CHECKING(--with-mac-arch argument)
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000115 AC_ARG_WITH(mac-arch, [ --with-mac-arch=ARCH current, intel, ppc or both],
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000116 MACARCH="$withval"; AC_MSG_RESULT($MACARCH),
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000117 MACARCH="current"; AC_MSG_RESULT(defaulting to $MACARCH))
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000118
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100119 AC_MSG_CHECKING(--with-developer-dir argument)
120 AC_ARG_WITH(developer-dir, [ --with-developer-dir=PATH use PATH as location for Xcode developer tools],
121 DEVELOPER_DIR="$withval"; AC_MSG_RESULT($DEVELOPER_DIR),
122 DEVELOPER_DIR=""; AC_MSG_RESULT(not present))
123
124 if test "x$DEVELOPER_DIR" = "x"; then
125 AC_PATH_PROG(XCODE_SELECT, xcode-select)
126 if test "x$XCODE_SELECT" != "x"; then
127 AC_MSG_CHECKING(for developer dir using xcode-select)
128 DEVELOPER_DIR=`$XCODE_SELECT -print-path`
129 AC_MSG_RESULT([$DEVELOPER_DIR])
130 else
131 DEVELOPER_DIR=/Developer
132 fi
133 fi
134
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000135 if test "x$MACARCH" = "xboth"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000136 AC_MSG_CHECKING(for 10.4 universal SDK)
137 dnl There is a terrible inconsistency (but we appear to get away with it):
138 dnl $CFLAGS uses the 10.4u SDK library for the headers, while $CPPFLAGS
139 dnl doesn't, because "gcc -E" doesn't grok it. That means the configure
140 dnl tests using the preprocessor are actually done with the wrong header
141 dnl files. $LDFLAGS is set at the end, because configure uses it together
142 dnl with $CFLAGS and we can only have one -sysroot argument.
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000143 save_cppflags="$CPPFLAGS"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000144 save_cflags="$CFLAGS"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000145 save_ldflags="$LDFLAGS"
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100146 CFLAGS="$CFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000147 AC_TRY_LINK([ ], [ ],
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000148 AC_MSG_RESULT(found, will make universal binary),
149
150 AC_MSG_RESULT(not found)
Bram Moolenaar1f35bf92006-03-07 22:38:47 +0000151 CFLAGS="$save_cflags"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000152 AC_MSG_CHECKING(if Intel architecture is supported)
153 CPPFLAGS="$CPPFLAGS -arch i386"
154 LDFLAGS="$save_ldflags -arch i386"
155 AC_TRY_LINK([ ], [ ],
156 AC_MSG_RESULT(yes); MACARCH="intel",
157 AC_MSG_RESULT(no, using PowerPC)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000158 MACARCH="ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000159 CPPFLAGS="$save_cppflags -arch ppc"
160 LDFLAGS="$save_ldflags -arch ppc"))
161 elif test "x$MACARCH" = "xintel"; then
162 CPPFLAGS="$CPPFLAGS -arch intel"
163 LDFLAGS="$LDFLAGS -arch intel"
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000164 elif test "x$MACARCH" = "xppc"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000165 CPPFLAGS="$CPPFLAGS -arch ppc"
166 LDFLAGS="$LDFLAGS -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000167 fi
168
Bram Moolenaar071d4272004-06-13 20:20:40 +0000169 if test "$enable_darwin" = "yes"; then
170 MACOSX=yes
Bram Moolenaar164fca32010-07-14 13:58:07 +0200171 OS_EXTRA_SRC="os_macosx.m os_mac_conv.c";
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000172 OS_EXTRA_OBJ="objects/os_macosx.o objects/os_mac_conv.o"
Bram Moolenaar32466aa2006-02-24 23:53:04 +0000173 dnl TODO: use -arch i386 on Intel machines
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000174 CPPFLAGS="$CPPFLAGS -DMACOS_X_UNIX -no-cpp-precomp"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000175
176 dnl If Carbon is found, assume we don't want X11
177 dnl unless it was specifically asked for (--with-x)
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000178 dnl or Motif, Athena or GTK GUI is used.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000179 AC_CHECK_HEADER(Carbon/Carbon.h, CARBON=yes)
180 if test "x$CARBON" = "xyes"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +0200181 if test -z "$with_x" -a "X$enable_gui" != Xmotif -a "X$enable_gui" != Xathena -a "X$enable_gui" != Xgtk2; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000182 with_x=no
Bram Moolenaar071d4272004-06-13 20:20:40 +0000183 fi
184 fi
185 fi
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000186
Bram Moolenaardb552d602006-03-23 22:59:57 +0000187 dnl Avoid a bug with -O2 with gcc 4.0.1. Symptom: malloc() reports double
Bram Moolenaarfd2ac762006-03-01 22:09:21 +0000188 dnl free. This happens in expand_filename(), because the optimizer swaps
Bram Moolenaardb552d602006-03-23 22:59:57 +0000189 dnl two blocks of code, both using "repl", that can't be swapped.
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000190 if test "$MACARCH" = "intel" -o "$MACARCH" = "both"; then
191 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-Oz/'`
192 fi
193
Bram Moolenaar071d4272004-06-13 20:20:40 +0000194else
195 AC_MSG_RESULT(no)
196fi
197
198AC_SUBST(OS_EXTRA_SRC)
199AC_SUBST(OS_EXTRA_OBJ)
200
201dnl Add /usr/local/lib to $LDFLAGS and /usr/local/include to CFLAGS.
202dnl Only when the directory exists and it wasn't there yet.
203dnl For gcc don't do this when it is already in the default search path.
Bram Moolenaar446cb832008-06-24 21:56:24 +0000204dnl Skip all of this when cross-compiling.
205if test "$cross_compiling" = no; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000206 AC_MSG_CHECKING(--with-local-dir argument)
Bram Moolenaar446cb832008-06-24 21:56:24 +0000207 have_local_include=''
208 have_local_lib=''
Bram Moolenaarc236c162008-07-13 17:41:49 +0000209 AC_ARG_WITH([local-dir], [ --with-local-dir=PATH search PATH instead of /usr/local for local libraries.
210 --without-local-dir do not search /usr/local for local libraries.], [
211 local_dir="$withval"
212 case "$withval" in
213 */*) ;;
214 no)
215 # avoid adding local dir to LDFLAGS and CPPFLAGS
216 have_local_dir=yes
217 have_local_lib=yes
218 ;;
219 *) AC_MSG_ERROR(must pass path argument to --with-local-dir) ;;
220 esac
221 AC_MSG_RESULT($local_dir)
222 ], [
223 local_dir=/usr/local
224 AC_MSG_RESULT(Defaulting to $local_dir)
225 ])
226 if test "$GCC" = yes -a "$local_dir" != no; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000227 echo 'void f(){}' > conftest.c
228 dnl -no-cpp-precomp is needed for OS X 10.2 (Ben Fowler)
Bram Moolenaarc236c162008-07-13 17:41:49 +0000229 have_local_include=`${CC-cc} -no-cpp-precomp -c -v conftest.c 2>&1 | grep "${local_dir}/include"`
230 have_local_lib=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/lib"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000231 rm -f conftest.c conftest.o
Bram Moolenaar071d4272004-06-13 20:20:40 +0000232 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000233 if test -z "$have_local_lib" -a -d "${local_dir}/lib"; then
234 tt=`echo "$LDFLAGS" | sed -e "s+-L${local_dir}/lib ++g" -e "s+-L${local_dir}/lib$++g"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000235 if test "$tt" = "$LDFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000236 LDFLAGS="$LDFLAGS -L${local_dir}/lib"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000237 fi
238 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000239 if test -z "$have_local_include" -a -d "${local_dir}/include"; then
240 tt=`echo "$CPPFLAGS" | sed -e "s+-I${local_dir}/include ++g" -e "s+-I${local_dir}/include$++g"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000241 if test "$tt" = "$CPPFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000242 CPPFLAGS="$CPPFLAGS -I${local_dir}/include"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000243 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000244 fi
245fi
246
247AC_MSG_CHECKING(--with-vim-name argument)
248AC_ARG_WITH(vim-name, [ --with-vim-name=NAME what to call the Vim executable],
249 VIMNAME="$withval"; AC_MSG_RESULT($VIMNAME),
Bram Moolenaare344bea2005-09-01 20:46:49 +0000250 VIMNAME="vim"; AC_MSG_RESULT(Defaulting to $VIMNAME))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000251AC_SUBST(VIMNAME)
252AC_MSG_CHECKING(--with-ex-name argument)
253AC_ARG_WITH(ex-name, [ --with-ex-name=NAME what to call the Ex executable],
254 EXNAME="$withval"; AC_MSG_RESULT($EXNAME),
255 EXNAME="ex"; AC_MSG_RESULT(Defaulting to ex))
256AC_SUBST(EXNAME)
257AC_MSG_CHECKING(--with-view-name argument)
258AC_ARG_WITH(view-name, [ --with-view-name=NAME what to call the View executable],
259 VIEWNAME="$withval"; AC_MSG_RESULT($VIEWNAME),
260 VIEWNAME="view"; AC_MSG_RESULT(Defaulting to view))
261AC_SUBST(VIEWNAME)
262
263AC_MSG_CHECKING(--with-global-runtime argument)
264AC_ARG_WITH(global-runtime, [ --with-global-runtime=DIR global runtime directory in 'runtimepath'],
265 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL, "$withval"),
266 AC_MSG_RESULT(no))
267
268AC_MSG_CHECKING(--with-modified-by argument)
269AC_ARG_WITH(modified-by, [ --with-modified-by=NAME name of who modified a release version],
270 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(MODIFIED_BY, "$withval"),
271 AC_MSG_RESULT(no))
272
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200273dnl Check for EBCDIC stolen from the LYNX port to z/OS Unix
Bram Moolenaar071d4272004-06-13 20:20:40 +0000274AC_MSG_CHECKING(if character set is EBCDIC)
275AC_TRY_COMPILE([ ],
276[ /* TryCompile function for CharSet.
277 Treat any failure as ASCII for compatibility with existing art.
278 Use compile-time rather than run-time tests for cross-compiler
279 tolerance. */
280#if '0'!=240
281make an error "Character set is not EBCDIC"
282#endif ],
283[ # TryCompile action if true
284cf_cv_ebcdic=yes ],
285[ # TryCompile action if false
286cf_cv_ebcdic=no])
287# end of TryCompile ])
288# end of CacheVal CvEbcdic
289AC_MSG_RESULT($cf_cv_ebcdic)
290case "$cf_cv_ebcdic" in #(vi
291 yes) AC_DEFINE(EBCDIC)
292 line_break='"\\n"'
293 ;;
294 *) line_break='"\\012"';;
295esac
296AC_SUBST(line_break)
297
298if test "$cf_cv_ebcdic" = "yes"; then
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200299dnl If we have EBCDIC we most likley have z/OS Unix, let's test it!
300AC_MSG_CHECKING(for z/OS Unix)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000301case `uname` in
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200302 OS/390) zOSUnix="yes";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000303 dnl If using cc the environment variable _CC_CCMODE must be
304 dnl set to "1", so that some compiler extensions are enabled.
305 dnl If using c89 the environment variable is named _CC_C89MODE.
306 dnl Note: compile with c89 never tested.
307 if test "$CC" = "cc"; then
308 ccm="$_CC_CCMODE"
309 ccn="CC"
310 else
311 if test "$CC" = "c89"; then
312 ccm="$_CC_C89MODE"
313 ccn="C89"
314 else
315 ccm=1
316 fi
317 fi
318 if test "$ccm" != "1"; then
319 echo ""
320 echo "------------------------------------------"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200321 echo " On z/OS Unix, the environment variable"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000322 echo " __CC_${ccn}MODE must be set to \"1\"!"
323 echo " Do:"
324 echo " export _CC_${ccn}MODE=1"
325 echo " and then call configure again."
326 echo "------------------------------------------"
327 exit 1
328 fi
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200329 CFLAGS="$CFLAGS -D_ALL_SOURCE -Wc,float\\(IEEE\\)";
330 LDFLAGS="$LDFLAGS -Wl,EDIT=NO"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000331 AC_MSG_RESULT(yes)
332 ;;
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200333 *) zOSUnix="no";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000334 AC_MSG_RESULT(no)
335 ;;
336esac
337fi
338
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200339dnl Set QUOTESED. Needs additional backslashes on zOS
340if test "$zOSUnix" = "yes"; then
341 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\\\\\&/g' -e 's/\\\\\\\\\"/\"/' -e 's/\\\\\\\\\";\$\$/\";/'"
342else
343 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\&/g' -e 's/\\\\\"/\"/' -e 's/\\\\\";\$\$/\";/'"
344fi
345AC_SUBST(QUOTESED)
346
347
Bram Moolenaar588ebeb2008-05-07 17:09:24 +0000348dnl Link with -lselinux for SELinux stuff; if not found
349AC_MSG_CHECKING(--disable-selinux argument)
350AC_ARG_ENABLE(selinux,
351 [ --disable-selinux Don't check for SELinux support.],
352 , enable_selinux="yes")
353if test "$enable_selinux" = "yes"; then
354 AC_MSG_RESULT(no)
355 AC_CHECK_LIB(selinux, is_selinux_enabled,
356 [LIBS="$LIBS -lselinux"
357 AC_DEFINE(HAVE_SELINUX)])
358else
359 AC_MSG_RESULT(yes)
360fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000361
362dnl Check user requested features.
363
364AC_MSG_CHECKING(--with-features argument)
365AC_ARG_WITH(features, [ --with-features=TYPE tiny, small, normal, big or huge (default: normal)],
366 features="$withval"; AC_MSG_RESULT($features),
367 features="normal"; AC_MSG_RESULT(Defaulting to normal))
368
369dovimdiff=""
370dogvimdiff=""
371case "$features" in
372 tiny) AC_DEFINE(FEAT_TINY) ;;
373 small) AC_DEFINE(FEAT_SMALL) ;;
374 normal) AC_DEFINE(FEAT_NORMAL) dovimdiff="installvimdiff";
375 dogvimdiff="installgvimdiff" ;;
376 big) AC_DEFINE(FEAT_BIG) dovimdiff="installvimdiff";
377 dogvimdiff="installgvimdiff" ;;
378 huge) AC_DEFINE(FEAT_HUGE) dovimdiff="installvimdiff";
379 dogvimdiff="installgvimdiff" ;;
380 *) AC_MSG_RESULT([Sorry, $features is not supported]) ;;
381esac
382
383AC_SUBST(dovimdiff)
384AC_SUBST(dogvimdiff)
385
386AC_MSG_CHECKING(--with-compiledby argument)
387AC_ARG_WITH(compiledby, [ --with-compiledby=NAME name to show in :version message],
388 compiledby="$withval"; AC_MSG_RESULT($withval),
389 compiledby=""; AC_MSG_RESULT(no))
390AC_SUBST(compiledby)
391
392AC_MSG_CHECKING(--disable-xsmp argument)
393AC_ARG_ENABLE(xsmp,
394 [ --disable-xsmp Disable XSMP session management],
395 , enable_xsmp="yes")
396
397if test "$enable_xsmp" = "yes"; then
398 AC_MSG_RESULT(no)
399 AC_MSG_CHECKING(--disable-xsmp-interact argument)
400 AC_ARG_ENABLE(xsmp-interact,
401 [ --disable-xsmp-interact Disable XSMP interaction],
402 , enable_xsmp_interact="yes")
403 if test "$enable_xsmp_interact" = "yes"; then
404 AC_MSG_RESULT(no)
405 AC_DEFINE(USE_XSMP_INTERACT)
406 else
407 AC_MSG_RESULT(yes)
408 fi
409else
410 AC_MSG_RESULT(yes)
411fi
412
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200413dnl Check for Lua feature.
414AC_MSG_CHECKING(--enable-luainterp argument)
415AC_ARG_ENABLE(luainterp,
416 [ --enable-luainterp Include Lua interpreter.], ,
417 [enable_luainterp="no"])
418AC_MSG_RESULT($enable_luainterp)
419
420if test "$enable_luainterp" = "yes"; then
421 dnl -- find the lua executable
422 AC_SUBST(vi_cv_path_lua)
423
424 AC_MSG_CHECKING(--with-lua-prefix argument)
425 AC_ARG_WITH(lua_prefix,
426 [ --with-lua-prefix=PFX Prefix where Lua is installed.],
427 with_lua_prefix="$withval"; AC_MSG_RESULT($with_lua_prefix),
428 with_lua_prefix="";AC_MSG_RESULT("no"))
429
430 if test "X$with_lua_prefix" != "X"; then
431 vi_cv_path_lua_pfx="$with_lua_prefix"
432 else
433 AC_MSG_CHECKING(LUA_PREFIX environment var)
434 if test "X$LUA_PREFIX" != "X"; then
435 AC_MSG_RESULT("$LUA_PREFIX")
436 vi_cv_path_lua_pfx="$LUA_PREFIX"
437 else
438 AC_MSG_RESULT("not set")
439 fi
440 fi
441
442 LUA_INC=
443 if test "X$vi_cv_path_lua_pfx" != "X"; then
444 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)
445 if test -f $vi_cv_path_lua_pfx/include/lua.h; then
446 AC_MSG_RESULT("yes")
447 else
448 AC_MSG_RESULT("no")
449 dnl -- try to find Lua executable
450 AC_PATH_PROG(vi_cv_path_lua, lua)
451 if test "X$vi_cv_path_lua" != "X"; then
452 dnl -- find Lua version
453 AC_CACHE_CHECK(Lua version, vi_cv_version_lua,
454 [ vi_cv_version_lua=`${vi_cv_path_lua} -e "print(_VERSION:sub(5,7))"` ])
455 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua)
456 if test -f $vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h; then
457 AC_MSG_RESULT("yes")
458 LUA_INC=/lua$vi_cv_version_lua
459 else
460 AC_MSG_RESULT("no")
461 vi_cv_path_lua_pfx=
462 fi
463 fi
464 fi
465 fi
466
467 if test "X$vi_cv_path_lua_pfx" != "X"; then
468 if test "X$vi_cv_version_lua" != "X"; then
469 dnl Test alternate location using version
470 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua$vi_cv_version_lua"
471 else
472 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua"
473 fi
474 LUA_CFLAGS="-I${vi_cv_path_lua_pfx}/include${LUA_INC}"
475 LUA_SRC="if_lua.c"
476 LUA_OBJ="objects/if_lua.o"
477 LUA_PRO="if_lua.pro"
478 AC_DEFINE(FEAT_LUA)
479 fi
480 AC_SUBST(LUA_SRC)
481 AC_SUBST(LUA_OBJ)
482 AC_SUBST(LUA_PRO)
483 AC_SUBST(LUA_LIBS)
484 AC_SUBST(LUA_CFLAGS)
485fi
486
487
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000488dnl Check for MzScheme feature.
489AC_MSG_CHECKING(--enable-mzschemeinterp argument)
490AC_ARG_ENABLE(mzschemeinterp,
491 [ --enable-mzschemeinterp Include MzScheme interpreter.], ,
492 [enable_mzschemeinterp="no"])
493AC_MSG_RESULT($enable_mzschemeinterp)
494
495if test "$enable_mzschemeinterp" = "yes"; then
496 dnl -- find the mzscheme executable
497 AC_SUBST(vi_cv_path_mzscheme)
498
499 AC_MSG_CHECKING(--with-plthome argument)
500 AC_ARG_WITH(plthome,
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000501 [ --with-plthome=PLTHOME Use PLTHOME.],
502 with_plthome="$withval"; AC_MSG_RESULT($with_plthome),
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000503 with_plthome="";AC_MSG_RESULT("no"))
504
505 if test "X$with_plthome" != "X"; then
506 vi_cv_path_mzscheme_pfx="$with_plthome"
507 else
508 AC_MSG_CHECKING(PLTHOME environment var)
509 if test "X$PLTHOME" != "X"; then
510 AC_MSG_RESULT("$PLTHOME")
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000511 vi_cv_path_mzscheme_pfx="$PLTHOME"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000512 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000513 AC_MSG_RESULT(not set)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000514 dnl -- try to find MzScheme executable
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000515 AC_PATH_PROG(vi_cv_path_mzscheme, mzscheme)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000516
517 dnl resolve symbolic link, the executable is often elsewhere and there
518 dnl are no links for the include files.
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000519 if test "X$vi_cv_path_mzscheme" != "X"; then
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000520 lsout=`ls -l $vi_cv_path_mzscheme`
521 if echo "$lsout" | grep -e '->' >/dev/null 2>/dev/null; then
522 vi_cv_path_mzscheme=`echo "$lsout" | sed 's/.*-> \(.*\)/\1/'`
523 fi
524 fi
525
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000526 if test "X$vi_cv_path_mzscheme" != "X"; then
527 dnl -- find where MzScheme thinks it was installed
528 AC_CACHE_CHECK(MzScheme install prefix,vi_cv_path_mzscheme_pfx,
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000529 dnl different versions of MzScheme differ in command line processing
530 dnl use universal approach
531 echo "(display (simplify-path \
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000532 (build-path (call-with-values \
533 (lambda () (split-path (find-system-path (quote exec-file)))) \
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000534 (lambda (base name must-be-dir?) base)) (quote up))))" > mzdirs.scm
535 dnl Remove a trailing slash
536 [ vi_cv_path_mzscheme_pfx=`${vi_cv_path_mzscheme} -r mzdirs.scm | \
537 sed -e 's+/$++'` ])
538 rm -f mzdirs.scm
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000539 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000540 fi
541 fi
542
Bram Moolenaard7afed32007-05-06 13:26:41 +0000543 SCHEME_INC=
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000544 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
545 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include)
546 if test -f $vi_cv_path_mzscheme_pfx/include/scheme.h; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000547 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include
548 AC_MSG_RESULT(yes)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000549 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000550 AC_MSG_RESULT(no)
551 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt)
Bram Moolenaard7afed32007-05-06 13:26:41 +0000552 if test -f $vi_cv_path_mzscheme_pfx/include/plt/scheme.h; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000553 AC_MSG_RESULT(yes)
554 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt
Bram Moolenaard7afed32007-05-06 13:26:41 +0000555 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000556 AC_MSG_RESULT(no)
557 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/)
558 if test -f /usr/include/plt/scheme.h; then
559 AC_MSG_RESULT(yes)
560 SCHEME_INC=/usr/include/plt
561 else
562 AC_MSG_RESULT(no)
563 vi_cv_path_mzscheme_pfx=
564 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000565 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000566 fi
567 fi
568
569 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaarf15f9432007-06-28 11:07:21 +0000570 if test "x$MACOSX" = "xyes"; then
571 MZSCHEME_LIBS="-framework PLT_MzScheme"
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000572 elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"; then
573 MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"
574 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
Bram Moolenaarf15f9432007-06-28 11:07:21 +0000575 elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a"; then
Bram Moolenaar9048f942007-05-12 14:32:25 +0000576 MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libmzscheme.a ${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000577 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000578 dnl Using shared objects
579 if test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.so"; then
580 MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lmzscheme3m"
581 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
582 else
583 MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lmzscheme -lmzgc"
584 fi
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +0000585 if test "$GCC" = yes; then
586 dnl Make Vim remember the path to the library. For when it's not in
587 dnl $LD_LIBRARY_PATH.
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000588 MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${vi_cv_path_mzscheme_pfx}/lib"
Bram Moolenaar21cf8232004-07-16 20:18:37 +0000589 elif test "`(uname) 2>/dev/null`" = SunOS &&
590 uname -r | grep '^5' >/dev/null; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000591 MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${vi_cv_path_mzscheme_pfx}/lib"
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +0000592 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000593 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000594 if test -d $vi_cv_path_mzscheme_pfx/lib/plt/collects; then
595 SCHEME_COLLECTS=lib/plt/
596 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000597 if test -f "${vi_cv_path_mzscheme_pfx}/${SCHEME_COLLECTS}collects/scheme/base.ss" ; then
598 dnl need to generate bytecode for MzScheme base
599 MZSCHEME_EXTRA="mzscheme_base.c"
600 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE"
601 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
602 fi
603 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -I${SCHEME_INC} \
Bram Moolenaard7afed32007-05-06 13:26:41 +0000604 -DMZSCHEME_COLLECTS='\"${vi_cv_path_mzscheme_pfx}/${SCHEME_COLLECTS}collects\"'"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000605 MZSCHEME_SRC="if_mzsch.c"
606 MZSCHEME_OBJ="objects/if_mzsch.o"
607 MZSCHEME_PRO="if_mzsch.pro"
608 AC_DEFINE(FEAT_MZSCHEME)
609 fi
610 AC_SUBST(MZSCHEME_SRC)
611 AC_SUBST(MZSCHEME_OBJ)
612 AC_SUBST(MZSCHEME_PRO)
613 AC_SUBST(MZSCHEME_LIBS)
614 AC_SUBST(MZSCHEME_CFLAGS)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000615 AC_SUBST(MZSCHEME_EXTRA)
616 AC_SUBST(MZSCHEME_MZC)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000617fi
618
619
Bram Moolenaar071d4272004-06-13 20:20:40 +0000620AC_MSG_CHECKING(--enable-perlinterp argument)
621AC_ARG_ENABLE(perlinterp,
622 [ --enable-perlinterp Include Perl interpreter.], ,
623 [enable_perlinterp="no"])
624AC_MSG_RESULT($enable_perlinterp)
625if test "$enable_perlinterp" = "yes"; then
626 AC_SUBST(vi_cv_path_perl)
627 AC_PATH_PROG(vi_cv_path_perl, perl)
628 if test "X$vi_cv_path_perl" != "X"; then
629 AC_MSG_CHECKING(Perl version)
630 if $vi_cv_path_perl -e 'require 5.003_01' >/dev/null 2>/dev/null; then
631 eval `$vi_cv_path_perl -V:usethreads`
632 if test "X$usethreads" = "XUNKNOWN" -o "X$usethreads" = "Xundef"; then
633 badthreads=no
634 else
635 if $vi_cv_path_perl -e 'require 5.6.0' >/dev/null 2>/dev/null; then
636 eval `$vi_cv_path_perl -V:use5005threads`
637 if test "X$use5005threads" = "XUNKNOWN" -o "X$use5005threads" = "Xundef"; then
638 badthreads=no
639 else
640 badthreads=yes
641 AC_MSG_RESULT(>>> Perl > 5.6 with 5.5 threads cannot be used <<<)
642 fi
643 else
644 badthreads=yes
645 AC_MSG_RESULT(>>> Perl 5.5 with threads cannot be used <<<)
646 fi
647 fi
648 if test $badthreads = no; then
649 AC_MSG_RESULT(OK)
650 eval `$vi_cv_path_perl -V:shrpenv`
651 if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04
652 shrpenv=""
653 fi
654 vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlibexp}'`
655 AC_SUBST(vi_cv_perllib)
656 dnl Remove "-fno-something", it breaks using cproto.
657 perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
658 -e 'ccflags;perl_inc;print"\n"' | sed -e 's/-fno[[^ ]]*//'`
659 dnl Remove "-lc", it breaks on FreeBSD when using "-pthread".
660 perllibs=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed -e 'ldopts' | \
661 sed -e '/Warning/d' -e '/Note (probably harmless)/d' \
662 -e 's/-bE:perl.exp//' -e 's/-lc //'`
663 dnl Don't add perl lib to $LIBS: if it's not in LD_LIBRARY_PATH
664 dnl a test in configure may fail because of that.
665 perlldflags=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed \
666 -e 'ccdlflags' | sed -e 's/-bE:perl.exp//'`
667
668 dnl check that compiling a simple program still works with the flags
669 dnl added for Perl.
670 AC_MSG_CHECKING([if compile and link flags for Perl are sane])
671 cflags_save=$CFLAGS
672 libs_save=$LIBS
673 ldflags_save=$LDFLAGS
674 CFLAGS="$CFLAGS $perlcppflags"
675 LIBS="$LIBS $perllibs"
676 LDFLAGS="$perlldflags $LDFLAGS"
677 AC_TRY_LINK(,[ ],
678 AC_MSG_RESULT(yes); perl_ok=yes,
679 AC_MSG_RESULT(no: PERL DISABLED); perl_ok=no)
680 CFLAGS=$cflags_save
681 LIBS=$libs_save
682 LDFLAGS=$ldflags_save
683 if test $perl_ok = yes; then
684 if test "X$perlcppflags" != "X"; then
Bram Moolenaard7afed32007-05-06 13:26:41 +0000685 dnl remove -pipe and -Wxxx, it confuses cproto
686 PERL_CFLAGS=`echo "$perlcppflags" | sed -e 's/-pipe //' -e 's/-W[[^ ]]*//'`
Bram Moolenaar071d4272004-06-13 20:20:40 +0000687 fi
688 if test "X$perlldflags" != "X"; then
689 LDFLAGS="$perlldflags $LDFLAGS"
690 fi
691 PERL_LIBS=$perllibs
692 PERL_SRC="auto/if_perl.c if_perlsfio.c"
693 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o"
694 PERL_PRO="if_perl.pro if_perlsfio.pro"
695 AC_DEFINE(FEAT_PERL)
696 fi
697 fi
698 else
699 AC_MSG_RESULT(>>> too old; need Perl version 5.003_01 or later <<<)
700 fi
701 fi
702
703 if test "x$MACOSX" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +0000704 dnl Mac OS X 10.2 or later
Bram Moolenaar071d4272004-06-13 20:20:40 +0000705 dir=/System/Library/Perl
706 darwindir=$dir/darwin
707 if test -d $darwindir; then
708 PERL=/usr/bin/perl
709 else
710 dnl Mac OS X 10.3
711 dir=/System/Library/Perl/5.8.1
712 darwindir=$dir/darwin-thread-multi-2level
713 if test -d $darwindir; then
714 PERL=/usr/bin/perl
715 fi
716 fi
717 if test -n "$PERL"; then
718 PERL_DIR="$dir"
719 PERL_CFLAGS="-DFEAT_PERL -I$darwindir/CORE"
720 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o $darwindir/auto/DynaLoader/DynaLoader.a"
721 PERL_LIBS="-L$darwindir/CORE -lperl"
722 fi
723 fi
724fi
725AC_SUBST(shrpenv)
726AC_SUBST(PERL_SRC)
727AC_SUBST(PERL_OBJ)
728AC_SUBST(PERL_PRO)
729AC_SUBST(PERL_CFLAGS)
730AC_SUBST(PERL_LIBS)
731
732AC_MSG_CHECKING(--enable-pythoninterp argument)
733AC_ARG_ENABLE(pythoninterp,
734 [ --enable-pythoninterp Include Python interpreter.], ,
735 [enable_pythoninterp="no"])
736AC_MSG_RESULT($enable_pythoninterp)
737if test "$enable_pythoninterp" = "yes"; then
738 dnl -- find the python executable
739 AC_PATH_PROG(vi_cv_path_python, python)
740 if test "X$vi_cv_path_python" != "X"; then
741
742 dnl -- get its version number
743 AC_CACHE_CHECK(Python version,vi_cv_var_python_version,
744 [[vi_cv_var_python_version=`
745 ${vi_cv_path_python} -c 'import sys; print sys.version[:3]'`
746 ]])
747
748 dnl -- it must be at least version 1.4
749 AC_MSG_CHECKING(Python is 1.4 or better)
750 if ${vi_cv_path_python} -c \
751 "import sys; sys.exit(${vi_cv_var_python_version} < 1.4)"
752 then
753 AC_MSG_RESULT(yep)
754
755 dnl -- find where python thinks it was installed
756 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python_pfx,
757 [ vi_cv_path_python_pfx=`
758 ${vi_cv_path_python} -c \
759 "import sys; print sys.prefix"` ])
760
761 dnl -- and where it thinks it runs
762 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python_epfx,
763 [ vi_cv_path_python_epfx=`
764 ${vi_cv_path_python} -c \
765 "import sys; print sys.exec_prefix"` ])
766
767 dnl -- python's internal library path
768
769 AC_CACHE_VAL(vi_cv_path_pythonpath,
770 [ vi_cv_path_pythonpath=`
771 unset PYTHONPATH;
772 ${vi_cv_path_python} -c \
773 "import sys, string; print string.join(sys.path,':')"` ])
774
775 dnl -- where the Python implementation library archives are
776
777 AC_ARG_WITH(python-config-dir,
778 [ --with-python-config-dir=PATH Python's config directory],
779 [ vi_cv_path_python_conf="${withval}" ] )
780
781 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python_conf,
782 [
783 vi_cv_path_python_conf=
784 for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
Bram Moolenaar72951072009-12-02 16:58:33 +0000785 for subdir in lib64 lib share; do
Bram Moolenaar071d4272004-06-13 20:20:40 +0000786 d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
787 if test -d "$d" && test -f "$d/config.c"; then
788 vi_cv_path_python_conf="$d"
789 fi
790 done
791 done
792 ])
793
794 PYTHON_CONFDIR="${vi_cv_path_python_conf}"
795
796 if test "X$PYTHON_CONFDIR" = "X"; then
797 AC_MSG_RESULT([can't find it!])
798 else
799
800 dnl -- we need to examine Python's config/Makefile too
801 dnl see what the interpreter is built from
802 AC_CACHE_VAL(vi_cv_path_python_plibs,
803 [
Bram Moolenaar01dd60c2008-07-24 14:24:48 +0000804 pwd=`pwd`
805 tmp_mkf="$pwd/config-PyMake$$"
806 cat -- "${PYTHON_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000807__:
Bram Moolenaar218116c2010-05-20 21:46:00 +0200808 @echo "python_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000809 @echo "python_LIBS='$(LIBS)'"
810 @echo "python_SYSLIBS='$(SYSLIBS)'"
811 @echo "python_LINKFORSHARED='$(LINKFORSHARED)'"
812eof
813 dnl -- delete the lines from make about Entering/Leaving directory
Bram Moolenaar01dd60c2008-07-24 14:24:48 +0000814 eval "`cd ${PYTHON_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
815 rm -f -- "${tmp_mkf}"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000816 if test "x$MACOSX" = "xyes" && ${vi_cv_path_python} -c \
817 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then
818 vi_cv_path_python_plibs="-framework Python"
819 else
820 if test "${vi_cv_var_python_version}" = "1.4"; then
821 vi_cv_path_python_plibs="${PYTHON_CONFDIR}/libModules.a ${PYTHON_CONFDIR}/libPython.a ${PYTHON_CONFDIR}/libObjects.a ${PYTHON_CONFDIR}/libParser.a"
822 else
823 vi_cv_path_python_plibs="-L${PYTHON_CONFDIR} -lpython${vi_cv_var_python_version}"
824 fi
Bram Moolenaar218116c2010-05-20 21:46:00 +0200825 vi_cv_path_python_plibs="${vi_cv_path_python_plibs} ${python_BASEMODLIBS} ${python_LIBS} ${python_SYSLIBS} ${python_LINKFORSHARED}"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000826 dnl remove -ltermcap, it can conflict with an earlier -lncurses
827 vi_cv_path_python_plibs=`echo $vi_cv_path_python_plibs | sed s/-ltermcap//`
828 fi
829 ])
830
831 PYTHON_LIBS="${vi_cv_path_python_plibs}"
832 if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
833 PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version}"
834 else
835 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}"
836 fi
837 PYTHON_SRC="if_python.c"
838 dnl For Mac OSX 10.2 config.o is included in the Python library.
839 if test "x$MACOSX" = "xyes"; then
840 PYTHON_OBJ="objects/if_python.o"
841 else
842 PYTHON_OBJ="objects/if_python.o objects/py_config.o"
843 fi
844 if test "${vi_cv_var_python_version}" = "1.4"; then
845 PYTHON_OBJ="$PYTHON_OBJ objects/py_getpath.o"
846 fi
847 PYTHON_GETPATH_CFLAGS="-DPYTHONPATH='\"${vi_cv_path_pythonpath}\"' -DPREFIX='\"${vi_cv_path_python_pfx}\"' -DEXEC_PREFIX='\"${vi_cv_path_python_epfx}\"'"
848
849 dnl On FreeBSD linking with "-pthread" is required to use threads.
850 dnl _THREAD_SAFE must be used for compiling then.
851 dnl The "-pthread" is added to $LIBS, so that the following check for
852 dnl sigaltstack() will look in libc_r (it's there in libc!).
853 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
854 dnl will then define target-specific defines, e.g., -D_REENTRANT.
855 dnl Don't do this for Mac OSX, -pthread will generate a warning.
856 AC_MSG_CHECKING([if -pthread should be used])
857 threadsafe_flag=
858 thread_lib=
Bram Moolenaara1b5aa52006-10-10 09:41:28 +0000859 dnl if test "x$MACOSX" != "xyes"; then
860 if test "`(uname) 2>/dev/null`" != Darwin; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000861 test "$GCC" = yes && threadsafe_flag="-pthread"
862 if test "`(uname) 2>/dev/null`" = FreeBSD; then
863 threadsafe_flag="-D_THREAD_SAFE"
864 thread_lib="-pthread"
865 fi
866 fi
867 libs_save_old=$LIBS
868 if test -n "$threadsafe_flag"; then
869 cflags_save=$CFLAGS
870 CFLAGS="$CFLAGS $threadsafe_flag"
871 LIBS="$LIBS $thread_lib"
872 AC_TRY_LINK(,[ ],
Bram Moolenaar69f787a2010-07-11 20:52:58 +0200873 AC_MSG_RESULT(yes); PYTHON_CFLAGS="$PYTHON_CFLAGS $threadsafe_flag",
Bram Moolenaar071d4272004-06-13 20:20:40 +0000874 AC_MSG_RESULT(no); LIBS=$libs_save_old
875 )
876 CFLAGS=$cflags_save
877 else
878 AC_MSG_RESULT(no)
879 fi
880
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +0200881 dnl Check that compiling a simple program still works with the flags
Bram Moolenaar071d4272004-06-13 20:20:40 +0000882 dnl added for Python.
883 AC_MSG_CHECKING([if compile and link flags for Python are sane])
884 cflags_save=$CFLAGS
885 libs_save=$LIBS
Bram Moolenaar69f787a2010-07-11 20:52:58 +0200886 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000887 LIBS="$LIBS $PYTHON_LIBS"
888 AC_TRY_LINK(,[ ],
889 AC_MSG_RESULT(yes); python_ok=yes,
890 AC_MSG_RESULT(no: PYTHON DISABLED); python_ok=no)
891 CFLAGS=$cflags_save
892 LIBS=$libs_save
893 if test $python_ok = yes; then
894 AC_DEFINE(FEAT_PYTHON)
895 else
896 LIBS=$libs_save_old
897 PYTHON_SRC=
898 PYTHON_OBJ=
899 PYTHON_LIBS=
900 PYTHON_CFLAGS=
901 fi
902
903 fi
904 else
905 AC_MSG_RESULT(too old)
906 fi
907 fi
908fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +0200909
Bram Moolenaar071d4272004-06-13 20:20:40 +0000910AC_SUBST(PYTHON_CONFDIR)
911AC_SUBST(PYTHON_LIBS)
912AC_SUBST(PYTHON_GETPATH_CFLAGS)
913AC_SUBST(PYTHON_CFLAGS)
914AC_SUBST(PYTHON_SRC)
915AC_SUBST(PYTHON_OBJ)
916
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +0200917
918AC_MSG_CHECKING(--enable-python3interp argument)
919AC_ARG_ENABLE(python3interp,
920 [ --enable-python3interp Include Python3 interpreter.], ,
921 [enable_python3interp="no"])
922AC_MSG_RESULT($enable_python3interp)
923if test "$enable_python3interp" = "yes"; then
924 dnl -- find the python3 executable
925 AC_PATH_PROG(vi_cv_path_python3, python3)
926 if test "X$vi_cv_path_python3" != "X"; then
927
928 dnl -- get its version number
929 AC_CACHE_CHECK(Python version,vi_cv_var_python3_version,
930 [[vi_cv_var_python3_version=`
931 ${vi_cv_path_python3} -c 'import sys; print(sys.version[1:3])'`
932 ]])
933
934 dnl -- find where python3 thinks it was installed
935 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx,
936 [ vi_cv_path_python3_pfx=`
937 ${vi_cv_path_python3} -c \
938 "import sys; print(sys.prefix)"` ])
939
940 dnl -- and where it thinks it runs
941 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx,
942 [ vi_cv_path_python3_epfx=`
943 ${vi_cv_path_python3} -c \
944 "import sys; print(sys.exec_prefix)"` ])
945
946 dnl -- python3's internal library path
947
948 AC_CACHE_VAL(vi_cv_path_python3path,
949 [ vi_cv_path_python3path=`
950 unset PYTHONPATH;
951 ${vi_cv_path_python3} -c \
952 "import sys, string; print(':'.join(sys.path))"` ])
953
954 dnl -- where the Python implementation library archives are
955
956 AC_ARG_WITH(python3-config-dir,
957 [ --with-python3-config-dir=PATH Python's config directory],
958 [ vi_cv_path_python3_conf="${withval}" ] )
959
960 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf,
961 [
962 vi_cv_path_python3_conf=
963 for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do
964 for subdir in lib share; do
965 d="${path}/${subdir}/python3${vi_cv_var_python3_version}/config"
966 if test -d "$d" && test -f "$d/config.c"; then
967 vi_cv_path_python3_conf="$d"
968 fi
969 done
970 done
971 ])
972
973 PYTHON3_CONFDIR="${vi_cv_path_python3_conf}"
974
975 if test "X$PYTHON3_CONFDIR" = "X"; then
976 AC_MSG_RESULT([can't find it!])
977 else
978
979 dnl -- we need to examine Python's config/Makefile too
980 dnl see what the interpreter is built from
981 AC_CACHE_VAL(vi_cv_path_python3_plibs,
982 [
983 pwd=`pwd`
984 tmp_mkf="$pwd/config-PyMake$$"
985 cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
986__:
987 @echo "python3_MODLIBS='$(MODLIBS)'"
988 @echo "python3_LIBS='$(LIBS)'"
989 @echo "python3_SYSLIBS='$(SYSLIBS)'"
990 @echo "python3_LINKFORSHARED='$(LINKFORSHARED)'"
991eof
992 dnl -- delete the lines from make about Entering/Leaving directory
993 eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
994 rm -f -- "${tmp_mkf}"
995 vi_cv_path_python3_plibs="-L${PYTHON3_CONFDIR} -lpython3${vi_cv_var_python3_version}"
996 vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_MODLIBS} ${python3_LIBS} ${python3_SYSLIBS} ${python3_LINKFORSHARED}"
997 dnl remove -ltermcap, it can conflict with an earlier -lncurses
998 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//`
999 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//`
1000 ])
1001
1002 PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
1003 if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
1004 PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python3${vi_cv_var_python3_version}"
1005 else
1006 PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python3${vi_cv_var_python3_version} -I${vi_cv_path_python3_epfx}/include/python3${vi_cv_var_python3_version}"
1007 fi
1008 PYTHON3_SRC="if_python3.c"
1009 dnl For Mac OSX 10.2 config.o is included in the Python library.
1010 if test "x$MACOSX" = "xyes"; then
1011 PYTHON3_OBJ="objects/if_python3.o"
1012 else
1013 PYTHON3_OBJ="objects/if_python3.o objects/py3_config.o"
1014 fi
1015
1016 dnl On FreeBSD linking with "-pthread" is required to use threads.
1017 dnl _THREAD_SAFE must be used for compiling then.
1018 dnl The "-pthread" is added to $LIBS, so that the following check for
1019 dnl sigaltstack() will look in libc_r (it's there in libc!).
1020 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1021 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1022 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1023 AC_MSG_CHECKING([if -pthread should be used])
1024 threadsafe_flag=
1025 thread_lib=
1026 dnl if test "x$MACOSX" != "xyes"; then
1027 if test "`(uname) 2>/dev/null`" != Darwin; then
1028 test "$GCC" = yes && threadsafe_flag="-pthread"
1029 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1030 threadsafe_flag="-D_THREAD_SAFE"
1031 thread_lib="-pthread"
1032 fi
1033 fi
1034 libs_save_old=$LIBS
1035 if test -n "$threadsafe_flag"; then
1036 cflags_save=$CFLAGS
1037 CFLAGS="$CFLAGS $threadsafe_flag"
1038 LIBS="$LIBS $thread_lib"
1039 AC_TRY_LINK(,[ ],
1040 AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag",
1041 AC_MSG_RESULT(no); LIBS=$libs_save_old
1042 )
1043 CFLAGS=$cflags_save
1044 else
1045 AC_MSG_RESULT(no)
1046 fi
1047
1048 dnl check that compiling a simple program still works with the flags
1049 dnl added for Python.
1050 AC_MSG_CHECKING([if compile and link flags for Python are sane])
1051 cflags_save=$CFLAGS
1052 libs_save=$LIBS
1053 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1054 LIBS="$LIBS $PYTHON3_LIBS"
1055 AC_TRY_LINK(,[ ],
1056 AC_MSG_RESULT(yes); python3_ok=yes,
1057 AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no)
1058 CFLAGS=$cflags_save
1059 LIBS=$libs_save
1060 if test "$python3_ok" = yes; then
1061 AC_DEFINE(FEAT_PYTHON3)
1062 else
1063 LIBS=$libs_save_old
1064 PYTHON3_SRC=
1065 PYTHON3_OBJ=
1066 PYTHON3_LIBS=
1067 PYTHON3_CFLAGS=
1068 fi
1069 fi
1070 fi
1071fi
1072
1073AC_SUBST(PYTHON3_CONFDIR)
1074AC_SUBST(PYTHON3_LIBS)
1075AC_SUBST(PYTHON3_CFLAGS)
1076AC_SUBST(PYTHON3_SRC)
1077AC_SUBST(PYTHON3_OBJ)
1078
1079dnl if python2.x and python3.x are enabled one can only link in code
1080dnl with dlopen(), dlsym(), dlclose()
1081if test "$python_ok" = yes && test "$python3_ok" = yes; then
1082 AC_DEFINE(DYNAMIC_PYTHON)
1083 AC_DEFINE(DYNAMIC_PYTHON3)
1084 PYTHON_SRC="if_python.c"
1085 PYTHON_OBJ="objects/if_python.o"
1086 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"libpython${vi_cv_var_python_version}.so\\\""
1087 PYTHON_LIBS=
1088 PYTHON3_SRC="if_python3.c"
1089 PYTHON3_OBJ="objects/if_python3.o"
1090 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"libpython3${vi_cv_var_python3_version}.so\\\""
1091 PYTHON3_LIBS=
1092fi
1093
Bram Moolenaar071d4272004-06-13 20:20:40 +00001094AC_MSG_CHECKING(--enable-tclinterp argument)
1095AC_ARG_ENABLE(tclinterp,
1096 [ --enable-tclinterp Include Tcl interpreter.], ,
1097 [enable_tclinterp="no"])
1098AC_MSG_RESULT($enable_tclinterp)
1099
1100if test "$enable_tclinterp" = "yes"; then
1101
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001102 dnl on FreeBSD tclsh is a silly script, look for tclsh8.[5420]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001103 AC_MSG_CHECKING(--with-tclsh argument)
1104 AC_ARG_WITH(tclsh, [ --with-tclsh=PATH which tclsh to use (default: tclsh8.0)],
1105 tclsh_name="$withval"; AC_MSG_RESULT($tclsh_name),
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001106 tclsh_name="tclsh8.5"; AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00001107 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1108 AC_SUBST(vi_cv_path_tcl)
1109
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001110 dnl when no specific version specified, also try 8.4, 8.2 and 8.0
1111 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.5"; then
1112 tclsh_name="tclsh8.4"
1113 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1114 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001115 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.4"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001116 tclsh_name="tclsh8.2"
1117 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1118 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001119 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.2"; then
1120 tclsh_name="tclsh8.0"
1121 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1122 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001123 dnl still didn't find it, try without version number
1124 if test "X$vi_cv_path_tcl" = "X"; then
1125 tclsh_name="tclsh"
1126 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1127 fi
1128 if test "X$vi_cv_path_tcl" != "X"; then
1129 AC_MSG_CHECKING(Tcl version)
1130 if echo 'exit [[expr [info tclversion] < 8.0]]' | $vi_cv_path_tcl - ; then
1131 tclver=`echo 'puts [[info tclversion]]' | $vi_cv_path_tcl -`
1132 AC_MSG_RESULT($tclver - OK);
1133 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 -`
1134
1135 AC_MSG_CHECKING(for location of Tcl include)
1136 if test "x$MACOSX" != "xyes"; then
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001137 tclinc="$tclloc/include $tclloc/include/tcl $tclloc/include/tcl$tclver /usr/local/include /usr/local/include/tcl$tclver /usr/include /usr/include/tcl$tclver"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001138 else
1139 dnl For Mac OS X 10.3, use the OS-provided framework location
1140 tclinc="/System/Library/Frameworks/Tcl.framework/Headers"
1141 fi
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001142 TCL_INC=
Bram Moolenaar071d4272004-06-13 20:20:40 +00001143 for try in $tclinc; do
1144 if test -f "$try/tcl.h"; then
1145 AC_MSG_RESULT($try/tcl.h)
1146 TCL_INC=$try
1147 break
1148 fi
1149 done
1150 if test -z "$TCL_INC"; then
1151 AC_MSG_RESULT(<not found>)
1152 SKIP_TCL=YES
1153 fi
1154 if test -z "$SKIP_TCL"; then
1155 AC_MSG_CHECKING(for location of tclConfig.sh script)
1156 if test "x$MACOSX" != "xyes"; then
1157 tclcnf=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001158 tclcnf="$tclcnf `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001159 else
1160 dnl For Mac OS X 10.3, use the OS-provided framework location
1161 tclcnf="/System/Library/Frameworks/Tcl.framework"
1162 fi
1163 for try in $tclcnf; do
1164 if test -f $try/tclConfig.sh; then
1165 AC_MSG_RESULT($try/tclConfig.sh)
1166 . $try/tclConfig.sh
1167 dnl use eval, because tcl 8.2 includes ${TCL_DBGX}
1168 TCL_LIBS=`eval echo "$TCL_LIB_SPEC $TCL_LIBS"`
1169 dnl Use $TCL_DEFS for -D_THREAD_SAFE et al. But only use the
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001170 dnl "-D_ABC" items. Watch out for -DFOO=long\ long.
Bram Moolenaar4394bff2008-07-24 11:21:31 +00001171 TCL_DEFS=`echo $TCL_DEFS | sed -e 's/\\\\ /\\\\X/g' | tr ' ' '\012' | sed -e '/^[[^-]]/d' -e '/^-[[^D]]/d' -e '/-D[[^_]]/d' -e 's/-D_/ -D_/' | tr '\012' ' ' | sed -e 's/\\\\X/\\\\ /g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001172 break
1173 fi
1174 done
1175 if test -z "$TCL_LIBS"; then
1176 AC_MSG_RESULT(<not found>)
1177 AC_MSG_CHECKING(for Tcl library by myself)
1178 tcllib=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001179 tcllib="$tcllib `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001180 for ext in .so .a ; do
1181 for ver in "" $tclver ; do
1182 for try in $tcllib ; do
1183 trylib=tcl$ver$ext
1184 if test -f $try/lib$trylib ; then
1185 AC_MSG_RESULT($try/lib$trylib)
1186 TCL_LIBS="-L$try -ltcl$ver -ldl -lm"
1187 if test "`(uname) 2>/dev/null`" = SunOS &&
1188 uname -r | grep '^5' >/dev/null; then
1189 TCL_LIBS="$TCL_LIBS -R $try"
1190 fi
1191 break 3
1192 fi
1193 done
1194 done
1195 done
1196 if test -z "$TCL_LIBS"; then
1197 AC_MSG_RESULT(<not found>)
1198 SKIP_TCL=YES
1199 fi
1200 fi
1201 if test -z "$SKIP_TCL"; then
1202 AC_DEFINE(FEAT_TCL)
1203 TCL_SRC=if_tcl.c
1204 TCL_OBJ=objects/if_tcl.o
1205 TCL_PRO=if_tcl.pro
1206 TCL_CFLAGS="-I$TCL_INC $TCL_DEFS"
1207 fi
1208 fi
1209 else
1210 AC_MSG_RESULT(too old; need Tcl version 8.0 or later)
1211 fi
1212 fi
1213fi
1214AC_SUBST(TCL_SRC)
1215AC_SUBST(TCL_OBJ)
1216AC_SUBST(TCL_PRO)
1217AC_SUBST(TCL_CFLAGS)
1218AC_SUBST(TCL_LIBS)
1219
1220AC_MSG_CHECKING(--enable-rubyinterp argument)
1221AC_ARG_ENABLE(rubyinterp,
1222 [ --enable-rubyinterp Include Ruby interpreter.], ,
1223 [enable_rubyinterp="no"])
1224AC_MSG_RESULT($enable_rubyinterp)
1225if test "$enable_rubyinterp" = "yes"; then
Bram Moolenaar165641d2010-02-17 16:23:09 +01001226 AC_MSG_CHECKING(--with-ruby-command argument)
1227 AC_ARG_WITH(ruby-command, [ --with-ruby-command=RUBY name of the Ruby command (default: ruby)],
1228 RUBY_CMD="$withval"; AC_MSG_RESULT($RUBY_CMD),
1229 RUBY_CMD="ruby"; AC_MSG_RESULT(defaulting to $RUBY_CMD))
Bram Moolenaar071d4272004-06-13 20:20:40 +00001230 AC_SUBST(vi_cv_path_ruby)
Bram Moolenaar165641d2010-02-17 16:23:09 +01001231 AC_PATH_PROG(vi_cv_path_ruby, $RUBY_CMD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001232 if test "X$vi_cv_path_ruby" != "X"; then
1233 AC_MSG_CHECKING(Ruby version)
Bram Moolenaare4efc3b2005-03-07 23:16:51 +00001234 if $vi_cv_path_ruby -e '(VERSION rescue RUBY_VERSION) >= "1.6.0" or exit 1' >/dev/null 2>/dev/null; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001235 AC_MSG_RESULT(OK)
1236 AC_MSG_CHECKING(Ruby header files)
Bram Moolenaar165641d2010-02-17 16:23:09 +01001237 rubyhdrdir=`$vi_cv_path_ruby -r mkmf -e 'print Config::CONFIG[["rubyhdrdir"]] || Config::CONFIG[["archdir"]] || $hdrdir' 2>/dev/null`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001238 if test "X$rubyhdrdir" != "X"; then
1239 AC_MSG_RESULT($rubyhdrdir)
1240 RUBY_CFLAGS="-I$rubyhdrdir"
Bram Moolenaar165641d2010-02-17 16:23:09 +01001241 rubyarch=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG[["arch"]]'`
1242 if test -d "$rubyhdrdir/$rubyarch"; then
1243 RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyhdrdir/$rubyarch"
1244 fi
1245 rubyversion=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG[["ruby_version"]].gsub(/\./, "")[[0,2]]'`
1246 RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001247 rubylibs=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG[["LIBS"]]'`
1248 if test "X$rubylibs" != "X"; then
1249 RUBY_LIBS="$rubylibs"
1250 fi
1251 librubyarg=`$vi_cv_path_ruby -r rbconfig -e 'print Config.expand(Config::CONFIG[["LIBRUBYARG"]])'`
1252 if test -f "$rubyhdrdir/$librubyarg"; then
1253 librubyarg="$rubyhdrdir/$librubyarg"
1254 else
1255 rubylibdir=`$vi_cv_path_ruby -r rbconfig -e 'print Config.expand(Config::CONFIG[["libdir"]])'`
1256 if test -f "$rubylibdir/$librubyarg"; then
1257 librubyarg="$rubylibdir/$librubyarg"
1258 elif test "$librubyarg" = "libruby.a"; then
1259 dnl required on Mac OS 10.3 where libruby.a doesn't exist
1260 librubyarg="-lruby"
1261 else
1262 librubyarg=`$vi_cv_path_ruby -r rbconfig -e "print '$librubyarg'.gsub(/-L\./, %'-L#{Config.expand(Config::CONFIG[\"libdir\"])}')"`
1263 fi
1264 fi
1265
1266 if test "X$librubyarg" != "X"; then
1267 RUBY_LIBS="$librubyarg $RUBY_LIBS"
1268 fi
1269 rubyldflags=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG[["LDFLAGS"]]'`
1270 if test "X$rubyldflags" != "X"; then
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001271 dnl Ruby on Mac OS X 10.5 adds "-arch" flags but these should only
1272 dnl be included if requested by passing --with-mac-arch to
1273 dnl configure, so strip these flags first (if present)
1274 rubyldflags=`echo "$rubyldflags" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//'`
1275 if test "X$rubyldflags" != "X"; then
1276 LDFLAGS="$rubyldflags $LDFLAGS"
1277 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001278 fi
1279 RUBY_SRC="if_ruby.c"
1280 RUBY_OBJ="objects/if_ruby.o"
1281 RUBY_PRO="if_ruby.pro"
1282 AC_DEFINE(FEAT_RUBY)
1283 else
Bram Moolenaar165641d2010-02-17 16:23:09 +01001284 AC_MSG_RESULT(not found; disabling Ruby)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001285 fi
1286 else
1287 AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
1288 fi
1289 fi
1290fi
1291AC_SUBST(RUBY_SRC)
1292AC_SUBST(RUBY_OBJ)
1293AC_SUBST(RUBY_PRO)
1294AC_SUBST(RUBY_CFLAGS)
1295AC_SUBST(RUBY_LIBS)
1296
1297AC_MSG_CHECKING(--enable-cscope argument)
1298AC_ARG_ENABLE(cscope,
1299 [ --enable-cscope Include cscope interface.], ,
1300 [enable_cscope="no"])
1301AC_MSG_RESULT($enable_cscope)
1302if test "$enable_cscope" = "yes"; then
1303 AC_DEFINE(FEAT_CSCOPE)
1304fi
1305
1306AC_MSG_CHECKING(--enable-workshop argument)
1307AC_ARG_ENABLE(workshop,
1308 [ --enable-workshop Include Sun Visual Workshop support.], ,
1309 [enable_workshop="no"])
1310AC_MSG_RESULT($enable_workshop)
1311if test "$enable_workshop" = "yes"; then
1312 AC_DEFINE(FEAT_SUN_WORKSHOP)
1313 WORKSHOP_SRC="workshop.c integration.c"
1314 AC_SUBST(WORKSHOP_SRC)
1315 WORKSHOP_OBJ="objects/workshop.o objects/integration.o"
1316 AC_SUBST(WORKSHOP_OBJ)
1317 if test "${enable_gui-xxx}" = xxx; then
1318 enable_gui=motif
1319 fi
1320fi
1321
1322AC_MSG_CHECKING(--disable-netbeans argument)
1323AC_ARG_ENABLE(netbeans,
1324 [ --disable-netbeans Disable NetBeans integration support.],
1325 , [enable_netbeans="yes"])
1326if test "$enable_netbeans" = "yes"; then
1327 AC_MSG_RESULT(no)
1328 dnl On Solaris we need the socket and nsl library.
1329 AC_CHECK_LIB(socket, socket)
1330 AC_CHECK_LIB(nsl, gethostbyname)
1331 AC_MSG_CHECKING(whether compiling netbeans integration is possible)
1332 AC_TRY_LINK([
1333#include <stdio.h>
1334#include <stdlib.h>
1335#include <stdarg.h>
1336#include <fcntl.h>
1337#include <netdb.h>
1338#include <netinet/in.h>
1339#include <errno.h>
1340#include <sys/types.h>
1341#include <sys/socket.h>
1342 /* Check bitfields */
1343 struct nbbuf {
1344 unsigned int initDone:1;
1345 ushort signmaplen;
1346 };
1347 ], [
1348 /* Check creating a socket. */
1349 struct sockaddr_in server;
1350 (void)socket(AF_INET, SOCK_STREAM, 0);
1351 (void)htons(100);
1352 (void)gethostbyname("microsoft.com");
1353 if (errno == ECONNREFUSED)
1354 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
1355 ],
1356 AC_MSG_RESULT(yes),
1357 AC_MSG_RESULT(no); enable_netbeans="no")
1358else
1359 AC_MSG_RESULT(yes)
1360fi
1361if test "$enable_netbeans" = "yes"; then
1362 AC_DEFINE(FEAT_NETBEANS_INTG)
1363 NETBEANS_SRC="netbeans.c"
1364 AC_SUBST(NETBEANS_SRC)
1365 NETBEANS_OBJ="objects/netbeans.o"
1366 AC_SUBST(NETBEANS_OBJ)
1367fi
1368
1369AC_MSG_CHECKING(--enable-sniff argument)
1370AC_ARG_ENABLE(sniff,
1371 [ --enable-sniff Include Sniff interface.], ,
1372 [enable_sniff="no"])
1373AC_MSG_RESULT($enable_sniff)
1374if test "$enable_sniff" = "yes"; then
1375 AC_DEFINE(FEAT_SNIFF)
1376 SNIFF_SRC="if_sniff.c"
1377 AC_SUBST(SNIFF_SRC)
1378 SNIFF_OBJ="objects/if_sniff.o"
1379 AC_SUBST(SNIFF_OBJ)
1380fi
1381
1382AC_MSG_CHECKING(--enable-multibyte argument)
1383AC_ARG_ENABLE(multibyte,
1384 [ --enable-multibyte Include multibyte editing support.], ,
1385 [enable_multibyte="no"])
1386AC_MSG_RESULT($enable_multibyte)
1387if test "$enable_multibyte" = "yes"; then
1388 AC_DEFINE(FEAT_MBYTE)
1389fi
1390
1391AC_MSG_CHECKING(--enable-hangulinput argument)
1392AC_ARG_ENABLE(hangulinput,
1393 [ --enable-hangulinput Include Hangul input support.], ,
1394 [enable_hangulinput="no"])
1395AC_MSG_RESULT($enable_hangulinput)
1396
1397AC_MSG_CHECKING(--enable-xim argument)
1398AC_ARG_ENABLE(xim,
1399 [ --enable-xim Include XIM input support.],
1400 AC_MSG_RESULT($enable_xim),
1401 [enable_xim="auto"; AC_MSG_RESULT(defaulting to auto)])
Bram Moolenaar071d4272004-06-13 20:20:40 +00001402
1403AC_MSG_CHECKING(--enable-fontset argument)
1404AC_ARG_ENABLE(fontset,
1405 [ --enable-fontset Include X fontset output support.], ,
1406 [enable_fontset="no"])
1407AC_MSG_RESULT($enable_fontset)
1408dnl defining FEAT_XFONTSET is delayed, so that it can be disabled for no GUI
1409
1410test -z "$with_x" && with_x=yes
1411test "${enable_gui-yes}" != no -a "x$MACOSX" != "xyes" -a "x$QNX" != "xyes" && with_x=yes
1412if test "$with_x" = no; then
1413 AC_MSG_RESULT(defaulting to: don't HAVE_X11)
1414else
1415 dnl Do this check early, so that its failure can override user requests.
1416
1417 AC_PATH_PROG(xmkmfpath, xmkmf)
1418
1419 AC_PATH_XTRA
1420
Bram Moolenaar2c704a72010-06-03 21:17:25 +02001421 dnl On z/OS Unix the X libraries are DLLs. To use them the code must
Bram Moolenaar071d4272004-06-13 20:20:40 +00001422 dnl be compiled with a special option.
1423 dnl Also add SM, ICE and Xmu to X_EXTRA_LIBS.
Bram Moolenaar2c704a72010-06-03 21:17:25 +02001424 if test "$zOSUnix" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001425 CFLAGS="$CFLAGS -W c,dll"
1426 LDFLAGS="$LDFLAGS -W l,dll"
1427 X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE -lXmu"
1428 fi
1429
1430 dnl On my HPUX system the X include dir is found, but the lib dir not.
1431 dnl This is a desparate try to fix this.
1432
1433 if test -d "$x_includes" && test ! -d "$x_libraries"; then
1434 x_libraries=`echo "$x_includes" | sed s/include/lib/`
1435 AC_MSG_RESULT(Corrected X libraries to $x_libraries)
1436 X_LIBS="$X_LIBS -L$x_libraries"
1437 if test "`(uname) 2>/dev/null`" = SunOS &&
1438 uname -r | grep '^5' >/dev/null; then
1439 X_LIBS="$X_LIBS -R $x_libraries"
1440 fi
1441 fi
1442
1443 if test -d "$x_libraries" && test ! -d "$x_includes"; then
1444 x_includes=`echo "$x_libraries" | sed s/lib/include/`
1445 AC_MSG_RESULT(Corrected X includes to $x_includes)
1446 X_CFLAGS="$X_CFLAGS -I$x_includes"
1447 fi
1448
1449 dnl Remove "-I/usr/include " from X_CFLAGS, should not be needed.
1450 X_CFLAGS="`echo $X_CFLAGS\ | sed 's%-I/usr/include %%'`"
1451 dnl Remove "-L/usr/lib " from X_LIBS, should not be needed.
1452 X_LIBS="`echo $X_LIBS\ | sed 's%-L/usr/lib %%'`"
1453 dnl Same for "-R/usr/lib ".
1454 X_LIBS="`echo $X_LIBS\ | sed -e 's%-R/usr/lib %%' -e 's%-R /usr/lib %%'`"
1455
1456
1457 dnl Check if the X11 header files are correctly installed. On some systems
Bram Moolenaar00ca2842008-06-26 20:14:00 +00001458 dnl Xlib.h includes files that don't exist. On some systems X11/Intrinsic.h
1459 dnl is missing.
Bram Moolenaar071d4272004-06-13 20:20:40 +00001460 AC_MSG_CHECKING(if X11 header files can be found)
1461 cflags_save=$CFLAGS
1462 CFLAGS="$CFLAGS $X_CFLAGS"
Bram Moolenaar00ca2842008-06-26 20:14:00 +00001463 AC_TRY_COMPILE([#include <X11/Xlib.h>
1464#include <X11/Intrinsic.h>], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001465 AC_MSG_RESULT(yes),
1466 AC_MSG_RESULT(no); no_x=yes)
1467 CFLAGS=$cflags_save
1468
1469 if test "${no_x-no}" = yes; then
1470 with_x=no
1471 else
1472 AC_DEFINE(HAVE_X11)
1473 X_LIB="-lXt -lX11";
1474 AC_SUBST(X_LIB)
1475
1476 ac_save_LDFLAGS="$LDFLAGS"
1477 LDFLAGS="-L$x_libraries $LDFLAGS"
1478
1479 dnl Check for -lXdmcp (needed on SunOS 4.1.4)
1480 dnl For HP-UX 10.20 it must be before -lSM -lICE
1481 AC_CHECK_LIB(Xdmcp, _XdmcpAuthDoIt, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lXdmcp"],,
1482 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXdmcp])
1483
1484 dnl Some systems need -lnsl -lsocket when testing for ICE.
1485 dnl The check above doesn't do this, try here (again). Also needed to get
1486 dnl them after Xdmcp. link.sh will remove them when not needed.
1487 dnl Check for other function than above to avoid the cached value
1488 AC_CHECK_LIB(ICE, IceOpenConnection,
1489 [X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE"],, [$X_EXTRA_LIBS])
1490
1491 dnl Check for -lXpm (needed for some versions of Motif)
1492 LDFLAGS="$X_LIBS $ac_save_LDFLAGS"
1493 AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [X_PRE_LIBS="$X_PRE_LIBS -lXpm"],,
1494 [-lXt $X_PRE_LIBS -lXpm -lX11 $X_EXTRA_LIBS])
1495
1496 dnl Check that the X11 header files don't use implicit declarations
1497 AC_MSG_CHECKING(if X11 header files implicitly declare return values)
1498 cflags_save=$CFLAGS
1499 CFLAGS="$CFLAGS $X_CFLAGS -Werror"
1500 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
1501 AC_MSG_RESULT(no),
1502 CFLAGS="$CFLAGS -Wno-implicit-int"
1503 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
1504 AC_MSG_RESULT(yes); cflags_save="$cflags_save -Wno-implicit-int",
1505 AC_MSG_RESULT(test failed)
1506 )
1507 )
1508 CFLAGS=$cflags_save
1509
1510 LDFLAGS="$ac_save_LDFLAGS"
1511
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00001512 AC_MSG_CHECKING(size of wchar_t is 2 bytes)
1513 AC_CACHE_VAL(ac_cv_small_wchar_t,
1514 [AC_TRY_RUN([
1515#include <X11/Xlib.h>
1516#if STDC_HEADERS
1517# include <stdlib.h>
1518# include <stddef.h>
1519#endif
1520 main()
1521 {
1522 if (sizeof(wchar_t) <= 2)
1523 exit(1);
1524 exit(0);
1525 }],
1526 ac_cv_small_wchar_t="no",
1527 ac_cv_small_wchar_t="yes",
1528 AC_MSG_ERROR(failed to compile test program))])
1529 AC_MSG_RESULT($ac_cv_small_wchar_t)
1530 if test "x$ac_cv_small_wchar_t" = "xyes" ; then
1531 AC_DEFINE(SMALL_WCHAR_T)
1532 fi
1533
Bram Moolenaar071d4272004-06-13 20:20:40 +00001534 fi
1535fi
1536
Bram Moolenaara7fc0102005-05-18 22:17:12 +00001537test "x$with_x" = xno -a "x$MACOSX" != "xyes" -a "x$QNX" != "xyes" && enable_gui=no
Bram Moolenaar071d4272004-06-13 20:20:40 +00001538
1539AC_MSG_CHECKING(--enable-gui argument)
1540AC_ARG_ENABLE(gui,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02001541 [ --enable-gui[=OPTS] X11 GUI [default=auto] [OPTS=auto/no/gtk2/gnome2/motif/athena/neXtaw/photon/carbon]], , enable_gui="auto")
Bram Moolenaar071d4272004-06-13 20:20:40 +00001542
1543dnl Canonicalize the --enable-gui= argument so that it can be easily compared.
1544dnl Do not use character classes for portability with old tools.
1545enable_gui_canon=`echo "_$enable_gui" | \
1546 sed 's/[[ _+-]]//g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
1547
1548dnl Skip everything by default.
Bram Moolenaar071d4272004-06-13 20:20:40 +00001549SKIP_GTK2=YES
1550SKIP_GNOME=YES
1551SKIP_MOTIF=YES
1552SKIP_ATHENA=YES
1553SKIP_NEXTAW=YES
1554SKIP_PHOTON=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00001555SKIP_CARBON=YES
1556GUITYPE=NONE
1557
Bram Moolenaarb11160e2005-01-04 21:31:43 +00001558if test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001559 SKIP_PHOTON=
1560 case "$enable_gui_canon" in
1561 no) AC_MSG_RESULT(no GUI support)
1562 SKIP_PHOTON=YES ;;
1563 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
1564 auto) AC_MSG_RESULT(auto - automatic GUI support) ;;
1565 photon) AC_MSG_RESULT(Photon GUI support) ;;
1566 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
1567 SKIP_PHOTON=YES ;;
1568 esac
1569
1570elif test "x$MACOSX" = "xyes" -a "x$with_x" = "xno" ; then
1571 SKIP_CARBON=
1572 case "$enable_gui_canon" in
1573 no) AC_MSG_RESULT(no GUI support)
1574 SKIP_CARBON=YES ;;
1575 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
Bram Moolenaar164fca32010-07-14 13:58:07 +02001576 auto) AC_MSG_RESULT(auto - Carbon GUI is outdated - disable GUI support)
1577 SKIP_CARBON=YES ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00001578 carbon) AC_MSG_RESULT(Carbon GUI support) ;;
1579 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
1580 SKIP_CARBON=YES ;;
1581 esac
1582
1583else
1584
Bram Moolenaar071d4272004-06-13 20:20:40 +00001585 case "$enable_gui_canon" in
1586 no|none) AC_MSG_RESULT(no GUI support) ;;
1587 yes|""|auto) AC_MSG_RESULT(yes/auto - automatic GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001588 SKIP_GTK2=
1589 SKIP_GNOME=
1590 SKIP_MOTIF=
1591 SKIP_ATHENA=
1592 SKIP_NEXTAW=
1593 SKIP_CARBON=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00001594 gtk2) AC_MSG_RESULT(GTK+ 2.x GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001595 SKIP_GTK2=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00001596 gnome2) AC_MSG_RESULT(GNOME 2.x GUI support)
1597 SKIP_GNOME=
Bram Moolenaar071d4272004-06-13 20:20:40 +00001598 SKIP_GTK2=;;
1599 motif) AC_MSG_RESULT(Motif GUI support)
1600 SKIP_MOTIF=;;
1601 athena) AC_MSG_RESULT(Athena GUI support)
1602 SKIP_ATHENA=;;
1603 nextaw) AC_MSG_RESULT(neXtaw GUI support)
1604 SKIP_NEXTAW=;;
1605 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
1606 esac
1607
1608fi
1609
Bram Moolenaar071d4272004-06-13 20:20:40 +00001610if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \
1611 -a "$enable_gui_canon" != "gnome2"; then
1612 AC_MSG_CHECKING(whether or not to look for GTK+ 2)
1613 AC_ARG_ENABLE(gtk2-check,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02001614 [ --enable-gtk2-check If auto-select GUI, check for GTK+ 2 [default=yes]],
Bram Moolenaar071d4272004-06-13 20:20:40 +00001615 , enable_gtk2_check="yes")
1616 AC_MSG_RESULT($enable_gtk2_check)
1617 if test "x$enable_gtk2_check" = "xno"; then
1618 SKIP_GTK2=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02001619 SKIP_GNOME=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00001620 fi
1621fi
1622
Bram Moolenaar182c5be2010-06-25 05:37:59 +02001623if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001624 AC_MSG_CHECKING(whether or not to look for GNOME)
1625 AC_ARG_ENABLE(gnome-check,
1626 [ --enable-gnome-check If GTK GUI, check for GNOME [default=no]],
1627 , enable_gnome_check="no")
1628 AC_MSG_RESULT($enable_gnome_check)
1629 if test "x$enable_gnome_check" = "xno"; then
1630 SKIP_GNOME=YES
1631 fi
1632fi
1633
1634if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then
1635 AC_MSG_CHECKING(whether or not to look for Motif)
1636 AC_ARG_ENABLE(motif-check,
1637 [ --enable-motif-check If auto-select GUI, check for Motif [default=yes]],
1638 , enable_motif_check="yes")
1639 AC_MSG_RESULT($enable_motif_check)
1640 if test "x$enable_motif_check" = "xno"; then
1641 SKIP_MOTIF=YES
1642 fi
1643fi
1644
1645if test "x$SKIP_ATHENA" != "xYES" -a "$enable_gui_canon" != "athena"; then
1646 AC_MSG_CHECKING(whether or not to look for Athena)
1647 AC_ARG_ENABLE(athena-check,
1648 [ --enable-athena-check If auto-select GUI, check for Athena [default=yes]],
1649 , enable_athena_check="yes")
1650 AC_MSG_RESULT($enable_athena_check)
1651 if test "x$enable_athena_check" = "xno"; then
1652 SKIP_ATHENA=YES
1653 fi
1654fi
1655
1656if test "x$SKIP_NEXTAW" != "xYES" -a "$enable_gui_canon" != "nextaw"; then
1657 AC_MSG_CHECKING(whether or not to look for neXtaw)
1658 AC_ARG_ENABLE(nextaw-check,
1659 [ --enable-nextaw-check If auto-select GUI, check for neXtaw [default=yes]],
1660 , enable_nextaw_check="yes")
1661 AC_MSG_RESULT($enable_nextaw_check);
1662 if test "x$enable_nextaw_check" = "xno"; then
1663 SKIP_NEXTAW=YES
1664 fi
1665fi
1666
1667if test "x$SKIP_CARBON" != "xYES" -a "$enable_gui_canon" != "carbon"; then
1668 AC_MSG_CHECKING(whether or not to look for Carbon)
1669 AC_ARG_ENABLE(carbon-check,
1670 [ --enable-carbon-check If auto-select GUI, check for Carbon [default=yes]],
1671 , enable_carbon_check="yes")
1672 AC_MSG_RESULT($enable_carbon_check);
1673 if test "x$enable_carbon_check" = "xno"; then
1674 SKIP_CARBON=YES
1675 fi
1676fi
1677
Bram Moolenaar843ee412004-06-30 16:16:41 +00001678
Bram Moolenaar071d4272004-06-13 20:20:40 +00001679if test "x$MACOSX" = "xyes" -a -z "$SKIP_CARBON" -a "x$CARBON" = "xyes"; then
1680 AC_MSG_CHECKING(for Carbon GUI)
Bram Moolenaar14716812006-05-04 21:54:08 +00001681 dnl already did the check, just give the message
Bram Moolenaar071d4272004-06-13 20:20:40 +00001682 AC_MSG_RESULT(yes);
1683 GUITYPE=CARBONGUI
Bram Moolenaare344bea2005-09-01 20:46:49 +00001684 if test "$VIMNAME" = "vim"; then
1685 VIMNAME=Vim
1686 fi
Bram Moolenaar14716812006-05-04 21:54:08 +00001687
Bram Moolenaar164fca32010-07-14 13:58:07 +02001688 if test "x$MACARCH" = "xboth"; then
1689 CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk/Developer/Headers/FlatCarbon"
1690 else
1691 CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/Headers/FlatCarbon"
1692 fi
1693
Bram Moolenaar14716812006-05-04 21:54:08 +00001694 dnl Default install directory is not /usr/local
1695 if test x$prefix = xNONE; then
1696 prefix=/Applications
1697 fi
1698
1699 dnl Sorry for the hard coded default
1700 datadir='${prefix}/Vim.app/Contents/Resources'
1701
Bram Moolenaar071d4272004-06-13 20:20:40 +00001702 dnl skip everything else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001703 SKIP_GTK2=YES;
1704 SKIP_GNOME=YES;
1705 SKIP_MOTIF=YES;
1706 SKIP_ATHENA=YES;
1707 SKIP_NEXTAW=YES;
1708 SKIP_PHOTON=YES;
Bram Moolenaar071d4272004-06-13 20:20:40 +00001709 SKIP_CARBON=YES
1710fi
1711
Bram Moolenaar071d4272004-06-13 20:20:40 +00001712dnl define an autoconf function to check for a specified version of GTK, and
Bram Moolenaar182c5be2010-06-25 05:37:59 +02001713dnl try to compile/link a GTK program.
Bram Moolenaar071d4272004-06-13 20:20:40 +00001714dnl
1715dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00001716dnl Test for GTK, and define GTK_CFLAGS, GTK_LIBDIR and GTK_LIBS
Bram Moolenaar071d4272004-06-13 20:20:40 +00001717dnl
1718AC_DEFUN(AM_PATH_GTK,
1719[
1720 if test "X$GTK_CONFIG" != "Xno" -o "X$PKG_CONFIG" != "Xno"; then
1721 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02001722 min_gtk_version=ifelse([$1], ,2.2.0,$1)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001723 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
1724 no_gtk=""
1725 if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
1726 && $PKG_CONFIG --exists gtk+-2.0; then
1727 {
1728 dnl We should be using PKG_CHECK_MODULES() instead of this hack.
1729 dnl But I guess the dependency on pkgconfig.m4 is not wanted or
1730 dnl something like that.
1731 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0`
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00001732 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-2.0`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001733 GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0`
1734 gtk_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
1735 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
1736 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
1737 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
1738 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
1739 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
1740 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00001741 else
1742 no_gtk=yes
1743 fi
1744
1745 if test "x$enable_gtktest" = "xyes" -a "x$no_gtk" = "x"; then
1746 {
1747 ac_save_CFLAGS="$CFLAGS"
1748 ac_save_LIBS="$LIBS"
1749 CFLAGS="$CFLAGS $GTK_CFLAGS"
1750 LIBS="$LIBS $GTK_LIBS"
1751
1752 dnl
Bram Moolenaar182c5be2010-06-25 05:37:59 +02001753 dnl Now check if the installed GTK is sufficiently new.
Bram Moolenaar071d4272004-06-13 20:20:40 +00001754 dnl
1755 rm -f conf.gtktest
1756 AC_TRY_RUN([
1757#include <gtk/gtk.h>
1758#include <stdio.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00001759#if STDC_HEADERS
1760# include <stdlib.h>
1761# include <stddef.h>
1762#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001763
1764int
1765main ()
1766{
1767int major, minor, micro;
1768char *tmp_version;
1769
1770system ("touch conf.gtktest");
1771
1772/* HP/UX 9 (%@#!) writes to sscanf strings */
1773tmp_version = g_strdup("$min_gtk_version");
1774if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
1775 printf("%s, bad version string\n", "$min_gtk_version");
1776 exit(1);
1777 }
1778
1779if ((gtk_major_version > major) ||
1780 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
1781 ((gtk_major_version == major) && (gtk_minor_version == minor) &&
1782 (gtk_micro_version >= micro)))
1783{
1784 return 0;
1785}
1786return 1;
1787}
1788],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
1789 CFLAGS="$ac_save_CFLAGS"
1790 LIBS="$ac_save_LIBS"
1791 }
1792 fi
1793 if test "x$no_gtk" = x ; then
1794 if test "x$enable_gtktest" = "xyes"; then
1795 AC_MSG_RESULT(yes; found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
1796 else
1797 AC_MSG_RESULT(found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
1798 fi
1799 ifelse([$2], , :, [$2])
1800 else
1801 {
1802 AC_MSG_RESULT(no)
1803 GTK_CFLAGS=""
1804 GTK_LIBS=""
1805 ifelse([$3], , :, [$3])
1806 }
1807 fi
1808 }
1809 else
1810 GTK_CFLAGS=""
1811 GTK_LIBS=""
1812 ifelse([$3], , :, [$3])
1813 fi
1814 AC_SUBST(GTK_CFLAGS)
1815 AC_SUBST(GTK_LIBS)
1816 rm -f conf.gtktest
1817])
1818
1819dnl ---------------------------------------------------------------------------
1820dnl gnome
1821dnl ---------------------------------------------------------------------------
1822AC_DEFUN([GNOME_INIT_HOOK],
1823[
1824 AC_SUBST(GNOME_LIBS)
1825 AC_SUBST(GNOME_LIBDIR)
1826 AC_SUBST(GNOME_INCLUDEDIR)
1827
1828 AC_ARG_WITH(gnome-includes,
1829 [ --with-gnome-includes=DIR Specify location of GNOME headers],
1830 [CFLAGS="$CFLAGS -I$withval"]
1831 )
1832
1833 AC_ARG_WITH(gnome-libs,
1834 [ --with-gnome-libs=DIR Specify location of GNOME libs],
1835 [LDFLAGS="$LDFLAGS -L$withval" gnome_prefix=$withval]
1836 )
1837
1838 AC_ARG_WITH(gnome,
1839 [ --with-gnome Specify prefix for GNOME files],
1840 if test x$withval = xyes; then
1841 want_gnome=yes
1842 ifelse([$1], [], :, [$1])
1843 else
1844 if test "x$withval" = xno; then
1845 want_gnome=no
1846 else
1847 want_gnome=yes
1848 LDFLAGS="$LDFLAGS -L$withval/lib"
1849 CFLAGS="$CFLAGS -I$withval/include"
1850 gnome_prefix=$withval/lib
1851 fi
1852 fi,
1853 want_gnome=yes)
1854
Bram Moolenaar182c5be2010-06-25 05:37:59 +02001855 if test "x$want_gnome" = xyes; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001856 {
1857 AC_MSG_CHECKING(for libgnomeui-2.0)
1858 if $PKG_CONFIG --exists libgnomeui-2.0; then
1859 AC_MSG_RESULT(yes)
1860 GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0`
1861 GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0`
1862 GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0`
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00001863
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00001864 dnl On FreeBSD we need -pthread but pkg-config doesn't include it.
1865 dnl This might not be the right way but it works for me...
1866 AC_MSG_CHECKING(for FreeBSD)
1867 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1868 AC_MSG_RESULT(yes, adding -pthread)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00001869 GNOME_INCLUDEDIR="$GNOME_INCLUDEDIR -D_THREAD_SAFE"
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00001870 GNOME_LIBS="$GNOME_LIBS -pthread"
1871 else
1872 AC_MSG_RESULT(no)
1873 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001874 $1
1875 else
1876 AC_MSG_RESULT(not found)
1877 if test "x$2" = xfail; then
1878 AC_MSG_ERROR(Could not find libgnomeui-2.0 via pkg-config)
1879 fi
1880 fi
1881 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00001882 fi
1883])
1884
1885AC_DEFUN([GNOME_INIT],[
1886 GNOME_INIT_HOOK([],fail)
1887])
1888
1889
1890dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02001891dnl Check for GTK2. If it fails, then continue on for Motif as before...
Bram Moolenaar071d4272004-06-13 20:20:40 +00001892dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02001893if test -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001894
1895 AC_MSG_CHECKING(--disable-gtktest argument)
1896 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
1897 , enable_gtktest=yes)
1898 if test "x$enable_gtktest" = "xyes" ; then
1899 AC_MSG_RESULT(gtk test enabled)
1900 else
1901 AC_MSG_RESULT(gtk test disabled)
1902 fi
1903
Bram Moolenaar071d4272004-06-13 20:20:40 +00001904 if test "X$PKG_CONFIG" = "X"; then
1905 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
1906 fi
1907
Bram Moolenaar182c5be2010-06-25 05:37:59 +02001908 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001909 dnl First try finding version 2.2.0 or later. The 2.0.x series has
1910 dnl problems (bold fonts, --remote doesn't work).
Bram Moolenaar182c5be2010-06-25 05:37:59 +02001911 AM_PATH_GTK(2.2.0,
1912 [GUI_LIB_LOC="$GTK_LIBDIR"
1913 GTK_LIBNAME="$GTK_LIBS"
1914 GUI_INC_LOC="$GTK_CFLAGS"], )
1915 if test "x$GTK_CFLAGS" != "x"; then
1916 SKIP_ATHENA=YES
1917 SKIP_NEXTAW=YES
1918 SKIP_MOTIF=YES
1919 GUITYPE=GTK
1920 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001921 fi
1922 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001923 if test "x$GUITYPE" = "xGTK"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +02001924 if test "$gtk_minor_version" = 1 -a "0$gtk_micro_version" -ge 1 \
1925 || test "0$gtk_minor_version" -ge 2; then
1926 AC_DEFINE(HAVE_GTK_MULTIHEAD)
1927 fi
1928 dnl
1929 dnl if GTK exists, then check for GNOME.
1930 dnl
1931 if test -z "$SKIP_GNOME"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001932 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02001933 GNOME_INIT_HOOK([have_gnome=yes])
1934 if test "x$have_gnome" = xyes ; then
1935 AC_DEFINE(FEAT_GUI_GNOME)
1936 GUI_INC_LOC="$GUI_INC_LOC $GNOME_INCLUDEDIR"
1937 GTK_LIBNAME="$GTK_LIBNAME $GNOME_LIBDIR $GNOME_LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001938 fi
1939 }
1940 fi
1941 fi
1942fi
1943
1944dnl Check for Motif include files location.
1945dnl The LAST one found is used, this makes the highest version to be used,
1946dnl e.g. when Motif1.2 and Motif2.0 are both present.
1947
1948if test -z "$SKIP_MOTIF"; then
1949 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"
1950 dnl Remove "-I" from before $GUI_INC_LOC if it's there
1951 GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`"
1952
1953 AC_MSG_CHECKING(for location of Motif GUI includes)
1954 gui_includes="`echo $x_includes|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC"
1955 GUI_INC_LOC=
1956 for try in $gui_includes; do
1957 if test -f "$try/Xm/Xm.h"; then
1958 GUI_INC_LOC=$try
1959 fi
1960 done
1961 if test -n "$GUI_INC_LOC"; then
1962 if test "$GUI_INC_LOC" = /usr/include; then
1963 GUI_INC_LOC=
1964 AC_MSG_RESULT(in default path)
1965 else
1966 AC_MSG_RESULT($GUI_INC_LOC)
1967 fi
1968 else
1969 AC_MSG_RESULT(<not found>)
1970 SKIP_MOTIF=YES
1971 fi
1972fi
1973
1974dnl Check for Motif library files location. In the same order as the include
1975dnl files, to avoid a mixup if several versions are present
1976
1977if test -z "$SKIP_MOTIF"; then
1978 AC_MSG_CHECKING(--with-motif-lib argument)
1979 AC_ARG_WITH(motif-lib,
1980 [ --with-motif-lib=STRING Library for Motif ],
1981 [ MOTIF_LIBNAME="${withval}" ] )
1982
1983 if test -n "$MOTIF_LIBNAME"; then
1984 AC_MSG_RESULT($MOTIF_LIBNAME)
1985 GUI_LIB_LOC=
1986 else
1987 AC_MSG_RESULT(no)
1988
1989 dnl Remove "-L" from before $GUI_LIB_LOC if it's there
1990 GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
1991
1992 AC_MSG_CHECKING(for location of Motif GUI libs)
1993 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"
1994 GUI_LIB_LOC=
1995 for try in $gui_libs; do
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001996 for libtry in "$try"/libXm.a "$try"/libXm.so* "$try"/libXm.sl "$try"/libXm.dylib; do
Bram Moolenaar071d4272004-06-13 20:20:40 +00001997 if test -f "$libtry"; then
1998 GUI_LIB_LOC=$try
1999 fi
2000 done
2001 done
2002 if test -n "$GUI_LIB_LOC"; then
2003 dnl Remove /usr/lib, it causes trouble on some systems
2004 if test "$GUI_LIB_LOC" = /usr/lib; then
2005 GUI_LIB_LOC=
2006 AC_MSG_RESULT(in default path)
2007 else
2008 if test -n "$GUI_LIB_LOC"; then
2009 AC_MSG_RESULT($GUI_LIB_LOC)
2010 if test "`(uname) 2>/dev/null`" = SunOS &&
2011 uname -r | grep '^5' >/dev/null; then
2012 GUI_LIB_LOC="$GUI_LIB_LOC -R $GUI_LIB_LOC"
2013 fi
2014 fi
2015 fi
2016 MOTIF_LIBNAME=-lXm
2017 else
2018 AC_MSG_RESULT(<not found>)
2019 SKIP_MOTIF=YES
2020 fi
2021 fi
2022fi
2023
2024if test -z "$SKIP_MOTIF"; then
2025 SKIP_ATHENA=YES
2026 SKIP_NEXTAW=YES
2027 GUITYPE=MOTIF
2028 AC_SUBST(MOTIF_LIBNAME)
2029fi
2030
2031dnl Check if the Athena files can be found
2032
2033GUI_X_LIBS=
2034
2035if test -z "$SKIP_ATHENA"; then
2036 AC_MSG_CHECKING(if Athena header files can be found)
2037 cflags_save=$CFLAGS
2038 CFLAGS="$CFLAGS $X_CFLAGS"
2039 AC_TRY_COMPILE([
2040#include <X11/Intrinsic.h>
2041#include <X11/Xaw/Paned.h>], ,
2042 AC_MSG_RESULT(yes),
2043 AC_MSG_RESULT(no); SKIP_ATHENA=YES )
2044 CFLAGS=$cflags_save
2045fi
2046
2047if test -z "$SKIP_ATHENA"; then
2048 GUITYPE=ATHENA
2049fi
2050
2051if test -z "$SKIP_NEXTAW"; then
2052 AC_MSG_CHECKING(if neXtaw header files can be found)
2053 cflags_save=$CFLAGS
2054 CFLAGS="$CFLAGS $X_CFLAGS"
2055 AC_TRY_COMPILE([
2056#include <X11/Intrinsic.h>
2057#include <X11/neXtaw/Paned.h>], ,
2058 AC_MSG_RESULT(yes),
2059 AC_MSG_RESULT(no); SKIP_NEXTAW=YES )
2060 CFLAGS=$cflags_save
2061fi
2062
2063if test -z "$SKIP_NEXTAW"; then
2064 GUITYPE=NEXTAW
2065fi
2066
2067if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
2068 dnl Prepend -I and -L to $GUI_INC_LOC and $GUI_LIB_LOC if not empty
2069 dnl Avoid adding it when it twice
2070 if test -n "$GUI_INC_LOC"; then
2071 GUI_INC_LOC=-I"`echo $GUI_INC_LOC|sed 's%-I%%'`"
2072 fi
2073 if test -n "$GUI_LIB_LOC"; then
2074 GUI_LIB_LOC=-L"`echo $GUI_LIB_LOC|sed 's%-L%%'`"
2075 fi
2076
2077 dnl Check for -lXext and then for -lXmu
2078 ldflags_save=$LDFLAGS
2079 LDFLAGS="$X_LIBS $LDFLAGS"
2080 AC_CHECK_LIB(Xext, XShapeQueryExtension, [GUI_X_LIBS="-lXext"],,
2081 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2082 dnl For Solaris we need -lw and -ldl before linking with -lXmu works.
2083 AC_CHECK_LIB(w, wslen, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lw"],,
2084 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2085 AC_CHECK_LIB(dl, dlsym, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldl"],,
2086 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2087 AC_CHECK_LIB(Xmu, XmuCreateStippledPixmap, [GUI_X_LIBS="-lXmu $GUI_X_LIBS"],,
2088 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2089 if test -z "$SKIP_MOTIF"; then
2090 AC_CHECK_LIB(Xp, XpEndJob, [GUI_X_LIBS="-lXp $GUI_X_LIBS"],,
2091 [$GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2092 fi
2093 LDFLAGS=$ldflags_save
2094
2095 dnl Execute xmkmf to figure out if -DNARROWPROTO is needed.
2096 AC_MSG_CHECKING(for extra X11 defines)
2097 NARROW_PROTO=
2098 rm -fr conftestdir
2099 if mkdir conftestdir; then
2100 cd conftestdir
2101 cat > Imakefile <<'EOF'
2102acfindx:
2103 @echo 'NARROW_PROTO="${PROTO_DEFINES}"'
2104EOF
2105 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
2106 eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
2107 fi
2108 cd ..
2109 rm -fr conftestdir
2110 fi
2111 if test -z "$NARROW_PROTO"; then
2112 AC_MSG_RESULT(no)
2113 else
2114 AC_MSG_RESULT($NARROW_PROTO)
2115 fi
2116 AC_SUBST(NARROW_PROTO)
2117fi
2118
2119dnl Look for XSMP support - but don't necessarily restrict it to X11 GUIs
2120dnl use the X11 include path
2121if test "$enable_xsmp" = "yes"; then
2122 cppflags_save=$CPPFLAGS
2123 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2124 AC_CHECK_HEADERS(X11/SM/SMlib.h)
2125 CPPFLAGS=$cppflags_save
2126fi
2127
2128
Bram Moolenaare667c952010-07-05 22:57:59 +02002129if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF" -o -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002130 dnl Check for X11/xpm.h and X11/Sunkeysym.h with the GUI include path
2131 cppflags_save=$CPPFLAGS
2132 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2133 AC_CHECK_HEADERS(X11/xpm.h X11/Sunkeysym.h)
2134
2135 dnl automatically disable XIM when XIMtext isn't in X11/Xlib.h
2136 if test ! "$enable_xim" = "no"; then
2137 AC_MSG_CHECKING(for XIMText in X11/Xlib.h)
2138 AC_EGREP_CPP(XIMText, [#include <X11/Xlib.h>],
2139 AC_MSG_RESULT(yes),
2140 AC_MSG_RESULT(no; xim has been disabled); enable_xim = "no")
2141 fi
2142 CPPFLAGS=$cppflags_save
2143
2144 dnl automatically enable XIM when hangul input isn't enabled
2145 if test "$enable_xim" = "auto" -a "$enable_hangulinput" != "yes" \
2146 -a "x$GUITYPE" != "xNONE" ; then
2147 AC_MSG_RESULT(X GUI selected; xim has been enabled)
2148 enable_xim="yes"
2149 fi
2150fi
2151
2152if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
2153 cppflags_save=$CPPFLAGS
2154 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00002155dnl Xmu/Editres.h may exist but can only be used after including Intrinsic.h
2156 AC_MSG_CHECKING([for X11/Xmu/Editres.h])
2157 AC_TRY_COMPILE([
2158#include <X11/Intrinsic.h>
2159#include <X11/Xmu/Editres.h>],
2160 [int i; i = 0;],
2161 AC_MSG_RESULT(yes)
2162 AC_DEFINE(HAVE_X11_XMU_EDITRES_H),
2163 AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00002164 CPPFLAGS=$cppflags_save
2165fi
2166
2167dnl Only use the Xm directory when compiling Motif, don't use it for Athena
2168if test -z "$SKIP_MOTIF"; then
2169 cppflags_save=$CPPFLAGS
2170 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00002171 AC_CHECK_HEADERS(Xm/Xm.h Xm/XpmP.h Xm/JoinSideT.h Xm/TraitP.h Xm/Manager.h \
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00002172 Xm/UnhighlightT.h Xm/Notebook.h)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00002173
2174 if test $ac_cv_header_Xm_XpmP_h = yes; then
2175 dnl Solaris uses XpmAttributes_21, very annoying.
2176 AC_MSG_CHECKING([for XpmAttributes_21 in Xm/XpmP.h])
2177 AC_TRY_COMPILE([#include <Xm/XpmP.h>], [XpmAttributes_21 attr;],
2178 AC_MSG_RESULT(yes); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes_21),
2179 AC_MSG_RESULT(no); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
2180 )
2181 else
Bram Moolenaar57657d82006-04-21 22:12:41 +00002182 AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00002183 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002184 CPPFLAGS=$cppflags_save
2185fi
2186
2187if test "x$GUITYPE" = "xNONE" -a "$enable_xim" = "yes"; then
2188 AC_MSG_RESULT(no GUI selected; xim has been disabled)
2189 enable_xim="no"
2190fi
2191if test "x$GUITYPE" = "xNONE" -a "$enable_fontset" = "yes"; then
2192 AC_MSG_RESULT(no GUI selected; fontset has been disabled)
2193 enable_fontset="no"
2194fi
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002195if test "x$GUITYPE:$enable_fontset" = "xGTK:yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002196 AC_MSG_RESULT(GTK+ 2 GUI selected; fontset has been disabled)
2197 enable_fontset="no"
2198fi
2199
Bram Moolenaar071d4272004-06-13 20:20:40 +00002200if test -z "$SKIP_PHOTON"; then
2201 GUITYPE=PHOTONGUI
2202fi
2203
2204AC_SUBST(GUI_INC_LOC)
2205AC_SUBST(GUI_LIB_LOC)
2206AC_SUBST(GUITYPE)
2207AC_SUBST(GUI_X_LIBS)
2208
2209if test "$enable_workshop" = "yes" -a -n "$SKIP_MOTIF"; then
2210 AC_MSG_ERROR([cannot use workshop without Motif])
2211fi
2212
2213dnl defining FEAT_XIM and FEAT_XFONTSET is delayed, so that they can be disabled
2214if test "$enable_xim" = "yes"; then
2215 AC_DEFINE(FEAT_XIM)
2216fi
2217if test "$enable_fontset" = "yes"; then
2218 AC_DEFINE(FEAT_XFONTSET)
2219fi
2220
2221
2222dnl ---------------------------------------------------------------------------
2223dnl end of GUI-checking
2224dnl ---------------------------------------------------------------------------
2225
2226
2227dnl Only really enable hangul input when GUI and XFONTSET are available
2228if test "$enable_hangulinput" = "yes"; then
2229 if test "x$GUITYPE" = "xNONE"; then
2230 AC_MSG_RESULT(no GUI selected; hangul input has been disabled)
2231 enable_hangulinput=no
2232 else
2233 AC_DEFINE(FEAT_HANGULIN)
2234 HANGULIN_SRC=hangulin.c
2235 AC_SUBST(HANGULIN_SRC)
2236 HANGULIN_OBJ=objects/hangulin.o
2237 AC_SUBST(HANGULIN_OBJ)
2238 fi
2239fi
2240
2241dnl Checks for libraries and include files.
2242
Bram Moolenaar446cb832008-06-24 21:56:24 +00002243AC_CACHE_CHECK([whether toupper is broken], [vim_cv_toupper_broken],
2244 [
2245 AC_RUN_IFELSE([[
2246#include "confdefs.h"
2247#include <ctype.h>
2248#if STDC_HEADERS
2249# include <stdlib.h>
2250# include <stddef.h>
2251#endif
2252main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); }
2253 ]],[
2254 vim_cv_toupper_broken=yes
2255 ],[
2256 vim_cv_toupper_broken=no
2257 ],[
2258 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_toupper_broken')
2259 ])])
2260
2261if test "x$vim_cv_toupper_broken" = "xyes" ; then
2262 AC_DEFINE(BROKEN_TOUPPER)
2263fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002264
2265AC_MSG_CHECKING(whether __DATE__ and __TIME__ work)
Bram Moolenaar446cb832008-06-24 21:56:24 +00002266AC_TRY_COMPILE([#include <stdio.h>], [printf("(" __DATE__ " " __TIME__ ")");],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002267 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DATE_TIME),
2268 AC_MSG_RESULT(no))
2269
Bram Moolenaar0c094b92009-05-14 20:20:33 +00002270AC_MSG_CHECKING(whether __attribute__((unused)) is allowed)
2271AC_TRY_COMPILE([#include <stdio.h>], [int x __attribute__((unused));],
2272 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ATTRIBUTE_UNUSED),
2273 AC_MSG_RESULT(no))
2274
Bram Moolenaar071d4272004-06-13 20:20:40 +00002275dnl Checks for header files.
2276AC_CHECK_HEADER(elf.h, HAS_ELF=1)
2277dnl AC_CHECK_HEADER(dwarf.h, SVR4=1)
2278if test "$HAS_ELF" = 1; then
2279 AC_CHECK_LIB(elf, main)
2280fi
2281
2282AC_HEADER_DIRENT
2283
Bram Moolenaar071d4272004-06-13 20:20:40 +00002284dnl If sys/wait.h is not found it might still exist but not be POSIX
2285dnl compliant. In that case we define HAVE_UNION_WAIT (for NeXT)
2286if test $ac_cv_header_sys_wait_h = no; then
2287 AC_MSG_CHECKING([for sys/wait.h that defines union wait])
2288 AC_TRY_COMPILE([#include <sys/wait.h>],
2289 [union wait xx, yy; xx = yy],
2290 AC_MSG_RESULT(yes)
2291 AC_DEFINE(HAVE_SYS_WAIT_H)
2292 AC_DEFINE(HAVE_UNION_WAIT),
2293 AC_MSG_RESULT(no))
2294fi
2295
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02002296AC_CHECK_HEADERS(stdarg.h stdint.h stdlib.h string.h \
2297 sys/select.h sys/utsname.h termcap.h fcntl.h \
2298 sgtty.h sys/ioctl.h sys/time.h sys/types.h \
2299 termio.h iconv.h inttypes.h langinfo.h math.h \
2300 unistd.h stropts.h errno.h sys/resource.h \
2301 sys/systeminfo.h locale.h sys/stream.h termios.h \
2302 libc.h sys/statfs.h poll.h sys/poll.h pwd.h \
2303 utime.h sys/param.h libintl.h libgen.h \
2304 util/debug.h util/msg18n.h frame.h sys/acl.h \
2305 sys/access.h sys/sysinfo.h wchar.h wctype.h)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002306
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002307dnl sys/ptem.h depends on sys/stream.h on Solaris
2308AC_CHECK_HEADERS(sys/ptem.h, [], [],
2309[#if defined HAVE_SYS_STREAM_H
2310# include <sys/stream.h>
2311#endif])
2312
Bram Moolenaar32f31b12009-05-21 13:20:59 +00002313dnl sys/sysctl.h depends on sys/param.h on OpenBSD
2314AC_CHECK_HEADERS(sys/sysctl.h, [], [],
2315[#if defined HAVE_SYS_PARAM_H
2316# include <sys/param.h>
2317#endif])
2318
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002319
Bram Moolenaardf3267e2005-01-25 22:07:05 +00002320dnl pthread_np.h may exist but can only be used after including pthread.h
2321AC_MSG_CHECKING([for pthread_np.h])
2322AC_TRY_COMPILE([
2323#include <pthread.h>
2324#include <pthread_np.h>],
2325 [int i; i = 0;],
2326 AC_MSG_RESULT(yes)
2327 AC_DEFINE(HAVE_PTHREAD_NP_H),
2328 AC_MSG_RESULT(no))
2329
Bram Moolenaare344bea2005-09-01 20:46:49 +00002330AC_CHECK_HEADERS(strings.h)
Bram Moolenaar9372a112005-12-06 19:59:18 +00002331if test "x$MACOSX" = "xyes"; then
2332 dnl The strings.h file on OS/X contains a warning and nothing useful.
2333 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
2334else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002335
2336dnl Check if strings.h and string.h can both be included when defined.
2337AC_MSG_CHECKING([if strings.h can be included after string.h])
2338cppflags_save=$CPPFLAGS
2339CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2340AC_TRY_COMPILE([
2341#if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO)
2342# define _NO_PROTO /* like in os_unix.h, causes conflict for AIX (Winn) */
2343 /* but don't do it on AIX 5.1 (Uribarri) */
2344#endif
2345#ifdef HAVE_XM_XM_H
2346# include <Xm/Xm.h> /* This breaks it for HP-UX 11 (Squassabia) */
2347#endif
2348#ifdef HAVE_STRING_H
2349# include <string.h>
2350#endif
2351#if defined(HAVE_STRINGS_H)
2352# include <strings.h>
2353#endif
2354 ], [int i; i = 0;],
2355 AC_MSG_RESULT(yes),
2356 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
2357 AC_MSG_RESULT(no))
2358CPPFLAGS=$cppflags_save
Bram Moolenaar9372a112005-12-06 19:59:18 +00002359fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002360
2361dnl Checks for typedefs, structures, and compiler characteristics.
2362AC_PROG_GCC_TRADITIONAL
2363AC_C_CONST
Bram Moolenaar76243bd2009-03-02 01:47:02 +00002364AC_C_VOLATILE
Bram Moolenaar071d4272004-06-13 20:20:40 +00002365AC_TYPE_MODE_T
2366AC_TYPE_OFF_T
2367AC_TYPE_PID_T
2368AC_TYPE_SIZE_T
2369AC_TYPE_UID_T
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02002370AC_TYPE_UINT32_T
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02002371
Bram Moolenaar071d4272004-06-13 20:20:40 +00002372AC_HEADER_TIME
2373AC_CHECK_TYPE(ino_t, long)
2374AC_CHECK_TYPE(dev_t, unsigned)
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02002375AC_C_BIGENDIAN(,,,)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002376
2377AC_MSG_CHECKING(for rlim_t)
2378if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
2379 AC_MSG_RESULT([(cached) $ac_cv_type_rlim_t])
2380else
2381 AC_EGREP_CPP(dnl
2382changequote(<<,>>)dnl
2383<<(^|[^a-zA-Z_0-9])rlim_t[^a-zA-Z_0-9]>>dnl
2384changequote([,]),
2385 [
2386#include <sys/types.h>
2387#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00002388# include <stdlib.h>
2389# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00002390#endif
2391#ifdef HAVE_SYS_RESOURCE_H
Bram Moolenaar446cb832008-06-24 21:56:24 +00002392# include <sys/resource.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00002393#endif
2394 ], ac_cv_type_rlim_t=yes, ac_cv_type_rlim_t=no)
2395 AC_MSG_RESULT($ac_cv_type_rlim_t)
2396fi
2397if test $ac_cv_type_rlim_t = no; then
2398 cat >> confdefs.h <<\EOF
2399#define rlim_t unsigned long
2400EOF
2401fi
2402
2403AC_MSG_CHECKING(for stack_t)
2404if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then
2405 AC_MSG_RESULT([(cached) $ac_cv_type_stack_t])
2406else
2407 AC_EGREP_CPP(stack_t,
2408 [
2409#include <sys/types.h>
2410#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00002411# include <stdlib.h>
2412# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00002413#endif
2414#include <signal.h>
2415 ], ac_cv_type_stack_t=yes, ac_cv_type_stack_t=no)
2416 AC_MSG_RESULT($ac_cv_type_stack_t)
2417fi
2418if test $ac_cv_type_stack_t = no; then
2419 cat >> confdefs.h <<\EOF
2420#define stack_t struct sigaltstack
2421EOF
2422fi
2423
2424dnl BSDI uses ss_base while others use ss_sp for the stack pointer.
2425AC_MSG_CHECKING(whether stack_t has an ss_base field)
2426AC_TRY_COMPILE([
2427#include <sys/types.h>
2428#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00002429# include <stdlib.h>
2430# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00002431#endif
2432#include <signal.h>
2433#include "confdefs.h"
2434 ], [stack_t sigstk; sigstk.ss_base = 0; ],
2435 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SS_BASE),
2436 AC_MSG_RESULT(no))
2437
2438olibs="$LIBS"
2439AC_MSG_CHECKING(--with-tlib argument)
2440AC_ARG_WITH(tlib, [ --with-tlib=library terminal library to be used ],)
2441if test -n "$with_tlib"; then
2442 AC_MSG_RESULT($with_tlib)
2443 LIBS="$LIBS -l$with_tlib"
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00002444 AC_MSG_CHECKING(for linking with $with_tlib library)
2445 AC_TRY_LINK([], [], AC_MSG_RESULT(OK), AC_MSG_ERROR(FAILED))
2446 dnl Need to check for tgetent() below.
2447 olibs="$LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002448else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00002449 AC_MSG_RESULT([empty: automatic terminal library selection])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002450 dnl On HP-UX 10.10 termcap or termlib should be used instead of
2451 dnl curses, because curses is much slower.
2452 dnl Newer versions of ncurses are preferred over anything.
2453 dnl Older versions of ncurses have bugs, get a new one!
2454 dnl Digital Unix (OSF1) should use curses (Ronald Schild).
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00002455 dnl On SCO Openserver should prefer termlib (Roger Cornelius).
Bram Moolenaar071d4272004-06-13 20:20:40 +00002456 case "`uname -s 2>/dev/null`" in
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00002457 OSF1|SCO_SV) tlibs="ncurses curses termlib termcap";;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002458 *) tlibs="ncurses termlib termcap curses";;
2459 esac
2460 for libname in $tlibs; do
2461 AC_CHECK_LIB(${libname}, tgetent,,)
2462 if test "x$olibs" != "x$LIBS"; then
2463 dnl It's possible that a library is found but it doesn't work
2464 dnl e.g., shared library that cannot be found
2465 dnl compile and run a test program to be sure
2466 AC_TRY_RUN([
2467#ifdef HAVE_TERMCAP_H
2468# include <termcap.h>
2469#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00002470#if STDC_HEADERS
2471# include <stdlib.h>
2472# include <stddef.h>
2473#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002474main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }],
2475 res="OK", res="FAIL", res="FAIL")
2476 if test "$res" = "OK"; then
2477 break
2478 fi
2479 AC_MSG_RESULT($libname library is not usable)
2480 LIBS="$olibs"
2481 fi
2482 done
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00002483 if test "x$olibs" = "x$LIBS"; then
2484 AC_MSG_RESULT(no terminal library found)
2485 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002486fi
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00002487
2488if test "x$olibs" = "x$LIBS"; then
2489 AC_MSG_CHECKING([for tgetent()])
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00002490 AC_TRY_LINK([],
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00002491 [char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");],
2492 AC_MSG_RESULT(yes),
2493 AC_MSG_ERROR([NOT FOUND!
2494 You need to install a terminal library; for example ncurses.
2495 Or specify the name of the library with --with-tlib.]))
2496fi
2497
Bram Moolenaar446cb832008-06-24 21:56:24 +00002498AC_CACHE_CHECK([whether we talk terminfo], [vim_cv_terminfo],
2499 [
2500 AC_RUN_IFELSE([[
2501#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002502#ifdef HAVE_TERMCAP_H
2503# include <termcap.h>
2504#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00002505#ifdef HAVE_STRING_H
2506# include <string.h>
2507#endif
2508#if STDC_HEADERS
2509# include <stdlib.h>
2510# include <stddef.h>
2511#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002512main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00002513{char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }
2514 ]],[
2515 vim_cv_terminfo=no
2516 ],[
2517 vim_cv_terminfo=yes
2518 ],[
2519 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_terminfo')
2520 ])
2521 ])
2522
2523if test "x$vim_cv_terminfo" = "xyes" ; then
2524 AC_DEFINE(TERMINFO)
2525fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002526
2527if test "x$olibs" != "x$LIBS"; then
Bram Moolenaar446cb832008-06-24 21:56:24 +00002528 AC_CACHE_CHECK([what tgetent() returns for an unknown terminal], [vim_cv_tgent],
2529 [
2530 AC_RUN_IFELSE([[
2531#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002532#ifdef HAVE_TERMCAP_H
2533# include <termcap.h>
2534#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00002535#if STDC_HEADERS
2536# include <stdlib.h>
2537# include <stddef.h>
2538#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002539main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00002540{char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
2541 ]],[
2542 vim_cv_tgent=zero
2543 ],[
2544 vim_cv_tgent=non-zero
2545 ],[
2546 AC_MSG_ERROR(failed to compile test program.)
2547 ])
2548 ])
2549
2550 if test "x$vim_cv_tgent" = "xzero" ; then
2551 AC_DEFINE(TGETENT_ZERO_ERR, 0)
2552 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002553fi
2554
2555AC_MSG_CHECKING(whether termcap.h contains ospeed)
2556AC_TRY_LINK([
2557#ifdef HAVE_TERMCAP_H
2558# include <termcap.h>
2559#endif
2560 ], [ospeed = 20000],
2561 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED),
2562 [AC_MSG_RESULT(no)
2563 AC_MSG_CHECKING(whether ospeed can be extern)
2564 AC_TRY_LINK([
2565#ifdef HAVE_TERMCAP_H
2566# include <termcap.h>
2567#endif
2568extern short ospeed;
2569 ], [ospeed = 20000],
2570 AC_MSG_RESULT(yes); AC_DEFINE(OSPEED_EXTERN),
2571 AC_MSG_RESULT(no))]
2572 )
2573
2574AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC])
2575AC_TRY_LINK([
2576#ifdef HAVE_TERMCAP_H
2577# include <termcap.h>
2578#endif
2579 ], [if (UP == 0 && BC == 0) PC = 1],
2580 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UP_BC_PC),
2581 [AC_MSG_RESULT(no)
2582 AC_MSG_CHECKING([whether UP, BC and PC can be extern])
2583 AC_TRY_LINK([
2584#ifdef HAVE_TERMCAP_H
2585# include <termcap.h>
2586#endif
2587extern char *UP, *BC, PC;
2588 ], [if (UP == 0 && BC == 0) PC = 1],
2589 AC_MSG_RESULT(yes); AC_DEFINE(UP_BC_PC_EXTERN),
2590 AC_MSG_RESULT(no))]
2591 )
2592
2593AC_MSG_CHECKING(whether tputs() uses outfuntype)
2594AC_TRY_COMPILE([
2595#ifdef HAVE_TERMCAP_H
2596# include <termcap.h>
2597#endif
2598 ], [extern int xx(); tputs("test", 1, (outfuntype)xx)],
2599 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OUTFUNTYPE),
2600 AC_MSG_RESULT(no))
2601
2602dnl On some SCO machines sys/select redefines struct timeval
2603AC_MSG_CHECKING([whether sys/select.h and sys/time.h may both be included])
2604AC_TRY_COMPILE([
2605#include <sys/types.h>
2606#include <sys/time.h>
2607#include <sys/select.h>], ,
2608 AC_MSG_RESULT(yes)
2609 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME),
2610 AC_MSG_RESULT(no))
2611
2612dnl AC_DECL_SYS_SIGLIST
2613
2614dnl Checks for pty.c (copied from screen) ==========================
2615AC_MSG_CHECKING(for /dev/ptc)
2616if test -r /dev/ptc; then
2617 AC_DEFINE(HAVE_DEV_PTC)
2618 AC_MSG_RESULT(yes)
2619else
2620 AC_MSG_RESULT(no)
2621fi
2622
2623AC_MSG_CHECKING(for SVR4 ptys)
2624if test -c /dev/ptmx ; then
2625 AC_TRY_LINK([], [ptsname(0);grantpt(0);unlockpt(0);],
2626 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SVR4_PTYS),
2627 AC_MSG_RESULT(no))
2628else
2629 AC_MSG_RESULT(no)
2630fi
2631
2632AC_MSG_CHECKING(for ptyranges)
2633if test -d /dev/ptym ; then
2634 pdir='/dev/ptym'
2635else
2636 pdir='/dev'
2637fi
2638dnl SCO uses ptyp%d
2639AC_EGREP_CPP(yes,
2640[#ifdef M_UNIX
2641 yes;
2642#endif
2643 ], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
2644dnl if test -c /dev/ptyp19; then
2645dnl ptys=`echo /dev/ptyp??`
2646dnl else
2647dnl ptys=`echo $pdir/pty??`
2648dnl fi
2649if test "$ptys" != "$pdir/pty??" ; then
2650 p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
2651 p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'`
2652 AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
2653 AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
2654 AC_MSG_RESULT([$p0 / $p1])
2655else
2656 AC_MSG_RESULT([don't know])
2657fi
2658
2659dnl **** pty mode/group handling ****
2660dnl
2661dnl support provided by Luke Mewburn <lm@rmit.edu.au>, 931222
Bram Moolenaar071d4272004-06-13 20:20:40 +00002662rm -f conftest_grp
Bram Moolenaar446cb832008-06-24 21:56:24 +00002663AC_CACHE_CHECK([default tty permissions/group], [vim_cv_tty_group],
2664 [
2665 AC_RUN_IFELSE([[
2666#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002667#include <sys/types.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00002668#if STDC_HEADERS
2669# include <stdlib.h>
2670# include <stddef.h>
2671#endif
2672#ifdef HAVE_UNISTD_H
2673#include <unistd.h>
2674#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002675#include <sys/stat.h>
2676#include <stdio.h>
2677main()
2678{
2679 struct stat sb;
2680 char *x,*ttyname();
2681 int om, m;
2682 FILE *fp;
2683
2684 if (!(x = ttyname(0))) exit(1);
2685 if (stat(x, &sb)) exit(1);
2686 om = sb.st_mode;
2687 if (om & 002) exit(0);
2688 m = system("mesg y");
2689 if (m == -1 || m == 127) exit(1);
2690 if (stat(x, &sb)) exit(1);
2691 m = sb.st_mode;
2692 if (chmod(x, om)) exit(1);
2693 if (m & 002) exit(0);
2694 if (sb.st_gid == getgid()) exit(1);
2695 if (!(fp=fopen("conftest_grp", "w")))
2696 exit(1);
2697 fprintf(fp, "%d\n", sb.st_gid);
2698 fclose(fp);
2699 exit(0);
2700}
Bram Moolenaar446cb832008-06-24 21:56:24 +00002701 ]],[
2702 if test -f conftest_grp; then
2703 vim_cv_tty_group=`cat conftest_grp`
2704 if test "x$vim_cv_tty_mode" = "x" ; then
2705 vim_cv_tty_mode=0620
2706 fi
2707 AC_MSG_RESULT([pty mode: $vim_cv_tty_mode, group: $vim_cv_tty_group])
2708 else
2709 vim_cv_tty_group=world
Bram Moolenaar72951072009-12-02 16:58:33 +00002710 AC_MSG_RESULT([ptys are world accessible])
Bram Moolenaar446cb832008-06-24 21:56:24 +00002711 fi
2712 ],[
2713 vim_cv_tty_group=world
Bram Moolenaar72951072009-12-02 16:58:33 +00002714 AC_MSG_RESULT([can't determine - assume ptys are world accessible])
Bram Moolenaar446cb832008-06-24 21:56:24 +00002715 ],[
2716 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_tty_group' and 'vim_cv_tty_mode')
2717 ])
2718 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002719rm -f conftest_grp
2720
Bram Moolenaar446cb832008-06-24 21:56:24 +00002721if test "x$vim_cv_tty_group" != "xworld" ; then
2722 AC_DEFINE_UNQUOTED(PTYGROUP,$vim_cv_tty_group)
2723 if test "x$vim_cv_tty_mode" = "x" ; then
2724 AC_MSG_ERROR([It seems you're cross compiling and have 'vim_cv_tty_group' set, please also set the environment variable 'vim_cv_tty_mode' to the correct mode (propably 0620)])
2725 else
2726 AC_DEFINE(PTYMODE, 0620)
2727 fi
2728fi
2729
Bram Moolenaar071d4272004-06-13 20:20:40 +00002730dnl Checks for library functions. ===================================
2731
2732AC_TYPE_SIGNAL
2733
2734dnl find out what to use at the end of a signal function
2735if test $ac_cv_type_signal = void; then
2736 AC_DEFINE(SIGRETURN, [return])
2737else
2738 AC_DEFINE(SIGRETURN, [return 0])
2739fi
2740
2741dnl check if struct sigcontext is defined (used for SGI only)
2742AC_MSG_CHECKING(for struct sigcontext)
2743AC_TRY_COMPILE([
2744#include <signal.h>
2745test_sig()
2746{
2747 struct sigcontext *scont;
2748 scont = (struct sigcontext *)0;
2749 return 1;
2750} ], ,
2751 AC_MSG_RESULT(yes)
2752 AC_DEFINE(HAVE_SIGCONTEXT),
2753 AC_MSG_RESULT(no))
2754
2755dnl tricky stuff: try to find out if getcwd() is implemented with
2756dnl system("sh -c pwd")
Bram Moolenaar446cb832008-06-24 21:56:24 +00002757AC_CACHE_CHECK([getcwd implementation is broken], [vim_cv_getcwd_broken],
2758 [
2759 AC_RUN_IFELSE([[
2760#include "confdefs.h"
2761#ifdef HAVE_UNISTD_H
2762#include <unistd.h>
2763#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002764char *dagger[] = { "IFS=pwd", 0 };
2765main()
2766{
2767 char buffer[500];
2768 extern char **environ;
2769 environ = dagger;
2770 return getcwd(buffer, 500) ? 0 : 1;
Bram Moolenaar446cb832008-06-24 21:56:24 +00002771}
2772 ]],[
2773 vim_cv_getcwd_broken=no
2774 ],[
2775 vim_cv_getcwd_broken=yes
2776 ],[
2777 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_getcwd_broken')
2778 ])
2779 ])
2780
2781if test "x$vim_cv_getcwd_broken" = "xyes" ; then
2782 AC_DEFINE(BAD_GETCWD)
2783fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002784
Bram Moolenaar25153e12010-02-24 14:47:08 +01002785dnl Check for functions in one big call, to reduce the size of configure.
2786dnl Can only be used for functions that do not require any include.
2787AC_CHECK_FUNCS(bcmp fchdir fchown fsync getcwd getpseudotty \
Bram Moolenaar071d4272004-06-13 20:20:40 +00002788 getpwnam getpwuid getrlimit gettimeofday getwd lstat memcmp \
Bram Moolenaareaf03392009-11-17 11:08:52 +00002789 memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
Bram Moolenaar071d4272004-06-13 20:20:40 +00002790 setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
Bram Moolenaar051b7822005-05-19 21:00:46 +00002791 sigvec strcasecmp strerror strftime stricmp strncasecmp \
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00002792 strnicmp strpbrk strtol tgetent towlower towupper iswupper \
2793 usleep utime utimes)
Bram Moolenaar25153e12010-02-24 14:47:08 +01002794AC_FUNC_FSEEKO
Bram Moolenaar071d4272004-06-13 20:20:40 +00002795
Bram Moolenaar317fd3a2010-05-07 16:05:55 +02002796dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when
2797dnl appropriate, so that off_t is 64 bits when needed.
2798AC_SYS_LARGEFILE
2799
Bram Moolenaar071d4272004-06-13 20:20:40 +00002800dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible
2801AC_MSG_CHECKING(for st_blksize)
2802AC_TRY_COMPILE(
2803[#include <sys/types.h>
2804#include <sys/stat.h>],
2805[ struct stat st;
2806 int n;
2807
2808 stat("/", &st);
2809 n = (int)st.st_blksize;],
2810 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ST_BLKSIZE),
2811 AC_MSG_RESULT(no))
2812
Bram Moolenaar446cb832008-06-24 21:56:24 +00002813AC_CACHE_CHECK([whether stat() ignores a trailing slash], [vim_cv_stat_ignores_slash],
2814 [
2815 AC_RUN_IFELSE([[
2816#include "confdefs.h"
2817#if STDC_HEADERS
2818# include <stdlib.h>
2819# include <stddef.h>
2820#endif
2821#include <sys/types.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00002822#include <sys/stat.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00002823main() {struct stat st; exit(stat("configure/", &st) != 0); }
2824 ]],[
2825 vim_cv_stat_ignores_slash=yes
2826 ],[
2827 vim_cv_stat_ignores_slash=no
2828 ],[
2829 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_stat_ignores_slash')
2830 ])
2831 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002832
Bram Moolenaar446cb832008-06-24 21:56:24 +00002833if test "x$vim_cv_stat_ignores_slash" = "xyes" ; then
2834 AC_DEFINE(STAT_IGNORES_SLASH)
2835fi
2836
Bram Moolenaar071d4272004-06-13 20:20:40 +00002837dnl Link with iconv for charset translation, if not found without library.
2838dnl check for iconv() requires including iconv.h
2839dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
2840dnl has been installed.
2841AC_MSG_CHECKING(for iconv_open())
2842save_LIBS="$LIBS"
2843LIBS="$LIBS -liconv"
2844AC_TRY_LINK([
2845#ifdef HAVE_ICONV_H
2846# include <iconv.h>
2847#endif
2848 ], [iconv_open("fr", "to");],
2849 AC_MSG_RESULT(yes; with -liconv); AC_DEFINE(HAVE_ICONV),
2850 LIBS="$save_LIBS"
2851 AC_TRY_LINK([
2852#ifdef HAVE_ICONV_H
2853# include <iconv.h>
2854#endif
2855 ], [iconv_open("fr", "to");],
2856 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ICONV),
2857 AC_MSG_RESULT(no)))
2858
2859
2860AC_MSG_CHECKING(for nl_langinfo(CODESET))
2861AC_TRY_LINK([
2862#ifdef HAVE_LANGINFO_H
2863# include <langinfo.h>
2864#endif
2865], [char *cs = nl_langinfo(CODESET);],
2866 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET),
2867 AC_MSG_RESULT(no))
2868
Bram Moolenaar446cb832008-06-24 21:56:24 +00002869dnl Need various functions for floating point support. Only enable
2870dnl floating point when they are all present.
2871AC_CHECK_LIB(m, strtod)
2872AC_MSG_CHECKING([for strtod() and other floating point functions])
2873AC_TRY_LINK([
2874#ifdef HAVE_MATH_H
2875# include <math.h>
2876#endif
2877#if STDC_HEADERS
2878# include <stdlib.h>
2879# include <stddef.h>
2880#endif
2881], [char *s; double d;
2882 d = strtod("1.1", &s);
2883 d = fabs(1.11);
2884 d = ceil(1.11);
2885 d = floor(1.11);
2886 d = log10(1.11);
2887 d = pow(1.11, 2.22);
2888 d = sqrt(1.11);
2889 d = sin(1.11);
2890 d = cos(1.11);
2891 d = atan(1.11);
2892 ],
2893 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT_FUNCS),
2894 AC_MSG_RESULT(no))
2895
Bram Moolenaar071d4272004-06-13 20:20:40 +00002896dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI
2897dnl when -lacl works, also try to use -lattr (required for Debian).
2898AC_MSG_CHECKING(--disable-acl argument)
2899AC_ARG_ENABLE(acl,
2900 [ --disable-acl Don't check for ACL support.],
2901 , [enable_acl="yes"])
2902if test "$enable_acl" = "yes"; then
2903AC_MSG_RESULT(no)
2904AC_CHECK_LIB(posix1e, acl_get_file, [LIBS="$LIBS -lposix1e"],
2905 AC_CHECK_LIB(acl, acl_get_file, [LIBS="$LIBS -lacl"
2906 AC_CHECK_LIB(attr, fgetxattr, LIBS="$LIBS -lattr",,)],,),)
2907
2908AC_MSG_CHECKING(for POSIX ACL support)
2909AC_TRY_LINK([
2910#include <sys/types.h>
2911#ifdef HAVE_SYS_ACL_H
2912# include <sys/acl.h>
2913#endif
2914acl_t acl;], [acl = acl_get_file("foo", ACL_TYPE_ACCESS);
2915 acl_set_file("foo", ACL_TYPE_ACCESS, acl);
2916 acl_free(acl);],
2917 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_ACL),
2918 AC_MSG_RESULT(no))
2919
2920AC_MSG_CHECKING(for Solaris ACL support)
2921AC_TRY_LINK([
2922#ifdef HAVE_SYS_ACL_H
2923# include <sys/acl.h>
2924#endif], [acl("foo", GETACLCNT, 0, NULL);
2925 ],
2926 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOLARIS_ACL),
2927 AC_MSG_RESULT(no))
2928
2929AC_MSG_CHECKING(for AIX ACL support)
2930AC_TRY_LINK([
Bram Moolenaar446cb832008-06-24 21:56:24 +00002931#if STDC_HEADERS
2932# include <stdlib.h>
2933# include <stddef.h>
2934#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002935#ifdef HAVE_SYS_ACL_H
2936# include <sys/acl.h>
2937#endif
2938#ifdef HAVE_SYS_ACCESS_H
2939# include <sys/access.h>
2940#endif
2941#define _ALL_SOURCE
2942
2943#include <sys/stat.h>
2944
2945int aclsize;
2946struct acl *aclent;], [aclsize = sizeof(struct acl);
2947 aclent = (void *)malloc(aclsize);
2948 statacl("foo", STX_NORMAL, aclent, aclsize);
2949 ],
2950 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_AIX_ACL),
2951 AC_MSG_RESULT(no))
2952else
2953 AC_MSG_RESULT(yes)
2954fi
2955
2956AC_MSG_CHECKING(--disable-gpm argument)
2957AC_ARG_ENABLE(gpm,
2958 [ --disable-gpm Don't use gpm (Linux mouse daemon).], ,
2959 [enable_gpm="yes"])
2960
2961if test "$enable_gpm" = "yes"; then
2962 AC_MSG_RESULT(no)
2963 dnl Checking if gpm support can be compiled
2964 AC_CACHE_CHECK([for gpm], vi_cv_have_gpm,
2965 [olibs="$LIBS" ; LIBS="-lgpm"]
2966 AC_TRY_LINK(
2967 [#include <gpm.h>
2968 #include <linux/keyboard.h>],
2969 [Gpm_GetLibVersion(NULL);],
2970 dnl Configure defines HAVE_GPM, if it is defined feature.h defines
2971 dnl FEAT_MOUSE_GPM if mouse support is included
2972 [vi_cv_have_gpm=yes],
2973 [vi_cv_have_gpm=no])
2974 [LIBS="$olibs"]
2975 )
2976 if test $vi_cv_have_gpm = yes; then
2977 LIBS="$LIBS -lgpm"
2978 AC_DEFINE(HAVE_GPM)
2979 fi
2980else
2981 AC_MSG_RESULT(yes)
2982fi
2983
Bram Moolenaar446cb832008-06-24 21:56:24 +00002984AC_MSG_CHECKING(--disable-sysmouse argument)
2985AC_ARG_ENABLE(sysmouse,
2986 [ --disable-sysmouse Don't use sysmouse (mouse in *BSD console).], ,
2987 [enable_sysmouse="yes"])
2988
2989if test "$enable_sysmouse" = "yes"; then
2990 AC_MSG_RESULT(no)
2991 dnl Checking if sysmouse support can be compiled
2992 dnl Configure defines HAVE_SYSMOUSE, if it is defined feature.h
2993 dnl defines FEAT_SYSMOUSE if mouse support is included
2994 AC_CACHE_CHECK([for sysmouse], vi_cv_have_sysmouse,
2995 AC_TRY_LINK(
2996 [#include <sys/consio.h>
2997 #include <signal.h>
2998 #include <sys/fbio.h>],
2999 [struct mouse_info mouse;
3000 mouse.operation = MOUSE_MODE;
3001 mouse.operation = MOUSE_SHOW;
3002 mouse.u.mode.mode = 0;
3003 mouse.u.mode.signal = SIGUSR2;],
3004 [vi_cv_have_sysmouse=yes],
3005 [vi_cv_have_sysmouse=no])
3006 )
3007 if test $vi_cv_have_sysmouse = yes; then
3008 AC_DEFINE(HAVE_SYSMOUSE)
3009 fi
3010else
3011 AC_MSG_RESULT(yes)
3012fi
3013
Bram Moolenaarf05da212009-11-17 16:13:15 +00003014dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
3015AC_MSG_CHECKING(for FD_CLOEXEC)
3016AC_TRY_COMPILE(
3017[#if HAVE_FCNTL_H
3018# include <fcntl.h>
3019#endif],
3020[ int flag = FD_CLOEXEC;],
3021 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
3022 AC_MSG_RESULT(not usable))
3023
Bram Moolenaar071d4272004-06-13 20:20:40 +00003024dnl rename needs to be checked separately to work on Nextstep with cc
3025AC_MSG_CHECKING(for rename)
3026AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
3027 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
3028 AC_MSG_RESULT(no))
3029
3030dnl sysctl() may exist but not the arguments we use
3031AC_MSG_CHECKING(for sysctl)
3032AC_TRY_COMPILE(
3033[#include <sys/types.h>
3034#include <sys/sysctl.h>],
3035[ int mib[2], r;
3036 size_t len;
3037
3038 mib[0] = CTL_HW;
3039 mib[1] = HW_USERMEM;
3040 len = sizeof(r);
3041 (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
3042 ],
3043 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL),
3044 AC_MSG_RESULT(not usable))
3045
3046dnl sysinfo() may exist but not be Linux compatible
3047AC_MSG_CHECKING(for sysinfo)
3048AC_TRY_COMPILE(
3049[#include <sys/types.h>
3050#include <sys/sysinfo.h>],
3051[ struct sysinfo sinfo;
3052 int t;
3053
3054 (void)sysinfo(&sinfo);
3055 t = sinfo.totalram;
3056 ],
3057 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
3058 AC_MSG_RESULT(not usable))
3059
Bram Moolenaar914572a2007-05-01 11:37:47 +00003060dnl struct sysinfo may have the mem_unit field or not
3061AC_MSG_CHECKING(for sysinfo.mem_unit)
3062AC_TRY_COMPILE(
3063[#include <sys/types.h>
3064#include <sys/sysinfo.h>],
3065[ struct sysinfo sinfo;
3066 sinfo.mem_unit = 1;
3067 ],
3068 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_MEM_UNIT),
3069 AC_MSG_RESULT(no))
3070
Bram Moolenaar071d4272004-06-13 20:20:40 +00003071dnl sysconf() may exist but not support what we want to use
3072AC_MSG_CHECKING(for sysconf)
3073AC_TRY_COMPILE(
3074[#include <unistd.h>],
3075[ (void)sysconf(_SC_PAGESIZE);
3076 (void)sysconf(_SC_PHYS_PAGES);
3077 ],
3078 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
3079 AC_MSG_RESULT(not usable))
3080
Bram Moolenaar914703b2010-05-31 21:59:46 +02003081AC_CHECK_SIZEOF([int])
3082AC_CHECK_SIZEOF([long])
3083AC_CHECK_SIZEOF([time_t])
3084AC_CHECK_SIZEOF([off_t])
Bram Moolenaar644fdff2010-05-30 13:26:21 +02003085
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003086dnl Make sure that uint32_t is really 32 bits unsigned.
3087AC_MSG_CHECKING([uint32_t is 32 bits])
3088AC_TRY_RUN([
3089#ifdef HAVE_STDINT_H
3090# include <stdint.h>
3091#endif
3092#ifdef HAVE_INTTYPES_H
3093# include <inttypes.h>
3094#endif
3095main() {
3096 uint32_t nr1 = (uint32_t)-1;
3097 uint32_t nr2 = (uint32_t)0xffffffffUL;
3098 if (sizeof(uint32_t) != 4 || nr1 != 0xffffffffUL || nr2 + 1 != 0) exit(1);
3099 exit(0);
3100}],
3101AC_MSG_RESULT(ok),
3102AC_MSG_ERROR([WRONG! uint32_t not defined correctly.]),
3103AC_MSG_ERROR([could not compile program using uint32_t.]))
3104
Bram Moolenaar446cb832008-06-24 21:56:24 +00003105dnl Check for memmove() before bcopy(), makes memmove() be used when both are
3106dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
3107
Bram Moolenaar071d4272004-06-13 20:20:40 +00003108[bcopy_test_prog='
Bram Moolenaar446cb832008-06-24 21:56:24 +00003109#include "confdefs.h"
3110#ifdef HAVE_STRING_H
3111# include <string.h>
3112#endif
3113#if STDC_HEADERS
3114# include <stdlib.h>
3115# include <stddef.h>
3116#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003117main() {
3118 char buf[10];
3119 strcpy(buf, "abcdefghi");
3120 mch_memmove(buf, buf + 2, 3);
3121 if (strncmp(buf, "ababcf", 6))
3122 exit(1);
3123 strcpy(buf, "abcdefghi");
3124 mch_memmove(buf + 2, buf, 3);
3125 if (strncmp(buf, "cdedef", 6))
3126 exit(1);
3127 exit(0); /* libc version works properly. */
3128}']
3129
Bram Moolenaar446cb832008-06-24 21:56:24 +00003130AC_CACHE_CHECK([whether memmove handles overlaps],[vim_cv_memmove_handles_overlap],
3131 [
3132 AC_RUN_IFELSE([[#define mch_memmove(s,d,l) memmove(d,s,l) $bcopy_test_prog]],
3133 [
3134 vim_cv_memmove_handles_overlap=yes
3135 ],[
3136 vim_cv_memmove_handles_overlap=no
3137 ],[
3138 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memmove_handles_overlap')
3139 ])
3140 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003141
Bram Moolenaar446cb832008-06-24 21:56:24 +00003142if test "x$vim_cv_memmove_handles_overlap" = "xyes" ; then
3143 AC_DEFINE(USEMEMMOVE)
3144else
3145 AC_CACHE_CHECK([whether bcopy handles overlaps],[vim_cv_bcopy_handles_overlap],
3146 [
3147 AC_RUN_IFELSE([[#define mch_bcopy(s,d,l) bcopy(d,s,l) $bcopy_test_prog]],
3148 [
3149 vim_cv_bcopy_handles_overlap=yes
3150 ],[
3151 vim_cv_bcopy_handles_overlap=no
3152 ],[
3153 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_bcopy_handles_overlap')
3154 ])
3155 ])
3156
3157 if test "x$vim_cv_bcopy_handles_overlap" = "xyes" ; then
3158 AC_DEFINE(USEBCOPY)
3159 else
3160 AC_CACHE_CHECK([whether memcpy handles overlaps],[vim_cv_memcpy_handles_overlap],
3161 [
3162 AC_RUN_IFELSE([[#define mch_memcpy(s,d,l) memcpy(d,s,l) $bcopy_test_prog]],
3163 [
3164 vim_cv_memcpy_handles_overlap=yes
3165 ],[
3166 vim_cv_memcpy_handles_overlap=no
3167 ],[
3168 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memcpy_handles_overlap')
3169 ])
3170 ])
3171
3172 if test "x$vim_cv_memcpy_handles_overlap" = "xyes" ; then
3173 AC_DEFINE(USEMEMCPY)
3174 fi
3175 fi
3176fi
3177
Bram Moolenaar071d4272004-06-13 20:20:40 +00003178
3179dnl Check for multibyte locale functions
3180dnl Find out if _Xsetlocale() is supported by libX11.
3181dnl Check if X_LOCALE should be defined.
3182
3183if test "$enable_multibyte" = "yes"; then
3184 cflags_save=$CFLAGS
3185 ldflags_save=$LDFLAGS
Bram Moolenaar94ba1ce2009-04-22 15:53:09 +00003186 if test "x$x_includes" != "xNONE" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003187 CFLAGS="$CFLAGS -I$x_includes"
3188 LDFLAGS="$X_LIBS $LDFLAGS -lX11"
3189 AC_MSG_CHECKING(whether X_LOCALE needed)
3190 AC_TRY_COMPILE([#include <X11/Xlocale.h>],,
3191 AC_TRY_LINK_FUNC([_Xsetlocale], [AC_MSG_RESULT(yes)
3192 AC_DEFINE(X_LOCALE)], AC_MSG_RESULT(no)),
3193 AC_MSG_RESULT(no))
3194 fi
3195 CFLAGS=$cflags_save
3196 LDFLAGS=$ldflags_save
3197fi
3198
3199dnl Link with xpg4, it is said to make Korean locale working
3200AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,)
3201
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00003202dnl Check how we can run ctags. Default to "ctags" when nothing works.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003203dnl --version for Exuberant ctags (preferred)
Bram Moolenaarb21e5842006-04-16 18:30:08 +00003204dnl Add --fields=+S to get function signatures for omni completion.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003205dnl -t for typedefs (many ctags have this)
3206dnl -s for static functions (Elvis ctags only?)
3207dnl -v for variables. Dangerous, most ctags take this for 'vgrind style'.
3208dnl -i+m to test for older Exuberant ctags
3209AC_MSG_CHECKING(how to create tags)
3210test -f tags && mv tags tags.save
3211if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaarb21e5842006-04-16 18:30:08 +00003212 TAGPRG="ctags -I INIT+ --fields=+S"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003213else
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00003214 TAGPRG="ctags"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003215 (eval etags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags"
3216 (eval etags -c /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags -c"
3217 (eval ctags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags"
3218 (eval ctags -t /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -t"
3219 (eval ctags -ts /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -ts"
3220 (eval ctags -tvs /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -tvs"
3221 (eval ctags -i+m /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -i+m"
3222fi
3223test -f tags.save && mv tags.save tags
3224AC_MSG_RESULT($TAGPRG) AC_SUBST(TAGPRG)
3225
3226dnl Check how we can run man with a section number
3227AC_MSG_CHECKING(how to run man with a section nr)
3228MANDEF="man"
Bram Moolenaar8b131502008-02-13 09:28:19 +00003229(eval MANPAGER=cat PAGER=cat man -s 2 read) < /dev/null > /dev/null 2>&AC_FD_CC && MANDEF="man -s"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003230AC_MSG_RESULT($MANDEF)
3231if test "$MANDEF" = "man -s"; then
3232 AC_DEFINE(USEMAN_S)
3233fi
3234
3235dnl Check if gettext() is working and if it needs -lintl
3236AC_MSG_CHECKING(--disable-nls argument)
3237AC_ARG_ENABLE(nls,
3238 [ --disable-nls Don't support NLS (gettext()).], ,
3239 [enable_nls="yes"])
3240
3241if test "$enable_nls" = "yes"; then
3242 AC_MSG_RESULT(no)
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00003243
3244 INSTALL_LANGS=install-languages
3245 AC_SUBST(INSTALL_LANGS)
3246 INSTALL_TOOL_LANGS=install-tool-languages
3247 AC_SUBST(INSTALL_TOOL_LANGS)
3248
Bram Moolenaar071d4272004-06-13 20:20:40 +00003249 AC_CHECK_PROG(MSGFMT, msgfmt, msgfmt, )
3250 AC_MSG_CHECKING([for NLS])
3251 if test -f po/Makefile; then
3252 have_gettext="no"
3253 if test -n "$MSGFMT"; then
3254 AC_TRY_LINK(
3255 [#include <libintl.h>],
3256 [gettext("Test");],
3257 AC_MSG_RESULT([gettext() works]); have_gettext="yes",
3258 olibs=$LIBS
3259 LIBS="$LIBS -lintl"
3260 AC_TRY_LINK(
3261 [#include <libintl.h>],
3262 [gettext("Test");],
3263 AC_MSG_RESULT([gettext() works with -lintl]); have_gettext="yes",
3264 AC_MSG_RESULT([gettext() doesn't work]);
3265 LIBS=$olibs))
3266 else
3267 AC_MSG_RESULT([msgfmt not found - disabled]);
3268 fi
3269 if test $have_gettext = "yes"; then
3270 AC_DEFINE(HAVE_GETTEXT)
3271 MAKEMO=yes
3272 AC_SUBST(MAKEMO)
3273 dnl this was added in GNU gettext 0.10.36
3274 AC_CHECK_FUNCS(bind_textdomain_codeset)
3275 dnl _nl_msg_cat_cntr is required for GNU gettext
3276 AC_MSG_CHECKING([for _nl_msg_cat_cntr])
3277 AC_TRY_LINK(
3278 [#include <libintl.h>
3279 extern int _nl_msg_cat_cntr;],
3280 [++_nl_msg_cat_cntr;],
3281 AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_NL_MSG_CAT_CNTR),
3282 AC_MSG_RESULT([no]))
3283 fi
3284 else
3285 AC_MSG_RESULT([no "po/Makefile" - disabled]);
3286 fi
3287else
3288 AC_MSG_RESULT(yes)
3289fi
3290
3291dnl Check for dynamic linking loader
3292AC_CHECK_HEADER(dlfcn.h, DLL=dlfcn.h, [AC_CHECK_HEADER(dl.h, DLL=dl.h)])
3293if test x${DLL} = xdlfcn.h; then
3294 AC_DEFINE(HAVE_DLFCN_H, 1, [ Define if we have dlfcn.h. ])
3295 AC_MSG_CHECKING([for dlopen()])
3296 AC_TRY_LINK(,[
3297 extern void* dlopen();
3298 dlopen();
3299 ],
3300 AC_MSG_RESULT(yes);
3301 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
3302 AC_MSG_RESULT(no);
3303 AC_MSG_CHECKING([for dlopen() in -ldl])
3304 olibs=$LIBS
3305 LIBS="$LIBS -ldl"
3306 AC_TRY_LINK(,[
3307 extern void* dlopen();
3308 dlopen();
3309 ],
3310 AC_MSG_RESULT(yes);
3311 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
3312 AC_MSG_RESULT(no);
3313 LIBS=$olibs))
3314 dnl ReliantUNIX has dlopen() in libc but everything else in libdl
3315 dnl ick :-)
3316 AC_MSG_CHECKING([for dlsym()])
3317 AC_TRY_LINK(,[
3318 extern void* dlsym();
3319 dlsym();
3320 ],
3321 AC_MSG_RESULT(yes);
3322 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
3323 AC_MSG_RESULT(no);
3324 AC_MSG_CHECKING([for dlsym() in -ldl])
3325 olibs=$LIBS
3326 LIBS="$LIBS -ldl"
3327 AC_TRY_LINK(,[
3328 extern void* dlsym();
3329 dlsym();
3330 ],
3331 AC_MSG_RESULT(yes);
3332 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
3333 AC_MSG_RESULT(no);
3334 LIBS=$olibs))
3335elif test x${DLL} = xdl.h; then
3336 AC_DEFINE(HAVE_DL_H, 1, [ Define if we have dl.h. ])
3337 AC_MSG_CHECKING([for shl_load()])
3338 AC_TRY_LINK(,[
3339 extern void* shl_load();
3340 shl_load();
3341 ],
3342 AC_MSG_RESULT(yes);
3343 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
3344 AC_MSG_RESULT(no);
3345 AC_MSG_CHECKING([for shl_load() in -ldld])
3346 olibs=$LIBS
3347 LIBS="$LIBS -ldld"
3348 AC_TRY_LINK(,[
3349 extern void* shl_load();
3350 shl_load();
3351 ],
3352 AC_MSG_RESULT(yes);
3353 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
3354 AC_MSG_RESULT(no);
3355 LIBS=$olibs))
3356fi
3357AC_CHECK_HEADERS(setjmp.h)
3358
3359if test "x$MACOSX" = "xyes" -a -n "$PERL"; then
3360 dnl -ldl must come after DynaLoader.a
3361 if echo $LIBS | grep -e '-ldl' >/dev/null; then
3362 LIBS=`echo $LIBS | sed s/-ldl//`
3363 PERL_LIBS="$PERL_LIBS -ldl"
3364 fi
3365fi
3366
Bram Moolenaar164fca32010-07-14 13:58:07 +02003367if test "x$MACOSX" = "xyes"; then
3368 AC_MSG_CHECKING(whether we need -framework Cocoa)
3369 dnl Cocoa is needed with FEAT_CLIPBOARD or FEAT_MBYTE (the former is
3370 dnl disabled during tiny build)
3371 if test "x$features" != "xtiny" || test "x$enable_multibyte" = "xyes"; then
3372 LIBS=$"$LIBS -framework Cocoa"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003373 AC_MSG_RESULT(yes)
3374 else
3375 AC_MSG_RESULT(no)
3376 fi
3377fi
Bram Moolenaar164fca32010-07-14 13:58:07 +02003378if test "x$MACARCH" = "xboth" && test "x$GUITYPE" = "xCARBONGUI"; then
Bram Moolenaar595a7be2010-03-10 16:28:12 +01003379 LDFLAGS="$LDFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +00003380fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003381
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00003382dnl gcc 3.1 changed the meaning of -MM. The only solution appears to be to
3383dnl use "-isystem" instead of "-I" for all non-Vim include dirs.
3384dnl But only when making dependencies, cproto and lint don't take "-isystem".
Bram Moolenaar32466aa2006-02-24 23:53:04 +00003385dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
3386dnl the number before the version number.
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00003387DEPEND_CFLAGS_FILTER=
3388if test "$GCC" = yes; then
Bram Moolenaar0cd49302008-11-20 09:37:01 +00003389 AC_MSG_CHECKING(for GCC 3 or later)
Bram Moolenaar2217cae2006-03-25 21:55:52 +00003390 gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]]\)\..*$/\1/g'`
Bram Moolenaarf740b292006-02-16 22:11:02 +00003391 if test "$gccmajor" -gt "2"; then
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00003392 DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
Bram Moolenaar0cd49302008-11-20 09:37:01 +00003393 AC_MSG_RESULT(yes)
3394 else
3395 AC_MSG_RESULT(no)
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00003396 fi
Bram Moolenaar0cd49302008-11-20 09:37:01 +00003397 dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
3398 dnl declared as char x[1] but actually longer. Introduced in gcc 4.0.
Bram Moolenaar56d1db32009-12-16 16:14:51 +00003399 dnl Also remove duplicate _FORTIFY_SOURCE arguments.
Bram Moolenaar0cd49302008-11-20 09:37:01 +00003400 AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
3401 if test "$gccmajor" -gt "3"; then
Bram Moolenaar56d1db32009-12-16 16:14:51 +00003402 CFLAGS=`echo "$CFLAGS" | sed -e 's/-Wp,-D_FORTIFY_SOURCE=.//g' -e 's/-D_FORTIFY_SOURCE=.//g' -e 's/$/ -D_FORTIFY_SOURCE=1/'`
Bram Moolenaar0cd49302008-11-20 09:37:01 +00003403 AC_MSG_RESULT(yes)
3404 else
3405 AC_MSG_RESULT(no)
3406 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +00003407fi
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00003408AC_SUBST(DEPEND_CFLAGS_FILTER)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003409
3410dnl write output files
3411AC_OUTPUT(auto/config.mk:config.mk.in)
3412
3413dnl vim: set sw=2 tw=78 fo+=l: