blob: 78023ad226b5cf146047183976a8967cbee0807b [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>], [
Bram Moolenaar561f8a52018-04-17 22:02:45 +020039 enum {
Bram Moolenaar285e3352018-04-18 23:01:13 +020040 one, // one comment
41 two, // two comments
42 three, // three comments
Bram Moolenaar561f8a52018-04-17 22:02:45 +020043 };
44 long long int a = 1;
45 long long unsigned b = 2;
46 printf("a %lld and a %llu", a, b);
47 ],
48AC_MSG_RESULT(yes),
49AC_MSG_ERROR([compiler does not work properly - see auto/config.log]))
50
Bram Moolenaarf788a062011-12-14 20:51:25 +010051dnl Check for the flag that fails if stuff are missing.
52
53AC_MSG_CHECKING(--enable-fail-if-missing argument)
54AC_ARG_ENABLE(fail_if_missing,
55 [ --enable-fail-if-missing Fail if dependencies on additional features
56 specified on the command line are missing.],
57 [fail_if_missing="yes"],
58 [fail_if_missing="no"])
59AC_MSG_RESULT($fail_if_missing)
60
Bram Moolenaar071d4272004-06-13 20:20:40 +000061dnl Set default value for CFLAGS if none is defined or it's empty
62if test -z "$CFLAGS"; then
63 CFLAGS="-O"
64 test "$GCC" = yes && CFLAGS="-O2 -fno-strength-reduce -Wall"
65fi
66if test "$GCC" = yes; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +000067 dnl method that should work for nearly all versions
Bram Moolenaarc8836f72014-04-12 13:12:24 +020068 gccversion=`$CC -dumpversion`
Bram Moolenaar910f66f2006-04-05 20:41:53 +000069 if test "x$gccversion" = "x"; then
70 dnl old method; fall-back for when -dumpversion doesn't work
Bram Moolenaarc8836f72014-04-12 13:12:24 +020071 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 +000072 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +000073 dnl version 4.0.1 was reported to cause trouble on Macintosh by Marcin Dalecki
74 if test "$gccversion" = "3.0.1" -o "$gccversion" = "3.0.2" -o "$gccversion" = "4.0.1"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +000075 echo 'GCC [[34]].0.[[12]] has a bug in the optimizer, disabling "-O#"'
Bram Moolenaar071d4272004-06-13 20:20:40 +000076 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-O/'`
77 else
78 if test "$gccversion" = "3.1" -o "$gccversion" = "3.2" -o "$gccversion" = "3.2.1" && `echo "$CFLAGS" | grep -v fno-strength-reduce >/dev/null`; then
79 echo 'GCC 3.1 and 3.2 have a bug in the optimizer, adding "-fno-strength-reduce"'
80 CFLAGS="$CFLAGS -fno-strength-reduce"
81 fi
82 fi
83fi
84
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +020085dnl clang-500.2.75 or around has abandoned -f[no-]strength-reduce and issues a
86dnl warning when that flag is passed to. Accordingly, adjust CFLAGS based on
87dnl the version number of the clang in use.
88dnl Note that this does not work to get the version of clang 3.1 or 3.2.
Bram Moolenaar5f69fee2017-03-09 11:58:40 +010089AC_MSG_CHECKING(for clang version)
90CLANG_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 +020091if test x"$CLANG_VERSION_STRING" != x"" ; then
92 CLANG_MAJOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*/\1/p'`
93 CLANG_MINOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/p'`
94 CLANG_REVISION=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)/\1/p'`
95 CLANG_VERSION=`expr $CLANG_MAJOR '*' 1000000 '+' $CLANG_MINOR '*' 1000 '+' $CLANG_REVISION`
96 AC_MSG_RESULT($CLANG_VERSION)
97 dnl If you find the same issue with versions earlier than 500.2.75,
98 dnl change the constant 500002075 below appropriately. To get the
99 dnl integer corresponding to a version number, refer to the
100 dnl definition of CLANG_VERSION above.
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100101 AC_MSG_CHECKING(if clang supports -fno-strength-reduce)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200102 if test "$CLANG_VERSION" -ge 500002075 ; then
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100103 AC_MSG_RESULT(no)
104 CFLAGS=`echo "$CFLAGS" | sed -e 's/-fno-strength-reduce/ /'`
105 else
106 AC_MSG_RESULT(yes)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200107 fi
108else
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100109 AC_MSG_RESULT(N/A)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200110fi
111
Bram Moolenaar446cb832008-06-24 21:56:24 +0000112dnl If configure thinks we are cross compiling, there might be something
113dnl wrong with the CC or CFLAGS settings, give a useful warning message
Bram Moolenaar839e9542016-04-14 16:46:02 +0200114CROSS_COMPILING=
Bram Moolenaar071d4272004-06-13 20:20:40 +0000115if test "$cross_compiling" = yes; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000116 AC_MSG_RESULT([cannot compile a simple program; if not cross compiling check CC and CFLAGS])
Bram Moolenaar839e9542016-04-14 16:46:02 +0200117 CROSS_COMPILING=1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000118fi
Bram Moolenaar839e9542016-04-14 16:46:02 +0200119AC_SUBST(CROSS_COMPILING)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000120
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +0000121dnl gcc-cpp has the wonderful -MM option to produce nicer dependencies.
122dnl But gcc 3.1 changed the meaning! See near the end.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000123test "$GCC" = yes && CPP_MM=M; AC_SUBST(CPP_MM)
124
125if test -f ./toolcheck; then
126 AC_CHECKING(for buggy tools)
127 sh ./toolcheck 1>&AC_FD_MSG
128fi
129
130OS_EXTRA_SRC=""; OS_EXTRA_OBJ=""
131
132dnl Check for BeOS, which needs an extra source file
133AC_MSG_CHECKING(for BeOS)
134case `uname` in
135 BeOS) OS_EXTRA_SRC=os_beos.c; OS_EXTRA_OBJ=objects/os_beos.o
136 BEOS=yes; AC_MSG_RESULT(yes);;
137 *) BEOS=no; AC_MSG_RESULT(no);;
138esac
139
140dnl If QNX is found, assume we don't want to use Xphoton
141dnl unless it was specifically asked for (--with-x)
142AC_MSG_CHECKING(for QNX)
143case `uname` in
144 QNX) OS_EXTRA_SRC=os_qnx.c; OS_EXTRA_OBJ=objects/os_qnx.o
145 test -z "$with_x" && with_x=no
146 QNX=yes; AC_MSG_RESULT(yes);;
147 *) QNX=no; AC_MSG_RESULT(no);;
148esac
149
150dnl Check for Darwin and MacOS X
151dnl We do a check for MacOS X in the very beginning because there
152dnl are a lot of other things we need to change besides GUI stuff
Bram Moolenaar071d4272004-06-13 20:20:40 +0000153AC_MSG_CHECKING([for Darwin (Mac OS X)])
154if test "`(uname) 2>/dev/null`" = Darwin; then
155 AC_MSG_RESULT(yes)
Bram Moolenaard0573012017-10-28 21:11:06 +0200156 MACOS_X=yes
Bram Moolenaar2e324952018-04-14 14:37:07 +0200157 CPPFLAGS="$CPPFLAGS -D_DARWIN_C_SOURCE -DMACOS_X"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000158
159 AC_MSG_CHECKING(--disable-darwin argument)
160 AC_ARG_ENABLE(darwin,
161 [ --disable-darwin Disable Darwin (Mac OS X) support.],
162 , [enable_darwin="yes"])
163 if test "$enable_darwin" = "yes"; then
164 AC_MSG_RESULT(no)
165 AC_MSG_CHECKING(if Darwin files are there)
Bram Moolenaar164fca32010-07-14 13:58:07 +0200166 if test -f os_macosx.m; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000167 AC_MSG_RESULT(yes)
168 else
169 AC_MSG_RESULT([no, Darwin support disabled])
170 enable_darwin=no
171 fi
172 else
173 AC_MSG_RESULT([yes, Darwin support excluded])
174 fi
175
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000176 AC_MSG_CHECKING(--with-mac-arch argument)
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000177 AC_ARG_WITH(mac-arch, [ --with-mac-arch=ARCH current, intel, ppc or both],
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000178 MACARCH="$withval"; AC_MSG_RESULT($MACARCH),
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000179 MACARCH="current"; AC_MSG_RESULT(defaulting to $MACARCH))
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000180
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100181 AC_MSG_CHECKING(--with-developer-dir argument)
182 AC_ARG_WITH(developer-dir, [ --with-developer-dir=PATH use PATH as location for Xcode developer tools],
183 DEVELOPER_DIR="$withval"; AC_MSG_RESULT($DEVELOPER_DIR),
Bram Moolenaar32d03b32015-11-19 13:46:48 +0100184 AC_MSG_RESULT(not present))
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100185
186 if test "x$DEVELOPER_DIR" = "x"; then
187 AC_PATH_PROG(XCODE_SELECT, xcode-select)
188 if test "x$XCODE_SELECT" != "x"; then
189 AC_MSG_CHECKING(for developer dir using xcode-select)
190 DEVELOPER_DIR=`$XCODE_SELECT -print-path`
191 AC_MSG_RESULT([$DEVELOPER_DIR])
192 else
193 DEVELOPER_DIR=/Developer
194 fi
195 fi
196
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000197 if test "x$MACARCH" = "xboth"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000198 AC_MSG_CHECKING(for 10.4 universal SDK)
199 dnl There is a terrible inconsistency (but we appear to get away with it):
200 dnl $CFLAGS uses the 10.4u SDK library for the headers, while $CPPFLAGS
201 dnl doesn't, because "gcc -E" doesn't grok it. That means the configure
202 dnl tests using the preprocessor are actually done with the wrong header
203 dnl files. $LDFLAGS is set at the end, because configure uses it together
204 dnl with $CFLAGS and we can only have one -sysroot argument.
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000205 save_cppflags="$CPPFLAGS"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000206 save_cflags="$CFLAGS"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000207 save_ldflags="$LDFLAGS"
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100208 CFLAGS="$CFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000209 AC_TRY_LINK([ ], [ ],
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000210 AC_MSG_RESULT(found, will make universal binary),
211
212 AC_MSG_RESULT(not found)
Bram Moolenaar1f35bf92006-03-07 22:38:47 +0000213 CFLAGS="$save_cflags"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000214 AC_MSG_CHECKING(if Intel architecture is supported)
215 CPPFLAGS="$CPPFLAGS -arch i386"
216 LDFLAGS="$save_ldflags -arch i386"
217 AC_TRY_LINK([ ], [ ],
218 AC_MSG_RESULT(yes); MACARCH="intel",
219 AC_MSG_RESULT(no, using PowerPC)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000220 MACARCH="ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000221 CPPFLAGS="$save_cppflags -arch ppc"
222 LDFLAGS="$save_ldflags -arch ppc"))
223 elif test "x$MACARCH" = "xintel"; then
224 CPPFLAGS="$CPPFLAGS -arch intel"
225 LDFLAGS="$LDFLAGS -arch intel"
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000226 elif test "x$MACARCH" = "xppc"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000227 CPPFLAGS="$CPPFLAGS -arch ppc"
228 LDFLAGS="$LDFLAGS -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000229 fi
230
Bram Moolenaar071d4272004-06-13 20:20:40 +0000231 if test "$enable_darwin" = "yes"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200232 MACOS_X_DARWIN=yes
Bram Moolenaar164fca32010-07-14 13:58:07 +0200233 OS_EXTRA_SRC="os_macosx.m os_mac_conv.c";
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000234 OS_EXTRA_OBJ="objects/os_macosx.o objects/os_mac_conv.o"
Bram Moolenaar32466aa2006-02-24 23:53:04 +0000235 dnl TODO: use -arch i386 on Intel machines
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100236 dnl Removed -no-cpp-precomp, only for very old compilers.
Bram Moolenaard0573012017-10-28 21:11:06 +0200237 CPPFLAGS="$CPPFLAGS -DMACOS_X_DARWIN"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000238
239 dnl If Carbon is found, assume we don't want X11
240 dnl unless it was specifically asked for (--with-x)
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000241 dnl or Motif, Athena or GTK GUI is used.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000242 AC_CHECK_HEADER(Carbon/Carbon.h, CARBON=yes)
243 if test "x$CARBON" = "xyes"; then
Bram Moolenaar98921892016-02-23 17:14:37 +0100244 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 +0000245 with_x=no
Bram Moolenaar071d4272004-06-13 20:20:40 +0000246 fi
247 fi
248 fi
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000249
Bram Moolenaardb552d602006-03-23 22:59:57 +0000250 dnl Avoid a bug with -O2 with gcc 4.0.1. Symptom: malloc() reports double
Bram Moolenaarfd2ac762006-03-01 22:09:21 +0000251 dnl free. This happens in expand_filename(), because the optimizer swaps
Bram Moolenaardb552d602006-03-23 22:59:57 +0000252 dnl two blocks of code, both using "repl", that can't be swapped.
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000253 if test "$MACARCH" = "intel" -o "$MACARCH" = "both"; then
254 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-Oz/'`
255 fi
256
Bram Moolenaar071d4272004-06-13 20:20:40 +0000257else
258 AC_MSG_RESULT(no)
259fi
260
Bram Moolenaar39766a72013-11-03 00:41:00 +0100261dnl Mac OS X 10.9+ no longer include AvailabilityMacros.h in Carbon
262dnl so we need to include it to have access to version macros.
Bram Moolenaar18e54692013-11-03 20:26:31 +0100263AC_CHECK_HEADERS(AvailabilityMacros.h)
Bram Moolenaar39766a72013-11-03 00:41:00 +0100264
Bram Moolenaar071d4272004-06-13 20:20:40 +0000265AC_SUBST(OS_EXTRA_SRC)
266AC_SUBST(OS_EXTRA_OBJ)
267
268dnl Add /usr/local/lib to $LDFLAGS and /usr/local/include to CFLAGS.
269dnl Only when the directory exists and it wasn't there yet.
270dnl For gcc don't do this when it is already in the default search path.
Bram Moolenaar446cb832008-06-24 21:56:24 +0000271dnl Skip all of this when cross-compiling.
272if test "$cross_compiling" = no; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000273 AC_MSG_CHECKING(--with-local-dir argument)
Bram Moolenaar446cb832008-06-24 21:56:24 +0000274 have_local_include=''
275 have_local_lib=''
Bram Moolenaarc236c162008-07-13 17:41:49 +0000276 AC_ARG_WITH([local-dir], [ --with-local-dir=PATH search PATH instead of /usr/local for local libraries.
277 --without-local-dir do not search /usr/local for local libraries.], [
278 local_dir="$withval"
279 case "$withval" in
280 */*) ;;
281 no)
282 # avoid adding local dir to LDFLAGS and CPPFLAGS
Bram Moolenaare06c1882010-07-21 22:05:20 +0200283 have_local_include=yes
Bram Moolenaarc236c162008-07-13 17:41:49 +0000284 have_local_lib=yes
285 ;;
286 *) AC_MSG_ERROR(must pass path argument to --with-local-dir) ;;
287 esac
288 AC_MSG_RESULT($local_dir)
289 ], [
290 local_dir=/usr/local
291 AC_MSG_RESULT(Defaulting to $local_dir)
292 ])
293 if test "$GCC" = yes -a "$local_dir" != no; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000294 echo 'void f(){}' > conftest.c
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100295 dnl Removed -no-cpp-precomp, only needed for OS X 10.2 (Ben Fowler)
296 have_local_include=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/include"`
Bram Moolenaarc236c162008-07-13 17:41:49 +0000297 have_local_lib=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/lib"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000298 rm -f conftest.c conftest.o
Bram Moolenaar071d4272004-06-13 20:20:40 +0000299 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000300 if test -z "$have_local_lib" -a -d "${local_dir}/lib"; then
301 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 +0000302 if test "$tt" = "$LDFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000303 LDFLAGS="$LDFLAGS -L${local_dir}/lib"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000304 fi
305 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000306 if test -z "$have_local_include" -a -d "${local_dir}/include"; then
307 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 +0000308 if test "$tt" = "$CPPFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000309 CPPFLAGS="$CPPFLAGS -I${local_dir}/include"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000310 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000311 fi
312fi
313
314AC_MSG_CHECKING(--with-vim-name argument)
315AC_ARG_WITH(vim-name, [ --with-vim-name=NAME what to call the Vim executable],
316 VIMNAME="$withval"; AC_MSG_RESULT($VIMNAME),
Bram Moolenaare344bea2005-09-01 20:46:49 +0000317 VIMNAME="vim"; AC_MSG_RESULT(Defaulting to $VIMNAME))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000318AC_SUBST(VIMNAME)
319AC_MSG_CHECKING(--with-ex-name argument)
320AC_ARG_WITH(ex-name, [ --with-ex-name=NAME what to call the Ex executable],
321 EXNAME="$withval"; AC_MSG_RESULT($EXNAME),
322 EXNAME="ex"; AC_MSG_RESULT(Defaulting to ex))
323AC_SUBST(EXNAME)
324AC_MSG_CHECKING(--with-view-name argument)
325AC_ARG_WITH(view-name, [ --with-view-name=NAME what to call the View executable],
326 VIEWNAME="$withval"; AC_MSG_RESULT($VIEWNAME),
327 VIEWNAME="view"; AC_MSG_RESULT(Defaulting to view))
328AC_SUBST(VIEWNAME)
329
330AC_MSG_CHECKING(--with-global-runtime argument)
331AC_ARG_WITH(global-runtime, [ --with-global-runtime=DIR global runtime directory in 'runtimepath'],
332 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL, "$withval"),
333 AC_MSG_RESULT(no))
334
335AC_MSG_CHECKING(--with-modified-by argument)
336AC_ARG_WITH(modified-by, [ --with-modified-by=NAME name of who modified a release version],
337 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(MODIFIED_BY, "$withval"),
338 AC_MSG_RESULT(no))
339
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200340dnl Check for EBCDIC stolen from the LYNX port to z/OS Unix
Bram Moolenaar071d4272004-06-13 20:20:40 +0000341AC_MSG_CHECKING(if character set is EBCDIC)
342AC_TRY_COMPILE([ ],
343[ /* TryCompile function for CharSet.
344 Treat any failure as ASCII for compatibility with existing art.
345 Use compile-time rather than run-time tests for cross-compiler
346 tolerance. */
347#if '0'!=240
348make an error "Character set is not EBCDIC"
349#endif ],
350[ # TryCompile action if true
351cf_cv_ebcdic=yes ],
352[ # TryCompile action if false
353cf_cv_ebcdic=no])
354# end of TryCompile ])
355# end of CacheVal CvEbcdic
356AC_MSG_RESULT($cf_cv_ebcdic)
357case "$cf_cv_ebcdic" in #(vi
358 yes) AC_DEFINE(EBCDIC)
359 line_break='"\\n"'
360 ;;
361 *) line_break='"\\012"';;
362esac
363AC_SUBST(line_break)
364
365if test "$cf_cv_ebcdic" = "yes"; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +0200366dnl If we have EBCDIC we most likely have z/OS Unix, let's test it!
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200367AC_MSG_CHECKING(for z/OS Unix)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000368case `uname` in
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200369 OS/390) zOSUnix="yes";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000370 dnl If using cc the environment variable _CC_CCMODE must be
371 dnl set to "1", so that some compiler extensions are enabled.
372 dnl If using c89 the environment variable is named _CC_C89MODE.
373 dnl Note: compile with c89 never tested.
374 if test "$CC" = "cc"; then
375 ccm="$_CC_CCMODE"
376 ccn="CC"
377 else
378 if test "$CC" = "c89"; then
379 ccm="$_CC_C89MODE"
380 ccn="C89"
381 else
382 ccm=1
383 fi
384 fi
385 if test "$ccm" != "1"; then
386 echo ""
387 echo "------------------------------------------"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200388 echo " On z/OS Unix, the environment variable"
Bram Moolenaar77c19352012-06-13 19:19:41 +0200389 echo " _CC_${ccn}MODE must be set to \"1\"!"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000390 echo " Do:"
391 echo " export _CC_${ccn}MODE=1"
392 echo " and then call configure again."
393 echo "------------------------------------------"
394 exit 1
395 fi
Bram Moolenaar77c19352012-06-13 19:19:41 +0200396 # Set CFLAGS for configure process.
397 # This will be reset later for config.mk.
398 # Use haltonmsg to force error for missing H files.
399 CFLAGS="$CFLAGS -D_ALL_SOURCE -Wc,float(ieee),haltonmsg(3296)";
400 LDFLAGS="$LDFLAGS -Wl,EDIT=NO"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000401 AC_MSG_RESULT(yes)
402 ;;
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200403 *) zOSUnix="no";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000404 AC_MSG_RESULT(no)
405 ;;
406esac
407fi
408
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200409dnl Set QUOTESED. Needs additional backslashes on zOS
410if test "$zOSUnix" = "yes"; then
411 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\\\\\&/g' -e 's/\\\\\\\\\"/\"/' -e 's/\\\\\\\\\";\$\$/\";/'"
412else
413 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\&/g' -e 's/\\\\\"/\"/' -e 's/\\\\\";\$\$/\";/'"
414fi
415AC_SUBST(QUOTESED)
416
417
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200418dnl Link with -lsmack for Smack stuff; if not found
419AC_MSG_CHECKING(--disable-smack argument)
420AC_ARG_ENABLE(smack,
421 [ --disable-smack Do not check for Smack support.],
422 , enable_smack="yes")
423if test "$enable_smack" = "yes"; then
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200424 AC_MSG_RESULT(no)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200425 AC_CHECK_HEADER([linux/xattr.h], true, enable_smack="no")
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200426else
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200427 AC_MSG_RESULT(yes)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200428fi
429if test "$enable_smack" = "yes"; then
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200430 AC_CHECK_HEADER([attr/xattr.h], true, enable_smack="no")
431fi
432if test "$enable_smack" = "yes"; then
433 AC_MSG_CHECKING(for XATTR_NAME_SMACKEXEC in linux/xattr.h)
434 AC_EGREP_CPP(XATTR_NAME_SMACKEXEC, [#include <linux/xattr.h>],
435 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +0200436 AC_MSG_RESULT(no); enable_smack="no")
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200437fi
438if test "$enable_smack" = "yes"; then
439 AC_CHECK_LIB(attr, setxattr,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200440 [LIBS="$LIBS -lattr"
441 found_smack="yes"
442 AC_DEFINE(HAVE_SMACK)])
Bram Moolenaar588ebeb2008-05-07 17:09:24 +0000443fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000444
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200445dnl When smack was found don't search for SELinux
446if test "x$found_smack" = "x"; then
447 dnl Link with -lselinux for SELinux stuff; if not found
448 AC_MSG_CHECKING(--disable-selinux argument)
449 AC_ARG_ENABLE(selinux,
450 [ --disable-selinux Do not check for SELinux support.],
451 , enable_selinux="yes")
452 if test "$enable_selinux" = "yes"; then
453 AC_MSG_RESULT(no)
454 AC_CHECK_LIB(selinux, is_selinux_enabled,
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100455 [AC_CHECK_HEADER(selinux/selinux.h,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200456 [LIBS="$LIBS -lselinux"
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100457 AC_DEFINE(HAVE_SELINUX)])])
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200458 else
459 AC_MSG_RESULT(yes)
460 fi
461fi
462
Bram Moolenaar071d4272004-06-13 20:20:40 +0000463dnl Check user requested features.
464
465AC_MSG_CHECKING(--with-features argument)
Bram Moolenaareec29812016-07-26 21:27:36 +0200466AC_ARG_WITH(features, [ --with-features=TYPE tiny, small, normal, big or huge (default: huge)],
Bram Moolenaar071d4272004-06-13 20:20:40 +0000467 features="$withval"; AC_MSG_RESULT($features),
Bram Moolenaar23c4f712016-01-20 22:11:59 +0100468 features="huge"; AC_MSG_RESULT(Defaulting to huge))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000469
470dovimdiff=""
471dogvimdiff=""
472case "$features" in
473 tiny) AC_DEFINE(FEAT_TINY) ;;
474 small) AC_DEFINE(FEAT_SMALL) ;;
475 normal) AC_DEFINE(FEAT_NORMAL) dovimdiff="installvimdiff";
476 dogvimdiff="installgvimdiff" ;;
477 big) AC_DEFINE(FEAT_BIG) dovimdiff="installvimdiff";
478 dogvimdiff="installgvimdiff" ;;
479 huge) AC_DEFINE(FEAT_HUGE) dovimdiff="installvimdiff";
480 dogvimdiff="installgvimdiff" ;;
481 *) AC_MSG_RESULT([Sorry, $features is not supported]) ;;
482esac
483
484AC_SUBST(dovimdiff)
485AC_SUBST(dogvimdiff)
486
487AC_MSG_CHECKING(--with-compiledby argument)
488AC_ARG_WITH(compiledby, [ --with-compiledby=NAME name to show in :version message],
489 compiledby="$withval"; AC_MSG_RESULT($withval),
490 compiledby=""; AC_MSG_RESULT(no))
491AC_SUBST(compiledby)
492
493AC_MSG_CHECKING(--disable-xsmp argument)
494AC_ARG_ENABLE(xsmp,
495 [ --disable-xsmp Disable XSMP session management],
496 , enable_xsmp="yes")
497
498if test "$enable_xsmp" = "yes"; then
499 AC_MSG_RESULT(no)
500 AC_MSG_CHECKING(--disable-xsmp-interact argument)
501 AC_ARG_ENABLE(xsmp-interact,
502 [ --disable-xsmp-interact Disable XSMP interaction],
503 , enable_xsmp_interact="yes")
504 if test "$enable_xsmp_interact" = "yes"; then
505 AC_MSG_RESULT(no)
506 AC_DEFINE(USE_XSMP_INTERACT)
507 else
508 AC_MSG_RESULT(yes)
509 fi
510else
511 AC_MSG_RESULT(yes)
512fi
513
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200514dnl Check for Lua feature.
515AC_MSG_CHECKING(--enable-luainterp argument)
516AC_ARG_ENABLE(luainterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200517 [ --enable-luainterp[=OPTS] Include Lua interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200518 [enable_luainterp="no"])
519AC_MSG_RESULT($enable_luainterp)
520
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200521if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +0100522 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
523 AC_MSG_ERROR([cannot use Lua with tiny or small features])
524 fi
525
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200526 dnl -- find the lua executable
527 AC_SUBST(vi_cv_path_lua)
528
529 AC_MSG_CHECKING(--with-lua-prefix argument)
530 AC_ARG_WITH(lua_prefix,
531 [ --with-lua-prefix=PFX Prefix where Lua is installed.],
532 with_lua_prefix="$withval"; AC_MSG_RESULT($with_lua_prefix),
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200533 with_lua_prefix="";AC_MSG_RESULT(no))
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200534
535 if test "X$with_lua_prefix" != "X"; then
536 vi_cv_path_lua_pfx="$with_lua_prefix"
537 else
538 AC_MSG_CHECKING(LUA_PREFIX environment var)
539 if test "X$LUA_PREFIX" != "X"; then
540 AC_MSG_RESULT("$LUA_PREFIX")
541 vi_cv_path_lua_pfx="$LUA_PREFIX"
542 else
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200543 AC_MSG_RESULT([not set, default to /usr])
544 vi_cv_path_lua_pfx="/usr"
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200545 fi
546 fi
547
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200548 AC_MSG_CHECKING(--with-luajit)
549 AC_ARG_WITH(luajit,
550 [ --with-luajit Link with LuaJIT instead of Lua.],
551 [vi_cv_with_luajit="$withval"],
552 [vi_cv_with_luajit="no"])
553 AC_MSG_RESULT($vi_cv_with_luajit)
554
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200555 LUA_INC=
556 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200557 if test "x$vi_cv_with_luajit" != "xno"; then
558 dnl -- try to find LuaJIT executable
559 AC_PATH_PROG(vi_cv_path_luajit, luajit)
560 if test "X$vi_cv_path_luajit" != "X"; then
561 dnl -- find LuaJIT version
562 AC_CACHE_CHECK(LuaJIT version, vi_cv_version_luajit,
Bram Moolenaar49b10272013-11-21 12:17:51 +0100563 [ 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 +0200564 AC_CACHE_CHECK(Lua version of LuaJIT, vi_cv_version_lua_luajit,
565 [ vi_cv_version_lua_luajit=`${vi_cv_path_luajit} -e "print(_VERSION)" | sed 's/.* //'` ])
566 vi_cv_path_lua="$vi_cv_path_luajit"
567 vi_cv_version_lua="$vi_cv_version_lua_luajit"
568 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200569 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200570 dnl -- try to find Lua executable
571 AC_PATH_PROG(vi_cv_path_plain_lua, lua)
572 if test "X$vi_cv_path_plain_lua" != "X"; then
573 dnl -- find Lua version
574 AC_CACHE_CHECK(Lua version, vi_cv_version_plain_lua,
575 [ vi_cv_version_plain_lua=`${vi_cv_path_plain_lua} -e "print(_VERSION)" | sed 's/.* //'` ])
576 fi
577 vi_cv_path_lua="$vi_cv_path_plain_lua"
578 vi_cv_version_lua="$vi_cv_version_plain_lua"
579 fi
580 if test "x$vi_cv_with_luajit" != "xno" && test "X$vi_cv_version_luajit" != "X"; then
581 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 +0100582 if test -f "$vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200583 AC_MSG_RESULT(yes)
584 LUA_INC=/luajit-$vi_cv_version_luajit
585 fi
586 fi
587 if test "X$LUA_INC" = "X"; then
588 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)
Bram Moolenaar49222be2015-12-11 18:11:30 +0100589 if test -f "$vi_cv_path_lua_pfx/include/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200590 AC_MSG_RESULT(yes)
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200591 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200592 AC_MSG_RESULT(no)
593 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 +0100594 if test -f "$vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200595 AC_MSG_RESULT(yes)
596 LUA_INC=/lua$vi_cv_version_lua
597 else
598 AC_MSG_RESULT(no)
599 vi_cv_path_lua_pfx=
600 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200601 fi
602 fi
603 fi
604
605 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200606 if test "x$vi_cv_with_luajit" != "xno"; then
607 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
608 if test "X$multiarch" != "X"; then
609 lib_multiarch="lib/${multiarch}"
610 else
611 lib_multiarch="lib"
612 fi
613 if test "X$vi_cv_version_lua" = "X"; then
614 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit"
615 else
616 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit-$vi_cv_version_lua"
617 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200618 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200619 if test "X$LUA_INC" != "X"; then
620 dnl Test alternate location using version
621 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua$vi_cv_version_lua"
622 else
623 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua"
624 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200625 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200626 if test "$enable_luainterp" = "dynamic"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200627 lua_ok="yes"
628 else
629 AC_MSG_CHECKING([if link with ${LUA_LIBS} is sane])
630 libs_save=$LIBS
631 LIBS="$LIBS $LUA_LIBS"
632 AC_TRY_LINK(,[ ],
633 AC_MSG_RESULT(yes); lua_ok="yes",
634 AC_MSG_RESULT(no); lua_ok="no"; LUA_LIBS="")
635 LIBS=$libs_save
636 fi
637 if test "x$lua_ok" = "xyes"; then
638 LUA_CFLAGS="-I${vi_cv_path_lua_pfx}/include${LUA_INC}"
639 LUA_SRC="if_lua.c"
640 LUA_OBJ="objects/if_lua.o"
641 LUA_PRO="if_lua.pro"
642 AC_DEFINE(FEAT_LUA)
643 fi
644 if test "$enable_luainterp" = "dynamic"; then
645 if test "x$vi_cv_with_luajit" != "xno"; then
646 luajit="jit"
647 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200648 if test -f "${vi_cv_path_lua_pfx}/bin/cyglua-${vi_cv_version_lua}.dll"; then
649 vi_cv_dll_name_lua="cyglua-${vi_cv_version_lua}.dll"
650 else
Bram Moolenaard0573012017-10-28 21:11:06 +0200651 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200652 ext="dylib"
653 indexes=""
654 else
655 ext="so"
656 indexes=".0 .1 .2 .3 .4 .5 .6 .7 .8 .9"
657 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
658 if test "X$multiarch" != "X"; then
659 lib_multiarch="lib/${multiarch}"
660 fi
Bram Moolenaar768baac2013-04-15 14:44:57 +0200661 fi
662 dnl Determine the sover for the current version, but fallback to
663 dnl liblua${vi_cv_version_lua}.so if no sover-versioned file is found.
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200664 AC_MSG_CHECKING(if liblua${luajit}*.${ext}* can be found in $vi_cv_path_lua_pfx)
Bram Moolenaar768baac2013-04-15 14:44:57 +0200665 for subdir in "${lib_multiarch}" lib64 lib; do
666 if test -z "$subdir"; then
667 continue
668 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200669 for sover in "${vi_cv_version_lua}.${ext}" "-${vi_cv_version_lua}.${ext}" \
670 ".${vi_cv_version_lua}.${ext}" ".${ext}.${vi_cv_version_lua}"; do
671 for i in $indexes ""; do
672 if test -f "${vi_cv_path_lua_pfx}/${subdir}/liblua${luajit}${sover}$i"; then
Bram Moolenaar768baac2013-04-15 14:44:57 +0200673 sover2="$i"
674 break 3
675 fi
676 done
Bram Moolenaar07e1da62013-02-06 19:49:43 +0100677 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200678 sover=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200679 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200680 if test "X$sover" = "X"; then
681 AC_MSG_RESULT(no)
682 lua_ok="no"
683 vi_cv_dll_name_lua="liblua${luajit}.${ext}"
684 else
685 AC_MSG_RESULT(yes)
686 lua_ok="yes"
687 vi_cv_dll_name_lua="liblua${luajit}${sover}$sover2"
688 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200689 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200690 AC_DEFINE(DYNAMIC_LUA)
691 LUA_LIBS=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200692 LUA_CFLAGS="-DDYNAMIC_LUA_DLL=\\\"${vi_cv_dll_name_lua}\\\" $LUA_CFLAGS"
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200693 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200694 if test "X$LUA_CFLAGS$LUA_LIBS" != "X" && \
Bram Moolenaard0573012017-10-28 21:11:06 +0200695 test "x$MACOS_X" = "xyes" && test "x$vi_cv_with_luajit" != "xno" && \
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200696 test "`(uname -m) 2>/dev/null`" = "x86_64"; then
697 dnl OSX/x64 requires these flags. See http://luajit.org/install.html
698 LUA_LIBS="-pagezero_size 10000 -image_base 100000000 $LUA_LIBS"
699 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200700 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200701 if test "$fail_if_missing" = "yes" -a "$lua_ok" != "yes"; then
Bram Moolenaarf788a062011-12-14 20:51:25 +0100702 AC_MSG_ERROR([could not configure lua])
703 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200704 AC_SUBST(LUA_SRC)
705 AC_SUBST(LUA_OBJ)
706 AC_SUBST(LUA_PRO)
707 AC_SUBST(LUA_LIBS)
708 AC_SUBST(LUA_CFLAGS)
709fi
710
711
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000712dnl Check for MzScheme feature.
713AC_MSG_CHECKING(--enable-mzschemeinterp argument)
714AC_ARG_ENABLE(mzschemeinterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200715 [ --enable-mzschemeinterp Include MzScheme interpreter.], ,
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000716 [enable_mzschemeinterp="no"])
717AC_MSG_RESULT($enable_mzschemeinterp)
718
719if test "$enable_mzschemeinterp" = "yes"; then
720 dnl -- find the mzscheme executable
721 AC_SUBST(vi_cv_path_mzscheme)
722
723 AC_MSG_CHECKING(--with-plthome argument)
724 AC_ARG_WITH(plthome,
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000725 [ --with-plthome=PLTHOME Use PLTHOME.],
726 with_plthome="$withval"; AC_MSG_RESULT($with_plthome),
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000727 with_plthome="";AC_MSG_RESULT("no"))
728
729 if test "X$with_plthome" != "X"; then
730 vi_cv_path_mzscheme_pfx="$with_plthome"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100731 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000732 else
733 AC_MSG_CHECKING(PLTHOME environment var)
734 if test "X$PLTHOME" != "X"; then
735 AC_MSG_RESULT("$PLTHOME")
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000736 vi_cv_path_mzscheme_pfx="$PLTHOME"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100737 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000738 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000739 AC_MSG_RESULT(not set)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000740 dnl -- try to find MzScheme executable
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000741 AC_PATH_PROG(vi_cv_path_mzscheme, mzscheme)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000742
743 dnl resolve symbolic link, the executable is often elsewhere and there
744 dnl are no links for the include files.
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000745 if test "X$vi_cv_path_mzscheme" != "X"; then
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000746 lsout=`ls -l $vi_cv_path_mzscheme`
747 if echo "$lsout" | grep -e '->' >/dev/null 2>/dev/null; then
748 vi_cv_path_mzscheme=`echo "$lsout" | sed 's/.*-> \(.*\)/\1/'`
749 fi
750 fi
751
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000752 if test "X$vi_cv_path_mzscheme" != "X"; then
753 dnl -- find where MzScheme thinks it was installed
754 AC_CACHE_CHECK(MzScheme install prefix,vi_cv_path_mzscheme_pfx,
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000755 dnl different versions of MzScheme differ in command line processing
756 dnl use universal approach
757 echo "(display (simplify-path \
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000758 (build-path (call-with-values \
759 (lambda () (split-path (find-system-path (quote exec-file)))) \
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000760 (lambda (base name must-be-dir?) base)) (quote up))))" > mzdirs.scm
761 dnl Remove a trailing slash
762 [ vi_cv_path_mzscheme_pfx=`${vi_cv_path_mzscheme} -r mzdirs.scm | \
763 sed -e 's+/$++'` ])
764 rm -f mzdirs.scm
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000765 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000766 fi
767 fi
768
769 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100770 AC_MSG_CHECKING(for racket include directory)
771 SCHEME_INC=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-include-dir))) (when (path? p) (display p)))'`
772 if test "X$SCHEME_INC" != "X"; then
773 AC_MSG_RESULT(${SCHEME_INC})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000774 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100775 AC_MSG_RESULT(not found)
776 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include)
777 if test -f "$vi_cv_path_mzscheme_pfx/include/scheme.h"; then
778 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000779 AC_MSG_RESULT(yes)
Bram Moolenaard7afed32007-05-06 13:26:41 +0000780 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000781 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100782 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt)
783 if test -f "$vi_cv_path_mzscheme_pfx/include/plt/scheme.h"; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000784 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100785 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000786 else
787 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100788 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket)
789 if test -f "$vi_cv_path_mzscheme_pfx/include/racket/scheme.h"; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100790 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100791 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100792 else
793 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100794 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/)
795 if test -f /usr/include/plt/scheme.h; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100796 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100797 SCHEME_INC=/usr/include/plt
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100798 else
799 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100800 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/racket/)
801 if test -f /usr/include/racket/scheme.h; then
802 AC_MSG_RESULT(yes)
803 SCHEME_INC=/usr/include/racket
804 else
805 AC_MSG_RESULT(no)
806 vi_cv_path_mzscheme_pfx=
807 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100808 fi
809 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000810 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000811 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000812 fi
813 fi
814
815 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100816
817 AC_MSG_CHECKING(for racket lib directory)
818 SCHEME_LIB=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-lib-dir))) (when (path? p) (display p)))'`
819 if test "X$SCHEME_LIB" != "X"; then
820 AC_MSG_RESULT(${SCHEME_LIB})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000821 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100822 AC_MSG_RESULT(not found)
823 fi
824
825 for path in "${vi_cv_path_mzscheme_pfx}/lib" "${SCHEME_LIB}"; do
826 if test "X$path" != "X"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200827 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100828 MZSCHEME_LIBS="-framework Racket"
829 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
830 elif test -f "${path}/libmzscheme3m.a"; then
831 MZSCHEME_LIBS="${path}/libmzscheme3m.a"
832 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
833 elif test -f "${path}/libracket3m.a"; then
834 MZSCHEME_LIBS="${path}/libracket3m.a"
835 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
836 elif test -f "${path}/libracket.a"; then
837 MZSCHEME_LIBS="${path}/libracket.a ${path}/libmzgc.a"
838 elif test -f "${path}/libmzscheme.a"; then
839 MZSCHEME_LIBS="${path}/libmzscheme.a ${path}/libmzgc.a"
840 else
841 dnl Using shared objects
842 if test -f "${path}/libmzscheme3m.so"; then
843 MZSCHEME_LIBS="-L${path} -lmzscheme3m"
844 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
845 elif test -f "${path}/libracket3m.so"; then
846 MZSCHEME_LIBS="-L${path} -lracket3m"
847 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
848 elif test -f "${path}/libracket.so"; then
849 MZSCHEME_LIBS="-L${path} -lracket -lmzgc"
850 else
851 dnl try next until last
852 if test "$path" != "$SCHEME_LIB"; then
853 continue
854 fi
855 MZSCHEME_LIBS="-L${path} -lmzscheme -lmzgc"
856 fi
857 if test "$GCC" = yes; then
858 dnl Make Vim remember the path to the library. For when it's not in
859 dnl $LD_LIBRARY_PATH.
860 MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${path}"
861 elif test "`(uname) 2>/dev/null`" = SunOS &&
862 uname -r | grep '^5' >/dev/null; then
863 MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${path}"
864 fi
865 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000866 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100867 if test "X$MZSCHEME_LIBS" != "X"; then
868 break
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +0000869 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100870 done
871
872 AC_MSG_CHECKING([if racket requires -pthread])
873 if test "X$SCHEME_LIB" != "X" && $FGREP -e -pthread "$SCHEME_LIB/buildinfo" >/dev/null ; then
874 AC_MSG_RESULT(yes)
875 MZSCHEME_LIBS="${MZSCHEME_LIBS} -pthread"
876 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -pthread"
877 else
878 AC_MSG_RESULT(no)
879 fi
880
881 AC_MSG_CHECKING(for racket config directory)
882 SCHEME_CONFIGDIR=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-config-dir))) (when (path? p) (display p)))'`
883 if test "X$SCHEME_CONFIGDIR" != "X"; then
884 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DMZSCHEME_CONFIGDIR='\"${SCHEME_CONFIGDIR}\"'"
885 AC_MSG_RESULT(${SCHEME_CONFIGDIR})
886 else
887 AC_MSG_RESULT(not found)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000888 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100889
890 AC_MSG_CHECKING(for racket collects directory)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100891 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))))'`
892 if test "X$SCHEME_COLLECTS" = "X"; then
893 if test -d "$vi_cv_path_mzscheme_pfx/lib/plt/collects"; then
894 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/plt/
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100895 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100896 if test -d "$vi_cv_path_mzscheme_pfx/lib/racket/collects"; then
897 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/racket/
Bram Moolenaar75676462013-01-30 14:55:42 +0100898 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100899 if test -d "$vi_cv_path_mzscheme_pfx/share/racket/collects"; then
900 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/
901 else
902 if test -d "$vi_cv_path_mzscheme_pfx/collects"; then
903 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/
904 fi
Bram Moolenaar75676462013-01-30 14:55:42 +0100905 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100906 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100907 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000908 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100909 if test "X$SCHEME_COLLECTS" != "X" ; then
910 AC_MSG_RESULT(${SCHEME_COLLECTS})
911 else
912 AC_MSG_RESULT(not found)
913 fi
914
915 AC_MSG_CHECKING(for mzscheme_base.c)
916 if test -f "${SCHEME_COLLECTS}collects/scheme/base.ss" ; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000917 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +0100918 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
919 MZSCHEME_MOD="++lib scheme/base"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100920 else
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100921 if test -f "${SCHEME_COLLECTS}collects/scheme/base.rkt" ; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100922 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +0100923 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
924 MZSCHEME_MOD="++lib scheme/base"
925 else
926 if test -f "${SCHEME_COLLECTS}collects/racket/base.rkt" ; then
927 MZSCHEME_EXTRA="mzscheme_base.c"
928 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/raco ctool"
929 MZSCHEME_MOD=""
930 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100931 fi
932 fi
933 if test "X$MZSCHEME_EXTRA" != "X" ; then
934 dnl need to generate bytecode for MzScheme base
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000935 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE"
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100936 AC_MSG_RESULT(needed)
937 else
938 AC_MSG_RESULT(not needed)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000939 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100940
Bram Moolenaar9e902192013-07-17 18:58:11 +0200941 dnl On Ubuntu this fixes "undefined reference to symbol 'ffi_type_void'".
942 AC_CHECK_LIB(ffi, ffi_type_void, [MZSCHEME_LIBS="$MZSCHEME_LIBS -lffi"])
943
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000944 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -I${SCHEME_INC} \
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100945 -DMZSCHEME_COLLECTS='\"${SCHEME_COLLECTS}collects\"'"
Bram Moolenaar9e902192013-07-17 18:58:11 +0200946
947 dnl Test that we can compile a simple program with these CFLAGS and LIBS.
948 AC_MSG_CHECKING([if compile and link flags for MzScheme are sane])
949 cflags_save=$CFLAGS
950 libs_save=$LIBS
951 CFLAGS="$CFLAGS $MZSCHEME_CFLAGS"
952 LIBS="$LIBS $MZSCHEME_LIBS"
953 AC_TRY_LINK(,[ ],
954 AC_MSG_RESULT(yes); mzs_ok=yes,
955 AC_MSG_RESULT(no: MZSCHEME DISABLED); mzs_ok=no)
956 CFLAGS=$cflags_save
957 LIBS=$libs_save
958 if test $mzs_ok = yes; then
959 MZSCHEME_SRC="if_mzsch.c"
960 MZSCHEME_OBJ="objects/if_mzsch.o"
961 MZSCHEME_PRO="if_mzsch.pro"
962 AC_DEFINE(FEAT_MZSCHEME)
963 else
964 MZSCHEME_CFLAGS=
965 MZSCHEME_LIBS=
966 MZSCHEME_EXTRA=
967 MZSCHEME_MZC=
968 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000969 fi
970 AC_SUBST(MZSCHEME_SRC)
971 AC_SUBST(MZSCHEME_OBJ)
972 AC_SUBST(MZSCHEME_PRO)
973 AC_SUBST(MZSCHEME_LIBS)
974 AC_SUBST(MZSCHEME_CFLAGS)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000975 AC_SUBST(MZSCHEME_EXTRA)
976 AC_SUBST(MZSCHEME_MZC)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000977fi
978
979
Bram Moolenaar071d4272004-06-13 20:20:40 +0000980AC_MSG_CHECKING(--enable-perlinterp argument)
981AC_ARG_ENABLE(perlinterp,
Bram Moolenaare06c1882010-07-21 22:05:20 +0200982 [ --enable-perlinterp[=OPTS] Include Perl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000983 [enable_perlinterp="no"])
984AC_MSG_RESULT($enable_perlinterp)
Bram Moolenaare06c1882010-07-21 22:05:20 +0200985if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +0100986 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
987 AC_MSG_ERROR([cannot use Perl with tiny or small features])
988 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000989 AC_SUBST(vi_cv_path_perl)
990 AC_PATH_PROG(vi_cv_path_perl, perl)
991 if test "X$vi_cv_path_perl" != "X"; then
992 AC_MSG_CHECKING(Perl version)
993 if $vi_cv_path_perl -e 'require 5.003_01' >/dev/null 2>/dev/null; then
994 eval `$vi_cv_path_perl -V:usethreads`
Bram Moolenaare06c1882010-07-21 22:05:20 +0200995 eval `$vi_cv_path_perl -V:libperl`
Bram Moolenaar071d4272004-06-13 20:20:40 +0000996 if test "X$usethreads" = "XUNKNOWN" -o "X$usethreads" = "Xundef"; then
997 badthreads=no
998 else
999 if $vi_cv_path_perl -e 'require 5.6.0' >/dev/null 2>/dev/null; then
1000 eval `$vi_cv_path_perl -V:use5005threads`
1001 if test "X$use5005threads" = "XUNKNOWN" -o "X$use5005threads" = "Xundef"; then
1002 badthreads=no
1003 else
1004 badthreads=yes
1005 AC_MSG_RESULT(>>> Perl > 5.6 with 5.5 threads cannot be used <<<)
1006 fi
1007 else
1008 badthreads=yes
1009 AC_MSG_RESULT(>>> Perl 5.5 with threads cannot be used <<<)
1010 fi
1011 fi
1012 if test $badthreads = no; then
1013 AC_MSG_RESULT(OK)
1014 eval `$vi_cv_path_perl -V:shrpenv`
1015 if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04
1016 shrpenv=""
1017 fi
1018 vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlibexp}'`
1019 AC_SUBST(vi_cv_perllib)
Bram Moolenaard5f62b12014-08-17 17:05:44 +02001020 vi_cv_perl_extutils=unknown_perl_extutils_path
1021 for extutils_rel_path in ExtUtils vendor_perl/ExtUtils; do
1022 xsubpp_path="$vi_cv_perllib/$extutils_rel_path/xsubpp"
1023 if test -f "$xsubpp_path"; then
1024 vi_cv_perl_xsubpp="$xsubpp_path"
1025 fi
1026 done
1027 AC_SUBST(vi_cv_perl_xsubpp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001028 dnl Remove "-fno-something", it breaks using cproto.
Bram Moolenaar280a8682015-06-21 13:41:08 +02001029 dnl Remove "-fdebug-prefix-map", it isn't supported by clang.
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001030 dnl Remove "FORTIFY_SOURCE", it will be defined twice.
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001031 dnl remove -pipe and -Wxxx, it confuses cproto
Bram Moolenaar071d4272004-06-13 20:20:40 +00001032 perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001033 -e 'ccflags;perl_inc;print"\n"' | sed -e 's/-fno[[^ ]]*//' \
1034 -e 's/-fdebug-prefix-map[[^ ]]*//g' \
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001035 -e 's/-pipe //' \
1036 -e 's/-W[[^ ]]*//g' \
1037 -e 's/-D_FORTIFY_SOURCE=.//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001038 dnl Remove "-lc", it breaks on FreeBSD when using "-pthread".
1039 perllibs=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed -e 'ldopts' | \
1040 sed -e '/Warning/d' -e '/Note (probably harmless)/d' \
1041 -e 's/-bE:perl.exp//' -e 's/-lc //'`
1042 dnl Don't add perl lib to $LIBS: if it's not in LD_LIBRARY_PATH
1043 dnl a test in configure may fail because of that.
1044 perlldflags=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed \
1045 -e 'ccdlflags' | sed -e 's/-bE:perl.exp//'`
1046
1047 dnl check that compiling a simple program still works with the flags
1048 dnl added for Perl.
1049 AC_MSG_CHECKING([if compile and link flags for Perl are sane])
1050 cflags_save=$CFLAGS
1051 libs_save=$LIBS
1052 ldflags_save=$LDFLAGS
1053 CFLAGS="$CFLAGS $perlcppflags"
1054 LIBS="$LIBS $perllibs"
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001055 perlldflags=`echo "$perlldflags" | sed -e 's/^ *//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001056 LDFLAGS="$perlldflags $LDFLAGS"
1057 AC_TRY_LINK(,[ ],
1058 AC_MSG_RESULT(yes); perl_ok=yes,
1059 AC_MSG_RESULT(no: PERL DISABLED); perl_ok=no)
1060 CFLAGS=$cflags_save
1061 LIBS=$libs_save
1062 LDFLAGS=$ldflags_save
1063 if test $perl_ok = yes; then
1064 if test "X$perlcppflags" != "X"; then
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001065 PERL_CFLAGS=$perlcppflags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001066 fi
1067 if test "X$perlldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001068 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$perlldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001069 LDFLAGS="$perlldflags $LDFLAGS"
1070 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001071 fi
1072 PERL_LIBS=$perllibs
1073 PERL_SRC="auto/if_perl.c if_perlsfio.c"
1074 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o"
1075 PERL_PRO="if_perl.pro if_perlsfio.pro"
1076 AC_DEFINE(FEAT_PERL)
1077 fi
1078 fi
1079 else
1080 AC_MSG_RESULT(>>> too old; need Perl version 5.003_01 or later <<<)
1081 fi
1082 fi
1083
Bram Moolenaard0573012017-10-28 21:11:06 +02001084 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00001085 dnl Mac OS X 10.2 or later
Bram Moolenaar071d4272004-06-13 20:20:40 +00001086 dir=/System/Library/Perl
1087 darwindir=$dir/darwin
1088 if test -d $darwindir; then
1089 PERL=/usr/bin/perl
1090 else
1091 dnl Mac OS X 10.3
1092 dir=/System/Library/Perl/5.8.1
1093 darwindir=$dir/darwin-thread-multi-2level
1094 if test -d $darwindir; then
1095 PERL=/usr/bin/perl
1096 fi
1097 fi
1098 if test -n "$PERL"; then
1099 PERL_DIR="$dir"
1100 PERL_CFLAGS="-DFEAT_PERL -I$darwindir/CORE"
1101 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o $darwindir/auto/DynaLoader/DynaLoader.a"
1102 PERL_LIBS="-L$darwindir/CORE -lperl"
1103 fi
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001104 dnl Perl on Mac OS X 10.5 adds "-arch" flags but these should only
1105 dnl be included if requested by passing --with-mac-arch to
1106 dnl configure, so strip these flags first (if present)
1107 PERL_LIBS=`echo "$PERL_LIBS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
1108 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 +00001109 fi
Bram Moolenaare06c1882010-07-21 22:05:20 +02001110 if test "$enable_perlinterp" = "dynamic"; then
1111 if test "$perl_ok" = "yes" -a "X$libperl" != "X"; then
1112 AC_DEFINE(DYNAMIC_PERL)
1113 PERL_CFLAGS="-DDYNAMIC_PERL_DLL=\\\"$libperl\\\" $PERL_CFLAGS"
1114 fi
1115 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001116
1117 if test "$fail_if_missing" = "yes" -a "$perl_ok" != "yes"; then
1118 AC_MSG_ERROR([could not configure perl])
1119 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001120fi
1121AC_SUBST(shrpenv)
1122AC_SUBST(PERL_SRC)
1123AC_SUBST(PERL_OBJ)
1124AC_SUBST(PERL_PRO)
1125AC_SUBST(PERL_CFLAGS)
1126AC_SUBST(PERL_LIBS)
1127
1128AC_MSG_CHECKING(--enable-pythoninterp argument)
1129AC_ARG_ENABLE(pythoninterp,
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001130 [ --enable-pythoninterp[=OPTS] Include Python interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001131 [enable_pythoninterp="no"])
1132AC_MSG_RESULT($enable_pythoninterp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001133if test "$enable_pythoninterp" = "yes" -o "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001134 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1135 AC_MSG_ERROR([cannot use Python with tiny or small features])
1136 fi
1137
Bram Moolenaar071d4272004-06-13 20:20:40 +00001138 dnl -- find the python executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001139 AC_MSG_CHECKING(--with-python-command argument)
1140 AC_SUBST(vi_cv_path_python)
1141 AC_ARG_WITH(python-command, [ --with-python-command=NAME name of the Python 2 command (default: python2 or python)],
1142 vi_cv_path_python="$withval"; AC_MSG_RESULT($vi_cv_path_python),
1143 AC_MSG_RESULT(no))
1144
1145 if test "X$vi_cv_path_python" = "X"; then
1146 AC_PATH_PROGS(vi_cv_path_python, python2 python)
1147 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001148 if test "X$vi_cv_path_python" != "X"; then
1149
1150 dnl -- get its version number
1151 AC_CACHE_CHECK(Python version,vi_cv_var_python_version,
1152 [[vi_cv_var_python_version=`
1153 ${vi_cv_path_python} -c 'import sys; print sys.version[:3]'`
1154 ]])
1155
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001156 dnl -- it must be at least version 2.3
1157 AC_MSG_CHECKING(Python is 2.3 or better)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001158 if ${vi_cv_path_python} -c \
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001159 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001160 then
1161 AC_MSG_RESULT(yep)
1162
1163 dnl -- find where python thinks it was installed
1164 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python_pfx,
1165 [ vi_cv_path_python_pfx=`
1166 ${vi_cv_path_python} -c \
1167 "import sys; print sys.prefix"` ])
1168
1169 dnl -- and where it thinks it runs
1170 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python_epfx,
1171 [ vi_cv_path_python_epfx=`
1172 ${vi_cv_path_python} -c \
1173 "import sys; print sys.exec_prefix"` ])
1174
1175 dnl -- python's internal library path
1176
1177 AC_CACHE_VAL(vi_cv_path_pythonpath,
1178 [ vi_cv_path_pythonpath=`
1179 unset PYTHONPATH;
1180 ${vi_cv_path_python} -c \
1181 "import sys, string; print string.join(sys.path,':')"` ])
1182
1183 dnl -- where the Python implementation library archives are
1184
1185 AC_ARG_WITH(python-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001186 [ --with-python-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001187 [ vi_cv_path_python_conf="${withval}"; have_python_config_dir=1 ] )
Bram Moolenaar071d4272004-06-13 20:20:40 +00001188
1189 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python_conf,
1190 [
1191 vi_cv_path_python_conf=
Bram Moolenaarac499e32013-06-02 19:14:17 +02001192 d=`${vi_cv_path_python} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBPL')"`
1193 if test -d "$d" && test -f "$d/config.c"; then
1194 vi_cv_path_python_conf="$d"
1195 else
1196 for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
1197 for subdir in lib64 lib share; do
1198 d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
1199 if test -d "$d" && test -f "$d/config.c"; then
1200 vi_cv_path_python_conf="$d"
1201 fi
1202 done
Bram Moolenaar071d4272004-06-13 20:20:40 +00001203 done
Bram Moolenaarac499e32013-06-02 19:14:17 +02001204 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001205 ])
1206
1207 PYTHON_CONFDIR="${vi_cv_path_python_conf}"
1208
1209 if test "X$PYTHON_CONFDIR" = "X"; then
1210 AC_MSG_RESULT([can't find it!])
1211 else
1212
1213 dnl -- we need to examine Python's config/Makefile too
1214 dnl see what the interpreter is built from
1215 AC_CACHE_VAL(vi_cv_path_python_plibs,
1216 [
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001217 pwd=`pwd`
1218 tmp_mkf="$pwd/config-PyMake$$"
1219 cat -- "${PYTHON_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001220__:
Bram Moolenaar218116c2010-05-20 21:46:00 +02001221 @echo "python_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001222 @echo "python_LIBS='$(LIBS)'"
1223 @echo "python_SYSLIBS='$(SYSLIBS)'"
1224 @echo "python_LINKFORSHARED='$(LINKFORSHARED)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001225 @echo "python_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001226 @echo "python_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001227 @echo "python_PYTHONFRAMEWORK='$(PYTHONFRAMEWORK)'"
1228 @echo "python_PYTHONFRAMEWORKPREFIX='$(PYTHONFRAMEWORKPREFIX)'"
1229 @echo "python_PYTHONFRAMEWORKINSTALLDIR='$(PYTHONFRAMEWORKINSTALLDIR)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001230eof
1231 dnl -- delete the lines from make about Entering/Leaving directory
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001232 eval "`cd ${PYTHON_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1233 rm -f -- "${tmp_mkf}"
Bram Moolenaard0573012017-10-28 21:11:06 +02001234 if test "x$MACOS_X" = "xyes" && test -n "${python_PYTHONFRAMEWORK}" && ${vi_cv_path_python} -c \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001235 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then
1236 vi_cv_path_python_plibs="-framework Python"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001237 if test "x${vi_cv_path_python}" != "x/usr/bin/python" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
1238 vi_cv_path_python_plibs="-F${python_PYTHONFRAMEWORKPREFIX} -framework Python"
1239 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001240 else
Bram Moolenaar9ce42132018-04-11 22:19:36 +02001241 vi_cv_path_python_plibs="-L${PYTHON_CONFDIR} -lpython${vi_cv_var_python_version}"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001242 dnl -- Check if the path contained in python_LINKFORSHARED is
1243 dnl usable for vim build. If not, make and try other
1244 dnl candidates.
Bram Moolenaara161e262015-03-24 15:14:27 +01001245 if test -n "${python_LINKFORSHARED}" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
Bram Moolenaar6c927552015-03-24 12:21:33 +01001246 python_link_symbol=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]].*/\1/'`
1247 python_link_path=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]][[ \t]]*\(.*\)/\2/'`
1248 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1249 dnl -- The path looks relative. Guess the absolute one using
1250 dnl the prefix and try that.
1251 python_link_path="${python_PYTHONFRAMEWORKPREFIX}/${python_link_path}"
1252 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1253 dnl -- A last resort.
1254 python_link_path="${python_PYTHONFRAMEWORKINSTALLDIR}/Versions/${vi_cv_var_python_version}/${python_PYTHONFRAMEWORK}"
1255 dnl -- No check is done. The last word is left to the
1256 dnl "sanity" test on link flags that follows shortly.
1257 fi
1258 python_LINKFORSHARED="${python_link_symbol} ${python_link_path}"
1259 fi
1260 fi
Bram Moolenaar218116c2010-05-20 21:46:00 +02001261 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 +00001262 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1263 vi_cv_path_python_plibs=`echo $vi_cv_path_python_plibs | sed s/-ltermcap//`
1264 fi
1265 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001266 AC_CACHE_CHECK(Python's dll name,vi_cv_dll_name_python,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001267 [
1268 if test "X$python_DLLLIBRARY" != "X"; then
1269 vi_cv_dll_name_python="$python_DLLLIBRARY"
1270 else
1271 vi_cv_dll_name_python="$python_INSTSONAME"
1272 fi
1273 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00001274
1275 PYTHON_LIBS="${vi_cv_path_python_plibs}"
1276 if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001277 PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001278 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001279 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 +00001280 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001281 if test "X$have_python_config_dir" = "X1" -a "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001282 dnl Define PYTHON_HOME if --with-python-config-dir was used
1283 PYTHON_CFLAGS="${PYTHON_CFLAGS} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'"
1284
1285 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001286 PYTHON_SRC="if_python.c"
Bram Moolenaar9bdb9a02012-07-25 16:32:08 +02001287 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001288
1289 dnl On FreeBSD linking with "-pthread" is required to use threads.
1290 dnl _THREAD_SAFE must be used for compiling then.
1291 dnl The "-pthread" is added to $LIBS, so that the following check for
1292 dnl sigaltstack() will look in libc_r (it's there in libc!).
1293 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1294 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1295 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1296 AC_MSG_CHECKING([if -pthread should be used])
1297 threadsafe_flag=
1298 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001299 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00001300 if test "`(uname) 2>/dev/null`" != Darwin; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001301 test "$GCC" = yes && threadsafe_flag="-pthread"
1302 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1303 threadsafe_flag="-D_THREAD_SAFE"
1304 thread_lib="-pthread"
1305 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001306 if test "`(uname) 2>/dev/null`" = SunOS; then
1307 threadsafe_flag="-pthreads"
1308 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001309 fi
1310 libs_save_old=$LIBS
1311 if test -n "$threadsafe_flag"; then
1312 cflags_save=$CFLAGS
1313 CFLAGS="$CFLAGS $threadsafe_flag"
1314 LIBS="$LIBS $thread_lib"
1315 AC_TRY_LINK(,[ ],
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001316 AC_MSG_RESULT(yes); PYTHON_CFLAGS="$PYTHON_CFLAGS $threadsafe_flag",
Bram Moolenaar071d4272004-06-13 20:20:40 +00001317 AC_MSG_RESULT(no); LIBS=$libs_save_old
1318 )
1319 CFLAGS=$cflags_save
1320 else
1321 AC_MSG_RESULT(no)
1322 fi
1323
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001324 dnl Check that compiling a simple program still works with the flags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001325 dnl added for Python.
1326 AC_MSG_CHECKING([if compile and link flags for Python are sane])
1327 cflags_save=$CFLAGS
1328 libs_save=$LIBS
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001329 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001330 LIBS="$LIBS $PYTHON_LIBS"
1331 AC_TRY_LINK(,[ ],
1332 AC_MSG_RESULT(yes); python_ok=yes,
1333 AC_MSG_RESULT(no: PYTHON DISABLED); python_ok=no)
1334 CFLAGS=$cflags_save
1335 LIBS=$libs_save
1336 if test $python_ok = yes; then
1337 AC_DEFINE(FEAT_PYTHON)
1338 else
1339 LIBS=$libs_save_old
1340 PYTHON_SRC=
1341 PYTHON_OBJ=
1342 PYTHON_LIBS=
1343 PYTHON_CFLAGS=
1344 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001345 fi
1346 else
1347 AC_MSG_RESULT(too old)
1348 fi
1349 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001350
1351 if test "$fail_if_missing" = "yes" -a "$python_ok" != "yes"; then
1352 AC_MSG_ERROR([could not configure python])
1353 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001354fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001355
Bram Moolenaar071d4272004-06-13 20:20:40 +00001356AC_SUBST(PYTHON_LIBS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001357AC_SUBST(PYTHON_CFLAGS)
1358AC_SUBST(PYTHON_SRC)
1359AC_SUBST(PYTHON_OBJ)
1360
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001361
1362AC_MSG_CHECKING(--enable-python3interp argument)
1363AC_ARG_ENABLE(python3interp,
Bram Moolenaar8008b632017-07-18 21:33:20 +02001364 [ --enable-python3interp[=OPTS] Include Python3 interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001365 [enable_python3interp="no"])
1366AC_MSG_RESULT($enable_python3interp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001367if test "$enable_python3interp" = "yes" -o "$enable_python3interp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001368 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1369 AC_MSG_ERROR([cannot use Python with tiny or small features])
1370 fi
1371
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001372 dnl -- find the python3 executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001373 AC_MSG_CHECKING(--with-python3-command argument)
1374 AC_SUBST(vi_cv_path_python3)
1375 AC_ARG_WITH(python3-command, [ --with-python3-command=NAME name of the Python 3 command (default: python3 or python)],
1376 vi_cv_path_python3="$withval"; AC_MSG_RESULT($vi_cv_path_python3),
1377 AC_MSG_RESULT(no))
1378
1379 if test "X$vi_cv_path_python3" = "X"; then
1380 AC_PATH_PROGS(vi_cv_path_python3, python3 python)
1381 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001382 if test "X$vi_cv_path_python3" != "X"; then
1383
1384 dnl -- get its version number
1385 AC_CACHE_CHECK(Python version,vi_cv_var_python3_version,
1386 [[vi_cv_var_python3_version=`
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001387 ${vi_cv_path_python3} -c 'import sys; print(sys.version[:3])'`
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001388 ]])
1389
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001390 dnl -- it must be at least version 3
1391 AC_MSG_CHECKING(Python is 3.0 or better)
1392 if ${vi_cv_path_python3} -c \
1393 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.0)"
1394 then
1395 AC_MSG_RESULT(yep)
Bram Moolenaar456f2bb2011-06-12 21:37:13 +02001396
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001397 dnl -- get abiflags for python 3.2 or higher (PEP 3149)
1398 AC_CACHE_CHECK(Python's abiflags,vi_cv_var_python3_abiflags,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001399 [
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001400 vi_cv_var_python3_abiflags=
1401 if ${vi_cv_path_python3} -c \
1402 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)"
1403 then
1404 vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \
1405 "import sys; print(sys.abiflags)"`
1406 fi ])
1407
1408 dnl -- find where python3 thinks it was installed
1409 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx,
1410 [ vi_cv_path_python3_pfx=`
1411 ${vi_cv_path_python3} -c \
1412 "import sys; print(sys.prefix)"` ])
1413
1414 dnl -- and where it thinks it runs
1415 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx,
1416 [ vi_cv_path_python3_epfx=`
1417 ${vi_cv_path_python3} -c \
1418 "import sys; print(sys.exec_prefix)"` ])
1419
1420 dnl -- python3's internal library path
1421
1422 AC_CACHE_VAL(vi_cv_path_python3path,
1423 [ vi_cv_path_python3path=`
1424 unset PYTHONPATH;
1425 ${vi_cv_path_python3} -c \
1426 "import sys, string; print(':'.join(sys.path))"` ])
1427
1428 dnl -- where the Python implementation library archives are
1429
1430 AC_ARG_WITH(python3-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001431 [ --with-python3-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001432 [ vi_cv_path_python3_conf="${withval}"; have_python3_config_dir=1 ] )
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001433
1434 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf,
1435 [
1436 vi_cv_path_python3_conf=
Bram Moolenaarfee496d2013-07-12 20:07:24 +02001437 config_dir="config-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001438 d=`${vi_cv_path_python3} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBPL'))"`
1439 if test -d "$d" && test -f "$d/config.c"; then
1440 vi_cv_path_python3_conf="$d"
1441 else
1442 for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do
1443 for subdir in lib64 lib share; do
1444 d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}"
1445 if test -d "$d" && test -f "$d/config.c"; then
1446 vi_cv_path_python3_conf="$d"
1447 fi
1448 done
1449 done
1450 fi
1451 ])
1452
1453 PYTHON3_CONFDIR="${vi_cv_path_python3_conf}"
1454
1455 if test "X$PYTHON3_CONFDIR" = "X"; then
1456 AC_MSG_RESULT([can't find it!])
1457 else
1458
1459 dnl -- we need to examine Python's config/Makefile too
1460 dnl see what the interpreter is built from
1461 AC_CACHE_VAL(vi_cv_path_python3_plibs,
1462 [
1463 pwd=`pwd`
1464 tmp_mkf="$pwd/config-PyMake$$"
1465 cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001466__:
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001467 @echo "python3_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001468 @echo "python3_LIBS='$(LIBS)'"
1469 @echo "python3_SYSLIBS='$(SYSLIBS)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001470 @echo "python3_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001471 @echo "python3_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001472eof
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001473 dnl -- delete the lines from make about Entering/Leaving directory
1474 eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1475 rm -f -- "${tmp_mkf}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001476 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 +02001477 vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}"
1478 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1479 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//`
1480 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//`
1481 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001482 AC_CACHE_CHECK(Python3's dll name,vi_cv_dll_name_python3,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001483 [
1484 if test "X$python3_DLLLIBRARY" != "X"; then
1485 vi_cv_dll_name_python3="$python3_DLLLIBRARY"
1486 else
1487 vi_cv_dll_name_python3="$python3_INSTSONAME"
1488 fi
1489 ])
1490
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001491 PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
1492 if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001493 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 +02001494 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001495 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 +02001496 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001497 if test "X$have_python3_config_dir" = "X1" -a "$enable_python3interp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001498 dnl Define PYTHON3_HOME if --with-python-config-dir was used
1499 PYTHON3_CFLAGS="${PYTHON3_CFLAGS} -DPYTHON3_HOME='L\"${vi_cv_path_python3_pfx}\"'"
1500 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001501 PYTHON3_SRC="if_python3.c"
1502 PYTHON3_OBJ="objects/if_python3.o"
1503
1504 dnl On FreeBSD linking with "-pthread" is required to use threads.
1505 dnl _THREAD_SAFE must be used for compiling then.
1506 dnl The "-pthread" is added to $LIBS, so that the following check for
1507 dnl sigaltstack() will look in libc_r (it's there in libc!).
1508 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1509 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1510 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1511 AC_MSG_CHECKING([if -pthread should be used])
1512 threadsafe_flag=
1513 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001514 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001515 if test "`(uname) 2>/dev/null`" != Darwin; then
1516 test "$GCC" = yes && threadsafe_flag="-pthread"
1517 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1518 threadsafe_flag="-D_THREAD_SAFE"
1519 thread_lib="-pthread"
1520 fi
1521 if test "`(uname) 2>/dev/null`" = SunOS; then
1522 threadsafe_flag="-pthreads"
1523 fi
1524 fi
1525 libs_save_old=$LIBS
1526 if test -n "$threadsafe_flag"; then
1527 cflags_save=$CFLAGS
1528 CFLAGS="$CFLAGS $threadsafe_flag"
1529 LIBS="$LIBS $thread_lib"
1530 AC_TRY_LINK(,[ ],
1531 AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag",
1532 AC_MSG_RESULT(no); LIBS=$libs_save_old
1533 )
1534 CFLAGS=$cflags_save
1535 else
1536 AC_MSG_RESULT(no)
1537 fi
1538
1539 dnl check that compiling a simple program still works with the flags
1540 dnl added for Python.
1541 AC_MSG_CHECKING([if compile and link flags for Python 3 are sane])
1542 cflags_save=$CFLAGS
1543 libs_save=$LIBS
1544 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1545 LIBS="$LIBS $PYTHON3_LIBS"
1546 AC_TRY_LINK(,[ ],
1547 AC_MSG_RESULT(yes); python3_ok=yes,
1548 AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no)
1549 CFLAGS=$cflags_save
1550 LIBS=$libs_save
1551 if test "$python3_ok" = yes; then
1552 AC_DEFINE(FEAT_PYTHON3)
1553 else
1554 LIBS=$libs_save_old
1555 PYTHON3_SRC=
1556 PYTHON3_OBJ=
1557 PYTHON3_LIBS=
1558 PYTHON3_CFLAGS=
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001559 fi
1560 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001561 else
1562 AC_MSG_RESULT(too old)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001563 fi
1564 fi
Bram Moolenaar1612b1a2013-06-14 21:22:39 +02001565 if test "$fail_if_missing" = "yes" -a "$python3_ok" != "yes"; then
1566 AC_MSG_ERROR([could not configure python3])
1567 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001568fi
1569
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001570AC_SUBST(PYTHON3_LIBS)
1571AC_SUBST(PYTHON3_CFLAGS)
1572AC_SUBST(PYTHON3_SRC)
1573AC_SUBST(PYTHON3_OBJ)
1574
1575dnl if python2.x and python3.x are enabled one can only link in code
1576dnl with dlopen(), dlsym(), dlclose()
1577if test "$python_ok" = yes && test "$python3_ok" = yes; then
1578 AC_DEFINE(DYNAMIC_PYTHON)
1579 AC_DEFINE(DYNAMIC_PYTHON3)
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001580 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001581 cflags_save=$CFLAGS
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001582 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001583 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001584 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001585 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001586 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001587 #include <dlfcn.h>
1588 /* If this program fails, then RTLD_GLOBAL is needed.
1589 * RTLD_GLOBAL will be used and then it is not possible to
1590 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001591 * Only the first python version used will be switched on.
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001592 */
1593
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001594 int no_rtl_global_needed_for(char *python_instsoname, char *prefix)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001595 {
1596 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001597 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001598 if (pylib != 0)
1599 {
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001600 void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome");
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001601 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1602 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1603 void (*final)(void) = dlsym(pylib, "Py_Finalize");
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001604 (*pfx)(prefix);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001605 (*init)();
1606 needed = (*simple)("import termios") == -1;
1607 (*final)();
1608 dlclose(pylib);
1609 }
1610 return !needed;
1611 }
1612
1613 int main(int argc, char** argv)
1614 {
1615 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001616 if (no_rtl_global_needed_for("${vi_cv_dll_name_python}", "${vi_cv_path_python_pfx}"))
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001617 not_needed = 1;
1618 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001619 }])],
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001620 [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001621
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001622 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001623 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001624
1625 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python3)
1626 cflags_save=$CFLAGS
1627 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001628 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001629 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001630 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001631 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001632 #include <dlfcn.h>
1633 #include <wchar.h>
1634 /* If this program fails, then RTLD_GLOBAL is needed.
1635 * RTLD_GLOBAL will be used and then it is not possible to
1636 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001637 * Only the first python version used will be switched on.
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001638 */
1639
1640 int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix)
1641 {
1642 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001643 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001644 if (pylib != 0)
1645 {
1646 void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome");
1647 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1648 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1649 void (*final)(void) = dlsym(pylib, "Py_Finalize");
1650 (*pfx)(prefix);
1651 (*init)();
1652 needed = (*simple)("import termios") == -1;
1653 (*final)();
1654 dlclose(pylib);
1655 }
1656 return !needed;
1657 }
1658
1659 int main(int argc, char** argv)
1660 {
1661 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001662 if (no_rtl_global_needed_for("${vi_cv_dll_name_python3}", L"${vi_cv_path_python3_pfx}"))
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001663 not_needed = 1;
1664 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001665 }])],
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001666 [AC_MSG_RESULT(yes);AC_DEFINE(PY3_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
1667
1668 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001669 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001670
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001671 PYTHON_SRC="if_python.c"
1672 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001673 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001674 PYTHON_LIBS=
1675 PYTHON3_SRC="if_python3.c"
1676 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001677 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001678 PYTHON3_LIBS=
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001679elif test "$python_ok" = yes && test "$enable_pythoninterp" = "dynamic"; then
1680 AC_DEFINE(DYNAMIC_PYTHON)
1681 PYTHON_SRC="if_python.c"
1682 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001683 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001684 PYTHON_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001685elif test "$python_ok" = yes; then
1686 dnl Check that adding -fPIE works. It may be needed when using a static
1687 dnl Python library.
1688 AC_MSG_CHECKING([if -fPIE can be added for Python])
1689 cflags_save=$CFLAGS
1690 libs_save=$LIBS
1691 CFLAGS="$CFLAGS $PYTHON_CFLAGS -fPIE"
1692 LIBS="$LIBS $PYTHON_LIBS"
1693 AC_TRY_LINK(,[ ],
1694 AC_MSG_RESULT(yes); fpie_ok=yes,
1695 AC_MSG_RESULT(no); fpie_ok=no)
1696 CFLAGS=$cflags_save
1697 LIBS=$libs_save
1698 if test $fpie_ok = yes; then
1699 PYTHON_CFLAGS="$PYTHON_CFLAGS -fPIE"
1700 fi
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001701elif test "$python3_ok" = yes && test "$enable_python3interp" = "dynamic"; then
1702 AC_DEFINE(DYNAMIC_PYTHON3)
1703 PYTHON3_SRC="if_python3.c"
1704 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001705 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001706 PYTHON3_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001707elif test "$python3_ok" = yes; then
1708 dnl Check that adding -fPIE works. It may be needed when using a static
1709 dnl Python library.
1710 AC_MSG_CHECKING([if -fPIE can be added for Python3])
1711 cflags_save=$CFLAGS
1712 libs_save=$LIBS
1713 CFLAGS="$CFLAGS $PYTHON3_CFLAGS -fPIE"
1714 LIBS="$LIBS $PYTHON3_LIBS"
1715 AC_TRY_LINK(,[ ],
1716 AC_MSG_RESULT(yes); fpie_ok=yes,
1717 AC_MSG_RESULT(no); fpie_ok=no)
1718 CFLAGS=$cflags_save
1719 LIBS=$libs_save
1720 if test $fpie_ok = yes; then
1721 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -fPIE"
1722 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001723fi
1724
Bram Moolenaar071d4272004-06-13 20:20:40 +00001725AC_MSG_CHECKING(--enable-tclinterp argument)
1726AC_ARG_ENABLE(tclinterp,
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001727 [ --enable-tclinterp[=OPTS] Include Tcl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001728 [enable_tclinterp="no"])
1729AC_MSG_RESULT($enable_tclinterp)
1730
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001731if test "$enable_tclinterp" = "yes" -o "$enable_tclinterp" = "dynamic"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001732
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001733 dnl on FreeBSD tclsh is a silly script, look for tclsh8.[5420]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001734 AC_MSG_CHECKING(--with-tclsh argument)
1735 AC_ARG_WITH(tclsh, [ --with-tclsh=PATH which tclsh to use (default: tclsh8.0)],
1736 tclsh_name="$withval"; AC_MSG_RESULT($tclsh_name),
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001737 tclsh_name="tclsh8.5"; AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00001738 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1739 AC_SUBST(vi_cv_path_tcl)
1740
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001741 dnl when no specific version specified, also try 8.4, 8.2 and 8.0
1742 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.5"; then
1743 tclsh_name="tclsh8.4"
1744 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1745 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001746 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.4"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001747 tclsh_name="tclsh8.2"
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.2"; then
1751 tclsh_name="tclsh8.0"
1752 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1753 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001754 dnl still didn't find it, try without version number
1755 if test "X$vi_cv_path_tcl" = "X"; then
1756 tclsh_name="tclsh"
1757 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1758 fi
1759 if test "X$vi_cv_path_tcl" != "X"; then
1760 AC_MSG_CHECKING(Tcl version)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001761 if echo 'exit [[expr [info tclversion] < 8.0]]' | "$vi_cv_path_tcl" - ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001762 tclver=`echo 'puts [[info tclversion]]' | $vi_cv_path_tcl -`
1763 AC_MSG_RESULT($tclver - OK);
1764 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 +01001765 tcldll=`echo 'puts libtcl[[info tclversion]][[info sharedlibextension]]' | $vi_cv_path_tcl -`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001766
1767 AC_MSG_CHECKING(for location of Tcl include)
Bram Moolenaard0573012017-10-28 21:11:06 +02001768 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001769 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 +00001770 else
1771 dnl For Mac OS X 10.3, use the OS-provided framework location
1772 tclinc="/System/Library/Frameworks/Tcl.framework/Headers"
1773 fi
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001774 TCL_INC=
Bram Moolenaar071d4272004-06-13 20:20:40 +00001775 for try in $tclinc; do
1776 if test -f "$try/tcl.h"; then
1777 AC_MSG_RESULT($try/tcl.h)
1778 TCL_INC=$try
1779 break
1780 fi
1781 done
1782 if test -z "$TCL_INC"; then
1783 AC_MSG_RESULT(<not found>)
1784 SKIP_TCL=YES
1785 fi
1786 if test -z "$SKIP_TCL"; then
1787 AC_MSG_CHECKING(for location of tclConfig.sh script)
Bram Moolenaard0573012017-10-28 21:11:06 +02001788 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001789 tclcnf=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001790 tclcnf="$tclcnf `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001791 else
1792 dnl For Mac OS X 10.3, use the OS-provided framework location
1793 tclcnf="/System/Library/Frameworks/Tcl.framework"
1794 fi
1795 for try in $tclcnf; do
Bram Moolenaar49222be2015-12-11 18:11:30 +01001796 if test -f "$try/tclConfig.sh"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001797 AC_MSG_RESULT($try/tclConfig.sh)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001798 . "$try/tclConfig.sh"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001799 dnl use eval, because tcl 8.2 includes ${TCL_DBGX}
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001800 if test "$enable_tclinterp" = "dynamic"; then
1801 TCL_LIBS=`eval echo "$TCL_STUB_LIB_SPEC $TCL_LIBS"`
1802 else
1803 TCL_LIBS=`eval echo "$TCL_LIB_SPEC $TCL_LIBS"`
1804 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001805 dnl Use $TCL_DEFS for -D_THREAD_SAFE et al. But only use the
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001806 dnl "-D_ABC" items. Watch out for -DFOO=long\ long.
Bram Moolenaar4394bff2008-07-24 11:21:31 +00001807 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 +00001808 break
1809 fi
1810 done
1811 if test -z "$TCL_LIBS"; then
1812 AC_MSG_RESULT(<not found>)
1813 AC_MSG_CHECKING(for Tcl library by myself)
1814 tcllib=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001815 tcllib="$tcllib `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001816 for ext in .so .a ; do
1817 for ver in "" $tclver ; do
1818 for try in $tcllib ; do
1819 trylib=tcl$ver$ext
Bram Moolenaar49222be2015-12-11 18:11:30 +01001820 if test -f "$try/lib$trylib" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001821 AC_MSG_RESULT($try/lib$trylib)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001822 TCL_LIBS="-L\"$try\" -ltcl$ver -ldl -lm"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001823 if test "`(uname) 2>/dev/null`" = SunOS &&
1824 uname -r | grep '^5' >/dev/null; then
1825 TCL_LIBS="$TCL_LIBS -R $try"
1826 fi
1827 break 3
1828 fi
1829 done
1830 done
1831 done
1832 if test -z "$TCL_LIBS"; then
1833 AC_MSG_RESULT(<not found>)
1834 SKIP_TCL=YES
1835 fi
1836 fi
1837 if test -z "$SKIP_TCL"; then
1838 AC_DEFINE(FEAT_TCL)
1839 TCL_SRC=if_tcl.c
1840 TCL_OBJ=objects/if_tcl.o
1841 TCL_PRO=if_tcl.pro
1842 TCL_CFLAGS="-I$TCL_INC $TCL_DEFS"
1843 fi
1844 fi
1845 else
1846 AC_MSG_RESULT(too old; need Tcl version 8.0 or later)
1847 fi
1848 fi
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001849 if test "$enable_tclinterp" = "dynamic"; then
1850 if test "X$TCL_SRC" != "X" -a "X$tcldll" != "X"; then
1851 AC_DEFINE(DYNAMIC_TCL)
1852 TCL_CFLAGS="-DDYNAMIC_TCL_DLL=\\\"$tcldll\\\" -DDYNAMIC_TCL_VER=\\\"$tclver\\\" $TCL_CFLAGS"
1853 fi
1854 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001855 if test "$fail_if_missing" = "yes" -a -z "$TCL_SRC"; then
1856 AC_MSG_ERROR([could not configure Tcl])
1857 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001858fi
1859AC_SUBST(TCL_SRC)
1860AC_SUBST(TCL_OBJ)
1861AC_SUBST(TCL_PRO)
1862AC_SUBST(TCL_CFLAGS)
1863AC_SUBST(TCL_LIBS)
1864
1865AC_MSG_CHECKING(--enable-rubyinterp argument)
1866AC_ARG_ENABLE(rubyinterp,
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001867 [ --enable-rubyinterp[=OPTS] Include Ruby interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001868 [enable_rubyinterp="no"])
1869AC_MSG_RESULT($enable_rubyinterp)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001870if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001871 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1872 AC_MSG_ERROR([cannot use Ruby with tiny or small features])
1873 fi
1874
Bram Moolenaar165641d2010-02-17 16:23:09 +01001875 AC_MSG_CHECKING(--with-ruby-command argument)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001876 AC_SUBST(vi_cv_path_ruby)
Bram Moolenaar948733a2011-05-05 18:10:16 +02001877 AC_ARG_WITH(ruby-command, [ --with-ruby-command=RUBY name of the Ruby command (default: ruby)],
1878 RUBY_CMD="$withval"; vi_cv_path_ruby="$withval"; AC_MSG_RESULT($RUBY_CMD),
1879 RUBY_CMD="ruby"; AC_MSG_RESULT(defaulting to $RUBY_CMD))
Bram Moolenaar165641d2010-02-17 16:23:09 +01001880 AC_PATH_PROG(vi_cv_path_ruby, $RUBY_CMD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001881 if test "X$vi_cv_path_ruby" != "X"; then
1882 AC_MSG_CHECKING(Ruby version)
Bram Moolenaare4efc3b2005-03-07 23:16:51 +00001883 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 +00001884 AC_MSG_RESULT(OK)
Bram Moolenaar81398892012-10-03 21:09:35 +02001885 AC_MSG_CHECKING(Ruby rbconfig)
1886 ruby_rbconfig="RbConfig"
1887 if ! $vi_cv_path_ruby -r rbconfig -e 'RbConfig' >/dev/null 2>/dev/null; then
1888 ruby_rbconfig="Config"
1889 fi
1890 AC_MSG_RESULT($ruby_rbconfig)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001891 AC_MSG_CHECKING(Ruby header files)
Bram Moolenaar81398892012-10-03 21:09:35 +02001892 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 +00001893 if test "X$rubyhdrdir" != "X"; then
1894 AC_MSG_RESULT($rubyhdrdir)
1895 RUBY_CFLAGS="-I$rubyhdrdir"
Bram Moolenaara6fd37b2014-03-27 17:19:09 +01001896 rubyarchdir=`$vi_cv_path_ruby -r rbconfig -e "print ($ruby_rbconfig::CONFIG.has_key? 'rubyarchhdrdir') ? $ruby_rbconfig::CONFIG[['rubyarchhdrdir']] : '$rubyhdrdir/'+$ruby_rbconfig::CONFIG[['arch']]"`
1897 if test -d "$rubyarchdir"; then
1898 RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyarchdir"
Bram Moolenaar165641d2010-02-17 16:23:09 +01001899 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001900 rubyversion=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['ruby_version']].gsub(/\./, '')[[0,2]]"`
Bram Moolenaar026a4452013-08-07 15:22:23 +02001901 if test "X$rubyversion" = "X"; then
1902 rubyversion=`$vi_cv_path_ruby -e "print ((VERSION rescue RUBY_VERSION)).gsub(/\./, '')[[0,2]]"`
1903 fi
Bram Moolenaar165641d2010-02-17 16:23:09 +01001904 RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
Bram Moolenaar81398892012-10-03 21:09:35 +02001905 rubylibs=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LIBS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001906 if test "X$rubylibs" != "X"; then
1907 RUBY_LIBS="$rubylibs"
1908 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001909 librubyarg=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBYARG']])"`
1910 librubya=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBY_A']])"`
Bram Moolenaarac499e32013-06-02 19:14:17 +02001911 rubylibdir=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['libdir']])"`
Bram Moolenaar948733a2011-05-05 18:10:16 +02001912 if test -f "$rubylibdir/$librubya"; then
1913 librubyarg="$librubyarg"
Bram Moolenaarac499e32013-06-02 19:14:17 +02001914 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
1915 elif test "$librubyarg" = "libruby.a"; then
1916 dnl required on Mac OS 10.3 where libruby.a doesn't exist
1917 librubyarg="-lruby"
1918 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001919 fi
1920
1921 if test "X$librubyarg" != "X"; then
1922 RUBY_LIBS="$librubyarg $RUBY_LIBS"
1923 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001924 rubyldflags=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LDFLAGS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001925 if test "X$rubyldflags" != "X"; then
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001926 dnl Ruby on Mac OS X 10.5 adds "-arch" flags but these should only
1927 dnl be included if requested by passing --with-mac-arch to
1928 dnl configure, so strip these flags first (if present)
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001929 rubyldflags=`echo "$rubyldflags" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001930 if test "X$rubyldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001931 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$rubyldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001932 LDFLAGS="$rubyldflags $LDFLAGS"
1933 fi
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001934 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001935 fi
1936 RUBY_SRC="if_ruby.c"
1937 RUBY_OBJ="objects/if_ruby.o"
1938 RUBY_PRO="if_ruby.pro"
1939 AC_DEFINE(FEAT_RUBY)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001940 if test "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar92021622017-10-12 12:33:43 +02001941 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_ALIASES']].split[[0]]"`
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001942 AC_DEFINE(DYNAMIC_RUBY)
Bram Moolenaar92021622017-10-12 12:33:43 +02001943 RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby_soname\\\" -DDYNAMIC_RUBY_VER=$rubyversion $RUBY_CFLAGS"
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001944 RUBY_LIBS=
1945 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001946 else
Bram Moolenaar165641d2010-02-17 16:23:09 +01001947 AC_MSG_RESULT(not found; disabling Ruby)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001948 fi
1949 else
1950 AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
1951 fi
1952 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001953
1954 if test "$fail_if_missing" = "yes" -a -z "$RUBY_OBJ"; then
1955 AC_MSG_ERROR([could not configure Ruby])
1956 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001957fi
1958AC_SUBST(RUBY_SRC)
1959AC_SUBST(RUBY_OBJ)
1960AC_SUBST(RUBY_PRO)
1961AC_SUBST(RUBY_CFLAGS)
1962AC_SUBST(RUBY_LIBS)
1963
1964AC_MSG_CHECKING(--enable-cscope argument)
1965AC_ARG_ENABLE(cscope,
1966 [ --enable-cscope Include cscope interface.], ,
1967 [enable_cscope="no"])
1968AC_MSG_RESULT($enable_cscope)
1969if test "$enable_cscope" = "yes"; then
1970 AC_DEFINE(FEAT_CSCOPE)
1971fi
1972
1973AC_MSG_CHECKING(--enable-workshop argument)
1974AC_ARG_ENABLE(workshop,
1975 [ --enable-workshop Include Sun Visual Workshop support.], ,
1976 [enable_workshop="no"])
1977AC_MSG_RESULT($enable_workshop)
1978if test "$enable_workshop" = "yes"; then
1979 AC_DEFINE(FEAT_SUN_WORKSHOP)
1980 WORKSHOP_SRC="workshop.c integration.c"
1981 AC_SUBST(WORKSHOP_SRC)
1982 WORKSHOP_OBJ="objects/workshop.o objects/integration.o"
1983 AC_SUBST(WORKSHOP_OBJ)
1984 if test "${enable_gui-xxx}" = xxx; then
1985 enable_gui=motif
1986 fi
1987fi
1988
1989AC_MSG_CHECKING(--disable-netbeans argument)
1990AC_ARG_ENABLE(netbeans,
1991 [ --disable-netbeans Disable NetBeans integration support.],
1992 , [enable_netbeans="yes"])
1993if test "$enable_netbeans" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01001994 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1995 AC_MSG_RESULT([cannot use NetBeans with tiny or small features])
1996 enable_netbeans="no"
1997 else
1998 AC_MSG_RESULT(no)
1999 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002000else
2001 AC_MSG_RESULT(yes)
2002fi
2003
2004AC_MSG_CHECKING(--disable-channel argument)
2005AC_ARG_ENABLE(channel,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002006 [ --disable-channel Disable process communication support.],
Bram Moolenaare0874f82016-01-24 20:36:41 +01002007 , [enable_channel="yes"])
2008if test "$enable_channel" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002009 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2010 AC_MSG_RESULT([cannot use channels with tiny or small features])
2011 enable_channel="no"
2012 else
2013 AC_MSG_RESULT(no)
2014 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002015else
2016 if test "$enable_netbeans" = "yes"; then
Bram Moolenaar16435482016-01-24 21:31:54 +01002017 AC_MSG_RESULT([yes, netbeans also disabled])
Bram Moolenaare0874f82016-01-24 20:36:41 +01002018 enable_netbeans="no"
2019 else
2020 AC_MSG_RESULT(yes)
2021 fi
2022fi
2023
Bram Moolenaar16435482016-01-24 21:31:54 +01002024if test "$enable_channel" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002025 dnl On Solaris we need the socket and nsl library.
2026 AC_CHECK_LIB(socket, socket)
2027 AC_CHECK_LIB(nsl, gethostbyname)
Bram Moolenaare0874f82016-01-24 20:36:41 +01002028 AC_MSG_CHECKING(whether compiling with process communication is possible)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002029 AC_TRY_LINK([
2030#include <stdio.h>
2031#include <stdlib.h>
2032#include <stdarg.h>
2033#include <fcntl.h>
2034#include <netdb.h>
2035#include <netinet/in.h>
2036#include <errno.h>
2037#include <sys/types.h>
2038#include <sys/socket.h>
2039 /* Check bitfields */
2040 struct nbbuf {
2041 unsigned int initDone:1;
Bram Moolenaar63de19e2016-12-09 20:11:26 +01002042 unsigned short signmaplen;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002043 };
2044 ], [
2045 /* Check creating a socket. */
2046 struct sockaddr_in server;
2047 (void)socket(AF_INET, SOCK_STREAM, 0);
2048 (void)htons(100);
2049 (void)gethostbyname("microsoft.com");
2050 if (errno == ECONNREFUSED)
2051 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
2052 ],
2053 AC_MSG_RESULT(yes),
Bram Moolenaare0874f82016-01-24 20:36:41 +01002054 AC_MSG_RESULT(no); enable_netbeans="no"; enable_channel="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00002055fi
2056if test "$enable_netbeans" = "yes"; then
2057 AC_DEFINE(FEAT_NETBEANS_INTG)
2058 NETBEANS_SRC="netbeans.c"
2059 AC_SUBST(NETBEANS_SRC)
2060 NETBEANS_OBJ="objects/netbeans.o"
2061 AC_SUBST(NETBEANS_OBJ)
2062fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002063if test "$enable_channel" = "yes"; then
Bram Moolenaar509ce2a2016-03-11 22:52:15 +01002064 AC_DEFINE(FEAT_JOB_CHANNEL)
Bram Moolenaare0874f82016-01-24 20:36:41 +01002065 CHANNEL_SRC="channel.c"
2066 AC_SUBST(CHANNEL_SRC)
2067 CHANNEL_OBJ="objects/channel.o"
2068 AC_SUBST(CHANNEL_OBJ)
2069fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002070
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002071AC_MSG_CHECKING(--enable-terminal argument)
2072AC_ARG_ENABLE(terminal,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002073 [ --enable-terminal Enable terminal emulation support.],
Bram Moolenaaref839562017-10-28 20:28:23 +02002074 , [enable_terminal="auto"])
Bram Moolenaar595a4022017-09-03 19:15:57 +02002075if test "$enable_terminal" = "yes" || test "$enable_terminal" = "auto" -a "x$features" = "xhuge" ; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002076 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2077 AC_MSG_RESULT([cannot use terminal emulator with tiny or small features])
2078 enable_terminal="no"
2079 else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002080 if test "$enable_terminal" = "auto"; then
2081 enable_terminal="yes"
2082 AC_MSG_RESULT(defaulting to yes)
2083 else
2084 AC_MSG_RESULT(yes)
2085 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002086 fi
2087else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002088 if test "$enable_terminal" = "auto"; then
2089 enable_terminal="no"
2090 AC_MSG_RESULT(defaulting to no)
2091 else
2092 AC_MSG_RESULT(no)
2093 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002094fi
Bram Moolenaar8b423282017-12-16 14:37:06 +01002095if test "$enable_terminal" = "yes" -a "$enable_channel" = "yes"; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002096 AC_DEFINE(FEAT_TERMINAL)
2097 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"
2098 AC_SUBST(TERM_SRC)
2099 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"
2100 AC_SUBST(TERM_OBJ)
2101fi
2102
Bram Moolenaare42a6d22017-11-12 19:21:51 +01002103AC_MSG_CHECKING(--enable-autoservername argument)
2104AC_ARG_ENABLE(autoservername,
2105 [ --enable-autoservername Automatically define servername at vim startup.], ,
2106 [enable_autoservername="no"])
2107AC_MSG_RESULT($enable_autoservername)
2108if test "$enable_autoservername" = "yes"; then
2109 AC_DEFINE(FEAT_AUTOSERVERNAME)
2110fi
2111
Bram Moolenaar071d4272004-06-13 20:20:40 +00002112AC_MSG_CHECKING(--enable-multibyte argument)
2113AC_ARG_ENABLE(multibyte,
2114 [ --enable-multibyte Include multibyte editing support.], ,
2115 [enable_multibyte="no"])
2116AC_MSG_RESULT($enable_multibyte)
2117if test "$enable_multibyte" = "yes"; then
2118 AC_DEFINE(FEAT_MBYTE)
2119fi
2120
2121AC_MSG_CHECKING(--enable-hangulinput argument)
2122AC_ARG_ENABLE(hangulinput,
2123 [ --enable-hangulinput Include Hangul input support.], ,
2124 [enable_hangulinput="no"])
2125AC_MSG_RESULT($enable_hangulinput)
2126
2127AC_MSG_CHECKING(--enable-xim argument)
2128AC_ARG_ENABLE(xim,
2129 [ --enable-xim Include XIM input support.],
2130 AC_MSG_RESULT($enable_xim),
2131 [enable_xim="auto"; AC_MSG_RESULT(defaulting to auto)])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002132
2133AC_MSG_CHECKING(--enable-fontset argument)
2134AC_ARG_ENABLE(fontset,
2135 [ --enable-fontset Include X fontset output support.], ,
2136 [enable_fontset="no"])
2137AC_MSG_RESULT($enable_fontset)
2138dnl defining FEAT_XFONTSET is delayed, so that it can be disabled for no GUI
2139
2140test -z "$with_x" && with_x=yes
Bram Moolenaard0573012017-10-28 21:11:06 +02002141test "${enable_gui-yes}" != no -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && with_x=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002142if test "$with_x" = no; then
2143 AC_MSG_RESULT(defaulting to: don't HAVE_X11)
2144else
2145 dnl Do this check early, so that its failure can override user requests.
2146
2147 AC_PATH_PROG(xmkmfpath, xmkmf)
2148
2149 AC_PATH_XTRA
2150
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002151 dnl On z/OS Unix the X libraries are DLLs. To use them the code must
Bram Moolenaar071d4272004-06-13 20:20:40 +00002152 dnl be compiled with a special option.
2153 dnl Also add SM, ICE and Xmu to X_EXTRA_LIBS.
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002154 if test "$zOSUnix" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002155 CFLAGS="$CFLAGS -W c,dll"
2156 LDFLAGS="$LDFLAGS -W l,dll"
2157 X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE -lXmu"
2158 fi
2159
2160 dnl On my HPUX system the X include dir is found, but the lib dir not.
2161 dnl This is a desparate try to fix this.
2162
2163 if test -d "$x_includes" && test ! -d "$x_libraries"; then
2164 x_libraries=`echo "$x_includes" | sed s/include/lib/`
2165 AC_MSG_RESULT(Corrected X libraries to $x_libraries)
2166 X_LIBS="$X_LIBS -L$x_libraries"
2167 if test "`(uname) 2>/dev/null`" = SunOS &&
2168 uname -r | grep '^5' >/dev/null; then
2169 X_LIBS="$X_LIBS -R $x_libraries"
2170 fi
2171 fi
2172
2173 if test -d "$x_libraries" && test ! -d "$x_includes"; then
2174 x_includes=`echo "$x_libraries" | sed s/lib/include/`
2175 AC_MSG_RESULT(Corrected X includes to $x_includes)
2176 X_CFLAGS="$X_CFLAGS -I$x_includes"
2177 fi
2178
2179 dnl Remove "-I/usr/include " from X_CFLAGS, should not be needed.
2180 X_CFLAGS="`echo $X_CFLAGS\ | sed 's%-I/usr/include %%'`"
2181 dnl Remove "-L/usr/lib " from X_LIBS, should not be needed.
2182 X_LIBS="`echo $X_LIBS\ | sed 's%-L/usr/lib %%'`"
2183 dnl Same for "-R/usr/lib ".
2184 X_LIBS="`echo $X_LIBS\ | sed -e 's%-R/usr/lib %%' -e 's%-R /usr/lib %%'`"
2185
2186
2187 dnl Check if the X11 header files are correctly installed. On some systems
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002188 dnl Xlib.h includes files that don't exist. On some systems X11/Intrinsic.h
2189 dnl is missing.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002190 AC_MSG_CHECKING(if X11 header files can be found)
2191 cflags_save=$CFLAGS
2192 CFLAGS="$CFLAGS $X_CFLAGS"
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002193 AC_TRY_COMPILE([#include <X11/Xlib.h>
2194#include <X11/Intrinsic.h>], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002195 AC_MSG_RESULT(yes),
2196 AC_MSG_RESULT(no); no_x=yes)
2197 CFLAGS=$cflags_save
2198
2199 if test "${no_x-no}" = yes; then
2200 with_x=no
2201 else
2202 AC_DEFINE(HAVE_X11)
2203 X_LIB="-lXt -lX11";
2204 AC_SUBST(X_LIB)
2205
2206 ac_save_LDFLAGS="$LDFLAGS"
2207 LDFLAGS="-L$x_libraries $LDFLAGS"
2208
2209 dnl Check for -lXdmcp (needed on SunOS 4.1.4)
2210 dnl For HP-UX 10.20 it must be before -lSM -lICE
2211 AC_CHECK_LIB(Xdmcp, _XdmcpAuthDoIt, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lXdmcp"],,
2212 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXdmcp])
2213
2214 dnl Some systems need -lnsl -lsocket when testing for ICE.
2215 dnl The check above doesn't do this, try here (again). Also needed to get
2216 dnl them after Xdmcp. link.sh will remove them when not needed.
2217 dnl Check for other function than above to avoid the cached value
2218 AC_CHECK_LIB(ICE, IceOpenConnection,
2219 [X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE"],, [$X_EXTRA_LIBS])
2220
2221 dnl Check for -lXpm (needed for some versions of Motif)
2222 LDFLAGS="$X_LIBS $ac_save_LDFLAGS"
2223 AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [X_PRE_LIBS="$X_PRE_LIBS -lXpm"],,
2224 [-lXt $X_PRE_LIBS -lXpm -lX11 $X_EXTRA_LIBS])
2225
2226 dnl Check that the X11 header files don't use implicit declarations
2227 AC_MSG_CHECKING(if X11 header files implicitly declare return values)
2228 cflags_save=$CFLAGS
Bram Moolenaard1864592013-05-04 04:40:15 +02002229 dnl -Werror is GCC only, others like Solaris Studio might not like it
2230 if test "$GCC" = yes; then
2231 CFLAGS="$CFLAGS $X_CFLAGS -Werror"
2232 else
2233 CFLAGS="$CFLAGS $X_CFLAGS"
2234 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002235 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2236 AC_MSG_RESULT(no),
2237 CFLAGS="$CFLAGS -Wno-implicit-int"
2238 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2239 AC_MSG_RESULT(yes); cflags_save="$cflags_save -Wno-implicit-int",
2240 AC_MSG_RESULT(test failed)
2241 )
2242 )
2243 CFLAGS=$cflags_save
2244
2245 LDFLAGS="$ac_save_LDFLAGS"
2246
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002247 AC_MSG_CHECKING(size of wchar_t is 2 bytes)
2248 AC_CACHE_VAL(ac_cv_small_wchar_t,
2249 [AC_TRY_RUN([
2250#include <X11/Xlib.h>
2251#if STDC_HEADERS
2252# include <stdlib.h>
2253# include <stddef.h>
2254#endif
2255 main()
2256 {
2257 if (sizeof(wchar_t) <= 2)
2258 exit(1);
2259 exit(0);
2260 }],
2261 ac_cv_small_wchar_t="no",
2262 ac_cv_small_wchar_t="yes",
2263 AC_MSG_ERROR(failed to compile test program))])
2264 AC_MSG_RESULT($ac_cv_small_wchar_t)
2265 if test "x$ac_cv_small_wchar_t" = "xyes" ; then
2266 AC_DEFINE(SMALL_WCHAR_T)
2267 fi
2268
Bram Moolenaar071d4272004-06-13 20:20:40 +00002269 fi
2270fi
2271
Bram Moolenaard0573012017-10-28 21:11:06 +02002272test "x$with_x" = xno -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && enable_gui=no
Bram Moolenaar071d4272004-06-13 20:20:40 +00002273
2274AC_MSG_CHECKING(--enable-gui argument)
2275AC_ARG_ENABLE(gui,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002276 [ --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 +00002277
2278dnl Canonicalize the --enable-gui= argument so that it can be easily compared.
2279dnl Do not use character classes for portability with old tools.
2280enable_gui_canon=`echo "_$enable_gui" | \
2281 sed 's/[[ _+-]]//g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
2282
2283dnl Skip everything by default.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002284SKIP_GTK2=YES
Bram Moolenaar1858a842016-02-23 22:30:31 +01002285SKIP_GTK3=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002286SKIP_GNOME=YES
2287SKIP_MOTIF=YES
2288SKIP_ATHENA=YES
2289SKIP_NEXTAW=YES
2290SKIP_PHOTON=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002291SKIP_CARBON=YES
2292GUITYPE=NONE
2293
Bram Moolenaarb11160e2005-01-04 21:31:43 +00002294if test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002295 SKIP_PHOTON=
2296 case "$enable_gui_canon" in
2297 no) AC_MSG_RESULT(no GUI support)
2298 SKIP_PHOTON=YES ;;
2299 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
2300 auto) AC_MSG_RESULT(auto - automatic GUI support) ;;
2301 photon) AC_MSG_RESULT(Photon GUI support) ;;
2302 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2303 SKIP_PHOTON=YES ;;
2304 esac
2305
Bram Moolenaard0573012017-10-28 21:11:06 +02002306elif test "x$MACOS_X" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002307 SKIP_CARBON=
2308 case "$enable_gui_canon" in
2309 no) AC_MSG_RESULT(no GUI support)
2310 SKIP_CARBON=YES ;;
2311 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
Bram Moolenaar164fca32010-07-14 13:58:07 +02002312 auto) AC_MSG_RESULT(auto - Carbon GUI is outdated - disable GUI support)
2313 SKIP_CARBON=YES ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002314 carbon) AC_MSG_RESULT(Carbon GUI support) ;;
2315 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2316 SKIP_CARBON=YES ;;
2317 esac
2318
2319else
2320
Bram Moolenaar071d4272004-06-13 20:20:40 +00002321 case "$enable_gui_canon" in
2322 no|none) AC_MSG_RESULT(no GUI support) ;;
2323 yes|""|auto) AC_MSG_RESULT(yes/auto - automatic GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002324 SKIP_GTK2=
2325 SKIP_GNOME=
2326 SKIP_MOTIF=
2327 SKIP_ATHENA=
2328 SKIP_NEXTAW=
2329 SKIP_CARBON=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002330 gtk2) AC_MSG_RESULT(GTK+ 2.x GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002331 SKIP_GTK2=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002332 gnome2) AC_MSG_RESULT(GNOME 2.x GUI support)
2333 SKIP_GNOME=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002334 SKIP_GTK2=;;
Bram Moolenaar98921892016-02-23 17:14:37 +01002335 gtk3) AC_MSG_RESULT(GTK+ 3.x GUI support)
2336 SKIP_GTK3=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002337 motif) AC_MSG_RESULT(Motif GUI support)
2338 SKIP_MOTIF=;;
2339 athena) AC_MSG_RESULT(Athena GUI support)
2340 SKIP_ATHENA=;;
2341 nextaw) AC_MSG_RESULT(neXtaw GUI support)
2342 SKIP_NEXTAW=;;
2343 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
2344 esac
2345
2346fi
2347
Bram Moolenaar071d4272004-06-13 20:20:40 +00002348if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \
2349 -a "$enable_gui_canon" != "gnome2"; then
2350 AC_MSG_CHECKING(whether or not to look for GTK+ 2)
2351 AC_ARG_ENABLE(gtk2-check,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002352 [ --enable-gtk2-check If auto-select GUI, check for GTK+ 2 [default=yes]],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002353 , enable_gtk2_check="yes")
2354 AC_MSG_RESULT($enable_gtk2_check)
2355 if test "x$enable_gtk2_check" = "xno"; then
2356 SKIP_GTK2=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002357 SKIP_GNOME=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002358 fi
2359fi
2360
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002361if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002362 AC_MSG_CHECKING(whether or not to look for GNOME)
2363 AC_ARG_ENABLE(gnome-check,
2364 [ --enable-gnome-check If GTK GUI, check for GNOME [default=no]],
2365 , enable_gnome_check="no")
2366 AC_MSG_RESULT($enable_gnome_check)
2367 if test "x$enable_gnome_check" = "xno"; then
2368 SKIP_GNOME=YES
2369 fi
2370fi
2371
Bram Moolenaar98921892016-02-23 17:14:37 +01002372if test "x$SKIP_GTK3" != "xYES" -a "$enable_gui_canon" != "gtk3"; then
2373 AC_MSG_CHECKING(whether or not to look for GTK+ 3)
2374 AC_ARG_ENABLE(gtk3-check,
2375 [ --enable-gtk3-check If auto-select GUI, check for GTK+ 3 [default=yes]],
2376 , enable_gtk3_check="yes")
2377 AC_MSG_RESULT($enable_gtk3_check)
2378 if test "x$enable_gtk3_check" = "xno"; then
2379 SKIP_GTK3=YES
2380 fi
2381fi
2382
Bram Moolenaar071d4272004-06-13 20:20:40 +00002383if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then
2384 AC_MSG_CHECKING(whether or not to look for Motif)
2385 AC_ARG_ENABLE(motif-check,
2386 [ --enable-motif-check If auto-select GUI, check for Motif [default=yes]],
2387 , enable_motif_check="yes")
2388 AC_MSG_RESULT($enable_motif_check)
2389 if test "x$enable_motif_check" = "xno"; then
2390 SKIP_MOTIF=YES
2391 fi
2392fi
2393
2394if test "x$SKIP_ATHENA" != "xYES" -a "$enable_gui_canon" != "athena"; then
2395 AC_MSG_CHECKING(whether or not to look for Athena)
2396 AC_ARG_ENABLE(athena-check,
2397 [ --enable-athena-check If auto-select GUI, check for Athena [default=yes]],
2398 , enable_athena_check="yes")
2399 AC_MSG_RESULT($enable_athena_check)
2400 if test "x$enable_athena_check" = "xno"; then
2401 SKIP_ATHENA=YES
2402 fi
2403fi
2404
2405if test "x$SKIP_NEXTAW" != "xYES" -a "$enable_gui_canon" != "nextaw"; then
2406 AC_MSG_CHECKING(whether or not to look for neXtaw)
2407 AC_ARG_ENABLE(nextaw-check,
2408 [ --enable-nextaw-check If auto-select GUI, check for neXtaw [default=yes]],
2409 , enable_nextaw_check="yes")
2410 AC_MSG_RESULT($enable_nextaw_check);
2411 if test "x$enable_nextaw_check" = "xno"; then
2412 SKIP_NEXTAW=YES
2413 fi
2414fi
2415
2416if test "x$SKIP_CARBON" != "xYES" -a "$enable_gui_canon" != "carbon"; then
2417 AC_MSG_CHECKING(whether or not to look for Carbon)
2418 AC_ARG_ENABLE(carbon-check,
2419 [ --enable-carbon-check If auto-select GUI, check for Carbon [default=yes]],
2420 , enable_carbon_check="yes")
2421 AC_MSG_RESULT($enable_carbon_check);
2422 if test "x$enable_carbon_check" = "xno"; then
2423 SKIP_CARBON=YES
2424 fi
2425fi
2426
Bram Moolenaar843ee412004-06-30 16:16:41 +00002427
Bram Moolenaard0573012017-10-28 21:11:06 +02002428if test "x$MACOS_X" = "xyes" -a -z "$SKIP_CARBON" -a "x$CARBON" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002429 AC_MSG_CHECKING(for Carbon GUI)
Bram Moolenaar14716812006-05-04 21:54:08 +00002430 dnl already did the check, just give the message
Bram Moolenaar071d4272004-06-13 20:20:40 +00002431 AC_MSG_RESULT(yes);
2432 GUITYPE=CARBONGUI
Bram Moolenaare344bea2005-09-01 20:46:49 +00002433 if test "$VIMNAME" = "vim"; then
2434 VIMNAME=Vim
2435 fi
Bram Moolenaar14716812006-05-04 21:54:08 +00002436
Bram Moolenaar164fca32010-07-14 13:58:07 +02002437 if test "x$MACARCH" = "xboth"; then
2438 CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk/Developer/Headers/FlatCarbon"
2439 else
2440 CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/Headers/FlatCarbon"
2441 fi
2442
Bram Moolenaar14716812006-05-04 21:54:08 +00002443 dnl Default install directory is not /usr/local
2444 if test x$prefix = xNONE; then
2445 prefix=/Applications
2446 fi
2447
2448 dnl Sorry for the hard coded default
2449 datadir='${prefix}/Vim.app/Contents/Resources'
2450
Bram Moolenaar071d4272004-06-13 20:20:40 +00002451 dnl skip everything else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002452 SKIP_GTK2=YES;
2453 SKIP_GNOME=YES;
2454 SKIP_MOTIF=YES;
2455 SKIP_ATHENA=YES;
2456 SKIP_NEXTAW=YES;
2457 SKIP_PHOTON=YES;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002458 SKIP_CARBON=YES
2459fi
2460
Bram Moolenaar071d4272004-06-13 20:20:40 +00002461dnl define an autoconf function to check for a specified version of GTK, and
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002462dnl try to compile/link a GTK program.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002463dnl
2464dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002465dnl Test for GTK, and define GTK_CFLAGS, GTK_LIBDIR and GTK_LIBS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002466dnl
2467AC_DEFUN(AM_PATH_GTK,
2468[
2469 if test "X$GTK_CONFIG" != "Xno" -o "X$PKG_CONFIG" != "Xno"; then
2470 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00002471 no_gtk=""
2472 if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2473 && $PKG_CONFIG --exists gtk+-2.0; then
2474 {
Bram Moolenaar98921892016-02-23 17:14:37 +01002475 min_gtk_version=ifelse([$1], ,2.2.0,$1)
2476 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002477 dnl We should be using PKG_CHECK_MODULES() instead of this hack.
2478 dnl But I guess the dependency on pkgconfig.m4 is not wanted or
2479 dnl something like that.
2480 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0`
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002481 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-2.0`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002482 GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0`
2483 gtk_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2484 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2485 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2486 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2487 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2488 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2489 }
Bram Moolenaar98921892016-02-23 17:14:37 +01002490 elif (test "X$SKIP_GTK3" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2491 && $PKG_CONFIG --exists gtk+-3.0; then
2492 {
2493 min_gtk_version=ifelse([$1], ,3.0.0,$1)
2494 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
2495
2496 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-3.0`
2497 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-3.0`
2498 GTK_LIBS=`$PKG_CONFIG --libs gtk+-3.0`
2499 gtk_major_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2500 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2501 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2502 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2503 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2504 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2505 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002506 else
2507 no_gtk=yes
2508 fi
2509
2510 if test "x$enable_gtktest" = "xyes" -a "x$no_gtk" = "x"; then
2511 {
2512 ac_save_CFLAGS="$CFLAGS"
2513 ac_save_LIBS="$LIBS"
2514 CFLAGS="$CFLAGS $GTK_CFLAGS"
2515 LIBS="$LIBS $GTK_LIBS"
2516
2517 dnl
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002518 dnl Now check if the installed GTK is sufficiently new.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002519 dnl
2520 rm -f conf.gtktest
2521 AC_TRY_RUN([
2522#include <gtk/gtk.h>
2523#include <stdio.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00002524#if STDC_HEADERS
2525# include <stdlib.h>
2526# include <stddef.h>
2527#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002528
2529int
2530main ()
2531{
2532int major, minor, micro;
2533char *tmp_version;
2534
2535system ("touch conf.gtktest");
2536
2537/* HP/UX 9 (%@#!) writes to sscanf strings */
2538tmp_version = g_strdup("$min_gtk_version");
2539if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
2540 printf("%s, bad version string\n", "$min_gtk_version");
2541 exit(1);
2542 }
2543
2544if ((gtk_major_version > major) ||
2545 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
2546 ((gtk_major_version == major) && (gtk_minor_version == minor) &&
2547 (gtk_micro_version >= micro)))
2548{
2549 return 0;
2550}
2551return 1;
2552}
2553],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
2554 CFLAGS="$ac_save_CFLAGS"
2555 LIBS="$ac_save_LIBS"
2556 }
2557 fi
2558 if test "x$no_gtk" = x ; then
2559 if test "x$enable_gtktest" = "xyes"; then
2560 AC_MSG_RESULT(yes; found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2561 else
2562 AC_MSG_RESULT(found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2563 fi
2564 ifelse([$2], , :, [$2])
2565 else
2566 {
2567 AC_MSG_RESULT(no)
2568 GTK_CFLAGS=""
2569 GTK_LIBS=""
2570 ifelse([$3], , :, [$3])
2571 }
2572 fi
2573 }
2574 else
2575 GTK_CFLAGS=""
2576 GTK_LIBS=""
2577 ifelse([$3], , :, [$3])
2578 fi
2579 AC_SUBST(GTK_CFLAGS)
2580 AC_SUBST(GTK_LIBS)
2581 rm -f conf.gtktest
2582])
2583
2584dnl ---------------------------------------------------------------------------
2585dnl gnome
2586dnl ---------------------------------------------------------------------------
2587AC_DEFUN([GNOME_INIT_HOOK],
2588[
2589 AC_SUBST(GNOME_LIBS)
2590 AC_SUBST(GNOME_LIBDIR)
2591 AC_SUBST(GNOME_INCLUDEDIR)
2592
2593 AC_ARG_WITH(gnome-includes,
2594 [ --with-gnome-includes=DIR Specify location of GNOME headers],
2595 [CFLAGS="$CFLAGS -I$withval"]
2596 )
2597
2598 AC_ARG_WITH(gnome-libs,
2599 [ --with-gnome-libs=DIR Specify location of GNOME libs],
2600 [LDFLAGS="$LDFLAGS -L$withval" gnome_prefix=$withval]
2601 )
2602
2603 AC_ARG_WITH(gnome,
2604 [ --with-gnome Specify prefix for GNOME files],
2605 if test x$withval = xyes; then
2606 want_gnome=yes
2607 ifelse([$1], [], :, [$1])
2608 else
2609 if test "x$withval" = xno; then
2610 want_gnome=no
2611 else
2612 want_gnome=yes
2613 LDFLAGS="$LDFLAGS -L$withval/lib"
2614 CFLAGS="$CFLAGS -I$withval/include"
2615 gnome_prefix=$withval/lib
2616 fi
2617 fi,
2618 want_gnome=yes)
2619
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002620 if test "x$want_gnome" = xyes; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002621 {
2622 AC_MSG_CHECKING(for libgnomeui-2.0)
2623 if $PKG_CONFIG --exists libgnomeui-2.0; then
2624 AC_MSG_RESULT(yes)
2625 GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0`
2626 GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0`
2627 GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0`
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002628
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002629 dnl On FreeBSD we need -pthread but pkg-config doesn't include it.
2630 dnl This might not be the right way but it works for me...
2631 AC_MSG_CHECKING(for FreeBSD)
2632 if test "`(uname) 2>/dev/null`" = FreeBSD; then
2633 AC_MSG_RESULT(yes, adding -pthread)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002634 GNOME_INCLUDEDIR="$GNOME_INCLUDEDIR -D_THREAD_SAFE"
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002635 GNOME_LIBS="$GNOME_LIBS -pthread"
2636 else
2637 AC_MSG_RESULT(no)
2638 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002639 $1
2640 else
2641 AC_MSG_RESULT(not found)
2642 if test "x$2" = xfail; then
2643 AC_MSG_ERROR(Could not find libgnomeui-2.0 via pkg-config)
2644 fi
2645 fi
2646 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002647 fi
2648])
2649
2650AC_DEFUN([GNOME_INIT],[
2651 GNOME_INIT_HOOK([],fail)
2652])
2653
2654
2655dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002656dnl Check for GTK2. If it fails, then continue on for Motif as before...
Bram Moolenaar071d4272004-06-13 20:20:40 +00002657dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002658if test -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002659
2660 AC_MSG_CHECKING(--disable-gtktest argument)
2661 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2662 , enable_gtktest=yes)
2663 if test "x$enable_gtktest" = "xyes" ; then
2664 AC_MSG_RESULT(gtk test enabled)
2665 else
2666 AC_MSG_RESULT(gtk test disabled)
2667 fi
2668
Bram Moolenaar071d4272004-06-13 20:20:40 +00002669 if test "X$PKG_CONFIG" = "X"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01002670 AC_PATH_TOOL(PKG_CONFIG, pkg-config, no)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002671 fi
2672
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002673 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002674 dnl First try finding version 2.2.0 or later. The 2.0.x series has
2675 dnl problems (bold fonts, --remote doesn't work).
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002676 AM_PATH_GTK(2.2.0,
2677 [GUI_LIB_LOC="$GTK_LIBDIR"
2678 GTK_LIBNAME="$GTK_LIBS"
2679 GUI_INC_LOC="$GTK_CFLAGS"], )
2680 if test "x$GTK_CFLAGS" != "x"; then
Bram Moolenaar98921892016-02-23 17:14:37 +01002681 SKIP_GTK3=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002682 SKIP_ATHENA=YES
2683 SKIP_NEXTAW=YES
2684 SKIP_MOTIF=YES
2685 GUITYPE=GTK
2686 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002687 fi
2688 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002689 if test "x$GUITYPE" = "xGTK"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002690 dnl
2691 dnl if GTK exists, then check for GNOME.
2692 dnl
2693 if test -z "$SKIP_GNOME"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002694 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002695 GNOME_INIT_HOOK([have_gnome=yes])
2696 if test "x$have_gnome" = xyes ; then
2697 AC_DEFINE(FEAT_GUI_GNOME)
2698 GUI_INC_LOC="$GUI_INC_LOC $GNOME_INCLUDEDIR"
2699 GTK_LIBNAME="$GTK_LIBNAME $GNOME_LIBDIR $GNOME_LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002700 fi
2701 }
2702 fi
2703 fi
2704fi
2705
Bram Moolenaar98921892016-02-23 17:14:37 +01002706
2707dnl ---------------------------------------------------------------------------
2708dnl Check for GTK3.
2709dnl ---------------------------------------------------------------------------
2710if test -z "$SKIP_GTK3"; then
2711
2712 AC_MSG_CHECKING(--disable-gtktest argument)
2713 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2714 , enable_gtktest=yes)
2715 if test "x$enable_gtktest" = "xyes" ; then
2716 AC_MSG_RESULT(gtk test enabled)
2717 else
2718 AC_MSG_RESULT(gtk test disabled)
2719 fi
2720
2721 if test "X$PKG_CONFIG" = "X"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01002722 AC_PATH_TOOL(PKG_CONFIG, pkg-config, no)
Bram Moolenaar98921892016-02-23 17:14:37 +01002723 fi
2724
2725 if test "x$PKG_CONFIG" != "xno"; then
2726 AM_PATH_GTK(3.0.0,
2727 [GUI_LIB_LOC="$GTK_LIBDIR"
2728 GTK_LIBNAME="$GTK_LIBS"
2729 GUI_INC_LOC="$GTK_CFLAGS"], )
2730 if test "x$GTK_CFLAGS" != "x"; then
2731 SKIP_GTK2=YES
2732 SKIP_GNOME=YES
2733 SKIP_ATHENA=YES
2734 SKIP_NEXTAW=YES
2735 SKIP_MOTIF=YES
2736 GUITYPE=GTK
2737 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar98921892016-02-23 17:14:37 +01002738 AC_DEFINE(USE_GTK3)
2739 fi
2740 fi
2741fi
2742
Bram Moolenaard2e03f02016-01-02 22:46:36 +01002743dnl Check the version of Gdk-Pixbuf. If the version is 2.31 or later and
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002744dnl glib-compile-resources is found in PATH, use GResource.
2745if test "x$GUITYPE" = "xGTK"; then
2746 AC_MSG_CHECKING([version of Gdk-Pixbuf])
2747 gdk_pixbuf_version=`$PKG_CONFIG --modversion gdk-pixbuf-2.0`
2748 if test "x$gdk_pixbuf_version" != x ; then
2749 gdk_pixbuf_version_minor=`echo $gdk_pixbuf_version | \
2750 sed -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/'`
2751 if test "x$gdk_pixbuf_version_minor" != x -a \
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002752 $gdk_pixbuf_version_minor -ge 31 ; then
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002753 AC_MSG_RESULT([OK.])
2754 AC_PATH_PROG(GLIB_COMPILE_RESOURCES,[glib-compile-resources],no)
2755 AC_MSG_CHECKING([glib-compile-resources])
2756 if test "x$GLIB_COMPILE_RESOURCES" = xno ; then
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002757 GLIB_COMPILE_RESOURCES=""
2758 AC_MSG_RESULT([cannot be found in PATH.])
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002759 else
2760 AC_MSG_RESULT([usable.])
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002761 AC_DEFINE(USE_GRESOURCE)
2762 GRESOURCE_SRC="auto/gui_gtk_gresources.c"
2763 GRESOURCE_OBJ="objects/gui_gtk_gresources.o"
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002764 fi
2765 else
2766 AC_MSG_RESULT([not usable.])
2767 fi
2768 else
2769 AC_MSG_RESULT([cannot obtain from pkg_config.])
2770 fi
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002771
2772 AC_MSG_CHECKING([--disable-icon-cache-update argument])
2773 AC_ARG_ENABLE(icon_cache_update,
2774 [ --disable-icon-cache-update update disabled],
2775 [],
2776 [enable_icon_cache_update="yes"])
2777 if test "$enable_icon_cache_update" = "yes"; then
2778 AC_MSG_RESULT([not set])
2779 AC_PATH_PROG(GTK_UPDATE_ICON_CACHE,[gtk-update-icon-cache],no)
2780 if test "x$GTK_UPDATE_ICON_CACHE" = "xno" ; then
2781 AC_MSG_RESULT([not found in PATH.])
2782 fi
2783 else
2784 AC_MSG_RESULT([update disabled])
2785 fi
2786
2787 AC_MSG_CHECKING([--disable-desktop-database-update argument])
2788 AC_ARG_ENABLE(desktop_database_update,
2789 [ --disable-desktop-database-update update disabled],
2790 [],
2791 [enable_desktop_database_update="yes"])
2792 if test "$enable_desktop_database_update" = "yes"; then
2793 AC_MSG_RESULT([not set])
2794 AC_PATH_PROG(UPDATE_DESKTOP_DATABASE,[update-desktop-database],no)
2795 if test "x$UPDATE_DESKTOP_DATABASE" = "xno" ; then
2796 AC_MSG_RESULT([not found in PATH.])
2797 fi
2798 else
2799 AC_MSG_RESULT([update disabled])
2800 fi
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002801fi
2802AC_SUBST(GLIB_COMPILE_RESOURCES)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002803AC_SUBST(GRESOURCE_SRC)
2804AC_SUBST(GRESOURCE_OBJ)
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002805AC_SUBST(GTK_UPDATE_ICON_CACHE)
2806AC_SUBST(UPDATE_DESKTOP_DATABASE)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002807
Bram Moolenaar071d4272004-06-13 20:20:40 +00002808dnl Check for Motif include files location.
2809dnl The LAST one found is used, this makes the highest version to be used,
2810dnl e.g. when Motif1.2 and Motif2.0 are both present.
2811
2812if test -z "$SKIP_MOTIF"; then
2813 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"
2814 dnl Remove "-I" from before $GUI_INC_LOC if it's there
2815 GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`"
2816
2817 AC_MSG_CHECKING(for location of Motif GUI includes)
2818 gui_includes="`echo $x_includes|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC"
2819 GUI_INC_LOC=
2820 for try in $gui_includes; do
2821 if test -f "$try/Xm/Xm.h"; then
2822 GUI_INC_LOC=$try
2823 fi
2824 done
2825 if test -n "$GUI_INC_LOC"; then
2826 if test "$GUI_INC_LOC" = /usr/include; then
2827 GUI_INC_LOC=
2828 AC_MSG_RESULT(in default path)
2829 else
2830 AC_MSG_RESULT($GUI_INC_LOC)
2831 fi
2832 else
2833 AC_MSG_RESULT(<not found>)
2834 SKIP_MOTIF=YES
2835 fi
2836fi
2837
2838dnl Check for Motif library files location. In the same order as the include
2839dnl files, to avoid a mixup if several versions are present
2840
2841if test -z "$SKIP_MOTIF"; then
2842 AC_MSG_CHECKING(--with-motif-lib argument)
2843 AC_ARG_WITH(motif-lib,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002844 [ --with-motif-lib=STRING Library for Motif ],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002845 [ MOTIF_LIBNAME="${withval}" ] )
2846
2847 if test -n "$MOTIF_LIBNAME"; then
2848 AC_MSG_RESULT($MOTIF_LIBNAME)
2849 GUI_LIB_LOC=
2850 else
2851 AC_MSG_RESULT(no)
2852
2853 dnl Remove "-L" from before $GUI_LIB_LOC if it's there
2854 GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
2855
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002856 dnl Ubuntu has libXm.so in /usr/lib/i386-linux-gnu and elsewhere. The
2857 dnl linker will figure out which one to use, we only check if one exists.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002858 AC_MSG_CHECKING(for location of Motif GUI libs)
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002859 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 +00002860 GUI_LIB_LOC=
2861 for try in $gui_libs; do
Bram Moolenaar325b7a22004-07-05 15:58:32 +00002862 for libtry in "$try"/libXm.a "$try"/libXm.so* "$try"/libXm.sl "$try"/libXm.dylib; do
Bram Moolenaar071d4272004-06-13 20:20:40 +00002863 if test -f "$libtry"; then
2864 GUI_LIB_LOC=$try
2865 fi
2866 done
2867 done
2868 if test -n "$GUI_LIB_LOC"; then
2869 dnl Remove /usr/lib, it causes trouble on some systems
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002870 if test "$GUI_LIB_LOC" = /usr/lib \
2871 -o "$GUI_LIB_LOC" = /usr/lib/i386-linux-gnu \
2872 -o "$GUI_LIB_LOC" = /usr/lib/x86_64-linux-gnu; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002873 GUI_LIB_LOC=
2874 AC_MSG_RESULT(in default path)
2875 else
2876 if test -n "$GUI_LIB_LOC"; then
2877 AC_MSG_RESULT($GUI_LIB_LOC)
2878 if test "`(uname) 2>/dev/null`" = SunOS &&
2879 uname -r | grep '^5' >/dev/null; then
2880 GUI_LIB_LOC="$GUI_LIB_LOC -R $GUI_LIB_LOC"
2881 fi
2882 fi
2883 fi
2884 MOTIF_LIBNAME=-lXm
2885 else
2886 AC_MSG_RESULT(<not found>)
2887 SKIP_MOTIF=YES
2888 fi
2889 fi
2890fi
2891
2892if test -z "$SKIP_MOTIF"; then
2893 SKIP_ATHENA=YES
2894 SKIP_NEXTAW=YES
2895 GUITYPE=MOTIF
2896 AC_SUBST(MOTIF_LIBNAME)
2897fi
2898
2899dnl Check if the Athena files can be found
2900
2901GUI_X_LIBS=
2902
2903if test -z "$SKIP_ATHENA"; then
2904 AC_MSG_CHECKING(if Athena header files can be found)
2905 cflags_save=$CFLAGS
2906 CFLAGS="$CFLAGS $X_CFLAGS"
2907 AC_TRY_COMPILE([
2908#include <X11/Intrinsic.h>
2909#include <X11/Xaw/Paned.h>], ,
2910 AC_MSG_RESULT(yes),
2911 AC_MSG_RESULT(no); SKIP_ATHENA=YES )
2912 CFLAGS=$cflags_save
2913fi
2914
2915if test -z "$SKIP_ATHENA"; then
2916 GUITYPE=ATHENA
2917fi
2918
2919if test -z "$SKIP_NEXTAW"; then
2920 AC_MSG_CHECKING(if neXtaw header files can be found)
2921 cflags_save=$CFLAGS
2922 CFLAGS="$CFLAGS $X_CFLAGS"
2923 AC_TRY_COMPILE([
2924#include <X11/Intrinsic.h>
2925#include <X11/neXtaw/Paned.h>], ,
2926 AC_MSG_RESULT(yes),
2927 AC_MSG_RESULT(no); SKIP_NEXTAW=YES )
2928 CFLAGS=$cflags_save
2929fi
2930
2931if test -z "$SKIP_NEXTAW"; then
2932 GUITYPE=NEXTAW
2933fi
2934
2935if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
2936 dnl Prepend -I and -L to $GUI_INC_LOC and $GUI_LIB_LOC if not empty
2937 dnl Avoid adding it when it twice
2938 if test -n "$GUI_INC_LOC"; then
2939 GUI_INC_LOC=-I"`echo $GUI_INC_LOC|sed 's%-I%%'`"
2940 fi
2941 if test -n "$GUI_LIB_LOC"; then
2942 GUI_LIB_LOC=-L"`echo $GUI_LIB_LOC|sed 's%-L%%'`"
2943 fi
2944
2945 dnl Check for -lXext and then for -lXmu
2946 ldflags_save=$LDFLAGS
2947 LDFLAGS="$X_LIBS $LDFLAGS"
2948 AC_CHECK_LIB(Xext, XShapeQueryExtension, [GUI_X_LIBS="-lXext"],,
2949 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2950 dnl For Solaris we need -lw and -ldl before linking with -lXmu works.
2951 AC_CHECK_LIB(w, wslen, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lw"],,
2952 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2953 AC_CHECK_LIB(dl, dlsym, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldl"],,
2954 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2955 AC_CHECK_LIB(Xmu, XmuCreateStippledPixmap, [GUI_X_LIBS="-lXmu $GUI_X_LIBS"],,
2956 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2957 if test -z "$SKIP_MOTIF"; then
2958 AC_CHECK_LIB(Xp, XpEndJob, [GUI_X_LIBS="-lXp $GUI_X_LIBS"],,
2959 [$GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2960 fi
2961 LDFLAGS=$ldflags_save
2962
2963 dnl Execute xmkmf to figure out if -DNARROWPROTO is needed.
2964 AC_MSG_CHECKING(for extra X11 defines)
2965 NARROW_PROTO=
2966 rm -fr conftestdir
2967 if mkdir conftestdir; then
2968 cd conftestdir
2969 cat > Imakefile <<'EOF'
2970acfindx:
2971 @echo 'NARROW_PROTO="${PROTO_DEFINES}"'
2972EOF
2973 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
2974 eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
2975 fi
2976 cd ..
2977 rm -fr conftestdir
2978 fi
2979 if test -z "$NARROW_PROTO"; then
2980 AC_MSG_RESULT(no)
2981 else
2982 AC_MSG_RESULT($NARROW_PROTO)
2983 fi
2984 AC_SUBST(NARROW_PROTO)
2985fi
2986
2987dnl Look for XSMP support - but don't necessarily restrict it to X11 GUIs
2988dnl use the X11 include path
2989if test "$enable_xsmp" = "yes"; then
2990 cppflags_save=$CPPFLAGS
2991 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2992 AC_CHECK_HEADERS(X11/SM/SMlib.h)
2993 CPPFLAGS=$cppflags_save
2994fi
2995
2996
Bram Moolenaar98921892016-02-23 17:14:37 +01002997if 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 +00002998 dnl Check for X11/xpm.h and X11/Sunkeysym.h with the GUI include path
2999 cppflags_save=$CPPFLAGS
3000 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3001 AC_CHECK_HEADERS(X11/xpm.h X11/Sunkeysym.h)
3002
3003 dnl automatically disable XIM when XIMtext isn't in X11/Xlib.h
3004 if test ! "$enable_xim" = "no"; then
3005 AC_MSG_CHECKING(for XIMText in X11/Xlib.h)
3006 AC_EGREP_CPP(XIMText, [#include <X11/Xlib.h>],
3007 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +02003008 AC_MSG_RESULT(no; xim has been disabled); enable_xim="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00003009 fi
3010 CPPFLAGS=$cppflags_save
3011
3012 dnl automatically enable XIM when hangul input isn't enabled
3013 if test "$enable_xim" = "auto" -a "$enable_hangulinput" != "yes" \
3014 -a "x$GUITYPE" != "xNONE" ; then
3015 AC_MSG_RESULT(X GUI selected; xim has been enabled)
3016 enable_xim="yes"
3017 fi
3018fi
3019
3020if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
3021 cppflags_save=$CPPFLAGS
3022 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00003023dnl Xmu/Editres.h may exist but can only be used after including Intrinsic.h
3024 AC_MSG_CHECKING([for X11/Xmu/Editres.h])
3025 AC_TRY_COMPILE([
3026#include <X11/Intrinsic.h>
3027#include <X11/Xmu/Editres.h>],
3028 [int i; i = 0;],
3029 AC_MSG_RESULT(yes)
3030 AC_DEFINE(HAVE_X11_XMU_EDITRES_H),
3031 AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003032 CPPFLAGS=$cppflags_save
3033fi
3034
3035dnl Only use the Xm directory when compiling Motif, don't use it for Athena
3036if test -z "$SKIP_MOTIF"; then
3037 cppflags_save=$CPPFLAGS
3038 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003039 if test "$zOSUnix" = "yes"; then
3040 xmheader="Xm/Xm.h"
3041 else
3042 xmheader="Xm/Xm.h Xm/XpmP.h Xm/JoinSideT.h Xm/TraitP.h Xm/Manager.h
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02003043 Xm/UnhighlightT.h Xm/Notebook.h"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003044 fi
3045 AC_CHECK_HEADERS($xmheader)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003046
Bram Moolenaar77c19352012-06-13 19:19:41 +02003047 if test "x$ac_cv_header_Xm_XpmP_h" = "xyes"; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003048 dnl Solaris uses XpmAttributes_21, very annoying.
3049 AC_MSG_CHECKING([for XpmAttributes_21 in Xm/XpmP.h])
3050 AC_TRY_COMPILE([#include <Xm/XpmP.h>], [XpmAttributes_21 attr;],
3051 AC_MSG_RESULT(yes); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes_21),
3052 AC_MSG_RESULT(no); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
3053 )
3054 else
Bram Moolenaar57657d82006-04-21 22:12:41 +00003055 AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003056 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003057 CPPFLAGS=$cppflags_save
3058fi
3059
3060if test "x$GUITYPE" = "xNONE" -a "$enable_xim" = "yes"; then
3061 AC_MSG_RESULT(no GUI selected; xim has been disabled)
3062 enable_xim="no"
3063fi
3064if test "x$GUITYPE" = "xNONE" -a "$enable_fontset" = "yes"; then
3065 AC_MSG_RESULT(no GUI selected; fontset has been disabled)
3066 enable_fontset="no"
3067fi
Bram Moolenaar182c5be2010-06-25 05:37:59 +02003068if test "x$GUITYPE:$enable_fontset" = "xGTK:yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003069 AC_MSG_RESULT(GTK+ 2 GUI selected; fontset has been disabled)
3070 enable_fontset="no"
3071fi
3072
Bram Moolenaar071d4272004-06-13 20:20:40 +00003073if test -z "$SKIP_PHOTON"; then
3074 GUITYPE=PHOTONGUI
3075fi
3076
3077AC_SUBST(GUI_INC_LOC)
3078AC_SUBST(GUI_LIB_LOC)
3079AC_SUBST(GUITYPE)
3080AC_SUBST(GUI_X_LIBS)
3081
3082if test "$enable_workshop" = "yes" -a -n "$SKIP_MOTIF"; then
3083 AC_MSG_ERROR([cannot use workshop without Motif])
3084fi
3085
3086dnl defining FEAT_XIM and FEAT_XFONTSET is delayed, so that they can be disabled
3087if test "$enable_xim" = "yes"; then
3088 AC_DEFINE(FEAT_XIM)
3089fi
3090if test "$enable_fontset" = "yes"; then
3091 AC_DEFINE(FEAT_XFONTSET)
3092fi
3093
3094
3095dnl ---------------------------------------------------------------------------
3096dnl end of GUI-checking
3097dnl ---------------------------------------------------------------------------
3098
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003099AC_MSG_CHECKING([for /proc link to executable])
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003100if test -L "/proc/self/exe"; then
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003101 dnl Linux
3102 AC_MSG_RESULT([/proc/self/exe])
3103 AC_DEFINE(PROC_EXE_LINK, "/proc/self/exe")
3104elif test -L "/proc/self/path/a.out"; then
3105 dnl Solaris
3106 AC_MSG_RESULT([/proc/self/path/a.out])
3107 AC_DEFINE(PROC_EXE_LINK, "/proc/self/path/a.out")
3108elif test -L "/proc/curproc/file"; then
3109 dnl FreeBSD
3110 AC_MSG_RESULT([/proc/curproc/file])
3111 AC_DEFINE(PROC_EXE_LINK, "/proc/curproc/file")
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003112else
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003113 AC_MSG_RESULT(no)
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003114fi
3115
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003116dnl Check for Cygwin, which needs an extra source file if not using X11
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003117AC_MSG_CHECKING(for CYGWIN or MSYS environment)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003118case `uname` in
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003119 CYGWIN*|MSYS*) CYGWIN=yes; AC_MSG_RESULT(yes)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003120 AC_MSG_CHECKING(for CYGWIN clipboard support)
3121 if test "x$with_x" = "xno" ; then
3122 OS_EXTRA_SRC=winclip.c; OS_EXTRA_OBJ=objects/winclip.o
3123 AC_MSG_RESULT(yes)
3124 AC_DEFINE(FEAT_CYGWIN_WIN32_CLIPBOARD)
3125 else
3126 AC_MSG_RESULT(no - using X11)
3127 fi ;;
3128
3129 *) CYGWIN=no; AC_MSG_RESULT(no);;
3130esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00003131
3132dnl Only really enable hangul input when GUI and XFONTSET are available
3133if test "$enable_hangulinput" = "yes"; then
3134 if test "x$GUITYPE" = "xNONE"; then
3135 AC_MSG_RESULT(no GUI selected; hangul input has been disabled)
3136 enable_hangulinput=no
3137 else
3138 AC_DEFINE(FEAT_HANGULIN)
3139 HANGULIN_SRC=hangulin.c
3140 AC_SUBST(HANGULIN_SRC)
3141 HANGULIN_OBJ=objects/hangulin.o
3142 AC_SUBST(HANGULIN_OBJ)
3143 fi
3144fi
3145
3146dnl Checks for libraries and include files.
3147
Bram Moolenaar446cb832008-06-24 21:56:24 +00003148AC_CACHE_CHECK([whether toupper is broken], [vim_cv_toupper_broken],
3149 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003150 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003151#include "confdefs.h"
3152#include <ctype.h>
3153#if STDC_HEADERS
3154# include <stdlib.h>
3155# include <stddef.h>
3156#endif
3157main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003158 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003159 vim_cv_toupper_broken=yes
3160 ],[
3161 vim_cv_toupper_broken=no
3162 ],[
3163 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_toupper_broken')
3164 ])])
3165
3166if test "x$vim_cv_toupper_broken" = "xyes" ; then
3167 AC_DEFINE(BROKEN_TOUPPER)
3168fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003169
3170AC_MSG_CHECKING(whether __DATE__ and __TIME__ work)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003171AC_TRY_COMPILE([#include <stdio.h>], [printf("(" __DATE__ " " __TIME__ ")");],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003172 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DATE_TIME),
3173 AC_MSG_RESULT(no))
3174
Bram Moolenaar0c094b92009-05-14 20:20:33 +00003175AC_MSG_CHECKING(whether __attribute__((unused)) is allowed)
3176AC_TRY_COMPILE([#include <stdio.h>], [int x __attribute__((unused));],
3177 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ATTRIBUTE_UNUSED),
3178 AC_MSG_RESULT(no))
3179
Bram Moolenaar071d4272004-06-13 20:20:40 +00003180dnl Checks for header files.
3181AC_CHECK_HEADER(elf.h, HAS_ELF=1)
3182dnl AC_CHECK_HEADER(dwarf.h, SVR4=1)
3183if test "$HAS_ELF" = 1; then
3184 AC_CHECK_LIB(elf, main)
3185fi
3186
3187AC_HEADER_DIRENT
3188
Bram Moolenaar071d4272004-06-13 20:20:40 +00003189dnl If sys/wait.h is not found it might still exist but not be POSIX
3190dnl compliant. In that case we define HAVE_UNION_WAIT (for NeXT)
3191if test $ac_cv_header_sys_wait_h = no; then
3192 AC_MSG_CHECKING([for sys/wait.h that defines union wait])
3193 AC_TRY_COMPILE([#include <sys/wait.h>],
3194 [union wait xx, yy; xx = yy],
3195 AC_MSG_RESULT(yes)
3196 AC_DEFINE(HAVE_SYS_WAIT_H)
3197 AC_DEFINE(HAVE_UNION_WAIT),
3198 AC_MSG_RESULT(no))
3199fi
3200
Bram Moolenaar779a7752016-01-30 23:26:34 +01003201AC_CHECK_HEADERS(stdint.h stdlib.h string.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003202 sys/select.h sys/utsname.h termcap.h fcntl.h \
3203 sgtty.h sys/ioctl.h sys/time.h sys/types.h \
3204 termio.h iconv.h inttypes.h langinfo.h math.h \
3205 unistd.h stropts.h errno.h sys/resource.h \
3206 sys/systeminfo.h locale.h sys/stream.h termios.h \
3207 libc.h sys/statfs.h poll.h sys/poll.h pwd.h \
3208 utime.h sys/param.h libintl.h libgen.h \
3209 util/debug.h util/msg18n.h frame.h sys/acl.h \
3210 sys/access.h sys/sysinfo.h wchar.h wctype.h)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003211
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003212dnl sys/ptem.h depends on sys/stream.h on Solaris
3213AC_CHECK_HEADERS(sys/ptem.h, [], [],
3214[#if defined HAVE_SYS_STREAM_H
3215# include <sys/stream.h>
3216#endif])
3217
Bram Moolenaar32f31b12009-05-21 13:20:59 +00003218dnl sys/sysctl.h depends on sys/param.h on OpenBSD
3219AC_CHECK_HEADERS(sys/sysctl.h, [], [],
3220[#if defined HAVE_SYS_PARAM_H
3221# include <sys/param.h>
3222#endif])
3223
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003224
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003225dnl pthread_np.h may exist but can only be used after including pthread.h
3226AC_MSG_CHECKING([for pthread_np.h])
3227AC_TRY_COMPILE([
3228#include <pthread.h>
3229#include <pthread_np.h>],
3230 [int i; i = 0;],
3231 AC_MSG_RESULT(yes)
3232 AC_DEFINE(HAVE_PTHREAD_NP_H),
3233 AC_MSG_RESULT(no))
3234
Bram Moolenaare344bea2005-09-01 20:46:49 +00003235AC_CHECK_HEADERS(strings.h)
Bram Moolenaard0573012017-10-28 21:11:06 +02003236if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00003237 dnl The strings.h file on OS/X contains a warning and nothing useful.
3238 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3239else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003240
3241dnl Check if strings.h and string.h can both be included when defined.
3242AC_MSG_CHECKING([if strings.h can be included after string.h])
3243cppflags_save=$CPPFLAGS
3244CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3245AC_TRY_COMPILE([
3246#if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO)
3247# define _NO_PROTO /* like in os_unix.h, causes conflict for AIX (Winn) */
3248 /* but don't do it on AIX 5.1 (Uribarri) */
3249#endif
3250#ifdef HAVE_XM_XM_H
3251# include <Xm/Xm.h> /* This breaks it for HP-UX 11 (Squassabia) */
3252#endif
3253#ifdef HAVE_STRING_H
3254# include <string.h>
3255#endif
3256#if defined(HAVE_STRINGS_H)
3257# include <strings.h>
3258#endif
3259 ], [int i; i = 0;],
3260 AC_MSG_RESULT(yes),
3261 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3262 AC_MSG_RESULT(no))
3263CPPFLAGS=$cppflags_save
Bram Moolenaar9372a112005-12-06 19:59:18 +00003264fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003265
3266dnl Checks for typedefs, structures, and compiler characteristics.
3267AC_PROG_GCC_TRADITIONAL
3268AC_C_CONST
Bram Moolenaar76243bd2009-03-02 01:47:02 +00003269AC_C_VOLATILE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003270AC_TYPE_MODE_T
3271AC_TYPE_OFF_T
3272AC_TYPE_PID_T
3273AC_TYPE_SIZE_T
3274AC_TYPE_UID_T
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003275AC_TYPE_UINT32_T
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003276
Bram Moolenaar071d4272004-06-13 20:20:40 +00003277AC_HEADER_TIME
3278AC_CHECK_TYPE(ino_t, long)
3279AC_CHECK_TYPE(dev_t, unsigned)
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003280AC_C_BIGENDIAN(,,,)
Bram Moolenaar136f29a2016-02-27 20:14:15 +01003281AC_C_INLINE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003282
3283AC_MSG_CHECKING(for rlim_t)
3284if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
3285 AC_MSG_RESULT([(cached) $ac_cv_type_rlim_t])
3286else
3287 AC_EGREP_CPP(dnl
3288changequote(<<,>>)dnl
3289<<(^|[^a-zA-Z_0-9])rlim_t[^a-zA-Z_0-9]>>dnl
3290changequote([,]),
3291 [
3292#include <sys/types.h>
3293#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003294# include <stdlib.h>
3295# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003296#endif
3297#ifdef HAVE_SYS_RESOURCE_H
Bram Moolenaar446cb832008-06-24 21:56:24 +00003298# include <sys/resource.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003299#endif
3300 ], ac_cv_type_rlim_t=yes, ac_cv_type_rlim_t=no)
3301 AC_MSG_RESULT($ac_cv_type_rlim_t)
3302fi
3303if test $ac_cv_type_rlim_t = no; then
3304 cat >> confdefs.h <<\EOF
3305#define rlim_t unsigned long
3306EOF
3307fi
3308
3309AC_MSG_CHECKING(for stack_t)
3310if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then
3311 AC_MSG_RESULT([(cached) $ac_cv_type_stack_t])
3312else
3313 AC_EGREP_CPP(stack_t,
3314 [
3315#include <sys/types.h>
3316#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003317# include <stdlib.h>
3318# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003319#endif
3320#include <signal.h>
3321 ], ac_cv_type_stack_t=yes, ac_cv_type_stack_t=no)
3322 AC_MSG_RESULT($ac_cv_type_stack_t)
3323fi
3324if test $ac_cv_type_stack_t = no; then
3325 cat >> confdefs.h <<\EOF
3326#define stack_t struct sigaltstack
3327EOF
3328fi
3329
3330dnl BSDI uses ss_base while others use ss_sp for the stack pointer.
3331AC_MSG_CHECKING(whether stack_t has an ss_base field)
3332AC_TRY_COMPILE([
3333#include <sys/types.h>
3334#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003335# include <stdlib.h>
3336# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003337#endif
3338#include <signal.h>
3339#include "confdefs.h"
3340 ], [stack_t sigstk; sigstk.ss_base = 0; ],
3341 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SS_BASE),
3342 AC_MSG_RESULT(no))
3343
3344olibs="$LIBS"
3345AC_MSG_CHECKING(--with-tlib argument)
3346AC_ARG_WITH(tlib, [ --with-tlib=library terminal library to be used ],)
3347if test -n "$with_tlib"; then
3348 AC_MSG_RESULT($with_tlib)
3349 LIBS="$LIBS -l$with_tlib"
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003350 AC_MSG_CHECKING(for linking with $with_tlib library)
3351 AC_TRY_LINK([], [], AC_MSG_RESULT(OK), AC_MSG_ERROR(FAILED))
3352 dnl Need to check for tgetent() below.
3353 olibs="$LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003354else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003355 AC_MSG_RESULT([empty: automatic terminal library selection])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003356 dnl On HP-UX 10.10 termcap or termlib should be used instead of
3357 dnl curses, because curses is much slower.
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003358 dnl Newer versions of ncurses are preferred over anything, except
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02003359 dnl when tinfo has been split off, it contains all we need.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003360 dnl Older versions of ncurses have bugs, get a new one!
3361 dnl Digital Unix (OSF1) should use curses (Ronald Schild).
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00003362 dnl On SCO Openserver should prefer termlib (Roger Cornelius).
Bram Moolenaar071d4272004-06-13 20:20:40 +00003363 case "`uname -s 2>/dev/null`" in
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003364 OSF1|SCO_SV) tlibs="tinfo ncurses curses termlib termcap";;
3365 *) tlibs="tinfo ncurses termlib termcap curses";;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003366 esac
3367 for libname in $tlibs; do
3368 AC_CHECK_LIB(${libname}, tgetent,,)
3369 if test "x$olibs" != "x$LIBS"; then
3370 dnl It's possible that a library is found but it doesn't work
3371 dnl e.g., shared library that cannot be found
3372 dnl compile and run a test program to be sure
3373 AC_TRY_RUN([
3374#ifdef HAVE_TERMCAP_H
3375# include <termcap.h>
3376#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003377#if STDC_HEADERS
3378# include <stdlib.h>
3379# include <stddef.h>
3380#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003381main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }],
3382 res="OK", res="FAIL", res="FAIL")
3383 if test "$res" = "OK"; then
3384 break
3385 fi
3386 AC_MSG_RESULT($libname library is not usable)
3387 LIBS="$olibs"
3388 fi
3389 done
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003390 if test "x$olibs" = "x$LIBS"; then
3391 AC_MSG_RESULT(no terminal library found)
3392 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003393fi
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003394
3395if test "x$olibs" = "x$LIBS"; then
3396 AC_MSG_CHECKING([for tgetent()])
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00003397 AC_TRY_LINK([],
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003398 [char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");],
3399 AC_MSG_RESULT(yes),
3400 AC_MSG_ERROR([NOT FOUND!
3401 You need to install a terminal library; for example ncurses.
3402 Or specify the name of the library with --with-tlib.]))
3403fi
3404
Bram Moolenaar446cb832008-06-24 21:56:24 +00003405AC_CACHE_CHECK([whether we talk terminfo], [vim_cv_terminfo],
3406 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003407 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003408#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003409#ifdef HAVE_TERMCAP_H
3410# include <termcap.h>
3411#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003412#ifdef HAVE_STRING_H
3413# include <string.h>
3414#endif
3415#if STDC_HEADERS
3416# include <stdlib.h>
3417# include <stddef.h>
3418#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003419main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003420{char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003421 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003422 vim_cv_terminfo=no
3423 ],[
3424 vim_cv_terminfo=yes
3425 ],[
3426 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_terminfo')
3427 ])
3428 ])
3429
3430if test "x$vim_cv_terminfo" = "xyes" ; then
3431 AC_DEFINE(TERMINFO)
3432fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003433
Bram Moolenaara88254f2017-11-02 23:04:14 +01003434AC_CACHE_CHECK([what tgetent() returns for an unknown terminal], [vim_cv_tgetent],
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003435 [
3436 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003437#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003438#ifdef HAVE_TERMCAP_H
3439# include <termcap.h>
3440#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003441#if STDC_HEADERS
3442# include <stdlib.h>
3443# include <stddef.h>
3444#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003445main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003446{char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003447 ]])],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003448 vim_cv_tgetent=zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003449 ],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003450 vim_cv_tgetent=non-zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003451 ],[
3452 AC_MSG_ERROR(failed to compile test program.)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003453 ])
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003454 ])
3455
Bram Moolenaara88254f2017-11-02 23:04:14 +01003456if test "x$vim_cv_tgetent" = "xzero" ; then
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003457 AC_DEFINE(TGETENT_ZERO_ERR, 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003458fi
3459
3460AC_MSG_CHECKING(whether termcap.h contains ospeed)
3461AC_TRY_LINK([
3462#ifdef HAVE_TERMCAP_H
3463# include <termcap.h>
3464#endif
3465 ], [ospeed = 20000],
3466 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED),
3467 [AC_MSG_RESULT(no)
3468 AC_MSG_CHECKING(whether ospeed can be extern)
3469 AC_TRY_LINK([
3470#ifdef HAVE_TERMCAP_H
3471# include <termcap.h>
3472#endif
3473extern short ospeed;
3474 ], [ospeed = 20000],
3475 AC_MSG_RESULT(yes); AC_DEFINE(OSPEED_EXTERN),
3476 AC_MSG_RESULT(no))]
3477 )
3478
3479AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC])
3480AC_TRY_LINK([
3481#ifdef HAVE_TERMCAP_H
3482# include <termcap.h>
3483#endif
3484 ], [if (UP == 0 && BC == 0) PC = 1],
3485 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UP_BC_PC),
3486 [AC_MSG_RESULT(no)
3487 AC_MSG_CHECKING([whether UP, BC and PC can be extern])
3488 AC_TRY_LINK([
3489#ifdef HAVE_TERMCAP_H
3490# include <termcap.h>
3491#endif
3492extern char *UP, *BC, PC;
3493 ], [if (UP == 0 && BC == 0) PC = 1],
3494 AC_MSG_RESULT(yes); AC_DEFINE(UP_BC_PC_EXTERN),
3495 AC_MSG_RESULT(no))]
3496 )
3497
3498AC_MSG_CHECKING(whether tputs() uses outfuntype)
3499AC_TRY_COMPILE([
3500#ifdef HAVE_TERMCAP_H
3501# include <termcap.h>
3502#endif
3503 ], [extern int xx(); tputs("test", 1, (outfuntype)xx)],
3504 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OUTFUNTYPE),
3505 AC_MSG_RESULT(no))
3506
3507dnl On some SCO machines sys/select redefines struct timeval
3508AC_MSG_CHECKING([whether sys/select.h and sys/time.h may both be included])
3509AC_TRY_COMPILE([
3510#include <sys/types.h>
3511#include <sys/time.h>
3512#include <sys/select.h>], ,
3513 AC_MSG_RESULT(yes)
3514 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME),
3515 AC_MSG_RESULT(no))
3516
3517dnl AC_DECL_SYS_SIGLIST
3518
3519dnl Checks for pty.c (copied from screen) ==========================
3520AC_MSG_CHECKING(for /dev/ptc)
3521if test -r /dev/ptc; then
3522 AC_DEFINE(HAVE_DEV_PTC)
3523 AC_MSG_RESULT(yes)
3524else
3525 AC_MSG_RESULT(no)
3526fi
3527
3528AC_MSG_CHECKING(for SVR4 ptys)
3529if test -c /dev/ptmx ; then
3530 AC_TRY_LINK([], [ptsname(0);grantpt(0);unlockpt(0);],
3531 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SVR4_PTYS),
3532 AC_MSG_RESULT(no))
3533else
3534 AC_MSG_RESULT(no)
3535fi
3536
3537AC_MSG_CHECKING(for ptyranges)
3538if test -d /dev/ptym ; then
3539 pdir='/dev/ptym'
3540else
3541 pdir='/dev'
3542fi
3543dnl SCO uses ptyp%d
3544AC_EGREP_CPP(yes,
3545[#ifdef M_UNIX
3546 yes;
3547#endif
3548 ], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
3549dnl if test -c /dev/ptyp19; then
3550dnl ptys=`echo /dev/ptyp??`
3551dnl else
3552dnl ptys=`echo $pdir/pty??`
3553dnl fi
3554if test "$ptys" != "$pdir/pty??" ; then
3555 p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
3556 p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'`
3557 AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
3558 AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
3559 AC_MSG_RESULT([$p0 / $p1])
3560else
3561 AC_MSG_RESULT([don't know])
3562fi
3563
3564dnl **** pty mode/group handling ****
3565dnl
3566dnl support provided by Luke Mewburn <lm@rmit.edu.au>, 931222
Bram Moolenaar071d4272004-06-13 20:20:40 +00003567rm -f conftest_grp
Bram Moolenaar446cb832008-06-24 21:56:24 +00003568AC_CACHE_CHECK([default tty permissions/group], [vim_cv_tty_group],
3569 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003570 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003571#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003572#include <sys/types.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003573#if STDC_HEADERS
3574# include <stdlib.h>
3575# include <stddef.h>
3576#endif
3577#ifdef HAVE_UNISTD_H
3578#include <unistd.h>
3579#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003580#include <sys/stat.h>
3581#include <stdio.h>
3582main()
3583{
3584 struct stat sb;
3585 char *x,*ttyname();
3586 int om, m;
3587 FILE *fp;
3588
3589 if (!(x = ttyname(0))) exit(1);
3590 if (stat(x, &sb)) exit(1);
3591 om = sb.st_mode;
3592 if (om & 002) exit(0);
3593 m = system("mesg y");
3594 if (m == -1 || m == 127) exit(1);
3595 if (stat(x, &sb)) exit(1);
3596 m = sb.st_mode;
3597 if (chmod(x, om)) exit(1);
3598 if (m & 002) exit(0);
3599 if (sb.st_gid == getgid()) exit(1);
3600 if (!(fp=fopen("conftest_grp", "w")))
3601 exit(1);
3602 fprintf(fp, "%d\n", sb.st_gid);
3603 fclose(fp);
3604 exit(0);
3605}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003606 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003607 if test -f conftest_grp; then
3608 vim_cv_tty_group=`cat conftest_grp`
3609 if test "x$vim_cv_tty_mode" = "x" ; then
3610 vim_cv_tty_mode=0620
3611 fi
3612 AC_MSG_RESULT([pty mode: $vim_cv_tty_mode, group: $vim_cv_tty_group])
3613 else
3614 vim_cv_tty_group=world
Bram Moolenaar72951072009-12-02 16:58:33 +00003615 AC_MSG_RESULT([ptys are world accessible])
Bram Moolenaar446cb832008-06-24 21:56:24 +00003616 fi
3617 ],[
3618 vim_cv_tty_group=world
Bram Moolenaar72951072009-12-02 16:58:33 +00003619 AC_MSG_RESULT([can't determine - assume ptys are world accessible])
Bram Moolenaar446cb832008-06-24 21:56:24 +00003620 ],[
3621 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_tty_group' and 'vim_cv_tty_mode')
3622 ])
3623 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003624rm -f conftest_grp
3625
Bram Moolenaar446cb832008-06-24 21:56:24 +00003626if test "x$vim_cv_tty_group" != "xworld" ; then
3627 AC_DEFINE_UNQUOTED(PTYGROUP,$vim_cv_tty_group)
3628 if test "x$vim_cv_tty_mode" = "x" ; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02003629 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 +00003630 else
3631 AC_DEFINE(PTYMODE, 0620)
3632 fi
3633fi
3634
Bram Moolenaar071d4272004-06-13 20:20:40 +00003635dnl Checks for library functions. ===================================
3636
3637AC_TYPE_SIGNAL
3638
3639dnl find out what to use at the end of a signal function
3640if test $ac_cv_type_signal = void; then
3641 AC_DEFINE(SIGRETURN, [return])
3642else
3643 AC_DEFINE(SIGRETURN, [return 0])
3644fi
3645
3646dnl check if struct sigcontext is defined (used for SGI only)
3647AC_MSG_CHECKING(for struct sigcontext)
3648AC_TRY_COMPILE([
3649#include <signal.h>
3650test_sig()
3651{
3652 struct sigcontext *scont;
3653 scont = (struct sigcontext *)0;
3654 return 1;
3655} ], ,
3656 AC_MSG_RESULT(yes)
3657 AC_DEFINE(HAVE_SIGCONTEXT),
3658 AC_MSG_RESULT(no))
3659
3660dnl tricky stuff: try to find out if getcwd() is implemented with
3661dnl system("sh -c pwd")
Bram Moolenaar446cb832008-06-24 21:56:24 +00003662AC_CACHE_CHECK([getcwd implementation is broken], [vim_cv_getcwd_broken],
3663 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003664 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003665#include "confdefs.h"
3666#ifdef HAVE_UNISTD_H
3667#include <unistd.h>
3668#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003669char *dagger[] = { "IFS=pwd", 0 };
3670main()
3671{
3672 char buffer[500];
3673 extern char **environ;
3674 environ = dagger;
3675 return getcwd(buffer, 500) ? 0 : 1;
Bram Moolenaar446cb832008-06-24 21:56:24 +00003676}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003677 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003678 vim_cv_getcwd_broken=no
3679 ],[
3680 vim_cv_getcwd_broken=yes
3681 ],[
3682 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_getcwd_broken')
3683 ])
3684 ])
3685
3686if test "x$vim_cv_getcwd_broken" = "xyes" ; then
3687 AC_DEFINE(BAD_GETCWD)
3688fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003689
Bram Moolenaar25153e12010-02-24 14:47:08 +01003690dnl Check for functions in one big call, to reduce the size of configure.
3691dnl Can only be used for functions that do not require any include.
Bram Moolenaarcd142e32017-11-16 17:03:45 +01003692AC_CHECK_FUNCS(fchdir fchown fchmod fsync getcwd getpseudotty \
Bram Moolenaarb129a442016-12-01 17:25:20 +01003693 getpwent getpwnam getpwuid getrlimit gettimeofday getwd lstat \
Bram Moolenaareaf03392009-11-17 11:08:52 +00003694 memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
Bram Moolenaar2fcf6682017-03-11 20:03:42 +01003695 getpgid setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
Bram Moolenaarbb09ceb2016-10-18 16:27:23 +02003696 sigprocmask sigvec strcasecmp strerror strftime stricmp strncasecmp \
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00003697 strnicmp strpbrk strtol tgetent towlower towupper iswupper \
Bram Moolenaarcd142e32017-11-16 17:03:45 +01003698 usleep utime utimes mblen ftruncate)
Bram Moolenaar25153e12010-02-24 14:47:08 +01003699AC_FUNC_FSEEKO
Bram Moolenaar071d4272004-06-13 20:20:40 +00003700
Bram Moolenaar317fd3a2010-05-07 16:05:55 +02003701dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when
3702dnl appropriate, so that off_t is 64 bits when needed.
3703AC_SYS_LARGEFILE
3704
Bram Moolenaar071d4272004-06-13 20:20:40 +00003705dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible
3706AC_MSG_CHECKING(for st_blksize)
3707AC_TRY_COMPILE(
3708[#include <sys/types.h>
3709#include <sys/stat.h>],
3710[ struct stat st;
3711 int n;
3712
3713 stat("/", &st);
3714 n = (int)st.st_blksize;],
3715 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ST_BLKSIZE),
3716 AC_MSG_RESULT(no))
3717
Bram Moolenaar446cb832008-06-24 21:56:24 +00003718AC_CACHE_CHECK([whether stat() ignores a trailing slash], [vim_cv_stat_ignores_slash],
3719 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003720 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003721#include "confdefs.h"
3722#if STDC_HEADERS
3723# include <stdlib.h>
3724# include <stddef.h>
3725#endif
3726#include <sys/types.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003727#include <sys/stat.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003728main() {struct stat st; exit(stat("configure/", &st) != 0); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003729 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003730 vim_cv_stat_ignores_slash=yes
3731 ],[
3732 vim_cv_stat_ignores_slash=no
3733 ],[
3734 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_stat_ignores_slash')
3735 ])
3736 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003737
Bram Moolenaar446cb832008-06-24 21:56:24 +00003738if test "x$vim_cv_stat_ignores_slash" = "xyes" ; then
3739 AC_DEFINE(STAT_IGNORES_SLASH)
3740fi
3741
Bram Moolenaar071d4272004-06-13 20:20:40 +00003742dnl Link with iconv for charset translation, if not found without library.
3743dnl check for iconv() requires including iconv.h
3744dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
3745dnl has been installed.
3746AC_MSG_CHECKING(for iconv_open())
3747save_LIBS="$LIBS"
3748LIBS="$LIBS -liconv"
3749AC_TRY_LINK([
3750#ifdef HAVE_ICONV_H
3751# include <iconv.h>
3752#endif
3753 ], [iconv_open("fr", "to");],
3754 AC_MSG_RESULT(yes; with -liconv); AC_DEFINE(HAVE_ICONV),
3755 LIBS="$save_LIBS"
3756 AC_TRY_LINK([
3757#ifdef HAVE_ICONV_H
3758# include <iconv.h>
3759#endif
3760 ], [iconv_open("fr", "to");],
3761 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ICONV),
3762 AC_MSG_RESULT(no)))
3763
3764
3765AC_MSG_CHECKING(for nl_langinfo(CODESET))
3766AC_TRY_LINK([
3767#ifdef HAVE_LANGINFO_H
3768# include <langinfo.h>
3769#endif
3770], [char *cs = nl_langinfo(CODESET);],
3771 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET),
3772 AC_MSG_RESULT(no))
3773
Bram Moolenaar446cb832008-06-24 21:56:24 +00003774dnl Need various functions for floating point support. Only enable
3775dnl floating point when they are all present.
3776AC_CHECK_LIB(m, strtod)
3777AC_MSG_CHECKING([for strtod() and other floating point functions])
3778AC_TRY_LINK([
3779#ifdef HAVE_MATH_H
3780# include <math.h>
3781#endif
3782#if STDC_HEADERS
3783# include <stdlib.h>
3784# include <stddef.h>
3785#endif
3786], [char *s; double d;
3787 d = strtod("1.1", &s);
3788 d = fabs(1.11);
3789 d = ceil(1.11);
3790 d = floor(1.11);
3791 d = log10(1.11);
3792 d = pow(1.11, 2.22);
3793 d = sqrt(1.11);
3794 d = sin(1.11);
3795 d = cos(1.11);
3796 d = atan(1.11);
3797 ],
3798 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT_FUNCS),
3799 AC_MSG_RESULT(no))
3800
Bram Moolenaara6b89762016-02-29 21:38:26 +01003801dnl isinf() and isnan() need to include header files and may need -lm.
3802AC_MSG_CHECKING([for isinf()])
3803AC_TRY_LINK([
3804#ifdef HAVE_MATH_H
3805# include <math.h>
3806#endif
3807#if STDC_HEADERS
3808# include <stdlib.h>
3809# include <stddef.h>
3810#endif
3811], [int r = isinf(1.11); ],
3812 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISINF),
3813 AC_MSG_RESULT(no))
3814
3815AC_MSG_CHECKING([for isnan()])
3816AC_TRY_LINK([
3817#ifdef HAVE_MATH_H
3818# include <math.h>
3819#endif
3820#if STDC_HEADERS
3821# include <stdlib.h>
3822# include <stddef.h>
3823#endif
3824], [int r = isnan(1.11); ],
3825 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISNAN),
3826 AC_MSG_RESULT(no))
3827
Bram Moolenaar071d4272004-06-13 20:20:40 +00003828dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI
3829dnl when -lacl works, also try to use -lattr (required for Debian).
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003830dnl On Solaris, use the acl_get/set functions in libsec, if present.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003831AC_MSG_CHECKING(--disable-acl argument)
3832AC_ARG_ENABLE(acl,
Bram Moolenaard6d30422018-01-28 22:48:55 +01003833 [ --disable-acl No check for ACL support.],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003834 , [enable_acl="yes"])
3835if test "$enable_acl" = "yes"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01003836 AC_MSG_RESULT(no)
3837 AC_CHECK_LIB(posix1e, acl_get_file, [LIBS="$LIBS -lposix1e"],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003838 AC_CHECK_LIB(acl, acl_get_file, [LIBS="$LIBS -lacl"
3839 AC_CHECK_LIB(attr, fgetxattr, LIBS="$LIBS -lattr",,)],,),)
3840
Bram Moolenaard6d30422018-01-28 22:48:55 +01003841 AC_MSG_CHECKING(for POSIX ACL support)
3842 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003843#include <sys/types.h>
3844#ifdef HAVE_SYS_ACL_H
3845# include <sys/acl.h>
3846#endif
3847acl_t acl;], [acl = acl_get_file("foo", ACL_TYPE_ACCESS);
3848 acl_set_file("foo", ACL_TYPE_ACCESS, acl);
3849 acl_free(acl);],
3850 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_ACL),
3851 AC_MSG_RESULT(no))
3852
Bram Moolenaard6d30422018-01-28 22:48:55 +01003853 AC_CHECK_LIB(sec, acl_get, [LIBS="$LIBS -lsec"; AC_DEFINE(HAVE_SOLARIS_ZFS_ACL)],
3854 AC_MSG_CHECKING(for Solaris ACL support)
3855 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003856#ifdef HAVE_SYS_ACL_H
3857# include <sys/acl.h>
3858#endif], [acl("foo", GETACLCNT, 0, NULL);
3859 ],
3860 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOLARIS_ACL),
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003861 AC_MSG_RESULT(no)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003862
Bram Moolenaard6d30422018-01-28 22:48:55 +01003863 AC_MSG_CHECKING(for AIX ACL support)
3864 AC_TRY_LINK([
Bram Moolenaar446cb832008-06-24 21:56:24 +00003865#if STDC_HEADERS
3866# include <stdlib.h>
3867# include <stddef.h>
3868#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003869#ifdef HAVE_SYS_ACL_H
3870# include <sys/acl.h>
3871#endif
3872#ifdef HAVE_SYS_ACCESS_H
3873# include <sys/access.h>
3874#endif
3875#define _ALL_SOURCE
3876
3877#include <sys/stat.h>
3878
3879int aclsize;
3880struct acl *aclent;], [aclsize = sizeof(struct acl);
3881 aclent = (void *)malloc(aclsize);
3882 statacl("foo", STX_NORMAL, aclent, aclsize);
3883 ],
3884 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_AIX_ACL),
3885 AC_MSG_RESULT(no))
3886else
3887 AC_MSG_RESULT(yes)
3888fi
3889
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02003890if test "x$GTK_CFLAGS" != "x"; then
3891 dnl pango_shape_full() is new, fall back to pango_shape().
3892 AC_MSG_CHECKING(for pango_shape_full)
3893 ac_save_CFLAGS="$CFLAGS"
3894 ac_save_LIBS="$LIBS"
3895 CFLAGS="$CFLAGS $GTK_CFLAGS"
3896 LIBS="$LIBS $GTK_LIBS"
Bram Moolenaar5325b9b2015-09-09 20:27:02 +02003897 AC_TRY_LINK(
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02003898 [#include <gtk/gtk.h>],
3899 [ pango_shape_full(NULL, 0, NULL, 0, NULL, NULL); ],
3900 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_PANGO_SHAPE_FULL),
3901 AC_MSG_RESULT(no))
3902 CFLAGS="$ac_save_CFLAGS"
3903 LIBS="$ac_save_LIBS"
3904fi
3905
Bram Moolenaar071d4272004-06-13 20:20:40 +00003906AC_MSG_CHECKING(--disable-gpm argument)
3907AC_ARG_ENABLE(gpm,
3908 [ --disable-gpm Don't use gpm (Linux mouse daemon).], ,
3909 [enable_gpm="yes"])
3910
3911if test "$enable_gpm" = "yes"; then
3912 AC_MSG_RESULT(no)
3913 dnl Checking if gpm support can be compiled
3914 AC_CACHE_CHECK([for gpm], vi_cv_have_gpm,
3915 [olibs="$LIBS" ; LIBS="-lgpm"]
3916 AC_TRY_LINK(
3917 [#include <gpm.h>
3918 #include <linux/keyboard.h>],
3919 [Gpm_GetLibVersion(NULL);],
3920 dnl Configure defines HAVE_GPM, if it is defined feature.h defines
3921 dnl FEAT_MOUSE_GPM if mouse support is included
3922 [vi_cv_have_gpm=yes],
3923 [vi_cv_have_gpm=no])
3924 [LIBS="$olibs"]
3925 )
3926 if test $vi_cv_have_gpm = yes; then
3927 LIBS="$LIBS -lgpm"
3928 AC_DEFINE(HAVE_GPM)
3929 fi
3930else
3931 AC_MSG_RESULT(yes)
3932fi
3933
Bram Moolenaar446cb832008-06-24 21:56:24 +00003934AC_MSG_CHECKING(--disable-sysmouse argument)
3935AC_ARG_ENABLE(sysmouse,
Bram Moolenaar8008b632017-07-18 21:33:20 +02003936 [ --disable-sysmouse Don't use sysmouse (mouse in *BSD console).], ,
Bram Moolenaar446cb832008-06-24 21:56:24 +00003937 [enable_sysmouse="yes"])
3938
3939if test "$enable_sysmouse" = "yes"; then
3940 AC_MSG_RESULT(no)
3941 dnl Checking if sysmouse support can be compiled
3942 dnl Configure defines HAVE_SYSMOUSE, if it is defined feature.h
3943 dnl defines FEAT_SYSMOUSE if mouse support is included
3944 AC_CACHE_CHECK([for sysmouse], vi_cv_have_sysmouse,
3945 AC_TRY_LINK(
3946 [#include <sys/consio.h>
3947 #include <signal.h>
3948 #include <sys/fbio.h>],
3949 [struct mouse_info mouse;
3950 mouse.operation = MOUSE_MODE;
3951 mouse.operation = MOUSE_SHOW;
3952 mouse.u.mode.mode = 0;
3953 mouse.u.mode.signal = SIGUSR2;],
3954 [vi_cv_have_sysmouse=yes],
3955 [vi_cv_have_sysmouse=no])
3956 )
3957 if test $vi_cv_have_sysmouse = yes; then
3958 AC_DEFINE(HAVE_SYSMOUSE)
3959 fi
3960else
3961 AC_MSG_RESULT(yes)
3962fi
3963
Bram Moolenaarf05da212009-11-17 16:13:15 +00003964dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
3965AC_MSG_CHECKING(for FD_CLOEXEC)
3966AC_TRY_COMPILE(
3967[#if HAVE_FCNTL_H
3968# include <fcntl.h>
3969#endif],
3970[ int flag = FD_CLOEXEC;],
3971 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
3972 AC_MSG_RESULT(not usable))
3973
Bram Moolenaar071d4272004-06-13 20:20:40 +00003974dnl rename needs to be checked separately to work on Nextstep with cc
3975AC_MSG_CHECKING(for rename)
3976AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
3977 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
3978 AC_MSG_RESULT(no))
3979
3980dnl sysctl() may exist but not the arguments we use
3981AC_MSG_CHECKING(for sysctl)
3982AC_TRY_COMPILE(
3983[#include <sys/types.h>
3984#include <sys/sysctl.h>],
3985[ int mib[2], r;
3986 size_t len;
3987
3988 mib[0] = CTL_HW;
3989 mib[1] = HW_USERMEM;
3990 len = sizeof(r);
3991 (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
3992 ],
3993 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL),
3994 AC_MSG_RESULT(not usable))
3995
3996dnl sysinfo() may exist but not be Linux compatible
3997AC_MSG_CHECKING(for sysinfo)
3998AC_TRY_COMPILE(
3999[#include <sys/types.h>
4000#include <sys/sysinfo.h>],
4001[ struct sysinfo sinfo;
4002 int t;
4003
4004 (void)sysinfo(&sinfo);
4005 t = sinfo.totalram;
4006 ],
4007 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
4008 AC_MSG_RESULT(not usable))
4009
Bram Moolenaar914572a2007-05-01 11:37:47 +00004010dnl struct sysinfo may have the mem_unit field or not
4011AC_MSG_CHECKING(for sysinfo.mem_unit)
4012AC_TRY_COMPILE(
4013[#include <sys/types.h>
4014#include <sys/sysinfo.h>],
4015[ struct sysinfo sinfo;
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02004016 sinfo.mem_unit = 1;
Bram Moolenaar914572a2007-05-01 11:37:47 +00004017 ],
4018 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_MEM_UNIT),
4019 AC_MSG_RESULT(no))
4020
Bram Moolenaar071d4272004-06-13 20:20:40 +00004021dnl sysconf() may exist but not support what we want to use
4022AC_MSG_CHECKING(for sysconf)
4023AC_TRY_COMPILE(
4024[#include <unistd.h>],
4025[ (void)sysconf(_SC_PAGESIZE);
4026 (void)sysconf(_SC_PHYS_PAGES);
4027 ],
4028 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
4029 AC_MSG_RESULT(not usable))
4030
Bram Moolenaar914703b2010-05-31 21:59:46 +02004031AC_CHECK_SIZEOF([int])
4032AC_CHECK_SIZEOF([long])
4033AC_CHECK_SIZEOF([time_t])
4034AC_CHECK_SIZEOF([off_t])
Bram Moolenaar644fdff2010-05-30 13:26:21 +02004035
Bram Moolenaara2aa31a2014-02-23 22:52:40 +01004036dnl Use different names to avoid clashing with other header files.
4037AC_DEFINE_UNQUOTED(VIM_SIZEOF_INT, [$ac_cv_sizeof_int])
4038AC_DEFINE_UNQUOTED(VIM_SIZEOF_LONG, [$ac_cv_sizeof_long])
4039
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004040dnl Make sure that uint32_t is really 32 bits unsigned.
4041AC_MSG_CHECKING([uint32_t is 32 bits])
4042AC_TRY_RUN([
4043#ifdef HAVE_STDINT_H
4044# include <stdint.h>
4045#endif
4046#ifdef HAVE_INTTYPES_H
4047# include <inttypes.h>
4048#endif
4049main() {
4050 uint32_t nr1 = (uint32_t)-1;
4051 uint32_t nr2 = (uint32_t)0xffffffffUL;
4052 if (sizeof(uint32_t) != 4 || nr1 != 0xffffffffUL || nr2 + 1 != 0) exit(1);
4053 exit(0);
4054}],
4055AC_MSG_RESULT(ok),
4056AC_MSG_ERROR([WRONG! uint32_t not defined correctly.]),
Bram Moolenaar323cb952011-12-14 19:22:34 +01004057AC_MSG_WARN([cannot check uint32_t when cross-compiling.]))
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004058
Bram Moolenaar446cb832008-06-24 21:56:24 +00004059dnl Check for memmove() before bcopy(), makes memmove() be used when both are
4060dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
4061
Bram Moolenaar071d4272004-06-13 20:20:40 +00004062[bcopy_test_prog='
Bram Moolenaar446cb832008-06-24 21:56:24 +00004063#include "confdefs.h"
4064#ifdef HAVE_STRING_H
4065# include <string.h>
4066#endif
4067#if STDC_HEADERS
4068# include <stdlib.h>
4069# include <stddef.h>
4070#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004071main() {
4072 char buf[10];
4073 strcpy(buf, "abcdefghi");
4074 mch_memmove(buf, buf + 2, 3);
4075 if (strncmp(buf, "ababcf", 6))
4076 exit(1);
4077 strcpy(buf, "abcdefghi");
4078 mch_memmove(buf + 2, buf, 3);
4079 if (strncmp(buf, "cdedef", 6))
4080 exit(1);
4081 exit(0); /* libc version works properly. */
4082}']
4083
Bram Moolenaar446cb832008-06-24 21:56:24 +00004084AC_CACHE_CHECK([whether memmove handles overlaps],[vim_cv_memmove_handles_overlap],
4085 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004086 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 +00004087 [
4088 vim_cv_memmove_handles_overlap=yes
4089 ],[
4090 vim_cv_memmove_handles_overlap=no
4091 ],[
4092 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memmove_handles_overlap')
4093 ])
4094 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00004095
Bram Moolenaar446cb832008-06-24 21:56:24 +00004096if test "x$vim_cv_memmove_handles_overlap" = "xyes" ; then
4097 AC_DEFINE(USEMEMMOVE)
4098else
4099 AC_CACHE_CHECK([whether bcopy handles overlaps],[vim_cv_bcopy_handles_overlap],
4100 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004101 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 +00004102 [
4103 vim_cv_bcopy_handles_overlap=yes
4104 ],[
4105 vim_cv_bcopy_handles_overlap=no
4106 ],[
4107 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_bcopy_handles_overlap')
4108 ])
4109 ])
4110
4111 if test "x$vim_cv_bcopy_handles_overlap" = "xyes" ; then
4112 AC_DEFINE(USEBCOPY)
4113 else
4114 AC_CACHE_CHECK([whether memcpy handles overlaps],[vim_cv_memcpy_handles_overlap],
4115 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004116 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 +00004117 [
4118 vim_cv_memcpy_handles_overlap=yes
4119 ],[
4120 vim_cv_memcpy_handles_overlap=no
4121 ],[
4122 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memcpy_handles_overlap')
4123 ])
4124 ])
4125
4126 if test "x$vim_cv_memcpy_handles_overlap" = "xyes" ; then
4127 AC_DEFINE(USEMEMCPY)
4128 fi
4129 fi
4130fi
4131
Bram Moolenaar071d4272004-06-13 20:20:40 +00004132
4133dnl Check for multibyte locale functions
4134dnl Find out if _Xsetlocale() is supported by libX11.
4135dnl Check if X_LOCALE should be defined.
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004136if test "x$with_x" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004137 cflags_save=$CFLAGS
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004138 libs_save=$LIBS
4139 LIBS="$LIBS $X_LIBS $GUI_LIB_LOC $GUI_X_LIBS $X_PRE_LIBS $X_LIB $X_EXTRA_LIBS"
4140 CFLAGS="$CFLAGS $X_CFLAGS"
4141
4142 AC_MSG_CHECKING(whether X_LOCALE needed)
4143 AC_TRY_COMPILE([#include <X11/Xlocale.h>],,
4144 AC_TRY_LINK_FUNC([_Xsetlocale], [AC_MSG_RESULT(yes)
4145 AC_DEFINE(X_LOCALE)], AC_MSG_RESULT(no)),
4146 AC_MSG_RESULT(no))
4147
4148 AC_MSG_CHECKING(whether Xutf8SetWMProperties() can be used)
4149 AC_TRY_LINK_FUNC([Xutf8SetWMProperties], [AC_MSG_RESULT(yes)
4150 AC_DEFINE(HAVE_XUTF8SETWMPROPERTIES)], AC_MSG_RESULT(no))
4151
Bram Moolenaar071d4272004-06-13 20:20:40 +00004152 CFLAGS=$cflags_save
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004153 LIBS=$libs_save
Bram Moolenaar071d4272004-06-13 20:20:40 +00004154fi
4155
4156dnl Link with xpg4, it is said to make Korean locale working
4157AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,)
4158
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004159dnl Check how we can run ctags. Default to "ctags" when nothing works.
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02004160dnl Use --version to detect Exuberant ctags (preferred)
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004161dnl Add --fields=+S to get function signatures for omni completion.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004162dnl -t for typedefs (many ctags have this)
4163dnl -s for static functions (Elvis ctags only?)
4164dnl -v for variables. Dangerous, most ctags take this for 'vgrind style'.
4165dnl -i+m to test for older Exuberant ctags
4166AC_MSG_CHECKING(how to create tags)
4167test -f tags && mv tags tags.save
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004168if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004169 TAGPRG="ctags -I INIT+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004170elif (eval exctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
4171 TAGPRG="exctags -I INIT+ --fields=+S"
4172elif (eval exuberant-ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
4173 TAGPRG="exuberant-ctags -I INIT+ --fields=+S"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004174else
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004175 TAGPRG="ctags"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004176 (eval etags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags"
4177 (eval etags -c /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags -c"
4178 (eval ctags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags"
4179 (eval ctags -t /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -t"
4180 (eval ctags -ts /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -ts"
4181 (eval ctags -tvs /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -tvs"
4182 (eval ctags -i+m /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -i+m"
4183fi
4184test -f tags.save && mv tags.save tags
4185AC_MSG_RESULT($TAGPRG) AC_SUBST(TAGPRG)
4186
4187dnl Check how we can run man with a section number
4188AC_MSG_CHECKING(how to run man with a section nr)
4189MANDEF="man"
Bram Moolenaar8b131502008-02-13 09:28:19 +00004190(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 +00004191AC_MSG_RESULT($MANDEF)
4192if test "$MANDEF" = "man -s"; then
4193 AC_DEFINE(USEMAN_S)
4194fi
4195
4196dnl Check if gettext() is working and if it needs -lintl
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004197dnl We take care to base this on an empty LIBS: on some systems libelf would be
4198dnl in LIBS and implicitly take along libintl. The final LIBS would then not
4199dnl contain libintl, and the link step would fail due to -Wl,--as-needed.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004200AC_MSG_CHECKING(--disable-nls argument)
4201AC_ARG_ENABLE(nls,
4202 [ --disable-nls Don't support NLS (gettext()).], ,
4203 [enable_nls="yes"])
4204
4205if test "$enable_nls" = "yes"; then
4206 AC_MSG_RESULT(no)
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00004207
4208 INSTALL_LANGS=install-languages
4209 AC_SUBST(INSTALL_LANGS)
4210 INSTALL_TOOL_LANGS=install-tool-languages
4211 AC_SUBST(INSTALL_TOOL_LANGS)
4212
Bram Moolenaar071d4272004-06-13 20:20:40 +00004213 AC_CHECK_PROG(MSGFMT, msgfmt, msgfmt, )
4214 AC_MSG_CHECKING([for NLS])
4215 if test -f po/Makefile; then
4216 have_gettext="no"
4217 if test -n "$MSGFMT"; then
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004218 olibs=$LIBS
4219 LIBS=""
Bram Moolenaar071d4272004-06-13 20:20:40 +00004220 AC_TRY_LINK(
4221 [#include <libintl.h>],
4222 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004223 AC_MSG_RESULT([gettext() works]); have_gettext="yes"; LIBS=$olibs,
4224 LIBS="-lintl"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004225 AC_TRY_LINK(
4226 [#include <libintl.h>],
4227 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004228 AC_MSG_RESULT([gettext() works with -lintl]); have_gettext="yes";
4229 LIBS="$olibs -lintl",
Bram Moolenaar071d4272004-06-13 20:20:40 +00004230 AC_MSG_RESULT([gettext() doesn't work]);
4231 LIBS=$olibs))
4232 else
4233 AC_MSG_RESULT([msgfmt not found - disabled]);
4234 fi
Bram Moolenaar278eb582014-07-30 13:22:52 +02004235 if test $have_gettext = "yes" -a "x$features" != "xtiny" -a "x$features" != "xsmall"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004236 AC_DEFINE(HAVE_GETTEXT)
4237 MAKEMO=yes
4238 AC_SUBST(MAKEMO)
4239 dnl this was added in GNU gettext 0.10.36
4240 AC_CHECK_FUNCS(bind_textdomain_codeset)
4241 dnl _nl_msg_cat_cntr is required for GNU gettext
4242 AC_MSG_CHECKING([for _nl_msg_cat_cntr])
4243 AC_TRY_LINK(
4244 [#include <libintl.h>
4245 extern int _nl_msg_cat_cntr;],
4246 [++_nl_msg_cat_cntr;],
4247 AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_NL_MSG_CAT_CNTR),
4248 AC_MSG_RESULT([no]))
4249 fi
4250 else
4251 AC_MSG_RESULT([no "po/Makefile" - disabled]);
4252 fi
4253else
4254 AC_MSG_RESULT(yes)
4255fi
4256
4257dnl Check for dynamic linking loader
4258AC_CHECK_HEADER(dlfcn.h, DLL=dlfcn.h, [AC_CHECK_HEADER(dl.h, DLL=dl.h)])
4259if test x${DLL} = xdlfcn.h; then
4260 AC_DEFINE(HAVE_DLFCN_H, 1, [ Define if we have dlfcn.h. ])
4261 AC_MSG_CHECKING([for dlopen()])
4262 AC_TRY_LINK(,[
4263 extern void* dlopen();
4264 dlopen();
4265 ],
4266 AC_MSG_RESULT(yes);
4267 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4268 AC_MSG_RESULT(no);
4269 AC_MSG_CHECKING([for dlopen() in -ldl])
4270 olibs=$LIBS
4271 LIBS="$LIBS -ldl"
4272 AC_TRY_LINK(,[
4273 extern void* dlopen();
4274 dlopen();
4275 ],
4276 AC_MSG_RESULT(yes);
4277 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4278 AC_MSG_RESULT(no);
4279 LIBS=$olibs))
4280 dnl ReliantUNIX has dlopen() in libc but everything else in libdl
4281 dnl ick :-)
4282 AC_MSG_CHECKING([for dlsym()])
4283 AC_TRY_LINK(,[
4284 extern void* dlsym();
4285 dlsym();
4286 ],
4287 AC_MSG_RESULT(yes);
4288 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4289 AC_MSG_RESULT(no);
4290 AC_MSG_CHECKING([for dlsym() in -ldl])
4291 olibs=$LIBS
4292 LIBS="$LIBS -ldl"
4293 AC_TRY_LINK(,[
4294 extern void* dlsym();
4295 dlsym();
4296 ],
4297 AC_MSG_RESULT(yes);
4298 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4299 AC_MSG_RESULT(no);
4300 LIBS=$olibs))
4301elif test x${DLL} = xdl.h; then
4302 AC_DEFINE(HAVE_DL_H, 1, [ Define if we have dl.h. ])
4303 AC_MSG_CHECKING([for shl_load()])
4304 AC_TRY_LINK(,[
4305 extern void* shl_load();
4306 shl_load();
4307 ],
4308 AC_MSG_RESULT(yes);
4309 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4310 AC_MSG_RESULT(no);
4311 AC_MSG_CHECKING([for shl_load() in -ldld])
4312 olibs=$LIBS
4313 LIBS="$LIBS -ldld"
4314 AC_TRY_LINK(,[
4315 extern void* shl_load();
4316 shl_load();
4317 ],
4318 AC_MSG_RESULT(yes);
4319 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4320 AC_MSG_RESULT(no);
4321 LIBS=$olibs))
4322fi
4323AC_CHECK_HEADERS(setjmp.h)
4324
Bram Moolenaard0573012017-10-28 21:11:06 +02004325if test "x$MACOS_X" = "xyes" -a -n "$PERL"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004326 dnl -ldl must come after DynaLoader.a
4327 if echo $LIBS | grep -e '-ldl' >/dev/null; then
4328 LIBS=`echo $LIBS | sed s/-ldl//`
4329 PERL_LIBS="$PERL_LIBS -ldl"
4330 fi
4331fi
4332
Bram Moolenaard0573012017-10-28 21:11:06 +02004333if test "$MACOS_X" = "yes"; then
4334 AC_MSG_CHECKING([whether we need macOS frameworks])
4335 if test "$GUITYPE" = "CARBONGUI"; then
4336 AC_MSG_RESULT([yes, we need Carbon])
4337 LIBS="$LIBS -framework Carbon"
4338 elif test "$MACOS_X_DARWIN" = "yes"; then
4339 if test "$features" = "tiny"; then
4340 dnl Since no FEAT_CLIPBOARD, no longer need for os_macosx.m.
4341 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_macosx.m++'`
4342 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_macosx.o++'`
4343 if test "$enable_multibyte" = "yes"; then
4344 AC_MSG_RESULT([yes, we need CoreServices])
4345 LIBS="$LIBS -framework CoreServices"
4346 else
4347 dnl Since no FEAT_MBYTE, no longer need for os_mac_conv.c.
4348 AC_MSG_RESULT([no])
4349 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_mac_conv.c++'`
4350 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_mac_conv.o++'`
4351 CPPFLAGS=`echo "$CPPFLAGS" | sed -e 's+-DMACOS_X_DARWIN++'`
4352 fi
4353 else
4354 AC_MSG_RESULT([yes, we need AppKit])
4355 LIBS="$LIBS -framework AppKit"
4356 if test "$features" = "small" -a "$enable_multibyte" = "no"; then
4357 dnl Since FEAT_CLIPBOARD is to be defined in vim.h for FEAT_SMALL, define
4358 dnl FEAT_MBYTE in order not to compromise the interoperability of the
4359 dnl clipboard.
4360 AC_MSG_NOTICE([+multi_byte will be set in favor of +clipboard])
4361 enable_multibyte=yes
4362 AC_DEFINE(FEAT_MBYTE)
4363 fi
4364 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004365 else
Bram Moolenaard0573012017-10-28 21:11:06 +02004366 AC_MSG_RESULT([no])
Bram Moolenaar3437b912013-07-03 19:52:53 +02004367 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004368fi
Bram Moolenaar164fca32010-07-14 13:58:07 +02004369if test "x$MACARCH" = "xboth" && test "x$GUITYPE" = "xCARBONGUI"; then
Bram Moolenaar595a7be2010-03-10 16:28:12 +01004370 LDFLAGS="$LDFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +00004371fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004372
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004373dnl gcc 3.1 changed the meaning of -MM. The only solution appears to be to
4374dnl use "-isystem" instead of "-I" for all non-Vim include dirs.
4375dnl But only when making dependencies, cproto and lint don't take "-isystem".
Bram Moolenaar32466aa2006-02-24 23:53:04 +00004376dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
4377dnl the number before the version number.
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004378DEPEND_CFLAGS_FILTER=
4379if test "$GCC" = yes; then
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004380 AC_MSG_CHECKING(for GCC 3 or later)
Bram Moolenaar2217cae2006-03-25 21:55:52 +00004381 gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]]\)\..*$/\1/g'`
Bram Moolenaarf740b292006-02-16 22:11:02 +00004382 if test "$gccmajor" -gt "2"; then
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004383 DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004384 AC_MSG_RESULT(yes)
4385 else
4386 AC_MSG_RESULT(no)
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004387 fi
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004388 dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
4389 dnl declared as char x[1] but actually longer. Introduced in gcc 4.0.
Bram Moolenaar56d1db32009-12-16 16:14:51 +00004390 dnl Also remove duplicate _FORTIFY_SOURCE arguments.
Bram Moolenaaraeabe052011-12-08 15:17:34 +01004391 dnl And undefine it first to avoid a warning.
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004392 AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
4393 if test "$gccmajor" -gt "3"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02004394 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 +00004395 AC_MSG_RESULT(yes)
4396 else
4397 AC_MSG_RESULT(no)
4398 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +00004399fi
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004400AC_SUBST(DEPEND_CFLAGS_FILTER)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004401
Bram Moolenaarec0557f2018-01-31 14:41:37 +01004402dnl On some systems AC_SYS_LARGEFILE determines that -D_FILE_OFFSET_BITS=64
4403dnl isn't required, but the CFLAGS for some of the libraries we're using
4404dnl include the define. Since the define changes the size of some datatypes
4405dnl (e.g. ino_t and off_t), all of Vim's modules must be compiled with a
4406dnl consistent value. It's therefore safest to force the use of the define
4407dnl if it's present in any of the *_CFLAGS variables.
4408AC_MSG_CHECKING(whether we need to force -D_FILE_OFFSET_BITS=64)
Bram Moolenaar9ce42132018-04-11 22:19:36 +02004409if 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 +01004410 AC_MSG_RESULT(yes)
4411 AC_DEFINE(_FILE_OFFSET_BITS, 64)
4412else
4413 AC_MSG_RESULT(no)
4414fi
4415
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004416dnl link.sh tries to avoid overlinking in a hackish way.
4417dnl At least GNU ld supports --as-needed which provides the same functionality
4418dnl at linker level. Let's use it.
4419AC_MSG_CHECKING(linker --as-needed support)
4420LINK_AS_NEEDED=
4421# Check if linker supports --as-needed and --no-as-needed options
4422if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02004423 LDFLAGS=`echo "$LDFLAGS" | sed -e 's/ *-Wl,--as-needed//g' | sed -e 's/$/ -Wl,--as-needed/'`
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004424 LINK_AS_NEEDED=yes
4425fi
4426if test "$LINK_AS_NEEDED" = yes; then
4427 AC_MSG_RESULT(yes)
4428else
4429 AC_MSG_RESULT(no)
4430fi
4431AC_SUBST(LINK_AS_NEEDED)
4432
Bram Moolenaar77c19352012-06-13 19:19:41 +02004433# IBM z/OS reset CFLAGS for config.mk
4434if test "$zOSUnix" = "yes"; then
4435 CFLAGS="-D_ALL_SOURCE -Wc,float\(ieee\),dll"
4436fi
4437
Bram Moolenaar071d4272004-06-13 20:20:40 +00004438dnl write output files
4439AC_OUTPUT(auto/config.mk:config.mk.in)
4440
4441dnl vim: set sw=2 tw=78 fo+=l: