blob: a5beb834dc6c227395117a25b20242e62bef7c94 [file] [log] [blame]
Bram Moolenaar3f7d0902016-11-12 21:13:42 +01001dnl configure.ac: autoconf script for Vim
Bram Moolenaar071d4272004-06-13 20:20:40 +00002
Paul Ollis65745772022-06-05 16:55:54 +01003dnl Process this file with autoconf 2.69 to produce "configure".
4dnl This should also work with other versions of autoconf, but 2.70 and later
5dnl generate lots of hard to fix "obsolete" warnings.
Bram Moolenaar071d4272004-06-13 20:20:40 +00006
7AC_INIT(vim.h)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01008AC_CONFIG_HEADERS(auto/config.h:config.h.in)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009
10dnl Being able to run configure means the system is Unix (compatible).
11AC_DEFINE(UNIX)
12AC_PROG_MAKE_SET
13
14dnl Checks for programs.
Bram Moolenaar22640082018-04-19 20:39:41 +020015AC_PROG_CC_C99 dnl required by almost everything
Bram Moolenaarc0394412017-04-20 20:20:23 +020016AC_PROG_CPP dnl required by header file checks
17AC_PROGRAM_EGREP dnl required by AC_EGREP_CPP
18AC_PROG_FGREP dnl finds working grep -F
19AC_ISC_POSIX dnl required by AC_C_CROSS
20AC_PROG_AWK dnl required for "make html" in ../doc
Bram Moolenaar071d4272004-06-13 20:20:40 +000021
22dnl Don't strip if we don't have it
23AC_CHECK_PROG(STRIP, strip, strip, :)
24
Bram Moolenaar325b7a22004-07-05 15:58:32 +000025dnl Check for extension of executables
Bram Moolenaar071d4272004-06-13 20:20:40 +000026AC_EXEEXT
27
Bram Moolenaar446cb832008-06-24 21:56:24 +000028dnl Check for standard headers. We don't use this in Vim but other stuff
29dnl in autoconf needs it, where it uses STDC_HEADERS.
30AC_HEADER_STDC
31AC_HEADER_SYS_WAIT
32
Bram Moolenaar561f8a52018-04-17 22:02:45 +020033dnl Check that the C99 features that Vim uses are supported:
Bram Moolenaar22640082018-04-19 20:39:41 +020034if test x"$ac_cv_prog_cc_c99" != xno; then
35 dnl If the compiler doesn't explicitly support C99, then check
36 dnl for the specific features Vim uses
37
38 AC_TYPE_LONG_LONG_INT
39 if test "$ac_cv_type_long_long_int" = no; then
40 AC_MSG_FAILURE([Compiler does not support long long int])
41 fi
42
43 AC_MSG_CHECKING([if the compiler supports trailing commas])
44 trailing_commas=no
Bram Moolenaar1004b3d2022-06-05 19:51:55 +010045 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
Bram Moolenaar22640082018-04-19 20:39:41 +020046 enum {
47 one,
Bram Moolenaar1004b3d2022-06-05 19:51:55 +010048 };])],
Bram Moolenaar22640082018-04-19 20:39:41 +020049 [AC_MSG_RESULT(yes); trailing_commas=yes],
50 [AC_MSG_RESULT(no)])
51 if test "$trailing_commas" = no; then
52 AC_MSG_FAILURE([Compiler does not support trailing comma in enum])
53 fi
54
55 AC_MSG_CHECKING([if the compiler supports C++ comments])
56 slash_comments=no
Bram Moolenaar1004b3d2022-06-05 19:51:55 +010057 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
58 [// C++ comments?])],
Bram Moolenaar22640082018-04-19 20:39:41 +020059 [AC_MSG_RESULT(yes); slash_comments=yes],
60 [AC_MSG_RESULT(no)])
61 if test "$slash_comments" = no; then
62 AC_MSG_FAILURE([Compiler does not support C++ comments])
63 fi
64fi
Bram Moolenaar561f8a52018-04-17 22:02:45 +020065
Bram Moolenaar8f1dde52020-06-05 23:16:29 +020066dnl If $SOURCE_DATE_EPOCH is present in the environment, use that as the
67dnl "compiled" timestamp in :version's output. Attempt to get the formatted
68dnl date using GNU date syntax, BSD date syntax, and finally falling back to
69dnl just using the current time.
70if test -n "$SOURCE_DATE_EPOCH"; then
71 DATE_FMT="%b %d %Y %H:%M:%S"
72 BUILD_DATE=$(LC_ALL=C date -u -d "@$SOURCE_DATE_EPOCH" "+$DATE_FMT" 2>/dev/null || LC_ALL=C date -u -r "$SOURCE_DATE_EPOCH" "+$DATE_FMT" 2>/dev/null || LC_ALL=C date -u "+$DATE_FMT")
73 AC_DEFINE_UNQUOTED(BUILD_DATE, ["$BUILD_DATE"])
74 BUILD_DATE_MSG=-"echo -e '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\nNOTE: build date/time is fixed: $BUILD_DATE\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='"
75 AC_SUBST(BUILD_DATE_MSG)
76fi
77
Bram Moolenaarf788a062011-12-14 20:51:25 +010078dnl Check for the flag that fails if stuff are missing.
79
80AC_MSG_CHECKING(--enable-fail-if-missing argument)
81AC_ARG_ENABLE(fail_if_missing,
82 [ --enable-fail-if-missing Fail if dependencies on additional features
Bram Moolenaare5303952022-06-19 17:05:47 +010083 specified on the command line are missing.],
Bram Moolenaarf788a062011-12-14 20:51:25 +010084 [fail_if_missing="yes"],
85 [fail_if_missing="no"])
86AC_MSG_RESULT($fail_if_missing)
87
Bram Moolenaard2a05492018-07-27 22:35:15 +020088dnl Keep original value to check later.
89with_x_arg="$with_x"
90
Bram Moolenaar071d4272004-06-13 20:20:40 +000091dnl Set default value for CFLAGS if none is defined or it's empty
92if test -z "$CFLAGS"; then
93 CFLAGS="-O"
Bram Moolenaar4d8479b2021-01-31 14:36:06 +010094 test "$GCC" = yes && CFLAGS="-O2 -fno-strength-reduce -Wall -Wno-deprecated-declarations"
Bram Moolenaar071d4272004-06-13 20:20:40 +000095fi
96if test "$GCC" = yes; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +000097 dnl method that should work for nearly all versions
Bram Moolenaarc8836f72014-04-12 13:12:24 +020098 gccversion=`$CC -dumpversion`
Bram Moolenaar910f66f2006-04-05 20:41:53 +000099 if test "x$gccversion" = "x"; then
100 dnl old method; fall-back for when -dumpversion doesn't work
Bram Moolenaarc8836f72014-04-12 13:12:24 +0200101 gccversion=`$CC --version | sed -e '2,$d' -e 's/darwin.//' -e 's/^[[^0-9]]*\([[0-9]]\.[[0-9.]]*\).*$/\1/g'`
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000102 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +0000103 dnl version 4.0.1 was reported to cause trouble on Macintosh by Marcin Dalecki
104 if test "$gccversion" = "3.0.1" -o "$gccversion" = "3.0.2" -o "$gccversion" = "4.0.1"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000105 echo 'GCC [[34]].0.[[12]] has a bug in the optimizer, disabling "-O#"'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000106 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-O/'`
107 else
108 if test "$gccversion" = "3.1" -o "$gccversion" = "3.2" -o "$gccversion" = "3.2.1" && `echo "$CFLAGS" | grep -v fno-strength-reduce >/dev/null`; then
109 echo 'GCC 3.1 and 3.2 have a bug in the optimizer, adding "-fno-strength-reduce"'
110 CFLAGS="$CFLAGS -fno-strength-reduce"
111 fi
112 fi
113fi
114
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200115dnl clang-500.2.75 or around has abandoned -f[no-]strength-reduce and issues a
116dnl warning when that flag is passed to. Accordingly, adjust CFLAGS based on
117dnl the version number of the clang in use.
118dnl Note that this does not work to get the version of clang 3.1 or 3.2.
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100119AC_MSG_CHECKING(for clang version)
120CLANG_VERSION_STRING=`$CC --version 2>/dev/null | sed -n -e 's/^.*clang[[^0-9]]*\([[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\).*$/\1/p'`
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200121if test x"$CLANG_VERSION_STRING" != x"" ; then
122 CLANG_MAJOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*/\1/p'`
123 CLANG_MINOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/p'`
124 CLANG_REVISION=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)/\1/p'`
125 CLANG_VERSION=`expr $CLANG_MAJOR '*' 1000000 '+' $CLANG_MINOR '*' 1000 '+' $CLANG_REVISION`
126 AC_MSG_RESULT($CLANG_VERSION)
127 dnl If you find the same issue with versions earlier than 500.2.75,
128 dnl change the constant 500002075 below appropriately. To get the
129 dnl integer corresponding to a version number, refer to the
130 dnl definition of CLANG_VERSION above.
Bram Moolenaarebd211c2021-01-30 19:33:36 +0100131 dnl Clang 11 reports "11", assume Clang 10 and later work like this.
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100132 AC_MSG_CHECKING(if clang supports -fno-strength-reduce)
Bram Moolenaarebd211c2021-01-30 19:33:36 +0100133 if test "$CLANG_MAJOR" -ge 10 -o "$CLANG_VERSION" -ge 500002075 ; then
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100134 AC_MSG_RESULT(no)
135 CFLAGS=`echo "$CFLAGS" | sed -e 's/-fno-strength-reduce/ /'`
136 else
137 AC_MSG_RESULT(yes)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200138 fi
139else
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100140 AC_MSG_RESULT(N/A)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200141fi
142
Bram Moolenaar446cb832008-06-24 21:56:24 +0000143dnl If configure thinks we are cross compiling, there might be something
144dnl wrong with the CC or CFLAGS settings, give a useful warning message
Bram Moolenaar839e9542016-04-14 16:46:02 +0200145CROSS_COMPILING=
Bram Moolenaar071d4272004-06-13 20:20:40 +0000146if test "$cross_compiling" = yes; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000147 AC_MSG_RESULT([cannot compile a simple program; if not cross compiling check CC and CFLAGS])
Bram Moolenaar839e9542016-04-14 16:46:02 +0200148 CROSS_COMPILING=1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000149fi
Bram Moolenaar839e9542016-04-14 16:46:02 +0200150AC_SUBST(CROSS_COMPILING)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000151
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +0000152dnl gcc-cpp has the wonderful -MM option to produce nicer dependencies.
153dnl But gcc 3.1 changed the meaning! See near the end.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000154test "$GCC" = yes && CPP_MM=M; AC_SUBST(CPP_MM)
155
156if test -f ./toolcheck; then
Bram Moolenaar1004b3d2022-06-05 19:51:55 +0100157 AC_MSG_CHECKING(for buggy tools)
158 sh ./toolcheck 1>&AS_MESSAGE_FD
Bram Moolenaar071d4272004-06-13 20:20:40 +0000159fi
160
161OS_EXTRA_SRC=""; OS_EXTRA_OBJ=""
162
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000163dnl When cross-compiling set $vim_cv_uname_output, $vim_cv_uname_r_output and
164dnl $vim_cv_uname_m_output to the desired value for the target system
165AC_MSG_CHECKING(uname)
166if test "x$vim_cv_uname_output" = "x" ; then
167 vim_cv_uname_output=`(uname) 2>/dev/null`
168 AC_MSG_RESULT($vim_cv_uname_output)
169else
170 AC_MSG_RESULT([$vim_cv_uname_output (cached)])
171fi
172
173AC_MSG_CHECKING(uname -r)
174if test "x$vim_cv_uname_r_output" = "x" ; then
175 vim_cv_uname_r_output=`(uname -r) 2>/dev/null`
176 AC_MSG_RESULT($vim_cv_uname_r_output)
177else
178 AC_MSG_RESULT([$vim_cv_uname_r_output (cached)])
179fi
180
181AC_MSG_CHECKING(uname -m)
182if test "x$vim_cv_uname_m_output" = "x" ; then
183 vim_cv_uname_m_output=`(uname -m) 2>/dev/null`
184 AC_MSG_RESULT($vim_cv_uname_m_output)
185else
186 AC_MSG_RESULT([$vim_cv_uname_m_output (cached)])
187fi
188
Bram Moolenaarb3f74062020-02-26 16:16:53 +0100189AC_MSG_CHECKING(for Haiku)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000190case $vim_cv_uname_output in
Bram Moolenaarb3f74062020-02-26 16:16:53 +0100191 Haiku) HAIKU=yes; AC_MSG_RESULT(yes);;
192 *) HAIKU=no; AC_MSG_RESULT(no);;
193esac
194
Bram Moolenaar071d4272004-06-13 20:20:40 +0000195dnl If QNX is found, assume we don't want to use Xphoton
196dnl unless it was specifically asked for (--with-x)
197AC_MSG_CHECKING(for QNX)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000198case $vim_cv_uname_output in
Bram Moolenaar071d4272004-06-13 20:20:40 +0000199 QNX) OS_EXTRA_SRC=os_qnx.c; OS_EXTRA_OBJ=objects/os_qnx.o
200 test -z "$with_x" && with_x=no
201 QNX=yes; AC_MSG_RESULT(yes);;
202 *) QNX=no; AC_MSG_RESULT(no);;
203esac
204
205dnl Check for Darwin and MacOS X
206dnl We do a check for MacOS X in the very beginning because there
207dnl are a lot of other things we need to change besides GUI stuff
Bram Moolenaar071d4272004-06-13 20:20:40 +0000208AC_MSG_CHECKING([for Darwin (Mac OS X)])
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000209if test "$vim_cv_uname_output" = Darwin; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000210 AC_MSG_RESULT(yes)
Bram Moolenaard0573012017-10-28 21:11:06 +0200211 MACOS_X=yes
Bram Moolenaar52ecaaa2018-05-12 21:38:13 +0200212 CPPFLAGS="$CPPFLAGS -DMACOS_X"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000213
214 AC_MSG_CHECKING(--disable-darwin argument)
215 AC_ARG_ENABLE(darwin,
216 [ --disable-darwin Disable Darwin (Mac OS X) support.],
217 , [enable_darwin="yes"])
218 if test "$enable_darwin" = "yes"; then
219 AC_MSG_RESULT(no)
220 AC_MSG_CHECKING(if Darwin files are there)
Bram Moolenaar164fca32010-07-14 13:58:07 +0200221 if test -f os_macosx.m; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000222 AC_MSG_RESULT(yes)
223 else
224 AC_MSG_RESULT([no, Darwin support disabled])
225 enable_darwin=no
226 fi
227 else
228 AC_MSG_RESULT([yes, Darwin support excluded])
229 fi
230
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000231 AC_MSG_CHECKING(--with-mac-arch argument)
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000232 AC_ARG_WITH(mac-arch, [ --with-mac-arch=ARCH current, intel, ppc or both],
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000233 MACARCH="$withval"; AC_MSG_RESULT($MACARCH),
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000234 MACARCH="current"; AC_MSG_RESULT(defaulting to $MACARCH))
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000235
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100236 AC_MSG_CHECKING(--with-developer-dir argument)
237 AC_ARG_WITH(developer-dir, [ --with-developer-dir=PATH use PATH as location for Xcode developer tools],
238 DEVELOPER_DIR="$withval"; AC_MSG_RESULT($DEVELOPER_DIR),
Bram Moolenaar32d03b32015-11-19 13:46:48 +0100239 AC_MSG_RESULT(not present))
Bram Moolenaare5303952022-06-19 17:05:47 +0100240
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100241 if test "x$DEVELOPER_DIR" = "x"; then
242 AC_PATH_PROG(XCODE_SELECT, xcode-select)
243 if test "x$XCODE_SELECT" != "x"; then
244 AC_MSG_CHECKING(for developer dir using xcode-select)
245 DEVELOPER_DIR=`$XCODE_SELECT -print-path`
246 AC_MSG_RESULT([$DEVELOPER_DIR])
247 else
248 DEVELOPER_DIR=/Developer
249 fi
250 fi
251
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000252 if test "x$MACARCH" = "xboth"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000253 AC_MSG_CHECKING(for 10.4 universal SDK)
254 dnl There is a terrible inconsistency (but we appear to get away with it):
255 dnl $CFLAGS uses the 10.4u SDK library for the headers, while $CPPFLAGS
256 dnl doesn't, because "gcc -E" doesn't grok it. That means the configure
257 dnl tests using the preprocessor are actually done with the wrong header
258 dnl files. $LDFLAGS is set at the end, because configure uses it together
259 dnl with $CFLAGS and we can only have one -sysroot argument.
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000260 save_cppflags="$CPPFLAGS"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000261 save_cflags="$CFLAGS"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000262 save_ldflags="$LDFLAGS"
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100263 CFLAGS="$CFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +0100264 AC_LINK_IFELSE([AC_LANG_PROGRAM([ ], [ ])],
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000265 AC_MSG_RESULT(found, will make universal binary),
266
267 AC_MSG_RESULT(not found)
Bram Moolenaar1f35bf92006-03-07 22:38:47 +0000268 CFLAGS="$save_cflags"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000269 AC_MSG_CHECKING(if Intel architecture is supported)
270 CPPFLAGS="$CPPFLAGS -arch i386"
271 LDFLAGS="$save_ldflags -arch i386"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +0100272 AC_LINK_IFELSE([AC_LANG_PROGRAM([ ], [ ])],
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000273 AC_MSG_RESULT(yes); MACARCH="intel",
274 AC_MSG_RESULT(no, using PowerPC)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000275 MACARCH="ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000276 CPPFLAGS="$save_cppflags -arch ppc"
277 LDFLAGS="$save_ldflags -arch ppc"))
278 elif test "x$MACARCH" = "xintel"; then
279 CPPFLAGS="$CPPFLAGS -arch intel"
280 LDFLAGS="$LDFLAGS -arch intel"
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000281 elif test "x$MACARCH" = "xppc"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000282 CPPFLAGS="$CPPFLAGS -arch ppc"
283 LDFLAGS="$LDFLAGS -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000284 fi
285
Bram Moolenaar071d4272004-06-13 20:20:40 +0000286 if test "$enable_darwin" = "yes"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200287 MACOS_X_DARWIN=yes
Bram Moolenaar164fca32010-07-14 13:58:07 +0200288 OS_EXTRA_SRC="os_macosx.m os_mac_conv.c";
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000289 OS_EXTRA_OBJ="objects/os_macosx.o objects/os_mac_conv.o"
Bram Moolenaare5303952022-06-19 17:05:47 +0100290 dnl os_macosx.m implements timer_create() and friends
291 AC_DEFINE(HAVE_TIMER_CREATE)
Bram Moolenaar32466aa2006-02-24 23:53:04 +0000292 dnl TODO: use -arch i386 on Intel machines
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100293 dnl Removed -no-cpp-precomp, only for very old compilers.
Bram Moolenaard0573012017-10-28 21:11:06 +0200294 CPPFLAGS="$CPPFLAGS -DMACOS_X_DARWIN"
Bram Moolenaar040f9752020-08-11 23:08:48 +0200295
296 dnl Assume we don't want X11 unless it was specifically asked for
Bram Moolenaar0b40d082022-03-08 13:32:37 +0000297 dnl (--with-x) or Motif or GTK GUI is used.
298 if test -z "$with_x" -a "X$enable_gui" != Xmotif -a "X$enable_gui" != Xgtk2 -a "X$enable_gui" != Xgtk3; then
Bram Moolenaar040f9752020-08-11 23:08:48 +0200299 with_x=no
300 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000301 fi
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000302
Bram Moolenaardb552d602006-03-23 22:59:57 +0000303 dnl Avoid a bug with -O2 with gcc 4.0.1. Symptom: malloc() reports double
Bram Moolenaarfd2ac762006-03-01 22:09:21 +0000304 dnl free. This happens in expand_filename(), because the optimizer swaps
Bram Moolenaardb552d602006-03-23 22:59:57 +0000305 dnl two blocks of code, both using "repl", that can't be swapped.
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000306 if test "$MACARCH" = "intel" -o "$MACARCH" = "both"; then
307 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-Oz/'`
308 fi
309
Bram Moolenaar071d4272004-06-13 20:20:40 +0000310else
311 AC_MSG_RESULT(no)
312fi
313
Bram Moolenaar39766a72013-11-03 00:41:00 +0100314dnl Mac OS X 10.9+ no longer include AvailabilityMacros.h in Carbon
315dnl so we need to include it to have access to version macros.
Bram Moolenaar18e54692013-11-03 20:26:31 +0100316AC_CHECK_HEADERS(AvailabilityMacros.h)
Bram Moolenaar39766a72013-11-03 00:41:00 +0100317
Bram Moolenaar071d4272004-06-13 20:20:40 +0000318AC_SUBST(OS_EXTRA_SRC)
319AC_SUBST(OS_EXTRA_OBJ)
320
321dnl Add /usr/local/lib to $LDFLAGS and /usr/local/include to CFLAGS.
322dnl Only when the directory exists and it wasn't there yet.
323dnl For gcc don't do this when it is already in the default search path.
Bram Moolenaar446cb832008-06-24 21:56:24 +0000324dnl Skip all of this when cross-compiling.
325if test "$cross_compiling" = no; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000326 AC_MSG_CHECKING(--with-local-dir argument)
Bram Moolenaar446cb832008-06-24 21:56:24 +0000327 have_local_include=''
328 have_local_lib=''
Bram Moolenaarc236c162008-07-13 17:41:49 +0000329 AC_ARG_WITH([local-dir], [ --with-local-dir=PATH search PATH instead of /usr/local for local libraries.
330 --without-local-dir do not search /usr/local for local libraries.], [
331 local_dir="$withval"
332 case "$withval" in
333 */*) ;;
334 no)
335 # avoid adding local dir to LDFLAGS and CPPFLAGS
Bram Moolenaare06c1882010-07-21 22:05:20 +0200336 have_local_include=yes
Bram Moolenaarc236c162008-07-13 17:41:49 +0000337 have_local_lib=yes
338 ;;
339 *) AC_MSG_ERROR(must pass path argument to --with-local-dir) ;;
340 esac
341 AC_MSG_RESULT($local_dir)
342 ], [
343 local_dir=/usr/local
344 AC_MSG_RESULT(Defaulting to $local_dir)
345 ])
346 if test "$GCC" = yes -a "$local_dir" != no; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000347 echo 'void f(){}' > conftest.c
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100348 dnl Removed -no-cpp-precomp, only needed for OS X 10.2 (Ben Fowler)
349 have_local_include=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/include"`
Bram Moolenaarc236c162008-07-13 17:41:49 +0000350 have_local_lib=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/lib"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000351 rm -f conftest.c conftest.o
Bram Moolenaar071d4272004-06-13 20:20:40 +0000352 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000353 if test -z "$have_local_lib" -a -d "${local_dir}/lib"; then
354 tt=`echo "$LDFLAGS" | sed -e "s+-L${local_dir}/lib ++g" -e "s+-L${local_dir}/lib$++g"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000355 if test "$tt" = "$LDFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000356 LDFLAGS="$LDFLAGS -L${local_dir}/lib"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000357 fi
358 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000359 if test -z "$have_local_include" -a -d "${local_dir}/include"; then
360 tt=`echo "$CPPFLAGS" | sed -e "s+-I${local_dir}/include ++g" -e "s+-I${local_dir}/include$++g"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000361 if test "$tt" = "$CPPFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000362 CPPFLAGS="$CPPFLAGS -I${local_dir}/include"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000363 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000364 fi
365fi
366
367AC_MSG_CHECKING(--with-vim-name argument)
368AC_ARG_WITH(vim-name, [ --with-vim-name=NAME what to call the Vim executable],
369 VIMNAME="$withval"; AC_MSG_RESULT($VIMNAME),
Bram Moolenaare344bea2005-09-01 20:46:49 +0000370 VIMNAME="vim"; AC_MSG_RESULT(Defaulting to $VIMNAME))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000371AC_SUBST(VIMNAME)
372AC_MSG_CHECKING(--with-ex-name argument)
373AC_ARG_WITH(ex-name, [ --with-ex-name=NAME what to call the Ex executable],
374 EXNAME="$withval"; AC_MSG_RESULT($EXNAME),
375 EXNAME="ex"; AC_MSG_RESULT(Defaulting to ex))
376AC_SUBST(EXNAME)
377AC_MSG_CHECKING(--with-view-name argument)
378AC_ARG_WITH(view-name, [ --with-view-name=NAME what to call the View executable],
379 VIEWNAME="$withval"; AC_MSG_RESULT($VIEWNAME),
380 VIEWNAME="view"; AC_MSG_RESULT(Defaulting to view))
381AC_SUBST(VIEWNAME)
382
383AC_MSG_CHECKING(--with-global-runtime argument)
Bram Moolenaar9d302ad2018-12-21 11:48:51 +0100384AC_ARG_WITH(global-runtime, [ --with-global-runtime=DIR global runtime directory in 'runtimepath', comma-separated for multiple directories],
385 RUNTIME_GLOBAL="$withval"; AC_MSG_RESULT($withval),
Bram Moolenaar071d4272004-06-13 20:20:40 +0000386 AC_MSG_RESULT(no))
387
Bram Moolenaar9d302ad2018-12-21 11:48:51 +0100388if test "X$RUNTIME_GLOBAL" != "X"; then
389 RUNTIME_GLOBAL_AFTER=$(printf -- "$RUNTIME_GLOBAL\\n" | $AWK -F, 'BEGIN { comma=0 } { for (i = NF; i > 0; i--) { if (comma) { printf ",%s/after", $i } else { printf "%s/after", $i; comma=1 } } } END { printf "\n" }')
390 AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL, "$RUNTIME_GLOBAL")
391 AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL_AFTER, "$RUNTIME_GLOBAL_AFTER")
392fi
393
Bram Moolenaar071d4272004-06-13 20:20:40 +0000394AC_MSG_CHECKING(--with-modified-by argument)
395AC_ARG_WITH(modified-by, [ --with-modified-by=NAME name of who modified a release version],
396 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(MODIFIED_BY, "$withval"),
397 AC_MSG_RESULT(no))
398
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200399dnl Check for EBCDIC stolen from the LYNX port to z/OS Unix
Bram Moolenaar071d4272004-06-13 20:20:40 +0000400AC_MSG_CHECKING(if character set is EBCDIC)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +0100401AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ ],
Bram Moolenaar071d4272004-06-13 20:20:40 +0000402[ /* TryCompile function for CharSet.
403 Treat any failure as ASCII for compatibility with existing art.
404 Use compile-time rather than run-time tests for cross-compiler
405 tolerance. */
406#if '0'!=240
407make an error "Character set is not EBCDIC"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +0100408#endif ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +0000409[ # TryCompile action if true
410cf_cv_ebcdic=yes ],
411[ # TryCompile action if false
412cf_cv_ebcdic=no])
413# end of TryCompile ])
414# end of CacheVal CvEbcdic
415AC_MSG_RESULT($cf_cv_ebcdic)
416case "$cf_cv_ebcdic" in #(vi
417 yes) AC_DEFINE(EBCDIC)
418 line_break='"\\n"'
419 ;;
420 *) line_break='"\\012"';;
421esac
422AC_SUBST(line_break)
423
424if test "$cf_cv_ebcdic" = "yes"; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +0200425dnl If we have EBCDIC we most likely have z/OS Unix, let's test it!
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200426AC_MSG_CHECKING(for z/OS Unix)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000427case $vim_cv_uname_output in
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200428 OS/390) zOSUnix="yes";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000429 dnl If using cc the environment variable _CC_CCMODE must be
430 dnl set to "1", so that some compiler extensions are enabled.
431 dnl If using c89 the environment variable is named _CC_C89MODE.
432 dnl Note: compile with c89 never tested.
433 if test "$CC" = "cc"; then
434 ccm="$_CC_CCMODE"
435 ccn="CC"
436 else
437 if test "$CC" = "c89"; then
438 ccm="$_CC_C89MODE"
439 ccn="C89"
440 else
441 ccm=1
442 fi
443 fi
444 if test "$ccm" != "1"; then
445 echo ""
446 echo "------------------------------------------"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200447 echo " On z/OS Unix, the environment variable"
Bram Moolenaar77c19352012-06-13 19:19:41 +0200448 echo " _CC_${ccn}MODE must be set to \"1\"!"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000449 echo " Do:"
450 echo " export _CC_${ccn}MODE=1"
451 echo " and then call configure again."
452 echo "------------------------------------------"
453 exit 1
454 fi
Bram Moolenaar77c19352012-06-13 19:19:41 +0200455 # Set CFLAGS for configure process.
456 # This will be reset later for config.mk.
457 # Use haltonmsg to force error for missing H files.
458 CFLAGS="$CFLAGS -D_ALL_SOURCE -Wc,float(ieee),haltonmsg(3296)";
459 LDFLAGS="$LDFLAGS -Wl,EDIT=NO"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000460 AC_MSG_RESULT(yes)
461 ;;
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200462 *) zOSUnix="no";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000463 AC_MSG_RESULT(no)
464 ;;
465esac
466fi
467
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200468dnl Set QUOTESED. Needs additional backslashes on zOS
469if test "$zOSUnix" = "yes"; then
Bram Moolenaarabcbb0e2020-12-23 12:33:42 +0100470 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\\\\\&/g' -e 's/\\\\\\\\\"/\"/' -e 's/\\\\\\\\\";\$\$/\";/' -e 's/ */ /g'"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200471else
Bram Moolenaarabcbb0e2020-12-23 12:33:42 +0100472 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\&/g' -e 's/\\\\\"/\"/' -e 's/\\\\\";\$\$/\";/' -e 's/ */ /g'"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200473fi
474AC_SUBST(QUOTESED)
475
476
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200477dnl Link with -lsmack for Smack stuff; if not found
478AC_MSG_CHECKING(--disable-smack argument)
479AC_ARG_ENABLE(smack,
480 [ --disable-smack Do not check for Smack support.],
481 , enable_smack="yes")
482if test "$enable_smack" = "yes"; then
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200483 AC_MSG_RESULT(no)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200484 AC_CHECK_HEADER([linux/xattr.h], true, enable_smack="no")
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200485else
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200486 AC_MSG_RESULT(yes)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200487fi
488if test "$enable_smack" = "yes"; then
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200489 AC_CHECK_HEADER([attr/xattr.h], true, enable_smack="no")
490fi
491if test "$enable_smack" = "yes"; then
492 AC_MSG_CHECKING(for XATTR_NAME_SMACKEXEC in linux/xattr.h)
493 AC_EGREP_CPP(XATTR_NAME_SMACKEXEC, [#include <linux/xattr.h>],
494 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +0200495 AC_MSG_RESULT(no); enable_smack="no")
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200496fi
497if test "$enable_smack" = "yes"; then
498 AC_CHECK_LIB(attr, setxattr,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200499 [LIBS="$LIBS -lattr"
500 found_smack="yes"
501 AC_DEFINE(HAVE_SMACK)])
Bram Moolenaar588ebeb2008-05-07 17:09:24 +0000502fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000503
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200504dnl When smack was found don't search for SELinux
505if test "x$found_smack" = "x"; then
506 dnl Link with -lselinux for SELinux stuff; if not found
507 AC_MSG_CHECKING(--disable-selinux argument)
508 AC_ARG_ENABLE(selinux,
509 [ --disable-selinux Do not check for SELinux support.],
510 , enable_selinux="yes")
511 if test "$enable_selinux" = "yes"; then
512 AC_MSG_RESULT(no)
513 AC_CHECK_LIB(selinux, is_selinux_enabled,
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100514 [AC_CHECK_HEADER(selinux/selinux.h,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200515 [LIBS="$LIBS -lselinux"
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100516 AC_DEFINE(HAVE_SELINUX)])])
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200517 else
518 AC_MSG_RESULT(yes)
519 fi
520fi
521
Bram Moolenaar071d4272004-06-13 20:20:40 +0000522dnl Check user requested features.
523
524AC_MSG_CHECKING(--with-features argument)
Martin Tournoij25f3a142022-10-08 19:26:41 +0100525AC_ARG_WITH(features, [ --with-features=TYPE tiny, normal or huge (default: huge)],
Bram Moolenaar071d4272004-06-13 20:20:40 +0000526 features="$withval"; AC_MSG_RESULT($features),
Bram Moolenaar23c4f712016-01-20 22:11:59 +0100527 features="huge"; AC_MSG_RESULT(Defaulting to huge))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000528
Martin Tournoij7904fa42022-10-04 16:28:45 +0100529dnl "small" is supported for backwards compatibility, now an alias for "tiny"
Martin Tournoij25f3a142022-10-08 19:26:41 +0100530dnl "big" is supported for backwards compatibility, now an alias for "normal"
Martin Tournoij7904fa42022-10-04 16:28:45 +0100531case "$features" in
Martin Tournoij25f3a142022-10-08 19:26:41 +0100532 small) features="tiny" ;;
533 big) features="normal" ;;
Martin Tournoij7904fa42022-10-04 16:28:45 +0100534esac
535
Bram Moolenaar071d4272004-06-13 20:20:40 +0000536dovimdiff=""
537dogvimdiff=""
538case "$features" in
539 tiny) AC_DEFINE(FEAT_TINY) ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000540 normal) AC_DEFINE(FEAT_NORMAL) dovimdiff="installvimdiff";
541 dogvimdiff="installgvimdiff" ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000542 huge) AC_DEFINE(FEAT_HUGE) dovimdiff="installvimdiff";
543 dogvimdiff="installgvimdiff" ;;
544 *) AC_MSG_RESULT([Sorry, $features is not supported]) ;;
545esac
546
547AC_SUBST(dovimdiff)
548AC_SUBST(dogvimdiff)
549
Martin Tournoij7904fa42022-10-04 16:28:45 +0100550if test "x$features" = "xtiny"; then
Bram Moolenaar12471262022-01-18 11:11:25 +0000551 has_eval=no
552else
553 has_eval=yes
554fi
555
Bram Moolenaar071d4272004-06-13 20:20:40 +0000556AC_MSG_CHECKING(--with-compiledby argument)
557AC_ARG_WITH(compiledby, [ --with-compiledby=NAME name to show in :version message],
558 compiledby="$withval"; AC_MSG_RESULT($withval),
559 compiledby=""; AC_MSG_RESULT(no))
560AC_SUBST(compiledby)
561
562AC_MSG_CHECKING(--disable-xsmp argument)
563AC_ARG_ENABLE(xsmp,
564 [ --disable-xsmp Disable XSMP session management],
565 , enable_xsmp="yes")
566
567if test "$enable_xsmp" = "yes"; then
568 AC_MSG_RESULT(no)
569 AC_MSG_CHECKING(--disable-xsmp-interact argument)
570 AC_ARG_ENABLE(xsmp-interact,
571 [ --disable-xsmp-interact Disable XSMP interaction],
572 , enable_xsmp_interact="yes")
573 if test "$enable_xsmp_interact" = "yes"; then
574 AC_MSG_RESULT(no)
575 AC_DEFINE(USE_XSMP_INTERACT)
576 else
577 AC_MSG_RESULT(yes)
578 fi
579else
580 AC_MSG_RESULT(yes)
581fi
582
Bram Moolenaar67ffb412022-01-08 13:36:57 +0000583AC_MSG_CHECKING([diff feature])
Martin Tournoij7904fa42022-10-04 16:28:45 +0100584if test "x$features" = "xtiny"; then
Bram Moolenaar67ffb412022-01-08 13:36:57 +0000585 AC_MSG_RESULT([disabled in $features version])
586else
587 AC_MSG_RESULT(enabled)
588 AC_DEFINE(FEAT_DIFF)
589 XDIFF_OBJS_USED="\$(XDIFF_OBJS)"
590 AC_SUBST(XDIFF_OBJS_USED)
591fi
592
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200593dnl Check for Lua feature.
594AC_MSG_CHECKING(--enable-luainterp argument)
595AC_ARG_ENABLE(luainterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200596 [ --enable-luainterp[=OPTS] Include Lua interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200597 [enable_luainterp="no"])
598AC_MSG_RESULT($enable_luainterp)
599
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200600if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then
Bram Moolenaar12471262022-01-18 11:11:25 +0000601 if test "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +0100602 AC_MSG_ERROR([cannot use Lua with tiny features])
Bram Moolenaar3c124e32016-01-31 14:36:58 +0100603 fi
604
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200605 dnl -- find the lua executable
606 AC_SUBST(vi_cv_path_lua)
607
608 AC_MSG_CHECKING(--with-lua-prefix argument)
609 AC_ARG_WITH(lua_prefix,
610 [ --with-lua-prefix=PFX Prefix where Lua is installed.],
611 with_lua_prefix="$withval"; AC_MSG_RESULT($with_lua_prefix),
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200612 with_lua_prefix="";AC_MSG_RESULT(no))
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200613
614 if test "X$with_lua_prefix" != "X"; then
615 vi_cv_path_lua_pfx="$with_lua_prefix"
616 else
617 AC_MSG_CHECKING(LUA_PREFIX environment var)
618 if test "X$LUA_PREFIX" != "X"; then
619 AC_MSG_RESULT("$LUA_PREFIX")
620 vi_cv_path_lua_pfx="$LUA_PREFIX"
621 else
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200622 AC_MSG_RESULT([not set, default to /usr])
623 vi_cv_path_lua_pfx="/usr"
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200624 fi
625 fi
626
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200627 AC_MSG_CHECKING(--with-luajit)
628 AC_ARG_WITH(luajit,
629 [ --with-luajit Link with LuaJIT instead of Lua.],
630 [vi_cv_with_luajit="$withval"],
631 [vi_cv_with_luajit="no"])
632 AC_MSG_RESULT($vi_cv_with_luajit)
633
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200634 LUA_INC=
635 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200636 if test "x$vi_cv_with_luajit" != "xno"; then
637 dnl -- try to find LuaJIT executable
638 AC_PATH_PROG(vi_cv_path_luajit, luajit)
639 if test "X$vi_cv_path_luajit" != "X"; then
640 dnl -- find LuaJIT version
641 AC_CACHE_CHECK(LuaJIT version, vi_cv_version_luajit,
Bram Moolenaar49b10272013-11-21 12:17:51 +0100642 [ 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 +0200643 AC_CACHE_CHECK(Lua version of LuaJIT, vi_cv_version_lua_luajit,
644 [ vi_cv_version_lua_luajit=`${vi_cv_path_luajit} -e "print(_VERSION)" | sed 's/.* //'` ])
645 vi_cv_path_lua="$vi_cv_path_luajit"
646 vi_cv_version_lua="$vi_cv_version_lua_luajit"
647 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200648 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200649 dnl -- try to find Lua executable
650 AC_PATH_PROG(vi_cv_path_plain_lua, lua)
651 if test "X$vi_cv_path_plain_lua" != "X"; then
652 dnl -- find Lua version
653 AC_CACHE_CHECK(Lua version, vi_cv_version_plain_lua,
654 [ vi_cv_version_plain_lua=`${vi_cv_path_plain_lua} -e "print(_VERSION)" | sed 's/.* //'` ])
655 fi
656 vi_cv_path_lua="$vi_cv_path_plain_lua"
657 vi_cv_version_lua="$vi_cv_version_plain_lua"
658 fi
659 if test "x$vi_cv_with_luajit" != "xno" && test "X$vi_cv_version_luajit" != "X"; then
660 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 +0100661 if test -f "$vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200662 AC_MSG_RESULT(yes)
663 LUA_INC=/luajit-$vi_cv_version_luajit
664 fi
665 fi
666 if test "X$LUA_INC" = "X"; then
667 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)
Bram Moolenaar49222be2015-12-11 18:11:30 +0100668 if test -f "$vi_cv_path_lua_pfx/include/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200669 AC_MSG_RESULT(yes)
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200670 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200671 AC_MSG_RESULT(no)
672 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 +0100673 if test -f "$vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200674 AC_MSG_RESULT(yes)
675 LUA_INC=/lua$vi_cv_version_lua
676 else
677 AC_MSG_RESULT(no)
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200678
679 # Detect moonjit:
680 # https://groups.google.com/forum/#!topic/vim_use/O0vek60WuTk
681 lua_suf=/moonjit-2.3
682 inc_path="$vi_cv_path_lua_pfx/include"
Bram Moolenaarad4dc832020-04-20 16:21:53 +0200683 for dir in "$inc_path"/moonjit-[[0-9]]* ; do
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200684 if test -d "$dir" ; then
Bram Moolenaara79a8942020-12-17 20:50:25 +0100685 lua_suf=`basename "$dir"`
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200686 lua_suf="/$lua_suf"
687 break
688 fi
689 done
690 AC_MSG_CHECKING(if lua.h can be found in $inc_path$lua_suf)
691 if test -f "$inc_path$lua_suf/lua.h"; then
692 AC_MSG_RESULT(yes)
693 LUA_INC=$lua_suf
694 else
695 AC_MSG_RESULT(no)
696 vi_cv_path_lua_pfx=
697 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200698 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200699 fi
700 fi
701 fi
702
703 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200704 if test "x$vi_cv_with_luajit" != "xno"; then
705 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
706 if test "X$multiarch" != "X"; then
707 lib_multiarch="lib/${multiarch}"
708 else
709 lib_multiarch="lib"
710 fi
711 if test "X$vi_cv_version_lua" = "X"; then
712 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit"
713 else
714 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit-$vi_cv_version_lua"
715 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200716 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200717 if test "X$LUA_INC" != "X"; then
718 dnl Test alternate location using version
719 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua$vi_cv_version_lua"
720 else
721 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua"
722 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200723 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200724 if test "$enable_luainterp" = "dynamic"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200725 lua_ok="yes"
726 else
727 AC_MSG_CHECKING([if link with ${LUA_LIBS} is sane])
728 libs_save=$LIBS
729 LIBS="$LIBS $LUA_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +0100730 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200731 AC_MSG_RESULT(yes); lua_ok="yes",
732 AC_MSG_RESULT(no); lua_ok="no"; LUA_LIBS="")
733 LIBS=$libs_save
734 fi
735 if test "x$lua_ok" = "xyes"; then
736 LUA_CFLAGS="-I${vi_cv_path_lua_pfx}/include${LUA_INC}"
737 LUA_SRC="if_lua.c"
738 LUA_OBJ="objects/if_lua.o"
739 LUA_PRO="if_lua.pro"
740 AC_DEFINE(FEAT_LUA)
741 fi
742 if test "$enable_luainterp" = "dynamic"; then
743 if test "x$vi_cv_with_luajit" != "xno"; then
744 luajit="jit"
745 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200746 if test -f "${vi_cv_path_lua_pfx}/bin/cyglua-${vi_cv_version_lua}.dll"; then
747 vi_cv_dll_name_lua="cyglua-${vi_cv_version_lua}.dll"
748 else
Bram Moolenaard0573012017-10-28 21:11:06 +0200749 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200750 ext="dylib"
751 indexes=""
752 else
753 ext="so"
754 indexes=".0 .1 .2 .3 .4 .5 .6 .7 .8 .9"
755 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
756 if test "X$multiarch" != "X"; then
757 lib_multiarch="lib/${multiarch}"
758 fi
Bram Moolenaar768baac2013-04-15 14:44:57 +0200759 fi
760 dnl Determine the sover for the current version, but fallback to
761 dnl liblua${vi_cv_version_lua}.so if no sover-versioned file is found.
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200762 AC_MSG_CHECKING(if liblua${luajit}*.${ext}* can be found in $vi_cv_path_lua_pfx)
Bram Moolenaar768baac2013-04-15 14:44:57 +0200763 for subdir in "${lib_multiarch}" lib64 lib; do
764 if test -z "$subdir"; then
765 continue
766 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200767 for sover in "${vi_cv_version_lua}.${ext}" "-${vi_cv_version_lua}.${ext}" \
768 ".${vi_cv_version_lua}.${ext}" ".${ext}.${vi_cv_version_lua}"; do
769 for i in $indexes ""; do
770 if test -f "${vi_cv_path_lua_pfx}/${subdir}/liblua${luajit}${sover}$i"; then
Bram Moolenaar768baac2013-04-15 14:44:57 +0200771 sover2="$i"
772 break 3
773 fi
774 done
Bram Moolenaar07e1da62013-02-06 19:49:43 +0100775 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200776 sover=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200777 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200778 if test "X$sover" = "X"; then
779 AC_MSG_RESULT(no)
780 lua_ok="no"
781 vi_cv_dll_name_lua="liblua${luajit}.${ext}"
782 else
783 AC_MSG_RESULT(yes)
784 lua_ok="yes"
785 vi_cv_dll_name_lua="liblua${luajit}${sover}$sover2"
786 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200787 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200788 AC_DEFINE(DYNAMIC_LUA)
789 LUA_LIBS=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200790 LUA_CFLAGS="-DDYNAMIC_LUA_DLL=\\\"${vi_cv_dll_name_lua}\\\" $LUA_CFLAGS"
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200791 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200792 if test "X$LUA_CFLAGS$LUA_LIBS" != "X" && \
Bram Moolenaard0573012017-10-28 21:11:06 +0200793 test "x$MACOS_X" = "xyes" && test "x$vi_cv_with_luajit" != "xno" && \
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000794 test "$vim_cv_uname_m_output" = "x86_64"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200795 dnl OSX/x64 requires these flags. See http://luajit.org/install.html
796 LUA_LIBS="-pagezero_size 10000 -image_base 100000000 $LUA_LIBS"
797 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200798 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200799 if test "$fail_if_missing" = "yes" -a "$lua_ok" != "yes"; then
Bram Moolenaarf788a062011-12-14 20:51:25 +0100800 AC_MSG_ERROR([could not configure lua])
801 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200802 AC_SUBST(LUA_SRC)
803 AC_SUBST(LUA_OBJ)
804 AC_SUBST(LUA_PRO)
805 AC_SUBST(LUA_LIBS)
806 AC_SUBST(LUA_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +0000807 AC_SUBST(LUA_CFLAGS_EXTRA)
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200808fi
809
810
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000811dnl Check for MzScheme feature.
812AC_MSG_CHECKING(--enable-mzschemeinterp argument)
813AC_ARG_ENABLE(mzschemeinterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200814 [ --enable-mzschemeinterp Include MzScheme interpreter.], ,
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000815 [enable_mzschemeinterp="no"])
816AC_MSG_RESULT($enable_mzschemeinterp)
817
818if test "$enable_mzschemeinterp" = "yes"; then
819 dnl -- find the mzscheme executable
820 AC_SUBST(vi_cv_path_mzscheme)
821
822 AC_MSG_CHECKING(--with-plthome argument)
823 AC_ARG_WITH(plthome,
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000824 [ --with-plthome=PLTHOME Use PLTHOME.],
825 with_plthome="$withval"; AC_MSG_RESULT($with_plthome),
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000826 with_plthome="";AC_MSG_RESULT("no"))
827
828 if test "X$with_plthome" != "X"; then
829 vi_cv_path_mzscheme_pfx="$with_plthome"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100830 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000831 else
832 AC_MSG_CHECKING(PLTHOME environment var)
833 if test "X$PLTHOME" != "X"; then
834 AC_MSG_RESULT("$PLTHOME")
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000835 vi_cv_path_mzscheme_pfx="$PLTHOME"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100836 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000837 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000838 AC_MSG_RESULT(not set)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000839 dnl -- try to find MzScheme executable
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000840 AC_PATH_PROG(vi_cv_path_mzscheme, mzscheme)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000841
842 dnl resolve symbolic link, the executable is often elsewhere and there
843 dnl are no links for the include files.
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000844 if test "X$vi_cv_path_mzscheme" != "X"; then
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000845 lsout=`ls -l $vi_cv_path_mzscheme`
846 if echo "$lsout" | grep -e '->' >/dev/null 2>/dev/null; then
847 vi_cv_path_mzscheme=`echo "$lsout" | sed 's/.*-> \(.*\)/\1/'`
848 fi
849 fi
850
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000851 if test "X$vi_cv_path_mzscheme" != "X"; then
852 dnl -- find where MzScheme thinks it was installed
853 AC_CACHE_CHECK(MzScheme install prefix,vi_cv_path_mzscheme_pfx,
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000854 dnl different versions of MzScheme differ in command line processing
855 dnl use universal approach
856 echo "(display (simplify-path \
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000857 (build-path (call-with-values \
858 (lambda () (split-path (find-system-path (quote exec-file)))) \
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000859 (lambda (base name must-be-dir?) base)) (quote up))))" > mzdirs.scm
860 dnl Remove a trailing slash
861 [ vi_cv_path_mzscheme_pfx=`${vi_cv_path_mzscheme} -r mzdirs.scm | \
862 sed -e 's+/$++'` ])
863 rm -f mzdirs.scm
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000864 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000865 fi
866 fi
867
868 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100869 AC_MSG_CHECKING(for racket include directory)
870 SCHEME_INC=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-include-dir))) (when (path? p) (display p)))'`
871 if test "X$SCHEME_INC" != "X"; then
872 AC_MSG_RESULT(${SCHEME_INC})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000873 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100874 AC_MSG_RESULT(not found)
875 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include)
876 if test -f "$vi_cv_path_mzscheme_pfx/include/scheme.h"; then
877 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000878 AC_MSG_RESULT(yes)
Bram Moolenaard7afed32007-05-06 13:26:41 +0000879 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000880 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100881 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt)
882 if test -f "$vi_cv_path_mzscheme_pfx/include/plt/scheme.h"; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000883 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100884 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000885 else
886 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100887 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket)
888 if test -f "$vi_cv_path_mzscheme_pfx/include/racket/scheme.h"; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100889 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100890 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100891 else
892 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100893 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/)
894 if test -f /usr/include/plt/scheme.h; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100895 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100896 SCHEME_INC=/usr/include/plt
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100897 else
898 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100899 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/racket/)
900 if test -f /usr/include/racket/scheme.h; then
901 AC_MSG_RESULT(yes)
902 SCHEME_INC=/usr/include/racket
903 else
904 AC_MSG_RESULT(no)
905 vi_cv_path_mzscheme_pfx=
906 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100907 fi
908 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000909 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000910 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000911 fi
912 fi
913
914 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100915
916 AC_MSG_CHECKING(for racket lib directory)
917 SCHEME_LIB=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-lib-dir))) (when (path? p) (display p)))'`
918 if test "X$SCHEME_LIB" != "X"; then
919 AC_MSG_RESULT(${SCHEME_LIB})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000920 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100921 AC_MSG_RESULT(not found)
922 fi
923
924 for path in "${vi_cv_path_mzscheme_pfx}/lib" "${SCHEME_LIB}"; do
925 if test "X$path" != "X"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200926 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100927 MZSCHEME_LIBS="-framework Racket"
928 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
929 elif test -f "${path}/libmzscheme3m.a"; then
930 MZSCHEME_LIBS="${path}/libmzscheme3m.a"
931 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
932 elif test -f "${path}/libracket3m.a"; then
933 MZSCHEME_LIBS="${path}/libracket3m.a"
Bram Moolenaar588d2412020-10-03 14:24:19 +0200934 if test -f "${path}/librktio.a"; then
935 MZSCHEME_LIBS="${MZSCHEME_LIBS} ${path}/librktio.a"
936 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100937 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
938 elif test -f "${path}/libracket.a"; then
939 MZSCHEME_LIBS="${path}/libracket.a ${path}/libmzgc.a"
940 elif test -f "${path}/libmzscheme.a"; then
941 MZSCHEME_LIBS="${path}/libmzscheme.a ${path}/libmzgc.a"
942 else
943 dnl Using shared objects
944 if test -f "${path}/libmzscheme3m.so"; then
945 MZSCHEME_LIBS="-L${path} -lmzscheme3m"
946 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
947 elif test -f "${path}/libracket3m.so"; then
948 MZSCHEME_LIBS="-L${path} -lracket3m"
949 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
950 elif test -f "${path}/libracket.so"; then
951 MZSCHEME_LIBS="-L${path} -lracket -lmzgc"
952 else
953 dnl try next until last
954 if test "$path" != "$SCHEME_LIB"; then
955 continue
956 fi
957 MZSCHEME_LIBS="-L${path} -lmzscheme -lmzgc"
958 fi
959 if test "$GCC" = yes; then
960 dnl Make Vim remember the path to the library. For when it's not in
961 dnl $LD_LIBRARY_PATH.
962 MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${path}"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +0000963 elif test "$vim_cv_uname_output" = SunOS &&
964 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100965 MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${path}"
966 fi
967 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000968 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100969 if test "X$MZSCHEME_LIBS" != "X"; then
970 break
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +0000971 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100972 done
973
974 AC_MSG_CHECKING([if racket requires -pthread])
975 if test "X$SCHEME_LIB" != "X" && $FGREP -e -pthread "$SCHEME_LIB/buildinfo" >/dev/null ; then
976 AC_MSG_RESULT(yes)
977 MZSCHEME_LIBS="${MZSCHEME_LIBS} -pthread"
978 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -pthread"
979 else
980 AC_MSG_RESULT(no)
981 fi
982
983 AC_MSG_CHECKING(for racket config directory)
984 SCHEME_CONFIGDIR=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-config-dir))) (when (path? p) (display p)))'`
985 if test "X$SCHEME_CONFIGDIR" != "X"; then
986 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DMZSCHEME_CONFIGDIR='\"${SCHEME_CONFIGDIR}\"'"
987 AC_MSG_RESULT(${SCHEME_CONFIGDIR})
988 else
989 AC_MSG_RESULT(not found)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000990 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100991
992 AC_MSG_CHECKING(for racket collects directory)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100993 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))))'`
994 if test "X$SCHEME_COLLECTS" = "X"; then
995 if test -d "$vi_cv_path_mzscheme_pfx/lib/plt/collects"; then
996 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/plt/
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100997 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100998 if test -d "$vi_cv_path_mzscheme_pfx/lib/racket/collects"; then
999 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/racket/
Bram Moolenaar75676462013-01-30 14:55:42 +01001000 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +01001001 if test -d "$vi_cv_path_mzscheme_pfx/share/racket/collects"; then
1002 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/
1003 else
1004 if test -d "$vi_cv_path_mzscheme_pfx/collects"; then
1005 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/
1006 fi
Bram Moolenaar75676462013-01-30 14:55:42 +01001007 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001008 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +01001009 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +00001010 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001011 if test "X$SCHEME_COLLECTS" != "X" ; then
1012 AC_MSG_RESULT(${SCHEME_COLLECTS})
1013 else
1014 AC_MSG_RESULT(not found)
1015 fi
1016
1017 AC_MSG_CHECKING(for mzscheme_base.c)
1018 if test -f "${SCHEME_COLLECTS}collects/scheme/base.ss" ; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001019 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +01001020 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
1021 MZSCHEME_MOD="++lib scheme/base"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +01001022 else
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001023 if test -f "${SCHEME_COLLECTS}collects/scheme/base.rkt" ; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +01001024 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +01001025 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
1026 MZSCHEME_MOD="++lib scheme/base"
1027 else
1028 if test -f "${SCHEME_COLLECTS}collects/racket/base.rkt" ; then
1029 MZSCHEME_EXTRA="mzscheme_base.c"
1030 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/raco ctool"
1031 MZSCHEME_MOD=""
1032 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +01001033 fi
1034 fi
1035 if test "X$MZSCHEME_EXTRA" != "X" ; then
1036 dnl need to generate bytecode for MzScheme base
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001037 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE"
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001038 AC_MSG_RESULT(needed)
1039 else
1040 AC_MSG_RESULT(not needed)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001041 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001042
Bram Moolenaar9e902192013-07-17 18:58:11 +02001043 dnl On Ubuntu this fixes "undefined reference to symbol 'ffi_type_void'".
1044 AC_CHECK_LIB(ffi, ffi_type_void, [MZSCHEME_LIBS="$MZSCHEME_LIBS -lffi"])
1045
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001046 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -I${SCHEME_INC} \
Bram Moolenaarfe9fb922012-11-23 21:54:48 +01001047 -DMZSCHEME_COLLECTS='\"${SCHEME_COLLECTS}collects\"'"
Bram Moolenaar9e902192013-07-17 18:58:11 +02001048
1049 dnl Test that we can compile a simple program with these CFLAGS and LIBS.
1050 AC_MSG_CHECKING([if compile and link flags for MzScheme are sane])
1051 cflags_save=$CFLAGS
1052 libs_save=$LIBS
1053 CFLAGS="$CFLAGS $MZSCHEME_CFLAGS"
1054 LIBS="$LIBS $MZSCHEME_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001055 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaar9e902192013-07-17 18:58:11 +02001056 AC_MSG_RESULT(yes); mzs_ok=yes,
1057 AC_MSG_RESULT(no: MZSCHEME DISABLED); mzs_ok=no)
1058 CFLAGS=$cflags_save
1059 LIBS=$libs_save
1060 if test $mzs_ok = yes; then
1061 MZSCHEME_SRC="if_mzsch.c"
1062 MZSCHEME_OBJ="objects/if_mzsch.o"
1063 MZSCHEME_PRO="if_mzsch.pro"
1064 AC_DEFINE(FEAT_MZSCHEME)
1065 else
1066 MZSCHEME_CFLAGS=
1067 MZSCHEME_LIBS=
1068 MZSCHEME_EXTRA=
1069 MZSCHEME_MZC=
1070 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001071 fi
1072 AC_SUBST(MZSCHEME_SRC)
1073 AC_SUBST(MZSCHEME_OBJ)
1074 AC_SUBST(MZSCHEME_PRO)
1075 AC_SUBST(MZSCHEME_LIBS)
1076 AC_SUBST(MZSCHEME_CFLAGS)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001077 AC_SUBST(MZSCHEME_EXTRA)
1078 AC_SUBST(MZSCHEME_MZC)
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001079fi
1080
1081
Bram Moolenaar071d4272004-06-13 20:20:40 +00001082AC_MSG_CHECKING(--enable-perlinterp argument)
1083AC_ARG_ENABLE(perlinterp,
Bram Moolenaare06c1882010-07-21 22:05:20 +02001084 [ --enable-perlinterp[=OPTS] Include Perl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001085 [enable_perlinterp="no"])
1086AC_MSG_RESULT($enable_perlinterp)
Bram Moolenaare06c1882010-07-21 22:05:20 +02001087if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00001088 if test "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +01001089 AC_MSG_ERROR([cannot use Perl with tiny features])
Bram Moolenaar3c124e32016-01-31 14:36:58 +01001090 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001091 AC_SUBST(vi_cv_path_perl)
1092 AC_PATH_PROG(vi_cv_path_perl, perl)
1093 if test "X$vi_cv_path_perl" != "X"; then
1094 AC_MSG_CHECKING(Perl version)
1095 if $vi_cv_path_perl -e 'require 5.003_01' >/dev/null 2>/dev/null; then
1096 eval `$vi_cv_path_perl -V:usethreads`
Bram Moolenaare06c1882010-07-21 22:05:20 +02001097 eval `$vi_cv_path_perl -V:libperl`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001098 if test "X$usethreads" = "XUNKNOWN" -o "X$usethreads" = "Xundef"; then
1099 badthreads=no
1100 else
1101 if $vi_cv_path_perl -e 'require 5.6.0' >/dev/null 2>/dev/null; then
1102 eval `$vi_cv_path_perl -V:use5005threads`
1103 if test "X$use5005threads" = "XUNKNOWN" -o "X$use5005threads" = "Xundef"; then
1104 badthreads=no
1105 else
1106 badthreads=yes
1107 AC_MSG_RESULT(>>> Perl > 5.6 with 5.5 threads cannot be used <<<)
1108 fi
1109 else
1110 badthreads=yes
1111 AC_MSG_RESULT(>>> Perl 5.5 with threads cannot be used <<<)
1112 fi
1113 fi
1114 if test $badthreads = no; then
1115 AC_MSG_RESULT(OK)
1116 eval `$vi_cv_path_perl -V:shrpenv`
1117 if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04
1118 shrpenv=""
1119 fi
1120 vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlibexp}'`
1121 AC_SUBST(vi_cv_perllib)
Bram Moolenaard5f62b12014-08-17 17:05:44 +02001122 vi_cv_perl_extutils=unknown_perl_extutils_path
1123 for extutils_rel_path in ExtUtils vendor_perl/ExtUtils; do
1124 xsubpp_path="$vi_cv_perllib/$extutils_rel_path/xsubpp"
1125 if test -f "$xsubpp_path"; then
1126 vi_cv_perl_xsubpp="$xsubpp_path"
1127 fi
1128 done
1129 AC_SUBST(vi_cv_perl_xsubpp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001130 dnl Remove "-fno-something", it breaks using cproto.
Bram Moolenaar280a8682015-06-21 13:41:08 +02001131 dnl Remove "-fdebug-prefix-map", it isn't supported by clang.
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001132 dnl Remove "FORTIFY_SOURCE", it will be defined twice.
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001133 dnl remove -pipe and -Wxxx, it confuses cproto
Bram Moolenaar071d4272004-06-13 20:20:40 +00001134 perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001135 -e 'ccflags;perl_inc;print"\n"' | sed -e 's/-fno[[^ ]]*//' \
1136 -e 's/-fdebug-prefix-map[[^ ]]*//g' \
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001137 -e 's/-pipe //' \
1138 -e 's/-W[[^ ]]*//g' \
1139 -e 's/-D_FORTIFY_SOURCE=.//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001140 dnl Remove "-lc", it breaks on FreeBSD when using "-pthread".
1141 perllibs=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed -e 'ldopts' | \
1142 sed -e '/Warning/d' -e '/Note (probably harmless)/d' \
1143 -e 's/-bE:perl.exp//' -e 's/-lc //'`
1144 dnl Don't add perl lib to $LIBS: if it's not in LD_LIBRARY_PATH
1145 dnl a test in configure may fail because of that.
1146 perlldflags=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed \
1147 -e 'ccdlflags' | sed -e 's/-bE:perl.exp//'`
1148
1149 dnl check that compiling a simple program still works with the flags
1150 dnl added for Perl.
1151 AC_MSG_CHECKING([if compile and link flags for Perl are sane])
1152 cflags_save=$CFLAGS
1153 libs_save=$LIBS
1154 ldflags_save=$LDFLAGS
1155 CFLAGS="$CFLAGS $perlcppflags"
1156 LIBS="$LIBS $perllibs"
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001157 perlldflags=`echo "$perlldflags" | sed -e 's/^ *//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001158 LDFLAGS="$perlldflags $LDFLAGS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001159 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00001160 AC_MSG_RESULT(yes); perl_ok=yes,
1161 AC_MSG_RESULT(no: PERL DISABLED); perl_ok=no)
1162 CFLAGS=$cflags_save
1163 LIBS=$libs_save
1164 LDFLAGS=$ldflags_save
1165 if test $perl_ok = yes; then
1166 if test "X$perlcppflags" != "X"; then
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001167 PERL_CFLAGS=$perlcppflags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001168 fi
1169 if test "X$perlldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001170 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$perlldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001171 LDFLAGS="$perlldflags $LDFLAGS"
1172 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001173 fi
1174 PERL_LIBS=$perllibs
1175 PERL_SRC="auto/if_perl.c if_perlsfio.c"
1176 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o"
1177 PERL_PRO="if_perl.pro if_perlsfio.pro"
1178 AC_DEFINE(FEAT_PERL)
1179 fi
1180 fi
1181 else
1182 AC_MSG_RESULT(>>> too old; need Perl version 5.003_01 or later <<<)
1183 fi
1184 fi
1185
Bram Moolenaard0573012017-10-28 21:11:06 +02001186 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00001187 dnl Mac OS X 10.2 or later
Bram Moolenaar071d4272004-06-13 20:20:40 +00001188 dir=/System/Library/Perl
1189 darwindir=$dir/darwin
1190 if test -d $darwindir; then
1191 PERL=/usr/bin/perl
1192 else
1193 dnl Mac OS X 10.3
1194 dir=/System/Library/Perl/5.8.1
1195 darwindir=$dir/darwin-thread-multi-2level
1196 if test -d $darwindir; then
1197 PERL=/usr/bin/perl
1198 fi
1199 fi
1200 if test -n "$PERL"; then
1201 PERL_DIR="$dir"
1202 PERL_CFLAGS="-DFEAT_PERL -I$darwindir/CORE"
1203 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o $darwindir/auto/DynaLoader/DynaLoader.a"
1204 PERL_LIBS="-L$darwindir/CORE -lperl"
1205 fi
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001206 dnl Perl on Mac OS X 10.5 adds "-arch" flags but these should only
1207 dnl be included if requested by passing --with-mac-arch to
1208 dnl configure, so strip these flags first (if present)
1209 PERL_LIBS=`echo "$PERL_LIBS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
1210 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 +00001211 fi
Bram Moolenaare06c1882010-07-21 22:05:20 +02001212 if test "$enable_perlinterp" = "dynamic"; then
1213 if test "$perl_ok" = "yes" -a "X$libperl" != "X"; then
1214 AC_DEFINE(DYNAMIC_PERL)
1215 PERL_CFLAGS="-DDYNAMIC_PERL_DLL=\\\"$libperl\\\" $PERL_CFLAGS"
1216 fi
1217 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001218
1219 if test "$fail_if_missing" = "yes" -a "$perl_ok" != "yes"; then
1220 AC_MSG_ERROR([could not configure perl])
1221 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001222fi
1223AC_SUBST(shrpenv)
1224AC_SUBST(PERL_SRC)
1225AC_SUBST(PERL_OBJ)
1226AC_SUBST(PERL_PRO)
1227AC_SUBST(PERL_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00001228AC_SUBST(PERL_CFLAGS_EXTRA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001229AC_SUBST(PERL_LIBS)
1230
1231AC_MSG_CHECKING(--enable-pythoninterp argument)
1232AC_ARG_ENABLE(pythoninterp,
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001233 [ --enable-pythoninterp[=OPTS] Include Python interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001234 [enable_pythoninterp="no"])
1235AC_MSG_RESULT($enable_pythoninterp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001236if test "$enable_pythoninterp" = "yes" -o "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00001237 if test "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +01001238 AC_MSG_ERROR([cannot use Python with tiny features])
Bram Moolenaar0b105412014-11-30 13:34:23 +01001239 fi
1240
Bram Moolenaar071d4272004-06-13 20:20:40 +00001241 dnl -- find the python executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001242 AC_MSG_CHECKING(--with-python-command argument)
1243 AC_SUBST(vi_cv_path_python)
1244 AC_ARG_WITH(python-command, [ --with-python-command=NAME name of the Python 2 command (default: python2 or python)],
1245 vi_cv_path_python="$withval"; AC_MSG_RESULT($vi_cv_path_python),
1246 AC_MSG_RESULT(no))
1247
1248 if test "X$vi_cv_path_python" = "X"; then
1249 AC_PATH_PROGS(vi_cv_path_python, python2 python)
1250 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001251 if test "X$vi_cv_path_python" != "X"; then
1252
1253 dnl -- get its version number
1254 AC_CACHE_CHECK(Python version,vi_cv_var_python_version,
1255 [[vi_cv_var_python_version=`
1256 ${vi_cv_path_python} -c 'import sys; print sys.version[:3]'`
1257 ]])
1258
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001259 dnl -- it must be at least version 2.3
1260 AC_MSG_CHECKING(Python is 2.3 or better)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001261 if ${vi_cv_path_python} -c \
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001262 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001263 then
1264 AC_MSG_RESULT(yep)
1265
1266 dnl -- find where python thinks it was installed
1267 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python_pfx,
1268 [ vi_cv_path_python_pfx=`
1269 ${vi_cv_path_python} -c \
1270 "import sys; print sys.prefix"` ])
1271
1272 dnl -- and where it thinks it runs
1273 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python_epfx,
1274 [ vi_cv_path_python_epfx=`
1275 ${vi_cv_path_python} -c \
1276 "import sys; print sys.exec_prefix"` ])
1277
1278 dnl -- python's internal library path
1279
1280 AC_CACHE_VAL(vi_cv_path_pythonpath,
1281 [ vi_cv_path_pythonpath=`
1282 unset PYTHONPATH;
1283 ${vi_cv_path_python} -c \
1284 "import sys, string; print string.join(sys.path,':')"` ])
1285
1286 dnl -- where the Python implementation library archives are
1287
1288 AC_ARG_WITH(python-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001289 [ --with-python-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001290 [ vi_cv_path_python_conf="${withval}"; have_python_config_dir=1 ] )
Bram Moolenaar071d4272004-06-13 20:20:40 +00001291
1292 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python_conf,
1293 [
1294 vi_cv_path_python_conf=
Bram Moolenaarac499e32013-06-02 19:14:17 +02001295 d=`${vi_cv_path_python} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBPL')"`
1296 if test -d "$d" && test -f "$d/config.c"; then
1297 vi_cv_path_python_conf="$d"
1298 else
1299 for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
1300 for subdir in lib64 lib share; do
1301 d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
1302 if test -d "$d" && test -f "$d/config.c"; then
1303 vi_cv_path_python_conf="$d"
1304 fi
1305 done
Bram Moolenaar071d4272004-06-13 20:20:40 +00001306 done
Bram Moolenaarac499e32013-06-02 19:14:17 +02001307 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001308 ])
1309
1310 PYTHON_CONFDIR="${vi_cv_path_python_conf}"
1311
1312 if test "X$PYTHON_CONFDIR" = "X"; then
1313 AC_MSG_RESULT([can't find it!])
1314 else
1315
1316 dnl -- we need to examine Python's config/Makefile too
1317 dnl see what the interpreter is built from
1318 AC_CACHE_VAL(vi_cv_path_python_plibs,
1319 [
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001320 pwd=`pwd`
1321 tmp_mkf="$pwd/config-PyMake$$"
1322 cat -- "${PYTHON_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001323__:
Bram Moolenaar218116c2010-05-20 21:46:00 +02001324 @echo "python_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001325 @echo "python_LIBS='$(LIBS)'"
1326 @echo "python_SYSLIBS='$(SYSLIBS)'"
1327 @echo "python_LINKFORSHARED='$(LINKFORSHARED)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001328 @echo "python_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001329 @echo "python_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001330 @echo "python_PYTHONFRAMEWORK='$(PYTHONFRAMEWORK)'"
1331 @echo "python_PYTHONFRAMEWORKPREFIX='$(PYTHONFRAMEWORKPREFIX)'"
1332 @echo "python_PYTHONFRAMEWORKINSTALLDIR='$(PYTHONFRAMEWORKINSTALLDIR)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001333eof
1334 dnl -- delete the lines from make about Entering/Leaving directory
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001335 eval "`cd ${PYTHON_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1336 rm -f -- "${tmp_mkf}"
Bram Moolenaard0573012017-10-28 21:11:06 +02001337 if test "x$MACOS_X" = "xyes" && test -n "${python_PYTHONFRAMEWORK}" && ${vi_cv_path_python} -c \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001338 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then
1339 vi_cv_path_python_plibs="-framework Python"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001340 if test "x${vi_cv_path_python}" != "x/usr/bin/python" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
1341 vi_cv_path_python_plibs="-F${python_PYTHONFRAMEWORKPREFIX} -framework Python"
1342 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001343 else
Bram Moolenaar9ce42132018-04-11 22:19:36 +02001344 vi_cv_path_python_plibs="-L${PYTHON_CONFDIR} -lpython${vi_cv_var_python_version}"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001345 dnl -- Check if the path contained in python_LINKFORSHARED is
1346 dnl usable for vim build. If not, make and try other
1347 dnl candidates.
Bram Moolenaara161e262015-03-24 15:14:27 +01001348 if test -n "${python_LINKFORSHARED}" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
Bram Moolenaar6c927552015-03-24 12:21:33 +01001349 python_link_symbol=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]].*/\1/'`
1350 python_link_path=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]][[ \t]]*\(.*\)/\2/'`
1351 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1352 dnl -- The path looks relative. Guess the absolute one using
1353 dnl the prefix and try that.
1354 python_link_path="${python_PYTHONFRAMEWORKPREFIX}/${python_link_path}"
1355 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1356 dnl -- A last resort.
1357 python_link_path="${python_PYTHONFRAMEWORKINSTALLDIR}/Versions/${vi_cv_var_python_version}/${python_PYTHONFRAMEWORK}"
1358 dnl -- No check is done. The last word is left to the
1359 dnl "sanity" test on link flags that follows shortly.
1360 fi
1361 python_LINKFORSHARED="${python_link_symbol} ${python_link_path}"
1362 fi
1363 fi
Bram Moolenaar218116c2010-05-20 21:46:00 +02001364 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 +00001365 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1366 vi_cv_path_python_plibs=`echo $vi_cv_path_python_plibs | sed s/-ltermcap//`
1367 fi
1368 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001369 AC_CACHE_CHECK(Python's dll name,vi_cv_dll_name_python,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001370 [
1371 if test "X$python_DLLLIBRARY" != "X"; then
1372 vi_cv_dll_name_python="$python_DLLLIBRARY"
1373 else
1374 vi_cv_dll_name_python="$python_INSTSONAME"
1375 fi
1376 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00001377
1378 PYTHON_LIBS="${vi_cv_path_python_plibs}"
1379 if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001380 PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001381 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001382 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 +00001383 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001384 if test "X$have_python_config_dir" = "X1" -a "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001385 dnl Define PYTHON_HOME if --with-python-config-dir was used
1386 PYTHON_CFLAGS="${PYTHON_CFLAGS} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'"
1387
1388 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001389 PYTHON_SRC="if_python.c"
Bram Moolenaar9bdb9a02012-07-25 16:32:08 +02001390 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001391
1392 dnl On FreeBSD linking with "-pthread" is required to use threads.
1393 dnl _THREAD_SAFE must be used for compiling then.
1394 dnl The "-pthread" is added to $LIBS, so that the following check for
1395 dnl sigaltstack() will look in libc_r (it's there in libc!).
1396 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1397 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1398 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1399 AC_MSG_CHECKING([if -pthread should be used])
1400 threadsafe_flag=
1401 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001402 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001403 if test "$vim_cv_uname_output" != Darwin; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001404 test "$GCC" = yes && threadsafe_flag="-pthread"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001405 if test "$vim_cv_uname_output" = FreeBSD; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001406 threadsafe_flag="-D_THREAD_SAFE"
1407 thread_lib="-pthread"
1408 fi
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001409 if test "$vim_cv_uname_output" = SunOS; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001410 threadsafe_flag="-pthreads"
1411 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001412 fi
1413 libs_save_old=$LIBS
1414 if test -n "$threadsafe_flag"; then
1415 cflags_save=$CFLAGS
1416 CFLAGS="$CFLAGS $threadsafe_flag"
1417 LIBS="$LIBS $thread_lib"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001418 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001419 AC_MSG_RESULT(yes); PYTHON_CFLAGS="$PYTHON_CFLAGS $threadsafe_flag",
Bram Moolenaar071d4272004-06-13 20:20:40 +00001420 AC_MSG_RESULT(no); LIBS=$libs_save_old
1421 )
1422 CFLAGS=$cflags_save
1423 else
1424 AC_MSG_RESULT(no)
1425 fi
1426
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001427 dnl Check that compiling a simple program still works with the flags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001428 dnl added for Python.
1429 AC_MSG_CHECKING([if compile and link flags for Python are sane])
1430 cflags_save=$CFLAGS
1431 libs_save=$LIBS
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001432 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001433 LIBS="$LIBS $PYTHON_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001434 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00001435 AC_MSG_RESULT(yes); python_ok=yes,
1436 AC_MSG_RESULT(no: PYTHON DISABLED); python_ok=no)
1437 CFLAGS=$cflags_save
1438 LIBS=$libs_save
1439 if test $python_ok = yes; then
1440 AC_DEFINE(FEAT_PYTHON)
1441 else
1442 LIBS=$libs_save_old
1443 PYTHON_SRC=
1444 PYTHON_OBJ=
1445 PYTHON_LIBS=
1446 PYTHON_CFLAGS=
1447 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001448 fi
1449 else
1450 AC_MSG_RESULT(too old)
1451 fi
1452 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001453
1454 if test "$fail_if_missing" = "yes" -a "$python_ok" != "yes"; then
1455 AC_MSG_ERROR([could not configure python])
1456 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001457fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001458
Bram Moolenaar071d4272004-06-13 20:20:40 +00001459AC_SUBST(PYTHON_LIBS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001460AC_SUBST(PYTHON_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00001461AC_SUBST(PYTHON_CFLAGS_EXTRA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001462AC_SUBST(PYTHON_SRC)
1463AC_SUBST(PYTHON_OBJ)
1464
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001465
1466AC_MSG_CHECKING(--enable-python3interp argument)
1467AC_ARG_ENABLE(python3interp,
Bram Moolenaar8008b632017-07-18 21:33:20 +02001468 [ --enable-python3interp[=OPTS] Include Python3 interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001469 [enable_python3interp="no"])
1470AC_MSG_RESULT($enable_python3interp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001471if test "$enable_python3interp" = "yes" -o "$enable_python3interp" = "dynamic"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00001472 if test "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +01001473 AC_MSG_ERROR([cannot use Python with tiny features])
Bram Moolenaar0b105412014-11-30 13:34:23 +01001474 fi
1475
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001476 dnl -- find the python3 executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001477 AC_MSG_CHECKING(--with-python3-command argument)
1478 AC_SUBST(vi_cv_path_python3)
1479 AC_ARG_WITH(python3-command, [ --with-python3-command=NAME name of the Python 3 command (default: python3 or python)],
1480 vi_cv_path_python3="$withval"; AC_MSG_RESULT($vi_cv_path_python3),
1481 AC_MSG_RESULT(no))
1482
1483 if test "X$vi_cv_path_python3" = "X"; then
1484 AC_PATH_PROGS(vi_cv_path_python3, python3 python)
1485 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001486 if test "X$vi_cv_path_python3" != "X"; then
1487
1488 dnl -- get its version number
1489 AC_CACHE_CHECK(Python version,vi_cv_var_python3_version,
1490 [[vi_cv_var_python3_version=`
Bram Moolenaar23c01922021-05-21 11:43:58 +02001491 ${vi_cv_path_python3} -c 'import sys; print("{}.{}".format(sys.version_info.major, sys.version_info.minor))'`
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001492 ]])
1493
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001494 dnl -- it must be at least version 3
1495 AC_MSG_CHECKING(Python is 3.0 or better)
1496 if ${vi_cv_path_python3} -c \
1497 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.0)"
1498 then
1499 AC_MSG_RESULT(yep)
Bram Moolenaar456f2bb2011-06-12 21:37:13 +02001500
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001501 dnl -- get abiflags for python 3.2 or higher (PEP 3149)
1502 AC_CACHE_CHECK(Python's abiflags,vi_cv_var_python3_abiflags,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001503 [
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001504 vi_cv_var_python3_abiflags=
1505 if ${vi_cv_path_python3} -c \
1506 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)"
1507 then
Bram Moolenaare5303952022-06-19 17:05:47 +01001508 vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001509 "import sys; print(sys.abiflags)"`
1510 fi ])
Bram Moolenaare5303952022-06-19 17:05:47 +01001511
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001512 dnl -- find where python3 thinks it was installed
1513 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx,
1514 [ vi_cv_path_python3_pfx=`
1515 ${vi_cv_path_python3} -c \
1516 "import sys; print(sys.prefix)"` ])
Bram Moolenaare5303952022-06-19 17:05:47 +01001517
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001518 dnl -- and where it thinks it runs
1519 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx,
1520 [ vi_cv_path_python3_epfx=`
1521 ${vi_cv_path_python3} -c \
1522 "import sys; print(sys.exec_prefix)"` ])
Bram Moolenaare5303952022-06-19 17:05:47 +01001523
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001524 dnl -- python3's internal library path
Bram Moolenaare5303952022-06-19 17:05:47 +01001525
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001526 AC_CACHE_VAL(vi_cv_path_python3path,
1527 [ vi_cv_path_python3path=`
1528 unset PYTHONPATH;
1529 ${vi_cv_path_python3} -c \
1530 "import sys, string; print(':'.join(sys.path))"` ])
Bram Moolenaare5303952022-06-19 17:05:47 +01001531
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001532 dnl -- where the Python implementation library archives are
Bram Moolenaare5303952022-06-19 17:05:47 +01001533
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001534 AC_ARG_WITH(python3-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001535 [ --with-python3-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001536 [ vi_cv_path_python3_conf="${withval}"; have_python3_config_dir=1 ] )
Bram Moolenaare5303952022-06-19 17:05:47 +01001537
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001538 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf,
1539 [
1540 vi_cv_path_python3_conf=
Bram Moolenaarfee496d2013-07-12 20:07:24 +02001541 config_dir="config-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Zdenek Dohnal31e299c2021-06-10 18:50:55 +02001542 d=`${vi_cv_path_python3} -c "import sysconfig; print(sysconfig.get_config_var('LIBPL'))" 2> /dev/null`
1543 if test "x$d" = "x"; then
1544 d=`${vi_cv_path_python3} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBPL'))"`
1545 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001546 if test -d "$d" && test -f "$d/config.c"; then
1547 vi_cv_path_python3_conf="$d"
1548 else
1549 for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do
1550 for subdir in lib64 lib share; do
1551 d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}"
1552 if test -d "$d" && test -f "$d/config.c"; then
1553 vi_cv_path_python3_conf="$d"
1554 fi
1555 done
1556 done
1557 fi
1558 ])
Bram Moolenaare5303952022-06-19 17:05:47 +01001559
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001560 PYTHON3_CONFDIR="${vi_cv_path_python3_conf}"
Bram Moolenaare5303952022-06-19 17:05:47 +01001561
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001562 if test "X$PYTHON3_CONFDIR" = "X"; then
1563 AC_MSG_RESULT([can't find it!])
1564 else
Bram Moolenaare5303952022-06-19 17:05:47 +01001565
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001566 dnl -- we need to examine Python's config/Makefile too
1567 dnl see what the interpreter is built from
1568 AC_CACHE_VAL(vi_cv_path_python3_plibs,
1569 [
1570 pwd=`pwd`
1571 tmp_mkf="$pwd/config-PyMake$$"
1572 cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001573__:
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001574 @echo "python3_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001575 @echo "python3_LIBS='$(LIBS)'"
1576 @echo "python3_SYSLIBS='$(SYSLIBS)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001577 @echo "python3_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001578 @echo "python3_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001579eof
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001580 dnl -- delete the lines from make about Entering/Leaving directory
1581 eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1582 rm -f -- "${tmp_mkf}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001583 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 +02001584 vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}"
1585 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1586 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//`
1587 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//`
1588 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001589 AC_CACHE_CHECK(Python3's dll name,vi_cv_dll_name_python3,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001590 [
1591 if test "X$python3_DLLLIBRARY" != "X"; then
1592 vi_cv_dll_name_python3="$python3_DLLLIBRARY"
1593 else
1594 vi_cv_dll_name_python3="$python3_INSTSONAME"
1595 fi
1596 ])
1597
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001598 PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
1599 if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001600 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 +02001601 else
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} -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 +02001603 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001604 if test "X$have_python3_config_dir" = "X1" -a "$enable_python3interp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001605 dnl Define PYTHON3_HOME if --with-python-config-dir was used
1606 PYTHON3_CFLAGS="${PYTHON3_CFLAGS} -DPYTHON3_HOME='L\"${vi_cv_path_python3_pfx}\"'"
1607 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001608 PYTHON3_SRC="if_python3.c"
1609 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaare5303952022-06-19 17:05:47 +01001610
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001611 dnl On FreeBSD linking with "-pthread" is required to use threads.
1612 dnl _THREAD_SAFE must be used for compiling then.
1613 dnl The "-pthread" is added to $LIBS, so that the following check for
1614 dnl sigaltstack() will look in libc_r (it's there in libc!).
1615 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1616 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1617 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1618 AC_MSG_CHECKING([if -pthread should be used])
1619 threadsafe_flag=
1620 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001621 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001622 if test "$vim_cv_uname_output" != Darwin; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001623 test "$GCC" = yes && threadsafe_flag="-pthread"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001624 if test "$vim_cv_uname_output" = FreeBSD; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001625 threadsafe_flag="-D_THREAD_SAFE"
1626 thread_lib="-pthread"
1627 fi
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001628 if test "$vim_cv_uname_output" = SunOS; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001629 threadsafe_flag="-pthreads"
1630 fi
1631 fi
1632 libs_save_old=$LIBS
1633 if test -n "$threadsafe_flag"; then
1634 cflags_save=$CFLAGS
1635 CFLAGS="$CFLAGS $threadsafe_flag"
1636 LIBS="$LIBS $thread_lib"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001637 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001638 AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag",
1639 AC_MSG_RESULT(no); LIBS=$libs_save_old
1640 )
1641 CFLAGS=$cflags_save
1642 else
1643 AC_MSG_RESULT(no)
1644 fi
Bram Moolenaare5303952022-06-19 17:05:47 +01001645
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001646 dnl check that compiling a simple program still works with the flags
1647 dnl added for Python.
1648 AC_MSG_CHECKING([if compile and link flags for Python 3 are sane])
1649 cflags_save=$CFLAGS
1650 libs_save=$LIBS
1651 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1652 LIBS="$LIBS $PYTHON3_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001653 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001654 AC_MSG_RESULT(yes); python3_ok=yes,
1655 AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no)
1656 CFLAGS=$cflags_save
1657 LIBS=$libs_save
1658 if test "$python3_ok" = yes; then
1659 AC_DEFINE(FEAT_PYTHON3)
1660 else
1661 LIBS=$libs_save_old
1662 PYTHON3_SRC=
1663 PYTHON3_OBJ=
1664 PYTHON3_LIBS=
1665 PYTHON3_CFLAGS=
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001666 fi
1667 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001668 else
1669 AC_MSG_RESULT(too old)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001670 fi
1671 fi
Bram Moolenaar1612b1a2013-06-14 21:22:39 +02001672 if test "$fail_if_missing" = "yes" -a "$python3_ok" != "yes"; then
1673 AC_MSG_ERROR([could not configure python3])
1674 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001675fi
1676
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001677AC_SUBST(PYTHON3_LIBS)
1678AC_SUBST(PYTHON3_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00001679AC_SUBST(PYTHON3_CFLAGS_EXTRA)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001680AC_SUBST(PYTHON3_SRC)
1681AC_SUBST(PYTHON3_OBJ)
1682
1683dnl if python2.x and python3.x are enabled one can only link in code
Bram Moolenaare5303952022-06-19 17:05:47 +01001684dnl with dlopen(), dlsym(), dlclose()
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001685if test "$python_ok" = yes && test "$python3_ok" = yes; then
1686 AC_DEFINE(DYNAMIC_PYTHON)
1687 AC_DEFINE(DYNAMIC_PYTHON3)
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001688 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001689 cflags_save=$CFLAGS
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001690 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001691 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001692 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001693 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001694 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001695 #include <dlfcn.h>
1696 /* If this program fails, then RTLD_GLOBAL is needed.
1697 * RTLD_GLOBAL will be used and then it is not possible to
1698 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001699 * Only the first python version used will be switched on.
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001700 */
1701
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01001702 static int no_rtl_global_needed_for(char *python_instsoname, char *prefix)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001703 {
1704 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001705 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001706 if (pylib != 0)
1707 {
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001708 void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome");
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001709 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1710 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1711 void (*final)(void) = dlsym(pylib, "Py_Finalize");
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001712 (*pfx)(prefix);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001713 (*init)();
1714 needed = (*simple)("import termios") == -1;
1715 (*final)();
1716 dlclose(pylib);
1717 }
1718 return !needed;
1719 }
1720
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01001721 int main()
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001722 {
1723 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001724 if (no_rtl_global_needed_for("${vi_cv_dll_name_python}", "${vi_cv_path_python_pfx}"))
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001725 not_needed = 1;
1726 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001727 }])],
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001728 [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001729
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001730 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001731 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001732
1733 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python3)
1734 cflags_save=$CFLAGS
1735 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001736 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001737 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001738 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001739 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001740 #include <dlfcn.h>
1741 #include <wchar.h>
1742 /* If this program fails, then RTLD_GLOBAL is needed.
1743 * RTLD_GLOBAL will be used and then it is not possible to
1744 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001745 * Only the first python version used will be switched on.
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001746 */
1747
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01001748 static int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix)
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001749 {
1750 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001751 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001752 if (pylib != 0)
1753 {
1754 void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome");
1755 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1756 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1757 void (*final)(void) = dlsym(pylib, "Py_Finalize");
1758 (*pfx)(prefix);
1759 (*init)();
1760 needed = (*simple)("import termios") == -1;
1761 (*final)();
1762 dlclose(pylib);
1763 }
1764 return !needed;
1765 }
1766
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01001767 int main()
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001768 {
1769 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001770 if (no_rtl_global_needed_for("${vi_cv_dll_name_python3}", L"${vi_cv_path_python3_pfx}"))
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001771 not_needed = 1;
1772 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001773 }])],
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001774 [AC_MSG_RESULT(yes);AC_DEFINE(PY3_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
1775
1776 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001777 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001778
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001779 PYTHON_SRC="if_python.c"
1780 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001781 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001782 PYTHON_LIBS=
1783 PYTHON3_SRC="if_python3.c"
1784 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001785 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001786 PYTHON3_LIBS=
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001787elif test "$python_ok" = yes && test "$enable_pythoninterp" = "dynamic"; then
1788 AC_DEFINE(DYNAMIC_PYTHON)
1789 PYTHON_SRC="if_python.c"
1790 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001791 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001792 PYTHON_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001793elif test "$python_ok" = yes; then
1794 dnl Check that adding -fPIE works. It may be needed when using a static
1795 dnl Python library.
1796 AC_MSG_CHECKING([if -fPIE can be added for Python])
1797 cflags_save=$CFLAGS
1798 libs_save=$LIBS
1799 CFLAGS="$CFLAGS $PYTHON_CFLAGS -fPIE"
1800 LIBS="$LIBS $PYTHON_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001801 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaare741f272013-07-09 21:57:52 +02001802 AC_MSG_RESULT(yes); fpie_ok=yes,
1803 AC_MSG_RESULT(no); fpie_ok=no)
1804 CFLAGS=$cflags_save
1805 LIBS=$libs_save
1806 if test $fpie_ok = yes; then
1807 PYTHON_CFLAGS="$PYTHON_CFLAGS -fPIE"
1808 fi
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001809elif test "$python3_ok" = yes && test "$enable_python3interp" = "dynamic"; then
1810 AC_DEFINE(DYNAMIC_PYTHON3)
1811 PYTHON3_SRC="if_python3.c"
1812 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001813 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001814 PYTHON3_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001815elif test "$python3_ok" = yes; then
1816 dnl Check that adding -fPIE works. It may be needed when using a static
1817 dnl Python library.
1818 AC_MSG_CHECKING([if -fPIE can be added for Python3])
1819 cflags_save=$CFLAGS
1820 libs_save=$LIBS
1821 CFLAGS="$CFLAGS $PYTHON3_CFLAGS -fPIE"
1822 LIBS="$LIBS $PYTHON3_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01001823 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[ ])],
Bram Moolenaare741f272013-07-09 21:57:52 +02001824 AC_MSG_RESULT(yes); fpie_ok=yes,
1825 AC_MSG_RESULT(no); fpie_ok=no)
1826 CFLAGS=$cflags_save
1827 LIBS=$libs_save
1828 if test $fpie_ok = yes; then
1829 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -fPIE"
1830 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001831fi
1832
Bram Moolenaar071d4272004-06-13 20:20:40 +00001833AC_MSG_CHECKING(--enable-tclinterp argument)
1834AC_ARG_ENABLE(tclinterp,
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001835 [ --enable-tclinterp[=OPTS] Include Tcl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001836 [enable_tclinterp="no"])
1837AC_MSG_RESULT($enable_tclinterp)
1838
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001839if test "$enable_tclinterp" = "yes" -o "$enable_tclinterp" = "dynamic"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001840
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001841 dnl on FreeBSD tclsh is a silly script, look for tclsh8.[5420]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001842 AC_MSG_CHECKING(--with-tclsh argument)
1843 AC_ARG_WITH(tclsh, [ --with-tclsh=PATH which tclsh to use (default: tclsh8.0)],
1844 tclsh_name="$withval"; AC_MSG_RESULT($tclsh_name),
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001845 tclsh_name="tclsh8.5"; AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00001846 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1847 AC_SUBST(vi_cv_path_tcl)
1848
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001849 dnl when no specific version specified, also try 8.4, 8.2 and 8.0
1850 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.5"; then
1851 tclsh_name="tclsh8.4"
1852 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1853 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001854 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.4"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001855 tclsh_name="tclsh8.2"
1856 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1857 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001858 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.2"; then
1859 tclsh_name="tclsh8.0"
1860 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1861 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001862 dnl still didn't find it, try without version number
1863 if test "X$vi_cv_path_tcl" = "X"; then
1864 tclsh_name="tclsh"
1865 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1866 fi
1867 if test "X$vi_cv_path_tcl" != "X"; then
1868 AC_MSG_CHECKING(Tcl version)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001869 if echo 'exit [[expr [info tclversion] < 8.0]]' | "$vi_cv_path_tcl" - ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001870 tclver=`echo 'puts [[info tclversion]]' | $vi_cv_path_tcl -`
1871 AC_MSG_RESULT($tclver - OK);
1872 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 +01001873 tcldll=`echo 'puts libtcl[[info tclversion]][[info sharedlibextension]]' | $vi_cv_path_tcl -`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001874
1875 AC_MSG_CHECKING(for location of Tcl include)
Bram Moolenaard0573012017-10-28 21:11:06 +02001876 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001877 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 +00001878 else
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001879 dnl For all macOS, use the value from TCL in case use of, say, homebrew
Bram Moolenaar071d4272004-06-13 20:20:40 +00001880 dnl For Mac OS X 10.3, use the OS-provided framework location
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001881 dnl For Mac OS X 10.14, the OS-provided framework location doesn't contain the headers, so also check the Xcode SDK
1882 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 +00001883 fi
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001884 TCL_INC=
Bram Moolenaar071d4272004-06-13 20:20:40 +00001885 for try in $tclinc; do
1886 if test -f "$try/tcl.h"; then
1887 AC_MSG_RESULT($try/tcl.h)
1888 TCL_INC=$try
1889 break
1890 fi
1891 done
1892 if test -z "$TCL_INC"; then
1893 AC_MSG_RESULT(<not found>)
1894 SKIP_TCL=YES
1895 fi
1896 if test -z "$SKIP_TCL"; then
1897 AC_MSG_CHECKING(for location of tclConfig.sh script)
Bram Moolenaard0573012017-10-28 21:11:06 +02001898 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001899 tclcnf=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001900 tclcnf="$tclcnf `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001901 else
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001902 dnl For all macOS, use the value from TCL in case use of, say, homebrew
Bram Moolenaar071d4272004-06-13 20:20:40 +00001903 dnl For Mac OS X 10.3, use the OS-provided framework location
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001904 dnl For Mac OS X 10.14, the OS-provided framework location doesn't contain the headers, so also check the Xcode SDK
1905 tclcnf=`echo $tclinc | sed s/include/lib/g`
1906 tclcnf="$tclcnf /System/Library/Frameworks/Tcl.framework `xcrun --show-sdk-path`/System/Library/Frameworks/Tcl.framework"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001907 fi
1908 for try in $tclcnf; do
Bram Moolenaar49222be2015-12-11 18:11:30 +01001909 if test -f "$try/tclConfig.sh"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001910 AC_MSG_RESULT($try/tclConfig.sh)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001911 . "$try/tclConfig.sh"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001912 dnl use eval, because tcl 8.2 includes ${TCL_DBGX}
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001913 if test "$enable_tclinterp" = "dynamic"; then
1914 TCL_LIBS=`eval echo "$TCL_STUB_LIB_SPEC $TCL_LIBS"`
1915 else
1916 TCL_LIBS=`eval echo "$TCL_LIB_SPEC $TCL_LIBS"`
1917 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001918 dnl Use $TCL_DEFS for -D_THREAD_SAFE et al. But only use the
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001919 dnl "-D_ABC" items. Watch out for -DFOO=long\ long.
Bram Moolenaar4394bff2008-07-24 11:21:31 +00001920 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 +00001921 break
1922 fi
1923 done
1924 if test -z "$TCL_LIBS"; then
1925 AC_MSG_RESULT(<not found>)
1926 AC_MSG_CHECKING(for Tcl library by myself)
1927 tcllib=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001928 tcllib="$tcllib `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001929 for ext in .so .a ; do
1930 for ver in "" $tclver ; do
1931 for try in $tcllib ; do
1932 trylib=tcl$ver$ext
Bram Moolenaar49222be2015-12-11 18:11:30 +01001933 if test -f "$try/lib$trylib" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001934 AC_MSG_RESULT($try/lib$trylib)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001935 TCL_LIBS="-L\"$try\" -ltcl$ver -ldl -lm"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00001936 if test "$vim_cv_uname_output" = SunOS &&
1937 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001938 TCL_LIBS="$TCL_LIBS -R $try"
1939 fi
1940 break 3
1941 fi
1942 done
1943 done
1944 done
1945 if test -z "$TCL_LIBS"; then
1946 AC_MSG_RESULT(<not found>)
1947 SKIP_TCL=YES
1948 fi
1949 fi
1950 if test -z "$SKIP_TCL"; then
1951 AC_DEFINE(FEAT_TCL)
1952 TCL_SRC=if_tcl.c
1953 TCL_OBJ=objects/if_tcl.o
1954 TCL_PRO=if_tcl.pro
1955 TCL_CFLAGS="-I$TCL_INC $TCL_DEFS"
1956 fi
1957 fi
1958 else
1959 AC_MSG_RESULT(too old; need Tcl version 8.0 or later)
1960 fi
1961 fi
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001962 if test "$enable_tclinterp" = "dynamic"; then
1963 if test "X$TCL_SRC" != "X" -a "X$tcldll" != "X"; then
1964 AC_DEFINE(DYNAMIC_TCL)
1965 TCL_CFLAGS="-DDYNAMIC_TCL_DLL=\\\"$tcldll\\\" -DDYNAMIC_TCL_VER=\\\"$tclver\\\" $TCL_CFLAGS"
1966 fi
1967 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001968 if test "$fail_if_missing" = "yes" -a -z "$TCL_SRC"; then
1969 AC_MSG_ERROR([could not configure Tcl])
1970 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001971fi
1972AC_SUBST(TCL_SRC)
1973AC_SUBST(TCL_OBJ)
1974AC_SUBST(TCL_PRO)
1975AC_SUBST(TCL_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00001976AC_SUBST(TCL_CFLAGS_EXTRA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001977AC_SUBST(TCL_LIBS)
1978
1979AC_MSG_CHECKING(--enable-rubyinterp argument)
1980AC_ARG_ENABLE(rubyinterp,
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001981 [ --enable-rubyinterp[=OPTS] Include Ruby interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001982 [enable_rubyinterp="no"])
1983AC_MSG_RESULT($enable_rubyinterp)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001984if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00001985 if test "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +01001986 AC_MSG_ERROR([cannot use Ruby with tiny features])
Bram Moolenaar0b105412014-11-30 13:34:23 +01001987 fi
1988
Bram Moolenaar165641d2010-02-17 16:23:09 +01001989 AC_MSG_CHECKING(--with-ruby-command argument)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001990 AC_SUBST(vi_cv_path_ruby)
Bram Moolenaar948733a2011-05-05 18:10:16 +02001991 AC_ARG_WITH(ruby-command, [ --with-ruby-command=RUBY name of the Ruby command (default: ruby)],
1992 RUBY_CMD="$withval"; vi_cv_path_ruby="$withval"; AC_MSG_RESULT($RUBY_CMD),
1993 RUBY_CMD="ruby"; AC_MSG_RESULT(defaulting to $RUBY_CMD))
Bram Moolenaar165641d2010-02-17 16:23:09 +01001994 AC_PATH_PROG(vi_cv_path_ruby, $RUBY_CMD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001995 if test "X$vi_cv_path_ruby" != "X"; then
1996 AC_MSG_CHECKING(Ruby version)
K.Takata236ccbf2022-09-22 16:12:06 +01001997 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 +00001998 AC_MSG_RESULT(OK)
Bram Moolenaar81398892012-10-03 21:09:35 +02001999 AC_MSG_CHECKING(Ruby rbconfig)
2000 ruby_rbconfig="RbConfig"
2001 if ! $vi_cv_path_ruby -r rbconfig -e 'RbConfig' >/dev/null 2>/dev/null; then
2002 ruby_rbconfig="Config"
2003 fi
2004 AC_MSG_RESULT($ruby_rbconfig)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002005 AC_MSG_CHECKING(Ruby header files)
Bram Moolenaar81398892012-10-03 21:09:35 +02002006 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 +00002007 if test "X$rubyhdrdir" != "X"; then
2008 AC_MSG_RESULT($rubyhdrdir)
2009 RUBY_CFLAGS="-I$rubyhdrdir"
Bram Moolenaara6fd37b2014-03-27 17:19:09 +01002010 rubyarchdir=`$vi_cv_path_ruby -r rbconfig -e "print ($ruby_rbconfig::CONFIG.has_key? 'rubyarchhdrdir') ? $ruby_rbconfig::CONFIG[['rubyarchhdrdir']] : '$rubyhdrdir/'+$ruby_rbconfig::CONFIG[['arch']]"`
2011 if test -d "$rubyarchdir"; then
2012 RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyarchdir"
Bram Moolenaar165641d2010-02-17 16:23:09 +01002013 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02002014 rubyversion=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['ruby_version']].gsub(/\./, '')[[0,2]]"`
Bram Moolenaar026a4452013-08-07 15:22:23 +02002015 if test "X$rubyversion" = "X"; then
K.Takata236ccbf2022-09-22 16:12:06 +01002016 rubyversion=`$vi_cv_path_ruby -e "print RUBY_VERSION.gsub(/\./, '')[[0,2]]"`
Bram Moolenaar026a4452013-08-07 15:22:23 +02002017 fi
Bram Moolenaar165641d2010-02-17 16:23:09 +01002018 RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
Bram Moolenaar81398892012-10-03 21:09:35 +02002019 rubylibs=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LIBS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002020 if test "X$rubylibs" != "X"; then
2021 RUBY_LIBS="$rubylibs"
2022 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02002023 librubyarg=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBYARG']])"`
2024 librubya=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBY_A']])"`
Bram Moolenaarac499e32013-06-02 19:14:17 +02002025 rubylibdir=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['libdir']])"`
Bram Moolenaard5a986f2020-12-06 21:11:31 +01002026 if test -f "$rubylibdir/$librubya" || expr "$librubyarg" : "-lruby"; then
Bram Moolenaarac499e32013-06-02 19:14:17 +02002027 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
2028 elif test "$librubyarg" = "libruby.a"; then
2029 dnl required on Mac OS 10.3 where libruby.a doesn't exist
2030 librubyarg="-lruby"
2031 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002032 fi
2033
2034 if test "X$librubyarg" != "X"; then
2035 RUBY_LIBS="$librubyarg $RUBY_LIBS"
2036 fi
Zdenek Dohnal1d822af2022-11-23 12:06:08 +00002037
2038 dnl Here the Ruby LDFLAGS used to be added to LDFLAGS, but that turns
2039 dnl out to cause trouble and was removed.
2040
Bram Moolenaar071d4272004-06-13 20:20:40 +00002041 RUBY_SRC="if_ruby.c"
2042 RUBY_OBJ="objects/if_ruby.o"
2043 RUBY_PRO="if_ruby.pro"
2044 AC_DEFINE(FEAT_RUBY)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002045 if test "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar92021622017-10-12 12:33:43 +02002046 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_ALIASES']].split[[0]]"`
Bram Moolenaar87ea64c2018-08-04 15:13:34 +02002047 if test -z "$libruby_soname"; then
2048 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_SO']]"`
2049 fi
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002050 AC_DEFINE(DYNAMIC_RUBY)
Bram Moolenaar41a41412020-01-07 21:32:19 +01002051 RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby_soname\\\" $RUBY_CFLAGS"
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002052 RUBY_LIBS=
2053 fi
Bram Moolenaar864a28b2020-12-28 21:36:56 +01002054 if test "X$CLANG_VERSION" != "X" -a "$rubyversion" -ge 30; then
2055 RUBY_CFLAGS="$RUBY_CFLAGS -fdeclspec"
2056 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002057 else
Bram Moolenaar165641d2010-02-17 16:23:09 +01002058 AC_MSG_RESULT(not found; disabling Ruby)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002059 fi
2060 else
K.Takata236ccbf2022-09-22 16:12:06 +01002061 AC_MSG_RESULT(too old; need Ruby version 1.9.1 or later)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002062 fi
2063 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01002064
2065 if test "$fail_if_missing" = "yes" -a -z "$RUBY_OBJ"; then
2066 AC_MSG_ERROR([could not configure Ruby])
2067 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002068fi
2069AC_SUBST(RUBY_SRC)
2070AC_SUBST(RUBY_OBJ)
2071AC_SUBST(RUBY_PRO)
2072AC_SUBST(RUBY_CFLAGS)
ichizok8bb3fe42021-12-28 15:51:45 +00002073AC_SUBST(RUBY_CFLAGS_EXTRA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002074AC_SUBST(RUBY_LIBS)
2075
2076AC_MSG_CHECKING(--enable-cscope argument)
2077AC_ARG_ENABLE(cscope,
2078 [ --enable-cscope Include cscope interface.], ,
2079 [enable_cscope="no"])
2080AC_MSG_RESULT($enable_cscope)
2081if test "$enable_cscope" = "yes"; then
2082 AC_DEFINE(FEAT_CSCOPE)
2083fi
2084
Bram Moolenaar071d4272004-06-13 20:20:40 +00002085AC_MSG_CHECKING(--disable-netbeans argument)
2086AC_ARG_ENABLE(netbeans,
2087 [ --disable-netbeans Disable NetBeans integration support.],
2088 , [enable_netbeans="yes"])
2089if test "$enable_netbeans" = "yes"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00002090 if test "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +01002091 AC_MSG_RESULT([cannot use NetBeans with tiny features])
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002092 enable_netbeans="no"
2093 else
2094 AC_MSG_RESULT(no)
2095 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002096else
2097 AC_MSG_RESULT(yes)
2098fi
2099
2100AC_MSG_CHECKING(--disable-channel argument)
2101AC_ARG_ENABLE(channel,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002102 [ --disable-channel Disable process communication support.],
Bram Moolenaare0874f82016-01-24 20:36:41 +01002103 , [enable_channel="yes"])
2104if test "$enable_channel" = "yes"; then
Bram Moolenaar12471262022-01-18 11:11:25 +00002105 if test "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +01002106 AC_MSG_RESULT([cannot use channels with tiny features])
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002107 enable_channel="no"
2108 else
2109 AC_MSG_RESULT(no)
2110 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002111else
2112 if test "$enable_netbeans" = "yes"; then
Bram Moolenaar16435482016-01-24 21:31:54 +01002113 AC_MSG_RESULT([yes, netbeans also disabled])
Bram Moolenaare0874f82016-01-24 20:36:41 +01002114 enable_netbeans="no"
2115 else
2116 AC_MSG_RESULT(yes)
2117 fi
2118fi
2119
Bram Moolenaar16435482016-01-24 21:31:54 +01002120if test "$enable_channel" = "yes"; then
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002121 dnl On Solaris we need the socket library, or on Haiku the network library.
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002122 if test "x$HAIKU" = "xyes"; then
2123 AC_CHECK_LIB(network, socket)
2124 else
2125 AC_CHECK_LIB(socket, socket)
2126 fi
2127
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002128 AC_CACHE_CHECK([whether compiling with IPv6 networking is possible], [vim_cv_ipv6_networking],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002129 [AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002130#include <stdio.h>
2131#include <stdlib.h>
2132#include <stdarg.h>
2133#include <fcntl.h>
2134#include <netdb.h>
2135#include <netinet/in.h>
2136#include <errno.h>
2137#include <sys/types.h>
2138#include <sys/socket.h>
2139 /* Check bitfields */
2140 struct nbbuf {
2141 unsigned int initDone:1;
2142 unsigned short signmaplen;
2143 };
2144 ], [
2145 /* Check creating a socket. */
2146 struct sockaddr_in server;
2147 struct addrinfo *res;
2148 (void)socket(AF_INET, SOCK_STREAM, 0);
2149 (void)htons(100);
2150 (void)getaddrinfo("microsoft.com", NULL, NULL, &res);
2151 if (errno == ECONNREFUSED)
2152 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
2153 (void)freeaddrinfo(res);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002154 ])],
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002155 [vim_cv_ipv6_networking="yes"],
2156 [vim_cv_ipv6_networking="no"])])
2157
2158 if test "x$vim_cv_ipv6_networking" = "xyes"; then
2159 AC_DEFINE(FEAT_IPV6)
Bram Moolenaarb6fb0512020-04-18 18:24:18 +02002160 AC_CHECK_FUNCS(inet_ntop)
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002161 else
2162 dnl On Solaris we need the nsl library.
2163 AC_CHECK_LIB(nsl, gethostbyname)
2164 AC_CACHE_CHECK([whether compiling with IPv4 networking is possible], [vim_cv_ipv4_networking],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002165 [AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00002166#include <stdio.h>
2167#include <stdlib.h>
2168#include <stdarg.h>
2169#include <fcntl.h>
2170#include <netdb.h>
2171#include <netinet/in.h>
2172#include <errno.h>
2173#include <sys/types.h>
2174#include <sys/socket.h>
2175 /* Check bitfields */
2176 struct nbbuf {
2177 unsigned int initDone:1;
Bram Moolenaar63de19e2016-12-09 20:11:26 +01002178 unsigned short signmaplen;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002179 };
2180 ], [
2181 /* Check creating a socket. */
2182 struct sockaddr_in server;
2183 (void)socket(AF_INET, SOCK_STREAM, 0);
2184 (void)htons(100);
2185 (void)gethostbyname("microsoft.com");
2186 if (errno == ECONNREFUSED)
2187 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002188 ])],
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002189 [vim_cv_ipv4_networking="yes"],
2190 [vim_cv_ipv4_networking="no"; enable_netbeans="no"; enable_channel="no"])])
2191 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002192fi
2193if test "$enable_netbeans" = "yes"; then
2194 AC_DEFINE(FEAT_NETBEANS_INTG)
2195 NETBEANS_SRC="netbeans.c"
2196 AC_SUBST(NETBEANS_SRC)
2197 NETBEANS_OBJ="objects/netbeans.o"
2198 AC_SUBST(NETBEANS_OBJ)
2199fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002200if test "$enable_channel" = "yes"; then
Bram Moolenaar509ce2a2016-03-11 22:52:15 +01002201 AC_DEFINE(FEAT_JOB_CHANNEL)
Bram Moolenaar8b5866d2020-09-05 15:48:51 +02002202 CHANNEL_SRC="job.c channel.c"
Bram Moolenaare0874f82016-01-24 20:36:41 +01002203 AC_SUBST(CHANNEL_SRC)
Bram Moolenaar8b5866d2020-09-05 15:48:51 +02002204 CHANNEL_OBJ="objects/job.o objects/channel.o"
Bram Moolenaare0874f82016-01-24 20:36:41 +01002205 AC_SUBST(CHANNEL_OBJ)
2206fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002207
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002208AC_MSG_CHECKING(--enable-terminal argument)
2209AC_ARG_ENABLE(terminal,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002210 [ --enable-terminal Enable terminal emulation support.],
Bram Moolenaaref839562017-10-28 20:28:23 +02002211 , [enable_terminal="auto"])
Bram Moolenaar595a4022017-09-03 19:15:57 +02002212if test "$enable_terminal" = "yes" || test "$enable_terminal" = "auto" -a "x$features" = "xhuge" ; then
Bram Moolenaar12471262022-01-18 11:11:25 +00002213 if test "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +01002214 AC_MSG_RESULT([cannot use terminal emulator with tiny features])
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002215 enable_terminal="no"
2216 else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002217 if test "$enable_terminal" = "auto"; then
2218 enable_terminal="yes"
2219 AC_MSG_RESULT(defaulting to yes)
2220 else
2221 AC_MSG_RESULT(yes)
2222 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002223 fi
2224else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002225 if test "$enable_terminal" = "auto"; then
2226 enable_terminal="no"
2227 AC_MSG_RESULT(defaulting to no)
2228 else
2229 AC_MSG_RESULT(no)
2230 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002231fi
Bram Moolenaar8b423282017-12-16 14:37:06 +01002232if test "$enable_terminal" = "yes" -a "$enable_channel" = "yes"; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002233 AC_DEFINE(FEAT_TERMINAL)
Bram Moolenaar93268052019-10-10 13:22:54 +02002234 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 +02002235 AC_SUBST(TERM_SRC)
Bram Moolenaar93268052019-10-10 13:22:54 +02002236 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 +02002237 AC_SUBST(TERM_OBJ)
Bram Moolenaar823edd12019-10-23 22:35:36 +02002238 TERM_TEST="test_libvterm"
2239 AC_SUBST(TERM_TEST)
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002240fi
2241
Bram Moolenaare42a6d22017-11-12 19:21:51 +01002242AC_MSG_CHECKING(--enable-autoservername argument)
2243AC_ARG_ENABLE(autoservername,
2244 [ --enable-autoservername Automatically define servername at vim startup.], ,
2245 [enable_autoservername="no"])
2246AC_MSG_RESULT($enable_autoservername)
2247if test "$enable_autoservername" = "yes"; then
2248 AC_DEFINE(FEAT_AUTOSERVERNAME)
2249fi
2250
Bram Moolenaar071d4272004-06-13 20:20:40 +00002251AC_MSG_CHECKING(--enable-multibyte argument)
2252AC_ARG_ENABLE(multibyte,
2253 [ --enable-multibyte Include multibyte editing support.], ,
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01002254 [enable_multibyte="yes"])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002255AC_MSG_RESULT($enable_multibyte)
Bram Moolenaar30276f22019-01-24 17:59:39 +01002256if test "$enable_multibyte" != "yes"; then
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01002257 AC_MSG_ERROR([The multi-byte feature can no longer be disabled. If you have
2258 a problem with this, discuss on the Vim mailing list.])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002259fi
2260
Martin Tournoij25f3a142022-10-08 19:26:41 +01002261dnl Right-to-Left language support for Vim will be included with huge features,
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002262dnl unless ENABLE_RIGHTLEFT is undefined.
2263AC_MSG_CHECKING(--disable-rightleft argument)
2264AC_ARG_ENABLE(rightleft,
2265 [ --disable-rightleft Do not include Right-to-Left language support.],
2266 , [enable_rightleft="yes"])
2267if test "$enable_rightleft" = "yes"; then
2268 AC_MSG_RESULT(no)
2269else
2270 AC_MSG_RESULT(yes)
2271 AC_DEFINE(DISABLE_RIGHTLEFT)
2272fi
2273
Martin Tournoij25f3a142022-10-08 19:26:41 +01002274dnl Arabic language support for Vim will be included with huge features,
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002275dnl unless ENABLE_ARABIC is undefined.
2276AC_MSG_CHECKING(--disable-arabic argument)
2277AC_ARG_ENABLE(arabic,
2278 [ --disable-arabic Do not include Arabic language support.],
2279 , [enable_arabic="yes"])
2280if test "$enable_arabic" = "yes"; then
2281 AC_MSG_RESULT(no)
2282else
2283 AC_MSG_RESULT(yes)
2284 AC_DEFINE(DISABLE_ARABIC)
2285fi
2286
Bram Moolenaar14184a32019-02-16 15:10:30 +01002287dnl Farsi language support has been removed, ignore --disable-farsi
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002288AC_ARG_ENABLE(farsi,
Bram Moolenaar14184a32019-02-16 15:10:30 +01002289 [ --disable-farsi Deprecated.],,)
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002290
Bram Moolenaar071d4272004-06-13 20:20:40 +00002291AC_MSG_CHECKING(--enable-xim argument)
2292AC_ARG_ENABLE(xim,
2293 [ --enable-xim Include XIM input support.],
2294 AC_MSG_RESULT($enable_xim),
2295 [enable_xim="auto"; AC_MSG_RESULT(defaulting to auto)])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002296
2297AC_MSG_CHECKING(--enable-fontset argument)
2298AC_ARG_ENABLE(fontset,
2299 [ --enable-fontset Include X fontset output support.], ,
2300 [enable_fontset="no"])
2301AC_MSG_RESULT($enable_fontset)
2302dnl defining FEAT_XFONTSET is delayed, so that it can be disabled for no GUI
2303
2304test -z "$with_x" && with_x=yes
Bram Moolenaard0573012017-10-28 21:11:06 +02002305test "${enable_gui-yes}" != no -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && with_x=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002306if test "$with_x" = no; then
2307 AC_MSG_RESULT(defaulting to: don't HAVE_X11)
2308else
2309 dnl Do this check early, so that its failure can override user requests.
2310
2311 AC_PATH_PROG(xmkmfpath, xmkmf)
2312
2313 AC_PATH_XTRA
2314
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002315 dnl On z/OS Unix the X libraries are DLLs. To use them the code must
Bram Moolenaar071d4272004-06-13 20:20:40 +00002316 dnl be compiled with a special option.
2317 dnl Also add SM, ICE and Xmu to X_EXTRA_LIBS.
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002318 if test "$zOSUnix" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002319 CFLAGS="$CFLAGS -W c,dll"
2320 LDFLAGS="$LDFLAGS -W l,dll"
2321 X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE -lXmu"
2322 fi
2323
2324 dnl On my HPUX system the X include dir is found, but the lib dir not.
Bram Moolenaar70778922020-02-05 20:44:24 +01002325 dnl This is a desperate try to fix this.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002326
2327 if test -d "$x_includes" && test ! -d "$x_libraries"; then
2328 x_libraries=`echo "$x_includes" | sed s/include/lib/`
2329 AC_MSG_RESULT(Corrected X libraries to $x_libraries)
2330 X_LIBS="$X_LIBS -L$x_libraries"
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00002331 if test "$vim_cv_uname_output" = SunOS &&
2332 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002333 X_LIBS="$X_LIBS -R $x_libraries"
2334 fi
2335 fi
2336
2337 if test -d "$x_libraries" && test ! -d "$x_includes"; then
2338 x_includes=`echo "$x_libraries" | sed s/lib/include/`
2339 AC_MSG_RESULT(Corrected X includes to $x_includes)
2340 X_CFLAGS="$X_CFLAGS -I$x_includes"
2341 fi
2342
2343 dnl Remove "-I/usr/include " from X_CFLAGS, should not be needed.
2344 X_CFLAGS="`echo $X_CFLAGS\ | sed 's%-I/usr/include %%'`"
2345 dnl Remove "-L/usr/lib " from X_LIBS, should not be needed.
2346 X_LIBS="`echo $X_LIBS\ | sed 's%-L/usr/lib %%'`"
2347 dnl Same for "-R/usr/lib ".
2348 X_LIBS="`echo $X_LIBS\ | sed -e 's%-R/usr/lib %%' -e 's%-R /usr/lib %%'`"
2349
2350
2351 dnl Check if the X11 header files are correctly installed. On some systems
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002352 dnl Xlib.h includes files that don't exist. On some systems X11/Intrinsic.h
2353 dnl is missing.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002354 AC_MSG_CHECKING(if X11 header files can be found)
2355 cflags_save=$CFLAGS
2356 CFLAGS="$CFLAGS $X_CFLAGS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002357 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <X11/Xlib.h>
2358#include <X11/Intrinsic.h>], )],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002359 AC_MSG_RESULT(yes),
2360 AC_MSG_RESULT(no); no_x=yes)
2361 CFLAGS=$cflags_save
2362
2363 if test "${no_x-no}" = yes; then
2364 with_x=no
2365 else
2366 AC_DEFINE(HAVE_X11)
2367 X_LIB="-lXt -lX11";
2368 AC_SUBST(X_LIB)
2369
2370 ac_save_LDFLAGS="$LDFLAGS"
2371 LDFLAGS="-L$x_libraries $LDFLAGS"
2372
2373 dnl Check for -lXdmcp (needed on SunOS 4.1.4)
2374 dnl For HP-UX 10.20 it must be before -lSM -lICE
2375 AC_CHECK_LIB(Xdmcp, _XdmcpAuthDoIt, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lXdmcp"],,
2376 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXdmcp])
2377
2378 dnl Some systems need -lnsl -lsocket when testing for ICE.
2379 dnl The check above doesn't do this, try here (again). Also needed to get
2380 dnl them after Xdmcp. link.sh will remove them when not needed.
2381 dnl Check for other function than above to avoid the cached value
2382 AC_CHECK_LIB(ICE, IceOpenConnection,
2383 [X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE"],, [$X_EXTRA_LIBS])
2384
2385 dnl Check for -lXpm (needed for some versions of Motif)
2386 LDFLAGS="$X_LIBS $ac_save_LDFLAGS"
2387 AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [X_PRE_LIBS="$X_PRE_LIBS -lXpm"],,
2388 [-lXt $X_PRE_LIBS -lXpm -lX11 $X_EXTRA_LIBS])
2389
2390 dnl Check that the X11 header files don't use implicit declarations
2391 AC_MSG_CHECKING(if X11 header files implicitly declare return values)
2392 cflags_save=$CFLAGS
Bram Moolenaard1864592013-05-04 04:40:15 +02002393 dnl -Werror is GCC only, others like Solaris Studio might not like it
2394 if test "$GCC" = yes; then
2395 CFLAGS="$CFLAGS $X_CFLAGS -Werror"
2396 else
2397 CFLAGS="$CFLAGS $X_CFLAGS"
2398 fi
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002399 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <X11/Xlib.h>], )],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002400 AC_MSG_RESULT(no),
2401 CFLAGS="$CFLAGS -Wno-implicit-int"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002402 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <X11/Xlib.h>], )],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002403 AC_MSG_RESULT(yes); cflags_save="$cflags_save -Wno-implicit-int",
2404 AC_MSG_RESULT(test failed)
2405 )
2406 )
2407 CFLAGS=$cflags_save
2408
2409 LDFLAGS="$ac_save_LDFLAGS"
2410
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002411 AC_MSG_CHECKING(size of wchar_t is 2 bytes)
2412 AC_CACHE_VAL(ac_cv_small_wchar_t,
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002413 [AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002414#include <X11/Xlib.h>
2415#if STDC_HEADERS
2416# include <stdlib.h>
2417# include <stddef.h>
2418#endif
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01002419 int main()
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002420 {
2421 if (sizeof(wchar_t) <= 2)
2422 exit(1);
2423 exit(0);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002424 }])],
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002425 ac_cv_small_wchar_t="no",
2426 ac_cv_small_wchar_t="yes",
2427 AC_MSG_ERROR(failed to compile test program))])
2428 AC_MSG_RESULT($ac_cv_small_wchar_t)
2429 if test "x$ac_cv_small_wchar_t" = "xyes" ; then
2430 AC_DEFINE(SMALL_WCHAR_T)
2431 fi
2432
Bram Moolenaar071d4272004-06-13 20:20:40 +00002433 fi
2434fi
2435
Bram Moolenaard2a05492018-07-27 22:35:15 +02002436dnl Check if --with-x was given but it doesn't work.
2437if test "x$with_x" = xno -a "x$with_x_arg" = xyes; then
2438 AC_MSG_ERROR([could not configure X])
2439fi
2440
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002441test "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 +00002442
2443AC_MSG_CHECKING(--enable-gui argument)
2444AC_ARG_ENABLE(gui,
Bram Moolenaarf52fac22022-03-11 16:01:26 +00002445 [ --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 +00002446
2447dnl Canonicalize the --enable-gui= argument so that it can be easily compared.
2448dnl Do not use character classes for portability with old tools.
2449enable_gui_canon=`echo "_$enable_gui" | \
2450 sed 's/[[ _+-]]//g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
2451
2452dnl Skip everything by default.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002453SKIP_GTK2=YES
Bram Moolenaar1858a842016-02-23 22:30:31 +01002454SKIP_GTK3=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002455SKIP_GNOME=YES
2456SKIP_MOTIF=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002457SKIP_PHOTON=YES
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002458SKIP_HAIKU=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002459GUITYPE=NONE
2460
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002461if test "x$HAIKU" = "xyes"; then
2462 SKIP_HAIKU=
2463 case "$enable_gui_canon" in
2464 no) AC_MSG_RESULT(no GUI support)
2465 SKIP_HAIKU=YES ;;
2466 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
2467 auto) AC_MSG_RESULT(auto - automatic GUI support) ;;
2468 haiku) AC_MSG_RESULT(Haiku GUI support) ;;
2469 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2470 SKIP_HAIKU=YES ;;
2471 esac
2472elif test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002473 SKIP_PHOTON=
2474 case "$enable_gui_canon" in
2475 no) AC_MSG_RESULT(no GUI support)
2476 SKIP_PHOTON=YES ;;
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002477 yes|""|auto) AC_MSG_RESULT(automatic GUI support)
2478 gui_auto=yes ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002479 photon) AC_MSG_RESULT(Photon GUI support) ;;
2480 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2481 SKIP_PHOTON=YES ;;
2482 esac
2483
Bram Moolenaar040f9752020-08-11 23:08:48 +02002484elif test "x$MACOS_X" = "xyes" -a "x$with_x" = "xno" ; then
2485 case "$enable_gui_canon" in
2486 no) AC_MSG_RESULT(no GUI support) ;;
2487 yes|"") AC_MSG_RESULT(yes - automatic GUI support)
2488 gui_auto=yes ;;
2489 auto) AC_MSG_RESULT(auto - disable GUI support for Mac OS) ;;
Bram Moolenaarbe7529e2020-08-13 21:05:39 +02002490 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
Bram Moolenaar040f9752020-08-11 23:08:48 +02002491 esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00002492else
2493
Bram Moolenaar071d4272004-06-13 20:20:40 +00002494 case "$enable_gui_canon" in
2495 no|none) AC_MSG_RESULT(no GUI support) ;;
2496 yes|""|auto) AC_MSG_RESULT(yes/auto - automatic GUI support)
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002497 gui_auto=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002498 SKIP_GTK2=
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002499 SKIP_GTK3=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002500 SKIP_GNOME=
Bram Moolenaarf52fac22022-03-11 16:01:26 +00002501 SKIP_MOTIF=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002502 gtk2) AC_MSG_RESULT(GTK+ 2.x GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002503 SKIP_GTK2=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002504 gnome2) AC_MSG_RESULT(GNOME 2.x GUI support)
2505 SKIP_GNOME=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002506 SKIP_GTK2=;;
Bram Moolenaar98921892016-02-23 17:14:37 +01002507 gtk3) AC_MSG_RESULT(GTK+ 3.x GUI support)
2508 SKIP_GTK3=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002509 motif) AC_MSG_RESULT(Motif GUI support)
2510 SKIP_MOTIF=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002511 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
2512 esac
2513
2514fi
2515
Bram Moolenaar071d4272004-06-13 20:20:40 +00002516if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \
2517 -a "$enable_gui_canon" != "gnome2"; then
2518 AC_MSG_CHECKING(whether or not to look for GTK+ 2)
2519 AC_ARG_ENABLE(gtk2-check,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002520 [ --enable-gtk2-check If auto-select GUI, check for GTK+ 2 [default=yes]],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002521 , enable_gtk2_check="yes")
2522 AC_MSG_RESULT($enable_gtk2_check)
2523 if test "x$enable_gtk2_check" = "xno"; then
2524 SKIP_GTK2=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002525 SKIP_GNOME=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002526 fi
2527fi
2528
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002529if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002530 AC_MSG_CHECKING(whether or not to look for GNOME)
2531 AC_ARG_ENABLE(gnome-check,
2532 [ --enable-gnome-check If GTK GUI, check for GNOME [default=no]],
2533 , enable_gnome_check="no")
2534 AC_MSG_RESULT($enable_gnome_check)
2535 if test "x$enable_gnome_check" = "xno"; then
2536 SKIP_GNOME=YES
2537 fi
2538fi
2539
Bram Moolenaar98921892016-02-23 17:14:37 +01002540if test "x$SKIP_GTK3" != "xYES" -a "$enable_gui_canon" != "gtk3"; then
2541 AC_MSG_CHECKING(whether or not to look for GTK+ 3)
2542 AC_ARG_ENABLE(gtk3-check,
2543 [ --enable-gtk3-check If auto-select GUI, check for GTK+ 3 [default=yes]],
2544 , enable_gtk3_check="yes")
2545 AC_MSG_RESULT($enable_gtk3_check)
2546 if test "x$enable_gtk3_check" = "xno"; then
2547 SKIP_GTK3=YES
2548 fi
2549fi
2550
Bram Moolenaar071d4272004-06-13 20:20:40 +00002551if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then
2552 AC_MSG_CHECKING(whether or not to look for Motif)
2553 AC_ARG_ENABLE(motif-check,
2554 [ --enable-motif-check If auto-select GUI, check for Motif [default=yes]],
2555 , enable_motif_check="yes")
2556 AC_MSG_RESULT($enable_motif_check)
2557 if test "x$enable_motif_check" = "xno"; then
2558 SKIP_MOTIF=YES
2559 fi
2560fi
2561
Bram Moolenaar071d4272004-06-13 20:20:40 +00002562dnl define an autoconf function to check for a specified version of GTK, and
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002563dnl try to compile/link a GTK program.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002564dnl
2565dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002566dnl Test for GTK, and define GTK_CFLAGS, GTK_LIBDIR and GTK_LIBS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002567dnl
2568AC_DEFUN(AM_PATH_GTK,
2569[
2570 if test "X$GTK_CONFIG" != "Xno" -o "X$PKG_CONFIG" != "Xno"; then
2571 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00002572 no_gtk=""
2573 if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2574 && $PKG_CONFIG --exists gtk+-2.0; then
2575 {
Bram Moolenaar98921892016-02-23 17:14:37 +01002576 min_gtk_version=ifelse([$1], ,2.2.0,$1)
2577 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002578 dnl We should be using PKG_CHECK_MODULES() instead of this hack.
2579 dnl But I guess the dependency on pkgconfig.m4 is not wanted or
2580 dnl something like that.
2581 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0`
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002582 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-2.0`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002583 GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0`
2584 gtk_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2585 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2586 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2587 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2588 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2589 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2590 }
Bram Moolenaar98921892016-02-23 17:14:37 +01002591 elif (test "X$SKIP_GTK3" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2592 && $PKG_CONFIG --exists gtk+-3.0; then
2593 {
2594 min_gtk_version=ifelse([$1], ,3.0.0,$1)
2595 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
2596
2597 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-3.0`
2598 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-3.0`
2599 GTK_LIBS=`$PKG_CONFIG --libs gtk+-3.0`
2600 gtk_major_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2601 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2602 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2603 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2604 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2605 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2606 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002607 else
Bram Moolenaar67876de2021-01-12 20:51:24 +01002608 dnl Put some text before the "no" to hint at installing the gtk-dev
2609 dnl packages.
2610 AC_MSG_CHECKING(for GTK -dev package)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002611 no_gtk=yes
2612 fi
2613
2614 if test "x$enable_gtktest" = "xyes" -a "x$no_gtk" = "x"; then
2615 {
2616 ac_save_CFLAGS="$CFLAGS"
2617 ac_save_LIBS="$LIBS"
2618 CFLAGS="$CFLAGS $GTK_CFLAGS"
2619 LIBS="$LIBS $GTK_LIBS"
2620
2621 dnl
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002622 dnl Now check if the installed GTK is sufficiently new.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002623 dnl
2624 rm -f conf.gtktest
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002625 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar071d4272004-06-13 20:20:40 +00002626#include <gtk/gtk.h>
2627#include <stdio.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00002628#if STDC_HEADERS
2629# include <stdlib.h>
2630# include <stddef.h>
2631#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002632
2633int
2634main ()
2635{
2636int major, minor, micro;
2637char *tmp_version;
2638
2639system ("touch conf.gtktest");
2640
2641/* HP/UX 9 (%@#!) writes to sscanf strings */
2642tmp_version = g_strdup("$min_gtk_version");
2643if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
2644 printf("%s, bad version string\n", "$min_gtk_version");
2645 exit(1);
2646 }
2647
2648if ((gtk_major_version > major) ||
2649 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
2650 ((gtk_major_version == major) && (gtk_minor_version == minor) &&
2651 (gtk_micro_version >= micro)))
2652{
2653 return 0;
2654}
2655return 1;
2656}
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01002657])],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002658 CFLAGS="$ac_save_CFLAGS"
2659 LIBS="$ac_save_LIBS"
2660 }
2661 fi
2662 if test "x$no_gtk" = x ; then
2663 if test "x$enable_gtktest" = "xyes"; then
2664 AC_MSG_RESULT(yes; found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2665 else
2666 AC_MSG_RESULT(found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2667 fi
2668 ifelse([$2], , :, [$2])
2669 else
2670 {
2671 AC_MSG_RESULT(no)
2672 GTK_CFLAGS=""
2673 GTK_LIBS=""
2674 ifelse([$3], , :, [$3])
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002675 if test "$fail_if_missing" = "yes" -a "X$gui_auto" != "Xyes"; then
2676 AC_MSG_ERROR([could not configure GTK])
2677 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002678 }
2679 fi
2680 }
2681 else
2682 GTK_CFLAGS=""
2683 GTK_LIBS=""
2684 ifelse([$3], , :, [$3])
2685 fi
2686 AC_SUBST(GTK_CFLAGS)
2687 AC_SUBST(GTK_LIBS)
2688 rm -f conf.gtktest
2689])
2690
2691dnl ---------------------------------------------------------------------------
2692dnl gnome
2693dnl ---------------------------------------------------------------------------
2694AC_DEFUN([GNOME_INIT_HOOK],
2695[
2696 AC_SUBST(GNOME_LIBS)
2697 AC_SUBST(GNOME_LIBDIR)
2698 AC_SUBST(GNOME_INCLUDEDIR)
2699
2700 AC_ARG_WITH(gnome-includes,
2701 [ --with-gnome-includes=DIR Specify location of GNOME headers],
2702 [CFLAGS="$CFLAGS -I$withval"]
2703 )
2704
2705 AC_ARG_WITH(gnome-libs,
2706 [ --with-gnome-libs=DIR Specify location of GNOME libs],
2707 [LDFLAGS="$LDFLAGS -L$withval" gnome_prefix=$withval]
2708 )
2709
2710 AC_ARG_WITH(gnome,
2711 [ --with-gnome Specify prefix for GNOME files],
2712 if test x$withval = xyes; then
2713 want_gnome=yes
2714 ifelse([$1], [], :, [$1])
2715 else
2716 if test "x$withval" = xno; then
2717 want_gnome=no
2718 else
2719 want_gnome=yes
2720 LDFLAGS="$LDFLAGS -L$withval/lib"
2721 CFLAGS="$CFLAGS -I$withval/include"
2722 gnome_prefix=$withval/lib
2723 fi
2724 fi,
2725 want_gnome=yes)
2726
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002727 if test "x$want_gnome" = xyes; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002728 {
2729 AC_MSG_CHECKING(for libgnomeui-2.0)
2730 if $PKG_CONFIG --exists libgnomeui-2.0; then
2731 AC_MSG_RESULT(yes)
2732 GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0`
2733 GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0`
2734 GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0`
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002735
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002736 dnl On FreeBSD we need -pthread but pkg-config doesn't include it.
2737 dnl This might not be the right way but it works for me...
2738 AC_MSG_CHECKING(for FreeBSD)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00002739 if test "$vim_cv_uname_output" = FreeBSD; then
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002740 AC_MSG_RESULT(yes, adding -pthread)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002741 GNOME_INCLUDEDIR="$GNOME_INCLUDEDIR -D_THREAD_SAFE"
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002742 GNOME_LIBS="$GNOME_LIBS -pthread"
2743 else
2744 AC_MSG_RESULT(no)
2745 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002746 $1
2747 else
2748 AC_MSG_RESULT(not found)
2749 if test "x$2" = xfail; then
2750 AC_MSG_ERROR(Could not find libgnomeui-2.0 via pkg-config)
2751 fi
2752 fi
2753 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002754 fi
2755])
2756
2757AC_DEFUN([GNOME_INIT],[
2758 GNOME_INIT_HOOK([],fail)
2759])
2760
Bram Moolenaar427f5b62019-06-09 13:43:51 +02002761if test "X$PKG_CONFIG" = "X"; then
2762 AC_PATH_TOOL(PKG_CONFIG, pkg-config, no)
2763fi
2764
Bram Moolenaar071d4272004-06-13 20:20:40 +00002765
2766dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002767dnl Check for GTK2. If it fails, then continue on for Motif as before...
Bram Moolenaar071d4272004-06-13 20:20:40 +00002768dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002769if test -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002770
2771 AC_MSG_CHECKING(--disable-gtktest argument)
2772 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2773 , enable_gtktest=yes)
2774 if test "x$enable_gtktest" = "xyes" ; then
2775 AC_MSG_RESULT(gtk test enabled)
2776 else
2777 AC_MSG_RESULT(gtk test disabled)
2778 fi
2779
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002780 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002781 dnl First try finding version 2.2.0 or later. The 2.0.x series has
2782 dnl problems (bold fonts, --remote doesn't work).
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002783 dnl Disable checking for GTK3 here, otherwise it's found when GTK2 is not
2784 dnl found.
2785 save_skip_gtk3=$SKIP_GTK3
2786 SKIP_GTK3=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002787 AM_PATH_GTK(2.2.0,
2788 [GUI_LIB_LOC="$GTK_LIBDIR"
2789 GTK_LIBNAME="$GTK_LIBS"
2790 GUI_INC_LOC="$GTK_CFLAGS"], )
2791 if test "x$GTK_CFLAGS" != "x"; then
Bram Moolenaar98921892016-02-23 17:14:37 +01002792 SKIP_GTK3=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002793 SKIP_MOTIF=YES
2794 GUITYPE=GTK
2795 AC_SUBST(GTK_LIBNAME)
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002796 else
2797 SKIP_GTK3=$save_skip_gtk3
Bram Moolenaar071d4272004-06-13 20:20:40 +00002798 fi
2799 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002800 if test "x$GUITYPE" = "xGTK"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002801 dnl
2802 dnl if GTK exists, then check for GNOME.
2803 dnl
2804 if test -z "$SKIP_GNOME"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002805 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002806 GNOME_INIT_HOOK([have_gnome=yes])
2807 if test "x$have_gnome" = xyes ; then
2808 AC_DEFINE(FEAT_GUI_GNOME)
2809 GUI_INC_LOC="$GUI_INC_LOC $GNOME_INCLUDEDIR"
2810 GTK_LIBNAME="$GTK_LIBNAME $GNOME_LIBDIR $GNOME_LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002811 fi
2812 }
2813 fi
2814 fi
2815fi
2816
Bram Moolenaar98921892016-02-23 17:14:37 +01002817
2818dnl ---------------------------------------------------------------------------
2819dnl Check for GTK3.
2820dnl ---------------------------------------------------------------------------
2821if test -z "$SKIP_GTK3"; then
2822
2823 AC_MSG_CHECKING(--disable-gtktest argument)
2824 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2825 , enable_gtktest=yes)
2826 if test "x$enable_gtktest" = "xyes" ; then
2827 AC_MSG_RESULT(gtk test enabled)
2828 else
2829 AC_MSG_RESULT(gtk test disabled)
2830 fi
2831
Bram Moolenaar98921892016-02-23 17:14:37 +01002832 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002833 save_skip_gtk2=$SKIP_GTK2
2834 SKIP_GTK2=YES
Bram Moolenaar98921892016-02-23 17:14:37 +01002835 AM_PATH_GTK(3.0.0,
2836 [GUI_LIB_LOC="$GTK_LIBDIR"
2837 GTK_LIBNAME="$GTK_LIBS"
2838 GUI_INC_LOC="$GTK_CFLAGS"], )
2839 if test "x$GTK_CFLAGS" != "x"; then
2840 SKIP_GTK2=YES
2841 SKIP_GNOME=YES
Bram Moolenaar98921892016-02-23 17:14:37 +01002842 SKIP_MOTIF=YES
2843 GUITYPE=GTK
2844 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar98921892016-02-23 17:14:37 +01002845 AC_DEFINE(USE_GTK3)
Bram Moolenaarf272ae12021-01-31 19:52:50 +01002846 else
2847 SKIP_GTK2=$save_skip_gtk2
Bram Moolenaar98921892016-02-23 17:14:37 +01002848 fi
2849 fi
2850fi
2851
Bram Moolenaard2e03f02016-01-02 22:46:36 +01002852dnl Check the version of Gdk-Pixbuf. If the version is 2.31 or later and
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002853dnl glib-compile-resources is found in PATH, use GResource.
2854if test "x$GUITYPE" = "xGTK"; then
2855 AC_MSG_CHECKING([version of Gdk-Pixbuf])
2856 gdk_pixbuf_version=`$PKG_CONFIG --modversion gdk-pixbuf-2.0`
2857 if test "x$gdk_pixbuf_version" != x ; then
2858 gdk_pixbuf_version_minor=`echo $gdk_pixbuf_version | \
2859 sed -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/'`
2860 if test "x$gdk_pixbuf_version_minor" != x -a \
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002861 $gdk_pixbuf_version_minor -ge 31 ; then
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002862 AC_MSG_RESULT([OK.])
2863 AC_PATH_PROG(GLIB_COMPILE_RESOURCES,[glib-compile-resources],no)
2864 AC_MSG_CHECKING([glib-compile-resources])
2865 if test "x$GLIB_COMPILE_RESOURCES" = xno ; then
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002866 GLIB_COMPILE_RESOURCES=""
2867 AC_MSG_RESULT([cannot be found in PATH.])
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002868 else
2869 AC_MSG_RESULT([usable.])
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002870 AC_DEFINE(USE_GRESOURCE)
2871 GRESOURCE_SRC="auto/gui_gtk_gresources.c"
2872 GRESOURCE_OBJ="objects/gui_gtk_gresources.o"
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002873 fi
2874 else
2875 AC_MSG_RESULT([not usable.])
2876 fi
2877 else
2878 AC_MSG_RESULT([cannot obtain from pkg_config.])
2879 fi
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002880
2881 AC_MSG_CHECKING([--disable-icon-cache-update argument])
2882 AC_ARG_ENABLE(icon_cache_update,
2883 [ --disable-icon-cache-update update disabled],
2884 [],
2885 [enable_icon_cache_update="yes"])
2886 if test "$enable_icon_cache_update" = "yes"; then
2887 AC_MSG_RESULT([not set])
2888 AC_PATH_PROG(GTK_UPDATE_ICON_CACHE,[gtk-update-icon-cache],no)
2889 if test "x$GTK_UPDATE_ICON_CACHE" = "xno" ; then
2890 AC_MSG_RESULT([not found in PATH.])
2891 fi
2892 else
2893 AC_MSG_RESULT([update disabled])
2894 fi
2895
2896 AC_MSG_CHECKING([--disable-desktop-database-update argument])
2897 AC_ARG_ENABLE(desktop_database_update,
2898 [ --disable-desktop-database-update update disabled],
2899 [],
2900 [enable_desktop_database_update="yes"])
2901 if test "$enable_desktop_database_update" = "yes"; then
2902 AC_MSG_RESULT([not set])
2903 AC_PATH_PROG(UPDATE_DESKTOP_DATABASE,[update-desktop-database],no)
2904 if test "x$UPDATE_DESKTOP_DATABASE" = "xno" ; then
2905 AC_MSG_RESULT([not found in PATH.])
2906 fi
2907 else
2908 AC_MSG_RESULT([update disabled])
2909 fi
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002910fi
2911AC_SUBST(GLIB_COMPILE_RESOURCES)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002912AC_SUBST(GRESOURCE_SRC)
2913AC_SUBST(GRESOURCE_OBJ)
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002914AC_SUBST(GTK_UPDATE_ICON_CACHE)
2915AC_SUBST(UPDATE_DESKTOP_DATABASE)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002916
Bram Moolenaar071d4272004-06-13 20:20:40 +00002917dnl Check for Motif include files location.
2918dnl The LAST one found is used, this makes the highest version to be used,
2919dnl e.g. when Motif1.2 and Motif2.0 are both present.
2920
2921if test -z "$SKIP_MOTIF"; then
2922 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"
2923 dnl Remove "-I" from before $GUI_INC_LOC if it's there
2924 GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`"
2925
2926 AC_MSG_CHECKING(for location of Motif GUI includes)
2927 gui_includes="`echo $x_includes|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC"
2928 GUI_INC_LOC=
2929 for try in $gui_includes; do
2930 if test -f "$try/Xm/Xm.h"; then
2931 GUI_INC_LOC=$try
2932 fi
2933 done
2934 if test -n "$GUI_INC_LOC"; then
2935 if test "$GUI_INC_LOC" = /usr/include; then
2936 GUI_INC_LOC=
2937 AC_MSG_RESULT(in default path)
2938 else
2939 AC_MSG_RESULT($GUI_INC_LOC)
2940 fi
2941 else
2942 AC_MSG_RESULT(<not found>)
2943 SKIP_MOTIF=YES
2944 fi
2945fi
2946
2947dnl Check for Motif library files location. In the same order as the include
2948dnl files, to avoid a mixup if several versions are present
2949
2950if test -z "$SKIP_MOTIF"; then
2951 AC_MSG_CHECKING(--with-motif-lib argument)
2952 AC_ARG_WITH(motif-lib,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002953 [ --with-motif-lib=STRING Library for Motif ],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002954 [ MOTIF_LIBNAME="${withval}" ] )
2955
2956 if test -n "$MOTIF_LIBNAME"; then
2957 AC_MSG_RESULT($MOTIF_LIBNAME)
2958 GUI_LIB_LOC=
2959 else
2960 AC_MSG_RESULT(no)
2961
2962 dnl Remove "-L" from before $GUI_LIB_LOC if it's there
2963 GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
2964
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002965 dnl Ubuntu has libXm.so in /usr/lib/i386-linux-gnu and elsewhere. The
2966 dnl linker will figure out which one to use, we only check if one exists.
Kelvin Leeb4716902022-04-04 17:20:01 +01002967 dnl Cygwin uses the .dll.a extension.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002968 AC_MSG_CHECKING(for location of Motif GUI libs)
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002969 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 +00002970 GUI_LIB_LOC=
2971 for try in $gui_libs; do
Kelvin Leeb4716902022-04-04 17:20:01 +01002972 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 +00002973 if test -f "$libtry"; then
2974 GUI_LIB_LOC=$try
2975 fi
2976 done
2977 done
2978 if test -n "$GUI_LIB_LOC"; then
2979 dnl Remove /usr/lib, it causes trouble on some systems
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002980 if test "$GUI_LIB_LOC" = /usr/lib \
2981 -o "$GUI_LIB_LOC" = /usr/lib/i386-linux-gnu \
2982 -o "$GUI_LIB_LOC" = /usr/lib/x86_64-linux-gnu; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002983 GUI_LIB_LOC=
2984 AC_MSG_RESULT(in default path)
2985 else
2986 if test -n "$GUI_LIB_LOC"; then
2987 AC_MSG_RESULT($GUI_LIB_LOC)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00002988 if test "$vim_cv_uname_output" = SunOS &&
2989 echo $vim_cv_uname_r_output | grep '^5' >/dev/null; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002990 GUI_LIB_LOC="$GUI_LIB_LOC -R $GUI_LIB_LOC"
2991 fi
2992 fi
2993 fi
2994 MOTIF_LIBNAME=-lXm
2995 else
2996 AC_MSG_RESULT(<not found>)
2997 SKIP_MOTIF=YES
2998 fi
2999 fi
3000fi
3001
3002if test -z "$SKIP_MOTIF"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003003 GUITYPE=MOTIF
3004 AC_SUBST(MOTIF_LIBNAME)
3005fi
3006
Bram Moolenaare2adcf32022-03-12 11:57:25 +00003007if test -z "$SKIP_MOTIF"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003008 dnl Prepend -I and -L to $GUI_INC_LOC and $GUI_LIB_LOC if not empty
3009 dnl Avoid adding it when it twice
3010 if test -n "$GUI_INC_LOC"; then
3011 GUI_INC_LOC=-I"`echo $GUI_INC_LOC|sed 's%-I%%'`"
3012 fi
3013 if test -n "$GUI_LIB_LOC"; then
3014 GUI_LIB_LOC=-L"`echo $GUI_LIB_LOC|sed 's%-L%%'`"
3015 fi
3016
3017 dnl Check for -lXext and then for -lXmu
3018 ldflags_save=$LDFLAGS
3019 LDFLAGS="$X_LIBS $LDFLAGS"
3020 AC_CHECK_LIB(Xext, XShapeQueryExtension, [GUI_X_LIBS="-lXext"],,
3021 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3022 dnl For Solaris we need -lw and -ldl before linking with -lXmu works.
3023 AC_CHECK_LIB(w, wslen, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lw"],,
3024 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3025 AC_CHECK_LIB(dl, dlsym, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldl"],,
3026 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3027 AC_CHECK_LIB(Xmu, XmuCreateStippledPixmap, [GUI_X_LIBS="-lXmu $GUI_X_LIBS"],,
3028 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3029 if test -z "$SKIP_MOTIF"; then
3030 AC_CHECK_LIB(Xp, XpEndJob, [GUI_X_LIBS="-lXp $GUI_X_LIBS"],,
3031 [$GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3032 fi
3033 LDFLAGS=$ldflags_save
3034
3035 dnl Execute xmkmf to figure out if -DNARROWPROTO is needed.
3036 AC_MSG_CHECKING(for extra X11 defines)
3037 NARROW_PROTO=
3038 rm -fr conftestdir
3039 if mkdir conftestdir; then
3040 cd conftestdir
3041 cat > Imakefile <<'EOF'
3042acfindx:
3043 @echo 'NARROW_PROTO="${PROTO_DEFINES}"'
3044EOF
3045 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
3046 eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
3047 fi
3048 cd ..
3049 rm -fr conftestdir
3050 fi
3051 if test -z "$NARROW_PROTO"; then
3052 AC_MSG_RESULT(no)
3053 else
3054 AC_MSG_RESULT($NARROW_PROTO)
3055 fi
3056 AC_SUBST(NARROW_PROTO)
3057fi
3058
3059dnl Look for XSMP support - but don't necessarily restrict it to X11 GUIs
3060dnl use the X11 include path
3061if test "$enable_xsmp" = "yes"; then
3062 cppflags_save=$CPPFLAGS
3063 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3064 AC_CHECK_HEADERS(X11/SM/SMlib.h)
3065 CPPFLAGS=$cppflags_save
3066fi
3067
3068
Bram Moolenaarf52fac22022-03-11 16:01:26 +00003069if test -z "$SKIP_MOTIF" -o -z "$SKIP_GTK2" -o -z "$SKIP_GTK3"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003070 dnl Check for X11/xpm.h and X11/Sunkeysym.h with the GUI include path
3071 cppflags_save=$CPPFLAGS
3072 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3073 AC_CHECK_HEADERS(X11/xpm.h X11/Sunkeysym.h)
3074
3075 dnl automatically disable XIM when XIMtext isn't in X11/Xlib.h
3076 if test ! "$enable_xim" = "no"; then
3077 AC_MSG_CHECKING(for XIMText in X11/Xlib.h)
3078 AC_EGREP_CPP(XIMText, [#include <X11/Xlib.h>],
3079 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +02003080 AC_MSG_RESULT(no; xim has been disabled); enable_xim="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00003081 fi
3082 CPPFLAGS=$cppflags_save
3083
Bram Moolenaar54612582019-11-21 17:13:31 +01003084 dnl automatically enable XIM in the GUI
3085 if test "$enable_xim" = "auto" -a "x$GUITYPE" != "xNONE" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003086 AC_MSG_RESULT(X GUI selected; xim has been enabled)
3087 enable_xim="yes"
3088 fi
3089fi
3090
Bram Moolenaarf52fac22022-03-11 16:01:26 +00003091if test -z "$SKIP_MOTIF"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003092 cppflags_save=$CPPFLAGS
3093 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00003094dnl Xmu/Editres.h may exist but can only be used after including Intrinsic.h
3095 AC_MSG_CHECKING([for X11/Xmu/Editres.h])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003096 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00003097#include <X11/Intrinsic.h>
3098#include <X11/Xmu/Editres.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003099 [int i; i = 0;])],
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00003100 AC_MSG_RESULT(yes)
3101 AC_DEFINE(HAVE_X11_XMU_EDITRES_H),
3102 AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003103 CPPFLAGS=$cppflags_save
3104fi
3105
Bram Moolenaar0b40d082022-03-08 13:32:37 +00003106dnl Only use the Xm directory when compiling Motif.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003107if test -z "$SKIP_MOTIF"; then
3108 cppflags_save=$CPPFLAGS
3109 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003110 if test "$zOSUnix" = "yes"; then
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003111 AC_CHECK_HEADERS(Xm/Xm.h)
Bram Moolenaar77c19352012-06-13 19:19:41 +02003112 else
Bram Moolenaarde1d7342022-06-05 20:03:17 +01003113 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 +01003114 fi
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003115
Bram Moolenaar77c19352012-06-13 19:19:41 +02003116 if test "x$ac_cv_header_Xm_XpmP_h" = "xyes"; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003117 dnl Solaris uses XpmAttributes_21, very annoying.
3118 AC_MSG_CHECKING([for XpmAttributes_21 in Xm/XpmP.h])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003119 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <Xm/XpmP.h>], [XpmAttributes_21 attr;])],
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003120 AC_MSG_RESULT(yes); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes_21),
3121 AC_MSG_RESULT(no); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
3122 )
3123 else
Bram Moolenaar57657d82006-04-21 22:12:41 +00003124 AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003125 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003126 CPPFLAGS=$cppflags_save
3127fi
3128
3129if test "x$GUITYPE" = "xNONE" -a "$enable_xim" = "yes"; then
3130 AC_MSG_RESULT(no GUI selected; xim has been disabled)
3131 enable_xim="no"
3132fi
3133if test "x$GUITYPE" = "xNONE" -a "$enable_fontset" = "yes"; then
3134 AC_MSG_RESULT(no GUI selected; fontset has been disabled)
3135 enable_fontset="no"
3136fi
Bram Moolenaar182c5be2010-06-25 05:37:59 +02003137if test "x$GUITYPE:$enable_fontset" = "xGTK:yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003138 AC_MSG_RESULT(GTK+ 2 GUI selected; fontset has been disabled)
3139 enable_fontset="no"
3140fi
3141
Bram Moolenaarb3f74062020-02-26 16:16:53 +01003142dnl There is no test for the Haiku GUI, if it's selected it's used
3143if test -z "$SKIP_HAIKU"; then
3144 GUITYPE=HAIKUGUI
3145fi
3146
Bram Moolenaar071d4272004-06-13 20:20:40 +00003147if test -z "$SKIP_PHOTON"; then
3148 GUITYPE=PHOTONGUI
3149fi
3150
3151AC_SUBST(GUI_INC_LOC)
3152AC_SUBST(GUI_LIB_LOC)
3153AC_SUBST(GUITYPE)
3154AC_SUBST(GUI_X_LIBS)
3155
3156if test "$enable_workshop" = "yes" -a -n "$SKIP_MOTIF"; then
3157 AC_MSG_ERROR([cannot use workshop without Motif])
3158fi
3159
3160dnl defining FEAT_XIM and FEAT_XFONTSET is delayed, so that they can be disabled
3161if test "$enable_xim" = "yes"; then
3162 AC_DEFINE(FEAT_XIM)
3163fi
3164if test "$enable_fontset" = "yes"; then
3165 AC_DEFINE(FEAT_XFONTSET)
3166fi
3167
3168
3169dnl ---------------------------------------------------------------------------
3170dnl end of GUI-checking
3171dnl ---------------------------------------------------------------------------
3172
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003173AC_MSG_CHECKING([for /proc link to executable])
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003174if test -L "/proc/self/exe"; then
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003175 dnl Linux
3176 AC_MSG_RESULT([/proc/self/exe])
3177 AC_DEFINE(PROC_EXE_LINK, "/proc/self/exe")
3178elif test -L "/proc/self/path/a.out"; then
3179 dnl Solaris
3180 AC_MSG_RESULT([/proc/self/path/a.out])
3181 AC_DEFINE(PROC_EXE_LINK, "/proc/self/path/a.out")
3182elif test -L "/proc/curproc/file"; then
3183 dnl FreeBSD
3184 AC_MSG_RESULT([/proc/curproc/file])
3185 AC_DEFINE(PROC_EXE_LINK, "/proc/curproc/file")
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003186else
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003187 AC_MSG_RESULT(no)
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003188fi
3189
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003190dnl Check for Cygwin, which needs an extra source file if not using X11
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003191AC_MSG_CHECKING(for CYGWIN or MSYS environment)
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00003192case $vim_cv_uname_output in
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003193 CYGWIN*|MSYS*) CYGWIN=yes; AC_MSG_RESULT(yes)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003194 AC_MSG_CHECKING(for CYGWIN clipboard support)
3195 if test "x$with_x" = "xno" ; then
3196 OS_EXTRA_SRC=winclip.c; OS_EXTRA_OBJ=objects/winclip.o
3197 AC_MSG_RESULT(yes)
3198 AC_DEFINE(FEAT_CYGWIN_WIN32_CLIPBOARD)
3199 else
3200 AC_MSG_RESULT(no - using X11)
3201 fi ;;
3202
3203 *) CYGWIN=no; AC_MSG_RESULT(no);;
3204esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00003205
Bram Moolenaar071d4272004-06-13 20:20:40 +00003206dnl Checks for libraries and include files.
3207
Bram Moolenaar446cb832008-06-24 21:56:24 +00003208AC_CACHE_CHECK([whether toupper is broken], [vim_cv_toupper_broken],
3209 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003210 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003211#include "confdefs.h"
3212#include <ctype.h>
3213#if STDC_HEADERS
3214# include <stdlib.h>
3215# include <stddef.h>
3216#endif
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01003217int main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003218 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003219 vim_cv_toupper_broken=yes
3220 ],[
3221 vim_cv_toupper_broken=no
3222 ],[
3223 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_toupper_broken')
3224 ])])
3225
3226if test "x$vim_cv_toupper_broken" = "xyes" ; then
3227 AC_DEFINE(BROKEN_TOUPPER)
3228fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003229
3230AC_MSG_CHECKING(whether __DATE__ and __TIME__ work)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003231AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>], [printf("(" __DATE__ " " __TIME__ ")");])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003232 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DATE_TIME),
3233 AC_MSG_RESULT(no))
3234
Bram Moolenaar0c094b92009-05-14 20:20:33 +00003235AC_MSG_CHECKING(whether __attribute__((unused)) is allowed)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003236AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>], [int x __attribute__((unused));])],
Bram Moolenaar0c094b92009-05-14 20:20:33 +00003237 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ATTRIBUTE_UNUSED),
3238 AC_MSG_RESULT(no))
3239
Bram Moolenaar071d4272004-06-13 20:20:40 +00003240dnl Checks for header files.
3241AC_CHECK_HEADER(elf.h, HAS_ELF=1)
3242dnl AC_CHECK_HEADER(dwarf.h, SVR4=1)
3243if test "$HAS_ELF" = 1; then
3244 AC_CHECK_LIB(elf, main)
3245fi
3246
3247AC_HEADER_DIRENT
3248
Bram Moolenaar071d4272004-06-13 20:20:40 +00003249dnl If sys/wait.h is not found it might still exist but not be POSIX
3250dnl compliant. In that case we define HAVE_UNION_WAIT (for NeXT)
3251if test $ac_cv_header_sys_wait_h = no; then
3252 AC_MSG_CHECKING([for sys/wait.h that defines union wait])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003253 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/wait.h>],
3254 [union wait xx, yy; xx = yy])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003255 AC_MSG_RESULT(yes)
3256 AC_DEFINE(HAVE_SYS_WAIT_H)
3257 AC_DEFINE(HAVE_UNION_WAIT),
3258 AC_MSG_RESULT(no))
3259fi
3260
Bram Moolenaar779a7752016-01-30 23:26:34 +01003261AC_CHECK_HEADERS(stdint.h stdlib.h string.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003262 sys/select.h sys/utsname.h termcap.h fcntl.h \
3263 sgtty.h sys/ioctl.h sys/time.h sys/types.h \
3264 termio.h iconv.h inttypes.h langinfo.h math.h \
3265 unistd.h stropts.h errno.h sys/resource.h \
3266 sys/systeminfo.h locale.h sys/stream.h termios.h \
3267 libc.h sys/statfs.h poll.h sys/poll.h pwd.h \
Bram Moolenaar1ecc5e42019-01-26 15:12:55 +01003268 utime.h sys/param.h sys/ptms.h libintl.h libgen.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003269 util/debug.h util/msg18n.h frame.h sys/acl.h \
3270 sys/access.h sys/sysinfo.h wchar.h wctype.h)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003271
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003272dnl sys/ptem.h depends on sys/stream.h on Solaris
3273AC_CHECK_HEADERS(sys/ptem.h, [], [],
3274[#if defined HAVE_SYS_STREAM_H
3275# include <sys/stream.h>
3276#endif])
3277
Bram Moolenaar32f31b12009-05-21 13:20:59 +00003278dnl sys/sysctl.h depends on sys/param.h on OpenBSD
3279AC_CHECK_HEADERS(sys/sysctl.h, [], [],
3280[#if defined HAVE_SYS_PARAM_H
3281# include <sys/param.h>
3282#endif])
3283
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003284
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003285dnl pthread_np.h may exist but can only be used after including pthread.h
3286AC_MSG_CHECKING([for pthread_np.h])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003287AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003288#include <pthread.h>
3289#include <pthread_np.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003290 [int i; i = 0;])],
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003291 AC_MSG_RESULT(yes)
3292 AC_DEFINE(HAVE_PTHREAD_NP_H),
3293 AC_MSG_RESULT(no))
3294
Bram Moolenaare344bea2005-09-01 20:46:49 +00003295AC_CHECK_HEADERS(strings.h)
Bram Moolenaard0573012017-10-28 21:11:06 +02003296if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00003297 dnl The strings.h file on OS/X contains a warning and nothing useful.
3298 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3299else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003300
3301dnl Check if strings.h and string.h can both be included when defined.
3302AC_MSG_CHECKING([if strings.h can be included after string.h])
3303cppflags_save=$CPPFLAGS
3304CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003305AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003306#if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO)
3307# define _NO_PROTO /* like in os_unix.h, causes conflict for AIX (Winn) */
3308 /* but don't do it on AIX 5.1 (Uribarri) */
3309#endif
3310#ifdef HAVE_XM_XM_H
3311# include <Xm/Xm.h> /* This breaks it for HP-UX 11 (Squassabia) */
3312#endif
3313#ifdef HAVE_STRING_H
3314# include <string.h>
3315#endif
3316#if defined(HAVE_STRINGS_H)
3317# include <strings.h>
3318#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003319 ], [int i; i = 0;])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003320 AC_MSG_RESULT(yes),
3321 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3322 AC_MSG_RESULT(no))
3323CPPFLAGS=$cppflags_save
Bram Moolenaar9372a112005-12-06 19:59:18 +00003324fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003325
3326dnl Checks for typedefs, structures, and compiler characteristics.
3327AC_PROG_GCC_TRADITIONAL
3328AC_C_CONST
Bram Moolenaar76243bd2009-03-02 01:47:02 +00003329AC_C_VOLATILE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003330AC_TYPE_MODE_T
3331AC_TYPE_OFF_T
3332AC_TYPE_PID_T
3333AC_TYPE_SIZE_T
3334AC_TYPE_UID_T
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003335AC_TYPE_UINT32_T
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003336
Bram Moolenaar071d4272004-06-13 20:20:40 +00003337AC_HEADER_TIME
3338AC_CHECK_TYPE(ino_t, long)
3339AC_CHECK_TYPE(dev_t, unsigned)
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003340AC_C_BIGENDIAN(,,,)
Bram Moolenaar136f29a2016-02-27 20:14:15 +01003341AC_C_INLINE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003342
3343AC_MSG_CHECKING(for rlim_t)
3344if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
3345 AC_MSG_RESULT([(cached) $ac_cv_type_rlim_t])
3346else
3347 AC_EGREP_CPP(dnl
3348changequote(<<,>>)dnl
3349<<(^|[^a-zA-Z_0-9])rlim_t[^a-zA-Z_0-9]>>dnl
3350changequote([,]),
3351 [
3352#include <sys/types.h>
3353#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003354# include <stdlib.h>
3355# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003356#endif
3357#ifdef HAVE_SYS_RESOURCE_H
Bram Moolenaar446cb832008-06-24 21:56:24 +00003358# include <sys/resource.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003359#endif
3360 ], ac_cv_type_rlim_t=yes, ac_cv_type_rlim_t=no)
3361 AC_MSG_RESULT($ac_cv_type_rlim_t)
3362fi
3363if test $ac_cv_type_rlim_t = no; then
3364 cat >> confdefs.h <<\EOF
3365#define rlim_t unsigned long
3366EOF
3367fi
3368
3369AC_MSG_CHECKING(for stack_t)
3370if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then
3371 AC_MSG_RESULT([(cached) $ac_cv_type_stack_t])
3372else
3373 AC_EGREP_CPP(stack_t,
3374 [
3375#include <sys/types.h>
3376#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003377# include <stdlib.h>
3378# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003379#endif
3380#include <signal.h>
3381 ], ac_cv_type_stack_t=yes, ac_cv_type_stack_t=no)
3382 AC_MSG_RESULT($ac_cv_type_stack_t)
3383fi
3384if test $ac_cv_type_stack_t = no; then
3385 cat >> confdefs.h <<\EOF
3386#define stack_t struct sigaltstack
3387EOF
3388fi
3389
3390dnl BSDI uses ss_base while others use ss_sp for the stack pointer.
3391AC_MSG_CHECKING(whether stack_t has an ss_base field)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003392AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003393#include <sys/types.h>
3394#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003395# include <stdlib.h>
3396# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003397#endif
3398#include <signal.h>
3399#include "confdefs.h"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003400 ], [stack_t sigstk; sigstk.ss_base = 0; ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003401 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SS_BASE),
3402 AC_MSG_RESULT(no))
3403
3404olibs="$LIBS"
3405AC_MSG_CHECKING(--with-tlib argument)
3406AC_ARG_WITH(tlib, [ --with-tlib=library terminal library to be used ],)
3407if test -n "$with_tlib"; then
3408 AC_MSG_RESULT($with_tlib)
3409 LIBS="$LIBS -l$with_tlib"
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003410 AC_MSG_CHECKING(for linking with $with_tlib library)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003411 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], AC_MSG_RESULT(OK), AC_MSG_ERROR(FAILED))
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003412 dnl Need to check for tgetent() below.
3413 olibs="$LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003414else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003415 AC_MSG_RESULT([empty: automatic terminal library selection])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003416 dnl On HP-UX 10.10 termcap or termlib should be used instead of
3417 dnl curses, because curses is much slower.
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003418 dnl Newer versions of ncurses are preferred over anything, except
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02003419 dnl when tinfo has been split off, it contains all we need.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003420 dnl Older versions of ncurses have bugs, get a new one!
3421 dnl Digital Unix (OSF1) should use curses (Ronald Schild).
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00003422 dnl On SCO Openserver should prefer termlib (Roger Cornelius).
Bram Moolenaar6840a0f2021-12-13 20:37:59 +00003423 case "$vim_cv_uname_output" in
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003424 OSF1|SCO_SV) tlibs="tinfo ncurses curses termlib termcap";;
3425 *) tlibs="tinfo ncurses termlib termcap curses";;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003426 esac
3427 for libname in $tlibs; do
3428 AC_CHECK_LIB(${libname}, tgetent,,)
3429 if test "x$olibs" != "x$LIBS"; then
3430 dnl It's possible that a library is found but it doesn't work
3431 dnl e.g., shared library that cannot be found
3432 dnl compile and run a test program to be sure
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003433 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003434#ifdef HAVE_TERMCAP_H
3435# include <termcap.h>
3436#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003437#if STDC_HEADERS
3438# include <stdlib.h>
3439# include <stddef.h>
3440#endif
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01003441int main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003442 res="OK", res="FAIL", res="FAIL")
3443 if test "$res" = "OK"; then
3444 break
3445 fi
3446 AC_MSG_RESULT($libname library is not usable)
3447 LIBS="$olibs"
3448 fi
3449 done
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003450 if test "x$olibs" = "x$LIBS"; then
3451 AC_MSG_RESULT(no terminal library found)
3452 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003453fi
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003454
3455if test "x$olibs" = "x$LIBS"; then
3456 AC_MSG_CHECKING([for tgetent()])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003457 AC_LINK_IFELSE([AC_LANG_PROGRAM([int tgetent(char *, const char *);],
3458 [[char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");]])],
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003459 AC_MSG_RESULT(yes),
3460 AC_MSG_ERROR([NOT FOUND!
3461 You need to install a terminal library; for example ncurses.
Bram Moolenaar16678eb2021-04-21 11:57:59 +02003462 On Linux that would be the libncurses-dev package.
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003463 Or specify the name of the library with --with-tlib.]))
3464fi
3465
Bram Moolenaar446cb832008-06-24 21:56:24 +00003466AC_CACHE_CHECK([whether we talk terminfo], [vim_cv_terminfo],
3467 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003468 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003469#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003470#ifdef HAVE_TERMCAP_H
3471# include <termcap.h>
3472#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003473#ifdef HAVE_STRING_H
3474# include <string.h>
3475#endif
3476#if STDC_HEADERS
3477# include <stdlib.h>
3478# include <stddef.h>
3479#endif
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01003480int main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003481{char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003482 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003483 vim_cv_terminfo=no
3484 ],[
3485 vim_cv_terminfo=yes
3486 ],[
3487 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_terminfo')
3488 ])
3489 ])
3490
3491if test "x$vim_cv_terminfo" = "xyes" ; then
3492 AC_DEFINE(TERMINFO)
3493fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003494
Bram Moolenaara88254f2017-11-02 23:04:14 +01003495AC_CACHE_CHECK([what tgetent() returns for an unknown terminal], [vim_cv_tgetent],
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003496 [
3497 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003498#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003499#ifdef HAVE_TERMCAP_H
3500# include <termcap.h>
3501#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003502#if STDC_HEADERS
3503# include <stdlib.h>
3504# include <stddef.h>
3505#endif
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01003506int main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003507{char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003508 ]])],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003509 vim_cv_tgetent=zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003510 ],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003511 vim_cv_tgetent=non-zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003512 ],[
3513 AC_MSG_ERROR(failed to compile test program.)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003514 ])
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003515 ])
3516
Bram Moolenaara88254f2017-11-02 23:04:14 +01003517if test "x$vim_cv_tgetent" = "xzero" ; then
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003518 AC_DEFINE(TGETENT_ZERO_ERR, 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003519fi
3520
3521AC_MSG_CHECKING(whether termcap.h contains ospeed)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003522AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003523#ifdef HAVE_TERMCAP_H
3524# include <termcap.h>
3525#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003526 ], [ospeed = 20000])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003527 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED),
3528 [AC_MSG_RESULT(no)
3529 AC_MSG_CHECKING(whether ospeed can be extern)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003530 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003531#ifdef HAVE_TERMCAP_H
3532# include <termcap.h>
3533#endif
3534extern short ospeed;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003535 ], [ospeed = 20000])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003536 AC_MSG_RESULT(yes); AC_DEFINE(OSPEED_EXTERN),
3537 AC_MSG_RESULT(no))]
3538 )
3539
3540AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003541AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003542#ifdef HAVE_TERMCAP_H
3543# include <termcap.h>
3544#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003545 ], [if (UP == 0 && BC == 0) PC = 1])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003546 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UP_BC_PC),
3547 [AC_MSG_RESULT(no)
3548 AC_MSG_CHECKING([whether UP, BC and PC can be extern])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003549 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003550#ifdef HAVE_TERMCAP_H
3551# include <termcap.h>
3552#endif
3553extern char *UP, *BC, PC;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003554 ], [if (UP == 0 && BC == 0) PC = 1])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003555 AC_MSG_RESULT(yes); AC_DEFINE(UP_BC_PC_EXTERN),
3556 AC_MSG_RESULT(no))]
3557 )
3558
3559AC_MSG_CHECKING(whether tputs() uses outfuntype)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003560AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003561#ifdef HAVE_TERMCAP_H
3562# include <termcap.h>
3563#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003564 ], [extern int xx(); tputs("test", 1, (outfuntype)xx)])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003565 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OUTFUNTYPE),
3566 AC_MSG_RESULT(no))
3567
Bram Moolenaarb3a29552021-11-19 11:28:04 +00003568AC_MSG_CHECKING([whether del_curterm() can be used])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003569AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaarb3a29552021-11-19 11:28:04 +00003570#ifdef HAVE_TERMCAP_H
3571# include <termcap.h>
3572#endif
3573#include <term.h>
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003574 ], [if (cur_term) del_curterm(cur_term);])],
Bram Moolenaarb3a29552021-11-19 11:28:04 +00003575 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DEL_CURTERM),
3576 AC_MSG_RESULT(no))
3577
Bram Moolenaar071d4272004-06-13 20:20:40 +00003578dnl On some SCO machines sys/select redefines struct timeval
3579AC_MSG_CHECKING([whether sys/select.h and sys/time.h may both be included])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003580AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003581#include <sys/types.h>
3582#include <sys/time.h>
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003583#include <sys/select.h>], )],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003584 AC_MSG_RESULT(yes)
3585 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME),
3586 AC_MSG_RESULT(no))
3587
3588dnl AC_DECL_SYS_SIGLIST
3589
3590dnl Checks for pty.c (copied from screen) ==========================
3591AC_MSG_CHECKING(for /dev/ptc)
3592if test -r /dev/ptc; then
3593 AC_DEFINE(HAVE_DEV_PTC)
3594 AC_MSG_RESULT(yes)
3595else
3596 AC_MSG_RESULT(no)
3597fi
3598
3599AC_MSG_CHECKING(for SVR4 ptys)
3600if test -c /dev/ptmx ; then
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003601 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaarce7be3a2020-11-26 20:11:11 +01003602// These should be in stdlib.h, but it depends on _XOPEN_SOURCE.
3603char *ptsname(int);
3604int unlockpt(int);
3605int grantpt(int);
3606 ], [
3607 ptsname(0);
3608 grantpt(0);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003609 unlockpt(0);])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003610 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SVR4_PTYS),
3611 AC_MSG_RESULT(no))
3612else
3613 AC_MSG_RESULT(no)
3614fi
3615
3616AC_MSG_CHECKING(for ptyranges)
3617if test -d /dev/ptym ; then
3618 pdir='/dev/ptym'
3619else
3620 pdir='/dev'
3621fi
3622dnl SCO uses ptyp%d
3623AC_EGREP_CPP(yes,
3624[#ifdef M_UNIX
3625 yes;
3626#endif
3627 ], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
3628dnl if test -c /dev/ptyp19; then
3629dnl ptys=`echo /dev/ptyp??`
3630dnl else
3631dnl ptys=`echo $pdir/pty??`
3632dnl fi
3633if test "$ptys" != "$pdir/pty??" ; then
3634 p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
3635 p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'`
3636 AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
3637 AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
3638 AC_MSG_RESULT([$p0 / $p1])
3639else
3640 AC_MSG_RESULT([don't know])
3641fi
3642
Bram Moolenaar071d4272004-06-13 20:20:40 +00003643dnl Checks for library functions. ===================================
3644
Bram Moolenaar071d4272004-06-13 20:20:40 +00003645dnl check if struct sigcontext is defined (used for SGI only)
3646AC_MSG_CHECKING(for struct sigcontext)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003647AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003648#include <signal.h>
Sam Jamesf8ea1062022-11-05 15:13:50 +00003649int test_sig()
Bram Moolenaar071d4272004-06-13 20:20:40 +00003650{
3651 struct sigcontext *scont;
3652 scont = (struct sigcontext *)0;
3653 return 1;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003654} ], )],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003655 AC_MSG_RESULT(yes)
3656 AC_DEFINE(HAVE_SIGCONTEXT),
3657 AC_MSG_RESULT(no))
3658
3659dnl tricky stuff: try to find out if getcwd() is implemented with
3660dnl system("sh -c pwd")
Bram Moolenaar446cb832008-06-24 21:56:24 +00003661AC_CACHE_CHECK([getcwd implementation is broken], [vim_cv_getcwd_broken],
3662 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003663 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003664#include "confdefs.h"
3665#ifdef HAVE_UNISTD_H
3666#include <unistd.h>
3667#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003668char *dagger[] = { "IFS=pwd", 0 };
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01003669int main()
Bram Moolenaar071d4272004-06-13 20:20:40 +00003670{
3671 char buffer[500];
3672 extern char **environ;
3673 environ = dagger;
3674 return getcwd(buffer, 500) ? 0 : 1;
Bram Moolenaar446cb832008-06-24 21:56:24 +00003675}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003676 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003677 vim_cv_getcwd_broken=no
3678 ],[
3679 vim_cv_getcwd_broken=yes
3680 ],[
3681 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_getcwd_broken')
3682 ])
3683 ])
3684
3685if test "x$vim_cv_getcwd_broken" = "xyes" ; then
3686 AC_DEFINE(BAD_GETCWD)
Bram Moolenaar63d25552019-05-10 21:28:38 +02003687 AC_CHECK_FUNCS(getwd)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003688fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003689
Bram Moolenaar25153e12010-02-24 14:47:08 +01003690dnl Check for functions in one big call, to reduce the size of configure.
3691dnl Can only be used for functions that do not require any include.
Bram Moolenaarcd142e32017-11-16 17:03:45 +01003692AC_CHECK_FUNCS(fchdir fchown fchmod fsync getcwd getpseudotty \
Bram Moolenaar63d25552019-05-10 21:28:38 +02003693 getpwent getpwnam getpwuid getrlimit gettimeofday localtime_r lstat \
Bram Moolenaareaf03392009-11-17 11:08:52 +00003694 memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
Bram Moolenaar2fcf6682017-03-11 20:03:42 +01003695 getpgid setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
Bram Moolenaar84cf6bd2020-06-16 20:03:43 +02003696 sigprocmask sigvec strcasecmp strcoll strerror strftime stricmp strncasecmp \
Bram Moolenaar10455d42019-11-21 15:36:18 +01003697 strnicmp strpbrk strptime strtol tgetent towlower towupper iswupper \
3698 tzset usleep utime utimes mblen ftruncate unsetenv posix_openpt)
Bram Moolenaar643b6142018-09-12 20:29:09 +02003699AC_FUNC_SELECT_ARGTYPES
Bram Moolenaar25153e12010-02-24 14:47:08 +01003700AC_FUNC_FSEEKO
Bram Moolenaar071d4272004-06-13 20:20:40 +00003701
Bram Moolenaar317fd3a2010-05-07 16:05:55 +02003702dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when
3703dnl appropriate, so that off_t is 64 bits when needed.
3704AC_SYS_LARGEFILE
3705
Bram Moolenaar21606672019-06-14 20:40:58 +02003706AC_MSG_CHECKING(--enable-canberra argument)
3707AC_ARG_ENABLE(canberra,
3708 [ --disable-canberra Do not use libcanberra.],
3709 , [enable_canberra="maybe"])
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003710
Bram Moolenaar21606672019-06-14 20:40:58 +02003711if test "$enable_canberra" = "maybe"; then
Martin Tournoij25f3a142022-10-08 19:26:41 +01003712 if test "$features" = "huge"; then
Bram Moolenaar21606672019-06-14 20:40:58 +02003713 AC_MSG_RESULT(Defaulting to yes)
3714 enable_canberra="yes"
3715 else
3716 AC_MSG_RESULT(Defaulting to no)
3717 enable_canberra="no"
3718 fi
3719else
Bram Moolenaar12471262022-01-18 11:11:25 +00003720 if test "$enable_canberra" = "yes" -a "$has_eval" = "no"; then
Martin Tournoij7904fa42022-10-04 16:28:45 +01003721 AC_MSG_RESULT([cannot use sound with tiny features])
Bram Moolenaar12471262022-01-18 11:11:25 +00003722 enable_canberra="no"
3723 else
3724 AC_MSG_RESULT($enable_canberra)
3725 fi
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003726fi
Bram Moolenaar21606672019-06-14 20:40:58 +02003727if test "$enable_canberra" = "yes"; then
3728 if test "x$PKG_CONFIG" != "xno"; then
3729 canberra_lib=`$PKG_CONFIG --libs libcanberra 2>/dev/null`
3730 canberra_cflags=`$PKG_CONFIG --cflags libcanberra 2>/dev/null`
3731 fi
3732 if test "x$canberra_lib" = "x"; then
3733 canberra_lib=-lcanberra
3734 canberra_cflags=-D_REENTRANT
3735 fi
3736 AC_MSG_CHECKING(for libcanberra)
3737 ac_save_CFLAGS="$CFLAGS"
3738 ac_save_LIBS="$LIBS"
Bram Moolenaar12471262022-01-18 11:11:25 +00003739 if `echo "$CFLAGS" | grep -v "$canberra_cflags" 2>/dev/null`; then
Christian Brabandt6b9efdd2021-09-09 17:14:50 +02003740 CFLAGS="$CFLAGS $canberra_cflags"
3741 fi
Bram Moolenaar21606672019-06-14 20:40:58 +02003742 LIBS="$LIBS $canberra_lib"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003743 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar21606672019-06-14 20:40:58 +02003744 # include <canberra.h>
3745 ], [
3746 ca_context *hello;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003747 ca_context_create(&hello);])],
Bram Moolenaar21606672019-06-14 20:40:58 +02003748 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_CANBERRA),
Bram Moolenaar91b992c2019-11-17 19:07:42 +01003749 AC_MSG_RESULT(no; try installing libcanberra-dev); CFLAGS="$ac_save_CFLAGS"; LIBS="$ac_save_LIBS")
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003750fi
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003751
Christian Brabandtf573c6e2021-06-20 14:02:16 +02003752AC_MSG_CHECKING(--enable-libsodium argument)
3753AC_ARG_ENABLE(libsodium,
3754 [ --disable-libsodium Do not use libsodium.],
3755 , [enable_libsodium="maybe"])
3756
3757if test "$enable_libsodium" = "maybe"; then
Martin Tournoij25f3a142022-10-08 19:26:41 +01003758 if test "$features" = "huge"; then
Christian Brabandtf573c6e2021-06-20 14:02:16 +02003759 AC_MSG_RESULT(Defaulting to yes)
3760 enable_libsodium="yes"
3761 else
3762 AC_MSG_RESULT(Defaulting to no)
3763 enable_libsodium="no"
3764 fi
3765else
3766 AC_MSG_RESULT($enable_libsodium)
3767fi
3768if test "$enable_libsodium" = "yes"; then
3769 if test "x$PKG_CONFIG" != "xno"; then
3770 libsodium_lib=`$PKG_CONFIG --libs libsodium 2>/dev/null`
3771 libsodium_cflags=`$PKG_CONFIG --cflags libsodium 2>/dev/null`
3772 fi
3773 if test "x$libsodium_lib" = "x"; then
3774 libsodium_lib=-lsodium
3775 libsodium_cflags=
3776 fi
ichizok8ce3ca82021-06-23 15:41:52 +02003777 AC_MSG_CHECKING(for libsodium)
Christian Brabandtf573c6e2021-06-20 14:02:16 +02003778 ac_save_CFLAGS="$CFLAGS"
3779 ac_save_LIBS="$LIBS"
3780 CFLAGS="$CFLAGS $libsodium_cflags"
3781 LIBS="$LIBS $libsodium_lib"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003782 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Christian Brabandtf573c6e2021-06-20 14:02:16 +02003783 # include <sodium.h>
3784 ], [
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003785 printf("%d", sodium_init()); ])],
Christian Brabandtf573c6e2021-06-20 14:02:16 +02003786 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SODIUM),
3787 AC_MSG_RESULT(no; try installing libsodium-dev); CFLAGS="$ac_save_CFLAGS"; LIBS="$ac_save_LIBS")
3788fi
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003789
Bram Moolenaar071d4272004-06-13 20:20:40 +00003790dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible
3791AC_MSG_CHECKING(for st_blksize)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003792AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00003793[#include <sys/types.h>
3794#include <sys/stat.h>],
3795[ struct stat st;
3796 int n;
3797
3798 stat("/", &st);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003799 n = (int)st.st_blksize;])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003800 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ST_BLKSIZE),
3801 AC_MSG_RESULT(no))
3802
Paul Ollis65745772022-06-05 16:55:54 +01003803dnl Check for timer_create. It probably requires the 'rt' library.
Bram Moolenaarf2ce76a2022-07-02 11:40:40 +01003804dnl Run the program to find out if timer_create(CLOCK_MONOTONIC) actually
3805dnl works, on Solaris timer_create() exists but fails at runtime.
Bram Moolenaarefffa532022-07-28 22:39:54 +01003806AC_CACHE_CHECK([for timer_create without -lrt], [vim_cv_timer_create], [
Bram Moolenaarf2ce76a2022-07-02 11:40:40 +01003807AC_RUN_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar5748b7f2022-07-28 12:09:04 +01003808#if STDC_HEADERS
3809# include <stdlib.h>
3810# include <stddef.h>
3811#endif
3812#include <signal.h>
3813#include <time.h>
Bram Moolenaare5303952022-06-19 17:05:47 +01003814static void set_flag(union sigval sv) {}
Paul Ollis65745772022-06-05 16:55:54 +01003815], [
3816 struct timespec ts;
3817 struct sigevent action = {0};
3818 timer_t timer_id;
3819
3820 action.sigev_notify = SIGEV_THREAD;
3821 action.sigev_notify_function = set_flag;
Bram Moolenaarf2ce76a2022-07-02 11:40:40 +01003822 if (timer_create(CLOCK_MONOTONIC, &action, &timer_id) < 0)
3823 exit(1); // cannot create a monotonic timer
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003824 ])],
Bram Moolenaarefffa532022-07-28 22:39:54 +01003825 vim_cv_timer_create=yes,
3826 vim_cv_timer_create=no,
Bram Moolenaar5f6cae82022-07-30 11:00:50 +01003827 AC_MSG_WARN([failed to build test program; if cross-compiling please set 'vim_cv_timer_create'])
Bram Moolenaarefffa532022-07-28 22:39:54 +01003828 )])
Paul Ollis65745772022-06-05 16:55:54 +01003829
Bram Moolenaarefffa532022-07-28 22:39:54 +01003830dnl If the previous failed, check for timer_create() and linking with -lrt.
3831if test "x$vim_cv_timer_create" = "xno" ; then
3832 save_LIBS="$LIBS"
3833 LIBS="$LIBS -lrt"
3834 AC_CACHE_CHECK([for timer_create with -lrt], [vim_cv_timer_create_with_lrt], [
3835 AC_RUN_IFELSE([AC_LANG_PROGRAM([
3836 #if STDC_HEADERS
3837 # include <stdlib.h>
3838 # include <stddef.h>
3839 #endif
3840 #include <signal.h>
3841 #include <time.h>
3842 static void set_flag(union sigval sv) {}
3843 ], [
3844 struct timespec ts;
3845 struct sigevent action = {0};
3846 timer_t timer_id;
3847
3848 action.sigev_notify = SIGEV_THREAD;
3849 action.sigev_notify_function = set_flag;
3850 if (timer_create(CLOCK_MONOTONIC, &action, &timer_id) < 0)
3851 exit(1); // cannot create a monotonic timer
3852 ])],
3853 vim_cv_timer_create_with_lrt=yes,
3854 vim_cv_timer_create_with_lrt=no,
Bram Moolenaar5f6cae82022-07-30 11:00:50 +01003855 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 +01003856 )])
3857 LIBS="$save_LIBS"
3858else
3859 vim_cv_timer_create_with_lrt=no
3860fi
Richard Purdie509695c2022-07-24 20:48:00 +01003861
3862if test "x$vim_cv_timer_create" = "xyes" ; then
3863 AC_DEFINE(HAVE_TIMER_CREATE)
3864fi
Bram Moolenaarefffa532022-07-28 22:39:54 +01003865if test "x$vim_cv_timer_create_with_lrt" = "xyes" ; then
3866 AC_DEFINE(HAVE_TIMER_CREATE)
3867 LIBS="$LIBS -lrt"
3868fi
Paul Ollis65745772022-06-05 16:55:54 +01003869
Bram Moolenaar446cb832008-06-24 21:56:24 +00003870AC_CACHE_CHECK([whether stat() ignores a trailing slash], [vim_cv_stat_ignores_slash],
3871 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003872 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003873#include "confdefs.h"
3874#if STDC_HEADERS
3875# include <stdlib.h>
3876# include <stddef.h>
3877#endif
3878#include <sys/types.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003879#include <sys/stat.h>
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01003880int main() {struct stat st; exit(stat("configure/", &st) != 0); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003881 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003882 vim_cv_stat_ignores_slash=yes
3883 ],[
3884 vim_cv_stat_ignores_slash=no
3885 ],[
3886 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_stat_ignores_slash')
3887 ])
3888 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003889
Bram Moolenaar446cb832008-06-24 21:56:24 +00003890if test "x$vim_cv_stat_ignores_slash" = "xyes" ; then
3891 AC_DEFINE(STAT_IGNORES_SLASH)
3892fi
Leah Neukirchen0a7984a2021-10-14 21:27:55 +01003893
3894dnl nanoseconds field of struct stat
3895AC_CACHE_CHECK([for nanoseconds field of struct stat],
3896 ac_cv_struct_st_mtim_nsec,
3897 [ac_save_CPPFLAGS="$CPPFLAGS"
3898 ac_cv_struct_st_mtim_nsec=no
3899 # st_mtim.tv_nsec -- the usual case
3900 # st_mtim._tv_nsec -- Solaris 2.6, if
3901 # (defined _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED == 1
3902 # && !defined __EXTENSIONS__)
3903 # st_mtim.st__tim.tv_nsec -- UnixWare 2.1.2
3904 # st_mtime_n -- AIX 5.2 and above
3905 # st_mtimespec.tv_nsec -- Darwin (Mac OSX)
3906 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
3907 CPPFLAGS="$ac_save_CPPFLAGS -DST_MTIM_NSEC=$ac_val"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003908 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
3909#include <sys/stat.h>], [struct stat s; s.ST_MTIM_NSEC;])],
Leah Neukirchen0a7984a2021-10-14 21:27:55 +01003910 [ac_cv_struct_st_mtim_nsec=$ac_val; break])
3911 done
3912 CPPFLAGS="$ac_save_CPPFLAGS"
3913])
3914if test $ac_cv_struct_st_mtim_nsec != no; then
3915 AC_DEFINE_UNQUOTED([ST_MTIM_NSEC], [$ac_cv_struct_st_mtim_nsec],
3916 [Define if struct stat contains a nanoseconds field])
3917fi
Bram Moolenaare5303952022-06-19 17:05:47 +01003918
Bram Moolenaar071d4272004-06-13 20:20:40 +00003919dnl Link with iconv for charset translation, if not found without library.
3920dnl check for iconv() requires including iconv.h
3921dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
3922dnl has been installed.
3923AC_MSG_CHECKING(for iconv_open())
3924save_LIBS="$LIBS"
3925LIBS="$LIBS -liconv"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003926AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003927#ifdef HAVE_ICONV_H
3928# include <iconv.h>
3929#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003930 ], [iconv_open("fr", "to");])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003931 AC_MSG_RESULT(yes; with -liconv); AC_DEFINE(HAVE_ICONV),
3932 LIBS="$save_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003933 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003934#ifdef HAVE_ICONV_H
3935# include <iconv.h>
3936#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003937 ], [iconv_open("fr", "to");])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003938 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ICONV),
3939 AC_MSG_RESULT(no)))
3940
3941
3942AC_MSG_CHECKING(for nl_langinfo(CODESET))
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003943AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003944#ifdef HAVE_LANGINFO_H
3945# include <langinfo.h>
3946#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003947], [char *cs = nl_langinfo(CODESET);])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003948 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET),
3949 AC_MSG_RESULT(no))
3950
Bram Moolenaar73e28dc2022-09-17 21:08:33 +01003951dnl Floating point support may require the "m" library
Bram Moolenaar446cb832008-06-24 21:56:24 +00003952AC_CHECK_LIB(m, strtod)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003953
Bram Moolenaara6b89762016-02-29 21:38:26 +01003954dnl isinf() and isnan() need to include header files and may need -lm.
3955AC_MSG_CHECKING([for isinf()])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003956AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaara6b89762016-02-29 21:38:26 +01003957#ifdef HAVE_MATH_H
3958# include <math.h>
3959#endif
3960#if STDC_HEADERS
3961# include <stdlib.h>
3962# include <stddef.h>
3963#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003964], [int r = isinf(1.11); ])],
Bram Moolenaara6b89762016-02-29 21:38:26 +01003965 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISINF),
3966 AC_MSG_RESULT(no))
3967
3968AC_MSG_CHECKING([for isnan()])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003969AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaara6b89762016-02-29 21:38:26 +01003970#ifdef HAVE_MATH_H
3971# include <math.h>
3972#endif
3973#if STDC_HEADERS
3974# include <stdlib.h>
3975# include <stddef.h>
3976#endif
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003977], [int r = isnan(1.11); ])],
Bram Moolenaara6b89762016-02-29 21:38:26 +01003978 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISNAN),
3979 AC_MSG_RESULT(no))
3980
Bram Moolenaar071d4272004-06-13 20:20:40 +00003981dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI
3982dnl when -lacl works, also try to use -lattr (required for Debian).
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003983dnl On Solaris, use the acl_get/set functions in libsec, if present.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003984AC_MSG_CHECKING(--disable-acl argument)
3985AC_ARG_ENABLE(acl,
Bram Moolenaard6d30422018-01-28 22:48:55 +01003986 [ --disable-acl No check for ACL support.],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003987 , [enable_acl="yes"])
3988if test "$enable_acl" = "yes"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01003989 AC_MSG_RESULT(no)
3990 AC_CHECK_LIB(posix1e, acl_get_file, [LIBS="$LIBS -lposix1e"],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003991 AC_CHECK_LIB(acl, acl_get_file, [LIBS="$LIBS -lacl"
3992 AC_CHECK_LIB(attr, fgetxattr, LIBS="$LIBS -lattr",,)],,),)
3993
Bram Moolenaard6d30422018-01-28 22:48:55 +01003994 AC_MSG_CHECKING(for POSIX ACL support)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01003995 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003996#include <sys/types.h>
3997#ifdef HAVE_SYS_ACL_H
3998# include <sys/acl.h>
3999#endif
4000acl_t acl;], [acl = acl_get_file("foo", ACL_TYPE_ACCESS);
4001 acl_set_file("foo", ACL_TYPE_ACCESS, acl);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004002 acl_free(acl);])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004003 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_ACL),
4004 AC_MSG_RESULT(no))
4005
Bram Moolenaard6d30422018-01-28 22:48:55 +01004006 AC_CHECK_LIB(sec, acl_get, [LIBS="$LIBS -lsec"; AC_DEFINE(HAVE_SOLARIS_ZFS_ACL)],
4007 AC_MSG_CHECKING(for Solaris ACL support)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004008 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar071d4272004-06-13 20:20:40 +00004009#ifdef HAVE_SYS_ACL_H
4010# include <sys/acl.h>
4011#endif], [acl("foo", GETACLCNT, 0, NULL);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004012 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004013 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOLARIS_ACL),
Bram Moolenaar8d462f92012-02-05 22:51:33 +01004014 AC_MSG_RESULT(no)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004015
Bram Moolenaard6d30422018-01-28 22:48:55 +01004016 AC_MSG_CHECKING(for AIX ACL support)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004017 AC_LINK_IFELSE([AC_LANG_PROGRAM([
Bram Moolenaar446cb832008-06-24 21:56:24 +00004018#if STDC_HEADERS
4019# include <stdlib.h>
4020# include <stddef.h>
4021#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004022#ifdef HAVE_SYS_ACL_H
4023# include <sys/acl.h>
4024#endif
4025#ifdef HAVE_SYS_ACCESS_H
4026# include <sys/access.h>
4027#endif
4028#define _ALL_SOURCE
4029
4030#include <sys/stat.h>
4031
4032int aclsize;
4033struct acl *aclent;], [aclsize = sizeof(struct acl);
4034 aclent = (void *)malloc(aclsize);
4035 statacl("foo", STX_NORMAL, aclent, aclsize);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004036 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004037 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_AIX_ACL),
4038 AC_MSG_RESULT(no))
4039else
4040 AC_MSG_RESULT(yes)
4041fi
4042
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02004043if test "x$GTK_CFLAGS" != "x"; then
4044 dnl pango_shape_full() is new, fall back to pango_shape().
4045 AC_MSG_CHECKING(for pango_shape_full)
4046 ac_save_CFLAGS="$CFLAGS"
4047 ac_save_LIBS="$LIBS"
4048 CFLAGS="$CFLAGS $GTK_CFLAGS"
4049 LIBS="$LIBS $GTK_LIBS"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004050 AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02004051 [#include <gtk/gtk.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004052 [ pango_shape_full(NULL, 0, NULL, 0, NULL, NULL); ])],
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02004053 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_PANGO_SHAPE_FULL),
4054 AC_MSG_RESULT(no))
4055 CFLAGS="$ac_save_CFLAGS"
4056 LIBS="$ac_save_LIBS"
4057fi
4058
Bram Moolenaar33fc4a62022-02-23 18:07:38 +00004059AC_MSG_CHECKING(--enable-gpm argument)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004060AC_ARG_ENABLE(gpm,
Bram Moolenaar33fc4a62022-02-23 18:07:38 +00004061 [ --enable-gpm=OPTS Use gpm (Linux mouse daemon). default=yes OPTS=yes/no/dynamic], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00004062 [enable_gpm="yes"])
4063
Bram Moolenaar33fc4a62022-02-23 18:07:38 +00004064if test "$enable_gpm" = "yes" -o "$enable_gpm" = "dynamic"; then
4065 AC_MSG_RESULT($enable_gpm)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004066 dnl Checking if gpm support can be compiled
4067 AC_CACHE_CHECK([for gpm], vi_cv_have_gpm,
4068 [olibs="$LIBS" ; LIBS="-lgpm"]
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004069 AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004070 [#include <gpm.h>
4071 #include <linux/keyboard.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004072 [Gpm_GetLibVersion(NULL);])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004073 dnl Configure defines HAVE_GPM, if it is defined feature.h defines
4074 dnl FEAT_MOUSE_GPM if mouse support is included
4075 [vi_cv_have_gpm=yes],
4076 [vi_cv_have_gpm=no])
4077 [LIBS="$olibs"]
4078 )
4079 if test $vi_cv_have_gpm = yes; then
Bram Moolenaar33fc4a62022-02-23 18:07:38 +00004080 if test "$enable_gpm" = "yes"; then
4081 LIBS="$LIBS -lgpm"
4082 else
4083 AC_DEFINE(DYNAMIC_GPM)
4084 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004085 AC_DEFINE(HAVE_GPM)
4086 fi
4087else
Bram Moolenaar33fc4a62022-02-23 18:07:38 +00004088 AC_MSG_RESULT(no)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004089fi
4090
Bram Moolenaar446cb832008-06-24 21:56:24 +00004091AC_MSG_CHECKING(--disable-sysmouse argument)
4092AC_ARG_ENABLE(sysmouse,
Bram Moolenaar8008b632017-07-18 21:33:20 +02004093 [ --disable-sysmouse Don't use sysmouse (mouse in *BSD console).], ,
Bram Moolenaar446cb832008-06-24 21:56:24 +00004094 [enable_sysmouse="yes"])
4095
4096if test "$enable_sysmouse" = "yes"; then
4097 AC_MSG_RESULT(no)
4098 dnl Checking if sysmouse support can be compiled
4099 dnl Configure defines HAVE_SYSMOUSE, if it is defined feature.h
4100 dnl defines FEAT_SYSMOUSE if mouse support is included
4101 AC_CACHE_CHECK([for sysmouse], vi_cv_have_sysmouse,
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004102 AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar446cb832008-06-24 21:56:24 +00004103 [#include <sys/consio.h>
4104 #include <signal.h>
4105 #include <sys/fbio.h>],
4106 [struct mouse_info mouse;
4107 mouse.operation = MOUSE_MODE;
4108 mouse.operation = MOUSE_SHOW;
4109 mouse.u.mode.mode = 0;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004110 mouse.u.mode.signal = SIGUSR2;])],
Bram Moolenaar446cb832008-06-24 21:56:24 +00004111 [vi_cv_have_sysmouse=yes],
4112 [vi_cv_have_sysmouse=no])
4113 )
4114 if test $vi_cv_have_sysmouse = yes; then
4115 AC_DEFINE(HAVE_SYSMOUSE)
4116 fi
4117else
4118 AC_MSG_RESULT(yes)
4119fi
4120
Bram Moolenaarf05da212009-11-17 16:13:15 +00004121dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
4122AC_MSG_CHECKING(for FD_CLOEXEC)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004123AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaarf05da212009-11-17 16:13:15 +00004124[#if HAVE_FCNTL_H
4125# include <fcntl.h>
4126#endif],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004127[ int flag = FD_CLOEXEC;])],
Bram Moolenaarf05da212009-11-17 16:13:15 +00004128 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
4129 AC_MSG_RESULT(not usable))
4130
Bram Moolenaar071d4272004-06-13 20:20:40 +00004131dnl rename needs to be checked separately to work on Nextstep with cc
4132AC_MSG_CHECKING(for rename)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004133AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>], [rename("this", "that")])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004134 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
4135 AC_MSG_RESULT(no))
4136
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004137dnl check for dirfd()
4138AC_MSG_CHECKING(for dirfd)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004139AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004140[#include <sys/types.h>
4141#include <dirent.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004142[DIR * dir=opendir("dirname"); dirfd(dir);])],
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004143AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DIRFD), AC_MSG_RESULT(not usable))
4144
4145dnl check for flock()
4146AC_MSG_CHECKING(for flock)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004147AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004148[#include <sys/file.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004149[flock(10, LOCK_SH);])],
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004150AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOCK), AC_MSG_RESULT(not usable))
4151
Bram Moolenaar071d4272004-06-13 20:20:40 +00004152dnl sysctl() may exist but not the arguments we use
4153AC_MSG_CHECKING(for sysctl)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004154AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004155[#include <sys/types.h>
4156#include <sys/sysctl.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004157[[ int mib[2], r;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004158 size_t len;
4159
4160 mib[0] = CTL_HW;
4161 mib[1] = HW_USERMEM;
4162 len = sizeof(r);
4163 (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004164 ]])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004165 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL),
4166 AC_MSG_RESULT(not usable))
4167
Bram Moolenaare2982d62021-10-06 11:27:21 +01004168dnl sysinfo() may exist but not be Linux compatible.
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004169dnl On some FreeBSD systems it may depend on libsysinfo, try to link
Bram Moolenaar071d4272004-06-13 20:20:40 +00004170AC_MSG_CHECKING(for sysinfo)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004171AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004172[#include <sys/types.h>
4173#include <sys/sysinfo.h>],
4174[ struct sysinfo sinfo;
4175 int t;
4176
4177 (void)sysinfo(&sinfo);
4178 t = sinfo.totalram;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004179 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004180 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
4181 AC_MSG_RESULT(not usable))
4182
Bram Moolenaar914572a2007-05-01 11:37:47 +00004183dnl struct sysinfo may have the mem_unit field or not
4184AC_MSG_CHECKING(for sysinfo.mem_unit)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004185AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar914572a2007-05-01 11:37:47 +00004186[#include <sys/types.h>
4187#include <sys/sysinfo.h>],
4188[ struct sysinfo sinfo;
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02004189 sinfo.mem_unit = 1;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004190 ])],
Bram Moolenaar914572a2007-05-01 11:37:47 +00004191 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_MEM_UNIT),
4192 AC_MSG_RESULT(no))
4193
Bram Moolenaarf52f0602021-03-10 21:26:37 +01004194dnl struct sysinfo may have the uptime field or not
4195AC_MSG_CHECKING(for sysinfo.uptime)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004196AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaarf52f0602021-03-10 21:26:37 +01004197[#include <sys/types.h>
4198#include <sys/sysinfo.h>],
4199[ struct sysinfo sinfo;
4200 long ut;
4201
4202 (void)sysinfo(&sinfo);
4203 ut = sinfo.uptime;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004204 ])],
Bram Moolenaarf52f0602021-03-10 21:26:37 +01004205 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_UPTIME),
4206 AC_MSG_RESULT(no))
4207
Bram Moolenaar071d4272004-06-13 20:20:40 +00004208dnl sysconf() may exist but not support what we want to use
4209AC_MSG_CHECKING(for sysconf)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004210AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004211[#include <unistd.h>],
4212[ (void)sysconf(_SC_PAGESIZE);
4213 (void)sysconf(_SC_PHYS_PAGES);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004214 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004215 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
4216 AC_MSG_RESULT(not usable))
4217
Bram Moolenaar0e62a672021-02-25 17:17:56 +01004218dnl check if we have _SC_SIGSTKSZ via sysconf()
4219AC_MSG_CHECKING(for _SC_SIGSTKSZ via sysconf())
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004220AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar0e62a672021-02-25 17:17:56 +01004221[#include <unistd.h>],
4222[ (void)sysconf(_SC_SIGSTKSZ);
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004223 ])],
Bram Moolenaar0e62a672021-02-25 17:17:56 +01004224 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF_SIGSTKSZ),
4225 AC_MSG_RESULT(not usable))
4226
Bram Moolenaar914703b2010-05-31 21:59:46 +02004227AC_CHECK_SIZEOF([int])
4228AC_CHECK_SIZEOF([long])
4229AC_CHECK_SIZEOF([time_t])
4230AC_CHECK_SIZEOF([off_t])
Bram Moolenaar644fdff2010-05-30 13:26:21 +02004231
Bram Moolenaara2aa31a2014-02-23 22:52:40 +01004232dnl Use different names to avoid clashing with other header files.
4233AC_DEFINE_UNQUOTED(VIM_SIZEOF_INT, [$ac_cv_sizeof_int])
4234AC_DEFINE_UNQUOTED(VIM_SIZEOF_LONG, [$ac_cv_sizeof_long])
4235
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004236dnl Make sure that uint32_t is really 32 bits unsigned.
4237AC_MSG_CHECKING([uint32_t is 32 bits])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004238AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004239#ifdef HAVE_STDINT_H
4240# include <stdint.h>
4241#endif
4242#ifdef HAVE_INTTYPES_H
4243# include <inttypes.h>
4244#endif
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01004245int main() {
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004246 uint32_t nr1 = (uint32_t)-1;
4247 uint32_t nr2 = (uint32_t)0xffffffffUL;
Bram Moolenaar52897832020-07-02 22:50:37 +02004248 if (sizeof(uint32_t) != 4 || nr1 != 0xffffffffUL || nr2 + 1 != 0) return 1;
4249 return 0;
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004250}])],
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004251AC_MSG_RESULT(ok),
4252AC_MSG_ERROR([WRONG! uint32_t not defined correctly.]),
Bram Moolenaar323cb952011-12-14 19:22:34 +01004253AC_MSG_WARN([cannot check uint32_t when cross-compiling.]))
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004254
Bram Moolenaar446cb832008-06-24 21:56:24 +00004255dnl Check for memmove() before bcopy(), makes memmove() be used when both are
4256dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
4257
Bram Moolenaar071d4272004-06-13 20:20:40 +00004258[bcopy_test_prog='
Bram Moolenaar446cb832008-06-24 21:56:24 +00004259#include "confdefs.h"
4260#ifdef HAVE_STRING_H
4261# include <string.h>
4262#endif
4263#if STDC_HEADERS
4264# include <stdlib.h>
4265# include <stddef.h>
4266#endif
Bram Moolenaar0f0d3a72022-06-19 18:02:05 +01004267int main() {
Bram Moolenaar071d4272004-06-13 20:20:40 +00004268 char buf[10];
4269 strcpy(buf, "abcdefghi");
4270 mch_memmove(buf, buf + 2, 3);
4271 if (strncmp(buf, "ababcf", 6))
4272 exit(1);
4273 strcpy(buf, "abcdefghi");
4274 mch_memmove(buf + 2, buf, 3);
4275 if (strncmp(buf, "cdedef", 6))
4276 exit(1);
4277 exit(0); /* libc version works properly. */
4278}']
4279
Bram Moolenaar446cb832008-06-24 21:56:24 +00004280AC_CACHE_CHECK([whether memmove handles overlaps],[vim_cv_memmove_handles_overlap],
4281 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004282 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 +00004283 [
4284 vim_cv_memmove_handles_overlap=yes
4285 ],[
4286 vim_cv_memmove_handles_overlap=no
4287 ],[
4288 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memmove_handles_overlap')
4289 ])
4290 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00004291
Bram Moolenaar446cb832008-06-24 21:56:24 +00004292if test "x$vim_cv_memmove_handles_overlap" = "xyes" ; then
4293 AC_DEFINE(USEMEMMOVE)
4294else
4295 AC_CACHE_CHECK([whether bcopy handles overlaps],[vim_cv_bcopy_handles_overlap],
4296 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004297 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 +00004298 [
4299 vim_cv_bcopy_handles_overlap=yes
4300 ],[
4301 vim_cv_bcopy_handles_overlap=no
4302 ],[
4303 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_bcopy_handles_overlap')
4304 ])
4305 ])
4306
4307 if test "x$vim_cv_bcopy_handles_overlap" = "xyes" ; then
4308 AC_DEFINE(USEBCOPY)
4309 else
4310 AC_CACHE_CHECK([whether memcpy handles overlaps],[vim_cv_memcpy_handles_overlap],
4311 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004312 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 +00004313 [
4314 vim_cv_memcpy_handles_overlap=yes
4315 ],[
4316 vim_cv_memcpy_handles_overlap=no
4317 ],[
4318 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memcpy_handles_overlap')
4319 ])
4320 ])
4321
4322 if test "x$vim_cv_memcpy_handles_overlap" = "xyes" ; then
4323 AC_DEFINE(USEMEMCPY)
4324 fi
4325 fi
4326fi
4327
Bram Moolenaar071d4272004-06-13 20:20:40 +00004328
4329dnl Check for multibyte locale functions
4330dnl Find out if _Xsetlocale() is supported by libX11.
4331dnl Check if X_LOCALE should be defined.
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004332if test "x$with_x" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004333 cflags_save=$CFLAGS
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004334 libs_save=$LIBS
4335 LIBS="$LIBS $X_LIBS $GUI_LIB_LOC $GUI_X_LIBS $X_PRE_LIBS $X_LIB $X_EXTRA_LIBS"
4336 CFLAGS="$CFLAGS $X_CFLAGS"
4337
4338 AC_MSG_CHECKING(whether X_LOCALE needed)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004339 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <X11/Xlocale.h>],)],
4340 AC_LINK_IFELSE([AC_LANG_CALL([],[_Xsetlocale])], [AC_MSG_RESULT(yes)
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004341 AC_DEFINE(X_LOCALE)], AC_MSG_RESULT(no)),
4342 AC_MSG_RESULT(no))
4343
4344 AC_MSG_CHECKING(whether Xutf8SetWMProperties() can be used)
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004345 AC_LINK_IFELSE([AC_LANG_CALL([],[Xutf8SetWMProperties])], [AC_MSG_RESULT(yes)
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004346 AC_DEFINE(HAVE_XUTF8SETWMPROPERTIES)], AC_MSG_RESULT(no))
4347
Bram Moolenaar071d4272004-06-13 20:20:40 +00004348 CFLAGS=$cflags_save
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004349 LIBS=$libs_save
Bram Moolenaar071d4272004-06-13 20:20:40 +00004350fi
4351
4352dnl Link with xpg4, it is said to make Korean locale working
4353AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,)
4354
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004355dnl Check how we can run ctags. Default to "ctags" when nothing works.
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02004356dnl Use --version to detect Exuberant ctags (preferred)
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004357dnl Add --fields=+S to get function signatures for omni completion.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004358dnl -t for typedefs (many ctags have this)
4359dnl -s for static functions (Elvis ctags only?)
4360dnl -v for variables. Dangerous, most ctags take this for 'vgrind style'.
4361dnl -i+m to test for older Exuberant ctags
4362AC_MSG_CHECKING(how to create tags)
4363test -f tags && mv tags tags.save
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004364if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004365 TAGPRG="ctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004366elif (eval exctags --version /dev/null | grep Exuberant) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004367 TAGPRG="exctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004368elif (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 +01004369 TAGPRG="exuberant-ctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004370else
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004371 TAGPRG="ctags"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004372 (eval etags /dev/null) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1 && TAGPRG="etags"
4373 (eval etags -c /dev/null) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1 && TAGPRG="etags -c"
4374 (eval ctags /dev/null) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1 && TAGPRG="ctags"
4375 (eval ctags -t /dev/null) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1 && TAGPRG="ctags -t"
4376 (eval ctags -ts /dev/null) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1 && TAGPRG="ctags -ts"
4377 (eval ctags -tvs /dev/null) < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&1 && TAGPRG="ctags -tvs"
4378 (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 +00004379fi
4380test -f tags.save && mv tags.save tags
4381AC_MSG_RESULT($TAGPRG) AC_SUBST(TAGPRG)
4382
4383dnl Check how we can run man with a section number
4384AC_MSG_CHECKING(how to run man with a section nr)
4385MANDEF="man"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004386(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 +00004387AC_MSG_RESULT($MANDEF)
4388if test "$MANDEF" = "man -s"; then
4389 AC_DEFINE(USEMAN_S)
4390fi
4391
4392dnl Check if gettext() is working and if it needs -lintl
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004393dnl We take care to base this on an empty LIBS: on some systems libelf would be
4394dnl in LIBS and implicitly take along libintl. The final LIBS would then not
4395dnl contain libintl, and the link step would fail due to -Wl,--as-needed.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004396AC_MSG_CHECKING(--disable-nls argument)
4397AC_ARG_ENABLE(nls,
4398 [ --disable-nls Don't support NLS (gettext()).], ,
4399 [enable_nls="yes"])
4400
4401if test "$enable_nls" = "yes"; then
4402 AC_MSG_RESULT(no)
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00004403
4404 INSTALL_LANGS=install-languages
4405 AC_SUBST(INSTALL_LANGS)
4406 INSTALL_TOOL_LANGS=install-tool-languages
4407 AC_SUBST(INSTALL_TOOL_LANGS)
4408
Bram Moolenaar071d4272004-06-13 20:20:40 +00004409 AC_CHECK_PROG(MSGFMT, msgfmt, msgfmt, )
4410 AC_MSG_CHECKING([for NLS])
4411 if test -f po/Makefile; then
4412 have_gettext="no"
4413 if test -n "$MSGFMT"; then
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004414 olibs=$LIBS
4415 LIBS=""
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004416 AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004417 [#include <libintl.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004418 [gettext("Test");])],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004419 AC_MSG_RESULT([gettext() works]); have_gettext="yes"; LIBS=$olibs,
4420 LIBS="-lintl"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004421 AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004422 [#include <libintl.h>],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004423 [gettext("Test");])],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004424 AC_MSG_RESULT([gettext() works with -lintl]); have_gettext="yes";
4425 LIBS="$olibs -lintl",
Bram Moolenaar071d4272004-06-13 20:20:40 +00004426 AC_MSG_RESULT([gettext() doesn't work]);
4427 LIBS=$olibs))
4428 else
4429 AC_MSG_RESULT([msgfmt not found - disabled]);
4430 fi
Martin Tournoij7904fa42022-10-04 16:28:45 +01004431 if test $have_gettext = "yes" -a "x$features" != "xtiny"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004432 AC_DEFINE(HAVE_GETTEXT)
4433 MAKEMO=yes
4434 AC_SUBST(MAKEMO)
4435 dnl this was added in GNU gettext 0.10.36
4436 AC_CHECK_FUNCS(bind_textdomain_codeset)
4437 dnl _nl_msg_cat_cntr is required for GNU gettext
4438 AC_MSG_CHECKING([for _nl_msg_cat_cntr])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004439 AC_LINK_IFELSE([AC_LANG_PROGRAM(
Bram Moolenaar071d4272004-06-13 20:20:40 +00004440 [#include <libintl.h>
4441 extern int _nl_msg_cat_cntr;],
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004442 [++_nl_msg_cat_cntr;])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004443 AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_NL_MSG_CAT_CNTR),
4444 AC_MSG_RESULT([no]))
Bram Moolenaar26096cc2019-04-11 15:25:40 +02004445 AC_MSG_CHECKING([if msgfmt supports --desktop])
4446 MSGFMT_DESKTOP=
4447 if "$MSGFMT" --help | grep -e '--desktop' >/dev/null; then
Bram Moolenaar62a88f42019-06-07 20:44:40 +02004448 if "$MSGFMT" --version | grep '0.19.[[3-7]]$' >/dev/null; then
4449 dnl GNU gettext 0.19.7's --desktop is broken. We assume back to
4450 dnl 0.19.3 is also broken.
4451 AC_MSG_RESULT([broken])
4452 else
4453 AC_MSG_RESULT([yes])
4454 MSGFMT_DESKTOP="gvim.desktop vim.desktop"
4455 fi
Bram Moolenaar26096cc2019-04-11 15:25:40 +02004456 else
4457 AC_MSG_RESULT([no])
4458 fi
4459 AC_SUBST(MSGFMT_DESKTOP)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004460 fi
4461 else
4462 AC_MSG_RESULT([no "po/Makefile" - disabled]);
4463 fi
4464else
4465 AC_MSG_RESULT(yes)
4466fi
4467
4468dnl Check for dynamic linking loader
4469AC_CHECK_HEADER(dlfcn.h, DLL=dlfcn.h, [AC_CHECK_HEADER(dl.h, DLL=dl.h)])
4470if test x${DLL} = xdlfcn.h; then
4471 AC_DEFINE(HAVE_DLFCN_H, 1, [ Define if we have dlfcn.h. ])
4472 AC_MSG_CHECKING([for dlopen()])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004473 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004474 extern void* dlopen();
4475 dlopen();
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004476 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004477 AC_MSG_RESULT(yes);
4478 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4479 AC_MSG_RESULT(no);
4480 AC_MSG_CHECKING([for dlopen() in -ldl])
4481 olibs=$LIBS
4482 LIBS="$LIBS -ldl"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004483 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004484 extern void* dlopen();
4485 dlopen();
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004486 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004487 AC_MSG_RESULT(yes);
4488 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4489 AC_MSG_RESULT(no);
4490 LIBS=$olibs))
4491 dnl ReliantUNIX has dlopen() in libc but everything else in libdl
4492 dnl ick :-)
4493 AC_MSG_CHECKING([for dlsym()])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004494 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004495 extern void* dlsym();
4496 dlsym();
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004497 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004498 AC_MSG_RESULT(yes);
4499 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4500 AC_MSG_RESULT(no);
4501 AC_MSG_CHECKING([for dlsym() in -ldl])
4502 olibs=$LIBS
4503 LIBS="$LIBS -ldl"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004504 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004505 extern void* dlsym();
4506 dlsym();
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004507 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004508 AC_MSG_RESULT(yes);
4509 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4510 AC_MSG_RESULT(no);
4511 LIBS=$olibs))
4512elif test x${DLL} = xdl.h; then
4513 AC_DEFINE(HAVE_DL_H, 1, [ Define if we have dl.h. ])
4514 AC_MSG_CHECKING([for shl_load()])
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004515 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004516 extern void* shl_load();
4517 shl_load();
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004518 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004519 AC_MSG_RESULT(yes);
4520 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4521 AC_MSG_RESULT(no);
4522 AC_MSG_CHECKING([for shl_load() in -ldld])
4523 olibs=$LIBS
4524 LIBS="$LIBS -ldld"
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004525 AC_LINK_IFELSE([AC_LANG_PROGRAM(,[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004526 extern void* shl_load();
4527 shl_load();
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004528 ])],
Bram Moolenaar071d4272004-06-13 20:20:40 +00004529 AC_MSG_RESULT(yes);
4530 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4531 AC_MSG_RESULT(no);
4532 LIBS=$olibs))
4533fi
4534AC_CHECK_HEADERS(setjmp.h)
4535
Bram Moolenaard0573012017-10-28 21:11:06 +02004536if test "x$MACOS_X" = "xyes" -a -n "$PERL"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004537 dnl -ldl must come after DynaLoader.a
4538 if echo $LIBS | grep -e '-ldl' >/dev/null; then
4539 LIBS=`echo $LIBS | sed s/-ldl//`
4540 PERL_LIBS="$PERL_LIBS -ldl"
4541 fi
4542fi
4543
Bram Moolenaard0573012017-10-28 21:11:06 +02004544if test "$MACOS_X" = "yes"; then
4545 AC_MSG_CHECKING([whether we need macOS frameworks])
Bram Moolenaar097148e2020-08-11 21:58:20 +02004546 if test "$MACOS_X_DARWIN" = "yes"; then
Bram Moolenaard0573012017-10-28 21:11:06 +02004547 if test "$features" = "tiny"; then
Yee Cheng Chin4314e4f2022-10-08 13:50:05 +01004548 dnl Since no FEAT_CLIPBOARD or FEAT_SOUND, no need for os_macosx.m.
Bram Moolenaard0573012017-10-28 21:11:06 +02004549 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_macosx.m++'`
4550 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_macosx.o++'`
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01004551 AC_MSG_RESULT([yes, we need CoreServices])
4552 LIBS="$LIBS -framework CoreServices"
Bram Moolenaard0573012017-10-28 21:11:06 +02004553 else
4554 AC_MSG_RESULT([yes, we need AppKit])
4555 LIBS="$LIBS -framework AppKit"
Bram Moolenaard0573012017-10-28 21:11:06 +02004556 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004557 else
Bram Moolenaard0573012017-10-28 21:11:06 +02004558 AC_MSG_RESULT([no])
Bram Moolenaar3437b912013-07-03 19:52:53 +02004559 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004560fi
4561
Bram Moolenaar3ae5fc92021-09-06 18:57:30 +02004562dnl On some systems REENTRANT needs to be defined. It should not hurt to use
4563dnl it everywhere.
4564if `echo "$CFLAGS" | grep -v D_REENTRANT >/dev/null`; then
4565 CFLAGS="$CFLAGS -D_REENTRANT"
4566fi
4567
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004568dnl gcc 3.1 changed the meaning of -MM. The only solution appears to be to
4569dnl use "-isystem" instead of "-I" for all non-Vim include dirs.
4570dnl But only when making dependencies, cproto and lint don't take "-isystem".
Bram Moolenaar32466aa2006-02-24 23:53:04 +00004571dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
4572dnl the number before the version number.
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004573DEPEND_CFLAGS_FILTER=
4574if test "$GCC" = yes; then
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004575 AC_MSG_CHECKING(for GCC 3 or later)
Bram Moolenaar348808f2020-02-07 20:50:07 +01004576 gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]][[0-9]]*\)\..*$/\1/g'`
Bram Moolenaarf740b292006-02-16 22:11:02 +00004577 if test "$gccmajor" -gt "2"; then
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004578 DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004579 AC_MSG_RESULT(yes)
4580 else
4581 AC_MSG_RESULT(no)
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004582 fi
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004583 dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
4584 dnl declared as char x[1] but actually longer. Introduced in gcc 4.0.
Bram Moolenaar56d1db32009-12-16 16:14:51 +00004585 dnl Also remove duplicate _FORTIFY_SOURCE arguments.
Bram Moolenaaraeabe052011-12-08 15:17:34 +01004586 dnl And undefine it first to avoid a warning.
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004587 AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
4588 if test "$gccmajor" -gt "3"; then
Bram Moolenaar26f20132021-04-03 17:33:52 +02004589 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/'`
4590 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 +00004591 AC_MSG_RESULT(yes)
4592 else
4593 AC_MSG_RESULT(no)
4594 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +00004595fi
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004596AC_SUBST(DEPEND_CFLAGS_FILTER)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004597
Bram Moolenaarec0557f2018-01-31 14:41:37 +01004598dnl On some systems AC_SYS_LARGEFILE determines that -D_FILE_OFFSET_BITS=64
4599dnl isn't required, but the CFLAGS for some of the libraries we're using
4600dnl include the define. Since the define changes the size of some datatypes
4601dnl (e.g. ino_t and off_t), all of Vim's modules must be compiled with a
4602dnl consistent value. It's therefore safest to force the use of the define
4603dnl if it's present in any of the *_CFLAGS variables.
4604AC_MSG_CHECKING(whether we need to force -D_FILE_OFFSET_BITS=64)
Bram Moolenaar9ce42132018-04-11 22:19:36 +02004605if 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 +01004606 AC_MSG_RESULT(yes)
4607 AC_DEFINE(_FILE_OFFSET_BITS, 64)
4608else
4609 AC_MSG_RESULT(no)
4610fi
4611
Bram Moolenaar6cd42db2020-12-04 18:09:54 +01004612dnl $LDFLAGS is passed to glibtool in libvterm, it doesn't like a space
4613dnl between "-L" and the path that follows.
4614LDFLAGS=`echo "$LDFLAGS" | sed -e 's/-L /-L/g'`
4615
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004616dnl link.sh tries to avoid overlinking in a hackish way.
4617dnl At least GNU ld supports --as-needed which provides the same functionality
4618dnl at linker level. Let's use it.
4619AC_MSG_CHECKING(linker --as-needed support)
4620LINK_AS_NEEDED=
4621# Check if linker supports --as-needed and --no-as-needed options
4622if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
Natanael Copa761ead42021-05-15 14:25:37 +02004623 if ! echo "$LDFLAGS" | grep -q -- '-Wl,[[^[:space:]]]*--as-needed'; then
4624 LDFLAGS="$LDFLAGS -Wl,--as-needed"
4625 fi
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004626 LINK_AS_NEEDED=yes
4627fi
4628if test "$LINK_AS_NEEDED" = yes; then
4629 AC_MSG_RESULT(yes)
4630else
4631 AC_MSG_RESULT(no)
4632fi
4633AC_SUBST(LINK_AS_NEEDED)
4634
Bram Moolenaar77c19352012-06-13 19:19:41 +02004635# IBM z/OS reset CFLAGS for config.mk
4636if test "$zOSUnix" = "yes"; then
4637 CFLAGS="-D_ALL_SOURCE -Wc,float\(ieee\),dll"
4638fi
4639
Bram Moolenaar071d4272004-06-13 20:20:40 +00004640dnl write output files
Bram Moolenaar1004b3d2022-06-05 19:51:55 +01004641AC_CONFIG_FILES(auto/config.mk:config.mk.in)
4642AC_OUTPUT
Bram Moolenaar071d4272004-06-13 20:20:40 +00004643
4644dnl vim: set sw=2 tw=78 fo+=l: