blob: 054ea1dcb8d11f2e4c556632d09d14ae9be394bf [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
266 dnl If Carbon is found, assume we don't want X11
267 dnl unless it was specifically asked for (--with-x)
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000268 dnl or Motif, Athena or GTK GUI is used.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000269 AC_CHECK_HEADER(Carbon/Carbon.h, CARBON=yes)
270 if test "x$CARBON" = "xyes"; then
Bram Moolenaar98921892016-02-23 17:14:37 +0100271 if test -z "$with_x" -a "X$enable_gui" != Xmotif -a "X$enable_gui" != Xathena -a "X$enable_gui" != Xgtk2 -a "X$enable_gui" != Xgtk3; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000272 with_x=no
Bram Moolenaar071d4272004-06-13 20:20:40 +0000273 fi
274 fi
275 fi
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000276
Bram Moolenaardb552d602006-03-23 22:59:57 +0000277 dnl Avoid a bug with -O2 with gcc 4.0.1. Symptom: malloc() reports double
Bram Moolenaarfd2ac762006-03-01 22:09:21 +0000278 dnl free. This happens in expand_filename(), because the optimizer swaps
Bram Moolenaardb552d602006-03-23 22:59:57 +0000279 dnl two blocks of code, both using "repl", that can't be swapped.
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000280 if test "$MACARCH" = "intel" -o "$MACARCH" = "both"; then
281 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-Oz/'`
282 fi
283
Bram Moolenaar071d4272004-06-13 20:20:40 +0000284else
285 AC_MSG_RESULT(no)
286fi
287
Bram Moolenaar39766a72013-11-03 00:41:00 +0100288dnl Mac OS X 10.9+ no longer include AvailabilityMacros.h in Carbon
289dnl so we need to include it to have access to version macros.
Bram Moolenaar18e54692013-11-03 20:26:31 +0100290AC_CHECK_HEADERS(AvailabilityMacros.h)
Bram Moolenaar39766a72013-11-03 00:41:00 +0100291
Bram Moolenaar071d4272004-06-13 20:20:40 +0000292AC_SUBST(OS_EXTRA_SRC)
293AC_SUBST(OS_EXTRA_OBJ)
294
295dnl Add /usr/local/lib to $LDFLAGS and /usr/local/include to CFLAGS.
296dnl Only when the directory exists and it wasn't there yet.
297dnl For gcc don't do this when it is already in the default search path.
Bram Moolenaar446cb832008-06-24 21:56:24 +0000298dnl Skip all of this when cross-compiling.
299if test "$cross_compiling" = no; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000300 AC_MSG_CHECKING(--with-local-dir argument)
Bram Moolenaar446cb832008-06-24 21:56:24 +0000301 have_local_include=''
302 have_local_lib=''
Bram Moolenaarc236c162008-07-13 17:41:49 +0000303 AC_ARG_WITH([local-dir], [ --with-local-dir=PATH search PATH instead of /usr/local for local libraries.
304 --without-local-dir do not search /usr/local for local libraries.], [
305 local_dir="$withval"
306 case "$withval" in
307 */*) ;;
308 no)
309 # avoid adding local dir to LDFLAGS and CPPFLAGS
Bram Moolenaare06c1882010-07-21 22:05:20 +0200310 have_local_include=yes
Bram Moolenaarc236c162008-07-13 17:41:49 +0000311 have_local_lib=yes
312 ;;
313 *) AC_MSG_ERROR(must pass path argument to --with-local-dir) ;;
314 esac
315 AC_MSG_RESULT($local_dir)
316 ], [
317 local_dir=/usr/local
318 AC_MSG_RESULT(Defaulting to $local_dir)
319 ])
320 if test "$GCC" = yes -a "$local_dir" != no; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000321 echo 'void f(){}' > conftest.c
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100322 dnl Removed -no-cpp-precomp, only needed for OS X 10.2 (Ben Fowler)
323 have_local_include=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/include"`
Bram Moolenaarc236c162008-07-13 17:41:49 +0000324 have_local_lib=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/lib"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000325 rm -f conftest.c conftest.o
Bram Moolenaar071d4272004-06-13 20:20:40 +0000326 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000327 if test -z "$have_local_lib" -a -d "${local_dir}/lib"; then
328 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 +0000329 if test "$tt" = "$LDFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000330 LDFLAGS="$LDFLAGS -L${local_dir}/lib"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000331 fi
332 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000333 if test -z "$have_local_include" -a -d "${local_dir}/include"; then
334 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 +0000335 if test "$tt" = "$CPPFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000336 CPPFLAGS="$CPPFLAGS -I${local_dir}/include"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000337 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000338 fi
339fi
340
341AC_MSG_CHECKING(--with-vim-name argument)
342AC_ARG_WITH(vim-name, [ --with-vim-name=NAME what to call the Vim executable],
343 VIMNAME="$withval"; AC_MSG_RESULT($VIMNAME),
Bram Moolenaare344bea2005-09-01 20:46:49 +0000344 VIMNAME="vim"; AC_MSG_RESULT(Defaulting to $VIMNAME))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000345AC_SUBST(VIMNAME)
346AC_MSG_CHECKING(--with-ex-name argument)
347AC_ARG_WITH(ex-name, [ --with-ex-name=NAME what to call the Ex executable],
348 EXNAME="$withval"; AC_MSG_RESULT($EXNAME),
349 EXNAME="ex"; AC_MSG_RESULT(Defaulting to ex))
350AC_SUBST(EXNAME)
351AC_MSG_CHECKING(--with-view-name argument)
352AC_ARG_WITH(view-name, [ --with-view-name=NAME what to call the View executable],
353 VIEWNAME="$withval"; AC_MSG_RESULT($VIEWNAME),
354 VIEWNAME="view"; AC_MSG_RESULT(Defaulting to view))
355AC_SUBST(VIEWNAME)
356
357AC_MSG_CHECKING(--with-global-runtime argument)
Bram Moolenaar9d302ad2018-12-21 11:48:51 +0100358AC_ARG_WITH(global-runtime, [ --with-global-runtime=DIR global runtime directory in 'runtimepath', comma-separated for multiple directories],
359 RUNTIME_GLOBAL="$withval"; AC_MSG_RESULT($withval),
Bram Moolenaar071d4272004-06-13 20:20:40 +0000360 AC_MSG_RESULT(no))
361
Bram Moolenaar9d302ad2018-12-21 11:48:51 +0100362if test "X$RUNTIME_GLOBAL" != "X"; then
363 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" }')
364 AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL, "$RUNTIME_GLOBAL")
365 AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL_AFTER, "$RUNTIME_GLOBAL_AFTER")
366fi
367
Bram Moolenaar071d4272004-06-13 20:20:40 +0000368AC_MSG_CHECKING(--with-modified-by argument)
369AC_ARG_WITH(modified-by, [ --with-modified-by=NAME name of who modified a release version],
370 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(MODIFIED_BY, "$withval"),
371 AC_MSG_RESULT(no))
372
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200373dnl Check for EBCDIC stolen from the LYNX port to z/OS Unix
Bram Moolenaar071d4272004-06-13 20:20:40 +0000374AC_MSG_CHECKING(if character set is EBCDIC)
375AC_TRY_COMPILE([ ],
376[ /* TryCompile function for CharSet.
377 Treat any failure as ASCII for compatibility with existing art.
378 Use compile-time rather than run-time tests for cross-compiler
379 tolerance. */
380#if '0'!=240
381make an error "Character set is not EBCDIC"
382#endif ],
383[ # TryCompile action if true
384cf_cv_ebcdic=yes ],
385[ # TryCompile action if false
386cf_cv_ebcdic=no])
387# end of TryCompile ])
388# end of CacheVal CvEbcdic
389AC_MSG_RESULT($cf_cv_ebcdic)
390case "$cf_cv_ebcdic" in #(vi
391 yes) AC_DEFINE(EBCDIC)
392 line_break='"\\n"'
393 ;;
394 *) line_break='"\\012"';;
395esac
396AC_SUBST(line_break)
397
398if test "$cf_cv_ebcdic" = "yes"; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +0200399dnl If we have EBCDIC we most likely have z/OS Unix, let's test it!
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200400AC_MSG_CHECKING(for z/OS Unix)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000401case `uname` in
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200402 OS/390) zOSUnix="yes";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000403 dnl If using cc the environment variable _CC_CCMODE must be
404 dnl set to "1", so that some compiler extensions are enabled.
405 dnl If using c89 the environment variable is named _CC_C89MODE.
406 dnl Note: compile with c89 never tested.
407 if test "$CC" = "cc"; then
408 ccm="$_CC_CCMODE"
409 ccn="CC"
410 else
411 if test "$CC" = "c89"; then
412 ccm="$_CC_C89MODE"
413 ccn="C89"
414 else
415 ccm=1
416 fi
417 fi
418 if test "$ccm" != "1"; then
419 echo ""
420 echo "------------------------------------------"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200421 echo " On z/OS Unix, the environment variable"
Bram Moolenaar77c19352012-06-13 19:19:41 +0200422 echo " _CC_${ccn}MODE must be set to \"1\"!"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000423 echo " Do:"
424 echo " export _CC_${ccn}MODE=1"
425 echo " and then call configure again."
426 echo "------------------------------------------"
427 exit 1
428 fi
Bram Moolenaar77c19352012-06-13 19:19:41 +0200429 # Set CFLAGS for configure process.
430 # This will be reset later for config.mk.
431 # Use haltonmsg to force error for missing H files.
432 CFLAGS="$CFLAGS -D_ALL_SOURCE -Wc,float(ieee),haltonmsg(3296)";
433 LDFLAGS="$LDFLAGS -Wl,EDIT=NO"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000434 AC_MSG_RESULT(yes)
435 ;;
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200436 *) zOSUnix="no";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000437 AC_MSG_RESULT(no)
438 ;;
439esac
440fi
441
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200442dnl Set QUOTESED. Needs additional backslashes on zOS
443if test "$zOSUnix" = "yes"; then
444 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\\\\\&/g' -e 's/\\\\\\\\\"/\"/' -e 's/\\\\\\\\\";\$\$/\";/'"
445else
446 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\&/g' -e 's/\\\\\"/\"/' -e 's/\\\\\";\$\$/\";/'"
447fi
448AC_SUBST(QUOTESED)
449
450
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200451dnl Link with -lsmack for Smack stuff; if not found
452AC_MSG_CHECKING(--disable-smack argument)
453AC_ARG_ENABLE(smack,
454 [ --disable-smack Do not check for Smack support.],
455 , enable_smack="yes")
456if test "$enable_smack" = "yes"; then
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200457 AC_MSG_RESULT(no)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200458 AC_CHECK_HEADER([linux/xattr.h], true, enable_smack="no")
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200459else
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200460 AC_MSG_RESULT(yes)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200461fi
462if test "$enable_smack" = "yes"; then
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200463 AC_CHECK_HEADER([attr/xattr.h], true, enable_smack="no")
464fi
465if test "$enable_smack" = "yes"; then
466 AC_MSG_CHECKING(for XATTR_NAME_SMACKEXEC in linux/xattr.h)
467 AC_EGREP_CPP(XATTR_NAME_SMACKEXEC, [#include <linux/xattr.h>],
468 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +0200469 AC_MSG_RESULT(no); enable_smack="no")
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200470fi
471if test "$enable_smack" = "yes"; then
472 AC_CHECK_LIB(attr, setxattr,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200473 [LIBS="$LIBS -lattr"
474 found_smack="yes"
475 AC_DEFINE(HAVE_SMACK)])
Bram Moolenaar588ebeb2008-05-07 17:09:24 +0000476fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000477
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200478dnl When smack was found don't search for SELinux
479if test "x$found_smack" = "x"; then
480 dnl Link with -lselinux for SELinux stuff; if not found
481 AC_MSG_CHECKING(--disable-selinux argument)
482 AC_ARG_ENABLE(selinux,
483 [ --disable-selinux Do not check for SELinux support.],
484 , enable_selinux="yes")
485 if test "$enable_selinux" = "yes"; then
486 AC_MSG_RESULT(no)
487 AC_CHECK_LIB(selinux, is_selinux_enabled,
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100488 [AC_CHECK_HEADER(selinux/selinux.h,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200489 [LIBS="$LIBS -lselinux"
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100490 AC_DEFINE(HAVE_SELINUX)])])
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200491 else
492 AC_MSG_RESULT(yes)
493 fi
494fi
495
Bram Moolenaar071d4272004-06-13 20:20:40 +0000496dnl Check user requested features.
497
498AC_MSG_CHECKING(--with-features argument)
Bram Moolenaareec29812016-07-26 21:27:36 +0200499AC_ARG_WITH(features, [ --with-features=TYPE tiny, small, normal, big or huge (default: huge)],
Bram Moolenaar071d4272004-06-13 20:20:40 +0000500 features="$withval"; AC_MSG_RESULT($features),
Bram Moolenaar23c4f712016-01-20 22:11:59 +0100501 features="huge"; AC_MSG_RESULT(Defaulting to huge))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000502
503dovimdiff=""
504dogvimdiff=""
505case "$features" in
506 tiny) AC_DEFINE(FEAT_TINY) ;;
507 small) AC_DEFINE(FEAT_SMALL) ;;
508 normal) AC_DEFINE(FEAT_NORMAL) dovimdiff="installvimdiff";
509 dogvimdiff="installgvimdiff" ;;
510 big) AC_DEFINE(FEAT_BIG) dovimdiff="installvimdiff";
511 dogvimdiff="installgvimdiff" ;;
512 huge) AC_DEFINE(FEAT_HUGE) dovimdiff="installvimdiff";
513 dogvimdiff="installgvimdiff" ;;
514 *) AC_MSG_RESULT([Sorry, $features is not supported]) ;;
515esac
516
517AC_SUBST(dovimdiff)
518AC_SUBST(dogvimdiff)
519
520AC_MSG_CHECKING(--with-compiledby argument)
521AC_ARG_WITH(compiledby, [ --with-compiledby=NAME name to show in :version message],
522 compiledby="$withval"; AC_MSG_RESULT($withval),
523 compiledby=""; AC_MSG_RESULT(no))
524AC_SUBST(compiledby)
525
526AC_MSG_CHECKING(--disable-xsmp argument)
527AC_ARG_ENABLE(xsmp,
528 [ --disable-xsmp Disable XSMP session management],
529 , enable_xsmp="yes")
530
531if test "$enable_xsmp" = "yes"; then
532 AC_MSG_RESULT(no)
533 AC_MSG_CHECKING(--disable-xsmp-interact argument)
534 AC_ARG_ENABLE(xsmp-interact,
535 [ --disable-xsmp-interact Disable XSMP interaction],
536 , enable_xsmp_interact="yes")
537 if test "$enable_xsmp_interact" = "yes"; then
538 AC_MSG_RESULT(no)
539 AC_DEFINE(USE_XSMP_INTERACT)
540 else
541 AC_MSG_RESULT(yes)
542 fi
543else
544 AC_MSG_RESULT(yes)
545fi
546
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200547dnl Check for Lua feature.
548AC_MSG_CHECKING(--enable-luainterp argument)
549AC_ARG_ENABLE(luainterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200550 [ --enable-luainterp[=OPTS] Include Lua interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200551 [enable_luainterp="no"])
552AC_MSG_RESULT($enable_luainterp)
553
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200554if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +0100555 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
556 AC_MSG_ERROR([cannot use Lua with tiny or small features])
557 fi
558
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200559 dnl -- find the lua executable
560 AC_SUBST(vi_cv_path_lua)
561
562 AC_MSG_CHECKING(--with-lua-prefix argument)
563 AC_ARG_WITH(lua_prefix,
564 [ --with-lua-prefix=PFX Prefix where Lua is installed.],
565 with_lua_prefix="$withval"; AC_MSG_RESULT($with_lua_prefix),
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200566 with_lua_prefix="";AC_MSG_RESULT(no))
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200567
568 if test "X$with_lua_prefix" != "X"; then
569 vi_cv_path_lua_pfx="$with_lua_prefix"
570 else
571 AC_MSG_CHECKING(LUA_PREFIX environment var)
572 if test "X$LUA_PREFIX" != "X"; then
573 AC_MSG_RESULT("$LUA_PREFIX")
574 vi_cv_path_lua_pfx="$LUA_PREFIX"
575 else
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200576 AC_MSG_RESULT([not set, default to /usr])
577 vi_cv_path_lua_pfx="/usr"
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200578 fi
579 fi
580
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200581 AC_MSG_CHECKING(--with-luajit)
582 AC_ARG_WITH(luajit,
583 [ --with-luajit Link with LuaJIT instead of Lua.],
584 [vi_cv_with_luajit="$withval"],
585 [vi_cv_with_luajit="no"])
586 AC_MSG_RESULT($vi_cv_with_luajit)
587
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200588 LUA_INC=
589 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200590 if test "x$vi_cv_with_luajit" != "xno"; then
591 dnl -- try to find LuaJIT executable
592 AC_PATH_PROG(vi_cv_path_luajit, luajit)
593 if test "X$vi_cv_path_luajit" != "X"; then
594 dnl -- find LuaJIT version
595 AC_CACHE_CHECK(LuaJIT version, vi_cv_version_luajit,
Bram Moolenaar49b10272013-11-21 12:17:51 +0100596 [ 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 +0200597 AC_CACHE_CHECK(Lua version of LuaJIT, vi_cv_version_lua_luajit,
598 [ vi_cv_version_lua_luajit=`${vi_cv_path_luajit} -e "print(_VERSION)" | sed 's/.* //'` ])
599 vi_cv_path_lua="$vi_cv_path_luajit"
600 vi_cv_version_lua="$vi_cv_version_lua_luajit"
601 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200602 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200603 dnl -- try to find Lua executable
604 AC_PATH_PROG(vi_cv_path_plain_lua, lua)
605 if test "X$vi_cv_path_plain_lua" != "X"; then
606 dnl -- find Lua version
607 AC_CACHE_CHECK(Lua version, vi_cv_version_plain_lua,
608 [ vi_cv_version_plain_lua=`${vi_cv_path_plain_lua} -e "print(_VERSION)" | sed 's/.* //'` ])
609 fi
610 vi_cv_path_lua="$vi_cv_path_plain_lua"
611 vi_cv_version_lua="$vi_cv_version_plain_lua"
612 fi
613 if test "x$vi_cv_with_luajit" != "xno" && test "X$vi_cv_version_luajit" != "X"; then
614 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 +0100615 if test -f "$vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200616 AC_MSG_RESULT(yes)
617 LUA_INC=/luajit-$vi_cv_version_luajit
618 fi
619 fi
620 if test "X$LUA_INC" = "X"; then
621 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)
Bram Moolenaar49222be2015-12-11 18:11:30 +0100622 if test -f "$vi_cv_path_lua_pfx/include/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200623 AC_MSG_RESULT(yes)
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200624 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200625 AC_MSG_RESULT(no)
626 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 +0100627 if test -f "$vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200628 AC_MSG_RESULT(yes)
629 LUA_INC=/lua$vi_cv_version_lua
630 else
631 AC_MSG_RESULT(no)
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200632
633 # Detect moonjit:
634 # https://groups.google.com/forum/#!topic/vim_use/O0vek60WuTk
635 lua_suf=/moonjit-2.3
636 inc_path="$vi_cv_path_lua_pfx/include"
Bram Moolenaarad4dc832020-04-20 16:21:53 +0200637 for dir in "$inc_path"/moonjit-[[0-9]]* ; do
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200638 if test -d "$dir" ; then
639 lua_suf=`basename '$dir'`
640 lua_suf="/$lua_suf"
641 break
642 fi
643 done
644 AC_MSG_CHECKING(if lua.h can be found in $inc_path$lua_suf)
645 if test -f "$inc_path$lua_suf/lua.h"; then
646 AC_MSG_RESULT(yes)
647 LUA_INC=$lua_suf
648 else
649 AC_MSG_RESULT(no)
650 vi_cv_path_lua_pfx=
651 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200652 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200653 fi
654 fi
655 fi
656
657 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200658 if test "x$vi_cv_with_luajit" != "xno"; then
659 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
660 if test "X$multiarch" != "X"; then
661 lib_multiarch="lib/${multiarch}"
662 else
663 lib_multiarch="lib"
664 fi
665 if test "X$vi_cv_version_lua" = "X"; then
666 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit"
667 else
668 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit-$vi_cv_version_lua"
669 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200670 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200671 if test "X$LUA_INC" != "X"; then
672 dnl Test alternate location using version
673 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua$vi_cv_version_lua"
674 else
675 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua"
676 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200677 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200678 if test "$enable_luainterp" = "dynamic"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200679 lua_ok="yes"
680 else
681 AC_MSG_CHECKING([if link with ${LUA_LIBS} is sane])
682 libs_save=$LIBS
683 LIBS="$LIBS $LUA_LIBS"
684 AC_TRY_LINK(,[ ],
685 AC_MSG_RESULT(yes); lua_ok="yes",
686 AC_MSG_RESULT(no); lua_ok="no"; LUA_LIBS="")
687 LIBS=$libs_save
688 fi
689 if test "x$lua_ok" = "xyes"; then
690 LUA_CFLAGS="-I${vi_cv_path_lua_pfx}/include${LUA_INC}"
691 LUA_SRC="if_lua.c"
692 LUA_OBJ="objects/if_lua.o"
693 LUA_PRO="if_lua.pro"
694 AC_DEFINE(FEAT_LUA)
695 fi
696 if test "$enable_luainterp" = "dynamic"; then
697 if test "x$vi_cv_with_luajit" != "xno"; then
698 luajit="jit"
699 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200700 if test -f "${vi_cv_path_lua_pfx}/bin/cyglua-${vi_cv_version_lua}.dll"; then
701 vi_cv_dll_name_lua="cyglua-${vi_cv_version_lua}.dll"
702 else
Bram Moolenaard0573012017-10-28 21:11:06 +0200703 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200704 ext="dylib"
705 indexes=""
706 else
707 ext="so"
708 indexes=".0 .1 .2 .3 .4 .5 .6 .7 .8 .9"
709 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
710 if test "X$multiarch" != "X"; then
711 lib_multiarch="lib/${multiarch}"
712 fi
Bram Moolenaar768baac2013-04-15 14:44:57 +0200713 fi
714 dnl Determine the sover for the current version, but fallback to
715 dnl liblua${vi_cv_version_lua}.so if no sover-versioned file is found.
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200716 AC_MSG_CHECKING(if liblua${luajit}*.${ext}* can be found in $vi_cv_path_lua_pfx)
Bram Moolenaar768baac2013-04-15 14:44:57 +0200717 for subdir in "${lib_multiarch}" lib64 lib; do
718 if test -z "$subdir"; then
719 continue
720 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200721 for sover in "${vi_cv_version_lua}.${ext}" "-${vi_cv_version_lua}.${ext}" \
722 ".${vi_cv_version_lua}.${ext}" ".${ext}.${vi_cv_version_lua}"; do
723 for i in $indexes ""; do
724 if test -f "${vi_cv_path_lua_pfx}/${subdir}/liblua${luajit}${sover}$i"; then
Bram Moolenaar768baac2013-04-15 14:44:57 +0200725 sover2="$i"
726 break 3
727 fi
728 done
Bram Moolenaar07e1da62013-02-06 19:49:43 +0100729 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200730 sover=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200731 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200732 if test "X$sover" = "X"; then
733 AC_MSG_RESULT(no)
734 lua_ok="no"
735 vi_cv_dll_name_lua="liblua${luajit}.${ext}"
736 else
737 AC_MSG_RESULT(yes)
738 lua_ok="yes"
739 vi_cv_dll_name_lua="liblua${luajit}${sover}$sover2"
740 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200741 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200742 AC_DEFINE(DYNAMIC_LUA)
743 LUA_LIBS=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200744 LUA_CFLAGS="-DDYNAMIC_LUA_DLL=\\\"${vi_cv_dll_name_lua}\\\" $LUA_CFLAGS"
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200745 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200746 if test "X$LUA_CFLAGS$LUA_LIBS" != "X" && \
Bram Moolenaard0573012017-10-28 21:11:06 +0200747 test "x$MACOS_X" = "xyes" && test "x$vi_cv_with_luajit" != "xno" && \
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200748 test "`(uname -m) 2>/dev/null`" = "x86_64"; then
749 dnl OSX/x64 requires these flags. See http://luajit.org/install.html
750 LUA_LIBS="-pagezero_size 10000 -image_base 100000000 $LUA_LIBS"
751 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200752 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200753 if test "$fail_if_missing" = "yes" -a "$lua_ok" != "yes"; then
Bram Moolenaarf788a062011-12-14 20:51:25 +0100754 AC_MSG_ERROR([could not configure lua])
755 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200756 AC_SUBST(LUA_SRC)
757 AC_SUBST(LUA_OBJ)
758 AC_SUBST(LUA_PRO)
759 AC_SUBST(LUA_LIBS)
760 AC_SUBST(LUA_CFLAGS)
761fi
762
763
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000764dnl Check for MzScheme feature.
765AC_MSG_CHECKING(--enable-mzschemeinterp argument)
766AC_ARG_ENABLE(mzschemeinterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200767 [ --enable-mzschemeinterp Include MzScheme interpreter.], ,
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000768 [enable_mzschemeinterp="no"])
769AC_MSG_RESULT($enable_mzschemeinterp)
770
771if test "$enable_mzschemeinterp" = "yes"; then
772 dnl -- find the mzscheme executable
773 AC_SUBST(vi_cv_path_mzscheme)
774
775 AC_MSG_CHECKING(--with-plthome argument)
776 AC_ARG_WITH(plthome,
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000777 [ --with-plthome=PLTHOME Use PLTHOME.],
778 with_plthome="$withval"; AC_MSG_RESULT($with_plthome),
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000779 with_plthome="";AC_MSG_RESULT("no"))
780
781 if test "X$with_plthome" != "X"; then
782 vi_cv_path_mzscheme_pfx="$with_plthome"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100783 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000784 else
785 AC_MSG_CHECKING(PLTHOME environment var)
786 if test "X$PLTHOME" != "X"; then
787 AC_MSG_RESULT("$PLTHOME")
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000788 vi_cv_path_mzscheme_pfx="$PLTHOME"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100789 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000790 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000791 AC_MSG_RESULT(not set)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000792 dnl -- try to find MzScheme executable
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000793 AC_PATH_PROG(vi_cv_path_mzscheme, mzscheme)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000794
795 dnl resolve symbolic link, the executable is often elsewhere and there
796 dnl are no links for the include files.
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000797 if test "X$vi_cv_path_mzscheme" != "X"; then
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000798 lsout=`ls -l $vi_cv_path_mzscheme`
799 if echo "$lsout" | grep -e '->' >/dev/null 2>/dev/null; then
800 vi_cv_path_mzscheme=`echo "$lsout" | sed 's/.*-> \(.*\)/\1/'`
801 fi
802 fi
803
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000804 if test "X$vi_cv_path_mzscheme" != "X"; then
805 dnl -- find where MzScheme thinks it was installed
806 AC_CACHE_CHECK(MzScheme install prefix,vi_cv_path_mzscheme_pfx,
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000807 dnl different versions of MzScheme differ in command line processing
808 dnl use universal approach
809 echo "(display (simplify-path \
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000810 (build-path (call-with-values \
811 (lambda () (split-path (find-system-path (quote exec-file)))) \
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000812 (lambda (base name must-be-dir?) base)) (quote up))))" > mzdirs.scm
813 dnl Remove a trailing slash
814 [ vi_cv_path_mzscheme_pfx=`${vi_cv_path_mzscheme} -r mzdirs.scm | \
815 sed -e 's+/$++'` ])
816 rm -f mzdirs.scm
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000817 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000818 fi
819 fi
820
821 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100822 AC_MSG_CHECKING(for racket include directory)
823 SCHEME_INC=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-include-dir))) (when (path? p) (display p)))'`
824 if test "X$SCHEME_INC" != "X"; then
825 AC_MSG_RESULT(${SCHEME_INC})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000826 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100827 AC_MSG_RESULT(not found)
828 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include)
829 if test -f "$vi_cv_path_mzscheme_pfx/include/scheme.h"; then
830 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000831 AC_MSG_RESULT(yes)
Bram Moolenaard7afed32007-05-06 13:26:41 +0000832 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000833 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100834 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt)
835 if test -f "$vi_cv_path_mzscheme_pfx/include/plt/scheme.h"; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000836 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100837 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000838 else
839 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100840 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket)
841 if test -f "$vi_cv_path_mzscheme_pfx/include/racket/scheme.h"; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100842 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100843 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100844 else
845 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100846 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/)
847 if test -f /usr/include/plt/scheme.h; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100848 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100849 SCHEME_INC=/usr/include/plt
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100850 else
851 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100852 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/racket/)
853 if test -f /usr/include/racket/scheme.h; then
854 AC_MSG_RESULT(yes)
855 SCHEME_INC=/usr/include/racket
856 else
857 AC_MSG_RESULT(no)
858 vi_cv_path_mzscheme_pfx=
859 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100860 fi
861 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000862 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000863 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000864 fi
865 fi
866
867 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100868
869 AC_MSG_CHECKING(for racket lib directory)
870 SCHEME_LIB=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-lib-dir))) (when (path? p) (display p)))'`
871 if test "X$SCHEME_LIB" != "X"; then
872 AC_MSG_RESULT(${SCHEME_LIB})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000873 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100874 AC_MSG_RESULT(not found)
875 fi
876
877 for path in "${vi_cv_path_mzscheme_pfx}/lib" "${SCHEME_LIB}"; do
878 if test "X$path" != "X"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200879 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100880 MZSCHEME_LIBS="-framework Racket"
881 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
882 elif test -f "${path}/libmzscheme3m.a"; then
883 MZSCHEME_LIBS="${path}/libmzscheme3m.a"
884 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
885 elif test -f "${path}/libracket3m.a"; then
886 MZSCHEME_LIBS="${path}/libracket3m.a"
887 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
888 elif test -f "${path}/libracket.a"; then
889 MZSCHEME_LIBS="${path}/libracket.a ${path}/libmzgc.a"
890 elif test -f "${path}/libmzscheme.a"; then
891 MZSCHEME_LIBS="${path}/libmzscheme.a ${path}/libmzgc.a"
892 else
893 dnl Using shared objects
894 if test -f "${path}/libmzscheme3m.so"; then
895 MZSCHEME_LIBS="-L${path} -lmzscheme3m"
896 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
897 elif test -f "${path}/libracket3m.so"; then
898 MZSCHEME_LIBS="-L${path} -lracket3m"
899 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
900 elif test -f "${path}/libracket.so"; then
901 MZSCHEME_LIBS="-L${path} -lracket -lmzgc"
902 else
903 dnl try next until last
904 if test "$path" != "$SCHEME_LIB"; then
905 continue
906 fi
907 MZSCHEME_LIBS="-L${path} -lmzscheme -lmzgc"
908 fi
909 if test "$GCC" = yes; then
910 dnl Make Vim remember the path to the library. For when it's not in
911 dnl $LD_LIBRARY_PATH.
912 MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${path}"
913 elif test "`(uname) 2>/dev/null`" = SunOS &&
914 uname -r | grep '^5' >/dev/null; then
915 MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${path}"
916 fi
917 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000918 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100919 if test "X$MZSCHEME_LIBS" != "X"; then
920 break
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +0000921 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100922 done
923
924 AC_MSG_CHECKING([if racket requires -pthread])
925 if test "X$SCHEME_LIB" != "X" && $FGREP -e -pthread "$SCHEME_LIB/buildinfo" >/dev/null ; then
926 AC_MSG_RESULT(yes)
927 MZSCHEME_LIBS="${MZSCHEME_LIBS} -pthread"
928 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -pthread"
929 else
930 AC_MSG_RESULT(no)
931 fi
932
933 AC_MSG_CHECKING(for racket config directory)
934 SCHEME_CONFIGDIR=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-config-dir))) (when (path? p) (display p)))'`
935 if test "X$SCHEME_CONFIGDIR" != "X"; then
936 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DMZSCHEME_CONFIGDIR='\"${SCHEME_CONFIGDIR}\"'"
937 AC_MSG_RESULT(${SCHEME_CONFIGDIR})
938 else
939 AC_MSG_RESULT(not found)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000940 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100941
942 AC_MSG_CHECKING(for racket collects directory)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100943 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))))'`
944 if test "X$SCHEME_COLLECTS" = "X"; then
945 if test -d "$vi_cv_path_mzscheme_pfx/lib/plt/collects"; then
946 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/plt/
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100947 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100948 if test -d "$vi_cv_path_mzscheme_pfx/lib/racket/collects"; then
949 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/racket/
Bram Moolenaar75676462013-01-30 14:55:42 +0100950 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100951 if test -d "$vi_cv_path_mzscheme_pfx/share/racket/collects"; then
952 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/
953 else
954 if test -d "$vi_cv_path_mzscheme_pfx/collects"; then
955 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/
956 fi
Bram Moolenaar75676462013-01-30 14:55:42 +0100957 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100958 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100959 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000960 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100961 if test "X$SCHEME_COLLECTS" != "X" ; then
962 AC_MSG_RESULT(${SCHEME_COLLECTS})
963 else
964 AC_MSG_RESULT(not found)
965 fi
966
967 AC_MSG_CHECKING(for mzscheme_base.c)
968 if test -f "${SCHEME_COLLECTS}collects/scheme/base.ss" ; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000969 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +0100970 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
971 MZSCHEME_MOD="++lib scheme/base"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100972 else
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100973 if test -f "${SCHEME_COLLECTS}collects/scheme/base.rkt" ; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100974 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +0100975 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
976 MZSCHEME_MOD="++lib scheme/base"
977 else
978 if test -f "${SCHEME_COLLECTS}collects/racket/base.rkt" ; then
979 MZSCHEME_EXTRA="mzscheme_base.c"
980 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/raco ctool"
981 MZSCHEME_MOD=""
982 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100983 fi
984 fi
985 if test "X$MZSCHEME_EXTRA" != "X" ; then
986 dnl need to generate bytecode for MzScheme base
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000987 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE"
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100988 AC_MSG_RESULT(needed)
989 else
990 AC_MSG_RESULT(not needed)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000991 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100992
Bram Moolenaar9e902192013-07-17 18:58:11 +0200993 dnl On Ubuntu this fixes "undefined reference to symbol 'ffi_type_void'".
994 AC_CHECK_LIB(ffi, ffi_type_void, [MZSCHEME_LIBS="$MZSCHEME_LIBS -lffi"])
995
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000996 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -I${SCHEME_INC} \
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100997 -DMZSCHEME_COLLECTS='\"${SCHEME_COLLECTS}collects\"'"
Bram Moolenaar9e902192013-07-17 18:58:11 +0200998
999 dnl Test that we can compile a simple program with these CFLAGS and LIBS.
1000 AC_MSG_CHECKING([if compile and link flags for MzScheme are sane])
1001 cflags_save=$CFLAGS
1002 libs_save=$LIBS
1003 CFLAGS="$CFLAGS $MZSCHEME_CFLAGS"
1004 LIBS="$LIBS $MZSCHEME_LIBS"
1005 AC_TRY_LINK(,[ ],
1006 AC_MSG_RESULT(yes); mzs_ok=yes,
1007 AC_MSG_RESULT(no: MZSCHEME DISABLED); mzs_ok=no)
1008 CFLAGS=$cflags_save
1009 LIBS=$libs_save
1010 if test $mzs_ok = yes; then
1011 MZSCHEME_SRC="if_mzsch.c"
1012 MZSCHEME_OBJ="objects/if_mzsch.o"
1013 MZSCHEME_PRO="if_mzsch.pro"
1014 AC_DEFINE(FEAT_MZSCHEME)
1015 else
1016 MZSCHEME_CFLAGS=
1017 MZSCHEME_LIBS=
1018 MZSCHEME_EXTRA=
1019 MZSCHEME_MZC=
1020 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001021 fi
1022 AC_SUBST(MZSCHEME_SRC)
1023 AC_SUBST(MZSCHEME_OBJ)
1024 AC_SUBST(MZSCHEME_PRO)
1025 AC_SUBST(MZSCHEME_LIBS)
1026 AC_SUBST(MZSCHEME_CFLAGS)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001027 AC_SUBST(MZSCHEME_EXTRA)
1028 AC_SUBST(MZSCHEME_MZC)
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001029fi
1030
1031
Bram Moolenaar071d4272004-06-13 20:20:40 +00001032AC_MSG_CHECKING(--enable-perlinterp argument)
1033AC_ARG_ENABLE(perlinterp,
Bram Moolenaare06c1882010-07-21 22:05:20 +02001034 [ --enable-perlinterp[=OPTS] Include Perl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001035 [enable_perlinterp="no"])
1036AC_MSG_RESULT($enable_perlinterp)
Bram Moolenaare06c1882010-07-21 22:05:20 +02001037if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01001038 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1039 AC_MSG_ERROR([cannot use Perl with tiny or small features])
1040 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001041 AC_SUBST(vi_cv_path_perl)
1042 AC_PATH_PROG(vi_cv_path_perl, perl)
1043 if test "X$vi_cv_path_perl" != "X"; then
1044 AC_MSG_CHECKING(Perl version)
1045 if $vi_cv_path_perl -e 'require 5.003_01' >/dev/null 2>/dev/null; then
1046 eval `$vi_cv_path_perl -V:usethreads`
Bram Moolenaare06c1882010-07-21 22:05:20 +02001047 eval `$vi_cv_path_perl -V:libperl`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001048 if test "X$usethreads" = "XUNKNOWN" -o "X$usethreads" = "Xundef"; then
1049 badthreads=no
1050 else
1051 if $vi_cv_path_perl -e 'require 5.6.0' >/dev/null 2>/dev/null; then
1052 eval `$vi_cv_path_perl -V:use5005threads`
1053 if test "X$use5005threads" = "XUNKNOWN" -o "X$use5005threads" = "Xundef"; then
1054 badthreads=no
1055 else
1056 badthreads=yes
1057 AC_MSG_RESULT(>>> Perl > 5.6 with 5.5 threads cannot be used <<<)
1058 fi
1059 else
1060 badthreads=yes
1061 AC_MSG_RESULT(>>> Perl 5.5 with threads cannot be used <<<)
1062 fi
1063 fi
1064 if test $badthreads = no; then
1065 AC_MSG_RESULT(OK)
1066 eval `$vi_cv_path_perl -V:shrpenv`
1067 if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04
1068 shrpenv=""
1069 fi
1070 vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlibexp}'`
1071 AC_SUBST(vi_cv_perllib)
Bram Moolenaard5f62b12014-08-17 17:05:44 +02001072 vi_cv_perl_extutils=unknown_perl_extutils_path
1073 for extutils_rel_path in ExtUtils vendor_perl/ExtUtils; do
1074 xsubpp_path="$vi_cv_perllib/$extutils_rel_path/xsubpp"
1075 if test -f "$xsubpp_path"; then
1076 vi_cv_perl_xsubpp="$xsubpp_path"
1077 fi
1078 done
1079 AC_SUBST(vi_cv_perl_xsubpp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001080 dnl Remove "-fno-something", it breaks using cproto.
Bram Moolenaar280a8682015-06-21 13:41:08 +02001081 dnl Remove "-fdebug-prefix-map", it isn't supported by clang.
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001082 dnl Remove "FORTIFY_SOURCE", it will be defined twice.
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001083 dnl remove -pipe and -Wxxx, it confuses cproto
Bram Moolenaar071d4272004-06-13 20:20:40 +00001084 perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001085 -e 'ccflags;perl_inc;print"\n"' | sed -e 's/-fno[[^ ]]*//' \
1086 -e 's/-fdebug-prefix-map[[^ ]]*//g' \
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001087 -e 's/-pipe //' \
1088 -e 's/-W[[^ ]]*//g' \
1089 -e 's/-D_FORTIFY_SOURCE=.//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001090 dnl Remove "-lc", it breaks on FreeBSD when using "-pthread".
1091 perllibs=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed -e 'ldopts' | \
1092 sed -e '/Warning/d' -e '/Note (probably harmless)/d' \
1093 -e 's/-bE:perl.exp//' -e 's/-lc //'`
1094 dnl Don't add perl lib to $LIBS: if it's not in LD_LIBRARY_PATH
1095 dnl a test in configure may fail because of that.
1096 perlldflags=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed \
1097 -e 'ccdlflags' | sed -e 's/-bE:perl.exp//'`
1098
1099 dnl check that compiling a simple program still works with the flags
1100 dnl added for Perl.
1101 AC_MSG_CHECKING([if compile and link flags for Perl are sane])
1102 cflags_save=$CFLAGS
1103 libs_save=$LIBS
1104 ldflags_save=$LDFLAGS
1105 CFLAGS="$CFLAGS $perlcppflags"
1106 LIBS="$LIBS $perllibs"
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001107 perlldflags=`echo "$perlldflags" | sed -e 's/^ *//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001108 LDFLAGS="$perlldflags $LDFLAGS"
1109 AC_TRY_LINK(,[ ],
1110 AC_MSG_RESULT(yes); perl_ok=yes,
1111 AC_MSG_RESULT(no: PERL DISABLED); perl_ok=no)
1112 CFLAGS=$cflags_save
1113 LIBS=$libs_save
1114 LDFLAGS=$ldflags_save
1115 if test $perl_ok = yes; then
1116 if test "X$perlcppflags" != "X"; then
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001117 PERL_CFLAGS=$perlcppflags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001118 fi
1119 if test "X$perlldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001120 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$perlldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001121 LDFLAGS="$perlldflags $LDFLAGS"
1122 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001123 fi
1124 PERL_LIBS=$perllibs
1125 PERL_SRC="auto/if_perl.c if_perlsfio.c"
1126 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o"
1127 PERL_PRO="if_perl.pro if_perlsfio.pro"
1128 AC_DEFINE(FEAT_PERL)
1129 fi
1130 fi
1131 else
1132 AC_MSG_RESULT(>>> too old; need Perl version 5.003_01 or later <<<)
1133 fi
1134 fi
1135
Bram Moolenaard0573012017-10-28 21:11:06 +02001136 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00001137 dnl Mac OS X 10.2 or later
Bram Moolenaar071d4272004-06-13 20:20:40 +00001138 dir=/System/Library/Perl
1139 darwindir=$dir/darwin
1140 if test -d $darwindir; then
1141 PERL=/usr/bin/perl
1142 else
1143 dnl Mac OS X 10.3
1144 dir=/System/Library/Perl/5.8.1
1145 darwindir=$dir/darwin-thread-multi-2level
1146 if test -d $darwindir; then
1147 PERL=/usr/bin/perl
1148 fi
1149 fi
1150 if test -n "$PERL"; then
1151 PERL_DIR="$dir"
1152 PERL_CFLAGS="-DFEAT_PERL -I$darwindir/CORE"
1153 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o $darwindir/auto/DynaLoader/DynaLoader.a"
1154 PERL_LIBS="-L$darwindir/CORE -lperl"
1155 fi
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001156 dnl Perl on Mac OS X 10.5 adds "-arch" flags but these should only
1157 dnl be included if requested by passing --with-mac-arch to
1158 dnl configure, so strip these flags first (if present)
1159 PERL_LIBS=`echo "$PERL_LIBS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
1160 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 +00001161 fi
Bram Moolenaare06c1882010-07-21 22:05:20 +02001162 if test "$enable_perlinterp" = "dynamic"; then
1163 if test "$perl_ok" = "yes" -a "X$libperl" != "X"; then
1164 AC_DEFINE(DYNAMIC_PERL)
1165 PERL_CFLAGS="-DDYNAMIC_PERL_DLL=\\\"$libperl\\\" $PERL_CFLAGS"
1166 fi
1167 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001168
1169 if test "$fail_if_missing" = "yes" -a "$perl_ok" != "yes"; then
1170 AC_MSG_ERROR([could not configure perl])
1171 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001172fi
1173AC_SUBST(shrpenv)
1174AC_SUBST(PERL_SRC)
1175AC_SUBST(PERL_OBJ)
1176AC_SUBST(PERL_PRO)
1177AC_SUBST(PERL_CFLAGS)
1178AC_SUBST(PERL_LIBS)
1179
1180AC_MSG_CHECKING(--enable-pythoninterp argument)
1181AC_ARG_ENABLE(pythoninterp,
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001182 [ --enable-pythoninterp[=OPTS] Include Python interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001183 [enable_pythoninterp="no"])
1184AC_MSG_RESULT($enable_pythoninterp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001185if test "$enable_pythoninterp" = "yes" -o "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001186 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1187 AC_MSG_ERROR([cannot use Python with tiny or small features])
1188 fi
1189
Bram Moolenaar071d4272004-06-13 20:20:40 +00001190 dnl -- find the python executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001191 AC_MSG_CHECKING(--with-python-command argument)
1192 AC_SUBST(vi_cv_path_python)
1193 AC_ARG_WITH(python-command, [ --with-python-command=NAME name of the Python 2 command (default: python2 or python)],
1194 vi_cv_path_python="$withval"; AC_MSG_RESULT($vi_cv_path_python),
1195 AC_MSG_RESULT(no))
1196
1197 if test "X$vi_cv_path_python" = "X"; then
1198 AC_PATH_PROGS(vi_cv_path_python, python2 python)
1199 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001200 if test "X$vi_cv_path_python" != "X"; then
1201
1202 dnl -- get its version number
1203 AC_CACHE_CHECK(Python version,vi_cv_var_python_version,
1204 [[vi_cv_var_python_version=`
1205 ${vi_cv_path_python} -c 'import sys; print sys.version[:3]'`
1206 ]])
1207
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001208 dnl -- it must be at least version 2.3
1209 AC_MSG_CHECKING(Python is 2.3 or better)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001210 if ${vi_cv_path_python} -c \
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001211 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001212 then
1213 AC_MSG_RESULT(yep)
1214
1215 dnl -- find where python thinks it was installed
1216 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python_pfx,
1217 [ vi_cv_path_python_pfx=`
1218 ${vi_cv_path_python} -c \
1219 "import sys; print sys.prefix"` ])
1220
1221 dnl -- and where it thinks it runs
1222 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python_epfx,
1223 [ vi_cv_path_python_epfx=`
1224 ${vi_cv_path_python} -c \
1225 "import sys; print sys.exec_prefix"` ])
1226
1227 dnl -- python's internal library path
1228
1229 AC_CACHE_VAL(vi_cv_path_pythonpath,
1230 [ vi_cv_path_pythonpath=`
1231 unset PYTHONPATH;
1232 ${vi_cv_path_python} -c \
1233 "import sys, string; print string.join(sys.path,':')"` ])
1234
1235 dnl -- where the Python implementation library archives are
1236
1237 AC_ARG_WITH(python-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001238 [ --with-python-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001239 [ vi_cv_path_python_conf="${withval}"; have_python_config_dir=1 ] )
Bram Moolenaar071d4272004-06-13 20:20:40 +00001240
1241 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python_conf,
1242 [
1243 vi_cv_path_python_conf=
Bram Moolenaarac499e32013-06-02 19:14:17 +02001244 d=`${vi_cv_path_python} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBPL')"`
1245 if test -d "$d" && test -f "$d/config.c"; then
1246 vi_cv_path_python_conf="$d"
1247 else
1248 for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
1249 for subdir in lib64 lib share; do
1250 d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
1251 if test -d "$d" && test -f "$d/config.c"; then
1252 vi_cv_path_python_conf="$d"
1253 fi
1254 done
Bram Moolenaar071d4272004-06-13 20:20:40 +00001255 done
Bram Moolenaarac499e32013-06-02 19:14:17 +02001256 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001257 ])
1258
1259 PYTHON_CONFDIR="${vi_cv_path_python_conf}"
1260
1261 if test "X$PYTHON_CONFDIR" = "X"; then
1262 AC_MSG_RESULT([can't find it!])
1263 else
1264
1265 dnl -- we need to examine Python's config/Makefile too
1266 dnl see what the interpreter is built from
1267 AC_CACHE_VAL(vi_cv_path_python_plibs,
1268 [
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001269 pwd=`pwd`
1270 tmp_mkf="$pwd/config-PyMake$$"
1271 cat -- "${PYTHON_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001272__:
Bram Moolenaar218116c2010-05-20 21:46:00 +02001273 @echo "python_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001274 @echo "python_LIBS='$(LIBS)'"
1275 @echo "python_SYSLIBS='$(SYSLIBS)'"
1276 @echo "python_LINKFORSHARED='$(LINKFORSHARED)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001277 @echo "python_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001278 @echo "python_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001279 @echo "python_PYTHONFRAMEWORK='$(PYTHONFRAMEWORK)'"
1280 @echo "python_PYTHONFRAMEWORKPREFIX='$(PYTHONFRAMEWORKPREFIX)'"
1281 @echo "python_PYTHONFRAMEWORKINSTALLDIR='$(PYTHONFRAMEWORKINSTALLDIR)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001282eof
1283 dnl -- delete the lines from make about Entering/Leaving directory
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001284 eval "`cd ${PYTHON_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1285 rm -f -- "${tmp_mkf}"
Bram Moolenaard0573012017-10-28 21:11:06 +02001286 if test "x$MACOS_X" = "xyes" && test -n "${python_PYTHONFRAMEWORK}" && ${vi_cv_path_python} -c \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001287 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then
1288 vi_cv_path_python_plibs="-framework Python"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001289 if test "x${vi_cv_path_python}" != "x/usr/bin/python" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
1290 vi_cv_path_python_plibs="-F${python_PYTHONFRAMEWORKPREFIX} -framework Python"
1291 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001292 else
Bram Moolenaar9ce42132018-04-11 22:19:36 +02001293 vi_cv_path_python_plibs="-L${PYTHON_CONFDIR} -lpython${vi_cv_var_python_version}"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001294 dnl -- Check if the path contained in python_LINKFORSHARED is
1295 dnl usable for vim build. If not, make and try other
1296 dnl candidates.
Bram Moolenaara161e262015-03-24 15:14:27 +01001297 if test -n "${python_LINKFORSHARED}" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
Bram Moolenaar6c927552015-03-24 12:21:33 +01001298 python_link_symbol=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]].*/\1/'`
1299 python_link_path=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]][[ \t]]*\(.*\)/\2/'`
1300 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1301 dnl -- The path looks relative. Guess the absolute one using
1302 dnl the prefix and try that.
1303 python_link_path="${python_PYTHONFRAMEWORKPREFIX}/${python_link_path}"
1304 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1305 dnl -- A last resort.
1306 python_link_path="${python_PYTHONFRAMEWORKINSTALLDIR}/Versions/${vi_cv_var_python_version}/${python_PYTHONFRAMEWORK}"
1307 dnl -- No check is done. The last word is left to the
1308 dnl "sanity" test on link flags that follows shortly.
1309 fi
1310 python_LINKFORSHARED="${python_link_symbol} ${python_link_path}"
1311 fi
1312 fi
Bram Moolenaar218116c2010-05-20 21:46:00 +02001313 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 +00001314 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1315 vi_cv_path_python_plibs=`echo $vi_cv_path_python_plibs | sed s/-ltermcap//`
1316 fi
1317 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001318 AC_CACHE_CHECK(Python's dll name,vi_cv_dll_name_python,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001319 [
1320 if test "X$python_DLLLIBRARY" != "X"; then
1321 vi_cv_dll_name_python="$python_DLLLIBRARY"
1322 else
1323 vi_cv_dll_name_python="$python_INSTSONAME"
1324 fi
1325 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00001326
1327 PYTHON_LIBS="${vi_cv_path_python_plibs}"
1328 if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001329 PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001330 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001331 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 +00001332 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001333 if test "X$have_python_config_dir" = "X1" -a "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001334 dnl Define PYTHON_HOME if --with-python-config-dir was used
1335 PYTHON_CFLAGS="${PYTHON_CFLAGS} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'"
1336
1337 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001338 PYTHON_SRC="if_python.c"
Bram Moolenaar9bdb9a02012-07-25 16:32:08 +02001339 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001340
1341 dnl On FreeBSD linking with "-pthread" is required to use threads.
1342 dnl _THREAD_SAFE must be used for compiling then.
1343 dnl The "-pthread" is added to $LIBS, so that the following check for
1344 dnl sigaltstack() will look in libc_r (it's there in libc!).
1345 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1346 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1347 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1348 AC_MSG_CHECKING([if -pthread should be used])
1349 threadsafe_flag=
1350 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001351 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00001352 if test "`(uname) 2>/dev/null`" != Darwin; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001353 test "$GCC" = yes && threadsafe_flag="-pthread"
1354 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1355 threadsafe_flag="-D_THREAD_SAFE"
1356 thread_lib="-pthread"
1357 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001358 if test "`(uname) 2>/dev/null`" = SunOS; then
1359 threadsafe_flag="-pthreads"
1360 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001361 fi
1362 libs_save_old=$LIBS
1363 if test -n "$threadsafe_flag"; then
1364 cflags_save=$CFLAGS
1365 CFLAGS="$CFLAGS $threadsafe_flag"
1366 LIBS="$LIBS $thread_lib"
1367 AC_TRY_LINK(,[ ],
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001368 AC_MSG_RESULT(yes); PYTHON_CFLAGS="$PYTHON_CFLAGS $threadsafe_flag",
Bram Moolenaar071d4272004-06-13 20:20:40 +00001369 AC_MSG_RESULT(no); LIBS=$libs_save_old
1370 )
1371 CFLAGS=$cflags_save
1372 else
1373 AC_MSG_RESULT(no)
1374 fi
1375
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001376 dnl Check that compiling a simple program still works with the flags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001377 dnl added for Python.
1378 AC_MSG_CHECKING([if compile and link flags for Python are sane])
1379 cflags_save=$CFLAGS
1380 libs_save=$LIBS
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001381 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001382 LIBS="$LIBS $PYTHON_LIBS"
1383 AC_TRY_LINK(,[ ],
1384 AC_MSG_RESULT(yes); python_ok=yes,
1385 AC_MSG_RESULT(no: PYTHON DISABLED); python_ok=no)
1386 CFLAGS=$cflags_save
1387 LIBS=$libs_save
1388 if test $python_ok = yes; then
1389 AC_DEFINE(FEAT_PYTHON)
1390 else
1391 LIBS=$libs_save_old
1392 PYTHON_SRC=
1393 PYTHON_OBJ=
1394 PYTHON_LIBS=
1395 PYTHON_CFLAGS=
1396 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001397 fi
1398 else
1399 AC_MSG_RESULT(too old)
1400 fi
1401 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001402
1403 if test "$fail_if_missing" = "yes" -a "$python_ok" != "yes"; then
1404 AC_MSG_ERROR([could not configure python])
1405 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001406fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001407
Bram Moolenaar071d4272004-06-13 20:20:40 +00001408AC_SUBST(PYTHON_LIBS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001409AC_SUBST(PYTHON_CFLAGS)
1410AC_SUBST(PYTHON_SRC)
1411AC_SUBST(PYTHON_OBJ)
1412
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001413
1414AC_MSG_CHECKING(--enable-python3interp argument)
1415AC_ARG_ENABLE(python3interp,
Bram Moolenaar8008b632017-07-18 21:33:20 +02001416 [ --enable-python3interp[=OPTS] Include Python3 interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001417 [enable_python3interp="no"])
1418AC_MSG_RESULT($enable_python3interp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001419if test "$enable_python3interp" = "yes" -o "$enable_python3interp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001420 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1421 AC_MSG_ERROR([cannot use Python with tiny or small features])
1422 fi
1423
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001424 dnl -- find the python3 executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001425 AC_MSG_CHECKING(--with-python3-command argument)
1426 AC_SUBST(vi_cv_path_python3)
1427 AC_ARG_WITH(python3-command, [ --with-python3-command=NAME name of the Python 3 command (default: python3 or python)],
1428 vi_cv_path_python3="$withval"; AC_MSG_RESULT($vi_cv_path_python3),
1429 AC_MSG_RESULT(no))
1430
1431 if test "X$vi_cv_path_python3" = "X"; then
1432 AC_PATH_PROGS(vi_cv_path_python3, python3 python)
1433 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001434 if test "X$vi_cv_path_python3" != "X"; then
1435
1436 dnl -- get its version number
1437 AC_CACHE_CHECK(Python version,vi_cv_var_python3_version,
1438 [[vi_cv_var_python3_version=`
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001439 ${vi_cv_path_python3} -c 'import sys; print(sys.version[:3])'`
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001440 ]])
1441
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001442 dnl -- it must be at least version 3
1443 AC_MSG_CHECKING(Python is 3.0 or better)
1444 if ${vi_cv_path_python3} -c \
1445 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.0)"
1446 then
1447 AC_MSG_RESULT(yep)
Bram Moolenaar456f2bb2011-06-12 21:37:13 +02001448
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001449 dnl -- get abiflags for python 3.2 or higher (PEP 3149)
1450 AC_CACHE_CHECK(Python's abiflags,vi_cv_var_python3_abiflags,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001451 [
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001452 vi_cv_var_python3_abiflags=
1453 if ${vi_cv_path_python3} -c \
1454 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)"
1455 then
1456 vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \
1457 "import sys; print(sys.abiflags)"`
1458 fi ])
1459
1460 dnl -- find where python3 thinks it was installed
1461 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx,
1462 [ vi_cv_path_python3_pfx=`
1463 ${vi_cv_path_python3} -c \
1464 "import sys; print(sys.prefix)"` ])
1465
1466 dnl -- and where it thinks it runs
1467 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx,
1468 [ vi_cv_path_python3_epfx=`
1469 ${vi_cv_path_python3} -c \
1470 "import sys; print(sys.exec_prefix)"` ])
1471
1472 dnl -- python3's internal library path
1473
1474 AC_CACHE_VAL(vi_cv_path_python3path,
1475 [ vi_cv_path_python3path=`
1476 unset PYTHONPATH;
1477 ${vi_cv_path_python3} -c \
1478 "import sys, string; print(':'.join(sys.path))"` ])
1479
1480 dnl -- where the Python implementation library archives are
1481
1482 AC_ARG_WITH(python3-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001483 [ --with-python3-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001484 [ vi_cv_path_python3_conf="${withval}"; have_python3_config_dir=1 ] )
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001485
1486 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf,
1487 [
1488 vi_cv_path_python3_conf=
Bram Moolenaarfee496d2013-07-12 20:07:24 +02001489 config_dir="config-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001490 d=`${vi_cv_path_python3} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBPL'))"`
1491 if test -d "$d" && test -f "$d/config.c"; then
1492 vi_cv_path_python3_conf="$d"
1493 else
1494 for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do
1495 for subdir in lib64 lib share; do
1496 d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}"
1497 if test -d "$d" && test -f "$d/config.c"; then
1498 vi_cv_path_python3_conf="$d"
1499 fi
1500 done
1501 done
1502 fi
1503 ])
1504
1505 PYTHON3_CONFDIR="${vi_cv_path_python3_conf}"
1506
1507 if test "X$PYTHON3_CONFDIR" = "X"; then
1508 AC_MSG_RESULT([can't find it!])
1509 else
1510
1511 dnl -- we need to examine Python's config/Makefile too
1512 dnl see what the interpreter is built from
1513 AC_CACHE_VAL(vi_cv_path_python3_plibs,
1514 [
1515 pwd=`pwd`
1516 tmp_mkf="$pwd/config-PyMake$$"
1517 cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001518__:
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001519 @echo "python3_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001520 @echo "python3_LIBS='$(LIBS)'"
1521 @echo "python3_SYSLIBS='$(SYSLIBS)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001522 @echo "python3_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001523 @echo "python3_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001524eof
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001525 dnl -- delete the lines from make about Entering/Leaving directory
1526 eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1527 rm -f -- "${tmp_mkf}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001528 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 +02001529 vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}"
1530 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1531 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//`
1532 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//`
1533 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001534 AC_CACHE_CHECK(Python3's dll name,vi_cv_dll_name_python3,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001535 [
1536 if test "X$python3_DLLLIBRARY" != "X"; then
1537 vi_cv_dll_name_python3="$python3_DLLLIBRARY"
1538 else
1539 vi_cv_dll_name_python3="$python3_INSTSONAME"
1540 fi
1541 ])
1542
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001543 PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
1544 if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001545 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 +02001546 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001547 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 +02001548 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001549 if test "X$have_python3_config_dir" = "X1" -a "$enable_python3interp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001550 dnl Define PYTHON3_HOME if --with-python-config-dir was used
1551 PYTHON3_CFLAGS="${PYTHON3_CFLAGS} -DPYTHON3_HOME='L\"${vi_cv_path_python3_pfx}\"'"
1552 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001553 PYTHON3_SRC="if_python3.c"
1554 PYTHON3_OBJ="objects/if_python3.o"
1555
1556 dnl On FreeBSD linking with "-pthread" is required to use threads.
1557 dnl _THREAD_SAFE must be used for compiling then.
1558 dnl The "-pthread" is added to $LIBS, so that the following check for
1559 dnl sigaltstack() will look in libc_r (it's there in libc!).
1560 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1561 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1562 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1563 AC_MSG_CHECKING([if -pthread should be used])
1564 threadsafe_flag=
1565 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001566 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001567 if test "`(uname) 2>/dev/null`" != Darwin; then
1568 test "$GCC" = yes && threadsafe_flag="-pthread"
1569 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1570 threadsafe_flag="-D_THREAD_SAFE"
1571 thread_lib="-pthread"
1572 fi
1573 if test "`(uname) 2>/dev/null`" = SunOS; then
1574 threadsafe_flag="-pthreads"
1575 fi
1576 fi
1577 libs_save_old=$LIBS
1578 if test -n "$threadsafe_flag"; then
1579 cflags_save=$CFLAGS
1580 CFLAGS="$CFLAGS $threadsafe_flag"
1581 LIBS="$LIBS $thread_lib"
1582 AC_TRY_LINK(,[ ],
1583 AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag",
1584 AC_MSG_RESULT(no); LIBS=$libs_save_old
1585 )
1586 CFLAGS=$cflags_save
1587 else
1588 AC_MSG_RESULT(no)
1589 fi
1590
1591 dnl check that compiling a simple program still works with the flags
1592 dnl added for Python.
1593 AC_MSG_CHECKING([if compile and link flags for Python 3 are sane])
1594 cflags_save=$CFLAGS
1595 libs_save=$LIBS
1596 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1597 LIBS="$LIBS $PYTHON3_LIBS"
1598 AC_TRY_LINK(,[ ],
1599 AC_MSG_RESULT(yes); python3_ok=yes,
1600 AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no)
1601 CFLAGS=$cflags_save
1602 LIBS=$libs_save
1603 if test "$python3_ok" = yes; then
1604 AC_DEFINE(FEAT_PYTHON3)
1605 else
1606 LIBS=$libs_save_old
1607 PYTHON3_SRC=
1608 PYTHON3_OBJ=
1609 PYTHON3_LIBS=
1610 PYTHON3_CFLAGS=
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001611 fi
1612 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001613 else
1614 AC_MSG_RESULT(too old)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001615 fi
1616 fi
Bram Moolenaar1612b1a2013-06-14 21:22:39 +02001617 if test "$fail_if_missing" = "yes" -a "$python3_ok" != "yes"; then
1618 AC_MSG_ERROR([could not configure python3])
1619 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001620fi
1621
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001622AC_SUBST(PYTHON3_LIBS)
1623AC_SUBST(PYTHON3_CFLAGS)
1624AC_SUBST(PYTHON3_SRC)
1625AC_SUBST(PYTHON3_OBJ)
1626
1627dnl if python2.x and python3.x are enabled one can only link in code
1628dnl with dlopen(), dlsym(), dlclose()
1629if test "$python_ok" = yes && test "$python3_ok" = yes; then
1630 AC_DEFINE(DYNAMIC_PYTHON)
1631 AC_DEFINE(DYNAMIC_PYTHON3)
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001632 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001633 cflags_save=$CFLAGS
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001634 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001635 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001636 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001637 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001638 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001639 #include <dlfcn.h>
1640 /* If this program fails, then RTLD_GLOBAL is needed.
1641 * RTLD_GLOBAL will be used and then it is not possible to
1642 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001643 * Only the first python version used will be switched on.
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001644 */
1645
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001646 int no_rtl_global_needed_for(char *python_instsoname, char *prefix)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001647 {
1648 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001649 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001650 if (pylib != 0)
1651 {
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001652 void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome");
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001653 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1654 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1655 void (*final)(void) = dlsym(pylib, "Py_Finalize");
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001656 (*pfx)(prefix);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001657 (*init)();
1658 needed = (*simple)("import termios") == -1;
1659 (*final)();
1660 dlclose(pylib);
1661 }
1662 return !needed;
1663 }
1664
1665 int main(int argc, char** argv)
1666 {
1667 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001668 if (no_rtl_global_needed_for("${vi_cv_dll_name_python}", "${vi_cv_path_python_pfx}"))
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001669 not_needed = 1;
1670 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001671 }])],
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001672 [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001673
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001674 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001675 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001676
1677 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python3)
1678 cflags_save=$CFLAGS
1679 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001680 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001681 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001682 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001683 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001684 #include <dlfcn.h>
1685 #include <wchar.h>
1686 /* If this program fails, then RTLD_GLOBAL is needed.
1687 * RTLD_GLOBAL will be used and then it is not possible to
1688 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001689 * Only the first python version used will be switched on.
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001690 */
1691
1692 int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix)
1693 {
1694 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001695 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001696 if (pylib != 0)
1697 {
1698 void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome");
1699 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1700 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1701 void (*final)(void) = dlsym(pylib, "Py_Finalize");
1702 (*pfx)(prefix);
1703 (*init)();
1704 needed = (*simple)("import termios") == -1;
1705 (*final)();
1706 dlclose(pylib);
1707 }
1708 return !needed;
1709 }
1710
1711 int main(int argc, char** argv)
1712 {
1713 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001714 if (no_rtl_global_needed_for("${vi_cv_dll_name_python3}", L"${vi_cv_path_python3_pfx}"))
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001715 not_needed = 1;
1716 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001717 }])],
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001718 [AC_MSG_RESULT(yes);AC_DEFINE(PY3_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
1719
1720 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001721 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001722
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001723 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 Moolenaarbd5e15f2010-07-17 21:19:38 +02001726 PYTHON_LIBS=
1727 PYTHON3_SRC="if_python3.c"
1728 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001729 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001730 PYTHON3_LIBS=
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001731elif test "$python_ok" = yes && test "$enable_pythoninterp" = "dynamic"; then
1732 AC_DEFINE(DYNAMIC_PYTHON)
1733 PYTHON_SRC="if_python.c"
1734 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001735 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001736 PYTHON_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001737elif test "$python_ok" = yes; then
1738 dnl Check that adding -fPIE works. It may be needed when using a static
1739 dnl Python library.
1740 AC_MSG_CHECKING([if -fPIE can be added for Python])
1741 cflags_save=$CFLAGS
1742 libs_save=$LIBS
1743 CFLAGS="$CFLAGS $PYTHON_CFLAGS -fPIE"
1744 LIBS="$LIBS $PYTHON_LIBS"
1745 AC_TRY_LINK(,[ ],
1746 AC_MSG_RESULT(yes); fpie_ok=yes,
1747 AC_MSG_RESULT(no); fpie_ok=no)
1748 CFLAGS=$cflags_save
1749 LIBS=$libs_save
1750 if test $fpie_ok = yes; then
1751 PYTHON_CFLAGS="$PYTHON_CFLAGS -fPIE"
1752 fi
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001753elif test "$python3_ok" = yes && test "$enable_python3interp" = "dynamic"; then
1754 AC_DEFINE(DYNAMIC_PYTHON3)
1755 PYTHON3_SRC="if_python3.c"
1756 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001757 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001758 PYTHON3_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001759elif test "$python3_ok" = yes; then
1760 dnl Check that adding -fPIE works. It may be needed when using a static
1761 dnl Python library.
1762 AC_MSG_CHECKING([if -fPIE can be added for Python3])
1763 cflags_save=$CFLAGS
1764 libs_save=$LIBS
1765 CFLAGS="$CFLAGS $PYTHON3_CFLAGS -fPIE"
1766 LIBS="$LIBS $PYTHON3_LIBS"
1767 AC_TRY_LINK(,[ ],
1768 AC_MSG_RESULT(yes); fpie_ok=yes,
1769 AC_MSG_RESULT(no); fpie_ok=no)
1770 CFLAGS=$cflags_save
1771 LIBS=$libs_save
1772 if test $fpie_ok = yes; then
1773 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -fPIE"
1774 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001775fi
1776
Bram Moolenaar071d4272004-06-13 20:20:40 +00001777AC_MSG_CHECKING(--enable-tclinterp argument)
1778AC_ARG_ENABLE(tclinterp,
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001779 [ --enable-tclinterp[=OPTS] Include Tcl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001780 [enable_tclinterp="no"])
1781AC_MSG_RESULT($enable_tclinterp)
1782
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001783if test "$enable_tclinterp" = "yes" -o "$enable_tclinterp" = "dynamic"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001784
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001785 dnl on FreeBSD tclsh is a silly script, look for tclsh8.[5420]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001786 AC_MSG_CHECKING(--with-tclsh argument)
1787 AC_ARG_WITH(tclsh, [ --with-tclsh=PATH which tclsh to use (default: tclsh8.0)],
1788 tclsh_name="$withval"; AC_MSG_RESULT($tclsh_name),
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001789 tclsh_name="tclsh8.5"; AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00001790 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1791 AC_SUBST(vi_cv_path_tcl)
1792
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001793 dnl when no specific version specified, also try 8.4, 8.2 and 8.0
1794 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.5"; then
1795 tclsh_name="tclsh8.4"
1796 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1797 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001798 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.4"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001799 tclsh_name="tclsh8.2"
1800 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1801 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001802 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.2"; then
1803 tclsh_name="tclsh8.0"
1804 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1805 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001806 dnl still didn't find it, try without version number
1807 if test "X$vi_cv_path_tcl" = "X"; then
1808 tclsh_name="tclsh"
1809 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1810 fi
1811 if test "X$vi_cv_path_tcl" != "X"; then
1812 AC_MSG_CHECKING(Tcl version)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001813 if echo 'exit [[expr [info tclversion] < 8.0]]' | "$vi_cv_path_tcl" - ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001814 tclver=`echo 'puts [[info tclversion]]' | $vi_cv_path_tcl -`
1815 AC_MSG_RESULT($tclver - OK);
1816 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 +01001817 tcldll=`echo 'puts libtcl[[info tclversion]][[info sharedlibextension]]' | $vi_cv_path_tcl -`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001818
1819 AC_MSG_CHECKING(for location of Tcl include)
Bram Moolenaard0573012017-10-28 21:11:06 +02001820 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001821 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 +00001822 else
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001823 dnl For all macOS, use the value from TCL in case use of, say, homebrew
Bram Moolenaar071d4272004-06-13 20:20:40 +00001824 dnl For Mac OS X 10.3, use the OS-provided framework location
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001825 dnl For Mac OS X 10.14, the OS-provided framework location doesn't contain the headers, so also check the Xcode SDK
1826 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 +00001827 fi
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001828 TCL_INC=
Bram Moolenaar071d4272004-06-13 20:20:40 +00001829 for try in $tclinc; do
1830 if test -f "$try/tcl.h"; then
1831 AC_MSG_RESULT($try/tcl.h)
1832 TCL_INC=$try
1833 break
1834 fi
1835 done
1836 if test -z "$TCL_INC"; then
1837 AC_MSG_RESULT(<not found>)
1838 SKIP_TCL=YES
1839 fi
1840 if test -z "$SKIP_TCL"; then
1841 AC_MSG_CHECKING(for location of tclConfig.sh script)
Bram Moolenaard0573012017-10-28 21:11:06 +02001842 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001843 tclcnf=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001844 tclcnf="$tclcnf `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001845 else
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001846 dnl For all macOS, use the value from TCL in case use of, say, homebrew
Bram Moolenaar071d4272004-06-13 20:20:40 +00001847 dnl For Mac OS X 10.3, use the OS-provided framework location
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001848 dnl For Mac OS X 10.14, the OS-provided framework location doesn't contain the headers, so also check the Xcode SDK
1849 tclcnf=`echo $tclinc | sed s/include/lib/g`
1850 tclcnf="$tclcnf /System/Library/Frameworks/Tcl.framework `xcrun --show-sdk-path`/System/Library/Frameworks/Tcl.framework"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001851 fi
1852 for try in $tclcnf; do
Bram Moolenaar49222be2015-12-11 18:11:30 +01001853 if test -f "$try/tclConfig.sh"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001854 AC_MSG_RESULT($try/tclConfig.sh)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001855 . "$try/tclConfig.sh"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001856 dnl use eval, because tcl 8.2 includes ${TCL_DBGX}
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001857 if test "$enable_tclinterp" = "dynamic"; then
1858 TCL_LIBS=`eval echo "$TCL_STUB_LIB_SPEC $TCL_LIBS"`
1859 else
1860 TCL_LIBS=`eval echo "$TCL_LIB_SPEC $TCL_LIBS"`
1861 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001862 dnl Use $TCL_DEFS for -D_THREAD_SAFE et al. But only use the
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001863 dnl "-D_ABC" items. Watch out for -DFOO=long\ long.
Bram Moolenaar4394bff2008-07-24 11:21:31 +00001864 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 +00001865 break
1866 fi
1867 done
1868 if test -z "$TCL_LIBS"; then
1869 AC_MSG_RESULT(<not found>)
1870 AC_MSG_CHECKING(for Tcl library by myself)
1871 tcllib=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001872 tcllib="$tcllib `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001873 for ext in .so .a ; do
1874 for ver in "" $tclver ; do
1875 for try in $tcllib ; do
1876 trylib=tcl$ver$ext
Bram Moolenaar49222be2015-12-11 18:11:30 +01001877 if test -f "$try/lib$trylib" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001878 AC_MSG_RESULT($try/lib$trylib)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001879 TCL_LIBS="-L\"$try\" -ltcl$ver -ldl -lm"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001880 if test "`(uname) 2>/dev/null`" = SunOS &&
1881 uname -r | grep '^5' >/dev/null; then
1882 TCL_LIBS="$TCL_LIBS -R $try"
1883 fi
1884 break 3
1885 fi
1886 done
1887 done
1888 done
1889 if test -z "$TCL_LIBS"; then
1890 AC_MSG_RESULT(<not found>)
1891 SKIP_TCL=YES
1892 fi
1893 fi
1894 if test -z "$SKIP_TCL"; then
1895 AC_DEFINE(FEAT_TCL)
1896 TCL_SRC=if_tcl.c
1897 TCL_OBJ=objects/if_tcl.o
1898 TCL_PRO=if_tcl.pro
1899 TCL_CFLAGS="-I$TCL_INC $TCL_DEFS"
1900 fi
1901 fi
1902 else
1903 AC_MSG_RESULT(too old; need Tcl version 8.0 or later)
1904 fi
1905 fi
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001906 if test "$enable_tclinterp" = "dynamic"; then
1907 if test "X$TCL_SRC" != "X" -a "X$tcldll" != "X"; then
1908 AC_DEFINE(DYNAMIC_TCL)
1909 TCL_CFLAGS="-DDYNAMIC_TCL_DLL=\\\"$tcldll\\\" -DDYNAMIC_TCL_VER=\\\"$tclver\\\" $TCL_CFLAGS"
1910 fi
1911 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001912 if test "$fail_if_missing" = "yes" -a -z "$TCL_SRC"; then
1913 AC_MSG_ERROR([could not configure Tcl])
1914 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001915fi
1916AC_SUBST(TCL_SRC)
1917AC_SUBST(TCL_OBJ)
1918AC_SUBST(TCL_PRO)
1919AC_SUBST(TCL_CFLAGS)
1920AC_SUBST(TCL_LIBS)
1921
1922AC_MSG_CHECKING(--enable-rubyinterp argument)
1923AC_ARG_ENABLE(rubyinterp,
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001924 [ --enable-rubyinterp[=OPTS] Include Ruby interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001925 [enable_rubyinterp="no"])
1926AC_MSG_RESULT($enable_rubyinterp)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001927if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001928 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1929 AC_MSG_ERROR([cannot use Ruby with tiny or small features])
1930 fi
1931
Bram Moolenaar165641d2010-02-17 16:23:09 +01001932 AC_MSG_CHECKING(--with-ruby-command argument)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001933 AC_SUBST(vi_cv_path_ruby)
Bram Moolenaar948733a2011-05-05 18:10:16 +02001934 AC_ARG_WITH(ruby-command, [ --with-ruby-command=RUBY name of the Ruby command (default: ruby)],
1935 RUBY_CMD="$withval"; vi_cv_path_ruby="$withval"; AC_MSG_RESULT($RUBY_CMD),
1936 RUBY_CMD="ruby"; AC_MSG_RESULT(defaulting to $RUBY_CMD))
Bram Moolenaar165641d2010-02-17 16:23:09 +01001937 AC_PATH_PROG(vi_cv_path_ruby, $RUBY_CMD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001938 if test "X$vi_cv_path_ruby" != "X"; then
1939 AC_MSG_CHECKING(Ruby version)
Bram Moolenaare4efc3b2005-03-07 23:16:51 +00001940 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 +00001941 AC_MSG_RESULT(OK)
Bram Moolenaar81398892012-10-03 21:09:35 +02001942 AC_MSG_CHECKING(Ruby rbconfig)
1943 ruby_rbconfig="RbConfig"
1944 if ! $vi_cv_path_ruby -r rbconfig -e 'RbConfig' >/dev/null 2>/dev/null; then
1945 ruby_rbconfig="Config"
1946 fi
1947 AC_MSG_RESULT($ruby_rbconfig)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001948 AC_MSG_CHECKING(Ruby header files)
Bram Moolenaar81398892012-10-03 21:09:35 +02001949 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 +00001950 if test "X$rubyhdrdir" != "X"; then
1951 AC_MSG_RESULT($rubyhdrdir)
1952 RUBY_CFLAGS="-I$rubyhdrdir"
Bram Moolenaara6fd37b2014-03-27 17:19:09 +01001953 rubyarchdir=`$vi_cv_path_ruby -r rbconfig -e "print ($ruby_rbconfig::CONFIG.has_key? 'rubyarchhdrdir') ? $ruby_rbconfig::CONFIG[['rubyarchhdrdir']] : '$rubyhdrdir/'+$ruby_rbconfig::CONFIG[['arch']]"`
1954 if test -d "$rubyarchdir"; then
1955 RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyarchdir"
Bram Moolenaar165641d2010-02-17 16:23:09 +01001956 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001957 rubyversion=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['ruby_version']].gsub(/\./, '')[[0,2]]"`
Bram Moolenaar026a4452013-08-07 15:22:23 +02001958 if test "X$rubyversion" = "X"; then
1959 rubyversion=`$vi_cv_path_ruby -e "print ((VERSION rescue RUBY_VERSION)).gsub(/\./, '')[[0,2]]"`
1960 fi
Bram Moolenaar165641d2010-02-17 16:23:09 +01001961 RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
Bram Moolenaar81398892012-10-03 21:09:35 +02001962 rubylibs=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LIBS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001963 if test "X$rubylibs" != "X"; then
1964 RUBY_LIBS="$rubylibs"
1965 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001966 librubyarg=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBYARG']])"`
1967 librubya=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBY_A']])"`
Bram Moolenaarac499e32013-06-02 19:14:17 +02001968 rubylibdir=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['libdir']])"`
Bram Moolenaar948733a2011-05-05 18:10:16 +02001969 if test -f "$rubylibdir/$librubya"; then
1970 librubyarg="$librubyarg"
Bram Moolenaarac499e32013-06-02 19:14:17 +02001971 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
1972 elif test "$librubyarg" = "libruby.a"; then
1973 dnl required on Mac OS 10.3 where libruby.a doesn't exist
1974 librubyarg="-lruby"
1975 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001976 fi
1977
1978 if test "X$librubyarg" != "X"; then
1979 RUBY_LIBS="$librubyarg $RUBY_LIBS"
1980 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001981 rubyldflags=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LDFLAGS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001982 if test "X$rubyldflags" != "X"; then
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001983 dnl Ruby on Mac OS X 10.5 adds "-arch" flags but these should only
1984 dnl be included if requested by passing --with-mac-arch to
1985 dnl configure, so strip these flags first (if present)
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001986 rubyldflags=`echo "$rubyldflags" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001987 if test "X$rubyldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001988 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$rubyldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001989 LDFLAGS="$rubyldflags $LDFLAGS"
1990 fi
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001991 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001992 fi
1993 RUBY_SRC="if_ruby.c"
1994 RUBY_OBJ="objects/if_ruby.o"
1995 RUBY_PRO="if_ruby.pro"
1996 AC_DEFINE(FEAT_RUBY)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001997 if test "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar92021622017-10-12 12:33:43 +02001998 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_ALIASES']].split[[0]]"`
Bram Moolenaar87ea64c2018-08-04 15:13:34 +02001999 if test -z "$libruby_soname"; then
2000 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_SO']]"`
2001 fi
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002002 AC_DEFINE(DYNAMIC_RUBY)
Bram Moolenaar41a41412020-01-07 21:32:19 +01002003 RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby_soname\\\" $RUBY_CFLAGS"
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002004 RUBY_LIBS=
2005 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002006 else
Bram Moolenaar165641d2010-02-17 16:23:09 +01002007 AC_MSG_RESULT(not found; disabling Ruby)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002008 fi
2009 else
2010 AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
2011 fi
2012 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01002013
2014 if test "$fail_if_missing" = "yes" -a -z "$RUBY_OBJ"; then
2015 AC_MSG_ERROR([could not configure Ruby])
2016 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002017fi
2018AC_SUBST(RUBY_SRC)
2019AC_SUBST(RUBY_OBJ)
2020AC_SUBST(RUBY_PRO)
2021AC_SUBST(RUBY_CFLAGS)
2022AC_SUBST(RUBY_LIBS)
2023
2024AC_MSG_CHECKING(--enable-cscope argument)
2025AC_ARG_ENABLE(cscope,
2026 [ --enable-cscope Include cscope interface.], ,
2027 [enable_cscope="no"])
2028AC_MSG_RESULT($enable_cscope)
2029if test "$enable_cscope" = "yes"; then
2030 AC_DEFINE(FEAT_CSCOPE)
2031fi
2032
Bram Moolenaar071d4272004-06-13 20:20:40 +00002033AC_MSG_CHECKING(--disable-netbeans argument)
2034AC_ARG_ENABLE(netbeans,
2035 [ --disable-netbeans Disable NetBeans integration support.],
2036 , [enable_netbeans="yes"])
2037if test "$enable_netbeans" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002038 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2039 AC_MSG_RESULT([cannot use NetBeans with tiny or small features])
2040 enable_netbeans="no"
2041 else
2042 AC_MSG_RESULT(no)
2043 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002044else
2045 AC_MSG_RESULT(yes)
2046fi
2047
2048AC_MSG_CHECKING(--disable-channel argument)
2049AC_ARG_ENABLE(channel,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002050 [ --disable-channel Disable process communication support.],
Bram Moolenaare0874f82016-01-24 20:36:41 +01002051 , [enable_channel="yes"])
2052if test "$enable_channel" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002053 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2054 AC_MSG_RESULT([cannot use channels with tiny or small features])
2055 enable_channel="no"
2056 else
2057 AC_MSG_RESULT(no)
2058 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002059else
2060 if test "$enable_netbeans" = "yes"; then
Bram Moolenaar16435482016-01-24 21:31:54 +01002061 AC_MSG_RESULT([yes, netbeans also disabled])
Bram Moolenaare0874f82016-01-24 20:36:41 +01002062 enable_netbeans="no"
2063 else
2064 AC_MSG_RESULT(yes)
2065 fi
2066fi
2067
Bram Moolenaar16435482016-01-24 21:31:54 +01002068if test "$enable_channel" = "yes"; then
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002069 dnl On Solaris we need the socket library, or on Haiku the network library.
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002070 if test "x$HAIKU" = "xyes"; then
2071 AC_CHECK_LIB(network, socket)
2072 else
2073 AC_CHECK_LIB(socket, socket)
2074 fi
2075
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002076 AC_CACHE_CHECK([whether compiling with IPv6 networking is possible], [vim_cv_ipv6_networking],
2077 [AC_TRY_LINK([
2078#include <stdio.h>
2079#include <stdlib.h>
2080#include <stdarg.h>
2081#include <fcntl.h>
2082#include <netdb.h>
2083#include <netinet/in.h>
2084#include <errno.h>
2085#include <sys/types.h>
2086#include <sys/socket.h>
2087 /* Check bitfields */
2088 struct nbbuf {
2089 unsigned int initDone:1;
2090 unsigned short signmaplen;
2091 };
2092 ], [
2093 /* Check creating a socket. */
2094 struct sockaddr_in server;
2095 struct addrinfo *res;
2096 (void)socket(AF_INET, SOCK_STREAM, 0);
2097 (void)htons(100);
2098 (void)getaddrinfo("microsoft.com", NULL, NULL, &res);
2099 if (errno == ECONNREFUSED)
2100 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
2101 (void)freeaddrinfo(res);
2102 ],
2103 [vim_cv_ipv6_networking="yes"],
2104 [vim_cv_ipv6_networking="no"])])
2105
2106 if test "x$vim_cv_ipv6_networking" = "xyes"; then
2107 AC_DEFINE(FEAT_IPV6)
Bram Moolenaarb6fb0512020-04-18 18:24:18 +02002108 AC_CHECK_FUNCS(inet_ntop)
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002109 else
2110 dnl On Solaris we need the nsl library.
2111 AC_CHECK_LIB(nsl, gethostbyname)
2112 AC_CACHE_CHECK([whether compiling with IPv4 networking is possible], [vim_cv_ipv4_networking],
2113 [AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00002114#include <stdio.h>
2115#include <stdlib.h>
2116#include <stdarg.h>
2117#include <fcntl.h>
2118#include <netdb.h>
2119#include <netinet/in.h>
2120#include <errno.h>
2121#include <sys/types.h>
2122#include <sys/socket.h>
2123 /* Check bitfields */
2124 struct nbbuf {
2125 unsigned int initDone:1;
Bram Moolenaar63de19e2016-12-09 20:11:26 +01002126 unsigned short signmaplen;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002127 };
2128 ], [
2129 /* Check creating a socket. */
2130 struct sockaddr_in server;
2131 (void)socket(AF_INET, SOCK_STREAM, 0);
2132 (void)htons(100);
2133 (void)gethostbyname("microsoft.com");
2134 if (errno == ECONNREFUSED)
2135 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
2136 ],
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002137 [vim_cv_ipv4_networking="yes"],
2138 [vim_cv_ipv4_networking="no"; enable_netbeans="no"; enable_channel="no"])])
2139 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002140fi
2141if test "$enable_netbeans" = "yes"; then
2142 AC_DEFINE(FEAT_NETBEANS_INTG)
2143 NETBEANS_SRC="netbeans.c"
2144 AC_SUBST(NETBEANS_SRC)
2145 NETBEANS_OBJ="objects/netbeans.o"
2146 AC_SUBST(NETBEANS_OBJ)
2147fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002148if test "$enable_channel" = "yes"; then
Bram Moolenaar509ce2a2016-03-11 22:52:15 +01002149 AC_DEFINE(FEAT_JOB_CHANNEL)
Bram Moolenaare0874f82016-01-24 20:36:41 +01002150 CHANNEL_SRC="channel.c"
2151 AC_SUBST(CHANNEL_SRC)
2152 CHANNEL_OBJ="objects/channel.o"
2153 AC_SUBST(CHANNEL_OBJ)
2154fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002155
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002156AC_MSG_CHECKING(--enable-terminal argument)
2157AC_ARG_ENABLE(terminal,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002158 [ --enable-terminal Enable terminal emulation support.],
Bram Moolenaaref839562017-10-28 20:28:23 +02002159 , [enable_terminal="auto"])
Bram Moolenaar595a4022017-09-03 19:15:57 +02002160if test "$enable_terminal" = "yes" || test "$enable_terminal" = "auto" -a "x$features" = "xhuge" ; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002161 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2162 AC_MSG_RESULT([cannot use terminal emulator with tiny or small features])
2163 enable_terminal="no"
2164 else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002165 if test "$enable_terminal" = "auto"; then
2166 enable_terminal="yes"
2167 AC_MSG_RESULT(defaulting to yes)
2168 else
2169 AC_MSG_RESULT(yes)
2170 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002171 fi
2172else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002173 if test "$enable_terminal" = "auto"; then
2174 enable_terminal="no"
2175 AC_MSG_RESULT(defaulting to no)
2176 else
2177 AC_MSG_RESULT(no)
2178 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002179fi
Bram Moolenaar8b423282017-12-16 14:37:06 +01002180if test "$enable_terminal" = "yes" -a "$enable_channel" = "yes"; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002181 AC_DEFINE(FEAT_TERMINAL)
Bram Moolenaar93268052019-10-10 13:22:54 +02002182 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 +02002183 AC_SUBST(TERM_SRC)
Bram Moolenaar93268052019-10-10 13:22:54 +02002184 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 +02002185 AC_SUBST(TERM_OBJ)
Bram Moolenaar823edd12019-10-23 22:35:36 +02002186 TERM_TEST="test_libvterm"
2187 AC_SUBST(TERM_TEST)
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002188fi
2189
Bram Moolenaare42a6d22017-11-12 19:21:51 +01002190AC_MSG_CHECKING(--enable-autoservername argument)
2191AC_ARG_ENABLE(autoservername,
2192 [ --enable-autoservername Automatically define servername at vim startup.], ,
2193 [enable_autoservername="no"])
2194AC_MSG_RESULT($enable_autoservername)
2195if test "$enable_autoservername" = "yes"; then
2196 AC_DEFINE(FEAT_AUTOSERVERNAME)
2197fi
2198
Bram Moolenaar071d4272004-06-13 20:20:40 +00002199AC_MSG_CHECKING(--enable-multibyte argument)
2200AC_ARG_ENABLE(multibyte,
2201 [ --enable-multibyte Include multibyte editing support.], ,
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01002202 [enable_multibyte="yes"])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002203AC_MSG_RESULT($enable_multibyte)
Bram Moolenaar30276f22019-01-24 17:59:39 +01002204if test "$enable_multibyte" != "yes"; then
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01002205 AC_MSG_ERROR([The multi-byte feature can no longer be disabled. If you have
2206 a problem with this, discuss on the Vim mailing list.])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002207fi
2208
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002209dnl Right-to-Left language support for Vim will be included with big features,
2210dnl unless ENABLE_RIGHTLEFT is undefined.
2211AC_MSG_CHECKING(--disable-rightleft argument)
2212AC_ARG_ENABLE(rightleft,
2213 [ --disable-rightleft Do not include Right-to-Left language support.],
2214 , [enable_rightleft="yes"])
2215if test "$enable_rightleft" = "yes"; then
2216 AC_MSG_RESULT(no)
2217else
2218 AC_MSG_RESULT(yes)
2219 AC_DEFINE(DISABLE_RIGHTLEFT)
2220fi
2221
2222dnl Arabic language support for Vim will be included with big features,
2223dnl unless ENABLE_ARABIC is undefined.
2224AC_MSG_CHECKING(--disable-arabic argument)
2225AC_ARG_ENABLE(arabic,
2226 [ --disable-arabic Do not include Arabic language support.],
2227 , [enable_arabic="yes"])
2228if test "$enable_arabic" = "yes"; then
2229 AC_MSG_RESULT(no)
2230else
2231 AC_MSG_RESULT(yes)
2232 AC_DEFINE(DISABLE_ARABIC)
2233fi
2234
Bram Moolenaar14184a32019-02-16 15:10:30 +01002235dnl Farsi language support has been removed, ignore --disable-farsi
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002236AC_ARG_ENABLE(farsi,
Bram Moolenaar14184a32019-02-16 15:10:30 +01002237 [ --disable-farsi Deprecated.],,)
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002238
Bram Moolenaar071d4272004-06-13 20:20:40 +00002239AC_MSG_CHECKING(--enable-xim argument)
2240AC_ARG_ENABLE(xim,
2241 [ --enable-xim Include XIM input support.],
2242 AC_MSG_RESULT($enable_xim),
2243 [enable_xim="auto"; AC_MSG_RESULT(defaulting to auto)])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002244
2245AC_MSG_CHECKING(--enable-fontset argument)
2246AC_ARG_ENABLE(fontset,
2247 [ --enable-fontset Include X fontset output support.], ,
2248 [enable_fontset="no"])
2249AC_MSG_RESULT($enable_fontset)
2250dnl defining FEAT_XFONTSET is delayed, so that it can be disabled for no GUI
2251
2252test -z "$with_x" && with_x=yes
Bram Moolenaard0573012017-10-28 21:11:06 +02002253test "${enable_gui-yes}" != no -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && with_x=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002254if test "$with_x" = no; then
2255 AC_MSG_RESULT(defaulting to: don't HAVE_X11)
2256else
2257 dnl Do this check early, so that its failure can override user requests.
2258
2259 AC_PATH_PROG(xmkmfpath, xmkmf)
2260
2261 AC_PATH_XTRA
2262
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002263 dnl On z/OS Unix the X libraries are DLLs. To use them the code must
Bram Moolenaar071d4272004-06-13 20:20:40 +00002264 dnl be compiled with a special option.
2265 dnl Also add SM, ICE and Xmu to X_EXTRA_LIBS.
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002266 if test "$zOSUnix" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002267 CFLAGS="$CFLAGS -W c,dll"
2268 LDFLAGS="$LDFLAGS -W l,dll"
2269 X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE -lXmu"
2270 fi
2271
2272 dnl On my HPUX system the X include dir is found, but the lib dir not.
Bram Moolenaar70778922020-02-05 20:44:24 +01002273 dnl This is a desperate try to fix this.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002274
2275 if test -d "$x_includes" && test ! -d "$x_libraries"; then
2276 x_libraries=`echo "$x_includes" | sed s/include/lib/`
2277 AC_MSG_RESULT(Corrected X libraries to $x_libraries)
2278 X_LIBS="$X_LIBS -L$x_libraries"
2279 if test "`(uname) 2>/dev/null`" = SunOS &&
2280 uname -r | grep '^5' >/dev/null; then
2281 X_LIBS="$X_LIBS -R $x_libraries"
2282 fi
2283 fi
2284
2285 if test -d "$x_libraries" && test ! -d "$x_includes"; then
2286 x_includes=`echo "$x_libraries" | sed s/lib/include/`
2287 AC_MSG_RESULT(Corrected X includes to $x_includes)
2288 X_CFLAGS="$X_CFLAGS -I$x_includes"
2289 fi
2290
2291 dnl Remove "-I/usr/include " from X_CFLAGS, should not be needed.
2292 X_CFLAGS="`echo $X_CFLAGS\ | sed 's%-I/usr/include %%'`"
2293 dnl Remove "-L/usr/lib " from X_LIBS, should not be needed.
2294 X_LIBS="`echo $X_LIBS\ | sed 's%-L/usr/lib %%'`"
2295 dnl Same for "-R/usr/lib ".
2296 X_LIBS="`echo $X_LIBS\ | sed -e 's%-R/usr/lib %%' -e 's%-R /usr/lib %%'`"
2297
2298
2299 dnl Check if the X11 header files are correctly installed. On some systems
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002300 dnl Xlib.h includes files that don't exist. On some systems X11/Intrinsic.h
2301 dnl is missing.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002302 AC_MSG_CHECKING(if X11 header files can be found)
2303 cflags_save=$CFLAGS
2304 CFLAGS="$CFLAGS $X_CFLAGS"
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002305 AC_TRY_COMPILE([#include <X11/Xlib.h>
2306#include <X11/Intrinsic.h>], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002307 AC_MSG_RESULT(yes),
2308 AC_MSG_RESULT(no); no_x=yes)
2309 CFLAGS=$cflags_save
2310
2311 if test "${no_x-no}" = yes; then
2312 with_x=no
2313 else
2314 AC_DEFINE(HAVE_X11)
2315 X_LIB="-lXt -lX11";
2316 AC_SUBST(X_LIB)
2317
2318 ac_save_LDFLAGS="$LDFLAGS"
2319 LDFLAGS="-L$x_libraries $LDFLAGS"
2320
2321 dnl Check for -lXdmcp (needed on SunOS 4.1.4)
2322 dnl For HP-UX 10.20 it must be before -lSM -lICE
2323 AC_CHECK_LIB(Xdmcp, _XdmcpAuthDoIt, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lXdmcp"],,
2324 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXdmcp])
2325
2326 dnl Some systems need -lnsl -lsocket when testing for ICE.
2327 dnl The check above doesn't do this, try here (again). Also needed to get
2328 dnl them after Xdmcp. link.sh will remove them when not needed.
2329 dnl Check for other function than above to avoid the cached value
2330 AC_CHECK_LIB(ICE, IceOpenConnection,
2331 [X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE"],, [$X_EXTRA_LIBS])
2332
2333 dnl Check for -lXpm (needed for some versions of Motif)
2334 LDFLAGS="$X_LIBS $ac_save_LDFLAGS"
2335 AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [X_PRE_LIBS="$X_PRE_LIBS -lXpm"],,
2336 [-lXt $X_PRE_LIBS -lXpm -lX11 $X_EXTRA_LIBS])
2337
2338 dnl Check that the X11 header files don't use implicit declarations
2339 AC_MSG_CHECKING(if X11 header files implicitly declare return values)
2340 cflags_save=$CFLAGS
Bram Moolenaard1864592013-05-04 04:40:15 +02002341 dnl -Werror is GCC only, others like Solaris Studio might not like it
2342 if test "$GCC" = yes; then
2343 CFLAGS="$CFLAGS $X_CFLAGS -Werror"
2344 else
2345 CFLAGS="$CFLAGS $X_CFLAGS"
2346 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002347 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2348 AC_MSG_RESULT(no),
2349 CFLAGS="$CFLAGS -Wno-implicit-int"
2350 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2351 AC_MSG_RESULT(yes); cflags_save="$cflags_save -Wno-implicit-int",
2352 AC_MSG_RESULT(test failed)
2353 )
2354 )
2355 CFLAGS=$cflags_save
2356
2357 LDFLAGS="$ac_save_LDFLAGS"
2358
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002359 AC_MSG_CHECKING(size of wchar_t is 2 bytes)
2360 AC_CACHE_VAL(ac_cv_small_wchar_t,
2361 [AC_TRY_RUN([
2362#include <X11/Xlib.h>
2363#if STDC_HEADERS
2364# include <stdlib.h>
2365# include <stddef.h>
2366#endif
2367 main()
2368 {
2369 if (sizeof(wchar_t) <= 2)
2370 exit(1);
2371 exit(0);
2372 }],
2373 ac_cv_small_wchar_t="no",
2374 ac_cv_small_wchar_t="yes",
2375 AC_MSG_ERROR(failed to compile test program))])
2376 AC_MSG_RESULT($ac_cv_small_wchar_t)
2377 if test "x$ac_cv_small_wchar_t" = "xyes" ; then
2378 AC_DEFINE(SMALL_WCHAR_T)
2379 fi
2380
Bram Moolenaar071d4272004-06-13 20:20:40 +00002381 fi
2382fi
2383
Bram Moolenaard2a05492018-07-27 22:35:15 +02002384dnl Check if --with-x was given but it doesn't work.
2385if test "x$with_x" = xno -a "x$with_x_arg" = xyes; then
2386 AC_MSG_ERROR([could not configure X])
2387fi
2388
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002389test "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 +00002390
2391AC_MSG_CHECKING(--enable-gui argument)
2392AC_ARG_ENABLE(gui,
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002393 [ --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 +00002394
2395dnl Canonicalize the --enable-gui= argument so that it can be easily compared.
2396dnl Do not use character classes for portability with old tools.
2397enable_gui_canon=`echo "_$enable_gui" | \
2398 sed 's/[[ _+-]]//g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
2399
2400dnl Skip everything by default.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002401SKIP_GTK2=YES
Bram Moolenaar1858a842016-02-23 22:30:31 +01002402SKIP_GTK3=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002403SKIP_GNOME=YES
2404SKIP_MOTIF=YES
2405SKIP_ATHENA=YES
2406SKIP_NEXTAW=YES
2407SKIP_PHOTON=YES
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002408SKIP_HAIKU=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002409SKIP_CARBON=YES
2410GUITYPE=NONE
2411
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002412if test "x$HAIKU" = "xyes"; then
2413 SKIP_HAIKU=
2414 case "$enable_gui_canon" in
2415 no) AC_MSG_RESULT(no GUI support)
2416 SKIP_HAIKU=YES ;;
2417 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
2418 auto) AC_MSG_RESULT(auto - automatic GUI support) ;;
2419 haiku) AC_MSG_RESULT(Haiku GUI support) ;;
2420 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2421 SKIP_HAIKU=YES ;;
2422 esac
2423elif test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002424 SKIP_PHOTON=
2425 case "$enable_gui_canon" in
2426 no) AC_MSG_RESULT(no GUI support)
2427 SKIP_PHOTON=YES ;;
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002428 yes|""|auto) AC_MSG_RESULT(automatic GUI support)
2429 gui_auto=yes ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002430 photon) AC_MSG_RESULT(Photon GUI support) ;;
2431 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2432 SKIP_PHOTON=YES ;;
2433 esac
2434
Bram Moolenaard0573012017-10-28 21:11:06 +02002435elif test "x$MACOS_X" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002436 SKIP_CARBON=
2437 case "$enable_gui_canon" in
2438 no) AC_MSG_RESULT(no GUI support)
2439 SKIP_CARBON=YES ;;
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002440 yes|"") AC_MSG_RESULT(yes - automatic GUI support)
2441 gui_auto=yes ;;
Bram Moolenaar164fca32010-07-14 13:58:07 +02002442 auto) AC_MSG_RESULT(auto - Carbon GUI is outdated - disable GUI support)
2443 SKIP_CARBON=YES ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002444 carbon) AC_MSG_RESULT(Carbon GUI support) ;;
2445 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2446 SKIP_CARBON=YES ;;
2447 esac
2448
2449else
2450
Bram Moolenaar071d4272004-06-13 20:20:40 +00002451 case "$enable_gui_canon" in
2452 no|none) AC_MSG_RESULT(no GUI support) ;;
2453 yes|""|auto) AC_MSG_RESULT(yes/auto - automatic GUI support)
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002454 gui_auto=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002455 SKIP_GTK2=
2456 SKIP_GNOME=
2457 SKIP_MOTIF=
2458 SKIP_ATHENA=
2459 SKIP_NEXTAW=
2460 SKIP_CARBON=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002461 gtk2) AC_MSG_RESULT(GTK+ 2.x GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002462 SKIP_GTK2=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002463 gnome2) AC_MSG_RESULT(GNOME 2.x GUI support)
2464 SKIP_GNOME=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002465 SKIP_GTK2=;;
Bram Moolenaar98921892016-02-23 17:14:37 +01002466 gtk3) AC_MSG_RESULT(GTK+ 3.x GUI support)
2467 SKIP_GTK3=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002468 motif) AC_MSG_RESULT(Motif GUI support)
2469 SKIP_MOTIF=;;
2470 athena) AC_MSG_RESULT(Athena GUI support)
2471 SKIP_ATHENA=;;
2472 nextaw) AC_MSG_RESULT(neXtaw GUI support)
2473 SKIP_NEXTAW=;;
2474 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
2475 esac
2476
2477fi
2478
Bram Moolenaar071d4272004-06-13 20:20:40 +00002479if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \
2480 -a "$enable_gui_canon" != "gnome2"; then
2481 AC_MSG_CHECKING(whether or not to look for GTK+ 2)
2482 AC_ARG_ENABLE(gtk2-check,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002483 [ --enable-gtk2-check If auto-select GUI, check for GTK+ 2 [default=yes]],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002484 , enable_gtk2_check="yes")
2485 AC_MSG_RESULT($enable_gtk2_check)
2486 if test "x$enable_gtk2_check" = "xno"; then
2487 SKIP_GTK2=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002488 SKIP_GNOME=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002489 fi
2490fi
2491
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002492if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002493 AC_MSG_CHECKING(whether or not to look for GNOME)
2494 AC_ARG_ENABLE(gnome-check,
2495 [ --enable-gnome-check If GTK GUI, check for GNOME [default=no]],
2496 , enable_gnome_check="no")
2497 AC_MSG_RESULT($enable_gnome_check)
2498 if test "x$enable_gnome_check" = "xno"; then
2499 SKIP_GNOME=YES
2500 fi
2501fi
2502
Bram Moolenaar98921892016-02-23 17:14:37 +01002503if test "x$SKIP_GTK3" != "xYES" -a "$enable_gui_canon" != "gtk3"; then
2504 AC_MSG_CHECKING(whether or not to look for GTK+ 3)
2505 AC_ARG_ENABLE(gtk3-check,
2506 [ --enable-gtk3-check If auto-select GUI, check for GTK+ 3 [default=yes]],
2507 , enable_gtk3_check="yes")
2508 AC_MSG_RESULT($enable_gtk3_check)
2509 if test "x$enable_gtk3_check" = "xno"; then
2510 SKIP_GTK3=YES
2511 fi
2512fi
2513
Bram Moolenaar071d4272004-06-13 20:20:40 +00002514if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then
2515 AC_MSG_CHECKING(whether or not to look for Motif)
2516 AC_ARG_ENABLE(motif-check,
2517 [ --enable-motif-check If auto-select GUI, check for Motif [default=yes]],
2518 , enable_motif_check="yes")
2519 AC_MSG_RESULT($enable_motif_check)
2520 if test "x$enable_motif_check" = "xno"; then
2521 SKIP_MOTIF=YES
2522 fi
2523fi
2524
2525if test "x$SKIP_ATHENA" != "xYES" -a "$enable_gui_canon" != "athena"; then
2526 AC_MSG_CHECKING(whether or not to look for Athena)
2527 AC_ARG_ENABLE(athena-check,
2528 [ --enable-athena-check If auto-select GUI, check for Athena [default=yes]],
2529 , enable_athena_check="yes")
2530 AC_MSG_RESULT($enable_athena_check)
2531 if test "x$enable_athena_check" = "xno"; then
2532 SKIP_ATHENA=YES
2533 fi
2534fi
2535
2536if test "x$SKIP_NEXTAW" != "xYES" -a "$enable_gui_canon" != "nextaw"; then
2537 AC_MSG_CHECKING(whether or not to look for neXtaw)
2538 AC_ARG_ENABLE(nextaw-check,
2539 [ --enable-nextaw-check If auto-select GUI, check for neXtaw [default=yes]],
2540 , enable_nextaw_check="yes")
2541 AC_MSG_RESULT($enable_nextaw_check);
2542 if test "x$enable_nextaw_check" = "xno"; then
2543 SKIP_NEXTAW=YES
2544 fi
2545fi
2546
2547if test "x$SKIP_CARBON" != "xYES" -a "$enable_gui_canon" != "carbon"; then
2548 AC_MSG_CHECKING(whether or not to look for Carbon)
2549 AC_ARG_ENABLE(carbon-check,
2550 [ --enable-carbon-check If auto-select GUI, check for Carbon [default=yes]],
2551 , enable_carbon_check="yes")
2552 AC_MSG_RESULT($enable_carbon_check);
2553 if test "x$enable_carbon_check" = "xno"; then
2554 SKIP_CARBON=YES
2555 fi
2556fi
2557
Bram Moolenaar843ee412004-06-30 16:16:41 +00002558
Bram Moolenaard0573012017-10-28 21:11:06 +02002559if test "x$MACOS_X" = "xyes" -a -z "$SKIP_CARBON" -a "x$CARBON" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002560 AC_MSG_CHECKING(for Carbon GUI)
Bram Moolenaar14716812006-05-04 21:54:08 +00002561 dnl already did the check, just give the message
Bram Moolenaar071d4272004-06-13 20:20:40 +00002562 AC_MSG_RESULT(yes);
2563 GUITYPE=CARBONGUI
Bram Moolenaare344bea2005-09-01 20:46:49 +00002564 if test "$VIMNAME" = "vim"; then
2565 VIMNAME=Vim
2566 fi
Bram Moolenaar14716812006-05-04 21:54:08 +00002567
Bram Moolenaar164fca32010-07-14 13:58:07 +02002568 if test "x$MACARCH" = "xboth"; then
2569 CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk/Developer/Headers/FlatCarbon"
2570 else
2571 CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/Headers/FlatCarbon"
2572 fi
2573
Bram Moolenaar14716812006-05-04 21:54:08 +00002574 dnl Default install directory is not /usr/local
2575 if test x$prefix = xNONE; then
2576 prefix=/Applications
2577 fi
2578
2579 dnl Sorry for the hard coded default
2580 datadir='${prefix}/Vim.app/Contents/Resources'
2581
Bram Moolenaar071d4272004-06-13 20:20:40 +00002582 dnl skip everything else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002583 SKIP_GTK2=YES;
2584 SKIP_GNOME=YES;
2585 SKIP_MOTIF=YES;
2586 SKIP_ATHENA=YES;
2587 SKIP_NEXTAW=YES;
2588 SKIP_PHOTON=YES;
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002589 SKIP_HAIKU=YES;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002590 SKIP_CARBON=YES
2591fi
2592
Bram Moolenaar071d4272004-06-13 20:20:40 +00002593dnl define an autoconf function to check for a specified version of GTK, and
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002594dnl try to compile/link a GTK program.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002595dnl
2596dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002597dnl Test for GTK, and define GTK_CFLAGS, GTK_LIBDIR and GTK_LIBS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002598dnl
2599AC_DEFUN(AM_PATH_GTK,
2600[
2601 if test "X$GTK_CONFIG" != "Xno" -o "X$PKG_CONFIG" != "Xno"; then
2602 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00002603 no_gtk=""
2604 if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2605 && $PKG_CONFIG --exists gtk+-2.0; then
2606 {
Bram Moolenaar98921892016-02-23 17:14:37 +01002607 min_gtk_version=ifelse([$1], ,2.2.0,$1)
2608 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002609 dnl We should be using PKG_CHECK_MODULES() instead of this hack.
2610 dnl But I guess the dependency on pkgconfig.m4 is not wanted or
2611 dnl something like that.
2612 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0`
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002613 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-2.0`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002614 GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0`
2615 gtk_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2616 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2617 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2618 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2619 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2620 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2621 }
Bram Moolenaar98921892016-02-23 17:14:37 +01002622 elif (test "X$SKIP_GTK3" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2623 && $PKG_CONFIG --exists gtk+-3.0; then
2624 {
2625 min_gtk_version=ifelse([$1], ,3.0.0,$1)
2626 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
2627
2628 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-3.0`
2629 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-3.0`
2630 GTK_LIBS=`$PKG_CONFIG --libs gtk+-3.0`
2631 gtk_major_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2632 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2633 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2634 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2635 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2636 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2637 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002638 else
2639 no_gtk=yes
2640 fi
2641
2642 if test "x$enable_gtktest" = "xyes" -a "x$no_gtk" = "x"; then
2643 {
2644 ac_save_CFLAGS="$CFLAGS"
2645 ac_save_LIBS="$LIBS"
2646 CFLAGS="$CFLAGS $GTK_CFLAGS"
2647 LIBS="$LIBS $GTK_LIBS"
2648
2649 dnl
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002650 dnl Now check if the installed GTK is sufficiently new.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002651 dnl
2652 rm -f conf.gtktest
2653 AC_TRY_RUN([
2654#include <gtk/gtk.h>
2655#include <stdio.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00002656#if STDC_HEADERS
2657# include <stdlib.h>
2658# include <stddef.h>
2659#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002660
2661int
2662main ()
2663{
2664int major, minor, micro;
2665char *tmp_version;
2666
2667system ("touch conf.gtktest");
2668
2669/* HP/UX 9 (%@#!) writes to sscanf strings */
2670tmp_version = g_strdup("$min_gtk_version");
2671if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
2672 printf("%s, bad version string\n", "$min_gtk_version");
2673 exit(1);
2674 }
2675
2676if ((gtk_major_version > major) ||
2677 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
2678 ((gtk_major_version == major) && (gtk_minor_version == minor) &&
2679 (gtk_micro_version >= micro)))
2680{
2681 return 0;
2682}
2683return 1;
2684}
2685],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
2686 CFLAGS="$ac_save_CFLAGS"
2687 LIBS="$ac_save_LIBS"
2688 }
2689 fi
2690 if test "x$no_gtk" = x ; then
2691 if test "x$enable_gtktest" = "xyes"; then
2692 AC_MSG_RESULT(yes; found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2693 else
2694 AC_MSG_RESULT(found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2695 fi
2696 ifelse([$2], , :, [$2])
2697 else
2698 {
2699 AC_MSG_RESULT(no)
2700 GTK_CFLAGS=""
2701 GTK_LIBS=""
2702 ifelse([$3], , :, [$3])
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002703 if test "$fail_if_missing" = "yes" -a "X$gui_auto" != "Xyes"; then
2704 AC_MSG_ERROR([could not configure GTK])
2705 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002706 }
2707 fi
2708 }
2709 else
2710 GTK_CFLAGS=""
2711 GTK_LIBS=""
2712 ifelse([$3], , :, [$3])
2713 fi
2714 AC_SUBST(GTK_CFLAGS)
2715 AC_SUBST(GTK_LIBS)
2716 rm -f conf.gtktest
2717])
2718
2719dnl ---------------------------------------------------------------------------
2720dnl gnome
2721dnl ---------------------------------------------------------------------------
2722AC_DEFUN([GNOME_INIT_HOOK],
2723[
2724 AC_SUBST(GNOME_LIBS)
2725 AC_SUBST(GNOME_LIBDIR)
2726 AC_SUBST(GNOME_INCLUDEDIR)
2727
2728 AC_ARG_WITH(gnome-includes,
2729 [ --with-gnome-includes=DIR Specify location of GNOME headers],
2730 [CFLAGS="$CFLAGS -I$withval"]
2731 )
2732
2733 AC_ARG_WITH(gnome-libs,
2734 [ --with-gnome-libs=DIR Specify location of GNOME libs],
2735 [LDFLAGS="$LDFLAGS -L$withval" gnome_prefix=$withval]
2736 )
2737
2738 AC_ARG_WITH(gnome,
2739 [ --with-gnome Specify prefix for GNOME files],
2740 if test x$withval = xyes; then
2741 want_gnome=yes
2742 ifelse([$1], [], :, [$1])
2743 else
2744 if test "x$withval" = xno; then
2745 want_gnome=no
2746 else
2747 want_gnome=yes
2748 LDFLAGS="$LDFLAGS -L$withval/lib"
2749 CFLAGS="$CFLAGS -I$withval/include"
2750 gnome_prefix=$withval/lib
2751 fi
2752 fi,
2753 want_gnome=yes)
2754
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002755 if test "x$want_gnome" = xyes; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002756 {
2757 AC_MSG_CHECKING(for libgnomeui-2.0)
2758 if $PKG_CONFIG --exists libgnomeui-2.0; then
2759 AC_MSG_RESULT(yes)
2760 GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0`
2761 GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0`
2762 GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0`
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002763
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002764 dnl On FreeBSD we need -pthread but pkg-config doesn't include it.
2765 dnl This might not be the right way but it works for me...
2766 AC_MSG_CHECKING(for FreeBSD)
2767 if test "`(uname) 2>/dev/null`" = FreeBSD; then
2768 AC_MSG_RESULT(yes, adding -pthread)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002769 GNOME_INCLUDEDIR="$GNOME_INCLUDEDIR -D_THREAD_SAFE"
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002770 GNOME_LIBS="$GNOME_LIBS -pthread"
2771 else
2772 AC_MSG_RESULT(no)
2773 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002774 $1
2775 else
2776 AC_MSG_RESULT(not found)
2777 if test "x$2" = xfail; then
2778 AC_MSG_ERROR(Could not find libgnomeui-2.0 via pkg-config)
2779 fi
2780 fi
2781 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002782 fi
2783])
2784
2785AC_DEFUN([GNOME_INIT],[
2786 GNOME_INIT_HOOK([],fail)
2787])
2788
Bram Moolenaar427f5b62019-06-09 13:43:51 +02002789if test "X$PKG_CONFIG" = "X"; then
2790 AC_PATH_TOOL(PKG_CONFIG, pkg-config, no)
2791fi
2792
Bram Moolenaar071d4272004-06-13 20:20:40 +00002793
2794dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002795dnl Check for GTK2. If it fails, then continue on for Motif as before...
Bram Moolenaar071d4272004-06-13 20:20:40 +00002796dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002797if test -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002798
2799 AC_MSG_CHECKING(--disable-gtktest argument)
2800 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2801 , enable_gtktest=yes)
2802 if test "x$enable_gtktest" = "xyes" ; then
2803 AC_MSG_RESULT(gtk test enabled)
2804 else
2805 AC_MSG_RESULT(gtk test disabled)
2806 fi
2807
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002808 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002809 dnl First try finding version 2.2.0 or later. The 2.0.x series has
2810 dnl problems (bold fonts, --remote doesn't work).
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002811 AM_PATH_GTK(2.2.0,
2812 [GUI_LIB_LOC="$GTK_LIBDIR"
2813 GTK_LIBNAME="$GTK_LIBS"
2814 GUI_INC_LOC="$GTK_CFLAGS"], )
2815 if test "x$GTK_CFLAGS" != "x"; then
Bram Moolenaar98921892016-02-23 17:14:37 +01002816 SKIP_GTK3=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002817 SKIP_ATHENA=YES
2818 SKIP_NEXTAW=YES
2819 SKIP_MOTIF=YES
2820 GUITYPE=GTK
2821 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002822 fi
2823 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002824 if test "x$GUITYPE" = "xGTK"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002825 dnl
2826 dnl if GTK exists, then check for GNOME.
2827 dnl
2828 if test -z "$SKIP_GNOME"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002829 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002830 GNOME_INIT_HOOK([have_gnome=yes])
2831 if test "x$have_gnome" = xyes ; then
2832 AC_DEFINE(FEAT_GUI_GNOME)
2833 GUI_INC_LOC="$GUI_INC_LOC $GNOME_INCLUDEDIR"
2834 GTK_LIBNAME="$GTK_LIBNAME $GNOME_LIBDIR $GNOME_LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002835 fi
2836 }
2837 fi
2838 fi
2839fi
2840
Bram Moolenaar98921892016-02-23 17:14:37 +01002841
2842dnl ---------------------------------------------------------------------------
2843dnl Check for GTK3.
2844dnl ---------------------------------------------------------------------------
2845if test -z "$SKIP_GTK3"; then
2846
2847 AC_MSG_CHECKING(--disable-gtktest argument)
2848 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2849 , enable_gtktest=yes)
2850 if test "x$enable_gtktest" = "xyes" ; then
2851 AC_MSG_RESULT(gtk test enabled)
2852 else
2853 AC_MSG_RESULT(gtk test disabled)
2854 fi
2855
Bram Moolenaar98921892016-02-23 17:14:37 +01002856 if test "x$PKG_CONFIG" != "xno"; then
2857 AM_PATH_GTK(3.0.0,
2858 [GUI_LIB_LOC="$GTK_LIBDIR"
2859 GTK_LIBNAME="$GTK_LIBS"
2860 GUI_INC_LOC="$GTK_CFLAGS"], )
2861 if test "x$GTK_CFLAGS" != "x"; then
2862 SKIP_GTK2=YES
2863 SKIP_GNOME=YES
2864 SKIP_ATHENA=YES
2865 SKIP_NEXTAW=YES
2866 SKIP_MOTIF=YES
2867 GUITYPE=GTK
2868 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar98921892016-02-23 17:14:37 +01002869 AC_DEFINE(USE_GTK3)
2870 fi
2871 fi
2872fi
2873
Bram Moolenaard2e03f02016-01-02 22:46:36 +01002874dnl Check the version of Gdk-Pixbuf. If the version is 2.31 or later and
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002875dnl glib-compile-resources is found in PATH, use GResource.
2876if test "x$GUITYPE" = "xGTK"; then
2877 AC_MSG_CHECKING([version of Gdk-Pixbuf])
2878 gdk_pixbuf_version=`$PKG_CONFIG --modversion gdk-pixbuf-2.0`
2879 if test "x$gdk_pixbuf_version" != x ; then
2880 gdk_pixbuf_version_minor=`echo $gdk_pixbuf_version | \
2881 sed -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/'`
2882 if test "x$gdk_pixbuf_version_minor" != x -a \
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002883 $gdk_pixbuf_version_minor -ge 31 ; then
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002884 AC_MSG_RESULT([OK.])
2885 AC_PATH_PROG(GLIB_COMPILE_RESOURCES,[glib-compile-resources],no)
2886 AC_MSG_CHECKING([glib-compile-resources])
2887 if test "x$GLIB_COMPILE_RESOURCES" = xno ; then
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002888 GLIB_COMPILE_RESOURCES=""
2889 AC_MSG_RESULT([cannot be found in PATH.])
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002890 else
2891 AC_MSG_RESULT([usable.])
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002892 AC_DEFINE(USE_GRESOURCE)
2893 GRESOURCE_SRC="auto/gui_gtk_gresources.c"
2894 GRESOURCE_OBJ="objects/gui_gtk_gresources.o"
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002895 fi
2896 else
2897 AC_MSG_RESULT([not usable.])
2898 fi
2899 else
2900 AC_MSG_RESULT([cannot obtain from pkg_config.])
2901 fi
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002902
2903 AC_MSG_CHECKING([--disable-icon-cache-update argument])
2904 AC_ARG_ENABLE(icon_cache_update,
2905 [ --disable-icon-cache-update update disabled],
2906 [],
2907 [enable_icon_cache_update="yes"])
2908 if test "$enable_icon_cache_update" = "yes"; then
2909 AC_MSG_RESULT([not set])
2910 AC_PATH_PROG(GTK_UPDATE_ICON_CACHE,[gtk-update-icon-cache],no)
2911 if test "x$GTK_UPDATE_ICON_CACHE" = "xno" ; then
2912 AC_MSG_RESULT([not found in PATH.])
2913 fi
2914 else
2915 AC_MSG_RESULT([update disabled])
2916 fi
2917
2918 AC_MSG_CHECKING([--disable-desktop-database-update argument])
2919 AC_ARG_ENABLE(desktop_database_update,
2920 [ --disable-desktop-database-update update disabled],
2921 [],
2922 [enable_desktop_database_update="yes"])
2923 if test "$enable_desktop_database_update" = "yes"; then
2924 AC_MSG_RESULT([not set])
2925 AC_PATH_PROG(UPDATE_DESKTOP_DATABASE,[update-desktop-database],no)
2926 if test "x$UPDATE_DESKTOP_DATABASE" = "xno" ; then
2927 AC_MSG_RESULT([not found in PATH.])
2928 fi
2929 else
2930 AC_MSG_RESULT([update disabled])
2931 fi
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002932fi
2933AC_SUBST(GLIB_COMPILE_RESOURCES)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002934AC_SUBST(GRESOURCE_SRC)
2935AC_SUBST(GRESOURCE_OBJ)
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002936AC_SUBST(GTK_UPDATE_ICON_CACHE)
2937AC_SUBST(UPDATE_DESKTOP_DATABASE)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002938
Bram Moolenaar071d4272004-06-13 20:20:40 +00002939dnl Check for Motif include files location.
2940dnl The LAST one found is used, this makes the highest version to be used,
2941dnl e.g. when Motif1.2 and Motif2.0 are both present.
2942
2943if test -z "$SKIP_MOTIF"; then
2944 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"
2945 dnl Remove "-I" from before $GUI_INC_LOC if it's there
2946 GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`"
2947
2948 AC_MSG_CHECKING(for location of Motif GUI includes)
2949 gui_includes="`echo $x_includes|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC"
2950 GUI_INC_LOC=
2951 for try in $gui_includes; do
2952 if test -f "$try/Xm/Xm.h"; then
2953 GUI_INC_LOC=$try
2954 fi
2955 done
2956 if test -n "$GUI_INC_LOC"; then
2957 if test "$GUI_INC_LOC" = /usr/include; then
2958 GUI_INC_LOC=
2959 AC_MSG_RESULT(in default path)
2960 else
2961 AC_MSG_RESULT($GUI_INC_LOC)
2962 fi
2963 else
2964 AC_MSG_RESULT(<not found>)
2965 SKIP_MOTIF=YES
2966 fi
2967fi
2968
2969dnl Check for Motif library files location. In the same order as the include
2970dnl files, to avoid a mixup if several versions are present
2971
2972if test -z "$SKIP_MOTIF"; then
2973 AC_MSG_CHECKING(--with-motif-lib argument)
2974 AC_ARG_WITH(motif-lib,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002975 [ --with-motif-lib=STRING Library for Motif ],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002976 [ MOTIF_LIBNAME="${withval}" ] )
2977
2978 if test -n "$MOTIF_LIBNAME"; then
2979 AC_MSG_RESULT($MOTIF_LIBNAME)
2980 GUI_LIB_LOC=
2981 else
2982 AC_MSG_RESULT(no)
2983
2984 dnl Remove "-L" from before $GUI_LIB_LOC if it's there
2985 GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
2986
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002987 dnl Ubuntu has libXm.so in /usr/lib/i386-linux-gnu and elsewhere. The
2988 dnl linker will figure out which one to use, we only check if one exists.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002989 AC_MSG_CHECKING(for location of Motif GUI libs)
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002990 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 +00002991 GUI_LIB_LOC=
2992 for try in $gui_libs; do
Bram Moolenaar325b7a22004-07-05 15:58:32 +00002993 for libtry in "$try"/libXm.a "$try"/libXm.so* "$try"/libXm.sl "$try"/libXm.dylib; do
Bram Moolenaar071d4272004-06-13 20:20:40 +00002994 if test -f "$libtry"; then
2995 GUI_LIB_LOC=$try
2996 fi
2997 done
2998 done
2999 if test -n "$GUI_LIB_LOC"; then
3000 dnl Remove /usr/lib, it causes trouble on some systems
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02003001 if test "$GUI_LIB_LOC" = /usr/lib \
3002 -o "$GUI_LIB_LOC" = /usr/lib/i386-linux-gnu \
3003 -o "$GUI_LIB_LOC" = /usr/lib/x86_64-linux-gnu; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003004 GUI_LIB_LOC=
3005 AC_MSG_RESULT(in default path)
3006 else
3007 if test -n "$GUI_LIB_LOC"; then
3008 AC_MSG_RESULT($GUI_LIB_LOC)
3009 if test "`(uname) 2>/dev/null`" = SunOS &&
3010 uname -r | grep '^5' >/dev/null; then
3011 GUI_LIB_LOC="$GUI_LIB_LOC -R $GUI_LIB_LOC"
3012 fi
3013 fi
3014 fi
3015 MOTIF_LIBNAME=-lXm
3016 else
3017 AC_MSG_RESULT(<not found>)
3018 SKIP_MOTIF=YES
3019 fi
3020 fi
3021fi
3022
3023if test -z "$SKIP_MOTIF"; then
3024 SKIP_ATHENA=YES
3025 SKIP_NEXTAW=YES
3026 GUITYPE=MOTIF
3027 AC_SUBST(MOTIF_LIBNAME)
3028fi
3029
3030dnl Check if the Athena files can be found
3031
3032GUI_X_LIBS=
3033
3034if test -z "$SKIP_ATHENA"; then
3035 AC_MSG_CHECKING(if Athena header files can be found)
3036 cflags_save=$CFLAGS
3037 CFLAGS="$CFLAGS $X_CFLAGS"
3038 AC_TRY_COMPILE([
3039#include <X11/Intrinsic.h>
3040#include <X11/Xaw/Paned.h>], ,
3041 AC_MSG_RESULT(yes),
3042 AC_MSG_RESULT(no); SKIP_ATHENA=YES )
3043 CFLAGS=$cflags_save
3044fi
3045
3046if test -z "$SKIP_ATHENA"; then
3047 GUITYPE=ATHENA
3048fi
3049
3050if test -z "$SKIP_NEXTAW"; then
3051 AC_MSG_CHECKING(if neXtaw header files can be found)
3052 cflags_save=$CFLAGS
3053 CFLAGS="$CFLAGS $X_CFLAGS"
3054 AC_TRY_COMPILE([
3055#include <X11/Intrinsic.h>
3056#include <X11/neXtaw/Paned.h>], ,
3057 AC_MSG_RESULT(yes),
3058 AC_MSG_RESULT(no); SKIP_NEXTAW=YES )
3059 CFLAGS=$cflags_save
3060fi
3061
3062if test -z "$SKIP_NEXTAW"; then
3063 GUITYPE=NEXTAW
3064fi
3065
3066if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
3067 dnl Prepend -I and -L to $GUI_INC_LOC and $GUI_LIB_LOC if not empty
3068 dnl Avoid adding it when it twice
3069 if test -n "$GUI_INC_LOC"; then
3070 GUI_INC_LOC=-I"`echo $GUI_INC_LOC|sed 's%-I%%'`"
3071 fi
3072 if test -n "$GUI_LIB_LOC"; then
3073 GUI_LIB_LOC=-L"`echo $GUI_LIB_LOC|sed 's%-L%%'`"
3074 fi
3075
3076 dnl Check for -lXext and then for -lXmu
3077 ldflags_save=$LDFLAGS
3078 LDFLAGS="$X_LIBS $LDFLAGS"
3079 AC_CHECK_LIB(Xext, XShapeQueryExtension, [GUI_X_LIBS="-lXext"],,
3080 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3081 dnl For Solaris we need -lw and -ldl before linking with -lXmu works.
3082 AC_CHECK_LIB(w, wslen, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lw"],,
3083 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3084 AC_CHECK_LIB(dl, dlsym, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldl"],,
3085 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3086 AC_CHECK_LIB(Xmu, XmuCreateStippledPixmap, [GUI_X_LIBS="-lXmu $GUI_X_LIBS"],,
3087 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3088 if test -z "$SKIP_MOTIF"; then
3089 AC_CHECK_LIB(Xp, XpEndJob, [GUI_X_LIBS="-lXp $GUI_X_LIBS"],,
3090 [$GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3091 fi
3092 LDFLAGS=$ldflags_save
3093
3094 dnl Execute xmkmf to figure out if -DNARROWPROTO is needed.
3095 AC_MSG_CHECKING(for extra X11 defines)
3096 NARROW_PROTO=
3097 rm -fr conftestdir
3098 if mkdir conftestdir; then
3099 cd conftestdir
3100 cat > Imakefile <<'EOF'
3101acfindx:
3102 @echo 'NARROW_PROTO="${PROTO_DEFINES}"'
3103EOF
3104 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
3105 eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
3106 fi
3107 cd ..
3108 rm -fr conftestdir
3109 fi
3110 if test -z "$NARROW_PROTO"; then
3111 AC_MSG_RESULT(no)
3112 else
3113 AC_MSG_RESULT($NARROW_PROTO)
3114 fi
3115 AC_SUBST(NARROW_PROTO)
3116fi
3117
3118dnl Look for XSMP support - but don't necessarily restrict it to X11 GUIs
3119dnl use the X11 include path
3120if test "$enable_xsmp" = "yes"; then
3121 cppflags_save=$CPPFLAGS
3122 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3123 AC_CHECK_HEADERS(X11/SM/SMlib.h)
3124 CPPFLAGS=$cppflags_save
3125fi
3126
3127
Bram Moolenaar98921892016-02-23 17:14:37 +01003128if 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 +00003129 dnl Check for X11/xpm.h and X11/Sunkeysym.h with the GUI include path
3130 cppflags_save=$CPPFLAGS
3131 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3132 AC_CHECK_HEADERS(X11/xpm.h X11/Sunkeysym.h)
3133
3134 dnl automatically disable XIM when XIMtext isn't in X11/Xlib.h
3135 if test ! "$enable_xim" = "no"; then
3136 AC_MSG_CHECKING(for XIMText in X11/Xlib.h)
3137 AC_EGREP_CPP(XIMText, [#include <X11/Xlib.h>],
3138 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +02003139 AC_MSG_RESULT(no; xim has been disabled); enable_xim="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00003140 fi
3141 CPPFLAGS=$cppflags_save
3142
Bram Moolenaar54612582019-11-21 17:13:31 +01003143 dnl automatically enable XIM in the GUI
3144 if test "$enable_xim" = "auto" -a "x$GUITYPE" != "xNONE" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003145 AC_MSG_RESULT(X GUI selected; xim has been enabled)
3146 enable_xim="yes"
3147 fi
3148fi
3149
3150if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
3151 cppflags_save=$CPPFLAGS
3152 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00003153dnl Xmu/Editres.h may exist but can only be used after including Intrinsic.h
3154 AC_MSG_CHECKING([for X11/Xmu/Editres.h])
3155 AC_TRY_COMPILE([
3156#include <X11/Intrinsic.h>
3157#include <X11/Xmu/Editres.h>],
3158 [int i; i = 0;],
3159 AC_MSG_RESULT(yes)
3160 AC_DEFINE(HAVE_X11_XMU_EDITRES_H),
3161 AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003162 CPPFLAGS=$cppflags_save
3163fi
3164
3165dnl Only use the Xm directory when compiling Motif, don't use it for Athena
3166if test -z "$SKIP_MOTIF"; then
3167 cppflags_save=$CPPFLAGS
3168 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003169 if test "$zOSUnix" = "yes"; then
3170 xmheader="Xm/Xm.h"
3171 else
3172 xmheader="Xm/Xm.h Xm/XpmP.h Xm/JoinSideT.h Xm/TraitP.h Xm/Manager.h
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02003173 Xm/UnhighlightT.h Xm/Notebook.h"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003174 fi
3175 AC_CHECK_HEADERS($xmheader)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003176
Bram Moolenaar77c19352012-06-13 19:19:41 +02003177 if test "x$ac_cv_header_Xm_XpmP_h" = "xyes"; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003178 dnl Solaris uses XpmAttributes_21, very annoying.
3179 AC_MSG_CHECKING([for XpmAttributes_21 in Xm/XpmP.h])
3180 AC_TRY_COMPILE([#include <Xm/XpmP.h>], [XpmAttributes_21 attr;],
3181 AC_MSG_RESULT(yes); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes_21),
3182 AC_MSG_RESULT(no); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
3183 )
3184 else
Bram Moolenaar57657d82006-04-21 22:12:41 +00003185 AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003186 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003187 CPPFLAGS=$cppflags_save
3188fi
3189
3190if test "x$GUITYPE" = "xNONE" -a "$enable_xim" = "yes"; then
3191 AC_MSG_RESULT(no GUI selected; xim has been disabled)
3192 enable_xim="no"
3193fi
3194if test "x$GUITYPE" = "xNONE" -a "$enable_fontset" = "yes"; then
3195 AC_MSG_RESULT(no GUI selected; fontset has been disabled)
3196 enable_fontset="no"
3197fi
Bram Moolenaar182c5be2010-06-25 05:37:59 +02003198if test "x$GUITYPE:$enable_fontset" = "xGTK:yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003199 AC_MSG_RESULT(GTK+ 2 GUI selected; fontset has been disabled)
3200 enable_fontset="no"
3201fi
3202
Bram Moolenaarb3f74062020-02-26 16:16:53 +01003203dnl There is no test for the Haiku GUI, if it's selected it's used
3204if test -z "$SKIP_HAIKU"; then
3205 GUITYPE=HAIKUGUI
3206fi
3207
Bram Moolenaar071d4272004-06-13 20:20:40 +00003208if test -z "$SKIP_PHOTON"; then
3209 GUITYPE=PHOTONGUI
3210fi
3211
3212AC_SUBST(GUI_INC_LOC)
3213AC_SUBST(GUI_LIB_LOC)
3214AC_SUBST(GUITYPE)
3215AC_SUBST(GUI_X_LIBS)
3216
3217if test "$enable_workshop" = "yes" -a -n "$SKIP_MOTIF"; then
3218 AC_MSG_ERROR([cannot use workshop without Motif])
3219fi
3220
3221dnl defining FEAT_XIM and FEAT_XFONTSET is delayed, so that they can be disabled
3222if test "$enable_xim" = "yes"; then
3223 AC_DEFINE(FEAT_XIM)
3224fi
3225if test "$enable_fontset" = "yes"; then
3226 AC_DEFINE(FEAT_XFONTSET)
3227fi
3228
3229
3230dnl ---------------------------------------------------------------------------
3231dnl end of GUI-checking
3232dnl ---------------------------------------------------------------------------
3233
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003234AC_MSG_CHECKING([for /proc link to executable])
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003235if test -L "/proc/self/exe"; then
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003236 dnl Linux
3237 AC_MSG_RESULT([/proc/self/exe])
3238 AC_DEFINE(PROC_EXE_LINK, "/proc/self/exe")
3239elif test -L "/proc/self/path/a.out"; then
3240 dnl Solaris
3241 AC_MSG_RESULT([/proc/self/path/a.out])
3242 AC_DEFINE(PROC_EXE_LINK, "/proc/self/path/a.out")
3243elif test -L "/proc/curproc/file"; then
3244 dnl FreeBSD
3245 AC_MSG_RESULT([/proc/curproc/file])
3246 AC_DEFINE(PROC_EXE_LINK, "/proc/curproc/file")
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003247else
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003248 AC_MSG_RESULT(no)
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003249fi
3250
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003251dnl Check for Cygwin, which needs an extra source file if not using X11
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003252AC_MSG_CHECKING(for CYGWIN or MSYS environment)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003253case `uname` in
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003254 CYGWIN*|MSYS*) CYGWIN=yes; AC_MSG_RESULT(yes)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003255 AC_MSG_CHECKING(for CYGWIN clipboard support)
3256 if test "x$with_x" = "xno" ; then
3257 OS_EXTRA_SRC=winclip.c; OS_EXTRA_OBJ=objects/winclip.o
3258 AC_MSG_RESULT(yes)
3259 AC_DEFINE(FEAT_CYGWIN_WIN32_CLIPBOARD)
3260 else
3261 AC_MSG_RESULT(no - using X11)
3262 fi ;;
3263
3264 *) CYGWIN=no; AC_MSG_RESULT(no);;
3265esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00003266
Bram Moolenaar071d4272004-06-13 20:20:40 +00003267dnl Checks for libraries and include files.
3268
Bram Moolenaar446cb832008-06-24 21:56:24 +00003269AC_CACHE_CHECK([whether toupper is broken], [vim_cv_toupper_broken],
3270 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003271 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003272#include "confdefs.h"
3273#include <ctype.h>
3274#if STDC_HEADERS
3275# include <stdlib.h>
3276# include <stddef.h>
3277#endif
3278main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003279 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003280 vim_cv_toupper_broken=yes
3281 ],[
3282 vim_cv_toupper_broken=no
3283 ],[
3284 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_toupper_broken')
3285 ])])
3286
3287if test "x$vim_cv_toupper_broken" = "xyes" ; then
3288 AC_DEFINE(BROKEN_TOUPPER)
3289fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003290
3291AC_MSG_CHECKING(whether __DATE__ and __TIME__ work)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003292AC_TRY_COMPILE([#include <stdio.h>], [printf("(" __DATE__ " " __TIME__ ")");],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003293 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DATE_TIME),
3294 AC_MSG_RESULT(no))
3295
Bram Moolenaar0c094b92009-05-14 20:20:33 +00003296AC_MSG_CHECKING(whether __attribute__((unused)) is allowed)
3297AC_TRY_COMPILE([#include <stdio.h>], [int x __attribute__((unused));],
3298 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ATTRIBUTE_UNUSED),
3299 AC_MSG_RESULT(no))
3300
Bram Moolenaar071d4272004-06-13 20:20:40 +00003301dnl Checks for header files.
3302AC_CHECK_HEADER(elf.h, HAS_ELF=1)
3303dnl AC_CHECK_HEADER(dwarf.h, SVR4=1)
3304if test "$HAS_ELF" = 1; then
3305 AC_CHECK_LIB(elf, main)
3306fi
3307
3308AC_HEADER_DIRENT
3309
Bram Moolenaar071d4272004-06-13 20:20:40 +00003310dnl If sys/wait.h is not found it might still exist but not be POSIX
3311dnl compliant. In that case we define HAVE_UNION_WAIT (for NeXT)
3312if test $ac_cv_header_sys_wait_h = no; then
3313 AC_MSG_CHECKING([for sys/wait.h that defines union wait])
3314 AC_TRY_COMPILE([#include <sys/wait.h>],
3315 [union wait xx, yy; xx = yy],
3316 AC_MSG_RESULT(yes)
3317 AC_DEFINE(HAVE_SYS_WAIT_H)
3318 AC_DEFINE(HAVE_UNION_WAIT),
3319 AC_MSG_RESULT(no))
3320fi
3321
Bram Moolenaar779a7752016-01-30 23:26:34 +01003322AC_CHECK_HEADERS(stdint.h stdlib.h string.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003323 sys/select.h sys/utsname.h termcap.h fcntl.h \
3324 sgtty.h sys/ioctl.h sys/time.h sys/types.h \
3325 termio.h iconv.h inttypes.h langinfo.h math.h \
3326 unistd.h stropts.h errno.h sys/resource.h \
3327 sys/systeminfo.h locale.h sys/stream.h termios.h \
3328 libc.h sys/statfs.h poll.h sys/poll.h pwd.h \
Bram Moolenaar1ecc5e42019-01-26 15:12:55 +01003329 utime.h sys/param.h sys/ptms.h libintl.h libgen.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003330 util/debug.h util/msg18n.h frame.h sys/acl.h \
3331 sys/access.h sys/sysinfo.h wchar.h wctype.h)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003332
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003333dnl sys/ptem.h depends on sys/stream.h on Solaris
3334AC_CHECK_HEADERS(sys/ptem.h, [], [],
3335[#if defined HAVE_SYS_STREAM_H
3336# include <sys/stream.h>
3337#endif])
3338
Bram Moolenaar32f31b12009-05-21 13:20:59 +00003339dnl sys/sysctl.h depends on sys/param.h on OpenBSD
3340AC_CHECK_HEADERS(sys/sysctl.h, [], [],
3341[#if defined HAVE_SYS_PARAM_H
3342# include <sys/param.h>
3343#endif])
3344
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003345
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003346dnl pthread_np.h may exist but can only be used after including pthread.h
3347AC_MSG_CHECKING([for pthread_np.h])
3348AC_TRY_COMPILE([
3349#include <pthread.h>
3350#include <pthread_np.h>],
3351 [int i; i = 0;],
3352 AC_MSG_RESULT(yes)
3353 AC_DEFINE(HAVE_PTHREAD_NP_H),
3354 AC_MSG_RESULT(no))
3355
Bram Moolenaare344bea2005-09-01 20:46:49 +00003356AC_CHECK_HEADERS(strings.h)
Bram Moolenaard0573012017-10-28 21:11:06 +02003357if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00003358 dnl The strings.h file on OS/X contains a warning and nothing useful.
3359 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3360else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003361
3362dnl Check if strings.h and string.h can both be included when defined.
3363AC_MSG_CHECKING([if strings.h can be included after string.h])
3364cppflags_save=$CPPFLAGS
3365CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3366AC_TRY_COMPILE([
3367#if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO)
3368# define _NO_PROTO /* like in os_unix.h, causes conflict for AIX (Winn) */
3369 /* but don't do it on AIX 5.1 (Uribarri) */
3370#endif
3371#ifdef HAVE_XM_XM_H
3372# include <Xm/Xm.h> /* This breaks it for HP-UX 11 (Squassabia) */
3373#endif
3374#ifdef HAVE_STRING_H
3375# include <string.h>
3376#endif
3377#if defined(HAVE_STRINGS_H)
3378# include <strings.h>
3379#endif
3380 ], [int i; i = 0;],
3381 AC_MSG_RESULT(yes),
3382 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3383 AC_MSG_RESULT(no))
3384CPPFLAGS=$cppflags_save
Bram Moolenaar9372a112005-12-06 19:59:18 +00003385fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003386
3387dnl Checks for typedefs, structures, and compiler characteristics.
3388AC_PROG_GCC_TRADITIONAL
3389AC_C_CONST
Bram Moolenaar76243bd2009-03-02 01:47:02 +00003390AC_C_VOLATILE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003391AC_TYPE_MODE_T
3392AC_TYPE_OFF_T
3393AC_TYPE_PID_T
3394AC_TYPE_SIZE_T
3395AC_TYPE_UID_T
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003396AC_TYPE_UINT32_T
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003397
Bram Moolenaar071d4272004-06-13 20:20:40 +00003398AC_HEADER_TIME
3399AC_CHECK_TYPE(ino_t, long)
3400AC_CHECK_TYPE(dev_t, unsigned)
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003401AC_C_BIGENDIAN(,,,)
Bram Moolenaar136f29a2016-02-27 20:14:15 +01003402AC_C_INLINE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003403
3404AC_MSG_CHECKING(for rlim_t)
3405if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
3406 AC_MSG_RESULT([(cached) $ac_cv_type_rlim_t])
3407else
3408 AC_EGREP_CPP(dnl
3409changequote(<<,>>)dnl
3410<<(^|[^a-zA-Z_0-9])rlim_t[^a-zA-Z_0-9]>>dnl
3411changequote([,]),
3412 [
3413#include <sys/types.h>
3414#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003415# include <stdlib.h>
3416# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003417#endif
3418#ifdef HAVE_SYS_RESOURCE_H
Bram Moolenaar446cb832008-06-24 21:56:24 +00003419# include <sys/resource.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003420#endif
3421 ], ac_cv_type_rlim_t=yes, ac_cv_type_rlim_t=no)
3422 AC_MSG_RESULT($ac_cv_type_rlim_t)
3423fi
3424if test $ac_cv_type_rlim_t = no; then
3425 cat >> confdefs.h <<\EOF
3426#define rlim_t unsigned long
3427EOF
3428fi
3429
3430AC_MSG_CHECKING(for stack_t)
3431if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then
3432 AC_MSG_RESULT([(cached) $ac_cv_type_stack_t])
3433else
3434 AC_EGREP_CPP(stack_t,
3435 [
3436#include <sys/types.h>
3437#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003438# include <stdlib.h>
3439# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003440#endif
3441#include <signal.h>
3442 ], ac_cv_type_stack_t=yes, ac_cv_type_stack_t=no)
3443 AC_MSG_RESULT($ac_cv_type_stack_t)
3444fi
3445if test $ac_cv_type_stack_t = no; then
3446 cat >> confdefs.h <<\EOF
3447#define stack_t struct sigaltstack
3448EOF
3449fi
3450
3451dnl BSDI uses ss_base while others use ss_sp for the stack pointer.
3452AC_MSG_CHECKING(whether stack_t has an ss_base field)
3453AC_TRY_COMPILE([
3454#include <sys/types.h>
3455#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003456# include <stdlib.h>
3457# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003458#endif
3459#include <signal.h>
3460#include "confdefs.h"
3461 ], [stack_t sigstk; sigstk.ss_base = 0; ],
3462 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SS_BASE),
3463 AC_MSG_RESULT(no))
3464
3465olibs="$LIBS"
3466AC_MSG_CHECKING(--with-tlib argument)
3467AC_ARG_WITH(tlib, [ --with-tlib=library terminal library to be used ],)
3468if test -n "$with_tlib"; then
3469 AC_MSG_RESULT($with_tlib)
3470 LIBS="$LIBS -l$with_tlib"
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003471 AC_MSG_CHECKING(for linking with $with_tlib library)
3472 AC_TRY_LINK([], [], AC_MSG_RESULT(OK), AC_MSG_ERROR(FAILED))
3473 dnl Need to check for tgetent() below.
3474 olibs="$LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003475else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003476 AC_MSG_RESULT([empty: automatic terminal library selection])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003477 dnl On HP-UX 10.10 termcap or termlib should be used instead of
3478 dnl curses, because curses is much slower.
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003479 dnl Newer versions of ncurses are preferred over anything, except
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02003480 dnl when tinfo has been split off, it contains all we need.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003481 dnl Older versions of ncurses have bugs, get a new one!
3482 dnl Digital Unix (OSF1) should use curses (Ronald Schild).
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00003483 dnl On SCO Openserver should prefer termlib (Roger Cornelius).
Bram Moolenaar071d4272004-06-13 20:20:40 +00003484 case "`uname -s 2>/dev/null`" in
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003485 OSF1|SCO_SV) tlibs="tinfo ncurses curses termlib termcap";;
3486 *) tlibs="tinfo ncurses termlib termcap curses";;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003487 esac
3488 for libname in $tlibs; do
3489 AC_CHECK_LIB(${libname}, tgetent,,)
3490 if test "x$olibs" != "x$LIBS"; then
3491 dnl It's possible that a library is found but it doesn't work
3492 dnl e.g., shared library that cannot be found
3493 dnl compile and run a test program to be sure
3494 AC_TRY_RUN([
3495#ifdef HAVE_TERMCAP_H
3496# include <termcap.h>
3497#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003498#if STDC_HEADERS
3499# include <stdlib.h>
3500# include <stddef.h>
3501#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003502main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }],
3503 res="OK", res="FAIL", res="FAIL")
3504 if test "$res" = "OK"; then
3505 break
3506 fi
3507 AC_MSG_RESULT($libname library is not usable)
3508 LIBS="$olibs"
3509 fi
3510 done
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003511 if test "x$olibs" = "x$LIBS"; then
3512 AC_MSG_RESULT(no terminal library found)
3513 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003514fi
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003515
3516if test "x$olibs" = "x$LIBS"; then
3517 AC_MSG_CHECKING([for tgetent()])
Bram Moolenaarbd7f7c12020-07-28 21:03:37 +02003518 AC_TRY_LINK([int tgetent(char *, const char *);],
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003519 [char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");],
3520 AC_MSG_RESULT(yes),
3521 AC_MSG_ERROR([NOT FOUND!
3522 You need to install a terminal library; for example ncurses.
3523 Or specify the name of the library with --with-tlib.]))
3524fi
3525
Bram Moolenaar446cb832008-06-24 21:56:24 +00003526AC_CACHE_CHECK([whether we talk terminfo], [vim_cv_terminfo],
3527 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003528 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003529#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003530#ifdef HAVE_TERMCAP_H
3531# include <termcap.h>
3532#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003533#ifdef HAVE_STRING_H
3534# include <string.h>
3535#endif
3536#if STDC_HEADERS
3537# include <stdlib.h>
3538# include <stddef.h>
3539#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003540main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003541{char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003542 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003543 vim_cv_terminfo=no
3544 ],[
3545 vim_cv_terminfo=yes
3546 ],[
3547 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_terminfo')
3548 ])
3549 ])
3550
3551if test "x$vim_cv_terminfo" = "xyes" ; then
3552 AC_DEFINE(TERMINFO)
3553fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003554
Bram Moolenaara88254f2017-11-02 23:04:14 +01003555AC_CACHE_CHECK([what tgetent() returns for an unknown terminal], [vim_cv_tgetent],
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003556 [
3557 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003558#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003559#ifdef HAVE_TERMCAP_H
3560# include <termcap.h>
3561#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003562#if STDC_HEADERS
3563# include <stdlib.h>
3564# include <stddef.h>
3565#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003566main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003567{char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003568 ]])],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003569 vim_cv_tgetent=zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003570 ],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003571 vim_cv_tgetent=non-zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003572 ],[
3573 AC_MSG_ERROR(failed to compile test program.)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003574 ])
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003575 ])
3576
Bram Moolenaara88254f2017-11-02 23:04:14 +01003577if test "x$vim_cv_tgetent" = "xzero" ; then
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003578 AC_DEFINE(TGETENT_ZERO_ERR, 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003579fi
3580
3581AC_MSG_CHECKING(whether termcap.h contains ospeed)
3582AC_TRY_LINK([
3583#ifdef HAVE_TERMCAP_H
3584# include <termcap.h>
3585#endif
3586 ], [ospeed = 20000],
3587 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED),
3588 [AC_MSG_RESULT(no)
3589 AC_MSG_CHECKING(whether ospeed can be extern)
3590 AC_TRY_LINK([
3591#ifdef HAVE_TERMCAP_H
3592# include <termcap.h>
3593#endif
3594extern short ospeed;
3595 ], [ospeed = 20000],
3596 AC_MSG_RESULT(yes); AC_DEFINE(OSPEED_EXTERN),
3597 AC_MSG_RESULT(no))]
3598 )
3599
3600AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC])
3601AC_TRY_LINK([
3602#ifdef HAVE_TERMCAP_H
3603# include <termcap.h>
3604#endif
3605 ], [if (UP == 0 && BC == 0) PC = 1],
3606 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UP_BC_PC),
3607 [AC_MSG_RESULT(no)
3608 AC_MSG_CHECKING([whether UP, BC and PC can be extern])
3609 AC_TRY_LINK([
3610#ifdef HAVE_TERMCAP_H
3611# include <termcap.h>
3612#endif
3613extern char *UP, *BC, PC;
3614 ], [if (UP == 0 && BC == 0) PC = 1],
3615 AC_MSG_RESULT(yes); AC_DEFINE(UP_BC_PC_EXTERN),
3616 AC_MSG_RESULT(no))]
3617 )
3618
3619AC_MSG_CHECKING(whether tputs() uses outfuntype)
3620AC_TRY_COMPILE([
3621#ifdef HAVE_TERMCAP_H
3622# include <termcap.h>
3623#endif
3624 ], [extern int xx(); tputs("test", 1, (outfuntype)xx)],
3625 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OUTFUNTYPE),
3626 AC_MSG_RESULT(no))
3627
3628dnl On some SCO machines sys/select redefines struct timeval
3629AC_MSG_CHECKING([whether sys/select.h and sys/time.h may both be included])
3630AC_TRY_COMPILE([
3631#include <sys/types.h>
3632#include <sys/time.h>
3633#include <sys/select.h>], ,
3634 AC_MSG_RESULT(yes)
3635 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME),
3636 AC_MSG_RESULT(no))
3637
3638dnl AC_DECL_SYS_SIGLIST
3639
3640dnl Checks for pty.c (copied from screen) ==========================
3641AC_MSG_CHECKING(for /dev/ptc)
3642if test -r /dev/ptc; then
3643 AC_DEFINE(HAVE_DEV_PTC)
3644 AC_MSG_RESULT(yes)
3645else
3646 AC_MSG_RESULT(no)
3647fi
3648
3649AC_MSG_CHECKING(for SVR4 ptys)
3650if test -c /dev/ptmx ; then
3651 AC_TRY_LINK([], [ptsname(0);grantpt(0);unlockpt(0);],
3652 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SVR4_PTYS),
3653 AC_MSG_RESULT(no))
3654else
3655 AC_MSG_RESULT(no)
3656fi
3657
3658AC_MSG_CHECKING(for ptyranges)
3659if test -d /dev/ptym ; then
3660 pdir='/dev/ptym'
3661else
3662 pdir='/dev'
3663fi
3664dnl SCO uses ptyp%d
3665AC_EGREP_CPP(yes,
3666[#ifdef M_UNIX
3667 yes;
3668#endif
3669 ], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
3670dnl if test -c /dev/ptyp19; then
3671dnl ptys=`echo /dev/ptyp??`
3672dnl else
3673dnl ptys=`echo $pdir/pty??`
3674dnl fi
3675if test "$ptys" != "$pdir/pty??" ; then
3676 p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
3677 p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'`
3678 AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
3679 AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
3680 AC_MSG_RESULT([$p0 / $p1])
3681else
3682 AC_MSG_RESULT([don't know])
3683fi
3684
Bram Moolenaar071d4272004-06-13 20:20:40 +00003685dnl Checks for library functions. ===================================
3686
3687AC_TYPE_SIGNAL
3688
3689dnl find out what to use at the end of a signal function
3690if test $ac_cv_type_signal = void; then
3691 AC_DEFINE(SIGRETURN, [return])
3692else
3693 AC_DEFINE(SIGRETURN, [return 0])
3694fi
3695
3696dnl check if struct sigcontext is defined (used for SGI only)
3697AC_MSG_CHECKING(for struct sigcontext)
3698AC_TRY_COMPILE([
3699#include <signal.h>
3700test_sig()
3701{
3702 struct sigcontext *scont;
3703 scont = (struct sigcontext *)0;
3704 return 1;
3705} ], ,
3706 AC_MSG_RESULT(yes)
3707 AC_DEFINE(HAVE_SIGCONTEXT),
3708 AC_MSG_RESULT(no))
3709
3710dnl tricky stuff: try to find out if getcwd() is implemented with
3711dnl system("sh -c pwd")
Bram Moolenaar446cb832008-06-24 21:56:24 +00003712AC_CACHE_CHECK([getcwd implementation is broken], [vim_cv_getcwd_broken],
3713 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003714 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003715#include "confdefs.h"
3716#ifdef HAVE_UNISTD_H
3717#include <unistd.h>
3718#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003719char *dagger[] = { "IFS=pwd", 0 };
3720main()
3721{
3722 char buffer[500];
3723 extern char **environ;
3724 environ = dagger;
3725 return getcwd(buffer, 500) ? 0 : 1;
Bram Moolenaar446cb832008-06-24 21:56:24 +00003726}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003727 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003728 vim_cv_getcwd_broken=no
3729 ],[
3730 vim_cv_getcwd_broken=yes
3731 ],[
3732 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_getcwd_broken')
3733 ])
3734 ])
3735
3736if test "x$vim_cv_getcwd_broken" = "xyes" ; then
3737 AC_DEFINE(BAD_GETCWD)
Bram Moolenaar63d25552019-05-10 21:28:38 +02003738 AC_CHECK_FUNCS(getwd)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003739fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003740
Bram Moolenaar25153e12010-02-24 14:47:08 +01003741dnl Check for functions in one big call, to reduce the size of configure.
3742dnl Can only be used for functions that do not require any include.
Bram Moolenaarcd142e32017-11-16 17:03:45 +01003743AC_CHECK_FUNCS(fchdir fchown fchmod fsync getcwd getpseudotty \
Bram Moolenaar63d25552019-05-10 21:28:38 +02003744 getpwent getpwnam getpwuid getrlimit gettimeofday localtime_r lstat \
Bram Moolenaareaf03392009-11-17 11:08:52 +00003745 memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
Bram Moolenaar2fcf6682017-03-11 20:03:42 +01003746 getpgid setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
Bram Moolenaar84cf6bd2020-06-16 20:03:43 +02003747 sigprocmask sigvec strcasecmp strcoll strerror strftime stricmp strncasecmp \
Bram Moolenaar10455d42019-11-21 15:36:18 +01003748 strnicmp strpbrk strptime strtol tgetent towlower towupper iswupper \
3749 tzset usleep utime utimes mblen ftruncate unsetenv posix_openpt)
Bram Moolenaar643b6142018-09-12 20:29:09 +02003750AC_FUNC_SELECT_ARGTYPES
Bram Moolenaar25153e12010-02-24 14:47:08 +01003751AC_FUNC_FSEEKO
Bram Moolenaar071d4272004-06-13 20:20:40 +00003752
Bram Moolenaar317fd3a2010-05-07 16:05:55 +02003753dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when
3754dnl appropriate, so that off_t is 64 bits when needed.
3755AC_SYS_LARGEFILE
3756
Bram Moolenaar21606672019-06-14 20:40:58 +02003757AC_MSG_CHECKING(--enable-canberra argument)
3758AC_ARG_ENABLE(canberra,
3759 [ --disable-canberra Do not use libcanberra.],
3760 , [enable_canberra="maybe"])
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003761
Bram Moolenaar21606672019-06-14 20:40:58 +02003762if test "$enable_canberra" = "maybe"; then
3763 if test "$features" = "big" -o "$features" = "huge"; then
3764 AC_MSG_RESULT(Defaulting to yes)
3765 enable_canberra="yes"
3766 else
3767 AC_MSG_RESULT(Defaulting to no)
3768 enable_canberra="no"
3769 fi
3770else
3771 AC_MSG_RESULT($enable_canberra)
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003772fi
Bram Moolenaar21606672019-06-14 20:40:58 +02003773if test "$enable_canberra" = "yes"; then
3774 if test "x$PKG_CONFIG" != "xno"; then
3775 canberra_lib=`$PKG_CONFIG --libs libcanberra 2>/dev/null`
3776 canberra_cflags=`$PKG_CONFIG --cflags libcanberra 2>/dev/null`
3777 fi
3778 if test "x$canberra_lib" = "x"; then
3779 canberra_lib=-lcanberra
3780 canberra_cflags=-D_REENTRANT
3781 fi
3782 AC_MSG_CHECKING(for libcanberra)
3783 ac_save_CFLAGS="$CFLAGS"
3784 ac_save_LIBS="$LIBS"
3785 CFLAGS="$CFLAGS $canberra_cflags"
3786 LIBS="$LIBS $canberra_lib"
3787 AC_TRY_LINK([
3788 # include <canberra.h>
3789 ], [
3790 ca_context *hello;
3791 ca_context_create(&hello);],
3792 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_CANBERRA),
Bram Moolenaar91b992c2019-11-17 19:07:42 +01003793 AC_MSG_RESULT(no; try installing libcanberra-dev); CFLAGS="$ac_save_CFLAGS"; LIBS="$ac_save_LIBS")
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003794fi
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003795
3796
Bram Moolenaar071d4272004-06-13 20:20:40 +00003797dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible
3798AC_MSG_CHECKING(for st_blksize)
3799AC_TRY_COMPILE(
3800[#include <sys/types.h>
3801#include <sys/stat.h>],
3802[ struct stat st;
3803 int n;
3804
3805 stat("/", &st);
3806 n = (int)st.st_blksize;],
3807 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ST_BLKSIZE),
3808 AC_MSG_RESULT(no))
3809
Bram Moolenaar446cb832008-06-24 21:56:24 +00003810AC_CACHE_CHECK([whether stat() ignores a trailing slash], [vim_cv_stat_ignores_slash],
3811 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003812 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003813#include "confdefs.h"
3814#if STDC_HEADERS
3815# include <stdlib.h>
3816# include <stddef.h>
3817#endif
3818#include <sys/types.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003819#include <sys/stat.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003820main() {struct stat st; exit(stat("configure/", &st) != 0); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003821 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003822 vim_cv_stat_ignores_slash=yes
3823 ],[
3824 vim_cv_stat_ignores_slash=no
3825 ],[
3826 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_stat_ignores_slash')
3827 ])
3828 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003829
Bram Moolenaar446cb832008-06-24 21:56:24 +00003830if test "x$vim_cv_stat_ignores_slash" = "xyes" ; then
3831 AC_DEFINE(STAT_IGNORES_SLASH)
3832fi
3833
Bram Moolenaar071d4272004-06-13 20:20:40 +00003834dnl Link with iconv for charset translation, if not found without library.
3835dnl check for iconv() requires including iconv.h
3836dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
3837dnl has been installed.
3838AC_MSG_CHECKING(for iconv_open())
3839save_LIBS="$LIBS"
3840LIBS="$LIBS -liconv"
3841AC_TRY_LINK([
3842#ifdef HAVE_ICONV_H
3843# include <iconv.h>
3844#endif
3845 ], [iconv_open("fr", "to");],
3846 AC_MSG_RESULT(yes; with -liconv); AC_DEFINE(HAVE_ICONV),
3847 LIBS="$save_LIBS"
3848 AC_TRY_LINK([
3849#ifdef HAVE_ICONV_H
3850# include <iconv.h>
3851#endif
3852 ], [iconv_open("fr", "to");],
3853 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ICONV),
3854 AC_MSG_RESULT(no)))
3855
3856
3857AC_MSG_CHECKING(for nl_langinfo(CODESET))
3858AC_TRY_LINK([
3859#ifdef HAVE_LANGINFO_H
3860# include <langinfo.h>
3861#endif
3862], [char *cs = nl_langinfo(CODESET);],
3863 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET),
3864 AC_MSG_RESULT(no))
3865
Bram Moolenaar446cb832008-06-24 21:56:24 +00003866dnl Need various functions for floating point support. Only enable
3867dnl floating point when they are all present.
3868AC_CHECK_LIB(m, strtod)
3869AC_MSG_CHECKING([for strtod() and other floating point functions])
3870AC_TRY_LINK([
3871#ifdef HAVE_MATH_H
3872# include <math.h>
3873#endif
3874#if STDC_HEADERS
3875# include <stdlib.h>
3876# include <stddef.h>
3877#endif
3878], [char *s; double d;
3879 d = strtod("1.1", &s);
3880 d = fabs(1.11);
3881 d = ceil(1.11);
3882 d = floor(1.11);
3883 d = log10(1.11);
3884 d = pow(1.11, 2.22);
3885 d = sqrt(1.11);
3886 d = sin(1.11);
3887 d = cos(1.11);
3888 d = atan(1.11);
3889 ],
3890 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT_FUNCS),
3891 AC_MSG_RESULT(no))
3892
Bram Moolenaara6b89762016-02-29 21:38:26 +01003893dnl isinf() and isnan() need to include header files and may need -lm.
3894AC_MSG_CHECKING([for isinf()])
3895AC_TRY_LINK([
3896#ifdef HAVE_MATH_H
3897# include <math.h>
3898#endif
3899#if STDC_HEADERS
3900# include <stdlib.h>
3901# include <stddef.h>
3902#endif
3903], [int r = isinf(1.11); ],
3904 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISINF),
3905 AC_MSG_RESULT(no))
3906
3907AC_MSG_CHECKING([for isnan()])
3908AC_TRY_LINK([
3909#ifdef HAVE_MATH_H
3910# include <math.h>
3911#endif
3912#if STDC_HEADERS
3913# include <stdlib.h>
3914# include <stddef.h>
3915#endif
3916], [int r = isnan(1.11); ],
3917 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISNAN),
3918 AC_MSG_RESULT(no))
3919
Bram Moolenaar071d4272004-06-13 20:20:40 +00003920dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI
3921dnl when -lacl works, also try to use -lattr (required for Debian).
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003922dnl On Solaris, use the acl_get/set functions in libsec, if present.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003923AC_MSG_CHECKING(--disable-acl argument)
3924AC_ARG_ENABLE(acl,
Bram Moolenaard6d30422018-01-28 22:48:55 +01003925 [ --disable-acl No check for ACL support.],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003926 , [enable_acl="yes"])
3927if test "$enable_acl" = "yes"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01003928 AC_MSG_RESULT(no)
3929 AC_CHECK_LIB(posix1e, acl_get_file, [LIBS="$LIBS -lposix1e"],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003930 AC_CHECK_LIB(acl, acl_get_file, [LIBS="$LIBS -lacl"
3931 AC_CHECK_LIB(attr, fgetxattr, LIBS="$LIBS -lattr",,)],,),)
3932
Bram Moolenaard6d30422018-01-28 22:48:55 +01003933 AC_MSG_CHECKING(for POSIX ACL support)
3934 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003935#include <sys/types.h>
3936#ifdef HAVE_SYS_ACL_H
3937# include <sys/acl.h>
3938#endif
3939acl_t acl;], [acl = acl_get_file("foo", ACL_TYPE_ACCESS);
3940 acl_set_file("foo", ACL_TYPE_ACCESS, acl);
3941 acl_free(acl);],
3942 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_ACL),
3943 AC_MSG_RESULT(no))
3944
Bram Moolenaard6d30422018-01-28 22:48:55 +01003945 AC_CHECK_LIB(sec, acl_get, [LIBS="$LIBS -lsec"; AC_DEFINE(HAVE_SOLARIS_ZFS_ACL)],
3946 AC_MSG_CHECKING(for Solaris ACL support)
3947 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003948#ifdef HAVE_SYS_ACL_H
3949# include <sys/acl.h>
3950#endif], [acl("foo", GETACLCNT, 0, NULL);
3951 ],
3952 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOLARIS_ACL),
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003953 AC_MSG_RESULT(no)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003954
Bram Moolenaard6d30422018-01-28 22:48:55 +01003955 AC_MSG_CHECKING(for AIX ACL support)
3956 AC_TRY_LINK([
Bram Moolenaar446cb832008-06-24 21:56:24 +00003957#if STDC_HEADERS
3958# include <stdlib.h>
3959# include <stddef.h>
3960#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003961#ifdef HAVE_SYS_ACL_H
3962# include <sys/acl.h>
3963#endif
3964#ifdef HAVE_SYS_ACCESS_H
3965# include <sys/access.h>
3966#endif
3967#define _ALL_SOURCE
3968
3969#include <sys/stat.h>
3970
3971int aclsize;
3972struct acl *aclent;], [aclsize = sizeof(struct acl);
3973 aclent = (void *)malloc(aclsize);
3974 statacl("foo", STX_NORMAL, aclent, aclsize);
3975 ],
3976 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_AIX_ACL),
3977 AC_MSG_RESULT(no))
3978else
3979 AC_MSG_RESULT(yes)
3980fi
3981
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02003982if test "x$GTK_CFLAGS" != "x"; then
3983 dnl pango_shape_full() is new, fall back to pango_shape().
3984 AC_MSG_CHECKING(for pango_shape_full)
3985 ac_save_CFLAGS="$CFLAGS"
3986 ac_save_LIBS="$LIBS"
3987 CFLAGS="$CFLAGS $GTK_CFLAGS"
3988 LIBS="$LIBS $GTK_LIBS"
Bram Moolenaar5325b9b2015-09-09 20:27:02 +02003989 AC_TRY_LINK(
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02003990 [#include <gtk/gtk.h>],
3991 [ pango_shape_full(NULL, 0, NULL, 0, NULL, NULL); ],
3992 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_PANGO_SHAPE_FULL),
3993 AC_MSG_RESULT(no))
3994 CFLAGS="$ac_save_CFLAGS"
3995 LIBS="$ac_save_LIBS"
3996fi
3997
Bram Moolenaar071d4272004-06-13 20:20:40 +00003998AC_MSG_CHECKING(--disable-gpm argument)
3999AC_ARG_ENABLE(gpm,
4000 [ --disable-gpm Don't use gpm (Linux mouse daemon).], ,
4001 [enable_gpm="yes"])
4002
4003if test "$enable_gpm" = "yes"; then
4004 AC_MSG_RESULT(no)
4005 dnl Checking if gpm support can be compiled
4006 AC_CACHE_CHECK([for gpm], vi_cv_have_gpm,
4007 [olibs="$LIBS" ; LIBS="-lgpm"]
4008 AC_TRY_LINK(
4009 [#include <gpm.h>
4010 #include <linux/keyboard.h>],
4011 [Gpm_GetLibVersion(NULL);],
4012 dnl Configure defines HAVE_GPM, if it is defined feature.h defines
4013 dnl FEAT_MOUSE_GPM if mouse support is included
4014 [vi_cv_have_gpm=yes],
4015 [vi_cv_have_gpm=no])
4016 [LIBS="$olibs"]
4017 )
4018 if test $vi_cv_have_gpm = yes; then
4019 LIBS="$LIBS -lgpm"
4020 AC_DEFINE(HAVE_GPM)
4021 fi
4022else
4023 AC_MSG_RESULT(yes)
4024fi
4025
Bram Moolenaar446cb832008-06-24 21:56:24 +00004026AC_MSG_CHECKING(--disable-sysmouse argument)
4027AC_ARG_ENABLE(sysmouse,
Bram Moolenaar8008b632017-07-18 21:33:20 +02004028 [ --disable-sysmouse Don't use sysmouse (mouse in *BSD console).], ,
Bram Moolenaar446cb832008-06-24 21:56:24 +00004029 [enable_sysmouse="yes"])
4030
4031if test "$enable_sysmouse" = "yes"; then
4032 AC_MSG_RESULT(no)
4033 dnl Checking if sysmouse support can be compiled
4034 dnl Configure defines HAVE_SYSMOUSE, if it is defined feature.h
4035 dnl defines FEAT_SYSMOUSE if mouse support is included
4036 AC_CACHE_CHECK([for sysmouse], vi_cv_have_sysmouse,
4037 AC_TRY_LINK(
4038 [#include <sys/consio.h>
4039 #include <signal.h>
4040 #include <sys/fbio.h>],
4041 [struct mouse_info mouse;
4042 mouse.operation = MOUSE_MODE;
4043 mouse.operation = MOUSE_SHOW;
4044 mouse.u.mode.mode = 0;
4045 mouse.u.mode.signal = SIGUSR2;],
4046 [vi_cv_have_sysmouse=yes],
4047 [vi_cv_have_sysmouse=no])
4048 )
4049 if test $vi_cv_have_sysmouse = yes; then
4050 AC_DEFINE(HAVE_SYSMOUSE)
4051 fi
4052else
4053 AC_MSG_RESULT(yes)
4054fi
4055
Bram Moolenaarf05da212009-11-17 16:13:15 +00004056dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
4057AC_MSG_CHECKING(for FD_CLOEXEC)
4058AC_TRY_COMPILE(
4059[#if HAVE_FCNTL_H
4060# include <fcntl.h>
4061#endif],
4062[ int flag = FD_CLOEXEC;],
4063 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
4064 AC_MSG_RESULT(not usable))
4065
Bram Moolenaar071d4272004-06-13 20:20:40 +00004066dnl rename needs to be checked separately to work on Nextstep with cc
4067AC_MSG_CHECKING(for rename)
4068AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
4069 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
4070 AC_MSG_RESULT(no))
4071
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004072dnl check for dirfd()
4073AC_MSG_CHECKING(for dirfd)
4074AC_TRY_COMPILE(
4075[#include <sys/types.h>
4076#include <dirent.h>],
4077[DIR * dir=opendir("dirname"); dirfd(dir);],
4078AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DIRFD), AC_MSG_RESULT(not usable))
4079
4080dnl check for flock()
4081AC_MSG_CHECKING(for flock)
4082AC_TRY_COMPILE(
4083[#include <sys/file.h>],
4084[flock(10, LOCK_SH);],
4085AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOCK), AC_MSG_RESULT(not usable))
4086
Bram Moolenaar071d4272004-06-13 20:20:40 +00004087dnl sysctl() may exist but not the arguments we use
4088AC_MSG_CHECKING(for sysctl)
4089AC_TRY_COMPILE(
4090[#include <sys/types.h>
4091#include <sys/sysctl.h>],
4092[ int mib[2], r;
4093 size_t len;
4094
4095 mib[0] = CTL_HW;
4096 mib[1] = HW_USERMEM;
4097 len = sizeof(r);
4098 (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
4099 ],
4100 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL),
4101 AC_MSG_RESULT(not usable))
4102
4103dnl sysinfo() may exist but not be Linux compatible
4104AC_MSG_CHECKING(for sysinfo)
4105AC_TRY_COMPILE(
4106[#include <sys/types.h>
4107#include <sys/sysinfo.h>],
4108[ struct sysinfo sinfo;
4109 int t;
4110
4111 (void)sysinfo(&sinfo);
4112 t = sinfo.totalram;
4113 ],
4114 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
4115 AC_MSG_RESULT(not usable))
4116
Bram Moolenaar914572a2007-05-01 11:37:47 +00004117dnl struct sysinfo may have the mem_unit field or not
4118AC_MSG_CHECKING(for sysinfo.mem_unit)
4119AC_TRY_COMPILE(
4120[#include <sys/types.h>
4121#include <sys/sysinfo.h>],
4122[ struct sysinfo sinfo;
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02004123 sinfo.mem_unit = 1;
Bram Moolenaar914572a2007-05-01 11:37:47 +00004124 ],
4125 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_MEM_UNIT),
4126 AC_MSG_RESULT(no))
4127
Bram Moolenaar071d4272004-06-13 20:20:40 +00004128dnl sysconf() may exist but not support what we want to use
4129AC_MSG_CHECKING(for sysconf)
4130AC_TRY_COMPILE(
4131[#include <unistd.h>],
4132[ (void)sysconf(_SC_PAGESIZE);
4133 (void)sysconf(_SC_PHYS_PAGES);
4134 ],
4135 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
4136 AC_MSG_RESULT(not usable))
4137
Bram Moolenaar914703b2010-05-31 21:59:46 +02004138AC_CHECK_SIZEOF([int])
4139AC_CHECK_SIZEOF([long])
4140AC_CHECK_SIZEOF([time_t])
4141AC_CHECK_SIZEOF([off_t])
Bram Moolenaar644fdff2010-05-30 13:26:21 +02004142
Bram Moolenaara2aa31a2014-02-23 22:52:40 +01004143dnl Use different names to avoid clashing with other header files.
4144AC_DEFINE_UNQUOTED(VIM_SIZEOF_INT, [$ac_cv_sizeof_int])
4145AC_DEFINE_UNQUOTED(VIM_SIZEOF_LONG, [$ac_cv_sizeof_long])
4146
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004147dnl Make sure that uint32_t is really 32 bits unsigned.
4148AC_MSG_CHECKING([uint32_t is 32 bits])
4149AC_TRY_RUN([
4150#ifdef HAVE_STDINT_H
4151# include <stdint.h>
4152#endif
4153#ifdef HAVE_INTTYPES_H
4154# include <inttypes.h>
4155#endif
4156main() {
4157 uint32_t nr1 = (uint32_t)-1;
4158 uint32_t nr2 = (uint32_t)0xffffffffUL;
Bram Moolenaar52897832020-07-02 22:50:37 +02004159 if (sizeof(uint32_t) != 4 || nr1 != 0xffffffffUL || nr2 + 1 != 0) return 1;
4160 return 0;
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004161}],
4162AC_MSG_RESULT(ok),
4163AC_MSG_ERROR([WRONG! uint32_t not defined correctly.]),
Bram Moolenaar323cb952011-12-14 19:22:34 +01004164AC_MSG_WARN([cannot check uint32_t when cross-compiling.]))
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004165
Bram Moolenaar446cb832008-06-24 21:56:24 +00004166dnl Check for memmove() before bcopy(), makes memmove() be used when both are
4167dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
4168
Bram Moolenaar071d4272004-06-13 20:20:40 +00004169[bcopy_test_prog='
Bram Moolenaar446cb832008-06-24 21:56:24 +00004170#include "confdefs.h"
4171#ifdef HAVE_STRING_H
4172# include <string.h>
4173#endif
4174#if STDC_HEADERS
4175# include <stdlib.h>
4176# include <stddef.h>
4177#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004178main() {
4179 char buf[10];
4180 strcpy(buf, "abcdefghi");
4181 mch_memmove(buf, buf + 2, 3);
4182 if (strncmp(buf, "ababcf", 6))
4183 exit(1);
4184 strcpy(buf, "abcdefghi");
4185 mch_memmove(buf + 2, buf, 3);
4186 if (strncmp(buf, "cdedef", 6))
4187 exit(1);
4188 exit(0); /* libc version works properly. */
4189}']
4190
Bram Moolenaar446cb832008-06-24 21:56:24 +00004191AC_CACHE_CHECK([whether memmove handles overlaps],[vim_cv_memmove_handles_overlap],
4192 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004193 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 +00004194 [
4195 vim_cv_memmove_handles_overlap=yes
4196 ],[
4197 vim_cv_memmove_handles_overlap=no
4198 ],[
4199 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memmove_handles_overlap')
4200 ])
4201 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00004202
Bram Moolenaar446cb832008-06-24 21:56:24 +00004203if test "x$vim_cv_memmove_handles_overlap" = "xyes" ; then
4204 AC_DEFINE(USEMEMMOVE)
4205else
4206 AC_CACHE_CHECK([whether bcopy handles overlaps],[vim_cv_bcopy_handles_overlap],
4207 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004208 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 +00004209 [
4210 vim_cv_bcopy_handles_overlap=yes
4211 ],[
4212 vim_cv_bcopy_handles_overlap=no
4213 ],[
4214 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_bcopy_handles_overlap')
4215 ])
4216 ])
4217
4218 if test "x$vim_cv_bcopy_handles_overlap" = "xyes" ; then
4219 AC_DEFINE(USEBCOPY)
4220 else
4221 AC_CACHE_CHECK([whether memcpy handles overlaps],[vim_cv_memcpy_handles_overlap],
4222 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004223 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 +00004224 [
4225 vim_cv_memcpy_handles_overlap=yes
4226 ],[
4227 vim_cv_memcpy_handles_overlap=no
4228 ],[
4229 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memcpy_handles_overlap')
4230 ])
4231 ])
4232
4233 if test "x$vim_cv_memcpy_handles_overlap" = "xyes" ; then
4234 AC_DEFINE(USEMEMCPY)
4235 fi
4236 fi
4237fi
4238
Bram Moolenaar071d4272004-06-13 20:20:40 +00004239
4240dnl Check for multibyte locale functions
4241dnl Find out if _Xsetlocale() is supported by libX11.
4242dnl Check if X_LOCALE should be defined.
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004243if test "x$with_x" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004244 cflags_save=$CFLAGS
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004245 libs_save=$LIBS
4246 LIBS="$LIBS $X_LIBS $GUI_LIB_LOC $GUI_X_LIBS $X_PRE_LIBS $X_LIB $X_EXTRA_LIBS"
4247 CFLAGS="$CFLAGS $X_CFLAGS"
4248
4249 AC_MSG_CHECKING(whether X_LOCALE needed)
4250 AC_TRY_COMPILE([#include <X11/Xlocale.h>],,
4251 AC_TRY_LINK_FUNC([_Xsetlocale], [AC_MSG_RESULT(yes)
4252 AC_DEFINE(X_LOCALE)], AC_MSG_RESULT(no)),
4253 AC_MSG_RESULT(no))
4254
4255 AC_MSG_CHECKING(whether Xutf8SetWMProperties() can be used)
4256 AC_TRY_LINK_FUNC([Xutf8SetWMProperties], [AC_MSG_RESULT(yes)
4257 AC_DEFINE(HAVE_XUTF8SETWMPROPERTIES)], AC_MSG_RESULT(no))
4258
Bram Moolenaar071d4272004-06-13 20:20:40 +00004259 CFLAGS=$cflags_save
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004260 LIBS=$libs_save
Bram Moolenaar071d4272004-06-13 20:20:40 +00004261fi
4262
4263dnl Link with xpg4, it is said to make Korean locale working
4264AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,)
4265
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004266dnl Check how we can run ctags. Default to "ctags" when nothing works.
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02004267dnl Use --version to detect Exuberant ctags (preferred)
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004268dnl Add --fields=+S to get function signatures for omni completion.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004269dnl -t for typedefs (many ctags have this)
4270dnl -s for static functions (Elvis ctags only?)
4271dnl -v for variables. Dangerous, most ctags take this for 'vgrind style'.
4272dnl -i+m to test for older Exuberant ctags
4273AC_MSG_CHECKING(how to create tags)
4274test -f tags && mv tags tags.save
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004275if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004276 TAGPRG="ctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004277elif (eval exctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004278 TAGPRG="exctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004279elif (eval exuberant-ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004280 TAGPRG="exuberant-ctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004281else
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004282 TAGPRG="ctags"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004283 (eval etags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags"
4284 (eval etags -c /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags -c"
4285 (eval ctags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags"
4286 (eval ctags -t /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -t"
4287 (eval ctags -ts /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -ts"
4288 (eval ctags -tvs /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -tvs"
4289 (eval ctags -i+m /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -i+m"
4290fi
4291test -f tags.save && mv tags.save tags
4292AC_MSG_RESULT($TAGPRG) AC_SUBST(TAGPRG)
4293
4294dnl Check how we can run man with a section number
4295AC_MSG_CHECKING(how to run man with a section nr)
4296MANDEF="man"
Bram Moolenaar8b131502008-02-13 09:28:19 +00004297(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 +00004298AC_MSG_RESULT($MANDEF)
4299if test "$MANDEF" = "man -s"; then
4300 AC_DEFINE(USEMAN_S)
4301fi
4302
4303dnl Check if gettext() is working and if it needs -lintl
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004304dnl We take care to base this on an empty LIBS: on some systems libelf would be
4305dnl in LIBS and implicitly take along libintl. The final LIBS would then not
4306dnl contain libintl, and the link step would fail due to -Wl,--as-needed.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004307AC_MSG_CHECKING(--disable-nls argument)
4308AC_ARG_ENABLE(nls,
4309 [ --disable-nls Don't support NLS (gettext()).], ,
4310 [enable_nls="yes"])
4311
4312if test "$enable_nls" = "yes"; then
4313 AC_MSG_RESULT(no)
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00004314
4315 INSTALL_LANGS=install-languages
4316 AC_SUBST(INSTALL_LANGS)
4317 INSTALL_TOOL_LANGS=install-tool-languages
4318 AC_SUBST(INSTALL_TOOL_LANGS)
4319
Bram Moolenaar071d4272004-06-13 20:20:40 +00004320 AC_CHECK_PROG(MSGFMT, msgfmt, msgfmt, )
4321 AC_MSG_CHECKING([for NLS])
4322 if test -f po/Makefile; then
4323 have_gettext="no"
4324 if test -n "$MSGFMT"; then
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004325 olibs=$LIBS
4326 LIBS=""
Bram Moolenaar071d4272004-06-13 20:20:40 +00004327 AC_TRY_LINK(
4328 [#include <libintl.h>],
4329 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004330 AC_MSG_RESULT([gettext() works]); have_gettext="yes"; LIBS=$olibs,
4331 LIBS="-lintl"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004332 AC_TRY_LINK(
4333 [#include <libintl.h>],
4334 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004335 AC_MSG_RESULT([gettext() works with -lintl]); have_gettext="yes";
4336 LIBS="$olibs -lintl",
Bram Moolenaar071d4272004-06-13 20:20:40 +00004337 AC_MSG_RESULT([gettext() doesn't work]);
4338 LIBS=$olibs))
4339 else
4340 AC_MSG_RESULT([msgfmt not found - disabled]);
4341 fi
Bram Moolenaar278eb582014-07-30 13:22:52 +02004342 if test $have_gettext = "yes" -a "x$features" != "xtiny" -a "x$features" != "xsmall"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004343 AC_DEFINE(HAVE_GETTEXT)
4344 MAKEMO=yes
4345 AC_SUBST(MAKEMO)
4346 dnl this was added in GNU gettext 0.10.36
4347 AC_CHECK_FUNCS(bind_textdomain_codeset)
4348 dnl _nl_msg_cat_cntr is required for GNU gettext
4349 AC_MSG_CHECKING([for _nl_msg_cat_cntr])
4350 AC_TRY_LINK(
4351 [#include <libintl.h>
4352 extern int _nl_msg_cat_cntr;],
4353 [++_nl_msg_cat_cntr;],
4354 AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_NL_MSG_CAT_CNTR),
4355 AC_MSG_RESULT([no]))
Bram Moolenaar26096cc2019-04-11 15:25:40 +02004356 AC_MSG_CHECKING([if msgfmt supports --desktop])
4357 MSGFMT_DESKTOP=
4358 if "$MSGFMT" --help | grep -e '--desktop' >/dev/null; then
Bram Moolenaar62a88f42019-06-07 20:44:40 +02004359 if "$MSGFMT" --version | grep '0.19.[[3-7]]$' >/dev/null; then
4360 dnl GNU gettext 0.19.7's --desktop is broken. We assume back to
4361 dnl 0.19.3 is also broken.
4362 AC_MSG_RESULT([broken])
4363 else
4364 AC_MSG_RESULT([yes])
4365 MSGFMT_DESKTOP="gvim.desktop vim.desktop"
4366 fi
Bram Moolenaar26096cc2019-04-11 15:25:40 +02004367 else
4368 AC_MSG_RESULT([no])
4369 fi
4370 AC_SUBST(MSGFMT_DESKTOP)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004371 fi
4372 else
4373 AC_MSG_RESULT([no "po/Makefile" - disabled]);
4374 fi
4375else
4376 AC_MSG_RESULT(yes)
4377fi
4378
4379dnl Check for dynamic linking loader
4380AC_CHECK_HEADER(dlfcn.h, DLL=dlfcn.h, [AC_CHECK_HEADER(dl.h, DLL=dl.h)])
4381if test x${DLL} = xdlfcn.h; then
4382 AC_DEFINE(HAVE_DLFCN_H, 1, [ Define if we have dlfcn.h. ])
4383 AC_MSG_CHECKING([for dlopen()])
4384 AC_TRY_LINK(,[
4385 extern void* dlopen();
4386 dlopen();
4387 ],
4388 AC_MSG_RESULT(yes);
4389 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4390 AC_MSG_RESULT(no);
4391 AC_MSG_CHECKING([for dlopen() in -ldl])
4392 olibs=$LIBS
4393 LIBS="$LIBS -ldl"
4394 AC_TRY_LINK(,[
4395 extern void* dlopen();
4396 dlopen();
4397 ],
4398 AC_MSG_RESULT(yes);
4399 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4400 AC_MSG_RESULT(no);
4401 LIBS=$olibs))
4402 dnl ReliantUNIX has dlopen() in libc but everything else in libdl
4403 dnl ick :-)
4404 AC_MSG_CHECKING([for dlsym()])
4405 AC_TRY_LINK(,[
4406 extern void* dlsym();
4407 dlsym();
4408 ],
4409 AC_MSG_RESULT(yes);
4410 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4411 AC_MSG_RESULT(no);
4412 AC_MSG_CHECKING([for dlsym() in -ldl])
4413 olibs=$LIBS
4414 LIBS="$LIBS -ldl"
4415 AC_TRY_LINK(,[
4416 extern void* dlsym();
4417 dlsym();
4418 ],
4419 AC_MSG_RESULT(yes);
4420 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4421 AC_MSG_RESULT(no);
4422 LIBS=$olibs))
4423elif test x${DLL} = xdl.h; then
4424 AC_DEFINE(HAVE_DL_H, 1, [ Define if we have dl.h. ])
4425 AC_MSG_CHECKING([for shl_load()])
4426 AC_TRY_LINK(,[
4427 extern void* shl_load();
4428 shl_load();
4429 ],
4430 AC_MSG_RESULT(yes);
4431 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4432 AC_MSG_RESULT(no);
4433 AC_MSG_CHECKING([for shl_load() in -ldld])
4434 olibs=$LIBS
4435 LIBS="$LIBS -ldld"
4436 AC_TRY_LINK(,[
4437 extern void* shl_load();
4438 shl_load();
4439 ],
4440 AC_MSG_RESULT(yes);
4441 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4442 AC_MSG_RESULT(no);
4443 LIBS=$olibs))
4444fi
4445AC_CHECK_HEADERS(setjmp.h)
4446
Bram Moolenaard0573012017-10-28 21:11:06 +02004447if test "x$MACOS_X" = "xyes" -a -n "$PERL"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004448 dnl -ldl must come after DynaLoader.a
4449 if echo $LIBS | grep -e '-ldl' >/dev/null; then
4450 LIBS=`echo $LIBS | sed s/-ldl//`
4451 PERL_LIBS="$PERL_LIBS -ldl"
4452 fi
4453fi
4454
Bram Moolenaard0573012017-10-28 21:11:06 +02004455if test "$MACOS_X" = "yes"; then
4456 AC_MSG_CHECKING([whether we need macOS frameworks])
4457 if test "$GUITYPE" = "CARBONGUI"; then
4458 AC_MSG_RESULT([yes, we need Carbon])
4459 LIBS="$LIBS -framework Carbon"
4460 elif test "$MACOS_X_DARWIN" = "yes"; then
4461 if test "$features" = "tiny"; then
4462 dnl Since no FEAT_CLIPBOARD, no longer need for os_macosx.m.
4463 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_macosx.m++'`
4464 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_macosx.o++'`
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01004465 AC_MSG_RESULT([yes, we need CoreServices])
4466 LIBS="$LIBS -framework CoreServices"
Bram Moolenaard0573012017-10-28 21:11:06 +02004467 else
4468 AC_MSG_RESULT([yes, we need AppKit])
4469 LIBS="$LIBS -framework AppKit"
Bram Moolenaard0573012017-10-28 21:11:06 +02004470 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004471 else
Bram Moolenaard0573012017-10-28 21:11:06 +02004472 AC_MSG_RESULT([no])
Bram Moolenaar3437b912013-07-03 19:52:53 +02004473 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004474fi
Bram Moolenaar164fca32010-07-14 13:58:07 +02004475if test "x$MACARCH" = "xboth" && test "x$GUITYPE" = "xCARBONGUI"; then
Bram Moolenaar595a7be2010-03-10 16:28:12 +01004476 LDFLAGS="$LDFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +00004477fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004478
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004479dnl gcc 3.1 changed the meaning of -MM. The only solution appears to be to
4480dnl use "-isystem" instead of "-I" for all non-Vim include dirs.
4481dnl But only when making dependencies, cproto and lint don't take "-isystem".
Bram Moolenaar32466aa2006-02-24 23:53:04 +00004482dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
4483dnl the number before the version number.
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004484DEPEND_CFLAGS_FILTER=
4485if test "$GCC" = yes; then
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004486 AC_MSG_CHECKING(for GCC 3 or later)
Bram Moolenaar348808f2020-02-07 20:50:07 +01004487 gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]][[0-9]]*\)\..*$/\1/g'`
Bram Moolenaarf740b292006-02-16 22:11:02 +00004488 if test "$gccmajor" -gt "2"; then
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004489 DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004490 AC_MSG_RESULT(yes)
4491 else
4492 AC_MSG_RESULT(no)
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004493 fi
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004494 dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
4495 dnl declared as char x[1] but actually longer. Introduced in gcc 4.0.
Bram Moolenaar56d1db32009-12-16 16:14:51 +00004496 dnl Also remove duplicate _FORTIFY_SOURCE arguments.
Bram Moolenaaraeabe052011-12-08 15:17:34 +01004497 dnl And undefine it first to avoid a warning.
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004498 AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
4499 if test "$gccmajor" -gt "3"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02004500 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 +01004501 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 +00004502 AC_MSG_RESULT(yes)
4503 else
4504 AC_MSG_RESULT(no)
4505 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +00004506fi
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004507AC_SUBST(DEPEND_CFLAGS_FILTER)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004508
Bram Moolenaarec0557f2018-01-31 14:41:37 +01004509dnl On some systems AC_SYS_LARGEFILE determines that -D_FILE_OFFSET_BITS=64
4510dnl isn't required, but the CFLAGS for some of the libraries we're using
4511dnl include the define. Since the define changes the size of some datatypes
4512dnl (e.g. ino_t and off_t), all of Vim's modules must be compiled with a
4513dnl consistent value. It's therefore safest to force the use of the define
4514dnl if it's present in any of the *_CFLAGS variables.
4515AC_MSG_CHECKING(whether we need to force -D_FILE_OFFSET_BITS=64)
Bram Moolenaar9ce42132018-04-11 22:19:36 +02004516if 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 +01004517 AC_MSG_RESULT(yes)
4518 AC_DEFINE(_FILE_OFFSET_BITS, 64)
4519else
4520 AC_MSG_RESULT(no)
4521fi
4522
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004523dnl link.sh tries to avoid overlinking in a hackish way.
4524dnl At least GNU ld supports --as-needed which provides the same functionality
4525dnl at linker level. Let's use it.
4526AC_MSG_CHECKING(linker --as-needed support)
4527LINK_AS_NEEDED=
4528# Check if linker supports --as-needed and --no-as-needed options
4529if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02004530 LDFLAGS=`echo "$LDFLAGS" | sed -e 's/ *-Wl,--as-needed//g' | sed -e 's/$/ -Wl,--as-needed/'`
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004531 LINK_AS_NEEDED=yes
4532fi
4533if test "$LINK_AS_NEEDED" = yes; then
4534 AC_MSG_RESULT(yes)
4535else
4536 AC_MSG_RESULT(no)
4537fi
4538AC_SUBST(LINK_AS_NEEDED)
4539
Bram Moolenaar77c19352012-06-13 19:19:41 +02004540# IBM z/OS reset CFLAGS for config.mk
4541if test "$zOSUnix" = "yes"; then
4542 CFLAGS="-D_ALL_SOURCE -Wc,float\(ieee\),dll"
4543fi
4544
Bram Moolenaar071d4272004-06-13 20:20:40 +00004545dnl write output files
4546AC_OUTPUT(auto/config.mk:config.mk.in)
4547
4548dnl vim: set sw=2 tw=78 fo+=l: