blob: b5f217ca1f92a93523fdbc3b938b60a2c52ea5fc [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 Moolenaar0ba04292010-07-14 23:23:17 +0200570dnl Check for Lua feature.
571AC_MSG_CHECKING(--enable-luainterp argument)
572AC_ARG_ENABLE(luainterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200573 [ --enable-luainterp[=OPTS] Include Lua interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200574 [enable_luainterp="no"])
575AC_MSG_RESULT($enable_luainterp)
576
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200577if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +0100578 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
579 AC_MSG_ERROR([cannot use Lua with tiny or small features])
580 fi
581
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200582 dnl -- find the lua executable
583 AC_SUBST(vi_cv_path_lua)
584
585 AC_MSG_CHECKING(--with-lua-prefix argument)
586 AC_ARG_WITH(lua_prefix,
587 [ --with-lua-prefix=PFX Prefix where Lua is installed.],
588 with_lua_prefix="$withval"; AC_MSG_RESULT($with_lua_prefix),
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200589 with_lua_prefix="";AC_MSG_RESULT(no))
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200590
591 if test "X$with_lua_prefix" != "X"; then
592 vi_cv_path_lua_pfx="$with_lua_prefix"
593 else
594 AC_MSG_CHECKING(LUA_PREFIX environment var)
595 if test "X$LUA_PREFIX" != "X"; then
596 AC_MSG_RESULT("$LUA_PREFIX")
597 vi_cv_path_lua_pfx="$LUA_PREFIX"
598 else
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200599 AC_MSG_RESULT([not set, default to /usr])
600 vi_cv_path_lua_pfx="/usr"
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200601 fi
602 fi
603
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200604 AC_MSG_CHECKING(--with-luajit)
605 AC_ARG_WITH(luajit,
606 [ --with-luajit Link with LuaJIT instead of Lua.],
607 [vi_cv_with_luajit="$withval"],
608 [vi_cv_with_luajit="no"])
609 AC_MSG_RESULT($vi_cv_with_luajit)
610
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200611 LUA_INC=
612 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200613 if test "x$vi_cv_with_luajit" != "xno"; then
614 dnl -- try to find LuaJIT executable
615 AC_PATH_PROG(vi_cv_path_luajit, luajit)
616 if test "X$vi_cv_path_luajit" != "X"; then
617 dnl -- find LuaJIT version
618 AC_CACHE_CHECK(LuaJIT version, vi_cv_version_luajit,
Bram Moolenaar49b10272013-11-21 12:17:51 +0100619 [ 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 +0200620 AC_CACHE_CHECK(Lua version of LuaJIT, vi_cv_version_lua_luajit,
621 [ vi_cv_version_lua_luajit=`${vi_cv_path_luajit} -e "print(_VERSION)" | sed 's/.* //'` ])
622 vi_cv_path_lua="$vi_cv_path_luajit"
623 vi_cv_version_lua="$vi_cv_version_lua_luajit"
624 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200625 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200626 dnl -- try to find Lua executable
627 AC_PATH_PROG(vi_cv_path_plain_lua, lua)
628 if test "X$vi_cv_path_plain_lua" != "X"; then
629 dnl -- find Lua version
630 AC_CACHE_CHECK(Lua version, vi_cv_version_plain_lua,
631 [ vi_cv_version_plain_lua=`${vi_cv_path_plain_lua} -e "print(_VERSION)" | sed 's/.* //'` ])
632 fi
633 vi_cv_path_lua="$vi_cv_path_plain_lua"
634 vi_cv_version_lua="$vi_cv_version_plain_lua"
635 fi
636 if test "x$vi_cv_with_luajit" != "xno" && test "X$vi_cv_version_luajit" != "X"; then
637 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 +0100638 if test -f "$vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200639 AC_MSG_RESULT(yes)
640 LUA_INC=/luajit-$vi_cv_version_luajit
641 fi
642 fi
643 if test "X$LUA_INC" = "X"; then
644 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)
Bram Moolenaar49222be2015-12-11 18:11:30 +0100645 if test -f "$vi_cv_path_lua_pfx/include/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200646 AC_MSG_RESULT(yes)
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200647 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200648 AC_MSG_RESULT(no)
649 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 +0100650 if test -f "$vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200651 AC_MSG_RESULT(yes)
652 LUA_INC=/lua$vi_cv_version_lua
653 else
654 AC_MSG_RESULT(no)
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200655
656 # Detect moonjit:
657 # https://groups.google.com/forum/#!topic/vim_use/O0vek60WuTk
658 lua_suf=/moonjit-2.3
659 inc_path="$vi_cv_path_lua_pfx/include"
Bram Moolenaarad4dc832020-04-20 16:21:53 +0200660 for dir in "$inc_path"/moonjit-[[0-9]]* ; do
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200661 if test -d "$dir" ; then
Bram Moolenaara79a8942020-12-17 20:50:25 +0100662 lua_suf=`basename "$dir"`
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200663 lua_suf="/$lua_suf"
664 break
665 fi
666 done
667 AC_MSG_CHECKING(if lua.h can be found in $inc_path$lua_suf)
668 if test -f "$inc_path$lua_suf/lua.h"; then
669 AC_MSG_RESULT(yes)
670 LUA_INC=$lua_suf
671 else
672 AC_MSG_RESULT(no)
673 vi_cv_path_lua_pfx=
674 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200675 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200676 fi
677 fi
678 fi
679
680 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200681 if test "x$vi_cv_with_luajit" != "xno"; then
682 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
683 if test "X$multiarch" != "X"; then
684 lib_multiarch="lib/${multiarch}"
685 else
686 lib_multiarch="lib"
687 fi
688 if test "X$vi_cv_version_lua" = "X"; then
689 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit"
690 else
691 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit-$vi_cv_version_lua"
692 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200693 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200694 if test "X$LUA_INC" != "X"; then
695 dnl Test alternate location using version
696 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua$vi_cv_version_lua"
697 else
698 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua"
699 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200700 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200701 if test "$enable_luainterp" = "dynamic"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200702 lua_ok="yes"
703 else
704 AC_MSG_CHECKING([if link with ${LUA_LIBS} is sane])
705 libs_save=$LIBS
706 LIBS="$LIBS $LUA_LIBS"
707 AC_TRY_LINK(,[ ],
708 AC_MSG_RESULT(yes); lua_ok="yes",
709 AC_MSG_RESULT(no); lua_ok="no"; LUA_LIBS="")
710 LIBS=$libs_save
711 fi
712 if test "x$lua_ok" = "xyes"; then
713 LUA_CFLAGS="-I${vi_cv_path_lua_pfx}/include${LUA_INC}"
714 LUA_SRC="if_lua.c"
715 LUA_OBJ="objects/if_lua.o"
716 LUA_PRO="if_lua.pro"
717 AC_DEFINE(FEAT_LUA)
718 fi
719 if test "$enable_luainterp" = "dynamic"; then
720 if test "x$vi_cv_with_luajit" != "xno"; then
721 luajit="jit"
722 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200723 if test -f "${vi_cv_path_lua_pfx}/bin/cyglua-${vi_cv_version_lua}.dll"; then
724 vi_cv_dll_name_lua="cyglua-${vi_cv_version_lua}.dll"
725 else
Bram Moolenaard0573012017-10-28 21:11:06 +0200726 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200727 ext="dylib"
728 indexes=""
729 else
730 ext="so"
731 indexes=".0 .1 .2 .3 .4 .5 .6 .7 .8 .9"
732 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
733 if test "X$multiarch" != "X"; then
734 lib_multiarch="lib/${multiarch}"
735 fi
Bram Moolenaar768baac2013-04-15 14:44:57 +0200736 fi
737 dnl Determine the sover for the current version, but fallback to
738 dnl liblua${vi_cv_version_lua}.so if no sover-versioned file is found.
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200739 AC_MSG_CHECKING(if liblua${luajit}*.${ext}* can be found in $vi_cv_path_lua_pfx)
Bram Moolenaar768baac2013-04-15 14:44:57 +0200740 for subdir in "${lib_multiarch}" lib64 lib; do
741 if test -z "$subdir"; then
742 continue
743 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200744 for sover in "${vi_cv_version_lua}.${ext}" "-${vi_cv_version_lua}.${ext}" \
745 ".${vi_cv_version_lua}.${ext}" ".${ext}.${vi_cv_version_lua}"; do
746 for i in $indexes ""; do
747 if test -f "${vi_cv_path_lua_pfx}/${subdir}/liblua${luajit}${sover}$i"; then
Bram Moolenaar768baac2013-04-15 14:44:57 +0200748 sover2="$i"
749 break 3
750 fi
751 done
Bram Moolenaar07e1da62013-02-06 19:49:43 +0100752 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200753 sover=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200754 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200755 if test "X$sover" = "X"; then
756 AC_MSG_RESULT(no)
757 lua_ok="no"
758 vi_cv_dll_name_lua="liblua${luajit}.${ext}"
759 else
760 AC_MSG_RESULT(yes)
761 lua_ok="yes"
762 vi_cv_dll_name_lua="liblua${luajit}${sover}$sover2"
763 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200764 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200765 AC_DEFINE(DYNAMIC_LUA)
766 LUA_LIBS=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200767 LUA_CFLAGS="-DDYNAMIC_LUA_DLL=\\\"${vi_cv_dll_name_lua}\\\" $LUA_CFLAGS"
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200768 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200769 if test "X$LUA_CFLAGS$LUA_LIBS" != "X" && \
Bram Moolenaard0573012017-10-28 21:11:06 +0200770 test "x$MACOS_X" = "xyes" && test "x$vi_cv_with_luajit" != "xno" && \
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000771 test "$vim_cv_uname_m_output" = "x86_64"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200772 dnl OSX/x64 requires these flags. See http://luajit.org/install.html
773 LUA_LIBS="-pagezero_size 10000 -image_base 100000000 $LUA_LIBS"
774 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200775 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200776 if test "$fail_if_missing" = "yes" -a "$lua_ok" != "yes"; then
Bram Moolenaarf788a062011-12-14 20:51:25 +0100777 AC_MSG_ERROR([could not configure lua])
778 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200779 AC_SUBST(LUA_SRC)
780 AC_SUBST(LUA_OBJ)
781 AC_SUBST(LUA_PRO)
782 AC_SUBST(LUA_LIBS)
783 AC_SUBST(LUA_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +0000784 AC_SUBST(LUA_CFLAGS_EXTRA)
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200785fi
786
787
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000788dnl Check for MzScheme feature.
789AC_MSG_CHECKING(--enable-mzschemeinterp argument)
790AC_ARG_ENABLE(mzschemeinterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200791 [ --enable-mzschemeinterp Include MzScheme interpreter.], ,
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000792 [enable_mzschemeinterp="no"])
793AC_MSG_RESULT($enable_mzschemeinterp)
794
795if test "$enable_mzschemeinterp" = "yes"; then
796 dnl -- find the mzscheme executable
797 AC_SUBST(vi_cv_path_mzscheme)
798
799 AC_MSG_CHECKING(--with-plthome argument)
800 AC_ARG_WITH(plthome,
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000801 [ --with-plthome=PLTHOME Use PLTHOME.],
802 with_plthome="$withval"; AC_MSG_RESULT($with_plthome),
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000803 with_plthome="";AC_MSG_RESULT("no"))
804
805 if test "X$with_plthome" != "X"; then
806 vi_cv_path_mzscheme_pfx="$with_plthome"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100807 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000808 else
809 AC_MSG_CHECKING(PLTHOME environment var)
810 if test "X$PLTHOME" != "X"; then
811 AC_MSG_RESULT("$PLTHOME")
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000812 vi_cv_path_mzscheme_pfx="$PLTHOME"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100813 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000814 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000815 AC_MSG_RESULT(not set)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000816 dnl -- try to find MzScheme executable
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000817 AC_PATH_PROG(vi_cv_path_mzscheme, mzscheme)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000818
819 dnl resolve symbolic link, the executable is often elsewhere and there
820 dnl are no links for the include files.
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000821 if test "X$vi_cv_path_mzscheme" != "X"; then
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000822 lsout=`ls -l $vi_cv_path_mzscheme`
823 if echo "$lsout" | grep -e '->' >/dev/null 2>/dev/null; then
824 vi_cv_path_mzscheme=`echo "$lsout" | sed 's/.*-> \(.*\)/\1/'`
825 fi
826 fi
827
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000828 if test "X$vi_cv_path_mzscheme" != "X"; then
829 dnl -- find where MzScheme thinks it was installed
830 AC_CACHE_CHECK(MzScheme install prefix,vi_cv_path_mzscheme_pfx,
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000831 dnl different versions of MzScheme differ in command line processing
832 dnl use universal approach
833 echo "(display (simplify-path \
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000834 (build-path (call-with-values \
835 (lambda () (split-path (find-system-path (quote exec-file)))) \
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000836 (lambda (base name must-be-dir?) base)) (quote up))))" > mzdirs.scm
837 dnl Remove a trailing slash
838 [ vi_cv_path_mzscheme_pfx=`${vi_cv_path_mzscheme} -r mzdirs.scm | \
839 sed -e 's+/$++'` ])
840 rm -f mzdirs.scm
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000841 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000842 fi
843 fi
844
845 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100846 AC_MSG_CHECKING(for racket include directory)
847 SCHEME_INC=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-include-dir))) (when (path? p) (display p)))'`
848 if test "X$SCHEME_INC" != "X"; then
849 AC_MSG_RESULT(${SCHEME_INC})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000850 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100851 AC_MSG_RESULT(not found)
852 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include)
853 if test -f "$vi_cv_path_mzscheme_pfx/include/scheme.h"; then
854 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000855 AC_MSG_RESULT(yes)
Bram Moolenaard7afed32007-05-06 13:26:41 +0000856 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000857 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100858 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt)
859 if test -f "$vi_cv_path_mzscheme_pfx/include/plt/scheme.h"; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000860 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100861 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000862 else
863 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100864 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket)
865 if test -f "$vi_cv_path_mzscheme_pfx/include/racket/scheme.h"; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100866 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100867 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100868 else
869 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100870 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/)
871 if test -f /usr/include/plt/scheme.h; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100872 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100873 SCHEME_INC=/usr/include/plt
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100874 else
875 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100876 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/racket/)
877 if test -f /usr/include/racket/scheme.h; then
878 AC_MSG_RESULT(yes)
879 SCHEME_INC=/usr/include/racket
880 else
881 AC_MSG_RESULT(no)
882 vi_cv_path_mzscheme_pfx=
883 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100884 fi
885 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000886 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000887 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000888 fi
889 fi
890
891 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100892
893 AC_MSG_CHECKING(for racket lib directory)
894 SCHEME_LIB=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-lib-dir))) (when (path? p) (display p)))'`
895 if test "X$SCHEME_LIB" != "X"; then
896 AC_MSG_RESULT(${SCHEME_LIB})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000897 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100898 AC_MSG_RESULT(not found)
899 fi
900
901 for path in "${vi_cv_path_mzscheme_pfx}/lib" "${SCHEME_LIB}"; do
902 if test "X$path" != "X"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200903 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100904 MZSCHEME_LIBS="-framework Racket"
905 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
906 elif test -f "${path}/libmzscheme3m.a"; then
907 MZSCHEME_LIBS="${path}/libmzscheme3m.a"
908 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
909 elif test -f "${path}/libracket3m.a"; then
910 MZSCHEME_LIBS="${path}/libracket3m.a"
Bram Moolenaar588d2412020-10-03 14:24:19 +0200911 if test -f "${path}/librktio.a"; then
912 MZSCHEME_LIBS="${MZSCHEME_LIBS} ${path}/librktio.a"
913 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100914 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
915 elif test -f "${path}/libracket.a"; then
916 MZSCHEME_LIBS="${path}/libracket.a ${path}/libmzgc.a"
917 elif test -f "${path}/libmzscheme.a"; then
918 MZSCHEME_LIBS="${path}/libmzscheme.a ${path}/libmzgc.a"
919 else
920 dnl Using shared objects
921 if test -f "${path}/libmzscheme3m.so"; then
922 MZSCHEME_LIBS="-L${path} -lmzscheme3m"
923 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
924 elif test -f "${path}/libracket3m.so"; then
925 MZSCHEME_LIBS="-L${path} -lracket3m"
926 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
927 elif test -f "${path}/libracket.so"; then
928 MZSCHEME_LIBS="-L${path} -lracket -lmzgc"
929 else
930 dnl try next until last
931 if test "$path" != "$SCHEME_LIB"; then
932 continue
933 fi
934 MZSCHEME_LIBS="-L${path} -lmzscheme -lmzgc"
935 fi
936 if test "$GCC" = yes; then
937 dnl Make Vim remember the path to the library. For when it's not in
938 dnl $LD_LIBRARY_PATH.
939 MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${path}"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000940 elif test "$vim_cv_uname_output" = SunOS &&
941 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100942 MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${path}"
943 fi
944 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000945 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100946 if test "X$MZSCHEME_LIBS" != "X"; then
947 break
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +0000948 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100949 done
950
951 AC_MSG_CHECKING([if racket requires -pthread])
952 if test "X$SCHEME_LIB" != "X" && $FGREP -e -pthread "$SCHEME_LIB/buildinfo" >/dev/null ; then
953 AC_MSG_RESULT(yes)
954 MZSCHEME_LIBS="${MZSCHEME_LIBS} -pthread"
955 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -pthread"
956 else
957 AC_MSG_RESULT(no)
958 fi
959
960 AC_MSG_CHECKING(for racket config directory)
961 SCHEME_CONFIGDIR=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-config-dir))) (when (path? p) (display p)))'`
962 if test "X$SCHEME_CONFIGDIR" != "X"; then
963 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DMZSCHEME_CONFIGDIR='\"${SCHEME_CONFIGDIR}\"'"
964 AC_MSG_RESULT(${SCHEME_CONFIGDIR})
965 else
966 AC_MSG_RESULT(not found)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000967 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100968
969 AC_MSG_CHECKING(for racket collects directory)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100970 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))))'`
971 if test "X$SCHEME_COLLECTS" = "X"; then
972 if test -d "$vi_cv_path_mzscheme_pfx/lib/plt/collects"; then
973 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/plt/
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100974 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100975 if test -d "$vi_cv_path_mzscheme_pfx/lib/racket/collects"; then
976 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/racket/
Bram Moolenaar75676462013-01-30 14:55:42 +0100977 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100978 if test -d "$vi_cv_path_mzscheme_pfx/share/racket/collects"; then
979 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/
980 else
981 if test -d "$vi_cv_path_mzscheme_pfx/collects"; then
982 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/
983 fi
Bram Moolenaar75676462013-01-30 14:55:42 +0100984 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100985 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100986 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000987 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100988 if test "X$SCHEME_COLLECTS" != "X" ; then
989 AC_MSG_RESULT(${SCHEME_COLLECTS})
990 else
991 AC_MSG_RESULT(not found)
992 fi
993
994 AC_MSG_CHECKING(for mzscheme_base.c)
995 if test -f "${SCHEME_COLLECTS}collects/scheme/base.ss" ; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000996 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +0100997 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
998 MZSCHEME_MOD="++lib scheme/base"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100999 else
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001000 if test -f "${SCHEME_COLLECTS}collects/scheme/base.rkt" ; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +01001001 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +01001002 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
1003 MZSCHEME_MOD="++lib scheme/base"
1004 else
1005 if test -f "${SCHEME_COLLECTS}collects/racket/base.rkt" ; then
1006 MZSCHEME_EXTRA="mzscheme_base.c"
1007 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/raco ctool"
1008 MZSCHEME_MOD=""
1009 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +01001010 fi
1011 fi
1012 if test "X$MZSCHEME_EXTRA" != "X" ; then
1013 dnl need to generate bytecode for MzScheme base
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001014 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE"
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001015 AC_MSG_RESULT(needed)
1016 else
1017 AC_MSG_RESULT(not needed)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001018 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001019
Bram Moolenaar9e902192013-07-17 18:58:11 +02001020 dnl On Ubuntu this fixes "undefined reference to symbol 'ffi_type_void'".
1021 AC_CHECK_LIB(ffi, ffi_type_void, [MZSCHEME_LIBS="$MZSCHEME_LIBS -lffi"])
1022
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001023 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -I${SCHEME_INC} \
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001024 -DMZSCHEME_COLLECTS='\"${SCHEME_COLLECTS}collects\"'"
Bram Moolenaar9e902192013-07-17 18:58:11 +02001025
1026 dnl Test that we can compile a simple program with these CFLAGS and LIBS.
1027 AC_MSG_CHECKING([if compile and link flags for MzScheme are sane])
1028 cflags_save=$CFLAGS
1029 libs_save=$LIBS
1030 CFLAGS="$CFLAGS $MZSCHEME_CFLAGS"
1031 LIBS="$LIBS $MZSCHEME_LIBS"
1032 AC_TRY_LINK(,[ ],
1033 AC_MSG_RESULT(yes); mzs_ok=yes,
1034 AC_MSG_RESULT(no: MZSCHEME DISABLED); mzs_ok=no)
1035 CFLAGS=$cflags_save
1036 LIBS=$libs_save
1037 if test $mzs_ok = yes; then
1038 MZSCHEME_SRC="if_mzsch.c"
1039 MZSCHEME_OBJ="objects/if_mzsch.o"
1040 MZSCHEME_PRO="if_mzsch.pro"
1041 AC_DEFINE(FEAT_MZSCHEME)
1042 else
1043 MZSCHEME_CFLAGS=
1044 MZSCHEME_LIBS=
1045 MZSCHEME_EXTRA=
1046 MZSCHEME_MZC=
1047 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001048 fi
1049 AC_SUBST(MZSCHEME_SRC)
1050 AC_SUBST(MZSCHEME_OBJ)
1051 AC_SUBST(MZSCHEME_PRO)
1052 AC_SUBST(MZSCHEME_LIBS)
1053 AC_SUBST(MZSCHEME_CFLAGS)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001054 AC_SUBST(MZSCHEME_EXTRA)
1055 AC_SUBST(MZSCHEME_MZC)
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001056fi
1057
1058
Bram Moolenaar071d4272004-06-13 20:20:40 +00001059AC_MSG_CHECKING(--enable-perlinterp argument)
1060AC_ARG_ENABLE(perlinterp,
Bram Moolenaare06c1882010-07-21 22:05:20 +02001061 [ --enable-perlinterp[=OPTS] Include Perl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001062 [enable_perlinterp="no"])
1063AC_MSG_RESULT($enable_perlinterp)
Bram Moolenaare06c1882010-07-21 22:05:20 +02001064if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01001065 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1066 AC_MSG_ERROR([cannot use Perl with tiny or small features])
1067 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001068 AC_SUBST(vi_cv_path_perl)
1069 AC_PATH_PROG(vi_cv_path_perl, perl)
1070 if test "X$vi_cv_path_perl" != "X"; then
1071 AC_MSG_CHECKING(Perl version)
1072 if $vi_cv_path_perl -e 'require 5.003_01' >/dev/null 2>/dev/null; then
1073 eval `$vi_cv_path_perl -V:usethreads`
Bram Moolenaare06c1882010-07-21 22:05:20 +02001074 eval `$vi_cv_path_perl -V:libperl`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001075 if test "X$usethreads" = "XUNKNOWN" -o "X$usethreads" = "Xundef"; then
1076 badthreads=no
1077 else
1078 if $vi_cv_path_perl -e 'require 5.6.0' >/dev/null 2>/dev/null; then
1079 eval `$vi_cv_path_perl -V:use5005threads`
1080 if test "X$use5005threads" = "XUNKNOWN" -o "X$use5005threads" = "Xundef"; then
1081 badthreads=no
1082 else
1083 badthreads=yes
1084 AC_MSG_RESULT(>>> Perl > 5.6 with 5.5 threads cannot be used <<<)
1085 fi
1086 else
1087 badthreads=yes
1088 AC_MSG_RESULT(>>> Perl 5.5 with threads cannot be used <<<)
1089 fi
1090 fi
1091 if test $badthreads = no; then
1092 AC_MSG_RESULT(OK)
1093 eval `$vi_cv_path_perl -V:shrpenv`
1094 if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04
1095 shrpenv=""
1096 fi
1097 vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlibexp}'`
1098 AC_SUBST(vi_cv_perllib)
Bram Moolenaard5f62b12014-08-17 17:05:44 +02001099 vi_cv_perl_extutils=unknown_perl_extutils_path
1100 for extutils_rel_path in ExtUtils vendor_perl/ExtUtils; do
1101 xsubpp_path="$vi_cv_perllib/$extutils_rel_path/xsubpp"
1102 if test -f "$xsubpp_path"; then
1103 vi_cv_perl_xsubpp="$xsubpp_path"
1104 fi
1105 done
1106 AC_SUBST(vi_cv_perl_xsubpp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001107 dnl Remove "-fno-something", it breaks using cproto.
Bram Moolenaar280a8682015-06-21 13:41:08 +02001108 dnl Remove "-fdebug-prefix-map", it isn't supported by clang.
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001109 dnl Remove "FORTIFY_SOURCE", it will be defined twice.
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001110 dnl remove -pipe and -Wxxx, it confuses cproto
Bram Moolenaar071d4272004-06-13 20:20:40 +00001111 perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001112 -e 'ccflags;perl_inc;print"\n"' | sed -e 's/-fno[[^ ]]*//' \
1113 -e 's/-fdebug-prefix-map[[^ ]]*//g' \
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001114 -e 's/-pipe //' \
1115 -e 's/-W[[^ ]]*//g' \
1116 -e 's/-D_FORTIFY_SOURCE=.//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001117 dnl Remove "-lc", it breaks on FreeBSD when using "-pthread".
1118 perllibs=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed -e 'ldopts' | \
1119 sed -e '/Warning/d' -e '/Note (probably harmless)/d' \
1120 -e 's/-bE:perl.exp//' -e 's/-lc //'`
1121 dnl Don't add perl lib to $LIBS: if it's not in LD_LIBRARY_PATH
1122 dnl a test in configure may fail because of that.
1123 perlldflags=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed \
1124 -e 'ccdlflags' | sed -e 's/-bE:perl.exp//'`
1125
1126 dnl check that compiling a simple program still works with the flags
1127 dnl added for Perl.
1128 AC_MSG_CHECKING([if compile and link flags for Perl are sane])
1129 cflags_save=$CFLAGS
1130 libs_save=$LIBS
1131 ldflags_save=$LDFLAGS
1132 CFLAGS="$CFLAGS $perlcppflags"
1133 LIBS="$LIBS $perllibs"
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001134 perlldflags=`echo "$perlldflags" | sed -e 's/^ *//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001135 LDFLAGS="$perlldflags $LDFLAGS"
1136 AC_TRY_LINK(,[ ],
1137 AC_MSG_RESULT(yes); perl_ok=yes,
1138 AC_MSG_RESULT(no: PERL DISABLED); perl_ok=no)
1139 CFLAGS=$cflags_save
1140 LIBS=$libs_save
1141 LDFLAGS=$ldflags_save
1142 if test $perl_ok = yes; then
1143 if test "X$perlcppflags" != "X"; then
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001144 PERL_CFLAGS=$perlcppflags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001145 fi
1146 if test "X$perlldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001147 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$perlldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001148 LDFLAGS="$perlldflags $LDFLAGS"
1149 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001150 fi
1151 PERL_LIBS=$perllibs
1152 PERL_SRC="auto/if_perl.c if_perlsfio.c"
1153 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o"
1154 PERL_PRO="if_perl.pro if_perlsfio.pro"
1155 AC_DEFINE(FEAT_PERL)
1156 fi
1157 fi
1158 else
1159 AC_MSG_RESULT(>>> too old; need Perl version 5.003_01 or later <<<)
1160 fi
1161 fi
1162
Bram Moolenaard0573012017-10-28 21:11:06 +02001163 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00001164 dnl Mac OS X 10.2 or later
Bram Moolenaar071d4272004-06-13 20:20:40 +00001165 dir=/System/Library/Perl
1166 darwindir=$dir/darwin
1167 if test -d $darwindir; then
1168 PERL=/usr/bin/perl
1169 else
1170 dnl Mac OS X 10.3
1171 dir=/System/Library/Perl/5.8.1
1172 darwindir=$dir/darwin-thread-multi-2level
1173 if test -d $darwindir; then
1174 PERL=/usr/bin/perl
1175 fi
1176 fi
1177 if test -n "$PERL"; then
1178 PERL_DIR="$dir"
1179 PERL_CFLAGS="-DFEAT_PERL -I$darwindir/CORE"
1180 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o $darwindir/auto/DynaLoader/DynaLoader.a"
1181 PERL_LIBS="-L$darwindir/CORE -lperl"
1182 fi
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001183 dnl Perl on Mac OS X 10.5 adds "-arch" flags but these should only
1184 dnl be included if requested by passing --with-mac-arch to
1185 dnl configure, so strip these flags first (if present)
1186 PERL_LIBS=`echo "$PERL_LIBS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
1187 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 +00001188 fi
Bram Moolenaare06c1882010-07-21 22:05:20 +02001189 if test "$enable_perlinterp" = "dynamic"; then
1190 if test "$perl_ok" = "yes" -a "X$libperl" != "X"; then
1191 AC_DEFINE(DYNAMIC_PERL)
1192 PERL_CFLAGS="-DDYNAMIC_PERL_DLL=\\\"$libperl\\\" $PERL_CFLAGS"
1193 fi
1194 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001195
1196 if test "$fail_if_missing" = "yes" -a "$perl_ok" != "yes"; then
1197 AC_MSG_ERROR([could not configure perl])
1198 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001199fi
1200AC_SUBST(shrpenv)
1201AC_SUBST(PERL_SRC)
1202AC_SUBST(PERL_OBJ)
1203AC_SUBST(PERL_PRO)
1204AC_SUBST(PERL_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00001205AC_SUBST(PERL_CFLAGS_EXTRA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001206AC_SUBST(PERL_LIBS)
1207
1208AC_MSG_CHECKING(--enable-pythoninterp argument)
1209AC_ARG_ENABLE(pythoninterp,
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001210 [ --enable-pythoninterp[=OPTS] Include Python interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001211 [enable_pythoninterp="no"])
1212AC_MSG_RESULT($enable_pythoninterp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001213if test "$enable_pythoninterp" = "yes" -o "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001214 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1215 AC_MSG_ERROR([cannot use Python with tiny or small features])
1216 fi
1217
Bram Moolenaar071d4272004-06-13 20:20:40 +00001218 dnl -- find the python executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001219 AC_MSG_CHECKING(--with-python-command argument)
1220 AC_SUBST(vi_cv_path_python)
1221 AC_ARG_WITH(python-command, [ --with-python-command=NAME name of the Python 2 command (default: python2 or python)],
1222 vi_cv_path_python="$withval"; AC_MSG_RESULT($vi_cv_path_python),
1223 AC_MSG_RESULT(no))
1224
1225 if test "X$vi_cv_path_python" = "X"; then
1226 AC_PATH_PROGS(vi_cv_path_python, python2 python)
1227 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001228 if test "X$vi_cv_path_python" != "X"; then
1229
1230 dnl -- get its version number
1231 AC_CACHE_CHECK(Python version,vi_cv_var_python_version,
1232 [[vi_cv_var_python_version=`
1233 ${vi_cv_path_python} -c 'import sys; print sys.version[:3]'`
1234 ]])
1235
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001236 dnl -- it must be at least version 2.3
1237 AC_MSG_CHECKING(Python is 2.3 or better)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001238 if ${vi_cv_path_python} -c \
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001239 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001240 then
1241 AC_MSG_RESULT(yep)
1242
1243 dnl -- find where python thinks it was installed
1244 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python_pfx,
1245 [ vi_cv_path_python_pfx=`
1246 ${vi_cv_path_python} -c \
1247 "import sys; print sys.prefix"` ])
1248
1249 dnl -- and where it thinks it runs
1250 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python_epfx,
1251 [ vi_cv_path_python_epfx=`
1252 ${vi_cv_path_python} -c \
1253 "import sys; print sys.exec_prefix"` ])
1254
1255 dnl -- python's internal library path
1256
1257 AC_CACHE_VAL(vi_cv_path_pythonpath,
1258 [ vi_cv_path_pythonpath=`
1259 unset PYTHONPATH;
1260 ${vi_cv_path_python} -c \
1261 "import sys, string; print string.join(sys.path,':')"` ])
1262
1263 dnl -- where the Python implementation library archives are
1264
1265 AC_ARG_WITH(python-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001266 [ --with-python-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001267 [ vi_cv_path_python_conf="${withval}"; have_python_config_dir=1 ] )
Bram Moolenaar071d4272004-06-13 20:20:40 +00001268
1269 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python_conf,
1270 [
1271 vi_cv_path_python_conf=
Bram Moolenaarac499e32013-06-02 19:14:17 +02001272 d=`${vi_cv_path_python} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBPL')"`
1273 if test -d "$d" && test -f "$d/config.c"; then
1274 vi_cv_path_python_conf="$d"
1275 else
1276 for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
1277 for subdir in lib64 lib share; do
1278 d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
1279 if test -d "$d" && test -f "$d/config.c"; then
1280 vi_cv_path_python_conf="$d"
1281 fi
1282 done
Bram Moolenaar071d4272004-06-13 20:20:40 +00001283 done
Bram Moolenaarac499e32013-06-02 19:14:17 +02001284 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001285 ])
1286
1287 PYTHON_CONFDIR="${vi_cv_path_python_conf}"
1288
1289 if test "X$PYTHON_CONFDIR" = "X"; then
1290 AC_MSG_RESULT([can't find it!])
1291 else
1292
1293 dnl -- we need to examine Python's config/Makefile too
1294 dnl see what the interpreter is built from
1295 AC_CACHE_VAL(vi_cv_path_python_plibs,
1296 [
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001297 pwd=`pwd`
1298 tmp_mkf="$pwd/config-PyMake$$"
1299 cat -- "${PYTHON_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001300__:
Bram Moolenaar218116c2010-05-20 21:46:00 +02001301 @echo "python_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001302 @echo "python_LIBS='$(LIBS)'"
1303 @echo "python_SYSLIBS='$(SYSLIBS)'"
1304 @echo "python_LINKFORSHARED='$(LINKFORSHARED)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001305 @echo "python_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001306 @echo "python_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001307 @echo "python_PYTHONFRAMEWORK='$(PYTHONFRAMEWORK)'"
1308 @echo "python_PYTHONFRAMEWORKPREFIX='$(PYTHONFRAMEWORKPREFIX)'"
1309 @echo "python_PYTHONFRAMEWORKINSTALLDIR='$(PYTHONFRAMEWORKINSTALLDIR)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001310eof
1311 dnl -- delete the lines from make about Entering/Leaving directory
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001312 eval "`cd ${PYTHON_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1313 rm -f -- "${tmp_mkf}"
Bram Moolenaard0573012017-10-28 21:11:06 +02001314 if test "x$MACOS_X" = "xyes" && test -n "${python_PYTHONFRAMEWORK}" && ${vi_cv_path_python} -c \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001315 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then
1316 vi_cv_path_python_plibs="-framework Python"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001317 if test "x${vi_cv_path_python}" != "x/usr/bin/python" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
1318 vi_cv_path_python_plibs="-F${python_PYTHONFRAMEWORKPREFIX} -framework Python"
1319 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001320 else
Bram Moolenaar9ce42132018-04-11 22:19:36 +02001321 vi_cv_path_python_plibs="-L${PYTHON_CONFDIR} -lpython${vi_cv_var_python_version}"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001322 dnl -- Check if the path contained in python_LINKFORSHARED is
1323 dnl usable for vim build. If not, make and try other
1324 dnl candidates.
Bram Moolenaara161e262015-03-24 15:14:27 +01001325 if test -n "${python_LINKFORSHARED}" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
Bram Moolenaar6c927552015-03-24 12:21:33 +01001326 python_link_symbol=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]].*/\1/'`
1327 python_link_path=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]][[ \t]]*\(.*\)/\2/'`
1328 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1329 dnl -- The path looks relative. Guess the absolute one using
1330 dnl the prefix and try that.
1331 python_link_path="${python_PYTHONFRAMEWORKPREFIX}/${python_link_path}"
1332 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1333 dnl -- A last resort.
1334 python_link_path="${python_PYTHONFRAMEWORKINSTALLDIR}/Versions/${vi_cv_var_python_version}/${python_PYTHONFRAMEWORK}"
1335 dnl -- No check is done. The last word is left to the
1336 dnl "sanity" test on link flags that follows shortly.
1337 fi
1338 python_LINKFORSHARED="${python_link_symbol} ${python_link_path}"
1339 fi
1340 fi
Bram Moolenaar218116c2010-05-20 21:46:00 +02001341 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 +00001342 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1343 vi_cv_path_python_plibs=`echo $vi_cv_path_python_plibs | sed s/-ltermcap//`
1344 fi
1345 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001346 AC_CACHE_CHECK(Python's dll name,vi_cv_dll_name_python,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001347 [
1348 if test "X$python_DLLLIBRARY" != "X"; then
1349 vi_cv_dll_name_python="$python_DLLLIBRARY"
1350 else
1351 vi_cv_dll_name_python="$python_INSTSONAME"
1352 fi
1353 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00001354
1355 PYTHON_LIBS="${vi_cv_path_python_plibs}"
1356 if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001357 PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001358 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001359 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 +00001360 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001361 if test "X$have_python_config_dir" = "X1" -a "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001362 dnl Define PYTHON_HOME if --with-python-config-dir was used
1363 PYTHON_CFLAGS="${PYTHON_CFLAGS} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'"
1364
1365 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001366 PYTHON_SRC="if_python.c"
Bram Moolenaar9bdb9a02012-07-25 16:32:08 +02001367 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001368
1369 dnl On FreeBSD linking with "-pthread" is required to use threads.
1370 dnl _THREAD_SAFE must be used for compiling then.
1371 dnl The "-pthread" is added to $LIBS, so that the following check for
1372 dnl sigaltstack() will look in libc_r (it's there in libc!).
1373 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1374 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1375 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1376 AC_MSG_CHECKING([if -pthread should be used])
1377 threadsafe_flag=
1378 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001379 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001380 if test "$vim_cv_uname_output" != Darwin; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001381 test "$GCC" = yes && threadsafe_flag="-pthread"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001382 if test "$vim_cv_uname_output" = FreeBSD; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001383 threadsafe_flag="-D_THREAD_SAFE"
1384 thread_lib="-pthread"
1385 fi
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001386 if test "$vim_cv_uname_output" = SunOS; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001387 threadsafe_flag="-pthreads"
1388 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001389 fi
1390 libs_save_old=$LIBS
1391 if test -n "$threadsafe_flag"; then
1392 cflags_save=$CFLAGS
1393 CFLAGS="$CFLAGS $threadsafe_flag"
1394 LIBS="$LIBS $thread_lib"
1395 AC_TRY_LINK(,[ ],
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001396 AC_MSG_RESULT(yes); PYTHON_CFLAGS="$PYTHON_CFLAGS $threadsafe_flag",
Bram Moolenaar071d4272004-06-13 20:20:40 +00001397 AC_MSG_RESULT(no); LIBS=$libs_save_old
1398 )
1399 CFLAGS=$cflags_save
1400 else
1401 AC_MSG_RESULT(no)
1402 fi
1403
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001404 dnl Check that compiling a simple program still works with the flags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001405 dnl added for Python.
1406 AC_MSG_CHECKING([if compile and link flags for Python are sane])
1407 cflags_save=$CFLAGS
1408 libs_save=$LIBS
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001409 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001410 LIBS="$LIBS $PYTHON_LIBS"
1411 AC_TRY_LINK(,[ ],
1412 AC_MSG_RESULT(yes); python_ok=yes,
1413 AC_MSG_RESULT(no: PYTHON DISABLED); python_ok=no)
1414 CFLAGS=$cflags_save
1415 LIBS=$libs_save
1416 if test $python_ok = yes; then
1417 AC_DEFINE(FEAT_PYTHON)
1418 else
1419 LIBS=$libs_save_old
1420 PYTHON_SRC=
1421 PYTHON_OBJ=
1422 PYTHON_LIBS=
1423 PYTHON_CFLAGS=
1424 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001425 fi
1426 else
1427 AC_MSG_RESULT(too old)
1428 fi
1429 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001430
1431 if test "$fail_if_missing" = "yes" -a "$python_ok" != "yes"; then
1432 AC_MSG_ERROR([could not configure python])
1433 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001434fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001435
Bram Moolenaar071d4272004-06-13 20:20:40 +00001436AC_SUBST(PYTHON_LIBS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001437AC_SUBST(PYTHON_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00001438AC_SUBST(PYTHON_CFLAGS_EXTRA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001439AC_SUBST(PYTHON_SRC)
1440AC_SUBST(PYTHON_OBJ)
1441
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001442
1443AC_MSG_CHECKING(--enable-python3interp argument)
1444AC_ARG_ENABLE(python3interp,
Bram Moolenaar8008b632017-07-18 21:33:20 +02001445 [ --enable-python3interp[=OPTS] Include Python3 interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001446 [enable_python3interp="no"])
1447AC_MSG_RESULT($enable_python3interp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001448if test "$enable_python3interp" = "yes" -o "$enable_python3interp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001449 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1450 AC_MSG_ERROR([cannot use Python with tiny or small features])
1451 fi
1452
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001453 dnl -- find the python3 executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001454 AC_MSG_CHECKING(--with-python3-command argument)
1455 AC_SUBST(vi_cv_path_python3)
1456 AC_ARG_WITH(python3-command, [ --with-python3-command=NAME name of the Python 3 command (default: python3 or python)],
1457 vi_cv_path_python3="$withval"; AC_MSG_RESULT($vi_cv_path_python3),
1458 AC_MSG_RESULT(no))
1459
1460 if test "X$vi_cv_path_python3" = "X"; then
1461 AC_PATH_PROGS(vi_cv_path_python3, python3 python)
1462 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001463 if test "X$vi_cv_path_python3" != "X"; then
1464
1465 dnl -- get its version number
1466 AC_CACHE_CHECK(Python version,vi_cv_var_python3_version,
1467 [[vi_cv_var_python3_version=`
Bram Moolenaar23c01922021-05-21 11:43:58 +02001468 ${vi_cv_path_python3} -c 'import sys; print("{}.{}".format(sys.version_info.major, sys.version_info.minor))'`
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001469 ]])
1470
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001471 dnl -- it must be at least version 3
1472 AC_MSG_CHECKING(Python is 3.0 or better)
1473 if ${vi_cv_path_python3} -c \
1474 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.0)"
1475 then
1476 AC_MSG_RESULT(yep)
Bram Moolenaar456f2bb2011-06-12 21:37:13 +02001477
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001478 dnl -- get abiflags for python 3.2 or higher (PEP 3149)
1479 AC_CACHE_CHECK(Python's abiflags,vi_cv_var_python3_abiflags,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001480 [
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001481 vi_cv_var_python3_abiflags=
1482 if ${vi_cv_path_python3} -c \
1483 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)"
1484 then
1485 vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \
1486 "import sys; print(sys.abiflags)"`
1487 fi ])
1488
1489 dnl -- find where python3 thinks it was installed
1490 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx,
1491 [ vi_cv_path_python3_pfx=`
1492 ${vi_cv_path_python3} -c \
1493 "import sys; print(sys.prefix)"` ])
1494
1495 dnl -- and where it thinks it runs
1496 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx,
1497 [ vi_cv_path_python3_epfx=`
1498 ${vi_cv_path_python3} -c \
1499 "import sys; print(sys.exec_prefix)"` ])
1500
1501 dnl -- python3's internal library path
1502
1503 AC_CACHE_VAL(vi_cv_path_python3path,
1504 [ vi_cv_path_python3path=`
1505 unset PYTHONPATH;
1506 ${vi_cv_path_python3} -c \
1507 "import sys, string; print(':'.join(sys.path))"` ])
1508
1509 dnl -- where the Python implementation library archives are
1510
1511 AC_ARG_WITH(python3-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001512 [ --with-python3-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001513 [ vi_cv_path_python3_conf="${withval}"; have_python3_config_dir=1 ] )
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001514
1515 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf,
1516 [
1517 vi_cv_path_python3_conf=
Bram Moolenaarfee496d2013-07-12 20:07:24 +02001518 config_dir="config-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Zdenek Dohnal31e299c2021-06-10 18:50:55 +02001519 d=`${vi_cv_path_python3} -c "import sysconfig; print(sysconfig.get_config_var('LIBPL'))" 2> /dev/null`
1520 if test "x$d" = "x"; then
1521 d=`${vi_cv_path_python3} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBPL'))"`
1522 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001523 if test -d "$d" && test -f "$d/config.c"; then
1524 vi_cv_path_python3_conf="$d"
1525 else
1526 for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do
1527 for subdir in lib64 lib share; do
1528 d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}"
1529 if test -d "$d" && test -f "$d/config.c"; then
1530 vi_cv_path_python3_conf="$d"
1531 fi
1532 done
1533 done
1534 fi
1535 ])
1536
1537 PYTHON3_CONFDIR="${vi_cv_path_python3_conf}"
1538
1539 if test "X$PYTHON3_CONFDIR" = "X"; then
1540 AC_MSG_RESULT([can't find it!])
1541 else
1542
1543 dnl -- we need to examine Python's config/Makefile too
1544 dnl see what the interpreter is built from
1545 AC_CACHE_VAL(vi_cv_path_python3_plibs,
1546 [
1547 pwd=`pwd`
1548 tmp_mkf="$pwd/config-PyMake$$"
1549 cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001550__:
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001551 @echo "python3_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001552 @echo "python3_LIBS='$(LIBS)'"
1553 @echo "python3_SYSLIBS='$(SYSLIBS)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001554 @echo "python3_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001555 @echo "python3_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001556eof
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001557 dnl -- delete the lines from make about Entering/Leaving directory
1558 eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1559 rm -f -- "${tmp_mkf}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001560 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 +02001561 vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}"
1562 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1563 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//`
1564 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//`
1565 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001566 AC_CACHE_CHECK(Python3's dll name,vi_cv_dll_name_python3,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001567 [
1568 if test "X$python3_DLLLIBRARY" != "X"; then
1569 vi_cv_dll_name_python3="$python3_DLLLIBRARY"
1570 else
1571 vi_cv_dll_name_python3="$python3_INSTSONAME"
1572 fi
1573 ])
1574
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001575 PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
1576 if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001577 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 +02001578 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001579 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 +02001580 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001581 if test "X$have_python3_config_dir" = "X1" -a "$enable_python3interp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001582 dnl Define PYTHON3_HOME if --with-python-config-dir was used
1583 PYTHON3_CFLAGS="${PYTHON3_CFLAGS} -DPYTHON3_HOME='L\"${vi_cv_path_python3_pfx}\"'"
1584 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001585 PYTHON3_SRC="if_python3.c"
1586 PYTHON3_OBJ="objects/if_python3.o"
1587
1588 dnl On FreeBSD linking with "-pthread" is required to use threads.
1589 dnl _THREAD_SAFE must be used for compiling then.
1590 dnl The "-pthread" is added to $LIBS, so that the following check for
1591 dnl sigaltstack() will look in libc_r (it's there in libc!).
1592 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1593 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1594 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1595 AC_MSG_CHECKING([if -pthread should be used])
1596 threadsafe_flag=
1597 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001598 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001599 if test "$vim_cv_uname_output" != Darwin; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001600 test "$GCC" = yes && threadsafe_flag="-pthread"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001601 if test "$vim_cv_uname_output" = FreeBSD; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001602 threadsafe_flag="-D_THREAD_SAFE"
1603 thread_lib="-pthread"
1604 fi
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001605 if test "$vim_cv_uname_output" = SunOS; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001606 threadsafe_flag="-pthreads"
1607 fi
1608 fi
1609 libs_save_old=$LIBS
1610 if test -n "$threadsafe_flag"; then
1611 cflags_save=$CFLAGS
1612 CFLAGS="$CFLAGS $threadsafe_flag"
1613 LIBS="$LIBS $thread_lib"
1614 AC_TRY_LINK(,[ ],
1615 AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag",
1616 AC_MSG_RESULT(no); LIBS=$libs_save_old
1617 )
1618 CFLAGS=$cflags_save
1619 else
1620 AC_MSG_RESULT(no)
1621 fi
1622
1623 dnl check that compiling a simple program still works with the flags
1624 dnl added for Python.
1625 AC_MSG_CHECKING([if compile and link flags for Python 3 are sane])
1626 cflags_save=$CFLAGS
1627 libs_save=$LIBS
1628 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1629 LIBS="$LIBS $PYTHON3_LIBS"
1630 AC_TRY_LINK(,[ ],
1631 AC_MSG_RESULT(yes); python3_ok=yes,
1632 AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no)
1633 CFLAGS=$cflags_save
1634 LIBS=$libs_save
1635 if test "$python3_ok" = yes; then
1636 AC_DEFINE(FEAT_PYTHON3)
1637 else
1638 LIBS=$libs_save_old
1639 PYTHON3_SRC=
1640 PYTHON3_OBJ=
1641 PYTHON3_LIBS=
1642 PYTHON3_CFLAGS=
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001643 fi
1644 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001645 else
1646 AC_MSG_RESULT(too old)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001647 fi
1648 fi
Bram Moolenaar1612b1a2013-06-14 21:22:39 +02001649 if test "$fail_if_missing" = "yes" -a "$python3_ok" != "yes"; then
1650 AC_MSG_ERROR([could not configure python3])
1651 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001652fi
1653
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001654AC_SUBST(PYTHON3_LIBS)
1655AC_SUBST(PYTHON3_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00001656AC_SUBST(PYTHON3_CFLAGS_EXTRA)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001657AC_SUBST(PYTHON3_SRC)
1658AC_SUBST(PYTHON3_OBJ)
1659
1660dnl if python2.x and python3.x are enabled one can only link in code
1661dnl with dlopen(), dlsym(), dlclose()
1662if test "$python_ok" = yes && test "$python3_ok" = yes; then
1663 AC_DEFINE(DYNAMIC_PYTHON)
1664 AC_DEFINE(DYNAMIC_PYTHON3)
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001665 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001666 cflags_save=$CFLAGS
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001667 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001668 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001669 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001670 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001671 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001672 #include <dlfcn.h>
1673 /* If this program fails, then RTLD_GLOBAL is needed.
1674 * RTLD_GLOBAL will be used and then it is not possible to
1675 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001676 * Only the first python version used will be switched on.
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001677 */
1678
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001679 int no_rtl_global_needed_for(char *python_instsoname, char *prefix)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001680 {
1681 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001682 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001683 if (pylib != 0)
1684 {
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001685 void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome");
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001686 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1687 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1688 void (*final)(void) = dlsym(pylib, "Py_Finalize");
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001689 (*pfx)(prefix);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001690 (*init)();
1691 needed = (*simple)("import termios") == -1;
1692 (*final)();
1693 dlclose(pylib);
1694 }
1695 return !needed;
1696 }
1697
1698 int main(int argc, char** argv)
1699 {
1700 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001701 if (no_rtl_global_needed_for("${vi_cv_dll_name_python}", "${vi_cv_path_python_pfx}"))
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001702 not_needed = 1;
1703 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001704 }])],
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001705 [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001706
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001707 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001708 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001709
1710 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python3)
1711 cflags_save=$CFLAGS
1712 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001713 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001714 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001715 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001716 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001717 #include <dlfcn.h>
1718 #include <wchar.h>
1719 /* If this program fails, then RTLD_GLOBAL is needed.
1720 * RTLD_GLOBAL will be used and then it is not possible to
1721 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001722 * Only the first python version used will be switched on.
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001723 */
1724
1725 int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix)
1726 {
1727 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001728 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001729 if (pylib != 0)
1730 {
1731 void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome");
1732 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1733 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1734 void (*final)(void) = dlsym(pylib, "Py_Finalize");
1735 (*pfx)(prefix);
1736 (*init)();
1737 needed = (*simple)("import termios") == -1;
1738 (*final)();
1739 dlclose(pylib);
1740 }
1741 return !needed;
1742 }
1743
1744 int main(int argc, char** argv)
1745 {
1746 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001747 if (no_rtl_global_needed_for("${vi_cv_dll_name_python3}", L"${vi_cv_path_python3_pfx}"))
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001748 not_needed = 1;
1749 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001750 }])],
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001751 [AC_MSG_RESULT(yes);AC_DEFINE(PY3_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
1752
1753 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001754 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001755
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001756 PYTHON_SRC="if_python.c"
1757 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001758 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001759 PYTHON_LIBS=
1760 PYTHON3_SRC="if_python3.c"
1761 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001762 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001763 PYTHON3_LIBS=
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001764elif test "$python_ok" = yes && test "$enable_pythoninterp" = "dynamic"; then
1765 AC_DEFINE(DYNAMIC_PYTHON)
1766 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 Moolenaarb744b2f2010-08-13 16:22:57 +02001769 PYTHON_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001770elif test "$python_ok" = yes; then
1771 dnl Check that adding -fPIE works. It may be needed when using a static
1772 dnl Python library.
1773 AC_MSG_CHECKING([if -fPIE can be added for Python])
1774 cflags_save=$CFLAGS
1775 libs_save=$LIBS
1776 CFLAGS="$CFLAGS $PYTHON_CFLAGS -fPIE"
1777 LIBS="$LIBS $PYTHON_LIBS"
1778 AC_TRY_LINK(,[ ],
1779 AC_MSG_RESULT(yes); fpie_ok=yes,
1780 AC_MSG_RESULT(no); fpie_ok=no)
1781 CFLAGS=$cflags_save
1782 LIBS=$libs_save
1783 if test $fpie_ok = yes; then
1784 PYTHON_CFLAGS="$PYTHON_CFLAGS -fPIE"
1785 fi
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001786elif test "$python3_ok" = yes && test "$enable_python3interp" = "dynamic"; then
1787 AC_DEFINE(DYNAMIC_PYTHON3)
1788 PYTHON3_SRC="if_python3.c"
1789 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001790 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001791 PYTHON3_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001792elif test "$python3_ok" = yes; then
1793 dnl Check that adding -fPIE works. It may be needed when using a static
1794 dnl Python library.
1795 AC_MSG_CHECKING([if -fPIE can be added for Python3])
1796 cflags_save=$CFLAGS
1797 libs_save=$LIBS
1798 CFLAGS="$CFLAGS $PYTHON3_CFLAGS -fPIE"
1799 LIBS="$LIBS $PYTHON3_LIBS"
1800 AC_TRY_LINK(,[ ],
1801 AC_MSG_RESULT(yes); fpie_ok=yes,
1802 AC_MSG_RESULT(no); fpie_ok=no)
1803 CFLAGS=$cflags_save
1804 LIBS=$libs_save
1805 if test $fpie_ok = yes; then
1806 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -fPIE"
1807 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001808fi
1809
Bram Moolenaar071d4272004-06-13 20:20:40 +00001810AC_MSG_CHECKING(--enable-tclinterp argument)
1811AC_ARG_ENABLE(tclinterp,
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001812 [ --enable-tclinterp[=OPTS] Include Tcl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001813 [enable_tclinterp="no"])
1814AC_MSG_RESULT($enable_tclinterp)
1815
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001816if test "$enable_tclinterp" = "yes" -o "$enable_tclinterp" = "dynamic"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001817
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001818 dnl on FreeBSD tclsh is a silly script, look for tclsh8.[5420]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001819 AC_MSG_CHECKING(--with-tclsh argument)
1820 AC_ARG_WITH(tclsh, [ --with-tclsh=PATH which tclsh to use (default: tclsh8.0)],
1821 tclsh_name="$withval"; AC_MSG_RESULT($tclsh_name),
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001822 tclsh_name="tclsh8.5"; AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00001823 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1824 AC_SUBST(vi_cv_path_tcl)
1825
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001826 dnl when no specific version specified, also try 8.4, 8.2 and 8.0
1827 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.5"; then
1828 tclsh_name="tclsh8.4"
1829 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1830 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001831 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.4"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001832 tclsh_name="tclsh8.2"
1833 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1834 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001835 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.2"; then
1836 tclsh_name="tclsh8.0"
1837 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1838 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001839 dnl still didn't find it, try without version number
1840 if test "X$vi_cv_path_tcl" = "X"; then
1841 tclsh_name="tclsh"
1842 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1843 fi
1844 if test "X$vi_cv_path_tcl" != "X"; then
1845 AC_MSG_CHECKING(Tcl version)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001846 if echo 'exit [[expr [info tclversion] < 8.0]]' | "$vi_cv_path_tcl" - ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001847 tclver=`echo 'puts [[info tclversion]]' | $vi_cv_path_tcl -`
1848 AC_MSG_RESULT($tclver - OK);
1849 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 +01001850 tcldll=`echo 'puts libtcl[[info tclversion]][[info sharedlibextension]]' | $vi_cv_path_tcl -`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001851
1852 AC_MSG_CHECKING(for location of Tcl include)
Bram Moolenaard0573012017-10-28 21:11:06 +02001853 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001854 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 +00001855 else
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001856 dnl For all macOS, use the value from TCL in case use of, say, homebrew
Bram Moolenaar071d4272004-06-13 20:20:40 +00001857 dnl For Mac OS X 10.3, use the OS-provided framework location
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001858 dnl For Mac OS X 10.14, the OS-provided framework location doesn't contain the headers, so also check the Xcode SDK
1859 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 +00001860 fi
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001861 TCL_INC=
Bram Moolenaar071d4272004-06-13 20:20:40 +00001862 for try in $tclinc; do
1863 if test -f "$try/tcl.h"; then
1864 AC_MSG_RESULT($try/tcl.h)
1865 TCL_INC=$try
1866 break
1867 fi
1868 done
1869 if test -z "$TCL_INC"; then
1870 AC_MSG_RESULT(<not found>)
1871 SKIP_TCL=YES
1872 fi
1873 if test -z "$SKIP_TCL"; then
1874 AC_MSG_CHECKING(for location of tclConfig.sh script)
Bram Moolenaard0573012017-10-28 21:11:06 +02001875 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001876 tclcnf=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001877 tclcnf="$tclcnf `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001878 else
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001879 dnl For all macOS, use the value from TCL in case use of, say, homebrew
Bram Moolenaar071d4272004-06-13 20:20:40 +00001880 dnl For Mac OS X 10.3, use the OS-provided framework location
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001881 dnl For Mac OS X 10.14, the OS-provided framework location doesn't contain the headers, so also check the Xcode SDK
1882 tclcnf=`echo $tclinc | sed s/include/lib/g`
1883 tclcnf="$tclcnf /System/Library/Frameworks/Tcl.framework `xcrun --show-sdk-path`/System/Library/Frameworks/Tcl.framework"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001884 fi
1885 for try in $tclcnf; do
Bram Moolenaar49222be2015-12-11 18:11:30 +01001886 if test -f "$try/tclConfig.sh"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001887 AC_MSG_RESULT($try/tclConfig.sh)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001888 . "$try/tclConfig.sh"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001889 dnl use eval, because tcl 8.2 includes ${TCL_DBGX}
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001890 if test "$enable_tclinterp" = "dynamic"; then
1891 TCL_LIBS=`eval echo "$TCL_STUB_LIB_SPEC $TCL_LIBS"`
1892 else
1893 TCL_LIBS=`eval echo "$TCL_LIB_SPEC $TCL_LIBS"`
1894 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001895 dnl Use $TCL_DEFS for -D_THREAD_SAFE et al. But only use the
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001896 dnl "-D_ABC" items. Watch out for -DFOO=long\ long.
Bram Moolenaar4394bff2008-07-24 11:21:31 +00001897 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 +00001898 break
1899 fi
1900 done
1901 if test -z "$TCL_LIBS"; then
1902 AC_MSG_RESULT(<not found>)
1903 AC_MSG_CHECKING(for Tcl library by myself)
1904 tcllib=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001905 tcllib="$tcllib `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001906 for ext in .so .a ; do
1907 for ver in "" $tclver ; do
1908 for try in $tcllib ; do
1909 trylib=tcl$ver$ext
Bram Moolenaar49222be2015-12-11 18:11:30 +01001910 if test -f "$try/lib$trylib" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001911 AC_MSG_RESULT($try/lib$trylib)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001912 TCL_LIBS="-L\"$try\" -ltcl$ver -ldl -lm"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001913 if test "$vim_cv_uname_output" = SunOS &&
1914 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001915 TCL_LIBS="$TCL_LIBS -R $try"
1916 fi
1917 break 3
1918 fi
1919 done
1920 done
1921 done
1922 if test -z "$TCL_LIBS"; then
1923 AC_MSG_RESULT(<not found>)
1924 SKIP_TCL=YES
1925 fi
1926 fi
1927 if test -z "$SKIP_TCL"; then
1928 AC_DEFINE(FEAT_TCL)
1929 TCL_SRC=if_tcl.c
1930 TCL_OBJ=objects/if_tcl.o
1931 TCL_PRO=if_tcl.pro
1932 TCL_CFLAGS="-I$TCL_INC $TCL_DEFS"
1933 fi
1934 fi
1935 else
1936 AC_MSG_RESULT(too old; need Tcl version 8.0 or later)
1937 fi
1938 fi
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001939 if test "$enable_tclinterp" = "dynamic"; then
1940 if test "X$TCL_SRC" != "X" -a "X$tcldll" != "X"; then
1941 AC_DEFINE(DYNAMIC_TCL)
1942 TCL_CFLAGS="-DDYNAMIC_TCL_DLL=\\\"$tcldll\\\" -DDYNAMIC_TCL_VER=\\\"$tclver\\\" $TCL_CFLAGS"
1943 fi
1944 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001945 if test "$fail_if_missing" = "yes" -a -z "$TCL_SRC"; then
1946 AC_MSG_ERROR([could not configure Tcl])
1947 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001948fi
1949AC_SUBST(TCL_SRC)
1950AC_SUBST(TCL_OBJ)
1951AC_SUBST(TCL_PRO)
1952AC_SUBST(TCL_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00001953AC_SUBST(TCL_CFLAGS_EXTRA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001954AC_SUBST(TCL_LIBS)
1955
1956AC_MSG_CHECKING(--enable-rubyinterp argument)
1957AC_ARG_ENABLE(rubyinterp,
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001958 [ --enable-rubyinterp[=OPTS] Include Ruby interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001959 [enable_rubyinterp="no"])
1960AC_MSG_RESULT($enable_rubyinterp)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001961if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001962 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1963 AC_MSG_ERROR([cannot use Ruby with tiny or small features])
1964 fi
1965
Bram Moolenaar165641d2010-02-17 16:23:09 +01001966 AC_MSG_CHECKING(--with-ruby-command argument)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001967 AC_SUBST(vi_cv_path_ruby)
Bram Moolenaar948733a2011-05-05 18:10:16 +02001968 AC_ARG_WITH(ruby-command, [ --with-ruby-command=RUBY name of the Ruby command (default: ruby)],
1969 RUBY_CMD="$withval"; vi_cv_path_ruby="$withval"; AC_MSG_RESULT($RUBY_CMD),
1970 RUBY_CMD="ruby"; AC_MSG_RESULT(defaulting to $RUBY_CMD))
Bram Moolenaar165641d2010-02-17 16:23:09 +01001971 AC_PATH_PROG(vi_cv_path_ruby, $RUBY_CMD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001972 if test "X$vi_cv_path_ruby" != "X"; then
1973 AC_MSG_CHECKING(Ruby version)
Bram Moolenaare4efc3b2005-03-07 23:16:51 +00001974 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 +00001975 AC_MSG_RESULT(OK)
Bram Moolenaar81398892012-10-03 21:09:35 +02001976 AC_MSG_CHECKING(Ruby rbconfig)
1977 ruby_rbconfig="RbConfig"
1978 if ! $vi_cv_path_ruby -r rbconfig -e 'RbConfig' >/dev/null 2>/dev/null; then
1979 ruby_rbconfig="Config"
1980 fi
1981 AC_MSG_RESULT($ruby_rbconfig)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001982 AC_MSG_CHECKING(Ruby header files)
Bram Moolenaar81398892012-10-03 21:09:35 +02001983 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 +00001984 if test "X$rubyhdrdir" != "X"; then
1985 AC_MSG_RESULT($rubyhdrdir)
1986 RUBY_CFLAGS="-I$rubyhdrdir"
Bram Moolenaara6fd37b2014-03-27 17:19:09 +01001987 rubyarchdir=`$vi_cv_path_ruby -r rbconfig -e "print ($ruby_rbconfig::CONFIG.has_key? 'rubyarchhdrdir') ? $ruby_rbconfig::CONFIG[['rubyarchhdrdir']] : '$rubyhdrdir/'+$ruby_rbconfig::CONFIG[['arch']]"`
1988 if test -d "$rubyarchdir"; then
1989 RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyarchdir"
Bram Moolenaar165641d2010-02-17 16:23:09 +01001990 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001991 rubyversion=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['ruby_version']].gsub(/\./, '')[[0,2]]"`
Bram Moolenaar026a4452013-08-07 15:22:23 +02001992 if test "X$rubyversion" = "X"; then
1993 rubyversion=`$vi_cv_path_ruby -e "print ((VERSION rescue RUBY_VERSION)).gsub(/\./, '')[[0,2]]"`
1994 fi
Bram Moolenaar165641d2010-02-17 16:23:09 +01001995 RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
Bram Moolenaar81398892012-10-03 21:09:35 +02001996 rubylibs=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LIBS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001997 if test "X$rubylibs" != "X"; then
1998 RUBY_LIBS="$rubylibs"
1999 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02002000 librubyarg=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBYARG']])"`
2001 librubya=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBY_A']])"`
Bram Moolenaarac499e32013-06-02 19:14:17 +02002002 rubylibdir=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['libdir']])"`
Bram Moolenaard5a986f2020-12-06 21:11:31 +01002003 if test -f "$rubylibdir/$librubya" || expr "$librubyarg" : "-lruby"; then
Bram Moolenaarac499e32013-06-02 19:14:17 +02002004 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
2005 elif test "$librubyarg" = "libruby.a"; then
2006 dnl required on Mac OS 10.3 where libruby.a doesn't exist
2007 librubyarg="-lruby"
2008 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002009 fi
2010
2011 if test "X$librubyarg" != "X"; then
2012 RUBY_LIBS="$librubyarg $RUBY_LIBS"
2013 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02002014 rubyldflags=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LDFLAGS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002015 if test "X$rubyldflags" != "X"; then
Bram Moolenaar996b6d82009-07-22 09:17:23 +00002016 dnl Ruby on Mac OS X 10.5 adds "-arch" flags but these should only
2017 dnl be included if requested by passing --with-mac-arch to
2018 dnl configure, so strip these flags first (if present)
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02002019 rubyldflags=`echo "$rubyldflags" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
Bram Moolenaar996b6d82009-07-22 09:17:23 +00002020 if test "X$rubyldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01002021 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$rubyldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02002022 LDFLAGS="$rubyldflags $LDFLAGS"
2023 fi
Bram Moolenaar996b6d82009-07-22 09:17:23 +00002024 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002025 fi
2026 RUBY_SRC="if_ruby.c"
2027 RUBY_OBJ="objects/if_ruby.o"
2028 RUBY_PRO="if_ruby.pro"
2029 AC_DEFINE(FEAT_RUBY)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002030 if test "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar92021622017-10-12 12:33:43 +02002031 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_ALIASES']].split[[0]]"`
Bram Moolenaar87ea64c2018-08-04 15:13:34 +02002032 if test -z "$libruby_soname"; then
2033 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_SO']]"`
2034 fi
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002035 AC_DEFINE(DYNAMIC_RUBY)
Bram Moolenaar41a41412020-01-07 21:32:19 +01002036 RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby_soname\\\" $RUBY_CFLAGS"
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002037 RUBY_LIBS=
2038 fi
Bram Moolenaar864a28b2020-12-28 21:36:56 +01002039 if test "X$CLANG_VERSION" != "X" -a "$rubyversion" -ge 30; then
2040 RUBY_CFLAGS="$RUBY_CFLAGS -fdeclspec"
2041 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002042 else
Bram Moolenaar165641d2010-02-17 16:23:09 +01002043 AC_MSG_RESULT(not found; disabling Ruby)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002044 fi
2045 else
2046 AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
2047 fi
2048 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01002049
2050 if test "$fail_if_missing" = "yes" -a -z "$RUBY_OBJ"; then
2051 AC_MSG_ERROR([could not configure Ruby])
2052 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002053fi
2054AC_SUBST(RUBY_SRC)
2055AC_SUBST(RUBY_OBJ)
2056AC_SUBST(RUBY_PRO)
2057AC_SUBST(RUBY_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00002058AC_SUBST(RUBY_CFLAGS_EXTRA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002059AC_SUBST(RUBY_LIBS)
2060
2061AC_MSG_CHECKING(--enable-cscope argument)
2062AC_ARG_ENABLE(cscope,
2063 [ --enable-cscope Include cscope interface.], ,
2064 [enable_cscope="no"])
2065AC_MSG_RESULT($enable_cscope)
2066if test "$enable_cscope" = "yes"; then
2067 AC_DEFINE(FEAT_CSCOPE)
2068fi
2069
Bram Moolenaar071d4272004-06-13 20:20:40 +00002070AC_MSG_CHECKING(--disable-netbeans argument)
2071AC_ARG_ENABLE(netbeans,
2072 [ --disable-netbeans Disable NetBeans integration support.],
2073 , [enable_netbeans="yes"])
2074if test "$enable_netbeans" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002075 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2076 AC_MSG_RESULT([cannot use NetBeans with tiny or small features])
2077 enable_netbeans="no"
2078 else
2079 AC_MSG_RESULT(no)
2080 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002081else
2082 AC_MSG_RESULT(yes)
2083fi
2084
2085AC_MSG_CHECKING(--disable-channel argument)
2086AC_ARG_ENABLE(channel,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002087 [ --disable-channel Disable process communication support.],
Bram Moolenaare0874f82016-01-24 20:36:41 +01002088 , [enable_channel="yes"])
2089if test "$enable_channel" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002090 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2091 AC_MSG_RESULT([cannot use channels with tiny or small features])
2092 enable_channel="no"
2093 else
2094 AC_MSG_RESULT(no)
2095 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002096else
2097 if test "$enable_netbeans" = "yes"; then
Bram Moolenaar16435482016-01-24 21:31:54 +01002098 AC_MSG_RESULT([yes, netbeans also disabled])
Bram Moolenaare0874f82016-01-24 20:36:41 +01002099 enable_netbeans="no"
2100 else
2101 AC_MSG_RESULT(yes)
2102 fi
2103fi
2104
Bram Moolenaar16435482016-01-24 21:31:54 +01002105if test "$enable_channel" = "yes"; then
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002106 dnl On Solaris we need the socket library, or on Haiku the network library.
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002107 if test "x$HAIKU" = "xyes"; then
2108 AC_CHECK_LIB(network, socket)
2109 else
2110 AC_CHECK_LIB(socket, socket)
2111 fi
2112
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002113 AC_CACHE_CHECK([whether compiling with IPv6 networking is possible], [vim_cv_ipv6_networking],
2114 [AC_TRY_LINK([
2115#include <stdio.h>
2116#include <stdlib.h>
2117#include <stdarg.h>
2118#include <fcntl.h>
2119#include <netdb.h>
2120#include <netinet/in.h>
2121#include <errno.h>
2122#include <sys/types.h>
2123#include <sys/socket.h>
2124 /* Check bitfields */
2125 struct nbbuf {
2126 unsigned int initDone:1;
2127 unsigned short signmaplen;
2128 };
2129 ], [
2130 /* Check creating a socket. */
2131 struct sockaddr_in server;
2132 struct addrinfo *res;
2133 (void)socket(AF_INET, SOCK_STREAM, 0);
2134 (void)htons(100);
2135 (void)getaddrinfo("microsoft.com", NULL, NULL, &res);
2136 if (errno == ECONNREFUSED)
2137 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
2138 (void)freeaddrinfo(res);
2139 ],
2140 [vim_cv_ipv6_networking="yes"],
2141 [vim_cv_ipv6_networking="no"])])
2142
2143 if test "x$vim_cv_ipv6_networking" = "xyes"; then
2144 AC_DEFINE(FEAT_IPV6)
Bram Moolenaarb6fb0512020-04-18 18:24:18 +02002145 AC_CHECK_FUNCS(inet_ntop)
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002146 else
2147 dnl On Solaris we need the nsl library.
2148 AC_CHECK_LIB(nsl, gethostbyname)
2149 AC_CACHE_CHECK([whether compiling with IPv4 networking is possible], [vim_cv_ipv4_networking],
2150 [AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00002151#include <stdio.h>
2152#include <stdlib.h>
2153#include <stdarg.h>
2154#include <fcntl.h>
2155#include <netdb.h>
2156#include <netinet/in.h>
2157#include <errno.h>
2158#include <sys/types.h>
2159#include <sys/socket.h>
2160 /* Check bitfields */
2161 struct nbbuf {
2162 unsigned int initDone:1;
Bram Moolenaar63de19e2016-12-09 20:11:26 +01002163 unsigned short signmaplen;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002164 };
2165 ], [
2166 /* Check creating a socket. */
2167 struct sockaddr_in server;
2168 (void)socket(AF_INET, SOCK_STREAM, 0);
2169 (void)htons(100);
2170 (void)gethostbyname("microsoft.com");
2171 if (errno == ECONNREFUSED)
2172 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
2173 ],
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002174 [vim_cv_ipv4_networking="yes"],
2175 [vim_cv_ipv4_networking="no"; enable_netbeans="no"; enable_channel="no"])])
2176 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002177fi
2178if test "$enable_netbeans" = "yes"; then
2179 AC_DEFINE(FEAT_NETBEANS_INTG)
2180 NETBEANS_SRC="netbeans.c"
2181 AC_SUBST(NETBEANS_SRC)
2182 NETBEANS_OBJ="objects/netbeans.o"
2183 AC_SUBST(NETBEANS_OBJ)
2184fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002185if test "$enable_channel" = "yes"; then
Bram Moolenaar509ce2a2016-03-11 22:52:15 +01002186 AC_DEFINE(FEAT_JOB_CHANNEL)
Bram Moolenaar8b5866d2020-09-05 15:48:51 +02002187 CHANNEL_SRC="job.c channel.c"
Bram Moolenaare0874f82016-01-24 20:36:41 +01002188 AC_SUBST(CHANNEL_SRC)
Bram Moolenaar8b5866d2020-09-05 15:48:51 +02002189 CHANNEL_OBJ="objects/job.o objects/channel.o"
Bram Moolenaare0874f82016-01-24 20:36:41 +01002190 AC_SUBST(CHANNEL_OBJ)
2191fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002192
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002193AC_MSG_CHECKING(--enable-terminal argument)
2194AC_ARG_ENABLE(terminal,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002195 [ --enable-terminal Enable terminal emulation support.],
Bram Moolenaaref839562017-10-28 20:28:23 +02002196 , [enable_terminal="auto"])
Bram Moolenaar595a4022017-09-03 19:15:57 +02002197if test "$enable_terminal" = "yes" || test "$enable_terminal" = "auto" -a "x$features" = "xhuge" ; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002198 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2199 AC_MSG_RESULT([cannot use terminal emulator with tiny or small features])
2200 enable_terminal="no"
2201 else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002202 if test "$enable_terminal" = "auto"; then
2203 enable_terminal="yes"
2204 AC_MSG_RESULT(defaulting to yes)
2205 else
2206 AC_MSG_RESULT(yes)
2207 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002208 fi
2209else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002210 if test "$enable_terminal" = "auto"; then
2211 enable_terminal="no"
2212 AC_MSG_RESULT(defaulting to no)
2213 else
2214 AC_MSG_RESULT(no)
2215 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002216fi
Bram Moolenaar8b423282017-12-16 14:37:06 +01002217if test "$enable_terminal" = "yes" -a "$enable_channel" = "yes"; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002218 AC_DEFINE(FEAT_TERMINAL)
Bram Moolenaar93268052019-10-10 13:22:54 +02002219 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 +02002220 AC_SUBST(TERM_SRC)
Bram Moolenaar93268052019-10-10 13:22:54 +02002221 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 +02002222 AC_SUBST(TERM_OBJ)
Bram Moolenaar823edd12019-10-23 22:35:36 +02002223 TERM_TEST="test_libvterm"
2224 AC_SUBST(TERM_TEST)
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002225fi
2226
Bram Moolenaare42a6d22017-11-12 19:21:51 +01002227AC_MSG_CHECKING(--enable-autoservername argument)
2228AC_ARG_ENABLE(autoservername,
2229 [ --enable-autoservername Automatically define servername at vim startup.], ,
2230 [enable_autoservername="no"])
2231AC_MSG_RESULT($enable_autoservername)
2232if test "$enable_autoservername" = "yes"; then
2233 AC_DEFINE(FEAT_AUTOSERVERNAME)
2234fi
2235
Bram Moolenaar071d4272004-06-13 20:20:40 +00002236AC_MSG_CHECKING(--enable-multibyte argument)
2237AC_ARG_ENABLE(multibyte,
2238 [ --enable-multibyte Include multibyte editing support.], ,
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01002239 [enable_multibyte="yes"])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002240AC_MSG_RESULT($enable_multibyte)
Bram Moolenaar30276f22019-01-24 17:59:39 +01002241if test "$enable_multibyte" != "yes"; then
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01002242 AC_MSG_ERROR([The multi-byte feature can no longer be disabled. If you have
2243 a problem with this, discuss on the Vim mailing list.])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002244fi
2245
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002246dnl Right-to-Left language support for Vim will be included with big features,
2247dnl unless ENABLE_RIGHTLEFT is undefined.
2248AC_MSG_CHECKING(--disable-rightleft argument)
2249AC_ARG_ENABLE(rightleft,
2250 [ --disable-rightleft Do not include Right-to-Left language support.],
2251 , [enable_rightleft="yes"])
2252if test "$enable_rightleft" = "yes"; then
2253 AC_MSG_RESULT(no)
2254else
2255 AC_MSG_RESULT(yes)
2256 AC_DEFINE(DISABLE_RIGHTLEFT)
2257fi
2258
2259dnl Arabic language support for Vim will be included with big features,
2260dnl unless ENABLE_ARABIC is undefined.
2261AC_MSG_CHECKING(--disable-arabic argument)
2262AC_ARG_ENABLE(arabic,
2263 [ --disable-arabic Do not include Arabic language support.],
2264 , [enable_arabic="yes"])
2265if test "$enable_arabic" = "yes"; then
2266 AC_MSG_RESULT(no)
2267else
2268 AC_MSG_RESULT(yes)
2269 AC_DEFINE(DISABLE_ARABIC)
2270fi
2271
Bram Moolenaar14184a32019-02-16 15:10:30 +01002272dnl Farsi language support has been removed, ignore --disable-farsi
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002273AC_ARG_ENABLE(farsi,
Bram Moolenaar14184a32019-02-16 15:10:30 +01002274 [ --disable-farsi Deprecated.],,)
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002275
Bram Moolenaar071d4272004-06-13 20:20:40 +00002276AC_MSG_CHECKING(--enable-xim argument)
2277AC_ARG_ENABLE(xim,
2278 [ --enable-xim Include XIM input support.],
2279 AC_MSG_RESULT($enable_xim),
2280 [enable_xim="auto"; AC_MSG_RESULT(defaulting to auto)])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002281
2282AC_MSG_CHECKING(--enable-fontset argument)
2283AC_ARG_ENABLE(fontset,
2284 [ --enable-fontset Include X fontset output support.], ,
2285 [enable_fontset="no"])
2286AC_MSG_RESULT($enable_fontset)
2287dnl defining FEAT_XFONTSET is delayed, so that it can be disabled for no GUI
2288
2289test -z "$with_x" && with_x=yes
Bram Moolenaard0573012017-10-28 21:11:06 +02002290test "${enable_gui-yes}" != no -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && with_x=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002291if test "$with_x" = no; then
2292 AC_MSG_RESULT(defaulting to: don't HAVE_X11)
2293else
2294 dnl Do this check early, so that its failure can override user requests.
2295
2296 AC_PATH_PROG(xmkmfpath, xmkmf)
2297
2298 AC_PATH_XTRA
2299
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002300 dnl On z/OS Unix the X libraries are DLLs. To use them the code must
Bram Moolenaar071d4272004-06-13 20:20:40 +00002301 dnl be compiled with a special option.
2302 dnl Also add SM, ICE and Xmu to X_EXTRA_LIBS.
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002303 if test "$zOSUnix" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002304 CFLAGS="$CFLAGS -W c,dll"
2305 LDFLAGS="$LDFLAGS -W l,dll"
2306 X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE -lXmu"
2307 fi
2308
2309 dnl On my HPUX system the X include dir is found, but the lib dir not.
Bram Moolenaar70778922020-02-05 20:44:24 +01002310 dnl This is a desperate try to fix this.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002311
2312 if test -d "$x_includes" && test ! -d "$x_libraries"; then
2313 x_libraries=`echo "$x_includes" | sed s/include/lib/`
2314 AC_MSG_RESULT(Corrected X libraries to $x_libraries)
2315 X_LIBS="$X_LIBS -L$x_libraries"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00002316 if test "$vim_cv_uname_output" = SunOS &&
2317 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002318 X_LIBS="$X_LIBS -R $x_libraries"
2319 fi
2320 fi
2321
2322 if test -d "$x_libraries" && test ! -d "$x_includes"; then
2323 x_includes=`echo "$x_libraries" | sed s/lib/include/`
2324 AC_MSG_RESULT(Corrected X includes to $x_includes)
2325 X_CFLAGS="$X_CFLAGS -I$x_includes"
2326 fi
2327
2328 dnl Remove "-I/usr/include " from X_CFLAGS, should not be needed.
2329 X_CFLAGS="`echo $X_CFLAGS\ | sed 's%-I/usr/include %%'`"
2330 dnl Remove "-L/usr/lib " from X_LIBS, should not be needed.
2331 X_LIBS="`echo $X_LIBS\ | sed 's%-L/usr/lib %%'`"
2332 dnl Same for "-R/usr/lib ".
2333 X_LIBS="`echo $X_LIBS\ | sed -e 's%-R/usr/lib %%' -e 's%-R /usr/lib %%'`"
2334
2335
2336 dnl Check if the X11 header files are correctly installed. On some systems
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002337 dnl Xlib.h includes files that don't exist. On some systems X11/Intrinsic.h
2338 dnl is missing.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002339 AC_MSG_CHECKING(if X11 header files can be found)
2340 cflags_save=$CFLAGS
2341 CFLAGS="$CFLAGS $X_CFLAGS"
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002342 AC_TRY_COMPILE([#include <X11/Xlib.h>
2343#include <X11/Intrinsic.h>], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002344 AC_MSG_RESULT(yes),
2345 AC_MSG_RESULT(no); no_x=yes)
2346 CFLAGS=$cflags_save
2347
2348 if test "${no_x-no}" = yes; then
2349 with_x=no
2350 else
2351 AC_DEFINE(HAVE_X11)
2352 X_LIB="-lXt -lX11";
2353 AC_SUBST(X_LIB)
2354
2355 ac_save_LDFLAGS="$LDFLAGS"
2356 LDFLAGS="-L$x_libraries $LDFLAGS"
2357
2358 dnl Check for -lXdmcp (needed on SunOS 4.1.4)
2359 dnl For HP-UX 10.20 it must be before -lSM -lICE
2360 AC_CHECK_LIB(Xdmcp, _XdmcpAuthDoIt, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lXdmcp"],,
2361 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXdmcp])
2362
2363 dnl Some systems need -lnsl -lsocket when testing for ICE.
2364 dnl The check above doesn't do this, try here (again). Also needed to get
2365 dnl them after Xdmcp. link.sh will remove them when not needed.
2366 dnl Check for other function than above to avoid the cached value
2367 AC_CHECK_LIB(ICE, IceOpenConnection,
2368 [X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE"],, [$X_EXTRA_LIBS])
2369
2370 dnl Check for -lXpm (needed for some versions of Motif)
2371 LDFLAGS="$X_LIBS $ac_save_LDFLAGS"
2372 AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [X_PRE_LIBS="$X_PRE_LIBS -lXpm"],,
2373 [-lXt $X_PRE_LIBS -lXpm -lX11 $X_EXTRA_LIBS])
2374
2375 dnl Check that the X11 header files don't use implicit declarations
2376 AC_MSG_CHECKING(if X11 header files implicitly declare return values)
2377 cflags_save=$CFLAGS
Bram Moolenaard1864592013-05-04 04:40:15 +02002378 dnl -Werror is GCC only, others like Solaris Studio might not like it
2379 if test "$GCC" = yes; then
2380 CFLAGS="$CFLAGS $X_CFLAGS -Werror"
2381 else
2382 CFLAGS="$CFLAGS $X_CFLAGS"
2383 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002384 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2385 AC_MSG_RESULT(no),
2386 CFLAGS="$CFLAGS -Wno-implicit-int"
2387 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2388 AC_MSG_RESULT(yes); cflags_save="$cflags_save -Wno-implicit-int",
2389 AC_MSG_RESULT(test failed)
2390 )
2391 )
2392 CFLAGS=$cflags_save
2393
2394 LDFLAGS="$ac_save_LDFLAGS"
2395
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002396 AC_MSG_CHECKING(size of wchar_t is 2 bytes)
2397 AC_CACHE_VAL(ac_cv_small_wchar_t,
2398 [AC_TRY_RUN([
2399#include <X11/Xlib.h>
2400#if STDC_HEADERS
2401# include <stdlib.h>
2402# include <stddef.h>
2403#endif
2404 main()
2405 {
2406 if (sizeof(wchar_t) <= 2)
2407 exit(1);
2408 exit(0);
2409 }],
2410 ac_cv_small_wchar_t="no",
2411 ac_cv_small_wchar_t="yes",
2412 AC_MSG_ERROR(failed to compile test program))])
2413 AC_MSG_RESULT($ac_cv_small_wchar_t)
2414 if test "x$ac_cv_small_wchar_t" = "xyes" ; then
2415 AC_DEFINE(SMALL_WCHAR_T)
2416 fi
2417
Bram Moolenaar071d4272004-06-13 20:20:40 +00002418 fi
2419fi
2420
Bram Moolenaard2a05492018-07-27 22:35:15 +02002421dnl Check if --with-x was given but it doesn't work.
2422if test "x$with_x" = xno -a "x$with_x_arg" = xyes; then
2423 AC_MSG_ERROR([could not configure X])
2424fi
2425
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002426test "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 +00002427
2428AC_MSG_CHECKING(--enable-gui argument)
2429AC_ARG_ENABLE(gui,
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002430 [ --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 +00002431
2432dnl Canonicalize the --enable-gui= argument so that it can be easily compared.
2433dnl Do not use character classes for portability with old tools.
2434enable_gui_canon=`echo "_$enable_gui" | \
2435 sed 's/[[ _+-]]//g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
2436
2437dnl Skip everything by default.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002438SKIP_GTK2=YES
Bram Moolenaar1858a842016-02-23 22:30:31 +01002439SKIP_GTK3=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002440SKIP_GNOME=YES
2441SKIP_MOTIF=YES
2442SKIP_ATHENA=YES
2443SKIP_NEXTAW=YES
2444SKIP_PHOTON=YES
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002445SKIP_HAIKU=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002446GUITYPE=NONE
2447
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002448if test "x$HAIKU" = "xyes"; then
2449 SKIP_HAIKU=
2450 case "$enable_gui_canon" in
2451 no) AC_MSG_RESULT(no GUI support)
2452 SKIP_HAIKU=YES ;;
2453 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
2454 auto) AC_MSG_RESULT(auto - automatic GUI support) ;;
2455 haiku) AC_MSG_RESULT(Haiku GUI support) ;;
2456 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2457 SKIP_HAIKU=YES ;;
2458 esac
2459elif test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002460 SKIP_PHOTON=
2461 case "$enable_gui_canon" in
2462 no) AC_MSG_RESULT(no GUI support)
2463 SKIP_PHOTON=YES ;;
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002464 yes|""|auto) AC_MSG_RESULT(automatic GUI support)
2465 gui_auto=yes ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002466 photon) AC_MSG_RESULT(Photon GUI support) ;;
2467 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2468 SKIP_PHOTON=YES ;;
2469 esac
2470
Bram Moolenaar040f9752020-08-11 23:08:48 +02002471elif test "x$MACOS_X" = "xyes" -a "x$with_x" = "xno" ; then
2472 case "$enable_gui_canon" in
2473 no) AC_MSG_RESULT(no GUI support) ;;
2474 yes|"") AC_MSG_RESULT(yes - automatic GUI support)
2475 gui_auto=yes ;;
2476 auto) AC_MSG_RESULT(auto - disable GUI support for Mac OS) ;;
Bram Moolenaarbe7529e2020-08-13 21:05:39 +02002477 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
Bram Moolenaar040f9752020-08-11 23:08:48 +02002478 esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00002479else
2480
Bram Moolenaar071d4272004-06-13 20:20:40 +00002481 case "$enable_gui_canon" in
2482 no|none) AC_MSG_RESULT(no GUI support) ;;
2483 yes|""|auto) AC_MSG_RESULT(yes/auto - automatic GUI support)
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002484 gui_auto=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002485 SKIP_GTK2=
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002486 SKIP_GTK3=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002487 SKIP_GNOME=
2488 SKIP_MOTIF=
2489 SKIP_ATHENA=
Bram Moolenaar097148e2020-08-11 21:58:20 +02002490 SKIP_NEXTAW=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002491 gtk2) AC_MSG_RESULT(GTK+ 2.x GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002492 SKIP_GTK2=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002493 gnome2) AC_MSG_RESULT(GNOME 2.x GUI support)
2494 SKIP_GNOME=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002495 SKIP_GTK2=;;
Bram Moolenaar98921892016-02-23 17:14:37 +01002496 gtk3) AC_MSG_RESULT(GTK+ 3.x GUI support)
2497 SKIP_GTK3=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002498 motif) AC_MSG_RESULT(Motif GUI support)
2499 SKIP_MOTIF=;;
2500 athena) AC_MSG_RESULT(Athena GUI support)
2501 SKIP_ATHENA=;;
2502 nextaw) AC_MSG_RESULT(neXtaw GUI support)
2503 SKIP_NEXTAW=;;
2504 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
2505 esac
2506
2507fi
2508
Bram Moolenaar071d4272004-06-13 20:20:40 +00002509if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \
2510 -a "$enable_gui_canon" != "gnome2"; then
2511 AC_MSG_CHECKING(whether or not to look for GTK+ 2)
2512 AC_ARG_ENABLE(gtk2-check,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002513 [ --enable-gtk2-check If auto-select GUI, check for GTK+ 2 [default=yes]],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002514 , enable_gtk2_check="yes")
2515 AC_MSG_RESULT($enable_gtk2_check)
2516 if test "x$enable_gtk2_check" = "xno"; then
2517 SKIP_GTK2=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002518 SKIP_GNOME=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002519 fi
2520fi
2521
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002522if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002523 AC_MSG_CHECKING(whether or not to look for GNOME)
2524 AC_ARG_ENABLE(gnome-check,
2525 [ --enable-gnome-check If GTK GUI, check for GNOME [default=no]],
2526 , enable_gnome_check="no")
2527 AC_MSG_RESULT($enable_gnome_check)
2528 if test "x$enable_gnome_check" = "xno"; then
2529 SKIP_GNOME=YES
2530 fi
2531fi
2532
Bram Moolenaar98921892016-02-23 17:14:37 +01002533if test "x$SKIP_GTK3" != "xYES" -a "$enable_gui_canon" != "gtk3"; then
2534 AC_MSG_CHECKING(whether or not to look for GTK+ 3)
2535 AC_ARG_ENABLE(gtk3-check,
2536 [ --enable-gtk3-check If auto-select GUI, check for GTK+ 3 [default=yes]],
2537 , enable_gtk3_check="yes")
2538 AC_MSG_RESULT($enable_gtk3_check)
2539 if test "x$enable_gtk3_check" = "xno"; then
2540 SKIP_GTK3=YES
2541 fi
2542fi
2543
Bram Moolenaar071d4272004-06-13 20:20:40 +00002544if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then
2545 AC_MSG_CHECKING(whether or not to look for Motif)
2546 AC_ARG_ENABLE(motif-check,
2547 [ --enable-motif-check If auto-select GUI, check for Motif [default=yes]],
2548 , enable_motif_check="yes")
2549 AC_MSG_RESULT($enable_motif_check)
2550 if test "x$enable_motif_check" = "xno"; then
2551 SKIP_MOTIF=YES
2552 fi
2553fi
2554
2555if test "x$SKIP_ATHENA" != "xYES" -a "$enable_gui_canon" != "athena"; then
2556 AC_MSG_CHECKING(whether or not to look for Athena)
2557 AC_ARG_ENABLE(athena-check,
2558 [ --enable-athena-check If auto-select GUI, check for Athena [default=yes]],
2559 , enable_athena_check="yes")
2560 AC_MSG_RESULT($enable_athena_check)
2561 if test "x$enable_athena_check" = "xno"; then
2562 SKIP_ATHENA=YES
2563 fi
2564fi
2565
2566if test "x$SKIP_NEXTAW" != "xYES" -a "$enable_gui_canon" != "nextaw"; then
2567 AC_MSG_CHECKING(whether or not to look for neXtaw)
2568 AC_ARG_ENABLE(nextaw-check,
2569 [ --enable-nextaw-check If auto-select GUI, check for neXtaw [default=yes]],
2570 , enable_nextaw_check="yes")
2571 AC_MSG_RESULT($enable_nextaw_check);
2572 if test "x$enable_nextaw_check" = "xno"; then
2573 SKIP_NEXTAW=YES
2574 fi
2575fi
2576
Bram Moolenaar071d4272004-06-13 20:20:40 +00002577dnl define an autoconf function to check for a specified version of GTK, and
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002578dnl try to compile/link a GTK program.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002579dnl
2580dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002581dnl Test for GTK, and define GTK_CFLAGS, GTK_LIBDIR and GTK_LIBS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002582dnl
2583AC_DEFUN(AM_PATH_GTK,
2584[
2585 if test "X$GTK_CONFIG" != "Xno" -o "X$PKG_CONFIG" != "Xno"; then
2586 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00002587 no_gtk=""
2588 if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2589 && $PKG_CONFIG --exists gtk+-2.0; then
2590 {
Bram Moolenaar98921892016-02-23 17:14:37 +01002591 min_gtk_version=ifelse([$1], ,2.2.0,$1)
2592 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002593 dnl We should be using PKG_CHECK_MODULES() instead of this hack.
2594 dnl But I guess the dependency on pkgconfig.m4 is not wanted or
2595 dnl something like that.
2596 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0`
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002597 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-2.0`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002598 GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0`
2599 gtk_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2600 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2601 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2602 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2603 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2604 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2605 }
Bram Moolenaar98921892016-02-23 17:14:37 +01002606 elif (test "X$SKIP_GTK3" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2607 && $PKG_CONFIG --exists gtk+-3.0; then
2608 {
2609 min_gtk_version=ifelse([$1], ,3.0.0,$1)
2610 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
2611
2612 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-3.0`
2613 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-3.0`
2614 GTK_LIBS=`$PKG_CONFIG --libs gtk+-3.0`
2615 gtk_major_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2616 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2617 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2618 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2619 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2620 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2621 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002622 else
Bram Moolenaar67876de2021-01-12 20:51:24 +01002623 dnl Put some text before the "no" to hint at installing the gtk-dev
2624 dnl packages.
2625 AC_MSG_CHECKING(for GTK -dev package)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002626 no_gtk=yes
2627 fi
2628
2629 if test "x$enable_gtktest" = "xyes" -a "x$no_gtk" = "x"; then
2630 {
2631 ac_save_CFLAGS="$CFLAGS"
2632 ac_save_LIBS="$LIBS"
2633 CFLAGS="$CFLAGS $GTK_CFLAGS"
2634 LIBS="$LIBS $GTK_LIBS"
2635
2636 dnl
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002637 dnl Now check if the installed GTK is sufficiently new.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002638 dnl
2639 rm -f conf.gtktest
2640 AC_TRY_RUN([
2641#include <gtk/gtk.h>
2642#include <stdio.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00002643#if STDC_HEADERS
2644# include <stdlib.h>
2645# include <stddef.h>
2646#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002647
2648int
2649main ()
2650{
2651int major, minor, micro;
2652char *tmp_version;
2653
2654system ("touch conf.gtktest");
2655
2656/* HP/UX 9 (%@#!) writes to sscanf strings */
2657tmp_version = g_strdup("$min_gtk_version");
2658if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
2659 printf("%s, bad version string\n", "$min_gtk_version");
2660 exit(1);
2661 }
2662
2663if ((gtk_major_version > major) ||
2664 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
2665 ((gtk_major_version == major) && (gtk_minor_version == minor) &&
2666 (gtk_micro_version >= micro)))
2667{
2668 return 0;
2669}
2670return 1;
2671}
2672],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
2673 CFLAGS="$ac_save_CFLAGS"
2674 LIBS="$ac_save_LIBS"
2675 }
2676 fi
2677 if test "x$no_gtk" = x ; then
2678 if test "x$enable_gtktest" = "xyes"; then
2679 AC_MSG_RESULT(yes; found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2680 else
2681 AC_MSG_RESULT(found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2682 fi
2683 ifelse([$2], , :, [$2])
2684 else
2685 {
2686 AC_MSG_RESULT(no)
2687 GTK_CFLAGS=""
2688 GTK_LIBS=""
2689 ifelse([$3], , :, [$3])
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002690 if test "$fail_if_missing" = "yes" -a "X$gui_auto" != "Xyes"; then
2691 AC_MSG_ERROR([could not configure GTK])
2692 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002693 }
2694 fi
2695 }
2696 else
2697 GTK_CFLAGS=""
2698 GTK_LIBS=""
2699 ifelse([$3], , :, [$3])
2700 fi
2701 AC_SUBST(GTK_CFLAGS)
2702 AC_SUBST(GTK_LIBS)
2703 rm -f conf.gtktest
2704])
2705
2706dnl ---------------------------------------------------------------------------
2707dnl gnome
2708dnl ---------------------------------------------------------------------------
2709AC_DEFUN([GNOME_INIT_HOOK],
2710[
2711 AC_SUBST(GNOME_LIBS)
2712 AC_SUBST(GNOME_LIBDIR)
2713 AC_SUBST(GNOME_INCLUDEDIR)
2714
2715 AC_ARG_WITH(gnome-includes,
2716 [ --with-gnome-includes=DIR Specify location of GNOME headers],
2717 [CFLAGS="$CFLAGS -I$withval"]
2718 )
2719
2720 AC_ARG_WITH(gnome-libs,
2721 [ --with-gnome-libs=DIR Specify location of GNOME libs],
2722 [LDFLAGS="$LDFLAGS -L$withval" gnome_prefix=$withval]
2723 )
2724
2725 AC_ARG_WITH(gnome,
2726 [ --with-gnome Specify prefix for GNOME files],
2727 if test x$withval = xyes; then
2728 want_gnome=yes
2729 ifelse([$1], [], :, [$1])
2730 else
2731 if test "x$withval" = xno; then
2732 want_gnome=no
2733 else
2734 want_gnome=yes
2735 LDFLAGS="$LDFLAGS -L$withval/lib"
2736 CFLAGS="$CFLAGS -I$withval/include"
2737 gnome_prefix=$withval/lib
2738 fi
2739 fi,
2740 want_gnome=yes)
2741
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002742 if test "x$want_gnome" = xyes; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002743 {
2744 AC_MSG_CHECKING(for libgnomeui-2.0)
2745 if $PKG_CONFIG --exists libgnomeui-2.0; then
2746 AC_MSG_RESULT(yes)
2747 GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0`
2748 GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0`
2749 GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0`
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002750
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002751 dnl On FreeBSD we need -pthread but pkg-config doesn't include it.
2752 dnl This might not be the right way but it works for me...
2753 AC_MSG_CHECKING(for FreeBSD)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00002754 if test "$vim_cv_uname_output" = FreeBSD; then
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002755 AC_MSG_RESULT(yes, adding -pthread)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002756 GNOME_INCLUDEDIR="$GNOME_INCLUDEDIR -D_THREAD_SAFE"
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002757 GNOME_LIBS="$GNOME_LIBS -pthread"
2758 else
2759 AC_MSG_RESULT(no)
2760 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002761 $1
2762 else
2763 AC_MSG_RESULT(not found)
2764 if test "x$2" = xfail; then
2765 AC_MSG_ERROR(Could not find libgnomeui-2.0 via pkg-config)
2766 fi
2767 fi
2768 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002769 fi
2770])
2771
2772AC_DEFUN([GNOME_INIT],[
2773 GNOME_INIT_HOOK([],fail)
2774])
2775
Bram Moolenaar427f5b62019-06-09 13:43:51 +02002776if test "X$PKG_CONFIG" = "X"; then
2777 AC_PATH_TOOL(PKG_CONFIG, pkg-config, no)
2778fi
2779
Bram Moolenaar071d4272004-06-13 20:20:40 +00002780
2781dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002782dnl Check for GTK2. If it fails, then continue on for Motif as before...
Bram Moolenaar071d4272004-06-13 20:20:40 +00002783dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002784if test -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002785
2786 AC_MSG_CHECKING(--disable-gtktest argument)
2787 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2788 , enable_gtktest=yes)
2789 if test "x$enable_gtktest" = "xyes" ; then
2790 AC_MSG_RESULT(gtk test enabled)
2791 else
2792 AC_MSG_RESULT(gtk test disabled)
2793 fi
2794
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002795 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002796 dnl First try finding version 2.2.0 or later. The 2.0.x series has
2797 dnl problems (bold fonts, --remote doesn't work).
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002798 dnl Disable checking for GTK3 here, otherwise it's found when GTK2 is not
2799 dnl found.
2800 save_skip_gtk3=$SKIP_GTK3
2801 SKIP_GTK3=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002802 AM_PATH_GTK(2.2.0,
2803 [GUI_LIB_LOC="$GTK_LIBDIR"
2804 GTK_LIBNAME="$GTK_LIBS"
2805 GUI_INC_LOC="$GTK_CFLAGS"], )
2806 if test "x$GTK_CFLAGS" != "x"; then
Bram Moolenaar98921892016-02-23 17:14:37 +01002807 SKIP_GTK3=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002808 SKIP_ATHENA=YES
2809 SKIP_NEXTAW=YES
2810 SKIP_MOTIF=YES
2811 GUITYPE=GTK
2812 AC_SUBST(GTK_LIBNAME)
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002813 else
2814 SKIP_GTK3=$save_skip_gtk3
Bram Moolenaar071d4272004-06-13 20:20:40 +00002815 fi
2816 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002817 if test "x$GUITYPE" = "xGTK"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002818 dnl
2819 dnl if GTK exists, then check for GNOME.
2820 dnl
2821 if test -z "$SKIP_GNOME"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002822 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002823 GNOME_INIT_HOOK([have_gnome=yes])
2824 if test "x$have_gnome" = xyes ; then
2825 AC_DEFINE(FEAT_GUI_GNOME)
2826 GUI_INC_LOC="$GUI_INC_LOC $GNOME_INCLUDEDIR"
2827 GTK_LIBNAME="$GTK_LIBNAME $GNOME_LIBDIR $GNOME_LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002828 fi
2829 }
2830 fi
2831 fi
2832fi
2833
Bram Moolenaar98921892016-02-23 17:14:37 +01002834
2835dnl ---------------------------------------------------------------------------
2836dnl Check for GTK3.
2837dnl ---------------------------------------------------------------------------
2838if test -z "$SKIP_GTK3"; then
2839
2840 AC_MSG_CHECKING(--disable-gtktest argument)
2841 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2842 , enable_gtktest=yes)
2843 if test "x$enable_gtktest" = "xyes" ; then
2844 AC_MSG_RESULT(gtk test enabled)
2845 else
2846 AC_MSG_RESULT(gtk test disabled)
2847 fi
2848
Bram Moolenaar98921892016-02-23 17:14:37 +01002849 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002850 save_skip_gtk2=$SKIP_GTK2
2851 SKIP_GTK2=YES
Bram Moolenaar98921892016-02-23 17:14:37 +01002852 AM_PATH_GTK(3.0.0,
2853 [GUI_LIB_LOC="$GTK_LIBDIR"
2854 GTK_LIBNAME="$GTK_LIBS"
2855 GUI_INC_LOC="$GTK_CFLAGS"], )
2856 if test "x$GTK_CFLAGS" != "x"; then
2857 SKIP_GTK2=YES
2858 SKIP_GNOME=YES
2859 SKIP_ATHENA=YES
2860 SKIP_NEXTAW=YES
2861 SKIP_MOTIF=YES
2862 GUITYPE=GTK
2863 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar98921892016-02-23 17:14:37 +01002864 AC_DEFINE(USE_GTK3)
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002865 else
2866 SKIP_GTK2=$save_skip_gtk2
Bram Moolenaar98921892016-02-23 17:14:37 +01002867 fi
2868 fi
2869fi
2870
Bram Moolenaard2e03f02016-01-02 22:46:36 +01002871dnl Check the version of Gdk-Pixbuf. If the version is 2.31 or later and
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002872dnl glib-compile-resources is found in PATH, use GResource.
2873if test "x$GUITYPE" = "xGTK"; then
2874 AC_MSG_CHECKING([version of Gdk-Pixbuf])
2875 gdk_pixbuf_version=`$PKG_CONFIG --modversion gdk-pixbuf-2.0`
2876 if test "x$gdk_pixbuf_version" != x ; then
2877 gdk_pixbuf_version_minor=`echo $gdk_pixbuf_version | \
2878 sed -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/'`
2879 if test "x$gdk_pixbuf_version_minor" != x -a \
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002880 $gdk_pixbuf_version_minor -ge 31 ; then
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002881 AC_MSG_RESULT([OK.])
2882 AC_PATH_PROG(GLIB_COMPILE_RESOURCES,[glib-compile-resources],no)
2883 AC_MSG_CHECKING([glib-compile-resources])
2884 if test "x$GLIB_COMPILE_RESOURCES" = xno ; then
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002885 GLIB_COMPILE_RESOURCES=""
2886 AC_MSG_RESULT([cannot be found in PATH.])
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002887 else
2888 AC_MSG_RESULT([usable.])
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002889 AC_DEFINE(USE_GRESOURCE)
2890 GRESOURCE_SRC="auto/gui_gtk_gresources.c"
2891 GRESOURCE_OBJ="objects/gui_gtk_gresources.o"
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002892 fi
2893 else
2894 AC_MSG_RESULT([not usable.])
2895 fi
2896 else
2897 AC_MSG_RESULT([cannot obtain from pkg_config.])
2898 fi
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002899
2900 AC_MSG_CHECKING([--disable-icon-cache-update argument])
2901 AC_ARG_ENABLE(icon_cache_update,
2902 [ --disable-icon-cache-update update disabled],
2903 [],
2904 [enable_icon_cache_update="yes"])
2905 if test "$enable_icon_cache_update" = "yes"; then
2906 AC_MSG_RESULT([not set])
2907 AC_PATH_PROG(GTK_UPDATE_ICON_CACHE,[gtk-update-icon-cache],no)
2908 if test "x$GTK_UPDATE_ICON_CACHE" = "xno" ; then
2909 AC_MSG_RESULT([not found in PATH.])
2910 fi
2911 else
2912 AC_MSG_RESULT([update disabled])
2913 fi
2914
2915 AC_MSG_CHECKING([--disable-desktop-database-update argument])
2916 AC_ARG_ENABLE(desktop_database_update,
2917 [ --disable-desktop-database-update update disabled],
2918 [],
2919 [enable_desktop_database_update="yes"])
2920 if test "$enable_desktop_database_update" = "yes"; then
2921 AC_MSG_RESULT([not set])
2922 AC_PATH_PROG(UPDATE_DESKTOP_DATABASE,[update-desktop-database],no)
2923 if test "x$UPDATE_DESKTOP_DATABASE" = "xno" ; then
2924 AC_MSG_RESULT([not found in PATH.])
2925 fi
2926 else
2927 AC_MSG_RESULT([update disabled])
2928 fi
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002929fi
2930AC_SUBST(GLIB_COMPILE_RESOURCES)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002931AC_SUBST(GRESOURCE_SRC)
2932AC_SUBST(GRESOURCE_OBJ)
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002933AC_SUBST(GTK_UPDATE_ICON_CACHE)
2934AC_SUBST(UPDATE_DESKTOP_DATABASE)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002935
Bram Moolenaar071d4272004-06-13 20:20:40 +00002936dnl Check for Motif include files location.
2937dnl The LAST one found is used, this makes the highest version to be used,
2938dnl e.g. when Motif1.2 and Motif2.0 are both present.
2939
2940if test -z "$SKIP_MOTIF"; then
2941 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"
2942 dnl Remove "-I" from before $GUI_INC_LOC if it's there
2943 GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`"
2944
2945 AC_MSG_CHECKING(for location of Motif GUI includes)
2946 gui_includes="`echo $x_includes|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC"
2947 GUI_INC_LOC=
2948 for try in $gui_includes; do
2949 if test -f "$try/Xm/Xm.h"; then
2950 GUI_INC_LOC=$try
2951 fi
2952 done
2953 if test -n "$GUI_INC_LOC"; then
2954 if test "$GUI_INC_LOC" = /usr/include; then
2955 GUI_INC_LOC=
2956 AC_MSG_RESULT(in default path)
2957 else
2958 AC_MSG_RESULT($GUI_INC_LOC)
2959 fi
2960 else
2961 AC_MSG_RESULT(<not found>)
2962 SKIP_MOTIF=YES
2963 fi
2964fi
2965
2966dnl Check for Motif library files location. In the same order as the include
2967dnl files, to avoid a mixup if several versions are present
2968
2969if test -z "$SKIP_MOTIF"; then
2970 AC_MSG_CHECKING(--with-motif-lib argument)
2971 AC_ARG_WITH(motif-lib,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002972 [ --with-motif-lib=STRING Library for Motif ],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002973 [ MOTIF_LIBNAME="${withval}" ] )
2974
2975 if test -n "$MOTIF_LIBNAME"; then
2976 AC_MSG_RESULT($MOTIF_LIBNAME)
2977 GUI_LIB_LOC=
2978 else
2979 AC_MSG_RESULT(no)
2980
2981 dnl Remove "-L" from before $GUI_LIB_LOC if it's there
2982 GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
2983
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002984 dnl Ubuntu has libXm.so in /usr/lib/i386-linux-gnu and elsewhere. The
2985 dnl linker will figure out which one to use, we only check if one exists.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002986 AC_MSG_CHECKING(for location of Motif GUI libs)
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002987 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 +00002988 GUI_LIB_LOC=
2989 for try in $gui_libs; do
Bram Moolenaar325b7a22004-07-05 15:58:32 +00002990 for libtry in "$try"/libXm.a "$try"/libXm.so* "$try"/libXm.sl "$try"/libXm.dylib; do
Bram Moolenaar071d4272004-06-13 20:20:40 +00002991 if test -f "$libtry"; then
2992 GUI_LIB_LOC=$try
2993 fi
2994 done
2995 done
2996 if test -n "$GUI_LIB_LOC"; then
2997 dnl Remove /usr/lib, it causes trouble on some systems
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002998 if test "$GUI_LIB_LOC" = /usr/lib \
2999 -o "$GUI_LIB_LOC" = /usr/lib/i386-linux-gnu \
3000 -o "$GUI_LIB_LOC" = /usr/lib/x86_64-linux-gnu; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003001 GUI_LIB_LOC=
3002 AC_MSG_RESULT(in default path)
3003 else
3004 if test -n "$GUI_LIB_LOC"; then
3005 AC_MSG_RESULT($GUI_LIB_LOC)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00003006 if test "$vim_cv_uname_output" = SunOS &&
3007 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003008 GUI_LIB_LOC="$GUI_LIB_LOC -R $GUI_LIB_LOC"
3009 fi
3010 fi
3011 fi
3012 MOTIF_LIBNAME=-lXm
3013 else
3014 AC_MSG_RESULT(<not found>)
3015 SKIP_MOTIF=YES
3016 fi
3017 fi
3018fi
3019
3020if test -z "$SKIP_MOTIF"; then
3021 SKIP_ATHENA=YES
3022 SKIP_NEXTAW=YES
3023 GUITYPE=MOTIF
3024 AC_SUBST(MOTIF_LIBNAME)
3025fi
3026
3027dnl Check if the Athena files can be found
3028
3029GUI_X_LIBS=
3030
3031if test -z "$SKIP_ATHENA"; then
3032 AC_MSG_CHECKING(if Athena header files can be found)
3033 cflags_save=$CFLAGS
3034 CFLAGS="$CFLAGS $X_CFLAGS"
3035 AC_TRY_COMPILE([
3036#include <X11/Intrinsic.h>
3037#include <X11/Xaw/Paned.h>], ,
3038 AC_MSG_RESULT(yes),
3039 AC_MSG_RESULT(no); SKIP_ATHENA=YES )
3040 CFLAGS=$cflags_save
3041fi
3042
3043if test -z "$SKIP_ATHENA"; then
3044 GUITYPE=ATHENA
3045fi
3046
3047if test -z "$SKIP_NEXTAW"; then
3048 AC_MSG_CHECKING(if neXtaw header files can be found)
3049 cflags_save=$CFLAGS
3050 CFLAGS="$CFLAGS $X_CFLAGS"
3051 AC_TRY_COMPILE([
3052#include <X11/Intrinsic.h>
3053#include <X11/neXtaw/Paned.h>], ,
3054 AC_MSG_RESULT(yes),
3055 AC_MSG_RESULT(no); SKIP_NEXTAW=YES )
3056 CFLAGS=$cflags_save
3057fi
3058
3059if test -z "$SKIP_NEXTAW"; then
3060 GUITYPE=NEXTAW
3061fi
3062
3063if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
3064 dnl Prepend -I and -L to $GUI_INC_LOC and $GUI_LIB_LOC if not empty
3065 dnl Avoid adding it when it twice
3066 if test -n "$GUI_INC_LOC"; then
3067 GUI_INC_LOC=-I"`echo $GUI_INC_LOC|sed 's%-I%%'`"
3068 fi
3069 if test -n "$GUI_LIB_LOC"; then
3070 GUI_LIB_LOC=-L"`echo $GUI_LIB_LOC|sed 's%-L%%'`"
3071 fi
3072
3073 dnl Check for -lXext and then for -lXmu
3074 ldflags_save=$LDFLAGS
3075 LDFLAGS="$X_LIBS $LDFLAGS"
3076 AC_CHECK_LIB(Xext, XShapeQueryExtension, [GUI_X_LIBS="-lXext"],,
3077 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3078 dnl For Solaris we need -lw and -ldl before linking with -lXmu works.
3079 AC_CHECK_LIB(w, wslen, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lw"],,
3080 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3081 AC_CHECK_LIB(dl, dlsym, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldl"],,
3082 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3083 AC_CHECK_LIB(Xmu, XmuCreateStippledPixmap, [GUI_X_LIBS="-lXmu $GUI_X_LIBS"],,
3084 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3085 if test -z "$SKIP_MOTIF"; then
3086 AC_CHECK_LIB(Xp, XpEndJob, [GUI_X_LIBS="-lXp $GUI_X_LIBS"],,
3087 [$GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3088 fi
3089 LDFLAGS=$ldflags_save
3090
3091 dnl Execute xmkmf to figure out if -DNARROWPROTO is needed.
3092 AC_MSG_CHECKING(for extra X11 defines)
3093 NARROW_PROTO=
3094 rm -fr conftestdir
3095 if mkdir conftestdir; then
3096 cd conftestdir
3097 cat > Imakefile <<'EOF'
3098acfindx:
3099 @echo 'NARROW_PROTO="${PROTO_DEFINES}"'
3100EOF
3101 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
3102 eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
3103 fi
3104 cd ..
3105 rm -fr conftestdir
3106 fi
3107 if test -z "$NARROW_PROTO"; then
3108 AC_MSG_RESULT(no)
3109 else
3110 AC_MSG_RESULT($NARROW_PROTO)
3111 fi
3112 AC_SUBST(NARROW_PROTO)
3113fi
3114
3115dnl Look for XSMP support - but don't necessarily restrict it to X11 GUIs
3116dnl use the X11 include path
3117if test "$enable_xsmp" = "yes"; then
3118 cppflags_save=$CPPFLAGS
3119 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3120 AC_CHECK_HEADERS(X11/SM/SMlib.h)
3121 CPPFLAGS=$cppflags_save
3122fi
3123
3124
Bram Moolenaar98921892016-02-23 17:14:37 +01003125if 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 +00003126 dnl Check for X11/xpm.h and X11/Sunkeysym.h with the GUI include path
3127 cppflags_save=$CPPFLAGS
3128 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3129 AC_CHECK_HEADERS(X11/xpm.h X11/Sunkeysym.h)
3130
3131 dnl automatically disable XIM when XIMtext isn't in X11/Xlib.h
3132 if test ! "$enable_xim" = "no"; then
3133 AC_MSG_CHECKING(for XIMText in X11/Xlib.h)
3134 AC_EGREP_CPP(XIMText, [#include <X11/Xlib.h>],
3135 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +02003136 AC_MSG_RESULT(no; xim has been disabled); enable_xim="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00003137 fi
3138 CPPFLAGS=$cppflags_save
3139
Bram Moolenaar54612582019-11-21 17:13:31 +01003140 dnl automatically enable XIM in the GUI
3141 if test "$enable_xim" = "auto" -a "x$GUITYPE" != "xNONE" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003142 AC_MSG_RESULT(X GUI selected; xim has been enabled)
3143 enable_xim="yes"
3144 fi
3145fi
3146
3147if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
3148 cppflags_save=$CPPFLAGS
3149 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00003150dnl Xmu/Editres.h may exist but can only be used after including Intrinsic.h
3151 AC_MSG_CHECKING([for X11/Xmu/Editres.h])
3152 AC_TRY_COMPILE([
3153#include <X11/Intrinsic.h>
3154#include <X11/Xmu/Editres.h>],
3155 [int i; i = 0;],
3156 AC_MSG_RESULT(yes)
3157 AC_DEFINE(HAVE_X11_XMU_EDITRES_H),
3158 AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003159 CPPFLAGS=$cppflags_save
3160fi
3161
3162dnl Only use the Xm directory when compiling Motif, don't use it for Athena
3163if test -z "$SKIP_MOTIF"; then
3164 cppflags_save=$CPPFLAGS
3165 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003166 if test "$zOSUnix" = "yes"; then
3167 xmheader="Xm/Xm.h"
3168 else
3169 xmheader="Xm/Xm.h Xm/XpmP.h Xm/JoinSideT.h Xm/TraitP.h Xm/Manager.h
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02003170 Xm/UnhighlightT.h Xm/Notebook.h"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003171 fi
3172 AC_CHECK_HEADERS($xmheader)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003173
Bram Moolenaar77c19352012-06-13 19:19:41 +02003174 if test "x$ac_cv_header_Xm_XpmP_h" = "xyes"; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003175 dnl Solaris uses XpmAttributes_21, very annoying.
3176 AC_MSG_CHECKING([for XpmAttributes_21 in Xm/XpmP.h])
3177 AC_TRY_COMPILE([#include <Xm/XpmP.h>], [XpmAttributes_21 attr;],
3178 AC_MSG_RESULT(yes); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes_21),
3179 AC_MSG_RESULT(no); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
3180 )
3181 else
Bram Moolenaar57657d82006-04-21 22:12:41 +00003182 AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003183 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003184 CPPFLAGS=$cppflags_save
3185fi
3186
3187if test "x$GUITYPE" = "xNONE" -a "$enable_xim" = "yes"; then
3188 AC_MSG_RESULT(no GUI selected; xim has been disabled)
3189 enable_xim="no"
3190fi
3191if test "x$GUITYPE" = "xNONE" -a "$enable_fontset" = "yes"; then
3192 AC_MSG_RESULT(no GUI selected; fontset has been disabled)
3193 enable_fontset="no"
3194fi
Bram Moolenaar182c5be2010-06-25 05:37:59 +02003195if test "x$GUITYPE:$enable_fontset" = "xGTK:yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003196 AC_MSG_RESULT(GTK+ 2 GUI selected; fontset has been disabled)
3197 enable_fontset="no"
3198fi
3199
Bram Moolenaarb3f74062020-02-26 16:16:53 +01003200dnl There is no test for the Haiku GUI, if it's selected it's used
3201if test -z "$SKIP_HAIKU"; then
3202 GUITYPE=HAIKUGUI
3203fi
3204
Bram Moolenaar071d4272004-06-13 20:20:40 +00003205if test -z "$SKIP_PHOTON"; then
3206 GUITYPE=PHOTONGUI
3207fi
3208
3209AC_SUBST(GUI_INC_LOC)
3210AC_SUBST(GUI_LIB_LOC)
3211AC_SUBST(GUITYPE)
3212AC_SUBST(GUI_X_LIBS)
3213
3214if test "$enable_workshop" = "yes" -a -n "$SKIP_MOTIF"; then
3215 AC_MSG_ERROR([cannot use workshop without Motif])
3216fi
3217
3218dnl defining FEAT_XIM and FEAT_XFONTSET is delayed, so that they can be disabled
3219if test "$enable_xim" = "yes"; then
3220 AC_DEFINE(FEAT_XIM)
3221fi
3222if test "$enable_fontset" = "yes"; then
3223 AC_DEFINE(FEAT_XFONTSET)
3224fi
3225
3226
3227dnl ---------------------------------------------------------------------------
3228dnl end of GUI-checking
3229dnl ---------------------------------------------------------------------------
3230
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003231AC_MSG_CHECKING([for /proc link to executable])
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003232if test -L "/proc/self/exe"; then
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003233 dnl Linux
3234 AC_MSG_RESULT([/proc/self/exe])
3235 AC_DEFINE(PROC_EXE_LINK, "/proc/self/exe")
3236elif test -L "/proc/self/path/a.out"; then
3237 dnl Solaris
3238 AC_MSG_RESULT([/proc/self/path/a.out])
3239 AC_DEFINE(PROC_EXE_LINK, "/proc/self/path/a.out")
3240elif test -L "/proc/curproc/file"; then
3241 dnl FreeBSD
3242 AC_MSG_RESULT([/proc/curproc/file])
3243 AC_DEFINE(PROC_EXE_LINK, "/proc/curproc/file")
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003244else
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003245 AC_MSG_RESULT(no)
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003246fi
3247
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003248dnl Check for Cygwin, which needs an extra source file if not using X11
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003249AC_MSG_CHECKING(for CYGWIN or MSYS environment)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00003250case $vim_cv_uname_output in
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003251 CYGWIN*|MSYS*) CYGWIN=yes; AC_MSG_RESULT(yes)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003252 AC_MSG_CHECKING(for CYGWIN clipboard support)
3253 if test "x$with_x" = "xno" ; then
3254 OS_EXTRA_SRC=winclip.c; OS_EXTRA_OBJ=objects/winclip.o
3255 AC_MSG_RESULT(yes)
3256 AC_DEFINE(FEAT_CYGWIN_WIN32_CLIPBOARD)
3257 else
3258 AC_MSG_RESULT(no - using X11)
3259 fi ;;
3260
3261 *) CYGWIN=no; AC_MSG_RESULT(no);;
3262esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00003263
Bram Moolenaar071d4272004-06-13 20:20:40 +00003264dnl Checks for libraries and include files.
3265
Bram Moolenaar446cb832008-06-24 21:56:24 +00003266AC_CACHE_CHECK([whether toupper is broken], [vim_cv_toupper_broken],
3267 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003268 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003269#include "confdefs.h"
3270#include <ctype.h>
3271#if STDC_HEADERS
3272# include <stdlib.h>
3273# include <stddef.h>
3274#endif
3275main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003276 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003277 vim_cv_toupper_broken=yes
3278 ],[
3279 vim_cv_toupper_broken=no
3280 ],[
3281 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_toupper_broken')
3282 ])])
3283
3284if test "x$vim_cv_toupper_broken" = "xyes" ; then
3285 AC_DEFINE(BROKEN_TOUPPER)
3286fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003287
3288AC_MSG_CHECKING(whether __DATE__ and __TIME__ work)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003289AC_TRY_COMPILE([#include <stdio.h>], [printf("(" __DATE__ " " __TIME__ ")");],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003290 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DATE_TIME),
3291 AC_MSG_RESULT(no))
3292
Bram Moolenaar0c094b92009-05-14 20:20:33 +00003293AC_MSG_CHECKING(whether __attribute__((unused)) is allowed)
3294AC_TRY_COMPILE([#include <stdio.h>], [int x __attribute__((unused));],
3295 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ATTRIBUTE_UNUSED),
3296 AC_MSG_RESULT(no))
3297
Bram Moolenaar071d4272004-06-13 20:20:40 +00003298dnl Checks for header files.
3299AC_CHECK_HEADER(elf.h, HAS_ELF=1)
3300dnl AC_CHECK_HEADER(dwarf.h, SVR4=1)
3301if test "$HAS_ELF" = 1; then
3302 AC_CHECK_LIB(elf, main)
3303fi
3304
3305AC_HEADER_DIRENT
3306
Bram Moolenaar071d4272004-06-13 20:20:40 +00003307dnl If sys/wait.h is not found it might still exist but not be POSIX
3308dnl compliant. In that case we define HAVE_UNION_WAIT (for NeXT)
3309if test $ac_cv_header_sys_wait_h = no; then
3310 AC_MSG_CHECKING([for sys/wait.h that defines union wait])
3311 AC_TRY_COMPILE([#include <sys/wait.h>],
3312 [union wait xx, yy; xx = yy],
3313 AC_MSG_RESULT(yes)
3314 AC_DEFINE(HAVE_SYS_WAIT_H)
3315 AC_DEFINE(HAVE_UNION_WAIT),
3316 AC_MSG_RESULT(no))
3317fi
3318
Bram Moolenaar779a7752016-01-30 23:26:34 +01003319AC_CHECK_HEADERS(stdint.h stdlib.h string.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003320 sys/select.h sys/utsname.h termcap.h fcntl.h \
3321 sgtty.h sys/ioctl.h sys/time.h sys/types.h \
3322 termio.h iconv.h inttypes.h langinfo.h math.h \
3323 unistd.h stropts.h errno.h sys/resource.h \
3324 sys/systeminfo.h locale.h sys/stream.h termios.h \
3325 libc.h sys/statfs.h poll.h sys/poll.h pwd.h \
Bram Moolenaar1ecc5e42019-01-26 15:12:55 +01003326 utime.h sys/param.h sys/ptms.h libintl.h libgen.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003327 util/debug.h util/msg18n.h frame.h sys/acl.h \
3328 sys/access.h sys/sysinfo.h wchar.h wctype.h)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003329
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003330dnl sys/ptem.h depends on sys/stream.h on Solaris
3331AC_CHECK_HEADERS(sys/ptem.h, [], [],
3332[#if defined HAVE_SYS_STREAM_H
3333# include <sys/stream.h>
3334#endif])
3335
Bram Moolenaar32f31b12009-05-21 13:20:59 +00003336dnl sys/sysctl.h depends on sys/param.h on OpenBSD
3337AC_CHECK_HEADERS(sys/sysctl.h, [], [],
3338[#if defined HAVE_SYS_PARAM_H
3339# include <sys/param.h>
3340#endif])
3341
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003342
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003343dnl pthread_np.h may exist but can only be used after including pthread.h
3344AC_MSG_CHECKING([for pthread_np.h])
3345AC_TRY_COMPILE([
3346#include <pthread.h>
3347#include <pthread_np.h>],
3348 [int i; i = 0;],
3349 AC_MSG_RESULT(yes)
3350 AC_DEFINE(HAVE_PTHREAD_NP_H),
3351 AC_MSG_RESULT(no))
3352
Bram Moolenaare344bea2005-09-01 20:46:49 +00003353AC_CHECK_HEADERS(strings.h)
Bram Moolenaard0573012017-10-28 21:11:06 +02003354if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00003355 dnl The strings.h file on OS/X contains a warning and nothing useful.
3356 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3357else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003358
3359dnl Check if strings.h and string.h can both be included when defined.
3360AC_MSG_CHECKING([if strings.h can be included after string.h])
3361cppflags_save=$CPPFLAGS
3362CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3363AC_TRY_COMPILE([
3364#if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO)
3365# define _NO_PROTO /* like in os_unix.h, causes conflict for AIX (Winn) */
3366 /* but don't do it on AIX 5.1 (Uribarri) */
3367#endif
3368#ifdef HAVE_XM_XM_H
3369# include <Xm/Xm.h> /* This breaks it for HP-UX 11 (Squassabia) */
3370#endif
3371#ifdef HAVE_STRING_H
3372# include <string.h>
3373#endif
3374#if defined(HAVE_STRINGS_H)
3375# include <strings.h>
3376#endif
3377 ], [int i; i = 0;],
3378 AC_MSG_RESULT(yes),
3379 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3380 AC_MSG_RESULT(no))
3381CPPFLAGS=$cppflags_save
Bram Moolenaar9372a112005-12-06 19:59:18 +00003382fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003383
3384dnl Checks for typedefs, structures, and compiler characteristics.
3385AC_PROG_GCC_TRADITIONAL
3386AC_C_CONST
Bram Moolenaar76243bd2009-03-02 01:47:02 +00003387AC_C_VOLATILE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003388AC_TYPE_MODE_T
3389AC_TYPE_OFF_T
3390AC_TYPE_PID_T
3391AC_TYPE_SIZE_T
3392AC_TYPE_UID_T
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003393AC_TYPE_UINT32_T
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003394
Bram Moolenaar071d4272004-06-13 20:20:40 +00003395AC_HEADER_TIME
3396AC_CHECK_TYPE(ino_t, long)
3397AC_CHECK_TYPE(dev_t, unsigned)
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003398AC_C_BIGENDIAN(,,,)
Bram Moolenaar136f29a2016-02-27 20:14:15 +01003399AC_C_INLINE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003400
3401AC_MSG_CHECKING(for rlim_t)
3402if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
3403 AC_MSG_RESULT([(cached) $ac_cv_type_rlim_t])
3404else
3405 AC_EGREP_CPP(dnl
3406changequote(<<,>>)dnl
3407<<(^|[^a-zA-Z_0-9])rlim_t[^a-zA-Z_0-9]>>dnl
3408changequote([,]),
3409 [
3410#include <sys/types.h>
3411#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003412# include <stdlib.h>
3413# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003414#endif
3415#ifdef HAVE_SYS_RESOURCE_H
Bram Moolenaar446cb832008-06-24 21:56:24 +00003416# include <sys/resource.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003417#endif
3418 ], ac_cv_type_rlim_t=yes, ac_cv_type_rlim_t=no)
3419 AC_MSG_RESULT($ac_cv_type_rlim_t)
3420fi
3421if test $ac_cv_type_rlim_t = no; then
3422 cat >> confdefs.h <<\EOF
3423#define rlim_t unsigned long
3424EOF
3425fi
3426
3427AC_MSG_CHECKING(for stack_t)
3428if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then
3429 AC_MSG_RESULT([(cached) $ac_cv_type_stack_t])
3430else
3431 AC_EGREP_CPP(stack_t,
3432 [
3433#include <sys/types.h>
3434#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003435# include <stdlib.h>
3436# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003437#endif
3438#include <signal.h>
3439 ], ac_cv_type_stack_t=yes, ac_cv_type_stack_t=no)
3440 AC_MSG_RESULT($ac_cv_type_stack_t)
3441fi
3442if test $ac_cv_type_stack_t = no; then
3443 cat >> confdefs.h <<\EOF
3444#define stack_t struct sigaltstack
3445EOF
3446fi
3447
3448dnl BSDI uses ss_base while others use ss_sp for the stack pointer.
3449AC_MSG_CHECKING(whether stack_t has an ss_base field)
3450AC_TRY_COMPILE([
3451#include <sys/types.h>
3452#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003453# include <stdlib.h>
3454# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003455#endif
3456#include <signal.h>
3457#include "confdefs.h"
3458 ], [stack_t sigstk; sigstk.ss_base = 0; ],
3459 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SS_BASE),
3460 AC_MSG_RESULT(no))
3461
3462olibs="$LIBS"
3463AC_MSG_CHECKING(--with-tlib argument)
3464AC_ARG_WITH(tlib, [ --with-tlib=library terminal library to be used ],)
3465if test -n "$with_tlib"; then
3466 AC_MSG_RESULT($with_tlib)
3467 LIBS="$LIBS -l$with_tlib"
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003468 AC_MSG_CHECKING(for linking with $with_tlib library)
3469 AC_TRY_LINK([], [], AC_MSG_RESULT(OK), AC_MSG_ERROR(FAILED))
3470 dnl Need to check for tgetent() below.
3471 olibs="$LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003472else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003473 AC_MSG_RESULT([empty: automatic terminal library selection])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003474 dnl On HP-UX 10.10 termcap or termlib should be used instead of
3475 dnl curses, because curses is much slower.
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003476 dnl Newer versions of ncurses are preferred over anything, except
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02003477 dnl when tinfo has been split off, it contains all we need.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003478 dnl Older versions of ncurses have bugs, get a new one!
3479 dnl Digital Unix (OSF1) should use curses (Ronald Schild).
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00003480 dnl On SCO Openserver should prefer termlib (Roger Cornelius).
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00003481 case "$vim_cv_uname_output" in
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003482 OSF1|SCO_SV) tlibs="tinfo ncurses curses termlib termcap";;
3483 *) tlibs="tinfo ncurses termlib termcap curses";;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003484 esac
3485 for libname in $tlibs; do
3486 AC_CHECK_LIB(${libname}, tgetent,,)
3487 if test "x$olibs" != "x$LIBS"; then
3488 dnl It's possible that a library is found but it doesn't work
3489 dnl e.g., shared library that cannot be found
3490 dnl compile and run a test program to be sure
3491 AC_TRY_RUN([
3492#ifdef HAVE_TERMCAP_H
3493# include <termcap.h>
3494#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003495#if STDC_HEADERS
3496# include <stdlib.h>
3497# include <stddef.h>
3498#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003499main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }],
3500 res="OK", res="FAIL", res="FAIL")
3501 if test "$res" = "OK"; then
3502 break
3503 fi
3504 AC_MSG_RESULT($libname library is not usable)
3505 LIBS="$olibs"
3506 fi
3507 done
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003508 if test "x$olibs" = "x$LIBS"; then
3509 AC_MSG_RESULT(no terminal library found)
3510 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003511fi
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003512
3513if test "x$olibs" = "x$LIBS"; then
3514 AC_MSG_CHECKING([for tgetent()])
Bram Moolenaarbd7f7c12020-07-28 21:03:37 +02003515 AC_TRY_LINK([int tgetent(char *, const char *);],
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003516 [char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");],
3517 AC_MSG_RESULT(yes),
3518 AC_MSG_ERROR([NOT FOUND!
3519 You need to install a terminal library; for example ncurses.
Bram Moolenaar16678eb2021-04-21 11:57:59 +02003520 On Linux that would be the libncurses-dev package.
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003521 Or specify the name of the library with --with-tlib.]))
3522fi
3523
Bram Moolenaar446cb832008-06-24 21:56:24 +00003524AC_CACHE_CHECK([whether we talk terminfo], [vim_cv_terminfo],
3525 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003526 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003527#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003528#ifdef HAVE_TERMCAP_H
3529# include <termcap.h>
3530#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003531#ifdef HAVE_STRING_H
3532# include <string.h>
3533#endif
3534#if STDC_HEADERS
3535# include <stdlib.h>
3536# include <stddef.h>
3537#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003538main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003539{char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003540 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003541 vim_cv_terminfo=no
3542 ],[
3543 vim_cv_terminfo=yes
3544 ],[
3545 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_terminfo')
3546 ])
3547 ])
3548
3549if test "x$vim_cv_terminfo" = "xyes" ; then
3550 AC_DEFINE(TERMINFO)
3551fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003552
Bram Moolenaara88254f2017-11-02 23:04:14 +01003553AC_CACHE_CHECK([what tgetent() returns for an unknown terminal], [vim_cv_tgetent],
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003554 [
3555 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003556#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003557#ifdef HAVE_TERMCAP_H
3558# include <termcap.h>
3559#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003560#if STDC_HEADERS
3561# include <stdlib.h>
3562# include <stddef.h>
3563#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003564main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003565{char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003566 ]])],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003567 vim_cv_tgetent=zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003568 ],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003569 vim_cv_tgetent=non-zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003570 ],[
3571 AC_MSG_ERROR(failed to compile test program.)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003572 ])
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003573 ])
3574
Bram Moolenaara88254f2017-11-02 23:04:14 +01003575if test "x$vim_cv_tgetent" = "xzero" ; then
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003576 AC_DEFINE(TGETENT_ZERO_ERR, 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003577fi
3578
3579AC_MSG_CHECKING(whether termcap.h contains ospeed)
3580AC_TRY_LINK([
3581#ifdef HAVE_TERMCAP_H
3582# include <termcap.h>
3583#endif
3584 ], [ospeed = 20000],
3585 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED),
3586 [AC_MSG_RESULT(no)
3587 AC_MSG_CHECKING(whether ospeed can be extern)
3588 AC_TRY_LINK([
3589#ifdef HAVE_TERMCAP_H
3590# include <termcap.h>
3591#endif
3592extern short ospeed;
3593 ], [ospeed = 20000],
3594 AC_MSG_RESULT(yes); AC_DEFINE(OSPEED_EXTERN),
3595 AC_MSG_RESULT(no))]
3596 )
3597
3598AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC])
3599AC_TRY_LINK([
3600#ifdef HAVE_TERMCAP_H
3601# include <termcap.h>
3602#endif
3603 ], [if (UP == 0 && BC == 0) PC = 1],
3604 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UP_BC_PC),
3605 [AC_MSG_RESULT(no)
3606 AC_MSG_CHECKING([whether UP, BC and PC can be extern])
3607 AC_TRY_LINK([
3608#ifdef HAVE_TERMCAP_H
3609# include <termcap.h>
3610#endif
3611extern char *UP, *BC, PC;
3612 ], [if (UP == 0 && BC == 0) PC = 1],
3613 AC_MSG_RESULT(yes); AC_DEFINE(UP_BC_PC_EXTERN),
3614 AC_MSG_RESULT(no))]
3615 )
3616
3617AC_MSG_CHECKING(whether tputs() uses outfuntype)
3618AC_TRY_COMPILE([
3619#ifdef HAVE_TERMCAP_H
3620# include <termcap.h>
3621#endif
3622 ], [extern int xx(); tputs("test", 1, (outfuntype)xx)],
3623 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OUTFUNTYPE),
3624 AC_MSG_RESULT(no))
3625
Bram Moolenaarb3a29552021-11-19 11:28:04 +00003626AC_MSG_CHECKING([whether del_curterm() can be used])
3627AC_TRY_LINK([
3628#ifdef HAVE_TERMCAP_H
3629# include <termcap.h>
3630#endif
3631#include <term.h>
3632 ], [if (cur_term) del_curterm(cur_term);],
3633 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DEL_CURTERM),
3634 AC_MSG_RESULT(no))
3635
Bram Moolenaar071d4272004-06-13 20:20:40 +00003636dnl On some SCO machines sys/select redefines struct timeval
3637AC_MSG_CHECKING([whether sys/select.h and sys/time.h may both be included])
3638AC_TRY_COMPILE([
3639#include <sys/types.h>
3640#include <sys/time.h>
3641#include <sys/select.h>], ,
3642 AC_MSG_RESULT(yes)
3643 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME),
3644 AC_MSG_RESULT(no))
3645
3646dnl AC_DECL_SYS_SIGLIST
3647
3648dnl Checks for pty.c (copied from screen) ==========================
3649AC_MSG_CHECKING(for /dev/ptc)
3650if test -r /dev/ptc; then
3651 AC_DEFINE(HAVE_DEV_PTC)
3652 AC_MSG_RESULT(yes)
3653else
3654 AC_MSG_RESULT(no)
3655fi
3656
3657AC_MSG_CHECKING(for SVR4 ptys)
3658if test -c /dev/ptmx ; then
Bram Moolenaarce7be3a2020-11-26 20:11:11 +01003659 AC_TRY_LINK([
3660// These should be in stdlib.h, but it depends on _XOPEN_SOURCE.
3661char *ptsname(int);
3662int unlockpt(int);
3663int grantpt(int);
3664 ], [
3665 ptsname(0);
3666 grantpt(0);
3667 unlockpt(0);],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003668 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SVR4_PTYS),
3669 AC_MSG_RESULT(no))
3670else
3671 AC_MSG_RESULT(no)
3672fi
3673
3674AC_MSG_CHECKING(for ptyranges)
3675if test -d /dev/ptym ; then
3676 pdir='/dev/ptym'
3677else
3678 pdir='/dev'
3679fi
3680dnl SCO uses ptyp%d
3681AC_EGREP_CPP(yes,
3682[#ifdef M_UNIX
3683 yes;
3684#endif
3685 ], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
3686dnl if test -c /dev/ptyp19; then
3687dnl ptys=`echo /dev/ptyp??`
3688dnl else
3689dnl ptys=`echo $pdir/pty??`
3690dnl fi
3691if test "$ptys" != "$pdir/pty??" ; then
3692 p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
3693 p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'`
3694 AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
3695 AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
3696 AC_MSG_RESULT([$p0 / $p1])
3697else
3698 AC_MSG_RESULT([don't know])
3699fi
3700
Bram Moolenaar071d4272004-06-13 20:20:40 +00003701dnl Checks for library functions. ===================================
3702
3703AC_TYPE_SIGNAL
3704
3705dnl find out what to use at the end of a signal function
3706if test $ac_cv_type_signal = void; then
3707 AC_DEFINE(SIGRETURN, [return])
3708else
3709 AC_DEFINE(SIGRETURN, [return 0])
3710fi
3711
3712dnl check if struct sigcontext is defined (used for SGI only)
3713AC_MSG_CHECKING(for struct sigcontext)
3714AC_TRY_COMPILE([
3715#include <signal.h>
3716test_sig()
3717{
3718 struct sigcontext *scont;
3719 scont = (struct sigcontext *)0;
3720 return 1;
3721} ], ,
3722 AC_MSG_RESULT(yes)
3723 AC_DEFINE(HAVE_SIGCONTEXT),
3724 AC_MSG_RESULT(no))
3725
3726dnl tricky stuff: try to find out if getcwd() is implemented with
3727dnl system("sh -c pwd")
Bram Moolenaar446cb832008-06-24 21:56:24 +00003728AC_CACHE_CHECK([getcwd implementation is broken], [vim_cv_getcwd_broken],
3729 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003730 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003731#include "confdefs.h"
3732#ifdef HAVE_UNISTD_H
3733#include <unistd.h>
3734#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003735char *dagger[] = { "IFS=pwd", 0 };
3736main()
3737{
3738 char buffer[500];
3739 extern char **environ;
3740 environ = dagger;
3741 return getcwd(buffer, 500) ? 0 : 1;
Bram Moolenaar446cb832008-06-24 21:56:24 +00003742}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003743 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003744 vim_cv_getcwd_broken=no
3745 ],[
3746 vim_cv_getcwd_broken=yes
3747 ],[
3748 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_getcwd_broken')
3749 ])
3750 ])
3751
3752if test "x$vim_cv_getcwd_broken" = "xyes" ; then
3753 AC_DEFINE(BAD_GETCWD)
Bram Moolenaar63d25552019-05-10 21:28:38 +02003754 AC_CHECK_FUNCS(getwd)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003755fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003756
Bram Moolenaar25153e12010-02-24 14:47:08 +01003757dnl Check for functions in one big call, to reduce the size of configure.
3758dnl Can only be used for functions that do not require any include.
Bram Moolenaarcd142e32017-11-16 17:03:45 +01003759AC_CHECK_FUNCS(fchdir fchown fchmod fsync getcwd getpseudotty \
Bram Moolenaar63d25552019-05-10 21:28:38 +02003760 getpwent getpwnam getpwuid getrlimit gettimeofday localtime_r lstat \
Bram Moolenaareaf03392009-11-17 11:08:52 +00003761 memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
Bram Moolenaar2fcf6682017-03-11 20:03:42 +01003762 getpgid setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
Bram Moolenaar84cf6bd2020-06-16 20:03:43 +02003763 sigprocmask sigvec strcasecmp strcoll strerror strftime stricmp strncasecmp \
Bram Moolenaar10455d42019-11-21 15:36:18 +01003764 strnicmp strpbrk strptime strtol tgetent towlower towupper iswupper \
3765 tzset usleep utime utimes mblen ftruncate unsetenv posix_openpt)
Bram Moolenaar643b6142018-09-12 20:29:09 +02003766AC_FUNC_SELECT_ARGTYPES
Bram Moolenaar25153e12010-02-24 14:47:08 +01003767AC_FUNC_FSEEKO
Bram Moolenaar071d4272004-06-13 20:20:40 +00003768
Bram Moolenaar317fd3a2010-05-07 16:05:55 +02003769dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when
3770dnl appropriate, so that off_t is 64 bits when needed.
3771AC_SYS_LARGEFILE
3772
Bram Moolenaar21606672019-06-14 20:40:58 +02003773AC_MSG_CHECKING(--enable-canberra argument)
3774AC_ARG_ENABLE(canberra,
3775 [ --disable-canberra Do not use libcanberra.],
3776 , [enable_canberra="maybe"])
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003777
Bram Moolenaar21606672019-06-14 20:40:58 +02003778if test "$enable_canberra" = "maybe"; then
3779 if test "$features" = "big" -o "$features" = "huge"; then
3780 AC_MSG_RESULT(Defaulting to yes)
3781 enable_canberra="yes"
3782 else
3783 AC_MSG_RESULT(Defaulting to no)
3784 enable_canberra="no"
3785 fi
3786else
3787 AC_MSG_RESULT($enable_canberra)
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003788fi
Bram Moolenaar21606672019-06-14 20:40:58 +02003789if test "$enable_canberra" = "yes"; then
3790 if test "x$PKG_CONFIG" != "xno"; then
3791 canberra_lib=`$PKG_CONFIG --libs libcanberra 2>/dev/null`
3792 canberra_cflags=`$PKG_CONFIG --cflags libcanberra 2>/dev/null`
3793 fi
3794 if test "x$canberra_lib" = "x"; then
3795 canberra_lib=-lcanberra
3796 canberra_cflags=-D_REENTRANT
3797 fi
3798 AC_MSG_CHECKING(for libcanberra)
3799 ac_save_CFLAGS="$CFLAGS"
3800 ac_save_LIBS="$LIBS"
Christian Brabandt6b9efdd2021-09-09 17:14:50 +02003801 if `echo "$CFLAGS" | grep -v "$canberra_cflags" >/dev/null`; then
3802 CFLAGS="$CFLAGS $canberra_cflags"
3803 fi
Bram Moolenaar21606672019-06-14 20:40:58 +02003804 LIBS="$LIBS $canberra_lib"
3805 AC_TRY_LINK([
3806 # include <canberra.h>
3807 ], [
3808 ca_context *hello;
3809 ca_context_create(&hello);],
3810 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_CANBERRA),
Bram Moolenaar91b992c2019-11-17 19:07:42 +01003811 AC_MSG_RESULT(no; try installing libcanberra-dev); CFLAGS="$ac_save_CFLAGS"; LIBS="$ac_save_LIBS")
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003812fi
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003813
Christian Brabandtf573c6e2021-06-20 14:02:16 +02003814AC_MSG_CHECKING(--enable-libsodium argument)
3815AC_ARG_ENABLE(libsodium,
3816 [ --disable-libsodium Do not use libsodium.],
3817 , [enable_libsodium="maybe"])
3818
3819if test "$enable_libsodium" = "maybe"; then
3820 if test "$features" = "big" -o "$features" = "huge"; then
3821 AC_MSG_RESULT(Defaulting to yes)
3822 enable_libsodium="yes"
3823 else
3824 AC_MSG_RESULT(Defaulting to no)
3825 enable_libsodium="no"
3826 fi
3827else
3828 AC_MSG_RESULT($enable_libsodium)
3829fi
3830if test "$enable_libsodium" = "yes"; then
3831 if test "x$PKG_CONFIG" != "xno"; then
3832 libsodium_lib=`$PKG_CONFIG --libs libsodium 2>/dev/null`
3833 libsodium_cflags=`$PKG_CONFIG --cflags libsodium 2>/dev/null`
3834 fi
3835 if test "x$libsodium_lib" = "x"; then
3836 libsodium_lib=-lsodium
3837 libsodium_cflags=
3838 fi
ichizok8ce3ca82021-06-23 15:41:52 +02003839 AC_MSG_CHECKING(for libsodium)
Christian Brabandtf573c6e2021-06-20 14:02:16 +02003840 ac_save_CFLAGS="$CFLAGS"
3841 ac_save_LIBS="$LIBS"
3842 CFLAGS="$CFLAGS $libsodium_cflags"
3843 LIBS="$LIBS $libsodium_lib"
3844 AC_TRY_LINK([
3845 # include <sodium.h>
3846 ], [
3847 printf("%d", sodium_init()); ],
3848 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SODIUM),
3849 AC_MSG_RESULT(no; try installing libsodium-dev); CFLAGS="$ac_save_CFLAGS"; LIBS="$ac_save_LIBS")
3850fi
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003851
Bram Moolenaar071d4272004-06-13 20:20:40 +00003852dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible
3853AC_MSG_CHECKING(for st_blksize)
3854AC_TRY_COMPILE(
3855[#include <sys/types.h>
3856#include <sys/stat.h>],
3857[ struct stat st;
3858 int n;
3859
3860 stat("/", &st);
3861 n = (int)st.st_blksize;],
3862 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ST_BLKSIZE),
3863 AC_MSG_RESULT(no))
3864
Bram Moolenaar446cb832008-06-24 21:56:24 +00003865AC_CACHE_CHECK([whether stat() ignores a trailing slash], [vim_cv_stat_ignores_slash],
3866 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003867 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003868#include "confdefs.h"
3869#if STDC_HEADERS
3870# include <stdlib.h>
3871# include <stddef.h>
3872#endif
3873#include <sys/types.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003874#include <sys/stat.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003875main() {struct stat st; exit(stat("configure/", &st) != 0); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003876 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003877 vim_cv_stat_ignores_slash=yes
3878 ],[
3879 vim_cv_stat_ignores_slash=no
3880 ],[
3881 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_stat_ignores_slash')
3882 ])
3883 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003884
Bram Moolenaar446cb832008-06-24 21:56:24 +00003885if test "x$vim_cv_stat_ignores_slash" = "xyes" ; then
3886 AC_DEFINE(STAT_IGNORES_SLASH)
3887fi
Leah Neukirchen0a7984a2021-10-14 21:27:55 +01003888
3889dnl nanoseconds field of struct stat
3890AC_CACHE_CHECK([for nanoseconds field of struct stat],
3891 ac_cv_struct_st_mtim_nsec,
3892 [ac_save_CPPFLAGS="$CPPFLAGS"
3893 ac_cv_struct_st_mtim_nsec=no
3894 # st_mtim.tv_nsec -- the usual case
3895 # st_mtim._tv_nsec -- Solaris 2.6, if
3896 # (defined _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED == 1
3897 # && !defined __EXTENSIONS__)
3898 # st_mtim.st__tim.tv_nsec -- UnixWare 2.1.2
3899 # st_mtime_n -- AIX 5.2 and above
3900 # st_mtimespec.tv_nsec -- Darwin (Mac OSX)
3901 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
3902 CPPFLAGS="$ac_save_CPPFLAGS -DST_MTIM_NSEC=$ac_val"
3903 AC_TRY_COMPILE([#include <sys/types.h>
3904#include <sys/stat.h>], [struct stat s; s.ST_MTIM_NSEC;],
3905 [ac_cv_struct_st_mtim_nsec=$ac_val; break])
3906 done
3907 CPPFLAGS="$ac_save_CPPFLAGS"
3908])
3909if test $ac_cv_struct_st_mtim_nsec != no; then
3910 AC_DEFINE_UNQUOTED([ST_MTIM_NSEC], [$ac_cv_struct_st_mtim_nsec],
3911 [Define if struct stat contains a nanoseconds field])
3912fi
Bram Moolenaar446cb832008-06-24 21:56:24 +00003913
Bram Moolenaar071d4272004-06-13 20:20:40 +00003914dnl Link with iconv for charset translation, if not found without library.
3915dnl check for iconv() requires including iconv.h
3916dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
3917dnl has been installed.
3918AC_MSG_CHECKING(for iconv_open())
3919save_LIBS="$LIBS"
3920LIBS="$LIBS -liconv"
3921AC_TRY_LINK([
3922#ifdef HAVE_ICONV_H
3923# include <iconv.h>
3924#endif
3925 ], [iconv_open("fr", "to");],
3926 AC_MSG_RESULT(yes; with -liconv); AC_DEFINE(HAVE_ICONV),
3927 LIBS="$save_LIBS"
3928 AC_TRY_LINK([
3929#ifdef HAVE_ICONV_H
3930# include <iconv.h>
3931#endif
3932 ], [iconv_open("fr", "to");],
3933 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ICONV),
3934 AC_MSG_RESULT(no)))
3935
3936
3937AC_MSG_CHECKING(for nl_langinfo(CODESET))
3938AC_TRY_LINK([
3939#ifdef HAVE_LANGINFO_H
3940# include <langinfo.h>
3941#endif
3942], [char *cs = nl_langinfo(CODESET);],
3943 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET),
3944 AC_MSG_RESULT(no))
3945
Bram Moolenaar446cb832008-06-24 21:56:24 +00003946dnl Need various functions for floating point support. Only enable
3947dnl floating point when they are all present.
3948AC_CHECK_LIB(m, strtod)
3949AC_MSG_CHECKING([for strtod() and other floating point functions])
3950AC_TRY_LINK([
3951#ifdef HAVE_MATH_H
3952# include <math.h>
3953#endif
3954#if STDC_HEADERS
3955# include <stdlib.h>
3956# include <stddef.h>
3957#endif
3958], [char *s; double d;
3959 d = strtod("1.1", &s);
3960 d = fabs(1.11);
3961 d = ceil(1.11);
3962 d = floor(1.11);
3963 d = log10(1.11);
3964 d = pow(1.11, 2.22);
3965 d = sqrt(1.11);
3966 d = sin(1.11);
3967 d = cos(1.11);
3968 d = atan(1.11);
3969 ],
3970 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT_FUNCS),
3971 AC_MSG_RESULT(no))
3972
Bram Moolenaara6b89762016-02-29 21:38:26 +01003973dnl isinf() and isnan() need to include header files and may need -lm.
3974AC_MSG_CHECKING([for isinf()])
3975AC_TRY_LINK([
3976#ifdef HAVE_MATH_H
3977# include <math.h>
3978#endif
3979#if STDC_HEADERS
3980# include <stdlib.h>
3981# include <stddef.h>
3982#endif
3983], [int r = isinf(1.11); ],
3984 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISINF),
3985 AC_MSG_RESULT(no))
3986
3987AC_MSG_CHECKING([for isnan()])
3988AC_TRY_LINK([
3989#ifdef HAVE_MATH_H
3990# include <math.h>
3991#endif
3992#if STDC_HEADERS
3993# include <stdlib.h>
3994# include <stddef.h>
3995#endif
3996], [int r = isnan(1.11); ],
3997 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISNAN),
3998 AC_MSG_RESULT(no))
3999
Bram Moolenaar071d4272004-06-13 20:20:40 +00004000dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI
4001dnl when -lacl works, also try to use -lattr (required for Debian).
Bram Moolenaar8d462f92012-02-05 22:51:33 +01004002dnl On Solaris, use the acl_get/set functions in libsec, if present.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004003AC_MSG_CHECKING(--disable-acl argument)
4004AC_ARG_ENABLE(acl,
Bram Moolenaard6d30422018-01-28 22:48:55 +01004005 [ --disable-acl No check for ACL support.],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004006 , [enable_acl="yes"])
4007if test "$enable_acl" = "yes"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01004008 AC_MSG_RESULT(no)
4009 AC_CHECK_LIB(posix1e, acl_get_file, [LIBS="$LIBS -lposix1e"],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004010 AC_CHECK_LIB(acl, acl_get_file, [LIBS="$LIBS -lacl"
4011 AC_CHECK_LIB(attr, fgetxattr, LIBS="$LIBS -lattr",,)],,),)
4012
Bram Moolenaard6d30422018-01-28 22:48:55 +01004013 AC_MSG_CHECKING(for POSIX ACL support)
4014 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00004015#include <sys/types.h>
4016#ifdef HAVE_SYS_ACL_H
4017# include <sys/acl.h>
4018#endif
4019acl_t acl;], [acl = acl_get_file("foo", ACL_TYPE_ACCESS);
4020 acl_set_file("foo", ACL_TYPE_ACCESS, acl);
4021 acl_free(acl);],
4022 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_ACL),
4023 AC_MSG_RESULT(no))
4024
Bram Moolenaard6d30422018-01-28 22:48:55 +01004025 AC_CHECK_LIB(sec, acl_get, [LIBS="$LIBS -lsec"; AC_DEFINE(HAVE_SOLARIS_ZFS_ACL)],
4026 AC_MSG_CHECKING(for Solaris ACL support)
4027 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00004028#ifdef HAVE_SYS_ACL_H
4029# include <sys/acl.h>
4030#endif], [acl("foo", GETACLCNT, 0, NULL);
4031 ],
4032 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOLARIS_ACL),
Bram Moolenaar8d462f92012-02-05 22:51:33 +01004033 AC_MSG_RESULT(no)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004034
Bram Moolenaard6d30422018-01-28 22:48:55 +01004035 AC_MSG_CHECKING(for AIX ACL support)
4036 AC_TRY_LINK([
Bram Moolenaar446cb832008-06-24 21:56:24 +00004037#if STDC_HEADERS
4038# include <stdlib.h>
4039# include <stddef.h>
4040#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004041#ifdef HAVE_SYS_ACL_H
4042# include <sys/acl.h>
4043#endif
4044#ifdef HAVE_SYS_ACCESS_H
4045# include <sys/access.h>
4046#endif
4047#define _ALL_SOURCE
4048
4049#include <sys/stat.h>
4050
4051int aclsize;
4052struct acl *aclent;], [aclsize = sizeof(struct acl);
4053 aclent = (void *)malloc(aclsize);
4054 statacl("foo", STX_NORMAL, aclent, aclsize);
4055 ],
4056 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_AIX_ACL),
4057 AC_MSG_RESULT(no))
4058else
4059 AC_MSG_RESULT(yes)
4060fi
4061
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02004062if test "x$GTK_CFLAGS" != "x"; then
4063 dnl pango_shape_full() is new, fall back to pango_shape().
4064 AC_MSG_CHECKING(for pango_shape_full)
4065 ac_save_CFLAGS="$CFLAGS"
4066 ac_save_LIBS="$LIBS"
4067 CFLAGS="$CFLAGS $GTK_CFLAGS"
4068 LIBS="$LIBS $GTK_LIBS"
Bram Moolenaar5325b9b2015-09-09 20:27:02 +02004069 AC_TRY_LINK(
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02004070 [#include <gtk/gtk.h>],
4071 [ pango_shape_full(NULL, 0, NULL, 0, NULL, NULL); ],
4072 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_PANGO_SHAPE_FULL),
4073 AC_MSG_RESULT(no))
4074 CFLAGS="$ac_save_CFLAGS"
4075 LIBS="$ac_save_LIBS"
4076fi
4077
Bram Moolenaar071d4272004-06-13 20:20:40 +00004078AC_MSG_CHECKING(--disable-gpm argument)
4079AC_ARG_ENABLE(gpm,
4080 [ --disable-gpm Don't use gpm (Linux mouse daemon).], ,
4081 [enable_gpm="yes"])
4082
4083if test "$enable_gpm" = "yes"; then
4084 AC_MSG_RESULT(no)
4085 dnl Checking if gpm support can be compiled
4086 AC_CACHE_CHECK([for gpm], vi_cv_have_gpm,
4087 [olibs="$LIBS" ; LIBS="-lgpm"]
4088 AC_TRY_LINK(
4089 [#include <gpm.h>
4090 #include <linux/keyboard.h>],
4091 [Gpm_GetLibVersion(NULL);],
4092 dnl Configure defines HAVE_GPM, if it is defined feature.h defines
4093 dnl FEAT_MOUSE_GPM if mouse support is included
4094 [vi_cv_have_gpm=yes],
4095 [vi_cv_have_gpm=no])
4096 [LIBS="$olibs"]
4097 )
4098 if test $vi_cv_have_gpm = yes; then
4099 LIBS="$LIBS -lgpm"
4100 AC_DEFINE(HAVE_GPM)
4101 fi
4102else
4103 AC_MSG_RESULT(yes)
4104fi
4105
Bram Moolenaar446cb832008-06-24 21:56:24 +00004106AC_MSG_CHECKING(--disable-sysmouse argument)
4107AC_ARG_ENABLE(sysmouse,
Bram Moolenaar8008b632017-07-18 21:33:20 +02004108 [ --disable-sysmouse Don't use sysmouse (mouse in *BSD console).], ,
Bram Moolenaar446cb832008-06-24 21:56:24 +00004109 [enable_sysmouse="yes"])
4110
4111if test "$enable_sysmouse" = "yes"; then
4112 AC_MSG_RESULT(no)
4113 dnl Checking if sysmouse support can be compiled
4114 dnl Configure defines HAVE_SYSMOUSE, if it is defined feature.h
4115 dnl defines FEAT_SYSMOUSE if mouse support is included
4116 AC_CACHE_CHECK([for sysmouse], vi_cv_have_sysmouse,
4117 AC_TRY_LINK(
4118 [#include <sys/consio.h>
4119 #include <signal.h>
4120 #include <sys/fbio.h>],
4121 [struct mouse_info mouse;
4122 mouse.operation = MOUSE_MODE;
4123 mouse.operation = MOUSE_SHOW;
4124 mouse.u.mode.mode = 0;
4125 mouse.u.mode.signal = SIGUSR2;],
4126 [vi_cv_have_sysmouse=yes],
4127 [vi_cv_have_sysmouse=no])
4128 )
4129 if test $vi_cv_have_sysmouse = yes; then
4130 AC_DEFINE(HAVE_SYSMOUSE)
4131 fi
4132else
4133 AC_MSG_RESULT(yes)
4134fi
4135
Bram Moolenaarf05da212009-11-17 16:13:15 +00004136dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
4137AC_MSG_CHECKING(for FD_CLOEXEC)
4138AC_TRY_COMPILE(
4139[#if HAVE_FCNTL_H
4140# include <fcntl.h>
4141#endif],
4142[ int flag = FD_CLOEXEC;],
4143 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
4144 AC_MSG_RESULT(not usable))
4145
Bram Moolenaar071d4272004-06-13 20:20:40 +00004146dnl rename needs to be checked separately to work on Nextstep with cc
4147AC_MSG_CHECKING(for rename)
4148AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
4149 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
4150 AC_MSG_RESULT(no))
4151
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004152dnl check for dirfd()
4153AC_MSG_CHECKING(for dirfd)
Bram Moolenaar9d8bfae2020-09-02 21:21:35 +02004154AC_TRY_LINK(
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004155[#include <sys/types.h>
4156#include <dirent.h>],
4157[DIR * dir=opendir("dirname"); dirfd(dir);],
4158AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DIRFD), AC_MSG_RESULT(not usable))
4159
4160dnl check for flock()
4161AC_MSG_CHECKING(for flock)
Bram Moolenaar9d8bfae2020-09-02 21:21:35 +02004162AC_TRY_LINK(
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004163[#include <sys/file.h>],
4164[flock(10, LOCK_SH);],
4165AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOCK), AC_MSG_RESULT(not usable))
4166
Bram Moolenaar071d4272004-06-13 20:20:40 +00004167dnl sysctl() may exist but not the arguments we use
4168AC_MSG_CHECKING(for sysctl)
4169AC_TRY_COMPILE(
4170[#include <sys/types.h>
4171#include <sys/sysctl.h>],
4172[ int mib[2], r;
4173 size_t len;
4174
4175 mib[0] = CTL_HW;
4176 mib[1] = HW_USERMEM;
4177 len = sizeof(r);
4178 (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
4179 ],
4180 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL),
4181 AC_MSG_RESULT(not usable))
4182
Bram Moolenaare2982d62021-10-06 11:27:21 +01004183dnl sysinfo() may exist but not be Linux compatible.
4184dnl On some FreeBSD systems it may depend on libsysinfo, use TRY_LINK
Bram Moolenaar071d4272004-06-13 20:20:40 +00004185AC_MSG_CHECKING(for sysinfo)
Bram Moolenaare2982d62021-10-06 11:27:21 +01004186AC_TRY_LINK(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004187[#include <sys/types.h>
4188#include <sys/sysinfo.h>],
4189[ struct sysinfo sinfo;
4190 int t;
4191
4192 (void)sysinfo(&sinfo);
4193 t = sinfo.totalram;
4194 ],
4195 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
4196 AC_MSG_RESULT(not usable))
4197
Bram Moolenaar914572a2007-05-01 11:37:47 +00004198dnl struct sysinfo may have the mem_unit field or not
4199AC_MSG_CHECKING(for sysinfo.mem_unit)
4200AC_TRY_COMPILE(
4201[#include <sys/types.h>
4202#include <sys/sysinfo.h>],
4203[ struct sysinfo sinfo;
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02004204 sinfo.mem_unit = 1;
Bram Moolenaar914572a2007-05-01 11:37:47 +00004205 ],
4206 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_MEM_UNIT),
4207 AC_MSG_RESULT(no))
4208
Bram Moolenaarf52f0602021-03-10 21:26:37 +01004209dnl struct sysinfo may have the uptime field or not
4210AC_MSG_CHECKING(for sysinfo.uptime)
4211AC_TRY_COMPILE(
4212[#include <sys/types.h>
4213#include <sys/sysinfo.h>],
4214[ struct sysinfo sinfo;
4215 long ut;
4216
4217 (void)sysinfo(&sinfo);
4218 ut = sinfo.uptime;
4219 ],
4220 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_UPTIME),
4221 AC_MSG_RESULT(no))
4222
Bram Moolenaar071d4272004-06-13 20:20:40 +00004223dnl sysconf() may exist but not support what we want to use
4224AC_MSG_CHECKING(for sysconf)
4225AC_TRY_COMPILE(
4226[#include <unistd.h>],
4227[ (void)sysconf(_SC_PAGESIZE);
4228 (void)sysconf(_SC_PHYS_PAGES);
4229 ],
4230 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
4231 AC_MSG_RESULT(not usable))
4232
Bram Moolenaar0e62a672021-02-25 17:17:56 +01004233dnl check if we have _SC_SIGSTKSZ via sysconf()
4234AC_MSG_CHECKING(for _SC_SIGSTKSZ via sysconf())
4235AC_TRY_COMPILE(
4236[#include <unistd.h>],
4237[ (void)sysconf(_SC_SIGSTKSZ);
4238 ],
4239 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF_SIGSTKSZ),
4240 AC_MSG_RESULT(not usable))
4241
Bram Moolenaar914703b2010-05-31 21:59:46 +02004242AC_CHECK_SIZEOF([int])
4243AC_CHECK_SIZEOF([long])
4244AC_CHECK_SIZEOF([time_t])
4245AC_CHECK_SIZEOF([off_t])
Bram Moolenaar644fdff2010-05-30 13:26:21 +02004246
Bram Moolenaara2aa31a2014-02-23 22:52:40 +01004247dnl Use different names to avoid clashing with other header files.
4248AC_DEFINE_UNQUOTED(VIM_SIZEOF_INT, [$ac_cv_sizeof_int])
4249AC_DEFINE_UNQUOTED(VIM_SIZEOF_LONG, [$ac_cv_sizeof_long])
4250
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004251dnl Make sure that uint32_t is really 32 bits unsigned.
4252AC_MSG_CHECKING([uint32_t is 32 bits])
4253AC_TRY_RUN([
4254#ifdef HAVE_STDINT_H
4255# include <stdint.h>
4256#endif
4257#ifdef HAVE_INTTYPES_H
4258# include <inttypes.h>
4259#endif
4260main() {
4261 uint32_t nr1 = (uint32_t)-1;
4262 uint32_t nr2 = (uint32_t)0xffffffffUL;
Bram Moolenaar52897832020-07-02 22:50:37 +02004263 if (sizeof(uint32_t) != 4 || nr1 != 0xffffffffUL || nr2 + 1 != 0) return 1;
4264 return 0;
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004265}],
4266AC_MSG_RESULT(ok),
4267AC_MSG_ERROR([WRONG! uint32_t not defined correctly.]),
Bram Moolenaar323cb952011-12-14 19:22:34 +01004268AC_MSG_WARN([cannot check uint32_t when cross-compiling.]))
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004269
Bram Moolenaar446cb832008-06-24 21:56:24 +00004270dnl Check for memmove() before bcopy(), makes memmove() be used when both are
4271dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
4272
Bram Moolenaar071d4272004-06-13 20:20:40 +00004273[bcopy_test_prog='
Bram Moolenaar446cb832008-06-24 21:56:24 +00004274#include "confdefs.h"
4275#ifdef HAVE_STRING_H
4276# include <string.h>
4277#endif
4278#if STDC_HEADERS
4279# include <stdlib.h>
4280# include <stddef.h>
4281#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004282main() {
4283 char buf[10];
4284 strcpy(buf, "abcdefghi");
4285 mch_memmove(buf, buf + 2, 3);
4286 if (strncmp(buf, "ababcf", 6))
4287 exit(1);
4288 strcpy(buf, "abcdefghi");
4289 mch_memmove(buf + 2, buf, 3);
4290 if (strncmp(buf, "cdedef", 6))
4291 exit(1);
4292 exit(0); /* libc version works properly. */
4293}']
4294
Bram Moolenaar446cb832008-06-24 21:56:24 +00004295AC_CACHE_CHECK([whether memmove handles overlaps],[vim_cv_memmove_handles_overlap],
4296 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004297 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 +00004298 [
4299 vim_cv_memmove_handles_overlap=yes
4300 ],[
4301 vim_cv_memmove_handles_overlap=no
4302 ],[
4303 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memmove_handles_overlap')
4304 ])
4305 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00004306
Bram Moolenaar446cb832008-06-24 21:56:24 +00004307if test "x$vim_cv_memmove_handles_overlap" = "xyes" ; then
4308 AC_DEFINE(USEMEMMOVE)
4309else
4310 AC_CACHE_CHECK([whether bcopy handles overlaps],[vim_cv_bcopy_handles_overlap],
4311 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004312 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 +00004313 [
4314 vim_cv_bcopy_handles_overlap=yes
4315 ],[
4316 vim_cv_bcopy_handles_overlap=no
4317 ],[
4318 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_bcopy_handles_overlap')
4319 ])
4320 ])
4321
4322 if test "x$vim_cv_bcopy_handles_overlap" = "xyes" ; then
4323 AC_DEFINE(USEBCOPY)
4324 else
4325 AC_CACHE_CHECK([whether memcpy handles overlaps],[vim_cv_memcpy_handles_overlap],
4326 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004327 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 +00004328 [
4329 vim_cv_memcpy_handles_overlap=yes
4330 ],[
4331 vim_cv_memcpy_handles_overlap=no
4332 ],[
4333 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memcpy_handles_overlap')
4334 ])
4335 ])
4336
4337 if test "x$vim_cv_memcpy_handles_overlap" = "xyes" ; then
4338 AC_DEFINE(USEMEMCPY)
4339 fi
4340 fi
4341fi
4342
Bram Moolenaar071d4272004-06-13 20:20:40 +00004343
4344dnl Check for multibyte locale functions
4345dnl Find out if _Xsetlocale() is supported by libX11.
4346dnl Check if X_LOCALE should be defined.
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004347if test "x$with_x" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004348 cflags_save=$CFLAGS
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004349 libs_save=$LIBS
4350 LIBS="$LIBS $X_LIBS $GUI_LIB_LOC $GUI_X_LIBS $X_PRE_LIBS $X_LIB $X_EXTRA_LIBS"
4351 CFLAGS="$CFLAGS $X_CFLAGS"
4352
4353 AC_MSG_CHECKING(whether X_LOCALE needed)
4354 AC_TRY_COMPILE([#include <X11/Xlocale.h>],,
4355 AC_TRY_LINK_FUNC([_Xsetlocale], [AC_MSG_RESULT(yes)
4356 AC_DEFINE(X_LOCALE)], AC_MSG_RESULT(no)),
4357 AC_MSG_RESULT(no))
4358
4359 AC_MSG_CHECKING(whether Xutf8SetWMProperties() can be used)
4360 AC_TRY_LINK_FUNC([Xutf8SetWMProperties], [AC_MSG_RESULT(yes)
4361 AC_DEFINE(HAVE_XUTF8SETWMPROPERTIES)], AC_MSG_RESULT(no))
4362
Bram Moolenaar071d4272004-06-13 20:20:40 +00004363 CFLAGS=$cflags_save
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004364 LIBS=$libs_save
Bram Moolenaar071d4272004-06-13 20:20:40 +00004365fi
4366
4367dnl Link with xpg4, it is said to make Korean locale working
4368AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,)
4369
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004370dnl Check how we can run ctags. Default to "ctags" when nothing works.
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02004371dnl Use --version to detect Exuberant ctags (preferred)
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004372dnl Add --fields=+S to get function signatures for omni completion.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004373dnl -t for typedefs (many ctags have this)
4374dnl -s for static functions (Elvis ctags only?)
4375dnl -v for variables. Dangerous, most ctags take this for 'vgrind style'.
4376dnl -i+m to test for older Exuberant ctags
4377AC_MSG_CHECKING(how to create tags)
4378test -f tags && mv tags tags.save
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004379if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004380 TAGPRG="ctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004381elif (eval exctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004382 TAGPRG="exctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004383elif (eval exuberant-ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004384 TAGPRG="exuberant-ctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004385else
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004386 TAGPRG="ctags"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004387 (eval etags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags"
4388 (eval etags -c /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags -c"
4389 (eval ctags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags"
4390 (eval ctags -t /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -t"
4391 (eval ctags -ts /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -ts"
4392 (eval ctags -tvs /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -tvs"
4393 (eval ctags -i+m /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -i+m"
4394fi
4395test -f tags.save && mv tags.save tags
4396AC_MSG_RESULT($TAGPRG) AC_SUBST(TAGPRG)
4397
4398dnl Check how we can run man with a section number
4399AC_MSG_CHECKING(how to run man with a section nr)
4400MANDEF="man"
Bram Moolenaar8b131502008-02-13 09:28:19 +00004401(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 +00004402AC_MSG_RESULT($MANDEF)
4403if test "$MANDEF" = "man -s"; then
4404 AC_DEFINE(USEMAN_S)
4405fi
4406
4407dnl Check if gettext() is working and if it needs -lintl
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004408dnl We take care to base this on an empty LIBS: on some systems libelf would be
4409dnl in LIBS and implicitly take along libintl. The final LIBS would then not
4410dnl contain libintl, and the link step would fail due to -Wl,--as-needed.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004411AC_MSG_CHECKING(--disable-nls argument)
4412AC_ARG_ENABLE(nls,
4413 [ --disable-nls Don't support NLS (gettext()).], ,
4414 [enable_nls="yes"])
4415
4416if test "$enable_nls" = "yes"; then
4417 AC_MSG_RESULT(no)
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00004418
4419 INSTALL_LANGS=install-languages
4420 AC_SUBST(INSTALL_LANGS)
4421 INSTALL_TOOL_LANGS=install-tool-languages
4422 AC_SUBST(INSTALL_TOOL_LANGS)
4423
Bram Moolenaar071d4272004-06-13 20:20:40 +00004424 AC_CHECK_PROG(MSGFMT, msgfmt, msgfmt, )
4425 AC_MSG_CHECKING([for NLS])
4426 if test -f po/Makefile; then
4427 have_gettext="no"
4428 if test -n "$MSGFMT"; then
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004429 olibs=$LIBS
4430 LIBS=""
Bram Moolenaar071d4272004-06-13 20:20:40 +00004431 AC_TRY_LINK(
4432 [#include <libintl.h>],
4433 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004434 AC_MSG_RESULT([gettext() works]); have_gettext="yes"; LIBS=$olibs,
4435 LIBS="-lintl"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004436 AC_TRY_LINK(
4437 [#include <libintl.h>],
4438 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004439 AC_MSG_RESULT([gettext() works with -lintl]); have_gettext="yes";
4440 LIBS="$olibs -lintl",
Bram Moolenaar071d4272004-06-13 20:20:40 +00004441 AC_MSG_RESULT([gettext() doesn't work]);
4442 LIBS=$olibs))
4443 else
4444 AC_MSG_RESULT([msgfmt not found - disabled]);
4445 fi
Bram Moolenaar278eb582014-07-30 13:22:52 +02004446 if test $have_gettext = "yes" -a "x$features" != "xtiny" -a "x$features" != "xsmall"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004447 AC_DEFINE(HAVE_GETTEXT)
4448 MAKEMO=yes
4449 AC_SUBST(MAKEMO)
4450 dnl this was added in GNU gettext 0.10.36
4451 AC_CHECK_FUNCS(bind_textdomain_codeset)
4452 dnl _nl_msg_cat_cntr is required for GNU gettext
4453 AC_MSG_CHECKING([for _nl_msg_cat_cntr])
4454 AC_TRY_LINK(
4455 [#include <libintl.h>
4456 extern int _nl_msg_cat_cntr;],
4457 [++_nl_msg_cat_cntr;],
4458 AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_NL_MSG_CAT_CNTR),
4459 AC_MSG_RESULT([no]))
Bram Moolenaar26096cc2019-04-11 15:25:40 +02004460 AC_MSG_CHECKING([if msgfmt supports --desktop])
4461 MSGFMT_DESKTOP=
4462 if "$MSGFMT" --help | grep -e '--desktop' >/dev/null; then
Bram Moolenaar62a88f42019-06-07 20:44:40 +02004463 if "$MSGFMT" --version | grep '0.19.[[3-7]]$' >/dev/null; then
4464 dnl GNU gettext 0.19.7's --desktop is broken. We assume back to
4465 dnl 0.19.3 is also broken.
4466 AC_MSG_RESULT([broken])
4467 else
4468 AC_MSG_RESULT([yes])
4469 MSGFMT_DESKTOP="gvim.desktop vim.desktop"
4470 fi
Bram Moolenaar26096cc2019-04-11 15:25:40 +02004471 else
4472 AC_MSG_RESULT([no])
4473 fi
4474 AC_SUBST(MSGFMT_DESKTOP)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004475 fi
4476 else
4477 AC_MSG_RESULT([no "po/Makefile" - disabled]);
4478 fi
4479else
4480 AC_MSG_RESULT(yes)
4481fi
4482
4483dnl Check for dynamic linking loader
4484AC_CHECK_HEADER(dlfcn.h, DLL=dlfcn.h, [AC_CHECK_HEADER(dl.h, DLL=dl.h)])
4485if test x${DLL} = xdlfcn.h; then
4486 AC_DEFINE(HAVE_DLFCN_H, 1, [ Define if we have dlfcn.h. ])
4487 AC_MSG_CHECKING([for dlopen()])
4488 AC_TRY_LINK(,[
4489 extern void* dlopen();
4490 dlopen();
4491 ],
4492 AC_MSG_RESULT(yes);
4493 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4494 AC_MSG_RESULT(no);
4495 AC_MSG_CHECKING([for dlopen() in -ldl])
4496 olibs=$LIBS
4497 LIBS="$LIBS -ldl"
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 LIBS=$olibs))
4506 dnl ReliantUNIX has dlopen() in libc but everything else in libdl
4507 dnl ick :-)
4508 AC_MSG_CHECKING([for dlsym()])
4509 AC_TRY_LINK(,[
4510 extern void* dlsym();
4511 dlsym();
4512 ],
4513 AC_MSG_RESULT(yes);
4514 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4515 AC_MSG_RESULT(no);
4516 AC_MSG_CHECKING([for dlsym() in -ldl])
4517 olibs=$LIBS
4518 LIBS="$LIBS -ldl"
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 LIBS=$olibs))
4527elif test x${DLL} = xdl.h; then
4528 AC_DEFINE(HAVE_DL_H, 1, [ Define if we have dl.h. ])
4529 AC_MSG_CHECKING([for shl_load()])
4530 AC_TRY_LINK(,[
4531 extern void* shl_load();
4532 shl_load();
4533 ],
4534 AC_MSG_RESULT(yes);
4535 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4536 AC_MSG_RESULT(no);
4537 AC_MSG_CHECKING([for shl_load() in -ldld])
4538 olibs=$LIBS
4539 LIBS="$LIBS -ldld"
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 LIBS=$olibs))
4548fi
4549AC_CHECK_HEADERS(setjmp.h)
4550
Bram Moolenaard0573012017-10-28 21:11:06 +02004551if test "x$MACOS_X" = "xyes" -a -n "$PERL"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004552 dnl -ldl must come after DynaLoader.a
4553 if echo $LIBS | grep -e '-ldl' >/dev/null; then
4554 LIBS=`echo $LIBS | sed s/-ldl//`
4555 PERL_LIBS="$PERL_LIBS -ldl"
4556 fi
4557fi
4558
Bram Moolenaard0573012017-10-28 21:11:06 +02004559if test "$MACOS_X" = "yes"; then
4560 AC_MSG_CHECKING([whether we need macOS frameworks])
Bram Moolenaar097148e2020-08-11 21:58:20 +02004561 if test "$MACOS_X_DARWIN" = "yes"; then
Bram Moolenaard0573012017-10-28 21:11:06 +02004562 if test "$features" = "tiny"; then
4563 dnl Since no FEAT_CLIPBOARD, no longer need for os_macosx.m.
4564 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_macosx.m++'`
4565 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_macosx.o++'`
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01004566 AC_MSG_RESULT([yes, we need CoreServices])
4567 LIBS="$LIBS -framework CoreServices"
Bram Moolenaard0573012017-10-28 21:11:06 +02004568 else
4569 AC_MSG_RESULT([yes, we need AppKit])
4570 LIBS="$LIBS -framework AppKit"
Bram Moolenaard0573012017-10-28 21:11:06 +02004571 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004572 else
Bram Moolenaard0573012017-10-28 21:11:06 +02004573 AC_MSG_RESULT([no])
Bram Moolenaar3437b912013-07-03 19:52:53 +02004574 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004575fi
4576
Bram Moolenaar3ae5fc92021-09-06 18:57:30 +02004577dnl On some systems REENTRANT needs to be defined. It should not hurt to use
4578dnl it everywhere.
4579if `echo "$CFLAGS" | grep -v D_REENTRANT >/dev/null`; then
4580 CFLAGS="$CFLAGS -D_REENTRANT"
4581fi
4582
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004583dnl gcc 3.1 changed the meaning of -MM. The only solution appears to be to
4584dnl use "-isystem" instead of "-I" for all non-Vim include dirs.
4585dnl But only when making dependencies, cproto and lint don't take "-isystem".
Bram Moolenaar32466aa2006-02-24 23:53:04 +00004586dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
4587dnl the number before the version number.
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004588DEPEND_CFLAGS_FILTER=
4589if test "$GCC" = yes; then
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004590 AC_MSG_CHECKING(for GCC 3 or later)
Bram Moolenaar348808f2020-02-07 20:50:07 +01004591 gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]][[0-9]]*\)\..*$/\1/g'`
Bram Moolenaarf740b292006-02-16 22:11:02 +00004592 if test "$gccmajor" -gt "2"; then
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004593 DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004594 AC_MSG_RESULT(yes)
4595 else
4596 AC_MSG_RESULT(no)
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004597 fi
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004598 dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
4599 dnl declared as char x[1] but actually longer. Introduced in gcc 4.0.
Bram Moolenaar56d1db32009-12-16 16:14:51 +00004600 dnl Also remove duplicate _FORTIFY_SOURCE arguments.
Bram Moolenaaraeabe052011-12-08 15:17:34 +01004601 dnl And undefine it first to avoid a warning.
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004602 AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
4603 if test "$gccmajor" -gt "3"; then
Bram Moolenaar26f20132021-04-03 17:33:52 +02004604 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/'`
4605 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 +00004606 AC_MSG_RESULT(yes)
4607 else
4608 AC_MSG_RESULT(no)
4609 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +00004610fi
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004611AC_SUBST(DEPEND_CFLAGS_FILTER)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004612
Bram Moolenaarec0557f2018-01-31 14:41:37 +01004613dnl On some systems AC_SYS_LARGEFILE determines that -D_FILE_OFFSET_BITS=64
4614dnl isn't required, but the CFLAGS for some of the libraries we're using
4615dnl include the define. Since the define changes the size of some datatypes
4616dnl (e.g. ino_t and off_t), all of Vim's modules must be compiled with a
4617dnl consistent value. It's therefore safest to force the use of the define
4618dnl if it's present in any of the *_CFLAGS variables.
4619AC_MSG_CHECKING(whether we need to force -D_FILE_OFFSET_BITS=64)
Bram Moolenaar9ce42132018-04-11 22:19:36 +02004620if 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 +01004621 AC_MSG_RESULT(yes)
4622 AC_DEFINE(_FILE_OFFSET_BITS, 64)
4623else
4624 AC_MSG_RESULT(no)
4625fi
4626
Bram Moolenaar6cd42db2020-12-04 18:09:54 +01004627dnl $LDFLAGS is passed to glibtool in libvterm, it doesn't like a space
4628dnl between "-L" and the path that follows.
4629LDFLAGS=`echo "$LDFLAGS" | sed -e 's/-L /-L/g'`
4630
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004631dnl link.sh tries to avoid overlinking in a hackish way.
4632dnl At least GNU ld supports --as-needed which provides the same functionality
4633dnl at linker level. Let's use it.
4634AC_MSG_CHECKING(linker --as-needed support)
4635LINK_AS_NEEDED=
4636# Check if linker supports --as-needed and --no-as-needed options
4637if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
Natanael Copa761ead42021-05-15 14:25:37 +02004638 if ! echo "$LDFLAGS" | grep -q -- '-Wl,[[^[:space:]]]*--as-needed'; then
4639 LDFLAGS="$LDFLAGS -Wl,--as-needed"
4640 fi
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004641 LINK_AS_NEEDED=yes
4642fi
4643if test "$LINK_AS_NEEDED" = yes; then
4644 AC_MSG_RESULT(yes)
4645else
4646 AC_MSG_RESULT(no)
4647fi
4648AC_SUBST(LINK_AS_NEEDED)
4649
Bram Moolenaar77c19352012-06-13 19:19:41 +02004650# IBM z/OS reset CFLAGS for config.mk
4651if test "$zOSUnix" = "yes"; then
4652 CFLAGS="-D_ALL_SOURCE -Wc,float\(ieee\),dll"
4653fi
4654
Bram Moolenaar071d4272004-06-13 20:20:40 +00004655dnl write output files
4656AC_OUTPUT(auto/config.mk:config.mk.in)
4657
4658dnl vim: set sw=2 tw=78 fo+=l: