blob: 1426e74c5e6309cfa0c4094a4503e9e16aa57c7e [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 Moolenaar22640082018-04-19 20:39:41 +020014AC_PROG_CC_C99 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:
Bram Moolenaar22640082018-04-19 20:39:41 +020033if test x"$ac_cv_prog_cc_c99" != xno; then
34 dnl If the compiler doesn't explicitly support C99, then check
35 dnl for the specific features Vim uses
36
37 AC_TYPE_LONG_LONG_INT
38 if test "$ac_cv_type_long_long_int" = no; then
39 AC_MSG_FAILURE([Compiler does not support long long int])
40 fi
41
42 AC_MSG_CHECKING([if the compiler supports trailing commas])
43 trailing_commas=no
44 AC_TRY_COMPILE([], [
45 enum {
46 one,
47 };],
48 [AC_MSG_RESULT(yes); trailing_commas=yes],
49 [AC_MSG_RESULT(no)])
50 if test "$trailing_commas" = no; then
51 AC_MSG_FAILURE([Compiler does not support trailing comma in enum])
52 fi
53
54 AC_MSG_CHECKING([if the compiler supports C++ comments])
55 slash_comments=no
56 AC_TRY_COMPILE([],
57 [// C++ comments?],
58 [AC_MSG_RESULT(yes); slash_comments=yes],
59 [AC_MSG_RESULT(no)])
60 if test "$slash_comments" = no; then
61 AC_MSG_FAILURE([Compiler does not support C++ comments])
62 fi
63fi
Bram Moolenaar561f8a52018-04-17 22:02:45 +020064
Bram Moolenaar8f1dde52020-06-05 23:16:29 +020065dnl If $SOURCE_DATE_EPOCH is present in the environment, use that as the
66dnl "compiled" timestamp in :version's output. Attempt to get the formatted
67dnl date using GNU date syntax, BSD date syntax, and finally falling back to
68dnl just using the current time.
69if test -n "$SOURCE_DATE_EPOCH"; then
70 DATE_FMT="%b %d %Y %H:%M:%S"
71 BUILD_DATE=$(LC_ALL=C date -u -d "@$SOURCE_DATE_EPOCH" "+$DATE_FMT" 2>/dev/null || LC_ALL=C date -u -r "$SOURCE_DATE_EPOCH" "+$DATE_FMT" 2>/dev/null || LC_ALL=C date -u "+$DATE_FMT")
72 AC_DEFINE_UNQUOTED(BUILD_DATE, ["$BUILD_DATE"])
73 BUILD_DATE_MSG=-"echo -e '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\nNOTE: build date/time is fixed: $BUILD_DATE\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='"
74 AC_SUBST(BUILD_DATE_MSG)
75fi
76
Bram Moolenaarf788a062011-12-14 20:51:25 +010077dnl Check for the flag that fails if stuff are missing.
78
79AC_MSG_CHECKING(--enable-fail-if-missing argument)
80AC_ARG_ENABLE(fail_if_missing,
81 [ --enable-fail-if-missing Fail if dependencies on additional features
82 specified on the command line are missing.],
83 [fail_if_missing="yes"],
84 [fail_if_missing="no"])
85AC_MSG_RESULT($fail_if_missing)
86
Bram Moolenaard2a05492018-07-27 22:35:15 +020087dnl Keep original value to check later.
88with_x_arg="$with_x"
89
Bram Moolenaar071d4272004-06-13 20:20:40 +000090dnl Set default value for CFLAGS if none is defined or it's empty
91if test -z "$CFLAGS"; then
92 CFLAGS="-O"
Bram Moolenaar4d8479b2021-01-31 14:36:06 +010093 test "$GCC" = yes && CFLAGS="-O2 -fno-strength-reduce -Wall -Wno-deprecated-declarations"
Bram Moolenaar071d4272004-06-13 20:20:40 +000094fi
95if test "$GCC" = yes; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +000096 dnl method that should work for nearly all versions
Bram Moolenaarc8836f72014-04-12 13:12:24 +020097 gccversion=`$CC -dumpversion`
Bram Moolenaar910f66f2006-04-05 20:41:53 +000098 if test "x$gccversion" = "x"; then
99 dnl old method; fall-back for when -dumpversion doesn't work
Bram Moolenaarc8836f72014-04-12 13:12:24 +0200100 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 +0000101 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +0000102 dnl version 4.0.1 was reported to cause trouble on Macintosh by Marcin Dalecki
103 if test "$gccversion" = "3.0.1" -o "$gccversion" = "3.0.2" -o "$gccversion" = "4.0.1"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000104 echo 'GCC [[34]].0.[[12]] has a bug in the optimizer, disabling "-O#"'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000105 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-O/'`
106 else
107 if test "$gccversion" = "3.1" -o "$gccversion" = "3.2" -o "$gccversion" = "3.2.1" && `echo "$CFLAGS" | grep -v fno-strength-reduce >/dev/null`; then
108 echo 'GCC 3.1 and 3.2 have a bug in the optimizer, adding "-fno-strength-reduce"'
109 CFLAGS="$CFLAGS -fno-strength-reduce"
110 fi
111 fi
112fi
113
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200114dnl clang-500.2.75 or around has abandoned -f[no-]strength-reduce and issues a
115dnl warning when that flag is passed to. Accordingly, adjust CFLAGS based on
116dnl the version number of the clang in use.
117dnl Note that this does not work to get the version of clang 3.1 or 3.2.
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100118AC_MSG_CHECKING(for clang version)
119CLANG_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 +0200120if test x"$CLANG_VERSION_STRING" != x"" ; then
121 CLANG_MAJOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*/\1/p'`
122 CLANG_MINOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/p'`
123 CLANG_REVISION=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)/\1/p'`
124 CLANG_VERSION=`expr $CLANG_MAJOR '*' 1000000 '+' $CLANG_MINOR '*' 1000 '+' $CLANG_REVISION`
125 AC_MSG_RESULT($CLANG_VERSION)
126 dnl If you find the same issue with versions earlier than 500.2.75,
127 dnl change the constant 500002075 below appropriately. To get the
128 dnl integer corresponding to a version number, refer to the
129 dnl definition of CLANG_VERSION above.
Bram Moolenaarebd211c2021-01-30 19:33:36 +0100130 dnl Clang 11 reports "11", assume Clang 10 and later work like this.
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100131 AC_MSG_CHECKING(if clang supports -fno-strength-reduce)
Bram Moolenaarebd211c2021-01-30 19:33:36 +0100132 if test "$CLANG_MAJOR" -ge 10 -o "$CLANG_VERSION" -ge 500002075 ; then
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100133 AC_MSG_RESULT(no)
134 CFLAGS=`echo "$CFLAGS" | sed -e 's/-fno-strength-reduce/ /'`
135 else
136 AC_MSG_RESULT(yes)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200137 fi
138else
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100139 AC_MSG_RESULT(N/A)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200140fi
141
Bram Moolenaar446cb832008-06-24 21:56:24 +0000142dnl If configure thinks we are cross compiling, there might be something
143dnl wrong with the CC or CFLAGS settings, give a useful warning message
Bram Moolenaar839e9542016-04-14 16:46:02 +0200144CROSS_COMPILING=
Bram Moolenaar071d4272004-06-13 20:20:40 +0000145if test "$cross_compiling" = yes; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000146 AC_MSG_RESULT([cannot compile a simple program; if not cross compiling check CC and CFLAGS])
Bram Moolenaar839e9542016-04-14 16:46:02 +0200147 CROSS_COMPILING=1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000148fi
Bram Moolenaar839e9542016-04-14 16:46:02 +0200149AC_SUBST(CROSS_COMPILING)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000150
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +0000151dnl gcc-cpp has the wonderful -MM option to produce nicer dependencies.
152dnl But gcc 3.1 changed the meaning! See near the end.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000153test "$GCC" = yes && CPP_MM=M; AC_SUBST(CPP_MM)
154
155if test -f ./toolcheck; then
156 AC_CHECKING(for buggy tools)
157 sh ./toolcheck 1>&AC_FD_MSG
158fi
159
160OS_EXTRA_SRC=""; OS_EXTRA_OBJ=""
161
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000162dnl When cross-compiling set $vim_cv_uname_output, $vim_cv_uname_r_output and
163dnl $vim_cv_uname_m_output to the desired value for the target system
164AC_MSG_CHECKING(uname)
165if test "x$vim_cv_uname_output" = "x" ; then
166 vim_cv_uname_output=`(uname) 2>/dev/null`
167 AC_MSG_RESULT($vim_cv_uname_output)
168else
169 AC_MSG_RESULT([$vim_cv_uname_output (cached)])
170fi
171
172AC_MSG_CHECKING(uname -r)
173if test "x$vim_cv_uname_r_output" = "x" ; then
174 vim_cv_uname_r_output=`(uname -r) 2>/dev/null`
175 AC_MSG_RESULT($vim_cv_uname_r_output)
176else
177 AC_MSG_RESULT([$vim_cv_uname_r_output (cached)])
178fi
179
180AC_MSG_CHECKING(uname -m)
181if test "x$vim_cv_uname_m_output" = "x" ; then
182 vim_cv_uname_m_output=`(uname -m) 2>/dev/null`
183 AC_MSG_RESULT($vim_cv_uname_m_output)
184else
185 AC_MSG_RESULT([$vim_cv_uname_m_output (cached)])
186fi
187
Bram Moolenaarb3f74062020-02-26 16:16:53 +0100188AC_MSG_CHECKING(for Haiku)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000189case $vim_cv_uname_output in
Bram Moolenaarb3f74062020-02-26 16:16:53 +0100190 Haiku) HAIKU=yes; AC_MSG_RESULT(yes);;
191 *) HAIKU=no; AC_MSG_RESULT(no);;
192esac
193
Bram Moolenaar071d4272004-06-13 20:20:40 +0000194dnl If QNX is found, assume we don't want to use Xphoton
195dnl unless it was specifically asked for (--with-x)
196AC_MSG_CHECKING(for QNX)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000197case $vim_cv_uname_output in
Bram Moolenaar071d4272004-06-13 20:20:40 +0000198 QNX) OS_EXTRA_SRC=os_qnx.c; OS_EXTRA_OBJ=objects/os_qnx.o
199 test -z "$with_x" && with_x=no
200 QNX=yes; AC_MSG_RESULT(yes);;
201 *) QNX=no; AC_MSG_RESULT(no);;
202esac
203
204dnl Check for Darwin and MacOS X
205dnl We do a check for MacOS X in the very beginning because there
206dnl are a lot of other things we need to change besides GUI stuff
Bram Moolenaar071d4272004-06-13 20:20:40 +0000207AC_MSG_CHECKING([for Darwin (Mac OS X)])
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000208if test "$vim_cv_uname_output" = Darwin; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000209 AC_MSG_RESULT(yes)
Bram Moolenaard0573012017-10-28 21:11:06 +0200210 MACOS_X=yes
Bram Moolenaar52ecaaa2018-05-12 21:38:13 +0200211 CPPFLAGS="$CPPFLAGS -DMACOS_X"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000212
213 AC_MSG_CHECKING(--disable-darwin argument)
214 AC_ARG_ENABLE(darwin,
215 [ --disable-darwin Disable Darwin (Mac OS X) support.],
216 , [enable_darwin="yes"])
217 if test "$enable_darwin" = "yes"; then
218 AC_MSG_RESULT(no)
219 AC_MSG_CHECKING(if Darwin files are there)
Bram Moolenaar164fca32010-07-14 13:58:07 +0200220 if test -f os_macosx.m; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000221 AC_MSG_RESULT(yes)
222 else
223 AC_MSG_RESULT([no, Darwin support disabled])
224 enable_darwin=no
225 fi
226 else
227 AC_MSG_RESULT([yes, Darwin support excluded])
228 fi
229
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000230 AC_MSG_CHECKING(--with-mac-arch argument)
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000231 AC_ARG_WITH(mac-arch, [ --with-mac-arch=ARCH current, intel, ppc or both],
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000232 MACARCH="$withval"; AC_MSG_RESULT($MACARCH),
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000233 MACARCH="current"; AC_MSG_RESULT(defaulting to $MACARCH))
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000234
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100235 AC_MSG_CHECKING(--with-developer-dir argument)
236 AC_ARG_WITH(developer-dir, [ --with-developer-dir=PATH use PATH as location for Xcode developer tools],
237 DEVELOPER_DIR="$withval"; AC_MSG_RESULT($DEVELOPER_DIR),
Bram Moolenaar32d03b32015-11-19 13:46:48 +0100238 AC_MSG_RESULT(not present))
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100239
240 if test "x$DEVELOPER_DIR" = "x"; then
241 AC_PATH_PROG(XCODE_SELECT, xcode-select)
242 if test "x$XCODE_SELECT" != "x"; then
243 AC_MSG_CHECKING(for developer dir using xcode-select)
244 DEVELOPER_DIR=`$XCODE_SELECT -print-path`
245 AC_MSG_RESULT([$DEVELOPER_DIR])
246 else
247 DEVELOPER_DIR=/Developer
248 fi
249 fi
250
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000251 if test "x$MACARCH" = "xboth"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000252 AC_MSG_CHECKING(for 10.4 universal SDK)
253 dnl There is a terrible inconsistency (but we appear to get away with it):
254 dnl $CFLAGS uses the 10.4u SDK library for the headers, while $CPPFLAGS
255 dnl doesn't, because "gcc -E" doesn't grok it. That means the configure
256 dnl tests using the preprocessor are actually done with the wrong header
257 dnl files. $LDFLAGS is set at the end, because configure uses it together
258 dnl with $CFLAGS and we can only have one -sysroot argument.
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000259 save_cppflags="$CPPFLAGS"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000260 save_cflags="$CFLAGS"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000261 save_ldflags="$LDFLAGS"
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100262 CFLAGS="$CFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000263 AC_TRY_LINK([ ], [ ],
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000264 AC_MSG_RESULT(found, will make universal binary),
265
266 AC_MSG_RESULT(not found)
Bram Moolenaar1f35bf92006-03-07 22:38:47 +0000267 CFLAGS="$save_cflags"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000268 AC_MSG_CHECKING(if Intel architecture is supported)
269 CPPFLAGS="$CPPFLAGS -arch i386"
270 LDFLAGS="$save_ldflags -arch i386"
271 AC_TRY_LINK([ ], [ ],
272 AC_MSG_RESULT(yes); MACARCH="intel",
273 AC_MSG_RESULT(no, using PowerPC)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000274 MACARCH="ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000275 CPPFLAGS="$save_cppflags -arch ppc"
276 LDFLAGS="$save_ldflags -arch ppc"))
277 elif test "x$MACARCH" = "xintel"; then
278 CPPFLAGS="$CPPFLAGS -arch intel"
279 LDFLAGS="$LDFLAGS -arch intel"
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000280 elif test "x$MACARCH" = "xppc"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000281 CPPFLAGS="$CPPFLAGS -arch ppc"
282 LDFLAGS="$LDFLAGS -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000283 fi
284
Bram Moolenaar071d4272004-06-13 20:20:40 +0000285 if test "$enable_darwin" = "yes"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200286 MACOS_X_DARWIN=yes
Bram Moolenaar164fca32010-07-14 13:58:07 +0200287 OS_EXTRA_SRC="os_macosx.m os_mac_conv.c";
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000288 OS_EXTRA_OBJ="objects/os_macosx.o objects/os_mac_conv.o"
Bram Moolenaar32466aa2006-02-24 23:53:04 +0000289 dnl TODO: use -arch i386 on Intel machines
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100290 dnl Removed -no-cpp-precomp, only for very old compilers.
Bram Moolenaard0573012017-10-28 21:11:06 +0200291 CPPFLAGS="$CPPFLAGS -DMACOS_X_DARWIN"
Bram Moolenaar040f9752020-08-11 23:08:48 +0200292
293 dnl Assume we don't want X11 unless it was specifically asked for
Bram Moolenaar0b40d082022-03-08 13:32:37 +0000294 dnl (--with-x) or Motif or GTK GUI is used.
295 if test -z "$with_x" -a "X$enable_gui" != Xmotif -a "X$enable_gui" != Xgtk2 -a "X$enable_gui" != Xgtk3; then
Bram Moolenaar040f9752020-08-11 23:08:48 +0200296 with_x=no
297 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000298 fi
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000299
Bram Moolenaardb552d602006-03-23 22:59:57 +0000300 dnl Avoid a bug with -O2 with gcc 4.0.1. Symptom: malloc() reports double
Bram Moolenaarfd2ac762006-03-01 22:09:21 +0000301 dnl free. This happens in expand_filename(), because the optimizer swaps
Bram Moolenaardb552d602006-03-23 22:59:57 +0000302 dnl two blocks of code, both using "repl", that can't be swapped.
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000303 if test "$MACARCH" = "intel" -o "$MACARCH" = "both"; then
304 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-Oz/'`
305 fi
306
Bram Moolenaar071d4272004-06-13 20:20:40 +0000307else
308 AC_MSG_RESULT(no)
309fi
310
Bram Moolenaar39766a72013-11-03 00:41:00 +0100311dnl Mac OS X 10.9+ no longer include AvailabilityMacros.h in Carbon
312dnl so we need to include it to have access to version macros.
Bram Moolenaar18e54692013-11-03 20:26:31 +0100313AC_CHECK_HEADERS(AvailabilityMacros.h)
Bram Moolenaar39766a72013-11-03 00:41:00 +0100314
Bram Moolenaar071d4272004-06-13 20:20:40 +0000315AC_SUBST(OS_EXTRA_SRC)
316AC_SUBST(OS_EXTRA_OBJ)
317
318dnl Add /usr/local/lib to $LDFLAGS and /usr/local/include to CFLAGS.
319dnl Only when the directory exists and it wasn't there yet.
320dnl For gcc don't do this when it is already in the default search path.
Bram Moolenaar446cb832008-06-24 21:56:24 +0000321dnl Skip all of this when cross-compiling.
322if test "$cross_compiling" = no; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000323 AC_MSG_CHECKING(--with-local-dir argument)
Bram Moolenaar446cb832008-06-24 21:56:24 +0000324 have_local_include=''
325 have_local_lib=''
Bram Moolenaarc236c162008-07-13 17:41:49 +0000326 AC_ARG_WITH([local-dir], [ --with-local-dir=PATH search PATH instead of /usr/local for local libraries.
327 --without-local-dir do not search /usr/local for local libraries.], [
328 local_dir="$withval"
329 case "$withval" in
330 */*) ;;
331 no)
332 # avoid adding local dir to LDFLAGS and CPPFLAGS
Bram Moolenaare06c1882010-07-21 22:05:20 +0200333 have_local_include=yes
Bram Moolenaarc236c162008-07-13 17:41:49 +0000334 have_local_lib=yes
335 ;;
336 *) AC_MSG_ERROR(must pass path argument to --with-local-dir) ;;
337 esac
338 AC_MSG_RESULT($local_dir)
339 ], [
340 local_dir=/usr/local
341 AC_MSG_RESULT(Defaulting to $local_dir)
342 ])
343 if test "$GCC" = yes -a "$local_dir" != no; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000344 echo 'void f(){}' > conftest.c
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100345 dnl Removed -no-cpp-precomp, only needed for OS X 10.2 (Ben Fowler)
346 have_local_include=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/include"`
Bram Moolenaarc236c162008-07-13 17:41:49 +0000347 have_local_lib=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/lib"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000348 rm -f conftest.c conftest.o
Bram Moolenaar071d4272004-06-13 20:20:40 +0000349 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000350 if test -z "$have_local_lib" -a -d "${local_dir}/lib"; then
351 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 +0000352 if test "$tt" = "$LDFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000353 LDFLAGS="$LDFLAGS -L${local_dir}/lib"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000354 fi
355 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000356 if test -z "$have_local_include" -a -d "${local_dir}/include"; then
357 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 +0000358 if test "$tt" = "$CPPFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000359 CPPFLAGS="$CPPFLAGS -I${local_dir}/include"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000360 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000361 fi
362fi
363
364AC_MSG_CHECKING(--with-vim-name argument)
365AC_ARG_WITH(vim-name, [ --with-vim-name=NAME what to call the Vim executable],
366 VIMNAME="$withval"; AC_MSG_RESULT($VIMNAME),
Bram Moolenaare344bea2005-09-01 20:46:49 +0000367 VIMNAME="vim"; AC_MSG_RESULT(Defaulting to $VIMNAME))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000368AC_SUBST(VIMNAME)
369AC_MSG_CHECKING(--with-ex-name argument)
370AC_ARG_WITH(ex-name, [ --with-ex-name=NAME what to call the Ex executable],
371 EXNAME="$withval"; AC_MSG_RESULT($EXNAME),
372 EXNAME="ex"; AC_MSG_RESULT(Defaulting to ex))
373AC_SUBST(EXNAME)
374AC_MSG_CHECKING(--with-view-name argument)
375AC_ARG_WITH(view-name, [ --with-view-name=NAME what to call the View executable],
376 VIEWNAME="$withval"; AC_MSG_RESULT($VIEWNAME),
377 VIEWNAME="view"; AC_MSG_RESULT(Defaulting to view))
378AC_SUBST(VIEWNAME)
379
380AC_MSG_CHECKING(--with-global-runtime argument)
Bram Moolenaar9d302ad2018-12-21 11:48:51 +0100381AC_ARG_WITH(global-runtime, [ --with-global-runtime=DIR global runtime directory in 'runtimepath', comma-separated for multiple directories],
382 RUNTIME_GLOBAL="$withval"; AC_MSG_RESULT($withval),
Bram Moolenaar071d4272004-06-13 20:20:40 +0000383 AC_MSG_RESULT(no))
384
Bram Moolenaar9d302ad2018-12-21 11:48:51 +0100385if test "X$RUNTIME_GLOBAL" != "X"; then
386 RUNTIME_GLOBAL_AFTER=$(printf -- "$RUNTIME_GLOBAL\\n" | $AWK -F, 'BEGIN { comma=0 } { for (i = NF; i > 0; i--) { if (comma) { printf ",%s/after", $i } else { printf "%s/after", $i; comma=1 } } } END { printf "\n" }')
387 AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL, "$RUNTIME_GLOBAL")
388 AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL_AFTER, "$RUNTIME_GLOBAL_AFTER")
389fi
390
Bram Moolenaar071d4272004-06-13 20:20:40 +0000391AC_MSG_CHECKING(--with-modified-by argument)
392AC_ARG_WITH(modified-by, [ --with-modified-by=NAME name of who modified a release version],
393 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(MODIFIED_BY, "$withval"),
394 AC_MSG_RESULT(no))
395
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200396dnl Check for EBCDIC stolen from the LYNX port to z/OS Unix
Bram Moolenaar071d4272004-06-13 20:20:40 +0000397AC_MSG_CHECKING(if character set is EBCDIC)
398AC_TRY_COMPILE([ ],
399[ /* TryCompile function for CharSet.
400 Treat any failure as ASCII for compatibility with existing art.
401 Use compile-time rather than run-time tests for cross-compiler
402 tolerance. */
403#if '0'!=240
404make an error "Character set is not EBCDIC"
405#endif ],
406[ # TryCompile action if true
407cf_cv_ebcdic=yes ],
408[ # TryCompile action if false
409cf_cv_ebcdic=no])
410# end of TryCompile ])
411# end of CacheVal CvEbcdic
412AC_MSG_RESULT($cf_cv_ebcdic)
413case "$cf_cv_ebcdic" in #(vi
414 yes) AC_DEFINE(EBCDIC)
415 line_break='"\\n"'
416 ;;
417 *) line_break='"\\012"';;
418esac
419AC_SUBST(line_break)
420
421if test "$cf_cv_ebcdic" = "yes"; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +0200422dnl If we have EBCDIC we most likely have z/OS Unix, let's test it!
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200423AC_MSG_CHECKING(for z/OS Unix)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000424case $vim_cv_uname_output in
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200425 OS/390) zOSUnix="yes";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000426 dnl If using cc the environment variable _CC_CCMODE must be
427 dnl set to "1", so that some compiler extensions are enabled.
428 dnl If using c89 the environment variable is named _CC_C89MODE.
429 dnl Note: compile with c89 never tested.
430 if test "$CC" = "cc"; then
431 ccm="$_CC_CCMODE"
432 ccn="CC"
433 else
434 if test "$CC" = "c89"; then
435 ccm="$_CC_C89MODE"
436 ccn="C89"
437 else
438 ccm=1
439 fi
440 fi
441 if test "$ccm" != "1"; then
442 echo ""
443 echo "------------------------------------------"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200444 echo " On z/OS Unix, the environment variable"
Bram Moolenaar77c19352012-06-13 19:19:41 +0200445 echo " _CC_${ccn}MODE must be set to \"1\"!"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000446 echo " Do:"
447 echo " export _CC_${ccn}MODE=1"
448 echo " and then call configure again."
449 echo "------------------------------------------"
450 exit 1
451 fi
Bram Moolenaar77c19352012-06-13 19:19:41 +0200452 # Set CFLAGS for configure process.
453 # This will be reset later for config.mk.
454 # Use haltonmsg to force error for missing H files.
455 CFLAGS="$CFLAGS -D_ALL_SOURCE -Wc,float(ieee),haltonmsg(3296)";
456 LDFLAGS="$LDFLAGS -Wl,EDIT=NO"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000457 AC_MSG_RESULT(yes)
458 ;;
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200459 *) zOSUnix="no";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000460 AC_MSG_RESULT(no)
461 ;;
462esac
463fi
464
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200465dnl Set QUOTESED. Needs additional backslashes on zOS
466if test "$zOSUnix" = "yes"; then
Bram Moolenaarabcbb0e2020-12-23 12:33:42 +0100467 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\\\\\&/g' -e 's/\\\\\\\\\"/\"/' -e 's/\\\\\\\\\";\$\$/\";/' -e 's/ */ /g'"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200468else
Bram Moolenaarabcbb0e2020-12-23 12:33:42 +0100469 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\&/g' -e 's/\\\\\"/\"/' -e 's/\\\\\";\$\$/\";/' -e 's/ */ /g'"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200470fi
471AC_SUBST(QUOTESED)
472
473
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200474dnl Link with -lsmack for Smack stuff; if not found
475AC_MSG_CHECKING(--disable-smack argument)
476AC_ARG_ENABLE(smack,
477 [ --disable-smack Do not check for Smack support.],
478 , enable_smack="yes")
479if test "$enable_smack" = "yes"; then
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200480 AC_MSG_RESULT(no)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200481 AC_CHECK_HEADER([linux/xattr.h], true, enable_smack="no")
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200482else
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200483 AC_MSG_RESULT(yes)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200484fi
485if test "$enable_smack" = "yes"; then
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200486 AC_CHECK_HEADER([attr/xattr.h], true, enable_smack="no")
487fi
488if test "$enable_smack" = "yes"; then
489 AC_MSG_CHECKING(for XATTR_NAME_SMACKEXEC in linux/xattr.h)
490 AC_EGREP_CPP(XATTR_NAME_SMACKEXEC, [#include <linux/xattr.h>],
491 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +0200492 AC_MSG_RESULT(no); enable_smack="no")
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200493fi
494if test "$enable_smack" = "yes"; then
495 AC_CHECK_LIB(attr, setxattr,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200496 [LIBS="$LIBS -lattr"
497 found_smack="yes"
498 AC_DEFINE(HAVE_SMACK)])
Bram Moolenaar588ebeb2008-05-07 17:09:24 +0000499fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000500
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200501dnl When smack was found don't search for SELinux
502if test "x$found_smack" = "x"; then
503 dnl Link with -lselinux for SELinux stuff; if not found
504 AC_MSG_CHECKING(--disable-selinux argument)
505 AC_ARG_ENABLE(selinux,
506 [ --disable-selinux Do not check for SELinux support.],
507 , enable_selinux="yes")
508 if test "$enable_selinux" = "yes"; then
509 AC_MSG_RESULT(no)
510 AC_CHECK_LIB(selinux, is_selinux_enabled,
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100511 [AC_CHECK_HEADER(selinux/selinux.h,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200512 [LIBS="$LIBS -lselinux"
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100513 AC_DEFINE(HAVE_SELINUX)])])
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200514 else
515 AC_MSG_RESULT(yes)
516 fi
517fi
518
Bram Moolenaar071d4272004-06-13 20:20:40 +0000519dnl Check user requested features.
520
521AC_MSG_CHECKING(--with-features argument)
Bram Moolenaareec29812016-07-26 21:27:36 +0200522AC_ARG_WITH(features, [ --with-features=TYPE tiny, small, normal, big or huge (default: huge)],
Bram Moolenaar071d4272004-06-13 20:20:40 +0000523 features="$withval"; AC_MSG_RESULT($features),
Bram Moolenaar23c4f712016-01-20 22:11:59 +0100524 features="huge"; AC_MSG_RESULT(Defaulting to huge))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000525
526dovimdiff=""
527dogvimdiff=""
528case "$features" in
529 tiny) AC_DEFINE(FEAT_TINY) ;;
530 small) AC_DEFINE(FEAT_SMALL) ;;
531 normal) AC_DEFINE(FEAT_NORMAL) dovimdiff="installvimdiff";
532 dogvimdiff="installgvimdiff" ;;
533 big) AC_DEFINE(FEAT_BIG) dovimdiff="installvimdiff";
534 dogvimdiff="installgvimdiff" ;;
535 huge) AC_DEFINE(FEAT_HUGE) dovimdiff="installvimdiff";
536 dogvimdiff="installgvimdiff" ;;
537 *) AC_MSG_RESULT([Sorry, $features is not supported]) ;;
538esac
539
540AC_SUBST(dovimdiff)
541AC_SUBST(dogvimdiff)
542
Bram Moolenaar12471262022-01-18 11:11:25 +0000543if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
544 has_eval=no
545else
546 has_eval=yes
547fi
548
Bram Moolenaar071d4272004-06-13 20:20:40 +0000549AC_MSG_CHECKING(--with-compiledby argument)
550AC_ARG_WITH(compiledby, [ --with-compiledby=NAME name to show in :version message],
551 compiledby="$withval"; AC_MSG_RESULT($withval),
552 compiledby=""; AC_MSG_RESULT(no))
553AC_SUBST(compiledby)
554
555AC_MSG_CHECKING(--disable-xsmp argument)
556AC_ARG_ENABLE(xsmp,
557 [ --disable-xsmp Disable XSMP session management],
558 , enable_xsmp="yes")
559
560if test "$enable_xsmp" = "yes"; then
561 AC_MSG_RESULT(no)
562 AC_MSG_CHECKING(--disable-xsmp-interact argument)
563 AC_ARG_ENABLE(xsmp-interact,
564 [ --disable-xsmp-interact Disable XSMP interaction],
565 , enable_xsmp_interact="yes")
566 if test "$enable_xsmp_interact" = "yes"; then
567 AC_MSG_RESULT(no)
568 AC_DEFINE(USE_XSMP_INTERACT)
569 else
570 AC_MSG_RESULT(yes)
571 fi
572else
573 AC_MSG_RESULT(yes)
574fi
575
Bram Moolenaar67ffb412022-01-08 13:36:57 +0000576AC_MSG_CHECKING([diff feature])
577if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
578 AC_MSG_RESULT([disabled in $features version])
579else
580 AC_MSG_RESULT(enabled)
581 AC_DEFINE(FEAT_DIFF)
582 XDIFF_OBJS_USED="\$(XDIFF_OBJS)"
583 AC_SUBST(XDIFF_OBJS_USED)
584fi
585
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200586dnl Check for Lua feature.
587AC_MSG_CHECKING(--enable-luainterp argument)
588AC_ARG_ENABLE(luainterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200589 [ --enable-luainterp[=OPTS] Include Lua interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200590 [enable_luainterp="no"])
591AC_MSG_RESULT($enable_luainterp)
592
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200593if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then
Bram Moolenaar12471262022-01-18 11:11:25 +0000594 if test "$has_eval" = "no"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +0100595 AC_MSG_ERROR([cannot use Lua with tiny or small features])
596 fi
597
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200598 dnl -- find the lua executable
599 AC_SUBST(vi_cv_path_lua)
600
601 AC_MSG_CHECKING(--with-lua-prefix argument)
602 AC_ARG_WITH(lua_prefix,
603 [ --with-lua-prefix=PFX Prefix where Lua is installed.],
604 with_lua_prefix="$withval"; AC_MSG_RESULT($with_lua_prefix),
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200605 with_lua_prefix="";AC_MSG_RESULT(no))
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200606
607 if test "X$with_lua_prefix" != "X"; then
608 vi_cv_path_lua_pfx="$with_lua_prefix"
609 else
610 AC_MSG_CHECKING(LUA_PREFIX environment var)
611 if test "X$LUA_PREFIX" != "X"; then
612 AC_MSG_RESULT("$LUA_PREFIX")
613 vi_cv_path_lua_pfx="$LUA_PREFIX"
614 else
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200615 AC_MSG_RESULT([not set, default to /usr])
616 vi_cv_path_lua_pfx="/usr"
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200617 fi
618 fi
619
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200620 AC_MSG_CHECKING(--with-luajit)
621 AC_ARG_WITH(luajit,
622 [ --with-luajit Link with LuaJIT instead of Lua.],
623 [vi_cv_with_luajit="$withval"],
624 [vi_cv_with_luajit="no"])
625 AC_MSG_RESULT($vi_cv_with_luajit)
626
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200627 LUA_INC=
628 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200629 if test "x$vi_cv_with_luajit" != "xno"; then
630 dnl -- try to find LuaJIT executable
631 AC_PATH_PROG(vi_cv_path_luajit, luajit)
632 if test "X$vi_cv_path_luajit" != "X"; then
633 dnl -- find LuaJIT version
634 AC_CACHE_CHECK(LuaJIT version, vi_cv_version_luajit,
Bram Moolenaar49b10272013-11-21 12:17:51 +0100635 [ 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 +0200636 AC_CACHE_CHECK(Lua version of LuaJIT, vi_cv_version_lua_luajit,
637 [ vi_cv_version_lua_luajit=`${vi_cv_path_luajit} -e "print(_VERSION)" | sed 's/.* //'` ])
638 vi_cv_path_lua="$vi_cv_path_luajit"
639 vi_cv_version_lua="$vi_cv_version_lua_luajit"
640 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200641 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200642 dnl -- try to find Lua executable
643 AC_PATH_PROG(vi_cv_path_plain_lua, lua)
644 if test "X$vi_cv_path_plain_lua" != "X"; then
645 dnl -- find Lua version
646 AC_CACHE_CHECK(Lua version, vi_cv_version_plain_lua,
647 [ vi_cv_version_plain_lua=`${vi_cv_path_plain_lua} -e "print(_VERSION)" | sed 's/.* //'` ])
648 fi
649 vi_cv_path_lua="$vi_cv_path_plain_lua"
650 vi_cv_version_lua="$vi_cv_version_plain_lua"
651 fi
652 if test "x$vi_cv_with_luajit" != "xno" && test "X$vi_cv_version_luajit" != "X"; then
653 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 +0100654 if test -f "$vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200655 AC_MSG_RESULT(yes)
656 LUA_INC=/luajit-$vi_cv_version_luajit
657 fi
658 fi
659 if test "X$LUA_INC" = "X"; then
660 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)
Bram Moolenaar49222be2015-12-11 18:11:30 +0100661 if test -f "$vi_cv_path_lua_pfx/include/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200662 AC_MSG_RESULT(yes)
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200663 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200664 AC_MSG_RESULT(no)
665 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 +0100666 if test -f "$vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200667 AC_MSG_RESULT(yes)
668 LUA_INC=/lua$vi_cv_version_lua
669 else
670 AC_MSG_RESULT(no)
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200671
672 # Detect moonjit:
673 # https://groups.google.com/forum/#!topic/vim_use/O0vek60WuTk
674 lua_suf=/moonjit-2.3
675 inc_path="$vi_cv_path_lua_pfx/include"
Bram Moolenaarad4dc832020-04-20 16:21:53 +0200676 for dir in "$inc_path"/moonjit-[[0-9]]* ; do
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200677 if test -d "$dir" ; then
Bram Moolenaara79a8942020-12-17 20:50:25 +0100678 lua_suf=`basename "$dir"`
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200679 lua_suf="/$lua_suf"
680 break
681 fi
682 done
683 AC_MSG_CHECKING(if lua.h can be found in $inc_path$lua_suf)
684 if test -f "$inc_path$lua_suf/lua.h"; then
685 AC_MSG_RESULT(yes)
686 LUA_INC=$lua_suf
687 else
688 AC_MSG_RESULT(no)
689 vi_cv_path_lua_pfx=
690 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200691 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200692 fi
693 fi
694 fi
695
696 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200697 if test "x$vi_cv_with_luajit" != "xno"; then
698 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
699 if test "X$multiarch" != "X"; then
700 lib_multiarch="lib/${multiarch}"
701 else
702 lib_multiarch="lib"
703 fi
704 if test "X$vi_cv_version_lua" = "X"; then
705 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit"
706 else
707 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit-$vi_cv_version_lua"
708 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200709 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200710 if test "X$LUA_INC" != "X"; then
711 dnl Test alternate location using version
712 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua$vi_cv_version_lua"
713 else
714 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua"
715 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200716 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200717 if test "$enable_luainterp" = "dynamic"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200718 lua_ok="yes"
719 else
720 AC_MSG_CHECKING([if link with ${LUA_LIBS} is sane])
721 libs_save=$LIBS
722 LIBS="$LIBS $LUA_LIBS"
723 AC_TRY_LINK(,[ ],
724 AC_MSG_RESULT(yes); lua_ok="yes",
725 AC_MSG_RESULT(no); lua_ok="no"; LUA_LIBS="")
726 LIBS=$libs_save
727 fi
728 if test "x$lua_ok" = "xyes"; then
729 LUA_CFLAGS="-I${vi_cv_path_lua_pfx}/include${LUA_INC}"
730 LUA_SRC="if_lua.c"
731 LUA_OBJ="objects/if_lua.o"
732 LUA_PRO="if_lua.pro"
733 AC_DEFINE(FEAT_LUA)
734 fi
735 if test "$enable_luainterp" = "dynamic"; then
736 if test "x$vi_cv_with_luajit" != "xno"; then
737 luajit="jit"
738 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200739 if test -f "${vi_cv_path_lua_pfx}/bin/cyglua-${vi_cv_version_lua}.dll"; then
740 vi_cv_dll_name_lua="cyglua-${vi_cv_version_lua}.dll"
741 else
Bram Moolenaard0573012017-10-28 21:11:06 +0200742 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200743 ext="dylib"
744 indexes=""
745 else
746 ext="so"
747 indexes=".0 .1 .2 .3 .4 .5 .6 .7 .8 .9"
748 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
749 if test "X$multiarch" != "X"; then
750 lib_multiarch="lib/${multiarch}"
751 fi
Bram Moolenaar768baac2013-04-15 14:44:57 +0200752 fi
753 dnl Determine the sover for the current version, but fallback to
754 dnl liblua${vi_cv_version_lua}.so if no sover-versioned file is found.
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200755 AC_MSG_CHECKING(if liblua${luajit}*.${ext}* can be found in $vi_cv_path_lua_pfx)
Bram Moolenaar768baac2013-04-15 14:44:57 +0200756 for subdir in "${lib_multiarch}" lib64 lib; do
757 if test -z "$subdir"; then
758 continue
759 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200760 for sover in "${vi_cv_version_lua}.${ext}" "-${vi_cv_version_lua}.${ext}" \
761 ".${vi_cv_version_lua}.${ext}" ".${ext}.${vi_cv_version_lua}"; do
762 for i in $indexes ""; do
763 if test -f "${vi_cv_path_lua_pfx}/${subdir}/liblua${luajit}${sover}$i"; then
Bram Moolenaar768baac2013-04-15 14:44:57 +0200764 sover2="$i"
765 break 3
766 fi
767 done
Bram Moolenaar07e1da62013-02-06 19:49:43 +0100768 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200769 sover=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200770 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200771 if test "X$sover" = "X"; then
772 AC_MSG_RESULT(no)
773 lua_ok="no"
774 vi_cv_dll_name_lua="liblua${luajit}.${ext}"
775 else
776 AC_MSG_RESULT(yes)
777 lua_ok="yes"
778 vi_cv_dll_name_lua="liblua${luajit}${sover}$sover2"
779 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200780 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200781 AC_DEFINE(DYNAMIC_LUA)
782 LUA_LIBS=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200783 LUA_CFLAGS="-DDYNAMIC_LUA_DLL=\\\"${vi_cv_dll_name_lua}\\\" $LUA_CFLAGS"
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200784 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200785 if test "X$LUA_CFLAGS$LUA_LIBS" != "X" && \
Bram Moolenaard0573012017-10-28 21:11:06 +0200786 test "x$MACOS_X" = "xyes" && test "x$vi_cv_with_luajit" != "xno" && \
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000787 test "$vim_cv_uname_m_output" = "x86_64"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200788 dnl OSX/x64 requires these flags. See http://luajit.org/install.html
789 LUA_LIBS="-pagezero_size 10000 -image_base 100000000 $LUA_LIBS"
790 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200791 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200792 if test "$fail_if_missing" = "yes" -a "$lua_ok" != "yes"; then
Bram Moolenaarf788a062011-12-14 20:51:25 +0100793 AC_MSG_ERROR([could not configure lua])
794 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200795 AC_SUBST(LUA_SRC)
796 AC_SUBST(LUA_OBJ)
797 AC_SUBST(LUA_PRO)
798 AC_SUBST(LUA_LIBS)
799 AC_SUBST(LUA_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +0000800 AC_SUBST(LUA_CFLAGS_EXTRA)
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200801fi
802
803
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000804dnl Check for MzScheme feature.
805AC_MSG_CHECKING(--enable-mzschemeinterp argument)
806AC_ARG_ENABLE(mzschemeinterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200807 [ --enable-mzschemeinterp Include MzScheme interpreter.], ,
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000808 [enable_mzschemeinterp="no"])
809AC_MSG_RESULT($enable_mzschemeinterp)
810
811if test "$enable_mzschemeinterp" = "yes"; then
812 dnl -- find the mzscheme executable
813 AC_SUBST(vi_cv_path_mzscheme)
814
815 AC_MSG_CHECKING(--with-plthome argument)
816 AC_ARG_WITH(plthome,
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000817 [ --with-plthome=PLTHOME Use PLTHOME.],
818 with_plthome="$withval"; AC_MSG_RESULT($with_plthome),
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000819 with_plthome="";AC_MSG_RESULT("no"))
820
821 if test "X$with_plthome" != "X"; then
822 vi_cv_path_mzscheme_pfx="$with_plthome"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100823 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000824 else
825 AC_MSG_CHECKING(PLTHOME environment var)
826 if test "X$PLTHOME" != "X"; then
827 AC_MSG_RESULT("$PLTHOME")
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000828 vi_cv_path_mzscheme_pfx="$PLTHOME"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100829 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000830 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000831 AC_MSG_RESULT(not set)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000832 dnl -- try to find MzScheme executable
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000833 AC_PATH_PROG(vi_cv_path_mzscheme, mzscheme)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000834
835 dnl resolve symbolic link, the executable is often elsewhere and there
836 dnl are no links for the include files.
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000837 if test "X$vi_cv_path_mzscheme" != "X"; then
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000838 lsout=`ls -l $vi_cv_path_mzscheme`
839 if echo "$lsout" | grep -e '->' >/dev/null 2>/dev/null; then
840 vi_cv_path_mzscheme=`echo "$lsout" | sed 's/.*-> \(.*\)/\1/'`
841 fi
842 fi
843
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000844 if test "X$vi_cv_path_mzscheme" != "X"; then
845 dnl -- find where MzScheme thinks it was installed
846 AC_CACHE_CHECK(MzScheme install prefix,vi_cv_path_mzscheme_pfx,
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000847 dnl different versions of MzScheme differ in command line processing
848 dnl use universal approach
849 echo "(display (simplify-path \
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000850 (build-path (call-with-values \
851 (lambda () (split-path (find-system-path (quote exec-file)))) \
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000852 (lambda (base name must-be-dir?) base)) (quote up))))" > mzdirs.scm
853 dnl Remove a trailing slash
854 [ vi_cv_path_mzscheme_pfx=`${vi_cv_path_mzscheme} -r mzdirs.scm | \
855 sed -e 's+/$++'` ])
856 rm -f mzdirs.scm
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000857 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000858 fi
859 fi
860
861 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100862 AC_MSG_CHECKING(for racket include directory)
863 SCHEME_INC=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-include-dir))) (when (path? p) (display p)))'`
864 if test "X$SCHEME_INC" != "X"; then
865 AC_MSG_RESULT(${SCHEME_INC})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000866 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100867 AC_MSG_RESULT(not found)
868 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include)
869 if test -f "$vi_cv_path_mzscheme_pfx/include/scheme.h"; then
870 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000871 AC_MSG_RESULT(yes)
Bram Moolenaard7afed32007-05-06 13:26:41 +0000872 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000873 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100874 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt)
875 if test -f "$vi_cv_path_mzscheme_pfx/include/plt/scheme.h"; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000876 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100877 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000878 else
879 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100880 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket)
881 if test -f "$vi_cv_path_mzscheme_pfx/include/racket/scheme.h"; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100882 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100883 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100884 else
885 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100886 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/)
887 if test -f /usr/include/plt/scheme.h; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100888 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100889 SCHEME_INC=/usr/include/plt
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100890 else
891 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100892 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/racket/)
893 if test -f /usr/include/racket/scheme.h; then
894 AC_MSG_RESULT(yes)
895 SCHEME_INC=/usr/include/racket
896 else
897 AC_MSG_RESULT(no)
898 vi_cv_path_mzscheme_pfx=
899 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100900 fi
901 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000902 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000903 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000904 fi
905 fi
906
907 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100908
909 AC_MSG_CHECKING(for racket lib directory)
910 SCHEME_LIB=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-lib-dir))) (when (path? p) (display p)))'`
911 if test "X$SCHEME_LIB" != "X"; then
912 AC_MSG_RESULT(${SCHEME_LIB})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000913 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100914 AC_MSG_RESULT(not found)
915 fi
916
917 for path in "${vi_cv_path_mzscheme_pfx}/lib" "${SCHEME_LIB}"; do
918 if test "X$path" != "X"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200919 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100920 MZSCHEME_LIBS="-framework Racket"
921 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
922 elif test -f "${path}/libmzscheme3m.a"; then
923 MZSCHEME_LIBS="${path}/libmzscheme3m.a"
924 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
925 elif test -f "${path}/libracket3m.a"; then
926 MZSCHEME_LIBS="${path}/libracket3m.a"
Bram Moolenaar588d2412020-10-03 14:24:19 +0200927 if test -f "${path}/librktio.a"; then
928 MZSCHEME_LIBS="${MZSCHEME_LIBS} ${path}/librktio.a"
929 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100930 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
931 elif test -f "${path}/libracket.a"; then
932 MZSCHEME_LIBS="${path}/libracket.a ${path}/libmzgc.a"
933 elif test -f "${path}/libmzscheme.a"; then
934 MZSCHEME_LIBS="${path}/libmzscheme.a ${path}/libmzgc.a"
935 else
936 dnl Using shared objects
937 if test -f "${path}/libmzscheme3m.so"; then
938 MZSCHEME_LIBS="-L${path} -lmzscheme3m"
939 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
940 elif test -f "${path}/libracket3m.so"; then
941 MZSCHEME_LIBS="-L${path} -lracket3m"
942 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
943 elif test -f "${path}/libracket.so"; then
944 MZSCHEME_LIBS="-L${path} -lracket -lmzgc"
945 else
946 dnl try next until last
947 if test "$path" != "$SCHEME_LIB"; then
948 continue
949 fi
950 MZSCHEME_LIBS="-L${path} -lmzscheme -lmzgc"
951 fi
952 if test "$GCC" = yes; then
953 dnl Make Vim remember the path to the library. For when it's not in
954 dnl $LD_LIBRARY_PATH.
955 MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${path}"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000956 elif test "$vim_cv_uname_output" = SunOS &&
957 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100958 MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${path}"
959 fi
960 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000961 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100962 if test "X$MZSCHEME_LIBS" != "X"; then
963 break
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +0000964 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100965 done
966
967 AC_MSG_CHECKING([if racket requires -pthread])
968 if test "X$SCHEME_LIB" != "X" && $FGREP -e -pthread "$SCHEME_LIB/buildinfo" >/dev/null ; then
969 AC_MSG_RESULT(yes)
970 MZSCHEME_LIBS="${MZSCHEME_LIBS} -pthread"
971 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -pthread"
972 else
973 AC_MSG_RESULT(no)
974 fi
975
976 AC_MSG_CHECKING(for racket config directory)
977 SCHEME_CONFIGDIR=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-config-dir))) (when (path? p) (display p)))'`
978 if test "X$SCHEME_CONFIGDIR" != "X"; then
979 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DMZSCHEME_CONFIGDIR='\"${SCHEME_CONFIGDIR}\"'"
980 AC_MSG_RESULT(${SCHEME_CONFIGDIR})
981 else
982 AC_MSG_RESULT(not found)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000983 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100984
985 AC_MSG_CHECKING(for racket collects directory)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100986 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))))'`
987 if test "X$SCHEME_COLLECTS" = "X"; then
988 if test -d "$vi_cv_path_mzscheme_pfx/lib/plt/collects"; then
989 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/plt/
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100990 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100991 if test -d "$vi_cv_path_mzscheme_pfx/lib/racket/collects"; then
992 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/racket/
Bram Moolenaar75676462013-01-30 14:55:42 +0100993 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100994 if test -d "$vi_cv_path_mzscheme_pfx/share/racket/collects"; then
995 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/
996 else
997 if test -d "$vi_cv_path_mzscheme_pfx/collects"; then
998 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/
999 fi
Bram Moolenaar75676462013-01-30 14:55:42 +01001000 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001001 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +01001002 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +00001003 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001004 if test "X$SCHEME_COLLECTS" != "X" ; then
1005 AC_MSG_RESULT(${SCHEME_COLLECTS})
1006 else
1007 AC_MSG_RESULT(not found)
1008 fi
1009
1010 AC_MSG_CHECKING(for mzscheme_base.c)
1011 if test -f "${SCHEME_COLLECTS}collects/scheme/base.ss" ; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001012 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +01001013 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
1014 MZSCHEME_MOD="++lib scheme/base"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +01001015 else
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001016 if test -f "${SCHEME_COLLECTS}collects/scheme/base.rkt" ; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +01001017 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +01001018 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
1019 MZSCHEME_MOD="++lib scheme/base"
1020 else
1021 if test -f "${SCHEME_COLLECTS}collects/racket/base.rkt" ; then
1022 MZSCHEME_EXTRA="mzscheme_base.c"
1023 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/raco ctool"
1024 MZSCHEME_MOD=""
1025 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +01001026 fi
1027 fi
1028 if test "X$MZSCHEME_EXTRA" != "X" ; then
1029 dnl need to generate bytecode for MzScheme base
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001030 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE"
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001031 AC_MSG_RESULT(needed)
1032 else
1033 AC_MSG_RESULT(not needed)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001034 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001035
Bram Moolenaar9e902192013-07-17 18:58:11 +02001036 dnl On Ubuntu this fixes "undefined reference to symbol 'ffi_type_void'".
1037 AC_CHECK_LIB(ffi, ffi_type_void, [MZSCHEME_LIBS="$MZSCHEME_LIBS -lffi"])
1038
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001039 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -I${SCHEME_INC} \
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001040 -DMZSCHEME_COLLECTS='\"${SCHEME_COLLECTS}collects\"'"
Bram Moolenaar9e902192013-07-17 18:58:11 +02001041
1042 dnl Test that we can compile a simple program with these CFLAGS and LIBS.
1043 AC_MSG_CHECKING([if compile and link flags for MzScheme are sane])
1044 cflags_save=$CFLAGS
1045 libs_save=$LIBS
1046 CFLAGS="$CFLAGS $MZSCHEME_CFLAGS"
1047 LIBS="$LIBS $MZSCHEME_LIBS"
1048 AC_TRY_LINK(,[ ],
1049 AC_MSG_RESULT(yes); mzs_ok=yes,
1050 AC_MSG_RESULT(no: MZSCHEME DISABLED); mzs_ok=no)
1051 CFLAGS=$cflags_save
1052 LIBS=$libs_save
1053 if test $mzs_ok = yes; then
1054 MZSCHEME_SRC="if_mzsch.c"
1055 MZSCHEME_OBJ="objects/if_mzsch.o"
1056 MZSCHEME_PRO="if_mzsch.pro"
1057 AC_DEFINE(FEAT_MZSCHEME)
1058 else
1059 MZSCHEME_CFLAGS=
1060 MZSCHEME_LIBS=
1061 MZSCHEME_EXTRA=
1062 MZSCHEME_MZC=
1063 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001064 fi
1065 AC_SUBST(MZSCHEME_SRC)
1066 AC_SUBST(MZSCHEME_OBJ)
1067 AC_SUBST(MZSCHEME_PRO)
1068 AC_SUBST(MZSCHEME_LIBS)
1069 AC_SUBST(MZSCHEME_CFLAGS)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001070 AC_SUBST(MZSCHEME_EXTRA)
1071 AC_SUBST(MZSCHEME_MZC)
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001072fi
1073
1074
Bram Moolenaar071d4272004-06-13 20:20:40 +00001075AC_MSG_CHECKING(--enable-perlinterp argument)
1076AC_ARG_ENABLE(perlinterp,
Bram Moolenaare06c1882010-07-21 22:05:20 +02001077 [ --enable-perlinterp[=OPTS] Include Perl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001078 [enable_perlinterp="no"])
1079AC_MSG_RESULT($enable_perlinterp)
Bram Moolenaare06c1882010-07-21 22:05:20 +02001080if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00001081 if test "$has_eval" = "no"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01001082 AC_MSG_ERROR([cannot use Perl with tiny or small features])
1083 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001084 AC_SUBST(vi_cv_path_perl)
1085 AC_PATH_PROG(vi_cv_path_perl, perl)
1086 if test "X$vi_cv_path_perl" != "X"; then
1087 AC_MSG_CHECKING(Perl version)
1088 if $vi_cv_path_perl -e 'require 5.003_01' >/dev/null 2>/dev/null; then
1089 eval `$vi_cv_path_perl -V:usethreads`
Bram Moolenaare06c1882010-07-21 22:05:20 +02001090 eval `$vi_cv_path_perl -V:libperl`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001091 if test "X$usethreads" = "XUNKNOWN" -o "X$usethreads" = "Xundef"; then
1092 badthreads=no
1093 else
1094 if $vi_cv_path_perl -e 'require 5.6.0' >/dev/null 2>/dev/null; then
1095 eval `$vi_cv_path_perl -V:use5005threads`
1096 if test "X$use5005threads" = "XUNKNOWN" -o "X$use5005threads" = "Xundef"; then
1097 badthreads=no
1098 else
1099 badthreads=yes
1100 AC_MSG_RESULT(>>> Perl > 5.6 with 5.5 threads cannot be used <<<)
1101 fi
1102 else
1103 badthreads=yes
1104 AC_MSG_RESULT(>>> Perl 5.5 with threads cannot be used <<<)
1105 fi
1106 fi
1107 if test $badthreads = no; then
1108 AC_MSG_RESULT(OK)
1109 eval `$vi_cv_path_perl -V:shrpenv`
1110 if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04
1111 shrpenv=""
1112 fi
1113 vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlibexp}'`
1114 AC_SUBST(vi_cv_perllib)
Bram Moolenaard5f62b12014-08-17 17:05:44 +02001115 vi_cv_perl_extutils=unknown_perl_extutils_path
1116 for extutils_rel_path in ExtUtils vendor_perl/ExtUtils; do
1117 xsubpp_path="$vi_cv_perllib/$extutils_rel_path/xsubpp"
1118 if test -f "$xsubpp_path"; then
1119 vi_cv_perl_xsubpp="$xsubpp_path"
1120 fi
1121 done
1122 AC_SUBST(vi_cv_perl_xsubpp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001123 dnl Remove "-fno-something", it breaks using cproto.
Bram Moolenaar280a8682015-06-21 13:41:08 +02001124 dnl Remove "-fdebug-prefix-map", it isn't supported by clang.
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001125 dnl Remove "FORTIFY_SOURCE", it will be defined twice.
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001126 dnl remove -pipe and -Wxxx, it confuses cproto
Bram Moolenaar071d4272004-06-13 20:20:40 +00001127 perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001128 -e 'ccflags;perl_inc;print"\n"' | sed -e 's/-fno[[^ ]]*//' \
1129 -e 's/-fdebug-prefix-map[[^ ]]*//g' \
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001130 -e 's/-pipe //' \
1131 -e 's/-W[[^ ]]*//g' \
1132 -e 's/-D_FORTIFY_SOURCE=.//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001133 dnl Remove "-lc", it breaks on FreeBSD when using "-pthread".
1134 perllibs=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed -e 'ldopts' | \
1135 sed -e '/Warning/d' -e '/Note (probably harmless)/d' \
1136 -e 's/-bE:perl.exp//' -e 's/-lc //'`
1137 dnl Don't add perl lib to $LIBS: if it's not in LD_LIBRARY_PATH
1138 dnl a test in configure may fail because of that.
1139 perlldflags=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed \
1140 -e 'ccdlflags' | sed -e 's/-bE:perl.exp//'`
1141
1142 dnl check that compiling a simple program still works with the flags
1143 dnl added for Perl.
1144 AC_MSG_CHECKING([if compile and link flags for Perl are sane])
1145 cflags_save=$CFLAGS
1146 libs_save=$LIBS
1147 ldflags_save=$LDFLAGS
1148 CFLAGS="$CFLAGS $perlcppflags"
1149 LIBS="$LIBS $perllibs"
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001150 perlldflags=`echo "$perlldflags" | sed -e 's/^ *//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001151 LDFLAGS="$perlldflags $LDFLAGS"
1152 AC_TRY_LINK(,[ ],
1153 AC_MSG_RESULT(yes); perl_ok=yes,
1154 AC_MSG_RESULT(no: PERL DISABLED); perl_ok=no)
1155 CFLAGS=$cflags_save
1156 LIBS=$libs_save
1157 LDFLAGS=$ldflags_save
1158 if test $perl_ok = yes; then
1159 if test "X$perlcppflags" != "X"; then
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001160 PERL_CFLAGS=$perlcppflags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001161 fi
1162 if test "X$perlldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001163 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$perlldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001164 LDFLAGS="$perlldflags $LDFLAGS"
1165 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001166 fi
1167 PERL_LIBS=$perllibs
1168 PERL_SRC="auto/if_perl.c if_perlsfio.c"
1169 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o"
1170 PERL_PRO="if_perl.pro if_perlsfio.pro"
1171 AC_DEFINE(FEAT_PERL)
1172 fi
1173 fi
1174 else
1175 AC_MSG_RESULT(>>> too old; need Perl version 5.003_01 or later <<<)
1176 fi
1177 fi
1178
Bram Moolenaard0573012017-10-28 21:11:06 +02001179 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00001180 dnl Mac OS X 10.2 or later
Bram Moolenaar071d4272004-06-13 20:20:40 +00001181 dir=/System/Library/Perl
1182 darwindir=$dir/darwin
1183 if test -d $darwindir; then
1184 PERL=/usr/bin/perl
1185 else
1186 dnl Mac OS X 10.3
1187 dir=/System/Library/Perl/5.8.1
1188 darwindir=$dir/darwin-thread-multi-2level
1189 if test -d $darwindir; then
1190 PERL=/usr/bin/perl
1191 fi
1192 fi
1193 if test -n "$PERL"; then
1194 PERL_DIR="$dir"
1195 PERL_CFLAGS="-DFEAT_PERL -I$darwindir/CORE"
1196 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o $darwindir/auto/DynaLoader/DynaLoader.a"
1197 PERL_LIBS="-L$darwindir/CORE -lperl"
1198 fi
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001199 dnl Perl on Mac OS X 10.5 adds "-arch" flags but these should only
1200 dnl be included if requested by passing --with-mac-arch to
1201 dnl configure, so strip these flags first (if present)
1202 PERL_LIBS=`echo "$PERL_LIBS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
1203 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 +00001204 fi
Bram Moolenaare06c1882010-07-21 22:05:20 +02001205 if test "$enable_perlinterp" = "dynamic"; then
1206 if test "$perl_ok" = "yes" -a "X$libperl" != "X"; then
1207 AC_DEFINE(DYNAMIC_PERL)
1208 PERL_CFLAGS="-DDYNAMIC_PERL_DLL=\\\"$libperl\\\" $PERL_CFLAGS"
1209 fi
1210 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001211
1212 if test "$fail_if_missing" = "yes" -a "$perl_ok" != "yes"; then
1213 AC_MSG_ERROR([could not configure perl])
1214 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001215fi
1216AC_SUBST(shrpenv)
1217AC_SUBST(PERL_SRC)
1218AC_SUBST(PERL_OBJ)
1219AC_SUBST(PERL_PRO)
1220AC_SUBST(PERL_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00001221AC_SUBST(PERL_CFLAGS_EXTRA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001222AC_SUBST(PERL_LIBS)
1223
1224AC_MSG_CHECKING(--enable-pythoninterp argument)
1225AC_ARG_ENABLE(pythoninterp,
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001226 [ --enable-pythoninterp[=OPTS] Include Python interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001227 [enable_pythoninterp="no"])
1228AC_MSG_RESULT($enable_pythoninterp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001229if test "$enable_pythoninterp" = "yes" -o "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00001230 if test "$has_eval" = "no"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001231 AC_MSG_ERROR([cannot use Python with tiny or small features])
1232 fi
1233
Bram Moolenaar071d4272004-06-13 20:20:40 +00001234 dnl -- find the python executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001235 AC_MSG_CHECKING(--with-python-command argument)
1236 AC_SUBST(vi_cv_path_python)
1237 AC_ARG_WITH(python-command, [ --with-python-command=NAME name of the Python 2 command (default: python2 or python)],
1238 vi_cv_path_python="$withval"; AC_MSG_RESULT($vi_cv_path_python),
1239 AC_MSG_RESULT(no))
1240
1241 if test "X$vi_cv_path_python" = "X"; then
1242 AC_PATH_PROGS(vi_cv_path_python, python2 python)
1243 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001244 if test "X$vi_cv_path_python" != "X"; then
1245
1246 dnl -- get its version number
1247 AC_CACHE_CHECK(Python version,vi_cv_var_python_version,
1248 [[vi_cv_var_python_version=`
1249 ${vi_cv_path_python} -c 'import sys; print sys.version[:3]'`
1250 ]])
1251
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001252 dnl -- it must be at least version 2.3
1253 AC_MSG_CHECKING(Python is 2.3 or better)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001254 if ${vi_cv_path_python} -c \
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001255 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001256 then
1257 AC_MSG_RESULT(yep)
1258
1259 dnl -- find where python thinks it was installed
1260 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python_pfx,
1261 [ vi_cv_path_python_pfx=`
1262 ${vi_cv_path_python} -c \
1263 "import sys; print sys.prefix"` ])
1264
1265 dnl -- and where it thinks it runs
1266 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python_epfx,
1267 [ vi_cv_path_python_epfx=`
1268 ${vi_cv_path_python} -c \
1269 "import sys; print sys.exec_prefix"` ])
1270
1271 dnl -- python's internal library path
1272
1273 AC_CACHE_VAL(vi_cv_path_pythonpath,
1274 [ vi_cv_path_pythonpath=`
1275 unset PYTHONPATH;
1276 ${vi_cv_path_python} -c \
1277 "import sys, string; print string.join(sys.path,':')"` ])
1278
1279 dnl -- where the Python implementation library archives are
1280
1281 AC_ARG_WITH(python-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001282 [ --with-python-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001283 [ vi_cv_path_python_conf="${withval}"; have_python_config_dir=1 ] )
Bram Moolenaar071d4272004-06-13 20:20:40 +00001284
1285 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python_conf,
1286 [
1287 vi_cv_path_python_conf=
Bram Moolenaarac499e32013-06-02 19:14:17 +02001288 d=`${vi_cv_path_python} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBPL')"`
1289 if test -d "$d" && test -f "$d/config.c"; then
1290 vi_cv_path_python_conf="$d"
1291 else
1292 for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
1293 for subdir in lib64 lib share; do
1294 d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
1295 if test -d "$d" && test -f "$d/config.c"; then
1296 vi_cv_path_python_conf="$d"
1297 fi
1298 done
Bram Moolenaar071d4272004-06-13 20:20:40 +00001299 done
Bram Moolenaarac499e32013-06-02 19:14:17 +02001300 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001301 ])
1302
1303 PYTHON_CONFDIR="${vi_cv_path_python_conf}"
1304
1305 if test "X$PYTHON_CONFDIR" = "X"; then
1306 AC_MSG_RESULT([can't find it!])
1307 else
1308
1309 dnl -- we need to examine Python's config/Makefile too
1310 dnl see what the interpreter is built from
1311 AC_CACHE_VAL(vi_cv_path_python_plibs,
1312 [
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001313 pwd=`pwd`
1314 tmp_mkf="$pwd/config-PyMake$$"
1315 cat -- "${PYTHON_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001316__:
Bram Moolenaar218116c2010-05-20 21:46:00 +02001317 @echo "python_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001318 @echo "python_LIBS='$(LIBS)'"
1319 @echo "python_SYSLIBS='$(SYSLIBS)'"
1320 @echo "python_LINKFORSHARED='$(LINKFORSHARED)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001321 @echo "python_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001322 @echo "python_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001323 @echo "python_PYTHONFRAMEWORK='$(PYTHONFRAMEWORK)'"
1324 @echo "python_PYTHONFRAMEWORKPREFIX='$(PYTHONFRAMEWORKPREFIX)'"
1325 @echo "python_PYTHONFRAMEWORKINSTALLDIR='$(PYTHONFRAMEWORKINSTALLDIR)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001326eof
1327 dnl -- delete the lines from make about Entering/Leaving directory
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001328 eval "`cd ${PYTHON_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1329 rm -f -- "${tmp_mkf}"
Bram Moolenaard0573012017-10-28 21:11:06 +02001330 if test "x$MACOS_X" = "xyes" && test -n "${python_PYTHONFRAMEWORK}" && ${vi_cv_path_python} -c \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001331 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then
1332 vi_cv_path_python_plibs="-framework Python"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001333 if test "x${vi_cv_path_python}" != "x/usr/bin/python" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
1334 vi_cv_path_python_plibs="-F${python_PYTHONFRAMEWORKPREFIX} -framework Python"
1335 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001336 else
Bram Moolenaar9ce42132018-04-11 22:19:36 +02001337 vi_cv_path_python_plibs="-L${PYTHON_CONFDIR} -lpython${vi_cv_var_python_version}"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001338 dnl -- Check if the path contained in python_LINKFORSHARED is
1339 dnl usable for vim build. If not, make and try other
1340 dnl candidates.
Bram Moolenaara161e262015-03-24 15:14:27 +01001341 if test -n "${python_LINKFORSHARED}" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
Bram Moolenaar6c927552015-03-24 12:21:33 +01001342 python_link_symbol=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]].*/\1/'`
1343 python_link_path=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]][[ \t]]*\(.*\)/\2/'`
1344 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1345 dnl -- The path looks relative. Guess the absolute one using
1346 dnl the prefix and try that.
1347 python_link_path="${python_PYTHONFRAMEWORKPREFIX}/${python_link_path}"
1348 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1349 dnl -- A last resort.
1350 python_link_path="${python_PYTHONFRAMEWORKINSTALLDIR}/Versions/${vi_cv_var_python_version}/${python_PYTHONFRAMEWORK}"
1351 dnl -- No check is done. The last word is left to the
1352 dnl "sanity" test on link flags that follows shortly.
1353 fi
1354 python_LINKFORSHARED="${python_link_symbol} ${python_link_path}"
1355 fi
1356 fi
Bram Moolenaar218116c2010-05-20 21:46:00 +02001357 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 +00001358 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1359 vi_cv_path_python_plibs=`echo $vi_cv_path_python_plibs | sed s/-ltermcap//`
1360 fi
1361 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001362 AC_CACHE_CHECK(Python's dll name,vi_cv_dll_name_python,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001363 [
1364 if test "X$python_DLLLIBRARY" != "X"; then
1365 vi_cv_dll_name_python="$python_DLLLIBRARY"
1366 else
1367 vi_cv_dll_name_python="$python_INSTSONAME"
1368 fi
1369 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00001370
1371 PYTHON_LIBS="${vi_cv_path_python_plibs}"
1372 if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001373 PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001374 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001375 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 +00001376 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001377 if test "X$have_python_config_dir" = "X1" -a "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001378 dnl Define PYTHON_HOME if --with-python-config-dir was used
1379 PYTHON_CFLAGS="${PYTHON_CFLAGS} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'"
1380
1381 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001382 PYTHON_SRC="if_python.c"
Bram Moolenaar9bdb9a02012-07-25 16:32:08 +02001383 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001384
1385 dnl On FreeBSD linking with "-pthread" is required to use threads.
1386 dnl _THREAD_SAFE must be used for compiling then.
1387 dnl The "-pthread" is added to $LIBS, so that the following check for
1388 dnl sigaltstack() will look in libc_r (it's there in libc!).
1389 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1390 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1391 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1392 AC_MSG_CHECKING([if -pthread should be used])
1393 threadsafe_flag=
1394 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001395 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001396 if test "$vim_cv_uname_output" != Darwin; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001397 test "$GCC" = yes && threadsafe_flag="-pthread"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001398 if test "$vim_cv_uname_output" = FreeBSD; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001399 threadsafe_flag="-D_THREAD_SAFE"
1400 thread_lib="-pthread"
1401 fi
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001402 if test "$vim_cv_uname_output" = SunOS; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001403 threadsafe_flag="-pthreads"
1404 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001405 fi
1406 libs_save_old=$LIBS
1407 if test -n "$threadsafe_flag"; then
1408 cflags_save=$CFLAGS
1409 CFLAGS="$CFLAGS $threadsafe_flag"
1410 LIBS="$LIBS $thread_lib"
1411 AC_TRY_LINK(,[ ],
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001412 AC_MSG_RESULT(yes); PYTHON_CFLAGS="$PYTHON_CFLAGS $threadsafe_flag",
Bram Moolenaar071d4272004-06-13 20:20:40 +00001413 AC_MSG_RESULT(no); LIBS=$libs_save_old
1414 )
1415 CFLAGS=$cflags_save
1416 else
1417 AC_MSG_RESULT(no)
1418 fi
1419
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001420 dnl Check that compiling a simple program still works with the flags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001421 dnl added for Python.
1422 AC_MSG_CHECKING([if compile and link flags for Python are sane])
1423 cflags_save=$CFLAGS
1424 libs_save=$LIBS
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001425 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001426 LIBS="$LIBS $PYTHON_LIBS"
1427 AC_TRY_LINK(,[ ],
1428 AC_MSG_RESULT(yes); python_ok=yes,
1429 AC_MSG_RESULT(no: PYTHON DISABLED); python_ok=no)
1430 CFLAGS=$cflags_save
1431 LIBS=$libs_save
1432 if test $python_ok = yes; then
1433 AC_DEFINE(FEAT_PYTHON)
1434 else
1435 LIBS=$libs_save_old
1436 PYTHON_SRC=
1437 PYTHON_OBJ=
1438 PYTHON_LIBS=
1439 PYTHON_CFLAGS=
1440 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001441 fi
1442 else
1443 AC_MSG_RESULT(too old)
1444 fi
1445 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001446
1447 if test "$fail_if_missing" = "yes" -a "$python_ok" != "yes"; then
1448 AC_MSG_ERROR([could not configure python])
1449 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001450fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001451
Bram Moolenaar071d4272004-06-13 20:20:40 +00001452AC_SUBST(PYTHON_LIBS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001453AC_SUBST(PYTHON_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00001454AC_SUBST(PYTHON_CFLAGS_EXTRA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001455AC_SUBST(PYTHON_SRC)
1456AC_SUBST(PYTHON_OBJ)
1457
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001458
1459AC_MSG_CHECKING(--enable-python3interp argument)
1460AC_ARG_ENABLE(python3interp,
Bram Moolenaar8008b632017-07-18 21:33:20 +02001461 [ --enable-python3interp[=OPTS] Include Python3 interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001462 [enable_python3interp="no"])
1463AC_MSG_RESULT($enable_python3interp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001464if test "$enable_python3interp" = "yes" -o "$enable_python3interp" = "dynamic"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00001465 if test "$has_eval" = "no"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001466 AC_MSG_ERROR([cannot use Python with tiny or small features])
1467 fi
1468
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001469 dnl -- find the python3 executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001470 AC_MSG_CHECKING(--with-python3-command argument)
1471 AC_SUBST(vi_cv_path_python3)
1472 AC_ARG_WITH(python3-command, [ --with-python3-command=NAME name of the Python 3 command (default: python3 or python)],
1473 vi_cv_path_python3="$withval"; AC_MSG_RESULT($vi_cv_path_python3),
1474 AC_MSG_RESULT(no))
1475
1476 if test "X$vi_cv_path_python3" = "X"; then
1477 AC_PATH_PROGS(vi_cv_path_python3, python3 python)
1478 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001479 if test "X$vi_cv_path_python3" != "X"; then
1480
1481 dnl -- get its version number
1482 AC_CACHE_CHECK(Python version,vi_cv_var_python3_version,
1483 [[vi_cv_var_python3_version=`
Bram Moolenaar23c01922021-05-21 11:43:58 +02001484 ${vi_cv_path_python3} -c 'import sys; print("{}.{}".format(sys.version_info.major, sys.version_info.minor))'`
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001485 ]])
1486
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001487 dnl -- it must be at least version 3
1488 AC_MSG_CHECKING(Python is 3.0 or better)
1489 if ${vi_cv_path_python3} -c \
1490 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.0)"
1491 then
1492 AC_MSG_RESULT(yep)
Bram Moolenaar456f2bb2011-06-12 21:37:13 +02001493
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001494 dnl -- get abiflags for python 3.2 or higher (PEP 3149)
1495 AC_CACHE_CHECK(Python's abiflags,vi_cv_var_python3_abiflags,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001496 [
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001497 vi_cv_var_python3_abiflags=
1498 if ${vi_cv_path_python3} -c \
1499 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)"
1500 then
1501 vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \
1502 "import sys; print(sys.abiflags)"`
1503 fi ])
1504
1505 dnl -- find where python3 thinks it was installed
1506 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx,
1507 [ vi_cv_path_python3_pfx=`
1508 ${vi_cv_path_python3} -c \
1509 "import sys; print(sys.prefix)"` ])
1510
1511 dnl -- and where it thinks it runs
1512 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx,
1513 [ vi_cv_path_python3_epfx=`
1514 ${vi_cv_path_python3} -c \
1515 "import sys; print(sys.exec_prefix)"` ])
1516
1517 dnl -- python3's internal library path
1518
1519 AC_CACHE_VAL(vi_cv_path_python3path,
1520 [ vi_cv_path_python3path=`
1521 unset PYTHONPATH;
1522 ${vi_cv_path_python3} -c \
1523 "import sys, string; print(':'.join(sys.path))"` ])
1524
1525 dnl -- where the Python implementation library archives are
1526
1527 AC_ARG_WITH(python3-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001528 [ --with-python3-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001529 [ vi_cv_path_python3_conf="${withval}"; have_python3_config_dir=1 ] )
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001530
1531 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf,
1532 [
1533 vi_cv_path_python3_conf=
Bram Moolenaarfee496d2013-07-12 20:07:24 +02001534 config_dir="config-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Zdenek Dohnal31e299c2021-06-10 18:50:55 +02001535 d=`${vi_cv_path_python3} -c "import sysconfig; print(sysconfig.get_config_var('LIBPL'))" 2> /dev/null`
1536 if test "x$d" = "x"; then
1537 d=`${vi_cv_path_python3} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBPL'))"`
1538 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001539 if test -d "$d" && test -f "$d/config.c"; then
1540 vi_cv_path_python3_conf="$d"
1541 else
1542 for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do
1543 for subdir in lib64 lib share; do
1544 d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}"
1545 if test -d "$d" && test -f "$d/config.c"; then
1546 vi_cv_path_python3_conf="$d"
1547 fi
1548 done
1549 done
1550 fi
1551 ])
1552
1553 PYTHON3_CONFDIR="${vi_cv_path_python3_conf}"
1554
1555 if test "X$PYTHON3_CONFDIR" = "X"; then
1556 AC_MSG_RESULT([can't find it!])
1557 else
1558
1559 dnl -- we need to examine Python's config/Makefile too
1560 dnl see what the interpreter is built from
1561 AC_CACHE_VAL(vi_cv_path_python3_plibs,
1562 [
1563 pwd=`pwd`
1564 tmp_mkf="$pwd/config-PyMake$$"
1565 cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001566__:
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001567 @echo "python3_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001568 @echo "python3_LIBS='$(LIBS)'"
1569 @echo "python3_SYSLIBS='$(SYSLIBS)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001570 @echo "python3_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001571 @echo "python3_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001572eof
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001573 dnl -- delete the lines from make about Entering/Leaving directory
1574 eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1575 rm -f -- "${tmp_mkf}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001576 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 +02001577 vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}"
1578 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1579 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//`
1580 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//`
1581 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001582 AC_CACHE_CHECK(Python3's dll name,vi_cv_dll_name_python3,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001583 [
1584 if test "X$python3_DLLLIBRARY" != "X"; then
1585 vi_cv_dll_name_python3="$python3_DLLLIBRARY"
1586 else
1587 vi_cv_dll_name_python3="$python3_INSTSONAME"
1588 fi
1589 ])
1590
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001591 PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
1592 if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001593 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 +02001594 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001595 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 +02001596 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001597 if test "X$have_python3_config_dir" = "X1" -a "$enable_python3interp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001598 dnl Define PYTHON3_HOME if --with-python-config-dir was used
1599 PYTHON3_CFLAGS="${PYTHON3_CFLAGS} -DPYTHON3_HOME='L\"${vi_cv_path_python3_pfx}\"'"
1600 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001601 PYTHON3_SRC="if_python3.c"
1602 PYTHON3_OBJ="objects/if_python3.o"
1603
1604 dnl On FreeBSD linking with "-pthread" is required to use threads.
1605 dnl _THREAD_SAFE must be used for compiling then.
1606 dnl The "-pthread" is added to $LIBS, so that the following check for
1607 dnl sigaltstack() will look in libc_r (it's there in libc!).
1608 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1609 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1610 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1611 AC_MSG_CHECKING([if -pthread should be used])
1612 threadsafe_flag=
1613 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001614 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001615 if test "$vim_cv_uname_output" != Darwin; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001616 test "$GCC" = yes && threadsafe_flag="-pthread"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001617 if test "$vim_cv_uname_output" = FreeBSD; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001618 threadsafe_flag="-D_THREAD_SAFE"
1619 thread_lib="-pthread"
1620 fi
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001621 if test "$vim_cv_uname_output" = SunOS; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001622 threadsafe_flag="-pthreads"
1623 fi
1624 fi
1625 libs_save_old=$LIBS
1626 if test -n "$threadsafe_flag"; then
1627 cflags_save=$CFLAGS
1628 CFLAGS="$CFLAGS $threadsafe_flag"
1629 LIBS="$LIBS $thread_lib"
1630 AC_TRY_LINK(,[ ],
1631 AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag",
1632 AC_MSG_RESULT(no); LIBS=$libs_save_old
1633 )
1634 CFLAGS=$cflags_save
1635 else
1636 AC_MSG_RESULT(no)
1637 fi
1638
1639 dnl check that compiling a simple program still works with the flags
1640 dnl added for Python.
1641 AC_MSG_CHECKING([if compile and link flags for Python 3 are sane])
1642 cflags_save=$CFLAGS
1643 libs_save=$LIBS
1644 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1645 LIBS="$LIBS $PYTHON3_LIBS"
1646 AC_TRY_LINK(,[ ],
1647 AC_MSG_RESULT(yes); python3_ok=yes,
1648 AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no)
1649 CFLAGS=$cflags_save
1650 LIBS=$libs_save
1651 if test "$python3_ok" = yes; then
1652 AC_DEFINE(FEAT_PYTHON3)
1653 else
1654 LIBS=$libs_save_old
1655 PYTHON3_SRC=
1656 PYTHON3_OBJ=
1657 PYTHON3_LIBS=
1658 PYTHON3_CFLAGS=
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001659 fi
1660 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001661 else
1662 AC_MSG_RESULT(too old)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001663 fi
1664 fi
Bram Moolenaar1612b1a2013-06-14 21:22:39 +02001665 if test "$fail_if_missing" = "yes" -a "$python3_ok" != "yes"; then
1666 AC_MSG_ERROR([could not configure python3])
1667 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001668fi
1669
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001670AC_SUBST(PYTHON3_LIBS)
1671AC_SUBST(PYTHON3_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00001672AC_SUBST(PYTHON3_CFLAGS_EXTRA)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001673AC_SUBST(PYTHON3_SRC)
1674AC_SUBST(PYTHON3_OBJ)
1675
1676dnl if python2.x and python3.x are enabled one can only link in code
1677dnl with dlopen(), dlsym(), dlclose()
1678if test "$python_ok" = yes && test "$python3_ok" = yes; then
1679 AC_DEFINE(DYNAMIC_PYTHON)
1680 AC_DEFINE(DYNAMIC_PYTHON3)
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001681 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001682 cflags_save=$CFLAGS
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001683 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001684 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001685 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001686 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001687 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001688 #include <dlfcn.h>
1689 /* If this program fails, then RTLD_GLOBAL is needed.
1690 * RTLD_GLOBAL will be used and then it is not possible to
1691 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001692 * Only the first python version used will be switched on.
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001693 */
1694
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001695 int no_rtl_global_needed_for(char *python_instsoname, char *prefix)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001696 {
1697 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001698 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001699 if (pylib != 0)
1700 {
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001701 void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome");
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001702 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1703 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1704 void (*final)(void) = dlsym(pylib, "Py_Finalize");
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001705 (*pfx)(prefix);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001706 (*init)();
1707 needed = (*simple)("import termios") == -1;
1708 (*final)();
1709 dlclose(pylib);
1710 }
1711 return !needed;
1712 }
1713
1714 int main(int argc, char** argv)
1715 {
1716 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001717 if (no_rtl_global_needed_for("${vi_cv_dll_name_python}", "${vi_cv_path_python_pfx}"))
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001718 not_needed = 1;
1719 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001720 }])],
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001721 [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001722
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001723 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001724 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001725
1726 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python3)
1727 cflags_save=$CFLAGS
1728 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001729 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001730 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001731 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001732 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001733 #include <dlfcn.h>
1734 #include <wchar.h>
1735 /* If this program fails, then RTLD_GLOBAL is needed.
1736 * RTLD_GLOBAL will be used and then it is not possible to
1737 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001738 * Only the first python version used will be switched on.
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001739 */
1740
1741 int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix)
1742 {
1743 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001744 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001745 if (pylib != 0)
1746 {
1747 void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome");
1748 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1749 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1750 void (*final)(void) = dlsym(pylib, "Py_Finalize");
1751 (*pfx)(prefix);
1752 (*init)();
1753 needed = (*simple)("import termios") == -1;
1754 (*final)();
1755 dlclose(pylib);
1756 }
1757 return !needed;
1758 }
1759
1760 int main(int argc, char** argv)
1761 {
1762 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001763 if (no_rtl_global_needed_for("${vi_cv_dll_name_python3}", L"${vi_cv_path_python3_pfx}"))
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001764 not_needed = 1;
1765 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001766 }])],
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001767 [AC_MSG_RESULT(yes);AC_DEFINE(PY3_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
1768
1769 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001770 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001771
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001772 PYTHON_SRC="if_python.c"
1773 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001774 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001775 PYTHON_LIBS=
1776 PYTHON3_SRC="if_python3.c"
1777 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001778 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001779 PYTHON3_LIBS=
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001780elif test "$python_ok" = yes && test "$enable_pythoninterp" = "dynamic"; then
1781 AC_DEFINE(DYNAMIC_PYTHON)
1782 PYTHON_SRC="if_python.c"
1783 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001784 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001785 PYTHON_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001786elif test "$python_ok" = yes; then
1787 dnl Check that adding -fPIE works. It may be needed when using a static
1788 dnl Python library.
1789 AC_MSG_CHECKING([if -fPIE can be added for Python])
1790 cflags_save=$CFLAGS
1791 libs_save=$LIBS
1792 CFLAGS="$CFLAGS $PYTHON_CFLAGS -fPIE"
1793 LIBS="$LIBS $PYTHON_LIBS"
1794 AC_TRY_LINK(,[ ],
1795 AC_MSG_RESULT(yes); fpie_ok=yes,
1796 AC_MSG_RESULT(no); fpie_ok=no)
1797 CFLAGS=$cflags_save
1798 LIBS=$libs_save
1799 if test $fpie_ok = yes; then
1800 PYTHON_CFLAGS="$PYTHON_CFLAGS -fPIE"
1801 fi
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001802elif test "$python3_ok" = yes && test "$enable_python3interp" = "dynamic"; then
1803 AC_DEFINE(DYNAMIC_PYTHON3)
1804 PYTHON3_SRC="if_python3.c"
1805 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001806 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001807 PYTHON3_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001808elif test "$python3_ok" = yes; then
1809 dnl Check that adding -fPIE works. It may be needed when using a static
1810 dnl Python library.
1811 AC_MSG_CHECKING([if -fPIE can be added for Python3])
1812 cflags_save=$CFLAGS
1813 libs_save=$LIBS
1814 CFLAGS="$CFLAGS $PYTHON3_CFLAGS -fPIE"
1815 LIBS="$LIBS $PYTHON3_LIBS"
1816 AC_TRY_LINK(,[ ],
1817 AC_MSG_RESULT(yes); fpie_ok=yes,
1818 AC_MSG_RESULT(no); fpie_ok=no)
1819 CFLAGS=$cflags_save
1820 LIBS=$libs_save
1821 if test $fpie_ok = yes; then
1822 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -fPIE"
1823 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001824fi
1825
Bram Moolenaar071d4272004-06-13 20:20:40 +00001826AC_MSG_CHECKING(--enable-tclinterp argument)
1827AC_ARG_ENABLE(tclinterp,
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001828 [ --enable-tclinterp[=OPTS] Include Tcl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001829 [enable_tclinterp="no"])
1830AC_MSG_RESULT($enable_tclinterp)
1831
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001832if test "$enable_tclinterp" = "yes" -o "$enable_tclinterp" = "dynamic"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001833
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001834 dnl on FreeBSD tclsh is a silly script, look for tclsh8.[5420]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001835 AC_MSG_CHECKING(--with-tclsh argument)
1836 AC_ARG_WITH(tclsh, [ --with-tclsh=PATH which tclsh to use (default: tclsh8.0)],
1837 tclsh_name="$withval"; AC_MSG_RESULT($tclsh_name),
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001838 tclsh_name="tclsh8.5"; AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00001839 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1840 AC_SUBST(vi_cv_path_tcl)
1841
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001842 dnl when no specific version specified, also try 8.4, 8.2 and 8.0
1843 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.5"; then
1844 tclsh_name="tclsh8.4"
1845 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1846 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001847 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.4"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001848 tclsh_name="tclsh8.2"
1849 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1850 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001851 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.2"; then
1852 tclsh_name="tclsh8.0"
1853 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1854 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001855 dnl still didn't find it, try without version number
1856 if test "X$vi_cv_path_tcl" = "X"; then
1857 tclsh_name="tclsh"
1858 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1859 fi
1860 if test "X$vi_cv_path_tcl" != "X"; then
1861 AC_MSG_CHECKING(Tcl version)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001862 if echo 'exit [[expr [info tclversion] < 8.0]]' | "$vi_cv_path_tcl" - ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001863 tclver=`echo 'puts [[info tclversion]]' | $vi_cv_path_tcl -`
1864 AC_MSG_RESULT($tclver - OK);
1865 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 +01001866 tcldll=`echo 'puts libtcl[[info tclversion]][[info sharedlibextension]]' | $vi_cv_path_tcl -`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001867
1868 AC_MSG_CHECKING(for location of Tcl include)
Bram Moolenaard0573012017-10-28 21:11:06 +02001869 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001870 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 +00001871 else
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001872 dnl For all macOS, use the value from TCL in case use of, say, homebrew
Bram Moolenaar071d4272004-06-13 20:20:40 +00001873 dnl For Mac OS X 10.3, use the OS-provided framework location
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001874 dnl For Mac OS X 10.14, the OS-provided framework location doesn't contain the headers, so also check the Xcode SDK
1875 tclinc="$tclloc/include $tclloc/include/tcl $tclloc/include/tcl$tclver /System/Library/Frameworks/Tcl.framework/Headers `xcrun --show-sdk-path`/System/Library/Frameworks/Tcl.framework/Versions/Current/Headers"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001876 fi
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001877 TCL_INC=
Bram Moolenaar071d4272004-06-13 20:20:40 +00001878 for try in $tclinc; do
1879 if test -f "$try/tcl.h"; then
1880 AC_MSG_RESULT($try/tcl.h)
1881 TCL_INC=$try
1882 break
1883 fi
1884 done
1885 if test -z "$TCL_INC"; then
1886 AC_MSG_RESULT(<not found>)
1887 SKIP_TCL=YES
1888 fi
1889 if test -z "$SKIP_TCL"; then
1890 AC_MSG_CHECKING(for location of tclConfig.sh script)
Bram Moolenaard0573012017-10-28 21:11:06 +02001891 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001892 tclcnf=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001893 tclcnf="$tclcnf `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001894 else
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001895 dnl For all macOS, use the value from TCL in case use of, say, homebrew
Bram Moolenaar071d4272004-06-13 20:20:40 +00001896 dnl For Mac OS X 10.3, use the OS-provided framework location
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001897 dnl For Mac OS X 10.14, the OS-provided framework location doesn't contain the headers, so also check the Xcode SDK
1898 tclcnf=`echo $tclinc | sed s/include/lib/g`
1899 tclcnf="$tclcnf /System/Library/Frameworks/Tcl.framework `xcrun --show-sdk-path`/System/Library/Frameworks/Tcl.framework"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001900 fi
1901 for try in $tclcnf; do
Bram Moolenaar49222be2015-12-11 18:11:30 +01001902 if test -f "$try/tclConfig.sh"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001903 AC_MSG_RESULT($try/tclConfig.sh)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001904 . "$try/tclConfig.sh"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001905 dnl use eval, because tcl 8.2 includes ${TCL_DBGX}
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001906 if test "$enable_tclinterp" = "dynamic"; then
1907 TCL_LIBS=`eval echo "$TCL_STUB_LIB_SPEC $TCL_LIBS"`
1908 else
1909 TCL_LIBS=`eval echo "$TCL_LIB_SPEC $TCL_LIBS"`
1910 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001911 dnl Use $TCL_DEFS for -D_THREAD_SAFE et al. But only use the
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001912 dnl "-D_ABC" items. Watch out for -DFOO=long\ long.
Bram Moolenaar4394bff2008-07-24 11:21:31 +00001913 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 +00001914 break
1915 fi
1916 done
1917 if test -z "$TCL_LIBS"; then
1918 AC_MSG_RESULT(<not found>)
1919 AC_MSG_CHECKING(for Tcl library by myself)
1920 tcllib=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001921 tcllib="$tcllib `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001922 for ext in .so .a ; do
1923 for ver in "" $tclver ; do
1924 for try in $tcllib ; do
1925 trylib=tcl$ver$ext
Bram Moolenaar49222be2015-12-11 18:11:30 +01001926 if test -f "$try/lib$trylib" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001927 AC_MSG_RESULT($try/lib$trylib)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001928 TCL_LIBS="-L\"$try\" -ltcl$ver -ldl -lm"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001929 if test "$vim_cv_uname_output" = SunOS &&
1930 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001931 TCL_LIBS="$TCL_LIBS -R $try"
1932 fi
1933 break 3
1934 fi
1935 done
1936 done
1937 done
1938 if test -z "$TCL_LIBS"; then
1939 AC_MSG_RESULT(<not found>)
1940 SKIP_TCL=YES
1941 fi
1942 fi
1943 if test -z "$SKIP_TCL"; then
1944 AC_DEFINE(FEAT_TCL)
1945 TCL_SRC=if_tcl.c
1946 TCL_OBJ=objects/if_tcl.o
1947 TCL_PRO=if_tcl.pro
1948 TCL_CFLAGS="-I$TCL_INC $TCL_DEFS"
1949 fi
1950 fi
1951 else
1952 AC_MSG_RESULT(too old; need Tcl version 8.0 or later)
1953 fi
1954 fi
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001955 if test "$enable_tclinterp" = "dynamic"; then
1956 if test "X$TCL_SRC" != "X" -a "X$tcldll" != "X"; then
1957 AC_DEFINE(DYNAMIC_TCL)
1958 TCL_CFLAGS="-DDYNAMIC_TCL_DLL=\\\"$tcldll\\\" -DDYNAMIC_TCL_VER=\\\"$tclver\\\" $TCL_CFLAGS"
1959 fi
1960 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001961 if test "$fail_if_missing" = "yes" -a -z "$TCL_SRC"; then
1962 AC_MSG_ERROR([could not configure Tcl])
1963 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001964fi
1965AC_SUBST(TCL_SRC)
1966AC_SUBST(TCL_OBJ)
1967AC_SUBST(TCL_PRO)
1968AC_SUBST(TCL_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00001969AC_SUBST(TCL_CFLAGS_EXTRA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001970AC_SUBST(TCL_LIBS)
1971
1972AC_MSG_CHECKING(--enable-rubyinterp argument)
1973AC_ARG_ENABLE(rubyinterp,
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001974 [ --enable-rubyinterp[=OPTS] Include Ruby interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001975 [enable_rubyinterp="no"])
1976AC_MSG_RESULT($enable_rubyinterp)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001977if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00001978 if test "$has_eval" = "no"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001979 AC_MSG_ERROR([cannot use Ruby with tiny or small features])
1980 fi
1981
Bram Moolenaar165641d2010-02-17 16:23:09 +01001982 AC_MSG_CHECKING(--with-ruby-command argument)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001983 AC_SUBST(vi_cv_path_ruby)
Bram Moolenaar948733a2011-05-05 18:10:16 +02001984 AC_ARG_WITH(ruby-command, [ --with-ruby-command=RUBY name of the Ruby command (default: ruby)],
1985 RUBY_CMD="$withval"; vi_cv_path_ruby="$withval"; AC_MSG_RESULT($RUBY_CMD),
1986 RUBY_CMD="ruby"; AC_MSG_RESULT(defaulting to $RUBY_CMD))
Bram Moolenaar165641d2010-02-17 16:23:09 +01001987 AC_PATH_PROG(vi_cv_path_ruby, $RUBY_CMD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001988 if test "X$vi_cv_path_ruby" != "X"; then
1989 AC_MSG_CHECKING(Ruby version)
Bram Moolenaare4efc3b2005-03-07 23:16:51 +00001990 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 +00001991 AC_MSG_RESULT(OK)
Bram Moolenaar81398892012-10-03 21:09:35 +02001992 AC_MSG_CHECKING(Ruby rbconfig)
1993 ruby_rbconfig="RbConfig"
1994 if ! $vi_cv_path_ruby -r rbconfig -e 'RbConfig' >/dev/null 2>/dev/null; then
1995 ruby_rbconfig="Config"
1996 fi
1997 AC_MSG_RESULT($ruby_rbconfig)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001998 AC_MSG_CHECKING(Ruby header files)
Bram Moolenaar81398892012-10-03 21:09:35 +02001999 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 +00002000 if test "X$rubyhdrdir" != "X"; then
2001 AC_MSG_RESULT($rubyhdrdir)
2002 RUBY_CFLAGS="-I$rubyhdrdir"
Bram Moolenaara6fd37b2014-03-27 17:19:09 +01002003 rubyarchdir=`$vi_cv_path_ruby -r rbconfig -e "print ($ruby_rbconfig::CONFIG.has_key? 'rubyarchhdrdir') ? $ruby_rbconfig::CONFIG[['rubyarchhdrdir']] : '$rubyhdrdir/'+$ruby_rbconfig::CONFIG[['arch']]"`
2004 if test -d "$rubyarchdir"; then
2005 RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyarchdir"
Bram Moolenaar165641d2010-02-17 16:23:09 +01002006 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02002007 rubyversion=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['ruby_version']].gsub(/\./, '')[[0,2]]"`
Bram Moolenaar026a4452013-08-07 15:22:23 +02002008 if test "X$rubyversion" = "X"; then
2009 rubyversion=`$vi_cv_path_ruby -e "print ((VERSION rescue RUBY_VERSION)).gsub(/\./, '')[[0,2]]"`
2010 fi
Bram Moolenaar165641d2010-02-17 16:23:09 +01002011 RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
Bram Moolenaar81398892012-10-03 21:09:35 +02002012 rubylibs=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LIBS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002013 if test "X$rubylibs" != "X"; then
2014 RUBY_LIBS="$rubylibs"
2015 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02002016 librubyarg=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBYARG']])"`
2017 librubya=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBY_A']])"`
Bram Moolenaarac499e32013-06-02 19:14:17 +02002018 rubylibdir=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['libdir']])"`
Bram Moolenaard5a986f2020-12-06 21:11:31 +01002019 if test -f "$rubylibdir/$librubya" || expr "$librubyarg" : "-lruby"; then
Bram Moolenaarac499e32013-06-02 19:14:17 +02002020 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
2021 elif test "$librubyarg" = "libruby.a"; then
2022 dnl required on Mac OS 10.3 where libruby.a doesn't exist
2023 librubyarg="-lruby"
2024 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002025 fi
2026
2027 if test "X$librubyarg" != "X"; then
2028 RUBY_LIBS="$librubyarg $RUBY_LIBS"
2029 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02002030 rubyldflags=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LDFLAGS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002031 if test "X$rubyldflags" != "X"; then
Bram Moolenaar996b6d82009-07-22 09:17:23 +00002032 dnl Ruby on Mac OS X 10.5 adds "-arch" flags but these should only
2033 dnl be included if requested by passing --with-mac-arch to
2034 dnl configure, so strip these flags first (if present)
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02002035 rubyldflags=`echo "$rubyldflags" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
Bram Moolenaar996b6d82009-07-22 09:17:23 +00002036 if test "X$rubyldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01002037 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$rubyldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02002038 LDFLAGS="$rubyldflags $LDFLAGS"
2039 fi
Bram Moolenaar996b6d82009-07-22 09:17:23 +00002040 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002041 fi
2042 RUBY_SRC="if_ruby.c"
2043 RUBY_OBJ="objects/if_ruby.o"
2044 RUBY_PRO="if_ruby.pro"
2045 AC_DEFINE(FEAT_RUBY)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002046 if test "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar92021622017-10-12 12:33:43 +02002047 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_ALIASES']].split[[0]]"`
Bram Moolenaar87ea64c2018-08-04 15:13:34 +02002048 if test -z "$libruby_soname"; then
2049 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_SO']]"`
2050 fi
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002051 AC_DEFINE(DYNAMIC_RUBY)
Bram Moolenaar41a41412020-01-07 21:32:19 +01002052 RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby_soname\\\" $RUBY_CFLAGS"
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002053 RUBY_LIBS=
2054 fi
Bram Moolenaar864a28b2020-12-28 21:36:56 +01002055 if test "X$CLANG_VERSION" != "X" -a "$rubyversion" -ge 30; then
2056 RUBY_CFLAGS="$RUBY_CFLAGS -fdeclspec"
2057 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002058 else
Bram Moolenaar165641d2010-02-17 16:23:09 +01002059 AC_MSG_RESULT(not found; disabling Ruby)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002060 fi
2061 else
2062 AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
2063 fi
2064 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01002065
2066 if test "$fail_if_missing" = "yes" -a -z "$RUBY_OBJ"; then
2067 AC_MSG_ERROR([could not configure Ruby])
2068 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002069fi
2070AC_SUBST(RUBY_SRC)
2071AC_SUBST(RUBY_OBJ)
2072AC_SUBST(RUBY_PRO)
2073AC_SUBST(RUBY_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00002074AC_SUBST(RUBY_CFLAGS_EXTRA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002075AC_SUBST(RUBY_LIBS)
2076
2077AC_MSG_CHECKING(--enable-cscope argument)
2078AC_ARG_ENABLE(cscope,
2079 [ --enable-cscope Include cscope interface.], ,
2080 [enable_cscope="no"])
2081AC_MSG_RESULT($enable_cscope)
2082if test "$enable_cscope" = "yes"; then
2083 AC_DEFINE(FEAT_CSCOPE)
2084fi
2085
Bram Moolenaar071d4272004-06-13 20:20:40 +00002086AC_MSG_CHECKING(--disable-netbeans argument)
2087AC_ARG_ENABLE(netbeans,
2088 [ --disable-netbeans Disable NetBeans integration support.],
2089 , [enable_netbeans="yes"])
2090if test "$enable_netbeans" = "yes"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00002091 if test "$has_eval" = "no"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002092 AC_MSG_RESULT([cannot use NetBeans with tiny or small features])
2093 enable_netbeans="no"
2094 else
2095 AC_MSG_RESULT(no)
2096 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002097else
2098 AC_MSG_RESULT(yes)
2099fi
2100
2101AC_MSG_CHECKING(--disable-channel argument)
2102AC_ARG_ENABLE(channel,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002103 [ --disable-channel Disable process communication support.],
Bram Moolenaare0874f82016-01-24 20:36:41 +01002104 , [enable_channel="yes"])
2105if test "$enable_channel" = "yes"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00002106 if test "$has_eval" = "no"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002107 AC_MSG_RESULT([cannot use channels with tiny or small features])
2108 enable_channel="no"
2109 else
2110 AC_MSG_RESULT(no)
2111 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002112else
2113 if test "$enable_netbeans" = "yes"; then
Bram Moolenaar16435482016-01-24 21:31:54 +01002114 AC_MSG_RESULT([yes, netbeans also disabled])
Bram Moolenaare0874f82016-01-24 20:36:41 +01002115 enable_netbeans="no"
2116 else
2117 AC_MSG_RESULT(yes)
2118 fi
2119fi
2120
Bram Moolenaar16435482016-01-24 21:31:54 +01002121if test "$enable_channel" = "yes"; then
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002122 dnl On Solaris we need the socket library, or on Haiku the network library.
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002123 if test "x$HAIKU" = "xyes"; then
2124 AC_CHECK_LIB(network, socket)
2125 else
2126 AC_CHECK_LIB(socket, socket)
2127 fi
2128
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002129 AC_CACHE_CHECK([whether compiling with IPv6 networking is possible], [vim_cv_ipv6_networking],
2130 [AC_TRY_LINK([
2131#include <stdio.h>
2132#include <stdlib.h>
2133#include <stdarg.h>
2134#include <fcntl.h>
2135#include <netdb.h>
2136#include <netinet/in.h>
2137#include <errno.h>
2138#include <sys/types.h>
2139#include <sys/socket.h>
2140 /* Check bitfields */
2141 struct nbbuf {
2142 unsigned int initDone:1;
2143 unsigned short signmaplen;
2144 };
2145 ], [
2146 /* Check creating a socket. */
2147 struct sockaddr_in server;
2148 struct addrinfo *res;
2149 (void)socket(AF_INET, SOCK_STREAM, 0);
2150 (void)htons(100);
2151 (void)getaddrinfo("microsoft.com", NULL, NULL, &res);
2152 if (errno == ECONNREFUSED)
2153 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
2154 (void)freeaddrinfo(res);
2155 ],
2156 [vim_cv_ipv6_networking="yes"],
2157 [vim_cv_ipv6_networking="no"])])
2158
2159 if test "x$vim_cv_ipv6_networking" = "xyes"; then
2160 AC_DEFINE(FEAT_IPV6)
Bram Moolenaarb6fb0512020-04-18 18:24:18 +02002161 AC_CHECK_FUNCS(inet_ntop)
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002162 else
2163 dnl On Solaris we need the nsl library.
2164 AC_CHECK_LIB(nsl, gethostbyname)
2165 AC_CACHE_CHECK([whether compiling with IPv4 networking is possible], [vim_cv_ipv4_networking],
2166 [AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00002167#include <stdio.h>
2168#include <stdlib.h>
2169#include <stdarg.h>
2170#include <fcntl.h>
2171#include <netdb.h>
2172#include <netinet/in.h>
2173#include <errno.h>
2174#include <sys/types.h>
2175#include <sys/socket.h>
2176 /* Check bitfields */
2177 struct nbbuf {
2178 unsigned int initDone:1;
Bram Moolenaar63de19e2016-12-09 20:11:26 +01002179 unsigned short signmaplen;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002180 };
2181 ], [
2182 /* Check creating a socket. */
2183 struct sockaddr_in server;
2184 (void)socket(AF_INET, SOCK_STREAM, 0);
2185 (void)htons(100);
2186 (void)gethostbyname("microsoft.com");
2187 if (errno == ECONNREFUSED)
2188 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
2189 ],
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002190 [vim_cv_ipv4_networking="yes"],
2191 [vim_cv_ipv4_networking="no"; enable_netbeans="no"; enable_channel="no"])])
2192 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002193fi
2194if test "$enable_netbeans" = "yes"; then
2195 AC_DEFINE(FEAT_NETBEANS_INTG)
2196 NETBEANS_SRC="netbeans.c"
2197 AC_SUBST(NETBEANS_SRC)
2198 NETBEANS_OBJ="objects/netbeans.o"
2199 AC_SUBST(NETBEANS_OBJ)
2200fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002201if test "$enable_channel" = "yes"; then
Bram Moolenaar509ce2a2016-03-11 22:52:15 +01002202 AC_DEFINE(FEAT_JOB_CHANNEL)
Bram Moolenaar8b5866d2020-09-05 15:48:51 +02002203 CHANNEL_SRC="job.c channel.c"
Bram Moolenaare0874f82016-01-24 20:36:41 +01002204 AC_SUBST(CHANNEL_SRC)
Bram Moolenaar8b5866d2020-09-05 15:48:51 +02002205 CHANNEL_OBJ="objects/job.o objects/channel.o"
Bram Moolenaare0874f82016-01-24 20:36:41 +01002206 AC_SUBST(CHANNEL_OBJ)
2207fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002208
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002209AC_MSG_CHECKING(--enable-terminal argument)
2210AC_ARG_ENABLE(terminal,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002211 [ --enable-terminal Enable terminal emulation support.],
Bram Moolenaaref839562017-10-28 20:28:23 +02002212 , [enable_terminal="auto"])
Bram Moolenaar595a4022017-09-03 19:15:57 +02002213if test "$enable_terminal" = "yes" || test "$enable_terminal" = "auto" -a "x$features" = "xhuge" ; then
Bram Moolenaar12471262022-01-18 11:11:25 +00002214 if test "$has_eval" = "no"; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002215 AC_MSG_RESULT([cannot use terminal emulator with tiny or small features])
2216 enable_terminal="no"
2217 else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002218 if test "$enable_terminal" = "auto"; then
2219 enable_terminal="yes"
2220 AC_MSG_RESULT(defaulting to yes)
2221 else
2222 AC_MSG_RESULT(yes)
2223 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002224 fi
2225else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002226 if test "$enable_terminal" = "auto"; then
2227 enable_terminal="no"
2228 AC_MSG_RESULT(defaulting to no)
2229 else
2230 AC_MSG_RESULT(no)
2231 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002232fi
Bram Moolenaar8b423282017-12-16 14:37:06 +01002233if test "$enable_terminal" = "yes" -a "$enable_channel" = "yes"; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002234 AC_DEFINE(FEAT_TERMINAL)
Bram Moolenaar93268052019-10-10 13:22:54 +02002235 TERM_SRC="libvterm/src/encoding.c libvterm/src/keyboard.c libvterm/src/mouse.c libvterm/src/parser.c libvterm/src/pen.c libvterm/src/creen.c libvterm/src/state.c libvterm/src/unicode.c libvterm/src/vterm.c"
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002236 AC_SUBST(TERM_SRC)
Bram Moolenaar93268052019-10-10 13:22:54 +02002237 TERM_OBJ="objects/vterm_encoding.o objects/vterm_keyboard.o objects/vterm_mouse.o objects/vterm_parser.o objects/vterm_pen.o objects/vterm_screen.o objects/vterm_state.o objects/vterm_unicode.o objects/vterm_vterm.o"
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002238 AC_SUBST(TERM_OBJ)
Bram Moolenaar823edd12019-10-23 22:35:36 +02002239 TERM_TEST="test_libvterm"
2240 AC_SUBST(TERM_TEST)
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002241fi
2242
Bram Moolenaare42a6d22017-11-12 19:21:51 +01002243AC_MSG_CHECKING(--enable-autoservername argument)
2244AC_ARG_ENABLE(autoservername,
2245 [ --enable-autoservername Automatically define servername at vim startup.], ,
2246 [enable_autoservername="no"])
2247AC_MSG_RESULT($enable_autoservername)
2248if test "$enable_autoservername" = "yes"; then
2249 AC_DEFINE(FEAT_AUTOSERVERNAME)
2250fi
2251
Bram Moolenaar071d4272004-06-13 20:20:40 +00002252AC_MSG_CHECKING(--enable-multibyte argument)
2253AC_ARG_ENABLE(multibyte,
2254 [ --enable-multibyte Include multibyte editing support.], ,
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01002255 [enable_multibyte="yes"])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002256AC_MSG_RESULT($enable_multibyte)
Bram Moolenaar30276f22019-01-24 17:59:39 +01002257if test "$enable_multibyte" != "yes"; then
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01002258 AC_MSG_ERROR([The multi-byte feature can no longer be disabled. If you have
2259 a problem with this, discuss on the Vim mailing list.])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002260fi
2261
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002262dnl Right-to-Left language support for Vim will be included with big features,
2263dnl unless ENABLE_RIGHTLEFT is undefined.
2264AC_MSG_CHECKING(--disable-rightleft argument)
2265AC_ARG_ENABLE(rightleft,
2266 [ --disable-rightleft Do not include Right-to-Left language support.],
2267 , [enable_rightleft="yes"])
2268if test "$enable_rightleft" = "yes"; then
2269 AC_MSG_RESULT(no)
2270else
2271 AC_MSG_RESULT(yes)
2272 AC_DEFINE(DISABLE_RIGHTLEFT)
2273fi
2274
2275dnl Arabic language support for Vim will be included with big features,
2276dnl unless ENABLE_ARABIC is undefined.
2277AC_MSG_CHECKING(--disable-arabic argument)
2278AC_ARG_ENABLE(arabic,
2279 [ --disable-arabic Do not include Arabic language support.],
2280 , [enable_arabic="yes"])
2281if test "$enable_arabic" = "yes"; then
2282 AC_MSG_RESULT(no)
2283else
2284 AC_MSG_RESULT(yes)
2285 AC_DEFINE(DISABLE_ARABIC)
2286fi
2287
Bram Moolenaar14184a32019-02-16 15:10:30 +01002288dnl Farsi language support has been removed, ignore --disable-farsi
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002289AC_ARG_ENABLE(farsi,
Bram Moolenaar14184a32019-02-16 15:10:30 +01002290 [ --disable-farsi Deprecated.],,)
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002291
Bram Moolenaar071d4272004-06-13 20:20:40 +00002292AC_MSG_CHECKING(--enable-xim argument)
2293AC_ARG_ENABLE(xim,
2294 [ --enable-xim Include XIM input support.],
2295 AC_MSG_RESULT($enable_xim),
2296 [enable_xim="auto"; AC_MSG_RESULT(defaulting to auto)])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002297
2298AC_MSG_CHECKING(--enable-fontset argument)
2299AC_ARG_ENABLE(fontset,
2300 [ --enable-fontset Include X fontset output support.], ,
2301 [enable_fontset="no"])
2302AC_MSG_RESULT($enable_fontset)
2303dnl defining FEAT_XFONTSET is delayed, so that it can be disabled for no GUI
2304
2305test -z "$with_x" && with_x=yes
Bram Moolenaard0573012017-10-28 21:11:06 +02002306test "${enable_gui-yes}" != no -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && with_x=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002307if test "$with_x" = no; then
2308 AC_MSG_RESULT(defaulting to: don't HAVE_X11)
2309else
2310 dnl Do this check early, so that its failure can override user requests.
2311
2312 AC_PATH_PROG(xmkmfpath, xmkmf)
2313
2314 AC_PATH_XTRA
2315
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002316 dnl On z/OS Unix the X libraries are DLLs. To use them the code must
Bram Moolenaar071d4272004-06-13 20:20:40 +00002317 dnl be compiled with a special option.
2318 dnl Also add SM, ICE and Xmu to X_EXTRA_LIBS.
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002319 if test "$zOSUnix" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002320 CFLAGS="$CFLAGS -W c,dll"
2321 LDFLAGS="$LDFLAGS -W l,dll"
2322 X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE -lXmu"
2323 fi
2324
2325 dnl On my HPUX system the X include dir is found, but the lib dir not.
Bram Moolenaar70778922020-02-05 20:44:24 +01002326 dnl This is a desperate try to fix this.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002327
2328 if test -d "$x_includes" && test ! -d "$x_libraries"; then
2329 x_libraries=`echo "$x_includes" | sed s/include/lib/`
2330 AC_MSG_RESULT(Corrected X libraries to $x_libraries)
2331 X_LIBS="$X_LIBS -L$x_libraries"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00002332 if test "$vim_cv_uname_output" = SunOS &&
2333 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002334 X_LIBS="$X_LIBS -R $x_libraries"
2335 fi
2336 fi
2337
2338 if test -d "$x_libraries" && test ! -d "$x_includes"; then
2339 x_includes=`echo "$x_libraries" | sed s/lib/include/`
2340 AC_MSG_RESULT(Corrected X includes to $x_includes)
2341 X_CFLAGS="$X_CFLAGS -I$x_includes"
2342 fi
2343
2344 dnl Remove "-I/usr/include " from X_CFLAGS, should not be needed.
2345 X_CFLAGS="`echo $X_CFLAGS\ | sed 's%-I/usr/include %%'`"
2346 dnl Remove "-L/usr/lib " from X_LIBS, should not be needed.
2347 X_LIBS="`echo $X_LIBS\ | sed 's%-L/usr/lib %%'`"
2348 dnl Same for "-R/usr/lib ".
2349 X_LIBS="`echo $X_LIBS\ | sed -e 's%-R/usr/lib %%' -e 's%-R /usr/lib %%'`"
2350
2351
2352 dnl Check if the X11 header files are correctly installed. On some systems
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002353 dnl Xlib.h includes files that don't exist. On some systems X11/Intrinsic.h
2354 dnl is missing.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002355 AC_MSG_CHECKING(if X11 header files can be found)
2356 cflags_save=$CFLAGS
2357 CFLAGS="$CFLAGS $X_CFLAGS"
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002358 AC_TRY_COMPILE([#include <X11/Xlib.h>
2359#include <X11/Intrinsic.h>], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002360 AC_MSG_RESULT(yes),
2361 AC_MSG_RESULT(no); no_x=yes)
2362 CFLAGS=$cflags_save
2363
2364 if test "${no_x-no}" = yes; then
2365 with_x=no
2366 else
2367 AC_DEFINE(HAVE_X11)
2368 X_LIB="-lXt -lX11";
2369 AC_SUBST(X_LIB)
2370
2371 ac_save_LDFLAGS="$LDFLAGS"
2372 LDFLAGS="-L$x_libraries $LDFLAGS"
2373
2374 dnl Check for -lXdmcp (needed on SunOS 4.1.4)
2375 dnl For HP-UX 10.20 it must be before -lSM -lICE
2376 AC_CHECK_LIB(Xdmcp, _XdmcpAuthDoIt, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lXdmcp"],,
2377 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXdmcp])
2378
2379 dnl Some systems need -lnsl -lsocket when testing for ICE.
2380 dnl The check above doesn't do this, try here (again). Also needed to get
2381 dnl them after Xdmcp. link.sh will remove them when not needed.
2382 dnl Check for other function than above to avoid the cached value
2383 AC_CHECK_LIB(ICE, IceOpenConnection,
2384 [X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE"],, [$X_EXTRA_LIBS])
2385
2386 dnl Check for -lXpm (needed for some versions of Motif)
2387 LDFLAGS="$X_LIBS $ac_save_LDFLAGS"
2388 AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [X_PRE_LIBS="$X_PRE_LIBS -lXpm"],,
2389 [-lXt $X_PRE_LIBS -lXpm -lX11 $X_EXTRA_LIBS])
2390
2391 dnl Check that the X11 header files don't use implicit declarations
2392 AC_MSG_CHECKING(if X11 header files implicitly declare return values)
2393 cflags_save=$CFLAGS
Bram Moolenaard1864592013-05-04 04:40:15 +02002394 dnl -Werror is GCC only, others like Solaris Studio might not like it
2395 if test "$GCC" = yes; then
2396 CFLAGS="$CFLAGS $X_CFLAGS -Werror"
2397 else
2398 CFLAGS="$CFLAGS $X_CFLAGS"
2399 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002400 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2401 AC_MSG_RESULT(no),
2402 CFLAGS="$CFLAGS -Wno-implicit-int"
2403 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2404 AC_MSG_RESULT(yes); cflags_save="$cflags_save -Wno-implicit-int",
2405 AC_MSG_RESULT(test failed)
2406 )
2407 )
2408 CFLAGS=$cflags_save
2409
2410 LDFLAGS="$ac_save_LDFLAGS"
2411
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002412 AC_MSG_CHECKING(size of wchar_t is 2 bytes)
2413 AC_CACHE_VAL(ac_cv_small_wchar_t,
2414 [AC_TRY_RUN([
2415#include <X11/Xlib.h>
2416#if STDC_HEADERS
2417# include <stdlib.h>
2418# include <stddef.h>
2419#endif
2420 main()
2421 {
2422 if (sizeof(wchar_t) <= 2)
2423 exit(1);
2424 exit(0);
2425 }],
2426 ac_cv_small_wchar_t="no",
2427 ac_cv_small_wchar_t="yes",
2428 AC_MSG_ERROR(failed to compile test program))])
2429 AC_MSG_RESULT($ac_cv_small_wchar_t)
2430 if test "x$ac_cv_small_wchar_t" = "xyes" ; then
2431 AC_DEFINE(SMALL_WCHAR_T)
2432 fi
2433
Bram Moolenaar071d4272004-06-13 20:20:40 +00002434 fi
2435fi
2436
Bram Moolenaard2a05492018-07-27 22:35:15 +02002437dnl Check if --with-x was given but it doesn't work.
2438if test "x$with_x" = xno -a "x$with_x_arg" = xyes; then
2439 AC_MSG_ERROR([could not configure X])
2440fi
2441
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002442test "x$with_x" = xno -a "x$HAIKU" != "xyes" -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && enable_gui=no
Bram Moolenaar071d4272004-06-13 20:20:40 +00002443
2444AC_MSG_CHECKING(--enable-gui argument)
2445AC_ARG_ENABLE(gui,
Bram Moolenaarf52fac22022-03-11 16:01:26 +00002446 [ --enable-gui[=OPTS] X11 GUI. [default=auto] [OPTS=auto/no/gtk2/gnome2/gtk3/motif/haiku/photon/carbon]], , enable_gui="auto")
Bram Moolenaar071d4272004-06-13 20:20:40 +00002447
2448dnl Canonicalize the --enable-gui= argument so that it can be easily compared.
2449dnl Do not use character classes for portability with old tools.
2450enable_gui_canon=`echo "_$enable_gui" | \
2451 sed 's/[[ _+-]]//g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
2452
2453dnl Skip everything by default.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002454SKIP_GTK2=YES
Bram Moolenaar1858a842016-02-23 22:30:31 +01002455SKIP_GTK3=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002456SKIP_GNOME=YES
2457SKIP_MOTIF=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002458SKIP_PHOTON=YES
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002459SKIP_HAIKU=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002460GUITYPE=NONE
2461
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002462if test "x$HAIKU" = "xyes"; then
2463 SKIP_HAIKU=
2464 case "$enable_gui_canon" in
2465 no) AC_MSG_RESULT(no GUI support)
2466 SKIP_HAIKU=YES ;;
2467 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
2468 auto) AC_MSG_RESULT(auto - automatic GUI support) ;;
2469 haiku) AC_MSG_RESULT(Haiku GUI support) ;;
2470 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2471 SKIP_HAIKU=YES ;;
2472 esac
2473elif test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002474 SKIP_PHOTON=
2475 case "$enable_gui_canon" in
2476 no) AC_MSG_RESULT(no GUI support)
2477 SKIP_PHOTON=YES ;;
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002478 yes|""|auto) AC_MSG_RESULT(automatic GUI support)
2479 gui_auto=yes ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002480 photon) AC_MSG_RESULT(Photon GUI support) ;;
2481 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2482 SKIP_PHOTON=YES ;;
2483 esac
2484
Bram Moolenaar040f9752020-08-11 23:08:48 +02002485elif test "x$MACOS_X" = "xyes" -a "x$with_x" = "xno" ; then
2486 case "$enable_gui_canon" in
2487 no) AC_MSG_RESULT(no GUI support) ;;
2488 yes|"") AC_MSG_RESULT(yes - automatic GUI support)
2489 gui_auto=yes ;;
2490 auto) AC_MSG_RESULT(auto - disable GUI support for Mac OS) ;;
Bram Moolenaarbe7529e2020-08-13 21:05:39 +02002491 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
Bram Moolenaar040f9752020-08-11 23:08:48 +02002492 esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00002493else
2494
Bram Moolenaar071d4272004-06-13 20:20:40 +00002495 case "$enable_gui_canon" in
2496 no|none) AC_MSG_RESULT(no GUI support) ;;
2497 yes|""|auto) AC_MSG_RESULT(yes/auto - automatic GUI support)
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002498 gui_auto=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002499 SKIP_GTK2=
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002500 SKIP_GTK3=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002501 SKIP_GNOME=
Bram Moolenaarf52fac22022-03-11 16:01:26 +00002502 SKIP_MOTIF=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002503 gtk2) AC_MSG_RESULT(GTK+ 2.x GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002504 SKIP_GTK2=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002505 gnome2) AC_MSG_RESULT(GNOME 2.x GUI support)
2506 SKIP_GNOME=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002507 SKIP_GTK2=;;
Bram Moolenaar98921892016-02-23 17:14:37 +01002508 gtk3) AC_MSG_RESULT(GTK+ 3.x GUI support)
2509 SKIP_GTK3=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002510 motif) AC_MSG_RESULT(Motif GUI support)
2511 SKIP_MOTIF=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002512 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
2513 esac
2514
2515fi
2516
Bram Moolenaar071d4272004-06-13 20:20:40 +00002517if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \
2518 -a "$enable_gui_canon" != "gnome2"; then
2519 AC_MSG_CHECKING(whether or not to look for GTK+ 2)
2520 AC_ARG_ENABLE(gtk2-check,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002521 [ --enable-gtk2-check If auto-select GUI, check for GTK+ 2 [default=yes]],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002522 , enable_gtk2_check="yes")
2523 AC_MSG_RESULT($enable_gtk2_check)
2524 if test "x$enable_gtk2_check" = "xno"; then
2525 SKIP_GTK2=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002526 SKIP_GNOME=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002527 fi
2528fi
2529
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002530if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002531 AC_MSG_CHECKING(whether or not to look for GNOME)
2532 AC_ARG_ENABLE(gnome-check,
2533 [ --enable-gnome-check If GTK GUI, check for GNOME [default=no]],
2534 , enable_gnome_check="no")
2535 AC_MSG_RESULT($enable_gnome_check)
2536 if test "x$enable_gnome_check" = "xno"; then
2537 SKIP_GNOME=YES
2538 fi
2539fi
2540
Bram Moolenaar98921892016-02-23 17:14:37 +01002541if test "x$SKIP_GTK3" != "xYES" -a "$enable_gui_canon" != "gtk3"; then
2542 AC_MSG_CHECKING(whether or not to look for GTK+ 3)
2543 AC_ARG_ENABLE(gtk3-check,
2544 [ --enable-gtk3-check If auto-select GUI, check for GTK+ 3 [default=yes]],
2545 , enable_gtk3_check="yes")
2546 AC_MSG_RESULT($enable_gtk3_check)
2547 if test "x$enable_gtk3_check" = "xno"; then
2548 SKIP_GTK3=YES
2549 fi
2550fi
2551
Bram Moolenaar071d4272004-06-13 20:20:40 +00002552if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then
2553 AC_MSG_CHECKING(whether or not to look for Motif)
2554 AC_ARG_ENABLE(motif-check,
2555 [ --enable-motif-check If auto-select GUI, check for Motif [default=yes]],
2556 , enable_motif_check="yes")
2557 AC_MSG_RESULT($enable_motif_check)
2558 if test "x$enable_motif_check" = "xno"; then
2559 SKIP_MOTIF=YES
2560 fi
2561fi
2562
Bram Moolenaar071d4272004-06-13 20:20:40 +00002563dnl define an autoconf function to check for a specified version of GTK, and
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002564dnl try to compile/link a GTK program.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002565dnl
2566dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002567dnl Test for GTK, and define GTK_CFLAGS, GTK_LIBDIR and GTK_LIBS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002568dnl
2569AC_DEFUN(AM_PATH_GTK,
2570[
2571 if test "X$GTK_CONFIG" != "Xno" -o "X$PKG_CONFIG" != "Xno"; then
2572 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00002573 no_gtk=""
2574 if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2575 && $PKG_CONFIG --exists gtk+-2.0; then
2576 {
Bram Moolenaar98921892016-02-23 17:14:37 +01002577 min_gtk_version=ifelse([$1], ,2.2.0,$1)
2578 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002579 dnl We should be using PKG_CHECK_MODULES() instead of this hack.
2580 dnl But I guess the dependency on pkgconfig.m4 is not wanted or
2581 dnl something like that.
2582 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0`
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002583 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-2.0`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002584 GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0`
2585 gtk_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2586 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2587 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2588 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2589 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2590 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2591 }
Bram Moolenaar98921892016-02-23 17:14:37 +01002592 elif (test "X$SKIP_GTK3" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2593 && $PKG_CONFIG --exists gtk+-3.0; then
2594 {
2595 min_gtk_version=ifelse([$1], ,3.0.0,$1)
2596 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
2597
2598 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-3.0`
2599 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-3.0`
2600 GTK_LIBS=`$PKG_CONFIG --libs gtk+-3.0`
2601 gtk_major_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2602 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2603 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2604 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2605 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2606 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2607 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002608 else
Bram Moolenaar67876de2021-01-12 20:51:24 +01002609 dnl Put some text before the "no" to hint at installing the gtk-dev
2610 dnl packages.
2611 AC_MSG_CHECKING(for GTK -dev package)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002612 no_gtk=yes
2613 fi
2614
2615 if test "x$enable_gtktest" = "xyes" -a "x$no_gtk" = "x"; then
2616 {
2617 ac_save_CFLAGS="$CFLAGS"
2618 ac_save_LIBS="$LIBS"
2619 CFLAGS="$CFLAGS $GTK_CFLAGS"
2620 LIBS="$LIBS $GTK_LIBS"
2621
2622 dnl
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002623 dnl Now check if the installed GTK is sufficiently new.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002624 dnl
2625 rm -f conf.gtktest
2626 AC_TRY_RUN([
2627#include <gtk/gtk.h>
2628#include <stdio.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00002629#if STDC_HEADERS
2630# include <stdlib.h>
2631# include <stddef.h>
2632#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002633
2634int
2635main ()
2636{
2637int major, minor, micro;
2638char *tmp_version;
2639
2640system ("touch conf.gtktest");
2641
2642/* HP/UX 9 (%@#!) writes to sscanf strings */
2643tmp_version = g_strdup("$min_gtk_version");
2644if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
2645 printf("%s, bad version string\n", "$min_gtk_version");
2646 exit(1);
2647 }
2648
2649if ((gtk_major_version > major) ||
2650 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
2651 ((gtk_major_version == major) && (gtk_minor_version == minor) &&
2652 (gtk_micro_version >= micro)))
2653{
2654 return 0;
2655}
2656return 1;
2657}
2658],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
2659 CFLAGS="$ac_save_CFLAGS"
2660 LIBS="$ac_save_LIBS"
2661 }
2662 fi
2663 if test "x$no_gtk" = x ; then
2664 if test "x$enable_gtktest" = "xyes"; then
2665 AC_MSG_RESULT(yes; found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2666 else
2667 AC_MSG_RESULT(found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2668 fi
2669 ifelse([$2], , :, [$2])
2670 else
2671 {
2672 AC_MSG_RESULT(no)
2673 GTK_CFLAGS=""
2674 GTK_LIBS=""
2675 ifelse([$3], , :, [$3])
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002676 if test "$fail_if_missing" = "yes" -a "X$gui_auto" != "Xyes"; then
2677 AC_MSG_ERROR([could not configure GTK])
2678 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002679 }
2680 fi
2681 }
2682 else
2683 GTK_CFLAGS=""
2684 GTK_LIBS=""
2685 ifelse([$3], , :, [$3])
2686 fi
2687 AC_SUBST(GTK_CFLAGS)
2688 AC_SUBST(GTK_LIBS)
2689 rm -f conf.gtktest
2690])
2691
2692dnl ---------------------------------------------------------------------------
2693dnl gnome
2694dnl ---------------------------------------------------------------------------
2695AC_DEFUN([GNOME_INIT_HOOK],
2696[
2697 AC_SUBST(GNOME_LIBS)
2698 AC_SUBST(GNOME_LIBDIR)
2699 AC_SUBST(GNOME_INCLUDEDIR)
2700
2701 AC_ARG_WITH(gnome-includes,
2702 [ --with-gnome-includes=DIR Specify location of GNOME headers],
2703 [CFLAGS="$CFLAGS -I$withval"]
2704 )
2705
2706 AC_ARG_WITH(gnome-libs,
2707 [ --with-gnome-libs=DIR Specify location of GNOME libs],
2708 [LDFLAGS="$LDFLAGS -L$withval" gnome_prefix=$withval]
2709 )
2710
2711 AC_ARG_WITH(gnome,
2712 [ --with-gnome Specify prefix for GNOME files],
2713 if test x$withval = xyes; then
2714 want_gnome=yes
2715 ifelse([$1], [], :, [$1])
2716 else
2717 if test "x$withval" = xno; then
2718 want_gnome=no
2719 else
2720 want_gnome=yes
2721 LDFLAGS="$LDFLAGS -L$withval/lib"
2722 CFLAGS="$CFLAGS -I$withval/include"
2723 gnome_prefix=$withval/lib
2724 fi
2725 fi,
2726 want_gnome=yes)
2727
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002728 if test "x$want_gnome" = xyes; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002729 {
2730 AC_MSG_CHECKING(for libgnomeui-2.0)
2731 if $PKG_CONFIG --exists libgnomeui-2.0; then
2732 AC_MSG_RESULT(yes)
2733 GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0`
2734 GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0`
2735 GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0`
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002736
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002737 dnl On FreeBSD we need -pthread but pkg-config doesn't include it.
2738 dnl This might not be the right way but it works for me...
2739 AC_MSG_CHECKING(for FreeBSD)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00002740 if test "$vim_cv_uname_output" = FreeBSD; then
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002741 AC_MSG_RESULT(yes, adding -pthread)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002742 GNOME_INCLUDEDIR="$GNOME_INCLUDEDIR -D_THREAD_SAFE"
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002743 GNOME_LIBS="$GNOME_LIBS -pthread"
2744 else
2745 AC_MSG_RESULT(no)
2746 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002747 $1
2748 else
2749 AC_MSG_RESULT(not found)
2750 if test "x$2" = xfail; then
2751 AC_MSG_ERROR(Could not find libgnomeui-2.0 via pkg-config)
2752 fi
2753 fi
2754 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002755 fi
2756])
2757
2758AC_DEFUN([GNOME_INIT],[
2759 GNOME_INIT_HOOK([],fail)
2760])
2761
Bram Moolenaar427f5b62019-06-09 13:43:51 +02002762if test "X$PKG_CONFIG" = "X"; then
2763 AC_PATH_TOOL(PKG_CONFIG, pkg-config, no)
2764fi
2765
Bram Moolenaar071d4272004-06-13 20:20:40 +00002766
2767dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002768dnl Check for GTK2. If it fails, then continue on for Motif as before...
Bram Moolenaar071d4272004-06-13 20:20:40 +00002769dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002770if test -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002771
2772 AC_MSG_CHECKING(--disable-gtktest argument)
2773 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2774 , enable_gtktest=yes)
2775 if test "x$enable_gtktest" = "xyes" ; then
2776 AC_MSG_RESULT(gtk test enabled)
2777 else
2778 AC_MSG_RESULT(gtk test disabled)
2779 fi
2780
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002781 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002782 dnl First try finding version 2.2.0 or later. The 2.0.x series has
2783 dnl problems (bold fonts, --remote doesn't work).
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002784 dnl Disable checking for GTK3 here, otherwise it's found when GTK2 is not
2785 dnl found.
2786 save_skip_gtk3=$SKIP_GTK3
2787 SKIP_GTK3=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002788 AM_PATH_GTK(2.2.0,
2789 [GUI_LIB_LOC="$GTK_LIBDIR"
2790 GTK_LIBNAME="$GTK_LIBS"
2791 GUI_INC_LOC="$GTK_CFLAGS"], )
2792 if test "x$GTK_CFLAGS" != "x"; then
Bram Moolenaar98921892016-02-23 17:14:37 +01002793 SKIP_GTK3=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002794 SKIP_MOTIF=YES
2795 GUITYPE=GTK
2796 AC_SUBST(GTK_LIBNAME)
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002797 else
2798 SKIP_GTK3=$save_skip_gtk3
Bram Moolenaar071d4272004-06-13 20:20:40 +00002799 fi
2800 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002801 if test "x$GUITYPE" = "xGTK"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002802 dnl
2803 dnl if GTK exists, then check for GNOME.
2804 dnl
2805 if test -z "$SKIP_GNOME"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002806 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002807 GNOME_INIT_HOOK([have_gnome=yes])
2808 if test "x$have_gnome" = xyes ; then
2809 AC_DEFINE(FEAT_GUI_GNOME)
2810 GUI_INC_LOC="$GUI_INC_LOC $GNOME_INCLUDEDIR"
2811 GTK_LIBNAME="$GTK_LIBNAME $GNOME_LIBDIR $GNOME_LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002812 fi
2813 }
2814 fi
2815 fi
2816fi
2817
Bram Moolenaar98921892016-02-23 17:14:37 +01002818
2819dnl ---------------------------------------------------------------------------
2820dnl Check for GTK3.
2821dnl ---------------------------------------------------------------------------
2822if test -z "$SKIP_GTK3"; then
2823
2824 AC_MSG_CHECKING(--disable-gtktest argument)
2825 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2826 , enable_gtktest=yes)
2827 if test "x$enable_gtktest" = "xyes" ; then
2828 AC_MSG_RESULT(gtk test enabled)
2829 else
2830 AC_MSG_RESULT(gtk test disabled)
2831 fi
2832
Bram Moolenaar98921892016-02-23 17:14:37 +01002833 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002834 save_skip_gtk2=$SKIP_GTK2
2835 SKIP_GTK2=YES
Bram Moolenaar98921892016-02-23 17:14:37 +01002836 AM_PATH_GTK(3.0.0,
2837 [GUI_LIB_LOC="$GTK_LIBDIR"
2838 GTK_LIBNAME="$GTK_LIBS"
2839 GUI_INC_LOC="$GTK_CFLAGS"], )
2840 if test "x$GTK_CFLAGS" != "x"; then
2841 SKIP_GTK2=YES
2842 SKIP_GNOME=YES
Bram Moolenaar98921892016-02-23 17:14:37 +01002843 SKIP_MOTIF=YES
2844 GUITYPE=GTK
2845 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar98921892016-02-23 17:14:37 +01002846 AC_DEFINE(USE_GTK3)
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002847 else
2848 SKIP_GTK2=$save_skip_gtk2
Bram Moolenaar98921892016-02-23 17:14:37 +01002849 fi
2850 fi
2851fi
2852
Bram Moolenaard2e03f02016-01-02 22:46:36 +01002853dnl Check the version of Gdk-Pixbuf. If the version is 2.31 or later and
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002854dnl glib-compile-resources is found in PATH, use GResource.
2855if test "x$GUITYPE" = "xGTK"; then
2856 AC_MSG_CHECKING([version of Gdk-Pixbuf])
2857 gdk_pixbuf_version=`$PKG_CONFIG --modversion gdk-pixbuf-2.0`
2858 if test "x$gdk_pixbuf_version" != x ; then
2859 gdk_pixbuf_version_minor=`echo $gdk_pixbuf_version | \
2860 sed -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/'`
2861 if test "x$gdk_pixbuf_version_minor" != x -a \
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002862 $gdk_pixbuf_version_minor -ge 31 ; then
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002863 AC_MSG_RESULT([OK.])
2864 AC_PATH_PROG(GLIB_COMPILE_RESOURCES,[glib-compile-resources],no)
2865 AC_MSG_CHECKING([glib-compile-resources])
2866 if test "x$GLIB_COMPILE_RESOURCES" = xno ; then
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002867 GLIB_COMPILE_RESOURCES=""
2868 AC_MSG_RESULT([cannot be found in PATH.])
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002869 else
2870 AC_MSG_RESULT([usable.])
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002871 AC_DEFINE(USE_GRESOURCE)
2872 GRESOURCE_SRC="auto/gui_gtk_gresources.c"
2873 GRESOURCE_OBJ="objects/gui_gtk_gresources.o"
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002874 fi
2875 else
2876 AC_MSG_RESULT([not usable.])
2877 fi
2878 else
2879 AC_MSG_RESULT([cannot obtain from pkg_config.])
2880 fi
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002881
2882 AC_MSG_CHECKING([--disable-icon-cache-update argument])
2883 AC_ARG_ENABLE(icon_cache_update,
2884 [ --disable-icon-cache-update update disabled],
2885 [],
2886 [enable_icon_cache_update="yes"])
2887 if test "$enable_icon_cache_update" = "yes"; then
2888 AC_MSG_RESULT([not set])
2889 AC_PATH_PROG(GTK_UPDATE_ICON_CACHE,[gtk-update-icon-cache],no)
2890 if test "x$GTK_UPDATE_ICON_CACHE" = "xno" ; then
2891 AC_MSG_RESULT([not found in PATH.])
2892 fi
2893 else
2894 AC_MSG_RESULT([update disabled])
2895 fi
2896
2897 AC_MSG_CHECKING([--disable-desktop-database-update argument])
2898 AC_ARG_ENABLE(desktop_database_update,
2899 [ --disable-desktop-database-update update disabled],
2900 [],
2901 [enable_desktop_database_update="yes"])
2902 if test "$enable_desktop_database_update" = "yes"; then
2903 AC_MSG_RESULT([not set])
2904 AC_PATH_PROG(UPDATE_DESKTOP_DATABASE,[update-desktop-database],no)
2905 if test "x$UPDATE_DESKTOP_DATABASE" = "xno" ; then
2906 AC_MSG_RESULT([not found in PATH.])
2907 fi
2908 else
2909 AC_MSG_RESULT([update disabled])
2910 fi
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002911fi
2912AC_SUBST(GLIB_COMPILE_RESOURCES)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002913AC_SUBST(GRESOURCE_SRC)
2914AC_SUBST(GRESOURCE_OBJ)
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002915AC_SUBST(GTK_UPDATE_ICON_CACHE)
2916AC_SUBST(UPDATE_DESKTOP_DATABASE)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002917
Bram Moolenaar071d4272004-06-13 20:20:40 +00002918dnl Check for Motif include files location.
2919dnl The LAST one found is used, this makes the highest version to be used,
2920dnl e.g. when Motif1.2 and Motif2.0 are both present.
2921
2922if test -z "$SKIP_MOTIF"; then
2923 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"
2924 dnl Remove "-I" from before $GUI_INC_LOC if it's there
2925 GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`"
2926
2927 AC_MSG_CHECKING(for location of Motif GUI includes)
2928 gui_includes="`echo $x_includes|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC"
2929 GUI_INC_LOC=
2930 for try in $gui_includes; do
2931 if test -f "$try/Xm/Xm.h"; then
2932 GUI_INC_LOC=$try
2933 fi
2934 done
2935 if test -n "$GUI_INC_LOC"; then
2936 if test "$GUI_INC_LOC" = /usr/include; then
2937 GUI_INC_LOC=
2938 AC_MSG_RESULT(in default path)
2939 else
2940 AC_MSG_RESULT($GUI_INC_LOC)
2941 fi
2942 else
2943 AC_MSG_RESULT(<not found>)
2944 SKIP_MOTIF=YES
2945 fi
2946fi
2947
2948dnl Check for Motif library files location. In the same order as the include
2949dnl files, to avoid a mixup if several versions are present
2950
2951if test -z "$SKIP_MOTIF"; then
2952 AC_MSG_CHECKING(--with-motif-lib argument)
2953 AC_ARG_WITH(motif-lib,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002954 [ --with-motif-lib=STRING Library for Motif ],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002955 [ MOTIF_LIBNAME="${withval}" ] )
2956
2957 if test -n "$MOTIF_LIBNAME"; then
2958 AC_MSG_RESULT($MOTIF_LIBNAME)
2959 GUI_LIB_LOC=
2960 else
2961 AC_MSG_RESULT(no)
2962
2963 dnl Remove "-L" from before $GUI_LIB_LOC if it's there
2964 GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
2965
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002966 dnl Ubuntu has libXm.so in /usr/lib/i386-linux-gnu and elsewhere. The
2967 dnl linker will figure out which one to use, we only check if one exists.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002968 AC_MSG_CHECKING(for location of Motif GUI libs)
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002969 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 +00002970 GUI_LIB_LOC=
2971 for try in $gui_libs; do
Bram Moolenaar325b7a22004-07-05 15:58:32 +00002972 for libtry in "$try"/libXm.a "$try"/libXm.so* "$try"/libXm.sl "$try"/libXm.dylib; do
Bram Moolenaar071d4272004-06-13 20:20:40 +00002973 if test -f "$libtry"; then
2974 GUI_LIB_LOC=$try
2975 fi
2976 done
2977 done
2978 if test -n "$GUI_LIB_LOC"; then
2979 dnl Remove /usr/lib, it causes trouble on some systems
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002980 if test "$GUI_LIB_LOC" = /usr/lib \
2981 -o "$GUI_LIB_LOC" = /usr/lib/i386-linux-gnu \
2982 -o "$GUI_LIB_LOC" = /usr/lib/x86_64-linux-gnu; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002983 GUI_LIB_LOC=
2984 AC_MSG_RESULT(in default path)
2985 else
2986 if test -n "$GUI_LIB_LOC"; then
2987 AC_MSG_RESULT($GUI_LIB_LOC)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00002988 if test "$vim_cv_uname_output" = SunOS &&
2989 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002990 GUI_LIB_LOC="$GUI_LIB_LOC -R $GUI_LIB_LOC"
2991 fi
2992 fi
2993 fi
2994 MOTIF_LIBNAME=-lXm
2995 else
2996 AC_MSG_RESULT(<not found>)
2997 SKIP_MOTIF=YES
2998 fi
2999 fi
3000fi
3001
3002if test -z "$SKIP_MOTIF"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003003 GUITYPE=MOTIF
3004 AC_SUBST(MOTIF_LIBNAME)
3005fi
3006
Bram Moolenaare2adcf32022-03-12 11:57:25 +00003007if test -z "$SKIP_MOTIF"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003008 dnl Prepend -I and -L to $GUI_INC_LOC and $GUI_LIB_LOC if not empty
3009 dnl Avoid adding it when it twice
3010 if test -n "$GUI_INC_LOC"; then
3011 GUI_INC_LOC=-I"`echo $GUI_INC_LOC|sed 's%-I%%'`"
3012 fi
3013 if test -n "$GUI_LIB_LOC"; then
3014 GUI_LIB_LOC=-L"`echo $GUI_LIB_LOC|sed 's%-L%%'`"
3015 fi
3016
3017 dnl Check for -lXext and then for -lXmu
3018 ldflags_save=$LDFLAGS
3019 LDFLAGS="$X_LIBS $LDFLAGS"
3020 AC_CHECK_LIB(Xext, XShapeQueryExtension, [GUI_X_LIBS="-lXext"],,
3021 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3022 dnl For Solaris we need -lw and -ldl before linking with -lXmu works.
3023 AC_CHECK_LIB(w, wslen, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lw"],,
3024 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3025 AC_CHECK_LIB(dl, dlsym, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldl"],,
3026 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3027 AC_CHECK_LIB(Xmu, XmuCreateStippledPixmap, [GUI_X_LIBS="-lXmu $GUI_X_LIBS"],,
3028 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3029 if test -z "$SKIP_MOTIF"; then
3030 AC_CHECK_LIB(Xp, XpEndJob, [GUI_X_LIBS="-lXp $GUI_X_LIBS"],,
3031 [$GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3032 fi
3033 LDFLAGS=$ldflags_save
3034
3035 dnl Execute xmkmf to figure out if -DNARROWPROTO is needed.
3036 AC_MSG_CHECKING(for extra X11 defines)
3037 NARROW_PROTO=
3038 rm -fr conftestdir
3039 if mkdir conftestdir; then
3040 cd conftestdir
3041 cat > Imakefile <<'EOF'
3042acfindx:
3043 @echo 'NARROW_PROTO="${PROTO_DEFINES}"'
3044EOF
3045 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
3046 eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
3047 fi
3048 cd ..
3049 rm -fr conftestdir
3050 fi
3051 if test -z "$NARROW_PROTO"; then
3052 AC_MSG_RESULT(no)
3053 else
3054 AC_MSG_RESULT($NARROW_PROTO)
3055 fi
3056 AC_SUBST(NARROW_PROTO)
3057fi
3058
3059dnl Look for XSMP support - but don't necessarily restrict it to X11 GUIs
3060dnl use the X11 include path
3061if test "$enable_xsmp" = "yes"; then
3062 cppflags_save=$CPPFLAGS
3063 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3064 AC_CHECK_HEADERS(X11/SM/SMlib.h)
3065 CPPFLAGS=$cppflags_save
3066fi
3067
3068
Bram Moolenaarf52fac22022-03-11 16:01:26 +00003069if test -z "$SKIP_MOTIF" -o -z "$SKIP_GTK2" -o -z "$SKIP_GTK3"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003070 dnl Check for X11/xpm.h and X11/Sunkeysym.h with the GUI include path
3071 cppflags_save=$CPPFLAGS
3072 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3073 AC_CHECK_HEADERS(X11/xpm.h X11/Sunkeysym.h)
3074
3075 dnl automatically disable XIM when XIMtext isn't in X11/Xlib.h
3076 if test ! "$enable_xim" = "no"; then
3077 AC_MSG_CHECKING(for XIMText in X11/Xlib.h)
3078 AC_EGREP_CPP(XIMText, [#include <X11/Xlib.h>],
3079 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +02003080 AC_MSG_RESULT(no; xim has been disabled); enable_xim="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00003081 fi
3082 CPPFLAGS=$cppflags_save
3083
Bram Moolenaar54612582019-11-21 17:13:31 +01003084 dnl automatically enable XIM in the GUI
3085 if test "$enable_xim" = "auto" -a "x$GUITYPE" != "xNONE" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003086 AC_MSG_RESULT(X GUI selected; xim has been enabled)
3087 enable_xim="yes"
3088 fi
3089fi
3090
Bram Moolenaarf52fac22022-03-11 16:01:26 +00003091if test -z "$SKIP_MOTIF"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003092 cppflags_save=$CPPFLAGS
3093 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00003094dnl Xmu/Editres.h may exist but can only be used after including Intrinsic.h
3095 AC_MSG_CHECKING([for X11/Xmu/Editres.h])
3096 AC_TRY_COMPILE([
3097#include <X11/Intrinsic.h>
3098#include <X11/Xmu/Editres.h>],
3099 [int i; i = 0;],
3100 AC_MSG_RESULT(yes)
3101 AC_DEFINE(HAVE_X11_XMU_EDITRES_H),
3102 AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003103 CPPFLAGS=$cppflags_save
3104fi
3105
Bram Moolenaar0b40d082022-03-08 13:32:37 +00003106dnl Only use the Xm directory when compiling Motif.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003107if test -z "$SKIP_MOTIF"; then
3108 cppflags_save=$CPPFLAGS
3109 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003110 if test "$zOSUnix" = "yes"; then
3111 xmheader="Xm/Xm.h"
3112 else
3113 xmheader="Xm/Xm.h Xm/XpmP.h Xm/JoinSideT.h Xm/TraitP.h Xm/Manager.h
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02003114 Xm/UnhighlightT.h Xm/Notebook.h"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003115 fi
3116 AC_CHECK_HEADERS($xmheader)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003117
Bram Moolenaar77c19352012-06-13 19:19:41 +02003118 if test "x$ac_cv_header_Xm_XpmP_h" = "xyes"; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003119 dnl Solaris uses XpmAttributes_21, very annoying.
3120 AC_MSG_CHECKING([for XpmAttributes_21 in Xm/XpmP.h])
3121 AC_TRY_COMPILE([#include <Xm/XpmP.h>], [XpmAttributes_21 attr;],
3122 AC_MSG_RESULT(yes); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes_21),
3123 AC_MSG_RESULT(no); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
3124 )
3125 else
Bram Moolenaar57657d82006-04-21 22:12:41 +00003126 AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003127 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003128 CPPFLAGS=$cppflags_save
3129fi
3130
3131if test "x$GUITYPE" = "xNONE" -a "$enable_xim" = "yes"; then
3132 AC_MSG_RESULT(no GUI selected; xim has been disabled)
3133 enable_xim="no"
3134fi
3135if test "x$GUITYPE" = "xNONE" -a "$enable_fontset" = "yes"; then
3136 AC_MSG_RESULT(no GUI selected; fontset has been disabled)
3137 enable_fontset="no"
3138fi
Bram Moolenaar182c5be2010-06-25 05:37:59 +02003139if test "x$GUITYPE:$enable_fontset" = "xGTK:yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003140 AC_MSG_RESULT(GTK+ 2 GUI selected; fontset has been disabled)
3141 enable_fontset="no"
3142fi
3143
Bram Moolenaarb3f74062020-02-26 16:16:53 +01003144dnl There is no test for the Haiku GUI, if it's selected it's used
3145if test -z "$SKIP_HAIKU"; then
3146 GUITYPE=HAIKUGUI
3147fi
3148
Bram Moolenaar071d4272004-06-13 20:20:40 +00003149if test -z "$SKIP_PHOTON"; then
3150 GUITYPE=PHOTONGUI
3151fi
3152
3153AC_SUBST(GUI_INC_LOC)
3154AC_SUBST(GUI_LIB_LOC)
3155AC_SUBST(GUITYPE)
3156AC_SUBST(GUI_X_LIBS)
3157
3158if test "$enable_workshop" = "yes" -a -n "$SKIP_MOTIF"; then
3159 AC_MSG_ERROR([cannot use workshop without Motif])
3160fi
3161
3162dnl defining FEAT_XIM and FEAT_XFONTSET is delayed, so that they can be disabled
3163if test "$enable_xim" = "yes"; then
3164 AC_DEFINE(FEAT_XIM)
3165fi
3166if test "$enable_fontset" = "yes"; then
3167 AC_DEFINE(FEAT_XFONTSET)
3168fi
3169
3170
3171dnl ---------------------------------------------------------------------------
3172dnl end of GUI-checking
3173dnl ---------------------------------------------------------------------------
3174
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003175AC_MSG_CHECKING([for /proc link to executable])
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003176if test -L "/proc/self/exe"; then
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003177 dnl Linux
3178 AC_MSG_RESULT([/proc/self/exe])
3179 AC_DEFINE(PROC_EXE_LINK, "/proc/self/exe")
3180elif test -L "/proc/self/path/a.out"; then
3181 dnl Solaris
3182 AC_MSG_RESULT([/proc/self/path/a.out])
3183 AC_DEFINE(PROC_EXE_LINK, "/proc/self/path/a.out")
3184elif test -L "/proc/curproc/file"; then
3185 dnl FreeBSD
3186 AC_MSG_RESULT([/proc/curproc/file])
3187 AC_DEFINE(PROC_EXE_LINK, "/proc/curproc/file")
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003188else
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003189 AC_MSG_RESULT(no)
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003190fi
3191
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003192dnl Check for Cygwin, which needs an extra source file if not using X11
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003193AC_MSG_CHECKING(for CYGWIN or MSYS environment)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00003194case $vim_cv_uname_output in
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003195 CYGWIN*|MSYS*) CYGWIN=yes; AC_MSG_RESULT(yes)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003196 AC_MSG_CHECKING(for CYGWIN clipboard support)
3197 if test "x$with_x" = "xno" ; then
3198 OS_EXTRA_SRC=winclip.c; OS_EXTRA_OBJ=objects/winclip.o
3199 AC_MSG_RESULT(yes)
3200 AC_DEFINE(FEAT_CYGWIN_WIN32_CLIPBOARD)
3201 else
3202 AC_MSG_RESULT(no - using X11)
3203 fi ;;
3204
3205 *) CYGWIN=no; AC_MSG_RESULT(no);;
3206esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00003207
Bram Moolenaar071d4272004-06-13 20:20:40 +00003208dnl Checks for libraries and include files.
3209
Bram Moolenaar446cb832008-06-24 21:56:24 +00003210AC_CACHE_CHECK([whether toupper is broken], [vim_cv_toupper_broken],
3211 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003212 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003213#include "confdefs.h"
3214#include <ctype.h>
3215#if STDC_HEADERS
3216# include <stdlib.h>
3217# include <stddef.h>
3218#endif
3219main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003220 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003221 vim_cv_toupper_broken=yes
3222 ],[
3223 vim_cv_toupper_broken=no
3224 ],[
3225 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_toupper_broken')
3226 ])])
3227
3228if test "x$vim_cv_toupper_broken" = "xyes" ; then
3229 AC_DEFINE(BROKEN_TOUPPER)
3230fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003231
3232AC_MSG_CHECKING(whether __DATE__ and __TIME__ work)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003233AC_TRY_COMPILE([#include <stdio.h>], [printf("(" __DATE__ " " __TIME__ ")");],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003234 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DATE_TIME),
3235 AC_MSG_RESULT(no))
3236
Bram Moolenaar0c094b92009-05-14 20:20:33 +00003237AC_MSG_CHECKING(whether __attribute__((unused)) is allowed)
3238AC_TRY_COMPILE([#include <stdio.h>], [int x __attribute__((unused));],
3239 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ATTRIBUTE_UNUSED),
3240 AC_MSG_RESULT(no))
3241
Bram Moolenaar071d4272004-06-13 20:20:40 +00003242dnl Checks for header files.
3243AC_CHECK_HEADER(elf.h, HAS_ELF=1)
3244dnl AC_CHECK_HEADER(dwarf.h, SVR4=1)
3245if test "$HAS_ELF" = 1; then
3246 AC_CHECK_LIB(elf, main)
3247fi
3248
3249AC_HEADER_DIRENT
3250
Bram Moolenaar071d4272004-06-13 20:20:40 +00003251dnl If sys/wait.h is not found it might still exist but not be POSIX
3252dnl compliant. In that case we define HAVE_UNION_WAIT (for NeXT)
3253if test $ac_cv_header_sys_wait_h = no; then
3254 AC_MSG_CHECKING([for sys/wait.h that defines union wait])
3255 AC_TRY_COMPILE([#include <sys/wait.h>],
3256 [union wait xx, yy; xx = yy],
3257 AC_MSG_RESULT(yes)
3258 AC_DEFINE(HAVE_SYS_WAIT_H)
3259 AC_DEFINE(HAVE_UNION_WAIT),
3260 AC_MSG_RESULT(no))
3261fi
3262
Bram Moolenaar779a7752016-01-30 23:26:34 +01003263AC_CHECK_HEADERS(stdint.h stdlib.h string.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003264 sys/select.h sys/utsname.h termcap.h fcntl.h \
3265 sgtty.h sys/ioctl.h sys/time.h sys/types.h \
3266 termio.h iconv.h inttypes.h langinfo.h math.h \
3267 unistd.h stropts.h errno.h sys/resource.h \
3268 sys/systeminfo.h locale.h sys/stream.h termios.h \
3269 libc.h sys/statfs.h poll.h sys/poll.h pwd.h \
Bram Moolenaar1ecc5e42019-01-26 15:12:55 +01003270 utime.h sys/param.h sys/ptms.h libintl.h libgen.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003271 util/debug.h util/msg18n.h frame.h sys/acl.h \
3272 sys/access.h sys/sysinfo.h wchar.h wctype.h)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003273
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003274dnl sys/ptem.h depends on sys/stream.h on Solaris
3275AC_CHECK_HEADERS(sys/ptem.h, [], [],
3276[#if defined HAVE_SYS_STREAM_H
3277# include <sys/stream.h>
3278#endif])
3279
Bram Moolenaar32f31b12009-05-21 13:20:59 +00003280dnl sys/sysctl.h depends on sys/param.h on OpenBSD
3281AC_CHECK_HEADERS(sys/sysctl.h, [], [],
3282[#if defined HAVE_SYS_PARAM_H
3283# include <sys/param.h>
3284#endif])
3285
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003286
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003287dnl pthread_np.h may exist but can only be used after including pthread.h
3288AC_MSG_CHECKING([for pthread_np.h])
3289AC_TRY_COMPILE([
3290#include <pthread.h>
3291#include <pthread_np.h>],
3292 [int i; i = 0;],
3293 AC_MSG_RESULT(yes)
3294 AC_DEFINE(HAVE_PTHREAD_NP_H),
3295 AC_MSG_RESULT(no))
3296
Bram Moolenaare344bea2005-09-01 20:46:49 +00003297AC_CHECK_HEADERS(strings.h)
Bram Moolenaard0573012017-10-28 21:11:06 +02003298if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00003299 dnl The strings.h file on OS/X contains a warning and nothing useful.
3300 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3301else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003302
3303dnl Check if strings.h and string.h can both be included when defined.
3304AC_MSG_CHECKING([if strings.h can be included after string.h])
3305cppflags_save=$CPPFLAGS
3306CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3307AC_TRY_COMPILE([
3308#if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO)
3309# define _NO_PROTO /* like in os_unix.h, causes conflict for AIX (Winn) */
3310 /* but don't do it on AIX 5.1 (Uribarri) */
3311#endif
3312#ifdef HAVE_XM_XM_H
3313# include <Xm/Xm.h> /* This breaks it for HP-UX 11 (Squassabia) */
3314#endif
3315#ifdef HAVE_STRING_H
3316# include <string.h>
3317#endif
3318#if defined(HAVE_STRINGS_H)
3319# include <strings.h>
3320#endif
3321 ], [int i; i = 0;],
3322 AC_MSG_RESULT(yes),
3323 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3324 AC_MSG_RESULT(no))
3325CPPFLAGS=$cppflags_save
Bram Moolenaar9372a112005-12-06 19:59:18 +00003326fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003327
3328dnl Checks for typedefs, structures, and compiler characteristics.
3329AC_PROG_GCC_TRADITIONAL
3330AC_C_CONST
Bram Moolenaar76243bd2009-03-02 01:47:02 +00003331AC_C_VOLATILE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003332AC_TYPE_MODE_T
3333AC_TYPE_OFF_T
3334AC_TYPE_PID_T
3335AC_TYPE_SIZE_T
3336AC_TYPE_UID_T
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003337AC_TYPE_UINT32_T
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003338
Bram Moolenaar071d4272004-06-13 20:20:40 +00003339AC_HEADER_TIME
3340AC_CHECK_TYPE(ino_t, long)
3341AC_CHECK_TYPE(dev_t, unsigned)
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003342AC_C_BIGENDIAN(,,,)
Bram Moolenaar136f29a2016-02-27 20:14:15 +01003343AC_C_INLINE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003344
3345AC_MSG_CHECKING(for rlim_t)
3346if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
3347 AC_MSG_RESULT([(cached) $ac_cv_type_rlim_t])
3348else
3349 AC_EGREP_CPP(dnl
3350changequote(<<,>>)dnl
3351<<(^|[^a-zA-Z_0-9])rlim_t[^a-zA-Z_0-9]>>dnl
3352changequote([,]),
3353 [
3354#include <sys/types.h>
3355#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003356# include <stdlib.h>
3357# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003358#endif
3359#ifdef HAVE_SYS_RESOURCE_H
Bram Moolenaar446cb832008-06-24 21:56:24 +00003360# include <sys/resource.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003361#endif
3362 ], ac_cv_type_rlim_t=yes, ac_cv_type_rlim_t=no)
3363 AC_MSG_RESULT($ac_cv_type_rlim_t)
3364fi
3365if test $ac_cv_type_rlim_t = no; then
3366 cat >> confdefs.h <<\EOF
3367#define rlim_t unsigned long
3368EOF
3369fi
3370
3371AC_MSG_CHECKING(for stack_t)
3372if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then
3373 AC_MSG_RESULT([(cached) $ac_cv_type_stack_t])
3374else
3375 AC_EGREP_CPP(stack_t,
3376 [
3377#include <sys/types.h>
3378#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003379# include <stdlib.h>
3380# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003381#endif
3382#include <signal.h>
3383 ], ac_cv_type_stack_t=yes, ac_cv_type_stack_t=no)
3384 AC_MSG_RESULT($ac_cv_type_stack_t)
3385fi
3386if test $ac_cv_type_stack_t = no; then
3387 cat >> confdefs.h <<\EOF
3388#define stack_t struct sigaltstack
3389EOF
3390fi
3391
3392dnl BSDI uses ss_base while others use ss_sp for the stack pointer.
3393AC_MSG_CHECKING(whether stack_t has an ss_base field)
3394AC_TRY_COMPILE([
3395#include <sys/types.h>
3396#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003397# include <stdlib.h>
3398# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003399#endif
3400#include <signal.h>
3401#include "confdefs.h"
3402 ], [stack_t sigstk; sigstk.ss_base = 0; ],
3403 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SS_BASE),
3404 AC_MSG_RESULT(no))
3405
3406olibs="$LIBS"
3407AC_MSG_CHECKING(--with-tlib argument)
3408AC_ARG_WITH(tlib, [ --with-tlib=library terminal library to be used ],)
3409if test -n "$with_tlib"; then
3410 AC_MSG_RESULT($with_tlib)
3411 LIBS="$LIBS -l$with_tlib"
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003412 AC_MSG_CHECKING(for linking with $with_tlib library)
3413 AC_TRY_LINK([], [], AC_MSG_RESULT(OK), AC_MSG_ERROR(FAILED))
3414 dnl Need to check for tgetent() below.
3415 olibs="$LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003416else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003417 AC_MSG_RESULT([empty: automatic terminal library selection])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003418 dnl On HP-UX 10.10 termcap or termlib should be used instead of
3419 dnl curses, because curses is much slower.
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003420 dnl Newer versions of ncurses are preferred over anything, except
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02003421 dnl when tinfo has been split off, it contains all we need.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003422 dnl Older versions of ncurses have bugs, get a new one!
3423 dnl Digital Unix (OSF1) should use curses (Ronald Schild).
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00003424 dnl On SCO Openserver should prefer termlib (Roger Cornelius).
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00003425 case "$vim_cv_uname_output" in
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003426 OSF1|SCO_SV) tlibs="tinfo ncurses curses termlib termcap";;
3427 *) tlibs="tinfo ncurses termlib termcap curses";;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003428 esac
3429 for libname in $tlibs; do
3430 AC_CHECK_LIB(${libname}, tgetent,,)
3431 if test "x$olibs" != "x$LIBS"; then
3432 dnl It's possible that a library is found but it doesn't work
3433 dnl e.g., shared library that cannot be found
3434 dnl compile and run a test program to be sure
3435 AC_TRY_RUN([
3436#ifdef HAVE_TERMCAP_H
3437# include <termcap.h>
3438#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003439#if STDC_HEADERS
3440# include <stdlib.h>
3441# include <stddef.h>
3442#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003443main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }],
3444 res="OK", res="FAIL", res="FAIL")
3445 if test "$res" = "OK"; then
3446 break
3447 fi
3448 AC_MSG_RESULT($libname library is not usable)
3449 LIBS="$olibs"
3450 fi
3451 done
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003452 if test "x$olibs" = "x$LIBS"; then
3453 AC_MSG_RESULT(no terminal library found)
3454 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003455fi
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003456
3457if test "x$olibs" = "x$LIBS"; then
3458 AC_MSG_CHECKING([for tgetent()])
Bram Moolenaarbd7f7c12020-07-28 21:03:37 +02003459 AC_TRY_LINK([int tgetent(char *, const char *);],
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003460 [char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");],
3461 AC_MSG_RESULT(yes),
3462 AC_MSG_ERROR([NOT FOUND!
3463 You need to install a terminal library; for example ncurses.
Bram Moolenaar16678eb2021-04-21 11:57:59 +02003464 On Linux that would be the libncurses-dev package.
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003465 Or specify the name of the library with --with-tlib.]))
3466fi
3467
Bram Moolenaar446cb832008-06-24 21:56:24 +00003468AC_CACHE_CHECK([whether we talk terminfo], [vim_cv_terminfo],
3469 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003470 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003471#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003472#ifdef HAVE_TERMCAP_H
3473# include <termcap.h>
3474#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003475#ifdef HAVE_STRING_H
3476# include <string.h>
3477#endif
3478#if STDC_HEADERS
3479# include <stdlib.h>
3480# include <stddef.h>
3481#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003482main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003483{char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003484 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003485 vim_cv_terminfo=no
3486 ],[
3487 vim_cv_terminfo=yes
3488 ],[
3489 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_terminfo')
3490 ])
3491 ])
3492
3493if test "x$vim_cv_terminfo" = "xyes" ; then
3494 AC_DEFINE(TERMINFO)
3495fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003496
Bram Moolenaara88254f2017-11-02 23:04:14 +01003497AC_CACHE_CHECK([what tgetent() returns for an unknown terminal], [vim_cv_tgetent],
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003498 [
3499 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003500#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003501#ifdef HAVE_TERMCAP_H
3502# include <termcap.h>
3503#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003504#if STDC_HEADERS
3505# include <stdlib.h>
3506# include <stddef.h>
3507#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003508main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003509{char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003510 ]])],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003511 vim_cv_tgetent=zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003512 ],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003513 vim_cv_tgetent=non-zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003514 ],[
3515 AC_MSG_ERROR(failed to compile test program.)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003516 ])
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003517 ])
3518
Bram Moolenaara88254f2017-11-02 23:04:14 +01003519if test "x$vim_cv_tgetent" = "xzero" ; then
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003520 AC_DEFINE(TGETENT_ZERO_ERR, 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003521fi
3522
3523AC_MSG_CHECKING(whether termcap.h contains ospeed)
3524AC_TRY_LINK([
3525#ifdef HAVE_TERMCAP_H
3526# include <termcap.h>
3527#endif
3528 ], [ospeed = 20000],
3529 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED),
3530 [AC_MSG_RESULT(no)
3531 AC_MSG_CHECKING(whether ospeed can be extern)
3532 AC_TRY_LINK([
3533#ifdef HAVE_TERMCAP_H
3534# include <termcap.h>
3535#endif
3536extern short ospeed;
3537 ], [ospeed = 20000],
3538 AC_MSG_RESULT(yes); AC_DEFINE(OSPEED_EXTERN),
3539 AC_MSG_RESULT(no))]
3540 )
3541
3542AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC])
3543AC_TRY_LINK([
3544#ifdef HAVE_TERMCAP_H
3545# include <termcap.h>
3546#endif
3547 ], [if (UP == 0 && BC == 0) PC = 1],
3548 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UP_BC_PC),
3549 [AC_MSG_RESULT(no)
3550 AC_MSG_CHECKING([whether UP, BC and PC can be extern])
3551 AC_TRY_LINK([
3552#ifdef HAVE_TERMCAP_H
3553# include <termcap.h>
3554#endif
3555extern char *UP, *BC, PC;
3556 ], [if (UP == 0 && BC == 0) PC = 1],
3557 AC_MSG_RESULT(yes); AC_DEFINE(UP_BC_PC_EXTERN),
3558 AC_MSG_RESULT(no))]
3559 )
3560
3561AC_MSG_CHECKING(whether tputs() uses outfuntype)
3562AC_TRY_COMPILE([
3563#ifdef HAVE_TERMCAP_H
3564# include <termcap.h>
3565#endif
3566 ], [extern int xx(); tputs("test", 1, (outfuntype)xx)],
3567 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OUTFUNTYPE),
3568 AC_MSG_RESULT(no))
3569
Bram Moolenaarb3a29552021-11-19 11:28:04 +00003570AC_MSG_CHECKING([whether del_curterm() can be used])
3571AC_TRY_LINK([
3572#ifdef HAVE_TERMCAP_H
3573# include <termcap.h>
3574#endif
3575#include <term.h>
3576 ], [if (cur_term) del_curterm(cur_term);],
3577 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DEL_CURTERM),
3578 AC_MSG_RESULT(no))
3579
Bram Moolenaar071d4272004-06-13 20:20:40 +00003580dnl On some SCO machines sys/select redefines struct timeval
3581AC_MSG_CHECKING([whether sys/select.h and sys/time.h may both be included])
3582AC_TRY_COMPILE([
3583#include <sys/types.h>
3584#include <sys/time.h>
3585#include <sys/select.h>], ,
3586 AC_MSG_RESULT(yes)
3587 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME),
3588 AC_MSG_RESULT(no))
3589
3590dnl AC_DECL_SYS_SIGLIST
3591
3592dnl Checks for pty.c (copied from screen) ==========================
3593AC_MSG_CHECKING(for /dev/ptc)
3594if test -r /dev/ptc; then
3595 AC_DEFINE(HAVE_DEV_PTC)
3596 AC_MSG_RESULT(yes)
3597else
3598 AC_MSG_RESULT(no)
3599fi
3600
3601AC_MSG_CHECKING(for SVR4 ptys)
3602if test -c /dev/ptmx ; then
Bram Moolenaarce7be3a2020-11-26 20:11:11 +01003603 AC_TRY_LINK([
3604// These should be in stdlib.h, but it depends on _XOPEN_SOURCE.
3605char *ptsname(int);
3606int unlockpt(int);
3607int grantpt(int);
3608 ], [
3609 ptsname(0);
3610 grantpt(0);
3611 unlockpt(0);],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003612 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SVR4_PTYS),
3613 AC_MSG_RESULT(no))
3614else
3615 AC_MSG_RESULT(no)
3616fi
3617
3618AC_MSG_CHECKING(for ptyranges)
3619if test -d /dev/ptym ; then
3620 pdir='/dev/ptym'
3621else
3622 pdir='/dev'
3623fi
3624dnl SCO uses ptyp%d
3625AC_EGREP_CPP(yes,
3626[#ifdef M_UNIX
3627 yes;
3628#endif
3629 ], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
3630dnl if test -c /dev/ptyp19; then
3631dnl ptys=`echo /dev/ptyp??`
3632dnl else
3633dnl ptys=`echo $pdir/pty??`
3634dnl fi
3635if test "$ptys" != "$pdir/pty??" ; then
3636 p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
3637 p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'`
3638 AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
3639 AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
3640 AC_MSG_RESULT([$p0 / $p1])
3641else
3642 AC_MSG_RESULT([don't know])
3643fi
3644
Bram Moolenaar071d4272004-06-13 20:20:40 +00003645dnl Checks for library functions. ===================================
3646
3647AC_TYPE_SIGNAL
3648
3649dnl find out what to use at the end of a signal function
3650if test $ac_cv_type_signal = void; then
3651 AC_DEFINE(SIGRETURN, [return])
3652else
3653 AC_DEFINE(SIGRETURN, [return 0])
3654fi
3655
3656dnl check if struct sigcontext is defined (used for SGI only)
3657AC_MSG_CHECKING(for struct sigcontext)
3658AC_TRY_COMPILE([
3659#include <signal.h>
3660test_sig()
3661{
3662 struct sigcontext *scont;
3663 scont = (struct sigcontext *)0;
3664 return 1;
3665} ], ,
3666 AC_MSG_RESULT(yes)
3667 AC_DEFINE(HAVE_SIGCONTEXT),
3668 AC_MSG_RESULT(no))
3669
3670dnl tricky stuff: try to find out if getcwd() is implemented with
3671dnl system("sh -c pwd")
Bram Moolenaar446cb832008-06-24 21:56:24 +00003672AC_CACHE_CHECK([getcwd implementation is broken], [vim_cv_getcwd_broken],
3673 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003674 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003675#include "confdefs.h"
3676#ifdef HAVE_UNISTD_H
3677#include <unistd.h>
3678#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003679char *dagger[] = { "IFS=pwd", 0 };
3680main()
3681{
3682 char buffer[500];
3683 extern char **environ;
3684 environ = dagger;
3685 return getcwd(buffer, 500) ? 0 : 1;
Bram Moolenaar446cb832008-06-24 21:56:24 +00003686}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003687 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003688 vim_cv_getcwd_broken=no
3689 ],[
3690 vim_cv_getcwd_broken=yes
3691 ],[
3692 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_getcwd_broken')
3693 ])
3694 ])
3695
3696if test "x$vim_cv_getcwd_broken" = "xyes" ; then
3697 AC_DEFINE(BAD_GETCWD)
Bram Moolenaar63d25552019-05-10 21:28:38 +02003698 AC_CHECK_FUNCS(getwd)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003699fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003700
Bram Moolenaar25153e12010-02-24 14:47:08 +01003701dnl Check for functions in one big call, to reduce the size of configure.
3702dnl Can only be used for functions that do not require any include.
Bram Moolenaarcd142e32017-11-16 17:03:45 +01003703AC_CHECK_FUNCS(fchdir fchown fchmod fsync getcwd getpseudotty \
Bram Moolenaar63d25552019-05-10 21:28:38 +02003704 getpwent getpwnam getpwuid getrlimit gettimeofday localtime_r lstat \
Bram Moolenaareaf03392009-11-17 11:08:52 +00003705 memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
Bram Moolenaar2fcf6682017-03-11 20:03:42 +01003706 getpgid setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
Bram Moolenaar84cf6bd2020-06-16 20:03:43 +02003707 sigprocmask sigvec strcasecmp strcoll strerror strftime stricmp strncasecmp \
Bram Moolenaar10455d42019-11-21 15:36:18 +01003708 strnicmp strpbrk strptime strtol tgetent towlower towupper iswupper \
3709 tzset usleep utime utimes mblen ftruncate unsetenv posix_openpt)
Bram Moolenaar643b6142018-09-12 20:29:09 +02003710AC_FUNC_SELECT_ARGTYPES
Bram Moolenaar25153e12010-02-24 14:47:08 +01003711AC_FUNC_FSEEKO
Bram Moolenaar071d4272004-06-13 20:20:40 +00003712
Bram Moolenaar317fd3a2010-05-07 16:05:55 +02003713dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when
3714dnl appropriate, so that off_t is 64 bits when needed.
3715AC_SYS_LARGEFILE
3716
Bram Moolenaar21606672019-06-14 20:40:58 +02003717AC_MSG_CHECKING(--enable-canberra argument)
3718AC_ARG_ENABLE(canberra,
3719 [ --disable-canberra Do not use libcanberra.],
3720 , [enable_canberra="maybe"])
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003721
Bram Moolenaar21606672019-06-14 20:40:58 +02003722if test "$enable_canberra" = "maybe"; then
3723 if test "$features" = "big" -o "$features" = "huge"; then
3724 AC_MSG_RESULT(Defaulting to yes)
3725 enable_canberra="yes"
3726 else
3727 AC_MSG_RESULT(Defaulting to no)
3728 enable_canberra="no"
3729 fi
3730else
Bram Moolenaar12471262022-01-18 11:11:25 +00003731 if test "$enable_canberra" = "yes" -a "$has_eval" = "no"; then
3732 AC_MSG_RESULT([cannot use sound with tiny or small features])
3733 enable_canberra="no"
3734 else
3735 AC_MSG_RESULT($enable_canberra)
3736 fi
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003737fi
Bram Moolenaar21606672019-06-14 20:40:58 +02003738if test "$enable_canberra" = "yes"; then
3739 if test "x$PKG_CONFIG" != "xno"; then
3740 canberra_lib=`$PKG_CONFIG --libs libcanberra 2>/dev/null`
3741 canberra_cflags=`$PKG_CONFIG --cflags libcanberra 2>/dev/null`
3742 fi
3743 if test "x$canberra_lib" = "x"; then
3744 canberra_lib=-lcanberra
3745 canberra_cflags=-D_REENTRANT
3746 fi
3747 AC_MSG_CHECKING(for libcanberra)
3748 ac_save_CFLAGS="$CFLAGS"
3749 ac_save_LIBS="$LIBS"
Bram Moolenaar12471262022-01-18 11:11:25 +00003750 if `echo "$CFLAGS" | grep -v "$canberra_cflags" 2>/dev/null`; then
Christian Brabandt6b9efdd2021-09-09 17:14:50 +02003751 CFLAGS="$CFLAGS $canberra_cflags"
3752 fi
Bram Moolenaar21606672019-06-14 20:40:58 +02003753 LIBS="$LIBS $canberra_lib"
3754 AC_TRY_LINK([
3755 # include <canberra.h>
3756 ], [
3757 ca_context *hello;
3758 ca_context_create(&hello);],
3759 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_CANBERRA),
Bram Moolenaar91b992c2019-11-17 19:07:42 +01003760 AC_MSG_RESULT(no; try installing libcanberra-dev); CFLAGS="$ac_save_CFLAGS"; LIBS="$ac_save_LIBS")
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003761fi
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003762
Christian Brabandtf573c6e2021-06-20 14:02:16 +02003763AC_MSG_CHECKING(--enable-libsodium argument)
3764AC_ARG_ENABLE(libsodium,
3765 [ --disable-libsodium Do not use libsodium.],
3766 , [enable_libsodium="maybe"])
3767
3768if test "$enable_libsodium" = "maybe"; then
3769 if test "$features" = "big" -o "$features" = "huge"; then
3770 AC_MSG_RESULT(Defaulting to yes)
3771 enable_libsodium="yes"
3772 else
3773 AC_MSG_RESULT(Defaulting to no)
3774 enable_libsodium="no"
3775 fi
3776else
3777 AC_MSG_RESULT($enable_libsodium)
3778fi
3779if test "$enable_libsodium" = "yes"; then
3780 if test "x$PKG_CONFIG" != "xno"; then
3781 libsodium_lib=`$PKG_CONFIG --libs libsodium 2>/dev/null`
3782 libsodium_cflags=`$PKG_CONFIG --cflags libsodium 2>/dev/null`
3783 fi
3784 if test "x$libsodium_lib" = "x"; then
3785 libsodium_lib=-lsodium
3786 libsodium_cflags=
3787 fi
ichizok8ce3ca82021-06-23 15:41:52 +02003788 AC_MSG_CHECKING(for libsodium)
Christian Brabandtf573c6e2021-06-20 14:02:16 +02003789 ac_save_CFLAGS="$CFLAGS"
3790 ac_save_LIBS="$LIBS"
3791 CFLAGS="$CFLAGS $libsodium_cflags"
3792 LIBS="$LIBS $libsodium_lib"
3793 AC_TRY_LINK([
3794 # include <sodium.h>
3795 ], [
3796 printf("%d", sodium_init()); ],
3797 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SODIUM),
3798 AC_MSG_RESULT(no; try installing libsodium-dev); CFLAGS="$ac_save_CFLAGS"; LIBS="$ac_save_LIBS")
3799fi
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003800
Bram Moolenaar071d4272004-06-13 20:20:40 +00003801dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible
3802AC_MSG_CHECKING(for st_blksize)
3803AC_TRY_COMPILE(
3804[#include <sys/types.h>
3805#include <sys/stat.h>],
3806[ struct stat st;
3807 int n;
3808
3809 stat("/", &st);
3810 n = (int)st.st_blksize;],
3811 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ST_BLKSIZE),
3812 AC_MSG_RESULT(no))
3813
Bram Moolenaar446cb832008-06-24 21:56:24 +00003814AC_CACHE_CHECK([whether stat() ignores a trailing slash], [vim_cv_stat_ignores_slash],
3815 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003816 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003817#include "confdefs.h"
3818#if STDC_HEADERS
3819# include <stdlib.h>
3820# include <stddef.h>
3821#endif
3822#include <sys/types.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003823#include <sys/stat.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003824main() {struct stat st; exit(stat("configure/", &st) != 0); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003825 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003826 vim_cv_stat_ignores_slash=yes
3827 ],[
3828 vim_cv_stat_ignores_slash=no
3829 ],[
3830 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_stat_ignores_slash')
3831 ])
3832 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003833
Bram Moolenaar446cb832008-06-24 21:56:24 +00003834if test "x$vim_cv_stat_ignores_slash" = "xyes" ; then
3835 AC_DEFINE(STAT_IGNORES_SLASH)
3836fi
Leah Neukirchen0a7984a2021-10-14 21:27:55 +01003837
3838dnl nanoseconds field of struct stat
3839AC_CACHE_CHECK([for nanoseconds field of struct stat],
3840 ac_cv_struct_st_mtim_nsec,
3841 [ac_save_CPPFLAGS="$CPPFLAGS"
3842 ac_cv_struct_st_mtim_nsec=no
3843 # st_mtim.tv_nsec -- the usual case
3844 # st_mtim._tv_nsec -- Solaris 2.6, if
3845 # (defined _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED == 1
3846 # && !defined __EXTENSIONS__)
3847 # st_mtim.st__tim.tv_nsec -- UnixWare 2.1.2
3848 # st_mtime_n -- AIX 5.2 and above
3849 # st_mtimespec.tv_nsec -- Darwin (Mac OSX)
3850 for ac_val in st_mtim.tv_nsec st_mtim._tv_nsec st_mtim.st__tim.tv_nsec st_mtime_n st_mtimespec.tv_nsec; do
3851 CPPFLAGS="$ac_save_CPPFLAGS -DST_MTIM_NSEC=$ac_val"
3852 AC_TRY_COMPILE([#include <sys/types.h>
3853#include <sys/stat.h>], [struct stat s; s.ST_MTIM_NSEC;],
3854 [ac_cv_struct_st_mtim_nsec=$ac_val; break])
3855 done
3856 CPPFLAGS="$ac_save_CPPFLAGS"
3857])
3858if test $ac_cv_struct_st_mtim_nsec != no; then
3859 AC_DEFINE_UNQUOTED([ST_MTIM_NSEC], [$ac_cv_struct_st_mtim_nsec],
3860 [Define if struct stat contains a nanoseconds field])
3861fi
Bram Moolenaar446cb832008-06-24 21:56:24 +00003862
Bram Moolenaar071d4272004-06-13 20:20:40 +00003863dnl Link with iconv for charset translation, if not found without library.
3864dnl check for iconv() requires including iconv.h
3865dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
3866dnl has been installed.
3867AC_MSG_CHECKING(for iconv_open())
3868save_LIBS="$LIBS"
3869LIBS="$LIBS -liconv"
3870AC_TRY_LINK([
3871#ifdef HAVE_ICONV_H
3872# include <iconv.h>
3873#endif
3874 ], [iconv_open("fr", "to");],
3875 AC_MSG_RESULT(yes; with -liconv); AC_DEFINE(HAVE_ICONV),
3876 LIBS="$save_LIBS"
3877 AC_TRY_LINK([
3878#ifdef HAVE_ICONV_H
3879# include <iconv.h>
3880#endif
3881 ], [iconv_open("fr", "to");],
3882 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ICONV),
3883 AC_MSG_RESULT(no)))
3884
3885
3886AC_MSG_CHECKING(for nl_langinfo(CODESET))
3887AC_TRY_LINK([
3888#ifdef HAVE_LANGINFO_H
3889# include <langinfo.h>
3890#endif
3891], [char *cs = nl_langinfo(CODESET);],
3892 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET),
3893 AC_MSG_RESULT(no))
3894
Bram Moolenaar446cb832008-06-24 21:56:24 +00003895dnl Need various functions for floating point support. Only enable
3896dnl floating point when they are all present.
3897AC_CHECK_LIB(m, strtod)
3898AC_MSG_CHECKING([for strtod() and other floating point functions])
3899AC_TRY_LINK([
3900#ifdef HAVE_MATH_H
3901# include <math.h>
3902#endif
3903#if STDC_HEADERS
3904# include <stdlib.h>
3905# include <stddef.h>
3906#endif
3907], [char *s; double d;
3908 d = strtod("1.1", &s);
3909 d = fabs(1.11);
3910 d = ceil(1.11);
3911 d = floor(1.11);
3912 d = log10(1.11);
3913 d = pow(1.11, 2.22);
3914 d = sqrt(1.11);
3915 d = sin(1.11);
3916 d = cos(1.11);
3917 d = atan(1.11);
3918 ],
3919 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT_FUNCS),
3920 AC_MSG_RESULT(no))
3921
Bram Moolenaara6b89762016-02-29 21:38:26 +01003922dnl isinf() and isnan() need to include header files and may need -lm.
3923AC_MSG_CHECKING([for isinf()])
3924AC_TRY_LINK([
3925#ifdef HAVE_MATH_H
3926# include <math.h>
3927#endif
3928#if STDC_HEADERS
3929# include <stdlib.h>
3930# include <stddef.h>
3931#endif
3932], [int r = isinf(1.11); ],
3933 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISINF),
3934 AC_MSG_RESULT(no))
3935
3936AC_MSG_CHECKING([for isnan()])
3937AC_TRY_LINK([
3938#ifdef HAVE_MATH_H
3939# include <math.h>
3940#endif
3941#if STDC_HEADERS
3942# include <stdlib.h>
3943# include <stddef.h>
3944#endif
3945], [int r = isnan(1.11); ],
3946 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISNAN),
3947 AC_MSG_RESULT(no))
3948
Bram Moolenaar071d4272004-06-13 20:20:40 +00003949dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI
3950dnl when -lacl works, also try to use -lattr (required for Debian).
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003951dnl On Solaris, use the acl_get/set functions in libsec, if present.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003952AC_MSG_CHECKING(--disable-acl argument)
3953AC_ARG_ENABLE(acl,
Bram Moolenaard6d30422018-01-28 22:48:55 +01003954 [ --disable-acl No check for ACL support.],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003955 , [enable_acl="yes"])
3956if test "$enable_acl" = "yes"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01003957 AC_MSG_RESULT(no)
3958 AC_CHECK_LIB(posix1e, acl_get_file, [LIBS="$LIBS -lposix1e"],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003959 AC_CHECK_LIB(acl, acl_get_file, [LIBS="$LIBS -lacl"
3960 AC_CHECK_LIB(attr, fgetxattr, LIBS="$LIBS -lattr",,)],,),)
3961
Bram Moolenaard6d30422018-01-28 22:48:55 +01003962 AC_MSG_CHECKING(for POSIX ACL support)
3963 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003964#include <sys/types.h>
3965#ifdef HAVE_SYS_ACL_H
3966# include <sys/acl.h>
3967#endif
3968acl_t acl;], [acl = acl_get_file("foo", ACL_TYPE_ACCESS);
3969 acl_set_file("foo", ACL_TYPE_ACCESS, acl);
3970 acl_free(acl);],
3971 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_ACL),
3972 AC_MSG_RESULT(no))
3973
Bram Moolenaard6d30422018-01-28 22:48:55 +01003974 AC_CHECK_LIB(sec, acl_get, [LIBS="$LIBS -lsec"; AC_DEFINE(HAVE_SOLARIS_ZFS_ACL)],
3975 AC_MSG_CHECKING(for Solaris ACL support)
3976 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003977#ifdef HAVE_SYS_ACL_H
3978# include <sys/acl.h>
3979#endif], [acl("foo", GETACLCNT, 0, NULL);
3980 ],
3981 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOLARIS_ACL),
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003982 AC_MSG_RESULT(no)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003983
Bram Moolenaard6d30422018-01-28 22:48:55 +01003984 AC_MSG_CHECKING(for AIX ACL support)
3985 AC_TRY_LINK([
Bram Moolenaar446cb832008-06-24 21:56:24 +00003986#if STDC_HEADERS
3987# include <stdlib.h>
3988# include <stddef.h>
3989#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003990#ifdef HAVE_SYS_ACL_H
3991# include <sys/acl.h>
3992#endif
3993#ifdef HAVE_SYS_ACCESS_H
3994# include <sys/access.h>
3995#endif
3996#define _ALL_SOURCE
3997
3998#include <sys/stat.h>
3999
4000int aclsize;
4001struct acl *aclent;], [aclsize = sizeof(struct acl);
4002 aclent = (void *)malloc(aclsize);
4003 statacl("foo", STX_NORMAL, aclent, aclsize);
4004 ],
4005 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_AIX_ACL),
4006 AC_MSG_RESULT(no))
4007else
4008 AC_MSG_RESULT(yes)
4009fi
4010
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02004011if test "x$GTK_CFLAGS" != "x"; then
4012 dnl pango_shape_full() is new, fall back to pango_shape().
4013 AC_MSG_CHECKING(for pango_shape_full)
4014 ac_save_CFLAGS="$CFLAGS"
4015 ac_save_LIBS="$LIBS"
4016 CFLAGS="$CFLAGS $GTK_CFLAGS"
4017 LIBS="$LIBS $GTK_LIBS"
Bram Moolenaar5325b9b2015-09-09 20:27:02 +02004018 AC_TRY_LINK(
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02004019 [#include <gtk/gtk.h>],
4020 [ pango_shape_full(NULL, 0, NULL, 0, NULL, NULL); ],
4021 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_PANGO_SHAPE_FULL),
4022 AC_MSG_RESULT(no))
4023 CFLAGS="$ac_save_CFLAGS"
4024 LIBS="$ac_save_LIBS"
4025fi
4026
Bram Moolenaar33fc4a62022-02-23 18:07:38 +00004027AC_MSG_CHECKING(--enable-gpm argument)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004028AC_ARG_ENABLE(gpm,
Bram Moolenaar33fc4a62022-02-23 18:07:38 +00004029 [ --enable-gpm=OPTS Use gpm (Linux mouse daemon). default=yes OPTS=yes/no/dynamic], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00004030 [enable_gpm="yes"])
4031
Bram Moolenaar33fc4a62022-02-23 18:07:38 +00004032if test "$enable_gpm" = "yes" -o "$enable_gpm" = "dynamic"; then
4033 AC_MSG_RESULT($enable_gpm)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004034 dnl Checking if gpm support can be compiled
4035 AC_CACHE_CHECK([for gpm], vi_cv_have_gpm,
4036 [olibs="$LIBS" ; LIBS="-lgpm"]
4037 AC_TRY_LINK(
4038 [#include <gpm.h>
4039 #include <linux/keyboard.h>],
4040 [Gpm_GetLibVersion(NULL);],
4041 dnl Configure defines HAVE_GPM, if it is defined feature.h defines
4042 dnl FEAT_MOUSE_GPM if mouse support is included
4043 [vi_cv_have_gpm=yes],
4044 [vi_cv_have_gpm=no])
4045 [LIBS="$olibs"]
4046 )
4047 if test $vi_cv_have_gpm = yes; then
Bram Moolenaar33fc4a62022-02-23 18:07:38 +00004048 if test "$enable_gpm" = "yes"; then
4049 LIBS="$LIBS -lgpm"
4050 else
4051 AC_DEFINE(DYNAMIC_GPM)
4052 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004053 AC_DEFINE(HAVE_GPM)
4054 fi
4055else
Bram Moolenaar33fc4a62022-02-23 18:07:38 +00004056 AC_MSG_RESULT(no)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004057fi
4058
Bram Moolenaar446cb832008-06-24 21:56:24 +00004059AC_MSG_CHECKING(--disable-sysmouse argument)
4060AC_ARG_ENABLE(sysmouse,
Bram Moolenaar8008b632017-07-18 21:33:20 +02004061 [ --disable-sysmouse Don't use sysmouse (mouse in *BSD console).], ,
Bram Moolenaar446cb832008-06-24 21:56:24 +00004062 [enable_sysmouse="yes"])
4063
4064if test "$enable_sysmouse" = "yes"; then
4065 AC_MSG_RESULT(no)
4066 dnl Checking if sysmouse support can be compiled
4067 dnl Configure defines HAVE_SYSMOUSE, if it is defined feature.h
4068 dnl defines FEAT_SYSMOUSE if mouse support is included
4069 AC_CACHE_CHECK([for sysmouse], vi_cv_have_sysmouse,
4070 AC_TRY_LINK(
4071 [#include <sys/consio.h>
4072 #include <signal.h>
4073 #include <sys/fbio.h>],
4074 [struct mouse_info mouse;
4075 mouse.operation = MOUSE_MODE;
4076 mouse.operation = MOUSE_SHOW;
4077 mouse.u.mode.mode = 0;
4078 mouse.u.mode.signal = SIGUSR2;],
4079 [vi_cv_have_sysmouse=yes],
4080 [vi_cv_have_sysmouse=no])
4081 )
4082 if test $vi_cv_have_sysmouse = yes; then
4083 AC_DEFINE(HAVE_SYSMOUSE)
4084 fi
4085else
4086 AC_MSG_RESULT(yes)
4087fi
4088
Bram Moolenaarf05da212009-11-17 16:13:15 +00004089dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
4090AC_MSG_CHECKING(for FD_CLOEXEC)
4091AC_TRY_COMPILE(
4092[#if HAVE_FCNTL_H
4093# include <fcntl.h>
4094#endif],
4095[ int flag = FD_CLOEXEC;],
4096 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
4097 AC_MSG_RESULT(not usable))
4098
Bram Moolenaar071d4272004-06-13 20:20:40 +00004099dnl rename needs to be checked separately to work on Nextstep with cc
4100AC_MSG_CHECKING(for rename)
4101AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
4102 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
4103 AC_MSG_RESULT(no))
4104
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004105dnl check for dirfd()
4106AC_MSG_CHECKING(for dirfd)
Bram Moolenaar9d8bfae2020-09-02 21:21:35 +02004107AC_TRY_LINK(
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004108[#include <sys/types.h>
4109#include <dirent.h>],
4110[DIR * dir=opendir("dirname"); dirfd(dir);],
4111AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DIRFD), AC_MSG_RESULT(not usable))
4112
4113dnl check for flock()
4114AC_MSG_CHECKING(for flock)
Bram Moolenaar9d8bfae2020-09-02 21:21:35 +02004115AC_TRY_LINK(
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004116[#include <sys/file.h>],
4117[flock(10, LOCK_SH);],
4118AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOCK), AC_MSG_RESULT(not usable))
4119
Bram Moolenaar071d4272004-06-13 20:20:40 +00004120dnl sysctl() may exist but not the arguments we use
4121AC_MSG_CHECKING(for sysctl)
4122AC_TRY_COMPILE(
4123[#include <sys/types.h>
4124#include <sys/sysctl.h>],
4125[ int mib[2], r;
4126 size_t len;
4127
4128 mib[0] = CTL_HW;
4129 mib[1] = HW_USERMEM;
4130 len = sizeof(r);
4131 (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
4132 ],
4133 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL),
4134 AC_MSG_RESULT(not usable))
4135
Bram Moolenaare2982d62021-10-06 11:27:21 +01004136dnl sysinfo() may exist but not be Linux compatible.
4137dnl On some FreeBSD systems it may depend on libsysinfo, use TRY_LINK
Bram Moolenaar071d4272004-06-13 20:20:40 +00004138AC_MSG_CHECKING(for sysinfo)
Bram Moolenaare2982d62021-10-06 11:27:21 +01004139AC_TRY_LINK(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004140[#include <sys/types.h>
4141#include <sys/sysinfo.h>],
4142[ struct sysinfo sinfo;
4143 int t;
4144
4145 (void)sysinfo(&sinfo);
4146 t = sinfo.totalram;
4147 ],
4148 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
4149 AC_MSG_RESULT(not usable))
4150
Bram Moolenaar914572a2007-05-01 11:37:47 +00004151dnl struct sysinfo may have the mem_unit field or not
4152AC_MSG_CHECKING(for sysinfo.mem_unit)
4153AC_TRY_COMPILE(
4154[#include <sys/types.h>
4155#include <sys/sysinfo.h>],
4156[ struct sysinfo sinfo;
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02004157 sinfo.mem_unit = 1;
Bram Moolenaar914572a2007-05-01 11:37:47 +00004158 ],
4159 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_MEM_UNIT),
4160 AC_MSG_RESULT(no))
4161
Bram Moolenaarf52f0602021-03-10 21:26:37 +01004162dnl struct sysinfo may have the uptime field or not
4163AC_MSG_CHECKING(for sysinfo.uptime)
4164AC_TRY_COMPILE(
4165[#include <sys/types.h>
4166#include <sys/sysinfo.h>],
4167[ struct sysinfo sinfo;
4168 long ut;
4169
4170 (void)sysinfo(&sinfo);
4171 ut = sinfo.uptime;
4172 ],
4173 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_UPTIME),
4174 AC_MSG_RESULT(no))
4175
Bram Moolenaar071d4272004-06-13 20:20:40 +00004176dnl sysconf() may exist but not support what we want to use
4177AC_MSG_CHECKING(for sysconf)
4178AC_TRY_COMPILE(
4179[#include <unistd.h>],
4180[ (void)sysconf(_SC_PAGESIZE);
4181 (void)sysconf(_SC_PHYS_PAGES);
4182 ],
4183 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
4184 AC_MSG_RESULT(not usable))
4185
Bram Moolenaar0e62a672021-02-25 17:17:56 +01004186dnl check if we have _SC_SIGSTKSZ via sysconf()
4187AC_MSG_CHECKING(for _SC_SIGSTKSZ via sysconf())
4188AC_TRY_COMPILE(
4189[#include <unistd.h>],
4190[ (void)sysconf(_SC_SIGSTKSZ);
4191 ],
4192 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF_SIGSTKSZ),
4193 AC_MSG_RESULT(not usable))
4194
Bram Moolenaar914703b2010-05-31 21:59:46 +02004195AC_CHECK_SIZEOF([int])
4196AC_CHECK_SIZEOF([long])
4197AC_CHECK_SIZEOF([time_t])
4198AC_CHECK_SIZEOF([off_t])
Bram Moolenaar644fdff2010-05-30 13:26:21 +02004199
Bram Moolenaara2aa31a2014-02-23 22:52:40 +01004200dnl Use different names to avoid clashing with other header files.
4201AC_DEFINE_UNQUOTED(VIM_SIZEOF_INT, [$ac_cv_sizeof_int])
4202AC_DEFINE_UNQUOTED(VIM_SIZEOF_LONG, [$ac_cv_sizeof_long])
4203
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004204dnl Make sure that uint32_t is really 32 bits unsigned.
4205AC_MSG_CHECKING([uint32_t is 32 bits])
4206AC_TRY_RUN([
4207#ifdef HAVE_STDINT_H
4208# include <stdint.h>
4209#endif
4210#ifdef HAVE_INTTYPES_H
4211# include <inttypes.h>
4212#endif
4213main() {
4214 uint32_t nr1 = (uint32_t)-1;
4215 uint32_t nr2 = (uint32_t)0xffffffffUL;
Bram Moolenaar52897832020-07-02 22:50:37 +02004216 if (sizeof(uint32_t) != 4 || nr1 != 0xffffffffUL || nr2 + 1 != 0) return 1;
4217 return 0;
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004218}],
4219AC_MSG_RESULT(ok),
4220AC_MSG_ERROR([WRONG! uint32_t not defined correctly.]),
Bram Moolenaar323cb952011-12-14 19:22:34 +01004221AC_MSG_WARN([cannot check uint32_t when cross-compiling.]))
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004222
Bram Moolenaar446cb832008-06-24 21:56:24 +00004223dnl Check for memmove() before bcopy(), makes memmove() be used when both are
4224dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
4225
Bram Moolenaar071d4272004-06-13 20:20:40 +00004226[bcopy_test_prog='
Bram Moolenaar446cb832008-06-24 21:56:24 +00004227#include "confdefs.h"
4228#ifdef HAVE_STRING_H
4229# include <string.h>
4230#endif
4231#if STDC_HEADERS
4232# include <stdlib.h>
4233# include <stddef.h>
4234#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004235main() {
4236 char buf[10];
4237 strcpy(buf, "abcdefghi");
4238 mch_memmove(buf, buf + 2, 3);
4239 if (strncmp(buf, "ababcf", 6))
4240 exit(1);
4241 strcpy(buf, "abcdefghi");
4242 mch_memmove(buf + 2, buf, 3);
4243 if (strncmp(buf, "cdedef", 6))
4244 exit(1);
4245 exit(0); /* libc version works properly. */
4246}']
4247
Bram Moolenaar446cb832008-06-24 21:56:24 +00004248AC_CACHE_CHECK([whether memmove handles overlaps],[vim_cv_memmove_handles_overlap],
4249 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004250 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 +00004251 [
4252 vim_cv_memmove_handles_overlap=yes
4253 ],[
4254 vim_cv_memmove_handles_overlap=no
4255 ],[
4256 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memmove_handles_overlap')
4257 ])
4258 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00004259
Bram Moolenaar446cb832008-06-24 21:56:24 +00004260if test "x$vim_cv_memmove_handles_overlap" = "xyes" ; then
4261 AC_DEFINE(USEMEMMOVE)
4262else
4263 AC_CACHE_CHECK([whether bcopy handles overlaps],[vim_cv_bcopy_handles_overlap],
4264 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004265 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 +00004266 [
4267 vim_cv_bcopy_handles_overlap=yes
4268 ],[
4269 vim_cv_bcopy_handles_overlap=no
4270 ],[
4271 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_bcopy_handles_overlap')
4272 ])
4273 ])
4274
4275 if test "x$vim_cv_bcopy_handles_overlap" = "xyes" ; then
4276 AC_DEFINE(USEBCOPY)
4277 else
4278 AC_CACHE_CHECK([whether memcpy handles overlaps],[vim_cv_memcpy_handles_overlap],
4279 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004280 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 +00004281 [
4282 vim_cv_memcpy_handles_overlap=yes
4283 ],[
4284 vim_cv_memcpy_handles_overlap=no
4285 ],[
4286 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memcpy_handles_overlap')
4287 ])
4288 ])
4289
4290 if test "x$vim_cv_memcpy_handles_overlap" = "xyes" ; then
4291 AC_DEFINE(USEMEMCPY)
4292 fi
4293 fi
4294fi
4295
Bram Moolenaar071d4272004-06-13 20:20:40 +00004296
4297dnl Check for multibyte locale functions
4298dnl Find out if _Xsetlocale() is supported by libX11.
4299dnl Check if X_LOCALE should be defined.
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004300if test "x$with_x" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004301 cflags_save=$CFLAGS
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004302 libs_save=$LIBS
4303 LIBS="$LIBS $X_LIBS $GUI_LIB_LOC $GUI_X_LIBS $X_PRE_LIBS $X_LIB $X_EXTRA_LIBS"
4304 CFLAGS="$CFLAGS $X_CFLAGS"
4305
4306 AC_MSG_CHECKING(whether X_LOCALE needed)
4307 AC_TRY_COMPILE([#include <X11/Xlocale.h>],,
4308 AC_TRY_LINK_FUNC([_Xsetlocale], [AC_MSG_RESULT(yes)
4309 AC_DEFINE(X_LOCALE)], AC_MSG_RESULT(no)),
4310 AC_MSG_RESULT(no))
4311
4312 AC_MSG_CHECKING(whether Xutf8SetWMProperties() can be used)
4313 AC_TRY_LINK_FUNC([Xutf8SetWMProperties], [AC_MSG_RESULT(yes)
4314 AC_DEFINE(HAVE_XUTF8SETWMPROPERTIES)], AC_MSG_RESULT(no))
4315
Bram Moolenaar071d4272004-06-13 20:20:40 +00004316 CFLAGS=$cflags_save
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004317 LIBS=$libs_save
Bram Moolenaar071d4272004-06-13 20:20:40 +00004318fi
4319
4320dnl Link with xpg4, it is said to make Korean locale working
4321AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,)
4322
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004323dnl Check how we can run ctags. Default to "ctags" when nothing works.
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02004324dnl Use --version to detect Exuberant ctags (preferred)
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004325dnl Add --fields=+S to get function signatures for omni completion.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004326dnl -t for typedefs (many ctags have this)
4327dnl -s for static functions (Elvis ctags only?)
4328dnl -v for variables. Dangerous, most ctags take this for 'vgrind style'.
4329dnl -i+m to test for older Exuberant ctags
4330AC_MSG_CHECKING(how to create tags)
4331test -f tags && mv tags tags.save
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004332if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004333 TAGPRG="ctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004334elif (eval exctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004335 TAGPRG="exctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004336elif (eval exuberant-ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004337 TAGPRG="exuberant-ctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004338else
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004339 TAGPRG="ctags"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004340 (eval etags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags"
4341 (eval etags -c /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags -c"
4342 (eval ctags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags"
4343 (eval ctags -t /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -t"
4344 (eval ctags -ts /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -ts"
4345 (eval ctags -tvs /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -tvs"
4346 (eval ctags -i+m /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -i+m"
4347fi
4348test -f tags.save && mv tags.save tags
4349AC_MSG_RESULT($TAGPRG) AC_SUBST(TAGPRG)
4350
4351dnl Check how we can run man with a section number
4352AC_MSG_CHECKING(how to run man with a section nr)
4353MANDEF="man"
Bram Moolenaar8b131502008-02-13 09:28:19 +00004354(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 +00004355AC_MSG_RESULT($MANDEF)
4356if test "$MANDEF" = "man -s"; then
4357 AC_DEFINE(USEMAN_S)
4358fi
4359
4360dnl Check if gettext() is working and if it needs -lintl
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004361dnl We take care to base this on an empty LIBS: on some systems libelf would be
4362dnl in LIBS and implicitly take along libintl. The final LIBS would then not
4363dnl contain libintl, and the link step would fail due to -Wl,--as-needed.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004364AC_MSG_CHECKING(--disable-nls argument)
4365AC_ARG_ENABLE(nls,
4366 [ --disable-nls Don't support NLS (gettext()).], ,
4367 [enable_nls="yes"])
4368
4369if test "$enable_nls" = "yes"; then
4370 AC_MSG_RESULT(no)
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00004371
4372 INSTALL_LANGS=install-languages
4373 AC_SUBST(INSTALL_LANGS)
4374 INSTALL_TOOL_LANGS=install-tool-languages
4375 AC_SUBST(INSTALL_TOOL_LANGS)
4376
Bram Moolenaar071d4272004-06-13 20:20:40 +00004377 AC_CHECK_PROG(MSGFMT, msgfmt, msgfmt, )
4378 AC_MSG_CHECKING([for NLS])
4379 if test -f po/Makefile; then
4380 have_gettext="no"
4381 if test -n "$MSGFMT"; then
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004382 olibs=$LIBS
4383 LIBS=""
Bram Moolenaar071d4272004-06-13 20:20:40 +00004384 AC_TRY_LINK(
4385 [#include <libintl.h>],
4386 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004387 AC_MSG_RESULT([gettext() works]); have_gettext="yes"; LIBS=$olibs,
4388 LIBS="-lintl"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004389 AC_TRY_LINK(
4390 [#include <libintl.h>],
4391 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004392 AC_MSG_RESULT([gettext() works with -lintl]); have_gettext="yes";
4393 LIBS="$olibs -lintl",
Bram Moolenaar071d4272004-06-13 20:20:40 +00004394 AC_MSG_RESULT([gettext() doesn't work]);
4395 LIBS=$olibs))
4396 else
4397 AC_MSG_RESULT([msgfmt not found - disabled]);
4398 fi
Bram Moolenaar278eb582014-07-30 13:22:52 +02004399 if test $have_gettext = "yes" -a "x$features" != "xtiny" -a "x$features" != "xsmall"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004400 AC_DEFINE(HAVE_GETTEXT)
4401 MAKEMO=yes
4402 AC_SUBST(MAKEMO)
4403 dnl this was added in GNU gettext 0.10.36
4404 AC_CHECK_FUNCS(bind_textdomain_codeset)
4405 dnl _nl_msg_cat_cntr is required for GNU gettext
4406 AC_MSG_CHECKING([for _nl_msg_cat_cntr])
4407 AC_TRY_LINK(
4408 [#include <libintl.h>
4409 extern int _nl_msg_cat_cntr;],
4410 [++_nl_msg_cat_cntr;],
4411 AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_NL_MSG_CAT_CNTR),
4412 AC_MSG_RESULT([no]))
Bram Moolenaar26096cc2019-04-11 15:25:40 +02004413 AC_MSG_CHECKING([if msgfmt supports --desktop])
4414 MSGFMT_DESKTOP=
4415 if "$MSGFMT" --help | grep -e '--desktop' >/dev/null; then
Bram Moolenaar62a88f42019-06-07 20:44:40 +02004416 if "$MSGFMT" --version | grep '0.19.[[3-7]]$' >/dev/null; then
4417 dnl GNU gettext 0.19.7's --desktop is broken. We assume back to
4418 dnl 0.19.3 is also broken.
4419 AC_MSG_RESULT([broken])
4420 else
4421 AC_MSG_RESULT([yes])
4422 MSGFMT_DESKTOP="gvim.desktop vim.desktop"
4423 fi
Bram Moolenaar26096cc2019-04-11 15:25:40 +02004424 else
4425 AC_MSG_RESULT([no])
4426 fi
4427 AC_SUBST(MSGFMT_DESKTOP)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004428 fi
4429 else
4430 AC_MSG_RESULT([no "po/Makefile" - disabled]);
4431 fi
4432else
4433 AC_MSG_RESULT(yes)
4434fi
4435
4436dnl Check for dynamic linking loader
4437AC_CHECK_HEADER(dlfcn.h, DLL=dlfcn.h, [AC_CHECK_HEADER(dl.h, DLL=dl.h)])
4438if test x${DLL} = xdlfcn.h; then
4439 AC_DEFINE(HAVE_DLFCN_H, 1, [ Define if we have dlfcn.h. ])
4440 AC_MSG_CHECKING([for dlopen()])
4441 AC_TRY_LINK(,[
4442 extern void* dlopen();
4443 dlopen();
4444 ],
4445 AC_MSG_RESULT(yes);
4446 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4447 AC_MSG_RESULT(no);
4448 AC_MSG_CHECKING([for dlopen() in -ldl])
4449 olibs=$LIBS
4450 LIBS="$LIBS -ldl"
4451 AC_TRY_LINK(,[
4452 extern void* dlopen();
4453 dlopen();
4454 ],
4455 AC_MSG_RESULT(yes);
4456 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4457 AC_MSG_RESULT(no);
4458 LIBS=$olibs))
4459 dnl ReliantUNIX has dlopen() in libc but everything else in libdl
4460 dnl ick :-)
4461 AC_MSG_CHECKING([for dlsym()])
4462 AC_TRY_LINK(,[
4463 extern void* dlsym();
4464 dlsym();
4465 ],
4466 AC_MSG_RESULT(yes);
4467 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4468 AC_MSG_RESULT(no);
4469 AC_MSG_CHECKING([for dlsym() in -ldl])
4470 olibs=$LIBS
4471 LIBS="$LIBS -ldl"
4472 AC_TRY_LINK(,[
4473 extern void* dlsym();
4474 dlsym();
4475 ],
4476 AC_MSG_RESULT(yes);
4477 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4478 AC_MSG_RESULT(no);
4479 LIBS=$olibs))
4480elif test x${DLL} = xdl.h; then
4481 AC_DEFINE(HAVE_DL_H, 1, [ Define if we have dl.h. ])
4482 AC_MSG_CHECKING([for shl_load()])
4483 AC_TRY_LINK(,[
4484 extern void* shl_load();
4485 shl_load();
4486 ],
4487 AC_MSG_RESULT(yes);
4488 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4489 AC_MSG_RESULT(no);
4490 AC_MSG_CHECKING([for shl_load() in -ldld])
4491 olibs=$LIBS
4492 LIBS="$LIBS -ldld"
4493 AC_TRY_LINK(,[
4494 extern void* shl_load();
4495 shl_load();
4496 ],
4497 AC_MSG_RESULT(yes);
4498 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4499 AC_MSG_RESULT(no);
4500 LIBS=$olibs))
4501fi
4502AC_CHECK_HEADERS(setjmp.h)
4503
Bram Moolenaard0573012017-10-28 21:11:06 +02004504if test "x$MACOS_X" = "xyes" -a -n "$PERL"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004505 dnl -ldl must come after DynaLoader.a
4506 if echo $LIBS | grep -e '-ldl' >/dev/null; then
4507 LIBS=`echo $LIBS | sed s/-ldl//`
4508 PERL_LIBS="$PERL_LIBS -ldl"
4509 fi
4510fi
4511
Bram Moolenaard0573012017-10-28 21:11:06 +02004512if test "$MACOS_X" = "yes"; then
4513 AC_MSG_CHECKING([whether we need macOS frameworks])
Bram Moolenaar097148e2020-08-11 21:58:20 +02004514 if test "$MACOS_X_DARWIN" = "yes"; then
Bram Moolenaard0573012017-10-28 21:11:06 +02004515 if test "$features" = "tiny"; then
4516 dnl Since no FEAT_CLIPBOARD, no longer need for os_macosx.m.
4517 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_macosx.m++'`
4518 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_macosx.o++'`
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01004519 AC_MSG_RESULT([yes, we need CoreServices])
4520 LIBS="$LIBS -framework CoreServices"
Bram Moolenaard0573012017-10-28 21:11:06 +02004521 else
4522 AC_MSG_RESULT([yes, we need AppKit])
4523 LIBS="$LIBS -framework AppKit"
Bram Moolenaard0573012017-10-28 21:11:06 +02004524 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004525 else
Bram Moolenaard0573012017-10-28 21:11:06 +02004526 AC_MSG_RESULT([no])
Bram Moolenaar3437b912013-07-03 19:52:53 +02004527 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004528fi
4529
Bram Moolenaar3ae5fc92021-09-06 18:57:30 +02004530dnl On some systems REENTRANT needs to be defined. It should not hurt to use
4531dnl it everywhere.
4532if `echo "$CFLAGS" | grep -v D_REENTRANT >/dev/null`; then
4533 CFLAGS="$CFLAGS -D_REENTRANT"
4534fi
4535
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004536dnl gcc 3.1 changed the meaning of -MM. The only solution appears to be to
4537dnl use "-isystem" instead of "-I" for all non-Vim include dirs.
4538dnl But only when making dependencies, cproto and lint don't take "-isystem".
Bram Moolenaar32466aa2006-02-24 23:53:04 +00004539dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
4540dnl the number before the version number.
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004541DEPEND_CFLAGS_FILTER=
4542if test "$GCC" = yes; then
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004543 AC_MSG_CHECKING(for GCC 3 or later)
Bram Moolenaar348808f2020-02-07 20:50:07 +01004544 gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]][[0-9]]*\)\..*$/\1/g'`
Bram Moolenaarf740b292006-02-16 22:11:02 +00004545 if test "$gccmajor" -gt "2"; then
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004546 DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004547 AC_MSG_RESULT(yes)
4548 else
4549 AC_MSG_RESULT(no)
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004550 fi
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004551 dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
4552 dnl declared as char x[1] but actually longer. Introduced in gcc 4.0.
Bram Moolenaar56d1db32009-12-16 16:14:51 +00004553 dnl Also remove duplicate _FORTIFY_SOURCE arguments.
Bram Moolenaaraeabe052011-12-08 15:17:34 +01004554 dnl And undefine it first to avoid a warning.
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004555 AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
4556 if test "$gccmajor" -gt "3"; then
Bram Moolenaar26f20132021-04-03 17:33:52 +02004557 CFLAGS=`echo "$CFLAGS" | sed -e 's/-D_FORTIFY_SOURCE=.,//g' -e 's/ *-Wp,-D_FORTIFY_SOURCE=. / /g' -e 's/,-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/'`
4558 CPPFLAGS=`echo "$CPPFLAGS" | sed -e 's/-D_FORTIFY_SOURCE=.,//g' -e 's/ *-Wp,-D_FORTIFY_SOURCE=. / /g' -e 's/,-D_FORTIFY_SOURCE=. //g' -e 's/ *-D_FORTIFY_SOURCE=.//g' -e 's/ *-U_FORTIFY_SOURCE//g'`
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004559 AC_MSG_RESULT(yes)
4560 else
4561 AC_MSG_RESULT(no)
4562 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +00004563fi
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004564AC_SUBST(DEPEND_CFLAGS_FILTER)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004565
Bram Moolenaarec0557f2018-01-31 14:41:37 +01004566dnl On some systems AC_SYS_LARGEFILE determines that -D_FILE_OFFSET_BITS=64
4567dnl isn't required, but the CFLAGS for some of the libraries we're using
4568dnl include the define. Since the define changes the size of some datatypes
4569dnl (e.g. ino_t and off_t), all of Vim's modules must be compiled with a
4570dnl consistent value. It's therefore safest to force the use of the define
4571dnl if it's present in any of the *_CFLAGS variables.
4572AC_MSG_CHECKING(whether we need to force -D_FILE_OFFSET_BITS=64)
Bram Moolenaar9ce42132018-04-11 22:19:36 +02004573if 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 +01004574 AC_MSG_RESULT(yes)
4575 AC_DEFINE(_FILE_OFFSET_BITS, 64)
4576else
4577 AC_MSG_RESULT(no)
4578fi
4579
Bram Moolenaar6cd42db2020-12-04 18:09:54 +01004580dnl $LDFLAGS is passed to glibtool in libvterm, it doesn't like a space
4581dnl between "-L" and the path that follows.
4582LDFLAGS=`echo "$LDFLAGS" | sed -e 's/-L /-L/g'`
4583
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004584dnl link.sh tries to avoid overlinking in a hackish way.
4585dnl At least GNU ld supports --as-needed which provides the same functionality
4586dnl at linker level. Let's use it.
4587AC_MSG_CHECKING(linker --as-needed support)
4588LINK_AS_NEEDED=
4589# Check if linker supports --as-needed and --no-as-needed options
4590if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
Natanael Copa761ead42021-05-15 14:25:37 +02004591 if ! echo "$LDFLAGS" | grep -q -- '-Wl,[[^[:space:]]]*--as-needed'; then
4592 LDFLAGS="$LDFLAGS -Wl,--as-needed"
4593 fi
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004594 LINK_AS_NEEDED=yes
4595fi
4596if test "$LINK_AS_NEEDED" = yes; then
4597 AC_MSG_RESULT(yes)
4598else
4599 AC_MSG_RESULT(no)
4600fi
4601AC_SUBST(LINK_AS_NEEDED)
4602
Bram Moolenaar77c19352012-06-13 19:19:41 +02004603# IBM z/OS reset CFLAGS for config.mk
4604if test "$zOSUnix" = "yes"; then
4605 CFLAGS="-D_ALL_SOURCE -Wc,float\(ieee\),dll"
4606fi
4607
Bram Moolenaar071d4272004-06-13 20:20:40 +00004608dnl write output files
4609AC_OUTPUT(auto/config.mk:config.mk.in)
4610
4611dnl vim: set sw=2 tw=78 fo+=l: