blob: 4dd74fc2a89018db06ab2690812b97a4503c520b [file] [log] [blame]
Bram Moolenaar3f7d0902016-11-12 21:13:42 +01001dnl configure.ac: autoconf script for Vim
Bram Moolenaar071d4272004-06-13 20:20:40 +00002
3dnl Process this file with autoconf 2.12 or 2.13 to produce "configure".
4dnl Should also work with autoconf 2.54 and later.
5
6AC_INIT(vim.h)
7AC_CONFIG_HEADER(auto/config.h:config.h.in)
8
9dnl Being able to run configure means the system is Unix (compatible).
10AC_DEFINE(UNIX)
11AC_PROG_MAKE_SET
12
13dnl Checks for programs.
Bram Moolenaar22640082018-04-19 20:39:41 +020014AC_PROG_CC_C99 dnl required by almost everything
Bram Moolenaarc0394412017-04-20 20:20:23 +020015AC_PROG_CPP dnl required by header file checks
16AC_PROGRAM_EGREP dnl required by AC_EGREP_CPP
17AC_PROG_FGREP dnl finds working grep -F
18AC_ISC_POSIX dnl required by AC_C_CROSS
19AC_PROG_AWK dnl required for "make html" in ../doc
Bram Moolenaar071d4272004-06-13 20:20:40 +000020
21dnl Don't strip if we don't have it
22AC_CHECK_PROG(STRIP, strip, strip, :)
23
Bram Moolenaar325b7a22004-07-05 15:58:32 +000024dnl Check for extension of executables
Bram Moolenaar071d4272004-06-13 20:20:40 +000025AC_EXEEXT
26
Bram Moolenaar446cb832008-06-24 21:56:24 +000027dnl Check for standard headers. We don't use this in Vim but other stuff
28dnl in autoconf needs it, where it uses STDC_HEADERS.
29AC_HEADER_STDC
30AC_HEADER_SYS_WAIT
31
Bram Moolenaar561f8a52018-04-17 22:02:45 +020032dnl Check that the C99 features that Vim uses are supported:
Bram Moolenaar22640082018-04-19 20:39:41 +020033if test x"$ac_cv_prog_cc_c99" != xno; then
34 dnl If the compiler doesn't explicitly support C99, then check
35 dnl for the specific features Vim uses
36
37 AC_TYPE_LONG_LONG_INT
38 if test "$ac_cv_type_long_long_int" = no; then
39 AC_MSG_FAILURE([Compiler does not support long long int])
40 fi
41
42 AC_MSG_CHECKING([if the compiler supports trailing commas])
43 trailing_commas=no
44 AC_TRY_COMPILE([], [
45 enum {
46 one,
47 };],
48 [AC_MSG_RESULT(yes); trailing_commas=yes],
49 [AC_MSG_RESULT(no)])
50 if test "$trailing_commas" = no; then
51 AC_MSG_FAILURE([Compiler does not support trailing comma in enum])
52 fi
53
54 AC_MSG_CHECKING([if the compiler supports C++ comments])
55 slash_comments=no
56 AC_TRY_COMPILE([],
57 [// C++ comments?],
58 [AC_MSG_RESULT(yes); slash_comments=yes],
59 [AC_MSG_RESULT(no)])
60 if test "$slash_comments" = no; then
61 AC_MSG_FAILURE([Compiler does not support C++ comments])
62 fi
63fi
Bram Moolenaar561f8a52018-04-17 22:02:45 +020064
Bram Moolenaar8f1dde52020-06-05 23:16:29 +020065dnl If $SOURCE_DATE_EPOCH is present in the environment, use that as the
66dnl "compiled" timestamp in :version's output. Attempt to get the formatted
67dnl date using GNU date syntax, BSD date syntax, and finally falling back to
68dnl just using the current time.
69if test -n "$SOURCE_DATE_EPOCH"; then
70 DATE_FMT="%b %d %Y %H:%M:%S"
71 BUILD_DATE=$(LC_ALL=C date -u -d "@$SOURCE_DATE_EPOCH" "+$DATE_FMT" 2>/dev/null || LC_ALL=C date -u -r "$SOURCE_DATE_EPOCH" "+$DATE_FMT" 2>/dev/null || LC_ALL=C date -u "+$DATE_FMT")
72 AC_DEFINE_UNQUOTED(BUILD_DATE, ["$BUILD_DATE"])
73 BUILD_DATE_MSG=-"echo -e '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\nNOTE: build date/time is fixed: $BUILD_DATE\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='"
74 AC_SUBST(BUILD_DATE_MSG)
75fi
76
Bram Moolenaarf788a062011-12-14 20:51:25 +010077dnl Check for the flag that fails if stuff are missing.
78
79AC_MSG_CHECKING(--enable-fail-if-missing argument)
80AC_ARG_ENABLE(fail_if_missing,
81 [ --enable-fail-if-missing Fail if dependencies on additional features
82 specified on the command line are missing.],
83 [fail_if_missing="yes"],
84 [fail_if_missing="no"])
85AC_MSG_RESULT($fail_if_missing)
86
Bram Moolenaard2a05492018-07-27 22:35:15 +020087dnl Keep original value to check later.
88with_x_arg="$with_x"
89
Bram Moolenaar071d4272004-06-13 20:20:40 +000090dnl Set default value for CFLAGS if none is defined or it's empty
91if test -z "$CFLAGS"; then
92 CFLAGS="-O"
Bram Moolenaar4d8479b2021-01-31 14:36:06 +010093 test "$GCC" = yes && CFLAGS="-O2 -fno-strength-reduce -Wall -Wno-deprecated-declarations"
Bram Moolenaar071d4272004-06-13 20:20:40 +000094fi
95if test "$GCC" = yes; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +000096 dnl method that should work for nearly all versions
Bram Moolenaarc8836f72014-04-12 13:12:24 +020097 gccversion=`$CC -dumpversion`
Bram Moolenaar910f66f2006-04-05 20:41:53 +000098 if test "x$gccversion" = "x"; then
99 dnl old method; fall-back for when -dumpversion doesn't work
Bram Moolenaarc8836f72014-04-12 13:12:24 +0200100 gccversion=`$CC --version | sed -e '2,$d' -e 's/darwin.//' -e 's/^[[^0-9]]*\([[0-9]]\.[[0-9.]]*\).*$/\1/g'`
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000101 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +0000102 dnl version 4.0.1 was reported to cause trouble on Macintosh by Marcin Dalecki
103 if test "$gccversion" = "3.0.1" -o "$gccversion" = "3.0.2" -o "$gccversion" = "4.0.1"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000104 echo 'GCC [[34]].0.[[12]] has a bug in the optimizer, disabling "-O#"'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000105 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-O/'`
106 else
107 if test "$gccversion" = "3.1" -o "$gccversion" = "3.2" -o "$gccversion" = "3.2.1" && `echo "$CFLAGS" | grep -v fno-strength-reduce >/dev/null`; then
108 echo 'GCC 3.1 and 3.2 have a bug in the optimizer, adding "-fno-strength-reduce"'
109 CFLAGS="$CFLAGS -fno-strength-reduce"
110 fi
111 fi
112fi
113
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200114dnl clang-500.2.75 or around has abandoned -f[no-]strength-reduce and issues a
115dnl warning when that flag is passed to. Accordingly, adjust CFLAGS based on
116dnl the version number of the clang in use.
117dnl Note that this does not work to get the version of clang 3.1 or 3.2.
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100118AC_MSG_CHECKING(for clang version)
119CLANG_VERSION_STRING=`$CC --version 2>/dev/null | sed -n -e 's/^.*clang[[^0-9]]*\([[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\).*$/\1/p'`
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200120if test x"$CLANG_VERSION_STRING" != x"" ; then
121 CLANG_MAJOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*/\1/p'`
122 CLANG_MINOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/p'`
123 CLANG_REVISION=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)/\1/p'`
124 CLANG_VERSION=`expr $CLANG_MAJOR '*' 1000000 '+' $CLANG_MINOR '*' 1000 '+' $CLANG_REVISION`
125 AC_MSG_RESULT($CLANG_VERSION)
126 dnl If you find the same issue with versions earlier than 500.2.75,
127 dnl change the constant 500002075 below appropriately. To get the
128 dnl integer corresponding to a version number, refer to the
129 dnl definition of CLANG_VERSION above.
Bram Moolenaarebd211c2021-01-30 19:33:36 +0100130 dnl Clang 11 reports "11", assume Clang 10 and later work like this.
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100131 AC_MSG_CHECKING(if clang supports -fno-strength-reduce)
Bram Moolenaarebd211c2021-01-30 19:33:36 +0100132 if test "$CLANG_MAJOR" -ge 10 -o "$CLANG_VERSION" -ge 500002075 ; then
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100133 AC_MSG_RESULT(no)
134 CFLAGS=`echo "$CFLAGS" | sed -e 's/-fno-strength-reduce/ /'`
135 else
136 AC_MSG_RESULT(yes)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200137 fi
138else
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100139 AC_MSG_RESULT(N/A)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200140fi
141
Bram Moolenaar446cb832008-06-24 21:56:24 +0000142dnl If configure thinks we are cross compiling, there might be something
143dnl wrong with the CC or CFLAGS settings, give a useful warning message
Bram Moolenaar839e9542016-04-14 16:46:02 +0200144CROSS_COMPILING=
Bram Moolenaar071d4272004-06-13 20:20:40 +0000145if test "$cross_compiling" = yes; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000146 AC_MSG_RESULT([cannot compile a simple program; if not cross compiling check CC and CFLAGS])
Bram Moolenaar839e9542016-04-14 16:46:02 +0200147 CROSS_COMPILING=1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000148fi
Bram Moolenaar839e9542016-04-14 16:46:02 +0200149AC_SUBST(CROSS_COMPILING)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000150
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +0000151dnl gcc-cpp has the wonderful -MM option to produce nicer dependencies.
152dnl But gcc 3.1 changed the meaning! See near the end.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000153test "$GCC" = yes && CPP_MM=M; AC_SUBST(CPP_MM)
154
155if test -f ./toolcheck; then
156 AC_CHECKING(for buggy tools)
157 sh ./toolcheck 1>&AC_FD_MSG
158fi
159
160OS_EXTRA_SRC=""; OS_EXTRA_OBJ=""
161
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000162dnl When cross-compiling set $vim_cv_uname_output, $vim_cv_uname_r_output and
163dnl $vim_cv_uname_m_output to the desired value for the target system
164AC_MSG_CHECKING(uname)
165if test "x$vim_cv_uname_output" = "x" ; then
166 vim_cv_uname_output=`(uname) 2>/dev/null`
167 AC_MSG_RESULT($vim_cv_uname_output)
168else
169 AC_MSG_RESULT([$vim_cv_uname_output (cached)])
170fi
171
172AC_MSG_CHECKING(uname -r)
173if test "x$vim_cv_uname_r_output" = "x" ; then
174 vim_cv_uname_r_output=`(uname -r) 2>/dev/null`
175 AC_MSG_RESULT($vim_cv_uname_r_output)
176else
177 AC_MSG_RESULT([$vim_cv_uname_r_output (cached)])
178fi
179
180AC_MSG_CHECKING(uname -m)
181if test "x$vim_cv_uname_m_output" = "x" ; then
182 vim_cv_uname_m_output=`(uname -m) 2>/dev/null`
183 AC_MSG_RESULT($vim_cv_uname_m_output)
184else
185 AC_MSG_RESULT([$vim_cv_uname_m_output (cached)])
186fi
187
Bram Moolenaarb3f74062020-02-26 16:16:53 +0100188AC_MSG_CHECKING(for Haiku)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000189case $vim_cv_uname_output in
Bram Moolenaarb3f74062020-02-26 16:16:53 +0100190 Haiku) HAIKU=yes; AC_MSG_RESULT(yes);;
191 *) HAIKU=no; AC_MSG_RESULT(no);;
192esac
193
Bram Moolenaar071d4272004-06-13 20:20:40 +0000194dnl If QNX is found, assume we don't want to use Xphoton
195dnl unless it was specifically asked for (--with-x)
196AC_MSG_CHECKING(for QNX)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000197case $vim_cv_uname_output in
Bram Moolenaar071d4272004-06-13 20:20:40 +0000198 QNX) OS_EXTRA_SRC=os_qnx.c; OS_EXTRA_OBJ=objects/os_qnx.o
199 test -z "$with_x" && with_x=no
200 QNX=yes; AC_MSG_RESULT(yes);;
201 *) QNX=no; AC_MSG_RESULT(no);;
202esac
203
204dnl Check for Darwin and MacOS X
205dnl We do a check for MacOS X in the very beginning because there
206dnl are a lot of other things we need to change besides GUI stuff
Bram Moolenaar071d4272004-06-13 20:20:40 +0000207AC_MSG_CHECKING([for Darwin (Mac OS X)])
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000208if test "$vim_cv_uname_output" = Darwin; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000209 AC_MSG_RESULT(yes)
Bram Moolenaard0573012017-10-28 21:11:06 +0200210 MACOS_X=yes
Bram Moolenaar52ecaaa2018-05-12 21:38:13 +0200211 CPPFLAGS="$CPPFLAGS -DMACOS_X"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000212
213 AC_MSG_CHECKING(--disable-darwin argument)
214 AC_ARG_ENABLE(darwin,
215 [ --disable-darwin Disable Darwin (Mac OS X) support.],
216 , [enable_darwin="yes"])
217 if test "$enable_darwin" = "yes"; then
218 AC_MSG_RESULT(no)
219 AC_MSG_CHECKING(if Darwin files are there)
Bram Moolenaar164fca32010-07-14 13:58:07 +0200220 if test -f os_macosx.m; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000221 AC_MSG_RESULT(yes)
222 else
223 AC_MSG_RESULT([no, Darwin support disabled])
224 enable_darwin=no
225 fi
226 else
227 AC_MSG_RESULT([yes, Darwin support excluded])
228 fi
229
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000230 AC_MSG_CHECKING(--with-mac-arch argument)
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000231 AC_ARG_WITH(mac-arch, [ --with-mac-arch=ARCH current, intel, ppc or both],
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000232 MACARCH="$withval"; AC_MSG_RESULT($MACARCH),
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000233 MACARCH="current"; AC_MSG_RESULT(defaulting to $MACARCH))
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000234
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100235 AC_MSG_CHECKING(--with-developer-dir argument)
236 AC_ARG_WITH(developer-dir, [ --with-developer-dir=PATH use PATH as location for Xcode developer tools],
237 DEVELOPER_DIR="$withval"; AC_MSG_RESULT($DEVELOPER_DIR),
Bram Moolenaar32d03b32015-11-19 13:46:48 +0100238 AC_MSG_RESULT(not present))
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100239
240 if test "x$DEVELOPER_DIR" = "x"; then
241 AC_PATH_PROG(XCODE_SELECT, xcode-select)
242 if test "x$XCODE_SELECT" != "x"; then
243 AC_MSG_CHECKING(for developer dir using xcode-select)
244 DEVELOPER_DIR=`$XCODE_SELECT -print-path`
245 AC_MSG_RESULT([$DEVELOPER_DIR])
246 else
247 DEVELOPER_DIR=/Developer
248 fi
249 fi
250
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000251 if test "x$MACARCH" = "xboth"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000252 AC_MSG_CHECKING(for 10.4 universal SDK)
253 dnl There is a terrible inconsistency (but we appear to get away with it):
254 dnl $CFLAGS uses the 10.4u SDK library for the headers, while $CPPFLAGS
255 dnl doesn't, because "gcc -E" doesn't grok it. That means the configure
256 dnl tests using the preprocessor are actually done with the wrong header
257 dnl files. $LDFLAGS is set at the end, because configure uses it together
258 dnl with $CFLAGS and we can only have one -sysroot argument.
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000259 save_cppflags="$CPPFLAGS"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000260 save_cflags="$CFLAGS"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000261 save_ldflags="$LDFLAGS"
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100262 CFLAGS="$CFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000263 AC_TRY_LINK([ ], [ ],
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000264 AC_MSG_RESULT(found, will make universal binary),
265
266 AC_MSG_RESULT(not found)
Bram Moolenaar1f35bf92006-03-07 22:38:47 +0000267 CFLAGS="$save_cflags"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000268 AC_MSG_CHECKING(if Intel architecture is supported)
269 CPPFLAGS="$CPPFLAGS -arch i386"
270 LDFLAGS="$save_ldflags -arch i386"
271 AC_TRY_LINK([ ], [ ],
272 AC_MSG_RESULT(yes); MACARCH="intel",
273 AC_MSG_RESULT(no, using PowerPC)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000274 MACARCH="ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000275 CPPFLAGS="$save_cppflags -arch ppc"
276 LDFLAGS="$save_ldflags -arch ppc"))
277 elif test "x$MACARCH" = "xintel"; then
278 CPPFLAGS="$CPPFLAGS -arch intel"
279 LDFLAGS="$LDFLAGS -arch intel"
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000280 elif test "x$MACARCH" = "xppc"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000281 CPPFLAGS="$CPPFLAGS -arch ppc"
282 LDFLAGS="$LDFLAGS -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000283 fi
284
Bram Moolenaar071d4272004-06-13 20:20:40 +0000285 if test "$enable_darwin" = "yes"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200286 MACOS_X_DARWIN=yes
Bram Moolenaar164fca32010-07-14 13:58:07 +0200287 OS_EXTRA_SRC="os_macosx.m os_mac_conv.c";
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000288 OS_EXTRA_OBJ="objects/os_macosx.o objects/os_mac_conv.o"
Bram Moolenaar32466aa2006-02-24 23:53:04 +0000289 dnl TODO: use -arch i386 on Intel machines
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100290 dnl Removed -no-cpp-precomp, only for very old compilers.
Bram Moolenaard0573012017-10-28 21:11:06 +0200291 CPPFLAGS="$CPPFLAGS -DMACOS_X_DARWIN"
Bram Moolenaar040f9752020-08-11 23:08:48 +0200292
293 dnl Assume we don't want X11 unless it was specifically asked for
294 dnl (--with-x) or Motif, Athena or GTK GUI is used.
295 if test -z "$with_x" -a "X$enable_gui" != Xmotif -a "X$enable_gui" != Xathena -a "X$enable_gui" != Xgtk2 -a "X$enable_gui" != Xgtk3; then
296 with_x=no
297 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000298 fi
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000299
Bram Moolenaardb552d602006-03-23 22:59:57 +0000300 dnl Avoid a bug with -O2 with gcc 4.0.1. Symptom: malloc() reports double
Bram Moolenaarfd2ac762006-03-01 22:09:21 +0000301 dnl free. This happens in expand_filename(), because the optimizer swaps
Bram Moolenaardb552d602006-03-23 22:59:57 +0000302 dnl two blocks of code, both using "repl", that can't be swapped.
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000303 if test "$MACARCH" = "intel" -o "$MACARCH" = "both"; then
304 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-Oz/'`
305 fi
306
Bram Moolenaar071d4272004-06-13 20:20:40 +0000307else
308 AC_MSG_RESULT(no)
309fi
310
Bram Moolenaar39766a72013-11-03 00:41:00 +0100311dnl Mac OS X 10.9+ no longer include AvailabilityMacros.h in Carbon
312dnl so we need to include it to have access to version macros.
Bram Moolenaar18e54692013-11-03 20:26:31 +0100313AC_CHECK_HEADERS(AvailabilityMacros.h)
Bram Moolenaar39766a72013-11-03 00:41:00 +0100314
Bram Moolenaar071d4272004-06-13 20:20:40 +0000315AC_SUBST(OS_EXTRA_SRC)
316AC_SUBST(OS_EXTRA_OBJ)
317
318dnl Add /usr/local/lib to $LDFLAGS and /usr/local/include to CFLAGS.
319dnl Only when the directory exists and it wasn't there yet.
320dnl For gcc don't do this when it is already in the default search path.
Bram Moolenaar446cb832008-06-24 21:56:24 +0000321dnl Skip all of this when cross-compiling.
322if test "$cross_compiling" = no; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000323 AC_MSG_CHECKING(--with-local-dir argument)
Bram Moolenaar446cb832008-06-24 21:56:24 +0000324 have_local_include=''
325 have_local_lib=''
Bram Moolenaarc236c162008-07-13 17:41:49 +0000326 AC_ARG_WITH([local-dir], [ --with-local-dir=PATH search PATH instead of /usr/local for local libraries.
327 --without-local-dir do not search /usr/local for local libraries.], [
328 local_dir="$withval"
329 case "$withval" in
330 */*) ;;
331 no)
332 # avoid adding local dir to LDFLAGS and CPPFLAGS
Bram Moolenaare06c1882010-07-21 22:05:20 +0200333 have_local_include=yes
Bram Moolenaarc236c162008-07-13 17:41:49 +0000334 have_local_lib=yes
335 ;;
336 *) AC_MSG_ERROR(must pass path argument to --with-local-dir) ;;
337 esac
338 AC_MSG_RESULT($local_dir)
339 ], [
340 local_dir=/usr/local
341 AC_MSG_RESULT(Defaulting to $local_dir)
342 ])
343 if test "$GCC" = yes -a "$local_dir" != no; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000344 echo 'void f(){}' > conftest.c
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100345 dnl Removed -no-cpp-precomp, only needed for OS X 10.2 (Ben Fowler)
346 have_local_include=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/include"`
Bram Moolenaarc236c162008-07-13 17:41:49 +0000347 have_local_lib=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/lib"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000348 rm -f conftest.c conftest.o
Bram Moolenaar071d4272004-06-13 20:20:40 +0000349 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000350 if test -z "$have_local_lib" -a -d "${local_dir}/lib"; then
351 tt=`echo "$LDFLAGS" | sed -e "s+-L${local_dir}/lib ++g" -e "s+-L${local_dir}/lib$++g"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000352 if test "$tt" = "$LDFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000353 LDFLAGS="$LDFLAGS -L${local_dir}/lib"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000354 fi
355 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000356 if test -z "$have_local_include" -a -d "${local_dir}/include"; then
357 tt=`echo "$CPPFLAGS" | sed -e "s+-I${local_dir}/include ++g" -e "s+-I${local_dir}/include$++g"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000358 if test "$tt" = "$CPPFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000359 CPPFLAGS="$CPPFLAGS -I${local_dir}/include"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000360 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000361 fi
362fi
363
364AC_MSG_CHECKING(--with-vim-name argument)
365AC_ARG_WITH(vim-name, [ --with-vim-name=NAME what to call the Vim executable],
366 VIMNAME="$withval"; AC_MSG_RESULT($VIMNAME),
Bram Moolenaare344bea2005-09-01 20:46:49 +0000367 VIMNAME="vim"; AC_MSG_RESULT(Defaulting to $VIMNAME))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000368AC_SUBST(VIMNAME)
369AC_MSG_CHECKING(--with-ex-name argument)
370AC_ARG_WITH(ex-name, [ --with-ex-name=NAME what to call the Ex executable],
371 EXNAME="$withval"; AC_MSG_RESULT($EXNAME),
372 EXNAME="ex"; AC_MSG_RESULT(Defaulting to ex))
373AC_SUBST(EXNAME)
374AC_MSG_CHECKING(--with-view-name argument)
375AC_ARG_WITH(view-name, [ --with-view-name=NAME what to call the View executable],
376 VIEWNAME="$withval"; AC_MSG_RESULT($VIEWNAME),
377 VIEWNAME="view"; AC_MSG_RESULT(Defaulting to view))
378AC_SUBST(VIEWNAME)
379
380AC_MSG_CHECKING(--with-global-runtime argument)
Bram Moolenaar9d302ad2018-12-21 11:48:51 +0100381AC_ARG_WITH(global-runtime, [ --with-global-runtime=DIR global runtime directory in 'runtimepath', comma-separated for multiple directories],
382 RUNTIME_GLOBAL="$withval"; AC_MSG_RESULT($withval),
Bram Moolenaar071d4272004-06-13 20:20:40 +0000383 AC_MSG_RESULT(no))
384
Bram Moolenaar9d302ad2018-12-21 11:48:51 +0100385if test "X$RUNTIME_GLOBAL" != "X"; then
386 RUNTIME_GLOBAL_AFTER=$(printf -- "$RUNTIME_GLOBAL\\n" | $AWK -F, 'BEGIN { comma=0 } { for (i = NF; i > 0; i--) { if (comma) { printf ",%s/after", $i } else { printf "%s/after", $i; comma=1 } } } END { printf "\n" }')
387 AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL, "$RUNTIME_GLOBAL")
388 AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL_AFTER, "$RUNTIME_GLOBAL_AFTER")
389fi
390
Bram Moolenaar071d4272004-06-13 20:20:40 +0000391AC_MSG_CHECKING(--with-modified-by argument)
392AC_ARG_WITH(modified-by, [ --with-modified-by=NAME name of who modified a release version],
393 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(MODIFIED_BY, "$withval"),
394 AC_MSG_RESULT(no))
395
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200396dnl Check for EBCDIC stolen from the LYNX port to z/OS Unix
Bram Moolenaar071d4272004-06-13 20:20:40 +0000397AC_MSG_CHECKING(if character set is EBCDIC)
398AC_TRY_COMPILE([ ],
399[ /* TryCompile function for CharSet.
400 Treat any failure as ASCII for compatibility with existing art.
401 Use compile-time rather than run-time tests for cross-compiler
402 tolerance. */
403#if '0'!=240
404make an error "Character set is not EBCDIC"
405#endif ],
406[ # TryCompile action if true
407cf_cv_ebcdic=yes ],
408[ # TryCompile action if false
409cf_cv_ebcdic=no])
410# end of TryCompile ])
411# end of CacheVal CvEbcdic
412AC_MSG_RESULT($cf_cv_ebcdic)
413case "$cf_cv_ebcdic" in #(vi
414 yes) AC_DEFINE(EBCDIC)
415 line_break='"\\n"'
416 ;;
417 *) line_break='"\\012"';;
418esac
419AC_SUBST(line_break)
420
421if test "$cf_cv_ebcdic" = "yes"; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +0200422dnl If we have EBCDIC we most likely have z/OS Unix, let's test it!
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200423AC_MSG_CHECKING(for z/OS Unix)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000424case $vim_cv_uname_output in
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200425 OS/390) zOSUnix="yes";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000426 dnl If using cc the environment variable _CC_CCMODE must be
427 dnl set to "1", so that some compiler extensions are enabled.
428 dnl If using c89 the environment variable is named _CC_C89MODE.
429 dnl Note: compile with c89 never tested.
430 if test "$CC" = "cc"; then
431 ccm="$_CC_CCMODE"
432 ccn="CC"
433 else
434 if test "$CC" = "c89"; then
435 ccm="$_CC_C89MODE"
436 ccn="C89"
437 else
438 ccm=1
439 fi
440 fi
441 if test "$ccm" != "1"; then
442 echo ""
443 echo "------------------------------------------"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200444 echo " On z/OS Unix, the environment variable"
Bram Moolenaar77c19352012-06-13 19:19:41 +0200445 echo " _CC_${ccn}MODE must be set to \"1\"!"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000446 echo " Do:"
447 echo " export _CC_${ccn}MODE=1"
448 echo " and then call configure again."
449 echo "------------------------------------------"
450 exit 1
451 fi
Bram Moolenaar77c19352012-06-13 19:19:41 +0200452 # Set CFLAGS for configure process.
453 # This will be reset later for config.mk.
454 # Use haltonmsg to force error for missing H files.
455 CFLAGS="$CFLAGS -D_ALL_SOURCE -Wc,float(ieee),haltonmsg(3296)";
456 LDFLAGS="$LDFLAGS -Wl,EDIT=NO"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000457 AC_MSG_RESULT(yes)
458 ;;
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200459 *) zOSUnix="no";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000460 AC_MSG_RESULT(no)
461 ;;
462esac
463fi
464
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200465dnl Set QUOTESED. Needs additional backslashes on zOS
466if test "$zOSUnix" = "yes"; then
Bram Moolenaarabcbb0e2020-12-23 12:33:42 +0100467 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\\\\\&/g' -e 's/\\\\\\\\\"/\"/' -e 's/\\\\\\\\\";\$\$/\";/' -e 's/ */ /g'"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200468else
Bram Moolenaarabcbb0e2020-12-23 12:33:42 +0100469 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\&/g' -e 's/\\\\\"/\"/' -e 's/\\\\\";\$\$/\";/' -e 's/ */ /g'"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200470fi
471AC_SUBST(QUOTESED)
472
473
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200474dnl Link with -lsmack for Smack stuff; if not found
475AC_MSG_CHECKING(--disable-smack argument)
476AC_ARG_ENABLE(smack,
477 [ --disable-smack Do not check for Smack support.],
478 , enable_smack="yes")
479if test "$enable_smack" = "yes"; then
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200480 AC_MSG_RESULT(no)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200481 AC_CHECK_HEADER([linux/xattr.h], true, enable_smack="no")
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200482else
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200483 AC_MSG_RESULT(yes)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200484fi
485if test "$enable_smack" = "yes"; then
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200486 AC_CHECK_HEADER([attr/xattr.h], true, enable_smack="no")
487fi
488if test "$enable_smack" = "yes"; then
489 AC_MSG_CHECKING(for XATTR_NAME_SMACKEXEC in linux/xattr.h)
490 AC_EGREP_CPP(XATTR_NAME_SMACKEXEC, [#include <linux/xattr.h>],
491 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +0200492 AC_MSG_RESULT(no); enable_smack="no")
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200493fi
494if test "$enable_smack" = "yes"; then
495 AC_CHECK_LIB(attr, setxattr,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200496 [LIBS="$LIBS -lattr"
497 found_smack="yes"
498 AC_DEFINE(HAVE_SMACK)])
Bram Moolenaar588ebeb2008-05-07 17:09:24 +0000499fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000500
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200501dnl When smack was found don't search for SELinux
502if test "x$found_smack" = "x"; then
503 dnl Link with -lselinux for SELinux stuff; if not found
504 AC_MSG_CHECKING(--disable-selinux argument)
505 AC_ARG_ENABLE(selinux,
506 [ --disable-selinux Do not check for SELinux support.],
507 , enable_selinux="yes")
508 if test "$enable_selinux" = "yes"; then
509 AC_MSG_RESULT(no)
510 AC_CHECK_LIB(selinux, is_selinux_enabled,
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100511 [AC_CHECK_HEADER(selinux/selinux.h,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200512 [LIBS="$LIBS -lselinux"
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100513 AC_DEFINE(HAVE_SELINUX)])])
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200514 else
515 AC_MSG_RESULT(yes)
516 fi
517fi
518
Bram Moolenaar071d4272004-06-13 20:20:40 +0000519dnl Check user requested features.
520
521AC_MSG_CHECKING(--with-features argument)
Bram Moolenaareec29812016-07-26 21:27:36 +0200522AC_ARG_WITH(features, [ --with-features=TYPE tiny, small, normal, big or huge (default: huge)],
Bram Moolenaar071d4272004-06-13 20:20:40 +0000523 features="$withval"; AC_MSG_RESULT($features),
Bram Moolenaar23c4f712016-01-20 22:11:59 +0100524 features="huge"; AC_MSG_RESULT(Defaulting to huge))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000525
526dovimdiff=""
527dogvimdiff=""
528case "$features" in
529 tiny) AC_DEFINE(FEAT_TINY) ;;
530 small) AC_DEFINE(FEAT_SMALL) ;;
531 normal) AC_DEFINE(FEAT_NORMAL) dovimdiff="installvimdiff";
532 dogvimdiff="installgvimdiff" ;;
533 big) AC_DEFINE(FEAT_BIG) dovimdiff="installvimdiff";
534 dogvimdiff="installgvimdiff" ;;
535 huge) AC_DEFINE(FEAT_HUGE) dovimdiff="installvimdiff";
536 dogvimdiff="installgvimdiff" ;;
537 *) AC_MSG_RESULT([Sorry, $features is not supported]) ;;
538esac
539
540AC_SUBST(dovimdiff)
541AC_SUBST(dogvimdiff)
542
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 Moolenaarb3f74062020-02-26 16:16:53 +01002446 [ --enable-gui[=OPTS] X11 GUI. [default=auto] [OPTS=auto/no/gtk2/gnome2/gtk3/motif/athena/neXtaw/haiku/photon/carbon]], , enable_gui="auto")
Bram Moolenaar071d4272004-06-13 20:20:40 +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
2458SKIP_ATHENA=YES
2459SKIP_NEXTAW=YES
2460SKIP_PHOTON=YES
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002461SKIP_HAIKU=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002462GUITYPE=NONE
2463
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002464if test "x$HAIKU" = "xyes"; then
2465 SKIP_HAIKU=
2466 case "$enable_gui_canon" in
2467 no) AC_MSG_RESULT(no GUI support)
2468 SKIP_HAIKU=YES ;;
2469 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
2470 auto) AC_MSG_RESULT(auto - automatic GUI support) ;;
2471 haiku) AC_MSG_RESULT(Haiku GUI support) ;;
2472 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2473 SKIP_HAIKU=YES ;;
2474 esac
2475elif test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002476 SKIP_PHOTON=
2477 case "$enable_gui_canon" in
2478 no) AC_MSG_RESULT(no GUI support)
2479 SKIP_PHOTON=YES ;;
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002480 yes|""|auto) AC_MSG_RESULT(automatic GUI support)
2481 gui_auto=yes ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002482 photon) AC_MSG_RESULT(Photon GUI support) ;;
2483 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2484 SKIP_PHOTON=YES ;;
2485 esac
2486
Bram Moolenaar040f9752020-08-11 23:08:48 +02002487elif test "x$MACOS_X" = "xyes" -a "x$with_x" = "xno" ; then
2488 case "$enable_gui_canon" in
2489 no) AC_MSG_RESULT(no GUI support) ;;
2490 yes|"") AC_MSG_RESULT(yes - automatic GUI support)
2491 gui_auto=yes ;;
2492 auto) AC_MSG_RESULT(auto - disable GUI support for Mac OS) ;;
Bram Moolenaarbe7529e2020-08-13 21:05:39 +02002493 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
Bram Moolenaar040f9752020-08-11 23:08:48 +02002494 esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00002495else
2496
Bram Moolenaar071d4272004-06-13 20:20:40 +00002497 case "$enable_gui_canon" in
2498 no|none) AC_MSG_RESULT(no GUI support) ;;
2499 yes|""|auto) AC_MSG_RESULT(yes/auto - automatic GUI support)
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002500 gui_auto=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002501 SKIP_GTK2=
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002502 SKIP_GTK3=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002503 SKIP_GNOME=
2504 SKIP_MOTIF=
2505 SKIP_ATHENA=
Bram Moolenaar097148e2020-08-11 21:58:20 +02002506 SKIP_NEXTAW=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002507 gtk2) AC_MSG_RESULT(GTK+ 2.x GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002508 SKIP_GTK2=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002509 gnome2) AC_MSG_RESULT(GNOME 2.x GUI support)
2510 SKIP_GNOME=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002511 SKIP_GTK2=;;
Bram Moolenaar98921892016-02-23 17:14:37 +01002512 gtk3) AC_MSG_RESULT(GTK+ 3.x GUI support)
2513 SKIP_GTK3=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002514 motif) AC_MSG_RESULT(Motif GUI support)
2515 SKIP_MOTIF=;;
2516 athena) AC_MSG_RESULT(Athena GUI support)
2517 SKIP_ATHENA=;;
2518 nextaw) AC_MSG_RESULT(neXtaw GUI support)
2519 SKIP_NEXTAW=;;
2520 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
2521 esac
2522
2523fi
2524
Bram Moolenaar071d4272004-06-13 20:20:40 +00002525if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \
2526 -a "$enable_gui_canon" != "gnome2"; then
2527 AC_MSG_CHECKING(whether or not to look for GTK+ 2)
2528 AC_ARG_ENABLE(gtk2-check,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002529 [ --enable-gtk2-check If auto-select GUI, check for GTK+ 2 [default=yes]],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002530 , enable_gtk2_check="yes")
2531 AC_MSG_RESULT($enable_gtk2_check)
2532 if test "x$enable_gtk2_check" = "xno"; then
2533 SKIP_GTK2=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002534 SKIP_GNOME=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002535 fi
2536fi
2537
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002538if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002539 AC_MSG_CHECKING(whether or not to look for GNOME)
2540 AC_ARG_ENABLE(gnome-check,
2541 [ --enable-gnome-check If GTK GUI, check for GNOME [default=no]],
2542 , enable_gnome_check="no")
2543 AC_MSG_RESULT($enable_gnome_check)
2544 if test "x$enable_gnome_check" = "xno"; then
2545 SKIP_GNOME=YES
2546 fi
2547fi
2548
Bram Moolenaar98921892016-02-23 17:14:37 +01002549if test "x$SKIP_GTK3" != "xYES" -a "$enable_gui_canon" != "gtk3"; then
2550 AC_MSG_CHECKING(whether or not to look for GTK+ 3)
2551 AC_ARG_ENABLE(gtk3-check,
2552 [ --enable-gtk3-check If auto-select GUI, check for GTK+ 3 [default=yes]],
2553 , enable_gtk3_check="yes")
2554 AC_MSG_RESULT($enable_gtk3_check)
2555 if test "x$enable_gtk3_check" = "xno"; then
2556 SKIP_GTK3=YES
2557 fi
2558fi
2559
Bram Moolenaar071d4272004-06-13 20:20:40 +00002560if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then
2561 AC_MSG_CHECKING(whether or not to look for Motif)
2562 AC_ARG_ENABLE(motif-check,
2563 [ --enable-motif-check If auto-select GUI, check for Motif [default=yes]],
2564 , enable_motif_check="yes")
2565 AC_MSG_RESULT($enable_motif_check)
2566 if test "x$enable_motif_check" = "xno"; then
2567 SKIP_MOTIF=YES
2568 fi
2569fi
2570
2571if test "x$SKIP_ATHENA" != "xYES" -a "$enable_gui_canon" != "athena"; then
2572 AC_MSG_CHECKING(whether or not to look for Athena)
2573 AC_ARG_ENABLE(athena-check,
2574 [ --enable-athena-check If auto-select GUI, check for Athena [default=yes]],
2575 , enable_athena_check="yes")
2576 AC_MSG_RESULT($enable_athena_check)
2577 if test "x$enable_athena_check" = "xno"; then
2578 SKIP_ATHENA=YES
2579 fi
2580fi
2581
2582if test "x$SKIP_NEXTAW" != "xYES" -a "$enable_gui_canon" != "nextaw"; then
2583 AC_MSG_CHECKING(whether or not to look for neXtaw)
2584 AC_ARG_ENABLE(nextaw-check,
2585 [ --enable-nextaw-check If auto-select GUI, check for neXtaw [default=yes]],
2586 , enable_nextaw_check="yes")
2587 AC_MSG_RESULT($enable_nextaw_check);
2588 if test "x$enable_nextaw_check" = "xno"; then
2589 SKIP_NEXTAW=YES
2590 fi
2591fi
2592
Bram Moolenaar071d4272004-06-13 20:20:40 +00002593dnl define an autoconf function to check for a specified version of GTK, and
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002594dnl try to compile/link a GTK program.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002595dnl
2596dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002597dnl Test for GTK, and define GTK_CFLAGS, GTK_LIBDIR and GTK_LIBS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002598dnl
2599AC_DEFUN(AM_PATH_GTK,
2600[
2601 if test "X$GTK_CONFIG" != "Xno" -o "X$PKG_CONFIG" != "Xno"; then
2602 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00002603 no_gtk=""
2604 if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2605 && $PKG_CONFIG --exists gtk+-2.0; then
2606 {
Bram Moolenaar98921892016-02-23 17:14:37 +01002607 min_gtk_version=ifelse([$1], ,2.2.0,$1)
2608 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002609 dnl We should be using PKG_CHECK_MODULES() instead of this hack.
2610 dnl But I guess the dependency on pkgconfig.m4 is not wanted or
2611 dnl something like that.
2612 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0`
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002613 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-2.0`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002614 GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0`
2615 gtk_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2616 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2617 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2618 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2619 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2620 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2621 }
Bram Moolenaar98921892016-02-23 17:14:37 +01002622 elif (test "X$SKIP_GTK3" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2623 && $PKG_CONFIG --exists gtk+-3.0; then
2624 {
2625 min_gtk_version=ifelse([$1], ,3.0.0,$1)
2626 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
2627
2628 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-3.0`
2629 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-3.0`
2630 GTK_LIBS=`$PKG_CONFIG --libs gtk+-3.0`
2631 gtk_major_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2632 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2633 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2634 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2635 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2636 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2637 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002638 else
Bram Moolenaar67876de2021-01-12 20:51:24 +01002639 dnl Put some text before the "no" to hint at installing the gtk-dev
2640 dnl packages.
2641 AC_MSG_CHECKING(for GTK -dev package)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002642 no_gtk=yes
2643 fi
2644
2645 if test "x$enable_gtktest" = "xyes" -a "x$no_gtk" = "x"; then
2646 {
2647 ac_save_CFLAGS="$CFLAGS"
2648 ac_save_LIBS="$LIBS"
2649 CFLAGS="$CFLAGS $GTK_CFLAGS"
2650 LIBS="$LIBS $GTK_LIBS"
2651
2652 dnl
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002653 dnl Now check if the installed GTK is sufficiently new.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002654 dnl
2655 rm -f conf.gtktest
2656 AC_TRY_RUN([
2657#include <gtk/gtk.h>
2658#include <stdio.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00002659#if STDC_HEADERS
2660# include <stdlib.h>
2661# include <stddef.h>
2662#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002663
2664int
2665main ()
2666{
2667int major, minor, micro;
2668char *tmp_version;
2669
2670system ("touch conf.gtktest");
2671
2672/* HP/UX 9 (%@#!) writes to sscanf strings */
2673tmp_version = g_strdup("$min_gtk_version");
2674if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
2675 printf("%s, bad version string\n", "$min_gtk_version");
2676 exit(1);
2677 }
2678
2679if ((gtk_major_version > major) ||
2680 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
2681 ((gtk_major_version == major) && (gtk_minor_version == minor) &&
2682 (gtk_micro_version >= micro)))
2683{
2684 return 0;
2685}
2686return 1;
2687}
2688],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
2689 CFLAGS="$ac_save_CFLAGS"
2690 LIBS="$ac_save_LIBS"
2691 }
2692 fi
2693 if test "x$no_gtk" = x ; then
2694 if test "x$enable_gtktest" = "xyes"; then
2695 AC_MSG_RESULT(yes; found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2696 else
2697 AC_MSG_RESULT(found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2698 fi
2699 ifelse([$2], , :, [$2])
2700 else
2701 {
2702 AC_MSG_RESULT(no)
2703 GTK_CFLAGS=""
2704 GTK_LIBS=""
2705 ifelse([$3], , :, [$3])
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002706 if test "$fail_if_missing" = "yes" -a "X$gui_auto" != "Xyes"; then
2707 AC_MSG_ERROR([could not configure GTK])
2708 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002709 }
2710 fi
2711 }
2712 else
2713 GTK_CFLAGS=""
2714 GTK_LIBS=""
2715 ifelse([$3], , :, [$3])
2716 fi
2717 AC_SUBST(GTK_CFLAGS)
2718 AC_SUBST(GTK_LIBS)
2719 rm -f conf.gtktest
2720])
2721
2722dnl ---------------------------------------------------------------------------
2723dnl gnome
2724dnl ---------------------------------------------------------------------------
2725AC_DEFUN([GNOME_INIT_HOOK],
2726[
2727 AC_SUBST(GNOME_LIBS)
2728 AC_SUBST(GNOME_LIBDIR)
2729 AC_SUBST(GNOME_INCLUDEDIR)
2730
2731 AC_ARG_WITH(gnome-includes,
2732 [ --with-gnome-includes=DIR Specify location of GNOME headers],
2733 [CFLAGS="$CFLAGS -I$withval"]
2734 )
2735
2736 AC_ARG_WITH(gnome-libs,
2737 [ --with-gnome-libs=DIR Specify location of GNOME libs],
2738 [LDFLAGS="$LDFLAGS -L$withval" gnome_prefix=$withval]
2739 )
2740
2741 AC_ARG_WITH(gnome,
2742 [ --with-gnome Specify prefix for GNOME files],
2743 if test x$withval = xyes; then
2744 want_gnome=yes
2745 ifelse([$1], [], :, [$1])
2746 else
2747 if test "x$withval" = xno; then
2748 want_gnome=no
2749 else
2750 want_gnome=yes
2751 LDFLAGS="$LDFLAGS -L$withval/lib"
2752 CFLAGS="$CFLAGS -I$withval/include"
2753 gnome_prefix=$withval/lib
2754 fi
2755 fi,
2756 want_gnome=yes)
2757
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002758 if test "x$want_gnome" = xyes; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002759 {
2760 AC_MSG_CHECKING(for libgnomeui-2.0)
2761 if $PKG_CONFIG --exists libgnomeui-2.0; then
2762 AC_MSG_RESULT(yes)
2763 GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0`
2764 GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0`
2765 GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0`
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002766
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002767 dnl On FreeBSD we need -pthread but pkg-config doesn't include it.
2768 dnl This might not be the right way but it works for me...
2769 AC_MSG_CHECKING(for FreeBSD)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00002770 if test "$vim_cv_uname_output" = FreeBSD; then
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002771 AC_MSG_RESULT(yes, adding -pthread)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002772 GNOME_INCLUDEDIR="$GNOME_INCLUDEDIR -D_THREAD_SAFE"
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002773 GNOME_LIBS="$GNOME_LIBS -pthread"
2774 else
2775 AC_MSG_RESULT(no)
2776 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002777 $1
2778 else
2779 AC_MSG_RESULT(not found)
2780 if test "x$2" = xfail; then
2781 AC_MSG_ERROR(Could not find libgnomeui-2.0 via pkg-config)
2782 fi
2783 fi
2784 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002785 fi
2786])
2787
2788AC_DEFUN([GNOME_INIT],[
2789 GNOME_INIT_HOOK([],fail)
2790])
2791
Bram Moolenaar427f5b62019-06-09 13:43:51 +02002792if test "X$PKG_CONFIG" = "X"; then
2793 AC_PATH_TOOL(PKG_CONFIG, pkg-config, no)
2794fi
2795
Bram Moolenaar071d4272004-06-13 20:20:40 +00002796
2797dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002798dnl Check for GTK2. If it fails, then continue on for Motif as before...
Bram Moolenaar071d4272004-06-13 20:20:40 +00002799dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002800if test -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002801
2802 AC_MSG_CHECKING(--disable-gtktest argument)
2803 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2804 , enable_gtktest=yes)
2805 if test "x$enable_gtktest" = "xyes" ; then
2806 AC_MSG_RESULT(gtk test enabled)
2807 else
2808 AC_MSG_RESULT(gtk test disabled)
2809 fi
2810
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002811 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002812 dnl First try finding version 2.2.0 or later. The 2.0.x series has
2813 dnl problems (bold fonts, --remote doesn't work).
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002814 dnl Disable checking for GTK3 here, otherwise it's found when GTK2 is not
2815 dnl found.
2816 save_skip_gtk3=$SKIP_GTK3
2817 SKIP_GTK3=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002818 AM_PATH_GTK(2.2.0,
2819 [GUI_LIB_LOC="$GTK_LIBDIR"
2820 GTK_LIBNAME="$GTK_LIBS"
2821 GUI_INC_LOC="$GTK_CFLAGS"], )
2822 if test "x$GTK_CFLAGS" != "x"; then
Bram Moolenaar98921892016-02-23 17:14:37 +01002823 SKIP_GTK3=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002824 SKIP_ATHENA=YES
2825 SKIP_NEXTAW=YES
2826 SKIP_MOTIF=YES
2827 GUITYPE=GTK
2828 AC_SUBST(GTK_LIBNAME)
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002829 else
2830 SKIP_GTK3=$save_skip_gtk3
Bram Moolenaar071d4272004-06-13 20:20:40 +00002831 fi
2832 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002833 if test "x$GUITYPE" = "xGTK"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002834 dnl
2835 dnl if GTK exists, then check for GNOME.
2836 dnl
2837 if test -z "$SKIP_GNOME"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002838 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002839 GNOME_INIT_HOOK([have_gnome=yes])
2840 if test "x$have_gnome" = xyes ; then
2841 AC_DEFINE(FEAT_GUI_GNOME)
2842 GUI_INC_LOC="$GUI_INC_LOC $GNOME_INCLUDEDIR"
2843 GTK_LIBNAME="$GTK_LIBNAME $GNOME_LIBDIR $GNOME_LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002844 fi
2845 }
2846 fi
2847 fi
2848fi
2849
Bram Moolenaar98921892016-02-23 17:14:37 +01002850
2851dnl ---------------------------------------------------------------------------
2852dnl Check for GTK3.
2853dnl ---------------------------------------------------------------------------
2854if test -z "$SKIP_GTK3"; then
2855
2856 AC_MSG_CHECKING(--disable-gtktest argument)
2857 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2858 , enable_gtktest=yes)
2859 if test "x$enable_gtktest" = "xyes" ; then
2860 AC_MSG_RESULT(gtk test enabled)
2861 else
2862 AC_MSG_RESULT(gtk test disabled)
2863 fi
2864
Bram Moolenaar98921892016-02-23 17:14:37 +01002865 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002866 save_skip_gtk2=$SKIP_GTK2
2867 SKIP_GTK2=YES
Bram Moolenaar98921892016-02-23 17:14:37 +01002868 AM_PATH_GTK(3.0.0,
2869 [GUI_LIB_LOC="$GTK_LIBDIR"
2870 GTK_LIBNAME="$GTK_LIBS"
2871 GUI_INC_LOC="$GTK_CFLAGS"], )
2872 if test "x$GTK_CFLAGS" != "x"; then
2873 SKIP_GTK2=YES
2874 SKIP_GNOME=YES
2875 SKIP_ATHENA=YES
2876 SKIP_NEXTAW=YES
2877 SKIP_MOTIF=YES
2878 GUITYPE=GTK
2879 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar98921892016-02-23 17:14:37 +01002880 AC_DEFINE(USE_GTK3)
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002881 else
2882 SKIP_GTK2=$save_skip_gtk2
Bram Moolenaar98921892016-02-23 17:14:37 +01002883 fi
2884 fi
2885fi
2886
Bram Moolenaard2e03f02016-01-02 22:46:36 +01002887dnl Check the version of Gdk-Pixbuf. If the version is 2.31 or later and
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002888dnl glib-compile-resources is found in PATH, use GResource.
2889if test "x$GUITYPE" = "xGTK"; then
2890 AC_MSG_CHECKING([version of Gdk-Pixbuf])
2891 gdk_pixbuf_version=`$PKG_CONFIG --modversion gdk-pixbuf-2.0`
2892 if test "x$gdk_pixbuf_version" != x ; then
2893 gdk_pixbuf_version_minor=`echo $gdk_pixbuf_version | \
2894 sed -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/'`
2895 if test "x$gdk_pixbuf_version_minor" != x -a \
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002896 $gdk_pixbuf_version_minor -ge 31 ; then
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002897 AC_MSG_RESULT([OK.])
2898 AC_PATH_PROG(GLIB_COMPILE_RESOURCES,[glib-compile-resources],no)
2899 AC_MSG_CHECKING([glib-compile-resources])
2900 if test "x$GLIB_COMPILE_RESOURCES" = xno ; then
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002901 GLIB_COMPILE_RESOURCES=""
2902 AC_MSG_RESULT([cannot be found in PATH.])
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002903 else
2904 AC_MSG_RESULT([usable.])
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002905 AC_DEFINE(USE_GRESOURCE)
2906 GRESOURCE_SRC="auto/gui_gtk_gresources.c"
2907 GRESOURCE_OBJ="objects/gui_gtk_gresources.o"
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002908 fi
2909 else
2910 AC_MSG_RESULT([not usable.])
2911 fi
2912 else
2913 AC_MSG_RESULT([cannot obtain from pkg_config.])
2914 fi
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002915
2916 AC_MSG_CHECKING([--disable-icon-cache-update argument])
2917 AC_ARG_ENABLE(icon_cache_update,
2918 [ --disable-icon-cache-update update disabled],
2919 [],
2920 [enable_icon_cache_update="yes"])
2921 if test "$enable_icon_cache_update" = "yes"; then
2922 AC_MSG_RESULT([not set])
2923 AC_PATH_PROG(GTK_UPDATE_ICON_CACHE,[gtk-update-icon-cache],no)
2924 if test "x$GTK_UPDATE_ICON_CACHE" = "xno" ; then
2925 AC_MSG_RESULT([not found in PATH.])
2926 fi
2927 else
2928 AC_MSG_RESULT([update disabled])
2929 fi
2930
2931 AC_MSG_CHECKING([--disable-desktop-database-update argument])
2932 AC_ARG_ENABLE(desktop_database_update,
2933 [ --disable-desktop-database-update update disabled],
2934 [],
2935 [enable_desktop_database_update="yes"])
2936 if test "$enable_desktop_database_update" = "yes"; then
2937 AC_MSG_RESULT([not set])
2938 AC_PATH_PROG(UPDATE_DESKTOP_DATABASE,[update-desktop-database],no)
2939 if test "x$UPDATE_DESKTOP_DATABASE" = "xno" ; then
2940 AC_MSG_RESULT([not found in PATH.])
2941 fi
2942 else
2943 AC_MSG_RESULT([update disabled])
2944 fi
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002945fi
2946AC_SUBST(GLIB_COMPILE_RESOURCES)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002947AC_SUBST(GRESOURCE_SRC)
2948AC_SUBST(GRESOURCE_OBJ)
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002949AC_SUBST(GTK_UPDATE_ICON_CACHE)
2950AC_SUBST(UPDATE_DESKTOP_DATABASE)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002951
Bram Moolenaar071d4272004-06-13 20:20:40 +00002952dnl Check for Motif include files location.
2953dnl The LAST one found is used, this makes the highest version to be used,
2954dnl e.g. when Motif1.2 and Motif2.0 are both present.
2955
2956if test -z "$SKIP_MOTIF"; then
2957 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"
2958 dnl Remove "-I" from before $GUI_INC_LOC if it's there
2959 GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`"
2960
2961 AC_MSG_CHECKING(for location of Motif GUI includes)
2962 gui_includes="`echo $x_includes|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC"
2963 GUI_INC_LOC=
2964 for try in $gui_includes; do
2965 if test -f "$try/Xm/Xm.h"; then
2966 GUI_INC_LOC=$try
2967 fi
2968 done
2969 if test -n "$GUI_INC_LOC"; then
2970 if test "$GUI_INC_LOC" = /usr/include; then
2971 GUI_INC_LOC=
2972 AC_MSG_RESULT(in default path)
2973 else
2974 AC_MSG_RESULT($GUI_INC_LOC)
2975 fi
2976 else
2977 AC_MSG_RESULT(<not found>)
2978 SKIP_MOTIF=YES
2979 fi
2980fi
2981
2982dnl Check for Motif library files location. In the same order as the include
2983dnl files, to avoid a mixup if several versions are present
2984
2985if test -z "$SKIP_MOTIF"; then
2986 AC_MSG_CHECKING(--with-motif-lib argument)
2987 AC_ARG_WITH(motif-lib,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002988 [ --with-motif-lib=STRING Library for Motif ],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002989 [ MOTIF_LIBNAME="${withval}" ] )
2990
2991 if test -n "$MOTIF_LIBNAME"; then
2992 AC_MSG_RESULT($MOTIF_LIBNAME)
2993 GUI_LIB_LOC=
2994 else
2995 AC_MSG_RESULT(no)
2996
2997 dnl Remove "-L" from before $GUI_LIB_LOC if it's there
2998 GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
2999
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02003000 dnl Ubuntu has libXm.so in /usr/lib/i386-linux-gnu and elsewhere. The
3001 dnl linker will figure out which one to use, we only check if one exists.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003002 AC_MSG_CHECKING(for location of Motif GUI libs)
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02003003 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 +00003004 GUI_LIB_LOC=
3005 for try in $gui_libs; do
Bram Moolenaar325b7a22004-07-05 15:58:32 +00003006 for libtry in "$try"/libXm.a "$try"/libXm.so* "$try"/libXm.sl "$try"/libXm.dylib; do
Bram Moolenaar071d4272004-06-13 20:20:40 +00003007 if test -f "$libtry"; then
3008 GUI_LIB_LOC=$try
3009 fi
3010 done
3011 done
3012 if test -n "$GUI_LIB_LOC"; then
3013 dnl Remove /usr/lib, it causes trouble on some systems
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02003014 if test "$GUI_LIB_LOC" = /usr/lib \
3015 -o "$GUI_LIB_LOC" = /usr/lib/i386-linux-gnu \
3016 -o "$GUI_LIB_LOC" = /usr/lib/x86_64-linux-gnu; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003017 GUI_LIB_LOC=
3018 AC_MSG_RESULT(in default path)
3019 else
3020 if test -n "$GUI_LIB_LOC"; then
3021 AC_MSG_RESULT($GUI_LIB_LOC)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00003022 if test "$vim_cv_uname_output" = SunOS &&
3023 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003024 GUI_LIB_LOC="$GUI_LIB_LOC -R $GUI_LIB_LOC"
3025 fi
3026 fi
3027 fi
3028 MOTIF_LIBNAME=-lXm
3029 else
3030 AC_MSG_RESULT(<not found>)
3031 SKIP_MOTIF=YES
3032 fi
3033 fi
3034fi
3035
3036if test -z "$SKIP_MOTIF"; then
3037 SKIP_ATHENA=YES
3038 SKIP_NEXTAW=YES
3039 GUITYPE=MOTIF
3040 AC_SUBST(MOTIF_LIBNAME)
3041fi
3042
3043dnl Check if the Athena files can be found
3044
3045GUI_X_LIBS=
3046
3047if test -z "$SKIP_ATHENA"; then
3048 AC_MSG_CHECKING(if Athena header files can be found)
3049 cflags_save=$CFLAGS
3050 CFLAGS="$CFLAGS $X_CFLAGS"
3051 AC_TRY_COMPILE([
3052#include <X11/Intrinsic.h>
3053#include <X11/Xaw/Paned.h>], ,
3054 AC_MSG_RESULT(yes),
3055 AC_MSG_RESULT(no); SKIP_ATHENA=YES )
3056 CFLAGS=$cflags_save
3057fi
3058
3059if test -z "$SKIP_ATHENA"; then
3060 GUITYPE=ATHENA
3061fi
3062
3063if test -z "$SKIP_NEXTAW"; then
3064 AC_MSG_CHECKING(if neXtaw header files can be found)
3065 cflags_save=$CFLAGS
3066 CFLAGS="$CFLAGS $X_CFLAGS"
3067 AC_TRY_COMPILE([
3068#include <X11/Intrinsic.h>
3069#include <X11/neXtaw/Paned.h>], ,
3070 AC_MSG_RESULT(yes),
3071 AC_MSG_RESULT(no); SKIP_NEXTAW=YES )
3072 CFLAGS=$cflags_save
3073fi
3074
3075if test -z "$SKIP_NEXTAW"; then
3076 GUITYPE=NEXTAW
3077fi
3078
3079if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
3080 dnl Prepend -I and -L to $GUI_INC_LOC and $GUI_LIB_LOC if not empty
3081 dnl Avoid adding it when it twice
3082 if test -n "$GUI_INC_LOC"; then
3083 GUI_INC_LOC=-I"`echo $GUI_INC_LOC|sed 's%-I%%'`"
3084 fi
3085 if test -n "$GUI_LIB_LOC"; then
3086 GUI_LIB_LOC=-L"`echo $GUI_LIB_LOC|sed 's%-L%%'`"
3087 fi
3088
3089 dnl Check for -lXext and then for -lXmu
3090 ldflags_save=$LDFLAGS
3091 LDFLAGS="$X_LIBS $LDFLAGS"
3092 AC_CHECK_LIB(Xext, XShapeQueryExtension, [GUI_X_LIBS="-lXext"],,
3093 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3094 dnl For Solaris we need -lw and -ldl before linking with -lXmu works.
3095 AC_CHECK_LIB(w, wslen, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lw"],,
3096 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3097 AC_CHECK_LIB(dl, dlsym, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldl"],,
3098 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3099 AC_CHECK_LIB(Xmu, XmuCreateStippledPixmap, [GUI_X_LIBS="-lXmu $GUI_X_LIBS"],,
3100 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3101 if test -z "$SKIP_MOTIF"; then
3102 AC_CHECK_LIB(Xp, XpEndJob, [GUI_X_LIBS="-lXp $GUI_X_LIBS"],,
3103 [$GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3104 fi
3105 LDFLAGS=$ldflags_save
3106
3107 dnl Execute xmkmf to figure out if -DNARROWPROTO is needed.
3108 AC_MSG_CHECKING(for extra X11 defines)
3109 NARROW_PROTO=
3110 rm -fr conftestdir
3111 if mkdir conftestdir; then
3112 cd conftestdir
3113 cat > Imakefile <<'EOF'
3114acfindx:
3115 @echo 'NARROW_PROTO="${PROTO_DEFINES}"'
3116EOF
3117 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
3118 eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
3119 fi
3120 cd ..
3121 rm -fr conftestdir
3122 fi
3123 if test -z "$NARROW_PROTO"; then
3124 AC_MSG_RESULT(no)
3125 else
3126 AC_MSG_RESULT($NARROW_PROTO)
3127 fi
3128 AC_SUBST(NARROW_PROTO)
3129fi
3130
3131dnl Look for XSMP support - but don't necessarily restrict it to X11 GUIs
3132dnl use the X11 include path
3133if test "$enable_xsmp" = "yes"; then
3134 cppflags_save=$CPPFLAGS
3135 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3136 AC_CHECK_HEADERS(X11/SM/SMlib.h)
3137 CPPFLAGS=$cppflags_save
3138fi
3139
3140
Bram Moolenaar98921892016-02-23 17:14:37 +01003141if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF" -o -z "$SKIP_GTK2" -o -z "$SKIP_GTK3"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003142 dnl Check for X11/xpm.h and X11/Sunkeysym.h with the GUI include path
3143 cppflags_save=$CPPFLAGS
3144 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3145 AC_CHECK_HEADERS(X11/xpm.h X11/Sunkeysym.h)
3146
3147 dnl automatically disable XIM when XIMtext isn't in X11/Xlib.h
3148 if test ! "$enable_xim" = "no"; then
3149 AC_MSG_CHECKING(for XIMText in X11/Xlib.h)
3150 AC_EGREP_CPP(XIMText, [#include <X11/Xlib.h>],
3151 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +02003152 AC_MSG_RESULT(no; xim has been disabled); enable_xim="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00003153 fi
3154 CPPFLAGS=$cppflags_save
3155
Bram Moolenaar54612582019-11-21 17:13:31 +01003156 dnl automatically enable XIM in the GUI
3157 if test "$enable_xim" = "auto" -a "x$GUITYPE" != "xNONE" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003158 AC_MSG_RESULT(X GUI selected; xim has been enabled)
3159 enable_xim="yes"
3160 fi
3161fi
3162
3163if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
3164 cppflags_save=$CPPFLAGS
3165 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00003166dnl Xmu/Editres.h may exist but can only be used after including Intrinsic.h
3167 AC_MSG_CHECKING([for X11/Xmu/Editres.h])
3168 AC_TRY_COMPILE([
3169#include <X11/Intrinsic.h>
3170#include <X11/Xmu/Editres.h>],
3171 [int i; i = 0;],
3172 AC_MSG_RESULT(yes)
3173 AC_DEFINE(HAVE_X11_XMU_EDITRES_H),
3174 AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003175 CPPFLAGS=$cppflags_save
3176fi
3177
3178dnl Only use the Xm directory when compiling Motif, don't use it for Athena
3179if test -z "$SKIP_MOTIF"; then
3180 cppflags_save=$CPPFLAGS
3181 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003182 if test "$zOSUnix" = "yes"; then
3183 xmheader="Xm/Xm.h"
3184 else
3185 xmheader="Xm/Xm.h Xm/XpmP.h Xm/JoinSideT.h Xm/TraitP.h Xm/Manager.h
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02003186 Xm/UnhighlightT.h Xm/Notebook.h"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003187 fi
3188 AC_CHECK_HEADERS($xmheader)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003189
Bram Moolenaar77c19352012-06-13 19:19:41 +02003190 if test "x$ac_cv_header_Xm_XpmP_h" = "xyes"; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003191 dnl Solaris uses XpmAttributes_21, very annoying.
3192 AC_MSG_CHECKING([for XpmAttributes_21 in Xm/XpmP.h])
3193 AC_TRY_COMPILE([#include <Xm/XpmP.h>], [XpmAttributes_21 attr;],
3194 AC_MSG_RESULT(yes); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes_21),
3195 AC_MSG_RESULT(no); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
3196 )
3197 else
Bram Moolenaar57657d82006-04-21 22:12:41 +00003198 AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003199 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003200 CPPFLAGS=$cppflags_save
3201fi
3202
3203if test "x$GUITYPE" = "xNONE" -a "$enable_xim" = "yes"; then
3204 AC_MSG_RESULT(no GUI selected; xim has been disabled)
3205 enable_xim="no"
3206fi
3207if test "x$GUITYPE" = "xNONE" -a "$enable_fontset" = "yes"; then
3208 AC_MSG_RESULT(no GUI selected; fontset has been disabled)
3209 enable_fontset="no"
3210fi
Bram Moolenaar182c5be2010-06-25 05:37:59 +02003211if test "x$GUITYPE:$enable_fontset" = "xGTK:yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003212 AC_MSG_RESULT(GTK+ 2 GUI selected; fontset has been disabled)
3213 enable_fontset="no"
3214fi
3215
Bram Moolenaarb3f74062020-02-26 16:16:53 +01003216dnl There is no test for the Haiku GUI, if it's selected it's used
3217if test -z "$SKIP_HAIKU"; then
3218 GUITYPE=HAIKUGUI
3219fi
3220
Bram Moolenaar071d4272004-06-13 20:20:40 +00003221if test -z "$SKIP_PHOTON"; then
3222 GUITYPE=PHOTONGUI
3223fi
3224
3225AC_SUBST(GUI_INC_LOC)
3226AC_SUBST(GUI_LIB_LOC)
3227AC_SUBST(GUITYPE)
3228AC_SUBST(GUI_X_LIBS)
3229
3230if test "$enable_workshop" = "yes" -a -n "$SKIP_MOTIF"; then
3231 AC_MSG_ERROR([cannot use workshop without Motif])
3232fi
3233
3234dnl defining FEAT_XIM and FEAT_XFONTSET is delayed, so that they can be disabled
3235if test "$enable_xim" = "yes"; then
3236 AC_DEFINE(FEAT_XIM)
3237fi
3238if test "$enable_fontset" = "yes"; then
3239 AC_DEFINE(FEAT_XFONTSET)
3240fi
3241
3242
3243dnl ---------------------------------------------------------------------------
3244dnl end of GUI-checking
3245dnl ---------------------------------------------------------------------------
3246
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003247AC_MSG_CHECKING([for /proc link to executable])
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003248if test -L "/proc/self/exe"; then
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003249 dnl Linux
3250 AC_MSG_RESULT([/proc/self/exe])
3251 AC_DEFINE(PROC_EXE_LINK, "/proc/self/exe")
3252elif test -L "/proc/self/path/a.out"; then
3253 dnl Solaris
3254 AC_MSG_RESULT([/proc/self/path/a.out])
3255 AC_DEFINE(PROC_EXE_LINK, "/proc/self/path/a.out")
3256elif test -L "/proc/curproc/file"; then
3257 dnl FreeBSD
3258 AC_MSG_RESULT([/proc/curproc/file])
3259 AC_DEFINE(PROC_EXE_LINK, "/proc/curproc/file")
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003260else
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003261 AC_MSG_RESULT(no)
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003262fi
3263
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003264dnl Check for Cygwin, which needs an extra source file if not using X11
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003265AC_MSG_CHECKING(for CYGWIN or MSYS environment)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00003266case $vim_cv_uname_output in
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003267 CYGWIN*|MSYS*) CYGWIN=yes; AC_MSG_RESULT(yes)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003268 AC_MSG_CHECKING(for CYGWIN clipboard support)
3269 if test "x$with_x" = "xno" ; then
3270 OS_EXTRA_SRC=winclip.c; OS_EXTRA_OBJ=objects/winclip.o
3271 AC_MSG_RESULT(yes)
3272 AC_DEFINE(FEAT_CYGWIN_WIN32_CLIPBOARD)
3273 else
3274 AC_MSG_RESULT(no - using X11)
3275 fi ;;
3276
3277 *) CYGWIN=no; AC_MSG_RESULT(no);;
3278esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00003279
Bram Moolenaar071d4272004-06-13 20:20:40 +00003280dnl Checks for libraries and include files.
3281
Bram Moolenaar446cb832008-06-24 21:56:24 +00003282AC_CACHE_CHECK([whether toupper is broken], [vim_cv_toupper_broken],
3283 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003284 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003285#include "confdefs.h"
3286#include <ctype.h>
3287#if STDC_HEADERS
3288# include <stdlib.h>
3289# include <stddef.h>
3290#endif
3291main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003292 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003293 vim_cv_toupper_broken=yes
3294 ],[
3295 vim_cv_toupper_broken=no
3296 ],[
3297 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_toupper_broken')
3298 ])])
3299
3300if test "x$vim_cv_toupper_broken" = "xyes" ; then
3301 AC_DEFINE(BROKEN_TOUPPER)
3302fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003303
3304AC_MSG_CHECKING(whether __DATE__ and __TIME__ work)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003305AC_TRY_COMPILE([#include <stdio.h>], [printf("(" __DATE__ " " __TIME__ ")");],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003306 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DATE_TIME),
3307 AC_MSG_RESULT(no))
3308
Bram Moolenaar0c094b92009-05-14 20:20:33 +00003309AC_MSG_CHECKING(whether __attribute__((unused)) is allowed)
3310AC_TRY_COMPILE([#include <stdio.h>], [int x __attribute__((unused));],
3311 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ATTRIBUTE_UNUSED),
3312 AC_MSG_RESULT(no))
3313
Bram Moolenaar071d4272004-06-13 20:20:40 +00003314dnl Checks for header files.
3315AC_CHECK_HEADER(elf.h, HAS_ELF=1)
3316dnl AC_CHECK_HEADER(dwarf.h, SVR4=1)
3317if test "$HAS_ELF" = 1; then
3318 AC_CHECK_LIB(elf, main)
3319fi
3320
3321AC_HEADER_DIRENT
3322
Bram Moolenaar071d4272004-06-13 20:20:40 +00003323dnl If sys/wait.h is not found it might still exist but not be POSIX
3324dnl compliant. In that case we define HAVE_UNION_WAIT (for NeXT)
3325if test $ac_cv_header_sys_wait_h = no; then
3326 AC_MSG_CHECKING([for sys/wait.h that defines union wait])
3327 AC_TRY_COMPILE([#include <sys/wait.h>],
3328 [union wait xx, yy; xx = yy],
3329 AC_MSG_RESULT(yes)
3330 AC_DEFINE(HAVE_SYS_WAIT_H)
3331 AC_DEFINE(HAVE_UNION_WAIT),
3332 AC_MSG_RESULT(no))
3333fi
3334
Bram Moolenaar779a7752016-01-30 23:26:34 +01003335AC_CHECK_HEADERS(stdint.h stdlib.h string.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003336 sys/select.h sys/utsname.h termcap.h fcntl.h \
3337 sgtty.h sys/ioctl.h sys/time.h sys/types.h \
3338 termio.h iconv.h inttypes.h langinfo.h math.h \
3339 unistd.h stropts.h errno.h sys/resource.h \
3340 sys/systeminfo.h locale.h sys/stream.h termios.h \
3341 libc.h sys/statfs.h poll.h sys/poll.h pwd.h \
Bram Moolenaar1ecc5e42019-01-26 15:12:55 +01003342 utime.h sys/param.h sys/ptms.h libintl.h libgen.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003343 util/debug.h util/msg18n.h frame.h sys/acl.h \
3344 sys/access.h sys/sysinfo.h wchar.h wctype.h)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003345
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003346dnl sys/ptem.h depends on sys/stream.h on Solaris
3347AC_CHECK_HEADERS(sys/ptem.h, [], [],
3348[#if defined HAVE_SYS_STREAM_H
3349# include <sys/stream.h>
3350#endif])
3351
Bram Moolenaar32f31b12009-05-21 13:20:59 +00003352dnl sys/sysctl.h depends on sys/param.h on OpenBSD
3353AC_CHECK_HEADERS(sys/sysctl.h, [], [],
3354[#if defined HAVE_SYS_PARAM_H
3355# include <sys/param.h>
3356#endif])
3357
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003358
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003359dnl pthread_np.h may exist but can only be used after including pthread.h
3360AC_MSG_CHECKING([for pthread_np.h])
3361AC_TRY_COMPILE([
3362#include <pthread.h>
3363#include <pthread_np.h>],
3364 [int i; i = 0;],
3365 AC_MSG_RESULT(yes)
3366 AC_DEFINE(HAVE_PTHREAD_NP_H),
3367 AC_MSG_RESULT(no))
3368
Bram Moolenaare344bea2005-09-01 20:46:49 +00003369AC_CHECK_HEADERS(strings.h)
Bram Moolenaard0573012017-10-28 21:11:06 +02003370if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00003371 dnl The strings.h file on OS/X contains a warning and nothing useful.
3372 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3373else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003374
3375dnl Check if strings.h and string.h can both be included when defined.
3376AC_MSG_CHECKING([if strings.h can be included after string.h])
3377cppflags_save=$CPPFLAGS
3378CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3379AC_TRY_COMPILE([
3380#if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO)
3381# define _NO_PROTO /* like in os_unix.h, causes conflict for AIX (Winn) */
3382 /* but don't do it on AIX 5.1 (Uribarri) */
3383#endif
3384#ifdef HAVE_XM_XM_H
3385# include <Xm/Xm.h> /* This breaks it for HP-UX 11 (Squassabia) */
3386#endif
3387#ifdef HAVE_STRING_H
3388# include <string.h>
3389#endif
3390#if defined(HAVE_STRINGS_H)
3391# include <strings.h>
3392#endif
3393 ], [int i; i = 0;],
3394 AC_MSG_RESULT(yes),
3395 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3396 AC_MSG_RESULT(no))
3397CPPFLAGS=$cppflags_save
Bram Moolenaar9372a112005-12-06 19:59:18 +00003398fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003399
3400dnl Checks for typedefs, structures, and compiler characteristics.
3401AC_PROG_GCC_TRADITIONAL
3402AC_C_CONST
Bram Moolenaar76243bd2009-03-02 01:47:02 +00003403AC_C_VOLATILE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003404AC_TYPE_MODE_T
3405AC_TYPE_OFF_T
3406AC_TYPE_PID_T
3407AC_TYPE_SIZE_T
3408AC_TYPE_UID_T
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003409AC_TYPE_UINT32_T
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003410
Bram Moolenaar071d4272004-06-13 20:20:40 +00003411AC_HEADER_TIME
3412AC_CHECK_TYPE(ino_t, long)
3413AC_CHECK_TYPE(dev_t, unsigned)
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003414AC_C_BIGENDIAN(,,,)
Bram Moolenaar136f29a2016-02-27 20:14:15 +01003415AC_C_INLINE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003416
3417AC_MSG_CHECKING(for rlim_t)
3418if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
3419 AC_MSG_RESULT([(cached) $ac_cv_type_rlim_t])
3420else
3421 AC_EGREP_CPP(dnl
3422changequote(<<,>>)dnl
3423<<(^|[^a-zA-Z_0-9])rlim_t[^a-zA-Z_0-9]>>dnl
3424changequote([,]),
3425 [
3426#include <sys/types.h>
3427#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003428# include <stdlib.h>
3429# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003430#endif
3431#ifdef HAVE_SYS_RESOURCE_H
Bram Moolenaar446cb832008-06-24 21:56:24 +00003432# include <sys/resource.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003433#endif
3434 ], ac_cv_type_rlim_t=yes, ac_cv_type_rlim_t=no)
3435 AC_MSG_RESULT($ac_cv_type_rlim_t)
3436fi
3437if test $ac_cv_type_rlim_t = no; then
3438 cat >> confdefs.h <<\EOF
3439#define rlim_t unsigned long
3440EOF
3441fi
3442
3443AC_MSG_CHECKING(for stack_t)
3444if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then
3445 AC_MSG_RESULT([(cached) $ac_cv_type_stack_t])
3446else
3447 AC_EGREP_CPP(stack_t,
3448 [
3449#include <sys/types.h>
3450#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003451# include <stdlib.h>
3452# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003453#endif
3454#include <signal.h>
3455 ], ac_cv_type_stack_t=yes, ac_cv_type_stack_t=no)
3456 AC_MSG_RESULT($ac_cv_type_stack_t)
3457fi
3458if test $ac_cv_type_stack_t = no; then
3459 cat >> confdefs.h <<\EOF
3460#define stack_t struct sigaltstack
3461EOF
3462fi
3463
3464dnl BSDI uses ss_base while others use ss_sp for the stack pointer.
3465AC_MSG_CHECKING(whether stack_t has an ss_base field)
3466AC_TRY_COMPILE([
3467#include <sys/types.h>
3468#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003469# include <stdlib.h>
3470# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003471#endif
3472#include <signal.h>
3473#include "confdefs.h"
3474 ], [stack_t sigstk; sigstk.ss_base = 0; ],
3475 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SS_BASE),
3476 AC_MSG_RESULT(no))
3477
3478olibs="$LIBS"
3479AC_MSG_CHECKING(--with-tlib argument)
3480AC_ARG_WITH(tlib, [ --with-tlib=library terminal library to be used ],)
3481if test -n "$with_tlib"; then
3482 AC_MSG_RESULT($with_tlib)
3483 LIBS="$LIBS -l$with_tlib"
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003484 AC_MSG_CHECKING(for linking with $with_tlib library)
3485 AC_TRY_LINK([], [], AC_MSG_RESULT(OK), AC_MSG_ERROR(FAILED))
3486 dnl Need to check for tgetent() below.
3487 olibs="$LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003488else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003489 AC_MSG_RESULT([empty: automatic terminal library selection])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003490 dnl On HP-UX 10.10 termcap or termlib should be used instead of
3491 dnl curses, because curses is much slower.
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003492 dnl Newer versions of ncurses are preferred over anything, except
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02003493 dnl when tinfo has been split off, it contains all we need.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003494 dnl Older versions of ncurses have bugs, get a new one!
3495 dnl Digital Unix (OSF1) should use curses (Ronald Schild).
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00003496 dnl On SCO Openserver should prefer termlib (Roger Cornelius).
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00003497 case "$vim_cv_uname_output" in
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003498 OSF1|SCO_SV) tlibs="tinfo ncurses curses termlib termcap";;
3499 *) tlibs="tinfo ncurses termlib termcap curses";;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003500 esac
3501 for libname in $tlibs; do
3502 AC_CHECK_LIB(${libname}, tgetent,,)
3503 if test "x$olibs" != "x$LIBS"; then
3504 dnl It's possible that a library is found but it doesn't work
3505 dnl e.g., shared library that cannot be found
3506 dnl compile and run a test program to be sure
3507 AC_TRY_RUN([
3508#ifdef HAVE_TERMCAP_H
3509# include <termcap.h>
3510#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003511#if STDC_HEADERS
3512# include <stdlib.h>
3513# include <stddef.h>
3514#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003515main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }],
3516 res="OK", res="FAIL", res="FAIL")
3517 if test "$res" = "OK"; then
3518 break
3519 fi
3520 AC_MSG_RESULT($libname library is not usable)
3521 LIBS="$olibs"
3522 fi
3523 done
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003524 if test "x$olibs" = "x$LIBS"; then
3525 AC_MSG_RESULT(no terminal library found)
3526 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003527fi
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003528
3529if test "x$olibs" = "x$LIBS"; then
3530 AC_MSG_CHECKING([for tgetent()])
Bram Moolenaarbd7f7c12020-07-28 21:03:37 +02003531 AC_TRY_LINK([int tgetent(char *, const char *);],
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003532 [char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");],
3533 AC_MSG_RESULT(yes),
3534 AC_MSG_ERROR([NOT FOUND!
3535 You need to install a terminal library; for example ncurses.
Bram Moolenaar16678eb2021-04-21 11:57:59 +02003536 On Linux that would be the libncurses-dev package.
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003537 Or specify the name of the library with --with-tlib.]))
3538fi
3539
Bram Moolenaar446cb832008-06-24 21:56:24 +00003540AC_CACHE_CHECK([whether we talk terminfo], [vim_cv_terminfo],
3541 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003542 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003543#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003544#ifdef HAVE_TERMCAP_H
3545# include <termcap.h>
3546#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003547#ifdef HAVE_STRING_H
3548# include <string.h>
3549#endif
3550#if STDC_HEADERS
3551# include <stdlib.h>
3552# include <stddef.h>
3553#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003554main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003555{char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003556 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003557 vim_cv_terminfo=no
3558 ],[
3559 vim_cv_terminfo=yes
3560 ],[
3561 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_terminfo')
3562 ])
3563 ])
3564
3565if test "x$vim_cv_terminfo" = "xyes" ; then
3566 AC_DEFINE(TERMINFO)
3567fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003568
Bram Moolenaara88254f2017-11-02 23:04:14 +01003569AC_CACHE_CHECK([what tgetent() returns for an unknown terminal], [vim_cv_tgetent],
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003570 [
3571 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003572#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003573#ifdef HAVE_TERMCAP_H
3574# include <termcap.h>
3575#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003576#if STDC_HEADERS
3577# include <stdlib.h>
3578# include <stddef.h>
3579#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003580main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003581{char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003582 ]])],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003583 vim_cv_tgetent=zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003584 ],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003585 vim_cv_tgetent=non-zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003586 ],[
3587 AC_MSG_ERROR(failed to compile test program.)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003588 ])
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003589 ])
3590
Bram Moolenaara88254f2017-11-02 23:04:14 +01003591if test "x$vim_cv_tgetent" = "xzero" ; then
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003592 AC_DEFINE(TGETENT_ZERO_ERR, 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003593fi
3594
3595AC_MSG_CHECKING(whether termcap.h contains ospeed)
3596AC_TRY_LINK([
3597#ifdef HAVE_TERMCAP_H
3598# include <termcap.h>
3599#endif
3600 ], [ospeed = 20000],
3601 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED),
3602 [AC_MSG_RESULT(no)
3603 AC_MSG_CHECKING(whether ospeed can be extern)
3604 AC_TRY_LINK([
3605#ifdef HAVE_TERMCAP_H
3606# include <termcap.h>
3607#endif
3608extern short ospeed;
3609 ], [ospeed = 20000],
3610 AC_MSG_RESULT(yes); AC_DEFINE(OSPEED_EXTERN),
3611 AC_MSG_RESULT(no))]
3612 )
3613
3614AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC])
3615AC_TRY_LINK([
3616#ifdef HAVE_TERMCAP_H
3617# include <termcap.h>
3618#endif
3619 ], [if (UP == 0 && BC == 0) PC = 1],
3620 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UP_BC_PC),
3621 [AC_MSG_RESULT(no)
3622 AC_MSG_CHECKING([whether UP, BC and PC can be extern])
3623 AC_TRY_LINK([
3624#ifdef HAVE_TERMCAP_H
3625# include <termcap.h>
3626#endif
3627extern char *UP, *BC, PC;
3628 ], [if (UP == 0 && BC == 0) PC = 1],
3629 AC_MSG_RESULT(yes); AC_DEFINE(UP_BC_PC_EXTERN),
3630 AC_MSG_RESULT(no))]
3631 )
3632
3633AC_MSG_CHECKING(whether tputs() uses outfuntype)
3634AC_TRY_COMPILE([
3635#ifdef HAVE_TERMCAP_H
3636# include <termcap.h>
3637#endif
3638 ], [extern int xx(); tputs("test", 1, (outfuntype)xx)],
3639 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OUTFUNTYPE),
3640 AC_MSG_RESULT(no))
3641
Bram Moolenaarb3a29552021-11-19 11:28:04 +00003642AC_MSG_CHECKING([whether del_curterm() can be used])
3643AC_TRY_LINK([
3644#ifdef HAVE_TERMCAP_H
3645# include <termcap.h>
3646#endif
3647#include <term.h>
3648 ], [if (cur_term) del_curterm(cur_term);],
3649 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DEL_CURTERM),
3650 AC_MSG_RESULT(no))
3651
Bram Moolenaar071d4272004-06-13 20:20:40 +00003652dnl On some SCO machines sys/select redefines struct timeval
3653AC_MSG_CHECKING([whether sys/select.h and sys/time.h may both be included])
3654AC_TRY_COMPILE([
3655#include <sys/types.h>
3656#include <sys/time.h>
3657#include <sys/select.h>], ,
3658 AC_MSG_RESULT(yes)
3659 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME),
3660 AC_MSG_RESULT(no))
3661
3662dnl AC_DECL_SYS_SIGLIST
3663
3664dnl Checks for pty.c (copied from screen) ==========================
3665AC_MSG_CHECKING(for /dev/ptc)
3666if test -r /dev/ptc; then
3667 AC_DEFINE(HAVE_DEV_PTC)
3668 AC_MSG_RESULT(yes)
3669else
3670 AC_MSG_RESULT(no)
3671fi
3672
3673AC_MSG_CHECKING(for SVR4 ptys)
3674if test -c /dev/ptmx ; then
Bram Moolenaarce7be3a2020-11-26 20:11:11 +01003675 AC_TRY_LINK([
3676// These should be in stdlib.h, but it depends on _XOPEN_SOURCE.
3677char *ptsname(int);
3678int unlockpt(int);
3679int grantpt(int);
3680 ], [
3681 ptsname(0);
3682 grantpt(0);
3683 unlockpt(0);],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003684 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SVR4_PTYS),
3685 AC_MSG_RESULT(no))
3686else
3687 AC_MSG_RESULT(no)
3688fi
3689
3690AC_MSG_CHECKING(for ptyranges)
3691if test -d /dev/ptym ; then
3692 pdir='/dev/ptym'
3693else
3694 pdir='/dev'
3695fi
3696dnl SCO uses ptyp%d
3697AC_EGREP_CPP(yes,
3698[#ifdef M_UNIX
3699 yes;
3700#endif
3701 ], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
3702dnl if test -c /dev/ptyp19; then
3703dnl ptys=`echo /dev/ptyp??`
3704dnl else
3705dnl ptys=`echo $pdir/pty??`
3706dnl fi
3707if test "$ptys" != "$pdir/pty??" ; then
3708 p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
3709 p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'`
3710 AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
3711 AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
3712 AC_MSG_RESULT([$p0 / $p1])
3713else
3714 AC_MSG_RESULT([don't know])
3715fi
3716
Bram Moolenaar071d4272004-06-13 20:20:40 +00003717dnl Checks for library functions. ===================================
3718
3719AC_TYPE_SIGNAL
3720
3721dnl find out what to use at the end of a signal function
3722if test $ac_cv_type_signal = void; then
3723 AC_DEFINE(SIGRETURN, [return])
3724else
3725 AC_DEFINE(SIGRETURN, [return 0])
3726fi
3727
3728dnl check if struct sigcontext is defined (used for SGI only)
3729AC_MSG_CHECKING(for struct sigcontext)
3730AC_TRY_COMPILE([
3731#include <signal.h>
3732test_sig()
3733{
3734 struct sigcontext *scont;
3735 scont = (struct sigcontext *)0;
3736 return 1;
3737} ], ,
3738 AC_MSG_RESULT(yes)
3739 AC_DEFINE(HAVE_SIGCONTEXT),
3740 AC_MSG_RESULT(no))
3741
3742dnl tricky stuff: try to find out if getcwd() is implemented with
3743dnl system("sh -c pwd")
Bram Moolenaar446cb832008-06-24 21:56:24 +00003744AC_CACHE_CHECK([getcwd implementation is broken], [vim_cv_getcwd_broken],
3745 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003746 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003747#include "confdefs.h"
3748#ifdef HAVE_UNISTD_H
3749#include <unistd.h>
3750#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003751char *dagger[] = { "IFS=pwd", 0 };
3752main()
3753{
3754 char buffer[500];
3755 extern char **environ;
3756 environ = dagger;
3757 return getcwd(buffer, 500) ? 0 : 1;
Bram Moolenaar446cb832008-06-24 21:56:24 +00003758}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003759 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003760 vim_cv_getcwd_broken=no
3761 ],[
3762 vim_cv_getcwd_broken=yes
3763 ],[
3764 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_getcwd_broken')
3765 ])
3766 ])
3767
3768if test "x$vim_cv_getcwd_broken" = "xyes" ; then
3769 AC_DEFINE(BAD_GETCWD)
Bram Moolenaar63d25552019-05-10 21:28:38 +02003770 AC_CHECK_FUNCS(getwd)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003771fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003772
Bram Moolenaar25153e12010-02-24 14:47:08 +01003773dnl Check for functions in one big call, to reduce the size of configure.
3774dnl Can only be used for functions that do not require any include.
Bram Moolenaarcd142e32017-11-16 17:03:45 +01003775AC_CHECK_FUNCS(fchdir fchown fchmod fsync getcwd getpseudotty \
Bram Moolenaar63d25552019-05-10 21:28:38 +02003776 getpwent getpwnam getpwuid getrlimit gettimeofday localtime_r lstat \
Bram Moolenaareaf03392009-11-17 11:08:52 +00003777 memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
Bram Moolenaar2fcf6682017-03-11 20:03:42 +01003778 getpgid setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
Bram Moolenaar84cf6bd2020-06-16 20:03:43 +02003779 sigprocmask sigvec strcasecmp strcoll strerror strftime stricmp strncasecmp \
Bram Moolenaar10455d42019-11-21 15:36:18 +01003780 strnicmp strpbrk strptime strtol tgetent towlower towupper iswupper \
3781 tzset usleep utime utimes mblen ftruncate unsetenv posix_openpt)
Bram Moolenaar643b6142018-09-12 20:29:09 +02003782AC_FUNC_SELECT_ARGTYPES
Bram Moolenaar25153e12010-02-24 14:47:08 +01003783AC_FUNC_FSEEKO
Bram Moolenaar071d4272004-06-13 20:20:40 +00003784
Bram Moolenaar317fd3a2010-05-07 16:05:55 +02003785dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when
3786dnl appropriate, so that off_t is 64 bits when needed.
3787AC_SYS_LARGEFILE
3788
Bram Moolenaar21606672019-06-14 20:40:58 +02003789AC_MSG_CHECKING(--enable-canberra argument)
3790AC_ARG_ENABLE(canberra,
3791 [ --disable-canberra Do not use libcanberra.],
3792 , [enable_canberra="maybe"])
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003793
Bram Moolenaar21606672019-06-14 20:40:58 +02003794if test "$enable_canberra" = "maybe"; then
3795 if test "$features" = "big" -o "$features" = "huge"; then
3796 AC_MSG_RESULT(Defaulting to yes)
3797 enable_canberra="yes"
3798 else
3799 AC_MSG_RESULT(Defaulting to no)
3800 enable_canberra="no"
3801 fi
3802else
Bram Moolenaar12471262022-01-18 11:11:25 +00003803 if test "$enable_canberra" = "yes" -a "$has_eval" = "no"; then
3804 AC_MSG_RESULT([cannot use sound with tiny or small features])
3805 enable_canberra="no"
3806 else
3807 AC_MSG_RESULT($enable_canberra)
3808 fi
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003809fi
Bram Moolenaar21606672019-06-14 20:40:58 +02003810if test "$enable_canberra" = "yes"; then
3811 if test "x$PKG_CONFIG" != "xno"; then
3812 canberra_lib=`$PKG_CONFIG --libs libcanberra 2>/dev/null`
3813 canberra_cflags=`$PKG_CONFIG --cflags libcanberra 2>/dev/null`
3814 fi
3815 if test "x$canberra_lib" = "x"; then
3816 canberra_lib=-lcanberra
3817 canberra_cflags=-D_REENTRANT
3818 fi
3819 AC_MSG_CHECKING(for libcanberra)
3820 ac_save_CFLAGS="$CFLAGS"
3821 ac_save_LIBS="$LIBS"
Bram Moolenaar12471262022-01-18 11:11:25 +00003822 if `echo "$CFLAGS" | grep -v "$canberra_cflags" 2>/dev/null`; then
Christian Brabandt6b9efdd2021-09-09 17:14:50 +02003823 CFLAGS="$CFLAGS $canberra_cflags"
3824 fi
Bram Moolenaar21606672019-06-14 20:40:58 +02003825 LIBS="$LIBS $canberra_lib"
3826 AC_TRY_LINK([
3827 # include <canberra.h>
3828 ], [
3829 ca_context *hello;
3830 ca_context_create(&hello);],
3831 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_CANBERRA),
Bram Moolenaar91b992c2019-11-17 19:07:42 +01003832 AC_MSG_RESULT(no; try installing libcanberra-dev); CFLAGS="$ac_save_CFLAGS"; LIBS="$ac_save_LIBS")
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003833fi
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003834
Christian Brabandtf573c6e2021-06-20 14:02:16 +02003835AC_MSG_CHECKING(--enable-libsodium argument)
3836AC_ARG_ENABLE(libsodium,
3837 [ --disable-libsodium Do not use libsodium.],
3838 , [enable_libsodium="maybe"])
3839
3840if test "$enable_libsodium" = "maybe"; then
3841 if test "$features" = "big" -o "$features" = "huge"; then
3842 AC_MSG_RESULT(Defaulting to yes)
3843 enable_libsodium="yes"
3844 else
3845 AC_MSG_RESULT(Defaulting to no)
3846 enable_libsodium="no"
3847 fi
3848else
3849 AC_MSG_RESULT($enable_libsodium)
3850fi
3851if test "$enable_libsodium" = "yes"; then
3852 if test "x$PKG_CONFIG" != "xno"; then
3853 libsodium_lib=`$PKG_CONFIG --libs libsodium 2>/dev/null`
3854 libsodium_cflags=`$PKG_CONFIG --cflags libsodium 2>/dev/null`
3855 fi
3856 if test "x$libsodium_lib" = "x"; then
3857 libsodium_lib=-lsodium
3858 libsodium_cflags=
3859 fi
ichizok8ce3ca82021-06-23 15:41:52 +02003860 AC_MSG_CHECKING(for libsodium)
Christian Brabandtf573c6e2021-06-20 14:02:16 +02003861 ac_save_CFLAGS="$CFLAGS"
3862 ac_save_LIBS="$LIBS"
3863 CFLAGS="$CFLAGS $libsodium_cflags"
3864 LIBS="$LIBS $libsodium_lib"
3865 AC_TRY_LINK([
3866 # include <sodium.h>
3867 ], [
3868 printf("%d", sodium_init()); ],
3869 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SODIUM),
3870 AC_MSG_RESULT(no; try installing libsodium-dev); CFLAGS="$ac_save_CFLAGS"; LIBS="$ac_save_LIBS")
3871fi
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003872
Bram Moolenaar071d4272004-06-13 20:20:40 +00003873dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible
3874AC_MSG_CHECKING(for st_blksize)
3875AC_TRY_COMPILE(
3876[#include <sys/types.h>
3877#include <sys/stat.h>],
3878[ struct stat st;
3879 int n;
3880
3881 stat("/", &st);
3882 n = (int)st.st_blksize;],
3883 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ST_BLKSIZE),
3884 AC_MSG_RESULT(no))
3885
Bram Moolenaar446cb832008-06-24 21:56:24 +00003886AC_CACHE_CHECK([whether stat() ignores a trailing slash], [vim_cv_stat_ignores_slash],
3887 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003888 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003889#include "confdefs.h"
3890#if STDC_HEADERS
3891# include <stdlib.h>
3892# include <stddef.h>
3893#endif
3894#include <sys/types.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003895#include <sys/stat.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003896main() {struct stat st; exit(stat("configure/", &st) != 0); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003897 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003898 vim_cv_stat_ignores_slash=yes
3899 ],[
3900 vim_cv_stat_ignores_slash=no
3901 ],[
3902 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_stat_ignores_slash')
3903 ])
3904 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003905
Bram Moolenaar446cb832008-06-24 21:56:24 +00003906if test "x$vim_cv_stat_ignores_slash" = "xyes" ; then
3907 AC_DEFINE(STAT_IGNORES_SLASH)
3908fi
Leah Neukirchen0a7984a2021-10-14 21:27:55 +01003909
3910dnl nanoseconds field of struct stat
3911AC_CACHE_CHECK([for nanoseconds field of struct stat],
3912 ac_cv_struct_st_mtim_nsec,
3913 [ac_save_CPPFLAGS="$CPPFLAGS"
3914 ac_cv_struct_st_mtim_nsec=no
3915 # st_mtim.tv_nsec -- the usual case
3916 # st_mtim._tv_nsec -- Solaris 2.6, if
3917 # (defined _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED == 1
3918 # && !defined __EXTENSIONS__)
3919 # st_mtim.st__tim.tv_nsec -- UnixWare 2.1.2
3920 # st_mtime_n -- AIX 5.2 and above
3921 # st_mtimespec.tv_nsec -- Darwin (Mac OSX)
3922 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
3923 CPPFLAGS="$ac_save_CPPFLAGS -DST_MTIM_NSEC=$ac_val"
3924 AC_TRY_COMPILE([#include <sys/types.h>
3925#include <sys/stat.h>], [struct stat s; s.ST_MTIM_NSEC;],
3926 [ac_cv_struct_st_mtim_nsec=$ac_val; break])
3927 done
3928 CPPFLAGS="$ac_save_CPPFLAGS"
3929])
3930if test $ac_cv_struct_st_mtim_nsec != no; then
3931 AC_DEFINE_UNQUOTED([ST_MTIM_NSEC], [$ac_cv_struct_st_mtim_nsec],
3932 [Define if struct stat contains a nanoseconds field])
3933fi
Bram Moolenaar446cb832008-06-24 21:56:24 +00003934
Bram Moolenaar071d4272004-06-13 20:20:40 +00003935dnl Link with iconv for charset translation, if not found without library.
3936dnl check for iconv() requires including iconv.h
3937dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
3938dnl has been installed.
3939AC_MSG_CHECKING(for iconv_open())
3940save_LIBS="$LIBS"
3941LIBS="$LIBS -liconv"
3942AC_TRY_LINK([
3943#ifdef HAVE_ICONV_H
3944# include <iconv.h>
3945#endif
3946 ], [iconv_open("fr", "to");],
3947 AC_MSG_RESULT(yes; with -liconv); AC_DEFINE(HAVE_ICONV),
3948 LIBS="$save_LIBS"
3949 AC_TRY_LINK([
3950#ifdef HAVE_ICONV_H
3951# include <iconv.h>
3952#endif
3953 ], [iconv_open("fr", "to");],
3954 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ICONV),
3955 AC_MSG_RESULT(no)))
3956
3957
3958AC_MSG_CHECKING(for nl_langinfo(CODESET))
3959AC_TRY_LINK([
3960#ifdef HAVE_LANGINFO_H
3961# include <langinfo.h>
3962#endif
3963], [char *cs = nl_langinfo(CODESET);],
3964 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET),
3965 AC_MSG_RESULT(no))
3966
Bram Moolenaar446cb832008-06-24 21:56:24 +00003967dnl Need various functions for floating point support. Only enable
3968dnl floating point when they are all present.
3969AC_CHECK_LIB(m, strtod)
3970AC_MSG_CHECKING([for strtod() and other floating point functions])
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], [char *s; double d;
3980 d = strtod("1.1", &s);
3981 d = fabs(1.11);
3982 d = ceil(1.11);
3983 d = floor(1.11);
3984 d = log10(1.11);
3985 d = pow(1.11, 2.22);
3986 d = sqrt(1.11);
3987 d = sin(1.11);
3988 d = cos(1.11);
3989 d = atan(1.11);
3990 ],
3991 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT_FUNCS),
3992 AC_MSG_RESULT(no))
3993
Bram Moolenaara6b89762016-02-29 21:38:26 +01003994dnl isinf() and isnan() need to include header files and may need -lm.
3995AC_MSG_CHECKING([for isinf()])
3996AC_TRY_LINK([
3997#ifdef HAVE_MATH_H
3998# include <math.h>
3999#endif
4000#if STDC_HEADERS
4001# include <stdlib.h>
4002# include <stddef.h>
4003#endif
4004], [int r = isinf(1.11); ],
4005 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISINF),
4006 AC_MSG_RESULT(no))
4007
4008AC_MSG_CHECKING([for isnan()])
4009AC_TRY_LINK([
4010#ifdef HAVE_MATH_H
4011# include <math.h>
4012#endif
4013#if STDC_HEADERS
4014# include <stdlib.h>
4015# include <stddef.h>
4016#endif
4017], [int r = isnan(1.11); ],
4018 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISNAN),
4019 AC_MSG_RESULT(no))
4020
Bram Moolenaar071d4272004-06-13 20:20:40 +00004021dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI
4022dnl when -lacl works, also try to use -lattr (required for Debian).
Bram Moolenaar8d462f92012-02-05 22:51:33 +01004023dnl On Solaris, use the acl_get/set functions in libsec, if present.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004024AC_MSG_CHECKING(--disable-acl argument)
4025AC_ARG_ENABLE(acl,
Bram Moolenaard6d30422018-01-28 22:48:55 +01004026 [ --disable-acl No check for ACL support.],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004027 , [enable_acl="yes"])
4028if test "$enable_acl" = "yes"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01004029 AC_MSG_RESULT(no)
4030 AC_CHECK_LIB(posix1e, acl_get_file, [LIBS="$LIBS -lposix1e"],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004031 AC_CHECK_LIB(acl, acl_get_file, [LIBS="$LIBS -lacl"
4032 AC_CHECK_LIB(attr, fgetxattr, LIBS="$LIBS -lattr",,)],,),)
4033
Bram Moolenaard6d30422018-01-28 22:48:55 +01004034 AC_MSG_CHECKING(for POSIX ACL support)
4035 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00004036#include <sys/types.h>
4037#ifdef HAVE_SYS_ACL_H
4038# include <sys/acl.h>
4039#endif
4040acl_t acl;], [acl = acl_get_file("foo", ACL_TYPE_ACCESS);
4041 acl_set_file("foo", ACL_TYPE_ACCESS, acl);
4042 acl_free(acl);],
4043 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_ACL),
4044 AC_MSG_RESULT(no))
4045
Bram Moolenaard6d30422018-01-28 22:48:55 +01004046 AC_CHECK_LIB(sec, acl_get, [LIBS="$LIBS -lsec"; AC_DEFINE(HAVE_SOLARIS_ZFS_ACL)],
4047 AC_MSG_CHECKING(for Solaris ACL support)
4048 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00004049#ifdef HAVE_SYS_ACL_H
4050# include <sys/acl.h>
4051#endif], [acl("foo", GETACLCNT, 0, NULL);
4052 ],
4053 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOLARIS_ACL),
Bram Moolenaar8d462f92012-02-05 22:51:33 +01004054 AC_MSG_RESULT(no)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004055
Bram Moolenaard6d30422018-01-28 22:48:55 +01004056 AC_MSG_CHECKING(for AIX ACL support)
4057 AC_TRY_LINK([
Bram Moolenaar446cb832008-06-24 21:56:24 +00004058#if STDC_HEADERS
4059# include <stdlib.h>
4060# include <stddef.h>
4061#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004062#ifdef HAVE_SYS_ACL_H
4063# include <sys/acl.h>
4064#endif
4065#ifdef HAVE_SYS_ACCESS_H
4066# include <sys/access.h>
4067#endif
4068#define _ALL_SOURCE
4069
4070#include <sys/stat.h>
4071
4072int aclsize;
4073struct acl *aclent;], [aclsize = sizeof(struct acl);
4074 aclent = (void *)malloc(aclsize);
4075 statacl("foo", STX_NORMAL, aclent, aclsize);
4076 ],
4077 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_AIX_ACL),
4078 AC_MSG_RESULT(no))
4079else
4080 AC_MSG_RESULT(yes)
4081fi
4082
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02004083if test "x$GTK_CFLAGS" != "x"; then
4084 dnl pango_shape_full() is new, fall back to pango_shape().
4085 AC_MSG_CHECKING(for pango_shape_full)
4086 ac_save_CFLAGS="$CFLAGS"
4087 ac_save_LIBS="$LIBS"
4088 CFLAGS="$CFLAGS $GTK_CFLAGS"
4089 LIBS="$LIBS $GTK_LIBS"
Bram Moolenaar5325b9b2015-09-09 20:27:02 +02004090 AC_TRY_LINK(
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02004091 [#include <gtk/gtk.h>],
4092 [ pango_shape_full(NULL, 0, NULL, 0, NULL, NULL); ],
4093 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_PANGO_SHAPE_FULL),
4094 AC_MSG_RESULT(no))
4095 CFLAGS="$ac_save_CFLAGS"
4096 LIBS="$ac_save_LIBS"
4097fi
4098
Bram Moolenaar33fc4a62022-02-23 18:07:38 +00004099AC_MSG_CHECKING(--enable-gpm argument)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004100AC_ARG_ENABLE(gpm,
Bram Moolenaar33fc4a62022-02-23 18:07:38 +00004101 [ --enable-gpm=OPTS Use gpm (Linux mouse daemon). default=yes OPTS=yes/no/dynamic], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00004102 [enable_gpm="yes"])
4103
Bram Moolenaar33fc4a62022-02-23 18:07:38 +00004104if test "$enable_gpm" = "yes" -o "$enable_gpm" = "dynamic"; then
4105 AC_MSG_RESULT($enable_gpm)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004106 dnl Checking if gpm support can be compiled
4107 AC_CACHE_CHECK([for gpm], vi_cv_have_gpm,
4108 [olibs="$LIBS" ; LIBS="-lgpm"]
4109 AC_TRY_LINK(
4110 [#include <gpm.h>
4111 #include <linux/keyboard.h>],
4112 [Gpm_GetLibVersion(NULL);],
4113 dnl Configure defines HAVE_GPM, if it is defined feature.h defines
4114 dnl FEAT_MOUSE_GPM if mouse support is included
4115 [vi_cv_have_gpm=yes],
4116 [vi_cv_have_gpm=no])
4117 [LIBS="$olibs"]
4118 )
4119 if test $vi_cv_have_gpm = yes; then
Bram Moolenaar33fc4a62022-02-23 18:07:38 +00004120 if test "$enable_gpm" = "yes"; then
4121 LIBS="$LIBS -lgpm"
4122 else
4123 AC_DEFINE(DYNAMIC_GPM)
4124 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004125 AC_DEFINE(HAVE_GPM)
4126 fi
4127else
Bram Moolenaar33fc4a62022-02-23 18:07:38 +00004128 AC_MSG_RESULT(no)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004129fi
4130
Bram Moolenaar446cb832008-06-24 21:56:24 +00004131AC_MSG_CHECKING(--disable-sysmouse argument)
4132AC_ARG_ENABLE(sysmouse,
Bram Moolenaar8008b632017-07-18 21:33:20 +02004133 [ --disable-sysmouse Don't use sysmouse (mouse in *BSD console).], ,
Bram Moolenaar446cb832008-06-24 21:56:24 +00004134 [enable_sysmouse="yes"])
4135
4136if test "$enable_sysmouse" = "yes"; then
4137 AC_MSG_RESULT(no)
4138 dnl Checking if sysmouse support can be compiled
4139 dnl Configure defines HAVE_SYSMOUSE, if it is defined feature.h
4140 dnl defines FEAT_SYSMOUSE if mouse support is included
4141 AC_CACHE_CHECK([for sysmouse], vi_cv_have_sysmouse,
4142 AC_TRY_LINK(
4143 [#include <sys/consio.h>
4144 #include <signal.h>
4145 #include <sys/fbio.h>],
4146 [struct mouse_info mouse;
4147 mouse.operation = MOUSE_MODE;
4148 mouse.operation = MOUSE_SHOW;
4149 mouse.u.mode.mode = 0;
4150 mouse.u.mode.signal = SIGUSR2;],
4151 [vi_cv_have_sysmouse=yes],
4152 [vi_cv_have_sysmouse=no])
4153 )
4154 if test $vi_cv_have_sysmouse = yes; then
4155 AC_DEFINE(HAVE_SYSMOUSE)
4156 fi
4157else
4158 AC_MSG_RESULT(yes)
4159fi
4160
Bram Moolenaarf05da212009-11-17 16:13:15 +00004161dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
4162AC_MSG_CHECKING(for FD_CLOEXEC)
4163AC_TRY_COMPILE(
4164[#if HAVE_FCNTL_H
4165# include <fcntl.h>
4166#endif],
4167[ int flag = FD_CLOEXEC;],
4168 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
4169 AC_MSG_RESULT(not usable))
4170
Bram Moolenaar071d4272004-06-13 20:20:40 +00004171dnl rename needs to be checked separately to work on Nextstep with cc
4172AC_MSG_CHECKING(for rename)
4173AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
4174 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
4175 AC_MSG_RESULT(no))
4176
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004177dnl check for dirfd()
4178AC_MSG_CHECKING(for dirfd)
Bram Moolenaar9d8bfae2020-09-02 21:21:35 +02004179AC_TRY_LINK(
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004180[#include <sys/types.h>
4181#include <dirent.h>],
4182[DIR * dir=opendir("dirname"); dirfd(dir);],
4183AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DIRFD), AC_MSG_RESULT(not usable))
4184
4185dnl check for flock()
4186AC_MSG_CHECKING(for flock)
Bram Moolenaar9d8bfae2020-09-02 21:21:35 +02004187AC_TRY_LINK(
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004188[#include <sys/file.h>],
4189[flock(10, LOCK_SH);],
4190AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOCK), AC_MSG_RESULT(not usable))
4191
Bram Moolenaar071d4272004-06-13 20:20:40 +00004192dnl sysctl() may exist but not the arguments we use
4193AC_MSG_CHECKING(for sysctl)
4194AC_TRY_COMPILE(
4195[#include <sys/types.h>
4196#include <sys/sysctl.h>],
4197[ int mib[2], r;
4198 size_t len;
4199
4200 mib[0] = CTL_HW;
4201 mib[1] = HW_USERMEM;
4202 len = sizeof(r);
4203 (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
4204 ],
4205 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL),
4206 AC_MSG_RESULT(not usable))
4207
Bram Moolenaare2982d62021-10-06 11:27:21 +01004208dnl sysinfo() may exist but not be Linux compatible.
4209dnl On some FreeBSD systems it may depend on libsysinfo, use TRY_LINK
Bram Moolenaar071d4272004-06-13 20:20:40 +00004210AC_MSG_CHECKING(for sysinfo)
Bram Moolenaare2982d62021-10-06 11:27:21 +01004211AC_TRY_LINK(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004212[#include <sys/types.h>
4213#include <sys/sysinfo.h>],
4214[ struct sysinfo sinfo;
4215 int t;
4216
4217 (void)sysinfo(&sinfo);
4218 t = sinfo.totalram;
4219 ],
4220 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
4221 AC_MSG_RESULT(not usable))
4222
Bram Moolenaar914572a2007-05-01 11:37:47 +00004223dnl struct sysinfo may have the mem_unit field or not
4224AC_MSG_CHECKING(for sysinfo.mem_unit)
4225AC_TRY_COMPILE(
4226[#include <sys/types.h>
4227#include <sys/sysinfo.h>],
4228[ struct sysinfo sinfo;
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02004229 sinfo.mem_unit = 1;
Bram Moolenaar914572a2007-05-01 11:37:47 +00004230 ],
4231 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_MEM_UNIT),
4232 AC_MSG_RESULT(no))
4233
Bram Moolenaarf52f0602021-03-10 21:26:37 +01004234dnl struct sysinfo may have the uptime field or not
4235AC_MSG_CHECKING(for sysinfo.uptime)
4236AC_TRY_COMPILE(
4237[#include <sys/types.h>
4238#include <sys/sysinfo.h>],
4239[ struct sysinfo sinfo;
4240 long ut;
4241
4242 (void)sysinfo(&sinfo);
4243 ut = sinfo.uptime;
4244 ],
4245 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_UPTIME),
4246 AC_MSG_RESULT(no))
4247
Bram Moolenaar071d4272004-06-13 20:20:40 +00004248dnl sysconf() may exist but not support what we want to use
4249AC_MSG_CHECKING(for sysconf)
4250AC_TRY_COMPILE(
4251[#include <unistd.h>],
4252[ (void)sysconf(_SC_PAGESIZE);
4253 (void)sysconf(_SC_PHYS_PAGES);
4254 ],
4255 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
4256 AC_MSG_RESULT(not usable))
4257
Bram Moolenaar0e62a672021-02-25 17:17:56 +01004258dnl check if we have _SC_SIGSTKSZ via sysconf()
4259AC_MSG_CHECKING(for _SC_SIGSTKSZ via sysconf())
4260AC_TRY_COMPILE(
4261[#include <unistd.h>],
4262[ (void)sysconf(_SC_SIGSTKSZ);
4263 ],
4264 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF_SIGSTKSZ),
4265 AC_MSG_RESULT(not usable))
4266
Bram Moolenaar914703b2010-05-31 21:59:46 +02004267AC_CHECK_SIZEOF([int])
4268AC_CHECK_SIZEOF([long])
4269AC_CHECK_SIZEOF([time_t])
4270AC_CHECK_SIZEOF([off_t])
Bram Moolenaar644fdff2010-05-30 13:26:21 +02004271
Bram Moolenaara2aa31a2014-02-23 22:52:40 +01004272dnl Use different names to avoid clashing with other header files.
4273AC_DEFINE_UNQUOTED(VIM_SIZEOF_INT, [$ac_cv_sizeof_int])
4274AC_DEFINE_UNQUOTED(VIM_SIZEOF_LONG, [$ac_cv_sizeof_long])
4275
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004276dnl Make sure that uint32_t is really 32 bits unsigned.
4277AC_MSG_CHECKING([uint32_t is 32 bits])
4278AC_TRY_RUN([
4279#ifdef HAVE_STDINT_H
4280# include <stdint.h>
4281#endif
4282#ifdef HAVE_INTTYPES_H
4283# include <inttypes.h>
4284#endif
4285main() {
4286 uint32_t nr1 = (uint32_t)-1;
4287 uint32_t nr2 = (uint32_t)0xffffffffUL;
Bram Moolenaar52897832020-07-02 22:50:37 +02004288 if (sizeof(uint32_t) != 4 || nr1 != 0xffffffffUL || nr2 + 1 != 0) return 1;
4289 return 0;
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004290}],
4291AC_MSG_RESULT(ok),
4292AC_MSG_ERROR([WRONG! uint32_t not defined correctly.]),
Bram Moolenaar323cb952011-12-14 19:22:34 +01004293AC_MSG_WARN([cannot check uint32_t when cross-compiling.]))
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004294
Bram Moolenaar446cb832008-06-24 21:56:24 +00004295dnl Check for memmove() before bcopy(), makes memmove() be used when both are
4296dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
4297
Bram Moolenaar071d4272004-06-13 20:20:40 +00004298[bcopy_test_prog='
Bram Moolenaar446cb832008-06-24 21:56:24 +00004299#include "confdefs.h"
4300#ifdef HAVE_STRING_H
4301# include <string.h>
4302#endif
4303#if STDC_HEADERS
4304# include <stdlib.h>
4305# include <stddef.h>
4306#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004307main() {
4308 char buf[10];
4309 strcpy(buf, "abcdefghi");
4310 mch_memmove(buf, buf + 2, 3);
4311 if (strncmp(buf, "ababcf", 6))
4312 exit(1);
4313 strcpy(buf, "abcdefghi");
4314 mch_memmove(buf + 2, buf, 3);
4315 if (strncmp(buf, "cdedef", 6))
4316 exit(1);
4317 exit(0); /* libc version works properly. */
4318}']
4319
Bram Moolenaar446cb832008-06-24 21:56:24 +00004320AC_CACHE_CHECK([whether memmove handles overlaps],[vim_cv_memmove_handles_overlap],
4321 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004322 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 +00004323 [
4324 vim_cv_memmove_handles_overlap=yes
4325 ],[
4326 vim_cv_memmove_handles_overlap=no
4327 ],[
4328 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memmove_handles_overlap')
4329 ])
4330 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00004331
Bram Moolenaar446cb832008-06-24 21:56:24 +00004332if test "x$vim_cv_memmove_handles_overlap" = "xyes" ; then
4333 AC_DEFINE(USEMEMMOVE)
4334else
4335 AC_CACHE_CHECK([whether bcopy handles overlaps],[vim_cv_bcopy_handles_overlap],
4336 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004337 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 +00004338 [
4339 vim_cv_bcopy_handles_overlap=yes
4340 ],[
4341 vim_cv_bcopy_handles_overlap=no
4342 ],[
4343 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_bcopy_handles_overlap')
4344 ])
4345 ])
4346
4347 if test "x$vim_cv_bcopy_handles_overlap" = "xyes" ; then
4348 AC_DEFINE(USEBCOPY)
4349 else
4350 AC_CACHE_CHECK([whether memcpy handles overlaps],[vim_cv_memcpy_handles_overlap],
4351 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004352 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 +00004353 [
4354 vim_cv_memcpy_handles_overlap=yes
4355 ],[
4356 vim_cv_memcpy_handles_overlap=no
4357 ],[
4358 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memcpy_handles_overlap')
4359 ])
4360 ])
4361
4362 if test "x$vim_cv_memcpy_handles_overlap" = "xyes" ; then
4363 AC_DEFINE(USEMEMCPY)
4364 fi
4365 fi
4366fi
4367
Bram Moolenaar071d4272004-06-13 20:20:40 +00004368
4369dnl Check for multibyte locale functions
4370dnl Find out if _Xsetlocale() is supported by libX11.
4371dnl Check if X_LOCALE should be defined.
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004372if test "x$with_x" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004373 cflags_save=$CFLAGS
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004374 libs_save=$LIBS
4375 LIBS="$LIBS $X_LIBS $GUI_LIB_LOC $GUI_X_LIBS $X_PRE_LIBS $X_LIB $X_EXTRA_LIBS"
4376 CFLAGS="$CFLAGS $X_CFLAGS"
4377
4378 AC_MSG_CHECKING(whether X_LOCALE needed)
4379 AC_TRY_COMPILE([#include <X11/Xlocale.h>],,
4380 AC_TRY_LINK_FUNC([_Xsetlocale], [AC_MSG_RESULT(yes)
4381 AC_DEFINE(X_LOCALE)], AC_MSG_RESULT(no)),
4382 AC_MSG_RESULT(no))
4383
4384 AC_MSG_CHECKING(whether Xutf8SetWMProperties() can be used)
4385 AC_TRY_LINK_FUNC([Xutf8SetWMProperties], [AC_MSG_RESULT(yes)
4386 AC_DEFINE(HAVE_XUTF8SETWMPROPERTIES)], AC_MSG_RESULT(no))
4387
Bram Moolenaar071d4272004-06-13 20:20:40 +00004388 CFLAGS=$cflags_save
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004389 LIBS=$libs_save
Bram Moolenaar071d4272004-06-13 20:20:40 +00004390fi
4391
4392dnl Link with xpg4, it is said to make Korean locale working
4393AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,)
4394
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004395dnl Check how we can run ctags. Default to "ctags" when nothing works.
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02004396dnl Use --version to detect Exuberant ctags (preferred)
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004397dnl Add --fields=+S to get function signatures for omni completion.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004398dnl -t for typedefs (many ctags have this)
4399dnl -s for static functions (Elvis ctags only?)
4400dnl -v for variables. Dangerous, most ctags take this for 'vgrind style'.
4401dnl -i+m to test for older Exuberant ctags
4402AC_MSG_CHECKING(how to create tags)
4403test -f tags && mv tags tags.save
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004404if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004405 TAGPRG="ctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004406elif (eval exctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004407 TAGPRG="exctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004408elif (eval exuberant-ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004409 TAGPRG="exuberant-ctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004410else
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004411 TAGPRG="ctags"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004412 (eval etags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags"
4413 (eval etags -c /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags -c"
4414 (eval ctags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags"
4415 (eval ctags -t /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -t"
4416 (eval ctags -ts /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -ts"
4417 (eval ctags -tvs /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -tvs"
4418 (eval ctags -i+m /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -i+m"
4419fi
4420test -f tags.save && mv tags.save tags
4421AC_MSG_RESULT($TAGPRG) AC_SUBST(TAGPRG)
4422
4423dnl Check how we can run man with a section number
4424AC_MSG_CHECKING(how to run man with a section nr)
4425MANDEF="man"
Bram Moolenaar8b131502008-02-13 09:28:19 +00004426(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 +00004427AC_MSG_RESULT($MANDEF)
4428if test "$MANDEF" = "man -s"; then
4429 AC_DEFINE(USEMAN_S)
4430fi
4431
4432dnl Check if gettext() is working and if it needs -lintl
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004433dnl We take care to base this on an empty LIBS: on some systems libelf would be
4434dnl in LIBS and implicitly take along libintl. The final LIBS would then not
4435dnl contain libintl, and the link step would fail due to -Wl,--as-needed.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004436AC_MSG_CHECKING(--disable-nls argument)
4437AC_ARG_ENABLE(nls,
4438 [ --disable-nls Don't support NLS (gettext()).], ,
4439 [enable_nls="yes"])
4440
4441if test "$enable_nls" = "yes"; then
4442 AC_MSG_RESULT(no)
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00004443
4444 INSTALL_LANGS=install-languages
4445 AC_SUBST(INSTALL_LANGS)
4446 INSTALL_TOOL_LANGS=install-tool-languages
4447 AC_SUBST(INSTALL_TOOL_LANGS)
4448
Bram Moolenaar071d4272004-06-13 20:20:40 +00004449 AC_CHECK_PROG(MSGFMT, msgfmt, msgfmt, )
4450 AC_MSG_CHECKING([for NLS])
4451 if test -f po/Makefile; then
4452 have_gettext="no"
4453 if test -n "$MSGFMT"; then
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004454 olibs=$LIBS
4455 LIBS=""
Bram Moolenaar071d4272004-06-13 20:20:40 +00004456 AC_TRY_LINK(
4457 [#include <libintl.h>],
4458 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004459 AC_MSG_RESULT([gettext() works]); have_gettext="yes"; LIBS=$olibs,
4460 LIBS="-lintl"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004461 AC_TRY_LINK(
4462 [#include <libintl.h>],
4463 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004464 AC_MSG_RESULT([gettext() works with -lintl]); have_gettext="yes";
4465 LIBS="$olibs -lintl",
Bram Moolenaar071d4272004-06-13 20:20:40 +00004466 AC_MSG_RESULT([gettext() doesn't work]);
4467 LIBS=$olibs))
4468 else
4469 AC_MSG_RESULT([msgfmt not found - disabled]);
4470 fi
Bram Moolenaar278eb582014-07-30 13:22:52 +02004471 if test $have_gettext = "yes" -a "x$features" != "xtiny" -a "x$features" != "xsmall"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004472 AC_DEFINE(HAVE_GETTEXT)
4473 MAKEMO=yes
4474 AC_SUBST(MAKEMO)
4475 dnl this was added in GNU gettext 0.10.36
4476 AC_CHECK_FUNCS(bind_textdomain_codeset)
4477 dnl _nl_msg_cat_cntr is required for GNU gettext
4478 AC_MSG_CHECKING([for _nl_msg_cat_cntr])
4479 AC_TRY_LINK(
4480 [#include <libintl.h>
4481 extern int _nl_msg_cat_cntr;],
4482 [++_nl_msg_cat_cntr;],
4483 AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_NL_MSG_CAT_CNTR),
4484 AC_MSG_RESULT([no]))
Bram Moolenaar26096cc2019-04-11 15:25:40 +02004485 AC_MSG_CHECKING([if msgfmt supports --desktop])
4486 MSGFMT_DESKTOP=
4487 if "$MSGFMT" --help | grep -e '--desktop' >/dev/null; then
Bram Moolenaar62a88f42019-06-07 20:44:40 +02004488 if "$MSGFMT" --version | grep '0.19.[[3-7]]$' >/dev/null; then
4489 dnl GNU gettext 0.19.7's --desktop is broken. We assume back to
4490 dnl 0.19.3 is also broken.
4491 AC_MSG_RESULT([broken])
4492 else
4493 AC_MSG_RESULT([yes])
4494 MSGFMT_DESKTOP="gvim.desktop vim.desktop"
4495 fi
Bram Moolenaar26096cc2019-04-11 15:25:40 +02004496 else
4497 AC_MSG_RESULT([no])
4498 fi
4499 AC_SUBST(MSGFMT_DESKTOP)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004500 fi
4501 else
4502 AC_MSG_RESULT([no "po/Makefile" - disabled]);
4503 fi
4504else
4505 AC_MSG_RESULT(yes)
4506fi
4507
4508dnl Check for dynamic linking loader
4509AC_CHECK_HEADER(dlfcn.h, DLL=dlfcn.h, [AC_CHECK_HEADER(dl.h, DLL=dl.h)])
4510if test x${DLL} = xdlfcn.h; then
4511 AC_DEFINE(HAVE_DLFCN_H, 1, [ Define if we have dlfcn.h. ])
4512 AC_MSG_CHECKING([for dlopen()])
4513 AC_TRY_LINK(,[
4514 extern void* dlopen();
4515 dlopen();
4516 ],
4517 AC_MSG_RESULT(yes);
4518 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4519 AC_MSG_RESULT(no);
4520 AC_MSG_CHECKING([for dlopen() in -ldl])
4521 olibs=$LIBS
4522 LIBS="$LIBS -ldl"
4523 AC_TRY_LINK(,[
4524 extern void* dlopen();
4525 dlopen();
4526 ],
4527 AC_MSG_RESULT(yes);
4528 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4529 AC_MSG_RESULT(no);
4530 LIBS=$olibs))
4531 dnl ReliantUNIX has dlopen() in libc but everything else in libdl
4532 dnl ick :-)
4533 AC_MSG_CHECKING([for dlsym()])
4534 AC_TRY_LINK(,[
4535 extern void* dlsym();
4536 dlsym();
4537 ],
4538 AC_MSG_RESULT(yes);
4539 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4540 AC_MSG_RESULT(no);
4541 AC_MSG_CHECKING([for dlsym() in -ldl])
4542 olibs=$LIBS
4543 LIBS="$LIBS -ldl"
4544 AC_TRY_LINK(,[
4545 extern void* dlsym();
4546 dlsym();
4547 ],
4548 AC_MSG_RESULT(yes);
4549 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4550 AC_MSG_RESULT(no);
4551 LIBS=$olibs))
4552elif test x${DLL} = xdl.h; then
4553 AC_DEFINE(HAVE_DL_H, 1, [ Define if we have dl.h. ])
4554 AC_MSG_CHECKING([for shl_load()])
4555 AC_TRY_LINK(,[
4556 extern void* shl_load();
4557 shl_load();
4558 ],
4559 AC_MSG_RESULT(yes);
4560 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4561 AC_MSG_RESULT(no);
4562 AC_MSG_CHECKING([for shl_load() in -ldld])
4563 olibs=$LIBS
4564 LIBS="$LIBS -ldld"
4565 AC_TRY_LINK(,[
4566 extern void* shl_load();
4567 shl_load();
4568 ],
4569 AC_MSG_RESULT(yes);
4570 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4571 AC_MSG_RESULT(no);
4572 LIBS=$olibs))
4573fi
4574AC_CHECK_HEADERS(setjmp.h)
4575
Bram Moolenaard0573012017-10-28 21:11:06 +02004576if test "x$MACOS_X" = "xyes" -a -n "$PERL"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004577 dnl -ldl must come after DynaLoader.a
4578 if echo $LIBS | grep -e '-ldl' >/dev/null; then
4579 LIBS=`echo $LIBS | sed s/-ldl//`
4580 PERL_LIBS="$PERL_LIBS -ldl"
4581 fi
4582fi
4583
Bram Moolenaard0573012017-10-28 21:11:06 +02004584if test "$MACOS_X" = "yes"; then
4585 AC_MSG_CHECKING([whether we need macOS frameworks])
Bram Moolenaar097148e2020-08-11 21:58:20 +02004586 if test "$MACOS_X_DARWIN" = "yes"; then
Bram Moolenaard0573012017-10-28 21:11:06 +02004587 if test "$features" = "tiny"; then
4588 dnl Since no FEAT_CLIPBOARD, no longer need for os_macosx.m.
4589 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_macosx.m++'`
4590 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_macosx.o++'`
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01004591 AC_MSG_RESULT([yes, we need CoreServices])
4592 LIBS="$LIBS -framework CoreServices"
Bram Moolenaard0573012017-10-28 21:11:06 +02004593 else
4594 AC_MSG_RESULT([yes, we need AppKit])
4595 LIBS="$LIBS -framework AppKit"
Bram Moolenaard0573012017-10-28 21:11:06 +02004596 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004597 else
Bram Moolenaard0573012017-10-28 21:11:06 +02004598 AC_MSG_RESULT([no])
Bram Moolenaar3437b912013-07-03 19:52:53 +02004599 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004600fi
4601
Bram Moolenaar3ae5fc92021-09-06 18:57:30 +02004602dnl On some systems REENTRANT needs to be defined. It should not hurt to use
4603dnl it everywhere.
4604if `echo "$CFLAGS" | grep -v D_REENTRANT >/dev/null`; then
4605 CFLAGS="$CFLAGS -D_REENTRANT"
4606fi
4607
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004608dnl gcc 3.1 changed the meaning of -MM. The only solution appears to be to
4609dnl use "-isystem" instead of "-I" for all non-Vim include dirs.
4610dnl But only when making dependencies, cproto and lint don't take "-isystem".
Bram Moolenaar32466aa2006-02-24 23:53:04 +00004611dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
4612dnl the number before the version number.
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004613DEPEND_CFLAGS_FILTER=
4614if test "$GCC" = yes; then
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004615 AC_MSG_CHECKING(for GCC 3 or later)
Bram Moolenaar348808f2020-02-07 20:50:07 +01004616 gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]][[0-9]]*\)\..*$/\1/g'`
Bram Moolenaarf740b292006-02-16 22:11:02 +00004617 if test "$gccmajor" -gt "2"; then
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004618 DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004619 AC_MSG_RESULT(yes)
4620 else
4621 AC_MSG_RESULT(no)
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004622 fi
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004623 dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
4624 dnl declared as char x[1] but actually longer. Introduced in gcc 4.0.
Bram Moolenaar56d1db32009-12-16 16:14:51 +00004625 dnl Also remove duplicate _FORTIFY_SOURCE arguments.
Bram Moolenaaraeabe052011-12-08 15:17:34 +01004626 dnl And undefine it first to avoid a warning.
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004627 AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
4628 if test "$gccmajor" -gt "3"; then
Bram Moolenaar26f20132021-04-03 17:33:52 +02004629 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/'`
4630 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 +00004631 AC_MSG_RESULT(yes)
4632 else
4633 AC_MSG_RESULT(no)
4634 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +00004635fi
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004636AC_SUBST(DEPEND_CFLAGS_FILTER)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004637
Bram Moolenaarec0557f2018-01-31 14:41:37 +01004638dnl On some systems AC_SYS_LARGEFILE determines that -D_FILE_OFFSET_BITS=64
4639dnl isn't required, but the CFLAGS for some of the libraries we're using
4640dnl include the define. Since the define changes the size of some datatypes
4641dnl (e.g. ino_t and off_t), all of Vim's modules must be compiled with a
4642dnl consistent value. It's therefore safest to force the use of the define
4643dnl if it's present in any of the *_CFLAGS variables.
4644AC_MSG_CHECKING(whether we need to force -D_FILE_OFFSET_BITS=64)
Bram Moolenaar9ce42132018-04-11 22:19:36 +02004645if 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 +01004646 AC_MSG_RESULT(yes)
4647 AC_DEFINE(_FILE_OFFSET_BITS, 64)
4648else
4649 AC_MSG_RESULT(no)
4650fi
4651
Bram Moolenaar6cd42db2020-12-04 18:09:54 +01004652dnl $LDFLAGS is passed to glibtool in libvterm, it doesn't like a space
4653dnl between "-L" and the path that follows.
4654LDFLAGS=`echo "$LDFLAGS" | sed -e 's/-L /-L/g'`
4655
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004656dnl link.sh tries to avoid overlinking in a hackish way.
4657dnl At least GNU ld supports --as-needed which provides the same functionality
4658dnl at linker level. Let's use it.
4659AC_MSG_CHECKING(linker --as-needed support)
4660LINK_AS_NEEDED=
4661# Check if linker supports --as-needed and --no-as-needed options
4662if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
Natanael Copa761ead42021-05-15 14:25:37 +02004663 if ! echo "$LDFLAGS" | grep -q -- '-Wl,[[^[:space:]]]*--as-needed'; then
4664 LDFLAGS="$LDFLAGS -Wl,--as-needed"
4665 fi
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004666 LINK_AS_NEEDED=yes
4667fi
4668if test "$LINK_AS_NEEDED" = yes; then
4669 AC_MSG_RESULT(yes)
4670else
4671 AC_MSG_RESULT(no)
4672fi
4673AC_SUBST(LINK_AS_NEEDED)
4674
Bram Moolenaar77c19352012-06-13 19:19:41 +02004675# IBM z/OS reset CFLAGS for config.mk
4676if test "$zOSUnix" = "yes"; then
4677 CFLAGS="-D_ALL_SOURCE -Wc,float\(ieee\),dll"
4678fi
4679
Bram Moolenaar071d4272004-06-13 20:20:40 +00004680dnl write output files
4681AC_OUTPUT(auto/config.mk:config.mk.in)
4682
4683dnl vim: set sw=2 tw=78 fo+=l: