blob: 47502a99c40571309543e61380419529d0998ad2 [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 Moolenaarf788a062011-12-14 20:51:25 +010065dnl Check for the flag that fails if stuff are missing.
66
67AC_MSG_CHECKING(--enable-fail-if-missing argument)
68AC_ARG_ENABLE(fail_if_missing,
69 [ --enable-fail-if-missing Fail if dependencies on additional features
70 specified on the command line are missing.],
71 [fail_if_missing="yes"],
72 [fail_if_missing="no"])
73AC_MSG_RESULT($fail_if_missing)
74
Bram Moolenaard2a05492018-07-27 22:35:15 +020075dnl Keep original value to check later.
76with_x_arg="$with_x"
77
Bram Moolenaar071d4272004-06-13 20:20:40 +000078dnl Set default value for CFLAGS if none is defined or it's empty
79if test -z "$CFLAGS"; then
80 CFLAGS="-O"
81 test "$GCC" = yes && CFLAGS="-O2 -fno-strength-reduce -Wall"
82fi
83if test "$GCC" = yes; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +000084 dnl method that should work for nearly all versions
Bram Moolenaarc8836f72014-04-12 13:12:24 +020085 gccversion=`$CC -dumpversion`
Bram Moolenaar910f66f2006-04-05 20:41:53 +000086 if test "x$gccversion" = "x"; then
87 dnl old method; fall-back for when -dumpversion doesn't work
Bram Moolenaarc8836f72014-04-12 13:12:24 +020088 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 +000089 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +000090 dnl version 4.0.1 was reported to cause trouble on Macintosh by Marcin Dalecki
91 if test "$gccversion" = "3.0.1" -o "$gccversion" = "3.0.2" -o "$gccversion" = "4.0.1"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +000092 echo 'GCC [[34]].0.[[12]] has a bug in the optimizer, disabling "-O#"'
Bram Moolenaar071d4272004-06-13 20:20:40 +000093 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-O/'`
94 else
95 if test "$gccversion" = "3.1" -o "$gccversion" = "3.2" -o "$gccversion" = "3.2.1" && `echo "$CFLAGS" | grep -v fno-strength-reduce >/dev/null`; then
96 echo 'GCC 3.1 and 3.2 have a bug in the optimizer, adding "-fno-strength-reduce"'
97 CFLAGS="$CFLAGS -fno-strength-reduce"
98 fi
99 fi
100fi
101
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200102dnl clang-500.2.75 or around has abandoned -f[no-]strength-reduce and issues a
103dnl warning when that flag is passed to. Accordingly, adjust CFLAGS based on
104dnl the version number of the clang in use.
105dnl Note that this does not work to get the version of clang 3.1 or 3.2.
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100106AC_MSG_CHECKING(for clang version)
107CLANG_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 +0200108if test x"$CLANG_VERSION_STRING" != x"" ; then
109 CLANG_MAJOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*/\1/p'`
110 CLANG_MINOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/p'`
111 CLANG_REVISION=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)/\1/p'`
112 CLANG_VERSION=`expr $CLANG_MAJOR '*' 1000000 '+' $CLANG_MINOR '*' 1000 '+' $CLANG_REVISION`
113 AC_MSG_RESULT($CLANG_VERSION)
114 dnl If you find the same issue with versions earlier than 500.2.75,
115 dnl change the constant 500002075 below appropriately. To get the
116 dnl integer corresponding to a version number, refer to the
117 dnl definition of CLANG_VERSION above.
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100118 AC_MSG_CHECKING(if clang supports -fno-strength-reduce)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200119 if test "$CLANG_VERSION" -ge 500002075 ; then
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100120 AC_MSG_RESULT(no)
121 CFLAGS=`echo "$CFLAGS" | sed -e 's/-fno-strength-reduce/ /'`
122 else
123 AC_MSG_RESULT(yes)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200124 fi
125else
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100126 AC_MSG_RESULT(N/A)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200127fi
128
Bram Moolenaar446cb832008-06-24 21:56:24 +0000129dnl If configure thinks we are cross compiling, there might be something
130dnl wrong with the CC or CFLAGS settings, give a useful warning message
Bram Moolenaar839e9542016-04-14 16:46:02 +0200131CROSS_COMPILING=
Bram Moolenaar071d4272004-06-13 20:20:40 +0000132if test "$cross_compiling" = yes; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000133 AC_MSG_RESULT([cannot compile a simple program; if not cross compiling check CC and CFLAGS])
Bram Moolenaar839e9542016-04-14 16:46:02 +0200134 CROSS_COMPILING=1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000135fi
Bram Moolenaar839e9542016-04-14 16:46:02 +0200136AC_SUBST(CROSS_COMPILING)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000137
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +0000138dnl gcc-cpp has the wonderful -MM option to produce nicer dependencies.
139dnl But gcc 3.1 changed the meaning! See near the end.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000140test "$GCC" = yes && CPP_MM=M; AC_SUBST(CPP_MM)
141
142if test -f ./toolcheck; then
143 AC_CHECKING(for buggy tools)
144 sh ./toolcheck 1>&AC_FD_MSG
145fi
146
147OS_EXTRA_SRC=""; OS_EXTRA_OBJ=""
148
149dnl Check for BeOS, which needs an extra source file
150AC_MSG_CHECKING(for BeOS)
151case `uname` in
152 BeOS) OS_EXTRA_SRC=os_beos.c; OS_EXTRA_OBJ=objects/os_beos.o
153 BEOS=yes; AC_MSG_RESULT(yes);;
154 *) BEOS=no; AC_MSG_RESULT(no);;
155esac
156
Bram Moolenaarb3f74062020-02-26 16:16:53 +0100157AC_MSG_CHECKING(for Haiku)
158case `uname` in
159 Haiku) HAIKU=yes; AC_MSG_RESULT(yes);;
160 *) HAIKU=no; AC_MSG_RESULT(no);;
161esac
162
Bram Moolenaar071d4272004-06-13 20:20:40 +0000163dnl If QNX is found, assume we don't want to use Xphoton
164dnl unless it was specifically asked for (--with-x)
165AC_MSG_CHECKING(for QNX)
166case `uname` in
167 QNX) OS_EXTRA_SRC=os_qnx.c; OS_EXTRA_OBJ=objects/os_qnx.o
168 test -z "$with_x" && with_x=no
169 QNX=yes; AC_MSG_RESULT(yes);;
170 *) QNX=no; AC_MSG_RESULT(no);;
171esac
172
173dnl Check for Darwin and MacOS X
174dnl We do a check for MacOS X in the very beginning because there
175dnl are a lot of other things we need to change besides GUI stuff
Bram Moolenaar071d4272004-06-13 20:20:40 +0000176AC_MSG_CHECKING([for Darwin (Mac OS X)])
177if test "`(uname) 2>/dev/null`" = Darwin; then
178 AC_MSG_RESULT(yes)
Bram Moolenaard0573012017-10-28 21:11:06 +0200179 MACOS_X=yes
Bram Moolenaar52ecaaa2018-05-12 21:38:13 +0200180 CPPFLAGS="$CPPFLAGS -DMACOS_X"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000181
182 AC_MSG_CHECKING(--disable-darwin argument)
183 AC_ARG_ENABLE(darwin,
184 [ --disable-darwin Disable Darwin (Mac OS X) support.],
185 , [enable_darwin="yes"])
186 if test "$enable_darwin" = "yes"; then
187 AC_MSG_RESULT(no)
188 AC_MSG_CHECKING(if Darwin files are there)
Bram Moolenaar164fca32010-07-14 13:58:07 +0200189 if test -f os_macosx.m; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000190 AC_MSG_RESULT(yes)
191 else
192 AC_MSG_RESULT([no, Darwin support disabled])
193 enable_darwin=no
194 fi
195 else
196 AC_MSG_RESULT([yes, Darwin support excluded])
197 fi
198
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000199 AC_MSG_CHECKING(--with-mac-arch argument)
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000200 AC_ARG_WITH(mac-arch, [ --with-mac-arch=ARCH current, intel, ppc or both],
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000201 MACARCH="$withval"; AC_MSG_RESULT($MACARCH),
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000202 MACARCH="current"; AC_MSG_RESULT(defaulting to $MACARCH))
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000203
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100204 AC_MSG_CHECKING(--with-developer-dir argument)
205 AC_ARG_WITH(developer-dir, [ --with-developer-dir=PATH use PATH as location for Xcode developer tools],
206 DEVELOPER_DIR="$withval"; AC_MSG_RESULT($DEVELOPER_DIR),
Bram Moolenaar32d03b32015-11-19 13:46:48 +0100207 AC_MSG_RESULT(not present))
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100208
209 if test "x$DEVELOPER_DIR" = "x"; then
210 AC_PATH_PROG(XCODE_SELECT, xcode-select)
211 if test "x$XCODE_SELECT" != "x"; then
212 AC_MSG_CHECKING(for developer dir using xcode-select)
213 DEVELOPER_DIR=`$XCODE_SELECT -print-path`
214 AC_MSG_RESULT([$DEVELOPER_DIR])
215 else
216 DEVELOPER_DIR=/Developer
217 fi
218 fi
219
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000220 if test "x$MACARCH" = "xboth"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000221 AC_MSG_CHECKING(for 10.4 universal SDK)
222 dnl There is a terrible inconsistency (but we appear to get away with it):
223 dnl $CFLAGS uses the 10.4u SDK library for the headers, while $CPPFLAGS
224 dnl doesn't, because "gcc -E" doesn't grok it. That means the configure
225 dnl tests using the preprocessor are actually done with the wrong header
226 dnl files. $LDFLAGS is set at the end, because configure uses it together
227 dnl with $CFLAGS and we can only have one -sysroot argument.
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000228 save_cppflags="$CPPFLAGS"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000229 save_cflags="$CFLAGS"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000230 save_ldflags="$LDFLAGS"
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100231 CFLAGS="$CFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000232 AC_TRY_LINK([ ], [ ],
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000233 AC_MSG_RESULT(found, will make universal binary),
234
235 AC_MSG_RESULT(not found)
Bram Moolenaar1f35bf92006-03-07 22:38:47 +0000236 CFLAGS="$save_cflags"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000237 AC_MSG_CHECKING(if Intel architecture is supported)
238 CPPFLAGS="$CPPFLAGS -arch i386"
239 LDFLAGS="$save_ldflags -arch i386"
240 AC_TRY_LINK([ ], [ ],
241 AC_MSG_RESULT(yes); MACARCH="intel",
242 AC_MSG_RESULT(no, using PowerPC)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000243 MACARCH="ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000244 CPPFLAGS="$save_cppflags -arch ppc"
245 LDFLAGS="$save_ldflags -arch ppc"))
246 elif test "x$MACARCH" = "xintel"; then
247 CPPFLAGS="$CPPFLAGS -arch intel"
248 LDFLAGS="$LDFLAGS -arch intel"
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000249 elif test "x$MACARCH" = "xppc"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000250 CPPFLAGS="$CPPFLAGS -arch ppc"
251 LDFLAGS="$LDFLAGS -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000252 fi
253
Bram Moolenaar071d4272004-06-13 20:20:40 +0000254 if test "$enable_darwin" = "yes"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200255 MACOS_X_DARWIN=yes
Bram Moolenaar164fca32010-07-14 13:58:07 +0200256 OS_EXTRA_SRC="os_macosx.m os_mac_conv.c";
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000257 OS_EXTRA_OBJ="objects/os_macosx.o objects/os_mac_conv.o"
Bram Moolenaar32466aa2006-02-24 23:53:04 +0000258 dnl TODO: use -arch i386 on Intel machines
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100259 dnl Removed -no-cpp-precomp, only for very old compilers.
Bram Moolenaard0573012017-10-28 21:11:06 +0200260 CPPFLAGS="$CPPFLAGS -DMACOS_X_DARWIN"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000261
262 dnl If Carbon is found, assume we don't want X11
263 dnl unless it was specifically asked for (--with-x)
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000264 dnl or Motif, Athena or GTK GUI is used.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000265 AC_CHECK_HEADER(Carbon/Carbon.h, CARBON=yes)
266 if test "x$CARBON" = "xyes"; then
Bram Moolenaar98921892016-02-23 17:14:37 +0100267 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 +0000268 with_x=no
Bram Moolenaar071d4272004-06-13 20:20:40 +0000269 fi
270 fi
271 fi
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000272
Bram Moolenaardb552d602006-03-23 22:59:57 +0000273 dnl Avoid a bug with -O2 with gcc 4.0.1. Symptom: malloc() reports double
Bram Moolenaarfd2ac762006-03-01 22:09:21 +0000274 dnl free. This happens in expand_filename(), because the optimizer swaps
Bram Moolenaardb552d602006-03-23 22:59:57 +0000275 dnl two blocks of code, both using "repl", that can't be swapped.
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000276 if test "$MACARCH" = "intel" -o "$MACARCH" = "both"; then
277 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-Oz/'`
278 fi
279
Bram Moolenaar071d4272004-06-13 20:20:40 +0000280else
281 AC_MSG_RESULT(no)
282fi
283
Bram Moolenaar39766a72013-11-03 00:41:00 +0100284dnl Mac OS X 10.9+ no longer include AvailabilityMacros.h in Carbon
285dnl so we need to include it to have access to version macros.
Bram Moolenaar18e54692013-11-03 20:26:31 +0100286AC_CHECK_HEADERS(AvailabilityMacros.h)
Bram Moolenaar39766a72013-11-03 00:41:00 +0100287
Bram Moolenaar071d4272004-06-13 20:20:40 +0000288AC_SUBST(OS_EXTRA_SRC)
289AC_SUBST(OS_EXTRA_OBJ)
290
291dnl Add /usr/local/lib to $LDFLAGS and /usr/local/include to CFLAGS.
292dnl Only when the directory exists and it wasn't there yet.
293dnl For gcc don't do this when it is already in the default search path.
Bram Moolenaar446cb832008-06-24 21:56:24 +0000294dnl Skip all of this when cross-compiling.
295if test "$cross_compiling" = no; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000296 AC_MSG_CHECKING(--with-local-dir argument)
Bram Moolenaar446cb832008-06-24 21:56:24 +0000297 have_local_include=''
298 have_local_lib=''
Bram Moolenaarc236c162008-07-13 17:41:49 +0000299 AC_ARG_WITH([local-dir], [ --with-local-dir=PATH search PATH instead of /usr/local for local libraries.
300 --without-local-dir do not search /usr/local for local libraries.], [
301 local_dir="$withval"
302 case "$withval" in
303 */*) ;;
304 no)
305 # avoid adding local dir to LDFLAGS and CPPFLAGS
Bram Moolenaare06c1882010-07-21 22:05:20 +0200306 have_local_include=yes
Bram Moolenaarc236c162008-07-13 17:41:49 +0000307 have_local_lib=yes
308 ;;
309 *) AC_MSG_ERROR(must pass path argument to --with-local-dir) ;;
310 esac
311 AC_MSG_RESULT($local_dir)
312 ], [
313 local_dir=/usr/local
314 AC_MSG_RESULT(Defaulting to $local_dir)
315 ])
316 if test "$GCC" = yes -a "$local_dir" != no; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000317 echo 'void f(){}' > conftest.c
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100318 dnl Removed -no-cpp-precomp, only needed for OS X 10.2 (Ben Fowler)
319 have_local_include=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/include"`
Bram Moolenaarc236c162008-07-13 17:41:49 +0000320 have_local_lib=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/lib"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000321 rm -f conftest.c conftest.o
Bram Moolenaar071d4272004-06-13 20:20:40 +0000322 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000323 if test -z "$have_local_lib" -a -d "${local_dir}/lib"; then
324 tt=`echo "$LDFLAGS" | sed -e "s+-L${local_dir}/lib ++g" -e "s+-L${local_dir}/lib$++g"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000325 if test "$tt" = "$LDFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000326 LDFLAGS="$LDFLAGS -L${local_dir}/lib"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000327 fi
328 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000329 if test -z "$have_local_include" -a -d "${local_dir}/include"; then
330 tt=`echo "$CPPFLAGS" | sed -e "s+-I${local_dir}/include ++g" -e "s+-I${local_dir}/include$++g"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000331 if test "$tt" = "$CPPFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000332 CPPFLAGS="$CPPFLAGS -I${local_dir}/include"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000333 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000334 fi
335fi
336
337AC_MSG_CHECKING(--with-vim-name argument)
338AC_ARG_WITH(vim-name, [ --with-vim-name=NAME what to call the Vim executable],
339 VIMNAME="$withval"; AC_MSG_RESULT($VIMNAME),
Bram Moolenaare344bea2005-09-01 20:46:49 +0000340 VIMNAME="vim"; AC_MSG_RESULT(Defaulting to $VIMNAME))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000341AC_SUBST(VIMNAME)
342AC_MSG_CHECKING(--with-ex-name argument)
343AC_ARG_WITH(ex-name, [ --with-ex-name=NAME what to call the Ex executable],
344 EXNAME="$withval"; AC_MSG_RESULT($EXNAME),
345 EXNAME="ex"; AC_MSG_RESULT(Defaulting to ex))
346AC_SUBST(EXNAME)
347AC_MSG_CHECKING(--with-view-name argument)
348AC_ARG_WITH(view-name, [ --with-view-name=NAME what to call the View executable],
349 VIEWNAME="$withval"; AC_MSG_RESULT($VIEWNAME),
350 VIEWNAME="view"; AC_MSG_RESULT(Defaulting to view))
351AC_SUBST(VIEWNAME)
352
353AC_MSG_CHECKING(--with-global-runtime argument)
Bram Moolenaar9d302ad2018-12-21 11:48:51 +0100354AC_ARG_WITH(global-runtime, [ --with-global-runtime=DIR global runtime directory in 'runtimepath', comma-separated for multiple directories],
355 RUNTIME_GLOBAL="$withval"; AC_MSG_RESULT($withval),
Bram Moolenaar071d4272004-06-13 20:20:40 +0000356 AC_MSG_RESULT(no))
357
Bram Moolenaar9d302ad2018-12-21 11:48:51 +0100358if test "X$RUNTIME_GLOBAL" != "X"; then
359 RUNTIME_GLOBAL_AFTER=$(printf -- "$RUNTIME_GLOBAL\\n" | $AWK -F, 'BEGIN { comma=0 } { for (i = NF; i > 0; i--) { if (comma) { printf ",%s/after", $i } else { printf "%s/after", $i; comma=1 } } } END { printf "\n" }')
360 AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL, "$RUNTIME_GLOBAL")
361 AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL_AFTER, "$RUNTIME_GLOBAL_AFTER")
362fi
363
Bram Moolenaar071d4272004-06-13 20:20:40 +0000364AC_MSG_CHECKING(--with-modified-by argument)
365AC_ARG_WITH(modified-by, [ --with-modified-by=NAME name of who modified a release version],
366 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(MODIFIED_BY, "$withval"),
367 AC_MSG_RESULT(no))
368
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200369dnl Check for EBCDIC stolen from the LYNX port to z/OS Unix
Bram Moolenaar071d4272004-06-13 20:20:40 +0000370AC_MSG_CHECKING(if character set is EBCDIC)
371AC_TRY_COMPILE([ ],
372[ /* TryCompile function for CharSet.
373 Treat any failure as ASCII for compatibility with existing art.
374 Use compile-time rather than run-time tests for cross-compiler
375 tolerance. */
376#if '0'!=240
377make an error "Character set is not EBCDIC"
378#endif ],
379[ # TryCompile action if true
380cf_cv_ebcdic=yes ],
381[ # TryCompile action if false
382cf_cv_ebcdic=no])
383# end of TryCompile ])
384# end of CacheVal CvEbcdic
385AC_MSG_RESULT($cf_cv_ebcdic)
386case "$cf_cv_ebcdic" in #(vi
387 yes) AC_DEFINE(EBCDIC)
388 line_break='"\\n"'
389 ;;
390 *) line_break='"\\012"';;
391esac
392AC_SUBST(line_break)
393
394if test "$cf_cv_ebcdic" = "yes"; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +0200395dnl If we have EBCDIC we most likely have z/OS Unix, let's test it!
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200396AC_MSG_CHECKING(for z/OS Unix)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000397case `uname` in
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200398 OS/390) zOSUnix="yes";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000399 dnl If using cc the environment variable _CC_CCMODE must be
400 dnl set to "1", so that some compiler extensions are enabled.
401 dnl If using c89 the environment variable is named _CC_C89MODE.
402 dnl Note: compile with c89 never tested.
403 if test "$CC" = "cc"; then
404 ccm="$_CC_CCMODE"
405 ccn="CC"
406 else
407 if test "$CC" = "c89"; then
408 ccm="$_CC_C89MODE"
409 ccn="C89"
410 else
411 ccm=1
412 fi
413 fi
414 if test "$ccm" != "1"; then
415 echo ""
416 echo "------------------------------------------"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200417 echo " On z/OS Unix, the environment variable"
Bram Moolenaar77c19352012-06-13 19:19:41 +0200418 echo " _CC_${ccn}MODE must be set to \"1\"!"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000419 echo " Do:"
420 echo " export _CC_${ccn}MODE=1"
421 echo " and then call configure again."
422 echo "------------------------------------------"
423 exit 1
424 fi
Bram Moolenaar77c19352012-06-13 19:19:41 +0200425 # Set CFLAGS for configure process.
426 # This will be reset later for config.mk.
427 # Use haltonmsg to force error for missing H files.
428 CFLAGS="$CFLAGS -D_ALL_SOURCE -Wc,float(ieee),haltonmsg(3296)";
429 LDFLAGS="$LDFLAGS -Wl,EDIT=NO"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000430 AC_MSG_RESULT(yes)
431 ;;
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200432 *) zOSUnix="no";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000433 AC_MSG_RESULT(no)
434 ;;
435esac
436fi
437
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200438dnl Set QUOTESED. Needs additional backslashes on zOS
439if test "$zOSUnix" = "yes"; then
440 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\\\\\&/g' -e 's/\\\\\\\\\"/\"/' -e 's/\\\\\\\\\";\$\$/\";/'"
441else
442 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\&/g' -e 's/\\\\\"/\"/' -e 's/\\\\\";\$\$/\";/'"
443fi
444AC_SUBST(QUOTESED)
445
446
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200447dnl Link with -lsmack for Smack stuff; if not found
448AC_MSG_CHECKING(--disable-smack argument)
449AC_ARG_ENABLE(smack,
450 [ --disable-smack Do not check for Smack support.],
451 , enable_smack="yes")
452if test "$enable_smack" = "yes"; then
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200453 AC_MSG_RESULT(no)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200454 AC_CHECK_HEADER([linux/xattr.h], true, enable_smack="no")
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200455else
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200456 AC_MSG_RESULT(yes)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200457fi
458if test "$enable_smack" = "yes"; then
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200459 AC_CHECK_HEADER([attr/xattr.h], true, enable_smack="no")
460fi
461if test "$enable_smack" = "yes"; then
462 AC_MSG_CHECKING(for XATTR_NAME_SMACKEXEC in linux/xattr.h)
463 AC_EGREP_CPP(XATTR_NAME_SMACKEXEC, [#include <linux/xattr.h>],
464 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +0200465 AC_MSG_RESULT(no); enable_smack="no")
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200466fi
467if test "$enable_smack" = "yes"; then
468 AC_CHECK_LIB(attr, setxattr,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200469 [LIBS="$LIBS -lattr"
470 found_smack="yes"
471 AC_DEFINE(HAVE_SMACK)])
Bram Moolenaar588ebeb2008-05-07 17:09:24 +0000472fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000473
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200474dnl When smack was found don't search for SELinux
475if test "x$found_smack" = "x"; then
476 dnl Link with -lselinux for SELinux stuff; if not found
477 AC_MSG_CHECKING(--disable-selinux argument)
478 AC_ARG_ENABLE(selinux,
479 [ --disable-selinux Do not check for SELinux support.],
480 , enable_selinux="yes")
481 if test "$enable_selinux" = "yes"; then
482 AC_MSG_RESULT(no)
483 AC_CHECK_LIB(selinux, is_selinux_enabled,
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100484 [AC_CHECK_HEADER(selinux/selinux.h,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200485 [LIBS="$LIBS -lselinux"
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100486 AC_DEFINE(HAVE_SELINUX)])])
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200487 else
488 AC_MSG_RESULT(yes)
489 fi
490fi
491
Bram Moolenaar071d4272004-06-13 20:20:40 +0000492dnl Check user requested features.
493
494AC_MSG_CHECKING(--with-features argument)
Bram Moolenaareec29812016-07-26 21:27:36 +0200495AC_ARG_WITH(features, [ --with-features=TYPE tiny, small, normal, big or huge (default: huge)],
Bram Moolenaar071d4272004-06-13 20:20:40 +0000496 features="$withval"; AC_MSG_RESULT($features),
Bram Moolenaar23c4f712016-01-20 22:11:59 +0100497 features="huge"; AC_MSG_RESULT(Defaulting to huge))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000498
499dovimdiff=""
500dogvimdiff=""
501case "$features" in
502 tiny) AC_DEFINE(FEAT_TINY) ;;
503 small) AC_DEFINE(FEAT_SMALL) ;;
504 normal) AC_DEFINE(FEAT_NORMAL) dovimdiff="installvimdiff";
505 dogvimdiff="installgvimdiff" ;;
506 big) AC_DEFINE(FEAT_BIG) dovimdiff="installvimdiff";
507 dogvimdiff="installgvimdiff" ;;
508 huge) AC_DEFINE(FEAT_HUGE) dovimdiff="installvimdiff";
509 dogvimdiff="installgvimdiff" ;;
510 *) AC_MSG_RESULT([Sorry, $features is not supported]) ;;
511esac
512
513AC_SUBST(dovimdiff)
514AC_SUBST(dogvimdiff)
515
516AC_MSG_CHECKING(--with-compiledby argument)
517AC_ARG_WITH(compiledby, [ --with-compiledby=NAME name to show in :version message],
518 compiledby="$withval"; AC_MSG_RESULT($withval),
519 compiledby=""; AC_MSG_RESULT(no))
520AC_SUBST(compiledby)
521
522AC_MSG_CHECKING(--disable-xsmp argument)
523AC_ARG_ENABLE(xsmp,
524 [ --disable-xsmp Disable XSMP session management],
525 , enable_xsmp="yes")
526
527if test "$enable_xsmp" = "yes"; then
528 AC_MSG_RESULT(no)
529 AC_MSG_CHECKING(--disable-xsmp-interact argument)
530 AC_ARG_ENABLE(xsmp-interact,
531 [ --disable-xsmp-interact Disable XSMP interaction],
532 , enable_xsmp_interact="yes")
533 if test "$enable_xsmp_interact" = "yes"; then
534 AC_MSG_RESULT(no)
535 AC_DEFINE(USE_XSMP_INTERACT)
536 else
537 AC_MSG_RESULT(yes)
538 fi
539else
540 AC_MSG_RESULT(yes)
541fi
542
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200543dnl Check for Lua feature.
544AC_MSG_CHECKING(--enable-luainterp argument)
545AC_ARG_ENABLE(luainterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200546 [ --enable-luainterp[=OPTS] Include Lua interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200547 [enable_luainterp="no"])
548AC_MSG_RESULT($enable_luainterp)
549
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200550if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +0100551 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
552 AC_MSG_ERROR([cannot use Lua with tiny or small features])
553 fi
554
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200555 dnl -- find the lua executable
556 AC_SUBST(vi_cv_path_lua)
557
558 AC_MSG_CHECKING(--with-lua-prefix argument)
559 AC_ARG_WITH(lua_prefix,
560 [ --with-lua-prefix=PFX Prefix where Lua is installed.],
561 with_lua_prefix="$withval"; AC_MSG_RESULT($with_lua_prefix),
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200562 with_lua_prefix="";AC_MSG_RESULT(no))
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200563
564 if test "X$with_lua_prefix" != "X"; then
565 vi_cv_path_lua_pfx="$with_lua_prefix"
566 else
567 AC_MSG_CHECKING(LUA_PREFIX environment var)
568 if test "X$LUA_PREFIX" != "X"; then
569 AC_MSG_RESULT("$LUA_PREFIX")
570 vi_cv_path_lua_pfx="$LUA_PREFIX"
571 else
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200572 AC_MSG_RESULT([not set, default to /usr])
573 vi_cv_path_lua_pfx="/usr"
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200574 fi
575 fi
576
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200577 AC_MSG_CHECKING(--with-luajit)
578 AC_ARG_WITH(luajit,
579 [ --with-luajit Link with LuaJIT instead of Lua.],
580 [vi_cv_with_luajit="$withval"],
581 [vi_cv_with_luajit="no"])
582 AC_MSG_RESULT($vi_cv_with_luajit)
583
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200584 LUA_INC=
585 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200586 if test "x$vi_cv_with_luajit" != "xno"; then
587 dnl -- try to find LuaJIT executable
588 AC_PATH_PROG(vi_cv_path_luajit, luajit)
589 if test "X$vi_cv_path_luajit" != "X"; then
590 dnl -- find LuaJIT version
591 AC_CACHE_CHECK(LuaJIT version, vi_cv_version_luajit,
Bram Moolenaar49b10272013-11-21 12:17:51 +0100592 [ vi_cv_version_luajit=`${vi_cv_path_luajit} -v 2>&1 | sed 's/LuaJIT \([[0-9.]]*\)\.[[0-9]]\(-[[a-z0-9]]*\)* .*/\1/'` ])
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200593 AC_CACHE_CHECK(Lua version of LuaJIT, vi_cv_version_lua_luajit,
594 [ vi_cv_version_lua_luajit=`${vi_cv_path_luajit} -e "print(_VERSION)" | sed 's/.* //'` ])
595 vi_cv_path_lua="$vi_cv_path_luajit"
596 vi_cv_version_lua="$vi_cv_version_lua_luajit"
597 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200598 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200599 dnl -- try to find Lua executable
600 AC_PATH_PROG(vi_cv_path_plain_lua, lua)
601 if test "X$vi_cv_path_plain_lua" != "X"; then
602 dnl -- find Lua version
603 AC_CACHE_CHECK(Lua version, vi_cv_version_plain_lua,
604 [ vi_cv_version_plain_lua=`${vi_cv_path_plain_lua} -e "print(_VERSION)" | sed 's/.* //'` ])
605 fi
606 vi_cv_path_lua="$vi_cv_path_plain_lua"
607 vi_cv_version_lua="$vi_cv_version_plain_lua"
608 fi
609 if test "x$vi_cv_with_luajit" != "xno" && test "X$vi_cv_version_luajit" != "X"; then
610 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit)
Bram Moolenaar49222be2015-12-11 18:11:30 +0100611 if test -f "$vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200612 AC_MSG_RESULT(yes)
613 LUA_INC=/luajit-$vi_cv_version_luajit
614 fi
615 fi
616 if test "X$LUA_INC" = "X"; then
617 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)
Bram Moolenaar49222be2015-12-11 18:11:30 +0100618 if test -f "$vi_cv_path_lua_pfx/include/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200619 AC_MSG_RESULT(yes)
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200620 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200621 AC_MSG_RESULT(no)
622 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua)
Bram Moolenaar49222be2015-12-11 18:11:30 +0100623 if test -f "$vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200624 AC_MSG_RESULT(yes)
625 LUA_INC=/lua$vi_cv_version_lua
626 else
627 AC_MSG_RESULT(no)
628 vi_cv_path_lua_pfx=
629 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200630 fi
631 fi
632 fi
633
634 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200635 if test "x$vi_cv_with_luajit" != "xno"; then
636 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
637 if test "X$multiarch" != "X"; then
638 lib_multiarch="lib/${multiarch}"
639 else
640 lib_multiarch="lib"
641 fi
642 if test "X$vi_cv_version_lua" = "X"; then
643 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit"
644 else
645 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit-$vi_cv_version_lua"
646 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200647 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200648 if test "X$LUA_INC" != "X"; then
649 dnl Test alternate location using version
650 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua$vi_cv_version_lua"
651 else
652 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua"
653 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200654 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200655 if test "$enable_luainterp" = "dynamic"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200656 lua_ok="yes"
657 else
658 AC_MSG_CHECKING([if link with ${LUA_LIBS} is sane])
659 libs_save=$LIBS
660 LIBS="$LIBS $LUA_LIBS"
661 AC_TRY_LINK(,[ ],
662 AC_MSG_RESULT(yes); lua_ok="yes",
663 AC_MSG_RESULT(no); lua_ok="no"; LUA_LIBS="")
664 LIBS=$libs_save
665 fi
666 if test "x$lua_ok" = "xyes"; then
667 LUA_CFLAGS="-I${vi_cv_path_lua_pfx}/include${LUA_INC}"
668 LUA_SRC="if_lua.c"
669 LUA_OBJ="objects/if_lua.o"
670 LUA_PRO="if_lua.pro"
671 AC_DEFINE(FEAT_LUA)
672 fi
673 if test "$enable_luainterp" = "dynamic"; then
674 if test "x$vi_cv_with_luajit" != "xno"; then
675 luajit="jit"
676 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200677 if test -f "${vi_cv_path_lua_pfx}/bin/cyglua-${vi_cv_version_lua}.dll"; then
678 vi_cv_dll_name_lua="cyglua-${vi_cv_version_lua}.dll"
679 else
Bram Moolenaard0573012017-10-28 21:11:06 +0200680 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200681 ext="dylib"
682 indexes=""
683 else
684 ext="so"
685 indexes=".0 .1 .2 .3 .4 .5 .6 .7 .8 .9"
686 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
687 if test "X$multiarch" != "X"; then
688 lib_multiarch="lib/${multiarch}"
689 fi
Bram Moolenaar768baac2013-04-15 14:44:57 +0200690 fi
691 dnl Determine the sover for the current version, but fallback to
692 dnl liblua${vi_cv_version_lua}.so if no sover-versioned file is found.
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200693 AC_MSG_CHECKING(if liblua${luajit}*.${ext}* can be found in $vi_cv_path_lua_pfx)
Bram Moolenaar768baac2013-04-15 14:44:57 +0200694 for subdir in "${lib_multiarch}" lib64 lib; do
695 if test -z "$subdir"; then
696 continue
697 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200698 for sover in "${vi_cv_version_lua}.${ext}" "-${vi_cv_version_lua}.${ext}" \
699 ".${vi_cv_version_lua}.${ext}" ".${ext}.${vi_cv_version_lua}"; do
700 for i in $indexes ""; do
701 if test -f "${vi_cv_path_lua_pfx}/${subdir}/liblua${luajit}${sover}$i"; then
Bram Moolenaar768baac2013-04-15 14:44:57 +0200702 sover2="$i"
703 break 3
704 fi
705 done
Bram Moolenaar07e1da62013-02-06 19:49:43 +0100706 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200707 sover=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200708 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200709 if test "X$sover" = "X"; then
710 AC_MSG_RESULT(no)
711 lua_ok="no"
712 vi_cv_dll_name_lua="liblua${luajit}.${ext}"
713 else
714 AC_MSG_RESULT(yes)
715 lua_ok="yes"
716 vi_cv_dll_name_lua="liblua${luajit}${sover}$sover2"
717 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200718 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200719 AC_DEFINE(DYNAMIC_LUA)
720 LUA_LIBS=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200721 LUA_CFLAGS="-DDYNAMIC_LUA_DLL=\\\"${vi_cv_dll_name_lua}\\\" $LUA_CFLAGS"
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200722 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200723 if test "X$LUA_CFLAGS$LUA_LIBS" != "X" && \
Bram Moolenaard0573012017-10-28 21:11:06 +0200724 test "x$MACOS_X" = "xyes" && test "x$vi_cv_with_luajit" != "xno" && \
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200725 test "`(uname -m) 2>/dev/null`" = "x86_64"; then
726 dnl OSX/x64 requires these flags. See http://luajit.org/install.html
727 LUA_LIBS="-pagezero_size 10000 -image_base 100000000 $LUA_LIBS"
728 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200729 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200730 if test "$fail_if_missing" = "yes" -a "$lua_ok" != "yes"; then
Bram Moolenaarf788a062011-12-14 20:51:25 +0100731 AC_MSG_ERROR([could not configure lua])
732 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200733 AC_SUBST(LUA_SRC)
734 AC_SUBST(LUA_OBJ)
735 AC_SUBST(LUA_PRO)
736 AC_SUBST(LUA_LIBS)
737 AC_SUBST(LUA_CFLAGS)
738fi
739
740
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000741dnl Check for MzScheme feature.
742AC_MSG_CHECKING(--enable-mzschemeinterp argument)
743AC_ARG_ENABLE(mzschemeinterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200744 [ --enable-mzschemeinterp Include MzScheme interpreter.], ,
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000745 [enable_mzschemeinterp="no"])
746AC_MSG_RESULT($enable_mzschemeinterp)
747
748if test "$enable_mzschemeinterp" = "yes"; then
749 dnl -- find the mzscheme executable
750 AC_SUBST(vi_cv_path_mzscheme)
751
752 AC_MSG_CHECKING(--with-plthome argument)
753 AC_ARG_WITH(plthome,
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000754 [ --with-plthome=PLTHOME Use PLTHOME.],
755 with_plthome="$withval"; AC_MSG_RESULT($with_plthome),
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000756 with_plthome="";AC_MSG_RESULT("no"))
757
758 if test "X$with_plthome" != "X"; then
759 vi_cv_path_mzscheme_pfx="$with_plthome"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100760 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000761 else
762 AC_MSG_CHECKING(PLTHOME environment var)
763 if test "X$PLTHOME" != "X"; then
764 AC_MSG_RESULT("$PLTHOME")
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000765 vi_cv_path_mzscheme_pfx="$PLTHOME"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100766 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000767 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000768 AC_MSG_RESULT(not set)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000769 dnl -- try to find MzScheme executable
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000770 AC_PATH_PROG(vi_cv_path_mzscheme, mzscheme)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000771
772 dnl resolve symbolic link, the executable is often elsewhere and there
773 dnl are no links for the include files.
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000774 if test "X$vi_cv_path_mzscheme" != "X"; then
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000775 lsout=`ls -l $vi_cv_path_mzscheme`
776 if echo "$lsout" | grep -e '->' >/dev/null 2>/dev/null; then
777 vi_cv_path_mzscheme=`echo "$lsout" | sed 's/.*-> \(.*\)/\1/'`
778 fi
779 fi
780
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000781 if test "X$vi_cv_path_mzscheme" != "X"; then
782 dnl -- find where MzScheme thinks it was installed
783 AC_CACHE_CHECK(MzScheme install prefix,vi_cv_path_mzscheme_pfx,
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000784 dnl different versions of MzScheme differ in command line processing
785 dnl use universal approach
786 echo "(display (simplify-path \
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000787 (build-path (call-with-values \
788 (lambda () (split-path (find-system-path (quote exec-file)))) \
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000789 (lambda (base name must-be-dir?) base)) (quote up))))" > mzdirs.scm
790 dnl Remove a trailing slash
791 [ vi_cv_path_mzscheme_pfx=`${vi_cv_path_mzscheme} -r mzdirs.scm | \
792 sed -e 's+/$++'` ])
793 rm -f mzdirs.scm
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000794 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000795 fi
796 fi
797
798 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100799 AC_MSG_CHECKING(for racket include directory)
800 SCHEME_INC=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-include-dir))) (when (path? p) (display p)))'`
801 if test "X$SCHEME_INC" != "X"; then
802 AC_MSG_RESULT(${SCHEME_INC})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000803 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100804 AC_MSG_RESULT(not found)
805 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include)
806 if test -f "$vi_cv_path_mzscheme_pfx/include/scheme.h"; then
807 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000808 AC_MSG_RESULT(yes)
Bram Moolenaard7afed32007-05-06 13:26:41 +0000809 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000810 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100811 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt)
812 if test -f "$vi_cv_path_mzscheme_pfx/include/plt/scheme.h"; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000813 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100814 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000815 else
816 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100817 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket)
818 if test -f "$vi_cv_path_mzscheme_pfx/include/racket/scheme.h"; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100819 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100820 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100821 else
822 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100823 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/)
824 if test -f /usr/include/plt/scheme.h; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100825 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100826 SCHEME_INC=/usr/include/plt
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100827 else
828 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100829 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/racket/)
830 if test -f /usr/include/racket/scheme.h; then
831 AC_MSG_RESULT(yes)
832 SCHEME_INC=/usr/include/racket
833 else
834 AC_MSG_RESULT(no)
835 vi_cv_path_mzscheme_pfx=
836 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100837 fi
838 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000839 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000840 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000841 fi
842 fi
843
844 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100845
846 AC_MSG_CHECKING(for racket lib directory)
847 SCHEME_LIB=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-lib-dir))) (when (path? p) (display p)))'`
848 if test "X$SCHEME_LIB" != "X"; then
849 AC_MSG_RESULT(${SCHEME_LIB})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000850 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100851 AC_MSG_RESULT(not found)
852 fi
853
854 for path in "${vi_cv_path_mzscheme_pfx}/lib" "${SCHEME_LIB}"; do
855 if test "X$path" != "X"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200856 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100857 MZSCHEME_LIBS="-framework Racket"
858 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
859 elif test -f "${path}/libmzscheme3m.a"; then
860 MZSCHEME_LIBS="${path}/libmzscheme3m.a"
861 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
862 elif test -f "${path}/libracket3m.a"; then
863 MZSCHEME_LIBS="${path}/libracket3m.a"
864 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
865 elif test -f "${path}/libracket.a"; then
866 MZSCHEME_LIBS="${path}/libracket.a ${path}/libmzgc.a"
867 elif test -f "${path}/libmzscheme.a"; then
868 MZSCHEME_LIBS="${path}/libmzscheme.a ${path}/libmzgc.a"
869 else
870 dnl Using shared objects
871 if test -f "${path}/libmzscheme3m.so"; then
872 MZSCHEME_LIBS="-L${path} -lmzscheme3m"
873 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
874 elif test -f "${path}/libracket3m.so"; then
875 MZSCHEME_LIBS="-L${path} -lracket3m"
876 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
877 elif test -f "${path}/libracket.so"; then
878 MZSCHEME_LIBS="-L${path} -lracket -lmzgc"
879 else
880 dnl try next until last
881 if test "$path" != "$SCHEME_LIB"; then
882 continue
883 fi
884 MZSCHEME_LIBS="-L${path} -lmzscheme -lmzgc"
885 fi
886 if test "$GCC" = yes; then
887 dnl Make Vim remember the path to the library. For when it's not in
888 dnl $LD_LIBRARY_PATH.
889 MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${path}"
890 elif test "`(uname) 2>/dev/null`" = SunOS &&
891 uname -r | grep '^5' >/dev/null; then
892 MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${path}"
893 fi
894 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000895 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100896 if test "X$MZSCHEME_LIBS" != "X"; then
897 break
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +0000898 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100899 done
900
901 AC_MSG_CHECKING([if racket requires -pthread])
902 if test "X$SCHEME_LIB" != "X" && $FGREP -e -pthread "$SCHEME_LIB/buildinfo" >/dev/null ; then
903 AC_MSG_RESULT(yes)
904 MZSCHEME_LIBS="${MZSCHEME_LIBS} -pthread"
905 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -pthread"
906 else
907 AC_MSG_RESULT(no)
908 fi
909
910 AC_MSG_CHECKING(for racket config directory)
911 SCHEME_CONFIGDIR=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-config-dir))) (when (path? p) (display p)))'`
912 if test "X$SCHEME_CONFIGDIR" != "X"; then
913 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DMZSCHEME_CONFIGDIR='\"${SCHEME_CONFIGDIR}\"'"
914 AC_MSG_RESULT(${SCHEME_CONFIGDIR})
915 else
916 AC_MSG_RESULT(not found)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000917 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100918
919 AC_MSG_CHECKING(for racket collects directory)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100920 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))))'`
921 if test "X$SCHEME_COLLECTS" = "X"; then
922 if test -d "$vi_cv_path_mzscheme_pfx/lib/plt/collects"; then
923 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/plt/
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100924 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100925 if test -d "$vi_cv_path_mzscheme_pfx/lib/racket/collects"; then
926 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/racket/
Bram Moolenaar75676462013-01-30 14:55:42 +0100927 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100928 if test -d "$vi_cv_path_mzscheme_pfx/share/racket/collects"; then
929 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/
930 else
931 if test -d "$vi_cv_path_mzscheme_pfx/collects"; then
932 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/
933 fi
Bram Moolenaar75676462013-01-30 14:55:42 +0100934 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100935 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100936 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000937 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100938 if test "X$SCHEME_COLLECTS" != "X" ; then
939 AC_MSG_RESULT(${SCHEME_COLLECTS})
940 else
941 AC_MSG_RESULT(not found)
942 fi
943
944 AC_MSG_CHECKING(for mzscheme_base.c)
945 if test -f "${SCHEME_COLLECTS}collects/scheme/base.ss" ; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000946 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +0100947 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
948 MZSCHEME_MOD="++lib scheme/base"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100949 else
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100950 if test -f "${SCHEME_COLLECTS}collects/scheme/base.rkt" ; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100951 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +0100952 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
953 MZSCHEME_MOD="++lib scheme/base"
954 else
955 if test -f "${SCHEME_COLLECTS}collects/racket/base.rkt" ; then
956 MZSCHEME_EXTRA="mzscheme_base.c"
957 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/raco ctool"
958 MZSCHEME_MOD=""
959 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100960 fi
961 fi
962 if test "X$MZSCHEME_EXTRA" != "X" ; then
963 dnl need to generate bytecode for MzScheme base
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000964 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE"
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100965 AC_MSG_RESULT(needed)
966 else
967 AC_MSG_RESULT(not needed)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000968 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100969
Bram Moolenaar9e902192013-07-17 18:58:11 +0200970 dnl On Ubuntu this fixes "undefined reference to symbol 'ffi_type_void'".
971 AC_CHECK_LIB(ffi, ffi_type_void, [MZSCHEME_LIBS="$MZSCHEME_LIBS -lffi"])
972
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000973 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -I${SCHEME_INC} \
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100974 -DMZSCHEME_COLLECTS='\"${SCHEME_COLLECTS}collects\"'"
Bram Moolenaar9e902192013-07-17 18:58:11 +0200975
976 dnl Test that we can compile a simple program with these CFLAGS and LIBS.
977 AC_MSG_CHECKING([if compile and link flags for MzScheme are sane])
978 cflags_save=$CFLAGS
979 libs_save=$LIBS
980 CFLAGS="$CFLAGS $MZSCHEME_CFLAGS"
981 LIBS="$LIBS $MZSCHEME_LIBS"
982 AC_TRY_LINK(,[ ],
983 AC_MSG_RESULT(yes); mzs_ok=yes,
984 AC_MSG_RESULT(no: MZSCHEME DISABLED); mzs_ok=no)
985 CFLAGS=$cflags_save
986 LIBS=$libs_save
987 if test $mzs_ok = yes; then
988 MZSCHEME_SRC="if_mzsch.c"
989 MZSCHEME_OBJ="objects/if_mzsch.o"
990 MZSCHEME_PRO="if_mzsch.pro"
991 AC_DEFINE(FEAT_MZSCHEME)
992 else
993 MZSCHEME_CFLAGS=
994 MZSCHEME_LIBS=
995 MZSCHEME_EXTRA=
996 MZSCHEME_MZC=
997 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000998 fi
999 AC_SUBST(MZSCHEME_SRC)
1000 AC_SUBST(MZSCHEME_OBJ)
1001 AC_SUBST(MZSCHEME_PRO)
1002 AC_SUBST(MZSCHEME_LIBS)
1003 AC_SUBST(MZSCHEME_CFLAGS)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001004 AC_SUBST(MZSCHEME_EXTRA)
1005 AC_SUBST(MZSCHEME_MZC)
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001006fi
1007
1008
Bram Moolenaar071d4272004-06-13 20:20:40 +00001009AC_MSG_CHECKING(--enable-perlinterp argument)
1010AC_ARG_ENABLE(perlinterp,
Bram Moolenaare06c1882010-07-21 22:05:20 +02001011 [ --enable-perlinterp[=OPTS] Include Perl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001012 [enable_perlinterp="no"])
1013AC_MSG_RESULT($enable_perlinterp)
Bram Moolenaare06c1882010-07-21 22:05:20 +02001014if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01001015 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1016 AC_MSG_ERROR([cannot use Perl with tiny or small features])
1017 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001018 AC_SUBST(vi_cv_path_perl)
1019 AC_PATH_PROG(vi_cv_path_perl, perl)
1020 if test "X$vi_cv_path_perl" != "X"; then
1021 AC_MSG_CHECKING(Perl version)
1022 if $vi_cv_path_perl -e 'require 5.003_01' >/dev/null 2>/dev/null; then
1023 eval `$vi_cv_path_perl -V:usethreads`
Bram Moolenaare06c1882010-07-21 22:05:20 +02001024 eval `$vi_cv_path_perl -V:libperl`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001025 if test "X$usethreads" = "XUNKNOWN" -o "X$usethreads" = "Xundef"; then
1026 badthreads=no
1027 else
1028 if $vi_cv_path_perl -e 'require 5.6.0' >/dev/null 2>/dev/null; then
1029 eval `$vi_cv_path_perl -V:use5005threads`
1030 if test "X$use5005threads" = "XUNKNOWN" -o "X$use5005threads" = "Xundef"; then
1031 badthreads=no
1032 else
1033 badthreads=yes
1034 AC_MSG_RESULT(>>> Perl > 5.6 with 5.5 threads cannot be used <<<)
1035 fi
1036 else
1037 badthreads=yes
1038 AC_MSG_RESULT(>>> Perl 5.5 with threads cannot be used <<<)
1039 fi
1040 fi
1041 if test $badthreads = no; then
1042 AC_MSG_RESULT(OK)
1043 eval `$vi_cv_path_perl -V:shrpenv`
1044 if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04
1045 shrpenv=""
1046 fi
1047 vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlibexp}'`
1048 AC_SUBST(vi_cv_perllib)
Bram Moolenaard5f62b12014-08-17 17:05:44 +02001049 vi_cv_perl_extutils=unknown_perl_extutils_path
1050 for extutils_rel_path in ExtUtils vendor_perl/ExtUtils; do
1051 xsubpp_path="$vi_cv_perllib/$extutils_rel_path/xsubpp"
1052 if test -f "$xsubpp_path"; then
1053 vi_cv_perl_xsubpp="$xsubpp_path"
1054 fi
1055 done
1056 AC_SUBST(vi_cv_perl_xsubpp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001057 dnl Remove "-fno-something", it breaks using cproto.
Bram Moolenaar280a8682015-06-21 13:41:08 +02001058 dnl Remove "-fdebug-prefix-map", it isn't supported by clang.
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001059 dnl Remove "FORTIFY_SOURCE", it will be defined twice.
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001060 dnl remove -pipe and -Wxxx, it confuses cproto
Bram Moolenaar071d4272004-06-13 20:20:40 +00001061 perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001062 -e 'ccflags;perl_inc;print"\n"' | sed -e 's/-fno[[^ ]]*//' \
1063 -e 's/-fdebug-prefix-map[[^ ]]*//g' \
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001064 -e 's/-pipe //' \
1065 -e 's/-W[[^ ]]*//g' \
1066 -e 's/-D_FORTIFY_SOURCE=.//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001067 dnl Remove "-lc", it breaks on FreeBSD when using "-pthread".
1068 perllibs=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed -e 'ldopts' | \
1069 sed -e '/Warning/d' -e '/Note (probably harmless)/d' \
1070 -e 's/-bE:perl.exp//' -e 's/-lc //'`
1071 dnl Don't add perl lib to $LIBS: if it's not in LD_LIBRARY_PATH
1072 dnl a test in configure may fail because of that.
1073 perlldflags=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed \
1074 -e 'ccdlflags' | sed -e 's/-bE:perl.exp//'`
1075
1076 dnl check that compiling a simple program still works with the flags
1077 dnl added for Perl.
1078 AC_MSG_CHECKING([if compile and link flags for Perl are sane])
1079 cflags_save=$CFLAGS
1080 libs_save=$LIBS
1081 ldflags_save=$LDFLAGS
1082 CFLAGS="$CFLAGS $perlcppflags"
1083 LIBS="$LIBS $perllibs"
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001084 perlldflags=`echo "$perlldflags" | sed -e 's/^ *//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001085 LDFLAGS="$perlldflags $LDFLAGS"
1086 AC_TRY_LINK(,[ ],
1087 AC_MSG_RESULT(yes); perl_ok=yes,
1088 AC_MSG_RESULT(no: PERL DISABLED); perl_ok=no)
1089 CFLAGS=$cflags_save
1090 LIBS=$libs_save
1091 LDFLAGS=$ldflags_save
1092 if test $perl_ok = yes; then
1093 if test "X$perlcppflags" != "X"; then
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001094 PERL_CFLAGS=$perlcppflags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001095 fi
1096 if test "X$perlldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001097 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$perlldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001098 LDFLAGS="$perlldflags $LDFLAGS"
1099 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001100 fi
1101 PERL_LIBS=$perllibs
1102 PERL_SRC="auto/if_perl.c if_perlsfio.c"
1103 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o"
1104 PERL_PRO="if_perl.pro if_perlsfio.pro"
1105 AC_DEFINE(FEAT_PERL)
1106 fi
1107 fi
1108 else
1109 AC_MSG_RESULT(>>> too old; need Perl version 5.003_01 or later <<<)
1110 fi
1111 fi
1112
Bram Moolenaard0573012017-10-28 21:11:06 +02001113 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00001114 dnl Mac OS X 10.2 or later
Bram Moolenaar071d4272004-06-13 20:20:40 +00001115 dir=/System/Library/Perl
1116 darwindir=$dir/darwin
1117 if test -d $darwindir; then
1118 PERL=/usr/bin/perl
1119 else
1120 dnl Mac OS X 10.3
1121 dir=/System/Library/Perl/5.8.1
1122 darwindir=$dir/darwin-thread-multi-2level
1123 if test -d $darwindir; then
1124 PERL=/usr/bin/perl
1125 fi
1126 fi
1127 if test -n "$PERL"; then
1128 PERL_DIR="$dir"
1129 PERL_CFLAGS="-DFEAT_PERL -I$darwindir/CORE"
1130 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o $darwindir/auto/DynaLoader/DynaLoader.a"
1131 PERL_LIBS="-L$darwindir/CORE -lperl"
1132 fi
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001133 dnl Perl on Mac OS X 10.5 adds "-arch" flags but these should only
1134 dnl be included if requested by passing --with-mac-arch to
1135 dnl configure, so strip these flags first (if present)
1136 PERL_LIBS=`echo "$PERL_LIBS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
1137 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 +00001138 fi
Bram Moolenaare06c1882010-07-21 22:05:20 +02001139 if test "$enable_perlinterp" = "dynamic"; then
1140 if test "$perl_ok" = "yes" -a "X$libperl" != "X"; then
1141 AC_DEFINE(DYNAMIC_PERL)
1142 PERL_CFLAGS="-DDYNAMIC_PERL_DLL=\\\"$libperl\\\" $PERL_CFLAGS"
1143 fi
1144 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001145
1146 if test "$fail_if_missing" = "yes" -a "$perl_ok" != "yes"; then
1147 AC_MSG_ERROR([could not configure perl])
1148 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001149fi
1150AC_SUBST(shrpenv)
1151AC_SUBST(PERL_SRC)
1152AC_SUBST(PERL_OBJ)
1153AC_SUBST(PERL_PRO)
1154AC_SUBST(PERL_CFLAGS)
1155AC_SUBST(PERL_LIBS)
1156
1157AC_MSG_CHECKING(--enable-pythoninterp argument)
1158AC_ARG_ENABLE(pythoninterp,
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001159 [ --enable-pythoninterp[=OPTS] Include Python interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001160 [enable_pythoninterp="no"])
1161AC_MSG_RESULT($enable_pythoninterp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001162if test "$enable_pythoninterp" = "yes" -o "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001163 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1164 AC_MSG_ERROR([cannot use Python with tiny or small features])
1165 fi
1166
Bram Moolenaar071d4272004-06-13 20:20:40 +00001167 dnl -- find the python executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001168 AC_MSG_CHECKING(--with-python-command argument)
1169 AC_SUBST(vi_cv_path_python)
1170 AC_ARG_WITH(python-command, [ --with-python-command=NAME name of the Python 2 command (default: python2 or python)],
1171 vi_cv_path_python="$withval"; AC_MSG_RESULT($vi_cv_path_python),
1172 AC_MSG_RESULT(no))
1173
1174 if test "X$vi_cv_path_python" = "X"; then
1175 AC_PATH_PROGS(vi_cv_path_python, python2 python)
1176 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001177 if test "X$vi_cv_path_python" != "X"; then
1178
1179 dnl -- get its version number
1180 AC_CACHE_CHECK(Python version,vi_cv_var_python_version,
1181 [[vi_cv_var_python_version=`
1182 ${vi_cv_path_python} -c 'import sys; print sys.version[:3]'`
1183 ]])
1184
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001185 dnl -- it must be at least version 2.3
1186 AC_MSG_CHECKING(Python is 2.3 or better)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001187 if ${vi_cv_path_python} -c \
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001188 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001189 then
1190 AC_MSG_RESULT(yep)
1191
1192 dnl -- find where python thinks it was installed
1193 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python_pfx,
1194 [ vi_cv_path_python_pfx=`
1195 ${vi_cv_path_python} -c \
1196 "import sys; print sys.prefix"` ])
1197
1198 dnl -- and where it thinks it runs
1199 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python_epfx,
1200 [ vi_cv_path_python_epfx=`
1201 ${vi_cv_path_python} -c \
1202 "import sys; print sys.exec_prefix"` ])
1203
1204 dnl -- python's internal library path
1205
1206 AC_CACHE_VAL(vi_cv_path_pythonpath,
1207 [ vi_cv_path_pythonpath=`
1208 unset PYTHONPATH;
1209 ${vi_cv_path_python} -c \
1210 "import sys, string; print string.join(sys.path,':')"` ])
1211
1212 dnl -- where the Python implementation library archives are
1213
1214 AC_ARG_WITH(python-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001215 [ --with-python-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001216 [ vi_cv_path_python_conf="${withval}"; have_python_config_dir=1 ] )
Bram Moolenaar071d4272004-06-13 20:20:40 +00001217
1218 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python_conf,
1219 [
1220 vi_cv_path_python_conf=
Bram Moolenaarac499e32013-06-02 19:14:17 +02001221 d=`${vi_cv_path_python} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBPL')"`
1222 if test -d "$d" && test -f "$d/config.c"; then
1223 vi_cv_path_python_conf="$d"
1224 else
1225 for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
1226 for subdir in lib64 lib share; do
1227 d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
1228 if test -d "$d" && test -f "$d/config.c"; then
1229 vi_cv_path_python_conf="$d"
1230 fi
1231 done
Bram Moolenaar071d4272004-06-13 20:20:40 +00001232 done
Bram Moolenaarac499e32013-06-02 19:14:17 +02001233 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001234 ])
1235
1236 PYTHON_CONFDIR="${vi_cv_path_python_conf}"
1237
1238 if test "X$PYTHON_CONFDIR" = "X"; then
1239 AC_MSG_RESULT([can't find it!])
1240 else
1241
1242 dnl -- we need to examine Python's config/Makefile too
1243 dnl see what the interpreter is built from
1244 AC_CACHE_VAL(vi_cv_path_python_plibs,
1245 [
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001246 pwd=`pwd`
1247 tmp_mkf="$pwd/config-PyMake$$"
1248 cat -- "${PYTHON_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001249__:
Bram Moolenaar218116c2010-05-20 21:46:00 +02001250 @echo "python_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001251 @echo "python_LIBS='$(LIBS)'"
1252 @echo "python_SYSLIBS='$(SYSLIBS)'"
1253 @echo "python_LINKFORSHARED='$(LINKFORSHARED)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001254 @echo "python_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001255 @echo "python_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001256 @echo "python_PYTHONFRAMEWORK='$(PYTHONFRAMEWORK)'"
1257 @echo "python_PYTHONFRAMEWORKPREFIX='$(PYTHONFRAMEWORKPREFIX)'"
1258 @echo "python_PYTHONFRAMEWORKINSTALLDIR='$(PYTHONFRAMEWORKINSTALLDIR)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001259eof
1260 dnl -- delete the lines from make about Entering/Leaving directory
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001261 eval "`cd ${PYTHON_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1262 rm -f -- "${tmp_mkf}"
Bram Moolenaard0573012017-10-28 21:11:06 +02001263 if test "x$MACOS_X" = "xyes" && test -n "${python_PYTHONFRAMEWORK}" && ${vi_cv_path_python} -c \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001264 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then
1265 vi_cv_path_python_plibs="-framework Python"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001266 if test "x${vi_cv_path_python}" != "x/usr/bin/python" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
1267 vi_cv_path_python_plibs="-F${python_PYTHONFRAMEWORKPREFIX} -framework Python"
1268 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001269 else
Bram Moolenaar9ce42132018-04-11 22:19:36 +02001270 vi_cv_path_python_plibs="-L${PYTHON_CONFDIR} -lpython${vi_cv_var_python_version}"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001271 dnl -- Check if the path contained in python_LINKFORSHARED is
1272 dnl usable for vim build. If not, make and try other
1273 dnl candidates.
Bram Moolenaara161e262015-03-24 15:14:27 +01001274 if test -n "${python_LINKFORSHARED}" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
Bram Moolenaar6c927552015-03-24 12:21:33 +01001275 python_link_symbol=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]].*/\1/'`
1276 python_link_path=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]][[ \t]]*\(.*\)/\2/'`
1277 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1278 dnl -- The path looks relative. Guess the absolute one using
1279 dnl the prefix and try that.
1280 python_link_path="${python_PYTHONFRAMEWORKPREFIX}/${python_link_path}"
1281 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1282 dnl -- A last resort.
1283 python_link_path="${python_PYTHONFRAMEWORKINSTALLDIR}/Versions/${vi_cv_var_python_version}/${python_PYTHONFRAMEWORK}"
1284 dnl -- No check is done. The last word is left to the
1285 dnl "sanity" test on link flags that follows shortly.
1286 fi
1287 python_LINKFORSHARED="${python_link_symbol} ${python_link_path}"
1288 fi
1289 fi
Bram Moolenaar218116c2010-05-20 21:46:00 +02001290 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 +00001291 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1292 vi_cv_path_python_plibs=`echo $vi_cv_path_python_plibs | sed s/-ltermcap//`
1293 fi
1294 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001295 AC_CACHE_CHECK(Python's dll name,vi_cv_dll_name_python,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001296 [
1297 if test "X$python_DLLLIBRARY" != "X"; then
1298 vi_cv_dll_name_python="$python_DLLLIBRARY"
1299 else
1300 vi_cv_dll_name_python="$python_INSTSONAME"
1301 fi
1302 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00001303
1304 PYTHON_LIBS="${vi_cv_path_python_plibs}"
1305 if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001306 PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001307 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001308 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 +00001309 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001310 if test "X$have_python_config_dir" = "X1" -a "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001311 dnl Define PYTHON_HOME if --with-python-config-dir was used
1312 PYTHON_CFLAGS="${PYTHON_CFLAGS} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'"
1313
1314 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001315 PYTHON_SRC="if_python.c"
Bram Moolenaar9bdb9a02012-07-25 16:32:08 +02001316 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001317
1318 dnl On FreeBSD linking with "-pthread" is required to use threads.
1319 dnl _THREAD_SAFE must be used for compiling then.
1320 dnl The "-pthread" is added to $LIBS, so that the following check for
1321 dnl sigaltstack() will look in libc_r (it's there in libc!).
1322 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1323 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1324 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1325 AC_MSG_CHECKING([if -pthread should be used])
1326 threadsafe_flag=
1327 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001328 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00001329 if test "`(uname) 2>/dev/null`" != Darwin; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001330 test "$GCC" = yes && threadsafe_flag="-pthread"
1331 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1332 threadsafe_flag="-D_THREAD_SAFE"
1333 thread_lib="-pthread"
1334 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001335 if test "`(uname) 2>/dev/null`" = SunOS; then
1336 threadsafe_flag="-pthreads"
1337 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001338 fi
1339 libs_save_old=$LIBS
1340 if test -n "$threadsafe_flag"; then
1341 cflags_save=$CFLAGS
1342 CFLAGS="$CFLAGS $threadsafe_flag"
1343 LIBS="$LIBS $thread_lib"
1344 AC_TRY_LINK(,[ ],
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001345 AC_MSG_RESULT(yes); PYTHON_CFLAGS="$PYTHON_CFLAGS $threadsafe_flag",
Bram Moolenaar071d4272004-06-13 20:20:40 +00001346 AC_MSG_RESULT(no); LIBS=$libs_save_old
1347 )
1348 CFLAGS=$cflags_save
1349 else
1350 AC_MSG_RESULT(no)
1351 fi
1352
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001353 dnl Check that compiling a simple program still works with the flags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001354 dnl added for Python.
1355 AC_MSG_CHECKING([if compile and link flags for Python are sane])
1356 cflags_save=$CFLAGS
1357 libs_save=$LIBS
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001358 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001359 LIBS="$LIBS $PYTHON_LIBS"
1360 AC_TRY_LINK(,[ ],
1361 AC_MSG_RESULT(yes); python_ok=yes,
1362 AC_MSG_RESULT(no: PYTHON DISABLED); python_ok=no)
1363 CFLAGS=$cflags_save
1364 LIBS=$libs_save
1365 if test $python_ok = yes; then
1366 AC_DEFINE(FEAT_PYTHON)
1367 else
1368 LIBS=$libs_save_old
1369 PYTHON_SRC=
1370 PYTHON_OBJ=
1371 PYTHON_LIBS=
1372 PYTHON_CFLAGS=
1373 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001374 fi
1375 else
1376 AC_MSG_RESULT(too old)
1377 fi
1378 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001379
1380 if test "$fail_if_missing" = "yes" -a "$python_ok" != "yes"; then
1381 AC_MSG_ERROR([could not configure python])
1382 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001383fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001384
Bram Moolenaar071d4272004-06-13 20:20:40 +00001385AC_SUBST(PYTHON_LIBS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001386AC_SUBST(PYTHON_CFLAGS)
1387AC_SUBST(PYTHON_SRC)
1388AC_SUBST(PYTHON_OBJ)
1389
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001390
1391AC_MSG_CHECKING(--enable-python3interp argument)
1392AC_ARG_ENABLE(python3interp,
Bram Moolenaar8008b632017-07-18 21:33:20 +02001393 [ --enable-python3interp[=OPTS] Include Python3 interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001394 [enable_python3interp="no"])
1395AC_MSG_RESULT($enable_python3interp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001396if test "$enable_python3interp" = "yes" -o "$enable_python3interp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001397 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1398 AC_MSG_ERROR([cannot use Python with tiny or small features])
1399 fi
1400
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001401 dnl -- find the python3 executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001402 AC_MSG_CHECKING(--with-python3-command argument)
1403 AC_SUBST(vi_cv_path_python3)
1404 AC_ARG_WITH(python3-command, [ --with-python3-command=NAME name of the Python 3 command (default: python3 or python)],
1405 vi_cv_path_python3="$withval"; AC_MSG_RESULT($vi_cv_path_python3),
1406 AC_MSG_RESULT(no))
1407
1408 if test "X$vi_cv_path_python3" = "X"; then
1409 AC_PATH_PROGS(vi_cv_path_python3, python3 python)
1410 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001411 if test "X$vi_cv_path_python3" != "X"; then
1412
1413 dnl -- get its version number
1414 AC_CACHE_CHECK(Python version,vi_cv_var_python3_version,
1415 [[vi_cv_var_python3_version=`
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001416 ${vi_cv_path_python3} -c 'import sys; print(sys.version[:3])'`
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001417 ]])
1418
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001419 dnl -- it must be at least version 3
1420 AC_MSG_CHECKING(Python is 3.0 or better)
1421 if ${vi_cv_path_python3} -c \
1422 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.0)"
1423 then
1424 AC_MSG_RESULT(yep)
Bram Moolenaar456f2bb2011-06-12 21:37:13 +02001425
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001426 dnl -- get abiflags for python 3.2 or higher (PEP 3149)
1427 AC_CACHE_CHECK(Python's abiflags,vi_cv_var_python3_abiflags,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001428 [
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001429 vi_cv_var_python3_abiflags=
1430 if ${vi_cv_path_python3} -c \
1431 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)"
1432 then
1433 vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \
1434 "import sys; print(sys.abiflags)"`
1435 fi ])
1436
1437 dnl -- find where python3 thinks it was installed
1438 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx,
1439 [ vi_cv_path_python3_pfx=`
1440 ${vi_cv_path_python3} -c \
1441 "import sys; print(sys.prefix)"` ])
1442
1443 dnl -- and where it thinks it runs
1444 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx,
1445 [ vi_cv_path_python3_epfx=`
1446 ${vi_cv_path_python3} -c \
1447 "import sys; print(sys.exec_prefix)"` ])
1448
1449 dnl -- python3's internal library path
1450
1451 AC_CACHE_VAL(vi_cv_path_python3path,
1452 [ vi_cv_path_python3path=`
1453 unset PYTHONPATH;
1454 ${vi_cv_path_python3} -c \
1455 "import sys, string; print(':'.join(sys.path))"` ])
1456
1457 dnl -- where the Python implementation library archives are
1458
1459 AC_ARG_WITH(python3-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001460 [ --with-python3-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001461 [ vi_cv_path_python3_conf="${withval}"; have_python3_config_dir=1 ] )
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001462
1463 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf,
1464 [
1465 vi_cv_path_python3_conf=
Bram Moolenaarfee496d2013-07-12 20:07:24 +02001466 config_dir="config-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001467 d=`${vi_cv_path_python3} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBPL'))"`
1468 if test -d "$d" && test -f "$d/config.c"; then
1469 vi_cv_path_python3_conf="$d"
1470 else
1471 for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do
1472 for subdir in lib64 lib share; do
1473 d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}"
1474 if test -d "$d" && test -f "$d/config.c"; then
1475 vi_cv_path_python3_conf="$d"
1476 fi
1477 done
1478 done
1479 fi
1480 ])
1481
1482 PYTHON3_CONFDIR="${vi_cv_path_python3_conf}"
1483
1484 if test "X$PYTHON3_CONFDIR" = "X"; then
1485 AC_MSG_RESULT([can't find it!])
1486 else
1487
1488 dnl -- we need to examine Python's config/Makefile too
1489 dnl see what the interpreter is built from
1490 AC_CACHE_VAL(vi_cv_path_python3_plibs,
1491 [
1492 pwd=`pwd`
1493 tmp_mkf="$pwd/config-PyMake$$"
1494 cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001495__:
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001496 @echo "python3_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001497 @echo "python3_LIBS='$(LIBS)'"
1498 @echo "python3_SYSLIBS='$(SYSLIBS)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001499 @echo "python3_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001500 @echo "python3_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001501eof
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001502 dnl -- delete the lines from make about Entering/Leaving directory
1503 eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1504 rm -f -- "${tmp_mkf}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001505 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 +02001506 vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}"
1507 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1508 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//`
1509 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//`
1510 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001511 AC_CACHE_CHECK(Python3's dll name,vi_cv_dll_name_python3,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001512 [
1513 if test "X$python3_DLLLIBRARY" != "X"; then
1514 vi_cv_dll_name_python3="$python3_DLLLIBRARY"
1515 else
1516 vi_cv_dll_name_python3="$python3_INSTSONAME"
1517 fi
1518 ])
1519
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001520 PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
1521 if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001522 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 +02001523 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001524 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 +02001525 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001526 if test "X$have_python3_config_dir" = "X1" -a "$enable_python3interp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001527 dnl Define PYTHON3_HOME if --with-python-config-dir was used
1528 PYTHON3_CFLAGS="${PYTHON3_CFLAGS} -DPYTHON3_HOME='L\"${vi_cv_path_python3_pfx}\"'"
1529 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001530 PYTHON3_SRC="if_python3.c"
1531 PYTHON3_OBJ="objects/if_python3.o"
1532
1533 dnl On FreeBSD linking with "-pthread" is required to use threads.
1534 dnl _THREAD_SAFE must be used for compiling then.
1535 dnl The "-pthread" is added to $LIBS, so that the following check for
1536 dnl sigaltstack() will look in libc_r (it's there in libc!).
1537 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1538 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1539 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1540 AC_MSG_CHECKING([if -pthread should be used])
1541 threadsafe_flag=
1542 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001543 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001544 if test "`(uname) 2>/dev/null`" != Darwin; then
1545 test "$GCC" = yes && threadsafe_flag="-pthread"
1546 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1547 threadsafe_flag="-D_THREAD_SAFE"
1548 thread_lib="-pthread"
1549 fi
1550 if test "`(uname) 2>/dev/null`" = SunOS; then
1551 threadsafe_flag="-pthreads"
1552 fi
1553 fi
1554 libs_save_old=$LIBS
1555 if test -n "$threadsafe_flag"; then
1556 cflags_save=$CFLAGS
1557 CFLAGS="$CFLAGS $threadsafe_flag"
1558 LIBS="$LIBS $thread_lib"
1559 AC_TRY_LINK(,[ ],
1560 AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag",
1561 AC_MSG_RESULT(no); LIBS=$libs_save_old
1562 )
1563 CFLAGS=$cflags_save
1564 else
1565 AC_MSG_RESULT(no)
1566 fi
1567
1568 dnl check that compiling a simple program still works with the flags
1569 dnl added for Python.
1570 AC_MSG_CHECKING([if compile and link flags for Python 3 are sane])
1571 cflags_save=$CFLAGS
1572 libs_save=$LIBS
1573 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1574 LIBS="$LIBS $PYTHON3_LIBS"
1575 AC_TRY_LINK(,[ ],
1576 AC_MSG_RESULT(yes); python3_ok=yes,
1577 AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no)
1578 CFLAGS=$cflags_save
1579 LIBS=$libs_save
1580 if test "$python3_ok" = yes; then
1581 AC_DEFINE(FEAT_PYTHON3)
1582 else
1583 LIBS=$libs_save_old
1584 PYTHON3_SRC=
1585 PYTHON3_OBJ=
1586 PYTHON3_LIBS=
1587 PYTHON3_CFLAGS=
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001588 fi
1589 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001590 else
1591 AC_MSG_RESULT(too old)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001592 fi
1593 fi
Bram Moolenaar1612b1a2013-06-14 21:22:39 +02001594 if test "$fail_if_missing" = "yes" -a "$python3_ok" != "yes"; then
1595 AC_MSG_ERROR([could not configure python3])
1596 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001597fi
1598
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001599AC_SUBST(PYTHON3_LIBS)
1600AC_SUBST(PYTHON3_CFLAGS)
1601AC_SUBST(PYTHON3_SRC)
1602AC_SUBST(PYTHON3_OBJ)
1603
1604dnl if python2.x and python3.x are enabled one can only link in code
1605dnl with dlopen(), dlsym(), dlclose()
1606if test "$python_ok" = yes && test "$python3_ok" = yes; then
1607 AC_DEFINE(DYNAMIC_PYTHON)
1608 AC_DEFINE(DYNAMIC_PYTHON3)
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001609 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001610 cflags_save=$CFLAGS
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001611 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001612 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001613 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001614 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001615 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001616 #include <dlfcn.h>
1617 /* If this program fails, then RTLD_GLOBAL is needed.
1618 * RTLD_GLOBAL will be used and then it is not possible to
1619 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001620 * Only the first python version used will be switched on.
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001621 */
1622
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001623 int no_rtl_global_needed_for(char *python_instsoname, char *prefix)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001624 {
1625 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001626 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001627 if (pylib != 0)
1628 {
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001629 void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome");
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001630 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1631 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1632 void (*final)(void) = dlsym(pylib, "Py_Finalize");
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001633 (*pfx)(prefix);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001634 (*init)();
1635 needed = (*simple)("import termios") == -1;
1636 (*final)();
1637 dlclose(pylib);
1638 }
1639 return !needed;
1640 }
1641
1642 int main(int argc, char** argv)
1643 {
1644 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001645 if (no_rtl_global_needed_for("${vi_cv_dll_name_python}", "${vi_cv_path_python_pfx}"))
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001646 not_needed = 1;
1647 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001648 }])],
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001649 [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001650
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001651 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001652 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001653
1654 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python3)
1655 cflags_save=$CFLAGS
1656 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001657 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001658 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001659 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001660 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001661 #include <dlfcn.h>
1662 #include <wchar.h>
1663 /* If this program fails, then RTLD_GLOBAL is needed.
1664 * RTLD_GLOBAL will be used and then it is not possible to
1665 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001666 * Only the first python version used will be switched on.
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001667 */
1668
1669 int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix)
1670 {
1671 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001672 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001673 if (pylib != 0)
1674 {
1675 void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome");
1676 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1677 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1678 void (*final)(void) = dlsym(pylib, "Py_Finalize");
1679 (*pfx)(prefix);
1680 (*init)();
1681 needed = (*simple)("import termios") == -1;
1682 (*final)();
1683 dlclose(pylib);
1684 }
1685 return !needed;
1686 }
1687
1688 int main(int argc, char** argv)
1689 {
1690 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001691 if (no_rtl_global_needed_for("${vi_cv_dll_name_python3}", L"${vi_cv_path_python3_pfx}"))
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001692 not_needed = 1;
1693 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001694 }])],
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001695 [AC_MSG_RESULT(yes);AC_DEFINE(PY3_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
1696
1697 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001698 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001699
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001700 PYTHON_SRC="if_python.c"
1701 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001702 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001703 PYTHON_LIBS=
1704 PYTHON3_SRC="if_python3.c"
1705 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001706 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001707 PYTHON3_LIBS=
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001708elif test "$python_ok" = yes && test "$enable_pythoninterp" = "dynamic"; then
1709 AC_DEFINE(DYNAMIC_PYTHON)
1710 PYTHON_SRC="if_python.c"
1711 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001712 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001713 PYTHON_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001714elif test "$python_ok" = yes; then
1715 dnl Check that adding -fPIE works. It may be needed when using a static
1716 dnl Python library.
1717 AC_MSG_CHECKING([if -fPIE can be added for Python])
1718 cflags_save=$CFLAGS
1719 libs_save=$LIBS
1720 CFLAGS="$CFLAGS $PYTHON_CFLAGS -fPIE"
1721 LIBS="$LIBS $PYTHON_LIBS"
1722 AC_TRY_LINK(,[ ],
1723 AC_MSG_RESULT(yes); fpie_ok=yes,
1724 AC_MSG_RESULT(no); fpie_ok=no)
1725 CFLAGS=$cflags_save
1726 LIBS=$libs_save
1727 if test $fpie_ok = yes; then
1728 PYTHON_CFLAGS="$PYTHON_CFLAGS -fPIE"
1729 fi
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001730elif test "$python3_ok" = yes && test "$enable_python3interp" = "dynamic"; then
1731 AC_DEFINE(DYNAMIC_PYTHON3)
1732 PYTHON3_SRC="if_python3.c"
1733 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001734 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001735 PYTHON3_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001736elif test "$python3_ok" = yes; then
1737 dnl Check that adding -fPIE works. It may be needed when using a static
1738 dnl Python library.
1739 AC_MSG_CHECKING([if -fPIE can be added for Python3])
1740 cflags_save=$CFLAGS
1741 libs_save=$LIBS
1742 CFLAGS="$CFLAGS $PYTHON3_CFLAGS -fPIE"
1743 LIBS="$LIBS $PYTHON3_LIBS"
1744 AC_TRY_LINK(,[ ],
1745 AC_MSG_RESULT(yes); fpie_ok=yes,
1746 AC_MSG_RESULT(no); fpie_ok=no)
1747 CFLAGS=$cflags_save
1748 LIBS=$libs_save
1749 if test $fpie_ok = yes; then
1750 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -fPIE"
1751 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001752fi
1753
Bram Moolenaar071d4272004-06-13 20:20:40 +00001754AC_MSG_CHECKING(--enable-tclinterp argument)
1755AC_ARG_ENABLE(tclinterp,
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001756 [ --enable-tclinterp[=OPTS] Include Tcl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001757 [enable_tclinterp="no"])
1758AC_MSG_RESULT($enable_tclinterp)
1759
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001760if test "$enable_tclinterp" = "yes" -o "$enable_tclinterp" = "dynamic"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001761
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001762 dnl on FreeBSD tclsh is a silly script, look for tclsh8.[5420]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001763 AC_MSG_CHECKING(--with-tclsh argument)
1764 AC_ARG_WITH(tclsh, [ --with-tclsh=PATH which tclsh to use (default: tclsh8.0)],
1765 tclsh_name="$withval"; AC_MSG_RESULT($tclsh_name),
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001766 tclsh_name="tclsh8.5"; AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00001767 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1768 AC_SUBST(vi_cv_path_tcl)
1769
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001770 dnl when no specific version specified, also try 8.4, 8.2 and 8.0
1771 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.5"; then
1772 tclsh_name="tclsh8.4"
1773 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1774 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001775 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.4"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001776 tclsh_name="tclsh8.2"
1777 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1778 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001779 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.2"; then
1780 tclsh_name="tclsh8.0"
1781 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1782 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001783 dnl still didn't find it, try without version number
1784 if test "X$vi_cv_path_tcl" = "X"; then
1785 tclsh_name="tclsh"
1786 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1787 fi
1788 if test "X$vi_cv_path_tcl" != "X"; then
1789 AC_MSG_CHECKING(Tcl version)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001790 if echo 'exit [[expr [info tclversion] < 8.0]]' | "$vi_cv_path_tcl" - ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001791 tclver=`echo 'puts [[info tclversion]]' | $vi_cv_path_tcl -`
1792 AC_MSG_RESULT($tclver - OK);
1793 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 +01001794 tcldll=`echo 'puts libtcl[[info tclversion]][[info sharedlibextension]]' | $vi_cv_path_tcl -`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001795
1796 AC_MSG_CHECKING(for location of Tcl include)
Bram Moolenaard0573012017-10-28 21:11:06 +02001797 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001798 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 +00001799 else
1800 dnl For Mac OS X 10.3, use the OS-provided framework location
1801 tclinc="/System/Library/Frameworks/Tcl.framework/Headers"
1802 fi
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001803 TCL_INC=
Bram Moolenaar071d4272004-06-13 20:20:40 +00001804 for try in $tclinc; do
1805 if test -f "$try/tcl.h"; then
1806 AC_MSG_RESULT($try/tcl.h)
1807 TCL_INC=$try
1808 break
1809 fi
1810 done
1811 if test -z "$TCL_INC"; then
1812 AC_MSG_RESULT(<not found>)
1813 SKIP_TCL=YES
1814 fi
1815 if test -z "$SKIP_TCL"; then
1816 AC_MSG_CHECKING(for location of tclConfig.sh script)
Bram Moolenaard0573012017-10-28 21:11:06 +02001817 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001818 tclcnf=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001819 tclcnf="$tclcnf `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001820 else
1821 dnl For Mac OS X 10.3, use the OS-provided framework location
1822 tclcnf="/System/Library/Frameworks/Tcl.framework"
1823 fi
1824 for try in $tclcnf; do
Bram Moolenaar49222be2015-12-11 18:11:30 +01001825 if test -f "$try/tclConfig.sh"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001826 AC_MSG_RESULT($try/tclConfig.sh)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001827 . "$try/tclConfig.sh"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001828 dnl use eval, because tcl 8.2 includes ${TCL_DBGX}
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001829 if test "$enable_tclinterp" = "dynamic"; then
1830 TCL_LIBS=`eval echo "$TCL_STUB_LIB_SPEC $TCL_LIBS"`
1831 else
1832 TCL_LIBS=`eval echo "$TCL_LIB_SPEC $TCL_LIBS"`
1833 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001834 dnl Use $TCL_DEFS for -D_THREAD_SAFE et al. But only use the
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001835 dnl "-D_ABC" items. Watch out for -DFOO=long\ long.
Bram Moolenaar4394bff2008-07-24 11:21:31 +00001836 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 +00001837 break
1838 fi
1839 done
1840 if test -z "$TCL_LIBS"; then
1841 AC_MSG_RESULT(<not found>)
1842 AC_MSG_CHECKING(for Tcl library by myself)
1843 tcllib=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001844 tcllib="$tcllib `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001845 for ext in .so .a ; do
1846 for ver in "" $tclver ; do
1847 for try in $tcllib ; do
1848 trylib=tcl$ver$ext
Bram Moolenaar49222be2015-12-11 18:11:30 +01001849 if test -f "$try/lib$trylib" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001850 AC_MSG_RESULT($try/lib$trylib)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001851 TCL_LIBS="-L\"$try\" -ltcl$ver -ldl -lm"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001852 if test "`(uname) 2>/dev/null`" = SunOS &&
1853 uname -r | grep '^5' >/dev/null; then
1854 TCL_LIBS="$TCL_LIBS -R $try"
1855 fi
1856 break 3
1857 fi
1858 done
1859 done
1860 done
1861 if test -z "$TCL_LIBS"; then
1862 AC_MSG_RESULT(<not found>)
1863 SKIP_TCL=YES
1864 fi
1865 fi
1866 if test -z "$SKIP_TCL"; then
1867 AC_DEFINE(FEAT_TCL)
1868 TCL_SRC=if_tcl.c
1869 TCL_OBJ=objects/if_tcl.o
1870 TCL_PRO=if_tcl.pro
1871 TCL_CFLAGS="-I$TCL_INC $TCL_DEFS"
1872 fi
1873 fi
1874 else
1875 AC_MSG_RESULT(too old; need Tcl version 8.0 or later)
1876 fi
1877 fi
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001878 if test "$enable_tclinterp" = "dynamic"; then
1879 if test "X$TCL_SRC" != "X" -a "X$tcldll" != "X"; then
1880 AC_DEFINE(DYNAMIC_TCL)
1881 TCL_CFLAGS="-DDYNAMIC_TCL_DLL=\\\"$tcldll\\\" -DDYNAMIC_TCL_VER=\\\"$tclver\\\" $TCL_CFLAGS"
1882 fi
1883 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001884 if test "$fail_if_missing" = "yes" -a -z "$TCL_SRC"; then
1885 AC_MSG_ERROR([could not configure Tcl])
1886 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001887fi
1888AC_SUBST(TCL_SRC)
1889AC_SUBST(TCL_OBJ)
1890AC_SUBST(TCL_PRO)
1891AC_SUBST(TCL_CFLAGS)
1892AC_SUBST(TCL_LIBS)
1893
1894AC_MSG_CHECKING(--enable-rubyinterp argument)
1895AC_ARG_ENABLE(rubyinterp,
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001896 [ --enable-rubyinterp[=OPTS] Include Ruby interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001897 [enable_rubyinterp="no"])
1898AC_MSG_RESULT($enable_rubyinterp)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001899if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001900 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1901 AC_MSG_ERROR([cannot use Ruby with tiny or small features])
1902 fi
1903
Bram Moolenaar165641d2010-02-17 16:23:09 +01001904 AC_MSG_CHECKING(--with-ruby-command argument)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001905 AC_SUBST(vi_cv_path_ruby)
Bram Moolenaar948733a2011-05-05 18:10:16 +02001906 AC_ARG_WITH(ruby-command, [ --with-ruby-command=RUBY name of the Ruby command (default: ruby)],
1907 RUBY_CMD="$withval"; vi_cv_path_ruby="$withval"; AC_MSG_RESULT($RUBY_CMD),
1908 RUBY_CMD="ruby"; AC_MSG_RESULT(defaulting to $RUBY_CMD))
Bram Moolenaar165641d2010-02-17 16:23:09 +01001909 AC_PATH_PROG(vi_cv_path_ruby, $RUBY_CMD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001910 if test "X$vi_cv_path_ruby" != "X"; then
1911 AC_MSG_CHECKING(Ruby version)
Bram Moolenaare4efc3b2005-03-07 23:16:51 +00001912 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 +00001913 AC_MSG_RESULT(OK)
Bram Moolenaar81398892012-10-03 21:09:35 +02001914 AC_MSG_CHECKING(Ruby rbconfig)
1915 ruby_rbconfig="RbConfig"
1916 if ! $vi_cv_path_ruby -r rbconfig -e 'RbConfig' >/dev/null 2>/dev/null; then
1917 ruby_rbconfig="Config"
1918 fi
1919 AC_MSG_RESULT($ruby_rbconfig)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001920 AC_MSG_CHECKING(Ruby header files)
Bram Moolenaar81398892012-10-03 21:09:35 +02001921 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 +00001922 if test "X$rubyhdrdir" != "X"; then
1923 AC_MSG_RESULT($rubyhdrdir)
1924 RUBY_CFLAGS="-I$rubyhdrdir"
Bram Moolenaara6fd37b2014-03-27 17:19:09 +01001925 rubyarchdir=`$vi_cv_path_ruby -r rbconfig -e "print ($ruby_rbconfig::CONFIG.has_key? 'rubyarchhdrdir') ? $ruby_rbconfig::CONFIG[['rubyarchhdrdir']] : '$rubyhdrdir/'+$ruby_rbconfig::CONFIG[['arch']]"`
1926 if test -d "$rubyarchdir"; then
1927 RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyarchdir"
Bram Moolenaar165641d2010-02-17 16:23:09 +01001928 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001929 rubyversion=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['ruby_version']].gsub(/\./, '')[[0,2]]"`
Bram Moolenaar026a4452013-08-07 15:22:23 +02001930 if test "X$rubyversion" = "X"; then
1931 rubyversion=`$vi_cv_path_ruby -e "print ((VERSION rescue RUBY_VERSION)).gsub(/\./, '')[[0,2]]"`
1932 fi
Bram Moolenaar165641d2010-02-17 16:23:09 +01001933 RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
Bram Moolenaar81398892012-10-03 21:09:35 +02001934 rubylibs=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LIBS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001935 if test "X$rubylibs" != "X"; then
1936 RUBY_LIBS="$rubylibs"
1937 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001938 librubyarg=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBYARG']])"`
1939 librubya=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBY_A']])"`
Bram Moolenaarac499e32013-06-02 19:14:17 +02001940 rubylibdir=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['libdir']])"`
Bram Moolenaar948733a2011-05-05 18:10:16 +02001941 if test -f "$rubylibdir/$librubya"; then
1942 librubyarg="$librubyarg"
Bram Moolenaarac499e32013-06-02 19:14:17 +02001943 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
1944 elif test "$librubyarg" = "libruby.a"; then
1945 dnl required on Mac OS 10.3 where libruby.a doesn't exist
1946 librubyarg="-lruby"
1947 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001948 fi
1949
1950 if test "X$librubyarg" != "X"; then
1951 RUBY_LIBS="$librubyarg $RUBY_LIBS"
1952 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001953 rubyldflags=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LDFLAGS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001954 if test "X$rubyldflags" != "X"; then
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001955 dnl Ruby on Mac OS X 10.5 adds "-arch" flags but these should only
1956 dnl be included if requested by passing --with-mac-arch to
1957 dnl configure, so strip these flags first (if present)
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001958 rubyldflags=`echo "$rubyldflags" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001959 if test "X$rubyldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001960 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$rubyldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001961 LDFLAGS="$rubyldflags $LDFLAGS"
1962 fi
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001963 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001964 fi
1965 RUBY_SRC="if_ruby.c"
1966 RUBY_OBJ="objects/if_ruby.o"
1967 RUBY_PRO="if_ruby.pro"
1968 AC_DEFINE(FEAT_RUBY)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001969 if test "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar92021622017-10-12 12:33:43 +02001970 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_ALIASES']].split[[0]]"`
Bram Moolenaar87ea64c2018-08-04 15:13:34 +02001971 if test -z "$libruby_soname"; then
1972 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_SO']]"`
1973 fi
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001974 AC_DEFINE(DYNAMIC_RUBY)
Bram Moolenaar41a41412020-01-07 21:32:19 +01001975 RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby_soname\\\" $RUBY_CFLAGS"
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001976 RUBY_LIBS=
1977 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001978 else
Bram Moolenaar165641d2010-02-17 16:23:09 +01001979 AC_MSG_RESULT(not found; disabling Ruby)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001980 fi
1981 else
1982 AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
1983 fi
1984 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001985
1986 if test "$fail_if_missing" = "yes" -a -z "$RUBY_OBJ"; then
1987 AC_MSG_ERROR([could not configure Ruby])
1988 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001989fi
1990AC_SUBST(RUBY_SRC)
1991AC_SUBST(RUBY_OBJ)
1992AC_SUBST(RUBY_PRO)
1993AC_SUBST(RUBY_CFLAGS)
1994AC_SUBST(RUBY_LIBS)
1995
1996AC_MSG_CHECKING(--enable-cscope argument)
1997AC_ARG_ENABLE(cscope,
1998 [ --enable-cscope Include cscope interface.], ,
1999 [enable_cscope="no"])
2000AC_MSG_RESULT($enable_cscope)
2001if test "$enable_cscope" = "yes"; then
2002 AC_DEFINE(FEAT_CSCOPE)
2003fi
2004
Bram Moolenaar071d4272004-06-13 20:20:40 +00002005AC_MSG_CHECKING(--disable-netbeans argument)
2006AC_ARG_ENABLE(netbeans,
2007 [ --disable-netbeans Disable NetBeans integration support.],
2008 , [enable_netbeans="yes"])
2009if test "$enable_netbeans" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002010 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2011 AC_MSG_RESULT([cannot use NetBeans with tiny or small features])
2012 enable_netbeans="no"
2013 else
2014 AC_MSG_RESULT(no)
2015 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002016else
2017 AC_MSG_RESULT(yes)
2018fi
2019
2020AC_MSG_CHECKING(--disable-channel argument)
2021AC_ARG_ENABLE(channel,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002022 [ --disable-channel Disable process communication support.],
Bram Moolenaare0874f82016-01-24 20:36:41 +01002023 , [enable_channel="yes"])
2024if test "$enable_channel" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002025 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2026 AC_MSG_RESULT([cannot use channels with tiny or small features])
2027 enable_channel="no"
2028 else
2029 AC_MSG_RESULT(no)
2030 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002031else
2032 if test "$enable_netbeans" = "yes"; then
Bram Moolenaar16435482016-01-24 21:31:54 +01002033 AC_MSG_RESULT([yes, netbeans also disabled])
Bram Moolenaare0874f82016-01-24 20:36:41 +01002034 enable_netbeans="no"
2035 else
2036 AC_MSG_RESULT(yes)
2037 fi
2038fi
2039
Bram Moolenaar16435482016-01-24 21:31:54 +01002040if test "$enable_channel" = "yes"; then
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002041 dnl On Solaris we need the socket library, or on Haiku the network library.
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002042 if test "x$HAIKU" = "xyes"; then
2043 AC_CHECK_LIB(network, socket)
2044 else
2045 AC_CHECK_LIB(socket, socket)
2046 fi
2047
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002048 AC_CACHE_CHECK([whether compiling with IPv6 networking is possible], [vim_cv_ipv6_networking],
2049 [AC_TRY_LINK([
2050#include <stdio.h>
2051#include <stdlib.h>
2052#include <stdarg.h>
2053#include <fcntl.h>
2054#include <netdb.h>
2055#include <netinet/in.h>
2056#include <errno.h>
2057#include <sys/types.h>
2058#include <sys/socket.h>
2059 /* Check bitfields */
2060 struct nbbuf {
2061 unsigned int initDone:1;
2062 unsigned short signmaplen;
2063 };
2064 ], [
2065 /* Check creating a socket. */
2066 struct sockaddr_in server;
2067 struct addrinfo *res;
2068 (void)socket(AF_INET, SOCK_STREAM, 0);
2069 (void)htons(100);
2070 (void)getaddrinfo("microsoft.com", NULL, NULL, &res);
2071 if (errno == ECONNREFUSED)
2072 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
2073 (void)freeaddrinfo(res);
2074 ],
2075 [vim_cv_ipv6_networking="yes"],
2076 [vim_cv_ipv6_networking="no"])])
2077
2078 if test "x$vim_cv_ipv6_networking" = "xyes"; then
2079 AC_DEFINE(FEAT_IPV6)
2080 else
2081 dnl On Solaris we need the nsl library.
2082 AC_CHECK_LIB(nsl, gethostbyname)
2083 AC_CACHE_CHECK([whether compiling with IPv4 networking is possible], [vim_cv_ipv4_networking],
2084 [AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00002085#include <stdio.h>
2086#include <stdlib.h>
2087#include <stdarg.h>
2088#include <fcntl.h>
2089#include <netdb.h>
2090#include <netinet/in.h>
2091#include <errno.h>
2092#include <sys/types.h>
2093#include <sys/socket.h>
2094 /* Check bitfields */
2095 struct nbbuf {
2096 unsigned int initDone:1;
Bram Moolenaar63de19e2016-12-09 20:11:26 +01002097 unsigned short signmaplen;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002098 };
2099 ], [
2100 /* Check creating a socket. */
2101 struct sockaddr_in server;
2102 (void)socket(AF_INET, SOCK_STREAM, 0);
2103 (void)htons(100);
2104 (void)gethostbyname("microsoft.com");
2105 if (errno == ECONNREFUSED)
2106 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
2107 ],
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002108 [vim_cv_ipv4_networking="yes"],
2109 [vim_cv_ipv4_networking="no"; enable_netbeans="no"; enable_channel="no"])])
2110 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002111fi
2112if test "$enable_netbeans" = "yes"; then
2113 AC_DEFINE(FEAT_NETBEANS_INTG)
2114 NETBEANS_SRC="netbeans.c"
2115 AC_SUBST(NETBEANS_SRC)
2116 NETBEANS_OBJ="objects/netbeans.o"
2117 AC_SUBST(NETBEANS_OBJ)
2118fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002119if test "$enable_channel" = "yes"; then
Bram Moolenaar509ce2a2016-03-11 22:52:15 +01002120 AC_DEFINE(FEAT_JOB_CHANNEL)
Bram Moolenaare0874f82016-01-24 20:36:41 +01002121 CHANNEL_SRC="channel.c"
2122 AC_SUBST(CHANNEL_SRC)
2123 CHANNEL_OBJ="objects/channel.o"
2124 AC_SUBST(CHANNEL_OBJ)
2125fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002126
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002127AC_MSG_CHECKING(--enable-terminal argument)
2128AC_ARG_ENABLE(terminal,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002129 [ --enable-terminal Enable terminal emulation support.],
Bram Moolenaaref839562017-10-28 20:28:23 +02002130 , [enable_terminal="auto"])
Bram Moolenaar595a4022017-09-03 19:15:57 +02002131if test "$enable_terminal" = "yes" || test "$enable_terminal" = "auto" -a "x$features" = "xhuge" ; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002132 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2133 AC_MSG_RESULT([cannot use terminal emulator with tiny or small features])
2134 enable_terminal="no"
2135 else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002136 if test "$enable_terminal" = "auto"; then
2137 enable_terminal="yes"
2138 AC_MSG_RESULT(defaulting to yes)
2139 else
2140 AC_MSG_RESULT(yes)
2141 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002142 fi
2143else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002144 if test "$enable_terminal" = "auto"; then
2145 enable_terminal="no"
2146 AC_MSG_RESULT(defaulting to no)
2147 else
2148 AC_MSG_RESULT(no)
2149 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002150fi
Bram Moolenaar8b423282017-12-16 14:37:06 +01002151if test "$enable_terminal" = "yes" -a "$enable_channel" = "yes"; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002152 AC_DEFINE(FEAT_TERMINAL)
Bram Moolenaar93268052019-10-10 13:22:54 +02002153 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 +02002154 AC_SUBST(TERM_SRC)
Bram Moolenaar93268052019-10-10 13:22:54 +02002155 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 +02002156 AC_SUBST(TERM_OBJ)
Bram Moolenaar823edd12019-10-23 22:35:36 +02002157 TERM_TEST="test_libvterm"
2158 AC_SUBST(TERM_TEST)
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002159fi
2160
Bram Moolenaare42a6d22017-11-12 19:21:51 +01002161AC_MSG_CHECKING(--enable-autoservername argument)
2162AC_ARG_ENABLE(autoservername,
2163 [ --enable-autoservername Automatically define servername at vim startup.], ,
2164 [enable_autoservername="no"])
2165AC_MSG_RESULT($enable_autoservername)
2166if test "$enable_autoservername" = "yes"; then
2167 AC_DEFINE(FEAT_AUTOSERVERNAME)
2168fi
2169
Bram Moolenaar071d4272004-06-13 20:20:40 +00002170AC_MSG_CHECKING(--enable-multibyte argument)
2171AC_ARG_ENABLE(multibyte,
2172 [ --enable-multibyte Include multibyte editing support.], ,
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01002173 [enable_multibyte="yes"])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002174AC_MSG_RESULT($enable_multibyte)
Bram Moolenaar30276f22019-01-24 17:59:39 +01002175if test "$enable_multibyte" != "yes"; then
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01002176 AC_MSG_ERROR([The multi-byte feature can no longer be disabled. If you have
2177 a problem with this, discuss on the Vim mailing list.])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002178fi
2179
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002180dnl Right-to-Left language support for Vim will be included with big features,
2181dnl unless ENABLE_RIGHTLEFT is undefined.
2182AC_MSG_CHECKING(--disable-rightleft argument)
2183AC_ARG_ENABLE(rightleft,
2184 [ --disable-rightleft Do not include Right-to-Left language support.],
2185 , [enable_rightleft="yes"])
2186if test "$enable_rightleft" = "yes"; then
2187 AC_MSG_RESULT(no)
2188else
2189 AC_MSG_RESULT(yes)
2190 AC_DEFINE(DISABLE_RIGHTLEFT)
2191fi
2192
2193dnl Arabic language support for Vim will be included with big features,
2194dnl unless ENABLE_ARABIC is undefined.
2195AC_MSG_CHECKING(--disable-arabic argument)
2196AC_ARG_ENABLE(arabic,
2197 [ --disable-arabic Do not include Arabic language support.],
2198 , [enable_arabic="yes"])
2199if test "$enable_arabic" = "yes"; then
2200 AC_MSG_RESULT(no)
2201else
2202 AC_MSG_RESULT(yes)
2203 AC_DEFINE(DISABLE_ARABIC)
2204fi
2205
Bram Moolenaar14184a32019-02-16 15:10:30 +01002206dnl Farsi language support has been removed, ignore --disable-farsi
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002207AC_ARG_ENABLE(farsi,
Bram Moolenaar14184a32019-02-16 15:10:30 +01002208 [ --disable-farsi Deprecated.],,)
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002209
Bram Moolenaar071d4272004-06-13 20:20:40 +00002210AC_MSG_CHECKING(--enable-xim argument)
2211AC_ARG_ENABLE(xim,
2212 [ --enable-xim Include XIM input support.],
2213 AC_MSG_RESULT($enable_xim),
2214 [enable_xim="auto"; AC_MSG_RESULT(defaulting to auto)])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002215
2216AC_MSG_CHECKING(--enable-fontset argument)
2217AC_ARG_ENABLE(fontset,
2218 [ --enable-fontset Include X fontset output support.], ,
2219 [enable_fontset="no"])
2220AC_MSG_RESULT($enable_fontset)
2221dnl defining FEAT_XFONTSET is delayed, so that it can be disabled for no GUI
2222
2223test -z "$with_x" && with_x=yes
Bram Moolenaard0573012017-10-28 21:11:06 +02002224test "${enable_gui-yes}" != no -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && with_x=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002225if test "$with_x" = no; then
2226 AC_MSG_RESULT(defaulting to: don't HAVE_X11)
2227else
2228 dnl Do this check early, so that its failure can override user requests.
2229
2230 AC_PATH_PROG(xmkmfpath, xmkmf)
2231
2232 AC_PATH_XTRA
2233
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002234 dnl On z/OS Unix the X libraries are DLLs. To use them the code must
Bram Moolenaar071d4272004-06-13 20:20:40 +00002235 dnl be compiled with a special option.
2236 dnl Also add SM, ICE and Xmu to X_EXTRA_LIBS.
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002237 if test "$zOSUnix" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002238 CFLAGS="$CFLAGS -W c,dll"
2239 LDFLAGS="$LDFLAGS -W l,dll"
2240 X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE -lXmu"
2241 fi
2242
2243 dnl On my HPUX system the X include dir is found, but the lib dir not.
Bram Moolenaar70778922020-02-05 20:44:24 +01002244 dnl This is a desperate try to fix this.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002245
2246 if test -d "$x_includes" && test ! -d "$x_libraries"; then
2247 x_libraries=`echo "$x_includes" | sed s/include/lib/`
2248 AC_MSG_RESULT(Corrected X libraries to $x_libraries)
2249 X_LIBS="$X_LIBS -L$x_libraries"
2250 if test "`(uname) 2>/dev/null`" = SunOS &&
2251 uname -r | grep '^5' >/dev/null; then
2252 X_LIBS="$X_LIBS -R $x_libraries"
2253 fi
2254 fi
2255
2256 if test -d "$x_libraries" && test ! -d "$x_includes"; then
2257 x_includes=`echo "$x_libraries" | sed s/lib/include/`
2258 AC_MSG_RESULT(Corrected X includes to $x_includes)
2259 X_CFLAGS="$X_CFLAGS -I$x_includes"
2260 fi
2261
2262 dnl Remove "-I/usr/include " from X_CFLAGS, should not be needed.
2263 X_CFLAGS="`echo $X_CFLAGS\ | sed 's%-I/usr/include %%'`"
2264 dnl Remove "-L/usr/lib " from X_LIBS, should not be needed.
2265 X_LIBS="`echo $X_LIBS\ | sed 's%-L/usr/lib %%'`"
2266 dnl Same for "-R/usr/lib ".
2267 X_LIBS="`echo $X_LIBS\ | sed -e 's%-R/usr/lib %%' -e 's%-R /usr/lib %%'`"
2268
2269
2270 dnl Check if the X11 header files are correctly installed. On some systems
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002271 dnl Xlib.h includes files that don't exist. On some systems X11/Intrinsic.h
2272 dnl is missing.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002273 AC_MSG_CHECKING(if X11 header files can be found)
2274 cflags_save=$CFLAGS
2275 CFLAGS="$CFLAGS $X_CFLAGS"
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002276 AC_TRY_COMPILE([#include <X11/Xlib.h>
2277#include <X11/Intrinsic.h>], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002278 AC_MSG_RESULT(yes),
2279 AC_MSG_RESULT(no); no_x=yes)
2280 CFLAGS=$cflags_save
2281
2282 if test "${no_x-no}" = yes; then
2283 with_x=no
2284 else
2285 AC_DEFINE(HAVE_X11)
2286 X_LIB="-lXt -lX11";
2287 AC_SUBST(X_LIB)
2288
2289 ac_save_LDFLAGS="$LDFLAGS"
2290 LDFLAGS="-L$x_libraries $LDFLAGS"
2291
2292 dnl Check for -lXdmcp (needed on SunOS 4.1.4)
2293 dnl For HP-UX 10.20 it must be before -lSM -lICE
2294 AC_CHECK_LIB(Xdmcp, _XdmcpAuthDoIt, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lXdmcp"],,
2295 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXdmcp])
2296
2297 dnl Some systems need -lnsl -lsocket when testing for ICE.
2298 dnl The check above doesn't do this, try here (again). Also needed to get
2299 dnl them after Xdmcp. link.sh will remove them when not needed.
2300 dnl Check for other function than above to avoid the cached value
2301 AC_CHECK_LIB(ICE, IceOpenConnection,
2302 [X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE"],, [$X_EXTRA_LIBS])
2303
2304 dnl Check for -lXpm (needed for some versions of Motif)
2305 LDFLAGS="$X_LIBS $ac_save_LDFLAGS"
2306 AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [X_PRE_LIBS="$X_PRE_LIBS -lXpm"],,
2307 [-lXt $X_PRE_LIBS -lXpm -lX11 $X_EXTRA_LIBS])
2308
2309 dnl Check that the X11 header files don't use implicit declarations
2310 AC_MSG_CHECKING(if X11 header files implicitly declare return values)
2311 cflags_save=$CFLAGS
Bram Moolenaard1864592013-05-04 04:40:15 +02002312 dnl -Werror is GCC only, others like Solaris Studio might not like it
2313 if test "$GCC" = yes; then
2314 CFLAGS="$CFLAGS $X_CFLAGS -Werror"
2315 else
2316 CFLAGS="$CFLAGS $X_CFLAGS"
2317 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002318 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2319 AC_MSG_RESULT(no),
2320 CFLAGS="$CFLAGS -Wno-implicit-int"
2321 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2322 AC_MSG_RESULT(yes); cflags_save="$cflags_save -Wno-implicit-int",
2323 AC_MSG_RESULT(test failed)
2324 )
2325 )
2326 CFLAGS=$cflags_save
2327
2328 LDFLAGS="$ac_save_LDFLAGS"
2329
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002330 AC_MSG_CHECKING(size of wchar_t is 2 bytes)
2331 AC_CACHE_VAL(ac_cv_small_wchar_t,
2332 [AC_TRY_RUN([
2333#include <X11/Xlib.h>
2334#if STDC_HEADERS
2335# include <stdlib.h>
2336# include <stddef.h>
2337#endif
2338 main()
2339 {
2340 if (sizeof(wchar_t) <= 2)
2341 exit(1);
2342 exit(0);
2343 }],
2344 ac_cv_small_wchar_t="no",
2345 ac_cv_small_wchar_t="yes",
2346 AC_MSG_ERROR(failed to compile test program))])
2347 AC_MSG_RESULT($ac_cv_small_wchar_t)
2348 if test "x$ac_cv_small_wchar_t" = "xyes" ; then
2349 AC_DEFINE(SMALL_WCHAR_T)
2350 fi
2351
Bram Moolenaar071d4272004-06-13 20:20:40 +00002352 fi
2353fi
2354
Bram Moolenaard2a05492018-07-27 22:35:15 +02002355dnl Check if --with-x was given but it doesn't work.
2356if test "x$with_x" = xno -a "x$with_x_arg" = xyes; then
2357 AC_MSG_ERROR([could not configure X])
2358fi
2359
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002360test "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 +00002361
2362AC_MSG_CHECKING(--enable-gui argument)
2363AC_ARG_ENABLE(gui,
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002364 [ --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 +00002365
2366dnl Canonicalize the --enable-gui= argument so that it can be easily compared.
2367dnl Do not use character classes for portability with old tools.
2368enable_gui_canon=`echo "_$enable_gui" | \
2369 sed 's/[[ _+-]]//g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
2370
2371dnl Skip everything by default.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002372SKIP_GTK2=YES
Bram Moolenaar1858a842016-02-23 22:30:31 +01002373SKIP_GTK3=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002374SKIP_GNOME=YES
2375SKIP_MOTIF=YES
2376SKIP_ATHENA=YES
2377SKIP_NEXTAW=YES
2378SKIP_PHOTON=YES
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002379SKIP_HAIKU=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002380SKIP_CARBON=YES
2381GUITYPE=NONE
2382
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002383if test "x$HAIKU" = "xyes"; then
2384 SKIP_HAIKU=
2385 case "$enable_gui_canon" in
2386 no) AC_MSG_RESULT(no GUI support)
2387 SKIP_HAIKU=YES ;;
2388 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
2389 auto) AC_MSG_RESULT(auto - automatic GUI support) ;;
2390 haiku) AC_MSG_RESULT(Haiku GUI support) ;;
2391 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2392 SKIP_HAIKU=YES ;;
2393 esac
2394elif test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002395 SKIP_PHOTON=
2396 case "$enable_gui_canon" in
2397 no) AC_MSG_RESULT(no GUI support)
2398 SKIP_PHOTON=YES ;;
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002399 yes|""|auto) AC_MSG_RESULT(automatic GUI support)
2400 gui_auto=yes ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002401 photon) AC_MSG_RESULT(Photon GUI support) ;;
2402 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2403 SKIP_PHOTON=YES ;;
2404 esac
2405
Bram Moolenaard0573012017-10-28 21:11:06 +02002406elif test "x$MACOS_X" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002407 SKIP_CARBON=
2408 case "$enable_gui_canon" in
2409 no) AC_MSG_RESULT(no GUI support)
2410 SKIP_CARBON=YES ;;
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002411 yes|"") AC_MSG_RESULT(yes - automatic GUI support)
2412 gui_auto=yes ;;
Bram Moolenaar164fca32010-07-14 13:58:07 +02002413 auto) AC_MSG_RESULT(auto - Carbon GUI is outdated - disable GUI support)
2414 SKIP_CARBON=YES ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002415 carbon) AC_MSG_RESULT(Carbon GUI support) ;;
2416 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2417 SKIP_CARBON=YES ;;
2418 esac
2419
2420else
2421
Bram Moolenaar071d4272004-06-13 20:20:40 +00002422 case "$enable_gui_canon" in
2423 no|none) AC_MSG_RESULT(no GUI support) ;;
2424 yes|""|auto) AC_MSG_RESULT(yes/auto - automatic GUI support)
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002425 gui_auto=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002426 SKIP_GTK2=
2427 SKIP_GNOME=
2428 SKIP_MOTIF=
2429 SKIP_ATHENA=
2430 SKIP_NEXTAW=
2431 SKIP_CARBON=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002432 gtk2) AC_MSG_RESULT(GTK+ 2.x GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002433 SKIP_GTK2=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002434 gnome2) AC_MSG_RESULT(GNOME 2.x GUI support)
2435 SKIP_GNOME=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002436 SKIP_GTK2=;;
Bram Moolenaar98921892016-02-23 17:14:37 +01002437 gtk3) AC_MSG_RESULT(GTK+ 3.x GUI support)
2438 SKIP_GTK3=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002439 motif) AC_MSG_RESULT(Motif GUI support)
2440 SKIP_MOTIF=;;
2441 athena) AC_MSG_RESULT(Athena GUI support)
2442 SKIP_ATHENA=;;
2443 nextaw) AC_MSG_RESULT(neXtaw GUI support)
2444 SKIP_NEXTAW=;;
2445 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
2446 esac
2447
2448fi
2449
Bram Moolenaar071d4272004-06-13 20:20:40 +00002450if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \
2451 -a "$enable_gui_canon" != "gnome2"; then
2452 AC_MSG_CHECKING(whether or not to look for GTK+ 2)
2453 AC_ARG_ENABLE(gtk2-check,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002454 [ --enable-gtk2-check If auto-select GUI, check for GTK+ 2 [default=yes]],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002455 , enable_gtk2_check="yes")
2456 AC_MSG_RESULT($enable_gtk2_check)
2457 if test "x$enable_gtk2_check" = "xno"; then
2458 SKIP_GTK2=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002459 SKIP_GNOME=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002460 fi
2461fi
2462
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002463if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002464 AC_MSG_CHECKING(whether or not to look for GNOME)
2465 AC_ARG_ENABLE(gnome-check,
2466 [ --enable-gnome-check If GTK GUI, check for GNOME [default=no]],
2467 , enable_gnome_check="no")
2468 AC_MSG_RESULT($enable_gnome_check)
2469 if test "x$enable_gnome_check" = "xno"; then
2470 SKIP_GNOME=YES
2471 fi
2472fi
2473
Bram Moolenaar98921892016-02-23 17:14:37 +01002474if test "x$SKIP_GTK3" != "xYES" -a "$enable_gui_canon" != "gtk3"; then
2475 AC_MSG_CHECKING(whether or not to look for GTK+ 3)
2476 AC_ARG_ENABLE(gtk3-check,
2477 [ --enable-gtk3-check If auto-select GUI, check for GTK+ 3 [default=yes]],
2478 , enable_gtk3_check="yes")
2479 AC_MSG_RESULT($enable_gtk3_check)
2480 if test "x$enable_gtk3_check" = "xno"; then
2481 SKIP_GTK3=YES
2482 fi
2483fi
2484
Bram Moolenaar071d4272004-06-13 20:20:40 +00002485if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then
2486 AC_MSG_CHECKING(whether or not to look for Motif)
2487 AC_ARG_ENABLE(motif-check,
2488 [ --enable-motif-check If auto-select GUI, check for Motif [default=yes]],
2489 , enable_motif_check="yes")
2490 AC_MSG_RESULT($enable_motif_check)
2491 if test "x$enable_motif_check" = "xno"; then
2492 SKIP_MOTIF=YES
2493 fi
2494fi
2495
2496if test "x$SKIP_ATHENA" != "xYES" -a "$enable_gui_canon" != "athena"; then
2497 AC_MSG_CHECKING(whether or not to look for Athena)
2498 AC_ARG_ENABLE(athena-check,
2499 [ --enable-athena-check If auto-select GUI, check for Athena [default=yes]],
2500 , enable_athena_check="yes")
2501 AC_MSG_RESULT($enable_athena_check)
2502 if test "x$enable_athena_check" = "xno"; then
2503 SKIP_ATHENA=YES
2504 fi
2505fi
2506
2507if test "x$SKIP_NEXTAW" != "xYES" -a "$enable_gui_canon" != "nextaw"; then
2508 AC_MSG_CHECKING(whether or not to look for neXtaw)
2509 AC_ARG_ENABLE(nextaw-check,
2510 [ --enable-nextaw-check If auto-select GUI, check for neXtaw [default=yes]],
2511 , enable_nextaw_check="yes")
2512 AC_MSG_RESULT($enable_nextaw_check);
2513 if test "x$enable_nextaw_check" = "xno"; then
2514 SKIP_NEXTAW=YES
2515 fi
2516fi
2517
2518if test "x$SKIP_CARBON" != "xYES" -a "$enable_gui_canon" != "carbon"; then
2519 AC_MSG_CHECKING(whether or not to look for Carbon)
2520 AC_ARG_ENABLE(carbon-check,
2521 [ --enable-carbon-check If auto-select GUI, check for Carbon [default=yes]],
2522 , enable_carbon_check="yes")
2523 AC_MSG_RESULT($enable_carbon_check);
2524 if test "x$enable_carbon_check" = "xno"; then
2525 SKIP_CARBON=YES
2526 fi
2527fi
2528
Bram Moolenaar843ee412004-06-30 16:16:41 +00002529
Bram Moolenaard0573012017-10-28 21:11:06 +02002530if test "x$MACOS_X" = "xyes" -a -z "$SKIP_CARBON" -a "x$CARBON" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002531 AC_MSG_CHECKING(for Carbon GUI)
Bram Moolenaar14716812006-05-04 21:54:08 +00002532 dnl already did the check, just give the message
Bram Moolenaar071d4272004-06-13 20:20:40 +00002533 AC_MSG_RESULT(yes);
2534 GUITYPE=CARBONGUI
Bram Moolenaare344bea2005-09-01 20:46:49 +00002535 if test "$VIMNAME" = "vim"; then
2536 VIMNAME=Vim
2537 fi
Bram Moolenaar14716812006-05-04 21:54:08 +00002538
Bram Moolenaar164fca32010-07-14 13:58:07 +02002539 if test "x$MACARCH" = "xboth"; then
2540 CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk/Developer/Headers/FlatCarbon"
2541 else
2542 CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/Headers/FlatCarbon"
2543 fi
2544
Bram Moolenaar14716812006-05-04 21:54:08 +00002545 dnl Default install directory is not /usr/local
2546 if test x$prefix = xNONE; then
2547 prefix=/Applications
2548 fi
2549
2550 dnl Sorry for the hard coded default
2551 datadir='${prefix}/Vim.app/Contents/Resources'
2552
Bram Moolenaar071d4272004-06-13 20:20:40 +00002553 dnl skip everything else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002554 SKIP_GTK2=YES;
2555 SKIP_GNOME=YES;
2556 SKIP_MOTIF=YES;
2557 SKIP_ATHENA=YES;
2558 SKIP_NEXTAW=YES;
2559 SKIP_PHOTON=YES;
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002560 SKIP_HAIKU=YES;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002561 SKIP_CARBON=YES
2562fi
2563
Bram Moolenaar071d4272004-06-13 20:20:40 +00002564dnl define an autoconf function to check for a specified version of GTK, and
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002565dnl try to compile/link a GTK program.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002566dnl
2567dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002568dnl Test for GTK, and define GTK_CFLAGS, GTK_LIBDIR and GTK_LIBS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002569dnl
2570AC_DEFUN(AM_PATH_GTK,
2571[
2572 if test "X$GTK_CONFIG" != "Xno" -o "X$PKG_CONFIG" != "Xno"; then
2573 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00002574 no_gtk=""
2575 if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2576 && $PKG_CONFIG --exists gtk+-2.0; then
2577 {
Bram Moolenaar98921892016-02-23 17:14:37 +01002578 min_gtk_version=ifelse([$1], ,2.2.0,$1)
2579 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002580 dnl We should be using PKG_CHECK_MODULES() instead of this hack.
2581 dnl But I guess the dependency on pkgconfig.m4 is not wanted or
2582 dnl something like that.
2583 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0`
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002584 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-2.0`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002585 GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0`
2586 gtk_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2587 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2588 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2589 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2590 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2591 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2592 }
Bram Moolenaar98921892016-02-23 17:14:37 +01002593 elif (test "X$SKIP_GTK3" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2594 && $PKG_CONFIG --exists gtk+-3.0; then
2595 {
2596 min_gtk_version=ifelse([$1], ,3.0.0,$1)
2597 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
2598
2599 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-3.0`
2600 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-3.0`
2601 GTK_LIBS=`$PKG_CONFIG --libs gtk+-3.0`
2602 gtk_major_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2603 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2604 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2605 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2606 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2607 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2608 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002609 else
2610 no_gtk=yes
2611 fi
2612
2613 if test "x$enable_gtktest" = "xyes" -a "x$no_gtk" = "x"; then
2614 {
2615 ac_save_CFLAGS="$CFLAGS"
2616 ac_save_LIBS="$LIBS"
2617 CFLAGS="$CFLAGS $GTK_CFLAGS"
2618 LIBS="$LIBS $GTK_LIBS"
2619
2620 dnl
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002621 dnl Now check if the installed GTK is sufficiently new.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002622 dnl
2623 rm -f conf.gtktest
2624 AC_TRY_RUN([
2625#include <gtk/gtk.h>
2626#include <stdio.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00002627#if STDC_HEADERS
2628# include <stdlib.h>
2629# include <stddef.h>
2630#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002631
2632int
2633main ()
2634{
2635int major, minor, micro;
2636char *tmp_version;
2637
2638system ("touch conf.gtktest");
2639
2640/* HP/UX 9 (%@#!) writes to sscanf strings */
2641tmp_version = g_strdup("$min_gtk_version");
2642if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
2643 printf("%s, bad version string\n", "$min_gtk_version");
2644 exit(1);
2645 }
2646
2647if ((gtk_major_version > major) ||
2648 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
2649 ((gtk_major_version == major) && (gtk_minor_version == minor) &&
2650 (gtk_micro_version >= micro)))
2651{
2652 return 0;
2653}
2654return 1;
2655}
2656],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
2657 CFLAGS="$ac_save_CFLAGS"
2658 LIBS="$ac_save_LIBS"
2659 }
2660 fi
2661 if test "x$no_gtk" = x ; then
2662 if test "x$enable_gtktest" = "xyes"; then
2663 AC_MSG_RESULT(yes; found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2664 else
2665 AC_MSG_RESULT(found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2666 fi
2667 ifelse([$2], , :, [$2])
2668 else
2669 {
2670 AC_MSG_RESULT(no)
2671 GTK_CFLAGS=""
2672 GTK_LIBS=""
2673 ifelse([$3], , :, [$3])
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002674 if test "$fail_if_missing" = "yes" -a "X$gui_auto" != "Xyes"; then
2675 AC_MSG_ERROR([could not configure GTK])
2676 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002677 }
2678 fi
2679 }
2680 else
2681 GTK_CFLAGS=""
2682 GTK_LIBS=""
2683 ifelse([$3], , :, [$3])
2684 fi
2685 AC_SUBST(GTK_CFLAGS)
2686 AC_SUBST(GTK_LIBS)
2687 rm -f conf.gtktest
2688])
2689
2690dnl ---------------------------------------------------------------------------
2691dnl gnome
2692dnl ---------------------------------------------------------------------------
2693AC_DEFUN([GNOME_INIT_HOOK],
2694[
2695 AC_SUBST(GNOME_LIBS)
2696 AC_SUBST(GNOME_LIBDIR)
2697 AC_SUBST(GNOME_INCLUDEDIR)
2698
2699 AC_ARG_WITH(gnome-includes,
2700 [ --with-gnome-includes=DIR Specify location of GNOME headers],
2701 [CFLAGS="$CFLAGS -I$withval"]
2702 )
2703
2704 AC_ARG_WITH(gnome-libs,
2705 [ --with-gnome-libs=DIR Specify location of GNOME libs],
2706 [LDFLAGS="$LDFLAGS -L$withval" gnome_prefix=$withval]
2707 )
2708
2709 AC_ARG_WITH(gnome,
2710 [ --with-gnome Specify prefix for GNOME files],
2711 if test x$withval = xyes; then
2712 want_gnome=yes
2713 ifelse([$1], [], :, [$1])
2714 else
2715 if test "x$withval" = xno; then
2716 want_gnome=no
2717 else
2718 want_gnome=yes
2719 LDFLAGS="$LDFLAGS -L$withval/lib"
2720 CFLAGS="$CFLAGS -I$withval/include"
2721 gnome_prefix=$withval/lib
2722 fi
2723 fi,
2724 want_gnome=yes)
2725
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002726 if test "x$want_gnome" = xyes; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002727 {
2728 AC_MSG_CHECKING(for libgnomeui-2.0)
2729 if $PKG_CONFIG --exists libgnomeui-2.0; then
2730 AC_MSG_RESULT(yes)
2731 GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0`
2732 GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0`
2733 GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0`
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002734
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002735 dnl On FreeBSD we need -pthread but pkg-config doesn't include it.
2736 dnl This might not be the right way but it works for me...
2737 AC_MSG_CHECKING(for FreeBSD)
2738 if test "`(uname) 2>/dev/null`" = FreeBSD; then
2739 AC_MSG_RESULT(yes, adding -pthread)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002740 GNOME_INCLUDEDIR="$GNOME_INCLUDEDIR -D_THREAD_SAFE"
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002741 GNOME_LIBS="$GNOME_LIBS -pthread"
2742 else
2743 AC_MSG_RESULT(no)
2744 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002745 $1
2746 else
2747 AC_MSG_RESULT(not found)
2748 if test "x$2" = xfail; then
2749 AC_MSG_ERROR(Could not find libgnomeui-2.0 via pkg-config)
2750 fi
2751 fi
2752 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002753 fi
2754])
2755
2756AC_DEFUN([GNOME_INIT],[
2757 GNOME_INIT_HOOK([],fail)
2758])
2759
Bram Moolenaar427f5b62019-06-09 13:43:51 +02002760if test "X$PKG_CONFIG" = "X"; then
2761 AC_PATH_TOOL(PKG_CONFIG, pkg-config, no)
2762fi
2763
Bram Moolenaar071d4272004-06-13 20:20:40 +00002764
2765dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002766dnl Check for GTK2. If it fails, then continue on for Motif as before...
Bram Moolenaar071d4272004-06-13 20:20:40 +00002767dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002768if test -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002769
2770 AC_MSG_CHECKING(--disable-gtktest argument)
2771 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2772 , enable_gtktest=yes)
2773 if test "x$enable_gtktest" = "xyes" ; then
2774 AC_MSG_RESULT(gtk test enabled)
2775 else
2776 AC_MSG_RESULT(gtk test disabled)
2777 fi
2778
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002779 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002780 dnl First try finding version 2.2.0 or later. The 2.0.x series has
2781 dnl problems (bold fonts, --remote doesn't work).
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002782 AM_PATH_GTK(2.2.0,
2783 [GUI_LIB_LOC="$GTK_LIBDIR"
2784 GTK_LIBNAME="$GTK_LIBS"
2785 GUI_INC_LOC="$GTK_CFLAGS"], )
2786 if test "x$GTK_CFLAGS" != "x"; then
Bram Moolenaar98921892016-02-23 17:14:37 +01002787 SKIP_GTK3=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002788 SKIP_ATHENA=YES
2789 SKIP_NEXTAW=YES
2790 SKIP_MOTIF=YES
2791 GUITYPE=GTK
2792 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002793 fi
2794 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002795 if test "x$GUITYPE" = "xGTK"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002796 dnl
2797 dnl if GTK exists, then check for GNOME.
2798 dnl
2799 if test -z "$SKIP_GNOME"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002800 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002801 GNOME_INIT_HOOK([have_gnome=yes])
2802 if test "x$have_gnome" = xyes ; then
2803 AC_DEFINE(FEAT_GUI_GNOME)
2804 GUI_INC_LOC="$GUI_INC_LOC $GNOME_INCLUDEDIR"
2805 GTK_LIBNAME="$GTK_LIBNAME $GNOME_LIBDIR $GNOME_LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002806 fi
2807 }
2808 fi
2809 fi
2810fi
2811
Bram Moolenaar98921892016-02-23 17:14:37 +01002812
2813dnl ---------------------------------------------------------------------------
2814dnl Check for GTK3.
2815dnl ---------------------------------------------------------------------------
2816if test -z "$SKIP_GTK3"; then
2817
2818 AC_MSG_CHECKING(--disable-gtktest argument)
2819 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2820 , enable_gtktest=yes)
2821 if test "x$enable_gtktest" = "xyes" ; then
2822 AC_MSG_RESULT(gtk test enabled)
2823 else
2824 AC_MSG_RESULT(gtk test disabled)
2825 fi
2826
Bram Moolenaar98921892016-02-23 17:14:37 +01002827 if test "x$PKG_CONFIG" != "xno"; then
2828 AM_PATH_GTK(3.0.0,
2829 [GUI_LIB_LOC="$GTK_LIBDIR"
2830 GTK_LIBNAME="$GTK_LIBS"
2831 GUI_INC_LOC="$GTK_CFLAGS"], )
2832 if test "x$GTK_CFLAGS" != "x"; then
2833 SKIP_GTK2=YES
2834 SKIP_GNOME=YES
2835 SKIP_ATHENA=YES
2836 SKIP_NEXTAW=YES
2837 SKIP_MOTIF=YES
2838 GUITYPE=GTK
2839 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar98921892016-02-23 17:14:37 +01002840 AC_DEFINE(USE_GTK3)
2841 fi
2842 fi
2843fi
2844
Bram Moolenaard2e03f02016-01-02 22:46:36 +01002845dnl Check the version of Gdk-Pixbuf. If the version is 2.31 or later and
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002846dnl glib-compile-resources is found in PATH, use GResource.
2847if test "x$GUITYPE" = "xGTK"; then
2848 AC_MSG_CHECKING([version of Gdk-Pixbuf])
2849 gdk_pixbuf_version=`$PKG_CONFIG --modversion gdk-pixbuf-2.0`
2850 if test "x$gdk_pixbuf_version" != x ; then
2851 gdk_pixbuf_version_minor=`echo $gdk_pixbuf_version | \
2852 sed -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/'`
2853 if test "x$gdk_pixbuf_version_minor" != x -a \
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002854 $gdk_pixbuf_version_minor -ge 31 ; then
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002855 AC_MSG_RESULT([OK.])
2856 AC_PATH_PROG(GLIB_COMPILE_RESOURCES,[glib-compile-resources],no)
2857 AC_MSG_CHECKING([glib-compile-resources])
2858 if test "x$GLIB_COMPILE_RESOURCES" = xno ; then
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002859 GLIB_COMPILE_RESOURCES=""
2860 AC_MSG_RESULT([cannot be found in PATH.])
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002861 else
2862 AC_MSG_RESULT([usable.])
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002863 AC_DEFINE(USE_GRESOURCE)
2864 GRESOURCE_SRC="auto/gui_gtk_gresources.c"
2865 GRESOURCE_OBJ="objects/gui_gtk_gresources.o"
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002866 fi
2867 else
2868 AC_MSG_RESULT([not usable.])
2869 fi
2870 else
2871 AC_MSG_RESULT([cannot obtain from pkg_config.])
2872 fi
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002873
2874 AC_MSG_CHECKING([--disable-icon-cache-update argument])
2875 AC_ARG_ENABLE(icon_cache_update,
2876 [ --disable-icon-cache-update update disabled],
2877 [],
2878 [enable_icon_cache_update="yes"])
2879 if test "$enable_icon_cache_update" = "yes"; then
2880 AC_MSG_RESULT([not set])
2881 AC_PATH_PROG(GTK_UPDATE_ICON_CACHE,[gtk-update-icon-cache],no)
2882 if test "x$GTK_UPDATE_ICON_CACHE" = "xno" ; then
2883 AC_MSG_RESULT([not found in PATH.])
2884 fi
2885 else
2886 AC_MSG_RESULT([update disabled])
2887 fi
2888
2889 AC_MSG_CHECKING([--disable-desktop-database-update argument])
2890 AC_ARG_ENABLE(desktop_database_update,
2891 [ --disable-desktop-database-update update disabled],
2892 [],
2893 [enable_desktop_database_update="yes"])
2894 if test "$enable_desktop_database_update" = "yes"; then
2895 AC_MSG_RESULT([not set])
2896 AC_PATH_PROG(UPDATE_DESKTOP_DATABASE,[update-desktop-database],no)
2897 if test "x$UPDATE_DESKTOP_DATABASE" = "xno" ; then
2898 AC_MSG_RESULT([not found in PATH.])
2899 fi
2900 else
2901 AC_MSG_RESULT([update disabled])
2902 fi
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002903fi
2904AC_SUBST(GLIB_COMPILE_RESOURCES)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002905AC_SUBST(GRESOURCE_SRC)
2906AC_SUBST(GRESOURCE_OBJ)
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002907AC_SUBST(GTK_UPDATE_ICON_CACHE)
2908AC_SUBST(UPDATE_DESKTOP_DATABASE)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002909
Bram Moolenaar071d4272004-06-13 20:20:40 +00002910dnl Check for Motif include files location.
2911dnl The LAST one found is used, this makes the highest version to be used,
2912dnl e.g. when Motif1.2 and Motif2.0 are both present.
2913
2914if test -z "$SKIP_MOTIF"; then
2915 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"
2916 dnl Remove "-I" from before $GUI_INC_LOC if it's there
2917 GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`"
2918
2919 AC_MSG_CHECKING(for location of Motif GUI includes)
2920 gui_includes="`echo $x_includes|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC"
2921 GUI_INC_LOC=
2922 for try in $gui_includes; do
2923 if test -f "$try/Xm/Xm.h"; then
2924 GUI_INC_LOC=$try
2925 fi
2926 done
2927 if test -n "$GUI_INC_LOC"; then
2928 if test "$GUI_INC_LOC" = /usr/include; then
2929 GUI_INC_LOC=
2930 AC_MSG_RESULT(in default path)
2931 else
2932 AC_MSG_RESULT($GUI_INC_LOC)
2933 fi
2934 else
2935 AC_MSG_RESULT(<not found>)
2936 SKIP_MOTIF=YES
2937 fi
2938fi
2939
2940dnl Check for Motif library files location. In the same order as the include
2941dnl files, to avoid a mixup if several versions are present
2942
2943if test -z "$SKIP_MOTIF"; then
2944 AC_MSG_CHECKING(--with-motif-lib argument)
2945 AC_ARG_WITH(motif-lib,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002946 [ --with-motif-lib=STRING Library for Motif ],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002947 [ MOTIF_LIBNAME="${withval}" ] )
2948
2949 if test -n "$MOTIF_LIBNAME"; then
2950 AC_MSG_RESULT($MOTIF_LIBNAME)
2951 GUI_LIB_LOC=
2952 else
2953 AC_MSG_RESULT(no)
2954
2955 dnl Remove "-L" from before $GUI_LIB_LOC if it's there
2956 GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
2957
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002958 dnl Ubuntu has libXm.so in /usr/lib/i386-linux-gnu and elsewhere. The
2959 dnl linker will figure out which one to use, we only check if one exists.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002960 AC_MSG_CHECKING(for location of Motif GUI libs)
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002961 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 +00002962 GUI_LIB_LOC=
2963 for try in $gui_libs; do
Bram Moolenaar325b7a22004-07-05 15:58:32 +00002964 for libtry in "$try"/libXm.a "$try"/libXm.so* "$try"/libXm.sl "$try"/libXm.dylib; do
Bram Moolenaar071d4272004-06-13 20:20:40 +00002965 if test -f "$libtry"; then
2966 GUI_LIB_LOC=$try
2967 fi
2968 done
2969 done
2970 if test -n "$GUI_LIB_LOC"; then
2971 dnl Remove /usr/lib, it causes trouble on some systems
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002972 if test "$GUI_LIB_LOC" = /usr/lib \
2973 -o "$GUI_LIB_LOC" = /usr/lib/i386-linux-gnu \
2974 -o "$GUI_LIB_LOC" = /usr/lib/x86_64-linux-gnu; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002975 GUI_LIB_LOC=
2976 AC_MSG_RESULT(in default path)
2977 else
2978 if test -n "$GUI_LIB_LOC"; then
2979 AC_MSG_RESULT($GUI_LIB_LOC)
2980 if test "`(uname) 2>/dev/null`" = SunOS &&
2981 uname -r | grep '^5' >/dev/null; then
2982 GUI_LIB_LOC="$GUI_LIB_LOC -R $GUI_LIB_LOC"
2983 fi
2984 fi
2985 fi
2986 MOTIF_LIBNAME=-lXm
2987 else
2988 AC_MSG_RESULT(<not found>)
2989 SKIP_MOTIF=YES
2990 fi
2991 fi
2992fi
2993
2994if test -z "$SKIP_MOTIF"; then
2995 SKIP_ATHENA=YES
2996 SKIP_NEXTAW=YES
2997 GUITYPE=MOTIF
2998 AC_SUBST(MOTIF_LIBNAME)
2999fi
3000
3001dnl Check if the Athena files can be found
3002
3003GUI_X_LIBS=
3004
3005if test -z "$SKIP_ATHENA"; then
3006 AC_MSG_CHECKING(if Athena header files can be found)
3007 cflags_save=$CFLAGS
3008 CFLAGS="$CFLAGS $X_CFLAGS"
3009 AC_TRY_COMPILE([
3010#include <X11/Intrinsic.h>
3011#include <X11/Xaw/Paned.h>], ,
3012 AC_MSG_RESULT(yes),
3013 AC_MSG_RESULT(no); SKIP_ATHENA=YES )
3014 CFLAGS=$cflags_save
3015fi
3016
3017if test -z "$SKIP_ATHENA"; then
3018 GUITYPE=ATHENA
3019fi
3020
3021if test -z "$SKIP_NEXTAW"; then
3022 AC_MSG_CHECKING(if neXtaw header files can be found)
3023 cflags_save=$CFLAGS
3024 CFLAGS="$CFLAGS $X_CFLAGS"
3025 AC_TRY_COMPILE([
3026#include <X11/Intrinsic.h>
3027#include <X11/neXtaw/Paned.h>], ,
3028 AC_MSG_RESULT(yes),
3029 AC_MSG_RESULT(no); SKIP_NEXTAW=YES )
3030 CFLAGS=$cflags_save
3031fi
3032
3033if test -z "$SKIP_NEXTAW"; then
3034 GUITYPE=NEXTAW
3035fi
3036
3037if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
3038 dnl Prepend -I and -L to $GUI_INC_LOC and $GUI_LIB_LOC if not empty
3039 dnl Avoid adding it when it twice
3040 if test -n "$GUI_INC_LOC"; then
3041 GUI_INC_LOC=-I"`echo $GUI_INC_LOC|sed 's%-I%%'`"
3042 fi
3043 if test -n "$GUI_LIB_LOC"; then
3044 GUI_LIB_LOC=-L"`echo $GUI_LIB_LOC|sed 's%-L%%'`"
3045 fi
3046
3047 dnl Check for -lXext and then for -lXmu
3048 ldflags_save=$LDFLAGS
3049 LDFLAGS="$X_LIBS $LDFLAGS"
3050 AC_CHECK_LIB(Xext, XShapeQueryExtension, [GUI_X_LIBS="-lXext"],,
3051 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3052 dnl For Solaris we need -lw and -ldl before linking with -lXmu works.
3053 AC_CHECK_LIB(w, wslen, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lw"],,
3054 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3055 AC_CHECK_LIB(dl, dlsym, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldl"],,
3056 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3057 AC_CHECK_LIB(Xmu, XmuCreateStippledPixmap, [GUI_X_LIBS="-lXmu $GUI_X_LIBS"],,
3058 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3059 if test -z "$SKIP_MOTIF"; then
3060 AC_CHECK_LIB(Xp, XpEndJob, [GUI_X_LIBS="-lXp $GUI_X_LIBS"],,
3061 [$GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3062 fi
3063 LDFLAGS=$ldflags_save
3064
3065 dnl Execute xmkmf to figure out if -DNARROWPROTO is needed.
3066 AC_MSG_CHECKING(for extra X11 defines)
3067 NARROW_PROTO=
3068 rm -fr conftestdir
3069 if mkdir conftestdir; then
3070 cd conftestdir
3071 cat > Imakefile <<'EOF'
3072acfindx:
3073 @echo 'NARROW_PROTO="${PROTO_DEFINES}"'
3074EOF
3075 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
3076 eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
3077 fi
3078 cd ..
3079 rm -fr conftestdir
3080 fi
3081 if test -z "$NARROW_PROTO"; then
3082 AC_MSG_RESULT(no)
3083 else
3084 AC_MSG_RESULT($NARROW_PROTO)
3085 fi
3086 AC_SUBST(NARROW_PROTO)
3087fi
3088
3089dnl Look for XSMP support - but don't necessarily restrict it to X11 GUIs
3090dnl use the X11 include path
3091if test "$enable_xsmp" = "yes"; then
3092 cppflags_save=$CPPFLAGS
3093 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3094 AC_CHECK_HEADERS(X11/SM/SMlib.h)
3095 CPPFLAGS=$cppflags_save
3096fi
3097
3098
Bram Moolenaar98921892016-02-23 17:14:37 +01003099if 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 +00003100 dnl Check for X11/xpm.h and X11/Sunkeysym.h with the GUI include path
3101 cppflags_save=$CPPFLAGS
3102 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3103 AC_CHECK_HEADERS(X11/xpm.h X11/Sunkeysym.h)
3104
3105 dnl automatically disable XIM when XIMtext isn't in X11/Xlib.h
3106 if test ! "$enable_xim" = "no"; then
3107 AC_MSG_CHECKING(for XIMText in X11/Xlib.h)
3108 AC_EGREP_CPP(XIMText, [#include <X11/Xlib.h>],
3109 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +02003110 AC_MSG_RESULT(no; xim has been disabled); enable_xim="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00003111 fi
3112 CPPFLAGS=$cppflags_save
3113
Bram Moolenaar54612582019-11-21 17:13:31 +01003114 dnl automatically enable XIM in the GUI
3115 if test "$enable_xim" = "auto" -a "x$GUITYPE" != "xNONE" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003116 AC_MSG_RESULT(X GUI selected; xim has been enabled)
3117 enable_xim="yes"
3118 fi
3119fi
3120
3121if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
3122 cppflags_save=$CPPFLAGS
3123 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00003124dnl Xmu/Editres.h may exist but can only be used after including Intrinsic.h
3125 AC_MSG_CHECKING([for X11/Xmu/Editres.h])
3126 AC_TRY_COMPILE([
3127#include <X11/Intrinsic.h>
3128#include <X11/Xmu/Editres.h>],
3129 [int i; i = 0;],
3130 AC_MSG_RESULT(yes)
3131 AC_DEFINE(HAVE_X11_XMU_EDITRES_H),
3132 AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003133 CPPFLAGS=$cppflags_save
3134fi
3135
3136dnl Only use the Xm directory when compiling Motif, don't use it for Athena
3137if test -z "$SKIP_MOTIF"; then
3138 cppflags_save=$CPPFLAGS
3139 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003140 if test "$zOSUnix" = "yes"; then
3141 xmheader="Xm/Xm.h"
3142 else
3143 xmheader="Xm/Xm.h Xm/XpmP.h Xm/JoinSideT.h Xm/TraitP.h Xm/Manager.h
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02003144 Xm/UnhighlightT.h Xm/Notebook.h"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003145 fi
3146 AC_CHECK_HEADERS($xmheader)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003147
Bram Moolenaar77c19352012-06-13 19:19:41 +02003148 if test "x$ac_cv_header_Xm_XpmP_h" = "xyes"; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003149 dnl Solaris uses XpmAttributes_21, very annoying.
3150 AC_MSG_CHECKING([for XpmAttributes_21 in Xm/XpmP.h])
3151 AC_TRY_COMPILE([#include <Xm/XpmP.h>], [XpmAttributes_21 attr;],
3152 AC_MSG_RESULT(yes); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes_21),
3153 AC_MSG_RESULT(no); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
3154 )
3155 else
Bram Moolenaar57657d82006-04-21 22:12:41 +00003156 AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003157 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003158 CPPFLAGS=$cppflags_save
3159fi
3160
3161if test "x$GUITYPE" = "xNONE" -a "$enable_xim" = "yes"; then
3162 AC_MSG_RESULT(no GUI selected; xim has been disabled)
3163 enable_xim="no"
3164fi
3165if test "x$GUITYPE" = "xNONE" -a "$enable_fontset" = "yes"; then
3166 AC_MSG_RESULT(no GUI selected; fontset has been disabled)
3167 enable_fontset="no"
3168fi
Bram Moolenaar182c5be2010-06-25 05:37:59 +02003169if test "x$GUITYPE:$enable_fontset" = "xGTK:yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003170 AC_MSG_RESULT(GTK+ 2 GUI selected; fontset has been disabled)
3171 enable_fontset="no"
3172fi
3173
Bram Moolenaarb3f74062020-02-26 16:16:53 +01003174dnl There is no test for the Haiku GUI, if it's selected it's used
3175if test -z "$SKIP_HAIKU"; then
3176 GUITYPE=HAIKUGUI
3177fi
3178
Bram Moolenaar071d4272004-06-13 20:20:40 +00003179if test -z "$SKIP_PHOTON"; then
3180 GUITYPE=PHOTONGUI
3181fi
3182
3183AC_SUBST(GUI_INC_LOC)
3184AC_SUBST(GUI_LIB_LOC)
3185AC_SUBST(GUITYPE)
3186AC_SUBST(GUI_X_LIBS)
3187
3188if test "$enable_workshop" = "yes" -a -n "$SKIP_MOTIF"; then
3189 AC_MSG_ERROR([cannot use workshop without Motif])
3190fi
3191
3192dnl defining FEAT_XIM and FEAT_XFONTSET is delayed, so that they can be disabled
3193if test "$enable_xim" = "yes"; then
3194 AC_DEFINE(FEAT_XIM)
3195fi
3196if test "$enable_fontset" = "yes"; then
3197 AC_DEFINE(FEAT_XFONTSET)
3198fi
3199
3200
3201dnl ---------------------------------------------------------------------------
3202dnl end of GUI-checking
3203dnl ---------------------------------------------------------------------------
3204
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003205AC_MSG_CHECKING([for /proc link to executable])
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003206if test -L "/proc/self/exe"; then
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003207 dnl Linux
3208 AC_MSG_RESULT([/proc/self/exe])
3209 AC_DEFINE(PROC_EXE_LINK, "/proc/self/exe")
3210elif test -L "/proc/self/path/a.out"; then
3211 dnl Solaris
3212 AC_MSG_RESULT([/proc/self/path/a.out])
3213 AC_DEFINE(PROC_EXE_LINK, "/proc/self/path/a.out")
3214elif test -L "/proc/curproc/file"; then
3215 dnl FreeBSD
3216 AC_MSG_RESULT([/proc/curproc/file])
3217 AC_DEFINE(PROC_EXE_LINK, "/proc/curproc/file")
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003218else
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003219 AC_MSG_RESULT(no)
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003220fi
3221
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003222dnl Check for Cygwin, which needs an extra source file if not using X11
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003223AC_MSG_CHECKING(for CYGWIN or MSYS environment)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003224case `uname` in
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003225 CYGWIN*|MSYS*) CYGWIN=yes; AC_MSG_RESULT(yes)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003226 AC_MSG_CHECKING(for CYGWIN clipboard support)
3227 if test "x$with_x" = "xno" ; then
3228 OS_EXTRA_SRC=winclip.c; OS_EXTRA_OBJ=objects/winclip.o
3229 AC_MSG_RESULT(yes)
3230 AC_DEFINE(FEAT_CYGWIN_WIN32_CLIPBOARD)
3231 else
3232 AC_MSG_RESULT(no - using X11)
3233 fi ;;
3234
3235 *) CYGWIN=no; AC_MSG_RESULT(no);;
3236esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00003237
Bram Moolenaar071d4272004-06-13 20:20:40 +00003238dnl Checks for libraries and include files.
3239
Bram Moolenaar446cb832008-06-24 21:56:24 +00003240AC_CACHE_CHECK([whether toupper is broken], [vim_cv_toupper_broken],
3241 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003242 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003243#include "confdefs.h"
3244#include <ctype.h>
3245#if STDC_HEADERS
3246# include <stdlib.h>
3247# include <stddef.h>
3248#endif
3249main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003250 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003251 vim_cv_toupper_broken=yes
3252 ],[
3253 vim_cv_toupper_broken=no
3254 ],[
3255 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_toupper_broken')
3256 ])])
3257
3258if test "x$vim_cv_toupper_broken" = "xyes" ; then
3259 AC_DEFINE(BROKEN_TOUPPER)
3260fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003261
3262AC_MSG_CHECKING(whether __DATE__ and __TIME__ work)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003263AC_TRY_COMPILE([#include <stdio.h>], [printf("(" __DATE__ " " __TIME__ ")");],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003264 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DATE_TIME),
3265 AC_MSG_RESULT(no))
3266
Bram Moolenaar0c094b92009-05-14 20:20:33 +00003267AC_MSG_CHECKING(whether __attribute__((unused)) is allowed)
3268AC_TRY_COMPILE([#include <stdio.h>], [int x __attribute__((unused));],
3269 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ATTRIBUTE_UNUSED),
3270 AC_MSG_RESULT(no))
3271
Bram Moolenaar071d4272004-06-13 20:20:40 +00003272dnl Checks for header files.
3273AC_CHECK_HEADER(elf.h, HAS_ELF=1)
3274dnl AC_CHECK_HEADER(dwarf.h, SVR4=1)
3275if test "$HAS_ELF" = 1; then
3276 AC_CHECK_LIB(elf, main)
3277fi
3278
3279AC_HEADER_DIRENT
3280
Bram Moolenaar071d4272004-06-13 20:20:40 +00003281dnl If sys/wait.h is not found it might still exist but not be POSIX
3282dnl compliant. In that case we define HAVE_UNION_WAIT (for NeXT)
3283if test $ac_cv_header_sys_wait_h = no; then
3284 AC_MSG_CHECKING([for sys/wait.h that defines union wait])
3285 AC_TRY_COMPILE([#include <sys/wait.h>],
3286 [union wait xx, yy; xx = yy],
3287 AC_MSG_RESULT(yes)
3288 AC_DEFINE(HAVE_SYS_WAIT_H)
3289 AC_DEFINE(HAVE_UNION_WAIT),
3290 AC_MSG_RESULT(no))
3291fi
3292
Bram Moolenaar779a7752016-01-30 23:26:34 +01003293AC_CHECK_HEADERS(stdint.h stdlib.h string.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003294 sys/select.h sys/utsname.h termcap.h fcntl.h \
3295 sgtty.h sys/ioctl.h sys/time.h sys/types.h \
3296 termio.h iconv.h inttypes.h langinfo.h math.h \
3297 unistd.h stropts.h errno.h sys/resource.h \
3298 sys/systeminfo.h locale.h sys/stream.h termios.h \
3299 libc.h sys/statfs.h poll.h sys/poll.h pwd.h \
Bram Moolenaar1ecc5e42019-01-26 15:12:55 +01003300 utime.h sys/param.h sys/ptms.h libintl.h libgen.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003301 util/debug.h util/msg18n.h frame.h sys/acl.h \
3302 sys/access.h sys/sysinfo.h wchar.h wctype.h)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003303
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003304dnl sys/ptem.h depends on sys/stream.h on Solaris
3305AC_CHECK_HEADERS(sys/ptem.h, [], [],
3306[#if defined HAVE_SYS_STREAM_H
3307# include <sys/stream.h>
3308#endif])
3309
Bram Moolenaar32f31b12009-05-21 13:20:59 +00003310dnl sys/sysctl.h depends on sys/param.h on OpenBSD
3311AC_CHECK_HEADERS(sys/sysctl.h, [], [],
3312[#if defined HAVE_SYS_PARAM_H
3313# include <sys/param.h>
3314#endif])
3315
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003316
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003317dnl pthread_np.h may exist but can only be used after including pthread.h
3318AC_MSG_CHECKING([for pthread_np.h])
3319AC_TRY_COMPILE([
3320#include <pthread.h>
3321#include <pthread_np.h>],
3322 [int i; i = 0;],
3323 AC_MSG_RESULT(yes)
3324 AC_DEFINE(HAVE_PTHREAD_NP_H),
3325 AC_MSG_RESULT(no))
3326
Bram Moolenaare344bea2005-09-01 20:46:49 +00003327AC_CHECK_HEADERS(strings.h)
Bram Moolenaard0573012017-10-28 21:11:06 +02003328if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00003329 dnl The strings.h file on OS/X contains a warning and nothing useful.
3330 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3331else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003332
3333dnl Check if strings.h and string.h can both be included when defined.
3334AC_MSG_CHECKING([if strings.h can be included after string.h])
3335cppflags_save=$CPPFLAGS
3336CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3337AC_TRY_COMPILE([
3338#if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO)
3339# define _NO_PROTO /* like in os_unix.h, causes conflict for AIX (Winn) */
3340 /* but don't do it on AIX 5.1 (Uribarri) */
3341#endif
3342#ifdef HAVE_XM_XM_H
3343# include <Xm/Xm.h> /* This breaks it for HP-UX 11 (Squassabia) */
3344#endif
3345#ifdef HAVE_STRING_H
3346# include <string.h>
3347#endif
3348#if defined(HAVE_STRINGS_H)
3349# include <strings.h>
3350#endif
3351 ], [int i; i = 0;],
3352 AC_MSG_RESULT(yes),
3353 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3354 AC_MSG_RESULT(no))
3355CPPFLAGS=$cppflags_save
Bram Moolenaar9372a112005-12-06 19:59:18 +00003356fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003357
3358dnl Checks for typedefs, structures, and compiler characteristics.
3359AC_PROG_GCC_TRADITIONAL
3360AC_C_CONST
Bram Moolenaar76243bd2009-03-02 01:47:02 +00003361AC_C_VOLATILE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003362AC_TYPE_MODE_T
3363AC_TYPE_OFF_T
3364AC_TYPE_PID_T
3365AC_TYPE_SIZE_T
3366AC_TYPE_UID_T
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003367AC_TYPE_UINT32_T
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003368
Bram Moolenaar071d4272004-06-13 20:20:40 +00003369AC_HEADER_TIME
3370AC_CHECK_TYPE(ino_t, long)
3371AC_CHECK_TYPE(dev_t, unsigned)
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003372AC_C_BIGENDIAN(,,,)
Bram Moolenaar136f29a2016-02-27 20:14:15 +01003373AC_C_INLINE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003374
3375AC_MSG_CHECKING(for rlim_t)
3376if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
3377 AC_MSG_RESULT([(cached) $ac_cv_type_rlim_t])
3378else
3379 AC_EGREP_CPP(dnl
3380changequote(<<,>>)dnl
3381<<(^|[^a-zA-Z_0-9])rlim_t[^a-zA-Z_0-9]>>dnl
3382changequote([,]),
3383 [
3384#include <sys/types.h>
3385#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003386# include <stdlib.h>
3387# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003388#endif
3389#ifdef HAVE_SYS_RESOURCE_H
Bram Moolenaar446cb832008-06-24 21:56:24 +00003390# include <sys/resource.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003391#endif
3392 ], ac_cv_type_rlim_t=yes, ac_cv_type_rlim_t=no)
3393 AC_MSG_RESULT($ac_cv_type_rlim_t)
3394fi
3395if test $ac_cv_type_rlim_t = no; then
3396 cat >> confdefs.h <<\EOF
3397#define rlim_t unsigned long
3398EOF
3399fi
3400
3401AC_MSG_CHECKING(for stack_t)
3402if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then
3403 AC_MSG_RESULT([(cached) $ac_cv_type_stack_t])
3404else
3405 AC_EGREP_CPP(stack_t,
3406 [
3407#include <sys/types.h>
3408#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003409# include <stdlib.h>
3410# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003411#endif
3412#include <signal.h>
3413 ], ac_cv_type_stack_t=yes, ac_cv_type_stack_t=no)
3414 AC_MSG_RESULT($ac_cv_type_stack_t)
3415fi
3416if test $ac_cv_type_stack_t = no; then
3417 cat >> confdefs.h <<\EOF
3418#define stack_t struct sigaltstack
3419EOF
3420fi
3421
3422dnl BSDI uses ss_base while others use ss_sp for the stack pointer.
3423AC_MSG_CHECKING(whether stack_t has an ss_base field)
3424AC_TRY_COMPILE([
3425#include <sys/types.h>
3426#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003427# include <stdlib.h>
3428# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003429#endif
3430#include <signal.h>
3431#include "confdefs.h"
3432 ], [stack_t sigstk; sigstk.ss_base = 0; ],
3433 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SS_BASE),
3434 AC_MSG_RESULT(no))
3435
3436olibs="$LIBS"
3437AC_MSG_CHECKING(--with-tlib argument)
3438AC_ARG_WITH(tlib, [ --with-tlib=library terminal library to be used ],)
3439if test -n "$with_tlib"; then
3440 AC_MSG_RESULT($with_tlib)
3441 LIBS="$LIBS -l$with_tlib"
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003442 AC_MSG_CHECKING(for linking with $with_tlib library)
3443 AC_TRY_LINK([], [], AC_MSG_RESULT(OK), AC_MSG_ERROR(FAILED))
3444 dnl Need to check for tgetent() below.
3445 olibs="$LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003446else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003447 AC_MSG_RESULT([empty: automatic terminal library selection])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003448 dnl On HP-UX 10.10 termcap or termlib should be used instead of
3449 dnl curses, because curses is much slower.
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003450 dnl Newer versions of ncurses are preferred over anything, except
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02003451 dnl when tinfo has been split off, it contains all we need.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003452 dnl Older versions of ncurses have bugs, get a new one!
3453 dnl Digital Unix (OSF1) should use curses (Ronald Schild).
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00003454 dnl On SCO Openserver should prefer termlib (Roger Cornelius).
Bram Moolenaar071d4272004-06-13 20:20:40 +00003455 case "`uname -s 2>/dev/null`" in
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003456 OSF1|SCO_SV) tlibs="tinfo ncurses curses termlib termcap";;
3457 *) tlibs="tinfo ncurses termlib termcap curses";;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003458 esac
3459 for libname in $tlibs; do
3460 AC_CHECK_LIB(${libname}, tgetent,,)
3461 if test "x$olibs" != "x$LIBS"; then
3462 dnl It's possible that a library is found but it doesn't work
3463 dnl e.g., shared library that cannot be found
3464 dnl compile and run a test program to be sure
3465 AC_TRY_RUN([
3466#ifdef HAVE_TERMCAP_H
3467# include <termcap.h>
3468#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003469#if STDC_HEADERS
3470# include <stdlib.h>
3471# include <stddef.h>
3472#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003473main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }],
3474 res="OK", res="FAIL", res="FAIL")
3475 if test "$res" = "OK"; then
3476 break
3477 fi
3478 AC_MSG_RESULT($libname library is not usable)
3479 LIBS="$olibs"
3480 fi
3481 done
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003482 if test "x$olibs" = "x$LIBS"; then
3483 AC_MSG_RESULT(no terminal library found)
3484 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003485fi
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003486
3487if test "x$olibs" = "x$LIBS"; then
3488 AC_MSG_CHECKING([for tgetent()])
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00003489 AC_TRY_LINK([],
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003490 [char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");],
3491 AC_MSG_RESULT(yes),
3492 AC_MSG_ERROR([NOT FOUND!
3493 You need to install a terminal library; for example ncurses.
3494 Or specify the name of the library with --with-tlib.]))
3495fi
3496
Bram Moolenaar446cb832008-06-24 21:56:24 +00003497AC_CACHE_CHECK([whether we talk terminfo], [vim_cv_terminfo],
3498 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003499 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003500#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003501#ifdef HAVE_TERMCAP_H
3502# include <termcap.h>
3503#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003504#ifdef HAVE_STRING_H
3505# include <string.h>
3506#endif
3507#if STDC_HEADERS
3508# include <stdlib.h>
3509# include <stddef.h>
3510#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003511main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003512{char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003513 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003514 vim_cv_terminfo=no
3515 ],[
3516 vim_cv_terminfo=yes
3517 ],[
3518 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_terminfo')
3519 ])
3520 ])
3521
3522if test "x$vim_cv_terminfo" = "xyes" ; then
3523 AC_DEFINE(TERMINFO)
3524fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003525
Bram Moolenaara88254f2017-11-02 23:04:14 +01003526AC_CACHE_CHECK([what tgetent() returns for an unknown terminal], [vim_cv_tgetent],
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003527 [
3528 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#if STDC_HEADERS
3534# include <stdlib.h>
3535# include <stddef.h>
3536#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003537main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003538{char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003539 ]])],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003540 vim_cv_tgetent=zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003541 ],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003542 vim_cv_tgetent=non-zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003543 ],[
3544 AC_MSG_ERROR(failed to compile test program.)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003545 ])
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003546 ])
3547
Bram Moolenaara88254f2017-11-02 23:04:14 +01003548if test "x$vim_cv_tgetent" = "xzero" ; then
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003549 AC_DEFINE(TGETENT_ZERO_ERR, 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003550fi
3551
3552AC_MSG_CHECKING(whether termcap.h contains ospeed)
3553AC_TRY_LINK([
3554#ifdef HAVE_TERMCAP_H
3555# include <termcap.h>
3556#endif
3557 ], [ospeed = 20000],
3558 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED),
3559 [AC_MSG_RESULT(no)
3560 AC_MSG_CHECKING(whether ospeed can be extern)
3561 AC_TRY_LINK([
3562#ifdef HAVE_TERMCAP_H
3563# include <termcap.h>
3564#endif
3565extern short ospeed;
3566 ], [ospeed = 20000],
3567 AC_MSG_RESULT(yes); AC_DEFINE(OSPEED_EXTERN),
3568 AC_MSG_RESULT(no))]
3569 )
3570
3571AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC])
3572AC_TRY_LINK([
3573#ifdef HAVE_TERMCAP_H
3574# include <termcap.h>
3575#endif
3576 ], [if (UP == 0 && BC == 0) PC = 1],
3577 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UP_BC_PC),
3578 [AC_MSG_RESULT(no)
3579 AC_MSG_CHECKING([whether UP, BC and PC can be extern])
3580 AC_TRY_LINK([
3581#ifdef HAVE_TERMCAP_H
3582# include <termcap.h>
3583#endif
3584extern char *UP, *BC, PC;
3585 ], [if (UP == 0 && BC == 0) PC = 1],
3586 AC_MSG_RESULT(yes); AC_DEFINE(UP_BC_PC_EXTERN),
3587 AC_MSG_RESULT(no))]
3588 )
3589
3590AC_MSG_CHECKING(whether tputs() uses outfuntype)
3591AC_TRY_COMPILE([
3592#ifdef HAVE_TERMCAP_H
3593# include <termcap.h>
3594#endif
3595 ], [extern int xx(); tputs("test", 1, (outfuntype)xx)],
3596 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OUTFUNTYPE),
3597 AC_MSG_RESULT(no))
3598
3599dnl On some SCO machines sys/select redefines struct timeval
3600AC_MSG_CHECKING([whether sys/select.h and sys/time.h may both be included])
3601AC_TRY_COMPILE([
3602#include <sys/types.h>
3603#include <sys/time.h>
3604#include <sys/select.h>], ,
3605 AC_MSG_RESULT(yes)
3606 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME),
3607 AC_MSG_RESULT(no))
3608
3609dnl AC_DECL_SYS_SIGLIST
3610
3611dnl Checks for pty.c (copied from screen) ==========================
3612AC_MSG_CHECKING(for /dev/ptc)
3613if test -r /dev/ptc; then
3614 AC_DEFINE(HAVE_DEV_PTC)
3615 AC_MSG_RESULT(yes)
3616else
3617 AC_MSG_RESULT(no)
3618fi
3619
3620AC_MSG_CHECKING(for SVR4 ptys)
3621if test -c /dev/ptmx ; then
3622 AC_TRY_LINK([], [ptsname(0);grantpt(0);unlockpt(0);],
3623 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SVR4_PTYS),
3624 AC_MSG_RESULT(no))
3625else
3626 AC_MSG_RESULT(no)
3627fi
3628
3629AC_MSG_CHECKING(for ptyranges)
3630if test -d /dev/ptym ; then
3631 pdir='/dev/ptym'
3632else
3633 pdir='/dev'
3634fi
3635dnl SCO uses ptyp%d
3636AC_EGREP_CPP(yes,
3637[#ifdef M_UNIX
3638 yes;
3639#endif
3640 ], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
3641dnl if test -c /dev/ptyp19; then
3642dnl ptys=`echo /dev/ptyp??`
3643dnl else
3644dnl ptys=`echo $pdir/pty??`
3645dnl fi
3646if test "$ptys" != "$pdir/pty??" ; then
3647 p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
3648 p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'`
3649 AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
3650 AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
3651 AC_MSG_RESULT([$p0 / $p1])
3652else
3653 AC_MSG_RESULT([don't know])
3654fi
3655
3656dnl **** pty mode/group handling ****
3657dnl
3658dnl support provided by Luke Mewburn <lm@rmit.edu.au>, 931222
Bram Moolenaar071d4272004-06-13 20:20:40 +00003659rm -f conftest_grp
Bram Moolenaar446cb832008-06-24 21:56:24 +00003660AC_CACHE_CHECK([default tty permissions/group], [vim_cv_tty_group],
3661 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003662 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003663#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003664#include <sys/types.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003665#if STDC_HEADERS
3666# include <stdlib.h>
3667# include <stddef.h>
3668#endif
3669#ifdef HAVE_UNISTD_H
3670#include <unistd.h>
3671#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003672#include <sys/stat.h>
3673#include <stdio.h>
3674main()
3675{
3676 struct stat sb;
3677 char *x,*ttyname();
3678 int om, m;
3679 FILE *fp;
3680
3681 if (!(x = ttyname(0))) exit(1);
3682 if (stat(x, &sb)) exit(1);
3683 om = sb.st_mode;
3684 if (om & 002) exit(0);
3685 m = system("mesg y");
3686 if (m == -1 || m == 127) exit(1);
3687 if (stat(x, &sb)) exit(1);
3688 m = sb.st_mode;
3689 if (chmod(x, om)) exit(1);
3690 if (m & 002) exit(0);
3691 if (sb.st_gid == getgid()) exit(1);
3692 if (!(fp=fopen("conftest_grp", "w")))
3693 exit(1);
3694 fprintf(fp, "%d\n", sb.st_gid);
3695 fclose(fp);
3696 exit(0);
3697}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003698 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003699 if test -f conftest_grp; then
3700 vim_cv_tty_group=`cat conftest_grp`
3701 if test "x$vim_cv_tty_mode" = "x" ; then
3702 vim_cv_tty_mode=0620
3703 fi
3704 AC_MSG_RESULT([pty mode: $vim_cv_tty_mode, group: $vim_cv_tty_group])
3705 else
3706 vim_cv_tty_group=world
Bram Moolenaar72951072009-12-02 16:58:33 +00003707 AC_MSG_RESULT([ptys are world accessible])
Bram Moolenaar446cb832008-06-24 21:56:24 +00003708 fi
3709 ],[
3710 vim_cv_tty_group=world
Bram Moolenaar72951072009-12-02 16:58:33 +00003711 AC_MSG_RESULT([can't determine - assume ptys are world accessible])
Bram Moolenaar446cb832008-06-24 21:56:24 +00003712 ],[
3713 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_tty_group' and 'vim_cv_tty_mode')
3714 ])
3715 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003716rm -f conftest_grp
3717
Bram Moolenaar446cb832008-06-24 21:56:24 +00003718if test "x$vim_cv_tty_group" != "xworld" ; then
3719 AC_DEFINE_UNQUOTED(PTYGROUP,$vim_cv_tty_group)
3720 if test "x$vim_cv_tty_mode" = "x" ; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02003721 AC_MSG_ERROR([It seems you're cross compiling and have 'vim_cv_tty_group' set, please also set the environment variable 'vim_cv_tty_mode' to the correct mode (probably 0620)])
Bram Moolenaar446cb832008-06-24 21:56:24 +00003722 else
3723 AC_DEFINE(PTYMODE, 0620)
3724 fi
3725fi
3726
Bram Moolenaar071d4272004-06-13 20:20:40 +00003727dnl Checks for library functions. ===================================
3728
3729AC_TYPE_SIGNAL
3730
3731dnl find out what to use at the end of a signal function
3732if test $ac_cv_type_signal = void; then
3733 AC_DEFINE(SIGRETURN, [return])
3734else
3735 AC_DEFINE(SIGRETURN, [return 0])
3736fi
3737
3738dnl check if struct sigcontext is defined (used for SGI only)
3739AC_MSG_CHECKING(for struct sigcontext)
3740AC_TRY_COMPILE([
3741#include <signal.h>
3742test_sig()
3743{
3744 struct sigcontext *scont;
3745 scont = (struct sigcontext *)0;
3746 return 1;
3747} ], ,
3748 AC_MSG_RESULT(yes)
3749 AC_DEFINE(HAVE_SIGCONTEXT),
3750 AC_MSG_RESULT(no))
3751
3752dnl tricky stuff: try to find out if getcwd() is implemented with
3753dnl system("sh -c pwd")
Bram Moolenaar446cb832008-06-24 21:56:24 +00003754AC_CACHE_CHECK([getcwd implementation is broken], [vim_cv_getcwd_broken],
3755 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003756 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003757#include "confdefs.h"
3758#ifdef HAVE_UNISTD_H
3759#include <unistd.h>
3760#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003761char *dagger[] = { "IFS=pwd", 0 };
3762main()
3763{
3764 char buffer[500];
3765 extern char **environ;
3766 environ = dagger;
3767 return getcwd(buffer, 500) ? 0 : 1;
Bram Moolenaar446cb832008-06-24 21:56:24 +00003768}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003769 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003770 vim_cv_getcwd_broken=no
3771 ],[
3772 vim_cv_getcwd_broken=yes
3773 ],[
3774 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_getcwd_broken')
3775 ])
3776 ])
3777
3778if test "x$vim_cv_getcwd_broken" = "xyes" ; then
3779 AC_DEFINE(BAD_GETCWD)
Bram Moolenaar63d25552019-05-10 21:28:38 +02003780 AC_CHECK_FUNCS(getwd)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003781fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003782
Bram Moolenaar25153e12010-02-24 14:47:08 +01003783dnl Check for functions in one big call, to reduce the size of configure.
3784dnl Can only be used for functions that do not require any include.
Bram Moolenaarcd142e32017-11-16 17:03:45 +01003785AC_CHECK_FUNCS(fchdir fchown fchmod fsync getcwd getpseudotty \
Bram Moolenaar63d25552019-05-10 21:28:38 +02003786 getpwent getpwnam getpwuid getrlimit gettimeofday localtime_r lstat \
Bram Moolenaareaf03392009-11-17 11:08:52 +00003787 memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
Bram Moolenaar2fcf6682017-03-11 20:03:42 +01003788 getpgid setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
Bram Moolenaarbb09ceb2016-10-18 16:27:23 +02003789 sigprocmask sigvec strcasecmp strerror strftime stricmp strncasecmp \
Bram Moolenaar10455d42019-11-21 15:36:18 +01003790 strnicmp strpbrk strptime strtol tgetent towlower towupper iswupper \
3791 tzset usleep utime utimes mblen ftruncate unsetenv posix_openpt)
Bram Moolenaar643b6142018-09-12 20:29:09 +02003792AC_FUNC_SELECT_ARGTYPES
Bram Moolenaar25153e12010-02-24 14:47:08 +01003793AC_FUNC_FSEEKO
Bram Moolenaar071d4272004-06-13 20:20:40 +00003794
Bram Moolenaar317fd3a2010-05-07 16:05:55 +02003795dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when
3796dnl appropriate, so that off_t is 64 bits when needed.
3797AC_SYS_LARGEFILE
3798
Bram Moolenaar21606672019-06-14 20:40:58 +02003799AC_MSG_CHECKING(--enable-canberra argument)
3800AC_ARG_ENABLE(canberra,
3801 [ --disable-canberra Do not use libcanberra.],
3802 , [enable_canberra="maybe"])
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003803
Bram Moolenaar21606672019-06-14 20:40:58 +02003804if test "$enable_canberra" = "maybe"; then
3805 if test "$features" = "big" -o "$features" = "huge"; then
3806 AC_MSG_RESULT(Defaulting to yes)
3807 enable_canberra="yes"
3808 else
3809 AC_MSG_RESULT(Defaulting to no)
3810 enable_canberra="no"
3811 fi
3812else
3813 AC_MSG_RESULT($enable_canberra)
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003814fi
Bram Moolenaar21606672019-06-14 20:40:58 +02003815if test "$enable_canberra" = "yes"; then
3816 if test "x$PKG_CONFIG" != "xno"; then
3817 canberra_lib=`$PKG_CONFIG --libs libcanberra 2>/dev/null`
3818 canberra_cflags=`$PKG_CONFIG --cflags libcanberra 2>/dev/null`
3819 fi
3820 if test "x$canberra_lib" = "x"; then
3821 canberra_lib=-lcanberra
3822 canberra_cflags=-D_REENTRANT
3823 fi
3824 AC_MSG_CHECKING(for libcanberra)
3825 ac_save_CFLAGS="$CFLAGS"
3826 ac_save_LIBS="$LIBS"
3827 CFLAGS="$CFLAGS $canberra_cflags"
3828 LIBS="$LIBS $canberra_lib"
3829 AC_TRY_LINK([
3830 # include <canberra.h>
3831 ], [
3832 ca_context *hello;
3833 ca_context_create(&hello);],
3834 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_CANBERRA),
Bram Moolenaar91b992c2019-11-17 19:07:42 +01003835 AC_MSG_RESULT(no; try installing libcanberra-dev); CFLAGS="$ac_save_CFLAGS"; LIBS="$ac_save_LIBS")
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003836fi
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003837
3838
Bram Moolenaar071d4272004-06-13 20:20:40 +00003839dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible
3840AC_MSG_CHECKING(for st_blksize)
3841AC_TRY_COMPILE(
3842[#include <sys/types.h>
3843#include <sys/stat.h>],
3844[ struct stat st;
3845 int n;
3846
3847 stat("/", &st);
3848 n = (int)st.st_blksize;],
3849 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ST_BLKSIZE),
3850 AC_MSG_RESULT(no))
3851
Bram Moolenaar446cb832008-06-24 21:56:24 +00003852AC_CACHE_CHECK([whether stat() ignores a trailing slash], [vim_cv_stat_ignores_slash],
3853 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003854 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003855#include "confdefs.h"
3856#if STDC_HEADERS
3857# include <stdlib.h>
3858# include <stddef.h>
3859#endif
3860#include <sys/types.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003861#include <sys/stat.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003862main() {struct stat st; exit(stat("configure/", &st) != 0); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003863 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003864 vim_cv_stat_ignores_slash=yes
3865 ],[
3866 vim_cv_stat_ignores_slash=no
3867 ],[
3868 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_stat_ignores_slash')
3869 ])
3870 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003871
Bram Moolenaar446cb832008-06-24 21:56:24 +00003872if test "x$vim_cv_stat_ignores_slash" = "xyes" ; then
3873 AC_DEFINE(STAT_IGNORES_SLASH)
3874fi
3875
Bram Moolenaar071d4272004-06-13 20:20:40 +00003876dnl Link with iconv for charset translation, if not found without library.
3877dnl check for iconv() requires including iconv.h
3878dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
3879dnl has been installed.
3880AC_MSG_CHECKING(for iconv_open())
3881save_LIBS="$LIBS"
3882LIBS="$LIBS -liconv"
3883AC_TRY_LINK([
3884#ifdef HAVE_ICONV_H
3885# include <iconv.h>
3886#endif
3887 ], [iconv_open("fr", "to");],
3888 AC_MSG_RESULT(yes; with -liconv); AC_DEFINE(HAVE_ICONV),
3889 LIBS="$save_LIBS"
3890 AC_TRY_LINK([
3891#ifdef HAVE_ICONV_H
3892# include <iconv.h>
3893#endif
3894 ], [iconv_open("fr", "to");],
3895 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ICONV),
3896 AC_MSG_RESULT(no)))
3897
3898
3899AC_MSG_CHECKING(for nl_langinfo(CODESET))
3900AC_TRY_LINK([
3901#ifdef HAVE_LANGINFO_H
3902# include <langinfo.h>
3903#endif
3904], [char *cs = nl_langinfo(CODESET);],
3905 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET),
3906 AC_MSG_RESULT(no))
3907
Bram Moolenaar446cb832008-06-24 21:56:24 +00003908dnl Need various functions for floating point support. Only enable
3909dnl floating point when they are all present.
3910AC_CHECK_LIB(m, strtod)
3911AC_MSG_CHECKING([for strtod() and other floating point functions])
3912AC_TRY_LINK([
3913#ifdef HAVE_MATH_H
3914# include <math.h>
3915#endif
3916#if STDC_HEADERS
3917# include <stdlib.h>
3918# include <stddef.h>
3919#endif
3920], [char *s; double d;
3921 d = strtod("1.1", &s);
3922 d = fabs(1.11);
3923 d = ceil(1.11);
3924 d = floor(1.11);
3925 d = log10(1.11);
3926 d = pow(1.11, 2.22);
3927 d = sqrt(1.11);
3928 d = sin(1.11);
3929 d = cos(1.11);
3930 d = atan(1.11);
3931 ],
3932 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT_FUNCS),
3933 AC_MSG_RESULT(no))
3934
Bram Moolenaara6b89762016-02-29 21:38:26 +01003935dnl isinf() and isnan() need to include header files and may need -lm.
3936AC_MSG_CHECKING([for isinf()])
3937AC_TRY_LINK([
3938#ifdef HAVE_MATH_H
3939# include <math.h>
3940#endif
3941#if STDC_HEADERS
3942# include <stdlib.h>
3943# include <stddef.h>
3944#endif
3945], [int r = isinf(1.11); ],
3946 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISINF),
3947 AC_MSG_RESULT(no))
3948
3949AC_MSG_CHECKING([for isnan()])
3950AC_TRY_LINK([
3951#ifdef HAVE_MATH_H
3952# include <math.h>
3953#endif
3954#if STDC_HEADERS
3955# include <stdlib.h>
3956# include <stddef.h>
3957#endif
3958], [int r = isnan(1.11); ],
3959 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISNAN),
3960 AC_MSG_RESULT(no))
3961
Bram Moolenaar071d4272004-06-13 20:20:40 +00003962dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI
3963dnl when -lacl works, also try to use -lattr (required for Debian).
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003964dnl On Solaris, use the acl_get/set functions in libsec, if present.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003965AC_MSG_CHECKING(--disable-acl argument)
3966AC_ARG_ENABLE(acl,
Bram Moolenaard6d30422018-01-28 22:48:55 +01003967 [ --disable-acl No check for ACL support.],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003968 , [enable_acl="yes"])
3969if test "$enable_acl" = "yes"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01003970 AC_MSG_RESULT(no)
3971 AC_CHECK_LIB(posix1e, acl_get_file, [LIBS="$LIBS -lposix1e"],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003972 AC_CHECK_LIB(acl, acl_get_file, [LIBS="$LIBS -lacl"
3973 AC_CHECK_LIB(attr, fgetxattr, LIBS="$LIBS -lattr",,)],,),)
3974
Bram Moolenaard6d30422018-01-28 22:48:55 +01003975 AC_MSG_CHECKING(for POSIX ACL support)
3976 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003977#include <sys/types.h>
3978#ifdef HAVE_SYS_ACL_H
3979# include <sys/acl.h>
3980#endif
3981acl_t acl;], [acl = acl_get_file("foo", ACL_TYPE_ACCESS);
3982 acl_set_file("foo", ACL_TYPE_ACCESS, acl);
3983 acl_free(acl);],
3984 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_ACL),
3985 AC_MSG_RESULT(no))
3986
Bram Moolenaard6d30422018-01-28 22:48:55 +01003987 AC_CHECK_LIB(sec, acl_get, [LIBS="$LIBS -lsec"; AC_DEFINE(HAVE_SOLARIS_ZFS_ACL)],
3988 AC_MSG_CHECKING(for Solaris ACL support)
3989 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003990#ifdef HAVE_SYS_ACL_H
3991# include <sys/acl.h>
3992#endif], [acl("foo", GETACLCNT, 0, NULL);
3993 ],
3994 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOLARIS_ACL),
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003995 AC_MSG_RESULT(no)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003996
Bram Moolenaard6d30422018-01-28 22:48:55 +01003997 AC_MSG_CHECKING(for AIX ACL support)
3998 AC_TRY_LINK([
Bram Moolenaar446cb832008-06-24 21:56:24 +00003999#if STDC_HEADERS
4000# include <stdlib.h>
4001# include <stddef.h>
4002#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004003#ifdef HAVE_SYS_ACL_H
4004# include <sys/acl.h>
4005#endif
4006#ifdef HAVE_SYS_ACCESS_H
4007# include <sys/access.h>
4008#endif
4009#define _ALL_SOURCE
4010
4011#include <sys/stat.h>
4012
4013int aclsize;
4014struct acl *aclent;], [aclsize = sizeof(struct acl);
4015 aclent = (void *)malloc(aclsize);
4016 statacl("foo", STX_NORMAL, aclent, aclsize);
4017 ],
4018 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_AIX_ACL),
4019 AC_MSG_RESULT(no))
4020else
4021 AC_MSG_RESULT(yes)
4022fi
4023
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02004024if test "x$GTK_CFLAGS" != "x"; then
4025 dnl pango_shape_full() is new, fall back to pango_shape().
4026 AC_MSG_CHECKING(for pango_shape_full)
4027 ac_save_CFLAGS="$CFLAGS"
4028 ac_save_LIBS="$LIBS"
4029 CFLAGS="$CFLAGS $GTK_CFLAGS"
4030 LIBS="$LIBS $GTK_LIBS"
Bram Moolenaar5325b9b2015-09-09 20:27:02 +02004031 AC_TRY_LINK(
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02004032 [#include <gtk/gtk.h>],
4033 [ pango_shape_full(NULL, 0, NULL, 0, NULL, NULL); ],
4034 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_PANGO_SHAPE_FULL),
4035 AC_MSG_RESULT(no))
4036 CFLAGS="$ac_save_CFLAGS"
4037 LIBS="$ac_save_LIBS"
4038fi
4039
Bram Moolenaar071d4272004-06-13 20:20:40 +00004040AC_MSG_CHECKING(--disable-gpm argument)
4041AC_ARG_ENABLE(gpm,
4042 [ --disable-gpm Don't use gpm (Linux mouse daemon).], ,
4043 [enable_gpm="yes"])
4044
4045if test "$enable_gpm" = "yes"; then
4046 AC_MSG_RESULT(no)
4047 dnl Checking if gpm support can be compiled
4048 AC_CACHE_CHECK([for gpm], vi_cv_have_gpm,
4049 [olibs="$LIBS" ; LIBS="-lgpm"]
4050 AC_TRY_LINK(
4051 [#include <gpm.h>
4052 #include <linux/keyboard.h>],
4053 [Gpm_GetLibVersion(NULL);],
4054 dnl Configure defines HAVE_GPM, if it is defined feature.h defines
4055 dnl FEAT_MOUSE_GPM if mouse support is included
4056 [vi_cv_have_gpm=yes],
4057 [vi_cv_have_gpm=no])
4058 [LIBS="$olibs"]
4059 )
4060 if test $vi_cv_have_gpm = yes; then
4061 LIBS="$LIBS -lgpm"
4062 AC_DEFINE(HAVE_GPM)
4063 fi
4064else
4065 AC_MSG_RESULT(yes)
4066fi
4067
Bram Moolenaar446cb832008-06-24 21:56:24 +00004068AC_MSG_CHECKING(--disable-sysmouse argument)
4069AC_ARG_ENABLE(sysmouse,
Bram Moolenaar8008b632017-07-18 21:33:20 +02004070 [ --disable-sysmouse Don't use sysmouse (mouse in *BSD console).], ,
Bram Moolenaar446cb832008-06-24 21:56:24 +00004071 [enable_sysmouse="yes"])
4072
4073if test "$enable_sysmouse" = "yes"; then
4074 AC_MSG_RESULT(no)
4075 dnl Checking if sysmouse support can be compiled
4076 dnl Configure defines HAVE_SYSMOUSE, if it is defined feature.h
4077 dnl defines FEAT_SYSMOUSE if mouse support is included
4078 AC_CACHE_CHECK([for sysmouse], vi_cv_have_sysmouse,
4079 AC_TRY_LINK(
4080 [#include <sys/consio.h>
4081 #include <signal.h>
4082 #include <sys/fbio.h>],
4083 [struct mouse_info mouse;
4084 mouse.operation = MOUSE_MODE;
4085 mouse.operation = MOUSE_SHOW;
4086 mouse.u.mode.mode = 0;
4087 mouse.u.mode.signal = SIGUSR2;],
4088 [vi_cv_have_sysmouse=yes],
4089 [vi_cv_have_sysmouse=no])
4090 )
4091 if test $vi_cv_have_sysmouse = yes; then
4092 AC_DEFINE(HAVE_SYSMOUSE)
4093 fi
4094else
4095 AC_MSG_RESULT(yes)
4096fi
4097
Bram Moolenaarf05da212009-11-17 16:13:15 +00004098dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
4099AC_MSG_CHECKING(for FD_CLOEXEC)
4100AC_TRY_COMPILE(
4101[#if HAVE_FCNTL_H
4102# include <fcntl.h>
4103#endif],
4104[ int flag = FD_CLOEXEC;],
4105 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
4106 AC_MSG_RESULT(not usable))
4107
Bram Moolenaar071d4272004-06-13 20:20:40 +00004108dnl rename needs to be checked separately to work on Nextstep with cc
4109AC_MSG_CHECKING(for rename)
4110AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
4111 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
4112 AC_MSG_RESULT(no))
4113
4114dnl sysctl() may exist but not the arguments we use
4115AC_MSG_CHECKING(for sysctl)
4116AC_TRY_COMPILE(
4117[#include <sys/types.h>
4118#include <sys/sysctl.h>],
4119[ int mib[2], r;
4120 size_t len;
4121
4122 mib[0] = CTL_HW;
4123 mib[1] = HW_USERMEM;
4124 len = sizeof(r);
4125 (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
4126 ],
4127 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL),
4128 AC_MSG_RESULT(not usable))
4129
4130dnl sysinfo() may exist but not be Linux compatible
4131AC_MSG_CHECKING(for sysinfo)
4132AC_TRY_COMPILE(
4133[#include <sys/types.h>
4134#include <sys/sysinfo.h>],
4135[ struct sysinfo sinfo;
4136 int t;
4137
4138 (void)sysinfo(&sinfo);
4139 t = sinfo.totalram;
4140 ],
4141 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
4142 AC_MSG_RESULT(not usable))
4143
Bram Moolenaar914572a2007-05-01 11:37:47 +00004144dnl struct sysinfo may have the mem_unit field or not
4145AC_MSG_CHECKING(for sysinfo.mem_unit)
4146AC_TRY_COMPILE(
4147[#include <sys/types.h>
4148#include <sys/sysinfo.h>],
4149[ struct sysinfo sinfo;
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02004150 sinfo.mem_unit = 1;
Bram Moolenaar914572a2007-05-01 11:37:47 +00004151 ],
4152 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_MEM_UNIT),
4153 AC_MSG_RESULT(no))
4154
Bram Moolenaar071d4272004-06-13 20:20:40 +00004155dnl sysconf() may exist but not support what we want to use
4156AC_MSG_CHECKING(for sysconf)
4157AC_TRY_COMPILE(
4158[#include <unistd.h>],
4159[ (void)sysconf(_SC_PAGESIZE);
4160 (void)sysconf(_SC_PHYS_PAGES);
4161 ],
4162 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
4163 AC_MSG_RESULT(not usable))
4164
Bram Moolenaar914703b2010-05-31 21:59:46 +02004165AC_CHECK_SIZEOF([int])
4166AC_CHECK_SIZEOF([long])
4167AC_CHECK_SIZEOF([time_t])
4168AC_CHECK_SIZEOF([off_t])
Bram Moolenaar644fdff2010-05-30 13:26:21 +02004169
Bram Moolenaara2aa31a2014-02-23 22:52:40 +01004170dnl Use different names to avoid clashing with other header files.
4171AC_DEFINE_UNQUOTED(VIM_SIZEOF_INT, [$ac_cv_sizeof_int])
4172AC_DEFINE_UNQUOTED(VIM_SIZEOF_LONG, [$ac_cv_sizeof_long])
4173
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004174dnl Make sure that uint32_t is really 32 bits unsigned.
4175AC_MSG_CHECKING([uint32_t is 32 bits])
4176AC_TRY_RUN([
4177#ifdef HAVE_STDINT_H
4178# include <stdint.h>
4179#endif
4180#ifdef HAVE_INTTYPES_H
4181# include <inttypes.h>
4182#endif
4183main() {
4184 uint32_t nr1 = (uint32_t)-1;
4185 uint32_t nr2 = (uint32_t)0xffffffffUL;
4186 if (sizeof(uint32_t) != 4 || nr1 != 0xffffffffUL || nr2 + 1 != 0) exit(1);
4187 exit(0);
4188}],
4189AC_MSG_RESULT(ok),
4190AC_MSG_ERROR([WRONG! uint32_t not defined correctly.]),
Bram Moolenaar323cb952011-12-14 19:22:34 +01004191AC_MSG_WARN([cannot check uint32_t when cross-compiling.]))
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004192
Bram Moolenaar446cb832008-06-24 21:56:24 +00004193dnl Check for memmove() before bcopy(), makes memmove() be used when both are
4194dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
4195
Bram Moolenaar071d4272004-06-13 20:20:40 +00004196[bcopy_test_prog='
Bram Moolenaar446cb832008-06-24 21:56:24 +00004197#include "confdefs.h"
4198#ifdef HAVE_STRING_H
4199# include <string.h>
4200#endif
4201#if STDC_HEADERS
4202# include <stdlib.h>
4203# include <stddef.h>
4204#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004205main() {
4206 char buf[10];
4207 strcpy(buf, "abcdefghi");
4208 mch_memmove(buf, buf + 2, 3);
4209 if (strncmp(buf, "ababcf", 6))
4210 exit(1);
4211 strcpy(buf, "abcdefghi");
4212 mch_memmove(buf + 2, buf, 3);
4213 if (strncmp(buf, "cdedef", 6))
4214 exit(1);
4215 exit(0); /* libc version works properly. */
4216}']
4217
Bram Moolenaar446cb832008-06-24 21:56:24 +00004218AC_CACHE_CHECK([whether memmove handles overlaps],[vim_cv_memmove_handles_overlap],
4219 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004220 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 +00004221 [
4222 vim_cv_memmove_handles_overlap=yes
4223 ],[
4224 vim_cv_memmove_handles_overlap=no
4225 ],[
4226 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memmove_handles_overlap')
4227 ])
4228 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00004229
Bram Moolenaar446cb832008-06-24 21:56:24 +00004230if test "x$vim_cv_memmove_handles_overlap" = "xyes" ; then
4231 AC_DEFINE(USEMEMMOVE)
4232else
4233 AC_CACHE_CHECK([whether bcopy handles overlaps],[vim_cv_bcopy_handles_overlap],
4234 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004235 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 +00004236 [
4237 vim_cv_bcopy_handles_overlap=yes
4238 ],[
4239 vim_cv_bcopy_handles_overlap=no
4240 ],[
4241 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_bcopy_handles_overlap')
4242 ])
4243 ])
4244
4245 if test "x$vim_cv_bcopy_handles_overlap" = "xyes" ; then
4246 AC_DEFINE(USEBCOPY)
4247 else
4248 AC_CACHE_CHECK([whether memcpy handles overlaps],[vim_cv_memcpy_handles_overlap],
4249 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004250 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 +00004251 [
4252 vim_cv_memcpy_handles_overlap=yes
4253 ],[
4254 vim_cv_memcpy_handles_overlap=no
4255 ],[
4256 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memcpy_handles_overlap')
4257 ])
4258 ])
4259
4260 if test "x$vim_cv_memcpy_handles_overlap" = "xyes" ; then
4261 AC_DEFINE(USEMEMCPY)
4262 fi
4263 fi
4264fi
4265
Bram Moolenaar071d4272004-06-13 20:20:40 +00004266
4267dnl Check for multibyte locale functions
4268dnl Find out if _Xsetlocale() is supported by libX11.
4269dnl Check if X_LOCALE should be defined.
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004270if test "x$with_x" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004271 cflags_save=$CFLAGS
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004272 libs_save=$LIBS
4273 LIBS="$LIBS $X_LIBS $GUI_LIB_LOC $GUI_X_LIBS $X_PRE_LIBS $X_LIB $X_EXTRA_LIBS"
4274 CFLAGS="$CFLAGS $X_CFLAGS"
4275
4276 AC_MSG_CHECKING(whether X_LOCALE needed)
4277 AC_TRY_COMPILE([#include <X11/Xlocale.h>],,
4278 AC_TRY_LINK_FUNC([_Xsetlocale], [AC_MSG_RESULT(yes)
4279 AC_DEFINE(X_LOCALE)], AC_MSG_RESULT(no)),
4280 AC_MSG_RESULT(no))
4281
4282 AC_MSG_CHECKING(whether Xutf8SetWMProperties() can be used)
4283 AC_TRY_LINK_FUNC([Xutf8SetWMProperties], [AC_MSG_RESULT(yes)
4284 AC_DEFINE(HAVE_XUTF8SETWMPROPERTIES)], AC_MSG_RESULT(no))
4285
Bram Moolenaar071d4272004-06-13 20:20:40 +00004286 CFLAGS=$cflags_save
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004287 LIBS=$libs_save
Bram Moolenaar071d4272004-06-13 20:20:40 +00004288fi
4289
4290dnl Link with xpg4, it is said to make Korean locale working
4291AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,)
4292
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004293dnl Check how we can run ctags. Default to "ctags" when nothing works.
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02004294dnl Use --version to detect Exuberant ctags (preferred)
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004295dnl Add --fields=+S to get function signatures for omni completion.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004296dnl -t for typedefs (many ctags have this)
4297dnl -s for static functions (Elvis ctags only?)
4298dnl -v for variables. Dangerous, most ctags take this for 'vgrind style'.
4299dnl -i+m to test for older Exuberant ctags
4300AC_MSG_CHECKING(how to create tags)
4301test -f tags && mv tags tags.save
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004302if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004303 TAGPRG="ctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004304elif (eval exctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004305 TAGPRG="exctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004306elif (eval exuberant-ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004307 TAGPRG="exuberant-ctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004308else
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004309 TAGPRG="ctags"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004310 (eval etags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags"
4311 (eval etags -c /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags -c"
4312 (eval ctags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags"
4313 (eval ctags -t /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -t"
4314 (eval ctags -ts /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -ts"
4315 (eval ctags -tvs /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -tvs"
4316 (eval ctags -i+m /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -i+m"
4317fi
4318test -f tags.save && mv tags.save tags
4319AC_MSG_RESULT($TAGPRG) AC_SUBST(TAGPRG)
4320
4321dnl Check how we can run man with a section number
4322AC_MSG_CHECKING(how to run man with a section nr)
4323MANDEF="man"
Bram Moolenaar8b131502008-02-13 09:28:19 +00004324(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 +00004325AC_MSG_RESULT($MANDEF)
4326if test "$MANDEF" = "man -s"; then
4327 AC_DEFINE(USEMAN_S)
4328fi
4329
4330dnl Check if gettext() is working and if it needs -lintl
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004331dnl We take care to base this on an empty LIBS: on some systems libelf would be
4332dnl in LIBS and implicitly take along libintl. The final LIBS would then not
4333dnl contain libintl, and the link step would fail due to -Wl,--as-needed.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004334AC_MSG_CHECKING(--disable-nls argument)
4335AC_ARG_ENABLE(nls,
4336 [ --disable-nls Don't support NLS (gettext()).], ,
4337 [enable_nls="yes"])
4338
4339if test "$enable_nls" = "yes"; then
4340 AC_MSG_RESULT(no)
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00004341
4342 INSTALL_LANGS=install-languages
4343 AC_SUBST(INSTALL_LANGS)
4344 INSTALL_TOOL_LANGS=install-tool-languages
4345 AC_SUBST(INSTALL_TOOL_LANGS)
4346
Bram Moolenaar071d4272004-06-13 20:20:40 +00004347 AC_CHECK_PROG(MSGFMT, msgfmt, msgfmt, )
4348 AC_MSG_CHECKING([for NLS])
4349 if test -f po/Makefile; then
4350 have_gettext="no"
4351 if test -n "$MSGFMT"; then
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004352 olibs=$LIBS
4353 LIBS=""
Bram Moolenaar071d4272004-06-13 20:20:40 +00004354 AC_TRY_LINK(
4355 [#include <libintl.h>],
4356 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004357 AC_MSG_RESULT([gettext() works]); have_gettext="yes"; LIBS=$olibs,
4358 LIBS="-lintl"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004359 AC_TRY_LINK(
4360 [#include <libintl.h>],
4361 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004362 AC_MSG_RESULT([gettext() works with -lintl]); have_gettext="yes";
4363 LIBS="$olibs -lintl",
Bram Moolenaar071d4272004-06-13 20:20:40 +00004364 AC_MSG_RESULT([gettext() doesn't work]);
4365 LIBS=$olibs))
4366 else
4367 AC_MSG_RESULT([msgfmt not found - disabled]);
4368 fi
Bram Moolenaar278eb582014-07-30 13:22:52 +02004369 if test $have_gettext = "yes" -a "x$features" != "xtiny" -a "x$features" != "xsmall"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004370 AC_DEFINE(HAVE_GETTEXT)
4371 MAKEMO=yes
4372 AC_SUBST(MAKEMO)
4373 dnl this was added in GNU gettext 0.10.36
4374 AC_CHECK_FUNCS(bind_textdomain_codeset)
4375 dnl _nl_msg_cat_cntr is required for GNU gettext
4376 AC_MSG_CHECKING([for _nl_msg_cat_cntr])
4377 AC_TRY_LINK(
4378 [#include <libintl.h>
4379 extern int _nl_msg_cat_cntr;],
4380 [++_nl_msg_cat_cntr;],
4381 AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_NL_MSG_CAT_CNTR),
4382 AC_MSG_RESULT([no]))
Bram Moolenaar26096cc2019-04-11 15:25:40 +02004383 AC_MSG_CHECKING([if msgfmt supports --desktop])
4384 MSGFMT_DESKTOP=
4385 if "$MSGFMT" --help | grep -e '--desktop' >/dev/null; then
Bram Moolenaar62a88f42019-06-07 20:44:40 +02004386 if "$MSGFMT" --version | grep '0.19.[[3-7]]$' >/dev/null; then
4387 dnl GNU gettext 0.19.7's --desktop is broken. We assume back to
4388 dnl 0.19.3 is also broken.
4389 AC_MSG_RESULT([broken])
4390 else
4391 AC_MSG_RESULT([yes])
4392 MSGFMT_DESKTOP="gvim.desktop vim.desktop"
4393 fi
Bram Moolenaar26096cc2019-04-11 15:25:40 +02004394 else
4395 AC_MSG_RESULT([no])
4396 fi
4397 AC_SUBST(MSGFMT_DESKTOP)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004398 fi
4399 else
4400 AC_MSG_RESULT([no "po/Makefile" - disabled]);
4401 fi
4402else
4403 AC_MSG_RESULT(yes)
4404fi
4405
4406dnl Check for dynamic linking loader
4407AC_CHECK_HEADER(dlfcn.h, DLL=dlfcn.h, [AC_CHECK_HEADER(dl.h, DLL=dl.h)])
4408if test x${DLL} = xdlfcn.h; then
4409 AC_DEFINE(HAVE_DLFCN_H, 1, [ Define if we have dlfcn.h. ])
4410 AC_MSG_CHECKING([for dlopen()])
4411 AC_TRY_LINK(,[
4412 extern void* dlopen();
4413 dlopen();
4414 ],
4415 AC_MSG_RESULT(yes);
4416 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4417 AC_MSG_RESULT(no);
4418 AC_MSG_CHECKING([for dlopen() in -ldl])
4419 olibs=$LIBS
4420 LIBS="$LIBS -ldl"
4421 AC_TRY_LINK(,[
4422 extern void* dlopen();
4423 dlopen();
4424 ],
4425 AC_MSG_RESULT(yes);
4426 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4427 AC_MSG_RESULT(no);
4428 LIBS=$olibs))
4429 dnl ReliantUNIX has dlopen() in libc but everything else in libdl
4430 dnl ick :-)
4431 AC_MSG_CHECKING([for dlsym()])
4432 AC_TRY_LINK(,[
4433 extern void* dlsym();
4434 dlsym();
4435 ],
4436 AC_MSG_RESULT(yes);
4437 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4438 AC_MSG_RESULT(no);
4439 AC_MSG_CHECKING([for dlsym() in -ldl])
4440 olibs=$LIBS
4441 LIBS="$LIBS -ldl"
4442 AC_TRY_LINK(,[
4443 extern void* dlsym();
4444 dlsym();
4445 ],
4446 AC_MSG_RESULT(yes);
4447 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4448 AC_MSG_RESULT(no);
4449 LIBS=$olibs))
4450elif test x${DLL} = xdl.h; then
4451 AC_DEFINE(HAVE_DL_H, 1, [ Define if we have dl.h. ])
4452 AC_MSG_CHECKING([for shl_load()])
4453 AC_TRY_LINK(,[
4454 extern void* shl_load();
4455 shl_load();
4456 ],
4457 AC_MSG_RESULT(yes);
4458 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4459 AC_MSG_RESULT(no);
4460 AC_MSG_CHECKING([for shl_load() in -ldld])
4461 olibs=$LIBS
4462 LIBS="$LIBS -ldld"
4463 AC_TRY_LINK(,[
4464 extern void* shl_load();
4465 shl_load();
4466 ],
4467 AC_MSG_RESULT(yes);
4468 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4469 AC_MSG_RESULT(no);
4470 LIBS=$olibs))
4471fi
4472AC_CHECK_HEADERS(setjmp.h)
4473
Bram Moolenaard0573012017-10-28 21:11:06 +02004474if test "x$MACOS_X" = "xyes" -a -n "$PERL"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004475 dnl -ldl must come after DynaLoader.a
4476 if echo $LIBS | grep -e '-ldl' >/dev/null; then
4477 LIBS=`echo $LIBS | sed s/-ldl//`
4478 PERL_LIBS="$PERL_LIBS -ldl"
4479 fi
4480fi
4481
Bram Moolenaard0573012017-10-28 21:11:06 +02004482if test "$MACOS_X" = "yes"; then
4483 AC_MSG_CHECKING([whether we need macOS frameworks])
4484 if test "$GUITYPE" = "CARBONGUI"; then
4485 AC_MSG_RESULT([yes, we need Carbon])
4486 LIBS="$LIBS -framework Carbon"
4487 elif test "$MACOS_X_DARWIN" = "yes"; then
4488 if test "$features" = "tiny"; then
4489 dnl Since no FEAT_CLIPBOARD, no longer need for os_macosx.m.
4490 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_macosx.m++'`
4491 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_macosx.o++'`
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01004492 AC_MSG_RESULT([yes, we need CoreServices])
4493 LIBS="$LIBS -framework CoreServices"
Bram Moolenaard0573012017-10-28 21:11:06 +02004494 else
4495 AC_MSG_RESULT([yes, we need AppKit])
4496 LIBS="$LIBS -framework AppKit"
Bram Moolenaard0573012017-10-28 21:11:06 +02004497 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004498 else
Bram Moolenaard0573012017-10-28 21:11:06 +02004499 AC_MSG_RESULT([no])
Bram Moolenaar3437b912013-07-03 19:52:53 +02004500 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004501fi
Bram Moolenaar164fca32010-07-14 13:58:07 +02004502if test "x$MACARCH" = "xboth" && test "x$GUITYPE" = "xCARBONGUI"; then
Bram Moolenaar595a7be2010-03-10 16:28:12 +01004503 LDFLAGS="$LDFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +00004504fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004505
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004506dnl gcc 3.1 changed the meaning of -MM. The only solution appears to be to
4507dnl use "-isystem" instead of "-I" for all non-Vim include dirs.
4508dnl But only when making dependencies, cproto and lint don't take "-isystem".
Bram Moolenaar32466aa2006-02-24 23:53:04 +00004509dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
4510dnl the number before the version number.
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004511DEPEND_CFLAGS_FILTER=
4512if test "$GCC" = yes; then
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004513 AC_MSG_CHECKING(for GCC 3 or later)
Bram Moolenaar348808f2020-02-07 20:50:07 +01004514 gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]][[0-9]]*\)\..*$/\1/g'`
Bram Moolenaarf740b292006-02-16 22:11:02 +00004515 if test "$gccmajor" -gt "2"; then
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004516 DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004517 AC_MSG_RESULT(yes)
4518 else
4519 AC_MSG_RESULT(no)
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004520 fi
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004521 dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
4522 dnl declared as char x[1] but actually longer. Introduced in gcc 4.0.
Bram Moolenaar56d1db32009-12-16 16:14:51 +00004523 dnl Also remove duplicate _FORTIFY_SOURCE arguments.
Bram Moolenaaraeabe052011-12-08 15:17:34 +01004524 dnl And undefine it first to avoid a warning.
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004525 AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
4526 if test "$gccmajor" -gt "3"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02004527 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 +01004528 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 +00004529 AC_MSG_RESULT(yes)
4530 else
4531 AC_MSG_RESULT(no)
4532 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +00004533fi
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004534AC_SUBST(DEPEND_CFLAGS_FILTER)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004535
Bram Moolenaarec0557f2018-01-31 14:41:37 +01004536dnl On some systems AC_SYS_LARGEFILE determines that -D_FILE_OFFSET_BITS=64
4537dnl isn't required, but the CFLAGS for some of the libraries we're using
4538dnl include the define. Since the define changes the size of some datatypes
4539dnl (e.g. ino_t and off_t), all of Vim's modules must be compiled with a
4540dnl consistent value. It's therefore safest to force the use of the define
4541dnl if it's present in any of the *_CFLAGS variables.
4542AC_MSG_CHECKING(whether we need to force -D_FILE_OFFSET_BITS=64)
Bram Moolenaar9ce42132018-04-11 22:19:36 +02004543if 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 +01004544 AC_MSG_RESULT(yes)
4545 AC_DEFINE(_FILE_OFFSET_BITS, 64)
4546else
4547 AC_MSG_RESULT(no)
4548fi
4549
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004550dnl link.sh tries to avoid overlinking in a hackish way.
4551dnl At least GNU ld supports --as-needed which provides the same functionality
4552dnl at linker level. Let's use it.
4553AC_MSG_CHECKING(linker --as-needed support)
4554LINK_AS_NEEDED=
4555# Check if linker supports --as-needed and --no-as-needed options
4556if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02004557 LDFLAGS=`echo "$LDFLAGS" | sed -e 's/ *-Wl,--as-needed//g' | sed -e 's/$/ -Wl,--as-needed/'`
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004558 LINK_AS_NEEDED=yes
4559fi
4560if test "$LINK_AS_NEEDED" = yes; then
4561 AC_MSG_RESULT(yes)
4562else
4563 AC_MSG_RESULT(no)
4564fi
4565AC_SUBST(LINK_AS_NEEDED)
4566
Bram Moolenaar77c19352012-06-13 19:19:41 +02004567# IBM z/OS reset CFLAGS for config.mk
4568if test "$zOSUnix" = "yes"; then
4569 CFLAGS="-D_ALL_SOURCE -Wc,float\(ieee\),dll"
4570fi
4571
Bram Moolenaar071d4272004-06-13 20:20:40 +00004572dnl write output files
4573AC_OUTPUT(auto/config.mk:config.mk.in)
4574
4575dnl vim: set sw=2 tw=78 fo+=l: