blob: 76eb56327cbf7ee519041fb586cc786094905b4f [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
Paul Ollis65745772022-06-05 16:55:54 +01003dnl Process this file with autoconf 2.69 to produce "configure".
4dnl This should also work with other versions of autoconf, but 2.70 and later
5dnl generate lots of hard to fix "obsolete" warnings.
Bram Moolenaar071d4272004-06-13 20:20:40 +00006
7AC_INIT(vim.h)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01008AC_CONFIG_HEADERS(auto/config.h:config.h.in)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009
10dnl Being able to run configure means the system is Unix (compatible).
11AC_DEFINE(UNIX)
12AC_PROG_MAKE_SET
13
14dnl Checks for programs.
Bram Moolenaar22640082018-04-19 20:39:41 +020015AC_PROG_CC_C99 dnl required by almost everything
Bram Moolenaarc0394412017-04-20 20:20:23 +020016AC_PROG_CPP dnl required by header file checks
17AC_PROGRAM_EGREP dnl required by AC_EGREP_CPP
18AC_PROG_FGREP dnl finds working grep -F
19AC_ISC_POSIX dnl required by AC_C_CROSS
20AC_PROG_AWK dnl required for "make html" in ../doc
Bram Moolenaar071d4272004-06-13 20:20:40 +000021
22dnl Don't strip if we don't have it
23AC_CHECK_PROG(STRIP, strip, strip, :)
24
Bram Moolenaar325b7a22004-07-05 15:58:32 +000025dnl Check for extension of executables
Bram Moolenaar071d4272004-06-13 20:20:40 +000026AC_EXEEXT
27
Bram Moolenaar446cb832008-06-24 21:56:24 +000028dnl Check for standard headers. We don't use this in Vim but other stuff
29dnl in autoconf needs it, where it uses STDC_HEADERS.
30AC_HEADER_STDC
31AC_HEADER_SYS_WAIT
32
Bram Moolenaar561f8a52018-04-17 22:02:45 +020033dnl Check that the C99 features that Vim uses are supported:
Bram Moolenaar22640082018-04-19 20:39:41 +020034if test x"$ac_cv_prog_cc_c99" != xno; then
35 dnl If the compiler doesn't explicitly support C99, then check
36 dnl for the specific features Vim uses
37
38 AC_TYPE_LONG_LONG_INT
39 if test "$ac_cv_type_long_long_int" = no; then
40 AC_MSG_FAILURE([Compiler does not support long long int])
41 fi
42
43 AC_MSG_CHECKING([if the compiler supports trailing commas])
44 trailing_commas=no
Bram Moolenaar1004b3d2022-06-05 19:51:55 +010045 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
Bram Moolenaar22640082018-04-19 20:39:41 +020046 enum {
47 one,
Bram Moolenaar1004b3d2022-06-05 19:51:55 +010048 };])],
Bram Moolenaar22640082018-04-19 20:39:41 +020049 [AC_MSG_RESULT(yes); trailing_commas=yes],
50 [AC_MSG_RESULT(no)])
51 if test "$trailing_commas" = no; then
52 AC_MSG_FAILURE([Compiler does not support trailing comma in enum])
53 fi
54
55 AC_MSG_CHECKING([if the compiler supports C++ comments])
56 slash_comments=no
Bram Moolenaar1004b3d2022-06-05 19:51:55 +010057 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
58 [// C++ comments?])],
Bram Moolenaar22640082018-04-19 20:39:41 +020059 [AC_MSG_RESULT(yes); slash_comments=yes],
60 [AC_MSG_RESULT(no)])
61 if test "$slash_comments" = no; then
62 AC_MSG_FAILURE([Compiler does not support C++ comments])
63 fi
64fi
Bram Moolenaar561f8a52018-04-17 22:02:45 +020065
Bram Moolenaar8f1dde52020-06-05 23:16:29 +020066dnl If $SOURCE_DATE_EPOCH is present in the environment, use that as the
67dnl "compiled" timestamp in :version's output. Attempt to get the formatted
68dnl date using GNU date syntax, BSD date syntax, and finally falling back to
69dnl just using the current time.
70if test -n "$SOURCE_DATE_EPOCH"; then
71 DATE_FMT="%b %d %Y %H:%M:%S"
72 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")
73 AC_DEFINE_UNQUOTED(BUILD_DATE, ["$BUILD_DATE"])
74 BUILD_DATE_MSG=-"echo -e '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\nNOTE: build date/time is fixed: $BUILD_DATE\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='"
75 AC_SUBST(BUILD_DATE_MSG)
76fi
77
Bram Moolenaarf788a062011-12-14 20:51:25 +010078dnl Check for the flag that fails if stuff are missing.
79
80AC_MSG_CHECKING(--enable-fail-if-missing argument)
81AC_ARG_ENABLE(fail_if_missing,
82 [ --enable-fail-if-missing Fail if dependencies on additional features
Bram Moolenaare5303952022-06-19 17:05:47 +010083 specified on the command line are missing.],
Bram Moolenaarf788a062011-12-14 20:51:25 +010084 [fail_if_missing="yes"],
85 [fail_if_missing="no"])
86AC_MSG_RESULT($fail_if_missing)
87
Bram Moolenaard2a05492018-07-27 22:35:15 +020088dnl Keep original value to check later.
89with_x_arg="$with_x"
90
Bram Moolenaar071d4272004-06-13 20:20:40 +000091dnl Set default value for CFLAGS if none is defined or it's empty
92if test -z "$CFLAGS"; then
93 CFLAGS="-O"
Bram Moolenaar4d8479b2021-01-31 14:36:06 +010094 test "$GCC" = yes && CFLAGS="-O2 -fno-strength-reduce -Wall -Wno-deprecated-declarations"
Bram Moolenaar071d4272004-06-13 20:20:40 +000095fi
96if test "$GCC" = yes; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +000097 dnl method that should work for nearly all versions
Bram Moolenaarc8836f72014-04-12 13:12:24 +020098 gccversion=`$CC -dumpversion`
Bram Moolenaar910f66f2006-04-05 20:41:53 +000099 if test "x$gccversion" = "x"; then
100 dnl old method; fall-back for when -dumpversion doesn't work
Bram Moolenaarc8836f72014-04-12 13:12:24 +0200101 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 +0000102 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +0000103 dnl version 4.0.1 was reported to cause trouble on Macintosh by Marcin Dalecki
104 if test "$gccversion" = "3.0.1" -o "$gccversion" = "3.0.2" -o "$gccversion" = "4.0.1"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000105 echo 'GCC [[34]].0.[[12]] has a bug in the optimizer, disabling "-O#"'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000106 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-O/'`
107 else
108 if test "$gccversion" = "3.1" -o "$gccversion" = "3.2" -o "$gccversion" = "3.2.1" && `echo "$CFLAGS" | grep -v fno-strength-reduce >/dev/null`; then
109 echo 'GCC 3.1 and 3.2 have a bug in the optimizer, adding "-fno-strength-reduce"'
110 CFLAGS="$CFLAGS -fno-strength-reduce"
111 fi
112 fi
113fi
114
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200115dnl clang-500.2.75 or around has abandoned -f[no-]strength-reduce and issues a
116dnl warning when that flag is passed to. Accordingly, adjust CFLAGS based on
117dnl the version number of the clang in use.
118dnl Note that this does not work to get the version of clang 3.1 or 3.2.
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100119AC_MSG_CHECKING(for clang version)
120CLANG_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 +0200121if test x"$CLANG_VERSION_STRING" != x"" ; then
122 CLANG_MAJOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*/\1/p'`
123 CLANG_MINOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/p'`
124 CLANG_REVISION=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)/\1/p'`
125 CLANG_VERSION=`expr $CLANG_MAJOR '*' 1000000 '+' $CLANG_MINOR '*' 1000 '+' $CLANG_REVISION`
126 AC_MSG_RESULT($CLANG_VERSION)
127 dnl If you find the same issue with versions earlier than 500.2.75,
128 dnl change the constant 500002075 below appropriately. To get the
129 dnl integer corresponding to a version number, refer to the
130 dnl definition of CLANG_VERSION above.
Bram Moolenaarebd211c2021-01-30 19:33:36 +0100131 dnl Clang 11 reports "11", assume Clang 10 and later work like this.
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100132 AC_MSG_CHECKING(if clang supports -fno-strength-reduce)
Bram Moolenaarebd211c2021-01-30 19:33:36 +0100133 if test "$CLANG_MAJOR" -ge 10 -o "$CLANG_VERSION" -ge 500002075 ; then
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100134 AC_MSG_RESULT(no)
135 CFLAGS=`echo "$CFLAGS" | sed -e 's/-fno-strength-reduce/ /'`
136 else
137 AC_MSG_RESULT(yes)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200138 fi
139else
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100140 AC_MSG_RESULT(N/A)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200141fi
142
Bram Moolenaar446cb832008-06-24 21:56:24 +0000143dnl If configure thinks we are cross compiling, there might be something
144dnl wrong with the CC or CFLAGS settings, give a useful warning message
Bram Moolenaar839e9542016-04-14 16:46:02 +0200145CROSS_COMPILING=
Bram Moolenaar071d4272004-06-13 20:20:40 +0000146if test "$cross_compiling" = yes; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000147 AC_MSG_RESULT([cannot compile a simple program; if not cross compiling check CC and CFLAGS])
Bram Moolenaar839e9542016-04-14 16:46:02 +0200148 CROSS_COMPILING=1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000149fi
Bram Moolenaar839e9542016-04-14 16:46:02 +0200150AC_SUBST(CROSS_COMPILING)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000151
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +0000152dnl gcc-cpp has the wonderful -MM option to produce nicer dependencies.
153dnl But gcc 3.1 changed the meaning! See near the end.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000154test "$GCC" = yes && CPP_MM=M; AC_SUBST(CPP_MM)
155
156if test -f ./toolcheck; then
Bram Moolenaar1004b3d2022-06-05 19:51:55 +0100157 AC_MSG_CHECKING(for buggy tools)
158 sh ./toolcheck 1>&AS_MESSAGE_FD
Bram Moolenaar071d4272004-06-13 20:20:40 +0000159fi
160
161OS_EXTRA_SRC=""; OS_EXTRA_OBJ=""
162
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000163dnl When cross-compiling set $vim_cv_uname_output, $vim_cv_uname_r_output and
164dnl $vim_cv_uname_m_output to the desired value for the target system
165AC_MSG_CHECKING(uname)
166if test "x$vim_cv_uname_output" = "x" ; then
167 vim_cv_uname_output=`(uname) 2>/dev/null`
168 AC_MSG_RESULT($vim_cv_uname_output)
169else
170 AC_MSG_RESULT([$vim_cv_uname_output (cached)])
171fi
172
173AC_MSG_CHECKING(uname -r)
174if test "x$vim_cv_uname_r_output" = "x" ; then
175 vim_cv_uname_r_output=`(uname -r) 2>/dev/null`
176 AC_MSG_RESULT($vim_cv_uname_r_output)
177else
178 AC_MSG_RESULT([$vim_cv_uname_r_output (cached)])
179fi
180
181AC_MSG_CHECKING(uname -m)
182if test "x$vim_cv_uname_m_output" = "x" ; then
183 vim_cv_uname_m_output=`(uname -m) 2>/dev/null`
184 AC_MSG_RESULT($vim_cv_uname_m_output)
185else
186 AC_MSG_RESULT([$vim_cv_uname_m_output (cached)])
187fi
188
Bram Moolenaarb3f74062020-02-26 16:16:53 +0100189AC_MSG_CHECKING(for Haiku)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000190case $vim_cv_uname_output in
Bram Moolenaarb3f74062020-02-26 16:16:53 +0100191 Haiku) HAIKU=yes; AC_MSG_RESULT(yes);;
192 *) HAIKU=no; AC_MSG_RESULT(no);;
193esac
194
Bram Moolenaar071d4272004-06-13 20:20:40 +0000195dnl If QNX is found, assume we don't want to use Xphoton
196dnl unless it was specifically asked for (--with-x)
197AC_MSG_CHECKING(for QNX)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000198case $vim_cv_uname_output in
Bram Moolenaar071d4272004-06-13 20:20:40 +0000199 QNX) OS_EXTRA_SRC=os_qnx.c; OS_EXTRA_OBJ=objects/os_qnx.o
200 test -z "$with_x" && with_x=no
201 QNX=yes; AC_MSG_RESULT(yes);;
202 *) QNX=no; AC_MSG_RESULT(no);;
203esac
204
205dnl Check for Darwin and MacOS X
206dnl We do a check for MacOS X in the very beginning because there
207dnl are a lot of other things we need to change besides GUI stuff
Bram Moolenaar071d4272004-06-13 20:20:40 +0000208AC_MSG_CHECKING([for Darwin (Mac OS X)])
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000209if test "$vim_cv_uname_output" = Darwin; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000210 AC_MSG_RESULT(yes)
Bram Moolenaard0573012017-10-28 21:11:06 +0200211 MACOS_X=yes
Bram Moolenaar52ecaaa2018-05-12 21:38:13 +0200212 CPPFLAGS="$CPPFLAGS -DMACOS_X"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000213
214 AC_MSG_CHECKING(--disable-darwin argument)
215 AC_ARG_ENABLE(darwin,
216 [ --disable-darwin Disable Darwin (Mac OS X) support.],
217 , [enable_darwin="yes"])
218 if test "$enable_darwin" = "yes"; then
219 AC_MSG_RESULT(no)
220 AC_MSG_CHECKING(if Darwin files are there)
Bram Moolenaar164fca32010-07-14 13:58:07 +0200221 if test -f os_macosx.m; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000222 AC_MSG_RESULT(yes)
223 else
224 AC_MSG_RESULT([no, Darwin support disabled])
225 enable_darwin=no
226 fi
227 else
228 AC_MSG_RESULT([yes, Darwin support excluded])
229 fi
230
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000231 AC_MSG_CHECKING(--with-mac-arch argument)
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000232 AC_ARG_WITH(mac-arch, [ --with-mac-arch=ARCH current, intel, ppc or both],
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000233 MACARCH="$withval"; AC_MSG_RESULT($MACARCH),
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000234 MACARCH="current"; AC_MSG_RESULT(defaulting to $MACARCH))
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000235
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100236 AC_MSG_CHECKING(--with-developer-dir argument)
237 AC_ARG_WITH(developer-dir, [ --with-developer-dir=PATH use PATH as location for Xcode developer tools],
238 DEVELOPER_DIR="$withval"; AC_MSG_RESULT($DEVELOPER_DIR),
Bram Moolenaar32d03b32015-11-19 13:46:48 +0100239 AC_MSG_RESULT(not present))
Bram Moolenaare5303952022-06-19 17:05:47 +0100240
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100241 if test "x$DEVELOPER_DIR" = "x"; then
242 AC_PATH_PROG(XCODE_SELECT, xcode-select)
243 if test "x$XCODE_SELECT" != "x"; then
244 AC_MSG_CHECKING(for developer dir using xcode-select)
245 DEVELOPER_DIR=`$XCODE_SELECT -print-path`
246 AC_MSG_RESULT([$DEVELOPER_DIR])
247 else
248 DEVELOPER_DIR=/Developer
249 fi
250 fi
251
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000252 if test "x$MACARCH" = "xboth"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000253 AC_MSG_CHECKING(for 10.4 universal SDK)
254 dnl There is a terrible inconsistency (but we appear to get away with it):
255 dnl $CFLAGS uses the 10.4u SDK library for the headers, while $CPPFLAGS
256 dnl doesn't, because "gcc -E" doesn't grok it. That means the configure
257 dnl tests using the preprocessor are actually done with the wrong header
258 dnl files. $LDFLAGS is set at the end, because configure uses it together
259 dnl with $CFLAGS and we can only have one -sysroot argument.
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000260 save_cppflags="$CPPFLAGS"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000261 save_cflags="$CFLAGS"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000262 save_ldflags="$LDFLAGS"
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100263 CFLAGS="$CFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +0100264 AC_LINK_IFELSE([AC_LANG_PROGRAM([ ], [ ])],
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000265 AC_MSG_RESULT(found, will make universal binary),
266
267 AC_MSG_RESULT(not found)
Bram Moolenaar1f35bf92006-03-07 22:38:47 +0000268 CFLAGS="$save_cflags"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000269 AC_MSG_CHECKING(if Intel architecture is supported)
270 CPPFLAGS="$CPPFLAGS -arch i386"
271 LDFLAGS="$save_ldflags -arch i386"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +0100272 AC_LINK_IFELSE([AC_LANG_PROGRAM([ ], [ ])],
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000273 AC_MSG_RESULT(yes); MACARCH="intel",
274 AC_MSG_RESULT(no, using PowerPC)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000275 MACARCH="ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000276 CPPFLAGS="$save_cppflags -arch ppc"
277 LDFLAGS="$save_ldflags -arch ppc"))
278 elif test "x$MACARCH" = "xintel"; then
279 CPPFLAGS="$CPPFLAGS -arch intel"
280 LDFLAGS="$LDFLAGS -arch intel"
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000281 elif test "x$MACARCH" = "xppc"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000282 CPPFLAGS="$CPPFLAGS -arch ppc"
283 LDFLAGS="$LDFLAGS -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000284 fi
285
Bram Moolenaar071d4272004-06-13 20:20:40 +0000286 if test "$enable_darwin" = "yes"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200287 MACOS_X_DARWIN=yes
Bram Moolenaar164fca32010-07-14 13:58:07 +0200288 OS_EXTRA_SRC="os_macosx.m os_mac_conv.c";
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000289 OS_EXTRA_OBJ="objects/os_macosx.o objects/os_mac_conv.o"
Bram Moolenaare5303952022-06-19 17:05:47 +0100290 dnl os_macosx.m implements timer_create() and friends
291 AC_DEFINE(HAVE_TIMER_CREATE)
Bram Moolenaar32466aa2006-02-24 23:53:04 +0000292 dnl TODO: use -arch i386 on Intel machines
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100293 dnl Removed -no-cpp-precomp, only for very old compilers.
Bram Moolenaard0573012017-10-28 21:11:06 +0200294 CPPFLAGS="$CPPFLAGS -DMACOS_X_DARWIN"
Bram Moolenaar040f9752020-08-11 23:08:48 +0200295
296 dnl Assume we don't want X11 unless it was specifically asked for
Bram Moolenaar0b40d082022-03-08 13:32:37 +0000297 dnl (--with-x) or Motif or GTK GUI is used.
298 if test -z "$with_x" -a "X$enable_gui" != Xmotif -a "X$enable_gui" != Xgtk2 -a "X$enable_gui" != Xgtk3; then
Bram Moolenaar040f9752020-08-11 23:08:48 +0200299 with_x=no
300 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000301 fi
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000302
Bram Moolenaardb552d602006-03-23 22:59:57 +0000303 dnl Avoid a bug with -O2 with gcc 4.0.1. Symptom: malloc() reports double
Bram Moolenaarfd2ac762006-03-01 22:09:21 +0000304 dnl free. This happens in expand_filename(), because the optimizer swaps
Bram Moolenaardb552d602006-03-23 22:59:57 +0000305 dnl two blocks of code, both using "repl", that can't be swapped.
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000306 if test "$MACARCH" = "intel" -o "$MACARCH" = "both"; then
307 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-Oz/'`
308 fi
309
Bram Moolenaar071d4272004-06-13 20:20:40 +0000310else
311 AC_MSG_RESULT(no)
312fi
313
Bram Moolenaar39766a72013-11-03 00:41:00 +0100314dnl Mac OS X 10.9+ no longer include AvailabilityMacros.h in Carbon
315dnl so we need to include it to have access to version macros.
Bram Moolenaar18e54692013-11-03 20:26:31 +0100316AC_CHECK_HEADERS(AvailabilityMacros.h)
Bram Moolenaar39766a72013-11-03 00:41:00 +0100317
Bram Moolenaar071d4272004-06-13 20:20:40 +0000318AC_SUBST(OS_EXTRA_SRC)
319AC_SUBST(OS_EXTRA_OBJ)
320
321dnl Add /usr/local/lib to $LDFLAGS and /usr/local/include to CFLAGS.
322dnl Only when the directory exists and it wasn't there yet.
323dnl For gcc don't do this when it is already in the default search path.
Bram Moolenaar446cb832008-06-24 21:56:24 +0000324dnl Skip all of this when cross-compiling.
325if test "$cross_compiling" = no; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000326 AC_MSG_CHECKING(--with-local-dir argument)
Bram Moolenaar446cb832008-06-24 21:56:24 +0000327 have_local_include=''
328 have_local_lib=''
Bram Moolenaarc236c162008-07-13 17:41:49 +0000329 AC_ARG_WITH([local-dir], [ --with-local-dir=PATH search PATH instead of /usr/local for local libraries.
330 --without-local-dir do not search /usr/local for local libraries.], [
331 local_dir="$withval"
332 case "$withval" in
333 */*) ;;
334 no)
335 # avoid adding local dir to LDFLAGS and CPPFLAGS
Bram Moolenaare06c1882010-07-21 22:05:20 +0200336 have_local_include=yes
Bram Moolenaarc236c162008-07-13 17:41:49 +0000337 have_local_lib=yes
338 ;;
339 *) AC_MSG_ERROR(must pass path argument to --with-local-dir) ;;
340 esac
341 AC_MSG_RESULT($local_dir)
342 ], [
343 local_dir=/usr/local
344 AC_MSG_RESULT(Defaulting to $local_dir)
345 ])
346 if test "$GCC" = yes -a "$local_dir" != no; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000347 echo 'void f(){}' > conftest.c
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100348 dnl Removed -no-cpp-precomp, only needed for OS X 10.2 (Ben Fowler)
349 have_local_include=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/include"`
Bram Moolenaarc236c162008-07-13 17:41:49 +0000350 have_local_lib=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/lib"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000351 rm -f conftest.c conftest.o
Bram Moolenaar071d4272004-06-13 20:20:40 +0000352 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000353 if test -z "$have_local_lib" -a -d "${local_dir}/lib"; then
354 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 +0000355 if test "$tt" = "$LDFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000356 LDFLAGS="$LDFLAGS -L${local_dir}/lib"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000357 fi
358 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000359 if test -z "$have_local_include" -a -d "${local_dir}/include"; then
360 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 +0000361 if test "$tt" = "$CPPFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000362 CPPFLAGS="$CPPFLAGS -I${local_dir}/include"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000363 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000364 fi
365fi
366
367AC_MSG_CHECKING(--with-vim-name argument)
368AC_ARG_WITH(vim-name, [ --with-vim-name=NAME what to call the Vim executable],
369 VIMNAME="$withval"; AC_MSG_RESULT($VIMNAME),
Bram Moolenaare344bea2005-09-01 20:46:49 +0000370 VIMNAME="vim"; AC_MSG_RESULT(Defaulting to $VIMNAME))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000371AC_SUBST(VIMNAME)
372AC_MSG_CHECKING(--with-ex-name argument)
373AC_ARG_WITH(ex-name, [ --with-ex-name=NAME what to call the Ex executable],
374 EXNAME="$withval"; AC_MSG_RESULT($EXNAME),
375 EXNAME="ex"; AC_MSG_RESULT(Defaulting to ex))
376AC_SUBST(EXNAME)
377AC_MSG_CHECKING(--with-view-name argument)
378AC_ARG_WITH(view-name, [ --with-view-name=NAME what to call the View executable],
379 VIEWNAME="$withval"; AC_MSG_RESULT($VIEWNAME),
380 VIEWNAME="view"; AC_MSG_RESULT(Defaulting to view))
381AC_SUBST(VIEWNAME)
382
383AC_MSG_CHECKING(--with-global-runtime argument)
Bram Moolenaar9d302ad2018-12-21 11:48:51 +0100384AC_ARG_WITH(global-runtime, [ --with-global-runtime=DIR global runtime directory in 'runtimepath', comma-separated for multiple directories],
385 RUNTIME_GLOBAL="$withval"; AC_MSG_RESULT($withval),
Bram Moolenaar071d4272004-06-13 20:20:40 +0000386 AC_MSG_RESULT(no))
387
Bram Moolenaar9d302ad2018-12-21 11:48:51 +0100388if test "X$RUNTIME_GLOBAL" != "X"; then
389 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" }')
390 AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL, "$RUNTIME_GLOBAL")
391 AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL_AFTER, "$RUNTIME_GLOBAL_AFTER")
392fi
393
Bram Moolenaar071d4272004-06-13 20:20:40 +0000394AC_MSG_CHECKING(--with-modified-by argument)
395AC_ARG_WITH(modified-by, [ --with-modified-by=NAME name of who modified a release version],
396 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(MODIFIED_BY, "$withval"),
397 AC_MSG_RESULT(no))
398
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200399dnl Check for EBCDIC stolen from the LYNX port to z/OS Unix
Bram Moolenaar071d4272004-06-13 20:20:40 +0000400AC_MSG_CHECKING(if character set is EBCDIC)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +0100401AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ ],
Bram Moolenaar071d4272004-06-13 20:20:40 +0000402[ /* TryCompile function for CharSet.
403 Treat any failure as ASCII for compatibility with existing art.
404 Use compile-time rather than run-time tests for cross-compiler
405 tolerance. */
406#if '0'!=240
407make an error "Character set is not EBCDIC"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +0100408#endif ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +0000409[ # TryCompile action if true
410cf_cv_ebcdic=yes ],
411[ # TryCompile action if false
412cf_cv_ebcdic=no])
413# end of TryCompile ])
414# end of CacheVal CvEbcdic
415AC_MSG_RESULT($cf_cv_ebcdic)
416case "$cf_cv_ebcdic" in #(vi
417 yes) AC_DEFINE(EBCDIC)
418 line_break='"\\n"'
419 ;;
420 *) line_break='"\\012"';;
421esac
422AC_SUBST(line_break)
423
424if test "$cf_cv_ebcdic" = "yes"; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +0200425dnl If we have EBCDIC we most likely have z/OS Unix, let's test it!
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200426AC_MSG_CHECKING(for z/OS Unix)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000427case $vim_cv_uname_output in
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200428 OS/390) zOSUnix="yes";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000429 dnl If using cc the environment variable _CC_CCMODE must be
430 dnl set to "1", so that some compiler extensions are enabled.
431 dnl If using c89 the environment variable is named _CC_C89MODE.
432 dnl Note: compile with c89 never tested.
433 if test "$CC" = "cc"; then
434 ccm="$_CC_CCMODE"
435 ccn="CC"
436 else
437 if test "$CC" = "c89"; then
438 ccm="$_CC_C89MODE"
439 ccn="C89"
440 else
441 ccm=1
442 fi
443 fi
444 if test "$ccm" != "1"; then
445 echo ""
446 echo "------------------------------------------"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200447 echo " On z/OS Unix, the environment variable"
Bram Moolenaar77c19352012-06-13 19:19:41 +0200448 echo " _CC_${ccn}MODE must be set to \"1\"!"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000449 echo " Do:"
450 echo " export _CC_${ccn}MODE=1"
451 echo " and then call configure again."
452 echo "------------------------------------------"
453 exit 1
454 fi
Bram Moolenaar77c19352012-06-13 19:19:41 +0200455 # Set CFLAGS for configure process.
456 # This will be reset later for config.mk.
457 # Use haltonmsg to force error for missing H files.
458 CFLAGS="$CFLAGS -D_ALL_SOURCE -Wc,float(ieee),haltonmsg(3296)";
459 LDFLAGS="$LDFLAGS -Wl,EDIT=NO"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000460 AC_MSG_RESULT(yes)
461 ;;
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200462 *) zOSUnix="no";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000463 AC_MSG_RESULT(no)
464 ;;
465esac
466fi
467
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200468dnl Set QUOTESED. Needs additional backslashes on zOS
469if test "$zOSUnix" = "yes"; then
Bram Moolenaarabcbb0e2020-12-23 12:33:42 +0100470 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\\\\\&/g' -e 's/\\\\\\\\\"/\"/' -e 's/\\\\\\\\\";\$\$/\";/' -e 's/ */ /g'"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200471else
Bram Moolenaarabcbb0e2020-12-23 12:33:42 +0100472 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\&/g' -e 's/\\\\\"/\"/' -e 's/\\\\\";\$\$/\";/' -e 's/ */ /g'"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200473fi
474AC_SUBST(QUOTESED)
475
476
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200477dnl Link with -lsmack for Smack stuff; if not found
478AC_MSG_CHECKING(--disable-smack argument)
479AC_ARG_ENABLE(smack,
480 [ --disable-smack Do not check for Smack support.],
481 , enable_smack="yes")
482if test "$enable_smack" = "yes"; then
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200483 AC_MSG_RESULT(no)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200484 AC_CHECK_HEADER([linux/xattr.h], true, enable_smack="no")
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200485else
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200486 AC_MSG_RESULT(yes)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200487fi
488if test "$enable_smack" = "yes"; then
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200489 AC_CHECK_HEADER([attr/xattr.h], true, enable_smack="no")
490fi
491if test "$enable_smack" = "yes"; then
492 AC_MSG_CHECKING(for XATTR_NAME_SMACKEXEC in linux/xattr.h)
493 AC_EGREP_CPP(XATTR_NAME_SMACKEXEC, [#include <linux/xattr.h>],
494 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +0200495 AC_MSG_RESULT(no); enable_smack="no")
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200496fi
497if test "$enable_smack" = "yes"; then
498 AC_CHECK_LIB(attr, setxattr,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200499 [LIBS="$LIBS -lattr"
500 found_smack="yes"
501 AC_DEFINE(HAVE_SMACK)])
Bram Moolenaar588ebeb2008-05-07 17:09:24 +0000502fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000503
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200504dnl When smack was found don't search for SELinux
505if test "x$found_smack" = "x"; then
506 dnl Link with -lselinux for SELinux stuff; if not found
507 AC_MSG_CHECKING(--disable-selinux argument)
508 AC_ARG_ENABLE(selinux,
509 [ --disable-selinux Do not check for SELinux support.],
510 , enable_selinux="yes")
511 if test "$enable_selinux" = "yes"; then
512 AC_MSG_RESULT(no)
513 AC_CHECK_LIB(selinux, is_selinux_enabled,
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100514 [AC_CHECK_HEADER(selinux/selinux.h,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200515 [LIBS="$LIBS -lselinux"
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100516 AC_DEFINE(HAVE_SELINUX)])])
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200517 else
518 AC_MSG_RESULT(yes)
519 fi
520fi
521
Bram Moolenaar071d4272004-06-13 20:20:40 +0000522dnl Check user requested features.
523
524AC_MSG_CHECKING(--with-features argument)
Bram Moolenaareec29812016-07-26 21:27:36 +0200525AC_ARG_WITH(features, [ --with-features=TYPE tiny, small, normal, big or huge (default: huge)],
Bram Moolenaar071d4272004-06-13 20:20:40 +0000526 features="$withval"; AC_MSG_RESULT($features),
Bram Moolenaar23c4f712016-01-20 22:11:59 +0100527 features="huge"; AC_MSG_RESULT(Defaulting to huge))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000528
529dovimdiff=""
530dogvimdiff=""
531case "$features" in
532 tiny) AC_DEFINE(FEAT_TINY) ;;
533 small) AC_DEFINE(FEAT_SMALL) ;;
534 normal) AC_DEFINE(FEAT_NORMAL) dovimdiff="installvimdiff";
535 dogvimdiff="installgvimdiff" ;;
536 big) AC_DEFINE(FEAT_BIG) dovimdiff="installvimdiff";
537 dogvimdiff="installgvimdiff" ;;
538 huge) AC_DEFINE(FEAT_HUGE) dovimdiff="installvimdiff";
539 dogvimdiff="installgvimdiff" ;;
540 *) AC_MSG_RESULT([Sorry, $features is not supported]) ;;
541esac
542
543AC_SUBST(dovimdiff)
544AC_SUBST(dogvimdiff)
545
Bram Moolenaar12471262022-01-18 11:11:25 +0000546if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
547 has_eval=no
548else
549 has_eval=yes
550fi
551
Bram Moolenaar071d4272004-06-13 20:20:40 +0000552AC_MSG_CHECKING(--with-compiledby argument)
553AC_ARG_WITH(compiledby, [ --with-compiledby=NAME name to show in :version message],
554 compiledby="$withval"; AC_MSG_RESULT($withval),
555 compiledby=""; AC_MSG_RESULT(no))
556AC_SUBST(compiledby)
557
558AC_MSG_CHECKING(--disable-xsmp argument)
559AC_ARG_ENABLE(xsmp,
560 [ --disable-xsmp Disable XSMP session management],
561 , enable_xsmp="yes")
562
563if test "$enable_xsmp" = "yes"; then
564 AC_MSG_RESULT(no)
565 AC_MSG_CHECKING(--disable-xsmp-interact argument)
566 AC_ARG_ENABLE(xsmp-interact,
567 [ --disable-xsmp-interact Disable XSMP interaction],
568 , enable_xsmp_interact="yes")
569 if test "$enable_xsmp_interact" = "yes"; then
570 AC_MSG_RESULT(no)
571 AC_DEFINE(USE_XSMP_INTERACT)
572 else
573 AC_MSG_RESULT(yes)
574 fi
575else
576 AC_MSG_RESULT(yes)
577fi
578
Bram Moolenaar67ffb412022-01-08 13:36:57 +0000579AC_MSG_CHECKING([diff feature])
580if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
581 AC_MSG_RESULT([disabled in $features version])
582else
583 AC_MSG_RESULT(enabled)
584 AC_DEFINE(FEAT_DIFF)
585 XDIFF_OBJS_USED="\$(XDIFF_OBJS)"
586 AC_SUBST(XDIFF_OBJS_USED)
587fi
588
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200589dnl Check for Lua feature.
590AC_MSG_CHECKING(--enable-luainterp argument)
591AC_ARG_ENABLE(luainterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200592 [ --enable-luainterp[=OPTS] Include Lua interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200593 [enable_luainterp="no"])
594AC_MSG_RESULT($enable_luainterp)
595
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200596if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then
Bram Moolenaar12471262022-01-18 11:11:25 +0000597 if test "$has_eval" = "no"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +0100598 AC_MSG_ERROR([cannot use Lua with tiny or small features])
599 fi
600
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200601 dnl -- find the lua executable
602 AC_SUBST(vi_cv_path_lua)
603
604 AC_MSG_CHECKING(--with-lua-prefix argument)
605 AC_ARG_WITH(lua_prefix,
606 [ --with-lua-prefix=PFX Prefix where Lua is installed.],
607 with_lua_prefix="$withval"; AC_MSG_RESULT($with_lua_prefix),
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200608 with_lua_prefix="";AC_MSG_RESULT(no))
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200609
610 if test "X$with_lua_prefix" != "X"; then
611 vi_cv_path_lua_pfx="$with_lua_prefix"
612 else
613 AC_MSG_CHECKING(LUA_PREFIX environment var)
614 if test "X$LUA_PREFIX" != "X"; then
615 AC_MSG_RESULT("$LUA_PREFIX")
616 vi_cv_path_lua_pfx="$LUA_PREFIX"
617 else
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200618 AC_MSG_RESULT([not set, default to /usr])
619 vi_cv_path_lua_pfx="/usr"
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200620 fi
621 fi
622
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200623 AC_MSG_CHECKING(--with-luajit)
624 AC_ARG_WITH(luajit,
625 [ --with-luajit Link with LuaJIT instead of Lua.],
626 [vi_cv_with_luajit="$withval"],
627 [vi_cv_with_luajit="no"])
628 AC_MSG_RESULT($vi_cv_with_luajit)
629
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200630 LUA_INC=
631 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200632 if test "x$vi_cv_with_luajit" != "xno"; then
633 dnl -- try to find LuaJIT executable
634 AC_PATH_PROG(vi_cv_path_luajit, luajit)
635 if test "X$vi_cv_path_luajit" != "X"; then
636 dnl -- find LuaJIT version
637 AC_CACHE_CHECK(LuaJIT version, vi_cv_version_luajit,
Bram Moolenaar49b10272013-11-21 12:17:51 +0100638 [ 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 +0200639 AC_CACHE_CHECK(Lua version of LuaJIT, vi_cv_version_lua_luajit,
640 [ vi_cv_version_lua_luajit=`${vi_cv_path_luajit} -e "print(_VERSION)" | sed 's/.* //'` ])
641 vi_cv_path_lua="$vi_cv_path_luajit"
642 vi_cv_version_lua="$vi_cv_version_lua_luajit"
643 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200644 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200645 dnl -- try to find Lua executable
646 AC_PATH_PROG(vi_cv_path_plain_lua, lua)
647 if test "X$vi_cv_path_plain_lua" != "X"; then
648 dnl -- find Lua version
649 AC_CACHE_CHECK(Lua version, vi_cv_version_plain_lua,
650 [ vi_cv_version_plain_lua=`${vi_cv_path_plain_lua} -e "print(_VERSION)" | sed 's/.* //'` ])
651 fi
652 vi_cv_path_lua="$vi_cv_path_plain_lua"
653 vi_cv_version_lua="$vi_cv_version_plain_lua"
654 fi
655 if test "x$vi_cv_with_luajit" != "xno" && test "X$vi_cv_version_luajit" != "X"; then
656 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 +0100657 if test -f "$vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200658 AC_MSG_RESULT(yes)
659 LUA_INC=/luajit-$vi_cv_version_luajit
660 fi
661 fi
662 if test "X$LUA_INC" = "X"; then
663 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)
Bram Moolenaar49222be2015-12-11 18:11:30 +0100664 if test -f "$vi_cv_path_lua_pfx/include/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200665 AC_MSG_RESULT(yes)
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200666 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200667 AC_MSG_RESULT(no)
668 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 +0100669 if test -f "$vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200670 AC_MSG_RESULT(yes)
671 LUA_INC=/lua$vi_cv_version_lua
672 else
673 AC_MSG_RESULT(no)
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200674
675 # Detect moonjit:
676 # https://groups.google.com/forum/#!topic/vim_use/O0vek60WuTk
677 lua_suf=/moonjit-2.3
678 inc_path="$vi_cv_path_lua_pfx/include"
Bram Moolenaarad4dc832020-04-20 16:21:53 +0200679 for dir in "$inc_path"/moonjit-[[0-9]]* ; do
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200680 if test -d "$dir" ; then
Bram Moolenaara79a8942020-12-17 20:50:25 +0100681 lua_suf=`basename "$dir"`
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200682 lua_suf="/$lua_suf"
683 break
684 fi
685 done
686 AC_MSG_CHECKING(if lua.h can be found in $inc_path$lua_suf)
687 if test -f "$inc_path$lua_suf/lua.h"; then
688 AC_MSG_RESULT(yes)
689 LUA_INC=$lua_suf
690 else
691 AC_MSG_RESULT(no)
692 vi_cv_path_lua_pfx=
693 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200694 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200695 fi
696 fi
697 fi
698
699 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200700 if test "x$vi_cv_with_luajit" != "xno"; then
701 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
702 if test "X$multiarch" != "X"; then
703 lib_multiarch="lib/${multiarch}"
704 else
705 lib_multiarch="lib"
706 fi
707 if test "X$vi_cv_version_lua" = "X"; then
708 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit"
709 else
710 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit-$vi_cv_version_lua"
711 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200712 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200713 if test "X$LUA_INC" != "X"; then
714 dnl Test alternate location using version
715 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua$vi_cv_version_lua"
716 else
717 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua"
718 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200719 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200720 if test "$enable_luainterp" = "dynamic"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200721 lua_ok="yes"
722 else
723 AC_MSG_CHECKING([if link with ${LUA_LIBS} is sane])
724 libs_save=$LIBS
725 LIBS="$LIBS $LUA_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +0100726 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200727 AC_MSG_RESULT(yes); lua_ok="yes",
728 AC_MSG_RESULT(no); lua_ok="no"; LUA_LIBS="")
729 LIBS=$libs_save
730 fi
731 if test "x$lua_ok" = "xyes"; then
732 LUA_CFLAGS="-I${vi_cv_path_lua_pfx}/include${LUA_INC}"
733 LUA_SRC="if_lua.c"
734 LUA_OBJ="objects/if_lua.o"
735 LUA_PRO="if_lua.pro"
736 AC_DEFINE(FEAT_LUA)
737 fi
738 if test "$enable_luainterp" = "dynamic"; then
739 if test "x$vi_cv_with_luajit" != "xno"; then
740 luajit="jit"
741 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200742 if test -f "${vi_cv_path_lua_pfx}/bin/cyglua-${vi_cv_version_lua}.dll"; then
743 vi_cv_dll_name_lua="cyglua-${vi_cv_version_lua}.dll"
744 else
Bram Moolenaard0573012017-10-28 21:11:06 +0200745 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200746 ext="dylib"
747 indexes=""
748 else
749 ext="so"
750 indexes=".0 .1 .2 .3 .4 .5 .6 .7 .8 .9"
751 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
752 if test "X$multiarch" != "X"; then
753 lib_multiarch="lib/${multiarch}"
754 fi
Bram Moolenaar768baac2013-04-15 14:44:57 +0200755 fi
756 dnl Determine the sover for the current version, but fallback to
757 dnl liblua${vi_cv_version_lua}.so if no sover-versioned file is found.
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200758 AC_MSG_CHECKING(if liblua${luajit}*.${ext}* can be found in $vi_cv_path_lua_pfx)
Bram Moolenaar768baac2013-04-15 14:44:57 +0200759 for subdir in "${lib_multiarch}" lib64 lib; do
760 if test -z "$subdir"; then
761 continue
762 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200763 for sover in "${vi_cv_version_lua}.${ext}" "-${vi_cv_version_lua}.${ext}" \
764 ".${vi_cv_version_lua}.${ext}" ".${ext}.${vi_cv_version_lua}"; do
765 for i in $indexes ""; do
766 if test -f "${vi_cv_path_lua_pfx}/${subdir}/liblua${luajit}${sover}$i"; then
Bram Moolenaar768baac2013-04-15 14:44:57 +0200767 sover2="$i"
768 break 3
769 fi
770 done
Bram Moolenaar07e1da62013-02-06 19:49:43 +0100771 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200772 sover=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200773 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200774 if test "X$sover" = "X"; then
775 AC_MSG_RESULT(no)
776 lua_ok="no"
777 vi_cv_dll_name_lua="liblua${luajit}.${ext}"
778 else
779 AC_MSG_RESULT(yes)
780 lua_ok="yes"
781 vi_cv_dll_name_lua="liblua${luajit}${sover}$sover2"
782 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200783 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200784 AC_DEFINE(DYNAMIC_LUA)
785 LUA_LIBS=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200786 LUA_CFLAGS="-DDYNAMIC_LUA_DLL=\\\"${vi_cv_dll_name_lua}\\\" $LUA_CFLAGS"
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200787 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200788 if test "X$LUA_CFLAGS$LUA_LIBS" != "X" && \
Bram Moolenaard0573012017-10-28 21:11:06 +0200789 test "x$MACOS_X" = "xyes" && test "x$vi_cv_with_luajit" != "xno" && \
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000790 test "$vim_cv_uname_m_output" = "x86_64"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200791 dnl OSX/x64 requires these flags. See http://luajit.org/install.html
792 LUA_LIBS="-pagezero_size 10000 -image_base 100000000 $LUA_LIBS"
793 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200794 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200795 if test "$fail_if_missing" = "yes" -a "$lua_ok" != "yes"; then
Bram Moolenaarf788a062011-12-14 20:51:25 +0100796 AC_MSG_ERROR([could not configure lua])
797 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200798 AC_SUBST(LUA_SRC)
799 AC_SUBST(LUA_OBJ)
800 AC_SUBST(LUA_PRO)
801 AC_SUBST(LUA_LIBS)
802 AC_SUBST(LUA_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +0000803 AC_SUBST(LUA_CFLAGS_EXTRA)
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200804fi
805
806
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000807dnl Check for MzScheme feature.
808AC_MSG_CHECKING(--enable-mzschemeinterp argument)
809AC_ARG_ENABLE(mzschemeinterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200810 [ --enable-mzschemeinterp Include MzScheme interpreter.], ,
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000811 [enable_mzschemeinterp="no"])
812AC_MSG_RESULT($enable_mzschemeinterp)
813
814if test "$enable_mzschemeinterp" = "yes"; then
815 dnl -- find the mzscheme executable
816 AC_SUBST(vi_cv_path_mzscheme)
817
818 AC_MSG_CHECKING(--with-plthome argument)
819 AC_ARG_WITH(plthome,
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000820 [ --with-plthome=PLTHOME Use PLTHOME.],
821 with_plthome="$withval"; AC_MSG_RESULT($with_plthome),
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000822 with_plthome="";AC_MSG_RESULT("no"))
823
824 if test "X$with_plthome" != "X"; then
825 vi_cv_path_mzscheme_pfx="$with_plthome"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100826 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000827 else
828 AC_MSG_CHECKING(PLTHOME environment var)
829 if test "X$PLTHOME" != "X"; then
830 AC_MSG_RESULT("$PLTHOME")
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000831 vi_cv_path_mzscheme_pfx="$PLTHOME"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100832 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000833 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000834 AC_MSG_RESULT(not set)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000835 dnl -- try to find MzScheme executable
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000836 AC_PATH_PROG(vi_cv_path_mzscheme, mzscheme)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000837
838 dnl resolve symbolic link, the executable is often elsewhere and there
839 dnl are no links for the include files.
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000840 if test "X$vi_cv_path_mzscheme" != "X"; then
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000841 lsout=`ls -l $vi_cv_path_mzscheme`
842 if echo "$lsout" | grep -e '->' >/dev/null 2>/dev/null; then
843 vi_cv_path_mzscheme=`echo "$lsout" | sed 's/.*-> \(.*\)/\1/'`
844 fi
845 fi
846
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000847 if test "X$vi_cv_path_mzscheme" != "X"; then
848 dnl -- find where MzScheme thinks it was installed
849 AC_CACHE_CHECK(MzScheme install prefix,vi_cv_path_mzscheme_pfx,
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000850 dnl different versions of MzScheme differ in command line processing
851 dnl use universal approach
852 echo "(display (simplify-path \
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000853 (build-path (call-with-values \
854 (lambda () (split-path (find-system-path (quote exec-file)))) \
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000855 (lambda (base name must-be-dir?) base)) (quote up))))" > mzdirs.scm
856 dnl Remove a trailing slash
857 [ vi_cv_path_mzscheme_pfx=`${vi_cv_path_mzscheme} -r mzdirs.scm | \
858 sed -e 's+/$++'` ])
859 rm -f mzdirs.scm
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000860 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000861 fi
862 fi
863
864 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100865 AC_MSG_CHECKING(for racket include directory)
866 SCHEME_INC=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-include-dir))) (when (path? p) (display p)))'`
867 if test "X$SCHEME_INC" != "X"; then
868 AC_MSG_RESULT(${SCHEME_INC})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000869 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100870 AC_MSG_RESULT(not found)
871 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include)
872 if test -f "$vi_cv_path_mzscheme_pfx/include/scheme.h"; then
873 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000874 AC_MSG_RESULT(yes)
Bram Moolenaard7afed32007-05-06 13:26:41 +0000875 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000876 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100877 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt)
878 if test -f "$vi_cv_path_mzscheme_pfx/include/plt/scheme.h"; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000879 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100880 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000881 else
882 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100883 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket)
884 if test -f "$vi_cv_path_mzscheme_pfx/include/racket/scheme.h"; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100885 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100886 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100887 else
888 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100889 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/)
890 if test -f /usr/include/plt/scheme.h; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100891 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100892 SCHEME_INC=/usr/include/plt
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100893 else
894 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100895 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/racket/)
896 if test -f /usr/include/racket/scheme.h; then
897 AC_MSG_RESULT(yes)
898 SCHEME_INC=/usr/include/racket
899 else
900 AC_MSG_RESULT(no)
901 vi_cv_path_mzscheme_pfx=
902 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100903 fi
904 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000905 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000906 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000907 fi
908 fi
909
910 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100911
912 AC_MSG_CHECKING(for racket lib directory)
913 SCHEME_LIB=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-lib-dir))) (when (path? p) (display p)))'`
914 if test "X$SCHEME_LIB" != "X"; then
915 AC_MSG_RESULT(${SCHEME_LIB})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000916 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100917 AC_MSG_RESULT(not found)
918 fi
919
920 for path in "${vi_cv_path_mzscheme_pfx}/lib" "${SCHEME_LIB}"; do
921 if test "X$path" != "X"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200922 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100923 MZSCHEME_LIBS="-framework Racket"
924 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
925 elif test -f "${path}/libmzscheme3m.a"; then
926 MZSCHEME_LIBS="${path}/libmzscheme3m.a"
927 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
928 elif test -f "${path}/libracket3m.a"; then
929 MZSCHEME_LIBS="${path}/libracket3m.a"
Bram Moolenaar588d2412020-10-03 14:24:19 +0200930 if test -f "${path}/librktio.a"; then
931 MZSCHEME_LIBS="${MZSCHEME_LIBS} ${path}/librktio.a"
932 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100933 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
934 elif test -f "${path}/libracket.a"; then
935 MZSCHEME_LIBS="${path}/libracket.a ${path}/libmzgc.a"
936 elif test -f "${path}/libmzscheme.a"; then
937 MZSCHEME_LIBS="${path}/libmzscheme.a ${path}/libmzgc.a"
938 else
939 dnl Using shared objects
940 if test -f "${path}/libmzscheme3m.so"; then
941 MZSCHEME_LIBS="-L${path} -lmzscheme3m"
942 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
943 elif test -f "${path}/libracket3m.so"; then
944 MZSCHEME_LIBS="-L${path} -lracket3m"
945 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
946 elif test -f "${path}/libracket.so"; then
947 MZSCHEME_LIBS="-L${path} -lracket -lmzgc"
948 else
949 dnl try next until last
950 if test "$path" != "$SCHEME_LIB"; then
951 continue
952 fi
953 MZSCHEME_LIBS="-L${path} -lmzscheme -lmzgc"
954 fi
955 if test "$GCC" = yes; then
956 dnl Make Vim remember the path to the library. For when it's not in
957 dnl $LD_LIBRARY_PATH.
958 MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${path}"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000959 elif test "$vim_cv_uname_output" = SunOS &&
960 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100961 MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${path}"
962 fi
963 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000964 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100965 if test "X$MZSCHEME_LIBS" != "X"; then
966 break
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +0000967 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100968 done
969
970 AC_MSG_CHECKING([if racket requires -pthread])
971 if test "X$SCHEME_LIB" != "X" && $FGREP -e -pthread "$SCHEME_LIB/buildinfo" >/dev/null ; then
972 AC_MSG_RESULT(yes)
973 MZSCHEME_LIBS="${MZSCHEME_LIBS} -pthread"
974 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -pthread"
975 else
976 AC_MSG_RESULT(no)
977 fi
978
979 AC_MSG_CHECKING(for racket config directory)
980 SCHEME_CONFIGDIR=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-config-dir))) (when (path? p) (display p)))'`
981 if test "X$SCHEME_CONFIGDIR" != "X"; then
982 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DMZSCHEME_CONFIGDIR='\"${SCHEME_CONFIGDIR}\"'"
983 AC_MSG_RESULT(${SCHEME_CONFIGDIR})
984 else
985 AC_MSG_RESULT(not found)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000986 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100987
988 AC_MSG_CHECKING(for racket collects directory)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100989 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))))'`
990 if test "X$SCHEME_COLLECTS" = "X"; then
991 if test -d "$vi_cv_path_mzscheme_pfx/lib/plt/collects"; then
992 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/plt/
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100993 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100994 if test -d "$vi_cv_path_mzscheme_pfx/lib/racket/collects"; then
995 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/racket/
Bram Moolenaar75676462013-01-30 14:55:42 +0100996 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100997 if test -d "$vi_cv_path_mzscheme_pfx/share/racket/collects"; then
998 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/
999 else
1000 if test -d "$vi_cv_path_mzscheme_pfx/collects"; then
1001 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/
1002 fi
Bram Moolenaar75676462013-01-30 14:55:42 +01001003 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001004 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +01001005 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +00001006 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001007 if test "X$SCHEME_COLLECTS" != "X" ; then
1008 AC_MSG_RESULT(${SCHEME_COLLECTS})
1009 else
1010 AC_MSG_RESULT(not found)
1011 fi
1012
1013 AC_MSG_CHECKING(for mzscheme_base.c)
1014 if test -f "${SCHEME_COLLECTS}collects/scheme/base.ss" ; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001015 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +01001016 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
1017 MZSCHEME_MOD="++lib scheme/base"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +01001018 else
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001019 if test -f "${SCHEME_COLLECTS}collects/scheme/base.rkt" ; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +01001020 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +01001021 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
1022 MZSCHEME_MOD="++lib scheme/base"
1023 else
1024 if test -f "${SCHEME_COLLECTS}collects/racket/base.rkt" ; then
1025 MZSCHEME_EXTRA="mzscheme_base.c"
1026 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/raco ctool"
1027 MZSCHEME_MOD=""
1028 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +01001029 fi
1030 fi
1031 if test "X$MZSCHEME_EXTRA" != "X" ; then
1032 dnl need to generate bytecode for MzScheme base
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001033 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE"
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001034 AC_MSG_RESULT(needed)
1035 else
1036 AC_MSG_RESULT(not needed)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001037 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001038
Bram Moolenaar9e902192013-07-17 18:58:11 +02001039 dnl On Ubuntu this fixes "undefined reference to symbol 'ffi_type_void'".
1040 AC_CHECK_LIB(ffi, ffi_type_void, [MZSCHEME_LIBS="$MZSCHEME_LIBS -lffi"])
1041
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001042 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -I${SCHEME_INC} \
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001043 -DMZSCHEME_COLLECTS='\"${SCHEME_COLLECTS}collects\"'"
Bram Moolenaar9e902192013-07-17 18:58:11 +02001044
1045 dnl Test that we can compile a simple program with these CFLAGS and LIBS.
1046 AC_MSG_CHECKING([if compile and link flags for MzScheme are sane])
1047 cflags_save=$CFLAGS
1048 libs_save=$LIBS
1049 CFLAGS="$CFLAGS $MZSCHEME_CFLAGS"
1050 LIBS="$LIBS $MZSCHEME_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001051 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaar9e902192013-07-17 18:58:11 +02001052 AC_MSG_RESULT(yes); mzs_ok=yes,
1053 AC_MSG_RESULT(no: MZSCHEME DISABLED); mzs_ok=no)
1054 CFLAGS=$cflags_save
1055 LIBS=$libs_save
1056 if test $mzs_ok = yes; then
1057 MZSCHEME_SRC="if_mzsch.c"
1058 MZSCHEME_OBJ="objects/if_mzsch.o"
1059 MZSCHEME_PRO="if_mzsch.pro"
1060 AC_DEFINE(FEAT_MZSCHEME)
1061 else
1062 MZSCHEME_CFLAGS=
1063 MZSCHEME_LIBS=
1064 MZSCHEME_EXTRA=
1065 MZSCHEME_MZC=
1066 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001067 fi
1068 AC_SUBST(MZSCHEME_SRC)
1069 AC_SUBST(MZSCHEME_OBJ)
1070 AC_SUBST(MZSCHEME_PRO)
1071 AC_SUBST(MZSCHEME_LIBS)
1072 AC_SUBST(MZSCHEME_CFLAGS)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001073 AC_SUBST(MZSCHEME_EXTRA)
1074 AC_SUBST(MZSCHEME_MZC)
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001075fi
1076
1077
Bram Moolenaar071d4272004-06-13 20:20:40 +00001078AC_MSG_CHECKING(--enable-perlinterp argument)
1079AC_ARG_ENABLE(perlinterp,
Bram Moolenaare06c1882010-07-21 22:05:20 +02001080 [ --enable-perlinterp[=OPTS] Include Perl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001081 [enable_perlinterp="no"])
1082AC_MSG_RESULT($enable_perlinterp)
Bram Moolenaare06c1882010-07-21 22:05:20 +02001083if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00001084 if test "$has_eval" = "no"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01001085 AC_MSG_ERROR([cannot use Perl with tiny or small features])
1086 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001087 AC_SUBST(vi_cv_path_perl)
1088 AC_PATH_PROG(vi_cv_path_perl, perl)
1089 if test "X$vi_cv_path_perl" != "X"; then
1090 AC_MSG_CHECKING(Perl version)
1091 if $vi_cv_path_perl -e 'require 5.003_01' >/dev/null 2>/dev/null; then
1092 eval `$vi_cv_path_perl -V:usethreads`
Bram Moolenaare06c1882010-07-21 22:05:20 +02001093 eval `$vi_cv_path_perl -V:libperl`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001094 if test "X$usethreads" = "XUNKNOWN" -o "X$usethreads" = "Xundef"; then
1095 badthreads=no
1096 else
1097 if $vi_cv_path_perl -e 'require 5.6.0' >/dev/null 2>/dev/null; then
1098 eval `$vi_cv_path_perl -V:use5005threads`
1099 if test "X$use5005threads" = "XUNKNOWN" -o "X$use5005threads" = "Xundef"; then
1100 badthreads=no
1101 else
1102 badthreads=yes
1103 AC_MSG_RESULT(>>> Perl > 5.6 with 5.5 threads cannot be used <<<)
1104 fi
1105 else
1106 badthreads=yes
1107 AC_MSG_RESULT(>>> Perl 5.5 with threads cannot be used <<<)
1108 fi
1109 fi
1110 if test $badthreads = no; then
1111 AC_MSG_RESULT(OK)
1112 eval `$vi_cv_path_perl -V:shrpenv`
1113 if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04
1114 shrpenv=""
1115 fi
1116 vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlibexp}'`
1117 AC_SUBST(vi_cv_perllib)
Bram Moolenaard5f62b12014-08-17 17:05:44 +02001118 vi_cv_perl_extutils=unknown_perl_extutils_path
1119 for extutils_rel_path in ExtUtils vendor_perl/ExtUtils; do
1120 xsubpp_path="$vi_cv_perllib/$extutils_rel_path/xsubpp"
1121 if test -f "$xsubpp_path"; then
1122 vi_cv_perl_xsubpp="$xsubpp_path"
1123 fi
1124 done
1125 AC_SUBST(vi_cv_perl_xsubpp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001126 dnl Remove "-fno-something", it breaks using cproto.
Bram Moolenaar280a8682015-06-21 13:41:08 +02001127 dnl Remove "-fdebug-prefix-map", it isn't supported by clang.
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001128 dnl Remove "FORTIFY_SOURCE", it will be defined twice.
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001129 dnl remove -pipe and -Wxxx, it confuses cproto
Bram Moolenaar071d4272004-06-13 20:20:40 +00001130 perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001131 -e 'ccflags;perl_inc;print"\n"' | sed -e 's/-fno[[^ ]]*//' \
1132 -e 's/-fdebug-prefix-map[[^ ]]*//g' \
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001133 -e 's/-pipe //' \
1134 -e 's/-W[[^ ]]*//g' \
1135 -e 's/-D_FORTIFY_SOURCE=.//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001136 dnl Remove "-lc", it breaks on FreeBSD when using "-pthread".
1137 perllibs=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed -e 'ldopts' | \
1138 sed -e '/Warning/d' -e '/Note (probably harmless)/d' \
1139 -e 's/-bE:perl.exp//' -e 's/-lc //'`
1140 dnl Don't add perl lib to $LIBS: if it's not in LD_LIBRARY_PATH
1141 dnl a test in configure may fail because of that.
1142 perlldflags=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed \
1143 -e 'ccdlflags' | sed -e 's/-bE:perl.exp//'`
1144
1145 dnl check that compiling a simple program still works with the flags
1146 dnl added for Perl.
1147 AC_MSG_CHECKING([if compile and link flags for Perl are sane])
1148 cflags_save=$CFLAGS
1149 libs_save=$LIBS
1150 ldflags_save=$LDFLAGS
1151 CFLAGS="$CFLAGS $perlcppflags"
1152 LIBS="$LIBS $perllibs"
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001153 perlldflags=`echo "$perlldflags" | sed -e 's/^ *//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001154 LDFLAGS="$perlldflags $LDFLAGS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001155 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00001156 AC_MSG_RESULT(yes); perl_ok=yes,
1157 AC_MSG_RESULT(no: PERL DISABLED); perl_ok=no)
1158 CFLAGS=$cflags_save
1159 LIBS=$libs_save
1160 LDFLAGS=$ldflags_save
1161 if test $perl_ok = yes; then
1162 if test "X$perlcppflags" != "X"; then
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001163 PERL_CFLAGS=$perlcppflags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001164 fi
1165 if test "X$perlldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001166 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$perlldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001167 LDFLAGS="$perlldflags $LDFLAGS"
1168 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001169 fi
1170 PERL_LIBS=$perllibs
1171 PERL_SRC="auto/if_perl.c if_perlsfio.c"
1172 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o"
1173 PERL_PRO="if_perl.pro if_perlsfio.pro"
1174 AC_DEFINE(FEAT_PERL)
1175 fi
1176 fi
1177 else
1178 AC_MSG_RESULT(>>> too old; need Perl version 5.003_01 or later <<<)
1179 fi
1180 fi
1181
Bram Moolenaard0573012017-10-28 21:11:06 +02001182 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00001183 dnl Mac OS X 10.2 or later
Bram Moolenaar071d4272004-06-13 20:20:40 +00001184 dir=/System/Library/Perl
1185 darwindir=$dir/darwin
1186 if test -d $darwindir; then
1187 PERL=/usr/bin/perl
1188 else
1189 dnl Mac OS X 10.3
1190 dir=/System/Library/Perl/5.8.1
1191 darwindir=$dir/darwin-thread-multi-2level
1192 if test -d $darwindir; then
1193 PERL=/usr/bin/perl
1194 fi
1195 fi
1196 if test -n "$PERL"; then
1197 PERL_DIR="$dir"
1198 PERL_CFLAGS="-DFEAT_PERL -I$darwindir/CORE"
1199 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o $darwindir/auto/DynaLoader/DynaLoader.a"
1200 PERL_LIBS="-L$darwindir/CORE -lperl"
1201 fi
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001202 dnl Perl on Mac OS X 10.5 adds "-arch" flags but these should only
1203 dnl be included if requested by passing --with-mac-arch to
1204 dnl configure, so strip these flags first (if present)
1205 PERL_LIBS=`echo "$PERL_LIBS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
1206 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 +00001207 fi
Bram Moolenaare06c1882010-07-21 22:05:20 +02001208 if test "$enable_perlinterp" = "dynamic"; then
1209 if test "$perl_ok" = "yes" -a "X$libperl" != "X"; then
1210 AC_DEFINE(DYNAMIC_PERL)
1211 PERL_CFLAGS="-DDYNAMIC_PERL_DLL=\\\"$libperl\\\" $PERL_CFLAGS"
1212 fi
1213 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001214
1215 if test "$fail_if_missing" = "yes" -a "$perl_ok" != "yes"; then
1216 AC_MSG_ERROR([could not configure perl])
1217 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001218fi
1219AC_SUBST(shrpenv)
1220AC_SUBST(PERL_SRC)
1221AC_SUBST(PERL_OBJ)
1222AC_SUBST(PERL_PRO)
1223AC_SUBST(PERL_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00001224AC_SUBST(PERL_CFLAGS_EXTRA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001225AC_SUBST(PERL_LIBS)
1226
1227AC_MSG_CHECKING(--enable-pythoninterp argument)
1228AC_ARG_ENABLE(pythoninterp,
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001229 [ --enable-pythoninterp[=OPTS] Include Python interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001230 [enable_pythoninterp="no"])
1231AC_MSG_RESULT($enable_pythoninterp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001232if test "$enable_pythoninterp" = "yes" -o "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00001233 if test "$has_eval" = "no"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001234 AC_MSG_ERROR([cannot use Python with tiny or small features])
1235 fi
1236
Bram Moolenaar071d4272004-06-13 20:20:40 +00001237 dnl -- find the python executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001238 AC_MSG_CHECKING(--with-python-command argument)
1239 AC_SUBST(vi_cv_path_python)
1240 AC_ARG_WITH(python-command, [ --with-python-command=NAME name of the Python 2 command (default: python2 or python)],
1241 vi_cv_path_python="$withval"; AC_MSG_RESULT($vi_cv_path_python),
1242 AC_MSG_RESULT(no))
1243
1244 if test "X$vi_cv_path_python" = "X"; then
1245 AC_PATH_PROGS(vi_cv_path_python, python2 python)
1246 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001247 if test "X$vi_cv_path_python" != "X"; then
1248
1249 dnl -- get its version number
1250 AC_CACHE_CHECK(Python version,vi_cv_var_python_version,
1251 [[vi_cv_var_python_version=`
1252 ${vi_cv_path_python} -c 'import sys; print sys.version[:3]'`
1253 ]])
1254
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001255 dnl -- it must be at least version 2.3
1256 AC_MSG_CHECKING(Python is 2.3 or better)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001257 if ${vi_cv_path_python} -c \
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001258 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001259 then
1260 AC_MSG_RESULT(yep)
1261
1262 dnl -- find where python thinks it was installed
1263 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python_pfx,
1264 [ vi_cv_path_python_pfx=`
1265 ${vi_cv_path_python} -c \
1266 "import sys; print sys.prefix"` ])
1267
1268 dnl -- and where it thinks it runs
1269 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python_epfx,
1270 [ vi_cv_path_python_epfx=`
1271 ${vi_cv_path_python} -c \
1272 "import sys; print sys.exec_prefix"` ])
1273
1274 dnl -- python's internal library path
1275
1276 AC_CACHE_VAL(vi_cv_path_pythonpath,
1277 [ vi_cv_path_pythonpath=`
1278 unset PYTHONPATH;
1279 ${vi_cv_path_python} -c \
1280 "import sys, string; print string.join(sys.path,':')"` ])
1281
1282 dnl -- where the Python implementation library archives are
1283
1284 AC_ARG_WITH(python-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001285 [ --with-python-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001286 [ vi_cv_path_python_conf="${withval}"; have_python_config_dir=1 ] )
Bram Moolenaar071d4272004-06-13 20:20:40 +00001287
1288 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python_conf,
1289 [
1290 vi_cv_path_python_conf=
Bram Moolenaarac499e32013-06-02 19:14:17 +02001291 d=`${vi_cv_path_python} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBPL')"`
1292 if test -d "$d" && test -f "$d/config.c"; then
1293 vi_cv_path_python_conf="$d"
1294 else
1295 for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
1296 for subdir in lib64 lib share; do
1297 d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
1298 if test -d "$d" && test -f "$d/config.c"; then
1299 vi_cv_path_python_conf="$d"
1300 fi
1301 done
Bram Moolenaar071d4272004-06-13 20:20:40 +00001302 done
Bram Moolenaarac499e32013-06-02 19:14:17 +02001303 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001304 ])
1305
1306 PYTHON_CONFDIR="${vi_cv_path_python_conf}"
1307
1308 if test "X$PYTHON_CONFDIR" = "X"; then
1309 AC_MSG_RESULT([can't find it!])
1310 else
1311
1312 dnl -- we need to examine Python's config/Makefile too
1313 dnl see what the interpreter is built from
1314 AC_CACHE_VAL(vi_cv_path_python_plibs,
1315 [
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001316 pwd=`pwd`
1317 tmp_mkf="$pwd/config-PyMake$$"
1318 cat -- "${PYTHON_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001319__:
Bram Moolenaar218116c2010-05-20 21:46:00 +02001320 @echo "python_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001321 @echo "python_LIBS='$(LIBS)'"
1322 @echo "python_SYSLIBS='$(SYSLIBS)'"
1323 @echo "python_LINKFORSHARED='$(LINKFORSHARED)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001324 @echo "python_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001325 @echo "python_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001326 @echo "python_PYTHONFRAMEWORK='$(PYTHONFRAMEWORK)'"
1327 @echo "python_PYTHONFRAMEWORKPREFIX='$(PYTHONFRAMEWORKPREFIX)'"
1328 @echo "python_PYTHONFRAMEWORKINSTALLDIR='$(PYTHONFRAMEWORKINSTALLDIR)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001329eof
1330 dnl -- delete the lines from make about Entering/Leaving directory
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001331 eval "`cd ${PYTHON_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1332 rm -f -- "${tmp_mkf}"
Bram Moolenaard0573012017-10-28 21:11:06 +02001333 if test "x$MACOS_X" = "xyes" && test -n "${python_PYTHONFRAMEWORK}" && ${vi_cv_path_python} -c \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001334 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then
1335 vi_cv_path_python_plibs="-framework Python"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001336 if test "x${vi_cv_path_python}" != "x/usr/bin/python" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
1337 vi_cv_path_python_plibs="-F${python_PYTHONFRAMEWORKPREFIX} -framework Python"
1338 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001339 else
Bram Moolenaar9ce42132018-04-11 22:19:36 +02001340 vi_cv_path_python_plibs="-L${PYTHON_CONFDIR} -lpython${vi_cv_var_python_version}"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001341 dnl -- Check if the path contained in python_LINKFORSHARED is
1342 dnl usable for vim build. If not, make and try other
1343 dnl candidates.
Bram Moolenaara161e262015-03-24 15:14:27 +01001344 if test -n "${python_LINKFORSHARED}" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
Bram Moolenaar6c927552015-03-24 12:21:33 +01001345 python_link_symbol=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]].*/\1/'`
1346 python_link_path=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]][[ \t]]*\(.*\)/\2/'`
1347 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1348 dnl -- The path looks relative. Guess the absolute one using
1349 dnl the prefix and try that.
1350 python_link_path="${python_PYTHONFRAMEWORKPREFIX}/${python_link_path}"
1351 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1352 dnl -- A last resort.
1353 python_link_path="${python_PYTHONFRAMEWORKINSTALLDIR}/Versions/${vi_cv_var_python_version}/${python_PYTHONFRAMEWORK}"
1354 dnl -- No check is done. The last word is left to the
1355 dnl "sanity" test on link flags that follows shortly.
1356 fi
1357 python_LINKFORSHARED="${python_link_symbol} ${python_link_path}"
1358 fi
1359 fi
Bram Moolenaar218116c2010-05-20 21:46:00 +02001360 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 +00001361 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1362 vi_cv_path_python_plibs=`echo $vi_cv_path_python_plibs | sed s/-ltermcap//`
1363 fi
1364 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001365 AC_CACHE_CHECK(Python's dll name,vi_cv_dll_name_python,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001366 [
1367 if test "X$python_DLLLIBRARY" != "X"; then
1368 vi_cv_dll_name_python="$python_DLLLIBRARY"
1369 else
1370 vi_cv_dll_name_python="$python_INSTSONAME"
1371 fi
1372 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00001373
1374 PYTHON_LIBS="${vi_cv_path_python_plibs}"
1375 if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001376 PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001377 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001378 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 +00001379 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001380 if test "X$have_python_config_dir" = "X1" -a "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001381 dnl Define PYTHON_HOME if --with-python-config-dir was used
1382 PYTHON_CFLAGS="${PYTHON_CFLAGS} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'"
1383
1384 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001385 PYTHON_SRC="if_python.c"
Bram Moolenaar9bdb9a02012-07-25 16:32:08 +02001386 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001387
1388 dnl On FreeBSD linking with "-pthread" is required to use threads.
1389 dnl _THREAD_SAFE must be used for compiling then.
1390 dnl The "-pthread" is added to $LIBS, so that the following check for
1391 dnl sigaltstack() will look in libc_r (it's there in libc!).
1392 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1393 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1394 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1395 AC_MSG_CHECKING([if -pthread should be used])
1396 threadsafe_flag=
1397 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001398 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001399 if test "$vim_cv_uname_output" != Darwin; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001400 test "$GCC" = yes && threadsafe_flag="-pthread"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001401 if test "$vim_cv_uname_output" = FreeBSD; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001402 threadsafe_flag="-D_THREAD_SAFE"
1403 thread_lib="-pthread"
1404 fi
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001405 if test "$vim_cv_uname_output" = SunOS; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001406 threadsafe_flag="-pthreads"
1407 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001408 fi
1409 libs_save_old=$LIBS
1410 if test -n "$threadsafe_flag"; then
1411 cflags_save=$CFLAGS
1412 CFLAGS="$CFLAGS $threadsafe_flag"
1413 LIBS="$LIBS $thread_lib"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001414 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001415 AC_MSG_RESULT(yes); PYTHON_CFLAGS="$PYTHON_CFLAGS $threadsafe_flag",
Bram Moolenaar071d4272004-06-13 20:20:40 +00001416 AC_MSG_RESULT(no); LIBS=$libs_save_old
1417 )
1418 CFLAGS=$cflags_save
1419 else
1420 AC_MSG_RESULT(no)
1421 fi
1422
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001423 dnl Check that compiling a simple program still works with the flags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001424 dnl added for Python.
1425 AC_MSG_CHECKING([if compile and link flags for Python are sane])
1426 cflags_save=$CFLAGS
1427 libs_save=$LIBS
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001428 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001429 LIBS="$LIBS $PYTHON_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001430 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00001431 AC_MSG_RESULT(yes); python_ok=yes,
1432 AC_MSG_RESULT(no: PYTHON DISABLED); python_ok=no)
1433 CFLAGS=$cflags_save
1434 LIBS=$libs_save
1435 if test $python_ok = yes; then
1436 AC_DEFINE(FEAT_PYTHON)
1437 else
1438 LIBS=$libs_save_old
1439 PYTHON_SRC=
1440 PYTHON_OBJ=
1441 PYTHON_LIBS=
1442 PYTHON_CFLAGS=
1443 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001444 fi
1445 else
1446 AC_MSG_RESULT(too old)
1447 fi
1448 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001449
1450 if test "$fail_if_missing" = "yes" -a "$python_ok" != "yes"; then
1451 AC_MSG_ERROR([could not configure python])
1452 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001453fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001454
Bram Moolenaar071d4272004-06-13 20:20:40 +00001455AC_SUBST(PYTHON_LIBS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001456AC_SUBST(PYTHON_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00001457AC_SUBST(PYTHON_CFLAGS_EXTRA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001458AC_SUBST(PYTHON_SRC)
1459AC_SUBST(PYTHON_OBJ)
1460
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001461
1462AC_MSG_CHECKING(--enable-python3interp argument)
1463AC_ARG_ENABLE(python3interp,
Bram Moolenaar8008b632017-07-18 21:33:20 +02001464 [ --enable-python3interp[=OPTS] Include Python3 interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001465 [enable_python3interp="no"])
1466AC_MSG_RESULT($enable_python3interp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001467if test "$enable_python3interp" = "yes" -o "$enable_python3interp" = "dynamic"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00001468 if test "$has_eval" = "no"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001469 AC_MSG_ERROR([cannot use Python with tiny or small features])
1470 fi
1471
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001472 dnl -- find the python3 executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001473 AC_MSG_CHECKING(--with-python3-command argument)
1474 AC_SUBST(vi_cv_path_python3)
1475 AC_ARG_WITH(python3-command, [ --with-python3-command=NAME name of the Python 3 command (default: python3 or python)],
1476 vi_cv_path_python3="$withval"; AC_MSG_RESULT($vi_cv_path_python3),
1477 AC_MSG_RESULT(no))
1478
1479 if test "X$vi_cv_path_python3" = "X"; then
1480 AC_PATH_PROGS(vi_cv_path_python3, python3 python)
1481 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001482 if test "X$vi_cv_path_python3" != "X"; then
1483
1484 dnl -- get its version number
1485 AC_CACHE_CHECK(Python version,vi_cv_var_python3_version,
1486 [[vi_cv_var_python3_version=`
Bram Moolenaar23c01922021-05-21 11:43:58 +02001487 ${vi_cv_path_python3} -c 'import sys; print("{}.{}".format(sys.version_info.major, sys.version_info.minor))'`
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001488 ]])
1489
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001490 dnl -- it must be at least version 3
1491 AC_MSG_CHECKING(Python is 3.0 or better)
1492 if ${vi_cv_path_python3} -c \
1493 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.0)"
1494 then
1495 AC_MSG_RESULT(yep)
Bram Moolenaar456f2bb2011-06-12 21:37:13 +02001496
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001497 dnl -- get abiflags for python 3.2 or higher (PEP 3149)
1498 AC_CACHE_CHECK(Python's abiflags,vi_cv_var_python3_abiflags,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001499 [
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001500 vi_cv_var_python3_abiflags=
1501 if ${vi_cv_path_python3} -c \
1502 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)"
1503 then
Bram Moolenaare5303952022-06-19 17:05:47 +01001504 vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001505 "import sys; print(sys.abiflags)"`
1506 fi ])
Bram Moolenaare5303952022-06-19 17:05:47 +01001507
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001508 dnl -- find where python3 thinks it was installed
1509 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx,
1510 [ vi_cv_path_python3_pfx=`
1511 ${vi_cv_path_python3} -c \
1512 "import sys; print(sys.prefix)"` ])
Bram Moolenaare5303952022-06-19 17:05:47 +01001513
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001514 dnl -- and where it thinks it runs
1515 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx,
1516 [ vi_cv_path_python3_epfx=`
1517 ${vi_cv_path_python3} -c \
1518 "import sys; print(sys.exec_prefix)"` ])
Bram Moolenaare5303952022-06-19 17:05:47 +01001519
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001520 dnl -- python3's internal library path
Bram Moolenaare5303952022-06-19 17:05:47 +01001521
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001522 AC_CACHE_VAL(vi_cv_path_python3path,
1523 [ vi_cv_path_python3path=`
1524 unset PYTHONPATH;
1525 ${vi_cv_path_python3} -c \
1526 "import sys, string; print(':'.join(sys.path))"` ])
Bram Moolenaare5303952022-06-19 17:05:47 +01001527
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001528 dnl -- where the Python implementation library archives are
Bram Moolenaare5303952022-06-19 17:05:47 +01001529
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001530 AC_ARG_WITH(python3-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001531 [ --with-python3-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001532 [ vi_cv_path_python3_conf="${withval}"; have_python3_config_dir=1 ] )
Bram Moolenaare5303952022-06-19 17:05:47 +01001533
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001534 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf,
1535 [
1536 vi_cv_path_python3_conf=
Bram Moolenaarfee496d2013-07-12 20:07:24 +02001537 config_dir="config-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Zdenek Dohnal31e299c2021-06-10 18:50:55 +02001538 d=`${vi_cv_path_python3} -c "import sysconfig; print(sysconfig.get_config_var('LIBPL'))" 2> /dev/null`
1539 if test "x$d" = "x"; then
1540 d=`${vi_cv_path_python3} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBPL'))"`
1541 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001542 if test -d "$d" && test -f "$d/config.c"; then
1543 vi_cv_path_python3_conf="$d"
1544 else
1545 for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do
1546 for subdir in lib64 lib share; do
1547 d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}"
1548 if test -d "$d" && test -f "$d/config.c"; then
1549 vi_cv_path_python3_conf="$d"
1550 fi
1551 done
1552 done
1553 fi
1554 ])
Bram Moolenaare5303952022-06-19 17:05:47 +01001555
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001556 PYTHON3_CONFDIR="${vi_cv_path_python3_conf}"
Bram Moolenaare5303952022-06-19 17:05:47 +01001557
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001558 if test "X$PYTHON3_CONFDIR" = "X"; then
1559 AC_MSG_RESULT([can't find it!])
1560 else
Bram Moolenaare5303952022-06-19 17:05:47 +01001561
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001562 dnl -- we need to examine Python's config/Makefile too
1563 dnl see what the interpreter is built from
1564 AC_CACHE_VAL(vi_cv_path_python3_plibs,
1565 [
1566 pwd=`pwd`
1567 tmp_mkf="$pwd/config-PyMake$$"
1568 cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001569__:
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001570 @echo "python3_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001571 @echo "python3_LIBS='$(LIBS)'"
1572 @echo "python3_SYSLIBS='$(SYSLIBS)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001573 @echo "python3_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001574 @echo "python3_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001575eof
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001576 dnl -- delete the lines from make about Entering/Leaving directory
1577 eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1578 rm -f -- "${tmp_mkf}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001579 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 +02001580 vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}"
1581 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1582 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//`
1583 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//`
1584 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001585 AC_CACHE_CHECK(Python3's dll name,vi_cv_dll_name_python3,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001586 [
1587 if test "X$python3_DLLLIBRARY" != "X"; then
1588 vi_cv_dll_name_python3="$python3_DLLLIBRARY"
1589 else
1590 vi_cv_dll_name_python3="$python3_INSTSONAME"
1591 fi
1592 ])
1593
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001594 PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
1595 if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001596 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 +02001597 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001598 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 +02001599 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001600 if test "X$have_python3_config_dir" = "X1" -a "$enable_python3interp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001601 dnl Define PYTHON3_HOME if --with-python-config-dir was used
1602 PYTHON3_CFLAGS="${PYTHON3_CFLAGS} -DPYTHON3_HOME='L\"${vi_cv_path_python3_pfx}\"'"
1603 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001604 PYTHON3_SRC="if_python3.c"
1605 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaare5303952022-06-19 17:05:47 +01001606
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001607 dnl On FreeBSD linking with "-pthread" is required to use threads.
1608 dnl _THREAD_SAFE must be used for compiling then.
1609 dnl The "-pthread" is added to $LIBS, so that the following check for
1610 dnl sigaltstack() will look in libc_r (it's there in libc!).
1611 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1612 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1613 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1614 AC_MSG_CHECKING([if -pthread should be used])
1615 threadsafe_flag=
1616 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001617 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001618 if test "$vim_cv_uname_output" != Darwin; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001619 test "$GCC" = yes && threadsafe_flag="-pthread"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001620 if test "$vim_cv_uname_output" = FreeBSD; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001621 threadsafe_flag="-D_THREAD_SAFE"
1622 thread_lib="-pthread"
1623 fi
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001624 if test "$vim_cv_uname_output" = SunOS; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001625 threadsafe_flag="-pthreads"
1626 fi
1627 fi
1628 libs_save_old=$LIBS
1629 if test -n "$threadsafe_flag"; then
1630 cflags_save=$CFLAGS
1631 CFLAGS="$CFLAGS $threadsafe_flag"
1632 LIBS="$LIBS $thread_lib"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001633 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001634 AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag",
1635 AC_MSG_RESULT(no); LIBS=$libs_save_old
1636 )
1637 CFLAGS=$cflags_save
1638 else
1639 AC_MSG_RESULT(no)
1640 fi
Bram Moolenaare5303952022-06-19 17:05:47 +01001641
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001642 dnl check that compiling a simple program still works with the flags
1643 dnl added for Python.
1644 AC_MSG_CHECKING([if compile and link flags for Python 3 are sane])
1645 cflags_save=$CFLAGS
1646 libs_save=$LIBS
1647 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1648 LIBS="$LIBS $PYTHON3_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001649 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001650 AC_MSG_RESULT(yes); python3_ok=yes,
1651 AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no)
1652 CFLAGS=$cflags_save
1653 LIBS=$libs_save
1654 if test "$python3_ok" = yes; then
1655 AC_DEFINE(FEAT_PYTHON3)
1656 else
1657 LIBS=$libs_save_old
1658 PYTHON3_SRC=
1659 PYTHON3_OBJ=
1660 PYTHON3_LIBS=
1661 PYTHON3_CFLAGS=
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001662 fi
1663 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001664 else
1665 AC_MSG_RESULT(too old)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001666 fi
1667 fi
Bram Moolenaar1612b1a2013-06-14 21:22:39 +02001668 if test "$fail_if_missing" = "yes" -a "$python3_ok" != "yes"; then
1669 AC_MSG_ERROR([could not configure python3])
1670 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001671fi
1672
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001673AC_SUBST(PYTHON3_LIBS)
1674AC_SUBST(PYTHON3_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00001675AC_SUBST(PYTHON3_CFLAGS_EXTRA)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001676AC_SUBST(PYTHON3_SRC)
1677AC_SUBST(PYTHON3_OBJ)
1678
1679dnl if python2.x and python3.x are enabled one can only link in code
Bram Moolenaare5303952022-06-19 17:05:47 +01001680dnl with dlopen(), dlsym(), dlclose()
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001681if test "$python_ok" = yes && test "$python3_ok" = yes; then
1682 AC_DEFINE(DYNAMIC_PYTHON)
1683 AC_DEFINE(DYNAMIC_PYTHON3)
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001684 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001685 cflags_save=$CFLAGS
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001686 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001687 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001688 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001689 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001690 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001691 #include <dlfcn.h>
1692 /* If this program fails, then RTLD_GLOBAL is needed.
1693 * RTLD_GLOBAL will be used and then it is not possible to
1694 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001695 * Only the first python version used will be switched on.
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001696 */
1697
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01001698 static int no_rtl_global_needed_for(char *python_instsoname, char *prefix)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001699 {
1700 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001701 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001702 if (pylib != 0)
1703 {
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001704 void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome");
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001705 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1706 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1707 void (*final)(void) = dlsym(pylib, "Py_Finalize");
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001708 (*pfx)(prefix);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001709 (*init)();
1710 needed = (*simple)("import termios") == -1;
1711 (*final)();
1712 dlclose(pylib);
1713 }
1714 return !needed;
1715 }
1716
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01001717 int main()
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001718 {
1719 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001720 if (no_rtl_global_needed_for("${vi_cv_dll_name_python}", "${vi_cv_path_python_pfx}"))
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001721 not_needed = 1;
1722 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001723 }])],
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001724 [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001725
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001726 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001727 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001728
1729 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python3)
1730 cflags_save=$CFLAGS
1731 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001732 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001733 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001734 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001735 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001736 #include <dlfcn.h>
1737 #include <wchar.h>
1738 /* If this program fails, then RTLD_GLOBAL is needed.
1739 * RTLD_GLOBAL will be used and then it is not possible to
1740 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001741 * Only the first python version used will be switched on.
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001742 */
1743
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01001744 static int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix)
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001745 {
1746 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001747 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001748 if (pylib != 0)
1749 {
1750 void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome");
1751 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1752 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1753 void (*final)(void) = dlsym(pylib, "Py_Finalize");
1754 (*pfx)(prefix);
1755 (*init)();
1756 needed = (*simple)("import termios") == -1;
1757 (*final)();
1758 dlclose(pylib);
1759 }
1760 return !needed;
1761 }
1762
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01001763 int main()
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001764 {
1765 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001766 if (no_rtl_global_needed_for("${vi_cv_dll_name_python3}", L"${vi_cv_path_python3_pfx}"))
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001767 not_needed = 1;
1768 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001769 }])],
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001770 [AC_MSG_RESULT(yes);AC_DEFINE(PY3_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
1771
1772 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001773 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001774
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001775 PYTHON_SRC="if_python.c"
1776 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001777 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001778 PYTHON_LIBS=
1779 PYTHON3_SRC="if_python3.c"
1780 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001781 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001782 PYTHON3_LIBS=
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001783elif test "$python_ok" = yes && test "$enable_pythoninterp" = "dynamic"; then
1784 AC_DEFINE(DYNAMIC_PYTHON)
1785 PYTHON_SRC="if_python.c"
1786 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001787 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001788 PYTHON_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001789elif test "$python_ok" = yes; then
1790 dnl Check that adding -fPIE works. It may be needed when using a static
1791 dnl Python library.
1792 AC_MSG_CHECKING([if -fPIE can be added for Python])
1793 cflags_save=$CFLAGS
1794 libs_save=$LIBS
1795 CFLAGS="$CFLAGS $PYTHON_CFLAGS -fPIE"
1796 LIBS="$LIBS $PYTHON_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001797 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaare741f272013-07-09 21:57:52 +02001798 AC_MSG_RESULT(yes); fpie_ok=yes,
1799 AC_MSG_RESULT(no); fpie_ok=no)
1800 CFLAGS=$cflags_save
1801 LIBS=$libs_save
1802 if test $fpie_ok = yes; then
1803 PYTHON_CFLAGS="$PYTHON_CFLAGS -fPIE"
1804 fi
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001805elif test "$python3_ok" = yes && test "$enable_python3interp" = "dynamic"; then
1806 AC_DEFINE(DYNAMIC_PYTHON3)
1807 PYTHON3_SRC="if_python3.c"
1808 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001809 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001810 PYTHON3_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001811elif test "$python3_ok" = yes; then
1812 dnl Check that adding -fPIE works. It may be needed when using a static
1813 dnl Python library.
1814 AC_MSG_CHECKING([if -fPIE can be added for Python3])
1815 cflags_save=$CFLAGS
1816 libs_save=$LIBS
1817 CFLAGS="$CFLAGS $PYTHON3_CFLAGS -fPIE"
1818 LIBS="$LIBS $PYTHON3_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001819 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaare741f272013-07-09 21:57:52 +02001820 AC_MSG_RESULT(yes); fpie_ok=yes,
1821 AC_MSG_RESULT(no); fpie_ok=no)
1822 CFLAGS=$cflags_save
1823 LIBS=$libs_save
1824 if test $fpie_ok = yes; then
1825 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -fPIE"
1826 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001827fi
1828
Bram Moolenaar071d4272004-06-13 20:20:40 +00001829AC_MSG_CHECKING(--enable-tclinterp argument)
1830AC_ARG_ENABLE(tclinterp,
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001831 [ --enable-tclinterp[=OPTS] Include Tcl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001832 [enable_tclinterp="no"])
1833AC_MSG_RESULT($enable_tclinterp)
1834
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001835if test "$enable_tclinterp" = "yes" -o "$enable_tclinterp" = "dynamic"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001836
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001837 dnl on FreeBSD tclsh is a silly script, look for tclsh8.[5420]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001838 AC_MSG_CHECKING(--with-tclsh argument)
1839 AC_ARG_WITH(tclsh, [ --with-tclsh=PATH which tclsh to use (default: tclsh8.0)],
1840 tclsh_name="$withval"; AC_MSG_RESULT($tclsh_name),
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001841 tclsh_name="tclsh8.5"; AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00001842 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1843 AC_SUBST(vi_cv_path_tcl)
1844
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001845 dnl when no specific version specified, also try 8.4, 8.2 and 8.0
1846 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.5"; then
1847 tclsh_name="tclsh8.4"
1848 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1849 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001850 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.4"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001851 tclsh_name="tclsh8.2"
1852 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1853 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001854 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.2"; then
1855 tclsh_name="tclsh8.0"
1856 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1857 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001858 dnl still didn't find it, try without version number
1859 if test "X$vi_cv_path_tcl" = "X"; then
1860 tclsh_name="tclsh"
1861 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1862 fi
1863 if test "X$vi_cv_path_tcl" != "X"; then
1864 AC_MSG_CHECKING(Tcl version)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001865 if echo 'exit [[expr [info tclversion] < 8.0]]' | "$vi_cv_path_tcl" - ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001866 tclver=`echo 'puts [[info tclversion]]' | $vi_cv_path_tcl -`
1867 AC_MSG_RESULT($tclver - OK);
1868 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 +01001869 tcldll=`echo 'puts libtcl[[info tclversion]][[info sharedlibextension]]' | $vi_cv_path_tcl -`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001870
1871 AC_MSG_CHECKING(for location of Tcl include)
Bram Moolenaard0573012017-10-28 21:11:06 +02001872 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001873 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 +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 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 +00001879 fi
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001880 TCL_INC=
Bram Moolenaar071d4272004-06-13 20:20:40 +00001881 for try in $tclinc; do
1882 if test -f "$try/tcl.h"; then
1883 AC_MSG_RESULT($try/tcl.h)
1884 TCL_INC=$try
1885 break
1886 fi
1887 done
1888 if test -z "$TCL_INC"; then
1889 AC_MSG_RESULT(<not found>)
1890 SKIP_TCL=YES
1891 fi
1892 if test -z "$SKIP_TCL"; then
1893 AC_MSG_CHECKING(for location of tclConfig.sh script)
Bram Moolenaard0573012017-10-28 21:11:06 +02001894 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001895 tclcnf=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001896 tclcnf="$tclcnf `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001897 else
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001898 dnl For all macOS, use the value from TCL in case use of, say, homebrew
Bram Moolenaar071d4272004-06-13 20:20:40 +00001899 dnl For Mac OS X 10.3, use the OS-provided framework location
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001900 dnl For Mac OS X 10.14, the OS-provided framework location doesn't contain the headers, so also check the Xcode SDK
1901 tclcnf=`echo $tclinc | sed s/include/lib/g`
1902 tclcnf="$tclcnf /System/Library/Frameworks/Tcl.framework `xcrun --show-sdk-path`/System/Library/Frameworks/Tcl.framework"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001903 fi
1904 for try in $tclcnf; do
Bram Moolenaar49222be2015-12-11 18:11:30 +01001905 if test -f "$try/tclConfig.sh"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001906 AC_MSG_RESULT($try/tclConfig.sh)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001907 . "$try/tclConfig.sh"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001908 dnl use eval, because tcl 8.2 includes ${TCL_DBGX}
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001909 if test "$enable_tclinterp" = "dynamic"; then
1910 TCL_LIBS=`eval echo "$TCL_STUB_LIB_SPEC $TCL_LIBS"`
1911 else
1912 TCL_LIBS=`eval echo "$TCL_LIB_SPEC $TCL_LIBS"`
1913 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001914 dnl Use $TCL_DEFS for -D_THREAD_SAFE et al. But only use the
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001915 dnl "-D_ABC" items. Watch out for -DFOO=long\ long.
Bram Moolenaar4394bff2008-07-24 11:21:31 +00001916 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 +00001917 break
1918 fi
1919 done
1920 if test -z "$TCL_LIBS"; then
1921 AC_MSG_RESULT(<not found>)
1922 AC_MSG_CHECKING(for Tcl library by myself)
1923 tcllib=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001924 tcllib="$tcllib `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001925 for ext in .so .a ; do
1926 for ver in "" $tclver ; do
1927 for try in $tcllib ; do
1928 trylib=tcl$ver$ext
Bram Moolenaar49222be2015-12-11 18:11:30 +01001929 if test -f "$try/lib$trylib" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001930 AC_MSG_RESULT($try/lib$trylib)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001931 TCL_LIBS="-L\"$try\" -ltcl$ver -ldl -lm"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001932 if test "$vim_cv_uname_output" = SunOS &&
1933 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001934 TCL_LIBS="$TCL_LIBS -R $try"
1935 fi
1936 break 3
1937 fi
1938 done
1939 done
1940 done
1941 if test -z "$TCL_LIBS"; then
1942 AC_MSG_RESULT(<not found>)
1943 SKIP_TCL=YES
1944 fi
1945 fi
1946 if test -z "$SKIP_TCL"; then
1947 AC_DEFINE(FEAT_TCL)
1948 TCL_SRC=if_tcl.c
1949 TCL_OBJ=objects/if_tcl.o
1950 TCL_PRO=if_tcl.pro
1951 TCL_CFLAGS="-I$TCL_INC $TCL_DEFS"
1952 fi
1953 fi
1954 else
1955 AC_MSG_RESULT(too old; need Tcl version 8.0 or later)
1956 fi
1957 fi
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001958 if test "$enable_tclinterp" = "dynamic"; then
1959 if test "X$TCL_SRC" != "X" -a "X$tcldll" != "X"; then
1960 AC_DEFINE(DYNAMIC_TCL)
1961 TCL_CFLAGS="-DDYNAMIC_TCL_DLL=\\\"$tcldll\\\" -DDYNAMIC_TCL_VER=\\\"$tclver\\\" $TCL_CFLAGS"
1962 fi
1963 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001964 if test "$fail_if_missing" = "yes" -a -z "$TCL_SRC"; then
1965 AC_MSG_ERROR([could not configure Tcl])
1966 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001967fi
1968AC_SUBST(TCL_SRC)
1969AC_SUBST(TCL_OBJ)
1970AC_SUBST(TCL_PRO)
1971AC_SUBST(TCL_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00001972AC_SUBST(TCL_CFLAGS_EXTRA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001973AC_SUBST(TCL_LIBS)
1974
1975AC_MSG_CHECKING(--enable-rubyinterp argument)
1976AC_ARG_ENABLE(rubyinterp,
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001977 [ --enable-rubyinterp[=OPTS] Include Ruby interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001978 [enable_rubyinterp="no"])
1979AC_MSG_RESULT($enable_rubyinterp)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001980if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00001981 if test "$has_eval" = "no"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001982 AC_MSG_ERROR([cannot use Ruby with tiny or small features])
1983 fi
1984
Bram Moolenaar165641d2010-02-17 16:23:09 +01001985 AC_MSG_CHECKING(--with-ruby-command argument)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001986 AC_SUBST(vi_cv_path_ruby)
Bram Moolenaar948733a2011-05-05 18:10:16 +02001987 AC_ARG_WITH(ruby-command, [ --with-ruby-command=RUBY name of the Ruby command (default: ruby)],
1988 RUBY_CMD="$withval"; vi_cv_path_ruby="$withval"; AC_MSG_RESULT($RUBY_CMD),
1989 RUBY_CMD="ruby"; AC_MSG_RESULT(defaulting to $RUBY_CMD))
Bram Moolenaar165641d2010-02-17 16:23:09 +01001990 AC_PATH_PROG(vi_cv_path_ruby, $RUBY_CMD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001991 if test "X$vi_cv_path_ruby" != "X"; then
1992 AC_MSG_CHECKING(Ruby version)
Bram Moolenaare4efc3b2005-03-07 23:16:51 +00001993 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 +00001994 AC_MSG_RESULT(OK)
Bram Moolenaar81398892012-10-03 21:09:35 +02001995 AC_MSG_CHECKING(Ruby rbconfig)
1996 ruby_rbconfig="RbConfig"
1997 if ! $vi_cv_path_ruby -r rbconfig -e 'RbConfig' >/dev/null 2>/dev/null; then
1998 ruby_rbconfig="Config"
1999 fi
2000 AC_MSG_RESULT($ruby_rbconfig)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002001 AC_MSG_CHECKING(Ruby header files)
Bram Moolenaar81398892012-10-03 21:09:35 +02002002 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 +00002003 if test "X$rubyhdrdir" != "X"; then
2004 AC_MSG_RESULT($rubyhdrdir)
2005 RUBY_CFLAGS="-I$rubyhdrdir"
Bram Moolenaara6fd37b2014-03-27 17:19:09 +01002006 rubyarchdir=`$vi_cv_path_ruby -r rbconfig -e "print ($ruby_rbconfig::CONFIG.has_key? 'rubyarchhdrdir') ? $ruby_rbconfig::CONFIG[['rubyarchhdrdir']] : '$rubyhdrdir/'+$ruby_rbconfig::CONFIG[['arch']]"`
2007 if test -d "$rubyarchdir"; then
2008 RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyarchdir"
Bram Moolenaar165641d2010-02-17 16:23:09 +01002009 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02002010 rubyversion=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['ruby_version']].gsub(/\./, '')[[0,2]]"`
Bram Moolenaar026a4452013-08-07 15:22:23 +02002011 if test "X$rubyversion" = "X"; then
2012 rubyversion=`$vi_cv_path_ruby -e "print ((VERSION rescue RUBY_VERSION)).gsub(/\./, '')[[0,2]]"`
2013 fi
Bram Moolenaar165641d2010-02-17 16:23:09 +01002014 RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
Bram Moolenaar81398892012-10-03 21:09:35 +02002015 rubylibs=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LIBS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002016 if test "X$rubylibs" != "X"; then
2017 RUBY_LIBS="$rubylibs"
2018 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02002019 librubyarg=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBYARG']])"`
2020 librubya=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBY_A']])"`
Bram Moolenaarac499e32013-06-02 19:14:17 +02002021 rubylibdir=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['libdir']])"`
Bram Moolenaard5a986f2020-12-06 21:11:31 +01002022 if test -f "$rubylibdir/$librubya" || expr "$librubyarg" : "-lruby"; then
Bram Moolenaarac499e32013-06-02 19:14:17 +02002023 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
2024 elif test "$librubyarg" = "libruby.a"; then
2025 dnl required on Mac OS 10.3 where libruby.a doesn't exist
2026 librubyarg="-lruby"
2027 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002028 fi
2029
2030 if test "X$librubyarg" != "X"; then
2031 RUBY_LIBS="$librubyarg $RUBY_LIBS"
2032 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02002033 rubyldflags=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LDFLAGS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002034 if test "X$rubyldflags" != "X"; then
Bram Moolenaar996b6d82009-07-22 09:17:23 +00002035 dnl Ruby on Mac OS X 10.5 adds "-arch" flags but these should only
2036 dnl be included if requested by passing --with-mac-arch to
2037 dnl configure, so strip these flags first (if present)
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02002038 rubyldflags=`echo "$rubyldflags" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
Bram Moolenaar996b6d82009-07-22 09:17:23 +00002039 if test "X$rubyldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01002040 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$rubyldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02002041 LDFLAGS="$rubyldflags $LDFLAGS"
2042 fi
Bram Moolenaar996b6d82009-07-22 09:17:23 +00002043 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002044 fi
2045 RUBY_SRC="if_ruby.c"
2046 RUBY_OBJ="objects/if_ruby.o"
2047 RUBY_PRO="if_ruby.pro"
2048 AC_DEFINE(FEAT_RUBY)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002049 if test "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar92021622017-10-12 12:33:43 +02002050 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_ALIASES']].split[[0]]"`
Bram Moolenaar87ea64c2018-08-04 15:13:34 +02002051 if test -z "$libruby_soname"; then
2052 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_SO']]"`
2053 fi
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002054 AC_DEFINE(DYNAMIC_RUBY)
Bram Moolenaar41a41412020-01-07 21:32:19 +01002055 RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby_soname\\\" $RUBY_CFLAGS"
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002056 RUBY_LIBS=
2057 fi
Bram Moolenaar864a28b2020-12-28 21:36:56 +01002058 if test "X$CLANG_VERSION" != "X" -a "$rubyversion" -ge 30; then
2059 RUBY_CFLAGS="$RUBY_CFLAGS -fdeclspec"
2060 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002061 else
Bram Moolenaar165641d2010-02-17 16:23:09 +01002062 AC_MSG_RESULT(not found; disabling Ruby)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002063 fi
2064 else
2065 AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
2066 fi
2067 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01002068
2069 if test "$fail_if_missing" = "yes" -a -z "$RUBY_OBJ"; then
2070 AC_MSG_ERROR([could not configure Ruby])
2071 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002072fi
2073AC_SUBST(RUBY_SRC)
2074AC_SUBST(RUBY_OBJ)
2075AC_SUBST(RUBY_PRO)
2076AC_SUBST(RUBY_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00002077AC_SUBST(RUBY_CFLAGS_EXTRA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002078AC_SUBST(RUBY_LIBS)
2079
2080AC_MSG_CHECKING(--enable-cscope argument)
2081AC_ARG_ENABLE(cscope,
2082 [ --enable-cscope Include cscope interface.], ,
2083 [enable_cscope="no"])
2084AC_MSG_RESULT($enable_cscope)
2085if test "$enable_cscope" = "yes"; then
2086 AC_DEFINE(FEAT_CSCOPE)
2087fi
2088
Bram Moolenaar071d4272004-06-13 20:20:40 +00002089AC_MSG_CHECKING(--disable-netbeans argument)
2090AC_ARG_ENABLE(netbeans,
2091 [ --disable-netbeans Disable NetBeans integration support.],
2092 , [enable_netbeans="yes"])
2093if test "$enable_netbeans" = "yes"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00002094 if test "$has_eval" = "no"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002095 AC_MSG_RESULT([cannot use NetBeans with tiny or small features])
2096 enable_netbeans="no"
2097 else
2098 AC_MSG_RESULT(no)
2099 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002100else
2101 AC_MSG_RESULT(yes)
2102fi
2103
2104AC_MSG_CHECKING(--disable-channel argument)
2105AC_ARG_ENABLE(channel,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002106 [ --disable-channel Disable process communication support.],
Bram Moolenaare0874f82016-01-24 20:36:41 +01002107 , [enable_channel="yes"])
2108if test "$enable_channel" = "yes"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00002109 if test "$has_eval" = "no"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002110 AC_MSG_RESULT([cannot use channels with tiny or small features])
2111 enable_channel="no"
2112 else
2113 AC_MSG_RESULT(no)
2114 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002115else
2116 if test "$enable_netbeans" = "yes"; then
Bram Moolenaar16435482016-01-24 21:31:54 +01002117 AC_MSG_RESULT([yes, netbeans also disabled])
Bram Moolenaare0874f82016-01-24 20:36:41 +01002118 enable_netbeans="no"
2119 else
2120 AC_MSG_RESULT(yes)
2121 fi
2122fi
2123
Bram Moolenaar16435482016-01-24 21:31:54 +01002124if test "$enable_channel" = "yes"; then
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002125 dnl On Solaris we need the socket library, or on Haiku the network library.
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002126 if test "x$HAIKU" = "xyes"; then
2127 AC_CHECK_LIB(network, socket)
2128 else
2129 AC_CHECK_LIB(socket, socket)
2130 fi
2131
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002132 AC_CACHE_CHECK([whether compiling with IPv6 networking is possible], [vim_cv_ipv6_networking],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002133 [AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002134#include <stdio.h>
2135#include <stdlib.h>
2136#include <stdarg.h>
2137#include <fcntl.h>
2138#include <netdb.h>
2139#include <netinet/in.h>
2140#include <errno.h>
2141#include <sys/types.h>
2142#include <sys/socket.h>
2143 /* Check bitfields */
2144 struct nbbuf {
2145 unsigned int initDone:1;
2146 unsigned short signmaplen;
2147 };
2148 ], [
2149 /* Check creating a socket. */
2150 struct sockaddr_in server;
2151 struct addrinfo *res;
2152 (void)socket(AF_INET, SOCK_STREAM, 0);
2153 (void)htons(100);
2154 (void)getaddrinfo("microsoft.com", NULL, NULL, &res);
2155 if (errno == ECONNREFUSED)
2156 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
2157 (void)freeaddrinfo(res);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002158 ])],
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002159 [vim_cv_ipv6_networking="yes"],
2160 [vim_cv_ipv6_networking="no"])])
2161
2162 if test "x$vim_cv_ipv6_networking" = "xyes"; then
2163 AC_DEFINE(FEAT_IPV6)
Bram Moolenaarb6fb0512020-04-18 18:24:18 +02002164 AC_CHECK_FUNCS(inet_ntop)
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002165 else
2166 dnl On Solaris we need the nsl library.
2167 AC_CHECK_LIB(nsl, gethostbyname)
2168 AC_CACHE_CHECK([whether compiling with IPv4 networking is possible], [vim_cv_ipv4_networking],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002169 [AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00002170#include <stdio.h>
2171#include <stdlib.h>
2172#include <stdarg.h>
2173#include <fcntl.h>
2174#include <netdb.h>
2175#include <netinet/in.h>
2176#include <errno.h>
2177#include <sys/types.h>
2178#include <sys/socket.h>
2179 /* Check bitfields */
2180 struct nbbuf {
2181 unsigned int initDone:1;
Bram Moolenaar63de19e2016-12-09 20:11:26 +01002182 unsigned short signmaplen;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002183 };
2184 ], [
2185 /* Check creating a socket. */
2186 struct sockaddr_in server;
2187 (void)socket(AF_INET, SOCK_STREAM, 0);
2188 (void)htons(100);
2189 (void)gethostbyname("microsoft.com");
2190 if (errno == ECONNREFUSED)
2191 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002192 ])],
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002193 [vim_cv_ipv4_networking="yes"],
2194 [vim_cv_ipv4_networking="no"; enable_netbeans="no"; enable_channel="no"])])
2195 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002196fi
2197if test "$enable_netbeans" = "yes"; then
2198 AC_DEFINE(FEAT_NETBEANS_INTG)
2199 NETBEANS_SRC="netbeans.c"
2200 AC_SUBST(NETBEANS_SRC)
2201 NETBEANS_OBJ="objects/netbeans.o"
2202 AC_SUBST(NETBEANS_OBJ)
2203fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002204if test "$enable_channel" = "yes"; then
Bram Moolenaar509ce2a2016-03-11 22:52:15 +01002205 AC_DEFINE(FEAT_JOB_CHANNEL)
Bram Moolenaar8b5866d2020-09-05 15:48:51 +02002206 CHANNEL_SRC="job.c channel.c"
Bram Moolenaare0874f82016-01-24 20:36:41 +01002207 AC_SUBST(CHANNEL_SRC)
Bram Moolenaar8b5866d2020-09-05 15:48:51 +02002208 CHANNEL_OBJ="objects/job.o objects/channel.o"
Bram Moolenaare0874f82016-01-24 20:36:41 +01002209 AC_SUBST(CHANNEL_OBJ)
2210fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002211
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002212AC_MSG_CHECKING(--enable-terminal argument)
2213AC_ARG_ENABLE(terminal,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002214 [ --enable-terminal Enable terminal emulation support.],
Bram Moolenaaref839562017-10-28 20:28:23 +02002215 , [enable_terminal="auto"])
Bram Moolenaar595a4022017-09-03 19:15:57 +02002216if test "$enable_terminal" = "yes" || test "$enable_terminal" = "auto" -a "x$features" = "xhuge" ; then
Bram Moolenaar12471262022-01-18 11:11:25 +00002217 if test "$has_eval" = "no"; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002218 AC_MSG_RESULT([cannot use terminal emulator with tiny or small features])
2219 enable_terminal="no"
2220 else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002221 if test "$enable_terminal" = "auto"; then
2222 enable_terminal="yes"
2223 AC_MSG_RESULT(defaulting to yes)
2224 else
2225 AC_MSG_RESULT(yes)
2226 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002227 fi
2228else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002229 if test "$enable_terminal" = "auto"; then
2230 enable_terminal="no"
2231 AC_MSG_RESULT(defaulting to no)
2232 else
2233 AC_MSG_RESULT(no)
2234 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002235fi
Bram Moolenaar8b423282017-12-16 14:37:06 +01002236if test "$enable_terminal" = "yes" -a "$enable_channel" = "yes"; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002237 AC_DEFINE(FEAT_TERMINAL)
Bram Moolenaar93268052019-10-10 13:22:54 +02002238 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 +02002239 AC_SUBST(TERM_SRC)
Bram Moolenaar93268052019-10-10 13:22:54 +02002240 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 +02002241 AC_SUBST(TERM_OBJ)
Bram Moolenaar823edd12019-10-23 22:35:36 +02002242 TERM_TEST="test_libvterm"
2243 AC_SUBST(TERM_TEST)
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002244fi
2245
Bram Moolenaare42a6d22017-11-12 19:21:51 +01002246AC_MSG_CHECKING(--enable-autoservername argument)
2247AC_ARG_ENABLE(autoservername,
2248 [ --enable-autoservername Automatically define servername at vim startup.], ,
2249 [enable_autoservername="no"])
2250AC_MSG_RESULT($enable_autoservername)
2251if test "$enable_autoservername" = "yes"; then
2252 AC_DEFINE(FEAT_AUTOSERVERNAME)
2253fi
2254
Bram Moolenaar071d4272004-06-13 20:20:40 +00002255AC_MSG_CHECKING(--enable-multibyte argument)
2256AC_ARG_ENABLE(multibyte,
2257 [ --enable-multibyte Include multibyte editing support.], ,
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01002258 [enable_multibyte="yes"])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002259AC_MSG_RESULT($enable_multibyte)
Bram Moolenaar30276f22019-01-24 17:59:39 +01002260if test "$enable_multibyte" != "yes"; then
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01002261 AC_MSG_ERROR([The multi-byte feature can no longer be disabled. If you have
2262 a problem with this, discuss on the Vim mailing list.])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002263fi
2264
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002265dnl Right-to-Left language support for Vim will be included with big features,
2266dnl unless ENABLE_RIGHTLEFT is undefined.
2267AC_MSG_CHECKING(--disable-rightleft argument)
2268AC_ARG_ENABLE(rightleft,
2269 [ --disable-rightleft Do not include Right-to-Left language support.],
2270 , [enable_rightleft="yes"])
2271if test "$enable_rightleft" = "yes"; then
2272 AC_MSG_RESULT(no)
2273else
2274 AC_MSG_RESULT(yes)
2275 AC_DEFINE(DISABLE_RIGHTLEFT)
2276fi
2277
2278dnl Arabic language support for Vim will be included with big features,
2279dnl unless ENABLE_ARABIC is undefined.
2280AC_MSG_CHECKING(--disable-arabic argument)
2281AC_ARG_ENABLE(arabic,
2282 [ --disable-arabic Do not include Arabic language support.],
2283 , [enable_arabic="yes"])
2284if test "$enable_arabic" = "yes"; then
2285 AC_MSG_RESULT(no)
2286else
2287 AC_MSG_RESULT(yes)
2288 AC_DEFINE(DISABLE_ARABIC)
2289fi
2290
Bram Moolenaar14184a32019-02-16 15:10:30 +01002291dnl Farsi language support has been removed, ignore --disable-farsi
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002292AC_ARG_ENABLE(farsi,
Bram Moolenaar14184a32019-02-16 15:10:30 +01002293 [ --disable-farsi Deprecated.],,)
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002294
Bram Moolenaar071d4272004-06-13 20:20:40 +00002295AC_MSG_CHECKING(--enable-xim argument)
2296AC_ARG_ENABLE(xim,
2297 [ --enable-xim Include XIM input support.],
2298 AC_MSG_RESULT($enable_xim),
2299 [enable_xim="auto"; AC_MSG_RESULT(defaulting to auto)])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002300
2301AC_MSG_CHECKING(--enable-fontset argument)
2302AC_ARG_ENABLE(fontset,
2303 [ --enable-fontset Include X fontset output support.], ,
2304 [enable_fontset="no"])
2305AC_MSG_RESULT($enable_fontset)
2306dnl defining FEAT_XFONTSET is delayed, so that it can be disabled for no GUI
2307
2308test -z "$with_x" && with_x=yes
Bram Moolenaard0573012017-10-28 21:11:06 +02002309test "${enable_gui-yes}" != no -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && with_x=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002310if test "$with_x" = no; then
2311 AC_MSG_RESULT(defaulting to: don't HAVE_X11)
2312else
2313 dnl Do this check early, so that its failure can override user requests.
2314
2315 AC_PATH_PROG(xmkmfpath, xmkmf)
2316
2317 AC_PATH_XTRA
2318
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002319 dnl On z/OS Unix the X libraries are DLLs. To use them the code must
Bram Moolenaar071d4272004-06-13 20:20:40 +00002320 dnl be compiled with a special option.
2321 dnl Also add SM, ICE and Xmu to X_EXTRA_LIBS.
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002322 if test "$zOSUnix" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002323 CFLAGS="$CFLAGS -W c,dll"
2324 LDFLAGS="$LDFLAGS -W l,dll"
2325 X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE -lXmu"
2326 fi
2327
2328 dnl On my HPUX system the X include dir is found, but the lib dir not.
Bram Moolenaar70778922020-02-05 20:44:24 +01002329 dnl This is a desperate try to fix this.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002330
2331 if test -d "$x_includes" && test ! -d "$x_libraries"; then
2332 x_libraries=`echo "$x_includes" | sed s/include/lib/`
2333 AC_MSG_RESULT(Corrected X libraries to $x_libraries)
2334 X_LIBS="$X_LIBS -L$x_libraries"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00002335 if test "$vim_cv_uname_output" = SunOS &&
2336 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002337 X_LIBS="$X_LIBS -R $x_libraries"
2338 fi
2339 fi
2340
2341 if test -d "$x_libraries" && test ! -d "$x_includes"; then
2342 x_includes=`echo "$x_libraries" | sed s/lib/include/`
2343 AC_MSG_RESULT(Corrected X includes to $x_includes)
2344 X_CFLAGS="$X_CFLAGS -I$x_includes"
2345 fi
2346
2347 dnl Remove "-I/usr/include " from X_CFLAGS, should not be needed.
2348 X_CFLAGS="`echo $X_CFLAGS\ | sed 's%-I/usr/include %%'`"
2349 dnl Remove "-L/usr/lib " from X_LIBS, should not be needed.
2350 X_LIBS="`echo $X_LIBS\ | sed 's%-L/usr/lib %%'`"
2351 dnl Same for "-R/usr/lib ".
2352 X_LIBS="`echo $X_LIBS\ | sed -e 's%-R/usr/lib %%' -e 's%-R /usr/lib %%'`"
2353
2354
2355 dnl Check if the X11 header files are correctly installed. On some systems
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002356 dnl Xlib.h includes files that don't exist. On some systems X11/Intrinsic.h
2357 dnl is missing.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002358 AC_MSG_CHECKING(if X11 header files can be found)
2359 cflags_save=$CFLAGS
2360 CFLAGS="$CFLAGS $X_CFLAGS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002361 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <X11/Xlib.h>
2362#include <X11/Intrinsic.h>], )],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002363 AC_MSG_RESULT(yes),
2364 AC_MSG_RESULT(no); no_x=yes)
2365 CFLAGS=$cflags_save
2366
2367 if test "${no_x-no}" = yes; then
2368 with_x=no
2369 else
2370 AC_DEFINE(HAVE_X11)
2371 X_LIB="-lXt -lX11";
2372 AC_SUBST(X_LIB)
2373
2374 ac_save_LDFLAGS="$LDFLAGS"
2375 LDFLAGS="-L$x_libraries $LDFLAGS"
2376
2377 dnl Check for -lXdmcp (needed on SunOS 4.1.4)
2378 dnl For HP-UX 10.20 it must be before -lSM -lICE
2379 AC_CHECK_LIB(Xdmcp, _XdmcpAuthDoIt, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lXdmcp"],,
2380 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXdmcp])
2381
2382 dnl Some systems need -lnsl -lsocket when testing for ICE.
2383 dnl The check above doesn't do this, try here (again). Also needed to get
2384 dnl them after Xdmcp. link.sh will remove them when not needed.
2385 dnl Check for other function than above to avoid the cached value
2386 AC_CHECK_LIB(ICE, IceOpenConnection,
2387 [X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE"],, [$X_EXTRA_LIBS])
2388
2389 dnl Check for -lXpm (needed for some versions of Motif)
2390 LDFLAGS="$X_LIBS $ac_save_LDFLAGS"
2391 AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [X_PRE_LIBS="$X_PRE_LIBS -lXpm"],,
2392 [-lXt $X_PRE_LIBS -lXpm -lX11 $X_EXTRA_LIBS])
2393
2394 dnl Check that the X11 header files don't use implicit declarations
2395 AC_MSG_CHECKING(if X11 header files implicitly declare return values)
2396 cflags_save=$CFLAGS
Bram Moolenaard1864592013-05-04 04:40:15 +02002397 dnl -Werror is GCC only, others like Solaris Studio might not like it
2398 if test "$GCC" = yes; then
2399 CFLAGS="$CFLAGS $X_CFLAGS -Werror"
2400 else
2401 CFLAGS="$CFLAGS $X_CFLAGS"
2402 fi
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002403 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <X11/Xlib.h>], )],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002404 AC_MSG_RESULT(no),
2405 CFLAGS="$CFLAGS -Wno-implicit-int"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002406 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <X11/Xlib.h>], )],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002407 AC_MSG_RESULT(yes); cflags_save="$cflags_save -Wno-implicit-int",
2408 AC_MSG_RESULT(test failed)
2409 )
2410 )
2411 CFLAGS=$cflags_save
2412
2413 LDFLAGS="$ac_save_LDFLAGS"
2414
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002415 AC_MSG_CHECKING(size of wchar_t is 2 bytes)
2416 AC_CACHE_VAL(ac_cv_small_wchar_t,
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002417 [AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002418#include <X11/Xlib.h>
2419#if STDC_HEADERS
2420# include <stdlib.h>
2421# include <stddef.h>
2422#endif
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01002423 int main()
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002424 {
2425 if (sizeof(wchar_t) <= 2)
2426 exit(1);
2427 exit(0);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002428 }])],
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002429 ac_cv_small_wchar_t="no",
2430 ac_cv_small_wchar_t="yes",
2431 AC_MSG_ERROR(failed to compile test program))])
2432 AC_MSG_RESULT($ac_cv_small_wchar_t)
2433 if test "x$ac_cv_small_wchar_t" = "xyes" ; then
2434 AC_DEFINE(SMALL_WCHAR_T)
2435 fi
2436
Bram Moolenaar071d4272004-06-13 20:20:40 +00002437 fi
2438fi
2439
Bram Moolenaard2a05492018-07-27 22:35:15 +02002440dnl Check if --with-x was given but it doesn't work.
2441if test "x$with_x" = xno -a "x$with_x_arg" = xyes; then
2442 AC_MSG_ERROR([could not configure X])
2443fi
2444
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002445test "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 +00002446
2447AC_MSG_CHECKING(--enable-gui argument)
2448AC_ARG_ENABLE(gui,
Bram Moolenaarf52fac22022-03-11 16:01:26 +00002449 [ --enable-gui[=OPTS] X11 GUI. [default=auto] [OPTS=auto/no/gtk2/gnome2/gtk3/motif/haiku/photon/carbon]], , enable_gui="auto")
Bram Moolenaar071d4272004-06-13 20:20:40 +00002450
2451dnl Canonicalize the --enable-gui= argument so that it can be easily compared.
2452dnl Do not use character classes for portability with old tools.
2453enable_gui_canon=`echo "_$enable_gui" | \
2454 sed 's/[[ _+-]]//g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
2455
2456dnl Skip everything by default.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002457SKIP_GTK2=YES
Bram Moolenaar1858a842016-02-23 22:30:31 +01002458SKIP_GTK3=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002459SKIP_GNOME=YES
2460SKIP_MOTIF=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002461SKIP_PHOTON=YES
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002462SKIP_HAIKU=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002463GUITYPE=NONE
2464
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002465if test "x$HAIKU" = "xyes"; then
2466 SKIP_HAIKU=
2467 case "$enable_gui_canon" in
2468 no) AC_MSG_RESULT(no GUI support)
2469 SKIP_HAIKU=YES ;;
2470 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
2471 auto) AC_MSG_RESULT(auto - automatic GUI support) ;;
2472 haiku) AC_MSG_RESULT(Haiku GUI support) ;;
2473 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2474 SKIP_HAIKU=YES ;;
2475 esac
2476elif test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002477 SKIP_PHOTON=
2478 case "$enable_gui_canon" in
2479 no) AC_MSG_RESULT(no GUI support)
2480 SKIP_PHOTON=YES ;;
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002481 yes|""|auto) AC_MSG_RESULT(automatic GUI support)
2482 gui_auto=yes ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002483 photon) AC_MSG_RESULT(Photon GUI support) ;;
2484 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2485 SKIP_PHOTON=YES ;;
2486 esac
2487
Bram Moolenaar040f9752020-08-11 23:08:48 +02002488elif test "x$MACOS_X" = "xyes" -a "x$with_x" = "xno" ; then
2489 case "$enable_gui_canon" in
2490 no) AC_MSG_RESULT(no GUI support) ;;
2491 yes|"") AC_MSG_RESULT(yes - automatic GUI support)
2492 gui_auto=yes ;;
2493 auto) AC_MSG_RESULT(auto - disable GUI support for Mac OS) ;;
Bram Moolenaarbe7529e2020-08-13 21:05:39 +02002494 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
Bram Moolenaar040f9752020-08-11 23:08:48 +02002495 esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00002496else
2497
Bram Moolenaar071d4272004-06-13 20:20:40 +00002498 case "$enable_gui_canon" in
2499 no|none) AC_MSG_RESULT(no GUI support) ;;
2500 yes|""|auto) AC_MSG_RESULT(yes/auto - automatic GUI support)
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002501 gui_auto=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002502 SKIP_GTK2=
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002503 SKIP_GTK3=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002504 SKIP_GNOME=
Bram Moolenaarf52fac22022-03-11 16:01:26 +00002505 SKIP_MOTIF=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002506 gtk2) AC_MSG_RESULT(GTK+ 2.x GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002507 SKIP_GTK2=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002508 gnome2) AC_MSG_RESULT(GNOME 2.x GUI support)
2509 SKIP_GNOME=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002510 SKIP_GTK2=;;
Bram Moolenaar98921892016-02-23 17:14:37 +01002511 gtk3) AC_MSG_RESULT(GTK+ 3.x GUI support)
2512 SKIP_GTK3=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002513 motif) AC_MSG_RESULT(Motif GUI support)
2514 SKIP_MOTIF=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002515 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
2516 esac
2517
2518fi
2519
Bram Moolenaar071d4272004-06-13 20:20:40 +00002520if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \
2521 -a "$enable_gui_canon" != "gnome2"; then
2522 AC_MSG_CHECKING(whether or not to look for GTK+ 2)
2523 AC_ARG_ENABLE(gtk2-check,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002524 [ --enable-gtk2-check If auto-select GUI, check for GTK+ 2 [default=yes]],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002525 , enable_gtk2_check="yes")
2526 AC_MSG_RESULT($enable_gtk2_check)
2527 if test "x$enable_gtk2_check" = "xno"; then
2528 SKIP_GTK2=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002529 SKIP_GNOME=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002530 fi
2531fi
2532
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002533if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002534 AC_MSG_CHECKING(whether or not to look for GNOME)
2535 AC_ARG_ENABLE(gnome-check,
2536 [ --enable-gnome-check If GTK GUI, check for GNOME [default=no]],
2537 , enable_gnome_check="no")
2538 AC_MSG_RESULT($enable_gnome_check)
2539 if test "x$enable_gnome_check" = "xno"; then
2540 SKIP_GNOME=YES
2541 fi
2542fi
2543
Bram Moolenaar98921892016-02-23 17:14:37 +01002544if test "x$SKIP_GTK3" != "xYES" -a "$enable_gui_canon" != "gtk3"; then
2545 AC_MSG_CHECKING(whether or not to look for GTK+ 3)
2546 AC_ARG_ENABLE(gtk3-check,
2547 [ --enable-gtk3-check If auto-select GUI, check for GTK+ 3 [default=yes]],
2548 , enable_gtk3_check="yes")
2549 AC_MSG_RESULT($enable_gtk3_check)
2550 if test "x$enable_gtk3_check" = "xno"; then
2551 SKIP_GTK3=YES
2552 fi
2553fi
2554
Bram Moolenaar071d4272004-06-13 20:20:40 +00002555if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then
2556 AC_MSG_CHECKING(whether or not to look for Motif)
2557 AC_ARG_ENABLE(motif-check,
2558 [ --enable-motif-check If auto-select GUI, check for Motif [default=yes]],
2559 , enable_motif_check="yes")
2560 AC_MSG_RESULT($enable_motif_check)
2561 if test "x$enable_motif_check" = "xno"; then
2562 SKIP_MOTIF=YES
2563 fi
2564fi
2565
Bram Moolenaar071d4272004-06-13 20:20:40 +00002566dnl define an autoconf function to check for a specified version of GTK, and
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002567dnl try to compile/link a GTK program.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002568dnl
2569dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002570dnl Test for GTK, and define GTK_CFLAGS, GTK_LIBDIR and GTK_LIBS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002571dnl
2572AC_DEFUN(AM_PATH_GTK,
2573[
2574 if test "X$GTK_CONFIG" != "Xno" -o "X$PKG_CONFIG" != "Xno"; then
2575 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00002576 no_gtk=""
2577 if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2578 && $PKG_CONFIG --exists gtk+-2.0; then
2579 {
Bram Moolenaar98921892016-02-23 17:14:37 +01002580 min_gtk_version=ifelse([$1], ,2.2.0,$1)
2581 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002582 dnl We should be using PKG_CHECK_MODULES() instead of this hack.
2583 dnl But I guess the dependency on pkgconfig.m4 is not wanted or
2584 dnl something like that.
2585 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0`
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002586 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-2.0`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002587 GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0`
2588 gtk_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2589 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2590 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2591 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2592 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2593 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2594 }
Bram Moolenaar98921892016-02-23 17:14:37 +01002595 elif (test "X$SKIP_GTK3" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2596 && $PKG_CONFIG --exists gtk+-3.0; then
2597 {
2598 min_gtk_version=ifelse([$1], ,3.0.0,$1)
2599 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
2600
2601 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-3.0`
2602 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-3.0`
2603 GTK_LIBS=`$PKG_CONFIG --libs gtk+-3.0`
2604 gtk_major_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2605 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2606 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2607 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2608 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2609 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2610 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002611 else
Bram Moolenaar67876de2021-01-12 20:51:24 +01002612 dnl Put some text before the "no" to hint at installing the gtk-dev
2613 dnl packages.
2614 AC_MSG_CHECKING(for GTK -dev package)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002615 no_gtk=yes
2616 fi
2617
2618 if test "x$enable_gtktest" = "xyes" -a "x$no_gtk" = "x"; then
2619 {
2620 ac_save_CFLAGS="$CFLAGS"
2621 ac_save_LIBS="$LIBS"
2622 CFLAGS="$CFLAGS $GTK_CFLAGS"
2623 LIBS="$LIBS $GTK_LIBS"
2624
2625 dnl
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002626 dnl Now check if the installed GTK is sufficiently new.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002627 dnl
2628 rm -f conf.gtktest
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002629 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar071d4272004-06-13 20:20:40 +00002630#include <gtk/gtk.h>
2631#include <stdio.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00002632#if STDC_HEADERS
2633# include <stdlib.h>
2634# include <stddef.h>
2635#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002636
2637int
2638main ()
2639{
2640int major, minor, micro;
2641char *tmp_version;
2642
2643system ("touch conf.gtktest");
2644
2645/* HP/UX 9 (%@#!) writes to sscanf strings */
2646tmp_version = g_strdup("$min_gtk_version");
2647if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
2648 printf("%s, bad version string\n", "$min_gtk_version");
2649 exit(1);
2650 }
2651
2652if ((gtk_major_version > major) ||
2653 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
2654 ((gtk_major_version == major) && (gtk_minor_version == minor) &&
2655 (gtk_micro_version >= micro)))
2656{
2657 return 0;
2658}
2659return 1;
2660}
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002661])],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002662 CFLAGS="$ac_save_CFLAGS"
2663 LIBS="$ac_save_LIBS"
2664 }
2665 fi
2666 if test "x$no_gtk" = x ; then
2667 if test "x$enable_gtktest" = "xyes"; then
2668 AC_MSG_RESULT(yes; found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2669 else
2670 AC_MSG_RESULT(found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2671 fi
2672 ifelse([$2], , :, [$2])
2673 else
2674 {
2675 AC_MSG_RESULT(no)
2676 GTK_CFLAGS=""
2677 GTK_LIBS=""
2678 ifelse([$3], , :, [$3])
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002679 if test "$fail_if_missing" = "yes" -a "X$gui_auto" != "Xyes"; then
2680 AC_MSG_ERROR([could not configure GTK])
2681 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002682 }
2683 fi
2684 }
2685 else
2686 GTK_CFLAGS=""
2687 GTK_LIBS=""
2688 ifelse([$3], , :, [$3])
2689 fi
2690 AC_SUBST(GTK_CFLAGS)
2691 AC_SUBST(GTK_LIBS)
2692 rm -f conf.gtktest
2693])
2694
2695dnl ---------------------------------------------------------------------------
2696dnl gnome
2697dnl ---------------------------------------------------------------------------
2698AC_DEFUN([GNOME_INIT_HOOK],
2699[
2700 AC_SUBST(GNOME_LIBS)
2701 AC_SUBST(GNOME_LIBDIR)
2702 AC_SUBST(GNOME_INCLUDEDIR)
2703
2704 AC_ARG_WITH(gnome-includes,
2705 [ --with-gnome-includes=DIR Specify location of GNOME headers],
2706 [CFLAGS="$CFLAGS -I$withval"]
2707 )
2708
2709 AC_ARG_WITH(gnome-libs,
2710 [ --with-gnome-libs=DIR Specify location of GNOME libs],
2711 [LDFLAGS="$LDFLAGS -L$withval" gnome_prefix=$withval]
2712 )
2713
2714 AC_ARG_WITH(gnome,
2715 [ --with-gnome Specify prefix for GNOME files],
2716 if test x$withval = xyes; then
2717 want_gnome=yes
2718 ifelse([$1], [], :, [$1])
2719 else
2720 if test "x$withval" = xno; then
2721 want_gnome=no
2722 else
2723 want_gnome=yes
2724 LDFLAGS="$LDFLAGS -L$withval/lib"
2725 CFLAGS="$CFLAGS -I$withval/include"
2726 gnome_prefix=$withval/lib
2727 fi
2728 fi,
2729 want_gnome=yes)
2730
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002731 if test "x$want_gnome" = xyes; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002732 {
2733 AC_MSG_CHECKING(for libgnomeui-2.0)
2734 if $PKG_CONFIG --exists libgnomeui-2.0; then
2735 AC_MSG_RESULT(yes)
2736 GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0`
2737 GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0`
2738 GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0`
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002739
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002740 dnl On FreeBSD we need -pthread but pkg-config doesn't include it.
2741 dnl This might not be the right way but it works for me...
2742 AC_MSG_CHECKING(for FreeBSD)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00002743 if test "$vim_cv_uname_output" = FreeBSD; then
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002744 AC_MSG_RESULT(yes, adding -pthread)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002745 GNOME_INCLUDEDIR="$GNOME_INCLUDEDIR -D_THREAD_SAFE"
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002746 GNOME_LIBS="$GNOME_LIBS -pthread"
2747 else
2748 AC_MSG_RESULT(no)
2749 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002750 $1
2751 else
2752 AC_MSG_RESULT(not found)
2753 if test "x$2" = xfail; then
2754 AC_MSG_ERROR(Could not find libgnomeui-2.0 via pkg-config)
2755 fi
2756 fi
2757 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002758 fi
2759])
2760
2761AC_DEFUN([GNOME_INIT],[
2762 GNOME_INIT_HOOK([],fail)
2763])
2764
Bram Moolenaar427f5b62019-06-09 13:43:51 +02002765if test "X$PKG_CONFIG" = "X"; then
2766 AC_PATH_TOOL(PKG_CONFIG, pkg-config, no)
2767fi
2768
Bram Moolenaar071d4272004-06-13 20:20:40 +00002769
2770dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002771dnl Check for GTK2. If it fails, then continue on for Motif as before...
Bram Moolenaar071d4272004-06-13 20:20:40 +00002772dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002773if test -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002774
2775 AC_MSG_CHECKING(--disable-gtktest argument)
2776 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2777 , enable_gtktest=yes)
2778 if test "x$enable_gtktest" = "xyes" ; then
2779 AC_MSG_RESULT(gtk test enabled)
2780 else
2781 AC_MSG_RESULT(gtk test disabled)
2782 fi
2783
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002784 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002785 dnl First try finding version 2.2.0 or later. The 2.0.x series has
2786 dnl problems (bold fonts, --remote doesn't work).
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002787 dnl Disable checking for GTK3 here, otherwise it's found when GTK2 is not
2788 dnl found.
2789 save_skip_gtk3=$SKIP_GTK3
2790 SKIP_GTK3=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002791 AM_PATH_GTK(2.2.0,
2792 [GUI_LIB_LOC="$GTK_LIBDIR"
2793 GTK_LIBNAME="$GTK_LIBS"
2794 GUI_INC_LOC="$GTK_CFLAGS"], )
2795 if test "x$GTK_CFLAGS" != "x"; then
Bram Moolenaar98921892016-02-23 17:14:37 +01002796 SKIP_GTK3=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002797 SKIP_MOTIF=YES
2798 GUITYPE=GTK
2799 AC_SUBST(GTK_LIBNAME)
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002800 else
2801 SKIP_GTK3=$save_skip_gtk3
Bram Moolenaar071d4272004-06-13 20:20:40 +00002802 fi
2803 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002804 if test "x$GUITYPE" = "xGTK"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002805 dnl
2806 dnl if GTK exists, then check for GNOME.
2807 dnl
2808 if test -z "$SKIP_GNOME"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002809 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002810 GNOME_INIT_HOOK([have_gnome=yes])
2811 if test "x$have_gnome" = xyes ; then
2812 AC_DEFINE(FEAT_GUI_GNOME)
2813 GUI_INC_LOC="$GUI_INC_LOC $GNOME_INCLUDEDIR"
2814 GTK_LIBNAME="$GTK_LIBNAME $GNOME_LIBDIR $GNOME_LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002815 fi
2816 }
2817 fi
2818 fi
2819fi
2820
Bram Moolenaar98921892016-02-23 17:14:37 +01002821
2822dnl ---------------------------------------------------------------------------
2823dnl Check for GTK3.
2824dnl ---------------------------------------------------------------------------
2825if test -z "$SKIP_GTK3"; then
2826
2827 AC_MSG_CHECKING(--disable-gtktest argument)
2828 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2829 , enable_gtktest=yes)
2830 if test "x$enable_gtktest" = "xyes" ; then
2831 AC_MSG_RESULT(gtk test enabled)
2832 else
2833 AC_MSG_RESULT(gtk test disabled)
2834 fi
2835
Bram Moolenaar98921892016-02-23 17:14:37 +01002836 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002837 save_skip_gtk2=$SKIP_GTK2
2838 SKIP_GTK2=YES
Bram Moolenaar98921892016-02-23 17:14:37 +01002839 AM_PATH_GTK(3.0.0,
2840 [GUI_LIB_LOC="$GTK_LIBDIR"
2841 GTK_LIBNAME="$GTK_LIBS"
2842 GUI_INC_LOC="$GTK_CFLAGS"], )
2843 if test "x$GTK_CFLAGS" != "x"; then
2844 SKIP_GTK2=YES
2845 SKIP_GNOME=YES
Bram Moolenaar98921892016-02-23 17:14:37 +01002846 SKIP_MOTIF=YES
2847 GUITYPE=GTK
2848 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar98921892016-02-23 17:14:37 +01002849 AC_DEFINE(USE_GTK3)
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002850 else
2851 SKIP_GTK2=$save_skip_gtk2
Bram Moolenaar98921892016-02-23 17:14:37 +01002852 fi
2853 fi
2854fi
2855
Bram Moolenaard2e03f02016-01-02 22:46:36 +01002856dnl Check the version of Gdk-Pixbuf. If the version is 2.31 or later and
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002857dnl glib-compile-resources is found in PATH, use GResource.
2858if test "x$GUITYPE" = "xGTK"; then
2859 AC_MSG_CHECKING([version of Gdk-Pixbuf])
2860 gdk_pixbuf_version=`$PKG_CONFIG --modversion gdk-pixbuf-2.0`
2861 if test "x$gdk_pixbuf_version" != x ; then
2862 gdk_pixbuf_version_minor=`echo $gdk_pixbuf_version | \
2863 sed -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/'`
2864 if test "x$gdk_pixbuf_version_minor" != x -a \
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002865 $gdk_pixbuf_version_minor -ge 31 ; then
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002866 AC_MSG_RESULT([OK.])
2867 AC_PATH_PROG(GLIB_COMPILE_RESOURCES,[glib-compile-resources],no)
2868 AC_MSG_CHECKING([glib-compile-resources])
2869 if test "x$GLIB_COMPILE_RESOURCES" = xno ; then
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002870 GLIB_COMPILE_RESOURCES=""
2871 AC_MSG_RESULT([cannot be found in PATH.])
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002872 else
2873 AC_MSG_RESULT([usable.])
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002874 AC_DEFINE(USE_GRESOURCE)
2875 GRESOURCE_SRC="auto/gui_gtk_gresources.c"
2876 GRESOURCE_OBJ="objects/gui_gtk_gresources.o"
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002877 fi
2878 else
2879 AC_MSG_RESULT([not usable.])
2880 fi
2881 else
2882 AC_MSG_RESULT([cannot obtain from pkg_config.])
2883 fi
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002884
2885 AC_MSG_CHECKING([--disable-icon-cache-update argument])
2886 AC_ARG_ENABLE(icon_cache_update,
2887 [ --disable-icon-cache-update update disabled],
2888 [],
2889 [enable_icon_cache_update="yes"])
2890 if test "$enable_icon_cache_update" = "yes"; then
2891 AC_MSG_RESULT([not set])
2892 AC_PATH_PROG(GTK_UPDATE_ICON_CACHE,[gtk-update-icon-cache],no)
2893 if test "x$GTK_UPDATE_ICON_CACHE" = "xno" ; then
2894 AC_MSG_RESULT([not found in PATH.])
2895 fi
2896 else
2897 AC_MSG_RESULT([update disabled])
2898 fi
2899
2900 AC_MSG_CHECKING([--disable-desktop-database-update argument])
2901 AC_ARG_ENABLE(desktop_database_update,
2902 [ --disable-desktop-database-update update disabled],
2903 [],
2904 [enable_desktop_database_update="yes"])
2905 if test "$enable_desktop_database_update" = "yes"; then
2906 AC_MSG_RESULT([not set])
2907 AC_PATH_PROG(UPDATE_DESKTOP_DATABASE,[update-desktop-database],no)
2908 if test "x$UPDATE_DESKTOP_DATABASE" = "xno" ; then
2909 AC_MSG_RESULT([not found in PATH.])
2910 fi
2911 else
2912 AC_MSG_RESULT([update disabled])
2913 fi
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002914fi
2915AC_SUBST(GLIB_COMPILE_RESOURCES)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002916AC_SUBST(GRESOURCE_SRC)
2917AC_SUBST(GRESOURCE_OBJ)
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002918AC_SUBST(GTK_UPDATE_ICON_CACHE)
2919AC_SUBST(UPDATE_DESKTOP_DATABASE)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002920
Bram Moolenaar071d4272004-06-13 20:20:40 +00002921dnl Check for Motif include files location.
2922dnl The LAST one found is used, this makes the highest version to be used,
2923dnl e.g. when Motif1.2 and Motif2.0 are both present.
2924
2925if test -z "$SKIP_MOTIF"; then
2926 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"
2927 dnl Remove "-I" from before $GUI_INC_LOC if it's there
2928 GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`"
2929
2930 AC_MSG_CHECKING(for location of Motif GUI includes)
2931 gui_includes="`echo $x_includes|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC"
2932 GUI_INC_LOC=
2933 for try in $gui_includes; do
2934 if test -f "$try/Xm/Xm.h"; then
2935 GUI_INC_LOC=$try
2936 fi
2937 done
2938 if test -n "$GUI_INC_LOC"; then
2939 if test "$GUI_INC_LOC" = /usr/include; then
2940 GUI_INC_LOC=
2941 AC_MSG_RESULT(in default path)
2942 else
2943 AC_MSG_RESULT($GUI_INC_LOC)
2944 fi
2945 else
2946 AC_MSG_RESULT(<not found>)
2947 SKIP_MOTIF=YES
2948 fi
2949fi
2950
2951dnl Check for Motif library files location. In the same order as the include
2952dnl files, to avoid a mixup if several versions are present
2953
2954if test -z "$SKIP_MOTIF"; then
2955 AC_MSG_CHECKING(--with-motif-lib argument)
2956 AC_ARG_WITH(motif-lib,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002957 [ --with-motif-lib=STRING Library for Motif ],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002958 [ MOTIF_LIBNAME="${withval}" ] )
2959
2960 if test -n "$MOTIF_LIBNAME"; then
2961 AC_MSG_RESULT($MOTIF_LIBNAME)
2962 GUI_LIB_LOC=
2963 else
2964 AC_MSG_RESULT(no)
2965
2966 dnl Remove "-L" from before $GUI_LIB_LOC if it's there
2967 GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
2968
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002969 dnl Ubuntu has libXm.so in /usr/lib/i386-linux-gnu and elsewhere. The
2970 dnl linker will figure out which one to use, we only check if one exists.
Kelvin Leeb4716902022-04-04 17:20:01 +01002971 dnl Cygwin uses the .dll.a extension.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002972 AC_MSG_CHECKING(for location of Motif GUI libs)
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002973 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 +00002974 GUI_LIB_LOC=
2975 for try in $gui_libs; do
Kelvin Leeb4716902022-04-04 17:20:01 +01002976 for libtry in "$try"/libXm.a "$try"/libXm.dll.a "$try"/libXm.so* "$try"/libXm.sl "$try"/libXm.dylib; do
Bram Moolenaar071d4272004-06-13 20:20:40 +00002977 if test -f "$libtry"; then
2978 GUI_LIB_LOC=$try
2979 fi
2980 done
2981 done
2982 if test -n "$GUI_LIB_LOC"; then
2983 dnl Remove /usr/lib, it causes trouble on some systems
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002984 if test "$GUI_LIB_LOC" = /usr/lib \
2985 -o "$GUI_LIB_LOC" = /usr/lib/i386-linux-gnu \
2986 -o "$GUI_LIB_LOC" = /usr/lib/x86_64-linux-gnu; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002987 GUI_LIB_LOC=
2988 AC_MSG_RESULT(in default path)
2989 else
2990 if test -n "$GUI_LIB_LOC"; then
2991 AC_MSG_RESULT($GUI_LIB_LOC)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00002992 if test "$vim_cv_uname_output" = SunOS &&
2993 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002994 GUI_LIB_LOC="$GUI_LIB_LOC -R $GUI_LIB_LOC"
2995 fi
2996 fi
2997 fi
2998 MOTIF_LIBNAME=-lXm
2999 else
3000 AC_MSG_RESULT(<not found>)
3001 SKIP_MOTIF=YES
3002 fi
3003 fi
3004fi
3005
3006if test -z "$SKIP_MOTIF"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003007 GUITYPE=MOTIF
3008 AC_SUBST(MOTIF_LIBNAME)
3009fi
3010
Bram Moolenaare2adcf32022-03-12 11:57:25 +00003011if test -z "$SKIP_MOTIF"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003012 dnl Prepend -I and -L to $GUI_INC_LOC and $GUI_LIB_LOC if not empty
3013 dnl Avoid adding it when it twice
3014 if test -n "$GUI_INC_LOC"; then
3015 GUI_INC_LOC=-I"`echo $GUI_INC_LOC|sed 's%-I%%'`"
3016 fi
3017 if test -n "$GUI_LIB_LOC"; then
3018 GUI_LIB_LOC=-L"`echo $GUI_LIB_LOC|sed 's%-L%%'`"
3019 fi
3020
3021 dnl Check for -lXext and then for -lXmu
3022 ldflags_save=$LDFLAGS
3023 LDFLAGS="$X_LIBS $LDFLAGS"
3024 AC_CHECK_LIB(Xext, XShapeQueryExtension, [GUI_X_LIBS="-lXext"],,
3025 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3026 dnl For Solaris we need -lw and -ldl before linking with -lXmu works.
3027 AC_CHECK_LIB(w, wslen, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lw"],,
3028 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3029 AC_CHECK_LIB(dl, dlsym, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldl"],,
3030 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3031 AC_CHECK_LIB(Xmu, XmuCreateStippledPixmap, [GUI_X_LIBS="-lXmu $GUI_X_LIBS"],,
3032 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3033 if test -z "$SKIP_MOTIF"; then
3034 AC_CHECK_LIB(Xp, XpEndJob, [GUI_X_LIBS="-lXp $GUI_X_LIBS"],,
3035 [$GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3036 fi
3037 LDFLAGS=$ldflags_save
3038
3039 dnl Execute xmkmf to figure out if -DNARROWPROTO is needed.
3040 AC_MSG_CHECKING(for extra X11 defines)
3041 NARROW_PROTO=
3042 rm -fr conftestdir
3043 if mkdir conftestdir; then
3044 cd conftestdir
3045 cat > Imakefile <<'EOF'
3046acfindx:
3047 @echo 'NARROW_PROTO="${PROTO_DEFINES}"'
3048EOF
3049 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
3050 eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
3051 fi
3052 cd ..
3053 rm -fr conftestdir
3054 fi
3055 if test -z "$NARROW_PROTO"; then
3056 AC_MSG_RESULT(no)
3057 else
3058 AC_MSG_RESULT($NARROW_PROTO)
3059 fi
3060 AC_SUBST(NARROW_PROTO)
3061fi
3062
3063dnl Look for XSMP support - but don't necessarily restrict it to X11 GUIs
3064dnl use the X11 include path
3065if test "$enable_xsmp" = "yes"; then
3066 cppflags_save=$CPPFLAGS
3067 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3068 AC_CHECK_HEADERS(X11/SM/SMlib.h)
3069 CPPFLAGS=$cppflags_save
3070fi
3071
3072
Bram Moolenaarf52fac22022-03-11 16:01:26 +00003073if test -z "$SKIP_MOTIF" -o -z "$SKIP_GTK2" -o -z "$SKIP_GTK3"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003074 dnl Check for X11/xpm.h and X11/Sunkeysym.h with the GUI include path
3075 cppflags_save=$CPPFLAGS
3076 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3077 AC_CHECK_HEADERS(X11/xpm.h X11/Sunkeysym.h)
3078
3079 dnl automatically disable XIM when XIMtext isn't in X11/Xlib.h
3080 if test ! "$enable_xim" = "no"; then
3081 AC_MSG_CHECKING(for XIMText in X11/Xlib.h)
3082 AC_EGREP_CPP(XIMText, [#include <X11/Xlib.h>],
3083 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +02003084 AC_MSG_RESULT(no; xim has been disabled); enable_xim="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00003085 fi
3086 CPPFLAGS=$cppflags_save
3087
Bram Moolenaar54612582019-11-21 17:13:31 +01003088 dnl automatically enable XIM in the GUI
3089 if test "$enable_xim" = "auto" -a "x$GUITYPE" != "xNONE" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003090 AC_MSG_RESULT(X GUI selected; xim has been enabled)
3091 enable_xim="yes"
3092 fi
3093fi
3094
Bram Moolenaarf52fac22022-03-11 16:01:26 +00003095if test -z "$SKIP_MOTIF"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003096 cppflags_save=$CPPFLAGS
3097 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00003098dnl Xmu/Editres.h may exist but can only be used after including Intrinsic.h
3099 AC_MSG_CHECKING([for X11/Xmu/Editres.h])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003100 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00003101#include <X11/Intrinsic.h>
3102#include <X11/Xmu/Editres.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003103 [int i; i = 0;])],
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00003104 AC_MSG_RESULT(yes)
3105 AC_DEFINE(HAVE_X11_XMU_EDITRES_H),
3106 AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003107 CPPFLAGS=$cppflags_save
3108fi
3109
Bram Moolenaar0b40d082022-03-08 13:32:37 +00003110dnl Only use the Xm directory when compiling Motif.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003111if test -z "$SKIP_MOTIF"; then
3112 cppflags_save=$CPPFLAGS
3113 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003114 if test "$zOSUnix" = "yes"; then
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003115 AC_CHECK_HEADERS(Xm/Xm.h)
Bram Moolenaar77c19352012-06-13 19:19:41 +02003116 else
Bram Moolenaarde1d7342022-06-05 20:03:17 +01003117 AC_CHECK_HEADERS(Xm/Xm.h Xm/XpmP.h Xm/JoinSideT.h Xm/TraitP.h Xm/Manager.h Xm/UnhighlightT.h Xm/Notebook.h)
Bram Moolenaare5303952022-06-19 17:05:47 +01003118 fi
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003119
Bram Moolenaar77c19352012-06-13 19:19:41 +02003120 if test "x$ac_cv_header_Xm_XpmP_h" = "xyes"; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003121 dnl Solaris uses XpmAttributes_21, very annoying.
3122 AC_MSG_CHECKING([for XpmAttributes_21 in Xm/XpmP.h])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003123 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <Xm/XpmP.h>], [XpmAttributes_21 attr;])],
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003124 AC_MSG_RESULT(yes); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes_21),
3125 AC_MSG_RESULT(no); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
3126 )
3127 else
Bram Moolenaar57657d82006-04-21 22:12:41 +00003128 AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003129 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003130 CPPFLAGS=$cppflags_save
3131fi
3132
3133if test "x$GUITYPE" = "xNONE" -a "$enable_xim" = "yes"; then
3134 AC_MSG_RESULT(no GUI selected; xim has been disabled)
3135 enable_xim="no"
3136fi
3137if test "x$GUITYPE" = "xNONE" -a "$enable_fontset" = "yes"; then
3138 AC_MSG_RESULT(no GUI selected; fontset has been disabled)
3139 enable_fontset="no"
3140fi
Bram Moolenaar182c5be2010-06-25 05:37:59 +02003141if test "x$GUITYPE:$enable_fontset" = "xGTK:yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003142 AC_MSG_RESULT(GTK+ 2 GUI selected; fontset has been disabled)
3143 enable_fontset="no"
3144fi
3145
Bram Moolenaarb3f74062020-02-26 16:16:53 +01003146dnl There is no test for the Haiku GUI, if it's selected it's used
3147if test -z "$SKIP_HAIKU"; then
3148 GUITYPE=HAIKUGUI
3149fi
3150
Bram Moolenaar071d4272004-06-13 20:20:40 +00003151if test -z "$SKIP_PHOTON"; then
3152 GUITYPE=PHOTONGUI
3153fi
3154
3155AC_SUBST(GUI_INC_LOC)
3156AC_SUBST(GUI_LIB_LOC)
3157AC_SUBST(GUITYPE)
3158AC_SUBST(GUI_X_LIBS)
3159
3160if test "$enable_workshop" = "yes" -a -n "$SKIP_MOTIF"; then
3161 AC_MSG_ERROR([cannot use workshop without Motif])
3162fi
3163
3164dnl defining FEAT_XIM and FEAT_XFONTSET is delayed, so that they can be disabled
3165if test "$enable_xim" = "yes"; then
3166 AC_DEFINE(FEAT_XIM)
3167fi
3168if test "$enable_fontset" = "yes"; then
3169 AC_DEFINE(FEAT_XFONTSET)
3170fi
3171
3172
3173dnl ---------------------------------------------------------------------------
3174dnl end of GUI-checking
3175dnl ---------------------------------------------------------------------------
3176
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003177AC_MSG_CHECKING([for /proc link to executable])
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003178if test -L "/proc/self/exe"; then
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003179 dnl Linux
3180 AC_MSG_RESULT([/proc/self/exe])
3181 AC_DEFINE(PROC_EXE_LINK, "/proc/self/exe")
3182elif test -L "/proc/self/path/a.out"; then
3183 dnl Solaris
3184 AC_MSG_RESULT([/proc/self/path/a.out])
3185 AC_DEFINE(PROC_EXE_LINK, "/proc/self/path/a.out")
3186elif test -L "/proc/curproc/file"; then
3187 dnl FreeBSD
3188 AC_MSG_RESULT([/proc/curproc/file])
3189 AC_DEFINE(PROC_EXE_LINK, "/proc/curproc/file")
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003190else
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003191 AC_MSG_RESULT(no)
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003192fi
3193
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003194dnl Check for Cygwin, which needs an extra source file if not using X11
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003195AC_MSG_CHECKING(for CYGWIN or MSYS environment)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00003196case $vim_cv_uname_output in
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003197 CYGWIN*|MSYS*) CYGWIN=yes; AC_MSG_RESULT(yes)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003198 AC_MSG_CHECKING(for CYGWIN clipboard support)
3199 if test "x$with_x" = "xno" ; then
3200 OS_EXTRA_SRC=winclip.c; OS_EXTRA_OBJ=objects/winclip.o
3201 AC_MSG_RESULT(yes)
3202 AC_DEFINE(FEAT_CYGWIN_WIN32_CLIPBOARD)
3203 else
3204 AC_MSG_RESULT(no - using X11)
3205 fi ;;
3206
3207 *) CYGWIN=no; AC_MSG_RESULT(no);;
3208esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00003209
Bram Moolenaar071d4272004-06-13 20:20:40 +00003210dnl Checks for libraries and include files.
3211
Bram Moolenaar446cb832008-06-24 21:56:24 +00003212AC_CACHE_CHECK([whether toupper is broken], [vim_cv_toupper_broken],
3213 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003214 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003215#include "confdefs.h"
3216#include <ctype.h>
3217#if STDC_HEADERS
3218# include <stdlib.h>
3219# include <stddef.h>
3220#endif
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01003221int main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003222 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003223 vim_cv_toupper_broken=yes
3224 ],[
3225 vim_cv_toupper_broken=no
3226 ],[
3227 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_toupper_broken')
3228 ])])
3229
3230if test "x$vim_cv_toupper_broken" = "xyes" ; then
3231 AC_DEFINE(BROKEN_TOUPPER)
3232fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003233
3234AC_MSG_CHECKING(whether __DATE__ and __TIME__ work)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003235AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>], [printf("(" __DATE__ " " __TIME__ ")");])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003236 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DATE_TIME),
3237 AC_MSG_RESULT(no))
3238
Bram Moolenaar0c094b92009-05-14 20:20:33 +00003239AC_MSG_CHECKING(whether __attribute__((unused)) is allowed)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003240AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>], [int x __attribute__((unused));])],
Bram Moolenaar0c094b92009-05-14 20:20:33 +00003241 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ATTRIBUTE_UNUSED),
3242 AC_MSG_RESULT(no))
3243
Bram Moolenaar071d4272004-06-13 20:20:40 +00003244dnl Checks for header files.
3245AC_CHECK_HEADER(elf.h, HAS_ELF=1)
3246dnl AC_CHECK_HEADER(dwarf.h, SVR4=1)
3247if test "$HAS_ELF" = 1; then
3248 AC_CHECK_LIB(elf, main)
3249fi
3250
3251AC_HEADER_DIRENT
3252
Bram Moolenaar071d4272004-06-13 20:20:40 +00003253dnl If sys/wait.h is not found it might still exist but not be POSIX
3254dnl compliant. In that case we define HAVE_UNION_WAIT (for NeXT)
3255if test $ac_cv_header_sys_wait_h = no; then
3256 AC_MSG_CHECKING([for sys/wait.h that defines union wait])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003257 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/wait.h>],
3258 [union wait xx, yy; xx = yy])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003259 AC_MSG_RESULT(yes)
3260 AC_DEFINE(HAVE_SYS_WAIT_H)
3261 AC_DEFINE(HAVE_UNION_WAIT),
3262 AC_MSG_RESULT(no))
3263fi
3264
Bram Moolenaar779a7752016-01-30 23:26:34 +01003265AC_CHECK_HEADERS(stdint.h stdlib.h string.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003266 sys/select.h sys/utsname.h termcap.h fcntl.h \
3267 sgtty.h sys/ioctl.h sys/time.h sys/types.h \
3268 termio.h iconv.h inttypes.h langinfo.h math.h \
3269 unistd.h stropts.h errno.h sys/resource.h \
3270 sys/systeminfo.h locale.h sys/stream.h termios.h \
3271 libc.h sys/statfs.h poll.h sys/poll.h pwd.h \
Bram Moolenaar1ecc5e42019-01-26 15:12:55 +01003272 utime.h sys/param.h sys/ptms.h libintl.h libgen.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003273 util/debug.h util/msg18n.h frame.h sys/acl.h \
3274 sys/access.h sys/sysinfo.h wchar.h wctype.h)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003275
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003276dnl sys/ptem.h depends on sys/stream.h on Solaris
3277AC_CHECK_HEADERS(sys/ptem.h, [], [],
3278[#if defined HAVE_SYS_STREAM_H
3279# include <sys/stream.h>
3280#endif])
3281
Bram Moolenaar32f31b12009-05-21 13:20:59 +00003282dnl sys/sysctl.h depends on sys/param.h on OpenBSD
3283AC_CHECK_HEADERS(sys/sysctl.h, [], [],
3284[#if defined HAVE_SYS_PARAM_H
3285# include <sys/param.h>
3286#endif])
3287
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003288
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003289dnl pthread_np.h may exist but can only be used after including pthread.h
3290AC_MSG_CHECKING([for pthread_np.h])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003291AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003292#include <pthread.h>
3293#include <pthread_np.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003294 [int i; i = 0;])],
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003295 AC_MSG_RESULT(yes)
3296 AC_DEFINE(HAVE_PTHREAD_NP_H),
3297 AC_MSG_RESULT(no))
3298
Bram Moolenaare344bea2005-09-01 20:46:49 +00003299AC_CHECK_HEADERS(strings.h)
Bram Moolenaard0573012017-10-28 21:11:06 +02003300if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00003301 dnl The strings.h file on OS/X contains a warning and nothing useful.
3302 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3303else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003304
3305dnl Check if strings.h and string.h can both be included when defined.
3306AC_MSG_CHECKING([if strings.h can be included after string.h])
3307cppflags_save=$CPPFLAGS
3308CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003309AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003310#if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO)
3311# define _NO_PROTO /* like in os_unix.h, causes conflict for AIX (Winn) */
3312 /* but don't do it on AIX 5.1 (Uribarri) */
3313#endif
3314#ifdef HAVE_XM_XM_H
3315# include <Xm/Xm.h> /* This breaks it for HP-UX 11 (Squassabia) */
3316#endif
3317#ifdef HAVE_STRING_H
3318# include <string.h>
3319#endif
3320#if defined(HAVE_STRINGS_H)
3321# include <strings.h>
3322#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003323 ], [int i; i = 0;])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003324 AC_MSG_RESULT(yes),
3325 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3326 AC_MSG_RESULT(no))
3327CPPFLAGS=$cppflags_save
Bram Moolenaar9372a112005-12-06 19:59:18 +00003328fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003329
3330dnl Checks for typedefs, structures, and compiler characteristics.
3331AC_PROG_GCC_TRADITIONAL
3332AC_C_CONST
Bram Moolenaar76243bd2009-03-02 01:47:02 +00003333AC_C_VOLATILE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003334AC_TYPE_MODE_T
3335AC_TYPE_OFF_T
3336AC_TYPE_PID_T
3337AC_TYPE_SIZE_T
3338AC_TYPE_UID_T
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003339AC_TYPE_UINT32_T
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003340
Bram Moolenaar071d4272004-06-13 20:20:40 +00003341AC_HEADER_TIME
3342AC_CHECK_TYPE(ino_t, long)
3343AC_CHECK_TYPE(dev_t, unsigned)
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003344AC_C_BIGENDIAN(,,,)
Bram Moolenaar136f29a2016-02-27 20:14:15 +01003345AC_C_INLINE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003346
3347AC_MSG_CHECKING(for rlim_t)
3348if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
3349 AC_MSG_RESULT([(cached) $ac_cv_type_rlim_t])
3350else
3351 AC_EGREP_CPP(dnl
3352changequote(<<,>>)dnl
3353<<(^|[^a-zA-Z_0-9])rlim_t[^a-zA-Z_0-9]>>dnl
3354changequote([,]),
3355 [
3356#include <sys/types.h>
3357#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003358# include <stdlib.h>
3359# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003360#endif
3361#ifdef HAVE_SYS_RESOURCE_H
Bram Moolenaar446cb832008-06-24 21:56:24 +00003362# include <sys/resource.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003363#endif
3364 ], ac_cv_type_rlim_t=yes, ac_cv_type_rlim_t=no)
3365 AC_MSG_RESULT($ac_cv_type_rlim_t)
3366fi
3367if test $ac_cv_type_rlim_t = no; then
3368 cat >> confdefs.h <<\EOF
3369#define rlim_t unsigned long
3370EOF
3371fi
3372
3373AC_MSG_CHECKING(for stack_t)
3374if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then
3375 AC_MSG_RESULT([(cached) $ac_cv_type_stack_t])
3376else
3377 AC_EGREP_CPP(stack_t,
3378 [
3379#include <sys/types.h>
3380#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003381# include <stdlib.h>
3382# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003383#endif
3384#include <signal.h>
3385 ], ac_cv_type_stack_t=yes, ac_cv_type_stack_t=no)
3386 AC_MSG_RESULT($ac_cv_type_stack_t)
3387fi
3388if test $ac_cv_type_stack_t = no; then
3389 cat >> confdefs.h <<\EOF
3390#define stack_t struct sigaltstack
3391EOF
3392fi
3393
3394dnl BSDI uses ss_base while others use ss_sp for the stack pointer.
3395AC_MSG_CHECKING(whether stack_t has an ss_base field)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003396AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003397#include <sys/types.h>
3398#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003399# include <stdlib.h>
3400# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003401#endif
3402#include <signal.h>
3403#include "confdefs.h"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003404 ], [stack_t sigstk; sigstk.ss_base = 0; ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003405 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SS_BASE),
3406 AC_MSG_RESULT(no))
3407
3408olibs="$LIBS"
3409AC_MSG_CHECKING(--with-tlib argument)
3410AC_ARG_WITH(tlib, [ --with-tlib=library terminal library to be used ],)
3411if test -n "$with_tlib"; then
3412 AC_MSG_RESULT($with_tlib)
3413 LIBS="$LIBS -l$with_tlib"
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003414 AC_MSG_CHECKING(for linking with $with_tlib library)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003415 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], AC_MSG_RESULT(OK), AC_MSG_ERROR(FAILED))
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003416 dnl Need to check for tgetent() below.
3417 olibs="$LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003418else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003419 AC_MSG_RESULT([empty: automatic terminal library selection])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003420 dnl On HP-UX 10.10 termcap or termlib should be used instead of
3421 dnl curses, because curses is much slower.
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003422 dnl Newer versions of ncurses are preferred over anything, except
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02003423 dnl when tinfo has been split off, it contains all we need.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003424 dnl Older versions of ncurses have bugs, get a new one!
3425 dnl Digital Unix (OSF1) should use curses (Ronald Schild).
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00003426 dnl On SCO Openserver should prefer termlib (Roger Cornelius).
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00003427 case "$vim_cv_uname_output" in
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003428 OSF1|SCO_SV) tlibs="tinfo ncurses curses termlib termcap";;
3429 *) tlibs="tinfo ncurses termlib termcap curses";;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003430 esac
3431 for libname in $tlibs; do
3432 AC_CHECK_LIB(${libname}, tgetent,,)
3433 if test "x$olibs" != "x$LIBS"; then
3434 dnl It's possible that a library is found but it doesn't work
3435 dnl e.g., shared library that cannot be found
3436 dnl compile and run a test program to be sure
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003437 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003438#ifdef HAVE_TERMCAP_H
3439# include <termcap.h>
3440#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003441#if STDC_HEADERS
3442# include <stdlib.h>
3443# include <stddef.h>
3444#endif
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01003445int main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003446 res="OK", res="FAIL", res="FAIL")
3447 if test "$res" = "OK"; then
3448 break
3449 fi
3450 AC_MSG_RESULT($libname library is not usable)
3451 LIBS="$olibs"
3452 fi
3453 done
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003454 if test "x$olibs" = "x$LIBS"; then
3455 AC_MSG_RESULT(no terminal library found)
3456 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003457fi
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003458
3459if test "x$olibs" = "x$LIBS"; then
3460 AC_MSG_CHECKING([for tgetent()])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003461 AC_LINK_IFELSE([AC_LANG_PROGRAM([int tgetent(char *, const char *);],
3462 [[char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");]])],
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003463 AC_MSG_RESULT(yes),
3464 AC_MSG_ERROR([NOT FOUND!
3465 You need to install a terminal library; for example ncurses.
Bram Moolenaar16678eb2021-04-21 11:57:59 +02003466 On Linux that would be the libncurses-dev package.
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003467 Or specify the name of the library with --with-tlib.]))
3468fi
3469
Bram Moolenaar446cb832008-06-24 21:56:24 +00003470AC_CACHE_CHECK([whether we talk terminfo], [vim_cv_terminfo],
3471 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003472 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003473#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003474#ifdef HAVE_TERMCAP_H
3475# include <termcap.h>
3476#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003477#ifdef HAVE_STRING_H
3478# include <string.h>
3479#endif
3480#if STDC_HEADERS
3481# include <stdlib.h>
3482# include <stddef.h>
3483#endif
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01003484int main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003485{char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003486 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003487 vim_cv_terminfo=no
3488 ],[
3489 vim_cv_terminfo=yes
3490 ],[
3491 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_terminfo')
3492 ])
3493 ])
3494
3495if test "x$vim_cv_terminfo" = "xyes" ; then
3496 AC_DEFINE(TERMINFO)
3497fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003498
Bram Moolenaara88254f2017-11-02 23:04:14 +01003499AC_CACHE_CHECK([what tgetent() returns for an unknown terminal], [vim_cv_tgetent],
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003500 [
3501 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003502#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003503#ifdef HAVE_TERMCAP_H
3504# include <termcap.h>
3505#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003506#if STDC_HEADERS
3507# include <stdlib.h>
3508# include <stddef.h>
3509#endif
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01003510int main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003511{char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003512 ]])],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003513 vim_cv_tgetent=zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003514 ],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003515 vim_cv_tgetent=non-zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003516 ],[
3517 AC_MSG_ERROR(failed to compile test program.)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003518 ])
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003519 ])
3520
Bram Moolenaara88254f2017-11-02 23:04:14 +01003521if test "x$vim_cv_tgetent" = "xzero" ; then
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003522 AC_DEFINE(TGETENT_ZERO_ERR, 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003523fi
3524
3525AC_MSG_CHECKING(whether termcap.h contains ospeed)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003526AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003527#ifdef HAVE_TERMCAP_H
3528# include <termcap.h>
3529#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003530 ], [ospeed = 20000])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003531 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED),
3532 [AC_MSG_RESULT(no)
3533 AC_MSG_CHECKING(whether ospeed can be extern)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003534 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003535#ifdef HAVE_TERMCAP_H
3536# include <termcap.h>
3537#endif
3538extern short ospeed;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003539 ], [ospeed = 20000])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003540 AC_MSG_RESULT(yes); AC_DEFINE(OSPEED_EXTERN),
3541 AC_MSG_RESULT(no))]
3542 )
3543
3544AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003545AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003546#ifdef HAVE_TERMCAP_H
3547# include <termcap.h>
3548#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003549 ], [if (UP == 0 && BC == 0) PC = 1])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003550 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UP_BC_PC),
3551 [AC_MSG_RESULT(no)
3552 AC_MSG_CHECKING([whether UP, BC and PC can be extern])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003553 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003554#ifdef HAVE_TERMCAP_H
3555# include <termcap.h>
3556#endif
3557extern char *UP, *BC, PC;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003558 ], [if (UP == 0 && BC == 0) PC = 1])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003559 AC_MSG_RESULT(yes); AC_DEFINE(UP_BC_PC_EXTERN),
3560 AC_MSG_RESULT(no))]
3561 )
3562
3563AC_MSG_CHECKING(whether tputs() uses outfuntype)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003564AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003565#ifdef HAVE_TERMCAP_H
3566# include <termcap.h>
3567#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003568 ], [extern int xx(); tputs("test", 1, (outfuntype)xx)])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003569 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OUTFUNTYPE),
3570 AC_MSG_RESULT(no))
3571
Bram Moolenaarb3a29552021-11-19 11:28:04 +00003572AC_MSG_CHECKING([whether del_curterm() can be used])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003573AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaarb3a29552021-11-19 11:28:04 +00003574#ifdef HAVE_TERMCAP_H
3575# include <termcap.h>
3576#endif
3577#include <term.h>
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003578 ], [if (cur_term) del_curterm(cur_term);])],
Bram Moolenaarb3a29552021-11-19 11:28:04 +00003579 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DEL_CURTERM),
3580 AC_MSG_RESULT(no))
3581
Bram Moolenaar071d4272004-06-13 20:20:40 +00003582dnl On some SCO machines sys/select redefines struct timeval
3583AC_MSG_CHECKING([whether sys/select.h and sys/time.h may both be included])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003584AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003585#include <sys/types.h>
3586#include <sys/time.h>
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003587#include <sys/select.h>], )],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003588 AC_MSG_RESULT(yes)
3589 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME),
3590 AC_MSG_RESULT(no))
3591
3592dnl AC_DECL_SYS_SIGLIST
3593
3594dnl Checks for pty.c (copied from screen) ==========================
3595AC_MSG_CHECKING(for /dev/ptc)
3596if test -r /dev/ptc; then
3597 AC_DEFINE(HAVE_DEV_PTC)
3598 AC_MSG_RESULT(yes)
3599else
3600 AC_MSG_RESULT(no)
3601fi
3602
3603AC_MSG_CHECKING(for SVR4 ptys)
3604if test -c /dev/ptmx ; then
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003605 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaarce7be3a2020-11-26 20:11:11 +01003606// These should be in stdlib.h, but it depends on _XOPEN_SOURCE.
3607char *ptsname(int);
3608int unlockpt(int);
3609int grantpt(int);
3610 ], [
3611 ptsname(0);
3612 grantpt(0);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003613 unlockpt(0);])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003614 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SVR4_PTYS),
3615 AC_MSG_RESULT(no))
3616else
3617 AC_MSG_RESULT(no)
3618fi
3619
3620AC_MSG_CHECKING(for ptyranges)
3621if test -d /dev/ptym ; then
3622 pdir='/dev/ptym'
3623else
3624 pdir='/dev'
3625fi
3626dnl SCO uses ptyp%d
3627AC_EGREP_CPP(yes,
3628[#ifdef M_UNIX
3629 yes;
3630#endif
3631 ], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
3632dnl if test -c /dev/ptyp19; then
3633dnl ptys=`echo /dev/ptyp??`
3634dnl else
3635dnl ptys=`echo $pdir/pty??`
3636dnl fi
3637if test "$ptys" != "$pdir/pty??" ; then
3638 p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
3639 p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'`
3640 AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
3641 AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
3642 AC_MSG_RESULT([$p0 / $p1])
3643else
3644 AC_MSG_RESULT([don't know])
3645fi
3646
Bram Moolenaar071d4272004-06-13 20:20:40 +00003647dnl Checks for library functions. ===================================
3648
Bram Moolenaar071d4272004-06-13 20:20:40 +00003649dnl check if struct sigcontext is defined (used for SGI only)
3650AC_MSG_CHECKING(for struct sigcontext)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003651AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003652#include <signal.h>
3653test_sig()
3654{
3655 struct sigcontext *scont;
3656 scont = (struct sigcontext *)0;
3657 return 1;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003658} ], )],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003659 AC_MSG_RESULT(yes)
3660 AC_DEFINE(HAVE_SIGCONTEXT),
3661 AC_MSG_RESULT(no))
3662
3663dnl tricky stuff: try to find out if getcwd() is implemented with
3664dnl system("sh -c pwd")
Bram Moolenaar446cb832008-06-24 21:56:24 +00003665AC_CACHE_CHECK([getcwd implementation is broken], [vim_cv_getcwd_broken],
3666 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003667 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003668#include "confdefs.h"
3669#ifdef HAVE_UNISTD_H
3670#include <unistd.h>
3671#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003672char *dagger[] = { "IFS=pwd", 0 };
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01003673int main()
Bram Moolenaar071d4272004-06-13 20:20:40 +00003674{
3675 char buffer[500];
3676 extern char **environ;
3677 environ = dagger;
3678 return getcwd(buffer, 500) ? 0 : 1;
Bram Moolenaar446cb832008-06-24 21:56:24 +00003679}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003680 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003681 vim_cv_getcwd_broken=no
3682 ],[
3683 vim_cv_getcwd_broken=yes
3684 ],[
3685 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_getcwd_broken')
3686 ])
3687 ])
3688
3689if test "x$vim_cv_getcwd_broken" = "xyes" ; then
3690 AC_DEFINE(BAD_GETCWD)
Bram Moolenaar63d25552019-05-10 21:28:38 +02003691 AC_CHECK_FUNCS(getwd)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003692fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003693
Bram Moolenaar25153e12010-02-24 14:47:08 +01003694dnl Check for functions in one big call, to reduce the size of configure.
3695dnl Can only be used for functions that do not require any include.
Bram Moolenaarcd142e32017-11-16 17:03:45 +01003696AC_CHECK_FUNCS(fchdir fchown fchmod fsync getcwd getpseudotty \
Bram Moolenaar63d25552019-05-10 21:28:38 +02003697 getpwent getpwnam getpwuid getrlimit gettimeofday localtime_r lstat \
Bram Moolenaareaf03392009-11-17 11:08:52 +00003698 memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
Bram Moolenaar2fcf6682017-03-11 20:03:42 +01003699 getpgid setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
Bram Moolenaar84cf6bd2020-06-16 20:03:43 +02003700 sigprocmask sigvec strcasecmp strcoll strerror strftime stricmp strncasecmp \
Bram Moolenaar10455d42019-11-21 15:36:18 +01003701 strnicmp strpbrk strptime strtol tgetent towlower towupper iswupper \
3702 tzset usleep utime utimes mblen ftruncate unsetenv posix_openpt)
Bram Moolenaar643b6142018-09-12 20:29:09 +02003703AC_FUNC_SELECT_ARGTYPES
Bram Moolenaar25153e12010-02-24 14:47:08 +01003704AC_FUNC_FSEEKO
Bram Moolenaar071d4272004-06-13 20:20:40 +00003705
Bram Moolenaar317fd3a2010-05-07 16:05:55 +02003706dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when
3707dnl appropriate, so that off_t is 64 bits when needed.
3708AC_SYS_LARGEFILE
3709
Bram Moolenaar21606672019-06-14 20:40:58 +02003710AC_MSG_CHECKING(--enable-canberra argument)
3711AC_ARG_ENABLE(canberra,
3712 [ --disable-canberra Do not use libcanberra.],
3713 , [enable_canberra="maybe"])
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003714
Bram Moolenaar21606672019-06-14 20:40:58 +02003715if test "$enable_canberra" = "maybe"; then
3716 if test "$features" = "big" -o "$features" = "huge"; then
3717 AC_MSG_RESULT(Defaulting to yes)
3718 enable_canberra="yes"
3719 else
3720 AC_MSG_RESULT(Defaulting to no)
3721 enable_canberra="no"
3722 fi
3723else
Bram Moolenaar12471262022-01-18 11:11:25 +00003724 if test "$enable_canberra" = "yes" -a "$has_eval" = "no"; then
3725 AC_MSG_RESULT([cannot use sound with tiny or small features])
3726 enable_canberra="no"
3727 else
3728 AC_MSG_RESULT($enable_canberra)
3729 fi
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003730fi
Bram Moolenaar21606672019-06-14 20:40:58 +02003731if test "$enable_canberra" = "yes"; then
3732 if test "x$PKG_CONFIG" != "xno"; then
3733 canberra_lib=`$PKG_CONFIG --libs libcanberra 2>/dev/null`
3734 canberra_cflags=`$PKG_CONFIG --cflags libcanberra 2>/dev/null`
3735 fi
3736 if test "x$canberra_lib" = "x"; then
3737 canberra_lib=-lcanberra
3738 canberra_cflags=-D_REENTRANT
3739 fi
3740 AC_MSG_CHECKING(for libcanberra)
3741 ac_save_CFLAGS="$CFLAGS"
3742 ac_save_LIBS="$LIBS"
Bram Moolenaar12471262022-01-18 11:11:25 +00003743 if `echo "$CFLAGS" | grep -v "$canberra_cflags" 2>/dev/null`; then
Christian Brabandt6b9efdd2021-09-09 17:14:50 +02003744 CFLAGS="$CFLAGS $canberra_cflags"
3745 fi
Bram Moolenaar21606672019-06-14 20:40:58 +02003746 LIBS="$LIBS $canberra_lib"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003747 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar21606672019-06-14 20:40:58 +02003748 # include <canberra.h>
3749 ], [
3750 ca_context *hello;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003751 ca_context_create(&hello);])],
Bram Moolenaar21606672019-06-14 20:40:58 +02003752 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_CANBERRA),
Bram Moolenaar91b992c2019-11-17 19:07:42 +01003753 AC_MSG_RESULT(no; try installing libcanberra-dev); CFLAGS="$ac_save_CFLAGS"; LIBS="$ac_save_LIBS")
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003754fi
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003755
Christian Brabandtf573c6e2021-06-20 14:02:16 +02003756AC_MSG_CHECKING(--enable-libsodium argument)
3757AC_ARG_ENABLE(libsodium,
3758 [ --disable-libsodium Do not use libsodium.],
3759 , [enable_libsodium="maybe"])
3760
3761if test "$enable_libsodium" = "maybe"; then
3762 if test "$features" = "big" -o "$features" = "huge"; then
3763 AC_MSG_RESULT(Defaulting to yes)
3764 enable_libsodium="yes"
3765 else
3766 AC_MSG_RESULT(Defaulting to no)
3767 enable_libsodium="no"
3768 fi
3769else
3770 AC_MSG_RESULT($enable_libsodium)
3771fi
3772if test "$enable_libsodium" = "yes"; then
3773 if test "x$PKG_CONFIG" != "xno"; then
3774 libsodium_lib=`$PKG_CONFIG --libs libsodium 2>/dev/null`
3775 libsodium_cflags=`$PKG_CONFIG --cflags libsodium 2>/dev/null`
3776 fi
3777 if test "x$libsodium_lib" = "x"; then
3778 libsodium_lib=-lsodium
3779 libsodium_cflags=
3780 fi
ichizok8ce3ca82021-06-23 15:41:52 +02003781 AC_MSG_CHECKING(for libsodium)
Christian Brabandtf573c6e2021-06-20 14:02:16 +02003782 ac_save_CFLAGS="$CFLAGS"
3783 ac_save_LIBS="$LIBS"
3784 CFLAGS="$CFLAGS $libsodium_cflags"
3785 LIBS="$LIBS $libsodium_lib"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003786 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Christian Brabandtf573c6e2021-06-20 14:02:16 +02003787 # include <sodium.h>
3788 ], [
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003789 printf("%d", sodium_init()); ])],
Christian Brabandtf573c6e2021-06-20 14:02:16 +02003790 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SODIUM),
3791 AC_MSG_RESULT(no; try installing libsodium-dev); CFLAGS="$ac_save_CFLAGS"; LIBS="$ac_save_LIBS")
3792fi
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003793
Bram Moolenaar071d4272004-06-13 20:20:40 +00003794dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible
3795AC_MSG_CHECKING(for st_blksize)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003796AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00003797[#include <sys/types.h>
3798#include <sys/stat.h>],
3799[ struct stat st;
3800 int n;
3801
3802 stat("/", &st);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003803 n = (int)st.st_blksize;])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003804 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ST_BLKSIZE),
3805 AC_MSG_RESULT(no))
3806
Paul Ollis65745772022-06-05 16:55:54 +01003807dnl Check for timer_create. It probably requires the 'rt' library.
Bram Moolenaarf2ce76a2022-07-02 11:40:40 +01003808dnl Run the program to find out if timer_create(CLOCK_MONOTONIC) actually
3809dnl works, on Solaris timer_create() exists but fails at runtime.
Bram Moolenaarefffa532022-07-28 22:39:54 +01003810AC_CACHE_CHECK([for timer_create without -lrt], [vim_cv_timer_create], [
Bram Moolenaarf2ce76a2022-07-02 11:40:40 +01003811AC_RUN_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar5748b7f2022-07-28 12:09:04 +01003812#if STDC_HEADERS
3813# include <stdlib.h>
3814# include <stddef.h>
3815#endif
3816#include <signal.h>
3817#include <time.h>
Bram Moolenaare5303952022-06-19 17:05:47 +01003818static void set_flag(union sigval sv) {}
Paul Ollis65745772022-06-05 16:55:54 +01003819], [
3820 struct timespec ts;
3821 struct sigevent action = {0};
3822 timer_t timer_id;
3823
3824 action.sigev_notify = SIGEV_THREAD;
3825 action.sigev_notify_function = set_flag;
Bram Moolenaarf2ce76a2022-07-02 11:40:40 +01003826 if (timer_create(CLOCK_MONOTONIC, &action, &timer_id) < 0)
3827 exit(1); // cannot create a monotonic timer
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003828 ])],
Bram Moolenaarefffa532022-07-28 22:39:54 +01003829 vim_cv_timer_create=yes,
3830 vim_cv_timer_create=no,
Bram Moolenaar5f6cae82022-07-30 11:00:50 +01003831 AC_MSG_WARN([failed to build test program; if cross-compiling please set 'vim_cv_timer_create'])
Bram Moolenaarefffa532022-07-28 22:39:54 +01003832 )])
Paul Ollis65745772022-06-05 16:55:54 +01003833
Bram Moolenaarefffa532022-07-28 22:39:54 +01003834dnl If the previous failed, check for timer_create() and linking with -lrt.
3835if test "x$vim_cv_timer_create" = "xno" ; then
3836 save_LIBS="$LIBS"
3837 LIBS="$LIBS -lrt"
3838 AC_CACHE_CHECK([for timer_create with -lrt], [vim_cv_timer_create_with_lrt], [
3839 AC_RUN_IFELSE([AC_LANG_PROGRAM([
3840 #if STDC_HEADERS
3841 # include <stdlib.h>
3842 # include <stddef.h>
3843 #endif
3844 #include <signal.h>
3845 #include <time.h>
3846 static void set_flag(union sigval sv) {}
3847 ], [
3848 struct timespec ts;
3849 struct sigevent action = {0};
3850 timer_t timer_id;
3851
3852 action.sigev_notify = SIGEV_THREAD;
3853 action.sigev_notify_function = set_flag;
3854 if (timer_create(CLOCK_MONOTONIC, &action, &timer_id) < 0)
3855 exit(1); // cannot create a monotonic timer
3856 ])],
3857 vim_cv_timer_create_with_lrt=yes,
3858 vim_cv_timer_create_with_lrt=no,
Bram Moolenaar5f6cae82022-07-30 11:00:50 +01003859 AC_MSG_WARN([failed to build test program; if cross-compiling please set 'vim_cv_timer_create_with_lrt'])
Bram Moolenaarefffa532022-07-28 22:39:54 +01003860 )])
3861 LIBS="$save_LIBS"
3862else
3863 vim_cv_timer_create_with_lrt=no
3864fi
Richard Purdie509695c2022-07-24 20:48:00 +01003865
3866if test "x$vim_cv_timer_create" = "xyes" ; then
3867 AC_DEFINE(HAVE_TIMER_CREATE)
3868fi
Bram Moolenaarefffa532022-07-28 22:39:54 +01003869if test "x$vim_cv_timer_create_with_lrt" = "xyes" ; then
3870 AC_DEFINE(HAVE_TIMER_CREATE)
3871 LIBS="$LIBS -lrt"
3872fi
Paul Ollis65745772022-06-05 16:55:54 +01003873
Bram Moolenaar446cb832008-06-24 21:56:24 +00003874AC_CACHE_CHECK([whether stat() ignores a trailing slash], [vim_cv_stat_ignores_slash],
3875 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003876 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003877#include "confdefs.h"
3878#if STDC_HEADERS
3879# include <stdlib.h>
3880# include <stddef.h>
3881#endif
3882#include <sys/types.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003883#include <sys/stat.h>
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01003884int main() {struct stat st; exit(stat("configure/", &st) != 0); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003885 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003886 vim_cv_stat_ignores_slash=yes
3887 ],[
3888 vim_cv_stat_ignores_slash=no
3889 ],[
3890 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_stat_ignores_slash')
3891 ])
3892 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003893
Bram Moolenaar446cb832008-06-24 21:56:24 +00003894if test "x$vim_cv_stat_ignores_slash" = "xyes" ; then
3895 AC_DEFINE(STAT_IGNORES_SLASH)
3896fi
Leah Neukirchen0a7984a2021-10-14 21:27:55 +01003897
3898dnl nanoseconds field of struct stat
3899AC_CACHE_CHECK([for nanoseconds field of struct stat],
3900 ac_cv_struct_st_mtim_nsec,
3901 [ac_save_CPPFLAGS="$CPPFLAGS"
3902 ac_cv_struct_st_mtim_nsec=no
3903 # st_mtim.tv_nsec -- the usual case
3904 # st_mtim._tv_nsec -- Solaris 2.6, if
3905 # (defined _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED == 1
3906 # && !defined __EXTENSIONS__)
3907 # st_mtim.st__tim.tv_nsec -- UnixWare 2.1.2
3908 # st_mtime_n -- AIX 5.2 and above
3909 # st_mtimespec.tv_nsec -- Darwin (Mac OSX)
3910 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
3911 CPPFLAGS="$ac_save_CPPFLAGS -DST_MTIM_NSEC=$ac_val"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003912 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
3913#include <sys/stat.h>], [struct stat s; s.ST_MTIM_NSEC;])],
Leah Neukirchen0a7984a2021-10-14 21:27:55 +01003914 [ac_cv_struct_st_mtim_nsec=$ac_val; break])
3915 done
3916 CPPFLAGS="$ac_save_CPPFLAGS"
3917])
3918if test $ac_cv_struct_st_mtim_nsec != no; then
3919 AC_DEFINE_UNQUOTED([ST_MTIM_NSEC], [$ac_cv_struct_st_mtim_nsec],
3920 [Define if struct stat contains a nanoseconds field])
3921fi
Bram Moolenaare5303952022-06-19 17:05:47 +01003922
Bram Moolenaar071d4272004-06-13 20:20:40 +00003923dnl Link with iconv for charset translation, if not found without library.
3924dnl check for iconv() requires including iconv.h
3925dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
3926dnl has been installed.
3927AC_MSG_CHECKING(for iconv_open())
3928save_LIBS="$LIBS"
3929LIBS="$LIBS -liconv"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003930AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003931#ifdef HAVE_ICONV_H
3932# include <iconv.h>
3933#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003934 ], [iconv_open("fr", "to");])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003935 AC_MSG_RESULT(yes; with -liconv); AC_DEFINE(HAVE_ICONV),
3936 LIBS="$save_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003937 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003938#ifdef HAVE_ICONV_H
3939# include <iconv.h>
3940#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003941 ], [iconv_open("fr", "to");])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003942 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ICONV),
3943 AC_MSG_RESULT(no)))
3944
3945
3946AC_MSG_CHECKING(for nl_langinfo(CODESET))
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003947AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003948#ifdef HAVE_LANGINFO_H
3949# include <langinfo.h>
3950#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003951], [char *cs = nl_langinfo(CODESET);])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003952 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET),
3953 AC_MSG_RESULT(no))
3954
Bram Moolenaar446cb832008-06-24 21:56:24 +00003955dnl Need various functions for floating point support. Only enable
3956dnl floating point when they are all present.
3957AC_CHECK_LIB(m, strtod)
3958AC_MSG_CHECKING([for strtod() and other floating point functions])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003959AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar446cb832008-06-24 21:56:24 +00003960#ifdef HAVE_MATH_H
3961# include <math.h>
3962#endif
3963#if STDC_HEADERS
3964# include <stdlib.h>
3965# include <stddef.h>
3966#endif
3967], [char *s; double d;
3968 d = strtod("1.1", &s);
3969 d = fabs(1.11);
3970 d = ceil(1.11);
3971 d = floor(1.11);
3972 d = log10(1.11);
3973 d = pow(1.11, 2.22);
3974 d = sqrt(1.11);
3975 d = sin(1.11);
3976 d = cos(1.11);
3977 d = atan(1.11);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003978 ])],
Bram Moolenaar446cb832008-06-24 21:56:24 +00003979 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT_FUNCS),
3980 AC_MSG_RESULT(no))
3981
Bram Moolenaara6b89762016-02-29 21:38:26 +01003982dnl isinf() and isnan() need to include header files and may need -lm.
3983AC_MSG_CHECKING([for isinf()])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003984AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaara6b89762016-02-29 21:38:26 +01003985#ifdef HAVE_MATH_H
3986# include <math.h>
3987#endif
3988#if STDC_HEADERS
3989# include <stdlib.h>
3990# include <stddef.h>
3991#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003992], [int r = isinf(1.11); ])],
Bram Moolenaara6b89762016-02-29 21:38:26 +01003993 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISINF),
3994 AC_MSG_RESULT(no))
3995
3996AC_MSG_CHECKING([for isnan()])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003997AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaara6b89762016-02-29 21:38:26 +01003998#ifdef HAVE_MATH_H
3999# include <math.h>
4000#endif
4001#if STDC_HEADERS
4002# include <stdlib.h>
4003# include <stddef.h>
4004#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004005], [int r = isnan(1.11); ])],
Bram Moolenaara6b89762016-02-29 21:38:26 +01004006 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISNAN),
4007 AC_MSG_RESULT(no))
4008
Bram Moolenaar071d4272004-06-13 20:20:40 +00004009dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI
4010dnl when -lacl works, also try to use -lattr (required for Debian).
Bram Moolenaar8d462f92012-02-05 22:51:33 +01004011dnl On Solaris, use the acl_get/set functions in libsec, if present.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004012AC_MSG_CHECKING(--disable-acl argument)
4013AC_ARG_ENABLE(acl,
Bram Moolenaard6d30422018-01-28 22:48:55 +01004014 [ --disable-acl No check for ACL support.],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004015 , [enable_acl="yes"])
4016if test "$enable_acl" = "yes"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01004017 AC_MSG_RESULT(no)
4018 AC_CHECK_LIB(posix1e, acl_get_file, [LIBS="$LIBS -lposix1e"],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004019 AC_CHECK_LIB(acl, acl_get_file, [LIBS="$LIBS -lacl"
4020 AC_CHECK_LIB(attr, fgetxattr, LIBS="$LIBS -lattr",,)],,),)
4021
Bram Moolenaard6d30422018-01-28 22:48:55 +01004022 AC_MSG_CHECKING(for POSIX ACL support)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004023 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00004024#include <sys/types.h>
4025#ifdef HAVE_SYS_ACL_H
4026# include <sys/acl.h>
4027#endif
4028acl_t acl;], [acl = acl_get_file("foo", ACL_TYPE_ACCESS);
4029 acl_set_file("foo", ACL_TYPE_ACCESS, acl);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004030 acl_free(acl);])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004031 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_ACL),
4032 AC_MSG_RESULT(no))
4033
Bram Moolenaard6d30422018-01-28 22:48:55 +01004034 AC_CHECK_LIB(sec, acl_get, [LIBS="$LIBS -lsec"; AC_DEFINE(HAVE_SOLARIS_ZFS_ACL)],
4035 AC_MSG_CHECKING(for Solaris ACL support)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004036 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00004037#ifdef HAVE_SYS_ACL_H
4038# include <sys/acl.h>
4039#endif], [acl("foo", GETACLCNT, 0, NULL);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004040 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004041 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOLARIS_ACL),
Bram Moolenaar8d462f92012-02-05 22:51:33 +01004042 AC_MSG_RESULT(no)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004043
Bram Moolenaard6d30422018-01-28 22:48:55 +01004044 AC_MSG_CHECKING(for AIX ACL support)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004045 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar446cb832008-06-24 21:56:24 +00004046#if STDC_HEADERS
4047# include <stdlib.h>
4048# include <stddef.h>
4049#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004050#ifdef HAVE_SYS_ACL_H
4051# include <sys/acl.h>
4052#endif
4053#ifdef HAVE_SYS_ACCESS_H
4054# include <sys/access.h>
4055#endif
4056#define _ALL_SOURCE
4057
4058#include <sys/stat.h>
4059
4060int aclsize;
4061struct acl *aclent;], [aclsize = sizeof(struct acl);
4062 aclent = (void *)malloc(aclsize);
4063 statacl("foo", STX_NORMAL, aclent, aclsize);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004064 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004065 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_AIX_ACL),
4066 AC_MSG_RESULT(no))
4067else
4068 AC_MSG_RESULT(yes)
4069fi
4070
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02004071if test "x$GTK_CFLAGS" != "x"; then
4072 dnl pango_shape_full() is new, fall back to pango_shape().
4073 AC_MSG_CHECKING(for pango_shape_full)
4074 ac_save_CFLAGS="$CFLAGS"
4075 ac_save_LIBS="$LIBS"
4076 CFLAGS="$CFLAGS $GTK_CFLAGS"
4077 LIBS="$LIBS $GTK_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004078 AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02004079 [#include <gtk/gtk.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004080 [ pango_shape_full(NULL, 0, NULL, 0, NULL, NULL); ])],
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02004081 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_PANGO_SHAPE_FULL),
4082 AC_MSG_RESULT(no))
4083 CFLAGS="$ac_save_CFLAGS"
4084 LIBS="$ac_save_LIBS"
4085fi
4086
Bram Moolenaar33fc4a62022-02-23 18:07:38 +00004087AC_MSG_CHECKING(--enable-gpm argument)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004088AC_ARG_ENABLE(gpm,
Bram Moolenaar33fc4a62022-02-23 18:07:38 +00004089 [ --enable-gpm=OPTS Use gpm (Linux mouse daemon). default=yes OPTS=yes/no/dynamic], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00004090 [enable_gpm="yes"])
4091
Bram Moolenaar33fc4a62022-02-23 18:07:38 +00004092if test "$enable_gpm" = "yes" -o "$enable_gpm" = "dynamic"; then
4093 AC_MSG_RESULT($enable_gpm)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004094 dnl Checking if gpm support can be compiled
4095 AC_CACHE_CHECK([for gpm], vi_cv_have_gpm,
4096 [olibs="$LIBS" ; LIBS="-lgpm"]
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004097 AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004098 [#include <gpm.h>
4099 #include <linux/keyboard.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004100 [Gpm_GetLibVersion(NULL);])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004101 dnl Configure defines HAVE_GPM, if it is defined feature.h defines
4102 dnl FEAT_MOUSE_GPM if mouse support is included
4103 [vi_cv_have_gpm=yes],
4104 [vi_cv_have_gpm=no])
4105 [LIBS="$olibs"]
4106 )
4107 if test $vi_cv_have_gpm = yes; then
Bram Moolenaar33fc4a62022-02-23 18:07:38 +00004108 if test "$enable_gpm" = "yes"; then
4109 LIBS="$LIBS -lgpm"
4110 else
4111 AC_DEFINE(DYNAMIC_GPM)
4112 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004113 AC_DEFINE(HAVE_GPM)
4114 fi
4115else
Bram Moolenaar33fc4a62022-02-23 18:07:38 +00004116 AC_MSG_RESULT(no)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004117fi
4118
Bram Moolenaar446cb832008-06-24 21:56:24 +00004119AC_MSG_CHECKING(--disable-sysmouse argument)
4120AC_ARG_ENABLE(sysmouse,
Bram Moolenaar8008b632017-07-18 21:33:20 +02004121 [ --disable-sysmouse Don't use sysmouse (mouse in *BSD console).], ,
Bram Moolenaar446cb832008-06-24 21:56:24 +00004122 [enable_sysmouse="yes"])
4123
4124if test "$enable_sysmouse" = "yes"; then
4125 AC_MSG_RESULT(no)
4126 dnl Checking if sysmouse support can be compiled
4127 dnl Configure defines HAVE_SYSMOUSE, if it is defined feature.h
4128 dnl defines FEAT_SYSMOUSE if mouse support is included
4129 AC_CACHE_CHECK([for sysmouse], vi_cv_have_sysmouse,
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004130 AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar446cb832008-06-24 21:56:24 +00004131 [#include <sys/consio.h>
4132 #include <signal.h>
4133 #include <sys/fbio.h>],
4134 [struct mouse_info mouse;
4135 mouse.operation = MOUSE_MODE;
4136 mouse.operation = MOUSE_SHOW;
4137 mouse.u.mode.mode = 0;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004138 mouse.u.mode.signal = SIGUSR2;])],
Bram Moolenaar446cb832008-06-24 21:56:24 +00004139 [vi_cv_have_sysmouse=yes],
4140 [vi_cv_have_sysmouse=no])
4141 )
4142 if test $vi_cv_have_sysmouse = yes; then
4143 AC_DEFINE(HAVE_SYSMOUSE)
4144 fi
4145else
4146 AC_MSG_RESULT(yes)
4147fi
4148
Bram Moolenaarf05da212009-11-17 16:13:15 +00004149dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
4150AC_MSG_CHECKING(for FD_CLOEXEC)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004151AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaarf05da212009-11-17 16:13:15 +00004152[#if HAVE_FCNTL_H
4153# include <fcntl.h>
4154#endif],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004155[ int flag = FD_CLOEXEC;])],
Bram Moolenaarf05da212009-11-17 16:13:15 +00004156 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
4157 AC_MSG_RESULT(not usable))
4158
Bram Moolenaar071d4272004-06-13 20:20:40 +00004159dnl rename needs to be checked separately to work on Nextstep with cc
4160AC_MSG_CHECKING(for rename)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004161AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>], [rename("this", "that")])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004162 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
4163 AC_MSG_RESULT(no))
4164
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004165dnl check for dirfd()
4166AC_MSG_CHECKING(for dirfd)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004167AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004168[#include <sys/types.h>
4169#include <dirent.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004170[DIR * dir=opendir("dirname"); dirfd(dir);])],
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004171AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DIRFD), AC_MSG_RESULT(not usable))
4172
4173dnl check for flock()
4174AC_MSG_CHECKING(for flock)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004175AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004176[#include <sys/file.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004177[flock(10, LOCK_SH);])],
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004178AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOCK), AC_MSG_RESULT(not usable))
4179
Bram Moolenaar071d4272004-06-13 20:20:40 +00004180dnl sysctl() may exist but not the arguments we use
4181AC_MSG_CHECKING(for sysctl)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004182AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004183[#include <sys/types.h>
4184#include <sys/sysctl.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004185[[ int mib[2], r;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004186 size_t len;
4187
4188 mib[0] = CTL_HW;
4189 mib[1] = HW_USERMEM;
4190 len = sizeof(r);
4191 (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004192 ]])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004193 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL),
4194 AC_MSG_RESULT(not usable))
4195
Bram Moolenaare2982d62021-10-06 11:27:21 +01004196dnl sysinfo() may exist but not be Linux compatible.
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004197dnl On some FreeBSD systems it may depend on libsysinfo, try to link
Bram Moolenaar071d4272004-06-13 20:20:40 +00004198AC_MSG_CHECKING(for sysinfo)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004199AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004200[#include <sys/types.h>
4201#include <sys/sysinfo.h>],
4202[ struct sysinfo sinfo;
4203 int t;
4204
4205 (void)sysinfo(&sinfo);
4206 t = sinfo.totalram;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004207 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004208 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
4209 AC_MSG_RESULT(not usable))
4210
Bram Moolenaar914572a2007-05-01 11:37:47 +00004211dnl struct sysinfo may have the mem_unit field or not
4212AC_MSG_CHECKING(for sysinfo.mem_unit)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004213AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar914572a2007-05-01 11:37:47 +00004214[#include <sys/types.h>
4215#include <sys/sysinfo.h>],
4216[ struct sysinfo sinfo;
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02004217 sinfo.mem_unit = 1;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004218 ])],
Bram Moolenaar914572a2007-05-01 11:37:47 +00004219 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_MEM_UNIT),
4220 AC_MSG_RESULT(no))
4221
Bram Moolenaarf52f0602021-03-10 21:26:37 +01004222dnl struct sysinfo may have the uptime field or not
4223AC_MSG_CHECKING(for sysinfo.uptime)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004224AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaarf52f0602021-03-10 21:26:37 +01004225[#include <sys/types.h>
4226#include <sys/sysinfo.h>],
4227[ struct sysinfo sinfo;
4228 long ut;
4229
4230 (void)sysinfo(&sinfo);
4231 ut = sinfo.uptime;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004232 ])],
Bram Moolenaarf52f0602021-03-10 21:26:37 +01004233 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_UPTIME),
4234 AC_MSG_RESULT(no))
4235
Bram Moolenaar071d4272004-06-13 20:20:40 +00004236dnl sysconf() may exist but not support what we want to use
4237AC_MSG_CHECKING(for sysconf)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004238AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004239[#include <unistd.h>],
4240[ (void)sysconf(_SC_PAGESIZE);
4241 (void)sysconf(_SC_PHYS_PAGES);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004242 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004243 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
4244 AC_MSG_RESULT(not usable))
4245
Bram Moolenaar0e62a672021-02-25 17:17:56 +01004246dnl check if we have _SC_SIGSTKSZ via sysconf()
4247AC_MSG_CHECKING(for _SC_SIGSTKSZ via sysconf())
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004248AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar0e62a672021-02-25 17:17:56 +01004249[#include <unistd.h>],
4250[ (void)sysconf(_SC_SIGSTKSZ);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004251 ])],
Bram Moolenaar0e62a672021-02-25 17:17:56 +01004252 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF_SIGSTKSZ),
4253 AC_MSG_RESULT(not usable))
4254
Bram Moolenaar914703b2010-05-31 21:59:46 +02004255AC_CHECK_SIZEOF([int])
4256AC_CHECK_SIZEOF([long])
4257AC_CHECK_SIZEOF([time_t])
4258AC_CHECK_SIZEOF([off_t])
Bram Moolenaar644fdff2010-05-30 13:26:21 +02004259
Bram Moolenaara2aa31a2014-02-23 22:52:40 +01004260dnl Use different names to avoid clashing with other header files.
4261AC_DEFINE_UNQUOTED(VIM_SIZEOF_INT, [$ac_cv_sizeof_int])
4262AC_DEFINE_UNQUOTED(VIM_SIZEOF_LONG, [$ac_cv_sizeof_long])
4263
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004264dnl Make sure that uint32_t is really 32 bits unsigned.
4265AC_MSG_CHECKING([uint32_t is 32 bits])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004266AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004267#ifdef HAVE_STDINT_H
4268# include <stdint.h>
4269#endif
4270#ifdef HAVE_INTTYPES_H
4271# include <inttypes.h>
4272#endif
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01004273int main() {
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004274 uint32_t nr1 = (uint32_t)-1;
4275 uint32_t nr2 = (uint32_t)0xffffffffUL;
Bram Moolenaar52897832020-07-02 22:50:37 +02004276 if (sizeof(uint32_t) != 4 || nr1 != 0xffffffffUL || nr2 + 1 != 0) return 1;
4277 return 0;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004278}])],
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004279AC_MSG_RESULT(ok),
4280AC_MSG_ERROR([WRONG! uint32_t not defined correctly.]),
Bram Moolenaar323cb952011-12-14 19:22:34 +01004281AC_MSG_WARN([cannot check uint32_t when cross-compiling.]))
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004282
Bram Moolenaar446cb832008-06-24 21:56:24 +00004283dnl Check for memmove() before bcopy(), makes memmove() be used when both are
4284dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
4285
Bram Moolenaar071d4272004-06-13 20:20:40 +00004286[bcopy_test_prog='
Bram Moolenaar446cb832008-06-24 21:56:24 +00004287#include "confdefs.h"
4288#ifdef HAVE_STRING_H
4289# include <string.h>
4290#endif
4291#if STDC_HEADERS
4292# include <stdlib.h>
4293# include <stddef.h>
4294#endif
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01004295int main() {
Bram Moolenaar071d4272004-06-13 20:20:40 +00004296 char buf[10];
4297 strcpy(buf, "abcdefghi");
4298 mch_memmove(buf, buf + 2, 3);
4299 if (strncmp(buf, "ababcf", 6))
4300 exit(1);
4301 strcpy(buf, "abcdefghi");
4302 mch_memmove(buf + 2, buf, 3);
4303 if (strncmp(buf, "cdedef", 6))
4304 exit(1);
4305 exit(0); /* libc version works properly. */
4306}']
4307
Bram Moolenaar446cb832008-06-24 21:56:24 +00004308AC_CACHE_CHECK([whether memmove handles overlaps],[vim_cv_memmove_handles_overlap],
4309 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004310 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 +00004311 [
4312 vim_cv_memmove_handles_overlap=yes
4313 ],[
4314 vim_cv_memmove_handles_overlap=no
4315 ],[
4316 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memmove_handles_overlap')
4317 ])
4318 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00004319
Bram Moolenaar446cb832008-06-24 21:56:24 +00004320if test "x$vim_cv_memmove_handles_overlap" = "xyes" ; then
4321 AC_DEFINE(USEMEMMOVE)
4322else
4323 AC_CACHE_CHECK([whether bcopy handles overlaps],[vim_cv_bcopy_handles_overlap],
4324 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004325 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 +00004326 [
4327 vim_cv_bcopy_handles_overlap=yes
4328 ],[
4329 vim_cv_bcopy_handles_overlap=no
4330 ],[
4331 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_bcopy_handles_overlap')
4332 ])
4333 ])
4334
4335 if test "x$vim_cv_bcopy_handles_overlap" = "xyes" ; then
4336 AC_DEFINE(USEBCOPY)
4337 else
4338 AC_CACHE_CHECK([whether memcpy handles overlaps],[vim_cv_memcpy_handles_overlap],
4339 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004340 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 +00004341 [
4342 vim_cv_memcpy_handles_overlap=yes
4343 ],[
4344 vim_cv_memcpy_handles_overlap=no
4345 ],[
4346 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memcpy_handles_overlap')
4347 ])
4348 ])
4349
4350 if test "x$vim_cv_memcpy_handles_overlap" = "xyes" ; then
4351 AC_DEFINE(USEMEMCPY)
4352 fi
4353 fi
4354fi
4355
Bram Moolenaar071d4272004-06-13 20:20:40 +00004356
4357dnl Check for multibyte locale functions
4358dnl Find out if _Xsetlocale() is supported by libX11.
4359dnl Check if X_LOCALE should be defined.
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004360if test "x$with_x" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004361 cflags_save=$CFLAGS
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004362 libs_save=$LIBS
4363 LIBS="$LIBS $X_LIBS $GUI_LIB_LOC $GUI_X_LIBS $X_PRE_LIBS $X_LIB $X_EXTRA_LIBS"
4364 CFLAGS="$CFLAGS $X_CFLAGS"
4365
4366 AC_MSG_CHECKING(whether X_LOCALE needed)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004367 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <X11/Xlocale.h>],)],
4368 AC_LINK_IFELSE([AC_LANG_CALL([],[_Xsetlocale])], [AC_MSG_RESULT(yes)
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004369 AC_DEFINE(X_LOCALE)], AC_MSG_RESULT(no)),
4370 AC_MSG_RESULT(no))
4371
4372 AC_MSG_CHECKING(whether Xutf8SetWMProperties() can be used)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004373 AC_LINK_IFELSE([AC_LANG_CALL([],[Xutf8SetWMProperties])], [AC_MSG_RESULT(yes)
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004374 AC_DEFINE(HAVE_XUTF8SETWMPROPERTIES)], AC_MSG_RESULT(no))
4375
Bram Moolenaar071d4272004-06-13 20:20:40 +00004376 CFLAGS=$cflags_save
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004377 LIBS=$libs_save
Bram Moolenaar071d4272004-06-13 20:20:40 +00004378fi
4379
4380dnl Link with xpg4, it is said to make Korean locale working
4381AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,)
4382
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004383dnl Check how we can run ctags. Default to "ctags" when nothing works.
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02004384dnl Use --version to detect Exuberant ctags (preferred)
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004385dnl Add --fields=+S to get function signatures for omni completion.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004386dnl -t for typedefs (many ctags have this)
4387dnl -s for static functions (Elvis ctags only?)
4388dnl -v for variables. Dangerous, most ctags take this for 'vgrind style'.
4389dnl -i+m to test for older Exuberant ctags
4390AC_MSG_CHECKING(how to create tags)
4391test -f tags && mv tags tags.save
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004392if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004393 TAGPRG="ctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004394elif (eval exctags --version /dev/null | grep Exuberant) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004395 TAGPRG="exctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004396elif (eval exuberant-ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004397 TAGPRG="exuberant-ctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004398else
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004399 TAGPRG="ctags"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004400 (eval etags /dev/null) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1 && TAGPRG="etags"
4401 (eval etags -c /dev/null) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1 && TAGPRG="etags -c"
4402 (eval ctags /dev/null) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1 && TAGPRG="ctags"
4403 (eval ctags -t /dev/null) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1 && TAGPRG="ctags -t"
4404 (eval ctags -ts /dev/null) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1 && TAGPRG="ctags -ts"
4405 (eval ctags -tvs /dev/null) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1 && TAGPRG="ctags -tvs"
4406 (eval ctags -i+m /dev/null) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1 && TAGPRG="ctags -i+m"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004407fi
4408test -f tags.save && mv tags.save tags
4409AC_MSG_RESULT($TAGPRG) AC_SUBST(TAGPRG)
4410
4411dnl Check how we can run man with a section number
4412AC_MSG_CHECKING(how to run man with a section nr)
4413MANDEF="man"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004414(eval MANPAGER=cat PAGER=cat man -s 2 read) < /dev/null > /dev/null 2>&AS_MESSAGE_LOG_FD && MANDEF="man -s"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004415AC_MSG_RESULT($MANDEF)
4416if test "$MANDEF" = "man -s"; then
4417 AC_DEFINE(USEMAN_S)
4418fi
4419
4420dnl Check if gettext() is working and if it needs -lintl
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004421dnl We take care to base this on an empty LIBS: on some systems libelf would be
4422dnl in LIBS and implicitly take along libintl. The final LIBS would then not
4423dnl contain libintl, and the link step would fail due to -Wl,--as-needed.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004424AC_MSG_CHECKING(--disable-nls argument)
4425AC_ARG_ENABLE(nls,
4426 [ --disable-nls Don't support NLS (gettext()).], ,
4427 [enable_nls="yes"])
4428
4429if test "$enable_nls" = "yes"; then
4430 AC_MSG_RESULT(no)
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00004431
4432 INSTALL_LANGS=install-languages
4433 AC_SUBST(INSTALL_LANGS)
4434 INSTALL_TOOL_LANGS=install-tool-languages
4435 AC_SUBST(INSTALL_TOOL_LANGS)
4436
Bram Moolenaar071d4272004-06-13 20:20:40 +00004437 AC_CHECK_PROG(MSGFMT, msgfmt, msgfmt, )
4438 AC_MSG_CHECKING([for NLS])
4439 if test -f po/Makefile; then
4440 have_gettext="no"
4441 if test -n "$MSGFMT"; then
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004442 olibs=$LIBS
4443 LIBS=""
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004444 AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004445 [#include <libintl.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004446 [gettext("Test");])],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004447 AC_MSG_RESULT([gettext() works]); have_gettext="yes"; LIBS=$olibs,
4448 LIBS="-lintl"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004449 AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004450 [#include <libintl.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004451 [gettext("Test");])],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004452 AC_MSG_RESULT([gettext() works with -lintl]); have_gettext="yes";
4453 LIBS="$olibs -lintl",
Bram Moolenaar071d4272004-06-13 20:20:40 +00004454 AC_MSG_RESULT([gettext() doesn't work]);
4455 LIBS=$olibs))
4456 else
4457 AC_MSG_RESULT([msgfmt not found - disabled]);
4458 fi
Bram Moolenaar278eb582014-07-30 13:22:52 +02004459 if test $have_gettext = "yes" -a "x$features" != "xtiny" -a "x$features" != "xsmall"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004460 AC_DEFINE(HAVE_GETTEXT)
4461 MAKEMO=yes
4462 AC_SUBST(MAKEMO)
4463 dnl this was added in GNU gettext 0.10.36
4464 AC_CHECK_FUNCS(bind_textdomain_codeset)
4465 dnl _nl_msg_cat_cntr is required for GNU gettext
4466 AC_MSG_CHECKING([for _nl_msg_cat_cntr])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004467 AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004468 [#include <libintl.h>
4469 extern int _nl_msg_cat_cntr;],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004470 [++_nl_msg_cat_cntr;])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004471 AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_NL_MSG_CAT_CNTR),
4472 AC_MSG_RESULT([no]))
Bram Moolenaar26096cc2019-04-11 15:25:40 +02004473 AC_MSG_CHECKING([if msgfmt supports --desktop])
4474 MSGFMT_DESKTOP=
4475 if "$MSGFMT" --help | grep -e '--desktop' >/dev/null; then
Bram Moolenaar62a88f42019-06-07 20:44:40 +02004476 if "$MSGFMT" --version | grep '0.19.[[3-7]]$' >/dev/null; then
4477 dnl GNU gettext 0.19.7's --desktop is broken. We assume back to
4478 dnl 0.19.3 is also broken.
4479 AC_MSG_RESULT([broken])
4480 else
4481 AC_MSG_RESULT([yes])
4482 MSGFMT_DESKTOP="gvim.desktop vim.desktop"
4483 fi
Bram Moolenaar26096cc2019-04-11 15:25:40 +02004484 else
4485 AC_MSG_RESULT([no])
4486 fi
4487 AC_SUBST(MSGFMT_DESKTOP)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004488 fi
4489 else
4490 AC_MSG_RESULT([no "po/Makefile" - disabled]);
4491 fi
4492else
4493 AC_MSG_RESULT(yes)
4494fi
4495
4496dnl Check for dynamic linking loader
4497AC_CHECK_HEADER(dlfcn.h, DLL=dlfcn.h, [AC_CHECK_HEADER(dl.h, DLL=dl.h)])
4498if test x${DLL} = xdlfcn.h; then
4499 AC_DEFINE(HAVE_DLFCN_H, 1, [ Define if we have dlfcn.h. ])
4500 AC_MSG_CHECKING([for dlopen()])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004501 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004502 extern void* dlopen();
4503 dlopen();
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004504 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004505 AC_MSG_RESULT(yes);
4506 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4507 AC_MSG_RESULT(no);
4508 AC_MSG_CHECKING([for dlopen() in -ldl])
4509 olibs=$LIBS
4510 LIBS="$LIBS -ldl"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004511 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004512 extern void* dlopen();
4513 dlopen();
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004514 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004515 AC_MSG_RESULT(yes);
4516 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4517 AC_MSG_RESULT(no);
4518 LIBS=$olibs))
4519 dnl ReliantUNIX has dlopen() in libc but everything else in libdl
4520 dnl ick :-)
4521 AC_MSG_CHECKING([for dlsym()])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004522 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004523 extern void* dlsym();
4524 dlsym();
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004525 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004526 AC_MSG_RESULT(yes);
4527 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4528 AC_MSG_RESULT(no);
4529 AC_MSG_CHECKING([for dlsym() in -ldl])
4530 olibs=$LIBS
4531 LIBS="$LIBS -ldl"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004532 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004533 extern void* dlsym();
4534 dlsym();
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004535 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004536 AC_MSG_RESULT(yes);
4537 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4538 AC_MSG_RESULT(no);
4539 LIBS=$olibs))
4540elif test x${DLL} = xdl.h; then
4541 AC_DEFINE(HAVE_DL_H, 1, [ Define if we have dl.h. ])
4542 AC_MSG_CHECKING([for shl_load()])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004543 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004544 extern void* shl_load();
4545 shl_load();
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004546 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004547 AC_MSG_RESULT(yes);
4548 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4549 AC_MSG_RESULT(no);
4550 AC_MSG_CHECKING([for shl_load() in -ldld])
4551 olibs=$LIBS
4552 LIBS="$LIBS -ldld"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004553 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004554 extern void* shl_load();
4555 shl_load();
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004556 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004557 AC_MSG_RESULT(yes);
4558 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4559 AC_MSG_RESULT(no);
4560 LIBS=$olibs))
4561fi
4562AC_CHECK_HEADERS(setjmp.h)
4563
Bram Moolenaard0573012017-10-28 21:11:06 +02004564if test "x$MACOS_X" = "xyes" -a -n "$PERL"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004565 dnl -ldl must come after DynaLoader.a
4566 if echo $LIBS | grep -e '-ldl' >/dev/null; then
4567 LIBS=`echo $LIBS | sed s/-ldl//`
4568 PERL_LIBS="$PERL_LIBS -ldl"
4569 fi
4570fi
4571
Bram Moolenaard0573012017-10-28 21:11:06 +02004572if test "$MACOS_X" = "yes"; then
4573 AC_MSG_CHECKING([whether we need macOS frameworks])
Bram Moolenaar097148e2020-08-11 21:58:20 +02004574 if test "$MACOS_X_DARWIN" = "yes"; then
Bram Moolenaard0573012017-10-28 21:11:06 +02004575 if test "$features" = "tiny"; then
4576 dnl Since no FEAT_CLIPBOARD, no longer need for os_macosx.m.
4577 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_macosx.m++'`
4578 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_macosx.o++'`
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01004579 AC_MSG_RESULT([yes, we need CoreServices])
4580 LIBS="$LIBS -framework CoreServices"
Bram Moolenaard0573012017-10-28 21:11:06 +02004581 else
4582 AC_MSG_RESULT([yes, we need AppKit])
4583 LIBS="$LIBS -framework AppKit"
Bram Moolenaard0573012017-10-28 21:11:06 +02004584 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004585 else
Bram Moolenaard0573012017-10-28 21:11:06 +02004586 AC_MSG_RESULT([no])
Bram Moolenaar3437b912013-07-03 19:52:53 +02004587 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004588fi
4589
Bram Moolenaar3ae5fc92021-09-06 18:57:30 +02004590dnl On some systems REENTRANT needs to be defined. It should not hurt to use
4591dnl it everywhere.
4592if `echo "$CFLAGS" | grep -v D_REENTRANT >/dev/null`; then
4593 CFLAGS="$CFLAGS -D_REENTRANT"
4594fi
4595
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004596dnl gcc 3.1 changed the meaning of -MM. The only solution appears to be to
4597dnl use "-isystem" instead of "-I" for all non-Vim include dirs.
4598dnl But only when making dependencies, cproto and lint don't take "-isystem".
Bram Moolenaar32466aa2006-02-24 23:53:04 +00004599dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
4600dnl the number before the version number.
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004601DEPEND_CFLAGS_FILTER=
4602if test "$GCC" = yes; then
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004603 AC_MSG_CHECKING(for GCC 3 or later)
Bram Moolenaar348808f2020-02-07 20:50:07 +01004604 gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]][[0-9]]*\)\..*$/\1/g'`
Bram Moolenaarf740b292006-02-16 22:11:02 +00004605 if test "$gccmajor" -gt "2"; then
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004606 DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004607 AC_MSG_RESULT(yes)
4608 else
4609 AC_MSG_RESULT(no)
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004610 fi
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004611 dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
4612 dnl declared as char x[1] but actually longer. Introduced in gcc 4.0.
Bram Moolenaar56d1db32009-12-16 16:14:51 +00004613 dnl Also remove duplicate _FORTIFY_SOURCE arguments.
Bram Moolenaaraeabe052011-12-08 15:17:34 +01004614 dnl And undefine it first to avoid a warning.
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004615 AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
4616 if test "$gccmajor" -gt "3"; then
Bram Moolenaar26f20132021-04-03 17:33:52 +02004617 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/'`
4618 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 +00004619 AC_MSG_RESULT(yes)
4620 else
4621 AC_MSG_RESULT(no)
4622 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +00004623fi
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004624AC_SUBST(DEPEND_CFLAGS_FILTER)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004625
Bram Moolenaarec0557f2018-01-31 14:41:37 +01004626dnl On some systems AC_SYS_LARGEFILE determines that -D_FILE_OFFSET_BITS=64
4627dnl isn't required, but the CFLAGS for some of the libraries we're using
4628dnl include the define. Since the define changes the size of some datatypes
4629dnl (e.g. ino_t and off_t), all of Vim's modules must be compiled with a
4630dnl consistent value. It's therefore safest to force the use of the define
4631dnl if it's present in any of the *_CFLAGS variables.
4632AC_MSG_CHECKING(whether we need to force -D_FILE_OFFSET_BITS=64)
Bram Moolenaar9ce42132018-04-11 22:19:36 +02004633if 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 +01004634 AC_MSG_RESULT(yes)
4635 AC_DEFINE(_FILE_OFFSET_BITS, 64)
4636else
4637 AC_MSG_RESULT(no)
4638fi
4639
Bram Moolenaar6cd42db2020-12-04 18:09:54 +01004640dnl $LDFLAGS is passed to glibtool in libvterm, it doesn't like a space
4641dnl between "-L" and the path that follows.
4642LDFLAGS=`echo "$LDFLAGS" | sed -e 's/-L /-L/g'`
4643
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004644dnl link.sh tries to avoid overlinking in a hackish way.
4645dnl At least GNU ld supports --as-needed which provides the same functionality
4646dnl at linker level. Let's use it.
4647AC_MSG_CHECKING(linker --as-needed support)
4648LINK_AS_NEEDED=
4649# Check if linker supports --as-needed and --no-as-needed options
4650if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
Natanael Copa761ead42021-05-15 14:25:37 +02004651 if ! echo "$LDFLAGS" | grep -q -- '-Wl,[[^[:space:]]]*--as-needed'; then
4652 LDFLAGS="$LDFLAGS -Wl,--as-needed"
4653 fi
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004654 LINK_AS_NEEDED=yes
4655fi
4656if test "$LINK_AS_NEEDED" = yes; then
4657 AC_MSG_RESULT(yes)
4658else
4659 AC_MSG_RESULT(no)
4660fi
4661AC_SUBST(LINK_AS_NEEDED)
4662
Bram Moolenaar77c19352012-06-13 19:19:41 +02004663# IBM z/OS reset CFLAGS for config.mk
4664if test "$zOSUnix" = "yes"; then
4665 CFLAGS="-D_ALL_SOURCE -Wc,float\(ieee\),dll"
4666fi
4667
Bram Moolenaar071d4272004-06-13 20:20:40 +00004668dnl write output files
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004669AC_CONFIG_FILES(auto/config.mk:config.mk.in)
4670AC_OUTPUT
Bram Moolenaar071d4272004-06-13 20:20:40 +00004671
4672dnl vim: set sw=2 tw=78 fo+=l: