blob: 8abec36b07ffc54c063a2f900cd724f8015dd5d3 [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
Illia Bobyra96d5442023-08-30 16:30:15 +02003dnl Process this file with autoconf 2.71 to produce "configure".
Bram Moolenaar071d4272004-06-13 20:20:40 +00004
Illia Bobyrf39842f2023-08-27 18:21:23 +02005AC_INIT
6AC_CONFIG_SRCDIR([vim.h])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01007AC_CONFIG_HEADERS(auto/config.h:config.h.in)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008
9dnl Being able to run configure means the system is Unix (compatible).
10AC_DEFINE(UNIX)
11AC_PROG_MAKE_SET
12
13dnl Checks for programs.
Illia Bobyra96d5442023-08-30 16:30:15 +020014AC_PROG_CC dnl required by almost everything
Bram Moolenaarc0394412017-04-20 20:20:23 +020015AC_PROG_CPP dnl required by header file checks
Illia Bobyrf39842f2023-08-27 18:21:23 +020016AC_PROG_EGREP dnl required by AC_EGREP_CPP
Bram Moolenaarc0394412017-04-20 20:20:23 +020017AC_PROG_FGREP dnl finds working grep -F
Bram Moolenaarc0394412017-04-20 20:20:23 +020018AC_PROG_AWK dnl required for "make html" in ../doc
Bram Moolenaar071d4272004-06-13 20:20:40 +000019
20dnl Don't strip if we don't have it
21AC_CHECK_PROG(STRIP, strip, strip, :)
22
Bram Moolenaar325b7a22004-07-05 15:58:32 +000023dnl Check for extension of executables
Bram Moolenaar071d4272004-06-13 20:20:40 +000024AC_EXEEXT
25
Bram Moolenaar446cb832008-06-24 21:56:24 +000026AC_HEADER_SYS_WAIT
27
Bram Moolenaar561f8a52018-04-17 22:02:45 +020028dnl Check that the C99 features that Vim uses are supported:
Bram Moolenaar22640082018-04-19 20:39:41 +020029if test x"$ac_cv_prog_cc_c99" != xno; then
30 dnl If the compiler doesn't explicitly support C99, then check
31 dnl for the specific features Vim uses
32
33 AC_TYPE_LONG_LONG_INT
34 if test "$ac_cv_type_long_long_int" = no; then
35 AC_MSG_FAILURE([Compiler does not support long long int])
36 fi
37
38 AC_MSG_CHECKING([if the compiler supports trailing commas])
39 trailing_commas=no
Bram Moolenaar1004b3d2022-06-05 19:51:55 +010040 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
Bram Moolenaar22640082018-04-19 20:39:41 +020041 enum {
42 one,
Bram Moolenaar1004b3d2022-06-05 19:51:55 +010043 };])],
Bram Moolenaar22640082018-04-19 20:39:41 +020044 [AC_MSG_RESULT(yes); trailing_commas=yes],
45 [AC_MSG_RESULT(no)])
46 if test "$trailing_commas" = no; then
47 AC_MSG_FAILURE([Compiler does not support trailing comma in enum])
48 fi
49
50 AC_MSG_CHECKING([if the compiler supports C++ comments])
51 slash_comments=no
Bram Moolenaar1004b3d2022-06-05 19:51:55 +010052 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
53 [// C++ comments?])],
Bram Moolenaar22640082018-04-19 20:39:41 +020054 [AC_MSG_RESULT(yes); slash_comments=yes],
55 [AC_MSG_RESULT(no)])
56 if test "$slash_comments" = no; then
57 AC_MSG_FAILURE([Compiler does not support C++ comments])
58 fi
59fi
Bram Moolenaar561f8a52018-04-17 22:02:45 +020060
Bram Moolenaar8f1dde52020-06-05 23:16:29 +020061dnl If $SOURCE_DATE_EPOCH is present in the environment, use that as the
62dnl "compiled" timestamp in :version's output. Attempt to get the formatted
63dnl date using GNU date syntax, BSD date syntax, and finally falling back to
64dnl just using the current time.
65if test -n "$SOURCE_DATE_EPOCH"; then
66 DATE_FMT="%b %d %Y %H:%M:%S"
67 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")
68 AC_DEFINE_UNQUOTED(BUILD_DATE, ["$BUILD_DATE"])
69 BUILD_DATE_MSG=-"echo -e '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\nNOTE: build date/time is fixed: $BUILD_DATE\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='"
70 AC_SUBST(BUILD_DATE_MSG)
71fi
72
Bram Moolenaarf788a062011-12-14 20:51:25 +010073dnl Check for the flag that fails if stuff are missing.
74
75AC_MSG_CHECKING(--enable-fail-if-missing argument)
76AC_ARG_ENABLE(fail_if_missing,
77 [ --enable-fail-if-missing Fail if dependencies on additional features
Bram Moolenaare5303952022-06-19 17:05:47 +010078 specified on the command line are missing.],
Bram Moolenaarf788a062011-12-14 20:51:25 +010079 [fail_if_missing="yes"],
80 [fail_if_missing="no"])
81AC_MSG_RESULT($fail_if_missing)
82
Bram Moolenaard2a05492018-07-27 22:35:15 +020083dnl Keep original value to check later.
84with_x_arg="$with_x"
85
Bram Moolenaar071d4272004-06-13 20:20:40 +000086dnl Set default value for CFLAGS if none is defined or it's empty
87if test -z "$CFLAGS"; then
88 CFLAGS="-O"
Bram Moolenaar4d8479b2021-01-31 14:36:06 +010089 test "$GCC" = yes && CFLAGS="-O2 -fno-strength-reduce -Wall -Wno-deprecated-declarations"
Bram Moolenaar071d4272004-06-13 20:20:40 +000090fi
Rose00d07e72023-05-06 18:07:14 +010091
Bram Moolenaar071d4272004-06-13 20:20:40 +000092if test "$GCC" = yes; then
Rose00d07e72023-05-06 18:07:14 +010093 dnl Method that should work for nearly all gcc versions.
Bram Moolenaarc8836f72014-04-12 13:12:24 +020094 gccversion=`$CC -dumpversion`
Bram Moolenaar910f66f2006-04-05 20:41:53 +000095 if test "x$gccversion" = "x"; then
96 dnl old method; fall-back for when -dumpversion doesn't work
Bram Moolenaarc8836f72014-04-12 13:12:24 +020097 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 +000098 fi
Rose00d07e72023-05-06 18:07:14 +010099
100 dnl Gcc version 4.0.1 was reported to cause trouble on Macintosh by Marcin
101 dnl Dalecki. For Mac with Intel the symptom reported is: malloc() reports
102 dnl double free. This happens in expand_filename(), because the optimizer
103 dnl swaps two blocks of code, both using "repl", that can't be swapped.
Bram Moolenaara5792f52005-11-23 21:25:05 +0000104 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
302else
303 AC_MSG_RESULT(no)
304fi
305
Bram Moolenaar39766a72013-11-03 00:41:00 +0100306dnl Mac OS X 10.9+ no longer include AvailabilityMacros.h in Carbon
307dnl so we need to include it to have access to version macros.
Bram Moolenaar18e54692013-11-03 20:26:31 +0100308AC_CHECK_HEADERS(AvailabilityMacros.h)
Evan Miller25448072022-12-30 10:42:23 +0000309# 10.5 and earlier lack dispatch
310AC_CHECK_HEADERS(dispatch/dispatch.h)
Bram Moolenaar39766a72013-11-03 00:41:00 +0100311
Bram Moolenaar071d4272004-06-13 20:20:40 +0000312AC_SUBST(OS_EXTRA_SRC)
313AC_SUBST(OS_EXTRA_OBJ)
314
315dnl Add /usr/local/lib to $LDFLAGS and /usr/local/include to CFLAGS.
316dnl Only when the directory exists and it wasn't there yet.
317dnl For gcc don't do this when it is already in the default search path.
Bram Moolenaar446cb832008-06-24 21:56:24 +0000318dnl Skip all of this when cross-compiling.
319if test "$cross_compiling" = no; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000320 AC_MSG_CHECKING(--with-local-dir argument)
Bram Moolenaar446cb832008-06-24 21:56:24 +0000321 have_local_include=''
322 have_local_lib=''
Bram Moolenaarc236c162008-07-13 17:41:49 +0000323 AC_ARG_WITH([local-dir], [ --with-local-dir=PATH search PATH instead of /usr/local for local libraries.
324 --without-local-dir do not search /usr/local for local libraries.], [
325 local_dir="$withval"
326 case "$withval" in
327 */*) ;;
328 no)
329 # avoid adding local dir to LDFLAGS and CPPFLAGS
Bram Moolenaare06c1882010-07-21 22:05:20 +0200330 have_local_include=yes
Bram Moolenaarc236c162008-07-13 17:41:49 +0000331 have_local_lib=yes
332 ;;
333 *) AC_MSG_ERROR(must pass path argument to --with-local-dir) ;;
334 esac
335 AC_MSG_RESULT($local_dir)
336 ], [
337 local_dir=/usr/local
338 AC_MSG_RESULT(Defaulting to $local_dir)
339 ])
340 if test "$GCC" = yes -a "$local_dir" != no; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000341 echo 'void f(){}' > conftest.c
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100342 dnl Removed -no-cpp-precomp, only needed for OS X 10.2 (Ben Fowler)
343 have_local_include=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/include"`
Bram Moolenaarc236c162008-07-13 17:41:49 +0000344 have_local_lib=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/lib"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000345 rm -f conftest.c conftest.o
Bram Moolenaar071d4272004-06-13 20:20:40 +0000346 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000347 if test -z "$have_local_lib" -a -d "${local_dir}/lib"; then
348 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 +0000349 if test "$tt" = "$LDFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000350 LDFLAGS="$LDFLAGS -L${local_dir}/lib"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000351 fi
352 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000353 if test -z "$have_local_include" -a -d "${local_dir}/include"; then
354 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 +0000355 if test "$tt" = "$CPPFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000356 CPPFLAGS="$CPPFLAGS -I${local_dir}/include"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000357 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000358 fi
359fi
360
361AC_MSG_CHECKING(--with-vim-name argument)
362AC_ARG_WITH(vim-name, [ --with-vim-name=NAME what to call the Vim executable],
363 VIMNAME="$withval"; AC_MSG_RESULT($VIMNAME),
Bram Moolenaare344bea2005-09-01 20:46:49 +0000364 VIMNAME="vim"; AC_MSG_RESULT(Defaulting to $VIMNAME))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000365AC_SUBST(VIMNAME)
366AC_MSG_CHECKING(--with-ex-name argument)
367AC_ARG_WITH(ex-name, [ --with-ex-name=NAME what to call the Ex executable],
368 EXNAME="$withval"; AC_MSG_RESULT($EXNAME),
369 EXNAME="ex"; AC_MSG_RESULT(Defaulting to ex))
370AC_SUBST(EXNAME)
371AC_MSG_CHECKING(--with-view-name argument)
372AC_ARG_WITH(view-name, [ --with-view-name=NAME what to call the View executable],
373 VIEWNAME="$withval"; AC_MSG_RESULT($VIEWNAME),
374 VIEWNAME="view"; AC_MSG_RESULT(Defaulting to view))
375AC_SUBST(VIEWNAME)
376
377AC_MSG_CHECKING(--with-global-runtime argument)
Bram Moolenaar9d302ad2018-12-21 11:48:51 +0100378AC_ARG_WITH(global-runtime, [ --with-global-runtime=DIR global runtime directory in 'runtimepath', comma-separated for multiple directories],
379 RUNTIME_GLOBAL="$withval"; AC_MSG_RESULT($withval),
Bram Moolenaar071d4272004-06-13 20:20:40 +0000380 AC_MSG_RESULT(no))
381
Bram Moolenaar9d302ad2018-12-21 11:48:51 +0100382if test "X$RUNTIME_GLOBAL" != "X"; then
383 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" }')
384 AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL, "$RUNTIME_GLOBAL")
385 AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL_AFTER, "$RUNTIME_GLOBAL_AFTER")
386fi
387
Bram Moolenaar071d4272004-06-13 20:20:40 +0000388AC_MSG_CHECKING(--with-modified-by argument)
389AC_ARG_WITH(modified-by, [ --with-modified-by=NAME name of who modified a release version],
390 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(MODIFIED_BY, "$withval"),
391 AC_MSG_RESULT(no))
392
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200393dnl Check for EBCDIC stolen from the LYNX port to z/OS Unix
Bram Moolenaar071d4272004-06-13 20:20:40 +0000394AC_MSG_CHECKING(if character set is EBCDIC)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +0100395AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ ],
Bram Moolenaar071d4272004-06-13 20:20:40 +0000396[ /* TryCompile function for CharSet.
397 Treat any failure as ASCII for compatibility with existing art.
398 Use compile-time rather than run-time tests for cross-compiler
399 tolerance. */
400#if '0'!=240
401make an error "Character set is not EBCDIC"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +0100402#endif ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +0000403[ # TryCompile action if true
404cf_cv_ebcdic=yes ],
405[ # TryCompile action if false
406cf_cv_ebcdic=no])
407# end of TryCompile ])
408# end of CacheVal CvEbcdic
409AC_MSG_RESULT($cf_cv_ebcdic)
410case "$cf_cv_ebcdic" in #(vi
411 yes) AC_DEFINE(EBCDIC)
412 line_break='"\\n"'
413 ;;
414 *) line_break='"\\012"';;
415esac
416AC_SUBST(line_break)
417
418if test "$cf_cv_ebcdic" = "yes"; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +0200419dnl If we have EBCDIC we most likely have z/OS Unix, let's test it!
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200420AC_MSG_CHECKING(for z/OS Unix)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000421case $vim_cv_uname_output in
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200422 OS/390) zOSUnix="yes";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000423 dnl If using cc the environment variable _CC_CCMODE must be
424 dnl set to "1", so that some compiler extensions are enabled.
425 dnl If using c89 the environment variable is named _CC_C89MODE.
426 dnl Note: compile with c89 never tested.
427 if test "$CC" = "cc"; then
428 ccm="$_CC_CCMODE"
429 ccn="CC"
430 else
431 if test "$CC" = "c89"; then
432 ccm="$_CC_C89MODE"
433 ccn="C89"
434 else
435 ccm=1
436 fi
437 fi
438 if test "$ccm" != "1"; then
439 echo ""
440 echo "------------------------------------------"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200441 echo " On z/OS Unix, the environment variable"
Bram Moolenaar77c19352012-06-13 19:19:41 +0200442 echo " _CC_${ccn}MODE must be set to \"1\"!"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000443 echo " Do:"
444 echo " export _CC_${ccn}MODE=1"
445 echo " and then call configure again."
446 echo "------------------------------------------"
447 exit 1
448 fi
Bram Moolenaar77c19352012-06-13 19:19:41 +0200449 # Set CFLAGS for configure process.
450 # This will be reset later for config.mk.
451 # Use haltonmsg to force error for missing H files.
452 CFLAGS="$CFLAGS -D_ALL_SOURCE -Wc,float(ieee),haltonmsg(3296)";
453 LDFLAGS="$LDFLAGS -Wl,EDIT=NO"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000454 AC_MSG_RESULT(yes)
455 ;;
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200456 *) zOSUnix="no";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000457 AC_MSG_RESULT(no)
458 ;;
459esac
460fi
461
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200462dnl Set QUOTESED. Needs additional backslashes on zOS
463if test "$zOSUnix" = "yes"; then
Bram Moolenaarabcbb0e2020-12-23 12:33:42 +0100464 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\\\\\&/g' -e 's/\\\\\\\\\"/\"/' -e 's/\\\\\\\\\";\$\$/\";/' -e 's/ */ /g'"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200465else
Bram Moolenaarabcbb0e2020-12-23 12:33:42 +0100466 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\&/g' -e 's/\\\\\"/\"/' -e 's/\\\\\";\$\$/\";/' -e 's/ */ /g'"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200467fi
468AC_SUBST(QUOTESED)
469
470
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200471dnl Link with -lsmack for Smack stuff; if not found
472AC_MSG_CHECKING(--disable-smack argument)
473AC_ARG_ENABLE(smack,
474 [ --disable-smack Do not check for Smack support.],
475 , enable_smack="yes")
476if test "$enable_smack" = "yes"; then
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200477 AC_MSG_RESULT(no)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200478 AC_CHECK_HEADER([linux/xattr.h], true, enable_smack="no")
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200479else
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200480 AC_MSG_RESULT(yes)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200481fi
482if test "$enable_smack" = "yes"; then
zeertzjq6de4e582023-09-30 14:19:14 +0200483 AC_CHECK_HEADER([sys/xattr.h], true, enable_smack="no")
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200484fi
485if test "$enable_smack" = "yes"; then
486 AC_MSG_CHECKING(for XATTR_NAME_SMACKEXEC in linux/xattr.h)
487 AC_EGREP_CPP(XATTR_NAME_SMACKEXEC, [#include <linux/xattr.h>],
488 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +0200489 AC_MSG_RESULT(no); enable_smack="no")
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200490fi
491if test "$enable_smack" = "yes"; then
492 AC_CHECK_LIB(attr, setxattr,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200493 [LIBS="$LIBS -lattr"
494 found_smack="yes"
495 AC_DEFINE(HAVE_SMACK)])
Bram Moolenaar588ebeb2008-05-07 17:09:24 +0000496fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000497
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200498dnl When smack was found don't search for SELinux
499if test "x$found_smack" = "x"; then
500 dnl Link with -lselinux for SELinux stuff; if not found
501 AC_MSG_CHECKING(--disable-selinux argument)
502 AC_ARG_ENABLE(selinux,
503 [ --disable-selinux Do not check for SELinux support.],
504 , enable_selinux="yes")
505 if test "$enable_selinux" = "yes"; then
506 AC_MSG_RESULT(no)
507 AC_CHECK_LIB(selinux, is_selinux_enabled,
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100508 [AC_CHECK_HEADER(selinux/selinux.h,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200509 [LIBS="$LIBS -lselinux"
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100510 AC_DEFINE(HAVE_SELINUX)])])
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200511 else
512 AC_MSG_RESULT(yes)
513 fi
514fi
515
Christian Brabandte085dfd2023-09-30 12:49:18 +0200516dnl enable xattr support
517AC_MSG_CHECKING(--enable-xattr argument)
518AC_ARG_ENABLE(xattr,
519 [ --disable-xattr Do not check for XATTR support.],
520 , enable_xattr="yes")
521if test "$enable_xattr" = "yes"; then
522 AC_MSG_RESULT(yes)
zeertzjq6de4e582023-09-30 14:19:14 +0200523 AC_CHECK_HEADER([sys/xattr.h], [AC_DEFINE(HAVE_XATTR)])
Christian Brabandte085dfd2023-09-30 12:49:18 +0200524else
525 AC_MSG_RESULT(no)
526fi
527
Bram Moolenaar071d4272004-06-13 20:20:40 +0000528dnl Check user requested features.
529
530AC_MSG_CHECKING(--with-features argument)
Martin Tournoij25f3a142022-10-08 19:26:41 +0100531AC_ARG_WITH(features, [ --with-features=TYPE tiny, normal or huge (default: huge)],
Bram Moolenaar071d4272004-06-13 20:20:40 +0000532 features="$withval"; AC_MSG_RESULT($features),
Bram Moolenaar23c4f712016-01-20 22:11:59 +0100533 features="huge"; AC_MSG_RESULT(Defaulting to huge))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000534
Martin Tournoij7904fa42022-10-04 16:28:45 +0100535dnl "small" is supported for backwards compatibility, now an alias for "tiny"
Martin Tournoij25f3a142022-10-08 19:26:41 +0100536dnl "big" is supported for backwards compatibility, now an alias for "normal"
Martin Tournoij7904fa42022-10-04 16:28:45 +0100537case "$features" in
Martin Tournoij25f3a142022-10-08 19:26:41 +0100538 small) features="tiny" ;;
539 big) features="normal" ;;
Martin Tournoij7904fa42022-10-04 16:28:45 +0100540esac
541
Bram Moolenaar071d4272004-06-13 20:20:40 +0000542dovimdiff=""
543dogvimdiff=""
544case "$features" in
545 tiny) AC_DEFINE(FEAT_TINY) ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000546 normal) AC_DEFINE(FEAT_NORMAL) dovimdiff="installvimdiff";
547 dogvimdiff="installgvimdiff" ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000548 huge) AC_DEFINE(FEAT_HUGE) dovimdiff="installvimdiff";
549 dogvimdiff="installgvimdiff" ;;
550 *) AC_MSG_RESULT([Sorry, $features is not supported]) ;;
551esac
552
553AC_SUBST(dovimdiff)
554AC_SUBST(dogvimdiff)
555
Martin Tournoij7904fa42022-10-04 16:28:45 +0100556if test "x$features" = "xtiny"; then
Bram Moolenaar12471262022-01-18 11:11:25 +0000557 has_eval=no
558else
559 has_eval=yes
560fi
561
Bram Moolenaar071d4272004-06-13 20:20:40 +0000562AC_MSG_CHECKING(--with-compiledby argument)
563AC_ARG_WITH(compiledby, [ --with-compiledby=NAME name to show in :version message],
564 compiledby="$withval"; AC_MSG_RESULT($withval),
565 compiledby=""; AC_MSG_RESULT(no))
566AC_SUBST(compiledby)
567
568AC_MSG_CHECKING(--disable-xsmp argument)
569AC_ARG_ENABLE(xsmp,
570 [ --disable-xsmp Disable XSMP session management],
571 , enable_xsmp="yes")
572
573if test "$enable_xsmp" = "yes"; then
574 AC_MSG_RESULT(no)
575 AC_MSG_CHECKING(--disable-xsmp-interact argument)
576 AC_ARG_ENABLE(xsmp-interact,
577 [ --disable-xsmp-interact Disable XSMP interaction],
578 , enable_xsmp_interact="yes")
579 if test "$enable_xsmp_interact" = "yes"; then
580 AC_MSG_RESULT(no)
581 AC_DEFINE(USE_XSMP_INTERACT)
582 else
583 AC_MSG_RESULT(yes)
584 fi
585else
586 AC_MSG_RESULT(yes)
587fi
588
Bram Moolenaar67ffb412022-01-08 13:36:57 +0000589AC_MSG_CHECKING([diff feature])
Martin Tournoij7904fa42022-10-04 16:28:45 +0100590if test "x$features" = "xtiny"; then
Bram Moolenaar67ffb412022-01-08 13:36:57 +0000591 AC_MSG_RESULT([disabled in $features version])
592else
593 AC_MSG_RESULT(enabled)
594 AC_DEFINE(FEAT_DIFF)
595 XDIFF_OBJS_USED="\$(XDIFF_OBJS)"
596 AC_SUBST(XDIFF_OBJS_USED)
597fi
598
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200599dnl Check for Lua feature.
600AC_MSG_CHECKING(--enable-luainterp argument)
601AC_ARG_ENABLE(luainterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200602 [ --enable-luainterp[=OPTS] Include Lua interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200603 [enable_luainterp="no"])
604AC_MSG_RESULT($enable_luainterp)
605
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200606if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then
Bram Moolenaar12471262022-01-18 11:11:25 +0000607 if test "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +0100608 AC_MSG_ERROR([cannot use Lua with tiny features])
Bram Moolenaar3c124e32016-01-31 14:36:58 +0100609 fi
610
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200611 dnl -- find the lua executable
612 AC_SUBST(vi_cv_path_lua)
613
614 AC_MSG_CHECKING(--with-lua-prefix argument)
615 AC_ARG_WITH(lua_prefix,
616 [ --with-lua-prefix=PFX Prefix where Lua is installed.],
617 with_lua_prefix="$withval"; AC_MSG_RESULT($with_lua_prefix),
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200618 with_lua_prefix="";AC_MSG_RESULT(no))
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200619
620 if test "X$with_lua_prefix" != "X"; then
621 vi_cv_path_lua_pfx="$with_lua_prefix"
622 else
623 AC_MSG_CHECKING(LUA_PREFIX environment var)
624 if test "X$LUA_PREFIX" != "X"; then
625 AC_MSG_RESULT("$LUA_PREFIX")
626 vi_cv_path_lua_pfx="$LUA_PREFIX"
627 else
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200628 AC_MSG_RESULT([not set, default to /usr])
629 vi_cv_path_lua_pfx="/usr"
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200630 fi
631 fi
632
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200633 AC_MSG_CHECKING(--with-luajit)
634 AC_ARG_WITH(luajit,
635 [ --with-luajit Link with LuaJIT instead of Lua.],
636 [vi_cv_with_luajit="$withval"],
637 [vi_cv_with_luajit="no"])
638 AC_MSG_RESULT($vi_cv_with_luajit)
639
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200640 LUA_INC=
641 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200642 if test "x$vi_cv_with_luajit" != "xno"; then
643 dnl -- try to find LuaJIT executable
644 AC_PATH_PROG(vi_cv_path_luajit, luajit)
645 if test "X$vi_cv_path_luajit" != "X"; then
646 dnl -- find LuaJIT version
647 AC_CACHE_CHECK(LuaJIT version, vi_cv_version_luajit,
ichizokbddc6ad2023-08-29 20:54:32 +0200648 [ 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 +0200649 AC_CACHE_CHECK(Lua version of LuaJIT, vi_cv_version_lua_luajit,
650 [ vi_cv_version_lua_luajit=`${vi_cv_path_luajit} -e "print(_VERSION)" | sed 's/.* //'` ])
651 vi_cv_path_lua="$vi_cv_path_luajit"
652 vi_cv_version_lua="$vi_cv_version_lua_luajit"
653 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200654 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200655 dnl -- try to find Lua executable
656 AC_PATH_PROG(vi_cv_path_plain_lua, lua)
657 if test "X$vi_cv_path_plain_lua" != "X"; then
658 dnl -- find Lua version
659 AC_CACHE_CHECK(Lua version, vi_cv_version_plain_lua,
660 [ vi_cv_version_plain_lua=`${vi_cv_path_plain_lua} -e "print(_VERSION)" | sed 's/.* //'` ])
661 fi
662 vi_cv_path_lua="$vi_cv_path_plain_lua"
663 vi_cv_version_lua="$vi_cv_version_plain_lua"
664 fi
665 if test "x$vi_cv_with_luajit" != "xno" && test "X$vi_cv_version_luajit" != "X"; then
666 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 +0100667 if test -f "$vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200668 AC_MSG_RESULT(yes)
669 LUA_INC=/luajit-$vi_cv_version_luajit
670 fi
671 fi
672 if test "X$LUA_INC" = "X"; then
673 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)
Bram Moolenaar49222be2015-12-11 18:11:30 +0100674 if test -f "$vi_cv_path_lua_pfx/include/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200675 AC_MSG_RESULT(yes)
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200676 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200677 AC_MSG_RESULT(no)
678 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 +0100679 if test -f "$vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200680 AC_MSG_RESULT(yes)
681 LUA_INC=/lua$vi_cv_version_lua
682 else
683 AC_MSG_RESULT(no)
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200684
685 # Detect moonjit:
686 # https://groups.google.com/forum/#!topic/vim_use/O0vek60WuTk
687 lua_suf=/moonjit-2.3
688 inc_path="$vi_cv_path_lua_pfx/include"
Bram Moolenaarad4dc832020-04-20 16:21:53 +0200689 for dir in "$inc_path"/moonjit-[[0-9]]* ; do
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200690 if test -d "$dir" ; then
Bram Moolenaara79a8942020-12-17 20:50:25 +0100691 lua_suf=`basename "$dir"`
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200692 lua_suf="/$lua_suf"
693 break
694 fi
695 done
696 AC_MSG_CHECKING(if lua.h can be found in $inc_path$lua_suf)
697 if test -f "$inc_path$lua_suf/lua.h"; then
698 AC_MSG_RESULT(yes)
699 LUA_INC=$lua_suf
700 else
701 AC_MSG_RESULT(no)
702 vi_cv_path_lua_pfx=
703 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200704 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200705 fi
706 fi
707 fi
708
709 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200710 if test "x$vi_cv_with_luajit" != "xno"; then
711 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
712 if test "X$multiarch" != "X"; then
713 lib_multiarch="lib/${multiarch}"
714 else
715 lib_multiarch="lib"
716 fi
717 if test "X$vi_cv_version_lua" = "X"; then
718 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit"
719 else
720 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit-$vi_cv_version_lua"
721 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200722 else
Bram Moolenaar869113f2023-03-31 21:29:00 +0100723 dnl Test alternate lib location including version
724 if test -d "${vi_cv_path_lua_pfx}/lib/lua$vi_cv_version_lua"; then
725 LUALIBDIR="lib/lua$vi_cv_version_lua"
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200726 else
Bram Moolenaar869113f2023-03-31 21:29:00 +0100727 LUALIBDIR=lib
728 fi
729 if test "X$LUA_INC" != "X"; then
730 dnl Test alternate name including version
731 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${LUALIBDIR} -llua$vi_cv_version_lua"
732 else
733 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${LUALIBDIR} -llua"
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200734 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200735 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200736 if test "$enable_luainterp" = "dynamic"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200737 lua_ok="yes"
738 else
739 AC_MSG_CHECKING([if link with ${LUA_LIBS} is sane])
740 libs_save=$LIBS
741 LIBS="$LIBS $LUA_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +0100742 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200743 AC_MSG_RESULT(yes); lua_ok="yes",
744 AC_MSG_RESULT(no); lua_ok="no"; LUA_LIBS="")
745 LIBS=$libs_save
746 fi
747 if test "x$lua_ok" = "xyes"; then
748 LUA_CFLAGS="-I${vi_cv_path_lua_pfx}/include${LUA_INC}"
749 LUA_SRC="if_lua.c"
750 LUA_OBJ="objects/if_lua.o"
751 LUA_PRO="if_lua.pro"
752 AC_DEFINE(FEAT_LUA)
753 fi
754 if test "$enable_luainterp" = "dynamic"; then
755 if test "x$vi_cv_with_luajit" != "xno"; then
756 luajit="jit"
757 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200758 if test -f "${vi_cv_path_lua_pfx}/bin/cyglua-${vi_cv_version_lua}.dll"; then
759 vi_cv_dll_name_lua="cyglua-${vi_cv_version_lua}.dll"
760 else
Bram Moolenaard0573012017-10-28 21:11:06 +0200761 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200762 ext="dylib"
763 indexes=""
764 else
765 ext="so"
766 indexes=".0 .1 .2 .3 .4 .5 .6 .7 .8 .9"
767 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
768 if test "X$multiarch" != "X"; then
769 lib_multiarch="lib/${multiarch}"
770 fi
Bram Moolenaar768baac2013-04-15 14:44:57 +0200771 fi
772 dnl Determine the sover for the current version, but fallback to
773 dnl liblua${vi_cv_version_lua}.so if no sover-versioned file is found.
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200774 AC_MSG_CHECKING(if liblua${luajit}*.${ext}* can be found in $vi_cv_path_lua_pfx)
Bram Moolenaar768baac2013-04-15 14:44:57 +0200775 for subdir in "${lib_multiarch}" lib64 lib; do
776 if test -z "$subdir"; then
777 continue
778 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200779 for sover in "${vi_cv_version_lua}.${ext}" "-${vi_cv_version_lua}.${ext}" \
780 ".${vi_cv_version_lua}.${ext}" ".${ext}.${vi_cv_version_lua}"; do
781 for i in $indexes ""; do
782 if test -f "${vi_cv_path_lua_pfx}/${subdir}/liblua${luajit}${sover}$i"; then
Bram Moolenaar768baac2013-04-15 14:44:57 +0200783 sover2="$i"
784 break 3
785 fi
786 done
Bram Moolenaar07e1da62013-02-06 19:49:43 +0100787 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200788 sover=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200789 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200790 if test "X$sover" = "X"; then
791 AC_MSG_RESULT(no)
792 lua_ok="no"
793 vi_cv_dll_name_lua="liblua${luajit}.${ext}"
794 else
795 AC_MSG_RESULT(yes)
796 lua_ok="yes"
797 vi_cv_dll_name_lua="liblua${luajit}${sover}$sover2"
798 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200799 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200800 AC_DEFINE(DYNAMIC_LUA)
801 LUA_LIBS=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200802 LUA_CFLAGS="-DDYNAMIC_LUA_DLL=\\\"${vi_cv_dll_name_lua}\\\" $LUA_CFLAGS"
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200803 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200804 if test "X$LUA_CFLAGS$LUA_LIBS" != "X" && \
Bram Moolenaard0573012017-10-28 21:11:06 +0200805 test "x$MACOS_X" = "xyes" && test "x$vi_cv_with_luajit" != "xno" && \
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000806 test "$vim_cv_uname_m_output" = "x86_64"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200807 dnl OSX/x64 requires these flags. See http://luajit.org/install.html
808 LUA_LIBS="-pagezero_size 10000 -image_base 100000000 $LUA_LIBS"
809 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200810 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200811 if test "$fail_if_missing" = "yes" -a "$lua_ok" != "yes"; then
Bram Moolenaarf788a062011-12-14 20:51:25 +0100812 AC_MSG_ERROR([could not configure lua])
813 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200814 AC_SUBST(LUA_SRC)
815 AC_SUBST(LUA_OBJ)
816 AC_SUBST(LUA_PRO)
817 AC_SUBST(LUA_LIBS)
818 AC_SUBST(LUA_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +0000819 AC_SUBST(LUA_CFLAGS_EXTRA)
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200820fi
821
822
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000823dnl Check for MzScheme feature.
824AC_MSG_CHECKING(--enable-mzschemeinterp argument)
825AC_ARG_ENABLE(mzschemeinterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200826 [ --enable-mzschemeinterp Include MzScheme interpreter.], ,
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000827 [enable_mzschemeinterp="no"])
828AC_MSG_RESULT($enable_mzschemeinterp)
829
830if test "$enable_mzschemeinterp" = "yes"; then
831 dnl -- find the mzscheme executable
832 AC_SUBST(vi_cv_path_mzscheme)
833
834 AC_MSG_CHECKING(--with-plthome argument)
835 AC_ARG_WITH(plthome,
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000836 [ --with-plthome=PLTHOME Use PLTHOME.],
837 with_plthome="$withval"; AC_MSG_RESULT($with_plthome),
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000838 with_plthome="";AC_MSG_RESULT("no"))
839
840 if test "X$with_plthome" != "X"; then
841 vi_cv_path_mzscheme_pfx="$with_plthome"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100842 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000843 else
844 AC_MSG_CHECKING(PLTHOME environment var)
845 if test "X$PLTHOME" != "X"; then
846 AC_MSG_RESULT("$PLTHOME")
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000847 vi_cv_path_mzscheme_pfx="$PLTHOME"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100848 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000849 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000850 AC_MSG_RESULT(not set)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000851 dnl -- try to find MzScheme executable
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000852 AC_PATH_PROG(vi_cv_path_mzscheme, mzscheme)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000853
854 dnl resolve symbolic link, the executable is often elsewhere and there
855 dnl are no links for the include files.
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000856 if test "X$vi_cv_path_mzscheme" != "X"; then
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000857 lsout=`ls -l $vi_cv_path_mzscheme`
858 if echo "$lsout" | grep -e '->' >/dev/null 2>/dev/null; then
859 vi_cv_path_mzscheme=`echo "$lsout" | sed 's/.*-> \(.*\)/\1/'`
860 fi
861 fi
862
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000863 if test "X$vi_cv_path_mzscheme" != "X"; then
864 dnl -- find where MzScheme thinks it was installed
865 AC_CACHE_CHECK(MzScheme install prefix,vi_cv_path_mzscheme_pfx,
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000866 dnl different versions of MzScheme differ in command line processing
867 dnl use universal approach
868 echo "(display (simplify-path \
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000869 (build-path (call-with-values \
870 (lambda () (split-path (find-system-path (quote exec-file)))) \
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000871 (lambda (base name must-be-dir?) base)) (quote up))))" > mzdirs.scm
872 dnl Remove a trailing slash
873 [ vi_cv_path_mzscheme_pfx=`${vi_cv_path_mzscheme} -r mzdirs.scm | \
874 sed -e 's+/$++'` ])
875 rm -f mzdirs.scm
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000876 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000877 fi
878 fi
879
880 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100881 AC_MSG_CHECKING(for racket include directory)
882 SCHEME_INC=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-include-dir))) (when (path? p) (display p)))'`
883 if test "X$SCHEME_INC" != "X"; then
884 AC_MSG_RESULT(${SCHEME_INC})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000885 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100886 AC_MSG_RESULT(not found)
887 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include)
888 if test -f "$vi_cv_path_mzscheme_pfx/include/scheme.h"; then
889 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000890 AC_MSG_RESULT(yes)
Bram Moolenaard7afed32007-05-06 13:26:41 +0000891 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000892 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100893 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt)
894 if test -f "$vi_cv_path_mzscheme_pfx/include/plt/scheme.h"; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000895 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100896 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000897 else
898 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100899 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket)
900 if test -f "$vi_cv_path_mzscheme_pfx/include/racket/scheme.h"; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100901 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100902 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100903 else
904 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100905 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/)
906 if test -f /usr/include/plt/scheme.h; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100907 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100908 SCHEME_INC=/usr/include/plt
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100909 else
910 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100911 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/racket/)
912 if test -f /usr/include/racket/scheme.h; then
913 AC_MSG_RESULT(yes)
914 SCHEME_INC=/usr/include/racket
915 else
916 AC_MSG_RESULT(no)
917 vi_cv_path_mzscheme_pfx=
918 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100919 fi
920 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000921 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000922 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000923 fi
924 fi
925
926 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100927
928 AC_MSG_CHECKING(for racket lib directory)
929 SCHEME_LIB=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-lib-dir))) (when (path? p) (display p)))'`
930 if test "X$SCHEME_LIB" != "X"; then
931 AC_MSG_RESULT(${SCHEME_LIB})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000932 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100933 AC_MSG_RESULT(not found)
934 fi
935
936 for path in "${vi_cv_path_mzscheme_pfx}/lib" "${SCHEME_LIB}"; do
937 if test "X$path" != "X"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200938 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100939 MZSCHEME_LIBS="-framework Racket"
940 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
941 elif test -f "${path}/libmzscheme3m.a"; then
942 MZSCHEME_LIBS="${path}/libmzscheme3m.a"
943 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
944 elif test -f "${path}/libracket3m.a"; then
945 MZSCHEME_LIBS="${path}/libracket3m.a"
Bram Moolenaar588d2412020-10-03 14:24:19 +0200946 if test -f "${path}/librktio.a"; then
947 MZSCHEME_LIBS="${MZSCHEME_LIBS} ${path}/librktio.a"
948 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100949 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
950 elif test -f "${path}/libracket.a"; then
951 MZSCHEME_LIBS="${path}/libracket.a ${path}/libmzgc.a"
952 elif test -f "${path}/libmzscheme.a"; then
953 MZSCHEME_LIBS="${path}/libmzscheme.a ${path}/libmzgc.a"
954 else
955 dnl Using shared objects
956 if test -f "${path}/libmzscheme3m.so"; then
957 MZSCHEME_LIBS="-L${path} -lmzscheme3m"
958 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
959 elif test -f "${path}/libracket3m.so"; then
960 MZSCHEME_LIBS="-L${path} -lracket3m"
961 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
962 elif test -f "${path}/libracket.so"; then
963 MZSCHEME_LIBS="-L${path} -lracket -lmzgc"
964 else
965 dnl try next until last
966 if test "$path" != "$SCHEME_LIB"; then
967 continue
968 fi
969 MZSCHEME_LIBS="-L${path} -lmzscheme -lmzgc"
970 fi
971 if test "$GCC" = yes; then
972 dnl Make Vim remember the path to the library. For when it's not in
973 dnl $LD_LIBRARY_PATH.
974 MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${path}"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000975 elif test "$vim_cv_uname_output" = SunOS &&
976 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100977 MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${path}"
978 fi
979 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000980 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100981 if test "X$MZSCHEME_LIBS" != "X"; then
982 break
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +0000983 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100984 done
985
986 AC_MSG_CHECKING([if racket requires -pthread])
987 if test "X$SCHEME_LIB" != "X" && $FGREP -e -pthread "$SCHEME_LIB/buildinfo" >/dev/null ; then
988 AC_MSG_RESULT(yes)
989 MZSCHEME_LIBS="${MZSCHEME_LIBS} -pthread"
990 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -pthread"
991 else
992 AC_MSG_RESULT(no)
993 fi
994
995 AC_MSG_CHECKING(for racket config directory)
996 SCHEME_CONFIGDIR=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-config-dir))) (when (path? p) (display p)))'`
997 if test "X$SCHEME_CONFIGDIR" != "X"; then
998 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DMZSCHEME_CONFIGDIR='\"${SCHEME_CONFIGDIR}\"'"
999 AC_MSG_RESULT(${SCHEME_CONFIGDIR})
1000 else
1001 AC_MSG_RESULT(not found)
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001002 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001003
1004 AC_MSG_CHECKING(for racket collects directory)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +01001005 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))))'`
1006 if test "X$SCHEME_COLLECTS" = "X"; then
1007 if test -d "$vi_cv_path_mzscheme_pfx/lib/plt/collects"; then
1008 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/plt/
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001009 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +01001010 if test -d "$vi_cv_path_mzscheme_pfx/lib/racket/collects"; then
1011 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/racket/
Bram Moolenaar75676462013-01-30 14:55:42 +01001012 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +01001013 if test -d "$vi_cv_path_mzscheme_pfx/share/racket/collects"; then
1014 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/
1015 else
1016 if test -d "$vi_cv_path_mzscheme_pfx/collects"; then
1017 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/
1018 fi
Bram Moolenaar75676462013-01-30 14:55:42 +01001019 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001020 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +01001021 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +00001022 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001023 if test "X$SCHEME_COLLECTS" != "X" ; then
1024 AC_MSG_RESULT(${SCHEME_COLLECTS})
1025 else
1026 AC_MSG_RESULT(not found)
1027 fi
1028
1029 AC_MSG_CHECKING(for mzscheme_base.c)
1030 if test -f "${SCHEME_COLLECTS}collects/scheme/base.ss" ; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001031 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +01001032 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
1033 MZSCHEME_MOD="++lib scheme/base"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +01001034 else
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001035 if test -f "${SCHEME_COLLECTS}collects/scheme/base.rkt" ; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +01001036 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +01001037 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
1038 MZSCHEME_MOD="++lib scheme/base"
1039 else
1040 if test -f "${SCHEME_COLLECTS}collects/racket/base.rkt" ; then
1041 MZSCHEME_EXTRA="mzscheme_base.c"
1042 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/raco ctool"
1043 MZSCHEME_MOD=""
1044 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +01001045 fi
1046 fi
1047 if test "X$MZSCHEME_EXTRA" != "X" ; then
1048 dnl need to generate bytecode for MzScheme base
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001049 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE"
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001050 AC_MSG_RESULT(needed)
1051 else
1052 AC_MSG_RESULT(not needed)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001053 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001054
Bram Moolenaar9e902192013-07-17 18:58:11 +02001055 dnl On Ubuntu this fixes "undefined reference to symbol 'ffi_type_void'".
1056 AC_CHECK_LIB(ffi, ffi_type_void, [MZSCHEME_LIBS="$MZSCHEME_LIBS -lffi"])
1057
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001058 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -I${SCHEME_INC} \
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001059 -DMZSCHEME_COLLECTS='\"${SCHEME_COLLECTS}collects\"'"
Bram Moolenaar9e902192013-07-17 18:58:11 +02001060
1061 dnl Test that we can compile a simple program with these CFLAGS and LIBS.
1062 AC_MSG_CHECKING([if compile and link flags for MzScheme are sane])
1063 cflags_save=$CFLAGS
1064 libs_save=$LIBS
1065 CFLAGS="$CFLAGS $MZSCHEME_CFLAGS"
1066 LIBS="$LIBS $MZSCHEME_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001067 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaar9e902192013-07-17 18:58:11 +02001068 AC_MSG_RESULT(yes); mzs_ok=yes,
1069 AC_MSG_RESULT(no: MZSCHEME DISABLED); mzs_ok=no)
1070 CFLAGS=$cflags_save
1071 LIBS=$libs_save
1072 if test $mzs_ok = yes; then
1073 MZSCHEME_SRC="if_mzsch.c"
1074 MZSCHEME_OBJ="objects/if_mzsch.o"
1075 MZSCHEME_PRO="if_mzsch.pro"
1076 AC_DEFINE(FEAT_MZSCHEME)
1077 else
1078 MZSCHEME_CFLAGS=
1079 MZSCHEME_LIBS=
1080 MZSCHEME_EXTRA=
1081 MZSCHEME_MZC=
1082 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001083 fi
1084 AC_SUBST(MZSCHEME_SRC)
1085 AC_SUBST(MZSCHEME_OBJ)
1086 AC_SUBST(MZSCHEME_PRO)
1087 AC_SUBST(MZSCHEME_LIBS)
1088 AC_SUBST(MZSCHEME_CFLAGS)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001089 AC_SUBST(MZSCHEME_EXTRA)
1090 AC_SUBST(MZSCHEME_MZC)
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001091fi
1092
1093
Bram Moolenaar071d4272004-06-13 20:20:40 +00001094AC_MSG_CHECKING(--enable-perlinterp argument)
1095AC_ARG_ENABLE(perlinterp,
Bram Moolenaare06c1882010-07-21 22:05:20 +02001096 [ --enable-perlinterp[=OPTS] Include Perl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001097 [enable_perlinterp="no"])
1098AC_MSG_RESULT($enable_perlinterp)
Bram Moolenaare06c1882010-07-21 22:05:20 +02001099if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00001100 if test "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +01001101 AC_MSG_ERROR([cannot use Perl with tiny features])
Bram Moolenaar3c124e32016-01-31 14:36:58 +01001102 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001103 AC_SUBST(vi_cv_path_perl)
1104 AC_PATH_PROG(vi_cv_path_perl, perl)
1105 if test "X$vi_cv_path_perl" != "X"; then
1106 AC_MSG_CHECKING(Perl version)
1107 if $vi_cv_path_perl -e 'require 5.003_01' >/dev/null 2>/dev/null; then
1108 eval `$vi_cv_path_perl -V:usethreads`
Bram Moolenaare06c1882010-07-21 22:05:20 +02001109 eval `$vi_cv_path_perl -V:libperl`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001110 if test "X$usethreads" = "XUNKNOWN" -o "X$usethreads" = "Xundef"; then
1111 badthreads=no
1112 else
1113 if $vi_cv_path_perl -e 'require 5.6.0' >/dev/null 2>/dev/null; then
1114 eval `$vi_cv_path_perl -V:use5005threads`
1115 if test "X$use5005threads" = "XUNKNOWN" -o "X$use5005threads" = "Xundef"; then
1116 badthreads=no
1117 else
1118 badthreads=yes
1119 AC_MSG_RESULT(>>> Perl > 5.6 with 5.5 threads cannot be used <<<)
1120 fi
1121 else
1122 badthreads=yes
1123 AC_MSG_RESULT(>>> Perl 5.5 with threads cannot be used <<<)
1124 fi
1125 fi
1126 if test $badthreads = no; then
1127 AC_MSG_RESULT(OK)
1128 eval `$vi_cv_path_perl -V:shrpenv`
1129 if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04
1130 shrpenv=""
1131 fi
1132 vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlibexp}'`
1133 AC_SUBST(vi_cv_perllib)
Bram Moolenaard5f62b12014-08-17 17:05:44 +02001134 vi_cv_perl_extutils=unknown_perl_extutils_path
Zdenek Dohnal1b1c9f22023-11-02 20:19:06 +01001135
1136 AC_MSG_CHECKING(--with-xsubpp path)
1137 vi_cv_perl_xsubpp=
1138 AC_ARG_WITH(xsubpp, [ --with-xsubpp=PATH path to the xsubpp command], [
1139 if test -f "$withval"
1140 then
1141 vi_cv_perl_xsubpp="$withval"
1142 fi
1143 ])
1144
1145 if test "x$vi_cv_perl_xsubpp" = "x"
1146 then
1147 for extutils_rel_path in ExtUtils vendor_perl/ExtUtils; do
1148 xsubpp_path="$vi_cv_perllib/$extutils_rel_path/xsubpp"
1149 if test -f "$xsubpp_path"; then
1150 vi_cv_perl_xsubpp="$xsubpp_path"
1151 fi
1152 done
1153 fi
1154
1155 if test "x$vi_cv_perl_xsubpp" = "x"
1156 then
1157 AC_MSG_RESULT(empty)
1158 else
1159 AC_MSG_RESULT($vi_cv_perl_xsubpp)
1160 fi
Bram Moolenaard5f62b12014-08-17 17:05:44 +02001161 AC_SUBST(vi_cv_perl_xsubpp)
Zdenek Dohnal1b1c9f22023-11-02 20:19:06 +01001162
Bram Moolenaar071d4272004-06-13 20:20:40 +00001163 dnl Remove "-fno-something", it breaks using cproto.
Bram Moolenaar280a8682015-06-21 13:41:08 +02001164 dnl Remove "-fdebug-prefix-map", it isn't supported by clang.
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001165 dnl Remove "FORTIFY_SOURCE", it will be defined twice.
Christian Brabandt2f9aef42024-02-12 23:12:26 +01001166 dnl Remove -pipe and -Wxxx, it confuses cproto
1167 dnl Remove -flto[=auto], it causes link failures for clang
Bram Moolenaar071d4272004-06-13 20:20:40 +00001168 perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001169 -e 'ccflags;perl_inc;print"\n"' | sed -e 's/-fno[[^ ]]*//' \
1170 -e 's/-fdebug-prefix-map[[^ ]]*//g' \
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001171 -e 's/-pipe //' \
Christian Brabandt2f9aef42024-02-12 23:12:26 +01001172 -e 's/-flto\(=auto\)\? //' \
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001173 -e 's/-W[[^ ]]*//g' \
1174 -e 's/-D_FORTIFY_SOURCE=.//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001175 dnl Remove "-lc", it breaks on FreeBSD when using "-pthread".
Christian Brabandt9c0ff472024-05-11 20:18:21 +02001176 dnl Remove -specs=<file-path>, the hardened flags cause relocation errors
Bram Moolenaar071d4272004-06-13 20:20:40 +00001177 perllibs=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed -e 'ldopts' | \
1178 sed -e '/Warning/d' -e '/Note (probably harmless)/d' \
Christian Brabandt9c0ff472024-05-11 20:18:21 +02001179 -e 's/-specs=[[^ ]*]//g' \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001180 -e 's/-bE:perl.exp//' -e 's/-lc //'`
1181 dnl Don't add perl lib to $LIBS: if it's not in LD_LIBRARY_PATH
1182 dnl a test in configure may fail because of that.
Christian Brabandt9c0ff472024-05-11 20:18:21 +02001183 dnl Remove -specs=<file-path>, the hardened flags cause relocation errors
Bram Moolenaar071d4272004-06-13 20:20:40 +00001184 perlldflags=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed \
Christian Brabandt9c0ff472024-05-11 20:18:21 +02001185 -e 'ccdlflags' | sed -e 's/-bE:perl.exp//' \
1186 -e 's/-specs=[[^ ]*]//g' `
Bram Moolenaar071d4272004-06-13 20:20:40 +00001187
1188 dnl check that compiling a simple program still works with the flags
1189 dnl added for Perl.
1190 AC_MSG_CHECKING([if compile and link flags for Perl are sane])
1191 cflags_save=$CFLAGS
1192 libs_save=$LIBS
1193 ldflags_save=$LDFLAGS
1194 CFLAGS="$CFLAGS $perlcppflags"
1195 LIBS="$LIBS $perllibs"
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001196 perlldflags=`echo "$perlldflags" | sed -e 's/^ *//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001197 LDFLAGS="$perlldflags $LDFLAGS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001198 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00001199 AC_MSG_RESULT(yes); perl_ok=yes,
1200 AC_MSG_RESULT(no: PERL DISABLED); perl_ok=no)
1201 CFLAGS=$cflags_save
1202 LIBS=$libs_save
1203 LDFLAGS=$ldflags_save
1204 if test $perl_ok = yes; then
1205 if test "X$perlcppflags" != "X"; then
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001206 PERL_CFLAGS=$perlcppflags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001207 fi
1208 if test "X$perlldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001209 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$perlldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001210 LDFLAGS="$perlldflags $LDFLAGS"
1211 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001212 fi
1213 PERL_LIBS=$perllibs
1214 PERL_SRC="auto/if_perl.c if_perlsfio.c"
1215 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o"
1216 PERL_PRO="if_perl.pro if_perlsfio.pro"
1217 AC_DEFINE(FEAT_PERL)
1218 fi
1219 fi
1220 else
1221 AC_MSG_RESULT(>>> too old; need Perl version 5.003_01 or later <<<)
1222 fi
1223 fi
1224
Bram Moolenaard0573012017-10-28 21:11:06 +02001225 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00001226 dnl Mac OS X 10.2 or later
Bram Moolenaar071d4272004-06-13 20:20:40 +00001227 dir=/System/Library/Perl
1228 darwindir=$dir/darwin
1229 if test -d $darwindir; then
1230 PERL=/usr/bin/perl
1231 else
1232 dnl Mac OS X 10.3
1233 dir=/System/Library/Perl/5.8.1
1234 darwindir=$dir/darwin-thread-multi-2level
1235 if test -d $darwindir; then
1236 PERL=/usr/bin/perl
1237 fi
1238 fi
1239 if test -n "$PERL"; then
1240 PERL_DIR="$dir"
1241 PERL_CFLAGS="-DFEAT_PERL -I$darwindir/CORE"
1242 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o $darwindir/auto/DynaLoader/DynaLoader.a"
1243 PERL_LIBS="-L$darwindir/CORE -lperl"
1244 fi
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001245 dnl Perl on Mac OS X 10.5 adds "-arch" flags but these should only
1246 dnl be included if requested by passing --with-mac-arch to
1247 dnl configure, so strip these flags first (if present)
1248 PERL_LIBS=`echo "$PERL_LIBS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
1249 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 +00001250 fi
Bram Moolenaare06c1882010-07-21 22:05:20 +02001251 if test "$enable_perlinterp" = "dynamic"; then
1252 if test "$perl_ok" = "yes" -a "X$libperl" != "X"; then
1253 AC_DEFINE(DYNAMIC_PERL)
1254 PERL_CFLAGS="-DDYNAMIC_PERL_DLL=\\\"$libperl\\\" $PERL_CFLAGS"
Christian Brabandt55460da2023-08-29 21:31:28 +02001255 PERL_LIBS=""
Bram Moolenaare06c1882010-07-21 22:05:20 +02001256 fi
1257 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001258
1259 if test "$fail_if_missing" = "yes" -a "$perl_ok" != "yes"; then
1260 AC_MSG_ERROR([could not configure perl])
1261 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001262fi
1263AC_SUBST(shrpenv)
1264AC_SUBST(PERL_SRC)
1265AC_SUBST(PERL_OBJ)
1266AC_SUBST(PERL_PRO)
1267AC_SUBST(PERL_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00001268AC_SUBST(PERL_CFLAGS_EXTRA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001269AC_SUBST(PERL_LIBS)
1270
1271AC_MSG_CHECKING(--enable-pythoninterp argument)
1272AC_ARG_ENABLE(pythoninterp,
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001273 [ --enable-pythoninterp[=OPTS] Include Python interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001274 [enable_pythoninterp="no"])
1275AC_MSG_RESULT($enable_pythoninterp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001276if test "$enable_pythoninterp" = "yes" -o "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00001277 if test "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +01001278 AC_MSG_ERROR([cannot use Python with tiny features])
Bram Moolenaar0b105412014-11-30 13:34:23 +01001279 fi
1280
Bram Moolenaar071d4272004-06-13 20:20:40 +00001281 dnl -- find the python executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001282 AC_MSG_CHECKING(--with-python-command argument)
1283 AC_SUBST(vi_cv_path_python)
1284 AC_ARG_WITH(python-command, [ --with-python-command=NAME name of the Python 2 command (default: python2 or python)],
1285 vi_cv_path_python="$withval"; AC_MSG_RESULT($vi_cv_path_python),
1286 AC_MSG_RESULT(no))
1287
1288 if test "X$vi_cv_path_python" = "X"; then
1289 AC_PATH_PROGS(vi_cv_path_python, python2 python)
1290 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001291 if test "X$vi_cv_path_python" != "X"; then
1292
1293 dnl -- get its version number
1294 AC_CACHE_CHECK(Python version,vi_cv_var_python_version,
1295 [[vi_cv_var_python_version=`
1296 ${vi_cv_path_python} -c 'import sys; print sys.version[:3]'`
1297 ]])
1298
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001299 dnl -- it must be at least version 2.3
1300 AC_MSG_CHECKING(Python is 2.3 or better)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001301 if ${vi_cv_path_python} -c \
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001302 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001303 then
1304 AC_MSG_RESULT(yep)
1305
1306 dnl -- find where python thinks it was installed
1307 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python_pfx,
1308 [ vi_cv_path_python_pfx=`
1309 ${vi_cv_path_python} -c \
1310 "import sys; print sys.prefix"` ])
1311
1312 dnl -- and where it thinks it runs
1313 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python_epfx,
1314 [ vi_cv_path_python_epfx=`
1315 ${vi_cv_path_python} -c \
1316 "import sys; print sys.exec_prefix"` ])
1317
1318 dnl -- python's internal library path
1319
1320 AC_CACHE_VAL(vi_cv_path_pythonpath,
1321 [ vi_cv_path_pythonpath=`
1322 unset PYTHONPATH;
1323 ${vi_cv_path_python} -c \
1324 "import sys, string; print string.join(sys.path,':')"` ])
1325
1326 dnl -- where the Python implementation library archives are
1327
1328 AC_ARG_WITH(python-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001329 [ --with-python-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001330 [ vi_cv_path_python_conf="${withval}"; have_python_config_dir=1 ] )
Bram Moolenaar071d4272004-06-13 20:20:40 +00001331
1332 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python_conf,
1333 [
1334 vi_cv_path_python_conf=
Bram Moolenaarac499e32013-06-02 19:14:17 +02001335 d=`${vi_cv_path_python} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBPL')"`
1336 if test -d "$d" && test -f "$d/config.c"; then
1337 vi_cv_path_python_conf="$d"
1338 else
1339 for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
1340 for subdir in lib64 lib share; do
1341 d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
1342 if test -d "$d" && test -f "$d/config.c"; then
1343 vi_cv_path_python_conf="$d"
1344 fi
1345 done
Bram Moolenaar071d4272004-06-13 20:20:40 +00001346 done
Bram Moolenaarac499e32013-06-02 19:14:17 +02001347 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001348 ])
1349
1350 PYTHON_CONFDIR="${vi_cv_path_python_conf}"
1351
1352 if test "X$PYTHON_CONFDIR" = "X"; then
1353 AC_MSG_RESULT([can't find it!])
1354 else
1355
1356 dnl -- we need to examine Python's config/Makefile too
1357 dnl see what the interpreter is built from
1358 AC_CACHE_VAL(vi_cv_path_python_plibs,
1359 [
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001360 pwd=`pwd`
1361 tmp_mkf="$pwd/config-PyMake$$"
1362 cat -- "${PYTHON_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001363__:
Bram Moolenaar218116c2010-05-20 21:46:00 +02001364 @echo "python_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001365 @echo "python_LIBS='$(LIBS)'"
1366 @echo "python_SYSLIBS='$(SYSLIBS)'"
1367 @echo "python_LINKFORSHARED='$(LINKFORSHARED)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001368 @echo "python_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001369 @echo "python_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001370 @echo "python_PYTHONFRAMEWORK='$(PYTHONFRAMEWORK)'"
1371 @echo "python_PYTHONFRAMEWORKPREFIX='$(PYTHONFRAMEWORKPREFIX)'"
1372 @echo "python_PYTHONFRAMEWORKINSTALLDIR='$(PYTHONFRAMEWORKINSTALLDIR)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001373eof
1374 dnl -- delete the lines from make about Entering/Leaving directory
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001375 eval "`cd ${PYTHON_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1376 rm -f -- "${tmp_mkf}"
Bram Moolenaard0573012017-10-28 21:11:06 +02001377 if test "x$MACOS_X" = "xyes" && test -n "${python_PYTHONFRAMEWORK}" && ${vi_cv_path_python} -c \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001378 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then
1379 vi_cv_path_python_plibs="-framework Python"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001380 if test "x${vi_cv_path_python}" != "x/usr/bin/python" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
1381 vi_cv_path_python_plibs="-F${python_PYTHONFRAMEWORKPREFIX} -framework Python"
1382 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001383 else
Bram Moolenaar9ce42132018-04-11 22:19:36 +02001384 vi_cv_path_python_plibs="-L${PYTHON_CONFDIR} -lpython${vi_cv_var_python_version}"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001385 dnl -- Check if the path contained in python_LINKFORSHARED is
1386 dnl usable for vim build. If not, make and try other
1387 dnl candidates.
Bram Moolenaara161e262015-03-24 15:14:27 +01001388 if test -n "${python_LINKFORSHARED}" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
Bram Moolenaar6c927552015-03-24 12:21:33 +01001389 python_link_symbol=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]].*/\1/'`
1390 python_link_path=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]][[ \t]]*\(.*\)/\2/'`
1391 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1392 dnl -- The path looks relative. Guess the absolute one using
1393 dnl the prefix and try that.
1394 python_link_path="${python_PYTHONFRAMEWORKPREFIX}/${python_link_path}"
1395 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1396 dnl -- A last resort.
1397 python_link_path="${python_PYTHONFRAMEWORKINSTALLDIR}/Versions/${vi_cv_var_python_version}/${python_PYTHONFRAMEWORK}"
1398 dnl -- No check is done. The last word is left to the
1399 dnl "sanity" test on link flags that follows shortly.
1400 fi
1401 python_LINKFORSHARED="${python_link_symbol} ${python_link_path}"
1402 fi
1403 fi
Bram Moolenaar218116c2010-05-20 21:46:00 +02001404 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 +00001405 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1406 vi_cv_path_python_plibs=`echo $vi_cv_path_python_plibs | sed s/-ltermcap//`
1407 fi
1408 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001409 AC_CACHE_CHECK(Python's dll name,vi_cv_dll_name_python,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001410 [
1411 if test "X$python_DLLLIBRARY" != "X"; then
1412 vi_cv_dll_name_python="$python_DLLLIBRARY"
1413 else
1414 vi_cv_dll_name_python="$python_INSTSONAME"
1415 fi
1416 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00001417
1418 PYTHON_LIBS="${vi_cv_path_python_plibs}"
1419 if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001420 PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001421 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001422 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 +00001423 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001424 if test "X$have_python_config_dir" = "X1" -a "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001425 dnl Define PYTHON_HOME if --with-python-config-dir was used
1426 PYTHON_CFLAGS="${PYTHON_CFLAGS} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'"
1427
1428 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001429 PYTHON_SRC="if_python.c"
Bram Moolenaar9bdb9a02012-07-25 16:32:08 +02001430 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001431
1432 dnl On FreeBSD linking with "-pthread" is required to use threads.
1433 dnl _THREAD_SAFE must be used for compiling then.
1434 dnl The "-pthread" is added to $LIBS, so that the following check for
1435 dnl sigaltstack() will look in libc_r (it's there in libc!).
1436 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1437 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1438 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1439 AC_MSG_CHECKING([if -pthread should be used])
1440 threadsafe_flag=
1441 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001442 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001443 if test "$vim_cv_uname_output" != Darwin; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001444 test "$GCC" = yes && threadsafe_flag="-pthread"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001445 if test "$vim_cv_uname_output" = FreeBSD; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001446 threadsafe_flag="-D_THREAD_SAFE"
1447 thread_lib="-pthread"
1448 fi
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001449 if test "$vim_cv_uname_output" = SunOS; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001450 threadsafe_flag="-pthreads"
1451 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001452 fi
1453 libs_save_old=$LIBS
1454 if test -n "$threadsafe_flag"; then
1455 cflags_save=$CFLAGS
1456 CFLAGS="$CFLAGS $threadsafe_flag"
1457 LIBS="$LIBS $thread_lib"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001458 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001459 AC_MSG_RESULT(yes); PYTHON_CFLAGS="$PYTHON_CFLAGS $threadsafe_flag",
Bram Moolenaar071d4272004-06-13 20:20:40 +00001460 AC_MSG_RESULT(no); LIBS=$libs_save_old
1461 )
1462 CFLAGS=$cflags_save
1463 else
1464 AC_MSG_RESULT(no)
1465 fi
1466
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001467 dnl Check that compiling a simple program still works with the flags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001468 dnl added for Python.
1469 AC_MSG_CHECKING([if compile and link flags for Python are sane])
1470 cflags_save=$CFLAGS
1471 libs_save=$LIBS
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001472 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001473 LIBS="$LIBS $PYTHON_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001474 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00001475 AC_MSG_RESULT(yes); python_ok=yes,
1476 AC_MSG_RESULT(no: PYTHON DISABLED); python_ok=no)
1477 CFLAGS=$cflags_save
1478 LIBS=$libs_save
1479 if test $python_ok = yes; then
1480 AC_DEFINE(FEAT_PYTHON)
1481 else
1482 LIBS=$libs_save_old
1483 PYTHON_SRC=
1484 PYTHON_OBJ=
1485 PYTHON_LIBS=
1486 PYTHON_CFLAGS=
1487 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001488 fi
1489 else
1490 AC_MSG_RESULT(too old)
1491 fi
1492 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001493
1494 if test "$fail_if_missing" = "yes" -a "$python_ok" != "yes"; then
1495 AC_MSG_ERROR([could not configure python])
1496 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001497fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001498
Bram Moolenaar071d4272004-06-13 20:20:40 +00001499AC_SUBST(PYTHON_LIBS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001500AC_SUBST(PYTHON_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00001501AC_SUBST(PYTHON_CFLAGS_EXTRA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001502AC_SUBST(PYTHON_SRC)
1503AC_SUBST(PYTHON_OBJ)
1504
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001505
1506AC_MSG_CHECKING(--enable-python3interp argument)
1507AC_ARG_ENABLE(python3interp,
Bram Moolenaar8008b632017-07-18 21:33:20 +02001508 [ --enable-python3interp[=OPTS] Include Python3 interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001509 [enable_python3interp="no"])
1510AC_MSG_RESULT($enable_python3interp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001511if test "$enable_python3interp" = "yes" -o "$enable_python3interp" = "dynamic"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00001512 if test "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +01001513 AC_MSG_ERROR([cannot use Python with tiny features])
Bram Moolenaar0b105412014-11-30 13:34:23 +01001514 fi
1515
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001516 dnl -- find the python3 executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001517 AC_MSG_CHECKING(--with-python3-command argument)
1518 AC_SUBST(vi_cv_path_python3)
1519 AC_ARG_WITH(python3-command, [ --with-python3-command=NAME name of the Python 3 command (default: python3 or python)],
1520 vi_cv_path_python3="$withval"; AC_MSG_RESULT($vi_cv_path_python3),
1521 AC_MSG_RESULT(no))
1522
1523 if test "X$vi_cv_path_python3" = "X"; then
1524 AC_PATH_PROGS(vi_cv_path_python3, python3 python)
1525 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001526 if test "X$vi_cv_path_python3" != "X"; then
1527
1528 dnl -- get its version number
1529 AC_CACHE_CHECK(Python version,vi_cv_var_python3_version,
1530 [[vi_cv_var_python3_version=`
Bram Moolenaar23c01922021-05-21 11:43:58 +02001531 ${vi_cv_path_python3} -c 'import sys; print("{}.{}".format(sys.version_info.major, sys.version_info.minor))'`
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001532 ]])
1533
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001534 dnl -- it must be at least version 3
1535 AC_MSG_CHECKING(Python is 3.0 or better)
1536 if ${vi_cv_path_python3} -c \
1537 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.0)"
1538 then
1539 AC_MSG_RESULT(yep)
Bram Moolenaar456f2bb2011-06-12 21:37:13 +02001540
Yee Cheng Chinc13b3d12023-08-20 21:18:38 +02001541 dnl -- get the stable ABI version if passed in
Ken Takata1c032e32024-08-11 18:41:41 +02001542 python3_stable_abi_default=3.8
Yee Cheng Chinc13b3d12023-08-20 21:18:38 +02001543 AC_MSG_CHECKING(--with-python3-stable-abi argument)
1544 AC_SUBST(vi_cv_var_python3_stable_abi)
Ken Takata1c032e32024-08-11 18:41:41 +02001545 AC_ARG_WITH(python3-stable-abi, [ --with-python3-stable-abi=VERSION stable ABI version to target (default: 3.8)],
1546 [
Christian Brabandt3f7024c2024-08-23 18:39:08 +02001547 if test "X$withval" = "Xyes"; then
1548 vi_cv_var_python3_stable_abi=$python3_stable_abi_default
1549 else
1550 vi_cv_var_python3_stable_abi="$withval"
1551 fi
Ken Takatadc2c75c2024-08-24 16:27:50 +02001552 AC_MSG_RESULT($vi_cv_var_python3_stable_abi)],
1553 AC_MSG_RESULT(no))
Christian Brabandt3f7024c2024-08-23 18:39:08 +02001554 if test "X$vi_cv_var_python3_stable_abi" != "X"; then
Yee Cheng Chinc13b3d12023-08-20 21:18:38 +02001555 AC_CACHE_VAL(vi_cv_var_python3_stable_abi_hex,
1556 [
1557 vi_cv_var_python3_stable_abi_hex=`
1558 ${vi_cv_path_python3} -c \
1559 "major_minor='${vi_cv_var_python3_stable_abi}'.split('.'); print('0x{0:X}'.format( (int(major_minor.__getitem__(0))<<24) + (int(major_minor.__getitem__(1))<<16) ))"` ])
Yee Cheng Chine7d79eb2023-09-16 13:38:26 +02001560 if test "X$vi_cv_var_python3_stable_abi_hex" = "X"; then
Yee Cheng Chinc13b3d12023-08-20 21:18:38 +02001561 AC_MSG_ERROR([can't parse Python 3 stable ABI version. It should be "<major>.<minor>"])
1562 fi
1563 fi
1564
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001565 dnl -- get abiflags for python 3.2 or higher (PEP 3149)
1566 AC_CACHE_CHECK(Python's abiflags,vi_cv_var_python3_abiflags,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001567 [
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001568 vi_cv_var_python3_abiflags=
1569 if ${vi_cv_path_python3} -c \
1570 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)"
1571 then
Bram Moolenaare5303952022-06-19 17:05:47 +01001572 vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001573 "import sys; print(sys.abiflags)"`
1574 fi ])
Bram Moolenaare5303952022-06-19 17:05:47 +01001575
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001576 dnl -- find where python3 thinks it was installed
1577 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx,
1578 [ vi_cv_path_python3_pfx=`
1579 ${vi_cv_path_python3} -c \
1580 "import sys; print(sys.prefix)"` ])
Bram Moolenaare5303952022-06-19 17:05:47 +01001581
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001582 dnl -- and where it thinks it runs
1583 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx,
1584 [ vi_cv_path_python3_epfx=`
1585 ${vi_cv_path_python3} -c \
1586 "import sys; print(sys.exec_prefix)"` ])
Bram Moolenaare5303952022-06-19 17:05:47 +01001587
Illia Bobyr74e1dad2023-08-27 18:26:54 +02001588 dnl -- python3's include path
1589 AC_CACHE_CHECK(Python's include path,vi_cv_path_python3_include,
1590 [ vi_cv_path_python3_include=`
1591 ${vi_cv_path_python3} -c \
1592 "import sysconfig; print(sysconfig.get_path(\"include\"))"` ])
1593
1594 dnl -- python3's platform include path
1595 AC_CACHE_CHECK(Python's include path,vi_cv_path_python3_platinclude,
1596 [ vi_cv_path_python3_platinclude=`
1597 ${vi_cv_path_python3} -c \
1598 "import sysconfig; print(sysconfig.get_path(\"platinclude\"))"` ])
1599
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001600 dnl -- python3's internal library path
Bram Moolenaare5303952022-06-19 17:05:47 +01001601
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001602 AC_CACHE_VAL(vi_cv_path_python3path,
1603 [ vi_cv_path_python3path=`
1604 unset PYTHONPATH;
1605 ${vi_cv_path_python3} -c \
1606 "import sys, string; print(':'.join(sys.path))"` ])
Bram Moolenaare5303952022-06-19 17:05:47 +01001607
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001608 dnl -- where the Python implementation library archives are
Bram Moolenaare5303952022-06-19 17:05:47 +01001609
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001610 AC_ARG_WITH(python3-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001611 [ --with-python3-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001612 [ vi_cv_path_python3_conf="${withval}"; have_python3_config_dir=1 ] )
Bram Moolenaare5303952022-06-19 17:05:47 +01001613
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001614 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf,
1615 [
1616 vi_cv_path_python3_conf=
Bram Moolenaarfee496d2013-07-12 20:07:24 +02001617 config_dir="config-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Zdenek Dohnal31e299c2021-06-10 18:50:55 +02001618 d=`${vi_cv_path_python3} -c "import sysconfig; print(sysconfig.get_config_var('LIBPL'))" 2> /dev/null`
1619 if test "x$d" = "x"; then
1620 d=`${vi_cv_path_python3} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBPL'))"`
1621 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001622 if test -d "$d" && test -f "$d/config.c"; then
1623 vi_cv_path_python3_conf="$d"
1624 else
1625 for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do
1626 for subdir in lib64 lib share; do
1627 d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}"
1628 if test -d "$d" && test -f "$d/config.c"; then
1629 vi_cv_path_python3_conf="$d"
1630 fi
1631 done
1632 done
1633 fi
1634 ])
Bram Moolenaare5303952022-06-19 17:05:47 +01001635
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001636 PYTHON3_CONFDIR="${vi_cv_path_python3_conf}"
Bram Moolenaare5303952022-06-19 17:05:47 +01001637
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001638 if test "X$PYTHON3_CONFDIR" = "X"; then
1639 AC_MSG_RESULT([can't find it!])
1640 else
Bram Moolenaare5303952022-06-19 17:05:47 +01001641
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001642 dnl -- we need to examine Python's config/Makefile too
1643 dnl see what the interpreter is built from
1644 AC_CACHE_VAL(vi_cv_path_python3_plibs,
1645 [
1646 pwd=`pwd`
1647 tmp_mkf="$pwd/config-PyMake$$"
1648 cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001649__:
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001650 @echo "python3_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001651 @echo "python3_LIBS='$(LIBS)'"
1652 @echo "python3_SYSLIBS='$(SYSLIBS)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001653 @echo "python3_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001654 @echo "python3_INSTSONAME='$(INSTSONAME)'"
Yee Cheng Chinb6ebe5a2023-04-05 18:24:50 +01001655 @echo "python3_PYTHONFRAMEWORKPREFIX='$(PYTHONFRAMEWORKPREFIX)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001656eof
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001657 dnl -- delete the lines from make about Entering/Leaving directory
1658 eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1659 rm -f -- "${tmp_mkf}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001660 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 +02001661 vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}"
1662 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1663 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//`
1664 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//`
1665 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001666 AC_CACHE_CHECK(Python3's dll name,vi_cv_dll_name_python3,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001667 [
1668 if test "X$python3_DLLLIBRARY" != "X"; then
1669 vi_cv_dll_name_python3="$python3_DLLLIBRARY"
Yee Cheng Chinb6ebe5a2023-04-05 18:24:50 +01001670 elif test "X$python3_PYTHONFRAMEWORKPREFIX" != "X"; then
1671 vi_cv_dll_name_python3="${python3_PYTHONFRAMEWORKPREFIX}/${python3_INSTSONAME}"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001672 else
1673 vi_cv_dll_name_python3="$python3_INSTSONAME"
1674 fi
1675 ])
1676
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001677 PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
Illia Bobyr74e1dad2023-08-27 18:26:54 +02001678 if test "${vi_cv_path_python3_include}" = "${vi_cv_path_python3_platinclude}"; then
1679 PYTHON3_CFLAGS="-I${vi_cv_path_python3_include}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001680 else
Illia Bobyr74e1dad2023-08-27 18:26:54 +02001681 PYTHON3_CFLAGS="-I${vi_cv_path_python3_include} -I${vi_cv_path_python3_platinclude}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001682 fi
Yee Cheng Chinc13b3d12023-08-20 21:18:38 +02001683 if test "X$have_python3_config_dir" = "X1" -a "$enable_python3interp" = "dynamic"; then
1684 dnl Define PYTHON3_HOME if --with-python-config-dir was used
1685 PYTHON3_CFLAGS="${PYTHON3_CFLAGS} -DPYTHON3_HOME='L\"${vi_cv_path_python3_pfx}\"'"
1686 fi
1687 if test "X$vi_cv_var_python3_stable_abi_hex" != "X"; then
1688 PYTHON3_CFLAGS="${PYTHON3_CFLAGS} -DPy_LIMITED_API=${vi_cv_var_python3_stable_abi_hex}"
1689 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001690 PYTHON3_SRC="if_python3.c"
1691 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaare5303952022-06-19 17:05:47 +01001692
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001693 dnl On FreeBSD linking with "-pthread" is required to use threads.
1694 dnl _THREAD_SAFE must be used for compiling then.
1695 dnl The "-pthread" is added to $LIBS, so that the following check for
1696 dnl sigaltstack() will look in libc_r (it's there in libc!).
1697 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1698 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1699 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1700 AC_MSG_CHECKING([if -pthread should be used])
1701 threadsafe_flag=
1702 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001703 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001704 if test "$vim_cv_uname_output" != Darwin; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001705 test "$GCC" = yes && threadsafe_flag="-pthread"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001706 if test "$vim_cv_uname_output" = FreeBSD; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001707 threadsafe_flag="-D_THREAD_SAFE"
1708 thread_lib="-pthread"
1709 fi
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001710 if test "$vim_cv_uname_output" = SunOS; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001711 threadsafe_flag="-pthreads"
1712 fi
1713 fi
1714 libs_save_old=$LIBS
1715 if test -n "$threadsafe_flag"; then
1716 cflags_save=$CFLAGS
1717 CFLAGS="$CFLAGS $threadsafe_flag"
1718 LIBS="$LIBS $thread_lib"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001719 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001720 AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag",
1721 AC_MSG_RESULT(no); LIBS=$libs_save_old
1722 )
1723 CFLAGS=$cflags_save
1724 else
1725 AC_MSG_RESULT(no)
1726 fi
Bram Moolenaare5303952022-06-19 17:05:47 +01001727
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001728 dnl check that compiling a simple program still works with the flags
1729 dnl added for Python.
1730 AC_MSG_CHECKING([if compile and link flags for Python 3 are sane])
1731 cflags_save=$CFLAGS
1732 libs_save=$LIBS
1733 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1734 LIBS="$LIBS $PYTHON3_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001735 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001736 AC_MSG_RESULT(yes); python3_ok=yes,
1737 AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no)
1738 CFLAGS=$cflags_save
1739 LIBS=$libs_save
1740 if test "$python3_ok" = yes; then
1741 AC_DEFINE(FEAT_PYTHON3)
1742 else
1743 LIBS=$libs_save_old
1744 PYTHON3_SRC=
1745 PYTHON3_OBJ=
1746 PYTHON3_LIBS=
1747 PYTHON3_CFLAGS=
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001748 fi
1749 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001750 else
1751 AC_MSG_RESULT(too old)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001752 fi
1753 fi
Bram Moolenaar1612b1a2013-06-14 21:22:39 +02001754 if test "$fail_if_missing" = "yes" -a "$python3_ok" != "yes"; then
1755 AC_MSG_ERROR([could not configure python3])
1756 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001757fi
1758
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001759AC_SUBST(PYTHON3_LIBS)
1760AC_SUBST(PYTHON3_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00001761AC_SUBST(PYTHON3_CFLAGS_EXTRA)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001762AC_SUBST(PYTHON3_SRC)
1763AC_SUBST(PYTHON3_OBJ)
1764
1765dnl if python2.x and python3.x are enabled one can only link in code
Bram Moolenaare5303952022-06-19 17:05:47 +01001766dnl with dlopen(), dlsym(), dlclose()
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001767if test "$python_ok" = yes && test "$python3_ok" = yes; then
1768 AC_DEFINE(DYNAMIC_PYTHON)
1769 AC_DEFINE(DYNAMIC_PYTHON3)
Yee Cheng Chinc13b3d12023-08-20 21:18:38 +02001770 if test "X$vi_cv_var_python3_stable_abi_hex" != "X"; then
1771 AC_DEFINE(DYNAMIC_PYTHON3_STABLE_ABI)
1772 fi
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001773 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001774 cflags_save=$CFLAGS
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001775 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001776 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001777 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001778 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001779 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001780 #include <dlfcn.h>
1781 /* If this program fails, then RTLD_GLOBAL is needed.
1782 * RTLD_GLOBAL will be used and then it is not possible to
1783 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001784 * Only the first python version used will be switched on.
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001785 */
1786
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01001787 static int no_rtl_global_needed_for(char *python_instsoname, char *prefix)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001788 {
1789 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001790 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001791 if (pylib != 0)
1792 {
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001793 void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome");
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001794 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1795 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1796 void (*final)(void) = dlsym(pylib, "Py_Finalize");
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001797 (*pfx)(prefix);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001798 (*init)();
1799 needed = (*simple)("import termios") == -1;
1800 (*final)();
1801 dlclose(pylib);
1802 }
1803 return !needed;
1804 }
1805
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01001806 int main()
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001807 {
1808 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001809 if (no_rtl_global_needed_for("${vi_cv_dll_name_python}", "${vi_cv_path_python_pfx}"))
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001810 not_needed = 1;
1811 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001812 }])],
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001813 [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001814
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001815 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001816 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001817
1818 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python3)
1819 cflags_save=$CFLAGS
1820 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001821 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001822 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001823 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001824 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001825 #include <dlfcn.h>
1826 #include <wchar.h>
1827 /* If this program fails, then RTLD_GLOBAL is needed.
1828 * RTLD_GLOBAL will be used and then it is not possible to
1829 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001830 * Only the first python version used will be switched on.
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001831 */
1832
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01001833 static int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix)
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001834 {
1835 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001836 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001837 if (pylib != 0)
1838 {
1839 void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome");
1840 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1841 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1842 void (*final)(void) = dlsym(pylib, "Py_Finalize");
1843 (*pfx)(prefix);
1844 (*init)();
1845 needed = (*simple)("import termios") == -1;
1846 (*final)();
1847 dlclose(pylib);
1848 }
1849 return !needed;
1850 }
1851
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01001852 int main()
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001853 {
1854 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001855 if (no_rtl_global_needed_for("${vi_cv_dll_name_python3}", L"${vi_cv_path_python3_pfx}"))
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001856 not_needed = 1;
1857 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001858 }])],
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001859 [AC_MSG_RESULT(yes);AC_DEFINE(PY3_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
1860
1861 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001862 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001863
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001864 PYTHON_SRC="if_python.c"
1865 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001866 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001867 PYTHON_LIBS=
1868 PYTHON3_SRC="if_python3.c"
1869 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001870 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001871 PYTHON3_LIBS=
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001872elif test "$python_ok" = yes && test "$enable_pythoninterp" = "dynamic"; then
1873 AC_DEFINE(DYNAMIC_PYTHON)
1874 PYTHON_SRC="if_python.c"
1875 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001876 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001877 PYTHON_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001878elif test "$python_ok" = yes; then
1879 dnl Check that adding -fPIE works. It may be needed when using a static
1880 dnl Python library.
1881 AC_MSG_CHECKING([if -fPIE can be added for Python])
1882 cflags_save=$CFLAGS
1883 libs_save=$LIBS
1884 CFLAGS="$CFLAGS $PYTHON_CFLAGS -fPIE"
1885 LIBS="$LIBS $PYTHON_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001886 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaare741f272013-07-09 21:57:52 +02001887 AC_MSG_RESULT(yes); fpie_ok=yes,
1888 AC_MSG_RESULT(no); fpie_ok=no)
1889 CFLAGS=$cflags_save
1890 LIBS=$libs_save
1891 if test $fpie_ok = yes; then
1892 PYTHON_CFLAGS="$PYTHON_CFLAGS -fPIE"
1893 fi
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001894elif test "$python3_ok" = yes && test "$enable_python3interp" = "dynamic"; then
1895 AC_DEFINE(DYNAMIC_PYTHON3)
Yee Cheng Chinc13b3d12023-08-20 21:18:38 +02001896 if test "X$vi_cv_var_python3_stable_abi_hex" != "X"; then
1897 AC_DEFINE(DYNAMIC_PYTHON3_STABLE_ABI)
1898 fi
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001899 PYTHON3_SRC="if_python3.c"
1900 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001901 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001902 PYTHON3_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001903elif test "$python3_ok" = yes; then
1904 dnl Check that adding -fPIE works. It may be needed when using a static
1905 dnl Python library.
1906 AC_MSG_CHECKING([if -fPIE can be added for Python3])
1907 cflags_save=$CFLAGS
1908 libs_save=$LIBS
1909 CFLAGS="$CFLAGS $PYTHON3_CFLAGS -fPIE"
1910 LIBS="$LIBS $PYTHON3_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001911 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaare741f272013-07-09 21:57:52 +02001912 AC_MSG_RESULT(yes); fpie_ok=yes,
1913 AC_MSG_RESULT(no); fpie_ok=no)
1914 CFLAGS=$cflags_save
1915 LIBS=$libs_save
1916 if test $fpie_ok = yes; then
1917 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -fPIE"
1918 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001919fi
1920
Bram Moolenaar071d4272004-06-13 20:20:40 +00001921AC_MSG_CHECKING(--enable-tclinterp argument)
1922AC_ARG_ENABLE(tclinterp,
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001923 [ --enable-tclinterp[=OPTS] Include Tcl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001924 [enable_tclinterp="no"])
1925AC_MSG_RESULT($enable_tclinterp)
1926
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001927if test "$enable_tclinterp" = "yes" -o "$enable_tclinterp" = "dynamic"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001928
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001929 dnl on FreeBSD tclsh is a silly script, look for tclsh8.[5420]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001930 AC_MSG_CHECKING(--with-tclsh argument)
1931 AC_ARG_WITH(tclsh, [ --with-tclsh=PATH which tclsh to use (default: tclsh8.0)],
1932 tclsh_name="$withval"; AC_MSG_RESULT($tclsh_name),
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001933 tclsh_name="tclsh8.5"; AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00001934 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1935 AC_SUBST(vi_cv_path_tcl)
1936
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001937 dnl when no specific version specified, also try 8.4, 8.2 and 8.0
1938 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.5"; then
1939 tclsh_name="tclsh8.4"
1940 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1941 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001942 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.4"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001943 tclsh_name="tclsh8.2"
1944 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1945 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001946 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.2"; then
1947 tclsh_name="tclsh8.0"
1948 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1949 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001950 dnl still didn't find it, try without version number
1951 if test "X$vi_cv_path_tcl" = "X"; then
1952 tclsh_name="tclsh"
1953 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1954 fi
1955 if test "X$vi_cv_path_tcl" != "X"; then
1956 AC_MSG_CHECKING(Tcl version)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001957 if echo 'exit [[expr [info tclversion] < 8.0]]' | "$vi_cv_path_tcl" - ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001958 tclver=`echo 'puts [[info tclversion]]' | $vi_cv_path_tcl -`
1959 AC_MSG_RESULT($tclver - OK);
1960 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 +01001961 tcldll=`echo 'puts libtcl[[info tclversion]][[info sharedlibextension]]' | $vi_cv_path_tcl -`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001962
1963 AC_MSG_CHECKING(for location of Tcl include)
Bram Moolenaard0573012017-10-28 21:11:06 +02001964 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001965 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 +00001966 else
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001967 dnl For all macOS, use the value from TCL in case use of, say, homebrew
Bram Moolenaar071d4272004-06-13 20:20:40 +00001968 dnl For Mac OS X 10.3, use the OS-provided framework location
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001969 dnl For Mac OS X 10.14, the OS-provided framework location doesn't contain the headers, so also check the Xcode SDK
1970 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 +00001971 fi
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001972 TCL_INC=
Bram Moolenaar071d4272004-06-13 20:20:40 +00001973 for try in $tclinc; do
1974 if test -f "$try/tcl.h"; then
1975 AC_MSG_RESULT($try/tcl.h)
1976 TCL_INC=$try
1977 break
1978 fi
1979 done
1980 if test -z "$TCL_INC"; then
1981 AC_MSG_RESULT(<not found>)
1982 SKIP_TCL=YES
1983 fi
1984 if test -z "$SKIP_TCL"; then
1985 AC_MSG_CHECKING(for location of tclConfig.sh script)
Bram Moolenaard0573012017-10-28 21:11:06 +02001986 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001987 tclcnf=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001988 tclcnf="$tclcnf `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001989 else
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001990 dnl For all macOS, use the value from TCL in case use of, say, homebrew
Bram Moolenaar071d4272004-06-13 20:20:40 +00001991 dnl For Mac OS X 10.3, use the OS-provided framework location
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001992 dnl For Mac OS X 10.14, the OS-provided framework location doesn't contain the headers, so also check the Xcode SDK
1993 tclcnf=`echo $tclinc | sed s/include/lib/g`
1994 tclcnf="$tclcnf /System/Library/Frameworks/Tcl.framework `xcrun --show-sdk-path`/System/Library/Frameworks/Tcl.framework"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001995 fi
1996 for try in $tclcnf; do
Bram Moolenaar49222be2015-12-11 18:11:30 +01001997 if test -f "$try/tclConfig.sh"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001998 AC_MSG_RESULT($try/tclConfig.sh)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001999 . "$try/tclConfig.sh"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002000 dnl use eval, because tcl 8.2 includes ${TCL_DBGX}
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01002001 if test "$enable_tclinterp" = "dynamic"; then
2002 TCL_LIBS=`eval echo "$TCL_STUB_LIB_SPEC $TCL_LIBS"`
2003 else
2004 TCL_LIBS=`eval echo "$TCL_LIB_SPEC $TCL_LIBS"`
2005 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002006 dnl Use $TCL_DEFS for -D_THREAD_SAFE et al. But only use the
Bram Moolenaardf3267e2005-01-25 22:07:05 +00002007 dnl "-D_ABC" items. Watch out for -DFOO=long\ long.
Bram Moolenaar4394bff2008-07-24 11:21:31 +00002008 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 +00002009 break
2010 fi
2011 done
2012 if test -z "$TCL_LIBS"; then
2013 AC_MSG_RESULT(<not found>)
2014 AC_MSG_CHECKING(for Tcl library by myself)
2015 tcllib=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00002016 tcllib="$tcllib `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002017 for ext in .so .a ; do
2018 for ver in "" $tclver ; do
2019 for try in $tcllib ; do
2020 trylib=tcl$ver$ext
Bram Moolenaar49222be2015-12-11 18:11:30 +01002021 if test -f "$try/lib$trylib" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002022 AC_MSG_RESULT($try/lib$trylib)
Bram Moolenaar49222be2015-12-11 18:11:30 +01002023 TCL_LIBS="-L\"$try\" -ltcl$ver -ldl -lm"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00002024 if test "$vim_cv_uname_output" = SunOS &&
2025 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002026 TCL_LIBS="$TCL_LIBS -R $try"
2027 fi
2028 break 3
2029 fi
2030 done
2031 done
2032 done
2033 if test -z "$TCL_LIBS"; then
2034 AC_MSG_RESULT(<not found>)
2035 SKIP_TCL=YES
2036 fi
2037 fi
2038 if test -z "$SKIP_TCL"; then
2039 AC_DEFINE(FEAT_TCL)
2040 TCL_SRC=if_tcl.c
2041 TCL_OBJ=objects/if_tcl.o
2042 TCL_PRO=if_tcl.pro
2043 TCL_CFLAGS="-I$TCL_INC $TCL_DEFS"
2044 fi
2045 fi
2046 else
2047 AC_MSG_RESULT(too old; need Tcl version 8.0 or later)
2048 fi
2049 fi
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01002050 if test "$enable_tclinterp" = "dynamic"; then
2051 if test "X$TCL_SRC" != "X" -a "X$tcldll" != "X"; then
2052 AC_DEFINE(DYNAMIC_TCL)
2053 TCL_CFLAGS="-DDYNAMIC_TCL_DLL=\\\"$tcldll\\\" -DDYNAMIC_TCL_VER=\\\"$tclver\\\" $TCL_CFLAGS"
2054 fi
2055 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01002056 if test "$fail_if_missing" = "yes" -a -z "$TCL_SRC"; then
2057 AC_MSG_ERROR([could not configure Tcl])
2058 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002059fi
2060AC_SUBST(TCL_SRC)
2061AC_SUBST(TCL_OBJ)
2062AC_SUBST(TCL_PRO)
2063AC_SUBST(TCL_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00002064AC_SUBST(TCL_CFLAGS_EXTRA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002065AC_SUBST(TCL_LIBS)
2066
2067AC_MSG_CHECKING(--enable-rubyinterp argument)
2068AC_ARG_ENABLE(rubyinterp,
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002069 [ --enable-rubyinterp[=OPTS] Include Ruby interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002070 [enable_rubyinterp="no"])
2071AC_MSG_RESULT($enable_rubyinterp)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002072if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00002073 if test "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +01002074 AC_MSG_ERROR([cannot use Ruby with tiny features])
Bram Moolenaar0b105412014-11-30 13:34:23 +01002075 fi
2076
Bram Moolenaar165641d2010-02-17 16:23:09 +01002077 AC_MSG_CHECKING(--with-ruby-command argument)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002078 AC_SUBST(vi_cv_path_ruby)
Bram Moolenaar948733a2011-05-05 18:10:16 +02002079 AC_ARG_WITH(ruby-command, [ --with-ruby-command=RUBY name of the Ruby command (default: ruby)],
2080 RUBY_CMD="$withval"; vi_cv_path_ruby="$withval"; AC_MSG_RESULT($RUBY_CMD),
2081 RUBY_CMD="ruby"; AC_MSG_RESULT(defaulting to $RUBY_CMD))
Bram Moolenaar165641d2010-02-17 16:23:09 +01002082 AC_PATH_PROG(vi_cv_path_ruby, $RUBY_CMD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002083 if test "X$vi_cv_path_ruby" != "X"; then
2084 AC_MSG_CHECKING(Ruby version)
K.Takata236ccbf2022-09-22 16:12:06 +01002085 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 +00002086 AC_MSG_RESULT(OK)
Bram Moolenaar81398892012-10-03 21:09:35 +02002087 AC_MSG_CHECKING(Ruby rbconfig)
2088 ruby_rbconfig="RbConfig"
2089 if ! $vi_cv_path_ruby -r rbconfig -e 'RbConfig' >/dev/null 2>/dev/null; then
2090 ruby_rbconfig="Config"
2091 fi
2092 AC_MSG_RESULT($ruby_rbconfig)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002093 AC_MSG_CHECKING(Ruby header files)
Bram Moolenaar81398892012-10-03 21:09:35 +02002094 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 +00002095 if test "X$rubyhdrdir" != "X"; then
2096 AC_MSG_RESULT($rubyhdrdir)
2097 RUBY_CFLAGS="-I$rubyhdrdir"
Bram Moolenaara6fd37b2014-03-27 17:19:09 +01002098 rubyarchdir=`$vi_cv_path_ruby -r rbconfig -e "print ($ruby_rbconfig::CONFIG.has_key? 'rubyarchhdrdir') ? $ruby_rbconfig::CONFIG[['rubyarchhdrdir']] : '$rubyhdrdir/'+$ruby_rbconfig::CONFIG[['arch']]"`
2099 if test -d "$rubyarchdir"; then
2100 RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyarchdir"
Bram Moolenaar165641d2010-02-17 16:23:09 +01002101 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02002102 rubyversion=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['ruby_version']].gsub(/\./, '')[[0,2]]"`
Bram Moolenaar026a4452013-08-07 15:22:23 +02002103 if test "X$rubyversion" = "X"; then
K.Takata236ccbf2022-09-22 16:12:06 +01002104 rubyversion=`$vi_cv_path_ruby -e "print RUBY_VERSION.gsub(/\./, '')[[0,2]]"`
Bram Moolenaar026a4452013-08-07 15:22:23 +02002105 fi
Bram Moolenaar165641d2010-02-17 16:23:09 +01002106 RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
Bram Moolenaar81398892012-10-03 21:09:35 +02002107 rubylibs=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LIBS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002108 if test "X$rubylibs" != "X"; then
2109 RUBY_LIBS="$rubylibs"
2110 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02002111 librubyarg=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBYARG']])"`
2112 librubya=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBY_A']])"`
Bram Moolenaarac499e32013-06-02 19:14:17 +02002113 rubylibdir=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['libdir']])"`
Illia Bobyre379e212023-09-30 22:59:27 +02002114 if test -f "$rubylibdir/$librubya" || expr "$librubyarg" : "-lruby" >/dev/null; then
Bram Moolenaarac499e32013-06-02 19:14:17 +02002115 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
2116 elif test "$librubyarg" = "libruby.a"; then
2117 dnl required on Mac OS 10.3 where libruby.a doesn't exist
2118 librubyarg="-lruby"
2119 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002120 fi
2121
2122 if test "X$librubyarg" != "X"; then
2123 RUBY_LIBS="$librubyarg $RUBY_LIBS"
2124 fi
Zdenek Dohnal1d822af2022-11-23 12:06:08 +00002125
2126 dnl Here the Ruby LDFLAGS used to be added to LDFLAGS, but that turns
2127 dnl out to cause trouble and was removed.
2128
Bram Moolenaar071d4272004-06-13 20:20:40 +00002129 RUBY_SRC="if_ruby.c"
2130 RUBY_OBJ="objects/if_ruby.o"
2131 RUBY_PRO="if_ruby.pro"
2132 AC_DEFINE(FEAT_RUBY)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002133 if test "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar92021622017-10-12 12:33:43 +02002134 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_ALIASES']].split[[0]]"`
Bram Moolenaar87ea64c2018-08-04 15:13:34 +02002135 if test -z "$libruby_soname"; then
2136 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_SO']]"`
2137 fi
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002138 AC_DEFINE(DYNAMIC_RUBY)
Bram Moolenaar41a41412020-01-07 21:32:19 +01002139 RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby_soname\\\" $RUBY_CFLAGS"
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002140 RUBY_LIBS=
2141 fi
Bram Moolenaar864a28b2020-12-28 21:36:56 +01002142 if test "X$CLANG_VERSION" != "X" -a "$rubyversion" -ge 30; then
2143 RUBY_CFLAGS="$RUBY_CFLAGS -fdeclspec"
2144 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002145 else
Bram Moolenaar165641d2010-02-17 16:23:09 +01002146 AC_MSG_RESULT(not found; disabling Ruby)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002147 fi
2148 else
K.Takata236ccbf2022-09-22 16:12:06 +01002149 AC_MSG_RESULT(too old; need Ruby version 1.9.1 or later)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002150 fi
2151 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01002152
2153 if test "$fail_if_missing" = "yes" -a -z "$RUBY_OBJ"; then
2154 AC_MSG_ERROR([could not configure Ruby])
2155 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002156fi
2157AC_SUBST(RUBY_SRC)
2158AC_SUBST(RUBY_OBJ)
2159AC_SUBST(RUBY_PRO)
2160AC_SUBST(RUBY_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00002161AC_SUBST(RUBY_CFLAGS_EXTRA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002162AC_SUBST(RUBY_LIBS)
2163
2164AC_MSG_CHECKING(--enable-cscope argument)
2165AC_ARG_ENABLE(cscope,
2166 [ --enable-cscope Include cscope interface.], ,
2167 [enable_cscope="no"])
2168AC_MSG_RESULT($enable_cscope)
2169if test "$enable_cscope" = "yes"; then
2170 AC_DEFINE(FEAT_CSCOPE)
2171fi
2172
Bram Moolenaar071d4272004-06-13 20:20:40 +00002173AC_MSG_CHECKING(--disable-netbeans argument)
2174AC_ARG_ENABLE(netbeans,
2175 [ --disable-netbeans Disable NetBeans integration support.],
2176 , [enable_netbeans="yes"])
2177if test "$enable_netbeans" = "yes"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00002178 if test "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +01002179 AC_MSG_RESULT([cannot use NetBeans with tiny features])
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002180 enable_netbeans="no"
2181 else
2182 AC_MSG_RESULT(no)
2183 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002184else
2185 AC_MSG_RESULT(yes)
2186fi
2187
2188AC_MSG_CHECKING(--disable-channel argument)
2189AC_ARG_ENABLE(channel,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002190 [ --disable-channel Disable process communication support.],
Bram Moolenaare0874f82016-01-24 20:36:41 +01002191 , [enable_channel="yes"])
2192if test "$enable_channel" = "yes"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00002193 if test "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +01002194 AC_MSG_RESULT([cannot use channels with tiny features])
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002195 enable_channel="no"
2196 else
2197 AC_MSG_RESULT(no)
2198 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002199else
2200 if test "$enable_netbeans" = "yes"; then
Bram Moolenaar16435482016-01-24 21:31:54 +01002201 AC_MSG_RESULT([yes, netbeans also disabled])
Bram Moolenaare0874f82016-01-24 20:36:41 +01002202 enable_netbeans="no"
2203 else
2204 AC_MSG_RESULT(yes)
2205 fi
2206fi
2207
Bram Moolenaar16435482016-01-24 21:31:54 +01002208if test "$enable_channel" = "yes"; then
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002209 dnl On Solaris we need the socket library, or on Haiku the network library.
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002210 if test "x$HAIKU" = "xyes"; then
2211 AC_CHECK_LIB(network, socket)
2212 else
2213 AC_CHECK_LIB(socket, socket)
2214 fi
2215
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002216 AC_CACHE_CHECK([whether compiling with IPv6 networking is possible], [vim_cv_ipv6_networking],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002217 [AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002218#include <stdio.h>
2219#include <stdlib.h>
2220#include <stdarg.h>
2221#include <fcntl.h>
2222#include <netdb.h>
2223#include <netinet/in.h>
2224#include <errno.h>
2225#include <sys/types.h>
2226#include <sys/socket.h>
2227 /* Check bitfields */
2228 struct nbbuf {
2229 unsigned int initDone:1;
2230 unsigned short signmaplen;
2231 };
2232 ], [
2233 /* Check creating a socket. */
2234 struct sockaddr_in server;
2235 struct addrinfo *res;
2236 (void)socket(AF_INET, SOCK_STREAM, 0);
2237 (void)htons(100);
2238 (void)getaddrinfo("microsoft.com", NULL, NULL, &res);
2239 if (errno == ECONNREFUSED)
2240 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
2241 (void)freeaddrinfo(res);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002242 ])],
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002243 [vim_cv_ipv6_networking="yes"],
2244 [vim_cv_ipv6_networking="no"])])
2245
2246 if test "x$vim_cv_ipv6_networking" = "xyes"; then
2247 AC_DEFINE(FEAT_IPV6)
Bram Moolenaarb6fb0512020-04-18 18:24:18 +02002248 AC_CHECK_FUNCS(inet_ntop)
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002249 else
2250 dnl On Solaris we need the nsl library.
2251 AC_CHECK_LIB(nsl, gethostbyname)
2252 AC_CACHE_CHECK([whether compiling with IPv4 networking is possible], [vim_cv_ipv4_networking],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002253 [AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00002254#include <stdio.h>
2255#include <stdlib.h>
2256#include <stdarg.h>
2257#include <fcntl.h>
2258#include <netdb.h>
2259#include <netinet/in.h>
2260#include <errno.h>
2261#include <sys/types.h>
2262#include <sys/socket.h>
2263 /* Check bitfields */
2264 struct nbbuf {
2265 unsigned int initDone:1;
Bram Moolenaar63de19e2016-12-09 20:11:26 +01002266 unsigned short signmaplen;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002267 };
2268 ], [
2269 /* Check creating a socket. */
2270 struct sockaddr_in server;
2271 (void)socket(AF_INET, SOCK_STREAM, 0);
2272 (void)htons(100);
2273 (void)gethostbyname("microsoft.com");
2274 if (errno == ECONNREFUSED)
2275 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002276 ])],
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002277 [vim_cv_ipv4_networking="yes"],
2278 [vim_cv_ipv4_networking="no"; enable_netbeans="no"; enable_channel="no"])])
2279 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002280fi
2281if test "$enable_netbeans" = "yes"; then
2282 AC_DEFINE(FEAT_NETBEANS_INTG)
2283 NETBEANS_SRC="netbeans.c"
2284 AC_SUBST(NETBEANS_SRC)
2285 NETBEANS_OBJ="objects/netbeans.o"
2286 AC_SUBST(NETBEANS_OBJ)
2287fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002288if test "$enable_channel" = "yes"; then
Bram Moolenaar509ce2a2016-03-11 22:52:15 +01002289 AC_DEFINE(FEAT_JOB_CHANNEL)
Bram Moolenaar8b5866d2020-09-05 15:48:51 +02002290 CHANNEL_SRC="job.c channel.c"
Bram Moolenaare0874f82016-01-24 20:36:41 +01002291 AC_SUBST(CHANNEL_SRC)
Bram Moolenaar8b5866d2020-09-05 15:48:51 +02002292 CHANNEL_OBJ="objects/job.o objects/channel.o"
Bram Moolenaare0874f82016-01-24 20:36:41 +01002293 AC_SUBST(CHANNEL_OBJ)
2294fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002295
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002296AC_MSG_CHECKING(--enable-terminal argument)
2297AC_ARG_ENABLE(terminal,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002298 [ --enable-terminal Enable terminal emulation support.],
Bram Moolenaaref839562017-10-28 20:28:23 +02002299 , [enable_terminal="auto"])
Bram Moolenaar595a4022017-09-03 19:15:57 +02002300if test "$enable_terminal" = "yes" || test "$enable_terminal" = "auto" -a "x$features" = "xhuge" ; then
Bram Moolenaar12471262022-01-18 11:11:25 +00002301 if test "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +01002302 AC_MSG_RESULT([cannot use terminal emulator with tiny features])
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002303 enable_terminal="no"
2304 else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002305 if test "$enable_terminal" = "auto"; then
2306 enable_terminal="yes"
2307 AC_MSG_RESULT(defaulting to yes)
2308 else
2309 AC_MSG_RESULT(yes)
2310 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002311 fi
2312else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002313 if test "$enable_terminal" = "auto"; then
2314 enable_terminal="no"
2315 AC_MSG_RESULT(defaulting to no)
2316 else
2317 AC_MSG_RESULT(no)
2318 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002319fi
Bram Moolenaar8b423282017-12-16 14:37:06 +01002320if test "$enable_terminal" = "yes" -a "$enable_channel" = "yes"; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002321 AC_DEFINE(FEAT_TERMINAL)
Bram Moolenaar93268052019-10-10 13:22:54 +02002322 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 +02002323 AC_SUBST(TERM_SRC)
Bram Moolenaar93268052019-10-10 13:22:54 +02002324 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 +02002325 AC_SUBST(TERM_OBJ)
Bram Moolenaar823edd12019-10-23 22:35:36 +02002326 TERM_TEST="test_libvterm"
2327 AC_SUBST(TERM_TEST)
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002328fi
2329
Bram Moolenaare42a6d22017-11-12 19:21:51 +01002330AC_MSG_CHECKING(--enable-autoservername argument)
2331AC_ARG_ENABLE(autoservername,
2332 [ --enable-autoservername Automatically define servername at vim startup.], ,
2333 [enable_autoservername="no"])
2334AC_MSG_RESULT($enable_autoservername)
2335if test "$enable_autoservername" = "yes"; then
2336 AC_DEFINE(FEAT_AUTOSERVERNAME)
2337fi
2338
Bram Moolenaar071d4272004-06-13 20:20:40 +00002339AC_MSG_CHECKING(--enable-multibyte argument)
2340AC_ARG_ENABLE(multibyte,
2341 [ --enable-multibyte Include multibyte editing support.], ,
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01002342 [enable_multibyte="yes"])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002343AC_MSG_RESULT($enable_multibyte)
Bram Moolenaar30276f22019-01-24 17:59:39 +01002344if test "$enable_multibyte" != "yes"; then
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01002345 AC_MSG_ERROR([The multi-byte feature can no longer be disabled. If you have
2346 a problem with this, discuss on the Vim mailing list.])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002347fi
2348
Martin Tournoij25f3a142022-10-08 19:26:41 +01002349dnl Right-to-Left language support for Vim will be included with huge features,
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002350dnl unless ENABLE_RIGHTLEFT is undefined.
2351AC_MSG_CHECKING(--disable-rightleft argument)
2352AC_ARG_ENABLE(rightleft,
2353 [ --disable-rightleft Do not include Right-to-Left language support.],
2354 , [enable_rightleft="yes"])
2355if test "$enable_rightleft" = "yes"; then
2356 AC_MSG_RESULT(no)
2357else
2358 AC_MSG_RESULT(yes)
2359 AC_DEFINE(DISABLE_RIGHTLEFT)
2360fi
2361
Martin Tournoij25f3a142022-10-08 19:26:41 +01002362dnl Arabic language support for Vim will be included with huge features,
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002363dnl unless ENABLE_ARABIC is undefined.
2364AC_MSG_CHECKING(--disable-arabic argument)
2365AC_ARG_ENABLE(arabic,
2366 [ --disable-arabic Do not include Arabic language support.],
2367 , [enable_arabic="yes"])
2368if test "$enable_arabic" = "yes"; then
2369 AC_MSG_RESULT(no)
2370else
2371 AC_MSG_RESULT(yes)
2372 AC_DEFINE(DISABLE_ARABIC)
2373fi
2374
Bram Moolenaar14184a32019-02-16 15:10:30 +01002375dnl Farsi language support has been removed, ignore --disable-farsi
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002376AC_ARG_ENABLE(farsi,
Bram Moolenaar14184a32019-02-16 15:10:30 +01002377 [ --disable-farsi Deprecated.],,)
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002378
Bram Moolenaar071d4272004-06-13 20:20:40 +00002379AC_MSG_CHECKING(--enable-xim argument)
2380AC_ARG_ENABLE(xim,
2381 [ --enable-xim Include XIM input support.],
2382 AC_MSG_RESULT($enable_xim),
2383 [enable_xim="auto"; AC_MSG_RESULT(defaulting to auto)])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002384
2385AC_MSG_CHECKING(--enable-fontset argument)
2386AC_ARG_ENABLE(fontset,
2387 [ --enable-fontset Include X fontset output support.], ,
2388 [enable_fontset="no"])
2389AC_MSG_RESULT($enable_fontset)
2390dnl defining FEAT_XFONTSET is delayed, so that it can be disabled for no GUI
2391
2392test -z "$with_x" && with_x=yes
Bram Moolenaard0573012017-10-28 21:11:06 +02002393test "${enable_gui-yes}" != no -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && with_x=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002394if test "$with_x" = no; then
2395 AC_MSG_RESULT(defaulting to: don't HAVE_X11)
2396else
2397 dnl Do this check early, so that its failure can override user requests.
2398
2399 AC_PATH_PROG(xmkmfpath, xmkmf)
2400
2401 AC_PATH_XTRA
2402
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002403 dnl On z/OS Unix the X libraries are DLLs. To use them the code must
Bram Moolenaar071d4272004-06-13 20:20:40 +00002404 dnl be compiled with a special option.
2405 dnl Also add SM, ICE and Xmu to X_EXTRA_LIBS.
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002406 if test "$zOSUnix" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002407 CFLAGS="$CFLAGS -W c,dll"
2408 LDFLAGS="$LDFLAGS -W l,dll"
2409 X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE -lXmu"
2410 fi
2411
2412 dnl On my HPUX system the X include dir is found, but the lib dir not.
Bram Moolenaar70778922020-02-05 20:44:24 +01002413 dnl This is a desperate try to fix this.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002414
2415 if test -d "$x_includes" && test ! -d "$x_libraries"; then
2416 x_libraries=`echo "$x_includes" | sed s/include/lib/`
2417 AC_MSG_RESULT(Corrected X libraries to $x_libraries)
2418 X_LIBS="$X_LIBS -L$x_libraries"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00002419 if test "$vim_cv_uname_output" = SunOS &&
2420 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002421 X_LIBS="$X_LIBS -R $x_libraries"
2422 fi
2423 fi
2424
2425 if test -d "$x_libraries" && test ! -d "$x_includes"; then
2426 x_includes=`echo "$x_libraries" | sed s/lib/include/`
2427 AC_MSG_RESULT(Corrected X includes to $x_includes)
2428 X_CFLAGS="$X_CFLAGS -I$x_includes"
2429 fi
2430
2431 dnl Remove "-I/usr/include " from X_CFLAGS, should not be needed.
2432 X_CFLAGS="`echo $X_CFLAGS\ | sed 's%-I/usr/include %%'`"
2433 dnl Remove "-L/usr/lib " from X_LIBS, should not be needed.
2434 X_LIBS="`echo $X_LIBS\ | sed 's%-L/usr/lib %%'`"
2435 dnl Same for "-R/usr/lib ".
2436 X_LIBS="`echo $X_LIBS\ | sed -e 's%-R/usr/lib %%' -e 's%-R /usr/lib %%'`"
2437
2438
2439 dnl Check if the X11 header files are correctly installed. On some systems
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002440 dnl Xlib.h includes files that don't exist. On some systems X11/Intrinsic.h
2441 dnl is missing.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002442 AC_MSG_CHECKING(if X11 header files can be found)
2443 cflags_save=$CFLAGS
2444 CFLAGS="$CFLAGS $X_CFLAGS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002445 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <X11/Xlib.h>
2446#include <X11/Intrinsic.h>], )],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002447 AC_MSG_RESULT(yes),
2448 AC_MSG_RESULT(no); no_x=yes)
2449 CFLAGS=$cflags_save
2450
2451 if test "${no_x-no}" = yes; then
2452 with_x=no
2453 else
2454 AC_DEFINE(HAVE_X11)
2455 X_LIB="-lXt -lX11";
2456 AC_SUBST(X_LIB)
2457
2458 ac_save_LDFLAGS="$LDFLAGS"
2459 LDFLAGS="-L$x_libraries $LDFLAGS"
2460
2461 dnl Check for -lXdmcp (needed on SunOS 4.1.4)
2462 dnl For HP-UX 10.20 it must be before -lSM -lICE
2463 AC_CHECK_LIB(Xdmcp, _XdmcpAuthDoIt, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lXdmcp"],,
2464 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXdmcp])
2465
2466 dnl Some systems need -lnsl -lsocket when testing for ICE.
2467 dnl The check above doesn't do this, try here (again). Also needed to get
2468 dnl them after Xdmcp. link.sh will remove them when not needed.
2469 dnl Check for other function than above to avoid the cached value
2470 AC_CHECK_LIB(ICE, IceOpenConnection,
2471 [X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE"],, [$X_EXTRA_LIBS])
2472
2473 dnl Check for -lXpm (needed for some versions of Motif)
2474 LDFLAGS="$X_LIBS $ac_save_LDFLAGS"
2475 AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [X_PRE_LIBS="$X_PRE_LIBS -lXpm"],,
2476 [-lXt $X_PRE_LIBS -lXpm -lX11 $X_EXTRA_LIBS])
2477
2478 dnl Check that the X11 header files don't use implicit declarations
2479 AC_MSG_CHECKING(if X11 header files implicitly declare return values)
2480 cflags_save=$CFLAGS
Bram Moolenaard1864592013-05-04 04:40:15 +02002481 dnl -Werror is GCC only, others like Solaris Studio might not like it
2482 if test "$GCC" = yes; then
2483 CFLAGS="$CFLAGS $X_CFLAGS -Werror"
2484 else
2485 CFLAGS="$CFLAGS $X_CFLAGS"
2486 fi
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002487 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <X11/Xlib.h>], )],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002488 AC_MSG_RESULT(no),
2489 CFLAGS="$CFLAGS -Wno-implicit-int"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002490 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <X11/Xlib.h>], )],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002491 AC_MSG_RESULT(yes); cflags_save="$cflags_save -Wno-implicit-int",
2492 AC_MSG_RESULT(test failed)
2493 )
2494 )
2495 CFLAGS=$cflags_save
2496
2497 LDFLAGS="$ac_save_LDFLAGS"
2498
Mike Gilberta055b442023-08-20 19:01:41 +02002499 AC_CHECK_SIZEOF([wchar_t])
2500 if test "$ac_cv_sizeof_wchar_t" -le 2; then
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002501 AC_DEFINE(SMALL_WCHAR_T)
2502 fi
2503
Bram Moolenaar071d4272004-06-13 20:20:40 +00002504 fi
2505fi
2506
Bram Moolenaard2a05492018-07-27 22:35:15 +02002507dnl Check if --with-x was given but it doesn't work.
2508if test "x$with_x" = xno -a "x$with_x_arg" = xyes; then
2509 AC_MSG_ERROR([could not configure X])
2510fi
2511
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002512test "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 +00002513
2514AC_MSG_CHECKING(--enable-gui argument)
2515AC_ARG_ENABLE(gui,
Bram Moolenaarf52fac22022-03-11 16:01:26 +00002516 [ --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 +00002517
2518dnl Canonicalize the --enable-gui= argument so that it can be easily compared.
2519dnl Do not use character classes for portability with old tools.
2520enable_gui_canon=`echo "_$enable_gui" | \
2521 sed 's/[[ _+-]]//g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
2522
2523dnl Skip everything by default.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002524SKIP_GTK2=YES
Bram Moolenaar1858a842016-02-23 22:30:31 +01002525SKIP_GTK3=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002526SKIP_GNOME=YES
2527SKIP_MOTIF=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002528SKIP_PHOTON=YES
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002529SKIP_HAIKU=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002530GUITYPE=NONE
2531
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002532if test "x$HAIKU" = "xyes"; then
2533 SKIP_HAIKU=
2534 case "$enable_gui_canon" in
2535 no) AC_MSG_RESULT(no GUI support)
2536 SKIP_HAIKU=YES ;;
2537 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
2538 auto) AC_MSG_RESULT(auto - automatic GUI support) ;;
2539 haiku) AC_MSG_RESULT(Haiku GUI support) ;;
2540 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2541 SKIP_HAIKU=YES ;;
2542 esac
2543elif test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002544 SKIP_PHOTON=
2545 case "$enable_gui_canon" in
2546 no) AC_MSG_RESULT(no GUI support)
2547 SKIP_PHOTON=YES ;;
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002548 yes|""|auto) AC_MSG_RESULT(automatic GUI support)
2549 gui_auto=yes ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002550 photon) AC_MSG_RESULT(Photon GUI support) ;;
2551 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2552 SKIP_PHOTON=YES ;;
2553 esac
2554
Bram Moolenaar040f9752020-08-11 23:08:48 +02002555elif test "x$MACOS_X" = "xyes" -a "x$with_x" = "xno" ; then
2556 case "$enable_gui_canon" in
2557 no) AC_MSG_RESULT(no GUI support) ;;
2558 yes|"") AC_MSG_RESULT(yes - automatic GUI support)
2559 gui_auto=yes ;;
2560 auto) AC_MSG_RESULT(auto - disable GUI support for Mac OS) ;;
Bram Moolenaarbe7529e2020-08-13 21:05:39 +02002561 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
Bram Moolenaar040f9752020-08-11 23:08:48 +02002562 esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00002563else
2564
Bram Moolenaar071d4272004-06-13 20:20:40 +00002565 case "$enable_gui_canon" in
2566 no|none) AC_MSG_RESULT(no GUI support) ;;
2567 yes|""|auto) AC_MSG_RESULT(yes/auto - automatic GUI support)
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002568 gui_auto=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002569 SKIP_GTK2=
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002570 SKIP_GTK3=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002571 SKIP_GNOME=
Bram Moolenaarf52fac22022-03-11 16:01:26 +00002572 SKIP_MOTIF=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002573 gtk2) AC_MSG_RESULT(GTK+ 2.x GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002574 SKIP_GTK2=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002575 gnome2) AC_MSG_RESULT(GNOME 2.x GUI support)
2576 SKIP_GNOME=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002577 SKIP_GTK2=;;
Bram Moolenaar98921892016-02-23 17:14:37 +01002578 gtk3) AC_MSG_RESULT(GTK+ 3.x GUI support)
2579 SKIP_GTK3=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002580 motif) AC_MSG_RESULT(Motif GUI support)
2581 SKIP_MOTIF=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002582 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
2583 esac
2584
2585fi
2586
Bram Moolenaar071d4272004-06-13 20:20:40 +00002587if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \
2588 -a "$enable_gui_canon" != "gnome2"; then
2589 AC_MSG_CHECKING(whether or not to look for GTK+ 2)
2590 AC_ARG_ENABLE(gtk2-check,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002591 [ --enable-gtk2-check If auto-select GUI, check for GTK+ 2 [default=yes]],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002592 , enable_gtk2_check="yes")
2593 AC_MSG_RESULT($enable_gtk2_check)
2594 if test "x$enable_gtk2_check" = "xno"; then
2595 SKIP_GTK2=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002596 SKIP_GNOME=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002597 fi
2598fi
2599
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002600if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002601 AC_MSG_CHECKING(whether or not to look for GNOME)
2602 AC_ARG_ENABLE(gnome-check,
2603 [ --enable-gnome-check If GTK GUI, check for GNOME [default=no]],
2604 , enable_gnome_check="no")
2605 AC_MSG_RESULT($enable_gnome_check)
2606 if test "x$enable_gnome_check" = "xno"; then
2607 SKIP_GNOME=YES
2608 fi
2609fi
2610
Bram Moolenaar98921892016-02-23 17:14:37 +01002611if test "x$SKIP_GTK3" != "xYES" -a "$enable_gui_canon" != "gtk3"; then
2612 AC_MSG_CHECKING(whether or not to look for GTK+ 3)
2613 AC_ARG_ENABLE(gtk3-check,
2614 [ --enable-gtk3-check If auto-select GUI, check for GTK+ 3 [default=yes]],
2615 , enable_gtk3_check="yes")
2616 AC_MSG_RESULT($enable_gtk3_check)
2617 if test "x$enable_gtk3_check" = "xno"; then
2618 SKIP_GTK3=YES
2619 fi
2620fi
2621
Bram Moolenaar071d4272004-06-13 20:20:40 +00002622if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then
2623 AC_MSG_CHECKING(whether or not to look for Motif)
2624 AC_ARG_ENABLE(motif-check,
2625 [ --enable-motif-check If auto-select GUI, check for Motif [default=yes]],
2626 , enable_motif_check="yes")
2627 AC_MSG_RESULT($enable_motif_check)
2628 if test "x$enable_motif_check" = "xno"; then
2629 SKIP_MOTIF=YES
2630 fi
2631fi
2632
Bram Moolenaar071d4272004-06-13 20:20:40 +00002633dnl define an autoconf function to check for a specified version of GTK, and
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002634dnl try to compile/link a GTK program.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002635dnl
2636dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002637dnl Test for GTK, and define GTK_CFLAGS, GTK_LIBDIR and GTK_LIBS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002638dnl
2639AC_DEFUN(AM_PATH_GTK,
2640[
Drew Vogel51995672025-05-28 21:13:52 +02002641 dnl Even if we don't end up using the pkg-config name, the min_gtk_version
2642 dnl will be used when compiling the gtktest program below.
2643 min_gtk_version="$1"
2644
2645 dnl Attempt to source flags from pkg-config if it is installed.
2646 if test "$PKG_CONFIG" != "no"; then
2647 AS_CASE([$min_gtk_version],
2648 [2.*], [gtk_pkg_name="gtk+-2.0"],
2649 [3.*], [gtk_pkg_name="gtk+-3.0"],
2650 [AC_MSG_FAILURE([The configure script does not know which pkg-config name to use for GTK $min_gtk_version"])])
2651
2652 AC_MSG_CHECKING([for pkg-config $gtk_pkg_name])
2653 AS_IF(["$PKG_CONFIG" --exists "$gtk_pkg_name"],
2654 [
2655 AC_MSG_RESULT(found)
2656 AC_MSG_CHECKING([for GTK - version >= $min_gtk_version])
2657 dnl We should be using PKG_CHECK_MODULES() instead of this hack.
2658 dnl But I guess the dependency on pkgconfig.m4 is not wanted or
2659 dnl something like that.
2660 GTK_CFLAGS=`$PKG_CONFIG --cflags $gtk_pkg_name`
2661 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L $gtk_pkg_name`
2662 GTK_LIBS=`$PKG_CONFIG --libs $gtk_pkg_name`
2663 gtk_major_version=`$PKG_CONFIG --modversion $gtk_pkg_name | \
2664 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2665 gtk_minor_version=`$PKG_CONFIG --modversion $gtk_pkg_name | \
2666 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2667 gtk_micro_version=`$PKG_CONFIG --modversion $gtk_pkg_name | \
2668 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2669 AC_MSG_RESULT([yes; found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version])
2670 ],
2671 [
2672 GTK_CFLAGS=""
2673 GTK_LIBDIR=""
2674 GTK_LIBS=""
2675 AC_MSG_RESULT([no; consider installing your distro GTK -dev package])
2676 if test "$fail_if_missing" = "yes" -a "$gui_auto" != "yes"; then
2677 AC_MSG_ERROR([pkg-config could not find $gtk_pkg_name])
2678 fi
2679 ])
2680 fi
2681
2682 dnl Regardless of whether we sources the GTK compilation flags from
2683 dnl pkg-config above versus the user specifying them in CFLAGS and LIBS, try
2684 dnl to compile the test program.
2685 dnl
2686 dnl Default to outcome flag to "yes" because disabling the check should be
2687 dnl considered the same as assuming it would succeed.
2688 gtktest_success="yes"
2689 if test "$enable_gtktest" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002690 {
Drew Vogel51995672025-05-28 21:13:52 +02002691 ac_save_CFLAGS="$CFLAGS"
2692 ac_save_LIBS="$LIBS"
2693 CFLAGS="$CFLAGS $GTK_CFLAGS"
2694 LIBS="$LIBS $GTK_LIBS"
Bram Moolenaar98921892016-02-23 17:14:37 +01002695
Drew Vogel51995672025-05-28 21:13:52 +02002696 dnl
2697 dnl Now check if the installed GTK is sufficiently new.
2698 dnl
2699 AC_MSG_CHECKING([ability to compile GTK test program])
2700 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar071d4272004-06-13 20:20:40 +00002701#include <gtk/gtk.h>
2702#include <stdio.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00002703#if STDC_HEADERS
2704# include <stdlib.h>
2705# include <stddef.h>
2706#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002707
2708int
2709main ()
2710{
Drew Vogel51995672025-05-28 21:13:52 +02002711 int ex_major = $gtk_major_version;
2712 int ex_minor = $gtk_minor_version;
2713 int ex_micro = $gtk_micro_version;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002714
Drew Vogel51995672025-05-28 21:13:52 +02002715 #if $gtk_major_version == 2
2716 guint ob_major = gtk_major_version;
2717 guint ob_minor = gtk_minor_version;
2718 guint ob_micro = gtk_micro_version;
2719 #else
2720 guint ob_major = gtk_get_major_version();
2721 guint ob_minor = gtk_get_minor_version();
2722 guint ob_micro = gtk_get_micro_version();
2723 #endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002724
Drew Vogel51995672025-05-28 21:13:52 +02002725 if ((ob_major > ex_major) ||
2726 ((ob_major == ex_major)
2727 && (ob_minor > ex_minor)) ||
2728 ((ob_major == ex_major)
2729 && (ob_minor == ex_minor)
2730 && (ob_micro >= ex_micro)))
2731 return 0;
2732 else
2733 return 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002734}
Drew Vogel51995672025-05-28 21:13:52 +02002735])],
2736 [gtktest_success="yes"; AC_MSG_RESULT(yes)],
2737 [gtktest_success="no"; AC_MSG_RESULT(no)],
2738 [echo $ac_n "cross compiling; assumed OK... $ac_c"])
2739 CFLAGS="$ac_save_CFLAGS"
2740 LIBS="$ac_save_LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002741 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002742 fi
Drew Vogel51995672025-05-28 21:13:52 +02002743
2744 if test "$gtktest_success" = "yes"; then
2745 ifelse([$2], , :, [$2])
2746 else
2747 dnl Reset flags sourced from pkg-config if the compilation test failed.
2748 GTK_CFLAGS=""
2749 GTK_LIBDIR=""
2750 GTK_LIBS=""
2751 if test "$fail_if_missing" = "yes" -a "$gui_auto" != "yes"; then
2752 AC_MSG_ERROR([Failed to compile GTK test program.])
2753 fi
2754 fi
2755
Bram Moolenaar071d4272004-06-13 20:20:40 +00002756 AC_SUBST(GTK_CFLAGS)
2757 AC_SUBST(GTK_LIBS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002758])
2759
2760dnl ---------------------------------------------------------------------------
2761dnl gnome
2762dnl ---------------------------------------------------------------------------
2763AC_DEFUN([GNOME_INIT_HOOK],
2764[
2765 AC_SUBST(GNOME_LIBS)
2766 AC_SUBST(GNOME_LIBDIR)
2767 AC_SUBST(GNOME_INCLUDEDIR)
2768
2769 AC_ARG_WITH(gnome-includes,
2770 [ --with-gnome-includes=DIR Specify location of GNOME headers],
2771 [CFLAGS="$CFLAGS -I$withval"]
2772 )
2773
2774 AC_ARG_WITH(gnome-libs,
2775 [ --with-gnome-libs=DIR Specify location of GNOME libs],
2776 [LDFLAGS="$LDFLAGS -L$withval" gnome_prefix=$withval]
2777 )
2778
2779 AC_ARG_WITH(gnome,
2780 [ --with-gnome Specify prefix for GNOME files],
2781 if test x$withval = xyes; then
2782 want_gnome=yes
2783 ifelse([$1], [], :, [$1])
2784 else
2785 if test "x$withval" = xno; then
2786 want_gnome=no
2787 else
2788 want_gnome=yes
2789 LDFLAGS="$LDFLAGS -L$withval/lib"
2790 CFLAGS="$CFLAGS -I$withval/include"
2791 gnome_prefix=$withval/lib
2792 fi
2793 fi,
2794 want_gnome=yes)
2795
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002796 if test "x$want_gnome" = xyes; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002797 {
2798 AC_MSG_CHECKING(for libgnomeui-2.0)
2799 if $PKG_CONFIG --exists libgnomeui-2.0; then
2800 AC_MSG_RESULT(yes)
2801 GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0`
2802 GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0`
2803 GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0`
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002804
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002805 dnl On FreeBSD we need -pthread but pkg-config doesn't include it.
2806 dnl This might not be the right way but it works for me...
2807 AC_MSG_CHECKING(for FreeBSD)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00002808 if test "$vim_cv_uname_output" = FreeBSD; then
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002809 AC_MSG_RESULT(yes, adding -pthread)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002810 GNOME_INCLUDEDIR="$GNOME_INCLUDEDIR -D_THREAD_SAFE"
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002811 GNOME_LIBS="$GNOME_LIBS -pthread"
2812 else
2813 AC_MSG_RESULT(no)
2814 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002815 $1
2816 else
2817 AC_MSG_RESULT(not found)
2818 if test "x$2" = xfail; then
2819 AC_MSG_ERROR(Could not find libgnomeui-2.0 via pkg-config)
2820 fi
2821 fi
2822 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002823 fi
2824])
2825
2826AC_DEFUN([GNOME_INIT],[
2827 GNOME_INIT_HOOK([],fail)
2828])
2829
Drew Vogel51995672025-05-28 21:13:52 +02002830if test -z "$PKG_CONFIG"; then
Bram Moolenaar427f5b62019-06-09 13:43:51 +02002831 AC_PATH_TOOL(PKG_CONFIG, pkg-config, no)
2832fi
2833
Drew Vogel51995672025-05-28 21:13:52 +02002834dnl ---------------------------------------------------------------------------
2835dnl Check for GTK3. If it succeeds, skip the check for GTK2.
2836dnl ---------------------------------------------------------------------------
2837if test -z "$SKIP_GTK3"; then
2838 AC_MSG_CHECKING(--disable-gtktest argument)
2839 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2840 , enable_gtktest=yes)
2841 if test "x$enable_gtktest" = "xyes" ; then
2842 AC_MSG_RESULT(gtk test enabled)
2843 else
2844 AC_MSG_RESULT(gtk test disabled)
2845 fi
2846
2847 if test "x$PKG_CONFIG" != "xno"; then
2848 AM_PATH_GTK(3.0.0,
2849 [GUI_LIB_LOC="$GTK_LIBDIR"
2850 GTK_LIBNAME="$GTK_LIBS"
2851 GUI_INC_LOC="$GTK_CFLAGS"])
2852 if test -n "$GTK_CFLAGS"; then
2853 SKIP_GTK2=YES
2854 SKIP_GNOME=YES
2855 SKIP_MOTIF=YES
2856 GUITYPE=GTK
2857 AC_SUBST(GTK_LIBNAME)
2858 AC_DEFINE(USE_GTK3)
2859 fi
2860 fi
2861fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002862
2863dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002864dnl Check for GTK2. If it fails, then continue on for Motif as before...
Bram Moolenaar071d4272004-06-13 20:20:40 +00002865dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002866if test -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002867 AC_MSG_CHECKING(--disable-gtktest argument)
2868 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2869 , enable_gtktest=yes)
2870 if test "x$enable_gtktest" = "xyes" ; then
2871 AC_MSG_RESULT(gtk test enabled)
2872 else
2873 AC_MSG_RESULT(gtk test disabled)
2874 fi
2875
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002876 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002877 dnl First try finding version 2.2.0 or later. The 2.0.x series has
2878 dnl problems (bold fonts, --remote doesn't work).
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002879 AM_PATH_GTK(2.2.0,
2880 [GUI_LIB_LOC="$GTK_LIBDIR"
2881 GTK_LIBNAME="$GTK_LIBS"
Drew Vogel51995672025-05-28 21:13:52 +02002882 GUI_INC_LOC="$GTK_CFLAGS"])
2883 if test -n "$GTK_CFLAGS"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002884 SKIP_MOTIF=YES
2885 GUITYPE=GTK
2886 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002887 fi
2888 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002889 if test "x$GUITYPE" = "xGTK"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002890 dnl
2891 dnl if GTK exists, then check for GNOME.
2892 dnl
2893 if test -z "$SKIP_GNOME"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002894 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002895 GNOME_INIT_HOOK([have_gnome=yes])
2896 if test "x$have_gnome" = xyes ; then
2897 AC_DEFINE(FEAT_GUI_GNOME)
2898 GUI_INC_LOC="$GUI_INC_LOC $GNOME_INCLUDEDIR"
2899 GTK_LIBNAME="$GTK_LIBNAME $GNOME_LIBDIR $GNOME_LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002900 fi
2901 }
2902 fi
2903 fi
2904fi
2905
Bram Moolenaard2e03f02016-01-02 22:46:36 +01002906dnl Check the version of Gdk-Pixbuf. If the version is 2.31 or later and
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002907dnl glib-compile-resources is found in PATH, use GResource.
2908if test "x$GUITYPE" = "xGTK"; then
2909 AC_MSG_CHECKING([version of Gdk-Pixbuf])
2910 gdk_pixbuf_version=`$PKG_CONFIG --modversion gdk-pixbuf-2.0`
2911 if test "x$gdk_pixbuf_version" != x ; then
2912 gdk_pixbuf_version_minor=`echo $gdk_pixbuf_version | \
2913 sed -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/'`
2914 if test "x$gdk_pixbuf_version_minor" != x -a \
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002915 $gdk_pixbuf_version_minor -ge 31 ; then
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002916 AC_MSG_RESULT([OK.])
2917 AC_PATH_PROG(GLIB_COMPILE_RESOURCES,[glib-compile-resources],no)
2918 AC_MSG_CHECKING([glib-compile-resources])
2919 if test "x$GLIB_COMPILE_RESOURCES" = xno ; then
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002920 GLIB_COMPILE_RESOURCES=""
2921 AC_MSG_RESULT([cannot be found in PATH.])
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002922 else
2923 AC_MSG_RESULT([usable.])
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002924 AC_DEFINE(USE_GRESOURCE)
2925 GRESOURCE_SRC="auto/gui_gtk_gresources.c"
2926 GRESOURCE_OBJ="objects/gui_gtk_gresources.o"
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002927 fi
2928 else
2929 AC_MSG_RESULT([not usable.])
2930 fi
2931 else
2932 AC_MSG_RESULT([cannot obtain from pkg_config.])
2933 fi
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002934
2935 AC_MSG_CHECKING([--disable-icon-cache-update argument])
2936 AC_ARG_ENABLE(icon_cache_update,
2937 [ --disable-icon-cache-update update disabled],
2938 [],
2939 [enable_icon_cache_update="yes"])
2940 if test "$enable_icon_cache_update" = "yes"; then
2941 AC_MSG_RESULT([not set])
2942 AC_PATH_PROG(GTK_UPDATE_ICON_CACHE,[gtk-update-icon-cache],no)
2943 if test "x$GTK_UPDATE_ICON_CACHE" = "xno" ; then
2944 AC_MSG_RESULT([not found in PATH.])
2945 fi
2946 else
2947 AC_MSG_RESULT([update disabled])
2948 fi
2949
2950 AC_MSG_CHECKING([--disable-desktop-database-update argument])
2951 AC_ARG_ENABLE(desktop_database_update,
2952 [ --disable-desktop-database-update update disabled],
2953 [],
2954 [enable_desktop_database_update="yes"])
2955 if test "$enable_desktop_database_update" = "yes"; then
2956 AC_MSG_RESULT([not set])
2957 AC_PATH_PROG(UPDATE_DESKTOP_DATABASE,[update-desktop-database],no)
2958 if test "x$UPDATE_DESKTOP_DATABASE" = "xno" ; then
2959 AC_MSG_RESULT([not found in PATH.])
2960 fi
2961 else
2962 AC_MSG_RESULT([update disabled])
2963 fi
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002964fi
2965AC_SUBST(GLIB_COMPILE_RESOURCES)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002966AC_SUBST(GRESOURCE_SRC)
2967AC_SUBST(GRESOURCE_OBJ)
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002968AC_SUBST(GTK_UPDATE_ICON_CACHE)
2969AC_SUBST(UPDATE_DESKTOP_DATABASE)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002970
Bram Moolenaar071d4272004-06-13 20:20:40 +00002971dnl Check for Motif include files location.
2972dnl The LAST one found is used, this makes the highest version to be used,
2973dnl e.g. when Motif1.2 and Motif2.0 are both present.
2974
2975if test -z "$SKIP_MOTIF"; then
2976 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"
2977 dnl Remove "-I" from before $GUI_INC_LOC if it's there
2978 GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`"
2979
2980 AC_MSG_CHECKING(for location of Motif GUI includes)
2981 gui_includes="`echo $x_includes|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC"
2982 GUI_INC_LOC=
2983 for try in $gui_includes; do
2984 if test -f "$try/Xm/Xm.h"; then
2985 GUI_INC_LOC=$try
2986 fi
2987 done
2988 if test -n "$GUI_INC_LOC"; then
2989 if test "$GUI_INC_LOC" = /usr/include; then
2990 GUI_INC_LOC=
2991 AC_MSG_RESULT(in default path)
2992 else
2993 AC_MSG_RESULT($GUI_INC_LOC)
2994 fi
2995 else
2996 AC_MSG_RESULT(<not found>)
2997 SKIP_MOTIF=YES
2998 fi
2999fi
3000
3001dnl Check for Motif library files location. In the same order as the include
3002dnl files, to avoid a mixup if several versions are present
3003
3004if test -z "$SKIP_MOTIF"; then
3005 AC_MSG_CHECKING(--with-motif-lib argument)
3006 AC_ARG_WITH(motif-lib,
Bram Moolenaar8008b632017-07-18 21:33:20 +02003007 [ --with-motif-lib=STRING Library for Motif ],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003008 [ MOTIF_LIBNAME="${withval}" ] )
3009
3010 if test -n "$MOTIF_LIBNAME"; then
3011 AC_MSG_RESULT($MOTIF_LIBNAME)
3012 GUI_LIB_LOC=
3013 else
3014 AC_MSG_RESULT(no)
3015
3016 dnl Remove "-L" from before $GUI_LIB_LOC if it's there
3017 GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
3018
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02003019 dnl Ubuntu has libXm.so in /usr/lib/i386-linux-gnu and elsewhere. The
3020 dnl linker will figure out which one to use, we only check if one exists.
Kelvin Leeb4716902022-04-04 17:20:01 +01003021 dnl Cygwin uses the .dll.a extension.
Bram Moolenaar01967f52023-04-12 16:24:03 +01003022 dnl OpenSUSE appears to use /usr/lib64.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003023 AC_MSG_CHECKING(for location of Motif GUI libs)
Bram Moolenaar01967f52023-04-12 16:24:03 +01003024 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 +00003025 GUI_LIB_LOC=
3026 for try in $gui_libs; do
Kelvin Leeb4716902022-04-04 17:20:01 +01003027 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 +00003028 if test -f "$libtry"; then
3029 GUI_LIB_LOC=$try
3030 fi
3031 done
3032 done
3033 if test -n "$GUI_LIB_LOC"; then
Bram Moolenaar01967f52023-04-12 16:24:03 +01003034 dnl Remove /usr/lib, it causes trouble on some systems.
3035 dnl For consistency also remove other standard lib directories.
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02003036 if test "$GUI_LIB_LOC" = /usr/lib \
Bram Moolenaar01967f52023-04-12 16:24:03 +01003037 -o "$GUI_LIB_LOC" = /usr/lib64 \
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02003038 -o "$GUI_LIB_LOC" = /usr/lib/i386-linux-gnu \
3039 -o "$GUI_LIB_LOC" = /usr/lib/x86_64-linux-gnu; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003040 GUI_LIB_LOC=
3041 AC_MSG_RESULT(in default path)
3042 else
3043 if test -n "$GUI_LIB_LOC"; then
3044 AC_MSG_RESULT($GUI_LIB_LOC)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00003045 if test "$vim_cv_uname_output" = SunOS &&
3046 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003047 GUI_LIB_LOC="$GUI_LIB_LOC -R $GUI_LIB_LOC"
3048 fi
3049 fi
3050 fi
3051 MOTIF_LIBNAME=-lXm
3052 else
3053 AC_MSG_RESULT(<not found>)
3054 SKIP_MOTIF=YES
3055 fi
3056 fi
3057fi
3058
3059if test -z "$SKIP_MOTIF"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003060 GUITYPE=MOTIF
3061 AC_SUBST(MOTIF_LIBNAME)
3062fi
3063
Bram Moolenaare2adcf32022-03-12 11:57:25 +00003064if test -z "$SKIP_MOTIF"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003065 dnl Prepend -I and -L to $GUI_INC_LOC and $GUI_LIB_LOC if not empty
3066 dnl Avoid adding it when it twice
3067 if test -n "$GUI_INC_LOC"; then
3068 GUI_INC_LOC=-I"`echo $GUI_INC_LOC|sed 's%-I%%'`"
3069 fi
3070 if test -n "$GUI_LIB_LOC"; then
3071 GUI_LIB_LOC=-L"`echo $GUI_LIB_LOC|sed 's%-L%%'`"
3072 fi
3073
3074 dnl Check for -lXext and then for -lXmu
3075 ldflags_save=$LDFLAGS
3076 LDFLAGS="$X_LIBS $LDFLAGS"
3077 AC_CHECK_LIB(Xext, XShapeQueryExtension, [GUI_X_LIBS="-lXext"],,
3078 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3079 dnl For Solaris we need -lw and -ldl before linking with -lXmu works.
3080 AC_CHECK_LIB(w, wslen, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lw"],,
3081 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3082 AC_CHECK_LIB(dl, dlsym, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldl"],,
3083 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3084 AC_CHECK_LIB(Xmu, XmuCreateStippledPixmap, [GUI_X_LIBS="-lXmu $GUI_X_LIBS"],,
3085 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3086 if test -z "$SKIP_MOTIF"; then
3087 AC_CHECK_LIB(Xp, XpEndJob, [GUI_X_LIBS="-lXp $GUI_X_LIBS"],,
3088 [$GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3089 fi
3090 LDFLAGS=$ldflags_save
3091
3092 dnl Execute xmkmf to figure out if -DNARROWPROTO is needed.
3093 AC_MSG_CHECKING(for extra X11 defines)
3094 NARROW_PROTO=
3095 rm -fr conftestdir
3096 if mkdir conftestdir; then
3097 cd conftestdir
3098 cat > Imakefile <<'EOF'
3099acfindx:
3100 @echo 'NARROW_PROTO="${PROTO_DEFINES}"'
3101EOF
3102 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
3103 eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
3104 fi
3105 cd ..
3106 rm -fr conftestdir
3107 fi
3108 if test -z "$NARROW_PROTO"; then
3109 AC_MSG_RESULT(no)
3110 else
3111 AC_MSG_RESULT($NARROW_PROTO)
3112 fi
3113 AC_SUBST(NARROW_PROTO)
3114fi
3115
3116dnl Look for XSMP support - but don't necessarily restrict it to X11 GUIs
3117dnl use the X11 include path
3118if test "$enable_xsmp" = "yes"; then
3119 cppflags_save=$CPPFLAGS
3120 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3121 AC_CHECK_HEADERS(X11/SM/SMlib.h)
3122 CPPFLAGS=$cppflags_save
3123fi
3124
3125
Bram Moolenaarf52fac22022-03-11 16:01:26 +00003126if test -z "$SKIP_MOTIF" -o -z "$SKIP_GTK2" -o -z "$SKIP_GTK3"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003127 dnl Check for X11/xpm.h and X11/Sunkeysym.h with the GUI include path
3128 cppflags_save=$CPPFLAGS
3129 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3130 AC_CHECK_HEADERS(X11/xpm.h X11/Sunkeysym.h)
3131
3132 dnl automatically disable XIM when XIMtext isn't in X11/Xlib.h
3133 if test ! "$enable_xim" = "no"; then
3134 AC_MSG_CHECKING(for XIMText in X11/Xlib.h)
3135 AC_EGREP_CPP(XIMText, [#include <X11/Xlib.h>],
3136 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +02003137 AC_MSG_RESULT(no; xim has been disabled); enable_xim="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00003138 fi
3139 CPPFLAGS=$cppflags_save
3140
Bram Moolenaar54612582019-11-21 17:13:31 +01003141 dnl automatically enable XIM in the GUI
3142 if test "$enable_xim" = "auto" -a "x$GUITYPE" != "xNONE" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003143 AC_MSG_RESULT(X GUI selected; xim has been enabled)
3144 enable_xim="yes"
3145 fi
3146fi
3147
Bram Moolenaarf52fac22022-03-11 16:01:26 +00003148if test -z "$SKIP_MOTIF"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003149 cppflags_save=$CPPFLAGS
3150 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00003151dnl Xmu/Editres.h may exist but can only be used after including Intrinsic.h
3152 AC_MSG_CHECKING([for X11/Xmu/Editres.h])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003153 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00003154#include <X11/Intrinsic.h>
3155#include <X11/Xmu/Editres.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003156 [int i; i = 0;])],
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00003157 AC_MSG_RESULT(yes)
3158 AC_DEFINE(HAVE_X11_XMU_EDITRES_H),
3159 AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003160 CPPFLAGS=$cppflags_save
3161fi
3162
Bram Moolenaar0b40d082022-03-08 13:32:37 +00003163dnl Only use the Xm directory when compiling Motif.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003164if test -z "$SKIP_MOTIF"; then
3165 cppflags_save=$CPPFLAGS
3166 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003167 if test "$zOSUnix" = "yes"; then
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003168 AC_CHECK_HEADERS(Xm/Xm.h)
Bram Moolenaar77c19352012-06-13 19:19:41 +02003169 else
Bram Moolenaarde1d7342022-06-05 20:03:17 +01003170 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 +01003171 fi
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003172
Bram Moolenaar77c19352012-06-13 19:19:41 +02003173 if test "x$ac_cv_header_Xm_XpmP_h" = "xyes"; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003174 dnl Solaris uses XpmAttributes_21, very annoying.
3175 AC_MSG_CHECKING([for XpmAttributes_21 in Xm/XpmP.h])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003176 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <Xm/XpmP.h>], [XpmAttributes_21 attr;])],
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003177 AC_MSG_RESULT(yes); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes_21),
3178 AC_MSG_RESULT(no); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
3179 )
3180 else
Bram Moolenaar57657d82006-04-21 22:12:41 +00003181 AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003182 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003183 CPPFLAGS=$cppflags_save
3184fi
3185
3186if test "x$GUITYPE" = "xNONE" -a "$enable_xim" = "yes"; then
3187 AC_MSG_RESULT(no GUI selected; xim has been disabled)
3188 enable_xim="no"
3189fi
3190if test "x$GUITYPE" = "xNONE" -a "$enable_fontset" = "yes"; then
3191 AC_MSG_RESULT(no GUI selected; fontset has been disabled)
3192 enable_fontset="no"
3193fi
Bram Moolenaar182c5be2010-06-25 05:37:59 +02003194if test "x$GUITYPE:$enable_fontset" = "xGTK:yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003195 AC_MSG_RESULT(GTK+ 2 GUI selected; fontset has been disabled)
3196 enable_fontset="no"
3197fi
3198
Bram Moolenaarb3f74062020-02-26 16:16:53 +01003199dnl There is no test for the Haiku GUI, if it's selected it's used
3200if test -z "$SKIP_HAIKU"; then
3201 GUITYPE=HAIKUGUI
3202fi
3203
Bram Moolenaar071d4272004-06-13 20:20:40 +00003204if test -z "$SKIP_PHOTON"; then
3205 GUITYPE=PHOTONGUI
3206fi
3207
3208AC_SUBST(GUI_INC_LOC)
3209AC_SUBST(GUI_LIB_LOC)
3210AC_SUBST(GUITYPE)
3211AC_SUBST(GUI_X_LIBS)
3212
3213if test "$enable_workshop" = "yes" -a -n "$SKIP_MOTIF"; then
3214 AC_MSG_ERROR([cannot use workshop without Motif])
3215fi
3216
3217dnl defining FEAT_XIM and FEAT_XFONTSET is delayed, so that they can be disabled
3218if test "$enable_xim" = "yes"; then
3219 AC_DEFINE(FEAT_XIM)
3220fi
3221if test "$enable_fontset" = "yes"; then
3222 AC_DEFINE(FEAT_XFONTSET)
3223fi
3224
3225
3226dnl ---------------------------------------------------------------------------
3227dnl end of GUI-checking
3228dnl ---------------------------------------------------------------------------
3229
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003230AC_MSG_CHECKING([for /proc link to executable])
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003231if test -L "/proc/self/exe"; then
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003232 dnl Linux
3233 AC_MSG_RESULT([/proc/self/exe])
3234 AC_DEFINE(PROC_EXE_LINK, "/proc/self/exe")
3235elif test -L "/proc/self/path/a.out"; then
3236 dnl Solaris
3237 AC_MSG_RESULT([/proc/self/path/a.out])
3238 AC_DEFINE(PROC_EXE_LINK, "/proc/self/path/a.out")
3239elif test -L "/proc/curproc/file"; then
3240 dnl FreeBSD
3241 AC_MSG_RESULT([/proc/curproc/file])
3242 AC_DEFINE(PROC_EXE_LINK, "/proc/curproc/file")
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003243else
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003244 AC_MSG_RESULT(no)
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003245fi
3246
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003247dnl Check for Cygwin, which needs an extra source file if not using X11
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003248AC_MSG_CHECKING(for CYGWIN or MSYS environment)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00003249case $vim_cv_uname_output in
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003250 CYGWIN*|MSYS*) CYGWIN=yes; AC_MSG_RESULT(yes)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003251 AC_MSG_CHECKING(for CYGWIN clipboard support)
3252 if test "x$with_x" = "xno" ; then
3253 OS_EXTRA_SRC=winclip.c; OS_EXTRA_OBJ=objects/winclip.o
3254 AC_MSG_RESULT(yes)
3255 AC_DEFINE(FEAT_CYGWIN_WIN32_CLIPBOARD)
3256 else
3257 AC_MSG_RESULT(no - using X11)
3258 fi ;;
3259
3260 *) CYGWIN=no; AC_MSG_RESULT(no);;
3261esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00003262
Bram Moolenaar071d4272004-06-13 20:20:40 +00003263dnl Checks for libraries and include files.
3264
Bram Moolenaar446cb832008-06-24 21:56:24 +00003265AC_CACHE_CHECK([whether toupper is broken], [vim_cv_toupper_broken],
3266 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003267 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003268#include "confdefs.h"
3269#include <ctype.h>
3270#if STDC_HEADERS
3271# include <stdlib.h>
3272# include <stddef.h>
3273#endif
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01003274int main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003275 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003276 vim_cv_toupper_broken=yes
3277 ],[
3278 vim_cv_toupper_broken=no
3279 ],[
Jonas Sortie Termansen2cf145b2024-11-03 20:58:21 +01003280 vim_cv_toupper_broken=no
3281 AC_MSG_WARN(cross-compiling: consider setting 'vim_cv_toupper_broken')
Bram Moolenaar446cb832008-06-24 21:56:24 +00003282 ])])
3283
3284if test "x$vim_cv_toupper_broken" = "xyes" ; then
3285 AC_DEFINE(BROKEN_TOUPPER)
3286fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003287
3288AC_MSG_CHECKING(whether __DATE__ and __TIME__ work)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003289AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>], [printf("(" __DATE__ " " __TIME__ ")");])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003290 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DATE_TIME),
3291 AC_MSG_RESULT(no))
3292
Bram Moolenaar0c094b92009-05-14 20:20:33 +00003293AC_MSG_CHECKING(whether __attribute__((unused)) is allowed)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003294AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>], [int x __attribute__((unused));])],
Bram Moolenaar0c094b92009-05-14 20:20:33 +00003295 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ATTRIBUTE_UNUSED),
3296 AC_MSG_RESULT(no))
3297
Bram Moolenaar071d4272004-06-13 20:20:40 +00003298AC_HEADER_DIRENT
3299
Bram Moolenaar071d4272004-06-13 20:20:40 +00003300dnl If sys/wait.h is not found it might still exist but not be POSIX
3301dnl compliant. In that case we define HAVE_UNION_WAIT (for NeXT)
3302if test $ac_cv_header_sys_wait_h = no; then
3303 AC_MSG_CHECKING([for sys/wait.h that defines union wait])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003304 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/wait.h>],
3305 [union wait xx, yy; xx = yy])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003306 AC_MSG_RESULT(yes)
3307 AC_DEFINE(HAVE_SYS_WAIT_H)
3308 AC_DEFINE(HAVE_UNION_WAIT),
3309 AC_MSG_RESULT(no))
3310fi
3311
Bram Moolenaar779a7752016-01-30 23:26:34 +01003312AC_CHECK_HEADERS(stdint.h stdlib.h string.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003313 sys/select.h sys/utsname.h termcap.h fcntl.h \
3314 sgtty.h sys/ioctl.h sys/time.h sys/types.h \
3315 termio.h iconv.h inttypes.h langinfo.h math.h \
3316 unistd.h stropts.h errno.h sys/resource.h \
3317 sys/systeminfo.h locale.h sys/stream.h termios.h \
3318 libc.h sys/statfs.h poll.h sys/poll.h pwd.h \
Bram Moolenaar1ecc5e42019-01-26 15:12:55 +01003319 utime.h sys/param.h sys/ptms.h libintl.h libgen.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003320 util/debug.h util/msg18n.h frame.h sys/acl.h \
3321 sys/access.h sys/sysinfo.h wchar.h wctype.h)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003322
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003323dnl sys/ptem.h depends on sys/stream.h on Solaris
3324AC_CHECK_HEADERS(sys/ptem.h, [], [],
3325[#if defined HAVE_SYS_STREAM_H
3326# include <sys/stream.h>
3327#endif])
3328
Bram Moolenaar32f31b12009-05-21 13:20:59 +00003329dnl sys/sysctl.h depends on sys/param.h on OpenBSD
3330AC_CHECK_HEADERS(sys/sysctl.h, [], [],
3331[#if defined HAVE_SYS_PARAM_H
3332# include <sys/param.h>
3333#endif])
3334
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003335
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003336dnl pthread_np.h may exist but can only be used after including pthread.h
3337AC_MSG_CHECKING([for pthread_np.h])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003338AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003339#include <pthread.h>
3340#include <pthread_np.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003341 [int i; i = 0;])],
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003342 AC_MSG_RESULT(yes)
3343 AC_DEFINE(HAVE_PTHREAD_NP_H),
3344 AC_MSG_RESULT(no))
3345
Bram Moolenaare344bea2005-09-01 20:46:49 +00003346AC_CHECK_HEADERS(strings.h)
Bram Moolenaard0573012017-10-28 21:11:06 +02003347if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00003348 dnl The strings.h file on OS/X contains a warning and nothing useful.
3349 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3350else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003351
3352dnl Check if strings.h and string.h can both be included when defined.
3353AC_MSG_CHECKING([if strings.h can be included after string.h])
3354cppflags_save=$CPPFLAGS
3355CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003356AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003357#if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO)
3358# define _NO_PROTO /* like in os_unix.h, causes conflict for AIX (Winn) */
3359 /* but don't do it on AIX 5.1 (Uribarri) */
3360#endif
3361#ifdef HAVE_XM_XM_H
3362# include <Xm/Xm.h> /* This breaks it for HP-UX 11 (Squassabia) */
3363#endif
3364#ifdef HAVE_STRING_H
3365# include <string.h>
3366#endif
3367#if defined(HAVE_STRINGS_H)
3368# include <strings.h>
3369#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003370 ], [int i; i = 0;])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003371 AC_MSG_RESULT(yes),
3372 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3373 AC_MSG_RESULT(no))
3374CPPFLAGS=$cppflags_save
Bram Moolenaar9372a112005-12-06 19:59:18 +00003375fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003376
3377dnl Checks for typedefs, structures, and compiler characteristics.
3378AC_PROG_GCC_TRADITIONAL
3379AC_C_CONST
Bram Moolenaar76243bd2009-03-02 01:47:02 +00003380AC_C_VOLATILE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003381AC_TYPE_MODE_T
3382AC_TYPE_OFF_T
3383AC_TYPE_PID_T
3384AC_TYPE_SIZE_T
3385AC_TYPE_UID_T
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003386AC_TYPE_UINT32_T
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003387
Illia Bobyrf39842f2023-08-27 18:21:23 +02003388AC_CHECK_HEADERS_ONCE([sys/time.h])
3389
Bram Moolenaar071d4272004-06-13 20:20:40 +00003390AC_CHECK_TYPE(ino_t, long)
3391AC_CHECK_TYPE(dev_t, unsigned)
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003392AC_C_BIGENDIAN(,,,)
Bram Moolenaar136f29a2016-02-27 20:14:15 +01003393AC_C_INLINE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003394
3395AC_MSG_CHECKING(for rlim_t)
3396if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
3397 AC_MSG_RESULT([(cached) $ac_cv_type_rlim_t])
3398else
3399 AC_EGREP_CPP(dnl
3400changequote(<<,>>)dnl
3401<<(^|[^a-zA-Z_0-9])rlim_t[^a-zA-Z_0-9]>>dnl
3402changequote([,]),
3403 [
3404#include <sys/types.h>
3405#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003406# include <stdlib.h>
3407# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003408#endif
3409#ifdef HAVE_SYS_RESOURCE_H
Bram Moolenaar446cb832008-06-24 21:56:24 +00003410# include <sys/resource.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003411#endif
3412 ], ac_cv_type_rlim_t=yes, ac_cv_type_rlim_t=no)
3413 AC_MSG_RESULT($ac_cv_type_rlim_t)
3414fi
3415if test $ac_cv_type_rlim_t = no; then
3416 cat >> confdefs.h <<\EOF
3417#define rlim_t unsigned long
3418EOF
3419fi
3420
3421AC_MSG_CHECKING(for stack_t)
3422if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then
3423 AC_MSG_RESULT([(cached) $ac_cv_type_stack_t])
3424else
3425 AC_EGREP_CPP(stack_t,
3426 [
3427#include <sys/types.h>
3428#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003429# include <stdlib.h>
3430# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003431#endif
3432#include <signal.h>
3433 ], ac_cv_type_stack_t=yes, ac_cv_type_stack_t=no)
3434 AC_MSG_RESULT($ac_cv_type_stack_t)
3435fi
3436if test $ac_cv_type_stack_t = no; then
3437 cat >> confdefs.h <<\EOF
3438#define stack_t struct sigaltstack
3439EOF
3440fi
3441
3442dnl BSDI uses ss_base while others use ss_sp for the stack pointer.
3443AC_MSG_CHECKING(whether stack_t has an ss_base field)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003444AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003445#include <sys/types.h>
3446#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003447# include <stdlib.h>
3448# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003449#endif
3450#include <signal.h>
3451#include "confdefs.h"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003452 ], [stack_t sigstk; sigstk.ss_base = 0; ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003453 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SS_BASE),
3454 AC_MSG_RESULT(no))
3455
3456olibs="$LIBS"
3457AC_MSG_CHECKING(--with-tlib argument)
3458AC_ARG_WITH(tlib, [ --with-tlib=library terminal library to be used ],)
3459if test -n "$with_tlib"; then
3460 AC_MSG_RESULT($with_tlib)
3461 LIBS="$LIBS -l$with_tlib"
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003462 AC_MSG_CHECKING(for linking with $with_tlib library)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003463 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], AC_MSG_RESULT(OK), AC_MSG_ERROR(FAILED))
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003464 dnl Need to check for tgetent() below.
3465 olibs="$LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003466else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003467 AC_MSG_RESULT([empty: automatic terminal library selection])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003468 dnl On HP-UX 10.10 termcap or termlib should be used instead of
3469 dnl curses, because curses is much slower.
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003470 dnl Newer versions of ncurses are preferred over anything, except
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02003471 dnl when tinfo has been split off, it contains all we need.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003472 dnl Older versions of ncurses have bugs, get a new one!
3473 dnl Digital Unix (OSF1) should use curses (Ronald Schild).
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00003474 dnl On SCO Openserver should prefer termlib (Roger Cornelius).
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00003475 case "$vim_cv_uname_output" in
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003476 OSF1|SCO_SV) tlibs="tinfo ncurses curses termlib termcap";;
3477 *) tlibs="tinfo ncurses termlib termcap curses";;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003478 esac
3479 for libname in $tlibs; do
3480 AC_CHECK_LIB(${libname}, tgetent,,)
3481 if test "x$olibs" != "x$LIBS"; then
3482 dnl It's possible that a library is found but it doesn't work
3483 dnl e.g., shared library that cannot be found
3484 dnl compile and run a test program to be sure
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003485 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003486#ifdef HAVE_TERMCAP_H
3487# include <termcap.h>
3488#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003489#if STDC_HEADERS
3490# include <stdlib.h>
3491# include <stddef.h>
3492#endif
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01003493int main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }])],
Jonas Sortie Termansen2cf145b2024-11-03 20:58:21 +01003494 res="OK", res="FAIL", res="OK")
Bram Moolenaar071d4272004-06-13 20:20:40 +00003495 if test "$res" = "OK"; then
3496 break
3497 fi
3498 AC_MSG_RESULT($libname library is not usable)
3499 LIBS="$olibs"
3500 fi
3501 done
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003502 if test "x$olibs" = "x$LIBS"; then
3503 AC_MSG_RESULT(no terminal library found)
3504 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003505fi
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003506
3507if test "x$olibs" = "x$LIBS"; then
3508 AC_MSG_CHECKING([for tgetent()])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003509 AC_LINK_IFELSE([AC_LANG_PROGRAM([int tgetent(char *, const char *);],
3510 [[char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");]])],
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003511 AC_MSG_RESULT(yes),
3512 AC_MSG_ERROR([NOT FOUND!
3513 You need to install a terminal library; for example ncurses.
Bram Moolenaar16678eb2021-04-21 11:57:59 +02003514 On Linux that would be the libncurses-dev package.
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003515 Or specify the name of the library with --with-tlib.]))
3516fi
3517
Bram Moolenaar446cb832008-06-24 21:56:24 +00003518AC_CACHE_CHECK([whether we talk terminfo], [vim_cv_terminfo],
3519 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003520 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003521#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003522#ifdef HAVE_TERMCAP_H
3523# include <termcap.h>
3524#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003525#ifdef HAVE_STRING_H
3526# include <string.h>
3527#endif
3528#if STDC_HEADERS
3529# include <stdlib.h>
3530# include <stddef.h>
3531#endif
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01003532int main()
Jonas Sortie Termansen2cf145b2024-11-03 20:58:21 +01003533{char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!!strcmp(s==0 ? "" : s, "1")); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003534 ]])],[
Jonas Sortie Termansen2cf145b2024-11-03 20:58:21 +01003535 vim_cv_terminfo=yes
3536 ],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003537 vim_cv_terminfo=no
3538 ],[
3539 vim_cv_terminfo=yes
Jonas Sortie Termansen2cf145b2024-11-03 20:58:21 +01003540 AC_MSG_WARN(cross-compiling: consider setting 'vim_cv_terminfo')
Bram Moolenaar446cb832008-06-24 21:56:24 +00003541 ])
3542 ])
3543
3544if test "x$vim_cv_terminfo" = "xyes" ; then
3545 AC_DEFINE(TERMINFO)
3546fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003547
Bram Moolenaara88254f2017-11-02 23:04:14 +01003548AC_CACHE_CHECK([what tgetent() returns for an unknown terminal], [vim_cv_tgetent],
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003549 [
3550 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003551#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003552#ifdef HAVE_TERMCAP_H
3553# include <termcap.h>
3554#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003555#if STDC_HEADERS
3556# include <stdlib.h>
3557# include <stddef.h>
3558#endif
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01003559int main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003560{char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003561 ]])],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003562 vim_cv_tgetent=zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003563 ],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003564 vim_cv_tgetent=non-zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003565 ],[
Jonas Sortie Termansen2cf145b2024-11-03 20:58:21 +01003566 vim_cv_tgetent=zero
3567 AC_MSG_WARN(cross-compiling: consider setting 'vim_cv_tgetent')
Bram Moolenaar446cb832008-06-24 21:56:24 +00003568 ])
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003569 ])
3570
Bram Moolenaara88254f2017-11-02 23:04:14 +01003571if test "x$vim_cv_tgetent" = "xzero" ; then
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003572 AC_DEFINE(TGETENT_ZERO_ERR, 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003573fi
3574
3575AC_MSG_CHECKING(whether termcap.h contains ospeed)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003576AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003577#ifdef HAVE_TERMCAP_H
3578# include <termcap.h>
3579#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003580 ], [ospeed = 20000])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003581 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED),
3582 [AC_MSG_RESULT(no)
3583 AC_MSG_CHECKING(whether ospeed can be extern)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003584 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003585#ifdef HAVE_TERMCAP_H
3586# include <termcap.h>
3587#endif
3588extern short ospeed;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003589 ], [ospeed = 20000])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003590 AC_MSG_RESULT(yes); AC_DEFINE(OSPEED_EXTERN),
3591 AC_MSG_RESULT(no))]
3592 )
3593
3594AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003595AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003596#ifdef HAVE_TERMCAP_H
3597# include <termcap.h>
3598#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003599 ], [if (UP == 0 && BC == 0) PC = 1])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003600 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UP_BC_PC),
3601 [AC_MSG_RESULT(no)
3602 AC_MSG_CHECKING([whether UP, BC and PC can be extern])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003603 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003604#ifdef HAVE_TERMCAP_H
3605# include <termcap.h>
3606#endif
3607extern char *UP, *BC, PC;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003608 ], [if (UP == 0 && BC == 0) PC = 1])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003609 AC_MSG_RESULT(yes); AC_DEFINE(UP_BC_PC_EXTERN),
3610 AC_MSG_RESULT(no))]
3611 )
3612
3613AC_MSG_CHECKING(whether tputs() uses outfuntype)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003614AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003615#ifdef HAVE_TERMCAP_H
3616# include <termcap.h>
3617#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003618 ], [extern int xx(); tputs("test", 1, (outfuntype)xx)])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003619 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OUTFUNTYPE),
3620 AC_MSG_RESULT(no))
3621
Bram Moolenaarb3a29552021-11-19 11:28:04 +00003622AC_MSG_CHECKING([whether del_curterm() can be used])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003623AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaarb3a29552021-11-19 11:28:04 +00003624#ifdef HAVE_TERMCAP_H
3625# include <termcap.h>
3626#endif
3627#include <term.h>
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003628 ], [if (cur_term) del_curterm(cur_term);])],
Bram Moolenaarb3a29552021-11-19 11:28:04 +00003629 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DEL_CURTERM),
3630 AC_MSG_RESULT(no))
3631
Bram Moolenaar071d4272004-06-13 20:20:40 +00003632dnl On some SCO machines sys/select redefines struct timeval
3633AC_MSG_CHECKING([whether sys/select.h and sys/time.h may both be included])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003634AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003635#include <sys/types.h>
3636#include <sys/time.h>
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003637#include <sys/select.h>], )],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003638 AC_MSG_RESULT(yes)
3639 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME),
3640 AC_MSG_RESULT(no))
3641
Bram Moolenaar071d4272004-06-13 20:20:40 +00003642dnl Checks for pty.c (copied from screen) ==========================
3643AC_MSG_CHECKING(for /dev/ptc)
3644if test -r /dev/ptc; then
3645 AC_DEFINE(HAVE_DEV_PTC)
3646 AC_MSG_RESULT(yes)
3647else
3648 AC_MSG_RESULT(no)
3649fi
3650
3651AC_MSG_CHECKING(for SVR4 ptys)
3652if test -c /dev/ptmx ; then
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003653 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaarce7be3a2020-11-26 20:11:11 +01003654// These should be in stdlib.h, but it depends on _XOPEN_SOURCE.
3655char *ptsname(int);
3656int unlockpt(int);
3657int grantpt(int);
3658 ], [
3659 ptsname(0);
3660 grantpt(0);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003661 unlockpt(0);])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003662 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SVR4_PTYS),
3663 AC_MSG_RESULT(no))
3664else
3665 AC_MSG_RESULT(no)
3666fi
3667
3668AC_MSG_CHECKING(for ptyranges)
3669if test -d /dev/ptym ; then
3670 pdir='/dev/ptym'
3671else
3672 pdir='/dev'
3673fi
3674dnl SCO uses ptyp%d
3675AC_EGREP_CPP(yes,
3676[#ifdef M_UNIX
3677 yes;
3678#endif
3679 ], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
3680dnl if test -c /dev/ptyp19; then
3681dnl ptys=`echo /dev/ptyp??`
3682dnl else
3683dnl ptys=`echo $pdir/pty??`
3684dnl fi
3685if test "$ptys" != "$pdir/pty??" ; then
3686 p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
3687 p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'`
3688 AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
3689 AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
3690 AC_MSG_RESULT([$p0 / $p1])
3691else
3692 AC_MSG_RESULT([don't know])
3693fi
3694
Bram Moolenaar071d4272004-06-13 20:20:40 +00003695dnl Checks for library functions. ===================================
3696
Bram Moolenaar071d4272004-06-13 20:20:40 +00003697dnl check if struct sigcontext is defined (used for SGI only)
3698AC_MSG_CHECKING(for struct sigcontext)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003699AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003700#include <signal.h>
Sam Jamesf8ea1062022-11-05 15:13:50 +00003701int test_sig()
Bram Moolenaar071d4272004-06-13 20:20:40 +00003702{
3703 struct sigcontext *scont;
3704 scont = (struct sigcontext *)0;
3705 return 1;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003706} ], )],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003707 AC_MSG_RESULT(yes)
3708 AC_DEFINE(HAVE_SIGCONTEXT),
3709 AC_MSG_RESULT(no))
3710
3711dnl tricky stuff: try to find out if getcwd() is implemented with
3712dnl system("sh -c pwd")
Bram Moolenaar446cb832008-06-24 21:56:24 +00003713AC_CACHE_CHECK([getcwd implementation is broken], [vim_cv_getcwd_broken],
3714 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003715 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003716#include "confdefs.h"
3717#ifdef HAVE_UNISTD_H
3718#include <unistd.h>
3719#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003720char *dagger[] = { "IFS=pwd", 0 };
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01003721int main()
Bram Moolenaar071d4272004-06-13 20:20:40 +00003722{
3723 char buffer[500];
3724 extern char **environ;
3725 environ = dagger;
3726 return getcwd(buffer, 500) ? 0 : 1;
Bram Moolenaar446cb832008-06-24 21:56:24 +00003727}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003728 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003729 vim_cv_getcwd_broken=no
3730 ],[
3731 vim_cv_getcwd_broken=yes
3732 ],[
Jonas Sortie Termansen2cf145b2024-11-03 20:58:21 +01003733 vim_cv_getcwd_broken=no
3734 AC_MSG_WARN(cross-compiling: consider setting 'vim_cv_getcwd_broken')
Bram Moolenaar446cb832008-06-24 21:56:24 +00003735 ])
3736 ])
3737
3738if test "x$vim_cv_getcwd_broken" = "xyes" ; then
3739 AC_DEFINE(BAD_GETCWD)
Bram Moolenaar63d25552019-05-10 21:28:38 +02003740 AC_CHECK_FUNCS(getwd)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003741fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003742
Bram Moolenaar25153e12010-02-24 14:47:08 +01003743dnl Check for functions in one big call, to reduce the size of configure.
3744dnl Can only be used for functions that do not require any include.
Bram Moolenaarcd142e32017-11-16 17:03:45 +01003745AC_CHECK_FUNCS(fchdir fchown fchmod fsync getcwd getpseudotty \
Bram Moolenaar63d25552019-05-10 21:28:38 +02003746 getpwent getpwnam getpwuid getrlimit gettimeofday localtime_r lstat \
Bram Moolenaareaf03392009-11-17 11:08:52 +00003747 memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
Bram Moolenaar2fcf6682017-03-11 20:03:42 +01003748 getpgid setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
Bram Moolenaar84cf6bd2020-06-16 20:03:43 +02003749 sigprocmask sigvec strcasecmp strcoll strerror strftime stricmp strncasecmp \
Bram Moolenaar10455d42019-11-21 15:36:18 +01003750 strnicmp strpbrk strptime strtol tgetent towlower towupper iswupper \
Bram Moolenaar08210f82023-04-13 19:15:54 +01003751 tzset usleep utime utimes mblen ftruncate unsetenv posix_openpt \
Jonas Sortie Termansen8bb5eaf2024-11-04 20:32:27 +01003752 clock_gettime sync)
Bram Moolenaar643b6142018-09-12 20:29:09 +02003753AC_FUNC_SELECT_ARGTYPES
Bram Moolenaar25153e12010-02-24 14:47:08 +01003754AC_FUNC_FSEEKO
Bram Moolenaar071d4272004-06-13 20:20:40 +00003755
Bram Moolenaar317fd3a2010-05-07 16:05:55 +02003756dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when
3757dnl appropriate, so that off_t is 64 bits when needed.
3758AC_SYS_LARGEFILE
3759
Bram Moolenaar21606672019-06-14 20:40:58 +02003760AC_MSG_CHECKING(--enable-canberra argument)
3761AC_ARG_ENABLE(canberra,
3762 [ --disable-canberra Do not use libcanberra.],
3763 , [enable_canberra="maybe"])
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003764
Bram Moolenaar21606672019-06-14 20:40:58 +02003765if test "$enable_canberra" = "maybe"; then
Martin Tournoij25f3a142022-10-08 19:26:41 +01003766 if test "$features" = "huge"; then
Bram Moolenaar21606672019-06-14 20:40:58 +02003767 AC_MSG_RESULT(Defaulting to yes)
3768 enable_canberra="yes"
3769 else
3770 AC_MSG_RESULT(Defaulting to no)
3771 enable_canberra="no"
3772 fi
3773else
Bram Moolenaar12471262022-01-18 11:11:25 +00003774 if test "$enable_canberra" = "yes" -a "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +01003775 AC_MSG_RESULT([cannot use sound with tiny features])
Bram Moolenaar12471262022-01-18 11:11:25 +00003776 enable_canberra="no"
3777 else
3778 AC_MSG_RESULT($enable_canberra)
3779 fi
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003780fi
Bram Moolenaar21606672019-06-14 20:40:58 +02003781if test "$enable_canberra" = "yes"; then
3782 if test "x$PKG_CONFIG" != "xno"; then
3783 canberra_lib=`$PKG_CONFIG --libs libcanberra 2>/dev/null`
3784 canberra_cflags=`$PKG_CONFIG --cflags libcanberra 2>/dev/null`
3785 fi
3786 if test "x$canberra_lib" = "x"; then
3787 canberra_lib=-lcanberra
3788 canberra_cflags=-D_REENTRANT
3789 fi
3790 AC_MSG_CHECKING(for libcanberra)
3791 ac_save_CFLAGS="$CFLAGS"
3792 ac_save_LIBS="$LIBS"
Bram Moolenaar12471262022-01-18 11:11:25 +00003793 if `echo "$CFLAGS" | grep -v "$canberra_cflags" 2>/dev/null`; then
Christian Brabandt6b9efdd2021-09-09 17:14:50 +02003794 CFLAGS="$CFLAGS $canberra_cflags"
3795 fi
Bram Moolenaar21606672019-06-14 20:40:58 +02003796 LIBS="$LIBS $canberra_lib"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003797 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar21606672019-06-14 20:40:58 +02003798 # include <canberra.h>
3799 ], [
3800 ca_context *hello;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003801 ca_context_create(&hello);])],
Bram Moolenaar21606672019-06-14 20:40:58 +02003802 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_CANBERRA),
Bram Moolenaar91b992c2019-11-17 19:07:42 +01003803 AC_MSG_RESULT(no; try installing libcanberra-dev); CFLAGS="$ac_save_CFLAGS"; LIBS="$ac_save_LIBS")
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003804fi
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003805
Christian Brabandtf573c6e2021-06-20 14:02:16 +02003806AC_MSG_CHECKING(--enable-libsodium argument)
3807AC_ARG_ENABLE(libsodium,
3808 [ --disable-libsodium Do not use libsodium.],
3809 , [enable_libsodium="maybe"])
3810
3811if test "$enable_libsodium" = "maybe"; then
Martin Tournoij25f3a142022-10-08 19:26:41 +01003812 if test "$features" = "huge"; then
Christian Brabandtf573c6e2021-06-20 14:02:16 +02003813 AC_MSG_RESULT(Defaulting to yes)
3814 enable_libsodium="yes"
3815 else
3816 AC_MSG_RESULT(Defaulting to no)
3817 enable_libsodium="no"
3818 fi
3819else
3820 AC_MSG_RESULT($enable_libsodium)
3821fi
3822if test "$enable_libsodium" = "yes"; then
3823 if test "x$PKG_CONFIG" != "xno"; then
3824 libsodium_lib=`$PKG_CONFIG --libs libsodium 2>/dev/null`
3825 libsodium_cflags=`$PKG_CONFIG --cflags libsodium 2>/dev/null`
3826 fi
3827 if test "x$libsodium_lib" = "x"; then
3828 libsodium_lib=-lsodium
3829 libsodium_cflags=
3830 fi
ichizok8ce3ca82021-06-23 15:41:52 +02003831 AC_MSG_CHECKING(for libsodium)
Christian Brabandtf573c6e2021-06-20 14:02:16 +02003832 ac_save_CFLAGS="$CFLAGS"
3833 ac_save_LIBS="$LIBS"
3834 CFLAGS="$CFLAGS $libsodium_cflags"
3835 LIBS="$LIBS $libsodium_lib"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003836 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Christian Brabandtf573c6e2021-06-20 14:02:16 +02003837 # include <sodium.h>
3838 ], [
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003839 printf("%d", sodium_init()); ])],
Christian Brabandtf573c6e2021-06-20 14:02:16 +02003840 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SODIUM),
3841 AC_MSG_RESULT(no; try installing libsodium-dev); CFLAGS="$ac_save_CFLAGS"; LIBS="$ac_save_LIBS")
3842fi
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003843
Bram Moolenaar071d4272004-06-13 20:20:40 +00003844dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible
3845AC_MSG_CHECKING(for st_blksize)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003846AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00003847[#include <sys/types.h>
3848#include <sys/stat.h>],
3849[ struct stat st;
3850 int n;
3851
3852 stat("/", &st);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003853 n = (int)st.st_blksize;])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003854 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ST_BLKSIZE),
3855 AC_MSG_RESULT(no))
3856
Paul Ollis65745772022-06-05 16:55:54 +01003857dnl Check for timer_create. It probably requires the 'rt' library.
Bram Moolenaarefffa532022-07-28 22:39:54 +01003858AC_CACHE_CHECK([for timer_create without -lrt], [vim_cv_timer_create], [
Jonas Sortie Termansen2cf145b2024-11-03 20:58:21 +01003859 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
3860 #include <time.h>
3861 ], [
3862 timer_create(CLOCK_MONOTONIC, NULL, NULL);
3863 ])],
3864 vim_cv_timer_create=yes,
3865 vim_cv_timer_create=no
Bram Moolenaarefffa532022-07-28 22:39:54 +01003866 )])
Paul Ollis65745772022-06-05 16:55:54 +01003867
Bram Moolenaarefffa532022-07-28 22:39:54 +01003868dnl If the previous failed, check for timer_create() and linking with -lrt.
3869if test "x$vim_cv_timer_create" = "xno" ; then
3870 save_LIBS="$LIBS"
3871 LIBS="$LIBS -lrt"
3872 AC_CACHE_CHECK([for timer_create with -lrt], [vim_cv_timer_create_with_lrt], [
Jonas Sortie Termansen2cf145b2024-11-03 20:58:21 +01003873 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
3874 #include <time.h>
3875 ], [
3876 timer_create(CLOCK_MONOTONIC, NULL, NULL);
3877 ])],
3878 vim_cv_timer_create_with_lrt=yes,
3879 vim_cv_timer_create_with_lrt=no
3880 )])
3881 LIBS="$save_LIBS"
3882else
3883 vim_cv_timer_create_with_lrt=no
3884fi
3885
3886dnl Run the program to find out if timer_create(CLOCK_MONOTONIC) actually
3887dnl works, on Solaris timer_create() exists but fails at runtime.
3888if test "x$vim_cv_timer_create" = "xyes" ||
3889 test "x$vim_cv_timer_create_with_lrt" = "xyes"; then
3890 save_LIBS="$LIBS"
Brandon Maiercbdc3c12024-12-18 21:18:01 +01003891 if test "x$vim_cv_timer_create_with_lrt" = "xyes" ; then
Jonas Sortie Termansen2cf145b2024-11-03 20:58:21 +01003892 LIBS="$LIBS -lrt"
3893 fi
3894
3895 AC_CACHE_CHECK([if timer_create works], [vim_cv_timer_create_works], [
Bram Moolenaarefffa532022-07-28 22:39:54 +01003896 AC_RUN_IFELSE([AC_LANG_PROGRAM([
3897 #if STDC_HEADERS
3898 # include <stdlib.h>
3899 # include <stddef.h>
3900 #endif
3901 #include <signal.h>
3902 #include <time.h>
3903 static void set_flag(union sigval sv) {}
3904 ], [
3905 struct timespec ts;
3906 struct sigevent action = {0};
3907 timer_t timer_id;
3908
3909 action.sigev_notify = SIGEV_THREAD;
3910 action.sigev_notify_function = set_flag;
3911 if (timer_create(CLOCK_MONOTONIC, &action, &timer_id) < 0)
Jonas Sortie Termansen2cf145b2024-11-03 20:58:21 +01003912 exit(1); // cannot create a monotonic timer
Bram Moolenaarefffa532022-07-28 22:39:54 +01003913 ])],
Jonas Sortie Termansen2cf145b2024-11-03 20:58:21 +01003914 vim_cv_timer_create_works=yes,
3915 vim_cv_timer_create_works=no,
3916 vim_cv_timer_create_works=yes
3917 AC_MSG_WARN([cross-compiling: consider setting 'vim_cv_timer_create_works'])
Bram Moolenaarefffa532022-07-28 22:39:54 +01003918 )])
Richard Purdie509695c2022-07-24 20:48:00 +01003919
Jonas Sortie Termansen2cf145b2024-11-03 20:58:21 +01003920 if test "x$vim_cv_timer_create_works" = "xyes" ; then
3921 AC_DEFINE(HAVE_TIMER_CREATE)
Jonas Sortie Termansen2cf145b2024-11-03 20:58:21 +01003922 else
3923 LIBS="$save_LIBS"
3924 fi
Bram Moolenaarefffa532022-07-28 22:39:54 +01003925fi
Paul Ollis65745772022-06-05 16:55:54 +01003926
Bram Moolenaar446cb832008-06-24 21:56:24 +00003927AC_CACHE_CHECK([whether stat() ignores a trailing slash], [vim_cv_stat_ignores_slash],
3928 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003929 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003930#include "confdefs.h"
3931#if STDC_HEADERS
3932# include <stdlib.h>
3933# include <stddef.h>
3934#endif
3935#include <sys/types.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003936#include <sys/stat.h>
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01003937int main() {struct stat st; exit(stat("configure/", &st) != 0); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003938 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003939 vim_cv_stat_ignores_slash=yes
3940 ],[
3941 vim_cv_stat_ignores_slash=no
3942 ],[
Jonas Sortie Termansen2cf145b2024-11-03 20:58:21 +01003943 vim_cv_stat_ignores_slash=yes
3944 AC_MSG_WARN(cross-compiling: consider setting 'vim_cv_stat_ignores_slash')
Bram Moolenaar446cb832008-06-24 21:56:24 +00003945 ])
3946 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003947
Bram Moolenaar446cb832008-06-24 21:56:24 +00003948if test "x$vim_cv_stat_ignores_slash" = "xyes" ; then
3949 AC_DEFINE(STAT_IGNORES_SLASH)
3950fi
Leah Neukirchen0a7984a2021-10-14 21:27:55 +01003951
3952dnl nanoseconds field of struct stat
3953AC_CACHE_CHECK([for nanoseconds field of struct stat],
3954 ac_cv_struct_st_mtim_nsec,
3955 [ac_save_CPPFLAGS="$CPPFLAGS"
3956 ac_cv_struct_st_mtim_nsec=no
3957 # st_mtim.tv_nsec -- the usual case
3958 # st_mtim._tv_nsec -- Solaris 2.6, if
3959 # (defined _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED == 1
3960 # && !defined __EXTENSIONS__)
3961 # st_mtim.st__tim.tv_nsec -- UnixWare 2.1.2
3962 # st_mtime_n -- AIX 5.2 and above
3963 # st_mtimespec.tv_nsec -- Darwin (Mac OSX)
3964 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
3965 CPPFLAGS="$ac_save_CPPFLAGS -DST_MTIM_NSEC=$ac_val"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003966 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
3967#include <sys/stat.h>], [struct stat s; s.ST_MTIM_NSEC;])],
Leah Neukirchen0a7984a2021-10-14 21:27:55 +01003968 [ac_cv_struct_st_mtim_nsec=$ac_val; break])
3969 done
3970 CPPFLAGS="$ac_save_CPPFLAGS"
3971])
3972if test $ac_cv_struct_st_mtim_nsec != no; then
3973 AC_DEFINE_UNQUOTED([ST_MTIM_NSEC], [$ac_cv_struct_st_mtim_nsec],
3974 [Define if struct stat contains a nanoseconds field])
3975fi
Bram Moolenaare5303952022-06-19 17:05:47 +01003976
Bram Moolenaar071d4272004-06-13 20:20:40 +00003977dnl Link with iconv for charset translation, if not found without library.
3978dnl check for iconv() requires including iconv.h
3979dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
3980dnl has been installed.
3981AC_MSG_CHECKING(for iconv_open())
3982save_LIBS="$LIBS"
3983LIBS="$LIBS -liconv"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003984AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003985#ifdef HAVE_ICONV_H
3986# include <iconv.h>
3987#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003988 ], [iconv_open("fr", "to");])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003989 AC_MSG_RESULT(yes; with -liconv); AC_DEFINE(HAVE_ICONV),
3990 LIBS="$save_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003991 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003992#ifdef HAVE_ICONV_H
3993# include <iconv.h>
3994#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003995 ], [iconv_open("fr", "to");])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003996 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ICONV),
3997 AC_MSG_RESULT(no)))
3998
3999
4000AC_MSG_CHECKING(for nl_langinfo(CODESET))
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004001AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00004002#ifdef HAVE_LANGINFO_H
4003# include <langinfo.h>
4004#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004005], [char *cs = nl_langinfo(CODESET);])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004006 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET),
4007 AC_MSG_RESULT(no))
4008
Bram Moolenaar73e28dc2022-09-17 21:08:33 +01004009dnl Floating point support may require the "m" library
Bram Moolenaar446cb832008-06-24 21:56:24 +00004010AC_CHECK_LIB(m, strtod)
Bram Moolenaar446cb832008-06-24 21:56:24 +00004011
Bram Moolenaara6b89762016-02-29 21:38:26 +01004012dnl isinf() and isnan() need to include header files and may need -lm.
4013AC_MSG_CHECKING([for isinf()])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004014AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaara6b89762016-02-29 21:38:26 +01004015#ifdef HAVE_MATH_H
4016# include <math.h>
4017#endif
4018#if STDC_HEADERS
4019# include <stdlib.h>
4020# include <stddef.h>
4021#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004022], [int r = isinf(1.11); ])],
Bram Moolenaara6b89762016-02-29 21:38:26 +01004023 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISINF),
4024 AC_MSG_RESULT(no))
4025
4026AC_MSG_CHECKING([for isnan()])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004027AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaara6b89762016-02-29 21:38:26 +01004028#ifdef HAVE_MATH_H
4029# include <math.h>
4030#endif
4031#if STDC_HEADERS
4032# include <stdlib.h>
4033# include <stddef.h>
4034#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004035], [int r = isnan(1.11); ])],
Bram Moolenaara6b89762016-02-29 21:38:26 +01004036 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISNAN),
4037 AC_MSG_RESULT(no))
4038
Bram Moolenaar071d4272004-06-13 20:20:40 +00004039dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI
4040dnl when -lacl works, also try to use -lattr (required for Debian).
Bram Moolenaar8d462f92012-02-05 22:51:33 +01004041dnl On Solaris, use the acl_get/set functions in libsec, if present.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004042AC_MSG_CHECKING(--disable-acl argument)
4043AC_ARG_ENABLE(acl,
Bram Moolenaard6d30422018-01-28 22:48:55 +01004044 [ --disable-acl No check for ACL support.],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004045 , [enable_acl="yes"])
4046if test "$enable_acl" = "yes"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01004047 AC_MSG_RESULT(no)
4048 AC_CHECK_LIB(posix1e, acl_get_file, [LIBS="$LIBS -lposix1e"],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004049 AC_CHECK_LIB(acl, acl_get_file, [LIBS="$LIBS -lacl"
4050 AC_CHECK_LIB(attr, fgetxattr, LIBS="$LIBS -lattr",,)],,),)
4051
Bram Moolenaard6d30422018-01-28 22:48:55 +01004052 AC_MSG_CHECKING(for POSIX ACL support)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004053 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00004054#include <sys/types.h>
4055#ifdef HAVE_SYS_ACL_H
4056# include <sys/acl.h>
4057#endif
4058acl_t acl;], [acl = acl_get_file("foo", ACL_TYPE_ACCESS);
4059 acl_set_file("foo", ACL_TYPE_ACCESS, acl);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004060 acl_free(acl);])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004061 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_ACL),
4062 AC_MSG_RESULT(no))
4063
Bram Moolenaard6d30422018-01-28 22:48:55 +01004064 AC_CHECK_LIB(sec, acl_get, [LIBS="$LIBS -lsec"; AC_DEFINE(HAVE_SOLARIS_ZFS_ACL)],
4065 AC_MSG_CHECKING(for Solaris ACL support)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004066 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00004067#ifdef HAVE_SYS_ACL_H
4068# include <sys/acl.h>
4069#endif], [acl("foo", GETACLCNT, 0, NULL);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004070 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004071 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOLARIS_ACL),
Bram Moolenaar8d462f92012-02-05 22:51:33 +01004072 AC_MSG_RESULT(no)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004073
Bram Moolenaard6d30422018-01-28 22:48:55 +01004074 AC_MSG_CHECKING(for AIX ACL support)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004075 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar446cb832008-06-24 21:56:24 +00004076#if STDC_HEADERS
4077# include <stdlib.h>
4078# include <stddef.h>
4079#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004080#ifdef HAVE_SYS_ACL_H
4081# include <sys/acl.h>
4082#endif
4083#ifdef HAVE_SYS_ACCESS_H
4084# include <sys/access.h>
4085#endif
4086#define _ALL_SOURCE
4087
4088#include <sys/stat.h>
4089
4090int aclsize;
4091struct acl *aclent;], [aclsize = sizeof(struct acl);
4092 aclent = (void *)malloc(aclsize);
4093 statacl("foo", STX_NORMAL, aclent, aclsize);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004094 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004095 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_AIX_ACL),
4096 AC_MSG_RESULT(no))
4097else
4098 AC_MSG_RESULT(yes)
4099fi
4100
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02004101if test "x$GTK_CFLAGS" != "x"; then
4102 dnl pango_shape_full() is new, fall back to pango_shape().
4103 AC_MSG_CHECKING(for pango_shape_full)
4104 ac_save_CFLAGS="$CFLAGS"
4105 ac_save_LIBS="$LIBS"
4106 CFLAGS="$CFLAGS $GTK_CFLAGS"
4107 LIBS="$LIBS $GTK_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004108 AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02004109 [#include <gtk/gtk.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004110 [ pango_shape_full(NULL, 0, NULL, 0, NULL, NULL); ])],
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02004111 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_PANGO_SHAPE_FULL),
4112 AC_MSG_RESULT(no))
4113 CFLAGS="$ac_save_CFLAGS"
4114 LIBS="$ac_save_LIBS"
4115fi
4116
Bram Moolenaar33fc4a62022-02-23 18:07:38 +00004117AC_MSG_CHECKING(--enable-gpm argument)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004118AC_ARG_ENABLE(gpm,
Bram Moolenaar33fc4a62022-02-23 18:07:38 +00004119 [ --enable-gpm=OPTS Use gpm (Linux mouse daemon). default=yes OPTS=yes/no/dynamic], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00004120 [enable_gpm="yes"])
4121
Bram Moolenaar33fc4a62022-02-23 18:07:38 +00004122if test "$enable_gpm" = "yes" -o "$enable_gpm" = "dynamic"; then
4123 AC_MSG_RESULT($enable_gpm)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004124 dnl Checking if gpm support can be compiled
4125 AC_CACHE_CHECK([for gpm], vi_cv_have_gpm,
4126 [olibs="$LIBS" ; LIBS="-lgpm"]
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004127 AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004128 [#include <gpm.h>
4129 #include <linux/keyboard.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004130 [Gpm_GetLibVersion(NULL);])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004131 dnl Configure defines HAVE_GPM, if it is defined feature.h defines
4132 dnl FEAT_MOUSE_GPM if mouse support is included
4133 [vi_cv_have_gpm=yes],
4134 [vi_cv_have_gpm=no])
4135 [LIBS="$olibs"]
4136 )
4137 if test $vi_cv_have_gpm = yes; then
Bram Moolenaar33fc4a62022-02-23 18:07:38 +00004138 if test "$enable_gpm" = "yes"; then
4139 LIBS="$LIBS -lgpm"
4140 else
4141 AC_DEFINE(DYNAMIC_GPM)
4142 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004143 AC_DEFINE(HAVE_GPM)
4144 fi
4145else
Bram Moolenaar33fc4a62022-02-23 18:07:38 +00004146 AC_MSG_RESULT(no)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004147fi
4148
Bram Moolenaar446cb832008-06-24 21:56:24 +00004149AC_MSG_CHECKING(--disable-sysmouse argument)
4150AC_ARG_ENABLE(sysmouse,
Bram Moolenaar8008b632017-07-18 21:33:20 +02004151 [ --disable-sysmouse Don't use sysmouse (mouse in *BSD console).], ,
Bram Moolenaar446cb832008-06-24 21:56:24 +00004152 [enable_sysmouse="yes"])
4153
4154if test "$enable_sysmouse" = "yes"; then
4155 AC_MSG_RESULT(no)
4156 dnl Checking if sysmouse support can be compiled
4157 dnl Configure defines HAVE_SYSMOUSE, if it is defined feature.h
4158 dnl defines FEAT_SYSMOUSE if mouse support is included
4159 AC_CACHE_CHECK([for sysmouse], vi_cv_have_sysmouse,
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004160 AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar446cb832008-06-24 21:56:24 +00004161 [#include <sys/consio.h>
4162 #include <signal.h>
4163 #include <sys/fbio.h>],
4164 [struct mouse_info mouse;
4165 mouse.operation = MOUSE_MODE;
4166 mouse.operation = MOUSE_SHOW;
4167 mouse.u.mode.mode = 0;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004168 mouse.u.mode.signal = SIGUSR2;])],
Bram Moolenaar446cb832008-06-24 21:56:24 +00004169 [vi_cv_have_sysmouse=yes],
4170 [vi_cv_have_sysmouse=no])
4171 )
4172 if test $vi_cv_have_sysmouse = yes; then
4173 AC_DEFINE(HAVE_SYSMOUSE)
4174 fi
4175else
4176 AC_MSG_RESULT(yes)
4177fi
4178
Bram Moolenaarf05da212009-11-17 16:13:15 +00004179dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
4180AC_MSG_CHECKING(for FD_CLOEXEC)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004181AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaarf05da212009-11-17 16:13:15 +00004182[#if HAVE_FCNTL_H
4183# include <fcntl.h>
4184#endif],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004185[ int flag = FD_CLOEXEC;])],
Bram Moolenaarf05da212009-11-17 16:13:15 +00004186 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
4187 AC_MSG_RESULT(not usable))
4188
Bram Moolenaar071d4272004-06-13 20:20:40 +00004189dnl rename needs to be checked separately to work on Nextstep with cc
4190AC_MSG_CHECKING(for rename)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004191AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>], [rename("this", "that")])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004192 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
4193 AC_MSG_RESULT(no))
4194
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004195dnl check for dirfd()
4196AC_MSG_CHECKING(for dirfd)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004197AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004198[#include <sys/types.h>
4199#include <dirent.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004200[DIR * dir=opendir("dirname"); dirfd(dir);])],
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004201AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DIRFD), AC_MSG_RESULT(not usable))
4202
4203dnl check for flock()
4204AC_MSG_CHECKING(for flock)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004205AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004206[#include <sys/file.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004207[flock(10, LOCK_SH);])],
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004208AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOCK), AC_MSG_RESULT(not usable))
4209
Bram Moolenaar071d4272004-06-13 20:20:40 +00004210dnl sysctl() may exist but not the arguments we use
4211AC_MSG_CHECKING(for sysctl)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004212AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004213[#include <sys/types.h>
4214#include <sys/sysctl.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004215[[ int mib[2], r;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004216 size_t len;
4217
4218 mib[0] = CTL_HW;
4219 mib[1] = HW_USERMEM;
4220 len = sizeof(r);
4221 (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004222 ]])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004223 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL),
4224 AC_MSG_RESULT(not usable))
4225
Bram Moolenaare2982d62021-10-06 11:27:21 +01004226dnl sysinfo() may exist but not be Linux compatible.
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004227dnl On some FreeBSD systems it may depend on libsysinfo, try to link
Bram Moolenaar071d4272004-06-13 20:20:40 +00004228AC_MSG_CHECKING(for sysinfo)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004229AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004230[#include <sys/types.h>
4231#include <sys/sysinfo.h>],
4232[ struct sysinfo sinfo;
4233 int t;
4234
4235 (void)sysinfo(&sinfo);
4236 t = sinfo.totalram;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004237 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004238 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
4239 AC_MSG_RESULT(not usable))
4240
Bram Moolenaar914572a2007-05-01 11:37:47 +00004241dnl struct sysinfo may have the mem_unit field or not
4242AC_MSG_CHECKING(for sysinfo.mem_unit)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004243AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar914572a2007-05-01 11:37:47 +00004244[#include <sys/types.h>
4245#include <sys/sysinfo.h>],
4246[ struct sysinfo sinfo;
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02004247 sinfo.mem_unit = 1;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004248 ])],
Bram Moolenaar914572a2007-05-01 11:37:47 +00004249 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_MEM_UNIT),
4250 AC_MSG_RESULT(no))
4251
Bram Moolenaarf52f0602021-03-10 21:26:37 +01004252dnl struct sysinfo may have the uptime field or not
4253AC_MSG_CHECKING(for sysinfo.uptime)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004254AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaarf52f0602021-03-10 21:26:37 +01004255[#include <sys/types.h>
4256#include <sys/sysinfo.h>],
4257[ struct sysinfo sinfo;
4258 long ut;
4259
4260 (void)sysinfo(&sinfo);
4261 ut = sinfo.uptime;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004262 ])],
Bram Moolenaarf52f0602021-03-10 21:26:37 +01004263 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_UPTIME),
4264 AC_MSG_RESULT(no))
4265
Bram Moolenaar071d4272004-06-13 20:20:40 +00004266dnl sysconf() may exist but not support what we want to use
4267AC_MSG_CHECKING(for sysconf)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004268AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004269[#include <unistd.h>],
4270[ (void)sysconf(_SC_PAGESIZE);
4271 (void)sysconf(_SC_PHYS_PAGES);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004272 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004273 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
4274 AC_MSG_RESULT(not usable))
4275
Bram Moolenaar0e62a672021-02-25 17:17:56 +01004276dnl check if we have _SC_SIGSTKSZ via sysconf()
4277AC_MSG_CHECKING(for _SC_SIGSTKSZ via sysconf())
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004278AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar0e62a672021-02-25 17:17:56 +01004279[#include <unistd.h>],
4280[ (void)sysconf(_SC_SIGSTKSZ);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004281 ])],
Bram Moolenaar0e62a672021-02-25 17:17:56 +01004282 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF_SIGSTKSZ),
4283 AC_MSG_RESULT(not usable))
4284
Bram Moolenaar914703b2010-05-31 21:59:46 +02004285AC_CHECK_SIZEOF([int])
4286AC_CHECK_SIZEOF([long])
4287AC_CHECK_SIZEOF([time_t])
4288AC_CHECK_SIZEOF([off_t])
Bram Moolenaar644fdff2010-05-30 13:26:21 +02004289
Bram Moolenaara2aa31a2014-02-23 22:52:40 +01004290dnl Use different names to avoid clashing with other header files.
4291AC_DEFINE_UNQUOTED(VIM_SIZEOF_INT, [$ac_cv_sizeof_int])
4292AC_DEFINE_UNQUOTED(VIM_SIZEOF_LONG, [$ac_cv_sizeof_long])
4293
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004294dnl Make sure that uint32_t is really 32 bits unsigned.
4295AC_MSG_CHECKING([uint32_t is 32 bits])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004296AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004297#ifdef HAVE_STDINT_H
4298# include <stdint.h>
4299#endif
4300#ifdef HAVE_INTTYPES_H
4301# include <inttypes.h>
4302#endif
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01004303int main() {
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004304 uint32_t nr1 = (uint32_t)-1;
4305 uint32_t nr2 = (uint32_t)0xffffffffUL;
Bram Moolenaar52897832020-07-02 22:50:37 +02004306 if (sizeof(uint32_t) != 4 || nr1 != 0xffffffffUL || nr2 + 1 != 0) return 1;
4307 return 0;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004308}])],
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004309AC_MSG_RESULT(ok),
4310AC_MSG_ERROR([WRONG! uint32_t not defined correctly.]),
Jonas Sortie Termansen2cf145b2024-11-03 20:58:21 +01004311AC_MSG_WARN([assuming uint32_t is correct when cross-compiling]))
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004312
Bram Moolenaar446cb832008-06-24 21:56:24 +00004313dnl Check for memmove() before bcopy(), makes memmove() be used when both are
4314dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
4315
Bram Moolenaar071d4272004-06-13 20:20:40 +00004316[bcopy_test_prog='
Bram Moolenaar446cb832008-06-24 21:56:24 +00004317#include "confdefs.h"
4318#ifdef HAVE_STRING_H
4319# include <string.h>
4320#endif
4321#if STDC_HEADERS
4322# include <stdlib.h>
4323# include <stddef.h>
4324#endif
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01004325int main() {
Bram Moolenaar071d4272004-06-13 20:20:40 +00004326 char buf[10];
4327 strcpy(buf, "abcdefghi");
4328 mch_memmove(buf, buf + 2, 3);
4329 if (strncmp(buf, "ababcf", 6))
4330 exit(1);
4331 strcpy(buf, "abcdefghi");
4332 mch_memmove(buf + 2, buf, 3);
4333 if (strncmp(buf, "cdedef", 6))
4334 exit(1);
4335 exit(0); /* libc version works properly. */
4336}']
4337
Bram Moolenaar446cb832008-06-24 21:56:24 +00004338AC_CACHE_CHECK([whether memmove handles overlaps],[vim_cv_memmove_handles_overlap],
4339 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004340 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 +00004341 [
4342 vim_cv_memmove_handles_overlap=yes
4343 ],[
4344 vim_cv_memmove_handles_overlap=no
4345 ],[
Jonas Sortie Termansen2cf145b2024-11-03 20:58:21 +01004346 vim_cv_memmove_handles_overlap=yes
4347 AC_MSG_WARN(cross-compiling: consider setting 'vim_cv_memmove_handles_overlap')
Bram Moolenaar446cb832008-06-24 21:56:24 +00004348 ])
4349 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00004350
Bram Moolenaar446cb832008-06-24 21:56:24 +00004351if test "x$vim_cv_memmove_handles_overlap" = "xyes" ; then
4352 AC_DEFINE(USEMEMMOVE)
4353else
4354 AC_CACHE_CHECK([whether bcopy handles overlaps],[vim_cv_bcopy_handles_overlap],
4355 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004356 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 +00004357 [
4358 vim_cv_bcopy_handles_overlap=yes
4359 ],[
4360 vim_cv_bcopy_handles_overlap=no
4361 ],[
Jonas Sortie Termansen2cf145b2024-11-03 20:58:21 +01004362 vim_cv_bcopy_handles_overlap=yes
4363 AC_MSG_WARN(cross-compiling: consider setting 'vim_cv_bcopy_handles_overlap')
Bram Moolenaar446cb832008-06-24 21:56:24 +00004364 ])
4365 ])
4366
4367 if test "x$vim_cv_bcopy_handles_overlap" = "xyes" ; then
4368 AC_DEFINE(USEBCOPY)
4369 else
4370 AC_CACHE_CHECK([whether memcpy handles overlaps],[vim_cv_memcpy_handles_overlap],
4371 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004372 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 +00004373 [
4374 vim_cv_memcpy_handles_overlap=yes
4375 ],[
4376 vim_cv_memcpy_handles_overlap=no
4377 ],[
Jonas Sortie Termansen2cf145b2024-11-03 20:58:21 +01004378 vim_cv_memcpy_handles_overlap=yes
4379 AC_MSG_WARN(cross-compiling: consider setting 'vim_cv_memcpy_handles_overlap')
Bram Moolenaar446cb832008-06-24 21:56:24 +00004380 ])
4381 ])
4382
4383 if test "x$vim_cv_memcpy_handles_overlap" = "xyes" ; then
4384 AC_DEFINE(USEMEMCPY)
4385 fi
4386 fi
4387fi
4388
Bram Moolenaar071d4272004-06-13 20:20:40 +00004389
4390dnl Check for multibyte locale functions
4391dnl Find out if _Xsetlocale() is supported by libX11.
4392dnl Check if X_LOCALE should be defined.
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004393if test "x$with_x" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004394 cflags_save=$CFLAGS
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004395 libs_save=$LIBS
4396 LIBS="$LIBS $X_LIBS $GUI_LIB_LOC $GUI_X_LIBS $X_PRE_LIBS $X_LIB $X_EXTRA_LIBS"
4397 CFLAGS="$CFLAGS $X_CFLAGS"
4398
4399 AC_MSG_CHECKING(whether X_LOCALE needed)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004400 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <X11/Xlocale.h>],)],
4401 AC_LINK_IFELSE([AC_LANG_CALL([],[_Xsetlocale])], [AC_MSG_RESULT(yes)
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004402 AC_DEFINE(X_LOCALE)], AC_MSG_RESULT(no)),
4403 AC_MSG_RESULT(no))
4404
4405 AC_MSG_CHECKING(whether Xutf8SetWMProperties() can be used)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004406 AC_LINK_IFELSE([AC_LANG_CALL([],[Xutf8SetWMProperties])], [AC_MSG_RESULT(yes)
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004407 AC_DEFINE(HAVE_XUTF8SETWMPROPERTIES)], AC_MSG_RESULT(no))
4408
Bram Moolenaar071d4272004-06-13 20:20:40 +00004409 CFLAGS=$cflags_save
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004410 LIBS=$libs_save
Bram Moolenaar071d4272004-06-13 20:20:40 +00004411fi
4412
4413dnl Link with xpg4, it is said to make Korean locale working
4414AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,)
4415
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004416dnl Check how we can run ctags. Default to "ctags" when nothing works.
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02004417dnl Use --version to detect Exuberant ctags (preferred)
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004418dnl Add --fields=+S to get function signatures for omni completion.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004419dnl -t for typedefs (many ctags have this)
4420dnl -s for static functions (Elvis ctags only?)
4421dnl -v for variables. Dangerous, most ctags take this for 'vgrind style'.
4422dnl -i+m to test for older Exuberant ctags
4423AC_MSG_CHECKING(how to create tags)
4424test -f tags && mv tags tags.save
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004425if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004426 TAGPRG="ctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004427elif (eval exctags --version /dev/null | grep Exuberant) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004428 TAGPRG="exctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004429elif (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 +01004430 TAGPRG="exuberant-ctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004431else
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004432 TAGPRG="ctags"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004433 (eval etags /dev/null) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1 && TAGPRG="etags"
4434 (eval etags -c /dev/null) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1 && TAGPRG="etags -c"
4435 (eval ctags /dev/null) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1 && TAGPRG="ctags"
4436 (eval ctags -t /dev/null) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1 && TAGPRG="ctags -t"
4437 (eval ctags -ts /dev/null) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1 && TAGPRG="ctags -ts"
4438 (eval ctags -tvs /dev/null) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1 && TAGPRG="ctags -tvs"
4439 (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 +00004440fi
4441test -f tags.save && mv tags.save tags
4442AC_MSG_RESULT($TAGPRG) AC_SUBST(TAGPRG)
4443
4444dnl Check how we can run man with a section number
4445AC_MSG_CHECKING(how to run man with a section nr)
4446MANDEF="man"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004447(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 +00004448AC_MSG_RESULT($MANDEF)
4449if test "$MANDEF" = "man -s"; then
4450 AC_DEFINE(USEMAN_S)
4451fi
4452
4453dnl Check if gettext() is working and if it needs -lintl
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004454dnl We take care to base this on an empty LIBS: on some systems libelf would be
4455dnl in LIBS and implicitly take along libintl. The final LIBS would then not
4456dnl contain libintl, and the link step would fail due to -Wl,--as-needed.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004457AC_MSG_CHECKING(--disable-nls argument)
4458AC_ARG_ENABLE(nls,
4459 [ --disable-nls Don't support NLS (gettext()).], ,
4460 [enable_nls="yes"])
4461
4462if test "$enable_nls" = "yes"; then
4463 AC_MSG_RESULT(no)
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00004464
4465 INSTALL_LANGS=install-languages
4466 AC_SUBST(INSTALL_LANGS)
4467 INSTALL_TOOL_LANGS=install-tool-languages
4468 AC_SUBST(INSTALL_TOOL_LANGS)
4469
Bram Moolenaar071d4272004-06-13 20:20:40 +00004470 AC_CHECK_PROG(MSGFMT, msgfmt, msgfmt, )
4471 AC_MSG_CHECKING([for NLS])
4472 if test -f po/Makefile; then
4473 have_gettext="no"
4474 if test -n "$MSGFMT"; then
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004475 olibs=$LIBS
4476 LIBS=""
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004477 AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004478 [#include <libintl.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004479 [gettext("Test");])],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004480 AC_MSG_RESULT([gettext() works]); have_gettext="yes"; LIBS=$olibs,
4481 LIBS="-lintl"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004482 AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004483 [#include <libintl.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004484 [gettext("Test");])],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004485 AC_MSG_RESULT([gettext() works with -lintl]); have_gettext="yes";
4486 LIBS="$olibs -lintl",
Bram Moolenaar071d4272004-06-13 20:20:40 +00004487 AC_MSG_RESULT([gettext() doesn't work]);
4488 LIBS=$olibs))
4489 else
4490 AC_MSG_RESULT([msgfmt not found - disabled]);
4491 fi
Martin Tournoij7904fa42022-10-04 16:28:45 +01004492 if test $have_gettext = "yes" -a "x$features" != "xtiny"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004493 AC_DEFINE(HAVE_GETTEXT)
4494 MAKEMO=yes
4495 AC_SUBST(MAKEMO)
4496 dnl this was added in GNU gettext 0.10.36
4497 AC_CHECK_FUNCS(bind_textdomain_codeset)
Christ van Willegence0ef912024-06-20 23:41:59 +02004498 AC_MSG_CHECKING([for dgettext])
4499 AC_LINK_IFELSE([AC_LANG_PROGRAM(
4500 [#include <libintl.h>],
4501 [dgettext("Test", "Test");])],
4502 AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_DGETTEXT),
Christ van Willegenc0786752025-02-01 15:42:16 +01004503 AC_MSG_CHECKING([for dngettext])
4504 AC_MSG_RESULT([no]))
4505 AC_LINK_IFELSE([AC_LANG_PROGRAM(
4506 [#include <libintl.h>],
4507 [dngettext("DOMAIN", "Test single", "Test plural", 1);])],
4508 AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_DNGETTEXT),
Christ van Willegence0ef912024-06-20 23:41:59 +02004509 AC_MSG_RESULT([no]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004510 dnl _nl_msg_cat_cntr is required for GNU gettext
4511 AC_MSG_CHECKING([for _nl_msg_cat_cntr])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004512 AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004513 [#include <libintl.h>
4514 extern int _nl_msg_cat_cntr;],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004515 [++_nl_msg_cat_cntr;])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004516 AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_NL_MSG_CAT_CNTR),
4517 AC_MSG_RESULT([no]))
Bram Moolenaar26096cc2019-04-11 15:25:40 +02004518 AC_MSG_CHECKING([if msgfmt supports --desktop])
4519 MSGFMT_DESKTOP=
4520 if "$MSGFMT" --help | grep -e '--desktop' >/dev/null; then
Bram Moolenaar62a88f42019-06-07 20:44:40 +02004521 if "$MSGFMT" --version | grep '0.19.[[3-7]]$' >/dev/null; then
4522 dnl GNU gettext 0.19.7's --desktop is broken. We assume back to
4523 dnl 0.19.3 is also broken.
4524 AC_MSG_RESULT([broken])
4525 else
4526 AC_MSG_RESULT([yes])
4527 MSGFMT_DESKTOP="gvim.desktop vim.desktop"
4528 fi
Bram Moolenaar26096cc2019-04-11 15:25:40 +02004529 else
4530 AC_MSG_RESULT([no])
4531 fi
4532 AC_SUBST(MSGFMT_DESKTOP)
Vladimír Marek87319172024-04-11 21:54:34 +02004533 AC_MSG_CHECKING([if $MSGFMT supports --no-convert])
RestorerZe498caf2024-03-12 22:11:36 +01004534 if "$MSGFMT" --help | grep -q -- '--no-convert' >/dev/null; then
4535 AC_MSG_RESULT([yes])
Vladimír Marek87319172024-04-11 21:54:34 +02004536 MSGFMTCMD="OLD_PO_FILE_INPUT=yes $MSGFMT --no-convert -v"
RestorerZe498caf2024-03-12 22:11:36 +01004537 else
4538 AC_MSG_RESULT([no])
Vladimír Marek87319172024-04-11 21:54:34 +02004539 MSGFMTCMD="OLD_PO_FILE_INPUT=yes $MSGFMT -v"
RestorerZe498caf2024-03-12 22:11:36 +01004540 fi
4541 AC_SUBST(MSGFMTCMD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004542 fi
4543 else
4544 AC_MSG_RESULT([no "po/Makefile" - disabled]);
4545 fi
4546else
4547 AC_MSG_RESULT(yes)
4548fi
4549
4550dnl Check for dynamic linking loader
4551AC_CHECK_HEADER(dlfcn.h, DLL=dlfcn.h, [AC_CHECK_HEADER(dl.h, DLL=dl.h)])
4552if test x${DLL} = xdlfcn.h; then
4553 AC_DEFINE(HAVE_DLFCN_H, 1, [ Define if we have dlfcn.h. ])
4554 AC_MSG_CHECKING([for dlopen()])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004555 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004556 extern void* dlopen();
4557 dlopen();
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004558 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004559 AC_MSG_RESULT(yes);
4560 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4561 AC_MSG_RESULT(no);
4562 AC_MSG_CHECKING([for dlopen() in -ldl])
4563 olibs=$LIBS
4564 LIBS="$LIBS -ldl"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004565 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004566 extern void* dlopen();
4567 dlopen();
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004568 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004569 AC_MSG_RESULT(yes);
4570 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4571 AC_MSG_RESULT(no);
4572 LIBS=$olibs))
4573 dnl ReliantUNIX has dlopen() in libc but everything else in libdl
4574 dnl ick :-)
4575 AC_MSG_CHECKING([for dlsym()])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004576 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004577 extern void* dlsym();
4578 dlsym();
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004579 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004580 AC_MSG_RESULT(yes);
4581 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4582 AC_MSG_RESULT(no);
4583 AC_MSG_CHECKING([for dlsym() in -ldl])
4584 olibs=$LIBS
4585 LIBS="$LIBS -ldl"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004586 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004587 extern void* dlsym();
4588 dlsym();
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004589 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004590 AC_MSG_RESULT(yes);
4591 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4592 AC_MSG_RESULT(no);
4593 LIBS=$olibs))
4594elif test x${DLL} = xdl.h; then
4595 AC_DEFINE(HAVE_DL_H, 1, [ Define if we have dl.h. ])
4596 AC_MSG_CHECKING([for shl_load()])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004597 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004598 extern void* shl_load();
4599 shl_load();
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004600 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004601 AC_MSG_RESULT(yes);
4602 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4603 AC_MSG_RESULT(no);
4604 AC_MSG_CHECKING([for shl_load() in -ldld])
4605 olibs=$LIBS
4606 LIBS="$LIBS -ldld"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004607 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004608 extern void* shl_load();
4609 shl_load();
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004610 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004611 AC_MSG_RESULT(yes);
4612 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4613 AC_MSG_RESULT(no);
4614 LIBS=$olibs))
4615fi
4616AC_CHECK_HEADERS(setjmp.h)
4617
Bram Moolenaard0573012017-10-28 21:11:06 +02004618if test "x$MACOS_X" = "xyes" -a -n "$PERL"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004619 dnl -ldl must come after DynaLoader.a
4620 if echo $LIBS | grep -e '-ldl' >/dev/null; then
4621 LIBS=`echo $LIBS | sed s/-ldl//`
4622 PERL_LIBS="$PERL_LIBS -ldl"
4623 fi
4624fi
4625
Bram Moolenaard0573012017-10-28 21:11:06 +02004626if test "$MACOS_X" = "yes"; then
4627 AC_MSG_CHECKING([whether we need macOS frameworks])
Bram Moolenaar097148e2020-08-11 21:58:20 +02004628 if test "$MACOS_X_DARWIN" = "yes"; then
Bram Moolenaard0573012017-10-28 21:11:06 +02004629 if test "$features" = "tiny"; then
Yee Cheng Chin4314e4f2022-10-08 13:50:05 +01004630 dnl Since no FEAT_CLIPBOARD or FEAT_SOUND, no need for os_macosx.m.
Bram Moolenaard0573012017-10-28 21:11:06 +02004631 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_macosx.m++'`
4632 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_macosx.o++'`
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01004633 AC_MSG_RESULT([yes, we need CoreServices])
4634 LIBS="$LIBS -framework CoreServices"
Bram Moolenaard0573012017-10-28 21:11:06 +02004635 else
4636 AC_MSG_RESULT([yes, we need AppKit])
4637 LIBS="$LIBS -framework AppKit"
Bram Moolenaard0573012017-10-28 21:11:06 +02004638 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004639 else
Bram Moolenaard0573012017-10-28 21:11:06 +02004640 AC_MSG_RESULT([no])
Bram Moolenaar3437b912013-07-03 19:52:53 +02004641 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004642fi
4643
Bram Moolenaar3ae5fc92021-09-06 18:57:30 +02004644dnl On some systems REENTRANT needs to be defined. It should not hurt to use
4645dnl it everywhere.
4646if `echo "$CFLAGS" | grep -v D_REENTRANT >/dev/null`; then
4647 CFLAGS="$CFLAGS -D_REENTRANT"
4648fi
4649
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004650dnl gcc 3.1 changed the meaning of -MM. The only solution appears to be to
4651dnl use "-isystem" instead of "-I" for all non-Vim include dirs.
4652dnl But only when making dependencies, cproto and lint don't take "-isystem".
Bram Moolenaar32466aa2006-02-24 23:53:04 +00004653dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
4654dnl the number before the version number.
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004655DEPEND_CFLAGS_FILTER=
4656if test "$GCC" = yes; then
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004657 AC_MSG_CHECKING(for GCC 3 or later)
Bram Moolenaar348808f2020-02-07 20:50:07 +01004658 gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]][[0-9]]*\)\..*$/\1/g'`
Bram Moolenaarf740b292006-02-16 22:11:02 +00004659 if test "$gccmajor" -gt "2"; then
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004660 DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004661 AC_MSG_RESULT(yes)
4662 else
4663 AC_MSG_RESULT(no)
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004664 fi
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004665 dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
4666 dnl declared as char x[1] but actually longer. Introduced in gcc 4.0.
Bram Moolenaar56d1db32009-12-16 16:14:51 +00004667 dnl Also remove duplicate _FORTIFY_SOURCE arguments.
Bram Moolenaaraeabe052011-12-08 15:17:34 +01004668 dnl And undefine it first to avoid a warning.
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004669 AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
4670 if test "$gccmajor" -gt "3"; then
Zdenek Dohnal42196982023-01-18 16:09:51 +00004671 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/'`
4672 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 +00004673 AC_MSG_RESULT(yes)
4674 else
4675 AC_MSG_RESULT(no)
4676 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +00004677fi
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004678AC_SUBST(DEPEND_CFLAGS_FILTER)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004679
Bram Moolenaarec0557f2018-01-31 14:41:37 +01004680dnl On some systems AC_SYS_LARGEFILE determines that -D_FILE_OFFSET_BITS=64
4681dnl isn't required, but the CFLAGS for some of the libraries we're using
4682dnl include the define. Since the define changes the size of some datatypes
4683dnl (e.g. ino_t and off_t), all of Vim's modules must be compiled with a
4684dnl consistent value. It's therefore safest to force the use of the define
4685dnl if it's present in any of the *_CFLAGS variables.
4686AC_MSG_CHECKING(whether we need to force -D_FILE_OFFSET_BITS=64)
Bram Moolenaar9ce42132018-04-11 22:19:36 +02004687if 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 +01004688 AC_MSG_RESULT(yes)
4689 AC_DEFINE(_FILE_OFFSET_BITS, 64)
4690else
4691 AC_MSG_RESULT(no)
4692fi
4693
Bram Moolenaar6cd42db2020-12-04 18:09:54 +01004694dnl $LDFLAGS is passed to glibtool in libvterm, it doesn't like a space
4695dnl between "-L" and the path that follows.
4696LDFLAGS=`echo "$LDFLAGS" | sed -e 's/-L /-L/g'`
4697
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004698dnl link.sh tries to avoid overlinking in a hackish way.
4699dnl At least GNU ld supports --as-needed which provides the same functionality
4700dnl at linker level. Let's use it.
4701AC_MSG_CHECKING(linker --as-needed support)
4702LINK_AS_NEEDED=
4703# Check if linker supports --as-needed and --no-as-needed options
4704if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
Natanael Copa761ead42021-05-15 14:25:37 +02004705 if ! echo "$LDFLAGS" | grep -q -- '-Wl,[[^[:space:]]]*--as-needed'; then
4706 LDFLAGS="$LDFLAGS -Wl,--as-needed"
4707 fi
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004708 LINK_AS_NEEDED=yes
4709fi
4710if test "$LINK_AS_NEEDED" = yes; then
4711 AC_MSG_RESULT(yes)
4712else
4713 AC_MSG_RESULT(no)
4714fi
4715AC_SUBST(LINK_AS_NEEDED)
4716
Bram Moolenaar77c19352012-06-13 19:19:41 +02004717# IBM z/OS reset CFLAGS for config.mk
4718if test "$zOSUnix" = "yes"; then
4719 CFLAGS="-D_ALL_SOURCE -Wc,float\(ieee\),dll"
4720fi
4721
Bram Moolenaar071d4272004-06-13 20:20:40 +00004722dnl write output files
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004723AC_CONFIG_FILES(auto/config.mk:config.mk.in)
4724AC_OUTPUT
Bram Moolenaar071d4272004-06-13 20:20:40 +00004725
Drew Vogel51995672025-05-28 21:13:52 +02004726dnl vim: set sw=2 sts=2 tw=78 fo+=l: