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