blob: 86f70f581cd1999acde807ce44d35b509ff5149a [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
294 dnl (--with-x) or Motif, Athena or GTK GUI is used.
295 if test -z "$with_x" -a "X$enable_gui" != Xmotif -a "X$enable_gui" != Xathena -a "X$enable_gui" != Xgtk2 -a "X$enable_gui" != Xgtk3; then
296 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
543AC_MSG_CHECKING(--with-compiledby argument)
544AC_ARG_WITH(compiledby, [ --with-compiledby=NAME name to show in :version message],
545 compiledby="$withval"; AC_MSG_RESULT($withval),
546 compiledby=""; AC_MSG_RESULT(no))
547AC_SUBST(compiledby)
548
549AC_MSG_CHECKING(--disable-xsmp argument)
550AC_ARG_ENABLE(xsmp,
551 [ --disable-xsmp Disable XSMP session management],
552 , enable_xsmp="yes")
553
554if test "$enable_xsmp" = "yes"; then
555 AC_MSG_RESULT(no)
556 AC_MSG_CHECKING(--disable-xsmp-interact argument)
557 AC_ARG_ENABLE(xsmp-interact,
558 [ --disable-xsmp-interact Disable XSMP interaction],
559 , enable_xsmp_interact="yes")
560 if test "$enable_xsmp_interact" = "yes"; then
561 AC_MSG_RESULT(no)
562 AC_DEFINE(USE_XSMP_INTERACT)
563 else
564 AC_MSG_RESULT(yes)
565 fi
566else
567 AC_MSG_RESULT(yes)
568fi
569
Bram Moolenaar67ffb412022-01-08 13:36:57 +0000570AC_MSG_CHECKING([diff feature])
571if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
572 AC_MSG_RESULT([disabled in $features version])
573else
574 AC_MSG_RESULT(enabled)
575 AC_DEFINE(FEAT_DIFF)
576 XDIFF_OBJS_USED="\$(XDIFF_OBJS)"
577 AC_SUBST(XDIFF_OBJS_USED)
578fi
579
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200580dnl Check for Lua feature.
581AC_MSG_CHECKING(--enable-luainterp argument)
582AC_ARG_ENABLE(luainterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200583 [ --enable-luainterp[=OPTS] Include Lua interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200584 [enable_luainterp="no"])
585AC_MSG_RESULT($enable_luainterp)
586
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200587if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +0100588 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
589 AC_MSG_ERROR([cannot use Lua with tiny or small features])
590 fi
591
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200592 dnl -- find the lua executable
593 AC_SUBST(vi_cv_path_lua)
594
595 AC_MSG_CHECKING(--with-lua-prefix argument)
596 AC_ARG_WITH(lua_prefix,
597 [ --with-lua-prefix=PFX Prefix where Lua is installed.],
598 with_lua_prefix="$withval"; AC_MSG_RESULT($with_lua_prefix),
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200599 with_lua_prefix="";AC_MSG_RESULT(no))
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200600
601 if test "X$with_lua_prefix" != "X"; then
602 vi_cv_path_lua_pfx="$with_lua_prefix"
603 else
604 AC_MSG_CHECKING(LUA_PREFIX environment var)
605 if test "X$LUA_PREFIX" != "X"; then
606 AC_MSG_RESULT("$LUA_PREFIX")
607 vi_cv_path_lua_pfx="$LUA_PREFIX"
608 else
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200609 AC_MSG_RESULT([not set, default to /usr])
610 vi_cv_path_lua_pfx="/usr"
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200611 fi
612 fi
613
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200614 AC_MSG_CHECKING(--with-luajit)
615 AC_ARG_WITH(luajit,
616 [ --with-luajit Link with LuaJIT instead of Lua.],
617 [vi_cv_with_luajit="$withval"],
618 [vi_cv_with_luajit="no"])
619 AC_MSG_RESULT($vi_cv_with_luajit)
620
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200621 LUA_INC=
622 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200623 if test "x$vi_cv_with_luajit" != "xno"; then
624 dnl -- try to find LuaJIT executable
625 AC_PATH_PROG(vi_cv_path_luajit, luajit)
626 if test "X$vi_cv_path_luajit" != "X"; then
627 dnl -- find LuaJIT version
628 AC_CACHE_CHECK(LuaJIT version, vi_cv_version_luajit,
Bram Moolenaar49b10272013-11-21 12:17:51 +0100629 [ 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 +0200630 AC_CACHE_CHECK(Lua version of LuaJIT, vi_cv_version_lua_luajit,
631 [ vi_cv_version_lua_luajit=`${vi_cv_path_luajit} -e "print(_VERSION)" | sed 's/.* //'` ])
632 vi_cv_path_lua="$vi_cv_path_luajit"
633 vi_cv_version_lua="$vi_cv_version_lua_luajit"
634 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200635 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200636 dnl -- try to find Lua executable
637 AC_PATH_PROG(vi_cv_path_plain_lua, lua)
638 if test "X$vi_cv_path_plain_lua" != "X"; then
639 dnl -- find Lua version
640 AC_CACHE_CHECK(Lua version, vi_cv_version_plain_lua,
641 [ vi_cv_version_plain_lua=`${vi_cv_path_plain_lua} -e "print(_VERSION)" | sed 's/.* //'` ])
642 fi
643 vi_cv_path_lua="$vi_cv_path_plain_lua"
644 vi_cv_version_lua="$vi_cv_version_plain_lua"
645 fi
646 if test "x$vi_cv_with_luajit" != "xno" && test "X$vi_cv_version_luajit" != "X"; then
647 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 +0100648 if test -f "$vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200649 AC_MSG_RESULT(yes)
650 LUA_INC=/luajit-$vi_cv_version_luajit
651 fi
652 fi
653 if test "X$LUA_INC" = "X"; then
654 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)
Bram Moolenaar49222be2015-12-11 18:11:30 +0100655 if test -f "$vi_cv_path_lua_pfx/include/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200656 AC_MSG_RESULT(yes)
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200657 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200658 AC_MSG_RESULT(no)
659 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 +0100660 if test -f "$vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200661 AC_MSG_RESULT(yes)
662 LUA_INC=/lua$vi_cv_version_lua
663 else
664 AC_MSG_RESULT(no)
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200665
666 # Detect moonjit:
667 # https://groups.google.com/forum/#!topic/vim_use/O0vek60WuTk
668 lua_suf=/moonjit-2.3
669 inc_path="$vi_cv_path_lua_pfx/include"
Bram Moolenaarad4dc832020-04-20 16:21:53 +0200670 for dir in "$inc_path"/moonjit-[[0-9]]* ; do
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200671 if test -d "$dir" ; then
Bram Moolenaara79a8942020-12-17 20:50:25 +0100672 lua_suf=`basename "$dir"`
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200673 lua_suf="/$lua_suf"
674 break
675 fi
676 done
677 AC_MSG_CHECKING(if lua.h can be found in $inc_path$lua_suf)
678 if test -f "$inc_path$lua_suf/lua.h"; then
679 AC_MSG_RESULT(yes)
680 LUA_INC=$lua_suf
681 else
682 AC_MSG_RESULT(no)
683 vi_cv_path_lua_pfx=
684 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200685 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200686 fi
687 fi
688 fi
689
690 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200691 if test "x$vi_cv_with_luajit" != "xno"; then
692 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
693 if test "X$multiarch" != "X"; then
694 lib_multiarch="lib/${multiarch}"
695 else
696 lib_multiarch="lib"
697 fi
698 if test "X$vi_cv_version_lua" = "X"; then
699 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit"
700 else
701 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit-$vi_cv_version_lua"
702 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200703 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200704 if test "X$LUA_INC" != "X"; then
705 dnl Test alternate location using version
706 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua$vi_cv_version_lua"
707 else
708 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua"
709 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200710 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200711 if test "$enable_luainterp" = "dynamic"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200712 lua_ok="yes"
713 else
714 AC_MSG_CHECKING([if link with ${LUA_LIBS} is sane])
715 libs_save=$LIBS
716 LIBS="$LIBS $LUA_LIBS"
717 AC_TRY_LINK(,[ ],
718 AC_MSG_RESULT(yes); lua_ok="yes",
719 AC_MSG_RESULT(no); lua_ok="no"; LUA_LIBS="")
720 LIBS=$libs_save
721 fi
722 if test "x$lua_ok" = "xyes"; then
723 LUA_CFLAGS="-I${vi_cv_path_lua_pfx}/include${LUA_INC}"
724 LUA_SRC="if_lua.c"
725 LUA_OBJ="objects/if_lua.o"
726 LUA_PRO="if_lua.pro"
727 AC_DEFINE(FEAT_LUA)
728 fi
729 if test "$enable_luainterp" = "dynamic"; then
730 if test "x$vi_cv_with_luajit" != "xno"; then
731 luajit="jit"
732 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200733 if test -f "${vi_cv_path_lua_pfx}/bin/cyglua-${vi_cv_version_lua}.dll"; then
734 vi_cv_dll_name_lua="cyglua-${vi_cv_version_lua}.dll"
735 else
Bram Moolenaard0573012017-10-28 21:11:06 +0200736 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200737 ext="dylib"
738 indexes=""
739 else
740 ext="so"
741 indexes=".0 .1 .2 .3 .4 .5 .6 .7 .8 .9"
742 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
743 if test "X$multiarch" != "X"; then
744 lib_multiarch="lib/${multiarch}"
745 fi
Bram Moolenaar768baac2013-04-15 14:44:57 +0200746 fi
747 dnl Determine the sover for the current version, but fallback to
748 dnl liblua${vi_cv_version_lua}.so if no sover-versioned file is found.
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200749 AC_MSG_CHECKING(if liblua${luajit}*.${ext}* can be found in $vi_cv_path_lua_pfx)
Bram Moolenaar768baac2013-04-15 14:44:57 +0200750 for subdir in "${lib_multiarch}" lib64 lib; do
751 if test -z "$subdir"; then
752 continue
753 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200754 for sover in "${vi_cv_version_lua}.${ext}" "-${vi_cv_version_lua}.${ext}" \
755 ".${vi_cv_version_lua}.${ext}" ".${ext}.${vi_cv_version_lua}"; do
756 for i in $indexes ""; do
757 if test -f "${vi_cv_path_lua_pfx}/${subdir}/liblua${luajit}${sover}$i"; then
Bram Moolenaar768baac2013-04-15 14:44:57 +0200758 sover2="$i"
759 break 3
760 fi
761 done
Bram Moolenaar07e1da62013-02-06 19:49:43 +0100762 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200763 sover=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200764 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200765 if test "X$sover" = "X"; then
766 AC_MSG_RESULT(no)
767 lua_ok="no"
768 vi_cv_dll_name_lua="liblua${luajit}.${ext}"
769 else
770 AC_MSG_RESULT(yes)
771 lua_ok="yes"
772 vi_cv_dll_name_lua="liblua${luajit}${sover}$sover2"
773 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200774 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200775 AC_DEFINE(DYNAMIC_LUA)
776 LUA_LIBS=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200777 LUA_CFLAGS="-DDYNAMIC_LUA_DLL=\\\"${vi_cv_dll_name_lua}\\\" $LUA_CFLAGS"
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200778 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200779 if test "X$LUA_CFLAGS$LUA_LIBS" != "X" && \
Bram Moolenaard0573012017-10-28 21:11:06 +0200780 test "x$MACOS_X" = "xyes" && test "x$vi_cv_with_luajit" != "xno" && \
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000781 test "$vim_cv_uname_m_output" = "x86_64"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200782 dnl OSX/x64 requires these flags. See http://luajit.org/install.html
783 LUA_LIBS="-pagezero_size 10000 -image_base 100000000 $LUA_LIBS"
784 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200785 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200786 if test "$fail_if_missing" = "yes" -a "$lua_ok" != "yes"; then
Bram Moolenaarf788a062011-12-14 20:51:25 +0100787 AC_MSG_ERROR([could not configure lua])
788 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200789 AC_SUBST(LUA_SRC)
790 AC_SUBST(LUA_OBJ)
791 AC_SUBST(LUA_PRO)
792 AC_SUBST(LUA_LIBS)
793 AC_SUBST(LUA_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +0000794 AC_SUBST(LUA_CFLAGS_EXTRA)
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200795fi
796
797
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000798dnl Check for MzScheme feature.
799AC_MSG_CHECKING(--enable-mzschemeinterp argument)
800AC_ARG_ENABLE(mzschemeinterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200801 [ --enable-mzschemeinterp Include MzScheme interpreter.], ,
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000802 [enable_mzschemeinterp="no"])
803AC_MSG_RESULT($enable_mzschemeinterp)
804
805if test "$enable_mzschemeinterp" = "yes"; then
806 dnl -- find the mzscheme executable
807 AC_SUBST(vi_cv_path_mzscheme)
808
809 AC_MSG_CHECKING(--with-plthome argument)
810 AC_ARG_WITH(plthome,
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000811 [ --with-plthome=PLTHOME Use PLTHOME.],
812 with_plthome="$withval"; AC_MSG_RESULT($with_plthome),
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000813 with_plthome="";AC_MSG_RESULT("no"))
814
815 if test "X$with_plthome" != "X"; then
816 vi_cv_path_mzscheme_pfx="$with_plthome"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100817 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000818 else
819 AC_MSG_CHECKING(PLTHOME environment var)
820 if test "X$PLTHOME" != "X"; then
821 AC_MSG_RESULT("$PLTHOME")
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000822 vi_cv_path_mzscheme_pfx="$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
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000825 AC_MSG_RESULT(not set)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000826 dnl -- try to find MzScheme executable
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000827 AC_PATH_PROG(vi_cv_path_mzscheme, mzscheme)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000828
829 dnl resolve symbolic link, the executable is often elsewhere and there
830 dnl are no links for the include files.
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000831 if test "X$vi_cv_path_mzscheme" != "X"; then
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000832 lsout=`ls -l $vi_cv_path_mzscheme`
833 if echo "$lsout" | grep -e '->' >/dev/null 2>/dev/null; then
834 vi_cv_path_mzscheme=`echo "$lsout" | sed 's/.*-> \(.*\)/\1/'`
835 fi
836 fi
837
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000838 if test "X$vi_cv_path_mzscheme" != "X"; then
839 dnl -- find where MzScheme thinks it was installed
840 AC_CACHE_CHECK(MzScheme install prefix,vi_cv_path_mzscheme_pfx,
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000841 dnl different versions of MzScheme differ in command line processing
842 dnl use universal approach
843 echo "(display (simplify-path \
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000844 (build-path (call-with-values \
845 (lambda () (split-path (find-system-path (quote exec-file)))) \
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000846 (lambda (base name must-be-dir?) base)) (quote up))))" > mzdirs.scm
847 dnl Remove a trailing slash
848 [ vi_cv_path_mzscheme_pfx=`${vi_cv_path_mzscheme} -r mzdirs.scm | \
849 sed -e 's+/$++'` ])
850 rm -f mzdirs.scm
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000851 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000852 fi
853 fi
854
855 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100856 AC_MSG_CHECKING(for racket include directory)
857 SCHEME_INC=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-include-dir))) (when (path? p) (display p)))'`
858 if test "X$SCHEME_INC" != "X"; then
859 AC_MSG_RESULT(${SCHEME_INC})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000860 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100861 AC_MSG_RESULT(not found)
862 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include)
863 if test -f "$vi_cv_path_mzscheme_pfx/include/scheme.h"; then
864 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000865 AC_MSG_RESULT(yes)
Bram Moolenaard7afed32007-05-06 13:26:41 +0000866 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000867 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100868 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt)
869 if test -f "$vi_cv_path_mzscheme_pfx/include/plt/scheme.h"; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000870 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100871 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000872 else
873 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/racket)
875 if test -f "$vi_cv_path_mzscheme_pfx/include/racket/scheme.h"; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100876 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100877 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100878 else
879 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100880 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/)
881 if test -f /usr/include/plt/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=/usr/include/plt
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/racket/)
887 if test -f /usr/include/racket/scheme.h; then
888 AC_MSG_RESULT(yes)
889 SCHEME_INC=/usr/include/racket
890 else
891 AC_MSG_RESULT(no)
892 vi_cv_path_mzscheme_pfx=
893 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100894 fi
895 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000896 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000897 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000898 fi
899 fi
900
901 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100902
903 AC_MSG_CHECKING(for racket lib directory)
904 SCHEME_LIB=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-lib-dir))) (when (path? p) (display p)))'`
905 if test "X$SCHEME_LIB" != "X"; then
906 AC_MSG_RESULT(${SCHEME_LIB})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000907 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100908 AC_MSG_RESULT(not found)
909 fi
910
911 for path in "${vi_cv_path_mzscheme_pfx}/lib" "${SCHEME_LIB}"; do
912 if test "X$path" != "X"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200913 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100914 MZSCHEME_LIBS="-framework Racket"
915 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
916 elif test -f "${path}/libmzscheme3m.a"; then
917 MZSCHEME_LIBS="${path}/libmzscheme3m.a"
918 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
919 elif test -f "${path}/libracket3m.a"; then
920 MZSCHEME_LIBS="${path}/libracket3m.a"
Bram Moolenaar588d2412020-10-03 14:24:19 +0200921 if test -f "${path}/librktio.a"; then
922 MZSCHEME_LIBS="${MZSCHEME_LIBS} ${path}/librktio.a"
923 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100924 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
925 elif test -f "${path}/libracket.a"; then
926 MZSCHEME_LIBS="${path}/libracket.a ${path}/libmzgc.a"
927 elif test -f "${path}/libmzscheme.a"; then
928 MZSCHEME_LIBS="${path}/libmzscheme.a ${path}/libmzgc.a"
929 else
930 dnl Using shared objects
931 if test -f "${path}/libmzscheme3m.so"; then
932 MZSCHEME_LIBS="-L${path} -lmzscheme3m"
933 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
934 elif test -f "${path}/libracket3m.so"; then
935 MZSCHEME_LIBS="-L${path} -lracket3m"
936 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
937 elif test -f "${path}/libracket.so"; then
938 MZSCHEME_LIBS="-L${path} -lracket -lmzgc"
939 else
940 dnl try next until last
941 if test "$path" != "$SCHEME_LIB"; then
942 continue
943 fi
944 MZSCHEME_LIBS="-L${path} -lmzscheme -lmzgc"
945 fi
946 if test "$GCC" = yes; then
947 dnl Make Vim remember the path to the library. For when it's not in
948 dnl $LD_LIBRARY_PATH.
949 MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${path}"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000950 elif test "$vim_cv_uname_output" = SunOS &&
951 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100952 MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${path}"
953 fi
954 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000955 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100956 if test "X$MZSCHEME_LIBS" != "X"; then
957 break
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +0000958 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100959 done
960
961 AC_MSG_CHECKING([if racket requires -pthread])
962 if test "X$SCHEME_LIB" != "X" && $FGREP -e -pthread "$SCHEME_LIB/buildinfo" >/dev/null ; then
963 AC_MSG_RESULT(yes)
964 MZSCHEME_LIBS="${MZSCHEME_LIBS} -pthread"
965 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -pthread"
966 else
967 AC_MSG_RESULT(no)
968 fi
969
970 AC_MSG_CHECKING(for racket config directory)
971 SCHEME_CONFIGDIR=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-config-dir))) (when (path? p) (display p)))'`
972 if test "X$SCHEME_CONFIGDIR" != "X"; then
973 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DMZSCHEME_CONFIGDIR='\"${SCHEME_CONFIGDIR}\"'"
974 AC_MSG_RESULT(${SCHEME_CONFIGDIR})
975 else
976 AC_MSG_RESULT(not found)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000977 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100978
979 AC_MSG_CHECKING(for racket collects directory)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100980 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))))'`
981 if test "X$SCHEME_COLLECTS" = "X"; then
982 if test -d "$vi_cv_path_mzscheme_pfx/lib/plt/collects"; then
983 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/plt/
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100984 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100985 if test -d "$vi_cv_path_mzscheme_pfx/lib/racket/collects"; then
986 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/racket/
Bram Moolenaar75676462013-01-30 14:55:42 +0100987 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100988 if test -d "$vi_cv_path_mzscheme_pfx/share/racket/collects"; then
989 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/
990 else
991 if test -d "$vi_cv_path_mzscheme_pfx/collects"; then
992 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/
993 fi
Bram Moolenaar75676462013-01-30 14:55:42 +0100994 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100995 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100996 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000997 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100998 if test "X$SCHEME_COLLECTS" != "X" ; then
999 AC_MSG_RESULT(${SCHEME_COLLECTS})
1000 else
1001 AC_MSG_RESULT(not found)
1002 fi
1003
1004 AC_MSG_CHECKING(for mzscheme_base.c)
1005 if test -f "${SCHEME_COLLECTS}collects/scheme/base.ss" ; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001006 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +01001007 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
1008 MZSCHEME_MOD="++lib scheme/base"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +01001009 else
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001010 if test -f "${SCHEME_COLLECTS}collects/scheme/base.rkt" ; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +01001011 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +01001012 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
1013 MZSCHEME_MOD="++lib scheme/base"
1014 else
1015 if test -f "${SCHEME_COLLECTS}collects/racket/base.rkt" ; then
1016 MZSCHEME_EXTRA="mzscheme_base.c"
1017 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/raco ctool"
1018 MZSCHEME_MOD=""
1019 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +01001020 fi
1021 fi
1022 if test "X$MZSCHEME_EXTRA" != "X" ; then
1023 dnl need to generate bytecode for MzScheme base
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001024 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE"
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001025 AC_MSG_RESULT(needed)
1026 else
1027 AC_MSG_RESULT(not needed)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001028 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001029
Bram Moolenaar9e902192013-07-17 18:58:11 +02001030 dnl On Ubuntu this fixes "undefined reference to symbol 'ffi_type_void'".
1031 AC_CHECK_LIB(ffi, ffi_type_void, [MZSCHEME_LIBS="$MZSCHEME_LIBS -lffi"])
1032
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001033 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -I${SCHEME_INC} \
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001034 -DMZSCHEME_COLLECTS='\"${SCHEME_COLLECTS}collects\"'"
Bram Moolenaar9e902192013-07-17 18:58:11 +02001035
1036 dnl Test that we can compile a simple program with these CFLAGS and LIBS.
1037 AC_MSG_CHECKING([if compile and link flags for MzScheme are sane])
1038 cflags_save=$CFLAGS
1039 libs_save=$LIBS
1040 CFLAGS="$CFLAGS $MZSCHEME_CFLAGS"
1041 LIBS="$LIBS $MZSCHEME_LIBS"
1042 AC_TRY_LINK(,[ ],
1043 AC_MSG_RESULT(yes); mzs_ok=yes,
1044 AC_MSG_RESULT(no: MZSCHEME DISABLED); mzs_ok=no)
1045 CFLAGS=$cflags_save
1046 LIBS=$libs_save
1047 if test $mzs_ok = yes; then
1048 MZSCHEME_SRC="if_mzsch.c"
1049 MZSCHEME_OBJ="objects/if_mzsch.o"
1050 MZSCHEME_PRO="if_mzsch.pro"
1051 AC_DEFINE(FEAT_MZSCHEME)
1052 else
1053 MZSCHEME_CFLAGS=
1054 MZSCHEME_LIBS=
1055 MZSCHEME_EXTRA=
1056 MZSCHEME_MZC=
1057 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001058 fi
1059 AC_SUBST(MZSCHEME_SRC)
1060 AC_SUBST(MZSCHEME_OBJ)
1061 AC_SUBST(MZSCHEME_PRO)
1062 AC_SUBST(MZSCHEME_LIBS)
1063 AC_SUBST(MZSCHEME_CFLAGS)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001064 AC_SUBST(MZSCHEME_EXTRA)
1065 AC_SUBST(MZSCHEME_MZC)
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001066fi
1067
1068
Bram Moolenaar071d4272004-06-13 20:20:40 +00001069AC_MSG_CHECKING(--enable-perlinterp argument)
1070AC_ARG_ENABLE(perlinterp,
Bram Moolenaare06c1882010-07-21 22:05:20 +02001071 [ --enable-perlinterp[=OPTS] Include Perl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001072 [enable_perlinterp="no"])
1073AC_MSG_RESULT($enable_perlinterp)
Bram Moolenaare06c1882010-07-21 22:05:20 +02001074if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01001075 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1076 AC_MSG_ERROR([cannot use Perl with tiny or small features])
1077 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001078 AC_SUBST(vi_cv_path_perl)
1079 AC_PATH_PROG(vi_cv_path_perl, perl)
1080 if test "X$vi_cv_path_perl" != "X"; then
1081 AC_MSG_CHECKING(Perl version)
1082 if $vi_cv_path_perl -e 'require 5.003_01' >/dev/null 2>/dev/null; then
1083 eval `$vi_cv_path_perl -V:usethreads`
Bram Moolenaare06c1882010-07-21 22:05:20 +02001084 eval `$vi_cv_path_perl -V:libperl`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001085 if test "X$usethreads" = "XUNKNOWN" -o "X$usethreads" = "Xundef"; then
1086 badthreads=no
1087 else
1088 if $vi_cv_path_perl -e 'require 5.6.0' >/dev/null 2>/dev/null; then
1089 eval `$vi_cv_path_perl -V:use5005threads`
1090 if test "X$use5005threads" = "XUNKNOWN" -o "X$use5005threads" = "Xundef"; then
1091 badthreads=no
1092 else
1093 badthreads=yes
1094 AC_MSG_RESULT(>>> Perl > 5.6 with 5.5 threads cannot be used <<<)
1095 fi
1096 else
1097 badthreads=yes
1098 AC_MSG_RESULT(>>> Perl 5.5 with threads cannot be used <<<)
1099 fi
1100 fi
1101 if test $badthreads = no; then
1102 AC_MSG_RESULT(OK)
1103 eval `$vi_cv_path_perl -V:shrpenv`
1104 if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04
1105 shrpenv=""
1106 fi
1107 vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlibexp}'`
1108 AC_SUBST(vi_cv_perllib)
Bram Moolenaard5f62b12014-08-17 17:05:44 +02001109 vi_cv_perl_extutils=unknown_perl_extutils_path
1110 for extutils_rel_path in ExtUtils vendor_perl/ExtUtils; do
1111 xsubpp_path="$vi_cv_perllib/$extutils_rel_path/xsubpp"
1112 if test -f "$xsubpp_path"; then
1113 vi_cv_perl_xsubpp="$xsubpp_path"
1114 fi
1115 done
1116 AC_SUBST(vi_cv_perl_xsubpp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001117 dnl Remove "-fno-something", it breaks using cproto.
Bram Moolenaar280a8682015-06-21 13:41:08 +02001118 dnl Remove "-fdebug-prefix-map", it isn't supported by clang.
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001119 dnl Remove "FORTIFY_SOURCE", it will be defined twice.
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001120 dnl remove -pipe and -Wxxx, it confuses cproto
Bram Moolenaar071d4272004-06-13 20:20:40 +00001121 perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001122 -e 'ccflags;perl_inc;print"\n"' | sed -e 's/-fno[[^ ]]*//' \
1123 -e 's/-fdebug-prefix-map[[^ ]]*//g' \
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001124 -e 's/-pipe //' \
1125 -e 's/-W[[^ ]]*//g' \
1126 -e 's/-D_FORTIFY_SOURCE=.//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001127 dnl Remove "-lc", it breaks on FreeBSD when using "-pthread".
1128 perllibs=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed -e 'ldopts' | \
1129 sed -e '/Warning/d' -e '/Note (probably harmless)/d' \
1130 -e 's/-bE:perl.exp//' -e 's/-lc //'`
1131 dnl Don't add perl lib to $LIBS: if it's not in LD_LIBRARY_PATH
1132 dnl a test in configure may fail because of that.
1133 perlldflags=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed \
1134 -e 'ccdlflags' | sed -e 's/-bE:perl.exp//'`
1135
1136 dnl check that compiling a simple program still works with the flags
1137 dnl added for Perl.
1138 AC_MSG_CHECKING([if compile and link flags for Perl are sane])
1139 cflags_save=$CFLAGS
1140 libs_save=$LIBS
1141 ldflags_save=$LDFLAGS
1142 CFLAGS="$CFLAGS $perlcppflags"
1143 LIBS="$LIBS $perllibs"
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001144 perlldflags=`echo "$perlldflags" | sed -e 's/^ *//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001145 LDFLAGS="$perlldflags $LDFLAGS"
1146 AC_TRY_LINK(,[ ],
1147 AC_MSG_RESULT(yes); perl_ok=yes,
1148 AC_MSG_RESULT(no: PERL DISABLED); perl_ok=no)
1149 CFLAGS=$cflags_save
1150 LIBS=$libs_save
1151 LDFLAGS=$ldflags_save
1152 if test $perl_ok = yes; then
1153 if test "X$perlcppflags" != "X"; then
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001154 PERL_CFLAGS=$perlcppflags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001155 fi
1156 if test "X$perlldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001157 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$perlldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001158 LDFLAGS="$perlldflags $LDFLAGS"
1159 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001160 fi
1161 PERL_LIBS=$perllibs
1162 PERL_SRC="auto/if_perl.c if_perlsfio.c"
1163 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o"
1164 PERL_PRO="if_perl.pro if_perlsfio.pro"
1165 AC_DEFINE(FEAT_PERL)
1166 fi
1167 fi
1168 else
1169 AC_MSG_RESULT(>>> too old; need Perl version 5.003_01 or later <<<)
1170 fi
1171 fi
1172
Bram Moolenaard0573012017-10-28 21:11:06 +02001173 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00001174 dnl Mac OS X 10.2 or later
Bram Moolenaar071d4272004-06-13 20:20:40 +00001175 dir=/System/Library/Perl
1176 darwindir=$dir/darwin
1177 if test -d $darwindir; then
1178 PERL=/usr/bin/perl
1179 else
1180 dnl Mac OS X 10.3
1181 dir=/System/Library/Perl/5.8.1
1182 darwindir=$dir/darwin-thread-multi-2level
1183 if test -d $darwindir; then
1184 PERL=/usr/bin/perl
1185 fi
1186 fi
1187 if test -n "$PERL"; then
1188 PERL_DIR="$dir"
1189 PERL_CFLAGS="-DFEAT_PERL -I$darwindir/CORE"
1190 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o $darwindir/auto/DynaLoader/DynaLoader.a"
1191 PERL_LIBS="-L$darwindir/CORE -lperl"
1192 fi
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001193 dnl Perl on Mac OS X 10.5 adds "-arch" flags but these should only
1194 dnl be included if requested by passing --with-mac-arch to
1195 dnl configure, so strip these flags first (if present)
1196 PERL_LIBS=`echo "$PERL_LIBS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
1197 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 +00001198 fi
Bram Moolenaare06c1882010-07-21 22:05:20 +02001199 if test "$enable_perlinterp" = "dynamic"; then
1200 if test "$perl_ok" = "yes" -a "X$libperl" != "X"; then
1201 AC_DEFINE(DYNAMIC_PERL)
1202 PERL_CFLAGS="-DDYNAMIC_PERL_DLL=\\\"$libperl\\\" $PERL_CFLAGS"
1203 fi
1204 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001205
1206 if test "$fail_if_missing" = "yes" -a "$perl_ok" != "yes"; then
1207 AC_MSG_ERROR([could not configure perl])
1208 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001209fi
1210AC_SUBST(shrpenv)
1211AC_SUBST(PERL_SRC)
1212AC_SUBST(PERL_OBJ)
1213AC_SUBST(PERL_PRO)
1214AC_SUBST(PERL_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00001215AC_SUBST(PERL_CFLAGS_EXTRA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001216AC_SUBST(PERL_LIBS)
1217
1218AC_MSG_CHECKING(--enable-pythoninterp argument)
1219AC_ARG_ENABLE(pythoninterp,
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001220 [ --enable-pythoninterp[=OPTS] Include Python interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001221 [enable_pythoninterp="no"])
1222AC_MSG_RESULT($enable_pythoninterp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001223if test "$enable_pythoninterp" = "yes" -o "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001224 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1225 AC_MSG_ERROR([cannot use Python with tiny or small features])
1226 fi
1227
Bram Moolenaar071d4272004-06-13 20:20:40 +00001228 dnl -- find the python executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001229 AC_MSG_CHECKING(--with-python-command argument)
1230 AC_SUBST(vi_cv_path_python)
1231 AC_ARG_WITH(python-command, [ --with-python-command=NAME name of the Python 2 command (default: python2 or python)],
1232 vi_cv_path_python="$withval"; AC_MSG_RESULT($vi_cv_path_python),
1233 AC_MSG_RESULT(no))
1234
1235 if test "X$vi_cv_path_python" = "X"; then
1236 AC_PATH_PROGS(vi_cv_path_python, python2 python)
1237 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001238 if test "X$vi_cv_path_python" != "X"; then
1239
1240 dnl -- get its version number
1241 AC_CACHE_CHECK(Python version,vi_cv_var_python_version,
1242 [[vi_cv_var_python_version=`
1243 ${vi_cv_path_python} -c 'import sys; print sys.version[:3]'`
1244 ]])
1245
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001246 dnl -- it must be at least version 2.3
1247 AC_MSG_CHECKING(Python is 2.3 or better)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001248 if ${vi_cv_path_python} -c \
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001249 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001250 then
1251 AC_MSG_RESULT(yep)
1252
1253 dnl -- find where python thinks it was installed
1254 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python_pfx,
1255 [ vi_cv_path_python_pfx=`
1256 ${vi_cv_path_python} -c \
1257 "import sys; print sys.prefix"` ])
1258
1259 dnl -- and where it thinks it runs
1260 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python_epfx,
1261 [ vi_cv_path_python_epfx=`
1262 ${vi_cv_path_python} -c \
1263 "import sys; print sys.exec_prefix"` ])
1264
1265 dnl -- python's internal library path
1266
1267 AC_CACHE_VAL(vi_cv_path_pythonpath,
1268 [ vi_cv_path_pythonpath=`
1269 unset PYTHONPATH;
1270 ${vi_cv_path_python} -c \
1271 "import sys, string; print string.join(sys.path,':')"` ])
1272
1273 dnl -- where the Python implementation library archives are
1274
1275 AC_ARG_WITH(python-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001276 [ --with-python-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001277 [ vi_cv_path_python_conf="${withval}"; have_python_config_dir=1 ] )
Bram Moolenaar071d4272004-06-13 20:20:40 +00001278
1279 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python_conf,
1280 [
1281 vi_cv_path_python_conf=
Bram Moolenaarac499e32013-06-02 19:14:17 +02001282 d=`${vi_cv_path_python} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBPL')"`
1283 if test -d "$d" && test -f "$d/config.c"; then
1284 vi_cv_path_python_conf="$d"
1285 else
1286 for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
1287 for subdir in lib64 lib share; do
1288 d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
1289 if test -d "$d" && test -f "$d/config.c"; then
1290 vi_cv_path_python_conf="$d"
1291 fi
1292 done
Bram Moolenaar071d4272004-06-13 20:20:40 +00001293 done
Bram Moolenaarac499e32013-06-02 19:14:17 +02001294 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001295 ])
1296
1297 PYTHON_CONFDIR="${vi_cv_path_python_conf}"
1298
1299 if test "X$PYTHON_CONFDIR" = "X"; then
1300 AC_MSG_RESULT([can't find it!])
1301 else
1302
1303 dnl -- we need to examine Python's config/Makefile too
1304 dnl see what the interpreter is built from
1305 AC_CACHE_VAL(vi_cv_path_python_plibs,
1306 [
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001307 pwd=`pwd`
1308 tmp_mkf="$pwd/config-PyMake$$"
1309 cat -- "${PYTHON_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001310__:
Bram Moolenaar218116c2010-05-20 21:46:00 +02001311 @echo "python_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001312 @echo "python_LIBS='$(LIBS)'"
1313 @echo "python_SYSLIBS='$(SYSLIBS)'"
1314 @echo "python_LINKFORSHARED='$(LINKFORSHARED)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001315 @echo "python_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001316 @echo "python_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001317 @echo "python_PYTHONFRAMEWORK='$(PYTHONFRAMEWORK)'"
1318 @echo "python_PYTHONFRAMEWORKPREFIX='$(PYTHONFRAMEWORKPREFIX)'"
1319 @echo "python_PYTHONFRAMEWORKINSTALLDIR='$(PYTHONFRAMEWORKINSTALLDIR)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001320eof
1321 dnl -- delete the lines from make about Entering/Leaving directory
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001322 eval "`cd ${PYTHON_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1323 rm -f -- "${tmp_mkf}"
Bram Moolenaard0573012017-10-28 21:11:06 +02001324 if test "x$MACOS_X" = "xyes" && test -n "${python_PYTHONFRAMEWORK}" && ${vi_cv_path_python} -c \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001325 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then
1326 vi_cv_path_python_plibs="-framework Python"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001327 if test "x${vi_cv_path_python}" != "x/usr/bin/python" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
1328 vi_cv_path_python_plibs="-F${python_PYTHONFRAMEWORKPREFIX} -framework Python"
1329 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001330 else
Bram Moolenaar9ce42132018-04-11 22:19:36 +02001331 vi_cv_path_python_plibs="-L${PYTHON_CONFDIR} -lpython${vi_cv_var_python_version}"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001332 dnl -- Check if the path contained in python_LINKFORSHARED is
1333 dnl usable for vim build. If not, make and try other
1334 dnl candidates.
Bram Moolenaara161e262015-03-24 15:14:27 +01001335 if test -n "${python_LINKFORSHARED}" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
Bram Moolenaar6c927552015-03-24 12:21:33 +01001336 python_link_symbol=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]].*/\1/'`
1337 python_link_path=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]][[ \t]]*\(.*\)/\2/'`
1338 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1339 dnl -- The path looks relative. Guess the absolute one using
1340 dnl the prefix and try that.
1341 python_link_path="${python_PYTHONFRAMEWORKPREFIX}/${python_link_path}"
1342 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1343 dnl -- A last resort.
1344 python_link_path="${python_PYTHONFRAMEWORKINSTALLDIR}/Versions/${vi_cv_var_python_version}/${python_PYTHONFRAMEWORK}"
1345 dnl -- No check is done. The last word is left to the
1346 dnl "sanity" test on link flags that follows shortly.
1347 fi
1348 python_LINKFORSHARED="${python_link_symbol} ${python_link_path}"
1349 fi
1350 fi
Bram Moolenaar218116c2010-05-20 21:46:00 +02001351 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 +00001352 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1353 vi_cv_path_python_plibs=`echo $vi_cv_path_python_plibs | sed s/-ltermcap//`
1354 fi
1355 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001356 AC_CACHE_CHECK(Python's dll name,vi_cv_dll_name_python,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001357 [
1358 if test "X$python_DLLLIBRARY" != "X"; then
1359 vi_cv_dll_name_python="$python_DLLLIBRARY"
1360 else
1361 vi_cv_dll_name_python="$python_INSTSONAME"
1362 fi
1363 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00001364
1365 PYTHON_LIBS="${vi_cv_path_python_plibs}"
1366 if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001367 PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001368 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001369 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 +00001370 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001371 if test "X$have_python_config_dir" = "X1" -a "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001372 dnl Define PYTHON_HOME if --with-python-config-dir was used
1373 PYTHON_CFLAGS="${PYTHON_CFLAGS} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'"
1374
1375 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001376 PYTHON_SRC="if_python.c"
Bram Moolenaar9bdb9a02012-07-25 16:32:08 +02001377 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001378
1379 dnl On FreeBSD linking with "-pthread" is required to use threads.
1380 dnl _THREAD_SAFE must be used for compiling then.
1381 dnl The "-pthread" is added to $LIBS, so that the following check for
1382 dnl sigaltstack() will look in libc_r (it's there in libc!).
1383 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1384 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1385 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1386 AC_MSG_CHECKING([if -pthread should be used])
1387 threadsafe_flag=
1388 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001389 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001390 if test "$vim_cv_uname_output" != Darwin; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001391 test "$GCC" = yes && threadsafe_flag="-pthread"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001392 if test "$vim_cv_uname_output" = FreeBSD; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001393 threadsafe_flag="-D_THREAD_SAFE"
1394 thread_lib="-pthread"
1395 fi
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001396 if test "$vim_cv_uname_output" = SunOS; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001397 threadsafe_flag="-pthreads"
1398 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001399 fi
1400 libs_save_old=$LIBS
1401 if test -n "$threadsafe_flag"; then
1402 cflags_save=$CFLAGS
1403 CFLAGS="$CFLAGS $threadsafe_flag"
1404 LIBS="$LIBS $thread_lib"
1405 AC_TRY_LINK(,[ ],
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001406 AC_MSG_RESULT(yes); PYTHON_CFLAGS="$PYTHON_CFLAGS $threadsafe_flag",
Bram Moolenaar071d4272004-06-13 20:20:40 +00001407 AC_MSG_RESULT(no); LIBS=$libs_save_old
1408 )
1409 CFLAGS=$cflags_save
1410 else
1411 AC_MSG_RESULT(no)
1412 fi
1413
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001414 dnl Check that compiling a simple program still works with the flags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001415 dnl added for Python.
1416 AC_MSG_CHECKING([if compile and link flags for Python are sane])
1417 cflags_save=$CFLAGS
1418 libs_save=$LIBS
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001419 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001420 LIBS="$LIBS $PYTHON_LIBS"
1421 AC_TRY_LINK(,[ ],
1422 AC_MSG_RESULT(yes); python_ok=yes,
1423 AC_MSG_RESULT(no: PYTHON DISABLED); python_ok=no)
1424 CFLAGS=$cflags_save
1425 LIBS=$libs_save
1426 if test $python_ok = yes; then
1427 AC_DEFINE(FEAT_PYTHON)
1428 else
1429 LIBS=$libs_save_old
1430 PYTHON_SRC=
1431 PYTHON_OBJ=
1432 PYTHON_LIBS=
1433 PYTHON_CFLAGS=
1434 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001435 fi
1436 else
1437 AC_MSG_RESULT(too old)
1438 fi
1439 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001440
1441 if test "$fail_if_missing" = "yes" -a "$python_ok" != "yes"; then
1442 AC_MSG_ERROR([could not configure python])
1443 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001444fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001445
Bram Moolenaar071d4272004-06-13 20:20:40 +00001446AC_SUBST(PYTHON_LIBS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001447AC_SUBST(PYTHON_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00001448AC_SUBST(PYTHON_CFLAGS_EXTRA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001449AC_SUBST(PYTHON_SRC)
1450AC_SUBST(PYTHON_OBJ)
1451
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001452
1453AC_MSG_CHECKING(--enable-python3interp argument)
1454AC_ARG_ENABLE(python3interp,
Bram Moolenaar8008b632017-07-18 21:33:20 +02001455 [ --enable-python3interp[=OPTS] Include Python3 interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001456 [enable_python3interp="no"])
1457AC_MSG_RESULT($enable_python3interp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001458if test "$enable_python3interp" = "yes" -o "$enable_python3interp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001459 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1460 AC_MSG_ERROR([cannot use Python with tiny or small features])
1461 fi
1462
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001463 dnl -- find the python3 executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001464 AC_MSG_CHECKING(--with-python3-command argument)
1465 AC_SUBST(vi_cv_path_python3)
1466 AC_ARG_WITH(python3-command, [ --with-python3-command=NAME name of the Python 3 command (default: python3 or python)],
1467 vi_cv_path_python3="$withval"; AC_MSG_RESULT($vi_cv_path_python3),
1468 AC_MSG_RESULT(no))
1469
1470 if test "X$vi_cv_path_python3" = "X"; then
1471 AC_PATH_PROGS(vi_cv_path_python3, python3 python)
1472 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001473 if test "X$vi_cv_path_python3" != "X"; then
1474
1475 dnl -- get its version number
1476 AC_CACHE_CHECK(Python version,vi_cv_var_python3_version,
1477 [[vi_cv_var_python3_version=`
Bram Moolenaar23c01922021-05-21 11:43:58 +02001478 ${vi_cv_path_python3} -c 'import sys; print("{}.{}".format(sys.version_info.major, sys.version_info.minor))'`
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001479 ]])
1480
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001481 dnl -- it must be at least version 3
1482 AC_MSG_CHECKING(Python is 3.0 or better)
1483 if ${vi_cv_path_python3} -c \
1484 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.0)"
1485 then
1486 AC_MSG_RESULT(yep)
Bram Moolenaar456f2bb2011-06-12 21:37:13 +02001487
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001488 dnl -- get abiflags for python 3.2 or higher (PEP 3149)
1489 AC_CACHE_CHECK(Python's abiflags,vi_cv_var_python3_abiflags,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001490 [
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001491 vi_cv_var_python3_abiflags=
1492 if ${vi_cv_path_python3} -c \
1493 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)"
1494 then
1495 vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \
1496 "import sys; print(sys.abiflags)"`
1497 fi ])
1498
1499 dnl -- find where python3 thinks it was installed
1500 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx,
1501 [ vi_cv_path_python3_pfx=`
1502 ${vi_cv_path_python3} -c \
1503 "import sys; print(sys.prefix)"` ])
1504
1505 dnl -- and where it thinks it runs
1506 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx,
1507 [ vi_cv_path_python3_epfx=`
1508 ${vi_cv_path_python3} -c \
1509 "import sys; print(sys.exec_prefix)"` ])
1510
1511 dnl -- python3's internal library path
1512
1513 AC_CACHE_VAL(vi_cv_path_python3path,
1514 [ vi_cv_path_python3path=`
1515 unset PYTHONPATH;
1516 ${vi_cv_path_python3} -c \
1517 "import sys, string; print(':'.join(sys.path))"` ])
1518
1519 dnl -- where the Python implementation library archives are
1520
1521 AC_ARG_WITH(python3-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001522 [ --with-python3-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001523 [ vi_cv_path_python3_conf="${withval}"; have_python3_config_dir=1 ] )
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001524
1525 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf,
1526 [
1527 vi_cv_path_python3_conf=
Bram Moolenaarfee496d2013-07-12 20:07:24 +02001528 config_dir="config-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Zdenek Dohnal31e299c2021-06-10 18:50:55 +02001529 d=`${vi_cv_path_python3} -c "import sysconfig; print(sysconfig.get_config_var('LIBPL'))" 2> /dev/null`
1530 if test "x$d" = "x"; then
1531 d=`${vi_cv_path_python3} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBPL'))"`
1532 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001533 if test -d "$d" && test -f "$d/config.c"; then
1534 vi_cv_path_python3_conf="$d"
1535 else
1536 for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do
1537 for subdir in lib64 lib share; do
1538 d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}"
1539 if test -d "$d" && test -f "$d/config.c"; then
1540 vi_cv_path_python3_conf="$d"
1541 fi
1542 done
1543 done
1544 fi
1545 ])
1546
1547 PYTHON3_CONFDIR="${vi_cv_path_python3_conf}"
1548
1549 if test "X$PYTHON3_CONFDIR" = "X"; then
1550 AC_MSG_RESULT([can't find it!])
1551 else
1552
1553 dnl -- we need to examine Python's config/Makefile too
1554 dnl see what the interpreter is built from
1555 AC_CACHE_VAL(vi_cv_path_python3_plibs,
1556 [
1557 pwd=`pwd`
1558 tmp_mkf="$pwd/config-PyMake$$"
1559 cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001560__:
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001561 @echo "python3_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001562 @echo "python3_LIBS='$(LIBS)'"
1563 @echo "python3_SYSLIBS='$(SYSLIBS)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001564 @echo "python3_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001565 @echo "python3_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001566eof
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001567 dnl -- delete the lines from make about Entering/Leaving directory
1568 eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1569 rm -f -- "${tmp_mkf}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001570 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 +02001571 vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}"
1572 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1573 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//`
1574 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//`
1575 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001576 AC_CACHE_CHECK(Python3's dll name,vi_cv_dll_name_python3,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001577 [
1578 if test "X$python3_DLLLIBRARY" != "X"; then
1579 vi_cv_dll_name_python3="$python3_DLLLIBRARY"
1580 else
1581 vi_cv_dll_name_python3="$python3_INSTSONAME"
1582 fi
1583 ])
1584
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001585 PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
1586 if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001587 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 +02001588 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001589 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 +02001590 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001591 if test "X$have_python3_config_dir" = "X1" -a "$enable_python3interp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001592 dnl Define PYTHON3_HOME if --with-python-config-dir was used
1593 PYTHON3_CFLAGS="${PYTHON3_CFLAGS} -DPYTHON3_HOME='L\"${vi_cv_path_python3_pfx}\"'"
1594 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001595 PYTHON3_SRC="if_python3.c"
1596 PYTHON3_OBJ="objects/if_python3.o"
1597
1598 dnl On FreeBSD linking with "-pthread" is required to use threads.
1599 dnl _THREAD_SAFE must be used for compiling then.
1600 dnl The "-pthread" is added to $LIBS, so that the following check for
1601 dnl sigaltstack() will look in libc_r (it's there in libc!).
1602 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1603 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1604 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1605 AC_MSG_CHECKING([if -pthread should be used])
1606 threadsafe_flag=
1607 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001608 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001609 if test "$vim_cv_uname_output" != Darwin; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001610 test "$GCC" = yes && threadsafe_flag="-pthread"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001611 if test "$vim_cv_uname_output" = FreeBSD; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001612 threadsafe_flag="-D_THREAD_SAFE"
1613 thread_lib="-pthread"
1614 fi
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001615 if test "$vim_cv_uname_output" = SunOS; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001616 threadsafe_flag="-pthreads"
1617 fi
1618 fi
1619 libs_save_old=$LIBS
1620 if test -n "$threadsafe_flag"; then
1621 cflags_save=$CFLAGS
1622 CFLAGS="$CFLAGS $threadsafe_flag"
1623 LIBS="$LIBS $thread_lib"
1624 AC_TRY_LINK(,[ ],
1625 AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag",
1626 AC_MSG_RESULT(no); LIBS=$libs_save_old
1627 )
1628 CFLAGS=$cflags_save
1629 else
1630 AC_MSG_RESULT(no)
1631 fi
1632
1633 dnl check that compiling a simple program still works with the flags
1634 dnl added for Python.
1635 AC_MSG_CHECKING([if compile and link flags for Python 3 are sane])
1636 cflags_save=$CFLAGS
1637 libs_save=$LIBS
1638 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1639 LIBS="$LIBS $PYTHON3_LIBS"
1640 AC_TRY_LINK(,[ ],
1641 AC_MSG_RESULT(yes); python3_ok=yes,
1642 AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no)
1643 CFLAGS=$cflags_save
1644 LIBS=$libs_save
1645 if test "$python3_ok" = yes; then
1646 AC_DEFINE(FEAT_PYTHON3)
1647 else
1648 LIBS=$libs_save_old
1649 PYTHON3_SRC=
1650 PYTHON3_OBJ=
1651 PYTHON3_LIBS=
1652 PYTHON3_CFLAGS=
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001653 fi
1654 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001655 else
1656 AC_MSG_RESULT(too old)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001657 fi
1658 fi
Bram Moolenaar1612b1a2013-06-14 21:22:39 +02001659 if test "$fail_if_missing" = "yes" -a "$python3_ok" != "yes"; then
1660 AC_MSG_ERROR([could not configure python3])
1661 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001662fi
1663
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001664AC_SUBST(PYTHON3_LIBS)
1665AC_SUBST(PYTHON3_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00001666AC_SUBST(PYTHON3_CFLAGS_EXTRA)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001667AC_SUBST(PYTHON3_SRC)
1668AC_SUBST(PYTHON3_OBJ)
1669
1670dnl if python2.x and python3.x are enabled one can only link in code
1671dnl with dlopen(), dlsym(), dlclose()
1672if test "$python_ok" = yes && test "$python3_ok" = yes; then
1673 AC_DEFINE(DYNAMIC_PYTHON)
1674 AC_DEFINE(DYNAMIC_PYTHON3)
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001675 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001676 cflags_save=$CFLAGS
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001677 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001678 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001679 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001680 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001681 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001682 #include <dlfcn.h>
1683 /* If this program fails, then RTLD_GLOBAL is needed.
1684 * RTLD_GLOBAL will be used and then it is not possible to
1685 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001686 * Only the first python version used will be switched on.
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001687 */
1688
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001689 int no_rtl_global_needed_for(char *python_instsoname, char *prefix)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001690 {
1691 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001692 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001693 if (pylib != 0)
1694 {
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001695 void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome");
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001696 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1697 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1698 void (*final)(void) = dlsym(pylib, "Py_Finalize");
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001699 (*pfx)(prefix);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001700 (*init)();
1701 needed = (*simple)("import termios") == -1;
1702 (*final)();
1703 dlclose(pylib);
1704 }
1705 return !needed;
1706 }
1707
1708 int main(int argc, char** argv)
1709 {
1710 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001711 if (no_rtl_global_needed_for("${vi_cv_dll_name_python}", "${vi_cv_path_python_pfx}"))
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001712 not_needed = 1;
1713 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001714 }])],
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001715 [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001716
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001717 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001718 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001719
1720 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python3)
1721 cflags_save=$CFLAGS
1722 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001723 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001724 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001725 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001726 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001727 #include <dlfcn.h>
1728 #include <wchar.h>
1729 /* If this program fails, then RTLD_GLOBAL is needed.
1730 * RTLD_GLOBAL will be used and then it is not possible to
1731 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001732 * Only the first python version used will be switched on.
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001733 */
1734
1735 int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix)
1736 {
1737 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001738 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001739 if (pylib != 0)
1740 {
1741 void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome");
1742 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1743 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1744 void (*final)(void) = dlsym(pylib, "Py_Finalize");
1745 (*pfx)(prefix);
1746 (*init)();
1747 needed = (*simple)("import termios") == -1;
1748 (*final)();
1749 dlclose(pylib);
1750 }
1751 return !needed;
1752 }
1753
1754 int main(int argc, char** argv)
1755 {
1756 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001757 if (no_rtl_global_needed_for("${vi_cv_dll_name_python3}", L"${vi_cv_path_python3_pfx}"))
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001758 not_needed = 1;
1759 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001760 }])],
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001761 [AC_MSG_RESULT(yes);AC_DEFINE(PY3_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
1762
1763 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001764 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001765
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001766 PYTHON_SRC="if_python.c"
1767 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001768 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001769 PYTHON_LIBS=
1770 PYTHON3_SRC="if_python3.c"
1771 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001772 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001773 PYTHON3_LIBS=
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001774elif test "$python_ok" = yes && test "$enable_pythoninterp" = "dynamic"; then
1775 AC_DEFINE(DYNAMIC_PYTHON)
1776 PYTHON_SRC="if_python.c"
1777 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001778 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001779 PYTHON_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001780elif test "$python_ok" = yes; then
1781 dnl Check that adding -fPIE works. It may be needed when using a static
1782 dnl Python library.
1783 AC_MSG_CHECKING([if -fPIE can be added for Python])
1784 cflags_save=$CFLAGS
1785 libs_save=$LIBS
1786 CFLAGS="$CFLAGS $PYTHON_CFLAGS -fPIE"
1787 LIBS="$LIBS $PYTHON_LIBS"
1788 AC_TRY_LINK(,[ ],
1789 AC_MSG_RESULT(yes); fpie_ok=yes,
1790 AC_MSG_RESULT(no); fpie_ok=no)
1791 CFLAGS=$cflags_save
1792 LIBS=$libs_save
1793 if test $fpie_ok = yes; then
1794 PYTHON_CFLAGS="$PYTHON_CFLAGS -fPIE"
1795 fi
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001796elif test "$python3_ok" = yes && test "$enable_python3interp" = "dynamic"; then
1797 AC_DEFINE(DYNAMIC_PYTHON3)
1798 PYTHON3_SRC="if_python3.c"
1799 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001800 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001801 PYTHON3_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001802elif test "$python3_ok" = yes; then
1803 dnl Check that adding -fPIE works. It may be needed when using a static
1804 dnl Python library.
1805 AC_MSG_CHECKING([if -fPIE can be added for Python3])
1806 cflags_save=$CFLAGS
1807 libs_save=$LIBS
1808 CFLAGS="$CFLAGS $PYTHON3_CFLAGS -fPIE"
1809 LIBS="$LIBS $PYTHON3_LIBS"
1810 AC_TRY_LINK(,[ ],
1811 AC_MSG_RESULT(yes); fpie_ok=yes,
1812 AC_MSG_RESULT(no); fpie_ok=no)
1813 CFLAGS=$cflags_save
1814 LIBS=$libs_save
1815 if test $fpie_ok = yes; then
1816 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -fPIE"
1817 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001818fi
1819
Bram Moolenaar071d4272004-06-13 20:20:40 +00001820AC_MSG_CHECKING(--enable-tclinterp argument)
1821AC_ARG_ENABLE(tclinterp,
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001822 [ --enable-tclinterp[=OPTS] Include Tcl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001823 [enable_tclinterp="no"])
1824AC_MSG_RESULT($enable_tclinterp)
1825
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001826if test "$enable_tclinterp" = "yes" -o "$enable_tclinterp" = "dynamic"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001827
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001828 dnl on FreeBSD tclsh is a silly script, look for tclsh8.[5420]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001829 AC_MSG_CHECKING(--with-tclsh argument)
1830 AC_ARG_WITH(tclsh, [ --with-tclsh=PATH which tclsh to use (default: tclsh8.0)],
1831 tclsh_name="$withval"; AC_MSG_RESULT($tclsh_name),
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001832 tclsh_name="tclsh8.5"; AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00001833 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1834 AC_SUBST(vi_cv_path_tcl)
1835
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001836 dnl when no specific version specified, also try 8.4, 8.2 and 8.0
1837 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.5"; then
1838 tclsh_name="tclsh8.4"
1839 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1840 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001841 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.4"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001842 tclsh_name="tclsh8.2"
1843 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1844 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001845 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.2"; then
1846 tclsh_name="tclsh8.0"
1847 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1848 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001849 dnl still didn't find it, try without version number
1850 if test "X$vi_cv_path_tcl" = "X"; then
1851 tclsh_name="tclsh"
1852 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1853 fi
1854 if test "X$vi_cv_path_tcl" != "X"; then
1855 AC_MSG_CHECKING(Tcl version)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001856 if echo 'exit [[expr [info tclversion] < 8.0]]' | "$vi_cv_path_tcl" - ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001857 tclver=`echo 'puts [[info tclversion]]' | $vi_cv_path_tcl -`
1858 AC_MSG_RESULT($tclver - OK);
1859 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 +01001860 tcldll=`echo 'puts libtcl[[info tclversion]][[info sharedlibextension]]' | $vi_cv_path_tcl -`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001861
1862 AC_MSG_CHECKING(for location of Tcl include)
Bram Moolenaard0573012017-10-28 21:11:06 +02001863 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001864 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 +00001865 else
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001866 dnl For all macOS, use the value from TCL in case use of, say, homebrew
Bram Moolenaar071d4272004-06-13 20:20:40 +00001867 dnl For Mac OS X 10.3, use the OS-provided framework location
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001868 dnl For Mac OS X 10.14, the OS-provided framework location doesn't contain the headers, so also check the Xcode SDK
1869 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 +00001870 fi
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001871 TCL_INC=
Bram Moolenaar071d4272004-06-13 20:20:40 +00001872 for try in $tclinc; do
1873 if test -f "$try/tcl.h"; then
1874 AC_MSG_RESULT($try/tcl.h)
1875 TCL_INC=$try
1876 break
1877 fi
1878 done
1879 if test -z "$TCL_INC"; then
1880 AC_MSG_RESULT(<not found>)
1881 SKIP_TCL=YES
1882 fi
1883 if test -z "$SKIP_TCL"; then
1884 AC_MSG_CHECKING(for location of tclConfig.sh script)
Bram Moolenaard0573012017-10-28 21:11:06 +02001885 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001886 tclcnf=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001887 tclcnf="$tclcnf `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001888 else
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001889 dnl For all macOS, use the value from TCL in case use of, say, homebrew
Bram Moolenaar071d4272004-06-13 20:20:40 +00001890 dnl For Mac OS X 10.3, use the OS-provided framework location
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001891 dnl For Mac OS X 10.14, the OS-provided framework location doesn't contain the headers, so also check the Xcode SDK
1892 tclcnf=`echo $tclinc | sed s/include/lib/g`
1893 tclcnf="$tclcnf /System/Library/Frameworks/Tcl.framework `xcrun --show-sdk-path`/System/Library/Frameworks/Tcl.framework"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001894 fi
1895 for try in $tclcnf; do
Bram Moolenaar49222be2015-12-11 18:11:30 +01001896 if test -f "$try/tclConfig.sh"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001897 AC_MSG_RESULT($try/tclConfig.sh)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001898 . "$try/tclConfig.sh"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001899 dnl use eval, because tcl 8.2 includes ${TCL_DBGX}
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001900 if test "$enable_tclinterp" = "dynamic"; then
1901 TCL_LIBS=`eval echo "$TCL_STUB_LIB_SPEC $TCL_LIBS"`
1902 else
1903 TCL_LIBS=`eval echo "$TCL_LIB_SPEC $TCL_LIBS"`
1904 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001905 dnl Use $TCL_DEFS for -D_THREAD_SAFE et al. But only use the
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001906 dnl "-D_ABC" items. Watch out for -DFOO=long\ long.
Bram Moolenaar4394bff2008-07-24 11:21:31 +00001907 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 +00001908 break
1909 fi
1910 done
1911 if test -z "$TCL_LIBS"; then
1912 AC_MSG_RESULT(<not found>)
1913 AC_MSG_CHECKING(for Tcl library by myself)
1914 tcllib=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001915 tcllib="$tcllib `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001916 for ext in .so .a ; do
1917 for ver in "" $tclver ; do
1918 for try in $tcllib ; do
1919 trylib=tcl$ver$ext
Bram Moolenaar49222be2015-12-11 18:11:30 +01001920 if test -f "$try/lib$trylib" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001921 AC_MSG_RESULT($try/lib$trylib)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001922 TCL_LIBS="-L\"$try\" -ltcl$ver -ldl -lm"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001923 if test "$vim_cv_uname_output" = SunOS &&
1924 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001925 TCL_LIBS="$TCL_LIBS -R $try"
1926 fi
1927 break 3
1928 fi
1929 done
1930 done
1931 done
1932 if test -z "$TCL_LIBS"; then
1933 AC_MSG_RESULT(<not found>)
1934 SKIP_TCL=YES
1935 fi
1936 fi
1937 if test -z "$SKIP_TCL"; then
1938 AC_DEFINE(FEAT_TCL)
1939 TCL_SRC=if_tcl.c
1940 TCL_OBJ=objects/if_tcl.o
1941 TCL_PRO=if_tcl.pro
1942 TCL_CFLAGS="-I$TCL_INC $TCL_DEFS"
1943 fi
1944 fi
1945 else
1946 AC_MSG_RESULT(too old; need Tcl version 8.0 or later)
1947 fi
1948 fi
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001949 if test "$enable_tclinterp" = "dynamic"; then
1950 if test "X$TCL_SRC" != "X" -a "X$tcldll" != "X"; then
1951 AC_DEFINE(DYNAMIC_TCL)
1952 TCL_CFLAGS="-DDYNAMIC_TCL_DLL=\\\"$tcldll\\\" -DDYNAMIC_TCL_VER=\\\"$tclver\\\" $TCL_CFLAGS"
1953 fi
1954 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001955 if test "$fail_if_missing" = "yes" -a -z "$TCL_SRC"; then
1956 AC_MSG_ERROR([could not configure Tcl])
1957 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001958fi
1959AC_SUBST(TCL_SRC)
1960AC_SUBST(TCL_OBJ)
1961AC_SUBST(TCL_PRO)
1962AC_SUBST(TCL_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00001963AC_SUBST(TCL_CFLAGS_EXTRA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001964AC_SUBST(TCL_LIBS)
1965
1966AC_MSG_CHECKING(--enable-rubyinterp argument)
1967AC_ARG_ENABLE(rubyinterp,
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001968 [ --enable-rubyinterp[=OPTS] Include Ruby interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001969 [enable_rubyinterp="no"])
1970AC_MSG_RESULT($enable_rubyinterp)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001971if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001972 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1973 AC_MSG_ERROR([cannot use Ruby with tiny or small features])
1974 fi
1975
Bram Moolenaar165641d2010-02-17 16:23:09 +01001976 AC_MSG_CHECKING(--with-ruby-command argument)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001977 AC_SUBST(vi_cv_path_ruby)
Bram Moolenaar948733a2011-05-05 18:10:16 +02001978 AC_ARG_WITH(ruby-command, [ --with-ruby-command=RUBY name of the Ruby command (default: ruby)],
1979 RUBY_CMD="$withval"; vi_cv_path_ruby="$withval"; AC_MSG_RESULT($RUBY_CMD),
1980 RUBY_CMD="ruby"; AC_MSG_RESULT(defaulting to $RUBY_CMD))
Bram Moolenaar165641d2010-02-17 16:23:09 +01001981 AC_PATH_PROG(vi_cv_path_ruby, $RUBY_CMD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001982 if test "X$vi_cv_path_ruby" != "X"; then
1983 AC_MSG_CHECKING(Ruby version)
Bram Moolenaare4efc3b2005-03-07 23:16:51 +00001984 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 +00001985 AC_MSG_RESULT(OK)
Bram Moolenaar81398892012-10-03 21:09:35 +02001986 AC_MSG_CHECKING(Ruby rbconfig)
1987 ruby_rbconfig="RbConfig"
1988 if ! $vi_cv_path_ruby -r rbconfig -e 'RbConfig' >/dev/null 2>/dev/null; then
1989 ruby_rbconfig="Config"
1990 fi
1991 AC_MSG_RESULT($ruby_rbconfig)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001992 AC_MSG_CHECKING(Ruby header files)
Bram Moolenaar81398892012-10-03 21:09:35 +02001993 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 +00001994 if test "X$rubyhdrdir" != "X"; then
1995 AC_MSG_RESULT($rubyhdrdir)
1996 RUBY_CFLAGS="-I$rubyhdrdir"
Bram Moolenaara6fd37b2014-03-27 17:19:09 +01001997 rubyarchdir=`$vi_cv_path_ruby -r rbconfig -e "print ($ruby_rbconfig::CONFIG.has_key? 'rubyarchhdrdir') ? $ruby_rbconfig::CONFIG[['rubyarchhdrdir']] : '$rubyhdrdir/'+$ruby_rbconfig::CONFIG[['arch']]"`
1998 if test -d "$rubyarchdir"; then
1999 RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyarchdir"
Bram Moolenaar165641d2010-02-17 16:23:09 +01002000 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02002001 rubyversion=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['ruby_version']].gsub(/\./, '')[[0,2]]"`
Bram Moolenaar026a4452013-08-07 15:22:23 +02002002 if test "X$rubyversion" = "X"; then
2003 rubyversion=`$vi_cv_path_ruby -e "print ((VERSION rescue RUBY_VERSION)).gsub(/\./, '')[[0,2]]"`
2004 fi
Bram Moolenaar165641d2010-02-17 16:23:09 +01002005 RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
Bram Moolenaar81398892012-10-03 21:09:35 +02002006 rubylibs=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LIBS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002007 if test "X$rubylibs" != "X"; then
2008 RUBY_LIBS="$rubylibs"
2009 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02002010 librubyarg=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBYARG']])"`
2011 librubya=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBY_A']])"`
Bram Moolenaarac499e32013-06-02 19:14:17 +02002012 rubylibdir=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['libdir']])"`
Bram Moolenaard5a986f2020-12-06 21:11:31 +01002013 if test -f "$rubylibdir/$librubya" || expr "$librubyarg" : "-lruby"; then
Bram Moolenaarac499e32013-06-02 19:14:17 +02002014 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
2015 elif test "$librubyarg" = "libruby.a"; then
2016 dnl required on Mac OS 10.3 where libruby.a doesn't exist
2017 librubyarg="-lruby"
2018 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002019 fi
2020
2021 if test "X$librubyarg" != "X"; then
2022 RUBY_LIBS="$librubyarg $RUBY_LIBS"
2023 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02002024 rubyldflags=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LDFLAGS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002025 if test "X$rubyldflags" != "X"; then
Bram Moolenaar996b6d82009-07-22 09:17:23 +00002026 dnl Ruby on Mac OS X 10.5 adds "-arch" flags but these should only
2027 dnl be included if requested by passing --with-mac-arch to
2028 dnl configure, so strip these flags first (if present)
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02002029 rubyldflags=`echo "$rubyldflags" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
Bram Moolenaar996b6d82009-07-22 09:17:23 +00002030 if test "X$rubyldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01002031 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$rubyldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02002032 LDFLAGS="$rubyldflags $LDFLAGS"
2033 fi
Bram Moolenaar996b6d82009-07-22 09:17:23 +00002034 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002035 fi
2036 RUBY_SRC="if_ruby.c"
2037 RUBY_OBJ="objects/if_ruby.o"
2038 RUBY_PRO="if_ruby.pro"
2039 AC_DEFINE(FEAT_RUBY)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002040 if test "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar92021622017-10-12 12:33:43 +02002041 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_ALIASES']].split[[0]]"`
Bram Moolenaar87ea64c2018-08-04 15:13:34 +02002042 if test -z "$libruby_soname"; then
2043 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_SO']]"`
2044 fi
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002045 AC_DEFINE(DYNAMIC_RUBY)
Bram Moolenaar41a41412020-01-07 21:32:19 +01002046 RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby_soname\\\" $RUBY_CFLAGS"
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002047 RUBY_LIBS=
2048 fi
Bram Moolenaar864a28b2020-12-28 21:36:56 +01002049 if test "X$CLANG_VERSION" != "X" -a "$rubyversion" -ge 30; then
2050 RUBY_CFLAGS="$RUBY_CFLAGS -fdeclspec"
2051 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002052 else
Bram Moolenaar165641d2010-02-17 16:23:09 +01002053 AC_MSG_RESULT(not found; disabling Ruby)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002054 fi
2055 else
2056 AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
2057 fi
2058 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01002059
2060 if test "$fail_if_missing" = "yes" -a -z "$RUBY_OBJ"; then
2061 AC_MSG_ERROR([could not configure Ruby])
2062 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002063fi
2064AC_SUBST(RUBY_SRC)
2065AC_SUBST(RUBY_OBJ)
2066AC_SUBST(RUBY_PRO)
2067AC_SUBST(RUBY_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00002068AC_SUBST(RUBY_CFLAGS_EXTRA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002069AC_SUBST(RUBY_LIBS)
2070
2071AC_MSG_CHECKING(--enable-cscope argument)
2072AC_ARG_ENABLE(cscope,
2073 [ --enable-cscope Include cscope interface.], ,
2074 [enable_cscope="no"])
2075AC_MSG_RESULT($enable_cscope)
2076if test "$enable_cscope" = "yes"; then
2077 AC_DEFINE(FEAT_CSCOPE)
2078fi
2079
Bram Moolenaar071d4272004-06-13 20:20:40 +00002080AC_MSG_CHECKING(--disable-netbeans argument)
2081AC_ARG_ENABLE(netbeans,
2082 [ --disable-netbeans Disable NetBeans integration support.],
2083 , [enable_netbeans="yes"])
2084if test "$enable_netbeans" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002085 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2086 AC_MSG_RESULT([cannot use NetBeans with tiny or small features])
2087 enable_netbeans="no"
2088 else
2089 AC_MSG_RESULT(no)
2090 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002091else
2092 AC_MSG_RESULT(yes)
2093fi
2094
2095AC_MSG_CHECKING(--disable-channel argument)
2096AC_ARG_ENABLE(channel,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002097 [ --disable-channel Disable process communication support.],
Bram Moolenaare0874f82016-01-24 20:36:41 +01002098 , [enable_channel="yes"])
2099if test "$enable_channel" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002100 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2101 AC_MSG_RESULT([cannot use channels with tiny or small features])
2102 enable_channel="no"
2103 else
2104 AC_MSG_RESULT(no)
2105 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002106else
2107 if test "$enable_netbeans" = "yes"; then
Bram Moolenaar16435482016-01-24 21:31:54 +01002108 AC_MSG_RESULT([yes, netbeans also disabled])
Bram Moolenaare0874f82016-01-24 20:36:41 +01002109 enable_netbeans="no"
2110 else
2111 AC_MSG_RESULT(yes)
2112 fi
2113fi
2114
Bram Moolenaar16435482016-01-24 21:31:54 +01002115if test "$enable_channel" = "yes"; then
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002116 dnl On Solaris we need the socket library, or on Haiku the network library.
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002117 if test "x$HAIKU" = "xyes"; then
2118 AC_CHECK_LIB(network, socket)
2119 else
2120 AC_CHECK_LIB(socket, socket)
2121 fi
2122
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002123 AC_CACHE_CHECK([whether compiling with IPv6 networking is possible], [vim_cv_ipv6_networking],
2124 [AC_TRY_LINK([
2125#include <stdio.h>
2126#include <stdlib.h>
2127#include <stdarg.h>
2128#include <fcntl.h>
2129#include <netdb.h>
2130#include <netinet/in.h>
2131#include <errno.h>
2132#include <sys/types.h>
2133#include <sys/socket.h>
2134 /* Check bitfields */
2135 struct nbbuf {
2136 unsigned int initDone:1;
2137 unsigned short signmaplen;
2138 };
2139 ], [
2140 /* Check creating a socket. */
2141 struct sockaddr_in server;
2142 struct addrinfo *res;
2143 (void)socket(AF_INET, SOCK_STREAM, 0);
2144 (void)htons(100);
2145 (void)getaddrinfo("microsoft.com", NULL, NULL, &res);
2146 if (errno == ECONNREFUSED)
2147 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
2148 (void)freeaddrinfo(res);
2149 ],
2150 [vim_cv_ipv6_networking="yes"],
2151 [vim_cv_ipv6_networking="no"])])
2152
2153 if test "x$vim_cv_ipv6_networking" = "xyes"; then
2154 AC_DEFINE(FEAT_IPV6)
Bram Moolenaarb6fb0512020-04-18 18:24:18 +02002155 AC_CHECK_FUNCS(inet_ntop)
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002156 else
2157 dnl On Solaris we need the nsl library.
2158 AC_CHECK_LIB(nsl, gethostbyname)
2159 AC_CACHE_CHECK([whether compiling with IPv4 networking is possible], [vim_cv_ipv4_networking],
2160 [AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00002161#include <stdio.h>
2162#include <stdlib.h>
2163#include <stdarg.h>
2164#include <fcntl.h>
2165#include <netdb.h>
2166#include <netinet/in.h>
2167#include <errno.h>
2168#include <sys/types.h>
2169#include <sys/socket.h>
2170 /* Check bitfields */
2171 struct nbbuf {
2172 unsigned int initDone:1;
Bram Moolenaar63de19e2016-12-09 20:11:26 +01002173 unsigned short signmaplen;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002174 };
2175 ], [
2176 /* Check creating a socket. */
2177 struct sockaddr_in server;
2178 (void)socket(AF_INET, SOCK_STREAM, 0);
2179 (void)htons(100);
2180 (void)gethostbyname("microsoft.com");
2181 if (errno == ECONNREFUSED)
2182 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
2183 ],
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002184 [vim_cv_ipv4_networking="yes"],
2185 [vim_cv_ipv4_networking="no"; enable_netbeans="no"; enable_channel="no"])])
2186 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002187fi
2188if test "$enable_netbeans" = "yes"; then
2189 AC_DEFINE(FEAT_NETBEANS_INTG)
2190 NETBEANS_SRC="netbeans.c"
2191 AC_SUBST(NETBEANS_SRC)
2192 NETBEANS_OBJ="objects/netbeans.o"
2193 AC_SUBST(NETBEANS_OBJ)
2194fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002195if test "$enable_channel" = "yes"; then
Bram Moolenaar509ce2a2016-03-11 22:52:15 +01002196 AC_DEFINE(FEAT_JOB_CHANNEL)
Bram Moolenaar8b5866d2020-09-05 15:48:51 +02002197 CHANNEL_SRC="job.c channel.c"
Bram Moolenaare0874f82016-01-24 20:36:41 +01002198 AC_SUBST(CHANNEL_SRC)
Bram Moolenaar8b5866d2020-09-05 15:48:51 +02002199 CHANNEL_OBJ="objects/job.o objects/channel.o"
Bram Moolenaare0874f82016-01-24 20:36:41 +01002200 AC_SUBST(CHANNEL_OBJ)
2201fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002202
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002203AC_MSG_CHECKING(--enable-terminal argument)
2204AC_ARG_ENABLE(terminal,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002205 [ --enable-terminal Enable terminal emulation support.],
Bram Moolenaaref839562017-10-28 20:28:23 +02002206 , [enable_terminal="auto"])
Bram Moolenaar595a4022017-09-03 19:15:57 +02002207if test "$enable_terminal" = "yes" || test "$enable_terminal" = "auto" -a "x$features" = "xhuge" ; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002208 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2209 AC_MSG_RESULT([cannot use terminal emulator with tiny or small features])
2210 enable_terminal="no"
2211 else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002212 if test "$enable_terminal" = "auto"; then
2213 enable_terminal="yes"
2214 AC_MSG_RESULT(defaulting to yes)
2215 else
2216 AC_MSG_RESULT(yes)
2217 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002218 fi
2219else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002220 if test "$enable_terminal" = "auto"; then
2221 enable_terminal="no"
2222 AC_MSG_RESULT(defaulting to no)
2223 else
2224 AC_MSG_RESULT(no)
2225 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002226fi
Bram Moolenaar8b423282017-12-16 14:37:06 +01002227if test "$enable_terminal" = "yes" -a "$enable_channel" = "yes"; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002228 AC_DEFINE(FEAT_TERMINAL)
Bram Moolenaar93268052019-10-10 13:22:54 +02002229 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 +02002230 AC_SUBST(TERM_SRC)
Bram Moolenaar93268052019-10-10 13:22:54 +02002231 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 +02002232 AC_SUBST(TERM_OBJ)
Bram Moolenaar823edd12019-10-23 22:35:36 +02002233 TERM_TEST="test_libvterm"
2234 AC_SUBST(TERM_TEST)
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002235fi
2236
Bram Moolenaare42a6d22017-11-12 19:21:51 +01002237AC_MSG_CHECKING(--enable-autoservername argument)
2238AC_ARG_ENABLE(autoservername,
2239 [ --enable-autoservername Automatically define servername at vim startup.], ,
2240 [enable_autoservername="no"])
2241AC_MSG_RESULT($enable_autoservername)
2242if test "$enable_autoservername" = "yes"; then
2243 AC_DEFINE(FEAT_AUTOSERVERNAME)
2244fi
2245
Bram Moolenaar071d4272004-06-13 20:20:40 +00002246AC_MSG_CHECKING(--enable-multibyte argument)
2247AC_ARG_ENABLE(multibyte,
2248 [ --enable-multibyte Include multibyte editing support.], ,
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01002249 [enable_multibyte="yes"])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002250AC_MSG_RESULT($enable_multibyte)
Bram Moolenaar30276f22019-01-24 17:59:39 +01002251if test "$enable_multibyte" != "yes"; then
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01002252 AC_MSG_ERROR([The multi-byte feature can no longer be disabled. If you have
2253 a problem with this, discuss on the Vim mailing list.])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002254fi
2255
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002256dnl Right-to-Left language support for Vim will be included with big features,
2257dnl unless ENABLE_RIGHTLEFT is undefined.
2258AC_MSG_CHECKING(--disable-rightleft argument)
2259AC_ARG_ENABLE(rightleft,
2260 [ --disable-rightleft Do not include Right-to-Left language support.],
2261 , [enable_rightleft="yes"])
2262if test "$enable_rightleft" = "yes"; then
2263 AC_MSG_RESULT(no)
2264else
2265 AC_MSG_RESULT(yes)
2266 AC_DEFINE(DISABLE_RIGHTLEFT)
2267fi
2268
2269dnl Arabic language support for Vim will be included with big features,
2270dnl unless ENABLE_ARABIC is undefined.
2271AC_MSG_CHECKING(--disable-arabic argument)
2272AC_ARG_ENABLE(arabic,
2273 [ --disable-arabic Do not include Arabic language support.],
2274 , [enable_arabic="yes"])
2275if test "$enable_arabic" = "yes"; then
2276 AC_MSG_RESULT(no)
2277else
2278 AC_MSG_RESULT(yes)
2279 AC_DEFINE(DISABLE_ARABIC)
2280fi
2281
Bram Moolenaar14184a32019-02-16 15:10:30 +01002282dnl Farsi language support has been removed, ignore --disable-farsi
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002283AC_ARG_ENABLE(farsi,
Bram Moolenaar14184a32019-02-16 15:10:30 +01002284 [ --disable-farsi Deprecated.],,)
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002285
Bram Moolenaar071d4272004-06-13 20:20:40 +00002286AC_MSG_CHECKING(--enable-xim argument)
2287AC_ARG_ENABLE(xim,
2288 [ --enable-xim Include XIM input support.],
2289 AC_MSG_RESULT($enable_xim),
2290 [enable_xim="auto"; AC_MSG_RESULT(defaulting to auto)])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002291
2292AC_MSG_CHECKING(--enable-fontset argument)
2293AC_ARG_ENABLE(fontset,
2294 [ --enable-fontset Include X fontset output support.], ,
2295 [enable_fontset="no"])
2296AC_MSG_RESULT($enable_fontset)
2297dnl defining FEAT_XFONTSET is delayed, so that it can be disabled for no GUI
2298
2299test -z "$with_x" && with_x=yes
Bram Moolenaard0573012017-10-28 21:11:06 +02002300test "${enable_gui-yes}" != no -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && with_x=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002301if test "$with_x" = no; then
2302 AC_MSG_RESULT(defaulting to: don't HAVE_X11)
2303else
2304 dnl Do this check early, so that its failure can override user requests.
2305
2306 AC_PATH_PROG(xmkmfpath, xmkmf)
2307
2308 AC_PATH_XTRA
2309
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002310 dnl On z/OS Unix the X libraries are DLLs. To use them the code must
Bram Moolenaar071d4272004-06-13 20:20:40 +00002311 dnl be compiled with a special option.
2312 dnl Also add SM, ICE and Xmu to X_EXTRA_LIBS.
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002313 if test "$zOSUnix" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002314 CFLAGS="$CFLAGS -W c,dll"
2315 LDFLAGS="$LDFLAGS -W l,dll"
2316 X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE -lXmu"
2317 fi
2318
2319 dnl On my HPUX system the X include dir is found, but the lib dir not.
Bram Moolenaar70778922020-02-05 20:44:24 +01002320 dnl This is a desperate try to fix this.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002321
2322 if test -d "$x_includes" && test ! -d "$x_libraries"; then
2323 x_libraries=`echo "$x_includes" | sed s/include/lib/`
2324 AC_MSG_RESULT(Corrected X libraries to $x_libraries)
2325 X_LIBS="$X_LIBS -L$x_libraries"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00002326 if test "$vim_cv_uname_output" = SunOS &&
2327 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002328 X_LIBS="$X_LIBS -R $x_libraries"
2329 fi
2330 fi
2331
2332 if test -d "$x_libraries" && test ! -d "$x_includes"; then
2333 x_includes=`echo "$x_libraries" | sed s/lib/include/`
2334 AC_MSG_RESULT(Corrected X includes to $x_includes)
2335 X_CFLAGS="$X_CFLAGS -I$x_includes"
2336 fi
2337
2338 dnl Remove "-I/usr/include " from X_CFLAGS, should not be needed.
2339 X_CFLAGS="`echo $X_CFLAGS\ | sed 's%-I/usr/include %%'`"
2340 dnl Remove "-L/usr/lib " from X_LIBS, should not be needed.
2341 X_LIBS="`echo $X_LIBS\ | sed 's%-L/usr/lib %%'`"
2342 dnl Same for "-R/usr/lib ".
2343 X_LIBS="`echo $X_LIBS\ | sed -e 's%-R/usr/lib %%' -e 's%-R /usr/lib %%'`"
2344
2345
2346 dnl Check if the X11 header files are correctly installed. On some systems
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002347 dnl Xlib.h includes files that don't exist. On some systems X11/Intrinsic.h
2348 dnl is missing.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002349 AC_MSG_CHECKING(if X11 header files can be found)
2350 cflags_save=$CFLAGS
2351 CFLAGS="$CFLAGS $X_CFLAGS"
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002352 AC_TRY_COMPILE([#include <X11/Xlib.h>
2353#include <X11/Intrinsic.h>], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002354 AC_MSG_RESULT(yes),
2355 AC_MSG_RESULT(no); no_x=yes)
2356 CFLAGS=$cflags_save
2357
2358 if test "${no_x-no}" = yes; then
2359 with_x=no
2360 else
2361 AC_DEFINE(HAVE_X11)
2362 X_LIB="-lXt -lX11";
2363 AC_SUBST(X_LIB)
2364
2365 ac_save_LDFLAGS="$LDFLAGS"
2366 LDFLAGS="-L$x_libraries $LDFLAGS"
2367
2368 dnl Check for -lXdmcp (needed on SunOS 4.1.4)
2369 dnl For HP-UX 10.20 it must be before -lSM -lICE
2370 AC_CHECK_LIB(Xdmcp, _XdmcpAuthDoIt, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lXdmcp"],,
2371 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXdmcp])
2372
2373 dnl Some systems need -lnsl -lsocket when testing for ICE.
2374 dnl The check above doesn't do this, try here (again). Also needed to get
2375 dnl them after Xdmcp. link.sh will remove them when not needed.
2376 dnl Check for other function than above to avoid the cached value
2377 AC_CHECK_LIB(ICE, IceOpenConnection,
2378 [X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE"],, [$X_EXTRA_LIBS])
2379
2380 dnl Check for -lXpm (needed for some versions of Motif)
2381 LDFLAGS="$X_LIBS $ac_save_LDFLAGS"
2382 AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [X_PRE_LIBS="$X_PRE_LIBS -lXpm"],,
2383 [-lXt $X_PRE_LIBS -lXpm -lX11 $X_EXTRA_LIBS])
2384
2385 dnl Check that the X11 header files don't use implicit declarations
2386 AC_MSG_CHECKING(if X11 header files implicitly declare return values)
2387 cflags_save=$CFLAGS
Bram Moolenaard1864592013-05-04 04:40:15 +02002388 dnl -Werror is GCC only, others like Solaris Studio might not like it
2389 if test "$GCC" = yes; then
2390 CFLAGS="$CFLAGS $X_CFLAGS -Werror"
2391 else
2392 CFLAGS="$CFLAGS $X_CFLAGS"
2393 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002394 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2395 AC_MSG_RESULT(no),
2396 CFLAGS="$CFLAGS -Wno-implicit-int"
2397 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2398 AC_MSG_RESULT(yes); cflags_save="$cflags_save -Wno-implicit-int",
2399 AC_MSG_RESULT(test failed)
2400 )
2401 )
2402 CFLAGS=$cflags_save
2403
2404 LDFLAGS="$ac_save_LDFLAGS"
2405
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002406 AC_MSG_CHECKING(size of wchar_t is 2 bytes)
2407 AC_CACHE_VAL(ac_cv_small_wchar_t,
2408 [AC_TRY_RUN([
2409#include <X11/Xlib.h>
2410#if STDC_HEADERS
2411# include <stdlib.h>
2412# include <stddef.h>
2413#endif
2414 main()
2415 {
2416 if (sizeof(wchar_t) <= 2)
2417 exit(1);
2418 exit(0);
2419 }],
2420 ac_cv_small_wchar_t="no",
2421 ac_cv_small_wchar_t="yes",
2422 AC_MSG_ERROR(failed to compile test program))])
2423 AC_MSG_RESULT($ac_cv_small_wchar_t)
2424 if test "x$ac_cv_small_wchar_t" = "xyes" ; then
2425 AC_DEFINE(SMALL_WCHAR_T)
2426 fi
2427
Bram Moolenaar071d4272004-06-13 20:20:40 +00002428 fi
2429fi
2430
Bram Moolenaard2a05492018-07-27 22:35:15 +02002431dnl Check if --with-x was given but it doesn't work.
2432if test "x$with_x" = xno -a "x$with_x_arg" = xyes; then
2433 AC_MSG_ERROR([could not configure X])
2434fi
2435
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002436test "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 +00002437
2438AC_MSG_CHECKING(--enable-gui argument)
2439AC_ARG_ENABLE(gui,
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002440 [ --enable-gui[=OPTS] X11 GUI. [default=auto] [OPTS=auto/no/gtk2/gnome2/gtk3/motif/athena/neXtaw/haiku/photon/carbon]], , enable_gui="auto")
Bram Moolenaar071d4272004-06-13 20:20:40 +00002441
2442dnl Canonicalize the --enable-gui= argument so that it can be easily compared.
2443dnl Do not use character classes for portability with old tools.
2444enable_gui_canon=`echo "_$enable_gui" | \
2445 sed 's/[[ _+-]]//g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
2446
2447dnl Skip everything by default.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002448SKIP_GTK2=YES
Bram Moolenaar1858a842016-02-23 22:30:31 +01002449SKIP_GTK3=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002450SKIP_GNOME=YES
2451SKIP_MOTIF=YES
2452SKIP_ATHENA=YES
2453SKIP_NEXTAW=YES
2454SKIP_PHOTON=YES
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002455SKIP_HAIKU=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002456GUITYPE=NONE
2457
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002458if test "x$HAIKU" = "xyes"; then
2459 SKIP_HAIKU=
2460 case "$enable_gui_canon" in
2461 no) AC_MSG_RESULT(no GUI support)
2462 SKIP_HAIKU=YES ;;
2463 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
2464 auto) AC_MSG_RESULT(auto - automatic GUI support) ;;
2465 haiku) AC_MSG_RESULT(Haiku GUI support) ;;
2466 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2467 SKIP_HAIKU=YES ;;
2468 esac
2469elif test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002470 SKIP_PHOTON=
2471 case "$enable_gui_canon" in
2472 no) AC_MSG_RESULT(no GUI support)
2473 SKIP_PHOTON=YES ;;
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002474 yes|""|auto) AC_MSG_RESULT(automatic GUI support)
2475 gui_auto=yes ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002476 photon) AC_MSG_RESULT(Photon GUI support) ;;
2477 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2478 SKIP_PHOTON=YES ;;
2479 esac
2480
Bram Moolenaar040f9752020-08-11 23:08:48 +02002481elif test "x$MACOS_X" = "xyes" -a "x$with_x" = "xno" ; then
2482 case "$enable_gui_canon" in
2483 no) AC_MSG_RESULT(no GUI support) ;;
2484 yes|"") AC_MSG_RESULT(yes - automatic GUI support)
2485 gui_auto=yes ;;
2486 auto) AC_MSG_RESULT(auto - disable GUI support for Mac OS) ;;
Bram Moolenaarbe7529e2020-08-13 21:05:39 +02002487 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
Bram Moolenaar040f9752020-08-11 23:08:48 +02002488 esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00002489else
2490
Bram Moolenaar071d4272004-06-13 20:20:40 +00002491 case "$enable_gui_canon" in
2492 no|none) AC_MSG_RESULT(no GUI support) ;;
2493 yes|""|auto) AC_MSG_RESULT(yes/auto - automatic GUI support)
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002494 gui_auto=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002495 SKIP_GTK2=
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002496 SKIP_GTK3=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002497 SKIP_GNOME=
2498 SKIP_MOTIF=
2499 SKIP_ATHENA=
Bram Moolenaar097148e2020-08-11 21:58:20 +02002500 SKIP_NEXTAW=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002501 gtk2) AC_MSG_RESULT(GTK+ 2.x GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002502 SKIP_GTK2=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002503 gnome2) AC_MSG_RESULT(GNOME 2.x GUI support)
2504 SKIP_GNOME=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002505 SKIP_GTK2=;;
Bram Moolenaar98921892016-02-23 17:14:37 +01002506 gtk3) AC_MSG_RESULT(GTK+ 3.x GUI support)
2507 SKIP_GTK3=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002508 motif) AC_MSG_RESULT(Motif GUI support)
2509 SKIP_MOTIF=;;
2510 athena) AC_MSG_RESULT(Athena GUI support)
2511 SKIP_ATHENA=;;
2512 nextaw) AC_MSG_RESULT(neXtaw GUI support)
2513 SKIP_NEXTAW=;;
2514 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
2515 esac
2516
2517fi
2518
Bram Moolenaar071d4272004-06-13 20:20:40 +00002519if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \
2520 -a "$enable_gui_canon" != "gnome2"; then
2521 AC_MSG_CHECKING(whether or not to look for GTK+ 2)
2522 AC_ARG_ENABLE(gtk2-check,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002523 [ --enable-gtk2-check If auto-select GUI, check for GTK+ 2 [default=yes]],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002524 , enable_gtk2_check="yes")
2525 AC_MSG_RESULT($enable_gtk2_check)
2526 if test "x$enable_gtk2_check" = "xno"; then
2527 SKIP_GTK2=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002528 SKIP_GNOME=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002529 fi
2530fi
2531
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002532if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002533 AC_MSG_CHECKING(whether or not to look for GNOME)
2534 AC_ARG_ENABLE(gnome-check,
2535 [ --enable-gnome-check If GTK GUI, check for GNOME [default=no]],
2536 , enable_gnome_check="no")
2537 AC_MSG_RESULT($enable_gnome_check)
2538 if test "x$enable_gnome_check" = "xno"; then
2539 SKIP_GNOME=YES
2540 fi
2541fi
2542
Bram Moolenaar98921892016-02-23 17:14:37 +01002543if test "x$SKIP_GTK3" != "xYES" -a "$enable_gui_canon" != "gtk3"; then
2544 AC_MSG_CHECKING(whether or not to look for GTK+ 3)
2545 AC_ARG_ENABLE(gtk3-check,
2546 [ --enable-gtk3-check If auto-select GUI, check for GTK+ 3 [default=yes]],
2547 , enable_gtk3_check="yes")
2548 AC_MSG_RESULT($enable_gtk3_check)
2549 if test "x$enable_gtk3_check" = "xno"; then
2550 SKIP_GTK3=YES
2551 fi
2552fi
2553
Bram Moolenaar071d4272004-06-13 20:20:40 +00002554if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then
2555 AC_MSG_CHECKING(whether or not to look for Motif)
2556 AC_ARG_ENABLE(motif-check,
2557 [ --enable-motif-check If auto-select GUI, check for Motif [default=yes]],
2558 , enable_motif_check="yes")
2559 AC_MSG_RESULT($enable_motif_check)
2560 if test "x$enable_motif_check" = "xno"; then
2561 SKIP_MOTIF=YES
2562 fi
2563fi
2564
2565if test "x$SKIP_ATHENA" != "xYES" -a "$enable_gui_canon" != "athena"; then
2566 AC_MSG_CHECKING(whether or not to look for Athena)
2567 AC_ARG_ENABLE(athena-check,
2568 [ --enable-athena-check If auto-select GUI, check for Athena [default=yes]],
2569 , enable_athena_check="yes")
2570 AC_MSG_RESULT($enable_athena_check)
2571 if test "x$enable_athena_check" = "xno"; then
2572 SKIP_ATHENA=YES
2573 fi
2574fi
2575
2576if test "x$SKIP_NEXTAW" != "xYES" -a "$enable_gui_canon" != "nextaw"; then
2577 AC_MSG_CHECKING(whether or not to look for neXtaw)
2578 AC_ARG_ENABLE(nextaw-check,
2579 [ --enable-nextaw-check If auto-select GUI, check for neXtaw [default=yes]],
2580 , enable_nextaw_check="yes")
2581 AC_MSG_RESULT($enable_nextaw_check);
2582 if test "x$enable_nextaw_check" = "xno"; then
2583 SKIP_NEXTAW=YES
2584 fi
2585fi
2586
Bram Moolenaar071d4272004-06-13 20:20:40 +00002587dnl define an autoconf function to check for a specified version of GTK, and
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002588dnl try to compile/link a GTK program.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002589dnl
2590dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002591dnl Test for GTK, and define GTK_CFLAGS, GTK_LIBDIR and GTK_LIBS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002592dnl
2593AC_DEFUN(AM_PATH_GTK,
2594[
2595 if test "X$GTK_CONFIG" != "Xno" -o "X$PKG_CONFIG" != "Xno"; then
2596 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00002597 no_gtk=""
2598 if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2599 && $PKG_CONFIG --exists gtk+-2.0; then
2600 {
Bram Moolenaar98921892016-02-23 17:14:37 +01002601 min_gtk_version=ifelse([$1], ,2.2.0,$1)
2602 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002603 dnl We should be using PKG_CHECK_MODULES() instead of this hack.
2604 dnl But I guess the dependency on pkgconfig.m4 is not wanted or
2605 dnl something like that.
2606 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0`
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002607 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-2.0`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002608 GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0`
2609 gtk_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2610 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2611 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2612 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2613 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2614 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2615 }
Bram Moolenaar98921892016-02-23 17:14:37 +01002616 elif (test "X$SKIP_GTK3" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2617 && $PKG_CONFIG --exists gtk+-3.0; then
2618 {
2619 min_gtk_version=ifelse([$1], ,3.0.0,$1)
2620 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
2621
2622 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-3.0`
2623 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-3.0`
2624 GTK_LIBS=`$PKG_CONFIG --libs gtk+-3.0`
2625 gtk_major_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2626 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2627 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2628 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2629 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2630 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2631 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002632 else
Bram Moolenaar67876de2021-01-12 20:51:24 +01002633 dnl Put some text before the "no" to hint at installing the gtk-dev
2634 dnl packages.
2635 AC_MSG_CHECKING(for GTK -dev package)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002636 no_gtk=yes
2637 fi
2638
2639 if test "x$enable_gtktest" = "xyes" -a "x$no_gtk" = "x"; then
2640 {
2641 ac_save_CFLAGS="$CFLAGS"
2642 ac_save_LIBS="$LIBS"
2643 CFLAGS="$CFLAGS $GTK_CFLAGS"
2644 LIBS="$LIBS $GTK_LIBS"
2645
2646 dnl
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002647 dnl Now check if the installed GTK is sufficiently new.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002648 dnl
2649 rm -f conf.gtktest
2650 AC_TRY_RUN([
2651#include <gtk/gtk.h>
2652#include <stdio.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00002653#if STDC_HEADERS
2654# include <stdlib.h>
2655# include <stddef.h>
2656#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002657
2658int
2659main ()
2660{
2661int major, minor, micro;
2662char *tmp_version;
2663
2664system ("touch conf.gtktest");
2665
2666/* HP/UX 9 (%@#!) writes to sscanf strings */
2667tmp_version = g_strdup("$min_gtk_version");
2668if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
2669 printf("%s, bad version string\n", "$min_gtk_version");
2670 exit(1);
2671 }
2672
2673if ((gtk_major_version > major) ||
2674 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
2675 ((gtk_major_version == major) && (gtk_minor_version == minor) &&
2676 (gtk_micro_version >= micro)))
2677{
2678 return 0;
2679}
2680return 1;
2681}
2682],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
2683 CFLAGS="$ac_save_CFLAGS"
2684 LIBS="$ac_save_LIBS"
2685 }
2686 fi
2687 if test "x$no_gtk" = x ; then
2688 if test "x$enable_gtktest" = "xyes"; then
2689 AC_MSG_RESULT(yes; found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2690 else
2691 AC_MSG_RESULT(found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2692 fi
2693 ifelse([$2], , :, [$2])
2694 else
2695 {
2696 AC_MSG_RESULT(no)
2697 GTK_CFLAGS=""
2698 GTK_LIBS=""
2699 ifelse([$3], , :, [$3])
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002700 if test "$fail_if_missing" = "yes" -a "X$gui_auto" != "Xyes"; then
2701 AC_MSG_ERROR([could not configure GTK])
2702 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002703 }
2704 fi
2705 }
2706 else
2707 GTK_CFLAGS=""
2708 GTK_LIBS=""
2709 ifelse([$3], , :, [$3])
2710 fi
2711 AC_SUBST(GTK_CFLAGS)
2712 AC_SUBST(GTK_LIBS)
2713 rm -f conf.gtktest
2714])
2715
2716dnl ---------------------------------------------------------------------------
2717dnl gnome
2718dnl ---------------------------------------------------------------------------
2719AC_DEFUN([GNOME_INIT_HOOK],
2720[
2721 AC_SUBST(GNOME_LIBS)
2722 AC_SUBST(GNOME_LIBDIR)
2723 AC_SUBST(GNOME_INCLUDEDIR)
2724
2725 AC_ARG_WITH(gnome-includes,
2726 [ --with-gnome-includes=DIR Specify location of GNOME headers],
2727 [CFLAGS="$CFLAGS -I$withval"]
2728 )
2729
2730 AC_ARG_WITH(gnome-libs,
2731 [ --with-gnome-libs=DIR Specify location of GNOME libs],
2732 [LDFLAGS="$LDFLAGS -L$withval" gnome_prefix=$withval]
2733 )
2734
2735 AC_ARG_WITH(gnome,
2736 [ --with-gnome Specify prefix for GNOME files],
2737 if test x$withval = xyes; then
2738 want_gnome=yes
2739 ifelse([$1], [], :, [$1])
2740 else
2741 if test "x$withval" = xno; then
2742 want_gnome=no
2743 else
2744 want_gnome=yes
2745 LDFLAGS="$LDFLAGS -L$withval/lib"
2746 CFLAGS="$CFLAGS -I$withval/include"
2747 gnome_prefix=$withval/lib
2748 fi
2749 fi,
2750 want_gnome=yes)
2751
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002752 if test "x$want_gnome" = xyes; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002753 {
2754 AC_MSG_CHECKING(for libgnomeui-2.0)
2755 if $PKG_CONFIG --exists libgnomeui-2.0; then
2756 AC_MSG_RESULT(yes)
2757 GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0`
2758 GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0`
2759 GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0`
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002760
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002761 dnl On FreeBSD we need -pthread but pkg-config doesn't include it.
2762 dnl This might not be the right way but it works for me...
2763 AC_MSG_CHECKING(for FreeBSD)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00002764 if test "$vim_cv_uname_output" = FreeBSD; then
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002765 AC_MSG_RESULT(yes, adding -pthread)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002766 GNOME_INCLUDEDIR="$GNOME_INCLUDEDIR -D_THREAD_SAFE"
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002767 GNOME_LIBS="$GNOME_LIBS -pthread"
2768 else
2769 AC_MSG_RESULT(no)
2770 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002771 $1
2772 else
2773 AC_MSG_RESULT(not found)
2774 if test "x$2" = xfail; then
2775 AC_MSG_ERROR(Could not find libgnomeui-2.0 via pkg-config)
2776 fi
2777 fi
2778 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002779 fi
2780])
2781
2782AC_DEFUN([GNOME_INIT],[
2783 GNOME_INIT_HOOK([],fail)
2784])
2785
Bram Moolenaar427f5b62019-06-09 13:43:51 +02002786if test "X$PKG_CONFIG" = "X"; then
2787 AC_PATH_TOOL(PKG_CONFIG, pkg-config, no)
2788fi
2789
Bram Moolenaar071d4272004-06-13 20:20:40 +00002790
2791dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002792dnl Check for GTK2. If it fails, then continue on for Motif as before...
Bram Moolenaar071d4272004-06-13 20:20:40 +00002793dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002794if test -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002795
2796 AC_MSG_CHECKING(--disable-gtktest argument)
2797 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2798 , enable_gtktest=yes)
2799 if test "x$enable_gtktest" = "xyes" ; then
2800 AC_MSG_RESULT(gtk test enabled)
2801 else
2802 AC_MSG_RESULT(gtk test disabled)
2803 fi
2804
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002805 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002806 dnl First try finding version 2.2.0 or later. The 2.0.x series has
2807 dnl problems (bold fonts, --remote doesn't work).
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002808 dnl Disable checking for GTK3 here, otherwise it's found when GTK2 is not
2809 dnl found.
2810 save_skip_gtk3=$SKIP_GTK3
2811 SKIP_GTK3=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002812 AM_PATH_GTK(2.2.0,
2813 [GUI_LIB_LOC="$GTK_LIBDIR"
2814 GTK_LIBNAME="$GTK_LIBS"
2815 GUI_INC_LOC="$GTK_CFLAGS"], )
2816 if test "x$GTK_CFLAGS" != "x"; then
Bram Moolenaar98921892016-02-23 17:14:37 +01002817 SKIP_GTK3=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002818 SKIP_ATHENA=YES
2819 SKIP_NEXTAW=YES
2820 SKIP_MOTIF=YES
2821 GUITYPE=GTK
2822 AC_SUBST(GTK_LIBNAME)
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002823 else
2824 SKIP_GTK3=$save_skip_gtk3
Bram Moolenaar071d4272004-06-13 20:20:40 +00002825 fi
2826 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002827 if test "x$GUITYPE" = "xGTK"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002828 dnl
2829 dnl if GTK exists, then check for GNOME.
2830 dnl
2831 if test -z "$SKIP_GNOME"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002832 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002833 GNOME_INIT_HOOK([have_gnome=yes])
2834 if test "x$have_gnome" = xyes ; then
2835 AC_DEFINE(FEAT_GUI_GNOME)
2836 GUI_INC_LOC="$GUI_INC_LOC $GNOME_INCLUDEDIR"
2837 GTK_LIBNAME="$GTK_LIBNAME $GNOME_LIBDIR $GNOME_LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002838 fi
2839 }
2840 fi
2841 fi
2842fi
2843
Bram Moolenaar98921892016-02-23 17:14:37 +01002844
2845dnl ---------------------------------------------------------------------------
2846dnl Check for GTK3.
2847dnl ---------------------------------------------------------------------------
2848if test -z "$SKIP_GTK3"; then
2849
2850 AC_MSG_CHECKING(--disable-gtktest argument)
2851 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2852 , enable_gtktest=yes)
2853 if test "x$enable_gtktest" = "xyes" ; then
2854 AC_MSG_RESULT(gtk test enabled)
2855 else
2856 AC_MSG_RESULT(gtk test disabled)
2857 fi
2858
Bram Moolenaar98921892016-02-23 17:14:37 +01002859 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002860 save_skip_gtk2=$SKIP_GTK2
2861 SKIP_GTK2=YES
Bram Moolenaar98921892016-02-23 17:14:37 +01002862 AM_PATH_GTK(3.0.0,
2863 [GUI_LIB_LOC="$GTK_LIBDIR"
2864 GTK_LIBNAME="$GTK_LIBS"
2865 GUI_INC_LOC="$GTK_CFLAGS"], )
2866 if test "x$GTK_CFLAGS" != "x"; then
2867 SKIP_GTK2=YES
2868 SKIP_GNOME=YES
2869 SKIP_ATHENA=YES
2870 SKIP_NEXTAW=YES
2871 SKIP_MOTIF=YES
2872 GUITYPE=GTK
2873 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar98921892016-02-23 17:14:37 +01002874 AC_DEFINE(USE_GTK3)
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002875 else
2876 SKIP_GTK2=$save_skip_gtk2
Bram Moolenaar98921892016-02-23 17:14:37 +01002877 fi
2878 fi
2879fi
2880
Bram Moolenaard2e03f02016-01-02 22:46:36 +01002881dnl Check the version of Gdk-Pixbuf. If the version is 2.31 or later and
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002882dnl glib-compile-resources is found in PATH, use GResource.
2883if test "x$GUITYPE" = "xGTK"; then
2884 AC_MSG_CHECKING([version of Gdk-Pixbuf])
2885 gdk_pixbuf_version=`$PKG_CONFIG --modversion gdk-pixbuf-2.0`
2886 if test "x$gdk_pixbuf_version" != x ; then
2887 gdk_pixbuf_version_minor=`echo $gdk_pixbuf_version | \
2888 sed -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/'`
2889 if test "x$gdk_pixbuf_version_minor" != x -a \
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002890 $gdk_pixbuf_version_minor -ge 31 ; then
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002891 AC_MSG_RESULT([OK.])
2892 AC_PATH_PROG(GLIB_COMPILE_RESOURCES,[glib-compile-resources],no)
2893 AC_MSG_CHECKING([glib-compile-resources])
2894 if test "x$GLIB_COMPILE_RESOURCES" = xno ; then
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002895 GLIB_COMPILE_RESOURCES=""
2896 AC_MSG_RESULT([cannot be found in PATH.])
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002897 else
2898 AC_MSG_RESULT([usable.])
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002899 AC_DEFINE(USE_GRESOURCE)
2900 GRESOURCE_SRC="auto/gui_gtk_gresources.c"
2901 GRESOURCE_OBJ="objects/gui_gtk_gresources.o"
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002902 fi
2903 else
2904 AC_MSG_RESULT([not usable.])
2905 fi
2906 else
2907 AC_MSG_RESULT([cannot obtain from pkg_config.])
2908 fi
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002909
2910 AC_MSG_CHECKING([--disable-icon-cache-update argument])
2911 AC_ARG_ENABLE(icon_cache_update,
2912 [ --disable-icon-cache-update update disabled],
2913 [],
2914 [enable_icon_cache_update="yes"])
2915 if test "$enable_icon_cache_update" = "yes"; then
2916 AC_MSG_RESULT([not set])
2917 AC_PATH_PROG(GTK_UPDATE_ICON_CACHE,[gtk-update-icon-cache],no)
2918 if test "x$GTK_UPDATE_ICON_CACHE" = "xno" ; then
2919 AC_MSG_RESULT([not found in PATH.])
2920 fi
2921 else
2922 AC_MSG_RESULT([update disabled])
2923 fi
2924
2925 AC_MSG_CHECKING([--disable-desktop-database-update argument])
2926 AC_ARG_ENABLE(desktop_database_update,
2927 [ --disable-desktop-database-update update disabled],
2928 [],
2929 [enable_desktop_database_update="yes"])
2930 if test "$enable_desktop_database_update" = "yes"; then
2931 AC_MSG_RESULT([not set])
2932 AC_PATH_PROG(UPDATE_DESKTOP_DATABASE,[update-desktop-database],no)
2933 if test "x$UPDATE_DESKTOP_DATABASE" = "xno" ; then
2934 AC_MSG_RESULT([not found in PATH.])
2935 fi
2936 else
2937 AC_MSG_RESULT([update disabled])
2938 fi
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002939fi
2940AC_SUBST(GLIB_COMPILE_RESOURCES)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002941AC_SUBST(GRESOURCE_SRC)
2942AC_SUBST(GRESOURCE_OBJ)
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002943AC_SUBST(GTK_UPDATE_ICON_CACHE)
2944AC_SUBST(UPDATE_DESKTOP_DATABASE)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002945
Bram Moolenaar071d4272004-06-13 20:20:40 +00002946dnl Check for Motif include files location.
2947dnl The LAST one found is used, this makes the highest version to be used,
2948dnl e.g. when Motif1.2 and Motif2.0 are both present.
2949
2950if test -z "$SKIP_MOTIF"; then
2951 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"
2952 dnl Remove "-I" from before $GUI_INC_LOC if it's there
2953 GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`"
2954
2955 AC_MSG_CHECKING(for location of Motif GUI includes)
2956 gui_includes="`echo $x_includes|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC"
2957 GUI_INC_LOC=
2958 for try in $gui_includes; do
2959 if test -f "$try/Xm/Xm.h"; then
2960 GUI_INC_LOC=$try
2961 fi
2962 done
2963 if test -n "$GUI_INC_LOC"; then
2964 if test "$GUI_INC_LOC" = /usr/include; then
2965 GUI_INC_LOC=
2966 AC_MSG_RESULT(in default path)
2967 else
2968 AC_MSG_RESULT($GUI_INC_LOC)
2969 fi
2970 else
2971 AC_MSG_RESULT(<not found>)
2972 SKIP_MOTIF=YES
2973 fi
2974fi
2975
2976dnl Check for Motif library files location. In the same order as the include
2977dnl files, to avoid a mixup if several versions are present
2978
2979if test -z "$SKIP_MOTIF"; then
2980 AC_MSG_CHECKING(--with-motif-lib argument)
2981 AC_ARG_WITH(motif-lib,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002982 [ --with-motif-lib=STRING Library for Motif ],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002983 [ MOTIF_LIBNAME="${withval}" ] )
2984
2985 if test -n "$MOTIF_LIBNAME"; then
2986 AC_MSG_RESULT($MOTIF_LIBNAME)
2987 GUI_LIB_LOC=
2988 else
2989 AC_MSG_RESULT(no)
2990
2991 dnl Remove "-L" from before $GUI_LIB_LOC if it's there
2992 GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
2993
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002994 dnl Ubuntu has libXm.so in /usr/lib/i386-linux-gnu and elsewhere. The
2995 dnl linker will figure out which one to use, we only check if one exists.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002996 AC_MSG_CHECKING(for location of Motif GUI libs)
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002997 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 +00002998 GUI_LIB_LOC=
2999 for try in $gui_libs; do
Bram Moolenaar325b7a22004-07-05 15:58:32 +00003000 for libtry in "$try"/libXm.a "$try"/libXm.so* "$try"/libXm.sl "$try"/libXm.dylib; do
Bram Moolenaar071d4272004-06-13 20:20:40 +00003001 if test -f "$libtry"; then
3002 GUI_LIB_LOC=$try
3003 fi
3004 done
3005 done
3006 if test -n "$GUI_LIB_LOC"; then
3007 dnl Remove /usr/lib, it causes trouble on some systems
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02003008 if test "$GUI_LIB_LOC" = /usr/lib \
3009 -o "$GUI_LIB_LOC" = /usr/lib/i386-linux-gnu \
3010 -o "$GUI_LIB_LOC" = /usr/lib/x86_64-linux-gnu; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003011 GUI_LIB_LOC=
3012 AC_MSG_RESULT(in default path)
3013 else
3014 if test -n "$GUI_LIB_LOC"; then
3015 AC_MSG_RESULT($GUI_LIB_LOC)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00003016 if test "$vim_cv_uname_output" = SunOS &&
3017 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003018 GUI_LIB_LOC="$GUI_LIB_LOC -R $GUI_LIB_LOC"
3019 fi
3020 fi
3021 fi
3022 MOTIF_LIBNAME=-lXm
3023 else
3024 AC_MSG_RESULT(<not found>)
3025 SKIP_MOTIF=YES
3026 fi
3027 fi
3028fi
3029
3030if test -z "$SKIP_MOTIF"; then
3031 SKIP_ATHENA=YES
3032 SKIP_NEXTAW=YES
3033 GUITYPE=MOTIF
3034 AC_SUBST(MOTIF_LIBNAME)
3035fi
3036
3037dnl Check if the Athena files can be found
3038
3039GUI_X_LIBS=
3040
3041if test -z "$SKIP_ATHENA"; then
3042 AC_MSG_CHECKING(if Athena header files can be found)
3043 cflags_save=$CFLAGS
3044 CFLAGS="$CFLAGS $X_CFLAGS"
3045 AC_TRY_COMPILE([
3046#include <X11/Intrinsic.h>
3047#include <X11/Xaw/Paned.h>], ,
3048 AC_MSG_RESULT(yes),
3049 AC_MSG_RESULT(no); SKIP_ATHENA=YES )
3050 CFLAGS=$cflags_save
3051fi
3052
3053if test -z "$SKIP_ATHENA"; then
3054 GUITYPE=ATHENA
3055fi
3056
3057if test -z "$SKIP_NEXTAW"; then
3058 AC_MSG_CHECKING(if neXtaw header files can be found)
3059 cflags_save=$CFLAGS
3060 CFLAGS="$CFLAGS $X_CFLAGS"
3061 AC_TRY_COMPILE([
3062#include <X11/Intrinsic.h>
3063#include <X11/neXtaw/Paned.h>], ,
3064 AC_MSG_RESULT(yes),
3065 AC_MSG_RESULT(no); SKIP_NEXTAW=YES )
3066 CFLAGS=$cflags_save
3067fi
3068
3069if test -z "$SKIP_NEXTAW"; then
3070 GUITYPE=NEXTAW
3071fi
3072
3073if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
3074 dnl Prepend -I and -L to $GUI_INC_LOC and $GUI_LIB_LOC if not empty
3075 dnl Avoid adding it when it twice
3076 if test -n "$GUI_INC_LOC"; then
3077 GUI_INC_LOC=-I"`echo $GUI_INC_LOC|sed 's%-I%%'`"
3078 fi
3079 if test -n "$GUI_LIB_LOC"; then
3080 GUI_LIB_LOC=-L"`echo $GUI_LIB_LOC|sed 's%-L%%'`"
3081 fi
3082
3083 dnl Check for -lXext and then for -lXmu
3084 ldflags_save=$LDFLAGS
3085 LDFLAGS="$X_LIBS $LDFLAGS"
3086 AC_CHECK_LIB(Xext, XShapeQueryExtension, [GUI_X_LIBS="-lXext"],,
3087 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3088 dnl For Solaris we need -lw and -ldl before linking with -lXmu works.
3089 AC_CHECK_LIB(w, wslen, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lw"],,
3090 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3091 AC_CHECK_LIB(dl, dlsym, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldl"],,
3092 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3093 AC_CHECK_LIB(Xmu, XmuCreateStippledPixmap, [GUI_X_LIBS="-lXmu $GUI_X_LIBS"],,
3094 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3095 if test -z "$SKIP_MOTIF"; then
3096 AC_CHECK_LIB(Xp, XpEndJob, [GUI_X_LIBS="-lXp $GUI_X_LIBS"],,
3097 [$GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3098 fi
3099 LDFLAGS=$ldflags_save
3100
3101 dnl Execute xmkmf to figure out if -DNARROWPROTO is needed.
3102 AC_MSG_CHECKING(for extra X11 defines)
3103 NARROW_PROTO=
3104 rm -fr conftestdir
3105 if mkdir conftestdir; then
3106 cd conftestdir
3107 cat > Imakefile <<'EOF'
3108acfindx:
3109 @echo 'NARROW_PROTO="${PROTO_DEFINES}"'
3110EOF
3111 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
3112 eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
3113 fi
3114 cd ..
3115 rm -fr conftestdir
3116 fi
3117 if test -z "$NARROW_PROTO"; then
3118 AC_MSG_RESULT(no)
3119 else
3120 AC_MSG_RESULT($NARROW_PROTO)
3121 fi
3122 AC_SUBST(NARROW_PROTO)
3123fi
3124
3125dnl Look for XSMP support - but don't necessarily restrict it to X11 GUIs
3126dnl use the X11 include path
3127if test "$enable_xsmp" = "yes"; then
3128 cppflags_save=$CPPFLAGS
3129 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3130 AC_CHECK_HEADERS(X11/SM/SMlib.h)
3131 CPPFLAGS=$cppflags_save
3132fi
3133
3134
Bram Moolenaar98921892016-02-23 17:14:37 +01003135if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF" -o -z "$SKIP_GTK2" -o -z "$SKIP_GTK3"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003136 dnl Check for X11/xpm.h and X11/Sunkeysym.h with the GUI include path
3137 cppflags_save=$CPPFLAGS
3138 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3139 AC_CHECK_HEADERS(X11/xpm.h X11/Sunkeysym.h)
3140
3141 dnl automatically disable XIM when XIMtext isn't in X11/Xlib.h
3142 if test ! "$enable_xim" = "no"; then
3143 AC_MSG_CHECKING(for XIMText in X11/Xlib.h)
3144 AC_EGREP_CPP(XIMText, [#include <X11/Xlib.h>],
3145 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +02003146 AC_MSG_RESULT(no; xim has been disabled); enable_xim="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00003147 fi
3148 CPPFLAGS=$cppflags_save
3149
Bram Moolenaar54612582019-11-21 17:13:31 +01003150 dnl automatically enable XIM in the GUI
3151 if test "$enable_xim" = "auto" -a "x$GUITYPE" != "xNONE" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003152 AC_MSG_RESULT(X GUI selected; xim has been enabled)
3153 enable_xim="yes"
3154 fi
3155fi
3156
3157if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
3158 cppflags_save=$CPPFLAGS
3159 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00003160dnl Xmu/Editres.h may exist but can only be used after including Intrinsic.h
3161 AC_MSG_CHECKING([for X11/Xmu/Editres.h])
3162 AC_TRY_COMPILE([
3163#include <X11/Intrinsic.h>
3164#include <X11/Xmu/Editres.h>],
3165 [int i; i = 0;],
3166 AC_MSG_RESULT(yes)
3167 AC_DEFINE(HAVE_X11_XMU_EDITRES_H),
3168 AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003169 CPPFLAGS=$cppflags_save
3170fi
3171
3172dnl Only use the Xm directory when compiling Motif, don't use it for Athena
3173if test -z "$SKIP_MOTIF"; then
3174 cppflags_save=$CPPFLAGS
3175 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003176 if test "$zOSUnix" = "yes"; then
3177 xmheader="Xm/Xm.h"
3178 else
3179 xmheader="Xm/Xm.h Xm/XpmP.h Xm/JoinSideT.h Xm/TraitP.h Xm/Manager.h
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02003180 Xm/UnhighlightT.h Xm/Notebook.h"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003181 fi
3182 AC_CHECK_HEADERS($xmheader)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003183
Bram Moolenaar77c19352012-06-13 19:19:41 +02003184 if test "x$ac_cv_header_Xm_XpmP_h" = "xyes"; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003185 dnl Solaris uses XpmAttributes_21, very annoying.
3186 AC_MSG_CHECKING([for XpmAttributes_21 in Xm/XpmP.h])
3187 AC_TRY_COMPILE([#include <Xm/XpmP.h>], [XpmAttributes_21 attr;],
3188 AC_MSG_RESULT(yes); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes_21),
3189 AC_MSG_RESULT(no); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
3190 )
3191 else
Bram Moolenaar57657d82006-04-21 22:12:41 +00003192 AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003193 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003194 CPPFLAGS=$cppflags_save
3195fi
3196
3197if test "x$GUITYPE" = "xNONE" -a "$enable_xim" = "yes"; then
3198 AC_MSG_RESULT(no GUI selected; xim has been disabled)
3199 enable_xim="no"
3200fi
3201if test "x$GUITYPE" = "xNONE" -a "$enable_fontset" = "yes"; then
3202 AC_MSG_RESULT(no GUI selected; fontset has been disabled)
3203 enable_fontset="no"
3204fi
Bram Moolenaar182c5be2010-06-25 05:37:59 +02003205if test "x$GUITYPE:$enable_fontset" = "xGTK:yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003206 AC_MSG_RESULT(GTK+ 2 GUI selected; fontset has been disabled)
3207 enable_fontset="no"
3208fi
3209
Bram Moolenaarb3f74062020-02-26 16:16:53 +01003210dnl There is no test for the Haiku GUI, if it's selected it's used
3211if test -z "$SKIP_HAIKU"; then
3212 GUITYPE=HAIKUGUI
3213fi
3214
Bram Moolenaar071d4272004-06-13 20:20:40 +00003215if test -z "$SKIP_PHOTON"; then
3216 GUITYPE=PHOTONGUI
3217fi
3218
3219AC_SUBST(GUI_INC_LOC)
3220AC_SUBST(GUI_LIB_LOC)
3221AC_SUBST(GUITYPE)
3222AC_SUBST(GUI_X_LIBS)
3223
3224if test "$enable_workshop" = "yes" -a -n "$SKIP_MOTIF"; then
3225 AC_MSG_ERROR([cannot use workshop without Motif])
3226fi
3227
3228dnl defining FEAT_XIM and FEAT_XFONTSET is delayed, so that they can be disabled
3229if test "$enable_xim" = "yes"; then
3230 AC_DEFINE(FEAT_XIM)
3231fi
3232if test "$enable_fontset" = "yes"; then
3233 AC_DEFINE(FEAT_XFONTSET)
3234fi
3235
3236
3237dnl ---------------------------------------------------------------------------
3238dnl end of GUI-checking
3239dnl ---------------------------------------------------------------------------
3240
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003241AC_MSG_CHECKING([for /proc link to executable])
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003242if test -L "/proc/self/exe"; then
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003243 dnl Linux
3244 AC_MSG_RESULT([/proc/self/exe])
3245 AC_DEFINE(PROC_EXE_LINK, "/proc/self/exe")
3246elif test -L "/proc/self/path/a.out"; then
3247 dnl Solaris
3248 AC_MSG_RESULT([/proc/self/path/a.out])
3249 AC_DEFINE(PROC_EXE_LINK, "/proc/self/path/a.out")
3250elif test -L "/proc/curproc/file"; then
3251 dnl FreeBSD
3252 AC_MSG_RESULT([/proc/curproc/file])
3253 AC_DEFINE(PROC_EXE_LINK, "/proc/curproc/file")
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003254else
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003255 AC_MSG_RESULT(no)
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003256fi
3257
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003258dnl Check for Cygwin, which needs an extra source file if not using X11
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003259AC_MSG_CHECKING(for CYGWIN or MSYS environment)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00003260case $vim_cv_uname_output in
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003261 CYGWIN*|MSYS*) CYGWIN=yes; AC_MSG_RESULT(yes)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003262 AC_MSG_CHECKING(for CYGWIN clipboard support)
3263 if test "x$with_x" = "xno" ; then
3264 OS_EXTRA_SRC=winclip.c; OS_EXTRA_OBJ=objects/winclip.o
3265 AC_MSG_RESULT(yes)
3266 AC_DEFINE(FEAT_CYGWIN_WIN32_CLIPBOARD)
3267 else
3268 AC_MSG_RESULT(no - using X11)
3269 fi ;;
3270
3271 *) CYGWIN=no; AC_MSG_RESULT(no);;
3272esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00003273
Bram Moolenaar071d4272004-06-13 20:20:40 +00003274dnl Checks for libraries and include files.
3275
Bram Moolenaar446cb832008-06-24 21:56:24 +00003276AC_CACHE_CHECK([whether toupper is broken], [vim_cv_toupper_broken],
3277 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003278 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003279#include "confdefs.h"
3280#include <ctype.h>
3281#if STDC_HEADERS
3282# include <stdlib.h>
3283# include <stddef.h>
3284#endif
3285main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003286 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003287 vim_cv_toupper_broken=yes
3288 ],[
3289 vim_cv_toupper_broken=no
3290 ],[
3291 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_toupper_broken')
3292 ])])
3293
3294if test "x$vim_cv_toupper_broken" = "xyes" ; then
3295 AC_DEFINE(BROKEN_TOUPPER)
3296fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003297
3298AC_MSG_CHECKING(whether __DATE__ and __TIME__ work)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003299AC_TRY_COMPILE([#include <stdio.h>], [printf("(" __DATE__ " " __TIME__ ")");],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003300 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DATE_TIME),
3301 AC_MSG_RESULT(no))
3302
Bram Moolenaar0c094b92009-05-14 20:20:33 +00003303AC_MSG_CHECKING(whether __attribute__((unused)) is allowed)
3304AC_TRY_COMPILE([#include <stdio.h>], [int x __attribute__((unused));],
3305 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ATTRIBUTE_UNUSED),
3306 AC_MSG_RESULT(no))
3307
Bram Moolenaar071d4272004-06-13 20:20:40 +00003308dnl Checks for header files.
3309AC_CHECK_HEADER(elf.h, HAS_ELF=1)
3310dnl AC_CHECK_HEADER(dwarf.h, SVR4=1)
3311if test "$HAS_ELF" = 1; then
3312 AC_CHECK_LIB(elf, main)
3313fi
3314
3315AC_HEADER_DIRENT
3316
Bram Moolenaar071d4272004-06-13 20:20:40 +00003317dnl If sys/wait.h is not found it might still exist but not be POSIX
3318dnl compliant. In that case we define HAVE_UNION_WAIT (for NeXT)
3319if test $ac_cv_header_sys_wait_h = no; then
3320 AC_MSG_CHECKING([for sys/wait.h that defines union wait])
3321 AC_TRY_COMPILE([#include <sys/wait.h>],
3322 [union wait xx, yy; xx = yy],
3323 AC_MSG_RESULT(yes)
3324 AC_DEFINE(HAVE_SYS_WAIT_H)
3325 AC_DEFINE(HAVE_UNION_WAIT),
3326 AC_MSG_RESULT(no))
3327fi
3328
Bram Moolenaar779a7752016-01-30 23:26:34 +01003329AC_CHECK_HEADERS(stdint.h stdlib.h string.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003330 sys/select.h sys/utsname.h termcap.h fcntl.h \
3331 sgtty.h sys/ioctl.h sys/time.h sys/types.h \
3332 termio.h iconv.h inttypes.h langinfo.h math.h \
3333 unistd.h stropts.h errno.h sys/resource.h \
3334 sys/systeminfo.h locale.h sys/stream.h termios.h \
3335 libc.h sys/statfs.h poll.h sys/poll.h pwd.h \
Bram Moolenaar1ecc5e42019-01-26 15:12:55 +01003336 utime.h sys/param.h sys/ptms.h libintl.h libgen.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003337 util/debug.h util/msg18n.h frame.h sys/acl.h \
3338 sys/access.h sys/sysinfo.h wchar.h wctype.h)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003339
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003340dnl sys/ptem.h depends on sys/stream.h on Solaris
3341AC_CHECK_HEADERS(sys/ptem.h, [], [],
3342[#if defined HAVE_SYS_STREAM_H
3343# include <sys/stream.h>
3344#endif])
3345
Bram Moolenaar32f31b12009-05-21 13:20:59 +00003346dnl sys/sysctl.h depends on sys/param.h on OpenBSD
3347AC_CHECK_HEADERS(sys/sysctl.h, [], [],
3348[#if defined HAVE_SYS_PARAM_H
3349# include <sys/param.h>
3350#endif])
3351
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003352
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003353dnl pthread_np.h may exist but can only be used after including pthread.h
3354AC_MSG_CHECKING([for pthread_np.h])
3355AC_TRY_COMPILE([
3356#include <pthread.h>
3357#include <pthread_np.h>],
3358 [int i; i = 0;],
3359 AC_MSG_RESULT(yes)
3360 AC_DEFINE(HAVE_PTHREAD_NP_H),
3361 AC_MSG_RESULT(no))
3362
Bram Moolenaare344bea2005-09-01 20:46:49 +00003363AC_CHECK_HEADERS(strings.h)
Bram Moolenaard0573012017-10-28 21:11:06 +02003364if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00003365 dnl The strings.h file on OS/X contains a warning and nothing useful.
3366 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3367else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003368
3369dnl Check if strings.h and string.h can both be included when defined.
3370AC_MSG_CHECKING([if strings.h can be included after string.h])
3371cppflags_save=$CPPFLAGS
3372CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3373AC_TRY_COMPILE([
3374#if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO)
3375# define _NO_PROTO /* like in os_unix.h, causes conflict for AIX (Winn) */
3376 /* but don't do it on AIX 5.1 (Uribarri) */
3377#endif
3378#ifdef HAVE_XM_XM_H
3379# include <Xm/Xm.h> /* This breaks it for HP-UX 11 (Squassabia) */
3380#endif
3381#ifdef HAVE_STRING_H
3382# include <string.h>
3383#endif
3384#if defined(HAVE_STRINGS_H)
3385# include <strings.h>
3386#endif
3387 ], [int i; i = 0;],
3388 AC_MSG_RESULT(yes),
3389 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3390 AC_MSG_RESULT(no))
3391CPPFLAGS=$cppflags_save
Bram Moolenaar9372a112005-12-06 19:59:18 +00003392fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003393
3394dnl Checks for typedefs, structures, and compiler characteristics.
3395AC_PROG_GCC_TRADITIONAL
3396AC_C_CONST
Bram Moolenaar76243bd2009-03-02 01:47:02 +00003397AC_C_VOLATILE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003398AC_TYPE_MODE_T
3399AC_TYPE_OFF_T
3400AC_TYPE_PID_T
3401AC_TYPE_SIZE_T
3402AC_TYPE_UID_T
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003403AC_TYPE_UINT32_T
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003404
Bram Moolenaar071d4272004-06-13 20:20:40 +00003405AC_HEADER_TIME
3406AC_CHECK_TYPE(ino_t, long)
3407AC_CHECK_TYPE(dev_t, unsigned)
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003408AC_C_BIGENDIAN(,,,)
Bram Moolenaar136f29a2016-02-27 20:14:15 +01003409AC_C_INLINE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003410
3411AC_MSG_CHECKING(for rlim_t)
3412if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
3413 AC_MSG_RESULT([(cached) $ac_cv_type_rlim_t])
3414else
3415 AC_EGREP_CPP(dnl
3416changequote(<<,>>)dnl
3417<<(^|[^a-zA-Z_0-9])rlim_t[^a-zA-Z_0-9]>>dnl
3418changequote([,]),
3419 [
3420#include <sys/types.h>
3421#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003422# include <stdlib.h>
3423# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003424#endif
3425#ifdef HAVE_SYS_RESOURCE_H
Bram Moolenaar446cb832008-06-24 21:56:24 +00003426# include <sys/resource.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003427#endif
3428 ], ac_cv_type_rlim_t=yes, ac_cv_type_rlim_t=no)
3429 AC_MSG_RESULT($ac_cv_type_rlim_t)
3430fi
3431if test $ac_cv_type_rlim_t = no; then
3432 cat >> confdefs.h <<\EOF
3433#define rlim_t unsigned long
3434EOF
3435fi
3436
3437AC_MSG_CHECKING(for stack_t)
3438if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then
3439 AC_MSG_RESULT([(cached) $ac_cv_type_stack_t])
3440else
3441 AC_EGREP_CPP(stack_t,
3442 [
3443#include <sys/types.h>
3444#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003445# include <stdlib.h>
3446# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003447#endif
3448#include <signal.h>
3449 ], ac_cv_type_stack_t=yes, ac_cv_type_stack_t=no)
3450 AC_MSG_RESULT($ac_cv_type_stack_t)
3451fi
3452if test $ac_cv_type_stack_t = no; then
3453 cat >> confdefs.h <<\EOF
3454#define stack_t struct sigaltstack
3455EOF
3456fi
3457
3458dnl BSDI uses ss_base while others use ss_sp for the stack pointer.
3459AC_MSG_CHECKING(whether stack_t has an ss_base field)
3460AC_TRY_COMPILE([
3461#include <sys/types.h>
3462#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003463# include <stdlib.h>
3464# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003465#endif
3466#include <signal.h>
3467#include "confdefs.h"
3468 ], [stack_t sigstk; sigstk.ss_base = 0; ],
3469 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SS_BASE),
3470 AC_MSG_RESULT(no))
3471
3472olibs="$LIBS"
3473AC_MSG_CHECKING(--with-tlib argument)
3474AC_ARG_WITH(tlib, [ --with-tlib=library terminal library to be used ],)
3475if test -n "$with_tlib"; then
3476 AC_MSG_RESULT($with_tlib)
3477 LIBS="$LIBS -l$with_tlib"
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003478 AC_MSG_CHECKING(for linking with $with_tlib library)
3479 AC_TRY_LINK([], [], AC_MSG_RESULT(OK), AC_MSG_ERROR(FAILED))
3480 dnl Need to check for tgetent() below.
3481 olibs="$LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003482else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003483 AC_MSG_RESULT([empty: automatic terminal library selection])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003484 dnl On HP-UX 10.10 termcap or termlib should be used instead of
3485 dnl curses, because curses is much slower.
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003486 dnl Newer versions of ncurses are preferred over anything, except
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02003487 dnl when tinfo has been split off, it contains all we need.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003488 dnl Older versions of ncurses have bugs, get a new one!
3489 dnl Digital Unix (OSF1) should use curses (Ronald Schild).
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00003490 dnl On SCO Openserver should prefer termlib (Roger Cornelius).
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00003491 case "$vim_cv_uname_output" in
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003492 OSF1|SCO_SV) tlibs="tinfo ncurses curses termlib termcap";;
3493 *) tlibs="tinfo ncurses termlib termcap curses";;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003494 esac
3495 for libname in $tlibs; do
3496 AC_CHECK_LIB(${libname}, tgetent,,)
3497 if test "x$olibs" != "x$LIBS"; then
3498 dnl It's possible that a library is found but it doesn't work
3499 dnl e.g., shared library that cannot be found
3500 dnl compile and run a test program to be sure
3501 AC_TRY_RUN([
3502#ifdef HAVE_TERMCAP_H
3503# include <termcap.h>
3504#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003505#if STDC_HEADERS
3506# include <stdlib.h>
3507# include <stddef.h>
3508#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003509main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }],
3510 res="OK", res="FAIL", res="FAIL")
3511 if test "$res" = "OK"; then
3512 break
3513 fi
3514 AC_MSG_RESULT($libname library is not usable)
3515 LIBS="$olibs"
3516 fi
3517 done
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003518 if test "x$olibs" = "x$LIBS"; then
3519 AC_MSG_RESULT(no terminal library found)
3520 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003521fi
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003522
3523if test "x$olibs" = "x$LIBS"; then
3524 AC_MSG_CHECKING([for tgetent()])
Bram Moolenaarbd7f7c12020-07-28 21:03:37 +02003525 AC_TRY_LINK([int tgetent(char *, const char *);],
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003526 [char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");],
3527 AC_MSG_RESULT(yes),
3528 AC_MSG_ERROR([NOT FOUND!
3529 You need to install a terminal library; for example ncurses.
Bram Moolenaar16678eb2021-04-21 11:57:59 +02003530 On Linux that would be the libncurses-dev package.
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003531 Or specify the name of the library with --with-tlib.]))
3532fi
3533
Bram Moolenaar446cb832008-06-24 21:56:24 +00003534AC_CACHE_CHECK([whether we talk terminfo], [vim_cv_terminfo],
3535 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003536 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003537#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003538#ifdef HAVE_TERMCAP_H
3539# include <termcap.h>
3540#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003541#ifdef HAVE_STRING_H
3542# include <string.h>
3543#endif
3544#if STDC_HEADERS
3545# include <stdlib.h>
3546# include <stddef.h>
3547#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003548main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003549{char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003550 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003551 vim_cv_terminfo=no
3552 ],[
3553 vim_cv_terminfo=yes
3554 ],[
3555 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_terminfo')
3556 ])
3557 ])
3558
3559if test "x$vim_cv_terminfo" = "xyes" ; then
3560 AC_DEFINE(TERMINFO)
3561fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003562
Bram Moolenaara88254f2017-11-02 23:04:14 +01003563AC_CACHE_CHECK([what tgetent() returns for an unknown terminal], [vim_cv_tgetent],
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003564 [
3565 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003566#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003567#ifdef HAVE_TERMCAP_H
3568# include <termcap.h>
3569#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003570#if STDC_HEADERS
3571# include <stdlib.h>
3572# include <stddef.h>
3573#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003574main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003575{char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003576 ]])],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003577 vim_cv_tgetent=zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003578 ],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003579 vim_cv_tgetent=non-zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003580 ],[
3581 AC_MSG_ERROR(failed to compile test program.)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003582 ])
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003583 ])
3584
Bram Moolenaara88254f2017-11-02 23:04:14 +01003585if test "x$vim_cv_tgetent" = "xzero" ; then
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003586 AC_DEFINE(TGETENT_ZERO_ERR, 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003587fi
3588
3589AC_MSG_CHECKING(whether termcap.h contains ospeed)
3590AC_TRY_LINK([
3591#ifdef HAVE_TERMCAP_H
3592# include <termcap.h>
3593#endif
3594 ], [ospeed = 20000],
3595 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED),
3596 [AC_MSG_RESULT(no)
3597 AC_MSG_CHECKING(whether ospeed can be extern)
3598 AC_TRY_LINK([
3599#ifdef HAVE_TERMCAP_H
3600# include <termcap.h>
3601#endif
3602extern short ospeed;
3603 ], [ospeed = 20000],
3604 AC_MSG_RESULT(yes); AC_DEFINE(OSPEED_EXTERN),
3605 AC_MSG_RESULT(no))]
3606 )
3607
3608AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC])
3609AC_TRY_LINK([
3610#ifdef HAVE_TERMCAP_H
3611# include <termcap.h>
3612#endif
3613 ], [if (UP == 0 && BC == 0) PC = 1],
3614 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UP_BC_PC),
3615 [AC_MSG_RESULT(no)
3616 AC_MSG_CHECKING([whether UP, BC and PC can be extern])
3617 AC_TRY_LINK([
3618#ifdef HAVE_TERMCAP_H
3619# include <termcap.h>
3620#endif
3621extern char *UP, *BC, PC;
3622 ], [if (UP == 0 && BC == 0) PC = 1],
3623 AC_MSG_RESULT(yes); AC_DEFINE(UP_BC_PC_EXTERN),
3624 AC_MSG_RESULT(no))]
3625 )
3626
3627AC_MSG_CHECKING(whether tputs() uses outfuntype)
3628AC_TRY_COMPILE([
3629#ifdef HAVE_TERMCAP_H
3630# include <termcap.h>
3631#endif
3632 ], [extern int xx(); tputs("test", 1, (outfuntype)xx)],
3633 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OUTFUNTYPE),
3634 AC_MSG_RESULT(no))
3635
Bram Moolenaarb3a29552021-11-19 11:28:04 +00003636AC_MSG_CHECKING([whether del_curterm() can be used])
3637AC_TRY_LINK([
3638#ifdef HAVE_TERMCAP_H
3639# include <termcap.h>
3640#endif
3641#include <term.h>
3642 ], [if (cur_term) del_curterm(cur_term);],
3643 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DEL_CURTERM),
3644 AC_MSG_RESULT(no))
3645
Bram Moolenaar071d4272004-06-13 20:20:40 +00003646dnl On some SCO machines sys/select redefines struct timeval
3647AC_MSG_CHECKING([whether sys/select.h and sys/time.h may both be included])
3648AC_TRY_COMPILE([
3649#include <sys/types.h>
3650#include <sys/time.h>
3651#include <sys/select.h>], ,
3652 AC_MSG_RESULT(yes)
3653 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME),
3654 AC_MSG_RESULT(no))
3655
3656dnl AC_DECL_SYS_SIGLIST
3657
3658dnl Checks for pty.c (copied from screen) ==========================
3659AC_MSG_CHECKING(for /dev/ptc)
3660if test -r /dev/ptc; then
3661 AC_DEFINE(HAVE_DEV_PTC)
3662 AC_MSG_RESULT(yes)
3663else
3664 AC_MSG_RESULT(no)
3665fi
3666
3667AC_MSG_CHECKING(for SVR4 ptys)
3668if test -c /dev/ptmx ; then
Bram Moolenaarce7be3a2020-11-26 20:11:11 +01003669 AC_TRY_LINK([
3670// These should be in stdlib.h, but it depends on _XOPEN_SOURCE.
3671char *ptsname(int);
3672int unlockpt(int);
3673int grantpt(int);
3674 ], [
3675 ptsname(0);
3676 grantpt(0);
3677 unlockpt(0);],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003678 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SVR4_PTYS),
3679 AC_MSG_RESULT(no))
3680else
3681 AC_MSG_RESULT(no)
3682fi
3683
3684AC_MSG_CHECKING(for ptyranges)
3685if test -d /dev/ptym ; then
3686 pdir='/dev/ptym'
3687else
3688 pdir='/dev'
3689fi
3690dnl SCO uses ptyp%d
3691AC_EGREP_CPP(yes,
3692[#ifdef M_UNIX
3693 yes;
3694#endif
3695 ], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
3696dnl if test -c /dev/ptyp19; then
3697dnl ptys=`echo /dev/ptyp??`
3698dnl else
3699dnl ptys=`echo $pdir/pty??`
3700dnl fi
3701if test "$ptys" != "$pdir/pty??" ; then
3702 p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
3703 p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'`
3704 AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
3705 AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
3706 AC_MSG_RESULT([$p0 / $p1])
3707else
3708 AC_MSG_RESULT([don't know])
3709fi
3710
Bram Moolenaar071d4272004-06-13 20:20:40 +00003711dnl Checks for library functions. ===================================
3712
3713AC_TYPE_SIGNAL
3714
3715dnl find out what to use at the end of a signal function
3716if test $ac_cv_type_signal = void; then
3717 AC_DEFINE(SIGRETURN, [return])
3718else
3719 AC_DEFINE(SIGRETURN, [return 0])
3720fi
3721
3722dnl check if struct sigcontext is defined (used for SGI only)
3723AC_MSG_CHECKING(for struct sigcontext)
3724AC_TRY_COMPILE([
3725#include <signal.h>
3726test_sig()
3727{
3728 struct sigcontext *scont;
3729 scont = (struct sigcontext *)0;
3730 return 1;
3731} ], ,
3732 AC_MSG_RESULT(yes)
3733 AC_DEFINE(HAVE_SIGCONTEXT),
3734 AC_MSG_RESULT(no))
3735
3736dnl tricky stuff: try to find out if getcwd() is implemented with
3737dnl system("sh -c pwd")
Bram Moolenaar446cb832008-06-24 21:56:24 +00003738AC_CACHE_CHECK([getcwd implementation is broken], [vim_cv_getcwd_broken],
3739 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003740 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003741#include "confdefs.h"
3742#ifdef HAVE_UNISTD_H
3743#include <unistd.h>
3744#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003745char *dagger[] = { "IFS=pwd", 0 };
3746main()
3747{
3748 char buffer[500];
3749 extern char **environ;
3750 environ = dagger;
3751 return getcwd(buffer, 500) ? 0 : 1;
Bram Moolenaar446cb832008-06-24 21:56:24 +00003752}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003753 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003754 vim_cv_getcwd_broken=no
3755 ],[
3756 vim_cv_getcwd_broken=yes
3757 ],[
3758 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_getcwd_broken')
3759 ])
3760 ])
3761
3762if test "x$vim_cv_getcwd_broken" = "xyes" ; then
3763 AC_DEFINE(BAD_GETCWD)
Bram Moolenaar63d25552019-05-10 21:28:38 +02003764 AC_CHECK_FUNCS(getwd)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003765fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003766
Bram Moolenaar25153e12010-02-24 14:47:08 +01003767dnl Check for functions in one big call, to reduce the size of configure.
3768dnl Can only be used for functions that do not require any include.
Bram Moolenaarcd142e32017-11-16 17:03:45 +01003769AC_CHECK_FUNCS(fchdir fchown fchmod fsync getcwd getpseudotty \
Bram Moolenaar63d25552019-05-10 21:28:38 +02003770 getpwent getpwnam getpwuid getrlimit gettimeofday localtime_r lstat \
Bram Moolenaareaf03392009-11-17 11:08:52 +00003771 memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
Bram Moolenaar2fcf6682017-03-11 20:03:42 +01003772 getpgid setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
Bram Moolenaar84cf6bd2020-06-16 20:03:43 +02003773 sigprocmask sigvec strcasecmp strcoll strerror strftime stricmp strncasecmp \
Bram Moolenaar10455d42019-11-21 15:36:18 +01003774 strnicmp strpbrk strptime strtol tgetent towlower towupper iswupper \
3775 tzset usleep utime utimes mblen ftruncate unsetenv posix_openpt)
Bram Moolenaar643b6142018-09-12 20:29:09 +02003776AC_FUNC_SELECT_ARGTYPES
Bram Moolenaar25153e12010-02-24 14:47:08 +01003777AC_FUNC_FSEEKO
Bram Moolenaar071d4272004-06-13 20:20:40 +00003778
Bram Moolenaar317fd3a2010-05-07 16:05:55 +02003779dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when
3780dnl appropriate, so that off_t is 64 bits when needed.
3781AC_SYS_LARGEFILE
3782
Bram Moolenaar21606672019-06-14 20:40:58 +02003783AC_MSG_CHECKING(--enable-canberra argument)
3784AC_ARG_ENABLE(canberra,
3785 [ --disable-canberra Do not use libcanberra.],
3786 , [enable_canberra="maybe"])
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003787
Bram Moolenaar21606672019-06-14 20:40:58 +02003788if test "$enable_canberra" = "maybe"; then
3789 if test "$features" = "big" -o "$features" = "huge"; then
3790 AC_MSG_RESULT(Defaulting to yes)
3791 enable_canberra="yes"
3792 else
3793 AC_MSG_RESULT(Defaulting to no)
3794 enable_canberra="no"
3795 fi
3796else
3797 AC_MSG_RESULT($enable_canberra)
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003798fi
Bram Moolenaar21606672019-06-14 20:40:58 +02003799if test "$enable_canberra" = "yes"; then
3800 if test "x$PKG_CONFIG" != "xno"; then
3801 canberra_lib=`$PKG_CONFIG --libs libcanberra 2>/dev/null`
3802 canberra_cflags=`$PKG_CONFIG --cflags libcanberra 2>/dev/null`
3803 fi
3804 if test "x$canberra_lib" = "x"; then
3805 canberra_lib=-lcanberra
3806 canberra_cflags=-D_REENTRANT
3807 fi
3808 AC_MSG_CHECKING(for libcanberra)
3809 ac_save_CFLAGS="$CFLAGS"
3810 ac_save_LIBS="$LIBS"
Christian Brabandt6b9efdd2021-09-09 17:14:50 +02003811 if `echo "$CFLAGS" | grep -v "$canberra_cflags" >/dev/null`; then
3812 CFLAGS="$CFLAGS $canberra_cflags"
3813 fi
Bram Moolenaar21606672019-06-14 20:40:58 +02003814 LIBS="$LIBS $canberra_lib"
3815 AC_TRY_LINK([
3816 # include <canberra.h>
3817 ], [
3818 ca_context *hello;
3819 ca_context_create(&hello);],
3820 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_CANBERRA),
Bram Moolenaar91b992c2019-11-17 19:07:42 +01003821 AC_MSG_RESULT(no; try installing libcanberra-dev); CFLAGS="$ac_save_CFLAGS"; LIBS="$ac_save_LIBS")
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003822fi
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003823
Christian Brabandtf573c6e2021-06-20 14:02:16 +02003824AC_MSG_CHECKING(--enable-libsodium argument)
3825AC_ARG_ENABLE(libsodium,
3826 [ --disable-libsodium Do not use libsodium.],
3827 , [enable_libsodium="maybe"])
3828
3829if test "$enable_libsodium" = "maybe"; then
3830 if test "$features" = "big" -o "$features" = "huge"; then
3831 AC_MSG_RESULT(Defaulting to yes)
3832 enable_libsodium="yes"
3833 else
3834 AC_MSG_RESULT(Defaulting to no)
3835 enable_libsodium="no"
3836 fi
3837else
3838 AC_MSG_RESULT($enable_libsodium)
3839fi
3840if test "$enable_libsodium" = "yes"; then
3841 if test "x$PKG_CONFIG" != "xno"; then
3842 libsodium_lib=`$PKG_CONFIG --libs libsodium 2>/dev/null`
3843 libsodium_cflags=`$PKG_CONFIG --cflags libsodium 2>/dev/null`
3844 fi
3845 if test "x$libsodium_lib" = "x"; then
3846 libsodium_lib=-lsodium
3847 libsodium_cflags=
3848 fi
ichizok8ce3ca82021-06-23 15:41:52 +02003849 AC_MSG_CHECKING(for libsodium)
Christian Brabandtf573c6e2021-06-20 14:02:16 +02003850 ac_save_CFLAGS="$CFLAGS"
3851 ac_save_LIBS="$LIBS"
3852 CFLAGS="$CFLAGS $libsodium_cflags"
3853 LIBS="$LIBS $libsodium_lib"
3854 AC_TRY_LINK([
3855 # include <sodium.h>
3856 ], [
3857 printf("%d", sodium_init()); ],
3858 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SODIUM),
3859 AC_MSG_RESULT(no; try installing libsodium-dev); CFLAGS="$ac_save_CFLAGS"; LIBS="$ac_save_LIBS")
3860fi
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003861
Bram Moolenaar071d4272004-06-13 20:20:40 +00003862dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible
3863AC_MSG_CHECKING(for st_blksize)
3864AC_TRY_COMPILE(
3865[#include <sys/types.h>
3866#include <sys/stat.h>],
3867[ struct stat st;
3868 int n;
3869
3870 stat("/", &st);
3871 n = (int)st.st_blksize;],
3872 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ST_BLKSIZE),
3873 AC_MSG_RESULT(no))
3874
Bram Moolenaar446cb832008-06-24 21:56:24 +00003875AC_CACHE_CHECK([whether stat() ignores a trailing slash], [vim_cv_stat_ignores_slash],
3876 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003877 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003878#include "confdefs.h"
3879#if STDC_HEADERS
3880# include <stdlib.h>
3881# include <stddef.h>
3882#endif
3883#include <sys/types.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003884#include <sys/stat.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003885main() {struct stat st; exit(stat("configure/", &st) != 0); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003886 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003887 vim_cv_stat_ignores_slash=yes
3888 ],[
3889 vim_cv_stat_ignores_slash=no
3890 ],[
3891 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_stat_ignores_slash')
3892 ])
3893 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003894
Bram Moolenaar446cb832008-06-24 21:56:24 +00003895if test "x$vim_cv_stat_ignores_slash" = "xyes" ; then
3896 AC_DEFINE(STAT_IGNORES_SLASH)
3897fi
Leah Neukirchen0a7984a2021-10-14 21:27:55 +01003898
3899dnl nanoseconds field of struct stat
3900AC_CACHE_CHECK([for nanoseconds field of struct stat],
3901 ac_cv_struct_st_mtim_nsec,
3902 [ac_save_CPPFLAGS="$CPPFLAGS"
3903 ac_cv_struct_st_mtim_nsec=no
3904 # st_mtim.tv_nsec -- the usual case
3905 # st_mtim._tv_nsec -- Solaris 2.6, if
3906 # (defined _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED == 1
3907 # && !defined __EXTENSIONS__)
3908 # st_mtim.st__tim.tv_nsec -- UnixWare 2.1.2
3909 # st_mtime_n -- AIX 5.2 and above
3910 # st_mtimespec.tv_nsec -- Darwin (Mac OSX)
3911 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
3912 CPPFLAGS="$ac_save_CPPFLAGS -DST_MTIM_NSEC=$ac_val"
3913 AC_TRY_COMPILE([#include <sys/types.h>
3914#include <sys/stat.h>], [struct stat s; s.ST_MTIM_NSEC;],
3915 [ac_cv_struct_st_mtim_nsec=$ac_val; break])
3916 done
3917 CPPFLAGS="$ac_save_CPPFLAGS"
3918])
3919if test $ac_cv_struct_st_mtim_nsec != no; then
3920 AC_DEFINE_UNQUOTED([ST_MTIM_NSEC], [$ac_cv_struct_st_mtim_nsec],
3921 [Define if struct stat contains a nanoseconds field])
3922fi
Bram Moolenaar446cb832008-06-24 21:56:24 +00003923
Bram Moolenaar071d4272004-06-13 20:20:40 +00003924dnl Link with iconv for charset translation, if not found without library.
3925dnl check for iconv() requires including iconv.h
3926dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
3927dnl has been installed.
3928AC_MSG_CHECKING(for iconv_open())
3929save_LIBS="$LIBS"
3930LIBS="$LIBS -liconv"
3931AC_TRY_LINK([
3932#ifdef HAVE_ICONV_H
3933# include <iconv.h>
3934#endif
3935 ], [iconv_open("fr", "to");],
3936 AC_MSG_RESULT(yes; with -liconv); AC_DEFINE(HAVE_ICONV),
3937 LIBS="$save_LIBS"
3938 AC_TRY_LINK([
3939#ifdef HAVE_ICONV_H
3940# include <iconv.h>
3941#endif
3942 ], [iconv_open("fr", "to");],
3943 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ICONV),
3944 AC_MSG_RESULT(no)))
3945
3946
3947AC_MSG_CHECKING(for nl_langinfo(CODESET))
3948AC_TRY_LINK([
3949#ifdef HAVE_LANGINFO_H
3950# include <langinfo.h>
3951#endif
3952], [char *cs = nl_langinfo(CODESET);],
3953 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET),
3954 AC_MSG_RESULT(no))
3955
Bram Moolenaar446cb832008-06-24 21:56:24 +00003956dnl Need various functions for floating point support. Only enable
3957dnl floating point when they are all present.
3958AC_CHECK_LIB(m, strtod)
3959AC_MSG_CHECKING([for strtod() and other floating point functions])
3960AC_TRY_LINK([
3961#ifdef HAVE_MATH_H
3962# include <math.h>
3963#endif
3964#if STDC_HEADERS
3965# include <stdlib.h>
3966# include <stddef.h>
3967#endif
3968], [char *s; double d;
3969 d = strtod("1.1", &s);
3970 d = fabs(1.11);
3971 d = ceil(1.11);
3972 d = floor(1.11);
3973 d = log10(1.11);
3974 d = pow(1.11, 2.22);
3975 d = sqrt(1.11);
3976 d = sin(1.11);
3977 d = cos(1.11);
3978 d = atan(1.11);
3979 ],
3980 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT_FUNCS),
3981 AC_MSG_RESULT(no))
3982
Bram Moolenaara6b89762016-02-29 21:38:26 +01003983dnl isinf() and isnan() need to include header files and may need -lm.
3984AC_MSG_CHECKING([for isinf()])
3985AC_TRY_LINK([
3986#ifdef HAVE_MATH_H
3987# include <math.h>
3988#endif
3989#if STDC_HEADERS
3990# include <stdlib.h>
3991# include <stddef.h>
3992#endif
3993], [int r = isinf(1.11); ],
3994 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISINF),
3995 AC_MSG_RESULT(no))
3996
3997AC_MSG_CHECKING([for isnan()])
3998AC_TRY_LINK([
3999#ifdef HAVE_MATH_H
4000# include <math.h>
4001#endif
4002#if STDC_HEADERS
4003# include <stdlib.h>
4004# include <stddef.h>
4005#endif
4006], [int r = isnan(1.11); ],
4007 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISNAN),
4008 AC_MSG_RESULT(no))
4009
Bram Moolenaar071d4272004-06-13 20:20:40 +00004010dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI
4011dnl when -lacl works, also try to use -lattr (required for Debian).
Bram Moolenaar8d462f92012-02-05 22:51:33 +01004012dnl On Solaris, use the acl_get/set functions in libsec, if present.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004013AC_MSG_CHECKING(--disable-acl argument)
4014AC_ARG_ENABLE(acl,
Bram Moolenaard6d30422018-01-28 22:48:55 +01004015 [ --disable-acl No check for ACL support.],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004016 , [enable_acl="yes"])
4017if test "$enable_acl" = "yes"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01004018 AC_MSG_RESULT(no)
4019 AC_CHECK_LIB(posix1e, acl_get_file, [LIBS="$LIBS -lposix1e"],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004020 AC_CHECK_LIB(acl, acl_get_file, [LIBS="$LIBS -lacl"
4021 AC_CHECK_LIB(attr, fgetxattr, LIBS="$LIBS -lattr",,)],,),)
4022
Bram Moolenaard6d30422018-01-28 22:48:55 +01004023 AC_MSG_CHECKING(for POSIX ACL support)
4024 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00004025#include <sys/types.h>
4026#ifdef HAVE_SYS_ACL_H
4027# include <sys/acl.h>
4028#endif
4029acl_t acl;], [acl = acl_get_file("foo", ACL_TYPE_ACCESS);
4030 acl_set_file("foo", ACL_TYPE_ACCESS, acl);
4031 acl_free(acl);],
4032 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_ACL),
4033 AC_MSG_RESULT(no))
4034
Bram Moolenaard6d30422018-01-28 22:48:55 +01004035 AC_CHECK_LIB(sec, acl_get, [LIBS="$LIBS -lsec"; AC_DEFINE(HAVE_SOLARIS_ZFS_ACL)],
4036 AC_MSG_CHECKING(for Solaris ACL support)
4037 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00004038#ifdef HAVE_SYS_ACL_H
4039# include <sys/acl.h>
4040#endif], [acl("foo", GETACLCNT, 0, NULL);
4041 ],
4042 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOLARIS_ACL),
Bram Moolenaar8d462f92012-02-05 22:51:33 +01004043 AC_MSG_RESULT(no)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004044
Bram Moolenaard6d30422018-01-28 22:48:55 +01004045 AC_MSG_CHECKING(for AIX ACL support)
4046 AC_TRY_LINK([
Bram Moolenaar446cb832008-06-24 21:56:24 +00004047#if STDC_HEADERS
4048# include <stdlib.h>
4049# include <stddef.h>
4050#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004051#ifdef HAVE_SYS_ACL_H
4052# include <sys/acl.h>
4053#endif
4054#ifdef HAVE_SYS_ACCESS_H
4055# include <sys/access.h>
4056#endif
4057#define _ALL_SOURCE
4058
4059#include <sys/stat.h>
4060
4061int aclsize;
4062struct acl *aclent;], [aclsize = sizeof(struct acl);
4063 aclent = (void *)malloc(aclsize);
4064 statacl("foo", STX_NORMAL, aclent, aclsize);
4065 ],
4066 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_AIX_ACL),
4067 AC_MSG_RESULT(no))
4068else
4069 AC_MSG_RESULT(yes)
4070fi
4071
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02004072if test "x$GTK_CFLAGS" != "x"; then
4073 dnl pango_shape_full() is new, fall back to pango_shape().
4074 AC_MSG_CHECKING(for pango_shape_full)
4075 ac_save_CFLAGS="$CFLAGS"
4076 ac_save_LIBS="$LIBS"
4077 CFLAGS="$CFLAGS $GTK_CFLAGS"
4078 LIBS="$LIBS $GTK_LIBS"
Bram Moolenaar5325b9b2015-09-09 20:27:02 +02004079 AC_TRY_LINK(
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02004080 [#include <gtk/gtk.h>],
4081 [ pango_shape_full(NULL, 0, NULL, 0, NULL, NULL); ],
4082 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_PANGO_SHAPE_FULL),
4083 AC_MSG_RESULT(no))
4084 CFLAGS="$ac_save_CFLAGS"
4085 LIBS="$ac_save_LIBS"
4086fi
4087
Bram Moolenaar071d4272004-06-13 20:20:40 +00004088AC_MSG_CHECKING(--disable-gpm argument)
4089AC_ARG_ENABLE(gpm,
4090 [ --disable-gpm Don't use gpm (Linux mouse daemon).], ,
4091 [enable_gpm="yes"])
4092
4093if test "$enable_gpm" = "yes"; then
4094 AC_MSG_RESULT(no)
4095 dnl Checking if gpm support can be compiled
4096 AC_CACHE_CHECK([for gpm], vi_cv_have_gpm,
4097 [olibs="$LIBS" ; LIBS="-lgpm"]
4098 AC_TRY_LINK(
4099 [#include <gpm.h>
4100 #include <linux/keyboard.h>],
4101 [Gpm_GetLibVersion(NULL);],
4102 dnl Configure defines HAVE_GPM, if it is defined feature.h defines
4103 dnl FEAT_MOUSE_GPM if mouse support is included
4104 [vi_cv_have_gpm=yes],
4105 [vi_cv_have_gpm=no])
4106 [LIBS="$olibs"]
4107 )
4108 if test $vi_cv_have_gpm = yes; then
4109 LIBS="$LIBS -lgpm"
4110 AC_DEFINE(HAVE_GPM)
4111 fi
4112else
4113 AC_MSG_RESULT(yes)
4114fi
4115
Bram Moolenaar446cb832008-06-24 21:56:24 +00004116AC_MSG_CHECKING(--disable-sysmouse argument)
4117AC_ARG_ENABLE(sysmouse,
Bram Moolenaar8008b632017-07-18 21:33:20 +02004118 [ --disable-sysmouse Don't use sysmouse (mouse in *BSD console).], ,
Bram Moolenaar446cb832008-06-24 21:56:24 +00004119 [enable_sysmouse="yes"])
4120
4121if test "$enable_sysmouse" = "yes"; then
4122 AC_MSG_RESULT(no)
4123 dnl Checking if sysmouse support can be compiled
4124 dnl Configure defines HAVE_SYSMOUSE, if it is defined feature.h
4125 dnl defines FEAT_SYSMOUSE if mouse support is included
4126 AC_CACHE_CHECK([for sysmouse], vi_cv_have_sysmouse,
4127 AC_TRY_LINK(
4128 [#include <sys/consio.h>
4129 #include <signal.h>
4130 #include <sys/fbio.h>],
4131 [struct mouse_info mouse;
4132 mouse.operation = MOUSE_MODE;
4133 mouse.operation = MOUSE_SHOW;
4134 mouse.u.mode.mode = 0;
4135 mouse.u.mode.signal = SIGUSR2;],
4136 [vi_cv_have_sysmouse=yes],
4137 [vi_cv_have_sysmouse=no])
4138 )
4139 if test $vi_cv_have_sysmouse = yes; then
4140 AC_DEFINE(HAVE_SYSMOUSE)
4141 fi
4142else
4143 AC_MSG_RESULT(yes)
4144fi
4145
Bram Moolenaarf05da212009-11-17 16:13:15 +00004146dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
4147AC_MSG_CHECKING(for FD_CLOEXEC)
4148AC_TRY_COMPILE(
4149[#if HAVE_FCNTL_H
4150# include <fcntl.h>
4151#endif],
4152[ int flag = FD_CLOEXEC;],
4153 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
4154 AC_MSG_RESULT(not usable))
4155
Bram Moolenaar071d4272004-06-13 20:20:40 +00004156dnl rename needs to be checked separately to work on Nextstep with cc
4157AC_MSG_CHECKING(for rename)
4158AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
4159 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
4160 AC_MSG_RESULT(no))
4161
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004162dnl check for dirfd()
4163AC_MSG_CHECKING(for dirfd)
Bram Moolenaar9d8bfae2020-09-02 21:21:35 +02004164AC_TRY_LINK(
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004165[#include <sys/types.h>
4166#include <dirent.h>],
4167[DIR * dir=opendir("dirname"); dirfd(dir);],
4168AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DIRFD), AC_MSG_RESULT(not usable))
4169
4170dnl check for flock()
4171AC_MSG_CHECKING(for flock)
Bram Moolenaar9d8bfae2020-09-02 21:21:35 +02004172AC_TRY_LINK(
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004173[#include <sys/file.h>],
4174[flock(10, LOCK_SH);],
4175AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOCK), AC_MSG_RESULT(not usable))
4176
Bram Moolenaar071d4272004-06-13 20:20:40 +00004177dnl sysctl() may exist but not the arguments we use
4178AC_MSG_CHECKING(for sysctl)
4179AC_TRY_COMPILE(
4180[#include <sys/types.h>
4181#include <sys/sysctl.h>],
4182[ int mib[2], r;
4183 size_t len;
4184
4185 mib[0] = CTL_HW;
4186 mib[1] = HW_USERMEM;
4187 len = sizeof(r);
4188 (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
4189 ],
4190 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL),
4191 AC_MSG_RESULT(not usable))
4192
Bram Moolenaare2982d62021-10-06 11:27:21 +01004193dnl sysinfo() may exist but not be Linux compatible.
4194dnl On some FreeBSD systems it may depend on libsysinfo, use TRY_LINK
Bram Moolenaar071d4272004-06-13 20:20:40 +00004195AC_MSG_CHECKING(for sysinfo)
Bram Moolenaare2982d62021-10-06 11:27:21 +01004196AC_TRY_LINK(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004197[#include <sys/types.h>
4198#include <sys/sysinfo.h>],
4199[ struct sysinfo sinfo;
4200 int t;
4201
4202 (void)sysinfo(&sinfo);
4203 t = sinfo.totalram;
4204 ],
4205 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
4206 AC_MSG_RESULT(not usable))
4207
Bram Moolenaar914572a2007-05-01 11:37:47 +00004208dnl struct sysinfo may have the mem_unit field or not
4209AC_MSG_CHECKING(for sysinfo.mem_unit)
4210AC_TRY_COMPILE(
4211[#include <sys/types.h>
4212#include <sys/sysinfo.h>],
4213[ struct sysinfo sinfo;
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02004214 sinfo.mem_unit = 1;
Bram Moolenaar914572a2007-05-01 11:37:47 +00004215 ],
4216 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_MEM_UNIT),
4217 AC_MSG_RESULT(no))
4218
Bram Moolenaarf52f0602021-03-10 21:26:37 +01004219dnl struct sysinfo may have the uptime field or not
4220AC_MSG_CHECKING(for sysinfo.uptime)
4221AC_TRY_COMPILE(
4222[#include <sys/types.h>
4223#include <sys/sysinfo.h>],
4224[ struct sysinfo sinfo;
4225 long ut;
4226
4227 (void)sysinfo(&sinfo);
4228 ut = sinfo.uptime;
4229 ],
4230 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_UPTIME),
4231 AC_MSG_RESULT(no))
4232
Bram Moolenaar071d4272004-06-13 20:20:40 +00004233dnl sysconf() may exist but not support what we want to use
4234AC_MSG_CHECKING(for sysconf)
4235AC_TRY_COMPILE(
4236[#include <unistd.h>],
4237[ (void)sysconf(_SC_PAGESIZE);
4238 (void)sysconf(_SC_PHYS_PAGES);
4239 ],
4240 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
4241 AC_MSG_RESULT(not usable))
4242
Bram Moolenaar0e62a672021-02-25 17:17:56 +01004243dnl check if we have _SC_SIGSTKSZ via sysconf()
4244AC_MSG_CHECKING(for _SC_SIGSTKSZ via sysconf())
4245AC_TRY_COMPILE(
4246[#include <unistd.h>],
4247[ (void)sysconf(_SC_SIGSTKSZ);
4248 ],
4249 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF_SIGSTKSZ),
4250 AC_MSG_RESULT(not usable))
4251
Bram Moolenaar914703b2010-05-31 21:59:46 +02004252AC_CHECK_SIZEOF([int])
4253AC_CHECK_SIZEOF([long])
4254AC_CHECK_SIZEOF([time_t])
4255AC_CHECK_SIZEOF([off_t])
Bram Moolenaar644fdff2010-05-30 13:26:21 +02004256
Bram Moolenaara2aa31a2014-02-23 22:52:40 +01004257dnl Use different names to avoid clashing with other header files.
4258AC_DEFINE_UNQUOTED(VIM_SIZEOF_INT, [$ac_cv_sizeof_int])
4259AC_DEFINE_UNQUOTED(VIM_SIZEOF_LONG, [$ac_cv_sizeof_long])
4260
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004261dnl Make sure that uint32_t is really 32 bits unsigned.
4262AC_MSG_CHECKING([uint32_t is 32 bits])
4263AC_TRY_RUN([
4264#ifdef HAVE_STDINT_H
4265# include <stdint.h>
4266#endif
4267#ifdef HAVE_INTTYPES_H
4268# include <inttypes.h>
4269#endif
4270main() {
4271 uint32_t nr1 = (uint32_t)-1;
4272 uint32_t nr2 = (uint32_t)0xffffffffUL;
Bram Moolenaar52897832020-07-02 22:50:37 +02004273 if (sizeof(uint32_t) != 4 || nr1 != 0xffffffffUL || nr2 + 1 != 0) return 1;
4274 return 0;
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004275}],
4276AC_MSG_RESULT(ok),
4277AC_MSG_ERROR([WRONG! uint32_t not defined correctly.]),
Bram Moolenaar323cb952011-12-14 19:22:34 +01004278AC_MSG_WARN([cannot check uint32_t when cross-compiling.]))
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004279
Bram Moolenaar446cb832008-06-24 21:56:24 +00004280dnl Check for memmove() before bcopy(), makes memmove() be used when both are
4281dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
4282
Bram Moolenaar071d4272004-06-13 20:20:40 +00004283[bcopy_test_prog='
Bram Moolenaar446cb832008-06-24 21:56:24 +00004284#include "confdefs.h"
4285#ifdef HAVE_STRING_H
4286# include <string.h>
4287#endif
4288#if STDC_HEADERS
4289# include <stdlib.h>
4290# include <stddef.h>
4291#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004292main() {
4293 char buf[10];
4294 strcpy(buf, "abcdefghi");
4295 mch_memmove(buf, buf + 2, 3);
4296 if (strncmp(buf, "ababcf", 6))
4297 exit(1);
4298 strcpy(buf, "abcdefghi");
4299 mch_memmove(buf + 2, buf, 3);
4300 if (strncmp(buf, "cdedef", 6))
4301 exit(1);
4302 exit(0); /* libc version works properly. */
4303}']
4304
Bram Moolenaar446cb832008-06-24 21:56:24 +00004305AC_CACHE_CHECK([whether memmove handles overlaps],[vim_cv_memmove_handles_overlap],
4306 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004307 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 +00004308 [
4309 vim_cv_memmove_handles_overlap=yes
4310 ],[
4311 vim_cv_memmove_handles_overlap=no
4312 ],[
4313 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memmove_handles_overlap')
4314 ])
4315 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00004316
Bram Moolenaar446cb832008-06-24 21:56:24 +00004317if test "x$vim_cv_memmove_handles_overlap" = "xyes" ; then
4318 AC_DEFINE(USEMEMMOVE)
4319else
4320 AC_CACHE_CHECK([whether bcopy handles overlaps],[vim_cv_bcopy_handles_overlap],
4321 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004322 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 +00004323 [
4324 vim_cv_bcopy_handles_overlap=yes
4325 ],[
4326 vim_cv_bcopy_handles_overlap=no
4327 ],[
4328 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_bcopy_handles_overlap')
4329 ])
4330 ])
4331
4332 if test "x$vim_cv_bcopy_handles_overlap" = "xyes" ; then
4333 AC_DEFINE(USEBCOPY)
4334 else
4335 AC_CACHE_CHECK([whether memcpy handles overlaps],[vim_cv_memcpy_handles_overlap],
4336 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004337 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 +00004338 [
4339 vim_cv_memcpy_handles_overlap=yes
4340 ],[
4341 vim_cv_memcpy_handles_overlap=no
4342 ],[
4343 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memcpy_handles_overlap')
4344 ])
4345 ])
4346
4347 if test "x$vim_cv_memcpy_handles_overlap" = "xyes" ; then
4348 AC_DEFINE(USEMEMCPY)
4349 fi
4350 fi
4351fi
4352
Bram Moolenaar071d4272004-06-13 20:20:40 +00004353
4354dnl Check for multibyte locale functions
4355dnl Find out if _Xsetlocale() is supported by libX11.
4356dnl Check if X_LOCALE should be defined.
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004357if test "x$with_x" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004358 cflags_save=$CFLAGS
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004359 libs_save=$LIBS
4360 LIBS="$LIBS $X_LIBS $GUI_LIB_LOC $GUI_X_LIBS $X_PRE_LIBS $X_LIB $X_EXTRA_LIBS"
4361 CFLAGS="$CFLAGS $X_CFLAGS"
4362
4363 AC_MSG_CHECKING(whether X_LOCALE needed)
4364 AC_TRY_COMPILE([#include <X11/Xlocale.h>],,
4365 AC_TRY_LINK_FUNC([_Xsetlocale], [AC_MSG_RESULT(yes)
4366 AC_DEFINE(X_LOCALE)], AC_MSG_RESULT(no)),
4367 AC_MSG_RESULT(no))
4368
4369 AC_MSG_CHECKING(whether Xutf8SetWMProperties() can be used)
4370 AC_TRY_LINK_FUNC([Xutf8SetWMProperties], [AC_MSG_RESULT(yes)
4371 AC_DEFINE(HAVE_XUTF8SETWMPROPERTIES)], AC_MSG_RESULT(no))
4372
Bram Moolenaar071d4272004-06-13 20:20:40 +00004373 CFLAGS=$cflags_save
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004374 LIBS=$libs_save
Bram Moolenaar071d4272004-06-13 20:20:40 +00004375fi
4376
4377dnl Link with xpg4, it is said to make Korean locale working
4378AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,)
4379
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004380dnl Check how we can run ctags. Default to "ctags" when nothing works.
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02004381dnl Use --version to detect Exuberant ctags (preferred)
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004382dnl Add --fields=+S to get function signatures for omni completion.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004383dnl -t for typedefs (many ctags have this)
4384dnl -s for static functions (Elvis ctags only?)
4385dnl -v for variables. Dangerous, most ctags take this for 'vgrind style'.
4386dnl -i+m to test for older Exuberant ctags
4387AC_MSG_CHECKING(how to create tags)
4388test -f tags && mv tags tags.save
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004389if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004390 TAGPRG="ctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004391elif (eval exctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004392 TAGPRG="exctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004393elif (eval exuberant-ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004394 TAGPRG="exuberant-ctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004395else
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004396 TAGPRG="ctags"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004397 (eval etags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags"
4398 (eval etags -c /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags -c"
4399 (eval ctags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags"
4400 (eval ctags -t /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -t"
4401 (eval ctags -ts /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -ts"
4402 (eval ctags -tvs /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -tvs"
4403 (eval ctags -i+m /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -i+m"
4404fi
4405test -f tags.save && mv tags.save tags
4406AC_MSG_RESULT($TAGPRG) AC_SUBST(TAGPRG)
4407
4408dnl Check how we can run man with a section number
4409AC_MSG_CHECKING(how to run man with a section nr)
4410MANDEF="man"
Bram Moolenaar8b131502008-02-13 09:28:19 +00004411(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 +00004412AC_MSG_RESULT($MANDEF)
4413if test "$MANDEF" = "man -s"; then
4414 AC_DEFINE(USEMAN_S)
4415fi
4416
4417dnl Check if gettext() is working and if it needs -lintl
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004418dnl We take care to base this on an empty LIBS: on some systems libelf would be
4419dnl in LIBS and implicitly take along libintl. The final LIBS would then not
4420dnl contain libintl, and the link step would fail due to -Wl,--as-needed.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004421AC_MSG_CHECKING(--disable-nls argument)
4422AC_ARG_ENABLE(nls,
4423 [ --disable-nls Don't support NLS (gettext()).], ,
4424 [enable_nls="yes"])
4425
4426if test "$enable_nls" = "yes"; then
4427 AC_MSG_RESULT(no)
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00004428
4429 INSTALL_LANGS=install-languages
4430 AC_SUBST(INSTALL_LANGS)
4431 INSTALL_TOOL_LANGS=install-tool-languages
4432 AC_SUBST(INSTALL_TOOL_LANGS)
4433
Bram Moolenaar071d4272004-06-13 20:20:40 +00004434 AC_CHECK_PROG(MSGFMT, msgfmt, msgfmt, )
4435 AC_MSG_CHECKING([for NLS])
4436 if test -f po/Makefile; then
4437 have_gettext="no"
4438 if test -n "$MSGFMT"; then
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004439 olibs=$LIBS
4440 LIBS=""
Bram Moolenaar071d4272004-06-13 20:20:40 +00004441 AC_TRY_LINK(
4442 [#include <libintl.h>],
4443 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004444 AC_MSG_RESULT([gettext() works]); have_gettext="yes"; LIBS=$olibs,
4445 LIBS="-lintl"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004446 AC_TRY_LINK(
4447 [#include <libintl.h>],
4448 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004449 AC_MSG_RESULT([gettext() works with -lintl]); have_gettext="yes";
4450 LIBS="$olibs -lintl",
Bram Moolenaar071d4272004-06-13 20:20:40 +00004451 AC_MSG_RESULT([gettext() doesn't work]);
4452 LIBS=$olibs))
4453 else
4454 AC_MSG_RESULT([msgfmt not found - disabled]);
4455 fi
Bram Moolenaar278eb582014-07-30 13:22:52 +02004456 if test $have_gettext = "yes" -a "x$features" != "xtiny" -a "x$features" != "xsmall"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004457 AC_DEFINE(HAVE_GETTEXT)
4458 MAKEMO=yes
4459 AC_SUBST(MAKEMO)
4460 dnl this was added in GNU gettext 0.10.36
4461 AC_CHECK_FUNCS(bind_textdomain_codeset)
4462 dnl _nl_msg_cat_cntr is required for GNU gettext
4463 AC_MSG_CHECKING([for _nl_msg_cat_cntr])
4464 AC_TRY_LINK(
4465 [#include <libintl.h>
4466 extern int _nl_msg_cat_cntr;],
4467 [++_nl_msg_cat_cntr;],
4468 AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_NL_MSG_CAT_CNTR),
4469 AC_MSG_RESULT([no]))
Bram Moolenaar26096cc2019-04-11 15:25:40 +02004470 AC_MSG_CHECKING([if msgfmt supports --desktop])
4471 MSGFMT_DESKTOP=
4472 if "$MSGFMT" --help | grep -e '--desktop' >/dev/null; then
Bram Moolenaar62a88f42019-06-07 20:44:40 +02004473 if "$MSGFMT" --version | grep '0.19.[[3-7]]$' >/dev/null; then
4474 dnl GNU gettext 0.19.7's --desktop is broken. We assume back to
4475 dnl 0.19.3 is also broken.
4476 AC_MSG_RESULT([broken])
4477 else
4478 AC_MSG_RESULT([yes])
4479 MSGFMT_DESKTOP="gvim.desktop vim.desktop"
4480 fi
Bram Moolenaar26096cc2019-04-11 15:25:40 +02004481 else
4482 AC_MSG_RESULT([no])
4483 fi
4484 AC_SUBST(MSGFMT_DESKTOP)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004485 fi
4486 else
4487 AC_MSG_RESULT([no "po/Makefile" - disabled]);
4488 fi
4489else
4490 AC_MSG_RESULT(yes)
4491fi
4492
4493dnl Check for dynamic linking loader
4494AC_CHECK_HEADER(dlfcn.h, DLL=dlfcn.h, [AC_CHECK_HEADER(dl.h, DLL=dl.h)])
4495if test x${DLL} = xdlfcn.h; then
4496 AC_DEFINE(HAVE_DLFCN_H, 1, [ Define if we have dlfcn.h. ])
4497 AC_MSG_CHECKING([for dlopen()])
4498 AC_TRY_LINK(,[
4499 extern void* dlopen();
4500 dlopen();
4501 ],
4502 AC_MSG_RESULT(yes);
4503 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4504 AC_MSG_RESULT(no);
4505 AC_MSG_CHECKING([for dlopen() in -ldl])
4506 olibs=$LIBS
4507 LIBS="$LIBS -ldl"
4508 AC_TRY_LINK(,[
4509 extern void* dlopen();
4510 dlopen();
4511 ],
4512 AC_MSG_RESULT(yes);
4513 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4514 AC_MSG_RESULT(no);
4515 LIBS=$olibs))
4516 dnl ReliantUNIX has dlopen() in libc but everything else in libdl
4517 dnl ick :-)
4518 AC_MSG_CHECKING([for dlsym()])
4519 AC_TRY_LINK(,[
4520 extern void* dlsym();
4521 dlsym();
4522 ],
4523 AC_MSG_RESULT(yes);
4524 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4525 AC_MSG_RESULT(no);
4526 AC_MSG_CHECKING([for dlsym() in -ldl])
4527 olibs=$LIBS
4528 LIBS="$LIBS -ldl"
4529 AC_TRY_LINK(,[
4530 extern void* dlsym();
4531 dlsym();
4532 ],
4533 AC_MSG_RESULT(yes);
4534 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4535 AC_MSG_RESULT(no);
4536 LIBS=$olibs))
4537elif test x${DLL} = xdl.h; then
4538 AC_DEFINE(HAVE_DL_H, 1, [ Define if we have dl.h. ])
4539 AC_MSG_CHECKING([for shl_load()])
4540 AC_TRY_LINK(,[
4541 extern void* shl_load();
4542 shl_load();
4543 ],
4544 AC_MSG_RESULT(yes);
4545 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4546 AC_MSG_RESULT(no);
4547 AC_MSG_CHECKING([for shl_load() in -ldld])
4548 olibs=$LIBS
4549 LIBS="$LIBS -ldld"
4550 AC_TRY_LINK(,[
4551 extern void* shl_load();
4552 shl_load();
4553 ],
4554 AC_MSG_RESULT(yes);
4555 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4556 AC_MSG_RESULT(no);
4557 LIBS=$olibs))
4558fi
4559AC_CHECK_HEADERS(setjmp.h)
4560
Bram Moolenaard0573012017-10-28 21:11:06 +02004561if test "x$MACOS_X" = "xyes" -a -n "$PERL"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004562 dnl -ldl must come after DynaLoader.a
4563 if echo $LIBS | grep -e '-ldl' >/dev/null; then
4564 LIBS=`echo $LIBS | sed s/-ldl//`
4565 PERL_LIBS="$PERL_LIBS -ldl"
4566 fi
4567fi
4568
Bram Moolenaard0573012017-10-28 21:11:06 +02004569if test "$MACOS_X" = "yes"; then
4570 AC_MSG_CHECKING([whether we need macOS frameworks])
Bram Moolenaar097148e2020-08-11 21:58:20 +02004571 if test "$MACOS_X_DARWIN" = "yes"; then
Bram Moolenaard0573012017-10-28 21:11:06 +02004572 if test "$features" = "tiny"; then
4573 dnl Since no FEAT_CLIPBOARD, no longer need for os_macosx.m.
4574 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_macosx.m++'`
4575 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_macosx.o++'`
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01004576 AC_MSG_RESULT([yes, we need CoreServices])
4577 LIBS="$LIBS -framework CoreServices"
Bram Moolenaard0573012017-10-28 21:11:06 +02004578 else
4579 AC_MSG_RESULT([yes, we need AppKit])
4580 LIBS="$LIBS -framework AppKit"
Bram Moolenaard0573012017-10-28 21:11:06 +02004581 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004582 else
Bram Moolenaard0573012017-10-28 21:11:06 +02004583 AC_MSG_RESULT([no])
Bram Moolenaar3437b912013-07-03 19:52:53 +02004584 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004585fi
4586
Bram Moolenaar3ae5fc92021-09-06 18:57:30 +02004587dnl On some systems REENTRANT needs to be defined. It should not hurt to use
4588dnl it everywhere.
4589if `echo "$CFLAGS" | grep -v D_REENTRANT >/dev/null`; then
4590 CFLAGS="$CFLAGS -D_REENTRANT"
4591fi
4592
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004593dnl gcc 3.1 changed the meaning of -MM. The only solution appears to be to
4594dnl use "-isystem" instead of "-I" for all non-Vim include dirs.
4595dnl But only when making dependencies, cproto and lint don't take "-isystem".
Bram Moolenaar32466aa2006-02-24 23:53:04 +00004596dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
4597dnl the number before the version number.
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004598DEPEND_CFLAGS_FILTER=
4599if test "$GCC" = yes; then
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004600 AC_MSG_CHECKING(for GCC 3 or later)
Bram Moolenaar348808f2020-02-07 20:50:07 +01004601 gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]][[0-9]]*\)\..*$/\1/g'`
Bram Moolenaarf740b292006-02-16 22:11:02 +00004602 if test "$gccmajor" -gt "2"; then
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004603 DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004604 AC_MSG_RESULT(yes)
4605 else
4606 AC_MSG_RESULT(no)
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004607 fi
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004608 dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
4609 dnl declared as char x[1] but actually longer. Introduced in gcc 4.0.
Bram Moolenaar56d1db32009-12-16 16:14:51 +00004610 dnl Also remove duplicate _FORTIFY_SOURCE arguments.
Bram Moolenaaraeabe052011-12-08 15:17:34 +01004611 dnl And undefine it first to avoid a warning.
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004612 AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
4613 if test "$gccmajor" -gt "3"; then
Bram Moolenaar26f20132021-04-03 17:33:52 +02004614 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/'`
4615 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 +00004616 AC_MSG_RESULT(yes)
4617 else
4618 AC_MSG_RESULT(no)
4619 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +00004620fi
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004621AC_SUBST(DEPEND_CFLAGS_FILTER)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004622
Bram Moolenaarec0557f2018-01-31 14:41:37 +01004623dnl On some systems AC_SYS_LARGEFILE determines that -D_FILE_OFFSET_BITS=64
4624dnl isn't required, but the CFLAGS for some of the libraries we're using
4625dnl include the define. Since the define changes the size of some datatypes
4626dnl (e.g. ino_t and off_t), all of Vim's modules must be compiled with a
4627dnl consistent value. It's therefore safest to force the use of the define
4628dnl if it's present in any of the *_CFLAGS variables.
4629AC_MSG_CHECKING(whether we need to force -D_FILE_OFFSET_BITS=64)
Bram Moolenaar9ce42132018-04-11 22:19:36 +02004630if 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 +01004631 AC_MSG_RESULT(yes)
4632 AC_DEFINE(_FILE_OFFSET_BITS, 64)
4633else
4634 AC_MSG_RESULT(no)
4635fi
4636
Bram Moolenaar6cd42db2020-12-04 18:09:54 +01004637dnl $LDFLAGS is passed to glibtool in libvterm, it doesn't like a space
4638dnl between "-L" and the path that follows.
4639LDFLAGS=`echo "$LDFLAGS" | sed -e 's/-L /-L/g'`
4640
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004641dnl link.sh tries to avoid overlinking in a hackish way.
4642dnl At least GNU ld supports --as-needed which provides the same functionality
4643dnl at linker level. Let's use it.
4644AC_MSG_CHECKING(linker --as-needed support)
4645LINK_AS_NEEDED=
4646# Check if linker supports --as-needed and --no-as-needed options
4647if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
Natanael Copa761ead42021-05-15 14:25:37 +02004648 if ! echo "$LDFLAGS" | grep -q -- '-Wl,[[^[:space:]]]*--as-needed'; then
4649 LDFLAGS="$LDFLAGS -Wl,--as-needed"
4650 fi
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004651 LINK_AS_NEEDED=yes
4652fi
4653if test "$LINK_AS_NEEDED" = yes; then
4654 AC_MSG_RESULT(yes)
4655else
4656 AC_MSG_RESULT(no)
4657fi
4658AC_SUBST(LINK_AS_NEEDED)
4659
Bram Moolenaar77c19352012-06-13 19:19:41 +02004660# IBM z/OS reset CFLAGS for config.mk
4661if test "$zOSUnix" = "yes"; then
4662 CFLAGS="-D_ALL_SOURCE -Wc,float\(ieee\),dll"
4663fi
4664
Bram Moolenaar071d4272004-06-13 20:20:40 +00004665dnl write output files
4666AC_OUTPUT(auto/config.mk:config.mk.in)
4667
4668dnl vim: set sw=2 tw=78 fo+=l: