blob: fe2a40134200fe4e2ef2119627b502a2d64a5aaf [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
3dnl Process this file with autoconf 2.12 or 2.13 to produce "configure".
4dnl Should also work with autoconf 2.54 and later.
5
6AC_INIT(vim.h)
7AC_CONFIG_HEADER(auto/config.h:config.h.in)
8
9dnl Being able to run configure means the system is Unix (compatible).
10AC_DEFINE(UNIX)
11AC_PROG_MAKE_SET
12
13dnl Checks for programs.
Bram Moolenaar22640082018-04-19 20:39:41 +020014AC_PROG_CC_C99 dnl required by almost everything
Bram Moolenaarc0394412017-04-20 20:20:23 +020015AC_PROG_CPP dnl required by header file checks
16AC_PROGRAM_EGREP dnl required by AC_EGREP_CPP
17AC_PROG_FGREP dnl finds working grep -F
18AC_ISC_POSIX dnl required by AC_C_CROSS
19AC_PROG_AWK dnl required for "make html" in ../doc
Bram Moolenaar071d4272004-06-13 20:20:40 +000020
21dnl Don't strip if we don't have it
22AC_CHECK_PROG(STRIP, strip, strip, :)
23
Bram Moolenaar325b7a22004-07-05 15:58:32 +000024dnl Check for extension of executables
Bram Moolenaar071d4272004-06-13 20:20:40 +000025AC_EXEEXT
26
Bram Moolenaar446cb832008-06-24 21:56:24 +000027dnl Check for standard headers. We don't use this in Vim but other stuff
28dnl in autoconf needs it, where it uses STDC_HEADERS.
29AC_HEADER_STDC
30AC_HEADER_SYS_WAIT
31
Bram Moolenaar561f8a52018-04-17 22:02:45 +020032dnl Check that the C99 features that Vim uses are supported:
Bram Moolenaar22640082018-04-19 20:39:41 +020033if test x"$ac_cv_prog_cc_c99" != xno; then
34 dnl If the compiler doesn't explicitly support C99, then check
35 dnl for the specific features Vim uses
36
37 AC_TYPE_LONG_LONG_INT
38 if test "$ac_cv_type_long_long_int" = no; then
39 AC_MSG_FAILURE([Compiler does not support long long int])
40 fi
41
42 AC_MSG_CHECKING([if the compiler supports trailing commas])
43 trailing_commas=no
44 AC_TRY_COMPILE([], [
45 enum {
46 one,
47 };],
48 [AC_MSG_RESULT(yes); trailing_commas=yes],
49 [AC_MSG_RESULT(no)])
50 if test "$trailing_commas" = no; then
51 AC_MSG_FAILURE([Compiler does not support trailing comma in enum])
52 fi
53
54 AC_MSG_CHECKING([if the compiler supports C++ comments])
55 slash_comments=no
56 AC_TRY_COMPILE([],
57 [// C++ comments?],
58 [AC_MSG_RESULT(yes); slash_comments=yes],
59 [AC_MSG_RESULT(no)])
60 if test "$slash_comments" = no; then
61 AC_MSG_FAILURE([Compiler does not support C++ comments])
62 fi
63fi
Bram Moolenaar561f8a52018-04-17 22:02:45 +020064
Bram Moolenaar8f1dde52020-06-05 23:16:29 +020065dnl If $SOURCE_DATE_EPOCH is present in the environment, use that as the
66dnl "compiled" timestamp in :version's output. Attempt to get the formatted
67dnl date using GNU date syntax, BSD date syntax, and finally falling back to
68dnl just using the current time.
69if test -n "$SOURCE_DATE_EPOCH"; then
70 DATE_FMT="%b %d %Y %H:%M:%S"
71 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")
72 AC_DEFINE_UNQUOTED(BUILD_DATE, ["$BUILD_DATE"])
73 BUILD_DATE_MSG=-"echo -e '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\nNOTE: build date/time is fixed: $BUILD_DATE\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='"
74 AC_SUBST(BUILD_DATE_MSG)
75fi
76
Bram Moolenaarf788a062011-12-14 20:51:25 +010077dnl Check for the flag that fails if stuff are missing.
78
79AC_MSG_CHECKING(--enable-fail-if-missing argument)
80AC_ARG_ENABLE(fail_if_missing,
81 [ --enable-fail-if-missing Fail if dependencies on additional features
82 specified on the command line are missing.],
83 [fail_if_missing="yes"],
84 [fail_if_missing="no"])
85AC_MSG_RESULT($fail_if_missing)
86
Bram Moolenaard2a05492018-07-27 22:35:15 +020087dnl Keep original value to check later.
88with_x_arg="$with_x"
89
Bram Moolenaar071d4272004-06-13 20:20:40 +000090dnl Set default value for CFLAGS if none is defined or it's empty
91if test -z "$CFLAGS"; then
92 CFLAGS="-O"
93 test "$GCC" = yes && CFLAGS="-O2 -fno-strength-reduce -Wall"
94fi
95if test "$GCC" = yes; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +000096 dnl method that should work for nearly all versions
Bram Moolenaarc8836f72014-04-12 13:12:24 +020097 gccversion=`$CC -dumpversion`
Bram Moolenaar910f66f2006-04-05 20:41:53 +000098 if test "x$gccversion" = "x"; then
99 dnl old method; fall-back for when -dumpversion doesn't work
Bram Moolenaarc8836f72014-04-12 13:12:24 +0200100 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 +0000101 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +0000102 dnl version 4.0.1 was reported to cause trouble on Macintosh by Marcin Dalecki
103 if test "$gccversion" = "3.0.1" -o "$gccversion" = "3.0.2" -o "$gccversion" = "4.0.1"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000104 echo 'GCC [[34]].0.[[12]] has a bug in the optimizer, disabling "-O#"'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000105 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-O/'`
106 else
107 if test "$gccversion" = "3.1" -o "$gccversion" = "3.2" -o "$gccversion" = "3.2.1" && `echo "$CFLAGS" | grep -v fno-strength-reduce >/dev/null`; then
108 echo 'GCC 3.1 and 3.2 have a bug in the optimizer, adding "-fno-strength-reduce"'
109 CFLAGS="$CFLAGS -fno-strength-reduce"
110 fi
111 fi
112fi
113
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200114dnl clang-500.2.75 or around has abandoned -f[no-]strength-reduce and issues a
115dnl warning when that flag is passed to. Accordingly, adjust CFLAGS based on
116dnl the version number of the clang in use.
117dnl Note that this does not work to get the version of clang 3.1 or 3.2.
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100118AC_MSG_CHECKING(for clang version)
119CLANG_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 +0200120if test x"$CLANG_VERSION_STRING" != x"" ; then
121 CLANG_MAJOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*/\1/p'`
122 CLANG_MINOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/p'`
123 CLANG_REVISION=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)/\1/p'`
124 CLANG_VERSION=`expr $CLANG_MAJOR '*' 1000000 '+' $CLANG_MINOR '*' 1000 '+' $CLANG_REVISION`
125 AC_MSG_RESULT($CLANG_VERSION)
126 dnl If you find the same issue with versions earlier than 500.2.75,
127 dnl change the constant 500002075 below appropriately. To get the
128 dnl integer corresponding to a version number, refer to the
129 dnl definition of CLANG_VERSION above.
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100130 AC_MSG_CHECKING(if clang supports -fno-strength-reduce)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200131 if test "$CLANG_VERSION" -ge 500002075 ; then
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100132 AC_MSG_RESULT(no)
133 CFLAGS=`echo "$CFLAGS" | sed -e 's/-fno-strength-reduce/ /'`
134 else
135 AC_MSG_RESULT(yes)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200136 fi
137else
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100138 AC_MSG_RESULT(N/A)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200139fi
140
Bram Moolenaar446cb832008-06-24 21:56:24 +0000141dnl If configure thinks we are cross compiling, there might be something
142dnl wrong with the CC or CFLAGS settings, give a useful warning message
Bram Moolenaar839e9542016-04-14 16:46:02 +0200143CROSS_COMPILING=
Bram Moolenaar071d4272004-06-13 20:20:40 +0000144if test "$cross_compiling" = yes; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000145 AC_MSG_RESULT([cannot compile a simple program; if not cross compiling check CC and CFLAGS])
Bram Moolenaar839e9542016-04-14 16:46:02 +0200146 CROSS_COMPILING=1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000147fi
Bram Moolenaar839e9542016-04-14 16:46:02 +0200148AC_SUBST(CROSS_COMPILING)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000149
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +0000150dnl gcc-cpp has the wonderful -MM option to produce nicer dependencies.
151dnl But gcc 3.1 changed the meaning! See near the end.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000152test "$GCC" = yes && CPP_MM=M; AC_SUBST(CPP_MM)
153
154if test -f ./toolcheck; then
155 AC_CHECKING(for buggy tools)
156 sh ./toolcheck 1>&AC_FD_MSG
157fi
158
159OS_EXTRA_SRC=""; OS_EXTRA_OBJ=""
160
Bram Moolenaarb3f74062020-02-26 16:16:53 +0100161AC_MSG_CHECKING(for Haiku)
162case `uname` in
163 Haiku) HAIKU=yes; AC_MSG_RESULT(yes);;
164 *) HAIKU=no; AC_MSG_RESULT(no);;
165esac
166
Bram Moolenaar071d4272004-06-13 20:20:40 +0000167dnl If QNX is found, assume we don't want to use Xphoton
168dnl unless it was specifically asked for (--with-x)
169AC_MSG_CHECKING(for QNX)
170case `uname` in
171 QNX) OS_EXTRA_SRC=os_qnx.c; OS_EXTRA_OBJ=objects/os_qnx.o
172 test -z "$with_x" && with_x=no
173 QNX=yes; AC_MSG_RESULT(yes);;
174 *) QNX=no; AC_MSG_RESULT(no);;
175esac
176
177dnl Check for Darwin and MacOS X
178dnl We do a check for MacOS X in the very beginning because there
179dnl are a lot of other things we need to change besides GUI stuff
Bram Moolenaar071d4272004-06-13 20:20:40 +0000180AC_MSG_CHECKING([for Darwin (Mac OS X)])
181if test "`(uname) 2>/dev/null`" = Darwin; then
182 AC_MSG_RESULT(yes)
Bram Moolenaard0573012017-10-28 21:11:06 +0200183 MACOS_X=yes
Bram Moolenaar52ecaaa2018-05-12 21:38:13 +0200184 CPPFLAGS="$CPPFLAGS -DMACOS_X"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000185
186 AC_MSG_CHECKING(--disable-darwin argument)
187 AC_ARG_ENABLE(darwin,
188 [ --disable-darwin Disable Darwin (Mac OS X) support.],
189 , [enable_darwin="yes"])
190 if test "$enable_darwin" = "yes"; then
191 AC_MSG_RESULT(no)
192 AC_MSG_CHECKING(if Darwin files are there)
Bram Moolenaar164fca32010-07-14 13:58:07 +0200193 if test -f os_macosx.m; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000194 AC_MSG_RESULT(yes)
195 else
196 AC_MSG_RESULT([no, Darwin support disabled])
197 enable_darwin=no
198 fi
199 else
200 AC_MSG_RESULT([yes, Darwin support excluded])
201 fi
202
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000203 AC_MSG_CHECKING(--with-mac-arch argument)
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000204 AC_ARG_WITH(mac-arch, [ --with-mac-arch=ARCH current, intel, ppc or both],
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000205 MACARCH="$withval"; AC_MSG_RESULT($MACARCH),
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000206 MACARCH="current"; AC_MSG_RESULT(defaulting to $MACARCH))
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000207
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100208 AC_MSG_CHECKING(--with-developer-dir argument)
209 AC_ARG_WITH(developer-dir, [ --with-developer-dir=PATH use PATH as location for Xcode developer tools],
210 DEVELOPER_DIR="$withval"; AC_MSG_RESULT($DEVELOPER_DIR),
Bram Moolenaar32d03b32015-11-19 13:46:48 +0100211 AC_MSG_RESULT(not present))
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100212
213 if test "x$DEVELOPER_DIR" = "x"; then
214 AC_PATH_PROG(XCODE_SELECT, xcode-select)
215 if test "x$XCODE_SELECT" != "x"; then
216 AC_MSG_CHECKING(for developer dir using xcode-select)
217 DEVELOPER_DIR=`$XCODE_SELECT -print-path`
218 AC_MSG_RESULT([$DEVELOPER_DIR])
219 else
220 DEVELOPER_DIR=/Developer
221 fi
222 fi
223
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000224 if test "x$MACARCH" = "xboth"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000225 AC_MSG_CHECKING(for 10.4 universal SDK)
226 dnl There is a terrible inconsistency (but we appear to get away with it):
227 dnl $CFLAGS uses the 10.4u SDK library for the headers, while $CPPFLAGS
228 dnl doesn't, because "gcc -E" doesn't grok it. That means the configure
229 dnl tests using the preprocessor are actually done with the wrong header
230 dnl files. $LDFLAGS is set at the end, because configure uses it together
231 dnl with $CFLAGS and we can only have one -sysroot argument.
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000232 save_cppflags="$CPPFLAGS"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000233 save_cflags="$CFLAGS"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000234 save_ldflags="$LDFLAGS"
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100235 CFLAGS="$CFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000236 AC_TRY_LINK([ ], [ ],
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000237 AC_MSG_RESULT(found, will make universal binary),
238
239 AC_MSG_RESULT(not found)
Bram Moolenaar1f35bf92006-03-07 22:38:47 +0000240 CFLAGS="$save_cflags"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000241 AC_MSG_CHECKING(if Intel architecture is supported)
242 CPPFLAGS="$CPPFLAGS -arch i386"
243 LDFLAGS="$save_ldflags -arch i386"
244 AC_TRY_LINK([ ], [ ],
245 AC_MSG_RESULT(yes); MACARCH="intel",
246 AC_MSG_RESULT(no, using PowerPC)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000247 MACARCH="ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000248 CPPFLAGS="$save_cppflags -arch ppc"
249 LDFLAGS="$save_ldflags -arch ppc"))
250 elif test "x$MACARCH" = "xintel"; then
251 CPPFLAGS="$CPPFLAGS -arch intel"
252 LDFLAGS="$LDFLAGS -arch intel"
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000253 elif test "x$MACARCH" = "xppc"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000254 CPPFLAGS="$CPPFLAGS -arch ppc"
255 LDFLAGS="$LDFLAGS -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000256 fi
257
Bram Moolenaar071d4272004-06-13 20:20:40 +0000258 if test "$enable_darwin" = "yes"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200259 MACOS_X_DARWIN=yes
Bram Moolenaar164fca32010-07-14 13:58:07 +0200260 OS_EXTRA_SRC="os_macosx.m os_mac_conv.c";
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000261 OS_EXTRA_OBJ="objects/os_macosx.o objects/os_mac_conv.o"
Bram Moolenaar32466aa2006-02-24 23:53:04 +0000262 dnl TODO: use -arch i386 on Intel machines
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100263 dnl Removed -no-cpp-precomp, only for very old compilers.
Bram Moolenaard0573012017-10-28 21:11:06 +0200264 CPPFLAGS="$CPPFLAGS -DMACOS_X_DARWIN"
Bram Moolenaar040f9752020-08-11 23:08:48 +0200265
266 dnl Assume we don't want X11 unless it was specifically asked for
267 dnl (--with-x) or Motif, Athena or GTK GUI is used.
268 if test -z "$with_x" -a "X$enable_gui" != Xmotif -a "X$enable_gui" != Xathena -a "X$enable_gui" != Xgtk2 -a "X$enable_gui" != Xgtk3; then
269 with_x=no
270 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000271 fi
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000272
Bram Moolenaardb552d602006-03-23 22:59:57 +0000273 dnl Avoid a bug with -O2 with gcc 4.0.1. Symptom: malloc() reports double
Bram Moolenaarfd2ac762006-03-01 22:09:21 +0000274 dnl free. This happens in expand_filename(), because the optimizer swaps
Bram Moolenaardb552d602006-03-23 22:59:57 +0000275 dnl two blocks of code, both using "repl", that can't be swapped.
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000276 if test "$MACARCH" = "intel" -o "$MACARCH" = "both"; then
277 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-Oz/'`
278 fi
279
Bram Moolenaar071d4272004-06-13 20:20:40 +0000280else
281 AC_MSG_RESULT(no)
282fi
283
Bram Moolenaar39766a72013-11-03 00:41:00 +0100284dnl Mac OS X 10.9+ no longer include AvailabilityMacros.h in Carbon
285dnl so we need to include it to have access to version macros.
Bram Moolenaar18e54692013-11-03 20:26:31 +0100286AC_CHECK_HEADERS(AvailabilityMacros.h)
Bram Moolenaar39766a72013-11-03 00:41:00 +0100287
Bram Moolenaar071d4272004-06-13 20:20:40 +0000288AC_SUBST(OS_EXTRA_SRC)
289AC_SUBST(OS_EXTRA_OBJ)
290
291dnl Add /usr/local/lib to $LDFLAGS and /usr/local/include to CFLAGS.
292dnl Only when the directory exists and it wasn't there yet.
293dnl For gcc don't do this when it is already in the default search path.
Bram Moolenaar446cb832008-06-24 21:56:24 +0000294dnl Skip all of this when cross-compiling.
295if test "$cross_compiling" = no; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000296 AC_MSG_CHECKING(--with-local-dir argument)
Bram Moolenaar446cb832008-06-24 21:56:24 +0000297 have_local_include=''
298 have_local_lib=''
Bram Moolenaarc236c162008-07-13 17:41:49 +0000299 AC_ARG_WITH([local-dir], [ --with-local-dir=PATH search PATH instead of /usr/local for local libraries.
300 --without-local-dir do not search /usr/local for local libraries.], [
301 local_dir="$withval"
302 case "$withval" in
303 */*) ;;
304 no)
305 # avoid adding local dir to LDFLAGS and CPPFLAGS
Bram Moolenaare06c1882010-07-21 22:05:20 +0200306 have_local_include=yes
Bram Moolenaarc236c162008-07-13 17:41:49 +0000307 have_local_lib=yes
308 ;;
309 *) AC_MSG_ERROR(must pass path argument to --with-local-dir) ;;
310 esac
311 AC_MSG_RESULT($local_dir)
312 ], [
313 local_dir=/usr/local
314 AC_MSG_RESULT(Defaulting to $local_dir)
315 ])
316 if test "$GCC" = yes -a "$local_dir" != no; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000317 echo 'void f(){}' > conftest.c
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100318 dnl Removed -no-cpp-precomp, only needed for OS X 10.2 (Ben Fowler)
319 have_local_include=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/include"`
Bram Moolenaarc236c162008-07-13 17:41:49 +0000320 have_local_lib=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/lib"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000321 rm -f conftest.c conftest.o
Bram Moolenaar071d4272004-06-13 20:20:40 +0000322 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000323 if test -z "$have_local_lib" -a -d "${local_dir}/lib"; then
324 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 +0000325 if test "$tt" = "$LDFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000326 LDFLAGS="$LDFLAGS -L${local_dir}/lib"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000327 fi
328 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000329 if test -z "$have_local_include" -a -d "${local_dir}/include"; then
330 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 +0000331 if test "$tt" = "$CPPFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000332 CPPFLAGS="$CPPFLAGS -I${local_dir}/include"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000333 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000334 fi
335fi
336
337AC_MSG_CHECKING(--with-vim-name argument)
338AC_ARG_WITH(vim-name, [ --with-vim-name=NAME what to call the Vim executable],
339 VIMNAME="$withval"; AC_MSG_RESULT($VIMNAME),
Bram Moolenaare344bea2005-09-01 20:46:49 +0000340 VIMNAME="vim"; AC_MSG_RESULT(Defaulting to $VIMNAME))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000341AC_SUBST(VIMNAME)
342AC_MSG_CHECKING(--with-ex-name argument)
343AC_ARG_WITH(ex-name, [ --with-ex-name=NAME what to call the Ex executable],
344 EXNAME="$withval"; AC_MSG_RESULT($EXNAME),
345 EXNAME="ex"; AC_MSG_RESULT(Defaulting to ex))
346AC_SUBST(EXNAME)
347AC_MSG_CHECKING(--with-view-name argument)
348AC_ARG_WITH(view-name, [ --with-view-name=NAME what to call the View executable],
349 VIEWNAME="$withval"; AC_MSG_RESULT($VIEWNAME),
350 VIEWNAME="view"; AC_MSG_RESULT(Defaulting to view))
351AC_SUBST(VIEWNAME)
352
353AC_MSG_CHECKING(--with-global-runtime argument)
Bram Moolenaar9d302ad2018-12-21 11:48:51 +0100354AC_ARG_WITH(global-runtime, [ --with-global-runtime=DIR global runtime directory in 'runtimepath', comma-separated for multiple directories],
355 RUNTIME_GLOBAL="$withval"; AC_MSG_RESULT($withval),
Bram Moolenaar071d4272004-06-13 20:20:40 +0000356 AC_MSG_RESULT(no))
357
Bram Moolenaar9d302ad2018-12-21 11:48:51 +0100358if test "X$RUNTIME_GLOBAL" != "X"; then
359 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" }')
360 AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL, "$RUNTIME_GLOBAL")
361 AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL_AFTER, "$RUNTIME_GLOBAL_AFTER")
362fi
363
Bram Moolenaar071d4272004-06-13 20:20:40 +0000364AC_MSG_CHECKING(--with-modified-by argument)
365AC_ARG_WITH(modified-by, [ --with-modified-by=NAME name of who modified a release version],
366 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(MODIFIED_BY, "$withval"),
367 AC_MSG_RESULT(no))
368
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200369dnl Check for EBCDIC stolen from the LYNX port to z/OS Unix
Bram Moolenaar071d4272004-06-13 20:20:40 +0000370AC_MSG_CHECKING(if character set is EBCDIC)
371AC_TRY_COMPILE([ ],
372[ /* TryCompile function for CharSet.
373 Treat any failure as ASCII for compatibility with existing art.
374 Use compile-time rather than run-time tests for cross-compiler
375 tolerance. */
376#if '0'!=240
377make an error "Character set is not EBCDIC"
378#endif ],
379[ # TryCompile action if true
380cf_cv_ebcdic=yes ],
381[ # TryCompile action if false
382cf_cv_ebcdic=no])
383# end of TryCompile ])
384# end of CacheVal CvEbcdic
385AC_MSG_RESULT($cf_cv_ebcdic)
386case "$cf_cv_ebcdic" in #(vi
387 yes) AC_DEFINE(EBCDIC)
388 line_break='"\\n"'
389 ;;
390 *) line_break='"\\012"';;
391esac
392AC_SUBST(line_break)
393
394if test "$cf_cv_ebcdic" = "yes"; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +0200395dnl If we have EBCDIC we most likely have z/OS Unix, let's test it!
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200396AC_MSG_CHECKING(for z/OS Unix)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000397case `uname` in
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200398 OS/390) zOSUnix="yes";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000399 dnl If using cc the environment variable _CC_CCMODE must be
400 dnl set to "1", so that some compiler extensions are enabled.
401 dnl If using c89 the environment variable is named _CC_C89MODE.
402 dnl Note: compile with c89 never tested.
403 if test "$CC" = "cc"; then
404 ccm="$_CC_CCMODE"
405 ccn="CC"
406 else
407 if test "$CC" = "c89"; then
408 ccm="$_CC_C89MODE"
409 ccn="C89"
410 else
411 ccm=1
412 fi
413 fi
414 if test "$ccm" != "1"; then
415 echo ""
416 echo "------------------------------------------"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200417 echo " On z/OS Unix, the environment variable"
Bram Moolenaar77c19352012-06-13 19:19:41 +0200418 echo " _CC_${ccn}MODE must be set to \"1\"!"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000419 echo " Do:"
420 echo " export _CC_${ccn}MODE=1"
421 echo " and then call configure again."
422 echo "------------------------------------------"
423 exit 1
424 fi
Bram Moolenaar77c19352012-06-13 19:19:41 +0200425 # Set CFLAGS for configure process.
426 # This will be reset later for config.mk.
427 # Use haltonmsg to force error for missing H files.
428 CFLAGS="$CFLAGS -D_ALL_SOURCE -Wc,float(ieee),haltonmsg(3296)";
429 LDFLAGS="$LDFLAGS -Wl,EDIT=NO"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000430 AC_MSG_RESULT(yes)
431 ;;
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200432 *) zOSUnix="no";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000433 AC_MSG_RESULT(no)
434 ;;
435esac
436fi
437
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200438dnl Set QUOTESED. Needs additional backslashes on zOS
439if test "$zOSUnix" = "yes"; then
Bram Moolenaarabcbb0e2020-12-23 12:33:42 +0100440 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\\\\\&/g' -e 's/\\\\\\\\\"/\"/' -e 's/\\\\\\\\\";\$\$/\";/' -e 's/ */ /g'"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200441else
Bram Moolenaarabcbb0e2020-12-23 12:33:42 +0100442 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\&/g' -e 's/\\\\\"/\"/' -e 's/\\\\\";\$\$/\";/' -e 's/ */ /g'"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200443fi
444AC_SUBST(QUOTESED)
445
446
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200447dnl Link with -lsmack for Smack stuff; if not found
448AC_MSG_CHECKING(--disable-smack argument)
449AC_ARG_ENABLE(smack,
450 [ --disable-smack Do not check for Smack support.],
451 , enable_smack="yes")
452if test "$enable_smack" = "yes"; then
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200453 AC_MSG_RESULT(no)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200454 AC_CHECK_HEADER([linux/xattr.h], true, enable_smack="no")
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200455else
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200456 AC_MSG_RESULT(yes)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200457fi
458if test "$enable_smack" = "yes"; then
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200459 AC_CHECK_HEADER([attr/xattr.h], true, enable_smack="no")
460fi
461if test "$enable_smack" = "yes"; then
462 AC_MSG_CHECKING(for XATTR_NAME_SMACKEXEC in linux/xattr.h)
463 AC_EGREP_CPP(XATTR_NAME_SMACKEXEC, [#include <linux/xattr.h>],
464 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +0200465 AC_MSG_RESULT(no); enable_smack="no")
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200466fi
467if test "$enable_smack" = "yes"; then
468 AC_CHECK_LIB(attr, setxattr,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200469 [LIBS="$LIBS -lattr"
470 found_smack="yes"
471 AC_DEFINE(HAVE_SMACK)])
Bram Moolenaar588ebeb2008-05-07 17:09:24 +0000472fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000473
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200474dnl When smack was found don't search for SELinux
475if test "x$found_smack" = "x"; then
476 dnl Link with -lselinux for SELinux stuff; if not found
477 AC_MSG_CHECKING(--disable-selinux argument)
478 AC_ARG_ENABLE(selinux,
479 [ --disable-selinux Do not check for SELinux support.],
480 , enable_selinux="yes")
481 if test "$enable_selinux" = "yes"; then
482 AC_MSG_RESULT(no)
483 AC_CHECK_LIB(selinux, is_selinux_enabled,
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100484 [AC_CHECK_HEADER(selinux/selinux.h,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200485 [LIBS="$LIBS -lselinux"
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100486 AC_DEFINE(HAVE_SELINUX)])])
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200487 else
488 AC_MSG_RESULT(yes)
489 fi
490fi
491
Bram Moolenaar071d4272004-06-13 20:20:40 +0000492dnl Check user requested features.
493
494AC_MSG_CHECKING(--with-features argument)
Bram Moolenaareec29812016-07-26 21:27:36 +0200495AC_ARG_WITH(features, [ --with-features=TYPE tiny, small, normal, big or huge (default: huge)],
Bram Moolenaar071d4272004-06-13 20:20:40 +0000496 features="$withval"; AC_MSG_RESULT($features),
Bram Moolenaar23c4f712016-01-20 22:11:59 +0100497 features="huge"; AC_MSG_RESULT(Defaulting to huge))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000498
499dovimdiff=""
500dogvimdiff=""
501case "$features" in
502 tiny) AC_DEFINE(FEAT_TINY) ;;
503 small) AC_DEFINE(FEAT_SMALL) ;;
504 normal) AC_DEFINE(FEAT_NORMAL) dovimdiff="installvimdiff";
505 dogvimdiff="installgvimdiff" ;;
506 big) AC_DEFINE(FEAT_BIG) dovimdiff="installvimdiff";
507 dogvimdiff="installgvimdiff" ;;
508 huge) AC_DEFINE(FEAT_HUGE) dovimdiff="installvimdiff";
509 dogvimdiff="installgvimdiff" ;;
510 *) AC_MSG_RESULT([Sorry, $features is not supported]) ;;
511esac
512
513AC_SUBST(dovimdiff)
514AC_SUBST(dogvimdiff)
515
516AC_MSG_CHECKING(--with-compiledby argument)
517AC_ARG_WITH(compiledby, [ --with-compiledby=NAME name to show in :version message],
518 compiledby="$withval"; AC_MSG_RESULT($withval),
519 compiledby=""; AC_MSG_RESULT(no))
520AC_SUBST(compiledby)
521
522AC_MSG_CHECKING(--disable-xsmp argument)
523AC_ARG_ENABLE(xsmp,
524 [ --disable-xsmp Disable XSMP session management],
525 , enable_xsmp="yes")
526
527if test "$enable_xsmp" = "yes"; then
528 AC_MSG_RESULT(no)
529 AC_MSG_CHECKING(--disable-xsmp-interact argument)
530 AC_ARG_ENABLE(xsmp-interact,
531 [ --disable-xsmp-interact Disable XSMP interaction],
532 , enable_xsmp_interact="yes")
533 if test "$enable_xsmp_interact" = "yes"; then
534 AC_MSG_RESULT(no)
535 AC_DEFINE(USE_XSMP_INTERACT)
536 else
537 AC_MSG_RESULT(yes)
538 fi
539else
540 AC_MSG_RESULT(yes)
541fi
542
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200543dnl Check for Lua feature.
544AC_MSG_CHECKING(--enable-luainterp argument)
545AC_ARG_ENABLE(luainterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200546 [ --enable-luainterp[=OPTS] Include Lua interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200547 [enable_luainterp="no"])
548AC_MSG_RESULT($enable_luainterp)
549
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200550if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +0100551 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
552 AC_MSG_ERROR([cannot use Lua with tiny or small features])
553 fi
554
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200555 dnl -- find the lua executable
556 AC_SUBST(vi_cv_path_lua)
557
558 AC_MSG_CHECKING(--with-lua-prefix argument)
559 AC_ARG_WITH(lua_prefix,
560 [ --with-lua-prefix=PFX Prefix where Lua is installed.],
561 with_lua_prefix="$withval"; AC_MSG_RESULT($with_lua_prefix),
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200562 with_lua_prefix="";AC_MSG_RESULT(no))
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200563
564 if test "X$with_lua_prefix" != "X"; then
565 vi_cv_path_lua_pfx="$with_lua_prefix"
566 else
567 AC_MSG_CHECKING(LUA_PREFIX environment var)
568 if test "X$LUA_PREFIX" != "X"; then
569 AC_MSG_RESULT("$LUA_PREFIX")
570 vi_cv_path_lua_pfx="$LUA_PREFIX"
571 else
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200572 AC_MSG_RESULT([not set, default to /usr])
573 vi_cv_path_lua_pfx="/usr"
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200574 fi
575 fi
576
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200577 AC_MSG_CHECKING(--with-luajit)
578 AC_ARG_WITH(luajit,
579 [ --with-luajit Link with LuaJIT instead of Lua.],
580 [vi_cv_with_luajit="$withval"],
581 [vi_cv_with_luajit="no"])
582 AC_MSG_RESULT($vi_cv_with_luajit)
583
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200584 LUA_INC=
585 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200586 if test "x$vi_cv_with_luajit" != "xno"; then
587 dnl -- try to find LuaJIT executable
588 AC_PATH_PROG(vi_cv_path_luajit, luajit)
589 if test "X$vi_cv_path_luajit" != "X"; then
590 dnl -- find LuaJIT version
591 AC_CACHE_CHECK(LuaJIT version, vi_cv_version_luajit,
Bram Moolenaar49b10272013-11-21 12:17:51 +0100592 [ 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 +0200593 AC_CACHE_CHECK(Lua version of LuaJIT, vi_cv_version_lua_luajit,
594 [ vi_cv_version_lua_luajit=`${vi_cv_path_luajit} -e "print(_VERSION)" | sed 's/.* //'` ])
595 vi_cv_path_lua="$vi_cv_path_luajit"
596 vi_cv_version_lua="$vi_cv_version_lua_luajit"
597 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200598 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200599 dnl -- try to find Lua executable
600 AC_PATH_PROG(vi_cv_path_plain_lua, lua)
601 if test "X$vi_cv_path_plain_lua" != "X"; then
602 dnl -- find Lua version
603 AC_CACHE_CHECK(Lua version, vi_cv_version_plain_lua,
604 [ vi_cv_version_plain_lua=`${vi_cv_path_plain_lua} -e "print(_VERSION)" | sed 's/.* //'` ])
605 fi
606 vi_cv_path_lua="$vi_cv_path_plain_lua"
607 vi_cv_version_lua="$vi_cv_version_plain_lua"
608 fi
609 if test "x$vi_cv_with_luajit" != "xno" && test "X$vi_cv_version_luajit" != "X"; then
610 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 +0100611 if test -f "$vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200612 AC_MSG_RESULT(yes)
613 LUA_INC=/luajit-$vi_cv_version_luajit
614 fi
615 fi
616 if test "X$LUA_INC" = "X"; then
617 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)
Bram Moolenaar49222be2015-12-11 18:11:30 +0100618 if test -f "$vi_cv_path_lua_pfx/include/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200619 AC_MSG_RESULT(yes)
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200620 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200621 AC_MSG_RESULT(no)
622 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 +0100623 if test -f "$vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200624 AC_MSG_RESULT(yes)
625 LUA_INC=/lua$vi_cv_version_lua
626 else
627 AC_MSG_RESULT(no)
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200628
629 # Detect moonjit:
630 # https://groups.google.com/forum/#!topic/vim_use/O0vek60WuTk
631 lua_suf=/moonjit-2.3
632 inc_path="$vi_cv_path_lua_pfx/include"
Bram Moolenaarad4dc832020-04-20 16:21:53 +0200633 for dir in "$inc_path"/moonjit-[[0-9]]* ; do
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200634 if test -d "$dir" ; then
Bram Moolenaara79a8942020-12-17 20:50:25 +0100635 lua_suf=`basename "$dir"`
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200636 lua_suf="/$lua_suf"
637 break
638 fi
639 done
640 AC_MSG_CHECKING(if lua.h can be found in $inc_path$lua_suf)
641 if test -f "$inc_path$lua_suf/lua.h"; then
642 AC_MSG_RESULT(yes)
643 LUA_INC=$lua_suf
644 else
645 AC_MSG_RESULT(no)
646 vi_cv_path_lua_pfx=
647 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200648 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200649 fi
650 fi
651 fi
652
653 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200654 if test "x$vi_cv_with_luajit" != "xno"; then
655 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
656 if test "X$multiarch" != "X"; then
657 lib_multiarch="lib/${multiarch}"
658 else
659 lib_multiarch="lib"
660 fi
661 if test "X$vi_cv_version_lua" = "X"; then
662 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit"
663 else
664 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit-$vi_cv_version_lua"
665 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200666 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200667 if test "X$LUA_INC" != "X"; then
668 dnl Test alternate location using version
669 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua$vi_cv_version_lua"
670 else
671 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua"
672 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200673 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200674 if test "$enable_luainterp" = "dynamic"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200675 lua_ok="yes"
676 else
677 AC_MSG_CHECKING([if link with ${LUA_LIBS} is sane])
678 libs_save=$LIBS
679 LIBS="$LIBS $LUA_LIBS"
680 AC_TRY_LINK(,[ ],
681 AC_MSG_RESULT(yes); lua_ok="yes",
682 AC_MSG_RESULT(no); lua_ok="no"; LUA_LIBS="")
683 LIBS=$libs_save
684 fi
685 if test "x$lua_ok" = "xyes"; then
686 LUA_CFLAGS="-I${vi_cv_path_lua_pfx}/include${LUA_INC}"
687 LUA_SRC="if_lua.c"
688 LUA_OBJ="objects/if_lua.o"
689 LUA_PRO="if_lua.pro"
690 AC_DEFINE(FEAT_LUA)
691 fi
692 if test "$enable_luainterp" = "dynamic"; then
693 if test "x$vi_cv_with_luajit" != "xno"; then
694 luajit="jit"
695 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200696 if test -f "${vi_cv_path_lua_pfx}/bin/cyglua-${vi_cv_version_lua}.dll"; then
697 vi_cv_dll_name_lua="cyglua-${vi_cv_version_lua}.dll"
698 else
Bram Moolenaard0573012017-10-28 21:11:06 +0200699 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200700 ext="dylib"
701 indexes=""
702 else
703 ext="so"
704 indexes=".0 .1 .2 .3 .4 .5 .6 .7 .8 .9"
705 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
706 if test "X$multiarch" != "X"; then
707 lib_multiarch="lib/${multiarch}"
708 fi
Bram Moolenaar768baac2013-04-15 14:44:57 +0200709 fi
710 dnl Determine the sover for the current version, but fallback to
711 dnl liblua${vi_cv_version_lua}.so if no sover-versioned file is found.
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200712 AC_MSG_CHECKING(if liblua${luajit}*.${ext}* can be found in $vi_cv_path_lua_pfx)
Bram Moolenaar768baac2013-04-15 14:44:57 +0200713 for subdir in "${lib_multiarch}" lib64 lib; do
714 if test -z "$subdir"; then
715 continue
716 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200717 for sover in "${vi_cv_version_lua}.${ext}" "-${vi_cv_version_lua}.${ext}" \
718 ".${vi_cv_version_lua}.${ext}" ".${ext}.${vi_cv_version_lua}"; do
719 for i in $indexes ""; do
720 if test -f "${vi_cv_path_lua_pfx}/${subdir}/liblua${luajit}${sover}$i"; then
Bram Moolenaar768baac2013-04-15 14:44:57 +0200721 sover2="$i"
722 break 3
723 fi
724 done
Bram Moolenaar07e1da62013-02-06 19:49:43 +0100725 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200726 sover=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200727 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200728 if test "X$sover" = "X"; then
729 AC_MSG_RESULT(no)
730 lua_ok="no"
731 vi_cv_dll_name_lua="liblua${luajit}.${ext}"
732 else
733 AC_MSG_RESULT(yes)
734 lua_ok="yes"
735 vi_cv_dll_name_lua="liblua${luajit}${sover}$sover2"
736 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200737 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200738 AC_DEFINE(DYNAMIC_LUA)
739 LUA_LIBS=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200740 LUA_CFLAGS="-DDYNAMIC_LUA_DLL=\\\"${vi_cv_dll_name_lua}\\\" $LUA_CFLAGS"
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200741 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200742 if test "X$LUA_CFLAGS$LUA_LIBS" != "X" && \
Bram Moolenaard0573012017-10-28 21:11:06 +0200743 test "x$MACOS_X" = "xyes" && test "x$vi_cv_with_luajit" != "xno" && \
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200744 test "`(uname -m) 2>/dev/null`" = "x86_64"; then
745 dnl OSX/x64 requires these flags. See http://luajit.org/install.html
746 LUA_LIBS="-pagezero_size 10000 -image_base 100000000 $LUA_LIBS"
747 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200748 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200749 if test "$fail_if_missing" = "yes" -a "$lua_ok" != "yes"; then
Bram Moolenaarf788a062011-12-14 20:51:25 +0100750 AC_MSG_ERROR([could not configure lua])
751 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200752 AC_SUBST(LUA_SRC)
753 AC_SUBST(LUA_OBJ)
754 AC_SUBST(LUA_PRO)
755 AC_SUBST(LUA_LIBS)
756 AC_SUBST(LUA_CFLAGS)
757fi
758
759
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000760dnl Check for MzScheme feature.
761AC_MSG_CHECKING(--enable-mzschemeinterp argument)
762AC_ARG_ENABLE(mzschemeinterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200763 [ --enable-mzschemeinterp Include MzScheme interpreter.], ,
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000764 [enable_mzschemeinterp="no"])
765AC_MSG_RESULT($enable_mzschemeinterp)
766
767if test "$enable_mzschemeinterp" = "yes"; then
768 dnl -- find the mzscheme executable
769 AC_SUBST(vi_cv_path_mzscheme)
770
771 AC_MSG_CHECKING(--with-plthome argument)
772 AC_ARG_WITH(plthome,
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000773 [ --with-plthome=PLTHOME Use PLTHOME.],
774 with_plthome="$withval"; AC_MSG_RESULT($with_plthome),
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000775 with_plthome="";AC_MSG_RESULT("no"))
776
777 if test "X$with_plthome" != "X"; then
778 vi_cv_path_mzscheme_pfx="$with_plthome"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100779 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000780 else
781 AC_MSG_CHECKING(PLTHOME environment var)
782 if test "X$PLTHOME" != "X"; then
783 AC_MSG_RESULT("$PLTHOME")
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000784 vi_cv_path_mzscheme_pfx="$PLTHOME"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100785 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000786 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000787 AC_MSG_RESULT(not set)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000788 dnl -- try to find MzScheme executable
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000789 AC_PATH_PROG(vi_cv_path_mzscheme, mzscheme)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000790
791 dnl resolve symbolic link, the executable is often elsewhere and there
792 dnl are no links for the include files.
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000793 if test "X$vi_cv_path_mzscheme" != "X"; then
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000794 lsout=`ls -l $vi_cv_path_mzscheme`
795 if echo "$lsout" | grep -e '->' >/dev/null 2>/dev/null; then
796 vi_cv_path_mzscheme=`echo "$lsout" | sed 's/.*-> \(.*\)/\1/'`
797 fi
798 fi
799
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000800 if test "X$vi_cv_path_mzscheme" != "X"; then
801 dnl -- find where MzScheme thinks it was installed
802 AC_CACHE_CHECK(MzScheme install prefix,vi_cv_path_mzscheme_pfx,
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000803 dnl different versions of MzScheme differ in command line processing
804 dnl use universal approach
805 echo "(display (simplify-path \
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000806 (build-path (call-with-values \
807 (lambda () (split-path (find-system-path (quote exec-file)))) \
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000808 (lambda (base name must-be-dir?) base)) (quote up))))" > mzdirs.scm
809 dnl Remove a trailing slash
810 [ vi_cv_path_mzscheme_pfx=`${vi_cv_path_mzscheme} -r mzdirs.scm | \
811 sed -e 's+/$++'` ])
812 rm -f mzdirs.scm
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000813 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000814 fi
815 fi
816
817 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100818 AC_MSG_CHECKING(for racket include directory)
819 SCHEME_INC=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-include-dir))) (when (path? p) (display p)))'`
820 if test "X$SCHEME_INC" != "X"; then
821 AC_MSG_RESULT(${SCHEME_INC})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000822 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100823 AC_MSG_RESULT(not found)
824 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include)
825 if test -f "$vi_cv_path_mzscheme_pfx/include/scheme.h"; then
826 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000827 AC_MSG_RESULT(yes)
Bram Moolenaard7afed32007-05-06 13:26:41 +0000828 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000829 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100830 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt)
831 if test -f "$vi_cv_path_mzscheme_pfx/include/plt/scheme.h"; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000832 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100833 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000834 else
835 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100836 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket)
837 if test -f "$vi_cv_path_mzscheme_pfx/include/racket/scheme.h"; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100838 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100839 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100840 else
841 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100842 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/)
843 if test -f /usr/include/plt/scheme.h; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100844 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100845 SCHEME_INC=/usr/include/plt
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100846 else
847 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100848 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/racket/)
849 if test -f /usr/include/racket/scheme.h; then
850 AC_MSG_RESULT(yes)
851 SCHEME_INC=/usr/include/racket
852 else
853 AC_MSG_RESULT(no)
854 vi_cv_path_mzscheme_pfx=
855 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100856 fi
857 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000858 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000859 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000860 fi
861 fi
862
863 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100864
865 AC_MSG_CHECKING(for racket lib directory)
866 SCHEME_LIB=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-lib-dir))) (when (path? p) (display p)))'`
867 if test "X$SCHEME_LIB" != "X"; then
868 AC_MSG_RESULT(${SCHEME_LIB})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000869 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100870 AC_MSG_RESULT(not found)
871 fi
872
873 for path in "${vi_cv_path_mzscheme_pfx}/lib" "${SCHEME_LIB}"; do
874 if test "X$path" != "X"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200875 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100876 MZSCHEME_LIBS="-framework Racket"
877 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
878 elif test -f "${path}/libmzscheme3m.a"; then
879 MZSCHEME_LIBS="${path}/libmzscheme3m.a"
880 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
881 elif test -f "${path}/libracket3m.a"; then
882 MZSCHEME_LIBS="${path}/libracket3m.a"
Bram Moolenaar588d2412020-10-03 14:24:19 +0200883 if test -f "${path}/librktio.a"; then
884 MZSCHEME_LIBS="${MZSCHEME_LIBS} ${path}/librktio.a"
885 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100886 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
887 elif test -f "${path}/libracket.a"; then
888 MZSCHEME_LIBS="${path}/libracket.a ${path}/libmzgc.a"
889 elif test -f "${path}/libmzscheme.a"; then
890 MZSCHEME_LIBS="${path}/libmzscheme.a ${path}/libmzgc.a"
891 else
892 dnl Using shared objects
893 if test -f "${path}/libmzscheme3m.so"; then
894 MZSCHEME_LIBS="-L${path} -lmzscheme3m"
895 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
896 elif test -f "${path}/libracket3m.so"; then
897 MZSCHEME_LIBS="-L${path} -lracket3m"
898 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
899 elif test -f "${path}/libracket.so"; then
900 MZSCHEME_LIBS="-L${path} -lracket -lmzgc"
901 else
902 dnl try next until last
903 if test "$path" != "$SCHEME_LIB"; then
904 continue
905 fi
906 MZSCHEME_LIBS="-L${path} -lmzscheme -lmzgc"
907 fi
908 if test "$GCC" = yes; then
909 dnl Make Vim remember the path to the library. For when it's not in
910 dnl $LD_LIBRARY_PATH.
911 MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${path}"
912 elif test "`(uname) 2>/dev/null`" = SunOS &&
913 uname -r | grep '^5' >/dev/null; then
914 MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${path}"
915 fi
916 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000917 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100918 if test "X$MZSCHEME_LIBS" != "X"; then
919 break
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +0000920 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100921 done
922
923 AC_MSG_CHECKING([if racket requires -pthread])
924 if test "X$SCHEME_LIB" != "X" && $FGREP -e -pthread "$SCHEME_LIB/buildinfo" >/dev/null ; then
925 AC_MSG_RESULT(yes)
926 MZSCHEME_LIBS="${MZSCHEME_LIBS} -pthread"
927 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -pthread"
928 else
929 AC_MSG_RESULT(no)
930 fi
931
932 AC_MSG_CHECKING(for racket config directory)
933 SCHEME_CONFIGDIR=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-config-dir))) (when (path? p) (display p)))'`
934 if test "X$SCHEME_CONFIGDIR" != "X"; then
935 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DMZSCHEME_CONFIGDIR='\"${SCHEME_CONFIGDIR}\"'"
936 AC_MSG_RESULT(${SCHEME_CONFIGDIR})
937 else
938 AC_MSG_RESULT(not found)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000939 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100940
941 AC_MSG_CHECKING(for racket collects directory)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100942 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))))'`
943 if test "X$SCHEME_COLLECTS" = "X"; then
944 if test -d "$vi_cv_path_mzscheme_pfx/lib/plt/collects"; then
945 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/plt/
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100946 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100947 if test -d "$vi_cv_path_mzscheme_pfx/lib/racket/collects"; then
948 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/racket/
Bram Moolenaar75676462013-01-30 14:55:42 +0100949 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100950 if test -d "$vi_cv_path_mzscheme_pfx/share/racket/collects"; then
951 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/
952 else
953 if test -d "$vi_cv_path_mzscheme_pfx/collects"; then
954 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/
955 fi
Bram Moolenaar75676462013-01-30 14:55:42 +0100956 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100957 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100958 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000959 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100960 if test "X$SCHEME_COLLECTS" != "X" ; then
961 AC_MSG_RESULT(${SCHEME_COLLECTS})
962 else
963 AC_MSG_RESULT(not found)
964 fi
965
966 AC_MSG_CHECKING(for mzscheme_base.c)
967 if test -f "${SCHEME_COLLECTS}collects/scheme/base.ss" ; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000968 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +0100969 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
970 MZSCHEME_MOD="++lib scheme/base"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100971 else
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100972 if test -f "${SCHEME_COLLECTS}collects/scheme/base.rkt" ; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100973 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +0100974 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
975 MZSCHEME_MOD="++lib scheme/base"
976 else
977 if test -f "${SCHEME_COLLECTS}collects/racket/base.rkt" ; then
978 MZSCHEME_EXTRA="mzscheme_base.c"
979 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/raco ctool"
980 MZSCHEME_MOD=""
981 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100982 fi
983 fi
984 if test "X$MZSCHEME_EXTRA" != "X" ; then
985 dnl need to generate bytecode for MzScheme base
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000986 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE"
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100987 AC_MSG_RESULT(needed)
988 else
989 AC_MSG_RESULT(not needed)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000990 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100991
Bram Moolenaar9e902192013-07-17 18:58:11 +0200992 dnl On Ubuntu this fixes "undefined reference to symbol 'ffi_type_void'".
993 AC_CHECK_LIB(ffi, ffi_type_void, [MZSCHEME_LIBS="$MZSCHEME_LIBS -lffi"])
994
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000995 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -I${SCHEME_INC} \
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100996 -DMZSCHEME_COLLECTS='\"${SCHEME_COLLECTS}collects\"'"
Bram Moolenaar9e902192013-07-17 18:58:11 +0200997
998 dnl Test that we can compile a simple program with these CFLAGS and LIBS.
999 AC_MSG_CHECKING([if compile and link flags for MzScheme are sane])
1000 cflags_save=$CFLAGS
1001 libs_save=$LIBS
1002 CFLAGS="$CFLAGS $MZSCHEME_CFLAGS"
1003 LIBS="$LIBS $MZSCHEME_LIBS"
1004 AC_TRY_LINK(,[ ],
1005 AC_MSG_RESULT(yes); mzs_ok=yes,
1006 AC_MSG_RESULT(no: MZSCHEME DISABLED); mzs_ok=no)
1007 CFLAGS=$cflags_save
1008 LIBS=$libs_save
1009 if test $mzs_ok = yes; then
1010 MZSCHEME_SRC="if_mzsch.c"
1011 MZSCHEME_OBJ="objects/if_mzsch.o"
1012 MZSCHEME_PRO="if_mzsch.pro"
1013 AC_DEFINE(FEAT_MZSCHEME)
1014 else
1015 MZSCHEME_CFLAGS=
1016 MZSCHEME_LIBS=
1017 MZSCHEME_EXTRA=
1018 MZSCHEME_MZC=
1019 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001020 fi
1021 AC_SUBST(MZSCHEME_SRC)
1022 AC_SUBST(MZSCHEME_OBJ)
1023 AC_SUBST(MZSCHEME_PRO)
1024 AC_SUBST(MZSCHEME_LIBS)
1025 AC_SUBST(MZSCHEME_CFLAGS)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001026 AC_SUBST(MZSCHEME_EXTRA)
1027 AC_SUBST(MZSCHEME_MZC)
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001028fi
1029
1030
Bram Moolenaar071d4272004-06-13 20:20:40 +00001031AC_MSG_CHECKING(--enable-perlinterp argument)
1032AC_ARG_ENABLE(perlinterp,
Bram Moolenaare06c1882010-07-21 22:05:20 +02001033 [ --enable-perlinterp[=OPTS] Include Perl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001034 [enable_perlinterp="no"])
1035AC_MSG_RESULT($enable_perlinterp)
Bram Moolenaare06c1882010-07-21 22:05:20 +02001036if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01001037 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1038 AC_MSG_ERROR([cannot use Perl with tiny or small features])
1039 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001040 AC_SUBST(vi_cv_path_perl)
1041 AC_PATH_PROG(vi_cv_path_perl, perl)
1042 if test "X$vi_cv_path_perl" != "X"; then
1043 AC_MSG_CHECKING(Perl version)
1044 if $vi_cv_path_perl -e 'require 5.003_01' >/dev/null 2>/dev/null; then
1045 eval `$vi_cv_path_perl -V:usethreads`
Bram Moolenaare06c1882010-07-21 22:05:20 +02001046 eval `$vi_cv_path_perl -V:libperl`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001047 if test "X$usethreads" = "XUNKNOWN" -o "X$usethreads" = "Xundef"; then
1048 badthreads=no
1049 else
1050 if $vi_cv_path_perl -e 'require 5.6.0' >/dev/null 2>/dev/null; then
1051 eval `$vi_cv_path_perl -V:use5005threads`
1052 if test "X$use5005threads" = "XUNKNOWN" -o "X$use5005threads" = "Xundef"; then
1053 badthreads=no
1054 else
1055 badthreads=yes
1056 AC_MSG_RESULT(>>> Perl > 5.6 with 5.5 threads cannot be used <<<)
1057 fi
1058 else
1059 badthreads=yes
1060 AC_MSG_RESULT(>>> Perl 5.5 with threads cannot be used <<<)
1061 fi
1062 fi
1063 if test $badthreads = no; then
1064 AC_MSG_RESULT(OK)
1065 eval `$vi_cv_path_perl -V:shrpenv`
1066 if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04
1067 shrpenv=""
1068 fi
1069 vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlibexp}'`
1070 AC_SUBST(vi_cv_perllib)
Bram Moolenaard5f62b12014-08-17 17:05:44 +02001071 vi_cv_perl_extutils=unknown_perl_extutils_path
1072 for extutils_rel_path in ExtUtils vendor_perl/ExtUtils; do
1073 xsubpp_path="$vi_cv_perllib/$extutils_rel_path/xsubpp"
1074 if test -f "$xsubpp_path"; then
1075 vi_cv_perl_xsubpp="$xsubpp_path"
1076 fi
1077 done
1078 AC_SUBST(vi_cv_perl_xsubpp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001079 dnl Remove "-fno-something", it breaks using cproto.
Bram Moolenaar280a8682015-06-21 13:41:08 +02001080 dnl Remove "-fdebug-prefix-map", it isn't supported by clang.
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001081 dnl Remove "FORTIFY_SOURCE", it will be defined twice.
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001082 dnl remove -pipe and -Wxxx, it confuses cproto
Bram Moolenaar071d4272004-06-13 20:20:40 +00001083 perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001084 -e 'ccflags;perl_inc;print"\n"' | sed -e 's/-fno[[^ ]]*//' \
1085 -e 's/-fdebug-prefix-map[[^ ]]*//g' \
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001086 -e 's/-pipe //' \
1087 -e 's/-W[[^ ]]*//g' \
1088 -e 's/-D_FORTIFY_SOURCE=.//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001089 dnl Remove "-lc", it breaks on FreeBSD when using "-pthread".
1090 perllibs=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed -e 'ldopts' | \
1091 sed -e '/Warning/d' -e '/Note (probably harmless)/d' \
1092 -e 's/-bE:perl.exp//' -e 's/-lc //'`
1093 dnl Don't add perl lib to $LIBS: if it's not in LD_LIBRARY_PATH
1094 dnl a test in configure may fail because of that.
1095 perlldflags=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed \
1096 -e 'ccdlflags' | sed -e 's/-bE:perl.exp//'`
1097
1098 dnl check that compiling a simple program still works with the flags
1099 dnl added for Perl.
1100 AC_MSG_CHECKING([if compile and link flags for Perl are sane])
1101 cflags_save=$CFLAGS
1102 libs_save=$LIBS
1103 ldflags_save=$LDFLAGS
1104 CFLAGS="$CFLAGS $perlcppflags"
1105 LIBS="$LIBS $perllibs"
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001106 perlldflags=`echo "$perlldflags" | sed -e 's/^ *//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001107 LDFLAGS="$perlldflags $LDFLAGS"
1108 AC_TRY_LINK(,[ ],
1109 AC_MSG_RESULT(yes); perl_ok=yes,
1110 AC_MSG_RESULT(no: PERL DISABLED); perl_ok=no)
1111 CFLAGS=$cflags_save
1112 LIBS=$libs_save
1113 LDFLAGS=$ldflags_save
1114 if test $perl_ok = yes; then
1115 if test "X$perlcppflags" != "X"; then
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001116 PERL_CFLAGS=$perlcppflags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001117 fi
1118 if test "X$perlldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001119 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$perlldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001120 LDFLAGS="$perlldflags $LDFLAGS"
1121 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001122 fi
1123 PERL_LIBS=$perllibs
1124 PERL_SRC="auto/if_perl.c if_perlsfio.c"
1125 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o"
1126 PERL_PRO="if_perl.pro if_perlsfio.pro"
1127 AC_DEFINE(FEAT_PERL)
1128 fi
1129 fi
1130 else
1131 AC_MSG_RESULT(>>> too old; need Perl version 5.003_01 or later <<<)
1132 fi
1133 fi
1134
Bram Moolenaard0573012017-10-28 21:11:06 +02001135 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00001136 dnl Mac OS X 10.2 or later
Bram Moolenaar071d4272004-06-13 20:20:40 +00001137 dir=/System/Library/Perl
1138 darwindir=$dir/darwin
1139 if test -d $darwindir; then
1140 PERL=/usr/bin/perl
1141 else
1142 dnl Mac OS X 10.3
1143 dir=/System/Library/Perl/5.8.1
1144 darwindir=$dir/darwin-thread-multi-2level
1145 if test -d $darwindir; then
1146 PERL=/usr/bin/perl
1147 fi
1148 fi
1149 if test -n "$PERL"; then
1150 PERL_DIR="$dir"
1151 PERL_CFLAGS="-DFEAT_PERL -I$darwindir/CORE"
1152 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o $darwindir/auto/DynaLoader/DynaLoader.a"
1153 PERL_LIBS="-L$darwindir/CORE -lperl"
1154 fi
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001155 dnl Perl on Mac OS X 10.5 adds "-arch" flags but these should only
1156 dnl be included if requested by passing --with-mac-arch to
1157 dnl configure, so strip these flags first (if present)
1158 PERL_LIBS=`echo "$PERL_LIBS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
1159 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 +00001160 fi
Bram Moolenaare06c1882010-07-21 22:05:20 +02001161 if test "$enable_perlinterp" = "dynamic"; then
1162 if test "$perl_ok" = "yes" -a "X$libperl" != "X"; then
1163 AC_DEFINE(DYNAMIC_PERL)
1164 PERL_CFLAGS="-DDYNAMIC_PERL_DLL=\\\"$libperl\\\" $PERL_CFLAGS"
1165 fi
1166 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001167
1168 if test "$fail_if_missing" = "yes" -a "$perl_ok" != "yes"; then
1169 AC_MSG_ERROR([could not configure perl])
1170 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001171fi
1172AC_SUBST(shrpenv)
1173AC_SUBST(PERL_SRC)
1174AC_SUBST(PERL_OBJ)
1175AC_SUBST(PERL_PRO)
1176AC_SUBST(PERL_CFLAGS)
1177AC_SUBST(PERL_LIBS)
1178
1179AC_MSG_CHECKING(--enable-pythoninterp argument)
1180AC_ARG_ENABLE(pythoninterp,
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001181 [ --enable-pythoninterp[=OPTS] Include Python interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001182 [enable_pythoninterp="no"])
1183AC_MSG_RESULT($enable_pythoninterp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001184if test "$enable_pythoninterp" = "yes" -o "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001185 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1186 AC_MSG_ERROR([cannot use Python with tiny or small features])
1187 fi
1188
Bram Moolenaar071d4272004-06-13 20:20:40 +00001189 dnl -- find the python executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001190 AC_MSG_CHECKING(--with-python-command argument)
1191 AC_SUBST(vi_cv_path_python)
1192 AC_ARG_WITH(python-command, [ --with-python-command=NAME name of the Python 2 command (default: python2 or python)],
1193 vi_cv_path_python="$withval"; AC_MSG_RESULT($vi_cv_path_python),
1194 AC_MSG_RESULT(no))
1195
1196 if test "X$vi_cv_path_python" = "X"; then
1197 AC_PATH_PROGS(vi_cv_path_python, python2 python)
1198 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001199 if test "X$vi_cv_path_python" != "X"; then
1200
1201 dnl -- get its version number
1202 AC_CACHE_CHECK(Python version,vi_cv_var_python_version,
1203 [[vi_cv_var_python_version=`
1204 ${vi_cv_path_python} -c 'import sys; print sys.version[:3]'`
1205 ]])
1206
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001207 dnl -- it must be at least version 2.3
1208 AC_MSG_CHECKING(Python is 2.3 or better)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001209 if ${vi_cv_path_python} -c \
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001210 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001211 then
1212 AC_MSG_RESULT(yep)
1213
1214 dnl -- find where python thinks it was installed
1215 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python_pfx,
1216 [ vi_cv_path_python_pfx=`
1217 ${vi_cv_path_python} -c \
1218 "import sys; print sys.prefix"` ])
1219
1220 dnl -- and where it thinks it runs
1221 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python_epfx,
1222 [ vi_cv_path_python_epfx=`
1223 ${vi_cv_path_python} -c \
1224 "import sys; print sys.exec_prefix"` ])
1225
1226 dnl -- python's internal library path
1227
1228 AC_CACHE_VAL(vi_cv_path_pythonpath,
1229 [ vi_cv_path_pythonpath=`
1230 unset PYTHONPATH;
1231 ${vi_cv_path_python} -c \
1232 "import sys, string; print string.join(sys.path,':')"` ])
1233
1234 dnl -- where the Python implementation library archives are
1235
1236 AC_ARG_WITH(python-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001237 [ --with-python-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001238 [ vi_cv_path_python_conf="${withval}"; have_python_config_dir=1 ] )
Bram Moolenaar071d4272004-06-13 20:20:40 +00001239
1240 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python_conf,
1241 [
1242 vi_cv_path_python_conf=
Bram Moolenaarac499e32013-06-02 19:14:17 +02001243 d=`${vi_cv_path_python} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBPL')"`
1244 if test -d "$d" && test -f "$d/config.c"; then
1245 vi_cv_path_python_conf="$d"
1246 else
1247 for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
1248 for subdir in lib64 lib share; do
1249 d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
1250 if test -d "$d" && test -f "$d/config.c"; then
1251 vi_cv_path_python_conf="$d"
1252 fi
1253 done
Bram Moolenaar071d4272004-06-13 20:20:40 +00001254 done
Bram Moolenaarac499e32013-06-02 19:14:17 +02001255 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001256 ])
1257
1258 PYTHON_CONFDIR="${vi_cv_path_python_conf}"
1259
1260 if test "X$PYTHON_CONFDIR" = "X"; then
1261 AC_MSG_RESULT([can't find it!])
1262 else
1263
1264 dnl -- we need to examine Python's config/Makefile too
1265 dnl see what the interpreter is built from
1266 AC_CACHE_VAL(vi_cv_path_python_plibs,
1267 [
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001268 pwd=`pwd`
1269 tmp_mkf="$pwd/config-PyMake$$"
1270 cat -- "${PYTHON_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001271__:
Bram Moolenaar218116c2010-05-20 21:46:00 +02001272 @echo "python_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001273 @echo "python_LIBS='$(LIBS)'"
1274 @echo "python_SYSLIBS='$(SYSLIBS)'"
1275 @echo "python_LINKFORSHARED='$(LINKFORSHARED)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001276 @echo "python_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001277 @echo "python_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001278 @echo "python_PYTHONFRAMEWORK='$(PYTHONFRAMEWORK)'"
1279 @echo "python_PYTHONFRAMEWORKPREFIX='$(PYTHONFRAMEWORKPREFIX)'"
1280 @echo "python_PYTHONFRAMEWORKINSTALLDIR='$(PYTHONFRAMEWORKINSTALLDIR)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001281eof
1282 dnl -- delete the lines from make about Entering/Leaving directory
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001283 eval "`cd ${PYTHON_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1284 rm -f -- "${tmp_mkf}"
Bram Moolenaard0573012017-10-28 21:11:06 +02001285 if test "x$MACOS_X" = "xyes" && test -n "${python_PYTHONFRAMEWORK}" && ${vi_cv_path_python} -c \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001286 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then
1287 vi_cv_path_python_plibs="-framework Python"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001288 if test "x${vi_cv_path_python}" != "x/usr/bin/python" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
1289 vi_cv_path_python_plibs="-F${python_PYTHONFRAMEWORKPREFIX} -framework Python"
1290 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001291 else
Bram Moolenaar9ce42132018-04-11 22:19:36 +02001292 vi_cv_path_python_plibs="-L${PYTHON_CONFDIR} -lpython${vi_cv_var_python_version}"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001293 dnl -- Check if the path contained in python_LINKFORSHARED is
1294 dnl usable for vim build. If not, make and try other
1295 dnl candidates.
Bram Moolenaara161e262015-03-24 15:14:27 +01001296 if test -n "${python_LINKFORSHARED}" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
Bram Moolenaar6c927552015-03-24 12:21:33 +01001297 python_link_symbol=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]].*/\1/'`
1298 python_link_path=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]][[ \t]]*\(.*\)/\2/'`
1299 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1300 dnl -- The path looks relative. Guess the absolute one using
1301 dnl the prefix and try that.
1302 python_link_path="${python_PYTHONFRAMEWORKPREFIX}/${python_link_path}"
1303 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1304 dnl -- A last resort.
1305 python_link_path="${python_PYTHONFRAMEWORKINSTALLDIR}/Versions/${vi_cv_var_python_version}/${python_PYTHONFRAMEWORK}"
1306 dnl -- No check is done. The last word is left to the
1307 dnl "sanity" test on link flags that follows shortly.
1308 fi
1309 python_LINKFORSHARED="${python_link_symbol} ${python_link_path}"
1310 fi
1311 fi
Bram Moolenaar218116c2010-05-20 21:46:00 +02001312 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 +00001313 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1314 vi_cv_path_python_plibs=`echo $vi_cv_path_python_plibs | sed s/-ltermcap//`
1315 fi
1316 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001317 AC_CACHE_CHECK(Python's dll name,vi_cv_dll_name_python,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001318 [
1319 if test "X$python_DLLLIBRARY" != "X"; then
1320 vi_cv_dll_name_python="$python_DLLLIBRARY"
1321 else
1322 vi_cv_dll_name_python="$python_INSTSONAME"
1323 fi
1324 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00001325
1326 PYTHON_LIBS="${vi_cv_path_python_plibs}"
1327 if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001328 PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001329 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001330 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 +00001331 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001332 if test "X$have_python_config_dir" = "X1" -a "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001333 dnl Define PYTHON_HOME if --with-python-config-dir was used
1334 PYTHON_CFLAGS="${PYTHON_CFLAGS} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'"
1335
1336 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001337 PYTHON_SRC="if_python.c"
Bram Moolenaar9bdb9a02012-07-25 16:32:08 +02001338 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001339
1340 dnl On FreeBSD linking with "-pthread" is required to use threads.
1341 dnl _THREAD_SAFE must be used for compiling then.
1342 dnl The "-pthread" is added to $LIBS, so that the following check for
1343 dnl sigaltstack() will look in libc_r (it's there in libc!).
1344 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1345 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1346 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1347 AC_MSG_CHECKING([if -pthread should be used])
1348 threadsafe_flag=
1349 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001350 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00001351 if test "`(uname) 2>/dev/null`" != Darwin; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001352 test "$GCC" = yes && threadsafe_flag="-pthread"
1353 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1354 threadsafe_flag="-D_THREAD_SAFE"
1355 thread_lib="-pthread"
1356 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001357 if test "`(uname) 2>/dev/null`" = SunOS; then
1358 threadsafe_flag="-pthreads"
1359 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001360 fi
1361 libs_save_old=$LIBS
1362 if test -n "$threadsafe_flag"; then
1363 cflags_save=$CFLAGS
1364 CFLAGS="$CFLAGS $threadsafe_flag"
1365 LIBS="$LIBS $thread_lib"
1366 AC_TRY_LINK(,[ ],
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001367 AC_MSG_RESULT(yes); PYTHON_CFLAGS="$PYTHON_CFLAGS $threadsafe_flag",
Bram Moolenaar071d4272004-06-13 20:20:40 +00001368 AC_MSG_RESULT(no); LIBS=$libs_save_old
1369 )
1370 CFLAGS=$cflags_save
1371 else
1372 AC_MSG_RESULT(no)
1373 fi
1374
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001375 dnl Check that compiling a simple program still works with the flags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001376 dnl added for Python.
1377 AC_MSG_CHECKING([if compile and link flags for Python are sane])
1378 cflags_save=$CFLAGS
1379 libs_save=$LIBS
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001380 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001381 LIBS="$LIBS $PYTHON_LIBS"
1382 AC_TRY_LINK(,[ ],
1383 AC_MSG_RESULT(yes); python_ok=yes,
1384 AC_MSG_RESULT(no: PYTHON DISABLED); python_ok=no)
1385 CFLAGS=$cflags_save
1386 LIBS=$libs_save
1387 if test $python_ok = yes; then
1388 AC_DEFINE(FEAT_PYTHON)
1389 else
1390 LIBS=$libs_save_old
1391 PYTHON_SRC=
1392 PYTHON_OBJ=
1393 PYTHON_LIBS=
1394 PYTHON_CFLAGS=
1395 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001396 fi
1397 else
1398 AC_MSG_RESULT(too old)
1399 fi
1400 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001401
1402 if test "$fail_if_missing" = "yes" -a "$python_ok" != "yes"; then
1403 AC_MSG_ERROR([could not configure python])
1404 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001405fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001406
Bram Moolenaar071d4272004-06-13 20:20:40 +00001407AC_SUBST(PYTHON_LIBS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001408AC_SUBST(PYTHON_CFLAGS)
1409AC_SUBST(PYTHON_SRC)
1410AC_SUBST(PYTHON_OBJ)
1411
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001412
1413AC_MSG_CHECKING(--enable-python3interp argument)
1414AC_ARG_ENABLE(python3interp,
Bram Moolenaar8008b632017-07-18 21:33:20 +02001415 [ --enable-python3interp[=OPTS] Include Python3 interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001416 [enable_python3interp="no"])
1417AC_MSG_RESULT($enable_python3interp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001418if test "$enable_python3interp" = "yes" -o "$enable_python3interp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001419 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1420 AC_MSG_ERROR([cannot use Python with tiny or small features])
1421 fi
1422
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001423 dnl -- find the python3 executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001424 AC_MSG_CHECKING(--with-python3-command argument)
1425 AC_SUBST(vi_cv_path_python3)
1426 AC_ARG_WITH(python3-command, [ --with-python3-command=NAME name of the Python 3 command (default: python3 or python)],
1427 vi_cv_path_python3="$withval"; AC_MSG_RESULT($vi_cv_path_python3),
1428 AC_MSG_RESULT(no))
1429
1430 if test "X$vi_cv_path_python3" = "X"; then
1431 AC_PATH_PROGS(vi_cv_path_python3, python3 python)
1432 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001433 if test "X$vi_cv_path_python3" != "X"; then
1434
1435 dnl -- get its version number
1436 AC_CACHE_CHECK(Python version,vi_cv_var_python3_version,
1437 [[vi_cv_var_python3_version=`
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001438 ${vi_cv_path_python3} -c 'import sys; print(sys.version[:3])'`
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001439 ]])
1440
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001441 dnl -- it must be at least version 3
1442 AC_MSG_CHECKING(Python is 3.0 or better)
1443 if ${vi_cv_path_python3} -c \
1444 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.0)"
1445 then
1446 AC_MSG_RESULT(yep)
Bram Moolenaar456f2bb2011-06-12 21:37:13 +02001447
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001448 dnl -- get abiflags for python 3.2 or higher (PEP 3149)
1449 AC_CACHE_CHECK(Python's abiflags,vi_cv_var_python3_abiflags,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001450 [
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001451 vi_cv_var_python3_abiflags=
1452 if ${vi_cv_path_python3} -c \
1453 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)"
1454 then
1455 vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \
1456 "import sys; print(sys.abiflags)"`
1457 fi ])
1458
1459 dnl -- find where python3 thinks it was installed
1460 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx,
1461 [ vi_cv_path_python3_pfx=`
1462 ${vi_cv_path_python3} -c \
1463 "import sys; print(sys.prefix)"` ])
1464
1465 dnl -- and where it thinks it runs
1466 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx,
1467 [ vi_cv_path_python3_epfx=`
1468 ${vi_cv_path_python3} -c \
1469 "import sys; print(sys.exec_prefix)"` ])
1470
1471 dnl -- python3's internal library path
1472
1473 AC_CACHE_VAL(vi_cv_path_python3path,
1474 [ vi_cv_path_python3path=`
1475 unset PYTHONPATH;
1476 ${vi_cv_path_python3} -c \
1477 "import sys, string; print(':'.join(sys.path))"` ])
1478
1479 dnl -- where the Python implementation library archives are
1480
1481 AC_ARG_WITH(python3-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001482 [ --with-python3-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001483 [ vi_cv_path_python3_conf="${withval}"; have_python3_config_dir=1 ] )
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001484
1485 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf,
1486 [
1487 vi_cv_path_python3_conf=
Bram Moolenaarfee496d2013-07-12 20:07:24 +02001488 config_dir="config-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001489 d=`${vi_cv_path_python3} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBPL'))"`
1490 if test -d "$d" && test -f "$d/config.c"; then
1491 vi_cv_path_python3_conf="$d"
1492 else
1493 for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do
1494 for subdir in lib64 lib share; do
1495 d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}"
1496 if test -d "$d" && test -f "$d/config.c"; then
1497 vi_cv_path_python3_conf="$d"
1498 fi
1499 done
1500 done
1501 fi
1502 ])
1503
1504 PYTHON3_CONFDIR="${vi_cv_path_python3_conf}"
1505
1506 if test "X$PYTHON3_CONFDIR" = "X"; then
1507 AC_MSG_RESULT([can't find it!])
1508 else
1509
1510 dnl -- we need to examine Python's config/Makefile too
1511 dnl see what the interpreter is built from
1512 AC_CACHE_VAL(vi_cv_path_python3_plibs,
1513 [
1514 pwd=`pwd`
1515 tmp_mkf="$pwd/config-PyMake$$"
1516 cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001517__:
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001518 @echo "python3_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001519 @echo "python3_LIBS='$(LIBS)'"
1520 @echo "python3_SYSLIBS='$(SYSLIBS)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001521 @echo "python3_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001522 @echo "python3_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001523eof
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001524 dnl -- delete the lines from make about Entering/Leaving directory
1525 eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1526 rm -f -- "${tmp_mkf}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001527 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 +02001528 vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}"
1529 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1530 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//`
1531 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//`
1532 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001533 AC_CACHE_CHECK(Python3's dll name,vi_cv_dll_name_python3,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001534 [
1535 if test "X$python3_DLLLIBRARY" != "X"; then
1536 vi_cv_dll_name_python3="$python3_DLLLIBRARY"
1537 else
1538 vi_cv_dll_name_python3="$python3_INSTSONAME"
1539 fi
1540 ])
1541
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001542 PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
1543 if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001544 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 +02001545 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001546 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 +02001547 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001548 if test "X$have_python3_config_dir" = "X1" -a "$enable_python3interp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001549 dnl Define PYTHON3_HOME if --with-python-config-dir was used
1550 PYTHON3_CFLAGS="${PYTHON3_CFLAGS} -DPYTHON3_HOME='L\"${vi_cv_path_python3_pfx}\"'"
1551 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001552 PYTHON3_SRC="if_python3.c"
1553 PYTHON3_OBJ="objects/if_python3.o"
1554
1555 dnl On FreeBSD linking with "-pthread" is required to use threads.
1556 dnl _THREAD_SAFE must be used for compiling then.
1557 dnl The "-pthread" is added to $LIBS, so that the following check for
1558 dnl sigaltstack() will look in libc_r (it's there in libc!).
1559 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1560 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1561 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1562 AC_MSG_CHECKING([if -pthread should be used])
1563 threadsafe_flag=
1564 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001565 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001566 if test "`(uname) 2>/dev/null`" != Darwin; then
1567 test "$GCC" = yes && threadsafe_flag="-pthread"
1568 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1569 threadsafe_flag="-D_THREAD_SAFE"
1570 thread_lib="-pthread"
1571 fi
1572 if test "`(uname) 2>/dev/null`" = SunOS; then
1573 threadsafe_flag="-pthreads"
1574 fi
1575 fi
1576 libs_save_old=$LIBS
1577 if test -n "$threadsafe_flag"; then
1578 cflags_save=$CFLAGS
1579 CFLAGS="$CFLAGS $threadsafe_flag"
1580 LIBS="$LIBS $thread_lib"
1581 AC_TRY_LINK(,[ ],
1582 AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag",
1583 AC_MSG_RESULT(no); LIBS=$libs_save_old
1584 )
1585 CFLAGS=$cflags_save
1586 else
1587 AC_MSG_RESULT(no)
1588 fi
1589
1590 dnl check that compiling a simple program still works with the flags
1591 dnl added for Python.
1592 AC_MSG_CHECKING([if compile and link flags for Python 3 are sane])
1593 cflags_save=$CFLAGS
1594 libs_save=$LIBS
1595 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1596 LIBS="$LIBS $PYTHON3_LIBS"
1597 AC_TRY_LINK(,[ ],
1598 AC_MSG_RESULT(yes); python3_ok=yes,
1599 AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no)
1600 CFLAGS=$cflags_save
1601 LIBS=$libs_save
1602 if test "$python3_ok" = yes; then
1603 AC_DEFINE(FEAT_PYTHON3)
1604 else
1605 LIBS=$libs_save_old
1606 PYTHON3_SRC=
1607 PYTHON3_OBJ=
1608 PYTHON3_LIBS=
1609 PYTHON3_CFLAGS=
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001610 fi
1611 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001612 else
1613 AC_MSG_RESULT(too old)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001614 fi
1615 fi
Bram Moolenaar1612b1a2013-06-14 21:22:39 +02001616 if test "$fail_if_missing" = "yes" -a "$python3_ok" != "yes"; then
1617 AC_MSG_ERROR([could not configure python3])
1618 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001619fi
1620
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001621AC_SUBST(PYTHON3_LIBS)
1622AC_SUBST(PYTHON3_CFLAGS)
1623AC_SUBST(PYTHON3_SRC)
1624AC_SUBST(PYTHON3_OBJ)
1625
1626dnl if python2.x and python3.x are enabled one can only link in code
1627dnl with dlopen(), dlsym(), dlclose()
1628if test "$python_ok" = yes && test "$python3_ok" = yes; then
1629 AC_DEFINE(DYNAMIC_PYTHON)
1630 AC_DEFINE(DYNAMIC_PYTHON3)
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001631 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001632 cflags_save=$CFLAGS
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001633 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001634 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001635 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001636 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001637 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001638 #include <dlfcn.h>
1639 /* If this program fails, then RTLD_GLOBAL is needed.
1640 * RTLD_GLOBAL will be used and then it is not possible to
1641 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001642 * Only the first python version used will be switched on.
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001643 */
1644
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001645 int no_rtl_global_needed_for(char *python_instsoname, char *prefix)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001646 {
1647 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001648 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001649 if (pylib != 0)
1650 {
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001651 void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome");
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001652 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1653 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1654 void (*final)(void) = dlsym(pylib, "Py_Finalize");
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001655 (*pfx)(prefix);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001656 (*init)();
1657 needed = (*simple)("import termios") == -1;
1658 (*final)();
1659 dlclose(pylib);
1660 }
1661 return !needed;
1662 }
1663
1664 int main(int argc, char** argv)
1665 {
1666 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001667 if (no_rtl_global_needed_for("${vi_cv_dll_name_python}", "${vi_cv_path_python_pfx}"))
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001668 not_needed = 1;
1669 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001670 }])],
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001671 [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001672
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001673 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001674 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001675
1676 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python3)
1677 cflags_save=$CFLAGS
1678 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001679 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001680 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001681 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001682 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001683 #include <dlfcn.h>
1684 #include <wchar.h>
1685 /* If this program fails, then RTLD_GLOBAL is needed.
1686 * RTLD_GLOBAL will be used and then it is not possible to
1687 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001688 * Only the first python version used will be switched on.
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001689 */
1690
1691 int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix)
1692 {
1693 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001694 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001695 if (pylib != 0)
1696 {
1697 void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome");
1698 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1699 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1700 void (*final)(void) = dlsym(pylib, "Py_Finalize");
1701 (*pfx)(prefix);
1702 (*init)();
1703 needed = (*simple)("import termios") == -1;
1704 (*final)();
1705 dlclose(pylib);
1706 }
1707 return !needed;
1708 }
1709
1710 int main(int argc, char** argv)
1711 {
1712 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001713 if (no_rtl_global_needed_for("${vi_cv_dll_name_python3}", L"${vi_cv_path_python3_pfx}"))
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001714 not_needed = 1;
1715 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001716 }])],
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001717 [AC_MSG_RESULT(yes);AC_DEFINE(PY3_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
1718
1719 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001720 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001721
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001722 PYTHON_SRC="if_python.c"
1723 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001724 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001725 PYTHON_LIBS=
1726 PYTHON3_SRC="if_python3.c"
1727 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001728 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001729 PYTHON3_LIBS=
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001730elif test "$python_ok" = yes && test "$enable_pythoninterp" = "dynamic"; then
1731 AC_DEFINE(DYNAMIC_PYTHON)
1732 PYTHON_SRC="if_python.c"
1733 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001734 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001735 PYTHON_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001736elif test "$python_ok" = yes; then
1737 dnl Check that adding -fPIE works. It may be needed when using a static
1738 dnl Python library.
1739 AC_MSG_CHECKING([if -fPIE can be added for Python])
1740 cflags_save=$CFLAGS
1741 libs_save=$LIBS
1742 CFLAGS="$CFLAGS $PYTHON_CFLAGS -fPIE"
1743 LIBS="$LIBS $PYTHON_LIBS"
1744 AC_TRY_LINK(,[ ],
1745 AC_MSG_RESULT(yes); fpie_ok=yes,
1746 AC_MSG_RESULT(no); fpie_ok=no)
1747 CFLAGS=$cflags_save
1748 LIBS=$libs_save
1749 if test $fpie_ok = yes; then
1750 PYTHON_CFLAGS="$PYTHON_CFLAGS -fPIE"
1751 fi
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001752elif test "$python3_ok" = yes && test "$enable_python3interp" = "dynamic"; then
1753 AC_DEFINE(DYNAMIC_PYTHON3)
1754 PYTHON3_SRC="if_python3.c"
1755 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001756 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001757 PYTHON3_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001758elif test "$python3_ok" = yes; then
1759 dnl Check that adding -fPIE works. It may be needed when using a static
1760 dnl Python library.
1761 AC_MSG_CHECKING([if -fPIE can be added for Python3])
1762 cflags_save=$CFLAGS
1763 libs_save=$LIBS
1764 CFLAGS="$CFLAGS $PYTHON3_CFLAGS -fPIE"
1765 LIBS="$LIBS $PYTHON3_LIBS"
1766 AC_TRY_LINK(,[ ],
1767 AC_MSG_RESULT(yes); fpie_ok=yes,
1768 AC_MSG_RESULT(no); fpie_ok=no)
1769 CFLAGS=$cflags_save
1770 LIBS=$libs_save
1771 if test $fpie_ok = yes; then
1772 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -fPIE"
1773 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001774fi
1775
Bram Moolenaar071d4272004-06-13 20:20:40 +00001776AC_MSG_CHECKING(--enable-tclinterp argument)
1777AC_ARG_ENABLE(tclinterp,
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001778 [ --enable-tclinterp[=OPTS] Include Tcl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001779 [enable_tclinterp="no"])
1780AC_MSG_RESULT($enable_tclinterp)
1781
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001782if test "$enable_tclinterp" = "yes" -o "$enable_tclinterp" = "dynamic"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001783
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001784 dnl on FreeBSD tclsh is a silly script, look for tclsh8.[5420]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001785 AC_MSG_CHECKING(--with-tclsh argument)
1786 AC_ARG_WITH(tclsh, [ --with-tclsh=PATH which tclsh to use (default: tclsh8.0)],
1787 tclsh_name="$withval"; AC_MSG_RESULT($tclsh_name),
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001788 tclsh_name="tclsh8.5"; AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00001789 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1790 AC_SUBST(vi_cv_path_tcl)
1791
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001792 dnl when no specific version specified, also try 8.4, 8.2 and 8.0
1793 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.5"; then
1794 tclsh_name="tclsh8.4"
1795 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1796 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001797 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.4"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001798 tclsh_name="tclsh8.2"
1799 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1800 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001801 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.2"; then
1802 tclsh_name="tclsh8.0"
1803 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1804 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001805 dnl still didn't find it, try without version number
1806 if test "X$vi_cv_path_tcl" = "X"; then
1807 tclsh_name="tclsh"
1808 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1809 fi
1810 if test "X$vi_cv_path_tcl" != "X"; then
1811 AC_MSG_CHECKING(Tcl version)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001812 if echo 'exit [[expr [info tclversion] < 8.0]]' | "$vi_cv_path_tcl" - ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001813 tclver=`echo 'puts [[info tclversion]]' | $vi_cv_path_tcl -`
1814 AC_MSG_RESULT($tclver - OK);
1815 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 +01001816 tcldll=`echo 'puts libtcl[[info tclversion]][[info sharedlibextension]]' | $vi_cv_path_tcl -`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001817
1818 AC_MSG_CHECKING(for location of Tcl include)
Bram Moolenaard0573012017-10-28 21:11:06 +02001819 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001820 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 +00001821 else
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001822 dnl For all macOS, use the value from TCL in case use of, say, homebrew
Bram Moolenaar071d4272004-06-13 20:20:40 +00001823 dnl For Mac OS X 10.3, use the OS-provided framework location
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001824 dnl For Mac OS X 10.14, the OS-provided framework location doesn't contain the headers, so also check the Xcode SDK
1825 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 +00001826 fi
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001827 TCL_INC=
Bram Moolenaar071d4272004-06-13 20:20:40 +00001828 for try in $tclinc; do
1829 if test -f "$try/tcl.h"; then
1830 AC_MSG_RESULT($try/tcl.h)
1831 TCL_INC=$try
1832 break
1833 fi
1834 done
1835 if test -z "$TCL_INC"; then
1836 AC_MSG_RESULT(<not found>)
1837 SKIP_TCL=YES
1838 fi
1839 if test -z "$SKIP_TCL"; then
1840 AC_MSG_CHECKING(for location of tclConfig.sh script)
Bram Moolenaard0573012017-10-28 21:11:06 +02001841 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001842 tclcnf=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001843 tclcnf="$tclcnf `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001844 else
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001845 dnl For all macOS, use the value from TCL in case use of, say, homebrew
Bram Moolenaar071d4272004-06-13 20:20:40 +00001846 dnl For Mac OS X 10.3, use the OS-provided framework location
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001847 dnl For Mac OS X 10.14, the OS-provided framework location doesn't contain the headers, so also check the Xcode SDK
1848 tclcnf=`echo $tclinc | sed s/include/lib/g`
1849 tclcnf="$tclcnf /System/Library/Frameworks/Tcl.framework `xcrun --show-sdk-path`/System/Library/Frameworks/Tcl.framework"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001850 fi
1851 for try in $tclcnf; do
Bram Moolenaar49222be2015-12-11 18:11:30 +01001852 if test -f "$try/tclConfig.sh"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001853 AC_MSG_RESULT($try/tclConfig.sh)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001854 . "$try/tclConfig.sh"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001855 dnl use eval, because tcl 8.2 includes ${TCL_DBGX}
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001856 if test "$enable_tclinterp" = "dynamic"; then
1857 TCL_LIBS=`eval echo "$TCL_STUB_LIB_SPEC $TCL_LIBS"`
1858 else
1859 TCL_LIBS=`eval echo "$TCL_LIB_SPEC $TCL_LIBS"`
1860 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001861 dnl Use $TCL_DEFS for -D_THREAD_SAFE et al. But only use the
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001862 dnl "-D_ABC" items. Watch out for -DFOO=long\ long.
Bram Moolenaar4394bff2008-07-24 11:21:31 +00001863 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 +00001864 break
1865 fi
1866 done
1867 if test -z "$TCL_LIBS"; then
1868 AC_MSG_RESULT(<not found>)
1869 AC_MSG_CHECKING(for Tcl library by myself)
1870 tcllib=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001871 tcllib="$tcllib `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001872 for ext in .so .a ; do
1873 for ver in "" $tclver ; do
1874 for try in $tcllib ; do
1875 trylib=tcl$ver$ext
Bram Moolenaar49222be2015-12-11 18:11:30 +01001876 if test -f "$try/lib$trylib" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001877 AC_MSG_RESULT($try/lib$trylib)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001878 TCL_LIBS="-L\"$try\" -ltcl$ver -ldl -lm"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001879 if test "`(uname) 2>/dev/null`" = SunOS &&
1880 uname -r | grep '^5' >/dev/null; then
1881 TCL_LIBS="$TCL_LIBS -R $try"
1882 fi
1883 break 3
1884 fi
1885 done
1886 done
1887 done
1888 if test -z "$TCL_LIBS"; then
1889 AC_MSG_RESULT(<not found>)
1890 SKIP_TCL=YES
1891 fi
1892 fi
1893 if test -z "$SKIP_TCL"; then
1894 AC_DEFINE(FEAT_TCL)
1895 TCL_SRC=if_tcl.c
1896 TCL_OBJ=objects/if_tcl.o
1897 TCL_PRO=if_tcl.pro
1898 TCL_CFLAGS="-I$TCL_INC $TCL_DEFS"
1899 fi
1900 fi
1901 else
1902 AC_MSG_RESULT(too old; need Tcl version 8.0 or later)
1903 fi
1904 fi
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001905 if test "$enable_tclinterp" = "dynamic"; then
1906 if test "X$TCL_SRC" != "X" -a "X$tcldll" != "X"; then
1907 AC_DEFINE(DYNAMIC_TCL)
1908 TCL_CFLAGS="-DDYNAMIC_TCL_DLL=\\\"$tcldll\\\" -DDYNAMIC_TCL_VER=\\\"$tclver\\\" $TCL_CFLAGS"
1909 fi
1910 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001911 if test "$fail_if_missing" = "yes" -a -z "$TCL_SRC"; then
1912 AC_MSG_ERROR([could not configure Tcl])
1913 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001914fi
1915AC_SUBST(TCL_SRC)
1916AC_SUBST(TCL_OBJ)
1917AC_SUBST(TCL_PRO)
1918AC_SUBST(TCL_CFLAGS)
1919AC_SUBST(TCL_LIBS)
1920
1921AC_MSG_CHECKING(--enable-rubyinterp argument)
1922AC_ARG_ENABLE(rubyinterp,
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001923 [ --enable-rubyinterp[=OPTS] Include Ruby interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001924 [enable_rubyinterp="no"])
1925AC_MSG_RESULT($enable_rubyinterp)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001926if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001927 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1928 AC_MSG_ERROR([cannot use Ruby with tiny or small features])
1929 fi
1930
Bram Moolenaar165641d2010-02-17 16:23:09 +01001931 AC_MSG_CHECKING(--with-ruby-command argument)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001932 AC_SUBST(vi_cv_path_ruby)
Bram Moolenaar948733a2011-05-05 18:10:16 +02001933 AC_ARG_WITH(ruby-command, [ --with-ruby-command=RUBY name of the Ruby command (default: ruby)],
1934 RUBY_CMD="$withval"; vi_cv_path_ruby="$withval"; AC_MSG_RESULT($RUBY_CMD),
1935 RUBY_CMD="ruby"; AC_MSG_RESULT(defaulting to $RUBY_CMD))
Bram Moolenaar165641d2010-02-17 16:23:09 +01001936 AC_PATH_PROG(vi_cv_path_ruby, $RUBY_CMD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001937 if test "X$vi_cv_path_ruby" != "X"; then
1938 AC_MSG_CHECKING(Ruby version)
Bram Moolenaare4efc3b2005-03-07 23:16:51 +00001939 if $vi_cv_path_ruby -e '(VERSION rescue RUBY_VERSION) >= "1.6.0" or exit 1' >/dev/null 2>/dev/null; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001940 AC_MSG_RESULT(OK)
Bram Moolenaar81398892012-10-03 21:09:35 +02001941 AC_MSG_CHECKING(Ruby rbconfig)
1942 ruby_rbconfig="RbConfig"
1943 if ! $vi_cv_path_ruby -r rbconfig -e 'RbConfig' >/dev/null 2>/dev/null; then
1944 ruby_rbconfig="Config"
1945 fi
1946 AC_MSG_RESULT($ruby_rbconfig)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001947 AC_MSG_CHECKING(Ruby header files)
Bram Moolenaar81398892012-10-03 21:09:35 +02001948 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 +00001949 if test "X$rubyhdrdir" != "X"; then
1950 AC_MSG_RESULT($rubyhdrdir)
1951 RUBY_CFLAGS="-I$rubyhdrdir"
Bram Moolenaara6fd37b2014-03-27 17:19:09 +01001952 rubyarchdir=`$vi_cv_path_ruby -r rbconfig -e "print ($ruby_rbconfig::CONFIG.has_key? 'rubyarchhdrdir') ? $ruby_rbconfig::CONFIG[['rubyarchhdrdir']] : '$rubyhdrdir/'+$ruby_rbconfig::CONFIG[['arch']]"`
1953 if test -d "$rubyarchdir"; then
1954 RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyarchdir"
Bram Moolenaar165641d2010-02-17 16:23:09 +01001955 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001956 rubyversion=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['ruby_version']].gsub(/\./, '')[[0,2]]"`
Bram Moolenaar026a4452013-08-07 15:22:23 +02001957 if test "X$rubyversion" = "X"; then
1958 rubyversion=`$vi_cv_path_ruby -e "print ((VERSION rescue RUBY_VERSION)).gsub(/\./, '')[[0,2]]"`
1959 fi
Bram Moolenaar165641d2010-02-17 16:23:09 +01001960 RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
Bram Moolenaar81398892012-10-03 21:09:35 +02001961 rubylibs=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LIBS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001962 if test "X$rubylibs" != "X"; then
1963 RUBY_LIBS="$rubylibs"
1964 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001965 librubyarg=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBYARG']])"`
1966 librubya=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBY_A']])"`
Bram Moolenaarac499e32013-06-02 19:14:17 +02001967 rubylibdir=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['libdir']])"`
Bram Moolenaard5a986f2020-12-06 21:11:31 +01001968 if test -f "$rubylibdir/$librubya" || expr "$librubyarg" : "-lruby"; then
Bram Moolenaarac499e32013-06-02 19:14:17 +02001969 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
1970 elif test "$librubyarg" = "libruby.a"; then
1971 dnl required on Mac OS 10.3 where libruby.a doesn't exist
1972 librubyarg="-lruby"
1973 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001974 fi
1975
1976 if test "X$librubyarg" != "X"; then
1977 RUBY_LIBS="$librubyarg $RUBY_LIBS"
1978 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001979 rubyldflags=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LDFLAGS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001980 if test "X$rubyldflags" != "X"; then
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001981 dnl Ruby on Mac OS X 10.5 adds "-arch" flags but these should only
1982 dnl be included if requested by passing --with-mac-arch to
1983 dnl configure, so strip these flags first (if present)
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001984 rubyldflags=`echo "$rubyldflags" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001985 if test "X$rubyldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001986 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$rubyldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001987 LDFLAGS="$rubyldflags $LDFLAGS"
1988 fi
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001989 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001990 fi
1991 RUBY_SRC="if_ruby.c"
1992 RUBY_OBJ="objects/if_ruby.o"
1993 RUBY_PRO="if_ruby.pro"
1994 AC_DEFINE(FEAT_RUBY)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001995 if test "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar92021622017-10-12 12:33:43 +02001996 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_ALIASES']].split[[0]]"`
Bram Moolenaar87ea64c2018-08-04 15:13:34 +02001997 if test -z "$libruby_soname"; then
1998 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_SO']]"`
1999 fi
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002000 AC_DEFINE(DYNAMIC_RUBY)
Bram Moolenaar41a41412020-01-07 21:32:19 +01002001 RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby_soname\\\" $RUBY_CFLAGS"
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002002 RUBY_LIBS=
2003 fi
Bram Moolenaar864a28b2020-12-28 21:36:56 +01002004 if test "X$CLANG_VERSION" != "X" -a "$rubyversion" -ge 30; then
2005 RUBY_CFLAGS="$RUBY_CFLAGS -fdeclspec"
2006 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002007 else
Bram Moolenaar165641d2010-02-17 16:23:09 +01002008 AC_MSG_RESULT(not found; disabling Ruby)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002009 fi
2010 else
2011 AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
2012 fi
2013 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01002014
2015 if test "$fail_if_missing" = "yes" -a -z "$RUBY_OBJ"; then
2016 AC_MSG_ERROR([could not configure Ruby])
2017 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002018fi
2019AC_SUBST(RUBY_SRC)
2020AC_SUBST(RUBY_OBJ)
2021AC_SUBST(RUBY_PRO)
2022AC_SUBST(RUBY_CFLAGS)
2023AC_SUBST(RUBY_LIBS)
2024
2025AC_MSG_CHECKING(--enable-cscope argument)
2026AC_ARG_ENABLE(cscope,
2027 [ --enable-cscope Include cscope interface.], ,
2028 [enable_cscope="no"])
2029AC_MSG_RESULT($enable_cscope)
2030if test "$enable_cscope" = "yes"; then
2031 AC_DEFINE(FEAT_CSCOPE)
2032fi
2033
Bram Moolenaar071d4272004-06-13 20:20:40 +00002034AC_MSG_CHECKING(--disable-netbeans argument)
2035AC_ARG_ENABLE(netbeans,
2036 [ --disable-netbeans Disable NetBeans integration support.],
2037 , [enable_netbeans="yes"])
2038if test "$enable_netbeans" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002039 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2040 AC_MSG_RESULT([cannot use NetBeans with tiny or small features])
2041 enable_netbeans="no"
2042 else
2043 AC_MSG_RESULT(no)
2044 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002045else
2046 AC_MSG_RESULT(yes)
2047fi
2048
2049AC_MSG_CHECKING(--disable-channel argument)
2050AC_ARG_ENABLE(channel,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002051 [ --disable-channel Disable process communication support.],
Bram Moolenaare0874f82016-01-24 20:36:41 +01002052 , [enable_channel="yes"])
2053if test "$enable_channel" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002054 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2055 AC_MSG_RESULT([cannot use channels with tiny or small features])
2056 enable_channel="no"
2057 else
2058 AC_MSG_RESULT(no)
2059 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002060else
2061 if test "$enable_netbeans" = "yes"; then
Bram Moolenaar16435482016-01-24 21:31:54 +01002062 AC_MSG_RESULT([yes, netbeans also disabled])
Bram Moolenaare0874f82016-01-24 20:36:41 +01002063 enable_netbeans="no"
2064 else
2065 AC_MSG_RESULT(yes)
2066 fi
2067fi
2068
Bram Moolenaar16435482016-01-24 21:31:54 +01002069if test "$enable_channel" = "yes"; then
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002070 dnl On Solaris we need the socket library, or on Haiku the network library.
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002071 if test "x$HAIKU" = "xyes"; then
2072 AC_CHECK_LIB(network, socket)
2073 else
2074 AC_CHECK_LIB(socket, socket)
2075 fi
2076
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002077 AC_CACHE_CHECK([whether compiling with IPv6 networking is possible], [vim_cv_ipv6_networking],
2078 [AC_TRY_LINK([
2079#include <stdio.h>
2080#include <stdlib.h>
2081#include <stdarg.h>
2082#include <fcntl.h>
2083#include <netdb.h>
2084#include <netinet/in.h>
2085#include <errno.h>
2086#include <sys/types.h>
2087#include <sys/socket.h>
2088 /* Check bitfields */
2089 struct nbbuf {
2090 unsigned int initDone:1;
2091 unsigned short signmaplen;
2092 };
2093 ], [
2094 /* Check creating a socket. */
2095 struct sockaddr_in server;
2096 struct addrinfo *res;
2097 (void)socket(AF_INET, SOCK_STREAM, 0);
2098 (void)htons(100);
2099 (void)getaddrinfo("microsoft.com", NULL, NULL, &res);
2100 if (errno == ECONNREFUSED)
2101 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
2102 (void)freeaddrinfo(res);
2103 ],
2104 [vim_cv_ipv6_networking="yes"],
2105 [vim_cv_ipv6_networking="no"])])
2106
2107 if test "x$vim_cv_ipv6_networking" = "xyes"; then
2108 AC_DEFINE(FEAT_IPV6)
Bram Moolenaarb6fb0512020-04-18 18:24:18 +02002109 AC_CHECK_FUNCS(inet_ntop)
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002110 else
2111 dnl On Solaris we need the nsl library.
2112 AC_CHECK_LIB(nsl, gethostbyname)
2113 AC_CACHE_CHECK([whether compiling with IPv4 networking is possible], [vim_cv_ipv4_networking],
2114 [AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00002115#include <stdio.h>
2116#include <stdlib.h>
2117#include <stdarg.h>
2118#include <fcntl.h>
2119#include <netdb.h>
2120#include <netinet/in.h>
2121#include <errno.h>
2122#include <sys/types.h>
2123#include <sys/socket.h>
2124 /* Check bitfields */
2125 struct nbbuf {
2126 unsigned int initDone:1;
Bram Moolenaar63de19e2016-12-09 20:11:26 +01002127 unsigned short signmaplen;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002128 };
2129 ], [
2130 /* Check creating a socket. */
2131 struct sockaddr_in server;
2132 (void)socket(AF_INET, SOCK_STREAM, 0);
2133 (void)htons(100);
2134 (void)gethostbyname("microsoft.com");
2135 if (errno == ECONNREFUSED)
2136 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
2137 ],
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002138 [vim_cv_ipv4_networking="yes"],
2139 [vim_cv_ipv4_networking="no"; enable_netbeans="no"; enable_channel="no"])])
2140 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002141fi
2142if test "$enable_netbeans" = "yes"; then
2143 AC_DEFINE(FEAT_NETBEANS_INTG)
2144 NETBEANS_SRC="netbeans.c"
2145 AC_SUBST(NETBEANS_SRC)
2146 NETBEANS_OBJ="objects/netbeans.o"
2147 AC_SUBST(NETBEANS_OBJ)
2148fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002149if test "$enable_channel" = "yes"; then
Bram Moolenaar509ce2a2016-03-11 22:52:15 +01002150 AC_DEFINE(FEAT_JOB_CHANNEL)
Bram Moolenaar8b5866d2020-09-05 15:48:51 +02002151 CHANNEL_SRC="job.c channel.c"
Bram Moolenaare0874f82016-01-24 20:36:41 +01002152 AC_SUBST(CHANNEL_SRC)
Bram Moolenaar8b5866d2020-09-05 15:48:51 +02002153 CHANNEL_OBJ="objects/job.o objects/channel.o"
Bram Moolenaare0874f82016-01-24 20:36:41 +01002154 AC_SUBST(CHANNEL_OBJ)
2155fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002156
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002157AC_MSG_CHECKING(--enable-terminal argument)
2158AC_ARG_ENABLE(terminal,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002159 [ --enable-terminal Enable terminal emulation support.],
Bram Moolenaaref839562017-10-28 20:28:23 +02002160 , [enable_terminal="auto"])
Bram Moolenaar595a4022017-09-03 19:15:57 +02002161if test "$enable_terminal" = "yes" || test "$enable_terminal" = "auto" -a "x$features" = "xhuge" ; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002162 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2163 AC_MSG_RESULT([cannot use terminal emulator with tiny or small features])
2164 enable_terminal="no"
2165 else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002166 if test "$enable_terminal" = "auto"; then
2167 enable_terminal="yes"
2168 AC_MSG_RESULT(defaulting to yes)
2169 else
2170 AC_MSG_RESULT(yes)
2171 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002172 fi
2173else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002174 if test "$enable_terminal" = "auto"; then
2175 enable_terminal="no"
2176 AC_MSG_RESULT(defaulting to no)
2177 else
2178 AC_MSG_RESULT(no)
2179 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002180fi
Bram Moolenaar8b423282017-12-16 14:37:06 +01002181if test "$enable_terminal" = "yes" -a "$enable_channel" = "yes"; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002182 AC_DEFINE(FEAT_TERMINAL)
Bram Moolenaar93268052019-10-10 13:22:54 +02002183 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 +02002184 AC_SUBST(TERM_SRC)
Bram Moolenaar93268052019-10-10 13:22:54 +02002185 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 +02002186 AC_SUBST(TERM_OBJ)
Bram Moolenaar823edd12019-10-23 22:35:36 +02002187 TERM_TEST="test_libvterm"
2188 AC_SUBST(TERM_TEST)
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002189fi
2190
Bram Moolenaare42a6d22017-11-12 19:21:51 +01002191AC_MSG_CHECKING(--enable-autoservername argument)
2192AC_ARG_ENABLE(autoservername,
2193 [ --enable-autoservername Automatically define servername at vim startup.], ,
2194 [enable_autoservername="no"])
2195AC_MSG_RESULT($enable_autoservername)
2196if test "$enable_autoservername" = "yes"; then
2197 AC_DEFINE(FEAT_AUTOSERVERNAME)
2198fi
2199
Bram Moolenaar071d4272004-06-13 20:20:40 +00002200AC_MSG_CHECKING(--enable-multibyte argument)
2201AC_ARG_ENABLE(multibyte,
2202 [ --enable-multibyte Include multibyte editing support.], ,
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01002203 [enable_multibyte="yes"])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002204AC_MSG_RESULT($enable_multibyte)
Bram Moolenaar30276f22019-01-24 17:59:39 +01002205if test "$enable_multibyte" != "yes"; then
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01002206 AC_MSG_ERROR([The multi-byte feature can no longer be disabled. If you have
2207 a problem with this, discuss on the Vim mailing list.])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002208fi
2209
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002210dnl Right-to-Left language support for Vim will be included with big features,
2211dnl unless ENABLE_RIGHTLEFT is undefined.
2212AC_MSG_CHECKING(--disable-rightleft argument)
2213AC_ARG_ENABLE(rightleft,
2214 [ --disable-rightleft Do not include Right-to-Left language support.],
2215 , [enable_rightleft="yes"])
2216if test "$enable_rightleft" = "yes"; then
2217 AC_MSG_RESULT(no)
2218else
2219 AC_MSG_RESULT(yes)
2220 AC_DEFINE(DISABLE_RIGHTLEFT)
2221fi
2222
2223dnl Arabic language support for Vim will be included with big features,
2224dnl unless ENABLE_ARABIC is undefined.
2225AC_MSG_CHECKING(--disable-arabic argument)
2226AC_ARG_ENABLE(arabic,
2227 [ --disable-arabic Do not include Arabic language support.],
2228 , [enable_arabic="yes"])
2229if test "$enable_arabic" = "yes"; then
2230 AC_MSG_RESULT(no)
2231else
2232 AC_MSG_RESULT(yes)
2233 AC_DEFINE(DISABLE_ARABIC)
2234fi
2235
Bram Moolenaar14184a32019-02-16 15:10:30 +01002236dnl Farsi language support has been removed, ignore --disable-farsi
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002237AC_ARG_ENABLE(farsi,
Bram Moolenaar14184a32019-02-16 15:10:30 +01002238 [ --disable-farsi Deprecated.],,)
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002239
Bram Moolenaar071d4272004-06-13 20:20:40 +00002240AC_MSG_CHECKING(--enable-xim argument)
2241AC_ARG_ENABLE(xim,
2242 [ --enable-xim Include XIM input support.],
2243 AC_MSG_RESULT($enable_xim),
2244 [enable_xim="auto"; AC_MSG_RESULT(defaulting to auto)])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002245
2246AC_MSG_CHECKING(--enable-fontset argument)
2247AC_ARG_ENABLE(fontset,
2248 [ --enable-fontset Include X fontset output support.], ,
2249 [enable_fontset="no"])
2250AC_MSG_RESULT($enable_fontset)
2251dnl defining FEAT_XFONTSET is delayed, so that it can be disabled for no GUI
2252
2253test -z "$with_x" && with_x=yes
Bram Moolenaard0573012017-10-28 21:11:06 +02002254test "${enable_gui-yes}" != no -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && with_x=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002255if test "$with_x" = no; then
2256 AC_MSG_RESULT(defaulting to: don't HAVE_X11)
2257else
2258 dnl Do this check early, so that its failure can override user requests.
2259
2260 AC_PATH_PROG(xmkmfpath, xmkmf)
2261
2262 AC_PATH_XTRA
2263
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002264 dnl On z/OS Unix the X libraries are DLLs. To use them the code must
Bram Moolenaar071d4272004-06-13 20:20:40 +00002265 dnl be compiled with a special option.
2266 dnl Also add SM, ICE and Xmu to X_EXTRA_LIBS.
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002267 if test "$zOSUnix" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002268 CFLAGS="$CFLAGS -W c,dll"
2269 LDFLAGS="$LDFLAGS -W l,dll"
2270 X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE -lXmu"
2271 fi
2272
2273 dnl On my HPUX system the X include dir is found, but the lib dir not.
Bram Moolenaar70778922020-02-05 20:44:24 +01002274 dnl This is a desperate try to fix this.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002275
2276 if test -d "$x_includes" && test ! -d "$x_libraries"; then
2277 x_libraries=`echo "$x_includes" | sed s/include/lib/`
2278 AC_MSG_RESULT(Corrected X libraries to $x_libraries)
2279 X_LIBS="$X_LIBS -L$x_libraries"
2280 if test "`(uname) 2>/dev/null`" = SunOS &&
2281 uname -r | grep '^5' >/dev/null; then
2282 X_LIBS="$X_LIBS -R $x_libraries"
2283 fi
2284 fi
2285
2286 if test -d "$x_libraries" && test ! -d "$x_includes"; then
2287 x_includes=`echo "$x_libraries" | sed s/lib/include/`
2288 AC_MSG_RESULT(Corrected X includes to $x_includes)
2289 X_CFLAGS="$X_CFLAGS -I$x_includes"
2290 fi
2291
2292 dnl Remove "-I/usr/include " from X_CFLAGS, should not be needed.
2293 X_CFLAGS="`echo $X_CFLAGS\ | sed 's%-I/usr/include %%'`"
2294 dnl Remove "-L/usr/lib " from X_LIBS, should not be needed.
2295 X_LIBS="`echo $X_LIBS\ | sed 's%-L/usr/lib %%'`"
2296 dnl Same for "-R/usr/lib ".
2297 X_LIBS="`echo $X_LIBS\ | sed -e 's%-R/usr/lib %%' -e 's%-R /usr/lib %%'`"
2298
2299
2300 dnl Check if the X11 header files are correctly installed. On some systems
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002301 dnl Xlib.h includes files that don't exist. On some systems X11/Intrinsic.h
2302 dnl is missing.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002303 AC_MSG_CHECKING(if X11 header files can be found)
2304 cflags_save=$CFLAGS
2305 CFLAGS="$CFLAGS $X_CFLAGS"
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002306 AC_TRY_COMPILE([#include <X11/Xlib.h>
2307#include <X11/Intrinsic.h>], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002308 AC_MSG_RESULT(yes),
2309 AC_MSG_RESULT(no); no_x=yes)
2310 CFLAGS=$cflags_save
2311
2312 if test "${no_x-no}" = yes; then
2313 with_x=no
2314 else
2315 AC_DEFINE(HAVE_X11)
2316 X_LIB="-lXt -lX11";
2317 AC_SUBST(X_LIB)
2318
2319 ac_save_LDFLAGS="$LDFLAGS"
2320 LDFLAGS="-L$x_libraries $LDFLAGS"
2321
2322 dnl Check for -lXdmcp (needed on SunOS 4.1.4)
2323 dnl For HP-UX 10.20 it must be before -lSM -lICE
2324 AC_CHECK_LIB(Xdmcp, _XdmcpAuthDoIt, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lXdmcp"],,
2325 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXdmcp])
2326
2327 dnl Some systems need -lnsl -lsocket when testing for ICE.
2328 dnl The check above doesn't do this, try here (again). Also needed to get
2329 dnl them after Xdmcp. link.sh will remove them when not needed.
2330 dnl Check for other function than above to avoid the cached value
2331 AC_CHECK_LIB(ICE, IceOpenConnection,
2332 [X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE"],, [$X_EXTRA_LIBS])
2333
2334 dnl Check for -lXpm (needed for some versions of Motif)
2335 LDFLAGS="$X_LIBS $ac_save_LDFLAGS"
2336 AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [X_PRE_LIBS="$X_PRE_LIBS -lXpm"],,
2337 [-lXt $X_PRE_LIBS -lXpm -lX11 $X_EXTRA_LIBS])
2338
2339 dnl Check that the X11 header files don't use implicit declarations
2340 AC_MSG_CHECKING(if X11 header files implicitly declare return values)
2341 cflags_save=$CFLAGS
Bram Moolenaard1864592013-05-04 04:40:15 +02002342 dnl -Werror is GCC only, others like Solaris Studio might not like it
2343 if test "$GCC" = yes; then
2344 CFLAGS="$CFLAGS $X_CFLAGS -Werror"
2345 else
2346 CFLAGS="$CFLAGS $X_CFLAGS"
2347 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002348 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2349 AC_MSG_RESULT(no),
2350 CFLAGS="$CFLAGS -Wno-implicit-int"
2351 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2352 AC_MSG_RESULT(yes); cflags_save="$cflags_save -Wno-implicit-int",
2353 AC_MSG_RESULT(test failed)
2354 )
2355 )
2356 CFLAGS=$cflags_save
2357
2358 LDFLAGS="$ac_save_LDFLAGS"
2359
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002360 AC_MSG_CHECKING(size of wchar_t is 2 bytes)
2361 AC_CACHE_VAL(ac_cv_small_wchar_t,
2362 [AC_TRY_RUN([
2363#include <X11/Xlib.h>
2364#if STDC_HEADERS
2365# include <stdlib.h>
2366# include <stddef.h>
2367#endif
2368 main()
2369 {
2370 if (sizeof(wchar_t) <= 2)
2371 exit(1);
2372 exit(0);
2373 }],
2374 ac_cv_small_wchar_t="no",
2375 ac_cv_small_wchar_t="yes",
2376 AC_MSG_ERROR(failed to compile test program))])
2377 AC_MSG_RESULT($ac_cv_small_wchar_t)
2378 if test "x$ac_cv_small_wchar_t" = "xyes" ; then
2379 AC_DEFINE(SMALL_WCHAR_T)
2380 fi
2381
Bram Moolenaar071d4272004-06-13 20:20:40 +00002382 fi
2383fi
2384
Bram Moolenaard2a05492018-07-27 22:35:15 +02002385dnl Check if --with-x was given but it doesn't work.
2386if test "x$with_x" = xno -a "x$with_x_arg" = xyes; then
2387 AC_MSG_ERROR([could not configure X])
2388fi
2389
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002390test "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 +00002391
2392AC_MSG_CHECKING(--enable-gui argument)
2393AC_ARG_ENABLE(gui,
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002394 [ --enable-gui[=OPTS] X11 GUI. [default=auto] [OPTS=auto/no/gtk2/gnome2/gtk3/motif/athena/neXtaw/haiku/photon/carbon]], , enable_gui="auto")
Bram Moolenaar071d4272004-06-13 20:20:40 +00002395
2396dnl Canonicalize the --enable-gui= argument so that it can be easily compared.
2397dnl Do not use character classes for portability with old tools.
2398enable_gui_canon=`echo "_$enable_gui" | \
2399 sed 's/[[ _+-]]//g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
2400
2401dnl Skip everything by default.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002402SKIP_GTK2=YES
Bram Moolenaar1858a842016-02-23 22:30:31 +01002403SKIP_GTK3=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002404SKIP_GNOME=YES
2405SKIP_MOTIF=YES
2406SKIP_ATHENA=YES
2407SKIP_NEXTAW=YES
2408SKIP_PHOTON=YES
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002409SKIP_HAIKU=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002410GUITYPE=NONE
2411
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002412if test "x$HAIKU" = "xyes"; then
2413 SKIP_HAIKU=
2414 case "$enable_gui_canon" in
2415 no) AC_MSG_RESULT(no GUI support)
2416 SKIP_HAIKU=YES ;;
2417 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
2418 auto) AC_MSG_RESULT(auto - automatic GUI support) ;;
2419 haiku) AC_MSG_RESULT(Haiku GUI support) ;;
2420 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2421 SKIP_HAIKU=YES ;;
2422 esac
2423elif test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002424 SKIP_PHOTON=
2425 case "$enable_gui_canon" in
2426 no) AC_MSG_RESULT(no GUI support)
2427 SKIP_PHOTON=YES ;;
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002428 yes|""|auto) AC_MSG_RESULT(automatic GUI support)
2429 gui_auto=yes ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002430 photon) AC_MSG_RESULT(Photon GUI support) ;;
2431 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2432 SKIP_PHOTON=YES ;;
2433 esac
2434
Bram Moolenaar040f9752020-08-11 23:08:48 +02002435elif test "x$MACOS_X" = "xyes" -a "x$with_x" = "xno" ; then
2436 case "$enable_gui_canon" in
2437 no) AC_MSG_RESULT(no GUI support) ;;
2438 yes|"") AC_MSG_RESULT(yes - automatic GUI support)
2439 gui_auto=yes ;;
2440 auto) AC_MSG_RESULT(auto - disable GUI support for Mac OS) ;;
Bram Moolenaarbe7529e2020-08-13 21:05:39 +02002441 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
Bram Moolenaar040f9752020-08-11 23:08:48 +02002442 esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00002443else
2444
Bram Moolenaar071d4272004-06-13 20:20:40 +00002445 case "$enable_gui_canon" in
2446 no|none) AC_MSG_RESULT(no GUI support) ;;
2447 yes|""|auto) AC_MSG_RESULT(yes/auto - automatic GUI support)
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002448 gui_auto=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002449 SKIP_GTK2=
2450 SKIP_GNOME=
2451 SKIP_MOTIF=
2452 SKIP_ATHENA=
Bram Moolenaar097148e2020-08-11 21:58:20 +02002453 SKIP_NEXTAW=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002454 gtk2) AC_MSG_RESULT(GTK+ 2.x GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002455 SKIP_GTK2=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002456 gnome2) AC_MSG_RESULT(GNOME 2.x GUI support)
2457 SKIP_GNOME=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002458 SKIP_GTK2=;;
Bram Moolenaar98921892016-02-23 17:14:37 +01002459 gtk3) AC_MSG_RESULT(GTK+ 3.x GUI support)
2460 SKIP_GTK3=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002461 motif) AC_MSG_RESULT(Motif GUI support)
2462 SKIP_MOTIF=;;
2463 athena) AC_MSG_RESULT(Athena GUI support)
2464 SKIP_ATHENA=;;
2465 nextaw) AC_MSG_RESULT(neXtaw GUI support)
2466 SKIP_NEXTAW=;;
2467 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
2468 esac
2469
2470fi
2471
Bram Moolenaar071d4272004-06-13 20:20:40 +00002472if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \
2473 -a "$enable_gui_canon" != "gnome2"; then
2474 AC_MSG_CHECKING(whether or not to look for GTK+ 2)
2475 AC_ARG_ENABLE(gtk2-check,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002476 [ --enable-gtk2-check If auto-select GUI, check for GTK+ 2 [default=yes]],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002477 , enable_gtk2_check="yes")
2478 AC_MSG_RESULT($enable_gtk2_check)
2479 if test "x$enable_gtk2_check" = "xno"; then
2480 SKIP_GTK2=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002481 SKIP_GNOME=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002482 fi
2483fi
2484
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002485if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002486 AC_MSG_CHECKING(whether or not to look for GNOME)
2487 AC_ARG_ENABLE(gnome-check,
2488 [ --enable-gnome-check If GTK GUI, check for GNOME [default=no]],
2489 , enable_gnome_check="no")
2490 AC_MSG_RESULT($enable_gnome_check)
2491 if test "x$enable_gnome_check" = "xno"; then
2492 SKIP_GNOME=YES
2493 fi
2494fi
2495
Bram Moolenaar98921892016-02-23 17:14:37 +01002496if test "x$SKIP_GTK3" != "xYES" -a "$enable_gui_canon" != "gtk3"; then
2497 AC_MSG_CHECKING(whether or not to look for GTK+ 3)
2498 AC_ARG_ENABLE(gtk3-check,
2499 [ --enable-gtk3-check If auto-select GUI, check for GTK+ 3 [default=yes]],
2500 , enable_gtk3_check="yes")
2501 AC_MSG_RESULT($enable_gtk3_check)
2502 if test "x$enable_gtk3_check" = "xno"; then
2503 SKIP_GTK3=YES
2504 fi
2505fi
2506
Bram Moolenaar071d4272004-06-13 20:20:40 +00002507if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then
2508 AC_MSG_CHECKING(whether or not to look for Motif)
2509 AC_ARG_ENABLE(motif-check,
2510 [ --enable-motif-check If auto-select GUI, check for Motif [default=yes]],
2511 , enable_motif_check="yes")
2512 AC_MSG_RESULT($enable_motif_check)
2513 if test "x$enable_motif_check" = "xno"; then
2514 SKIP_MOTIF=YES
2515 fi
2516fi
2517
2518if test "x$SKIP_ATHENA" != "xYES" -a "$enable_gui_canon" != "athena"; then
2519 AC_MSG_CHECKING(whether or not to look for Athena)
2520 AC_ARG_ENABLE(athena-check,
2521 [ --enable-athena-check If auto-select GUI, check for Athena [default=yes]],
2522 , enable_athena_check="yes")
2523 AC_MSG_RESULT($enable_athena_check)
2524 if test "x$enable_athena_check" = "xno"; then
2525 SKIP_ATHENA=YES
2526 fi
2527fi
2528
2529if test "x$SKIP_NEXTAW" != "xYES" -a "$enable_gui_canon" != "nextaw"; then
2530 AC_MSG_CHECKING(whether or not to look for neXtaw)
2531 AC_ARG_ENABLE(nextaw-check,
2532 [ --enable-nextaw-check If auto-select GUI, check for neXtaw [default=yes]],
2533 , enable_nextaw_check="yes")
2534 AC_MSG_RESULT($enable_nextaw_check);
2535 if test "x$enable_nextaw_check" = "xno"; then
2536 SKIP_NEXTAW=YES
2537 fi
2538fi
2539
Bram Moolenaar071d4272004-06-13 20:20:40 +00002540dnl define an autoconf function to check for a specified version of GTK, and
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002541dnl try to compile/link a GTK program.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002542dnl
2543dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002544dnl Test for GTK, and define GTK_CFLAGS, GTK_LIBDIR and GTK_LIBS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002545dnl
2546AC_DEFUN(AM_PATH_GTK,
2547[
2548 if test "X$GTK_CONFIG" != "Xno" -o "X$PKG_CONFIG" != "Xno"; then
2549 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00002550 no_gtk=""
2551 if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2552 && $PKG_CONFIG --exists gtk+-2.0; then
2553 {
Bram Moolenaar98921892016-02-23 17:14:37 +01002554 min_gtk_version=ifelse([$1], ,2.2.0,$1)
2555 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002556 dnl We should be using PKG_CHECK_MODULES() instead of this hack.
2557 dnl But I guess the dependency on pkgconfig.m4 is not wanted or
2558 dnl something like that.
2559 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0`
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002560 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-2.0`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002561 GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0`
2562 gtk_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2563 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2564 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2565 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2566 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2567 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2568 }
Bram Moolenaar98921892016-02-23 17:14:37 +01002569 elif (test "X$SKIP_GTK3" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2570 && $PKG_CONFIG --exists gtk+-3.0; then
2571 {
2572 min_gtk_version=ifelse([$1], ,3.0.0,$1)
2573 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
2574
2575 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-3.0`
2576 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-3.0`
2577 GTK_LIBS=`$PKG_CONFIG --libs gtk+-3.0`
2578 gtk_major_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2579 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2580 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2581 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2582 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2583 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2584 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002585 else
Bram Moolenaar67876de2021-01-12 20:51:24 +01002586 dnl Put some text before the "no" to hint at installing the gtk-dev
2587 dnl packages.
2588 AC_MSG_CHECKING(for GTK -dev package)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002589 no_gtk=yes
2590 fi
2591
2592 if test "x$enable_gtktest" = "xyes" -a "x$no_gtk" = "x"; then
2593 {
2594 ac_save_CFLAGS="$CFLAGS"
2595 ac_save_LIBS="$LIBS"
2596 CFLAGS="$CFLAGS $GTK_CFLAGS"
2597 LIBS="$LIBS $GTK_LIBS"
2598
2599 dnl
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002600 dnl Now check if the installed GTK is sufficiently new.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002601 dnl
2602 rm -f conf.gtktest
2603 AC_TRY_RUN([
2604#include <gtk/gtk.h>
2605#include <stdio.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00002606#if STDC_HEADERS
2607# include <stdlib.h>
2608# include <stddef.h>
2609#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002610
2611int
2612main ()
2613{
2614int major, minor, micro;
2615char *tmp_version;
2616
2617system ("touch conf.gtktest");
2618
2619/* HP/UX 9 (%@#!) writes to sscanf strings */
2620tmp_version = g_strdup("$min_gtk_version");
2621if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
2622 printf("%s, bad version string\n", "$min_gtk_version");
2623 exit(1);
2624 }
2625
2626if ((gtk_major_version > major) ||
2627 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
2628 ((gtk_major_version == major) && (gtk_minor_version == minor) &&
2629 (gtk_micro_version >= micro)))
2630{
2631 return 0;
2632}
2633return 1;
2634}
2635],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
2636 CFLAGS="$ac_save_CFLAGS"
2637 LIBS="$ac_save_LIBS"
2638 }
2639 fi
2640 if test "x$no_gtk" = x ; then
2641 if test "x$enable_gtktest" = "xyes"; then
2642 AC_MSG_RESULT(yes; found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2643 else
2644 AC_MSG_RESULT(found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2645 fi
2646 ifelse([$2], , :, [$2])
2647 else
2648 {
2649 AC_MSG_RESULT(no)
2650 GTK_CFLAGS=""
2651 GTK_LIBS=""
2652 ifelse([$3], , :, [$3])
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002653 if test "$fail_if_missing" = "yes" -a "X$gui_auto" != "Xyes"; then
2654 AC_MSG_ERROR([could not configure GTK])
2655 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002656 }
2657 fi
2658 }
2659 else
2660 GTK_CFLAGS=""
2661 GTK_LIBS=""
2662 ifelse([$3], , :, [$3])
2663 fi
2664 AC_SUBST(GTK_CFLAGS)
2665 AC_SUBST(GTK_LIBS)
2666 rm -f conf.gtktest
2667])
2668
2669dnl ---------------------------------------------------------------------------
2670dnl gnome
2671dnl ---------------------------------------------------------------------------
2672AC_DEFUN([GNOME_INIT_HOOK],
2673[
2674 AC_SUBST(GNOME_LIBS)
2675 AC_SUBST(GNOME_LIBDIR)
2676 AC_SUBST(GNOME_INCLUDEDIR)
2677
2678 AC_ARG_WITH(gnome-includes,
2679 [ --with-gnome-includes=DIR Specify location of GNOME headers],
2680 [CFLAGS="$CFLAGS -I$withval"]
2681 )
2682
2683 AC_ARG_WITH(gnome-libs,
2684 [ --with-gnome-libs=DIR Specify location of GNOME libs],
2685 [LDFLAGS="$LDFLAGS -L$withval" gnome_prefix=$withval]
2686 )
2687
2688 AC_ARG_WITH(gnome,
2689 [ --with-gnome Specify prefix for GNOME files],
2690 if test x$withval = xyes; then
2691 want_gnome=yes
2692 ifelse([$1], [], :, [$1])
2693 else
2694 if test "x$withval" = xno; then
2695 want_gnome=no
2696 else
2697 want_gnome=yes
2698 LDFLAGS="$LDFLAGS -L$withval/lib"
2699 CFLAGS="$CFLAGS -I$withval/include"
2700 gnome_prefix=$withval/lib
2701 fi
2702 fi,
2703 want_gnome=yes)
2704
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002705 if test "x$want_gnome" = xyes; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002706 {
2707 AC_MSG_CHECKING(for libgnomeui-2.0)
2708 if $PKG_CONFIG --exists libgnomeui-2.0; then
2709 AC_MSG_RESULT(yes)
2710 GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0`
2711 GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0`
2712 GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0`
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002713
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002714 dnl On FreeBSD we need -pthread but pkg-config doesn't include it.
2715 dnl This might not be the right way but it works for me...
2716 AC_MSG_CHECKING(for FreeBSD)
2717 if test "`(uname) 2>/dev/null`" = FreeBSD; then
2718 AC_MSG_RESULT(yes, adding -pthread)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002719 GNOME_INCLUDEDIR="$GNOME_INCLUDEDIR -D_THREAD_SAFE"
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002720 GNOME_LIBS="$GNOME_LIBS -pthread"
2721 else
2722 AC_MSG_RESULT(no)
2723 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002724 $1
2725 else
2726 AC_MSG_RESULT(not found)
2727 if test "x$2" = xfail; then
2728 AC_MSG_ERROR(Could not find libgnomeui-2.0 via pkg-config)
2729 fi
2730 fi
2731 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002732 fi
2733])
2734
2735AC_DEFUN([GNOME_INIT],[
2736 GNOME_INIT_HOOK([],fail)
2737])
2738
Bram Moolenaar427f5b62019-06-09 13:43:51 +02002739if test "X$PKG_CONFIG" = "X"; then
2740 AC_PATH_TOOL(PKG_CONFIG, pkg-config, no)
2741fi
2742
Bram Moolenaar071d4272004-06-13 20:20:40 +00002743
2744dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002745dnl Check for GTK2. If it fails, then continue on for Motif as before...
Bram Moolenaar071d4272004-06-13 20:20:40 +00002746dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002747if test -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002748
2749 AC_MSG_CHECKING(--disable-gtktest argument)
2750 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2751 , enable_gtktest=yes)
2752 if test "x$enable_gtktest" = "xyes" ; then
2753 AC_MSG_RESULT(gtk test enabled)
2754 else
2755 AC_MSG_RESULT(gtk test disabled)
2756 fi
2757
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002758 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002759 dnl First try finding version 2.2.0 or later. The 2.0.x series has
2760 dnl problems (bold fonts, --remote doesn't work).
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002761 AM_PATH_GTK(2.2.0,
2762 [GUI_LIB_LOC="$GTK_LIBDIR"
2763 GTK_LIBNAME="$GTK_LIBS"
2764 GUI_INC_LOC="$GTK_CFLAGS"], )
2765 if test "x$GTK_CFLAGS" != "x"; then
Bram Moolenaar98921892016-02-23 17:14:37 +01002766 SKIP_GTK3=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002767 SKIP_ATHENA=YES
2768 SKIP_NEXTAW=YES
2769 SKIP_MOTIF=YES
2770 GUITYPE=GTK
2771 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002772 fi
2773 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002774 if test "x$GUITYPE" = "xGTK"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002775 dnl
2776 dnl if GTK exists, then check for GNOME.
2777 dnl
2778 if test -z "$SKIP_GNOME"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002779 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002780 GNOME_INIT_HOOK([have_gnome=yes])
2781 if test "x$have_gnome" = xyes ; then
2782 AC_DEFINE(FEAT_GUI_GNOME)
2783 GUI_INC_LOC="$GUI_INC_LOC $GNOME_INCLUDEDIR"
2784 GTK_LIBNAME="$GTK_LIBNAME $GNOME_LIBDIR $GNOME_LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002785 fi
2786 }
2787 fi
2788 fi
2789fi
2790
Bram Moolenaar98921892016-02-23 17:14:37 +01002791
2792dnl ---------------------------------------------------------------------------
2793dnl Check for GTK3.
2794dnl ---------------------------------------------------------------------------
2795if test -z "$SKIP_GTK3"; then
2796
2797 AC_MSG_CHECKING(--disable-gtktest argument)
2798 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2799 , enable_gtktest=yes)
2800 if test "x$enable_gtktest" = "xyes" ; then
2801 AC_MSG_RESULT(gtk test enabled)
2802 else
2803 AC_MSG_RESULT(gtk test disabled)
2804 fi
2805
Bram Moolenaar98921892016-02-23 17:14:37 +01002806 if test "x$PKG_CONFIG" != "xno"; then
2807 AM_PATH_GTK(3.0.0,
2808 [GUI_LIB_LOC="$GTK_LIBDIR"
2809 GTK_LIBNAME="$GTK_LIBS"
2810 GUI_INC_LOC="$GTK_CFLAGS"], )
2811 if test "x$GTK_CFLAGS" != "x"; then
2812 SKIP_GTK2=YES
2813 SKIP_GNOME=YES
2814 SKIP_ATHENA=YES
2815 SKIP_NEXTAW=YES
2816 SKIP_MOTIF=YES
2817 GUITYPE=GTK
2818 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar98921892016-02-23 17:14:37 +01002819 AC_DEFINE(USE_GTK3)
2820 fi
2821 fi
2822fi
2823
Bram Moolenaard2e03f02016-01-02 22:46:36 +01002824dnl Check the version of Gdk-Pixbuf. If the version is 2.31 or later and
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002825dnl glib-compile-resources is found in PATH, use GResource.
2826if test "x$GUITYPE" = "xGTK"; then
2827 AC_MSG_CHECKING([version of Gdk-Pixbuf])
2828 gdk_pixbuf_version=`$PKG_CONFIG --modversion gdk-pixbuf-2.0`
2829 if test "x$gdk_pixbuf_version" != x ; then
2830 gdk_pixbuf_version_minor=`echo $gdk_pixbuf_version | \
2831 sed -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/'`
2832 if test "x$gdk_pixbuf_version_minor" != x -a \
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002833 $gdk_pixbuf_version_minor -ge 31 ; then
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002834 AC_MSG_RESULT([OK.])
2835 AC_PATH_PROG(GLIB_COMPILE_RESOURCES,[glib-compile-resources],no)
2836 AC_MSG_CHECKING([glib-compile-resources])
2837 if test "x$GLIB_COMPILE_RESOURCES" = xno ; then
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002838 GLIB_COMPILE_RESOURCES=""
2839 AC_MSG_RESULT([cannot be found in PATH.])
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002840 else
2841 AC_MSG_RESULT([usable.])
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002842 AC_DEFINE(USE_GRESOURCE)
2843 GRESOURCE_SRC="auto/gui_gtk_gresources.c"
2844 GRESOURCE_OBJ="objects/gui_gtk_gresources.o"
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002845 fi
2846 else
2847 AC_MSG_RESULT([not usable.])
2848 fi
2849 else
2850 AC_MSG_RESULT([cannot obtain from pkg_config.])
2851 fi
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002852
2853 AC_MSG_CHECKING([--disable-icon-cache-update argument])
2854 AC_ARG_ENABLE(icon_cache_update,
2855 [ --disable-icon-cache-update update disabled],
2856 [],
2857 [enable_icon_cache_update="yes"])
2858 if test "$enable_icon_cache_update" = "yes"; then
2859 AC_MSG_RESULT([not set])
2860 AC_PATH_PROG(GTK_UPDATE_ICON_CACHE,[gtk-update-icon-cache],no)
2861 if test "x$GTK_UPDATE_ICON_CACHE" = "xno" ; then
2862 AC_MSG_RESULT([not found in PATH.])
2863 fi
2864 else
2865 AC_MSG_RESULT([update disabled])
2866 fi
2867
2868 AC_MSG_CHECKING([--disable-desktop-database-update argument])
2869 AC_ARG_ENABLE(desktop_database_update,
2870 [ --disable-desktop-database-update update disabled],
2871 [],
2872 [enable_desktop_database_update="yes"])
2873 if test "$enable_desktop_database_update" = "yes"; then
2874 AC_MSG_RESULT([not set])
2875 AC_PATH_PROG(UPDATE_DESKTOP_DATABASE,[update-desktop-database],no)
2876 if test "x$UPDATE_DESKTOP_DATABASE" = "xno" ; then
2877 AC_MSG_RESULT([not found in PATH.])
2878 fi
2879 else
2880 AC_MSG_RESULT([update disabled])
2881 fi
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002882fi
2883AC_SUBST(GLIB_COMPILE_RESOURCES)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002884AC_SUBST(GRESOURCE_SRC)
2885AC_SUBST(GRESOURCE_OBJ)
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002886AC_SUBST(GTK_UPDATE_ICON_CACHE)
2887AC_SUBST(UPDATE_DESKTOP_DATABASE)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002888
Bram Moolenaar071d4272004-06-13 20:20:40 +00002889dnl Check for Motif include files location.
2890dnl The LAST one found is used, this makes the highest version to be used,
2891dnl e.g. when Motif1.2 and Motif2.0 are both present.
2892
2893if test -z "$SKIP_MOTIF"; then
2894 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"
2895 dnl Remove "-I" from before $GUI_INC_LOC if it's there
2896 GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`"
2897
2898 AC_MSG_CHECKING(for location of Motif GUI includes)
2899 gui_includes="`echo $x_includes|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC"
2900 GUI_INC_LOC=
2901 for try in $gui_includes; do
2902 if test -f "$try/Xm/Xm.h"; then
2903 GUI_INC_LOC=$try
2904 fi
2905 done
2906 if test -n "$GUI_INC_LOC"; then
2907 if test "$GUI_INC_LOC" = /usr/include; then
2908 GUI_INC_LOC=
2909 AC_MSG_RESULT(in default path)
2910 else
2911 AC_MSG_RESULT($GUI_INC_LOC)
2912 fi
2913 else
2914 AC_MSG_RESULT(<not found>)
2915 SKIP_MOTIF=YES
2916 fi
2917fi
2918
2919dnl Check for Motif library files location. In the same order as the include
2920dnl files, to avoid a mixup if several versions are present
2921
2922if test -z "$SKIP_MOTIF"; then
2923 AC_MSG_CHECKING(--with-motif-lib argument)
2924 AC_ARG_WITH(motif-lib,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002925 [ --with-motif-lib=STRING Library for Motif ],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002926 [ MOTIF_LIBNAME="${withval}" ] )
2927
2928 if test -n "$MOTIF_LIBNAME"; then
2929 AC_MSG_RESULT($MOTIF_LIBNAME)
2930 GUI_LIB_LOC=
2931 else
2932 AC_MSG_RESULT(no)
2933
2934 dnl Remove "-L" from before $GUI_LIB_LOC if it's there
2935 GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
2936
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002937 dnl Ubuntu has libXm.so in /usr/lib/i386-linux-gnu and elsewhere. The
2938 dnl linker will figure out which one to use, we only check if one exists.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002939 AC_MSG_CHECKING(for location of Motif GUI libs)
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002940 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 +00002941 GUI_LIB_LOC=
2942 for try in $gui_libs; do
Bram Moolenaar325b7a22004-07-05 15:58:32 +00002943 for libtry in "$try"/libXm.a "$try"/libXm.so* "$try"/libXm.sl "$try"/libXm.dylib; do
Bram Moolenaar071d4272004-06-13 20:20:40 +00002944 if test -f "$libtry"; then
2945 GUI_LIB_LOC=$try
2946 fi
2947 done
2948 done
2949 if test -n "$GUI_LIB_LOC"; then
2950 dnl Remove /usr/lib, it causes trouble on some systems
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002951 if test "$GUI_LIB_LOC" = /usr/lib \
2952 -o "$GUI_LIB_LOC" = /usr/lib/i386-linux-gnu \
2953 -o "$GUI_LIB_LOC" = /usr/lib/x86_64-linux-gnu; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002954 GUI_LIB_LOC=
2955 AC_MSG_RESULT(in default path)
2956 else
2957 if test -n "$GUI_LIB_LOC"; then
2958 AC_MSG_RESULT($GUI_LIB_LOC)
2959 if test "`(uname) 2>/dev/null`" = SunOS &&
2960 uname -r | grep '^5' >/dev/null; then
2961 GUI_LIB_LOC="$GUI_LIB_LOC -R $GUI_LIB_LOC"
2962 fi
2963 fi
2964 fi
2965 MOTIF_LIBNAME=-lXm
2966 else
2967 AC_MSG_RESULT(<not found>)
2968 SKIP_MOTIF=YES
2969 fi
2970 fi
2971fi
2972
2973if test -z "$SKIP_MOTIF"; then
2974 SKIP_ATHENA=YES
2975 SKIP_NEXTAW=YES
2976 GUITYPE=MOTIF
2977 AC_SUBST(MOTIF_LIBNAME)
2978fi
2979
2980dnl Check if the Athena files can be found
2981
2982GUI_X_LIBS=
2983
2984if test -z "$SKIP_ATHENA"; then
2985 AC_MSG_CHECKING(if Athena header files can be found)
2986 cflags_save=$CFLAGS
2987 CFLAGS="$CFLAGS $X_CFLAGS"
2988 AC_TRY_COMPILE([
2989#include <X11/Intrinsic.h>
2990#include <X11/Xaw/Paned.h>], ,
2991 AC_MSG_RESULT(yes),
2992 AC_MSG_RESULT(no); SKIP_ATHENA=YES )
2993 CFLAGS=$cflags_save
2994fi
2995
2996if test -z "$SKIP_ATHENA"; then
2997 GUITYPE=ATHENA
2998fi
2999
3000if test -z "$SKIP_NEXTAW"; then
3001 AC_MSG_CHECKING(if neXtaw header files can be found)
3002 cflags_save=$CFLAGS
3003 CFLAGS="$CFLAGS $X_CFLAGS"
3004 AC_TRY_COMPILE([
3005#include <X11/Intrinsic.h>
3006#include <X11/neXtaw/Paned.h>], ,
3007 AC_MSG_RESULT(yes),
3008 AC_MSG_RESULT(no); SKIP_NEXTAW=YES )
3009 CFLAGS=$cflags_save
3010fi
3011
3012if test -z "$SKIP_NEXTAW"; then
3013 GUITYPE=NEXTAW
3014fi
3015
3016if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
3017 dnl Prepend -I and -L to $GUI_INC_LOC and $GUI_LIB_LOC if not empty
3018 dnl Avoid adding it when it twice
3019 if test -n "$GUI_INC_LOC"; then
3020 GUI_INC_LOC=-I"`echo $GUI_INC_LOC|sed 's%-I%%'`"
3021 fi
3022 if test -n "$GUI_LIB_LOC"; then
3023 GUI_LIB_LOC=-L"`echo $GUI_LIB_LOC|sed 's%-L%%'`"
3024 fi
3025
3026 dnl Check for -lXext and then for -lXmu
3027 ldflags_save=$LDFLAGS
3028 LDFLAGS="$X_LIBS $LDFLAGS"
3029 AC_CHECK_LIB(Xext, XShapeQueryExtension, [GUI_X_LIBS="-lXext"],,
3030 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3031 dnl For Solaris we need -lw and -ldl before linking with -lXmu works.
3032 AC_CHECK_LIB(w, wslen, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lw"],,
3033 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3034 AC_CHECK_LIB(dl, dlsym, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldl"],,
3035 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3036 AC_CHECK_LIB(Xmu, XmuCreateStippledPixmap, [GUI_X_LIBS="-lXmu $GUI_X_LIBS"],,
3037 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3038 if test -z "$SKIP_MOTIF"; then
3039 AC_CHECK_LIB(Xp, XpEndJob, [GUI_X_LIBS="-lXp $GUI_X_LIBS"],,
3040 [$GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3041 fi
3042 LDFLAGS=$ldflags_save
3043
3044 dnl Execute xmkmf to figure out if -DNARROWPROTO is needed.
3045 AC_MSG_CHECKING(for extra X11 defines)
3046 NARROW_PROTO=
3047 rm -fr conftestdir
3048 if mkdir conftestdir; then
3049 cd conftestdir
3050 cat > Imakefile <<'EOF'
3051acfindx:
3052 @echo 'NARROW_PROTO="${PROTO_DEFINES}"'
3053EOF
3054 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
3055 eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
3056 fi
3057 cd ..
3058 rm -fr conftestdir
3059 fi
3060 if test -z "$NARROW_PROTO"; then
3061 AC_MSG_RESULT(no)
3062 else
3063 AC_MSG_RESULT($NARROW_PROTO)
3064 fi
3065 AC_SUBST(NARROW_PROTO)
3066fi
3067
3068dnl Look for XSMP support - but don't necessarily restrict it to X11 GUIs
3069dnl use the X11 include path
3070if test "$enable_xsmp" = "yes"; then
3071 cppflags_save=$CPPFLAGS
3072 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3073 AC_CHECK_HEADERS(X11/SM/SMlib.h)
3074 CPPFLAGS=$cppflags_save
3075fi
3076
3077
Bram Moolenaar98921892016-02-23 17:14:37 +01003078if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF" -o -z "$SKIP_GTK2" -o -z "$SKIP_GTK3"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003079 dnl Check for X11/xpm.h and X11/Sunkeysym.h with the GUI include path
3080 cppflags_save=$CPPFLAGS
3081 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3082 AC_CHECK_HEADERS(X11/xpm.h X11/Sunkeysym.h)
3083
3084 dnl automatically disable XIM when XIMtext isn't in X11/Xlib.h
3085 if test ! "$enable_xim" = "no"; then
3086 AC_MSG_CHECKING(for XIMText in X11/Xlib.h)
3087 AC_EGREP_CPP(XIMText, [#include <X11/Xlib.h>],
3088 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +02003089 AC_MSG_RESULT(no; xim has been disabled); enable_xim="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00003090 fi
3091 CPPFLAGS=$cppflags_save
3092
Bram Moolenaar54612582019-11-21 17:13:31 +01003093 dnl automatically enable XIM in the GUI
3094 if test "$enable_xim" = "auto" -a "x$GUITYPE" != "xNONE" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003095 AC_MSG_RESULT(X GUI selected; xim has been enabled)
3096 enable_xim="yes"
3097 fi
3098fi
3099
3100if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
3101 cppflags_save=$CPPFLAGS
3102 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00003103dnl Xmu/Editres.h may exist but can only be used after including Intrinsic.h
3104 AC_MSG_CHECKING([for X11/Xmu/Editres.h])
3105 AC_TRY_COMPILE([
3106#include <X11/Intrinsic.h>
3107#include <X11/Xmu/Editres.h>],
3108 [int i; i = 0;],
3109 AC_MSG_RESULT(yes)
3110 AC_DEFINE(HAVE_X11_XMU_EDITRES_H),
3111 AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003112 CPPFLAGS=$cppflags_save
3113fi
3114
3115dnl Only use the Xm directory when compiling Motif, don't use it for Athena
3116if test -z "$SKIP_MOTIF"; then
3117 cppflags_save=$CPPFLAGS
3118 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003119 if test "$zOSUnix" = "yes"; then
3120 xmheader="Xm/Xm.h"
3121 else
3122 xmheader="Xm/Xm.h Xm/XpmP.h Xm/JoinSideT.h Xm/TraitP.h Xm/Manager.h
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02003123 Xm/UnhighlightT.h Xm/Notebook.h"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003124 fi
3125 AC_CHECK_HEADERS($xmheader)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003126
Bram Moolenaar77c19352012-06-13 19:19:41 +02003127 if test "x$ac_cv_header_Xm_XpmP_h" = "xyes"; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003128 dnl Solaris uses XpmAttributes_21, very annoying.
3129 AC_MSG_CHECKING([for XpmAttributes_21 in Xm/XpmP.h])
3130 AC_TRY_COMPILE([#include <Xm/XpmP.h>], [XpmAttributes_21 attr;],
3131 AC_MSG_RESULT(yes); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes_21),
3132 AC_MSG_RESULT(no); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
3133 )
3134 else
Bram Moolenaar57657d82006-04-21 22:12:41 +00003135 AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003136 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003137 CPPFLAGS=$cppflags_save
3138fi
3139
3140if test "x$GUITYPE" = "xNONE" -a "$enable_xim" = "yes"; then
3141 AC_MSG_RESULT(no GUI selected; xim has been disabled)
3142 enable_xim="no"
3143fi
3144if test "x$GUITYPE" = "xNONE" -a "$enable_fontset" = "yes"; then
3145 AC_MSG_RESULT(no GUI selected; fontset has been disabled)
3146 enable_fontset="no"
3147fi
Bram Moolenaar182c5be2010-06-25 05:37:59 +02003148if test "x$GUITYPE:$enable_fontset" = "xGTK:yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003149 AC_MSG_RESULT(GTK+ 2 GUI selected; fontset has been disabled)
3150 enable_fontset="no"
3151fi
3152
Bram Moolenaarb3f74062020-02-26 16:16:53 +01003153dnl There is no test for the Haiku GUI, if it's selected it's used
3154if test -z "$SKIP_HAIKU"; then
3155 GUITYPE=HAIKUGUI
3156fi
3157
Bram Moolenaar071d4272004-06-13 20:20:40 +00003158if test -z "$SKIP_PHOTON"; then
3159 GUITYPE=PHOTONGUI
3160fi
3161
3162AC_SUBST(GUI_INC_LOC)
3163AC_SUBST(GUI_LIB_LOC)
3164AC_SUBST(GUITYPE)
3165AC_SUBST(GUI_X_LIBS)
3166
3167if test "$enable_workshop" = "yes" -a -n "$SKIP_MOTIF"; then
3168 AC_MSG_ERROR([cannot use workshop without Motif])
3169fi
3170
3171dnl defining FEAT_XIM and FEAT_XFONTSET is delayed, so that they can be disabled
3172if test "$enable_xim" = "yes"; then
3173 AC_DEFINE(FEAT_XIM)
3174fi
3175if test "$enable_fontset" = "yes"; then
3176 AC_DEFINE(FEAT_XFONTSET)
3177fi
3178
3179
3180dnl ---------------------------------------------------------------------------
3181dnl end of GUI-checking
3182dnl ---------------------------------------------------------------------------
3183
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003184AC_MSG_CHECKING([for /proc link to executable])
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003185if test -L "/proc/self/exe"; then
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003186 dnl Linux
3187 AC_MSG_RESULT([/proc/self/exe])
3188 AC_DEFINE(PROC_EXE_LINK, "/proc/self/exe")
3189elif test -L "/proc/self/path/a.out"; then
3190 dnl Solaris
3191 AC_MSG_RESULT([/proc/self/path/a.out])
3192 AC_DEFINE(PROC_EXE_LINK, "/proc/self/path/a.out")
3193elif test -L "/proc/curproc/file"; then
3194 dnl FreeBSD
3195 AC_MSG_RESULT([/proc/curproc/file])
3196 AC_DEFINE(PROC_EXE_LINK, "/proc/curproc/file")
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003197else
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003198 AC_MSG_RESULT(no)
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003199fi
3200
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003201dnl Check for Cygwin, which needs an extra source file if not using X11
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003202AC_MSG_CHECKING(for CYGWIN or MSYS environment)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003203case `uname` in
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003204 CYGWIN*|MSYS*) CYGWIN=yes; AC_MSG_RESULT(yes)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003205 AC_MSG_CHECKING(for CYGWIN clipboard support)
3206 if test "x$with_x" = "xno" ; then
3207 OS_EXTRA_SRC=winclip.c; OS_EXTRA_OBJ=objects/winclip.o
3208 AC_MSG_RESULT(yes)
3209 AC_DEFINE(FEAT_CYGWIN_WIN32_CLIPBOARD)
3210 else
3211 AC_MSG_RESULT(no - using X11)
3212 fi ;;
3213
3214 *) CYGWIN=no; AC_MSG_RESULT(no);;
3215esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00003216
Bram Moolenaar071d4272004-06-13 20:20:40 +00003217dnl Checks for libraries and include files.
3218
Bram Moolenaar446cb832008-06-24 21:56:24 +00003219AC_CACHE_CHECK([whether toupper is broken], [vim_cv_toupper_broken],
3220 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003221 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003222#include "confdefs.h"
3223#include <ctype.h>
3224#if STDC_HEADERS
3225# include <stdlib.h>
3226# include <stddef.h>
3227#endif
3228main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003229 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003230 vim_cv_toupper_broken=yes
3231 ],[
3232 vim_cv_toupper_broken=no
3233 ],[
3234 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_toupper_broken')
3235 ])])
3236
3237if test "x$vim_cv_toupper_broken" = "xyes" ; then
3238 AC_DEFINE(BROKEN_TOUPPER)
3239fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003240
3241AC_MSG_CHECKING(whether __DATE__ and __TIME__ work)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003242AC_TRY_COMPILE([#include <stdio.h>], [printf("(" __DATE__ " " __TIME__ ")");],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003243 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DATE_TIME),
3244 AC_MSG_RESULT(no))
3245
Bram Moolenaar0c094b92009-05-14 20:20:33 +00003246AC_MSG_CHECKING(whether __attribute__((unused)) is allowed)
3247AC_TRY_COMPILE([#include <stdio.h>], [int x __attribute__((unused));],
3248 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ATTRIBUTE_UNUSED),
3249 AC_MSG_RESULT(no))
3250
Bram Moolenaar071d4272004-06-13 20:20:40 +00003251dnl Checks for header files.
3252AC_CHECK_HEADER(elf.h, HAS_ELF=1)
3253dnl AC_CHECK_HEADER(dwarf.h, SVR4=1)
3254if test "$HAS_ELF" = 1; then
3255 AC_CHECK_LIB(elf, main)
3256fi
3257
3258AC_HEADER_DIRENT
3259
Bram Moolenaar071d4272004-06-13 20:20:40 +00003260dnl If sys/wait.h is not found it might still exist but not be POSIX
3261dnl compliant. In that case we define HAVE_UNION_WAIT (for NeXT)
3262if test $ac_cv_header_sys_wait_h = no; then
3263 AC_MSG_CHECKING([for sys/wait.h that defines union wait])
3264 AC_TRY_COMPILE([#include <sys/wait.h>],
3265 [union wait xx, yy; xx = yy],
3266 AC_MSG_RESULT(yes)
3267 AC_DEFINE(HAVE_SYS_WAIT_H)
3268 AC_DEFINE(HAVE_UNION_WAIT),
3269 AC_MSG_RESULT(no))
3270fi
3271
Bram Moolenaar779a7752016-01-30 23:26:34 +01003272AC_CHECK_HEADERS(stdint.h stdlib.h string.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003273 sys/select.h sys/utsname.h termcap.h fcntl.h \
3274 sgtty.h sys/ioctl.h sys/time.h sys/types.h \
3275 termio.h iconv.h inttypes.h langinfo.h math.h \
3276 unistd.h stropts.h errno.h sys/resource.h \
3277 sys/systeminfo.h locale.h sys/stream.h termios.h \
3278 libc.h sys/statfs.h poll.h sys/poll.h pwd.h \
Bram Moolenaar1ecc5e42019-01-26 15:12:55 +01003279 utime.h sys/param.h sys/ptms.h libintl.h libgen.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003280 util/debug.h util/msg18n.h frame.h sys/acl.h \
3281 sys/access.h sys/sysinfo.h wchar.h wctype.h)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003282
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003283dnl sys/ptem.h depends on sys/stream.h on Solaris
3284AC_CHECK_HEADERS(sys/ptem.h, [], [],
3285[#if defined HAVE_SYS_STREAM_H
3286# include <sys/stream.h>
3287#endif])
3288
Bram Moolenaar32f31b12009-05-21 13:20:59 +00003289dnl sys/sysctl.h depends on sys/param.h on OpenBSD
3290AC_CHECK_HEADERS(sys/sysctl.h, [], [],
3291[#if defined HAVE_SYS_PARAM_H
3292# include <sys/param.h>
3293#endif])
3294
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003295
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003296dnl pthread_np.h may exist but can only be used after including pthread.h
3297AC_MSG_CHECKING([for pthread_np.h])
3298AC_TRY_COMPILE([
3299#include <pthread.h>
3300#include <pthread_np.h>],
3301 [int i; i = 0;],
3302 AC_MSG_RESULT(yes)
3303 AC_DEFINE(HAVE_PTHREAD_NP_H),
3304 AC_MSG_RESULT(no))
3305
Bram Moolenaare344bea2005-09-01 20:46:49 +00003306AC_CHECK_HEADERS(strings.h)
Bram Moolenaard0573012017-10-28 21:11:06 +02003307if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00003308 dnl The strings.h file on OS/X contains a warning and nothing useful.
3309 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3310else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003311
3312dnl Check if strings.h and string.h can both be included when defined.
3313AC_MSG_CHECKING([if strings.h can be included after string.h])
3314cppflags_save=$CPPFLAGS
3315CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3316AC_TRY_COMPILE([
3317#if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO)
3318# define _NO_PROTO /* like in os_unix.h, causes conflict for AIX (Winn) */
3319 /* but don't do it on AIX 5.1 (Uribarri) */
3320#endif
3321#ifdef HAVE_XM_XM_H
3322# include <Xm/Xm.h> /* This breaks it for HP-UX 11 (Squassabia) */
3323#endif
3324#ifdef HAVE_STRING_H
3325# include <string.h>
3326#endif
3327#if defined(HAVE_STRINGS_H)
3328# include <strings.h>
3329#endif
3330 ], [int i; i = 0;],
3331 AC_MSG_RESULT(yes),
3332 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3333 AC_MSG_RESULT(no))
3334CPPFLAGS=$cppflags_save
Bram Moolenaar9372a112005-12-06 19:59:18 +00003335fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003336
3337dnl Checks for typedefs, structures, and compiler characteristics.
3338AC_PROG_GCC_TRADITIONAL
3339AC_C_CONST
Bram Moolenaar76243bd2009-03-02 01:47:02 +00003340AC_C_VOLATILE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003341AC_TYPE_MODE_T
3342AC_TYPE_OFF_T
3343AC_TYPE_PID_T
3344AC_TYPE_SIZE_T
3345AC_TYPE_UID_T
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003346AC_TYPE_UINT32_T
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003347
Bram Moolenaar071d4272004-06-13 20:20:40 +00003348AC_HEADER_TIME
3349AC_CHECK_TYPE(ino_t, long)
3350AC_CHECK_TYPE(dev_t, unsigned)
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003351AC_C_BIGENDIAN(,,,)
Bram Moolenaar136f29a2016-02-27 20:14:15 +01003352AC_C_INLINE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003353
3354AC_MSG_CHECKING(for rlim_t)
3355if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
3356 AC_MSG_RESULT([(cached) $ac_cv_type_rlim_t])
3357else
3358 AC_EGREP_CPP(dnl
3359changequote(<<,>>)dnl
3360<<(^|[^a-zA-Z_0-9])rlim_t[^a-zA-Z_0-9]>>dnl
3361changequote([,]),
3362 [
3363#include <sys/types.h>
3364#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003365# include <stdlib.h>
3366# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003367#endif
3368#ifdef HAVE_SYS_RESOURCE_H
Bram Moolenaar446cb832008-06-24 21:56:24 +00003369# include <sys/resource.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003370#endif
3371 ], ac_cv_type_rlim_t=yes, ac_cv_type_rlim_t=no)
3372 AC_MSG_RESULT($ac_cv_type_rlim_t)
3373fi
3374if test $ac_cv_type_rlim_t = no; then
3375 cat >> confdefs.h <<\EOF
3376#define rlim_t unsigned long
3377EOF
3378fi
3379
3380AC_MSG_CHECKING(for stack_t)
3381if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then
3382 AC_MSG_RESULT([(cached) $ac_cv_type_stack_t])
3383else
3384 AC_EGREP_CPP(stack_t,
3385 [
3386#include <sys/types.h>
3387#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003388# include <stdlib.h>
3389# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003390#endif
3391#include <signal.h>
3392 ], ac_cv_type_stack_t=yes, ac_cv_type_stack_t=no)
3393 AC_MSG_RESULT($ac_cv_type_stack_t)
3394fi
3395if test $ac_cv_type_stack_t = no; then
3396 cat >> confdefs.h <<\EOF
3397#define stack_t struct sigaltstack
3398EOF
3399fi
3400
3401dnl BSDI uses ss_base while others use ss_sp for the stack pointer.
3402AC_MSG_CHECKING(whether stack_t has an ss_base field)
3403AC_TRY_COMPILE([
3404#include <sys/types.h>
3405#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003406# include <stdlib.h>
3407# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003408#endif
3409#include <signal.h>
3410#include "confdefs.h"
3411 ], [stack_t sigstk; sigstk.ss_base = 0; ],
3412 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SS_BASE),
3413 AC_MSG_RESULT(no))
3414
3415olibs="$LIBS"
3416AC_MSG_CHECKING(--with-tlib argument)
3417AC_ARG_WITH(tlib, [ --with-tlib=library terminal library to be used ],)
3418if test -n "$with_tlib"; then
3419 AC_MSG_RESULT($with_tlib)
3420 LIBS="$LIBS -l$with_tlib"
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003421 AC_MSG_CHECKING(for linking with $with_tlib library)
3422 AC_TRY_LINK([], [], AC_MSG_RESULT(OK), AC_MSG_ERROR(FAILED))
3423 dnl Need to check for tgetent() below.
3424 olibs="$LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003425else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003426 AC_MSG_RESULT([empty: automatic terminal library selection])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003427 dnl On HP-UX 10.10 termcap or termlib should be used instead of
3428 dnl curses, because curses is much slower.
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003429 dnl Newer versions of ncurses are preferred over anything, except
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02003430 dnl when tinfo has been split off, it contains all we need.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003431 dnl Older versions of ncurses have bugs, get a new one!
3432 dnl Digital Unix (OSF1) should use curses (Ronald Schild).
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00003433 dnl On SCO Openserver should prefer termlib (Roger Cornelius).
Bram Moolenaar071d4272004-06-13 20:20:40 +00003434 case "`uname -s 2>/dev/null`" in
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003435 OSF1|SCO_SV) tlibs="tinfo ncurses curses termlib termcap";;
3436 *) tlibs="tinfo ncurses termlib termcap curses";;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003437 esac
3438 for libname in $tlibs; do
3439 AC_CHECK_LIB(${libname}, tgetent,,)
3440 if test "x$olibs" != "x$LIBS"; then
3441 dnl It's possible that a library is found but it doesn't work
3442 dnl e.g., shared library that cannot be found
3443 dnl compile and run a test program to be sure
3444 AC_TRY_RUN([
3445#ifdef HAVE_TERMCAP_H
3446# include <termcap.h>
3447#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003448#if STDC_HEADERS
3449# include <stdlib.h>
3450# include <stddef.h>
3451#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003452main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }],
3453 res="OK", res="FAIL", res="FAIL")
3454 if test "$res" = "OK"; then
3455 break
3456 fi
3457 AC_MSG_RESULT($libname library is not usable)
3458 LIBS="$olibs"
3459 fi
3460 done
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003461 if test "x$olibs" = "x$LIBS"; then
3462 AC_MSG_RESULT(no terminal library found)
3463 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003464fi
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003465
3466if test "x$olibs" = "x$LIBS"; then
3467 AC_MSG_CHECKING([for tgetent()])
Bram Moolenaarbd7f7c12020-07-28 21:03:37 +02003468 AC_TRY_LINK([int tgetent(char *, const char *);],
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003469 [char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");],
3470 AC_MSG_RESULT(yes),
3471 AC_MSG_ERROR([NOT FOUND!
3472 You need to install a terminal library; for example ncurses.
3473 Or specify the name of the library with --with-tlib.]))
3474fi
3475
Bram Moolenaar446cb832008-06-24 21:56:24 +00003476AC_CACHE_CHECK([whether we talk terminfo], [vim_cv_terminfo],
3477 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003478 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003479#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003480#ifdef HAVE_TERMCAP_H
3481# include <termcap.h>
3482#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003483#ifdef HAVE_STRING_H
3484# include <string.h>
3485#endif
3486#if STDC_HEADERS
3487# include <stdlib.h>
3488# include <stddef.h>
3489#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003490main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003491{char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003492 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003493 vim_cv_terminfo=no
3494 ],[
3495 vim_cv_terminfo=yes
3496 ],[
3497 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_terminfo')
3498 ])
3499 ])
3500
3501if test "x$vim_cv_terminfo" = "xyes" ; then
3502 AC_DEFINE(TERMINFO)
3503fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003504
Bram Moolenaara88254f2017-11-02 23:04:14 +01003505AC_CACHE_CHECK([what tgetent() returns for an unknown terminal], [vim_cv_tgetent],
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003506 [
3507 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003508#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003509#ifdef HAVE_TERMCAP_H
3510# include <termcap.h>
3511#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003512#if STDC_HEADERS
3513# include <stdlib.h>
3514# include <stddef.h>
3515#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003516main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003517{char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003518 ]])],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003519 vim_cv_tgetent=zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003520 ],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003521 vim_cv_tgetent=non-zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003522 ],[
3523 AC_MSG_ERROR(failed to compile test program.)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003524 ])
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003525 ])
3526
Bram Moolenaara88254f2017-11-02 23:04:14 +01003527if test "x$vim_cv_tgetent" = "xzero" ; then
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003528 AC_DEFINE(TGETENT_ZERO_ERR, 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003529fi
3530
3531AC_MSG_CHECKING(whether termcap.h contains ospeed)
3532AC_TRY_LINK([
3533#ifdef HAVE_TERMCAP_H
3534# include <termcap.h>
3535#endif
3536 ], [ospeed = 20000],
3537 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED),
3538 [AC_MSG_RESULT(no)
3539 AC_MSG_CHECKING(whether ospeed can be extern)
3540 AC_TRY_LINK([
3541#ifdef HAVE_TERMCAP_H
3542# include <termcap.h>
3543#endif
3544extern short ospeed;
3545 ], [ospeed = 20000],
3546 AC_MSG_RESULT(yes); AC_DEFINE(OSPEED_EXTERN),
3547 AC_MSG_RESULT(no))]
3548 )
3549
3550AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC])
3551AC_TRY_LINK([
3552#ifdef HAVE_TERMCAP_H
3553# include <termcap.h>
3554#endif
3555 ], [if (UP == 0 && BC == 0) PC = 1],
3556 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UP_BC_PC),
3557 [AC_MSG_RESULT(no)
3558 AC_MSG_CHECKING([whether UP, BC and PC can be extern])
3559 AC_TRY_LINK([
3560#ifdef HAVE_TERMCAP_H
3561# include <termcap.h>
3562#endif
3563extern char *UP, *BC, PC;
3564 ], [if (UP == 0 && BC == 0) PC = 1],
3565 AC_MSG_RESULT(yes); AC_DEFINE(UP_BC_PC_EXTERN),
3566 AC_MSG_RESULT(no))]
3567 )
3568
3569AC_MSG_CHECKING(whether tputs() uses outfuntype)
3570AC_TRY_COMPILE([
3571#ifdef HAVE_TERMCAP_H
3572# include <termcap.h>
3573#endif
3574 ], [extern int xx(); tputs("test", 1, (outfuntype)xx)],
3575 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OUTFUNTYPE),
3576 AC_MSG_RESULT(no))
3577
3578dnl On some SCO machines sys/select redefines struct timeval
3579AC_MSG_CHECKING([whether sys/select.h and sys/time.h may both be included])
3580AC_TRY_COMPILE([
3581#include <sys/types.h>
3582#include <sys/time.h>
3583#include <sys/select.h>], ,
3584 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 Moolenaarce7be3a2020-11-26 20:11:11 +01003601 AC_TRY_LINK([
3602// 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);
3609 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
3645AC_TYPE_SIGNAL
3646
3647dnl find out what to use at the end of a signal function
3648if test $ac_cv_type_signal = void; then
3649 AC_DEFINE(SIGRETURN, [return])
3650else
3651 AC_DEFINE(SIGRETURN, [return 0])
3652fi
3653
3654dnl check if struct sigcontext is defined (used for SGI only)
3655AC_MSG_CHECKING(for struct sigcontext)
3656AC_TRY_COMPILE([
3657#include <signal.h>
3658test_sig()
3659{
3660 struct sigcontext *scont;
3661 scont = (struct sigcontext *)0;
3662 return 1;
3663} ], ,
3664 AC_MSG_RESULT(yes)
3665 AC_DEFINE(HAVE_SIGCONTEXT),
3666 AC_MSG_RESULT(no))
3667
3668dnl tricky stuff: try to find out if getcwd() is implemented with
3669dnl system("sh -c pwd")
Bram Moolenaar446cb832008-06-24 21:56:24 +00003670AC_CACHE_CHECK([getcwd implementation is broken], [vim_cv_getcwd_broken],
3671 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003672 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003673#include "confdefs.h"
3674#ifdef HAVE_UNISTD_H
3675#include <unistd.h>
3676#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003677char *dagger[] = { "IFS=pwd", 0 };
3678main()
3679{
3680 char buffer[500];
3681 extern char **environ;
3682 environ = dagger;
3683 return getcwd(buffer, 500) ? 0 : 1;
Bram Moolenaar446cb832008-06-24 21:56:24 +00003684}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003685 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003686 vim_cv_getcwd_broken=no
3687 ],[
3688 vim_cv_getcwd_broken=yes
3689 ],[
3690 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_getcwd_broken')
3691 ])
3692 ])
3693
3694if test "x$vim_cv_getcwd_broken" = "xyes" ; then
3695 AC_DEFINE(BAD_GETCWD)
Bram Moolenaar63d25552019-05-10 21:28:38 +02003696 AC_CHECK_FUNCS(getwd)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003697fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003698
Bram Moolenaar25153e12010-02-24 14:47:08 +01003699dnl Check for functions in one big call, to reduce the size of configure.
3700dnl Can only be used for functions that do not require any include.
Bram Moolenaarcd142e32017-11-16 17:03:45 +01003701AC_CHECK_FUNCS(fchdir fchown fchmod fsync getcwd getpseudotty \
Bram Moolenaar63d25552019-05-10 21:28:38 +02003702 getpwent getpwnam getpwuid getrlimit gettimeofday localtime_r lstat \
Bram Moolenaareaf03392009-11-17 11:08:52 +00003703 memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
Bram Moolenaar2fcf6682017-03-11 20:03:42 +01003704 getpgid setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
Bram Moolenaar84cf6bd2020-06-16 20:03:43 +02003705 sigprocmask sigvec strcasecmp strcoll strerror strftime stricmp strncasecmp \
Bram Moolenaar10455d42019-11-21 15:36:18 +01003706 strnicmp strpbrk strptime strtol tgetent towlower towupper iswupper \
3707 tzset usleep utime utimes mblen ftruncate unsetenv posix_openpt)
Bram Moolenaar643b6142018-09-12 20:29:09 +02003708AC_FUNC_SELECT_ARGTYPES
Bram Moolenaar25153e12010-02-24 14:47:08 +01003709AC_FUNC_FSEEKO
Bram Moolenaar071d4272004-06-13 20:20:40 +00003710
Bram Moolenaar317fd3a2010-05-07 16:05:55 +02003711dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when
3712dnl appropriate, so that off_t is 64 bits when needed.
3713AC_SYS_LARGEFILE
3714
Bram Moolenaar21606672019-06-14 20:40:58 +02003715AC_MSG_CHECKING(--enable-canberra argument)
3716AC_ARG_ENABLE(canberra,
3717 [ --disable-canberra Do not use libcanberra.],
3718 , [enable_canberra="maybe"])
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003719
Bram Moolenaar21606672019-06-14 20:40:58 +02003720if test "$enable_canberra" = "maybe"; then
3721 if test "$features" = "big" -o "$features" = "huge"; then
3722 AC_MSG_RESULT(Defaulting to yes)
3723 enable_canberra="yes"
3724 else
3725 AC_MSG_RESULT(Defaulting to no)
3726 enable_canberra="no"
3727 fi
3728else
3729 AC_MSG_RESULT($enable_canberra)
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003730fi
Bram Moolenaar21606672019-06-14 20:40:58 +02003731if test "$enable_canberra" = "yes"; then
3732 if test "x$PKG_CONFIG" != "xno"; then
3733 canberra_lib=`$PKG_CONFIG --libs libcanberra 2>/dev/null`
3734 canberra_cflags=`$PKG_CONFIG --cflags libcanberra 2>/dev/null`
3735 fi
3736 if test "x$canberra_lib" = "x"; then
3737 canberra_lib=-lcanberra
3738 canberra_cflags=-D_REENTRANT
3739 fi
3740 AC_MSG_CHECKING(for libcanberra)
3741 ac_save_CFLAGS="$CFLAGS"
3742 ac_save_LIBS="$LIBS"
3743 CFLAGS="$CFLAGS $canberra_cflags"
3744 LIBS="$LIBS $canberra_lib"
3745 AC_TRY_LINK([
3746 # include <canberra.h>
3747 ], [
3748 ca_context *hello;
3749 ca_context_create(&hello);],
3750 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_CANBERRA),
Bram Moolenaar91b992c2019-11-17 19:07:42 +01003751 AC_MSG_RESULT(no; try installing libcanberra-dev); CFLAGS="$ac_save_CFLAGS"; LIBS="$ac_save_LIBS")
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003752fi
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003753
3754
Bram Moolenaar071d4272004-06-13 20:20:40 +00003755dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible
3756AC_MSG_CHECKING(for st_blksize)
3757AC_TRY_COMPILE(
3758[#include <sys/types.h>
3759#include <sys/stat.h>],
3760[ struct stat st;
3761 int n;
3762
3763 stat("/", &st);
3764 n = (int)st.st_blksize;],
3765 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ST_BLKSIZE),
3766 AC_MSG_RESULT(no))
3767
Bram Moolenaar446cb832008-06-24 21:56:24 +00003768AC_CACHE_CHECK([whether stat() ignores a trailing slash], [vim_cv_stat_ignores_slash],
3769 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003770 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003771#include "confdefs.h"
3772#if STDC_HEADERS
3773# include <stdlib.h>
3774# include <stddef.h>
3775#endif
3776#include <sys/types.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003777#include <sys/stat.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003778main() {struct stat st; exit(stat("configure/", &st) != 0); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003779 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003780 vim_cv_stat_ignores_slash=yes
3781 ],[
3782 vim_cv_stat_ignores_slash=no
3783 ],[
3784 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_stat_ignores_slash')
3785 ])
3786 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003787
Bram Moolenaar446cb832008-06-24 21:56:24 +00003788if test "x$vim_cv_stat_ignores_slash" = "xyes" ; then
3789 AC_DEFINE(STAT_IGNORES_SLASH)
3790fi
3791
Bram Moolenaar071d4272004-06-13 20:20:40 +00003792dnl Link with iconv for charset translation, if not found without library.
3793dnl check for iconv() requires including iconv.h
3794dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
3795dnl has been installed.
3796AC_MSG_CHECKING(for iconv_open())
3797save_LIBS="$LIBS"
3798LIBS="$LIBS -liconv"
3799AC_TRY_LINK([
3800#ifdef HAVE_ICONV_H
3801# include <iconv.h>
3802#endif
3803 ], [iconv_open("fr", "to");],
3804 AC_MSG_RESULT(yes; with -liconv); AC_DEFINE(HAVE_ICONV),
3805 LIBS="$save_LIBS"
3806 AC_TRY_LINK([
3807#ifdef HAVE_ICONV_H
3808# include <iconv.h>
3809#endif
3810 ], [iconv_open("fr", "to");],
3811 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ICONV),
3812 AC_MSG_RESULT(no)))
3813
3814
3815AC_MSG_CHECKING(for nl_langinfo(CODESET))
3816AC_TRY_LINK([
3817#ifdef HAVE_LANGINFO_H
3818# include <langinfo.h>
3819#endif
3820], [char *cs = nl_langinfo(CODESET);],
3821 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET),
3822 AC_MSG_RESULT(no))
3823
Bram Moolenaar446cb832008-06-24 21:56:24 +00003824dnl Need various functions for floating point support. Only enable
3825dnl floating point when they are all present.
3826AC_CHECK_LIB(m, strtod)
3827AC_MSG_CHECKING([for strtod() and other floating point functions])
3828AC_TRY_LINK([
3829#ifdef HAVE_MATH_H
3830# include <math.h>
3831#endif
3832#if STDC_HEADERS
3833# include <stdlib.h>
3834# include <stddef.h>
3835#endif
3836], [char *s; double d;
3837 d = strtod("1.1", &s);
3838 d = fabs(1.11);
3839 d = ceil(1.11);
3840 d = floor(1.11);
3841 d = log10(1.11);
3842 d = pow(1.11, 2.22);
3843 d = sqrt(1.11);
3844 d = sin(1.11);
3845 d = cos(1.11);
3846 d = atan(1.11);
3847 ],
3848 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT_FUNCS),
3849 AC_MSG_RESULT(no))
3850
Bram Moolenaara6b89762016-02-29 21:38:26 +01003851dnl isinf() and isnan() need to include header files and may need -lm.
3852AC_MSG_CHECKING([for isinf()])
3853AC_TRY_LINK([
3854#ifdef HAVE_MATH_H
3855# include <math.h>
3856#endif
3857#if STDC_HEADERS
3858# include <stdlib.h>
3859# include <stddef.h>
3860#endif
3861], [int r = isinf(1.11); ],
3862 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISINF),
3863 AC_MSG_RESULT(no))
3864
3865AC_MSG_CHECKING([for isnan()])
3866AC_TRY_LINK([
3867#ifdef HAVE_MATH_H
3868# include <math.h>
3869#endif
3870#if STDC_HEADERS
3871# include <stdlib.h>
3872# include <stddef.h>
3873#endif
3874], [int r = isnan(1.11); ],
3875 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISNAN),
3876 AC_MSG_RESULT(no))
3877
Bram Moolenaar071d4272004-06-13 20:20:40 +00003878dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI
3879dnl when -lacl works, also try to use -lattr (required for Debian).
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003880dnl On Solaris, use the acl_get/set functions in libsec, if present.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003881AC_MSG_CHECKING(--disable-acl argument)
3882AC_ARG_ENABLE(acl,
Bram Moolenaard6d30422018-01-28 22:48:55 +01003883 [ --disable-acl No check for ACL support.],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003884 , [enable_acl="yes"])
3885if test "$enable_acl" = "yes"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01003886 AC_MSG_RESULT(no)
3887 AC_CHECK_LIB(posix1e, acl_get_file, [LIBS="$LIBS -lposix1e"],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003888 AC_CHECK_LIB(acl, acl_get_file, [LIBS="$LIBS -lacl"
3889 AC_CHECK_LIB(attr, fgetxattr, LIBS="$LIBS -lattr",,)],,),)
3890
Bram Moolenaard6d30422018-01-28 22:48:55 +01003891 AC_MSG_CHECKING(for POSIX ACL support)
3892 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003893#include <sys/types.h>
3894#ifdef HAVE_SYS_ACL_H
3895# include <sys/acl.h>
3896#endif
3897acl_t acl;], [acl = acl_get_file("foo", ACL_TYPE_ACCESS);
3898 acl_set_file("foo", ACL_TYPE_ACCESS, acl);
3899 acl_free(acl);],
3900 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_ACL),
3901 AC_MSG_RESULT(no))
3902
Bram Moolenaard6d30422018-01-28 22:48:55 +01003903 AC_CHECK_LIB(sec, acl_get, [LIBS="$LIBS -lsec"; AC_DEFINE(HAVE_SOLARIS_ZFS_ACL)],
3904 AC_MSG_CHECKING(for Solaris ACL support)
3905 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003906#ifdef HAVE_SYS_ACL_H
3907# include <sys/acl.h>
3908#endif], [acl("foo", GETACLCNT, 0, NULL);
3909 ],
3910 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOLARIS_ACL),
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003911 AC_MSG_RESULT(no)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003912
Bram Moolenaard6d30422018-01-28 22:48:55 +01003913 AC_MSG_CHECKING(for AIX ACL support)
3914 AC_TRY_LINK([
Bram Moolenaar446cb832008-06-24 21:56:24 +00003915#if STDC_HEADERS
3916# include <stdlib.h>
3917# include <stddef.h>
3918#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003919#ifdef HAVE_SYS_ACL_H
3920# include <sys/acl.h>
3921#endif
3922#ifdef HAVE_SYS_ACCESS_H
3923# include <sys/access.h>
3924#endif
3925#define _ALL_SOURCE
3926
3927#include <sys/stat.h>
3928
3929int aclsize;
3930struct acl *aclent;], [aclsize = sizeof(struct acl);
3931 aclent = (void *)malloc(aclsize);
3932 statacl("foo", STX_NORMAL, aclent, aclsize);
3933 ],
3934 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_AIX_ACL),
3935 AC_MSG_RESULT(no))
3936else
3937 AC_MSG_RESULT(yes)
3938fi
3939
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02003940if test "x$GTK_CFLAGS" != "x"; then
3941 dnl pango_shape_full() is new, fall back to pango_shape().
3942 AC_MSG_CHECKING(for pango_shape_full)
3943 ac_save_CFLAGS="$CFLAGS"
3944 ac_save_LIBS="$LIBS"
3945 CFLAGS="$CFLAGS $GTK_CFLAGS"
3946 LIBS="$LIBS $GTK_LIBS"
Bram Moolenaar5325b9b2015-09-09 20:27:02 +02003947 AC_TRY_LINK(
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02003948 [#include <gtk/gtk.h>],
3949 [ pango_shape_full(NULL, 0, NULL, 0, NULL, NULL); ],
3950 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_PANGO_SHAPE_FULL),
3951 AC_MSG_RESULT(no))
3952 CFLAGS="$ac_save_CFLAGS"
3953 LIBS="$ac_save_LIBS"
3954fi
3955
Bram Moolenaar071d4272004-06-13 20:20:40 +00003956AC_MSG_CHECKING(--disable-gpm argument)
3957AC_ARG_ENABLE(gpm,
3958 [ --disable-gpm Don't use gpm (Linux mouse daemon).], ,
3959 [enable_gpm="yes"])
3960
3961if test "$enable_gpm" = "yes"; then
3962 AC_MSG_RESULT(no)
3963 dnl Checking if gpm support can be compiled
3964 AC_CACHE_CHECK([for gpm], vi_cv_have_gpm,
3965 [olibs="$LIBS" ; LIBS="-lgpm"]
3966 AC_TRY_LINK(
3967 [#include <gpm.h>
3968 #include <linux/keyboard.h>],
3969 [Gpm_GetLibVersion(NULL);],
3970 dnl Configure defines HAVE_GPM, if it is defined feature.h defines
3971 dnl FEAT_MOUSE_GPM if mouse support is included
3972 [vi_cv_have_gpm=yes],
3973 [vi_cv_have_gpm=no])
3974 [LIBS="$olibs"]
3975 )
3976 if test $vi_cv_have_gpm = yes; then
3977 LIBS="$LIBS -lgpm"
3978 AC_DEFINE(HAVE_GPM)
3979 fi
3980else
3981 AC_MSG_RESULT(yes)
3982fi
3983
Bram Moolenaar446cb832008-06-24 21:56:24 +00003984AC_MSG_CHECKING(--disable-sysmouse argument)
3985AC_ARG_ENABLE(sysmouse,
Bram Moolenaar8008b632017-07-18 21:33:20 +02003986 [ --disable-sysmouse Don't use sysmouse (mouse in *BSD console).], ,
Bram Moolenaar446cb832008-06-24 21:56:24 +00003987 [enable_sysmouse="yes"])
3988
3989if test "$enable_sysmouse" = "yes"; then
3990 AC_MSG_RESULT(no)
3991 dnl Checking if sysmouse support can be compiled
3992 dnl Configure defines HAVE_SYSMOUSE, if it is defined feature.h
3993 dnl defines FEAT_SYSMOUSE if mouse support is included
3994 AC_CACHE_CHECK([for sysmouse], vi_cv_have_sysmouse,
3995 AC_TRY_LINK(
3996 [#include <sys/consio.h>
3997 #include <signal.h>
3998 #include <sys/fbio.h>],
3999 [struct mouse_info mouse;
4000 mouse.operation = MOUSE_MODE;
4001 mouse.operation = MOUSE_SHOW;
4002 mouse.u.mode.mode = 0;
4003 mouse.u.mode.signal = SIGUSR2;],
4004 [vi_cv_have_sysmouse=yes],
4005 [vi_cv_have_sysmouse=no])
4006 )
4007 if test $vi_cv_have_sysmouse = yes; then
4008 AC_DEFINE(HAVE_SYSMOUSE)
4009 fi
4010else
4011 AC_MSG_RESULT(yes)
4012fi
4013
Bram Moolenaarf05da212009-11-17 16:13:15 +00004014dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
4015AC_MSG_CHECKING(for FD_CLOEXEC)
4016AC_TRY_COMPILE(
4017[#if HAVE_FCNTL_H
4018# include <fcntl.h>
4019#endif],
4020[ int flag = FD_CLOEXEC;],
4021 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
4022 AC_MSG_RESULT(not usable))
4023
Bram Moolenaar071d4272004-06-13 20:20:40 +00004024dnl rename needs to be checked separately to work on Nextstep with cc
4025AC_MSG_CHECKING(for rename)
4026AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
4027 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
4028 AC_MSG_RESULT(no))
4029
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004030dnl check for dirfd()
4031AC_MSG_CHECKING(for dirfd)
Bram Moolenaar9d8bfae2020-09-02 21:21:35 +02004032AC_TRY_LINK(
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004033[#include <sys/types.h>
4034#include <dirent.h>],
4035[DIR * dir=opendir("dirname"); dirfd(dir);],
4036AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DIRFD), AC_MSG_RESULT(not usable))
4037
4038dnl check for flock()
4039AC_MSG_CHECKING(for flock)
Bram Moolenaar9d8bfae2020-09-02 21:21:35 +02004040AC_TRY_LINK(
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004041[#include <sys/file.h>],
4042[flock(10, LOCK_SH);],
4043AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOCK), AC_MSG_RESULT(not usable))
4044
Bram Moolenaar071d4272004-06-13 20:20:40 +00004045dnl sysctl() may exist but not the arguments we use
4046AC_MSG_CHECKING(for sysctl)
4047AC_TRY_COMPILE(
4048[#include <sys/types.h>
4049#include <sys/sysctl.h>],
4050[ int mib[2], r;
4051 size_t len;
4052
4053 mib[0] = CTL_HW;
4054 mib[1] = HW_USERMEM;
4055 len = sizeof(r);
4056 (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
4057 ],
4058 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL),
4059 AC_MSG_RESULT(not usable))
4060
4061dnl sysinfo() may exist but not be Linux compatible
4062AC_MSG_CHECKING(for sysinfo)
4063AC_TRY_COMPILE(
4064[#include <sys/types.h>
4065#include <sys/sysinfo.h>],
4066[ struct sysinfo sinfo;
4067 int t;
4068
4069 (void)sysinfo(&sinfo);
4070 t = sinfo.totalram;
4071 ],
4072 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
4073 AC_MSG_RESULT(not usable))
4074
Bram Moolenaar914572a2007-05-01 11:37:47 +00004075dnl struct sysinfo may have the mem_unit field or not
4076AC_MSG_CHECKING(for sysinfo.mem_unit)
4077AC_TRY_COMPILE(
4078[#include <sys/types.h>
4079#include <sys/sysinfo.h>],
4080[ struct sysinfo sinfo;
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02004081 sinfo.mem_unit = 1;
Bram Moolenaar914572a2007-05-01 11:37:47 +00004082 ],
4083 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_MEM_UNIT),
4084 AC_MSG_RESULT(no))
4085
Bram Moolenaar071d4272004-06-13 20:20:40 +00004086dnl sysconf() may exist but not support what we want to use
4087AC_MSG_CHECKING(for sysconf)
4088AC_TRY_COMPILE(
4089[#include <unistd.h>],
4090[ (void)sysconf(_SC_PAGESIZE);
4091 (void)sysconf(_SC_PHYS_PAGES);
4092 ],
4093 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
4094 AC_MSG_RESULT(not usable))
4095
Bram Moolenaar914703b2010-05-31 21:59:46 +02004096AC_CHECK_SIZEOF([int])
4097AC_CHECK_SIZEOF([long])
4098AC_CHECK_SIZEOF([time_t])
4099AC_CHECK_SIZEOF([off_t])
Bram Moolenaar644fdff2010-05-30 13:26:21 +02004100
Bram Moolenaara2aa31a2014-02-23 22:52:40 +01004101dnl Use different names to avoid clashing with other header files.
4102AC_DEFINE_UNQUOTED(VIM_SIZEOF_INT, [$ac_cv_sizeof_int])
4103AC_DEFINE_UNQUOTED(VIM_SIZEOF_LONG, [$ac_cv_sizeof_long])
4104
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004105dnl Make sure that uint32_t is really 32 bits unsigned.
4106AC_MSG_CHECKING([uint32_t is 32 bits])
4107AC_TRY_RUN([
4108#ifdef HAVE_STDINT_H
4109# include <stdint.h>
4110#endif
4111#ifdef HAVE_INTTYPES_H
4112# include <inttypes.h>
4113#endif
4114main() {
4115 uint32_t nr1 = (uint32_t)-1;
4116 uint32_t nr2 = (uint32_t)0xffffffffUL;
Bram Moolenaar52897832020-07-02 22:50:37 +02004117 if (sizeof(uint32_t) != 4 || nr1 != 0xffffffffUL || nr2 + 1 != 0) return 1;
4118 return 0;
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004119}],
4120AC_MSG_RESULT(ok),
4121AC_MSG_ERROR([WRONG! uint32_t not defined correctly.]),
Bram Moolenaar323cb952011-12-14 19:22:34 +01004122AC_MSG_WARN([cannot check uint32_t when cross-compiling.]))
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004123
Bram Moolenaar446cb832008-06-24 21:56:24 +00004124dnl Check for memmove() before bcopy(), makes memmove() be used when both are
4125dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
4126
Bram Moolenaar071d4272004-06-13 20:20:40 +00004127[bcopy_test_prog='
Bram Moolenaar446cb832008-06-24 21:56:24 +00004128#include "confdefs.h"
4129#ifdef HAVE_STRING_H
4130# include <string.h>
4131#endif
4132#if STDC_HEADERS
4133# include <stdlib.h>
4134# include <stddef.h>
4135#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004136main() {
4137 char buf[10];
4138 strcpy(buf, "abcdefghi");
4139 mch_memmove(buf, buf + 2, 3);
4140 if (strncmp(buf, "ababcf", 6))
4141 exit(1);
4142 strcpy(buf, "abcdefghi");
4143 mch_memmove(buf + 2, buf, 3);
4144 if (strncmp(buf, "cdedef", 6))
4145 exit(1);
4146 exit(0); /* libc version works properly. */
4147}']
4148
Bram Moolenaar446cb832008-06-24 21:56:24 +00004149AC_CACHE_CHECK([whether memmove handles overlaps],[vim_cv_memmove_handles_overlap],
4150 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004151 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 +00004152 [
4153 vim_cv_memmove_handles_overlap=yes
4154 ],[
4155 vim_cv_memmove_handles_overlap=no
4156 ],[
4157 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memmove_handles_overlap')
4158 ])
4159 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00004160
Bram Moolenaar446cb832008-06-24 21:56:24 +00004161if test "x$vim_cv_memmove_handles_overlap" = "xyes" ; then
4162 AC_DEFINE(USEMEMMOVE)
4163else
4164 AC_CACHE_CHECK([whether bcopy handles overlaps],[vim_cv_bcopy_handles_overlap],
4165 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004166 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 +00004167 [
4168 vim_cv_bcopy_handles_overlap=yes
4169 ],[
4170 vim_cv_bcopy_handles_overlap=no
4171 ],[
4172 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_bcopy_handles_overlap')
4173 ])
4174 ])
4175
4176 if test "x$vim_cv_bcopy_handles_overlap" = "xyes" ; then
4177 AC_DEFINE(USEBCOPY)
4178 else
4179 AC_CACHE_CHECK([whether memcpy handles overlaps],[vim_cv_memcpy_handles_overlap],
4180 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004181 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 +00004182 [
4183 vim_cv_memcpy_handles_overlap=yes
4184 ],[
4185 vim_cv_memcpy_handles_overlap=no
4186 ],[
4187 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memcpy_handles_overlap')
4188 ])
4189 ])
4190
4191 if test "x$vim_cv_memcpy_handles_overlap" = "xyes" ; then
4192 AC_DEFINE(USEMEMCPY)
4193 fi
4194 fi
4195fi
4196
Bram Moolenaar071d4272004-06-13 20:20:40 +00004197
4198dnl Check for multibyte locale functions
4199dnl Find out if _Xsetlocale() is supported by libX11.
4200dnl Check if X_LOCALE should be defined.
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004201if test "x$with_x" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004202 cflags_save=$CFLAGS
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004203 libs_save=$LIBS
4204 LIBS="$LIBS $X_LIBS $GUI_LIB_LOC $GUI_X_LIBS $X_PRE_LIBS $X_LIB $X_EXTRA_LIBS"
4205 CFLAGS="$CFLAGS $X_CFLAGS"
4206
4207 AC_MSG_CHECKING(whether X_LOCALE needed)
4208 AC_TRY_COMPILE([#include <X11/Xlocale.h>],,
4209 AC_TRY_LINK_FUNC([_Xsetlocale], [AC_MSG_RESULT(yes)
4210 AC_DEFINE(X_LOCALE)], AC_MSG_RESULT(no)),
4211 AC_MSG_RESULT(no))
4212
4213 AC_MSG_CHECKING(whether Xutf8SetWMProperties() can be used)
4214 AC_TRY_LINK_FUNC([Xutf8SetWMProperties], [AC_MSG_RESULT(yes)
4215 AC_DEFINE(HAVE_XUTF8SETWMPROPERTIES)], AC_MSG_RESULT(no))
4216
Bram Moolenaar071d4272004-06-13 20:20:40 +00004217 CFLAGS=$cflags_save
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004218 LIBS=$libs_save
Bram Moolenaar071d4272004-06-13 20:20:40 +00004219fi
4220
4221dnl Link with xpg4, it is said to make Korean locale working
4222AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,)
4223
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004224dnl Check how we can run ctags. Default to "ctags" when nothing works.
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02004225dnl Use --version to detect Exuberant ctags (preferred)
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004226dnl Add --fields=+S to get function signatures for omni completion.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004227dnl -t for typedefs (many ctags have this)
4228dnl -s for static functions (Elvis ctags only?)
4229dnl -v for variables. Dangerous, most ctags take this for 'vgrind style'.
4230dnl -i+m to test for older Exuberant ctags
4231AC_MSG_CHECKING(how to create tags)
4232test -f tags && mv tags tags.save
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004233if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004234 TAGPRG="ctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004235elif (eval exctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004236 TAGPRG="exctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004237elif (eval exuberant-ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004238 TAGPRG="exuberant-ctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004239else
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004240 TAGPRG="ctags"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004241 (eval etags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags"
4242 (eval etags -c /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags -c"
4243 (eval ctags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags"
4244 (eval ctags -t /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -t"
4245 (eval ctags -ts /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -ts"
4246 (eval ctags -tvs /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -tvs"
4247 (eval ctags -i+m /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -i+m"
4248fi
4249test -f tags.save && mv tags.save tags
4250AC_MSG_RESULT($TAGPRG) AC_SUBST(TAGPRG)
4251
4252dnl Check how we can run man with a section number
4253AC_MSG_CHECKING(how to run man with a section nr)
4254MANDEF="man"
Bram Moolenaar8b131502008-02-13 09:28:19 +00004255(eval MANPAGER=cat PAGER=cat man -s 2 read) < /dev/null > /dev/null 2>&AC_FD_CC && MANDEF="man -s"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004256AC_MSG_RESULT($MANDEF)
4257if test "$MANDEF" = "man -s"; then
4258 AC_DEFINE(USEMAN_S)
4259fi
4260
4261dnl Check if gettext() is working and if it needs -lintl
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004262dnl We take care to base this on an empty LIBS: on some systems libelf would be
4263dnl in LIBS and implicitly take along libintl. The final LIBS would then not
4264dnl contain libintl, and the link step would fail due to -Wl,--as-needed.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004265AC_MSG_CHECKING(--disable-nls argument)
4266AC_ARG_ENABLE(nls,
4267 [ --disable-nls Don't support NLS (gettext()).], ,
4268 [enable_nls="yes"])
4269
4270if test "$enable_nls" = "yes"; then
4271 AC_MSG_RESULT(no)
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00004272
4273 INSTALL_LANGS=install-languages
4274 AC_SUBST(INSTALL_LANGS)
4275 INSTALL_TOOL_LANGS=install-tool-languages
4276 AC_SUBST(INSTALL_TOOL_LANGS)
4277
Bram Moolenaar071d4272004-06-13 20:20:40 +00004278 AC_CHECK_PROG(MSGFMT, msgfmt, msgfmt, )
4279 AC_MSG_CHECKING([for NLS])
4280 if test -f po/Makefile; then
4281 have_gettext="no"
4282 if test -n "$MSGFMT"; then
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004283 olibs=$LIBS
4284 LIBS=""
Bram Moolenaar071d4272004-06-13 20:20:40 +00004285 AC_TRY_LINK(
4286 [#include <libintl.h>],
4287 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004288 AC_MSG_RESULT([gettext() works]); have_gettext="yes"; LIBS=$olibs,
4289 LIBS="-lintl"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004290 AC_TRY_LINK(
4291 [#include <libintl.h>],
4292 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004293 AC_MSG_RESULT([gettext() works with -lintl]); have_gettext="yes";
4294 LIBS="$olibs -lintl",
Bram Moolenaar071d4272004-06-13 20:20:40 +00004295 AC_MSG_RESULT([gettext() doesn't work]);
4296 LIBS=$olibs))
4297 else
4298 AC_MSG_RESULT([msgfmt not found - disabled]);
4299 fi
Bram Moolenaar278eb582014-07-30 13:22:52 +02004300 if test $have_gettext = "yes" -a "x$features" != "xtiny" -a "x$features" != "xsmall"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004301 AC_DEFINE(HAVE_GETTEXT)
4302 MAKEMO=yes
4303 AC_SUBST(MAKEMO)
4304 dnl this was added in GNU gettext 0.10.36
4305 AC_CHECK_FUNCS(bind_textdomain_codeset)
4306 dnl _nl_msg_cat_cntr is required for GNU gettext
4307 AC_MSG_CHECKING([for _nl_msg_cat_cntr])
4308 AC_TRY_LINK(
4309 [#include <libintl.h>
4310 extern int _nl_msg_cat_cntr;],
4311 [++_nl_msg_cat_cntr;],
4312 AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_NL_MSG_CAT_CNTR),
4313 AC_MSG_RESULT([no]))
Bram Moolenaar26096cc2019-04-11 15:25:40 +02004314 AC_MSG_CHECKING([if msgfmt supports --desktop])
4315 MSGFMT_DESKTOP=
4316 if "$MSGFMT" --help | grep -e '--desktop' >/dev/null; then
Bram Moolenaar62a88f42019-06-07 20:44:40 +02004317 if "$MSGFMT" --version | grep '0.19.[[3-7]]$' >/dev/null; then
4318 dnl GNU gettext 0.19.7's --desktop is broken. We assume back to
4319 dnl 0.19.3 is also broken.
4320 AC_MSG_RESULT([broken])
4321 else
4322 AC_MSG_RESULT([yes])
4323 MSGFMT_DESKTOP="gvim.desktop vim.desktop"
4324 fi
Bram Moolenaar26096cc2019-04-11 15:25:40 +02004325 else
4326 AC_MSG_RESULT([no])
4327 fi
4328 AC_SUBST(MSGFMT_DESKTOP)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004329 fi
4330 else
4331 AC_MSG_RESULT([no "po/Makefile" - disabled]);
4332 fi
4333else
4334 AC_MSG_RESULT(yes)
4335fi
4336
4337dnl Check for dynamic linking loader
4338AC_CHECK_HEADER(dlfcn.h, DLL=dlfcn.h, [AC_CHECK_HEADER(dl.h, DLL=dl.h)])
4339if test x${DLL} = xdlfcn.h; then
4340 AC_DEFINE(HAVE_DLFCN_H, 1, [ Define if we have dlfcn.h. ])
4341 AC_MSG_CHECKING([for dlopen()])
4342 AC_TRY_LINK(,[
4343 extern void* dlopen();
4344 dlopen();
4345 ],
4346 AC_MSG_RESULT(yes);
4347 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4348 AC_MSG_RESULT(no);
4349 AC_MSG_CHECKING([for dlopen() in -ldl])
4350 olibs=$LIBS
4351 LIBS="$LIBS -ldl"
4352 AC_TRY_LINK(,[
4353 extern void* dlopen();
4354 dlopen();
4355 ],
4356 AC_MSG_RESULT(yes);
4357 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4358 AC_MSG_RESULT(no);
4359 LIBS=$olibs))
4360 dnl ReliantUNIX has dlopen() in libc but everything else in libdl
4361 dnl ick :-)
4362 AC_MSG_CHECKING([for dlsym()])
4363 AC_TRY_LINK(,[
4364 extern void* dlsym();
4365 dlsym();
4366 ],
4367 AC_MSG_RESULT(yes);
4368 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4369 AC_MSG_RESULT(no);
4370 AC_MSG_CHECKING([for dlsym() in -ldl])
4371 olibs=$LIBS
4372 LIBS="$LIBS -ldl"
4373 AC_TRY_LINK(,[
4374 extern void* dlsym();
4375 dlsym();
4376 ],
4377 AC_MSG_RESULT(yes);
4378 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4379 AC_MSG_RESULT(no);
4380 LIBS=$olibs))
4381elif test x${DLL} = xdl.h; then
4382 AC_DEFINE(HAVE_DL_H, 1, [ Define if we have dl.h. ])
4383 AC_MSG_CHECKING([for shl_load()])
4384 AC_TRY_LINK(,[
4385 extern void* shl_load();
4386 shl_load();
4387 ],
4388 AC_MSG_RESULT(yes);
4389 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4390 AC_MSG_RESULT(no);
4391 AC_MSG_CHECKING([for shl_load() in -ldld])
4392 olibs=$LIBS
4393 LIBS="$LIBS -ldld"
4394 AC_TRY_LINK(,[
4395 extern void* shl_load();
4396 shl_load();
4397 ],
4398 AC_MSG_RESULT(yes);
4399 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4400 AC_MSG_RESULT(no);
4401 LIBS=$olibs))
4402fi
4403AC_CHECK_HEADERS(setjmp.h)
4404
Bram Moolenaard0573012017-10-28 21:11:06 +02004405if test "x$MACOS_X" = "xyes" -a -n "$PERL"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004406 dnl -ldl must come after DynaLoader.a
4407 if echo $LIBS | grep -e '-ldl' >/dev/null; then
4408 LIBS=`echo $LIBS | sed s/-ldl//`
4409 PERL_LIBS="$PERL_LIBS -ldl"
4410 fi
4411fi
4412
Bram Moolenaard0573012017-10-28 21:11:06 +02004413if test "$MACOS_X" = "yes"; then
4414 AC_MSG_CHECKING([whether we need macOS frameworks])
Bram Moolenaar097148e2020-08-11 21:58:20 +02004415 if test "$MACOS_X_DARWIN" = "yes"; then
Bram Moolenaard0573012017-10-28 21:11:06 +02004416 if test "$features" = "tiny"; then
4417 dnl Since no FEAT_CLIPBOARD, no longer need for os_macosx.m.
4418 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_macosx.m++'`
4419 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_macosx.o++'`
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01004420 AC_MSG_RESULT([yes, we need CoreServices])
4421 LIBS="$LIBS -framework CoreServices"
Bram Moolenaard0573012017-10-28 21:11:06 +02004422 else
4423 AC_MSG_RESULT([yes, we need AppKit])
4424 LIBS="$LIBS -framework AppKit"
Bram Moolenaard0573012017-10-28 21:11:06 +02004425 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004426 else
Bram Moolenaard0573012017-10-28 21:11:06 +02004427 AC_MSG_RESULT([no])
Bram Moolenaar3437b912013-07-03 19:52:53 +02004428 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004429fi
4430
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004431dnl gcc 3.1 changed the meaning of -MM. The only solution appears to be to
4432dnl use "-isystem" instead of "-I" for all non-Vim include dirs.
4433dnl But only when making dependencies, cproto and lint don't take "-isystem".
Bram Moolenaar32466aa2006-02-24 23:53:04 +00004434dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
4435dnl the number before the version number.
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004436DEPEND_CFLAGS_FILTER=
4437if test "$GCC" = yes; then
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004438 AC_MSG_CHECKING(for GCC 3 or later)
Bram Moolenaar348808f2020-02-07 20:50:07 +01004439 gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]][[0-9]]*\)\..*$/\1/g'`
Bram Moolenaarf740b292006-02-16 22:11:02 +00004440 if test "$gccmajor" -gt "2"; then
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004441 DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004442 AC_MSG_RESULT(yes)
4443 else
4444 AC_MSG_RESULT(no)
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004445 fi
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004446 dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
4447 dnl declared as char x[1] but actually longer. Introduced in gcc 4.0.
Bram Moolenaar56d1db32009-12-16 16:14:51 +00004448 dnl Also remove duplicate _FORTIFY_SOURCE arguments.
Bram Moolenaaraeabe052011-12-08 15:17:34 +01004449 dnl And undefine it first to avoid a warning.
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004450 AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
4451 if test "$gccmajor" -gt "3"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02004452 CFLAGS=`echo "$CFLAGS" | sed -e 's/ *-Wp,-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/'`
Bram Moolenaar91b992c2019-11-17 19:07:42 +01004453 CPPFLAGS=`echo "$CPPFLAGS" | sed -e 's/ *-Wp,-D_FORTIFY_SOURCE=.//g' -e 's/ *-D_FORTIFY_SOURCE=.//g' -e 's/ *-U_FORTIFY_SOURCE//g'`
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004454 AC_MSG_RESULT(yes)
4455 else
4456 AC_MSG_RESULT(no)
4457 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +00004458fi
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004459AC_SUBST(DEPEND_CFLAGS_FILTER)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004460
Bram Moolenaarec0557f2018-01-31 14:41:37 +01004461dnl On some systems AC_SYS_LARGEFILE determines that -D_FILE_OFFSET_BITS=64
4462dnl isn't required, but the CFLAGS for some of the libraries we're using
4463dnl include the define. Since the define changes the size of some datatypes
4464dnl (e.g. ino_t and off_t), all of Vim's modules must be compiled with a
4465dnl consistent value. It's therefore safest to force the use of the define
4466dnl if it's present in any of the *_CFLAGS variables.
4467AC_MSG_CHECKING(whether we need to force -D_FILE_OFFSET_BITS=64)
Bram Moolenaar9ce42132018-04-11 22:19:36 +02004468if 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 +01004469 AC_MSG_RESULT(yes)
4470 AC_DEFINE(_FILE_OFFSET_BITS, 64)
4471else
4472 AC_MSG_RESULT(no)
4473fi
4474
Bram Moolenaar6cd42db2020-12-04 18:09:54 +01004475dnl $LDFLAGS is passed to glibtool in libvterm, it doesn't like a space
4476dnl between "-L" and the path that follows.
4477LDFLAGS=`echo "$LDFLAGS" | sed -e 's/-L /-L/g'`
4478
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004479dnl link.sh tries to avoid overlinking in a hackish way.
4480dnl At least GNU ld supports --as-needed which provides the same functionality
4481dnl at linker level. Let's use it.
4482AC_MSG_CHECKING(linker --as-needed support)
4483LINK_AS_NEEDED=
4484# Check if linker supports --as-needed and --no-as-needed options
4485if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02004486 LDFLAGS=`echo "$LDFLAGS" | sed -e 's/ *-Wl,--as-needed//g' | sed -e 's/$/ -Wl,--as-needed/'`
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004487 LINK_AS_NEEDED=yes
4488fi
4489if test "$LINK_AS_NEEDED" = yes; then
4490 AC_MSG_RESULT(yes)
4491else
4492 AC_MSG_RESULT(no)
4493fi
4494AC_SUBST(LINK_AS_NEEDED)
4495
Bram Moolenaar77c19352012-06-13 19:19:41 +02004496# IBM z/OS reset CFLAGS for config.mk
4497if test "$zOSUnix" = "yes"; then
4498 CFLAGS="-D_ALL_SOURCE -Wc,float\(ieee\),dll"
4499fi
4500
Bram Moolenaar071d4272004-06-13 20:20:40 +00004501dnl write output files
4502AC_OUTPUT(auto/config.mk:config.mk.in)
4503
4504dnl vim: set sw=2 tw=78 fo+=l: