blob: 6fee99ca6461cd751c723bd3ea1b3f6e8873ce35 [file] [log] [blame]
Bram Moolenaar3f7d0902016-11-12 21:13:42 +01001dnl configure.ac: autoconf script for Vim
Bram Moolenaar071d4272004-06-13 20:20:40 +00002
3dnl Process this file with autoconf 2.12 or 2.13 to produce "configure".
4dnl Should also work with autoconf 2.54 and later.
5
6AC_INIT(vim.h)
7AC_CONFIG_HEADER(auto/config.h:config.h.in)
8
9dnl Being able to run configure means the system is Unix (compatible).
10AC_DEFINE(UNIX)
11AC_PROG_MAKE_SET
12
13dnl Checks for programs.
Bram Moolenaar22640082018-04-19 20:39:41 +020014AC_PROG_CC_C99 dnl required by almost everything
Bram Moolenaarc0394412017-04-20 20:20:23 +020015AC_PROG_CPP dnl required by header file checks
16AC_PROGRAM_EGREP dnl required by AC_EGREP_CPP
17AC_PROG_FGREP dnl finds working grep -F
18AC_ISC_POSIX dnl required by AC_C_CROSS
19AC_PROG_AWK dnl required for "make html" in ../doc
Bram Moolenaar071d4272004-06-13 20:20:40 +000020
21dnl Don't strip if we don't have it
22AC_CHECK_PROG(STRIP, strip, strip, :)
23
Bram Moolenaar325b7a22004-07-05 15:58:32 +000024dnl Check for extension of executables
Bram Moolenaar071d4272004-06-13 20:20:40 +000025AC_EXEEXT
26
Bram Moolenaar446cb832008-06-24 21:56:24 +000027dnl Check for standard headers. We don't use this in Vim but other stuff
28dnl in autoconf needs it, where it uses STDC_HEADERS.
29AC_HEADER_STDC
30AC_HEADER_SYS_WAIT
31
Bram Moolenaar561f8a52018-04-17 22:02:45 +020032dnl Check that the C99 features that Vim uses are supported:
Bram Moolenaar22640082018-04-19 20:39:41 +020033if test x"$ac_cv_prog_cc_c99" != xno; then
34 dnl If the compiler doesn't explicitly support C99, then check
35 dnl for the specific features Vim uses
36
37 AC_TYPE_LONG_LONG_INT
38 if test "$ac_cv_type_long_long_int" = no; then
39 AC_MSG_FAILURE([Compiler does not support long long int])
40 fi
41
42 AC_MSG_CHECKING([if the compiler supports trailing commas])
43 trailing_commas=no
44 AC_TRY_COMPILE([], [
45 enum {
46 one,
47 };],
48 [AC_MSG_RESULT(yes); trailing_commas=yes],
49 [AC_MSG_RESULT(no)])
50 if test "$trailing_commas" = no; then
51 AC_MSG_FAILURE([Compiler does not support trailing comma in enum])
52 fi
53
54 AC_MSG_CHECKING([if the compiler supports C++ comments])
55 slash_comments=no
56 AC_TRY_COMPILE([],
57 [// C++ comments?],
58 [AC_MSG_RESULT(yes); slash_comments=yes],
59 [AC_MSG_RESULT(no)])
60 if test "$slash_comments" = no; then
61 AC_MSG_FAILURE([Compiler does not support C++ comments])
62 fi
63fi
Bram Moolenaar561f8a52018-04-17 22:02:45 +020064
Bram Moolenaar8f1dde52020-06-05 23:16:29 +020065dnl If $SOURCE_DATE_EPOCH is present in the environment, use that as the
66dnl "compiled" timestamp in :version's output. Attempt to get the formatted
67dnl date using GNU date syntax, BSD date syntax, and finally falling back to
68dnl just using the current time.
69if test -n "$SOURCE_DATE_EPOCH"; then
70 DATE_FMT="%b %d %Y %H:%M:%S"
71 BUILD_DATE=$(LC_ALL=C date -u -d "@$SOURCE_DATE_EPOCH" "+$DATE_FMT" 2>/dev/null || LC_ALL=C date -u -r "$SOURCE_DATE_EPOCH" "+$DATE_FMT" 2>/dev/null || LC_ALL=C date -u "+$DATE_FMT")
72 AC_DEFINE_UNQUOTED(BUILD_DATE, ["$BUILD_DATE"])
73 BUILD_DATE_MSG=-"echo -e '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\nNOTE: build date/time is fixed: $BUILD_DATE\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='"
74 AC_SUBST(BUILD_DATE_MSG)
75fi
76
Bram Moolenaarf788a062011-12-14 20:51:25 +010077dnl Check for the flag that fails if stuff are missing.
78
79AC_MSG_CHECKING(--enable-fail-if-missing argument)
80AC_ARG_ENABLE(fail_if_missing,
81 [ --enable-fail-if-missing Fail if dependencies on additional features
82 specified on the command line are missing.],
83 [fail_if_missing="yes"],
84 [fail_if_missing="no"])
85AC_MSG_RESULT($fail_if_missing)
86
Bram Moolenaard2a05492018-07-27 22:35:15 +020087dnl Keep original value to check later.
88with_x_arg="$with_x"
89
Bram Moolenaar071d4272004-06-13 20:20:40 +000090dnl Set default value for CFLAGS if none is defined or it's empty
91if test -z "$CFLAGS"; then
92 CFLAGS="-O"
Bram Moolenaar4d8479b2021-01-31 14:36:06 +010093 test "$GCC" = yes && CFLAGS="-O2 -fno-strength-reduce -Wall -Wno-deprecated-declarations"
Bram Moolenaar071d4272004-06-13 20:20:40 +000094fi
95if test "$GCC" = yes; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +000096 dnl method that should work for nearly all versions
Bram Moolenaarc8836f72014-04-12 13:12:24 +020097 gccversion=`$CC -dumpversion`
Bram Moolenaar910f66f2006-04-05 20:41:53 +000098 if test "x$gccversion" = "x"; then
99 dnl old method; fall-back for when -dumpversion doesn't work
Bram Moolenaarc8836f72014-04-12 13:12:24 +0200100 gccversion=`$CC --version | sed -e '2,$d' -e 's/darwin.//' -e 's/^[[^0-9]]*\([[0-9]]\.[[0-9.]]*\).*$/\1/g'`
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000101 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +0000102 dnl version 4.0.1 was reported to cause trouble on Macintosh by Marcin Dalecki
103 if test "$gccversion" = "3.0.1" -o "$gccversion" = "3.0.2" -o "$gccversion" = "4.0.1"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000104 echo 'GCC [[34]].0.[[12]] has a bug in the optimizer, disabling "-O#"'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000105 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-O/'`
106 else
107 if test "$gccversion" = "3.1" -o "$gccversion" = "3.2" -o "$gccversion" = "3.2.1" && `echo "$CFLAGS" | grep -v fno-strength-reduce >/dev/null`; then
108 echo 'GCC 3.1 and 3.2 have a bug in the optimizer, adding "-fno-strength-reduce"'
109 CFLAGS="$CFLAGS -fno-strength-reduce"
110 fi
111 fi
112fi
113
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200114dnl clang-500.2.75 or around has abandoned -f[no-]strength-reduce and issues a
115dnl warning when that flag is passed to. Accordingly, adjust CFLAGS based on
116dnl the version number of the clang in use.
117dnl Note that this does not work to get the version of clang 3.1 or 3.2.
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100118AC_MSG_CHECKING(for clang version)
119CLANG_VERSION_STRING=`$CC --version 2>/dev/null | sed -n -e 's/^.*clang[[^0-9]]*\([[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\).*$/\1/p'`
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200120if test x"$CLANG_VERSION_STRING" != x"" ; then
121 CLANG_MAJOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*/\1/p'`
122 CLANG_MINOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/p'`
123 CLANG_REVISION=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)/\1/p'`
124 CLANG_VERSION=`expr $CLANG_MAJOR '*' 1000000 '+' $CLANG_MINOR '*' 1000 '+' $CLANG_REVISION`
125 AC_MSG_RESULT($CLANG_VERSION)
126 dnl If you find the same issue with versions earlier than 500.2.75,
127 dnl change the constant 500002075 below appropriately. To get the
128 dnl integer corresponding to a version number, refer to the
129 dnl definition of CLANG_VERSION above.
Bram Moolenaarebd211c2021-01-30 19:33:36 +0100130 dnl Clang 11 reports "11", assume Clang 10 and later work like this.
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100131 AC_MSG_CHECKING(if clang supports -fno-strength-reduce)
Bram Moolenaarebd211c2021-01-30 19:33:36 +0100132 if test "$CLANG_MAJOR" -ge 10 -o "$CLANG_VERSION" -ge 500002075 ; then
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100133 AC_MSG_RESULT(no)
134 CFLAGS=`echo "$CFLAGS" | sed -e 's/-fno-strength-reduce/ /'`
135 else
136 AC_MSG_RESULT(yes)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200137 fi
138else
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100139 AC_MSG_RESULT(N/A)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200140fi
141
Bram Moolenaar446cb832008-06-24 21:56:24 +0000142dnl If configure thinks we are cross compiling, there might be something
143dnl wrong with the CC or CFLAGS settings, give a useful warning message
Bram Moolenaar839e9542016-04-14 16:46:02 +0200144CROSS_COMPILING=
Bram Moolenaar071d4272004-06-13 20:20:40 +0000145if test "$cross_compiling" = yes; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000146 AC_MSG_RESULT([cannot compile a simple program; if not cross compiling check CC and CFLAGS])
Bram Moolenaar839e9542016-04-14 16:46:02 +0200147 CROSS_COMPILING=1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000148fi
Bram Moolenaar839e9542016-04-14 16:46:02 +0200149AC_SUBST(CROSS_COMPILING)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000150
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +0000151dnl gcc-cpp has the wonderful -MM option to produce nicer dependencies.
152dnl But gcc 3.1 changed the meaning! See near the end.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000153test "$GCC" = yes && CPP_MM=M; AC_SUBST(CPP_MM)
154
155if test -f ./toolcheck; then
156 AC_CHECKING(for buggy tools)
157 sh ./toolcheck 1>&AC_FD_MSG
158fi
159
160OS_EXTRA_SRC=""; OS_EXTRA_OBJ=""
161
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000162dnl When cross-compiling set $vim_cv_uname_output, $vim_cv_uname_r_output and
163dnl $vim_cv_uname_m_output to the desired value for the target system
164AC_MSG_CHECKING(uname)
165if test "x$vim_cv_uname_output" = "x" ; then
166 vim_cv_uname_output=`(uname) 2>/dev/null`
167 AC_MSG_RESULT($vim_cv_uname_output)
168else
169 AC_MSG_RESULT([$vim_cv_uname_output (cached)])
170fi
171
172AC_MSG_CHECKING(uname -r)
173if test "x$vim_cv_uname_r_output" = "x" ; then
174 vim_cv_uname_r_output=`(uname -r) 2>/dev/null`
175 AC_MSG_RESULT($vim_cv_uname_r_output)
176else
177 AC_MSG_RESULT([$vim_cv_uname_r_output (cached)])
178fi
179
180AC_MSG_CHECKING(uname -m)
181if test "x$vim_cv_uname_m_output" = "x" ; then
182 vim_cv_uname_m_output=`(uname -m) 2>/dev/null`
183 AC_MSG_RESULT($vim_cv_uname_m_output)
184else
185 AC_MSG_RESULT([$vim_cv_uname_m_output (cached)])
186fi
187
Bram Moolenaarb3f74062020-02-26 16:16:53 +0100188AC_MSG_CHECKING(for Haiku)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000189case $vim_cv_uname_output in
Bram Moolenaarb3f74062020-02-26 16:16:53 +0100190 Haiku) HAIKU=yes; AC_MSG_RESULT(yes);;
191 *) HAIKU=no; AC_MSG_RESULT(no);;
192esac
193
Bram Moolenaar071d4272004-06-13 20:20:40 +0000194dnl If QNX is found, assume we don't want to use Xphoton
195dnl unless it was specifically asked for (--with-x)
196AC_MSG_CHECKING(for QNX)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000197case $vim_cv_uname_output in
Bram Moolenaar071d4272004-06-13 20:20:40 +0000198 QNX) OS_EXTRA_SRC=os_qnx.c; OS_EXTRA_OBJ=objects/os_qnx.o
199 test -z "$with_x" && with_x=no
200 QNX=yes; AC_MSG_RESULT(yes);;
201 *) QNX=no; AC_MSG_RESULT(no);;
202esac
203
204dnl Check for Darwin and MacOS X
205dnl We do a check for MacOS X in the very beginning because there
206dnl are a lot of other things we need to change besides GUI stuff
Bram Moolenaar071d4272004-06-13 20:20:40 +0000207AC_MSG_CHECKING([for Darwin (Mac OS X)])
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000208if test "$vim_cv_uname_output" = Darwin; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000209 AC_MSG_RESULT(yes)
Bram Moolenaard0573012017-10-28 21:11:06 +0200210 MACOS_X=yes
Bram Moolenaar52ecaaa2018-05-12 21:38:13 +0200211 CPPFLAGS="$CPPFLAGS -DMACOS_X"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000212
213 AC_MSG_CHECKING(--disable-darwin argument)
214 AC_ARG_ENABLE(darwin,
215 [ --disable-darwin Disable Darwin (Mac OS X) support.],
216 , [enable_darwin="yes"])
217 if test "$enable_darwin" = "yes"; then
218 AC_MSG_RESULT(no)
219 AC_MSG_CHECKING(if Darwin files are there)
Bram Moolenaar164fca32010-07-14 13:58:07 +0200220 if test -f os_macosx.m; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000221 AC_MSG_RESULT(yes)
222 else
223 AC_MSG_RESULT([no, Darwin support disabled])
224 enable_darwin=no
225 fi
226 else
227 AC_MSG_RESULT([yes, Darwin support excluded])
228 fi
229
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000230 AC_MSG_CHECKING(--with-mac-arch argument)
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000231 AC_ARG_WITH(mac-arch, [ --with-mac-arch=ARCH current, intel, ppc or both],
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000232 MACARCH="$withval"; AC_MSG_RESULT($MACARCH),
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000233 MACARCH="current"; AC_MSG_RESULT(defaulting to $MACARCH))
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000234
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100235 AC_MSG_CHECKING(--with-developer-dir argument)
236 AC_ARG_WITH(developer-dir, [ --with-developer-dir=PATH use PATH as location for Xcode developer tools],
237 DEVELOPER_DIR="$withval"; AC_MSG_RESULT($DEVELOPER_DIR),
Bram Moolenaar32d03b32015-11-19 13:46:48 +0100238 AC_MSG_RESULT(not present))
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100239
240 if test "x$DEVELOPER_DIR" = "x"; then
241 AC_PATH_PROG(XCODE_SELECT, xcode-select)
242 if test "x$XCODE_SELECT" != "x"; then
243 AC_MSG_CHECKING(for developer dir using xcode-select)
244 DEVELOPER_DIR=`$XCODE_SELECT -print-path`
245 AC_MSG_RESULT([$DEVELOPER_DIR])
246 else
247 DEVELOPER_DIR=/Developer
248 fi
249 fi
250
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000251 if test "x$MACARCH" = "xboth"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000252 AC_MSG_CHECKING(for 10.4 universal SDK)
253 dnl There is a terrible inconsistency (but we appear to get away with it):
254 dnl $CFLAGS uses the 10.4u SDK library for the headers, while $CPPFLAGS
255 dnl doesn't, because "gcc -E" doesn't grok it. That means the configure
256 dnl tests using the preprocessor are actually done with the wrong header
257 dnl files. $LDFLAGS is set at the end, because configure uses it together
258 dnl with $CFLAGS and we can only have one -sysroot argument.
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000259 save_cppflags="$CPPFLAGS"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000260 save_cflags="$CFLAGS"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000261 save_ldflags="$LDFLAGS"
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100262 CFLAGS="$CFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000263 AC_TRY_LINK([ ], [ ],
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000264 AC_MSG_RESULT(found, will make universal binary),
265
266 AC_MSG_RESULT(not found)
Bram Moolenaar1f35bf92006-03-07 22:38:47 +0000267 CFLAGS="$save_cflags"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000268 AC_MSG_CHECKING(if Intel architecture is supported)
269 CPPFLAGS="$CPPFLAGS -arch i386"
270 LDFLAGS="$save_ldflags -arch i386"
271 AC_TRY_LINK([ ], [ ],
272 AC_MSG_RESULT(yes); MACARCH="intel",
273 AC_MSG_RESULT(no, using PowerPC)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000274 MACARCH="ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000275 CPPFLAGS="$save_cppflags -arch ppc"
276 LDFLAGS="$save_ldflags -arch ppc"))
277 elif test "x$MACARCH" = "xintel"; then
278 CPPFLAGS="$CPPFLAGS -arch intel"
279 LDFLAGS="$LDFLAGS -arch intel"
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000280 elif test "x$MACARCH" = "xppc"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000281 CPPFLAGS="$CPPFLAGS -arch ppc"
282 LDFLAGS="$LDFLAGS -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000283 fi
284
Bram Moolenaar071d4272004-06-13 20:20:40 +0000285 if test "$enable_darwin" = "yes"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200286 MACOS_X_DARWIN=yes
Bram Moolenaar164fca32010-07-14 13:58:07 +0200287 OS_EXTRA_SRC="os_macosx.m os_mac_conv.c";
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000288 OS_EXTRA_OBJ="objects/os_macosx.o objects/os_mac_conv.o"
Bram Moolenaar32466aa2006-02-24 23:53:04 +0000289 dnl TODO: use -arch i386 on Intel machines
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100290 dnl Removed -no-cpp-precomp, only for very old compilers.
Bram Moolenaard0573012017-10-28 21:11:06 +0200291 CPPFLAGS="$CPPFLAGS -DMACOS_X_DARWIN"
Bram Moolenaar040f9752020-08-11 23:08:48 +0200292
293 dnl Assume we don't want X11 unless it was specifically asked for
294 dnl (--with-x) or Motif, Athena or GTK GUI is used.
295 if test -z "$with_x" -a "X$enable_gui" != Xmotif -a "X$enable_gui" != Xathena -a "X$enable_gui" != Xgtk2 -a "X$enable_gui" != Xgtk3; then
296 with_x=no
297 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000298 fi
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000299
Bram Moolenaardb552d602006-03-23 22:59:57 +0000300 dnl Avoid a bug with -O2 with gcc 4.0.1. Symptom: malloc() reports double
Bram Moolenaarfd2ac762006-03-01 22:09:21 +0000301 dnl free. This happens in expand_filename(), because the optimizer swaps
Bram Moolenaardb552d602006-03-23 22:59:57 +0000302 dnl two blocks of code, both using "repl", that can't be swapped.
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000303 if test "$MACARCH" = "intel" -o "$MACARCH" = "both"; then
304 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-Oz/'`
305 fi
306
Bram Moolenaar071d4272004-06-13 20:20:40 +0000307else
308 AC_MSG_RESULT(no)
309fi
310
Bram Moolenaar39766a72013-11-03 00:41:00 +0100311dnl Mac OS X 10.9+ no longer include AvailabilityMacros.h in Carbon
312dnl so we need to include it to have access to version macros.
Bram Moolenaar18e54692013-11-03 20:26:31 +0100313AC_CHECK_HEADERS(AvailabilityMacros.h)
Bram Moolenaar39766a72013-11-03 00:41:00 +0100314
Bram Moolenaar071d4272004-06-13 20:20:40 +0000315AC_SUBST(OS_EXTRA_SRC)
316AC_SUBST(OS_EXTRA_OBJ)
317
318dnl Add /usr/local/lib to $LDFLAGS and /usr/local/include to CFLAGS.
319dnl Only when the directory exists and it wasn't there yet.
320dnl For gcc don't do this when it is already in the default search path.
Bram Moolenaar446cb832008-06-24 21:56:24 +0000321dnl Skip all of this when cross-compiling.
322if test "$cross_compiling" = no; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000323 AC_MSG_CHECKING(--with-local-dir argument)
Bram Moolenaar446cb832008-06-24 21:56:24 +0000324 have_local_include=''
325 have_local_lib=''
Bram Moolenaarc236c162008-07-13 17:41:49 +0000326 AC_ARG_WITH([local-dir], [ --with-local-dir=PATH search PATH instead of /usr/local for local libraries.
327 --without-local-dir do not search /usr/local for local libraries.], [
328 local_dir="$withval"
329 case "$withval" in
330 */*) ;;
331 no)
332 # avoid adding local dir to LDFLAGS and CPPFLAGS
Bram Moolenaare06c1882010-07-21 22:05:20 +0200333 have_local_include=yes
Bram Moolenaarc236c162008-07-13 17:41:49 +0000334 have_local_lib=yes
335 ;;
336 *) AC_MSG_ERROR(must pass path argument to --with-local-dir) ;;
337 esac
338 AC_MSG_RESULT($local_dir)
339 ], [
340 local_dir=/usr/local
341 AC_MSG_RESULT(Defaulting to $local_dir)
342 ])
343 if test "$GCC" = yes -a "$local_dir" != no; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000344 echo 'void f(){}' > conftest.c
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100345 dnl Removed -no-cpp-precomp, only needed for OS X 10.2 (Ben Fowler)
346 have_local_include=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/include"`
Bram Moolenaarc236c162008-07-13 17:41:49 +0000347 have_local_lib=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/lib"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000348 rm -f conftest.c conftest.o
Bram Moolenaar071d4272004-06-13 20:20:40 +0000349 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000350 if test -z "$have_local_lib" -a -d "${local_dir}/lib"; then
351 tt=`echo "$LDFLAGS" | sed -e "s+-L${local_dir}/lib ++g" -e "s+-L${local_dir}/lib$++g"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000352 if test "$tt" = "$LDFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000353 LDFLAGS="$LDFLAGS -L${local_dir}/lib"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000354 fi
355 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000356 if test -z "$have_local_include" -a -d "${local_dir}/include"; then
357 tt=`echo "$CPPFLAGS" | sed -e "s+-I${local_dir}/include ++g" -e "s+-I${local_dir}/include$++g"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000358 if test "$tt" = "$CPPFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000359 CPPFLAGS="$CPPFLAGS -I${local_dir}/include"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000360 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000361 fi
362fi
363
364AC_MSG_CHECKING(--with-vim-name argument)
365AC_ARG_WITH(vim-name, [ --with-vim-name=NAME what to call the Vim executable],
366 VIMNAME="$withval"; AC_MSG_RESULT($VIMNAME),
Bram Moolenaare344bea2005-09-01 20:46:49 +0000367 VIMNAME="vim"; AC_MSG_RESULT(Defaulting to $VIMNAME))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000368AC_SUBST(VIMNAME)
369AC_MSG_CHECKING(--with-ex-name argument)
370AC_ARG_WITH(ex-name, [ --with-ex-name=NAME what to call the Ex executable],
371 EXNAME="$withval"; AC_MSG_RESULT($EXNAME),
372 EXNAME="ex"; AC_MSG_RESULT(Defaulting to ex))
373AC_SUBST(EXNAME)
374AC_MSG_CHECKING(--with-view-name argument)
375AC_ARG_WITH(view-name, [ --with-view-name=NAME what to call the View executable],
376 VIEWNAME="$withval"; AC_MSG_RESULT($VIEWNAME),
377 VIEWNAME="view"; AC_MSG_RESULT(Defaulting to view))
378AC_SUBST(VIEWNAME)
379
380AC_MSG_CHECKING(--with-global-runtime argument)
Bram Moolenaar9d302ad2018-12-21 11:48:51 +0100381AC_ARG_WITH(global-runtime, [ --with-global-runtime=DIR global runtime directory in 'runtimepath', comma-separated for multiple directories],
382 RUNTIME_GLOBAL="$withval"; AC_MSG_RESULT($withval),
Bram Moolenaar071d4272004-06-13 20:20:40 +0000383 AC_MSG_RESULT(no))
384
Bram Moolenaar9d302ad2018-12-21 11:48:51 +0100385if test "X$RUNTIME_GLOBAL" != "X"; then
386 RUNTIME_GLOBAL_AFTER=$(printf -- "$RUNTIME_GLOBAL\\n" | $AWK -F, 'BEGIN { comma=0 } { for (i = NF; i > 0; i--) { if (comma) { printf ",%s/after", $i } else { printf "%s/after", $i; comma=1 } } } END { printf "\n" }')
387 AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL, "$RUNTIME_GLOBAL")
388 AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL_AFTER, "$RUNTIME_GLOBAL_AFTER")
389fi
390
Bram Moolenaar071d4272004-06-13 20:20:40 +0000391AC_MSG_CHECKING(--with-modified-by argument)
392AC_ARG_WITH(modified-by, [ --with-modified-by=NAME name of who modified a release version],
393 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(MODIFIED_BY, "$withval"),
394 AC_MSG_RESULT(no))
395
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200396dnl Check for EBCDIC stolen from the LYNX port to z/OS Unix
Bram Moolenaar071d4272004-06-13 20:20:40 +0000397AC_MSG_CHECKING(if character set is EBCDIC)
398AC_TRY_COMPILE([ ],
399[ /* TryCompile function for CharSet.
400 Treat any failure as ASCII for compatibility with existing art.
401 Use compile-time rather than run-time tests for cross-compiler
402 tolerance. */
403#if '0'!=240
404make an error "Character set is not EBCDIC"
405#endif ],
406[ # TryCompile action if true
407cf_cv_ebcdic=yes ],
408[ # TryCompile action if false
409cf_cv_ebcdic=no])
410# end of TryCompile ])
411# end of CacheVal CvEbcdic
412AC_MSG_RESULT($cf_cv_ebcdic)
413case "$cf_cv_ebcdic" in #(vi
414 yes) AC_DEFINE(EBCDIC)
415 line_break='"\\n"'
416 ;;
417 *) line_break='"\\012"';;
418esac
419AC_SUBST(line_break)
420
421if test "$cf_cv_ebcdic" = "yes"; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +0200422dnl If we have EBCDIC we most likely have z/OS Unix, let's test it!
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200423AC_MSG_CHECKING(for z/OS Unix)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000424case $vim_cv_uname_output in
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200425 OS/390) zOSUnix="yes";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000426 dnl If using cc the environment variable _CC_CCMODE must be
427 dnl set to "1", so that some compiler extensions are enabled.
428 dnl If using c89 the environment variable is named _CC_C89MODE.
429 dnl Note: compile with c89 never tested.
430 if test "$CC" = "cc"; then
431 ccm="$_CC_CCMODE"
432 ccn="CC"
433 else
434 if test "$CC" = "c89"; then
435 ccm="$_CC_C89MODE"
436 ccn="C89"
437 else
438 ccm=1
439 fi
440 fi
441 if test "$ccm" != "1"; then
442 echo ""
443 echo "------------------------------------------"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200444 echo " On z/OS Unix, the environment variable"
Bram Moolenaar77c19352012-06-13 19:19:41 +0200445 echo " _CC_${ccn}MODE must be set to \"1\"!"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000446 echo " Do:"
447 echo " export _CC_${ccn}MODE=1"
448 echo " and then call configure again."
449 echo "------------------------------------------"
450 exit 1
451 fi
Bram Moolenaar77c19352012-06-13 19:19:41 +0200452 # Set CFLAGS for configure process.
453 # This will be reset later for config.mk.
454 # Use haltonmsg to force error for missing H files.
455 CFLAGS="$CFLAGS -D_ALL_SOURCE -Wc,float(ieee),haltonmsg(3296)";
456 LDFLAGS="$LDFLAGS -Wl,EDIT=NO"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000457 AC_MSG_RESULT(yes)
458 ;;
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200459 *) zOSUnix="no";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000460 AC_MSG_RESULT(no)
461 ;;
462esac
463fi
464
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200465dnl Set QUOTESED. Needs additional backslashes on zOS
466if test "$zOSUnix" = "yes"; then
Bram Moolenaarabcbb0e2020-12-23 12:33:42 +0100467 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\\\\\&/g' -e 's/\\\\\\\\\"/\"/' -e 's/\\\\\\\\\";\$\$/\";/' -e 's/ */ /g'"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200468else
Bram Moolenaarabcbb0e2020-12-23 12:33:42 +0100469 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\&/g' -e 's/\\\\\"/\"/' -e 's/\\\\\";\$\$/\";/' -e 's/ */ /g'"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200470fi
471AC_SUBST(QUOTESED)
472
473
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200474dnl Link with -lsmack for Smack stuff; if not found
475AC_MSG_CHECKING(--disable-smack argument)
476AC_ARG_ENABLE(smack,
477 [ --disable-smack Do not check for Smack support.],
478 , enable_smack="yes")
479if test "$enable_smack" = "yes"; then
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200480 AC_MSG_RESULT(no)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200481 AC_CHECK_HEADER([linux/xattr.h], true, enable_smack="no")
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200482else
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200483 AC_MSG_RESULT(yes)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200484fi
485if test "$enable_smack" = "yes"; then
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200486 AC_CHECK_HEADER([attr/xattr.h], true, enable_smack="no")
487fi
488if test "$enable_smack" = "yes"; then
489 AC_MSG_CHECKING(for XATTR_NAME_SMACKEXEC in linux/xattr.h)
490 AC_EGREP_CPP(XATTR_NAME_SMACKEXEC, [#include <linux/xattr.h>],
491 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +0200492 AC_MSG_RESULT(no); enable_smack="no")
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200493fi
494if test "$enable_smack" = "yes"; then
495 AC_CHECK_LIB(attr, setxattr,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200496 [LIBS="$LIBS -lattr"
497 found_smack="yes"
498 AC_DEFINE(HAVE_SMACK)])
Bram Moolenaar588ebeb2008-05-07 17:09:24 +0000499fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000500
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200501dnl When smack was found don't search for SELinux
502if test "x$found_smack" = "x"; then
503 dnl Link with -lselinux for SELinux stuff; if not found
504 AC_MSG_CHECKING(--disable-selinux argument)
505 AC_ARG_ENABLE(selinux,
506 [ --disable-selinux Do not check for SELinux support.],
507 , enable_selinux="yes")
508 if test "$enable_selinux" = "yes"; then
509 AC_MSG_RESULT(no)
510 AC_CHECK_LIB(selinux, is_selinux_enabled,
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100511 [AC_CHECK_HEADER(selinux/selinux.h,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200512 [LIBS="$LIBS -lselinux"
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100513 AC_DEFINE(HAVE_SELINUX)])])
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200514 else
515 AC_MSG_RESULT(yes)
516 fi
517fi
518
Bram Moolenaar071d4272004-06-13 20:20:40 +0000519dnl Check user requested features.
520
521AC_MSG_CHECKING(--with-features argument)
Bram Moolenaareec29812016-07-26 21:27:36 +0200522AC_ARG_WITH(features, [ --with-features=TYPE tiny, small, normal, big or huge (default: huge)],
Bram Moolenaar071d4272004-06-13 20:20:40 +0000523 features="$withval"; AC_MSG_RESULT($features),
Bram Moolenaar23c4f712016-01-20 22:11:59 +0100524 features="huge"; AC_MSG_RESULT(Defaulting to huge))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000525
526dovimdiff=""
527dogvimdiff=""
528case "$features" in
529 tiny) AC_DEFINE(FEAT_TINY) ;;
530 small) AC_DEFINE(FEAT_SMALL) ;;
531 normal) AC_DEFINE(FEAT_NORMAL) dovimdiff="installvimdiff";
532 dogvimdiff="installgvimdiff" ;;
533 big) AC_DEFINE(FEAT_BIG) dovimdiff="installvimdiff";
534 dogvimdiff="installgvimdiff" ;;
535 huge) AC_DEFINE(FEAT_HUGE) dovimdiff="installvimdiff";
536 dogvimdiff="installgvimdiff" ;;
537 *) AC_MSG_RESULT([Sorry, $features is not supported]) ;;
538esac
539
540AC_SUBST(dovimdiff)
541AC_SUBST(dogvimdiff)
542
543AC_MSG_CHECKING(--with-compiledby argument)
544AC_ARG_WITH(compiledby, [ --with-compiledby=NAME name to show in :version message],
545 compiledby="$withval"; AC_MSG_RESULT($withval),
546 compiledby=""; AC_MSG_RESULT(no))
547AC_SUBST(compiledby)
548
549AC_MSG_CHECKING(--disable-xsmp argument)
550AC_ARG_ENABLE(xsmp,
551 [ --disable-xsmp Disable XSMP session management],
552 , enable_xsmp="yes")
553
554if test "$enable_xsmp" = "yes"; then
555 AC_MSG_RESULT(no)
556 AC_MSG_CHECKING(--disable-xsmp-interact argument)
557 AC_ARG_ENABLE(xsmp-interact,
558 [ --disable-xsmp-interact Disable XSMP interaction],
559 , enable_xsmp_interact="yes")
560 if test "$enable_xsmp_interact" = "yes"; then
561 AC_MSG_RESULT(no)
562 AC_DEFINE(USE_XSMP_INTERACT)
563 else
564 AC_MSG_RESULT(yes)
565 fi
566else
567 AC_MSG_RESULT(yes)
568fi
569
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200570dnl Check for Lua feature.
571AC_MSG_CHECKING(--enable-luainterp argument)
572AC_ARG_ENABLE(luainterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200573 [ --enable-luainterp[=OPTS] Include Lua interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200574 [enable_luainterp="no"])
575AC_MSG_RESULT($enable_luainterp)
576
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200577if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +0100578 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
579 AC_MSG_ERROR([cannot use Lua with tiny or small features])
580 fi
581
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200582 dnl -- find the lua executable
583 AC_SUBST(vi_cv_path_lua)
584
585 AC_MSG_CHECKING(--with-lua-prefix argument)
586 AC_ARG_WITH(lua_prefix,
587 [ --with-lua-prefix=PFX Prefix where Lua is installed.],
588 with_lua_prefix="$withval"; AC_MSG_RESULT($with_lua_prefix),
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200589 with_lua_prefix="";AC_MSG_RESULT(no))
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200590
591 if test "X$with_lua_prefix" != "X"; then
592 vi_cv_path_lua_pfx="$with_lua_prefix"
593 else
594 AC_MSG_CHECKING(LUA_PREFIX environment var)
595 if test "X$LUA_PREFIX" != "X"; then
596 AC_MSG_RESULT("$LUA_PREFIX")
597 vi_cv_path_lua_pfx="$LUA_PREFIX"
598 else
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200599 AC_MSG_RESULT([not set, default to /usr])
600 vi_cv_path_lua_pfx="/usr"
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200601 fi
602 fi
603
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200604 AC_MSG_CHECKING(--with-luajit)
605 AC_ARG_WITH(luajit,
606 [ --with-luajit Link with LuaJIT instead of Lua.],
607 [vi_cv_with_luajit="$withval"],
608 [vi_cv_with_luajit="no"])
609 AC_MSG_RESULT($vi_cv_with_luajit)
610
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200611 LUA_INC=
612 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200613 if test "x$vi_cv_with_luajit" != "xno"; then
614 dnl -- try to find LuaJIT executable
615 AC_PATH_PROG(vi_cv_path_luajit, luajit)
616 if test "X$vi_cv_path_luajit" != "X"; then
617 dnl -- find LuaJIT version
618 AC_CACHE_CHECK(LuaJIT version, vi_cv_version_luajit,
Bram Moolenaar49b10272013-11-21 12:17:51 +0100619 [ vi_cv_version_luajit=`${vi_cv_path_luajit} -v 2>&1 | sed 's/LuaJIT \([[0-9.]]*\)\.[[0-9]]\(-[[a-z0-9]]*\)* .*/\1/'` ])
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200620 AC_CACHE_CHECK(Lua version of LuaJIT, vi_cv_version_lua_luajit,
621 [ vi_cv_version_lua_luajit=`${vi_cv_path_luajit} -e "print(_VERSION)" | sed 's/.* //'` ])
622 vi_cv_path_lua="$vi_cv_path_luajit"
623 vi_cv_version_lua="$vi_cv_version_lua_luajit"
624 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200625 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200626 dnl -- try to find Lua executable
627 AC_PATH_PROG(vi_cv_path_plain_lua, lua)
628 if test "X$vi_cv_path_plain_lua" != "X"; then
629 dnl -- find Lua version
630 AC_CACHE_CHECK(Lua version, vi_cv_version_plain_lua,
631 [ vi_cv_version_plain_lua=`${vi_cv_path_plain_lua} -e "print(_VERSION)" | sed 's/.* //'` ])
632 fi
633 vi_cv_path_lua="$vi_cv_path_plain_lua"
634 vi_cv_version_lua="$vi_cv_version_plain_lua"
635 fi
636 if test "x$vi_cv_with_luajit" != "xno" && test "X$vi_cv_version_luajit" != "X"; then
637 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit)
Bram Moolenaar49222be2015-12-11 18:11:30 +0100638 if test -f "$vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200639 AC_MSG_RESULT(yes)
640 LUA_INC=/luajit-$vi_cv_version_luajit
641 fi
642 fi
643 if test "X$LUA_INC" = "X"; then
644 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)
Bram Moolenaar49222be2015-12-11 18:11:30 +0100645 if test -f "$vi_cv_path_lua_pfx/include/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200646 AC_MSG_RESULT(yes)
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200647 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200648 AC_MSG_RESULT(no)
649 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua)
Bram Moolenaar49222be2015-12-11 18:11:30 +0100650 if test -f "$vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200651 AC_MSG_RESULT(yes)
652 LUA_INC=/lua$vi_cv_version_lua
653 else
654 AC_MSG_RESULT(no)
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200655
656 # Detect moonjit:
657 # https://groups.google.com/forum/#!topic/vim_use/O0vek60WuTk
658 lua_suf=/moonjit-2.3
659 inc_path="$vi_cv_path_lua_pfx/include"
Bram Moolenaarad4dc832020-04-20 16:21:53 +0200660 for dir in "$inc_path"/moonjit-[[0-9]]* ; do
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200661 if test -d "$dir" ; then
Bram Moolenaara79a8942020-12-17 20:50:25 +0100662 lua_suf=`basename "$dir"`
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200663 lua_suf="/$lua_suf"
664 break
665 fi
666 done
667 AC_MSG_CHECKING(if lua.h can be found in $inc_path$lua_suf)
668 if test -f "$inc_path$lua_suf/lua.h"; then
669 AC_MSG_RESULT(yes)
670 LUA_INC=$lua_suf
671 else
672 AC_MSG_RESULT(no)
673 vi_cv_path_lua_pfx=
674 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200675 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200676 fi
677 fi
678 fi
679
680 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200681 if test "x$vi_cv_with_luajit" != "xno"; then
682 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
683 if test "X$multiarch" != "X"; then
684 lib_multiarch="lib/${multiarch}"
685 else
686 lib_multiarch="lib"
687 fi
688 if test "X$vi_cv_version_lua" = "X"; then
689 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit"
690 else
691 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit-$vi_cv_version_lua"
692 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200693 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200694 if test "X$LUA_INC" != "X"; then
695 dnl Test alternate location using version
696 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua$vi_cv_version_lua"
697 else
698 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua"
699 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200700 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200701 if test "$enable_luainterp" = "dynamic"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200702 lua_ok="yes"
703 else
704 AC_MSG_CHECKING([if link with ${LUA_LIBS} is sane])
705 libs_save=$LIBS
706 LIBS="$LIBS $LUA_LIBS"
707 AC_TRY_LINK(,[ ],
708 AC_MSG_RESULT(yes); lua_ok="yes",
709 AC_MSG_RESULT(no); lua_ok="no"; LUA_LIBS="")
710 LIBS=$libs_save
711 fi
712 if test "x$lua_ok" = "xyes"; then
713 LUA_CFLAGS="-I${vi_cv_path_lua_pfx}/include${LUA_INC}"
714 LUA_SRC="if_lua.c"
715 LUA_OBJ="objects/if_lua.o"
716 LUA_PRO="if_lua.pro"
717 AC_DEFINE(FEAT_LUA)
718 fi
719 if test "$enable_luainterp" = "dynamic"; then
720 if test "x$vi_cv_with_luajit" != "xno"; then
721 luajit="jit"
722 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200723 if test -f "${vi_cv_path_lua_pfx}/bin/cyglua-${vi_cv_version_lua}.dll"; then
724 vi_cv_dll_name_lua="cyglua-${vi_cv_version_lua}.dll"
725 else
Bram Moolenaard0573012017-10-28 21:11:06 +0200726 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200727 ext="dylib"
728 indexes=""
729 else
730 ext="so"
731 indexes=".0 .1 .2 .3 .4 .5 .6 .7 .8 .9"
732 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
733 if test "X$multiarch" != "X"; then
734 lib_multiarch="lib/${multiarch}"
735 fi
Bram Moolenaar768baac2013-04-15 14:44:57 +0200736 fi
737 dnl Determine the sover for the current version, but fallback to
738 dnl liblua${vi_cv_version_lua}.so if no sover-versioned file is found.
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200739 AC_MSG_CHECKING(if liblua${luajit}*.${ext}* can be found in $vi_cv_path_lua_pfx)
Bram Moolenaar768baac2013-04-15 14:44:57 +0200740 for subdir in "${lib_multiarch}" lib64 lib; do
741 if test -z "$subdir"; then
742 continue
743 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200744 for sover in "${vi_cv_version_lua}.${ext}" "-${vi_cv_version_lua}.${ext}" \
745 ".${vi_cv_version_lua}.${ext}" ".${ext}.${vi_cv_version_lua}"; do
746 for i in $indexes ""; do
747 if test -f "${vi_cv_path_lua_pfx}/${subdir}/liblua${luajit}${sover}$i"; then
Bram Moolenaar768baac2013-04-15 14:44:57 +0200748 sover2="$i"
749 break 3
750 fi
751 done
Bram Moolenaar07e1da62013-02-06 19:49:43 +0100752 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200753 sover=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200754 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200755 if test "X$sover" = "X"; then
756 AC_MSG_RESULT(no)
757 lua_ok="no"
758 vi_cv_dll_name_lua="liblua${luajit}.${ext}"
759 else
760 AC_MSG_RESULT(yes)
761 lua_ok="yes"
762 vi_cv_dll_name_lua="liblua${luajit}${sover}$sover2"
763 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200764 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200765 AC_DEFINE(DYNAMIC_LUA)
766 LUA_LIBS=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200767 LUA_CFLAGS="-DDYNAMIC_LUA_DLL=\\\"${vi_cv_dll_name_lua}\\\" $LUA_CFLAGS"
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200768 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200769 if test "X$LUA_CFLAGS$LUA_LIBS" != "X" && \
Bram Moolenaard0573012017-10-28 21:11:06 +0200770 test "x$MACOS_X" = "xyes" && test "x$vi_cv_with_luajit" != "xno" && \
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000771 test "$vim_cv_uname_m_output" = "x86_64"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200772 dnl OSX/x64 requires these flags. See http://luajit.org/install.html
773 LUA_LIBS="-pagezero_size 10000 -image_base 100000000 $LUA_LIBS"
774 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200775 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200776 if test "$fail_if_missing" = "yes" -a "$lua_ok" != "yes"; then
Bram Moolenaarf788a062011-12-14 20:51:25 +0100777 AC_MSG_ERROR([could not configure lua])
778 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200779 AC_SUBST(LUA_SRC)
780 AC_SUBST(LUA_OBJ)
781 AC_SUBST(LUA_PRO)
782 AC_SUBST(LUA_LIBS)
783 AC_SUBST(LUA_CFLAGS)
784fi
785
786
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000787dnl Check for MzScheme feature.
788AC_MSG_CHECKING(--enable-mzschemeinterp argument)
789AC_ARG_ENABLE(mzschemeinterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200790 [ --enable-mzschemeinterp Include MzScheme interpreter.], ,
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000791 [enable_mzschemeinterp="no"])
792AC_MSG_RESULT($enable_mzschemeinterp)
793
794if test "$enable_mzschemeinterp" = "yes"; then
795 dnl -- find the mzscheme executable
796 AC_SUBST(vi_cv_path_mzscheme)
797
798 AC_MSG_CHECKING(--with-plthome argument)
799 AC_ARG_WITH(plthome,
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000800 [ --with-plthome=PLTHOME Use PLTHOME.],
801 with_plthome="$withval"; AC_MSG_RESULT($with_plthome),
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000802 with_plthome="";AC_MSG_RESULT("no"))
803
804 if test "X$with_plthome" != "X"; then
805 vi_cv_path_mzscheme_pfx="$with_plthome"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100806 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000807 else
808 AC_MSG_CHECKING(PLTHOME environment var)
809 if test "X$PLTHOME" != "X"; then
810 AC_MSG_RESULT("$PLTHOME")
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000811 vi_cv_path_mzscheme_pfx="$PLTHOME"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100812 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000813 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000814 AC_MSG_RESULT(not set)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000815 dnl -- try to find MzScheme executable
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000816 AC_PATH_PROG(vi_cv_path_mzscheme, mzscheme)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000817
818 dnl resolve symbolic link, the executable is often elsewhere and there
819 dnl are no links for the include files.
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000820 if test "X$vi_cv_path_mzscheme" != "X"; then
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000821 lsout=`ls -l $vi_cv_path_mzscheme`
822 if echo "$lsout" | grep -e '->' >/dev/null 2>/dev/null; then
823 vi_cv_path_mzscheme=`echo "$lsout" | sed 's/.*-> \(.*\)/\1/'`
824 fi
825 fi
826
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000827 if test "X$vi_cv_path_mzscheme" != "X"; then
828 dnl -- find where MzScheme thinks it was installed
829 AC_CACHE_CHECK(MzScheme install prefix,vi_cv_path_mzscheme_pfx,
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000830 dnl different versions of MzScheme differ in command line processing
831 dnl use universal approach
832 echo "(display (simplify-path \
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000833 (build-path (call-with-values \
834 (lambda () (split-path (find-system-path (quote exec-file)))) \
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000835 (lambda (base name must-be-dir?) base)) (quote up))))" > mzdirs.scm
836 dnl Remove a trailing slash
837 [ vi_cv_path_mzscheme_pfx=`${vi_cv_path_mzscheme} -r mzdirs.scm | \
838 sed -e 's+/$++'` ])
839 rm -f mzdirs.scm
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000840 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000841 fi
842 fi
843
844 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100845 AC_MSG_CHECKING(for racket include directory)
846 SCHEME_INC=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-include-dir))) (when (path? p) (display p)))'`
847 if test "X$SCHEME_INC" != "X"; then
848 AC_MSG_RESULT(${SCHEME_INC})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000849 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100850 AC_MSG_RESULT(not found)
851 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include)
852 if test -f "$vi_cv_path_mzscheme_pfx/include/scheme.h"; then
853 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000854 AC_MSG_RESULT(yes)
Bram Moolenaard7afed32007-05-06 13:26:41 +0000855 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000856 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100857 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt)
858 if test -f "$vi_cv_path_mzscheme_pfx/include/plt/scheme.h"; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000859 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100860 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000861 else
862 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100863 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket)
864 if test -f "$vi_cv_path_mzscheme_pfx/include/racket/scheme.h"; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100865 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100866 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100867 else
868 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100869 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/)
870 if test -f /usr/include/plt/scheme.h; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100871 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100872 SCHEME_INC=/usr/include/plt
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100873 else
874 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100875 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/racket/)
876 if test -f /usr/include/racket/scheme.h; then
877 AC_MSG_RESULT(yes)
878 SCHEME_INC=/usr/include/racket
879 else
880 AC_MSG_RESULT(no)
881 vi_cv_path_mzscheme_pfx=
882 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100883 fi
884 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000885 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000886 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000887 fi
888 fi
889
890 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100891
892 AC_MSG_CHECKING(for racket lib directory)
893 SCHEME_LIB=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-lib-dir))) (when (path? p) (display p)))'`
894 if test "X$SCHEME_LIB" != "X"; then
895 AC_MSG_RESULT(${SCHEME_LIB})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000896 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100897 AC_MSG_RESULT(not found)
898 fi
899
900 for path in "${vi_cv_path_mzscheme_pfx}/lib" "${SCHEME_LIB}"; do
901 if test "X$path" != "X"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200902 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100903 MZSCHEME_LIBS="-framework Racket"
904 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
905 elif test -f "${path}/libmzscheme3m.a"; then
906 MZSCHEME_LIBS="${path}/libmzscheme3m.a"
907 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
908 elif test -f "${path}/libracket3m.a"; then
909 MZSCHEME_LIBS="${path}/libracket3m.a"
Bram Moolenaar588d2412020-10-03 14:24:19 +0200910 if test -f "${path}/librktio.a"; then
911 MZSCHEME_LIBS="${MZSCHEME_LIBS} ${path}/librktio.a"
912 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100913 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
914 elif test -f "${path}/libracket.a"; then
915 MZSCHEME_LIBS="${path}/libracket.a ${path}/libmzgc.a"
916 elif test -f "${path}/libmzscheme.a"; then
917 MZSCHEME_LIBS="${path}/libmzscheme.a ${path}/libmzgc.a"
918 else
919 dnl Using shared objects
920 if test -f "${path}/libmzscheme3m.so"; then
921 MZSCHEME_LIBS="-L${path} -lmzscheme3m"
922 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
923 elif test -f "${path}/libracket3m.so"; then
924 MZSCHEME_LIBS="-L${path} -lracket3m"
925 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
926 elif test -f "${path}/libracket.so"; then
927 MZSCHEME_LIBS="-L${path} -lracket -lmzgc"
928 else
929 dnl try next until last
930 if test "$path" != "$SCHEME_LIB"; then
931 continue
932 fi
933 MZSCHEME_LIBS="-L${path} -lmzscheme -lmzgc"
934 fi
935 if test "$GCC" = yes; then
936 dnl Make Vim remember the path to the library. For when it's not in
937 dnl $LD_LIBRARY_PATH.
938 MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${path}"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000939 elif test "$vim_cv_uname_output" = SunOS &&
940 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100941 MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${path}"
942 fi
943 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000944 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100945 if test "X$MZSCHEME_LIBS" != "X"; then
946 break
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +0000947 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100948 done
949
950 AC_MSG_CHECKING([if racket requires -pthread])
951 if test "X$SCHEME_LIB" != "X" && $FGREP -e -pthread "$SCHEME_LIB/buildinfo" >/dev/null ; then
952 AC_MSG_RESULT(yes)
953 MZSCHEME_LIBS="${MZSCHEME_LIBS} -pthread"
954 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -pthread"
955 else
956 AC_MSG_RESULT(no)
957 fi
958
959 AC_MSG_CHECKING(for racket config directory)
960 SCHEME_CONFIGDIR=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-config-dir))) (when (path? p) (display p)))'`
961 if test "X$SCHEME_CONFIGDIR" != "X"; then
962 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DMZSCHEME_CONFIGDIR='\"${SCHEME_CONFIGDIR}\"'"
963 AC_MSG_RESULT(${SCHEME_CONFIGDIR})
964 else
965 AC_MSG_RESULT(not found)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000966 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100967
968 AC_MSG_CHECKING(for racket collects directory)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100969 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))))'`
970 if test "X$SCHEME_COLLECTS" = "X"; then
971 if test -d "$vi_cv_path_mzscheme_pfx/lib/plt/collects"; then
972 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/plt/
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100973 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100974 if test -d "$vi_cv_path_mzscheme_pfx/lib/racket/collects"; then
975 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/racket/
Bram Moolenaar75676462013-01-30 14:55:42 +0100976 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100977 if test -d "$vi_cv_path_mzscheme_pfx/share/racket/collects"; then
978 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/
979 else
980 if test -d "$vi_cv_path_mzscheme_pfx/collects"; then
981 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/
982 fi
Bram Moolenaar75676462013-01-30 14:55:42 +0100983 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100984 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100985 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000986 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100987 if test "X$SCHEME_COLLECTS" != "X" ; then
988 AC_MSG_RESULT(${SCHEME_COLLECTS})
989 else
990 AC_MSG_RESULT(not found)
991 fi
992
993 AC_MSG_CHECKING(for mzscheme_base.c)
994 if test -f "${SCHEME_COLLECTS}collects/scheme/base.ss" ; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000995 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +0100996 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
997 MZSCHEME_MOD="++lib scheme/base"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100998 else
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100999 if test -f "${SCHEME_COLLECTS}collects/scheme/base.rkt" ; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +01001000 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +01001001 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
1002 MZSCHEME_MOD="++lib scheme/base"
1003 else
1004 if test -f "${SCHEME_COLLECTS}collects/racket/base.rkt" ; then
1005 MZSCHEME_EXTRA="mzscheme_base.c"
1006 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/raco ctool"
1007 MZSCHEME_MOD=""
1008 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +01001009 fi
1010 fi
1011 if test "X$MZSCHEME_EXTRA" != "X" ; then
1012 dnl need to generate bytecode for MzScheme base
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001013 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE"
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001014 AC_MSG_RESULT(needed)
1015 else
1016 AC_MSG_RESULT(not needed)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001017 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001018
Bram Moolenaar9e902192013-07-17 18:58:11 +02001019 dnl On Ubuntu this fixes "undefined reference to symbol 'ffi_type_void'".
1020 AC_CHECK_LIB(ffi, ffi_type_void, [MZSCHEME_LIBS="$MZSCHEME_LIBS -lffi"])
1021
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001022 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -I${SCHEME_INC} \
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001023 -DMZSCHEME_COLLECTS='\"${SCHEME_COLLECTS}collects\"'"
Bram Moolenaar9e902192013-07-17 18:58:11 +02001024
1025 dnl Test that we can compile a simple program with these CFLAGS and LIBS.
1026 AC_MSG_CHECKING([if compile and link flags for MzScheme are sane])
1027 cflags_save=$CFLAGS
1028 libs_save=$LIBS
1029 CFLAGS="$CFLAGS $MZSCHEME_CFLAGS"
1030 LIBS="$LIBS $MZSCHEME_LIBS"
1031 AC_TRY_LINK(,[ ],
1032 AC_MSG_RESULT(yes); mzs_ok=yes,
1033 AC_MSG_RESULT(no: MZSCHEME DISABLED); mzs_ok=no)
1034 CFLAGS=$cflags_save
1035 LIBS=$libs_save
1036 if test $mzs_ok = yes; then
1037 MZSCHEME_SRC="if_mzsch.c"
1038 MZSCHEME_OBJ="objects/if_mzsch.o"
1039 MZSCHEME_PRO="if_mzsch.pro"
1040 AC_DEFINE(FEAT_MZSCHEME)
1041 else
1042 MZSCHEME_CFLAGS=
1043 MZSCHEME_LIBS=
1044 MZSCHEME_EXTRA=
1045 MZSCHEME_MZC=
1046 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001047 fi
1048 AC_SUBST(MZSCHEME_SRC)
1049 AC_SUBST(MZSCHEME_OBJ)
1050 AC_SUBST(MZSCHEME_PRO)
1051 AC_SUBST(MZSCHEME_LIBS)
1052 AC_SUBST(MZSCHEME_CFLAGS)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001053 AC_SUBST(MZSCHEME_EXTRA)
1054 AC_SUBST(MZSCHEME_MZC)
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001055fi
1056
1057
Bram Moolenaar071d4272004-06-13 20:20:40 +00001058AC_MSG_CHECKING(--enable-perlinterp argument)
1059AC_ARG_ENABLE(perlinterp,
Bram Moolenaare06c1882010-07-21 22:05:20 +02001060 [ --enable-perlinterp[=OPTS] Include Perl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001061 [enable_perlinterp="no"])
1062AC_MSG_RESULT($enable_perlinterp)
Bram Moolenaare06c1882010-07-21 22:05:20 +02001063if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01001064 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1065 AC_MSG_ERROR([cannot use Perl with tiny or small features])
1066 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001067 AC_SUBST(vi_cv_path_perl)
1068 AC_PATH_PROG(vi_cv_path_perl, perl)
1069 if test "X$vi_cv_path_perl" != "X"; then
1070 AC_MSG_CHECKING(Perl version)
1071 if $vi_cv_path_perl -e 'require 5.003_01' >/dev/null 2>/dev/null; then
1072 eval `$vi_cv_path_perl -V:usethreads`
Bram Moolenaare06c1882010-07-21 22:05:20 +02001073 eval `$vi_cv_path_perl -V:libperl`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001074 if test "X$usethreads" = "XUNKNOWN" -o "X$usethreads" = "Xundef"; then
1075 badthreads=no
1076 else
1077 if $vi_cv_path_perl -e 'require 5.6.0' >/dev/null 2>/dev/null; then
1078 eval `$vi_cv_path_perl -V:use5005threads`
1079 if test "X$use5005threads" = "XUNKNOWN" -o "X$use5005threads" = "Xundef"; then
1080 badthreads=no
1081 else
1082 badthreads=yes
1083 AC_MSG_RESULT(>>> Perl > 5.6 with 5.5 threads cannot be used <<<)
1084 fi
1085 else
1086 badthreads=yes
1087 AC_MSG_RESULT(>>> Perl 5.5 with threads cannot be used <<<)
1088 fi
1089 fi
1090 if test $badthreads = no; then
1091 AC_MSG_RESULT(OK)
1092 eval `$vi_cv_path_perl -V:shrpenv`
1093 if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04
1094 shrpenv=""
1095 fi
1096 vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlibexp}'`
1097 AC_SUBST(vi_cv_perllib)
Bram Moolenaard5f62b12014-08-17 17:05:44 +02001098 vi_cv_perl_extutils=unknown_perl_extutils_path
1099 for extutils_rel_path in ExtUtils vendor_perl/ExtUtils; do
1100 xsubpp_path="$vi_cv_perllib/$extutils_rel_path/xsubpp"
1101 if test -f "$xsubpp_path"; then
1102 vi_cv_perl_xsubpp="$xsubpp_path"
1103 fi
1104 done
1105 AC_SUBST(vi_cv_perl_xsubpp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001106 dnl Remove "-fno-something", it breaks using cproto.
Bram Moolenaar280a8682015-06-21 13:41:08 +02001107 dnl Remove "-fdebug-prefix-map", it isn't supported by clang.
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001108 dnl Remove "FORTIFY_SOURCE", it will be defined twice.
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001109 dnl remove -pipe and -Wxxx, it confuses cproto
Bram Moolenaar071d4272004-06-13 20:20:40 +00001110 perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001111 -e 'ccflags;perl_inc;print"\n"' | sed -e 's/-fno[[^ ]]*//' \
1112 -e 's/-fdebug-prefix-map[[^ ]]*//g' \
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001113 -e 's/-pipe //' \
1114 -e 's/-W[[^ ]]*//g' \
1115 -e 's/-D_FORTIFY_SOURCE=.//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001116 dnl Remove "-lc", it breaks on FreeBSD when using "-pthread".
1117 perllibs=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed -e 'ldopts' | \
1118 sed -e '/Warning/d' -e '/Note (probably harmless)/d' \
1119 -e 's/-bE:perl.exp//' -e 's/-lc //'`
1120 dnl Don't add perl lib to $LIBS: if it's not in LD_LIBRARY_PATH
1121 dnl a test in configure may fail because of that.
1122 perlldflags=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed \
1123 -e 'ccdlflags' | sed -e 's/-bE:perl.exp//'`
1124
1125 dnl check that compiling a simple program still works with the flags
1126 dnl added for Perl.
1127 AC_MSG_CHECKING([if compile and link flags for Perl are sane])
1128 cflags_save=$CFLAGS
1129 libs_save=$LIBS
1130 ldflags_save=$LDFLAGS
1131 CFLAGS="$CFLAGS $perlcppflags"
1132 LIBS="$LIBS $perllibs"
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001133 perlldflags=`echo "$perlldflags" | sed -e 's/^ *//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001134 LDFLAGS="$perlldflags $LDFLAGS"
1135 AC_TRY_LINK(,[ ],
1136 AC_MSG_RESULT(yes); perl_ok=yes,
1137 AC_MSG_RESULT(no: PERL DISABLED); perl_ok=no)
1138 CFLAGS=$cflags_save
1139 LIBS=$libs_save
1140 LDFLAGS=$ldflags_save
1141 if test $perl_ok = yes; then
1142 if test "X$perlcppflags" != "X"; then
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001143 PERL_CFLAGS=$perlcppflags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001144 fi
1145 if test "X$perlldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001146 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$perlldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001147 LDFLAGS="$perlldflags $LDFLAGS"
1148 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001149 fi
1150 PERL_LIBS=$perllibs
1151 PERL_SRC="auto/if_perl.c if_perlsfio.c"
1152 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o"
1153 PERL_PRO="if_perl.pro if_perlsfio.pro"
1154 AC_DEFINE(FEAT_PERL)
1155 fi
1156 fi
1157 else
1158 AC_MSG_RESULT(>>> too old; need Perl version 5.003_01 or later <<<)
1159 fi
1160 fi
1161
Bram Moolenaard0573012017-10-28 21:11:06 +02001162 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00001163 dnl Mac OS X 10.2 or later
Bram Moolenaar071d4272004-06-13 20:20:40 +00001164 dir=/System/Library/Perl
1165 darwindir=$dir/darwin
1166 if test -d $darwindir; then
1167 PERL=/usr/bin/perl
1168 else
1169 dnl Mac OS X 10.3
1170 dir=/System/Library/Perl/5.8.1
1171 darwindir=$dir/darwin-thread-multi-2level
1172 if test -d $darwindir; then
1173 PERL=/usr/bin/perl
1174 fi
1175 fi
1176 if test -n "$PERL"; then
1177 PERL_DIR="$dir"
1178 PERL_CFLAGS="-DFEAT_PERL -I$darwindir/CORE"
1179 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o $darwindir/auto/DynaLoader/DynaLoader.a"
1180 PERL_LIBS="-L$darwindir/CORE -lperl"
1181 fi
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001182 dnl Perl on Mac OS X 10.5 adds "-arch" flags but these should only
1183 dnl be included if requested by passing --with-mac-arch to
1184 dnl configure, so strip these flags first (if present)
1185 PERL_LIBS=`echo "$PERL_LIBS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
1186 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 +00001187 fi
Bram Moolenaare06c1882010-07-21 22:05:20 +02001188 if test "$enable_perlinterp" = "dynamic"; then
1189 if test "$perl_ok" = "yes" -a "X$libperl" != "X"; then
1190 AC_DEFINE(DYNAMIC_PERL)
1191 PERL_CFLAGS="-DDYNAMIC_PERL_DLL=\\\"$libperl\\\" $PERL_CFLAGS"
1192 fi
1193 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001194
1195 if test "$fail_if_missing" = "yes" -a "$perl_ok" != "yes"; then
1196 AC_MSG_ERROR([could not configure perl])
1197 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001198fi
1199AC_SUBST(shrpenv)
1200AC_SUBST(PERL_SRC)
1201AC_SUBST(PERL_OBJ)
1202AC_SUBST(PERL_PRO)
1203AC_SUBST(PERL_CFLAGS)
1204AC_SUBST(PERL_LIBS)
1205
1206AC_MSG_CHECKING(--enable-pythoninterp argument)
1207AC_ARG_ENABLE(pythoninterp,
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001208 [ --enable-pythoninterp[=OPTS] Include Python interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001209 [enable_pythoninterp="no"])
1210AC_MSG_RESULT($enable_pythoninterp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001211if test "$enable_pythoninterp" = "yes" -o "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001212 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1213 AC_MSG_ERROR([cannot use Python with tiny or small features])
1214 fi
1215
Bram Moolenaar071d4272004-06-13 20:20:40 +00001216 dnl -- find the python executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001217 AC_MSG_CHECKING(--with-python-command argument)
1218 AC_SUBST(vi_cv_path_python)
1219 AC_ARG_WITH(python-command, [ --with-python-command=NAME name of the Python 2 command (default: python2 or python)],
1220 vi_cv_path_python="$withval"; AC_MSG_RESULT($vi_cv_path_python),
1221 AC_MSG_RESULT(no))
1222
1223 if test "X$vi_cv_path_python" = "X"; then
1224 AC_PATH_PROGS(vi_cv_path_python, python2 python)
1225 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001226 if test "X$vi_cv_path_python" != "X"; then
1227
1228 dnl -- get its version number
1229 AC_CACHE_CHECK(Python version,vi_cv_var_python_version,
1230 [[vi_cv_var_python_version=`
1231 ${vi_cv_path_python} -c 'import sys; print sys.version[:3]'`
1232 ]])
1233
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001234 dnl -- it must be at least version 2.3
1235 AC_MSG_CHECKING(Python is 2.3 or better)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001236 if ${vi_cv_path_python} -c \
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001237 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001238 then
1239 AC_MSG_RESULT(yep)
1240
1241 dnl -- find where python thinks it was installed
1242 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python_pfx,
1243 [ vi_cv_path_python_pfx=`
1244 ${vi_cv_path_python} -c \
1245 "import sys; print sys.prefix"` ])
1246
1247 dnl -- and where it thinks it runs
1248 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python_epfx,
1249 [ vi_cv_path_python_epfx=`
1250 ${vi_cv_path_python} -c \
1251 "import sys; print sys.exec_prefix"` ])
1252
1253 dnl -- python's internal library path
1254
1255 AC_CACHE_VAL(vi_cv_path_pythonpath,
1256 [ vi_cv_path_pythonpath=`
1257 unset PYTHONPATH;
1258 ${vi_cv_path_python} -c \
1259 "import sys, string; print string.join(sys.path,':')"` ])
1260
1261 dnl -- where the Python implementation library archives are
1262
1263 AC_ARG_WITH(python-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001264 [ --with-python-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001265 [ vi_cv_path_python_conf="${withval}"; have_python_config_dir=1 ] )
Bram Moolenaar071d4272004-06-13 20:20:40 +00001266
1267 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python_conf,
1268 [
1269 vi_cv_path_python_conf=
Bram Moolenaarac499e32013-06-02 19:14:17 +02001270 d=`${vi_cv_path_python} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBPL')"`
1271 if test -d "$d" && test -f "$d/config.c"; then
1272 vi_cv_path_python_conf="$d"
1273 else
1274 for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
1275 for subdir in lib64 lib share; do
1276 d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
1277 if test -d "$d" && test -f "$d/config.c"; then
1278 vi_cv_path_python_conf="$d"
1279 fi
1280 done
Bram Moolenaar071d4272004-06-13 20:20:40 +00001281 done
Bram Moolenaarac499e32013-06-02 19:14:17 +02001282 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001283 ])
1284
1285 PYTHON_CONFDIR="${vi_cv_path_python_conf}"
1286
1287 if test "X$PYTHON_CONFDIR" = "X"; then
1288 AC_MSG_RESULT([can't find it!])
1289 else
1290
1291 dnl -- we need to examine Python's config/Makefile too
1292 dnl see what the interpreter is built from
1293 AC_CACHE_VAL(vi_cv_path_python_plibs,
1294 [
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001295 pwd=`pwd`
1296 tmp_mkf="$pwd/config-PyMake$$"
1297 cat -- "${PYTHON_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001298__:
Bram Moolenaar218116c2010-05-20 21:46:00 +02001299 @echo "python_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001300 @echo "python_LIBS='$(LIBS)'"
1301 @echo "python_SYSLIBS='$(SYSLIBS)'"
1302 @echo "python_LINKFORSHARED='$(LINKFORSHARED)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001303 @echo "python_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001304 @echo "python_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001305 @echo "python_PYTHONFRAMEWORK='$(PYTHONFRAMEWORK)'"
1306 @echo "python_PYTHONFRAMEWORKPREFIX='$(PYTHONFRAMEWORKPREFIX)'"
1307 @echo "python_PYTHONFRAMEWORKINSTALLDIR='$(PYTHONFRAMEWORKINSTALLDIR)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001308eof
1309 dnl -- delete the lines from make about Entering/Leaving directory
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001310 eval "`cd ${PYTHON_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1311 rm -f -- "${tmp_mkf}"
Bram Moolenaard0573012017-10-28 21:11:06 +02001312 if test "x$MACOS_X" = "xyes" && test -n "${python_PYTHONFRAMEWORK}" && ${vi_cv_path_python} -c \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001313 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then
1314 vi_cv_path_python_plibs="-framework Python"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001315 if test "x${vi_cv_path_python}" != "x/usr/bin/python" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
1316 vi_cv_path_python_plibs="-F${python_PYTHONFRAMEWORKPREFIX} -framework Python"
1317 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001318 else
Bram Moolenaar9ce42132018-04-11 22:19:36 +02001319 vi_cv_path_python_plibs="-L${PYTHON_CONFDIR} -lpython${vi_cv_var_python_version}"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001320 dnl -- Check if the path contained in python_LINKFORSHARED is
1321 dnl usable for vim build. If not, make and try other
1322 dnl candidates.
Bram Moolenaara161e262015-03-24 15:14:27 +01001323 if test -n "${python_LINKFORSHARED}" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
Bram Moolenaar6c927552015-03-24 12:21:33 +01001324 python_link_symbol=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]].*/\1/'`
1325 python_link_path=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]][[ \t]]*\(.*\)/\2/'`
1326 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1327 dnl -- The path looks relative. Guess the absolute one using
1328 dnl the prefix and try that.
1329 python_link_path="${python_PYTHONFRAMEWORKPREFIX}/${python_link_path}"
1330 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1331 dnl -- A last resort.
1332 python_link_path="${python_PYTHONFRAMEWORKINSTALLDIR}/Versions/${vi_cv_var_python_version}/${python_PYTHONFRAMEWORK}"
1333 dnl -- No check is done. The last word is left to the
1334 dnl "sanity" test on link flags that follows shortly.
1335 fi
1336 python_LINKFORSHARED="${python_link_symbol} ${python_link_path}"
1337 fi
1338 fi
Bram Moolenaar218116c2010-05-20 21:46:00 +02001339 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 +00001340 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1341 vi_cv_path_python_plibs=`echo $vi_cv_path_python_plibs | sed s/-ltermcap//`
1342 fi
1343 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001344 AC_CACHE_CHECK(Python's dll name,vi_cv_dll_name_python,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001345 [
1346 if test "X$python_DLLLIBRARY" != "X"; then
1347 vi_cv_dll_name_python="$python_DLLLIBRARY"
1348 else
1349 vi_cv_dll_name_python="$python_INSTSONAME"
1350 fi
1351 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00001352
1353 PYTHON_LIBS="${vi_cv_path_python_plibs}"
1354 if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001355 PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001356 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001357 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 +00001358 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001359 if test "X$have_python_config_dir" = "X1" -a "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001360 dnl Define PYTHON_HOME if --with-python-config-dir was used
1361 PYTHON_CFLAGS="${PYTHON_CFLAGS} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'"
1362
1363 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001364 PYTHON_SRC="if_python.c"
Bram Moolenaar9bdb9a02012-07-25 16:32:08 +02001365 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001366
1367 dnl On FreeBSD linking with "-pthread" is required to use threads.
1368 dnl _THREAD_SAFE must be used for compiling then.
1369 dnl The "-pthread" is added to $LIBS, so that the following check for
1370 dnl sigaltstack() will look in libc_r (it's there in libc!).
1371 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1372 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1373 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1374 AC_MSG_CHECKING([if -pthread should be used])
1375 threadsafe_flag=
1376 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001377 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001378 if test "$vim_cv_uname_output" != Darwin; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001379 test "$GCC" = yes && threadsafe_flag="-pthread"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001380 if test "$vim_cv_uname_output" = FreeBSD; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001381 threadsafe_flag="-D_THREAD_SAFE"
1382 thread_lib="-pthread"
1383 fi
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001384 if test "$vim_cv_uname_output" = SunOS; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001385 threadsafe_flag="-pthreads"
1386 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001387 fi
1388 libs_save_old=$LIBS
1389 if test -n "$threadsafe_flag"; then
1390 cflags_save=$CFLAGS
1391 CFLAGS="$CFLAGS $threadsafe_flag"
1392 LIBS="$LIBS $thread_lib"
1393 AC_TRY_LINK(,[ ],
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001394 AC_MSG_RESULT(yes); PYTHON_CFLAGS="$PYTHON_CFLAGS $threadsafe_flag",
Bram Moolenaar071d4272004-06-13 20:20:40 +00001395 AC_MSG_RESULT(no); LIBS=$libs_save_old
1396 )
1397 CFLAGS=$cflags_save
1398 else
1399 AC_MSG_RESULT(no)
1400 fi
1401
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001402 dnl Check that compiling a simple program still works with the flags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001403 dnl added for Python.
1404 AC_MSG_CHECKING([if compile and link flags for Python are sane])
1405 cflags_save=$CFLAGS
1406 libs_save=$LIBS
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001407 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001408 LIBS="$LIBS $PYTHON_LIBS"
1409 AC_TRY_LINK(,[ ],
1410 AC_MSG_RESULT(yes); python_ok=yes,
1411 AC_MSG_RESULT(no: PYTHON DISABLED); python_ok=no)
1412 CFLAGS=$cflags_save
1413 LIBS=$libs_save
1414 if test $python_ok = yes; then
1415 AC_DEFINE(FEAT_PYTHON)
1416 else
1417 LIBS=$libs_save_old
1418 PYTHON_SRC=
1419 PYTHON_OBJ=
1420 PYTHON_LIBS=
1421 PYTHON_CFLAGS=
1422 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001423 fi
1424 else
1425 AC_MSG_RESULT(too old)
1426 fi
1427 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001428
1429 if test "$fail_if_missing" = "yes" -a "$python_ok" != "yes"; then
1430 AC_MSG_ERROR([could not configure python])
1431 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001432fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001433
Bram Moolenaar071d4272004-06-13 20:20:40 +00001434AC_SUBST(PYTHON_LIBS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001435AC_SUBST(PYTHON_CFLAGS)
1436AC_SUBST(PYTHON_SRC)
1437AC_SUBST(PYTHON_OBJ)
1438
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001439
1440AC_MSG_CHECKING(--enable-python3interp argument)
1441AC_ARG_ENABLE(python3interp,
Bram Moolenaar8008b632017-07-18 21:33:20 +02001442 [ --enable-python3interp[=OPTS] Include Python3 interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001443 [enable_python3interp="no"])
1444AC_MSG_RESULT($enable_python3interp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001445if test "$enable_python3interp" = "yes" -o "$enable_python3interp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001446 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1447 AC_MSG_ERROR([cannot use Python with tiny or small features])
1448 fi
1449
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001450 dnl -- find the python3 executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001451 AC_MSG_CHECKING(--with-python3-command argument)
1452 AC_SUBST(vi_cv_path_python3)
1453 AC_ARG_WITH(python3-command, [ --with-python3-command=NAME name of the Python 3 command (default: python3 or python)],
1454 vi_cv_path_python3="$withval"; AC_MSG_RESULT($vi_cv_path_python3),
1455 AC_MSG_RESULT(no))
1456
1457 if test "X$vi_cv_path_python3" = "X"; then
1458 AC_PATH_PROGS(vi_cv_path_python3, python3 python)
1459 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001460 if test "X$vi_cv_path_python3" != "X"; then
1461
1462 dnl -- get its version number
1463 AC_CACHE_CHECK(Python version,vi_cv_var_python3_version,
1464 [[vi_cv_var_python3_version=`
Bram Moolenaar23c01922021-05-21 11:43:58 +02001465 ${vi_cv_path_python3} -c 'import sys; print("{}.{}".format(sys.version_info.major, sys.version_info.minor))'`
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001466 ]])
1467
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001468 dnl -- it must be at least version 3
1469 AC_MSG_CHECKING(Python is 3.0 or better)
1470 if ${vi_cv_path_python3} -c \
1471 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.0)"
1472 then
1473 AC_MSG_RESULT(yep)
Bram Moolenaar456f2bb2011-06-12 21:37:13 +02001474
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001475 dnl -- get abiflags for python 3.2 or higher (PEP 3149)
1476 AC_CACHE_CHECK(Python's abiflags,vi_cv_var_python3_abiflags,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001477 [
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001478 vi_cv_var_python3_abiflags=
1479 if ${vi_cv_path_python3} -c \
1480 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)"
1481 then
1482 vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \
1483 "import sys; print(sys.abiflags)"`
1484 fi ])
1485
1486 dnl -- find where python3 thinks it was installed
1487 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx,
1488 [ vi_cv_path_python3_pfx=`
1489 ${vi_cv_path_python3} -c \
1490 "import sys; print(sys.prefix)"` ])
1491
1492 dnl -- and where it thinks it runs
1493 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx,
1494 [ vi_cv_path_python3_epfx=`
1495 ${vi_cv_path_python3} -c \
1496 "import sys; print(sys.exec_prefix)"` ])
1497
1498 dnl -- python3's internal library path
1499
1500 AC_CACHE_VAL(vi_cv_path_python3path,
1501 [ vi_cv_path_python3path=`
1502 unset PYTHONPATH;
1503 ${vi_cv_path_python3} -c \
1504 "import sys, string; print(':'.join(sys.path))"` ])
1505
1506 dnl -- where the Python implementation library archives are
1507
1508 AC_ARG_WITH(python3-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001509 [ --with-python3-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001510 [ vi_cv_path_python3_conf="${withval}"; have_python3_config_dir=1 ] )
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001511
1512 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf,
1513 [
1514 vi_cv_path_python3_conf=
Bram Moolenaarfee496d2013-07-12 20:07:24 +02001515 config_dir="config-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Zdenek Dohnal31e299c2021-06-10 18:50:55 +02001516 d=`${vi_cv_path_python3} -c "import sysconfig; print(sysconfig.get_config_var('LIBPL'))" 2> /dev/null`
1517 if test "x$d" = "x"; then
1518 d=`${vi_cv_path_python3} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBPL'))"`
1519 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001520 if test -d "$d" && test -f "$d/config.c"; then
1521 vi_cv_path_python3_conf="$d"
1522 else
1523 for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do
1524 for subdir in lib64 lib share; do
1525 d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}"
1526 if test -d "$d" && test -f "$d/config.c"; then
1527 vi_cv_path_python3_conf="$d"
1528 fi
1529 done
1530 done
1531 fi
1532 ])
1533
1534 PYTHON3_CONFDIR="${vi_cv_path_python3_conf}"
1535
1536 if test "X$PYTHON3_CONFDIR" = "X"; then
1537 AC_MSG_RESULT([can't find it!])
1538 else
1539
1540 dnl -- we need to examine Python's config/Makefile too
1541 dnl see what the interpreter is built from
1542 AC_CACHE_VAL(vi_cv_path_python3_plibs,
1543 [
1544 pwd=`pwd`
1545 tmp_mkf="$pwd/config-PyMake$$"
1546 cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001547__:
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001548 @echo "python3_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001549 @echo "python3_LIBS='$(LIBS)'"
1550 @echo "python3_SYSLIBS='$(SYSLIBS)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001551 @echo "python3_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001552 @echo "python3_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001553eof
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001554 dnl -- delete the lines from make about Entering/Leaving directory
1555 eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1556 rm -f -- "${tmp_mkf}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001557 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 +02001558 vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}"
1559 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1560 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//`
1561 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//`
1562 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001563 AC_CACHE_CHECK(Python3's dll name,vi_cv_dll_name_python3,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001564 [
1565 if test "X$python3_DLLLIBRARY" != "X"; then
1566 vi_cv_dll_name_python3="$python3_DLLLIBRARY"
1567 else
1568 vi_cv_dll_name_python3="$python3_INSTSONAME"
1569 fi
1570 ])
1571
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001572 PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
1573 if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001574 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 +02001575 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001576 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 +02001577 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001578 if test "X$have_python3_config_dir" = "X1" -a "$enable_python3interp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001579 dnl Define PYTHON3_HOME if --with-python-config-dir was used
1580 PYTHON3_CFLAGS="${PYTHON3_CFLAGS} -DPYTHON3_HOME='L\"${vi_cv_path_python3_pfx}\"'"
1581 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001582 PYTHON3_SRC="if_python3.c"
1583 PYTHON3_OBJ="objects/if_python3.o"
1584
1585 dnl On FreeBSD linking with "-pthread" is required to use threads.
1586 dnl _THREAD_SAFE must be used for compiling then.
1587 dnl The "-pthread" is added to $LIBS, so that the following check for
1588 dnl sigaltstack() will look in libc_r (it's there in libc!).
1589 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1590 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1591 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1592 AC_MSG_CHECKING([if -pthread should be used])
1593 threadsafe_flag=
1594 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001595 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001596 if test "$vim_cv_uname_output" != Darwin; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001597 test "$GCC" = yes && threadsafe_flag="-pthread"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001598 if test "$vim_cv_uname_output" = FreeBSD; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001599 threadsafe_flag="-D_THREAD_SAFE"
1600 thread_lib="-pthread"
1601 fi
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001602 if test "$vim_cv_uname_output" = SunOS; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001603 threadsafe_flag="-pthreads"
1604 fi
1605 fi
1606 libs_save_old=$LIBS
1607 if test -n "$threadsafe_flag"; then
1608 cflags_save=$CFLAGS
1609 CFLAGS="$CFLAGS $threadsafe_flag"
1610 LIBS="$LIBS $thread_lib"
1611 AC_TRY_LINK(,[ ],
1612 AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag",
1613 AC_MSG_RESULT(no); LIBS=$libs_save_old
1614 )
1615 CFLAGS=$cflags_save
1616 else
1617 AC_MSG_RESULT(no)
1618 fi
1619
1620 dnl check that compiling a simple program still works with the flags
1621 dnl added for Python.
1622 AC_MSG_CHECKING([if compile and link flags for Python 3 are sane])
1623 cflags_save=$CFLAGS
1624 libs_save=$LIBS
1625 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1626 LIBS="$LIBS $PYTHON3_LIBS"
1627 AC_TRY_LINK(,[ ],
1628 AC_MSG_RESULT(yes); python3_ok=yes,
1629 AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no)
1630 CFLAGS=$cflags_save
1631 LIBS=$libs_save
1632 if test "$python3_ok" = yes; then
1633 AC_DEFINE(FEAT_PYTHON3)
1634 else
1635 LIBS=$libs_save_old
1636 PYTHON3_SRC=
1637 PYTHON3_OBJ=
1638 PYTHON3_LIBS=
1639 PYTHON3_CFLAGS=
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001640 fi
1641 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001642 else
1643 AC_MSG_RESULT(too old)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001644 fi
1645 fi
Bram Moolenaar1612b1a2013-06-14 21:22:39 +02001646 if test "$fail_if_missing" = "yes" -a "$python3_ok" != "yes"; then
1647 AC_MSG_ERROR([could not configure python3])
1648 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001649fi
1650
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001651AC_SUBST(PYTHON3_LIBS)
1652AC_SUBST(PYTHON3_CFLAGS)
1653AC_SUBST(PYTHON3_SRC)
1654AC_SUBST(PYTHON3_OBJ)
1655
1656dnl if python2.x and python3.x are enabled one can only link in code
1657dnl with dlopen(), dlsym(), dlclose()
1658if test "$python_ok" = yes && test "$python3_ok" = yes; then
1659 AC_DEFINE(DYNAMIC_PYTHON)
1660 AC_DEFINE(DYNAMIC_PYTHON3)
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001661 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001662 cflags_save=$CFLAGS
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001663 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001664 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001665 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001666 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001667 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001668 #include <dlfcn.h>
1669 /* If this program fails, then RTLD_GLOBAL is needed.
1670 * RTLD_GLOBAL will be used and then it is not possible to
1671 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001672 * Only the first python version used will be switched on.
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001673 */
1674
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001675 int no_rtl_global_needed_for(char *python_instsoname, char *prefix)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001676 {
1677 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001678 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001679 if (pylib != 0)
1680 {
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001681 void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome");
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001682 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1683 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1684 void (*final)(void) = dlsym(pylib, "Py_Finalize");
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001685 (*pfx)(prefix);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001686 (*init)();
1687 needed = (*simple)("import termios") == -1;
1688 (*final)();
1689 dlclose(pylib);
1690 }
1691 return !needed;
1692 }
1693
1694 int main(int argc, char** argv)
1695 {
1696 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001697 if (no_rtl_global_needed_for("${vi_cv_dll_name_python}", "${vi_cv_path_python_pfx}"))
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001698 not_needed = 1;
1699 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001700 }])],
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001701 [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001702
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001703 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001704 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001705
1706 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python3)
1707 cflags_save=$CFLAGS
1708 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001709 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001710 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001711 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001712 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001713 #include <dlfcn.h>
1714 #include <wchar.h>
1715 /* If this program fails, then RTLD_GLOBAL is needed.
1716 * RTLD_GLOBAL will be used and then it is not possible to
1717 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001718 * Only the first python version used will be switched on.
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001719 */
1720
1721 int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix)
1722 {
1723 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001724 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001725 if (pylib != 0)
1726 {
1727 void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome");
1728 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1729 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1730 void (*final)(void) = dlsym(pylib, "Py_Finalize");
1731 (*pfx)(prefix);
1732 (*init)();
1733 needed = (*simple)("import termios") == -1;
1734 (*final)();
1735 dlclose(pylib);
1736 }
1737 return !needed;
1738 }
1739
1740 int main(int argc, char** argv)
1741 {
1742 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001743 if (no_rtl_global_needed_for("${vi_cv_dll_name_python3}", L"${vi_cv_path_python3_pfx}"))
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001744 not_needed = 1;
1745 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001746 }])],
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001747 [AC_MSG_RESULT(yes);AC_DEFINE(PY3_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
1748
1749 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001750 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001751
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001752 PYTHON_SRC="if_python.c"
1753 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001754 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001755 PYTHON_LIBS=
1756 PYTHON3_SRC="if_python3.c"
1757 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001758 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001759 PYTHON3_LIBS=
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001760elif test "$python_ok" = yes && test "$enable_pythoninterp" = "dynamic"; then
1761 AC_DEFINE(DYNAMIC_PYTHON)
1762 PYTHON_SRC="if_python.c"
1763 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001764 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001765 PYTHON_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001766elif test "$python_ok" = yes; then
1767 dnl Check that adding -fPIE works. It may be needed when using a static
1768 dnl Python library.
1769 AC_MSG_CHECKING([if -fPIE can be added for Python])
1770 cflags_save=$CFLAGS
1771 libs_save=$LIBS
1772 CFLAGS="$CFLAGS $PYTHON_CFLAGS -fPIE"
1773 LIBS="$LIBS $PYTHON_LIBS"
1774 AC_TRY_LINK(,[ ],
1775 AC_MSG_RESULT(yes); fpie_ok=yes,
1776 AC_MSG_RESULT(no); fpie_ok=no)
1777 CFLAGS=$cflags_save
1778 LIBS=$libs_save
1779 if test $fpie_ok = yes; then
1780 PYTHON_CFLAGS="$PYTHON_CFLAGS -fPIE"
1781 fi
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001782elif test "$python3_ok" = yes && test "$enable_python3interp" = "dynamic"; then
1783 AC_DEFINE(DYNAMIC_PYTHON3)
1784 PYTHON3_SRC="if_python3.c"
1785 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001786 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001787 PYTHON3_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001788elif test "$python3_ok" = yes; then
1789 dnl Check that adding -fPIE works. It may be needed when using a static
1790 dnl Python library.
1791 AC_MSG_CHECKING([if -fPIE can be added for Python3])
1792 cflags_save=$CFLAGS
1793 libs_save=$LIBS
1794 CFLAGS="$CFLAGS $PYTHON3_CFLAGS -fPIE"
1795 LIBS="$LIBS $PYTHON3_LIBS"
1796 AC_TRY_LINK(,[ ],
1797 AC_MSG_RESULT(yes); fpie_ok=yes,
1798 AC_MSG_RESULT(no); fpie_ok=no)
1799 CFLAGS=$cflags_save
1800 LIBS=$libs_save
1801 if test $fpie_ok = yes; then
1802 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -fPIE"
1803 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001804fi
1805
Bram Moolenaar071d4272004-06-13 20:20:40 +00001806AC_MSG_CHECKING(--enable-tclinterp argument)
1807AC_ARG_ENABLE(tclinterp,
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001808 [ --enable-tclinterp[=OPTS] Include Tcl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001809 [enable_tclinterp="no"])
1810AC_MSG_RESULT($enable_tclinterp)
1811
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001812if test "$enable_tclinterp" = "yes" -o "$enable_tclinterp" = "dynamic"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001813
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001814 dnl on FreeBSD tclsh is a silly script, look for tclsh8.[5420]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001815 AC_MSG_CHECKING(--with-tclsh argument)
1816 AC_ARG_WITH(tclsh, [ --with-tclsh=PATH which tclsh to use (default: tclsh8.0)],
1817 tclsh_name="$withval"; AC_MSG_RESULT($tclsh_name),
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001818 tclsh_name="tclsh8.5"; AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00001819 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1820 AC_SUBST(vi_cv_path_tcl)
1821
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001822 dnl when no specific version specified, also try 8.4, 8.2 and 8.0
1823 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.5"; then
1824 tclsh_name="tclsh8.4"
1825 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1826 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001827 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.4"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001828 tclsh_name="tclsh8.2"
1829 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1830 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001831 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.2"; then
1832 tclsh_name="tclsh8.0"
1833 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1834 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001835 dnl still didn't find it, try without version number
1836 if test "X$vi_cv_path_tcl" = "X"; then
1837 tclsh_name="tclsh"
1838 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1839 fi
1840 if test "X$vi_cv_path_tcl" != "X"; then
1841 AC_MSG_CHECKING(Tcl version)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001842 if echo 'exit [[expr [info tclversion] < 8.0]]' | "$vi_cv_path_tcl" - ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001843 tclver=`echo 'puts [[info tclversion]]' | $vi_cv_path_tcl -`
1844 AC_MSG_RESULT($tclver - OK);
1845 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 +01001846 tcldll=`echo 'puts libtcl[[info tclversion]][[info sharedlibextension]]' | $vi_cv_path_tcl -`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001847
1848 AC_MSG_CHECKING(for location of Tcl include)
Bram Moolenaard0573012017-10-28 21:11:06 +02001849 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001850 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 +00001851 else
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001852 dnl For all macOS, use the value from TCL in case use of, say, homebrew
Bram Moolenaar071d4272004-06-13 20:20:40 +00001853 dnl For Mac OS X 10.3, use the OS-provided framework location
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001854 dnl For Mac OS X 10.14, the OS-provided framework location doesn't contain the headers, so also check the Xcode SDK
1855 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 +00001856 fi
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001857 TCL_INC=
Bram Moolenaar071d4272004-06-13 20:20:40 +00001858 for try in $tclinc; do
1859 if test -f "$try/tcl.h"; then
1860 AC_MSG_RESULT($try/tcl.h)
1861 TCL_INC=$try
1862 break
1863 fi
1864 done
1865 if test -z "$TCL_INC"; then
1866 AC_MSG_RESULT(<not found>)
1867 SKIP_TCL=YES
1868 fi
1869 if test -z "$SKIP_TCL"; then
1870 AC_MSG_CHECKING(for location of tclConfig.sh script)
Bram Moolenaard0573012017-10-28 21:11:06 +02001871 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001872 tclcnf=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001873 tclcnf="$tclcnf `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001874 else
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001875 dnl For all macOS, use the value from TCL in case use of, say, homebrew
Bram Moolenaar071d4272004-06-13 20:20:40 +00001876 dnl For Mac OS X 10.3, use the OS-provided framework location
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001877 dnl For Mac OS X 10.14, the OS-provided framework location doesn't contain the headers, so also check the Xcode SDK
1878 tclcnf=`echo $tclinc | sed s/include/lib/g`
1879 tclcnf="$tclcnf /System/Library/Frameworks/Tcl.framework `xcrun --show-sdk-path`/System/Library/Frameworks/Tcl.framework"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001880 fi
1881 for try in $tclcnf; do
Bram Moolenaar49222be2015-12-11 18:11:30 +01001882 if test -f "$try/tclConfig.sh"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001883 AC_MSG_RESULT($try/tclConfig.sh)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001884 . "$try/tclConfig.sh"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001885 dnl use eval, because tcl 8.2 includes ${TCL_DBGX}
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001886 if test "$enable_tclinterp" = "dynamic"; then
1887 TCL_LIBS=`eval echo "$TCL_STUB_LIB_SPEC $TCL_LIBS"`
1888 else
1889 TCL_LIBS=`eval echo "$TCL_LIB_SPEC $TCL_LIBS"`
1890 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001891 dnl Use $TCL_DEFS for -D_THREAD_SAFE et al. But only use the
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001892 dnl "-D_ABC" items. Watch out for -DFOO=long\ long.
Bram Moolenaar4394bff2008-07-24 11:21:31 +00001893 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 +00001894 break
1895 fi
1896 done
1897 if test -z "$TCL_LIBS"; then
1898 AC_MSG_RESULT(<not found>)
1899 AC_MSG_CHECKING(for Tcl library by myself)
1900 tcllib=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001901 tcllib="$tcllib `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001902 for ext in .so .a ; do
1903 for ver in "" $tclver ; do
1904 for try in $tcllib ; do
1905 trylib=tcl$ver$ext
Bram Moolenaar49222be2015-12-11 18:11:30 +01001906 if test -f "$try/lib$trylib" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001907 AC_MSG_RESULT($try/lib$trylib)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001908 TCL_LIBS="-L\"$try\" -ltcl$ver -ldl -lm"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001909 if test "$vim_cv_uname_output" = SunOS &&
1910 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001911 TCL_LIBS="$TCL_LIBS -R $try"
1912 fi
1913 break 3
1914 fi
1915 done
1916 done
1917 done
1918 if test -z "$TCL_LIBS"; then
1919 AC_MSG_RESULT(<not found>)
1920 SKIP_TCL=YES
1921 fi
1922 fi
1923 if test -z "$SKIP_TCL"; then
1924 AC_DEFINE(FEAT_TCL)
1925 TCL_SRC=if_tcl.c
1926 TCL_OBJ=objects/if_tcl.o
1927 TCL_PRO=if_tcl.pro
1928 TCL_CFLAGS="-I$TCL_INC $TCL_DEFS"
1929 fi
1930 fi
1931 else
1932 AC_MSG_RESULT(too old; need Tcl version 8.0 or later)
1933 fi
1934 fi
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001935 if test "$enable_tclinterp" = "dynamic"; then
1936 if test "X$TCL_SRC" != "X" -a "X$tcldll" != "X"; then
1937 AC_DEFINE(DYNAMIC_TCL)
1938 TCL_CFLAGS="-DDYNAMIC_TCL_DLL=\\\"$tcldll\\\" -DDYNAMIC_TCL_VER=\\\"$tclver\\\" $TCL_CFLAGS"
1939 fi
1940 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001941 if test "$fail_if_missing" = "yes" -a -z "$TCL_SRC"; then
1942 AC_MSG_ERROR([could not configure Tcl])
1943 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001944fi
1945AC_SUBST(TCL_SRC)
1946AC_SUBST(TCL_OBJ)
1947AC_SUBST(TCL_PRO)
1948AC_SUBST(TCL_CFLAGS)
1949AC_SUBST(TCL_LIBS)
1950
1951AC_MSG_CHECKING(--enable-rubyinterp argument)
1952AC_ARG_ENABLE(rubyinterp,
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001953 [ --enable-rubyinterp[=OPTS] Include Ruby interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001954 [enable_rubyinterp="no"])
1955AC_MSG_RESULT($enable_rubyinterp)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001956if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001957 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1958 AC_MSG_ERROR([cannot use Ruby with tiny or small features])
1959 fi
1960
Bram Moolenaar165641d2010-02-17 16:23:09 +01001961 AC_MSG_CHECKING(--with-ruby-command argument)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001962 AC_SUBST(vi_cv_path_ruby)
Bram Moolenaar948733a2011-05-05 18:10:16 +02001963 AC_ARG_WITH(ruby-command, [ --with-ruby-command=RUBY name of the Ruby command (default: ruby)],
1964 RUBY_CMD="$withval"; vi_cv_path_ruby="$withval"; AC_MSG_RESULT($RUBY_CMD),
1965 RUBY_CMD="ruby"; AC_MSG_RESULT(defaulting to $RUBY_CMD))
Bram Moolenaar165641d2010-02-17 16:23:09 +01001966 AC_PATH_PROG(vi_cv_path_ruby, $RUBY_CMD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001967 if test "X$vi_cv_path_ruby" != "X"; then
1968 AC_MSG_CHECKING(Ruby version)
Bram Moolenaare4efc3b2005-03-07 23:16:51 +00001969 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 +00001970 AC_MSG_RESULT(OK)
Bram Moolenaar81398892012-10-03 21:09:35 +02001971 AC_MSG_CHECKING(Ruby rbconfig)
1972 ruby_rbconfig="RbConfig"
1973 if ! $vi_cv_path_ruby -r rbconfig -e 'RbConfig' >/dev/null 2>/dev/null; then
1974 ruby_rbconfig="Config"
1975 fi
1976 AC_MSG_RESULT($ruby_rbconfig)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001977 AC_MSG_CHECKING(Ruby header files)
Bram Moolenaar81398892012-10-03 21:09:35 +02001978 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 +00001979 if test "X$rubyhdrdir" != "X"; then
1980 AC_MSG_RESULT($rubyhdrdir)
1981 RUBY_CFLAGS="-I$rubyhdrdir"
Bram Moolenaara6fd37b2014-03-27 17:19:09 +01001982 rubyarchdir=`$vi_cv_path_ruby -r rbconfig -e "print ($ruby_rbconfig::CONFIG.has_key? 'rubyarchhdrdir') ? $ruby_rbconfig::CONFIG[['rubyarchhdrdir']] : '$rubyhdrdir/'+$ruby_rbconfig::CONFIG[['arch']]"`
1983 if test -d "$rubyarchdir"; then
1984 RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyarchdir"
Bram Moolenaar165641d2010-02-17 16:23:09 +01001985 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001986 rubyversion=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['ruby_version']].gsub(/\./, '')[[0,2]]"`
Bram Moolenaar026a4452013-08-07 15:22:23 +02001987 if test "X$rubyversion" = "X"; then
1988 rubyversion=`$vi_cv_path_ruby -e "print ((VERSION rescue RUBY_VERSION)).gsub(/\./, '')[[0,2]]"`
1989 fi
Bram Moolenaar165641d2010-02-17 16:23:09 +01001990 RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
Bram Moolenaar81398892012-10-03 21:09:35 +02001991 rubylibs=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LIBS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001992 if test "X$rubylibs" != "X"; then
1993 RUBY_LIBS="$rubylibs"
1994 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001995 librubyarg=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBYARG']])"`
1996 librubya=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBY_A']])"`
Bram Moolenaarac499e32013-06-02 19:14:17 +02001997 rubylibdir=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['libdir']])"`
Bram Moolenaard5a986f2020-12-06 21:11:31 +01001998 if test -f "$rubylibdir/$librubya" || expr "$librubyarg" : "-lruby"; then
Bram Moolenaarac499e32013-06-02 19:14:17 +02001999 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
2000 elif test "$librubyarg" = "libruby.a"; then
2001 dnl required on Mac OS 10.3 where libruby.a doesn't exist
2002 librubyarg="-lruby"
2003 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002004 fi
2005
2006 if test "X$librubyarg" != "X"; then
2007 RUBY_LIBS="$librubyarg $RUBY_LIBS"
2008 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02002009 rubyldflags=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LDFLAGS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002010 if test "X$rubyldflags" != "X"; then
Bram Moolenaar996b6d82009-07-22 09:17:23 +00002011 dnl Ruby on Mac OS X 10.5 adds "-arch" flags but these should only
2012 dnl be included if requested by passing --with-mac-arch to
2013 dnl configure, so strip these flags first (if present)
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02002014 rubyldflags=`echo "$rubyldflags" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
Bram Moolenaar996b6d82009-07-22 09:17:23 +00002015 if test "X$rubyldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01002016 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$rubyldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02002017 LDFLAGS="$rubyldflags $LDFLAGS"
2018 fi
Bram Moolenaar996b6d82009-07-22 09:17:23 +00002019 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002020 fi
2021 RUBY_SRC="if_ruby.c"
2022 RUBY_OBJ="objects/if_ruby.o"
2023 RUBY_PRO="if_ruby.pro"
2024 AC_DEFINE(FEAT_RUBY)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002025 if test "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar92021622017-10-12 12:33:43 +02002026 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_ALIASES']].split[[0]]"`
Bram Moolenaar87ea64c2018-08-04 15:13:34 +02002027 if test -z "$libruby_soname"; then
2028 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_SO']]"`
2029 fi
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002030 AC_DEFINE(DYNAMIC_RUBY)
Bram Moolenaar41a41412020-01-07 21:32:19 +01002031 RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby_soname\\\" $RUBY_CFLAGS"
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002032 RUBY_LIBS=
2033 fi
Bram Moolenaar864a28b2020-12-28 21:36:56 +01002034 if test "X$CLANG_VERSION" != "X" -a "$rubyversion" -ge 30; then
2035 RUBY_CFLAGS="$RUBY_CFLAGS -fdeclspec"
2036 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002037 else
Bram Moolenaar165641d2010-02-17 16:23:09 +01002038 AC_MSG_RESULT(not found; disabling Ruby)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002039 fi
2040 else
2041 AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
2042 fi
2043 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01002044
2045 if test "$fail_if_missing" = "yes" -a -z "$RUBY_OBJ"; then
2046 AC_MSG_ERROR([could not configure Ruby])
2047 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002048fi
2049AC_SUBST(RUBY_SRC)
2050AC_SUBST(RUBY_OBJ)
2051AC_SUBST(RUBY_PRO)
2052AC_SUBST(RUBY_CFLAGS)
2053AC_SUBST(RUBY_LIBS)
2054
2055AC_MSG_CHECKING(--enable-cscope argument)
2056AC_ARG_ENABLE(cscope,
2057 [ --enable-cscope Include cscope interface.], ,
2058 [enable_cscope="no"])
2059AC_MSG_RESULT($enable_cscope)
2060if test "$enable_cscope" = "yes"; then
2061 AC_DEFINE(FEAT_CSCOPE)
2062fi
2063
Bram Moolenaar071d4272004-06-13 20:20:40 +00002064AC_MSG_CHECKING(--disable-netbeans argument)
2065AC_ARG_ENABLE(netbeans,
2066 [ --disable-netbeans Disable NetBeans integration support.],
2067 , [enable_netbeans="yes"])
2068if test "$enable_netbeans" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002069 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2070 AC_MSG_RESULT([cannot use NetBeans with tiny or small features])
2071 enable_netbeans="no"
2072 else
2073 AC_MSG_RESULT(no)
2074 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002075else
2076 AC_MSG_RESULT(yes)
2077fi
2078
2079AC_MSG_CHECKING(--disable-channel argument)
2080AC_ARG_ENABLE(channel,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002081 [ --disable-channel Disable process communication support.],
Bram Moolenaare0874f82016-01-24 20:36:41 +01002082 , [enable_channel="yes"])
2083if test "$enable_channel" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002084 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2085 AC_MSG_RESULT([cannot use channels with tiny or small features])
2086 enable_channel="no"
2087 else
2088 AC_MSG_RESULT(no)
2089 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002090else
2091 if test "$enable_netbeans" = "yes"; then
Bram Moolenaar16435482016-01-24 21:31:54 +01002092 AC_MSG_RESULT([yes, netbeans also disabled])
Bram Moolenaare0874f82016-01-24 20:36:41 +01002093 enable_netbeans="no"
2094 else
2095 AC_MSG_RESULT(yes)
2096 fi
2097fi
2098
Bram Moolenaar16435482016-01-24 21:31:54 +01002099if test "$enable_channel" = "yes"; then
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002100 dnl On Solaris we need the socket library, or on Haiku the network library.
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002101 if test "x$HAIKU" = "xyes"; then
2102 AC_CHECK_LIB(network, socket)
2103 else
2104 AC_CHECK_LIB(socket, socket)
2105 fi
2106
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002107 AC_CACHE_CHECK([whether compiling with IPv6 networking is possible], [vim_cv_ipv6_networking],
2108 [AC_TRY_LINK([
2109#include <stdio.h>
2110#include <stdlib.h>
2111#include <stdarg.h>
2112#include <fcntl.h>
2113#include <netdb.h>
2114#include <netinet/in.h>
2115#include <errno.h>
2116#include <sys/types.h>
2117#include <sys/socket.h>
2118 /* Check bitfields */
2119 struct nbbuf {
2120 unsigned int initDone:1;
2121 unsigned short signmaplen;
2122 };
2123 ], [
2124 /* Check creating a socket. */
2125 struct sockaddr_in server;
2126 struct addrinfo *res;
2127 (void)socket(AF_INET, SOCK_STREAM, 0);
2128 (void)htons(100);
2129 (void)getaddrinfo("microsoft.com", NULL, NULL, &res);
2130 if (errno == ECONNREFUSED)
2131 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
2132 (void)freeaddrinfo(res);
2133 ],
2134 [vim_cv_ipv6_networking="yes"],
2135 [vim_cv_ipv6_networking="no"])])
2136
2137 if test "x$vim_cv_ipv6_networking" = "xyes"; then
2138 AC_DEFINE(FEAT_IPV6)
Bram Moolenaarb6fb0512020-04-18 18:24:18 +02002139 AC_CHECK_FUNCS(inet_ntop)
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002140 else
2141 dnl On Solaris we need the nsl library.
2142 AC_CHECK_LIB(nsl, gethostbyname)
2143 AC_CACHE_CHECK([whether compiling with IPv4 networking is possible], [vim_cv_ipv4_networking],
2144 [AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00002145#include <stdio.h>
2146#include <stdlib.h>
2147#include <stdarg.h>
2148#include <fcntl.h>
2149#include <netdb.h>
2150#include <netinet/in.h>
2151#include <errno.h>
2152#include <sys/types.h>
2153#include <sys/socket.h>
2154 /* Check bitfields */
2155 struct nbbuf {
2156 unsigned int initDone:1;
Bram Moolenaar63de19e2016-12-09 20:11:26 +01002157 unsigned short signmaplen;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002158 };
2159 ], [
2160 /* Check creating a socket. */
2161 struct sockaddr_in server;
2162 (void)socket(AF_INET, SOCK_STREAM, 0);
2163 (void)htons(100);
2164 (void)gethostbyname("microsoft.com");
2165 if (errno == ECONNREFUSED)
2166 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
2167 ],
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002168 [vim_cv_ipv4_networking="yes"],
2169 [vim_cv_ipv4_networking="no"; enable_netbeans="no"; enable_channel="no"])])
2170 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002171fi
2172if test "$enable_netbeans" = "yes"; then
2173 AC_DEFINE(FEAT_NETBEANS_INTG)
2174 NETBEANS_SRC="netbeans.c"
2175 AC_SUBST(NETBEANS_SRC)
2176 NETBEANS_OBJ="objects/netbeans.o"
2177 AC_SUBST(NETBEANS_OBJ)
2178fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002179if test "$enable_channel" = "yes"; then
Bram Moolenaar509ce2a2016-03-11 22:52:15 +01002180 AC_DEFINE(FEAT_JOB_CHANNEL)
Bram Moolenaar8b5866d2020-09-05 15:48:51 +02002181 CHANNEL_SRC="job.c channel.c"
Bram Moolenaare0874f82016-01-24 20:36:41 +01002182 AC_SUBST(CHANNEL_SRC)
Bram Moolenaar8b5866d2020-09-05 15:48:51 +02002183 CHANNEL_OBJ="objects/job.o objects/channel.o"
Bram Moolenaare0874f82016-01-24 20:36:41 +01002184 AC_SUBST(CHANNEL_OBJ)
2185fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002186
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002187AC_MSG_CHECKING(--enable-terminal argument)
2188AC_ARG_ENABLE(terminal,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002189 [ --enable-terminal Enable terminal emulation support.],
Bram Moolenaaref839562017-10-28 20:28:23 +02002190 , [enable_terminal="auto"])
Bram Moolenaar595a4022017-09-03 19:15:57 +02002191if test "$enable_terminal" = "yes" || test "$enable_terminal" = "auto" -a "x$features" = "xhuge" ; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002192 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2193 AC_MSG_RESULT([cannot use terminal emulator with tiny or small features])
2194 enable_terminal="no"
2195 else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002196 if test "$enable_terminal" = "auto"; then
2197 enable_terminal="yes"
2198 AC_MSG_RESULT(defaulting to yes)
2199 else
2200 AC_MSG_RESULT(yes)
2201 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002202 fi
2203else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002204 if test "$enable_terminal" = "auto"; then
2205 enable_terminal="no"
2206 AC_MSG_RESULT(defaulting to no)
2207 else
2208 AC_MSG_RESULT(no)
2209 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002210fi
Bram Moolenaar8b423282017-12-16 14:37:06 +01002211if test "$enable_terminal" = "yes" -a "$enable_channel" = "yes"; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002212 AC_DEFINE(FEAT_TERMINAL)
Bram Moolenaar93268052019-10-10 13:22:54 +02002213 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 +02002214 AC_SUBST(TERM_SRC)
Bram Moolenaar93268052019-10-10 13:22:54 +02002215 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 +02002216 AC_SUBST(TERM_OBJ)
Bram Moolenaar823edd12019-10-23 22:35:36 +02002217 TERM_TEST="test_libvterm"
2218 AC_SUBST(TERM_TEST)
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002219fi
2220
Bram Moolenaare42a6d22017-11-12 19:21:51 +01002221AC_MSG_CHECKING(--enable-autoservername argument)
2222AC_ARG_ENABLE(autoservername,
2223 [ --enable-autoservername Automatically define servername at vim startup.], ,
2224 [enable_autoservername="no"])
2225AC_MSG_RESULT($enable_autoservername)
2226if test "$enable_autoservername" = "yes"; then
2227 AC_DEFINE(FEAT_AUTOSERVERNAME)
2228fi
2229
Bram Moolenaar071d4272004-06-13 20:20:40 +00002230AC_MSG_CHECKING(--enable-multibyte argument)
2231AC_ARG_ENABLE(multibyte,
2232 [ --enable-multibyte Include multibyte editing support.], ,
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01002233 [enable_multibyte="yes"])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002234AC_MSG_RESULT($enable_multibyte)
Bram Moolenaar30276f22019-01-24 17:59:39 +01002235if test "$enable_multibyte" != "yes"; then
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01002236 AC_MSG_ERROR([The multi-byte feature can no longer be disabled. If you have
2237 a problem with this, discuss on the Vim mailing list.])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002238fi
2239
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002240dnl Right-to-Left language support for Vim will be included with big features,
2241dnl unless ENABLE_RIGHTLEFT is undefined.
2242AC_MSG_CHECKING(--disable-rightleft argument)
2243AC_ARG_ENABLE(rightleft,
2244 [ --disable-rightleft Do not include Right-to-Left language support.],
2245 , [enable_rightleft="yes"])
2246if test "$enable_rightleft" = "yes"; then
2247 AC_MSG_RESULT(no)
2248else
2249 AC_MSG_RESULT(yes)
2250 AC_DEFINE(DISABLE_RIGHTLEFT)
2251fi
2252
2253dnl Arabic language support for Vim will be included with big features,
2254dnl unless ENABLE_ARABIC is undefined.
2255AC_MSG_CHECKING(--disable-arabic argument)
2256AC_ARG_ENABLE(arabic,
2257 [ --disable-arabic Do not include Arabic language support.],
2258 , [enable_arabic="yes"])
2259if test "$enable_arabic" = "yes"; then
2260 AC_MSG_RESULT(no)
2261else
2262 AC_MSG_RESULT(yes)
2263 AC_DEFINE(DISABLE_ARABIC)
2264fi
2265
Bram Moolenaar14184a32019-02-16 15:10:30 +01002266dnl Farsi language support has been removed, ignore --disable-farsi
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002267AC_ARG_ENABLE(farsi,
Bram Moolenaar14184a32019-02-16 15:10:30 +01002268 [ --disable-farsi Deprecated.],,)
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002269
Bram Moolenaar071d4272004-06-13 20:20:40 +00002270AC_MSG_CHECKING(--enable-xim argument)
2271AC_ARG_ENABLE(xim,
2272 [ --enable-xim Include XIM input support.],
2273 AC_MSG_RESULT($enable_xim),
2274 [enable_xim="auto"; AC_MSG_RESULT(defaulting to auto)])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002275
2276AC_MSG_CHECKING(--enable-fontset argument)
2277AC_ARG_ENABLE(fontset,
2278 [ --enable-fontset Include X fontset output support.], ,
2279 [enable_fontset="no"])
2280AC_MSG_RESULT($enable_fontset)
2281dnl defining FEAT_XFONTSET is delayed, so that it can be disabled for no GUI
2282
2283test -z "$with_x" && with_x=yes
Bram Moolenaard0573012017-10-28 21:11:06 +02002284test "${enable_gui-yes}" != no -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && with_x=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002285if test "$with_x" = no; then
2286 AC_MSG_RESULT(defaulting to: don't HAVE_X11)
2287else
2288 dnl Do this check early, so that its failure can override user requests.
2289
2290 AC_PATH_PROG(xmkmfpath, xmkmf)
2291
2292 AC_PATH_XTRA
2293
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002294 dnl On z/OS Unix the X libraries are DLLs. To use them the code must
Bram Moolenaar071d4272004-06-13 20:20:40 +00002295 dnl be compiled with a special option.
2296 dnl Also add SM, ICE and Xmu to X_EXTRA_LIBS.
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002297 if test "$zOSUnix" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002298 CFLAGS="$CFLAGS -W c,dll"
2299 LDFLAGS="$LDFLAGS -W l,dll"
2300 X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE -lXmu"
2301 fi
2302
2303 dnl On my HPUX system the X include dir is found, but the lib dir not.
Bram Moolenaar70778922020-02-05 20:44:24 +01002304 dnl This is a desperate try to fix this.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002305
2306 if test -d "$x_includes" && test ! -d "$x_libraries"; then
2307 x_libraries=`echo "$x_includes" | sed s/include/lib/`
2308 AC_MSG_RESULT(Corrected X libraries to $x_libraries)
2309 X_LIBS="$X_LIBS -L$x_libraries"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00002310 if test "$vim_cv_uname_output" = SunOS &&
2311 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002312 X_LIBS="$X_LIBS -R $x_libraries"
2313 fi
2314 fi
2315
2316 if test -d "$x_libraries" && test ! -d "$x_includes"; then
2317 x_includes=`echo "$x_libraries" | sed s/lib/include/`
2318 AC_MSG_RESULT(Corrected X includes to $x_includes)
2319 X_CFLAGS="$X_CFLAGS -I$x_includes"
2320 fi
2321
2322 dnl Remove "-I/usr/include " from X_CFLAGS, should not be needed.
2323 X_CFLAGS="`echo $X_CFLAGS\ | sed 's%-I/usr/include %%'`"
2324 dnl Remove "-L/usr/lib " from X_LIBS, should not be needed.
2325 X_LIBS="`echo $X_LIBS\ | sed 's%-L/usr/lib %%'`"
2326 dnl Same for "-R/usr/lib ".
2327 X_LIBS="`echo $X_LIBS\ | sed -e 's%-R/usr/lib %%' -e 's%-R /usr/lib %%'`"
2328
2329
2330 dnl Check if the X11 header files are correctly installed. On some systems
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002331 dnl Xlib.h includes files that don't exist. On some systems X11/Intrinsic.h
2332 dnl is missing.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002333 AC_MSG_CHECKING(if X11 header files can be found)
2334 cflags_save=$CFLAGS
2335 CFLAGS="$CFLAGS $X_CFLAGS"
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002336 AC_TRY_COMPILE([#include <X11/Xlib.h>
2337#include <X11/Intrinsic.h>], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002338 AC_MSG_RESULT(yes),
2339 AC_MSG_RESULT(no); no_x=yes)
2340 CFLAGS=$cflags_save
2341
2342 if test "${no_x-no}" = yes; then
2343 with_x=no
2344 else
2345 AC_DEFINE(HAVE_X11)
2346 X_LIB="-lXt -lX11";
2347 AC_SUBST(X_LIB)
2348
2349 ac_save_LDFLAGS="$LDFLAGS"
2350 LDFLAGS="-L$x_libraries $LDFLAGS"
2351
2352 dnl Check for -lXdmcp (needed on SunOS 4.1.4)
2353 dnl For HP-UX 10.20 it must be before -lSM -lICE
2354 AC_CHECK_LIB(Xdmcp, _XdmcpAuthDoIt, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lXdmcp"],,
2355 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXdmcp])
2356
2357 dnl Some systems need -lnsl -lsocket when testing for ICE.
2358 dnl The check above doesn't do this, try here (again). Also needed to get
2359 dnl them after Xdmcp. link.sh will remove them when not needed.
2360 dnl Check for other function than above to avoid the cached value
2361 AC_CHECK_LIB(ICE, IceOpenConnection,
2362 [X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE"],, [$X_EXTRA_LIBS])
2363
2364 dnl Check for -lXpm (needed for some versions of Motif)
2365 LDFLAGS="$X_LIBS $ac_save_LDFLAGS"
2366 AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [X_PRE_LIBS="$X_PRE_LIBS -lXpm"],,
2367 [-lXt $X_PRE_LIBS -lXpm -lX11 $X_EXTRA_LIBS])
2368
2369 dnl Check that the X11 header files don't use implicit declarations
2370 AC_MSG_CHECKING(if X11 header files implicitly declare return values)
2371 cflags_save=$CFLAGS
Bram Moolenaard1864592013-05-04 04:40:15 +02002372 dnl -Werror is GCC only, others like Solaris Studio might not like it
2373 if test "$GCC" = yes; then
2374 CFLAGS="$CFLAGS $X_CFLAGS -Werror"
2375 else
2376 CFLAGS="$CFLAGS $X_CFLAGS"
2377 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002378 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2379 AC_MSG_RESULT(no),
2380 CFLAGS="$CFLAGS -Wno-implicit-int"
2381 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2382 AC_MSG_RESULT(yes); cflags_save="$cflags_save -Wno-implicit-int",
2383 AC_MSG_RESULT(test failed)
2384 )
2385 )
2386 CFLAGS=$cflags_save
2387
2388 LDFLAGS="$ac_save_LDFLAGS"
2389
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002390 AC_MSG_CHECKING(size of wchar_t is 2 bytes)
2391 AC_CACHE_VAL(ac_cv_small_wchar_t,
2392 [AC_TRY_RUN([
2393#include <X11/Xlib.h>
2394#if STDC_HEADERS
2395# include <stdlib.h>
2396# include <stddef.h>
2397#endif
2398 main()
2399 {
2400 if (sizeof(wchar_t) <= 2)
2401 exit(1);
2402 exit(0);
2403 }],
2404 ac_cv_small_wchar_t="no",
2405 ac_cv_small_wchar_t="yes",
2406 AC_MSG_ERROR(failed to compile test program))])
2407 AC_MSG_RESULT($ac_cv_small_wchar_t)
2408 if test "x$ac_cv_small_wchar_t" = "xyes" ; then
2409 AC_DEFINE(SMALL_WCHAR_T)
2410 fi
2411
Bram Moolenaar071d4272004-06-13 20:20:40 +00002412 fi
2413fi
2414
Bram Moolenaard2a05492018-07-27 22:35:15 +02002415dnl Check if --with-x was given but it doesn't work.
2416if test "x$with_x" = xno -a "x$with_x_arg" = xyes; then
2417 AC_MSG_ERROR([could not configure X])
2418fi
2419
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002420test "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 +00002421
2422AC_MSG_CHECKING(--enable-gui argument)
2423AC_ARG_ENABLE(gui,
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002424 [ --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 +00002425
2426dnl Canonicalize the --enable-gui= argument so that it can be easily compared.
2427dnl Do not use character classes for portability with old tools.
2428enable_gui_canon=`echo "_$enable_gui" | \
2429 sed 's/[[ _+-]]//g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
2430
2431dnl Skip everything by default.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002432SKIP_GTK2=YES
Bram Moolenaar1858a842016-02-23 22:30:31 +01002433SKIP_GTK3=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002434SKIP_GNOME=YES
2435SKIP_MOTIF=YES
2436SKIP_ATHENA=YES
2437SKIP_NEXTAW=YES
2438SKIP_PHOTON=YES
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002439SKIP_HAIKU=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002440GUITYPE=NONE
2441
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002442if test "x$HAIKU" = "xyes"; then
2443 SKIP_HAIKU=
2444 case "$enable_gui_canon" in
2445 no) AC_MSG_RESULT(no GUI support)
2446 SKIP_HAIKU=YES ;;
2447 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
2448 auto) AC_MSG_RESULT(auto - automatic GUI support) ;;
2449 haiku) AC_MSG_RESULT(Haiku GUI support) ;;
2450 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2451 SKIP_HAIKU=YES ;;
2452 esac
2453elif test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002454 SKIP_PHOTON=
2455 case "$enable_gui_canon" in
2456 no) AC_MSG_RESULT(no GUI support)
2457 SKIP_PHOTON=YES ;;
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002458 yes|""|auto) AC_MSG_RESULT(automatic GUI support)
2459 gui_auto=yes ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002460 photon) AC_MSG_RESULT(Photon GUI support) ;;
2461 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2462 SKIP_PHOTON=YES ;;
2463 esac
2464
Bram Moolenaar040f9752020-08-11 23:08:48 +02002465elif test "x$MACOS_X" = "xyes" -a "x$with_x" = "xno" ; then
2466 case "$enable_gui_canon" in
2467 no) AC_MSG_RESULT(no GUI support) ;;
2468 yes|"") AC_MSG_RESULT(yes - automatic GUI support)
2469 gui_auto=yes ;;
2470 auto) AC_MSG_RESULT(auto - disable GUI support for Mac OS) ;;
Bram Moolenaarbe7529e2020-08-13 21:05:39 +02002471 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
Bram Moolenaar040f9752020-08-11 23:08:48 +02002472 esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00002473else
2474
Bram Moolenaar071d4272004-06-13 20:20:40 +00002475 case "$enable_gui_canon" in
2476 no|none) AC_MSG_RESULT(no GUI support) ;;
2477 yes|""|auto) AC_MSG_RESULT(yes/auto - automatic GUI support)
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002478 gui_auto=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002479 SKIP_GTK2=
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002480 SKIP_GTK3=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002481 SKIP_GNOME=
2482 SKIP_MOTIF=
2483 SKIP_ATHENA=
Bram Moolenaar097148e2020-08-11 21:58:20 +02002484 SKIP_NEXTAW=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002485 gtk2) AC_MSG_RESULT(GTK+ 2.x GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002486 SKIP_GTK2=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002487 gnome2) AC_MSG_RESULT(GNOME 2.x GUI support)
2488 SKIP_GNOME=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002489 SKIP_GTK2=;;
Bram Moolenaar98921892016-02-23 17:14:37 +01002490 gtk3) AC_MSG_RESULT(GTK+ 3.x GUI support)
2491 SKIP_GTK3=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002492 motif) AC_MSG_RESULT(Motif GUI support)
2493 SKIP_MOTIF=;;
2494 athena) AC_MSG_RESULT(Athena GUI support)
2495 SKIP_ATHENA=;;
2496 nextaw) AC_MSG_RESULT(neXtaw GUI support)
2497 SKIP_NEXTAW=;;
2498 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
2499 esac
2500
2501fi
2502
Bram Moolenaar071d4272004-06-13 20:20:40 +00002503if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \
2504 -a "$enable_gui_canon" != "gnome2"; then
2505 AC_MSG_CHECKING(whether or not to look for GTK+ 2)
2506 AC_ARG_ENABLE(gtk2-check,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002507 [ --enable-gtk2-check If auto-select GUI, check for GTK+ 2 [default=yes]],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002508 , enable_gtk2_check="yes")
2509 AC_MSG_RESULT($enable_gtk2_check)
2510 if test "x$enable_gtk2_check" = "xno"; then
2511 SKIP_GTK2=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002512 SKIP_GNOME=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002513 fi
2514fi
2515
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002516if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002517 AC_MSG_CHECKING(whether or not to look for GNOME)
2518 AC_ARG_ENABLE(gnome-check,
2519 [ --enable-gnome-check If GTK GUI, check for GNOME [default=no]],
2520 , enable_gnome_check="no")
2521 AC_MSG_RESULT($enable_gnome_check)
2522 if test "x$enable_gnome_check" = "xno"; then
2523 SKIP_GNOME=YES
2524 fi
2525fi
2526
Bram Moolenaar98921892016-02-23 17:14:37 +01002527if test "x$SKIP_GTK3" != "xYES" -a "$enable_gui_canon" != "gtk3"; then
2528 AC_MSG_CHECKING(whether or not to look for GTK+ 3)
2529 AC_ARG_ENABLE(gtk3-check,
2530 [ --enable-gtk3-check If auto-select GUI, check for GTK+ 3 [default=yes]],
2531 , enable_gtk3_check="yes")
2532 AC_MSG_RESULT($enable_gtk3_check)
2533 if test "x$enable_gtk3_check" = "xno"; then
2534 SKIP_GTK3=YES
2535 fi
2536fi
2537
Bram Moolenaar071d4272004-06-13 20:20:40 +00002538if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then
2539 AC_MSG_CHECKING(whether or not to look for Motif)
2540 AC_ARG_ENABLE(motif-check,
2541 [ --enable-motif-check If auto-select GUI, check for Motif [default=yes]],
2542 , enable_motif_check="yes")
2543 AC_MSG_RESULT($enable_motif_check)
2544 if test "x$enable_motif_check" = "xno"; then
2545 SKIP_MOTIF=YES
2546 fi
2547fi
2548
2549if test "x$SKIP_ATHENA" != "xYES" -a "$enable_gui_canon" != "athena"; then
2550 AC_MSG_CHECKING(whether or not to look for Athena)
2551 AC_ARG_ENABLE(athena-check,
2552 [ --enable-athena-check If auto-select GUI, check for Athena [default=yes]],
2553 , enable_athena_check="yes")
2554 AC_MSG_RESULT($enable_athena_check)
2555 if test "x$enable_athena_check" = "xno"; then
2556 SKIP_ATHENA=YES
2557 fi
2558fi
2559
2560if test "x$SKIP_NEXTAW" != "xYES" -a "$enable_gui_canon" != "nextaw"; then
2561 AC_MSG_CHECKING(whether or not to look for neXtaw)
2562 AC_ARG_ENABLE(nextaw-check,
2563 [ --enable-nextaw-check If auto-select GUI, check for neXtaw [default=yes]],
2564 , enable_nextaw_check="yes")
2565 AC_MSG_RESULT($enable_nextaw_check);
2566 if test "x$enable_nextaw_check" = "xno"; then
2567 SKIP_NEXTAW=YES
2568 fi
2569fi
2570
Bram Moolenaar071d4272004-06-13 20:20:40 +00002571dnl define an autoconf function to check for a specified version of GTK, and
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002572dnl try to compile/link a GTK program.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002573dnl
2574dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002575dnl Test for GTK, and define GTK_CFLAGS, GTK_LIBDIR and GTK_LIBS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002576dnl
2577AC_DEFUN(AM_PATH_GTK,
2578[
2579 if test "X$GTK_CONFIG" != "Xno" -o "X$PKG_CONFIG" != "Xno"; then
2580 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00002581 no_gtk=""
2582 if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2583 && $PKG_CONFIG --exists gtk+-2.0; then
2584 {
Bram Moolenaar98921892016-02-23 17:14:37 +01002585 min_gtk_version=ifelse([$1], ,2.2.0,$1)
2586 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002587 dnl We should be using PKG_CHECK_MODULES() instead of this hack.
2588 dnl But I guess the dependency on pkgconfig.m4 is not wanted or
2589 dnl something like that.
2590 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0`
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002591 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-2.0`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002592 GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0`
2593 gtk_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2594 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2595 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2596 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2597 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2598 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2599 }
Bram Moolenaar98921892016-02-23 17:14:37 +01002600 elif (test "X$SKIP_GTK3" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2601 && $PKG_CONFIG --exists gtk+-3.0; then
2602 {
2603 min_gtk_version=ifelse([$1], ,3.0.0,$1)
2604 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
2605
2606 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-3.0`
2607 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-3.0`
2608 GTK_LIBS=`$PKG_CONFIG --libs gtk+-3.0`
2609 gtk_major_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2610 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2611 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2612 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2613 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2614 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2615 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002616 else
Bram Moolenaar67876de2021-01-12 20:51:24 +01002617 dnl Put some text before the "no" to hint at installing the gtk-dev
2618 dnl packages.
2619 AC_MSG_CHECKING(for GTK -dev package)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002620 no_gtk=yes
2621 fi
2622
2623 if test "x$enable_gtktest" = "xyes" -a "x$no_gtk" = "x"; then
2624 {
2625 ac_save_CFLAGS="$CFLAGS"
2626 ac_save_LIBS="$LIBS"
2627 CFLAGS="$CFLAGS $GTK_CFLAGS"
2628 LIBS="$LIBS $GTK_LIBS"
2629
2630 dnl
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002631 dnl Now check if the installed GTK is sufficiently new.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002632 dnl
2633 rm -f conf.gtktest
2634 AC_TRY_RUN([
2635#include <gtk/gtk.h>
2636#include <stdio.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00002637#if STDC_HEADERS
2638# include <stdlib.h>
2639# include <stddef.h>
2640#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002641
2642int
2643main ()
2644{
2645int major, minor, micro;
2646char *tmp_version;
2647
2648system ("touch conf.gtktest");
2649
2650/* HP/UX 9 (%@#!) writes to sscanf strings */
2651tmp_version = g_strdup("$min_gtk_version");
2652if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
2653 printf("%s, bad version string\n", "$min_gtk_version");
2654 exit(1);
2655 }
2656
2657if ((gtk_major_version > major) ||
2658 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
2659 ((gtk_major_version == major) && (gtk_minor_version == minor) &&
2660 (gtk_micro_version >= micro)))
2661{
2662 return 0;
2663}
2664return 1;
2665}
2666],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
2667 CFLAGS="$ac_save_CFLAGS"
2668 LIBS="$ac_save_LIBS"
2669 }
2670 fi
2671 if test "x$no_gtk" = x ; then
2672 if test "x$enable_gtktest" = "xyes"; then
2673 AC_MSG_RESULT(yes; found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2674 else
2675 AC_MSG_RESULT(found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2676 fi
2677 ifelse([$2], , :, [$2])
2678 else
2679 {
2680 AC_MSG_RESULT(no)
2681 GTK_CFLAGS=""
2682 GTK_LIBS=""
2683 ifelse([$3], , :, [$3])
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002684 if test "$fail_if_missing" = "yes" -a "X$gui_auto" != "Xyes"; then
2685 AC_MSG_ERROR([could not configure GTK])
2686 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002687 }
2688 fi
2689 }
2690 else
2691 GTK_CFLAGS=""
2692 GTK_LIBS=""
2693 ifelse([$3], , :, [$3])
2694 fi
2695 AC_SUBST(GTK_CFLAGS)
2696 AC_SUBST(GTK_LIBS)
2697 rm -f conf.gtktest
2698])
2699
2700dnl ---------------------------------------------------------------------------
2701dnl gnome
2702dnl ---------------------------------------------------------------------------
2703AC_DEFUN([GNOME_INIT_HOOK],
2704[
2705 AC_SUBST(GNOME_LIBS)
2706 AC_SUBST(GNOME_LIBDIR)
2707 AC_SUBST(GNOME_INCLUDEDIR)
2708
2709 AC_ARG_WITH(gnome-includes,
2710 [ --with-gnome-includes=DIR Specify location of GNOME headers],
2711 [CFLAGS="$CFLAGS -I$withval"]
2712 )
2713
2714 AC_ARG_WITH(gnome-libs,
2715 [ --with-gnome-libs=DIR Specify location of GNOME libs],
2716 [LDFLAGS="$LDFLAGS -L$withval" gnome_prefix=$withval]
2717 )
2718
2719 AC_ARG_WITH(gnome,
2720 [ --with-gnome Specify prefix for GNOME files],
2721 if test x$withval = xyes; then
2722 want_gnome=yes
2723 ifelse([$1], [], :, [$1])
2724 else
2725 if test "x$withval" = xno; then
2726 want_gnome=no
2727 else
2728 want_gnome=yes
2729 LDFLAGS="$LDFLAGS -L$withval/lib"
2730 CFLAGS="$CFLAGS -I$withval/include"
2731 gnome_prefix=$withval/lib
2732 fi
2733 fi,
2734 want_gnome=yes)
2735
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002736 if test "x$want_gnome" = xyes; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002737 {
2738 AC_MSG_CHECKING(for libgnomeui-2.0)
2739 if $PKG_CONFIG --exists libgnomeui-2.0; then
2740 AC_MSG_RESULT(yes)
2741 GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0`
2742 GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0`
2743 GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0`
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002744
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002745 dnl On FreeBSD we need -pthread but pkg-config doesn't include it.
2746 dnl This might not be the right way but it works for me...
2747 AC_MSG_CHECKING(for FreeBSD)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00002748 if test "$vim_cv_uname_output" = FreeBSD; then
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002749 AC_MSG_RESULT(yes, adding -pthread)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002750 GNOME_INCLUDEDIR="$GNOME_INCLUDEDIR -D_THREAD_SAFE"
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002751 GNOME_LIBS="$GNOME_LIBS -pthread"
2752 else
2753 AC_MSG_RESULT(no)
2754 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002755 $1
2756 else
2757 AC_MSG_RESULT(not found)
2758 if test "x$2" = xfail; then
2759 AC_MSG_ERROR(Could not find libgnomeui-2.0 via pkg-config)
2760 fi
2761 fi
2762 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002763 fi
2764])
2765
2766AC_DEFUN([GNOME_INIT],[
2767 GNOME_INIT_HOOK([],fail)
2768])
2769
Bram Moolenaar427f5b62019-06-09 13:43:51 +02002770if test "X$PKG_CONFIG" = "X"; then
2771 AC_PATH_TOOL(PKG_CONFIG, pkg-config, no)
2772fi
2773
Bram Moolenaar071d4272004-06-13 20:20:40 +00002774
2775dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002776dnl Check for GTK2. If it fails, then continue on for Motif as before...
Bram Moolenaar071d4272004-06-13 20:20:40 +00002777dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002778if test -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002779
2780 AC_MSG_CHECKING(--disable-gtktest argument)
2781 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2782 , enable_gtktest=yes)
2783 if test "x$enable_gtktest" = "xyes" ; then
2784 AC_MSG_RESULT(gtk test enabled)
2785 else
2786 AC_MSG_RESULT(gtk test disabled)
2787 fi
2788
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002789 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002790 dnl First try finding version 2.2.0 or later. The 2.0.x series has
2791 dnl problems (bold fonts, --remote doesn't work).
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002792 dnl Disable checking for GTK3 here, otherwise it's found when GTK2 is not
2793 dnl found.
2794 save_skip_gtk3=$SKIP_GTK3
2795 SKIP_GTK3=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002796 AM_PATH_GTK(2.2.0,
2797 [GUI_LIB_LOC="$GTK_LIBDIR"
2798 GTK_LIBNAME="$GTK_LIBS"
2799 GUI_INC_LOC="$GTK_CFLAGS"], )
2800 if test "x$GTK_CFLAGS" != "x"; then
Bram Moolenaar98921892016-02-23 17:14:37 +01002801 SKIP_GTK3=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002802 SKIP_ATHENA=YES
2803 SKIP_NEXTAW=YES
2804 SKIP_MOTIF=YES
2805 GUITYPE=GTK
2806 AC_SUBST(GTK_LIBNAME)
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002807 else
2808 SKIP_GTK3=$save_skip_gtk3
Bram Moolenaar071d4272004-06-13 20:20:40 +00002809 fi
2810 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002811 if test "x$GUITYPE" = "xGTK"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002812 dnl
2813 dnl if GTK exists, then check for GNOME.
2814 dnl
2815 if test -z "$SKIP_GNOME"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002816 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002817 GNOME_INIT_HOOK([have_gnome=yes])
2818 if test "x$have_gnome" = xyes ; then
2819 AC_DEFINE(FEAT_GUI_GNOME)
2820 GUI_INC_LOC="$GUI_INC_LOC $GNOME_INCLUDEDIR"
2821 GTK_LIBNAME="$GTK_LIBNAME $GNOME_LIBDIR $GNOME_LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002822 fi
2823 }
2824 fi
2825 fi
2826fi
2827
Bram Moolenaar98921892016-02-23 17:14:37 +01002828
2829dnl ---------------------------------------------------------------------------
2830dnl Check for GTK3.
2831dnl ---------------------------------------------------------------------------
2832if test -z "$SKIP_GTK3"; then
2833
2834 AC_MSG_CHECKING(--disable-gtktest argument)
2835 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2836 , enable_gtktest=yes)
2837 if test "x$enable_gtktest" = "xyes" ; then
2838 AC_MSG_RESULT(gtk test enabled)
2839 else
2840 AC_MSG_RESULT(gtk test disabled)
2841 fi
2842
Bram Moolenaar98921892016-02-23 17:14:37 +01002843 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002844 save_skip_gtk2=$SKIP_GTK2
2845 SKIP_GTK2=YES
Bram Moolenaar98921892016-02-23 17:14:37 +01002846 AM_PATH_GTK(3.0.0,
2847 [GUI_LIB_LOC="$GTK_LIBDIR"
2848 GTK_LIBNAME="$GTK_LIBS"
2849 GUI_INC_LOC="$GTK_CFLAGS"], )
2850 if test "x$GTK_CFLAGS" != "x"; then
2851 SKIP_GTK2=YES
2852 SKIP_GNOME=YES
2853 SKIP_ATHENA=YES
2854 SKIP_NEXTAW=YES
2855 SKIP_MOTIF=YES
2856 GUITYPE=GTK
2857 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar98921892016-02-23 17:14:37 +01002858 AC_DEFINE(USE_GTK3)
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002859 else
2860 SKIP_GTK2=$save_skip_gtk2
Bram Moolenaar98921892016-02-23 17:14:37 +01002861 fi
2862 fi
2863fi
2864
Bram Moolenaard2e03f02016-01-02 22:46:36 +01002865dnl Check the version of Gdk-Pixbuf. If the version is 2.31 or later and
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002866dnl glib-compile-resources is found in PATH, use GResource.
2867if test "x$GUITYPE" = "xGTK"; then
2868 AC_MSG_CHECKING([version of Gdk-Pixbuf])
2869 gdk_pixbuf_version=`$PKG_CONFIG --modversion gdk-pixbuf-2.0`
2870 if test "x$gdk_pixbuf_version" != x ; then
2871 gdk_pixbuf_version_minor=`echo $gdk_pixbuf_version | \
2872 sed -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/'`
2873 if test "x$gdk_pixbuf_version_minor" != x -a \
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002874 $gdk_pixbuf_version_minor -ge 31 ; then
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002875 AC_MSG_RESULT([OK.])
2876 AC_PATH_PROG(GLIB_COMPILE_RESOURCES,[glib-compile-resources],no)
2877 AC_MSG_CHECKING([glib-compile-resources])
2878 if test "x$GLIB_COMPILE_RESOURCES" = xno ; then
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002879 GLIB_COMPILE_RESOURCES=""
2880 AC_MSG_RESULT([cannot be found in PATH.])
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002881 else
2882 AC_MSG_RESULT([usable.])
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002883 AC_DEFINE(USE_GRESOURCE)
2884 GRESOURCE_SRC="auto/gui_gtk_gresources.c"
2885 GRESOURCE_OBJ="objects/gui_gtk_gresources.o"
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002886 fi
2887 else
2888 AC_MSG_RESULT([not usable.])
2889 fi
2890 else
2891 AC_MSG_RESULT([cannot obtain from pkg_config.])
2892 fi
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002893
2894 AC_MSG_CHECKING([--disable-icon-cache-update argument])
2895 AC_ARG_ENABLE(icon_cache_update,
2896 [ --disable-icon-cache-update update disabled],
2897 [],
2898 [enable_icon_cache_update="yes"])
2899 if test "$enable_icon_cache_update" = "yes"; then
2900 AC_MSG_RESULT([not set])
2901 AC_PATH_PROG(GTK_UPDATE_ICON_CACHE,[gtk-update-icon-cache],no)
2902 if test "x$GTK_UPDATE_ICON_CACHE" = "xno" ; then
2903 AC_MSG_RESULT([not found in PATH.])
2904 fi
2905 else
2906 AC_MSG_RESULT([update disabled])
2907 fi
2908
2909 AC_MSG_CHECKING([--disable-desktop-database-update argument])
2910 AC_ARG_ENABLE(desktop_database_update,
2911 [ --disable-desktop-database-update update disabled],
2912 [],
2913 [enable_desktop_database_update="yes"])
2914 if test "$enable_desktop_database_update" = "yes"; then
2915 AC_MSG_RESULT([not set])
2916 AC_PATH_PROG(UPDATE_DESKTOP_DATABASE,[update-desktop-database],no)
2917 if test "x$UPDATE_DESKTOP_DATABASE" = "xno" ; then
2918 AC_MSG_RESULT([not found in PATH.])
2919 fi
2920 else
2921 AC_MSG_RESULT([update disabled])
2922 fi
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002923fi
2924AC_SUBST(GLIB_COMPILE_RESOURCES)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002925AC_SUBST(GRESOURCE_SRC)
2926AC_SUBST(GRESOURCE_OBJ)
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002927AC_SUBST(GTK_UPDATE_ICON_CACHE)
2928AC_SUBST(UPDATE_DESKTOP_DATABASE)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002929
Bram Moolenaar071d4272004-06-13 20:20:40 +00002930dnl Check for Motif include files location.
2931dnl The LAST one found is used, this makes the highest version to be used,
2932dnl e.g. when Motif1.2 and Motif2.0 are both present.
2933
2934if test -z "$SKIP_MOTIF"; then
2935 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"
2936 dnl Remove "-I" from before $GUI_INC_LOC if it's there
2937 GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`"
2938
2939 AC_MSG_CHECKING(for location of Motif GUI includes)
2940 gui_includes="`echo $x_includes|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC"
2941 GUI_INC_LOC=
2942 for try in $gui_includes; do
2943 if test -f "$try/Xm/Xm.h"; then
2944 GUI_INC_LOC=$try
2945 fi
2946 done
2947 if test -n "$GUI_INC_LOC"; then
2948 if test "$GUI_INC_LOC" = /usr/include; then
2949 GUI_INC_LOC=
2950 AC_MSG_RESULT(in default path)
2951 else
2952 AC_MSG_RESULT($GUI_INC_LOC)
2953 fi
2954 else
2955 AC_MSG_RESULT(<not found>)
2956 SKIP_MOTIF=YES
2957 fi
2958fi
2959
2960dnl Check for Motif library files location. In the same order as the include
2961dnl files, to avoid a mixup if several versions are present
2962
2963if test -z "$SKIP_MOTIF"; then
2964 AC_MSG_CHECKING(--with-motif-lib argument)
2965 AC_ARG_WITH(motif-lib,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002966 [ --with-motif-lib=STRING Library for Motif ],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002967 [ MOTIF_LIBNAME="${withval}" ] )
2968
2969 if test -n "$MOTIF_LIBNAME"; then
2970 AC_MSG_RESULT($MOTIF_LIBNAME)
2971 GUI_LIB_LOC=
2972 else
2973 AC_MSG_RESULT(no)
2974
2975 dnl Remove "-L" from before $GUI_LIB_LOC if it's there
2976 GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
2977
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002978 dnl Ubuntu has libXm.so in /usr/lib/i386-linux-gnu and elsewhere. The
2979 dnl linker will figure out which one to use, we only check if one exists.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002980 AC_MSG_CHECKING(for location of Motif GUI libs)
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002981 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 +00002982 GUI_LIB_LOC=
2983 for try in $gui_libs; do
Bram Moolenaar325b7a22004-07-05 15:58:32 +00002984 for libtry in "$try"/libXm.a "$try"/libXm.so* "$try"/libXm.sl "$try"/libXm.dylib; do
Bram Moolenaar071d4272004-06-13 20:20:40 +00002985 if test -f "$libtry"; then
2986 GUI_LIB_LOC=$try
2987 fi
2988 done
2989 done
2990 if test -n "$GUI_LIB_LOC"; then
2991 dnl Remove /usr/lib, it causes trouble on some systems
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002992 if test "$GUI_LIB_LOC" = /usr/lib \
2993 -o "$GUI_LIB_LOC" = /usr/lib/i386-linux-gnu \
2994 -o "$GUI_LIB_LOC" = /usr/lib/x86_64-linux-gnu; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002995 GUI_LIB_LOC=
2996 AC_MSG_RESULT(in default path)
2997 else
2998 if test -n "$GUI_LIB_LOC"; then
2999 AC_MSG_RESULT($GUI_LIB_LOC)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00003000 if test "$vim_cv_uname_output" = SunOS &&
3001 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003002 GUI_LIB_LOC="$GUI_LIB_LOC -R $GUI_LIB_LOC"
3003 fi
3004 fi
3005 fi
3006 MOTIF_LIBNAME=-lXm
3007 else
3008 AC_MSG_RESULT(<not found>)
3009 SKIP_MOTIF=YES
3010 fi
3011 fi
3012fi
3013
3014if test -z "$SKIP_MOTIF"; then
3015 SKIP_ATHENA=YES
3016 SKIP_NEXTAW=YES
3017 GUITYPE=MOTIF
3018 AC_SUBST(MOTIF_LIBNAME)
3019fi
3020
3021dnl Check if the Athena files can be found
3022
3023GUI_X_LIBS=
3024
3025if test -z "$SKIP_ATHENA"; then
3026 AC_MSG_CHECKING(if Athena header files can be found)
3027 cflags_save=$CFLAGS
3028 CFLAGS="$CFLAGS $X_CFLAGS"
3029 AC_TRY_COMPILE([
3030#include <X11/Intrinsic.h>
3031#include <X11/Xaw/Paned.h>], ,
3032 AC_MSG_RESULT(yes),
3033 AC_MSG_RESULT(no); SKIP_ATHENA=YES )
3034 CFLAGS=$cflags_save
3035fi
3036
3037if test -z "$SKIP_ATHENA"; then
3038 GUITYPE=ATHENA
3039fi
3040
3041if test -z "$SKIP_NEXTAW"; then
3042 AC_MSG_CHECKING(if neXtaw header files can be found)
3043 cflags_save=$CFLAGS
3044 CFLAGS="$CFLAGS $X_CFLAGS"
3045 AC_TRY_COMPILE([
3046#include <X11/Intrinsic.h>
3047#include <X11/neXtaw/Paned.h>], ,
3048 AC_MSG_RESULT(yes),
3049 AC_MSG_RESULT(no); SKIP_NEXTAW=YES )
3050 CFLAGS=$cflags_save
3051fi
3052
3053if test -z "$SKIP_NEXTAW"; then
3054 GUITYPE=NEXTAW
3055fi
3056
3057if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
3058 dnl Prepend -I and -L to $GUI_INC_LOC and $GUI_LIB_LOC if not empty
3059 dnl Avoid adding it when it twice
3060 if test -n "$GUI_INC_LOC"; then
3061 GUI_INC_LOC=-I"`echo $GUI_INC_LOC|sed 's%-I%%'`"
3062 fi
3063 if test -n "$GUI_LIB_LOC"; then
3064 GUI_LIB_LOC=-L"`echo $GUI_LIB_LOC|sed 's%-L%%'`"
3065 fi
3066
3067 dnl Check for -lXext and then for -lXmu
3068 ldflags_save=$LDFLAGS
3069 LDFLAGS="$X_LIBS $LDFLAGS"
3070 AC_CHECK_LIB(Xext, XShapeQueryExtension, [GUI_X_LIBS="-lXext"],,
3071 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3072 dnl For Solaris we need -lw and -ldl before linking with -lXmu works.
3073 AC_CHECK_LIB(w, wslen, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lw"],,
3074 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3075 AC_CHECK_LIB(dl, dlsym, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldl"],,
3076 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3077 AC_CHECK_LIB(Xmu, XmuCreateStippledPixmap, [GUI_X_LIBS="-lXmu $GUI_X_LIBS"],,
3078 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3079 if test -z "$SKIP_MOTIF"; then
3080 AC_CHECK_LIB(Xp, XpEndJob, [GUI_X_LIBS="-lXp $GUI_X_LIBS"],,
3081 [$GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3082 fi
3083 LDFLAGS=$ldflags_save
3084
3085 dnl Execute xmkmf to figure out if -DNARROWPROTO is needed.
3086 AC_MSG_CHECKING(for extra X11 defines)
3087 NARROW_PROTO=
3088 rm -fr conftestdir
3089 if mkdir conftestdir; then
3090 cd conftestdir
3091 cat > Imakefile <<'EOF'
3092acfindx:
3093 @echo 'NARROW_PROTO="${PROTO_DEFINES}"'
3094EOF
3095 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
3096 eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
3097 fi
3098 cd ..
3099 rm -fr conftestdir
3100 fi
3101 if test -z "$NARROW_PROTO"; then
3102 AC_MSG_RESULT(no)
3103 else
3104 AC_MSG_RESULT($NARROW_PROTO)
3105 fi
3106 AC_SUBST(NARROW_PROTO)
3107fi
3108
3109dnl Look for XSMP support - but don't necessarily restrict it to X11 GUIs
3110dnl use the X11 include path
3111if test "$enable_xsmp" = "yes"; then
3112 cppflags_save=$CPPFLAGS
3113 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3114 AC_CHECK_HEADERS(X11/SM/SMlib.h)
3115 CPPFLAGS=$cppflags_save
3116fi
3117
3118
Bram Moolenaar98921892016-02-23 17:14:37 +01003119if 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 +00003120 dnl Check for X11/xpm.h and X11/Sunkeysym.h with the GUI include path
3121 cppflags_save=$CPPFLAGS
3122 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3123 AC_CHECK_HEADERS(X11/xpm.h X11/Sunkeysym.h)
3124
3125 dnl automatically disable XIM when XIMtext isn't in X11/Xlib.h
3126 if test ! "$enable_xim" = "no"; then
3127 AC_MSG_CHECKING(for XIMText in X11/Xlib.h)
3128 AC_EGREP_CPP(XIMText, [#include <X11/Xlib.h>],
3129 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +02003130 AC_MSG_RESULT(no; xim has been disabled); enable_xim="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00003131 fi
3132 CPPFLAGS=$cppflags_save
3133
Bram Moolenaar54612582019-11-21 17:13:31 +01003134 dnl automatically enable XIM in the GUI
3135 if test "$enable_xim" = "auto" -a "x$GUITYPE" != "xNONE" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003136 AC_MSG_RESULT(X GUI selected; xim has been enabled)
3137 enable_xim="yes"
3138 fi
3139fi
3140
3141if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
3142 cppflags_save=$CPPFLAGS
3143 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00003144dnl Xmu/Editres.h may exist but can only be used after including Intrinsic.h
3145 AC_MSG_CHECKING([for X11/Xmu/Editres.h])
3146 AC_TRY_COMPILE([
3147#include <X11/Intrinsic.h>
3148#include <X11/Xmu/Editres.h>],
3149 [int i; i = 0;],
3150 AC_MSG_RESULT(yes)
3151 AC_DEFINE(HAVE_X11_XMU_EDITRES_H),
3152 AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003153 CPPFLAGS=$cppflags_save
3154fi
3155
3156dnl Only use the Xm directory when compiling Motif, don't use it for Athena
3157if test -z "$SKIP_MOTIF"; then
3158 cppflags_save=$CPPFLAGS
3159 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003160 if test "$zOSUnix" = "yes"; then
3161 xmheader="Xm/Xm.h"
3162 else
3163 xmheader="Xm/Xm.h Xm/XpmP.h Xm/JoinSideT.h Xm/TraitP.h Xm/Manager.h
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02003164 Xm/UnhighlightT.h Xm/Notebook.h"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003165 fi
3166 AC_CHECK_HEADERS($xmheader)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003167
Bram Moolenaar77c19352012-06-13 19:19:41 +02003168 if test "x$ac_cv_header_Xm_XpmP_h" = "xyes"; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003169 dnl Solaris uses XpmAttributes_21, very annoying.
3170 AC_MSG_CHECKING([for XpmAttributes_21 in Xm/XpmP.h])
3171 AC_TRY_COMPILE([#include <Xm/XpmP.h>], [XpmAttributes_21 attr;],
3172 AC_MSG_RESULT(yes); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes_21),
3173 AC_MSG_RESULT(no); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
3174 )
3175 else
Bram Moolenaar57657d82006-04-21 22:12:41 +00003176 AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003177 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003178 CPPFLAGS=$cppflags_save
3179fi
3180
3181if test "x$GUITYPE" = "xNONE" -a "$enable_xim" = "yes"; then
3182 AC_MSG_RESULT(no GUI selected; xim has been disabled)
3183 enable_xim="no"
3184fi
3185if test "x$GUITYPE" = "xNONE" -a "$enable_fontset" = "yes"; then
3186 AC_MSG_RESULT(no GUI selected; fontset has been disabled)
3187 enable_fontset="no"
3188fi
Bram Moolenaar182c5be2010-06-25 05:37:59 +02003189if test "x$GUITYPE:$enable_fontset" = "xGTK:yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003190 AC_MSG_RESULT(GTK+ 2 GUI selected; fontset has been disabled)
3191 enable_fontset="no"
3192fi
3193
Bram Moolenaarb3f74062020-02-26 16:16:53 +01003194dnl There is no test for the Haiku GUI, if it's selected it's used
3195if test -z "$SKIP_HAIKU"; then
3196 GUITYPE=HAIKUGUI
3197fi
3198
Bram Moolenaar071d4272004-06-13 20:20:40 +00003199if test -z "$SKIP_PHOTON"; then
3200 GUITYPE=PHOTONGUI
3201fi
3202
3203AC_SUBST(GUI_INC_LOC)
3204AC_SUBST(GUI_LIB_LOC)
3205AC_SUBST(GUITYPE)
3206AC_SUBST(GUI_X_LIBS)
3207
3208if test "$enable_workshop" = "yes" -a -n "$SKIP_MOTIF"; then
3209 AC_MSG_ERROR([cannot use workshop without Motif])
3210fi
3211
3212dnl defining FEAT_XIM and FEAT_XFONTSET is delayed, so that they can be disabled
3213if test "$enable_xim" = "yes"; then
3214 AC_DEFINE(FEAT_XIM)
3215fi
3216if test "$enable_fontset" = "yes"; then
3217 AC_DEFINE(FEAT_XFONTSET)
3218fi
3219
3220
3221dnl ---------------------------------------------------------------------------
3222dnl end of GUI-checking
3223dnl ---------------------------------------------------------------------------
3224
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003225AC_MSG_CHECKING([for /proc link to executable])
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003226if test -L "/proc/self/exe"; then
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003227 dnl Linux
3228 AC_MSG_RESULT([/proc/self/exe])
3229 AC_DEFINE(PROC_EXE_LINK, "/proc/self/exe")
3230elif test -L "/proc/self/path/a.out"; then
3231 dnl Solaris
3232 AC_MSG_RESULT([/proc/self/path/a.out])
3233 AC_DEFINE(PROC_EXE_LINK, "/proc/self/path/a.out")
3234elif test -L "/proc/curproc/file"; then
3235 dnl FreeBSD
3236 AC_MSG_RESULT([/proc/curproc/file])
3237 AC_DEFINE(PROC_EXE_LINK, "/proc/curproc/file")
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003238else
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003239 AC_MSG_RESULT(no)
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003240fi
3241
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003242dnl Check for Cygwin, which needs an extra source file if not using X11
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003243AC_MSG_CHECKING(for CYGWIN or MSYS environment)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00003244case $vim_cv_uname_output in
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003245 CYGWIN*|MSYS*) CYGWIN=yes; AC_MSG_RESULT(yes)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003246 AC_MSG_CHECKING(for CYGWIN clipboard support)
3247 if test "x$with_x" = "xno" ; then
3248 OS_EXTRA_SRC=winclip.c; OS_EXTRA_OBJ=objects/winclip.o
3249 AC_MSG_RESULT(yes)
3250 AC_DEFINE(FEAT_CYGWIN_WIN32_CLIPBOARD)
3251 else
3252 AC_MSG_RESULT(no - using X11)
3253 fi ;;
3254
3255 *) CYGWIN=no; AC_MSG_RESULT(no);;
3256esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00003257
Bram Moolenaar071d4272004-06-13 20:20:40 +00003258dnl Checks for libraries and include files.
3259
Bram Moolenaar446cb832008-06-24 21:56:24 +00003260AC_CACHE_CHECK([whether toupper is broken], [vim_cv_toupper_broken],
3261 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003262 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003263#include "confdefs.h"
3264#include <ctype.h>
3265#if STDC_HEADERS
3266# include <stdlib.h>
3267# include <stddef.h>
3268#endif
3269main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003270 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003271 vim_cv_toupper_broken=yes
3272 ],[
3273 vim_cv_toupper_broken=no
3274 ],[
3275 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_toupper_broken')
3276 ])])
3277
3278if test "x$vim_cv_toupper_broken" = "xyes" ; then
3279 AC_DEFINE(BROKEN_TOUPPER)
3280fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003281
3282AC_MSG_CHECKING(whether __DATE__ and __TIME__ work)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003283AC_TRY_COMPILE([#include <stdio.h>], [printf("(" __DATE__ " " __TIME__ ")");],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003284 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DATE_TIME),
3285 AC_MSG_RESULT(no))
3286
Bram Moolenaar0c094b92009-05-14 20:20:33 +00003287AC_MSG_CHECKING(whether __attribute__((unused)) is allowed)
3288AC_TRY_COMPILE([#include <stdio.h>], [int x __attribute__((unused));],
3289 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ATTRIBUTE_UNUSED),
3290 AC_MSG_RESULT(no))
3291
Bram Moolenaar071d4272004-06-13 20:20:40 +00003292dnl Checks for header files.
3293AC_CHECK_HEADER(elf.h, HAS_ELF=1)
3294dnl AC_CHECK_HEADER(dwarf.h, SVR4=1)
3295if test "$HAS_ELF" = 1; then
3296 AC_CHECK_LIB(elf, main)
3297fi
3298
3299AC_HEADER_DIRENT
3300
Bram Moolenaar071d4272004-06-13 20:20:40 +00003301dnl If sys/wait.h is not found it might still exist but not be POSIX
3302dnl compliant. In that case we define HAVE_UNION_WAIT (for NeXT)
3303if test $ac_cv_header_sys_wait_h = no; then
3304 AC_MSG_CHECKING([for sys/wait.h that defines union wait])
3305 AC_TRY_COMPILE([#include <sys/wait.h>],
3306 [union wait xx, yy; xx = yy],
3307 AC_MSG_RESULT(yes)
3308 AC_DEFINE(HAVE_SYS_WAIT_H)
3309 AC_DEFINE(HAVE_UNION_WAIT),
3310 AC_MSG_RESULT(no))
3311fi
3312
Bram Moolenaar779a7752016-01-30 23:26:34 +01003313AC_CHECK_HEADERS(stdint.h stdlib.h string.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003314 sys/select.h sys/utsname.h termcap.h fcntl.h \
3315 sgtty.h sys/ioctl.h sys/time.h sys/types.h \
3316 termio.h iconv.h inttypes.h langinfo.h math.h \
3317 unistd.h stropts.h errno.h sys/resource.h \
3318 sys/systeminfo.h locale.h sys/stream.h termios.h \
3319 libc.h sys/statfs.h poll.h sys/poll.h pwd.h \
Bram Moolenaar1ecc5e42019-01-26 15:12:55 +01003320 utime.h sys/param.h sys/ptms.h libintl.h libgen.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003321 util/debug.h util/msg18n.h frame.h sys/acl.h \
3322 sys/access.h sys/sysinfo.h wchar.h wctype.h)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003323
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003324dnl sys/ptem.h depends on sys/stream.h on Solaris
3325AC_CHECK_HEADERS(sys/ptem.h, [], [],
3326[#if defined HAVE_SYS_STREAM_H
3327# include <sys/stream.h>
3328#endif])
3329
Bram Moolenaar32f31b12009-05-21 13:20:59 +00003330dnl sys/sysctl.h depends on sys/param.h on OpenBSD
3331AC_CHECK_HEADERS(sys/sysctl.h, [], [],
3332[#if defined HAVE_SYS_PARAM_H
3333# include <sys/param.h>
3334#endif])
3335
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003336
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003337dnl pthread_np.h may exist but can only be used after including pthread.h
3338AC_MSG_CHECKING([for pthread_np.h])
3339AC_TRY_COMPILE([
3340#include <pthread.h>
3341#include <pthread_np.h>],
3342 [int i; i = 0;],
3343 AC_MSG_RESULT(yes)
3344 AC_DEFINE(HAVE_PTHREAD_NP_H),
3345 AC_MSG_RESULT(no))
3346
Bram Moolenaare344bea2005-09-01 20:46:49 +00003347AC_CHECK_HEADERS(strings.h)
Bram Moolenaard0573012017-10-28 21:11:06 +02003348if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00003349 dnl The strings.h file on OS/X contains a warning and nothing useful.
3350 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3351else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003352
3353dnl Check if strings.h and string.h can both be included when defined.
3354AC_MSG_CHECKING([if strings.h can be included after string.h])
3355cppflags_save=$CPPFLAGS
3356CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3357AC_TRY_COMPILE([
3358#if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO)
3359# define _NO_PROTO /* like in os_unix.h, causes conflict for AIX (Winn) */
3360 /* but don't do it on AIX 5.1 (Uribarri) */
3361#endif
3362#ifdef HAVE_XM_XM_H
3363# include <Xm/Xm.h> /* This breaks it for HP-UX 11 (Squassabia) */
3364#endif
3365#ifdef HAVE_STRING_H
3366# include <string.h>
3367#endif
3368#if defined(HAVE_STRINGS_H)
3369# include <strings.h>
3370#endif
3371 ], [int i; i = 0;],
3372 AC_MSG_RESULT(yes),
3373 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3374 AC_MSG_RESULT(no))
3375CPPFLAGS=$cppflags_save
Bram Moolenaar9372a112005-12-06 19:59:18 +00003376fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003377
3378dnl Checks for typedefs, structures, and compiler characteristics.
3379AC_PROG_GCC_TRADITIONAL
3380AC_C_CONST
Bram Moolenaar76243bd2009-03-02 01:47:02 +00003381AC_C_VOLATILE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003382AC_TYPE_MODE_T
3383AC_TYPE_OFF_T
3384AC_TYPE_PID_T
3385AC_TYPE_SIZE_T
3386AC_TYPE_UID_T
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003387AC_TYPE_UINT32_T
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003388
Bram Moolenaar071d4272004-06-13 20:20:40 +00003389AC_HEADER_TIME
3390AC_CHECK_TYPE(ino_t, long)
3391AC_CHECK_TYPE(dev_t, unsigned)
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003392AC_C_BIGENDIAN(,,,)
Bram Moolenaar136f29a2016-02-27 20:14:15 +01003393AC_C_INLINE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003394
3395AC_MSG_CHECKING(for rlim_t)
3396if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
3397 AC_MSG_RESULT([(cached) $ac_cv_type_rlim_t])
3398else
3399 AC_EGREP_CPP(dnl
3400changequote(<<,>>)dnl
3401<<(^|[^a-zA-Z_0-9])rlim_t[^a-zA-Z_0-9]>>dnl
3402changequote([,]),
3403 [
3404#include <sys/types.h>
3405#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003406# include <stdlib.h>
3407# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003408#endif
3409#ifdef HAVE_SYS_RESOURCE_H
Bram Moolenaar446cb832008-06-24 21:56:24 +00003410# include <sys/resource.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003411#endif
3412 ], ac_cv_type_rlim_t=yes, ac_cv_type_rlim_t=no)
3413 AC_MSG_RESULT($ac_cv_type_rlim_t)
3414fi
3415if test $ac_cv_type_rlim_t = no; then
3416 cat >> confdefs.h <<\EOF
3417#define rlim_t unsigned long
3418EOF
3419fi
3420
3421AC_MSG_CHECKING(for stack_t)
3422if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then
3423 AC_MSG_RESULT([(cached) $ac_cv_type_stack_t])
3424else
3425 AC_EGREP_CPP(stack_t,
3426 [
3427#include <sys/types.h>
3428#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003429# include <stdlib.h>
3430# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003431#endif
3432#include <signal.h>
3433 ], ac_cv_type_stack_t=yes, ac_cv_type_stack_t=no)
3434 AC_MSG_RESULT($ac_cv_type_stack_t)
3435fi
3436if test $ac_cv_type_stack_t = no; then
3437 cat >> confdefs.h <<\EOF
3438#define stack_t struct sigaltstack
3439EOF
3440fi
3441
3442dnl BSDI uses ss_base while others use ss_sp for the stack pointer.
3443AC_MSG_CHECKING(whether stack_t has an ss_base field)
3444AC_TRY_COMPILE([
3445#include <sys/types.h>
3446#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003447# include <stdlib.h>
3448# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003449#endif
3450#include <signal.h>
3451#include "confdefs.h"
3452 ], [stack_t sigstk; sigstk.ss_base = 0; ],
3453 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SS_BASE),
3454 AC_MSG_RESULT(no))
3455
3456olibs="$LIBS"
3457AC_MSG_CHECKING(--with-tlib argument)
3458AC_ARG_WITH(tlib, [ --with-tlib=library terminal library to be used ],)
3459if test -n "$with_tlib"; then
3460 AC_MSG_RESULT($with_tlib)
3461 LIBS="$LIBS -l$with_tlib"
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003462 AC_MSG_CHECKING(for linking with $with_tlib library)
3463 AC_TRY_LINK([], [], AC_MSG_RESULT(OK), AC_MSG_ERROR(FAILED))
3464 dnl Need to check for tgetent() below.
3465 olibs="$LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003466else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003467 AC_MSG_RESULT([empty: automatic terminal library selection])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003468 dnl On HP-UX 10.10 termcap or termlib should be used instead of
3469 dnl curses, because curses is much slower.
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003470 dnl Newer versions of ncurses are preferred over anything, except
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02003471 dnl when tinfo has been split off, it contains all we need.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003472 dnl Older versions of ncurses have bugs, get a new one!
3473 dnl Digital Unix (OSF1) should use curses (Ronald Schild).
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00003474 dnl On SCO Openserver should prefer termlib (Roger Cornelius).
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00003475 case "$vim_cv_uname_output" in
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003476 OSF1|SCO_SV) tlibs="tinfo ncurses curses termlib termcap";;
3477 *) tlibs="tinfo ncurses termlib termcap curses";;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003478 esac
3479 for libname in $tlibs; do
3480 AC_CHECK_LIB(${libname}, tgetent,,)
3481 if test "x$olibs" != "x$LIBS"; then
3482 dnl It's possible that a library is found but it doesn't work
3483 dnl e.g., shared library that cannot be found
3484 dnl compile and run a test program to be sure
3485 AC_TRY_RUN([
3486#ifdef HAVE_TERMCAP_H
3487# include <termcap.h>
3488#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003489#if STDC_HEADERS
3490# include <stdlib.h>
3491# include <stddef.h>
3492#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003493main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }],
3494 res="OK", res="FAIL", res="FAIL")
3495 if test "$res" = "OK"; then
3496 break
3497 fi
3498 AC_MSG_RESULT($libname library is not usable)
3499 LIBS="$olibs"
3500 fi
3501 done
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003502 if test "x$olibs" = "x$LIBS"; then
3503 AC_MSG_RESULT(no terminal library found)
3504 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003505fi
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003506
3507if test "x$olibs" = "x$LIBS"; then
3508 AC_MSG_CHECKING([for tgetent()])
Bram Moolenaarbd7f7c12020-07-28 21:03:37 +02003509 AC_TRY_LINK([int tgetent(char *, const char *);],
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003510 [char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");],
3511 AC_MSG_RESULT(yes),
3512 AC_MSG_ERROR([NOT FOUND!
3513 You need to install a terminal library; for example ncurses.
Bram Moolenaar16678eb2021-04-21 11:57:59 +02003514 On Linux that would be the libncurses-dev package.
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003515 Or specify the name of the library with --with-tlib.]))
3516fi
3517
Bram Moolenaar446cb832008-06-24 21:56:24 +00003518AC_CACHE_CHECK([whether we talk terminfo], [vim_cv_terminfo],
3519 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003520 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003521#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003522#ifdef HAVE_TERMCAP_H
3523# include <termcap.h>
3524#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003525#ifdef HAVE_STRING_H
3526# include <string.h>
3527#endif
3528#if STDC_HEADERS
3529# include <stdlib.h>
3530# include <stddef.h>
3531#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003532main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003533{char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003534 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003535 vim_cv_terminfo=no
3536 ],[
3537 vim_cv_terminfo=yes
3538 ],[
3539 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_terminfo')
3540 ])
3541 ])
3542
3543if test "x$vim_cv_terminfo" = "xyes" ; then
3544 AC_DEFINE(TERMINFO)
3545fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003546
Bram Moolenaara88254f2017-11-02 23:04:14 +01003547AC_CACHE_CHECK([what tgetent() returns for an unknown terminal], [vim_cv_tgetent],
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003548 [
3549 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003550#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003551#ifdef HAVE_TERMCAP_H
3552# include <termcap.h>
3553#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003554#if STDC_HEADERS
3555# include <stdlib.h>
3556# include <stddef.h>
3557#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003558main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003559{char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003560 ]])],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003561 vim_cv_tgetent=zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003562 ],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003563 vim_cv_tgetent=non-zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003564 ],[
3565 AC_MSG_ERROR(failed to compile test program.)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003566 ])
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003567 ])
3568
Bram Moolenaara88254f2017-11-02 23:04:14 +01003569if test "x$vim_cv_tgetent" = "xzero" ; then
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003570 AC_DEFINE(TGETENT_ZERO_ERR, 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003571fi
3572
3573AC_MSG_CHECKING(whether termcap.h contains ospeed)
3574AC_TRY_LINK([
3575#ifdef HAVE_TERMCAP_H
3576# include <termcap.h>
3577#endif
3578 ], [ospeed = 20000],
3579 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED),
3580 [AC_MSG_RESULT(no)
3581 AC_MSG_CHECKING(whether ospeed can be extern)
3582 AC_TRY_LINK([
3583#ifdef HAVE_TERMCAP_H
3584# include <termcap.h>
3585#endif
3586extern short ospeed;
3587 ], [ospeed = 20000],
3588 AC_MSG_RESULT(yes); AC_DEFINE(OSPEED_EXTERN),
3589 AC_MSG_RESULT(no))]
3590 )
3591
3592AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC])
3593AC_TRY_LINK([
3594#ifdef HAVE_TERMCAP_H
3595# include <termcap.h>
3596#endif
3597 ], [if (UP == 0 && BC == 0) PC = 1],
3598 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UP_BC_PC),
3599 [AC_MSG_RESULT(no)
3600 AC_MSG_CHECKING([whether UP, BC and PC can be extern])
3601 AC_TRY_LINK([
3602#ifdef HAVE_TERMCAP_H
3603# include <termcap.h>
3604#endif
3605extern char *UP, *BC, PC;
3606 ], [if (UP == 0 && BC == 0) PC = 1],
3607 AC_MSG_RESULT(yes); AC_DEFINE(UP_BC_PC_EXTERN),
3608 AC_MSG_RESULT(no))]
3609 )
3610
3611AC_MSG_CHECKING(whether tputs() uses outfuntype)
3612AC_TRY_COMPILE([
3613#ifdef HAVE_TERMCAP_H
3614# include <termcap.h>
3615#endif
3616 ], [extern int xx(); tputs("test", 1, (outfuntype)xx)],
3617 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OUTFUNTYPE),
3618 AC_MSG_RESULT(no))
3619
Bram Moolenaarb3a29552021-11-19 11:28:04 +00003620AC_MSG_CHECKING([whether del_curterm() can be used])
3621AC_TRY_LINK([
3622#ifdef HAVE_TERMCAP_H
3623# include <termcap.h>
3624#endif
3625#include <term.h>
3626 ], [if (cur_term) del_curterm(cur_term);],
3627 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DEL_CURTERM),
3628 AC_MSG_RESULT(no))
3629
Bram Moolenaar071d4272004-06-13 20:20:40 +00003630dnl On some SCO machines sys/select redefines struct timeval
3631AC_MSG_CHECKING([whether sys/select.h and sys/time.h may both be included])
3632AC_TRY_COMPILE([
3633#include <sys/types.h>
3634#include <sys/time.h>
3635#include <sys/select.h>], ,
3636 AC_MSG_RESULT(yes)
3637 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME),
3638 AC_MSG_RESULT(no))
3639
3640dnl AC_DECL_SYS_SIGLIST
3641
3642dnl Checks for pty.c (copied from screen) ==========================
3643AC_MSG_CHECKING(for /dev/ptc)
3644if test -r /dev/ptc; then
3645 AC_DEFINE(HAVE_DEV_PTC)
3646 AC_MSG_RESULT(yes)
3647else
3648 AC_MSG_RESULT(no)
3649fi
3650
3651AC_MSG_CHECKING(for SVR4 ptys)
3652if test -c /dev/ptmx ; then
Bram Moolenaarce7be3a2020-11-26 20:11:11 +01003653 AC_TRY_LINK([
3654// These should be in stdlib.h, but it depends on _XOPEN_SOURCE.
3655char *ptsname(int);
3656int unlockpt(int);
3657int grantpt(int);
3658 ], [
3659 ptsname(0);
3660 grantpt(0);
3661 unlockpt(0);],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003662 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SVR4_PTYS),
3663 AC_MSG_RESULT(no))
3664else
3665 AC_MSG_RESULT(no)
3666fi
3667
3668AC_MSG_CHECKING(for ptyranges)
3669if test -d /dev/ptym ; then
3670 pdir='/dev/ptym'
3671else
3672 pdir='/dev'
3673fi
3674dnl SCO uses ptyp%d
3675AC_EGREP_CPP(yes,
3676[#ifdef M_UNIX
3677 yes;
3678#endif
3679 ], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
3680dnl if test -c /dev/ptyp19; then
3681dnl ptys=`echo /dev/ptyp??`
3682dnl else
3683dnl ptys=`echo $pdir/pty??`
3684dnl fi
3685if test "$ptys" != "$pdir/pty??" ; then
3686 p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
3687 p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'`
3688 AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
3689 AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
3690 AC_MSG_RESULT([$p0 / $p1])
3691else
3692 AC_MSG_RESULT([don't know])
3693fi
3694
Bram Moolenaar071d4272004-06-13 20:20:40 +00003695dnl Checks for library functions. ===================================
3696
3697AC_TYPE_SIGNAL
3698
3699dnl find out what to use at the end of a signal function
3700if test $ac_cv_type_signal = void; then
3701 AC_DEFINE(SIGRETURN, [return])
3702else
3703 AC_DEFINE(SIGRETURN, [return 0])
3704fi
3705
3706dnl check if struct sigcontext is defined (used for SGI only)
3707AC_MSG_CHECKING(for struct sigcontext)
3708AC_TRY_COMPILE([
3709#include <signal.h>
3710test_sig()
3711{
3712 struct sigcontext *scont;
3713 scont = (struct sigcontext *)0;
3714 return 1;
3715} ], ,
3716 AC_MSG_RESULT(yes)
3717 AC_DEFINE(HAVE_SIGCONTEXT),
3718 AC_MSG_RESULT(no))
3719
3720dnl tricky stuff: try to find out if getcwd() is implemented with
3721dnl system("sh -c pwd")
Bram Moolenaar446cb832008-06-24 21:56:24 +00003722AC_CACHE_CHECK([getcwd implementation is broken], [vim_cv_getcwd_broken],
3723 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003724 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003725#include "confdefs.h"
3726#ifdef HAVE_UNISTD_H
3727#include <unistd.h>
3728#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003729char *dagger[] = { "IFS=pwd", 0 };
3730main()
3731{
3732 char buffer[500];
3733 extern char **environ;
3734 environ = dagger;
3735 return getcwd(buffer, 500) ? 0 : 1;
Bram Moolenaar446cb832008-06-24 21:56:24 +00003736}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003737 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003738 vim_cv_getcwd_broken=no
3739 ],[
3740 vim_cv_getcwd_broken=yes
3741 ],[
3742 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_getcwd_broken')
3743 ])
3744 ])
3745
3746if test "x$vim_cv_getcwd_broken" = "xyes" ; then
3747 AC_DEFINE(BAD_GETCWD)
Bram Moolenaar63d25552019-05-10 21:28:38 +02003748 AC_CHECK_FUNCS(getwd)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003749fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003750
Bram Moolenaar25153e12010-02-24 14:47:08 +01003751dnl Check for functions in one big call, to reduce the size of configure.
3752dnl Can only be used for functions that do not require any include.
Bram Moolenaarcd142e32017-11-16 17:03:45 +01003753AC_CHECK_FUNCS(fchdir fchown fchmod fsync getcwd getpseudotty \
Bram Moolenaar63d25552019-05-10 21:28:38 +02003754 getpwent getpwnam getpwuid getrlimit gettimeofday localtime_r lstat \
Bram Moolenaareaf03392009-11-17 11:08:52 +00003755 memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
Bram Moolenaar2fcf6682017-03-11 20:03:42 +01003756 getpgid setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
Bram Moolenaar84cf6bd2020-06-16 20:03:43 +02003757 sigprocmask sigvec strcasecmp strcoll strerror strftime stricmp strncasecmp \
Bram Moolenaar10455d42019-11-21 15:36:18 +01003758 strnicmp strpbrk strptime strtol tgetent towlower towupper iswupper \
3759 tzset usleep utime utimes mblen ftruncate unsetenv posix_openpt)
Bram Moolenaar643b6142018-09-12 20:29:09 +02003760AC_FUNC_SELECT_ARGTYPES
Bram Moolenaar25153e12010-02-24 14:47:08 +01003761AC_FUNC_FSEEKO
Bram Moolenaar071d4272004-06-13 20:20:40 +00003762
Bram Moolenaar317fd3a2010-05-07 16:05:55 +02003763dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when
3764dnl appropriate, so that off_t is 64 bits when needed.
3765AC_SYS_LARGEFILE
3766
Bram Moolenaar21606672019-06-14 20:40:58 +02003767AC_MSG_CHECKING(--enable-canberra argument)
3768AC_ARG_ENABLE(canberra,
3769 [ --disable-canberra Do not use libcanberra.],
3770 , [enable_canberra="maybe"])
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003771
Bram Moolenaar21606672019-06-14 20:40:58 +02003772if test "$enable_canberra" = "maybe"; then
3773 if test "$features" = "big" -o "$features" = "huge"; then
3774 AC_MSG_RESULT(Defaulting to yes)
3775 enable_canberra="yes"
3776 else
3777 AC_MSG_RESULT(Defaulting to no)
3778 enable_canberra="no"
3779 fi
3780else
3781 AC_MSG_RESULT($enable_canberra)
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003782fi
Bram Moolenaar21606672019-06-14 20:40:58 +02003783if test "$enable_canberra" = "yes"; then
3784 if test "x$PKG_CONFIG" != "xno"; then
3785 canberra_lib=`$PKG_CONFIG --libs libcanberra 2>/dev/null`
3786 canberra_cflags=`$PKG_CONFIG --cflags libcanberra 2>/dev/null`
3787 fi
3788 if test "x$canberra_lib" = "x"; then
3789 canberra_lib=-lcanberra
3790 canberra_cflags=-D_REENTRANT
3791 fi
3792 AC_MSG_CHECKING(for libcanberra)
3793 ac_save_CFLAGS="$CFLAGS"
3794 ac_save_LIBS="$LIBS"
Christian Brabandt6b9efdd2021-09-09 17:14:50 +02003795 if `echo "$CFLAGS" | grep -v "$canberra_cflags" >/dev/null`; then
3796 CFLAGS="$CFLAGS $canberra_cflags"
3797 fi
Bram Moolenaar21606672019-06-14 20:40:58 +02003798 LIBS="$LIBS $canberra_lib"
3799 AC_TRY_LINK([
3800 # include <canberra.h>
3801 ], [
3802 ca_context *hello;
3803 ca_context_create(&hello);],
3804 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_CANBERRA),
Bram Moolenaar91b992c2019-11-17 19:07:42 +01003805 AC_MSG_RESULT(no; try installing libcanberra-dev); CFLAGS="$ac_save_CFLAGS"; LIBS="$ac_save_LIBS")
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003806fi
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003807
Christian Brabandtf573c6e2021-06-20 14:02:16 +02003808AC_MSG_CHECKING(--enable-libsodium argument)
3809AC_ARG_ENABLE(libsodium,
3810 [ --disable-libsodium Do not use libsodium.],
3811 , [enable_libsodium="maybe"])
3812
3813if test "$enable_libsodium" = "maybe"; then
3814 if test "$features" = "big" -o "$features" = "huge"; then
3815 AC_MSG_RESULT(Defaulting to yes)
3816 enable_libsodium="yes"
3817 else
3818 AC_MSG_RESULT(Defaulting to no)
3819 enable_libsodium="no"
3820 fi
3821else
3822 AC_MSG_RESULT($enable_libsodium)
3823fi
3824if test "$enable_libsodium" = "yes"; then
3825 if test "x$PKG_CONFIG" != "xno"; then
3826 libsodium_lib=`$PKG_CONFIG --libs libsodium 2>/dev/null`
3827 libsodium_cflags=`$PKG_CONFIG --cflags libsodium 2>/dev/null`
3828 fi
3829 if test "x$libsodium_lib" = "x"; then
3830 libsodium_lib=-lsodium
3831 libsodium_cflags=
3832 fi
ichizok8ce3ca82021-06-23 15:41:52 +02003833 AC_MSG_CHECKING(for libsodium)
Christian Brabandtf573c6e2021-06-20 14:02:16 +02003834 ac_save_CFLAGS="$CFLAGS"
3835 ac_save_LIBS="$LIBS"
3836 CFLAGS="$CFLAGS $libsodium_cflags"
3837 LIBS="$LIBS $libsodium_lib"
3838 AC_TRY_LINK([
3839 # include <sodium.h>
3840 ], [
3841 printf("%d", sodium_init()); ],
3842 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SODIUM),
3843 AC_MSG_RESULT(no; try installing libsodium-dev); CFLAGS="$ac_save_CFLAGS"; LIBS="$ac_save_LIBS")
3844fi
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003845
Bram Moolenaar071d4272004-06-13 20:20:40 +00003846dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible
3847AC_MSG_CHECKING(for st_blksize)
3848AC_TRY_COMPILE(
3849[#include <sys/types.h>
3850#include <sys/stat.h>],
3851[ struct stat st;
3852 int n;
3853
3854 stat("/", &st);
3855 n = (int)st.st_blksize;],
3856 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ST_BLKSIZE),
3857 AC_MSG_RESULT(no))
3858
Bram Moolenaar446cb832008-06-24 21:56:24 +00003859AC_CACHE_CHECK([whether stat() ignores a trailing slash], [vim_cv_stat_ignores_slash],
3860 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003861 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003862#include "confdefs.h"
3863#if STDC_HEADERS
3864# include <stdlib.h>
3865# include <stddef.h>
3866#endif
3867#include <sys/types.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003868#include <sys/stat.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003869main() {struct stat st; exit(stat("configure/", &st) != 0); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003870 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003871 vim_cv_stat_ignores_slash=yes
3872 ],[
3873 vim_cv_stat_ignores_slash=no
3874 ],[
3875 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_stat_ignores_slash')
3876 ])
3877 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003878
Bram Moolenaar446cb832008-06-24 21:56:24 +00003879if test "x$vim_cv_stat_ignores_slash" = "xyes" ; then
3880 AC_DEFINE(STAT_IGNORES_SLASH)
3881fi
Leah Neukirchen0a7984a2021-10-14 21:27:55 +01003882
3883dnl nanoseconds field of struct stat
3884AC_CACHE_CHECK([for nanoseconds field of struct stat],
3885 ac_cv_struct_st_mtim_nsec,
3886 [ac_save_CPPFLAGS="$CPPFLAGS"
3887 ac_cv_struct_st_mtim_nsec=no
3888 # st_mtim.tv_nsec -- the usual case
3889 # st_mtim._tv_nsec -- Solaris 2.6, if
3890 # (defined _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED == 1
3891 # && !defined __EXTENSIONS__)
3892 # st_mtim.st__tim.tv_nsec -- UnixWare 2.1.2
3893 # st_mtime_n -- AIX 5.2 and above
3894 # st_mtimespec.tv_nsec -- Darwin (Mac OSX)
3895 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
3896 CPPFLAGS="$ac_save_CPPFLAGS -DST_MTIM_NSEC=$ac_val"
3897 AC_TRY_COMPILE([#include <sys/types.h>
3898#include <sys/stat.h>], [struct stat s; s.ST_MTIM_NSEC;],
3899 [ac_cv_struct_st_mtim_nsec=$ac_val; break])
3900 done
3901 CPPFLAGS="$ac_save_CPPFLAGS"
3902])
3903if test $ac_cv_struct_st_mtim_nsec != no; then
3904 AC_DEFINE_UNQUOTED([ST_MTIM_NSEC], [$ac_cv_struct_st_mtim_nsec],
3905 [Define if struct stat contains a nanoseconds field])
3906fi
Bram Moolenaar446cb832008-06-24 21:56:24 +00003907
Bram Moolenaar071d4272004-06-13 20:20:40 +00003908dnl Link with iconv for charset translation, if not found without library.
3909dnl check for iconv() requires including iconv.h
3910dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
3911dnl has been installed.
3912AC_MSG_CHECKING(for iconv_open())
3913save_LIBS="$LIBS"
3914LIBS="$LIBS -liconv"
3915AC_TRY_LINK([
3916#ifdef HAVE_ICONV_H
3917# include <iconv.h>
3918#endif
3919 ], [iconv_open("fr", "to");],
3920 AC_MSG_RESULT(yes; with -liconv); AC_DEFINE(HAVE_ICONV),
3921 LIBS="$save_LIBS"
3922 AC_TRY_LINK([
3923#ifdef HAVE_ICONV_H
3924# include <iconv.h>
3925#endif
3926 ], [iconv_open("fr", "to");],
3927 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ICONV),
3928 AC_MSG_RESULT(no)))
3929
3930
3931AC_MSG_CHECKING(for nl_langinfo(CODESET))
3932AC_TRY_LINK([
3933#ifdef HAVE_LANGINFO_H
3934# include <langinfo.h>
3935#endif
3936], [char *cs = nl_langinfo(CODESET);],
3937 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET),
3938 AC_MSG_RESULT(no))
3939
Bram Moolenaar446cb832008-06-24 21:56:24 +00003940dnl Need various functions for floating point support. Only enable
3941dnl floating point when they are all present.
3942AC_CHECK_LIB(m, strtod)
3943AC_MSG_CHECKING([for strtod() and other floating point functions])
3944AC_TRY_LINK([
3945#ifdef HAVE_MATH_H
3946# include <math.h>
3947#endif
3948#if STDC_HEADERS
3949# include <stdlib.h>
3950# include <stddef.h>
3951#endif
3952], [char *s; double d;
3953 d = strtod("1.1", &s);
3954 d = fabs(1.11);
3955 d = ceil(1.11);
3956 d = floor(1.11);
3957 d = log10(1.11);
3958 d = pow(1.11, 2.22);
3959 d = sqrt(1.11);
3960 d = sin(1.11);
3961 d = cos(1.11);
3962 d = atan(1.11);
3963 ],
3964 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT_FUNCS),
3965 AC_MSG_RESULT(no))
3966
Bram Moolenaara6b89762016-02-29 21:38:26 +01003967dnl isinf() and isnan() need to include header files and may need -lm.
3968AC_MSG_CHECKING([for isinf()])
3969AC_TRY_LINK([
3970#ifdef HAVE_MATH_H
3971# include <math.h>
3972#endif
3973#if STDC_HEADERS
3974# include <stdlib.h>
3975# include <stddef.h>
3976#endif
3977], [int r = isinf(1.11); ],
3978 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISINF),
3979 AC_MSG_RESULT(no))
3980
3981AC_MSG_CHECKING([for isnan()])
3982AC_TRY_LINK([
3983#ifdef HAVE_MATH_H
3984# include <math.h>
3985#endif
3986#if STDC_HEADERS
3987# include <stdlib.h>
3988# include <stddef.h>
3989#endif
3990], [int r = isnan(1.11); ],
3991 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISNAN),
3992 AC_MSG_RESULT(no))
3993
Bram Moolenaar071d4272004-06-13 20:20:40 +00003994dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI
3995dnl when -lacl works, also try to use -lattr (required for Debian).
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003996dnl On Solaris, use the acl_get/set functions in libsec, if present.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003997AC_MSG_CHECKING(--disable-acl argument)
3998AC_ARG_ENABLE(acl,
Bram Moolenaard6d30422018-01-28 22:48:55 +01003999 [ --disable-acl No check for ACL support.],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004000 , [enable_acl="yes"])
4001if test "$enable_acl" = "yes"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01004002 AC_MSG_RESULT(no)
4003 AC_CHECK_LIB(posix1e, acl_get_file, [LIBS="$LIBS -lposix1e"],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004004 AC_CHECK_LIB(acl, acl_get_file, [LIBS="$LIBS -lacl"
4005 AC_CHECK_LIB(attr, fgetxattr, LIBS="$LIBS -lattr",,)],,),)
4006
Bram Moolenaard6d30422018-01-28 22:48:55 +01004007 AC_MSG_CHECKING(for POSIX ACL support)
4008 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00004009#include <sys/types.h>
4010#ifdef HAVE_SYS_ACL_H
4011# include <sys/acl.h>
4012#endif
4013acl_t acl;], [acl = acl_get_file("foo", ACL_TYPE_ACCESS);
4014 acl_set_file("foo", ACL_TYPE_ACCESS, acl);
4015 acl_free(acl);],
4016 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_ACL),
4017 AC_MSG_RESULT(no))
4018
Bram Moolenaard6d30422018-01-28 22:48:55 +01004019 AC_CHECK_LIB(sec, acl_get, [LIBS="$LIBS -lsec"; AC_DEFINE(HAVE_SOLARIS_ZFS_ACL)],
4020 AC_MSG_CHECKING(for Solaris ACL support)
4021 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00004022#ifdef HAVE_SYS_ACL_H
4023# include <sys/acl.h>
4024#endif], [acl("foo", GETACLCNT, 0, NULL);
4025 ],
4026 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOLARIS_ACL),
Bram Moolenaar8d462f92012-02-05 22:51:33 +01004027 AC_MSG_RESULT(no)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004028
Bram Moolenaard6d30422018-01-28 22:48:55 +01004029 AC_MSG_CHECKING(for AIX ACL support)
4030 AC_TRY_LINK([
Bram Moolenaar446cb832008-06-24 21:56:24 +00004031#if STDC_HEADERS
4032# include <stdlib.h>
4033# include <stddef.h>
4034#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004035#ifdef HAVE_SYS_ACL_H
4036# include <sys/acl.h>
4037#endif
4038#ifdef HAVE_SYS_ACCESS_H
4039# include <sys/access.h>
4040#endif
4041#define _ALL_SOURCE
4042
4043#include <sys/stat.h>
4044
4045int aclsize;
4046struct acl *aclent;], [aclsize = sizeof(struct acl);
4047 aclent = (void *)malloc(aclsize);
4048 statacl("foo", STX_NORMAL, aclent, aclsize);
4049 ],
4050 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_AIX_ACL),
4051 AC_MSG_RESULT(no))
4052else
4053 AC_MSG_RESULT(yes)
4054fi
4055
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02004056if test "x$GTK_CFLAGS" != "x"; then
4057 dnl pango_shape_full() is new, fall back to pango_shape().
4058 AC_MSG_CHECKING(for pango_shape_full)
4059 ac_save_CFLAGS="$CFLAGS"
4060 ac_save_LIBS="$LIBS"
4061 CFLAGS="$CFLAGS $GTK_CFLAGS"
4062 LIBS="$LIBS $GTK_LIBS"
Bram Moolenaar5325b9b2015-09-09 20:27:02 +02004063 AC_TRY_LINK(
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02004064 [#include <gtk/gtk.h>],
4065 [ pango_shape_full(NULL, 0, NULL, 0, NULL, NULL); ],
4066 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_PANGO_SHAPE_FULL),
4067 AC_MSG_RESULT(no))
4068 CFLAGS="$ac_save_CFLAGS"
4069 LIBS="$ac_save_LIBS"
4070fi
4071
Bram Moolenaar071d4272004-06-13 20:20:40 +00004072AC_MSG_CHECKING(--disable-gpm argument)
4073AC_ARG_ENABLE(gpm,
4074 [ --disable-gpm Don't use gpm (Linux mouse daemon).], ,
4075 [enable_gpm="yes"])
4076
4077if test "$enable_gpm" = "yes"; then
4078 AC_MSG_RESULT(no)
4079 dnl Checking if gpm support can be compiled
4080 AC_CACHE_CHECK([for gpm], vi_cv_have_gpm,
4081 [olibs="$LIBS" ; LIBS="-lgpm"]
4082 AC_TRY_LINK(
4083 [#include <gpm.h>
4084 #include <linux/keyboard.h>],
4085 [Gpm_GetLibVersion(NULL);],
4086 dnl Configure defines HAVE_GPM, if it is defined feature.h defines
4087 dnl FEAT_MOUSE_GPM if mouse support is included
4088 [vi_cv_have_gpm=yes],
4089 [vi_cv_have_gpm=no])
4090 [LIBS="$olibs"]
4091 )
4092 if test $vi_cv_have_gpm = yes; then
4093 LIBS="$LIBS -lgpm"
4094 AC_DEFINE(HAVE_GPM)
4095 fi
4096else
4097 AC_MSG_RESULT(yes)
4098fi
4099
Bram Moolenaar446cb832008-06-24 21:56:24 +00004100AC_MSG_CHECKING(--disable-sysmouse argument)
4101AC_ARG_ENABLE(sysmouse,
Bram Moolenaar8008b632017-07-18 21:33:20 +02004102 [ --disable-sysmouse Don't use sysmouse (mouse in *BSD console).], ,
Bram Moolenaar446cb832008-06-24 21:56:24 +00004103 [enable_sysmouse="yes"])
4104
4105if test "$enable_sysmouse" = "yes"; then
4106 AC_MSG_RESULT(no)
4107 dnl Checking if sysmouse support can be compiled
4108 dnl Configure defines HAVE_SYSMOUSE, if it is defined feature.h
4109 dnl defines FEAT_SYSMOUSE if mouse support is included
4110 AC_CACHE_CHECK([for sysmouse], vi_cv_have_sysmouse,
4111 AC_TRY_LINK(
4112 [#include <sys/consio.h>
4113 #include <signal.h>
4114 #include <sys/fbio.h>],
4115 [struct mouse_info mouse;
4116 mouse.operation = MOUSE_MODE;
4117 mouse.operation = MOUSE_SHOW;
4118 mouse.u.mode.mode = 0;
4119 mouse.u.mode.signal = SIGUSR2;],
4120 [vi_cv_have_sysmouse=yes],
4121 [vi_cv_have_sysmouse=no])
4122 )
4123 if test $vi_cv_have_sysmouse = yes; then
4124 AC_DEFINE(HAVE_SYSMOUSE)
4125 fi
4126else
4127 AC_MSG_RESULT(yes)
4128fi
4129
Bram Moolenaarf05da212009-11-17 16:13:15 +00004130dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
4131AC_MSG_CHECKING(for FD_CLOEXEC)
4132AC_TRY_COMPILE(
4133[#if HAVE_FCNTL_H
4134# include <fcntl.h>
4135#endif],
4136[ int flag = FD_CLOEXEC;],
4137 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
4138 AC_MSG_RESULT(not usable))
4139
Bram Moolenaar071d4272004-06-13 20:20:40 +00004140dnl rename needs to be checked separately to work on Nextstep with cc
4141AC_MSG_CHECKING(for rename)
4142AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
4143 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
4144 AC_MSG_RESULT(no))
4145
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004146dnl check for dirfd()
4147AC_MSG_CHECKING(for dirfd)
Bram Moolenaar9d8bfae2020-09-02 21:21:35 +02004148AC_TRY_LINK(
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004149[#include <sys/types.h>
4150#include <dirent.h>],
4151[DIR * dir=opendir("dirname"); dirfd(dir);],
4152AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DIRFD), AC_MSG_RESULT(not usable))
4153
4154dnl check for flock()
4155AC_MSG_CHECKING(for flock)
Bram Moolenaar9d8bfae2020-09-02 21:21:35 +02004156AC_TRY_LINK(
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004157[#include <sys/file.h>],
4158[flock(10, LOCK_SH);],
4159AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOCK), AC_MSG_RESULT(not usable))
4160
Bram Moolenaar071d4272004-06-13 20:20:40 +00004161dnl sysctl() may exist but not the arguments we use
4162AC_MSG_CHECKING(for sysctl)
4163AC_TRY_COMPILE(
4164[#include <sys/types.h>
4165#include <sys/sysctl.h>],
4166[ int mib[2], r;
4167 size_t len;
4168
4169 mib[0] = CTL_HW;
4170 mib[1] = HW_USERMEM;
4171 len = sizeof(r);
4172 (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
4173 ],
4174 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL),
4175 AC_MSG_RESULT(not usable))
4176
Bram Moolenaare2982d62021-10-06 11:27:21 +01004177dnl sysinfo() may exist but not be Linux compatible.
4178dnl On some FreeBSD systems it may depend on libsysinfo, use TRY_LINK
Bram Moolenaar071d4272004-06-13 20:20:40 +00004179AC_MSG_CHECKING(for sysinfo)
Bram Moolenaare2982d62021-10-06 11:27:21 +01004180AC_TRY_LINK(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004181[#include <sys/types.h>
4182#include <sys/sysinfo.h>],
4183[ struct sysinfo sinfo;
4184 int t;
4185
4186 (void)sysinfo(&sinfo);
4187 t = sinfo.totalram;
4188 ],
4189 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
4190 AC_MSG_RESULT(not usable))
4191
Bram Moolenaar914572a2007-05-01 11:37:47 +00004192dnl struct sysinfo may have the mem_unit field or not
4193AC_MSG_CHECKING(for sysinfo.mem_unit)
4194AC_TRY_COMPILE(
4195[#include <sys/types.h>
4196#include <sys/sysinfo.h>],
4197[ struct sysinfo sinfo;
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02004198 sinfo.mem_unit = 1;
Bram Moolenaar914572a2007-05-01 11:37:47 +00004199 ],
4200 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_MEM_UNIT),
4201 AC_MSG_RESULT(no))
4202
Bram Moolenaarf52f0602021-03-10 21:26:37 +01004203dnl struct sysinfo may have the uptime field or not
4204AC_MSG_CHECKING(for sysinfo.uptime)
4205AC_TRY_COMPILE(
4206[#include <sys/types.h>
4207#include <sys/sysinfo.h>],
4208[ struct sysinfo sinfo;
4209 long ut;
4210
4211 (void)sysinfo(&sinfo);
4212 ut = sinfo.uptime;
4213 ],
4214 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_UPTIME),
4215 AC_MSG_RESULT(no))
4216
Bram Moolenaar071d4272004-06-13 20:20:40 +00004217dnl sysconf() may exist but not support what we want to use
4218AC_MSG_CHECKING(for sysconf)
4219AC_TRY_COMPILE(
4220[#include <unistd.h>],
4221[ (void)sysconf(_SC_PAGESIZE);
4222 (void)sysconf(_SC_PHYS_PAGES);
4223 ],
4224 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
4225 AC_MSG_RESULT(not usable))
4226
Bram Moolenaar0e62a672021-02-25 17:17:56 +01004227dnl check if we have _SC_SIGSTKSZ via sysconf()
4228AC_MSG_CHECKING(for _SC_SIGSTKSZ via sysconf())
4229AC_TRY_COMPILE(
4230[#include <unistd.h>],
4231[ (void)sysconf(_SC_SIGSTKSZ);
4232 ],
4233 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF_SIGSTKSZ),
4234 AC_MSG_RESULT(not usable))
4235
Bram Moolenaar914703b2010-05-31 21:59:46 +02004236AC_CHECK_SIZEOF([int])
4237AC_CHECK_SIZEOF([long])
4238AC_CHECK_SIZEOF([time_t])
4239AC_CHECK_SIZEOF([off_t])
Bram Moolenaar644fdff2010-05-30 13:26:21 +02004240
Bram Moolenaara2aa31a2014-02-23 22:52:40 +01004241dnl Use different names to avoid clashing with other header files.
4242AC_DEFINE_UNQUOTED(VIM_SIZEOF_INT, [$ac_cv_sizeof_int])
4243AC_DEFINE_UNQUOTED(VIM_SIZEOF_LONG, [$ac_cv_sizeof_long])
4244
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004245dnl Make sure that uint32_t is really 32 bits unsigned.
4246AC_MSG_CHECKING([uint32_t is 32 bits])
4247AC_TRY_RUN([
4248#ifdef HAVE_STDINT_H
4249# include <stdint.h>
4250#endif
4251#ifdef HAVE_INTTYPES_H
4252# include <inttypes.h>
4253#endif
4254main() {
4255 uint32_t nr1 = (uint32_t)-1;
4256 uint32_t nr2 = (uint32_t)0xffffffffUL;
Bram Moolenaar52897832020-07-02 22:50:37 +02004257 if (sizeof(uint32_t) != 4 || nr1 != 0xffffffffUL || nr2 + 1 != 0) return 1;
4258 return 0;
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004259}],
4260AC_MSG_RESULT(ok),
4261AC_MSG_ERROR([WRONG! uint32_t not defined correctly.]),
Bram Moolenaar323cb952011-12-14 19:22:34 +01004262AC_MSG_WARN([cannot check uint32_t when cross-compiling.]))
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004263
Bram Moolenaar446cb832008-06-24 21:56:24 +00004264dnl Check for memmove() before bcopy(), makes memmove() be used when both are
4265dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
4266
Bram Moolenaar071d4272004-06-13 20:20:40 +00004267[bcopy_test_prog='
Bram Moolenaar446cb832008-06-24 21:56:24 +00004268#include "confdefs.h"
4269#ifdef HAVE_STRING_H
4270# include <string.h>
4271#endif
4272#if STDC_HEADERS
4273# include <stdlib.h>
4274# include <stddef.h>
4275#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004276main() {
4277 char buf[10];
4278 strcpy(buf, "abcdefghi");
4279 mch_memmove(buf, buf + 2, 3);
4280 if (strncmp(buf, "ababcf", 6))
4281 exit(1);
4282 strcpy(buf, "abcdefghi");
4283 mch_memmove(buf + 2, buf, 3);
4284 if (strncmp(buf, "cdedef", 6))
4285 exit(1);
4286 exit(0); /* libc version works properly. */
4287}']
4288
Bram Moolenaar446cb832008-06-24 21:56:24 +00004289AC_CACHE_CHECK([whether memmove handles overlaps],[vim_cv_memmove_handles_overlap],
4290 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004291 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 +00004292 [
4293 vim_cv_memmove_handles_overlap=yes
4294 ],[
4295 vim_cv_memmove_handles_overlap=no
4296 ],[
4297 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memmove_handles_overlap')
4298 ])
4299 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00004300
Bram Moolenaar446cb832008-06-24 21:56:24 +00004301if test "x$vim_cv_memmove_handles_overlap" = "xyes" ; then
4302 AC_DEFINE(USEMEMMOVE)
4303else
4304 AC_CACHE_CHECK([whether bcopy handles overlaps],[vim_cv_bcopy_handles_overlap],
4305 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004306 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 +00004307 [
4308 vim_cv_bcopy_handles_overlap=yes
4309 ],[
4310 vim_cv_bcopy_handles_overlap=no
4311 ],[
4312 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_bcopy_handles_overlap')
4313 ])
4314 ])
4315
4316 if test "x$vim_cv_bcopy_handles_overlap" = "xyes" ; then
4317 AC_DEFINE(USEBCOPY)
4318 else
4319 AC_CACHE_CHECK([whether memcpy handles overlaps],[vim_cv_memcpy_handles_overlap],
4320 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004321 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 +00004322 [
4323 vim_cv_memcpy_handles_overlap=yes
4324 ],[
4325 vim_cv_memcpy_handles_overlap=no
4326 ],[
4327 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memcpy_handles_overlap')
4328 ])
4329 ])
4330
4331 if test "x$vim_cv_memcpy_handles_overlap" = "xyes" ; then
4332 AC_DEFINE(USEMEMCPY)
4333 fi
4334 fi
4335fi
4336
Bram Moolenaar071d4272004-06-13 20:20:40 +00004337
4338dnl Check for multibyte locale functions
4339dnl Find out if _Xsetlocale() is supported by libX11.
4340dnl Check if X_LOCALE should be defined.
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004341if test "x$with_x" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004342 cflags_save=$CFLAGS
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004343 libs_save=$LIBS
4344 LIBS="$LIBS $X_LIBS $GUI_LIB_LOC $GUI_X_LIBS $X_PRE_LIBS $X_LIB $X_EXTRA_LIBS"
4345 CFLAGS="$CFLAGS $X_CFLAGS"
4346
4347 AC_MSG_CHECKING(whether X_LOCALE needed)
4348 AC_TRY_COMPILE([#include <X11/Xlocale.h>],,
4349 AC_TRY_LINK_FUNC([_Xsetlocale], [AC_MSG_RESULT(yes)
4350 AC_DEFINE(X_LOCALE)], AC_MSG_RESULT(no)),
4351 AC_MSG_RESULT(no))
4352
4353 AC_MSG_CHECKING(whether Xutf8SetWMProperties() can be used)
4354 AC_TRY_LINK_FUNC([Xutf8SetWMProperties], [AC_MSG_RESULT(yes)
4355 AC_DEFINE(HAVE_XUTF8SETWMPROPERTIES)], AC_MSG_RESULT(no))
4356
Bram Moolenaar071d4272004-06-13 20:20:40 +00004357 CFLAGS=$cflags_save
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004358 LIBS=$libs_save
Bram Moolenaar071d4272004-06-13 20:20:40 +00004359fi
4360
4361dnl Link with xpg4, it is said to make Korean locale working
4362AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,)
4363
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004364dnl Check how we can run ctags. Default to "ctags" when nothing works.
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02004365dnl Use --version to detect Exuberant ctags (preferred)
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004366dnl Add --fields=+S to get function signatures for omni completion.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004367dnl -t for typedefs (many ctags have this)
4368dnl -s for static functions (Elvis ctags only?)
4369dnl -v for variables. Dangerous, most ctags take this for 'vgrind style'.
4370dnl -i+m to test for older Exuberant ctags
4371AC_MSG_CHECKING(how to create tags)
4372test -f tags && mv tags tags.save
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004373if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004374 TAGPRG="ctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004375elif (eval exctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004376 TAGPRG="exctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004377elif (eval exuberant-ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004378 TAGPRG="exuberant-ctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004379else
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004380 TAGPRG="ctags"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004381 (eval etags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags"
4382 (eval etags -c /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags -c"
4383 (eval ctags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags"
4384 (eval ctags -t /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -t"
4385 (eval ctags -ts /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -ts"
4386 (eval ctags -tvs /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -tvs"
4387 (eval ctags -i+m /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -i+m"
4388fi
4389test -f tags.save && mv tags.save tags
4390AC_MSG_RESULT($TAGPRG) AC_SUBST(TAGPRG)
4391
4392dnl Check how we can run man with a section number
4393AC_MSG_CHECKING(how to run man with a section nr)
4394MANDEF="man"
Bram Moolenaar8b131502008-02-13 09:28:19 +00004395(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 +00004396AC_MSG_RESULT($MANDEF)
4397if test "$MANDEF" = "man -s"; then
4398 AC_DEFINE(USEMAN_S)
4399fi
4400
4401dnl Check if gettext() is working and if it needs -lintl
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004402dnl We take care to base this on an empty LIBS: on some systems libelf would be
4403dnl in LIBS and implicitly take along libintl. The final LIBS would then not
4404dnl contain libintl, and the link step would fail due to -Wl,--as-needed.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004405AC_MSG_CHECKING(--disable-nls argument)
4406AC_ARG_ENABLE(nls,
4407 [ --disable-nls Don't support NLS (gettext()).], ,
4408 [enable_nls="yes"])
4409
4410if test "$enable_nls" = "yes"; then
4411 AC_MSG_RESULT(no)
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00004412
4413 INSTALL_LANGS=install-languages
4414 AC_SUBST(INSTALL_LANGS)
4415 INSTALL_TOOL_LANGS=install-tool-languages
4416 AC_SUBST(INSTALL_TOOL_LANGS)
4417
Bram Moolenaar071d4272004-06-13 20:20:40 +00004418 AC_CHECK_PROG(MSGFMT, msgfmt, msgfmt, )
4419 AC_MSG_CHECKING([for NLS])
4420 if test -f po/Makefile; then
4421 have_gettext="no"
4422 if test -n "$MSGFMT"; then
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004423 olibs=$LIBS
4424 LIBS=""
Bram Moolenaar071d4272004-06-13 20:20:40 +00004425 AC_TRY_LINK(
4426 [#include <libintl.h>],
4427 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004428 AC_MSG_RESULT([gettext() works]); have_gettext="yes"; LIBS=$olibs,
4429 LIBS="-lintl"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004430 AC_TRY_LINK(
4431 [#include <libintl.h>],
4432 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004433 AC_MSG_RESULT([gettext() works with -lintl]); have_gettext="yes";
4434 LIBS="$olibs -lintl",
Bram Moolenaar071d4272004-06-13 20:20:40 +00004435 AC_MSG_RESULT([gettext() doesn't work]);
4436 LIBS=$olibs))
4437 else
4438 AC_MSG_RESULT([msgfmt not found - disabled]);
4439 fi
Bram Moolenaar278eb582014-07-30 13:22:52 +02004440 if test $have_gettext = "yes" -a "x$features" != "xtiny" -a "x$features" != "xsmall"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004441 AC_DEFINE(HAVE_GETTEXT)
4442 MAKEMO=yes
4443 AC_SUBST(MAKEMO)
4444 dnl this was added in GNU gettext 0.10.36
4445 AC_CHECK_FUNCS(bind_textdomain_codeset)
4446 dnl _nl_msg_cat_cntr is required for GNU gettext
4447 AC_MSG_CHECKING([for _nl_msg_cat_cntr])
4448 AC_TRY_LINK(
4449 [#include <libintl.h>
4450 extern int _nl_msg_cat_cntr;],
4451 [++_nl_msg_cat_cntr;],
4452 AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_NL_MSG_CAT_CNTR),
4453 AC_MSG_RESULT([no]))
Bram Moolenaar26096cc2019-04-11 15:25:40 +02004454 AC_MSG_CHECKING([if msgfmt supports --desktop])
4455 MSGFMT_DESKTOP=
4456 if "$MSGFMT" --help | grep -e '--desktop' >/dev/null; then
Bram Moolenaar62a88f42019-06-07 20:44:40 +02004457 if "$MSGFMT" --version | grep '0.19.[[3-7]]$' >/dev/null; then
4458 dnl GNU gettext 0.19.7's --desktop is broken. We assume back to
4459 dnl 0.19.3 is also broken.
4460 AC_MSG_RESULT([broken])
4461 else
4462 AC_MSG_RESULT([yes])
4463 MSGFMT_DESKTOP="gvim.desktop vim.desktop"
4464 fi
Bram Moolenaar26096cc2019-04-11 15:25:40 +02004465 else
4466 AC_MSG_RESULT([no])
4467 fi
4468 AC_SUBST(MSGFMT_DESKTOP)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004469 fi
4470 else
4471 AC_MSG_RESULT([no "po/Makefile" - disabled]);
4472 fi
4473else
4474 AC_MSG_RESULT(yes)
4475fi
4476
4477dnl Check for dynamic linking loader
4478AC_CHECK_HEADER(dlfcn.h, DLL=dlfcn.h, [AC_CHECK_HEADER(dl.h, DLL=dl.h)])
4479if test x${DLL} = xdlfcn.h; then
4480 AC_DEFINE(HAVE_DLFCN_H, 1, [ Define if we have dlfcn.h. ])
4481 AC_MSG_CHECKING([for dlopen()])
4482 AC_TRY_LINK(,[
4483 extern void* dlopen();
4484 dlopen();
4485 ],
4486 AC_MSG_RESULT(yes);
4487 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4488 AC_MSG_RESULT(no);
4489 AC_MSG_CHECKING([for dlopen() in -ldl])
4490 olibs=$LIBS
4491 LIBS="$LIBS -ldl"
4492 AC_TRY_LINK(,[
4493 extern void* dlopen();
4494 dlopen();
4495 ],
4496 AC_MSG_RESULT(yes);
4497 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4498 AC_MSG_RESULT(no);
4499 LIBS=$olibs))
4500 dnl ReliantUNIX has dlopen() in libc but everything else in libdl
4501 dnl ick :-)
4502 AC_MSG_CHECKING([for dlsym()])
4503 AC_TRY_LINK(,[
4504 extern void* dlsym();
4505 dlsym();
4506 ],
4507 AC_MSG_RESULT(yes);
4508 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4509 AC_MSG_RESULT(no);
4510 AC_MSG_CHECKING([for dlsym() in -ldl])
4511 olibs=$LIBS
4512 LIBS="$LIBS -ldl"
4513 AC_TRY_LINK(,[
4514 extern void* dlsym();
4515 dlsym();
4516 ],
4517 AC_MSG_RESULT(yes);
4518 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4519 AC_MSG_RESULT(no);
4520 LIBS=$olibs))
4521elif test x${DLL} = xdl.h; then
4522 AC_DEFINE(HAVE_DL_H, 1, [ Define if we have dl.h. ])
4523 AC_MSG_CHECKING([for shl_load()])
4524 AC_TRY_LINK(,[
4525 extern void* shl_load();
4526 shl_load();
4527 ],
4528 AC_MSG_RESULT(yes);
4529 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4530 AC_MSG_RESULT(no);
4531 AC_MSG_CHECKING([for shl_load() in -ldld])
4532 olibs=$LIBS
4533 LIBS="$LIBS -ldld"
4534 AC_TRY_LINK(,[
4535 extern void* shl_load();
4536 shl_load();
4537 ],
4538 AC_MSG_RESULT(yes);
4539 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4540 AC_MSG_RESULT(no);
4541 LIBS=$olibs))
4542fi
4543AC_CHECK_HEADERS(setjmp.h)
4544
Bram Moolenaard0573012017-10-28 21:11:06 +02004545if test "x$MACOS_X" = "xyes" -a -n "$PERL"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004546 dnl -ldl must come after DynaLoader.a
4547 if echo $LIBS | grep -e '-ldl' >/dev/null; then
4548 LIBS=`echo $LIBS | sed s/-ldl//`
4549 PERL_LIBS="$PERL_LIBS -ldl"
4550 fi
4551fi
4552
Bram Moolenaard0573012017-10-28 21:11:06 +02004553if test "$MACOS_X" = "yes"; then
4554 AC_MSG_CHECKING([whether we need macOS frameworks])
Bram Moolenaar097148e2020-08-11 21:58:20 +02004555 if test "$MACOS_X_DARWIN" = "yes"; then
Bram Moolenaard0573012017-10-28 21:11:06 +02004556 if test "$features" = "tiny"; then
4557 dnl Since no FEAT_CLIPBOARD, no longer need for os_macosx.m.
4558 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_macosx.m++'`
4559 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_macosx.o++'`
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01004560 AC_MSG_RESULT([yes, we need CoreServices])
4561 LIBS="$LIBS -framework CoreServices"
Bram Moolenaard0573012017-10-28 21:11:06 +02004562 else
4563 AC_MSG_RESULT([yes, we need AppKit])
4564 LIBS="$LIBS -framework AppKit"
Bram Moolenaard0573012017-10-28 21:11:06 +02004565 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004566 else
Bram Moolenaard0573012017-10-28 21:11:06 +02004567 AC_MSG_RESULT([no])
Bram Moolenaar3437b912013-07-03 19:52:53 +02004568 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004569fi
4570
Bram Moolenaar3ae5fc92021-09-06 18:57:30 +02004571dnl On some systems REENTRANT needs to be defined. It should not hurt to use
4572dnl it everywhere.
4573if `echo "$CFLAGS" | grep -v D_REENTRANT >/dev/null`; then
4574 CFLAGS="$CFLAGS -D_REENTRANT"
4575fi
4576
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004577dnl gcc 3.1 changed the meaning of -MM. The only solution appears to be to
4578dnl use "-isystem" instead of "-I" for all non-Vim include dirs.
4579dnl But only when making dependencies, cproto and lint don't take "-isystem".
Bram Moolenaar32466aa2006-02-24 23:53:04 +00004580dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
4581dnl the number before the version number.
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004582DEPEND_CFLAGS_FILTER=
4583if test "$GCC" = yes; then
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004584 AC_MSG_CHECKING(for GCC 3 or later)
Bram Moolenaar348808f2020-02-07 20:50:07 +01004585 gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]][[0-9]]*\)\..*$/\1/g'`
Bram Moolenaarf740b292006-02-16 22:11:02 +00004586 if test "$gccmajor" -gt "2"; then
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004587 DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004588 AC_MSG_RESULT(yes)
4589 else
4590 AC_MSG_RESULT(no)
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004591 fi
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004592 dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
4593 dnl declared as char x[1] but actually longer. Introduced in gcc 4.0.
Bram Moolenaar56d1db32009-12-16 16:14:51 +00004594 dnl Also remove duplicate _FORTIFY_SOURCE arguments.
Bram Moolenaaraeabe052011-12-08 15:17:34 +01004595 dnl And undefine it first to avoid a warning.
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004596 AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
4597 if test "$gccmajor" -gt "3"; then
Bram Moolenaar26f20132021-04-03 17:33:52 +02004598 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/'`
4599 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 +00004600 AC_MSG_RESULT(yes)
4601 else
4602 AC_MSG_RESULT(no)
4603 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +00004604fi
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004605AC_SUBST(DEPEND_CFLAGS_FILTER)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004606
Bram Moolenaarec0557f2018-01-31 14:41:37 +01004607dnl On some systems AC_SYS_LARGEFILE determines that -D_FILE_OFFSET_BITS=64
4608dnl isn't required, but the CFLAGS for some of the libraries we're using
4609dnl include the define. Since the define changes the size of some datatypes
4610dnl (e.g. ino_t and off_t), all of Vim's modules must be compiled with a
4611dnl consistent value. It's therefore safest to force the use of the define
4612dnl if it's present in any of the *_CFLAGS variables.
4613AC_MSG_CHECKING(whether we need to force -D_FILE_OFFSET_BITS=64)
Bram Moolenaar9ce42132018-04-11 22:19:36 +02004614if 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 +01004615 AC_MSG_RESULT(yes)
4616 AC_DEFINE(_FILE_OFFSET_BITS, 64)
4617else
4618 AC_MSG_RESULT(no)
4619fi
4620
Bram Moolenaar6cd42db2020-12-04 18:09:54 +01004621dnl $LDFLAGS is passed to glibtool in libvterm, it doesn't like a space
4622dnl between "-L" and the path that follows.
4623LDFLAGS=`echo "$LDFLAGS" | sed -e 's/-L /-L/g'`
4624
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004625dnl link.sh tries to avoid overlinking in a hackish way.
4626dnl At least GNU ld supports --as-needed which provides the same functionality
4627dnl at linker level. Let's use it.
4628AC_MSG_CHECKING(linker --as-needed support)
4629LINK_AS_NEEDED=
4630# Check if linker supports --as-needed and --no-as-needed options
4631if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
Natanael Copa761ead42021-05-15 14:25:37 +02004632 if ! echo "$LDFLAGS" | grep -q -- '-Wl,[[^[:space:]]]*--as-needed'; then
4633 LDFLAGS="$LDFLAGS -Wl,--as-needed"
4634 fi
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004635 LINK_AS_NEEDED=yes
4636fi
4637if test "$LINK_AS_NEEDED" = yes; then
4638 AC_MSG_RESULT(yes)
4639else
4640 AC_MSG_RESULT(no)
4641fi
4642AC_SUBST(LINK_AS_NEEDED)
4643
Bram Moolenaar77c19352012-06-13 19:19:41 +02004644# IBM z/OS reset CFLAGS for config.mk
4645if test "$zOSUnix" = "yes"; then
4646 CFLAGS="-D_ALL_SOURCE -Wc,float\(ieee\),dll"
4647fi
4648
Bram Moolenaar071d4272004-06-13 20:20:40 +00004649dnl write output files
4650AC_OUTPUT(auto/config.mk:config.mk.in)
4651
4652dnl vim: set sw=2 tw=78 fo+=l: