blob: fc346dc8112b73a832cc9e8073246e6a68e6ebc6 [file] [log] [blame]
Bram Moolenaar3f7d0902016-11-12 21:13:42 +01001dnl configure.ac: autoconf script for Vim
Bram Moolenaar071d4272004-06-13 20:20:40 +00002
Paul Ollis65745772022-06-05 16:55:54 +01003dnl Process this file with autoconf 2.69 to produce "configure".
4dnl This should also work with other versions of autoconf, but 2.70 and later
5dnl generate lots of hard to fix "obsolete" warnings.
Bram Moolenaar071d4272004-06-13 20:20:40 +00006
7AC_INIT(vim.h)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01008AC_CONFIG_HEADERS(auto/config.h:config.h.in)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009
10dnl Being able to run configure means the system is Unix (compatible).
11AC_DEFINE(UNIX)
12AC_PROG_MAKE_SET
13
14dnl Checks for programs.
Bram Moolenaar22640082018-04-19 20:39:41 +020015AC_PROG_CC_C99 dnl required by almost everything
Bram Moolenaarc0394412017-04-20 20:20:23 +020016AC_PROG_CPP dnl required by header file checks
17AC_PROGRAM_EGREP dnl required by AC_EGREP_CPP
18AC_PROG_FGREP dnl finds working grep -F
19AC_ISC_POSIX dnl required by AC_C_CROSS
20AC_PROG_AWK dnl required for "make html" in ../doc
Bram Moolenaar071d4272004-06-13 20:20:40 +000021
22dnl Don't strip if we don't have it
23AC_CHECK_PROG(STRIP, strip, strip, :)
24
Bram Moolenaar325b7a22004-07-05 15:58:32 +000025dnl Check for extension of executables
Bram Moolenaar071d4272004-06-13 20:20:40 +000026AC_EXEEXT
27
Bram Moolenaar446cb832008-06-24 21:56:24 +000028dnl Check for standard headers. We don't use this in Vim but other stuff
29dnl in autoconf needs it, where it uses STDC_HEADERS.
30AC_HEADER_STDC
31AC_HEADER_SYS_WAIT
32
Bram Moolenaar561f8a52018-04-17 22:02:45 +020033dnl Check that the C99 features that Vim uses are supported:
Bram Moolenaar22640082018-04-19 20:39:41 +020034if test x"$ac_cv_prog_cc_c99" != xno; then
35 dnl If the compiler doesn't explicitly support C99, then check
36 dnl for the specific features Vim uses
37
38 AC_TYPE_LONG_LONG_INT
39 if test "$ac_cv_type_long_long_int" = no; then
40 AC_MSG_FAILURE([Compiler does not support long long int])
41 fi
42
43 AC_MSG_CHECKING([if the compiler supports trailing commas])
44 trailing_commas=no
Bram Moolenaar1004b3d2022-06-05 19:51:55 +010045 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
Bram Moolenaar22640082018-04-19 20:39:41 +020046 enum {
47 one,
Bram Moolenaar1004b3d2022-06-05 19:51:55 +010048 };])],
Bram Moolenaar22640082018-04-19 20:39:41 +020049 [AC_MSG_RESULT(yes); trailing_commas=yes],
50 [AC_MSG_RESULT(no)])
51 if test "$trailing_commas" = no; then
52 AC_MSG_FAILURE([Compiler does not support trailing comma in enum])
53 fi
54
55 AC_MSG_CHECKING([if the compiler supports C++ comments])
56 slash_comments=no
Bram Moolenaar1004b3d2022-06-05 19:51:55 +010057 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
58 [// C++ comments?])],
Bram Moolenaar22640082018-04-19 20:39:41 +020059 [AC_MSG_RESULT(yes); slash_comments=yes],
60 [AC_MSG_RESULT(no)])
61 if test "$slash_comments" = no; then
62 AC_MSG_FAILURE([Compiler does not support C++ comments])
63 fi
64fi
Bram Moolenaar561f8a52018-04-17 22:02:45 +020065
Bram Moolenaar8f1dde52020-06-05 23:16:29 +020066dnl If $SOURCE_DATE_EPOCH is present in the environment, use that as the
67dnl "compiled" timestamp in :version's output. Attempt to get the formatted
68dnl date using GNU date syntax, BSD date syntax, and finally falling back to
69dnl just using the current time.
70if test -n "$SOURCE_DATE_EPOCH"; then
71 DATE_FMT="%b %d %Y %H:%M:%S"
72 BUILD_DATE=$(LC_ALL=C date -u -d "@$SOURCE_DATE_EPOCH" "+$DATE_FMT" 2>/dev/null || LC_ALL=C date -u -r "$SOURCE_DATE_EPOCH" "+$DATE_FMT" 2>/dev/null || LC_ALL=C date -u "+$DATE_FMT")
73 AC_DEFINE_UNQUOTED(BUILD_DATE, ["$BUILD_DATE"])
74 BUILD_DATE_MSG=-"echo -e '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\nNOTE: build date/time is fixed: $BUILD_DATE\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='"
75 AC_SUBST(BUILD_DATE_MSG)
76fi
77
Bram Moolenaarf788a062011-12-14 20:51:25 +010078dnl Check for the flag that fails if stuff are missing.
79
80AC_MSG_CHECKING(--enable-fail-if-missing argument)
81AC_ARG_ENABLE(fail_if_missing,
82 [ --enable-fail-if-missing Fail if dependencies on additional features
Bram Moolenaare5303952022-06-19 17:05:47 +010083 specified on the command line are missing.],
Bram Moolenaarf788a062011-12-14 20:51:25 +010084 [fail_if_missing="yes"],
85 [fail_if_missing="no"])
86AC_MSG_RESULT($fail_if_missing)
87
Bram Moolenaard2a05492018-07-27 22:35:15 +020088dnl Keep original value to check later.
89with_x_arg="$with_x"
90
Bram Moolenaar071d4272004-06-13 20:20:40 +000091dnl Set default value for CFLAGS if none is defined or it's empty
92if test -z "$CFLAGS"; then
93 CFLAGS="-O"
Bram Moolenaar4d8479b2021-01-31 14:36:06 +010094 test "$GCC" = yes && CFLAGS="-O2 -fno-strength-reduce -Wall -Wno-deprecated-declarations"
Bram Moolenaar071d4272004-06-13 20:20:40 +000095fi
96if test "$GCC" = yes; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +000097 dnl method that should work for nearly all versions
Bram Moolenaarc8836f72014-04-12 13:12:24 +020098 gccversion=`$CC -dumpversion`
Bram Moolenaar910f66f2006-04-05 20:41:53 +000099 if test "x$gccversion" = "x"; then
100 dnl old method; fall-back for when -dumpversion doesn't work
Bram Moolenaarc8836f72014-04-12 13:12:24 +0200101 gccversion=`$CC --version | sed -e '2,$d' -e 's/darwin.//' -e 's/^[[^0-9]]*\([[0-9]]\.[[0-9.]]*\).*$/\1/g'`
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000102 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +0000103 dnl version 4.0.1 was reported to cause trouble on Macintosh by Marcin Dalecki
104 if test "$gccversion" = "3.0.1" -o "$gccversion" = "3.0.2" -o "$gccversion" = "4.0.1"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000105 echo 'GCC [[34]].0.[[12]] has a bug in the optimizer, disabling "-O#"'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000106 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-O/'`
107 else
108 if test "$gccversion" = "3.1" -o "$gccversion" = "3.2" -o "$gccversion" = "3.2.1" && `echo "$CFLAGS" | grep -v fno-strength-reduce >/dev/null`; then
109 echo 'GCC 3.1 and 3.2 have a bug in the optimizer, adding "-fno-strength-reduce"'
110 CFLAGS="$CFLAGS -fno-strength-reduce"
111 fi
112 fi
113fi
114
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200115dnl clang-500.2.75 or around has abandoned -f[no-]strength-reduce and issues a
116dnl warning when that flag is passed to. Accordingly, adjust CFLAGS based on
117dnl the version number of the clang in use.
118dnl Note that this does not work to get the version of clang 3.1 or 3.2.
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100119AC_MSG_CHECKING(for clang version)
120CLANG_VERSION_STRING=`$CC --version 2>/dev/null | sed -n -e 's/^.*clang[[^0-9]]*\([[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\).*$/\1/p'`
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200121if test x"$CLANG_VERSION_STRING" != x"" ; then
122 CLANG_MAJOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*/\1/p'`
123 CLANG_MINOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/p'`
124 CLANG_REVISION=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)/\1/p'`
125 CLANG_VERSION=`expr $CLANG_MAJOR '*' 1000000 '+' $CLANG_MINOR '*' 1000 '+' $CLANG_REVISION`
126 AC_MSG_RESULT($CLANG_VERSION)
127 dnl If you find the same issue with versions earlier than 500.2.75,
128 dnl change the constant 500002075 below appropriately. To get the
129 dnl integer corresponding to a version number, refer to the
130 dnl definition of CLANG_VERSION above.
Bram Moolenaarebd211c2021-01-30 19:33:36 +0100131 dnl Clang 11 reports "11", assume Clang 10 and later work like this.
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100132 AC_MSG_CHECKING(if clang supports -fno-strength-reduce)
Bram Moolenaarebd211c2021-01-30 19:33:36 +0100133 if test "$CLANG_MAJOR" -ge 10 -o "$CLANG_VERSION" -ge 500002075 ; then
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100134 AC_MSG_RESULT(no)
135 CFLAGS=`echo "$CFLAGS" | sed -e 's/-fno-strength-reduce/ /'`
136 else
137 AC_MSG_RESULT(yes)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200138 fi
139else
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100140 AC_MSG_RESULT(N/A)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200141fi
142
Bram Moolenaar446cb832008-06-24 21:56:24 +0000143dnl If configure thinks we are cross compiling, there might be something
144dnl wrong with the CC or CFLAGS settings, give a useful warning message
Bram Moolenaar839e9542016-04-14 16:46:02 +0200145CROSS_COMPILING=
Bram Moolenaar071d4272004-06-13 20:20:40 +0000146if test "$cross_compiling" = yes; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000147 AC_MSG_RESULT([cannot compile a simple program; if not cross compiling check CC and CFLAGS])
Bram Moolenaar839e9542016-04-14 16:46:02 +0200148 CROSS_COMPILING=1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000149fi
Bram Moolenaar839e9542016-04-14 16:46:02 +0200150AC_SUBST(CROSS_COMPILING)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000151
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +0000152dnl gcc-cpp has the wonderful -MM option to produce nicer dependencies.
153dnl But gcc 3.1 changed the meaning! See near the end.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000154test "$GCC" = yes && CPP_MM=M; AC_SUBST(CPP_MM)
155
156if test -f ./toolcheck; then
Bram Moolenaar1004b3d2022-06-05 19:51:55 +0100157 AC_MSG_CHECKING(for buggy tools)
158 sh ./toolcheck 1>&AS_MESSAGE_FD
Bram Moolenaar071d4272004-06-13 20:20:40 +0000159fi
160
161OS_EXTRA_SRC=""; OS_EXTRA_OBJ=""
162
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000163dnl When cross-compiling set $vim_cv_uname_output, $vim_cv_uname_r_output and
164dnl $vim_cv_uname_m_output to the desired value for the target system
165AC_MSG_CHECKING(uname)
166if test "x$vim_cv_uname_output" = "x" ; then
167 vim_cv_uname_output=`(uname) 2>/dev/null`
168 AC_MSG_RESULT($vim_cv_uname_output)
169else
170 AC_MSG_RESULT([$vim_cv_uname_output (cached)])
171fi
172
173AC_MSG_CHECKING(uname -r)
174if test "x$vim_cv_uname_r_output" = "x" ; then
175 vim_cv_uname_r_output=`(uname -r) 2>/dev/null`
176 AC_MSG_RESULT($vim_cv_uname_r_output)
177else
178 AC_MSG_RESULT([$vim_cv_uname_r_output (cached)])
179fi
180
181AC_MSG_CHECKING(uname -m)
182if test "x$vim_cv_uname_m_output" = "x" ; then
183 vim_cv_uname_m_output=`(uname -m) 2>/dev/null`
184 AC_MSG_RESULT($vim_cv_uname_m_output)
185else
186 AC_MSG_RESULT([$vim_cv_uname_m_output (cached)])
187fi
188
Bram Moolenaarb3f74062020-02-26 16:16:53 +0100189AC_MSG_CHECKING(for Haiku)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000190case $vim_cv_uname_output in
Bram Moolenaarb3f74062020-02-26 16:16:53 +0100191 Haiku) HAIKU=yes; AC_MSG_RESULT(yes);;
192 *) HAIKU=no; AC_MSG_RESULT(no);;
193esac
194
Bram Moolenaar071d4272004-06-13 20:20:40 +0000195dnl If QNX is found, assume we don't want to use Xphoton
196dnl unless it was specifically asked for (--with-x)
197AC_MSG_CHECKING(for QNX)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000198case $vim_cv_uname_output in
Bram Moolenaar071d4272004-06-13 20:20:40 +0000199 QNX) OS_EXTRA_SRC=os_qnx.c; OS_EXTRA_OBJ=objects/os_qnx.o
200 test -z "$with_x" && with_x=no
201 QNX=yes; AC_MSG_RESULT(yes);;
202 *) QNX=no; AC_MSG_RESULT(no);;
203esac
204
205dnl Check for Darwin and MacOS X
206dnl We do a check for MacOS X in the very beginning because there
207dnl are a lot of other things we need to change besides GUI stuff
Bram Moolenaar071d4272004-06-13 20:20:40 +0000208AC_MSG_CHECKING([for Darwin (Mac OS X)])
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000209if test "$vim_cv_uname_output" = Darwin; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000210 AC_MSG_RESULT(yes)
Bram Moolenaard0573012017-10-28 21:11:06 +0200211 MACOS_X=yes
Bram Moolenaar52ecaaa2018-05-12 21:38:13 +0200212 CPPFLAGS="$CPPFLAGS -DMACOS_X"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000213
214 AC_MSG_CHECKING(--disable-darwin argument)
215 AC_ARG_ENABLE(darwin,
216 [ --disable-darwin Disable Darwin (Mac OS X) support.],
217 , [enable_darwin="yes"])
218 if test "$enable_darwin" = "yes"; then
219 AC_MSG_RESULT(no)
220 AC_MSG_CHECKING(if Darwin files are there)
Bram Moolenaar164fca32010-07-14 13:58:07 +0200221 if test -f os_macosx.m; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000222 AC_MSG_RESULT(yes)
223 else
224 AC_MSG_RESULT([no, Darwin support disabled])
225 enable_darwin=no
226 fi
227 else
228 AC_MSG_RESULT([yes, Darwin support excluded])
229 fi
230
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000231 AC_MSG_CHECKING(--with-mac-arch argument)
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000232 AC_ARG_WITH(mac-arch, [ --with-mac-arch=ARCH current, intel, ppc or both],
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000233 MACARCH="$withval"; AC_MSG_RESULT($MACARCH),
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000234 MACARCH="current"; AC_MSG_RESULT(defaulting to $MACARCH))
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000235
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100236 AC_MSG_CHECKING(--with-developer-dir argument)
237 AC_ARG_WITH(developer-dir, [ --with-developer-dir=PATH use PATH as location for Xcode developer tools],
238 DEVELOPER_DIR="$withval"; AC_MSG_RESULT($DEVELOPER_DIR),
Bram Moolenaar32d03b32015-11-19 13:46:48 +0100239 AC_MSG_RESULT(not present))
Bram Moolenaare5303952022-06-19 17:05:47 +0100240
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100241 if test "x$DEVELOPER_DIR" = "x"; then
242 AC_PATH_PROG(XCODE_SELECT, xcode-select)
243 if test "x$XCODE_SELECT" != "x"; then
244 AC_MSG_CHECKING(for developer dir using xcode-select)
245 DEVELOPER_DIR=`$XCODE_SELECT -print-path`
246 AC_MSG_RESULT([$DEVELOPER_DIR])
247 else
248 DEVELOPER_DIR=/Developer
249 fi
250 fi
251
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000252 if test "x$MACARCH" = "xboth"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000253 AC_MSG_CHECKING(for 10.4 universal SDK)
254 dnl There is a terrible inconsistency (but we appear to get away with it):
255 dnl $CFLAGS uses the 10.4u SDK library for the headers, while $CPPFLAGS
256 dnl doesn't, because "gcc -E" doesn't grok it. That means the configure
257 dnl tests using the preprocessor are actually done with the wrong header
258 dnl files. $LDFLAGS is set at the end, because configure uses it together
259 dnl with $CFLAGS and we can only have one -sysroot argument.
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000260 save_cppflags="$CPPFLAGS"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000261 save_cflags="$CFLAGS"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000262 save_ldflags="$LDFLAGS"
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100263 CFLAGS="$CFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +0100264 AC_LINK_IFELSE([AC_LANG_PROGRAM([ ], [ ])],
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000265 AC_MSG_RESULT(found, will make universal binary),
266
267 AC_MSG_RESULT(not found)
Bram Moolenaar1f35bf92006-03-07 22:38:47 +0000268 CFLAGS="$save_cflags"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000269 AC_MSG_CHECKING(if Intel architecture is supported)
270 CPPFLAGS="$CPPFLAGS -arch i386"
271 LDFLAGS="$save_ldflags -arch i386"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +0100272 AC_LINK_IFELSE([AC_LANG_PROGRAM([ ], [ ])],
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000273 AC_MSG_RESULT(yes); MACARCH="intel",
274 AC_MSG_RESULT(no, using PowerPC)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000275 MACARCH="ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000276 CPPFLAGS="$save_cppflags -arch ppc"
277 LDFLAGS="$save_ldflags -arch ppc"))
278 elif test "x$MACARCH" = "xintel"; then
279 CPPFLAGS="$CPPFLAGS -arch intel"
280 LDFLAGS="$LDFLAGS -arch intel"
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000281 elif test "x$MACARCH" = "xppc"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000282 CPPFLAGS="$CPPFLAGS -arch ppc"
283 LDFLAGS="$LDFLAGS -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000284 fi
285
Bram Moolenaar071d4272004-06-13 20:20:40 +0000286 if test "$enable_darwin" = "yes"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200287 MACOS_X_DARWIN=yes
Bram Moolenaar164fca32010-07-14 13:58:07 +0200288 OS_EXTRA_SRC="os_macosx.m os_mac_conv.c";
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000289 OS_EXTRA_OBJ="objects/os_macosx.o objects/os_mac_conv.o"
Bram Moolenaare5303952022-06-19 17:05:47 +0100290 dnl os_macosx.m implements timer_create() and friends
291 AC_DEFINE(HAVE_TIMER_CREATE)
Bram Moolenaar32466aa2006-02-24 23:53:04 +0000292 dnl TODO: use -arch i386 on Intel machines
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100293 dnl Removed -no-cpp-precomp, only for very old compilers.
Bram Moolenaard0573012017-10-28 21:11:06 +0200294 CPPFLAGS="$CPPFLAGS -DMACOS_X_DARWIN"
Bram Moolenaar040f9752020-08-11 23:08:48 +0200295
296 dnl Assume we don't want X11 unless it was specifically asked for
Bram Moolenaar0b40d082022-03-08 13:32:37 +0000297 dnl (--with-x) or Motif or GTK GUI is used.
298 if test -z "$with_x" -a "X$enable_gui" != Xmotif -a "X$enable_gui" != Xgtk2 -a "X$enable_gui" != Xgtk3; then
Bram Moolenaar040f9752020-08-11 23:08:48 +0200299 with_x=no
300 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000301 fi
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000302
Bram Moolenaardb552d602006-03-23 22:59:57 +0000303 dnl Avoid a bug with -O2 with gcc 4.0.1. Symptom: malloc() reports double
Bram Moolenaarfd2ac762006-03-01 22:09:21 +0000304 dnl free. This happens in expand_filename(), because the optimizer swaps
Bram Moolenaardb552d602006-03-23 22:59:57 +0000305 dnl two blocks of code, both using "repl", that can't be swapped.
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000306 if test "$MACARCH" = "intel" -o "$MACARCH" = "both"; then
307 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-Oz/'`
308 fi
309
Bram Moolenaar071d4272004-06-13 20:20:40 +0000310else
311 AC_MSG_RESULT(no)
312fi
313
Bram Moolenaar39766a72013-11-03 00:41:00 +0100314dnl Mac OS X 10.9+ no longer include AvailabilityMacros.h in Carbon
315dnl so we need to include it to have access to version macros.
Bram Moolenaar18e54692013-11-03 20:26:31 +0100316AC_CHECK_HEADERS(AvailabilityMacros.h)
Evan Miller25448072022-12-30 10:42:23 +0000317# 10.5 and earlier lack dispatch
318AC_CHECK_HEADERS(dispatch/dispatch.h)
Bram Moolenaar39766a72013-11-03 00:41:00 +0100319
Bram Moolenaar071d4272004-06-13 20:20:40 +0000320AC_SUBST(OS_EXTRA_SRC)
321AC_SUBST(OS_EXTRA_OBJ)
322
323dnl Add /usr/local/lib to $LDFLAGS and /usr/local/include to CFLAGS.
324dnl Only when the directory exists and it wasn't there yet.
325dnl For gcc don't do this when it is already in the default search path.
Bram Moolenaar446cb832008-06-24 21:56:24 +0000326dnl Skip all of this when cross-compiling.
327if test "$cross_compiling" = no; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000328 AC_MSG_CHECKING(--with-local-dir argument)
Bram Moolenaar446cb832008-06-24 21:56:24 +0000329 have_local_include=''
330 have_local_lib=''
Bram Moolenaarc236c162008-07-13 17:41:49 +0000331 AC_ARG_WITH([local-dir], [ --with-local-dir=PATH search PATH instead of /usr/local for local libraries.
332 --without-local-dir do not search /usr/local for local libraries.], [
333 local_dir="$withval"
334 case "$withval" in
335 */*) ;;
336 no)
337 # avoid adding local dir to LDFLAGS and CPPFLAGS
Bram Moolenaare06c1882010-07-21 22:05:20 +0200338 have_local_include=yes
Bram Moolenaarc236c162008-07-13 17:41:49 +0000339 have_local_lib=yes
340 ;;
341 *) AC_MSG_ERROR(must pass path argument to --with-local-dir) ;;
342 esac
343 AC_MSG_RESULT($local_dir)
344 ], [
345 local_dir=/usr/local
346 AC_MSG_RESULT(Defaulting to $local_dir)
347 ])
348 if test "$GCC" = yes -a "$local_dir" != no; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000349 echo 'void f(){}' > conftest.c
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100350 dnl Removed -no-cpp-precomp, only needed for OS X 10.2 (Ben Fowler)
351 have_local_include=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/include"`
Bram Moolenaarc236c162008-07-13 17:41:49 +0000352 have_local_lib=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/lib"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000353 rm -f conftest.c conftest.o
Bram Moolenaar071d4272004-06-13 20:20:40 +0000354 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000355 if test -z "$have_local_lib" -a -d "${local_dir}/lib"; then
356 tt=`echo "$LDFLAGS" | sed -e "s+-L${local_dir}/lib ++g" -e "s+-L${local_dir}/lib$++g"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000357 if test "$tt" = "$LDFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000358 LDFLAGS="$LDFLAGS -L${local_dir}/lib"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000359 fi
360 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000361 if test -z "$have_local_include" -a -d "${local_dir}/include"; then
362 tt=`echo "$CPPFLAGS" | sed -e "s+-I${local_dir}/include ++g" -e "s+-I${local_dir}/include$++g"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000363 if test "$tt" = "$CPPFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000364 CPPFLAGS="$CPPFLAGS -I${local_dir}/include"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000365 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000366 fi
367fi
368
369AC_MSG_CHECKING(--with-vim-name argument)
370AC_ARG_WITH(vim-name, [ --with-vim-name=NAME what to call the Vim executable],
371 VIMNAME="$withval"; AC_MSG_RESULT($VIMNAME),
Bram Moolenaare344bea2005-09-01 20:46:49 +0000372 VIMNAME="vim"; AC_MSG_RESULT(Defaulting to $VIMNAME))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000373AC_SUBST(VIMNAME)
374AC_MSG_CHECKING(--with-ex-name argument)
375AC_ARG_WITH(ex-name, [ --with-ex-name=NAME what to call the Ex executable],
376 EXNAME="$withval"; AC_MSG_RESULT($EXNAME),
377 EXNAME="ex"; AC_MSG_RESULT(Defaulting to ex))
378AC_SUBST(EXNAME)
379AC_MSG_CHECKING(--with-view-name argument)
380AC_ARG_WITH(view-name, [ --with-view-name=NAME what to call the View executable],
381 VIEWNAME="$withval"; AC_MSG_RESULT($VIEWNAME),
382 VIEWNAME="view"; AC_MSG_RESULT(Defaulting to view))
383AC_SUBST(VIEWNAME)
384
385AC_MSG_CHECKING(--with-global-runtime argument)
Bram Moolenaar9d302ad2018-12-21 11:48:51 +0100386AC_ARG_WITH(global-runtime, [ --with-global-runtime=DIR global runtime directory in 'runtimepath', comma-separated for multiple directories],
387 RUNTIME_GLOBAL="$withval"; AC_MSG_RESULT($withval),
Bram Moolenaar071d4272004-06-13 20:20:40 +0000388 AC_MSG_RESULT(no))
389
Bram Moolenaar9d302ad2018-12-21 11:48:51 +0100390if test "X$RUNTIME_GLOBAL" != "X"; then
391 RUNTIME_GLOBAL_AFTER=$(printf -- "$RUNTIME_GLOBAL\\n" | $AWK -F, 'BEGIN { comma=0 } { for (i = NF; i > 0; i--) { if (comma) { printf ",%s/after", $i } else { printf "%s/after", $i; comma=1 } } } END { printf "\n" }')
392 AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL, "$RUNTIME_GLOBAL")
393 AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL_AFTER, "$RUNTIME_GLOBAL_AFTER")
394fi
395
Bram Moolenaar071d4272004-06-13 20:20:40 +0000396AC_MSG_CHECKING(--with-modified-by argument)
397AC_ARG_WITH(modified-by, [ --with-modified-by=NAME name of who modified a release version],
398 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(MODIFIED_BY, "$withval"),
399 AC_MSG_RESULT(no))
400
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200401dnl Check for EBCDIC stolen from the LYNX port to z/OS Unix
Bram Moolenaar071d4272004-06-13 20:20:40 +0000402AC_MSG_CHECKING(if character set is EBCDIC)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +0100403AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ ],
Bram Moolenaar071d4272004-06-13 20:20:40 +0000404[ /* TryCompile function for CharSet.
405 Treat any failure as ASCII for compatibility with existing art.
406 Use compile-time rather than run-time tests for cross-compiler
407 tolerance. */
408#if '0'!=240
409make an error "Character set is not EBCDIC"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +0100410#endif ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +0000411[ # TryCompile action if true
412cf_cv_ebcdic=yes ],
413[ # TryCompile action if false
414cf_cv_ebcdic=no])
415# end of TryCompile ])
416# end of CacheVal CvEbcdic
417AC_MSG_RESULT($cf_cv_ebcdic)
418case "$cf_cv_ebcdic" in #(vi
419 yes) AC_DEFINE(EBCDIC)
420 line_break='"\\n"'
421 ;;
422 *) line_break='"\\012"';;
423esac
424AC_SUBST(line_break)
425
426if test "$cf_cv_ebcdic" = "yes"; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +0200427dnl If we have EBCDIC we most likely have z/OS Unix, let's test it!
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200428AC_MSG_CHECKING(for z/OS Unix)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000429case $vim_cv_uname_output in
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200430 OS/390) zOSUnix="yes";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000431 dnl If using cc the environment variable _CC_CCMODE must be
432 dnl set to "1", so that some compiler extensions are enabled.
433 dnl If using c89 the environment variable is named _CC_C89MODE.
434 dnl Note: compile with c89 never tested.
435 if test "$CC" = "cc"; then
436 ccm="$_CC_CCMODE"
437 ccn="CC"
438 else
439 if test "$CC" = "c89"; then
440 ccm="$_CC_C89MODE"
441 ccn="C89"
442 else
443 ccm=1
444 fi
445 fi
446 if test "$ccm" != "1"; then
447 echo ""
448 echo "------------------------------------------"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200449 echo " On z/OS Unix, the environment variable"
Bram Moolenaar77c19352012-06-13 19:19:41 +0200450 echo " _CC_${ccn}MODE must be set to \"1\"!"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000451 echo " Do:"
452 echo " export _CC_${ccn}MODE=1"
453 echo " and then call configure again."
454 echo "------------------------------------------"
455 exit 1
456 fi
Bram Moolenaar77c19352012-06-13 19:19:41 +0200457 # Set CFLAGS for configure process.
458 # This will be reset later for config.mk.
459 # Use haltonmsg to force error for missing H files.
460 CFLAGS="$CFLAGS -D_ALL_SOURCE -Wc,float(ieee),haltonmsg(3296)";
461 LDFLAGS="$LDFLAGS -Wl,EDIT=NO"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000462 AC_MSG_RESULT(yes)
463 ;;
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200464 *) zOSUnix="no";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000465 AC_MSG_RESULT(no)
466 ;;
467esac
468fi
469
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200470dnl Set QUOTESED. Needs additional backslashes on zOS
471if test "$zOSUnix" = "yes"; then
Bram Moolenaarabcbb0e2020-12-23 12:33:42 +0100472 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\\\\\&/g' -e 's/\\\\\\\\\"/\"/' -e 's/\\\\\\\\\";\$\$/\";/' -e 's/ */ /g'"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200473else
Bram Moolenaarabcbb0e2020-12-23 12:33:42 +0100474 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\&/g' -e 's/\\\\\"/\"/' -e 's/\\\\\";\$\$/\";/' -e 's/ */ /g'"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200475fi
476AC_SUBST(QUOTESED)
477
478
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200479dnl Link with -lsmack for Smack stuff; if not found
480AC_MSG_CHECKING(--disable-smack argument)
481AC_ARG_ENABLE(smack,
482 [ --disable-smack Do not check for Smack support.],
483 , enable_smack="yes")
484if test "$enable_smack" = "yes"; then
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200485 AC_MSG_RESULT(no)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200486 AC_CHECK_HEADER([linux/xattr.h], true, enable_smack="no")
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200487else
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200488 AC_MSG_RESULT(yes)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200489fi
490if test "$enable_smack" = "yes"; then
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200491 AC_CHECK_HEADER([attr/xattr.h], true, enable_smack="no")
492fi
493if test "$enable_smack" = "yes"; then
494 AC_MSG_CHECKING(for XATTR_NAME_SMACKEXEC in linux/xattr.h)
495 AC_EGREP_CPP(XATTR_NAME_SMACKEXEC, [#include <linux/xattr.h>],
496 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +0200497 AC_MSG_RESULT(no); enable_smack="no")
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200498fi
499if test "$enable_smack" = "yes"; then
500 AC_CHECK_LIB(attr, setxattr,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200501 [LIBS="$LIBS -lattr"
502 found_smack="yes"
503 AC_DEFINE(HAVE_SMACK)])
Bram Moolenaar588ebeb2008-05-07 17:09:24 +0000504fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000505
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200506dnl When smack was found don't search for SELinux
507if test "x$found_smack" = "x"; then
508 dnl Link with -lselinux for SELinux stuff; if not found
509 AC_MSG_CHECKING(--disable-selinux argument)
510 AC_ARG_ENABLE(selinux,
511 [ --disable-selinux Do not check for SELinux support.],
512 , enable_selinux="yes")
513 if test "$enable_selinux" = "yes"; then
514 AC_MSG_RESULT(no)
515 AC_CHECK_LIB(selinux, is_selinux_enabled,
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100516 [AC_CHECK_HEADER(selinux/selinux.h,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200517 [LIBS="$LIBS -lselinux"
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100518 AC_DEFINE(HAVE_SELINUX)])])
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200519 else
520 AC_MSG_RESULT(yes)
521 fi
522fi
523
Bram Moolenaar071d4272004-06-13 20:20:40 +0000524dnl Check user requested features.
525
526AC_MSG_CHECKING(--with-features argument)
Martin Tournoij25f3a142022-10-08 19:26:41 +0100527AC_ARG_WITH(features, [ --with-features=TYPE tiny, normal or huge (default: huge)],
Bram Moolenaar071d4272004-06-13 20:20:40 +0000528 features="$withval"; AC_MSG_RESULT($features),
Bram Moolenaar23c4f712016-01-20 22:11:59 +0100529 features="huge"; AC_MSG_RESULT(Defaulting to huge))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000530
Martin Tournoij7904fa42022-10-04 16:28:45 +0100531dnl "small" is supported for backwards compatibility, now an alias for "tiny"
Martin Tournoij25f3a142022-10-08 19:26:41 +0100532dnl "big" is supported for backwards compatibility, now an alias for "normal"
Martin Tournoij7904fa42022-10-04 16:28:45 +0100533case "$features" in
Martin Tournoij25f3a142022-10-08 19:26:41 +0100534 small) features="tiny" ;;
535 big) features="normal" ;;
Martin Tournoij7904fa42022-10-04 16:28:45 +0100536esac
537
Bram Moolenaar071d4272004-06-13 20:20:40 +0000538dovimdiff=""
539dogvimdiff=""
540case "$features" in
541 tiny) AC_DEFINE(FEAT_TINY) ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000542 normal) AC_DEFINE(FEAT_NORMAL) dovimdiff="installvimdiff";
543 dogvimdiff="installgvimdiff" ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000544 huge) AC_DEFINE(FEAT_HUGE) dovimdiff="installvimdiff";
545 dogvimdiff="installgvimdiff" ;;
546 *) AC_MSG_RESULT([Sorry, $features is not supported]) ;;
547esac
548
549AC_SUBST(dovimdiff)
550AC_SUBST(dogvimdiff)
551
Martin Tournoij7904fa42022-10-04 16:28:45 +0100552if test "x$features" = "xtiny"; then
Bram Moolenaar12471262022-01-18 11:11:25 +0000553 has_eval=no
554else
555 has_eval=yes
556fi
557
Bram Moolenaar071d4272004-06-13 20:20:40 +0000558AC_MSG_CHECKING(--with-compiledby argument)
559AC_ARG_WITH(compiledby, [ --with-compiledby=NAME name to show in :version message],
560 compiledby="$withval"; AC_MSG_RESULT($withval),
561 compiledby=""; AC_MSG_RESULT(no))
562AC_SUBST(compiledby)
563
564AC_MSG_CHECKING(--disable-xsmp argument)
565AC_ARG_ENABLE(xsmp,
566 [ --disable-xsmp Disable XSMP session management],
567 , enable_xsmp="yes")
568
569if test "$enable_xsmp" = "yes"; then
570 AC_MSG_RESULT(no)
571 AC_MSG_CHECKING(--disable-xsmp-interact argument)
572 AC_ARG_ENABLE(xsmp-interact,
573 [ --disable-xsmp-interact Disable XSMP interaction],
574 , enable_xsmp_interact="yes")
575 if test "$enable_xsmp_interact" = "yes"; then
576 AC_MSG_RESULT(no)
577 AC_DEFINE(USE_XSMP_INTERACT)
578 else
579 AC_MSG_RESULT(yes)
580 fi
581else
582 AC_MSG_RESULT(yes)
583fi
584
Bram Moolenaar67ffb412022-01-08 13:36:57 +0000585AC_MSG_CHECKING([diff feature])
Martin Tournoij7904fa42022-10-04 16:28:45 +0100586if test "x$features" = "xtiny"; then
Bram Moolenaar67ffb412022-01-08 13:36:57 +0000587 AC_MSG_RESULT([disabled in $features version])
588else
589 AC_MSG_RESULT(enabled)
590 AC_DEFINE(FEAT_DIFF)
591 XDIFF_OBJS_USED="\$(XDIFF_OBJS)"
592 AC_SUBST(XDIFF_OBJS_USED)
593fi
594
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200595dnl Check for Lua feature.
596AC_MSG_CHECKING(--enable-luainterp argument)
597AC_ARG_ENABLE(luainterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200598 [ --enable-luainterp[=OPTS] Include Lua interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200599 [enable_luainterp="no"])
600AC_MSG_RESULT($enable_luainterp)
601
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200602if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then
Bram Moolenaar12471262022-01-18 11:11:25 +0000603 if test "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +0100604 AC_MSG_ERROR([cannot use Lua with tiny features])
Bram Moolenaar3c124e32016-01-31 14:36:58 +0100605 fi
606
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200607 dnl -- find the lua executable
608 AC_SUBST(vi_cv_path_lua)
609
610 AC_MSG_CHECKING(--with-lua-prefix argument)
611 AC_ARG_WITH(lua_prefix,
612 [ --with-lua-prefix=PFX Prefix where Lua is installed.],
613 with_lua_prefix="$withval"; AC_MSG_RESULT($with_lua_prefix),
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200614 with_lua_prefix="";AC_MSG_RESULT(no))
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200615
616 if test "X$with_lua_prefix" != "X"; then
617 vi_cv_path_lua_pfx="$with_lua_prefix"
618 else
619 AC_MSG_CHECKING(LUA_PREFIX environment var)
620 if test "X$LUA_PREFIX" != "X"; then
621 AC_MSG_RESULT("$LUA_PREFIX")
622 vi_cv_path_lua_pfx="$LUA_PREFIX"
623 else
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200624 AC_MSG_RESULT([not set, default to /usr])
625 vi_cv_path_lua_pfx="/usr"
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200626 fi
627 fi
628
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200629 AC_MSG_CHECKING(--with-luajit)
630 AC_ARG_WITH(luajit,
631 [ --with-luajit Link with LuaJIT instead of Lua.],
632 [vi_cv_with_luajit="$withval"],
633 [vi_cv_with_luajit="no"])
634 AC_MSG_RESULT($vi_cv_with_luajit)
635
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200636 LUA_INC=
637 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200638 if test "x$vi_cv_with_luajit" != "xno"; then
639 dnl -- try to find LuaJIT executable
640 AC_PATH_PROG(vi_cv_path_luajit, luajit)
641 if test "X$vi_cv_path_luajit" != "X"; then
642 dnl -- find LuaJIT version
643 AC_CACHE_CHECK(LuaJIT version, vi_cv_version_luajit,
Bram Moolenaar49b10272013-11-21 12:17:51 +0100644 [ vi_cv_version_luajit=`${vi_cv_path_luajit} -v 2>&1 | sed 's/LuaJIT \([[0-9.]]*\)\.[[0-9]]\(-[[a-z0-9]]*\)* .*/\1/'` ])
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200645 AC_CACHE_CHECK(Lua version of LuaJIT, vi_cv_version_lua_luajit,
646 [ vi_cv_version_lua_luajit=`${vi_cv_path_luajit} -e "print(_VERSION)" | sed 's/.* //'` ])
647 vi_cv_path_lua="$vi_cv_path_luajit"
648 vi_cv_version_lua="$vi_cv_version_lua_luajit"
649 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200650 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200651 dnl -- try to find Lua executable
652 AC_PATH_PROG(vi_cv_path_plain_lua, lua)
653 if test "X$vi_cv_path_plain_lua" != "X"; then
654 dnl -- find Lua version
655 AC_CACHE_CHECK(Lua version, vi_cv_version_plain_lua,
656 [ vi_cv_version_plain_lua=`${vi_cv_path_plain_lua} -e "print(_VERSION)" | sed 's/.* //'` ])
657 fi
658 vi_cv_path_lua="$vi_cv_path_plain_lua"
659 vi_cv_version_lua="$vi_cv_version_plain_lua"
660 fi
661 if test "x$vi_cv_with_luajit" != "xno" && test "X$vi_cv_version_luajit" != "X"; then
662 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit)
Bram Moolenaar49222be2015-12-11 18:11:30 +0100663 if test -f "$vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200664 AC_MSG_RESULT(yes)
665 LUA_INC=/luajit-$vi_cv_version_luajit
666 fi
667 fi
668 if test "X$LUA_INC" = "X"; then
669 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)
Bram Moolenaar49222be2015-12-11 18:11:30 +0100670 if test -f "$vi_cv_path_lua_pfx/include/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200671 AC_MSG_RESULT(yes)
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200672 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200673 AC_MSG_RESULT(no)
674 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua)
Bram Moolenaar49222be2015-12-11 18:11:30 +0100675 if test -f "$vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200676 AC_MSG_RESULT(yes)
677 LUA_INC=/lua$vi_cv_version_lua
678 else
679 AC_MSG_RESULT(no)
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200680
681 # Detect moonjit:
682 # https://groups.google.com/forum/#!topic/vim_use/O0vek60WuTk
683 lua_suf=/moonjit-2.3
684 inc_path="$vi_cv_path_lua_pfx/include"
Bram Moolenaarad4dc832020-04-20 16:21:53 +0200685 for dir in "$inc_path"/moonjit-[[0-9]]* ; do
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200686 if test -d "$dir" ; then
Bram Moolenaara79a8942020-12-17 20:50:25 +0100687 lua_suf=`basename "$dir"`
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200688 lua_suf="/$lua_suf"
689 break
690 fi
691 done
692 AC_MSG_CHECKING(if lua.h can be found in $inc_path$lua_suf)
693 if test -f "$inc_path$lua_suf/lua.h"; then
694 AC_MSG_RESULT(yes)
695 LUA_INC=$lua_suf
696 else
697 AC_MSG_RESULT(no)
698 vi_cv_path_lua_pfx=
699 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200700 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200701 fi
702 fi
703 fi
704
705 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200706 if test "x$vi_cv_with_luajit" != "xno"; then
707 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
708 if test "X$multiarch" != "X"; then
709 lib_multiarch="lib/${multiarch}"
710 else
711 lib_multiarch="lib"
712 fi
713 if test "X$vi_cv_version_lua" = "X"; then
714 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit"
715 else
716 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit-$vi_cv_version_lua"
717 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200718 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200719 if test "X$LUA_INC" != "X"; then
720 dnl Test alternate location using version
721 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua$vi_cv_version_lua"
722 else
723 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua"
724 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200725 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200726 if test "$enable_luainterp" = "dynamic"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200727 lua_ok="yes"
728 else
729 AC_MSG_CHECKING([if link with ${LUA_LIBS} is sane])
730 libs_save=$LIBS
731 LIBS="$LIBS $LUA_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +0100732 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200733 AC_MSG_RESULT(yes); lua_ok="yes",
734 AC_MSG_RESULT(no); lua_ok="no"; LUA_LIBS="")
735 LIBS=$libs_save
736 fi
737 if test "x$lua_ok" = "xyes"; then
738 LUA_CFLAGS="-I${vi_cv_path_lua_pfx}/include${LUA_INC}"
739 LUA_SRC="if_lua.c"
740 LUA_OBJ="objects/if_lua.o"
741 LUA_PRO="if_lua.pro"
742 AC_DEFINE(FEAT_LUA)
743 fi
744 if test "$enable_luainterp" = "dynamic"; then
745 if test "x$vi_cv_with_luajit" != "xno"; then
746 luajit="jit"
747 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200748 if test -f "${vi_cv_path_lua_pfx}/bin/cyglua-${vi_cv_version_lua}.dll"; then
749 vi_cv_dll_name_lua="cyglua-${vi_cv_version_lua}.dll"
750 else
Bram Moolenaard0573012017-10-28 21:11:06 +0200751 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200752 ext="dylib"
753 indexes=""
754 else
755 ext="so"
756 indexes=".0 .1 .2 .3 .4 .5 .6 .7 .8 .9"
757 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
758 if test "X$multiarch" != "X"; then
759 lib_multiarch="lib/${multiarch}"
760 fi
Bram Moolenaar768baac2013-04-15 14:44:57 +0200761 fi
762 dnl Determine the sover for the current version, but fallback to
763 dnl liblua${vi_cv_version_lua}.so if no sover-versioned file is found.
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200764 AC_MSG_CHECKING(if liblua${luajit}*.${ext}* can be found in $vi_cv_path_lua_pfx)
Bram Moolenaar768baac2013-04-15 14:44:57 +0200765 for subdir in "${lib_multiarch}" lib64 lib; do
766 if test -z "$subdir"; then
767 continue
768 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200769 for sover in "${vi_cv_version_lua}.${ext}" "-${vi_cv_version_lua}.${ext}" \
770 ".${vi_cv_version_lua}.${ext}" ".${ext}.${vi_cv_version_lua}"; do
771 for i in $indexes ""; do
772 if test -f "${vi_cv_path_lua_pfx}/${subdir}/liblua${luajit}${sover}$i"; then
Bram Moolenaar768baac2013-04-15 14:44:57 +0200773 sover2="$i"
774 break 3
775 fi
776 done
Bram Moolenaar07e1da62013-02-06 19:49:43 +0100777 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200778 sover=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200779 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200780 if test "X$sover" = "X"; then
781 AC_MSG_RESULT(no)
782 lua_ok="no"
783 vi_cv_dll_name_lua="liblua${luajit}.${ext}"
784 else
785 AC_MSG_RESULT(yes)
786 lua_ok="yes"
787 vi_cv_dll_name_lua="liblua${luajit}${sover}$sover2"
788 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200789 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200790 AC_DEFINE(DYNAMIC_LUA)
791 LUA_LIBS=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200792 LUA_CFLAGS="-DDYNAMIC_LUA_DLL=\\\"${vi_cv_dll_name_lua}\\\" $LUA_CFLAGS"
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200793 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200794 if test "X$LUA_CFLAGS$LUA_LIBS" != "X" && \
Bram Moolenaard0573012017-10-28 21:11:06 +0200795 test "x$MACOS_X" = "xyes" && test "x$vi_cv_with_luajit" != "xno" && \
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000796 test "$vim_cv_uname_m_output" = "x86_64"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200797 dnl OSX/x64 requires these flags. See http://luajit.org/install.html
798 LUA_LIBS="-pagezero_size 10000 -image_base 100000000 $LUA_LIBS"
799 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200800 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200801 if test "$fail_if_missing" = "yes" -a "$lua_ok" != "yes"; then
Bram Moolenaarf788a062011-12-14 20:51:25 +0100802 AC_MSG_ERROR([could not configure lua])
803 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200804 AC_SUBST(LUA_SRC)
805 AC_SUBST(LUA_OBJ)
806 AC_SUBST(LUA_PRO)
807 AC_SUBST(LUA_LIBS)
808 AC_SUBST(LUA_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +0000809 AC_SUBST(LUA_CFLAGS_EXTRA)
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200810fi
811
812
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000813dnl Check for MzScheme feature.
814AC_MSG_CHECKING(--enable-mzschemeinterp argument)
815AC_ARG_ENABLE(mzschemeinterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200816 [ --enable-mzschemeinterp Include MzScheme interpreter.], ,
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000817 [enable_mzschemeinterp="no"])
818AC_MSG_RESULT($enable_mzschemeinterp)
819
820if test "$enable_mzschemeinterp" = "yes"; then
821 dnl -- find the mzscheme executable
822 AC_SUBST(vi_cv_path_mzscheme)
823
824 AC_MSG_CHECKING(--with-plthome argument)
825 AC_ARG_WITH(plthome,
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000826 [ --with-plthome=PLTHOME Use PLTHOME.],
827 with_plthome="$withval"; AC_MSG_RESULT($with_plthome),
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000828 with_plthome="";AC_MSG_RESULT("no"))
829
830 if test "X$with_plthome" != "X"; then
831 vi_cv_path_mzscheme_pfx="$with_plthome"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100832 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000833 else
834 AC_MSG_CHECKING(PLTHOME environment var)
835 if test "X$PLTHOME" != "X"; then
836 AC_MSG_RESULT("$PLTHOME")
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000837 vi_cv_path_mzscheme_pfx="$PLTHOME"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100838 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000839 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000840 AC_MSG_RESULT(not set)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000841 dnl -- try to find MzScheme executable
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000842 AC_PATH_PROG(vi_cv_path_mzscheme, mzscheme)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000843
844 dnl resolve symbolic link, the executable is often elsewhere and there
845 dnl are no links for the include files.
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000846 if test "X$vi_cv_path_mzscheme" != "X"; then
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000847 lsout=`ls -l $vi_cv_path_mzscheme`
848 if echo "$lsout" | grep -e '->' >/dev/null 2>/dev/null; then
849 vi_cv_path_mzscheme=`echo "$lsout" | sed 's/.*-> \(.*\)/\1/'`
850 fi
851 fi
852
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000853 if test "X$vi_cv_path_mzscheme" != "X"; then
854 dnl -- find where MzScheme thinks it was installed
855 AC_CACHE_CHECK(MzScheme install prefix,vi_cv_path_mzscheme_pfx,
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000856 dnl different versions of MzScheme differ in command line processing
857 dnl use universal approach
858 echo "(display (simplify-path \
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000859 (build-path (call-with-values \
860 (lambda () (split-path (find-system-path (quote exec-file)))) \
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000861 (lambda (base name must-be-dir?) base)) (quote up))))" > mzdirs.scm
862 dnl Remove a trailing slash
863 [ vi_cv_path_mzscheme_pfx=`${vi_cv_path_mzscheme} -r mzdirs.scm | \
864 sed -e 's+/$++'` ])
865 rm -f mzdirs.scm
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000866 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000867 fi
868 fi
869
870 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100871 AC_MSG_CHECKING(for racket include directory)
872 SCHEME_INC=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-include-dir))) (when (path? p) (display p)))'`
873 if test "X$SCHEME_INC" != "X"; then
874 AC_MSG_RESULT(${SCHEME_INC})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000875 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100876 AC_MSG_RESULT(not found)
877 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include)
878 if test -f "$vi_cv_path_mzscheme_pfx/include/scheme.h"; then
879 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000880 AC_MSG_RESULT(yes)
Bram Moolenaard7afed32007-05-06 13:26:41 +0000881 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000882 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100883 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt)
884 if test -f "$vi_cv_path_mzscheme_pfx/include/plt/scheme.h"; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000885 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100886 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000887 else
888 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100889 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket)
890 if test -f "$vi_cv_path_mzscheme_pfx/include/racket/scheme.h"; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100891 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100892 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100893 else
894 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100895 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/)
896 if test -f /usr/include/plt/scheme.h; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100897 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100898 SCHEME_INC=/usr/include/plt
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100899 else
900 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100901 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/racket/)
902 if test -f /usr/include/racket/scheme.h; then
903 AC_MSG_RESULT(yes)
904 SCHEME_INC=/usr/include/racket
905 else
906 AC_MSG_RESULT(no)
907 vi_cv_path_mzscheme_pfx=
908 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100909 fi
910 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000911 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000912 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000913 fi
914 fi
915
916 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100917
918 AC_MSG_CHECKING(for racket lib directory)
919 SCHEME_LIB=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-lib-dir))) (when (path? p) (display p)))'`
920 if test "X$SCHEME_LIB" != "X"; then
921 AC_MSG_RESULT(${SCHEME_LIB})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000922 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100923 AC_MSG_RESULT(not found)
924 fi
925
926 for path in "${vi_cv_path_mzscheme_pfx}/lib" "${SCHEME_LIB}"; do
927 if test "X$path" != "X"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200928 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100929 MZSCHEME_LIBS="-framework Racket"
930 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
931 elif test -f "${path}/libmzscheme3m.a"; then
932 MZSCHEME_LIBS="${path}/libmzscheme3m.a"
933 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
934 elif test -f "${path}/libracket3m.a"; then
935 MZSCHEME_LIBS="${path}/libracket3m.a"
Bram Moolenaar588d2412020-10-03 14:24:19 +0200936 if test -f "${path}/librktio.a"; then
937 MZSCHEME_LIBS="${MZSCHEME_LIBS} ${path}/librktio.a"
938 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100939 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
940 elif test -f "${path}/libracket.a"; then
941 MZSCHEME_LIBS="${path}/libracket.a ${path}/libmzgc.a"
942 elif test -f "${path}/libmzscheme.a"; then
943 MZSCHEME_LIBS="${path}/libmzscheme.a ${path}/libmzgc.a"
944 else
945 dnl Using shared objects
946 if test -f "${path}/libmzscheme3m.so"; then
947 MZSCHEME_LIBS="-L${path} -lmzscheme3m"
948 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
949 elif test -f "${path}/libracket3m.so"; then
950 MZSCHEME_LIBS="-L${path} -lracket3m"
951 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
952 elif test -f "${path}/libracket.so"; then
953 MZSCHEME_LIBS="-L${path} -lracket -lmzgc"
954 else
955 dnl try next until last
956 if test "$path" != "$SCHEME_LIB"; then
957 continue
958 fi
959 MZSCHEME_LIBS="-L${path} -lmzscheme -lmzgc"
960 fi
961 if test "$GCC" = yes; then
962 dnl Make Vim remember the path to the library. For when it's not in
963 dnl $LD_LIBRARY_PATH.
964 MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${path}"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000965 elif test "$vim_cv_uname_output" = SunOS &&
966 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100967 MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${path}"
968 fi
969 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000970 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100971 if test "X$MZSCHEME_LIBS" != "X"; then
972 break
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +0000973 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100974 done
975
976 AC_MSG_CHECKING([if racket requires -pthread])
977 if test "X$SCHEME_LIB" != "X" && $FGREP -e -pthread "$SCHEME_LIB/buildinfo" >/dev/null ; then
978 AC_MSG_RESULT(yes)
979 MZSCHEME_LIBS="${MZSCHEME_LIBS} -pthread"
980 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -pthread"
981 else
982 AC_MSG_RESULT(no)
983 fi
984
985 AC_MSG_CHECKING(for racket config directory)
986 SCHEME_CONFIGDIR=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-config-dir))) (when (path? p) (display p)))'`
987 if test "X$SCHEME_CONFIGDIR" != "X"; then
988 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DMZSCHEME_CONFIGDIR='\"${SCHEME_CONFIGDIR}\"'"
989 AC_MSG_RESULT(${SCHEME_CONFIGDIR})
990 else
991 AC_MSG_RESULT(not found)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000992 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100993
994 AC_MSG_CHECKING(for racket collects directory)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100995 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))))'`
996 if test "X$SCHEME_COLLECTS" = "X"; then
997 if test -d "$vi_cv_path_mzscheme_pfx/lib/plt/collects"; then
998 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/plt/
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100999 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +01001000 if test -d "$vi_cv_path_mzscheme_pfx/lib/racket/collects"; then
1001 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/racket/
Bram Moolenaar75676462013-01-30 14:55:42 +01001002 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +01001003 if test -d "$vi_cv_path_mzscheme_pfx/share/racket/collects"; then
1004 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/
1005 else
1006 if test -d "$vi_cv_path_mzscheme_pfx/collects"; then
1007 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/
1008 fi
Bram Moolenaar75676462013-01-30 14:55:42 +01001009 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001010 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +01001011 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +00001012 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001013 if test "X$SCHEME_COLLECTS" != "X" ; then
1014 AC_MSG_RESULT(${SCHEME_COLLECTS})
1015 else
1016 AC_MSG_RESULT(not found)
1017 fi
1018
1019 AC_MSG_CHECKING(for mzscheme_base.c)
1020 if test -f "${SCHEME_COLLECTS}collects/scheme/base.ss" ; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001021 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +01001022 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
1023 MZSCHEME_MOD="++lib scheme/base"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +01001024 else
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001025 if test -f "${SCHEME_COLLECTS}collects/scheme/base.rkt" ; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +01001026 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +01001027 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
1028 MZSCHEME_MOD="++lib scheme/base"
1029 else
1030 if test -f "${SCHEME_COLLECTS}collects/racket/base.rkt" ; then
1031 MZSCHEME_EXTRA="mzscheme_base.c"
1032 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/raco ctool"
1033 MZSCHEME_MOD=""
1034 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +01001035 fi
1036 fi
1037 if test "X$MZSCHEME_EXTRA" != "X" ; then
1038 dnl need to generate bytecode for MzScheme base
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001039 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE"
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001040 AC_MSG_RESULT(needed)
1041 else
1042 AC_MSG_RESULT(not needed)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001043 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001044
Bram Moolenaar9e902192013-07-17 18:58:11 +02001045 dnl On Ubuntu this fixes "undefined reference to symbol 'ffi_type_void'".
1046 AC_CHECK_LIB(ffi, ffi_type_void, [MZSCHEME_LIBS="$MZSCHEME_LIBS -lffi"])
1047
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001048 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -I${SCHEME_INC} \
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001049 -DMZSCHEME_COLLECTS='\"${SCHEME_COLLECTS}collects\"'"
Bram Moolenaar9e902192013-07-17 18:58:11 +02001050
1051 dnl Test that we can compile a simple program with these CFLAGS and LIBS.
1052 AC_MSG_CHECKING([if compile and link flags for MzScheme are sane])
1053 cflags_save=$CFLAGS
1054 libs_save=$LIBS
1055 CFLAGS="$CFLAGS $MZSCHEME_CFLAGS"
1056 LIBS="$LIBS $MZSCHEME_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001057 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaar9e902192013-07-17 18:58:11 +02001058 AC_MSG_RESULT(yes); mzs_ok=yes,
1059 AC_MSG_RESULT(no: MZSCHEME DISABLED); mzs_ok=no)
1060 CFLAGS=$cflags_save
1061 LIBS=$libs_save
1062 if test $mzs_ok = yes; then
1063 MZSCHEME_SRC="if_mzsch.c"
1064 MZSCHEME_OBJ="objects/if_mzsch.o"
1065 MZSCHEME_PRO="if_mzsch.pro"
1066 AC_DEFINE(FEAT_MZSCHEME)
1067 else
1068 MZSCHEME_CFLAGS=
1069 MZSCHEME_LIBS=
1070 MZSCHEME_EXTRA=
1071 MZSCHEME_MZC=
1072 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001073 fi
1074 AC_SUBST(MZSCHEME_SRC)
1075 AC_SUBST(MZSCHEME_OBJ)
1076 AC_SUBST(MZSCHEME_PRO)
1077 AC_SUBST(MZSCHEME_LIBS)
1078 AC_SUBST(MZSCHEME_CFLAGS)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001079 AC_SUBST(MZSCHEME_EXTRA)
1080 AC_SUBST(MZSCHEME_MZC)
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001081fi
1082
1083
Bram Moolenaar071d4272004-06-13 20:20:40 +00001084AC_MSG_CHECKING(--enable-perlinterp argument)
1085AC_ARG_ENABLE(perlinterp,
Bram Moolenaare06c1882010-07-21 22:05:20 +02001086 [ --enable-perlinterp[=OPTS] Include Perl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001087 [enable_perlinterp="no"])
1088AC_MSG_RESULT($enable_perlinterp)
Bram Moolenaare06c1882010-07-21 22:05:20 +02001089if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00001090 if test "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +01001091 AC_MSG_ERROR([cannot use Perl with tiny features])
Bram Moolenaar3c124e32016-01-31 14:36:58 +01001092 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001093 AC_SUBST(vi_cv_path_perl)
1094 AC_PATH_PROG(vi_cv_path_perl, perl)
1095 if test "X$vi_cv_path_perl" != "X"; then
1096 AC_MSG_CHECKING(Perl version)
1097 if $vi_cv_path_perl -e 'require 5.003_01' >/dev/null 2>/dev/null; then
1098 eval `$vi_cv_path_perl -V:usethreads`
Bram Moolenaare06c1882010-07-21 22:05:20 +02001099 eval `$vi_cv_path_perl -V:libperl`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001100 if test "X$usethreads" = "XUNKNOWN" -o "X$usethreads" = "Xundef"; then
1101 badthreads=no
1102 else
1103 if $vi_cv_path_perl -e 'require 5.6.0' >/dev/null 2>/dev/null; then
1104 eval `$vi_cv_path_perl -V:use5005threads`
1105 if test "X$use5005threads" = "XUNKNOWN" -o "X$use5005threads" = "Xundef"; then
1106 badthreads=no
1107 else
1108 badthreads=yes
1109 AC_MSG_RESULT(>>> Perl > 5.6 with 5.5 threads cannot be used <<<)
1110 fi
1111 else
1112 badthreads=yes
1113 AC_MSG_RESULT(>>> Perl 5.5 with threads cannot be used <<<)
1114 fi
1115 fi
1116 if test $badthreads = no; then
1117 AC_MSG_RESULT(OK)
1118 eval `$vi_cv_path_perl -V:shrpenv`
1119 if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04
1120 shrpenv=""
1121 fi
1122 vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlibexp}'`
1123 AC_SUBST(vi_cv_perllib)
Bram Moolenaard5f62b12014-08-17 17:05:44 +02001124 vi_cv_perl_extutils=unknown_perl_extutils_path
1125 for extutils_rel_path in ExtUtils vendor_perl/ExtUtils; do
1126 xsubpp_path="$vi_cv_perllib/$extutils_rel_path/xsubpp"
1127 if test -f "$xsubpp_path"; then
1128 vi_cv_perl_xsubpp="$xsubpp_path"
1129 fi
1130 done
1131 AC_SUBST(vi_cv_perl_xsubpp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001132 dnl Remove "-fno-something", it breaks using cproto.
Bram Moolenaar280a8682015-06-21 13:41:08 +02001133 dnl Remove "-fdebug-prefix-map", it isn't supported by clang.
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001134 dnl Remove "FORTIFY_SOURCE", it will be defined twice.
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001135 dnl remove -pipe and -Wxxx, it confuses cproto
Bram Moolenaar071d4272004-06-13 20:20:40 +00001136 perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001137 -e 'ccflags;perl_inc;print"\n"' | sed -e 's/-fno[[^ ]]*//' \
1138 -e 's/-fdebug-prefix-map[[^ ]]*//g' \
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001139 -e 's/-pipe //' \
1140 -e 's/-W[[^ ]]*//g' \
1141 -e 's/-D_FORTIFY_SOURCE=.//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001142 dnl Remove "-lc", it breaks on FreeBSD when using "-pthread".
1143 perllibs=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed -e 'ldopts' | \
1144 sed -e '/Warning/d' -e '/Note (probably harmless)/d' \
1145 -e 's/-bE:perl.exp//' -e 's/-lc //'`
1146 dnl Don't add perl lib to $LIBS: if it's not in LD_LIBRARY_PATH
1147 dnl a test in configure may fail because of that.
1148 perlldflags=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed \
1149 -e 'ccdlflags' | sed -e 's/-bE:perl.exp//'`
1150
1151 dnl check that compiling a simple program still works with the flags
1152 dnl added for Perl.
1153 AC_MSG_CHECKING([if compile and link flags for Perl are sane])
1154 cflags_save=$CFLAGS
1155 libs_save=$LIBS
1156 ldflags_save=$LDFLAGS
1157 CFLAGS="$CFLAGS $perlcppflags"
1158 LIBS="$LIBS $perllibs"
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001159 perlldflags=`echo "$perlldflags" | sed -e 's/^ *//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001160 LDFLAGS="$perlldflags $LDFLAGS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001161 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00001162 AC_MSG_RESULT(yes); perl_ok=yes,
1163 AC_MSG_RESULT(no: PERL DISABLED); perl_ok=no)
1164 CFLAGS=$cflags_save
1165 LIBS=$libs_save
1166 LDFLAGS=$ldflags_save
1167 if test $perl_ok = yes; then
1168 if test "X$perlcppflags" != "X"; then
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001169 PERL_CFLAGS=$perlcppflags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001170 fi
1171 if test "X$perlldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001172 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$perlldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001173 LDFLAGS="$perlldflags $LDFLAGS"
1174 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001175 fi
1176 PERL_LIBS=$perllibs
1177 PERL_SRC="auto/if_perl.c if_perlsfio.c"
1178 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o"
1179 PERL_PRO="if_perl.pro if_perlsfio.pro"
1180 AC_DEFINE(FEAT_PERL)
1181 fi
1182 fi
1183 else
1184 AC_MSG_RESULT(>>> too old; need Perl version 5.003_01 or later <<<)
1185 fi
1186 fi
1187
Bram Moolenaard0573012017-10-28 21:11:06 +02001188 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00001189 dnl Mac OS X 10.2 or later
Bram Moolenaar071d4272004-06-13 20:20:40 +00001190 dir=/System/Library/Perl
1191 darwindir=$dir/darwin
1192 if test -d $darwindir; then
1193 PERL=/usr/bin/perl
1194 else
1195 dnl Mac OS X 10.3
1196 dir=/System/Library/Perl/5.8.1
1197 darwindir=$dir/darwin-thread-multi-2level
1198 if test -d $darwindir; then
1199 PERL=/usr/bin/perl
1200 fi
1201 fi
1202 if test -n "$PERL"; then
1203 PERL_DIR="$dir"
1204 PERL_CFLAGS="-DFEAT_PERL -I$darwindir/CORE"
1205 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o $darwindir/auto/DynaLoader/DynaLoader.a"
1206 PERL_LIBS="-L$darwindir/CORE -lperl"
1207 fi
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001208 dnl Perl on Mac OS X 10.5 adds "-arch" flags but these should only
1209 dnl be included if requested by passing --with-mac-arch to
1210 dnl configure, so strip these flags first (if present)
1211 PERL_LIBS=`echo "$PERL_LIBS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
1212 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 +00001213 fi
Bram Moolenaare06c1882010-07-21 22:05:20 +02001214 if test "$enable_perlinterp" = "dynamic"; then
1215 if test "$perl_ok" = "yes" -a "X$libperl" != "X"; then
1216 AC_DEFINE(DYNAMIC_PERL)
1217 PERL_CFLAGS="-DDYNAMIC_PERL_DLL=\\\"$libperl\\\" $PERL_CFLAGS"
1218 fi
1219 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001220
1221 if test "$fail_if_missing" = "yes" -a "$perl_ok" != "yes"; then
1222 AC_MSG_ERROR([could not configure perl])
1223 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001224fi
1225AC_SUBST(shrpenv)
1226AC_SUBST(PERL_SRC)
1227AC_SUBST(PERL_OBJ)
1228AC_SUBST(PERL_PRO)
1229AC_SUBST(PERL_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00001230AC_SUBST(PERL_CFLAGS_EXTRA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001231AC_SUBST(PERL_LIBS)
1232
1233AC_MSG_CHECKING(--enable-pythoninterp argument)
1234AC_ARG_ENABLE(pythoninterp,
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001235 [ --enable-pythoninterp[=OPTS] Include Python interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001236 [enable_pythoninterp="no"])
1237AC_MSG_RESULT($enable_pythoninterp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001238if test "$enable_pythoninterp" = "yes" -o "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00001239 if test "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +01001240 AC_MSG_ERROR([cannot use Python with tiny features])
Bram Moolenaar0b105412014-11-30 13:34:23 +01001241 fi
1242
Bram Moolenaar071d4272004-06-13 20:20:40 +00001243 dnl -- find the python executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001244 AC_MSG_CHECKING(--with-python-command argument)
1245 AC_SUBST(vi_cv_path_python)
1246 AC_ARG_WITH(python-command, [ --with-python-command=NAME name of the Python 2 command (default: python2 or python)],
1247 vi_cv_path_python="$withval"; AC_MSG_RESULT($vi_cv_path_python),
1248 AC_MSG_RESULT(no))
1249
1250 if test "X$vi_cv_path_python" = "X"; then
1251 AC_PATH_PROGS(vi_cv_path_python, python2 python)
1252 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001253 if test "X$vi_cv_path_python" != "X"; then
1254
1255 dnl -- get its version number
1256 AC_CACHE_CHECK(Python version,vi_cv_var_python_version,
1257 [[vi_cv_var_python_version=`
1258 ${vi_cv_path_python} -c 'import sys; print sys.version[:3]'`
1259 ]])
1260
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001261 dnl -- it must be at least version 2.3
1262 AC_MSG_CHECKING(Python is 2.3 or better)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001263 if ${vi_cv_path_python} -c \
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001264 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001265 then
1266 AC_MSG_RESULT(yep)
1267
1268 dnl -- find where python thinks it was installed
1269 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python_pfx,
1270 [ vi_cv_path_python_pfx=`
1271 ${vi_cv_path_python} -c \
1272 "import sys; print sys.prefix"` ])
1273
1274 dnl -- and where it thinks it runs
1275 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python_epfx,
1276 [ vi_cv_path_python_epfx=`
1277 ${vi_cv_path_python} -c \
1278 "import sys; print sys.exec_prefix"` ])
1279
1280 dnl -- python's internal library path
1281
1282 AC_CACHE_VAL(vi_cv_path_pythonpath,
1283 [ vi_cv_path_pythonpath=`
1284 unset PYTHONPATH;
1285 ${vi_cv_path_python} -c \
1286 "import sys, string; print string.join(sys.path,':')"` ])
1287
1288 dnl -- where the Python implementation library archives are
1289
1290 AC_ARG_WITH(python-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001291 [ --with-python-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001292 [ vi_cv_path_python_conf="${withval}"; have_python_config_dir=1 ] )
Bram Moolenaar071d4272004-06-13 20:20:40 +00001293
1294 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python_conf,
1295 [
1296 vi_cv_path_python_conf=
Bram Moolenaarac499e32013-06-02 19:14:17 +02001297 d=`${vi_cv_path_python} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBPL')"`
1298 if test -d "$d" && test -f "$d/config.c"; then
1299 vi_cv_path_python_conf="$d"
1300 else
1301 for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
1302 for subdir in lib64 lib share; do
1303 d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
1304 if test -d "$d" && test -f "$d/config.c"; then
1305 vi_cv_path_python_conf="$d"
1306 fi
1307 done
Bram Moolenaar071d4272004-06-13 20:20:40 +00001308 done
Bram Moolenaarac499e32013-06-02 19:14:17 +02001309 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001310 ])
1311
1312 PYTHON_CONFDIR="${vi_cv_path_python_conf}"
1313
1314 if test "X$PYTHON_CONFDIR" = "X"; then
1315 AC_MSG_RESULT([can't find it!])
1316 else
1317
1318 dnl -- we need to examine Python's config/Makefile too
1319 dnl see what the interpreter is built from
1320 AC_CACHE_VAL(vi_cv_path_python_plibs,
1321 [
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001322 pwd=`pwd`
1323 tmp_mkf="$pwd/config-PyMake$$"
1324 cat -- "${PYTHON_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001325__:
Bram Moolenaar218116c2010-05-20 21:46:00 +02001326 @echo "python_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001327 @echo "python_LIBS='$(LIBS)'"
1328 @echo "python_SYSLIBS='$(SYSLIBS)'"
1329 @echo "python_LINKFORSHARED='$(LINKFORSHARED)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001330 @echo "python_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001331 @echo "python_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001332 @echo "python_PYTHONFRAMEWORK='$(PYTHONFRAMEWORK)'"
1333 @echo "python_PYTHONFRAMEWORKPREFIX='$(PYTHONFRAMEWORKPREFIX)'"
1334 @echo "python_PYTHONFRAMEWORKINSTALLDIR='$(PYTHONFRAMEWORKINSTALLDIR)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001335eof
1336 dnl -- delete the lines from make about Entering/Leaving directory
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001337 eval "`cd ${PYTHON_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1338 rm -f -- "${tmp_mkf}"
Bram Moolenaard0573012017-10-28 21:11:06 +02001339 if test "x$MACOS_X" = "xyes" && test -n "${python_PYTHONFRAMEWORK}" && ${vi_cv_path_python} -c \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001340 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then
1341 vi_cv_path_python_plibs="-framework Python"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001342 if test "x${vi_cv_path_python}" != "x/usr/bin/python" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
1343 vi_cv_path_python_plibs="-F${python_PYTHONFRAMEWORKPREFIX} -framework Python"
1344 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001345 else
Bram Moolenaar9ce42132018-04-11 22:19:36 +02001346 vi_cv_path_python_plibs="-L${PYTHON_CONFDIR} -lpython${vi_cv_var_python_version}"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001347 dnl -- Check if the path contained in python_LINKFORSHARED is
1348 dnl usable for vim build. If not, make and try other
1349 dnl candidates.
Bram Moolenaara161e262015-03-24 15:14:27 +01001350 if test -n "${python_LINKFORSHARED}" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
Bram Moolenaar6c927552015-03-24 12:21:33 +01001351 python_link_symbol=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]].*/\1/'`
1352 python_link_path=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]][[ \t]]*\(.*\)/\2/'`
1353 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1354 dnl -- The path looks relative. Guess the absolute one using
1355 dnl the prefix and try that.
1356 python_link_path="${python_PYTHONFRAMEWORKPREFIX}/${python_link_path}"
1357 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1358 dnl -- A last resort.
1359 python_link_path="${python_PYTHONFRAMEWORKINSTALLDIR}/Versions/${vi_cv_var_python_version}/${python_PYTHONFRAMEWORK}"
1360 dnl -- No check is done. The last word is left to the
1361 dnl "sanity" test on link flags that follows shortly.
1362 fi
1363 python_LINKFORSHARED="${python_link_symbol} ${python_link_path}"
1364 fi
1365 fi
Bram Moolenaar218116c2010-05-20 21:46:00 +02001366 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 +00001367 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1368 vi_cv_path_python_plibs=`echo $vi_cv_path_python_plibs | sed s/-ltermcap//`
1369 fi
1370 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001371 AC_CACHE_CHECK(Python's dll name,vi_cv_dll_name_python,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001372 [
1373 if test "X$python_DLLLIBRARY" != "X"; then
1374 vi_cv_dll_name_python="$python_DLLLIBRARY"
1375 else
1376 vi_cv_dll_name_python="$python_INSTSONAME"
1377 fi
1378 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00001379
1380 PYTHON_LIBS="${vi_cv_path_python_plibs}"
1381 if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001382 PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001383 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001384 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 +00001385 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001386 if test "X$have_python_config_dir" = "X1" -a "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001387 dnl Define PYTHON_HOME if --with-python-config-dir was used
1388 PYTHON_CFLAGS="${PYTHON_CFLAGS} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'"
1389
1390 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001391 PYTHON_SRC="if_python.c"
Bram Moolenaar9bdb9a02012-07-25 16:32:08 +02001392 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001393
1394 dnl On FreeBSD linking with "-pthread" is required to use threads.
1395 dnl _THREAD_SAFE must be used for compiling then.
1396 dnl The "-pthread" is added to $LIBS, so that the following check for
1397 dnl sigaltstack() will look in libc_r (it's there in libc!).
1398 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1399 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1400 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1401 AC_MSG_CHECKING([if -pthread should be used])
1402 threadsafe_flag=
1403 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001404 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001405 if test "$vim_cv_uname_output" != Darwin; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001406 test "$GCC" = yes && threadsafe_flag="-pthread"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001407 if test "$vim_cv_uname_output" = FreeBSD; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001408 threadsafe_flag="-D_THREAD_SAFE"
1409 thread_lib="-pthread"
1410 fi
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001411 if test "$vim_cv_uname_output" = SunOS; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001412 threadsafe_flag="-pthreads"
1413 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001414 fi
1415 libs_save_old=$LIBS
1416 if test -n "$threadsafe_flag"; then
1417 cflags_save=$CFLAGS
1418 CFLAGS="$CFLAGS $threadsafe_flag"
1419 LIBS="$LIBS $thread_lib"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001420 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001421 AC_MSG_RESULT(yes); PYTHON_CFLAGS="$PYTHON_CFLAGS $threadsafe_flag",
Bram Moolenaar071d4272004-06-13 20:20:40 +00001422 AC_MSG_RESULT(no); LIBS=$libs_save_old
1423 )
1424 CFLAGS=$cflags_save
1425 else
1426 AC_MSG_RESULT(no)
1427 fi
1428
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001429 dnl Check that compiling a simple program still works with the flags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001430 dnl added for Python.
1431 AC_MSG_CHECKING([if compile and link flags for Python are sane])
1432 cflags_save=$CFLAGS
1433 libs_save=$LIBS
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001434 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001435 LIBS="$LIBS $PYTHON_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001436 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00001437 AC_MSG_RESULT(yes); python_ok=yes,
1438 AC_MSG_RESULT(no: PYTHON DISABLED); python_ok=no)
1439 CFLAGS=$cflags_save
1440 LIBS=$libs_save
1441 if test $python_ok = yes; then
1442 AC_DEFINE(FEAT_PYTHON)
1443 else
1444 LIBS=$libs_save_old
1445 PYTHON_SRC=
1446 PYTHON_OBJ=
1447 PYTHON_LIBS=
1448 PYTHON_CFLAGS=
1449 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001450 fi
1451 else
1452 AC_MSG_RESULT(too old)
1453 fi
1454 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001455
1456 if test "$fail_if_missing" = "yes" -a "$python_ok" != "yes"; then
1457 AC_MSG_ERROR([could not configure python])
1458 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001459fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001460
Bram Moolenaar071d4272004-06-13 20:20:40 +00001461AC_SUBST(PYTHON_LIBS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001462AC_SUBST(PYTHON_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00001463AC_SUBST(PYTHON_CFLAGS_EXTRA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001464AC_SUBST(PYTHON_SRC)
1465AC_SUBST(PYTHON_OBJ)
1466
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001467
1468AC_MSG_CHECKING(--enable-python3interp argument)
1469AC_ARG_ENABLE(python3interp,
Bram Moolenaar8008b632017-07-18 21:33:20 +02001470 [ --enable-python3interp[=OPTS] Include Python3 interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001471 [enable_python3interp="no"])
1472AC_MSG_RESULT($enable_python3interp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001473if test "$enable_python3interp" = "yes" -o "$enable_python3interp" = "dynamic"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00001474 if test "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +01001475 AC_MSG_ERROR([cannot use Python with tiny features])
Bram Moolenaar0b105412014-11-30 13:34:23 +01001476 fi
1477
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001478 dnl -- find the python3 executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001479 AC_MSG_CHECKING(--with-python3-command argument)
1480 AC_SUBST(vi_cv_path_python3)
1481 AC_ARG_WITH(python3-command, [ --with-python3-command=NAME name of the Python 3 command (default: python3 or python)],
1482 vi_cv_path_python3="$withval"; AC_MSG_RESULT($vi_cv_path_python3),
1483 AC_MSG_RESULT(no))
1484
1485 if test "X$vi_cv_path_python3" = "X"; then
1486 AC_PATH_PROGS(vi_cv_path_python3, python3 python)
1487 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001488 if test "X$vi_cv_path_python3" != "X"; then
1489
1490 dnl -- get its version number
1491 AC_CACHE_CHECK(Python version,vi_cv_var_python3_version,
1492 [[vi_cv_var_python3_version=`
Bram Moolenaar23c01922021-05-21 11:43:58 +02001493 ${vi_cv_path_python3} -c 'import sys; print("{}.{}".format(sys.version_info.major, sys.version_info.minor))'`
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001494 ]])
1495
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001496 dnl -- it must be at least version 3
1497 AC_MSG_CHECKING(Python is 3.0 or better)
1498 if ${vi_cv_path_python3} -c \
1499 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.0)"
1500 then
1501 AC_MSG_RESULT(yep)
Bram Moolenaar456f2bb2011-06-12 21:37:13 +02001502
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001503 dnl -- get abiflags for python 3.2 or higher (PEP 3149)
1504 AC_CACHE_CHECK(Python's abiflags,vi_cv_var_python3_abiflags,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001505 [
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001506 vi_cv_var_python3_abiflags=
1507 if ${vi_cv_path_python3} -c \
1508 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)"
1509 then
Bram Moolenaare5303952022-06-19 17:05:47 +01001510 vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001511 "import sys; print(sys.abiflags)"`
1512 fi ])
Bram Moolenaare5303952022-06-19 17:05:47 +01001513
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001514 dnl -- find where python3 thinks it was installed
1515 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx,
1516 [ vi_cv_path_python3_pfx=`
1517 ${vi_cv_path_python3} -c \
1518 "import sys; print(sys.prefix)"` ])
Bram Moolenaare5303952022-06-19 17:05:47 +01001519
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001520 dnl -- and where it thinks it runs
1521 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx,
1522 [ vi_cv_path_python3_epfx=`
1523 ${vi_cv_path_python3} -c \
1524 "import sys; print(sys.exec_prefix)"` ])
Bram Moolenaare5303952022-06-19 17:05:47 +01001525
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001526 dnl -- python3's internal library path
Bram Moolenaare5303952022-06-19 17:05:47 +01001527
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001528 AC_CACHE_VAL(vi_cv_path_python3path,
1529 [ vi_cv_path_python3path=`
1530 unset PYTHONPATH;
1531 ${vi_cv_path_python3} -c \
1532 "import sys, string; print(':'.join(sys.path))"` ])
Bram Moolenaare5303952022-06-19 17:05:47 +01001533
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001534 dnl -- where the Python implementation library archives are
Bram Moolenaare5303952022-06-19 17:05:47 +01001535
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001536 AC_ARG_WITH(python3-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001537 [ --with-python3-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001538 [ vi_cv_path_python3_conf="${withval}"; have_python3_config_dir=1 ] )
Bram Moolenaare5303952022-06-19 17:05:47 +01001539
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001540 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf,
1541 [
1542 vi_cv_path_python3_conf=
Bram Moolenaarfee496d2013-07-12 20:07:24 +02001543 config_dir="config-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Zdenek Dohnal31e299c2021-06-10 18:50:55 +02001544 d=`${vi_cv_path_python3} -c "import sysconfig; print(sysconfig.get_config_var('LIBPL'))" 2> /dev/null`
1545 if test "x$d" = "x"; then
1546 d=`${vi_cv_path_python3} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBPL'))"`
1547 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001548 if test -d "$d" && test -f "$d/config.c"; then
1549 vi_cv_path_python3_conf="$d"
1550 else
1551 for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do
1552 for subdir in lib64 lib share; do
1553 d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}"
1554 if test -d "$d" && test -f "$d/config.c"; then
1555 vi_cv_path_python3_conf="$d"
1556 fi
1557 done
1558 done
1559 fi
1560 ])
Bram Moolenaare5303952022-06-19 17:05:47 +01001561
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001562 PYTHON3_CONFDIR="${vi_cv_path_python3_conf}"
Bram Moolenaare5303952022-06-19 17:05:47 +01001563
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001564 if test "X$PYTHON3_CONFDIR" = "X"; then
1565 AC_MSG_RESULT([can't find it!])
1566 else
Bram Moolenaare5303952022-06-19 17:05:47 +01001567
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001568 dnl -- we need to examine Python's config/Makefile too
1569 dnl see what the interpreter is built from
1570 AC_CACHE_VAL(vi_cv_path_python3_plibs,
1571 [
1572 pwd=`pwd`
1573 tmp_mkf="$pwd/config-PyMake$$"
1574 cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001575__:
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001576 @echo "python3_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001577 @echo "python3_LIBS='$(LIBS)'"
1578 @echo "python3_SYSLIBS='$(SYSLIBS)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001579 @echo "python3_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001580 @echo "python3_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001581eof
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001582 dnl -- delete the lines from make about Entering/Leaving directory
1583 eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1584 rm -f -- "${tmp_mkf}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001585 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 +02001586 vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}"
1587 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1588 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//`
1589 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//`
1590 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001591 AC_CACHE_CHECK(Python3's dll name,vi_cv_dll_name_python3,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001592 [
1593 if test "X$python3_DLLLIBRARY" != "X"; then
1594 vi_cv_dll_name_python3="$python3_DLLLIBRARY"
1595 else
1596 vi_cv_dll_name_python3="$python3_INSTSONAME"
1597 fi
1598 ])
1599
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001600 PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
1601 if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001602 PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001603 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001604 PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -I${vi_cv_path_python3_epfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001605 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001606 if test "X$have_python3_config_dir" = "X1" -a "$enable_python3interp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001607 dnl Define PYTHON3_HOME if --with-python-config-dir was used
1608 PYTHON3_CFLAGS="${PYTHON3_CFLAGS} -DPYTHON3_HOME='L\"${vi_cv_path_python3_pfx}\"'"
1609 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001610 PYTHON3_SRC="if_python3.c"
1611 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaare5303952022-06-19 17:05:47 +01001612
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001613 dnl On FreeBSD linking with "-pthread" is required to use threads.
1614 dnl _THREAD_SAFE must be used for compiling then.
1615 dnl The "-pthread" is added to $LIBS, so that the following check for
1616 dnl sigaltstack() will look in libc_r (it's there in libc!).
1617 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1618 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1619 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1620 AC_MSG_CHECKING([if -pthread should be used])
1621 threadsafe_flag=
1622 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001623 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001624 if test "$vim_cv_uname_output" != Darwin; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001625 test "$GCC" = yes && threadsafe_flag="-pthread"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001626 if test "$vim_cv_uname_output" = FreeBSD; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001627 threadsafe_flag="-D_THREAD_SAFE"
1628 thread_lib="-pthread"
1629 fi
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001630 if test "$vim_cv_uname_output" = SunOS; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001631 threadsafe_flag="-pthreads"
1632 fi
1633 fi
1634 libs_save_old=$LIBS
1635 if test -n "$threadsafe_flag"; then
1636 cflags_save=$CFLAGS
1637 CFLAGS="$CFLAGS $threadsafe_flag"
1638 LIBS="$LIBS $thread_lib"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001639 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001640 AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag",
1641 AC_MSG_RESULT(no); LIBS=$libs_save_old
1642 )
1643 CFLAGS=$cflags_save
1644 else
1645 AC_MSG_RESULT(no)
1646 fi
Bram Moolenaare5303952022-06-19 17:05:47 +01001647
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001648 dnl check that compiling a simple program still works with the flags
1649 dnl added for Python.
1650 AC_MSG_CHECKING([if compile and link flags for Python 3 are sane])
1651 cflags_save=$CFLAGS
1652 libs_save=$LIBS
1653 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1654 LIBS="$LIBS $PYTHON3_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001655 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001656 AC_MSG_RESULT(yes); python3_ok=yes,
1657 AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no)
1658 CFLAGS=$cflags_save
1659 LIBS=$libs_save
1660 if test "$python3_ok" = yes; then
1661 AC_DEFINE(FEAT_PYTHON3)
1662 else
1663 LIBS=$libs_save_old
1664 PYTHON3_SRC=
1665 PYTHON3_OBJ=
1666 PYTHON3_LIBS=
1667 PYTHON3_CFLAGS=
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001668 fi
1669 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001670 else
1671 AC_MSG_RESULT(too old)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001672 fi
1673 fi
Bram Moolenaar1612b1a2013-06-14 21:22:39 +02001674 if test "$fail_if_missing" = "yes" -a "$python3_ok" != "yes"; then
1675 AC_MSG_ERROR([could not configure python3])
1676 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001677fi
1678
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001679AC_SUBST(PYTHON3_LIBS)
1680AC_SUBST(PYTHON3_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00001681AC_SUBST(PYTHON3_CFLAGS_EXTRA)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001682AC_SUBST(PYTHON3_SRC)
1683AC_SUBST(PYTHON3_OBJ)
1684
1685dnl if python2.x and python3.x are enabled one can only link in code
Bram Moolenaare5303952022-06-19 17:05:47 +01001686dnl with dlopen(), dlsym(), dlclose()
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001687if test "$python_ok" = yes && test "$python3_ok" = yes; then
1688 AC_DEFINE(DYNAMIC_PYTHON)
1689 AC_DEFINE(DYNAMIC_PYTHON3)
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001690 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001691 cflags_save=$CFLAGS
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001692 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001693 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001694 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001695 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001696 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001697 #include <dlfcn.h>
1698 /* If this program fails, then RTLD_GLOBAL is needed.
1699 * RTLD_GLOBAL will be used and then it is not possible to
1700 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001701 * Only the first python version used will be switched on.
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001702 */
1703
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01001704 static int no_rtl_global_needed_for(char *python_instsoname, char *prefix)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001705 {
1706 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001707 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001708 if (pylib != 0)
1709 {
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001710 void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome");
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001711 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1712 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1713 void (*final)(void) = dlsym(pylib, "Py_Finalize");
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001714 (*pfx)(prefix);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001715 (*init)();
1716 needed = (*simple)("import termios") == -1;
1717 (*final)();
1718 dlclose(pylib);
1719 }
1720 return !needed;
1721 }
1722
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01001723 int main()
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001724 {
1725 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001726 if (no_rtl_global_needed_for("${vi_cv_dll_name_python}", "${vi_cv_path_python_pfx}"))
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001727 not_needed = 1;
1728 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001729 }])],
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001730 [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001731
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001732 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001733 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001734
1735 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python3)
1736 cflags_save=$CFLAGS
1737 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001738 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001739 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001740 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001741 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001742 #include <dlfcn.h>
1743 #include <wchar.h>
1744 /* If this program fails, then RTLD_GLOBAL is needed.
1745 * RTLD_GLOBAL will be used and then it is not possible to
1746 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001747 * Only the first python version used will be switched on.
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001748 */
1749
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01001750 static int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix)
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001751 {
1752 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001753 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001754 if (pylib != 0)
1755 {
1756 void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome");
1757 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1758 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1759 void (*final)(void) = dlsym(pylib, "Py_Finalize");
1760 (*pfx)(prefix);
1761 (*init)();
1762 needed = (*simple)("import termios") == -1;
1763 (*final)();
1764 dlclose(pylib);
1765 }
1766 return !needed;
1767 }
1768
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01001769 int main()
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001770 {
1771 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001772 if (no_rtl_global_needed_for("${vi_cv_dll_name_python3}", L"${vi_cv_path_python3_pfx}"))
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001773 not_needed = 1;
1774 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001775 }])],
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001776 [AC_MSG_RESULT(yes);AC_DEFINE(PY3_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
1777
1778 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001779 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001780
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001781 PYTHON_SRC="if_python.c"
1782 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001783 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001784 PYTHON_LIBS=
1785 PYTHON3_SRC="if_python3.c"
1786 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001787 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001788 PYTHON3_LIBS=
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001789elif test "$python_ok" = yes && test "$enable_pythoninterp" = "dynamic"; then
1790 AC_DEFINE(DYNAMIC_PYTHON)
1791 PYTHON_SRC="if_python.c"
1792 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001793 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001794 PYTHON_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001795elif test "$python_ok" = yes; then
1796 dnl Check that adding -fPIE works. It may be needed when using a static
1797 dnl Python library.
1798 AC_MSG_CHECKING([if -fPIE can be added for Python])
1799 cflags_save=$CFLAGS
1800 libs_save=$LIBS
1801 CFLAGS="$CFLAGS $PYTHON_CFLAGS -fPIE"
1802 LIBS="$LIBS $PYTHON_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001803 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaare741f272013-07-09 21:57:52 +02001804 AC_MSG_RESULT(yes); fpie_ok=yes,
1805 AC_MSG_RESULT(no); fpie_ok=no)
1806 CFLAGS=$cflags_save
1807 LIBS=$libs_save
1808 if test $fpie_ok = yes; then
1809 PYTHON_CFLAGS="$PYTHON_CFLAGS -fPIE"
1810 fi
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001811elif test "$python3_ok" = yes && test "$enable_python3interp" = "dynamic"; then
1812 AC_DEFINE(DYNAMIC_PYTHON3)
1813 PYTHON3_SRC="if_python3.c"
1814 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001815 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001816 PYTHON3_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001817elif test "$python3_ok" = yes; then
1818 dnl Check that adding -fPIE works. It may be needed when using a static
1819 dnl Python library.
1820 AC_MSG_CHECKING([if -fPIE can be added for Python3])
1821 cflags_save=$CFLAGS
1822 libs_save=$LIBS
1823 CFLAGS="$CFLAGS $PYTHON3_CFLAGS -fPIE"
1824 LIBS="$LIBS $PYTHON3_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001825 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaare741f272013-07-09 21:57:52 +02001826 AC_MSG_RESULT(yes); fpie_ok=yes,
1827 AC_MSG_RESULT(no); fpie_ok=no)
1828 CFLAGS=$cflags_save
1829 LIBS=$libs_save
1830 if test $fpie_ok = yes; then
1831 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -fPIE"
1832 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001833fi
1834
Bram Moolenaar071d4272004-06-13 20:20:40 +00001835AC_MSG_CHECKING(--enable-tclinterp argument)
1836AC_ARG_ENABLE(tclinterp,
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001837 [ --enable-tclinterp[=OPTS] Include Tcl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001838 [enable_tclinterp="no"])
1839AC_MSG_RESULT($enable_tclinterp)
1840
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001841if test "$enable_tclinterp" = "yes" -o "$enable_tclinterp" = "dynamic"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001842
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001843 dnl on FreeBSD tclsh is a silly script, look for tclsh8.[5420]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001844 AC_MSG_CHECKING(--with-tclsh argument)
1845 AC_ARG_WITH(tclsh, [ --with-tclsh=PATH which tclsh to use (default: tclsh8.0)],
1846 tclsh_name="$withval"; AC_MSG_RESULT($tclsh_name),
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001847 tclsh_name="tclsh8.5"; AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00001848 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1849 AC_SUBST(vi_cv_path_tcl)
1850
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001851 dnl when no specific version specified, also try 8.4, 8.2 and 8.0
1852 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.5"; then
1853 tclsh_name="tclsh8.4"
1854 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1855 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001856 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.4"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001857 tclsh_name="tclsh8.2"
1858 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1859 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001860 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.2"; then
1861 tclsh_name="tclsh8.0"
1862 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1863 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001864 dnl still didn't find it, try without version number
1865 if test "X$vi_cv_path_tcl" = "X"; then
1866 tclsh_name="tclsh"
1867 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1868 fi
1869 if test "X$vi_cv_path_tcl" != "X"; then
1870 AC_MSG_CHECKING(Tcl version)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001871 if echo 'exit [[expr [info tclversion] < 8.0]]' | "$vi_cv_path_tcl" - ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001872 tclver=`echo 'puts [[info tclversion]]' | $vi_cv_path_tcl -`
1873 AC_MSG_RESULT($tclver - OK);
1874 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 +01001875 tcldll=`echo 'puts libtcl[[info tclversion]][[info sharedlibextension]]' | $vi_cv_path_tcl -`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001876
1877 AC_MSG_CHECKING(for location of Tcl include)
Bram Moolenaard0573012017-10-28 21:11:06 +02001878 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001879 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 +00001880 else
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001881 dnl For all macOS, use the value from TCL in case use of, say, homebrew
Bram Moolenaar071d4272004-06-13 20:20:40 +00001882 dnl For Mac OS X 10.3, use the OS-provided framework location
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001883 dnl For Mac OS X 10.14, the OS-provided framework location doesn't contain the headers, so also check the Xcode SDK
1884 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 +00001885 fi
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001886 TCL_INC=
Bram Moolenaar071d4272004-06-13 20:20:40 +00001887 for try in $tclinc; do
1888 if test -f "$try/tcl.h"; then
1889 AC_MSG_RESULT($try/tcl.h)
1890 TCL_INC=$try
1891 break
1892 fi
1893 done
1894 if test -z "$TCL_INC"; then
1895 AC_MSG_RESULT(<not found>)
1896 SKIP_TCL=YES
1897 fi
1898 if test -z "$SKIP_TCL"; then
1899 AC_MSG_CHECKING(for location of tclConfig.sh script)
Bram Moolenaard0573012017-10-28 21:11:06 +02001900 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001901 tclcnf=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001902 tclcnf="$tclcnf `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001903 else
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001904 dnl For all macOS, use the value from TCL in case use of, say, homebrew
Bram Moolenaar071d4272004-06-13 20:20:40 +00001905 dnl For Mac OS X 10.3, use the OS-provided framework location
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001906 dnl For Mac OS X 10.14, the OS-provided framework location doesn't contain the headers, so also check the Xcode SDK
1907 tclcnf=`echo $tclinc | sed s/include/lib/g`
1908 tclcnf="$tclcnf /System/Library/Frameworks/Tcl.framework `xcrun --show-sdk-path`/System/Library/Frameworks/Tcl.framework"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001909 fi
1910 for try in $tclcnf; do
Bram Moolenaar49222be2015-12-11 18:11:30 +01001911 if test -f "$try/tclConfig.sh"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001912 AC_MSG_RESULT($try/tclConfig.sh)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001913 . "$try/tclConfig.sh"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001914 dnl use eval, because tcl 8.2 includes ${TCL_DBGX}
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001915 if test "$enable_tclinterp" = "dynamic"; then
1916 TCL_LIBS=`eval echo "$TCL_STUB_LIB_SPEC $TCL_LIBS"`
1917 else
1918 TCL_LIBS=`eval echo "$TCL_LIB_SPEC $TCL_LIBS"`
1919 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001920 dnl Use $TCL_DEFS for -D_THREAD_SAFE et al. But only use the
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001921 dnl "-D_ABC" items. Watch out for -DFOO=long\ long.
Bram Moolenaar4394bff2008-07-24 11:21:31 +00001922 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 +00001923 break
1924 fi
1925 done
1926 if test -z "$TCL_LIBS"; then
1927 AC_MSG_RESULT(<not found>)
1928 AC_MSG_CHECKING(for Tcl library by myself)
1929 tcllib=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001930 tcllib="$tcllib `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001931 for ext in .so .a ; do
1932 for ver in "" $tclver ; do
1933 for try in $tcllib ; do
1934 trylib=tcl$ver$ext
Bram Moolenaar49222be2015-12-11 18:11:30 +01001935 if test -f "$try/lib$trylib" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001936 AC_MSG_RESULT($try/lib$trylib)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001937 TCL_LIBS="-L\"$try\" -ltcl$ver -ldl -lm"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001938 if test "$vim_cv_uname_output" = SunOS &&
1939 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001940 TCL_LIBS="$TCL_LIBS -R $try"
1941 fi
1942 break 3
1943 fi
1944 done
1945 done
1946 done
1947 if test -z "$TCL_LIBS"; then
1948 AC_MSG_RESULT(<not found>)
1949 SKIP_TCL=YES
1950 fi
1951 fi
1952 if test -z "$SKIP_TCL"; then
1953 AC_DEFINE(FEAT_TCL)
1954 TCL_SRC=if_tcl.c
1955 TCL_OBJ=objects/if_tcl.o
1956 TCL_PRO=if_tcl.pro
1957 TCL_CFLAGS="-I$TCL_INC $TCL_DEFS"
1958 fi
1959 fi
1960 else
1961 AC_MSG_RESULT(too old; need Tcl version 8.0 or later)
1962 fi
1963 fi
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001964 if test "$enable_tclinterp" = "dynamic"; then
1965 if test "X$TCL_SRC" != "X" -a "X$tcldll" != "X"; then
1966 AC_DEFINE(DYNAMIC_TCL)
1967 TCL_CFLAGS="-DDYNAMIC_TCL_DLL=\\\"$tcldll\\\" -DDYNAMIC_TCL_VER=\\\"$tclver\\\" $TCL_CFLAGS"
1968 fi
1969 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001970 if test "$fail_if_missing" = "yes" -a -z "$TCL_SRC"; then
1971 AC_MSG_ERROR([could not configure Tcl])
1972 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001973fi
1974AC_SUBST(TCL_SRC)
1975AC_SUBST(TCL_OBJ)
1976AC_SUBST(TCL_PRO)
1977AC_SUBST(TCL_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00001978AC_SUBST(TCL_CFLAGS_EXTRA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001979AC_SUBST(TCL_LIBS)
1980
1981AC_MSG_CHECKING(--enable-rubyinterp argument)
1982AC_ARG_ENABLE(rubyinterp,
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001983 [ --enable-rubyinterp[=OPTS] Include Ruby interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001984 [enable_rubyinterp="no"])
1985AC_MSG_RESULT($enable_rubyinterp)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001986if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00001987 if test "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +01001988 AC_MSG_ERROR([cannot use Ruby with tiny features])
Bram Moolenaar0b105412014-11-30 13:34:23 +01001989 fi
1990
Bram Moolenaar165641d2010-02-17 16:23:09 +01001991 AC_MSG_CHECKING(--with-ruby-command argument)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001992 AC_SUBST(vi_cv_path_ruby)
Bram Moolenaar948733a2011-05-05 18:10:16 +02001993 AC_ARG_WITH(ruby-command, [ --with-ruby-command=RUBY name of the Ruby command (default: ruby)],
1994 RUBY_CMD="$withval"; vi_cv_path_ruby="$withval"; AC_MSG_RESULT($RUBY_CMD),
1995 RUBY_CMD="ruby"; AC_MSG_RESULT(defaulting to $RUBY_CMD))
Bram Moolenaar165641d2010-02-17 16:23:09 +01001996 AC_PATH_PROG(vi_cv_path_ruby, $RUBY_CMD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001997 if test "X$vi_cv_path_ruby" != "X"; then
1998 AC_MSG_CHECKING(Ruby version)
K.Takata236ccbf2022-09-22 16:12:06 +01001999 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 +00002000 AC_MSG_RESULT(OK)
Bram Moolenaar81398892012-10-03 21:09:35 +02002001 AC_MSG_CHECKING(Ruby rbconfig)
2002 ruby_rbconfig="RbConfig"
2003 if ! $vi_cv_path_ruby -r rbconfig -e 'RbConfig' >/dev/null 2>/dev/null; then
2004 ruby_rbconfig="Config"
2005 fi
2006 AC_MSG_RESULT($ruby_rbconfig)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002007 AC_MSG_CHECKING(Ruby header files)
Bram Moolenaar81398892012-10-03 21:09:35 +02002008 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 +00002009 if test "X$rubyhdrdir" != "X"; then
2010 AC_MSG_RESULT($rubyhdrdir)
2011 RUBY_CFLAGS="-I$rubyhdrdir"
Bram Moolenaara6fd37b2014-03-27 17:19:09 +01002012 rubyarchdir=`$vi_cv_path_ruby -r rbconfig -e "print ($ruby_rbconfig::CONFIG.has_key? 'rubyarchhdrdir') ? $ruby_rbconfig::CONFIG[['rubyarchhdrdir']] : '$rubyhdrdir/'+$ruby_rbconfig::CONFIG[['arch']]"`
2013 if test -d "$rubyarchdir"; then
2014 RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyarchdir"
Bram Moolenaar165641d2010-02-17 16:23:09 +01002015 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02002016 rubyversion=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['ruby_version']].gsub(/\./, '')[[0,2]]"`
Bram Moolenaar026a4452013-08-07 15:22:23 +02002017 if test "X$rubyversion" = "X"; then
K.Takata236ccbf2022-09-22 16:12:06 +01002018 rubyversion=`$vi_cv_path_ruby -e "print RUBY_VERSION.gsub(/\./, '')[[0,2]]"`
Bram Moolenaar026a4452013-08-07 15:22:23 +02002019 fi
Bram Moolenaar165641d2010-02-17 16:23:09 +01002020 RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
Bram Moolenaar81398892012-10-03 21:09:35 +02002021 rubylibs=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LIBS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002022 if test "X$rubylibs" != "X"; then
2023 RUBY_LIBS="$rubylibs"
2024 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02002025 librubyarg=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBYARG']])"`
2026 librubya=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBY_A']])"`
Bram Moolenaarac499e32013-06-02 19:14:17 +02002027 rubylibdir=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['libdir']])"`
Bram Moolenaard5a986f2020-12-06 21:11:31 +01002028 if test -f "$rubylibdir/$librubya" || expr "$librubyarg" : "-lruby"; then
Bram Moolenaarac499e32013-06-02 19:14:17 +02002029 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
2030 elif test "$librubyarg" = "libruby.a"; then
2031 dnl required on Mac OS 10.3 where libruby.a doesn't exist
2032 librubyarg="-lruby"
2033 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002034 fi
2035
2036 if test "X$librubyarg" != "X"; then
2037 RUBY_LIBS="$librubyarg $RUBY_LIBS"
2038 fi
Zdenek Dohnal1d822af2022-11-23 12:06:08 +00002039
2040 dnl Here the Ruby LDFLAGS used to be added to LDFLAGS, but that turns
2041 dnl out to cause trouble and was removed.
2042
Bram Moolenaar071d4272004-06-13 20:20:40 +00002043 RUBY_SRC="if_ruby.c"
2044 RUBY_OBJ="objects/if_ruby.o"
2045 RUBY_PRO="if_ruby.pro"
2046 AC_DEFINE(FEAT_RUBY)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002047 if test "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar92021622017-10-12 12:33:43 +02002048 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_ALIASES']].split[[0]]"`
Bram Moolenaar87ea64c2018-08-04 15:13:34 +02002049 if test -z "$libruby_soname"; then
2050 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_SO']]"`
2051 fi
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002052 AC_DEFINE(DYNAMIC_RUBY)
Bram Moolenaar41a41412020-01-07 21:32:19 +01002053 RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby_soname\\\" $RUBY_CFLAGS"
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002054 RUBY_LIBS=
2055 fi
Bram Moolenaar864a28b2020-12-28 21:36:56 +01002056 if test "X$CLANG_VERSION" != "X" -a "$rubyversion" -ge 30; then
2057 RUBY_CFLAGS="$RUBY_CFLAGS -fdeclspec"
2058 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002059 else
Bram Moolenaar165641d2010-02-17 16:23:09 +01002060 AC_MSG_RESULT(not found; disabling Ruby)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002061 fi
2062 else
K.Takata236ccbf2022-09-22 16:12:06 +01002063 AC_MSG_RESULT(too old; need Ruby version 1.9.1 or later)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002064 fi
2065 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01002066
2067 if test "$fail_if_missing" = "yes" -a -z "$RUBY_OBJ"; then
2068 AC_MSG_ERROR([could not configure Ruby])
2069 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002070fi
2071AC_SUBST(RUBY_SRC)
2072AC_SUBST(RUBY_OBJ)
2073AC_SUBST(RUBY_PRO)
2074AC_SUBST(RUBY_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00002075AC_SUBST(RUBY_CFLAGS_EXTRA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002076AC_SUBST(RUBY_LIBS)
2077
2078AC_MSG_CHECKING(--enable-cscope argument)
2079AC_ARG_ENABLE(cscope,
2080 [ --enable-cscope Include cscope interface.], ,
2081 [enable_cscope="no"])
2082AC_MSG_RESULT($enable_cscope)
2083if test "$enable_cscope" = "yes"; then
2084 AC_DEFINE(FEAT_CSCOPE)
2085fi
2086
Bram Moolenaar071d4272004-06-13 20:20:40 +00002087AC_MSG_CHECKING(--disable-netbeans argument)
2088AC_ARG_ENABLE(netbeans,
2089 [ --disable-netbeans Disable NetBeans integration support.],
2090 , [enable_netbeans="yes"])
2091if test "$enable_netbeans" = "yes"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00002092 if test "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +01002093 AC_MSG_RESULT([cannot use NetBeans with tiny features])
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002094 enable_netbeans="no"
2095 else
2096 AC_MSG_RESULT(no)
2097 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002098else
2099 AC_MSG_RESULT(yes)
2100fi
2101
2102AC_MSG_CHECKING(--disable-channel argument)
2103AC_ARG_ENABLE(channel,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002104 [ --disable-channel Disable process communication support.],
Bram Moolenaare0874f82016-01-24 20:36:41 +01002105 , [enable_channel="yes"])
2106if test "$enable_channel" = "yes"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00002107 if test "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +01002108 AC_MSG_RESULT([cannot use channels with tiny features])
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002109 enable_channel="no"
2110 else
2111 AC_MSG_RESULT(no)
2112 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002113else
2114 if test "$enable_netbeans" = "yes"; then
Bram Moolenaar16435482016-01-24 21:31:54 +01002115 AC_MSG_RESULT([yes, netbeans also disabled])
Bram Moolenaare0874f82016-01-24 20:36:41 +01002116 enable_netbeans="no"
2117 else
2118 AC_MSG_RESULT(yes)
2119 fi
2120fi
2121
Bram Moolenaar16435482016-01-24 21:31:54 +01002122if test "$enable_channel" = "yes"; then
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002123 dnl On Solaris we need the socket library, or on Haiku the network library.
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002124 if test "x$HAIKU" = "xyes"; then
2125 AC_CHECK_LIB(network, socket)
2126 else
2127 AC_CHECK_LIB(socket, socket)
2128 fi
2129
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002130 AC_CACHE_CHECK([whether compiling with IPv6 networking is possible], [vim_cv_ipv6_networking],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002131 [AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002132#include <stdio.h>
2133#include <stdlib.h>
2134#include <stdarg.h>
2135#include <fcntl.h>
2136#include <netdb.h>
2137#include <netinet/in.h>
2138#include <errno.h>
2139#include <sys/types.h>
2140#include <sys/socket.h>
2141 /* Check bitfields */
2142 struct nbbuf {
2143 unsigned int initDone:1;
2144 unsigned short signmaplen;
2145 };
2146 ], [
2147 /* Check creating a socket. */
2148 struct sockaddr_in server;
2149 struct addrinfo *res;
2150 (void)socket(AF_INET, SOCK_STREAM, 0);
2151 (void)htons(100);
2152 (void)getaddrinfo("microsoft.com", NULL, NULL, &res);
2153 if (errno == ECONNREFUSED)
2154 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
2155 (void)freeaddrinfo(res);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002156 ])],
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002157 [vim_cv_ipv6_networking="yes"],
2158 [vim_cv_ipv6_networking="no"])])
2159
2160 if test "x$vim_cv_ipv6_networking" = "xyes"; then
2161 AC_DEFINE(FEAT_IPV6)
Bram Moolenaarb6fb0512020-04-18 18:24:18 +02002162 AC_CHECK_FUNCS(inet_ntop)
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002163 else
2164 dnl On Solaris we need the nsl library.
2165 AC_CHECK_LIB(nsl, gethostbyname)
2166 AC_CACHE_CHECK([whether compiling with IPv4 networking is possible], [vim_cv_ipv4_networking],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002167 [AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00002168#include <stdio.h>
2169#include <stdlib.h>
2170#include <stdarg.h>
2171#include <fcntl.h>
2172#include <netdb.h>
2173#include <netinet/in.h>
2174#include <errno.h>
2175#include <sys/types.h>
2176#include <sys/socket.h>
2177 /* Check bitfields */
2178 struct nbbuf {
2179 unsigned int initDone:1;
Bram Moolenaar63de19e2016-12-09 20:11:26 +01002180 unsigned short signmaplen;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002181 };
2182 ], [
2183 /* Check creating a socket. */
2184 struct sockaddr_in server;
2185 (void)socket(AF_INET, SOCK_STREAM, 0);
2186 (void)htons(100);
2187 (void)gethostbyname("microsoft.com");
2188 if (errno == ECONNREFUSED)
2189 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002190 ])],
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002191 [vim_cv_ipv4_networking="yes"],
2192 [vim_cv_ipv4_networking="no"; enable_netbeans="no"; enable_channel="no"])])
2193 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002194fi
2195if test "$enable_netbeans" = "yes"; then
2196 AC_DEFINE(FEAT_NETBEANS_INTG)
2197 NETBEANS_SRC="netbeans.c"
2198 AC_SUBST(NETBEANS_SRC)
2199 NETBEANS_OBJ="objects/netbeans.o"
2200 AC_SUBST(NETBEANS_OBJ)
2201fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002202if test "$enable_channel" = "yes"; then
Bram Moolenaar509ce2a2016-03-11 22:52:15 +01002203 AC_DEFINE(FEAT_JOB_CHANNEL)
Bram Moolenaar8b5866d2020-09-05 15:48:51 +02002204 CHANNEL_SRC="job.c channel.c"
Bram Moolenaare0874f82016-01-24 20:36:41 +01002205 AC_SUBST(CHANNEL_SRC)
Bram Moolenaar8b5866d2020-09-05 15:48:51 +02002206 CHANNEL_OBJ="objects/job.o objects/channel.o"
Bram Moolenaare0874f82016-01-24 20:36:41 +01002207 AC_SUBST(CHANNEL_OBJ)
2208fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002209
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002210AC_MSG_CHECKING(--enable-terminal argument)
2211AC_ARG_ENABLE(terminal,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002212 [ --enable-terminal Enable terminal emulation support.],
Bram Moolenaaref839562017-10-28 20:28:23 +02002213 , [enable_terminal="auto"])
Bram Moolenaar595a4022017-09-03 19:15:57 +02002214if test "$enable_terminal" = "yes" || test "$enable_terminal" = "auto" -a "x$features" = "xhuge" ; then
Bram Moolenaar12471262022-01-18 11:11:25 +00002215 if test "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +01002216 AC_MSG_RESULT([cannot use terminal emulator with tiny features])
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002217 enable_terminal="no"
2218 else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002219 if test "$enable_terminal" = "auto"; then
2220 enable_terminal="yes"
2221 AC_MSG_RESULT(defaulting to yes)
2222 else
2223 AC_MSG_RESULT(yes)
2224 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002225 fi
2226else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002227 if test "$enable_terminal" = "auto"; then
2228 enable_terminal="no"
2229 AC_MSG_RESULT(defaulting to no)
2230 else
2231 AC_MSG_RESULT(no)
2232 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002233fi
Bram Moolenaar8b423282017-12-16 14:37:06 +01002234if test "$enable_terminal" = "yes" -a "$enable_channel" = "yes"; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002235 AC_DEFINE(FEAT_TERMINAL)
Bram Moolenaar93268052019-10-10 13:22:54 +02002236 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 +02002237 AC_SUBST(TERM_SRC)
Bram Moolenaar93268052019-10-10 13:22:54 +02002238 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 +02002239 AC_SUBST(TERM_OBJ)
Bram Moolenaar823edd12019-10-23 22:35:36 +02002240 TERM_TEST="test_libvterm"
2241 AC_SUBST(TERM_TEST)
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002242fi
2243
Bram Moolenaare42a6d22017-11-12 19:21:51 +01002244AC_MSG_CHECKING(--enable-autoservername argument)
2245AC_ARG_ENABLE(autoservername,
2246 [ --enable-autoservername Automatically define servername at vim startup.], ,
2247 [enable_autoservername="no"])
2248AC_MSG_RESULT($enable_autoservername)
2249if test "$enable_autoservername" = "yes"; then
2250 AC_DEFINE(FEAT_AUTOSERVERNAME)
2251fi
2252
Bram Moolenaar071d4272004-06-13 20:20:40 +00002253AC_MSG_CHECKING(--enable-multibyte argument)
2254AC_ARG_ENABLE(multibyte,
2255 [ --enable-multibyte Include multibyte editing support.], ,
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01002256 [enable_multibyte="yes"])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002257AC_MSG_RESULT($enable_multibyte)
Bram Moolenaar30276f22019-01-24 17:59:39 +01002258if test "$enable_multibyte" != "yes"; then
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01002259 AC_MSG_ERROR([The multi-byte feature can no longer be disabled. If you have
2260 a problem with this, discuss on the Vim mailing list.])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002261fi
2262
Martin Tournoij25f3a142022-10-08 19:26:41 +01002263dnl Right-to-Left language support for Vim will be included with huge features,
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002264dnl unless ENABLE_RIGHTLEFT is undefined.
2265AC_MSG_CHECKING(--disable-rightleft argument)
2266AC_ARG_ENABLE(rightleft,
2267 [ --disable-rightleft Do not include Right-to-Left language support.],
2268 , [enable_rightleft="yes"])
2269if test "$enable_rightleft" = "yes"; then
2270 AC_MSG_RESULT(no)
2271else
2272 AC_MSG_RESULT(yes)
2273 AC_DEFINE(DISABLE_RIGHTLEFT)
2274fi
2275
Martin Tournoij25f3a142022-10-08 19:26:41 +01002276dnl Arabic language support for Vim will be included with huge features,
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002277dnl unless ENABLE_ARABIC is undefined.
2278AC_MSG_CHECKING(--disable-arabic argument)
2279AC_ARG_ENABLE(arabic,
2280 [ --disable-arabic Do not include Arabic language support.],
2281 , [enable_arabic="yes"])
2282if test "$enable_arabic" = "yes"; then
2283 AC_MSG_RESULT(no)
2284else
2285 AC_MSG_RESULT(yes)
2286 AC_DEFINE(DISABLE_ARABIC)
2287fi
2288
Bram Moolenaar14184a32019-02-16 15:10:30 +01002289dnl Farsi language support has been removed, ignore --disable-farsi
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002290AC_ARG_ENABLE(farsi,
Bram Moolenaar14184a32019-02-16 15:10:30 +01002291 [ --disable-farsi Deprecated.],,)
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002292
Bram Moolenaar071d4272004-06-13 20:20:40 +00002293AC_MSG_CHECKING(--enable-xim argument)
2294AC_ARG_ENABLE(xim,
2295 [ --enable-xim Include XIM input support.],
2296 AC_MSG_RESULT($enable_xim),
2297 [enable_xim="auto"; AC_MSG_RESULT(defaulting to auto)])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002298
2299AC_MSG_CHECKING(--enable-fontset argument)
2300AC_ARG_ENABLE(fontset,
2301 [ --enable-fontset Include X fontset output support.], ,
2302 [enable_fontset="no"])
2303AC_MSG_RESULT($enable_fontset)
2304dnl defining FEAT_XFONTSET is delayed, so that it can be disabled for no GUI
2305
2306test -z "$with_x" && with_x=yes
Bram Moolenaard0573012017-10-28 21:11:06 +02002307test "${enable_gui-yes}" != no -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && with_x=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002308if test "$with_x" = no; then
2309 AC_MSG_RESULT(defaulting to: don't HAVE_X11)
2310else
2311 dnl Do this check early, so that its failure can override user requests.
2312
2313 AC_PATH_PROG(xmkmfpath, xmkmf)
2314
2315 AC_PATH_XTRA
2316
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002317 dnl On z/OS Unix the X libraries are DLLs. To use them the code must
Bram Moolenaar071d4272004-06-13 20:20:40 +00002318 dnl be compiled with a special option.
2319 dnl Also add SM, ICE and Xmu to X_EXTRA_LIBS.
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002320 if test "$zOSUnix" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002321 CFLAGS="$CFLAGS -W c,dll"
2322 LDFLAGS="$LDFLAGS -W l,dll"
2323 X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE -lXmu"
2324 fi
2325
2326 dnl On my HPUX system the X include dir is found, but the lib dir not.
Bram Moolenaar70778922020-02-05 20:44:24 +01002327 dnl This is a desperate try to fix this.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002328
2329 if test -d "$x_includes" && test ! -d "$x_libraries"; then
2330 x_libraries=`echo "$x_includes" | sed s/include/lib/`
2331 AC_MSG_RESULT(Corrected X libraries to $x_libraries)
2332 X_LIBS="$X_LIBS -L$x_libraries"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00002333 if test "$vim_cv_uname_output" = SunOS &&
2334 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002335 X_LIBS="$X_LIBS -R $x_libraries"
2336 fi
2337 fi
2338
2339 if test -d "$x_libraries" && test ! -d "$x_includes"; then
2340 x_includes=`echo "$x_libraries" | sed s/lib/include/`
2341 AC_MSG_RESULT(Corrected X includes to $x_includes)
2342 X_CFLAGS="$X_CFLAGS -I$x_includes"
2343 fi
2344
2345 dnl Remove "-I/usr/include " from X_CFLAGS, should not be needed.
2346 X_CFLAGS="`echo $X_CFLAGS\ | sed 's%-I/usr/include %%'`"
2347 dnl Remove "-L/usr/lib " from X_LIBS, should not be needed.
2348 X_LIBS="`echo $X_LIBS\ | sed 's%-L/usr/lib %%'`"
2349 dnl Same for "-R/usr/lib ".
2350 X_LIBS="`echo $X_LIBS\ | sed -e 's%-R/usr/lib %%' -e 's%-R /usr/lib %%'`"
2351
2352
2353 dnl Check if the X11 header files are correctly installed. On some systems
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002354 dnl Xlib.h includes files that don't exist. On some systems X11/Intrinsic.h
2355 dnl is missing.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002356 AC_MSG_CHECKING(if X11 header files can be found)
2357 cflags_save=$CFLAGS
2358 CFLAGS="$CFLAGS $X_CFLAGS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002359 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <X11/Xlib.h>
2360#include <X11/Intrinsic.h>], )],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002361 AC_MSG_RESULT(yes),
2362 AC_MSG_RESULT(no); no_x=yes)
2363 CFLAGS=$cflags_save
2364
2365 if test "${no_x-no}" = yes; then
2366 with_x=no
2367 else
2368 AC_DEFINE(HAVE_X11)
2369 X_LIB="-lXt -lX11";
2370 AC_SUBST(X_LIB)
2371
2372 ac_save_LDFLAGS="$LDFLAGS"
2373 LDFLAGS="-L$x_libraries $LDFLAGS"
2374
2375 dnl Check for -lXdmcp (needed on SunOS 4.1.4)
2376 dnl For HP-UX 10.20 it must be before -lSM -lICE
2377 AC_CHECK_LIB(Xdmcp, _XdmcpAuthDoIt, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lXdmcp"],,
2378 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXdmcp])
2379
2380 dnl Some systems need -lnsl -lsocket when testing for ICE.
2381 dnl The check above doesn't do this, try here (again). Also needed to get
2382 dnl them after Xdmcp. link.sh will remove them when not needed.
2383 dnl Check for other function than above to avoid the cached value
2384 AC_CHECK_LIB(ICE, IceOpenConnection,
2385 [X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE"],, [$X_EXTRA_LIBS])
2386
2387 dnl Check for -lXpm (needed for some versions of Motif)
2388 LDFLAGS="$X_LIBS $ac_save_LDFLAGS"
2389 AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [X_PRE_LIBS="$X_PRE_LIBS -lXpm"],,
2390 [-lXt $X_PRE_LIBS -lXpm -lX11 $X_EXTRA_LIBS])
2391
2392 dnl Check that the X11 header files don't use implicit declarations
2393 AC_MSG_CHECKING(if X11 header files implicitly declare return values)
2394 cflags_save=$CFLAGS
Bram Moolenaard1864592013-05-04 04:40:15 +02002395 dnl -Werror is GCC only, others like Solaris Studio might not like it
2396 if test "$GCC" = yes; then
2397 CFLAGS="$CFLAGS $X_CFLAGS -Werror"
2398 else
2399 CFLAGS="$CFLAGS $X_CFLAGS"
2400 fi
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002401 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <X11/Xlib.h>], )],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002402 AC_MSG_RESULT(no),
2403 CFLAGS="$CFLAGS -Wno-implicit-int"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002404 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <X11/Xlib.h>], )],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002405 AC_MSG_RESULT(yes); cflags_save="$cflags_save -Wno-implicit-int",
2406 AC_MSG_RESULT(test failed)
2407 )
2408 )
2409 CFLAGS=$cflags_save
2410
2411 LDFLAGS="$ac_save_LDFLAGS"
2412
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002413 AC_MSG_CHECKING(size of wchar_t is 2 bytes)
2414 AC_CACHE_VAL(ac_cv_small_wchar_t,
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002415 [AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002416#include <X11/Xlib.h>
2417#if STDC_HEADERS
2418# include <stdlib.h>
2419# include <stddef.h>
2420#endif
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01002421 int main()
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002422 {
2423 if (sizeof(wchar_t) <= 2)
2424 exit(1);
2425 exit(0);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002426 }])],
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002427 ac_cv_small_wchar_t="no",
2428 ac_cv_small_wchar_t="yes",
2429 AC_MSG_ERROR(failed to compile test program))])
2430 AC_MSG_RESULT($ac_cv_small_wchar_t)
2431 if test "x$ac_cv_small_wchar_t" = "xyes" ; then
2432 AC_DEFINE(SMALL_WCHAR_T)
2433 fi
2434
Bram Moolenaar071d4272004-06-13 20:20:40 +00002435 fi
2436fi
2437
Bram Moolenaard2a05492018-07-27 22:35:15 +02002438dnl Check if --with-x was given but it doesn't work.
2439if test "x$with_x" = xno -a "x$with_x_arg" = xyes; then
2440 AC_MSG_ERROR([could not configure X])
2441fi
2442
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002443test "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 +00002444
2445AC_MSG_CHECKING(--enable-gui argument)
2446AC_ARG_ENABLE(gui,
Bram Moolenaarf52fac22022-03-11 16:01:26 +00002447 [ --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 +00002448
2449dnl Canonicalize the --enable-gui= argument so that it can be easily compared.
2450dnl Do not use character classes for portability with old tools.
2451enable_gui_canon=`echo "_$enable_gui" | \
2452 sed 's/[[ _+-]]//g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
2453
2454dnl Skip everything by default.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002455SKIP_GTK2=YES
Bram Moolenaar1858a842016-02-23 22:30:31 +01002456SKIP_GTK3=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002457SKIP_GNOME=YES
2458SKIP_MOTIF=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002459SKIP_PHOTON=YES
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002460SKIP_HAIKU=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002461GUITYPE=NONE
2462
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002463if test "x$HAIKU" = "xyes"; then
2464 SKIP_HAIKU=
2465 case "$enable_gui_canon" in
2466 no) AC_MSG_RESULT(no GUI support)
2467 SKIP_HAIKU=YES ;;
2468 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
2469 auto) AC_MSG_RESULT(auto - automatic GUI support) ;;
2470 haiku) AC_MSG_RESULT(Haiku GUI support) ;;
2471 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2472 SKIP_HAIKU=YES ;;
2473 esac
2474elif test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002475 SKIP_PHOTON=
2476 case "$enable_gui_canon" in
2477 no) AC_MSG_RESULT(no GUI support)
2478 SKIP_PHOTON=YES ;;
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002479 yes|""|auto) AC_MSG_RESULT(automatic GUI support)
2480 gui_auto=yes ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002481 photon) AC_MSG_RESULT(Photon GUI support) ;;
2482 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2483 SKIP_PHOTON=YES ;;
2484 esac
2485
Bram Moolenaar040f9752020-08-11 23:08:48 +02002486elif test "x$MACOS_X" = "xyes" -a "x$with_x" = "xno" ; then
2487 case "$enable_gui_canon" in
2488 no) AC_MSG_RESULT(no GUI support) ;;
2489 yes|"") AC_MSG_RESULT(yes - automatic GUI support)
2490 gui_auto=yes ;;
2491 auto) AC_MSG_RESULT(auto - disable GUI support for Mac OS) ;;
Bram Moolenaarbe7529e2020-08-13 21:05:39 +02002492 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
Bram Moolenaar040f9752020-08-11 23:08:48 +02002493 esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00002494else
2495
Bram Moolenaar071d4272004-06-13 20:20:40 +00002496 case "$enable_gui_canon" in
2497 no|none) AC_MSG_RESULT(no GUI support) ;;
2498 yes|""|auto) AC_MSG_RESULT(yes/auto - automatic GUI support)
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002499 gui_auto=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002500 SKIP_GTK2=
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002501 SKIP_GTK3=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002502 SKIP_GNOME=
Bram Moolenaarf52fac22022-03-11 16:01:26 +00002503 SKIP_MOTIF=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002504 gtk2) AC_MSG_RESULT(GTK+ 2.x GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002505 SKIP_GTK2=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002506 gnome2) AC_MSG_RESULT(GNOME 2.x GUI support)
2507 SKIP_GNOME=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002508 SKIP_GTK2=;;
Bram Moolenaar98921892016-02-23 17:14:37 +01002509 gtk3) AC_MSG_RESULT(GTK+ 3.x GUI support)
2510 SKIP_GTK3=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002511 motif) AC_MSG_RESULT(Motif GUI support)
2512 SKIP_MOTIF=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002513 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
2514 esac
2515
2516fi
2517
Bram Moolenaar071d4272004-06-13 20:20:40 +00002518if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \
2519 -a "$enable_gui_canon" != "gnome2"; then
2520 AC_MSG_CHECKING(whether or not to look for GTK+ 2)
2521 AC_ARG_ENABLE(gtk2-check,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002522 [ --enable-gtk2-check If auto-select GUI, check for GTK+ 2 [default=yes]],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002523 , enable_gtk2_check="yes")
2524 AC_MSG_RESULT($enable_gtk2_check)
2525 if test "x$enable_gtk2_check" = "xno"; then
2526 SKIP_GTK2=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002527 SKIP_GNOME=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002528 fi
2529fi
2530
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002531if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002532 AC_MSG_CHECKING(whether or not to look for GNOME)
2533 AC_ARG_ENABLE(gnome-check,
2534 [ --enable-gnome-check If GTK GUI, check for GNOME [default=no]],
2535 , enable_gnome_check="no")
2536 AC_MSG_RESULT($enable_gnome_check)
2537 if test "x$enable_gnome_check" = "xno"; then
2538 SKIP_GNOME=YES
2539 fi
2540fi
2541
Bram Moolenaar98921892016-02-23 17:14:37 +01002542if test "x$SKIP_GTK3" != "xYES" -a "$enable_gui_canon" != "gtk3"; then
2543 AC_MSG_CHECKING(whether or not to look for GTK+ 3)
2544 AC_ARG_ENABLE(gtk3-check,
2545 [ --enable-gtk3-check If auto-select GUI, check for GTK+ 3 [default=yes]],
2546 , enable_gtk3_check="yes")
2547 AC_MSG_RESULT($enable_gtk3_check)
2548 if test "x$enable_gtk3_check" = "xno"; then
2549 SKIP_GTK3=YES
2550 fi
2551fi
2552
Bram Moolenaar071d4272004-06-13 20:20:40 +00002553if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then
2554 AC_MSG_CHECKING(whether or not to look for Motif)
2555 AC_ARG_ENABLE(motif-check,
2556 [ --enable-motif-check If auto-select GUI, check for Motif [default=yes]],
2557 , enable_motif_check="yes")
2558 AC_MSG_RESULT($enable_motif_check)
2559 if test "x$enable_motif_check" = "xno"; then
2560 SKIP_MOTIF=YES
2561 fi
2562fi
2563
Bram Moolenaar071d4272004-06-13 20:20:40 +00002564dnl define an autoconf function to check for a specified version of GTK, and
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002565dnl try to compile/link a GTK program.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002566dnl
2567dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002568dnl Test for GTK, and define GTK_CFLAGS, GTK_LIBDIR and GTK_LIBS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002569dnl
2570AC_DEFUN(AM_PATH_GTK,
2571[
2572 if test "X$GTK_CONFIG" != "Xno" -o "X$PKG_CONFIG" != "Xno"; then
2573 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00002574 no_gtk=""
2575 if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2576 && $PKG_CONFIG --exists gtk+-2.0; then
2577 {
Bram Moolenaar98921892016-02-23 17:14:37 +01002578 min_gtk_version=ifelse([$1], ,2.2.0,$1)
2579 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002580 dnl We should be using PKG_CHECK_MODULES() instead of this hack.
2581 dnl But I guess the dependency on pkgconfig.m4 is not wanted or
2582 dnl something like that.
2583 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0`
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002584 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-2.0`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002585 GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0`
2586 gtk_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2587 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2588 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2589 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2590 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2591 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2592 }
Bram Moolenaar98921892016-02-23 17:14:37 +01002593 elif (test "X$SKIP_GTK3" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2594 && $PKG_CONFIG --exists gtk+-3.0; then
2595 {
2596 min_gtk_version=ifelse([$1], ,3.0.0,$1)
2597 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
2598
2599 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-3.0`
2600 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-3.0`
2601 GTK_LIBS=`$PKG_CONFIG --libs gtk+-3.0`
2602 gtk_major_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2603 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2604 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2605 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2606 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2607 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2608 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002609 else
Bram Moolenaar67876de2021-01-12 20:51:24 +01002610 dnl Put some text before the "no" to hint at installing the gtk-dev
2611 dnl packages.
2612 AC_MSG_CHECKING(for GTK -dev package)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002613 no_gtk=yes
2614 fi
2615
2616 if test "x$enable_gtktest" = "xyes" -a "x$no_gtk" = "x"; then
2617 {
2618 ac_save_CFLAGS="$CFLAGS"
2619 ac_save_LIBS="$LIBS"
2620 CFLAGS="$CFLAGS $GTK_CFLAGS"
2621 LIBS="$LIBS $GTK_LIBS"
2622
2623 dnl
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002624 dnl Now check if the installed GTK is sufficiently new.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002625 dnl
2626 rm -f conf.gtktest
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002627 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar071d4272004-06-13 20:20:40 +00002628#include <gtk/gtk.h>
2629#include <stdio.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00002630#if STDC_HEADERS
2631# include <stdlib.h>
2632# include <stddef.h>
2633#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002634
2635int
2636main ()
2637{
2638int major, minor, micro;
2639char *tmp_version;
2640
2641system ("touch conf.gtktest");
2642
2643/* HP/UX 9 (%@#!) writes to sscanf strings */
2644tmp_version = g_strdup("$min_gtk_version");
2645if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
2646 printf("%s, bad version string\n", "$min_gtk_version");
2647 exit(1);
2648 }
2649
2650if ((gtk_major_version > major) ||
2651 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
2652 ((gtk_major_version == major) && (gtk_minor_version == minor) &&
2653 (gtk_micro_version >= micro)))
2654{
2655 return 0;
2656}
2657return 1;
2658}
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002659])],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002660 CFLAGS="$ac_save_CFLAGS"
2661 LIBS="$ac_save_LIBS"
2662 }
2663 fi
2664 if test "x$no_gtk" = x ; then
2665 if test "x$enable_gtktest" = "xyes"; then
2666 AC_MSG_RESULT(yes; found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2667 else
2668 AC_MSG_RESULT(found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2669 fi
2670 ifelse([$2], , :, [$2])
2671 else
2672 {
2673 AC_MSG_RESULT(no)
2674 GTK_CFLAGS=""
2675 GTK_LIBS=""
2676 ifelse([$3], , :, [$3])
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002677 if test "$fail_if_missing" = "yes" -a "X$gui_auto" != "Xyes"; then
2678 AC_MSG_ERROR([could not configure GTK])
2679 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002680 }
2681 fi
2682 }
2683 else
2684 GTK_CFLAGS=""
2685 GTK_LIBS=""
2686 ifelse([$3], , :, [$3])
2687 fi
2688 AC_SUBST(GTK_CFLAGS)
2689 AC_SUBST(GTK_LIBS)
2690 rm -f conf.gtktest
2691])
2692
2693dnl ---------------------------------------------------------------------------
2694dnl gnome
2695dnl ---------------------------------------------------------------------------
2696AC_DEFUN([GNOME_INIT_HOOK],
2697[
2698 AC_SUBST(GNOME_LIBS)
2699 AC_SUBST(GNOME_LIBDIR)
2700 AC_SUBST(GNOME_INCLUDEDIR)
2701
2702 AC_ARG_WITH(gnome-includes,
2703 [ --with-gnome-includes=DIR Specify location of GNOME headers],
2704 [CFLAGS="$CFLAGS -I$withval"]
2705 )
2706
2707 AC_ARG_WITH(gnome-libs,
2708 [ --with-gnome-libs=DIR Specify location of GNOME libs],
2709 [LDFLAGS="$LDFLAGS -L$withval" gnome_prefix=$withval]
2710 )
2711
2712 AC_ARG_WITH(gnome,
2713 [ --with-gnome Specify prefix for GNOME files],
2714 if test x$withval = xyes; then
2715 want_gnome=yes
2716 ifelse([$1], [], :, [$1])
2717 else
2718 if test "x$withval" = xno; then
2719 want_gnome=no
2720 else
2721 want_gnome=yes
2722 LDFLAGS="$LDFLAGS -L$withval/lib"
2723 CFLAGS="$CFLAGS -I$withval/include"
2724 gnome_prefix=$withval/lib
2725 fi
2726 fi,
2727 want_gnome=yes)
2728
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002729 if test "x$want_gnome" = xyes; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002730 {
2731 AC_MSG_CHECKING(for libgnomeui-2.0)
2732 if $PKG_CONFIG --exists libgnomeui-2.0; then
2733 AC_MSG_RESULT(yes)
2734 GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0`
2735 GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0`
2736 GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0`
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002737
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002738 dnl On FreeBSD we need -pthread but pkg-config doesn't include it.
2739 dnl This might not be the right way but it works for me...
2740 AC_MSG_CHECKING(for FreeBSD)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00002741 if test "$vim_cv_uname_output" = FreeBSD; then
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002742 AC_MSG_RESULT(yes, adding -pthread)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002743 GNOME_INCLUDEDIR="$GNOME_INCLUDEDIR -D_THREAD_SAFE"
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002744 GNOME_LIBS="$GNOME_LIBS -pthread"
2745 else
2746 AC_MSG_RESULT(no)
2747 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002748 $1
2749 else
2750 AC_MSG_RESULT(not found)
2751 if test "x$2" = xfail; then
2752 AC_MSG_ERROR(Could not find libgnomeui-2.0 via pkg-config)
2753 fi
2754 fi
2755 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002756 fi
2757])
2758
2759AC_DEFUN([GNOME_INIT],[
2760 GNOME_INIT_HOOK([],fail)
2761])
2762
Bram Moolenaar427f5b62019-06-09 13:43:51 +02002763if test "X$PKG_CONFIG" = "X"; then
2764 AC_PATH_TOOL(PKG_CONFIG, pkg-config, no)
2765fi
2766
Bram Moolenaar071d4272004-06-13 20:20:40 +00002767
2768dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002769dnl Check for GTK2. If it fails, then continue on for Motif as before...
Bram Moolenaar071d4272004-06-13 20:20:40 +00002770dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002771if test -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002772
2773 AC_MSG_CHECKING(--disable-gtktest argument)
2774 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2775 , enable_gtktest=yes)
2776 if test "x$enable_gtktest" = "xyes" ; then
2777 AC_MSG_RESULT(gtk test enabled)
2778 else
2779 AC_MSG_RESULT(gtk test disabled)
2780 fi
2781
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002782 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002783 dnl First try finding version 2.2.0 or later. The 2.0.x series has
2784 dnl problems (bold fonts, --remote doesn't work).
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002785 dnl Disable checking for GTK3 here, otherwise it's found when GTK2 is not
2786 dnl found.
2787 save_skip_gtk3=$SKIP_GTK3
2788 SKIP_GTK3=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002789 AM_PATH_GTK(2.2.0,
2790 [GUI_LIB_LOC="$GTK_LIBDIR"
2791 GTK_LIBNAME="$GTK_LIBS"
2792 GUI_INC_LOC="$GTK_CFLAGS"], )
2793 if test "x$GTK_CFLAGS" != "x"; then
Bram Moolenaar98921892016-02-23 17:14:37 +01002794 SKIP_GTK3=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002795 SKIP_MOTIF=YES
2796 GUITYPE=GTK
2797 AC_SUBST(GTK_LIBNAME)
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002798 else
2799 SKIP_GTK3=$save_skip_gtk3
Bram Moolenaar071d4272004-06-13 20:20:40 +00002800 fi
2801 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002802 if test "x$GUITYPE" = "xGTK"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002803 dnl
2804 dnl if GTK exists, then check for GNOME.
2805 dnl
2806 if test -z "$SKIP_GNOME"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002807 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002808 GNOME_INIT_HOOK([have_gnome=yes])
2809 if test "x$have_gnome" = xyes ; then
2810 AC_DEFINE(FEAT_GUI_GNOME)
2811 GUI_INC_LOC="$GUI_INC_LOC $GNOME_INCLUDEDIR"
2812 GTK_LIBNAME="$GTK_LIBNAME $GNOME_LIBDIR $GNOME_LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002813 fi
2814 }
2815 fi
2816 fi
2817fi
2818
Bram Moolenaar98921892016-02-23 17:14:37 +01002819
2820dnl ---------------------------------------------------------------------------
2821dnl Check for GTK3.
2822dnl ---------------------------------------------------------------------------
2823if test -z "$SKIP_GTK3"; then
2824
2825 AC_MSG_CHECKING(--disable-gtktest argument)
2826 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2827 , enable_gtktest=yes)
2828 if test "x$enable_gtktest" = "xyes" ; then
2829 AC_MSG_RESULT(gtk test enabled)
2830 else
2831 AC_MSG_RESULT(gtk test disabled)
2832 fi
2833
Bram Moolenaar98921892016-02-23 17:14:37 +01002834 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002835 save_skip_gtk2=$SKIP_GTK2
2836 SKIP_GTK2=YES
Bram Moolenaar98921892016-02-23 17:14:37 +01002837 AM_PATH_GTK(3.0.0,
2838 [GUI_LIB_LOC="$GTK_LIBDIR"
2839 GTK_LIBNAME="$GTK_LIBS"
2840 GUI_INC_LOC="$GTK_CFLAGS"], )
2841 if test "x$GTK_CFLAGS" != "x"; then
2842 SKIP_GTK2=YES
2843 SKIP_GNOME=YES
Bram Moolenaar98921892016-02-23 17:14:37 +01002844 SKIP_MOTIF=YES
2845 GUITYPE=GTK
2846 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar98921892016-02-23 17:14:37 +01002847 AC_DEFINE(USE_GTK3)
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002848 else
2849 SKIP_GTK2=$save_skip_gtk2
Bram Moolenaar98921892016-02-23 17:14:37 +01002850 fi
2851 fi
2852fi
2853
Bram Moolenaard2e03f02016-01-02 22:46:36 +01002854dnl Check the version of Gdk-Pixbuf. If the version is 2.31 or later and
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002855dnl glib-compile-resources is found in PATH, use GResource.
2856if test "x$GUITYPE" = "xGTK"; then
2857 AC_MSG_CHECKING([version of Gdk-Pixbuf])
2858 gdk_pixbuf_version=`$PKG_CONFIG --modversion gdk-pixbuf-2.0`
2859 if test "x$gdk_pixbuf_version" != x ; then
2860 gdk_pixbuf_version_minor=`echo $gdk_pixbuf_version | \
2861 sed -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/'`
2862 if test "x$gdk_pixbuf_version_minor" != x -a \
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002863 $gdk_pixbuf_version_minor -ge 31 ; then
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002864 AC_MSG_RESULT([OK.])
2865 AC_PATH_PROG(GLIB_COMPILE_RESOURCES,[glib-compile-resources],no)
2866 AC_MSG_CHECKING([glib-compile-resources])
2867 if test "x$GLIB_COMPILE_RESOURCES" = xno ; then
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002868 GLIB_COMPILE_RESOURCES=""
2869 AC_MSG_RESULT([cannot be found in PATH.])
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002870 else
2871 AC_MSG_RESULT([usable.])
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002872 AC_DEFINE(USE_GRESOURCE)
2873 GRESOURCE_SRC="auto/gui_gtk_gresources.c"
2874 GRESOURCE_OBJ="objects/gui_gtk_gresources.o"
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002875 fi
2876 else
2877 AC_MSG_RESULT([not usable.])
2878 fi
2879 else
2880 AC_MSG_RESULT([cannot obtain from pkg_config.])
2881 fi
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002882
2883 AC_MSG_CHECKING([--disable-icon-cache-update argument])
2884 AC_ARG_ENABLE(icon_cache_update,
2885 [ --disable-icon-cache-update update disabled],
2886 [],
2887 [enable_icon_cache_update="yes"])
2888 if test "$enable_icon_cache_update" = "yes"; then
2889 AC_MSG_RESULT([not set])
2890 AC_PATH_PROG(GTK_UPDATE_ICON_CACHE,[gtk-update-icon-cache],no)
2891 if test "x$GTK_UPDATE_ICON_CACHE" = "xno" ; then
2892 AC_MSG_RESULT([not found in PATH.])
2893 fi
2894 else
2895 AC_MSG_RESULT([update disabled])
2896 fi
2897
2898 AC_MSG_CHECKING([--disable-desktop-database-update argument])
2899 AC_ARG_ENABLE(desktop_database_update,
2900 [ --disable-desktop-database-update update disabled],
2901 [],
2902 [enable_desktop_database_update="yes"])
2903 if test "$enable_desktop_database_update" = "yes"; then
2904 AC_MSG_RESULT([not set])
2905 AC_PATH_PROG(UPDATE_DESKTOP_DATABASE,[update-desktop-database],no)
2906 if test "x$UPDATE_DESKTOP_DATABASE" = "xno" ; then
2907 AC_MSG_RESULT([not found in PATH.])
2908 fi
2909 else
2910 AC_MSG_RESULT([update disabled])
2911 fi
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002912fi
2913AC_SUBST(GLIB_COMPILE_RESOURCES)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002914AC_SUBST(GRESOURCE_SRC)
2915AC_SUBST(GRESOURCE_OBJ)
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002916AC_SUBST(GTK_UPDATE_ICON_CACHE)
2917AC_SUBST(UPDATE_DESKTOP_DATABASE)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002918
Bram Moolenaar071d4272004-06-13 20:20:40 +00002919dnl Check for Motif include files location.
2920dnl The LAST one found is used, this makes the highest version to be used,
2921dnl e.g. when Motif1.2 and Motif2.0 are both present.
2922
2923if test -z "$SKIP_MOTIF"; then
2924 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"
2925 dnl Remove "-I" from before $GUI_INC_LOC if it's there
2926 GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`"
2927
2928 AC_MSG_CHECKING(for location of Motif GUI includes)
2929 gui_includes="`echo $x_includes|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC"
2930 GUI_INC_LOC=
2931 for try in $gui_includes; do
2932 if test -f "$try/Xm/Xm.h"; then
2933 GUI_INC_LOC=$try
2934 fi
2935 done
2936 if test -n "$GUI_INC_LOC"; then
2937 if test "$GUI_INC_LOC" = /usr/include; then
2938 GUI_INC_LOC=
2939 AC_MSG_RESULT(in default path)
2940 else
2941 AC_MSG_RESULT($GUI_INC_LOC)
2942 fi
2943 else
2944 AC_MSG_RESULT(<not found>)
2945 SKIP_MOTIF=YES
2946 fi
2947fi
2948
2949dnl Check for Motif library files location. In the same order as the include
2950dnl files, to avoid a mixup if several versions are present
2951
2952if test -z "$SKIP_MOTIF"; then
2953 AC_MSG_CHECKING(--with-motif-lib argument)
2954 AC_ARG_WITH(motif-lib,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002955 [ --with-motif-lib=STRING Library for Motif ],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002956 [ MOTIF_LIBNAME="${withval}" ] )
2957
2958 if test -n "$MOTIF_LIBNAME"; then
2959 AC_MSG_RESULT($MOTIF_LIBNAME)
2960 GUI_LIB_LOC=
2961 else
2962 AC_MSG_RESULT(no)
2963
2964 dnl Remove "-L" from before $GUI_LIB_LOC if it's there
2965 GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
2966
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002967 dnl Ubuntu has libXm.so in /usr/lib/i386-linux-gnu and elsewhere. The
2968 dnl linker will figure out which one to use, we only check if one exists.
Kelvin Leeb4716902022-04-04 17:20:01 +01002969 dnl Cygwin uses the .dll.a extension.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002970 AC_MSG_CHECKING(for location of Motif GUI libs)
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002971 gui_libs="`echo $x_libraries|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/lib/g` /usr/lib/i386-linux-gnu /usr/lib/x86_64-linux-gnu `echo "$GUI_INC_LOC" | sed s/include/lib/` $GUI_LIB_LOC"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002972 GUI_LIB_LOC=
2973 for try in $gui_libs; do
Kelvin Leeb4716902022-04-04 17:20:01 +01002974 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 +00002975 if test -f "$libtry"; then
2976 GUI_LIB_LOC=$try
2977 fi
2978 done
2979 done
2980 if test -n "$GUI_LIB_LOC"; then
2981 dnl Remove /usr/lib, it causes trouble on some systems
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002982 if test "$GUI_LIB_LOC" = /usr/lib \
2983 -o "$GUI_LIB_LOC" = /usr/lib/i386-linux-gnu \
2984 -o "$GUI_LIB_LOC" = /usr/lib/x86_64-linux-gnu; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002985 GUI_LIB_LOC=
2986 AC_MSG_RESULT(in default path)
2987 else
2988 if test -n "$GUI_LIB_LOC"; then
2989 AC_MSG_RESULT($GUI_LIB_LOC)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00002990 if test "$vim_cv_uname_output" = SunOS &&
2991 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002992 GUI_LIB_LOC="$GUI_LIB_LOC -R $GUI_LIB_LOC"
2993 fi
2994 fi
2995 fi
2996 MOTIF_LIBNAME=-lXm
2997 else
2998 AC_MSG_RESULT(<not found>)
2999 SKIP_MOTIF=YES
3000 fi
3001 fi
3002fi
3003
3004if test -z "$SKIP_MOTIF"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003005 GUITYPE=MOTIF
3006 AC_SUBST(MOTIF_LIBNAME)
3007fi
3008
Bram Moolenaare2adcf32022-03-12 11:57:25 +00003009if test -z "$SKIP_MOTIF"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003010 dnl Prepend -I and -L to $GUI_INC_LOC and $GUI_LIB_LOC if not empty
3011 dnl Avoid adding it when it twice
3012 if test -n "$GUI_INC_LOC"; then
3013 GUI_INC_LOC=-I"`echo $GUI_INC_LOC|sed 's%-I%%'`"
3014 fi
3015 if test -n "$GUI_LIB_LOC"; then
3016 GUI_LIB_LOC=-L"`echo $GUI_LIB_LOC|sed 's%-L%%'`"
3017 fi
3018
3019 dnl Check for -lXext and then for -lXmu
3020 ldflags_save=$LDFLAGS
3021 LDFLAGS="$X_LIBS $LDFLAGS"
3022 AC_CHECK_LIB(Xext, XShapeQueryExtension, [GUI_X_LIBS="-lXext"],,
3023 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3024 dnl For Solaris we need -lw and -ldl before linking with -lXmu works.
3025 AC_CHECK_LIB(w, wslen, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lw"],,
3026 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3027 AC_CHECK_LIB(dl, dlsym, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldl"],,
3028 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3029 AC_CHECK_LIB(Xmu, XmuCreateStippledPixmap, [GUI_X_LIBS="-lXmu $GUI_X_LIBS"],,
3030 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3031 if test -z "$SKIP_MOTIF"; then
3032 AC_CHECK_LIB(Xp, XpEndJob, [GUI_X_LIBS="-lXp $GUI_X_LIBS"],,
3033 [$GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3034 fi
3035 LDFLAGS=$ldflags_save
3036
3037 dnl Execute xmkmf to figure out if -DNARROWPROTO is needed.
3038 AC_MSG_CHECKING(for extra X11 defines)
3039 NARROW_PROTO=
3040 rm -fr conftestdir
3041 if mkdir conftestdir; then
3042 cd conftestdir
3043 cat > Imakefile <<'EOF'
3044acfindx:
3045 @echo 'NARROW_PROTO="${PROTO_DEFINES}"'
3046EOF
3047 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
3048 eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
3049 fi
3050 cd ..
3051 rm -fr conftestdir
3052 fi
3053 if test -z "$NARROW_PROTO"; then
3054 AC_MSG_RESULT(no)
3055 else
3056 AC_MSG_RESULT($NARROW_PROTO)
3057 fi
3058 AC_SUBST(NARROW_PROTO)
3059fi
3060
3061dnl Look for XSMP support - but don't necessarily restrict it to X11 GUIs
3062dnl use the X11 include path
3063if test "$enable_xsmp" = "yes"; then
3064 cppflags_save=$CPPFLAGS
3065 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3066 AC_CHECK_HEADERS(X11/SM/SMlib.h)
3067 CPPFLAGS=$cppflags_save
3068fi
3069
3070
Bram Moolenaarf52fac22022-03-11 16:01:26 +00003071if test -z "$SKIP_MOTIF" -o -z "$SKIP_GTK2" -o -z "$SKIP_GTK3"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003072 dnl Check for X11/xpm.h and X11/Sunkeysym.h with the GUI include path
3073 cppflags_save=$CPPFLAGS
3074 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3075 AC_CHECK_HEADERS(X11/xpm.h X11/Sunkeysym.h)
3076
3077 dnl automatically disable XIM when XIMtext isn't in X11/Xlib.h
3078 if test ! "$enable_xim" = "no"; then
3079 AC_MSG_CHECKING(for XIMText in X11/Xlib.h)
3080 AC_EGREP_CPP(XIMText, [#include <X11/Xlib.h>],
3081 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +02003082 AC_MSG_RESULT(no; xim has been disabled); enable_xim="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00003083 fi
3084 CPPFLAGS=$cppflags_save
3085
Bram Moolenaar54612582019-11-21 17:13:31 +01003086 dnl automatically enable XIM in the GUI
3087 if test "$enable_xim" = "auto" -a "x$GUITYPE" != "xNONE" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003088 AC_MSG_RESULT(X GUI selected; xim has been enabled)
3089 enable_xim="yes"
3090 fi
3091fi
3092
Bram Moolenaarf52fac22022-03-11 16:01:26 +00003093if test -z "$SKIP_MOTIF"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003094 cppflags_save=$CPPFLAGS
3095 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00003096dnl Xmu/Editres.h may exist but can only be used after including Intrinsic.h
3097 AC_MSG_CHECKING([for X11/Xmu/Editres.h])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003098 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00003099#include <X11/Intrinsic.h>
3100#include <X11/Xmu/Editres.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003101 [int i; i = 0;])],
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00003102 AC_MSG_RESULT(yes)
3103 AC_DEFINE(HAVE_X11_XMU_EDITRES_H),
3104 AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003105 CPPFLAGS=$cppflags_save
3106fi
3107
Bram Moolenaar0b40d082022-03-08 13:32:37 +00003108dnl Only use the Xm directory when compiling Motif.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003109if test -z "$SKIP_MOTIF"; then
3110 cppflags_save=$CPPFLAGS
3111 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003112 if test "$zOSUnix" = "yes"; then
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003113 AC_CHECK_HEADERS(Xm/Xm.h)
Bram Moolenaar77c19352012-06-13 19:19:41 +02003114 else
Bram Moolenaarde1d7342022-06-05 20:03:17 +01003115 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 +01003116 fi
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003117
Bram Moolenaar77c19352012-06-13 19:19:41 +02003118 if test "x$ac_cv_header_Xm_XpmP_h" = "xyes"; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003119 dnl Solaris uses XpmAttributes_21, very annoying.
3120 AC_MSG_CHECKING([for XpmAttributes_21 in Xm/XpmP.h])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003121 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <Xm/XpmP.h>], [XpmAttributes_21 attr;])],
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003122 AC_MSG_RESULT(yes); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes_21),
3123 AC_MSG_RESULT(no); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
3124 )
3125 else
Bram Moolenaar57657d82006-04-21 22:12:41 +00003126 AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003127 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003128 CPPFLAGS=$cppflags_save
3129fi
3130
3131if test "x$GUITYPE" = "xNONE" -a "$enable_xim" = "yes"; then
3132 AC_MSG_RESULT(no GUI selected; xim has been disabled)
3133 enable_xim="no"
3134fi
3135if test "x$GUITYPE" = "xNONE" -a "$enable_fontset" = "yes"; then
3136 AC_MSG_RESULT(no GUI selected; fontset has been disabled)
3137 enable_fontset="no"
3138fi
Bram Moolenaar182c5be2010-06-25 05:37:59 +02003139if test "x$GUITYPE:$enable_fontset" = "xGTK:yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003140 AC_MSG_RESULT(GTK+ 2 GUI selected; fontset has been disabled)
3141 enable_fontset="no"
3142fi
3143
Bram Moolenaarb3f74062020-02-26 16:16:53 +01003144dnl There is no test for the Haiku GUI, if it's selected it's used
3145if test -z "$SKIP_HAIKU"; then
3146 GUITYPE=HAIKUGUI
3147fi
3148
Bram Moolenaar071d4272004-06-13 20:20:40 +00003149if test -z "$SKIP_PHOTON"; then
3150 GUITYPE=PHOTONGUI
3151fi
3152
3153AC_SUBST(GUI_INC_LOC)
3154AC_SUBST(GUI_LIB_LOC)
3155AC_SUBST(GUITYPE)
3156AC_SUBST(GUI_X_LIBS)
3157
3158if test "$enable_workshop" = "yes" -a -n "$SKIP_MOTIF"; then
3159 AC_MSG_ERROR([cannot use workshop without Motif])
3160fi
3161
3162dnl defining FEAT_XIM and FEAT_XFONTSET is delayed, so that they can be disabled
3163if test "$enable_xim" = "yes"; then
3164 AC_DEFINE(FEAT_XIM)
3165fi
3166if test "$enable_fontset" = "yes"; then
3167 AC_DEFINE(FEAT_XFONTSET)
3168fi
3169
3170
3171dnl ---------------------------------------------------------------------------
3172dnl end of GUI-checking
3173dnl ---------------------------------------------------------------------------
3174
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003175AC_MSG_CHECKING([for /proc link to executable])
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003176if test -L "/proc/self/exe"; then
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003177 dnl Linux
3178 AC_MSG_RESULT([/proc/self/exe])
3179 AC_DEFINE(PROC_EXE_LINK, "/proc/self/exe")
3180elif test -L "/proc/self/path/a.out"; then
3181 dnl Solaris
3182 AC_MSG_RESULT([/proc/self/path/a.out])
3183 AC_DEFINE(PROC_EXE_LINK, "/proc/self/path/a.out")
3184elif test -L "/proc/curproc/file"; then
3185 dnl FreeBSD
3186 AC_MSG_RESULT([/proc/curproc/file])
3187 AC_DEFINE(PROC_EXE_LINK, "/proc/curproc/file")
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003188else
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003189 AC_MSG_RESULT(no)
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003190fi
3191
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003192dnl Check for Cygwin, which needs an extra source file if not using X11
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003193AC_MSG_CHECKING(for CYGWIN or MSYS environment)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00003194case $vim_cv_uname_output in
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003195 CYGWIN*|MSYS*) CYGWIN=yes; AC_MSG_RESULT(yes)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003196 AC_MSG_CHECKING(for CYGWIN clipboard support)
3197 if test "x$with_x" = "xno" ; then
3198 OS_EXTRA_SRC=winclip.c; OS_EXTRA_OBJ=objects/winclip.o
3199 AC_MSG_RESULT(yes)
3200 AC_DEFINE(FEAT_CYGWIN_WIN32_CLIPBOARD)
3201 else
3202 AC_MSG_RESULT(no - using X11)
3203 fi ;;
3204
3205 *) CYGWIN=no; AC_MSG_RESULT(no);;
3206esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00003207
Bram Moolenaar071d4272004-06-13 20:20:40 +00003208dnl Checks for libraries and include files.
3209
Bram Moolenaar446cb832008-06-24 21:56:24 +00003210AC_CACHE_CHECK([whether toupper is broken], [vim_cv_toupper_broken],
3211 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003212 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003213#include "confdefs.h"
3214#include <ctype.h>
3215#if STDC_HEADERS
3216# include <stdlib.h>
3217# include <stddef.h>
3218#endif
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01003219int main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003220 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003221 vim_cv_toupper_broken=yes
3222 ],[
3223 vim_cv_toupper_broken=no
3224 ],[
3225 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_toupper_broken')
3226 ])])
3227
3228if test "x$vim_cv_toupper_broken" = "xyes" ; then
3229 AC_DEFINE(BROKEN_TOUPPER)
3230fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003231
3232AC_MSG_CHECKING(whether __DATE__ and __TIME__ work)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003233AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>], [printf("(" __DATE__ " " __TIME__ ")");])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003234 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DATE_TIME),
3235 AC_MSG_RESULT(no))
3236
Bram Moolenaar0c094b92009-05-14 20:20:33 +00003237AC_MSG_CHECKING(whether __attribute__((unused)) is allowed)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003238AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>], [int x __attribute__((unused));])],
Bram Moolenaar0c094b92009-05-14 20:20:33 +00003239 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ATTRIBUTE_UNUSED),
3240 AC_MSG_RESULT(no))
3241
Bram Moolenaar071d4272004-06-13 20:20:40 +00003242dnl Checks for header files.
3243AC_CHECK_HEADER(elf.h, HAS_ELF=1)
3244dnl AC_CHECK_HEADER(dwarf.h, SVR4=1)
3245if test "$HAS_ELF" = 1; then
3246 AC_CHECK_LIB(elf, main)
3247fi
3248
3249AC_HEADER_DIRENT
3250
Bram Moolenaar071d4272004-06-13 20:20:40 +00003251dnl If sys/wait.h is not found it might still exist but not be POSIX
3252dnl compliant. In that case we define HAVE_UNION_WAIT (for NeXT)
3253if test $ac_cv_header_sys_wait_h = no; then
3254 AC_MSG_CHECKING([for sys/wait.h that defines union wait])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003255 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/wait.h>],
3256 [union wait xx, yy; xx = yy])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003257 AC_MSG_RESULT(yes)
3258 AC_DEFINE(HAVE_SYS_WAIT_H)
3259 AC_DEFINE(HAVE_UNION_WAIT),
3260 AC_MSG_RESULT(no))
3261fi
3262
Bram Moolenaar779a7752016-01-30 23:26:34 +01003263AC_CHECK_HEADERS(stdint.h stdlib.h string.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003264 sys/select.h sys/utsname.h termcap.h fcntl.h \
3265 sgtty.h sys/ioctl.h sys/time.h sys/types.h \
3266 termio.h iconv.h inttypes.h langinfo.h math.h \
3267 unistd.h stropts.h errno.h sys/resource.h \
3268 sys/systeminfo.h locale.h sys/stream.h termios.h \
3269 libc.h sys/statfs.h poll.h sys/poll.h pwd.h \
Bram Moolenaar1ecc5e42019-01-26 15:12:55 +01003270 utime.h sys/param.h sys/ptms.h libintl.h libgen.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003271 util/debug.h util/msg18n.h frame.h sys/acl.h \
3272 sys/access.h sys/sysinfo.h wchar.h wctype.h)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003273
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003274dnl sys/ptem.h depends on sys/stream.h on Solaris
3275AC_CHECK_HEADERS(sys/ptem.h, [], [],
3276[#if defined HAVE_SYS_STREAM_H
3277# include <sys/stream.h>
3278#endif])
3279
Bram Moolenaar32f31b12009-05-21 13:20:59 +00003280dnl sys/sysctl.h depends on sys/param.h on OpenBSD
3281AC_CHECK_HEADERS(sys/sysctl.h, [], [],
3282[#if defined HAVE_SYS_PARAM_H
3283# include <sys/param.h>
3284#endif])
3285
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003286
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003287dnl pthread_np.h may exist but can only be used after including pthread.h
3288AC_MSG_CHECKING([for pthread_np.h])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003289AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003290#include <pthread.h>
3291#include <pthread_np.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003292 [int i; i = 0;])],
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003293 AC_MSG_RESULT(yes)
3294 AC_DEFINE(HAVE_PTHREAD_NP_H),
3295 AC_MSG_RESULT(no))
3296
Bram Moolenaare344bea2005-09-01 20:46:49 +00003297AC_CHECK_HEADERS(strings.h)
Bram Moolenaard0573012017-10-28 21:11:06 +02003298if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00003299 dnl The strings.h file on OS/X contains a warning and nothing useful.
3300 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3301else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003302
3303dnl Check if strings.h and string.h can both be included when defined.
3304AC_MSG_CHECKING([if strings.h can be included after string.h])
3305cppflags_save=$CPPFLAGS
3306CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003307AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003308#if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO)
3309# define _NO_PROTO /* like in os_unix.h, causes conflict for AIX (Winn) */
3310 /* but don't do it on AIX 5.1 (Uribarri) */
3311#endif
3312#ifdef HAVE_XM_XM_H
3313# include <Xm/Xm.h> /* This breaks it for HP-UX 11 (Squassabia) */
3314#endif
3315#ifdef HAVE_STRING_H
3316# include <string.h>
3317#endif
3318#if defined(HAVE_STRINGS_H)
3319# include <strings.h>
3320#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003321 ], [int i; i = 0;])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003322 AC_MSG_RESULT(yes),
3323 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3324 AC_MSG_RESULT(no))
3325CPPFLAGS=$cppflags_save
Bram Moolenaar9372a112005-12-06 19:59:18 +00003326fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003327
3328dnl Checks for typedefs, structures, and compiler characteristics.
3329AC_PROG_GCC_TRADITIONAL
3330AC_C_CONST
Bram Moolenaar76243bd2009-03-02 01:47:02 +00003331AC_C_VOLATILE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003332AC_TYPE_MODE_T
3333AC_TYPE_OFF_T
3334AC_TYPE_PID_T
3335AC_TYPE_SIZE_T
3336AC_TYPE_UID_T
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003337AC_TYPE_UINT32_T
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003338
Bram Moolenaar071d4272004-06-13 20:20:40 +00003339AC_HEADER_TIME
3340AC_CHECK_TYPE(ino_t, long)
3341AC_CHECK_TYPE(dev_t, unsigned)
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003342AC_C_BIGENDIAN(,,,)
Bram Moolenaar136f29a2016-02-27 20:14:15 +01003343AC_C_INLINE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003344
3345AC_MSG_CHECKING(for rlim_t)
3346if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
3347 AC_MSG_RESULT([(cached) $ac_cv_type_rlim_t])
3348else
3349 AC_EGREP_CPP(dnl
3350changequote(<<,>>)dnl
3351<<(^|[^a-zA-Z_0-9])rlim_t[^a-zA-Z_0-9]>>dnl
3352changequote([,]),
3353 [
3354#include <sys/types.h>
3355#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003356# include <stdlib.h>
3357# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003358#endif
3359#ifdef HAVE_SYS_RESOURCE_H
Bram Moolenaar446cb832008-06-24 21:56:24 +00003360# include <sys/resource.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003361#endif
3362 ], ac_cv_type_rlim_t=yes, ac_cv_type_rlim_t=no)
3363 AC_MSG_RESULT($ac_cv_type_rlim_t)
3364fi
3365if test $ac_cv_type_rlim_t = no; then
3366 cat >> confdefs.h <<\EOF
3367#define rlim_t unsigned long
3368EOF
3369fi
3370
3371AC_MSG_CHECKING(for stack_t)
3372if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then
3373 AC_MSG_RESULT([(cached) $ac_cv_type_stack_t])
3374else
3375 AC_EGREP_CPP(stack_t,
3376 [
3377#include <sys/types.h>
3378#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003379# include <stdlib.h>
3380# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003381#endif
3382#include <signal.h>
3383 ], ac_cv_type_stack_t=yes, ac_cv_type_stack_t=no)
3384 AC_MSG_RESULT($ac_cv_type_stack_t)
3385fi
3386if test $ac_cv_type_stack_t = no; then
3387 cat >> confdefs.h <<\EOF
3388#define stack_t struct sigaltstack
3389EOF
3390fi
3391
3392dnl BSDI uses ss_base while others use ss_sp for the stack pointer.
3393AC_MSG_CHECKING(whether stack_t has an ss_base field)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003394AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003395#include <sys/types.h>
3396#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003397# include <stdlib.h>
3398# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003399#endif
3400#include <signal.h>
3401#include "confdefs.h"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003402 ], [stack_t sigstk; sigstk.ss_base = 0; ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003403 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SS_BASE),
3404 AC_MSG_RESULT(no))
3405
3406olibs="$LIBS"
3407AC_MSG_CHECKING(--with-tlib argument)
3408AC_ARG_WITH(tlib, [ --with-tlib=library terminal library to be used ],)
3409if test -n "$with_tlib"; then
3410 AC_MSG_RESULT($with_tlib)
3411 LIBS="$LIBS -l$with_tlib"
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003412 AC_MSG_CHECKING(for linking with $with_tlib library)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003413 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], AC_MSG_RESULT(OK), AC_MSG_ERROR(FAILED))
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003414 dnl Need to check for tgetent() below.
3415 olibs="$LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003416else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003417 AC_MSG_RESULT([empty: automatic terminal library selection])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003418 dnl On HP-UX 10.10 termcap or termlib should be used instead of
3419 dnl curses, because curses is much slower.
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003420 dnl Newer versions of ncurses are preferred over anything, except
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02003421 dnl when tinfo has been split off, it contains all we need.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003422 dnl Older versions of ncurses have bugs, get a new one!
3423 dnl Digital Unix (OSF1) should use curses (Ronald Schild).
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00003424 dnl On SCO Openserver should prefer termlib (Roger Cornelius).
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00003425 case "$vim_cv_uname_output" in
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003426 OSF1|SCO_SV) tlibs="tinfo ncurses curses termlib termcap";;
3427 *) tlibs="tinfo ncurses termlib termcap curses";;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003428 esac
3429 for libname in $tlibs; do
3430 AC_CHECK_LIB(${libname}, tgetent,,)
3431 if test "x$olibs" != "x$LIBS"; then
3432 dnl It's possible that a library is found but it doesn't work
3433 dnl e.g., shared library that cannot be found
3434 dnl compile and run a test program to be sure
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003435 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003436#ifdef HAVE_TERMCAP_H
3437# include <termcap.h>
3438#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003439#if STDC_HEADERS
3440# include <stdlib.h>
3441# include <stddef.h>
3442#endif
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01003443int main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003444 res="OK", res="FAIL", res="FAIL")
3445 if test "$res" = "OK"; then
3446 break
3447 fi
3448 AC_MSG_RESULT($libname library is not usable)
3449 LIBS="$olibs"
3450 fi
3451 done
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003452 if test "x$olibs" = "x$LIBS"; then
3453 AC_MSG_RESULT(no terminal library found)
3454 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003455fi
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003456
3457if test "x$olibs" = "x$LIBS"; then
3458 AC_MSG_CHECKING([for tgetent()])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003459 AC_LINK_IFELSE([AC_LANG_PROGRAM([int tgetent(char *, const char *);],
3460 [[char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");]])],
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003461 AC_MSG_RESULT(yes),
3462 AC_MSG_ERROR([NOT FOUND!
3463 You need to install a terminal library; for example ncurses.
Bram Moolenaar16678eb2021-04-21 11:57:59 +02003464 On Linux that would be the libncurses-dev package.
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003465 Or specify the name of the library with --with-tlib.]))
3466fi
3467
Bram Moolenaar446cb832008-06-24 21:56:24 +00003468AC_CACHE_CHECK([whether we talk terminfo], [vim_cv_terminfo],
3469 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003470 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003471#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003472#ifdef HAVE_TERMCAP_H
3473# include <termcap.h>
3474#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003475#ifdef HAVE_STRING_H
3476# include <string.h>
3477#endif
3478#if STDC_HEADERS
3479# include <stdlib.h>
3480# include <stddef.h>
3481#endif
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01003482int main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003483{char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003484 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003485 vim_cv_terminfo=no
3486 ],[
3487 vim_cv_terminfo=yes
3488 ],[
3489 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_terminfo')
3490 ])
3491 ])
3492
3493if test "x$vim_cv_terminfo" = "xyes" ; then
3494 AC_DEFINE(TERMINFO)
3495fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003496
Bram Moolenaara88254f2017-11-02 23:04:14 +01003497AC_CACHE_CHECK([what tgetent() returns for an unknown terminal], [vim_cv_tgetent],
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003498 [
3499 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003500#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003501#ifdef HAVE_TERMCAP_H
3502# include <termcap.h>
3503#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003504#if STDC_HEADERS
3505# include <stdlib.h>
3506# include <stddef.h>
3507#endif
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01003508int main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003509{char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003510 ]])],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003511 vim_cv_tgetent=zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003512 ],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003513 vim_cv_tgetent=non-zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003514 ],[
3515 AC_MSG_ERROR(failed to compile test program.)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003516 ])
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003517 ])
3518
Bram Moolenaara88254f2017-11-02 23:04:14 +01003519if test "x$vim_cv_tgetent" = "xzero" ; then
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003520 AC_DEFINE(TGETENT_ZERO_ERR, 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003521fi
3522
3523AC_MSG_CHECKING(whether termcap.h contains ospeed)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003524AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003525#ifdef HAVE_TERMCAP_H
3526# include <termcap.h>
3527#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003528 ], [ospeed = 20000])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003529 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED),
3530 [AC_MSG_RESULT(no)
3531 AC_MSG_CHECKING(whether ospeed can be extern)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003532 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003533#ifdef HAVE_TERMCAP_H
3534# include <termcap.h>
3535#endif
3536extern short ospeed;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003537 ], [ospeed = 20000])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003538 AC_MSG_RESULT(yes); AC_DEFINE(OSPEED_EXTERN),
3539 AC_MSG_RESULT(no))]
3540 )
3541
3542AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003543AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003544#ifdef HAVE_TERMCAP_H
3545# include <termcap.h>
3546#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003547 ], [if (UP == 0 && BC == 0) PC = 1])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003548 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UP_BC_PC),
3549 [AC_MSG_RESULT(no)
3550 AC_MSG_CHECKING([whether UP, BC and PC can be extern])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003551 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003552#ifdef HAVE_TERMCAP_H
3553# include <termcap.h>
3554#endif
3555extern char *UP, *BC, PC;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003556 ], [if (UP == 0 && BC == 0) PC = 1])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003557 AC_MSG_RESULT(yes); AC_DEFINE(UP_BC_PC_EXTERN),
3558 AC_MSG_RESULT(no))]
3559 )
3560
3561AC_MSG_CHECKING(whether tputs() uses outfuntype)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003562AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003563#ifdef HAVE_TERMCAP_H
3564# include <termcap.h>
3565#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003566 ], [extern int xx(); tputs("test", 1, (outfuntype)xx)])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003567 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OUTFUNTYPE),
3568 AC_MSG_RESULT(no))
3569
Bram Moolenaarb3a29552021-11-19 11:28:04 +00003570AC_MSG_CHECKING([whether del_curterm() can be used])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003571AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaarb3a29552021-11-19 11:28:04 +00003572#ifdef HAVE_TERMCAP_H
3573# include <termcap.h>
3574#endif
3575#include <term.h>
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003576 ], [if (cur_term) del_curterm(cur_term);])],
Bram Moolenaarb3a29552021-11-19 11:28:04 +00003577 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DEL_CURTERM),
3578 AC_MSG_RESULT(no))
3579
Bram Moolenaar071d4272004-06-13 20:20:40 +00003580dnl On some SCO machines sys/select redefines struct timeval
3581AC_MSG_CHECKING([whether sys/select.h and sys/time.h may both be included])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003582AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003583#include <sys/types.h>
3584#include <sys/time.h>
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003585#include <sys/select.h>], )],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003586 AC_MSG_RESULT(yes)
3587 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME),
3588 AC_MSG_RESULT(no))
3589
3590dnl AC_DECL_SYS_SIGLIST
3591
3592dnl Checks for pty.c (copied from screen) ==========================
3593AC_MSG_CHECKING(for /dev/ptc)
3594if test -r /dev/ptc; then
3595 AC_DEFINE(HAVE_DEV_PTC)
3596 AC_MSG_RESULT(yes)
3597else
3598 AC_MSG_RESULT(no)
3599fi
3600
3601AC_MSG_CHECKING(for SVR4 ptys)
3602if test -c /dev/ptmx ; then
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003603 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaarce7be3a2020-11-26 20:11:11 +01003604// These should be in stdlib.h, but it depends on _XOPEN_SOURCE.
3605char *ptsname(int);
3606int unlockpt(int);
3607int grantpt(int);
3608 ], [
3609 ptsname(0);
3610 grantpt(0);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003611 unlockpt(0);])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003612 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SVR4_PTYS),
3613 AC_MSG_RESULT(no))
3614else
3615 AC_MSG_RESULT(no)
3616fi
3617
3618AC_MSG_CHECKING(for ptyranges)
3619if test -d /dev/ptym ; then
3620 pdir='/dev/ptym'
3621else
3622 pdir='/dev'
3623fi
3624dnl SCO uses ptyp%d
3625AC_EGREP_CPP(yes,
3626[#ifdef M_UNIX
3627 yes;
3628#endif
3629 ], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
3630dnl if test -c /dev/ptyp19; then
3631dnl ptys=`echo /dev/ptyp??`
3632dnl else
3633dnl ptys=`echo $pdir/pty??`
3634dnl fi
3635if test "$ptys" != "$pdir/pty??" ; then
3636 p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
3637 p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'`
3638 AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
3639 AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
3640 AC_MSG_RESULT([$p0 / $p1])
3641else
3642 AC_MSG_RESULT([don't know])
3643fi
3644
Bram Moolenaar071d4272004-06-13 20:20:40 +00003645dnl Checks for library functions. ===================================
3646
Bram Moolenaar071d4272004-06-13 20:20:40 +00003647dnl check if struct sigcontext is defined (used for SGI only)
3648AC_MSG_CHECKING(for struct sigcontext)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003649AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003650#include <signal.h>
Sam Jamesf8ea1062022-11-05 15:13:50 +00003651int test_sig()
Bram Moolenaar071d4272004-06-13 20:20:40 +00003652{
3653 struct sigcontext *scont;
3654 scont = (struct sigcontext *)0;
3655 return 1;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003656} ], )],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003657 AC_MSG_RESULT(yes)
3658 AC_DEFINE(HAVE_SIGCONTEXT),
3659 AC_MSG_RESULT(no))
3660
3661dnl tricky stuff: try to find out if getcwd() is implemented with
3662dnl system("sh -c pwd")
Bram Moolenaar446cb832008-06-24 21:56:24 +00003663AC_CACHE_CHECK([getcwd implementation is broken], [vim_cv_getcwd_broken],
3664 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003665 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003666#include "confdefs.h"
3667#ifdef HAVE_UNISTD_H
3668#include <unistd.h>
3669#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003670char *dagger[] = { "IFS=pwd", 0 };
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01003671int main()
Bram Moolenaar071d4272004-06-13 20:20:40 +00003672{
3673 char buffer[500];
3674 extern char **environ;
3675 environ = dagger;
3676 return getcwd(buffer, 500) ? 0 : 1;
Bram Moolenaar446cb832008-06-24 21:56:24 +00003677}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003678 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003679 vim_cv_getcwd_broken=no
3680 ],[
3681 vim_cv_getcwd_broken=yes
3682 ],[
3683 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_getcwd_broken')
3684 ])
3685 ])
3686
3687if test "x$vim_cv_getcwd_broken" = "xyes" ; then
3688 AC_DEFINE(BAD_GETCWD)
Bram Moolenaar63d25552019-05-10 21:28:38 +02003689 AC_CHECK_FUNCS(getwd)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003690fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003691
Bram Moolenaar25153e12010-02-24 14:47:08 +01003692dnl Check for functions in one big call, to reduce the size of configure.
3693dnl Can only be used for functions that do not require any include.
Bram Moolenaarcd142e32017-11-16 17:03:45 +01003694AC_CHECK_FUNCS(fchdir fchown fchmod fsync getcwd getpseudotty \
Bram Moolenaar63d25552019-05-10 21:28:38 +02003695 getpwent getpwnam getpwuid getrlimit gettimeofday localtime_r lstat \
Bram Moolenaareaf03392009-11-17 11:08:52 +00003696 memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
Bram Moolenaar2fcf6682017-03-11 20:03:42 +01003697 getpgid setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
Bram Moolenaar84cf6bd2020-06-16 20:03:43 +02003698 sigprocmask sigvec strcasecmp strcoll strerror strftime stricmp strncasecmp \
Bram Moolenaar10455d42019-11-21 15:36:18 +01003699 strnicmp strpbrk strptime strtol tgetent towlower towupper iswupper \
3700 tzset usleep utime utimes mblen ftruncate unsetenv posix_openpt)
Bram Moolenaar643b6142018-09-12 20:29:09 +02003701AC_FUNC_SELECT_ARGTYPES
Bram Moolenaar25153e12010-02-24 14:47:08 +01003702AC_FUNC_FSEEKO
Bram Moolenaar071d4272004-06-13 20:20:40 +00003703
Bram Moolenaar317fd3a2010-05-07 16:05:55 +02003704dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when
3705dnl appropriate, so that off_t is 64 bits when needed.
3706AC_SYS_LARGEFILE
3707
Bram Moolenaar21606672019-06-14 20:40:58 +02003708AC_MSG_CHECKING(--enable-canberra argument)
3709AC_ARG_ENABLE(canberra,
3710 [ --disable-canberra Do not use libcanberra.],
3711 , [enable_canberra="maybe"])
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003712
Bram Moolenaar21606672019-06-14 20:40:58 +02003713if test "$enable_canberra" = "maybe"; then
Martin Tournoij25f3a142022-10-08 19:26:41 +01003714 if test "$features" = "huge"; then
Bram Moolenaar21606672019-06-14 20:40:58 +02003715 AC_MSG_RESULT(Defaulting to yes)
3716 enable_canberra="yes"
3717 else
3718 AC_MSG_RESULT(Defaulting to no)
3719 enable_canberra="no"
3720 fi
3721else
Bram Moolenaar12471262022-01-18 11:11:25 +00003722 if test "$enable_canberra" = "yes" -a "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +01003723 AC_MSG_RESULT([cannot use sound with tiny features])
Bram Moolenaar12471262022-01-18 11:11:25 +00003724 enable_canberra="no"
3725 else
3726 AC_MSG_RESULT($enable_canberra)
3727 fi
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003728fi
Bram Moolenaar21606672019-06-14 20:40:58 +02003729if test "$enable_canberra" = "yes"; then
3730 if test "x$PKG_CONFIG" != "xno"; then
3731 canberra_lib=`$PKG_CONFIG --libs libcanberra 2>/dev/null`
3732 canberra_cflags=`$PKG_CONFIG --cflags libcanberra 2>/dev/null`
3733 fi
3734 if test "x$canberra_lib" = "x"; then
3735 canberra_lib=-lcanberra
3736 canberra_cflags=-D_REENTRANT
3737 fi
3738 AC_MSG_CHECKING(for libcanberra)
3739 ac_save_CFLAGS="$CFLAGS"
3740 ac_save_LIBS="$LIBS"
Bram Moolenaar12471262022-01-18 11:11:25 +00003741 if `echo "$CFLAGS" | grep -v "$canberra_cflags" 2>/dev/null`; then
Christian Brabandt6b9efdd2021-09-09 17:14:50 +02003742 CFLAGS="$CFLAGS $canberra_cflags"
3743 fi
Bram Moolenaar21606672019-06-14 20:40:58 +02003744 LIBS="$LIBS $canberra_lib"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003745 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar21606672019-06-14 20:40:58 +02003746 # include <canberra.h>
3747 ], [
3748 ca_context *hello;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003749 ca_context_create(&hello);])],
Bram Moolenaar21606672019-06-14 20:40:58 +02003750 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_CANBERRA),
Bram Moolenaar91b992c2019-11-17 19:07:42 +01003751 AC_MSG_RESULT(no; try installing libcanberra-dev); CFLAGS="$ac_save_CFLAGS"; LIBS="$ac_save_LIBS")
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003752fi
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003753
Christian Brabandtf573c6e2021-06-20 14:02:16 +02003754AC_MSG_CHECKING(--enable-libsodium argument)
3755AC_ARG_ENABLE(libsodium,
3756 [ --disable-libsodium Do not use libsodium.],
3757 , [enable_libsodium="maybe"])
3758
3759if test "$enable_libsodium" = "maybe"; then
Martin Tournoij25f3a142022-10-08 19:26:41 +01003760 if test "$features" = "huge"; then
Christian Brabandtf573c6e2021-06-20 14:02:16 +02003761 AC_MSG_RESULT(Defaulting to yes)
3762 enable_libsodium="yes"
3763 else
3764 AC_MSG_RESULT(Defaulting to no)
3765 enable_libsodium="no"
3766 fi
3767else
3768 AC_MSG_RESULT($enable_libsodium)
3769fi
3770if test "$enable_libsodium" = "yes"; then
3771 if test "x$PKG_CONFIG" != "xno"; then
3772 libsodium_lib=`$PKG_CONFIG --libs libsodium 2>/dev/null`
3773 libsodium_cflags=`$PKG_CONFIG --cflags libsodium 2>/dev/null`
3774 fi
3775 if test "x$libsodium_lib" = "x"; then
3776 libsodium_lib=-lsodium
3777 libsodium_cflags=
3778 fi
ichizok8ce3ca82021-06-23 15:41:52 +02003779 AC_MSG_CHECKING(for libsodium)
Christian Brabandtf573c6e2021-06-20 14:02:16 +02003780 ac_save_CFLAGS="$CFLAGS"
3781 ac_save_LIBS="$LIBS"
3782 CFLAGS="$CFLAGS $libsodium_cflags"
3783 LIBS="$LIBS $libsodium_lib"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003784 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Christian Brabandtf573c6e2021-06-20 14:02:16 +02003785 # include <sodium.h>
3786 ], [
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003787 printf("%d", sodium_init()); ])],
Christian Brabandtf573c6e2021-06-20 14:02:16 +02003788 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SODIUM),
3789 AC_MSG_RESULT(no; try installing libsodium-dev); CFLAGS="$ac_save_CFLAGS"; LIBS="$ac_save_LIBS")
3790fi
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003791
Bram Moolenaar071d4272004-06-13 20:20:40 +00003792dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible
3793AC_MSG_CHECKING(for st_blksize)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003794AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00003795[#include <sys/types.h>
3796#include <sys/stat.h>],
3797[ struct stat st;
3798 int n;
3799
3800 stat("/", &st);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003801 n = (int)st.st_blksize;])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003802 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ST_BLKSIZE),
3803 AC_MSG_RESULT(no))
3804
Paul Ollis65745772022-06-05 16:55:54 +01003805dnl Check for timer_create. It probably requires the 'rt' library.
Bram Moolenaarf2ce76a2022-07-02 11:40:40 +01003806dnl Run the program to find out if timer_create(CLOCK_MONOTONIC) actually
3807dnl works, on Solaris timer_create() exists but fails at runtime.
Bram Moolenaarefffa532022-07-28 22:39:54 +01003808AC_CACHE_CHECK([for timer_create without -lrt], [vim_cv_timer_create], [
Bram Moolenaarf2ce76a2022-07-02 11:40:40 +01003809AC_RUN_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar5748b7f2022-07-28 12:09:04 +01003810#if STDC_HEADERS
3811# include <stdlib.h>
3812# include <stddef.h>
3813#endif
3814#include <signal.h>
3815#include <time.h>
Bram Moolenaare5303952022-06-19 17:05:47 +01003816static void set_flag(union sigval sv) {}
Paul Ollis65745772022-06-05 16:55:54 +01003817], [
3818 struct timespec ts;
3819 struct sigevent action = {0};
3820 timer_t timer_id;
3821
3822 action.sigev_notify = SIGEV_THREAD;
3823 action.sigev_notify_function = set_flag;
Bram Moolenaarf2ce76a2022-07-02 11:40:40 +01003824 if (timer_create(CLOCK_MONOTONIC, &action, &timer_id) < 0)
3825 exit(1); // cannot create a monotonic timer
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003826 ])],
Bram Moolenaarefffa532022-07-28 22:39:54 +01003827 vim_cv_timer_create=yes,
3828 vim_cv_timer_create=no,
Bram Moolenaar5f6cae82022-07-30 11:00:50 +01003829 AC_MSG_WARN([failed to build test program; if cross-compiling please set 'vim_cv_timer_create'])
Bram Moolenaarefffa532022-07-28 22:39:54 +01003830 )])
Paul Ollis65745772022-06-05 16:55:54 +01003831
Bram Moolenaarefffa532022-07-28 22:39:54 +01003832dnl If the previous failed, check for timer_create() and linking with -lrt.
3833if test "x$vim_cv_timer_create" = "xno" ; then
3834 save_LIBS="$LIBS"
3835 LIBS="$LIBS -lrt"
3836 AC_CACHE_CHECK([for timer_create with -lrt], [vim_cv_timer_create_with_lrt], [
3837 AC_RUN_IFELSE([AC_LANG_PROGRAM([
3838 #if STDC_HEADERS
3839 # include <stdlib.h>
3840 # include <stddef.h>
3841 #endif
3842 #include <signal.h>
3843 #include <time.h>
3844 static void set_flag(union sigval sv) {}
3845 ], [
3846 struct timespec ts;
3847 struct sigevent action = {0};
3848 timer_t timer_id;
3849
3850 action.sigev_notify = SIGEV_THREAD;
3851 action.sigev_notify_function = set_flag;
3852 if (timer_create(CLOCK_MONOTONIC, &action, &timer_id) < 0)
3853 exit(1); // cannot create a monotonic timer
3854 ])],
3855 vim_cv_timer_create_with_lrt=yes,
3856 vim_cv_timer_create_with_lrt=no,
Bram Moolenaar5f6cae82022-07-30 11:00:50 +01003857 AC_MSG_WARN([failed to build test program; if cross-compiling please set 'vim_cv_timer_create_with_lrt'])
Bram Moolenaarefffa532022-07-28 22:39:54 +01003858 )])
3859 LIBS="$save_LIBS"
3860else
3861 vim_cv_timer_create_with_lrt=no
3862fi
Richard Purdie509695c2022-07-24 20:48:00 +01003863
3864if test "x$vim_cv_timer_create" = "xyes" ; then
3865 AC_DEFINE(HAVE_TIMER_CREATE)
3866fi
Bram Moolenaarefffa532022-07-28 22:39:54 +01003867if test "x$vim_cv_timer_create_with_lrt" = "xyes" ; then
3868 AC_DEFINE(HAVE_TIMER_CREATE)
3869 LIBS="$LIBS -lrt"
3870fi
Paul Ollis65745772022-06-05 16:55:54 +01003871
Bram Moolenaar446cb832008-06-24 21:56:24 +00003872AC_CACHE_CHECK([whether stat() ignores a trailing slash], [vim_cv_stat_ignores_slash],
3873 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003874 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003875#include "confdefs.h"
3876#if STDC_HEADERS
3877# include <stdlib.h>
3878# include <stddef.h>
3879#endif
3880#include <sys/types.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003881#include <sys/stat.h>
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01003882int main() {struct stat st; exit(stat("configure/", &st) != 0); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003883 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003884 vim_cv_stat_ignores_slash=yes
3885 ],[
3886 vim_cv_stat_ignores_slash=no
3887 ],[
3888 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_stat_ignores_slash')
3889 ])
3890 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003891
Bram Moolenaar446cb832008-06-24 21:56:24 +00003892if test "x$vim_cv_stat_ignores_slash" = "xyes" ; then
3893 AC_DEFINE(STAT_IGNORES_SLASH)
3894fi
Leah Neukirchen0a7984a2021-10-14 21:27:55 +01003895
3896dnl nanoseconds field of struct stat
3897AC_CACHE_CHECK([for nanoseconds field of struct stat],
3898 ac_cv_struct_st_mtim_nsec,
3899 [ac_save_CPPFLAGS="$CPPFLAGS"
3900 ac_cv_struct_st_mtim_nsec=no
3901 # st_mtim.tv_nsec -- the usual case
3902 # st_mtim._tv_nsec -- Solaris 2.6, if
3903 # (defined _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED == 1
3904 # && !defined __EXTENSIONS__)
3905 # st_mtim.st__tim.tv_nsec -- UnixWare 2.1.2
3906 # st_mtime_n -- AIX 5.2 and above
3907 # st_mtimespec.tv_nsec -- Darwin (Mac OSX)
3908 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
3909 CPPFLAGS="$ac_save_CPPFLAGS -DST_MTIM_NSEC=$ac_val"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003910 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
3911#include <sys/stat.h>], [struct stat s; s.ST_MTIM_NSEC;])],
Leah Neukirchen0a7984a2021-10-14 21:27:55 +01003912 [ac_cv_struct_st_mtim_nsec=$ac_val; break])
3913 done
3914 CPPFLAGS="$ac_save_CPPFLAGS"
3915])
3916if test $ac_cv_struct_st_mtim_nsec != no; then
3917 AC_DEFINE_UNQUOTED([ST_MTIM_NSEC], [$ac_cv_struct_st_mtim_nsec],
3918 [Define if struct stat contains a nanoseconds field])
3919fi
Bram Moolenaare5303952022-06-19 17:05:47 +01003920
Bram Moolenaar071d4272004-06-13 20:20:40 +00003921dnl Link with iconv for charset translation, if not found without library.
3922dnl check for iconv() requires including iconv.h
3923dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
3924dnl has been installed.
3925AC_MSG_CHECKING(for iconv_open())
3926save_LIBS="$LIBS"
3927LIBS="$LIBS -liconv"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003928AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003929#ifdef HAVE_ICONV_H
3930# include <iconv.h>
3931#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003932 ], [iconv_open("fr", "to");])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003933 AC_MSG_RESULT(yes; with -liconv); AC_DEFINE(HAVE_ICONV),
3934 LIBS="$save_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003935 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003936#ifdef HAVE_ICONV_H
3937# include <iconv.h>
3938#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003939 ], [iconv_open("fr", "to");])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003940 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ICONV),
3941 AC_MSG_RESULT(no)))
3942
3943
3944AC_MSG_CHECKING(for nl_langinfo(CODESET))
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003945AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003946#ifdef HAVE_LANGINFO_H
3947# include <langinfo.h>
3948#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003949], [char *cs = nl_langinfo(CODESET);])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003950 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET),
3951 AC_MSG_RESULT(no))
3952
Bram Moolenaar73e28dc2022-09-17 21:08:33 +01003953dnl Floating point support may require the "m" library
Bram Moolenaar446cb832008-06-24 21:56:24 +00003954AC_CHECK_LIB(m, strtod)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003955
Bram Moolenaara6b89762016-02-29 21:38:26 +01003956dnl isinf() and isnan() need to include header files and may need -lm.
3957AC_MSG_CHECKING([for isinf()])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003958AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaara6b89762016-02-29 21:38:26 +01003959#ifdef HAVE_MATH_H
3960# include <math.h>
3961#endif
3962#if STDC_HEADERS
3963# include <stdlib.h>
3964# include <stddef.h>
3965#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003966], [int r = isinf(1.11); ])],
Bram Moolenaara6b89762016-02-29 21:38:26 +01003967 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISINF),
3968 AC_MSG_RESULT(no))
3969
3970AC_MSG_CHECKING([for isnan()])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003971AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaara6b89762016-02-29 21:38:26 +01003972#ifdef HAVE_MATH_H
3973# include <math.h>
3974#endif
3975#if STDC_HEADERS
3976# include <stdlib.h>
3977# include <stddef.h>
3978#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003979], [int r = isnan(1.11); ])],
Bram Moolenaara6b89762016-02-29 21:38:26 +01003980 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISNAN),
3981 AC_MSG_RESULT(no))
3982
Bram Moolenaar071d4272004-06-13 20:20:40 +00003983dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI
3984dnl when -lacl works, also try to use -lattr (required for Debian).
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003985dnl On Solaris, use the acl_get/set functions in libsec, if present.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003986AC_MSG_CHECKING(--disable-acl argument)
3987AC_ARG_ENABLE(acl,
Bram Moolenaard6d30422018-01-28 22:48:55 +01003988 [ --disable-acl No check for ACL support.],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003989 , [enable_acl="yes"])
3990if test "$enable_acl" = "yes"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01003991 AC_MSG_RESULT(no)
3992 AC_CHECK_LIB(posix1e, acl_get_file, [LIBS="$LIBS -lposix1e"],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003993 AC_CHECK_LIB(acl, acl_get_file, [LIBS="$LIBS -lacl"
3994 AC_CHECK_LIB(attr, fgetxattr, LIBS="$LIBS -lattr",,)],,),)
3995
Bram Moolenaard6d30422018-01-28 22:48:55 +01003996 AC_MSG_CHECKING(for POSIX ACL support)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003997 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003998#include <sys/types.h>
3999#ifdef HAVE_SYS_ACL_H
4000# include <sys/acl.h>
4001#endif
4002acl_t acl;], [acl = acl_get_file("foo", ACL_TYPE_ACCESS);
4003 acl_set_file("foo", ACL_TYPE_ACCESS, acl);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004004 acl_free(acl);])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004005 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_ACL),
4006 AC_MSG_RESULT(no))
4007
Bram Moolenaard6d30422018-01-28 22:48:55 +01004008 AC_CHECK_LIB(sec, acl_get, [LIBS="$LIBS -lsec"; AC_DEFINE(HAVE_SOLARIS_ZFS_ACL)],
4009 AC_MSG_CHECKING(for Solaris ACL support)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004010 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00004011#ifdef HAVE_SYS_ACL_H
4012# include <sys/acl.h>
4013#endif], [acl("foo", GETACLCNT, 0, NULL);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004014 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004015 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOLARIS_ACL),
Bram Moolenaar8d462f92012-02-05 22:51:33 +01004016 AC_MSG_RESULT(no)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004017
Bram Moolenaard6d30422018-01-28 22:48:55 +01004018 AC_MSG_CHECKING(for AIX ACL support)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004019 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar446cb832008-06-24 21:56:24 +00004020#if STDC_HEADERS
4021# include <stdlib.h>
4022# include <stddef.h>
4023#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004024#ifdef HAVE_SYS_ACL_H
4025# include <sys/acl.h>
4026#endif
4027#ifdef HAVE_SYS_ACCESS_H
4028# include <sys/access.h>
4029#endif
4030#define _ALL_SOURCE
4031
4032#include <sys/stat.h>
4033
4034int aclsize;
4035struct acl *aclent;], [aclsize = sizeof(struct acl);
4036 aclent = (void *)malloc(aclsize);
4037 statacl("foo", STX_NORMAL, aclent, aclsize);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004038 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004039 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_AIX_ACL),
4040 AC_MSG_RESULT(no))
4041else
4042 AC_MSG_RESULT(yes)
4043fi
4044
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02004045if test "x$GTK_CFLAGS" != "x"; then
4046 dnl pango_shape_full() is new, fall back to pango_shape().
4047 AC_MSG_CHECKING(for pango_shape_full)
4048 ac_save_CFLAGS="$CFLAGS"
4049 ac_save_LIBS="$LIBS"
4050 CFLAGS="$CFLAGS $GTK_CFLAGS"
4051 LIBS="$LIBS $GTK_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004052 AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02004053 [#include <gtk/gtk.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004054 [ pango_shape_full(NULL, 0, NULL, 0, NULL, NULL); ])],
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02004055 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_PANGO_SHAPE_FULL),
4056 AC_MSG_RESULT(no))
4057 CFLAGS="$ac_save_CFLAGS"
4058 LIBS="$ac_save_LIBS"
4059fi
4060
Bram Moolenaar33fc4a62022-02-23 18:07:38 +00004061AC_MSG_CHECKING(--enable-gpm argument)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004062AC_ARG_ENABLE(gpm,
Bram Moolenaar33fc4a62022-02-23 18:07:38 +00004063 [ --enable-gpm=OPTS Use gpm (Linux mouse daemon). default=yes OPTS=yes/no/dynamic], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00004064 [enable_gpm="yes"])
4065
Bram Moolenaar33fc4a62022-02-23 18:07:38 +00004066if test "$enable_gpm" = "yes" -o "$enable_gpm" = "dynamic"; then
4067 AC_MSG_RESULT($enable_gpm)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004068 dnl Checking if gpm support can be compiled
4069 AC_CACHE_CHECK([for gpm], vi_cv_have_gpm,
4070 [olibs="$LIBS" ; LIBS="-lgpm"]
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004071 AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004072 [#include <gpm.h>
4073 #include <linux/keyboard.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004074 [Gpm_GetLibVersion(NULL);])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004075 dnl Configure defines HAVE_GPM, if it is defined feature.h defines
4076 dnl FEAT_MOUSE_GPM if mouse support is included
4077 [vi_cv_have_gpm=yes],
4078 [vi_cv_have_gpm=no])
4079 [LIBS="$olibs"]
4080 )
4081 if test $vi_cv_have_gpm = yes; then
Bram Moolenaar33fc4a62022-02-23 18:07:38 +00004082 if test "$enable_gpm" = "yes"; then
4083 LIBS="$LIBS -lgpm"
4084 else
4085 AC_DEFINE(DYNAMIC_GPM)
4086 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004087 AC_DEFINE(HAVE_GPM)
4088 fi
4089else
Bram Moolenaar33fc4a62022-02-23 18:07:38 +00004090 AC_MSG_RESULT(no)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004091fi
4092
Bram Moolenaar446cb832008-06-24 21:56:24 +00004093AC_MSG_CHECKING(--disable-sysmouse argument)
4094AC_ARG_ENABLE(sysmouse,
Bram Moolenaar8008b632017-07-18 21:33:20 +02004095 [ --disable-sysmouse Don't use sysmouse (mouse in *BSD console).], ,
Bram Moolenaar446cb832008-06-24 21:56:24 +00004096 [enable_sysmouse="yes"])
4097
4098if test "$enable_sysmouse" = "yes"; then
4099 AC_MSG_RESULT(no)
4100 dnl Checking if sysmouse support can be compiled
4101 dnl Configure defines HAVE_SYSMOUSE, if it is defined feature.h
4102 dnl defines FEAT_SYSMOUSE if mouse support is included
4103 AC_CACHE_CHECK([for sysmouse], vi_cv_have_sysmouse,
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004104 AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar446cb832008-06-24 21:56:24 +00004105 [#include <sys/consio.h>
4106 #include <signal.h>
4107 #include <sys/fbio.h>],
4108 [struct mouse_info mouse;
4109 mouse.operation = MOUSE_MODE;
4110 mouse.operation = MOUSE_SHOW;
4111 mouse.u.mode.mode = 0;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004112 mouse.u.mode.signal = SIGUSR2;])],
Bram Moolenaar446cb832008-06-24 21:56:24 +00004113 [vi_cv_have_sysmouse=yes],
4114 [vi_cv_have_sysmouse=no])
4115 )
4116 if test $vi_cv_have_sysmouse = yes; then
4117 AC_DEFINE(HAVE_SYSMOUSE)
4118 fi
4119else
4120 AC_MSG_RESULT(yes)
4121fi
4122
Bram Moolenaarf05da212009-11-17 16:13:15 +00004123dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
4124AC_MSG_CHECKING(for FD_CLOEXEC)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004125AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaarf05da212009-11-17 16:13:15 +00004126[#if HAVE_FCNTL_H
4127# include <fcntl.h>
4128#endif],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004129[ int flag = FD_CLOEXEC;])],
Bram Moolenaarf05da212009-11-17 16:13:15 +00004130 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
4131 AC_MSG_RESULT(not usable))
4132
Bram Moolenaar071d4272004-06-13 20:20:40 +00004133dnl rename needs to be checked separately to work on Nextstep with cc
4134AC_MSG_CHECKING(for rename)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004135AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>], [rename("this", "that")])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004136 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
4137 AC_MSG_RESULT(no))
4138
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004139dnl check for dirfd()
4140AC_MSG_CHECKING(for dirfd)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004141AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004142[#include <sys/types.h>
4143#include <dirent.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004144[DIR * dir=opendir("dirname"); dirfd(dir);])],
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004145AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DIRFD), AC_MSG_RESULT(not usable))
4146
4147dnl check for flock()
4148AC_MSG_CHECKING(for flock)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004149AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004150[#include <sys/file.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004151[flock(10, LOCK_SH);])],
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004152AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOCK), AC_MSG_RESULT(not usable))
4153
Bram Moolenaar071d4272004-06-13 20:20:40 +00004154dnl sysctl() may exist but not the arguments we use
4155AC_MSG_CHECKING(for sysctl)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004156AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004157[#include <sys/types.h>
4158#include <sys/sysctl.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004159[[ int mib[2], r;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004160 size_t len;
4161
4162 mib[0] = CTL_HW;
4163 mib[1] = HW_USERMEM;
4164 len = sizeof(r);
4165 (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004166 ]])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004167 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL),
4168 AC_MSG_RESULT(not usable))
4169
Bram Moolenaare2982d62021-10-06 11:27:21 +01004170dnl sysinfo() may exist but not be Linux compatible.
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004171dnl On some FreeBSD systems it may depend on libsysinfo, try to link
Bram Moolenaar071d4272004-06-13 20:20:40 +00004172AC_MSG_CHECKING(for sysinfo)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004173AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004174[#include <sys/types.h>
4175#include <sys/sysinfo.h>],
4176[ struct sysinfo sinfo;
4177 int t;
4178
4179 (void)sysinfo(&sinfo);
4180 t = sinfo.totalram;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004181 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004182 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
4183 AC_MSG_RESULT(not usable))
4184
Bram Moolenaar914572a2007-05-01 11:37:47 +00004185dnl struct sysinfo may have the mem_unit field or not
4186AC_MSG_CHECKING(for sysinfo.mem_unit)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004187AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar914572a2007-05-01 11:37:47 +00004188[#include <sys/types.h>
4189#include <sys/sysinfo.h>],
4190[ struct sysinfo sinfo;
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02004191 sinfo.mem_unit = 1;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004192 ])],
Bram Moolenaar914572a2007-05-01 11:37:47 +00004193 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_MEM_UNIT),
4194 AC_MSG_RESULT(no))
4195
Bram Moolenaarf52f0602021-03-10 21:26:37 +01004196dnl struct sysinfo may have the uptime field or not
4197AC_MSG_CHECKING(for sysinfo.uptime)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004198AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaarf52f0602021-03-10 21:26:37 +01004199[#include <sys/types.h>
4200#include <sys/sysinfo.h>],
4201[ struct sysinfo sinfo;
4202 long ut;
4203
4204 (void)sysinfo(&sinfo);
4205 ut = sinfo.uptime;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004206 ])],
Bram Moolenaarf52f0602021-03-10 21:26:37 +01004207 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_UPTIME),
4208 AC_MSG_RESULT(no))
4209
Bram Moolenaar071d4272004-06-13 20:20:40 +00004210dnl sysconf() may exist but not support what we want to use
4211AC_MSG_CHECKING(for sysconf)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004212AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004213[#include <unistd.h>],
4214[ (void)sysconf(_SC_PAGESIZE);
4215 (void)sysconf(_SC_PHYS_PAGES);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004216 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004217 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
4218 AC_MSG_RESULT(not usable))
4219
Bram Moolenaar0e62a672021-02-25 17:17:56 +01004220dnl check if we have _SC_SIGSTKSZ via sysconf()
4221AC_MSG_CHECKING(for _SC_SIGSTKSZ via sysconf())
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004222AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar0e62a672021-02-25 17:17:56 +01004223[#include <unistd.h>],
4224[ (void)sysconf(_SC_SIGSTKSZ);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004225 ])],
Bram Moolenaar0e62a672021-02-25 17:17:56 +01004226 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF_SIGSTKSZ),
4227 AC_MSG_RESULT(not usable))
4228
Bram Moolenaar914703b2010-05-31 21:59:46 +02004229AC_CHECK_SIZEOF([int])
4230AC_CHECK_SIZEOF([long])
4231AC_CHECK_SIZEOF([time_t])
4232AC_CHECK_SIZEOF([off_t])
Bram Moolenaar644fdff2010-05-30 13:26:21 +02004233
Bram Moolenaara2aa31a2014-02-23 22:52:40 +01004234dnl Use different names to avoid clashing with other header files.
4235AC_DEFINE_UNQUOTED(VIM_SIZEOF_INT, [$ac_cv_sizeof_int])
4236AC_DEFINE_UNQUOTED(VIM_SIZEOF_LONG, [$ac_cv_sizeof_long])
4237
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004238dnl Make sure that uint32_t is really 32 bits unsigned.
4239AC_MSG_CHECKING([uint32_t is 32 bits])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004240AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004241#ifdef HAVE_STDINT_H
4242# include <stdint.h>
4243#endif
4244#ifdef HAVE_INTTYPES_H
4245# include <inttypes.h>
4246#endif
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01004247int main() {
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004248 uint32_t nr1 = (uint32_t)-1;
4249 uint32_t nr2 = (uint32_t)0xffffffffUL;
Bram Moolenaar52897832020-07-02 22:50:37 +02004250 if (sizeof(uint32_t) != 4 || nr1 != 0xffffffffUL || nr2 + 1 != 0) return 1;
4251 return 0;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004252}])],
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004253AC_MSG_RESULT(ok),
4254AC_MSG_ERROR([WRONG! uint32_t not defined correctly.]),
Bram Moolenaar323cb952011-12-14 19:22:34 +01004255AC_MSG_WARN([cannot check uint32_t when cross-compiling.]))
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004256
Bram Moolenaar446cb832008-06-24 21:56:24 +00004257dnl Check for memmove() before bcopy(), makes memmove() be used when both are
4258dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
4259
Bram Moolenaar071d4272004-06-13 20:20:40 +00004260[bcopy_test_prog='
Bram Moolenaar446cb832008-06-24 21:56:24 +00004261#include "confdefs.h"
4262#ifdef HAVE_STRING_H
4263# include <string.h>
4264#endif
4265#if STDC_HEADERS
4266# include <stdlib.h>
4267# include <stddef.h>
4268#endif
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01004269int main() {
Bram Moolenaar071d4272004-06-13 20:20:40 +00004270 char buf[10];
4271 strcpy(buf, "abcdefghi");
4272 mch_memmove(buf, buf + 2, 3);
4273 if (strncmp(buf, "ababcf", 6))
4274 exit(1);
4275 strcpy(buf, "abcdefghi");
4276 mch_memmove(buf + 2, buf, 3);
4277 if (strncmp(buf, "cdedef", 6))
4278 exit(1);
4279 exit(0); /* libc version works properly. */
4280}']
4281
Bram Moolenaar446cb832008-06-24 21:56:24 +00004282AC_CACHE_CHECK([whether memmove handles overlaps],[vim_cv_memmove_handles_overlap],
4283 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004284 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 +00004285 [
4286 vim_cv_memmove_handles_overlap=yes
4287 ],[
4288 vim_cv_memmove_handles_overlap=no
4289 ],[
4290 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memmove_handles_overlap')
4291 ])
4292 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00004293
Bram Moolenaar446cb832008-06-24 21:56:24 +00004294if test "x$vim_cv_memmove_handles_overlap" = "xyes" ; then
4295 AC_DEFINE(USEMEMMOVE)
4296else
4297 AC_CACHE_CHECK([whether bcopy handles overlaps],[vim_cv_bcopy_handles_overlap],
4298 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004299 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 +00004300 [
4301 vim_cv_bcopy_handles_overlap=yes
4302 ],[
4303 vim_cv_bcopy_handles_overlap=no
4304 ],[
4305 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_bcopy_handles_overlap')
4306 ])
4307 ])
4308
4309 if test "x$vim_cv_bcopy_handles_overlap" = "xyes" ; then
4310 AC_DEFINE(USEBCOPY)
4311 else
4312 AC_CACHE_CHECK([whether memcpy handles overlaps],[vim_cv_memcpy_handles_overlap],
4313 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004314 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 +00004315 [
4316 vim_cv_memcpy_handles_overlap=yes
4317 ],[
4318 vim_cv_memcpy_handles_overlap=no
4319 ],[
4320 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memcpy_handles_overlap')
4321 ])
4322 ])
4323
4324 if test "x$vim_cv_memcpy_handles_overlap" = "xyes" ; then
4325 AC_DEFINE(USEMEMCPY)
4326 fi
4327 fi
4328fi
4329
Bram Moolenaar071d4272004-06-13 20:20:40 +00004330
4331dnl Check for multibyte locale functions
4332dnl Find out if _Xsetlocale() is supported by libX11.
4333dnl Check if X_LOCALE should be defined.
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004334if test "x$with_x" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004335 cflags_save=$CFLAGS
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004336 libs_save=$LIBS
4337 LIBS="$LIBS $X_LIBS $GUI_LIB_LOC $GUI_X_LIBS $X_PRE_LIBS $X_LIB $X_EXTRA_LIBS"
4338 CFLAGS="$CFLAGS $X_CFLAGS"
4339
4340 AC_MSG_CHECKING(whether X_LOCALE needed)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004341 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <X11/Xlocale.h>],)],
4342 AC_LINK_IFELSE([AC_LANG_CALL([],[_Xsetlocale])], [AC_MSG_RESULT(yes)
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004343 AC_DEFINE(X_LOCALE)], AC_MSG_RESULT(no)),
4344 AC_MSG_RESULT(no))
4345
4346 AC_MSG_CHECKING(whether Xutf8SetWMProperties() can be used)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004347 AC_LINK_IFELSE([AC_LANG_CALL([],[Xutf8SetWMProperties])], [AC_MSG_RESULT(yes)
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004348 AC_DEFINE(HAVE_XUTF8SETWMPROPERTIES)], AC_MSG_RESULT(no))
4349
Bram Moolenaar071d4272004-06-13 20:20:40 +00004350 CFLAGS=$cflags_save
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004351 LIBS=$libs_save
Bram Moolenaar071d4272004-06-13 20:20:40 +00004352fi
4353
4354dnl Link with xpg4, it is said to make Korean locale working
4355AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,)
4356
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004357dnl Check how we can run ctags. Default to "ctags" when nothing works.
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02004358dnl Use --version to detect Exuberant ctags (preferred)
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004359dnl Add --fields=+S to get function signatures for omni completion.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004360dnl -t for typedefs (many ctags have this)
4361dnl -s for static functions (Elvis ctags only?)
4362dnl -v for variables. Dangerous, most ctags take this for 'vgrind style'.
4363dnl -i+m to test for older Exuberant ctags
4364AC_MSG_CHECKING(how to create tags)
4365test -f tags && mv tags tags.save
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004366if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004367 TAGPRG="ctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004368elif (eval exctags --version /dev/null | grep Exuberant) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004369 TAGPRG="exctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004370elif (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 +01004371 TAGPRG="exuberant-ctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004372else
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004373 TAGPRG="ctags"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004374 (eval etags /dev/null) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1 && TAGPRG="etags"
4375 (eval etags -c /dev/null) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1 && TAGPRG="etags -c"
4376 (eval ctags /dev/null) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1 && TAGPRG="ctags"
4377 (eval ctags -t /dev/null) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1 && TAGPRG="ctags -t"
4378 (eval ctags -ts /dev/null) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1 && TAGPRG="ctags -ts"
4379 (eval ctags -tvs /dev/null) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1 && TAGPRG="ctags -tvs"
4380 (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 +00004381fi
4382test -f tags.save && mv tags.save tags
4383AC_MSG_RESULT($TAGPRG) AC_SUBST(TAGPRG)
4384
4385dnl Check how we can run man with a section number
4386AC_MSG_CHECKING(how to run man with a section nr)
4387MANDEF="man"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004388(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 +00004389AC_MSG_RESULT($MANDEF)
4390if test "$MANDEF" = "man -s"; then
4391 AC_DEFINE(USEMAN_S)
4392fi
4393
4394dnl Check if gettext() is working and if it needs -lintl
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004395dnl We take care to base this on an empty LIBS: on some systems libelf would be
4396dnl in LIBS and implicitly take along libintl. The final LIBS would then not
4397dnl contain libintl, and the link step would fail due to -Wl,--as-needed.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004398AC_MSG_CHECKING(--disable-nls argument)
4399AC_ARG_ENABLE(nls,
4400 [ --disable-nls Don't support NLS (gettext()).], ,
4401 [enable_nls="yes"])
4402
4403if test "$enable_nls" = "yes"; then
4404 AC_MSG_RESULT(no)
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00004405
4406 INSTALL_LANGS=install-languages
4407 AC_SUBST(INSTALL_LANGS)
4408 INSTALL_TOOL_LANGS=install-tool-languages
4409 AC_SUBST(INSTALL_TOOL_LANGS)
4410
Bram Moolenaar071d4272004-06-13 20:20:40 +00004411 AC_CHECK_PROG(MSGFMT, msgfmt, msgfmt, )
4412 AC_MSG_CHECKING([for NLS])
4413 if test -f po/Makefile; then
4414 have_gettext="no"
4415 if test -n "$MSGFMT"; then
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004416 olibs=$LIBS
4417 LIBS=""
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004418 AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004419 [#include <libintl.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004420 [gettext("Test");])],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004421 AC_MSG_RESULT([gettext() works]); have_gettext="yes"; LIBS=$olibs,
4422 LIBS="-lintl"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004423 AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004424 [#include <libintl.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004425 [gettext("Test");])],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004426 AC_MSG_RESULT([gettext() works with -lintl]); have_gettext="yes";
4427 LIBS="$olibs -lintl",
Bram Moolenaar071d4272004-06-13 20:20:40 +00004428 AC_MSG_RESULT([gettext() doesn't work]);
4429 LIBS=$olibs))
4430 else
4431 AC_MSG_RESULT([msgfmt not found - disabled]);
4432 fi
Martin Tournoij7904fa42022-10-04 16:28:45 +01004433 if test $have_gettext = "yes" -a "x$features" != "xtiny"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004434 AC_DEFINE(HAVE_GETTEXT)
4435 MAKEMO=yes
4436 AC_SUBST(MAKEMO)
4437 dnl this was added in GNU gettext 0.10.36
4438 AC_CHECK_FUNCS(bind_textdomain_codeset)
4439 dnl _nl_msg_cat_cntr is required for GNU gettext
4440 AC_MSG_CHECKING([for _nl_msg_cat_cntr])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004441 AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004442 [#include <libintl.h>
4443 extern int _nl_msg_cat_cntr;],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004444 [++_nl_msg_cat_cntr;])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004445 AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_NL_MSG_CAT_CNTR),
4446 AC_MSG_RESULT([no]))
Bram Moolenaar26096cc2019-04-11 15:25:40 +02004447 AC_MSG_CHECKING([if msgfmt supports --desktop])
4448 MSGFMT_DESKTOP=
4449 if "$MSGFMT" --help | grep -e '--desktop' >/dev/null; then
Bram Moolenaar62a88f42019-06-07 20:44:40 +02004450 if "$MSGFMT" --version | grep '0.19.[[3-7]]$' >/dev/null; then
4451 dnl GNU gettext 0.19.7's --desktop is broken. We assume back to
4452 dnl 0.19.3 is also broken.
4453 AC_MSG_RESULT([broken])
4454 else
4455 AC_MSG_RESULT([yes])
4456 MSGFMT_DESKTOP="gvim.desktop vim.desktop"
4457 fi
Bram Moolenaar26096cc2019-04-11 15:25:40 +02004458 else
4459 AC_MSG_RESULT([no])
4460 fi
4461 AC_SUBST(MSGFMT_DESKTOP)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004462 fi
4463 else
4464 AC_MSG_RESULT([no "po/Makefile" - disabled]);
4465 fi
4466else
4467 AC_MSG_RESULT(yes)
4468fi
4469
4470dnl Check for dynamic linking loader
4471AC_CHECK_HEADER(dlfcn.h, DLL=dlfcn.h, [AC_CHECK_HEADER(dl.h, DLL=dl.h)])
4472if test x${DLL} = xdlfcn.h; then
4473 AC_DEFINE(HAVE_DLFCN_H, 1, [ Define if we have dlfcn.h. ])
4474 AC_MSG_CHECKING([for dlopen()])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004475 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004476 extern void* dlopen();
4477 dlopen();
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004478 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004479 AC_MSG_RESULT(yes);
4480 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4481 AC_MSG_RESULT(no);
4482 AC_MSG_CHECKING([for dlopen() in -ldl])
4483 olibs=$LIBS
4484 LIBS="$LIBS -ldl"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004485 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004486 extern void* dlopen();
4487 dlopen();
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004488 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004489 AC_MSG_RESULT(yes);
4490 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4491 AC_MSG_RESULT(no);
4492 LIBS=$olibs))
4493 dnl ReliantUNIX has dlopen() in libc but everything else in libdl
4494 dnl ick :-)
4495 AC_MSG_CHECKING([for dlsym()])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004496 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004497 extern void* dlsym();
4498 dlsym();
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004499 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004500 AC_MSG_RESULT(yes);
4501 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4502 AC_MSG_RESULT(no);
4503 AC_MSG_CHECKING([for dlsym() in -ldl])
4504 olibs=$LIBS
4505 LIBS="$LIBS -ldl"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004506 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004507 extern void* dlsym();
4508 dlsym();
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004509 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004510 AC_MSG_RESULT(yes);
4511 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4512 AC_MSG_RESULT(no);
4513 LIBS=$olibs))
4514elif test x${DLL} = xdl.h; then
4515 AC_DEFINE(HAVE_DL_H, 1, [ Define if we have dl.h. ])
4516 AC_MSG_CHECKING([for shl_load()])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004517 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004518 extern void* shl_load();
4519 shl_load();
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004520 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004521 AC_MSG_RESULT(yes);
4522 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4523 AC_MSG_RESULT(no);
4524 AC_MSG_CHECKING([for shl_load() in -ldld])
4525 olibs=$LIBS
4526 LIBS="$LIBS -ldld"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004527 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004528 extern void* shl_load();
4529 shl_load();
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004530 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004531 AC_MSG_RESULT(yes);
4532 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4533 AC_MSG_RESULT(no);
4534 LIBS=$olibs))
4535fi
4536AC_CHECK_HEADERS(setjmp.h)
4537
Bram Moolenaard0573012017-10-28 21:11:06 +02004538if test "x$MACOS_X" = "xyes" -a -n "$PERL"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004539 dnl -ldl must come after DynaLoader.a
4540 if echo $LIBS | grep -e '-ldl' >/dev/null; then
4541 LIBS=`echo $LIBS | sed s/-ldl//`
4542 PERL_LIBS="$PERL_LIBS -ldl"
4543 fi
4544fi
4545
Bram Moolenaard0573012017-10-28 21:11:06 +02004546if test "$MACOS_X" = "yes"; then
4547 AC_MSG_CHECKING([whether we need macOS frameworks])
Bram Moolenaar097148e2020-08-11 21:58:20 +02004548 if test "$MACOS_X_DARWIN" = "yes"; then
Bram Moolenaard0573012017-10-28 21:11:06 +02004549 if test "$features" = "tiny"; then
Yee Cheng Chin4314e4f2022-10-08 13:50:05 +01004550 dnl Since no FEAT_CLIPBOARD or FEAT_SOUND, no need for os_macosx.m.
Bram Moolenaard0573012017-10-28 21:11:06 +02004551 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_macosx.m++'`
4552 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_macosx.o++'`
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01004553 AC_MSG_RESULT([yes, we need CoreServices])
4554 LIBS="$LIBS -framework CoreServices"
Bram Moolenaard0573012017-10-28 21:11:06 +02004555 else
4556 AC_MSG_RESULT([yes, we need AppKit])
4557 LIBS="$LIBS -framework AppKit"
Bram Moolenaard0573012017-10-28 21:11:06 +02004558 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004559 else
Bram Moolenaard0573012017-10-28 21:11:06 +02004560 AC_MSG_RESULT([no])
Bram Moolenaar3437b912013-07-03 19:52:53 +02004561 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004562fi
4563
Bram Moolenaar3ae5fc92021-09-06 18:57:30 +02004564dnl On some systems REENTRANT needs to be defined. It should not hurt to use
4565dnl it everywhere.
4566if `echo "$CFLAGS" | grep -v D_REENTRANT >/dev/null`; then
4567 CFLAGS="$CFLAGS -D_REENTRANT"
4568fi
4569
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004570dnl gcc 3.1 changed the meaning of -MM. The only solution appears to be to
4571dnl use "-isystem" instead of "-I" for all non-Vim include dirs.
4572dnl But only when making dependencies, cproto and lint don't take "-isystem".
Bram Moolenaar32466aa2006-02-24 23:53:04 +00004573dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
4574dnl the number before the version number.
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004575DEPEND_CFLAGS_FILTER=
4576if test "$GCC" = yes; then
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004577 AC_MSG_CHECKING(for GCC 3 or later)
Bram Moolenaar348808f2020-02-07 20:50:07 +01004578 gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]][[0-9]]*\)\..*$/\1/g'`
Bram Moolenaarf740b292006-02-16 22:11:02 +00004579 if test "$gccmajor" -gt "2"; then
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004580 DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004581 AC_MSG_RESULT(yes)
4582 else
4583 AC_MSG_RESULT(no)
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004584 fi
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004585 dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
4586 dnl declared as char x[1] but actually longer. Introduced in gcc 4.0.
Bram Moolenaar56d1db32009-12-16 16:14:51 +00004587 dnl Also remove duplicate _FORTIFY_SOURCE arguments.
Bram Moolenaaraeabe052011-12-08 15:17:34 +01004588 dnl And undefine it first to avoid a warning.
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004589 AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
4590 if test "$gccmajor" -gt "3"; then
Bram Moolenaar26f20132021-04-03 17:33:52 +02004591 CFLAGS=`echo "$CFLAGS" | sed -e 's/-D_FORTIFY_SOURCE=.,//g' -e 's/ *-Wp,-D_FORTIFY_SOURCE=. / /g' -e 's/,-D_FORTIFY_SOURCE=. //g' -e 's/ *-D_FORTIFY_SOURCE=.//g' -e 's/ *-U_FORTIFY_SOURCE//g' -e 's/$/ -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1/'`
4592 CPPFLAGS=`echo "$CPPFLAGS" | sed -e 's/-D_FORTIFY_SOURCE=.,//g' -e 's/ *-Wp,-D_FORTIFY_SOURCE=. / /g' -e 's/,-D_FORTIFY_SOURCE=. //g' -e 's/ *-D_FORTIFY_SOURCE=.//g' -e 's/ *-U_FORTIFY_SOURCE//g'`
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004593 AC_MSG_RESULT(yes)
4594 else
4595 AC_MSG_RESULT(no)
4596 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +00004597fi
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004598AC_SUBST(DEPEND_CFLAGS_FILTER)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004599
Bram Moolenaarec0557f2018-01-31 14:41:37 +01004600dnl On some systems AC_SYS_LARGEFILE determines that -D_FILE_OFFSET_BITS=64
4601dnl isn't required, but the CFLAGS for some of the libraries we're using
4602dnl include the define. Since the define changes the size of some datatypes
4603dnl (e.g. ino_t and off_t), all of Vim's modules must be compiled with a
4604dnl consistent value. It's therefore safest to force the use of the define
4605dnl if it's present in any of the *_CFLAGS variables.
4606AC_MSG_CHECKING(whether we need to force -D_FILE_OFFSET_BITS=64)
Bram Moolenaar9ce42132018-04-11 22:19:36 +02004607if 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 +01004608 AC_MSG_RESULT(yes)
4609 AC_DEFINE(_FILE_OFFSET_BITS, 64)
4610else
4611 AC_MSG_RESULT(no)
4612fi
4613
Bram Moolenaar6cd42db2020-12-04 18:09:54 +01004614dnl $LDFLAGS is passed to glibtool in libvterm, it doesn't like a space
4615dnl between "-L" and the path that follows.
4616LDFLAGS=`echo "$LDFLAGS" | sed -e 's/-L /-L/g'`
4617
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004618dnl link.sh tries to avoid overlinking in a hackish way.
4619dnl At least GNU ld supports --as-needed which provides the same functionality
4620dnl at linker level. Let's use it.
4621AC_MSG_CHECKING(linker --as-needed support)
4622LINK_AS_NEEDED=
4623# Check if linker supports --as-needed and --no-as-needed options
4624if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
Natanael Copa761ead42021-05-15 14:25:37 +02004625 if ! echo "$LDFLAGS" | grep -q -- '-Wl,[[^[:space:]]]*--as-needed'; then
4626 LDFLAGS="$LDFLAGS -Wl,--as-needed"
4627 fi
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004628 LINK_AS_NEEDED=yes
4629fi
4630if test "$LINK_AS_NEEDED" = yes; then
4631 AC_MSG_RESULT(yes)
4632else
4633 AC_MSG_RESULT(no)
4634fi
4635AC_SUBST(LINK_AS_NEEDED)
4636
Bram Moolenaar77c19352012-06-13 19:19:41 +02004637# IBM z/OS reset CFLAGS for config.mk
4638if test "$zOSUnix" = "yes"; then
4639 CFLAGS="-D_ALL_SOURCE -Wc,float\(ieee\),dll"
4640fi
4641
Bram Moolenaar071d4272004-06-13 20:20:40 +00004642dnl write output files
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004643AC_CONFIG_FILES(auto/config.mk:config.mk.in)
4644AC_OUTPUT
Bram Moolenaar071d4272004-06-13 20:20:40 +00004645
4646dnl vim: set sw=2 tw=78 fo+=l: