blob: 0c776a2c422c999fa8f27059332bb8b93689049d [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)
Evan Miller25448072022-12-30 10:42:23 +0000317# 10.5 and earlier lack dispatch
318AC_CHECK_HEADERS(dispatch/dispatch.h)
Bram Moolenaar39766a72013-11-03 00:41:00 +0100319
Bram Moolenaar071d4272004-06-13 20:20:40 +0000320AC_SUBST(OS_EXTRA_SRC)
321AC_SUBST(OS_EXTRA_OBJ)
322
323dnl Add /usr/local/lib to $LDFLAGS and /usr/local/include to CFLAGS.
324dnl Only when the directory exists and it wasn't there yet.
325dnl For gcc don't do this when it is already in the default search path.
Bram Moolenaar446cb832008-06-24 21:56:24 +0000326dnl Skip all of this when cross-compiling.
327if test "$cross_compiling" = no; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000328 AC_MSG_CHECKING(--with-local-dir argument)
Bram Moolenaar446cb832008-06-24 21:56:24 +0000329 have_local_include=''
330 have_local_lib=''
Bram Moolenaarc236c162008-07-13 17:41:49 +0000331 AC_ARG_WITH([local-dir], [ --with-local-dir=PATH search PATH instead of /usr/local for local libraries.
332 --without-local-dir do not search /usr/local for local libraries.], [
333 local_dir="$withval"
334 case "$withval" in
335 */*) ;;
336 no)
337 # avoid adding local dir to LDFLAGS and CPPFLAGS
Bram Moolenaare06c1882010-07-21 22:05:20 +0200338 have_local_include=yes
Bram Moolenaarc236c162008-07-13 17:41:49 +0000339 have_local_lib=yes
340 ;;
341 *) AC_MSG_ERROR(must pass path argument to --with-local-dir) ;;
342 esac
343 AC_MSG_RESULT($local_dir)
344 ], [
345 local_dir=/usr/local
346 AC_MSG_RESULT(Defaulting to $local_dir)
347 ])
348 if test "$GCC" = yes -a "$local_dir" != no; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000349 echo 'void f(){}' > conftest.c
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100350 dnl Removed -no-cpp-precomp, only needed for OS X 10.2 (Ben Fowler)
351 have_local_include=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/include"`
Bram Moolenaarc236c162008-07-13 17:41:49 +0000352 have_local_lib=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/lib"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000353 rm -f conftest.c conftest.o
Bram Moolenaar071d4272004-06-13 20:20:40 +0000354 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000355 if test -z "$have_local_lib" -a -d "${local_dir}/lib"; then
356 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 +0000357 if test "$tt" = "$LDFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000358 LDFLAGS="$LDFLAGS -L${local_dir}/lib"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000359 fi
360 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000361 if test -z "$have_local_include" -a -d "${local_dir}/include"; then
362 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 +0000363 if test "$tt" = "$CPPFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000364 CPPFLAGS="$CPPFLAGS -I${local_dir}/include"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000365 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000366 fi
367fi
368
369AC_MSG_CHECKING(--with-vim-name argument)
370AC_ARG_WITH(vim-name, [ --with-vim-name=NAME what to call the Vim executable],
371 VIMNAME="$withval"; AC_MSG_RESULT($VIMNAME),
Bram Moolenaare344bea2005-09-01 20:46:49 +0000372 VIMNAME="vim"; AC_MSG_RESULT(Defaulting to $VIMNAME))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000373AC_SUBST(VIMNAME)
374AC_MSG_CHECKING(--with-ex-name argument)
375AC_ARG_WITH(ex-name, [ --with-ex-name=NAME what to call the Ex executable],
376 EXNAME="$withval"; AC_MSG_RESULT($EXNAME),
377 EXNAME="ex"; AC_MSG_RESULT(Defaulting to ex))
378AC_SUBST(EXNAME)
379AC_MSG_CHECKING(--with-view-name argument)
380AC_ARG_WITH(view-name, [ --with-view-name=NAME what to call the View executable],
381 VIEWNAME="$withval"; AC_MSG_RESULT($VIEWNAME),
382 VIEWNAME="view"; AC_MSG_RESULT(Defaulting to view))
383AC_SUBST(VIEWNAME)
384
385AC_MSG_CHECKING(--with-global-runtime argument)
Bram Moolenaar9d302ad2018-12-21 11:48:51 +0100386AC_ARG_WITH(global-runtime, [ --with-global-runtime=DIR global runtime directory in 'runtimepath', comma-separated for multiple directories],
387 RUNTIME_GLOBAL="$withval"; AC_MSG_RESULT($withval),
Bram Moolenaar071d4272004-06-13 20:20:40 +0000388 AC_MSG_RESULT(no))
389
Bram Moolenaar9d302ad2018-12-21 11:48:51 +0100390if test "X$RUNTIME_GLOBAL" != "X"; then
391 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" }')
392 AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL, "$RUNTIME_GLOBAL")
393 AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL_AFTER, "$RUNTIME_GLOBAL_AFTER")
394fi
395
Bram Moolenaar071d4272004-06-13 20:20:40 +0000396AC_MSG_CHECKING(--with-modified-by argument)
397AC_ARG_WITH(modified-by, [ --with-modified-by=NAME name of who modified a release version],
398 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(MODIFIED_BY, "$withval"),
399 AC_MSG_RESULT(no))
400
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200401dnl Check for EBCDIC stolen from the LYNX port to z/OS Unix
Bram Moolenaar071d4272004-06-13 20:20:40 +0000402AC_MSG_CHECKING(if character set is EBCDIC)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +0100403AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ ],
Bram Moolenaar071d4272004-06-13 20:20:40 +0000404[ /* TryCompile function for CharSet.
405 Treat any failure as ASCII for compatibility with existing art.
406 Use compile-time rather than run-time tests for cross-compiler
407 tolerance. */
408#if '0'!=240
409make an error "Character set is not EBCDIC"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +0100410#endif ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +0000411[ # TryCompile action if true
412cf_cv_ebcdic=yes ],
413[ # TryCompile action if false
414cf_cv_ebcdic=no])
415# end of TryCompile ])
416# end of CacheVal CvEbcdic
417AC_MSG_RESULT($cf_cv_ebcdic)
418case "$cf_cv_ebcdic" in #(vi
419 yes) AC_DEFINE(EBCDIC)
420 line_break='"\\n"'
421 ;;
422 *) line_break='"\\012"';;
423esac
424AC_SUBST(line_break)
425
426if test "$cf_cv_ebcdic" = "yes"; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +0200427dnl If we have EBCDIC we most likely have z/OS Unix, let's test it!
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200428AC_MSG_CHECKING(for z/OS Unix)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000429case $vim_cv_uname_output in
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200430 OS/390) zOSUnix="yes";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000431 dnl If using cc the environment variable _CC_CCMODE must be
432 dnl set to "1", so that some compiler extensions are enabled.
433 dnl If using c89 the environment variable is named _CC_C89MODE.
434 dnl Note: compile with c89 never tested.
435 if test "$CC" = "cc"; then
436 ccm="$_CC_CCMODE"
437 ccn="CC"
438 else
439 if test "$CC" = "c89"; then
440 ccm="$_CC_C89MODE"
441 ccn="C89"
442 else
443 ccm=1
444 fi
445 fi
446 if test "$ccm" != "1"; then
447 echo ""
448 echo "------------------------------------------"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200449 echo " On z/OS Unix, the environment variable"
Bram Moolenaar77c19352012-06-13 19:19:41 +0200450 echo " _CC_${ccn}MODE must be set to \"1\"!"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000451 echo " Do:"
452 echo " export _CC_${ccn}MODE=1"
453 echo " and then call configure again."
454 echo "------------------------------------------"
455 exit 1
456 fi
Bram Moolenaar77c19352012-06-13 19:19:41 +0200457 # Set CFLAGS for configure process.
458 # This will be reset later for config.mk.
459 # Use haltonmsg to force error for missing H files.
460 CFLAGS="$CFLAGS -D_ALL_SOURCE -Wc,float(ieee),haltonmsg(3296)";
461 LDFLAGS="$LDFLAGS -Wl,EDIT=NO"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000462 AC_MSG_RESULT(yes)
463 ;;
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200464 *) zOSUnix="no";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000465 AC_MSG_RESULT(no)
466 ;;
467esac
468fi
469
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200470dnl Set QUOTESED. Needs additional backslashes on zOS
471if test "$zOSUnix" = "yes"; then
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 +0200473else
Bram Moolenaarabcbb0e2020-12-23 12:33:42 +0100474 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\&/g' -e 's/\\\\\"/\"/' -e 's/\\\\\";\$\$/\";/' -e 's/ */ /g'"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200475fi
476AC_SUBST(QUOTESED)
477
478
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200479dnl Link with -lsmack for Smack stuff; if not found
480AC_MSG_CHECKING(--disable-smack argument)
481AC_ARG_ENABLE(smack,
482 [ --disable-smack Do not check for Smack support.],
483 , enable_smack="yes")
484if test "$enable_smack" = "yes"; then
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200485 AC_MSG_RESULT(no)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200486 AC_CHECK_HEADER([linux/xattr.h], true, enable_smack="no")
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200487else
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200488 AC_MSG_RESULT(yes)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200489fi
490if test "$enable_smack" = "yes"; then
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200491 AC_CHECK_HEADER([attr/xattr.h], true, enable_smack="no")
492fi
493if test "$enable_smack" = "yes"; then
494 AC_MSG_CHECKING(for XATTR_NAME_SMACKEXEC in linux/xattr.h)
495 AC_EGREP_CPP(XATTR_NAME_SMACKEXEC, [#include <linux/xattr.h>],
496 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +0200497 AC_MSG_RESULT(no); enable_smack="no")
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200498fi
499if test "$enable_smack" = "yes"; then
500 AC_CHECK_LIB(attr, setxattr,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200501 [LIBS="$LIBS -lattr"
502 found_smack="yes"
503 AC_DEFINE(HAVE_SMACK)])
Bram Moolenaar588ebeb2008-05-07 17:09:24 +0000504fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000505
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200506dnl When smack was found don't search for SELinux
507if test "x$found_smack" = "x"; then
508 dnl Link with -lselinux for SELinux stuff; if not found
509 AC_MSG_CHECKING(--disable-selinux argument)
510 AC_ARG_ENABLE(selinux,
511 [ --disable-selinux Do not check for SELinux support.],
512 , enable_selinux="yes")
513 if test "$enable_selinux" = "yes"; then
514 AC_MSG_RESULT(no)
515 AC_CHECK_LIB(selinux, is_selinux_enabled,
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100516 [AC_CHECK_HEADER(selinux/selinux.h,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200517 [LIBS="$LIBS -lselinux"
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100518 AC_DEFINE(HAVE_SELINUX)])])
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200519 else
520 AC_MSG_RESULT(yes)
521 fi
522fi
523
Bram Moolenaar071d4272004-06-13 20:20:40 +0000524dnl Check user requested features.
525
526AC_MSG_CHECKING(--with-features argument)
Martin Tournoij25f3a142022-10-08 19:26:41 +0100527AC_ARG_WITH(features, [ --with-features=TYPE tiny, normal or huge (default: huge)],
Bram Moolenaar071d4272004-06-13 20:20:40 +0000528 features="$withval"; AC_MSG_RESULT($features),
Bram Moolenaar23c4f712016-01-20 22:11:59 +0100529 features="huge"; AC_MSG_RESULT(Defaulting to huge))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000530
Martin Tournoij7904fa42022-10-04 16:28:45 +0100531dnl "small" is supported for backwards compatibility, now an alias for "tiny"
Martin Tournoij25f3a142022-10-08 19:26:41 +0100532dnl "big" is supported for backwards compatibility, now an alias for "normal"
Martin Tournoij7904fa42022-10-04 16:28:45 +0100533case "$features" in
Martin Tournoij25f3a142022-10-08 19:26:41 +0100534 small) features="tiny" ;;
535 big) features="normal" ;;
Martin Tournoij7904fa42022-10-04 16:28:45 +0100536esac
537
Bram Moolenaar071d4272004-06-13 20:20:40 +0000538dovimdiff=""
539dogvimdiff=""
540case "$features" in
541 tiny) AC_DEFINE(FEAT_TINY) ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000542 normal) AC_DEFINE(FEAT_NORMAL) dovimdiff="installvimdiff";
543 dogvimdiff="installgvimdiff" ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000544 huge) AC_DEFINE(FEAT_HUGE) dovimdiff="installvimdiff";
545 dogvimdiff="installgvimdiff" ;;
546 *) AC_MSG_RESULT([Sorry, $features is not supported]) ;;
547esac
548
549AC_SUBST(dovimdiff)
550AC_SUBST(dogvimdiff)
551
Martin Tournoij7904fa42022-10-04 16:28:45 +0100552if test "x$features" = "xtiny"; then
Bram Moolenaar12471262022-01-18 11:11:25 +0000553 has_eval=no
554else
555 has_eval=yes
556fi
557
Bram Moolenaar071d4272004-06-13 20:20:40 +0000558AC_MSG_CHECKING(--with-compiledby argument)
559AC_ARG_WITH(compiledby, [ --with-compiledby=NAME name to show in :version message],
560 compiledby="$withval"; AC_MSG_RESULT($withval),
561 compiledby=""; AC_MSG_RESULT(no))
562AC_SUBST(compiledby)
563
564AC_MSG_CHECKING(--disable-xsmp argument)
565AC_ARG_ENABLE(xsmp,
566 [ --disable-xsmp Disable XSMP session management],
567 , enable_xsmp="yes")
568
569if test "$enable_xsmp" = "yes"; then
570 AC_MSG_RESULT(no)
571 AC_MSG_CHECKING(--disable-xsmp-interact argument)
572 AC_ARG_ENABLE(xsmp-interact,
573 [ --disable-xsmp-interact Disable XSMP interaction],
574 , enable_xsmp_interact="yes")
575 if test "$enable_xsmp_interact" = "yes"; then
576 AC_MSG_RESULT(no)
577 AC_DEFINE(USE_XSMP_INTERACT)
578 else
579 AC_MSG_RESULT(yes)
580 fi
581else
582 AC_MSG_RESULT(yes)
583fi
584
Bram Moolenaar67ffb412022-01-08 13:36:57 +0000585AC_MSG_CHECKING([diff feature])
Martin Tournoij7904fa42022-10-04 16:28:45 +0100586if test "x$features" = "xtiny"; then
Bram Moolenaar67ffb412022-01-08 13:36:57 +0000587 AC_MSG_RESULT([disabled in $features version])
588else
589 AC_MSG_RESULT(enabled)
590 AC_DEFINE(FEAT_DIFF)
591 XDIFF_OBJS_USED="\$(XDIFF_OBJS)"
592 AC_SUBST(XDIFF_OBJS_USED)
593fi
594
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200595dnl Check for Lua feature.
596AC_MSG_CHECKING(--enable-luainterp argument)
597AC_ARG_ENABLE(luainterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200598 [ --enable-luainterp[=OPTS] Include Lua interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200599 [enable_luainterp="no"])
600AC_MSG_RESULT($enable_luainterp)
601
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200602if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then
Bram Moolenaar12471262022-01-18 11:11:25 +0000603 if test "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +0100604 AC_MSG_ERROR([cannot use Lua with tiny features])
Bram Moolenaar3c124e32016-01-31 14:36:58 +0100605 fi
606
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200607 dnl -- find the lua executable
608 AC_SUBST(vi_cv_path_lua)
609
610 AC_MSG_CHECKING(--with-lua-prefix argument)
611 AC_ARG_WITH(lua_prefix,
612 [ --with-lua-prefix=PFX Prefix where Lua is installed.],
613 with_lua_prefix="$withval"; AC_MSG_RESULT($with_lua_prefix),
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200614 with_lua_prefix="";AC_MSG_RESULT(no))
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200615
616 if test "X$with_lua_prefix" != "X"; then
617 vi_cv_path_lua_pfx="$with_lua_prefix"
618 else
619 AC_MSG_CHECKING(LUA_PREFIX environment var)
620 if test "X$LUA_PREFIX" != "X"; then
621 AC_MSG_RESULT("$LUA_PREFIX")
622 vi_cv_path_lua_pfx="$LUA_PREFIX"
623 else
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200624 AC_MSG_RESULT([not set, default to /usr])
625 vi_cv_path_lua_pfx="/usr"
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200626 fi
627 fi
628
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200629 AC_MSG_CHECKING(--with-luajit)
630 AC_ARG_WITH(luajit,
631 [ --with-luajit Link with LuaJIT instead of Lua.],
632 [vi_cv_with_luajit="$withval"],
633 [vi_cv_with_luajit="no"])
634 AC_MSG_RESULT($vi_cv_with_luajit)
635
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200636 LUA_INC=
637 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200638 if test "x$vi_cv_with_luajit" != "xno"; then
639 dnl -- try to find LuaJIT executable
640 AC_PATH_PROG(vi_cv_path_luajit, luajit)
641 if test "X$vi_cv_path_luajit" != "X"; then
642 dnl -- find LuaJIT version
643 AC_CACHE_CHECK(LuaJIT version, vi_cv_version_luajit,
Bram Moolenaar49b10272013-11-21 12:17:51 +0100644 [ 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 +0200645 AC_CACHE_CHECK(Lua version of LuaJIT, vi_cv_version_lua_luajit,
646 [ vi_cv_version_lua_luajit=`${vi_cv_path_luajit} -e "print(_VERSION)" | sed 's/.* //'` ])
647 vi_cv_path_lua="$vi_cv_path_luajit"
648 vi_cv_version_lua="$vi_cv_version_lua_luajit"
649 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200650 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200651 dnl -- try to find Lua executable
652 AC_PATH_PROG(vi_cv_path_plain_lua, lua)
653 if test "X$vi_cv_path_plain_lua" != "X"; then
654 dnl -- find Lua version
655 AC_CACHE_CHECK(Lua version, vi_cv_version_plain_lua,
656 [ vi_cv_version_plain_lua=`${vi_cv_path_plain_lua} -e "print(_VERSION)" | sed 's/.* //'` ])
657 fi
658 vi_cv_path_lua="$vi_cv_path_plain_lua"
659 vi_cv_version_lua="$vi_cv_version_plain_lua"
660 fi
661 if test "x$vi_cv_with_luajit" != "xno" && test "X$vi_cv_version_luajit" != "X"; then
662 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 +0100663 if test -f "$vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200664 AC_MSG_RESULT(yes)
665 LUA_INC=/luajit-$vi_cv_version_luajit
666 fi
667 fi
668 if test "X$LUA_INC" = "X"; then
669 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)
Bram Moolenaar49222be2015-12-11 18:11:30 +0100670 if test -f "$vi_cv_path_lua_pfx/include/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200671 AC_MSG_RESULT(yes)
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200672 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200673 AC_MSG_RESULT(no)
674 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 +0100675 if test -f "$vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200676 AC_MSG_RESULT(yes)
677 LUA_INC=/lua$vi_cv_version_lua
678 else
679 AC_MSG_RESULT(no)
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200680
681 # Detect moonjit:
682 # https://groups.google.com/forum/#!topic/vim_use/O0vek60WuTk
683 lua_suf=/moonjit-2.3
684 inc_path="$vi_cv_path_lua_pfx/include"
Bram Moolenaarad4dc832020-04-20 16:21:53 +0200685 for dir in "$inc_path"/moonjit-[[0-9]]* ; do
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200686 if test -d "$dir" ; then
Bram Moolenaara79a8942020-12-17 20:50:25 +0100687 lua_suf=`basename "$dir"`
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200688 lua_suf="/$lua_suf"
689 break
690 fi
691 done
692 AC_MSG_CHECKING(if lua.h can be found in $inc_path$lua_suf)
693 if test -f "$inc_path$lua_suf/lua.h"; then
694 AC_MSG_RESULT(yes)
695 LUA_INC=$lua_suf
696 else
697 AC_MSG_RESULT(no)
698 vi_cv_path_lua_pfx=
699 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200700 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200701 fi
702 fi
703 fi
704
705 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200706 if test "x$vi_cv_with_luajit" != "xno"; then
707 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
708 if test "X$multiarch" != "X"; then
709 lib_multiarch="lib/${multiarch}"
710 else
711 lib_multiarch="lib"
712 fi
713 if test "X$vi_cv_version_lua" = "X"; then
714 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit"
715 else
716 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit-$vi_cv_version_lua"
717 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200718 else
Bram Moolenaar869113f2023-03-31 21:29:00 +0100719 dnl Test alternate lib location including version
720 if test -d "${vi_cv_path_lua_pfx}/lib/lua$vi_cv_version_lua"; then
721 LUALIBDIR="lib/lua$vi_cv_version_lua"
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200722 else
Bram Moolenaar869113f2023-03-31 21:29:00 +0100723 LUALIBDIR=lib
724 fi
725 if test "X$LUA_INC" != "X"; then
726 dnl Test alternate name including version
727 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${LUALIBDIR} -llua$vi_cv_version_lua"
728 else
729 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${LUALIBDIR} -llua"
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200730 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200731 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200732 if test "$enable_luainterp" = "dynamic"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200733 lua_ok="yes"
734 else
735 AC_MSG_CHECKING([if link with ${LUA_LIBS} is sane])
736 libs_save=$LIBS
737 LIBS="$LIBS $LUA_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +0100738 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200739 AC_MSG_RESULT(yes); lua_ok="yes",
740 AC_MSG_RESULT(no); lua_ok="no"; LUA_LIBS="")
741 LIBS=$libs_save
742 fi
743 if test "x$lua_ok" = "xyes"; then
744 LUA_CFLAGS="-I${vi_cv_path_lua_pfx}/include${LUA_INC}"
745 LUA_SRC="if_lua.c"
746 LUA_OBJ="objects/if_lua.o"
747 LUA_PRO="if_lua.pro"
748 AC_DEFINE(FEAT_LUA)
749 fi
750 if test "$enable_luainterp" = "dynamic"; then
751 if test "x$vi_cv_with_luajit" != "xno"; then
752 luajit="jit"
753 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200754 if test -f "${vi_cv_path_lua_pfx}/bin/cyglua-${vi_cv_version_lua}.dll"; then
755 vi_cv_dll_name_lua="cyglua-${vi_cv_version_lua}.dll"
756 else
Bram Moolenaard0573012017-10-28 21:11:06 +0200757 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200758 ext="dylib"
759 indexes=""
760 else
761 ext="so"
762 indexes=".0 .1 .2 .3 .4 .5 .6 .7 .8 .9"
763 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
764 if test "X$multiarch" != "X"; then
765 lib_multiarch="lib/${multiarch}"
766 fi
Bram Moolenaar768baac2013-04-15 14:44:57 +0200767 fi
768 dnl Determine the sover for the current version, but fallback to
769 dnl liblua${vi_cv_version_lua}.so if no sover-versioned file is found.
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200770 AC_MSG_CHECKING(if liblua${luajit}*.${ext}* can be found in $vi_cv_path_lua_pfx)
Bram Moolenaar768baac2013-04-15 14:44:57 +0200771 for subdir in "${lib_multiarch}" lib64 lib; do
772 if test -z "$subdir"; then
773 continue
774 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200775 for sover in "${vi_cv_version_lua}.${ext}" "-${vi_cv_version_lua}.${ext}" \
776 ".${vi_cv_version_lua}.${ext}" ".${ext}.${vi_cv_version_lua}"; do
777 for i in $indexes ""; do
778 if test -f "${vi_cv_path_lua_pfx}/${subdir}/liblua${luajit}${sover}$i"; then
Bram Moolenaar768baac2013-04-15 14:44:57 +0200779 sover2="$i"
780 break 3
781 fi
782 done
Bram Moolenaar07e1da62013-02-06 19:49:43 +0100783 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200784 sover=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200785 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200786 if test "X$sover" = "X"; then
787 AC_MSG_RESULT(no)
788 lua_ok="no"
789 vi_cv_dll_name_lua="liblua${luajit}.${ext}"
790 else
791 AC_MSG_RESULT(yes)
792 lua_ok="yes"
793 vi_cv_dll_name_lua="liblua${luajit}${sover}$sover2"
794 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200795 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200796 AC_DEFINE(DYNAMIC_LUA)
797 LUA_LIBS=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200798 LUA_CFLAGS="-DDYNAMIC_LUA_DLL=\\\"${vi_cv_dll_name_lua}\\\" $LUA_CFLAGS"
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200799 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200800 if test "X$LUA_CFLAGS$LUA_LIBS" != "X" && \
Bram Moolenaard0573012017-10-28 21:11:06 +0200801 test "x$MACOS_X" = "xyes" && test "x$vi_cv_with_luajit" != "xno" && \
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000802 test "$vim_cv_uname_m_output" = "x86_64"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200803 dnl OSX/x64 requires these flags. See http://luajit.org/install.html
804 LUA_LIBS="-pagezero_size 10000 -image_base 100000000 $LUA_LIBS"
805 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200806 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200807 if test "$fail_if_missing" = "yes" -a "$lua_ok" != "yes"; then
Bram Moolenaarf788a062011-12-14 20:51:25 +0100808 AC_MSG_ERROR([could not configure lua])
809 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200810 AC_SUBST(LUA_SRC)
811 AC_SUBST(LUA_OBJ)
812 AC_SUBST(LUA_PRO)
813 AC_SUBST(LUA_LIBS)
814 AC_SUBST(LUA_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +0000815 AC_SUBST(LUA_CFLAGS_EXTRA)
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200816fi
817
818
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000819dnl Check for MzScheme feature.
820AC_MSG_CHECKING(--enable-mzschemeinterp argument)
821AC_ARG_ENABLE(mzschemeinterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200822 [ --enable-mzschemeinterp Include MzScheme interpreter.], ,
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000823 [enable_mzschemeinterp="no"])
824AC_MSG_RESULT($enable_mzschemeinterp)
825
826if test "$enable_mzschemeinterp" = "yes"; then
827 dnl -- find the mzscheme executable
828 AC_SUBST(vi_cv_path_mzscheme)
829
830 AC_MSG_CHECKING(--with-plthome argument)
831 AC_ARG_WITH(plthome,
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000832 [ --with-plthome=PLTHOME Use PLTHOME.],
833 with_plthome="$withval"; AC_MSG_RESULT($with_plthome),
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000834 with_plthome="";AC_MSG_RESULT("no"))
835
836 if test "X$with_plthome" != "X"; then
837 vi_cv_path_mzscheme_pfx="$with_plthome"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100838 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000839 else
840 AC_MSG_CHECKING(PLTHOME environment var)
841 if test "X$PLTHOME" != "X"; then
842 AC_MSG_RESULT("$PLTHOME")
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000843 vi_cv_path_mzscheme_pfx="$PLTHOME"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100844 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000845 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000846 AC_MSG_RESULT(not set)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000847 dnl -- try to find MzScheme executable
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000848 AC_PATH_PROG(vi_cv_path_mzscheme, mzscheme)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000849
850 dnl resolve symbolic link, the executable is often elsewhere and there
851 dnl are no links for the include files.
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000852 if test "X$vi_cv_path_mzscheme" != "X"; then
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000853 lsout=`ls -l $vi_cv_path_mzscheme`
854 if echo "$lsout" | grep -e '->' >/dev/null 2>/dev/null; then
855 vi_cv_path_mzscheme=`echo "$lsout" | sed 's/.*-> \(.*\)/\1/'`
856 fi
857 fi
858
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000859 if test "X$vi_cv_path_mzscheme" != "X"; then
860 dnl -- find where MzScheme thinks it was installed
861 AC_CACHE_CHECK(MzScheme install prefix,vi_cv_path_mzscheme_pfx,
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000862 dnl different versions of MzScheme differ in command line processing
863 dnl use universal approach
864 echo "(display (simplify-path \
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000865 (build-path (call-with-values \
866 (lambda () (split-path (find-system-path (quote exec-file)))) \
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000867 (lambda (base name must-be-dir?) base)) (quote up))))" > mzdirs.scm
868 dnl Remove a trailing slash
869 [ vi_cv_path_mzscheme_pfx=`${vi_cv_path_mzscheme} -r mzdirs.scm | \
870 sed -e 's+/$++'` ])
871 rm -f mzdirs.scm
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000872 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000873 fi
874 fi
875
876 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100877 AC_MSG_CHECKING(for racket include directory)
878 SCHEME_INC=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-include-dir))) (when (path? p) (display p)))'`
879 if test "X$SCHEME_INC" != "X"; then
880 AC_MSG_RESULT(${SCHEME_INC})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000881 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100882 AC_MSG_RESULT(not found)
883 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include)
884 if test -f "$vi_cv_path_mzscheme_pfx/include/scheme.h"; then
885 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000886 AC_MSG_RESULT(yes)
Bram Moolenaard7afed32007-05-06 13:26:41 +0000887 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000888 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100889 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt)
890 if test -f "$vi_cv_path_mzscheme_pfx/include/plt/scheme.h"; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000891 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100892 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000893 else
894 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100895 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket)
896 if test -f "$vi_cv_path_mzscheme_pfx/include/racket/scheme.h"; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100897 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100898 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100899 else
900 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100901 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/)
902 if test -f /usr/include/plt/scheme.h; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100903 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100904 SCHEME_INC=/usr/include/plt
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100905 else
906 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100907 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/racket/)
908 if test -f /usr/include/racket/scheme.h; then
909 AC_MSG_RESULT(yes)
910 SCHEME_INC=/usr/include/racket
911 else
912 AC_MSG_RESULT(no)
913 vi_cv_path_mzscheme_pfx=
914 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100915 fi
916 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000917 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000918 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000919 fi
920 fi
921
922 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100923
924 AC_MSG_CHECKING(for racket lib directory)
925 SCHEME_LIB=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-lib-dir))) (when (path? p) (display p)))'`
926 if test "X$SCHEME_LIB" != "X"; then
927 AC_MSG_RESULT(${SCHEME_LIB})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000928 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100929 AC_MSG_RESULT(not found)
930 fi
931
932 for path in "${vi_cv_path_mzscheme_pfx}/lib" "${SCHEME_LIB}"; do
933 if test "X$path" != "X"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200934 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100935 MZSCHEME_LIBS="-framework Racket"
936 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
937 elif test -f "${path}/libmzscheme3m.a"; then
938 MZSCHEME_LIBS="${path}/libmzscheme3m.a"
939 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
940 elif test -f "${path}/libracket3m.a"; then
941 MZSCHEME_LIBS="${path}/libracket3m.a"
Bram Moolenaar588d2412020-10-03 14:24:19 +0200942 if test -f "${path}/librktio.a"; then
943 MZSCHEME_LIBS="${MZSCHEME_LIBS} ${path}/librktio.a"
944 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100945 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
946 elif test -f "${path}/libracket.a"; then
947 MZSCHEME_LIBS="${path}/libracket.a ${path}/libmzgc.a"
948 elif test -f "${path}/libmzscheme.a"; then
949 MZSCHEME_LIBS="${path}/libmzscheme.a ${path}/libmzgc.a"
950 else
951 dnl Using shared objects
952 if test -f "${path}/libmzscheme3m.so"; then
953 MZSCHEME_LIBS="-L${path} -lmzscheme3m"
954 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
955 elif test -f "${path}/libracket3m.so"; then
956 MZSCHEME_LIBS="-L${path} -lracket3m"
957 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
958 elif test -f "${path}/libracket.so"; then
959 MZSCHEME_LIBS="-L${path} -lracket -lmzgc"
960 else
961 dnl try next until last
962 if test "$path" != "$SCHEME_LIB"; then
963 continue
964 fi
965 MZSCHEME_LIBS="-L${path} -lmzscheme -lmzgc"
966 fi
967 if test "$GCC" = yes; then
968 dnl Make Vim remember the path to the library. For when it's not in
969 dnl $LD_LIBRARY_PATH.
970 MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${path}"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000971 elif test "$vim_cv_uname_output" = SunOS &&
972 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100973 MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${path}"
974 fi
975 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000976 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100977 if test "X$MZSCHEME_LIBS" != "X"; then
978 break
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +0000979 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100980 done
981
982 AC_MSG_CHECKING([if racket requires -pthread])
983 if test "X$SCHEME_LIB" != "X" && $FGREP -e -pthread "$SCHEME_LIB/buildinfo" >/dev/null ; then
984 AC_MSG_RESULT(yes)
985 MZSCHEME_LIBS="${MZSCHEME_LIBS} -pthread"
986 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -pthread"
987 else
988 AC_MSG_RESULT(no)
989 fi
990
991 AC_MSG_CHECKING(for racket config directory)
992 SCHEME_CONFIGDIR=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-config-dir))) (when (path? p) (display p)))'`
993 if test "X$SCHEME_CONFIGDIR" != "X"; then
994 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DMZSCHEME_CONFIGDIR='\"${SCHEME_CONFIGDIR}\"'"
995 AC_MSG_RESULT(${SCHEME_CONFIGDIR})
996 else
997 AC_MSG_RESULT(not found)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000998 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100999
1000 AC_MSG_CHECKING(for racket collects directory)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +01001001 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))))'`
1002 if test "X$SCHEME_COLLECTS" = "X"; then
1003 if test -d "$vi_cv_path_mzscheme_pfx/lib/plt/collects"; then
1004 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/plt/
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001005 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +01001006 if test -d "$vi_cv_path_mzscheme_pfx/lib/racket/collects"; then
1007 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/racket/
Bram Moolenaar75676462013-01-30 14:55:42 +01001008 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +01001009 if test -d "$vi_cv_path_mzscheme_pfx/share/racket/collects"; then
1010 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/
1011 else
1012 if test -d "$vi_cv_path_mzscheme_pfx/collects"; then
1013 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/
1014 fi
Bram Moolenaar75676462013-01-30 14:55:42 +01001015 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001016 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +01001017 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +00001018 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001019 if test "X$SCHEME_COLLECTS" != "X" ; then
1020 AC_MSG_RESULT(${SCHEME_COLLECTS})
1021 else
1022 AC_MSG_RESULT(not found)
1023 fi
1024
1025 AC_MSG_CHECKING(for mzscheme_base.c)
1026 if test -f "${SCHEME_COLLECTS}collects/scheme/base.ss" ; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001027 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +01001028 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
1029 MZSCHEME_MOD="++lib scheme/base"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +01001030 else
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001031 if test -f "${SCHEME_COLLECTS}collects/scheme/base.rkt" ; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +01001032 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +01001033 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
1034 MZSCHEME_MOD="++lib scheme/base"
1035 else
1036 if test -f "${SCHEME_COLLECTS}collects/racket/base.rkt" ; then
1037 MZSCHEME_EXTRA="mzscheme_base.c"
1038 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/raco ctool"
1039 MZSCHEME_MOD=""
1040 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +01001041 fi
1042 fi
1043 if test "X$MZSCHEME_EXTRA" != "X" ; then
1044 dnl need to generate bytecode for MzScheme base
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001045 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE"
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001046 AC_MSG_RESULT(needed)
1047 else
1048 AC_MSG_RESULT(not needed)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001049 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001050
Bram Moolenaar9e902192013-07-17 18:58:11 +02001051 dnl On Ubuntu this fixes "undefined reference to symbol 'ffi_type_void'".
1052 AC_CHECK_LIB(ffi, ffi_type_void, [MZSCHEME_LIBS="$MZSCHEME_LIBS -lffi"])
1053
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001054 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -I${SCHEME_INC} \
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001055 -DMZSCHEME_COLLECTS='\"${SCHEME_COLLECTS}collects\"'"
Bram Moolenaar9e902192013-07-17 18:58:11 +02001056
1057 dnl Test that we can compile a simple program with these CFLAGS and LIBS.
1058 AC_MSG_CHECKING([if compile and link flags for MzScheme are sane])
1059 cflags_save=$CFLAGS
1060 libs_save=$LIBS
1061 CFLAGS="$CFLAGS $MZSCHEME_CFLAGS"
1062 LIBS="$LIBS $MZSCHEME_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001063 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaar9e902192013-07-17 18:58:11 +02001064 AC_MSG_RESULT(yes); mzs_ok=yes,
1065 AC_MSG_RESULT(no: MZSCHEME DISABLED); mzs_ok=no)
1066 CFLAGS=$cflags_save
1067 LIBS=$libs_save
1068 if test $mzs_ok = yes; then
1069 MZSCHEME_SRC="if_mzsch.c"
1070 MZSCHEME_OBJ="objects/if_mzsch.o"
1071 MZSCHEME_PRO="if_mzsch.pro"
1072 AC_DEFINE(FEAT_MZSCHEME)
1073 else
1074 MZSCHEME_CFLAGS=
1075 MZSCHEME_LIBS=
1076 MZSCHEME_EXTRA=
1077 MZSCHEME_MZC=
1078 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001079 fi
1080 AC_SUBST(MZSCHEME_SRC)
1081 AC_SUBST(MZSCHEME_OBJ)
1082 AC_SUBST(MZSCHEME_PRO)
1083 AC_SUBST(MZSCHEME_LIBS)
1084 AC_SUBST(MZSCHEME_CFLAGS)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001085 AC_SUBST(MZSCHEME_EXTRA)
1086 AC_SUBST(MZSCHEME_MZC)
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001087fi
1088
1089
Bram Moolenaar071d4272004-06-13 20:20:40 +00001090AC_MSG_CHECKING(--enable-perlinterp argument)
1091AC_ARG_ENABLE(perlinterp,
Bram Moolenaare06c1882010-07-21 22:05:20 +02001092 [ --enable-perlinterp[=OPTS] Include Perl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001093 [enable_perlinterp="no"])
1094AC_MSG_RESULT($enable_perlinterp)
Bram Moolenaare06c1882010-07-21 22:05:20 +02001095if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00001096 if test "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +01001097 AC_MSG_ERROR([cannot use Perl with tiny features])
Bram Moolenaar3c124e32016-01-31 14:36:58 +01001098 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001099 AC_SUBST(vi_cv_path_perl)
1100 AC_PATH_PROG(vi_cv_path_perl, perl)
1101 if test "X$vi_cv_path_perl" != "X"; then
1102 AC_MSG_CHECKING(Perl version)
1103 if $vi_cv_path_perl -e 'require 5.003_01' >/dev/null 2>/dev/null; then
1104 eval `$vi_cv_path_perl -V:usethreads`
Bram Moolenaare06c1882010-07-21 22:05:20 +02001105 eval `$vi_cv_path_perl -V:libperl`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001106 if test "X$usethreads" = "XUNKNOWN" -o "X$usethreads" = "Xundef"; then
1107 badthreads=no
1108 else
1109 if $vi_cv_path_perl -e 'require 5.6.0' >/dev/null 2>/dev/null; then
1110 eval `$vi_cv_path_perl -V:use5005threads`
1111 if test "X$use5005threads" = "XUNKNOWN" -o "X$use5005threads" = "Xundef"; then
1112 badthreads=no
1113 else
1114 badthreads=yes
1115 AC_MSG_RESULT(>>> Perl > 5.6 with 5.5 threads cannot be used <<<)
1116 fi
1117 else
1118 badthreads=yes
1119 AC_MSG_RESULT(>>> Perl 5.5 with threads cannot be used <<<)
1120 fi
1121 fi
1122 if test $badthreads = no; then
1123 AC_MSG_RESULT(OK)
1124 eval `$vi_cv_path_perl -V:shrpenv`
1125 if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04
1126 shrpenv=""
1127 fi
1128 vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlibexp}'`
1129 AC_SUBST(vi_cv_perllib)
Bram Moolenaard5f62b12014-08-17 17:05:44 +02001130 vi_cv_perl_extutils=unknown_perl_extutils_path
1131 for extutils_rel_path in ExtUtils vendor_perl/ExtUtils; do
1132 xsubpp_path="$vi_cv_perllib/$extutils_rel_path/xsubpp"
1133 if test -f "$xsubpp_path"; then
1134 vi_cv_perl_xsubpp="$xsubpp_path"
1135 fi
1136 done
1137 AC_SUBST(vi_cv_perl_xsubpp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001138 dnl Remove "-fno-something", it breaks using cproto.
Bram Moolenaar280a8682015-06-21 13:41:08 +02001139 dnl Remove "-fdebug-prefix-map", it isn't supported by clang.
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001140 dnl Remove "FORTIFY_SOURCE", it will be defined twice.
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001141 dnl remove -pipe and -Wxxx, it confuses cproto
Bram Moolenaar071d4272004-06-13 20:20:40 +00001142 perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001143 -e 'ccflags;perl_inc;print"\n"' | sed -e 's/-fno[[^ ]]*//' \
1144 -e 's/-fdebug-prefix-map[[^ ]]*//g' \
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001145 -e 's/-pipe //' \
1146 -e 's/-W[[^ ]]*//g' \
1147 -e 's/-D_FORTIFY_SOURCE=.//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001148 dnl Remove "-lc", it breaks on FreeBSD when using "-pthread".
1149 perllibs=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed -e 'ldopts' | \
1150 sed -e '/Warning/d' -e '/Note (probably harmless)/d' \
1151 -e 's/-bE:perl.exp//' -e 's/-lc //'`
1152 dnl Don't add perl lib to $LIBS: if it's not in LD_LIBRARY_PATH
1153 dnl a test in configure may fail because of that.
1154 perlldflags=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed \
1155 -e 'ccdlflags' | sed -e 's/-bE:perl.exp//'`
1156
1157 dnl check that compiling a simple program still works with the flags
1158 dnl added for Perl.
1159 AC_MSG_CHECKING([if compile and link flags for Perl are sane])
1160 cflags_save=$CFLAGS
1161 libs_save=$LIBS
1162 ldflags_save=$LDFLAGS
1163 CFLAGS="$CFLAGS $perlcppflags"
1164 LIBS="$LIBS $perllibs"
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001165 perlldflags=`echo "$perlldflags" | sed -e 's/^ *//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001166 LDFLAGS="$perlldflags $LDFLAGS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001167 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00001168 AC_MSG_RESULT(yes); perl_ok=yes,
1169 AC_MSG_RESULT(no: PERL DISABLED); perl_ok=no)
1170 CFLAGS=$cflags_save
1171 LIBS=$libs_save
1172 LDFLAGS=$ldflags_save
1173 if test $perl_ok = yes; then
1174 if test "X$perlcppflags" != "X"; then
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001175 PERL_CFLAGS=$perlcppflags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001176 fi
1177 if test "X$perlldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001178 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$perlldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001179 LDFLAGS="$perlldflags $LDFLAGS"
1180 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001181 fi
1182 PERL_LIBS=$perllibs
1183 PERL_SRC="auto/if_perl.c if_perlsfio.c"
1184 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o"
1185 PERL_PRO="if_perl.pro if_perlsfio.pro"
1186 AC_DEFINE(FEAT_PERL)
1187 fi
1188 fi
1189 else
1190 AC_MSG_RESULT(>>> too old; need Perl version 5.003_01 or later <<<)
1191 fi
1192 fi
1193
Bram Moolenaard0573012017-10-28 21:11:06 +02001194 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00001195 dnl Mac OS X 10.2 or later
Bram Moolenaar071d4272004-06-13 20:20:40 +00001196 dir=/System/Library/Perl
1197 darwindir=$dir/darwin
1198 if test -d $darwindir; then
1199 PERL=/usr/bin/perl
1200 else
1201 dnl Mac OS X 10.3
1202 dir=/System/Library/Perl/5.8.1
1203 darwindir=$dir/darwin-thread-multi-2level
1204 if test -d $darwindir; then
1205 PERL=/usr/bin/perl
1206 fi
1207 fi
1208 if test -n "$PERL"; then
1209 PERL_DIR="$dir"
1210 PERL_CFLAGS="-DFEAT_PERL -I$darwindir/CORE"
1211 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o $darwindir/auto/DynaLoader/DynaLoader.a"
1212 PERL_LIBS="-L$darwindir/CORE -lperl"
1213 fi
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001214 dnl Perl on Mac OS X 10.5 adds "-arch" flags but these should only
1215 dnl be included if requested by passing --with-mac-arch to
1216 dnl configure, so strip these flags first (if present)
1217 PERL_LIBS=`echo "$PERL_LIBS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
1218 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 +00001219 fi
Bram Moolenaare06c1882010-07-21 22:05:20 +02001220 if test "$enable_perlinterp" = "dynamic"; then
1221 if test "$perl_ok" = "yes" -a "X$libperl" != "X"; then
1222 AC_DEFINE(DYNAMIC_PERL)
1223 PERL_CFLAGS="-DDYNAMIC_PERL_DLL=\\\"$libperl\\\" $PERL_CFLAGS"
1224 fi
1225 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001226
1227 if test "$fail_if_missing" = "yes" -a "$perl_ok" != "yes"; then
1228 AC_MSG_ERROR([could not configure perl])
1229 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001230fi
1231AC_SUBST(shrpenv)
1232AC_SUBST(PERL_SRC)
1233AC_SUBST(PERL_OBJ)
1234AC_SUBST(PERL_PRO)
1235AC_SUBST(PERL_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00001236AC_SUBST(PERL_CFLAGS_EXTRA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001237AC_SUBST(PERL_LIBS)
1238
1239AC_MSG_CHECKING(--enable-pythoninterp argument)
1240AC_ARG_ENABLE(pythoninterp,
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001241 [ --enable-pythoninterp[=OPTS] Include Python interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001242 [enable_pythoninterp="no"])
1243AC_MSG_RESULT($enable_pythoninterp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001244if test "$enable_pythoninterp" = "yes" -o "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00001245 if test "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +01001246 AC_MSG_ERROR([cannot use Python with tiny features])
Bram Moolenaar0b105412014-11-30 13:34:23 +01001247 fi
1248
Bram Moolenaar071d4272004-06-13 20:20:40 +00001249 dnl -- find the python executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001250 AC_MSG_CHECKING(--with-python-command argument)
1251 AC_SUBST(vi_cv_path_python)
1252 AC_ARG_WITH(python-command, [ --with-python-command=NAME name of the Python 2 command (default: python2 or python)],
1253 vi_cv_path_python="$withval"; AC_MSG_RESULT($vi_cv_path_python),
1254 AC_MSG_RESULT(no))
1255
1256 if test "X$vi_cv_path_python" = "X"; then
1257 AC_PATH_PROGS(vi_cv_path_python, python2 python)
1258 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001259 if test "X$vi_cv_path_python" != "X"; then
1260
1261 dnl -- get its version number
1262 AC_CACHE_CHECK(Python version,vi_cv_var_python_version,
1263 [[vi_cv_var_python_version=`
1264 ${vi_cv_path_python} -c 'import sys; print sys.version[:3]'`
1265 ]])
1266
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001267 dnl -- it must be at least version 2.3
1268 AC_MSG_CHECKING(Python is 2.3 or better)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001269 if ${vi_cv_path_python} -c \
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001270 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001271 then
1272 AC_MSG_RESULT(yep)
1273
1274 dnl -- find where python thinks it was installed
1275 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python_pfx,
1276 [ vi_cv_path_python_pfx=`
1277 ${vi_cv_path_python} -c \
1278 "import sys; print sys.prefix"` ])
1279
1280 dnl -- and where it thinks it runs
1281 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python_epfx,
1282 [ vi_cv_path_python_epfx=`
1283 ${vi_cv_path_python} -c \
1284 "import sys; print sys.exec_prefix"` ])
1285
1286 dnl -- python's internal library path
1287
1288 AC_CACHE_VAL(vi_cv_path_pythonpath,
1289 [ vi_cv_path_pythonpath=`
1290 unset PYTHONPATH;
1291 ${vi_cv_path_python} -c \
1292 "import sys, string; print string.join(sys.path,':')"` ])
1293
1294 dnl -- where the Python implementation library archives are
1295
1296 AC_ARG_WITH(python-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001297 [ --with-python-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001298 [ vi_cv_path_python_conf="${withval}"; have_python_config_dir=1 ] )
Bram Moolenaar071d4272004-06-13 20:20:40 +00001299
1300 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python_conf,
1301 [
1302 vi_cv_path_python_conf=
Bram Moolenaarac499e32013-06-02 19:14:17 +02001303 d=`${vi_cv_path_python} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBPL')"`
1304 if test -d "$d" && test -f "$d/config.c"; then
1305 vi_cv_path_python_conf="$d"
1306 else
1307 for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
1308 for subdir in lib64 lib share; do
1309 d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
1310 if test -d "$d" && test -f "$d/config.c"; then
1311 vi_cv_path_python_conf="$d"
1312 fi
1313 done
Bram Moolenaar071d4272004-06-13 20:20:40 +00001314 done
Bram Moolenaarac499e32013-06-02 19:14:17 +02001315 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001316 ])
1317
1318 PYTHON_CONFDIR="${vi_cv_path_python_conf}"
1319
1320 if test "X$PYTHON_CONFDIR" = "X"; then
1321 AC_MSG_RESULT([can't find it!])
1322 else
1323
1324 dnl -- we need to examine Python's config/Makefile too
1325 dnl see what the interpreter is built from
1326 AC_CACHE_VAL(vi_cv_path_python_plibs,
1327 [
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001328 pwd=`pwd`
1329 tmp_mkf="$pwd/config-PyMake$$"
1330 cat -- "${PYTHON_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001331__:
Bram Moolenaar218116c2010-05-20 21:46:00 +02001332 @echo "python_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001333 @echo "python_LIBS='$(LIBS)'"
1334 @echo "python_SYSLIBS='$(SYSLIBS)'"
1335 @echo "python_LINKFORSHARED='$(LINKFORSHARED)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001336 @echo "python_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001337 @echo "python_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001338 @echo "python_PYTHONFRAMEWORK='$(PYTHONFRAMEWORK)'"
1339 @echo "python_PYTHONFRAMEWORKPREFIX='$(PYTHONFRAMEWORKPREFIX)'"
1340 @echo "python_PYTHONFRAMEWORKINSTALLDIR='$(PYTHONFRAMEWORKINSTALLDIR)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001341eof
1342 dnl -- delete the lines from make about Entering/Leaving directory
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001343 eval "`cd ${PYTHON_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1344 rm -f -- "${tmp_mkf}"
Bram Moolenaard0573012017-10-28 21:11:06 +02001345 if test "x$MACOS_X" = "xyes" && test -n "${python_PYTHONFRAMEWORK}" && ${vi_cv_path_python} -c \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001346 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then
1347 vi_cv_path_python_plibs="-framework Python"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001348 if test "x${vi_cv_path_python}" != "x/usr/bin/python" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
1349 vi_cv_path_python_plibs="-F${python_PYTHONFRAMEWORKPREFIX} -framework Python"
1350 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001351 else
Bram Moolenaar9ce42132018-04-11 22:19:36 +02001352 vi_cv_path_python_plibs="-L${PYTHON_CONFDIR} -lpython${vi_cv_var_python_version}"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001353 dnl -- Check if the path contained in python_LINKFORSHARED is
1354 dnl usable for vim build. If not, make and try other
1355 dnl candidates.
Bram Moolenaara161e262015-03-24 15:14:27 +01001356 if test -n "${python_LINKFORSHARED}" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
Bram Moolenaar6c927552015-03-24 12:21:33 +01001357 python_link_symbol=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]].*/\1/'`
1358 python_link_path=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]][[ \t]]*\(.*\)/\2/'`
1359 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1360 dnl -- The path looks relative. Guess the absolute one using
1361 dnl the prefix and try that.
1362 python_link_path="${python_PYTHONFRAMEWORKPREFIX}/${python_link_path}"
1363 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1364 dnl -- A last resort.
1365 python_link_path="${python_PYTHONFRAMEWORKINSTALLDIR}/Versions/${vi_cv_var_python_version}/${python_PYTHONFRAMEWORK}"
1366 dnl -- No check is done. The last word is left to the
1367 dnl "sanity" test on link flags that follows shortly.
1368 fi
1369 python_LINKFORSHARED="${python_link_symbol} ${python_link_path}"
1370 fi
1371 fi
Bram Moolenaar218116c2010-05-20 21:46:00 +02001372 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 +00001373 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1374 vi_cv_path_python_plibs=`echo $vi_cv_path_python_plibs | sed s/-ltermcap//`
1375 fi
1376 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001377 AC_CACHE_CHECK(Python's dll name,vi_cv_dll_name_python,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001378 [
1379 if test "X$python_DLLLIBRARY" != "X"; then
1380 vi_cv_dll_name_python="$python_DLLLIBRARY"
1381 else
1382 vi_cv_dll_name_python="$python_INSTSONAME"
1383 fi
1384 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00001385
1386 PYTHON_LIBS="${vi_cv_path_python_plibs}"
1387 if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001388 PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001389 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001390 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 +00001391 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001392 if test "X$have_python_config_dir" = "X1" -a "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001393 dnl Define PYTHON_HOME if --with-python-config-dir was used
1394 PYTHON_CFLAGS="${PYTHON_CFLAGS} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'"
1395
1396 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001397 PYTHON_SRC="if_python.c"
Bram Moolenaar9bdb9a02012-07-25 16:32:08 +02001398 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001399
1400 dnl On FreeBSD linking with "-pthread" is required to use threads.
1401 dnl _THREAD_SAFE must be used for compiling then.
1402 dnl The "-pthread" is added to $LIBS, so that the following check for
1403 dnl sigaltstack() will look in libc_r (it's there in libc!).
1404 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1405 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1406 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1407 AC_MSG_CHECKING([if -pthread should be used])
1408 threadsafe_flag=
1409 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001410 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001411 if test "$vim_cv_uname_output" != Darwin; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001412 test "$GCC" = yes && threadsafe_flag="-pthread"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001413 if test "$vim_cv_uname_output" = FreeBSD; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001414 threadsafe_flag="-D_THREAD_SAFE"
1415 thread_lib="-pthread"
1416 fi
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001417 if test "$vim_cv_uname_output" = SunOS; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001418 threadsafe_flag="-pthreads"
1419 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001420 fi
1421 libs_save_old=$LIBS
1422 if test -n "$threadsafe_flag"; then
1423 cflags_save=$CFLAGS
1424 CFLAGS="$CFLAGS $threadsafe_flag"
1425 LIBS="$LIBS $thread_lib"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001426 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001427 AC_MSG_RESULT(yes); PYTHON_CFLAGS="$PYTHON_CFLAGS $threadsafe_flag",
Bram Moolenaar071d4272004-06-13 20:20:40 +00001428 AC_MSG_RESULT(no); LIBS=$libs_save_old
1429 )
1430 CFLAGS=$cflags_save
1431 else
1432 AC_MSG_RESULT(no)
1433 fi
1434
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001435 dnl Check that compiling a simple program still works with the flags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001436 dnl added for Python.
1437 AC_MSG_CHECKING([if compile and link flags for Python are sane])
1438 cflags_save=$CFLAGS
1439 libs_save=$LIBS
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001440 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001441 LIBS="$LIBS $PYTHON_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001442 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00001443 AC_MSG_RESULT(yes); python_ok=yes,
1444 AC_MSG_RESULT(no: PYTHON DISABLED); python_ok=no)
1445 CFLAGS=$cflags_save
1446 LIBS=$libs_save
1447 if test $python_ok = yes; then
1448 AC_DEFINE(FEAT_PYTHON)
1449 else
1450 LIBS=$libs_save_old
1451 PYTHON_SRC=
1452 PYTHON_OBJ=
1453 PYTHON_LIBS=
1454 PYTHON_CFLAGS=
1455 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001456 fi
1457 else
1458 AC_MSG_RESULT(too old)
1459 fi
1460 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001461
1462 if test "$fail_if_missing" = "yes" -a "$python_ok" != "yes"; then
1463 AC_MSG_ERROR([could not configure python])
1464 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001465fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001466
Bram Moolenaar071d4272004-06-13 20:20:40 +00001467AC_SUBST(PYTHON_LIBS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001468AC_SUBST(PYTHON_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00001469AC_SUBST(PYTHON_CFLAGS_EXTRA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001470AC_SUBST(PYTHON_SRC)
1471AC_SUBST(PYTHON_OBJ)
1472
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001473
1474AC_MSG_CHECKING(--enable-python3interp argument)
1475AC_ARG_ENABLE(python3interp,
Bram Moolenaar8008b632017-07-18 21:33:20 +02001476 [ --enable-python3interp[=OPTS] Include Python3 interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001477 [enable_python3interp="no"])
1478AC_MSG_RESULT($enable_python3interp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001479if test "$enable_python3interp" = "yes" -o "$enable_python3interp" = "dynamic"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00001480 if test "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +01001481 AC_MSG_ERROR([cannot use Python with tiny features])
Bram Moolenaar0b105412014-11-30 13:34:23 +01001482 fi
1483
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001484 dnl -- find the python3 executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001485 AC_MSG_CHECKING(--with-python3-command argument)
1486 AC_SUBST(vi_cv_path_python3)
1487 AC_ARG_WITH(python3-command, [ --with-python3-command=NAME name of the Python 3 command (default: python3 or python)],
1488 vi_cv_path_python3="$withval"; AC_MSG_RESULT($vi_cv_path_python3),
1489 AC_MSG_RESULT(no))
1490
1491 if test "X$vi_cv_path_python3" = "X"; then
1492 AC_PATH_PROGS(vi_cv_path_python3, python3 python)
1493 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001494 if test "X$vi_cv_path_python3" != "X"; then
1495
1496 dnl -- get its version number
1497 AC_CACHE_CHECK(Python version,vi_cv_var_python3_version,
1498 [[vi_cv_var_python3_version=`
Bram Moolenaar23c01922021-05-21 11:43:58 +02001499 ${vi_cv_path_python3} -c 'import sys; print("{}.{}".format(sys.version_info.major, sys.version_info.minor))'`
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001500 ]])
1501
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001502 dnl -- it must be at least version 3
1503 AC_MSG_CHECKING(Python is 3.0 or better)
1504 if ${vi_cv_path_python3} -c \
1505 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.0)"
1506 then
1507 AC_MSG_RESULT(yep)
Bram Moolenaar456f2bb2011-06-12 21:37:13 +02001508
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001509 dnl -- get abiflags for python 3.2 or higher (PEP 3149)
1510 AC_CACHE_CHECK(Python's abiflags,vi_cv_var_python3_abiflags,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001511 [
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001512 vi_cv_var_python3_abiflags=
1513 if ${vi_cv_path_python3} -c \
1514 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)"
1515 then
Bram Moolenaare5303952022-06-19 17:05:47 +01001516 vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001517 "import sys; print(sys.abiflags)"`
1518 fi ])
Bram Moolenaare5303952022-06-19 17:05:47 +01001519
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001520 dnl -- find where python3 thinks it was installed
1521 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx,
1522 [ vi_cv_path_python3_pfx=`
1523 ${vi_cv_path_python3} -c \
1524 "import sys; print(sys.prefix)"` ])
Bram Moolenaare5303952022-06-19 17:05:47 +01001525
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001526 dnl -- and where it thinks it runs
1527 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx,
1528 [ vi_cv_path_python3_epfx=`
1529 ${vi_cv_path_python3} -c \
1530 "import sys; print(sys.exec_prefix)"` ])
Bram Moolenaare5303952022-06-19 17:05:47 +01001531
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001532 dnl -- python3's internal library path
Bram Moolenaare5303952022-06-19 17:05:47 +01001533
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001534 AC_CACHE_VAL(vi_cv_path_python3path,
1535 [ vi_cv_path_python3path=`
1536 unset PYTHONPATH;
1537 ${vi_cv_path_python3} -c \
1538 "import sys, string; print(':'.join(sys.path))"` ])
Bram Moolenaare5303952022-06-19 17:05:47 +01001539
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001540 dnl -- where the Python implementation library archives are
Bram Moolenaare5303952022-06-19 17:05:47 +01001541
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001542 AC_ARG_WITH(python3-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001543 [ --with-python3-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001544 [ vi_cv_path_python3_conf="${withval}"; have_python3_config_dir=1 ] )
Bram Moolenaare5303952022-06-19 17:05:47 +01001545
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001546 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf,
1547 [
1548 vi_cv_path_python3_conf=
Bram Moolenaarfee496d2013-07-12 20:07:24 +02001549 config_dir="config-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Zdenek Dohnal31e299c2021-06-10 18:50:55 +02001550 d=`${vi_cv_path_python3} -c "import sysconfig; print(sysconfig.get_config_var('LIBPL'))" 2> /dev/null`
1551 if test "x$d" = "x"; then
1552 d=`${vi_cv_path_python3} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBPL'))"`
1553 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001554 if test -d "$d" && test -f "$d/config.c"; then
1555 vi_cv_path_python3_conf="$d"
1556 else
1557 for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do
1558 for subdir in lib64 lib share; do
1559 d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}"
1560 if test -d "$d" && test -f "$d/config.c"; then
1561 vi_cv_path_python3_conf="$d"
1562 fi
1563 done
1564 done
1565 fi
1566 ])
Bram Moolenaare5303952022-06-19 17:05:47 +01001567
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001568 PYTHON3_CONFDIR="${vi_cv_path_python3_conf}"
Bram Moolenaare5303952022-06-19 17:05:47 +01001569
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001570 if test "X$PYTHON3_CONFDIR" = "X"; then
1571 AC_MSG_RESULT([can't find it!])
1572 else
Bram Moolenaare5303952022-06-19 17:05:47 +01001573
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001574 dnl -- we need to examine Python's config/Makefile too
1575 dnl see what the interpreter is built from
1576 AC_CACHE_VAL(vi_cv_path_python3_plibs,
1577 [
1578 pwd=`pwd`
1579 tmp_mkf="$pwd/config-PyMake$$"
1580 cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001581__:
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001582 @echo "python3_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001583 @echo "python3_LIBS='$(LIBS)'"
1584 @echo "python3_SYSLIBS='$(SYSLIBS)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001585 @echo "python3_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001586 @echo "python3_INSTSONAME='$(INSTSONAME)'"
Yee Cheng Chinb6ebe5a2023-04-05 18:24:50 +01001587 @echo "python3_PYTHONFRAMEWORKPREFIX='$(PYTHONFRAMEWORKPREFIX)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001588eof
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001589 dnl -- delete the lines from make about Entering/Leaving directory
1590 eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1591 rm -f -- "${tmp_mkf}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001592 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 +02001593 vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}"
1594 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1595 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//`
1596 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//`
1597 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001598 AC_CACHE_CHECK(Python3's dll name,vi_cv_dll_name_python3,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001599 [
1600 if test "X$python3_DLLLIBRARY" != "X"; then
1601 vi_cv_dll_name_python3="$python3_DLLLIBRARY"
Yee Cheng Chinb6ebe5a2023-04-05 18:24:50 +01001602 elif test "X$python3_PYTHONFRAMEWORKPREFIX" != "X"; then
1603 vi_cv_dll_name_python3="${python3_PYTHONFRAMEWORKPREFIX}/${python3_INSTSONAME}"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001604 else
1605 vi_cv_dll_name_python3="$python3_INSTSONAME"
1606 fi
1607 ])
1608
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001609 PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
1610 if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001611 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 +02001612 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001613 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 +02001614 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001615 if test "X$have_python3_config_dir" = "X1" -a "$enable_python3interp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001616 dnl Define PYTHON3_HOME if --with-python-config-dir was used
1617 PYTHON3_CFLAGS="${PYTHON3_CFLAGS} -DPYTHON3_HOME='L\"${vi_cv_path_python3_pfx}\"'"
1618 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001619 PYTHON3_SRC="if_python3.c"
1620 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaare5303952022-06-19 17:05:47 +01001621
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001622 dnl On FreeBSD linking with "-pthread" is required to use threads.
1623 dnl _THREAD_SAFE must be used for compiling then.
1624 dnl The "-pthread" is added to $LIBS, so that the following check for
1625 dnl sigaltstack() will look in libc_r (it's there in libc!).
1626 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1627 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1628 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1629 AC_MSG_CHECKING([if -pthread should be used])
1630 threadsafe_flag=
1631 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001632 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001633 if test "$vim_cv_uname_output" != Darwin; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001634 test "$GCC" = yes && threadsafe_flag="-pthread"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001635 if test "$vim_cv_uname_output" = FreeBSD; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001636 threadsafe_flag="-D_THREAD_SAFE"
1637 thread_lib="-pthread"
1638 fi
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001639 if test "$vim_cv_uname_output" = SunOS; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001640 threadsafe_flag="-pthreads"
1641 fi
1642 fi
1643 libs_save_old=$LIBS
1644 if test -n "$threadsafe_flag"; then
1645 cflags_save=$CFLAGS
1646 CFLAGS="$CFLAGS $threadsafe_flag"
1647 LIBS="$LIBS $thread_lib"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001648 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001649 AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag",
1650 AC_MSG_RESULT(no); LIBS=$libs_save_old
1651 )
1652 CFLAGS=$cflags_save
1653 else
1654 AC_MSG_RESULT(no)
1655 fi
Bram Moolenaare5303952022-06-19 17:05:47 +01001656
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001657 dnl check that compiling a simple program still works with the flags
1658 dnl added for Python.
1659 AC_MSG_CHECKING([if compile and link flags for Python 3 are sane])
1660 cflags_save=$CFLAGS
1661 libs_save=$LIBS
1662 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1663 LIBS="$LIBS $PYTHON3_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001664 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001665 AC_MSG_RESULT(yes); python3_ok=yes,
1666 AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no)
1667 CFLAGS=$cflags_save
1668 LIBS=$libs_save
1669 if test "$python3_ok" = yes; then
1670 AC_DEFINE(FEAT_PYTHON3)
1671 else
1672 LIBS=$libs_save_old
1673 PYTHON3_SRC=
1674 PYTHON3_OBJ=
1675 PYTHON3_LIBS=
1676 PYTHON3_CFLAGS=
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001677 fi
1678 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001679 else
1680 AC_MSG_RESULT(too old)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001681 fi
1682 fi
Bram Moolenaar1612b1a2013-06-14 21:22:39 +02001683 if test "$fail_if_missing" = "yes" -a "$python3_ok" != "yes"; then
1684 AC_MSG_ERROR([could not configure python3])
1685 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001686fi
1687
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001688AC_SUBST(PYTHON3_LIBS)
1689AC_SUBST(PYTHON3_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00001690AC_SUBST(PYTHON3_CFLAGS_EXTRA)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001691AC_SUBST(PYTHON3_SRC)
1692AC_SUBST(PYTHON3_OBJ)
1693
1694dnl if python2.x and python3.x are enabled one can only link in code
Bram Moolenaare5303952022-06-19 17:05:47 +01001695dnl with dlopen(), dlsym(), dlclose()
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001696if test "$python_ok" = yes && test "$python3_ok" = yes; then
1697 AC_DEFINE(DYNAMIC_PYTHON)
1698 AC_DEFINE(DYNAMIC_PYTHON3)
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001699 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001700 cflags_save=$CFLAGS
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001701 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001702 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001703 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001704 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001705 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001706 #include <dlfcn.h>
1707 /* If this program fails, then RTLD_GLOBAL is needed.
1708 * RTLD_GLOBAL will be used and then it is not possible to
1709 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001710 * Only the first python version used will be switched on.
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001711 */
1712
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01001713 static int no_rtl_global_needed_for(char *python_instsoname, char *prefix)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001714 {
1715 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001716 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001717 if (pylib != 0)
1718 {
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001719 void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome");
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001720 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1721 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1722 void (*final)(void) = dlsym(pylib, "Py_Finalize");
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001723 (*pfx)(prefix);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001724 (*init)();
1725 needed = (*simple)("import termios") == -1;
1726 (*final)();
1727 dlclose(pylib);
1728 }
1729 return !needed;
1730 }
1731
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01001732 int main()
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001733 {
1734 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001735 if (no_rtl_global_needed_for("${vi_cv_dll_name_python}", "${vi_cv_path_python_pfx}"))
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001736 not_needed = 1;
1737 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001738 }])],
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001739 [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001740
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001741 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001742 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001743
1744 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python3)
1745 cflags_save=$CFLAGS
1746 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001747 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001748 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001749 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001750 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001751 #include <dlfcn.h>
1752 #include <wchar.h>
1753 /* If this program fails, then RTLD_GLOBAL is needed.
1754 * RTLD_GLOBAL will be used and then it is not possible to
1755 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001756 * Only the first python version used will be switched on.
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001757 */
1758
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01001759 static int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix)
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001760 {
1761 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001762 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001763 if (pylib != 0)
1764 {
1765 void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome");
1766 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1767 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1768 void (*final)(void) = dlsym(pylib, "Py_Finalize");
1769 (*pfx)(prefix);
1770 (*init)();
1771 needed = (*simple)("import termios") == -1;
1772 (*final)();
1773 dlclose(pylib);
1774 }
1775 return !needed;
1776 }
1777
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01001778 int main()
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001779 {
1780 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001781 if (no_rtl_global_needed_for("${vi_cv_dll_name_python3}", L"${vi_cv_path_python3_pfx}"))
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001782 not_needed = 1;
1783 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001784 }])],
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001785 [AC_MSG_RESULT(yes);AC_DEFINE(PY3_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
1786
1787 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001788 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001789
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001790 PYTHON_SRC="if_python.c"
1791 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001792 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001793 PYTHON_LIBS=
1794 PYTHON3_SRC="if_python3.c"
1795 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001796 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001797 PYTHON3_LIBS=
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001798elif test "$python_ok" = yes && test "$enable_pythoninterp" = "dynamic"; then
1799 AC_DEFINE(DYNAMIC_PYTHON)
1800 PYTHON_SRC="if_python.c"
1801 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001802 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001803 PYTHON_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001804elif test "$python_ok" = yes; then
1805 dnl Check that adding -fPIE works. It may be needed when using a static
1806 dnl Python library.
1807 AC_MSG_CHECKING([if -fPIE can be added for Python])
1808 cflags_save=$CFLAGS
1809 libs_save=$LIBS
1810 CFLAGS="$CFLAGS $PYTHON_CFLAGS -fPIE"
1811 LIBS="$LIBS $PYTHON_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001812 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaare741f272013-07-09 21:57:52 +02001813 AC_MSG_RESULT(yes); fpie_ok=yes,
1814 AC_MSG_RESULT(no); fpie_ok=no)
1815 CFLAGS=$cflags_save
1816 LIBS=$libs_save
1817 if test $fpie_ok = yes; then
1818 PYTHON_CFLAGS="$PYTHON_CFLAGS -fPIE"
1819 fi
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001820elif test "$python3_ok" = yes && test "$enable_python3interp" = "dynamic"; then
1821 AC_DEFINE(DYNAMIC_PYTHON3)
1822 PYTHON3_SRC="if_python3.c"
1823 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001824 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001825 PYTHON3_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001826elif test "$python3_ok" = yes; then
1827 dnl Check that adding -fPIE works. It may be needed when using a static
1828 dnl Python library.
1829 AC_MSG_CHECKING([if -fPIE can be added for Python3])
1830 cflags_save=$CFLAGS
1831 libs_save=$LIBS
1832 CFLAGS="$CFLAGS $PYTHON3_CFLAGS -fPIE"
1833 LIBS="$LIBS $PYTHON3_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001834 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaare741f272013-07-09 21:57:52 +02001835 AC_MSG_RESULT(yes); fpie_ok=yes,
1836 AC_MSG_RESULT(no); fpie_ok=no)
1837 CFLAGS=$cflags_save
1838 LIBS=$libs_save
1839 if test $fpie_ok = yes; then
1840 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -fPIE"
1841 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001842fi
1843
Bram Moolenaar071d4272004-06-13 20:20:40 +00001844AC_MSG_CHECKING(--enable-tclinterp argument)
1845AC_ARG_ENABLE(tclinterp,
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001846 [ --enable-tclinterp[=OPTS] Include Tcl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001847 [enable_tclinterp="no"])
1848AC_MSG_RESULT($enable_tclinterp)
1849
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001850if test "$enable_tclinterp" = "yes" -o "$enable_tclinterp" = "dynamic"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001851
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001852 dnl on FreeBSD tclsh is a silly script, look for tclsh8.[5420]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001853 AC_MSG_CHECKING(--with-tclsh argument)
1854 AC_ARG_WITH(tclsh, [ --with-tclsh=PATH which tclsh to use (default: tclsh8.0)],
1855 tclsh_name="$withval"; AC_MSG_RESULT($tclsh_name),
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001856 tclsh_name="tclsh8.5"; AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00001857 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1858 AC_SUBST(vi_cv_path_tcl)
1859
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001860 dnl when no specific version specified, also try 8.4, 8.2 and 8.0
1861 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.5"; then
1862 tclsh_name="tclsh8.4"
1863 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1864 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001865 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.4"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001866 tclsh_name="tclsh8.2"
1867 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1868 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001869 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.2"; then
1870 tclsh_name="tclsh8.0"
1871 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1872 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001873 dnl still didn't find it, try without version number
1874 if test "X$vi_cv_path_tcl" = "X"; then
1875 tclsh_name="tclsh"
1876 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1877 fi
1878 if test "X$vi_cv_path_tcl" != "X"; then
1879 AC_MSG_CHECKING(Tcl version)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001880 if echo 'exit [[expr [info tclversion] < 8.0]]' | "$vi_cv_path_tcl" - ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001881 tclver=`echo 'puts [[info tclversion]]' | $vi_cv_path_tcl -`
1882 AC_MSG_RESULT($tclver - OK);
1883 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 +01001884 tcldll=`echo 'puts libtcl[[info tclversion]][[info sharedlibextension]]' | $vi_cv_path_tcl -`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001885
1886 AC_MSG_CHECKING(for location of Tcl include)
Bram Moolenaard0573012017-10-28 21:11:06 +02001887 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001888 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 +00001889 else
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001890 dnl For all macOS, use the value from TCL in case use of, say, homebrew
Bram Moolenaar071d4272004-06-13 20:20:40 +00001891 dnl For Mac OS X 10.3, use the OS-provided framework location
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001892 dnl For Mac OS X 10.14, the OS-provided framework location doesn't contain the headers, so also check the Xcode SDK
1893 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 +00001894 fi
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001895 TCL_INC=
Bram Moolenaar071d4272004-06-13 20:20:40 +00001896 for try in $tclinc; do
1897 if test -f "$try/tcl.h"; then
1898 AC_MSG_RESULT($try/tcl.h)
1899 TCL_INC=$try
1900 break
1901 fi
1902 done
1903 if test -z "$TCL_INC"; then
1904 AC_MSG_RESULT(<not found>)
1905 SKIP_TCL=YES
1906 fi
1907 if test -z "$SKIP_TCL"; then
1908 AC_MSG_CHECKING(for location of tclConfig.sh script)
Bram Moolenaard0573012017-10-28 21:11:06 +02001909 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001910 tclcnf=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001911 tclcnf="$tclcnf `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001912 else
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001913 dnl For all macOS, use the value from TCL in case use of, say, homebrew
Bram Moolenaar071d4272004-06-13 20:20:40 +00001914 dnl For Mac OS X 10.3, use the OS-provided framework location
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001915 dnl For Mac OS X 10.14, the OS-provided framework location doesn't contain the headers, so also check the Xcode SDK
1916 tclcnf=`echo $tclinc | sed s/include/lib/g`
1917 tclcnf="$tclcnf /System/Library/Frameworks/Tcl.framework `xcrun --show-sdk-path`/System/Library/Frameworks/Tcl.framework"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001918 fi
1919 for try in $tclcnf; do
Bram Moolenaar49222be2015-12-11 18:11:30 +01001920 if test -f "$try/tclConfig.sh"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001921 AC_MSG_RESULT($try/tclConfig.sh)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001922 . "$try/tclConfig.sh"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001923 dnl use eval, because tcl 8.2 includes ${TCL_DBGX}
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001924 if test "$enable_tclinterp" = "dynamic"; then
1925 TCL_LIBS=`eval echo "$TCL_STUB_LIB_SPEC $TCL_LIBS"`
1926 else
1927 TCL_LIBS=`eval echo "$TCL_LIB_SPEC $TCL_LIBS"`
1928 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001929 dnl Use $TCL_DEFS for -D_THREAD_SAFE et al. But only use the
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001930 dnl "-D_ABC" items. Watch out for -DFOO=long\ long.
Bram Moolenaar4394bff2008-07-24 11:21:31 +00001931 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 +00001932 break
1933 fi
1934 done
1935 if test -z "$TCL_LIBS"; then
1936 AC_MSG_RESULT(<not found>)
1937 AC_MSG_CHECKING(for Tcl library by myself)
1938 tcllib=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001939 tcllib="$tcllib `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001940 for ext in .so .a ; do
1941 for ver in "" $tclver ; do
1942 for try in $tcllib ; do
1943 trylib=tcl$ver$ext
Bram Moolenaar49222be2015-12-11 18:11:30 +01001944 if test -f "$try/lib$trylib" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001945 AC_MSG_RESULT($try/lib$trylib)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001946 TCL_LIBS="-L\"$try\" -ltcl$ver -ldl -lm"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001947 if test "$vim_cv_uname_output" = SunOS &&
1948 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001949 TCL_LIBS="$TCL_LIBS -R $try"
1950 fi
1951 break 3
1952 fi
1953 done
1954 done
1955 done
1956 if test -z "$TCL_LIBS"; then
1957 AC_MSG_RESULT(<not found>)
1958 SKIP_TCL=YES
1959 fi
1960 fi
1961 if test -z "$SKIP_TCL"; then
1962 AC_DEFINE(FEAT_TCL)
1963 TCL_SRC=if_tcl.c
1964 TCL_OBJ=objects/if_tcl.o
1965 TCL_PRO=if_tcl.pro
1966 TCL_CFLAGS="-I$TCL_INC $TCL_DEFS"
1967 fi
1968 fi
1969 else
1970 AC_MSG_RESULT(too old; need Tcl version 8.0 or later)
1971 fi
1972 fi
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001973 if test "$enable_tclinterp" = "dynamic"; then
1974 if test "X$TCL_SRC" != "X" -a "X$tcldll" != "X"; then
1975 AC_DEFINE(DYNAMIC_TCL)
1976 TCL_CFLAGS="-DDYNAMIC_TCL_DLL=\\\"$tcldll\\\" -DDYNAMIC_TCL_VER=\\\"$tclver\\\" $TCL_CFLAGS"
1977 fi
1978 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001979 if test "$fail_if_missing" = "yes" -a -z "$TCL_SRC"; then
1980 AC_MSG_ERROR([could not configure Tcl])
1981 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001982fi
1983AC_SUBST(TCL_SRC)
1984AC_SUBST(TCL_OBJ)
1985AC_SUBST(TCL_PRO)
1986AC_SUBST(TCL_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00001987AC_SUBST(TCL_CFLAGS_EXTRA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001988AC_SUBST(TCL_LIBS)
1989
1990AC_MSG_CHECKING(--enable-rubyinterp argument)
1991AC_ARG_ENABLE(rubyinterp,
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001992 [ --enable-rubyinterp[=OPTS] Include Ruby interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001993 [enable_rubyinterp="no"])
1994AC_MSG_RESULT($enable_rubyinterp)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001995if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00001996 if test "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +01001997 AC_MSG_ERROR([cannot use Ruby with tiny features])
Bram Moolenaar0b105412014-11-30 13:34:23 +01001998 fi
1999
Bram Moolenaar165641d2010-02-17 16:23:09 +01002000 AC_MSG_CHECKING(--with-ruby-command argument)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002001 AC_SUBST(vi_cv_path_ruby)
Bram Moolenaar948733a2011-05-05 18:10:16 +02002002 AC_ARG_WITH(ruby-command, [ --with-ruby-command=RUBY name of the Ruby command (default: ruby)],
2003 RUBY_CMD="$withval"; vi_cv_path_ruby="$withval"; AC_MSG_RESULT($RUBY_CMD),
2004 RUBY_CMD="ruby"; AC_MSG_RESULT(defaulting to $RUBY_CMD))
Bram Moolenaar165641d2010-02-17 16:23:09 +01002005 AC_PATH_PROG(vi_cv_path_ruby, $RUBY_CMD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002006 if test "X$vi_cv_path_ruby" != "X"; then
2007 AC_MSG_CHECKING(Ruby version)
K.Takata236ccbf2022-09-22 16:12:06 +01002008 if $vi_cv_path_ruby -e 'RUBY_VERSION >= "1.9.1" or exit 1' >/dev/null 2>/dev/null; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002009 AC_MSG_RESULT(OK)
Bram Moolenaar81398892012-10-03 21:09:35 +02002010 AC_MSG_CHECKING(Ruby rbconfig)
2011 ruby_rbconfig="RbConfig"
2012 if ! $vi_cv_path_ruby -r rbconfig -e 'RbConfig' >/dev/null 2>/dev/null; then
2013 ruby_rbconfig="Config"
2014 fi
2015 AC_MSG_RESULT($ruby_rbconfig)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002016 AC_MSG_CHECKING(Ruby header files)
Bram Moolenaar81398892012-10-03 21:09:35 +02002017 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 +00002018 if test "X$rubyhdrdir" != "X"; then
2019 AC_MSG_RESULT($rubyhdrdir)
2020 RUBY_CFLAGS="-I$rubyhdrdir"
Bram Moolenaara6fd37b2014-03-27 17:19:09 +01002021 rubyarchdir=`$vi_cv_path_ruby -r rbconfig -e "print ($ruby_rbconfig::CONFIG.has_key? 'rubyarchhdrdir') ? $ruby_rbconfig::CONFIG[['rubyarchhdrdir']] : '$rubyhdrdir/'+$ruby_rbconfig::CONFIG[['arch']]"`
2022 if test -d "$rubyarchdir"; then
2023 RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyarchdir"
Bram Moolenaar165641d2010-02-17 16:23:09 +01002024 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02002025 rubyversion=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['ruby_version']].gsub(/\./, '')[[0,2]]"`
Bram Moolenaar026a4452013-08-07 15:22:23 +02002026 if test "X$rubyversion" = "X"; then
K.Takata236ccbf2022-09-22 16:12:06 +01002027 rubyversion=`$vi_cv_path_ruby -e "print RUBY_VERSION.gsub(/\./, '')[[0,2]]"`
Bram Moolenaar026a4452013-08-07 15:22:23 +02002028 fi
Bram Moolenaar165641d2010-02-17 16:23:09 +01002029 RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
Bram Moolenaar81398892012-10-03 21:09:35 +02002030 rubylibs=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LIBS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002031 if test "X$rubylibs" != "X"; then
2032 RUBY_LIBS="$rubylibs"
2033 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02002034 librubyarg=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBYARG']])"`
2035 librubya=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBY_A']])"`
Bram Moolenaarac499e32013-06-02 19:14:17 +02002036 rubylibdir=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['libdir']])"`
Bram Moolenaard5a986f2020-12-06 21:11:31 +01002037 if test -f "$rubylibdir/$librubya" || expr "$librubyarg" : "-lruby"; then
Bram Moolenaarac499e32013-06-02 19:14:17 +02002038 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
2039 elif test "$librubyarg" = "libruby.a"; then
2040 dnl required on Mac OS 10.3 where libruby.a doesn't exist
2041 librubyarg="-lruby"
2042 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002043 fi
2044
2045 if test "X$librubyarg" != "X"; then
2046 RUBY_LIBS="$librubyarg $RUBY_LIBS"
2047 fi
Zdenek Dohnal1d822af2022-11-23 12:06:08 +00002048
2049 dnl Here the Ruby LDFLAGS used to be added to LDFLAGS, but that turns
2050 dnl out to cause trouble and was removed.
2051
Bram Moolenaar071d4272004-06-13 20:20:40 +00002052 RUBY_SRC="if_ruby.c"
2053 RUBY_OBJ="objects/if_ruby.o"
2054 RUBY_PRO="if_ruby.pro"
2055 AC_DEFINE(FEAT_RUBY)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002056 if test "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar92021622017-10-12 12:33:43 +02002057 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_ALIASES']].split[[0]]"`
Bram Moolenaar87ea64c2018-08-04 15:13:34 +02002058 if test -z "$libruby_soname"; then
2059 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_SO']]"`
2060 fi
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002061 AC_DEFINE(DYNAMIC_RUBY)
Bram Moolenaar41a41412020-01-07 21:32:19 +01002062 RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby_soname\\\" $RUBY_CFLAGS"
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002063 RUBY_LIBS=
2064 fi
Bram Moolenaar864a28b2020-12-28 21:36:56 +01002065 if test "X$CLANG_VERSION" != "X" -a "$rubyversion" -ge 30; then
2066 RUBY_CFLAGS="$RUBY_CFLAGS -fdeclspec"
2067 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002068 else
Bram Moolenaar165641d2010-02-17 16:23:09 +01002069 AC_MSG_RESULT(not found; disabling Ruby)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002070 fi
2071 else
K.Takata236ccbf2022-09-22 16:12:06 +01002072 AC_MSG_RESULT(too old; need Ruby version 1.9.1 or later)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002073 fi
2074 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01002075
2076 if test "$fail_if_missing" = "yes" -a -z "$RUBY_OBJ"; then
2077 AC_MSG_ERROR([could not configure Ruby])
2078 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002079fi
2080AC_SUBST(RUBY_SRC)
2081AC_SUBST(RUBY_OBJ)
2082AC_SUBST(RUBY_PRO)
2083AC_SUBST(RUBY_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00002084AC_SUBST(RUBY_CFLAGS_EXTRA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002085AC_SUBST(RUBY_LIBS)
2086
2087AC_MSG_CHECKING(--enable-cscope argument)
2088AC_ARG_ENABLE(cscope,
2089 [ --enable-cscope Include cscope interface.], ,
2090 [enable_cscope="no"])
2091AC_MSG_RESULT($enable_cscope)
2092if test "$enable_cscope" = "yes"; then
2093 AC_DEFINE(FEAT_CSCOPE)
2094fi
2095
Bram Moolenaar071d4272004-06-13 20:20:40 +00002096AC_MSG_CHECKING(--disable-netbeans argument)
2097AC_ARG_ENABLE(netbeans,
2098 [ --disable-netbeans Disable NetBeans integration support.],
2099 , [enable_netbeans="yes"])
2100if test "$enable_netbeans" = "yes"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00002101 if test "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +01002102 AC_MSG_RESULT([cannot use NetBeans with tiny features])
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002103 enable_netbeans="no"
2104 else
2105 AC_MSG_RESULT(no)
2106 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002107else
2108 AC_MSG_RESULT(yes)
2109fi
2110
2111AC_MSG_CHECKING(--disable-channel argument)
2112AC_ARG_ENABLE(channel,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002113 [ --disable-channel Disable process communication support.],
Bram Moolenaare0874f82016-01-24 20:36:41 +01002114 , [enable_channel="yes"])
2115if test "$enable_channel" = "yes"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00002116 if test "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +01002117 AC_MSG_RESULT([cannot use channels with tiny features])
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002118 enable_channel="no"
2119 else
2120 AC_MSG_RESULT(no)
2121 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002122else
2123 if test "$enable_netbeans" = "yes"; then
Bram Moolenaar16435482016-01-24 21:31:54 +01002124 AC_MSG_RESULT([yes, netbeans also disabled])
Bram Moolenaare0874f82016-01-24 20:36:41 +01002125 enable_netbeans="no"
2126 else
2127 AC_MSG_RESULT(yes)
2128 fi
2129fi
2130
Bram Moolenaar16435482016-01-24 21:31:54 +01002131if test "$enable_channel" = "yes"; then
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002132 dnl On Solaris we need the socket library, or on Haiku the network library.
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002133 if test "x$HAIKU" = "xyes"; then
2134 AC_CHECK_LIB(network, socket)
2135 else
2136 AC_CHECK_LIB(socket, socket)
2137 fi
2138
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002139 AC_CACHE_CHECK([whether compiling with IPv6 networking is possible], [vim_cv_ipv6_networking],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002140 [AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002141#include <stdio.h>
2142#include <stdlib.h>
2143#include <stdarg.h>
2144#include <fcntl.h>
2145#include <netdb.h>
2146#include <netinet/in.h>
2147#include <errno.h>
2148#include <sys/types.h>
2149#include <sys/socket.h>
2150 /* Check bitfields */
2151 struct nbbuf {
2152 unsigned int initDone:1;
2153 unsigned short signmaplen;
2154 };
2155 ], [
2156 /* Check creating a socket. */
2157 struct sockaddr_in server;
2158 struct addrinfo *res;
2159 (void)socket(AF_INET, SOCK_STREAM, 0);
2160 (void)htons(100);
2161 (void)getaddrinfo("microsoft.com", NULL, NULL, &res);
2162 if (errno == ECONNREFUSED)
2163 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
2164 (void)freeaddrinfo(res);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002165 ])],
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002166 [vim_cv_ipv6_networking="yes"],
2167 [vim_cv_ipv6_networking="no"])])
2168
2169 if test "x$vim_cv_ipv6_networking" = "xyes"; then
2170 AC_DEFINE(FEAT_IPV6)
Bram Moolenaarb6fb0512020-04-18 18:24:18 +02002171 AC_CHECK_FUNCS(inet_ntop)
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002172 else
2173 dnl On Solaris we need the nsl library.
2174 AC_CHECK_LIB(nsl, gethostbyname)
2175 AC_CACHE_CHECK([whether compiling with IPv4 networking is possible], [vim_cv_ipv4_networking],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002176 [AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00002177#include <stdio.h>
2178#include <stdlib.h>
2179#include <stdarg.h>
2180#include <fcntl.h>
2181#include <netdb.h>
2182#include <netinet/in.h>
2183#include <errno.h>
2184#include <sys/types.h>
2185#include <sys/socket.h>
2186 /* Check bitfields */
2187 struct nbbuf {
2188 unsigned int initDone:1;
Bram Moolenaar63de19e2016-12-09 20:11:26 +01002189 unsigned short signmaplen;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002190 };
2191 ], [
2192 /* Check creating a socket. */
2193 struct sockaddr_in server;
2194 (void)socket(AF_INET, SOCK_STREAM, 0);
2195 (void)htons(100);
2196 (void)gethostbyname("microsoft.com");
2197 if (errno == ECONNREFUSED)
2198 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002199 ])],
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002200 [vim_cv_ipv4_networking="yes"],
2201 [vim_cv_ipv4_networking="no"; enable_netbeans="no"; enable_channel="no"])])
2202 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002203fi
2204if test "$enable_netbeans" = "yes"; then
2205 AC_DEFINE(FEAT_NETBEANS_INTG)
2206 NETBEANS_SRC="netbeans.c"
2207 AC_SUBST(NETBEANS_SRC)
2208 NETBEANS_OBJ="objects/netbeans.o"
2209 AC_SUBST(NETBEANS_OBJ)
2210fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002211if test "$enable_channel" = "yes"; then
Bram Moolenaar509ce2a2016-03-11 22:52:15 +01002212 AC_DEFINE(FEAT_JOB_CHANNEL)
Bram Moolenaar8b5866d2020-09-05 15:48:51 +02002213 CHANNEL_SRC="job.c channel.c"
Bram Moolenaare0874f82016-01-24 20:36:41 +01002214 AC_SUBST(CHANNEL_SRC)
Bram Moolenaar8b5866d2020-09-05 15:48:51 +02002215 CHANNEL_OBJ="objects/job.o objects/channel.o"
Bram Moolenaare0874f82016-01-24 20:36:41 +01002216 AC_SUBST(CHANNEL_OBJ)
2217fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002218
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002219AC_MSG_CHECKING(--enable-terminal argument)
2220AC_ARG_ENABLE(terminal,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002221 [ --enable-terminal Enable terminal emulation support.],
Bram Moolenaaref839562017-10-28 20:28:23 +02002222 , [enable_terminal="auto"])
Bram Moolenaar595a4022017-09-03 19:15:57 +02002223if test "$enable_terminal" = "yes" || test "$enable_terminal" = "auto" -a "x$features" = "xhuge" ; then
Bram Moolenaar12471262022-01-18 11:11:25 +00002224 if test "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +01002225 AC_MSG_RESULT([cannot use terminal emulator with tiny features])
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002226 enable_terminal="no"
2227 else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002228 if test "$enable_terminal" = "auto"; then
2229 enable_terminal="yes"
2230 AC_MSG_RESULT(defaulting to yes)
2231 else
2232 AC_MSG_RESULT(yes)
2233 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002234 fi
2235else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002236 if test "$enable_terminal" = "auto"; then
2237 enable_terminal="no"
2238 AC_MSG_RESULT(defaulting to no)
2239 else
2240 AC_MSG_RESULT(no)
2241 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002242fi
Bram Moolenaar8b423282017-12-16 14:37:06 +01002243if test "$enable_terminal" = "yes" -a "$enable_channel" = "yes"; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002244 AC_DEFINE(FEAT_TERMINAL)
Bram Moolenaar93268052019-10-10 13:22:54 +02002245 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 +02002246 AC_SUBST(TERM_SRC)
Bram Moolenaar93268052019-10-10 13:22:54 +02002247 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 +02002248 AC_SUBST(TERM_OBJ)
Bram Moolenaar823edd12019-10-23 22:35:36 +02002249 TERM_TEST="test_libvterm"
2250 AC_SUBST(TERM_TEST)
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002251fi
2252
Bram Moolenaare42a6d22017-11-12 19:21:51 +01002253AC_MSG_CHECKING(--enable-autoservername argument)
2254AC_ARG_ENABLE(autoservername,
2255 [ --enable-autoservername Automatically define servername at vim startup.], ,
2256 [enable_autoservername="no"])
2257AC_MSG_RESULT($enable_autoservername)
2258if test "$enable_autoservername" = "yes"; then
2259 AC_DEFINE(FEAT_AUTOSERVERNAME)
2260fi
2261
Bram Moolenaar071d4272004-06-13 20:20:40 +00002262AC_MSG_CHECKING(--enable-multibyte argument)
2263AC_ARG_ENABLE(multibyte,
2264 [ --enable-multibyte Include multibyte editing support.], ,
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01002265 [enable_multibyte="yes"])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002266AC_MSG_RESULT($enable_multibyte)
Bram Moolenaar30276f22019-01-24 17:59:39 +01002267if test "$enable_multibyte" != "yes"; then
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01002268 AC_MSG_ERROR([The multi-byte feature can no longer be disabled. If you have
2269 a problem with this, discuss on the Vim mailing list.])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002270fi
2271
Martin Tournoij25f3a142022-10-08 19:26:41 +01002272dnl Right-to-Left language support for Vim will be included with huge features,
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002273dnl unless ENABLE_RIGHTLEFT is undefined.
2274AC_MSG_CHECKING(--disable-rightleft argument)
2275AC_ARG_ENABLE(rightleft,
2276 [ --disable-rightleft Do not include Right-to-Left language support.],
2277 , [enable_rightleft="yes"])
2278if test "$enable_rightleft" = "yes"; then
2279 AC_MSG_RESULT(no)
2280else
2281 AC_MSG_RESULT(yes)
2282 AC_DEFINE(DISABLE_RIGHTLEFT)
2283fi
2284
Martin Tournoij25f3a142022-10-08 19:26:41 +01002285dnl Arabic language support for Vim will be included with huge features,
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002286dnl unless ENABLE_ARABIC is undefined.
2287AC_MSG_CHECKING(--disable-arabic argument)
2288AC_ARG_ENABLE(arabic,
2289 [ --disable-arabic Do not include Arabic language support.],
2290 , [enable_arabic="yes"])
2291if test "$enable_arabic" = "yes"; then
2292 AC_MSG_RESULT(no)
2293else
2294 AC_MSG_RESULT(yes)
2295 AC_DEFINE(DISABLE_ARABIC)
2296fi
2297
Bram Moolenaar14184a32019-02-16 15:10:30 +01002298dnl Farsi language support has been removed, ignore --disable-farsi
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002299AC_ARG_ENABLE(farsi,
Bram Moolenaar14184a32019-02-16 15:10:30 +01002300 [ --disable-farsi Deprecated.],,)
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002301
Bram Moolenaar071d4272004-06-13 20:20:40 +00002302AC_MSG_CHECKING(--enable-xim argument)
2303AC_ARG_ENABLE(xim,
2304 [ --enable-xim Include XIM input support.],
2305 AC_MSG_RESULT($enable_xim),
2306 [enable_xim="auto"; AC_MSG_RESULT(defaulting to auto)])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002307
2308AC_MSG_CHECKING(--enable-fontset argument)
2309AC_ARG_ENABLE(fontset,
2310 [ --enable-fontset Include X fontset output support.], ,
2311 [enable_fontset="no"])
2312AC_MSG_RESULT($enable_fontset)
2313dnl defining FEAT_XFONTSET is delayed, so that it can be disabled for no GUI
2314
2315test -z "$with_x" && with_x=yes
Bram Moolenaard0573012017-10-28 21:11:06 +02002316test "${enable_gui-yes}" != no -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && with_x=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002317if test "$with_x" = no; then
2318 AC_MSG_RESULT(defaulting to: don't HAVE_X11)
2319else
2320 dnl Do this check early, so that its failure can override user requests.
2321
2322 AC_PATH_PROG(xmkmfpath, xmkmf)
2323
2324 AC_PATH_XTRA
2325
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002326 dnl On z/OS Unix the X libraries are DLLs. To use them the code must
Bram Moolenaar071d4272004-06-13 20:20:40 +00002327 dnl be compiled with a special option.
2328 dnl Also add SM, ICE and Xmu to X_EXTRA_LIBS.
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002329 if test "$zOSUnix" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002330 CFLAGS="$CFLAGS -W c,dll"
2331 LDFLAGS="$LDFLAGS -W l,dll"
2332 X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE -lXmu"
2333 fi
2334
2335 dnl On my HPUX system the X include dir is found, but the lib dir not.
Bram Moolenaar70778922020-02-05 20:44:24 +01002336 dnl This is a desperate try to fix this.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002337
2338 if test -d "$x_includes" && test ! -d "$x_libraries"; then
2339 x_libraries=`echo "$x_includes" | sed s/include/lib/`
2340 AC_MSG_RESULT(Corrected X libraries to $x_libraries)
2341 X_LIBS="$X_LIBS -L$x_libraries"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00002342 if test "$vim_cv_uname_output" = SunOS &&
2343 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002344 X_LIBS="$X_LIBS -R $x_libraries"
2345 fi
2346 fi
2347
2348 if test -d "$x_libraries" && test ! -d "$x_includes"; then
2349 x_includes=`echo "$x_libraries" | sed s/lib/include/`
2350 AC_MSG_RESULT(Corrected X includes to $x_includes)
2351 X_CFLAGS="$X_CFLAGS -I$x_includes"
2352 fi
2353
2354 dnl Remove "-I/usr/include " from X_CFLAGS, should not be needed.
2355 X_CFLAGS="`echo $X_CFLAGS\ | sed 's%-I/usr/include %%'`"
2356 dnl Remove "-L/usr/lib " from X_LIBS, should not be needed.
2357 X_LIBS="`echo $X_LIBS\ | sed 's%-L/usr/lib %%'`"
2358 dnl Same for "-R/usr/lib ".
2359 X_LIBS="`echo $X_LIBS\ | sed -e 's%-R/usr/lib %%' -e 's%-R /usr/lib %%'`"
2360
2361
2362 dnl Check if the X11 header files are correctly installed. On some systems
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002363 dnl Xlib.h includes files that don't exist. On some systems X11/Intrinsic.h
2364 dnl is missing.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002365 AC_MSG_CHECKING(if X11 header files can be found)
2366 cflags_save=$CFLAGS
2367 CFLAGS="$CFLAGS $X_CFLAGS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002368 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <X11/Xlib.h>
2369#include <X11/Intrinsic.h>], )],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002370 AC_MSG_RESULT(yes),
2371 AC_MSG_RESULT(no); no_x=yes)
2372 CFLAGS=$cflags_save
2373
2374 if test "${no_x-no}" = yes; then
2375 with_x=no
2376 else
2377 AC_DEFINE(HAVE_X11)
2378 X_LIB="-lXt -lX11";
2379 AC_SUBST(X_LIB)
2380
2381 ac_save_LDFLAGS="$LDFLAGS"
2382 LDFLAGS="-L$x_libraries $LDFLAGS"
2383
2384 dnl Check for -lXdmcp (needed on SunOS 4.1.4)
2385 dnl For HP-UX 10.20 it must be before -lSM -lICE
2386 AC_CHECK_LIB(Xdmcp, _XdmcpAuthDoIt, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lXdmcp"],,
2387 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXdmcp])
2388
2389 dnl Some systems need -lnsl -lsocket when testing for ICE.
2390 dnl The check above doesn't do this, try here (again). Also needed to get
2391 dnl them after Xdmcp. link.sh will remove them when not needed.
2392 dnl Check for other function than above to avoid the cached value
2393 AC_CHECK_LIB(ICE, IceOpenConnection,
2394 [X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE"],, [$X_EXTRA_LIBS])
2395
2396 dnl Check for -lXpm (needed for some versions of Motif)
2397 LDFLAGS="$X_LIBS $ac_save_LDFLAGS"
2398 AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [X_PRE_LIBS="$X_PRE_LIBS -lXpm"],,
2399 [-lXt $X_PRE_LIBS -lXpm -lX11 $X_EXTRA_LIBS])
2400
2401 dnl Check that the X11 header files don't use implicit declarations
2402 AC_MSG_CHECKING(if X11 header files implicitly declare return values)
2403 cflags_save=$CFLAGS
Bram Moolenaard1864592013-05-04 04:40:15 +02002404 dnl -Werror is GCC only, others like Solaris Studio might not like it
2405 if test "$GCC" = yes; then
2406 CFLAGS="$CFLAGS $X_CFLAGS -Werror"
2407 else
2408 CFLAGS="$CFLAGS $X_CFLAGS"
2409 fi
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002410 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <X11/Xlib.h>], )],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002411 AC_MSG_RESULT(no),
2412 CFLAGS="$CFLAGS -Wno-implicit-int"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002413 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <X11/Xlib.h>], )],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002414 AC_MSG_RESULT(yes); cflags_save="$cflags_save -Wno-implicit-int",
2415 AC_MSG_RESULT(test failed)
2416 )
2417 )
2418 CFLAGS=$cflags_save
2419
2420 LDFLAGS="$ac_save_LDFLAGS"
2421
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002422 AC_MSG_CHECKING(size of wchar_t is 2 bytes)
2423 AC_CACHE_VAL(ac_cv_small_wchar_t,
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002424 [AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002425#include <X11/Xlib.h>
2426#if STDC_HEADERS
2427# include <stdlib.h>
2428# include <stddef.h>
2429#endif
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01002430 int main()
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002431 {
2432 if (sizeof(wchar_t) <= 2)
2433 exit(1);
2434 exit(0);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002435 }])],
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002436 ac_cv_small_wchar_t="no",
2437 ac_cv_small_wchar_t="yes",
2438 AC_MSG_ERROR(failed to compile test program))])
2439 AC_MSG_RESULT($ac_cv_small_wchar_t)
2440 if test "x$ac_cv_small_wchar_t" = "xyes" ; then
2441 AC_DEFINE(SMALL_WCHAR_T)
2442 fi
2443
Bram Moolenaar071d4272004-06-13 20:20:40 +00002444 fi
2445fi
2446
Bram Moolenaard2a05492018-07-27 22:35:15 +02002447dnl Check if --with-x was given but it doesn't work.
2448if test "x$with_x" = xno -a "x$with_x_arg" = xyes; then
2449 AC_MSG_ERROR([could not configure X])
2450fi
2451
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002452test "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 +00002453
2454AC_MSG_CHECKING(--enable-gui argument)
2455AC_ARG_ENABLE(gui,
Bram Moolenaarf52fac22022-03-11 16:01:26 +00002456 [ --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 +00002457
2458dnl Canonicalize the --enable-gui= argument so that it can be easily compared.
2459dnl Do not use character classes for portability with old tools.
2460enable_gui_canon=`echo "_$enable_gui" | \
2461 sed 's/[[ _+-]]//g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
2462
2463dnl Skip everything by default.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002464SKIP_GTK2=YES
Bram Moolenaar1858a842016-02-23 22:30:31 +01002465SKIP_GTK3=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002466SKIP_GNOME=YES
2467SKIP_MOTIF=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002468SKIP_PHOTON=YES
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002469SKIP_HAIKU=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002470GUITYPE=NONE
2471
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002472if test "x$HAIKU" = "xyes"; then
2473 SKIP_HAIKU=
2474 case "$enable_gui_canon" in
2475 no) AC_MSG_RESULT(no GUI support)
2476 SKIP_HAIKU=YES ;;
2477 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
2478 auto) AC_MSG_RESULT(auto - automatic GUI support) ;;
2479 haiku) AC_MSG_RESULT(Haiku GUI support) ;;
2480 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2481 SKIP_HAIKU=YES ;;
2482 esac
2483elif test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002484 SKIP_PHOTON=
2485 case "$enable_gui_canon" in
2486 no) AC_MSG_RESULT(no GUI support)
2487 SKIP_PHOTON=YES ;;
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002488 yes|""|auto) AC_MSG_RESULT(automatic GUI support)
2489 gui_auto=yes ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002490 photon) AC_MSG_RESULT(Photon GUI support) ;;
2491 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2492 SKIP_PHOTON=YES ;;
2493 esac
2494
Bram Moolenaar040f9752020-08-11 23:08:48 +02002495elif test "x$MACOS_X" = "xyes" -a "x$with_x" = "xno" ; then
2496 case "$enable_gui_canon" in
2497 no) AC_MSG_RESULT(no GUI support) ;;
2498 yes|"") AC_MSG_RESULT(yes - automatic GUI support)
2499 gui_auto=yes ;;
2500 auto) AC_MSG_RESULT(auto - disable GUI support for Mac OS) ;;
Bram Moolenaarbe7529e2020-08-13 21:05:39 +02002501 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
Bram Moolenaar040f9752020-08-11 23:08:48 +02002502 esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00002503else
2504
Bram Moolenaar071d4272004-06-13 20:20:40 +00002505 case "$enable_gui_canon" in
2506 no|none) AC_MSG_RESULT(no GUI support) ;;
2507 yes|""|auto) AC_MSG_RESULT(yes/auto - automatic GUI support)
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002508 gui_auto=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002509 SKIP_GTK2=
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002510 SKIP_GTK3=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002511 SKIP_GNOME=
Bram Moolenaarf52fac22022-03-11 16:01:26 +00002512 SKIP_MOTIF=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002513 gtk2) AC_MSG_RESULT(GTK+ 2.x GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002514 SKIP_GTK2=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002515 gnome2) AC_MSG_RESULT(GNOME 2.x GUI support)
2516 SKIP_GNOME=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002517 SKIP_GTK2=;;
Bram Moolenaar98921892016-02-23 17:14:37 +01002518 gtk3) AC_MSG_RESULT(GTK+ 3.x GUI support)
2519 SKIP_GTK3=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002520 motif) AC_MSG_RESULT(Motif GUI support)
2521 SKIP_MOTIF=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002522 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
2523 esac
2524
2525fi
2526
Bram Moolenaar071d4272004-06-13 20:20:40 +00002527if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \
2528 -a "$enable_gui_canon" != "gnome2"; then
2529 AC_MSG_CHECKING(whether or not to look for GTK+ 2)
2530 AC_ARG_ENABLE(gtk2-check,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002531 [ --enable-gtk2-check If auto-select GUI, check for GTK+ 2 [default=yes]],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002532 , enable_gtk2_check="yes")
2533 AC_MSG_RESULT($enable_gtk2_check)
2534 if test "x$enable_gtk2_check" = "xno"; then
2535 SKIP_GTK2=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002536 SKIP_GNOME=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002537 fi
2538fi
2539
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002540if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002541 AC_MSG_CHECKING(whether or not to look for GNOME)
2542 AC_ARG_ENABLE(gnome-check,
2543 [ --enable-gnome-check If GTK GUI, check for GNOME [default=no]],
2544 , enable_gnome_check="no")
2545 AC_MSG_RESULT($enable_gnome_check)
2546 if test "x$enable_gnome_check" = "xno"; then
2547 SKIP_GNOME=YES
2548 fi
2549fi
2550
Bram Moolenaar98921892016-02-23 17:14:37 +01002551if test "x$SKIP_GTK3" != "xYES" -a "$enable_gui_canon" != "gtk3"; then
2552 AC_MSG_CHECKING(whether or not to look for GTK+ 3)
2553 AC_ARG_ENABLE(gtk3-check,
2554 [ --enable-gtk3-check If auto-select GUI, check for GTK+ 3 [default=yes]],
2555 , enable_gtk3_check="yes")
2556 AC_MSG_RESULT($enable_gtk3_check)
2557 if test "x$enable_gtk3_check" = "xno"; then
2558 SKIP_GTK3=YES
2559 fi
2560fi
2561
Bram Moolenaar071d4272004-06-13 20:20:40 +00002562if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then
2563 AC_MSG_CHECKING(whether or not to look for Motif)
2564 AC_ARG_ENABLE(motif-check,
2565 [ --enable-motif-check If auto-select GUI, check for Motif [default=yes]],
2566 , enable_motif_check="yes")
2567 AC_MSG_RESULT($enable_motif_check)
2568 if test "x$enable_motif_check" = "xno"; then
2569 SKIP_MOTIF=YES
2570 fi
2571fi
2572
Bram Moolenaar071d4272004-06-13 20:20:40 +00002573dnl define an autoconf function to check for a specified version of GTK, and
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002574dnl try to compile/link a GTK program.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002575dnl
2576dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002577dnl Test for GTK, and define GTK_CFLAGS, GTK_LIBDIR and GTK_LIBS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002578dnl
2579AC_DEFUN(AM_PATH_GTK,
2580[
2581 if test "X$GTK_CONFIG" != "Xno" -o "X$PKG_CONFIG" != "Xno"; then
2582 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00002583 no_gtk=""
2584 if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2585 && $PKG_CONFIG --exists gtk+-2.0; then
2586 {
Bram Moolenaar98921892016-02-23 17:14:37 +01002587 min_gtk_version=ifelse([$1], ,2.2.0,$1)
2588 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002589 dnl We should be using PKG_CHECK_MODULES() instead of this hack.
2590 dnl But I guess the dependency on pkgconfig.m4 is not wanted or
2591 dnl something like that.
2592 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0`
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002593 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-2.0`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002594 GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0`
2595 gtk_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2596 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2597 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2598 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2599 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2600 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2601 }
Bram Moolenaar98921892016-02-23 17:14:37 +01002602 elif (test "X$SKIP_GTK3" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2603 && $PKG_CONFIG --exists gtk+-3.0; then
2604 {
2605 min_gtk_version=ifelse([$1], ,3.0.0,$1)
2606 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
2607
2608 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-3.0`
2609 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-3.0`
2610 GTK_LIBS=`$PKG_CONFIG --libs gtk+-3.0`
2611 gtk_major_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2612 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2613 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2614 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2615 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2616 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2617 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002618 else
Bram Moolenaar67876de2021-01-12 20:51:24 +01002619 dnl Put some text before the "no" to hint at installing the gtk-dev
2620 dnl packages.
2621 AC_MSG_CHECKING(for GTK -dev package)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002622 no_gtk=yes
2623 fi
2624
2625 if test "x$enable_gtktest" = "xyes" -a "x$no_gtk" = "x"; then
2626 {
2627 ac_save_CFLAGS="$CFLAGS"
2628 ac_save_LIBS="$LIBS"
2629 CFLAGS="$CFLAGS $GTK_CFLAGS"
2630 LIBS="$LIBS $GTK_LIBS"
2631
2632 dnl
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002633 dnl Now check if the installed GTK is sufficiently new.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002634 dnl
2635 rm -f conf.gtktest
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002636 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar071d4272004-06-13 20:20:40 +00002637#include <gtk/gtk.h>
2638#include <stdio.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00002639#if STDC_HEADERS
2640# include <stdlib.h>
2641# include <stddef.h>
2642#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002643
2644int
2645main ()
2646{
2647int major, minor, micro;
2648char *tmp_version;
2649
2650system ("touch conf.gtktest");
2651
2652/* HP/UX 9 (%@#!) writes to sscanf strings */
2653tmp_version = g_strdup("$min_gtk_version");
2654if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
2655 printf("%s, bad version string\n", "$min_gtk_version");
2656 exit(1);
2657 }
2658
2659if ((gtk_major_version > major) ||
2660 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
2661 ((gtk_major_version == major) && (gtk_minor_version == minor) &&
2662 (gtk_micro_version >= micro)))
2663{
2664 return 0;
2665}
2666return 1;
2667}
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002668])],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002669 CFLAGS="$ac_save_CFLAGS"
2670 LIBS="$ac_save_LIBS"
2671 }
2672 fi
2673 if test "x$no_gtk" = x ; then
2674 if test "x$enable_gtktest" = "xyes"; then
2675 AC_MSG_RESULT(yes; found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2676 else
2677 AC_MSG_RESULT(found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2678 fi
2679 ifelse([$2], , :, [$2])
2680 else
2681 {
2682 AC_MSG_RESULT(no)
2683 GTK_CFLAGS=""
2684 GTK_LIBS=""
2685 ifelse([$3], , :, [$3])
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002686 if test "$fail_if_missing" = "yes" -a "X$gui_auto" != "Xyes"; then
2687 AC_MSG_ERROR([could not configure GTK])
2688 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002689 }
2690 fi
2691 }
2692 else
2693 GTK_CFLAGS=""
2694 GTK_LIBS=""
2695 ifelse([$3], , :, [$3])
2696 fi
2697 AC_SUBST(GTK_CFLAGS)
2698 AC_SUBST(GTK_LIBS)
2699 rm -f conf.gtktest
2700])
2701
2702dnl ---------------------------------------------------------------------------
2703dnl gnome
2704dnl ---------------------------------------------------------------------------
2705AC_DEFUN([GNOME_INIT_HOOK],
2706[
2707 AC_SUBST(GNOME_LIBS)
2708 AC_SUBST(GNOME_LIBDIR)
2709 AC_SUBST(GNOME_INCLUDEDIR)
2710
2711 AC_ARG_WITH(gnome-includes,
2712 [ --with-gnome-includes=DIR Specify location of GNOME headers],
2713 [CFLAGS="$CFLAGS -I$withval"]
2714 )
2715
2716 AC_ARG_WITH(gnome-libs,
2717 [ --with-gnome-libs=DIR Specify location of GNOME libs],
2718 [LDFLAGS="$LDFLAGS -L$withval" gnome_prefix=$withval]
2719 )
2720
2721 AC_ARG_WITH(gnome,
2722 [ --with-gnome Specify prefix for GNOME files],
2723 if test x$withval = xyes; then
2724 want_gnome=yes
2725 ifelse([$1], [], :, [$1])
2726 else
2727 if test "x$withval" = xno; then
2728 want_gnome=no
2729 else
2730 want_gnome=yes
2731 LDFLAGS="$LDFLAGS -L$withval/lib"
2732 CFLAGS="$CFLAGS -I$withval/include"
2733 gnome_prefix=$withval/lib
2734 fi
2735 fi,
2736 want_gnome=yes)
2737
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002738 if test "x$want_gnome" = xyes; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002739 {
2740 AC_MSG_CHECKING(for libgnomeui-2.0)
2741 if $PKG_CONFIG --exists libgnomeui-2.0; then
2742 AC_MSG_RESULT(yes)
2743 GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0`
2744 GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0`
2745 GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0`
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002746
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002747 dnl On FreeBSD we need -pthread but pkg-config doesn't include it.
2748 dnl This might not be the right way but it works for me...
2749 AC_MSG_CHECKING(for FreeBSD)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00002750 if test "$vim_cv_uname_output" = FreeBSD; then
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002751 AC_MSG_RESULT(yes, adding -pthread)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002752 GNOME_INCLUDEDIR="$GNOME_INCLUDEDIR -D_THREAD_SAFE"
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002753 GNOME_LIBS="$GNOME_LIBS -pthread"
2754 else
2755 AC_MSG_RESULT(no)
2756 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002757 $1
2758 else
2759 AC_MSG_RESULT(not found)
2760 if test "x$2" = xfail; then
2761 AC_MSG_ERROR(Could not find libgnomeui-2.0 via pkg-config)
2762 fi
2763 fi
2764 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002765 fi
2766])
2767
2768AC_DEFUN([GNOME_INIT],[
2769 GNOME_INIT_HOOK([],fail)
2770])
2771
Bram Moolenaar427f5b62019-06-09 13:43:51 +02002772if test "X$PKG_CONFIG" = "X"; then
2773 AC_PATH_TOOL(PKG_CONFIG, pkg-config, no)
2774fi
2775
Bram Moolenaar071d4272004-06-13 20:20:40 +00002776
2777dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002778dnl Check for GTK2. If it fails, then continue on for Motif as before...
Bram Moolenaar071d4272004-06-13 20:20:40 +00002779dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002780if test -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002781
2782 AC_MSG_CHECKING(--disable-gtktest argument)
2783 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2784 , enable_gtktest=yes)
2785 if test "x$enable_gtktest" = "xyes" ; then
2786 AC_MSG_RESULT(gtk test enabled)
2787 else
2788 AC_MSG_RESULT(gtk test disabled)
2789 fi
2790
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002791 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002792 dnl First try finding version 2.2.0 or later. The 2.0.x series has
2793 dnl problems (bold fonts, --remote doesn't work).
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002794 dnl Disable checking for GTK3 here, otherwise it's found when GTK2 is not
2795 dnl found.
2796 save_skip_gtk3=$SKIP_GTK3
2797 SKIP_GTK3=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002798 AM_PATH_GTK(2.2.0,
2799 [GUI_LIB_LOC="$GTK_LIBDIR"
2800 GTK_LIBNAME="$GTK_LIBS"
2801 GUI_INC_LOC="$GTK_CFLAGS"], )
2802 if test "x$GTK_CFLAGS" != "x"; then
Bram Moolenaar98921892016-02-23 17:14:37 +01002803 SKIP_GTK3=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002804 SKIP_MOTIF=YES
2805 GUITYPE=GTK
2806 AC_SUBST(GTK_LIBNAME)
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002807 else
2808 SKIP_GTK3=$save_skip_gtk3
Bram Moolenaar071d4272004-06-13 20:20:40 +00002809 fi
2810 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002811 if test "x$GUITYPE" = "xGTK"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002812 dnl
2813 dnl if GTK exists, then check for GNOME.
2814 dnl
2815 if test -z "$SKIP_GNOME"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002816 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002817 GNOME_INIT_HOOK([have_gnome=yes])
2818 if test "x$have_gnome" = xyes ; then
2819 AC_DEFINE(FEAT_GUI_GNOME)
2820 GUI_INC_LOC="$GUI_INC_LOC $GNOME_INCLUDEDIR"
2821 GTK_LIBNAME="$GTK_LIBNAME $GNOME_LIBDIR $GNOME_LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002822 fi
2823 }
2824 fi
2825 fi
2826fi
2827
Bram Moolenaar98921892016-02-23 17:14:37 +01002828
2829dnl ---------------------------------------------------------------------------
2830dnl Check for GTK3.
2831dnl ---------------------------------------------------------------------------
2832if test -z "$SKIP_GTK3"; then
2833
2834 AC_MSG_CHECKING(--disable-gtktest argument)
2835 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2836 , enable_gtktest=yes)
2837 if test "x$enable_gtktest" = "xyes" ; then
2838 AC_MSG_RESULT(gtk test enabled)
2839 else
2840 AC_MSG_RESULT(gtk test disabled)
2841 fi
2842
Bram Moolenaar98921892016-02-23 17:14:37 +01002843 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002844 save_skip_gtk2=$SKIP_GTK2
2845 SKIP_GTK2=YES
Bram Moolenaar98921892016-02-23 17:14:37 +01002846 AM_PATH_GTK(3.0.0,
2847 [GUI_LIB_LOC="$GTK_LIBDIR"
2848 GTK_LIBNAME="$GTK_LIBS"
2849 GUI_INC_LOC="$GTK_CFLAGS"], )
2850 if test "x$GTK_CFLAGS" != "x"; then
2851 SKIP_GTK2=YES
2852 SKIP_GNOME=YES
Bram Moolenaar98921892016-02-23 17:14:37 +01002853 SKIP_MOTIF=YES
2854 GUITYPE=GTK
2855 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar98921892016-02-23 17:14:37 +01002856 AC_DEFINE(USE_GTK3)
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002857 else
2858 SKIP_GTK2=$save_skip_gtk2
Bram Moolenaar98921892016-02-23 17:14:37 +01002859 fi
2860 fi
2861fi
2862
Bram Moolenaard2e03f02016-01-02 22:46:36 +01002863dnl Check the version of Gdk-Pixbuf. If the version is 2.31 or later and
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002864dnl glib-compile-resources is found in PATH, use GResource.
2865if test "x$GUITYPE" = "xGTK"; then
2866 AC_MSG_CHECKING([version of Gdk-Pixbuf])
2867 gdk_pixbuf_version=`$PKG_CONFIG --modversion gdk-pixbuf-2.0`
2868 if test "x$gdk_pixbuf_version" != x ; then
2869 gdk_pixbuf_version_minor=`echo $gdk_pixbuf_version | \
2870 sed -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/'`
2871 if test "x$gdk_pixbuf_version_minor" != x -a \
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002872 $gdk_pixbuf_version_minor -ge 31 ; then
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002873 AC_MSG_RESULT([OK.])
2874 AC_PATH_PROG(GLIB_COMPILE_RESOURCES,[glib-compile-resources],no)
2875 AC_MSG_CHECKING([glib-compile-resources])
2876 if test "x$GLIB_COMPILE_RESOURCES" = xno ; then
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002877 GLIB_COMPILE_RESOURCES=""
2878 AC_MSG_RESULT([cannot be found in PATH.])
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002879 else
2880 AC_MSG_RESULT([usable.])
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002881 AC_DEFINE(USE_GRESOURCE)
2882 GRESOURCE_SRC="auto/gui_gtk_gresources.c"
2883 GRESOURCE_OBJ="objects/gui_gtk_gresources.o"
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002884 fi
2885 else
2886 AC_MSG_RESULT([not usable.])
2887 fi
2888 else
2889 AC_MSG_RESULT([cannot obtain from pkg_config.])
2890 fi
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002891
2892 AC_MSG_CHECKING([--disable-icon-cache-update argument])
2893 AC_ARG_ENABLE(icon_cache_update,
2894 [ --disable-icon-cache-update update disabled],
2895 [],
2896 [enable_icon_cache_update="yes"])
2897 if test "$enable_icon_cache_update" = "yes"; then
2898 AC_MSG_RESULT([not set])
2899 AC_PATH_PROG(GTK_UPDATE_ICON_CACHE,[gtk-update-icon-cache],no)
2900 if test "x$GTK_UPDATE_ICON_CACHE" = "xno" ; then
2901 AC_MSG_RESULT([not found in PATH.])
2902 fi
2903 else
2904 AC_MSG_RESULT([update disabled])
2905 fi
2906
2907 AC_MSG_CHECKING([--disable-desktop-database-update argument])
2908 AC_ARG_ENABLE(desktop_database_update,
2909 [ --disable-desktop-database-update update disabled],
2910 [],
2911 [enable_desktop_database_update="yes"])
2912 if test "$enable_desktop_database_update" = "yes"; then
2913 AC_MSG_RESULT([not set])
2914 AC_PATH_PROG(UPDATE_DESKTOP_DATABASE,[update-desktop-database],no)
2915 if test "x$UPDATE_DESKTOP_DATABASE" = "xno" ; then
2916 AC_MSG_RESULT([not found in PATH.])
2917 fi
2918 else
2919 AC_MSG_RESULT([update disabled])
2920 fi
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002921fi
2922AC_SUBST(GLIB_COMPILE_RESOURCES)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002923AC_SUBST(GRESOURCE_SRC)
2924AC_SUBST(GRESOURCE_OBJ)
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002925AC_SUBST(GTK_UPDATE_ICON_CACHE)
2926AC_SUBST(UPDATE_DESKTOP_DATABASE)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002927
Bram Moolenaar071d4272004-06-13 20:20:40 +00002928dnl Check for Motif include files location.
2929dnl The LAST one found is used, this makes the highest version to be used,
2930dnl e.g. when Motif1.2 and Motif2.0 are both present.
2931
2932if test -z "$SKIP_MOTIF"; then
2933 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"
2934 dnl Remove "-I" from before $GUI_INC_LOC if it's there
2935 GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`"
2936
2937 AC_MSG_CHECKING(for location of Motif GUI includes)
2938 gui_includes="`echo $x_includes|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC"
2939 GUI_INC_LOC=
2940 for try in $gui_includes; do
2941 if test -f "$try/Xm/Xm.h"; then
2942 GUI_INC_LOC=$try
2943 fi
2944 done
2945 if test -n "$GUI_INC_LOC"; then
2946 if test "$GUI_INC_LOC" = /usr/include; then
2947 GUI_INC_LOC=
2948 AC_MSG_RESULT(in default path)
2949 else
2950 AC_MSG_RESULT($GUI_INC_LOC)
2951 fi
2952 else
2953 AC_MSG_RESULT(<not found>)
2954 SKIP_MOTIF=YES
2955 fi
2956fi
2957
2958dnl Check for Motif library files location. In the same order as the include
2959dnl files, to avoid a mixup if several versions are present
2960
2961if test -z "$SKIP_MOTIF"; then
2962 AC_MSG_CHECKING(--with-motif-lib argument)
2963 AC_ARG_WITH(motif-lib,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002964 [ --with-motif-lib=STRING Library for Motif ],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002965 [ MOTIF_LIBNAME="${withval}" ] )
2966
2967 if test -n "$MOTIF_LIBNAME"; then
2968 AC_MSG_RESULT($MOTIF_LIBNAME)
2969 GUI_LIB_LOC=
2970 else
2971 AC_MSG_RESULT(no)
2972
2973 dnl Remove "-L" from before $GUI_LIB_LOC if it's there
2974 GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
2975
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002976 dnl Ubuntu has libXm.so in /usr/lib/i386-linux-gnu and elsewhere. The
2977 dnl linker will figure out which one to use, we only check if one exists.
Kelvin Leeb4716902022-04-04 17:20:01 +01002978 dnl Cygwin uses the .dll.a extension.
Bram Moolenaar01967f52023-04-12 16:24:03 +01002979 dnl OpenSUSE appears to use /usr/lib64.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002980 AC_MSG_CHECKING(for location of Motif GUI libs)
Bram Moolenaar01967f52023-04-12 16:24:03 +01002981 gui_libs="`echo $x_libraries|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/lib/g` /usr/lib64 /usr/lib/i386-linux-gnu /usr/lib/x86_64-linux-gnu `echo "$GUI_INC_LOC" | sed s/include/lib/` $GUI_LIB_LOC"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002982 GUI_LIB_LOC=
2983 for try in $gui_libs; do
Kelvin Leeb4716902022-04-04 17:20:01 +01002984 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 +00002985 if test -f "$libtry"; then
2986 GUI_LIB_LOC=$try
2987 fi
2988 done
2989 done
2990 if test -n "$GUI_LIB_LOC"; then
Bram Moolenaar01967f52023-04-12 16:24:03 +01002991 dnl Remove /usr/lib, it causes trouble on some systems.
2992 dnl For consistency also remove other standard lib directories.
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002993 if test "$GUI_LIB_LOC" = /usr/lib \
Bram Moolenaar01967f52023-04-12 16:24:03 +01002994 -o "$GUI_LIB_LOC" = /usr/lib64 \
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002995 -o "$GUI_LIB_LOC" = /usr/lib/i386-linux-gnu \
2996 -o "$GUI_LIB_LOC" = /usr/lib/x86_64-linux-gnu; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002997 GUI_LIB_LOC=
2998 AC_MSG_RESULT(in default path)
2999 else
3000 if test -n "$GUI_LIB_LOC"; then
3001 AC_MSG_RESULT($GUI_LIB_LOC)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00003002 if test "$vim_cv_uname_output" = SunOS &&
3003 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003004 GUI_LIB_LOC="$GUI_LIB_LOC -R $GUI_LIB_LOC"
3005 fi
3006 fi
3007 fi
3008 MOTIF_LIBNAME=-lXm
3009 else
3010 AC_MSG_RESULT(<not found>)
3011 SKIP_MOTIF=YES
3012 fi
3013 fi
3014fi
3015
3016if test -z "$SKIP_MOTIF"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003017 GUITYPE=MOTIF
3018 AC_SUBST(MOTIF_LIBNAME)
3019fi
3020
Bram Moolenaare2adcf32022-03-12 11:57:25 +00003021if test -z "$SKIP_MOTIF"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003022 dnl Prepend -I and -L to $GUI_INC_LOC and $GUI_LIB_LOC if not empty
3023 dnl Avoid adding it when it twice
3024 if test -n "$GUI_INC_LOC"; then
3025 GUI_INC_LOC=-I"`echo $GUI_INC_LOC|sed 's%-I%%'`"
3026 fi
3027 if test -n "$GUI_LIB_LOC"; then
3028 GUI_LIB_LOC=-L"`echo $GUI_LIB_LOC|sed 's%-L%%'`"
3029 fi
3030
3031 dnl Check for -lXext and then for -lXmu
3032 ldflags_save=$LDFLAGS
3033 LDFLAGS="$X_LIBS $LDFLAGS"
3034 AC_CHECK_LIB(Xext, XShapeQueryExtension, [GUI_X_LIBS="-lXext"],,
3035 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3036 dnl For Solaris we need -lw and -ldl before linking with -lXmu works.
3037 AC_CHECK_LIB(w, wslen, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lw"],,
3038 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3039 AC_CHECK_LIB(dl, dlsym, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldl"],,
3040 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3041 AC_CHECK_LIB(Xmu, XmuCreateStippledPixmap, [GUI_X_LIBS="-lXmu $GUI_X_LIBS"],,
3042 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3043 if test -z "$SKIP_MOTIF"; then
3044 AC_CHECK_LIB(Xp, XpEndJob, [GUI_X_LIBS="-lXp $GUI_X_LIBS"],,
3045 [$GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3046 fi
3047 LDFLAGS=$ldflags_save
3048
3049 dnl Execute xmkmf to figure out if -DNARROWPROTO is needed.
3050 AC_MSG_CHECKING(for extra X11 defines)
3051 NARROW_PROTO=
3052 rm -fr conftestdir
3053 if mkdir conftestdir; then
3054 cd conftestdir
3055 cat > Imakefile <<'EOF'
3056acfindx:
3057 @echo 'NARROW_PROTO="${PROTO_DEFINES}"'
3058EOF
3059 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
3060 eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
3061 fi
3062 cd ..
3063 rm -fr conftestdir
3064 fi
3065 if test -z "$NARROW_PROTO"; then
3066 AC_MSG_RESULT(no)
3067 else
3068 AC_MSG_RESULT($NARROW_PROTO)
3069 fi
3070 AC_SUBST(NARROW_PROTO)
3071fi
3072
3073dnl Look for XSMP support - but don't necessarily restrict it to X11 GUIs
3074dnl use the X11 include path
3075if test "$enable_xsmp" = "yes"; then
3076 cppflags_save=$CPPFLAGS
3077 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3078 AC_CHECK_HEADERS(X11/SM/SMlib.h)
3079 CPPFLAGS=$cppflags_save
3080fi
3081
3082
Bram Moolenaarf52fac22022-03-11 16:01:26 +00003083if test -z "$SKIP_MOTIF" -o -z "$SKIP_GTK2" -o -z "$SKIP_GTK3"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003084 dnl Check for X11/xpm.h and X11/Sunkeysym.h with the GUI include path
3085 cppflags_save=$CPPFLAGS
3086 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3087 AC_CHECK_HEADERS(X11/xpm.h X11/Sunkeysym.h)
3088
3089 dnl automatically disable XIM when XIMtext isn't in X11/Xlib.h
3090 if test ! "$enable_xim" = "no"; then
3091 AC_MSG_CHECKING(for XIMText in X11/Xlib.h)
3092 AC_EGREP_CPP(XIMText, [#include <X11/Xlib.h>],
3093 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +02003094 AC_MSG_RESULT(no; xim has been disabled); enable_xim="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00003095 fi
3096 CPPFLAGS=$cppflags_save
3097
Bram Moolenaar54612582019-11-21 17:13:31 +01003098 dnl automatically enable XIM in the GUI
3099 if test "$enable_xim" = "auto" -a "x$GUITYPE" != "xNONE" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003100 AC_MSG_RESULT(X GUI selected; xim has been enabled)
3101 enable_xim="yes"
3102 fi
3103fi
3104
Bram Moolenaarf52fac22022-03-11 16:01:26 +00003105if test -z "$SKIP_MOTIF"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003106 cppflags_save=$CPPFLAGS
3107 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00003108dnl Xmu/Editres.h may exist but can only be used after including Intrinsic.h
3109 AC_MSG_CHECKING([for X11/Xmu/Editres.h])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003110 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00003111#include <X11/Intrinsic.h>
3112#include <X11/Xmu/Editres.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003113 [int i; i = 0;])],
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00003114 AC_MSG_RESULT(yes)
3115 AC_DEFINE(HAVE_X11_XMU_EDITRES_H),
3116 AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003117 CPPFLAGS=$cppflags_save
3118fi
3119
Bram Moolenaar0b40d082022-03-08 13:32:37 +00003120dnl Only use the Xm directory when compiling Motif.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003121if test -z "$SKIP_MOTIF"; then
3122 cppflags_save=$CPPFLAGS
3123 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003124 if test "$zOSUnix" = "yes"; then
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003125 AC_CHECK_HEADERS(Xm/Xm.h)
Bram Moolenaar77c19352012-06-13 19:19:41 +02003126 else
Bram Moolenaarde1d7342022-06-05 20:03:17 +01003127 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 +01003128 fi
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003129
Bram Moolenaar77c19352012-06-13 19:19:41 +02003130 if test "x$ac_cv_header_Xm_XpmP_h" = "xyes"; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003131 dnl Solaris uses XpmAttributes_21, very annoying.
3132 AC_MSG_CHECKING([for XpmAttributes_21 in Xm/XpmP.h])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003133 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <Xm/XpmP.h>], [XpmAttributes_21 attr;])],
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003134 AC_MSG_RESULT(yes); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes_21),
3135 AC_MSG_RESULT(no); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
3136 )
3137 else
Bram Moolenaar57657d82006-04-21 22:12:41 +00003138 AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003139 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003140 CPPFLAGS=$cppflags_save
3141fi
3142
3143if test "x$GUITYPE" = "xNONE" -a "$enable_xim" = "yes"; then
3144 AC_MSG_RESULT(no GUI selected; xim has been disabled)
3145 enable_xim="no"
3146fi
3147if test "x$GUITYPE" = "xNONE" -a "$enable_fontset" = "yes"; then
3148 AC_MSG_RESULT(no GUI selected; fontset has been disabled)
3149 enable_fontset="no"
3150fi
Bram Moolenaar182c5be2010-06-25 05:37:59 +02003151if test "x$GUITYPE:$enable_fontset" = "xGTK:yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003152 AC_MSG_RESULT(GTK+ 2 GUI selected; fontset has been disabled)
3153 enable_fontset="no"
3154fi
3155
Bram Moolenaarb3f74062020-02-26 16:16:53 +01003156dnl There is no test for the Haiku GUI, if it's selected it's used
3157if test -z "$SKIP_HAIKU"; then
3158 GUITYPE=HAIKUGUI
3159fi
3160
Bram Moolenaar071d4272004-06-13 20:20:40 +00003161if test -z "$SKIP_PHOTON"; then
3162 GUITYPE=PHOTONGUI
3163fi
3164
3165AC_SUBST(GUI_INC_LOC)
3166AC_SUBST(GUI_LIB_LOC)
3167AC_SUBST(GUITYPE)
3168AC_SUBST(GUI_X_LIBS)
3169
3170if test "$enable_workshop" = "yes" -a -n "$SKIP_MOTIF"; then
3171 AC_MSG_ERROR([cannot use workshop without Motif])
3172fi
3173
3174dnl defining FEAT_XIM and FEAT_XFONTSET is delayed, so that they can be disabled
3175if test "$enable_xim" = "yes"; then
3176 AC_DEFINE(FEAT_XIM)
3177fi
3178if test "$enable_fontset" = "yes"; then
3179 AC_DEFINE(FEAT_XFONTSET)
3180fi
3181
3182
3183dnl ---------------------------------------------------------------------------
3184dnl end of GUI-checking
3185dnl ---------------------------------------------------------------------------
3186
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003187AC_MSG_CHECKING([for /proc link to executable])
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003188if test -L "/proc/self/exe"; then
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003189 dnl Linux
3190 AC_MSG_RESULT([/proc/self/exe])
3191 AC_DEFINE(PROC_EXE_LINK, "/proc/self/exe")
3192elif test -L "/proc/self/path/a.out"; then
3193 dnl Solaris
3194 AC_MSG_RESULT([/proc/self/path/a.out])
3195 AC_DEFINE(PROC_EXE_LINK, "/proc/self/path/a.out")
3196elif test -L "/proc/curproc/file"; then
3197 dnl FreeBSD
3198 AC_MSG_RESULT([/proc/curproc/file])
3199 AC_DEFINE(PROC_EXE_LINK, "/proc/curproc/file")
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003200else
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003201 AC_MSG_RESULT(no)
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003202fi
3203
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003204dnl Check for Cygwin, which needs an extra source file if not using X11
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003205AC_MSG_CHECKING(for CYGWIN or MSYS environment)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00003206case $vim_cv_uname_output in
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003207 CYGWIN*|MSYS*) CYGWIN=yes; AC_MSG_RESULT(yes)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003208 AC_MSG_CHECKING(for CYGWIN clipboard support)
3209 if test "x$with_x" = "xno" ; then
3210 OS_EXTRA_SRC=winclip.c; OS_EXTRA_OBJ=objects/winclip.o
3211 AC_MSG_RESULT(yes)
3212 AC_DEFINE(FEAT_CYGWIN_WIN32_CLIPBOARD)
3213 else
3214 AC_MSG_RESULT(no - using X11)
3215 fi ;;
3216
3217 *) CYGWIN=no; AC_MSG_RESULT(no);;
3218esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00003219
Bram Moolenaar071d4272004-06-13 20:20:40 +00003220dnl Checks for libraries and include files.
3221
Bram Moolenaar446cb832008-06-24 21:56:24 +00003222AC_CACHE_CHECK([whether toupper is broken], [vim_cv_toupper_broken],
3223 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003224 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003225#include "confdefs.h"
3226#include <ctype.h>
3227#if STDC_HEADERS
3228# include <stdlib.h>
3229# include <stddef.h>
3230#endif
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01003231int main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003232 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003233 vim_cv_toupper_broken=yes
3234 ],[
3235 vim_cv_toupper_broken=no
3236 ],[
3237 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_toupper_broken')
3238 ])])
3239
3240if test "x$vim_cv_toupper_broken" = "xyes" ; then
3241 AC_DEFINE(BROKEN_TOUPPER)
3242fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003243
3244AC_MSG_CHECKING(whether __DATE__ and __TIME__ work)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003245AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>], [printf("(" __DATE__ " " __TIME__ ")");])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003246 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DATE_TIME),
3247 AC_MSG_RESULT(no))
3248
Bram Moolenaar0c094b92009-05-14 20:20:33 +00003249AC_MSG_CHECKING(whether __attribute__((unused)) is allowed)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003250AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>], [int x __attribute__((unused));])],
Bram Moolenaar0c094b92009-05-14 20:20:33 +00003251 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ATTRIBUTE_UNUSED),
3252 AC_MSG_RESULT(no))
3253
Bram Moolenaar071d4272004-06-13 20:20:40 +00003254dnl Checks for header files.
3255AC_CHECK_HEADER(elf.h, HAS_ELF=1)
3256dnl AC_CHECK_HEADER(dwarf.h, SVR4=1)
3257if test "$HAS_ELF" = 1; then
3258 AC_CHECK_LIB(elf, main)
3259fi
3260
3261AC_HEADER_DIRENT
3262
Bram Moolenaar071d4272004-06-13 20:20:40 +00003263dnl If sys/wait.h is not found it might still exist but not be POSIX
3264dnl compliant. In that case we define HAVE_UNION_WAIT (for NeXT)
3265if test $ac_cv_header_sys_wait_h = no; then
3266 AC_MSG_CHECKING([for sys/wait.h that defines union wait])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003267 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/wait.h>],
3268 [union wait xx, yy; xx = yy])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003269 AC_MSG_RESULT(yes)
3270 AC_DEFINE(HAVE_SYS_WAIT_H)
3271 AC_DEFINE(HAVE_UNION_WAIT),
3272 AC_MSG_RESULT(no))
3273fi
3274
Bram Moolenaar779a7752016-01-30 23:26:34 +01003275AC_CHECK_HEADERS(stdint.h stdlib.h string.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003276 sys/select.h sys/utsname.h termcap.h fcntl.h \
3277 sgtty.h sys/ioctl.h sys/time.h sys/types.h \
3278 termio.h iconv.h inttypes.h langinfo.h math.h \
3279 unistd.h stropts.h errno.h sys/resource.h \
3280 sys/systeminfo.h locale.h sys/stream.h termios.h \
3281 libc.h sys/statfs.h poll.h sys/poll.h pwd.h \
Bram Moolenaar1ecc5e42019-01-26 15:12:55 +01003282 utime.h sys/param.h sys/ptms.h libintl.h libgen.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003283 util/debug.h util/msg18n.h frame.h sys/acl.h \
3284 sys/access.h sys/sysinfo.h wchar.h wctype.h)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003285
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003286dnl sys/ptem.h depends on sys/stream.h on Solaris
3287AC_CHECK_HEADERS(sys/ptem.h, [], [],
3288[#if defined HAVE_SYS_STREAM_H
3289# include <sys/stream.h>
3290#endif])
3291
Bram Moolenaar32f31b12009-05-21 13:20:59 +00003292dnl sys/sysctl.h depends on sys/param.h on OpenBSD
3293AC_CHECK_HEADERS(sys/sysctl.h, [], [],
3294[#if defined HAVE_SYS_PARAM_H
3295# include <sys/param.h>
3296#endif])
3297
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003298
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003299dnl pthread_np.h may exist but can only be used after including pthread.h
3300AC_MSG_CHECKING([for pthread_np.h])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003301AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003302#include <pthread.h>
3303#include <pthread_np.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003304 [int i; i = 0;])],
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003305 AC_MSG_RESULT(yes)
3306 AC_DEFINE(HAVE_PTHREAD_NP_H),
3307 AC_MSG_RESULT(no))
3308
Bram Moolenaare344bea2005-09-01 20:46:49 +00003309AC_CHECK_HEADERS(strings.h)
Bram Moolenaard0573012017-10-28 21:11:06 +02003310if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00003311 dnl The strings.h file on OS/X contains a warning and nothing useful.
3312 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3313else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003314
3315dnl Check if strings.h and string.h can both be included when defined.
3316AC_MSG_CHECKING([if strings.h can be included after string.h])
3317cppflags_save=$CPPFLAGS
3318CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003319AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003320#if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO)
3321# define _NO_PROTO /* like in os_unix.h, causes conflict for AIX (Winn) */
3322 /* but don't do it on AIX 5.1 (Uribarri) */
3323#endif
3324#ifdef HAVE_XM_XM_H
3325# include <Xm/Xm.h> /* This breaks it for HP-UX 11 (Squassabia) */
3326#endif
3327#ifdef HAVE_STRING_H
3328# include <string.h>
3329#endif
3330#if defined(HAVE_STRINGS_H)
3331# include <strings.h>
3332#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003333 ], [int i; i = 0;])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003334 AC_MSG_RESULT(yes),
3335 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3336 AC_MSG_RESULT(no))
3337CPPFLAGS=$cppflags_save
Bram Moolenaar9372a112005-12-06 19:59:18 +00003338fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003339
3340dnl Checks for typedefs, structures, and compiler characteristics.
3341AC_PROG_GCC_TRADITIONAL
3342AC_C_CONST
Bram Moolenaar76243bd2009-03-02 01:47:02 +00003343AC_C_VOLATILE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003344AC_TYPE_MODE_T
3345AC_TYPE_OFF_T
3346AC_TYPE_PID_T
3347AC_TYPE_SIZE_T
3348AC_TYPE_UID_T
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003349AC_TYPE_UINT32_T
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003350
Bram Moolenaar071d4272004-06-13 20:20:40 +00003351AC_HEADER_TIME
3352AC_CHECK_TYPE(ino_t, long)
3353AC_CHECK_TYPE(dev_t, unsigned)
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003354AC_C_BIGENDIAN(,,,)
Bram Moolenaar136f29a2016-02-27 20:14:15 +01003355AC_C_INLINE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003356
3357AC_MSG_CHECKING(for rlim_t)
3358if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
3359 AC_MSG_RESULT([(cached) $ac_cv_type_rlim_t])
3360else
3361 AC_EGREP_CPP(dnl
3362changequote(<<,>>)dnl
3363<<(^|[^a-zA-Z_0-9])rlim_t[^a-zA-Z_0-9]>>dnl
3364changequote([,]),
3365 [
3366#include <sys/types.h>
3367#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003368# include <stdlib.h>
3369# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003370#endif
3371#ifdef HAVE_SYS_RESOURCE_H
Bram Moolenaar446cb832008-06-24 21:56:24 +00003372# include <sys/resource.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003373#endif
3374 ], ac_cv_type_rlim_t=yes, ac_cv_type_rlim_t=no)
3375 AC_MSG_RESULT($ac_cv_type_rlim_t)
3376fi
3377if test $ac_cv_type_rlim_t = no; then
3378 cat >> confdefs.h <<\EOF
3379#define rlim_t unsigned long
3380EOF
3381fi
3382
3383AC_MSG_CHECKING(for stack_t)
3384if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then
3385 AC_MSG_RESULT([(cached) $ac_cv_type_stack_t])
3386else
3387 AC_EGREP_CPP(stack_t,
3388 [
3389#include <sys/types.h>
3390#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003391# include <stdlib.h>
3392# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003393#endif
3394#include <signal.h>
3395 ], ac_cv_type_stack_t=yes, ac_cv_type_stack_t=no)
3396 AC_MSG_RESULT($ac_cv_type_stack_t)
3397fi
3398if test $ac_cv_type_stack_t = no; then
3399 cat >> confdefs.h <<\EOF
3400#define stack_t struct sigaltstack
3401EOF
3402fi
3403
3404dnl BSDI uses ss_base while others use ss_sp for the stack pointer.
3405AC_MSG_CHECKING(whether stack_t has an ss_base field)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003406AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003407#include <sys/types.h>
3408#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003409# include <stdlib.h>
3410# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003411#endif
3412#include <signal.h>
3413#include "confdefs.h"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003414 ], [stack_t sigstk; sigstk.ss_base = 0; ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003415 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SS_BASE),
3416 AC_MSG_RESULT(no))
3417
3418olibs="$LIBS"
3419AC_MSG_CHECKING(--with-tlib argument)
3420AC_ARG_WITH(tlib, [ --with-tlib=library terminal library to be used ],)
3421if test -n "$with_tlib"; then
3422 AC_MSG_RESULT($with_tlib)
3423 LIBS="$LIBS -l$with_tlib"
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003424 AC_MSG_CHECKING(for linking with $with_tlib library)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003425 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], AC_MSG_RESULT(OK), AC_MSG_ERROR(FAILED))
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003426 dnl Need to check for tgetent() below.
3427 olibs="$LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003428else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003429 AC_MSG_RESULT([empty: automatic terminal library selection])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003430 dnl On HP-UX 10.10 termcap or termlib should be used instead of
3431 dnl curses, because curses is much slower.
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003432 dnl Newer versions of ncurses are preferred over anything, except
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02003433 dnl when tinfo has been split off, it contains all we need.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003434 dnl Older versions of ncurses have bugs, get a new one!
3435 dnl Digital Unix (OSF1) should use curses (Ronald Schild).
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00003436 dnl On SCO Openserver should prefer termlib (Roger Cornelius).
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00003437 case "$vim_cv_uname_output" in
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003438 OSF1|SCO_SV) tlibs="tinfo ncurses curses termlib termcap";;
3439 *) tlibs="tinfo ncurses termlib termcap curses";;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003440 esac
3441 for libname in $tlibs; do
3442 AC_CHECK_LIB(${libname}, tgetent,,)
3443 if test "x$olibs" != "x$LIBS"; then
3444 dnl It's possible that a library is found but it doesn't work
3445 dnl e.g., shared library that cannot be found
3446 dnl compile and run a test program to be sure
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003447 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003448#ifdef HAVE_TERMCAP_H
3449# include <termcap.h>
3450#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003451#if STDC_HEADERS
3452# include <stdlib.h>
3453# include <stddef.h>
3454#endif
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01003455int main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003456 res="OK", res="FAIL", res="FAIL")
3457 if test "$res" = "OK"; then
3458 break
3459 fi
3460 AC_MSG_RESULT($libname library is not usable)
3461 LIBS="$olibs"
3462 fi
3463 done
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003464 if test "x$olibs" = "x$LIBS"; then
3465 AC_MSG_RESULT(no terminal library found)
3466 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003467fi
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003468
3469if test "x$olibs" = "x$LIBS"; then
3470 AC_MSG_CHECKING([for tgetent()])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003471 AC_LINK_IFELSE([AC_LANG_PROGRAM([int tgetent(char *, const char *);],
3472 [[char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");]])],
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003473 AC_MSG_RESULT(yes),
3474 AC_MSG_ERROR([NOT FOUND!
3475 You need to install a terminal library; for example ncurses.
Bram Moolenaar16678eb2021-04-21 11:57:59 +02003476 On Linux that would be the libncurses-dev package.
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003477 Or specify the name of the library with --with-tlib.]))
3478fi
3479
Bram Moolenaar446cb832008-06-24 21:56:24 +00003480AC_CACHE_CHECK([whether we talk terminfo], [vim_cv_terminfo],
3481 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003482 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003483#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003484#ifdef HAVE_TERMCAP_H
3485# include <termcap.h>
3486#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003487#ifdef HAVE_STRING_H
3488# include <string.h>
3489#endif
3490#if STDC_HEADERS
3491# include <stdlib.h>
3492# include <stddef.h>
3493#endif
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01003494int main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003495{char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003496 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003497 vim_cv_terminfo=no
3498 ],[
3499 vim_cv_terminfo=yes
3500 ],[
3501 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_terminfo')
3502 ])
3503 ])
3504
3505if test "x$vim_cv_terminfo" = "xyes" ; then
3506 AC_DEFINE(TERMINFO)
3507fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003508
Bram Moolenaara88254f2017-11-02 23:04:14 +01003509AC_CACHE_CHECK([what tgetent() returns for an unknown terminal], [vim_cv_tgetent],
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003510 [
3511 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003512#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003513#ifdef HAVE_TERMCAP_H
3514# include <termcap.h>
3515#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003516#if STDC_HEADERS
3517# include <stdlib.h>
3518# include <stddef.h>
3519#endif
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01003520int main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003521{char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003522 ]])],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003523 vim_cv_tgetent=zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003524 ],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003525 vim_cv_tgetent=non-zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003526 ],[
3527 AC_MSG_ERROR(failed to compile test program.)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003528 ])
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003529 ])
3530
Bram Moolenaara88254f2017-11-02 23:04:14 +01003531if test "x$vim_cv_tgetent" = "xzero" ; then
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003532 AC_DEFINE(TGETENT_ZERO_ERR, 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003533fi
3534
3535AC_MSG_CHECKING(whether termcap.h contains ospeed)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003536AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003537#ifdef HAVE_TERMCAP_H
3538# include <termcap.h>
3539#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003540 ], [ospeed = 20000])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003541 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED),
3542 [AC_MSG_RESULT(no)
3543 AC_MSG_CHECKING(whether ospeed can be extern)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003544 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003545#ifdef HAVE_TERMCAP_H
3546# include <termcap.h>
3547#endif
3548extern short ospeed;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003549 ], [ospeed = 20000])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003550 AC_MSG_RESULT(yes); AC_DEFINE(OSPEED_EXTERN),
3551 AC_MSG_RESULT(no))]
3552 )
3553
3554AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003555AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003556#ifdef HAVE_TERMCAP_H
3557# include <termcap.h>
3558#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003559 ], [if (UP == 0 && BC == 0) PC = 1])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003560 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UP_BC_PC),
3561 [AC_MSG_RESULT(no)
3562 AC_MSG_CHECKING([whether UP, BC and PC can be extern])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003563 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003564#ifdef HAVE_TERMCAP_H
3565# include <termcap.h>
3566#endif
3567extern char *UP, *BC, PC;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003568 ], [if (UP == 0 && BC == 0) PC = 1])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003569 AC_MSG_RESULT(yes); AC_DEFINE(UP_BC_PC_EXTERN),
3570 AC_MSG_RESULT(no))]
3571 )
3572
3573AC_MSG_CHECKING(whether tputs() uses outfuntype)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003574AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003575#ifdef HAVE_TERMCAP_H
3576# include <termcap.h>
3577#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003578 ], [extern int xx(); tputs("test", 1, (outfuntype)xx)])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003579 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OUTFUNTYPE),
3580 AC_MSG_RESULT(no))
3581
Bram Moolenaarb3a29552021-11-19 11:28:04 +00003582AC_MSG_CHECKING([whether del_curterm() can be used])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003583AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaarb3a29552021-11-19 11:28:04 +00003584#ifdef HAVE_TERMCAP_H
3585# include <termcap.h>
3586#endif
3587#include <term.h>
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003588 ], [if (cur_term) del_curterm(cur_term);])],
Bram Moolenaarb3a29552021-11-19 11:28:04 +00003589 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DEL_CURTERM),
3590 AC_MSG_RESULT(no))
3591
Bram Moolenaar071d4272004-06-13 20:20:40 +00003592dnl On some SCO machines sys/select redefines struct timeval
3593AC_MSG_CHECKING([whether sys/select.h and sys/time.h may both be included])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003594AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003595#include <sys/types.h>
3596#include <sys/time.h>
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003597#include <sys/select.h>], )],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003598 AC_MSG_RESULT(yes)
3599 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME),
3600 AC_MSG_RESULT(no))
3601
3602dnl AC_DECL_SYS_SIGLIST
3603
3604dnl Checks for pty.c (copied from screen) ==========================
3605AC_MSG_CHECKING(for /dev/ptc)
3606if test -r /dev/ptc; then
3607 AC_DEFINE(HAVE_DEV_PTC)
3608 AC_MSG_RESULT(yes)
3609else
3610 AC_MSG_RESULT(no)
3611fi
3612
3613AC_MSG_CHECKING(for SVR4 ptys)
3614if test -c /dev/ptmx ; then
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003615 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaarce7be3a2020-11-26 20:11:11 +01003616// These should be in stdlib.h, but it depends on _XOPEN_SOURCE.
3617char *ptsname(int);
3618int unlockpt(int);
3619int grantpt(int);
3620 ], [
3621 ptsname(0);
3622 grantpt(0);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003623 unlockpt(0);])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003624 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SVR4_PTYS),
3625 AC_MSG_RESULT(no))
3626else
3627 AC_MSG_RESULT(no)
3628fi
3629
3630AC_MSG_CHECKING(for ptyranges)
3631if test -d /dev/ptym ; then
3632 pdir='/dev/ptym'
3633else
3634 pdir='/dev'
3635fi
3636dnl SCO uses ptyp%d
3637AC_EGREP_CPP(yes,
3638[#ifdef M_UNIX
3639 yes;
3640#endif
3641 ], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
3642dnl if test -c /dev/ptyp19; then
3643dnl ptys=`echo /dev/ptyp??`
3644dnl else
3645dnl ptys=`echo $pdir/pty??`
3646dnl fi
3647if test "$ptys" != "$pdir/pty??" ; then
3648 p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
3649 p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'`
3650 AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
3651 AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
3652 AC_MSG_RESULT([$p0 / $p1])
3653else
3654 AC_MSG_RESULT([don't know])
3655fi
3656
Bram Moolenaar071d4272004-06-13 20:20:40 +00003657dnl Checks for library functions. ===================================
3658
Bram Moolenaar071d4272004-06-13 20:20:40 +00003659dnl check if struct sigcontext is defined (used for SGI only)
3660AC_MSG_CHECKING(for struct sigcontext)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003661AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003662#include <signal.h>
Sam Jamesf8ea1062022-11-05 15:13:50 +00003663int test_sig()
Bram Moolenaar071d4272004-06-13 20:20:40 +00003664{
3665 struct sigcontext *scont;
3666 scont = (struct sigcontext *)0;
3667 return 1;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003668} ], )],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003669 AC_MSG_RESULT(yes)
3670 AC_DEFINE(HAVE_SIGCONTEXT),
3671 AC_MSG_RESULT(no))
3672
3673dnl tricky stuff: try to find out if getcwd() is implemented with
3674dnl system("sh -c pwd")
Bram Moolenaar446cb832008-06-24 21:56:24 +00003675AC_CACHE_CHECK([getcwd implementation is broken], [vim_cv_getcwd_broken],
3676 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003677 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003678#include "confdefs.h"
3679#ifdef HAVE_UNISTD_H
3680#include <unistd.h>
3681#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003682char *dagger[] = { "IFS=pwd", 0 };
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01003683int main()
Bram Moolenaar071d4272004-06-13 20:20:40 +00003684{
3685 char buffer[500];
3686 extern char **environ;
3687 environ = dagger;
3688 return getcwd(buffer, 500) ? 0 : 1;
Bram Moolenaar446cb832008-06-24 21:56:24 +00003689}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003690 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003691 vim_cv_getcwd_broken=no
3692 ],[
3693 vim_cv_getcwd_broken=yes
3694 ],[
3695 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_getcwd_broken')
3696 ])
3697 ])
3698
3699if test "x$vim_cv_getcwd_broken" = "xyes" ; then
3700 AC_DEFINE(BAD_GETCWD)
Bram Moolenaar63d25552019-05-10 21:28:38 +02003701 AC_CHECK_FUNCS(getwd)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003702fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003703
Bram Moolenaar25153e12010-02-24 14:47:08 +01003704dnl Check for functions in one big call, to reduce the size of configure.
3705dnl Can only be used for functions that do not require any include.
Bram Moolenaarcd142e32017-11-16 17:03:45 +01003706AC_CHECK_FUNCS(fchdir fchown fchmod fsync getcwd getpseudotty \
Bram Moolenaar63d25552019-05-10 21:28:38 +02003707 getpwent getpwnam getpwuid getrlimit gettimeofday localtime_r lstat \
Bram Moolenaareaf03392009-11-17 11:08:52 +00003708 memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
Bram Moolenaar2fcf6682017-03-11 20:03:42 +01003709 getpgid setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
Bram Moolenaar84cf6bd2020-06-16 20:03:43 +02003710 sigprocmask sigvec strcasecmp strcoll strerror strftime stricmp strncasecmp \
Bram Moolenaar10455d42019-11-21 15:36:18 +01003711 strnicmp strpbrk strptime strtol tgetent towlower towupper iswupper \
3712 tzset usleep utime utimes mblen ftruncate unsetenv posix_openpt)
Bram Moolenaar643b6142018-09-12 20:29:09 +02003713AC_FUNC_SELECT_ARGTYPES
Bram Moolenaar25153e12010-02-24 14:47:08 +01003714AC_FUNC_FSEEKO
Bram Moolenaar071d4272004-06-13 20:20:40 +00003715
Bram Moolenaar317fd3a2010-05-07 16:05:55 +02003716dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when
3717dnl appropriate, so that off_t is 64 bits when needed.
3718AC_SYS_LARGEFILE
3719
Bram Moolenaar21606672019-06-14 20:40:58 +02003720AC_MSG_CHECKING(--enable-canberra argument)
3721AC_ARG_ENABLE(canberra,
3722 [ --disable-canberra Do not use libcanberra.],
3723 , [enable_canberra="maybe"])
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003724
Bram Moolenaar21606672019-06-14 20:40:58 +02003725if test "$enable_canberra" = "maybe"; then
Martin Tournoij25f3a142022-10-08 19:26:41 +01003726 if test "$features" = "huge"; then
Bram Moolenaar21606672019-06-14 20:40:58 +02003727 AC_MSG_RESULT(Defaulting to yes)
3728 enable_canberra="yes"
3729 else
3730 AC_MSG_RESULT(Defaulting to no)
3731 enable_canberra="no"
3732 fi
3733else
Bram Moolenaar12471262022-01-18 11:11:25 +00003734 if test "$enable_canberra" = "yes" -a "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +01003735 AC_MSG_RESULT([cannot use sound with tiny features])
Bram Moolenaar12471262022-01-18 11:11:25 +00003736 enable_canberra="no"
3737 else
3738 AC_MSG_RESULT($enable_canberra)
3739 fi
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003740fi
Bram Moolenaar21606672019-06-14 20:40:58 +02003741if test "$enable_canberra" = "yes"; then
3742 if test "x$PKG_CONFIG" != "xno"; then
3743 canberra_lib=`$PKG_CONFIG --libs libcanberra 2>/dev/null`
3744 canberra_cflags=`$PKG_CONFIG --cflags libcanberra 2>/dev/null`
3745 fi
3746 if test "x$canberra_lib" = "x"; then
3747 canberra_lib=-lcanberra
3748 canberra_cflags=-D_REENTRANT
3749 fi
3750 AC_MSG_CHECKING(for libcanberra)
3751 ac_save_CFLAGS="$CFLAGS"
3752 ac_save_LIBS="$LIBS"
Bram Moolenaar12471262022-01-18 11:11:25 +00003753 if `echo "$CFLAGS" | grep -v "$canberra_cflags" 2>/dev/null`; then
Christian Brabandt6b9efdd2021-09-09 17:14:50 +02003754 CFLAGS="$CFLAGS $canberra_cflags"
3755 fi
Bram Moolenaar21606672019-06-14 20:40:58 +02003756 LIBS="$LIBS $canberra_lib"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003757 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar21606672019-06-14 20:40:58 +02003758 # include <canberra.h>
3759 ], [
3760 ca_context *hello;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003761 ca_context_create(&hello);])],
Bram Moolenaar21606672019-06-14 20:40:58 +02003762 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_CANBERRA),
Bram Moolenaar91b992c2019-11-17 19:07:42 +01003763 AC_MSG_RESULT(no; try installing libcanberra-dev); CFLAGS="$ac_save_CFLAGS"; LIBS="$ac_save_LIBS")
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003764fi
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003765
Christian Brabandtf573c6e2021-06-20 14:02:16 +02003766AC_MSG_CHECKING(--enable-libsodium argument)
3767AC_ARG_ENABLE(libsodium,
3768 [ --disable-libsodium Do not use libsodium.],
3769 , [enable_libsodium="maybe"])
3770
3771if test "$enable_libsodium" = "maybe"; then
Martin Tournoij25f3a142022-10-08 19:26:41 +01003772 if test "$features" = "huge"; then
Christian Brabandtf573c6e2021-06-20 14:02:16 +02003773 AC_MSG_RESULT(Defaulting to yes)
3774 enable_libsodium="yes"
3775 else
3776 AC_MSG_RESULT(Defaulting to no)
3777 enable_libsodium="no"
3778 fi
3779else
3780 AC_MSG_RESULT($enable_libsodium)
3781fi
3782if test "$enable_libsodium" = "yes"; then
3783 if test "x$PKG_CONFIG" != "xno"; then
3784 libsodium_lib=`$PKG_CONFIG --libs libsodium 2>/dev/null`
3785 libsodium_cflags=`$PKG_CONFIG --cflags libsodium 2>/dev/null`
3786 fi
3787 if test "x$libsodium_lib" = "x"; then
3788 libsodium_lib=-lsodium
3789 libsodium_cflags=
3790 fi
ichizok8ce3ca82021-06-23 15:41:52 +02003791 AC_MSG_CHECKING(for libsodium)
Christian Brabandtf573c6e2021-06-20 14:02:16 +02003792 ac_save_CFLAGS="$CFLAGS"
3793 ac_save_LIBS="$LIBS"
3794 CFLAGS="$CFLAGS $libsodium_cflags"
3795 LIBS="$LIBS $libsodium_lib"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003796 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Christian Brabandtf573c6e2021-06-20 14:02:16 +02003797 # include <sodium.h>
3798 ], [
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003799 printf("%d", sodium_init()); ])],
Christian Brabandtf573c6e2021-06-20 14:02:16 +02003800 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SODIUM),
3801 AC_MSG_RESULT(no; try installing libsodium-dev); CFLAGS="$ac_save_CFLAGS"; LIBS="$ac_save_LIBS")
3802fi
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003803
Bram Moolenaar071d4272004-06-13 20:20:40 +00003804dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible
3805AC_MSG_CHECKING(for st_blksize)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003806AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00003807[#include <sys/types.h>
3808#include <sys/stat.h>],
3809[ struct stat st;
3810 int n;
3811
3812 stat("/", &st);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003813 n = (int)st.st_blksize;])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003814 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ST_BLKSIZE),
3815 AC_MSG_RESULT(no))
3816
Paul Ollis65745772022-06-05 16:55:54 +01003817dnl Check for timer_create. It probably requires the 'rt' library.
Bram Moolenaarf2ce76a2022-07-02 11:40:40 +01003818dnl Run the program to find out if timer_create(CLOCK_MONOTONIC) actually
3819dnl works, on Solaris timer_create() exists but fails at runtime.
Bram Moolenaarefffa532022-07-28 22:39:54 +01003820AC_CACHE_CHECK([for timer_create without -lrt], [vim_cv_timer_create], [
Bram Moolenaarf2ce76a2022-07-02 11:40:40 +01003821AC_RUN_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar5748b7f2022-07-28 12:09:04 +01003822#if STDC_HEADERS
3823# include <stdlib.h>
3824# include <stddef.h>
3825#endif
3826#include <signal.h>
3827#include <time.h>
Bram Moolenaare5303952022-06-19 17:05:47 +01003828static void set_flag(union sigval sv) {}
Paul Ollis65745772022-06-05 16:55:54 +01003829], [
3830 struct timespec ts;
3831 struct sigevent action = {0};
3832 timer_t timer_id;
3833
3834 action.sigev_notify = SIGEV_THREAD;
3835 action.sigev_notify_function = set_flag;
Bram Moolenaarf2ce76a2022-07-02 11:40:40 +01003836 if (timer_create(CLOCK_MONOTONIC, &action, &timer_id) < 0)
3837 exit(1); // cannot create a monotonic timer
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003838 ])],
Bram Moolenaarefffa532022-07-28 22:39:54 +01003839 vim_cv_timer_create=yes,
3840 vim_cv_timer_create=no,
Bram Moolenaar5f6cae82022-07-30 11:00:50 +01003841 AC_MSG_WARN([failed to build test program; if cross-compiling please set 'vim_cv_timer_create'])
Bram Moolenaarefffa532022-07-28 22:39:54 +01003842 )])
Paul Ollis65745772022-06-05 16:55:54 +01003843
Bram Moolenaarefffa532022-07-28 22:39:54 +01003844dnl If the previous failed, check for timer_create() and linking with -lrt.
3845if test "x$vim_cv_timer_create" = "xno" ; then
3846 save_LIBS="$LIBS"
3847 LIBS="$LIBS -lrt"
3848 AC_CACHE_CHECK([for timer_create with -lrt], [vim_cv_timer_create_with_lrt], [
3849 AC_RUN_IFELSE([AC_LANG_PROGRAM([
3850 #if STDC_HEADERS
3851 # include <stdlib.h>
3852 # include <stddef.h>
3853 #endif
3854 #include <signal.h>
3855 #include <time.h>
3856 static void set_flag(union sigval sv) {}
3857 ], [
3858 struct timespec ts;
3859 struct sigevent action = {0};
3860 timer_t timer_id;
3861
3862 action.sigev_notify = SIGEV_THREAD;
3863 action.sigev_notify_function = set_flag;
3864 if (timer_create(CLOCK_MONOTONIC, &action, &timer_id) < 0)
3865 exit(1); // cannot create a monotonic timer
3866 ])],
3867 vim_cv_timer_create_with_lrt=yes,
3868 vim_cv_timer_create_with_lrt=no,
Bram Moolenaar5f6cae82022-07-30 11:00:50 +01003869 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 +01003870 )])
3871 LIBS="$save_LIBS"
3872else
3873 vim_cv_timer_create_with_lrt=no
3874fi
Richard Purdie509695c2022-07-24 20:48:00 +01003875
3876if test "x$vim_cv_timer_create" = "xyes" ; then
3877 AC_DEFINE(HAVE_TIMER_CREATE)
3878fi
Bram Moolenaarefffa532022-07-28 22:39:54 +01003879if test "x$vim_cv_timer_create_with_lrt" = "xyes" ; then
3880 AC_DEFINE(HAVE_TIMER_CREATE)
3881 LIBS="$LIBS -lrt"
3882fi
Paul Ollis65745772022-06-05 16:55:54 +01003883
Bram Moolenaar446cb832008-06-24 21:56:24 +00003884AC_CACHE_CHECK([whether stat() ignores a trailing slash], [vim_cv_stat_ignores_slash],
3885 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003886 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003887#include "confdefs.h"
3888#if STDC_HEADERS
3889# include <stdlib.h>
3890# include <stddef.h>
3891#endif
3892#include <sys/types.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003893#include <sys/stat.h>
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01003894int main() {struct stat st; exit(stat("configure/", &st) != 0); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003895 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003896 vim_cv_stat_ignores_slash=yes
3897 ],[
3898 vim_cv_stat_ignores_slash=no
3899 ],[
3900 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_stat_ignores_slash')
3901 ])
3902 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003903
Bram Moolenaar446cb832008-06-24 21:56:24 +00003904if test "x$vim_cv_stat_ignores_slash" = "xyes" ; then
3905 AC_DEFINE(STAT_IGNORES_SLASH)
3906fi
Leah Neukirchen0a7984a2021-10-14 21:27:55 +01003907
3908dnl nanoseconds field of struct stat
3909AC_CACHE_CHECK([for nanoseconds field of struct stat],
3910 ac_cv_struct_st_mtim_nsec,
3911 [ac_save_CPPFLAGS="$CPPFLAGS"
3912 ac_cv_struct_st_mtim_nsec=no
3913 # st_mtim.tv_nsec -- the usual case
3914 # st_mtim._tv_nsec -- Solaris 2.6, if
3915 # (defined _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED == 1
3916 # && !defined __EXTENSIONS__)
3917 # st_mtim.st__tim.tv_nsec -- UnixWare 2.1.2
3918 # st_mtime_n -- AIX 5.2 and above
3919 # st_mtimespec.tv_nsec -- Darwin (Mac OSX)
3920 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
3921 CPPFLAGS="$ac_save_CPPFLAGS -DST_MTIM_NSEC=$ac_val"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003922 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
3923#include <sys/stat.h>], [struct stat s; s.ST_MTIM_NSEC;])],
Leah Neukirchen0a7984a2021-10-14 21:27:55 +01003924 [ac_cv_struct_st_mtim_nsec=$ac_val; break])
3925 done
3926 CPPFLAGS="$ac_save_CPPFLAGS"
3927])
3928if test $ac_cv_struct_st_mtim_nsec != no; then
3929 AC_DEFINE_UNQUOTED([ST_MTIM_NSEC], [$ac_cv_struct_st_mtim_nsec],
3930 [Define if struct stat contains a nanoseconds field])
3931fi
Bram Moolenaare5303952022-06-19 17:05:47 +01003932
Bram Moolenaar071d4272004-06-13 20:20:40 +00003933dnl Link with iconv for charset translation, if not found without library.
3934dnl check for iconv() requires including iconv.h
3935dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
3936dnl has been installed.
3937AC_MSG_CHECKING(for iconv_open())
3938save_LIBS="$LIBS"
3939LIBS="$LIBS -liconv"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003940AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003941#ifdef HAVE_ICONV_H
3942# include <iconv.h>
3943#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003944 ], [iconv_open("fr", "to");])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003945 AC_MSG_RESULT(yes; with -liconv); AC_DEFINE(HAVE_ICONV),
3946 LIBS="$save_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003947 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003948#ifdef HAVE_ICONV_H
3949# include <iconv.h>
3950#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003951 ], [iconv_open("fr", "to");])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003952 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ICONV),
3953 AC_MSG_RESULT(no)))
3954
3955
3956AC_MSG_CHECKING(for nl_langinfo(CODESET))
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003957AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003958#ifdef HAVE_LANGINFO_H
3959# include <langinfo.h>
3960#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003961], [char *cs = nl_langinfo(CODESET);])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003962 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET),
3963 AC_MSG_RESULT(no))
3964
Bram Moolenaar73e28dc2022-09-17 21:08:33 +01003965dnl Floating point support may require the "m" library
Bram Moolenaar446cb832008-06-24 21:56:24 +00003966AC_CHECK_LIB(m, strtod)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003967
Bram Moolenaara6b89762016-02-29 21:38:26 +01003968dnl isinf() and isnan() need to include header files and may need -lm.
3969AC_MSG_CHECKING([for isinf()])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003970AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaara6b89762016-02-29 21:38:26 +01003971#ifdef HAVE_MATH_H
3972# include <math.h>
3973#endif
3974#if STDC_HEADERS
3975# include <stdlib.h>
3976# include <stddef.h>
3977#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003978], [int r = isinf(1.11); ])],
Bram Moolenaara6b89762016-02-29 21:38:26 +01003979 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISINF),
3980 AC_MSG_RESULT(no))
3981
3982AC_MSG_CHECKING([for isnan()])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003983AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaara6b89762016-02-29 21:38:26 +01003984#ifdef HAVE_MATH_H
3985# include <math.h>
3986#endif
3987#if STDC_HEADERS
3988# include <stdlib.h>
3989# include <stddef.h>
3990#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003991], [int r = isnan(1.11); ])],
Bram Moolenaara6b89762016-02-29 21:38:26 +01003992 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISNAN),
3993 AC_MSG_RESULT(no))
3994
Bram Moolenaar071d4272004-06-13 20:20:40 +00003995dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI
3996dnl when -lacl works, also try to use -lattr (required for Debian).
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003997dnl On Solaris, use the acl_get/set functions in libsec, if present.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003998AC_MSG_CHECKING(--disable-acl argument)
3999AC_ARG_ENABLE(acl,
Bram Moolenaard6d30422018-01-28 22:48:55 +01004000 [ --disable-acl No check for ACL support.],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004001 , [enable_acl="yes"])
4002if test "$enable_acl" = "yes"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01004003 AC_MSG_RESULT(no)
4004 AC_CHECK_LIB(posix1e, acl_get_file, [LIBS="$LIBS -lposix1e"],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004005 AC_CHECK_LIB(acl, acl_get_file, [LIBS="$LIBS -lacl"
4006 AC_CHECK_LIB(attr, fgetxattr, LIBS="$LIBS -lattr",,)],,),)
4007
Bram Moolenaard6d30422018-01-28 22:48:55 +01004008 AC_MSG_CHECKING(for POSIX ACL support)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004009 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00004010#include <sys/types.h>
4011#ifdef HAVE_SYS_ACL_H
4012# include <sys/acl.h>
4013#endif
4014acl_t acl;], [acl = acl_get_file("foo", ACL_TYPE_ACCESS);
4015 acl_set_file("foo", ACL_TYPE_ACCESS, acl);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004016 acl_free(acl);])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004017 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_ACL),
4018 AC_MSG_RESULT(no))
4019
Bram Moolenaard6d30422018-01-28 22:48:55 +01004020 AC_CHECK_LIB(sec, acl_get, [LIBS="$LIBS -lsec"; AC_DEFINE(HAVE_SOLARIS_ZFS_ACL)],
4021 AC_MSG_CHECKING(for Solaris ACL support)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004022 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00004023#ifdef HAVE_SYS_ACL_H
4024# include <sys/acl.h>
4025#endif], [acl("foo", GETACLCNT, 0, NULL);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004026 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004027 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOLARIS_ACL),
Bram Moolenaar8d462f92012-02-05 22:51:33 +01004028 AC_MSG_RESULT(no)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004029
Bram Moolenaard6d30422018-01-28 22:48:55 +01004030 AC_MSG_CHECKING(for AIX ACL support)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004031 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar446cb832008-06-24 21:56:24 +00004032#if STDC_HEADERS
4033# include <stdlib.h>
4034# include <stddef.h>
4035#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004036#ifdef HAVE_SYS_ACL_H
4037# include <sys/acl.h>
4038#endif
4039#ifdef HAVE_SYS_ACCESS_H
4040# include <sys/access.h>
4041#endif
4042#define _ALL_SOURCE
4043
4044#include <sys/stat.h>
4045
4046int aclsize;
4047struct acl *aclent;], [aclsize = sizeof(struct acl);
4048 aclent = (void *)malloc(aclsize);
4049 statacl("foo", STX_NORMAL, aclent, aclsize);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004050 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004051 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_AIX_ACL),
4052 AC_MSG_RESULT(no))
4053else
4054 AC_MSG_RESULT(yes)
4055fi
4056
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02004057if test "x$GTK_CFLAGS" != "x"; then
4058 dnl pango_shape_full() is new, fall back to pango_shape().
4059 AC_MSG_CHECKING(for pango_shape_full)
4060 ac_save_CFLAGS="$CFLAGS"
4061 ac_save_LIBS="$LIBS"
4062 CFLAGS="$CFLAGS $GTK_CFLAGS"
4063 LIBS="$LIBS $GTK_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004064 AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02004065 [#include <gtk/gtk.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004066 [ pango_shape_full(NULL, 0, NULL, 0, NULL, NULL); ])],
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02004067 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_PANGO_SHAPE_FULL),
4068 AC_MSG_RESULT(no))
4069 CFLAGS="$ac_save_CFLAGS"
4070 LIBS="$ac_save_LIBS"
4071fi
4072
Bram Moolenaar33fc4a62022-02-23 18:07:38 +00004073AC_MSG_CHECKING(--enable-gpm argument)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004074AC_ARG_ENABLE(gpm,
Bram Moolenaar33fc4a62022-02-23 18:07:38 +00004075 [ --enable-gpm=OPTS Use gpm (Linux mouse daemon). default=yes OPTS=yes/no/dynamic], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00004076 [enable_gpm="yes"])
4077
Bram Moolenaar33fc4a62022-02-23 18:07:38 +00004078if test "$enable_gpm" = "yes" -o "$enable_gpm" = "dynamic"; then
4079 AC_MSG_RESULT($enable_gpm)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004080 dnl Checking if gpm support can be compiled
4081 AC_CACHE_CHECK([for gpm], vi_cv_have_gpm,
4082 [olibs="$LIBS" ; LIBS="-lgpm"]
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004083 AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004084 [#include <gpm.h>
4085 #include <linux/keyboard.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004086 [Gpm_GetLibVersion(NULL);])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004087 dnl Configure defines HAVE_GPM, if it is defined feature.h defines
4088 dnl FEAT_MOUSE_GPM if mouse support is included
4089 [vi_cv_have_gpm=yes],
4090 [vi_cv_have_gpm=no])
4091 [LIBS="$olibs"]
4092 )
4093 if test $vi_cv_have_gpm = yes; then
Bram Moolenaar33fc4a62022-02-23 18:07:38 +00004094 if test "$enable_gpm" = "yes"; then
4095 LIBS="$LIBS -lgpm"
4096 else
4097 AC_DEFINE(DYNAMIC_GPM)
4098 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004099 AC_DEFINE(HAVE_GPM)
4100 fi
4101else
Bram Moolenaar33fc4a62022-02-23 18:07:38 +00004102 AC_MSG_RESULT(no)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004103fi
4104
Bram Moolenaar446cb832008-06-24 21:56:24 +00004105AC_MSG_CHECKING(--disable-sysmouse argument)
4106AC_ARG_ENABLE(sysmouse,
Bram Moolenaar8008b632017-07-18 21:33:20 +02004107 [ --disable-sysmouse Don't use sysmouse (mouse in *BSD console).], ,
Bram Moolenaar446cb832008-06-24 21:56:24 +00004108 [enable_sysmouse="yes"])
4109
4110if test "$enable_sysmouse" = "yes"; then
4111 AC_MSG_RESULT(no)
4112 dnl Checking if sysmouse support can be compiled
4113 dnl Configure defines HAVE_SYSMOUSE, if it is defined feature.h
4114 dnl defines FEAT_SYSMOUSE if mouse support is included
4115 AC_CACHE_CHECK([for sysmouse], vi_cv_have_sysmouse,
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004116 AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar446cb832008-06-24 21:56:24 +00004117 [#include <sys/consio.h>
4118 #include <signal.h>
4119 #include <sys/fbio.h>],
4120 [struct mouse_info mouse;
4121 mouse.operation = MOUSE_MODE;
4122 mouse.operation = MOUSE_SHOW;
4123 mouse.u.mode.mode = 0;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004124 mouse.u.mode.signal = SIGUSR2;])],
Bram Moolenaar446cb832008-06-24 21:56:24 +00004125 [vi_cv_have_sysmouse=yes],
4126 [vi_cv_have_sysmouse=no])
4127 )
4128 if test $vi_cv_have_sysmouse = yes; then
4129 AC_DEFINE(HAVE_SYSMOUSE)
4130 fi
4131else
4132 AC_MSG_RESULT(yes)
4133fi
4134
Bram Moolenaarf05da212009-11-17 16:13:15 +00004135dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
4136AC_MSG_CHECKING(for FD_CLOEXEC)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004137AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaarf05da212009-11-17 16:13:15 +00004138[#if HAVE_FCNTL_H
4139# include <fcntl.h>
4140#endif],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004141[ int flag = FD_CLOEXEC;])],
Bram Moolenaarf05da212009-11-17 16:13:15 +00004142 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
4143 AC_MSG_RESULT(not usable))
4144
Bram Moolenaar071d4272004-06-13 20:20:40 +00004145dnl rename needs to be checked separately to work on Nextstep with cc
4146AC_MSG_CHECKING(for rename)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004147AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>], [rename("this", "that")])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004148 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
4149 AC_MSG_RESULT(no))
4150
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004151dnl check for dirfd()
4152AC_MSG_CHECKING(for dirfd)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004153AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004154[#include <sys/types.h>
4155#include <dirent.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004156[DIR * dir=opendir("dirname"); dirfd(dir);])],
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004157AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DIRFD), AC_MSG_RESULT(not usable))
4158
4159dnl check for flock()
4160AC_MSG_CHECKING(for flock)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004161AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004162[#include <sys/file.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004163[flock(10, LOCK_SH);])],
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004164AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOCK), AC_MSG_RESULT(not usable))
4165
Bram Moolenaar071d4272004-06-13 20:20:40 +00004166dnl sysctl() may exist but not the arguments we use
4167AC_MSG_CHECKING(for sysctl)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004168AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004169[#include <sys/types.h>
4170#include <sys/sysctl.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004171[[ int mib[2], r;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004172 size_t len;
4173
4174 mib[0] = CTL_HW;
4175 mib[1] = HW_USERMEM;
4176 len = sizeof(r);
4177 (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004178 ]])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004179 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL),
4180 AC_MSG_RESULT(not usable))
4181
Bram Moolenaare2982d62021-10-06 11:27:21 +01004182dnl sysinfo() may exist but not be Linux compatible.
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004183dnl On some FreeBSD systems it may depend on libsysinfo, try to link
Bram Moolenaar071d4272004-06-13 20:20:40 +00004184AC_MSG_CHECKING(for sysinfo)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004185AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004186[#include <sys/types.h>
4187#include <sys/sysinfo.h>],
4188[ struct sysinfo sinfo;
4189 int t;
4190
4191 (void)sysinfo(&sinfo);
4192 t = sinfo.totalram;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004193 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004194 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
4195 AC_MSG_RESULT(not usable))
4196
Bram Moolenaar914572a2007-05-01 11:37:47 +00004197dnl struct sysinfo may have the mem_unit field or not
4198AC_MSG_CHECKING(for sysinfo.mem_unit)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004199AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar914572a2007-05-01 11:37:47 +00004200[#include <sys/types.h>
4201#include <sys/sysinfo.h>],
4202[ struct sysinfo sinfo;
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02004203 sinfo.mem_unit = 1;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004204 ])],
Bram Moolenaar914572a2007-05-01 11:37:47 +00004205 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_MEM_UNIT),
4206 AC_MSG_RESULT(no))
4207
Bram Moolenaarf52f0602021-03-10 21:26:37 +01004208dnl struct sysinfo may have the uptime field or not
4209AC_MSG_CHECKING(for sysinfo.uptime)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004210AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaarf52f0602021-03-10 21:26:37 +01004211[#include <sys/types.h>
4212#include <sys/sysinfo.h>],
4213[ struct sysinfo sinfo;
4214 long ut;
4215
4216 (void)sysinfo(&sinfo);
4217 ut = sinfo.uptime;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004218 ])],
Bram Moolenaarf52f0602021-03-10 21:26:37 +01004219 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_UPTIME),
4220 AC_MSG_RESULT(no))
4221
Bram Moolenaar071d4272004-06-13 20:20:40 +00004222dnl sysconf() may exist but not support what we want to use
4223AC_MSG_CHECKING(for sysconf)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004224AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004225[#include <unistd.h>],
4226[ (void)sysconf(_SC_PAGESIZE);
4227 (void)sysconf(_SC_PHYS_PAGES);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004228 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004229 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
4230 AC_MSG_RESULT(not usable))
4231
Bram Moolenaar0e62a672021-02-25 17:17:56 +01004232dnl check if we have _SC_SIGSTKSZ via sysconf()
4233AC_MSG_CHECKING(for _SC_SIGSTKSZ via sysconf())
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004234AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar0e62a672021-02-25 17:17:56 +01004235[#include <unistd.h>],
4236[ (void)sysconf(_SC_SIGSTKSZ);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004237 ])],
Bram Moolenaar0e62a672021-02-25 17:17:56 +01004238 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF_SIGSTKSZ),
4239 AC_MSG_RESULT(not usable))
4240
Bram Moolenaar914703b2010-05-31 21:59:46 +02004241AC_CHECK_SIZEOF([int])
4242AC_CHECK_SIZEOF([long])
4243AC_CHECK_SIZEOF([time_t])
4244AC_CHECK_SIZEOF([off_t])
Bram Moolenaar644fdff2010-05-30 13:26:21 +02004245
Bram Moolenaara2aa31a2014-02-23 22:52:40 +01004246dnl Use different names to avoid clashing with other header files.
4247AC_DEFINE_UNQUOTED(VIM_SIZEOF_INT, [$ac_cv_sizeof_int])
4248AC_DEFINE_UNQUOTED(VIM_SIZEOF_LONG, [$ac_cv_sizeof_long])
4249
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004250dnl Make sure that uint32_t is really 32 bits unsigned.
4251AC_MSG_CHECKING([uint32_t is 32 bits])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004252AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004253#ifdef HAVE_STDINT_H
4254# include <stdint.h>
4255#endif
4256#ifdef HAVE_INTTYPES_H
4257# include <inttypes.h>
4258#endif
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01004259int main() {
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004260 uint32_t nr1 = (uint32_t)-1;
4261 uint32_t nr2 = (uint32_t)0xffffffffUL;
Bram Moolenaar52897832020-07-02 22:50:37 +02004262 if (sizeof(uint32_t) != 4 || nr1 != 0xffffffffUL || nr2 + 1 != 0) return 1;
4263 return 0;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004264}])],
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004265AC_MSG_RESULT(ok),
4266AC_MSG_ERROR([WRONG! uint32_t not defined correctly.]),
Bram Moolenaar323cb952011-12-14 19:22:34 +01004267AC_MSG_WARN([cannot check uint32_t when cross-compiling.]))
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004268
Bram Moolenaar446cb832008-06-24 21:56:24 +00004269dnl Check for memmove() before bcopy(), makes memmove() be used when both are
4270dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
4271
Bram Moolenaar071d4272004-06-13 20:20:40 +00004272[bcopy_test_prog='
Bram Moolenaar446cb832008-06-24 21:56:24 +00004273#include "confdefs.h"
4274#ifdef HAVE_STRING_H
4275# include <string.h>
4276#endif
4277#if STDC_HEADERS
4278# include <stdlib.h>
4279# include <stddef.h>
4280#endif
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01004281int main() {
Bram Moolenaar071d4272004-06-13 20:20:40 +00004282 char buf[10];
4283 strcpy(buf, "abcdefghi");
4284 mch_memmove(buf, buf + 2, 3);
4285 if (strncmp(buf, "ababcf", 6))
4286 exit(1);
4287 strcpy(buf, "abcdefghi");
4288 mch_memmove(buf + 2, buf, 3);
4289 if (strncmp(buf, "cdedef", 6))
4290 exit(1);
4291 exit(0); /* libc version works properly. */
4292}']
4293
Bram Moolenaar446cb832008-06-24 21:56:24 +00004294AC_CACHE_CHECK([whether memmove handles overlaps],[vim_cv_memmove_handles_overlap],
4295 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004296 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 +00004297 [
4298 vim_cv_memmove_handles_overlap=yes
4299 ],[
4300 vim_cv_memmove_handles_overlap=no
4301 ],[
4302 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memmove_handles_overlap')
4303 ])
4304 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00004305
Bram Moolenaar446cb832008-06-24 21:56:24 +00004306if test "x$vim_cv_memmove_handles_overlap" = "xyes" ; then
4307 AC_DEFINE(USEMEMMOVE)
4308else
4309 AC_CACHE_CHECK([whether bcopy handles overlaps],[vim_cv_bcopy_handles_overlap],
4310 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004311 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 +00004312 [
4313 vim_cv_bcopy_handles_overlap=yes
4314 ],[
4315 vim_cv_bcopy_handles_overlap=no
4316 ],[
4317 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_bcopy_handles_overlap')
4318 ])
4319 ])
4320
4321 if test "x$vim_cv_bcopy_handles_overlap" = "xyes" ; then
4322 AC_DEFINE(USEBCOPY)
4323 else
4324 AC_CACHE_CHECK([whether memcpy handles overlaps],[vim_cv_memcpy_handles_overlap],
4325 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004326 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 +00004327 [
4328 vim_cv_memcpy_handles_overlap=yes
4329 ],[
4330 vim_cv_memcpy_handles_overlap=no
4331 ],[
4332 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memcpy_handles_overlap')
4333 ])
4334 ])
4335
4336 if test "x$vim_cv_memcpy_handles_overlap" = "xyes" ; then
4337 AC_DEFINE(USEMEMCPY)
4338 fi
4339 fi
4340fi
4341
Bram Moolenaar071d4272004-06-13 20:20:40 +00004342
4343dnl Check for multibyte locale functions
4344dnl Find out if _Xsetlocale() is supported by libX11.
4345dnl Check if X_LOCALE should be defined.
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004346if test "x$with_x" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004347 cflags_save=$CFLAGS
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004348 libs_save=$LIBS
4349 LIBS="$LIBS $X_LIBS $GUI_LIB_LOC $GUI_X_LIBS $X_PRE_LIBS $X_LIB $X_EXTRA_LIBS"
4350 CFLAGS="$CFLAGS $X_CFLAGS"
4351
4352 AC_MSG_CHECKING(whether X_LOCALE needed)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004353 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <X11/Xlocale.h>],)],
4354 AC_LINK_IFELSE([AC_LANG_CALL([],[_Xsetlocale])], [AC_MSG_RESULT(yes)
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004355 AC_DEFINE(X_LOCALE)], AC_MSG_RESULT(no)),
4356 AC_MSG_RESULT(no))
4357
4358 AC_MSG_CHECKING(whether Xutf8SetWMProperties() can be used)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004359 AC_LINK_IFELSE([AC_LANG_CALL([],[Xutf8SetWMProperties])], [AC_MSG_RESULT(yes)
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004360 AC_DEFINE(HAVE_XUTF8SETWMPROPERTIES)], AC_MSG_RESULT(no))
4361
Bram Moolenaar071d4272004-06-13 20:20:40 +00004362 CFLAGS=$cflags_save
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004363 LIBS=$libs_save
Bram Moolenaar071d4272004-06-13 20:20:40 +00004364fi
4365
4366dnl Link with xpg4, it is said to make Korean locale working
4367AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,)
4368
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004369dnl Check how we can run ctags. Default to "ctags" when nothing works.
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02004370dnl Use --version to detect Exuberant ctags (preferred)
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004371dnl Add --fields=+S to get function signatures for omni completion.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004372dnl -t for typedefs (many ctags have this)
4373dnl -s for static functions (Elvis ctags only?)
4374dnl -v for variables. Dangerous, most ctags take this for 'vgrind style'.
4375dnl -i+m to test for older Exuberant ctags
4376AC_MSG_CHECKING(how to create tags)
4377test -f tags && mv tags tags.save
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004378if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004379 TAGPRG="ctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004380elif (eval exctags --version /dev/null | grep Exuberant) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004381 TAGPRG="exctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004382elif (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 +01004383 TAGPRG="exuberant-ctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004384else
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004385 TAGPRG="ctags"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004386 (eval etags /dev/null) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1 && TAGPRG="etags"
4387 (eval etags -c /dev/null) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1 && TAGPRG="etags -c"
4388 (eval ctags /dev/null) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1 && TAGPRG="ctags"
4389 (eval ctags -t /dev/null) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1 && TAGPRG="ctags -t"
4390 (eval ctags -ts /dev/null) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1 && TAGPRG="ctags -ts"
4391 (eval ctags -tvs /dev/null) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1 && TAGPRG="ctags -tvs"
4392 (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 +00004393fi
4394test -f tags.save && mv tags.save tags
4395AC_MSG_RESULT($TAGPRG) AC_SUBST(TAGPRG)
4396
4397dnl Check how we can run man with a section number
4398AC_MSG_CHECKING(how to run man with a section nr)
4399MANDEF="man"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004400(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 +00004401AC_MSG_RESULT($MANDEF)
4402if test "$MANDEF" = "man -s"; then
4403 AC_DEFINE(USEMAN_S)
4404fi
4405
4406dnl Check if gettext() is working and if it needs -lintl
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004407dnl We take care to base this on an empty LIBS: on some systems libelf would be
4408dnl in LIBS and implicitly take along libintl. The final LIBS would then not
4409dnl contain libintl, and the link step would fail due to -Wl,--as-needed.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004410AC_MSG_CHECKING(--disable-nls argument)
4411AC_ARG_ENABLE(nls,
4412 [ --disable-nls Don't support NLS (gettext()).], ,
4413 [enable_nls="yes"])
4414
4415if test "$enable_nls" = "yes"; then
4416 AC_MSG_RESULT(no)
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00004417
4418 INSTALL_LANGS=install-languages
4419 AC_SUBST(INSTALL_LANGS)
4420 INSTALL_TOOL_LANGS=install-tool-languages
4421 AC_SUBST(INSTALL_TOOL_LANGS)
4422
Bram Moolenaar071d4272004-06-13 20:20:40 +00004423 AC_CHECK_PROG(MSGFMT, msgfmt, msgfmt, )
4424 AC_MSG_CHECKING([for NLS])
4425 if test -f po/Makefile; then
4426 have_gettext="no"
4427 if test -n "$MSGFMT"; then
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004428 olibs=$LIBS
4429 LIBS=""
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004430 AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004431 [#include <libintl.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004432 [gettext("Test");])],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004433 AC_MSG_RESULT([gettext() works]); have_gettext="yes"; LIBS=$olibs,
4434 LIBS="-lintl"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004435 AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004436 [#include <libintl.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004437 [gettext("Test");])],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004438 AC_MSG_RESULT([gettext() works with -lintl]); have_gettext="yes";
4439 LIBS="$olibs -lintl",
Bram Moolenaar071d4272004-06-13 20:20:40 +00004440 AC_MSG_RESULT([gettext() doesn't work]);
4441 LIBS=$olibs))
4442 else
4443 AC_MSG_RESULT([msgfmt not found - disabled]);
4444 fi
Martin Tournoij7904fa42022-10-04 16:28:45 +01004445 if test $have_gettext = "yes" -a "x$features" != "xtiny"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004446 AC_DEFINE(HAVE_GETTEXT)
4447 MAKEMO=yes
4448 AC_SUBST(MAKEMO)
4449 dnl this was added in GNU gettext 0.10.36
4450 AC_CHECK_FUNCS(bind_textdomain_codeset)
4451 dnl _nl_msg_cat_cntr is required for GNU gettext
4452 AC_MSG_CHECKING([for _nl_msg_cat_cntr])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004453 AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004454 [#include <libintl.h>
4455 extern int _nl_msg_cat_cntr;],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004456 [++_nl_msg_cat_cntr;])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004457 AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_NL_MSG_CAT_CNTR),
4458 AC_MSG_RESULT([no]))
Bram Moolenaar26096cc2019-04-11 15:25:40 +02004459 AC_MSG_CHECKING([if msgfmt supports --desktop])
4460 MSGFMT_DESKTOP=
4461 if "$MSGFMT" --help | grep -e '--desktop' >/dev/null; then
Bram Moolenaar62a88f42019-06-07 20:44:40 +02004462 if "$MSGFMT" --version | grep '0.19.[[3-7]]$' >/dev/null; then
4463 dnl GNU gettext 0.19.7's --desktop is broken. We assume back to
4464 dnl 0.19.3 is also broken.
4465 AC_MSG_RESULT([broken])
4466 else
4467 AC_MSG_RESULT([yes])
4468 MSGFMT_DESKTOP="gvim.desktop vim.desktop"
4469 fi
Bram Moolenaar26096cc2019-04-11 15:25:40 +02004470 else
4471 AC_MSG_RESULT([no])
4472 fi
4473 AC_SUBST(MSGFMT_DESKTOP)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004474 fi
4475 else
4476 AC_MSG_RESULT([no "po/Makefile" - disabled]);
4477 fi
4478else
4479 AC_MSG_RESULT(yes)
4480fi
4481
4482dnl Check for dynamic linking loader
4483AC_CHECK_HEADER(dlfcn.h, DLL=dlfcn.h, [AC_CHECK_HEADER(dl.h, DLL=dl.h)])
4484if test x${DLL} = xdlfcn.h; then
4485 AC_DEFINE(HAVE_DLFCN_H, 1, [ Define if we have dlfcn.h. ])
4486 AC_MSG_CHECKING([for dlopen()])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004487 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004488 extern void* dlopen();
4489 dlopen();
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004490 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004491 AC_MSG_RESULT(yes);
4492 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4493 AC_MSG_RESULT(no);
4494 AC_MSG_CHECKING([for dlopen() in -ldl])
4495 olibs=$LIBS
4496 LIBS="$LIBS -ldl"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004497 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004498 extern void* dlopen();
4499 dlopen();
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004500 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004501 AC_MSG_RESULT(yes);
4502 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4503 AC_MSG_RESULT(no);
4504 LIBS=$olibs))
4505 dnl ReliantUNIX has dlopen() in libc but everything else in libdl
4506 dnl ick :-)
4507 AC_MSG_CHECKING([for dlsym()])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004508 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004509 extern void* dlsym();
4510 dlsym();
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004511 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004512 AC_MSG_RESULT(yes);
4513 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4514 AC_MSG_RESULT(no);
4515 AC_MSG_CHECKING([for dlsym() in -ldl])
4516 olibs=$LIBS
4517 LIBS="$LIBS -ldl"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004518 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004519 extern void* dlsym();
4520 dlsym();
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004521 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004522 AC_MSG_RESULT(yes);
4523 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4524 AC_MSG_RESULT(no);
4525 LIBS=$olibs))
4526elif test x${DLL} = xdl.h; then
4527 AC_DEFINE(HAVE_DL_H, 1, [ Define if we have dl.h. ])
4528 AC_MSG_CHECKING([for shl_load()])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004529 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004530 extern void* shl_load();
4531 shl_load();
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004532 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004533 AC_MSG_RESULT(yes);
4534 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4535 AC_MSG_RESULT(no);
4536 AC_MSG_CHECKING([for shl_load() in -ldld])
4537 olibs=$LIBS
4538 LIBS="$LIBS -ldld"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004539 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004540 extern void* shl_load();
4541 shl_load();
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004542 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004543 AC_MSG_RESULT(yes);
4544 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4545 AC_MSG_RESULT(no);
4546 LIBS=$olibs))
4547fi
4548AC_CHECK_HEADERS(setjmp.h)
4549
Bram Moolenaard0573012017-10-28 21:11:06 +02004550if test "x$MACOS_X" = "xyes" -a -n "$PERL"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004551 dnl -ldl must come after DynaLoader.a
4552 if echo $LIBS | grep -e '-ldl' >/dev/null; then
4553 LIBS=`echo $LIBS | sed s/-ldl//`
4554 PERL_LIBS="$PERL_LIBS -ldl"
4555 fi
4556fi
4557
Bram Moolenaard0573012017-10-28 21:11:06 +02004558if test "$MACOS_X" = "yes"; then
4559 AC_MSG_CHECKING([whether we need macOS frameworks])
Bram Moolenaar097148e2020-08-11 21:58:20 +02004560 if test "$MACOS_X_DARWIN" = "yes"; then
Bram Moolenaard0573012017-10-28 21:11:06 +02004561 if test "$features" = "tiny"; then
Yee Cheng Chin4314e4f2022-10-08 13:50:05 +01004562 dnl Since no FEAT_CLIPBOARD or FEAT_SOUND, no need for os_macosx.m.
Bram Moolenaard0573012017-10-28 21:11:06 +02004563 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_macosx.m++'`
4564 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_macosx.o++'`
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01004565 AC_MSG_RESULT([yes, we need CoreServices])
4566 LIBS="$LIBS -framework CoreServices"
Bram Moolenaard0573012017-10-28 21:11:06 +02004567 else
4568 AC_MSG_RESULT([yes, we need AppKit])
4569 LIBS="$LIBS -framework AppKit"
Bram Moolenaard0573012017-10-28 21:11:06 +02004570 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004571 else
Bram Moolenaard0573012017-10-28 21:11:06 +02004572 AC_MSG_RESULT([no])
Bram Moolenaar3437b912013-07-03 19:52:53 +02004573 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004574fi
4575
Bram Moolenaar3ae5fc92021-09-06 18:57:30 +02004576dnl On some systems REENTRANT needs to be defined. It should not hurt to use
4577dnl it everywhere.
4578if `echo "$CFLAGS" | grep -v D_REENTRANT >/dev/null`; then
4579 CFLAGS="$CFLAGS -D_REENTRANT"
4580fi
4581
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004582dnl gcc 3.1 changed the meaning of -MM. The only solution appears to be to
4583dnl use "-isystem" instead of "-I" for all non-Vim include dirs.
4584dnl But only when making dependencies, cproto and lint don't take "-isystem".
Bram Moolenaar32466aa2006-02-24 23:53:04 +00004585dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
4586dnl the number before the version number.
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004587DEPEND_CFLAGS_FILTER=
4588if test "$GCC" = yes; then
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004589 AC_MSG_CHECKING(for GCC 3 or later)
Bram Moolenaar348808f2020-02-07 20:50:07 +01004590 gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]][[0-9]]*\)\..*$/\1/g'`
Bram Moolenaarf740b292006-02-16 22:11:02 +00004591 if test "$gccmajor" -gt "2"; then
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004592 DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004593 AC_MSG_RESULT(yes)
4594 else
4595 AC_MSG_RESULT(no)
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004596 fi
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004597 dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
4598 dnl declared as char x[1] but actually longer. Introduced in gcc 4.0.
Bram Moolenaar56d1db32009-12-16 16:14:51 +00004599 dnl Also remove duplicate _FORTIFY_SOURCE arguments.
Bram Moolenaaraeabe052011-12-08 15:17:34 +01004600 dnl And undefine it first to avoid a warning.
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004601 AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
4602 if test "$gccmajor" -gt "3"; then
Zdenek Dohnal42196982023-01-18 16:09:51 +00004603 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/ *-Wp,-U_FORTIFY_SOURCE/ /g' -e 's/ *-U_FORTIFY_SOURCE//g' -e 's/$/ -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1/'`
4604 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/ *-Wp,-U_FORTIFY_SOURCE/ /g' -e 's/ *-U_FORTIFY_SOURCE//g'`
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004605 AC_MSG_RESULT(yes)
4606 else
4607 AC_MSG_RESULT(no)
4608 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +00004609fi
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004610AC_SUBST(DEPEND_CFLAGS_FILTER)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004611
Bram Moolenaarec0557f2018-01-31 14:41:37 +01004612dnl On some systems AC_SYS_LARGEFILE determines that -D_FILE_OFFSET_BITS=64
4613dnl isn't required, but the CFLAGS for some of the libraries we're using
4614dnl include the define. Since the define changes the size of some datatypes
4615dnl (e.g. ino_t and off_t), all of Vim's modules must be compiled with a
4616dnl consistent value. It's therefore safest to force the use of the define
4617dnl if it's present in any of the *_CFLAGS variables.
4618AC_MSG_CHECKING(whether we need to force -D_FILE_OFFSET_BITS=64)
Bram Moolenaar9ce42132018-04-11 22:19:36 +02004619if 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 +01004620 AC_MSG_RESULT(yes)
4621 AC_DEFINE(_FILE_OFFSET_BITS, 64)
4622else
4623 AC_MSG_RESULT(no)
4624fi
4625
Bram Moolenaar6cd42db2020-12-04 18:09:54 +01004626dnl $LDFLAGS is passed to glibtool in libvterm, it doesn't like a space
4627dnl between "-L" and the path that follows.
4628LDFLAGS=`echo "$LDFLAGS" | sed -e 's/-L /-L/g'`
4629
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004630dnl link.sh tries to avoid overlinking in a hackish way.
4631dnl At least GNU ld supports --as-needed which provides the same functionality
4632dnl at linker level. Let's use it.
4633AC_MSG_CHECKING(linker --as-needed support)
4634LINK_AS_NEEDED=
4635# Check if linker supports --as-needed and --no-as-needed options
4636if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
Natanael Copa761ead42021-05-15 14:25:37 +02004637 if ! echo "$LDFLAGS" | grep -q -- '-Wl,[[^[:space:]]]*--as-needed'; then
4638 LDFLAGS="$LDFLAGS -Wl,--as-needed"
4639 fi
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004640 LINK_AS_NEEDED=yes
4641fi
4642if test "$LINK_AS_NEEDED" = yes; then
4643 AC_MSG_RESULT(yes)
4644else
4645 AC_MSG_RESULT(no)
4646fi
4647AC_SUBST(LINK_AS_NEEDED)
4648
Bram Moolenaar77c19352012-06-13 19:19:41 +02004649# IBM z/OS reset CFLAGS for config.mk
4650if test "$zOSUnix" = "yes"; then
4651 CFLAGS="-D_ALL_SOURCE -Wc,float\(ieee\),dll"
4652fi
4653
Bram Moolenaar071d4272004-06-13 20:20:40 +00004654dnl write output files
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004655AC_CONFIG_FILES(auto/config.mk:config.mk.in)
4656AC_OUTPUT
Bram Moolenaar071d4272004-06-13 20:20:40 +00004657
4658dnl vim: set sw=2 tw=78 fo+=l: