blob: 8a5216a8a3ceabe38ab55e6ea54dfe62148f6206 [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 Moolenaar071d4272004-06-13 20:20:40 +0000265 fi
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000266
Bram Moolenaardb552d602006-03-23 22:59:57 +0000267 dnl Avoid a bug with -O2 with gcc 4.0.1. Symptom: malloc() reports double
Bram Moolenaarfd2ac762006-03-01 22:09:21 +0000268 dnl free. This happens in expand_filename(), because the optimizer swaps
Bram Moolenaardb552d602006-03-23 22:59:57 +0000269 dnl two blocks of code, both using "repl", that can't be swapped.
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000270 if test "$MACARCH" = "intel" -o "$MACARCH" = "both"; then
271 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-Oz/'`
272 fi
273
Bram Moolenaar071d4272004-06-13 20:20:40 +0000274else
275 AC_MSG_RESULT(no)
276fi
277
Bram Moolenaar39766a72013-11-03 00:41:00 +0100278dnl Mac OS X 10.9+ no longer include AvailabilityMacros.h in Carbon
279dnl so we need to include it to have access to version macros.
Bram Moolenaar18e54692013-11-03 20:26:31 +0100280AC_CHECK_HEADERS(AvailabilityMacros.h)
Bram Moolenaar39766a72013-11-03 00:41:00 +0100281
Bram Moolenaar071d4272004-06-13 20:20:40 +0000282AC_SUBST(OS_EXTRA_SRC)
283AC_SUBST(OS_EXTRA_OBJ)
284
285dnl Add /usr/local/lib to $LDFLAGS and /usr/local/include to CFLAGS.
286dnl Only when the directory exists and it wasn't there yet.
287dnl For gcc don't do this when it is already in the default search path.
Bram Moolenaar446cb832008-06-24 21:56:24 +0000288dnl Skip all of this when cross-compiling.
289if test "$cross_compiling" = no; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000290 AC_MSG_CHECKING(--with-local-dir argument)
Bram Moolenaar446cb832008-06-24 21:56:24 +0000291 have_local_include=''
292 have_local_lib=''
Bram Moolenaarc236c162008-07-13 17:41:49 +0000293 AC_ARG_WITH([local-dir], [ --with-local-dir=PATH search PATH instead of /usr/local for local libraries.
294 --without-local-dir do not search /usr/local for local libraries.], [
295 local_dir="$withval"
296 case "$withval" in
297 */*) ;;
298 no)
299 # avoid adding local dir to LDFLAGS and CPPFLAGS
Bram Moolenaare06c1882010-07-21 22:05:20 +0200300 have_local_include=yes
Bram Moolenaarc236c162008-07-13 17:41:49 +0000301 have_local_lib=yes
302 ;;
303 *) AC_MSG_ERROR(must pass path argument to --with-local-dir) ;;
304 esac
305 AC_MSG_RESULT($local_dir)
306 ], [
307 local_dir=/usr/local
308 AC_MSG_RESULT(Defaulting to $local_dir)
309 ])
310 if test "$GCC" = yes -a "$local_dir" != no; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000311 echo 'void f(){}' > conftest.c
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100312 dnl Removed -no-cpp-precomp, only needed for OS X 10.2 (Ben Fowler)
313 have_local_include=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/include"`
Bram Moolenaarc236c162008-07-13 17:41:49 +0000314 have_local_lib=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/lib"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000315 rm -f conftest.c conftest.o
Bram Moolenaar071d4272004-06-13 20:20:40 +0000316 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000317 if test -z "$have_local_lib" -a -d "${local_dir}/lib"; then
318 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 +0000319 if test "$tt" = "$LDFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000320 LDFLAGS="$LDFLAGS -L${local_dir}/lib"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000321 fi
322 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000323 if test -z "$have_local_include" -a -d "${local_dir}/include"; then
324 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 +0000325 if test "$tt" = "$CPPFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000326 CPPFLAGS="$CPPFLAGS -I${local_dir}/include"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000327 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000328 fi
329fi
330
331AC_MSG_CHECKING(--with-vim-name argument)
332AC_ARG_WITH(vim-name, [ --with-vim-name=NAME what to call the Vim executable],
333 VIMNAME="$withval"; AC_MSG_RESULT($VIMNAME),
Bram Moolenaare344bea2005-09-01 20:46:49 +0000334 VIMNAME="vim"; AC_MSG_RESULT(Defaulting to $VIMNAME))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000335AC_SUBST(VIMNAME)
336AC_MSG_CHECKING(--with-ex-name argument)
337AC_ARG_WITH(ex-name, [ --with-ex-name=NAME what to call the Ex executable],
338 EXNAME="$withval"; AC_MSG_RESULT($EXNAME),
339 EXNAME="ex"; AC_MSG_RESULT(Defaulting to ex))
340AC_SUBST(EXNAME)
341AC_MSG_CHECKING(--with-view-name argument)
342AC_ARG_WITH(view-name, [ --with-view-name=NAME what to call the View executable],
343 VIEWNAME="$withval"; AC_MSG_RESULT($VIEWNAME),
344 VIEWNAME="view"; AC_MSG_RESULT(Defaulting to view))
345AC_SUBST(VIEWNAME)
346
347AC_MSG_CHECKING(--with-global-runtime argument)
Bram Moolenaar9d302ad2018-12-21 11:48:51 +0100348AC_ARG_WITH(global-runtime, [ --with-global-runtime=DIR global runtime directory in 'runtimepath', comma-separated for multiple directories],
349 RUNTIME_GLOBAL="$withval"; AC_MSG_RESULT($withval),
Bram Moolenaar071d4272004-06-13 20:20:40 +0000350 AC_MSG_RESULT(no))
351
Bram Moolenaar9d302ad2018-12-21 11:48:51 +0100352if test "X$RUNTIME_GLOBAL" != "X"; then
353 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" }')
354 AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL, "$RUNTIME_GLOBAL")
355 AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL_AFTER, "$RUNTIME_GLOBAL_AFTER")
356fi
357
Bram Moolenaar071d4272004-06-13 20:20:40 +0000358AC_MSG_CHECKING(--with-modified-by argument)
359AC_ARG_WITH(modified-by, [ --with-modified-by=NAME name of who modified a release version],
360 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(MODIFIED_BY, "$withval"),
361 AC_MSG_RESULT(no))
362
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200363dnl Check for EBCDIC stolen from the LYNX port to z/OS Unix
Bram Moolenaar071d4272004-06-13 20:20:40 +0000364AC_MSG_CHECKING(if character set is EBCDIC)
365AC_TRY_COMPILE([ ],
366[ /* TryCompile function for CharSet.
367 Treat any failure as ASCII for compatibility with existing art.
368 Use compile-time rather than run-time tests for cross-compiler
369 tolerance. */
370#if '0'!=240
371make an error "Character set is not EBCDIC"
372#endif ],
373[ # TryCompile action if true
374cf_cv_ebcdic=yes ],
375[ # TryCompile action if false
376cf_cv_ebcdic=no])
377# end of TryCompile ])
378# end of CacheVal CvEbcdic
379AC_MSG_RESULT($cf_cv_ebcdic)
380case "$cf_cv_ebcdic" in #(vi
381 yes) AC_DEFINE(EBCDIC)
382 line_break='"\\n"'
383 ;;
384 *) line_break='"\\012"';;
385esac
386AC_SUBST(line_break)
387
388if test "$cf_cv_ebcdic" = "yes"; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +0200389dnl If we have EBCDIC we most likely have z/OS Unix, let's test it!
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200390AC_MSG_CHECKING(for z/OS Unix)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000391case `uname` in
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200392 OS/390) zOSUnix="yes";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000393 dnl If using cc the environment variable _CC_CCMODE must be
394 dnl set to "1", so that some compiler extensions are enabled.
395 dnl If using c89 the environment variable is named _CC_C89MODE.
396 dnl Note: compile with c89 never tested.
397 if test "$CC" = "cc"; then
398 ccm="$_CC_CCMODE"
399 ccn="CC"
400 else
401 if test "$CC" = "c89"; then
402 ccm="$_CC_C89MODE"
403 ccn="C89"
404 else
405 ccm=1
406 fi
407 fi
408 if test "$ccm" != "1"; then
409 echo ""
410 echo "------------------------------------------"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200411 echo " On z/OS Unix, the environment variable"
Bram Moolenaar77c19352012-06-13 19:19:41 +0200412 echo " _CC_${ccn}MODE must be set to \"1\"!"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000413 echo " Do:"
414 echo " export _CC_${ccn}MODE=1"
415 echo " and then call configure again."
416 echo "------------------------------------------"
417 exit 1
418 fi
Bram Moolenaar77c19352012-06-13 19:19:41 +0200419 # Set CFLAGS for configure process.
420 # This will be reset later for config.mk.
421 # Use haltonmsg to force error for missing H files.
422 CFLAGS="$CFLAGS -D_ALL_SOURCE -Wc,float(ieee),haltonmsg(3296)";
423 LDFLAGS="$LDFLAGS -Wl,EDIT=NO"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000424 AC_MSG_RESULT(yes)
425 ;;
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200426 *) zOSUnix="no";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000427 AC_MSG_RESULT(no)
428 ;;
429esac
430fi
431
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200432dnl Set QUOTESED. Needs additional backslashes on zOS
433if test "$zOSUnix" = "yes"; then
434 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\\\\\&/g' -e 's/\\\\\\\\\"/\"/' -e 's/\\\\\\\\\";\$\$/\";/'"
435else
436 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\&/g' -e 's/\\\\\"/\"/' -e 's/\\\\\";\$\$/\";/'"
437fi
438AC_SUBST(QUOTESED)
439
440
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200441dnl Link with -lsmack for Smack stuff; if not found
442AC_MSG_CHECKING(--disable-smack argument)
443AC_ARG_ENABLE(smack,
444 [ --disable-smack Do not check for Smack support.],
445 , enable_smack="yes")
446if test "$enable_smack" = "yes"; then
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200447 AC_MSG_RESULT(no)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200448 AC_CHECK_HEADER([linux/xattr.h], true, enable_smack="no")
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200449else
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200450 AC_MSG_RESULT(yes)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200451fi
452if test "$enable_smack" = "yes"; then
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200453 AC_CHECK_HEADER([attr/xattr.h], true, enable_smack="no")
454fi
455if test "$enable_smack" = "yes"; then
456 AC_MSG_CHECKING(for XATTR_NAME_SMACKEXEC in linux/xattr.h)
457 AC_EGREP_CPP(XATTR_NAME_SMACKEXEC, [#include <linux/xattr.h>],
458 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +0200459 AC_MSG_RESULT(no); enable_smack="no")
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200460fi
461if test "$enable_smack" = "yes"; then
462 AC_CHECK_LIB(attr, setxattr,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200463 [LIBS="$LIBS -lattr"
464 found_smack="yes"
465 AC_DEFINE(HAVE_SMACK)])
Bram Moolenaar588ebeb2008-05-07 17:09:24 +0000466fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000467
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200468dnl When smack was found don't search for SELinux
469if test "x$found_smack" = "x"; then
470 dnl Link with -lselinux for SELinux stuff; if not found
471 AC_MSG_CHECKING(--disable-selinux argument)
472 AC_ARG_ENABLE(selinux,
473 [ --disable-selinux Do not check for SELinux support.],
474 , enable_selinux="yes")
475 if test "$enable_selinux" = "yes"; then
476 AC_MSG_RESULT(no)
477 AC_CHECK_LIB(selinux, is_selinux_enabled,
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100478 [AC_CHECK_HEADER(selinux/selinux.h,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200479 [LIBS="$LIBS -lselinux"
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100480 AC_DEFINE(HAVE_SELINUX)])])
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200481 else
482 AC_MSG_RESULT(yes)
483 fi
484fi
485
Bram Moolenaar071d4272004-06-13 20:20:40 +0000486dnl Check user requested features.
487
488AC_MSG_CHECKING(--with-features argument)
Bram Moolenaareec29812016-07-26 21:27:36 +0200489AC_ARG_WITH(features, [ --with-features=TYPE tiny, small, normal, big or huge (default: huge)],
Bram Moolenaar071d4272004-06-13 20:20:40 +0000490 features="$withval"; AC_MSG_RESULT($features),
Bram Moolenaar23c4f712016-01-20 22:11:59 +0100491 features="huge"; AC_MSG_RESULT(Defaulting to huge))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000492
493dovimdiff=""
494dogvimdiff=""
495case "$features" in
496 tiny) AC_DEFINE(FEAT_TINY) ;;
497 small) AC_DEFINE(FEAT_SMALL) ;;
498 normal) AC_DEFINE(FEAT_NORMAL) dovimdiff="installvimdiff";
499 dogvimdiff="installgvimdiff" ;;
500 big) AC_DEFINE(FEAT_BIG) dovimdiff="installvimdiff";
501 dogvimdiff="installgvimdiff" ;;
502 huge) AC_DEFINE(FEAT_HUGE) dovimdiff="installvimdiff";
503 dogvimdiff="installgvimdiff" ;;
504 *) AC_MSG_RESULT([Sorry, $features is not supported]) ;;
505esac
506
507AC_SUBST(dovimdiff)
508AC_SUBST(dogvimdiff)
509
510AC_MSG_CHECKING(--with-compiledby argument)
511AC_ARG_WITH(compiledby, [ --with-compiledby=NAME name to show in :version message],
512 compiledby="$withval"; AC_MSG_RESULT($withval),
513 compiledby=""; AC_MSG_RESULT(no))
514AC_SUBST(compiledby)
515
516AC_MSG_CHECKING(--disable-xsmp argument)
517AC_ARG_ENABLE(xsmp,
518 [ --disable-xsmp Disable XSMP session management],
519 , enable_xsmp="yes")
520
521if test "$enable_xsmp" = "yes"; then
522 AC_MSG_RESULT(no)
523 AC_MSG_CHECKING(--disable-xsmp-interact argument)
524 AC_ARG_ENABLE(xsmp-interact,
525 [ --disable-xsmp-interact Disable XSMP interaction],
526 , enable_xsmp_interact="yes")
527 if test "$enable_xsmp_interact" = "yes"; then
528 AC_MSG_RESULT(no)
529 AC_DEFINE(USE_XSMP_INTERACT)
530 else
531 AC_MSG_RESULT(yes)
532 fi
533else
534 AC_MSG_RESULT(yes)
535fi
536
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200537dnl Check for Lua feature.
538AC_MSG_CHECKING(--enable-luainterp argument)
539AC_ARG_ENABLE(luainterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200540 [ --enable-luainterp[=OPTS] Include Lua interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200541 [enable_luainterp="no"])
542AC_MSG_RESULT($enable_luainterp)
543
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200544if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +0100545 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
546 AC_MSG_ERROR([cannot use Lua with tiny or small features])
547 fi
548
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200549 dnl -- find the lua executable
550 AC_SUBST(vi_cv_path_lua)
551
552 AC_MSG_CHECKING(--with-lua-prefix argument)
553 AC_ARG_WITH(lua_prefix,
554 [ --with-lua-prefix=PFX Prefix where Lua is installed.],
555 with_lua_prefix="$withval"; AC_MSG_RESULT($with_lua_prefix),
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200556 with_lua_prefix="";AC_MSG_RESULT(no))
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200557
558 if test "X$with_lua_prefix" != "X"; then
559 vi_cv_path_lua_pfx="$with_lua_prefix"
560 else
561 AC_MSG_CHECKING(LUA_PREFIX environment var)
562 if test "X$LUA_PREFIX" != "X"; then
563 AC_MSG_RESULT("$LUA_PREFIX")
564 vi_cv_path_lua_pfx="$LUA_PREFIX"
565 else
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200566 AC_MSG_RESULT([not set, default to /usr])
567 vi_cv_path_lua_pfx="/usr"
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200568 fi
569 fi
570
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200571 AC_MSG_CHECKING(--with-luajit)
572 AC_ARG_WITH(luajit,
573 [ --with-luajit Link with LuaJIT instead of Lua.],
574 [vi_cv_with_luajit="$withval"],
575 [vi_cv_with_luajit="no"])
576 AC_MSG_RESULT($vi_cv_with_luajit)
577
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200578 LUA_INC=
579 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200580 if test "x$vi_cv_with_luajit" != "xno"; then
581 dnl -- try to find LuaJIT executable
582 AC_PATH_PROG(vi_cv_path_luajit, luajit)
583 if test "X$vi_cv_path_luajit" != "X"; then
584 dnl -- find LuaJIT version
585 AC_CACHE_CHECK(LuaJIT version, vi_cv_version_luajit,
Bram Moolenaar49b10272013-11-21 12:17:51 +0100586 [ 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 +0200587 AC_CACHE_CHECK(Lua version of LuaJIT, vi_cv_version_lua_luajit,
588 [ vi_cv_version_lua_luajit=`${vi_cv_path_luajit} -e "print(_VERSION)" | sed 's/.* //'` ])
589 vi_cv_path_lua="$vi_cv_path_luajit"
590 vi_cv_version_lua="$vi_cv_version_lua_luajit"
591 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200592 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200593 dnl -- try to find Lua executable
594 AC_PATH_PROG(vi_cv_path_plain_lua, lua)
595 if test "X$vi_cv_path_plain_lua" != "X"; then
596 dnl -- find Lua version
597 AC_CACHE_CHECK(Lua version, vi_cv_version_plain_lua,
598 [ vi_cv_version_plain_lua=`${vi_cv_path_plain_lua} -e "print(_VERSION)" | sed 's/.* //'` ])
599 fi
600 vi_cv_path_lua="$vi_cv_path_plain_lua"
601 vi_cv_version_lua="$vi_cv_version_plain_lua"
602 fi
603 if test "x$vi_cv_with_luajit" != "xno" && test "X$vi_cv_version_luajit" != "X"; then
604 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 +0100605 if test -f "$vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200606 AC_MSG_RESULT(yes)
607 LUA_INC=/luajit-$vi_cv_version_luajit
608 fi
609 fi
610 if test "X$LUA_INC" = "X"; then
611 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)
Bram Moolenaar49222be2015-12-11 18:11:30 +0100612 if test -f "$vi_cv_path_lua_pfx/include/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200613 AC_MSG_RESULT(yes)
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200614 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200615 AC_MSG_RESULT(no)
616 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 +0100617 if test -f "$vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200618 AC_MSG_RESULT(yes)
619 LUA_INC=/lua$vi_cv_version_lua
620 else
621 AC_MSG_RESULT(no)
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200622
623 # Detect moonjit:
624 # https://groups.google.com/forum/#!topic/vim_use/O0vek60WuTk
625 lua_suf=/moonjit-2.3
626 inc_path="$vi_cv_path_lua_pfx/include"
Bram Moolenaarad4dc832020-04-20 16:21:53 +0200627 for dir in "$inc_path"/moonjit-[[0-9]]* ; do
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200628 if test -d "$dir" ; then
629 lua_suf=`basename '$dir'`
630 lua_suf="/$lua_suf"
631 break
632 fi
633 done
634 AC_MSG_CHECKING(if lua.h can be found in $inc_path$lua_suf)
635 if test -f "$inc_path$lua_suf/lua.h"; then
636 AC_MSG_RESULT(yes)
637 LUA_INC=$lua_suf
638 else
639 AC_MSG_RESULT(no)
640 vi_cv_path_lua_pfx=
641 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200642 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200643 fi
644 fi
645 fi
646
647 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200648 if test "x$vi_cv_with_luajit" != "xno"; then
649 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
650 if test "X$multiarch" != "X"; then
651 lib_multiarch="lib/${multiarch}"
652 else
653 lib_multiarch="lib"
654 fi
655 if test "X$vi_cv_version_lua" = "X"; then
656 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit"
657 else
658 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit-$vi_cv_version_lua"
659 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200660 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200661 if test "X$LUA_INC" != "X"; then
662 dnl Test alternate location using version
663 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua$vi_cv_version_lua"
664 else
665 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua"
666 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200667 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200668 if test "$enable_luainterp" = "dynamic"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200669 lua_ok="yes"
670 else
671 AC_MSG_CHECKING([if link with ${LUA_LIBS} is sane])
672 libs_save=$LIBS
673 LIBS="$LIBS $LUA_LIBS"
674 AC_TRY_LINK(,[ ],
675 AC_MSG_RESULT(yes); lua_ok="yes",
676 AC_MSG_RESULT(no); lua_ok="no"; LUA_LIBS="")
677 LIBS=$libs_save
678 fi
679 if test "x$lua_ok" = "xyes"; then
680 LUA_CFLAGS="-I${vi_cv_path_lua_pfx}/include${LUA_INC}"
681 LUA_SRC="if_lua.c"
682 LUA_OBJ="objects/if_lua.o"
683 LUA_PRO="if_lua.pro"
684 AC_DEFINE(FEAT_LUA)
685 fi
686 if test "$enable_luainterp" = "dynamic"; then
687 if test "x$vi_cv_with_luajit" != "xno"; then
688 luajit="jit"
689 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200690 if test -f "${vi_cv_path_lua_pfx}/bin/cyglua-${vi_cv_version_lua}.dll"; then
691 vi_cv_dll_name_lua="cyglua-${vi_cv_version_lua}.dll"
692 else
Bram Moolenaard0573012017-10-28 21:11:06 +0200693 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200694 ext="dylib"
695 indexes=""
696 else
697 ext="so"
698 indexes=".0 .1 .2 .3 .4 .5 .6 .7 .8 .9"
699 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
700 if test "X$multiarch" != "X"; then
701 lib_multiarch="lib/${multiarch}"
702 fi
Bram Moolenaar768baac2013-04-15 14:44:57 +0200703 fi
704 dnl Determine the sover for the current version, but fallback to
705 dnl liblua${vi_cv_version_lua}.so if no sover-versioned file is found.
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200706 AC_MSG_CHECKING(if liblua${luajit}*.${ext}* can be found in $vi_cv_path_lua_pfx)
Bram Moolenaar768baac2013-04-15 14:44:57 +0200707 for subdir in "${lib_multiarch}" lib64 lib; do
708 if test -z "$subdir"; then
709 continue
710 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200711 for sover in "${vi_cv_version_lua}.${ext}" "-${vi_cv_version_lua}.${ext}" \
712 ".${vi_cv_version_lua}.${ext}" ".${ext}.${vi_cv_version_lua}"; do
713 for i in $indexes ""; do
714 if test -f "${vi_cv_path_lua_pfx}/${subdir}/liblua${luajit}${sover}$i"; then
Bram Moolenaar768baac2013-04-15 14:44:57 +0200715 sover2="$i"
716 break 3
717 fi
718 done
Bram Moolenaar07e1da62013-02-06 19:49:43 +0100719 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200720 sover=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200721 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200722 if test "X$sover" = "X"; then
723 AC_MSG_RESULT(no)
724 lua_ok="no"
725 vi_cv_dll_name_lua="liblua${luajit}.${ext}"
726 else
727 AC_MSG_RESULT(yes)
728 lua_ok="yes"
729 vi_cv_dll_name_lua="liblua${luajit}${sover}$sover2"
730 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200731 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200732 AC_DEFINE(DYNAMIC_LUA)
733 LUA_LIBS=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200734 LUA_CFLAGS="-DDYNAMIC_LUA_DLL=\\\"${vi_cv_dll_name_lua}\\\" $LUA_CFLAGS"
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200735 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200736 if test "X$LUA_CFLAGS$LUA_LIBS" != "X" && \
Bram Moolenaard0573012017-10-28 21:11:06 +0200737 test "x$MACOS_X" = "xyes" && test "x$vi_cv_with_luajit" != "xno" && \
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200738 test "`(uname -m) 2>/dev/null`" = "x86_64"; then
739 dnl OSX/x64 requires these flags. See http://luajit.org/install.html
740 LUA_LIBS="-pagezero_size 10000 -image_base 100000000 $LUA_LIBS"
741 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200742 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200743 if test "$fail_if_missing" = "yes" -a "$lua_ok" != "yes"; then
Bram Moolenaarf788a062011-12-14 20:51:25 +0100744 AC_MSG_ERROR([could not configure lua])
745 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200746 AC_SUBST(LUA_SRC)
747 AC_SUBST(LUA_OBJ)
748 AC_SUBST(LUA_PRO)
749 AC_SUBST(LUA_LIBS)
750 AC_SUBST(LUA_CFLAGS)
751fi
752
753
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000754dnl Check for MzScheme feature.
755AC_MSG_CHECKING(--enable-mzschemeinterp argument)
756AC_ARG_ENABLE(mzschemeinterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200757 [ --enable-mzschemeinterp Include MzScheme interpreter.], ,
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000758 [enable_mzschemeinterp="no"])
759AC_MSG_RESULT($enable_mzschemeinterp)
760
761if test "$enable_mzschemeinterp" = "yes"; then
762 dnl -- find the mzscheme executable
763 AC_SUBST(vi_cv_path_mzscheme)
764
765 AC_MSG_CHECKING(--with-plthome argument)
766 AC_ARG_WITH(plthome,
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000767 [ --with-plthome=PLTHOME Use PLTHOME.],
768 with_plthome="$withval"; AC_MSG_RESULT($with_plthome),
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000769 with_plthome="";AC_MSG_RESULT("no"))
770
771 if test "X$with_plthome" != "X"; then
772 vi_cv_path_mzscheme_pfx="$with_plthome"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100773 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000774 else
775 AC_MSG_CHECKING(PLTHOME environment var)
776 if test "X$PLTHOME" != "X"; then
777 AC_MSG_RESULT("$PLTHOME")
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000778 vi_cv_path_mzscheme_pfx="$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
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000781 AC_MSG_RESULT(not set)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000782 dnl -- try to find MzScheme executable
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000783 AC_PATH_PROG(vi_cv_path_mzscheme, mzscheme)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000784
785 dnl resolve symbolic link, the executable is often elsewhere and there
786 dnl are no links for the include files.
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000787 if test "X$vi_cv_path_mzscheme" != "X"; then
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000788 lsout=`ls -l $vi_cv_path_mzscheme`
789 if echo "$lsout" | grep -e '->' >/dev/null 2>/dev/null; then
790 vi_cv_path_mzscheme=`echo "$lsout" | sed 's/.*-> \(.*\)/\1/'`
791 fi
792 fi
793
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000794 if test "X$vi_cv_path_mzscheme" != "X"; then
795 dnl -- find where MzScheme thinks it was installed
796 AC_CACHE_CHECK(MzScheme install prefix,vi_cv_path_mzscheme_pfx,
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000797 dnl different versions of MzScheme differ in command line processing
798 dnl use universal approach
799 echo "(display (simplify-path \
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000800 (build-path (call-with-values \
801 (lambda () (split-path (find-system-path (quote exec-file)))) \
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000802 (lambda (base name must-be-dir?) base)) (quote up))))" > mzdirs.scm
803 dnl Remove a trailing slash
804 [ vi_cv_path_mzscheme_pfx=`${vi_cv_path_mzscheme} -r mzdirs.scm | \
805 sed -e 's+/$++'` ])
806 rm -f mzdirs.scm
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000807 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000808 fi
809 fi
810
811 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100812 AC_MSG_CHECKING(for racket include directory)
813 SCHEME_INC=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-include-dir))) (when (path? p) (display p)))'`
814 if test "X$SCHEME_INC" != "X"; then
815 AC_MSG_RESULT(${SCHEME_INC})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000816 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100817 AC_MSG_RESULT(not found)
818 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include)
819 if test -f "$vi_cv_path_mzscheme_pfx/include/scheme.h"; then
820 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000821 AC_MSG_RESULT(yes)
Bram Moolenaard7afed32007-05-06 13:26:41 +0000822 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000823 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100824 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt)
825 if test -f "$vi_cv_path_mzscheme_pfx/include/plt/scheme.h"; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000826 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100827 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000828 else
829 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/racket)
831 if test -f "$vi_cv_path_mzscheme_pfx/include/racket/scheme.h"; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100832 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100833 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100834 else
835 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100836 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/)
837 if test -f /usr/include/plt/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=/usr/include/plt
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/racket/)
843 if test -f /usr/include/racket/scheme.h; then
844 AC_MSG_RESULT(yes)
845 SCHEME_INC=/usr/include/racket
846 else
847 AC_MSG_RESULT(no)
848 vi_cv_path_mzscheme_pfx=
849 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100850 fi
851 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000852 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000853 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000854 fi
855 fi
856
857 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100858
859 AC_MSG_CHECKING(for racket lib directory)
860 SCHEME_LIB=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-lib-dir))) (when (path? p) (display p)))'`
861 if test "X$SCHEME_LIB" != "X"; then
862 AC_MSG_RESULT(${SCHEME_LIB})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000863 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100864 AC_MSG_RESULT(not found)
865 fi
866
867 for path in "${vi_cv_path_mzscheme_pfx}/lib" "${SCHEME_LIB}"; do
868 if test "X$path" != "X"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200869 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100870 MZSCHEME_LIBS="-framework Racket"
871 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
872 elif test -f "${path}/libmzscheme3m.a"; then
873 MZSCHEME_LIBS="${path}/libmzscheme3m.a"
874 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
875 elif test -f "${path}/libracket3m.a"; then
876 MZSCHEME_LIBS="${path}/libracket3m.a"
877 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
878 elif test -f "${path}/libracket.a"; then
879 MZSCHEME_LIBS="${path}/libracket.a ${path}/libmzgc.a"
880 elif test -f "${path}/libmzscheme.a"; then
881 MZSCHEME_LIBS="${path}/libmzscheme.a ${path}/libmzgc.a"
882 else
883 dnl Using shared objects
884 if test -f "${path}/libmzscheme3m.so"; then
885 MZSCHEME_LIBS="-L${path} -lmzscheme3m"
886 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
887 elif test -f "${path}/libracket3m.so"; then
888 MZSCHEME_LIBS="-L${path} -lracket3m"
889 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
890 elif test -f "${path}/libracket.so"; then
891 MZSCHEME_LIBS="-L${path} -lracket -lmzgc"
892 else
893 dnl try next until last
894 if test "$path" != "$SCHEME_LIB"; then
895 continue
896 fi
897 MZSCHEME_LIBS="-L${path} -lmzscheme -lmzgc"
898 fi
899 if test "$GCC" = yes; then
900 dnl Make Vim remember the path to the library. For when it's not in
901 dnl $LD_LIBRARY_PATH.
902 MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${path}"
903 elif test "`(uname) 2>/dev/null`" = SunOS &&
904 uname -r | grep '^5' >/dev/null; then
905 MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${path}"
906 fi
907 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000908 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100909 if test "X$MZSCHEME_LIBS" != "X"; then
910 break
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +0000911 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100912 done
913
914 AC_MSG_CHECKING([if racket requires -pthread])
915 if test "X$SCHEME_LIB" != "X" && $FGREP -e -pthread "$SCHEME_LIB/buildinfo" >/dev/null ; then
916 AC_MSG_RESULT(yes)
917 MZSCHEME_LIBS="${MZSCHEME_LIBS} -pthread"
918 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -pthread"
919 else
920 AC_MSG_RESULT(no)
921 fi
922
923 AC_MSG_CHECKING(for racket config directory)
924 SCHEME_CONFIGDIR=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-config-dir))) (when (path? p) (display p)))'`
925 if test "X$SCHEME_CONFIGDIR" != "X"; then
926 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DMZSCHEME_CONFIGDIR='\"${SCHEME_CONFIGDIR}\"'"
927 AC_MSG_RESULT(${SCHEME_CONFIGDIR})
928 else
929 AC_MSG_RESULT(not found)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000930 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100931
932 AC_MSG_CHECKING(for racket collects directory)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100933 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))))'`
934 if test "X$SCHEME_COLLECTS" = "X"; then
935 if test -d "$vi_cv_path_mzscheme_pfx/lib/plt/collects"; then
936 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/plt/
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100937 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100938 if test -d "$vi_cv_path_mzscheme_pfx/lib/racket/collects"; then
939 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/racket/
Bram Moolenaar75676462013-01-30 14:55:42 +0100940 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100941 if test -d "$vi_cv_path_mzscheme_pfx/share/racket/collects"; then
942 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/
943 else
944 if test -d "$vi_cv_path_mzscheme_pfx/collects"; then
945 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/
946 fi
Bram Moolenaar75676462013-01-30 14:55:42 +0100947 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100948 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100949 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000950 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100951 if test "X$SCHEME_COLLECTS" != "X" ; then
952 AC_MSG_RESULT(${SCHEME_COLLECTS})
953 else
954 AC_MSG_RESULT(not found)
955 fi
956
957 AC_MSG_CHECKING(for mzscheme_base.c)
958 if test -f "${SCHEME_COLLECTS}collects/scheme/base.ss" ; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000959 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +0100960 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
961 MZSCHEME_MOD="++lib scheme/base"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100962 else
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100963 if test -f "${SCHEME_COLLECTS}collects/scheme/base.rkt" ; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100964 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +0100965 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
966 MZSCHEME_MOD="++lib scheme/base"
967 else
968 if test -f "${SCHEME_COLLECTS}collects/racket/base.rkt" ; then
969 MZSCHEME_EXTRA="mzscheme_base.c"
970 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/raco ctool"
971 MZSCHEME_MOD=""
972 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100973 fi
974 fi
975 if test "X$MZSCHEME_EXTRA" != "X" ; then
976 dnl need to generate bytecode for MzScheme base
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000977 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE"
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100978 AC_MSG_RESULT(needed)
979 else
980 AC_MSG_RESULT(not needed)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000981 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100982
Bram Moolenaar9e902192013-07-17 18:58:11 +0200983 dnl On Ubuntu this fixes "undefined reference to symbol 'ffi_type_void'".
984 AC_CHECK_LIB(ffi, ffi_type_void, [MZSCHEME_LIBS="$MZSCHEME_LIBS -lffi"])
985
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000986 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -I${SCHEME_INC} \
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100987 -DMZSCHEME_COLLECTS='\"${SCHEME_COLLECTS}collects\"'"
Bram Moolenaar9e902192013-07-17 18:58:11 +0200988
989 dnl Test that we can compile a simple program with these CFLAGS and LIBS.
990 AC_MSG_CHECKING([if compile and link flags for MzScheme are sane])
991 cflags_save=$CFLAGS
992 libs_save=$LIBS
993 CFLAGS="$CFLAGS $MZSCHEME_CFLAGS"
994 LIBS="$LIBS $MZSCHEME_LIBS"
995 AC_TRY_LINK(,[ ],
996 AC_MSG_RESULT(yes); mzs_ok=yes,
997 AC_MSG_RESULT(no: MZSCHEME DISABLED); mzs_ok=no)
998 CFLAGS=$cflags_save
999 LIBS=$libs_save
1000 if test $mzs_ok = yes; then
1001 MZSCHEME_SRC="if_mzsch.c"
1002 MZSCHEME_OBJ="objects/if_mzsch.o"
1003 MZSCHEME_PRO="if_mzsch.pro"
1004 AC_DEFINE(FEAT_MZSCHEME)
1005 else
1006 MZSCHEME_CFLAGS=
1007 MZSCHEME_LIBS=
1008 MZSCHEME_EXTRA=
1009 MZSCHEME_MZC=
1010 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001011 fi
1012 AC_SUBST(MZSCHEME_SRC)
1013 AC_SUBST(MZSCHEME_OBJ)
1014 AC_SUBST(MZSCHEME_PRO)
1015 AC_SUBST(MZSCHEME_LIBS)
1016 AC_SUBST(MZSCHEME_CFLAGS)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001017 AC_SUBST(MZSCHEME_EXTRA)
1018 AC_SUBST(MZSCHEME_MZC)
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001019fi
1020
1021
Bram Moolenaar071d4272004-06-13 20:20:40 +00001022AC_MSG_CHECKING(--enable-perlinterp argument)
1023AC_ARG_ENABLE(perlinterp,
Bram Moolenaare06c1882010-07-21 22:05:20 +02001024 [ --enable-perlinterp[=OPTS] Include Perl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001025 [enable_perlinterp="no"])
1026AC_MSG_RESULT($enable_perlinterp)
Bram Moolenaare06c1882010-07-21 22:05:20 +02001027if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01001028 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1029 AC_MSG_ERROR([cannot use Perl with tiny or small features])
1030 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001031 AC_SUBST(vi_cv_path_perl)
1032 AC_PATH_PROG(vi_cv_path_perl, perl)
1033 if test "X$vi_cv_path_perl" != "X"; then
1034 AC_MSG_CHECKING(Perl version)
1035 if $vi_cv_path_perl -e 'require 5.003_01' >/dev/null 2>/dev/null; then
1036 eval `$vi_cv_path_perl -V:usethreads`
Bram Moolenaare06c1882010-07-21 22:05:20 +02001037 eval `$vi_cv_path_perl -V:libperl`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001038 if test "X$usethreads" = "XUNKNOWN" -o "X$usethreads" = "Xundef"; then
1039 badthreads=no
1040 else
1041 if $vi_cv_path_perl -e 'require 5.6.0' >/dev/null 2>/dev/null; then
1042 eval `$vi_cv_path_perl -V:use5005threads`
1043 if test "X$use5005threads" = "XUNKNOWN" -o "X$use5005threads" = "Xundef"; then
1044 badthreads=no
1045 else
1046 badthreads=yes
1047 AC_MSG_RESULT(>>> Perl > 5.6 with 5.5 threads cannot be used <<<)
1048 fi
1049 else
1050 badthreads=yes
1051 AC_MSG_RESULT(>>> Perl 5.5 with threads cannot be used <<<)
1052 fi
1053 fi
1054 if test $badthreads = no; then
1055 AC_MSG_RESULT(OK)
1056 eval `$vi_cv_path_perl -V:shrpenv`
1057 if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04
1058 shrpenv=""
1059 fi
1060 vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlibexp}'`
1061 AC_SUBST(vi_cv_perllib)
Bram Moolenaard5f62b12014-08-17 17:05:44 +02001062 vi_cv_perl_extutils=unknown_perl_extutils_path
1063 for extutils_rel_path in ExtUtils vendor_perl/ExtUtils; do
1064 xsubpp_path="$vi_cv_perllib/$extutils_rel_path/xsubpp"
1065 if test -f "$xsubpp_path"; then
1066 vi_cv_perl_xsubpp="$xsubpp_path"
1067 fi
1068 done
1069 AC_SUBST(vi_cv_perl_xsubpp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001070 dnl Remove "-fno-something", it breaks using cproto.
Bram Moolenaar280a8682015-06-21 13:41:08 +02001071 dnl Remove "-fdebug-prefix-map", it isn't supported by clang.
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001072 dnl Remove "FORTIFY_SOURCE", it will be defined twice.
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001073 dnl remove -pipe and -Wxxx, it confuses cproto
Bram Moolenaar071d4272004-06-13 20:20:40 +00001074 perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001075 -e 'ccflags;perl_inc;print"\n"' | sed -e 's/-fno[[^ ]]*//' \
1076 -e 's/-fdebug-prefix-map[[^ ]]*//g' \
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001077 -e 's/-pipe //' \
1078 -e 's/-W[[^ ]]*//g' \
1079 -e 's/-D_FORTIFY_SOURCE=.//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001080 dnl Remove "-lc", it breaks on FreeBSD when using "-pthread".
1081 perllibs=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed -e 'ldopts' | \
1082 sed -e '/Warning/d' -e '/Note (probably harmless)/d' \
1083 -e 's/-bE:perl.exp//' -e 's/-lc //'`
1084 dnl Don't add perl lib to $LIBS: if it's not in LD_LIBRARY_PATH
1085 dnl a test in configure may fail because of that.
1086 perlldflags=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed \
1087 -e 'ccdlflags' | sed -e 's/-bE:perl.exp//'`
1088
1089 dnl check that compiling a simple program still works with the flags
1090 dnl added for Perl.
1091 AC_MSG_CHECKING([if compile and link flags for Perl are sane])
1092 cflags_save=$CFLAGS
1093 libs_save=$LIBS
1094 ldflags_save=$LDFLAGS
1095 CFLAGS="$CFLAGS $perlcppflags"
1096 LIBS="$LIBS $perllibs"
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001097 perlldflags=`echo "$perlldflags" | sed -e 's/^ *//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001098 LDFLAGS="$perlldflags $LDFLAGS"
1099 AC_TRY_LINK(,[ ],
1100 AC_MSG_RESULT(yes); perl_ok=yes,
1101 AC_MSG_RESULT(no: PERL DISABLED); perl_ok=no)
1102 CFLAGS=$cflags_save
1103 LIBS=$libs_save
1104 LDFLAGS=$ldflags_save
1105 if test $perl_ok = yes; then
1106 if test "X$perlcppflags" != "X"; then
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001107 PERL_CFLAGS=$perlcppflags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001108 fi
1109 if test "X$perlldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001110 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$perlldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001111 LDFLAGS="$perlldflags $LDFLAGS"
1112 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001113 fi
1114 PERL_LIBS=$perllibs
1115 PERL_SRC="auto/if_perl.c if_perlsfio.c"
1116 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o"
1117 PERL_PRO="if_perl.pro if_perlsfio.pro"
1118 AC_DEFINE(FEAT_PERL)
1119 fi
1120 fi
1121 else
1122 AC_MSG_RESULT(>>> too old; need Perl version 5.003_01 or later <<<)
1123 fi
1124 fi
1125
Bram Moolenaard0573012017-10-28 21:11:06 +02001126 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00001127 dnl Mac OS X 10.2 or later
Bram Moolenaar071d4272004-06-13 20:20:40 +00001128 dir=/System/Library/Perl
1129 darwindir=$dir/darwin
1130 if test -d $darwindir; then
1131 PERL=/usr/bin/perl
1132 else
1133 dnl Mac OS X 10.3
1134 dir=/System/Library/Perl/5.8.1
1135 darwindir=$dir/darwin-thread-multi-2level
1136 if test -d $darwindir; then
1137 PERL=/usr/bin/perl
1138 fi
1139 fi
1140 if test -n "$PERL"; then
1141 PERL_DIR="$dir"
1142 PERL_CFLAGS="-DFEAT_PERL -I$darwindir/CORE"
1143 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o $darwindir/auto/DynaLoader/DynaLoader.a"
1144 PERL_LIBS="-L$darwindir/CORE -lperl"
1145 fi
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001146 dnl Perl on Mac OS X 10.5 adds "-arch" flags but these should only
1147 dnl be included if requested by passing --with-mac-arch to
1148 dnl configure, so strip these flags first (if present)
1149 PERL_LIBS=`echo "$PERL_LIBS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
1150 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 +00001151 fi
Bram Moolenaare06c1882010-07-21 22:05:20 +02001152 if test "$enable_perlinterp" = "dynamic"; then
1153 if test "$perl_ok" = "yes" -a "X$libperl" != "X"; then
1154 AC_DEFINE(DYNAMIC_PERL)
1155 PERL_CFLAGS="-DDYNAMIC_PERL_DLL=\\\"$libperl\\\" $PERL_CFLAGS"
1156 fi
1157 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001158
1159 if test "$fail_if_missing" = "yes" -a "$perl_ok" != "yes"; then
1160 AC_MSG_ERROR([could not configure perl])
1161 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001162fi
1163AC_SUBST(shrpenv)
1164AC_SUBST(PERL_SRC)
1165AC_SUBST(PERL_OBJ)
1166AC_SUBST(PERL_PRO)
1167AC_SUBST(PERL_CFLAGS)
1168AC_SUBST(PERL_LIBS)
1169
1170AC_MSG_CHECKING(--enable-pythoninterp argument)
1171AC_ARG_ENABLE(pythoninterp,
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001172 [ --enable-pythoninterp[=OPTS] Include Python interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001173 [enable_pythoninterp="no"])
1174AC_MSG_RESULT($enable_pythoninterp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001175if test "$enable_pythoninterp" = "yes" -o "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001176 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1177 AC_MSG_ERROR([cannot use Python with tiny or small features])
1178 fi
1179
Bram Moolenaar071d4272004-06-13 20:20:40 +00001180 dnl -- find the python executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001181 AC_MSG_CHECKING(--with-python-command argument)
1182 AC_SUBST(vi_cv_path_python)
1183 AC_ARG_WITH(python-command, [ --with-python-command=NAME name of the Python 2 command (default: python2 or python)],
1184 vi_cv_path_python="$withval"; AC_MSG_RESULT($vi_cv_path_python),
1185 AC_MSG_RESULT(no))
1186
1187 if test "X$vi_cv_path_python" = "X"; then
1188 AC_PATH_PROGS(vi_cv_path_python, python2 python)
1189 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001190 if test "X$vi_cv_path_python" != "X"; then
1191
1192 dnl -- get its version number
1193 AC_CACHE_CHECK(Python version,vi_cv_var_python_version,
1194 [[vi_cv_var_python_version=`
1195 ${vi_cv_path_python} -c 'import sys; print sys.version[:3]'`
1196 ]])
1197
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001198 dnl -- it must be at least version 2.3
1199 AC_MSG_CHECKING(Python is 2.3 or better)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001200 if ${vi_cv_path_python} -c \
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001201 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001202 then
1203 AC_MSG_RESULT(yep)
1204
1205 dnl -- find where python thinks it was installed
1206 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python_pfx,
1207 [ vi_cv_path_python_pfx=`
1208 ${vi_cv_path_python} -c \
1209 "import sys; print sys.prefix"` ])
1210
1211 dnl -- and where it thinks it runs
1212 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python_epfx,
1213 [ vi_cv_path_python_epfx=`
1214 ${vi_cv_path_python} -c \
1215 "import sys; print sys.exec_prefix"` ])
1216
1217 dnl -- python's internal library path
1218
1219 AC_CACHE_VAL(vi_cv_path_pythonpath,
1220 [ vi_cv_path_pythonpath=`
1221 unset PYTHONPATH;
1222 ${vi_cv_path_python} -c \
1223 "import sys, string; print string.join(sys.path,':')"` ])
1224
1225 dnl -- where the Python implementation library archives are
1226
1227 AC_ARG_WITH(python-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001228 [ --with-python-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001229 [ vi_cv_path_python_conf="${withval}"; have_python_config_dir=1 ] )
Bram Moolenaar071d4272004-06-13 20:20:40 +00001230
1231 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python_conf,
1232 [
1233 vi_cv_path_python_conf=
Bram Moolenaarac499e32013-06-02 19:14:17 +02001234 d=`${vi_cv_path_python} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBPL')"`
1235 if test -d "$d" && test -f "$d/config.c"; then
1236 vi_cv_path_python_conf="$d"
1237 else
1238 for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
1239 for subdir in lib64 lib share; do
1240 d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
1241 if test -d "$d" && test -f "$d/config.c"; then
1242 vi_cv_path_python_conf="$d"
1243 fi
1244 done
Bram Moolenaar071d4272004-06-13 20:20:40 +00001245 done
Bram Moolenaarac499e32013-06-02 19:14:17 +02001246 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001247 ])
1248
1249 PYTHON_CONFDIR="${vi_cv_path_python_conf}"
1250
1251 if test "X$PYTHON_CONFDIR" = "X"; then
1252 AC_MSG_RESULT([can't find it!])
1253 else
1254
1255 dnl -- we need to examine Python's config/Makefile too
1256 dnl see what the interpreter is built from
1257 AC_CACHE_VAL(vi_cv_path_python_plibs,
1258 [
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001259 pwd=`pwd`
1260 tmp_mkf="$pwd/config-PyMake$$"
1261 cat -- "${PYTHON_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001262__:
Bram Moolenaar218116c2010-05-20 21:46:00 +02001263 @echo "python_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001264 @echo "python_LIBS='$(LIBS)'"
1265 @echo "python_SYSLIBS='$(SYSLIBS)'"
1266 @echo "python_LINKFORSHARED='$(LINKFORSHARED)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001267 @echo "python_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001268 @echo "python_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001269 @echo "python_PYTHONFRAMEWORK='$(PYTHONFRAMEWORK)'"
1270 @echo "python_PYTHONFRAMEWORKPREFIX='$(PYTHONFRAMEWORKPREFIX)'"
1271 @echo "python_PYTHONFRAMEWORKINSTALLDIR='$(PYTHONFRAMEWORKINSTALLDIR)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001272eof
1273 dnl -- delete the lines from make about Entering/Leaving directory
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001274 eval "`cd ${PYTHON_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1275 rm -f -- "${tmp_mkf}"
Bram Moolenaard0573012017-10-28 21:11:06 +02001276 if test "x$MACOS_X" = "xyes" && test -n "${python_PYTHONFRAMEWORK}" && ${vi_cv_path_python} -c \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001277 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then
1278 vi_cv_path_python_plibs="-framework Python"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001279 if test "x${vi_cv_path_python}" != "x/usr/bin/python" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
1280 vi_cv_path_python_plibs="-F${python_PYTHONFRAMEWORKPREFIX} -framework Python"
1281 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001282 else
Bram Moolenaar9ce42132018-04-11 22:19:36 +02001283 vi_cv_path_python_plibs="-L${PYTHON_CONFDIR} -lpython${vi_cv_var_python_version}"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001284 dnl -- Check if the path contained in python_LINKFORSHARED is
1285 dnl usable for vim build. If not, make and try other
1286 dnl candidates.
Bram Moolenaara161e262015-03-24 15:14:27 +01001287 if test -n "${python_LINKFORSHARED}" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
Bram Moolenaar6c927552015-03-24 12:21:33 +01001288 python_link_symbol=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]].*/\1/'`
1289 python_link_path=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]][[ \t]]*\(.*\)/\2/'`
1290 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1291 dnl -- The path looks relative. Guess the absolute one using
1292 dnl the prefix and try that.
1293 python_link_path="${python_PYTHONFRAMEWORKPREFIX}/${python_link_path}"
1294 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1295 dnl -- A last resort.
1296 python_link_path="${python_PYTHONFRAMEWORKINSTALLDIR}/Versions/${vi_cv_var_python_version}/${python_PYTHONFRAMEWORK}"
1297 dnl -- No check is done. The last word is left to the
1298 dnl "sanity" test on link flags that follows shortly.
1299 fi
1300 python_LINKFORSHARED="${python_link_symbol} ${python_link_path}"
1301 fi
1302 fi
Bram Moolenaar218116c2010-05-20 21:46:00 +02001303 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 +00001304 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1305 vi_cv_path_python_plibs=`echo $vi_cv_path_python_plibs | sed s/-ltermcap//`
1306 fi
1307 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001308 AC_CACHE_CHECK(Python's dll name,vi_cv_dll_name_python,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001309 [
1310 if test "X$python_DLLLIBRARY" != "X"; then
1311 vi_cv_dll_name_python="$python_DLLLIBRARY"
1312 else
1313 vi_cv_dll_name_python="$python_INSTSONAME"
1314 fi
1315 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00001316
1317 PYTHON_LIBS="${vi_cv_path_python_plibs}"
1318 if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001319 PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001320 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001321 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 +00001322 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001323 if test "X$have_python_config_dir" = "X1" -a "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001324 dnl Define PYTHON_HOME if --with-python-config-dir was used
1325 PYTHON_CFLAGS="${PYTHON_CFLAGS} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'"
1326
1327 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001328 PYTHON_SRC="if_python.c"
Bram Moolenaar9bdb9a02012-07-25 16:32:08 +02001329 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001330
1331 dnl On FreeBSD linking with "-pthread" is required to use threads.
1332 dnl _THREAD_SAFE must be used for compiling then.
1333 dnl The "-pthread" is added to $LIBS, so that the following check for
1334 dnl sigaltstack() will look in libc_r (it's there in libc!).
1335 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1336 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1337 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1338 AC_MSG_CHECKING([if -pthread should be used])
1339 threadsafe_flag=
1340 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001341 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00001342 if test "`(uname) 2>/dev/null`" != Darwin; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001343 test "$GCC" = yes && threadsafe_flag="-pthread"
1344 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1345 threadsafe_flag="-D_THREAD_SAFE"
1346 thread_lib="-pthread"
1347 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001348 if test "`(uname) 2>/dev/null`" = SunOS; then
1349 threadsafe_flag="-pthreads"
1350 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001351 fi
1352 libs_save_old=$LIBS
1353 if test -n "$threadsafe_flag"; then
1354 cflags_save=$CFLAGS
1355 CFLAGS="$CFLAGS $threadsafe_flag"
1356 LIBS="$LIBS $thread_lib"
1357 AC_TRY_LINK(,[ ],
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001358 AC_MSG_RESULT(yes); PYTHON_CFLAGS="$PYTHON_CFLAGS $threadsafe_flag",
Bram Moolenaar071d4272004-06-13 20:20:40 +00001359 AC_MSG_RESULT(no); LIBS=$libs_save_old
1360 )
1361 CFLAGS=$cflags_save
1362 else
1363 AC_MSG_RESULT(no)
1364 fi
1365
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001366 dnl Check that compiling a simple program still works with the flags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001367 dnl added for Python.
1368 AC_MSG_CHECKING([if compile and link flags for Python are sane])
1369 cflags_save=$CFLAGS
1370 libs_save=$LIBS
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001371 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001372 LIBS="$LIBS $PYTHON_LIBS"
1373 AC_TRY_LINK(,[ ],
1374 AC_MSG_RESULT(yes); python_ok=yes,
1375 AC_MSG_RESULT(no: PYTHON DISABLED); python_ok=no)
1376 CFLAGS=$cflags_save
1377 LIBS=$libs_save
1378 if test $python_ok = yes; then
1379 AC_DEFINE(FEAT_PYTHON)
1380 else
1381 LIBS=$libs_save_old
1382 PYTHON_SRC=
1383 PYTHON_OBJ=
1384 PYTHON_LIBS=
1385 PYTHON_CFLAGS=
1386 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001387 fi
1388 else
1389 AC_MSG_RESULT(too old)
1390 fi
1391 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001392
1393 if test "$fail_if_missing" = "yes" -a "$python_ok" != "yes"; then
1394 AC_MSG_ERROR([could not configure python])
1395 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001396fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001397
Bram Moolenaar071d4272004-06-13 20:20:40 +00001398AC_SUBST(PYTHON_LIBS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001399AC_SUBST(PYTHON_CFLAGS)
1400AC_SUBST(PYTHON_SRC)
1401AC_SUBST(PYTHON_OBJ)
1402
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001403
1404AC_MSG_CHECKING(--enable-python3interp argument)
1405AC_ARG_ENABLE(python3interp,
Bram Moolenaar8008b632017-07-18 21:33:20 +02001406 [ --enable-python3interp[=OPTS] Include Python3 interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001407 [enable_python3interp="no"])
1408AC_MSG_RESULT($enable_python3interp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001409if test "$enable_python3interp" = "yes" -o "$enable_python3interp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001410 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1411 AC_MSG_ERROR([cannot use Python with tiny or small features])
1412 fi
1413
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001414 dnl -- find the python3 executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001415 AC_MSG_CHECKING(--with-python3-command argument)
1416 AC_SUBST(vi_cv_path_python3)
1417 AC_ARG_WITH(python3-command, [ --with-python3-command=NAME name of the Python 3 command (default: python3 or python)],
1418 vi_cv_path_python3="$withval"; AC_MSG_RESULT($vi_cv_path_python3),
1419 AC_MSG_RESULT(no))
1420
1421 if test "X$vi_cv_path_python3" = "X"; then
1422 AC_PATH_PROGS(vi_cv_path_python3, python3 python)
1423 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001424 if test "X$vi_cv_path_python3" != "X"; then
1425
1426 dnl -- get its version number
1427 AC_CACHE_CHECK(Python version,vi_cv_var_python3_version,
1428 [[vi_cv_var_python3_version=`
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001429 ${vi_cv_path_python3} -c 'import sys; print(sys.version[:3])'`
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001430 ]])
1431
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001432 dnl -- it must be at least version 3
1433 AC_MSG_CHECKING(Python is 3.0 or better)
1434 if ${vi_cv_path_python3} -c \
1435 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.0)"
1436 then
1437 AC_MSG_RESULT(yep)
Bram Moolenaar456f2bb2011-06-12 21:37:13 +02001438
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001439 dnl -- get abiflags for python 3.2 or higher (PEP 3149)
1440 AC_CACHE_CHECK(Python's abiflags,vi_cv_var_python3_abiflags,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001441 [
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001442 vi_cv_var_python3_abiflags=
1443 if ${vi_cv_path_python3} -c \
1444 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)"
1445 then
1446 vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \
1447 "import sys; print(sys.abiflags)"`
1448 fi ])
1449
1450 dnl -- find where python3 thinks it was installed
1451 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx,
1452 [ vi_cv_path_python3_pfx=`
1453 ${vi_cv_path_python3} -c \
1454 "import sys; print(sys.prefix)"` ])
1455
1456 dnl -- and where it thinks it runs
1457 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx,
1458 [ vi_cv_path_python3_epfx=`
1459 ${vi_cv_path_python3} -c \
1460 "import sys; print(sys.exec_prefix)"` ])
1461
1462 dnl -- python3's internal library path
1463
1464 AC_CACHE_VAL(vi_cv_path_python3path,
1465 [ vi_cv_path_python3path=`
1466 unset PYTHONPATH;
1467 ${vi_cv_path_python3} -c \
1468 "import sys, string; print(':'.join(sys.path))"` ])
1469
1470 dnl -- where the Python implementation library archives are
1471
1472 AC_ARG_WITH(python3-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001473 [ --with-python3-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001474 [ vi_cv_path_python3_conf="${withval}"; have_python3_config_dir=1 ] )
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001475
1476 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf,
1477 [
1478 vi_cv_path_python3_conf=
Bram Moolenaarfee496d2013-07-12 20:07:24 +02001479 config_dir="config-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001480 d=`${vi_cv_path_python3} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBPL'))"`
1481 if test -d "$d" && test -f "$d/config.c"; then
1482 vi_cv_path_python3_conf="$d"
1483 else
1484 for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do
1485 for subdir in lib64 lib share; do
1486 d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}"
1487 if test -d "$d" && test -f "$d/config.c"; then
1488 vi_cv_path_python3_conf="$d"
1489 fi
1490 done
1491 done
1492 fi
1493 ])
1494
1495 PYTHON3_CONFDIR="${vi_cv_path_python3_conf}"
1496
1497 if test "X$PYTHON3_CONFDIR" = "X"; then
1498 AC_MSG_RESULT([can't find it!])
1499 else
1500
1501 dnl -- we need to examine Python's config/Makefile too
1502 dnl see what the interpreter is built from
1503 AC_CACHE_VAL(vi_cv_path_python3_plibs,
1504 [
1505 pwd=`pwd`
1506 tmp_mkf="$pwd/config-PyMake$$"
1507 cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001508__:
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001509 @echo "python3_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001510 @echo "python3_LIBS='$(LIBS)'"
1511 @echo "python3_SYSLIBS='$(SYSLIBS)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001512 @echo "python3_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001513 @echo "python3_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001514eof
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001515 dnl -- delete the lines from make about Entering/Leaving directory
1516 eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1517 rm -f -- "${tmp_mkf}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001518 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 +02001519 vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}"
1520 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1521 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//`
1522 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//`
1523 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001524 AC_CACHE_CHECK(Python3's dll name,vi_cv_dll_name_python3,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001525 [
1526 if test "X$python3_DLLLIBRARY" != "X"; then
1527 vi_cv_dll_name_python3="$python3_DLLLIBRARY"
1528 else
1529 vi_cv_dll_name_python3="$python3_INSTSONAME"
1530 fi
1531 ])
1532
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001533 PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
1534 if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001535 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 +02001536 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001537 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 +02001538 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001539 if test "X$have_python3_config_dir" = "X1" -a "$enable_python3interp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001540 dnl Define PYTHON3_HOME if --with-python-config-dir was used
1541 PYTHON3_CFLAGS="${PYTHON3_CFLAGS} -DPYTHON3_HOME='L\"${vi_cv_path_python3_pfx}\"'"
1542 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001543 PYTHON3_SRC="if_python3.c"
1544 PYTHON3_OBJ="objects/if_python3.o"
1545
1546 dnl On FreeBSD linking with "-pthread" is required to use threads.
1547 dnl _THREAD_SAFE must be used for compiling then.
1548 dnl The "-pthread" is added to $LIBS, so that the following check for
1549 dnl sigaltstack() will look in libc_r (it's there in libc!).
1550 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1551 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1552 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1553 AC_MSG_CHECKING([if -pthread should be used])
1554 threadsafe_flag=
1555 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001556 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001557 if test "`(uname) 2>/dev/null`" != Darwin; then
1558 test "$GCC" = yes && threadsafe_flag="-pthread"
1559 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1560 threadsafe_flag="-D_THREAD_SAFE"
1561 thread_lib="-pthread"
1562 fi
1563 if test "`(uname) 2>/dev/null`" = SunOS; then
1564 threadsafe_flag="-pthreads"
1565 fi
1566 fi
1567 libs_save_old=$LIBS
1568 if test -n "$threadsafe_flag"; then
1569 cflags_save=$CFLAGS
1570 CFLAGS="$CFLAGS $threadsafe_flag"
1571 LIBS="$LIBS $thread_lib"
1572 AC_TRY_LINK(,[ ],
1573 AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag",
1574 AC_MSG_RESULT(no); LIBS=$libs_save_old
1575 )
1576 CFLAGS=$cflags_save
1577 else
1578 AC_MSG_RESULT(no)
1579 fi
1580
1581 dnl check that compiling a simple program still works with the flags
1582 dnl added for Python.
1583 AC_MSG_CHECKING([if compile and link flags for Python 3 are sane])
1584 cflags_save=$CFLAGS
1585 libs_save=$LIBS
1586 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1587 LIBS="$LIBS $PYTHON3_LIBS"
1588 AC_TRY_LINK(,[ ],
1589 AC_MSG_RESULT(yes); python3_ok=yes,
1590 AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no)
1591 CFLAGS=$cflags_save
1592 LIBS=$libs_save
1593 if test "$python3_ok" = yes; then
1594 AC_DEFINE(FEAT_PYTHON3)
1595 else
1596 LIBS=$libs_save_old
1597 PYTHON3_SRC=
1598 PYTHON3_OBJ=
1599 PYTHON3_LIBS=
1600 PYTHON3_CFLAGS=
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001601 fi
1602 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001603 else
1604 AC_MSG_RESULT(too old)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001605 fi
1606 fi
Bram Moolenaar1612b1a2013-06-14 21:22:39 +02001607 if test "$fail_if_missing" = "yes" -a "$python3_ok" != "yes"; then
1608 AC_MSG_ERROR([could not configure python3])
1609 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001610fi
1611
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001612AC_SUBST(PYTHON3_LIBS)
1613AC_SUBST(PYTHON3_CFLAGS)
1614AC_SUBST(PYTHON3_SRC)
1615AC_SUBST(PYTHON3_OBJ)
1616
1617dnl if python2.x and python3.x are enabled one can only link in code
1618dnl with dlopen(), dlsym(), dlclose()
1619if test "$python_ok" = yes && test "$python3_ok" = yes; then
1620 AC_DEFINE(DYNAMIC_PYTHON)
1621 AC_DEFINE(DYNAMIC_PYTHON3)
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001622 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001623 cflags_save=$CFLAGS
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001624 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001625 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001626 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001627 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001628 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001629 #include <dlfcn.h>
1630 /* If this program fails, then RTLD_GLOBAL is needed.
1631 * RTLD_GLOBAL will be used and then it is not possible to
1632 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001633 * Only the first python version used will be switched on.
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001634 */
1635
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001636 int no_rtl_global_needed_for(char *python_instsoname, char *prefix)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001637 {
1638 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001639 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001640 if (pylib != 0)
1641 {
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001642 void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome");
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001643 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1644 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1645 void (*final)(void) = dlsym(pylib, "Py_Finalize");
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001646 (*pfx)(prefix);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001647 (*init)();
1648 needed = (*simple)("import termios") == -1;
1649 (*final)();
1650 dlclose(pylib);
1651 }
1652 return !needed;
1653 }
1654
1655 int main(int argc, char** argv)
1656 {
1657 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001658 if (no_rtl_global_needed_for("${vi_cv_dll_name_python}", "${vi_cv_path_python_pfx}"))
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001659 not_needed = 1;
1660 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001661 }])],
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001662 [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001663
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001664 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001665 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001666
1667 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python3)
1668 cflags_save=$CFLAGS
1669 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001670 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001671 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001672 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001673 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001674 #include <dlfcn.h>
1675 #include <wchar.h>
1676 /* If this program fails, then RTLD_GLOBAL is needed.
1677 * RTLD_GLOBAL will be used and then it is not possible to
1678 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001679 * Only the first python version used will be switched on.
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001680 */
1681
1682 int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix)
1683 {
1684 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001685 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001686 if (pylib != 0)
1687 {
1688 void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome");
1689 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1690 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1691 void (*final)(void) = dlsym(pylib, "Py_Finalize");
1692 (*pfx)(prefix);
1693 (*init)();
1694 needed = (*simple)("import termios") == -1;
1695 (*final)();
1696 dlclose(pylib);
1697 }
1698 return !needed;
1699 }
1700
1701 int main(int argc, char** argv)
1702 {
1703 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001704 if (no_rtl_global_needed_for("${vi_cv_dll_name_python3}", L"${vi_cv_path_python3_pfx}"))
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001705 not_needed = 1;
1706 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001707 }])],
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001708 [AC_MSG_RESULT(yes);AC_DEFINE(PY3_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
1709
1710 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001711 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001712
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001713 PYTHON_SRC="if_python.c"
1714 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001715 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001716 PYTHON_LIBS=
1717 PYTHON3_SRC="if_python3.c"
1718 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001719 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001720 PYTHON3_LIBS=
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001721elif test "$python_ok" = yes && test "$enable_pythoninterp" = "dynamic"; then
1722 AC_DEFINE(DYNAMIC_PYTHON)
1723 PYTHON_SRC="if_python.c"
1724 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001725 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001726 PYTHON_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001727elif test "$python_ok" = yes; then
1728 dnl Check that adding -fPIE works. It may be needed when using a static
1729 dnl Python library.
1730 AC_MSG_CHECKING([if -fPIE can be added for Python])
1731 cflags_save=$CFLAGS
1732 libs_save=$LIBS
1733 CFLAGS="$CFLAGS $PYTHON_CFLAGS -fPIE"
1734 LIBS="$LIBS $PYTHON_LIBS"
1735 AC_TRY_LINK(,[ ],
1736 AC_MSG_RESULT(yes); fpie_ok=yes,
1737 AC_MSG_RESULT(no); fpie_ok=no)
1738 CFLAGS=$cflags_save
1739 LIBS=$libs_save
1740 if test $fpie_ok = yes; then
1741 PYTHON_CFLAGS="$PYTHON_CFLAGS -fPIE"
1742 fi
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001743elif test "$python3_ok" = yes && test "$enable_python3interp" = "dynamic"; then
1744 AC_DEFINE(DYNAMIC_PYTHON3)
1745 PYTHON3_SRC="if_python3.c"
1746 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001747 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001748 PYTHON3_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001749elif test "$python3_ok" = yes; then
1750 dnl Check that adding -fPIE works. It may be needed when using a static
1751 dnl Python library.
1752 AC_MSG_CHECKING([if -fPIE can be added for Python3])
1753 cflags_save=$CFLAGS
1754 libs_save=$LIBS
1755 CFLAGS="$CFLAGS $PYTHON3_CFLAGS -fPIE"
1756 LIBS="$LIBS $PYTHON3_LIBS"
1757 AC_TRY_LINK(,[ ],
1758 AC_MSG_RESULT(yes); fpie_ok=yes,
1759 AC_MSG_RESULT(no); fpie_ok=no)
1760 CFLAGS=$cflags_save
1761 LIBS=$libs_save
1762 if test $fpie_ok = yes; then
1763 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -fPIE"
1764 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001765fi
1766
Bram Moolenaar071d4272004-06-13 20:20:40 +00001767AC_MSG_CHECKING(--enable-tclinterp argument)
1768AC_ARG_ENABLE(tclinterp,
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001769 [ --enable-tclinterp[=OPTS] Include Tcl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001770 [enable_tclinterp="no"])
1771AC_MSG_RESULT($enable_tclinterp)
1772
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001773if test "$enable_tclinterp" = "yes" -o "$enable_tclinterp" = "dynamic"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001774
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001775 dnl on FreeBSD tclsh is a silly script, look for tclsh8.[5420]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001776 AC_MSG_CHECKING(--with-tclsh argument)
1777 AC_ARG_WITH(tclsh, [ --with-tclsh=PATH which tclsh to use (default: tclsh8.0)],
1778 tclsh_name="$withval"; AC_MSG_RESULT($tclsh_name),
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001779 tclsh_name="tclsh8.5"; AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00001780 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1781 AC_SUBST(vi_cv_path_tcl)
1782
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001783 dnl when no specific version specified, also try 8.4, 8.2 and 8.0
1784 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.5"; then
1785 tclsh_name="tclsh8.4"
1786 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1787 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001788 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.4"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001789 tclsh_name="tclsh8.2"
1790 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1791 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001792 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.2"; then
1793 tclsh_name="tclsh8.0"
1794 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1795 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001796 dnl still didn't find it, try without version number
1797 if test "X$vi_cv_path_tcl" = "X"; then
1798 tclsh_name="tclsh"
1799 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1800 fi
1801 if test "X$vi_cv_path_tcl" != "X"; then
1802 AC_MSG_CHECKING(Tcl version)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001803 if echo 'exit [[expr [info tclversion] < 8.0]]' | "$vi_cv_path_tcl" - ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001804 tclver=`echo 'puts [[info tclversion]]' | $vi_cv_path_tcl -`
1805 AC_MSG_RESULT($tclver - OK);
1806 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 +01001807 tcldll=`echo 'puts libtcl[[info tclversion]][[info sharedlibextension]]' | $vi_cv_path_tcl -`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001808
1809 AC_MSG_CHECKING(for location of Tcl include)
Bram Moolenaard0573012017-10-28 21:11:06 +02001810 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001811 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 +00001812 else
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001813 dnl For all macOS, use the value from TCL in case use of, say, homebrew
Bram Moolenaar071d4272004-06-13 20:20:40 +00001814 dnl For Mac OS X 10.3, use the OS-provided framework location
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001815 dnl For Mac OS X 10.14, the OS-provided framework location doesn't contain the headers, so also check the Xcode SDK
1816 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 +00001817 fi
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001818 TCL_INC=
Bram Moolenaar071d4272004-06-13 20:20:40 +00001819 for try in $tclinc; do
1820 if test -f "$try/tcl.h"; then
1821 AC_MSG_RESULT($try/tcl.h)
1822 TCL_INC=$try
1823 break
1824 fi
1825 done
1826 if test -z "$TCL_INC"; then
1827 AC_MSG_RESULT(<not found>)
1828 SKIP_TCL=YES
1829 fi
1830 if test -z "$SKIP_TCL"; then
1831 AC_MSG_CHECKING(for location of tclConfig.sh script)
Bram Moolenaard0573012017-10-28 21:11:06 +02001832 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001833 tclcnf=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001834 tclcnf="$tclcnf `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001835 else
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001836 dnl For all macOS, use the value from TCL in case use of, say, homebrew
Bram Moolenaar071d4272004-06-13 20:20:40 +00001837 dnl For Mac OS X 10.3, use the OS-provided framework location
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001838 dnl For Mac OS X 10.14, the OS-provided framework location doesn't contain the headers, so also check the Xcode SDK
1839 tclcnf=`echo $tclinc | sed s/include/lib/g`
1840 tclcnf="$tclcnf /System/Library/Frameworks/Tcl.framework `xcrun --show-sdk-path`/System/Library/Frameworks/Tcl.framework"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001841 fi
1842 for try in $tclcnf; do
Bram Moolenaar49222be2015-12-11 18:11:30 +01001843 if test -f "$try/tclConfig.sh"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001844 AC_MSG_RESULT($try/tclConfig.sh)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001845 . "$try/tclConfig.sh"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001846 dnl use eval, because tcl 8.2 includes ${TCL_DBGX}
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001847 if test "$enable_tclinterp" = "dynamic"; then
1848 TCL_LIBS=`eval echo "$TCL_STUB_LIB_SPEC $TCL_LIBS"`
1849 else
1850 TCL_LIBS=`eval echo "$TCL_LIB_SPEC $TCL_LIBS"`
1851 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001852 dnl Use $TCL_DEFS for -D_THREAD_SAFE et al. But only use the
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001853 dnl "-D_ABC" items. Watch out for -DFOO=long\ long.
Bram Moolenaar4394bff2008-07-24 11:21:31 +00001854 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 +00001855 break
1856 fi
1857 done
1858 if test -z "$TCL_LIBS"; then
1859 AC_MSG_RESULT(<not found>)
1860 AC_MSG_CHECKING(for Tcl library by myself)
1861 tcllib=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001862 tcllib="$tcllib `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001863 for ext in .so .a ; do
1864 for ver in "" $tclver ; do
1865 for try in $tcllib ; do
1866 trylib=tcl$ver$ext
Bram Moolenaar49222be2015-12-11 18:11:30 +01001867 if test -f "$try/lib$trylib" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001868 AC_MSG_RESULT($try/lib$trylib)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001869 TCL_LIBS="-L\"$try\" -ltcl$ver -ldl -lm"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001870 if test "`(uname) 2>/dev/null`" = SunOS &&
1871 uname -r | grep '^5' >/dev/null; then
1872 TCL_LIBS="$TCL_LIBS -R $try"
1873 fi
1874 break 3
1875 fi
1876 done
1877 done
1878 done
1879 if test -z "$TCL_LIBS"; then
1880 AC_MSG_RESULT(<not found>)
1881 SKIP_TCL=YES
1882 fi
1883 fi
1884 if test -z "$SKIP_TCL"; then
1885 AC_DEFINE(FEAT_TCL)
1886 TCL_SRC=if_tcl.c
1887 TCL_OBJ=objects/if_tcl.o
1888 TCL_PRO=if_tcl.pro
1889 TCL_CFLAGS="-I$TCL_INC $TCL_DEFS"
1890 fi
1891 fi
1892 else
1893 AC_MSG_RESULT(too old; need Tcl version 8.0 or later)
1894 fi
1895 fi
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001896 if test "$enable_tclinterp" = "dynamic"; then
1897 if test "X$TCL_SRC" != "X" -a "X$tcldll" != "X"; then
1898 AC_DEFINE(DYNAMIC_TCL)
1899 TCL_CFLAGS="-DDYNAMIC_TCL_DLL=\\\"$tcldll\\\" -DDYNAMIC_TCL_VER=\\\"$tclver\\\" $TCL_CFLAGS"
1900 fi
1901 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001902 if test "$fail_if_missing" = "yes" -a -z "$TCL_SRC"; then
1903 AC_MSG_ERROR([could not configure Tcl])
1904 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001905fi
1906AC_SUBST(TCL_SRC)
1907AC_SUBST(TCL_OBJ)
1908AC_SUBST(TCL_PRO)
1909AC_SUBST(TCL_CFLAGS)
1910AC_SUBST(TCL_LIBS)
1911
1912AC_MSG_CHECKING(--enable-rubyinterp argument)
1913AC_ARG_ENABLE(rubyinterp,
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001914 [ --enable-rubyinterp[=OPTS] Include Ruby interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001915 [enable_rubyinterp="no"])
1916AC_MSG_RESULT($enable_rubyinterp)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001917if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001918 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1919 AC_MSG_ERROR([cannot use Ruby with tiny or small features])
1920 fi
1921
Bram Moolenaar165641d2010-02-17 16:23:09 +01001922 AC_MSG_CHECKING(--with-ruby-command argument)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001923 AC_SUBST(vi_cv_path_ruby)
Bram Moolenaar948733a2011-05-05 18:10:16 +02001924 AC_ARG_WITH(ruby-command, [ --with-ruby-command=RUBY name of the Ruby command (default: ruby)],
1925 RUBY_CMD="$withval"; vi_cv_path_ruby="$withval"; AC_MSG_RESULT($RUBY_CMD),
1926 RUBY_CMD="ruby"; AC_MSG_RESULT(defaulting to $RUBY_CMD))
Bram Moolenaar165641d2010-02-17 16:23:09 +01001927 AC_PATH_PROG(vi_cv_path_ruby, $RUBY_CMD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001928 if test "X$vi_cv_path_ruby" != "X"; then
1929 AC_MSG_CHECKING(Ruby version)
Bram Moolenaare4efc3b2005-03-07 23:16:51 +00001930 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 +00001931 AC_MSG_RESULT(OK)
Bram Moolenaar81398892012-10-03 21:09:35 +02001932 AC_MSG_CHECKING(Ruby rbconfig)
1933 ruby_rbconfig="RbConfig"
1934 if ! $vi_cv_path_ruby -r rbconfig -e 'RbConfig' >/dev/null 2>/dev/null; then
1935 ruby_rbconfig="Config"
1936 fi
1937 AC_MSG_RESULT($ruby_rbconfig)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001938 AC_MSG_CHECKING(Ruby header files)
Bram Moolenaar81398892012-10-03 21:09:35 +02001939 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 +00001940 if test "X$rubyhdrdir" != "X"; then
1941 AC_MSG_RESULT($rubyhdrdir)
1942 RUBY_CFLAGS="-I$rubyhdrdir"
Bram Moolenaara6fd37b2014-03-27 17:19:09 +01001943 rubyarchdir=`$vi_cv_path_ruby -r rbconfig -e "print ($ruby_rbconfig::CONFIG.has_key? 'rubyarchhdrdir') ? $ruby_rbconfig::CONFIG[['rubyarchhdrdir']] : '$rubyhdrdir/'+$ruby_rbconfig::CONFIG[['arch']]"`
1944 if test -d "$rubyarchdir"; then
1945 RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyarchdir"
Bram Moolenaar165641d2010-02-17 16:23:09 +01001946 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001947 rubyversion=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['ruby_version']].gsub(/\./, '')[[0,2]]"`
Bram Moolenaar026a4452013-08-07 15:22:23 +02001948 if test "X$rubyversion" = "X"; then
1949 rubyversion=`$vi_cv_path_ruby -e "print ((VERSION rescue RUBY_VERSION)).gsub(/\./, '')[[0,2]]"`
1950 fi
Bram Moolenaar165641d2010-02-17 16:23:09 +01001951 RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
Bram Moolenaar81398892012-10-03 21:09:35 +02001952 rubylibs=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LIBS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001953 if test "X$rubylibs" != "X"; then
1954 RUBY_LIBS="$rubylibs"
1955 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001956 librubyarg=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBYARG']])"`
1957 librubya=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBY_A']])"`
Bram Moolenaarac499e32013-06-02 19:14:17 +02001958 rubylibdir=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['libdir']])"`
Bram Moolenaar948733a2011-05-05 18:10:16 +02001959 if test -f "$rubylibdir/$librubya"; then
1960 librubyarg="$librubyarg"
Bram Moolenaarac499e32013-06-02 19:14:17 +02001961 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
1962 elif test "$librubyarg" = "libruby.a"; then
1963 dnl required on Mac OS 10.3 where libruby.a doesn't exist
1964 librubyarg="-lruby"
1965 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001966 fi
1967
1968 if test "X$librubyarg" != "X"; then
1969 RUBY_LIBS="$librubyarg $RUBY_LIBS"
1970 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001971 rubyldflags=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LDFLAGS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001972 if test "X$rubyldflags" != "X"; then
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001973 dnl Ruby on Mac OS X 10.5 adds "-arch" flags but these should only
1974 dnl be included if requested by passing --with-mac-arch to
1975 dnl configure, so strip these flags first (if present)
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001976 rubyldflags=`echo "$rubyldflags" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001977 if test "X$rubyldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001978 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$rubyldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001979 LDFLAGS="$rubyldflags $LDFLAGS"
1980 fi
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001981 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001982 fi
1983 RUBY_SRC="if_ruby.c"
1984 RUBY_OBJ="objects/if_ruby.o"
1985 RUBY_PRO="if_ruby.pro"
1986 AC_DEFINE(FEAT_RUBY)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001987 if test "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar92021622017-10-12 12:33:43 +02001988 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_ALIASES']].split[[0]]"`
Bram Moolenaar87ea64c2018-08-04 15:13:34 +02001989 if test -z "$libruby_soname"; then
1990 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_SO']]"`
1991 fi
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001992 AC_DEFINE(DYNAMIC_RUBY)
Bram Moolenaar41a41412020-01-07 21:32:19 +01001993 RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby_soname\\\" $RUBY_CFLAGS"
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001994 RUBY_LIBS=
1995 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001996 else
Bram Moolenaar165641d2010-02-17 16:23:09 +01001997 AC_MSG_RESULT(not found; disabling Ruby)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001998 fi
1999 else
2000 AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
2001 fi
2002 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01002003
2004 if test "$fail_if_missing" = "yes" -a -z "$RUBY_OBJ"; then
2005 AC_MSG_ERROR([could not configure Ruby])
2006 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002007fi
2008AC_SUBST(RUBY_SRC)
2009AC_SUBST(RUBY_OBJ)
2010AC_SUBST(RUBY_PRO)
2011AC_SUBST(RUBY_CFLAGS)
2012AC_SUBST(RUBY_LIBS)
2013
2014AC_MSG_CHECKING(--enable-cscope argument)
2015AC_ARG_ENABLE(cscope,
2016 [ --enable-cscope Include cscope interface.], ,
2017 [enable_cscope="no"])
2018AC_MSG_RESULT($enable_cscope)
2019if test "$enable_cscope" = "yes"; then
2020 AC_DEFINE(FEAT_CSCOPE)
2021fi
2022
Bram Moolenaar071d4272004-06-13 20:20:40 +00002023AC_MSG_CHECKING(--disable-netbeans argument)
2024AC_ARG_ENABLE(netbeans,
2025 [ --disable-netbeans Disable NetBeans integration support.],
2026 , [enable_netbeans="yes"])
2027if test "$enable_netbeans" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002028 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2029 AC_MSG_RESULT([cannot use NetBeans with tiny or small features])
2030 enable_netbeans="no"
2031 else
2032 AC_MSG_RESULT(no)
2033 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002034else
2035 AC_MSG_RESULT(yes)
2036fi
2037
2038AC_MSG_CHECKING(--disable-channel argument)
2039AC_ARG_ENABLE(channel,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002040 [ --disable-channel Disable process communication support.],
Bram Moolenaare0874f82016-01-24 20:36:41 +01002041 , [enable_channel="yes"])
2042if test "$enable_channel" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002043 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2044 AC_MSG_RESULT([cannot use channels with tiny or small features])
2045 enable_channel="no"
2046 else
2047 AC_MSG_RESULT(no)
2048 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002049else
2050 if test "$enable_netbeans" = "yes"; then
Bram Moolenaar16435482016-01-24 21:31:54 +01002051 AC_MSG_RESULT([yes, netbeans also disabled])
Bram Moolenaare0874f82016-01-24 20:36:41 +01002052 enable_netbeans="no"
2053 else
2054 AC_MSG_RESULT(yes)
2055 fi
2056fi
2057
Bram Moolenaar16435482016-01-24 21:31:54 +01002058if test "$enable_channel" = "yes"; then
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002059 dnl On Solaris we need the socket library, or on Haiku the network library.
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002060 if test "x$HAIKU" = "xyes"; then
2061 AC_CHECK_LIB(network, socket)
2062 else
2063 AC_CHECK_LIB(socket, socket)
2064 fi
2065
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002066 AC_CACHE_CHECK([whether compiling with IPv6 networking is possible], [vim_cv_ipv6_networking],
2067 [AC_TRY_LINK([
2068#include <stdio.h>
2069#include <stdlib.h>
2070#include <stdarg.h>
2071#include <fcntl.h>
2072#include <netdb.h>
2073#include <netinet/in.h>
2074#include <errno.h>
2075#include <sys/types.h>
2076#include <sys/socket.h>
2077 /* Check bitfields */
2078 struct nbbuf {
2079 unsigned int initDone:1;
2080 unsigned short signmaplen;
2081 };
2082 ], [
2083 /* Check creating a socket. */
2084 struct sockaddr_in server;
2085 struct addrinfo *res;
2086 (void)socket(AF_INET, SOCK_STREAM, 0);
2087 (void)htons(100);
2088 (void)getaddrinfo("microsoft.com", NULL, NULL, &res);
2089 if (errno == ECONNREFUSED)
2090 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
2091 (void)freeaddrinfo(res);
2092 ],
2093 [vim_cv_ipv6_networking="yes"],
2094 [vim_cv_ipv6_networking="no"])])
2095
2096 if test "x$vim_cv_ipv6_networking" = "xyes"; then
2097 AC_DEFINE(FEAT_IPV6)
Bram Moolenaarb6fb0512020-04-18 18:24:18 +02002098 AC_CHECK_FUNCS(inet_ntop)
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002099 else
2100 dnl On Solaris we need the nsl library.
2101 AC_CHECK_LIB(nsl, gethostbyname)
2102 AC_CACHE_CHECK([whether compiling with IPv4 networking is possible], [vim_cv_ipv4_networking],
2103 [AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00002104#include <stdio.h>
2105#include <stdlib.h>
2106#include <stdarg.h>
2107#include <fcntl.h>
2108#include <netdb.h>
2109#include <netinet/in.h>
2110#include <errno.h>
2111#include <sys/types.h>
2112#include <sys/socket.h>
2113 /* Check bitfields */
2114 struct nbbuf {
2115 unsigned int initDone:1;
Bram Moolenaar63de19e2016-12-09 20:11:26 +01002116 unsigned short signmaplen;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002117 };
2118 ], [
2119 /* Check creating a socket. */
2120 struct sockaddr_in server;
2121 (void)socket(AF_INET, SOCK_STREAM, 0);
2122 (void)htons(100);
2123 (void)gethostbyname("microsoft.com");
2124 if (errno == ECONNREFUSED)
2125 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
2126 ],
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002127 [vim_cv_ipv4_networking="yes"],
2128 [vim_cv_ipv4_networking="no"; enable_netbeans="no"; enable_channel="no"])])
2129 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002130fi
2131if test "$enable_netbeans" = "yes"; then
2132 AC_DEFINE(FEAT_NETBEANS_INTG)
2133 NETBEANS_SRC="netbeans.c"
2134 AC_SUBST(NETBEANS_SRC)
2135 NETBEANS_OBJ="objects/netbeans.o"
2136 AC_SUBST(NETBEANS_OBJ)
2137fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002138if test "$enable_channel" = "yes"; then
Bram Moolenaar509ce2a2016-03-11 22:52:15 +01002139 AC_DEFINE(FEAT_JOB_CHANNEL)
Bram Moolenaare0874f82016-01-24 20:36:41 +01002140 CHANNEL_SRC="channel.c"
2141 AC_SUBST(CHANNEL_SRC)
2142 CHANNEL_OBJ="objects/channel.o"
2143 AC_SUBST(CHANNEL_OBJ)
2144fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002145
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002146AC_MSG_CHECKING(--enable-terminal argument)
2147AC_ARG_ENABLE(terminal,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002148 [ --enable-terminal Enable terminal emulation support.],
Bram Moolenaaref839562017-10-28 20:28:23 +02002149 , [enable_terminal="auto"])
Bram Moolenaar595a4022017-09-03 19:15:57 +02002150if test "$enable_terminal" = "yes" || test "$enable_terminal" = "auto" -a "x$features" = "xhuge" ; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002151 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2152 AC_MSG_RESULT([cannot use terminal emulator with tiny or small features])
2153 enable_terminal="no"
2154 else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002155 if test "$enable_terminal" = "auto"; then
2156 enable_terminal="yes"
2157 AC_MSG_RESULT(defaulting to yes)
2158 else
2159 AC_MSG_RESULT(yes)
2160 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002161 fi
2162else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002163 if test "$enable_terminal" = "auto"; then
2164 enable_terminal="no"
2165 AC_MSG_RESULT(defaulting to no)
2166 else
2167 AC_MSG_RESULT(no)
2168 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002169fi
Bram Moolenaar8b423282017-12-16 14:37:06 +01002170if test "$enable_terminal" = "yes" -a "$enable_channel" = "yes"; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002171 AC_DEFINE(FEAT_TERMINAL)
Bram Moolenaar93268052019-10-10 13:22:54 +02002172 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 +02002173 AC_SUBST(TERM_SRC)
Bram Moolenaar93268052019-10-10 13:22:54 +02002174 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 +02002175 AC_SUBST(TERM_OBJ)
Bram Moolenaar823edd12019-10-23 22:35:36 +02002176 TERM_TEST="test_libvterm"
2177 AC_SUBST(TERM_TEST)
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002178fi
2179
Bram Moolenaare42a6d22017-11-12 19:21:51 +01002180AC_MSG_CHECKING(--enable-autoservername argument)
2181AC_ARG_ENABLE(autoservername,
2182 [ --enable-autoservername Automatically define servername at vim startup.], ,
2183 [enable_autoservername="no"])
2184AC_MSG_RESULT($enable_autoservername)
2185if test "$enable_autoservername" = "yes"; then
2186 AC_DEFINE(FEAT_AUTOSERVERNAME)
2187fi
2188
Bram Moolenaar071d4272004-06-13 20:20:40 +00002189AC_MSG_CHECKING(--enable-multibyte argument)
2190AC_ARG_ENABLE(multibyte,
2191 [ --enable-multibyte Include multibyte editing support.], ,
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01002192 [enable_multibyte="yes"])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002193AC_MSG_RESULT($enable_multibyte)
Bram Moolenaar30276f22019-01-24 17:59:39 +01002194if test "$enable_multibyte" != "yes"; then
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01002195 AC_MSG_ERROR([The multi-byte feature can no longer be disabled. If you have
2196 a problem with this, discuss on the Vim mailing list.])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002197fi
2198
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002199dnl Right-to-Left language support for Vim will be included with big features,
2200dnl unless ENABLE_RIGHTLEFT is undefined.
2201AC_MSG_CHECKING(--disable-rightleft argument)
2202AC_ARG_ENABLE(rightleft,
2203 [ --disable-rightleft Do not include Right-to-Left language support.],
2204 , [enable_rightleft="yes"])
2205if test "$enable_rightleft" = "yes"; then
2206 AC_MSG_RESULT(no)
2207else
2208 AC_MSG_RESULT(yes)
2209 AC_DEFINE(DISABLE_RIGHTLEFT)
2210fi
2211
2212dnl Arabic language support for Vim will be included with big features,
2213dnl unless ENABLE_ARABIC is undefined.
2214AC_MSG_CHECKING(--disable-arabic argument)
2215AC_ARG_ENABLE(arabic,
2216 [ --disable-arabic Do not include Arabic language support.],
2217 , [enable_arabic="yes"])
2218if test "$enable_arabic" = "yes"; then
2219 AC_MSG_RESULT(no)
2220else
2221 AC_MSG_RESULT(yes)
2222 AC_DEFINE(DISABLE_ARABIC)
2223fi
2224
Bram Moolenaar14184a32019-02-16 15:10:30 +01002225dnl Farsi language support has been removed, ignore --disable-farsi
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002226AC_ARG_ENABLE(farsi,
Bram Moolenaar14184a32019-02-16 15:10:30 +01002227 [ --disable-farsi Deprecated.],,)
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002228
Bram Moolenaar071d4272004-06-13 20:20:40 +00002229AC_MSG_CHECKING(--enable-xim argument)
2230AC_ARG_ENABLE(xim,
2231 [ --enable-xim Include XIM input support.],
2232 AC_MSG_RESULT($enable_xim),
2233 [enable_xim="auto"; AC_MSG_RESULT(defaulting to auto)])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002234
2235AC_MSG_CHECKING(--enable-fontset argument)
2236AC_ARG_ENABLE(fontset,
2237 [ --enable-fontset Include X fontset output support.], ,
2238 [enable_fontset="no"])
2239AC_MSG_RESULT($enable_fontset)
2240dnl defining FEAT_XFONTSET is delayed, so that it can be disabled for no GUI
2241
2242test -z "$with_x" && with_x=yes
Bram Moolenaard0573012017-10-28 21:11:06 +02002243test "${enable_gui-yes}" != no -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && with_x=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002244if test "$with_x" = no; then
2245 AC_MSG_RESULT(defaulting to: don't HAVE_X11)
2246else
2247 dnl Do this check early, so that its failure can override user requests.
2248
2249 AC_PATH_PROG(xmkmfpath, xmkmf)
2250
2251 AC_PATH_XTRA
2252
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002253 dnl On z/OS Unix the X libraries are DLLs. To use them the code must
Bram Moolenaar071d4272004-06-13 20:20:40 +00002254 dnl be compiled with a special option.
2255 dnl Also add SM, ICE and Xmu to X_EXTRA_LIBS.
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002256 if test "$zOSUnix" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002257 CFLAGS="$CFLAGS -W c,dll"
2258 LDFLAGS="$LDFLAGS -W l,dll"
2259 X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE -lXmu"
2260 fi
2261
2262 dnl On my HPUX system the X include dir is found, but the lib dir not.
Bram Moolenaar70778922020-02-05 20:44:24 +01002263 dnl This is a desperate try to fix this.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002264
2265 if test -d "$x_includes" && test ! -d "$x_libraries"; then
2266 x_libraries=`echo "$x_includes" | sed s/include/lib/`
2267 AC_MSG_RESULT(Corrected X libraries to $x_libraries)
2268 X_LIBS="$X_LIBS -L$x_libraries"
2269 if test "`(uname) 2>/dev/null`" = SunOS &&
2270 uname -r | grep '^5' >/dev/null; then
2271 X_LIBS="$X_LIBS -R $x_libraries"
2272 fi
2273 fi
2274
2275 if test -d "$x_libraries" && test ! -d "$x_includes"; then
2276 x_includes=`echo "$x_libraries" | sed s/lib/include/`
2277 AC_MSG_RESULT(Corrected X includes to $x_includes)
2278 X_CFLAGS="$X_CFLAGS -I$x_includes"
2279 fi
2280
2281 dnl Remove "-I/usr/include " from X_CFLAGS, should not be needed.
2282 X_CFLAGS="`echo $X_CFLAGS\ | sed 's%-I/usr/include %%'`"
2283 dnl Remove "-L/usr/lib " from X_LIBS, should not be needed.
2284 X_LIBS="`echo $X_LIBS\ | sed 's%-L/usr/lib %%'`"
2285 dnl Same for "-R/usr/lib ".
2286 X_LIBS="`echo $X_LIBS\ | sed -e 's%-R/usr/lib %%' -e 's%-R /usr/lib %%'`"
2287
2288
2289 dnl Check if the X11 header files are correctly installed. On some systems
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002290 dnl Xlib.h includes files that don't exist. On some systems X11/Intrinsic.h
2291 dnl is missing.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002292 AC_MSG_CHECKING(if X11 header files can be found)
2293 cflags_save=$CFLAGS
2294 CFLAGS="$CFLAGS $X_CFLAGS"
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002295 AC_TRY_COMPILE([#include <X11/Xlib.h>
2296#include <X11/Intrinsic.h>], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002297 AC_MSG_RESULT(yes),
2298 AC_MSG_RESULT(no); no_x=yes)
2299 CFLAGS=$cflags_save
2300
2301 if test "${no_x-no}" = yes; then
2302 with_x=no
2303 else
2304 AC_DEFINE(HAVE_X11)
2305 X_LIB="-lXt -lX11";
2306 AC_SUBST(X_LIB)
2307
2308 ac_save_LDFLAGS="$LDFLAGS"
2309 LDFLAGS="-L$x_libraries $LDFLAGS"
2310
2311 dnl Check for -lXdmcp (needed on SunOS 4.1.4)
2312 dnl For HP-UX 10.20 it must be before -lSM -lICE
2313 AC_CHECK_LIB(Xdmcp, _XdmcpAuthDoIt, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lXdmcp"],,
2314 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXdmcp])
2315
2316 dnl Some systems need -lnsl -lsocket when testing for ICE.
2317 dnl The check above doesn't do this, try here (again). Also needed to get
2318 dnl them after Xdmcp. link.sh will remove them when not needed.
2319 dnl Check for other function than above to avoid the cached value
2320 AC_CHECK_LIB(ICE, IceOpenConnection,
2321 [X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE"],, [$X_EXTRA_LIBS])
2322
2323 dnl Check for -lXpm (needed for some versions of Motif)
2324 LDFLAGS="$X_LIBS $ac_save_LDFLAGS"
2325 AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [X_PRE_LIBS="$X_PRE_LIBS -lXpm"],,
2326 [-lXt $X_PRE_LIBS -lXpm -lX11 $X_EXTRA_LIBS])
2327
2328 dnl Check that the X11 header files don't use implicit declarations
2329 AC_MSG_CHECKING(if X11 header files implicitly declare return values)
2330 cflags_save=$CFLAGS
Bram Moolenaard1864592013-05-04 04:40:15 +02002331 dnl -Werror is GCC only, others like Solaris Studio might not like it
2332 if test "$GCC" = yes; then
2333 CFLAGS="$CFLAGS $X_CFLAGS -Werror"
2334 else
2335 CFLAGS="$CFLAGS $X_CFLAGS"
2336 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002337 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2338 AC_MSG_RESULT(no),
2339 CFLAGS="$CFLAGS -Wno-implicit-int"
2340 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2341 AC_MSG_RESULT(yes); cflags_save="$cflags_save -Wno-implicit-int",
2342 AC_MSG_RESULT(test failed)
2343 )
2344 )
2345 CFLAGS=$cflags_save
2346
2347 LDFLAGS="$ac_save_LDFLAGS"
2348
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002349 AC_MSG_CHECKING(size of wchar_t is 2 bytes)
2350 AC_CACHE_VAL(ac_cv_small_wchar_t,
2351 [AC_TRY_RUN([
2352#include <X11/Xlib.h>
2353#if STDC_HEADERS
2354# include <stdlib.h>
2355# include <stddef.h>
2356#endif
2357 main()
2358 {
2359 if (sizeof(wchar_t) <= 2)
2360 exit(1);
2361 exit(0);
2362 }],
2363 ac_cv_small_wchar_t="no",
2364 ac_cv_small_wchar_t="yes",
2365 AC_MSG_ERROR(failed to compile test program))])
2366 AC_MSG_RESULT($ac_cv_small_wchar_t)
2367 if test "x$ac_cv_small_wchar_t" = "xyes" ; then
2368 AC_DEFINE(SMALL_WCHAR_T)
2369 fi
2370
Bram Moolenaar071d4272004-06-13 20:20:40 +00002371 fi
2372fi
2373
Bram Moolenaard2a05492018-07-27 22:35:15 +02002374dnl Check if --with-x was given but it doesn't work.
2375if test "x$with_x" = xno -a "x$with_x_arg" = xyes; then
2376 AC_MSG_ERROR([could not configure X])
2377fi
2378
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002379test "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 +00002380
2381AC_MSG_CHECKING(--enable-gui argument)
2382AC_ARG_ENABLE(gui,
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002383 [ --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 +00002384
2385dnl Canonicalize the --enable-gui= argument so that it can be easily compared.
2386dnl Do not use character classes for portability with old tools.
2387enable_gui_canon=`echo "_$enable_gui" | \
2388 sed 's/[[ _+-]]//g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
2389
2390dnl Skip everything by default.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002391SKIP_GTK2=YES
Bram Moolenaar1858a842016-02-23 22:30:31 +01002392SKIP_GTK3=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002393SKIP_GNOME=YES
2394SKIP_MOTIF=YES
2395SKIP_ATHENA=YES
2396SKIP_NEXTAW=YES
2397SKIP_PHOTON=YES
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002398SKIP_HAIKU=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002399GUITYPE=NONE
2400
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002401if test "x$HAIKU" = "xyes"; then
2402 SKIP_HAIKU=
2403 case "$enable_gui_canon" in
2404 no) AC_MSG_RESULT(no GUI support)
2405 SKIP_HAIKU=YES ;;
2406 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
2407 auto) AC_MSG_RESULT(auto - automatic GUI support) ;;
2408 haiku) AC_MSG_RESULT(Haiku GUI support) ;;
2409 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2410 SKIP_HAIKU=YES ;;
2411 esac
2412elif test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002413 SKIP_PHOTON=
2414 case "$enable_gui_canon" in
2415 no) AC_MSG_RESULT(no GUI support)
2416 SKIP_PHOTON=YES ;;
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002417 yes|""|auto) AC_MSG_RESULT(automatic GUI support)
2418 gui_auto=yes ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002419 photon) AC_MSG_RESULT(Photon GUI support) ;;
2420 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2421 SKIP_PHOTON=YES ;;
2422 esac
2423
Bram Moolenaar071d4272004-06-13 20:20:40 +00002424else
2425
Bram Moolenaar071d4272004-06-13 20:20:40 +00002426 case "$enable_gui_canon" in
2427 no|none) AC_MSG_RESULT(no GUI support) ;;
2428 yes|""|auto) AC_MSG_RESULT(yes/auto - automatic GUI support)
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002429 gui_auto=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002430 SKIP_GTK2=
2431 SKIP_GNOME=
2432 SKIP_MOTIF=
2433 SKIP_ATHENA=
Bram Moolenaar097148e2020-08-11 21:58:20 +02002434 SKIP_NEXTAW=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002435 gtk2) AC_MSG_RESULT(GTK+ 2.x GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002436 SKIP_GTK2=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002437 gnome2) AC_MSG_RESULT(GNOME 2.x GUI support)
2438 SKIP_GNOME=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002439 SKIP_GTK2=;;
Bram Moolenaar98921892016-02-23 17:14:37 +01002440 gtk3) AC_MSG_RESULT(GTK+ 3.x GUI support)
2441 SKIP_GTK3=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002442 motif) AC_MSG_RESULT(Motif GUI support)
2443 SKIP_MOTIF=;;
2444 athena) AC_MSG_RESULT(Athena GUI support)
2445 SKIP_ATHENA=;;
2446 nextaw) AC_MSG_RESULT(neXtaw GUI support)
2447 SKIP_NEXTAW=;;
2448 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
2449 esac
2450
2451fi
2452
Bram Moolenaar071d4272004-06-13 20:20:40 +00002453if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \
2454 -a "$enable_gui_canon" != "gnome2"; then
2455 AC_MSG_CHECKING(whether or not to look for GTK+ 2)
2456 AC_ARG_ENABLE(gtk2-check,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002457 [ --enable-gtk2-check If auto-select GUI, check for GTK+ 2 [default=yes]],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002458 , enable_gtk2_check="yes")
2459 AC_MSG_RESULT($enable_gtk2_check)
2460 if test "x$enable_gtk2_check" = "xno"; then
2461 SKIP_GTK2=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002462 SKIP_GNOME=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002463 fi
2464fi
2465
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002466if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002467 AC_MSG_CHECKING(whether or not to look for GNOME)
2468 AC_ARG_ENABLE(gnome-check,
2469 [ --enable-gnome-check If GTK GUI, check for GNOME [default=no]],
2470 , enable_gnome_check="no")
2471 AC_MSG_RESULT($enable_gnome_check)
2472 if test "x$enable_gnome_check" = "xno"; then
2473 SKIP_GNOME=YES
2474 fi
2475fi
2476
Bram Moolenaar98921892016-02-23 17:14:37 +01002477if test "x$SKIP_GTK3" != "xYES" -a "$enable_gui_canon" != "gtk3"; then
2478 AC_MSG_CHECKING(whether or not to look for GTK+ 3)
2479 AC_ARG_ENABLE(gtk3-check,
2480 [ --enable-gtk3-check If auto-select GUI, check for GTK+ 3 [default=yes]],
2481 , enable_gtk3_check="yes")
2482 AC_MSG_RESULT($enable_gtk3_check)
2483 if test "x$enable_gtk3_check" = "xno"; then
2484 SKIP_GTK3=YES
2485 fi
2486fi
2487
Bram Moolenaar071d4272004-06-13 20:20:40 +00002488if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then
2489 AC_MSG_CHECKING(whether or not to look for Motif)
2490 AC_ARG_ENABLE(motif-check,
2491 [ --enable-motif-check If auto-select GUI, check for Motif [default=yes]],
2492 , enable_motif_check="yes")
2493 AC_MSG_RESULT($enable_motif_check)
2494 if test "x$enable_motif_check" = "xno"; then
2495 SKIP_MOTIF=YES
2496 fi
2497fi
2498
2499if test "x$SKIP_ATHENA" != "xYES" -a "$enable_gui_canon" != "athena"; then
2500 AC_MSG_CHECKING(whether or not to look for Athena)
2501 AC_ARG_ENABLE(athena-check,
2502 [ --enable-athena-check If auto-select GUI, check for Athena [default=yes]],
2503 , enable_athena_check="yes")
2504 AC_MSG_RESULT($enable_athena_check)
2505 if test "x$enable_athena_check" = "xno"; then
2506 SKIP_ATHENA=YES
2507 fi
2508fi
2509
2510if test "x$SKIP_NEXTAW" != "xYES" -a "$enable_gui_canon" != "nextaw"; then
2511 AC_MSG_CHECKING(whether or not to look for neXtaw)
2512 AC_ARG_ENABLE(nextaw-check,
2513 [ --enable-nextaw-check If auto-select GUI, check for neXtaw [default=yes]],
2514 , enable_nextaw_check="yes")
2515 AC_MSG_RESULT($enable_nextaw_check);
2516 if test "x$enable_nextaw_check" = "xno"; then
2517 SKIP_NEXTAW=YES
2518 fi
2519fi
2520
Bram Moolenaar071d4272004-06-13 20:20:40 +00002521dnl define an autoconf function to check for a specified version of GTK, and
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002522dnl try to compile/link a GTK program.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002523dnl
2524dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002525dnl Test for GTK, and define GTK_CFLAGS, GTK_LIBDIR and GTK_LIBS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002526dnl
2527AC_DEFUN(AM_PATH_GTK,
2528[
2529 if test "X$GTK_CONFIG" != "Xno" -o "X$PKG_CONFIG" != "Xno"; then
2530 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00002531 no_gtk=""
2532 if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2533 && $PKG_CONFIG --exists gtk+-2.0; then
2534 {
Bram Moolenaar98921892016-02-23 17:14:37 +01002535 min_gtk_version=ifelse([$1], ,2.2.0,$1)
2536 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002537 dnl We should be using PKG_CHECK_MODULES() instead of this hack.
2538 dnl But I guess the dependency on pkgconfig.m4 is not wanted or
2539 dnl something like that.
2540 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0`
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002541 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-2.0`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002542 GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0`
2543 gtk_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2544 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2545 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2546 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2547 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2548 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2549 }
Bram Moolenaar98921892016-02-23 17:14:37 +01002550 elif (test "X$SKIP_GTK3" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2551 && $PKG_CONFIG --exists gtk+-3.0; then
2552 {
2553 min_gtk_version=ifelse([$1], ,3.0.0,$1)
2554 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
2555
2556 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-3.0`
2557 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-3.0`
2558 GTK_LIBS=`$PKG_CONFIG --libs gtk+-3.0`
2559 gtk_major_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2560 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2561 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2562 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2563 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2564 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2565 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002566 else
2567 no_gtk=yes
2568 fi
2569
2570 if test "x$enable_gtktest" = "xyes" -a "x$no_gtk" = "x"; then
2571 {
2572 ac_save_CFLAGS="$CFLAGS"
2573 ac_save_LIBS="$LIBS"
2574 CFLAGS="$CFLAGS $GTK_CFLAGS"
2575 LIBS="$LIBS $GTK_LIBS"
2576
2577 dnl
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002578 dnl Now check if the installed GTK is sufficiently new.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002579 dnl
2580 rm -f conf.gtktest
2581 AC_TRY_RUN([
2582#include <gtk/gtk.h>
2583#include <stdio.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00002584#if STDC_HEADERS
2585# include <stdlib.h>
2586# include <stddef.h>
2587#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002588
2589int
2590main ()
2591{
2592int major, minor, micro;
2593char *tmp_version;
2594
2595system ("touch conf.gtktest");
2596
2597/* HP/UX 9 (%@#!) writes to sscanf strings */
2598tmp_version = g_strdup("$min_gtk_version");
2599if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
2600 printf("%s, bad version string\n", "$min_gtk_version");
2601 exit(1);
2602 }
2603
2604if ((gtk_major_version > major) ||
2605 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
2606 ((gtk_major_version == major) && (gtk_minor_version == minor) &&
2607 (gtk_micro_version >= micro)))
2608{
2609 return 0;
2610}
2611return 1;
2612}
2613],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
2614 CFLAGS="$ac_save_CFLAGS"
2615 LIBS="$ac_save_LIBS"
2616 }
2617 fi
2618 if test "x$no_gtk" = x ; then
2619 if test "x$enable_gtktest" = "xyes"; then
2620 AC_MSG_RESULT(yes; found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2621 else
2622 AC_MSG_RESULT(found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2623 fi
2624 ifelse([$2], , :, [$2])
2625 else
2626 {
2627 AC_MSG_RESULT(no)
2628 GTK_CFLAGS=""
2629 GTK_LIBS=""
2630 ifelse([$3], , :, [$3])
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002631 if test "$fail_if_missing" = "yes" -a "X$gui_auto" != "Xyes"; then
2632 AC_MSG_ERROR([could not configure GTK])
2633 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002634 }
2635 fi
2636 }
2637 else
2638 GTK_CFLAGS=""
2639 GTK_LIBS=""
2640 ifelse([$3], , :, [$3])
2641 fi
2642 AC_SUBST(GTK_CFLAGS)
2643 AC_SUBST(GTK_LIBS)
2644 rm -f conf.gtktest
2645])
2646
2647dnl ---------------------------------------------------------------------------
2648dnl gnome
2649dnl ---------------------------------------------------------------------------
2650AC_DEFUN([GNOME_INIT_HOOK],
2651[
2652 AC_SUBST(GNOME_LIBS)
2653 AC_SUBST(GNOME_LIBDIR)
2654 AC_SUBST(GNOME_INCLUDEDIR)
2655
2656 AC_ARG_WITH(gnome-includes,
2657 [ --with-gnome-includes=DIR Specify location of GNOME headers],
2658 [CFLAGS="$CFLAGS -I$withval"]
2659 )
2660
2661 AC_ARG_WITH(gnome-libs,
2662 [ --with-gnome-libs=DIR Specify location of GNOME libs],
2663 [LDFLAGS="$LDFLAGS -L$withval" gnome_prefix=$withval]
2664 )
2665
2666 AC_ARG_WITH(gnome,
2667 [ --with-gnome Specify prefix for GNOME files],
2668 if test x$withval = xyes; then
2669 want_gnome=yes
2670 ifelse([$1], [], :, [$1])
2671 else
2672 if test "x$withval" = xno; then
2673 want_gnome=no
2674 else
2675 want_gnome=yes
2676 LDFLAGS="$LDFLAGS -L$withval/lib"
2677 CFLAGS="$CFLAGS -I$withval/include"
2678 gnome_prefix=$withval/lib
2679 fi
2680 fi,
2681 want_gnome=yes)
2682
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002683 if test "x$want_gnome" = xyes; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002684 {
2685 AC_MSG_CHECKING(for libgnomeui-2.0)
2686 if $PKG_CONFIG --exists libgnomeui-2.0; then
2687 AC_MSG_RESULT(yes)
2688 GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0`
2689 GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0`
2690 GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0`
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002691
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002692 dnl On FreeBSD we need -pthread but pkg-config doesn't include it.
2693 dnl This might not be the right way but it works for me...
2694 AC_MSG_CHECKING(for FreeBSD)
2695 if test "`(uname) 2>/dev/null`" = FreeBSD; then
2696 AC_MSG_RESULT(yes, adding -pthread)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002697 GNOME_INCLUDEDIR="$GNOME_INCLUDEDIR -D_THREAD_SAFE"
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002698 GNOME_LIBS="$GNOME_LIBS -pthread"
2699 else
2700 AC_MSG_RESULT(no)
2701 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002702 $1
2703 else
2704 AC_MSG_RESULT(not found)
2705 if test "x$2" = xfail; then
2706 AC_MSG_ERROR(Could not find libgnomeui-2.0 via pkg-config)
2707 fi
2708 fi
2709 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002710 fi
2711])
2712
2713AC_DEFUN([GNOME_INIT],[
2714 GNOME_INIT_HOOK([],fail)
2715])
2716
Bram Moolenaar427f5b62019-06-09 13:43:51 +02002717if test "X$PKG_CONFIG" = "X"; then
2718 AC_PATH_TOOL(PKG_CONFIG, pkg-config, no)
2719fi
2720
Bram Moolenaar071d4272004-06-13 20:20:40 +00002721
2722dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002723dnl Check for GTK2. If it fails, then continue on for Motif as before...
Bram Moolenaar071d4272004-06-13 20:20:40 +00002724dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002725if test -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002726
2727 AC_MSG_CHECKING(--disable-gtktest argument)
2728 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2729 , enable_gtktest=yes)
2730 if test "x$enable_gtktest" = "xyes" ; then
2731 AC_MSG_RESULT(gtk test enabled)
2732 else
2733 AC_MSG_RESULT(gtk test disabled)
2734 fi
2735
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002736 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002737 dnl First try finding version 2.2.0 or later. The 2.0.x series has
2738 dnl problems (bold fonts, --remote doesn't work).
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002739 AM_PATH_GTK(2.2.0,
2740 [GUI_LIB_LOC="$GTK_LIBDIR"
2741 GTK_LIBNAME="$GTK_LIBS"
2742 GUI_INC_LOC="$GTK_CFLAGS"], )
2743 if test "x$GTK_CFLAGS" != "x"; then
Bram Moolenaar98921892016-02-23 17:14:37 +01002744 SKIP_GTK3=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002745 SKIP_ATHENA=YES
2746 SKIP_NEXTAW=YES
2747 SKIP_MOTIF=YES
2748 GUITYPE=GTK
2749 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002750 fi
2751 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002752 if test "x$GUITYPE" = "xGTK"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002753 dnl
2754 dnl if GTK exists, then check for GNOME.
2755 dnl
2756 if test -z "$SKIP_GNOME"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002757 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002758 GNOME_INIT_HOOK([have_gnome=yes])
2759 if test "x$have_gnome" = xyes ; then
2760 AC_DEFINE(FEAT_GUI_GNOME)
2761 GUI_INC_LOC="$GUI_INC_LOC $GNOME_INCLUDEDIR"
2762 GTK_LIBNAME="$GTK_LIBNAME $GNOME_LIBDIR $GNOME_LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002763 fi
2764 }
2765 fi
2766 fi
2767fi
2768
Bram Moolenaar98921892016-02-23 17:14:37 +01002769
2770dnl ---------------------------------------------------------------------------
2771dnl Check for GTK3.
2772dnl ---------------------------------------------------------------------------
2773if test -z "$SKIP_GTK3"; then
2774
2775 AC_MSG_CHECKING(--disable-gtktest argument)
2776 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2777 , enable_gtktest=yes)
2778 if test "x$enable_gtktest" = "xyes" ; then
2779 AC_MSG_RESULT(gtk test enabled)
2780 else
2781 AC_MSG_RESULT(gtk test disabled)
2782 fi
2783
Bram Moolenaar98921892016-02-23 17:14:37 +01002784 if test "x$PKG_CONFIG" != "xno"; then
2785 AM_PATH_GTK(3.0.0,
2786 [GUI_LIB_LOC="$GTK_LIBDIR"
2787 GTK_LIBNAME="$GTK_LIBS"
2788 GUI_INC_LOC="$GTK_CFLAGS"], )
2789 if test "x$GTK_CFLAGS" != "x"; then
2790 SKIP_GTK2=YES
2791 SKIP_GNOME=YES
2792 SKIP_ATHENA=YES
2793 SKIP_NEXTAW=YES
2794 SKIP_MOTIF=YES
2795 GUITYPE=GTK
2796 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar98921892016-02-23 17:14:37 +01002797 AC_DEFINE(USE_GTK3)
2798 fi
2799 fi
2800fi
2801
Bram Moolenaard2e03f02016-01-02 22:46:36 +01002802dnl Check the version of Gdk-Pixbuf. If the version is 2.31 or later and
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002803dnl glib-compile-resources is found in PATH, use GResource.
2804if test "x$GUITYPE" = "xGTK"; then
2805 AC_MSG_CHECKING([version of Gdk-Pixbuf])
2806 gdk_pixbuf_version=`$PKG_CONFIG --modversion gdk-pixbuf-2.0`
2807 if test "x$gdk_pixbuf_version" != x ; then
2808 gdk_pixbuf_version_minor=`echo $gdk_pixbuf_version | \
2809 sed -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/'`
2810 if test "x$gdk_pixbuf_version_minor" != x -a \
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002811 $gdk_pixbuf_version_minor -ge 31 ; then
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002812 AC_MSG_RESULT([OK.])
2813 AC_PATH_PROG(GLIB_COMPILE_RESOURCES,[glib-compile-resources],no)
2814 AC_MSG_CHECKING([glib-compile-resources])
2815 if test "x$GLIB_COMPILE_RESOURCES" = xno ; then
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002816 GLIB_COMPILE_RESOURCES=""
2817 AC_MSG_RESULT([cannot be found in PATH.])
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002818 else
2819 AC_MSG_RESULT([usable.])
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002820 AC_DEFINE(USE_GRESOURCE)
2821 GRESOURCE_SRC="auto/gui_gtk_gresources.c"
2822 GRESOURCE_OBJ="objects/gui_gtk_gresources.o"
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002823 fi
2824 else
2825 AC_MSG_RESULT([not usable.])
2826 fi
2827 else
2828 AC_MSG_RESULT([cannot obtain from pkg_config.])
2829 fi
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002830
2831 AC_MSG_CHECKING([--disable-icon-cache-update argument])
2832 AC_ARG_ENABLE(icon_cache_update,
2833 [ --disable-icon-cache-update update disabled],
2834 [],
2835 [enable_icon_cache_update="yes"])
2836 if test "$enable_icon_cache_update" = "yes"; then
2837 AC_MSG_RESULT([not set])
2838 AC_PATH_PROG(GTK_UPDATE_ICON_CACHE,[gtk-update-icon-cache],no)
2839 if test "x$GTK_UPDATE_ICON_CACHE" = "xno" ; then
2840 AC_MSG_RESULT([not found in PATH.])
2841 fi
2842 else
2843 AC_MSG_RESULT([update disabled])
2844 fi
2845
2846 AC_MSG_CHECKING([--disable-desktop-database-update argument])
2847 AC_ARG_ENABLE(desktop_database_update,
2848 [ --disable-desktop-database-update update disabled],
2849 [],
2850 [enable_desktop_database_update="yes"])
2851 if test "$enable_desktop_database_update" = "yes"; then
2852 AC_MSG_RESULT([not set])
2853 AC_PATH_PROG(UPDATE_DESKTOP_DATABASE,[update-desktop-database],no)
2854 if test "x$UPDATE_DESKTOP_DATABASE" = "xno" ; then
2855 AC_MSG_RESULT([not found in PATH.])
2856 fi
2857 else
2858 AC_MSG_RESULT([update disabled])
2859 fi
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002860fi
2861AC_SUBST(GLIB_COMPILE_RESOURCES)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002862AC_SUBST(GRESOURCE_SRC)
2863AC_SUBST(GRESOURCE_OBJ)
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002864AC_SUBST(GTK_UPDATE_ICON_CACHE)
2865AC_SUBST(UPDATE_DESKTOP_DATABASE)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002866
Bram Moolenaar071d4272004-06-13 20:20:40 +00002867dnl Check for Motif include files location.
2868dnl The LAST one found is used, this makes the highest version to be used,
2869dnl e.g. when Motif1.2 and Motif2.0 are both present.
2870
2871if test -z "$SKIP_MOTIF"; then
2872 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"
2873 dnl Remove "-I" from before $GUI_INC_LOC if it's there
2874 GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`"
2875
2876 AC_MSG_CHECKING(for location of Motif GUI includes)
2877 gui_includes="`echo $x_includes|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC"
2878 GUI_INC_LOC=
2879 for try in $gui_includes; do
2880 if test -f "$try/Xm/Xm.h"; then
2881 GUI_INC_LOC=$try
2882 fi
2883 done
2884 if test -n "$GUI_INC_LOC"; then
2885 if test "$GUI_INC_LOC" = /usr/include; then
2886 GUI_INC_LOC=
2887 AC_MSG_RESULT(in default path)
2888 else
2889 AC_MSG_RESULT($GUI_INC_LOC)
2890 fi
2891 else
2892 AC_MSG_RESULT(<not found>)
2893 SKIP_MOTIF=YES
2894 fi
2895fi
2896
2897dnl Check for Motif library files location. In the same order as the include
2898dnl files, to avoid a mixup if several versions are present
2899
2900if test -z "$SKIP_MOTIF"; then
2901 AC_MSG_CHECKING(--with-motif-lib argument)
2902 AC_ARG_WITH(motif-lib,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002903 [ --with-motif-lib=STRING Library for Motif ],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002904 [ MOTIF_LIBNAME="${withval}" ] )
2905
2906 if test -n "$MOTIF_LIBNAME"; then
2907 AC_MSG_RESULT($MOTIF_LIBNAME)
2908 GUI_LIB_LOC=
2909 else
2910 AC_MSG_RESULT(no)
2911
2912 dnl Remove "-L" from before $GUI_LIB_LOC if it's there
2913 GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
2914
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002915 dnl Ubuntu has libXm.so in /usr/lib/i386-linux-gnu and elsewhere. The
2916 dnl linker will figure out which one to use, we only check if one exists.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002917 AC_MSG_CHECKING(for location of Motif GUI libs)
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002918 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 +00002919 GUI_LIB_LOC=
2920 for try in $gui_libs; do
Bram Moolenaar325b7a22004-07-05 15:58:32 +00002921 for libtry in "$try"/libXm.a "$try"/libXm.so* "$try"/libXm.sl "$try"/libXm.dylib; do
Bram Moolenaar071d4272004-06-13 20:20:40 +00002922 if test -f "$libtry"; then
2923 GUI_LIB_LOC=$try
2924 fi
2925 done
2926 done
2927 if test -n "$GUI_LIB_LOC"; then
2928 dnl Remove /usr/lib, it causes trouble on some systems
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002929 if test "$GUI_LIB_LOC" = /usr/lib \
2930 -o "$GUI_LIB_LOC" = /usr/lib/i386-linux-gnu \
2931 -o "$GUI_LIB_LOC" = /usr/lib/x86_64-linux-gnu; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002932 GUI_LIB_LOC=
2933 AC_MSG_RESULT(in default path)
2934 else
2935 if test -n "$GUI_LIB_LOC"; then
2936 AC_MSG_RESULT($GUI_LIB_LOC)
2937 if test "`(uname) 2>/dev/null`" = SunOS &&
2938 uname -r | grep '^5' >/dev/null; then
2939 GUI_LIB_LOC="$GUI_LIB_LOC -R $GUI_LIB_LOC"
2940 fi
2941 fi
2942 fi
2943 MOTIF_LIBNAME=-lXm
2944 else
2945 AC_MSG_RESULT(<not found>)
2946 SKIP_MOTIF=YES
2947 fi
2948 fi
2949fi
2950
2951if test -z "$SKIP_MOTIF"; then
2952 SKIP_ATHENA=YES
2953 SKIP_NEXTAW=YES
2954 GUITYPE=MOTIF
2955 AC_SUBST(MOTIF_LIBNAME)
2956fi
2957
2958dnl Check if the Athena files can be found
2959
2960GUI_X_LIBS=
2961
2962if test -z "$SKIP_ATHENA"; then
2963 AC_MSG_CHECKING(if Athena header files can be found)
2964 cflags_save=$CFLAGS
2965 CFLAGS="$CFLAGS $X_CFLAGS"
2966 AC_TRY_COMPILE([
2967#include <X11/Intrinsic.h>
2968#include <X11/Xaw/Paned.h>], ,
2969 AC_MSG_RESULT(yes),
2970 AC_MSG_RESULT(no); SKIP_ATHENA=YES )
2971 CFLAGS=$cflags_save
2972fi
2973
2974if test -z "$SKIP_ATHENA"; then
2975 GUITYPE=ATHENA
2976fi
2977
2978if test -z "$SKIP_NEXTAW"; then
2979 AC_MSG_CHECKING(if neXtaw header files can be found)
2980 cflags_save=$CFLAGS
2981 CFLAGS="$CFLAGS $X_CFLAGS"
2982 AC_TRY_COMPILE([
2983#include <X11/Intrinsic.h>
2984#include <X11/neXtaw/Paned.h>], ,
2985 AC_MSG_RESULT(yes),
2986 AC_MSG_RESULT(no); SKIP_NEXTAW=YES )
2987 CFLAGS=$cflags_save
2988fi
2989
2990if test -z "$SKIP_NEXTAW"; then
2991 GUITYPE=NEXTAW
2992fi
2993
2994if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
2995 dnl Prepend -I and -L to $GUI_INC_LOC and $GUI_LIB_LOC if not empty
2996 dnl Avoid adding it when it twice
2997 if test -n "$GUI_INC_LOC"; then
2998 GUI_INC_LOC=-I"`echo $GUI_INC_LOC|sed 's%-I%%'`"
2999 fi
3000 if test -n "$GUI_LIB_LOC"; then
3001 GUI_LIB_LOC=-L"`echo $GUI_LIB_LOC|sed 's%-L%%'`"
3002 fi
3003
3004 dnl Check for -lXext and then for -lXmu
3005 ldflags_save=$LDFLAGS
3006 LDFLAGS="$X_LIBS $LDFLAGS"
3007 AC_CHECK_LIB(Xext, XShapeQueryExtension, [GUI_X_LIBS="-lXext"],,
3008 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3009 dnl For Solaris we need -lw and -ldl before linking with -lXmu works.
3010 AC_CHECK_LIB(w, wslen, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lw"],,
3011 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3012 AC_CHECK_LIB(dl, dlsym, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldl"],,
3013 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3014 AC_CHECK_LIB(Xmu, XmuCreateStippledPixmap, [GUI_X_LIBS="-lXmu $GUI_X_LIBS"],,
3015 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3016 if test -z "$SKIP_MOTIF"; then
3017 AC_CHECK_LIB(Xp, XpEndJob, [GUI_X_LIBS="-lXp $GUI_X_LIBS"],,
3018 [$GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3019 fi
3020 LDFLAGS=$ldflags_save
3021
3022 dnl Execute xmkmf to figure out if -DNARROWPROTO is needed.
3023 AC_MSG_CHECKING(for extra X11 defines)
3024 NARROW_PROTO=
3025 rm -fr conftestdir
3026 if mkdir conftestdir; then
3027 cd conftestdir
3028 cat > Imakefile <<'EOF'
3029acfindx:
3030 @echo 'NARROW_PROTO="${PROTO_DEFINES}"'
3031EOF
3032 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
3033 eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
3034 fi
3035 cd ..
3036 rm -fr conftestdir
3037 fi
3038 if test -z "$NARROW_PROTO"; then
3039 AC_MSG_RESULT(no)
3040 else
3041 AC_MSG_RESULT($NARROW_PROTO)
3042 fi
3043 AC_SUBST(NARROW_PROTO)
3044fi
3045
3046dnl Look for XSMP support - but don't necessarily restrict it to X11 GUIs
3047dnl use the X11 include path
3048if test "$enable_xsmp" = "yes"; then
3049 cppflags_save=$CPPFLAGS
3050 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3051 AC_CHECK_HEADERS(X11/SM/SMlib.h)
3052 CPPFLAGS=$cppflags_save
3053fi
3054
3055
Bram Moolenaar98921892016-02-23 17:14:37 +01003056if 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 +00003057 dnl Check for X11/xpm.h and X11/Sunkeysym.h with the GUI include path
3058 cppflags_save=$CPPFLAGS
3059 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3060 AC_CHECK_HEADERS(X11/xpm.h X11/Sunkeysym.h)
3061
3062 dnl automatically disable XIM when XIMtext isn't in X11/Xlib.h
3063 if test ! "$enable_xim" = "no"; then
3064 AC_MSG_CHECKING(for XIMText in X11/Xlib.h)
3065 AC_EGREP_CPP(XIMText, [#include <X11/Xlib.h>],
3066 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +02003067 AC_MSG_RESULT(no; xim has been disabled); enable_xim="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00003068 fi
3069 CPPFLAGS=$cppflags_save
3070
Bram Moolenaar54612582019-11-21 17:13:31 +01003071 dnl automatically enable XIM in the GUI
3072 if test "$enable_xim" = "auto" -a "x$GUITYPE" != "xNONE" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003073 AC_MSG_RESULT(X GUI selected; xim has been enabled)
3074 enable_xim="yes"
3075 fi
3076fi
3077
3078if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
3079 cppflags_save=$CPPFLAGS
3080 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00003081dnl Xmu/Editres.h may exist but can only be used after including Intrinsic.h
3082 AC_MSG_CHECKING([for X11/Xmu/Editres.h])
3083 AC_TRY_COMPILE([
3084#include <X11/Intrinsic.h>
3085#include <X11/Xmu/Editres.h>],
3086 [int i; i = 0;],
3087 AC_MSG_RESULT(yes)
3088 AC_DEFINE(HAVE_X11_XMU_EDITRES_H),
3089 AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003090 CPPFLAGS=$cppflags_save
3091fi
3092
3093dnl Only use the Xm directory when compiling Motif, don't use it for Athena
3094if test -z "$SKIP_MOTIF"; then
3095 cppflags_save=$CPPFLAGS
3096 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003097 if test "$zOSUnix" = "yes"; then
3098 xmheader="Xm/Xm.h"
3099 else
3100 xmheader="Xm/Xm.h Xm/XpmP.h Xm/JoinSideT.h Xm/TraitP.h Xm/Manager.h
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02003101 Xm/UnhighlightT.h Xm/Notebook.h"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003102 fi
3103 AC_CHECK_HEADERS($xmheader)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003104
Bram Moolenaar77c19352012-06-13 19:19:41 +02003105 if test "x$ac_cv_header_Xm_XpmP_h" = "xyes"; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003106 dnl Solaris uses XpmAttributes_21, very annoying.
3107 AC_MSG_CHECKING([for XpmAttributes_21 in Xm/XpmP.h])
3108 AC_TRY_COMPILE([#include <Xm/XpmP.h>], [XpmAttributes_21 attr;],
3109 AC_MSG_RESULT(yes); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes_21),
3110 AC_MSG_RESULT(no); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
3111 )
3112 else
Bram Moolenaar57657d82006-04-21 22:12:41 +00003113 AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003114 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003115 CPPFLAGS=$cppflags_save
3116fi
3117
3118if test "x$GUITYPE" = "xNONE" -a "$enable_xim" = "yes"; then
3119 AC_MSG_RESULT(no GUI selected; xim has been disabled)
3120 enable_xim="no"
3121fi
3122if test "x$GUITYPE" = "xNONE" -a "$enable_fontset" = "yes"; then
3123 AC_MSG_RESULT(no GUI selected; fontset has been disabled)
3124 enable_fontset="no"
3125fi
Bram Moolenaar182c5be2010-06-25 05:37:59 +02003126if test "x$GUITYPE:$enable_fontset" = "xGTK:yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003127 AC_MSG_RESULT(GTK+ 2 GUI selected; fontset has been disabled)
3128 enable_fontset="no"
3129fi
3130
Bram Moolenaarb3f74062020-02-26 16:16:53 +01003131dnl There is no test for the Haiku GUI, if it's selected it's used
3132if test -z "$SKIP_HAIKU"; then
3133 GUITYPE=HAIKUGUI
3134fi
3135
Bram Moolenaar071d4272004-06-13 20:20:40 +00003136if test -z "$SKIP_PHOTON"; then
3137 GUITYPE=PHOTONGUI
3138fi
3139
3140AC_SUBST(GUI_INC_LOC)
3141AC_SUBST(GUI_LIB_LOC)
3142AC_SUBST(GUITYPE)
3143AC_SUBST(GUI_X_LIBS)
3144
3145if test "$enable_workshop" = "yes" -a -n "$SKIP_MOTIF"; then
3146 AC_MSG_ERROR([cannot use workshop without Motif])
3147fi
3148
3149dnl defining FEAT_XIM and FEAT_XFONTSET is delayed, so that they can be disabled
3150if test "$enable_xim" = "yes"; then
3151 AC_DEFINE(FEAT_XIM)
3152fi
3153if test "$enable_fontset" = "yes"; then
3154 AC_DEFINE(FEAT_XFONTSET)
3155fi
3156
3157
3158dnl ---------------------------------------------------------------------------
3159dnl end of GUI-checking
3160dnl ---------------------------------------------------------------------------
3161
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003162AC_MSG_CHECKING([for /proc link to executable])
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003163if test -L "/proc/self/exe"; then
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003164 dnl Linux
3165 AC_MSG_RESULT([/proc/self/exe])
3166 AC_DEFINE(PROC_EXE_LINK, "/proc/self/exe")
3167elif test -L "/proc/self/path/a.out"; then
3168 dnl Solaris
3169 AC_MSG_RESULT([/proc/self/path/a.out])
3170 AC_DEFINE(PROC_EXE_LINK, "/proc/self/path/a.out")
3171elif test -L "/proc/curproc/file"; then
3172 dnl FreeBSD
3173 AC_MSG_RESULT([/proc/curproc/file])
3174 AC_DEFINE(PROC_EXE_LINK, "/proc/curproc/file")
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003175else
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003176 AC_MSG_RESULT(no)
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003177fi
3178
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003179dnl Check for Cygwin, which needs an extra source file if not using X11
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003180AC_MSG_CHECKING(for CYGWIN or MSYS environment)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003181case `uname` in
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003182 CYGWIN*|MSYS*) CYGWIN=yes; AC_MSG_RESULT(yes)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003183 AC_MSG_CHECKING(for CYGWIN clipboard support)
3184 if test "x$with_x" = "xno" ; then
3185 OS_EXTRA_SRC=winclip.c; OS_EXTRA_OBJ=objects/winclip.o
3186 AC_MSG_RESULT(yes)
3187 AC_DEFINE(FEAT_CYGWIN_WIN32_CLIPBOARD)
3188 else
3189 AC_MSG_RESULT(no - using X11)
3190 fi ;;
3191
3192 *) CYGWIN=no; AC_MSG_RESULT(no);;
3193esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00003194
Bram Moolenaar071d4272004-06-13 20:20:40 +00003195dnl Checks for libraries and include files.
3196
Bram Moolenaar446cb832008-06-24 21:56:24 +00003197AC_CACHE_CHECK([whether toupper is broken], [vim_cv_toupper_broken],
3198 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003199 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003200#include "confdefs.h"
3201#include <ctype.h>
3202#if STDC_HEADERS
3203# include <stdlib.h>
3204# include <stddef.h>
3205#endif
3206main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003207 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003208 vim_cv_toupper_broken=yes
3209 ],[
3210 vim_cv_toupper_broken=no
3211 ],[
3212 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_toupper_broken')
3213 ])])
3214
3215if test "x$vim_cv_toupper_broken" = "xyes" ; then
3216 AC_DEFINE(BROKEN_TOUPPER)
3217fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003218
3219AC_MSG_CHECKING(whether __DATE__ and __TIME__ work)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003220AC_TRY_COMPILE([#include <stdio.h>], [printf("(" __DATE__ " " __TIME__ ")");],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003221 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DATE_TIME),
3222 AC_MSG_RESULT(no))
3223
Bram Moolenaar0c094b92009-05-14 20:20:33 +00003224AC_MSG_CHECKING(whether __attribute__((unused)) is allowed)
3225AC_TRY_COMPILE([#include <stdio.h>], [int x __attribute__((unused));],
3226 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ATTRIBUTE_UNUSED),
3227 AC_MSG_RESULT(no))
3228
Bram Moolenaar071d4272004-06-13 20:20:40 +00003229dnl Checks for header files.
3230AC_CHECK_HEADER(elf.h, HAS_ELF=1)
3231dnl AC_CHECK_HEADER(dwarf.h, SVR4=1)
3232if test "$HAS_ELF" = 1; then
3233 AC_CHECK_LIB(elf, main)
3234fi
3235
3236AC_HEADER_DIRENT
3237
Bram Moolenaar071d4272004-06-13 20:20:40 +00003238dnl If sys/wait.h is not found it might still exist but not be POSIX
3239dnl compliant. In that case we define HAVE_UNION_WAIT (for NeXT)
3240if test $ac_cv_header_sys_wait_h = no; then
3241 AC_MSG_CHECKING([for sys/wait.h that defines union wait])
3242 AC_TRY_COMPILE([#include <sys/wait.h>],
3243 [union wait xx, yy; xx = yy],
3244 AC_MSG_RESULT(yes)
3245 AC_DEFINE(HAVE_SYS_WAIT_H)
3246 AC_DEFINE(HAVE_UNION_WAIT),
3247 AC_MSG_RESULT(no))
3248fi
3249
Bram Moolenaar779a7752016-01-30 23:26:34 +01003250AC_CHECK_HEADERS(stdint.h stdlib.h string.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003251 sys/select.h sys/utsname.h termcap.h fcntl.h \
3252 sgtty.h sys/ioctl.h sys/time.h sys/types.h \
3253 termio.h iconv.h inttypes.h langinfo.h math.h \
3254 unistd.h stropts.h errno.h sys/resource.h \
3255 sys/systeminfo.h locale.h sys/stream.h termios.h \
3256 libc.h sys/statfs.h poll.h sys/poll.h pwd.h \
Bram Moolenaar1ecc5e42019-01-26 15:12:55 +01003257 utime.h sys/param.h sys/ptms.h libintl.h libgen.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003258 util/debug.h util/msg18n.h frame.h sys/acl.h \
3259 sys/access.h sys/sysinfo.h wchar.h wctype.h)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003260
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003261dnl sys/ptem.h depends on sys/stream.h on Solaris
3262AC_CHECK_HEADERS(sys/ptem.h, [], [],
3263[#if defined HAVE_SYS_STREAM_H
3264# include <sys/stream.h>
3265#endif])
3266
Bram Moolenaar32f31b12009-05-21 13:20:59 +00003267dnl sys/sysctl.h depends on sys/param.h on OpenBSD
3268AC_CHECK_HEADERS(sys/sysctl.h, [], [],
3269[#if defined HAVE_SYS_PARAM_H
3270# include <sys/param.h>
3271#endif])
3272
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003273
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003274dnl pthread_np.h may exist but can only be used after including pthread.h
3275AC_MSG_CHECKING([for pthread_np.h])
3276AC_TRY_COMPILE([
3277#include <pthread.h>
3278#include <pthread_np.h>],
3279 [int i; i = 0;],
3280 AC_MSG_RESULT(yes)
3281 AC_DEFINE(HAVE_PTHREAD_NP_H),
3282 AC_MSG_RESULT(no))
3283
Bram Moolenaare344bea2005-09-01 20:46:49 +00003284AC_CHECK_HEADERS(strings.h)
Bram Moolenaard0573012017-10-28 21:11:06 +02003285if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00003286 dnl The strings.h file on OS/X contains a warning and nothing useful.
3287 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3288else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003289
3290dnl Check if strings.h and string.h can both be included when defined.
3291AC_MSG_CHECKING([if strings.h can be included after string.h])
3292cppflags_save=$CPPFLAGS
3293CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3294AC_TRY_COMPILE([
3295#if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO)
3296# define _NO_PROTO /* like in os_unix.h, causes conflict for AIX (Winn) */
3297 /* but don't do it on AIX 5.1 (Uribarri) */
3298#endif
3299#ifdef HAVE_XM_XM_H
3300# include <Xm/Xm.h> /* This breaks it for HP-UX 11 (Squassabia) */
3301#endif
3302#ifdef HAVE_STRING_H
3303# include <string.h>
3304#endif
3305#if defined(HAVE_STRINGS_H)
3306# include <strings.h>
3307#endif
3308 ], [int i; i = 0;],
3309 AC_MSG_RESULT(yes),
3310 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3311 AC_MSG_RESULT(no))
3312CPPFLAGS=$cppflags_save
Bram Moolenaar9372a112005-12-06 19:59:18 +00003313fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003314
3315dnl Checks for typedefs, structures, and compiler characteristics.
3316AC_PROG_GCC_TRADITIONAL
3317AC_C_CONST
Bram Moolenaar76243bd2009-03-02 01:47:02 +00003318AC_C_VOLATILE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003319AC_TYPE_MODE_T
3320AC_TYPE_OFF_T
3321AC_TYPE_PID_T
3322AC_TYPE_SIZE_T
3323AC_TYPE_UID_T
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003324AC_TYPE_UINT32_T
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003325
Bram Moolenaar071d4272004-06-13 20:20:40 +00003326AC_HEADER_TIME
3327AC_CHECK_TYPE(ino_t, long)
3328AC_CHECK_TYPE(dev_t, unsigned)
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003329AC_C_BIGENDIAN(,,,)
Bram Moolenaar136f29a2016-02-27 20:14:15 +01003330AC_C_INLINE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003331
3332AC_MSG_CHECKING(for rlim_t)
3333if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
3334 AC_MSG_RESULT([(cached) $ac_cv_type_rlim_t])
3335else
3336 AC_EGREP_CPP(dnl
3337changequote(<<,>>)dnl
3338<<(^|[^a-zA-Z_0-9])rlim_t[^a-zA-Z_0-9]>>dnl
3339changequote([,]),
3340 [
3341#include <sys/types.h>
3342#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003343# include <stdlib.h>
3344# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003345#endif
3346#ifdef HAVE_SYS_RESOURCE_H
Bram Moolenaar446cb832008-06-24 21:56:24 +00003347# include <sys/resource.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003348#endif
3349 ], ac_cv_type_rlim_t=yes, ac_cv_type_rlim_t=no)
3350 AC_MSG_RESULT($ac_cv_type_rlim_t)
3351fi
3352if test $ac_cv_type_rlim_t = no; then
3353 cat >> confdefs.h <<\EOF
3354#define rlim_t unsigned long
3355EOF
3356fi
3357
3358AC_MSG_CHECKING(for stack_t)
3359if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then
3360 AC_MSG_RESULT([(cached) $ac_cv_type_stack_t])
3361else
3362 AC_EGREP_CPP(stack_t,
3363 [
3364#include <sys/types.h>
3365#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003366# include <stdlib.h>
3367# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003368#endif
3369#include <signal.h>
3370 ], ac_cv_type_stack_t=yes, ac_cv_type_stack_t=no)
3371 AC_MSG_RESULT($ac_cv_type_stack_t)
3372fi
3373if test $ac_cv_type_stack_t = no; then
3374 cat >> confdefs.h <<\EOF
3375#define stack_t struct sigaltstack
3376EOF
3377fi
3378
3379dnl BSDI uses ss_base while others use ss_sp for the stack pointer.
3380AC_MSG_CHECKING(whether stack_t has an ss_base field)
3381AC_TRY_COMPILE([
3382#include <sys/types.h>
3383#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003384# include <stdlib.h>
3385# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003386#endif
3387#include <signal.h>
3388#include "confdefs.h"
3389 ], [stack_t sigstk; sigstk.ss_base = 0; ],
3390 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SS_BASE),
3391 AC_MSG_RESULT(no))
3392
3393olibs="$LIBS"
3394AC_MSG_CHECKING(--with-tlib argument)
3395AC_ARG_WITH(tlib, [ --with-tlib=library terminal library to be used ],)
3396if test -n "$with_tlib"; then
3397 AC_MSG_RESULT($with_tlib)
3398 LIBS="$LIBS -l$with_tlib"
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003399 AC_MSG_CHECKING(for linking with $with_tlib library)
3400 AC_TRY_LINK([], [], AC_MSG_RESULT(OK), AC_MSG_ERROR(FAILED))
3401 dnl Need to check for tgetent() below.
3402 olibs="$LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003403else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003404 AC_MSG_RESULT([empty: automatic terminal library selection])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003405 dnl On HP-UX 10.10 termcap or termlib should be used instead of
3406 dnl curses, because curses is much slower.
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003407 dnl Newer versions of ncurses are preferred over anything, except
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02003408 dnl when tinfo has been split off, it contains all we need.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003409 dnl Older versions of ncurses have bugs, get a new one!
3410 dnl Digital Unix (OSF1) should use curses (Ronald Schild).
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00003411 dnl On SCO Openserver should prefer termlib (Roger Cornelius).
Bram Moolenaar071d4272004-06-13 20:20:40 +00003412 case "`uname -s 2>/dev/null`" in
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003413 OSF1|SCO_SV) tlibs="tinfo ncurses curses termlib termcap";;
3414 *) tlibs="tinfo ncurses termlib termcap curses";;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003415 esac
3416 for libname in $tlibs; do
3417 AC_CHECK_LIB(${libname}, tgetent,,)
3418 if test "x$olibs" != "x$LIBS"; then
3419 dnl It's possible that a library is found but it doesn't work
3420 dnl e.g., shared library that cannot be found
3421 dnl compile and run a test program to be sure
3422 AC_TRY_RUN([
3423#ifdef HAVE_TERMCAP_H
3424# include <termcap.h>
3425#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003426#if STDC_HEADERS
3427# include <stdlib.h>
3428# include <stddef.h>
3429#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003430main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }],
3431 res="OK", res="FAIL", res="FAIL")
3432 if test "$res" = "OK"; then
3433 break
3434 fi
3435 AC_MSG_RESULT($libname library is not usable)
3436 LIBS="$olibs"
3437 fi
3438 done
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003439 if test "x$olibs" = "x$LIBS"; then
3440 AC_MSG_RESULT(no terminal library found)
3441 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003442fi
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003443
3444if test "x$olibs" = "x$LIBS"; then
3445 AC_MSG_CHECKING([for tgetent()])
Bram Moolenaarbd7f7c12020-07-28 21:03:37 +02003446 AC_TRY_LINK([int tgetent(char *, const char *);],
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003447 [char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");],
3448 AC_MSG_RESULT(yes),
3449 AC_MSG_ERROR([NOT FOUND!
3450 You need to install a terminal library; for example ncurses.
3451 Or specify the name of the library with --with-tlib.]))
3452fi
3453
Bram Moolenaar446cb832008-06-24 21:56:24 +00003454AC_CACHE_CHECK([whether we talk terminfo], [vim_cv_terminfo],
3455 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003456 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003457#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003458#ifdef HAVE_TERMCAP_H
3459# include <termcap.h>
3460#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003461#ifdef HAVE_STRING_H
3462# include <string.h>
3463#endif
3464#if STDC_HEADERS
3465# include <stdlib.h>
3466# include <stddef.h>
3467#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003468main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003469{char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003470 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003471 vim_cv_terminfo=no
3472 ],[
3473 vim_cv_terminfo=yes
3474 ],[
3475 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_terminfo')
3476 ])
3477 ])
3478
3479if test "x$vim_cv_terminfo" = "xyes" ; then
3480 AC_DEFINE(TERMINFO)
3481fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003482
Bram Moolenaara88254f2017-11-02 23:04:14 +01003483AC_CACHE_CHECK([what tgetent() returns for an unknown terminal], [vim_cv_tgetent],
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003484 [
3485 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003486#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003487#ifdef HAVE_TERMCAP_H
3488# include <termcap.h>
3489#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003490#if STDC_HEADERS
3491# include <stdlib.h>
3492# include <stddef.h>
3493#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003494main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003495{char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003496 ]])],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003497 vim_cv_tgetent=zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003498 ],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003499 vim_cv_tgetent=non-zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003500 ],[
3501 AC_MSG_ERROR(failed to compile test program.)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003502 ])
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003503 ])
3504
Bram Moolenaara88254f2017-11-02 23:04:14 +01003505if test "x$vim_cv_tgetent" = "xzero" ; then
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003506 AC_DEFINE(TGETENT_ZERO_ERR, 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003507fi
3508
3509AC_MSG_CHECKING(whether termcap.h contains ospeed)
3510AC_TRY_LINK([
3511#ifdef HAVE_TERMCAP_H
3512# include <termcap.h>
3513#endif
3514 ], [ospeed = 20000],
3515 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED),
3516 [AC_MSG_RESULT(no)
3517 AC_MSG_CHECKING(whether ospeed can be extern)
3518 AC_TRY_LINK([
3519#ifdef HAVE_TERMCAP_H
3520# include <termcap.h>
3521#endif
3522extern short ospeed;
3523 ], [ospeed = 20000],
3524 AC_MSG_RESULT(yes); AC_DEFINE(OSPEED_EXTERN),
3525 AC_MSG_RESULT(no))]
3526 )
3527
3528AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC])
3529AC_TRY_LINK([
3530#ifdef HAVE_TERMCAP_H
3531# include <termcap.h>
3532#endif
3533 ], [if (UP == 0 && BC == 0) PC = 1],
3534 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UP_BC_PC),
3535 [AC_MSG_RESULT(no)
3536 AC_MSG_CHECKING([whether UP, BC and PC can be extern])
3537 AC_TRY_LINK([
3538#ifdef HAVE_TERMCAP_H
3539# include <termcap.h>
3540#endif
3541extern char *UP, *BC, PC;
3542 ], [if (UP == 0 && BC == 0) PC = 1],
3543 AC_MSG_RESULT(yes); AC_DEFINE(UP_BC_PC_EXTERN),
3544 AC_MSG_RESULT(no))]
3545 )
3546
3547AC_MSG_CHECKING(whether tputs() uses outfuntype)
3548AC_TRY_COMPILE([
3549#ifdef HAVE_TERMCAP_H
3550# include <termcap.h>
3551#endif
3552 ], [extern int xx(); tputs("test", 1, (outfuntype)xx)],
3553 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OUTFUNTYPE),
3554 AC_MSG_RESULT(no))
3555
3556dnl On some SCO machines sys/select redefines struct timeval
3557AC_MSG_CHECKING([whether sys/select.h and sys/time.h may both be included])
3558AC_TRY_COMPILE([
3559#include <sys/types.h>
3560#include <sys/time.h>
3561#include <sys/select.h>], ,
3562 AC_MSG_RESULT(yes)
3563 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME),
3564 AC_MSG_RESULT(no))
3565
3566dnl AC_DECL_SYS_SIGLIST
3567
3568dnl Checks for pty.c (copied from screen) ==========================
3569AC_MSG_CHECKING(for /dev/ptc)
3570if test -r /dev/ptc; then
3571 AC_DEFINE(HAVE_DEV_PTC)
3572 AC_MSG_RESULT(yes)
3573else
3574 AC_MSG_RESULT(no)
3575fi
3576
3577AC_MSG_CHECKING(for SVR4 ptys)
3578if test -c /dev/ptmx ; then
3579 AC_TRY_LINK([], [ptsname(0);grantpt(0);unlockpt(0);],
3580 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SVR4_PTYS),
3581 AC_MSG_RESULT(no))
3582else
3583 AC_MSG_RESULT(no)
3584fi
3585
3586AC_MSG_CHECKING(for ptyranges)
3587if test -d /dev/ptym ; then
3588 pdir='/dev/ptym'
3589else
3590 pdir='/dev'
3591fi
3592dnl SCO uses ptyp%d
3593AC_EGREP_CPP(yes,
3594[#ifdef M_UNIX
3595 yes;
3596#endif
3597 ], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
3598dnl if test -c /dev/ptyp19; then
3599dnl ptys=`echo /dev/ptyp??`
3600dnl else
3601dnl ptys=`echo $pdir/pty??`
3602dnl fi
3603if test "$ptys" != "$pdir/pty??" ; then
3604 p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
3605 p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'`
3606 AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
3607 AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
3608 AC_MSG_RESULT([$p0 / $p1])
3609else
3610 AC_MSG_RESULT([don't know])
3611fi
3612
Bram Moolenaar071d4272004-06-13 20:20:40 +00003613dnl Checks for library functions. ===================================
3614
3615AC_TYPE_SIGNAL
3616
3617dnl find out what to use at the end of a signal function
3618if test $ac_cv_type_signal = void; then
3619 AC_DEFINE(SIGRETURN, [return])
3620else
3621 AC_DEFINE(SIGRETURN, [return 0])
3622fi
3623
3624dnl check if struct sigcontext is defined (used for SGI only)
3625AC_MSG_CHECKING(for struct sigcontext)
3626AC_TRY_COMPILE([
3627#include <signal.h>
3628test_sig()
3629{
3630 struct sigcontext *scont;
3631 scont = (struct sigcontext *)0;
3632 return 1;
3633} ], ,
3634 AC_MSG_RESULT(yes)
3635 AC_DEFINE(HAVE_SIGCONTEXT),
3636 AC_MSG_RESULT(no))
3637
3638dnl tricky stuff: try to find out if getcwd() is implemented with
3639dnl system("sh -c pwd")
Bram Moolenaar446cb832008-06-24 21:56:24 +00003640AC_CACHE_CHECK([getcwd implementation is broken], [vim_cv_getcwd_broken],
3641 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003642 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003643#include "confdefs.h"
3644#ifdef HAVE_UNISTD_H
3645#include <unistd.h>
3646#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003647char *dagger[] = { "IFS=pwd", 0 };
3648main()
3649{
3650 char buffer[500];
3651 extern char **environ;
3652 environ = dagger;
3653 return getcwd(buffer, 500) ? 0 : 1;
Bram Moolenaar446cb832008-06-24 21:56:24 +00003654}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003655 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003656 vim_cv_getcwd_broken=no
3657 ],[
3658 vim_cv_getcwd_broken=yes
3659 ],[
3660 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_getcwd_broken')
3661 ])
3662 ])
3663
3664if test "x$vim_cv_getcwd_broken" = "xyes" ; then
3665 AC_DEFINE(BAD_GETCWD)
Bram Moolenaar63d25552019-05-10 21:28:38 +02003666 AC_CHECK_FUNCS(getwd)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003667fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003668
Bram Moolenaar25153e12010-02-24 14:47:08 +01003669dnl Check for functions in one big call, to reduce the size of configure.
3670dnl Can only be used for functions that do not require any include.
Bram Moolenaarcd142e32017-11-16 17:03:45 +01003671AC_CHECK_FUNCS(fchdir fchown fchmod fsync getcwd getpseudotty \
Bram Moolenaar63d25552019-05-10 21:28:38 +02003672 getpwent getpwnam getpwuid getrlimit gettimeofday localtime_r lstat \
Bram Moolenaareaf03392009-11-17 11:08:52 +00003673 memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
Bram Moolenaar2fcf6682017-03-11 20:03:42 +01003674 getpgid setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
Bram Moolenaar84cf6bd2020-06-16 20:03:43 +02003675 sigprocmask sigvec strcasecmp strcoll strerror strftime stricmp strncasecmp \
Bram Moolenaar10455d42019-11-21 15:36:18 +01003676 strnicmp strpbrk strptime strtol tgetent towlower towupper iswupper \
3677 tzset usleep utime utimes mblen ftruncate unsetenv posix_openpt)
Bram Moolenaar643b6142018-09-12 20:29:09 +02003678AC_FUNC_SELECT_ARGTYPES
Bram Moolenaar25153e12010-02-24 14:47:08 +01003679AC_FUNC_FSEEKO
Bram Moolenaar071d4272004-06-13 20:20:40 +00003680
Bram Moolenaar317fd3a2010-05-07 16:05:55 +02003681dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when
3682dnl appropriate, so that off_t is 64 bits when needed.
3683AC_SYS_LARGEFILE
3684
Bram Moolenaar21606672019-06-14 20:40:58 +02003685AC_MSG_CHECKING(--enable-canberra argument)
3686AC_ARG_ENABLE(canberra,
3687 [ --disable-canberra Do not use libcanberra.],
3688 , [enable_canberra="maybe"])
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003689
Bram Moolenaar21606672019-06-14 20:40:58 +02003690if test "$enable_canberra" = "maybe"; then
3691 if test "$features" = "big" -o "$features" = "huge"; then
3692 AC_MSG_RESULT(Defaulting to yes)
3693 enable_canberra="yes"
3694 else
3695 AC_MSG_RESULT(Defaulting to no)
3696 enable_canberra="no"
3697 fi
3698else
3699 AC_MSG_RESULT($enable_canberra)
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003700fi
Bram Moolenaar21606672019-06-14 20:40:58 +02003701if test "$enable_canberra" = "yes"; then
3702 if test "x$PKG_CONFIG" != "xno"; then
3703 canberra_lib=`$PKG_CONFIG --libs libcanberra 2>/dev/null`
3704 canberra_cflags=`$PKG_CONFIG --cflags libcanberra 2>/dev/null`
3705 fi
3706 if test "x$canberra_lib" = "x"; then
3707 canberra_lib=-lcanberra
3708 canberra_cflags=-D_REENTRANT
3709 fi
3710 AC_MSG_CHECKING(for libcanberra)
3711 ac_save_CFLAGS="$CFLAGS"
3712 ac_save_LIBS="$LIBS"
3713 CFLAGS="$CFLAGS $canberra_cflags"
3714 LIBS="$LIBS $canberra_lib"
3715 AC_TRY_LINK([
3716 # include <canberra.h>
3717 ], [
3718 ca_context *hello;
3719 ca_context_create(&hello);],
3720 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_CANBERRA),
Bram Moolenaar91b992c2019-11-17 19:07:42 +01003721 AC_MSG_RESULT(no; try installing libcanberra-dev); CFLAGS="$ac_save_CFLAGS"; LIBS="$ac_save_LIBS")
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003722fi
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003723
3724
Bram Moolenaar071d4272004-06-13 20:20:40 +00003725dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible
3726AC_MSG_CHECKING(for st_blksize)
3727AC_TRY_COMPILE(
3728[#include <sys/types.h>
3729#include <sys/stat.h>],
3730[ struct stat st;
3731 int n;
3732
3733 stat("/", &st);
3734 n = (int)st.st_blksize;],
3735 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ST_BLKSIZE),
3736 AC_MSG_RESULT(no))
3737
Bram Moolenaar446cb832008-06-24 21:56:24 +00003738AC_CACHE_CHECK([whether stat() ignores a trailing slash], [vim_cv_stat_ignores_slash],
3739 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003740 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003741#include "confdefs.h"
3742#if STDC_HEADERS
3743# include <stdlib.h>
3744# include <stddef.h>
3745#endif
3746#include <sys/types.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003747#include <sys/stat.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003748main() {struct stat st; exit(stat("configure/", &st) != 0); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003749 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003750 vim_cv_stat_ignores_slash=yes
3751 ],[
3752 vim_cv_stat_ignores_slash=no
3753 ],[
3754 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_stat_ignores_slash')
3755 ])
3756 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003757
Bram Moolenaar446cb832008-06-24 21:56:24 +00003758if test "x$vim_cv_stat_ignores_slash" = "xyes" ; then
3759 AC_DEFINE(STAT_IGNORES_SLASH)
3760fi
3761
Bram Moolenaar071d4272004-06-13 20:20:40 +00003762dnl Link with iconv for charset translation, if not found without library.
3763dnl check for iconv() requires including iconv.h
3764dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
3765dnl has been installed.
3766AC_MSG_CHECKING(for iconv_open())
3767save_LIBS="$LIBS"
3768LIBS="$LIBS -liconv"
3769AC_TRY_LINK([
3770#ifdef HAVE_ICONV_H
3771# include <iconv.h>
3772#endif
3773 ], [iconv_open("fr", "to");],
3774 AC_MSG_RESULT(yes; with -liconv); AC_DEFINE(HAVE_ICONV),
3775 LIBS="$save_LIBS"
3776 AC_TRY_LINK([
3777#ifdef HAVE_ICONV_H
3778# include <iconv.h>
3779#endif
3780 ], [iconv_open("fr", "to");],
3781 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ICONV),
3782 AC_MSG_RESULT(no)))
3783
3784
3785AC_MSG_CHECKING(for nl_langinfo(CODESET))
3786AC_TRY_LINK([
3787#ifdef HAVE_LANGINFO_H
3788# include <langinfo.h>
3789#endif
3790], [char *cs = nl_langinfo(CODESET);],
3791 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET),
3792 AC_MSG_RESULT(no))
3793
Bram Moolenaar446cb832008-06-24 21:56:24 +00003794dnl Need various functions for floating point support. Only enable
3795dnl floating point when they are all present.
3796AC_CHECK_LIB(m, strtod)
3797AC_MSG_CHECKING([for strtod() and other floating point functions])
3798AC_TRY_LINK([
3799#ifdef HAVE_MATH_H
3800# include <math.h>
3801#endif
3802#if STDC_HEADERS
3803# include <stdlib.h>
3804# include <stddef.h>
3805#endif
3806], [char *s; double d;
3807 d = strtod("1.1", &s);
3808 d = fabs(1.11);
3809 d = ceil(1.11);
3810 d = floor(1.11);
3811 d = log10(1.11);
3812 d = pow(1.11, 2.22);
3813 d = sqrt(1.11);
3814 d = sin(1.11);
3815 d = cos(1.11);
3816 d = atan(1.11);
3817 ],
3818 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT_FUNCS),
3819 AC_MSG_RESULT(no))
3820
Bram Moolenaara6b89762016-02-29 21:38:26 +01003821dnl isinf() and isnan() need to include header files and may need -lm.
3822AC_MSG_CHECKING([for isinf()])
3823AC_TRY_LINK([
3824#ifdef HAVE_MATH_H
3825# include <math.h>
3826#endif
3827#if STDC_HEADERS
3828# include <stdlib.h>
3829# include <stddef.h>
3830#endif
3831], [int r = isinf(1.11); ],
3832 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISINF),
3833 AC_MSG_RESULT(no))
3834
3835AC_MSG_CHECKING([for isnan()])
3836AC_TRY_LINK([
3837#ifdef HAVE_MATH_H
3838# include <math.h>
3839#endif
3840#if STDC_HEADERS
3841# include <stdlib.h>
3842# include <stddef.h>
3843#endif
3844], [int r = isnan(1.11); ],
3845 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISNAN),
3846 AC_MSG_RESULT(no))
3847
Bram Moolenaar071d4272004-06-13 20:20:40 +00003848dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI
3849dnl when -lacl works, also try to use -lattr (required for Debian).
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003850dnl On Solaris, use the acl_get/set functions in libsec, if present.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003851AC_MSG_CHECKING(--disable-acl argument)
3852AC_ARG_ENABLE(acl,
Bram Moolenaard6d30422018-01-28 22:48:55 +01003853 [ --disable-acl No check for ACL support.],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003854 , [enable_acl="yes"])
3855if test "$enable_acl" = "yes"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01003856 AC_MSG_RESULT(no)
3857 AC_CHECK_LIB(posix1e, acl_get_file, [LIBS="$LIBS -lposix1e"],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003858 AC_CHECK_LIB(acl, acl_get_file, [LIBS="$LIBS -lacl"
3859 AC_CHECK_LIB(attr, fgetxattr, LIBS="$LIBS -lattr",,)],,),)
3860
Bram Moolenaard6d30422018-01-28 22:48:55 +01003861 AC_MSG_CHECKING(for POSIX ACL support)
3862 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003863#include <sys/types.h>
3864#ifdef HAVE_SYS_ACL_H
3865# include <sys/acl.h>
3866#endif
3867acl_t acl;], [acl = acl_get_file("foo", ACL_TYPE_ACCESS);
3868 acl_set_file("foo", ACL_TYPE_ACCESS, acl);
3869 acl_free(acl);],
3870 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_ACL),
3871 AC_MSG_RESULT(no))
3872
Bram Moolenaard6d30422018-01-28 22:48:55 +01003873 AC_CHECK_LIB(sec, acl_get, [LIBS="$LIBS -lsec"; AC_DEFINE(HAVE_SOLARIS_ZFS_ACL)],
3874 AC_MSG_CHECKING(for Solaris ACL support)
3875 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003876#ifdef HAVE_SYS_ACL_H
3877# include <sys/acl.h>
3878#endif], [acl("foo", GETACLCNT, 0, NULL);
3879 ],
3880 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOLARIS_ACL),
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003881 AC_MSG_RESULT(no)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003882
Bram Moolenaard6d30422018-01-28 22:48:55 +01003883 AC_MSG_CHECKING(for AIX ACL support)
3884 AC_TRY_LINK([
Bram Moolenaar446cb832008-06-24 21:56:24 +00003885#if STDC_HEADERS
3886# include <stdlib.h>
3887# include <stddef.h>
3888#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003889#ifdef HAVE_SYS_ACL_H
3890# include <sys/acl.h>
3891#endif
3892#ifdef HAVE_SYS_ACCESS_H
3893# include <sys/access.h>
3894#endif
3895#define _ALL_SOURCE
3896
3897#include <sys/stat.h>
3898
3899int aclsize;
3900struct acl *aclent;], [aclsize = sizeof(struct acl);
3901 aclent = (void *)malloc(aclsize);
3902 statacl("foo", STX_NORMAL, aclent, aclsize);
3903 ],
3904 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_AIX_ACL),
3905 AC_MSG_RESULT(no))
3906else
3907 AC_MSG_RESULT(yes)
3908fi
3909
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02003910if test "x$GTK_CFLAGS" != "x"; then
3911 dnl pango_shape_full() is new, fall back to pango_shape().
3912 AC_MSG_CHECKING(for pango_shape_full)
3913 ac_save_CFLAGS="$CFLAGS"
3914 ac_save_LIBS="$LIBS"
3915 CFLAGS="$CFLAGS $GTK_CFLAGS"
3916 LIBS="$LIBS $GTK_LIBS"
Bram Moolenaar5325b9b2015-09-09 20:27:02 +02003917 AC_TRY_LINK(
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02003918 [#include <gtk/gtk.h>],
3919 [ pango_shape_full(NULL, 0, NULL, 0, NULL, NULL); ],
3920 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_PANGO_SHAPE_FULL),
3921 AC_MSG_RESULT(no))
3922 CFLAGS="$ac_save_CFLAGS"
3923 LIBS="$ac_save_LIBS"
3924fi
3925
Bram Moolenaar071d4272004-06-13 20:20:40 +00003926AC_MSG_CHECKING(--disable-gpm argument)
3927AC_ARG_ENABLE(gpm,
3928 [ --disable-gpm Don't use gpm (Linux mouse daemon).], ,
3929 [enable_gpm="yes"])
3930
3931if test "$enable_gpm" = "yes"; then
3932 AC_MSG_RESULT(no)
3933 dnl Checking if gpm support can be compiled
3934 AC_CACHE_CHECK([for gpm], vi_cv_have_gpm,
3935 [olibs="$LIBS" ; LIBS="-lgpm"]
3936 AC_TRY_LINK(
3937 [#include <gpm.h>
3938 #include <linux/keyboard.h>],
3939 [Gpm_GetLibVersion(NULL);],
3940 dnl Configure defines HAVE_GPM, if it is defined feature.h defines
3941 dnl FEAT_MOUSE_GPM if mouse support is included
3942 [vi_cv_have_gpm=yes],
3943 [vi_cv_have_gpm=no])
3944 [LIBS="$olibs"]
3945 )
3946 if test $vi_cv_have_gpm = yes; then
3947 LIBS="$LIBS -lgpm"
3948 AC_DEFINE(HAVE_GPM)
3949 fi
3950else
3951 AC_MSG_RESULT(yes)
3952fi
3953
Bram Moolenaar446cb832008-06-24 21:56:24 +00003954AC_MSG_CHECKING(--disable-sysmouse argument)
3955AC_ARG_ENABLE(sysmouse,
Bram Moolenaar8008b632017-07-18 21:33:20 +02003956 [ --disable-sysmouse Don't use sysmouse (mouse in *BSD console).], ,
Bram Moolenaar446cb832008-06-24 21:56:24 +00003957 [enable_sysmouse="yes"])
3958
3959if test "$enable_sysmouse" = "yes"; then
3960 AC_MSG_RESULT(no)
3961 dnl Checking if sysmouse support can be compiled
3962 dnl Configure defines HAVE_SYSMOUSE, if it is defined feature.h
3963 dnl defines FEAT_SYSMOUSE if mouse support is included
3964 AC_CACHE_CHECK([for sysmouse], vi_cv_have_sysmouse,
3965 AC_TRY_LINK(
3966 [#include <sys/consio.h>
3967 #include <signal.h>
3968 #include <sys/fbio.h>],
3969 [struct mouse_info mouse;
3970 mouse.operation = MOUSE_MODE;
3971 mouse.operation = MOUSE_SHOW;
3972 mouse.u.mode.mode = 0;
3973 mouse.u.mode.signal = SIGUSR2;],
3974 [vi_cv_have_sysmouse=yes],
3975 [vi_cv_have_sysmouse=no])
3976 )
3977 if test $vi_cv_have_sysmouse = yes; then
3978 AC_DEFINE(HAVE_SYSMOUSE)
3979 fi
3980else
3981 AC_MSG_RESULT(yes)
3982fi
3983
Bram Moolenaarf05da212009-11-17 16:13:15 +00003984dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
3985AC_MSG_CHECKING(for FD_CLOEXEC)
3986AC_TRY_COMPILE(
3987[#if HAVE_FCNTL_H
3988# include <fcntl.h>
3989#endif],
3990[ int flag = FD_CLOEXEC;],
3991 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
3992 AC_MSG_RESULT(not usable))
3993
Bram Moolenaar071d4272004-06-13 20:20:40 +00003994dnl rename needs to be checked separately to work on Nextstep with cc
3995AC_MSG_CHECKING(for rename)
3996AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
3997 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
3998 AC_MSG_RESULT(no))
3999
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004000dnl check for dirfd()
4001AC_MSG_CHECKING(for dirfd)
4002AC_TRY_COMPILE(
4003[#include <sys/types.h>
4004#include <dirent.h>],
4005[DIR * dir=opendir("dirname"); dirfd(dir);],
4006AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DIRFD), AC_MSG_RESULT(not usable))
4007
4008dnl check for flock()
4009AC_MSG_CHECKING(for flock)
4010AC_TRY_COMPILE(
4011[#include <sys/file.h>],
4012[flock(10, LOCK_SH);],
4013AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOCK), AC_MSG_RESULT(not usable))
4014
Bram Moolenaar071d4272004-06-13 20:20:40 +00004015dnl sysctl() may exist but not the arguments we use
4016AC_MSG_CHECKING(for sysctl)
4017AC_TRY_COMPILE(
4018[#include <sys/types.h>
4019#include <sys/sysctl.h>],
4020[ int mib[2], r;
4021 size_t len;
4022
4023 mib[0] = CTL_HW;
4024 mib[1] = HW_USERMEM;
4025 len = sizeof(r);
4026 (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
4027 ],
4028 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL),
4029 AC_MSG_RESULT(not usable))
4030
4031dnl sysinfo() may exist but not be Linux compatible
4032AC_MSG_CHECKING(for sysinfo)
4033AC_TRY_COMPILE(
4034[#include <sys/types.h>
4035#include <sys/sysinfo.h>],
4036[ struct sysinfo sinfo;
4037 int t;
4038
4039 (void)sysinfo(&sinfo);
4040 t = sinfo.totalram;
4041 ],
4042 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
4043 AC_MSG_RESULT(not usable))
4044
Bram Moolenaar914572a2007-05-01 11:37:47 +00004045dnl struct sysinfo may have the mem_unit field or not
4046AC_MSG_CHECKING(for sysinfo.mem_unit)
4047AC_TRY_COMPILE(
4048[#include <sys/types.h>
4049#include <sys/sysinfo.h>],
4050[ struct sysinfo sinfo;
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02004051 sinfo.mem_unit = 1;
Bram Moolenaar914572a2007-05-01 11:37:47 +00004052 ],
4053 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_MEM_UNIT),
4054 AC_MSG_RESULT(no))
4055
Bram Moolenaar071d4272004-06-13 20:20:40 +00004056dnl sysconf() may exist but not support what we want to use
4057AC_MSG_CHECKING(for sysconf)
4058AC_TRY_COMPILE(
4059[#include <unistd.h>],
4060[ (void)sysconf(_SC_PAGESIZE);
4061 (void)sysconf(_SC_PHYS_PAGES);
4062 ],
4063 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
4064 AC_MSG_RESULT(not usable))
4065
Bram Moolenaar914703b2010-05-31 21:59:46 +02004066AC_CHECK_SIZEOF([int])
4067AC_CHECK_SIZEOF([long])
4068AC_CHECK_SIZEOF([time_t])
4069AC_CHECK_SIZEOF([off_t])
Bram Moolenaar644fdff2010-05-30 13:26:21 +02004070
Bram Moolenaara2aa31a2014-02-23 22:52:40 +01004071dnl Use different names to avoid clashing with other header files.
4072AC_DEFINE_UNQUOTED(VIM_SIZEOF_INT, [$ac_cv_sizeof_int])
4073AC_DEFINE_UNQUOTED(VIM_SIZEOF_LONG, [$ac_cv_sizeof_long])
4074
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004075dnl Make sure that uint32_t is really 32 bits unsigned.
4076AC_MSG_CHECKING([uint32_t is 32 bits])
4077AC_TRY_RUN([
4078#ifdef HAVE_STDINT_H
4079# include <stdint.h>
4080#endif
4081#ifdef HAVE_INTTYPES_H
4082# include <inttypes.h>
4083#endif
4084main() {
4085 uint32_t nr1 = (uint32_t)-1;
4086 uint32_t nr2 = (uint32_t)0xffffffffUL;
Bram Moolenaar52897832020-07-02 22:50:37 +02004087 if (sizeof(uint32_t) != 4 || nr1 != 0xffffffffUL || nr2 + 1 != 0) return 1;
4088 return 0;
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004089}],
4090AC_MSG_RESULT(ok),
4091AC_MSG_ERROR([WRONG! uint32_t not defined correctly.]),
Bram Moolenaar323cb952011-12-14 19:22:34 +01004092AC_MSG_WARN([cannot check uint32_t when cross-compiling.]))
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004093
Bram Moolenaar446cb832008-06-24 21:56:24 +00004094dnl Check for memmove() before bcopy(), makes memmove() be used when both are
4095dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
4096
Bram Moolenaar071d4272004-06-13 20:20:40 +00004097[bcopy_test_prog='
Bram Moolenaar446cb832008-06-24 21:56:24 +00004098#include "confdefs.h"
4099#ifdef HAVE_STRING_H
4100# include <string.h>
4101#endif
4102#if STDC_HEADERS
4103# include <stdlib.h>
4104# include <stddef.h>
4105#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004106main() {
4107 char buf[10];
4108 strcpy(buf, "abcdefghi");
4109 mch_memmove(buf, buf + 2, 3);
4110 if (strncmp(buf, "ababcf", 6))
4111 exit(1);
4112 strcpy(buf, "abcdefghi");
4113 mch_memmove(buf + 2, buf, 3);
4114 if (strncmp(buf, "cdedef", 6))
4115 exit(1);
4116 exit(0); /* libc version works properly. */
4117}']
4118
Bram Moolenaar446cb832008-06-24 21:56:24 +00004119AC_CACHE_CHECK([whether memmove handles overlaps],[vim_cv_memmove_handles_overlap],
4120 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004121 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 +00004122 [
4123 vim_cv_memmove_handles_overlap=yes
4124 ],[
4125 vim_cv_memmove_handles_overlap=no
4126 ],[
4127 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memmove_handles_overlap')
4128 ])
4129 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00004130
Bram Moolenaar446cb832008-06-24 21:56:24 +00004131if test "x$vim_cv_memmove_handles_overlap" = "xyes" ; then
4132 AC_DEFINE(USEMEMMOVE)
4133else
4134 AC_CACHE_CHECK([whether bcopy handles overlaps],[vim_cv_bcopy_handles_overlap],
4135 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004136 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 +00004137 [
4138 vim_cv_bcopy_handles_overlap=yes
4139 ],[
4140 vim_cv_bcopy_handles_overlap=no
4141 ],[
4142 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_bcopy_handles_overlap')
4143 ])
4144 ])
4145
4146 if test "x$vim_cv_bcopy_handles_overlap" = "xyes" ; then
4147 AC_DEFINE(USEBCOPY)
4148 else
4149 AC_CACHE_CHECK([whether memcpy handles overlaps],[vim_cv_memcpy_handles_overlap],
4150 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004151 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 +00004152 [
4153 vim_cv_memcpy_handles_overlap=yes
4154 ],[
4155 vim_cv_memcpy_handles_overlap=no
4156 ],[
4157 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memcpy_handles_overlap')
4158 ])
4159 ])
4160
4161 if test "x$vim_cv_memcpy_handles_overlap" = "xyes" ; then
4162 AC_DEFINE(USEMEMCPY)
4163 fi
4164 fi
4165fi
4166
Bram Moolenaar071d4272004-06-13 20:20:40 +00004167
4168dnl Check for multibyte locale functions
4169dnl Find out if _Xsetlocale() is supported by libX11.
4170dnl Check if X_LOCALE should be defined.
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004171if test "x$with_x" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004172 cflags_save=$CFLAGS
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004173 libs_save=$LIBS
4174 LIBS="$LIBS $X_LIBS $GUI_LIB_LOC $GUI_X_LIBS $X_PRE_LIBS $X_LIB $X_EXTRA_LIBS"
4175 CFLAGS="$CFLAGS $X_CFLAGS"
4176
4177 AC_MSG_CHECKING(whether X_LOCALE needed)
4178 AC_TRY_COMPILE([#include <X11/Xlocale.h>],,
4179 AC_TRY_LINK_FUNC([_Xsetlocale], [AC_MSG_RESULT(yes)
4180 AC_DEFINE(X_LOCALE)], AC_MSG_RESULT(no)),
4181 AC_MSG_RESULT(no))
4182
4183 AC_MSG_CHECKING(whether Xutf8SetWMProperties() can be used)
4184 AC_TRY_LINK_FUNC([Xutf8SetWMProperties], [AC_MSG_RESULT(yes)
4185 AC_DEFINE(HAVE_XUTF8SETWMPROPERTIES)], AC_MSG_RESULT(no))
4186
Bram Moolenaar071d4272004-06-13 20:20:40 +00004187 CFLAGS=$cflags_save
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004188 LIBS=$libs_save
Bram Moolenaar071d4272004-06-13 20:20:40 +00004189fi
4190
4191dnl Link with xpg4, it is said to make Korean locale working
4192AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,)
4193
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004194dnl Check how we can run ctags. Default to "ctags" when nothing works.
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02004195dnl Use --version to detect Exuberant ctags (preferred)
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004196dnl Add --fields=+S to get function signatures for omni completion.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004197dnl -t for typedefs (many ctags have this)
4198dnl -s for static functions (Elvis ctags only?)
4199dnl -v for variables. Dangerous, most ctags take this for 'vgrind style'.
4200dnl -i+m to test for older Exuberant ctags
4201AC_MSG_CHECKING(how to create tags)
4202test -f tags && mv tags tags.save
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004203if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004204 TAGPRG="ctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004205elif (eval exctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004206 TAGPRG="exctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004207elif (eval exuberant-ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004208 TAGPRG="exuberant-ctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004209else
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004210 TAGPRG="ctags"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004211 (eval etags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags"
4212 (eval etags -c /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags -c"
4213 (eval ctags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags"
4214 (eval ctags -t /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -t"
4215 (eval ctags -ts /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -ts"
4216 (eval ctags -tvs /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -tvs"
4217 (eval ctags -i+m /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -i+m"
4218fi
4219test -f tags.save && mv tags.save tags
4220AC_MSG_RESULT($TAGPRG) AC_SUBST(TAGPRG)
4221
4222dnl Check how we can run man with a section number
4223AC_MSG_CHECKING(how to run man with a section nr)
4224MANDEF="man"
Bram Moolenaar8b131502008-02-13 09:28:19 +00004225(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 +00004226AC_MSG_RESULT($MANDEF)
4227if test "$MANDEF" = "man -s"; then
4228 AC_DEFINE(USEMAN_S)
4229fi
4230
4231dnl Check if gettext() is working and if it needs -lintl
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004232dnl We take care to base this on an empty LIBS: on some systems libelf would be
4233dnl in LIBS and implicitly take along libintl. The final LIBS would then not
4234dnl contain libintl, and the link step would fail due to -Wl,--as-needed.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004235AC_MSG_CHECKING(--disable-nls argument)
4236AC_ARG_ENABLE(nls,
4237 [ --disable-nls Don't support NLS (gettext()).], ,
4238 [enable_nls="yes"])
4239
4240if test "$enable_nls" = "yes"; then
4241 AC_MSG_RESULT(no)
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00004242
4243 INSTALL_LANGS=install-languages
4244 AC_SUBST(INSTALL_LANGS)
4245 INSTALL_TOOL_LANGS=install-tool-languages
4246 AC_SUBST(INSTALL_TOOL_LANGS)
4247
Bram Moolenaar071d4272004-06-13 20:20:40 +00004248 AC_CHECK_PROG(MSGFMT, msgfmt, msgfmt, )
4249 AC_MSG_CHECKING([for NLS])
4250 if test -f po/Makefile; then
4251 have_gettext="no"
4252 if test -n "$MSGFMT"; then
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004253 olibs=$LIBS
4254 LIBS=""
Bram Moolenaar071d4272004-06-13 20:20:40 +00004255 AC_TRY_LINK(
4256 [#include <libintl.h>],
4257 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004258 AC_MSG_RESULT([gettext() works]); have_gettext="yes"; LIBS=$olibs,
4259 LIBS="-lintl"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004260 AC_TRY_LINK(
4261 [#include <libintl.h>],
4262 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004263 AC_MSG_RESULT([gettext() works with -lintl]); have_gettext="yes";
4264 LIBS="$olibs -lintl",
Bram Moolenaar071d4272004-06-13 20:20:40 +00004265 AC_MSG_RESULT([gettext() doesn't work]);
4266 LIBS=$olibs))
4267 else
4268 AC_MSG_RESULT([msgfmt not found - disabled]);
4269 fi
Bram Moolenaar278eb582014-07-30 13:22:52 +02004270 if test $have_gettext = "yes" -a "x$features" != "xtiny" -a "x$features" != "xsmall"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004271 AC_DEFINE(HAVE_GETTEXT)
4272 MAKEMO=yes
4273 AC_SUBST(MAKEMO)
4274 dnl this was added in GNU gettext 0.10.36
4275 AC_CHECK_FUNCS(bind_textdomain_codeset)
4276 dnl _nl_msg_cat_cntr is required for GNU gettext
4277 AC_MSG_CHECKING([for _nl_msg_cat_cntr])
4278 AC_TRY_LINK(
4279 [#include <libintl.h>
4280 extern int _nl_msg_cat_cntr;],
4281 [++_nl_msg_cat_cntr;],
4282 AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_NL_MSG_CAT_CNTR),
4283 AC_MSG_RESULT([no]))
Bram Moolenaar26096cc2019-04-11 15:25:40 +02004284 AC_MSG_CHECKING([if msgfmt supports --desktop])
4285 MSGFMT_DESKTOP=
4286 if "$MSGFMT" --help | grep -e '--desktop' >/dev/null; then
Bram Moolenaar62a88f42019-06-07 20:44:40 +02004287 if "$MSGFMT" --version | grep '0.19.[[3-7]]$' >/dev/null; then
4288 dnl GNU gettext 0.19.7's --desktop is broken. We assume back to
4289 dnl 0.19.3 is also broken.
4290 AC_MSG_RESULT([broken])
4291 else
4292 AC_MSG_RESULT([yes])
4293 MSGFMT_DESKTOP="gvim.desktop vim.desktop"
4294 fi
Bram Moolenaar26096cc2019-04-11 15:25:40 +02004295 else
4296 AC_MSG_RESULT([no])
4297 fi
4298 AC_SUBST(MSGFMT_DESKTOP)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004299 fi
4300 else
4301 AC_MSG_RESULT([no "po/Makefile" - disabled]);
4302 fi
4303else
4304 AC_MSG_RESULT(yes)
4305fi
4306
4307dnl Check for dynamic linking loader
4308AC_CHECK_HEADER(dlfcn.h, DLL=dlfcn.h, [AC_CHECK_HEADER(dl.h, DLL=dl.h)])
4309if test x${DLL} = xdlfcn.h; then
4310 AC_DEFINE(HAVE_DLFCN_H, 1, [ Define if we have dlfcn.h. ])
4311 AC_MSG_CHECKING([for dlopen()])
4312 AC_TRY_LINK(,[
4313 extern void* dlopen();
4314 dlopen();
4315 ],
4316 AC_MSG_RESULT(yes);
4317 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4318 AC_MSG_RESULT(no);
4319 AC_MSG_CHECKING([for dlopen() in -ldl])
4320 olibs=$LIBS
4321 LIBS="$LIBS -ldl"
4322 AC_TRY_LINK(,[
4323 extern void* dlopen();
4324 dlopen();
4325 ],
4326 AC_MSG_RESULT(yes);
4327 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4328 AC_MSG_RESULT(no);
4329 LIBS=$olibs))
4330 dnl ReliantUNIX has dlopen() in libc but everything else in libdl
4331 dnl ick :-)
4332 AC_MSG_CHECKING([for dlsym()])
4333 AC_TRY_LINK(,[
4334 extern void* dlsym();
4335 dlsym();
4336 ],
4337 AC_MSG_RESULT(yes);
4338 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4339 AC_MSG_RESULT(no);
4340 AC_MSG_CHECKING([for dlsym() in -ldl])
4341 olibs=$LIBS
4342 LIBS="$LIBS -ldl"
4343 AC_TRY_LINK(,[
4344 extern void* dlsym();
4345 dlsym();
4346 ],
4347 AC_MSG_RESULT(yes);
4348 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4349 AC_MSG_RESULT(no);
4350 LIBS=$olibs))
4351elif test x${DLL} = xdl.h; then
4352 AC_DEFINE(HAVE_DL_H, 1, [ Define if we have dl.h. ])
4353 AC_MSG_CHECKING([for shl_load()])
4354 AC_TRY_LINK(,[
4355 extern void* shl_load();
4356 shl_load();
4357 ],
4358 AC_MSG_RESULT(yes);
4359 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4360 AC_MSG_RESULT(no);
4361 AC_MSG_CHECKING([for shl_load() in -ldld])
4362 olibs=$LIBS
4363 LIBS="$LIBS -ldld"
4364 AC_TRY_LINK(,[
4365 extern void* shl_load();
4366 shl_load();
4367 ],
4368 AC_MSG_RESULT(yes);
4369 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4370 AC_MSG_RESULT(no);
4371 LIBS=$olibs))
4372fi
4373AC_CHECK_HEADERS(setjmp.h)
4374
Bram Moolenaard0573012017-10-28 21:11:06 +02004375if test "x$MACOS_X" = "xyes" -a -n "$PERL"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004376 dnl -ldl must come after DynaLoader.a
4377 if echo $LIBS | grep -e '-ldl' >/dev/null; then
4378 LIBS=`echo $LIBS | sed s/-ldl//`
4379 PERL_LIBS="$PERL_LIBS -ldl"
4380 fi
4381fi
4382
Bram Moolenaard0573012017-10-28 21:11:06 +02004383if test "$MACOS_X" = "yes"; then
4384 AC_MSG_CHECKING([whether we need macOS frameworks])
Bram Moolenaar097148e2020-08-11 21:58:20 +02004385 if test "$MACOS_X_DARWIN" = "yes"; then
Bram Moolenaard0573012017-10-28 21:11:06 +02004386 if test "$features" = "tiny"; then
4387 dnl Since no FEAT_CLIPBOARD, no longer need for os_macosx.m.
4388 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_macosx.m++'`
4389 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_macosx.o++'`
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01004390 AC_MSG_RESULT([yes, we need CoreServices])
4391 LIBS="$LIBS -framework CoreServices"
Bram Moolenaard0573012017-10-28 21:11:06 +02004392 else
4393 AC_MSG_RESULT([yes, we need AppKit])
4394 LIBS="$LIBS -framework AppKit"
Bram Moolenaard0573012017-10-28 21:11:06 +02004395 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004396 else
Bram Moolenaard0573012017-10-28 21:11:06 +02004397 AC_MSG_RESULT([no])
Bram Moolenaar3437b912013-07-03 19:52:53 +02004398 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004399fi
4400
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004401dnl gcc 3.1 changed the meaning of -MM. The only solution appears to be to
4402dnl use "-isystem" instead of "-I" for all non-Vim include dirs.
4403dnl But only when making dependencies, cproto and lint don't take "-isystem".
Bram Moolenaar32466aa2006-02-24 23:53:04 +00004404dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
4405dnl the number before the version number.
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004406DEPEND_CFLAGS_FILTER=
4407if test "$GCC" = yes; then
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004408 AC_MSG_CHECKING(for GCC 3 or later)
Bram Moolenaar348808f2020-02-07 20:50:07 +01004409 gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]][[0-9]]*\)\..*$/\1/g'`
Bram Moolenaarf740b292006-02-16 22:11:02 +00004410 if test "$gccmajor" -gt "2"; then
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004411 DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004412 AC_MSG_RESULT(yes)
4413 else
4414 AC_MSG_RESULT(no)
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004415 fi
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004416 dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
4417 dnl declared as char x[1] but actually longer. Introduced in gcc 4.0.
Bram Moolenaar56d1db32009-12-16 16:14:51 +00004418 dnl Also remove duplicate _FORTIFY_SOURCE arguments.
Bram Moolenaaraeabe052011-12-08 15:17:34 +01004419 dnl And undefine it first to avoid a warning.
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004420 AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
4421 if test "$gccmajor" -gt "3"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02004422 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 +01004423 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 +00004424 AC_MSG_RESULT(yes)
4425 else
4426 AC_MSG_RESULT(no)
4427 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +00004428fi
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004429AC_SUBST(DEPEND_CFLAGS_FILTER)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004430
Bram Moolenaarec0557f2018-01-31 14:41:37 +01004431dnl On some systems AC_SYS_LARGEFILE determines that -D_FILE_OFFSET_BITS=64
4432dnl isn't required, but the CFLAGS for some of the libraries we're using
4433dnl include the define. Since the define changes the size of some datatypes
4434dnl (e.g. ino_t and off_t), all of Vim's modules must be compiled with a
4435dnl consistent value. It's therefore safest to force the use of the define
4436dnl if it's present in any of the *_CFLAGS variables.
4437AC_MSG_CHECKING(whether we need to force -D_FILE_OFFSET_BITS=64)
Bram Moolenaar9ce42132018-04-11 22:19:36 +02004438if 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 +01004439 AC_MSG_RESULT(yes)
4440 AC_DEFINE(_FILE_OFFSET_BITS, 64)
4441else
4442 AC_MSG_RESULT(no)
4443fi
4444
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004445dnl link.sh tries to avoid overlinking in a hackish way.
4446dnl At least GNU ld supports --as-needed which provides the same functionality
4447dnl at linker level. Let's use it.
4448AC_MSG_CHECKING(linker --as-needed support)
4449LINK_AS_NEEDED=
4450# Check if linker supports --as-needed and --no-as-needed options
4451if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02004452 LDFLAGS=`echo "$LDFLAGS" | sed -e 's/ *-Wl,--as-needed//g' | sed -e 's/$/ -Wl,--as-needed/'`
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004453 LINK_AS_NEEDED=yes
4454fi
4455if test "$LINK_AS_NEEDED" = yes; then
4456 AC_MSG_RESULT(yes)
4457else
4458 AC_MSG_RESULT(no)
4459fi
4460AC_SUBST(LINK_AS_NEEDED)
4461
Bram Moolenaar77c19352012-06-13 19:19:41 +02004462# IBM z/OS reset CFLAGS for config.mk
4463if test "$zOSUnix" = "yes"; then
4464 CFLAGS="-D_ALL_SOURCE -Wc,float\(ieee\),dll"
4465fi
4466
Bram Moolenaar071d4272004-06-13 20:20:40 +00004467dnl write output files
4468AC_OUTPUT(auto/config.mk:config.mk.in)
4469
4470dnl vim: set sw=2 tw=78 fo+=l: