blob: e2867b422e264c1567dd0550a9f155dcd8a6075e [file] [log] [blame]
Bram Moolenaar3f7d0902016-11-12 21:13:42 +01001dnl configure.ac: autoconf script for Vim
Bram Moolenaar071d4272004-06-13 20:20:40 +00002
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.
Bram Moolenaarc0394412017-04-20 20:20:23 +020014AC_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_PROG_FGREP dnl finds working grep -F
18AC_ISC_POSIX dnl required by AC_C_CROSS
19AC_PROG_AWK dnl required for "make html" in ../doc
Bram Moolenaar071d4272004-06-13 20:20:40 +000020
21dnl Don't strip if we don't have it
22AC_CHECK_PROG(STRIP, strip, strip, :)
23
Bram Moolenaar325b7a22004-07-05 15:58:32 +000024dnl Check for extension of executables
Bram Moolenaar071d4272004-06-13 20:20:40 +000025AC_EXEEXT
26
Bram Moolenaar446cb832008-06-24 21:56:24 +000027dnl Check for standard headers. We don't use this in Vim but other stuff
28dnl in autoconf needs it, where it uses STDC_HEADERS.
29AC_HEADER_STDC
30AC_HEADER_SYS_WAIT
31
Bram Moolenaarf788a062011-12-14 20:51:25 +010032dnl Check for the flag that fails if stuff are missing.
33
34AC_MSG_CHECKING(--enable-fail-if-missing argument)
35AC_ARG_ENABLE(fail_if_missing,
36 [ --enable-fail-if-missing Fail if dependencies on additional features
37 specified on the command line are missing.],
38 [fail_if_missing="yes"],
39 [fail_if_missing="no"])
40AC_MSG_RESULT($fail_if_missing)
41
Bram Moolenaar071d4272004-06-13 20:20:40 +000042dnl Set default value for CFLAGS if none is defined or it's empty
43if test -z "$CFLAGS"; then
44 CFLAGS="-O"
45 test "$GCC" = yes && CFLAGS="-O2 -fno-strength-reduce -Wall"
46fi
47if test "$GCC" = yes; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +000048 dnl method that should work for nearly all versions
Bram Moolenaarc8836f72014-04-12 13:12:24 +020049 gccversion=`$CC -dumpversion`
Bram Moolenaar910f66f2006-04-05 20:41:53 +000050 if test "x$gccversion" = "x"; then
51 dnl old method; fall-back for when -dumpversion doesn't work
Bram Moolenaarc8836f72014-04-12 13:12:24 +020052 gccversion=`$CC --version | sed -e '2,$d' -e 's/darwin.//' -e 's/^[[^0-9]]*\([[0-9]]\.[[0-9.]]*\).*$/\1/g'`
Bram Moolenaar910f66f2006-04-05 20:41:53 +000053 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +000054 dnl version 4.0.1 was reported to cause trouble on Macintosh by Marcin Dalecki
55 if test "$gccversion" = "3.0.1" -o "$gccversion" = "3.0.2" -o "$gccversion" = "4.0.1"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +000056 echo 'GCC [[34]].0.[[12]] has a bug in the optimizer, disabling "-O#"'
Bram Moolenaar071d4272004-06-13 20:20:40 +000057 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-O/'`
58 else
59 if test "$gccversion" = "3.1" -o "$gccversion" = "3.2" -o "$gccversion" = "3.2.1" && `echo "$CFLAGS" | grep -v fno-strength-reduce >/dev/null`; then
60 echo 'GCC 3.1 and 3.2 have a bug in the optimizer, adding "-fno-strength-reduce"'
61 CFLAGS="$CFLAGS -fno-strength-reduce"
62 fi
63 fi
64fi
65
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +020066dnl clang-500.2.75 or around has abandoned -f[no-]strength-reduce and issues a
67dnl warning when that flag is passed to. Accordingly, adjust CFLAGS based on
68dnl the version number of the clang in use.
69dnl Note that this does not work to get the version of clang 3.1 or 3.2.
Bram Moolenaar5f69fee2017-03-09 11:58:40 +010070AC_MSG_CHECKING(for clang version)
71CLANG_VERSION_STRING=`$CC --version 2>/dev/null | sed -n -e 's/^.*clang[[^0-9]]*\([[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\).*$/\1/p'`
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +020072if test x"$CLANG_VERSION_STRING" != x"" ; then
73 CLANG_MAJOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*/\1/p'`
74 CLANG_MINOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/p'`
75 CLANG_REVISION=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)/\1/p'`
76 CLANG_VERSION=`expr $CLANG_MAJOR '*' 1000000 '+' $CLANG_MINOR '*' 1000 '+' $CLANG_REVISION`
77 AC_MSG_RESULT($CLANG_VERSION)
78 dnl If you find the same issue with versions earlier than 500.2.75,
79 dnl change the constant 500002075 below appropriately. To get the
80 dnl integer corresponding to a version number, refer to the
81 dnl definition of CLANG_VERSION above.
Bram Moolenaar5f69fee2017-03-09 11:58:40 +010082 AC_MSG_CHECKING(if clang supports -fno-strength-reduce)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +020083 if test "$CLANG_VERSION" -ge 500002075 ; then
Bram Moolenaar5f69fee2017-03-09 11:58:40 +010084 AC_MSG_RESULT(no)
85 CFLAGS=`echo "$CFLAGS" | sed -e 's/-fno-strength-reduce/ /'`
86 else
87 AC_MSG_RESULT(yes)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +020088 fi
89else
Bram Moolenaar5f69fee2017-03-09 11:58:40 +010090 AC_MSG_RESULT(N/A)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +020091fi
92
Bram Moolenaar446cb832008-06-24 21:56:24 +000093dnl If configure thinks we are cross compiling, there might be something
94dnl wrong with the CC or CFLAGS settings, give a useful warning message
Bram Moolenaar839e9542016-04-14 16:46:02 +020095CROSS_COMPILING=
Bram Moolenaar071d4272004-06-13 20:20:40 +000096if test "$cross_compiling" = yes; then
Bram Moolenaar446cb832008-06-24 21:56:24 +000097 AC_MSG_RESULT([cannot compile a simple program; if not cross compiling check CC and CFLAGS])
Bram Moolenaar839e9542016-04-14 16:46:02 +020098 CROSS_COMPILING=1
Bram Moolenaar071d4272004-06-13 20:20:40 +000099fi
Bram Moolenaar839e9542016-04-14 16:46:02 +0200100AC_SUBST(CROSS_COMPILING)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000101
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +0000102dnl gcc-cpp has the wonderful -MM option to produce nicer dependencies.
103dnl But gcc 3.1 changed the meaning! See near the end.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000104test "$GCC" = yes && CPP_MM=M; AC_SUBST(CPP_MM)
105
106if test -f ./toolcheck; then
107 AC_CHECKING(for buggy tools)
108 sh ./toolcheck 1>&AC_FD_MSG
109fi
110
111OS_EXTRA_SRC=""; OS_EXTRA_OBJ=""
112
113dnl Check for BeOS, which needs an extra source file
114AC_MSG_CHECKING(for BeOS)
115case `uname` in
116 BeOS) OS_EXTRA_SRC=os_beos.c; OS_EXTRA_OBJ=objects/os_beos.o
117 BEOS=yes; AC_MSG_RESULT(yes);;
118 *) BEOS=no; AC_MSG_RESULT(no);;
119esac
120
121dnl If QNX is found, assume we don't want to use Xphoton
122dnl unless it was specifically asked for (--with-x)
123AC_MSG_CHECKING(for QNX)
124case `uname` in
125 QNX) OS_EXTRA_SRC=os_qnx.c; OS_EXTRA_OBJ=objects/os_qnx.o
126 test -z "$with_x" && with_x=no
127 QNX=yes; AC_MSG_RESULT(yes);;
128 *) QNX=no; AC_MSG_RESULT(no);;
129esac
130
131dnl Check for Darwin and MacOS X
132dnl We do a check for MacOS X in the very beginning because there
133dnl are a lot of other things we need to change besides GUI stuff
Bram Moolenaar071d4272004-06-13 20:20:40 +0000134AC_MSG_CHECKING([for Darwin (Mac OS X)])
135if test "`(uname) 2>/dev/null`" = Darwin; then
136 AC_MSG_RESULT(yes)
Bram Moolenaard0573012017-10-28 21:11:06 +0200137 MACOS_X=yes
138 CPPFLAGS="$CPPFLAGS -DMACOS_X"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000139
140 AC_MSG_CHECKING(--disable-darwin argument)
141 AC_ARG_ENABLE(darwin,
142 [ --disable-darwin Disable Darwin (Mac OS X) support.],
143 , [enable_darwin="yes"])
144 if test "$enable_darwin" = "yes"; then
145 AC_MSG_RESULT(no)
146 AC_MSG_CHECKING(if Darwin files are there)
Bram Moolenaar164fca32010-07-14 13:58:07 +0200147 if test -f os_macosx.m; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000148 AC_MSG_RESULT(yes)
149 else
150 AC_MSG_RESULT([no, Darwin support disabled])
151 enable_darwin=no
152 fi
153 else
154 AC_MSG_RESULT([yes, Darwin support excluded])
155 fi
156
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000157 AC_MSG_CHECKING(--with-mac-arch argument)
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000158 AC_ARG_WITH(mac-arch, [ --with-mac-arch=ARCH current, intel, ppc or both],
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000159 MACARCH="$withval"; AC_MSG_RESULT($MACARCH),
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000160 MACARCH="current"; AC_MSG_RESULT(defaulting to $MACARCH))
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000161
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100162 AC_MSG_CHECKING(--with-developer-dir argument)
163 AC_ARG_WITH(developer-dir, [ --with-developer-dir=PATH use PATH as location for Xcode developer tools],
164 DEVELOPER_DIR="$withval"; AC_MSG_RESULT($DEVELOPER_DIR),
Bram Moolenaar32d03b32015-11-19 13:46:48 +0100165 AC_MSG_RESULT(not present))
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100166
167 if test "x$DEVELOPER_DIR" = "x"; then
168 AC_PATH_PROG(XCODE_SELECT, xcode-select)
169 if test "x$XCODE_SELECT" != "x"; then
170 AC_MSG_CHECKING(for developer dir using xcode-select)
171 DEVELOPER_DIR=`$XCODE_SELECT -print-path`
172 AC_MSG_RESULT([$DEVELOPER_DIR])
173 else
174 DEVELOPER_DIR=/Developer
175 fi
176 fi
177
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000178 if test "x$MACARCH" = "xboth"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000179 AC_MSG_CHECKING(for 10.4 universal SDK)
180 dnl There is a terrible inconsistency (but we appear to get away with it):
181 dnl $CFLAGS uses the 10.4u SDK library for the headers, while $CPPFLAGS
182 dnl doesn't, because "gcc -E" doesn't grok it. That means the configure
183 dnl tests using the preprocessor are actually done with the wrong header
184 dnl files. $LDFLAGS is set at the end, because configure uses it together
185 dnl with $CFLAGS and we can only have one -sysroot argument.
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000186 save_cppflags="$CPPFLAGS"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000187 save_cflags="$CFLAGS"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000188 save_ldflags="$LDFLAGS"
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100189 CFLAGS="$CFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000190 AC_TRY_LINK([ ], [ ],
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000191 AC_MSG_RESULT(found, will make universal binary),
192
193 AC_MSG_RESULT(not found)
Bram Moolenaar1f35bf92006-03-07 22:38:47 +0000194 CFLAGS="$save_cflags"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000195 AC_MSG_CHECKING(if Intel architecture is supported)
196 CPPFLAGS="$CPPFLAGS -arch i386"
197 LDFLAGS="$save_ldflags -arch i386"
198 AC_TRY_LINK([ ], [ ],
199 AC_MSG_RESULT(yes); MACARCH="intel",
200 AC_MSG_RESULT(no, using PowerPC)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000201 MACARCH="ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000202 CPPFLAGS="$save_cppflags -arch ppc"
203 LDFLAGS="$save_ldflags -arch ppc"))
204 elif test "x$MACARCH" = "xintel"; then
205 CPPFLAGS="$CPPFLAGS -arch intel"
206 LDFLAGS="$LDFLAGS -arch intel"
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000207 elif test "x$MACARCH" = "xppc"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000208 CPPFLAGS="$CPPFLAGS -arch ppc"
209 LDFLAGS="$LDFLAGS -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000210 fi
211
Bram Moolenaar071d4272004-06-13 20:20:40 +0000212 if test "$enable_darwin" = "yes"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200213 MACOS_X_DARWIN=yes
Bram Moolenaar164fca32010-07-14 13:58:07 +0200214 OS_EXTRA_SRC="os_macosx.m os_mac_conv.c";
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000215 OS_EXTRA_OBJ="objects/os_macosx.o objects/os_mac_conv.o"
Bram Moolenaar32466aa2006-02-24 23:53:04 +0000216 dnl TODO: use -arch i386 on Intel machines
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100217 dnl Removed -no-cpp-precomp, only for very old compilers.
Bram Moolenaard0573012017-10-28 21:11:06 +0200218 CPPFLAGS="$CPPFLAGS -DMACOS_X_DARWIN"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000219
220 dnl If Carbon is found, assume we don't want X11
221 dnl unless it was specifically asked for (--with-x)
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000222 dnl or Motif, Athena or GTK GUI is used.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000223 AC_CHECK_HEADER(Carbon/Carbon.h, CARBON=yes)
224 if test "x$CARBON" = "xyes"; then
Bram Moolenaar98921892016-02-23 17:14:37 +0100225 if test -z "$with_x" -a "X$enable_gui" != Xmotif -a "X$enable_gui" != Xathena -a "X$enable_gui" != Xgtk2 -a "X$enable_gui" != Xgtk3; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000226 with_x=no
Bram Moolenaar071d4272004-06-13 20:20:40 +0000227 fi
228 fi
229 fi
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000230
Bram Moolenaardb552d602006-03-23 22:59:57 +0000231 dnl Avoid a bug with -O2 with gcc 4.0.1. Symptom: malloc() reports double
Bram Moolenaarfd2ac762006-03-01 22:09:21 +0000232 dnl free. This happens in expand_filename(), because the optimizer swaps
Bram Moolenaardb552d602006-03-23 22:59:57 +0000233 dnl two blocks of code, both using "repl", that can't be swapped.
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000234 if test "$MACARCH" = "intel" -o "$MACARCH" = "both"; then
235 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-Oz/'`
236 fi
237
Bram Moolenaar071d4272004-06-13 20:20:40 +0000238else
239 AC_MSG_RESULT(no)
240fi
241
Bram Moolenaar39766a72013-11-03 00:41:00 +0100242dnl Mac OS X 10.9+ no longer include AvailabilityMacros.h in Carbon
243dnl so we need to include it to have access to version macros.
Bram Moolenaar18e54692013-11-03 20:26:31 +0100244AC_CHECK_HEADERS(AvailabilityMacros.h)
Bram Moolenaar39766a72013-11-03 00:41:00 +0100245
Bram Moolenaar071d4272004-06-13 20:20:40 +0000246AC_SUBST(OS_EXTRA_SRC)
247AC_SUBST(OS_EXTRA_OBJ)
248
249dnl Add /usr/local/lib to $LDFLAGS and /usr/local/include to CFLAGS.
250dnl Only when the directory exists and it wasn't there yet.
251dnl For gcc don't do this when it is already in the default search path.
Bram Moolenaar446cb832008-06-24 21:56:24 +0000252dnl Skip all of this when cross-compiling.
253if test "$cross_compiling" = no; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000254 AC_MSG_CHECKING(--with-local-dir argument)
Bram Moolenaar446cb832008-06-24 21:56:24 +0000255 have_local_include=''
256 have_local_lib=''
Bram Moolenaarc236c162008-07-13 17:41:49 +0000257 AC_ARG_WITH([local-dir], [ --with-local-dir=PATH search PATH instead of /usr/local for local libraries.
258 --without-local-dir do not search /usr/local for local libraries.], [
259 local_dir="$withval"
260 case "$withval" in
261 */*) ;;
262 no)
263 # avoid adding local dir to LDFLAGS and CPPFLAGS
Bram Moolenaare06c1882010-07-21 22:05:20 +0200264 have_local_include=yes
Bram Moolenaarc236c162008-07-13 17:41:49 +0000265 have_local_lib=yes
266 ;;
267 *) AC_MSG_ERROR(must pass path argument to --with-local-dir) ;;
268 esac
269 AC_MSG_RESULT($local_dir)
270 ], [
271 local_dir=/usr/local
272 AC_MSG_RESULT(Defaulting to $local_dir)
273 ])
274 if test "$GCC" = yes -a "$local_dir" != no; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000275 echo 'void f(){}' > conftest.c
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100276 dnl Removed -no-cpp-precomp, only needed for OS X 10.2 (Ben Fowler)
277 have_local_include=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/include"`
Bram Moolenaarc236c162008-07-13 17:41:49 +0000278 have_local_lib=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/lib"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000279 rm -f conftest.c conftest.o
Bram Moolenaar071d4272004-06-13 20:20:40 +0000280 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000281 if test -z "$have_local_lib" -a -d "${local_dir}/lib"; then
282 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 +0000283 if test "$tt" = "$LDFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000284 LDFLAGS="$LDFLAGS -L${local_dir}/lib"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000285 fi
286 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000287 if test -z "$have_local_include" -a -d "${local_dir}/include"; then
288 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 +0000289 if test "$tt" = "$CPPFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000290 CPPFLAGS="$CPPFLAGS -I${local_dir}/include"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000291 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000292 fi
293fi
294
295AC_MSG_CHECKING(--with-vim-name argument)
296AC_ARG_WITH(vim-name, [ --with-vim-name=NAME what to call the Vim executable],
297 VIMNAME="$withval"; AC_MSG_RESULT($VIMNAME),
Bram Moolenaare344bea2005-09-01 20:46:49 +0000298 VIMNAME="vim"; AC_MSG_RESULT(Defaulting to $VIMNAME))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000299AC_SUBST(VIMNAME)
300AC_MSG_CHECKING(--with-ex-name argument)
301AC_ARG_WITH(ex-name, [ --with-ex-name=NAME what to call the Ex executable],
302 EXNAME="$withval"; AC_MSG_RESULT($EXNAME),
303 EXNAME="ex"; AC_MSG_RESULT(Defaulting to ex))
304AC_SUBST(EXNAME)
305AC_MSG_CHECKING(--with-view-name argument)
306AC_ARG_WITH(view-name, [ --with-view-name=NAME what to call the View executable],
307 VIEWNAME="$withval"; AC_MSG_RESULT($VIEWNAME),
308 VIEWNAME="view"; AC_MSG_RESULT(Defaulting to view))
309AC_SUBST(VIEWNAME)
310
311AC_MSG_CHECKING(--with-global-runtime argument)
312AC_ARG_WITH(global-runtime, [ --with-global-runtime=DIR global runtime directory in 'runtimepath'],
313 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL, "$withval"),
314 AC_MSG_RESULT(no))
315
316AC_MSG_CHECKING(--with-modified-by argument)
317AC_ARG_WITH(modified-by, [ --with-modified-by=NAME name of who modified a release version],
318 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(MODIFIED_BY, "$withval"),
319 AC_MSG_RESULT(no))
320
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200321dnl Check for EBCDIC stolen from the LYNX port to z/OS Unix
Bram Moolenaar071d4272004-06-13 20:20:40 +0000322AC_MSG_CHECKING(if character set is EBCDIC)
323AC_TRY_COMPILE([ ],
324[ /* TryCompile function for CharSet.
325 Treat any failure as ASCII for compatibility with existing art.
326 Use compile-time rather than run-time tests for cross-compiler
327 tolerance. */
328#if '0'!=240
329make an error "Character set is not EBCDIC"
330#endif ],
331[ # TryCompile action if true
332cf_cv_ebcdic=yes ],
333[ # TryCompile action if false
334cf_cv_ebcdic=no])
335# end of TryCompile ])
336# end of CacheVal CvEbcdic
337AC_MSG_RESULT($cf_cv_ebcdic)
338case "$cf_cv_ebcdic" in #(vi
339 yes) AC_DEFINE(EBCDIC)
340 line_break='"\\n"'
341 ;;
342 *) line_break='"\\012"';;
343esac
344AC_SUBST(line_break)
345
346if test "$cf_cv_ebcdic" = "yes"; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +0200347dnl If we have EBCDIC we most likely have z/OS Unix, let's test it!
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200348AC_MSG_CHECKING(for z/OS Unix)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000349case `uname` in
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200350 OS/390) zOSUnix="yes";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000351 dnl If using cc the environment variable _CC_CCMODE must be
352 dnl set to "1", so that some compiler extensions are enabled.
353 dnl If using c89 the environment variable is named _CC_C89MODE.
354 dnl Note: compile with c89 never tested.
355 if test "$CC" = "cc"; then
356 ccm="$_CC_CCMODE"
357 ccn="CC"
358 else
359 if test "$CC" = "c89"; then
360 ccm="$_CC_C89MODE"
361 ccn="C89"
362 else
363 ccm=1
364 fi
365 fi
366 if test "$ccm" != "1"; then
367 echo ""
368 echo "------------------------------------------"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200369 echo " On z/OS Unix, the environment variable"
Bram Moolenaar77c19352012-06-13 19:19:41 +0200370 echo " _CC_${ccn}MODE must be set to \"1\"!"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000371 echo " Do:"
372 echo " export _CC_${ccn}MODE=1"
373 echo " and then call configure again."
374 echo "------------------------------------------"
375 exit 1
376 fi
Bram Moolenaar77c19352012-06-13 19:19:41 +0200377 # Set CFLAGS for configure process.
378 # This will be reset later for config.mk.
379 # Use haltonmsg to force error for missing H files.
380 CFLAGS="$CFLAGS -D_ALL_SOURCE -Wc,float(ieee),haltonmsg(3296)";
381 LDFLAGS="$LDFLAGS -Wl,EDIT=NO"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000382 AC_MSG_RESULT(yes)
383 ;;
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200384 *) zOSUnix="no";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000385 AC_MSG_RESULT(no)
386 ;;
387esac
388fi
389
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200390dnl Set QUOTESED. Needs additional backslashes on zOS
391if test "$zOSUnix" = "yes"; then
392 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\\\\\&/g' -e 's/\\\\\\\\\"/\"/' -e 's/\\\\\\\\\";\$\$/\";/'"
393else
394 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\&/g' -e 's/\\\\\"/\"/' -e 's/\\\\\";\$\$/\";/'"
395fi
396AC_SUBST(QUOTESED)
397
398
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200399dnl Link with -lsmack for Smack stuff; if not found
400AC_MSG_CHECKING(--disable-smack argument)
401AC_ARG_ENABLE(smack,
402 [ --disable-smack Do not check for Smack support.],
403 , enable_smack="yes")
404if test "$enable_smack" = "yes"; then
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200405 AC_MSG_RESULT(no)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200406 AC_CHECK_HEADER([linux/xattr.h], true, enable_smack="no")
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200407else
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200408 AC_MSG_RESULT(yes)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200409fi
410if test "$enable_smack" = "yes"; then
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200411 AC_CHECK_HEADER([attr/xattr.h], true, enable_smack="no")
412fi
413if test "$enable_smack" = "yes"; then
414 AC_MSG_CHECKING(for XATTR_NAME_SMACKEXEC in linux/xattr.h)
415 AC_EGREP_CPP(XATTR_NAME_SMACKEXEC, [#include <linux/xattr.h>],
416 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +0200417 AC_MSG_RESULT(no); enable_smack="no")
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200418fi
419if test "$enable_smack" = "yes"; then
420 AC_CHECK_LIB(attr, setxattr,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200421 [LIBS="$LIBS -lattr"
422 found_smack="yes"
423 AC_DEFINE(HAVE_SMACK)])
Bram Moolenaar588ebeb2008-05-07 17:09:24 +0000424fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000425
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200426dnl When smack was found don't search for SELinux
427if test "x$found_smack" = "x"; then
428 dnl Link with -lselinux for SELinux stuff; if not found
429 AC_MSG_CHECKING(--disable-selinux argument)
430 AC_ARG_ENABLE(selinux,
431 [ --disable-selinux Do not check for SELinux support.],
432 , enable_selinux="yes")
433 if test "$enable_selinux" = "yes"; then
434 AC_MSG_RESULT(no)
435 AC_CHECK_LIB(selinux, is_selinux_enabled,
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100436 [AC_CHECK_HEADER(selinux/selinux.h,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200437 [LIBS="$LIBS -lselinux"
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100438 AC_DEFINE(HAVE_SELINUX)])])
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200439 else
440 AC_MSG_RESULT(yes)
441 fi
442fi
443
Bram Moolenaar071d4272004-06-13 20:20:40 +0000444dnl Check user requested features.
445
446AC_MSG_CHECKING(--with-features argument)
Bram Moolenaareec29812016-07-26 21:27:36 +0200447AC_ARG_WITH(features, [ --with-features=TYPE tiny, small, normal, big or huge (default: huge)],
Bram Moolenaar071d4272004-06-13 20:20:40 +0000448 features="$withval"; AC_MSG_RESULT($features),
Bram Moolenaar23c4f712016-01-20 22:11:59 +0100449 features="huge"; AC_MSG_RESULT(Defaulting to huge))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000450
451dovimdiff=""
452dogvimdiff=""
453case "$features" in
454 tiny) AC_DEFINE(FEAT_TINY) ;;
455 small) AC_DEFINE(FEAT_SMALL) ;;
456 normal) AC_DEFINE(FEAT_NORMAL) dovimdiff="installvimdiff";
457 dogvimdiff="installgvimdiff" ;;
458 big) AC_DEFINE(FEAT_BIG) dovimdiff="installvimdiff";
459 dogvimdiff="installgvimdiff" ;;
460 huge) AC_DEFINE(FEAT_HUGE) dovimdiff="installvimdiff";
461 dogvimdiff="installgvimdiff" ;;
462 *) AC_MSG_RESULT([Sorry, $features is not supported]) ;;
463esac
464
465AC_SUBST(dovimdiff)
466AC_SUBST(dogvimdiff)
467
468AC_MSG_CHECKING(--with-compiledby argument)
469AC_ARG_WITH(compiledby, [ --with-compiledby=NAME name to show in :version message],
470 compiledby="$withval"; AC_MSG_RESULT($withval),
471 compiledby=""; AC_MSG_RESULT(no))
472AC_SUBST(compiledby)
473
474AC_MSG_CHECKING(--disable-xsmp argument)
475AC_ARG_ENABLE(xsmp,
476 [ --disable-xsmp Disable XSMP session management],
477 , enable_xsmp="yes")
478
479if test "$enable_xsmp" = "yes"; then
480 AC_MSG_RESULT(no)
481 AC_MSG_CHECKING(--disable-xsmp-interact argument)
482 AC_ARG_ENABLE(xsmp-interact,
483 [ --disable-xsmp-interact Disable XSMP interaction],
484 , enable_xsmp_interact="yes")
485 if test "$enable_xsmp_interact" = "yes"; then
486 AC_MSG_RESULT(no)
487 AC_DEFINE(USE_XSMP_INTERACT)
488 else
489 AC_MSG_RESULT(yes)
490 fi
491else
492 AC_MSG_RESULT(yes)
493fi
494
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200495dnl Check for Lua feature.
496AC_MSG_CHECKING(--enable-luainterp argument)
497AC_ARG_ENABLE(luainterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200498 [ --enable-luainterp[=OPTS] Include Lua interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200499 [enable_luainterp="no"])
500AC_MSG_RESULT($enable_luainterp)
501
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200502if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +0100503 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
504 AC_MSG_ERROR([cannot use Lua with tiny or small features])
505 fi
506
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200507 dnl -- find the lua executable
508 AC_SUBST(vi_cv_path_lua)
509
510 AC_MSG_CHECKING(--with-lua-prefix argument)
511 AC_ARG_WITH(lua_prefix,
512 [ --with-lua-prefix=PFX Prefix where Lua is installed.],
513 with_lua_prefix="$withval"; AC_MSG_RESULT($with_lua_prefix),
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200514 with_lua_prefix="";AC_MSG_RESULT(no))
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200515
516 if test "X$with_lua_prefix" != "X"; then
517 vi_cv_path_lua_pfx="$with_lua_prefix"
518 else
519 AC_MSG_CHECKING(LUA_PREFIX environment var)
520 if test "X$LUA_PREFIX" != "X"; then
521 AC_MSG_RESULT("$LUA_PREFIX")
522 vi_cv_path_lua_pfx="$LUA_PREFIX"
523 else
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200524 AC_MSG_RESULT([not set, default to /usr])
525 vi_cv_path_lua_pfx="/usr"
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200526 fi
527 fi
528
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200529 AC_MSG_CHECKING(--with-luajit)
530 AC_ARG_WITH(luajit,
531 [ --with-luajit Link with LuaJIT instead of Lua.],
532 [vi_cv_with_luajit="$withval"],
533 [vi_cv_with_luajit="no"])
534 AC_MSG_RESULT($vi_cv_with_luajit)
535
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200536 LUA_INC=
537 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200538 if test "x$vi_cv_with_luajit" != "xno"; then
539 dnl -- try to find LuaJIT executable
540 AC_PATH_PROG(vi_cv_path_luajit, luajit)
541 if test "X$vi_cv_path_luajit" != "X"; then
542 dnl -- find LuaJIT version
543 AC_CACHE_CHECK(LuaJIT version, vi_cv_version_luajit,
Bram Moolenaar49b10272013-11-21 12:17:51 +0100544 [ vi_cv_version_luajit=`${vi_cv_path_luajit} -v 2>&1 | sed 's/LuaJIT \([[0-9.]]*\)\.[[0-9]]\(-[[a-z0-9]]*\)* .*/\1/'` ])
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200545 AC_CACHE_CHECK(Lua version of LuaJIT, vi_cv_version_lua_luajit,
546 [ vi_cv_version_lua_luajit=`${vi_cv_path_luajit} -e "print(_VERSION)" | sed 's/.* //'` ])
547 vi_cv_path_lua="$vi_cv_path_luajit"
548 vi_cv_version_lua="$vi_cv_version_lua_luajit"
549 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200550 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200551 dnl -- try to find Lua executable
552 AC_PATH_PROG(vi_cv_path_plain_lua, lua)
553 if test "X$vi_cv_path_plain_lua" != "X"; then
554 dnl -- find Lua version
555 AC_CACHE_CHECK(Lua version, vi_cv_version_plain_lua,
556 [ vi_cv_version_plain_lua=`${vi_cv_path_plain_lua} -e "print(_VERSION)" | sed 's/.* //'` ])
557 fi
558 vi_cv_path_lua="$vi_cv_path_plain_lua"
559 vi_cv_version_lua="$vi_cv_version_plain_lua"
560 fi
561 if test "x$vi_cv_with_luajit" != "xno" && test "X$vi_cv_version_luajit" != "X"; then
562 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit)
Bram Moolenaar49222be2015-12-11 18:11:30 +0100563 if test -f "$vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200564 AC_MSG_RESULT(yes)
565 LUA_INC=/luajit-$vi_cv_version_luajit
566 fi
567 fi
568 if test "X$LUA_INC" = "X"; then
569 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)
Bram Moolenaar49222be2015-12-11 18:11:30 +0100570 if test -f "$vi_cv_path_lua_pfx/include/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200571 AC_MSG_RESULT(yes)
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200572 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200573 AC_MSG_RESULT(no)
574 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua)
Bram Moolenaar49222be2015-12-11 18:11:30 +0100575 if test -f "$vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200576 AC_MSG_RESULT(yes)
577 LUA_INC=/lua$vi_cv_version_lua
578 else
579 AC_MSG_RESULT(no)
580 vi_cv_path_lua_pfx=
581 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200582 fi
583 fi
584 fi
585
586 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200587 if test "x$vi_cv_with_luajit" != "xno"; then
588 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
589 if test "X$multiarch" != "X"; then
590 lib_multiarch="lib/${multiarch}"
591 else
592 lib_multiarch="lib"
593 fi
594 if test "X$vi_cv_version_lua" = "X"; then
595 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit"
596 else
597 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit-$vi_cv_version_lua"
598 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200599 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200600 if test "X$LUA_INC" != "X"; then
601 dnl Test alternate location using version
602 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua$vi_cv_version_lua"
603 else
604 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua"
605 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200606 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200607 if test "$enable_luainterp" = "dynamic"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200608 lua_ok="yes"
609 else
610 AC_MSG_CHECKING([if link with ${LUA_LIBS} is sane])
611 libs_save=$LIBS
612 LIBS="$LIBS $LUA_LIBS"
613 AC_TRY_LINK(,[ ],
614 AC_MSG_RESULT(yes); lua_ok="yes",
615 AC_MSG_RESULT(no); lua_ok="no"; LUA_LIBS="")
616 LIBS=$libs_save
617 fi
618 if test "x$lua_ok" = "xyes"; then
619 LUA_CFLAGS="-I${vi_cv_path_lua_pfx}/include${LUA_INC}"
620 LUA_SRC="if_lua.c"
621 LUA_OBJ="objects/if_lua.o"
622 LUA_PRO="if_lua.pro"
623 AC_DEFINE(FEAT_LUA)
624 fi
625 if test "$enable_luainterp" = "dynamic"; then
626 if test "x$vi_cv_with_luajit" != "xno"; then
627 luajit="jit"
628 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200629 if test -f "${vi_cv_path_lua_pfx}/bin/cyglua-${vi_cv_version_lua}.dll"; then
630 vi_cv_dll_name_lua="cyglua-${vi_cv_version_lua}.dll"
631 else
Bram Moolenaard0573012017-10-28 21:11:06 +0200632 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200633 ext="dylib"
634 indexes=""
635 else
636 ext="so"
637 indexes=".0 .1 .2 .3 .4 .5 .6 .7 .8 .9"
638 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
639 if test "X$multiarch" != "X"; then
640 lib_multiarch="lib/${multiarch}"
641 fi
Bram Moolenaar768baac2013-04-15 14:44:57 +0200642 fi
643 dnl Determine the sover for the current version, but fallback to
644 dnl liblua${vi_cv_version_lua}.so if no sover-versioned file is found.
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200645 AC_MSG_CHECKING(if liblua${luajit}*.${ext}* can be found in $vi_cv_path_lua_pfx)
Bram Moolenaar768baac2013-04-15 14:44:57 +0200646 for subdir in "${lib_multiarch}" lib64 lib; do
647 if test -z "$subdir"; then
648 continue
649 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200650 for sover in "${vi_cv_version_lua}.${ext}" "-${vi_cv_version_lua}.${ext}" \
651 ".${vi_cv_version_lua}.${ext}" ".${ext}.${vi_cv_version_lua}"; do
652 for i in $indexes ""; do
653 if test -f "${vi_cv_path_lua_pfx}/${subdir}/liblua${luajit}${sover}$i"; then
Bram Moolenaar768baac2013-04-15 14:44:57 +0200654 sover2="$i"
655 break 3
656 fi
657 done
Bram Moolenaar07e1da62013-02-06 19:49:43 +0100658 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200659 sover=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200660 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200661 if test "X$sover" = "X"; then
662 AC_MSG_RESULT(no)
663 lua_ok="no"
664 vi_cv_dll_name_lua="liblua${luajit}.${ext}"
665 else
666 AC_MSG_RESULT(yes)
667 lua_ok="yes"
668 vi_cv_dll_name_lua="liblua${luajit}${sover}$sover2"
669 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200670 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200671 AC_DEFINE(DYNAMIC_LUA)
672 LUA_LIBS=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200673 LUA_CFLAGS="-DDYNAMIC_LUA_DLL=\\\"${vi_cv_dll_name_lua}\\\" $LUA_CFLAGS"
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200674 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200675 if test "X$LUA_CFLAGS$LUA_LIBS" != "X" && \
Bram Moolenaard0573012017-10-28 21:11:06 +0200676 test "x$MACOS_X" = "xyes" && test "x$vi_cv_with_luajit" != "xno" && \
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200677 test "`(uname -m) 2>/dev/null`" = "x86_64"; then
678 dnl OSX/x64 requires these flags. See http://luajit.org/install.html
679 LUA_LIBS="-pagezero_size 10000 -image_base 100000000 $LUA_LIBS"
680 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200681 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200682 if test "$fail_if_missing" = "yes" -a "$lua_ok" != "yes"; then
Bram Moolenaarf788a062011-12-14 20:51:25 +0100683 AC_MSG_ERROR([could not configure lua])
684 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200685 AC_SUBST(LUA_SRC)
686 AC_SUBST(LUA_OBJ)
687 AC_SUBST(LUA_PRO)
688 AC_SUBST(LUA_LIBS)
689 AC_SUBST(LUA_CFLAGS)
690fi
691
692
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000693dnl Check for MzScheme feature.
694AC_MSG_CHECKING(--enable-mzschemeinterp argument)
695AC_ARG_ENABLE(mzschemeinterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200696 [ --enable-mzschemeinterp Include MzScheme interpreter.], ,
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000697 [enable_mzschemeinterp="no"])
698AC_MSG_RESULT($enable_mzschemeinterp)
699
700if test "$enable_mzschemeinterp" = "yes"; then
701 dnl -- find the mzscheme executable
702 AC_SUBST(vi_cv_path_mzscheme)
703
704 AC_MSG_CHECKING(--with-plthome argument)
705 AC_ARG_WITH(plthome,
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000706 [ --with-plthome=PLTHOME Use PLTHOME.],
707 with_plthome="$withval"; AC_MSG_RESULT($with_plthome),
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000708 with_plthome="";AC_MSG_RESULT("no"))
709
710 if test "X$with_plthome" != "X"; then
711 vi_cv_path_mzscheme_pfx="$with_plthome"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100712 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000713 else
714 AC_MSG_CHECKING(PLTHOME environment var)
715 if test "X$PLTHOME" != "X"; then
716 AC_MSG_RESULT("$PLTHOME")
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000717 vi_cv_path_mzscheme_pfx="$PLTHOME"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100718 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000719 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000720 AC_MSG_RESULT(not set)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000721 dnl -- try to find MzScheme executable
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000722 AC_PATH_PROG(vi_cv_path_mzscheme, mzscheme)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000723
724 dnl resolve symbolic link, the executable is often elsewhere and there
725 dnl are no links for the include files.
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000726 if test "X$vi_cv_path_mzscheme" != "X"; then
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000727 lsout=`ls -l $vi_cv_path_mzscheme`
728 if echo "$lsout" | grep -e '->' >/dev/null 2>/dev/null; then
729 vi_cv_path_mzscheme=`echo "$lsout" | sed 's/.*-> \(.*\)/\1/'`
730 fi
731 fi
732
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000733 if test "X$vi_cv_path_mzscheme" != "X"; then
734 dnl -- find where MzScheme thinks it was installed
735 AC_CACHE_CHECK(MzScheme install prefix,vi_cv_path_mzscheme_pfx,
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000736 dnl different versions of MzScheme differ in command line processing
737 dnl use universal approach
738 echo "(display (simplify-path \
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000739 (build-path (call-with-values \
740 (lambda () (split-path (find-system-path (quote exec-file)))) \
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000741 (lambda (base name must-be-dir?) base)) (quote up))))" > mzdirs.scm
742 dnl Remove a trailing slash
743 [ vi_cv_path_mzscheme_pfx=`${vi_cv_path_mzscheme} -r mzdirs.scm | \
744 sed -e 's+/$++'` ])
745 rm -f mzdirs.scm
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000746 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000747 fi
748 fi
749
750 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100751 AC_MSG_CHECKING(for racket include directory)
752 SCHEME_INC=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-include-dir))) (when (path? p) (display p)))'`
753 if test "X$SCHEME_INC" != "X"; then
754 AC_MSG_RESULT(${SCHEME_INC})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000755 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100756 AC_MSG_RESULT(not found)
757 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include)
758 if test -f "$vi_cv_path_mzscheme_pfx/include/scheme.h"; then
759 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000760 AC_MSG_RESULT(yes)
Bram Moolenaard7afed32007-05-06 13:26:41 +0000761 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000762 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100763 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt)
764 if test -f "$vi_cv_path_mzscheme_pfx/include/plt/scheme.h"; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000765 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100766 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000767 else
768 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100769 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket)
770 if test -f "$vi_cv_path_mzscheme_pfx/include/racket/scheme.h"; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100771 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100772 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100773 else
774 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100775 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/)
776 if test -f /usr/include/plt/scheme.h; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100777 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100778 SCHEME_INC=/usr/include/plt
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100779 else
780 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100781 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/racket/)
782 if test -f /usr/include/racket/scheme.h; then
783 AC_MSG_RESULT(yes)
784 SCHEME_INC=/usr/include/racket
785 else
786 AC_MSG_RESULT(no)
787 vi_cv_path_mzscheme_pfx=
788 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100789 fi
790 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000791 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000792 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000793 fi
794 fi
795
796 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100797
798 AC_MSG_CHECKING(for racket lib directory)
799 SCHEME_LIB=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-lib-dir))) (when (path? p) (display p)))'`
800 if test "X$SCHEME_LIB" != "X"; then
801 AC_MSG_RESULT(${SCHEME_LIB})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000802 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100803 AC_MSG_RESULT(not found)
804 fi
805
806 for path in "${vi_cv_path_mzscheme_pfx}/lib" "${SCHEME_LIB}"; do
807 if test "X$path" != "X"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200808 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100809 MZSCHEME_LIBS="-framework Racket"
810 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
811 elif test -f "${path}/libmzscheme3m.a"; then
812 MZSCHEME_LIBS="${path}/libmzscheme3m.a"
813 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
814 elif test -f "${path}/libracket3m.a"; then
815 MZSCHEME_LIBS="${path}/libracket3m.a"
816 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
817 elif test -f "${path}/libracket.a"; then
818 MZSCHEME_LIBS="${path}/libracket.a ${path}/libmzgc.a"
819 elif test -f "${path}/libmzscheme.a"; then
820 MZSCHEME_LIBS="${path}/libmzscheme.a ${path}/libmzgc.a"
821 else
822 dnl Using shared objects
823 if test -f "${path}/libmzscheme3m.so"; then
824 MZSCHEME_LIBS="-L${path} -lmzscheme3m"
825 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
826 elif test -f "${path}/libracket3m.so"; then
827 MZSCHEME_LIBS="-L${path} -lracket3m"
828 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
829 elif test -f "${path}/libracket.so"; then
830 MZSCHEME_LIBS="-L${path} -lracket -lmzgc"
831 else
832 dnl try next until last
833 if test "$path" != "$SCHEME_LIB"; then
834 continue
835 fi
836 MZSCHEME_LIBS="-L${path} -lmzscheme -lmzgc"
837 fi
838 if test "$GCC" = yes; then
839 dnl Make Vim remember the path to the library. For when it's not in
840 dnl $LD_LIBRARY_PATH.
841 MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${path}"
842 elif test "`(uname) 2>/dev/null`" = SunOS &&
843 uname -r | grep '^5' >/dev/null; then
844 MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${path}"
845 fi
846 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000847 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100848 if test "X$MZSCHEME_LIBS" != "X"; then
849 break
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +0000850 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100851 done
852
853 AC_MSG_CHECKING([if racket requires -pthread])
854 if test "X$SCHEME_LIB" != "X" && $FGREP -e -pthread "$SCHEME_LIB/buildinfo" >/dev/null ; then
855 AC_MSG_RESULT(yes)
856 MZSCHEME_LIBS="${MZSCHEME_LIBS} -pthread"
857 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -pthread"
858 else
859 AC_MSG_RESULT(no)
860 fi
861
862 AC_MSG_CHECKING(for racket config directory)
863 SCHEME_CONFIGDIR=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-config-dir))) (when (path? p) (display p)))'`
864 if test "X$SCHEME_CONFIGDIR" != "X"; then
865 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DMZSCHEME_CONFIGDIR='\"${SCHEME_CONFIGDIR}\"'"
866 AC_MSG_RESULT(${SCHEME_CONFIGDIR})
867 else
868 AC_MSG_RESULT(not found)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000869 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100870
871 AC_MSG_CHECKING(for racket collects directory)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100872 SCHEME_COLLECTS=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-collects-dir))) (when (path? p) (let-values (((base _1 _2) (split-path p))) (display base))))'`
873 if test "X$SCHEME_COLLECTS" = "X"; then
874 if test -d "$vi_cv_path_mzscheme_pfx/lib/plt/collects"; then
875 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/plt/
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100876 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100877 if test -d "$vi_cv_path_mzscheme_pfx/lib/racket/collects"; then
878 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/racket/
Bram Moolenaar75676462013-01-30 14:55:42 +0100879 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100880 if test -d "$vi_cv_path_mzscheme_pfx/share/racket/collects"; then
881 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/
882 else
883 if test -d "$vi_cv_path_mzscheme_pfx/collects"; then
884 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/
885 fi
Bram Moolenaar75676462013-01-30 14:55:42 +0100886 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100887 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100888 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000889 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100890 if test "X$SCHEME_COLLECTS" != "X" ; then
891 AC_MSG_RESULT(${SCHEME_COLLECTS})
892 else
893 AC_MSG_RESULT(not found)
894 fi
895
896 AC_MSG_CHECKING(for mzscheme_base.c)
897 if test -f "${SCHEME_COLLECTS}collects/scheme/base.ss" ; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000898 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +0100899 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
900 MZSCHEME_MOD="++lib scheme/base"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100901 else
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100902 if test -f "${SCHEME_COLLECTS}collects/scheme/base.rkt" ; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100903 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +0100904 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
905 MZSCHEME_MOD="++lib scheme/base"
906 else
907 if test -f "${SCHEME_COLLECTS}collects/racket/base.rkt" ; then
908 MZSCHEME_EXTRA="mzscheme_base.c"
909 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/raco ctool"
910 MZSCHEME_MOD=""
911 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100912 fi
913 fi
914 if test "X$MZSCHEME_EXTRA" != "X" ; then
915 dnl need to generate bytecode for MzScheme base
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000916 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE"
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100917 AC_MSG_RESULT(needed)
918 else
919 AC_MSG_RESULT(not needed)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000920 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100921
Bram Moolenaar9e902192013-07-17 18:58:11 +0200922 dnl On Ubuntu this fixes "undefined reference to symbol 'ffi_type_void'".
923 AC_CHECK_LIB(ffi, ffi_type_void, [MZSCHEME_LIBS="$MZSCHEME_LIBS -lffi"])
924
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000925 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -I${SCHEME_INC} \
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100926 -DMZSCHEME_COLLECTS='\"${SCHEME_COLLECTS}collects\"'"
Bram Moolenaar9e902192013-07-17 18:58:11 +0200927
928 dnl Test that we can compile a simple program with these CFLAGS and LIBS.
929 AC_MSG_CHECKING([if compile and link flags for MzScheme are sane])
930 cflags_save=$CFLAGS
931 libs_save=$LIBS
932 CFLAGS="$CFLAGS $MZSCHEME_CFLAGS"
933 LIBS="$LIBS $MZSCHEME_LIBS"
934 AC_TRY_LINK(,[ ],
935 AC_MSG_RESULT(yes); mzs_ok=yes,
936 AC_MSG_RESULT(no: MZSCHEME DISABLED); mzs_ok=no)
937 CFLAGS=$cflags_save
938 LIBS=$libs_save
939 if test $mzs_ok = yes; then
940 MZSCHEME_SRC="if_mzsch.c"
941 MZSCHEME_OBJ="objects/if_mzsch.o"
942 MZSCHEME_PRO="if_mzsch.pro"
943 AC_DEFINE(FEAT_MZSCHEME)
944 else
945 MZSCHEME_CFLAGS=
946 MZSCHEME_LIBS=
947 MZSCHEME_EXTRA=
948 MZSCHEME_MZC=
949 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000950 fi
951 AC_SUBST(MZSCHEME_SRC)
952 AC_SUBST(MZSCHEME_OBJ)
953 AC_SUBST(MZSCHEME_PRO)
954 AC_SUBST(MZSCHEME_LIBS)
955 AC_SUBST(MZSCHEME_CFLAGS)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000956 AC_SUBST(MZSCHEME_EXTRA)
957 AC_SUBST(MZSCHEME_MZC)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000958fi
959
960
Bram Moolenaar071d4272004-06-13 20:20:40 +0000961AC_MSG_CHECKING(--enable-perlinterp argument)
962AC_ARG_ENABLE(perlinterp,
Bram Moolenaare06c1882010-07-21 22:05:20 +0200963 [ --enable-perlinterp[=OPTS] Include Perl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000964 [enable_perlinterp="no"])
965AC_MSG_RESULT($enable_perlinterp)
Bram Moolenaare06c1882010-07-21 22:05:20 +0200966if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +0100967 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
968 AC_MSG_ERROR([cannot use Perl with tiny or small features])
969 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000970 AC_SUBST(vi_cv_path_perl)
971 AC_PATH_PROG(vi_cv_path_perl, perl)
972 if test "X$vi_cv_path_perl" != "X"; then
973 AC_MSG_CHECKING(Perl version)
974 if $vi_cv_path_perl -e 'require 5.003_01' >/dev/null 2>/dev/null; then
975 eval `$vi_cv_path_perl -V:usethreads`
Bram Moolenaare06c1882010-07-21 22:05:20 +0200976 eval `$vi_cv_path_perl -V:libperl`
Bram Moolenaar071d4272004-06-13 20:20:40 +0000977 if test "X$usethreads" = "XUNKNOWN" -o "X$usethreads" = "Xundef"; then
978 badthreads=no
979 else
980 if $vi_cv_path_perl -e 'require 5.6.0' >/dev/null 2>/dev/null; then
981 eval `$vi_cv_path_perl -V:use5005threads`
982 if test "X$use5005threads" = "XUNKNOWN" -o "X$use5005threads" = "Xundef"; then
983 badthreads=no
984 else
985 badthreads=yes
986 AC_MSG_RESULT(>>> Perl > 5.6 with 5.5 threads cannot be used <<<)
987 fi
988 else
989 badthreads=yes
990 AC_MSG_RESULT(>>> Perl 5.5 with threads cannot be used <<<)
991 fi
992 fi
993 if test $badthreads = no; then
994 AC_MSG_RESULT(OK)
995 eval `$vi_cv_path_perl -V:shrpenv`
996 if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04
997 shrpenv=""
998 fi
999 vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlibexp}'`
1000 AC_SUBST(vi_cv_perllib)
Bram Moolenaard5f62b12014-08-17 17:05:44 +02001001 vi_cv_perl_extutils=unknown_perl_extutils_path
1002 for extutils_rel_path in ExtUtils vendor_perl/ExtUtils; do
1003 xsubpp_path="$vi_cv_perllib/$extutils_rel_path/xsubpp"
1004 if test -f "$xsubpp_path"; then
1005 vi_cv_perl_xsubpp="$xsubpp_path"
1006 fi
1007 done
1008 AC_SUBST(vi_cv_perl_xsubpp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001009 dnl Remove "-fno-something", it breaks using cproto.
Bram Moolenaar280a8682015-06-21 13:41:08 +02001010 dnl Remove "-fdebug-prefix-map", it isn't supported by clang.
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001011 dnl Remove "FORTIFY_SOURCE", it will be defined twice.
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001012 dnl remove -pipe and -Wxxx, it confuses cproto
Bram Moolenaar071d4272004-06-13 20:20:40 +00001013 perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001014 -e 'ccflags;perl_inc;print"\n"' | sed -e 's/-fno[[^ ]]*//' \
1015 -e 's/-fdebug-prefix-map[[^ ]]*//g' \
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001016 -e 's/-pipe //' \
1017 -e 's/-W[[^ ]]*//g' \
1018 -e 's/-D_FORTIFY_SOURCE=.//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001019 dnl Remove "-lc", it breaks on FreeBSD when using "-pthread".
1020 perllibs=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed -e 'ldopts' | \
1021 sed -e '/Warning/d' -e '/Note (probably harmless)/d' \
1022 -e 's/-bE:perl.exp//' -e 's/-lc //'`
1023 dnl Don't add perl lib to $LIBS: if it's not in LD_LIBRARY_PATH
1024 dnl a test in configure may fail because of that.
1025 perlldflags=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed \
1026 -e 'ccdlflags' | sed -e 's/-bE:perl.exp//'`
1027
1028 dnl check that compiling a simple program still works with the flags
1029 dnl added for Perl.
1030 AC_MSG_CHECKING([if compile and link flags for Perl are sane])
1031 cflags_save=$CFLAGS
1032 libs_save=$LIBS
1033 ldflags_save=$LDFLAGS
1034 CFLAGS="$CFLAGS $perlcppflags"
1035 LIBS="$LIBS $perllibs"
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001036 perlldflags=`echo "$perlldflags" | sed -e 's/^ *//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001037 LDFLAGS="$perlldflags $LDFLAGS"
1038 AC_TRY_LINK(,[ ],
1039 AC_MSG_RESULT(yes); perl_ok=yes,
1040 AC_MSG_RESULT(no: PERL DISABLED); perl_ok=no)
1041 CFLAGS=$cflags_save
1042 LIBS=$libs_save
1043 LDFLAGS=$ldflags_save
1044 if test $perl_ok = yes; then
1045 if test "X$perlcppflags" != "X"; then
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001046 PERL_CFLAGS=$perlcppflags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001047 fi
1048 if test "X$perlldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001049 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$perlldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001050 LDFLAGS="$perlldflags $LDFLAGS"
1051 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001052 fi
1053 PERL_LIBS=$perllibs
1054 PERL_SRC="auto/if_perl.c if_perlsfio.c"
1055 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o"
1056 PERL_PRO="if_perl.pro if_perlsfio.pro"
1057 AC_DEFINE(FEAT_PERL)
1058 fi
1059 fi
1060 else
1061 AC_MSG_RESULT(>>> too old; need Perl version 5.003_01 or later <<<)
1062 fi
1063 fi
1064
Bram Moolenaard0573012017-10-28 21:11:06 +02001065 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00001066 dnl Mac OS X 10.2 or later
Bram Moolenaar071d4272004-06-13 20:20:40 +00001067 dir=/System/Library/Perl
1068 darwindir=$dir/darwin
1069 if test -d $darwindir; then
1070 PERL=/usr/bin/perl
1071 else
1072 dnl Mac OS X 10.3
1073 dir=/System/Library/Perl/5.8.1
1074 darwindir=$dir/darwin-thread-multi-2level
1075 if test -d $darwindir; then
1076 PERL=/usr/bin/perl
1077 fi
1078 fi
1079 if test -n "$PERL"; then
1080 PERL_DIR="$dir"
1081 PERL_CFLAGS="-DFEAT_PERL -I$darwindir/CORE"
1082 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o $darwindir/auto/DynaLoader/DynaLoader.a"
1083 PERL_LIBS="-L$darwindir/CORE -lperl"
1084 fi
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001085 dnl Perl on Mac OS X 10.5 adds "-arch" flags but these should only
1086 dnl be included if requested by passing --with-mac-arch to
1087 dnl configure, so strip these flags first (if present)
1088 PERL_LIBS=`echo "$PERL_LIBS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
1089 PERL_CFLAGS=`echo "$PERL_CFLAGS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001090 fi
Bram Moolenaare06c1882010-07-21 22:05:20 +02001091 if test "$enable_perlinterp" = "dynamic"; then
1092 if test "$perl_ok" = "yes" -a "X$libperl" != "X"; then
1093 AC_DEFINE(DYNAMIC_PERL)
1094 PERL_CFLAGS="-DDYNAMIC_PERL_DLL=\\\"$libperl\\\" $PERL_CFLAGS"
1095 fi
1096 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001097
1098 if test "$fail_if_missing" = "yes" -a "$perl_ok" != "yes"; then
1099 AC_MSG_ERROR([could not configure perl])
1100 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001101fi
1102AC_SUBST(shrpenv)
1103AC_SUBST(PERL_SRC)
1104AC_SUBST(PERL_OBJ)
1105AC_SUBST(PERL_PRO)
1106AC_SUBST(PERL_CFLAGS)
1107AC_SUBST(PERL_LIBS)
1108
1109AC_MSG_CHECKING(--enable-pythoninterp argument)
1110AC_ARG_ENABLE(pythoninterp,
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001111 [ --enable-pythoninterp[=OPTS] Include Python interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001112 [enable_pythoninterp="no"])
1113AC_MSG_RESULT($enable_pythoninterp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001114if test "$enable_pythoninterp" = "yes" -o "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001115 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1116 AC_MSG_ERROR([cannot use Python with tiny or small features])
1117 fi
1118
Bram Moolenaar071d4272004-06-13 20:20:40 +00001119 dnl -- find the python executable
Bram Moolenaar09ba6d72012-12-12 14:25:05 +01001120 AC_PATH_PROGS(vi_cv_path_python, python2 python)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001121 if test "X$vi_cv_path_python" != "X"; then
1122
1123 dnl -- get its version number
1124 AC_CACHE_CHECK(Python version,vi_cv_var_python_version,
1125 [[vi_cv_var_python_version=`
1126 ${vi_cv_path_python} -c 'import sys; print sys.version[:3]'`
1127 ]])
1128
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001129 dnl -- it must be at least version 2.3
1130 AC_MSG_CHECKING(Python is 2.3 or better)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001131 if ${vi_cv_path_python} -c \
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001132 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001133 then
1134 AC_MSG_RESULT(yep)
1135
1136 dnl -- find where python thinks it was installed
1137 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python_pfx,
1138 [ vi_cv_path_python_pfx=`
1139 ${vi_cv_path_python} -c \
1140 "import sys; print sys.prefix"` ])
1141
1142 dnl -- and where it thinks it runs
1143 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python_epfx,
1144 [ vi_cv_path_python_epfx=`
1145 ${vi_cv_path_python} -c \
1146 "import sys; print sys.exec_prefix"` ])
1147
1148 dnl -- python's internal library path
1149
1150 AC_CACHE_VAL(vi_cv_path_pythonpath,
1151 [ vi_cv_path_pythonpath=`
1152 unset PYTHONPATH;
1153 ${vi_cv_path_python} -c \
1154 "import sys, string; print string.join(sys.path,':')"` ])
1155
1156 dnl -- where the Python implementation library archives are
1157
1158 AC_ARG_WITH(python-config-dir,
1159 [ --with-python-config-dir=PATH Python's config directory],
Bram Moolenaard0882402018-04-10 18:13:05 +02001160 [ vi_cv_path_python_conf="${withval}"; have_python_config_dir=1 ] )
Bram Moolenaar071d4272004-06-13 20:20:40 +00001161
1162 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python_conf,
1163 [
1164 vi_cv_path_python_conf=
Bram Moolenaarac499e32013-06-02 19:14:17 +02001165 d=`${vi_cv_path_python} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBPL')"`
1166 if test -d "$d" && test -f "$d/config.c"; then
1167 vi_cv_path_python_conf="$d"
1168 else
1169 for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
1170 for subdir in lib64 lib share; do
1171 d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
1172 if test -d "$d" && test -f "$d/config.c"; then
1173 vi_cv_path_python_conf="$d"
1174 fi
1175 done
Bram Moolenaar071d4272004-06-13 20:20:40 +00001176 done
Bram Moolenaarac499e32013-06-02 19:14:17 +02001177 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001178 ])
1179
1180 PYTHON_CONFDIR="${vi_cv_path_python_conf}"
1181
1182 if test "X$PYTHON_CONFDIR" = "X"; then
1183 AC_MSG_RESULT([can't find it!])
1184 else
1185
1186 dnl -- we need to examine Python's config/Makefile too
1187 dnl see what the interpreter is built from
1188 AC_CACHE_VAL(vi_cv_path_python_plibs,
1189 [
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001190 pwd=`pwd`
1191 tmp_mkf="$pwd/config-PyMake$$"
1192 cat -- "${PYTHON_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001193__:
Bram Moolenaar218116c2010-05-20 21:46:00 +02001194 @echo "python_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001195 @echo "python_LIBS='$(LIBS)'"
1196 @echo "python_SYSLIBS='$(SYSLIBS)'"
1197 @echo "python_LINKFORSHARED='$(LINKFORSHARED)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001198 @echo "python_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001199 @echo "python_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001200 @echo "python_PYTHONFRAMEWORK='$(PYTHONFRAMEWORK)'"
1201 @echo "python_PYTHONFRAMEWORKPREFIX='$(PYTHONFRAMEWORKPREFIX)'"
1202 @echo "python_PYTHONFRAMEWORKINSTALLDIR='$(PYTHONFRAMEWORKINSTALLDIR)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001203eof
1204 dnl -- delete the lines from make about Entering/Leaving directory
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001205 eval "`cd ${PYTHON_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1206 rm -f -- "${tmp_mkf}"
Bram Moolenaard0573012017-10-28 21:11:06 +02001207 if test "x$MACOS_X" = "xyes" && test -n "${python_PYTHONFRAMEWORK}" && ${vi_cv_path_python} -c \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001208 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then
1209 vi_cv_path_python_plibs="-framework Python"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001210 if test "x${vi_cv_path_python}" != "x/usr/bin/python" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
1211 vi_cv_path_python_plibs="-F${python_PYTHONFRAMEWORKPREFIX} -framework Python"
1212 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001213 else
1214 if test "${vi_cv_var_python_version}" = "1.4"; then
1215 vi_cv_path_python_plibs="${PYTHON_CONFDIR}/libModules.a ${PYTHON_CONFDIR}/libPython.a ${PYTHON_CONFDIR}/libObjects.a ${PYTHON_CONFDIR}/libParser.a"
1216 else
1217 vi_cv_path_python_plibs="-L${PYTHON_CONFDIR} -lpython${vi_cv_var_python_version}"
1218 fi
Bram Moolenaar6c927552015-03-24 12:21:33 +01001219 dnl -- Check if the path contained in python_LINKFORSHARED is
1220 dnl usable for vim build. If not, make and try other
1221 dnl candidates.
Bram Moolenaara161e262015-03-24 15:14:27 +01001222 if test -n "${python_LINKFORSHARED}" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
Bram Moolenaar6c927552015-03-24 12:21:33 +01001223 python_link_symbol=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]].*/\1/'`
1224 python_link_path=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]][[ \t]]*\(.*\)/\2/'`
1225 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1226 dnl -- The path looks relative. Guess the absolute one using
1227 dnl the prefix and try that.
1228 python_link_path="${python_PYTHONFRAMEWORKPREFIX}/${python_link_path}"
1229 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1230 dnl -- A last resort.
1231 python_link_path="${python_PYTHONFRAMEWORKINSTALLDIR}/Versions/${vi_cv_var_python_version}/${python_PYTHONFRAMEWORK}"
1232 dnl -- No check is done. The last word is left to the
1233 dnl "sanity" test on link flags that follows shortly.
1234 fi
1235 python_LINKFORSHARED="${python_link_symbol} ${python_link_path}"
1236 fi
1237 fi
Bram Moolenaar218116c2010-05-20 21:46:00 +02001238 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 +00001239 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1240 vi_cv_path_python_plibs=`echo $vi_cv_path_python_plibs | sed s/-ltermcap//`
1241 fi
1242 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001243 AC_CACHE_CHECK(Python's dll name,vi_cv_dll_name_python,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001244 [
1245 if test "X$python_DLLLIBRARY" != "X"; then
1246 vi_cv_dll_name_python="$python_DLLLIBRARY"
1247 else
1248 vi_cv_dll_name_python="$python_INSTSONAME"
1249 fi
1250 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00001251
1252 PYTHON_LIBS="${vi_cv_path_python_plibs}"
1253 if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001254 PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001255 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001256 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}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001257 fi
Bram Moolenaard0882402018-04-10 18:13:05 +02001258 if test "X$have_python_config_dir" = "X1"; then
1259 dnl Define PYTHON_HOME if --with-python-config-dir was used
1260 PYTHON_CFLAGS="${PYTHON_CFLAGS} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'"
1261
1262 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001263 PYTHON_SRC="if_python.c"
Bram Moolenaar9bdb9a02012-07-25 16:32:08 +02001264 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001265 if test "${vi_cv_var_python_version}" = "1.4"; then
1266 PYTHON_OBJ="$PYTHON_OBJ objects/py_getpath.o"
1267 fi
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001268 PYTHON_GETPATH_CFLAGS="-DPYTHONPATH='\"${vi_cv_path_pythonpath}\"' -DPREFIX='\"${vi_cv_path_python_pfx}\"' -DEXEC_PREFIX='\"${vi_cv_path_python_epfx}\"'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001269
1270 dnl On FreeBSD linking with "-pthread" is required to use threads.
1271 dnl _THREAD_SAFE must be used for compiling then.
1272 dnl The "-pthread" is added to $LIBS, so that the following check for
1273 dnl sigaltstack() will look in libc_r (it's there in libc!).
1274 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1275 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1276 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1277 AC_MSG_CHECKING([if -pthread should be used])
1278 threadsafe_flag=
1279 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001280 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00001281 if test "`(uname) 2>/dev/null`" != Darwin; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001282 test "$GCC" = yes && threadsafe_flag="-pthread"
1283 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1284 threadsafe_flag="-D_THREAD_SAFE"
1285 thread_lib="-pthread"
1286 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001287 if test "`(uname) 2>/dev/null`" = SunOS; then
1288 threadsafe_flag="-pthreads"
1289 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001290 fi
1291 libs_save_old=$LIBS
1292 if test -n "$threadsafe_flag"; then
1293 cflags_save=$CFLAGS
1294 CFLAGS="$CFLAGS $threadsafe_flag"
1295 LIBS="$LIBS $thread_lib"
1296 AC_TRY_LINK(,[ ],
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001297 AC_MSG_RESULT(yes); PYTHON_CFLAGS="$PYTHON_CFLAGS $threadsafe_flag",
Bram Moolenaar071d4272004-06-13 20:20:40 +00001298 AC_MSG_RESULT(no); LIBS=$libs_save_old
1299 )
1300 CFLAGS=$cflags_save
1301 else
1302 AC_MSG_RESULT(no)
1303 fi
1304
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001305 dnl Check that compiling a simple program still works with the flags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001306 dnl added for Python.
1307 AC_MSG_CHECKING([if compile and link flags for Python are sane])
1308 cflags_save=$CFLAGS
1309 libs_save=$LIBS
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001310 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001311 LIBS="$LIBS $PYTHON_LIBS"
1312 AC_TRY_LINK(,[ ],
1313 AC_MSG_RESULT(yes); python_ok=yes,
1314 AC_MSG_RESULT(no: PYTHON DISABLED); python_ok=no)
1315 CFLAGS=$cflags_save
1316 LIBS=$libs_save
1317 if test $python_ok = yes; then
1318 AC_DEFINE(FEAT_PYTHON)
1319 else
1320 LIBS=$libs_save_old
1321 PYTHON_SRC=
1322 PYTHON_OBJ=
1323 PYTHON_LIBS=
1324 PYTHON_CFLAGS=
1325 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001326 fi
1327 else
1328 AC_MSG_RESULT(too old)
1329 fi
1330 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001331
1332 if test "$fail_if_missing" = "yes" -a "$python_ok" != "yes"; then
1333 AC_MSG_ERROR([could not configure python])
1334 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001335fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001336
Bram Moolenaar071d4272004-06-13 20:20:40 +00001337AC_SUBST(PYTHON_CONFDIR)
1338AC_SUBST(PYTHON_LIBS)
1339AC_SUBST(PYTHON_GETPATH_CFLAGS)
1340AC_SUBST(PYTHON_CFLAGS)
1341AC_SUBST(PYTHON_SRC)
1342AC_SUBST(PYTHON_OBJ)
1343
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001344
1345AC_MSG_CHECKING(--enable-python3interp argument)
1346AC_ARG_ENABLE(python3interp,
Bram Moolenaar8008b632017-07-18 21:33:20 +02001347 [ --enable-python3interp[=OPTS] Include Python3 interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001348 [enable_python3interp="no"])
1349AC_MSG_RESULT($enable_python3interp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001350if test "$enable_python3interp" = "yes" -o "$enable_python3interp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001351 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1352 AC_MSG_ERROR([cannot use Python with tiny or small features])
1353 fi
1354
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001355 dnl -- find the python3 executable
Bram Moolenaar09ba6d72012-12-12 14:25:05 +01001356 AC_PATH_PROGS(vi_cv_path_python3, python3 python)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001357 if test "X$vi_cv_path_python3" != "X"; then
1358
1359 dnl -- get its version number
1360 AC_CACHE_CHECK(Python version,vi_cv_var_python3_version,
1361 [[vi_cv_var_python3_version=`
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001362 ${vi_cv_path_python3} -c 'import sys; print(sys.version[:3])'`
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001363 ]])
1364
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001365 dnl -- it must be at least version 3
1366 AC_MSG_CHECKING(Python is 3.0 or better)
1367 if ${vi_cv_path_python3} -c \
1368 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.0)"
1369 then
1370 AC_MSG_RESULT(yep)
Bram Moolenaar456f2bb2011-06-12 21:37:13 +02001371
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001372 dnl -- get abiflags for python 3.2 or higher (PEP 3149)
1373 AC_CACHE_CHECK(Python's abiflags,vi_cv_var_python3_abiflags,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001374 [
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001375 vi_cv_var_python3_abiflags=
1376 if ${vi_cv_path_python3} -c \
1377 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)"
1378 then
1379 vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \
1380 "import sys; print(sys.abiflags)"`
1381 fi ])
1382
1383 dnl -- find where python3 thinks it was installed
1384 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx,
1385 [ vi_cv_path_python3_pfx=`
1386 ${vi_cv_path_python3} -c \
1387 "import sys; print(sys.prefix)"` ])
1388
1389 dnl -- and where it thinks it runs
1390 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx,
1391 [ vi_cv_path_python3_epfx=`
1392 ${vi_cv_path_python3} -c \
1393 "import sys; print(sys.exec_prefix)"` ])
1394
1395 dnl -- python3's internal library path
1396
1397 AC_CACHE_VAL(vi_cv_path_python3path,
1398 [ vi_cv_path_python3path=`
1399 unset PYTHONPATH;
1400 ${vi_cv_path_python3} -c \
1401 "import sys, string; print(':'.join(sys.path))"` ])
1402
1403 dnl -- where the Python implementation library archives are
1404
1405 AC_ARG_WITH(python3-config-dir,
1406 [ --with-python3-config-dir=PATH Python's config directory],
Bram Moolenaard0882402018-04-10 18:13:05 +02001407 [ vi_cv_path_python3_conf="${withval}"; have_python3_config_dir=1 ] )
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001408
1409 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf,
1410 [
1411 vi_cv_path_python3_conf=
Bram Moolenaarfee496d2013-07-12 20:07:24 +02001412 config_dir="config-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001413 d=`${vi_cv_path_python3} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBPL'))"`
1414 if test -d "$d" && test -f "$d/config.c"; then
1415 vi_cv_path_python3_conf="$d"
1416 else
1417 for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do
1418 for subdir in lib64 lib share; do
1419 d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}"
1420 if test -d "$d" && test -f "$d/config.c"; then
1421 vi_cv_path_python3_conf="$d"
1422 fi
1423 done
1424 done
1425 fi
1426 ])
1427
1428 PYTHON3_CONFDIR="${vi_cv_path_python3_conf}"
1429
1430 if test "X$PYTHON3_CONFDIR" = "X"; then
1431 AC_MSG_RESULT([can't find it!])
1432 else
1433
1434 dnl -- we need to examine Python's config/Makefile too
1435 dnl see what the interpreter is built from
1436 AC_CACHE_VAL(vi_cv_path_python3_plibs,
1437 [
1438 pwd=`pwd`
1439 tmp_mkf="$pwd/config-PyMake$$"
1440 cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001441__:
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001442 @echo "python3_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001443 @echo "python3_LIBS='$(LIBS)'"
1444 @echo "python3_SYSLIBS='$(SYSLIBS)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001445 @echo "python3_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001446 @echo "python3_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001447eof
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001448 dnl -- delete the lines from make about Entering/Leaving directory
1449 eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1450 rm -f -- "${tmp_mkf}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001451 vi_cv_path_python3_plibs="-L${PYTHON3_CONFDIR} -lpython${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001452 vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}"
1453 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1454 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//`
1455 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//`
1456 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001457 AC_CACHE_CHECK(Python3's dll name,vi_cv_dll_name_python3,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001458 [
1459 if test "X$python3_DLLLIBRARY" != "X"; then
1460 vi_cv_dll_name_python3="$python3_DLLLIBRARY"
1461 else
1462 vi_cv_dll_name_python3="$python3_INSTSONAME"
1463 fi
1464 ])
1465
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001466 PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
1467 if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001468 PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001469 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001470 PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -I${vi_cv_path_python3_epfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001471 fi
Bram Moolenaard0882402018-04-10 18:13:05 +02001472 if test "X$have_python3_config_dir" = "X1"; then
1473 dnl Define PYTHON3_HOME if --with-python-config-dir was used
1474 PYTHON3_CFLAGS="${PYTHON3_CFLAGS} -DPYTHON3_HOME='L\"${vi_cv_path_python3_pfx}\"'"
1475 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001476 PYTHON3_SRC="if_python3.c"
1477 PYTHON3_OBJ="objects/if_python3.o"
1478
1479 dnl On FreeBSD linking with "-pthread" is required to use threads.
1480 dnl _THREAD_SAFE must be used for compiling then.
1481 dnl The "-pthread" is added to $LIBS, so that the following check for
1482 dnl sigaltstack() will look in libc_r (it's there in libc!).
1483 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1484 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1485 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1486 AC_MSG_CHECKING([if -pthread should be used])
1487 threadsafe_flag=
1488 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001489 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001490 if test "`(uname) 2>/dev/null`" != Darwin; then
1491 test "$GCC" = yes && threadsafe_flag="-pthread"
1492 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1493 threadsafe_flag="-D_THREAD_SAFE"
1494 thread_lib="-pthread"
1495 fi
1496 if test "`(uname) 2>/dev/null`" = SunOS; then
1497 threadsafe_flag="-pthreads"
1498 fi
1499 fi
1500 libs_save_old=$LIBS
1501 if test -n "$threadsafe_flag"; then
1502 cflags_save=$CFLAGS
1503 CFLAGS="$CFLAGS $threadsafe_flag"
1504 LIBS="$LIBS $thread_lib"
1505 AC_TRY_LINK(,[ ],
1506 AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag",
1507 AC_MSG_RESULT(no); LIBS=$libs_save_old
1508 )
1509 CFLAGS=$cflags_save
1510 else
1511 AC_MSG_RESULT(no)
1512 fi
1513
1514 dnl check that compiling a simple program still works with the flags
1515 dnl added for Python.
1516 AC_MSG_CHECKING([if compile and link flags for Python 3 are sane])
1517 cflags_save=$CFLAGS
1518 libs_save=$LIBS
1519 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1520 LIBS="$LIBS $PYTHON3_LIBS"
1521 AC_TRY_LINK(,[ ],
1522 AC_MSG_RESULT(yes); python3_ok=yes,
1523 AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no)
1524 CFLAGS=$cflags_save
1525 LIBS=$libs_save
1526 if test "$python3_ok" = yes; then
1527 AC_DEFINE(FEAT_PYTHON3)
1528 else
1529 LIBS=$libs_save_old
1530 PYTHON3_SRC=
1531 PYTHON3_OBJ=
1532 PYTHON3_LIBS=
1533 PYTHON3_CFLAGS=
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001534 fi
1535 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001536 else
1537 AC_MSG_RESULT(too old)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001538 fi
1539 fi
Bram Moolenaar1612b1a2013-06-14 21:22:39 +02001540 if test "$fail_if_missing" = "yes" -a "$python3_ok" != "yes"; then
1541 AC_MSG_ERROR([could not configure python3])
1542 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001543fi
1544
1545AC_SUBST(PYTHON3_CONFDIR)
1546AC_SUBST(PYTHON3_LIBS)
1547AC_SUBST(PYTHON3_CFLAGS)
1548AC_SUBST(PYTHON3_SRC)
1549AC_SUBST(PYTHON3_OBJ)
1550
1551dnl if python2.x and python3.x are enabled one can only link in code
1552dnl with dlopen(), dlsym(), dlclose()
1553if test "$python_ok" = yes && test "$python3_ok" = yes; then
1554 AC_DEFINE(DYNAMIC_PYTHON)
1555 AC_DEFINE(DYNAMIC_PYTHON3)
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001556 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001557 cflags_save=$CFLAGS
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001558 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001559 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001560 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001561 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001562 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001563 #include <dlfcn.h>
1564 /* If this program fails, then RTLD_GLOBAL is needed.
1565 * RTLD_GLOBAL will be used and then it is not possible to
1566 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001567 * Only the first python version used will be switched on.
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001568 */
1569
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001570 int no_rtl_global_needed_for(char *python_instsoname, char *prefix)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001571 {
1572 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001573 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001574 if (pylib != 0)
1575 {
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001576 void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome");
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001577 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1578 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1579 void (*final)(void) = dlsym(pylib, "Py_Finalize");
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001580 (*pfx)(prefix);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001581 (*init)();
1582 needed = (*simple)("import termios") == -1;
1583 (*final)();
1584 dlclose(pylib);
1585 }
1586 return !needed;
1587 }
1588
1589 int main(int argc, char** argv)
1590 {
1591 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001592 if (no_rtl_global_needed_for("${vi_cv_dll_name_python}", "${vi_cv_path_python_pfx}"))
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001593 not_needed = 1;
1594 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001595 }])],
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001596 [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001597
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001598 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001599 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001600
1601 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python3)
1602 cflags_save=$CFLAGS
1603 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001604 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001605 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001606 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001607 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001608 #include <dlfcn.h>
1609 #include <wchar.h>
1610 /* If this program fails, then RTLD_GLOBAL is needed.
1611 * RTLD_GLOBAL will be used and then it is not possible to
1612 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001613 * Only the first python version used will be switched on.
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001614 */
1615
1616 int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix)
1617 {
1618 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001619 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001620 if (pylib != 0)
1621 {
1622 void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome");
1623 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1624 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1625 void (*final)(void) = dlsym(pylib, "Py_Finalize");
1626 (*pfx)(prefix);
1627 (*init)();
1628 needed = (*simple)("import termios") == -1;
1629 (*final)();
1630 dlclose(pylib);
1631 }
1632 return !needed;
1633 }
1634
1635 int main(int argc, char** argv)
1636 {
1637 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001638 if (no_rtl_global_needed_for("${vi_cv_dll_name_python3}", L"${vi_cv_path_python3_pfx}"))
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001639 not_needed = 1;
1640 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001641 }])],
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001642 [AC_MSG_RESULT(yes);AC_DEFINE(PY3_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
1643
1644 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001645 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001646
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001647 PYTHON_SRC="if_python.c"
1648 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001649 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001650 PYTHON_LIBS=
1651 PYTHON3_SRC="if_python3.c"
1652 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001653 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001654 PYTHON3_LIBS=
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001655elif test "$python_ok" = yes && test "$enable_pythoninterp" = "dynamic"; then
1656 AC_DEFINE(DYNAMIC_PYTHON)
1657 PYTHON_SRC="if_python.c"
1658 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001659 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001660 PYTHON_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001661elif test "$python_ok" = yes; then
1662 dnl Check that adding -fPIE works. It may be needed when using a static
1663 dnl Python library.
1664 AC_MSG_CHECKING([if -fPIE can be added for Python])
1665 cflags_save=$CFLAGS
1666 libs_save=$LIBS
1667 CFLAGS="$CFLAGS $PYTHON_CFLAGS -fPIE"
1668 LIBS="$LIBS $PYTHON_LIBS"
1669 AC_TRY_LINK(,[ ],
1670 AC_MSG_RESULT(yes); fpie_ok=yes,
1671 AC_MSG_RESULT(no); fpie_ok=no)
1672 CFLAGS=$cflags_save
1673 LIBS=$libs_save
1674 if test $fpie_ok = yes; then
1675 PYTHON_CFLAGS="$PYTHON_CFLAGS -fPIE"
1676 fi
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001677elif test "$python3_ok" = yes && test "$enable_python3interp" = "dynamic"; then
1678 AC_DEFINE(DYNAMIC_PYTHON3)
1679 PYTHON3_SRC="if_python3.c"
1680 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001681 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001682 PYTHON3_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001683elif test "$python3_ok" = yes; then
1684 dnl Check that adding -fPIE works. It may be needed when using a static
1685 dnl Python library.
1686 AC_MSG_CHECKING([if -fPIE can be added for Python3])
1687 cflags_save=$CFLAGS
1688 libs_save=$LIBS
1689 CFLAGS="$CFLAGS $PYTHON3_CFLAGS -fPIE"
1690 LIBS="$LIBS $PYTHON3_LIBS"
1691 AC_TRY_LINK(,[ ],
1692 AC_MSG_RESULT(yes); fpie_ok=yes,
1693 AC_MSG_RESULT(no); fpie_ok=no)
1694 CFLAGS=$cflags_save
1695 LIBS=$libs_save
1696 if test $fpie_ok = yes; then
1697 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -fPIE"
1698 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001699fi
1700
Bram Moolenaar071d4272004-06-13 20:20:40 +00001701AC_MSG_CHECKING(--enable-tclinterp argument)
1702AC_ARG_ENABLE(tclinterp,
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001703 [ --enable-tclinterp[=OPTS] Include Tcl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001704 [enable_tclinterp="no"])
1705AC_MSG_RESULT($enable_tclinterp)
1706
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001707if test "$enable_tclinterp" = "yes" -o "$enable_tclinterp" = "dynamic"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001708
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001709 dnl on FreeBSD tclsh is a silly script, look for tclsh8.[5420]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001710 AC_MSG_CHECKING(--with-tclsh argument)
1711 AC_ARG_WITH(tclsh, [ --with-tclsh=PATH which tclsh to use (default: tclsh8.0)],
1712 tclsh_name="$withval"; AC_MSG_RESULT($tclsh_name),
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001713 tclsh_name="tclsh8.5"; AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00001714 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1715 AC_SUBST(vi_cv_path_tcl)
1716
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001717 dnl when no specific version specified, also try 8.4, 8.2 and 8.0
1718 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.5"; then
1719 tclsh_name="tclsh8.4"
1720 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1721 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001722 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.4"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001723 tclsh_name="tclsh8.2"
1724 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1725 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001726 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.2"; then
1727 tclsh_name="tclsh8.0"
1728 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1729 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001730 dnl still didn't find it, try without version number
1731 if test "X$vi_cv_path_tcl" = "X"; then
1732 tclsh_name="tclsh"
1733 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1734 fi
1735 if test "X$vi_cv_path_tcl" != "X"; then
1736 AC_MSG_CHECKING(Tcl version)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001737 if echo 'exit [[expr [info tclversion] < 8.0]]' | "$vi_cv_path_tcl" - ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001738 tclver=`echo 'puts [[info tclversion]]' | $vi_cv_path_tcl -`
1739 AC_MSG_RESULT($tclver - OK);
1740 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 -`
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001741 tcldll=`echo 'puts libtcl[[info tclversion]][[info sharedlibextension]]' | $vi_cv_path_tcl -`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001742
1743 AC_MSG_CHECKING(for location of Tcl include)
Bram Moolenaard0573012017-10-28 21:11:06 +02001744 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001745 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 +00001746 else
1747 dnl For Mac OS X 10.3, use the OS-provided framework location
1748 tclinc="/System/Library/Frameworks/Tcl.framework/Headers"
1749 fi
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001750 TCL_INC=
Bram Moolenaar071d4272004-06-13 20:20:40 +00001751 for try in $tclinc; do
1752 if test -f "$try/tcl.h"; then
1753 AC_MSG_RESULT($try/tcl.h)
1754 TCL_INC=$try
1755 break
1756 fi
1757 done
1758 if test -z "$TCL_INC"; then
1759 AC_MSG_RESULT(<not found>)
1760 SKIP_TCL=YES
1761 fi
1762 if test -z "$SKIP_TCL"; then
1763 AC_MSG_CHECKING(for location of tclConfig.sh script)
Bram Moolenaard0573012017-10-28 21:11:06 +02001764 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001765 tclcnf=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001766 tclcnf="$tclcnf `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001767 else
1768 dnl For Mac OS X 10.3, use the OS-provided framework location
1769 tclcnf="/System/Library/Frameworks/Tcl.framework"
1770 fi
1771 for try in $tclcnf; do
Bram Moolenaar49222be2015-12-11 18:11:30 +01001772 if test -f "$try/tclConfig.sh"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001773 AC_MSG_RESULT($try/tclConfig.sh)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001774 . "$try/tclConfig.sh"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001775 dnl use eval, because tcl 8.2 includes ${TCL_DBGX}
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001776 if test "$enable_tclinterp" = "dynamic"; then
1777 TCL_LIBS=`eval echo "$TCL_STUB_LIB_SPEC $TCL_LIBS"`
1778 else
1779 TCL_LIBS=`eval echo "$TCL_LIB_SPEC $TCL_LIBS"`
1780 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001781 dnl Use $TCL_DEFS for -D_THREAD_SAFE et al. But only use the
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001782 dnl "-D_ABC" items. Watch out for -DFOO=long\ long.
Bram Moolenaar4394bff2008-07-24 11:21:31 +00001783 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 +00001784 break
1785 fi
1786 done
1787 if test -z "$TCL_LIBS"; then
1788 AC_MSG_RESULT(<not found>)
1789 AC_MSG_CHECKING(for Tcl library by myself)
1790 tcllib=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001791 tcllib="$tcllib `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001792 for ext in .so .a ; do
1793 for ver in "" $tclver ; do
1794 for try in $tcllib ; do
1795 trylib=tcl$ver$ext
Bram Moolenaar49222be2015-12-11 18:11:30 +01001796 if test -f "$try/lib$trylib" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001797 AC_MSG_RESULT($try/lib$trylib)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001798 TCL_LIBS="-L\"$try\" -ltcl$ver -ldl -lm"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001799 if test "`(uname) 2>/dev/null`" = SunOS &&
1800 uname -r | grep '^5' >/dev/null; then
1801 TCL_LIBS="$TCL_LIBS -R $try"
1802 fi
1803 break 3
1804 fi
1805 done
1806 done
1807 done
1808 if test -z "$TCL_LIBS"; then
1809 AC_MSG_RESULT(<not found>)
1810 SKIP_TCL=YES
1811 fi
1812 fi
1813 if test -z "$SKIP_TCL"; then
1814 AC_DEFINE(FEAT_TCL)
1815 TCL_SRC=if_tcl.c
1816 TCL_OBJ=objects/if_tcl.o
1817 TCL_PRO=if_tcl.pro
1818 TCL_CFLAGS="-I$TCL_INC $TCL_DEFS"
1819 fi
1820 fi
1821 else
1822 AC_MSG_RESULT(too old; need Tcl version 8.0 or later)
1823 fi
1824 fi
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001825 if test "$enable_tclinterp" = "dynamic"; then
1826 if test "X$TCL_SRC" != "X" -a "X$tcldll" != "X"; then
1827 AC_DEFINE(DYNAMIC_TCL)
1828 TCL_CFLAGS="-DDYNAMIC_TCL_DLL=\\\"$tcldll\\\" -DDYNAMIC_TCL_VER=\\\"$tclver\\\" $TCL_CFLAGS"
1829 fi
1830 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001831 if test "$fail_if_missing" = "yes" -a -z "$TCL_SRC"; then
1832 AC_MSG_ERROR([could not configure Tcl])
1833 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001834fi
1835AC_SUBST(TCL_SRC)
1836AC_SUBST(TCL_OBJ)
1837AC_SUBST(TCL_PRO)
1838AC_SUBST(TCL_CFLAGS)
1839AC_SUBST(TCL_LIBS)
1840
1841AC_MSG_CHECKING(--enable-rubyinterp argument)
1842AC_ARG_ENABLE(rubyinterp,
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001843 [ --enable-rubyinterp[=OPTS] Include Ruby interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001844 [enable_rubyinterp="no"])
1845AC_MSG_RESULT($enable_rubyinterp)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001846if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001847 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1848 AC_MSG_ERROR([cannot use Ruby with tiny or small features])
1849 fi
1850
Bram Moolenaar165641d2010-02-17 16:23:09 +01001851 AC_MSG_CHECKING(--with-ruby-command argument)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001852 AC_SUBST(vi_cv_path_ruby)
Bram Moolenaar948733a2011-05-05 18:10:16 +02001853 AC_ARG_WITH(ruby-command, [ --with-ruby-command=RUBY name of the Ruby command (default: ruby)],
1854 RUBY_CMD="$withval"; vi_cv_path_ruby="$withval"; AC_MSG_RESULT($RUBY_CMD),
1855 RUBY_CMD="ruby"; AC_MSG_RESULT(defaulting to $RUBY_CMD))
Bram Moolenaar165641d2010-02-17 16:23:09 +01001856 AC_PATH_PROG(vi_cv_path_ruby, $RUBY_CMD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001857 if test "X$vi_cv_path_ruby" != "X"; then
1858 AC_MSG_CHECKING(Ruby version)
Bram Moolenaare4efc3b2005-03-07 23:16:51 +00001859 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 +00001860 AC_MSG_RESULT(OK)
Bram Moolenaar81398892012-10-03 21:09:35 +02001861 AC_MSG_CHECKING(Ruby rbconfig)
1862 ruby_rbconfig="RbConfig"
1863 if ! $vi_cv_path_ruby -r rbconfig -e 'RbConfig' >/dev/null 2>/dev/null; then
1864 ruby_rbconfig="Config"
1865 fi
1866 AC_MSG_RESULT($ruby_rbconfig)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001867 AC_MSG_CHECKING(Ruby header files)
Bram Moolenaar81398892012-10-03 21:09:35 +02001868 rubyhdrdir=`$vi_cv_path_ruby -r mkmf -e "print $ruby_rbconfig::CONFIG[['rubyhdrdir']] || $ruby_rbconfig::CONFIG[['archdir']] || \\$hdrdir" 2>/dev/null`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001869 if test "X$rubyhdrdir" != "X"; then
1870 AC_MSG_RESULT($rubyhdrdir)
1871 RUBY_CFLAGS="-I$rubyhdrdir"
Bram Moolenaara6fd37b2014-03-27 17:19:09 +01001872 rubyarchdir=`$vi_cv_path_ruby -r rbconfig -e "print ($ruby_rbconfig::CONFIG.has_key? 'rubyarchhdrdir') ? $ruby_rbconfig::CONFIG[['rubyarchhdrdir']] : '$rubyhdrdir/'+$ruby_rbconfig::CONFIG[['arch']]"`
1873 if test -d "$rubyarchdir"; then
1874 RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyarchdir"
Bram Moolenaar165641d2010-02-17 16:23:09 +01001875 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001876 rubyversion=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['ruby_version']].gsub(/\./, '')[[0,2]]"`
Bram Moolenaar026a4452013-08-07 15:22:23 +02001877 if test "X$rubyversion" = "X"; then
1878 rubyversion=`$vi_cv_path_ruby -e "print ((VERSION rescue RUBY_VERSION)).gsub(/\./, '')[[0,2]]"`
1879 fi
Bram Moolenaar165641d2010-02-17 16:23:09 +01001880 RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
Bram Moolenaar81398892012-10-03 21:09:35 +02001881 rubylibs=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LIBS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001882 if test "X$rubylibs" != "X"; then
1883 RUBY_LIBS="$rubylibs"
1884 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001885 librubyarg=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBYARG']])"`
1886 librubya=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBY_A']])"`
Bram Moolenaarac499e32013-06-02 19:14:17 +02001887 rubylibdir=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['libdir']])"`
Bram Moolenaar948733a2011-05-05 18:10:16 +02001888 if test -f "$rubylibdir/$librubya"; then
1889 librubyarg="$librubyarg"
Bram Moolenaarac499e32013-06-02 19:14:17 +02001890 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
1891 elif test "$librubyarg" = "libruby.a"; then
1892 dnl required on Mac OS 10.3 where libruby.a doesn't exist
1893 librubyarg="-lruby"
1894 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001895 fi
1896
1897 if test "X$librubyarg" != "X"; then
1898 RUBY_LIBS="$librubyarg $RUBY_LIBS"
1899 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001900 rubyldflags=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LDFLAGS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001901 if test "X$rubyldflags" != "X"; then
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001902 dnl Ruby on Mac OS X 10.5 adds "-arch" flags but these should only
1903 dnl be included if requested by passing --with-mac-arch to
1904 dnl configure, so strip these flags first (if present)
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001905 rubyldflags=`echo "$rubyldflags" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001906 if test "X$rubyldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001907 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$rubyldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001908 LDFLAGS="$rubyldflags $LDFLAGS"
1909 fi
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001910 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001911 fi
1912 RUBY_SRC="if_ruby.c"
1913 RUBY_OBJ="objects/if_ruby.o"
1914 RUBY_PRO="if_ruby.pro"
1915 AC_DEFINE(FEAT_RUBY)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001916 if test "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar92021622017-10-12 12:33:43 +02001917 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_ALIASES']].split[[0]]"`
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001918 AC_DEFINE(DYNAMIC_RUBY)
Bram Moolenaar92021622017-10-12 12:33:43 +02001919 RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby_soname\\\" -DDYNAMIC_RUBY_VER=$rubyversion $RUBY_CFLAGS"
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001920 RUBY_LIBS=
1921 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001922 else
Bram Moolenaar165641d2010-02-17 16:23:09 +01001923 AC_MSG_RESULT(not found; disabling Ruby)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001924 fi
1925 else
1926 AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
1927 fi
1928 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001929
1930 if test "$fail_if_missing" = "yes" -a -z "$RUBY_OBJ"; then
1931 AC_MSG_ERROR([could not configure Ruby])
1932 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001933fi
1934AC_SUBST(RUBY_SRC)
1935AC_SUBST(RUBY_OBJ)
1936AC_SUBST(RUBY_PRO)
1937AC_SUBST(RUBY_CFLAGS)
1938AC_SUBST(RUBY_LIBS)
1939
1940AC_MSG_CHECKING(--enable-cscope argument)
1941AC_ARG_ENABLE(cscope,
1942 [ --enable-cscope Include cscope interface.], ,
1943 [enable_cscope="no"])
1944AC_MSG_RESULT($enable_cscope)
1945if test "$enable_cscope" = "yes"; then
1946 AC_DEFINE(FEAT_CSCOPE)
1947fi
1948
1949AC_MSG_CHECKING(--enable-workshop argument)
1950AC_ARG_ENABLE(workshop,
1951 [ --enable-workshop Include Sun Visual Workshop support.], ,
1952 [enable_workshop="no"])
1953AC_MSG_RESULT($enable_workshop)
1954if test "$enable_workshop" = "yes"; then
1955 AC_DEFINE(FEAT_SUN_WORKSHOP)
1956 WORKSHOP_SRC="workshop.c integration.c"
1957 AC_SUBST(WORKSHOP_SRC)
1958 WORKSHOP_OBJ="objects/workshop.o objects/integration.o"
1959 AC_SUBST(WORKSHOP_OBJ)
1960 if test "${enable_gui-xxx}" = xxx; then
1961 enable_gui=motif
1962 fi
1963fi
1964
1965AC_MSG_CHECKING(--disable-netbeans argument)
1966AC_ARG_ENABLE(netbeans,
1967 [ --disable-netbeans Disable NetBeans integration support.],
1968 , [enable_netbeans="yes"])
1969if test "$enable_netbeans" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01001970 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1971 AC_MSG_RESULT([cannot use NetBeans with tiny or small features])
1972 enable_netbeans="no"
1973 else
1974 AC_MSG_RESULT(no)
1975 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01001976else
1977 AC_MSG_RESULT(yes)
1978fi
1979
1980AC_MSG_CHECKING(--disable-channel argument)
1981AC_ARG_ENABLE(channel,
Bram Moolenaar8008b632017-07-18 21:33:20 +02001982 [ --disable-channel Disable process communication support.],
Bram Moolenaare0874f82016-01-24 20:36:41 +01001983 , [enable_channel="yes"])
1984if test "$enable_channel" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01001985 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1986 AC_MSG_RESULT([cannot use channels with tiny or small features])
1987 enable_channel="no"
1988 else
1989 AC_MSG_RESULT(no)
1990 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01001991else
1992 if test "$enable_netbeans" = "yes"; then
Bram Moolenaar16435482016-01-24 21:31:54 +01001993 AC_MSG_RESULT([yes, netbeans also disabled])
Bram Moolenaare0874f82016-01-24 20:36:41 +01001994 enable_netbeans="no"
1995 else
1996 AC_MSG_RESULT(yes)
1997 fi
1998fi
1999
Bram Moolenaar16435482016-01-24 21:31:54 +01002000if test "$enable_channel" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002001 dnl On Solaris we need the socket and nsl library.
2002 AC_CHECK_LIB(socket, socket)
2003 AC_CHECK_LIB(nsl, gethostbyname)
Bram Moolenaare0874f82016-01-24 20:36:41 +01002004 AC_MSG_CHECKING(whether compiling with process communication is possible)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002005 AC_TRY_LINK([
2006#include <stdio.h>
2007#include <stdlib.h>
2008#include <stdarg.h>
2009#include <fcntl.h>
2010#include <netdb.h>
2011#include <netinet/in.h>
2012#include <errno.h>
2013#include <sys/types.h>
2014#include <sys/socket.h>
2015 /* Check bitfields */
2016 struct nbbuf {
2017 unsigned int initDone:1;
Bram Moolenaar63de19e2016-12-09 20:11:26 +01002018 unsigned short signmaplen;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002019 };
2020 ], [
2021 /* Check creating a socket. */
2022 struct sockaddr_in server;
2023 (void)socket(AF_INET, SOCK_STREAM, 0);
2024 (void)htons(100);
2025 (void)gethostbyname("microsoft.com");
2026 if (errno == ECONNREFUSED)
2027 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
2028 ],
2029 AC_MSG_RESULT(yes),
Bram Moolenaare0874f82016-01-24 20:36:41 +01002030 AC_MSG_RESULT(no); enable_netbeans="no"; enable_channel="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00002031fi
2032if test "$enable_netbeans" = "yes"; then
2033 AC_DEFINE(FEAT_NETBEANS_INTG)
2034 NETBEANS_SRC="netbeans.c"
2035 AC_SUBST(NETBEANS_SRC)
2036 NETBEANS_OBJ="objects/netbeans.o"
2037 AC_SUBST(NETBEANS_OBJ)
2038fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002039if test "$enable_channel" = "yes"; then
Bram Moolenaar509ce2a2016-03-11 22:52:15 +01002040 AC_DEFINE(FEAT_JOB_CHANNEL)
Bram Moolenaare0874f82016-01-24 20:36:41 +01002041 CHANNEL_SRC="channel.c"
2042 AC_SUBST(CHANNEL_SRC)
2043 CHANNEL_OBJ="objects/channel.o"
2044 AC_SUBST(CHANNEL_OBJ)
2045fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002046
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002047AC_MSG_CHECKING(--enable-terminal argument)
2048AC_ARG_ENABLE(terminal,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002049 [ --enable-terminal Enable terminal emulation support.],
Bram Moolenaaref839562017-10-28 20:28:23 +02002050 , [enable_terminal="auto"])
Bram Moolenaar595a4022017-09-03 19:15:57 +02002051if test "$enable_terminal" = "yes" || test "$enable_terminal" = "auto" -a "x$features" = "xhuge" ; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002052 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2053 AC_MSG_RESULT([cannot use terminal emulator with tiny or small features])
2054 enable_terminal="no"
2055 else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002056 if test "$enable_terminal" = "auto"; then
2057 enable_terminal="yes"
2058 AC_MSG_RESULT(defaulting to yes)
2059 else
2060 AC_MSG_RESULT(yes)
2061 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002062 fi
2063else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002064 if test "$enable_terminal" = "auto"; then
2065 enable_terminal="no"
2066 AC_MSG_RESULT(defaulting to no)
2067 else
2068 AC_MSG_RESULT(no)
2069 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002070fi
Bram Moolenaar8b423282017-12-16 14:37:06 +01002071if test "$enable_terminal" = "yes" -a "$enable_channel" = "yes"; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002072 AC_DEFINE(FEAT_TERMINAL)
2073 TERM_SRC="libvterm/src/encoding.c libvterm/src/keyboard.c libvterm/src/mouse.c libvterm/src/parser.c libvterm/src/pen.c libvterm/src/screen.c libvterm/src/state.c libvterm/src/unicode.c libvterm/src/vterm.c"
2074 AC_SUBST(TERM_SRC)
2075 TERM_OBJ="objects/term_encoding.o objects/term_keyboard.o objects/term_mouse.o objects/term_parser.o objects/term_pen.o objects/term_screen.o objects/term_state.o objects/term_unicode.o objects/term_vterm.o"
2076 AC_SUBST(TERM_OBJ)
2077fi
2078
Bram Moolenaare42a6d22017-11-12 19:21:51 +01002079AC_MSG_CHECKING(--enable-autoservername argument)
2080AC_ARG_ENABLE(autoservername,
2081 [ --enable-autoservername Automatically define servername at vim startup.], ,
2082 [enable_autoservername="no"])
2083AC_MSG_RESULT($enable_autoservername)
2084if test "$enable_autoservername" = "yes"; then
2085 AC_DEFINE(FEAT_AUTOSERVERNAME)
2086fi
2087
Bram Moolenaar071d4272004-06-13 20:20:40 +00002088AC_MSG_CHECKING(--enable-multibyte argument)
2089AC_ARG_ENABLE(multibyte,
2090 [ --enable-multibyte Include multibyte editing support.], ,
2091 [enable_multibyte="no"])
2092AC_MSG_RESULT($enable_multibyte)
2093if test "$enable_multibyte" = "yes"; then
2094 AC_DEFINE(FEAT_MBYTE)
2095fi
2096
2097AC_MSG_CHECKING(--enable-hangulinput argument)
2098AC_ARG_ENABLE(hangulinput,
2099 [ --enable-hangulinput Include Hangul input support.], ,
2100 [enable_hangulinput="no"])
2101AC_MSG_RESULT($enable_hangulinput)
2102
2103AC_MSG_CHECKING(--enable-xim argument)
2104AC_ARG_ENABLE(xim,
2105 [ --enable-xim Include XIM input support.],
2106 AC_MSG_RESULT($enable_xim),
2107 [enable_xim="auto"; AC_MSG_RESULT(defaulting to auto)])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002108
2109AC_MSG_CHECKING(--enable-fontset argument)
2110AC_ARG_ENABLE(fontset,
2111 [ --enable-fontset Include X fontset output support.], ,
2112 [enable_fontset="no"])
2113AC_MSG_RESULT($enable_fontset)
2114dnl defining FEAT_XFONTSET is delayed, so that it can be disabled for no GUI
2115
2116test -z "$with_x" && with_x=yes
Bram Moolenaard0573012017-10-28 21:11:06 +02002117test "${enable_gui-yes}" != no -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && with_x=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002118if test "$with_x" = no; then
2119 AC_MSG_RESULT(defaulting to: don't HAVE_X11)
2120else
2121 dnl Do this check early, so that its failure can override user requests.
2122
2123 AC_PATH_PROG(xmkmfpath, xmkmf)
2124
2125 AC_PATH_XTRA
2126
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002127 dnl On z/OS Unix the X libraries are DLLs. To use them the code must
Bram Moolenaar071d4272004-06-13 20:20:40 +00002128 dnl be compiled with a special option.
2129 dnl Also add SM, ICE and Xmu to X_EXTRA_LIBS.
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002130 if test "$zOSUnix" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002131 CFLAGS="$CFLAGS -W c,dll"
2132 LDFLAGS="$LDFLAGS -W l,dll"
2133 X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE -lXmu"
2134 fi
2135
2136 dnl On my HPUX system the X include dir is found, but the lib dir not.
2137 dnl This is a desparate try to fix this.
2138
2139 if test -d "$x_includes" && test ! -d "$x_libraries"; then
2140 x_libraries=`echo "$x_includes" | sed s/include/lib/`
2141 AC_MSG_RESULT(Corrected X libraries to $x_libraries)
2142 X_LIBS="$X_LIBS -L$x_libraries"
2143 if test "`(uname) 2>/dev/null`" = SunOS &&
2144 uname -r | grep '^5' >/dev/null; then
2145 X_LIBS="$X_LIBS -R $x_libraries"
2146 fi
2147 fi
2148
2149 if test -d "$x_libraries" && test ! -d "$x_includes"; then
2150 x_includes=`echo "$x_libraries" | sed s/lib/include/`
2151 AC_MSG_RESULT(Corrected X includes to $x_includes)
2152 X_CFLAGS="$X_CFLAGS -I$x_includes"
2153 fi
2154
2155 dnl Remove "-I/usr/include " from X_CFLAGS, should not be needed.
2156 X_CFLAGS="`echo $X_CFLAGS\ | sed 's%-I/usr/include %%'`"
2157 dnl Remove "-L/usr/lib " from X_LIBS, should not be needed.
2158 X_LIBS="`echo $X_LIBS\ | sed 's%-L/usr/lib %%'`"
2159 dnl Same for "-R/usr/lib ".
2160 X_LIBS="`echo $X_LIBS\ | sed -e 's%-R/usr/lib %%' -e 's%-R /usr/lib %%'`"
2161
2162
2163 dnl Check if the X11 header files are correctly installed. On some systems
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002164 dnl Xlib.h includes files that don't exist. On some systems X11/Intrinsic.h
2165 dnl is missing.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002166 AC_MSG_CHECKING(if X11 header files can be found)
2167 cflags_save=$CFLAGS
2168 CFLAGS="$CFLAGS $X_CFLAGS"
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002169 AC_TRY_COMPILE([#include <X11/Xlib.h>
2170#include <X11/Intrinsic.h>], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002171 AC_MSG_RESULT(yes),
2172 AC_MSG_RESULT(no); no_x=yes)
2173 CFLAGS=$cflags_save
2174
2175 if test "${no_x-no}" = yes; then
2176 with_x=no
2177 else
2178 AC_DEFINE(HAVE_X11)
2179 X_LIB="-lXt -lX11";
2180 AC_SUBST(X_LIB)
2181
2182 ac_save_LDFLAGS="$LDFLAGS"
2183 LDFLAGS="-L$x_libraries $LDFLAGS"
2184
2185 dnl Check for -lXdmcp (needed on SunOS 4.1.4)
2186 dnl For HP-UX 10.20 it must be before -lSM -lICE
2187 AC_CHECK_LIB(Xdmcp, _XdmcpAuthDoIt, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lXdmcp"],,
2188 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXdmcp])
2189
2190 dnl Some systems need -lnsl -lsocket when testing for ICE.
2191 dnl The check above doesn't do this, try here (again). Also needed to get
2192 dnl them after Xdmcp. link.sh will remove them when not needed.
2193 dnl Check for other function than above to avoid the cached value
2194 AC_CHECK_LIB(ICE, IceOpenConnection,
2195 [X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE"],, [$X_EXTRA_LIBS])
2196
2197 dnl Check for -lXpm (needed for some versions of Motif)
2198 LDFLAGS="$X_LIBS $ac_save_LDFLAGS"
2199 AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [X_PRE_LIBS="$X_PRE_LIBS -lXpm"],,
2200 [-lXt $X_PRE_LIBS -lXpm -lX11 $X_EXTRA_LIBS])
2201
2202 dnl Check that the X11 header files don't use implicit declarations
2203 AC_MSG_CHECKING(if X11 header files implicitly declare return values)
2204 cflags_save=$CFLAGS
Bram Moolenaard1864592013-05-04 04:40:15 +02002205 dnl -Werror is GCC only, others like Solaris Studio might not like it
2206 if test "$GCC" = yes; then
2207 CFLAGS="$CFLAGS $X_CFLAGS -Werror"
2208 else
2209 CFLAGS="$CFLAGS $X_CFLAGS"
2210 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002211 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2212 AC_MSG_RESULT(no),
2213 CFLAGS="$CFLAGS -Wno-implicit-int"
2214 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2215 AC_MSG_RESULT(yes); cflags_save="$cflags_save -Wno-implicit-int",
2216 AC_MSG_RESULT(test failed)
2217 )
2218 )
2219 CFLAGS=$cflags_save
2220
2221 LDFLAGS="$ac_save_LDFLAGS"
2222
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002223 AC_MSG_CHECKING(size of wchar_t is 2 bytes)
2224 AC_CACHE_VAL(ac_cv_small_wchar_t,
2225 [AC_TRY_RUN([
2226#include <X11/Xlib.h>
2227#if STDC_HEADERS
2228# include <stdlib.h>
2229# include <stddef.h>
2230#endif
2231 main()
2232 {
2233 if (sizeof(wchar_t) <= 2)
2234 exit(1);
2235 exit(0);
2236 }],
2237 ac_cv_small_wchar_t="no",
2238 ac_cv_small_wchar_t="yes",
2239 AC_MSG_ERROR(failed to compile test program))])
2240 AC_MSG_RESULT($ac_cv_small_wchar_t)
2241 if test "x$ac_cv_small_wchar_t" = "xyes" ; then
2242 AC_DEFINE(SMALL_WCHAR_T)
2243 fi
2244
Bram Moolenaar071d4272004-06-13 20:20:40 +00002245 fi
2246fi
2247
Bram Moolenaard0573012017-10-28 21:11:06 +02002248test "x$with_x" = xno -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && enable_gui=no
Bram Moolenaar071d4272004-06-13 20:20:40 +00002249
2250AC_MSG_CHECKING(--enable-gui argument)
2251AC_ARG_ENABLE(gui,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002252 [ --enable-gui[=OPTS] X11 GUI. [default=auto] [OPTS=auto/no/gtk2/gnome2/gtk3/motif/athena/neXtaw/photon/carbon]], , enable_gui="auto")
Bram Moolenaar071d4272004-06-13 20:20:40 +00002253
2254dnl Canonicalize the --enable-gui= argument so that it can be easily compared.
2255dnl Do not use character classes for portability with old tools.
2256enable_gui_canon=`echo "_$enable_gui" | \
2257 sed 's/[[ _+-]]//g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
2258
2259dnl Skip everything by default.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002260SKIP_GTK2=YES
Bram Moolenaar1858a842016-02-23 22:30:31 +01002261SKIP_GTK3=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002262SKIP_GNOME=YES
2263SKIP_MOTIF=YES
2264SKIP_ATHENA=YES
2265SKIP_NEXTAW=YES
2266SKIP_PHOTON=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002267SKIP_CARBON=YES
2268GUITYPE=NONE
2269
Bram Moolenaarb11160e2005-01-04 21:31:43 +00002270if test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002271 SKIP_PHOTON=
2272 case "$enable_gui_canon" in
2273 no) AC_MSG_RESULT(no GUI support)
2274 SKIP_PHOTON=YES ;;
2275 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
2276 auto) AC_MSG_RESULT(auto - automatic GUI support) ;;
2277 photon) AC_MSG_RESULT(Photon GUI support) ;;
2278 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2279 SKIP_PHOTON=YES ;;
2280 esac
2281
Bram Moolenaard0573012017-10-28 21:11:06 +02002282elif test "x$MACOS_X" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002283 SKIP_CARBON=
2284 case "$enable_gui_canon" in
2285 no) AC_MSG_RESULT(no GUI support)
2286 SKIP_CARBON=YES ;;
2287 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
Bram Moolenaar164fca32010-07-14 13:58:07 +02002288 auto) AC_MSG_RESULT(auto - Carbon GUI is outdated - disable GUI support)
2289 SKIP_CARBON=YES ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002290 carbon) AC_MSG_RESULT(Carbon GUI support) ;;
2291 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2292 SKIP_CARBON=YES ;;
2293 esac
2294
2295else
2296
Bram Moolenaar071d4272004-06-13 20:20:40 +00002297 case "$enable_gui_canon" in
2298 no|none) AC_MSG_RESULT(no GUI support) ;;
2299 yes|""|auto) AC_MSG_RESULT(yes/auto - automatic GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002300 SKIP_GTK2=
2301 SKIP_GNOME=
2302 SKIP_MOTIF=
2303 SKIP_ATHENA=
2304 SKIP_NEXTAW=
2305 SKIP_CARBON=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002306 gtk2) AC_MSG_RESULT(GTK+ 2.x GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002307 SKIP_GTK2=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002308 gnome2) AC_MSG_RESULT(GNOME 2.x GUI support)
2309 SKIP_GNOME=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002310 SKIP_GTK2=;;
Bram Moolenaar98921892016-02-23 17:14:37 +01002311 gtk3) AC_MSG_RESULT(GTK+ 3.x GUI support)
2312 SKIP_GTK3=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002313 motif) AC_MSG_RESULT(Motif GUI support)
2314 SKIP_MOTIF=;;
2315 athena) AC_MSG_RESULT(Athena GUI support)
2316 SKIP_ATHENA=;;
2317 nextaw) AC_MSG_RESULT(neXtaw GUI support)
2318 SKIP_NEXTAW=;;
2319 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
2320 esac
2321
2322fi
2323
Bram Moolenaar071d4272004-06-13 20:20:40 +00002324if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \
2325 -a "$enable_gui_canon" != "gnome2"; then
2326 AC_MSG_CHECKING(whether or not to look for GTK+ 2)
2327 AC_ARG_ENABLE(gtk2-check,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002328 [ --enable-gtk2-check If auto-select GUI, check for GTK+ 2 [default=yes]],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002329 , enable_gtk2_check="yes")
2330 AC_MSG_RESULT($enable_gtk2_check)
2331 if test "x$enable_gtk2_check" = "xno"; then
2332 SKIP_GTK2=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002333 SKIP_GNOME=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002334 fi
2335fi
2336
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002337if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002338 AC_MSG_CHECKING(whether or not to look for GNOME)
2339 AC_ARG_ENABLE(gnome-check,
2340 [ --enable-gnome-check If GTK GUI, check for GNOME [default=no]],
2341 , enable_gnome_check="no")
2342 AC_MSG_RESULT($enable_gnome_check)
2343 if test "x$enable_gnome_check" = "xno"; then
2344 SKIP_GNOME=YES
2345 fi
2346fi
2347
Bram Moolenaar98921892016-02-23 17:14:37 +01002348if test "x$SKIP_GTK3" != "xYES" -a "$enable_gui_canon" != "gtk3"; then
2349 AC_MSG_CHECKING(whether or not to look for GTK+ 3)
2350 AC_ARG_ENABLE(gtk3-check,
2351 [ --enable-gtk3-check If auto-select GUI, check for GTK+ 3 [default=yes]],
2352 , enable_gtk3_check="yes")
2353 AC_MSG_RESULT($enable_gtk3_check)
2354 if test "x$enable_gtk3_check" = "xno"; then
2355 SKIP_GTK3=YES
2356 fi
2357fi
2358
Bram Moolenaar071d4272004-06-13 20:20:40 +00002359if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then
2360 AC_MSG_CHECKING(whether or not to look for Motif)
2361 AC_ARG_ENABLE(motif-check,
2362 [ --enable-motif-check If auto-select GUI, check for Motif [default=yes]],
2363 , enable_motif_check="yes")
2364 AC_MSG_RESULT($enable_motif_check)
2365 if test "x$enable_motif_check" = "xno"; then
2366 SKIP_MOTIF=YES
2367 fi
2368fi
2369
2370if test "x$SKIP_ATHENA" != "xYES" -a "$enable_gui_canon" != "athena"; then
2371 AC_MSG_CHECKING(whether or not to look for Athena)
2372 AC_ARG_ENABLE(athena-check,
2373 [ --enable-athena-check If auto-select GUI, check for Athena [default=yes]],
2374 , enable_athena_check="yes")
2375 AC_MSG_RESULT($enable_athena_check)
2376 if test "x$enable_athena_check" = "xno"; then
2377 SKIP_ATHENA=YES
2378 fi
2379fi
2380
2381if test "x$SKIP_NEXTAW" != "xYES" -a "$enable_gui_canon" != "nextaw"; then
2382 AC_MSG_CHECKING(whether or not to look for neXtaw)
2383 AC_ARG_ENABLE(nextaw-check,
2384 [ --enable-nextaw-check If auto-select GUI, check for neXtaw [default=yes]],
2385 , enable_nextaw_check="yes")
2386 AC_MSG_RESULT($enable_nextaw_check);
2387 if test "x$enable_nextaw_check" = "xno"; then
2388 SKIP_NEXTAW=YES
2389 fi
2390fi
2391
2392if test "x$SKIP_CARBON" != "xYES" -a "$enable_gui_canon" != "carbon"; then
2393 AC_MSG_CHECKING(whether or not to look for Carbon)
2394 AC_ARG_ENABLE(carbon-check,
2395 [ --enable-carbon-check If auto-select GUI, check for Carbon [default=yes]],
2396 , enable_carbon_check="yes")
2397 AC_MSG_RESULT($enable_carbon_check);
2398 if test "x$enable_carbon_check" = "xno"; then
2399 SKIP_CARBON=YES
2400 fi
2401fi
2402
Bram Moolenaar843ee412004-06-30 16:16:41 +00002403
Bram Moolenaard0573012017-10-28 21:11:06 +02002404if test "x$MACOS_X" = "xyes" -a -z "$SKIP_CARBON" -a "x$CARBON" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002405 AC_MSG_CHECKING(for Carbon GUI)
Bram Moolenaar14716812006-05-04 21:54:08 +00002406 dnl already did the check, just give the message
Bram Moolenaar071d4272004-06-13 20:20:40 +00002407 AC_MSG_RESULT(yes);
2408 GUITYPE=CARBONGUI
Bram Moolenaare344bea2005-09-01 20:46:49 +00002409 if test "$VIMNAME" = "vim"; then
2410 VIMNAME=Vim
2411 fi
Bram Moolenaar14716812006-05-04 21:54:08 +00002412
Bram Moolenaar164fca32010-07-14 13:58:07 +02002413 if test "x$MACARCH" = "xboth"; then
2414 CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk/Developer/Headers/FlatCarbon"
2415 else
2416 CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/Headers/FlatCarbon"
2417 fi
2418
Bram Moolenaar14716812006-05-04 21:54:08 +00002419 dnl Default install directory is not /usr/local
2420 if test x$prefix = xNONE; then
2421 prefix=/Applications
2422 fi
2423
2424 dnl Sorry for the hard coded default
2425 datadir='${prefix}/Vim.app/Contents/Resources'
2426
Bram Moolenaar071d4272004-06-13 20:20:40 +00002427 dnl skip everything else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002428 SKIP_GTK2=YES;
2429 SKIP_GNOME=YES;
2430 SKIP_MOTIF=YES;
2431 SKIP_ATHENA=YES;
2432 SKIP_NEXTAW=YES;
2433 SKIP_PHOTON=YES;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002434 SKIP_CARBON=YES
2435fi
2436
Bram Moolenaar071d4272004-06-13 20:20:40 +00002437dnl define an autoconf function to check for a specified version of GTK, and
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002438dnl try to compile/link a GTK program.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002439dnl
2440dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002441dnl Test for GTK, and define GTK_CFLAGS, GTK_LIBDIR and GTK_LIBS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002442dnl
2443AC_DEFUN(AM_PATH_GTK,
2444[
2445 if test "X$GTK_CONFIG" != "Xno" -o "X$PKG_CONFIG" != "Xno"; then
2446 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00002447 no_gtk=""
2448 if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2449 && $PKG_CONFIG --exists gtk+-2.0; then
2450 {
Bram Moolenaar98921892016-02-23 17:14:37 +01002451 min_gtk_version=ifelse([$1], ,2.2.0,$1)
2452 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002453 dnl We should be using PKG_CHECK_MODULES() instead of this hack.
2454 dnl But I guess the dependency on pkgconfig.m4 is not wanted or
2455 dnl something like that.
2456 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0`
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002457 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-2.0`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002458 GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0`
2459 gtk_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2460 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2461 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2462 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2463 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2464 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2465 }
Bram Moolenaar98921892016-02-23 17:14:37 +01002466 elif (test "X$SKIP_GTK3" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2467 && $PKG_CONFIG --exists gtk+-3.0; then
2468 {
2469 min_gtk_version=ifelse([$1], ,3.0.0,$1)
2470 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
2471
2472 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-3.0`
2473 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-3.0`
2474 GTK_LIBS=`$PKG_CONFIG --libs gtk+-3.0`
2475 gtk_major_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2476 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2477 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2478 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2479 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2480 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2481 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002482 else
2483 no_gtk=yes
2484 fi
2485
2486 if test "x$enable_gtktest" = "xyes" -a "x$no_gtk" = "x"; then
2487 {
2488 ac_save_CFLAGS="$CFLAGS"
2489 ac_save_LIBS="$LIBS"
2490 CFLAGS="$CFLAGS $GTK_CFLAGS"
2491 LIBS="$LIBS $GTK_LIBS"
2492
2493 dnl
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002494 dnl Now check if the installed GTK is sufficiently new.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002495 dnl
2496 rm -f conf.gtktest
2497 AC_TRY_RUN([
2498#include <gtk/gtk.h>
2499#include <stdio.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00002500#if STDC_HEADERS
2501# include <stdlib.h>
2502# include <stddef.h>
2503#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002504
2505int
2506main ()
2507{
2508int major, minor, micro;
2509char *tmp_version;
2510
2511system ("touch conf.gtktest");
2512
2513/* HP/UX 9 (%@#!) writes to sscanf strings */
2514tmp_version = g_strdup("$min_gtk_version");
2515if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
2516 printf("%s, bad version string\n", "$min_gtk_version");
2517 exit(1);
2518 }
2519
2520if ((gtk_major_version > major) ||
2521 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
2522 ((gtk_major_version == major) && (gtk_minor_version == minor) &&
2523 (gtk_micro_version >= micro)))
2524{
2525 return 0;
2526}
2527return 1;
2528}
2529],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
2530 CFLAGS="$ac_save_CFLAGS"
2531 LIBS="$ac_save_LIBS"
2532 }
2533 fi
2534 if test "x$no_gtk" = x ; then
2535 if test "x$enable_gtktest" = "xyes"; then
2536 AC_MSG_RESULT(yes; found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2537 else
2538 AC_MSG_RESULT(found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2539 fi
2540 ifelse([$2], , :, [$2])
2541 else
2542 {
2543 AC_MSG_RESULT(no)
2544 GTK_CFLAGS=""
2545 GTK_LIBS=""
2546 ifelse([$3], , :, [$3])
2547 }
2548 fi
2549 }
2550 else
2551 GTK_CFLAGS=""
2552 GTK_LIBS=""
2553 ifelse([$3], , :, [$3])
2554 fi
2555 AC_SUBST(GTK_CFLAGS)
2556 AC_SUBST(GTK_LIBS)
2557 rm -f conf.gtktest
2558])
2559
2560dnl ---------------------------------------------------------------------------
2561dnl gnome
2562dnl ---------------------------------------------------------------------------
2563AC_DEFUN([GNOME_INIT_HOOK],
2564[
2565 AC_SUBST(GNOME_LIBS)
2566 AC_SUBST(GNOME_LIBDIR)
2567 AC_SUBST(GNOME_INCLUDEDIR)
2568
2569 AC_ARG_WITH(gnome-includes,
2570 [ --with-gnome-includes=DIR Specify location of GNOME headers],
2571 [CFLAGS="$CFLAGS -I$withval"]
2572 )
2573
2574 AC_ARG_WITH(gnome-libs,
2575 [ --with-gnome-libs=DIR Specify location of GNOME libs],
2576 [LDFLAGS="$LDFLAGS -L$withval" gnome_prefix=$withval]
2577 )
2578
2579 AC_ARG_WITH(gnome,
2580 [ --with-gnome Specify prefix for GNOME files],
2581 if test x$withval = xyes; then
2582 want_gnome=yes
2583 ifelse([$1], [], :, [$1])
2584 else
2585 if test "x$withval" = xno; then
2586 want_gnome=no
2587 else
2588 want_gnome=yes
2589 LDFLAGS="$LDFLAGS -L$withval/lib"
2590 CFLAGS="$CFLAGS -I$withval/include"
2591 gnome_prefix=$withval/lib
2592 fi
2593 fi,
2594 want_gnome=yes)
2595
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002596 if test "x$want_gnome" = xyes; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002597 {
2598 AC_MSG_CHECKING(for libgnomeui-2.0)
2599 if $PKG_CONFIG --exists libgnomeui-2.0; then
2600 AC_MSG_RESULT(yes)
2601 GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0`
2602 GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0`
2603 GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0`
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002604
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002605 dnl On FreeBSD we need -pthread but pkg-config doesn't include it.
2606 dnl This might not be the right way but it works for me...
2607 AC_MSG_CHECKING(for FreeBSD)
2608 if test "`(uname) 2>/dev/null`" = FreeBSD; then
2609 AC_MSG_RESULT(yes, adding -pthread)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002610 GNOME_INCLUDEDIR="$GNOME_INCLUDEDIR -D_THREAD_SAFE"
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002611 GNOME_LIBS="$GNOME_LIBS -pthread"
2612 else
2613 AC_MSG_RESULT(no)
2614 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002615 $1
2616 else
2617 AC_MSG_RESULT(not found)
2618 if test "x$2" = xfail; then
2619 AC_MSG_ERROR(Could not find libgnomeui-2.0 via pkg-config)
2620 fi
2621 fi
2622 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002623 fi
2624])
2625
2626AC_DEFUN([GNOME_INIT],[
2627 GNOME_INIT_HOOK([],fail)
2628])
2629
2630
2631dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002632dnl Check for GTK2. If it fails, then continue on for Motif as before...
Bram Moolenaar071d4272004-06-13 20:20:40 +00002633dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002634if test -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002635
2636 AC_MSG_CHECKING(--disable-gtktest argument)
2637 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2638 , enable_gtktest=yes)
2639 if test "x$enable_gtktest" = "xyes" ; then
2640 AC_MSG_RESULT(gtk test enabled)
2641 else
2642 AC_MSG_RESULT(gtk test disabled)
2643 fi
2644
Bram Moolenaar071d4272004-06-13 20:20:40 +00002645 if test "X$PKG_CONFIG" = "X"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01002646 AC_PATH_TOOL(PKG_CONFIG, pkg-config, no)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002647 fi
2648
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002649 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002650 dnl First try finding version 2.2.0 or later. The 2.0.x series has
2651 dnl problems (bold fonts, --remote doesn't work).
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002652 AM_PATH_GTK(2.2.0,
2653 [GUI_LIB_LOC="$GTK_LIBDIR"
2654 GTK_LIBNAME="$GTK_LIBS"
2655 GUI_INC_LOC="$GTK_CFLAGS"], )
2656 if test "x$GTK_CFLAGS" != "x"; then
Bram Moolenaar98921892016-02-23 17:14:37 +01002657 SKIP_GTK3=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002658 SKIP_ATHENA=YES
2659 SKIP_NEXTAW=YES
2660 SKIP_MOTIF=YES
2661 GUITYPE=GTK
2662 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002663 fi
2664 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002665 if test "x$GUITYPE" = "xGTK"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002666 dnl
2667 dnl if GTK exists, then check for GNOME.
2668 dnl
2669 if test -z "$SKIP_GNOME"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002670 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002671 GNOME_INIT_HOOK([have_gnome=yes])
2672 if test "x$have_gnome" = xyes ; then
2673 AC_DEFINE(FEAT_GUI_GNOME)
2674 GUI_INC_LOC="$GUI_INC_LOC $GNOME_INCLUDEDIR"
2675 GTK_LIBNAME="$GTK_LIBNAME $GNOME_LIBDIR $GNOME_LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002676 fi
2677 }
2678 fi
2679 fi
2680fi
2681
Bram Moolenaar98921892016-02-23 17:14:37 +01002682
2683dnl ---------------------------------------------------------------------------
2684dnl Check for GTK3.
2685dnl ---------------------------------------------------------------------------
2686if test -z "$SKIP_GTK3"; then
2687
2688 AC_MSG_CHECKING(--disable-gtktest argument)
2689 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2690 , enable_gtktest=yes)
2691 if test "x$enable_gtktest" = "xyes" ; then
2692 AC_MSG_RESULT(gtk test enabled)
2693 else
2694 AC_MSG_RESULT(gtk test disabled)
2695 fi
2696
2697 if test "X$PKG_CONFIG" = "X"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01002698 AC_PATH_TOOL(PKG_CONFIG, pkg-config, no)
Bram Moolenaar98921892016-02-23 17:14:37 +01002699 fi
2700
2701 if test "x$PKG_CONFIG" != "xno"; then
2702 AM_PATH_GTK(3.0.0,
2703 [GUI_LIB_LOC="$GTK_LIBDIR"
2704 GTK_LIBNAME="$GTK_LIBS"
2705 GUI_INC_LOC="$GTK_CFLAGS"], )
2706 if test "x$GTK_CFLAGS" != "x"; then
2707 SKIP_GTK2=YES
2708 SKIP_GNOME=YES
2709 SKIP_ATHENA=YES
2710 SKIP_NEXTAW=YES
2711 SKIP_MOTIF=YES
2712 GUITYPE=GTK
2713 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar98921892016-02-23 17:14:37 +01002714 AC_DEFINE(USE_GTK3)
2715 fi
2716 fi
2717fi
2718
Bram Moolenaard2e03f02016-01-02 22:46:36 +01002719dnl Check the version of Gdk-Pixbuf. If the version is 2.31 or later and
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002720dnl glib-compile-resources is found in PATH, use GResource.
2721if test "x$GUITYPE" = "xGTK"; then
2722 AC_MSG_CHECKING([version of Gdk-Pixbuf])
2723 gdk_pixbuf_version=`$PKG_CONFIG --modversion gdk-pixbuf-2.0`
2724 if test "x$gdk_pixbuf_version" != x ; then
2725 gdk_pixbuf_version_minor=`echo $gdk_pixbuf_version | \
2726 sed -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/'`
2727 if test "x$gdk_pixbuf_version_minor" != x -a \
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002728 $gdk_pixbuf_version_minor -ge 31 ; then
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002729 AC_MSG_RESULT([OK.])
2730 AC_PATH_PROG(GLIB_COMPILE_RESOURCES,[glib-compile-resources],no)
2731 AC_MSG_CHECKING([glib-compile-resources])
2732 if test "x$GLIB_COMPILE_RESOURCES" = xno ; then
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002733 GLIB_COMPILE_RESOURCES=""
2734 AC_MSG_RESULT([cannot be found in PATH.])
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002735 else
2736 AC_MSG_RESULT([usable.])
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002737 AC_DEFINE(USE_GRESOURCE)
2738 GRESOURCE_SRC="auto/gui_gtk_gresources.c"
2739 GRESOURCE_OBJ="objects/gui_gtk_gresources.o"
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002740 fi
2741 else
2742 AC_MSG_RESULT([not usable.])
2743 fi
2744 else
2745 AC_MSG_RESULT([cannot obtain from pkg_config.])
2746 fi
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002747
2748 AC_MSG_CHECKING([--disable-icon-cache-update argument])
2749 AC_ARG_ENABLE(icon_cache_update,
2750 [ --disable-icon-cache-update update disabled],
2751 [],
2752 [enable_icon_cache_update="yes"])
2753 if test "$enable_icon_cache_update" = "yes"; then
2754 AC_MSG_RESULT([not set])
2755 AC_PATH_PROG(GTK_UPDATE_ICON_CACHE,[gtk-update-icon-cache],no)
2756 if test "x$GTK_UPDATE_ICON_CACHE" = "xno" ; then
2757 AC_MSG_RESULT([not found in PATH.])
2758 fi
2759 else
2760 AC_MSG_RESULT([update disabled])
2761 fi
2762
2763 AC_MSG_CHECKING([--disable-desktop-database-update argument])
2764 AC_ARG_ENABLE(desktop_database_update,
2765 [ --disable-desktop-database-update update disabled],
2766 [],
2767 [enable_desktop_database_update="yes"])
2768 if test "$enable_desktop_database_update" = "yes"; then
2769 AC_MSG_RESULT([not set])
2770 AC_PATH_PROG(UPDATE_DESKTOP_DATABASE,[update-desktop-database],no)
2771 if test "x$UPDATE_DESKTOP_DATABASE" = "xno" ; then
2772 AC_MSG_RESULT([not found in PATH.])
2773 fi
2774 else
2775 AC_MSG_RESULT([update disabled])
2776 fi
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002777fi
2778AC_SUBST(GLIB_COMPILE_RESOURCES)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002779AC_SUBST(GRESOURCE_SRC)
2780AC_SUBST(GRESOURCE_OBJ)
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002781AC_SUBST(GTK_UPDATE_ICON_CACHE)
2782AC_SUBST(UPDATE_DESKTOP_DATABASE)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002783
Bram Moolenaar071d4272004-06-13 20:20:40 +00002784dnl Check for Motif include files location.
2785dnl The LAST one found is used, this makes the highest version to be used,
2786dnl e.g. when Motif1.2 and Motif2.0 are both present.
2787
2788if test -z "$SKIP_MOTIF"; then
2789 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"
2790 dnl Remove "-I" from before $GUI_INC_LOC if it's there
2791 GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`"
2792
2793 AC_MSG_CHECKING(for location of Motif GUI includes)
2794 gui_includes="`echo $x_includes|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC"
2795 GUI_INC_LOC=
2796 for try in $gui_includes; do
2797 if test -f "$try/Xm/Xm.h"; then
2798 GUI_INC_LOC=$try
2799 fi
2800 done
2801 if test -n "$GUI_INC_LOC"; then
2802 if test "$GUI_INC_LOC" = /usr/include; then
2803 GUI_INC_LOC=
2804 AC_MSG_RESULT(in default path)
2805 else
2806 AC_MSG_RESULT($GUI_INC_LOC)
2807 fi
2808 else
2809 AC_MSG_RESULT(<not found>)
2810 SKIP_MOTIF=YES
2811 fi
2812fi
2813
2814dnl Check for Motif library files location. In the same order as the include
2815dnl files, to avoid a mixup if several versions are present
2816
2817if test -z "$SKIP_MOTIF"; then
2818 AC_MSG_CHECKING(--with-motif-lib argument)
2819 AC_ARG_WITH(motif-lib,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002820 [ --with-motif-lib=STRING Library for Motif ],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002821 [ MOTIF_LIBNAME="${withval}" ] )
2822
2823 if test -n "$MOTIF_LIBNAME"; then
2824 AC_MSG_RESULT($MOTIF_LIBNAME)
2825 GUI_LIB_LOC=
2826 else
2827 AC_MSG_RESULT(no)
2828
2829 dnl Remove "-L" from before $GUI_LIB_LOC if it's there
2830 GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
2831
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002832 dnl Ubuntu has libXm.so in /usr/lib/i386-linux-gnu and elsewhere. The
2833 dnl linker will figure out which one to use, we only check if one exists.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002834 AC_MSG_CHECKING(for location of Motif GUI libs)
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002835 gui_libs="`echo $x_libraries|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/lib/g` /usr/lib/i386-linux-gnu /usr/lib/x86_64-linux-gnu `echo "$GUI_INC_LOC" | sed s/include/lib/` $GUI_LIB_LOC"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002836 GUI_LIB_LOC=
2837 for try in $gui_libs; do
Bram Moolenaar325b7a22004-07-05 15:58:32 +00002838 for libtry in "$try"/libXm.a "$try"/libXm.so* "$try"/libXm.sl "$try"/libXm.dylib; do
Bram Moolenaar071d4272004-06-13 20:20:40 +00002839 if test -f "$libtry"; then
2840 GUI_LIB_LOC=$try
2841 fi
2842 done
2843 done
2844 if test -n "$GUI_LIB_LOC"; then
2845 dnl Remove /usr/lib, it causes trouble on some systems
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002846 if test "$GUI_LIB_LOC" = /usr/lib \
2847 -o "$GUI_LIB_LOC" = /usr/lib/i386-linux-gnu \
2848 -o "$GUI_LIB_LOC" = /usr/lib/x86_64-linux-gnu; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002849 GUI_LIB_LOC=
2850 AC_MSG_RESULT(in default path)
2851 else
2852 if test -n "$GUI_LIB_LOC"; then
2853 AC_MSG_RESULT($GUI_LIB_LOC)
2854 if test "`(uname) 2>/dev/null`" = SunOS &&
2855 uname -r | grep '^5' >/dev/null; then
2856 GUI_LIB_LOC="$GUI_LIB_LOC -R $GUI_LIB_LOC"
2857 fi
2858 fi
2859 fi
2860 MOTIF_LIBNAME=-lXm
2861 else
2862 AC_MSG_RESULT(<not found>)
2863 SKIP_MOTIF=YES
2864 fi
2865 fi
2866fi
2867
2868if test -z "$SKIP_MOTIF"; then
2869 SKIP_ATHENA=YES
2870 SKIP_NEXTAW=YES
2871 GUITYPE=MOTIF
2872 AC_SUBST(MOTIF_LIBNAME)
2873fi
2874
2875dnl Check if the Athena files can be found
2876
2877GUI_X_LIBS=
2878
2879if test -z "$SKIP_ATHENA"; then
2880 AC_MSG_CHECKING(if Athena header files can be found)
2881 cflags_save=$CFLAGS
2882 CFLAGS="$CFLAGS $X_CFLAGS"
2883 AC_TRY_COMPILE([
2884#include <X11/Intrinsic.h>
2885#include <X11/Xaw/Paned.h>], ,
2886 AC_MSG_RESULT(yes),
2887 AC_MSG_RESULT(no); SKIP_ATHENA=YES )
2888 CFLAGS=$cflags_save
2889fi
2890
2891if test -z "$SKIP_ATHENA"; then
2892 GUITYPE=ATHENA
2893fi
2894
2895if test -z "$SKIP_NEXTAW"; then
2896 AC_MSG_CHECKING(if neXtaw header files can be found)
2897 cflags_save=$CFLAGS
2898 CFLAGS="$CFLAGS $X_CFLAGS"
2899 AC_TRY_COMPILE([
2900#include <X11/Intrinsic.h>
2901#include <X11/neXtaw/Paned.h>], ,
2902 AC_MSG_RESULT(yes),
2903 AC_MSG_RESULT(no); SKIP_NEXTAW=YES )
2904 CFLAGS=$cflags_save
2905fi
2906
2907if test -z "$SKIP_NEXTAW"; then
2908 GUITYPE=NEXTAW
2909fi
2910
2911if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
2912 dnl Prepend -I and -L to $GUI_INC_LOC and $GUI_LIB_LOC if not empty
2913 dnl Avoid adding it when it twice
2914 if test -n "$GUI_INC_LOC"; then
2915 GUI_INC_LOC=-I"`echo $GUI_INC_LOC|sed 's%-I%%'`"
2916 fi
2917 if test -n "$GUI_LIB_LOC"; then
2918 GUI_LIB_LOC=-L"`echo $GUI_LIB_LOC|sed 's%-L%%'`"
2919 fi
2920
2921 dnl Check for -lXext and then for -lXmu
2922 ldflags_save=$LDFLAGS
2923 LDFLAGS="$X_LIBS $LDFLAGS"
2924 AC_CHECK_LIB(Xext, XShapeQueryExtension, [GUI_X_LIBS="-lXext"],,
2925 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2926 dnl For Solaris we need -lw and -ldl before linking with -lXmu works.
2927 AC_CHECK_LIB(w, wslen, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lw"],,
2928 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2929 AC_CHECK_LIB(dl, dlsym, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldl"],,
2930 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2931 AC_CHECK_LIB(Xmu, XmuCreateStippledPixmap, [GUI_X_LIBS="-lXmu $GUI_X_LIBS"],,
2932 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2933 if test -z "$SKIP_MOTIF"; then
2934 AC_CHECK_LIB(Xp, XpEndJob, [GUI_X_LIBS="-lXp $GUI_X_LIBS"],,
2935 [$GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2936 fi
2937 LDFLAGS=$ldflags_save
2938
2939 dnl Execute xmkmf to figure out if -DNARROWPROTO is needed.
2940 AC_MSG_CHECKING(for extra X11 defines)
2941 NARROW_PROTO=
2942 rm -fr conftestdir
2943 if mkdir conftestdir; then
2944 cd conftestdir
2945 cat > Imakefile <<'EOF'
2946acfindx:
2947 @echo 'NARROW_PROTO="${PROTO_DEFINES}"'
2948EOF
2949 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
2950 eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
2951 fi
2952 cd ..
2953 rm -fr conftestdir
2954 fi
2955 if test -z "$NARROW_PROTO"; then
2956 AC_MSG_RESULT(no)
2957 else
2958 AC_MSG_RESULT($NARROW_PROTO)
2959 fi
2960 AC_SUBST(NARROW_PROTO)
2961fi
2962
2963dnl Look for XSMP support - but don't necessarily restrict it to X11 GUIs
2964dnl use the X11 include path
2965if test "$enable_xsmp" = "yes"; then
2966 cppflags_save=$CPPFLAGS
2967 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2968 AC_CHECK_HEADERS(X11/SM/SMlib.h)
2969 CPPFLAGS=$cppflags_save
2970fi
2971
2972
Bram Moolenaar98921892016-02-23 17:14:37 +01002973if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF" -o -z "$SKIP_GTK2" -o -z "$SKIP_GTK3"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002974 dnl Check for X11/xpm.h and X11/Sunkeysym.h with the GUI include path
2975 cppflags_save=$CPPFLAGS
2976 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2977 AC_CHECK_HEADERS(X11/xpm.h X11/Sunkeysym.h)
2978
2979 dnl automatically disable XIM when XIMtext isn't in X11/Xlib.h
2980 if test ! "$enable_xim" = "no"; then
2981 AC_MSG_CHECKING(for XIMText in X11/Xlib.h)
2982 AC_EGREP_CPP(XIMText, [#include <X11/Xlib.h>],
2983 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +02002984 AC_MSG_RESULT(no; xim has been disabled); enable_xim="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00002985 fi
2986 CPPFLAGS=$cppflags_save
2987
2988 dnl automatically enable XIM when hangul input isn't enabled
2989 if test "$enable_xim" = "auto" -a "$enable_hangulinput" != "yes" \
2990 -a "x$GUITYPE" != "xNONE" ; then
2991 AC_MSG_RESULT(X GUI selected; xim has been enabled)
2992 enable_xim="yes"
2993 fi
2994fi
2995
2996if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
2997 cppflags_save=$CPPFLAGS
2998 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00002999dnl Xmu/Editres.h may exist but can only be used after including Intrinsic.h
3000 AC_MSG_CHECKING([for X11/Xmu/Editres.h])
3001 AC_TRY_COMPILE([
3002#include <X11/Intrinsic.h>
3003#include <X11/Xmu/Editres.h>],
3004 [int i; i = 0;],
3005 AC_MSG_RESULT(yes)
3006 AC_DEFINE(HAVE_X11_XMU_EDITRES_H),
3007 AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003008 CPPFLAGS=$cppflags_save
3009fi
3010
3011dnl Only use the Xm directory when compiling Motif, don't use it for Athena
3012if test -z "$SKIP_MOTIF"; then
3013 cppflags_save=$CPPFLAGS
3014 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003015 if test "$zOSUnix" = "yes"; then
3016 xmheader="Xm/Xm.h"
3017 else
3018 xmheader="Xm/Xm.h Xm/XpmP.h Xm/JoinSideT.h Xm/TraitP.h Xm/Manager.h
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02003019 Xm/UnhighlightT.h Xm/Notebook.h"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003020 fi
3021 AC_CHECK_HEADERS($xmheader)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003022
Bram Moolenaar77c19352012-06-13 19:19:41 +02003023 if test "x$ac_cv_header_Xm_XpmP_h" = "xyes"; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003024 dnl Solaris uses XpmAttributes_21, very annoying.
3025 AC_MSG_CHECKING([for XpmAttributes_21 in Xm/XpmP.h])
3026 AC_TRY_COMPILE([#include <Xm/XpmP.h>], [XpmAttributes_21 attr;],
3027 AC_MSG_RESULT(yes); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes_21),
3028 AC_MSG_RESULT(no); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
3029 )
3030 else
Bram Moolenaar57657d82006-04-21 22:12:41 +00003031 AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003032 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003033 CPPFLAGS=$cppflags_save
3034fi
3035
3036if test "x$GUITYPE" = "xNONE" -a "$enable_xim" = "yes"; then
3037 AC_MSG_RESULT(no GUI selected; xim has been disabled)
3038 enable_xim="no"
3039fi
3040if test "x$GUITYPE" = "xNONE" -a "$enable_fontset" = "yes"; then
3041 AC_MSG_RESULT(no GUI selected; fontset has been disabled)
3042 enable_fontset="no"
3043fi
Bram Moolenaar182c5be2010-06-25 05:37:59 +02003044if test "x$GUITYPE:$enable_fontset" = "xGTK:yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003045 AC_MSG_RESULT(GTK+ 2 GUI selected; fontset has been disabled)
3046 enable_fontset="no"
3047fi
3048
Bram Moolenaar071d4272004-06-13 20:20:40 +00003049if test -z "$SKIP_PHOTON"; then
3050 GUITYPE=PHOTONGUI
3051fi
3052
3053AC_SUBST(GUI_INC_LOC)
3054AC_SUBST(GUI_LIB_LOC)
3055AC_SUBST(GUITYPE)
3056AC_SUBST(GUI_X_LIBS)
3057
3058if test "$enable_workshop" = "yes" -a -n "$SKIP_MOTIF"; then
3059 AC_MSG_ERROR([cannot use workshop without Motif])
3060fi
3061
3062dnl defining FEAT_XIM and FEAT_XFONTSET is delayed, so that they can be disabled
3063if test "$enable_xim" = "yes"; then
3064 AC_DEFINE(FEAT_XIM)
3065fi
3066if test "$enable_fontset" = "yes"; then
3067 AC_DEFINE(FEAT_XFONTSET)
3068fi
3069
3070
3071dnl ---------------------------------------------------------------------------
3072dnl end of GUI-checking
3073dnl ---------------------------------------------------------------------------
3074
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003075AC_MSG_CHECKING([for /proc link to executable])
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003076if test -L "/proc/self/exe"; then
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003077 dnl Linux
3078 AC_MSG_RESULT([/proc/self/exe])
3079 AC_DEFINE(PROC_EXE_LINK, "/proc/self/exe")
3080elif test -L "/proc/self/path/a.out"; then
3081 dnl Solaris
3082 AC_MSG_RESULT([/proc/self/path/a.out])
3083 AC_DEFINE(PROC_EXE_LINK, "/proc/self/path/a.out")
3084elif test -L "/proc/curproc/file"; then
3085 dnl FreeBSD
3086 AC_MSG_RESULT([/proc/curproc/file])
3087 AC_DEFINE(PROC_EXE_LINK, "/proc/curproc/file")
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003088else
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003089 AC_MSG_RESULT(no)
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003090fi
3091
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003092dnl Check for Cygwin, which needs an extra source file if not using X11
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003093AC_MSG_CHECKING(for CYGWIN or MSYS environment)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003094case `uname` in
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003095 CYGWIN*|MSYS*) CYGWIN=yes; AC_MSG_RESULT(yes)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003096 AC_MSG_CHECKING(for CYGWIN clipboard support)
3097 if test "x$with_x" = "xno" ; then
3098 OS_EXTRA_SRC=winclip.c; OS_EXTRA_OBJ=objects/winclip.o
3099 AC_MSG_RESULT(yes)
3100 AC_DEFINE(FEAT_CYGWIN_WIN32_CLIPBOARD)
3101 else
3102 AC_MSG_RESULT(no - using X11)
3103 fi ;;
3104
3105 *) CYGWIN=no; AC_MSG_RESULT(no);;
3106esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00003107
3108dnl Only really enable hangul input when GUI and XFONTSET are available
3109if test "$enable_hangulinput" = "yes"; then
3110 if test "x$GUITYPE" = "xNONE"; then
3111 AC_MSG_RESULT(no GUI selected; hangul input has been disabled)
3112 enable_hangulinput=no
3113 else
3114 AC_DEFINE(FEAT_HANGULIN)
3115 HANGULIN_SRC=hangulin.c
3116 AC_SUBST(HANGULIN_SRC)
3117 HANGULIN_OBJ=objects/hangulin.o
3118 AC_SUBST(HANGULIN_OBJ)
3119 fi
3120fi
3121
3122dnl Checks for libraries and include files.
3123
Bram Moolenaar446cb832008-06-24 21:56:24 +00003124AC_CACHE_CHECK([whether toupper is broken], [vim_cv_toupper_broken],
3125 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003126 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003127#include "confdefs.h"
3128#include <ctype.h>
3129#if STDC_HEADERS
3130# include <stdlib.h>
3131# include <stddef.h>
3132#endif
3133main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003134 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003135 vim_cv_toupper_broken=yes
3136 ],[
3137 vim_cv_toupper_broken=no
3138 ],[
3139 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_toupper_broken')
3140 ])])
3141
3142if test "x$vim_cv_toupper_broken" = "xyes" ; then
3143 AC_DEFINE(BROKEN_TOUPPER)
3144fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003145
3146AC_MSG_CHECKING(whether __DATE__ and __TIME__ work)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003147AC_TRY_COMPILE([#include <stdio.h>], [printf("(" __DATE__ " " __TIME__ ")");],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003148 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DATE_TIME),
3149 AC_MSG_RESULT(no))
3150
Bram Moolenaar0c094b92009-05-14 20:20:33 +00003151AC_MSG_CHECKING(whether __attribute__((unused)) is allowed)
3152AC_TRY_COMPILE([#include <stdio.h>], [int x __attribute__((unused));],
3153 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ATTRIBUTE_UNUSED),
3154 AC_MSG_RESULT(no))
3155
Bram Moolenaar071d4272004-06-13 20:20:40 +00003156dnl Checks for header files.
3157AC_CHECK_HEADER(elf.h, HAS_ELF=1)
3158dnl AC_CHECK_HEADER(dwarf.h, SVR4=1)
3159if test "$HAS_ELF" = 1; then
3160 AC_CHECK_LIB(elf, main)
3161fi
3162
3163AC_HEADER_DIRENT
3164
Bram Moolenaar071d4272004-06-13 20:20:40 +00003165dnl If sys/wait.h is not found it might still exist but not be POSIX
3166dnl compliant. In that case we define HAVE_UNION_WAIT (for NeXT)
3167if test $ac_cv_header_sys_wait_h = no; then
3168 AC_MSG_CHECKING([for sys/wait.h that defines union wait])
3169 AC_TRY_COMPILE([#include <sys/wait.h>],
3170 [union wait xx, yy; xx = yy],
3171 AC_MSG_RESULT(yes)
3172 AC_DEFINE(HAVE_SYS_WAIT_H)
3173 AC_DEFINE(HAVE_UNION_WAIT),
3174 AC_MSG_RESULT(no))
3175fi
3176
Bram Moolenaar779a7752016-01-30 23:26:34 +01003177AC_CHECK_HEADERS(stdint.h stdlib.h string.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003178 sys/select.h sys/utsname.h termcap.h fcntl.h \
3179 sgtty.h sys/ioctl.h sys/time.h sys/types.h \
3180 termio.h iconv.h inttypes.h langinfo.h math.h \
3181 unistd.h stropts.h errno.h sys/resource.h \
3182 sys/systeminfo.h locale.h sys/stream.h termios.h \
3183 libc.h sys/statfs.h poll.h sys/poll.h pwd.h \
3184 utime.h sys/param.h libintl.h libgen.h \
3185 util/debug.h util/msg18n.h frame.h sys/acl.h \
3186 sys/access.h sys/sysinfo.h wchar.h wctype.h)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003187
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003188dnl sys/ptem.h depends on sys/stream.h on Solaris
3189AC_CHECK_HEADERS(sys/ptem.h, [], [],
3190[#if defined HAVE_SYS_STREAM_H
3191# include <sys/stream.h>
3192#endif])
3193
Bram Moolenaar32f31b12009-05-21 13:20:59 +00003194dnl sys/sysctl.h depends on sys/param.h on OpenBSD
3195AC_CHECK_HEADERS(sys/sysctl.h, [], [],
3196[#if defined HAVE_SYS_PARAM_H
3197# include <sys/param.h>
3198#endif])
3199
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003200
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003201dnl pthread_np.h may exist but can only be used after including pthread.h
3202AC_MSG_CHECKING([for pthread_np.h])
3203AC_TRY_COMPILE([
3204#include <pthread.h>
3205#include <pthread_np.h>],
3206 [int i; i = 0;],
3207 AC_MSG_RESULT(yes)
3208 AC_DEFINE(HAVE_PTHREAD_NP_H),
3209 AC_MSG_RESULT(no))
3210
Bram Moolenaare344bea2005-09-01 20:46:49 +00003211AC_CHECK_HEADERS(strings.h)
Bram Moolenaard0573012017-10-28 21:11:06 +02003212if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00003213 dnl The strings.h file on OS/X contains a warning and nothing useful.
3214 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3215else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003216
3217dnl Check if strings.h and string.h can both be included when defined.
3218AC_MSG_CHECKING([if strings.h can be included after string.h])
3219cppflags_save=$CPPFLAGS
3220CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3221AC_TRY_COMPILE([
3222#if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO)
3223# define _NO_PROTO /* like in os_unix.h, causes conflict for AIX (Winn) */
3224 /* but don't do it on AIX 5.1 (Uribarri) */
3225#endif
3226#ifdef HAVE_XM_XM_H
3227# include <Xm/Xm.h> /* This breaks it for HP-UX 11 (Squassabia) */
3228#endif
3229#ifdef HAVE_STRING_H
3230# include <string.h>
3231#endif
3232#if defined(HAVE_STRINGS_H)
3233# include <strings.h>
3234#endif
3235 ], [int i; i = 0;],
3236 AC_MSG_RESULT(yes),
3237 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3238 AC_MSG_RESULT(no))
3239CPPFLAGS=$cppflags_save
Bram Moolenaar9372a112005-12-06 19:59:18 +00003240fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003241
3242dnl Checks for typedefs, structures, and compiler characteristics.
3243AC_PROG_GCC_TRADITIONAL
3244AC_C_CONST
Bram Moolenaar76243bd2009-03-02 01:47:02 +00003245AC_C_VOLATILE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003246AC_TYPE_MODE_T
3247AC_TYPE_OFF_T
3248AC_TYPE_PID_T
3249AC_TYPE_SIZE_T
3250AC_TYPE_UID_T
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003251AC_TYPE_UINT32_T
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003252
Bram Moolenaar071d4272004-06-13 20:20:40 +00003253AC_HEADER_TIME
3254AC_CHECK_TYPE(ino_t, long)
3255AC_CHECK_TYPE(dev_t, unsigned)
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003256AC_C_BIGENDIAN(,,,)
Bram Moolenaar136f29a2016-02-27 20:14:15 +01003257AC_C_INLINE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003258
3259AC_MSG_CHECKING(for rlim_t)
3260if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
3261 AC_MSG_RESULT([(cached) $ac_cv_type_rlim_t])
3262else
3263 AC_EGREP_CPP(dnl
3264changequote(<<,>>)dnl
3265<<(^|[^a-zA-Z_0-9])rlim_t[^a-zA-Z_0-9]>>dnl
3266changequote([,]),
3267 [
3268#include <sys/types.h>
3269#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003270# include <stdlib.h>
3271# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003272#endif
3273#ifdef HAVE_SYS_RESOURCE_H
Bram Moolenaar446cb832008-06-24 21:56:24 +00003274# include <sys/resource.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003275#endif
3276 ], ac_cv_type_rlim_t=yes, ac_cv_type_rlim_t=no)
3277 AC_MSG_RESULT($ac_cv_type_rlim_t)
3278fi
3279if test $ac_cv_type_rlim_t = no; then
3280 cat >> confdefs.h <<\EOF
3281#define rlim_t unsigned long
3282EOF
3283fi
3284
3285AC_MSG_CHECKING(for stack_t)
3286if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then
3287 AC_MSG_RESULT([(cached) $ac_cv_type_stack_t])
3288else
3289 AC_EGREP_CPP(stack_t,
3290 [
3291#include <sys/types.h>
3292#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003293# include <stdlib.h>
3294# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003295#endif
3296#include <signal.h>
3297 ], ac_cv_type_stack_t=yes, ac_cv_type_stack_t=no)
3298 AC_MSG_RESULT($ac_cv_type_stack_t)
3299fi
3300if test $ac_cv_type_stack_t = no; then
3301 cat >> confdefs.h <<\EOF
3302#define stack_t struct sigaltstack
3303EOF
3304fi
3305
3306dnl BSDI uses ss_base while others use ss_sp for the stack pointer.
3307AC_MSG_CHECKING(whether stack_t has an ss_base field)
3308AC_TRY_COMPILE([
3309#include <sys/types.h>
3310#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003311# include <stdlib.h>
3312# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003313#endif
3314#include <signal.h>
3315#include "confdefs.h"
3316 ], [stack_t sigstk; sigstk.ss_base = 0; ],
3317 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SS_BASE),
3318 AC_MSG_RESULT(no))
3319
3320olibs="$LIBS"
3321AC_MSG_CHECKING(--with-tlib argument)
3322AC_ARG_WITH(tlib, [ --with-tlib=library terminal library to be used ],)
3323if test -n "$with_tlib"; then
3324 AC_MSG_RESULT($with_tlib)
3325 LIBS="$LIBS -l$with_tlib"
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003326 AC_MSG_CHECKING(for linking with $with_tlib library)
3327 AC_TRY_LINK([], [], AC_MSG_RESULT(OK), AC_MSG_ERROR(FAILED))
3328 dnl Need to check for tgetent() below.
3329 olibs="$LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003330else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003331 AC_MSG_RESULT([empty: automatic terminal library selection])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003332 dnl On HP-UX 10.10 termcap or termlib should be used instead of
3333 dnl curses, because curses is much slower.
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003334 dnl Newer versions of ncurses are preferred over anything, except
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02003335 dnl when tinfo has been split off, it contains all we need.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003336 dnl Older versions of ncurses have bugs, get a new one!
3337 dnl Digital Unix (OSF1) should use curses (Ronald Schild).
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00003338 dnl On SCO Openserver should prefer termlib (Roger Cornelius).
Bram Moolenaar071d4272004-06-13 20:20:40 +00003339 case "`uname -s 2>/dev/null`" in
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003340 OSF1|SCO_SV) tlibs="tinfo ncurses curses termlib termcap";;
3341 *) tlibs="tinfo ncurses termlib termcap curses";;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003342 esac
3343 for libname in $tlibs; do
3344 AC_CHECK_LIB(${libname}, tgetent,,)
3345 if test "x$olibs" != "x$LIBS"; then
3346 dnl It's possible that a library is found but it doesn't work
3347 dnl e.g., shared library that cannot be found
3348 dnl compile and run a test program to be sure
3349 AC_TRY_RUN([
3350#ifdef HAVE_TERMCAP_H
3351# include <termcap.h>
3352#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003353#if STDC_HEADERS
3354# include <stdlib.h>
3355# include <stddef.h>
3356#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003357main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }],
3358 res="OK", res="FAIL", res="FAIL")
3359 if test "$res" = "OK"; then
3360 break
3361 fi
3362 AC_MSG_RESULT($libname library is not usable)
3363 LIBS="$olibs"
3364 fi
3365 done
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003366 if test "x$olibs" = "x$LIBS"; then
3367 AC_MSG_RESULT(no terminal library found)
3368 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003369fi
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003370
3371if test "x$olibs" = "x$LIBS"; then
3372 AC_MSG_CHECKING([for tgetent()])
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00003373 AC_TRY_LINK([],
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003374 [char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");],
3375 AC_MSG_RESULT(yes),
3376 AC_MSG_ERROR([NOT FOUND!
3377 You need to install a terminal library; for example ncurses.
3378 Or specify the name of the library with --with-tlib.]))
3379fi
3380
Bram Moolenaar446cb832008-06-24 21:56:24 +00003381AC_CACHE_CHECK([whether we talk terminfo], [vim_cv_terminfo],
3382 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003383 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003384#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003385#ifdef HAVE_TERMCAP_H
3386# include <termcap.h>
3387#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003388#ifdef HAVE_STRING_H
3389# include <string.h>
3390#endif
3391#if STDC_HEADERS
3392# include <stdlib.h>
3393# include <stddef.h>
3394#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003395main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003396{char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003397 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003398 vim_cv_terminfo=no
3399 ],[
3400 vim_cv_terminfo=yes
3401 ],[
3402 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_terminfo')
3403 ])
3404 ])
3405
3406if test "x$vim_cv_terminfo" = "xyes" ; then
3407 AC_DEFINE(TERMINFO)
3408fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003409
Bram Moolenaara88254f2017-11-02 23:04:14 +01003410AC_CACHE_CHECK([what tgetent() returns for an unknown terminal], [vim_cv_tgetent],
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003411 [
3412 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003413#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003414#ifdef HAVE_TERMCAP_H
3415# include <termcap.h>
3416#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003417#if STDC_HEADERS
3418# include <stdlib.h>
3419# include <stddef.h>
3420#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003421main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003422{char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003423 ]])],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003424 vim_cv_tgetent=zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003425 ],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003426 vim_cv_tgetent=non-zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003427 ],[
3428 AC_MSG_ERROR(failed to compile test program.)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003429 ])
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003430 ])
3431
Bram Moolenaara88254f2017-11-02 23:04:14 +01003432if test "x$vim_cv_tgetent" = "xzero" ; then
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003433 AC_DEFINE(TGETENT_ZERO_ERR, 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003434fi
3435
3436AC_MSG_CHECKING(whether termcap.h contains ospeed)
3437AC_TRY_LINK([
3438#ifdef HAVE_TERMCAP_H
3439# include <termcap.h>
3440#endif
3441 ], [ospeed = 20000],
3442 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED),
3443 [AC_MSG_RESULT(no)
3444 AC_MSG_CHECKING(whether ospeed can be extern)
3445 AC_TRY_LINK([
3446#ifdef HAVE_TERMCAP_H
3447# include <termcap.h>
3448#endif
3449extern short ospeed;
3450 ], [ospeed = 20000],
3451 AC_MSG_RESULT(yes); AC_DEFINE(OSPEED_EXTERN),
3452 AC_MSG_RESULT(no))]
3453 )
3454
3455AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC])
3456AC_TRY_LINK([
3457#ifdef HAVE_TERMCAP_H
3458# include <termcap.h>
3459#endif
3460 ], [if (UP == 0 && BC == 0) PC = 1],
3461 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UP_BC_PC),
3462 [AC_MSG_RESULT(no)
3463 AC_MSG_CHECKING([whether UP, BC and PC can be extern])
3464 AC_TRY_LINK([
3465#ifdef HAVE_TERMCAP_H
3466# include <termcap.h>
3467#endif
3468extern char *UP, *BC, PC;
3469 ], [if (UP == 0 && BC == 0) PC = 1],
3470 AC_MSG_RESULT(yes); AC_DEFINE(UP_BC_PC_EXTERN),
3471 AC_MSG_RESULT(no))]
3472 )
3473
3474AC_MSG_CHECKING(whether tputs() uses outfuntype)
3475AC_TRY_COMPILE([
3476#ifdef HAVE_TERMCAP_H
3477# include <termcap.h>
3478#endif
3479 ], [extern int xx(); tputs("test", 1, (outfuntype)xx)],
3480 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OUTFUNTYPE),
3481 AC_MSG_RESULT(no))
3482
3483dnl On some SCO machines sys/select redefines struct timeval
3484AC_MSG_CHECKING([whether sys/select.h and sys/time.h may both be included])
3485AC_TRY_COMPILE([
3486#include <sys/types.h>
3487#include <sys/time.h>
3488#include <sys/select.h>], ,
3489 AC_MSG_RESULT(yes)
3490 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME),
3491 AC_MSG_RESULT(no))
3492
3493dnl AC_DECL_SYS_SIGLIST
3494
3495dnl Checks for pty.c (copied from screen) ==========================
3496AC_MSG_CHECKING(for /dev/ptc)
3497if test -r /dev/ptc; then
3498 AC_DEFINE(HAVE_DEV_PTC)
3499 AC_MSG_RESULT(yes)
3500else
3501 AC_MSG_RESULT(no)
3502fi
3503
3504AC_MSG_CHECKING(for SVR4 ptys)
3505if test -c /dev/ptmx ; then
3506 AC_TRY_LINK([], [ptsname(0);grantpt(0);unlockpt(0);],
3507 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SVR4_PTYS),
3508 AC_MSG_RESULT(no))
3509else
3510 AC_MSG_RESULT(no)
3511fi
3512
3513AC_MSG_CHECKING(for ptyranges)
3514if test -d /dev/ptym ; then
3515 pdir='/dev/ptym'
3516else
3517 pdir='/dev'
3518fi
3519dnl SCO uses ptyp%d
3520AC_EGREP_CPP(yes,
3521[#ifdef M_UNIX
3522 yes;
3523#endif
3524 ], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
3525dnl if test -c /dev/ptyp19; then
3526dnl ptys=`echo /dev/ptyp??`
3527dnl else
3528dnl ptys=`echo $pdir/pty??`
3529dnl fi
3530if test "$ptys" != "$pdir/pty??" ; then
3531 p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
3532 p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'`
3533 AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
3534 AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
3535 AC_MSG_RESULT([$p0 / $p1])
3536else
3537 AC_MSG_RESULT([don't know])
3538fi
3539
3540dnl **** pty mode/group handling ****
3541dnl
3542dnl support provided by Luke Mewburn <lm@rmit.edu.au>, 931222
Bram Moolenaar071d4272004-06-13 20:20:40 +00003543rm -f conftest_grp
Bram Moolenaar446cb832008-06-24 21:56:24 +00003544AC_CACHE_CHECK([default tty permissions/group], [vim_cv_tty_group],
3545 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003546 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003547#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003548#include <sys/types.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003549#if STDC_HEADERS
3550# include <stdlib.h>
3551# include <stddef.h>
3552#endif
3553#ifdef HAVE_UNISTD_H
3554#include <unistd.h>
3555#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003556#include <sys/stat.h>
3557#include <stdio.h>
3558main()
3559{
3560 struct stat sb;
3561 char *x,*ttyname();
3562 int om, m;
3563 FILE *fp;
3564
3565 if (!(x = ttyname(0))) exit(1);
3566 if (stat(x, &sb)) exit(1);
3567 om = sb.st_mode;
3568 if (om & 002) exit(0);
3569 m = system("mesg y");
3570 if (m == -1 || m == 127) exit(1);
3571 if (stat(x, &sb)) exit(1);
3572 m = sb.st_mode;
3573 if (chmod(x, om)) exit(1);
3574 if (m & 002) exit(0);
3575 if (sb.st_gid == getgid()) exit(1);
3576 if (!(fp=fopen("conftest_grp", "w")))
3577 exit(1);
3578 fprintf(fp, "%d\n", sb.st_gid);
3579 fclose(fp);
3580 exit(0);
3581}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003582 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003583 if test -f conftest_grp; then
3584 vim_cv_tty_group=`cat conftest_grp`
3585 if test "x$vim_cv_tty_mode" = "x" ; then
3586 vim_cv_tty_mode=0620
3587 fi
3588 AC_MSG_RESULT([pty mode: $vim_cv_tty_mode, group: $vim_cv_tty_group])
3589 else
3590 vim_cv_tty_group=world
Bram Moolenaar72951072009-12-02 16:58:33 +00003591 AC_MSG_RESULT([ptys are world accessible])
Bram Moolenaar446cb832008-06-24 21:56:24 +00003592 fi
3593 ],[
3594 vim_cv_tty_group=world
Bram Moolenaar72951072009-12-02 16:58:33 +00003595 AC_MSG_RESULT([can't determine - assume ptys are world accessible])
Bram Moolenaar446cb832008-06-24 21:56:24 +00003596 ],[
3597 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_tty_group' and 'vim_cv_tty_mode')
3598 ])
3599 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003600rm -f conftest_grp
3601
Bram Moolenaar446cb832008-06-24 21:56:24 +00003602if test "x$vim_cv_tty_group" != "xworld" ; then
3603 AC_DEFINE_UNQUOTED(PTYGROUP,$vim_cv_tty_group)
3604 if test "x$vim_cv_tty_mode" = "x" ; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02003605 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 (probably 0620)])
Bram Moolenaar446cb832008-06-24 21:56:24 +00003606 else
3607 AC_DEFINE(PTYMODE, 0620)
3608 fi
3609fi
3610
Bram Moolenaar071d4272004-06-13 20:20:40 +00003611dnl Checks for library functions. ===================================
3612
3613AC_TYPE_SIGNAL
3614
3615dnl find out what to use at the end of a signal function
3616if test $ac_cv_type_signal = void; then
3617 AC_DEFINE(SIGRETURN, [return])
3618else
3619 AC_DEFINE(SIGRETURN, [return 0])
3620fi
3621
3622dnl check if struct sigcontext is defined (used for SGI only)
3623AC_MSG_CHECKING(for struct sigcontext)
3624AC_TRY_COMPILE([
3625#include <signal.h>
3626test_sig()
3627{
3628 struct sigcontext *scont;
3629 scont = (struct sigcontext *)0;
3630 return 1;
3631} ], ,
3632 AC_MSG_RESULT(yes)
3633 AC_DEFINE(HAVE_SIGCONTEXT),
3634 AC_MSG_RESULT(no))
3635
3636dnl tricky stuff: try to find out if getcwd() is implemented with
3637dnl system("sh -c pwd")
Bram Moolenaar446cb832008-06-24 21:56:24 +00003638AC_CACHE_CHECK([getcwd implementation is broken], [vim_cv_getcwd_broken],
3639 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003640 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003641#include "confdefs.h"
3642#ifdef HAVE_UNISTD_H
3643#include <unistd.h>
3644#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003645char *dagger[] = { "IFS=pwd", 0 };
3646main()
3647{
3648 char buffer[500];
3649 extern char **environ;
3650 environ = dagger;
3651 return getcwd(buffer, 500) ? 0 : 1;
Bram Moolenaar446cb832008-06-24 21:56:24 +00003652}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003653 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003654 vim_cv_getcwd_broken=no
3655 ],[
3656 vim_cv_getcwd_broken=yes
3657 ],[
3658 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_getcwd_broken')
3659 ])
3660 ])
3661
3662if test "x$vim_cv_getcwd_broken" = "xyes" ; then
3663 AC_DEFINE(BAD_GETCWD)
3664fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003665
Bram Moolenaar25153e12010-02-24 14:47:08 +01003666dnl Check for functions in one big call, to reduce the size of configure.
3667dnl Can only be used for functions that do not require any include.
Bram Moolenaarcd142e32017-11-16 17:03:45 +01003668AC_CHECK_FUNCS(fchdir fchown fchmod fsync getcwd getpseudotty \
Bram Moolenaarb129a442016-12-01 17:25:20 +01003669 getpwent getpwnam getpwuid getrlimit gettimeofday getwd lstat \
Bram Moolenaareaf03392009-11-17 11:08:52 +00003670 memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
Bram Moolenaar2fcf6682017-03-11 20:03:42 +01003671 getpgid setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
Bram Moolenaarbb09ceb2016-10-18 16:27:23 +02003672 sigprocmask sigvec strcasecmp strerror strftime stricmp strncasecmp \
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00003673 strnicmp strpbrk strtol tgetent towlower towupper iswupper \
Bram Moolenaarcd142e32017-11-16 17:03:45 +01003674 usleep utime utimes mblen ftruncate)
Bram Moolenaar25153e12010-02-24 14:47:08 +01003675AC_FUNC_FSEEKO
Bram Moolenaar071d4272004-06-13 20:20:40 +00003676
Bram Moolenaar317fd3a2010-05-07 16:05:55 +02003677dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when
3678dnl appropriate, so that off_t is 64 bits when needed.
3679AC_SYS_LARGEFILE
3680
Bram Moolenaar071d4272004-06-13 20:20:40 +00003681dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible
3682AC_MSG_CHECKING(for st_blksize)
3683AC_TRY_COMPILE(
3684[#include <sys/types.h>
3685#include <sys/stat.h>],
3686[ struct stat st;
3687 int n;
3688
3689 stat("/", &st);
3690 n = (int)st.st_blksize;],
3691 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ST_BLKSIZE),
3692 AC_MSG_RESULT(no))
3693
Bram Moolenaar446cb832008-06-24 21:56:24 +00003694AC_CACHE_CHECK([whether stat() ignores a trailing slash], [vim_cv_stat_ignores_slash],
3695 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003696 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003697#include "confdefs.h"
3698#if STDC_HEADERS
3699# include <stdlib.h>
3700# include <stddef.h>
3701#endif
3702#include <sys/types.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003703#include <sys/stat.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003704main() {struct stat st; exit(stat("configure/", &st) != 0); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003705 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003706 vim_cv_stat_ignores_slash=yes
3707 ],[
3708 vim_cv_stat_ignores_slash=no
3709 ],[
3710 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_stat_ignores_slash')
3711 ])
3712 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003713
Bram Moolenaar446cb832008-06-24 21:56:24 +00003714if test "x$vim_cv_stat_ignores_slash" = "xyes" ; then
3715 AC_DEFINE(STAT_IGNORES_SLASH)
3716fi
3717
Bram Moolenaar071d4272004-06-13 20:20:40 +00003718dnl Link with iconv for charset translation, if not found without library.
3719dnl check for iconv() requires including iconv.h
3720dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
3721dnl has been installed.
3722AC_MSG_CHECKING(for iconv_open())
3723save_LIBS="$LIBS"
3724LIBS="$LIBS -liconv"
3725AC_TRY_LINK([
3726#ifdef HAVE_ICONV_H
3727# include <iconv.h>
3728#endif
3729 ], [iconv_open("fr", "to");],
3730 AC_MSG_RESULT(yes; with -liconv); AC_DEFINE(HAVE_ICONV),
3731 LIBS="$save_LIBS"
3732 AC_TRY_LINK([
3733#ifdef HAVE_ICONV_H
3734# include <iconv.h>
3735#endif
3736 ], [iconv_open("fr", "to");],
3737 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ICONV),
3738 AC_MSG_RESULT(no)))
3739
3740
3741AC_MSG_CHECKING(for nl_langinfo(CODESET))
3742AC_TRY_LINK([
3743#ifdef HAVE_LANGINFO_H
3744# include <langinfo.h>
3745#endif
3746], [char *cs = nl_langinfo(CODESET);],
3747 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET),
3748 AC_MSG_RESULT(no))
3749
Bram Moolenaar446cb832008-06-24 21:56:24 +00003750dnl Need various functions for floating point support. Only enable
3751dnl floating point when they are all present.
3752AC_CHECK_LIB(m, strtod)
3753AC_MSG_CHECKING([for strtod() and other floating point functions])
3754AC_TRY_LINK([
3755#ifdef HAVE_MATH_H
3756# include <math.h>
3757#endif
3758#if STDC_HEADERS
3759# include <stdlib.h>
3760# include <stddef.h>
3761#endif
3762], [char *s; double d;
3763 d = strtod("1.1", &s);
3764 d = fabs(1.11);
3765 d = ceil(1.11);
3766 d = floor(1.11);
3767 d = log10(1.11);
3768 d = pow(1.11, 2.22);
3769 d = sqrt(1.11);
3770 d = sin(1.11);
3771 d = cos(1.11);
3772 d = atan(1.11);
3773 ],
3774 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT_FUNCS),
3775 AC_MSG_RESULT(no))
3776
Bram Moolenaara6b89762016-02-29 21:38:26 +01003777dnl isinf() and isnan() need to include header files and may need -lm.
3778AC_MSG_CHECKING([for isinf()])
3779AC_TRY_LINK([
3780#ifdef HAVE_MATH_H
3781# include <math.h>
3782#endif
3783#if STDC_HEADERS
3784# include <stdlib.h>
3785# include <stddef.h>
3786#endif
3787], [int r = isinf(1.11); ],
3788 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISINF),
3789 AC_MSG_RESULT(no))
3790
3791AC_MSG_CHECKING([for isnan()])
3792AC_TRY_LINK([
3793#ifdef HAVE_MATH_H
3794# include <math.h>
3795#endif
3796#if STDC_HEADERS
3797# include <stdlib.h>
3798# include <stddef.h>
3799#endif
3800], [int r = isnan(1.11); ],
3801 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISNAN),
3802 AC_MSG_RESULT(no))
3803
Bram Moolenaar071d4272004-06-13 20:20:40 +00003804dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI
3805dnl when -lacl works, also try to use -lattr (required for Debian).
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003806dnl On Solaris, use the acl_get/set functions in libsec, if present.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003807AC_MSG_CHECKING(--disable-acl argument)
3808AC_ARG_ENABLE(acl,
Bram Moolenaard6d30422018-01-28 22:48:55 +01003809 [ --disable-acl No check for ACL support.],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003810 , [enable_acl="yes"])
3811if test "$enable_acl" = "yes"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01003812 AC_MSG_RESULT(no)
3813 AC_CHECK_LIB(posix1e, acl_get_file, [LIBS="$LIBS -lposix1e"],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003814 AC_CHECK_LIB(acl, acl_get_file, [LIBS="$LIBS -lacl"
3815 AC_CHECK_LIB(attr, fgetxattr, LIBS="$LIBS -lattr",,)],,),)
3816
Bram Moolenaard6d30422018-01-28 22:48:55 +01003817 AC_MSG_CHECKING(for POSIX ACL support)
3818 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003819#include <sys/types.h>
3820#ifdef HAVE_SYS_ACL_H
3821# include <sys/acl.h>
3822#endif
3823acl_t acl;], [acl = acl_get_file("foo", ACL_TYPE_ACCESS);
3824 acl_set_file("foo", ACL_TYPE_ACCESS, acl);
3825 acl_free(acl);],
3826 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_ACL),
3827 AC_MSG_RESULT(no))
3828
Bram Moolenaard6d30422018-01-28 22:48:55 +01003829 AC_CHECK_LIB(sec, acl_get, [LIBS="$LIBS -lsec"; AC_DEFINE(HAVE_SOLARIS_ZFS_ACL)],
3830 AC_MSG_CHECKING(for Solaris ACL support)
3831 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003832#ifdef HAVE_SYS_ACL_H
3833# include <sys/acl.h>
3834#endif], [acl("foo", GETACLCNT, 0, NULL);
3835 ],
3836 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOLARIS_ACL),
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003837 AC_MSG_RESULT(no)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003838
Bram Moolenaard6d30422018-01-28 22:48:55 +01003839 AC_MSG_CHECKING(for AIX ACL support)
3840 AC_TRY_LINK([
Bram Moolenaar446cb832008-06-24 21:56:24 +00003841#if STDC_HEADERS
3842# include <stdlib.h>
3843# include <stddef.h>
3844#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003845#ifdef HAVE_SYS_ACL_H
3846# include <sys/acl.h>
3847#endif
3848#ifdef HAVE_SYS_ACCESS_H
3849# include <sys/access.h>
3850#endif
3851#define _ALL_SOURCE
3852
3853#include <sys/stat.h>
3854
3855int aclsize;
3856struct acl *aclent;], [aclsize = sizeof(struct acl);
3857 aclent = (void *)malloc(aclsize);
3858 statacl("foo", STX_NORMAL, aclent, aclsize);
3859 ],
3860 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_AIX_ACL),
3861 AC_MSG_RESULT(no))
3862else
3863 AC_MSG_RESULT(yes)
3864fi
3865
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02003866if test "x$GTK_CFLAGS" != "x"; then
3867 dnl pango_shape_full() is new, fall back to pango_shape().
3868 AC_MSG_CHECKING(for pango_shape_full)
3869 ac_save_CFLAGS="$CFLAGS"
3870 ac_save_LIBS="$LIBS"
3871 CFLAGS="$CFLAGS $GTK_CFLAGS"
3872 LIBS="$LIBS $GTK_LIBS"
Bram Moolenaar5325b9b2015-09-09 20:27:02 +02003873 AC_TRY_LINK(
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02003874 [#include <gtk/gtk.h>],
3875 [ pango_shape_full(NULL, 0, NULL, 0, NULL, NULL); ],
3876 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_PANGO_SHAPE_FULL),
3877 AC_MSG_RESULT(no))
3878 CFLAGS="$ac_save_CFLAGS"
3879 LIBS="$ac_save_LIBS"
3880fi
3881
Bram Moolenaar071d4272004-06-13 20:20:40 +00003882AC_MSG_CHECKING(--disable-gpm argument)
3883AC_ARG_ENABLE(gpm,
3884 [ --disable-gpm Don't use gpm (Linux mouse daemon).], ,
3885 [enable_gpm="yes"])
3886
3887if test "$enable_gpm" = "yes"; then
3888 AC_MSG_RESULT(no)
3889 dnl Checking if gpm support can be compiled
3890 AC_CACHE_CHECK([for gpm], vi_cv_have_gpm,
3891 [olibs="$LIBS" ; LIBS="-lgpm"]
3892 AC_TRY_LINK(
3893 [#include <gpm.h>
3894 #include <linux/keyboard.h>],
3895 [Gpm_GetLibVersion(NULL);],
3896 dnl Configure defines HAVE_GPM, if it is defined feature.h defines
3897 dnl FEAT_MOUSE_GPM if mouse support is included
3898 [vi_cv_have_gpm=yes],
3899 [vi_cv_have_gpm=no])
3900 [LIBS="$olibs"]
3901 )
3902 if test $vi_cv_have_gpm = yes; then
3903 LIBS="$LIBS -lgpm"
3904 AC_DEFINE(HAVE_GPM)
3905 fi
3906else
3907 AC_MSG_RESULT(yes)
3908fi
3909
Bram Moolenaar446cb832008-06-24 21:56:24 +00003910AC_MSG_CHECKING(--disable-sysmouse argument)
3911AC_ARG_ENABLE(sysmouse,
Bram Moolenaar8008b632017-07-18 21:33:20 +02003912 [ --disable-sysmouse Don't use sysmouse (mouse in *BSD console).], ,
Bram Moolenaar446cb832008-06-24 21:56:24 +00003913 [enable_sysmouse="yes"])
3914
3915if test "$enable_sysmouse" = "yes"; then
3916 AC_MSG_RESULT(no)
3917 dnl Checking if sysmouse support can be compiled
3918 dnl Configure defines HAVE_SYSMOUSE, if it is defined feature.h
3919 dnl defines FEAT_SYSMOUSE if mouse support is included
3920 AC_CACHE_CHECK([for sysmouse], vi_cv_have_sysmouse,
3921 AC_TRY_LINK(
3922 [#include <sys/consio.h>
3923 #include <signal.h>
3924 #include <sys/fbio.h>],
3925 [struct mouse_info mouse;
3926 mouse.operation = MOUSE_MODE;
3927 mouse.operation = MOUSE_SHOW;
3928 mouse.u.mode.mode = 0;
3929 mouse.u.mode.signal = SIGUSR2;],
3930 [vi_cv_have_sysmouse=yes],
3931 [vi_cv_have_sysmouse=no])
3932 )
3933 if test $vi_cv_have_sysmouse = yes; then
3934 AC_DEFINE(HAVE_SYSMOUSE)
3935 fi
3936else
3937 AC_MSG_RESULT(yes)
3938fi
3939
Bram Moolenaarf05da212009-11-17 16:13:15 +00003940dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
3941AC_MSG_CHECKING(for FD_CLOEXEC)
3942AC_TRY_COMPILE(
3943[#if HAVE_FCNTL_H
3944# include <fcntl.h>
3945#endif],
3946[ int flag = FD_CLOEXEC;],
3947 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
3948 AC_MSG_RESULT(not usable))
3949
Bram Moolenaar071d4272004-06-13 20:20:40 +00003950dnl rename needs to be checked separately to work on Nextstep with cc
3951AC_MSG_CHECKING(for rename)
3952AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
3953 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
3954 AC_MSG_RESULT(no))
3955
3956dnl sysctl() may exist but not the arguments we use
3957AC_MSG_CHECKING(for sysctl)
3958AC_TRY_COMPILE(
3959[#include <sys/types.h>
3960#include <sys/sysctl.h>],
3961[ int mib[2], r;
3962 size_t len;
3963
3964 mib[0] = CTL_HW;
3965 mib[1] = HW_USERMEM;
3966 len = sizeof(r);
3967 (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
3968 ],
3969 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL),
3970 AC_MSG_RESULT(not usable))
3971
3972dnl sysinfo() may exist but not be Linux compatible
3973AC_MSG_CHECKING(for sysinfo)
3974AC_TRY_COMPILE(
3975[#include <sys/types.h>
3976#include <sys/sysinfo.h>],
3977[ struct sysinfo sinfo;
3978 int t;
3979
3980 (void)sysinfo(&sinfo);
3981 t = sinfo.totalram;
3982 ],
3983 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
3984 AC_MSG_RESULT(not usable))
3985
Bram Moolenaar914572a2007-05-01 11:37:47 +00003986dnl struct sysinfo may have the mem_unit field or not
3987AC_MSG_CHECKING(for sysinfo.mem_unit)
3988AC_TRY_COMPILE(
3989[#include <sys/types.h>
3990#include <sys/sysinfo.h>],
3991[ struct sysinfo sinfo;
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02003992 sinfo.mem_unit = 1;
Bram Moolenaar914572a2007-05-01 11:37:47 +00003993 ],
3994 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_MEM_UNIT),
3995 AC_MSG_RESULT(no))
3996
Bram Moolenaar071d4272004-06-13 20:20:40 +00003997dnl sysconf() may exist but not support what we want to use
3998AC_MSG_CHECKING(for sysconf)
3999AC_TRY_COMPILE(
4000[#include <unistd.h>],
4001[ (void)sysconf(_SC_PAGESIZE);
4002 (void)sysconf(_SC_PHYS_PAGES);
4003 ],
4004 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
4005 AC_MSG_RESULT(not usable))
4006
Bram Moolenaar914703b2010-05-31 21:59:46 +02004007AC_CHECK_SIZEOF([int])
4008AC_CHECK_SIZEOF([long])
4009AC_CHECK_SIZEOF([time_t])
4010AC_CHECK_SIZEOF([off_t])
Bram Moolenaar644fdff2010-05-30 13:26:21 +02004011
Bram Moolenaara2aa31a2014-02-23 22:52:40 +01004012dnl Use different names to avoid clashing with other header files.
4013AC_DEFINE_UNQUOTED(VIM_SIZEOF_INT, [$ac_cv_sizeof_int])
4014AC_DEFINE_UNQUOTED(VIM_SIZEOF_LONG, [$ac_cv_sizeof_long])
4015
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004016dnl Make sure that uint32_t is really 32 bits unsigned.
4017AC_MSG_CHECKING([uint32_t is 32 bits])
4018AC_TRY_RUN([
4019#ifdef HAVE_STDINT_H
4020# include <stdint.h>
4021#endif
4022#ifdef HAVE_INTTYPES_H
4023# include <inttypes.h>
4024#endif
4025main() {
4026 uint32_t nr1 = (uint32_t)-1;
4027 uint32_t nr2 = (uint32_t)0xffffffffUL;
4028 if (sizeof(uint32_t) != 4 || nr1 != 0xffffffffUL || nr2 + 1 != 0) exit(1);
4029 exit(0);
4030}],
4031AC_MSG_RESULT(ok),
4032AC_MSG_ERROR([WRONG! uint32_t not defined correctly.]),
Bram Moolenaar323cb952011-12-14 19:22:34 +01004033AC_MSG_WARN([cannot check uint32_t when cross-compiling.]))
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004034
Bram Moolenaar446cb832008-06-24 21:56:24 +00004035dnl Check for memmove() before bcopy(), makes memmove() be used when both are
4036dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
4037
Bram Moolenaar071d4272004-06-13 20:20:40 +00004038[bcopy_test_prog='
Bram Moolenaar446cb832008-06-24 21:56:24 +00004039#include "confdefs.h"
4040#ifdef HAVE_STRING_H
4041# include <string.h>
4042#endif
4043#if STDC_HEADERS
4044# include <stdlib.h>
4045# include <stddef.h>
4046#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004047main() {
4048 char buf[10];
4049 strcpy(buf, "abcdefghi");
4050 mch_memmove(buf, buf + 2, 3);
4051 if (strncmp(buf, "ababcf", 6))
4052 exit(1);
4053 strcpy(buf, "abcdefghi");
4054 mch_memmove(buf + 2, buf, 3);
4055 if (strncmp(buf, "cdedef", 6))
4056 exit(1);
4057 exit(0); /* libc version works properly. */
4058}']
4059
Bram Moolenaar446cb832008-06-24 21:56:24 +00004060AC_CACHE_CHECK([whether memmove handles overlaps],[vim_cv_memmove_handles_overlap],
4061 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004062 AC_RUN_IFELSE([AC_LANG_SOURCE([[#define mch_memmove(s,d,l) memmove(d,s,l) $bcopy_test_prog]])],
Bram Moolenaar446cb832008-06-24 21:56:24 +00004063 [
4064 vim_cv_memmove_handles_overlap=yes
4065 ],[
4066 vim_cv_memmove_handles_overlap=no
4067 ],[
4068 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memmove_handles_overlap')
4069 ])
4070 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00004071
Bram Moolenaar446cb832008-06-24 21:56:24 +00004072if test "x$vim_cv_memmove_handles_overlap" = "xyes" ; then
4073 AC_DEFINE(USEMEMMOVE)
4074else
4075 AC_CACHE_CHECK([whether bcopy handles overlaps],[vim_cv_bcopy_handles_overlap],
4076 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004077 AC_RUN_IFELSE([AC_LANG_SOURCE([[#define mch_bcopy(s,d,l) bcopy(d,s,l) $bcopy_test_prog]])],
Bram Moolenaar446cb832008-06-24 21:56:24 +00004078 [
4079 vim_cv_bcopy_handles_overlap=yes
4080 ],[
4081 vim_cv_bcopy_handles_overlap=no
4082 ],[
4083 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_bcopy_handles_overlap')
4084 ])
4085 ])
4086
4087 if test "x$vim_cv_bcopy_handles_overlap" = "xyes" ; then
4088 AC_DEFINE(USEBCOPY)
4089 else
4090 AC_CACHE_CHECK([whether memcpy handles overlaps],[vim_cv_memcpy_handles_overlap],
4091 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004092 AC_RUN_IFELSE([AC_LANG_SOURCE([[#define mch_memcpy(s,d,l) memcpy(d,s,l) $bcopy_test_prog]])],
Bram Moolenaar446cb832008-06-24 21:56:24 +00004093 [
4094 vim_cv_memcpy_handles_overlap=yes
4095 ],[
4096 vim_cv_memcpy_handles_overlap=no
4097 ],[
4098 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memcpy_handles_overlap')
4099 ])
4100 ])
4101
4102 if test "x$vim_cv_memcpy_handles_overlap" = "xyes" ; then
4103 AC_DEFINE(USEMEMCPY)
4104 fi
4105 fi
4106fi
4107
Bram Moolenaar071d4272004-06-13 20:20:40 +00004108
4109dnl Check for multibyte locale functions
4110dnl Find out if _Xsetlocale() is supported by libX11.
4111dnl Check if X_LOCALE should be defined.
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004112if test "x$with_x" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004113 cflags_save=$CFLAGS
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004114 libs_save=$LIBS
4115 LIBS="$LIBS $X_LIBS $GUI_LIB_LOC $GUI_X_LIBS $X_PRE_LIBS $X_LIB $X_EXTRA_LIBS"
4116 CFLAGS="$CFLAGS $X_CFLAGS"
4117
4118 AC_MSG_CHECKING(whether X_LOCALE needed)
4119 AC_TRY_COMPILE([#include <X11/Xlocale.h>],,
4120 AC_TRY_LINK_FUNC([_Xsetlocale], [AC_MSG_RESULT(yes)
4121 AC_DEFINE(X_LOCALE)], AC_MSG_RESULT(no)),
4122 AC_MSG_RESULT(no))
4123
4124 AC_MSG_CHECKING(whether Xutf8SetWMProperties() can be used)
4125 AC_TRY_LINK_FUNC([Xutf8SetWMProperties], [AC_MSG_RESULT(yes)
4126 AC_DEFINE(HAVE_XUTF8SETWMPROPERTIES)], AC_MSG_RESULT(no))
4127
Bram Moolenaar071d4272004-06-13 20:20:40 +00004128 CFLAGS=$cflags_save
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004129 LIBS=$libs_save
Bram Moolenaar071d4272004-06-13 20:20:40 +00004130fi
4131
4132dnl Link with xpg4, it is said to make Korean locale working
4133AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,)
4134
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004135dnl Check how we can run ctags. Default to "ctags" when nothing works.
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02004136dnl Use --version to detect Exuberant ctags (preferred)
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004137dnl Add --fields=+S to get function signatures for omni completion.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004138dnl -t for typedefs (many ctags have this)
4139dnl -s for static functions (Elvis ctags only?)
4140dnl -v for variables. Dangerous, most ctags take this for 'vgrind style'.
4141dnl -i+m to test for older Exuberant ctags
4142AC_MSG_CHECKING(how to create tags)
4143test -f tags && mv tags tags.save
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004144if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004145 TAGPRG="ctags -I INIT+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004146elif (eval exctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
4147 TAGPRG="exctags -I INIT+ --fields=+S"
4148elif (eval exuberant-ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
4149 TAGPRG="exuberant-ctags -I INIT+ --fields=+S"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004150else
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004151 TAGPRG="ctags"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004152 (eval etags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags"
4153 (eval etags -c /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags -c"
4154 (eval ctags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags"
4155 (eval ctags -t /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -t"
4156 (eval ctags -ts /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -ts"
4157 (eval ctags -tvs /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -tvs"
4158 (eval ctags -i+m /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -i+m"
4159fi
4160test -f tags.save && mv tags.save tags
4161AC_MSG_RESULT($TAGPRG) AC_SUBST(TAGPRG)
4162
4163dnl Check how we can run man with a section number
4164AC_MSG_CHECKING(how to run man with a section nr)
4165MANDEF="man"
Bram Moolenaar8b131502008-02-13 09:28:19 +00004166(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 +00004167AC_MSG_RESULT($MANDEF)
4168if test "$MANDEF" = "man -s"; then
4169 AC_DEFINE(USEMAN_S)
4170fi
4171
4172dnl Check if gettext() is working and if it needs -lintl
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004173dnl We take care to base this on an empty LIBS: on some systems libelf would be
4174dnl in LIBS and implicitly take along libintl. The final LIBS would then not
4175dnl contain libintl, and the link step would fail due to -Wl,--as-needed.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004176AC_MSG_CHECKING(--disable-nls argument)
4177AC_ARG_ENABLE(nls,
4178 [ --disable-nls Don't support NLS (gettext()).], ,
4179 [enable_nls="yes"])
4180
4181if test "$enable_nls" = "yes"; then
4182 AC_MSG_RESULT(no)
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00004183
4184 INSTALL_LANGS=install-languages
4185 AC_SUBST(INSTALL_LANGS)
4186 INSTALL_TOOL_LANGS=install-tool-languages
4187 AC_SUBST(INSTALL_TOOL_LANGS)
4188
Bram Moolenaar071d4272004-06-13 20:20:40 +00004189 AC_CHECK_PROG(MSGFMT, msgfmt, msgfmt, )
4190 AC_MSG_CHECKING([for NLS])
4191 if test -f po/Makefile; then
4192 have_gettext="no"
4193 if test -n "$MSGFMT"; then
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004194 olibs=$LIBS
4195 LIBS=""
Bram Moolenaar071d4272004-06-13 20:20:40 +00004196 AC_TRY_LINK(
4197 [#include <libintl.h>],
4198 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004199 AC_MSG_RESULT([gettext() works]); have_gettext="yes"; LIBS=$olibs,
4200 LIBS="-lintl"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004201 AC_TRY_LINK(
4202 [#include <libintl.h>],
4203 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004204 AC_MSG_RESULT([gettext() works with -lintl]); have_gettext="yes";
4205 LIBS="$olibs -lintl",
Bram Moolenaar071d4272004-06-13 20:20:40 +00004206 AC_MSG_RESULT([gettext() doesn't work]);
4207 LIBS=$olibs))
4208 else
4209 AC_MSG_RESULT([msgfmt not found - disabled]);
4210 fi
Bram Moolenaar278eb582014-07-30 13:22:52 +02004211 if test $have_gettext = "yes" -a "x$features" != "xtiny" -a "x$features" != "xsmall"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004212 AC_DEFINE(HAVE_GETTEXT)
4213 MAKEMO=yes
4214 AC_SUBST(MAKEMO)
4215 dnl this was added in GNU gettext 0.10.36
4216 AC_CHECK_FUNCS(bind_textdomain_codeset)
4217 dnl _nl_msg_cat_cntr is required for GNU gettext
4218 AC_MSG_CHECKING([for _nl_msg_cat_cntr])
4219 AC_TRY_LINK(
4220 [#include <libintl.h>
4221 extern int _nl_msg_cat_cntr;],
4222 [++_nl_msg_cat_cntr;],
4223 AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_NL_MSG_CAT_CNTR),
4224 AC_MSG_RESULT([no]))
4225 fi
4226 else
4227 AC_MSG_RESULT([no "po/Makefile" - disabled]);
4228 fi
4229else
4230 AC_MSG_RESULT(yes)
4231fi
4232
4233dnl Check for dynamic linking loader
4234AC_CHECK_HEADER(dlfcn.h, DLL=dlfcn.h, [AC_CHECK_HEADER(dl.h, DLL=dl.h)])
4235if test x${DLL} = xdlfcn.h; then
4236 AC_DEFINE(HAVE_DLFCN_H, 1, [ Define if we have dlfcn.h. ])
4237 AC_MSG_CHECKING([for dlopen()])
4238 AC_TRY_LINK(,[
4239 extern void* dlopen();
4240 dlopen();
4241 ],
4242 AC_MSG_RESULT(yes);
4243 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4244 AC_MSG_RESULT(no);
4245 AC_MSG_CHECKING([for dlopen() in -ldl])
4246 olibs=$LIBS
4247 LIBS="$LIBS -ldl"
4248 AC_TRY_LINK(,[
4249 extern void* dlopen();
4250 dlopen();
4251 ],
4252 AC_MSG_RESULT(yes);
4253 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4254 AC_MSG_RESULT(no);
4255 LIBS=$olibs))
4256 dnl ReliantUNIX has dlopen() in libc but everything else in libdl
4257 dnl ick :-)
4258 AC_MSG_CHECKING([for dlsym()])
4259 AC_TRY_LINK(,[
4260 extern void* dlsym();
4261 dlsym();
4262 ],
4263 AC_MSG_RESULT(yes);
4264 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4265 AC_MSG_RESULT(no);
4266 AC_MSG_CHECKING([for dlsym() in -ldl])
4267 olibs=$LIBS
4268 LIBS="$LIBS -ldl"
4269 AC_TRY_LINK(,[
4270 extern void* dlsym();
4271 dlsym();
4272 ],
4273 AC_MSG_RESULT(yes);
4274 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4275 AC_MSG_RESULT(no);
4276 LIBS=$olibs))
4277elif test x${DLL} = xdl.h; then
4278 AC_DEFINE(HAVE_DL_H, 1, [ Define if we have dl.h. ])
4279 AC_MSG_CHECKING([for shl_load()])
4280 AC_TRY_LINK(,[
4281 extern void* shl_load();
4282 shl_load();
4283 ],
4284 AC_MSG_RESULT(yes);
4285 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4286 AC_MSG_RESULT(no);
4287 AC_MSG_CHECKING([for shl_load() in -ldld])
4288 olibs=$LIBS
4289 LIBS="$LIBS -ldld"
4290 AC_TRY_LINK(,[
4291 extern void* shl_load();
4292 shl_load();
4293 ],
4294 AC_MSG_RESULT(yes);
4295 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4296 AC_MSG_RESULT(no);
4297 LIBS=$olibs))
4298fi
4299AC_CHECK_HEADERS(setjmp.h)
4300
Bram Moolenaard0573012017-10-28 21:11:06 +02004301if test "x$MACOS_X" = "xyes" -a -n "$PERL"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004302 dnl -ldl must come after DynaLoader.a
4303 if echo $LIBS | grep -e '-ldl' >/dev/null; then
4304 LIBS=`echo $LIBS | sed s/-ldl//`
4305 PERL_LIBS="$PERL_LIBS -ldl"
4306 fi
4307fi
4308
Bram Moolenaard0573012017-10-28 21:11:06 +02004309if test "$MACOS_X" = "yes"; then
4310 AC_MSG_CHECKING([whether we need macOS frameworks])
4311 if test "$GUITYPE" = "CARBONGUI"; then
4312 AC_MSG_RESULT([yes, we need Carbon])
4313 LIBS="$LIBS -framework Carbon"
4314 elif test "$MACOS_X_DARWIN" = "yes"; then
4315 if test "$features" = "tiny"; then
4316 dnl Since no FEAT_CLIPBOARD, no longer need for os_macosx.m.
4317 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_macosx.m++'`
4318 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_macosx.o++'`
4319 if test "$enable_multibyte" = "yes"; then
4320 AC_MSG_RESULT([yes, we need CoreServices])
4321 LIBS="$LIBS -framework CoreServices"
4322 else
4323 dnl Since no FEAT_MBYTE, no longer need for os_mac_conv.c.
4324 AC_MSG_RESULT([no])
4325 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_mac_conv.c++'`
4326 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_mac_conv.o++'`
4327 CPPFLAGS=`echo "$CPPFLAGS" | sed -e 's+-DMACOS_X_DARWIN++'`
4328 fi
4329 else
4330 AC_MSG_RESULT([yes, we need AppKit])
4331 LIBS="$LIBS -framework AppKit"
4332 if test "$features" = "small" -a "$enable_multibyte" = "no"; then
4333 dnl Since FEAT_CLIPBOARD is to be defined in vim.h for FEAT_SMALL, define
4334 dnl FEAT_MBYTE in order not to compromise the interoperability of the
4335 dnl clipboard.
4336 AC_MSG_NOTICE([+multi_byte will be set in favor of +clipboard])
4337 enable_multibyte=yes
4338 AC_DEFINE(FEAT_MBYTE)
4339 fi
4340 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004341 else
Bram Moolenaard0573012017-10-28 21:11:06 +02004342 AC_MSG_RESULT([no])
Bram Moolenaar3437b912013-07-03 19:52:53 +02004343 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004344fi
Bram Moolenaar164fca32010-07-14 13:58:07 +02004345if test "x$MACARCH" = "xboth" && test "x$GUITYPE" = "xCARBONGUI"; then
Bram Moolenaar595a7be2010-03-10 16:28:12 +01004346 LDFLAGS="$LDFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +00004347fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004348
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004349dnl gcc 3.1 changed the meaning of -MM. The only solution appears to be to
4350dnl use "-isystem" instead of "-I" for all non-Vim include dirs.
4351dnl But only when making dependencies, cproto and lint don't take "-isystem".
Bram Moolenaar32466aa2006-02-24 23:53:04 +00004352dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
4353dnl the number before the version number.
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004354DEPEND_CFLAGS_FILTER=
4355if test "$GCC" = yes; then
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004356 AC_MSG_CHECKING(for GCC 3 or later)
Bram Moolenaar2217cae2006-03-25 21:55:52 +00004357 gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]]\)\..*$/\1/g'`
Bram Moolenaarf740b292006-02-16 22:11:02 +00004358 if test "$gccmajor" -gt "2"; then
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004359 DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004360 AC_MSG_RESULT(yes)
4361 else
4362 AC_MSG_RESULT(no)
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004363 fi
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004364 dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
4365 dnl declared as char x[1] but actually longer. Introduced in gcc 4.0.
Bram Moolenaar56d1db32009-12-16 16:14:51 +00004366 dnl Also remove duplicate _FORTIFY_SOURCE arguments.
Bram Moolenaaraeabe052011-12-08 15:17:34 +01004367 dnl And undefine it first to avoid a warning.
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004368 AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
4369 if test "$gccmajor" -gt "3"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02004370 CFLAGS=`echo "$CFLAGS" | sed -e 's/ *-Wp,-D_FORTIFY_SOURCE=.//g' -e 's/ *-D_FORTIFY_SOURCE=.//g' -e 's/ *-U_FORTIFY_SOURCE//g' -e 's/$/ -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1/'`
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004371 AC_MSG_RESULT(yes)
4372 else
4373 AC_MSG_RESULT(no)
4374 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +00004375fi
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004376AC_SUBST(DEPEND_CFLAGS_FILTER)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004377
Bram Moolenaarec0557f2018-01-31 14:41:37 +01004378dnl On some systems AC_SYS_LARGEFILE determines that -D_FILE_OFFSET_BITS=64
4379dnl isn't required, but the CFLAGS for some of the libraries we're using
4380dnl include the define. Since the define changes the size of some datatypes
4381dnl (e.g. ino_t and off_t), all of Vim's modules must be compiled with a
4382dnl consistent value. It's therefore safest to force the use of the define
4383dnl if it's present in any of the *_CFLAGS variables.
4384AC_MSG_CHECKING(whether we need to force -D_FILE_OFFSET_BITS=64)
4385if echo "$CFLAGS $LUA_CFLAGS $MZSCHEME_CFLAGS $PERL_CFLAGS $PYTHON_GETPATH_CFLAGS $PYTHON_CFLAGS $PYTHON3_CFLAGS $TCL_CFLAGS $RUBY_CFLAGS $GTK_CFLAGS" | grep -q D_FILE_OFFSET_BITS 2>/dev/null; then
4386 AC_MSG_RESULT(yes)
4387 AC_DEFINE(_FILE_OFFSET_BITS, 64)
4388else
4389 AC_MSG_RESULT(no)
4390fi
4391
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004392dnl link.sh tries to avoid overlinking in a hackish way.
4393dnl At least GNU ld supports --as-needed which provides the same functionality
4394dnl at linker level. Let's use it.
4395AC_MSG_CHECKING(linker --as-needed support)
4396LINK_AS_NEEDED=
4397# Check if linker supports --as-needed and --no-as-needed options
4398if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02004399 LDFLAGS=`echo "$LDFLAGS" | sed -e 's/ *-Wl,--as-needed//g' | sed -e 's/$/ -Wl,--as-needed/'`
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004400 LINK_AS_NEEDED=yes
4401fi
4402if test "$LINK_AS_NEEDED" = yes; then
4403 AC_MSG_RESULT(yes)
4404else
4405 AC_MSG_RESULT(no)
4406fi
4407AC_SUBST(LINK_AS_NEEDED)
4408
Bram Moolenaar77c19352012-06-13 19:19:41 +02004409# IBM z/OS reset CFLAGS for config.mk
4410if test "$zOSUnix" = "yes"; then
4411 CFLAGS="-D_ALL_SOURCE -Wc,float\(ieee\),dll"
4412fi
4413
Bram Moolenaar071d4272004-06-13 20:20:40 +00004414dnl write output files
4415AC_OUTPUT(auto/config.mk:config.mk.in)
4416
4417dnl vim: set sw=2 tw=78 fo+=l: