blob: 4ae21a110e03f5e981a67803aed0668f3c219112 [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 Moolenaar2e324952018-04-14 14:37:07 +020014AC_PROG_CC_C89 dnl required by almost everything
Bram Moolenaarc0394412017-04-20 20:20:23 +020015AC_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 Moolenaar561f8a52018-04-17 22:02:45 +020032dnl Check that the C99 features that Vim uses are supported:
33dnl - // commands
34dnl - comma after last enum item
35dnl - "long long int" and "long long unsigned"
36dnl - flexible array member
37AC_MSG_CHECKING(if the compiler can handle Vim code)
38AC_TRY_COMPILE([#include <stdio.h>], [
39 struct with_flexible_member {
40 int count; // comment
41 char text[]; // another comment
42 };
43 enum {
44 one,
45 two,
46 three,
47 };
48 long long int a = 1;
49 long long unsigned b = 2;
50 printf("a %lld and a %llu", a, b);
51 ],
52AC_MSG_RESULT(yes),
53AC_MSG_ERROR([compiler does not work properly - see auto/config.log]))
54
Bram Moolenaarf788a062011-12-14 20:51:25 +010055dnl Check for the flag that fails if stuff are missing.
56
57AC_MSG_CHECKING(--enable-fail-if-missing argument)
58AC_ARG_ENABLE(fail_if_missing,
59 [ --enable-fail-if-missing Fail if dependencies on additional features
60 specified on the command line are missing.],
61 [fail_if_missing="yes"],
62 [fail_if_missing="no"])
63AC_MSG_RESULT($fail_if_missing)
64
Bram Moolenaar071d4272004-06-13 20:20:40 +000065dnl Set default value for CFLAGS if none is defined or it's empty
66if test -z "$CFLAGS"; then
67 CFLAGS="-O"
68 test "$GCC" = yes && CFLAGS="-O2 -fno-strength-reduce -Wall"
69fi
70if test "$GCC" = yes; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +000071 dnl method that should work for nearly all versions
Bram Moolenaarc8836f72014-04-12 13:12:24 +020072 gccversion=`$CC -dumpversion`
Bram Moolenaar910f66f2006-04-05 20:41:53 +000073 if test "x$gccversion" = "x"; then
74 dnl old method; fall-back for when -dumpversion doesn't work
Bram Moolenaarc8836f72014-04-12 13:12:24 +020075 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 +000076 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +000077 dnl version 4.0.1 was reported to cause trouble on Macintosh by Marcin Dalecki
78 if test "$gccversion" = "3.0.1" -o "$gccversion" = "3.0.2" -o "$gccversion" = "4.0.1"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +000079 echo 'GCC [[34]].0.[[12]] has a bug in the optimizer, disabling "-O#"'
Bram Moolenaar071d4272004-06-13 20:20:40 +000080 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-O/'`
81 else
82 if test "$gccversion" = "3.1" -o "$gccversion" = "3.2" -o "$gccversion" = "3.2.1" && `echo "$CFLAGS" | grep -v fno-strength-reduce >/dev/null`; then
83 echo 'GCC 3.1 and 3.2 have a bug in the optimizer, adding "-fno-strength-reduce"'
84 CFLAGS="$CFLAGS -fno-strength-reduce"
85 fi
86 fi
87fi
88
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +020089dnl clang-500.2.75 or around has abandoned -f[no-]strength-reduce and issues a
90dnl warning when that flag is passed to. Accordingly, adjust CFLAGS based on
91dnl the version number of the clang in use.
92dnl Note that this does not work to get the version of clang 3.1 or 3.2.
Bram Moolenaar5f69fee2017-03-09 11:58:40 +010093AC_MSG_CHECKING(for clang version)
94CLANG_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 +020095if test x"$CLANG_VERSION_STRING" != x"" ; then
96 CLANG_MAJOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*/\1/p'`
97 CLANG_MINOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/p'`
98 CLANG_REVISION=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)/\1/p'`
99 CLANG_VERSION=`expr $CLANG_MAJOR '*' 1000000 '+' $CLANG_MINOR '*' 1000 '+' $CLANG_REVISION`
100 AC_MSG_RESULT($CLANG_VERSION)
101 dnl If you find the same issue with versions earlier than 500.2.75,
102 dnl change the constant 500002075 below appropriately. To get the
103 dnl integer corresponding to a version number, refer to the
104 dnl definition of CLANG_VERSION above.
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100105 AC_MSG_CHECKING(if clang supports -fno-strength-reduce)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200106 if test "$CLANG_VERSION" -ge 500002075 ; then
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100107 AC_MSG_RESULT(no)
108 CFLAGS=`echo "$CFLAGS" | sed -e 's/-fno-strength-reduce/ /'`
109 else
110 AC_MSG_RESULT(yes)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200111 fi
112else
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100113 AC_MSG_RESULT(N/A)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200114fi
115
Bram Moolenaar446cb832008-06-24 21:56:24 +0000116dnl If configure thinks we are cross compiling, there might be something
117dnl wrong with the CC or CFLAGS settings, give a useful warning message
Bram Moolenaar839e9542016-04-14 16:46:02 +0200118CROSS_COMPILING=
Bram Moolenaar071d4272004-06-13 20:20:40 +0000119if test "$cross_compiling" = yes; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000120 AC_MSG_RESULT([cannot compile a simple program; if not cross compiling check CC and CFLAGS])
Bram Moolenaar839e9542016-04-14 16:46:02 +0200121 CROSS_COMPILING=1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000122fi
Bram Moolenaar839e9542016-04-14 16:46:02 +0200123AC_SUBST(CROSS_COMPILING)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000124
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +0000125dnl gcc-cpp has the wonderful -MM option to produce nicer dependencies.
126dnl But gcc 3.1 changed the meaning! See near the end.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000127test "$GCC" = yes && CPP_MM=M; AC_SUBST(CPP_MM)
128
129if test -f ./toolcheck; then
130 AC_CHECKING(for buggy tools)
131 sh ./toolcheck 1>&AC_FD_MSG
132fi
133
134OS_EXTRA_SRC=""; OS_EXTRA_OBJ=""
135
136dnl Check for BeOS, which needs an extra source file
137AC_MSG_CHECKING(for BeOS)
138case `uname` in
139 BeOS) OS_EXTRA_SRC=os_beos.c; OS_EXTRA_OBJ=objects/os_beos.o
140 BEOS=yes; AC_MSG_RESULT(yes);;
141 *) BEOS=no; AC_MSG_RESULT(no);;
142esac
143
144dnl If QNX is found, assume we don't want to use Xphoton
145dnl unless it was specifically asked for (--with-x)
146AC_MSG_CHECKING(for QNX)
147case `uname` in
148 QNX) OS_EXTRA_SRC=os_qnx.c; OS_EXTRA_OBJ=objects/os_qnx.o
149 test -z "$with_x" && with_x=no
150 QNX=yes; AC_MSG_RESULT(yes);;
151 *) QNX=no; AC_MSG_RESULT(no);;
152esac
153
154dnl Check for Darwin and MacOS X
155dnl We do a check for MacOS X in the very beginning because there
156dnl are a lot of other things we need to change besides GUI stuff
Bram Moolenaar071d4272004-06-13 20:20:40 +0000157AC_MSG_CHECKING([for Darwin (Mac OS X)])
158if test "`(uname) 2>/dev/null`" = Darwin; then
159 AC_MSG_RESULT(yes)
Bram Moolenaard0573012017-10-28 21:11:06 +0200160 MACOS_X=yes
Bram Moolenaar2e324952018-04-14 14:37:07 +0200161 CPPFLAGS="$CPPFLAGS -D_DARWIN_C_SOURCE -DMACOS_X"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000162
163 AC_MSG_CHECKING(--disable-darwin argument)
164 AC_ARG_ENABLE(darwin,
165 [ --disable-darwin Disable Darwin (Mac OS X) support.],
166 , [enable_darwin="yes"])
167 if test "$enable_darwin" = "yes"; then
168 AC_MSG_RESULT(no)
169 AC_MSG_CHECKING(if Darwin files are there)
Bram Moolenaar164fca32010-07-14 13:58:07 +0200170 if test -f os_macosx.m; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000171 AC_MSG_RESULT(yes)
172 else
173 AC_MSG_RESULT([no, Darwin support disabled])
174 enable_darwin=no
175 fi
176 else
177 AC_MSG_RESULT([yes, Darwin support excluded])
178 fi
179
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000180 AC_MSG_CHECKING(--with-mac-arch argument)
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000181 AC_ARG_WITH(mac-arch, [ --with-mac-arch=ARCH current, intel, ppc or both],
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000182 MACARCH="$withval"; AC_MSG_RESULT($MACARCH),
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000183 MACARCH="current"; AC_MSG_RESULT(defaulting to $MACARCH))
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000184
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100185 AC_MSG_CHECKING(--with-developer-dir argument)
186 AC_ARG_WITH(developer-dir, [ --with-developer-dir=PATH use PATH as location for Xcode developer tools],
187 DEVELOPER_DIR="$withval"; AC_MSG_RESULT($DEVELOPER_DIR),
Bram Moolenaar32d03b32015-11-19 13:46:48 +0100188 AC_MSG_RESULT(not present))
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100189
190 if test "x$DEVELOPER_DIR" = "x"; then
191 AC_PATH_PROG(XCODE_SELECT, xcode-select)
192 if test "x$XCODE_SELECT" != "x"; then
193 AC_MSG_CHECKING(for developer dir using xcode-select)
194 DEVELOPER_DIR=`$XCODE_SELECT -print-path`
195 AC_MSG_RESULT([$DEVELOPER_DIR])
196 else
197 DEVELOPER_DIR=/Developer
198 fi
199 fi
200
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000201 if test "x$MACARCH" = "xboth"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000202 AC_MSG_CHECKING(for 10.4 universal SDK)
203 dnl There is a terrible inconsistency (but we appear to get away with it):
204 dnl $CFLAGS uses the 10.4u SDK library for the headers, while $CPPFLAGS
205 dnl doesn't, because "gcc -E" doesn't grok it. That means the configure
206 dnl tests using the preprocessor are actually done with the wrong header
207 dnl files. $LDFLAGS is set at the end, because configure uses it together
208 dnl with $CFLAGS and we can only have one -sysroot argument.
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000209 save_cppflags="$CPPFLAGS"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000210 save_cflags="$CFLAGS"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000211 save_ldflags="$LDFLAGS"
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100212 CFLAGS="$CFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000213 AC_TRY_LINK([ ], [ ],
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000214 AC_MSG_RESULT(found, will make universal binary),
215
216 AC_MSG_RESULT(not found)
Bram Moolenaar1f35bf92006-03-07 22:38:47 +0000217 CFLAGS="$save_cflags"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000218 AC_MSG_CHECKING(if Intel architecture is supported)
219 CPPFLAGS="$CPPFLAGS -arch i386"
220 LDFLAGS="$save_ldflags -arch i386"
221 AC_TRY_LINK([ ], [ ],
222 AC_MSG_RESULT(yes); MACARCH="intel",
223 AC_MSG_RESULT(no, using PowerPC)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000224 MACARCH="ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000225 CPPFLAGS="$save_cppflags -arch ppc"
226 LDFLAGS="$save_ldflags -arch ppc"))
227 elif test "x$MACARCH" = "xintel"; then
228 CPPFLAGS="$CPPFLAGS -arch intel"
229 LDFLAGS="$LDFLAGS -arch intel"
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000230 elif test "x$MACARCH" = "xppc"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000231 CPPFLAGS="$CPPFLAGS -arch ppc"
232 LDFLAGS="$LDFLAGS -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000233 fi
234
Bram Moolenaar071d4272004-06-13 20:20:40 +0000235 if test "$enable_darwin" = "yes"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200236 MACOS_X_DARWIN=yes
Bram Moolenaar164fca32010-07-14 13:58:07 +0200237 OS_EXTRA_SRC="os_macosx.m os_mac_conv.c";
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000238 OS_EXTRA_OBJ="objects/os_macosx.o objects/os_mac_conv.o"
Bram Moolenaar32466aa2006-02-24 23:53:04 +0000239 dnl TODO: use -arch i386 on Intel machines
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100240 dnl Removed -no-cpp-precomp, only for very old compilers.
Bram Moolenaard0573012017-10-28 21:11:06 +0200241 CPPFLAGS="$CPPFLAGS -DMACOS_X_DARWIN"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000242
243 dnl If Carbon is found, assume we don't want X11
244 dnl unless it was specifically asked for (--with-x)
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000245 dnl or Motif, Athena or GTK GUI is used.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000246 AC_CHECK_HEADER(Carbon/Carbon.h, CARBON=yes)
247 if test "x$CARBON" = "xyes"; then
Bram Moolenaar98921892016-02-23 17:14:37 +0100248 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 +0000249 with_x=no
Bram Moolenaar071d4272004-06-13 20:20:40 +0000250 fi
251 fi
252 fi
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000253
Bram Moolenaardb552d602006-03-23 22:59:57 +0000254 dnl Avoid a bug with -O2 with gcc 4.0.1. Symptom: malloc() reports double
Bram Moolenaarfd2ac762006-03-01 22:09:21 +0000255 dnl free. This happens in expand_filename(), because the optimizer swaps
Bram Moolenaardb552d602006-03-23 22:59:57 +0000256 dnl two blocks of code, both using "repl", that can't be swapped.
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000257 if test "$MACARCH" = "intel" -o "$MACARCH" = "both"; then
258 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-Oz/'`
259 fi
260
Bram Moolenaar071d4272004-06-13 20:20:40 +0000261else
262 AC_MSG_RESULT(no)
263fi
264
Bram Moolenaar39766a72013-11-03 00:41:00 +0100265dnl Mac OS X 10.9+ no longer include AvailabilityMacros.h in Carbon
266dnl so we need to include it to have access to version macros.
Bram Moolenaar18e54692013-11-03 20:26:31 +0100267AC_CHECK_HEADERS(AvailabilityMacros.h)
Bram Moolenaar39766a72013-11-03 00:41:00 +0100268
Bram Moolenaar071d4272004-06-13 20:20:40 +0000269AC_SUBST(OS_EXTRA_SRC)
270AC_SUBST(OS_EXTRA_OBJ)
271
272dnl Add /usr/local/lib to $LDFLAGS and /usr/local/include to CFLAGS.
273dnl Only when the directory exists and it wasn't there yet.
274dnl For gcc don't do this when it is already in the default search path.
Bram Moolenaar446cb832008-06-24 21:56:24 +0000275dnl Skip all of this when cross-compiling.
276if test "$cross_compiling" = no; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000277 AC_MSG_CHECKING(--with-local-dir argument)
Bram Moolenaar446cb832008-06-24 21:56:24 +0000278 have_local_include=''
279 have_local_lib=''
Bram Moolenaarc236c162008-07-13 17:41:49 +0000280 AC_ARG_WITH([local-dir], [ --with-local-dir=PATH search PATH instead of /usr/local for local libraries.
281 --without-local-dir do not search /usr/local for local libraries.], [
282 local_dir="$withval"
283 case "$withval" in
284 */*) ;;
285 no)
286 # avoid adding local dir to LDFLAGS and CPPFLAGS
Bram Moolenaare06c1882010-07-21 22:05:20 +0200287 have_local_include=yes
Bram Moolenaarc236c162008-07-13 17:41:49 +0000288 have_local_lib=yes
289 ;;
290 *) AC_MSG_ERROR(must pass path argument to --with-local-dir) ;;
291 esac
292 AC_MSG_RESULT($local_dir)
293 ], [
294 local_dir=/usr/local
295 AC_MSG_RESULT(Defaulting to $local_dir)
296 ])
297 if test "$GCC" = yes -a "$local_dir" != no; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000298 echo 'void f(){}' > conftest.c
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100299 dnl Removed -no-cpp-precomp, only needed for OS X 10.2 (Ben Fowler)
300 have_local_include=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/include"`
Bram Moolenaarc236c162008-07-13 17:41:49 +0000301 have_local_lib=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/lib"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000302 rm -f conftest.c conftest.o
Bram Moolenaar071d4272004-06-13 20:20:40 +0000303 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000304 if test -z "$have_local_lib" -a -d "${local_dir}/lib"; then
305 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 +0000306 if test "$tt" = "$LDFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000307 LDFLAGS="$LDFLAGS -L${local_dir}/lib"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000308 fi
309 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000310 if test -z "$have_local_include" -a -d "${local_dir}/include"; then
311 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 +0000312 if test "$tt" = "$CPPFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000313 CPPFLAGS="$CPPFLAGS -I${local_dir}/include"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000314 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000315 fi
316fi
317
318AC_MSG_CHECKING(--with-vim-name argument)
319AC_ARG_WITH(vim-name, [ --with-vim-name=NAME what to call the Vim executable],
320 VIMNAME="$withval"; AC_MSG_RESULT($VIMNAME),
Bram Moolenaare344bea2005-09-01 20:46:49 +0000321 VIMNAME="vim"; AC_MSG_RESULT(Defaulting to $VIMNAME))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000322AC_SUBST(VIMNAME)
323AC_MSG_CHECKING(--with-ex-name argument)
324AC_ARG_WITH(ex-name, [ --with-ex-name=NAME what to call the Ex executable],
325 EXNAME="$withval"; AC_MSG_RESULT($EXNAME),
326 EXNAME="ex"; AC_MSG_RESULT(Defaulting to ex))
327AC_SUBST(EXNAME)
328AC_MSG_CHECKING(--with-view-name argument)
329AC_ARG_WITH(view-name, [ --with-view-name=NAME what to call the View executable],
330 VIEWNAME="$withval"; AC_MSG_RESULT($VIEWNAME),
331 VIEWNAME="view"; AC_MSG_RESULT(Defaulting to view))
332AC_SUBST(VIEWNAME)
333
334AC_MSG_CHECKING(--with-global-runtime argument)
335AC_ARG_WITH(global-runtime, [ --with-global-runtime=DIR global runtime directory in 'runtimepath'],
336 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL, "$withval"),
337 AC_MSG_RESULT(no))
338
339AC_MSG_CHECKING(--with-modified-by argument)
340AC_ARG_WITH(modified-by, [ --with-modified-by=NAME name of who modified a release version],
341 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(MODIFIED_BY, "$withval"),
342 AC_MSG_RESULT(no))
343
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200344dnl Check for EBCDIC stolen from the LYNX port to z/OS Unix
Bram Moolenaar071d4272004-06-13 20:20:40 +0000345AC_MSG_CHECKING(if character set is EBCDIC)
346AC_TRY_COMPILE([ ],
347[ /* TryCompile function for CharSet.
348 Treat any failure as ASCII for compatibility with existing art.
349 Use compile-time rather than run-time tests for cross-compiler
350 tolerance. */
351#if '0'!=240
352make an error "Character set is not EBCDIC"
353#endif ],
354[ # TryCompile action if true
355cf_cv_ebcdic=yes ],
356[ # TryCompile action if false
357cf_cv_ebcdic=no])
358# end of TryCompile ])
359# end of CacheVal CvEbcdic
360AC_MSG_RESULT($cf_cv_ebcdic)
361case "$cf_cv_ebcdic" in #(vi
362 yes) AC_DEFINE(EBCDIC)
363 line_break='"\\n"'
364 ;;
365 *) line_break='"\\012"';;
366esac
367AC_SUBST(line_break)
368
369if test "$cf_cv_ebcdic" = "yes"; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +0200370dnl If we have EBCDIC we most likely have z/OS Unix, let's test it!
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200371AC_MSG_CHECKING(for z/OS Unix)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000372case `uname` in
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200373 OS/390) zOSUnix="yes";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000374 dnl If using cc the environment variable _CC_CCMODE must be
375 dnl set to "1", so that some compiler extensions are enabled.
376 dnl If using c89 the environment variable is named _CC_C89MODE.
377 dnl Note: compile with c89 never tested.
378 if test "$CC" = "cc"; then
379 ccm="$_CC_CCMODE"
380 ccn="CC"
381 else
382 if test "$CC" = "c89"; then
383 ccm="$_CC_C89MODE"
384 ccn="C89"
385 else
386 ccm=1
387 fi
388 fi
389 if test "$ccm" != "1"; then
390 echo ""
391 echo "------------------------------------------"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200392 echo " On z/OS Unix, the environment variable"
Bram Moolenaar77c19352012-06-13 19:19:41 +0200393 echo " _CC_${ccn}MODE must be set to \"1\"!"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000394 echo " Do:"
395 echo " export _CC_${ccn}MODE=1"
396 echo " and then call configure again."
397 echo "------------------------------------------"
398 exit 1
399 fi
Bram Moolenaar77c19352012-06-13 19:19:41 +0200400 # Set CFLAGS for configure process.
401 # This will be reset later for config.mk.
402 # Use haltonmsg to force error for missing H files.
403 CFLAGS="$CFLAGS -D_ALL_SOURCE -Wc,float(ieee),haltonmsg(3296)";
404 LDFLAGS="$LDFLAGS -Wl,EDIT=NO"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000405 AC_MSG_RESULT(yes)
406 ;;
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200407 *) zOSUnix="no";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000408 AC_MSG_RESULT(no)
409 ;;
410esac
411fi
412
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200413dnl Set QUOTESED. Needs additional backslashes on zOS
414if test "$zOSUnix" = "yes"; then
415 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\\\\\&/g' -e 's/\\\\\\\\\"/\"/' -e 's/\\\\\\\\\";\$\$/\";/'"
416else
417 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\&/g' -e 's/\\\\\"/\"/' -e 's/\\\\\";\$\$/\";/'"
418fi
419AC_SUBST(QUOTESED)
420
421
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200422dnl Link with -lsmack for Smack stuff; if not found
423AC_MSG_CHECKING(--disable-smack argument)
424AC_ARG_ENABLE(smack,
425 [ --disable-smack Do not check for Smack support.],
426 , enable_smack="yes")
427if test "$enable_smack" = "yes"; then
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200428 AC_MSG_RESULT(no)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200429 AC_CHECK_HEADER([linux/xattr.h], true, enable_smack="no")
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200430else
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200431 AC_MSG_RESULT(yes)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200432fi
433if test "$enable_smack" = "yes"; then
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200434 AC_CHECK_HEADER([attr/xattr.h], true, enable_smack="no")
435fi
436if test "$enable_smack" = "yes"; then
437 AC_MSG_CHECKING(for XATTR_NAME_SMACKEXEC in linux/xattr.h)
438 AC_EGREP_CPP(XATTR_NAME_SMACKEXEC, [#include <linux/xattr.h>],
439 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +0200440 AC_MSG_RESULT(no); enable_smack="no")
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200441fi
442if test "$enable_smack" = "yes"; then
443 AC_CHECK_LIB(attr, setxattr,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200444 [LIBS="$LIBS -lattr"
445 found_smack="yes"
446 AC_DEFINE(HAVE_SMACK)])
Bram Moolenaar588ebeb2008-05-07 17:09:24 +0000447fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000448
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200449dnl When smack was found don't search for SELinux
450if test "x$found_smack" = "x"; then
451 dnl Link with -lselinux for SELinux stuff; if not found
452 AC_MSG_CHECKING(--disable-selinux argument)
453 AC_ARG_ENABLE(selinux,
454 [ --disable-selinux Do not check for SELinux support.],
455 , enable_selinux="yes")
456 if test "$enable_selinux" = "yes"; then
457 AC_MSG_RESULT(no)
458 AC_CHECK_LIB(selinux, is_selinux_enabled,
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100459 [AC_CHECK_HEADER(selinux/selinux.h,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200460 [LIBS="$LIBS -lselinux"
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100461 AC_DEFINE(HAVE_SELINUX)])])
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200462 else
463 AC_MSG_RESULT(yes)
464 fi
465fi
466
Bram Moolenaar071d4272004-06-13 20:20:40 +0000467dnl Check user requested features.
468
469AC_MSG_CHECKING(--with-features argument)
Bram Moolenaareec29812016-07-26 21:27:36 +0200470AC_ARG_WITH(features, [ --with-features=TYPE tiny, small, normal, big or huge (default: huge)],
Bram Moolenaar071d4272004-06-13 20:20:40 +0000471 features="$withval"; AC_MSG_RESULT($features),
Bram Moolenaar23c4f712016-01-20 22:11:59 +0100472 features="huge"; AC_MSG_RESULT(Defaulting to huge))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000473
474dovimdiff=""
475dogvimdiff=""
476case "$features" in
477 tiny) AC_DEFINE(FEAT_TINY) ;;
478 small) AC_DEFINE(FEAT_SMALL) ;;
479 normal) AC_DEFINE(FEAT_NORMAL) dovimdiff="installvimdiff";
480 dogvimdiff="installgvimdiff" ;;
481 big) AC_DEFINE(FEAT_BIG) dovimdiff="installvimdiff";
482 dogvimdiff="installgvimdiff" ;;
483 huge) AC_DEFINE(FEAT_HUGE) dovimdiff="installvimdiff";
484 dogvimdiff="installgvimdiff" ;;
485 *) AC_MSG_RESULT([Sorry, $features is not supported]) ;;
486esac
487
488AC_SUBST(dovimdiff)
489AC_SUBST(dogvimdiff)
490
491AC_MSG_CHECKING(--with-compiledby argument)
492AC_ARG_WITH(compiledby, [ --with-compiledby=NAME name to show in :version message],
493 compiledby="$withval"; AC_MSG_RESULT($withval),
494 compiledby=""; AC_MSG_RESULT(no))
495AC_SUBST(compiledby)
496
497AC_MSG_CHECKING(--disable-xsmp argument)
498AC_ARG_ENABLE(xsmp,
499 [ --disable-xsmp Disable XSMP session management],
500 , enable_xsmp="yes")
501
502if test "$enable_xsmp" = "yes"; then
503 AC_MSG_RESULT(no)
504 AC_MSG_CHECKING(--disable-xsmp-interact argument)
505 AC_ARG_ENABLE(xsmp-interact,
506 [ --disable-xsmp-interact Disable XSMP interaction],
507 , enable_xsmp_interact="yes")
508 if test "$enable_xsmp_interact" = "yes"; then
509 AC_MSG_RESULT(no)
510 AC_DEFINE(USE_XSMP_INTERACT)
511 else
512 AC_MSG_RESULT(yes)
513 fi
514else
515 AC_MSG_RESULT(yes)
516fi
517
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200518dnl Check for Lua feature.
519AC_MSG_CHECKING(--enable-luainterp argument)
520AC_ARG_ENABLE(luainterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200521 [ --enable-luainterp[=OPTS] Include Lua interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200522 [enable_luainterp="no"])
523AC_MSG_RESULT($enable_luainterp)
524
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200525if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +0100526 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
527 AC_MSG_ERROR([cannot use Lua with tiny or small features])
528 fi
529
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200530 dnl -- find the lua executable
531 AC_SUBST(vi_cv_path_lua)
532
533 AC_MSG_CHECKING(--with-lua-prefix argument)
534 AC_ARG_WITH(lua_prefix,
535 [ --with-lua-prefix=PFX Prefix where Lua is installed.],
536 with_lua_prefix="$withval"; AC_MSG_RESULT($with_lua_prefix),
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200537 with_lua_prefix="";AC_MSG_RESULT(no))
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200538
539 if test "X$with_lua_prefix" != "X"; then
540 vi_cv_path_lua_pfx="$with_lua_prefix"
541 else
542 AC_MSG_CHECKING(LUA_PREFIX environment var)
543 if test "X$LUA_PREFIX" != "X"; then
544 AC_MSG_RESULT("$LUA_PREFIX")
545 vi_cv_path_lua_pfx="$LUA_PREFIX"
546 else
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200547 AC_MSG_RESULT([not set, default to /usr])
548 vi_cv_path_lua_pfx="/usr"
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200549 fi
550 fi
551
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200552 AC_MSG_CHECKING(--with-luajit)
553 AC_ARG_WITH(luajit,
554 [ --with-luajit Link with LuaJIT instead of Lua.],
555 [vi_cv_with_luajit="$withval"],
556 [vi_cv_with_luajit="no"])
557 AC_MSG_RESULT($vi_cv_with_luajit)
558
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200559 LUA_INC=
560 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200561 if test "x$vi_cv_with_luajit" != "xno"; then
562 dnl -- try to find LuaJIT executable
563 AC_PATH_PROG(vi_cv_path_luajit, luajit)
564 if test "X$vi_cv_path_luajit" != "X"; then
565 dnl -- find LuaJIT version
566 AC_CACHE_CHECK(LuaJIT version, vi_cv_version_luajit,
Bram Moolenaar49b10272013-11-21 12:17:51 +0100567 [ 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 +0200568 AC_CACHE_CHECK(Lua version of LuaJIT, vi_cv_version_lua_luajit,
569 [ vi_cv_version_lua_luajit=`${vi_cv_path_luajit} -e "print(_VERSION)" | sed 's/.* //'` ])
570 vi_cv_path_lua="$vi_cv_path_luajit"
571 vi_cv_version_lua="$vi_cv_version_lua_luajit"
572 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200573 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200574 dnl -- try to find Lua executable
575 AC_PATH_PROG(vi_cv_path_plain_lua, lua)
576 if test "X$vi_cv_path_plain_lua" != "X"; then
577 dnl -- find Lua version
578 AC_CACHE_CHECK(Lua version, vi_cv_version_plain_lua,
579 [ vi_cv_version_plain_lua=`${vi_cv_path_plain_lua} -e "print(_VERSION)" | sed 's/.* //'` ])
580 fi
581 vi_cv_path_lua="$vi_cv_path_plain_lua"
582 vi_cv_version_lua="$vi_cv_version_plain_lua"
583 fi
584 if test "x$vi_cv_with_luajit" != "xno" && test "X$vi_cv_version_luajit" != "X"; then
585 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 +0100586 if test -f "$vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200587 AC_MSG_RESULT(yes)
588 LUA_INC=/luajit-$vi_cv_version_luajit
589 fi
590 fi
591 if test "X$LUA_INC" = "X"; then
592 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)
Bram Moolenaar49222be2015-12-11 18:11:30 +0100593 if test -f "$vi_cv_path_lua_pfx/include/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200594 AC_MSG_RESULT(yes)
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200595 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200596 AC_MSG_RESULT(no)
597 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 +0100598 if test -f "$vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200599 AC_MSG_RESULT(yes)
600 LUA_INC=/lua$vi_cv_version_lua
601 else
602 AC_MSG_RESULT(no)
603 vi_cv_path_lua_pfx=
604 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200605 fi
606 fi
607 fi
608
609 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200610 if test "x$vi_cv_with_luajit" != "xno"; then
611 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
612 if test "X$multiarch" != "X"; then
613 lib_multiarch="lib/${multiarch}"
614 else
615 lib_multiarch="lib"
616 fi
617 if test "X$vi_cv_version_lua" = "X"; then
618 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit"
619 else
620 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit-$vi_cv_version_lua"
621 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200622 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200623 if test "X$LUA_INC" != "X"; then
624 dnl Test alternate location using version
625 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua$vi_cv_version_lua"
626 else
627 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua"
628 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200629 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200630 if test "$enable_luainterp" = "dynamic"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200631 lua_ok="yes"
632 else
633 AC_MSG_CHECKING([if link with ${LUA_LIBS} is sane])
634 libs_save=$LIBS
635 LIBS="$LIBS $LUA_LIBS"
636 AC_TRY_LINK(,[ ],
637 AC_MSG_RESULT(yes); lua_ok="yes",
638 AC_MSG_RESULT(no); lua_ok="no"; LUA_LIBS="")
639 LIBS=$libs_save
640 fi
641 if test "x$lua_ok" = "xyes"; then
642 LUA_CFLAGS="-I${vi_cv_path_lua_pfx}/include${LUA_INC}"
643 LUA_SRC="if_lua.c"
644 LUA_OBJ="objects/if_lua.o"
645 LUA_PRO="if_lua.pro"
646 AC_DEFINE(FEAT_LUA)
647 fi
648 if test "$enable_luainterp" = "dynamic"; then
649 if test "x$vi_cv_with_luajit" != "xno"; then
650 luajit="jit"
651 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200652 if test -f "${vi_cv_path_lua_pfx}/bin/cyglua-${vi_cv_version_lua}.dll"; then
653 vi_cv_dll_name_lua="cyglua-${vi_cv_version_lua}.dll"
654 else
Bram Moolenaard0573012017-10-28 21:11:06 +0200655 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200656 ext="dylib"
657 indexes=""
658 else
659 ext="so"
660 indexes=".0 .1 .2 .3 .4 .5 .6 .7 .8 .9"
661 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
662 if test "X$multiarch" != "X"; then
663 lib_multiarch="lib/${multiarch}"
664 fi
Bram Moolenaar768baac2013-04-15 14:44:57 +0200665 fi
666 dnl Determine the sover for the current version, but fallback to
667 dnl liblua${vi_cv_version_lua}.so if no sover-versioned file is found.
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200668 AC_MSG_CHECKING(if liblua${luajit}*.${ext}* can be found in $vi_cv_path_lua_pfx)
Bram Moolenaar768baac2013-04-15 14:44:57 +0200669 for subdir in "${lib_multiarch}" lib64 lib; do
670 if test -z "$subdir"; then
671 continue
672 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200673 for sover in "${vi_cv_version_lua}.${ext}" "-${vi_cv_version_lua}.${ext}" \
674 ".${vi_cv_version_lua}.${ext}" ".${ext}.${vi_cv_version_lua}"; do
675 for i in $indexes ""; do
676 if test -f "${vi_cv_path_lua_pfx}/${subdir}/liblua${luajit}${sover}$i"; then
Bram Moolenaar768baac2013-04-15 14:44:57 +0200677 sover2="$i"
678 break 3
679 fi
680 done
Bram Moolenaar07e1da62013-02-06 19:49:43 +0100681 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200682 sover=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200683 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200684 if test "X$sover" = "X"; then
685 AC_MSG_RESULT(no)
686 lua_ok="no"
687 vi_cv_dll_name_lua="liblua${luajit}.${ext}"
688 else
689 AC_MSG_RESULT(yes)
690 lua_ok="yes"
691 vi_cv_dll_name_lua="liblua${luajit}${sover}$sover2"
692 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200693 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200694 AC_DEFINE(DYNAMIC_LUA)
695 LUA_LIBS=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200696 LUA_CFLAGS="-DDYNAMIC_LUA_DLL=\\\"${vi_cv_dll_name_lua}\\\" $LUA_CFLAGS"
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200697 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200698 if test "X$LUA_CFLAGS$LUA_LIBS" != "X" && \
Bram Moolenaard0573012017-10-28 21:11:06 +0200699 test "x$MACOS_X" = "xyes" && test "x$vi_cv_with_luajit" != "xno" && \
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200700 test "`(uname -m) 2>/dev/null`" = "x86_64"; then
701 dnl OSX/x64 requires these flags. See http://luajit.org/install.html
702 LUA_LIBS="-pagezero_size 10000 -image_base 100000000 $LUA_LIBS"
703 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200704 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200705 if test "$fail_if_missing" = "yes" -a "$lua_ok" != "yes"; then
Bram Moolenaarf788a062011-12-14 20:51:25 +0100706 AC_MSG_ERROR([could not configure lua])
707 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200708 AC_SUBST(LUA_SRC)
709 AC_SUBST(LUA_OBJ)
710 AC_SUBST(LUA_PRO)
711 AC_SUBST(LUA_LIBS)
712 AC_SUBST(LUA_CFLAGS)
713fi
714
715
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000716dnl Check for MzScheme feature.
717AC_MSG_CHECKING(--enable-mzschemeinterp argument)
718AC_ARG_ENABLE(mzschemeinterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200719 [ --enable-mzschemeinterp Include MzScheme interpreter.], ,
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000720 [enable_mzschemeinterp="no"])
721AC_MSG_RESULT($enable_mzschemeinterp)
722
723if test "$enable_mzschemeinterp" = "yes"; then
724 dnl -- find the mzscheme executable
725 AC_SUBST(vi_cv_path_mzscheme)
726
727 AC_MSG_CHECKING(--with-plthome argument)
728 AC_ARG_WITH(plthome,
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000729 [ --with-plthome=PLTHOME Use PLTHOME.],
730 with_plthome="$withval"; AC_MSG_RESULT($with_plthome),
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000731 with_plthome="";AC_MSG_RESULT("no"))
732
733 if test "X$with_plthome" != "X"; then
734 vi_cv_path_mzscheme_pfx="$with_plthome"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100735 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000736 else
737 AC_MSG_CHECKING(PLTHOME environment var)
738 if test "X$PLTHOME" != "X"; then
739 AC_MSG_RESULT("$PLTHOME")
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000740 vi_cv_path_mzscheme_pfx="$PLTHOME"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100741 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000742 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000743 AC_MSG_RESULT(not set)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000744 dnl -- try to find MzScheme executable
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000745 AC_PATH_PROG(vi_cv_path_mzscheme, mzscheme)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000746
747 dnl resolve symbolic link, the executable is often elsewhere and there
748 dnl are no links for the include files.
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000749 if test "X$vi_cv_path_mzscheme" != "X"; then
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000750 lsout=`ls -l $vi_cv_path_mzscheme`
751 if echo "$lsout" | grep -e '->' >/dev/null 2>/dev/null; then
752 vi_cv_path_mzscheme=`echo "$lsout" | sed 's/.*-> \(.*\)/\1/'`
753 fi
754 fi
755
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000756 if test "X$vi_cv_path_mzscheme" != "X"; then
757 dnl -- find where MzScheme thinks it was installed
758 AC_CACHE_CHECK(MzScheme install prefix,vi_cv_path_mzscheme_pfx,
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000759 dnl different versions of MzScheme differ in command line processing
760 dnl use universal approach
761 echo "(display (simplify-path \
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000762 (build-path (call-with-values \
763 (lambda () (split-path (find-system-path (quote exec-file)))) \
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000764 (lambda (base name must-be-dir?) base)) (quote up))))" > mzdirs.scm
765 dnl Remove a trailing slash
766 [ vi_cv_path_mzscheme_pfx=`${vi_cv_path_mzscheme} -r mzdirs.scm | \
767 sed -e 's+/$++'` ])
768 rm -f mzdirs.scm
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000769 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000770 fi
771 fi
772
773 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100774 AC_MSG_CHECKING(for racket include directory)
775 SCHEME_INC=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-include-dir))) (when (path? p) (display p)))'`
776 if test "X$SCHEME_INC" != "X"; then
777 AC_MSG_RESULT(${SCHEME_INC})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000778 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100779 AC_MSG_RESULT(not found)
780 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include)
781 if test -f "$vi_cv_path_mzscheme_pfx/include/scheme.h"; then
782 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000783 AC_MSG_RESULT(yes)
Bram Moolenaard7afed32007-05-06 13:26:41 +0000784 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000785 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100786 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt)
787 if test -f "$vi_cv_path_mzscheme_pfx/include/plt/scheme.h"; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000788 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100789 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000790 else
791 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100792 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket)
793 if test -f "$vi_cv_path_mzscheme_pfx/include/racket/scheme.h"; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100794 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100795 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100796 else
797 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100798 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/)
799 if test -f /usr/include/plt/scheme.h; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100800 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100801 SCHEME_INC=/usr/include/plt
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100802 else
803 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100804 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/racket/)
805 if test -f /usr/include/racket/scheme.h; then
806 AC_MSG_RESULT(yes)
807 SCHEME_INC=/usr/include/racket
808 else
809 AC_MSG_RESULT(no)
810 vi_cv_path_mzscheme_pfx=
811 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100812 fi
813 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000814 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000815 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000816 fi
817 fi
818
819 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100820
821 AC_MSG_CHECKING(for racket lib directory)
822 SCHEME_LIB=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-lib-dir))) (when (path? p) (display p)))'`
823 if test "X$SCHEME_LIB" != "X"; then
824 AC_MSG_RESULT(${SCHEME_LIB})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000825 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100826 AC_MSG_RESULT(not found)
827 fi
828
829 for path in "${vi_cv_path_mzscheme_pfx}/lib" "${SCHEME_LIB}"; do
830 if test "X$path" != "X"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200831 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100832 MZSCHEME_LIBS="-framework Racket"
833 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
834 elif test -f "${path}/libmzscheme3m.a"; then
835 MZSCHEME_LIBS="${path}/libmzscheme3m.a"
836 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
837 elif test -f "${path}/libracket3m.a"; then
838 MZSCHEME_LIBS="${path}/libracket3m.a"
839 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
840 elif test -f "${path}/libracket.a"; then
841 MZSCHEME_LIBS="${path}/libracket.a ${path}/libmzgc.a"
842 elif test -f "${path}/libmzscheme.a"; then
843 MZSCHEME_LIBS="${path}/libmzscheme.a ${path}/libmzgc.a"
844 else
845 dnl Using shared objects
846 if test -f "${path}/libmzscheme3m.so"; then
847 MZSCHEME_LIBS="-L${path} -lmzscheme3m"
848 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
849 elif test -f "${path}/libracket3m.so"; then
850 MZSCHEME_LIBS="-L${path} -lracket3m"
851 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
852 elif test -f "${path}/libracket.so"; then
853 MZSCHEME_LIBS="-L${path} -lracket -lmzgc"
854 else
855 dnl try next until last
856 if test "$path" != "$SCHEME_LIB"; then
857 continue
858 fi
859 MZSCHEME_LIBS="-L${path} -lmzscheme -lmzgc"
860 fi
861 if test "$GCC" = yes; then
862 dnl Make Vim remember the path to the library. For when it's not in
863 dnl $LD_LIBRARY_PATH.
864 MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${path}"
865 elif test "`(uname) 2>/dev/null`" = SunOS &&
866 uname -r | grep '^5' >/dev/null; then
867 MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${path}"
868 fi
869 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000870 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100871 if test "X$MZSCHEME_LIBS" != "X"; then
872 break
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +0000873 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100874 done
875
876 AC_MSG_CHECKING([if racket requires -pthread])
877 if test "X$SCHEME_LIB" != "X" && $FGREP -e -pthread "$SCHEME_LIB/buildinfo" >/dev/null ; then
878 AC_MSG_RESULT(yes)
879 MZSCHEME_LIBS="${MZSCHEME_LIBS} -pthread"
880 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -pthread"
881 else
882 AC_MSG_RESULT(no)
883 fi
884
885 AC_MSG_CHECKING(for racket config directory)
886 SCHEME_CONFIGDIR=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-config-dir))) (when (path? p) (display p)))'`
887 if test "X$SCHEME_CONFIGDIR" != "X"; then
888 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DMZSCHEME_CONFIGDIR='\"${SCHEME_CONFIGDIR}\"'"
889 AC_MSG_RESULT(${SCHEME_CONFIGDIR})
890 else
891 AC_MSG_RESULT(not found)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000892 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100893
894 AC_MSG_CHECKING(for racket collects directory)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100895 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))))'`
896 if test "X$SCHEME_COLLECTS" = "X"; then
897 if test -d "$vi_cv_path_mzscheme_pfx/lib/plt/collects"; then
898 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/plt/
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100899 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100900 if test -d "$vi_cv_path_mzscheme_pfx/lib/racket/collects"; then
901 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/racket/
Bram Moolenaar75676462013-01-30 14:55:42 +0100902 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100903 if test -d "$vi_cv_path_mzscheme_pfx/share/racket/collects"; then
904 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/
905 else
906 if test -d "$vi_cv_path_mzscheme_pfx/collects"; then
907 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/
908 fi
Bram Moolenaar75676462013-01-30 14:55:42 +0100909 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100910 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100911 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000912 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100913 if test "X$SCHEME_COLLECTS" != "X" ; then
914 AC_MSG_RESULT(${SCHEME_COLLECTS})
915 else
916 AC_MSG_RESULT(not found)
917 fi
918
919 AC_MSG_CHECKING(for mzscheme_base.c)
920 if test -f "${SCHEME_COLLECTS}collects/scheme/base.ss" ; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000921 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +0100922 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
923 MZSCHEME_MOD="++lib scheme/base"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100924 else
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100925 if test -f "${SCHEME_COLLECTS}collects/scheme/base.rkt" ; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100926 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +0100927 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
928 MZSCHEME_MOD="++lib scheme/base"
929 else
930 if test -f "${SCHEME_COLLECTS}collects/racket/base.rkt" ; then
931 MZSCHEME_EXTRA="mzscheme_base.c"
932 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/raco ctool"
933 MZSCHEME_MOD=""
934 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100935 fi
936 fi
937 if test "X$MZSCHEME_EXTRA" != "X" ; then
938 dnl need to generate bytecode for MzScheme base
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000939 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE"
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100940 AC_MSG_RESULT(needed)
941 else
942 AC_MSG_RESULT(not needed)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000943 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100944
Bram Moolenaar9e902192013-07-17 18:58:11 +0200945 dnl On Ubuntu this fixes "undefined reference to symbol 'ffi_type_void'".
946 AC_CHECK_LIB(ffi, ffi_type_void, [MZSCHEME_LIBS="$MZSCHEME_LIBS -lffi"])
947
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000948 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -I${SCHEME_INC} \
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100949 -DMZSCHEME_COLLECTS='\"${SCHEME_COLLECTS}collects\"'"
Bram Moolenaar9e902192013-07-17 18:58:11 +0200950
951 dnl Test that we can compile a simple program with these CFLAGS and LIBS.
952 AC_MSG_CHECKING([if compile and link flags for MzScheme are sane])
953 cflags_save=$CFLAGS
954 libs_save=$LIBS
955 CFLAGS="$CFLAGS $MZSCHEME_CFLAGS"
956 LIBS="$LIBS $MZSCHEME_LIBS"
957 AC_TRY_LINK(,[ ],
958 AC_MSG_RESULT(yes); mzs_ok=yes,
959 AC_MSG_RESULT(no: MZSCHEME DISABLED); mzs_ok=no)
960 CFLAGS=$cflags_save
961 LIBS=$libs_save
962 if test $mzs_ok = yes; then
963 MZSCHEME_SRC="if_mzsch.c"
964 MZSCHEME_OBJ="objects/if_mzsch.o"
965 MZSCHEME_PRO="if_mzsch.pro"
966 AC_DEFINE(FEAT_MZSCHEME)
967 else
968 MZSCHEME_CFLAGS=
969 MZSCHEME_LIBS=
970 MZSCHEME_EXTRA=
971 MZSCHEME_MZC=
972 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000973 fi
974 AC_SUBST(MZSCHEME_SRC)
975 AC_SUBST(MZSCHEME_OBJ)
976 AC_SUBST(MZSCHEME_PRO)
977 AC_SUBST(MZSCHEME_LIBS)
978 AC_SUBST(MZSCHEME_CFLAGS)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000979 AC_SUBST(MZSCHEME_EXTRA)
980 AC_SUBST(MZSCHEME_MZC)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000981fi
982
983
Bram Moolenaar071d4272004-06-13 20:20:40 +0000984AC_MSG_CHECKING(--enable-perlinterp argument)
985AC_ARG_ENABLE(perlinterp,
Bram Moolenaare06c1882010-07-21 22:05:20 +0200986 [ --enable-perlinterp[=OPTS] Include Perl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000987 [enable_perlinterp="no"])
988AC_MSG_RESULT($enable_perlinterp)
Bram Moolenaare06c1882010-07-21 22:05:20 +0200989if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +0100990 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
991 AC_MSG_ERROR([cannot use Perl with tiny or small features])
992 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000993 AC_SUBST(vi_cv_path_perl)
994 AC_PATH_PROG(vi_cv_path_perl, perl)
995 if test "X$vi_cv_path_perl" != "X"; then
996 AC_MSG_CHECKING(Perl version)
997 if $vi_cv_path_perl -e 'require 5.003_01' >/dev/null 2>/dev/null; then
998 eval `$vi_cv_path_perl -V:usethreads`
Bram Moolenaare06c1882010-07-21 22:05:20 +0200999 eval `$vi_cv_path_perl -V:libperl`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001000 if test "X$usethreads" = "XUNKNOWN" -o "X$usethreads" = "Xundef"; then
1001 badthreads=no
1002 else
1003 if $vi_cv_path_perl -e 'require 5.6.0' >/dev/null 2>/dev/null; then
1004 eval `$vi_cv_path_perl -V:use5005threads`
1005 if test "X$use5005threads" = "XUNKNOWN" -o "X$use5005threads" = "Xundef"; then
1006 badthreads=no
1007 else
1008 badthreads=yes
1009 AC_MSG_RESULT(>>> Perl > 5.6 with 5.5 threads cannot be used <<<)
1010 fi
1011 else
1012 badthreads=yes
1013 AC_MSG_RESULT(>>> Perl 5.5 with threads cannot be used <<<)
1014 fi
1015 fi
1016 if test $badthreads = no; then
1017 AC_MSG_RESULT(OK)
1018 eval `$vi_cv_path_perl -V:shrpenv`
1019 if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04
1020 shrpenv=""
1021 fi
1022 vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlibexp}'`
1023 AC_SUBST(vi_cv_perllib)
Bram Moolenaard5f62b12014-08-17 17:05:44 +02001024 vi_cv_perl_extutils=unknown_perl_extutils_path
1025 for extutils_rel_path in ExtUtils vendor_perl/ExtUtils; do
1026 xsubpp_path="$vi_cv_perllib/$extutils_rel_path/xsubpp"
1027 if test -f "$xsubpp_path"; then
1028 vi_cv_perl_xsubpp="$xsubpp_path"
1029 fi
1030 done
1031 AC_SUBST(vi_cv_perl_xsubpp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001032 dnl Remove "-fno-something", it breaks using cproto.
Bram Moolenaar280a8682015-06-21 13:41:08 +02001033 dnl Remove "-fdebug-prefix-map", it isn't supported by clang.
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001034 dnl Remove "FORTIFY_SOURCE", it will be defined twice.
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001035 dnl remove -pipe and -Wxxx, it confuses cproto
Bram Moolenaar071d4272004-06-13 20:20:40 +00001036 perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001037 -e 'ccflags;perl_inc;print"\n"' | sed -e 's/-fno[[^ ]]*//' \
1038 -e 's/-fdebug-prefix-map[[^ ]]*//g' \
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001039 -e 's/-pipe //' \
1040 -e 's/-W[[^ ]]*//g' \
1041 -e 's/-D_FORTIFY_SOURCE=.//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001042 dnl Remove "-lc", it breaks on FreeBSD when using "-pthread".
1043 perllibs=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed -e 'ldopts' | \
1044 sed -e '/Warning/d' -e '/Note (probably harmless)/d' \
1045 -e 's/-bE:perl.exp//' -e 's/-lc //'`
1046 dnl Don't add perl lib to $LIBS: if it's not in LD_LIBRARY_PATH
1047 dnl a test in configure may fail because of that.
1048 perlldflags=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed \
1049 -e 'ccdlflags' | sed -e 's/-bE:perl.exp//'`
1050
1051 dnl check that compiling a simple program still works with the flags
1052 dnl added for Perl.
1053 AC_MSG_CHECKING([if compile and link flags for Perl are sane])
1054 cflags_save=$CFLAGS
1055 libs_save=$LIBS
1056 ldflags_save=$LDFLAGS
1057 CFLAGS="$CFLAGS $perlcppflags"
1058 LIBS="$LIBS $perllibs"
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001059 perlldflags=`echo "$perlldflags" | sed -e 's/^ *//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001060 LDFLAGS="$perlldflags $LDFLAGS"
1061 AC_TRY_LINK(,[ ],
1062 AC_MSG_RESULT(yes); perl_ok=yes,
1063 AC_MSG_RESULT(no: PERL DISABLED); perl_ok=no)
1064 CFLAGS=$cflags_save
1065 LIBS=$libs_save
1066 LDFLAGS=$ldflags_save
1067 if test $perl_ok = yes; then
1068 if test "X$perlcppflags" != "X"; then
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001069 PERL_CFLAGS=$perlcppflags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001070 fi
1071 if test "X$perlldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001072 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$perlldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001073 LDFLAGS="$perlldflags $LDFLAGS"
1074 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001075 fi
1076 PERL_LIBS=$perllibs
1077 PERL_SRC="auto/if_perl.c if_perlsfio.c"
1078 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o"
1079 PERL_PRO="if_perl.pro if_perlsfio.pro"
1080 AC_DEFINE(FEAT_PERL)
1081 fi
1082 fi
1083 else
1084 AC_MSG_RESULT(>>> too old; need Perl version 5.003_01 or later <<<)
1085 fi
1086 fi
1087
Bram Moolenaard0573012017-10-28 21:11:06 +02001088 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00001089 dnl Mac OS X 10.2 or later
Bram Moolenaar071d4272004-06-13 20:20:40 +00001090 dir=/System/Library/Perl
1091 darwindir=$dir/darwin
1092 if test -d $darwindir; then
1093 PERL=/usr/bin/perl
1094 else
1095 dnl Mac OS X 10.3
1096 dir=/System/Library/Perl/5.8.1
1097 darwindir=$dir/darwin-thread-multi-2level
1098 if test -d $darwindir; then
1099 PERL=/usr/bin/perl
1100 fi
1101 fi
1102 if test -n "$PERL"; then
1103 PERL_DIR="$dir"
1104 PERL_CFLAGS="-DFEAT_PERL -I$darwindir/CORE"
1105 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o $darwindir/auto/DynaLoader/DynaLoader.a"
1106 PERL_LIBS="-L$darwindir/CORE -lperl"
1107 fi
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001108 dnl Perl on Mac OS X 10.5 adds "-arch" flags but these should only
1109 dnl be included if requested by passing --with-mac-arch to
1110 dnl configure, so strip these flags first (if present)
1111 PERL_LIBS=`echo "$PERL_LIBS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
1112 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 +00001113 fi
Bram Moolenaare06c1882010-07-21 22:05:20 +02001114 if test "$enable_perlinterp" = "dynamic"; then
1115 if test "$perl_ok" = "yes" -a "X$libperl" != "X"; then
1116 AC_DEFINE(DYNAMIC_PERL)
1117 PERL_CFLAGS="-DDYNAMIC_PERL_DLL=\\\"$libperl\\\" $PERL_CFLAGS"
1118 fi
1119 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001120
1121 if test "$fail_if_missing" = "yes" -a "$perl_ok" != "yes"; then
1122 AC_MSG_ERROR([could not configure perl])
1123 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001124fi
1125AC_SUBST(shrpenv)
1126AC_SUBST(PERL_SRC)
1127AC_SUBST(PERL_OBJ)
1128AC_SUBST(PERL_PRO)
1129AC_SUBST(PERL_CFLAGS)
1130AC_SUBST(PERL_LIBS)
1131
1132AC_MSG_CHECKING(--enable-pythoninterp argument)
1133AC_ARG_ENABLE(pythoninterp,
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001134 [ --enable-pythoninterp[=OPTS] Include Python interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001135 [enable_pythoninterp="no"])
1136AC_MSG_RESULT($enable_pythoninterp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001137if test "$enable_pythoninterp" = "yes" -o "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001138 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1139 AC_MSG_ERROR([cannot use Python with tiny or small features])
1140 fi
1141
Bram Moolenaar071d4272004-06-13 20:20:40 +00001142 dnl -- find the python executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001143 AC_MSG_CHECKING(--with-python-command argument)
1144 AC_SUBST(vi_cv_path_python)
1145 AC_ARG_WITH(python-command, [ --with-python-command=NAME name of the Python 2 command (default: python2 or python)],
1146 vi_cv_path_python="$withval"; AC_MSG_RESULT($vi_cv_path_python),
1147 AC_MSG_RESULT(no))
1148
1149 if test "X$vi_cv_path_python" = "X"; then
1150 AC_PATH_PROGS(vi_cv_path_python, python2 python)
1151 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001152 if test "X$vi_cv_path_python" != "X"; then
1153
1154 dnl -- get its version number
1155 AC_CACHE_CHECK(Python version,vi_cv_var_python_version,
1156 [[vi_cv_var_python_version=`
1157 ${vi_cv_path_python} -c 'import sys; print sys.version[:3]'`
1158 ]])
1159
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001160 dnl -- it must be at least version 2.3
1161 AC_MSG_CHECKING(Python is 2.3 or better)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001162 if ${vi_cv_path_python} -c \
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001163 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001164 then
1165 AC_MSG_RESULT(yep)
1166
1167 dnl -- find where python thinks it was installed
1168 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python_pfx,
1169 [ vi_cv_path_python_pfx=`
1170 ${vi_cv_path_python} -c \
1171 "import sys; print sys.prefix"` ])
1172
1173 dnl -- and where it thinks it runs
1174 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python_epfx,
1175 [ vi_cv_path_python_epfx=`
1176 ${vi_cv_path_python} -c \
1177 "import sys; print sys.exec_prefix"` ])
1178
1179 dnl -- python's internal library path
1180
1181 AC_CACHE_VAL(vi_cv_path_pythonpath,
1182 [ vi_cv_path_pythonpath=`
1183 unset PYTHONPATH;
1184 ${vi_cv_path_python} -c \
1185 "import sys, string; print string.join(sys.path,':')"` ])
1186
1187 dnl -- where the Python implementation library archives are
1188
1189 AC_ARG_WITH(python-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001190 [ --with-python-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001191 [ vi_cv_path_python_conf="${withval}"; have_python_config_dir=1 ] )
Bram Moolenaar071d4272004-06-13 20:20:40 +00001192
1193 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python_conf,
1194 [
1195 vi_cv_path_python_conf=
Bram Moolenaarac499e32013-06-02 19:14:17 +02001196 d=`${vi_cv_path_python} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBPL')"`
1197 if test -d "$d" && test -f "$d/config.c"; then
1198 vi_cv_path_python_conf="$d"
1199 else
1200 for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
1201 for subdir in lib64 lib share; do
1202 d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
1203 if test -d "$d" && test -f "$d/config.c"; then
1204 vi_cv_path_python_conf="$d"
1205 fi
1206 done
Bram Moolenaar071d4272004-06-13 20:20:40 +00001207 done
Bram Moolenaarac499e32013-06-02 19:14:17 +02001208 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001209 ])
1210
1211 PYTHON_CONFDIR="${vi_cv_path_python_conf}"
1212
1213 if test "X$PYTHON_CONFDIR" = "X"; then
1214 AC_MSG_RESULT([can't find it!])
1215 else
1216
1217 dnl -- we need to examine Python's config/Makefile too
1218 dnl see what the interpreter is built from
1219 AC_CACHE_VAL(vi_cv_path_python_plibs,
1220 [
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001221 pwd=`pwd`
1222 tmp_mkf="$pwd/config-PyMake$$"
1223 cat -- "${PYTHON_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001224__:
Bram Moolenaar218116c2010-05-20 21:46:00 +02001225 @echo "python_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001226 @echo "python_LIBS='$(LIBS)'"
1227 @echo "python_SYSLIBS='$(SYSLIBS)'"
1228 @echo "python_LINKFORSHARED='$(LINKFORSHARED)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001229 @echo "python_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001230 @echo "python_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001231 @echo "python_PYTHONFRAMEWORK='$(PYTHONFRAMEWORK)'"
1232 @echo "python_PYTHONFRAMEWORKPREFIX='$(PYTHONFRAMEWORKPREFIX)'"
1233 @echo "python_PYTHONFRAMEWORKINSTALLDIR='$(PYTHONFRAMEWORKINSTALLDIR)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001234eof
1235 dnl -- delete the lines from make about Entering/Leaving directory
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001236 eval "`cd ${PYTHON_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1237 rm -f -- "${tmp_mkf}"
Bram Moolenaard0573012017-10-28 21:11:06 +02001238 if test "x$MACOS_X" = "xyes" && test -n "${python_PYTHONFRAMEWORK}" && ${vi_cv_path_python} -c \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001239 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then
1240 vi_cv_path_python_plibs="-framework Python"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001241 if test "x${vi_cv_path_python}" != "x/usr/bin/python" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
1242 vi_cv_path_python_plibs="-F${python_PYTHONFRAMEWORKPREFIX} -framework Python"
1243 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001244 else
Bram Moolenaar9ce42132018-04-11 22:19:36 +02001245 vi_cv_path_python_plibs="-L${PYTHON_CONFDIR} -lpython${vi_cv_var_python_version}"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001246 dnl -- Check if the path contained in python_LINKFORSHARED is
1247 dnl usable for vim build. If not, make and try other
1248 dnl candidates.
Bram Moolenaara161e262015-03-24 15:14:27 +01001249 if test -n "${python_LINKFORSHARED}" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
Bram Moolenaar6c927552015-03-24 12:21:33 +01001250 python_link_symbol=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]].*/\1/'`
1251 python_link_path=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]][[ \t]]*\(.*\)/\2/'`
1252 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1253 dnl -- The path looks relative. Guess the absolute one using
1254 dnl the prefix and try that.
1255 python_link_path="${python_PYTHONFRAMEWORKPREFIX}/${python_link_path}"
1256 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1257 dnl -- A last resort.
1258 python_link_path="${python_PYTHONFRAMEWORKINSTALLDIR}/Versions/${vi_cv_var_python_version}/${python_PYTHONFRAMEWORK}"
1259 dnl -- No check is done. The last word is left to the
1260 dnl "sanity" test on link flags that follows shortly.
1261 fi
1262 python_LINKFORSHARED="${python_link_symbol} ${python_link_path}"
1263 fi
1264 fi
Bram Moolenaar218116c2010-05-20 21:46:00 +02001265 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 +00001266 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1267 vi_cv_path_python_plibs=`echo $vi_cv_path_python_plibs | sed s/-ltermcap//`
1268 fi
1269 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001270 AC_CACHE_CHECK(Python's dll name,vi_cv_dll_name_python,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001271 [
1272 if test "X$python_DLLLIBRARY" != "X"; then
1273 vi_cv_dll_name_python="$python_DLLLIBRARY"
1274 else
1275 vi_cv_dll_name_python="$python_INSTSONAME"
1276 fi
1277 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00001278
1279 PYTHON_LIBS="${vi_cv_path_python_plibs}"
1280 if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001281 PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001282 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001283 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 +00001284 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001285 if test "X$have_python_config_dir" = "X1" -a "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001286 dnl Define PYTHON_HOME if --with-python-config-dir was used
1287 PYTHON_CFLAGS="${PYTHON_CFLAGS} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'"
1288
1289 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001290 PYTHON_SRC="if_python.c"
Bram Moolenaar9bdb9a02012-07-25 16:32:08 +02001291 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001292
1293 dnl On FreeBSD linking with "-pthread" is required to use threads.
1294 dnl _THREAD_SAFE must be used for compiling then.
1295 dnl The "-pthread" is added to $LIBS, so that the following check for
1296 dnl sigaltstack() will look in libc_r (it's there in libc!).
1297 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1298 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1299 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1300 AC_MSG_CHECKING([if -pthread should be used])
1301 threadsafe_flag=
1302 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001303 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00001304 if test "`(uname) 2>/dev/null`" != Darwin; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001305 test "$GCC" = yes && threadsafe_flag="-pthread"
1306 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1307 threadsafe_flag="-D_THREAD_SAFE"
1308 thread_lib="-pthread"
1309 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001310 if test "`(uname) 2>/dev/null`" = SunOS; then
1311 threadsafe_flag="-pthreads"
1312 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001313 fi
1314 libs_save_old=$LIBS
1315 if test -n "$threadsafe_flag"; then
1316 cflags_save=$CFLAGS
1317 CFLAGS="$CFLAGS $threadsafe_flag"
1318 LIBS="$LIBS $thread_lib"
1319 AC_TRY_LINK(,[ ],
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001320 AC_MSG_RESULT(yes); PYTHON_CFLAGS="$PYTHON_CFLAGS $threadsafe_flag",
Bram Moolenaar071d4272004-06-13 20:20:40 +00001321 AC_MSG_RESULT(no); LIBS=$libs_save_old
1322 )
1323 CFLAGS=$cflags_save
1324 else
1325 AC_MSG_RESULT(no)
1326 fi
1327
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001328 dnl Check that compiling a simple program still works with the flags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001329 dnl added for Python.
1330 AC_MSG_CHECKING([if compile and link flags for Python are sane])
1331 cflags_save=$CFLAGS
1332 libs_save=$LIBS
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001333 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001334 LIBS="$LIBS $PYTHON_LIBS"
1335 AC_TRY_LINK(,[ ],
1336 AC_MSG_RESULT(yes); python_ok=yes,
1337 AC_MSG_RESULT(no: PYTHON DISABLED); python_ok=no)
1338 CFLAGS=$cflags_save
1339 LIBS=$libs_save
1340 if test $python_ok = yes; then
1341 AC_DEFINE(FEAT_PYTHON)
1342 else
1343 LIBS=$libs_save_old
1344 PYTHON_SRC=
1345 PYTHON_OBJ=
1346 PYTHON_LIBS=
1347 PYTHON_CFLAGS=
1348 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001349 fi
1350 else
1351 AC_MSG_RESULT(too old)
1352 fi
1353 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001354
1355 if test "$fail_if_missing" = "yes" -a "$python_ok" != "yes"; then
1356 AC_MSG_ERROR([could not configure python])
1357 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001358fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001359
Bram Moolenaar071d4272004-06-13 20:20:40 +00001360AC_SUBST(PYTHON_LIBS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001361AC_SUBST(PYTHON_CFLAGS)
1362AC_SUBST(PYTHON_SRC)
1363AC_SUBST(PYTHON_OBJ)
1364
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001365
1366AC_MSG_CHECKING(--enable-python3interp argument)
1367AC_ARG_ENABLE(python3interp,
Bram Moolenaar8008b632017-07-18 21:33:20 +02001368 [ --enable-python3interp[=OPTS] Include Python3 interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001369 [enable_python3interp="no"])
1370AC_MSG_RESULT($enable_python3interp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001371if test "$enable_python3interp" = "yes" -o "$enable_python3interp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001372 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1373 AC_MSG_ERROR([cannot use Python with tiny or small features])
1374 fi
1375
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001376 dnl -- find the python3 executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001377 AC_MSG_CHECKING(--with-python3-command argument)
1378 AC_SUBST(vi_cv_path_python3)
1379 AC_ARG_WITH(python3-command, [ --with-python3-command=NAME name of the Python 3 command (default: python3 or python)],
1380 vi_cv_path_python3="$withval"; AC_MSG_RESULT($vi_cv_path_python3),
1381 AC_MSG_RESULT(no))
1382
1383 if test "X$vi_cv_path_python3" = "X"; then
1384 AC_PATH_PROGS(vi_cv_path_python3, python3 python)
1385 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001386 if test "X$vi_cv_path_python3" != "X"; then
1387
1388 dnl -- get its version number
1389 AC_CACHE_CHECK(Python version,vi_cv_var_python3_version,
1390 [[vi_cv_var_python3_version=`
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001391 ${vi_cv_path_python3} -c 'import sys; print(sys.version[:3])'`
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001392 ]])
1393
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001394 dnl -- it must be at least version 3
1395 AC_MSG_CHECKING(Python is 3.0 or better)
1396 if ${vi_cv_path_python3} -c \
1397 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.0)"
1398 then
1399 AC_MSG_RESULT(yep)
Bram Moolenaar456f2bb2011-06-12 21:37:13 +02001400
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001401 dnl -- get abiflags for python 3.2 or higher (PEP 3149)
1402 AC_CACHE_CHECK(Python's abiflags,vi_cv_var_python3_abiflags,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001403 [
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001404 vi_cv_var_python3_abiflags=
1405 if ${vi_cv_path_python3} -c \
1406 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)"
1407 then
1408 vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \
1409 "import sys; print(sys.abiflags)"`
1410 fi ])
1411
1412 dnl -- find where python3 thinks it was installed
1413 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx,
1414 [ vi_cv_path_python3_pfx=`
1415 ${vi_cv_path_python3} -c \
1416 "import sys; print(sys.prefix)"` ])
1417
1418 dnl -- and where it thinks it runs
1419 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx,
1420 [ vi_cv_path_python3_epfx=`
1421 ${vi_cv_path_python3} -c \
1422 "import sys; print(sys.exec_prefix)"` ])
1423
1424 dnl -- python3's internal library path
1425
1426 AC_CACHE_VAL(vi_cv_path_python3path,
1427 [ vi_cv_path_python3path=`
1428 unset PYTHONPATH;
1429 ${vi_cv_path_python3} -c \
1430 "import sys, string; print(':'.join(sys.path))"` ])
1431
1432 dnl -- where the Python implementation library archives are
1433
1434 AC_ARG_WITH(python3-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001435 [ --with-python3-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001436 [ vi_cv_path_python3_conf="${withval}"; have_python3_config_dir=1 ] )
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001437
1438 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf,
1439 [
1440 vi_cv_path_python3_conf=
Bram Moolenaarfee496d2013-07-12 20:07:24 +02001441 config_dir="config-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001442 d=`${vi_cv_path_python3} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBPL'))"`
1443 if test -d "$d" && test -f "$d/config.c"; then
1444 vi_cv_path_python3_conf="$d"
1445 else
1446 for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do
1447 for subdir in lib64 lib share; do
1448 d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}"
1449 if test -d "$d" && test -f "$d/config.c"; then
1450 vi_cv_path_python3_conf="$d"
1451 fi
1452 done
1453 done
1454 fi
1455 ])
1456
1457 PYTHON3_CONFDIR="${vi_cv_path_python3_conf}"
1458
1459 if test "X$PYTHON3_CONFDIR" = "X"; then
1460 AC_MSG_RESULT([can't find it!])
1461 else
1462
1463 dnl -- we need to examine Python's config/Makefile too
1464 dnl see what the interpreter is built from
1465 AC_CACHE_VAL(vi_cv_path_python3_plibs,
1466 [
1467 pwd=`pwd`
1468 tmp_mkf="$pwd/config-PyMake$$"
1469 cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001470__:
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001471 @echo "python3_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001472 @echo "python3_LIBS='$(LIBS)'"
1473 @echo "python3_SYSLIBS='$(SYSLIBS)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001474 @echo "python3_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001475 @echo "python3_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001476eof
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001477 dnl -- delete the lines from make about Entering/Leaving directory
1478 eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1479 rm -f -- "${tmp_mkf}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001480 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 +02001481 vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}"
1482 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1483 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//`
1484 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//`
1485 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001486 AC_CACHE_CHECK(Python3's dll name,vi_cv_dll_name_python3,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001487 [
1488 if test "X$python3_DLLLIBRARY" != "X"; then
1489 vi_cv_dll_name_python3="$python3_DLLLIBRARY"
1490 else
1491 vi_cv_dll_name_python3="$python3_INSTSONAME"
1492 fi
1493 ])
1494
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001495 PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
1496 if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001497 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 +02001498 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001499 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 +02001500 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001501 if test "X$have_python3_config_dir" = "X1" -a "$enable_python3interp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001502 dnl Define PYTHON3_HOME if --with-python-config-dir was used
1503 PYTHON3_CFLAGS="${PYTHON3_CFLAGS} -DPYTHON3_HOME='L\"${vi_cv_path_python3_pfx}\"'"
1504 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001505 PYTHON3_SRC="if_python3.c"
1506 PYTHON3_OBJ="objects/if_python3.o"
1507
1508 dnl On FreeBSD linking with "-pthread" is required to use threads.
1509 dnl _THREAD_SAFE must be used for compiling then.
1510 dnl The "-pthread" is added to $LIBS, so that the following check for
1511 dnl sigaltstack() will look in libc_r (it's there in libc!).
1512 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1513 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1514 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1515 AC_MSG_CHECKING([if -pthread should be used])
1516 threadsafe_flag=
1517 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001518 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001519 if test "`(uname) 2>/dev/null`" != Darwin; then
1520 test "$GCC" = yes && threadsafe_flag="-pthread"
1521 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1522 threadsafe_flag="-D_THREAD_SAFE"
1523 thread_lib="-pthread"
1524 fi
1525 if test "`(uname) 2>/dev/null`" = SunOS; then
1526 threadsafe_flag="-pthreads"
1527 fi
1528 fi
1529 libs_save_old=$LIBS
1530 if test -n "$threadsafe_flag"; then
1531 cflags_save=$CFLAGS
1532 CFLAGS="$CFLAGS $threadsafe_flag"
1533 LIBS="$LIBS $thread_lib"
1534 AC_TRY_LINK(,[ ],
1535 AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag",
1536 AC_MSG_RESULT(no); LIBS=$libs_save_old
1537 )
1538 CFLAGS=$cflags_save
1539 else
1540 AC_MSG_RESULT(no)
1541 fi
1542
1543 dnl check that compiling a simple program still works with the flags
1544 dnl added for Python.
1545 AC_MSG_CHECKING([if compile and link flags for Python 3 are sane])
1546 cflags_save=$CFLAGS
1547 libs_save=$LIBS
1548 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1549 LIBS="$LIBS $PYTHON3_LIBS"
1550 AC_TRY_LINK(,[ ],
1551 AC_MSG_RESULT(yes); python3_ok=yes,
1552 AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no)
1553 CFLAGS=$cflags_save
1554 LIBS=$libs_save
1555 if test "$python3_ok" = yes; then
1556 AC_DEFINE(FEAT_PYTHON3)
1557 else
1558 LIBS=$libs_save_old
1559 PYTHON3_SRC=
1560 PYTHON3_OBJ=
1561 PYTHON3_LIBS=
1562 PYTHON3_CFLAGS=
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001563 fi
1564 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001565 else
1566 AC_MSG_RESULT(too old)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001567 fi
1568 fi
Bram Moolenaar1612b1a2013-06-14 21:22:39 +02001569 if test "$fail_if_missing" = "yes" -a "$python3_ok" != "yes"; then
1570 AC_MSG_ERROR([could not configure python3])
1571 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001572fi
1573
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001574AC_SUBST(PYTHON3_LIBS)
1575AC_SUBST(PYTHON3_CFLAGS)
1576AC_SUBST(PYTHON3_SRC)
1577AC_SUBST(PYTHON3_OBJ)
1578
1579dnl if python2.x and python3.x are enabled one can only link in code
1580dnl with dlopen(), dlsym(), dlclose()
1581if test "$python_ok" = yes && test "$python3_ok" = yes; then
1582 AC_DEFINE(DYNAMIC_PYTHON)
1583 AC_DEFINE(DYNAMIC_PYTHON3)
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001584 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001585 cflags_save=$CFLAGS
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001586 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001587 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001588 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001589 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001590 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001591 #include <dlfcn.h>
1592 /* If this program fails, then RTLD_GLOBAL is needed.
1593 * RTLD_GLOBAL will be used and then it is not possible to
1594 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001595 * Only the first python version used will be switched on.
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001596 */
1597
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001598 int no_rtl_global_needed_for(char *python_instsoname, char *prefix)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001599 {
1600 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001601 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001602 if (pylib != 0)
1603 {
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001604 void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome");
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001605 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1606 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1607 void (*final)(void) = dlsym(pylib, "Py_Finalize");
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001608 (*pfx)(prefix);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001609 (*init)();
1610 needed = (*simple)("import termios") == -1;
1611 (*final)();
1612 dlclose(pylib);
1613 }
1614 return !needed;
1615 }
1616
1617 int main(int argc, char** argv)
1618 {
1619 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001620 if (no_rtl_global_needed_for("${vi_cv_dll_name_python}", "${vi_cv_path_python_pfx}"))
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001621 not_needed = 1;
1622 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001623 }])],
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001624 [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001625
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001626 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001627 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001628
1629 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python3)
1630 cflags_save=$CFLAGS
1631 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001632 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001633 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001634 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001635 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001636 #include <dlfcn.h>
1637 #include <wchar.h>
1638 /* If this program fails, then RTLD_GLOBAL is needed.
1639 * RTLD_GLOBAL will be used and then it is not possible to
1640 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001641 * Only the first python version used will be switched on.
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001642 */
1643
1644 int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix)
1645 {
1646 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001647 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001648 if (pylib != 0)
1649 {
1650 void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome");
1651 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1652 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1653 void (*final)(void) = dlsym(pylib, "Py_Finalize");
1654 (*pfx)(prefix);
1655 (*init)();
1656 needed = (*simple)("import termios") == -1;
1657 (*final)();
1658 dlclose(pylib);
1659 }
1660 return !needed;
1661 }
1662
1663 int main(int argc, char** argv)
1664 {
1665 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001666 if (no_rtl_global_needed_for("${vi_cv_dll_name_python3}", L"${vi_cv_path_python3_pfx}"))
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001667 not_needed = 1;
1668 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001669 }])],
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001670 [AC_MSG_RESULT(yes);AC_DEFINE(PY3_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
1671
1672 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001673 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001674
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001675 PYTHON_SRC="if_python.c"
1676 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001677 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001678 PYTHON_LIBS=
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 Moolenaarbd5e15f2010-07-17 21:19:38 +02001682 PYTHON3_LIBS=
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001683elif test "$python_ok" = yes && test "$enable_pythoninterp" = "dynamic"; then
1684 AC_DEFINE(DYNAMIC_PYTHON)
1685 PYTHON_SRC="if_python.c"
1686 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001687 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001688 PYTHON_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001689elif test "$python_ok" = yes; then
1690 dnl Check that adding -fPIE works. It may be needed when using a static
1691 dnl Python library.
1692 AC_MSG_CHECKING([if -fPIE can be added for Python])
1693 cflags_save=$CFLAGS
1694 libs_save=$LIBS
1695 CFLAGS="$CFLAGS $PYTHON_CFLAGS -fPIE"
1696 LIBS="$LIBS $PYTHON_LIBS"
1697 AC_TRY_LINK(,[ ],
1698 AC_MSG_RESULT(yes); fpie_ok=yes,
1699 AC_MSG_RESULT(no); fpie_ok=no)
1700 CFLAGS=$cflags_save
1701 LIBS=$libs_save
1702 if test $fpie_ok = yes; then
1703 PYTHON_CFLAGS="$PYTHON_CFLAGS -fPIE"
1704 fi
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001705elif test "$python3_ok" = yes && test "$enable_python3interp" = "dynamic"; then
1706 AC_DEFINE(DYNAMIC_PYTHON3)
1707 PYTHON3_SRC="if_python3.c"
1708 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001709 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001710 PYTHON3_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001711elif test "$python3_ok" = yes; then
1712 dnl Check that adding -fPIE works. It may be needed when using a static
1713 dnl Python library.
1714 AC_MSG_CHECKING([if -fPIE can be added for Python3])
1715 cflags_save=$CFLAGS
1716 libs_save=$LIBS
1717 CFLAGS="$CFLAGS $PYTHON3_CFLAGS -fPIE"
1718 LIBS="$LIBS $PYTHON3_LIBS"
1719 AC_TRY_LINK(,[ ],
1720 AC_MSG_RESULT(yes); fpie_ok=yes,
1721 AC_MSG_RESULT(no); fpie_ok=no)
1722 CFLAGS=$cflags_save
1723 LIBS=$libs_save
1724 if test $fpie_ok = yes; then
1725 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -fPIE"
1726 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001727fi
1728
Bram Moolenaar071d4272004-06-13 20:20:40 +00001729AC_MSG_CHECKING(--enable-tclinterp argument)
1730AC_ARG_ENABLE(tclinterp,
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001731 [ --enable-tclinterp[=OPTS] Include Tcl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001732 [enable_tclinterp="no"])
1733AC_MSG_RESULT($enable_tclinterp)
1734
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001735if test "$enable_tclinterp" = "yes" -o "$enable_tclinterp" = "dynamic"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001736
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001737 dnl on FreeBSD tclsh is a silly script, look for tclsh8.[5420]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001738 AC_MSG_CHECKING(--with-tclsh argument)
1739 AC_ARG_WITH(tclsh, [ --with-tclsh=PATH which tclsh to use (default: tclsh8.0)],
1740 tclsh_name="$withval"; AC_MSG_RESULT($tclsh_name),
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001741 tclsh_name="tclsh8.5"; AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00001742 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1743 AC_SUBST(vi_cv_path_tcl)
1744
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001745 dnl when no specific version specified, also try 8.4, 8.2 and 8.0
1746 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.5"; then
1747 tclsh_name="tclsh8.4"
1748 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1749 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001750 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.4"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001751 tclsh_name="tclsh8.2"
1752 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1753 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001754 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.2"; then
1755 tclsh_name="tclsh8.0"
1756 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1757 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001758 dnl still didn't find it, try without version number
1759 if test "X$vi_cv_path_tcl" = "X"; then
1760 tclsh_name="tclsh"
1761 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1762 fi
1763 if test "X$vi_cv_path_tcl" != "X"; then
1764 AC_MSG_CHECKING(Tcl version)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001765 if echo 'exit [[expr [info tclversion] < 8.0]]' | "$vi_cv_path_tcl" - ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001766 tclver=`echo 'puts [[info tclversion]]' | $vi_cv_path_tcl -`
1767 AC_MSG_RESULT($tclver - OK);
1768 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 +01001769 tcldll=`echo 'puts libtcl[[info tclversion]][[info sharedlibextension]]' | $vi_cv_path_tcl -`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001770
1771 AC_MSG_CHECKING(for location of Tcl include)
Bram Moolenaard0573012017-10-28 21:11:06 +02001772 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001773 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 +00001774 else
1775 dnl For Mac OS X 10.3, use the OS-provided framework location
1776 tclinc="/System/Library/Frameworks/Tcl.framework/Headers"
1777 fi
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001778 TCL_INC=
Bram Moolenaar071d4272004-06-13 20:20:40 +00001779 for try in $tclinc; do
1780 if test -f "$try/tcl.h"; then
1781 AC_MSG_RESULT($try/tcl.h)
1782 TCL_INC=$try
1783 break
1784 fi
1785 done
1786 if test -z "$TCL_INC"; then
1787 AC_MSG_RESULT(<not found>)
1788 SKIP_TCL=YES
1789 fi
1790 if test -z "$SKIP_TCL"; then
1791 AC_MSG_CHECKING(for location of tclConfig.sh script)
Bram Moolenaard0573012017-10-28 21:11:06 +02001792 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001793 tclcnf=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001794 tclcnf="$tclcnf `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001795 else
1796 dnl For Mac OS X 10.3, use the OS-provided framework location
1797 tclcnf="/System/Library/Frameworks/Tcl.framework"
1798 fi
1799 for try in $tclcnf; do
Bram Moolenaar49222be2015-12-11 18:11:30 +01001800 if test -f "$try/tclConfig.sh"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001801 AC_MSG_RESULT($try/tclConfig.sh)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001802 . "$try/tclConfig.sh"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001803 dnl use eval, because tcl 8.2 includes ${TCL_DBGX}
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001804 if test "$enable_tclinterp" = "dynamic"; then
1805 TCL_LIBS=`eval echo "$TCL_STUB_LIB_SPEC $TCL_LIBS"`
1806 else
1807 TCL_LIBS=`eval echo "$TCL_LIB_SPEC $TCL_LIBS"`
1808 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001809 dnl Use $TCL_DEFS for -D_THREAD_SAFE et al. But only use the
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001810 dnl "-D_ABC" items. Watch out for -DFOO=long\ long.
Bram Moolenaar4394bff2008-07-24 11:21:31 +00001811 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 +00001812 break
1813 fi
1814 done
1815 if test -z "$TCL_LIBS"; then
1816 AC_MSG_RESULT(<not found>)
1817 AC_MSG_CHECKING(for Tcl library by myself)
1818 tcllib=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001819 tcllib="$tcllib `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001820 for ext in .so .a ; do
1821 for ver in "" $tclver ; do
1822 for try in $tcllib ; do
1823 trylib=tcl$ver$ext
Bram Moolenaar49222be2015-12-11 18:11:30 +01001824 if test -f "$try/lib$trylib" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001825 AC_MSG_RESULT($try/lib$trylib)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001826 TCL_LIBS="-L\"$try\" -ltcl$ver -ldl -lm"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001827 if test "`(uname) 2>/dev/null`" = SunOS &&
1828 uname -r | grep '^5' >/dev/null; then
1829 TCL_LIBS="$TCL_LIBS -R $try"
1830 fi
1831 break 3
1832 fi
1833 done
1834 done
1835 done
1836 if test -z "$TCL_LIBS"; then
1837 AC_MSG_RESULT(<not found>)
1838 SKIP_TCL=YES
1839 fi
1840 fi
1841 if test -z "$SKIP_TCL"; then
1842 AC_DEFINE(FEAT_TCL)
1843 TCL_SRC=if_tcl.c
1844 TCL_OBJ=objects/if_tcl.o
1845 TCL_PRO=if_tcl.pro
1846 TCL_CFLAGS="-I$TCL_INC $TCL_DEFS"
1847 fi
1848 fi
1849 else
1850 AC_MSG_RESULT(too old; need Tcl version 8.0 or later)
1851 fi
1852 fi
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001853 if test "$enable_tclinterp" = "dynamic"; then
1854 if test "X$TCL_SRC" != "X" -a "X$tcldll" != "X"; then
1855 AC_DEFINE(DYNAMIC_TCL)
1856 TCL_CFLAGS="-DDYNAMIC_TCL_DLL=\\\"$tcldll\\\" -DDYNAMIC_TCL_VER=\\\"$tclver\\\" $TCL_CFLAGS"
1857 fi
1858 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001859 if test "$fail_if_missing" = "yes" -a -z "$TCL_SRC"; then
1860 AC_MSG_ERROR([could not configure Tcl])
1861 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001862fi
1863AC_SUBST(TCL_SRC)
1864AC_SUBST(TCL_OBJ)
1865AC_SUBST(TCL_PRO)
1866AC_SUBST(TCL_CFLAGS)
1867AC_SUBST(TCL_LIBS)
1868
1869AC_MSG_CHECKING(--enable-rubyinterp argument)
1870AC_ARG_ENABLE(rubyinterp,
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001871 [ --enable-rubyinterp[=OPTS] Include Ruby interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001872 [enable_rubyinterp="no"])
1873AC_MSG_RESULT($enable_rubyinterp)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001874if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001875 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1876 AC_MSG_ERROR([cannot use Ruby with tiny or small features])
1877 fi
1878
Bram Moolenaar165641d2010-02-17 16:23:09 +01001879 AC_MSG_CHECKING(--with-ruby-command argument)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001880 AC_SUBST(vi_cv_path_ruby)
Bram Moolenaar948733a2011-05-05 18:10:16 +02001881 AC_ARG_WITH(ruby-command, [ --with-ruby-command=RUBY name of the Ruby command (default: ruby)],
1882 RUBY_CMD="$withval"; vi_cv_path_ruby="$withval"; AC_MSG_RESULT($RUBY_CMD),
1883 RUBY_CMD="ruby"; AC_MSG_RESULT(defaulting to $RUBY_CMD))
Bram Moolenaar165641d2010-02-17 16:23:09 +01001884 AC_PATH_PROG(vi_cv_path_ruby, $RUBY_CMD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001885 if test "X$vi_cv_path_ruby" != "X"; then
1886 AC_MSG_CHECKING(Ruby version)
Bram Moolenaare4efc3b2005-03-07 23:16:51 +00001887 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 +00001888 AC_MSG_RESULT(OK)
Bram Moolenaar81398892012-10-03 21:09:35 +02001889 AC_MSG_CHECKING(Ruby rbconfig)
1890 ruby_rbconfig="RbConfig"
1891 if ! $vi_cv_path_ruby -r rbconfig -e 'RbConfig' >/dev/null 2>/dev/null; then
1892 ruby_rbconfig="Config"
1893 fi
1894 AC_MSG_RESULT($ruby_rbconfig)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001895 AC_MSG_CHECKING(Ruby header files)
Bram Moolenaar81398892012-10-03 21:09:35 +02001896 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 +00001897 if test "X$rubyhdrdir" != "X"; then
1898 AC_MSG_RESULT($rubyhdrdir)
1899 RUBY_CFLAGS="-I$rubyhdrdir"
Bram Moolenaara6fd37b2014-03-27 17:19:09 +01001900 rubyarchdir=`$vi_cv_path_ruby -r rbconfig -e "print ($ruby_rbconfig::CONFIG.has_key? 'rubyarchhdrdir') ? $ruby_rbconfig::CONFIG[['rubyarchhdrdir']] : '$rubyhdrdir/'+$ruby_rbconfig::CONFIG[['arch']]"`
1901 if test -d "$rubyarchdir"; then
1902 RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyarchdir"
Bram Moolenaar165641d2010-02-17 16:23:09 +01001903 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001904 rubyversion=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['ruby_version']].gsub(/\./, '')[[0,2]]"`
Bram Moolenaar026a4452013-08-07 15:22:23 +02001905 if test "X$rubyversion" = "X"; then
1906 rubyversion=`$vi_cv_path_ruby -e "print ((VERSION rescue RUBY_VERSION)).gsub(/\./, '')[[0,2]]"`
1907 fi
Bram Moolenaar165641d2010-02-17 16:23:09 +01001908 RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
Bram Moolenaar81398892012-10-03 21:09:35 +02001909 rubylibs=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LIBS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001910 if test "X$rubylibs" != "X"; then
1911 RUBY_LIBS="$rubylibs"
1912 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001913 librubyarg=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBYARG']])"`
1914 librubya=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBY_A']])"`
Bram Moolenaarac499e32013-06-02 19:14:17 +02001915 rubylibdir=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['libdir']])"`
Bram Moolenaar948733a2011-05-05 18:10:16 +02001916 if test -f "$rubylibdir/$librubya"; then
1917 librubyarg="$librubyarg"
Bram Moolenaarac499e32013-06-02 19:14:17 +02001918 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
1919 elif test "$librubyarg" = "libruby.a"; then
1920 dnl required on Mac OS 10.3 where libruby.a doesn't exist
1921 librubyarg="-lruby"
1922 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001923 fi
1924
1925 if test "X$librubyarg" != "X"; then
1926 RUBY_LIBS="$librubyarg $RUBY_LIBS"
1927 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001928 rubyldflags=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LDFLAGS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001929 if test "X$rubyldflags" != "X"; then
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001930 dnl Ruby on Mac OS X 10.5 adds "-arch" flags but these should only
1931 dnl be included if requested by passing --with-mac-arch to
1932 dnl configure, so strip these flags first (if present)
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001933 rubyldflags=`echo "$rubyldflags" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001934 if test "X$rubyldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001935 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$rubyldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001936 LDFLAGS="$rubyldflags $LDFLAGS"
1937 fi
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001938 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001939 fi
1940 RUBY_SRC="if_ruby.c"
1941 RUBY_OBJ="objects/if_ruby.o"
1942 RUBY_PRO="if_ruby.pro"
1943 AC_DEFINE(FEAT_RUBY)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001944 if test "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar92021622017-10-12 12:33:43 +02001945 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_ALIASES']].split[[0]]"`
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001946 AC_DEFINE(DYNAMIC_RUBY)
Bram Moolenaar92021622017-10-12 12:33:43 +02001947 RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby_soname\\\" -DDYNAMIC_RUBY_VER=$rubyversion $RUBY_CFLAGS"
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001948 RUBY_LIBS=
1949 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001950 else
Bram Moolenaar165641d2010-02-17 16:23:09 +01001951 AC_MSG_RESULT(not found; disabling Ruby)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001952 fi
1953 else
1954 AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
1955 fi
1956 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001957
1958 if test "$fail_if_missing" = "yes" -a -z "$RUBY_OBJ"; then
1959 AC_MSG_ERROR([could not configure Ruby])
1960 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001961fi
1962AC_SUBST(RUBY_SRC)
1963AC_SUBST(RUBY_OBJ)
1964AC_SUBST(RUBY_PRO)
1965AC_SUBST(RUBY_CFLAGS)
1966AC_SUBST(RUBY_LIBS)
1967
1968AC_MSG_CHECKING(--enable-cscope argument)
1969AC_ARG_ENABLE(cscope,
1970 [ --enable-cscope Include cscope interface.], ,
1971 [enable_cscope="no"])
1972AC_MSG_RESULT($enable_cscope)
1973if test "$enable_cscope" = "yes"; then
1974 AC_DEFINE(FEAT_CSCOPE)
1975fi
1976
1977AC_MSG_CHECKING(--enable-workshop argument)
1978AC_ARG_ENABLE(workshop,
1979 [ --enable-workshop Include Sun Visual Workshop support.], ,
1980 [enable_workshop="no"])
1981AC_MSG_RESULT($enable_workshop)
1982if test "$enable_workshop" = "yes"; then
1983 AC_DEFINE(FEAT_SUN_WORKSHOP)
1984 WORKSHOP_SRC="workshop.c integration.c"
1985 AC_SUBST(WORKSHOP_SRC)
1986 WORKSHOP_OBJ="objects/workshop.o objects/integration.o"
1987 AC_SUBST(WORKSHOP_OBJ)
1988 if test "${enable_gui-xxx}" = xxx; then
1989 enable_gui=motif
1990 fi
1991fi
1992
1993AC_MSG_CHECKING(--disable-netbeans argument)
1994AC_ARG_ENABLE(netbeans,
1995 [ --disable-netbeans Disable NetBeans integration support.],
1996 , [enable_netbeans="yes"])
1997if test "$enable_netbeans" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01001998 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1999 AC_MSG_RESULT([cannot use NetBeans with tiny or small features])
2000 enable_netbeans="no"
2001 else
2002 AC_MSG_RESULT(no)
2003 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002004else
2005 AC_MSG_RESULT(yes)
2006fi
2007
2008AC_MSG_CHECKING(--disable-channel argument)
2009AC_ARG_ENABLE(channel,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002010 [ --disable-channel Disable process communication support.],
Bram Moolenaare0874f82016-01-24 20:36:41 +01002011 , [enable_channel="yes"])
2012if test "$enable_channel" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002013 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2014 AC_MSG_RESULT([cannot use channels with tiny or small features])
2015 enable_channel="no"
2016 else
2017 AC_MSG_RESULT(no)
2018 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002019else
2020 if test "$enable_netbeans" = "yes"; then
Bram Moolenaar16435482016-01-24 21:31:54 +01002021 AC_MSG_RESULT([yes, netbeans also disabled])
Bram Moolenaare0874f82016-01-24 20:36:41 +01002022 enable_netbeans="no"
2023 else
2024 AC_MSG_RESULT(yes)
2025 fi
2026fi
2027
Bram Moolenaar16435482016-01-24 21:31:54 +01002028if test "$enable_channel" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002029 dnl On Solaris we need the socket and nsl library.
2030 AC_CHECK_LIB(socket, socket)
2031 AC_CHECK_LIB(nsl, gethostbyname)
Bram Moolenaare0874f82016-01-24 20:36:41 +01002032 AC_MSG_CHECKING(whether compiling with process communication is possible)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002033 AC_TRY_LINK([
2034#include <stdio.h>
2035#include <stdlib.h>
2036#include <stdarg.h>
2037#include <fcntl.h>
2038#include <netdb.h>
2039#include <netinet/in.h>
2040#include <errno.h>
2041#include <sys/types.h>
2042#include <sys/socket.h>
2043 /* Check bitfields */
2044 struct nbbuf {
2045 unsigned int initDone:1;
Bram Moolenaar63de19e2016-12-09 20:11:26 +01002046 unsigned short signmaplen;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002047 };
2048 ], [
2049 /* Check creating a socket. */
2050 struct sockaddr_in server;
2051 (void)socket(AF_INET, SOCK_STREAM, 0);
2052 (void)htons(100);
2053 (void)gethostbyname("microsoft.com");
2054 if (errno == ECONNREFUSED)
2055 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
2056 ],
2057 AC_MSG_RESULT(yes),
Bram Moolenaare0874f82016-01-24 20:36:41 +01002058 AC_MSG_RESULT(no); enable_netbeans="no"; enable_channel="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00002059fi
2060if test "$enable_netbeans" = "yes"; then
2061 AC_DEFINE(FEAT_NETBEANS_INTG)
2062 NETBEANS_SRC="netbeans.c"
2063 AC_SUBST(NETBEANS_SRC)
2064 NETBEANS_OBJ="objects/netbeans.o"
2065 AC_SUBST(NETBEANS_OBJ)
2066fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002067if test "$enable_channel" = "yes"; then
Bram Moolenaar509ce2a2016-03-11 22:52:15 +01002068 AC_DEFINE(FEAT_JOB_CHANNEL)
Bram Moolenaare0874f82016-01-24 20:36:41 +01002069 CHANNEL_SRC="channel.c"
2070 AC_SUBST(CHANNEL_SRC)
2071 CHANNEL_OBJ="objects/channel.o"
2072 AC_SUBST(CHANNEL_OBJ)
2073fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002074
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002075AC_MSG_CHECKING(--enable-terminal argument)
2076AC_ARG_ENABLE(terminal,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002077 [ --enable-terminal Enable terminal emulation support.],
Bram Moolenaaref839562017-10-28 20:28:23 +02002078 , [enable_terminal="auto"])
Bram Moolenaar595a4022017-09-03 19:15:57 +02002079if test "$enable_terminal" = "yes" || test "$enable_terminal" = "auto" -a "x$features" = "xhuge" ; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002080 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2081 AC_MSG_RESULT([cannot use terminal emulator with tiny or small features])
2082 enable_terminal="no"
2083 else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002084 if test "$enable_terminal" = "auto"; then
2085 enable_terminal="yes"
2086 AC_MSG_RESULT(defaulting to yes)
2087 else
2088 AC_MSG_RESULT(yes)
2089 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002090 fi
2091else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002092 if test "$enable_terminal" = "auto"; then
2093 enable_terminal="no"
2094 AC_MSG_RESULT(defaulting to no)
2095 else
2096 AC_MSG_RESULT(no)
2097 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002098fi
Bram Moolenaar8b423282017-12-16 14:37:06 +01002099if test "$enable_terminal" = "yes" -a "$enable_channel" = "yes"; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002100 AC_DEFINE(FEAT_TERMINAL)
2101 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"
2102 AC_SUBST(TERM_SRC)
2103 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"
2104 AC_SUBST(TERM_OBJ)
2105fi
2106
Bram Moolenaare42a6d22017-11-12 19:21:51 +01002107AC_MSG_CHECKING(--enable-autoservername argument)
2108AC_ARG_ENABLE(autoservername,
2109 [ --enable-autoservername Automatically define servername at vim startup.], ,
2110 [enable_autoservername="no"])
2111AC_MSG_RESULT($enable_autoservername)
2112if test "$enable_autoservername" = "yes"; then
2113 AC_DEFINE(FEAT_AUTOSERVERNAME)
2114fi
2115
Bram Moolenaar071d4272004-06-13 20:20:40 +00002116AC_MSG_CHECKING(--enable-multibyte argument)
2117AC_ARG_ENABLE(multibyte,
2118 [ --enable-multibyte Include multibyte editing support.], ,
2119 [enable_multibyte="no"])
2120AC_MSG_RESULT($enable_multibyte)
2121if test "$enable_multibyte" = "yes"; then
2122 AC_DEFINE(FEAT_MBYTE)
2123fi
2124
2125AC_MSG_CHECKING(--enable-hangulinput argument)
2126AC_ARG_ENABLE(hangulinput,
2127 [ --enable-hangulinput Include Hangul input support.], ,
2128 [enable_hangulinput="no"])
2129AC_MSG_RESULT($enable_hangulinput)
2130
2131AC_MSG_CHECKING(--enable-xim argument)
2132AC_ARG_ENABLE(xim,
2133 [ --enable-xim Include XIM input support.],
2134 AC_MSG_RESULT($enable_xim),
2135 [enable_xim="auto"; AC_MSG_RESULT(defaulting to auto)])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002136
2137AC_MSG_CHECKING(--enable-fontset argument)
2138AC_ARG_ENABLE(fontset,
2139 [ --enable-fontset Include X fontset output support.], ,
2140 [enable_fontset="no"])
2141AC_MSG_RESULT($enable_fontset)
2142dnl defining FEAT_XFONTSET is delayed, so that it can be disabled for no GUI
2143
2144test -z "$with_x" && with_x=yes
Bram Moolenaard0573012017-10-28 21:11:06 +02002145test "${enable_gui-yes}" != no -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && with_x=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002146if test "$with_x" = no; then
2147 AC_MSG_RESULT(defaulting to: don't HAVE_X11)
2148else
2149 dnl Do this check early, so that its failure can override user requests.
2150
2151 AC_PATH_PROG(xmkmfpath, xmkmf)
2152
2153 AC_PATH_XTRA
2154
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002155 dnl On z/OS Unix the X libraries are DLLs. To use them the code must
Bram Moolenaar071d4272004-06-13 20:20:40 +00002156 dnl be compiled with a special option.
2157 dnl Also add SM, ICE and Xmu to X_EXTRA_LIBS.
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002158 if test "$zOSUnix" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002159 CFLAGS="$CFLAGS -W c,dll"
2160 LDFLAGS="$LDFLAGS -W l,dll"
2161 X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE -lXmu"
2162 fi
2163
2164 dnl On my HPUX system the X include dir is found, but the lib dir not.
2165 dnl This is a desparate try to fix this.
2166
2167 if test -d "$x_includes" && test ! -d "$x_libraries"; then
2168 x_libraries=`echo "$x_includes" | sed s/include/lib/`
2169 AC_MSG_RESULT(Corrected X libraries to $x_libraries)
2170 X_LIBS="$X_LIBS -L$x_libraries"
2171 if test "`(uname) 2>/dev/null`" = SunOS &&
2172 uname -r | grep '^5' >/dev/null; then
2173 X_LIBS="$X_LIBS -R $x_libraries"
2174 fi
2175 fi
2176
2177 if test -d "$x_libraries" && test ! -d "$x_includes"; then
2178 x_includes=`echo "$x_libraries" | sed s/lib/include/`
2179 AC_MSG_RESULT(Corrected X includes to $x_includes)
2180 X_CFLAGS="$X_CFLAGS -I$x_includes"
2181 fi
2182
2183 dnl Remove "-I/usr/include " from X_CFLAGS, should not be needed.
2184 X_CFLAGS="`echo $X_CFLAGS\ | sed 's%-I/usr/include %%'`"
2185 dnl Remove "-L/usr/lib " from X_LIBS, should not be needed.
2186 X_LIBS="`echo $X_LIBS\ | sed 's%-L/usr/lib %%'`"
2187 dnl Same for "-R/usr/lib ".
2188 X_LIBS="`echo $X_LIBS\ | sed -e 's%-R/usr/lib %%' -e 's%-R /usr/lib %%'`"
2189
2190
2191 dnl Check if the X11 header files are correctly installed. On some systems
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002192 dnl Xlib.h includes files that don't exist. On some systems X11/Intrinsic.h
2193 dnl is missing.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002194 AC_MSG_CHECKING(if X11 header files can be found)
2195 cflags_save=$CFLAGS
2196 CFLAGS="$CFLAGS $X_CFLAGS"
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002197 AC_TRY_COMPILE([#include <X11/Xlib.h>
2198#include <X11/Intrinsic.h>], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002199 AC_MSG_RESULT(yes),
2200 AC_MSG_RESULT(no); no_x=yes)
2201 CFLAGS=$cflags_save
2202
2203 if test "${no_x-no}" = yes; then
2204 with_x=no
2205 else
2206 AC_DEFINE(HAVE_X11)
2207 X_LIB="-lXt -lX11";
2208 AC_SUBST(X_LIB)
2209
2210 ac_save_LDFLAGS="$LDFLAGS"
2211 LDFLAGS="-L$x_libraries $LDFLAGS"
2212
2213 dnl Check for -lXdmcp (needed on SunOS 4.1.4)
2214 dnl For HP-UX 10.20 it must be before -lSM -lICE
2215 AC_CHECK_LIB(Xdmcp, _XdmcpAuthDoIt, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lXdmcp"],,
2216 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXdmcp])
2217
2218 dnl Some systems need -lnsl -lsocket when testing for ICE.
2219 dnl The check above doesn't do this, try here (again). Also needed to get
2220 dnl them after Xdmcp. link.sh will remove them when not needed.
2221 dnl Check for other function than above to avoid the cached value
2222 AC_CHECK_LIB(ICE, IceOpenConnection,
2223 [X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE"],, [$X_EXTRA_LIBS])
2224
2225 dnl Check for -lXpm (needed for some versions of Motif)
2226 LDFLAGS="$X_LIBS $ac_save_LDFLAGS"
2227 AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [X_PRE_LIBS="$X_PRE_LIBS -lXpm"],,
2228 [-lXt $X_PRE_LIBS -lXpm -lX11 $X_EXTRA_LIBS])
2229
2230 dnl Check that the X11 header files don't use implicit declarations
2231 AC_MSG_CHECKING(if X11 header files implicitly declare return values)
2232 cflags_save=$CFLAGS
Bram Moolenaard1864592013-05-04 04:40:15 +02002233 dnl -Werror is GCC only, others like Solaris Studio might not like it
2234 if test "$GCC" = yes; then
2235 CFLAGS="$CFLAGS $X_CFLAGS -Werror"
2236 else
2237 CFLAGS="$CFLAGS $X_CFLAGS"
2238 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002239 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2240 AC_MSG_RESULT(no),
2241 CFLAGS="$CFLAGS -Wno-implicit-int"
2242 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2243 AC_MSG_RESULT(yes); cflags_save="$cflags_save -Wno-implicit-int",
2244 AC_MSG_RESULT(test failed)
2245 )
2246 )
2247 CFLAGS=$cflags_save
2248
2249 LDFLAGS="$ac_save_LDFLAGS"
2250
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002251 AC_MSG_CHECKING(size of wchar_t is 2 bytes)
2252 AC_CACHE_VAL(ac_cv_small_wchar_t,
2253 [AC_TRY_RUN([
2254#include <X11/Xlib.h>
2255#if STDC_HEADERS
2256# include <stdlib.h>
2257# include <stddef.h>
2258#endif
2259 main()
2260 {
2261 if (sizeof(wchar_t) <= 2)
2262 exit(1);
2263 exit(0);
2264 }],
2265 ac_cv_small_wchar_t="no",
2266 ac_cv_small_wchar_t="yes",
2267 AC_MSG_ERROR(failed to compile test program))])
2268 AC_MSG_RESULT($ac_cv_small_wchar_t)
2269 if test "x$ac_cv_small_wchar_t" = "xyes" ; then
2270 AC_DEFINE(SMALL_WCHAR_T)
2271 fi
2272
Bram Moolenaar071d4272004-06-13 20:20:40 +00002273 fi
2274fi
2275
Bram Moolenaard0573012017-10-28 21:11:06 +02002276test "x$with_x" = xno -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && enable_gui=no
Bram Moolenaar071d4272004-06-13 20:20:40 +00002277
2278AC_MSG_CHECKING(--enable-gui argument)
2279AC_ARG_ENABLE(gui,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002280 [ --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 +00002281
2282dnl Canonicalize the --enable-gui= argument so that it can be easily compared.
2283dnl Do not use character classes for portability with old tools.
2284enable_gui_canon=`echo "_$enable_gui" | \
2285 sed 's/[[ _+-]]//g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
2286
2287dnl Skip everything by default.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002288SKIP_GTK2=YES
Bram Moolenaar1858a842016-02-23 22:30:31 +01002289SKIP_GTK3=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002290SKIP_GNOME=YES
2291SKIP_MOTIF=YES
2292SKIP_ATHENA=YES
2293SKIP_NEXTAW=YES
2294SKIP_PHOTON=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002295SKIP_CARBON=YES
2296GUITYPE=NONE
2297
Bram Moolenaarb11160e2005-01-04 21:31:43 +00002298if test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002299 SKIP_PHOTON=
2300 case "$enable_gui_canon" in
2301 no) AC_MSG_RESULT(no GUI support)
2302 SKIP_PHOTON=YES ;;
2303 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
2304 auto) AC_MSG_RESULT(auto - automatic GUI support) ;;
2305 photon) AC_MSG_RESULT(Photon GUI support) ;;
2306 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2307 SKIP_PHOTON=YES ;;
2308 esac
2309
Bram Moolenaard0573012017-10-28 21:11:06 +02002310elif test "x$MACOS_X" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002311 SKIP_CARBON=
2312 case "$enable_gui_canon" in
2313 no) AC_MSG_RESULT(no GUI support)
2314 SKIP_CARBON=YES ;;
2315 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
Bram Moolenaar164fca32010-07-14 13:58:07 +02002316 auto) AC_MSG_RESULT(auto - Carbon GUI is outdated - disable GUI support)
2317 SKIP_CARBON=YES ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002318 carbon) AC_MSG_RESULT(Carbon GUI support) ;;
2319 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2320 SKIP_CARBON=YES ;;
2321 esac
2322
2323else
2324
Bram Moolenaar071d4272004-06-13 20:20:40 +00002325 case "$enable_gui_canon" in
2326 no|none) AC_MSG_RESULT(no GUI support) ;;
2327 yes|""|auto) AC_MSG_RESULT(yes/auto - automatic GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002328 SKIP_GTK2=
2329 SKIP_GNOME=
2330 SKIP_MOTIF=
2331 SKIP_ATHENA=
2332 SKIP_NEXTAW=
2333 SKIP_CARBON=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002334 gtk2) AC_MSG_RESULT(GTK+ 2.x GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002335 SKIP_GTK2=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002336 gnome2) AC_MSG_RESULT(GNOME 2.x GUI support)
2337 SKIP_GNOME=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002338 SKIP_GTK2=;;
Bram Moolenaar98921892016-02-23 17:14:37 +01002339 gtk3) AC_MSG_RESULT(GTK+ 3.x GUI support)
2340 SKIP_GTK3=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002341 motif) AC_MSG_RESULT(Motif GUI support)
2342 SKIP_MOTIF=;;
2343 athena) AC_MSG_RESULT(Athena GUI support)
2344 SKIP_ATHENA=;;
2345 nextaw) AC_MSG_RESULT(neXtaw GUI support)
2346 SKIP_NEXTAW=;;
2347 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
2348 esac
2349
2350fi
2351
Bram Moolenaar071d4272004-06-13 20:20:40 +00002352if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \
2353 -a "$enable_gui_canon" != "gnome2"; then
2354 AC_MSG_CHECKING(whether or not to look for GTK+ 2)
2355 AC_ARG_ENABLE(gtk2-check,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002356 [ --enable-gtk2-check If auto-select GUI, check for GTK+ 2 [default=yes]],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002357 , enable_gtk2_check="yes")
2358 AC_MSG_RESULT($enable_gtk2_check)
2359 if test "x$enable_gtk2_check" = "xno"; then
2360 SKIP_GTK2=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002361 SKIP_GNOME=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002362 fi
2363fi
2364
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002365if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002366 AC_MSG_CHECKING(whether or not to look for GNOME)
2367 AC_ARG_ENABLE(gnome-check,
2368 [ --enable-gnome-check If GTK GUI, check for GNOME [default=no]],
2369 , enable_gnome_check="no")
2370 AC_MSG_RESULT($enable_gnome_check)
2371 if test "x$enable_gnome_check" = "xno"; then
2372 SKIP_GNOME=YES
2373 fi
2374fi
2375
Bram Moolenaar98921892016-02-23 17:14:37 +01002376if test "x$SKIP_GTK3" != "xYES" -a "$enable_gui_canon" != "gtk3"; then
2377 AC_MSG_CHECKING(whether or not to look for GTK+ 3)
2378 AC_ARG_ENABLE(gtk3-check,
2379 [ --enable-gtk3-check If auto-select GUI, check for GTK+ 3 [default=yes]],
2380 , enable_gtk3_check="yes")
2381 AC_MSG_RESULT($enable_gtk3_check)
2382 if test "x$enable_gtk3_check" = "xno"; then
2383 SKIP_GTK3=YES
2384 fi
2385fi
2386
Bram Moolenaar071d4272004-06-13 20:20:40 +00002387if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then
2388 AC_MSG_CHECKING(whether or not to look for Motif)
2389 AC_ARG_ENABLE(motif-check,
2390 [ --enable-motif-check If auto-select GUI, check for Motif [default=yes]],
2391 , enable_motif_check="yes")
2392 AC_MSG_RESULT($enable_motif_check)
2393 if test "x$enable_motif_check" = "xno"; then
2394 SKIP_MOTIF=YES
2395 fi
2396fi
2397
2398if test "x$SKIP_ATHENA" != "xYES" -a "$enable_gui_canon" != "athena"; then
2399 AC_MSG_CHECKING(whether or not to look for Athena)
2400 AC_ARG_ENABLE(athena-check,
2401 [ --enable-athena-check If auto-select GUI, check for Athena [default=yes]],
2402 , enable_athena_check="yes")
2403 AC_MSG_RESULT($enable_athena_check)
2404 if test "x$enable_athena_check" = "xno"; then
2405 SKIP_ATHENA=YES
2406 fi
2407fi
2408
2409if test "x$SKIP_NEXTAW" != "xYES" -a "$enable_gui_canon" != "nextaw"; then
2410 AC_MSG_CHECKING(whether or not to look for neXtaw)
2411 AC_ARG_ENABLE(nextaw-check,
2412 [ --enable-nextaw-check If auto-select GUI, check for neXtaw [default=yes]],
2413 , enable_nextaw_check="yes")
2414 AC_MSG_RESULT($enable_nextaw_check);
2415 if test "x$enable_nextaw_check" = "xno"; then
2416 SKIP_NEXTAW=YES
2417 fi
2418fi
2419
2420if test "x$SKIP_CARBON" != "xYES" -a "$enable_gui_canon" != "carbon"; then
2421 AC_MSG_CHECKING(whether or not to look for Carbon)
2422 AC_ARG_ENABLE(carbon-check,
2423 [ --enable-carbon-check If auto-select GUI, check for Carbon [default=yes]],
2424 , enable_carbon_check="yes")
2425 AC_MSG_RESULT($enable_carbon_check);
2426 if test "x$enable_carbon_check" = "xno"; then
2427 SKIP_CARBON=YES
2428 fi
2429fi
2430
Bram Moolenaar843ee412004-06-30 16:16:41 +00002431
Bram Moolenaard0573012017-10-28 21:11:06 +02002432if test "x$MACOS_X" = "xyes" -a -z "$SKIP_CARBON" -a "x$CARBON" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002433 AC_MSG_CHECKING(for Carbon GUI)
Bram Moolenaar14716812006-05-04 21:54:08 +00002434 dnl already did the check, just give the message
Bram Moolenaar071d4272004-06-13 20:20:40 +00002435 AC_MSG_RESULT(yes);
2436 GUITYPE=CARBONGUI
Bram Moolenaare344bea2005-09-01 20:46:49 +00002437 if test "$VIMNAME" = "vim"; then
2438 VIMNAME=Vim
2439 fi
Bram Moolenaar14716812006-05-04 21:54:08 +00002440
Bram Moolenaar164fca32010-07-14 13:58:07 +02002441 if test "x$MACARCH" = "xboth"; then
2442 CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk/Developer/Headers/FlatCarbon"
2443 else
2444 CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/Headers/FlatCarbon"
2445 fi
2446
Bram Moolenaar14716812006-05-04 21:54:08 +00002447 dnl Default install directory is not /usr/local
2448 if test x$prefix = xNONE; then
2449 prefix=/Applications
2450 fi
2451
2452 dnl Sorry for the hard coded default
2453 datadir='${prefix}/Vim.app/Contents/Resources'
2454
Bram Moolenaar071d4272004-06-13 20:20:40 +00002455 dnl skip everything else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002456 SKIP_GTK2=YES;
2457 SKIP_GNOME=YES;
2458 SKIP_MOTIF=YES;
2459 SKIP_ATHENA=YES;
2460 SKIP_NEXTAW=YES;
2461 SKIP_PHOTON=YES;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002462 SKIP_CARBON=YES
2463fi
2464
Bram Moolenaar071d4272004-06-13 20:20:40 +00002465dnl define an autoconf function to check for a specified version of GTK, and
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002466dnl try to compile/link a GTK program.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002467dnl
2468dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002469dnl Test for GTK, and define GTK_CFLAGS, GTK_LIBDIR and GTK_LIBS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002470dnl
2471AC_DEFUN(AM_PATH_GTK,
2472[
2473 if test "X$GTK_CONFIG" != "Xno" -o "X$PKG_CONFIG" != "Xno"; then
2474 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00002475 no_gtk=""
2476 if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2477 && $PKG_CONFIG --exists gtk+-2.0; then
2478 {
Bram Moolenaar98921892016-02-23 17:14:37 +01002479 min_gtk_version=ifelse([$1], ,2.2.0,$1)
2480 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002481 dnl We should be using PKG_CHECK_MODULES() instead of this hack.
2482 dnl But I guess the dependency on pkgconfig.m4 is not wanted or
2483 dnl something like that.
2484 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0`
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002485 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-2.0`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002486 GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0`
2487 gtk_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2488 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2489 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2490 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2491 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2492 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2493 }
Bram Moolenaar98921892016-02-23 17:14:37 +01002494 elif (test "X$SKIP_GTK3" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2495 && $PKG_CONFIG --exists gtk+-3.0; then
2496 {
2497 min_gtk_version=ifelse([$1], ,3.0.0,$1)
2498 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
2499
2500 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-3.0`
2501 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-3.0`
2502 GTK_LIBS=`$PKG_CONFIG --libs gtk+-3.0`
2503 gtk_major_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2504 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2505 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2506 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2507 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2508 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2509 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002510 else
2511 no_gtk=yes
2512 fi
2513
2514 if test "x$enable_gtktest" = "xyes" -a "x$no_gtk" = "x"; then
2515 {
2516 ac_save_CFLAGS="$CFLAGS"
2517 ac_save_LIBS="$LIBS"
2518 CFLAGS="$CFLAGS $GTK_CFLAGS"
2519 LIBS="$LIBS $GTK_LIBS"
2520
2521 dnl
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002522 dnl Now check if the installed GTK is sufficiently new.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002523 dnl
2524 rm -f conf.gtktest
2525 AC_TRY_RUN([
2526#include <gtk/gtk.h>
2527#include <stdio.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00002528#if STDC_HEADERS
2529# include <stdlib.h>
2530# include <stddef.h>
2531#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002532
2533int
2534main ()
2535{
2536int major, minor, micro;
2537char *tmp_version;
2538
2539system ("touch conf.gtktest");
2540
2541/* HP/UX 9 (%@#!) writes to sscanf strings */
2542tmp_version = g_strdup("$min_gtk_version");
2543if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
2544 printf("%s, bad version string\n", "$min_gtk_version");
2545 exit(1);
2546 }
2547
2548if ((gtk_major_version > major) ||
2549 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
2550 ((gtk_major_version == major) && (gtk_minor_version == minor) &&
2551 (gtk_micro_version >= micro)))
2552{
2553 return 0;
2554}
2555return 1;
2556}
2557],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
2558 CFLAGS="$ac_save_CFLAGS"
2559 LIBS="$ac_save_LIBS"
2560 }
2561 fi
2562 if test "x$no_gtk" = x ; then
2563 if test "x$enable_gtktest" = "xyes"; then
2564 AC_MSG_RESULT(yes; found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2565 else
2566 AC_MSG_RESULT(found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2567 fi
2568 ifelse([$2], , :, [$2])
2569 else
2570 {
2571 AC_MSG_RESULT(no)
2572 GTK_CFLAGS=""
2573 GTK_LIBS=""
2574 ifelse([$3], , :, [$3])
2575 }
2576 fi
2577 }
2578 else
2579 GTK_CFLAGS=""
2580 GTK_LIBS=""
2581 ifelse([$3], , :, [$3])
2582 fi
2583 AC_SUBST(GTK_CFLAGS)
2584 AC_SUBST(GTK_LIBS)
2585 rm -f conf.gtktest
2586])
2587
2588dnl ---------------------------------------------------------------------------
2589dnl gnome
2590dnl ---------------------------------------------------------------------------
2591AC_DEFUN([GNOME_INIT_HOOK],
2592[
2593 AC_SUBST(GNOME_LIBS)
2594 AC_SUBST(GNOME_LIBDIR)
2595 AC_SUBST(GNOME_INCLUDEDIR)
2596
2597 AC_ARG_WITH(gnome-includes,
2598 [ --with-gnome-includes=DIR Specify location of GNOME headers],
2599 [CFLAGS="$CFLAGS -I$withval"]
2600 )
2601
2602 AC_ARG_WITH(gnome-libs,
2603 [ --with-gnome-libs=DIR Specify location of GNOME libs],
2604 [LDFLAGS="$LDFLAGS -L$withval" gnome_prefix=$withval]
2605 )
2606
2607 AC_ARG_WITH(gnome,
2608 [ --with-gnome Specify prefix for GNOME files],
2609 if test x$withval = xyes; then
2610 want_gnome=yes
2611 ifelse([$1], [], :, [$1])
2612 else
2613 if test "x$withval" = xno; then
2614 want_gnome=no
2615 else
2616 want_gnome=yes
2617 LDFLAGS="$LDFLAGS -L$withval/lib"
2618 CFLAGS="$CFLAGS -I$withval/include"
2619 gnome_prefix=$withval/lib
2620 fi
2621 fi,
2622 want_gnome=yes)
2623
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002624 if test "x$want_gnome" = xyes; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002625 {
2626 AC_MSG_CHECKING(for libgnomeui-2.0)
2627 if $PKG_CONFIG --exists libgnomeui-2.0; then
2628 AC_MSG_RESULT(yes)
2629 GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0`
2630 GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0`
2631 GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0`
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002632
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002633 dnl On FreeBSD we need -pthread but pkg-config doesn't include it.
2634 dnl This might not be the right way but it works for me...
2635 AC_MSG_CHECKING(for FreeBSD)
2636 if test "`(uname) 2>/dev/null`" = FreeBSD; then
2637 AC_MSG_RESULT(yes, adding -pthread)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002638 GNOME_INCLUDEDIR="$GNOME_INCLUDEDIR -D_THREAD_SAFE"
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002639 GNOME_LIBS="$GNOME_LIBS -pthread"
2640 else
2641 AC_MSG_RESULT(no)
2642 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002643 $1
2644 else
2645 AC_MSG_RESULT(not found)
2646 if test "x$2" = xfail; then
2647 AC_MSG_ERROR(Could not find libgnomeui-2.0 via pkg-config)
2648 fi
2649 fi
2650 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002651 fi
2652])
2653
2654AC_DEFUN([GNOME_INIT],[
2655 GNOME_INIT_HOOK([],fail)
2656])
2657
2658
2659dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002660dnl Check for GTK2. If it fails, then continue on for Motif as before...
Bram Moolenaar071d4272004-06-13 20:20:40 +00002661dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002662if test -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002663
2664 AC_MSG_CHECKING(--disable-gtktest argument)
2665 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2666 , enable_gtktest=yes)
2667 if test "x$enable_gtktest" = "xyes" ; then
2668 AC_MSG_RESULT(gtk test enabled)
2669 else
2670 AC_MSG_RESULT(gtk test disabled)
2671 fi
2672
Bram Moolenaar071d4272004-06-13 20:20:40 +00002673 if test "X$PKG_CONFIG" = "X"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01002674 AC_PATH_TOOL(PKG_CONFIG, pkg-config, no)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002675 fi
2676
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002677 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002678 dnl First try finding version 2.2.0 or later. The 2.0.x series has
2679 dnl problems (bold fonts, --remote doesn't work).
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002680 AM_PATH_GTK(2.2.0,
2681 [GUI_LIB_LOC="$GTK_LIBDIR"
2682 GTK_LIBNAME="$GTK_LIBS"
2683 GUI_INC_LOC="$GTK_CFLAGS"], )
2684 if test "x$GTK_CFLAGS" != "x"; then
Bram Moolenaar98921892016-02-23 17:14:37 +01002685 SKIP_GTK3=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002686 SKIP_ATHENA=YES
2687 SKIP_NEXTAW=YES
2688 SKIP_MOTIF=YES
2689 GUITYPE=GTK
2690 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002691 fi
2692 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002693 if test "x$GUITYPE" = "xGTK"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002694 dnl
2695 dnl if GTK exists, then check for GNOME.
2696 dnl
2697 if test -z "$SKIP_GNOME"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002698 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002699 GNOME_INIT_HOOK([have_gnome=yes])
2700 if test "x$have_gnome" = xyes ; then
2701 AC_DEFINE(FEAT_GUI_GNOME)
2702 GUI_INC_LOC="$GUI_INC_LOC $GNOME_INCLUDEDIR"
2703 GTK_LIBNAME="$GTK_LIBNAME $GNOME_LIBDIR $GNOME_LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002704 fi
2705 }
2706 fi
2707 fi
2708fi
2709
Bram Moolenaar98921892016-02-23 17:14:37 +01002710
2711dnl ---------------------------------------------------------------------------
2712dnl Check for GTK3.
2713dnl ---------------------------------------------------------------------------
2714if test -z "$SKIP_GTK3"; then
2715
2716 AC_MSG_CHECKING(--disable-gtktest argument)
2717 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2718 , enable_gtktest=yes)
2719 if test "x$enable_gtktest" = "xyes" ; then
2720 AC_MSG_RESULT(gtk test enabled)
2721 else
2722 AC_MSG_RESULT(gtk test disabled)
2723 fi
2724
2725 if test "X$PKG_CONFIG" = "X"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01002726 AC_PATH_TOOL(PKG_CONFIG, pkg-config, no)
Bram Moolenaar98921892016-02-23 17:14:37 +01002727 fi
2728
2729 if test "x$PKG_CONFIG" != "xno"; then
2730 AM_PATH_GTK(3.0.0,
2731 [GUI_LIB_LOC="$GTK_LIBDIR"
2732 GTK_LIBNAME="$GTK_LIBS"
2733 GUI_INC_LOC="$GTK_CFLAGS"], )
2734 if test "x$GTK_CFLAGS" != "x"; then
2735 SKIP_GTK2=YES
2736 SKIP_GNOME=YES
2737 SKIP_ATHENA=YES
2738 SKIP_NEXTAW=YES
2739 SKIP_MOTIF=YES
2740 GUITYPE=GTK
2741 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar98921892016-02-23 17:14:37 +01002742 AC_DEFINE(USE_GTK3)
2743 fi
2744 fi
2745fi
2746
Bram Moolenaard2e03f02016-01-02 22:46:36 +01002747dnl Check the version of Gdk-Pixbuf. If the version is 2.31 or later and
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002748dnl glib-compile-resources is found in PATH, use GResource.
2749if test "x$GUITYPE" = "xGTK"; then
2750 AC_MSG_CHECKING([version of Gdk-Pixbuf])
2751 gdk_pixbuf_version=`$PKG_CONFIG --modversion gdk-pixbuf-2.0`
2752 if test "x$gdk_pixbuf_version" != x ; then
2753 gdk_pixbuf_version_minor=`echo $gdk_pixbuf_version | \
2754 sed -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/'`
2755 if test "x$gdk_pixbuf_version_minor" != x -a \
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002756 $gdk_pixbuf_version_minor -ge 31 ; then
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002757 AC_MSG_RESULT([OK.])
2758 AC_PATH_PROG(GLIB_COMPILE_RESOURCES,[glib-compile-resources],no)
2759 AC_MSG_CHECKING([glib-compile-resources])
2760 if test "x$GLIB_COMPILE_RESOURCES" = xno ; then
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002761 GLIB_COMPILE_RESOURCES=""
2762 AC_MSG_RESULT([cannot be found in PATH.])
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002763 else
2764 AC_MSG_RESULT([usable.])
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002765 AC_DEFINE(USE_GRESOURCE)
2766 GRESOURCE_SRC="auto/gui_gtk_gresources.c"
2767 GRESOURCE_OBJ="objects/gui_gtk_gresources.o"
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002768 fi
2769 else
2770 AC_MSG_RESULT([not usable.])
2771 fi
2772 else
2773 AC_MSG_RESULT([cannot obtain from pkg_config.])
2774 fi
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002775
2776 AC_MSG_CHECKING([--disable-icon-cache-update argument])
2777 AC_ARG_ENABLE(icon_cache_update,
2778 [ --disable-icon-cache-update update disabled],
2779 [],
2780 [enable_icon_cache_update="yes"])
2781 if test "$enable_icon_cache_update" = "yes"; then
2782 AC_MSG_RESULT([not set])
2783 AC_PATH_PROG(GTK_UPDATE_ICON_CACHE,[gtk-update-icon-cache],no)
2784 if test "x$GTK_UPDATE_ICON_CACHE" = "xno" ; then
2785 AC_MSG_RESULT([not found in PATH.])
2786 fi
2787 else
2788 AC_MSG_RESULT([update disabled])
2789 fi
2790
2791 AC_MSG_CHECKING([--disable-desktop-database-update argument])
2792 AC_ARG_ENABLE(desktop_database_update,
2793 [ --disable-desktop-database-update update disabled],
2794 [],
2795 [enable_desktop_database_update="yes"])
2796 if test "$enable_desktop_database_update" = "yes"; then
2797 AC_MSG_RESULT([not set])
2798 AC_PATH_PROG(UPDATE_DESKTOP_DATABASE,[update-desktop-database],no)
2799 if test "x$UPDATE_DESKTOP_DATABASE" = "xno" ; then
2800 AC_MSG_RESULT([not found in PATH.])
2801 fi
2802 else
2803 AC_MSG_RESULT([update disabled])
2804 fi
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002805fi
2806AC_SUBST(GLIB_COMPILE_RESOURCES)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002807AC_SUBST(GRESOURCE_SRC)
2808AC_SUBST(GRESOURCE_OBJ)
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002809AC_SUBST(GTK_UPDATE_ICON_CACHE)
2810AC_SUBST(UPDATE_DESKTOP_DATABASE)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002811
Bram Moolenaar071d4272004-06-13 20:20:40 +00002812dnl Check for Motif include files location.
2813dnl The LAST one found is used, this makes the highest version to be used,
2814dnl e.g. when Motif1.2 and Motif2.0 are both present.
2815
2816if test -z "$SKIP_MOTIF"; then
2817 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"
2818 dnl Remove "-I" from before $GUI_INC_LOC if it's there
2819 GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`"
2820
2821 AC_MSG_CHECKING(for location of Motif GUI includes)
2822 gui_includes="`echo $x_includes|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC"
2823 GUI_INC_LOC=
2824 for try in $gui_includes; do
2825 if test -f "$try/Xm/Xm.h"; then
2826 GUI_INC_LOC=$try
2827 fi
2828 done
2829 if test -n "$GUI_INC_LOC"; then
2830 if test "$GUI_INC_LOC" = /usr/include; then
2831 GUI_INC_LOC=
2832 AC_MSG_RESULT(in default path)
2833 else
2834 AC_MSG_RESULT($GUI_INC_LOC)
2835 fi
2836 else
2837 AC_MSG_RESULT(<not found>)
2838 SKIP_MOTIF=YES
2839 fi
2840fi
2841
2842dnl Check for Motif library files location. In the same order as the include
2843dnl files, to avoid a mixup if several versions are present
2844
2845if test -z "$SKIP_MOTIF"; then
2846 AC_MSG_CHECKING(--with-motif-lib argument)
2847 AC_ARG_WITH(motif-lib,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002848 [ --with-motif-lib=STRING Library for Motif ],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002849 [ MOTIF_LIBNAME="${withval}" ] )
2850
2851 if test -n "$MOTIF_LIBNAME"; then
2852 AC_MSG_RESULT($MOTIF_LIBNAME)
2853 GUI_LIB_LOC=
2854 else
2855 AC_MSG_RESULT(no)
2856
2857 dnl Remove "-L" from before $GUI_LIB_LOC if it's there
2858 GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
2859
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002860 dnl Ubuntu has libXm.so in /usr/lib/i386-linux-gnu and elsewhere. The
2861 dnl linker will figure out which one to use, we only check if one exists.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002862 AC_MSG_CHECKING(for location of Motif GUI libs)
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002863 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 +00002864 GUI_LIB_LOC=
2865 for try in $gui_libs; do
Bram Moolenaar325b7a22004-07-05 15:58:32 +00002866 for libtry in "$try"/libXm.a "$try"/libXm.so* "$try"/libXm.sl "$try"/libXm.dylib; do
Bram Moolenaar071d4272004-06-13 20:20:40 +00002867 if test -f "$libtry"; then
2868 GUI_LIB_LOC=$try
2869 fi
2870 done
2871 done
2872 if test -n "$GUI_LIB_LOC"; then
2873 dnl Remove /usr/lib, it causes trouble on some systems
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002874 if test "$GUI_LIB_LOC" = /usr/lib \
2875 -o "$GUI_LIB_LOC" = /usr/lib/i386-linux-gnu \
2876 -o "$GUI_LIB_LOC" = /usr/lib/x86_64-linux-gnu; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002877 GUI_LIB_LOC=
2878 AC_MSG_RESULT(in default path)
2879 else
2880 if test -n "$GUI_LIB_LOC"; then
2881 AC_MSG_RESULT($GUI_LIB_LOC)
2882 if test "`(uname) 2>/dev/null`" = SunOS &&
2883 uname -r | grep '^5' >/dev/null; then
2884 GUI_LIB_LOC="$GUI_LIB_LOC -R $GUI_LIB_LOC"
2885 fi
2886 fi
2887 fi
2888 MOTIF_LIBNAME=-lXm
2889 else
2890 AC_MSG_RESULT(<not found>)
2891 SKIP_MOTIF=YES
2892 fi
2893 fi
2894fi
2895
2896if test -z "$SKIP_MOTIF"; then
2897 SKIP_ATHENA=YES
2898 SKIP_NEXTAW=YES
2899 GUITYPE=MOTIF
2900 AC_SUBST(MOTIF_LIBNAME)
2901fi
2902
2903dnl Check if the Athena files can be found
2904
2905GUI_X_LIBS=
2906
2907if test -z "$SKIP_ATHENA"; then
2908 AC_MSG_CHECKING(if Athena header files can be found)
2909 cflags_save=$CFLAGS
2910 CFLAGS="$CFLAGS $X_CFLAGS"
2911 AC_TRY_COMPILE([
2912#include <X11/Intrinsic.h>
2913#include <X11/Xaw/Paned.h>], ,
2914 AC_MSG_RESULT(yes),
2915 AC_MSG_RESULT(no); SKIP_ATHENA=YES )
2916 CFLAGS=$cflags_save
2917fi
2918
2919if test -z "$SKIP_ATHENA"; then
2920 GUITYPE=ATHENA
2921fi
2922
2923if test -z "$SKIP_NEXTAW"; then
2924 AC_MSG_CHECKING(if neXtaw header files can be found)
2925 cflags_save=$CFLAGS
2926 CFLAGS="$CFLAGS $X_CFLAGS"
2927 AC_TRY_COMPILE([
2928#include <X11/Intrinsic.h>
2929#include <X11/neXtaw/Paned.h>], ,
2930 AC_MSG_RESULT(yes),
2931 AC_MSG_RESULT(no); SKIP_NEXTAW=YES )
2932 CFLAGS=$cflags_save
2933fi
2934
2935if test -z "$SKIP_NEXTAW"; then
2936 GUITYPE=NEXTAW
2937fi
2938
2939if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
2940 dnl Prepend -I and -L to $GUI_INC_LOC and $GUI_LIB_LOC if not empty
2941 dnl Avoid adding it when it twice
2942 if test -n "$GUI_INC_LOC"; then
2943 GUI_INC_LOC=-I"`echo $GUI_INC_LOC|sed 's%-I%%'`"
2944 fi
2945 if test -n "$GUI_LIB_LOC"; then
2946 GUI_LIB_LOC=-L"`echo $GUI_LIB_LOC|sed 's%-L%%'`"
2947 fi
2948
2949 dnl Check for -lXext and then for -lXmu
2950 ldflags_save=$LDFLAGS
2951 LDFLAGS="$X_LIBS $LDFLAGS"
2952 AC_CHECK_LIB(Xext, XShapeQueryExtension, [GUI_X_LIBS="-lXext"],,
2953 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2954 dnl For Solaris we need -lw and -ldl before linking with -lXmu works.
2955 AC_CHECK_LIB(w, wslen, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lw"],,
2956 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2957 AC_CHECK_LIB(dl, dlsym, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldl"],,
2958 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2959 AC_CHECK_LIB(Xmu, XmuCreateStippledPixmap, [GUI_X_LIBS="-lXmu $GUI_X_LIBS"],,
2960 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2961 if test -z "$SKIP_MOTIF"; then
2962 AC_CHECK_LIB(Xp, XpEndJob, [GUI_X_LIBS="-lXp $GUI_X_LIBS"],,
2963 [$GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2964 fi
2965 LDFLAGS=$ldflags_save
2966
2967 dnl Execute xmkmf to figure out if -DNARROWPROTO is needed.
2968 AC_MSG_CHECKING(for extra X11 defines)
2969 NARROW_PROTO=
2970 rm -fr conftestdir
2971 if mkdir conftestdir; then
2972 cd conftestdir
2973 cat > Imakefile <<'EOF'
2974acfindx:
2975 @echo 'NARROW_PROTO="${PROTO_DEFINES}"'
2976EOF
2977 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
2978 eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
2979 fi
2980 cd ..
2981 rm -fr conftestdir
2982 fi
2983 if test -z "$NARROW_PROTO"; then
2984 AC_MSG_RESULT(no)
2985 else
2986 AC_MSG_RESULT($NARROW_PROTO)
2987 fi
2988 AC_SUBST(NARROW_PROTO)
2989fi
2990
2991dnl Look for XSMP support - but don't necessarily restrict it to X11 GUIs
2992dnl use the X11 include path
2993if test "$enable_xsmp" = "yes"; then
2994 cppflags_save=$CPPFLAGS
2995 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2996 AC_CHECK_HEADERS(X11/SM/SMlib.h)
2997 CPPFLAGS=$cppflags_save
2998fi
2999
3000
Bram Moolenaar98921892016-02-23 17:14:37 +01003001if 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 +00003002 dnl Check for X11/xpm.h and X11/Sunkeysym.h with the GUI include path
3003 cppflags_save=$CPPFLAGS
3004 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3005 AC_CHECK_HEADERS(X11/xpm.h X11/Sunkeysym.h)
3006
3007 dnl automatically disable XIM when XIMtext isn't in X11/Xlib.h
3008 if test ! "$enable_xim" = "no"; then
3009 AC_MSG_CHECKING(for XIMText in X11/Xlib.h)
3010 AC_EGREP_CPP(XIMText, [#include <X11/Xlib.h>],
3011 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +02003012 AC_MSG_RESULT(no; xim has been disabled); enable_xim="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00003013 fi
3014 CPPFLAGS=$cppflags_save
3015
3016 dnl automatically enable XIM when hangul input isn't enabled
3017 if test "$enable_xim" = "auto" -a "$enable_hangulinput" != "yes" \
3018 -a "x$GUITYPE" != "xNONE" ; then
3019 AC_MSG_RESULT(X GUI selected; xim has been enabled)
3020 enable_xim="yes"
3021 fi
3022fi
3023
3024if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
3025 cppflags_save=$CPPFLAGS
3026 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00003027dnl Xmu/Editres.h may exist but can only be used after including Intrinsic.h
3028 AC_MSG_CHECKING([for X11/Xmu/Editres.h])
3029 AC_TRY_COMPILE([
3030#include <X11/Intrinsic.h>
3031#include <X11/Xmu/Editres.h>],
3032 [int i; i = 0;],
3033 AC_MSG_RESULT(yes)
3034 AC_DEFINE(HAVE_X11_XMU_EDITRES_H),
3035 AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003036 CPPFLAGS=$cppflags_save
3037fi
3038
3039dnl Only use the Xm directory when compiling Motif, don't use it for Athena
3040if test -z "$SKIP_MOTIF"; then
3041 cppflags_save=$CPPFLAGS
3042 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003043 if test "$zOSUnix" = "yes"; then
3044 xmheader="Xm/Xm.h"
3045 else
3046 xmheader="Xm/Xm.h Xm/XpmP.h Xm/JoinSideT.h Xm/TraitP.h Xm/Manager.h
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02003047 Xm/UnhighlightT.h Xm/Notebook.h"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003048 fi
3049 AC_CHECK_HEADERS($xmheader)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003050
Bram Moolenaar77c19352012-06-13 19:19:41 +02003051 if test "x$ac_cv_header_Xm_XpmP_h" = "xyes"; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003052 dnl Solaris uses XpmAttributes_21, very annoying.
3053 AC_MSG_CHECKING([for XpmAttributes_21 in Xm/XpmP.h])
3054 AC_TRY_COMPILE([#include <Xm/XpmP.h>], [XpmAttributes_21 attr;],
3055 AC_MSG_RESULT(yes); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes_21),
3056 AC_MSG_RESULT(no); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
3057 )
3058 else
Bram Moolenaar57657d82006-04-21 22:12:41 +00003059 AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003060 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003061 CPPFLAGS=$cppflags_save
3062fi
3063
3064if test "x$GUITYPE" = "xNONE" -a "$enable_xim" = "yes"; then
3065 AC_MSG_RESULT(no GUI selected; xim has been disabled)
3066 enable_xim="no"
3067fi
3068if test "x$GUITYPE" = "xNONE" -a "$enable_fontset" = "yes"; then
3069 AC_MSG_RESULT(no GUI selected; fontset has been disabled)
3070 enable_fontset="no"
3071fi
Bram Moolenaar182c5be2010-06-25 05:37:59 +02003072if test "x$GUITYPE:$enable_fontset" = "xGTK:yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003073 AC_MSG_RESULT(GTK+ 2 GUI selected; fontset has been disabled)
3074 enable_fontset="no"
3075fi
3076
Bram Moolenaar071d4272004-06-13 20:20:40 +00003077if test -z "$SKIP_PHOTON"; then
3078 GUITYPE=PHOTONGUI
3079fi
3080
3081AC_SUBST(GUI_INC_LOC)
3082AC_SUBST(GUI_LIB_LOC)
3083AC_SUBST(GUITYPE)
3084AC_SUBST(GUI_X_LIBS)
3085
3086if test "$enable_workshop" = "yes" -a -n "$SKIP_MOTIF"; then
3087 AC_MSG_ERROR([cannot use workshop without Motif])
3088fi
3089
3090dnl defining FEAT_XIM and FEAT_XFONTSET is delayed, so that they can be disabled
3091if test "$enable_xim" = "yes"; then
3092 AC_DEFINE(FEAT_XIM)
3093fi
3094if test "$enable_fontset" = "yes"; then
3095 AC_DEFINE(FEAT_XFONTSET)
3096fi
3097
3098
3099dnl ---------------------------------------------------------------------------
3100dnl end of GUI-checking
3101dnl ---------------------------------------------------------------------------
3102
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003103AC_MSG_CHECKING([for /proc link to executable])
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003104if test -L "/proc/self/exe"; then
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003105 dnl Linux
3106 AC_MSG_RESULT([/proc/self/exe])
3107 AC_DEFINE(PROC_EXE_LINK, "/proc/self/exe")
3108elif test -L "/proc/self/path/a.out"; then
3109 dnl Solaris
3110 AC_MSG_RESULT([/proc/self/path/a.out])
3111 AC_DEFINE(PROC_EXE_LINK, "/proc/self/path/a.out")
3112elif test -L "/proc/curproc/file"; then
3113 dnl FreeBSD
3114 AC_MSG_RESULT([/proc/curproc/file])
3115 AC_DEFINE(PROC_EXE_LINK, "/proc/curproc/file")
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003116else
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003117 AC_MSG_RESULT(no)
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003118fi
3119
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003120dnl Check for Cygwin, which needs an extra source file if not using X11
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003121AC_MSG_CHECKING(for CYGWIN or MSYS environment)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003122case `uname` in
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003123 CYGWIN*|MSYS*) CYGWIN=yes; AC_MSG_RESULT(yes)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003124 AC_MSG_CHECKING(for CYGWIN clipboard support)
3125 if test "x$with_x" = "xno" ; then
3126 OS_EXTRA_SRC=winclip.c; OS_EXTRA_OBJ=objects/winclip.o
3127 AC_MSG_RESULT(yes)
3128 AC_DEFINE(FEAT_CYGWIN_WIN32_CLIPBOARD)
3129 else
3130 AC_MSG_RESULT(no - using X11)
3131 fi ;;
3132
3133 *) CYGWIN=no; AC_MSG_RESULT(no);;
3134esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00003135
3136dnl Only really enable hangul input when GUI and XFONTSET are available
3137if test "$enable_hangulinput" = "yes"; then
3138 if test "x$GUITYPE" = "xNONE"; then
3139 AC_MSG_RESULT(no GUI selected; hangul input has been disabled)
3140 enable_hangulinput=no
3141 else
3142 AC_DEFINE(FEAT_HANGULIN)
3143 HANGULIN_SRC=hangulin.c
3144 AC_SUBST(HANGULIN_SRC)
3145 HANGULIN_OBJ=objects/hangulin.o
3146 AC_SUBST(HANGULIN_OBJ)
3147 fi
3148fi
3149
3150dnl Checks for libraries and include files.
3151
Bram Moolenaar446cb832008-06-24 21:56:24 +00003152AC_CACHE_CHECK([whether toupper is broken], [vim_cv_toupper_broken],
3153 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003154 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003155#include "confdefs.h"
3156#include <ctype.h>
3157#if STDC_HEADERS
3158# include <stdlib.h>
3159# include <stddef.h>
3160#endif
3161main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003162 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003163 vim_cv_toupper_broken=yes
3164 ],[
3165 vim_cv_toupper_broken=no
3166 ],[
3167 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_toupper_broken')
3168 ])])
3169
3170if test "x$vim_cv_toupper_broken" = "xyes" ; then
3171 AC_DEFINE(BROKEN_TOUPPER)
3172fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003173
3174AC_MSG_CHECKING(whether __DATE__ and __TIME__ work)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003175AC_TRY_COMPILE([#include <stdio.h>], [printf("(" __DATE__ " " __TIME__ ")");],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003176 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DATE_TIME),
3177 AC_MSG_RESULT(no))
3178
Bram Moolenaar0c094b92009-05-14 20:20:33 +00003179AC_MSG_CHECKING(whether __attribute__((unused)) is allowed)
3180AC_TRY_COMPILE([#include <stdio.h>], [int x __attribute__((unused));],
3181 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ATTRIBUTE_UNUSED),
3182 AC_MSG_RESULT(no))
3183
Bram Moolenaar071d4272004-06-13 20:20:40 +00003184dnl Checks for header files.
3185AC_CHECK_HEADER(elf.h, HAS_ELF=1)
3186dnl AC_CHECK_HEADER(dwarf.h, SVR4=1)
3187if test "$HAS_ELF" = 1; then
3188 AC_CHECK_LIB(elf, main)
3189fi
3190
3191AC_HEADER_DIRENT
3192
Bram Moolenaar071d4272004-06-13 20:20:40 +00003193dnl If sys/wait.h is not found it might still exist but not be POSIX
3194dnl compliant. In that case we define HAVE_UNION_WAIT (for NeXT)
3195if test $ac_cv_header_sys_wait_h = no; then
3196 AC_MSG_CHECKING([for sys/wait.h that defines union wait])
3197 AC_TRY_COMPILE([#include <sys/wait.h>],
3198 [union wait xx, yy; xx = yy],
3199 AC_MSG_RESULT(yes)
3200 AC_DEFINE(HAVE_SYS_WAIT_H)
3201 AC_DEFINE(HAVE_UNION_WAIT),
3202 AC_MSG_RESULT(no))
3203fi
3204
Bram Moolenaar779a7752016-01-30 23:26:34 +01003205AC_CHECK_HEADERS(stdint.h stdlib.h string.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003206 sys/select.h sys/utsname.h termcap.h fcntl.h \
3207 sgtty.h sys/ioctl.h sys/time.h sys/types.h \
3208 termio.h iconv.h inttypes.h langinfo.h math.h \
3209 unistd.h stropts.h errno.h sys/resource.h \
3210 sys/systeminfo.h locale.h sys/stream.h termios.h \
3211 libc.h sys/statfs.h poll.h sys/poll.h pwd.h \
3212 utime.h sys/param.h libintl.h libgen.h \
3213 util/debug.h util/msg18n.h frame.h sys/acl.h \
3214 sys/access.h sys/sysinfo.h wchar.h wctype.h)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003215
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003216dnl sys/ptem.h depends on sys/stream.h on Solaris
3217AC_CHECK_HEADERS(sys/ptem.h, [], [],
3218[#if defined HAVE_SYS_STREAM_H
3219# include <sys/stream.h>
3220#endif])
3221
Bram Moolenaar32f31b12009-05-21 13:20:59 +00003222dnl sys/sysctl.h depends on sys/param.h on OpenBSD
3223AC_CHECK_HEADERS(sys/sysctl.h, [], [],
3224[#if defined HAVE_SYS_PARAM_H
3225# include <sys/param.h>
3226#endif])
3227
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003228
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003229dnl pthread_np.h may exist but can only be used after including pthread.h
3230AC_MSG_CHECKING([for pthread_np.h])
3231AC_TRY_COMPILE([
3232#include <pthread.h>
3233#include <pthread_np.h>],
3234 [int i; i = 0;],
3235 AC_MSG_RESULT(yes)
3236 AC_DEFINE(HAVE_PTHREAD_NP_H),
3237 AC_MSG_RESULT(no))
3238
Bram Moolenaare344bea2005-09-01 20:46:49 +00003239AC_CHECK_HEADERS(strings.h)
Bram Moolenaard0573012017-10-28 21:11:06 +02003240if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00003241 dnl The strings.h file on OS/X contains a warning and nothing useful.
3242 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3243else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003244
3245dnl Check if strings.h and string.h can both be included when defined.
3246AC_MSG_CHECKING([if strings.h can be included after string.h])
3247cppflags_save=$CPPFLAGS
3248CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3249AC_TRY_COMPILE([
3250#if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO)
3251# define _NO_PROTO /* like in os_unix.h, causes conflict for AIX (Winn) */
3252 /* but don't do it on AIX 5.1 (Uribarri) */
3253#endif
3254#ifdef HAVE_XM_XM_H
3255# include <Xm/Xm.h> /* This breaks it for HP-UX 11 (Squassabia) */
3256#endif
3257#ifdef HAVE_STRING_H
3258# include <string.h>
3259#endif
3260#if defined(HAVE_STRINGS_H)
3261# include <strings.h>
3262#endif
3263 ], [int i; i = 0;],
3264 AC_MSG_RESULT(yes),
3265 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3266 AC_MSG_RESULT(no))
3267CPPFLAGS=$cppflags_save
Bram Moolenaar9372a112005-12-06 19:59:18 +00003268fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003269
3270dnl Checks for typedefs, structures, and compiler characteristics.
3271AC_PROG_GCC_TRADITIONAL
3272AC_C_CONST
Bram Moolenaar76243bd2009-03-02 01:47:02 +00003273AC_C_VOLATILE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003274AC_TYPE_MODE_T
3275AC_TYPE_OFF_T
3276AC_TYPE_PID_T
3277AC_TYPE_SIZE_T
3278AC_TYPE_UID_T
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003279AC_TYPE_UINT32_T
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003280
Bram Moolenaar071d4272004-06-13 20:20:40 +00003281AC_HEADER_TIME
3282AC_CHECK_TYPE(ino_t, long)
3283AC_CHECK_TYPE(dev_t, unsigned)
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003284AC_C_BIGENDIAN(,,,)
Bram Moolenaar136f29a2016-02-27 20:14:15 +01003285AC_C_INLINE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003286
3287AC_MSG_CHECKING(for rlim_t)
3288if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
3289 AC_MSG_RESULT([(cached) $ac_cv_type_rlim_t])
3290else
3291 AC_EGREP_CPP(dnl
3292changequote(<<,>>)dnl
3293<<(^|[^a-zA-Z_0-9])rlim_t[^a-zA-Z_0-9]>>dnl
3294changequote([,]),
3295 [
3296#include <sys/types.h>
3297#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003298# include <stdlib.h>
3299# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003300#endif
3301#ifdef HAVE_SYS_RESOURCE_H
Bram Moolenaar446cb832008-06-24 21:56:24 +00003302# include <sys/resource.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003303#endif
3304 ], ac_cv_type_rlim_t=yes, ac_cv_type_rlim_t=no)
3305 AC_MSG_RESULT($ac_cv_type_rlim_t)
3306fi
3307if test $ac_cv_type_rlim_t = no; then
3308 cat >> confdefs.h <<\EOF
3309#define rlim_t unsigned long
3310EOF
3311fi
3312
3313AC_MSG_CHECKING(for stack_t)
3314if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then
3315 AC_MSG_RESULT([(cached) $ac_cv_type_stack_t])
3316else
3317 AC_EGREP_CPP(stack_t,
3318 [
3319#include <sys/types.h>
3320#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003321# include <stdlib.h>
3322# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003323#endif
3324#include <signal.h>
3325 ], ac_cv_type_stack_t=yes, ac_cv_type_stack_t=no)
3326 AC_MSG_RESULT($ac_cv_type_stack_t)
3327fi
3328if test $ac_cv_type_stack_t = no; then
3329 cat >> confdefs.h <<\EOF
3330#define stack_t struct sigaltstack
3331EOF
3332fi
3333
3334dnl BSDI uses ss_base while others use ss_sp for the stack pointer.
3335AC_MSG_CHECKING(whether stack_t has an ss_base field)
3336AC_TRY_COMPILE([
3337#include <sys/types.h>
3338#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003339# include <stdlib.h>
3340# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003341#endif
3342#include <signal.h>
3343#include "confdefs.h"
3344 ], [stack_t sigstk; sigstk.ss_base = 0; ],
3345 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SS_BASE),
3346 AC_MSG_RESULT(no))
3347
3348olibs="$LIBS"
3349AC_MSG_CHECKING(--with-tlib argument)
3350AC_ARG_WITH(tlib, [ --with-tlib=library terminal library to be used ],)
3351if test -n "$with_tlib"; then
3352 AC_MSG_RESULT($with_tlib)
3353 LIBS="$LIBS -l$with_tlib"
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003354 AC_MSG_CHECKING(for linking with $with_tlib library)
3355 AC_TRY_LINK([], [], AC_MSG_RESULT(OK), AC_MSG_ERROR(FAILED))
3356 dnl Need to check for tgetent() below.
3357 olibs="$LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003358else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003359 AC_MSG_RESULT([empty: automatic terminal library selection])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003360 dnl On HP-UX 10.10 termcap or termlib should be used instead of
3361 dnl curses, because curses is much slower.
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003362 dnl Newer versions of ncurses are preferred over anything, except
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02003363 dnl when tinfo has been split off, it contains all we need.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003364 dnl Older versions of ncurses have bugs, get a new one!
3365 dnl Digital Unix (OSF1) should use curses (Ronald Schild).
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00003366 dnl On SCO Openserver should prefer termlib (Roger Cornelius).
Bram Moolenaar071d4272004-06-13 20:20:40 +00003367 case "`uname -s 2>/dev/null`" in
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003368 OSF1|SCO_SV) tlibs="tinfo ncurses curses termlib termcap";;
3369 *) tlibs="tinfo ncurses termlib termcap curses";;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003370 esac
3371 for libname in $tlibs; do
3372 AC_CHECK_LIB(${libname}, tgetent,,)
3373 if test "x$olibs" != "x$LIBS"; then
3374 dnl It's possible that a library is found but it doesn't work
3375 dnl e.g., shared library that cannot be found
3376 dnl compile and run a test program to be sure
3377 AC_TRY_RUN([
3378#ifdef HAVE_TERMCAP_H
3379# include <termcap.h>
3380#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003381#if STDC_HEADERS
3382# include <stdlib.h>
3383# include <stddef.h>
3384#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003385main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }],
3386 res="OK", res="FAIL", res="FAIL")
3387 if test "$res" = "OK"; then
3388 break
3389 fi
3390 AC_MSG_RESULT($libname library is not usable)
3391 LIBS="$olibs"
3392 fi
3393 done
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003394 if test "x$olibs" = "x$LIBS"; then
3395 AC_MSG_RESULT(no terminal library found)
3396 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003397fi
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003398
3399if test "x$olibs" = "x$LIBS"; then
3400 AC_MSG_CHECKING([for tgetent()])
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00003401 AC_TRY_LINK([],
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003402 [char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");],
3403 AC_MSG_RESULT(yes),
3404 AC_MSG_ERROR([NOT FOUND!
3405 You need to install a terminal library; for example ncurses.
3406 Or specify the name of the library with --with-tlib.]))
3407fi
3408
Bram Moolenaar446cb832008-06-24 21:56:24 +00003409AC_CACHE_CHECK([whether we talk terminfo], [vim_cv_terminfo],
3410 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003411 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003412#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003413#ifdef HAVE_TERMCAP_H
3414# include <termcap.h>
3415#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003416#ifdef HAVE_STRING_H
3417# include <string.h>
3418#endif
3419#if STDC_HEADERS
3420# include <stdlib.h>
3421# include <stddef.h>
3422#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003423main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003424{char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003425 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003426 vim_cv_terminfo=no
3427 ],[
3428 vim_cv_terminfo=yes
3429 ],[
3430 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_terminfo')
3431 ])
3432 ])
3433
3434if test "x$vim_cv_terminfo" = "xyes" ; then
3435 AC_DEFINE(TERMINFO)
3436fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003437
Bram Moolenaara88254f2017-11-02 23:04:14 +01003438AC_CACHE_CHECK([what tgetent() returns for an unknown terminal], [vim_cv_tgetent],
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003439 [
3440 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003441#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003442#ifdef HAVE_TERMCAP_H
3443# include <termcap.h>
3444#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003445#if STDC_HEADERS
3446# include <stdlib.h>
3447# include <stddef.h>
3448#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003449main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003450{char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003451 ]])],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003452 vim_cv_tgetent=zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003453 ],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003454 vim_cv_tgetent=non-zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003455 ],[
3456 AC_MSG_ERROR(failed to compile test program.)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003457 ])
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003458 ])
3459
Bram Moolenaara88254f2017-11-02 23:04:14 +01003460if test "x$vim_cv_tgetent" = "xzero" ; then
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003461 AC_DEFINE(TGETENT_ZERO_ERR, 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003462fi
3463
3464AC_MSG_CHECKING(whether termcap.h contains ospeed)
3465AC_TRY_LINK([
3466#ifdef HAVE_TERMCAP_H
3467# include <termcap.h>
3468#endif
3469 ], [ospeed = 20000],
3470 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED),
3471 [AC_MSG_RESULT(no)
3472 AC_MSG_CHECKING(whether ospeed can be extern)
3473 AC_TRY_LINK([
3474#ifdef HAVE_TERMCAP_H
3475# include <termcap.h>
3476#endif
3477extern short ospeed;
3478 ], [ospeed = 20000],
3479 AC_MSG_RESULT(yes); AC_DEFINE(OSPEED_EXTERN),
3480 AC_MSG_RESULT(no))]
3481 )
3482
3483AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC])
3484AC_TRY_LINK([
3485#ifdef HAVE_TERMCAP_H
3486# include <termcap.h>
3487#endif
3488 ], [if (UP == 0 && BC == 0) PC = 1],
3489 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UP_BC_PC),
3490 [AC_MSG_RESULT(no)
3491 AC_MSG_CHECKING([whether UP, BC and PC can be extern])
3492 AC_TRY_LINK([
3493#ifdef HAVE_TERMCAP_H
3494# include <termcap.h>
3495#endif
3496extern char *UP, *BC, PC;
3497 ], [if (UP == 0 && BC == 0) PC = 1],
3498 AC_MSG_RESULT(yes); AC_DEFINE(UP_BC_PC_EXTERN),
3499 AC_MSG_RESULT(no))]
3500 )
3501
3502AC_MSG_CHECKING(whether tputs() uses outfuntype)
3503AC_TRY_COMPILE([
3504#ifdef HAVE_TERMCAP_H
3505# include <termcap.h>
3506#endif
3507 ], [extern int xx(); tputs("test", 1, (outfuntype)xx)],
3508 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OUTFUNTYPE),
3509 AC_MSG_RESULT(no))
3510
3511dnl On some SCO machines sys/select redefines struct timeval
3512AC_MSG_CHECKING([whether sys/select.h and sys/time.h may both be included])
3513AC_TRY_COMPILE([
3514#include <sys/types.h>
3515#include <sys/time.h>
3516#include <sys/select.h>], ,
3517 AC_MSG_RESULT(yes)
3518 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME),
3519 AC_MSG_RESULT(no))
3520
3521dnl AC_DECL_SYS_SIGLIST
3522
3523dnl Checks for pty.c (copied from screen) ==========================
3524AC_MSG_CHECKING(for /dev/ptc)
3525if test -r /dev/ptc; then
3526 AC_DEFINE(HAVE_DEV_PTC)
3527 AC_MSG_RESULT(yes)
3528else
3529 AC_MSG_RESULT(no)
3530fi
3531
3532AC_MSG_CHECKING(for SVR4 ptys)
3533if test -c /dev/ptmx ; then
3534 AC_TRY_LINK([], [ptsname(0);grantpt(0);unlockpt(0);],
3535 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SVR4_PTYS),
3536 AC_MSG_RESULT(no))
3537else
3538 AC_MSG_RESULT(no)
3539fi
3540
3541AC_MSG_CHECKING(for ptyranges)
3542if test -d /dev/ptym ; then
3543 pdir='/dev/ptym'
3544else
3545 pdir='/dev'
3546fi
3547dnl SCO uses ptyp%d
3548AC_EGREP_CPP(yes,
3549[#ifdef M_UNIX
3550 yes;
3551#endif
3552 ], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
3553dnl if test -c /dev/ptyp19; then
3554dnl ptys=`echo /dev/ptyp??`
3555dnl else
3556dnl ptys=`echo $pdir/pty??`
3557dnl fi
3558if test "$ptys" != "$pdir/pty??" ; then
3559 p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
3560 p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'`
3561 AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
3562 AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
3563 AC_MSG_RESULT([$p0 / $p1])
3564else
3565 AC_MSG_RESULT([don't know])
3566fi
3567
3568dnl **** pty mode/group handling ****
3569dnl
3570dnl support provided by Luke Mewburn <lm@rmit.edu.au>, 931222
Bram Moolenaar071d4272004-06-13 20:20:40 +00003571rm -f conftest_grp
Bram Moolenaar446cb832008-06-24 21:56:24 +00003572AC_CACHE_CHECK([default tty permissions/group], [vim_cv_tty_group],
3573 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003574 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003575#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003576#include <sys/types.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003577#if STDC_HEADERS
3578# include <stdlib.h>
3579# include <stddef.h>
3580#endif
3581#ifdef HAVE_UNISTD_H
3582#include <unistd.h>
3583#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003584#include <sys/stat.h>
3585#include <stdio.h>
3586main()
3587{
3588 struct stat sb;
3589 char *x,*ttyname();
3590 int om, m;
3591 FILE *fp;
3592
3593 if (!(x = ttyname(0))) exit(1);
3594 if (stat(x, &sb)) exit(1);
3595 om = sb.st_mode;
3596 if (om & 002) exit(0);
3597 m = system("mesg y");
3598 if (m == -1 || m == 127) exit(1);
3599 if (stat(x, &sb)) exit(1);
3600 m = sb.st_mode;
3601 if (chmod(x, om)) exit(1);
3602 if (m & 002) exit(0);
3603 if (sb.st_gid == getgid()) exit(1);
3604 if (!(fp=fopen("conftest_grp", "w")))
3605 exit(1);
3606 fprintf(fp, "%d\n", sb.st_gid);
3607 fclose(fp);
3608 exit(0);
3609}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003610 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003611 if test -f conftest_grp; then
3612 vim_cv_tty_group=`cat conftest_grp`
3613 if test "x$vim_cv_tty_mode" = "x" ; then
3614 vim_cv_tty_mode=0620
3615 fi
3616 AC_MSG_RESULT([pty mode: $vim_cv_tty_mode, group: $vim_cv_tty_group])
3617 else
3618 vim_cv_tty_group=world
Bram Moolenaar72951072009-12-02 16:58:33 +00003619 AC_MSG_RESULT([ptys are world accessible])
Bram Moolenaar446cb832008-06-24 21:56:24 +00003620 fi
3621 ],[
3622 vim_cv_tty_group=world
Bram Moolenaar72951072009-12-02 16:58:33 +00003623 AC_MSG_RESULT([can't determine - assume ptys are world accessible])
Bram Moolenaar446cb832008-06-24 21:56:24 +00003624 ],[
3625 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_tty_group' and 'vim_cv_tty_mode')
3626 ])
3627 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003628rm -f conftest_grp
3629
Bram Moolenaar446cb832008-06-24 21:56:24 +00003630if test "x$vim_cv_tty_group" != "xworld" ; then
3631 AC_DEFINE_UNQUOTED(PTYGROUP,$vim_cv_tty_group)
3632 if test "x$vim_cv_tty_mode" = "x" ; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02003633 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 +00003634 else
3635 AC_DEFINE(PTYMODE, 0620)
3636 fi
3637fi
3638
Bram Moolenaar071d4272004-06-13 20:20:40 +00003639dnl Checks for library functions. ===================================
3640
3641AC_TYPE_SIGNAL
3642
3643dnl find out what to use at the end of a signal function
3644if test $ac_cv_type_signal = void; then
3645 AC_DEFINE(SIGRETURN, [return])
3646else
3647 AC_DEFINE(SIGRETURN, [return 0])
3648fi
3649
3650dnl check if struct sigcontext is defined (used for SGI only)
3651AC_MSG_CHECKING(for struct sigcontext)
3652AC_TRY_COMPILE([
3653#include <signal.h>
3654test_sig()
3655{
3656 struct sigcontext *scont;
3657 scont = (struct sigcontext *)0;
3658 return 1;
3659} ], ,
3660 AC_MSG_RESULT(yes)
3661 AC_DEFINE(HAVE_SIGCONTEXT),
3662 AC_MSG_RESULT(no))
3663
3664dnl tricky stuff: try to find out if getcwd() is implemented with
3665dnl system("sh -c pwd")
Bram Moolenaar446cb832008-06-24 21:56:24 +00003666AC_CACHE_CHECK([getcwd implementation is broken], [vim_cv_getcwd_broken],
3667 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003668 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003669#include "confdefs.h"
3670#ifdef HAVE_UNISTD_H
3671#include <unistd.h>
3672#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003673char *dagger[] = { "IFS=pwd", 0 };
3674main()
3675{
3676 char buffer[500];
3677 extern char **environ;
3678 environ = dagger;
3679 return getcwd(buffer, 500) ? 0 : 1;
Bram Moolenaar446cb832008-06-24 21:56:24 +00003680}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003681 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003682 vim_cv_getcwd_broken=no
3683 ],[
3684 vim_cv_getcwd_broken=yes
3685 ],[
3686 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_getcwd_broken')
3687 ])
3688 ])
3689
3690if test "x$vim_cv_getcwd_broken" = "xyes" ; then
3691 AC_DEFINE(BAD_GETCWD)
3692fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003693
Bram Moolenaar25153e12010-02-24 14:47:08 +01003694dnl Check for functions in one big call, to reduce the size of configure.
3695dnl Can only be used for functions that do not require any include.
Bram Moolenaarcd142e32017-11-16 17:03:45 +01003696AC_CHECK_FUNCS(fchdir fchown fchmod fsync getcwd getpseudotty \
Bram Moolenaarb129a442016-12-01 17:25:20 +01003697 getpwent getpwnam getpwuid getrlimit gettimeofday getwd lstat \
Bram Moolenaareaf03392009-11-17 11:08:52 +00003698 memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
Bram Moolenaar2fcf6682017-03-11 20:03:42 +01003699 getpgid setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
Bram Moolenaarbb09ceb2016-10-18 16:27:23 +02003700 sigprocmask sigvec strcasecmp strerror strftime stricmp strncasecmp \
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00003701 strnicmp strpbrk strtol tgetent towlower towupper iswupper \
Bram Moolenaarcd142e32017-11-16 17:03:45 +01003702 usleep utime utimes mblen ftruncate)
Bram Moolenaar25153e12010-02-24 14:47:08 +01003703AC_FUNC_FSEEKO
Bram Moolenaar071d4272004-06-13 20:20:40 +00003704
Bram Moolenaar317fd3a2010-05-07 16:05:55 +02003705dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when
3706dnl appropriate, so that off_t is 64 bits when needed.
3707AC_SYS_LARGEFILE
3708
Bram Moolenaar071d4272004-06-13 20:20:40 +00003709dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible
3710AC_MSG_CHECKING(for st_blksize)
3711AC_TRY_COMPILE(
3712[#include <sys/types.h>
3713#include <sys/stat.h>],
3714[ struct stat st;
3715 int n;
3716
3717 stat("/", &st);
3718 n = (int)st.st_blksize;],
3719 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ST_BLKSIZE),
3720 AC_MSG_RESULT(no))
3721
Bram Moolenaar446cb832008-06-24 21:56:24 +00003722AC_CACHE_CHECK([whether stat() ignores a trailing slash], [vim_cv_stat_ignores_slash],
3723 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003724 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003725#include "confdefs.h"
3726#if STDC_HEADERS
3727# include <stdlib.h>
3728# include <stddef.h>
3729#endif
3730#include <sys/types.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003731#include <sys/stat.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003732main() {struct stat st; exit(stat("configure/", &st) != 0); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003733 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003734 vim_cv_stat_ignores_slash=yes
3735 ],[
3736 vim_cv_stat_ignores_slash=no
3737 ],[
3738 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_stat_ignores_slash')
3739 ])
3740 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003741
Bram Moolenaar446cb832008-06-24 21:56:24 +00003742if test "x$vim_cv_stat_ignores_slash" = "xyes" ; then
3743 AC_DEFINE(STAT_IGNORES_SLASH)
3744fi
3745
Bram Moolenaar071d4272004-06-13 20:20:40 +00003746dnl Link with iconv for charset translation, if not found without library.
3747dnl check for iconv() requires including iconv.h
3748dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
3749dnl has been installed.
3750AC_MSG_CHECKING(for iconv_open())
3751save_LIBS="$LIBS"
3752LIBS="$LIBS -liconv"
3753AC_TRY_LINK([
3754#ifdef HAVE_ICONV_H
3755# include <iconv.h>
3756#endif
3757 ], [iconv_open("fr", "to");],
3758 AC_MSG_RESULT(yes; with -liconv); AC_DEFINE(HAVE_ICONV),
3759 LIBS="$save_LIBS"
3760 AC_TRY_LINK([
3761#ifdef HAVE_ICONV_H
3762# include <iconv.h>
3763#endif
3764 ], [iconv_open("fr", "to");],
3765 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ICONV),
3766 AC_MSG_RESULT(no)))
3767
3768
3769AC_MSG_CHECKING(for nl_langinfo(CODESET))
3770AC_TRY_LINK([
3771#ifdef HAVE_LANGINFO_H
3772# include <langinfo.h>
3773#endif
3774], [char *cs = nl_langinfo(CODESET);],
3775 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET),
3776 AC_MSG_RESULT(no))
3777
Bram Moolenaar446cb832008-06-24 21:56:24 +00003778dnl Need various functions for floating point support. Only enable
3779dnl floating point when they are all present.
3780AC_CHECK_LIB(m, strtod)
3781AC_MSG_CHECKING([for strtod() and other floating point functions])
3782AC_TRY_LINK([
3783#ifdef HAVE_MATH_H
3784# include <math.h>
3785#endif
3786#if STDC_HEADERS
3787# include <stdlib.h>
3788# include <stddef.h>
3789#endif
3790], [char *s; double d;
3791 d = strtod("1.1", &s);
3792 d = fabs(1.11);
3793 d = ceil(1.11);
3794 d = floor(1.11);
3795 d = log10(1.11);
3796 d = pow(1.11, 2.22);
3797 d = sqrt(1.11);
3798 d = sin(1.11);
3799 d = cos(1.11);
3800 d = atan(1.11);
3801 ],
3802 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT_FUNCS),
3803 AC_MSG_RESULT(no))
3804
Bram Moolenaara6b89762016-02-29 21:38:26 +01003805dnl isinf() and isnan() need to include header files and may need -lm.
3806AC_MSG_CHECKING([for isinf()])
3807AC_TRY_LINK([
3808#ifdef HAVE_MATH_H
3809# include <math.h>
3810#endif
3811#if STDC_HEADERS
3812# include <stdlib.h>
3813# include <stddef.h>
3814#endif
3815], [int r = isinf(1.11); ],
3816 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISINF),
3817 AC_MSG_RESULT(no))
3818
3819AC_MSG_CHECKING([for isnan()])
3820AC_TRY_LINK([
3821#ifdef HAVE_MATH_H
3822# include <math.h>
3823#endif
3824#if STDC_HEADERS
3825# include <stdlib.h>
3826# include <stddef.h>
3827#endif
3828], [int r = isnan(1.11); ],
3829 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISNAN),
3830 AC_MSG_RESULT(no))
3831
Bram Moolenaar071d4272004-06-13 20:20:40 +00003832dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI
3833dnl when -lacl works, also try to use -lattr (required for Debian).
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003834dnl On Solaris, use the acl_get/set functions in libsec, if present.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003835AC_MSG_CHECKING(--disable-acl argument)
3836AC_ARG_ENABLE(acl,
Bram Moolenaard6d30422018-01-28 22:48:55 +01003837 [ --disable-acl No check for ACL support.],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003838 , [enable_acl="yes"])
3839if test "$enable_acl" = "yes"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01003840 AC_MSG_RESULT(no)
3841 AC_CHECK_LIB(posix1e, acl_get_file, [LIBS="$LIBS -lposix1e"],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003842 AC_CHECK_LIB(acl, acl_get_file, [LIBS="$LIBS -lacl"
3843 AC_CHECK_LIB(attr, fgetxattr, LIBS="$LIBS -lattr",,)],,),)
3844
Bram Moolenaard6d30422018-01-28 22:48:55 +01003845 AC_MSG_CHECKING(for POSIX ACL support)
3846 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003847#include <sys/types.h>
3848#ifdef HAVE_SYS_ACL_H
3849# include <sys/acl.h>
3850#endif
3851acl_t acl;], [acl = acl_get_file("foo", ACL_TYPE_ACCESS);
3852 acl_set_file("foo", ACL_TYPE_ACCESS, acl);
3853 acl_free(acl);],
3854 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_ACL),
3855 AC_MSG_RESULT(no))
3856
Bram Moolenaard6d30422018-01-28 22:48:55 +01003857 AC_CHECK_LIB(sec, acl_get, [LIBS="$LIBS -lsec"; AC_DEFINE(HAVE_SOLARIS_ZFS_ACL)],
3858 AC_MSG_CHECKING(for Solaris ACL support)
3859 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003860#ifdef HAVE_SYS_ACL_H
3861# include <sys/acl.h>
3862#endif], [acl("foo", GETACLCNT, 0, NULL);
3863 ],
3864 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOLARIS_ACL),
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003865 AC_MSG_RESULT(no)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003866
Bram Moolenaard6d30422018-01-28 22:48:55 +01003867 AC_MSG_CHECKING(for AIX ACL support)
3868 AC_TRY_LINK([
Bram Moolenaar446cb832008-06-24 21:56:24 +00003869#if STDC_HEADERS
3870# include <stdlib.h>
3871# include <stddef.h>
3872#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003873#ifdef HAVE_SYS_ACL_H
3874# include <sys/acl.h>
3875#endif
3876#ifdef HAVE_SYS_ACCESS_H
3877# include <sys/access.h>
3878#endif
3879#define _ALL_SOURCE
3880
3881#include <sys/stat.h>
3882
3883int aclsize;
3884struct acl *aclent;], [aclsize = sizeof(struct acl);
3885 aclent = (void *)malloc(aclsize);
3886 statacl("foo", STX_NORMAL, aclent, aclsize);
3887 ],
3888 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_AIX_ACL),
3889 AC_MSG_RESULT(no))
3890else
3891 AC_MSG_RESULT(yes)
3892fi
3893
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02003894if test "x$GTK_CFLAGS" != "x"; then
3895 dnl pango_shape_full() is new, fall back to pango_shape().
3896 AC_MSG_CHECKING(for pango_shape_full)
3897 ac_save_CFLAGS="$CFLAGS"
3898 ac_save_LIBS="$LIBS"
3899 CFLAGS="$CFLAGS $GTK_CFLAGS"
3900 LIBS="$LIBS $GTK_LIBS"
Bram Moolenaar5325b9b2015-09-09 20:27:02 +02003901 AC_TRY_LINK(
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02003902 [#include <gtk/gtk.h>],
3903 [ pango_shape_full(NULL, 0, NULL, 0, NULL, NULL); ],
3904 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_PANGO_SHAPE_FULL),
3905 AC_MSG_RESULT(no))
3906 CFLAGS="$ac_save_CFLAGS"
3907 LIBS="$ac_save_LIBS"
3908fi
3909
Bram Moolenaar071d4272004-06-13 20:20:40 +00003910AC_MSG_CHECKING(--disable-gpm argument)
3911AC_ARG_ENABLE(gpm,
3912 [ --disable-gpm Don't use gpm (Linux mouse daemon).], ,
3913 [enable_gpm="yes"])
3914
3915if test "$enable_gpm" = "yes"; then
3916 AC_MSG_RESULT(no)
3917 dnl Checking if gpm support can be compiled
3918 AC_CACHE_CHECK([for gpm], vi_cv_have_gpm,
3919 [olibs="$LIBS" ; LIBS="-lgpm"]
3920 AC_TRY_LINK(
3921 [#include <gpm.h>
3922 #include <linux/keyboard.h>],
3923 [Gpm_GetLibVersion(NULL);],
3924 dnl Configure defines HAVE_GPM, if it is defined feature.h defines
3925 dnl FEAT_MOUSE_GPM if mouse support is included
3926 [vi_cv_have_gpm=yes],
3927 [vi_cv_have_gpm=no])
3928 [LIBS="$olibs"]
3929 )
3930 if test $vi_cv_have_gpm = yes; then
3931 LIBS="$LIBS -lgpm"
3932 AC_DEFINE(HAVE_GPM)
3933 fi
3934else
3935 AC_MSG_RESULT(yes)
3936fi
3937
Bram Moolenaar446cb832008-06-24 21:56:24 +00003938AC_MSG_CHECKING(--disable-sysmouse argument)
3939AC_ARG_ENABLE(sysmouse,
Bram Moolenaar8008b632017-07-18 21:33:20 +02003940 [ --disable-sysmouse Don't use sysmouse (mouse in *BSD console).], ,
Bram Moolenaar446cb832008-06-24 21:56:24 +00003941 [enable_sysmouse="yes"])
3942
3943if test "$enable_sysmouse" = "yes"; then
3944 AC_MSG_RESULT(no)
3945 dnl Checking if sysmouse support can be compiled
3946 dnl Configure defines HAVE_SYSMOUSE, if it is defined feature.h
3947 dnl defines FEAT_SYSMOUSE if mouse support is included
3948 AC_CACHE_CHECK([for sysmouse], vi_cv_have_sysmouse,
3949 AC_TRY_LINK(
3950 [#include <sys/consio.h>
3951 #include <signal.h>
3952 #include <sys/fbio.h>],
3953 [struct mouse_info mouse;
3954 mouse.operation = MOUSE_MODE;
3955 mouse.operation = MOUSE_SHOW;
3956 mouse.u.mode.mode = 0;
3957 mouse.u.mode.signal = SIGUSR2;],
3958 [vi_cv_have_sysmouse=yes],
3959 [vi_cv_have_sysmouse=no])
3960 )
3961 if test $vi_cv_have_sysmouse = yes; then
3962 AC_DEFINE(HAVE_SYSMOUSE)
3963 fi
3964else
3965 AC_MSG_RESULT(yes)
3966fi
3967
Bram Moolenaarf05da212009-11-17 16:13:15 +00003968dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
3969AC_MSG_CHECKING(for FD_CLOEXEC)
3970AC_TRY_COMPILE(
3971[#if HAVE_FCNTL_H
3972# include <fcntl.h>
3973#endif],
3974[ int flag = FD_CLOEXEC;],
3975 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
3976 AC_MSG_RESULT(not usable))
3977
Bram Moolenaar071d4272004-06-13 20:20:40 +00003978dnl rename needs to be checked separately to work on Nextstep with cc
3979AC_MSG_CHECKING(for rename)
3980AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
3981 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
3982 AC_MSG_RESULT(no))
3983
3984dnl sysctl() may exist but not the arguments we use
3985AC_MSG_CHECKING(for sysctl)
3986AC_TRY_COMPILE(
3987[#include <sys/types.h>
3988#include <sys/sysctl.h>],
3989[ int mib[2], r;
3990 size_t len;
3991
3992 mib[0] = CTL_HW;
3993 mib[1] = HW_USERMEM;
3994 len = sizeof(r);
3995 (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
3996 ],
3997 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL),
3998 AC_MSG_RESULT(not usable))
3999
4000dnl sysinfo() may exist but not be Linux compatible
4001AC_MSG_CHECKING(for sysinfo)
4002AC_TRY_COMPILE(
4003[#include <sys/types.h>
4004#include <sys/sysinfo.h>],
4005[ struct sysinfo sinfo;
4006 int t;
4007
4008 (void)sysinfo(&sinfo);
4009 t = sinfo.totalram;
4010 ],
4011 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
4012 AC_MSG_RESULT(not usable))
4013
Bram Moolenaar914572a2007-05-01 11:37:47 +00004014dnl struct sysinfo may have the mem_unit field or not
4015AC_MSG_CHECKING(for sysinfo.mem_unit)
4016AC_TRY_COMPILE(
4017[#include <sys/types.h>
4018#include <sys/sysinfo.h>],
4019[ struct sysinfo sinfo;
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02004020 sinfo.mem_unit = 1;
Bram Moolenaar914572a2007-05-01 11:37:47 +00004021 ],
4022 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_MEM_UNIT),
4023 AC_MSG_RESULT(no))
4024
Bram Moolenaar071d4272004-06-13 20:20:40 +00004025dnl sysconf() may exist but not support what we want to use
4026AC_MSG_CHECKING(for sysconf)
4027AC_TRY_COMPILE(
4028[#include <unistd.h>],
4029[ (void)sysconf(_SC_PAGESIZE);
4030 (void)sysconf(_SC_PHYS_PAGES);
4031 ],
4032 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
4033 AC_MSG_RESULT(not usable))
4034
Bram Moolenaar914703b2010-05-31 21:59:46 +02004035AC_CHECK_SIZEOF([int])
4036AC_CHECK_SIZEOF([long])
4037AC_CHECK_SIZEOF([time_t])
4038AC_CHECK_SIZEOF([off_t])
Bram Moolenaar644fdff2010-05-30 13:26:21 +02004039
Bram Moolenaara2aa31a2014-02-23 22:52:40 +01004040dnl Use different names to avoid clashing with other header files.
4041AC_DEFINE_UNQUOTED(VIM_SIZEOF_INT, [$ac_cv_sizeof_int])
4042AC_DEFINE_UNQUOTED(VIM_SIZEOF_LONG, [$ac_cv_sizeof_long])
4043
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004044dnl Make sure that uint32_t is really 32 bits unsigned.
4045AC_MSG_CHECKING([uint32_t is 32 bits])
4046AC_TRY_RUN([
4047#ifdef HAVE_STDINT_H
4048# include <stdint.h>
4049#endif
4050#ifdef HAVE_INTTYPES_H
4051# include <inttypes.h>
4052#endif
4053main() {
4054 uint32_t nr1 = (uint32_t)-1;
4055 uint32_t nr2 = (uint32_t)0xffffffffUL;
4056 if (sizeof(uint32_t) != 4 || nr1 != 0xffffffffUL || nr2 + 1 != 0) exit(1);
4057 exit(0);
4058}],
4059AC_MSG_RESULT(ok),
4060AC_MSG_ERROR([WRONG! uint32_t not defined correctly.]),
Bram Moolenaar323cb952011-12-14 19:22:34 +01004061AC_MSG_WARN([cannot check uint32_t when cross-compiling.]))
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004062
Bram Moolenaar446cb832008-06-24 21:56:24 +00004063dnl Check for memmove() before bcopy(), makes memmove() be used when both are
4064dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
4065
Bram Moolenaar071d4272004-06-13 20:20:40 +00004066[bcopy_test_prog='
Bram Moolenaar446cb832008-06-24 21:56:24 +00004067#include "confdefs.h"
4068#ifdef HAVE_STRING_H
4069# include <string.h>
4070#endif
4071#if STDC_HEADERS
4072# include <stdlib.h>
4073# include <stddef.h>
4074#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004075main() {
4076 char buf[10];
4077 strcpy(buf, "abcdefghi");
4078 mch_memmove(buf, buf + 2, 3);
4079 if (strncmp(buf, "ababcf", 6))
4080 exit(1);
4081 strcpy(buf, "abcdefghi");
4082 mch_memmove(buf + 2, buf, 3);
4083 if (strncmp(buf, "cdedef", 6))
4084 exit(1);
4085 exit(0); /* libc version works properly. */
4086}']
4087
Bram Moolenaar446cb832008-06-24 21:56:24 +00004088AC_CACHE_CHECK([whether memmove handles overlaps],[vim_cv_memmove_handles_overlap],
4089 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004090 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 +00004091 [
4092 vim_cv_memmove_handles_overlap=yes
4093 ],[
4094 vim_cv_memmove_handles_overlap=no
4095 ],[
4096 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memmove_handles_overlap')
4097 ])
4098 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00004099
Bram Moolenaar446cb832008-06-24 21:56:24 +00004100if test "x$vim_cv_memmove_handles_overlap" = "xyes" ; then
4101 AC_DEFINE(USEMEMMOVE)
4102else
4103 AC_CACHE_CHECK([whether bcopy handles overlaps],[vim_cv_bcopy_handles_overlap],
4104 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004105 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 +00004106 [
4107 vim_cv_bcopy_handles_overlap=yes
4108 ],[
4109 vim_cv_bcopy_handles_overlap=no
4110 ],[
4111 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_bcopy_handles_overlap')
4112 ])
4113 ])
4114
4115 if test "x$vim_cv_bcopy_handles_overlap" = "xyes" ; then
4116 AC_DEFINE(USEBCOPY)
4117 else
4118 AC_CACHE_CHECK([whether memcpy handles overlaps],[vim_cv_memcpy_handles_overlap],
4119 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004120 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 +00004121 [
4122 vim_cv_memcpy_handles_overlap=yes
4123 ],[
4124 vim_cv_memcpy_handles_overlap=no
4125 ],[
4126 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memcpy_handles_overlap')
4127 ])
4128 ])
4129
4130 if test "x$vim_cv_memcpy_handles_overlap" = "xyes" ; then
4131 AC_DEFINE(USEMEMCPY)
4132 fi
4133 fi
4134fi
4135
Bram Moolenaar071d4272004-06-13 20:20:40 +00004136
4137dnl Check for multibyte locale functions
4138dnl Find out if _Xsetlocale() is supported by libX11.
4139dnl Check if X_LOCALE should be defined.
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004140if test "x$with_x" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004141 cflags_save=$CFLAGS
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004142 libs_save=$LIBS
4143 LIBS="$LIBS $X_LIBS $GUI_LIB_LOC $GUI_X_LIBS $X_PRE_LIBS $X_LIB $X_EXTRA_LIBS"
4144 CFLAGS="$CFLAGS $X_CFLAGS"
4145
4146 AC_MSG_CHECKING(whether X_LOCALE needed)
4147 AC_TRY_COMPILE([#include <X11/Xlocale.h>],,
4148 AC_TRY_LINK_FUNC([_Xsetlocale], [AC_MSG_RESULT(yes)
4149 AC_DEFINE(X_LOCALE)], AC_MSG_RESULT(no)),
4150 AC_MSG_RESULT(no))
4151
4152 AC_MSG_CHECKING(whether Xutf8SetWMProperties() can be used)
4153 AC_TRY_LINK_FUNC([Xutf8SetWMProperties], [AC_MSG_RESULT(yes)
4154 AC_DEFINE(HAVE_XUTF8SETWMPROPERTIES)], AC_MSG_RESULT(no))
4155
Bram Moolenaar071d4272004-06-13 20:20:40 +00004156 CFLAGS=$cflags_save
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004157 LIBS=$libs_save
Bram Moolenaar071d4272004-06-13 20:20:40 +00004158fi
4159
4160dnl Link with xpg4, it is said to make Korean locale working
4161AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,)
4162
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004163dnl Check how we can run ctags. Default to "ctags" when nothing works.
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02004164dnl Use --version to detect Exuberant ctags (preferred)
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004165dnl Add --fields=+S to get function signatures for omni completion.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004166dnl -t for typedefs (many ctags have this)
4167dnl -s for static functions (Elvis ctags only?)
4168dnl -v for variables. Dangerous, most ctags take this for 'vgrind style'.
4169dnl -i+m to test for older Exuberant ctags
4170AC_MSG_CHECKING(how to create tags)
4171test -f tags && mv tags tags.save
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004172if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004173 TAGPRG="ctags -I INIT+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004174elif (eval exctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
4175 TAGPRG="exctags -I INIT+ --fields=+S"
4176elif (eval exuberant-ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
4177 TAGPRG="exuberant-ctags -I INIT+ --fields=+S"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004178else
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004179 TAGPRG="ctags"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004180 (eval etags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags"
4181 (eval etags -c /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags -c"
4182 (eval ctags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags"
4183 (eval ctags -t /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -t"
4184 (eval ctags -ts /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -ts"
4185 (eval ctags -tvs /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -tvs"
4186 (eval ctags -i+m /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -i+m"
4187fi
4188test -f tags.save && mv tags.save tags
4189AC_MSG_RESULT($TAGPRG) AC_SUBST(TAGPRG)
4190
4191dnl Check how we can run man with a section number
4192AC_MSG_CHECKING(how to run man with a section nr)
4193MANDEF="man"
Bram Moolenaar8b131502008-02-13 09:28:19 +00004194(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 +00004195AC_MSG_RESULT($MANDEF)
4196if test "$MANDEF" = "man -s"; then
4197 AC_DEFINE(USEMAN_S)
4198fi
4199
4200dnl Check if gettext() is working and if it needs -lintl
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004201dnl We take care to base this on an empty LIBS: on some systems libelf would be
4202dnl in LIBS and implicitly take along libintl. The final LIBS would then not
4203dnl contain libintl, and the link step would fail due to -Wl,--as-needed.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004204AC_MSG_CHECKING(--disable-nls argument)
4205AC_ARG_ENABLE(nls,
4206 [ --disable-nls Don't support NLS (gettext()).], ,
4207 [enable_nls="yes"])
4208
4209if test "$enable_nls" = "yes"; then
4210 AC_MSG_RESULT(no)
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00004211
4212 INSTALL_LANGS=install-languages
4213 AC_SUBST(INSTALL_LANGS)
4214 INSTALL_TOOL_LANGS=install-tool-languages
4215 AC_SUBST(INSTALL_TOOL_LANGS)
4216
Bram Moolenaar071d4272004-06-13 20:20:40 +00004217 AC_CHECK_PROG(MSGFMT, msgfmt, msgfmt, )
4218 AC_MSG_CHECKING([for NLS])
4219 if test -f po/Makefile; then
4220 have_gettext="no"
4221 if test -n "$MSGFMT"; then
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004222 olibs=$LIBS
4223 LIBS=""
Bram Moolenaar071d4272004-06-13 20:20:40 +00004224 AC_TRY_LINK(
4225 [#include <libintl.h>],
4226 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004227 AC_MSG_RESULT([gettext() works]); have_gettext="yes"; LIBS=$olibs,
4228 LIBS="-lintl"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004229 AC_TRY_LINK(
4230 [#include <libintl.h>],
4231 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004232 AC_MSG_RESULT([gettext() works with -lintl]); have_gettext="yes";
4233 LIBS="$olibs -lintl",
Bram Moolenaar071d4272004-06-13 20:20:40 +00004234 AC_MSG_RESULT([gettext() doesn't work]);
4235 LIBS=$olibs))
4236 else
4237 AC_MSG_RESULT([msgfmt not found - disabled]);
4238 fi
Bram Moolenaar278eb582014-07-30 13:22:52 +02004239 if test $have_gettext = "yes" -a "x$features" != "xtiny" -a "x$features" != "xsmall"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004240 AC_DEFINE(HAVE_GETTEXT)
4241 MAKEMO=yes
4242 AC_SUBST(MAKEMO)
4243 dnl this was added in GNU gettext 0.10.36
4244 AC_CHECK_FUNCS(bind_textdomain_codeset)
4245 dnl _nl_msg_cat_cntr is required for GNU gettext
4246 AC_MSG_CHECKING([for _nl_msg_cat_cntr])
4247 AC_TRY_LINK(
4248 [#include <libintl.h>
4249 extern int _nl_msg_cat_cntr;],
4250 [++_nl_msg_cat_cntr;],
4251 AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_NL_MSG_CAT_CNTR),
4252 AC_MSG_RESULT([no]))
4253 fi
4254 else
4255 AC_MSG_RESULT([no "po/Makefile" - disabled]);
4256 fi
4257else
4258 AC_MSG_RESULT(yes)
4259fi
4260
4261dnl Check for dynamic linking loader
4262AC_CHECK_HEADER(dlfcn.h, DLL=dlfcn.h, [AC_CHECK_HEADER(dl.h, DLL=dl.h)])
4263if test x${DLL} = xdlfcn.h; then
4264 AC_DEFINE(HAVE_DLFCN_H, 1, [ Define if we have dlfcn.h. ])
4265 AC_MSG_CHECKING([for dlopen()])
4266 AC_TRY_LINK(,[
4267 extern void* dlopen();
4268 dlopen();
4269 ],
4270 AC_MSG_RESULT(yes);
4271 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4272 AC_MSG_RESULT(no);
4273 AC_MSG_CHECKING([for dlopen() in -ldl])
4274 olibs=$LIBS
4275 LIBS="$LIBS -ldl"
4276 AC_TRY_LINK(,[
4277 extern void* dlopen();
4278 dlopen();
4279 ],
4280 AC_MSG_RESULT(yes);
4281 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4282 AC_MSG_RESULT(no);
4283 LIBS=$olibs))
4284 dnl ReliantUNIX has dlopen() in libc but everything else in libdl
4285 dnl ick :-)
4286 AC_MSG_CHECKING([for dlsym()])
4287 AC_TRY_LINK(,[
4288 extern void* dlsym();
4289 dlsym();
4290 ],
4291 AC_MSG_RESULT(yes);
4292 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4293 AC_MSG_RESULT(no);
4294 AC_MSG_CHECKING([for dlsym() in -ldl])
4295 olibs=$LIBS
4296 LIBS="$LIBS -ldl"
4297 AC_TRY_LINK(,[
4298 extern void* dlsym();
4299 dlsym();
4300 ],
4301 AC_MSG_RESULT(yes);
4302 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4303 AC_MSG_RESULT(no);
4304 LIBS=$olibs))
4305elif test x${DLL} = xdl.h; then
4306 AC_DEFINE(HAVE_DL_H, 1, [ Define if we have dl.h. ])
4307 AC_MSG_CHECKING([for shl_load()])
4308 AC_TRY_LINK(,[
4309 extern void* shl_load();
4310 shl_load();
4311 ],
4312 AC_MSG_RESULT(yes);
4313 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4314 AC_MSG_RESULT(no);
4315 AC_MSG_CHECKING([for shl_load() in -ldld])
4316 olibs=$LIBS
4317 LIBS="$LIBS -ldld"
4318 AC_TRY_LINK(,[
4319 extern void* shl_load();
4320 shl_load();
4321 ],
4322 AC_MSG_RESULT(yes);
4323 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4324 AC_MSG_RESULT(no);
4325 LIBS=$olibs))
4326fi
4327AC_CHECK_HEADERS(setjmp.h)
4328
Bram Moolenaard0573012017-10-28 21:11:06 +02004329if test "x$MACOS_X" = "xyes" -a -n "$PERL"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004330 dnl -ldl must come after DynaLoader.a
4331 if echo $LIBS | grep -e '-ldl' >/dev/null; then
4332 LIBS=`echo $LIBS | sed s/-ldl//`
4333 PERL_LIBS="$PERL_LIBS -ldl"
4334 fi
4335fi
4336
Bram Moolenaard0573012017-10-28 21:11:06 +02004337if test "$MACOS_X" = "yes"; then
4338 AC_MSG_CHECKING([whether we need macOS frameworks])
4339 if test "$GUITYPE" = "CARBONGUI"; then
4340 AC_MSG_RESULT([yes, we need Carbon])
4341 LIBS="$LIBS -framework Carbon"
4342 elif test "$MACOS_X_DARWIN" = "yes"; then
4343 if test "$features" = "tiny"; then
4344 dnl Since no FEAT_CLIPBOARD, no longer need for os_macosx.m.
4345 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_macosx.m++'`
4346 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_macosx.o++'`
4347 if test "$enable_multibyte" = "yes"; then
4348 AC_MSG_RESULT([yes, we need CoreServices])
4349 LIBS="$LIBS -framework CoreServices"
4350 else
4351 dnl Since no FEAT_MBYTE, no longer need for os_mac_conv.c.
4352 AC_MSG_RESULT([no])
4353 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_mac_conv.c++'`
4354 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_mac_conv.o++'`
4355 CPPFLAGS=`echo "$CPPFLAGS" | sed -e 's+-DMACOS_X_DARWIN++'`
4356 fi
4357 else
4358 AC_MSG_RESULT([yes, we need AppKit])
4359 LIBS="$LIBS -framework AppKit"
4360 if test "$features" = "small" -a "$enable_multibyte" = "no"; then
4361 dnl Since FEAT_CLIPBOARD is to be defined in vim.h for FEAT_SMALL, define
4362 dnl FEAT_MBYTE in order not to compromise the interoperability of the
4363 dnl clipboard.
4364 AC_MSG_NOTICE([+multi_byte will be set in favor of +clipboard])
4365 enable_multibyte=yes
4366 AC_DEFINE(FEAT_MBYTE)
4367 fi
4368 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004369 else
Bram Moolenaard0573012017-10-28 21:11:06 +02004370 AC_MSG_RESULT([no])
Bram Moolenaar3437b912013-07-03 19:52:53 +02004371 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004372fi
Bram Moolenaar164fca32010-07-14 13:58:07 +02004373if test "x$MACARCH" = "xboth" && test "x$GUITYPE" = "xCARBONGUI"; then
Bram Moolenaar595a7be2010-03-10 16:28:12 +01004374 LDFLAGS="$LDFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +00004375fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004376
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004377dnl gcc 3.1 changed the meaning of -MM. The only solution appears to be to
4378dnl use "-isystem" instead of "-I" for all non-Vim include dirs.
4379dnl But only when making dependencies, cproto and lint don't take "-isystem".
Bram Moolenaar32466aa2006-02-24 23:53:04 +00004380dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
4381dnl the number before the version number.
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004382DEPEND_CFLAGS_FILTER=
4383if test "$GCC" = yes; then
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004384 AC_MSG_CHECKING(for GCC 3 or later)
Bram Moolenaar2217cae2006-03-25 21:55:52 +00004385 gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]]\)\..*$/\1/g'`
Bram Moolenaarf740b292006-02-16 22:11:02 +00004386 if test "$gccmajor" -gt "2"; then
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004387 DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004388 AC_MSG_RESULT(yes)
4389 else
4390 AC_MSG_RESULT(no)
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004391 fi
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004392 dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
4393 dnl declared as char x[1] but actually longer. Introduced in gcc 4.0.
Bram Moolenaar56d1db32009-12-16 16:14:51 +00004394 dnl Also remove duplicate _FORTIFY_SOURCE arguments.
Bram Moolenaaraeabe052011-12-08 15:17:34 +01004395 dnl And undefine it first to avoid a warning.
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004396 AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
4397 if test "$gccmajor" -gt "3"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02004398 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 +00004399 AC_MSG_RESULT(yes)
4400 else
4401 AC_MSG_RESULT(no)
4402 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +00004403fi
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004404AC_SUBST(DEPEND_CFLAGS_FILTER)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004405
Bram Moolenaarec0557f2018-01-31 14:41:37 +01004406dnl On some systems AC_SYS_LARGEFILE determines that -D_FILE_OFFSET_BITS=64
4407dnl isn't required, but the CFLAGS for some of the libraries we're using
4408dnl include the define. Since the define changes the size of some datatypes
4409dnl (e.g. ino_t and off_t), all of Vim's modules must be compiled with a
4410dnl consistent value. It's therefore safest to force the use of the define
4411dnl if it's present in any of the *_CFLAGS variables.
4412AC_MSG_CHECKING(whether we need to force -D_FILE_OFFSET_BITS=64)
Bram Moolenaar9ce42132018-04-11 22:19:36 +02004413if echo "$CFLAGS $LUA_CFLAGS $MZSCHEME_CFLAGS $PERL_CFLAGS $PYTHON_CFLAGS $PYTHON3_CFLAGS $TCL_CFLAGS $RUBY_CFLAGS $GTK_CFLAGS" | grep -q D_FILE_OFFSET_BITS 2>/dev/null; then
Bram Moolenaarec0557f2018-01-31 14:41:37 +01004414 AC_MSG_RESULT(yes)
4415 AC_DEFINE(_FILE_OFFSET_BITS, 64)
4416else
4417 AC_MSG_RESULT(no)
4418fi
4419
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004420dnl link.sh tries to avoid overlinking in a hackish way.
4421dnl At least GNU ld supports --as-needed which provides the same functionality
4422dnl at linker level. Let's use it.
4423AC_MSG_CHECKING(linker --as-needed support)
4424LINK_AS_NEEDED=
4425# Check if linker supports --as-needed and --no-as-needed options
4426if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02004427 LDFLAGS=`echo "$LDFLAGS" | sed -e 's/ *-Wl,--as-needed//g' | sed -e 's/$/ -Wl,--as-needed/'`
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004428 LINK_AS_NEEDED=yes
4429fi
4430if test "$LINK_AS_NEEDED" = yes; then
4431 AC_MSG_RESULT(yes)
4432else
4433 AC_MSG_RESULT(no)
4434fi
4435AC_SUBST(LINK_AS_NEEDED)
4436
Bram Moolenaar77c19352012-06-13 19:19:41 +02004437# IBM z/OS reset CFLAGS for config.mk
4438if test "$zOSUnix" = "yes"; then
4439 CFLAGS="-D_ALL_SOURCE -Wc,float\(ieee\),dll"
4440fi
4441
Bram Moolenaar071d4272004-06-13 20:20:40 +00004442dnl write output files
4443AC_OUTPUT(auto/config.mk:config.mk.in)
4444
4445dnl vim: set sw=2 tw=78 fo+=l: