blob: 2a31f41a43f8ebe7d916a8a32e2e3504576f35dd [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
157dnl If QNX is found, assume we don't want to use Xphoton
158dnl unless it was specifically asked for (--with-x)
159AC_MSG_CHECKING(for QNX)
160case `uname` in
161 QNX) OS_EXTRA_SRC=os_qnx.c; OS_EXTRA_OBJ=objects/os_qnx.o
162 test -z "$with_x" && with_x=no
163 QNX=yes; AC_MSG_RESULT(yes);;
164 *) QNX=no; AC_MSG_RESULT(no);;
165esac
166
167dnl Check for Darwin and MacOS X
168dnl We do a check for MacOS X in the very beginning because there
169dnl are a lot of other things we need to change besides GUI stuff
Bram Moolenaar071d4272004-06-13 20:20:40 +0000170AC_MSG_CHECKING([for Darwin (Mac OS X)])
171if test "`(uname) 2>/dev/null`" = Darwin; then
172 AC_MSG_RESULT(yes)
Bram Moolenaard0573012017-10-28 21:11:06 +0200173 MACOS_X=yes
Bram Moolenaar52ecaaa2018-05-12 21:38:13 +0200174 CPPFLAGS="$CPPFLAGS -DMACOS_X"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000175
176 AC_MSG_CHECKING(--disable-darwin argument)
177 AC_ARG_ENABLE(darwin,
178 [ --disable-darwin Disable Darwin (Mac OS X) support.],
179 , [enable_darwin="yes"])
180 if test "$enable_darwin" = "yes"; then
181 AC_MSG_RESULT(no)
182 AC_MSG_CHECKING(if Darwin files are there)
Bram Moolenaar164fca32010-07-14 13:58:07 +0200183 if test -f os_macosx.m; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000184 AC_MSG_RESULT(yes)
185 else
186 AC_MSG_RESULT([no, Darwin support disabled])
187 enable_darwin=no
188 fi
189 else
190 AC_MSG_RESULT([yes, Darwin support excluded])
191 fi
192
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000193 AC_MSG_CHECKING(--with-mac-arch argument)
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000194 AC_ARG_WITH(mac-arch, [ --with-mac-arch=ARCH current, intel, ppc or both],
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000195 MACARCH="$withval"; AC_MSG_RESULT($MACARCH),
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000196 MACARCH="current"; AC_MSG_RESULT(defaulting to $MACARCH))
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000197
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100198 AC_MSG_CHECKING(--with-developer-dir argument)
199 AC_ARG_WITH(developer-dir, [ --with-developer-dir=PATH use PATH as location for Xcode developer tools],
200 DEVELOPER_DIR="$withval"; AC_MSG_RESULT($DEVELOPER_DIR),
Bram Moolenaar32d03b32015-11-19 13:46:48 +0100201 AC_MSG_RESULT(not present))
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100202
203 if test "x$DEVELOPER_DIR" = "x"; then
204 AC_PATH_PROG(XCODE_SELECT, xcode-select)
205 if test "x$XCODE_SELECT" != "x"; then
206 AC_MSG_CHECKING(for developer dir using xcode-select)
207 DEVELOPER_DIR=`$XCODE_SELECT -print-path`
208 AC_MSG_RESULT([$DEVELOPER_DIR])
209 else
210 DEVELOPER_DIR=/Developer
211 fi
212 fi
213
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000214 if test "x$MACARCH" = "xboth"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000215 AC_MSG_CHECKING(for 10.4 universal SDK)
216 dnl There is a terrible inconsistency (but we appear to get away with it):
217 dnl $CFLAGS uses the 10.4u SDK library for the headers, while $CPPFLAGS
218 dnl doesn't, because "gcc -E" doesn't grok it. That means the configure
219 dnl tests using the preprocessor are actually done with the wrong header
220 dnl files. $LDFLAGS is set at the end, because configure uses it together
221 dnl with $CFLAGS and we can only have one -sysroot argument.
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000222 save_cppflags="$CPPFLAGS"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000223 save_cflags="$CFLAGS"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000224 save_ldflags="$LDFLAGS"
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100225 CFLAGS="$CFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000226 AC_TRY_LINK([ ], [ ],
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000227 AC_MSG_RESULT(found, will make universal binary),
228
229 AC_MSG_RESULT(not found)
Bram Moolenaar1f35bf92006-03-07 22:38:47 +0000230 CFLAGS="$save_cflags"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000231 AC_MSG_CHECKING(if Intel architecture is supported)
232 CPPFLAGS="$CPPFLAGS -arch i386"
233 LDFLAGS="$save_ldflags -arch i386"
234 AC_TRY_LINK([ ], [ ],
235 AC_MSG_RESULT(yes); MACARCH="intel",
236 AC_MSG_RESULT(no, using PowerPC)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000237 MACARCH="ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000238 CPPFLAGS="$save_cppflags -arch ppc"
239 LDFLAGS="$save_ldflags -arch ppc"))
240 elif test "x$MACARCH" = "xintel"; then
241 CPPFLAGS="$CPPFLAGS -arch intel"
242 LDFLAGS="$LDFLAGS -arch intel"
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000243 elif test "x$MACARCH" = "xppc"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000244 CPPFLAGS="$CPPFLAGS -arch ppc"
245 LDFLAGS="$LDFLAGS -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000246 fi
247
Bram Moolenaar071d4272004-06-13 20:20:40 +0000248 if test "$enable_darwin" = "yes"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200249 MACOS_X_DARWIN=yes
Bram Moolenaar164fca32010-07-14 13:58:07 +0200250 OS_EXTRA_SRC="os_macosx.m os_mac_conv.c";
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000251 OS_EXTRA_OBJ="objects/os_macosx.o objects/os_mac_conv.o"
Bram Moolenaar32466aa2006-02-24 23:53:04 +0000252 dnl TODO: use -arch i386 on Intel machines
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100253 dnl Removed -no-cpp-precomp, only for very old compilers.
Bram Moolenaard0573012017-10-28 21:11:06 +0200254 CPPFLAGS="$CPPFLAGS -DMACOS_X_DARWIN"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000255
256 dnl If Carbon is found, assume we don't want X11
257 dnl unless it was specifically asked for (--with-x)
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000258 dnl or Motif, Athena or GTK GUI is used.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000259 AC_CHECK_HEADER(Carbon/Carbon.h, CARBON=yes)
260 if test "x$CARBON" = "xyes"; then
Bram Moolenaar98921892016-02-23 17:14:37 +0100261 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 +0000262 with_x=no
Bram Moolenaar071d4272004-06-13 20:20:40 +0000263 fi
264 fi
265 fi
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000266
Bram Moolenaardb552d602006-03-23 22:59:57 +0000267 dnl Avoid a bug with -O2 with gcc 4.0.1. Symptom: malloc() reports double
Bram Moolenaarfd2ac762006-03-01 22:09:21 +0000268 dnl free. This happens in expand_filename(), because the optimizer swaps
Bram Moolenaardb552d602006-03-23 22:59:57 +0000269 dnl two blocks of code, both using "repl", that can't be swapped.
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000270 if test "$MACARCH" = "intel" -o "$MACARCH" = "both"; then
271 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-Oz/'`
272 fi
273
Bram Moolenaar071d4272004-06-13 20:20:40 +0000274else
275 AC_MSG_RESULT(no)
276fi
277
Bram Moolenaar39766a72013-11-03 00:41:00 +0100278dnl Mac OS X 10.9+ no longer include AvailabilityMacros.h in Carbon
279dnl so we need to include it to have access to version macros.
Bram Moolenaar18e54692013-11-03 20:26:31 +0100280AC_CHECK_HEADERS(AvailabilityMacros.h)
Bram Moolenaar39766a72013-11-03 00:41:00 +0100281
Bram Moolenaar071d4272004-06-13 20:20:40 +0000282AC_SUBST(OS_EXTRA_SRC)
283AC_SUBST(OS_EXTRA_OBJ)
284
285dnl Add /usr/local/lib to $LDFLAGS and /usr/local/include to CFLAGS.
286dnl Only when the directory exists and it wasn't there yet.
287dnl For gcc don't do this when it is already in the default search path.
Bram Moolenaar446cb832008-06-24 21:56:24 +0000288dnl Skip all of this when cross-compiling.
289if test "$cross_compiling" = no; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000290 AC_MSG_CHECKING(--with-local-dir argument)
Bram Moolenaar446cb832008-06-24 21:56:24 +0000291 have_local_include=''
292 have_local_lib=''
Bram Moolenaarc236c162008-07-13 17:41:49 +0000293 AC_ARG_WITH([local-dir], [ --with-local-dir=PATH search PATH instead of /usr/local for local libraries.
294 --without-local-dir do not search /usr/local for local libraries.], [
295 local_dir="$withval"
296 case "$withval" in
297 */*) ;;
298 no)
299 # avoid adding local dir to LDFLAGS and CPPFLAGS
Bram Moolenaare06c1882010-07-21 22:05:20 +0200300 have_local_include=yes
Bram Moolenaarc236c162008-07-13 17:41:49 +0000301 have_local_lib=yes
302 ;;
303 *) AC_MSG_ERROR(must pass path argument to --with-local-dir) ;;
304 esac
305 AC_MSG_RESULT($local_dir)
306 ], [
307 local_dir=/usr/local
308 AC_MSG_RESULT(Defaulting to $local_dir)
309 ])
310 if test "$GCC" = yes -a "$local_dir" != no; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000311 echo 'void f(){}' > conftest.c
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100312 dnl Removed -no-cpp-precomp, only needed for OS X 10.2 (Ben Fowler)
313 have_local_include=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/include"`
Bram Moolenaarc236c162008-07-13 17:41:49 +0000314 have_local_lib=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/lib"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000315 rm -f conftest.c conftest.o
Bram Moolenaar071d4272004-06-13 20:20:40 +0000316 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000317 if test -z "$have_local_lib" -a -d "${local_dir}/lib"; then
318 tt=`echo "$LDFLAGS" | sed -e "s+-L${local_dir}/lib ++g" -e "s+-L${local_dir}/lib$++g"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000319 if test "$tt" = "$LDFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000320 LDFLAGS="$LDFLAGS -L${local_dir}/lib"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000321 fi
322 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000323 if test -z "$have_local_include" -a -d "${local_dir}/include"; then
324 tt=`echo "$CPPFLAGS" | sed -e "s+-I${local_dir}/include ++g" -e "s+-I${local_dir}/include$++g"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000325 if test "$tt" = "$CPPFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000326 CPPFLAGS="$CPPFLAGS -I${local_dir}/include"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000327 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000328 fi
329fi
330
331AC_MSG_CHECKING(--with-vim-name argument)
332AC_ARG_WITH(vim-name, [ --with-vim-name=NAME what to call the Vim executable],
333 VIMNAME="$withval"; AC_MSG_RESULT($VIMNAME),
Bram Moolenaare344bea2005-09-01 20:46:49 +0000334 VIMNAME="vim"; AC_MSG_RESULT(Defaulting to $VIMNAME))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000335AC_SUBST(VIMNAME)
336AC_MSG_CHECKING(--with-ex-name argument)
337AC_ARG_WITH(ex-name, [ --with-ex-name=NAME what to call the Ex executable],
338 EXNAME="$withval"; AC_MSG_RESULT($EXNAME),
339 EXNAME="ex"; AC_MSG_RESULT(Defaulting to ex))
340AC_SUBST(EXNAME)
341AC_MSG_CHECKING(--with-view-name argument)
342AC_ARG_WITH(view-name, [ --with-view-name=NAME what to call the View executable],
343 VIEWNAME="$withval"; AC_MSG_RESULT($VIEWNAME),
344 VIEWNAME="view"; AC_MSG_RESULT(Defaulting to view))
345AC_SUBST(VIEWNAME)
346
347AC_MSG_CHECKING(--with-global-runtime argument)
348AC_ARG_WITH(global-runtime, [ --with-global-runtime=DIR global runtime directory in 'runtimepath'],
349 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL, "$withval"),
350 AC_MSG_RESULT(no))
351
352AC_MSG_CHECKING(--with-modified-by argument)
353AC_ARG_WITH(modified-by, [ --with-modified-by=NAME name of who modified a release version],
354 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(MODIFIED_BY, "$withval"),
355 AC_MSG_RESULT(no))
356
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200357dnl Check for EBCDIC stolen from the LYNX port to z/OS Unix
Bram Moolenaar071d4272004-06-13 20:20:40 +0000358AC_MSG_CHECKING(if character set is EBCDIC)
359AC_TRY_COMPILE([ ],
360[ /* TryCompile function for CharSet.
361 Treat any failure as ASCII for compatibility with existing art.
362 Use compile-time rather than run-time tests for cross-compiler
363 tolerance. */
364#if '0'!=240
365make an error "Character set is not EBCDIC"
366#endif ],
367[ # TryCompile action if true
368cf_cv_ebcdic=yes ],
369[ # TryCompile action if false
370cf_cv_ebcdic=no])
371# end of TryCompile ])
372# end of CacheVal CvEbcdic
373AC_MSG_RESULT($cf_cv_ebcdic)
374case "$cf_cv_ebcdic" in #(vi
375 yes) AC_DEFINE(EBCDIC)
376 line_break='"\\n"'
377 ;;
378 *) line_break='"\\012"';;
379esac
380AC_SUBST(line_break)
381
382if test "$cf_cv_ebcdic" = "yes"; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +0200383dnl If we have EBCDIC we most likely have z/OS Unix, let's test it!
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200384AC_MSG_CHECKING(for z/OS Unix)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000385case `uname` in
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200386 OS/390) zOSUnix="yes";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000387 dnl If using cc the environment variable _CC_CCMODE must be
388 dnl set to "1", so that some compiler extensions are enabled.
389 dnl If using c89 the environment variable is named _CC_C89MODE.
390 dnl Note: compile with c89 never tested.
391 if test "$CC" = "cc"; then
392 ccm="$_CC_CCMODE"
393 ccn="CC"
394 else
395 if test "$CC" = "c89"; then
396 ccm="$_CC_C89MODE"
397 ccn="C89"
398 else
399 ccm=1
400 fi
401 fi
402 if test "$ccm" != "1"; then
403 echo ""
404 echo "------------------------------------------"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200405 echo " On z/OS Unix, the environment variable"
Bram Moolenaar77c19352012-06-13 19:19:41 +0200406 echo " _CC_${ccn}MODE must be set to \"1\"!"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000407 echo " Do:"
408 echo " export _CC_${ccn}MODE=1"
409 echo " and then call configure again."
410 echo "------------------------------------------"
411 exit 1
412 fi
Bram Moolenaar77c19352012-06-13 19:19:41 +0200413 # Set CFLAGS for configure process.
414 # This will be reset later for config.mk.
415 # Use haltonmsg to force error for missing H files.
416 CFLAGS="$CFLAGS -D_ALL_SOURCE -Wc,float(ieee),haltonmsg(3296)";
417 LDFLAGS="$LDFLAGS -Wl,EDIT=NO"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000418 AC_MSG_RESULT(yes)
419 ;;
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200420 *) zOSUnix="no";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000421 AC_MSG_RESULT(no)
422 ;;
423esac
424fi
425
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200426dnl Set QUOTESED. Needs additional backslashes on zOS
427if test "$zOSUnix" = "yes"; then
428 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\\\\\&/g' -e 's/\\\\\\\\\"/\"/' -e 's/\\\\\\\\\";\$\$/\";/'"
429else
430 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\&/g' -e 's/\\\\\"/\"/' -e 's/\\\\\";\$\$/\";/'"
431fi
432AC_SUBST(QUOTESED)
433
434
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200435dnl Link with -lsmack for Smack stuff; if not found
436AC_MSG_CHECKING(--disable-smack argument)
437AC_ARG_ENABLE(smack,
438 [ --disable-smack Do not check for Smack support.],
439 , enable_smack="yes")
440if test "$enable_smack" = "yes"; then
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200441 AC_MSG_RESULT(no)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200442 AC_CHECK_HEADER([linux/xattr.h], true, enable_smack="no")
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200443else
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200444 AC_MSG_RESULT(yes)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200445fi
446if test "$enable_smack" = "yes"; then
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200447 AC_CHECK_HEADER([attr/xattr.h], true, enable_smack="no")
448fi
449if test "$enable_smack" = "yes"; then
450 AC_MSG_CHECKING(for XATTR_NAME_SMACKEXEC in linux/xattr.h)
451 AC_EGREP_CPP(XATTR_NAME_SMACKEXEC, [#include <linux/xattr.h>],
452 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +0200453 AC_MSG_RESULT(no); enable_smack="no")
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200454fi
455if test "$enable_smack" = "yes"; then
456 AC_CHECK_LIB(attr, setxattr,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200457 [LIBS="$LIBS -lattr"
458 found_smack="yes"
459 AC_DEFINE(HAVE_SMACK)])
Bram Moolenaar588ebeb2008-05-07 17:09:24 +0000460fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000461
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200462dnl When smack was found don't search for SELinux
463if test "x$found_smack" = "x"; then
464 dnl Link with -lselinux for SELinux stuff; if not found
465 AC_MSG_CHECKING(--disable-selinux argument)
466 AC_ARG_ENABLE(selinux,
467 [ --disable-selinux Do not check for SELinux support.],
468 , enable_selinux="yes")
469 if test "$enable_selinux" = "yes"; then
470 AC_MSG_RESULT(no)
471 AC_CHECK_LIB(selinux, is_selinux_enabled,
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100472 [AC_CHECK_HEADER(selinux/selinux.h,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200473 [LIBS="$LIBS -lselinux"
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100474 AC_DEFINE(HAVE_SELINUX)])])
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200475 else
476 AC_MSG_RESULT(yes)
477 fi
478fi
479
Bram Moolenaar071d4272004-06-13 20:20:40 +0000480dnl Check user requested features.
481
482AC_MSG_CHECKING(--with-features argument)
Bram Moolenaareec29812016-07-26 21:27:36 +0200483AC_ARG_WITH(features, [ --with-features=TYPE tiny, small, normal, big or huge (default: huge)],
Bram Moolenaar071d4272004-06-13 20:20:40 +0000484 features="$withval"; AC_MSG_RESULT($features),
Bram Moolenaar23c4f712016-01-20 22:11:59 +0100485 features="huge"; AC_MSG_RESULT(Defaulting to huge))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000486
487dovimdiff=""
488dogvimdiff=""
489case "$features" in
490 tiny) AC_DEFINE(FEAT_TINY) ;;
491 small) AC_DEFINE(FEAT_SMALL) ;;
492 normal) AC_DEFINE(FEAT_NORMAL) dovimdiff="installvimdiff";
493 dogvimdiff="installgvimdiff" ;;
494 big) AC_DEFINE(FEAT_BIG) dovimdiff="installvimdiff";
495 dogvimdiff="installgvimdiff" ;;
496 huge) AC_DEFINE(FEAT_HUGE) dovimdiff="installvimdiff";
497 dogvimdiff="installgvimdiff" ;;
498 *) AC_MSG_RESULT([Sorry, $features is not supported]) ;;
499esac
500
501AC_SUBST(dovimdiff)
502AC_SUBST(dogvimdiff)
503
504AC_MSG_CHECKING(--with-compiledby argument)
505AC_ARG_WITH(compiledby, [ --with-compiledby=NAME name to show in :version message],
506 compiledby="$withval"; AC_MSG_RESULT($withval),
507 compiledby=""; AC_MSG_RESULT(no))
508AC_SUBST(compiledby)
509
510AC_MSG_CHECKING(--disable-xsmp argument)
511AC_ARG_ENABLE(xsmp,
512 [ --disable-xsmp Disable XSMP session management],
513 , enable_xsmp="yes")
514
515if test "$enable_xsmp" = "yes"; then
516 AC_MSG_RESULT(no)
517 AC_MSG_CHECKING(--disable-xsmp-interact argument)
518 AC_ARG_ENABLE(xsmp-interact,
519 [ --disable-xsmp-interact Disable XSMP interaction],
520 , enable_xsmp_interact="yes")
521 if test "$enable_xsmp_interact" = "yes"; then
522 AC_MSG_RESULT(no)
523 AC_DEFINE(USE_XSMP_INTERACT)
524 else
525 AC_MSG_RESULT(yes)
526 fi
527else
528 AC_MSG_RESULT(yes)
529fi
530
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200531dnl Check for Lua feature.
532AC_MSG_CHECKING(--enable-luainterp argument)
533AC_ARG_ENABLE(luainterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200534 [ --enable-luainterp[=OPTS] Include Lua interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200535 [enable_luainterp="no"])
536AC_MSG_RESULT($enable_luainterp)
537
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200538if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +0100539 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
540 AC_MSG_ERROR([cannot use Lua with tiny or small features])
541 fi
542
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200543 dnl -- find the lua executable
544 AC_SUBST(vi_cv_path_lua)
545
546 AC_MSG_CHECKING(--with-lua-prefix argument)
547 AC_ARG_WITH(lua_prefix,
548 [ --with-lua-prefix=PFX Prefix where Lua is installed.],
549 with_lua_prefix="$withval"; AC_MSG_RESULT($with_lua_prefix),
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200550 with_lua_prefix="";AC_MSG_RESULT(no))
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200551
552 if test "X$with_lua_prefix" != "X"; then
553 vi_cv_path_lua_pfx="$with_lua_prefix"
554 else
555 AC_MSG_CHECKING(LUA_PREFIX environment var)
556 if test "X$LUA_PREFIX" != "X"; then
557 AC_MSG_RESULT("$LUA_PREFIX")
558 vi_cv_path_lua_pfx="$LUA_PREFIX"
559 else
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200560 AC_MSG_RESULT([not set, default to /usr])
561 vi_cv_path_lua_pfx="/usr"
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200562 fi
563 fi
564
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200565 AC_MSG_CHECKING(--with-luajit)
566 AC_ARG_WITH(luajit,
567 [ --with-luajit Link with LuaJIT instead of Lua.],
568 [vi_cv_with_luajit="$withval"],
569 [vi_cv_with_luajit="no"])
570 AC_MSG_RESULT($vi_cv_with_luajit)
571
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200572 LUA_INC=
573 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200574 if test "x$vi_cv_with_luajit" != "xno"; then
575 dnl -- try to find LuaJIT executable
576 AC_PATH_PROG(vi_cv_path_luajit, luajit)
577 if test "X$vi_cv_path_luajit" != "X"; then
578 dnl -- find LuaJIT version
579 AC_CACHE_CHECK(LuaJIT version, vi_cv_version_luajit,
Bram Moolenaar49b10272013-11-21 12:17:51 +0100580 [ 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 +0200581 AC_CACHE_CHECK(Lua version of LuaJIT, vi_cv_version_lua_luajit,
582 [ vi_cv_version_lua_luajit=`${vi_cv_path_luajit} -e "print(_VERSION)" | sed 's/.* //'` ])
583 vi_cv_path_lua="$vi_cv_path_luajit"
584 vi_cv_version_lua="$vi_cv_version_lua_luajit"
585 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200586 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200587 dnl -- try to find Lua executable
588 AC_PATH_PROG(vi_cv_path_plain_lua, lua)
589 if test "X$vi_cv_path_plain_lua" != "X"; then
590 dnl -- find Lua version
591 AC_CACHE_CHECK(Lua version, vi_cv_version_plain_lua,
592 [ vi_cv_version_plain_lua=`${vi_cv_path_plain_lua} -e "print(_VERSION)" | sed 's/.* //'` ])
593 fi
594 vi_cv_path_lua="$vi_cv_path_plain_lua"
595 vi_cv_version_lua="$vi_cv_version_plain_lua"
596 fi
597 if test "x$vi_cv_with_luajit" != "xno" && test "X$vi_cv_version_luajit" != "X"; then
598 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 +0100599 if test -f "$vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200600 AC_MSG_RESULT(yes)
601 LUA_INC=/luajit-$vi_cv_version_luajit
602 fi
603 fi
604 if test "X$LUA_INC" = "X"; then
605 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)
Bram Moolenaar49222be2015-12-11 18:11:30 +0100606 if test -f "$vi_cv_path_lua_pfx/include/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200607 AC_MSG_RESULT(yes)
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200608 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200609 AC_MSG_RESULT(no)
610 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 +0100611 if test -f "$vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200612 AC_MSG_RESULT(yes)
613 LUA_INC=/lua$vi_cv_version_lua
614 else
615 AC_MSG_RESULT(no)
616 vi_cv_path_lua_pfx=
617 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200618 fi
619 fi
620 fi
621
622 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200623 if test "x$vi_cv_with_luajit" != "xno"; then
624 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
625 if test "X$multiarch" != "X"; then
626 lib_multiarch="lib/${multiarch}"
627 else
628 lib_multiarch="lib"
629 fi
630 if test "X$vi_cv_version_lua" = "X"; then
631 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit"
632 else
633 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit-$vi_cv_version_lua"
634 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200635 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200636 if test "X$LUA_INC" != "X"; then
637 dnl Test alternate location using version
638 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua$vi_cv_version_lua"
639 else
640 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua"
641 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200642 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200643 if test "$enable_luainterp" = "dynamic"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200644 lua_ok="yes"
645 else
646 AC_MSG_CHECKING([if link with ${LUA_LIBS} is sane])
647 libs_save=$LIBS
648 LIBS="$LIBS $LUA_LIBS"
649 AC_TRY_LINK(,[ ],
650 AC_MSG_RESULT(yes); lua_ok="yes",
651 AC_MSG_RESULT(no); lua_ok="no"; LUA_LIBS="")
652 LIBS=$libs_save
653 fi
654 if test "x$lua_ok" = "xyes"; then
655 LUA_CFLAGS="-I${vi_cv_path_lua_pfx}/include${LUA_INC}"
656 LUA_SRC="if_lua.c"
657 LUA_OBJ="objects/if_lua.o"
658 LUA_PRO="if_lua.pro"
659 AC_DEFINE(FEAT_LUA)
660 fi
661 if test "$enable_luainterp" = "dynamic"; then
662 if test "x$vi_cv_with_luajit" != "xno"; then
663 luajit="jit"
664 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200665 if test -f "${vi_cv_path_lua_pfx}/bin/cyglua-${vi_cv_version_lua}.dll"; then
666 vi_cv_dll_name_lua="cyglua-${vi_cv_version_lua}.dll"
667 else
Bram Moolenaard0573012017-10-28 21:11:06 +0200668 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200669 ext="dylib"
670 indexes=""
671 else
672 ext="so"
673 indexes=".0 .1 .2 .3 .4 .5 .6 .7 .8 .9"
674 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
675 if test "X$multiarch" != "X"; then
676 lib_multiarch="lib/${multiarch}"
677 fi
Bram Moolenaar768baac2013-04-15 14:44:57 +0200678 fi
679 dnl Determine the sover for the current version, but fallback to
680 dnl liblua${vi_cv_version_lua}.so if no sover-versioned file is found.
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200681 AC_MSG_CHECKING(if liblua${luajit}*.${ext}* can be found in $vi_cv_path_lua_pfx)
Bram Moolenaar768baac2013-04-15 14:44:57 +0200682 for subdir in "${lib_multiarch}" lib64 lib; do
683 if test -z "$subdir"; then
684 continue
685 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200686 for sover in "${vi_cv_version_lua}.${ext}" "-${vi_cv_version_lua}.${ext}" \
687 ".${vi_cv_version_lua}.${ext}" ".${ext}.${vi_cv_version_lua}"; do
688 for i in $indexes ""; do
689 if test -f "${vi_cv_path_lua_pfx}/${subdir}/liblua${luajit}${sover}$i"; then
Bram Moolenaar768baac2013-04-15 14:44:57 +0200690 sover2="$i"
691 break 3
692 fi
693 done
Bram Moolenaar07e1da62013-02-06 19:49:43 +0100694 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200695 sover=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200696 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200697 if test "X$sover" = "X"; then
698 AC_MSG_RESULT(no)
699 lua_ok="no"
700 vi_cv_dll_name_lua="liblua${luajit}.${ext}"
701 else
702 AC_MSG_RESULT(yes)
703 lua_ok="yes"
704 vi_cv_dll_name_lua="liblua${luajit}${sover}$sover2"
705 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200706 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200707 AC_DEFINE(DYNAMIC_LUA)
708 LUA_LIBS=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200709 LUA_CFLAGS="-DDYNAMIC_LUA_DLL=\\\"${vi_cv_dll_name_lua}\\\" $LUA_CFLAGS"
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200710 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200711 if test "X$LUA_CFLAGS$LUA_LIBS" != "X" && \
Bram Moolenaard0573012017-10-28 21:11:06 +0200712 test "x$MACOS_X" = "xyes" && test "x$vi_cv_with_luajit" != "xno" && \
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200713 test "`(uname -m) 2>/dev/null`" = "x86_64"; then
714 dnl OSX/x64 requires these flags. See http://luajit.org/install.html
715 LUA_LIBS="-pagezero_size 10000 -image_base 100000000 $LUA_LIBS"
716 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200717 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200718 if test "$fail_if_missing" = "yes" -a "$lua_ok" != "yes"; then
Bram Moolenaarf788a062011-12-14 20:51:25 +0100719 AC_MSG_ERROR([could not configure lua])
720 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200721 AC_SUBST(LUA_SRC)
722 AC_SUBST(LUA_OBJ)
723 AC_SUBST(LUA_PRO)
724 AC_SUBST(LUA_LIBS)
725 AC_SUBST(LUA_CFLAGS)
726fi
727
728
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000729dnl Check for MzScheme feature.
730AC_MSG_CHECKING(--enable-mzschemeinterp argument)
731AC_ARG_ENABLE(mzschemeinterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200732 [ --enable-mzschemeinterp Include MzScheme interpreter.], ,
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000733 [enable_mzschemeinterp="no"])
734AC_MSG_RESULT($enable_mzschemeinterp)
735
736if test "$enable_mzschemeinterp" = "yes"; then
737 dnl -- find the mzscheme executable
738 AC_SUBST(vi_cv_path_mzscheme)
739
740 AC_MSG_CHECKING(--with-plthome argument)
741 AC_ARG_WITH(plthome,
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000742 [ --with-plthome=PLTHOME Use PLTHOME.],
743 with_plthome="$withval"; AC_MSG_RESULT($with_plthome),
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000744 with_plthome="";AC_MSG_RESULT("no"))
745
746 if test "X$with_plthome" != "X"; then
747 vi_cv_path_mzscheme_pfx="$with_plthome"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100748 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000749 else
750 AC_MSG_CHECKING(PLTHOME environment var)
751 if test "X$PLTHOME" != "X"; then
752 AC_MSG_RESULT("$PLTHOME")
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000753 vi_cv_path_mzscheme_pfx="$PLTHOME"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100754 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000755 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000756 AC_MSG_RESULT(not set)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000757 dnl -- try to find MzScheme executable
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000758 AC_PATH_PROG(vi_cv_path_mzscheme, mzscheme)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000759
760 dnl resolve symbolic link, the executable is often elsewhere and there
761 dnl are no links for the include files.
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000762 if test "X$vi_cv_path_mzscheme" != "X"; then
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000763 lsout=`ls -l $vi_cv_path_mzscheme`
764 if echo "$lsout" | grep -e '->' >/dev/null 2>/dev/null; then
765 vi_cv_path_mzscheme=`echo "$lsout" | sed 's/.*-> \(.*\)/\1/'`
766 fi
767 fi
768
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000769 if test "X$vi_cv_path_mzscheme" != "X"; then
770 dnl -- find where MzScheme thinks it was installed
771 AC_CACHE_CHECK(MzScheme install prefix,vi_cv_path_mzscheme_pfx,
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000772 dnl different versions of MzScheme differ in command line processing
773 dnl use universal approach
774 echo "(display (simplify-path \
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000775 (build-path (call-with-values \
776 (lambda () (split-path (find-system-path (quote exec-file)))) \
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000777 (lambda (base name must-be-dir?) base)) (quote up))))" > mzdirs.scm
778 dnl Remove a trailing slash
779 [ vi_cv_path_mzscheme_pfx=`${vi_cv_path_mzscheme} -r mzdirs.scm | \
780 sed -e 's+/$++'` ])
781 rm -f mzdirs.scm
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000782 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000783 fi
784 fi
785
786 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100787 AC_MSG_CHECKING(for racket include directory)
788 SCHEME_INC=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-include-dir))) (when (path? p) (display p)))'`
789 if test "X$SCHEME_INC" != "X"; then
790 AC_MSG_RESULT(${SCHEME_INC})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000791 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100792 AC_MSG_RESULT(not found)
793 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include)
794 if test -f "$vi_cv_path_mzscheme_pfx/include/scheme.h"; then
795 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000796 AC_MSG_RESULT(yes)
Bram Moolenaard7afed32007-05-06 13:26:41 +0000797 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000798 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100799 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt)
800 if test -f "$vi_cv_path_mzscheme_pfx/include/plt/scheme.h"; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000801 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100802 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000803 else
804 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100805 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket)
806 if test -f "$vi_cv_path_mzscheme_pfx/include/racket/scheme.h"; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100807 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100808 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100809 else
810 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100811 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/)
812 if test -f /usr/include/plt/scheme.h; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100813 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100814 SCHEME_INC=/usr/include/plt
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100815 else
816 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100817 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/racket/)
818 if test -f /usr/include/racket/scheme.h; then
819 AC_MSG_RESULT(yes)
820 SCHEME_INC=/usr/include/racket
821 else
822 AC_MSG_RESULT(no)
823 vi_cv_path_mzscheme_pfx=
824 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100825 fi
826 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000827 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000828 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000829 fi
830 fi
831
832 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100833
834 AC_MSG_CHECKING(for racket lib directory)
835 SCHEME_LIB=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-lib-dir))) (when (path? p) (display p)))'`
836 if test "X$SCHEME_LIB" != "X"; then
837 AC_MSG_RESULT(${SCHEME_LIB})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000838 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100839 AC_MSG_RESULT(not found)
840 fi
841
842 for path in "${vi_cv_path_mzscheme_pfx}/lib" "${SCHEME_LIB}"; do
843 if test "X$path" != "X"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200844 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100845 MZSCHEME_LIBS="-framework Racket"
846 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
847 elif test -f "${path}/libmzscheme3m.a"; then
848 MZSCHEME_LIBS="${path}/libmzscheme3m.a"
849 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
850 elif test -f "${path}/libracket3m.a"; then
851 MZSCHEME_LIBS="${path}/libracket3m.a"
852 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
853 elif test -f "${path}/libracket.a"; then
854 MZSCHEME_LIBS="${path}/libracket.a ${path}/libmzgc.a"
855 elif test -f "${path}/libmzscheme.a"; then
856 MZSCHEME_LIBS="${path}/libmzscheme.a ${path}/libmzgc.a"
857 else
858 dnl Using shared objects
859 if test -f "${path}/libmzscheme3m.so"; then
860 MZSCHEME_LIBS="-L${path} -lmzscheme3m"
861 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
862 elif test -f "${path}/libracket3m.so"; then
863 MZSCHEME_LIBS="-L${path} -lracket3m"
864 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
865 elif test -f "${path}/libracket.so"; then
866 MZSCHEME_LIBS="-L${path} -lracket -lmzgc"
867 else
868 dnl try next until last
869 if test "$path" != "$SCHEME_LIB"; then
870 continue
871 fi
872 MZSCHEME_LIBS="-L${path} -lmzscheme -lmzgc"
873 fi
874 if test "$GCC" = yes; then
875 dnl Make Vim remember the path to the library. For when it's not in
876 dnl $LD_LIBRARY_PATH.
877 MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${path}"
878 elif test "`(uname) 2>/dev/null`" = SunOS &&
879 uname -r | grep '^5' >/dev/null; then
880 MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${path}"
881 fi
882 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000883 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100884 if test "X$MZSCHEME_LIBS" != "X"; then
885 break
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +0000886 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100887 done
888
889 AC_MSG_CHECKING([if racket requires -pthread])
890 if test "X$SCHEME_LIB" != "X" && $FGREP -e -pthread "$SCHEME_LIB/buildinfo" >/dev/null ; then
891 AC_MSG_RESULT(yes)
892 MZSCHEME_LIBS="${MZSCHEME_LIBS} -pthread"
893 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -pthread"
894 else
895 AC_MSG_RESULT(no)
896 fi
897
898 AC_MSG_CHECKING(for racket config directory)
899 SCHEME_CONFIGDIR=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-config-dir))) (when (path? p) (display p)))'`
900 if test "X$SCHEME_CONFIGDIR" != "X"; then
901 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DMZSCHEME_CONFIGDIR='\"${SCHEME_CONFIGDIR}\"'"
902 AC_MSG_RESULT(${SCHEME_CONFIGDIR})
903 else
904 AC_MSG_RESULT(not found)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000905 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100906
907 AC_MSG_CHECKING(for racket collects directory)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100908 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))))'`
909 if test "X$SCHEME_COLLECTS" = "X"; then
910 if test -d "$vi_cv_path_mzscheme_pfx/lib/plt/collects"; then
911 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/plt/
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100912 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100913 if test -d "$vi_cv_path_mzscheme_pfx/lib/racket/collects"; then
914 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/racket/
Bram Moolenaar75676462013-01-30 14:55:42 +0100915 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100916 if test -d "$vi_cv_path_mzscheme_pfx/share/racket/collects"; then
917 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/
918 else
919 if test -d "$vi_cv_path_mzscheme_pfx/collects"; then
920 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/
921 fi
Bram Moolenaar75676462013-01-30 14:55:42 +0100922 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100923 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100924 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000925 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100926 if test "X$SCHEME_COLLECTS" != "X" ; then
927 AC_MSG_RESULT(${SCHEME_COLLECTS})
928 else
929 AC_MSG_RESULT(not found)
930 fi
931
932 AC_MSG_CHECKING(for mzscheme_base.c)
933 if test -f "${SCHEME_COLLECTS}collects/scheme/base.ss" ; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000934 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +0100935 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
936 MZSCHEME_MOD="++lib scheme/base"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100937 else
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100938 if test -f "${SCHEME_COLLECTS}collects/scheme/base.rkt" ; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100939 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +0100940 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
941 MZSCHEME_MOD="++lib scheme/base"
942 else
943 if test -f "${SCHEME_COLLECTS}collects/racket/base.rkt" ; then
944 MZSCHEME_EXTRA="mzscheme_base.c"
945 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/raco ctool"
946 MZSCHEME_MOD=""
947 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100948 fi
949 fi
950 if test "X$MZSCHEME_EXTRA" != "X" ; then
951 dnl need to generate bytecode for MzScheme base
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000952 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE"
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100953 AC_MSG_RESULT(needed)
954 else
955 AC_MSG_RESULT(not needed)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000956 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100957
Bram Moolenaar9e902192013-07-17 18:58:11 +0200958 dnl On Ubuntu this fixes "undefined reference to symbol 'ffi_type_void'".
959 AC_CHECK_LIB(ffi, ffi_type_void, [MZSCHEME_LIBS="$MZSCHEME_LIBS -lffi"])
960
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000961 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -I${SCHEME_INC} \
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100962 -DMZSCHEME_COLLECTS='\"${SCHEME_COLLECTS}collects\"'"
Bram Moolenaar9e902192013-07-17 18:58:11 +0200963
964 dnl Test that we can compile a simple program with these CFLAGS and LIBS.
965 AC_MSG_CHECKING([if compile and link flags for MzScheme are sane])
966 cflags_save=$CFLAGS
967 libs_save=$LIBS
968 CFLAGS="$CFLAGS $MZSCHEME_CFLAGS"
969 LIBS="$LIBS $MZSCHEME_LIBS"
970 AC_TRY_LINK(,[ ],
971 AC_MSG_RESULT(yes); mzs_ok=yes,
972 AC_MSG_RESULT(no: MZSCHEME DISABLED); mzs_ok=no)
973 CFLAGS=$cflags_save
974 LIBS=$libs_save
975 if test $mzs_ok = yes; then
976 MZSCHEME_SRC="if_mzsch.c"
977 MZSCHEME_OBJ="objects/if_mzsch.o"
978 MZSCHEME_PRO="if_mzsch.pro"
979 AC_DEFINE(FEAT_MZSCHEME)
980 else
981 MZSCHEME_CFLAGS=
982 MZSCHEME_LIBS=
983 MZSCHEME_EXTRA=
984 MZSCHEME_MZC=
985 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000986 fi
987 AC_SUBST(MZSCHEME_SRC)
988 AC_SUBST(MZSCHEME_OBJ)
989 AC_SUBST(MZSCHEME_PRO)
990 AC_SUBST(MZSCHEME_LIBS)
991 AC_SUBST(MZSCHEME_CFLAGS)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000992 AC_SUBST(MZSCHEME_EXTRA)
993 AC_SUBST(MZSCHEME_MZC)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000994fi
995
996
Bram Moolenaar071d4272004-06-13 20:20:40 +0000997AC_MSG_CHECKING(--enable-perlinterp argument)
998AC_ARG_ENABLE(perlinterp,
Bram Moolenaare06c1882010-07-21 22:05:20 +0200999 [ --enable-perlinterp[=OPTS] Include Perl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001000 [enable_perlinterp="no"])
1001AC_MSG_RESULT($enable_perlinterp)
Bram Moolenaare06c1882010-07-21 22:05:20 +02001002if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01001003 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1004 AC_MSG_ERROR([cannot use Perl with tiny or small features])
1005 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001006 AC_SUBST(vi_cv_path_perl)
1007 AC_PATH_PROG(vi_cv_path_perl, perl)
1008 if test "X$vi_cv_path_perl" != "X"; then
1009 AC_MSG_CHECKING(Perl version)
1010 if $vi_cv_path_perl -e 'require 5.003_01' >/dev/null 2>/dev/null; then
1011 eval `$vi_cv_path_perl -V:usethreads`
Bram Moolenaare06c1882010-07-21 22:05:20 +02001012 eval `$vi_cv_path_perl -V:libperl`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001013 if test "X$usethreads" = "XUNKNOWN" -o "X$usethreads" = "Xundef"; then
1014 badthreads=no
1015 else
1016 if $vi_cv_path_perl -e 'require 5.6.0' >/dev/null 2>/dev/null; then
1017 eval `$vi_cv_path_perl -V:use5005threads`
1018 if test "X$use5005threads" = "XUNKNOWN" -o "X$use5005threads" = "Xundef"; then
1019 badthreads=no
1020 else
1021 badthreads=yes
1022 AC_MSG_RESULT(>>> Perl > 5.6 with 5.5 threads cannot be used <<<)
1023 fi
1024 else
1025 badthreads=yes
1026 AC_MSG_RESULT(>>> Perl 5.5 with threads cannot be used <<<)
1027 fi
1028 fi
1029 if test $badthreads = no; then
1030 AC_MSG_RESULT(OK)
1031 eval `$vi_cv_path_perl -V:shrpenv`
1032 if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04
1033 shrpenv=""
1034 fi
1035 vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlibexp}'`
1036 AC_SUBST(vi_cv_perllib)
Bram Moolenaard5f62b12014-08-17 17:05:44 +02001037 vi_cv_perl_extutils=unknown_perl_extutils_path
1038 for extutils_rel_path in ExtUtils vendor_perl/ExtUtils; do
1039 xsubpp_path="$vi_cv_perllib/$extutils_rel_path/xsubpp"
1040 if test -f "$xsubpp_path"; then
1041 vi_cv_perl_xsubpp="$xsubpp_path"
1042 fi
1043 done
1044 AC_SUBST(vi_cv_perl_xsubpp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001045 dnl Remove "-fno-something", it breaks using cproto.
Bram Moolenaar280a8682015-06-21 13:41:08 +02001046 dnl Remove "-fdebug-prefix-map", it isn't supported by clang.
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001047 dnl Remove "FORTIFY_SOURCE", it will be defined twice.
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001048 dnl remove -pipe and -Wxxx, it confuses cproto
Bram Moolenaar071d4272004-06-13 20:20:40 +00001049 perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001050 -e 'ccflags;perl_inc;print"\n"' | sed -e 's/-fno[[^ ]]*//' \
1051 -e 's/-fdebug-prefix-map[[^ ]]*//g' \
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001052 -e 's/-pipe //' \
1053 -e 's/-W[[^ ]]*//g' \
1054 -e 's/-D_FORTIFY_SOURCE=.//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001055 dnl Remove "-lc", it breaks on FreeBSD when using "-pthread".
1056 perllibs=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed -e 'ldopts' | \
1057 sed -e '/Warning/d' -e '/Note (probably harmless)/d' \
1058 -e 's/-bE:perl.exp//' -e 's/-lc //'`
1059 dnl Don't add perl lib to $LIBS: if it's not in LD_LIBRARY_PATH
1060 dnl a test in configure may fail because of that.
1061 perlldflags=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed \
1062 -e 'ccdlflags' | sed -e 's/-bE:perl.exp//'`
1063
1064 dnl check that compiling a simple program still works with the flags
1065 dnl added for Perl.
1066 AC_MSG_CHECKING([if compile and link flags for Perl are sane])
1067 cflags_save=$CFLAGS
1068 libs_save=$LIBS
1069 ldflags_save=$LDFLAGS
1070 CFLAGS="$CFLAGS $perlcppflags"
1071 LIBS="$LIBS $perllibs"
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001072 perlldflags=`echo "$perlldflags" | sed -e 's/^ *//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001073 LDFLAGS="$perlldflags $LDFLAGS"
1074 AC_TRY_LINK(,[ ],
1075 AC_MSG_RESULT(yes); perl_ok=yes,
1076 AC_MSG_RESULT(no: PERL DISABLED); perl_ok=no)
1077 CFLAGS=$cflags_save
1078 LIBS=$libs_save
1079 LDFLAGS=$ldflags_save
1080 if test $perl_ok = yes; then
1081 if test "X$perlcppflags" != "X"; then
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001082 PERL_CFLAGS=$perlcppflags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001083 fi
1084 if test "X$perlldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001085 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$perlldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001086 LDFLAGS="$perlldflags $LDFLAGS"
1087 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001088 fi
1089 PERL_LIBS=$perllibs
1090 PERL_SRC="auto/if_perl.c if_perlsfio.c"
1091 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o"
1092 PERL_PRO="if_perl.pro if_perlsfio.pro"
1093 AC_DEFINE(FEAT_PERL)
1094 fi
1095 fi
1096 else
1097 AC_MSG_RESULT(>>> too old; need Perl version 5.003_01 or later <<<)
1098 fi
1099 fi
1100
Bram Moolenaard0573012017-10-28 21:11:06 +02001101 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00001102 dnl Mac OS X 10.2 or later
Bram Moolenaar071d4272004-06-13 20:20:40 +00001103 dir=/System/Library/Perl
1104 darwindir=$dir/darwin
1105 if test -d $darwindir; then
1106 PERL=/usr/bin/perl
1107 else
1108 dnl Mac OS X 10.3
1109 dir=/System/Library/Perl/5.8.1
1110 darwindir=$dir/darwin-thread-multi-2level
1111 if test -d $darwindir; then
1112 PERL=/usr/bin/perl
1113 fi
1114 fi
1115 if test -n "$PERL"; then
1116 PERL_DIR="$dir"
1117 PERL_CFLAGS="-DFEAT_PERL -I$darwindir/CORE"
1118 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o $darwindir/auto/DynaLoader/DynaLoader.a"
1119 PERL_LIBS="-L$darwindir/CORE -lperl"
1120 fi
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001121 dnl Perl on Mac OS X 10.5 adds "-arch" flags but these should only
1122 dnl be included if requested by passing --with-mac-arch to
1123 dnl configure, so strip these flags first (if present)
1124 PERL_LIBS=`echo "$PERL_LIBS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
1125 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 +00001126 fi
Bram Moolenaare06c1882010-07-21 22:05:20 +02001127 if test "$enable_perlinterp" = "dynamic"; then
1128 if test "$perl_ok" = "yes" -a "X$libperl" != "X"; then
1129 AC_DEFINE(DYNAMIC_PERL)
1130 PERL_CFLAGS="-DDYNAMIC_PERL_DLL=\\\"$libperl\\\" $PERL_CFLAGS"
1131 fi
1132 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001133
1134 if test "$fail_if_missing" = "yes" -a "$perl_ok" != "yes"; then
1135 AC_MSG_ERROR([could not configure perl])
1136 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001137fi
1138AC_SUBST(shrpenv)
1139AC_SUBST(PERL_SRC)
1140AC_SUBST(PERL_OBJ)
1141AC_SUBST(PERL_PRO)
1142AC_SUBST(PERL_CFLAGS)
1143AC_SUBST(PERL_LIBS)
1144
1145AC_MSG_CHECKING(--enable-pythoninterp argument)
1146AC_ARG_ENABLE(pythoninterp,
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001147 [ --enable-pythoninterp[=OPTS] Include Python interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001148 [enable_pythoninterp="no"])
1149AC_MSG_RESULT($enable_pythoninterp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001150if test "$enable_pythoninterp" = "yes" -o "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001151 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1152 AC_MSG_ERROR([cannot use Python with tiny or small features])
1153 fi
1154
Bram Moolenaar071d4272004-06-13 20:20:40 +00001155 dnl -- find the python executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001156 AC_MSG_CHECKING(--with-python-command argument)
1157 AC_SUBST(vi_cv_path_python)
1158 AC_ARG_WITH(python-command, [ --with-python-command=NAME name of the Python 2 command (default: python2 or python)],
1159 vi_cv_path_python="$withval"; AC_MSG_RESULT($vi_cv_path_python),
1160 AC_MSG_RESULT(no))
1161
1162 if test "X$vi_cv_path_python" = "X"; then
1163 AC_PATH_PROGS(vi_cv_path_python, python2 python)
1164 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001165 if test "X$vi_cv_path_python" != "X"; then
1166
1167 dnl -- get its version number
1168 AC_CACHE_CHECK(Python version,vi_cv_var_python_version,
1169 [[vi_cv_var_python_version=`
1170 ${vi_cv_path_python} -c 'import sys; print sys.version[:3]'`
1171 ]])
1172
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001173 dnl -- it must be at least version 2.3
1174 AC_MSG_CHECKING(Python is 2.3 or better)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001175 if ${vi_cv_path_python} -c \
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001176 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001177 then
1178 AC_MSG_RESULT(yep)
1179
1180 dnl -- find where python thinks it was installed
1181 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python_pfx,
1182 [ vi_cv_path_python_pfx=`
1183 ${vi_cv_path_python} -c \
1184 "import sys; print sys.prefix"` ])
1185
1186 dnl -- and where it thinks it runs
1187 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python_epfx,
1188 [ vi_cv_path_python_epfx=`
1189 ${vi_cv_path_python} -c \
1190 "import sys; print sys.exec_prefix"` ])
1191
1192 dnl -- python's internal library path
1193
1194 AC_CACHE_VAL(vi_cv_path_pythonpath,
1195 [ vi_cv_path_pythonpath=`
1196 unset PYTHONPATH;
1197 ${vi_cv_path_python} -c \
1198 "import sys, string; print string.join(sys.path,':')"` ])
1199
1200 dnl -- where the Python implementation library archives are
1201
1202 AC_ARG_WITH(python-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001203 [ --with-python-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001204 [ vi_cv_path_python_conf="${withval}"; have_python_config_dir=1 ] )
Bram Moolenaar071d4272004-06-13 20:20:40 +00001205
1206 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python_conf,
1207 [
1208 vi_cv_path_python_conf=
Bram Moolenaarac499e32013-06-02 19:14:17 +02001209 d=`${vi_cv_path_python} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBPL')"`
1210 if test -d "$d" && test -f "$d/config.c"; then
1211 vi_cv_path_python_conf="$d"
1212 else
1213 for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
1214 for subdir in lib64 lib share; do
1215 d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
1216 if test -d "$d" && test -f "$d/config.c"; then
1217 vi_cv_path_python_conf="$d"
1218 fi
1219 done
Bram Moolenaar071d4272004-06-13 20:20:40 +00001220 done
Bram Moolenaarac499e32013-06-02 19:14:17 +02001221 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001222 ])
1223
1224 PYTHON_CONFDIR="${vi_cv_path_python_conf}"
1225
1226 if test "X$PYTHON_CONFDIR" = "X"; then
1227 AC_MSG_RESULT([can't find it!])
1228 else
1229
1230 dnl -- we need to examine Python's config/Makefile too
1231 dnl see what the interpreter is built from
1232 AC_CACHE_VAL(vi_cv_path_python_plibs,
1233 [
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001234 pwd=`pwd`
1235 tmp_mkf="$pwd/config-PyMake$$"
1236 cat -- "${PYTHON_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001237__:
Bram Moolenaar218116c2010-05-20 21:46:00 +02001238 @echo "python_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001239 @echo "python_LIBS='$(LIBS)'"
1240 @echo "python_SYSLIBS='$(SYSLIBS)'"
1241 @echo "python_LINKFORSHARED='$(LINKFORSHARED)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001242 @echo "python_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001243 @echo "python_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001244 @echo "python_PYTHONFRAMEWORK='$(PYTHONFRAMEWORK)'"
1245 @echo "python_PYTHONFRAMEWORKPREFIX='$(PYTHONFRAMEWORKPREFIX)'"
1246 @echo "python_PYTHONFRAMEWORKINSTALLDIR='$(PYTHONFRAMEWORKINSTALLDIR)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001247eof
1248 dnl -- delete the lines from make about Entering/Leaving directory
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001249 eval "`cd ${PYTHON_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1250 rm -f -- "${tmp_mkf}"
Bram Moolenaard0573012017-10-28 21:11:06 +02001251 if test "x$MACOS_X" = "xyes" && test -n "${python_PYTHONFRAMEWORK}" && ${vi_cv_path_python} -c \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001252 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then
1253 vi_cv_path_python_plibs="-framework Python"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001254 if test "x${vi_cv_path_python}" != "x/usr/bin/python" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
1255 vi_cv_path_python_plibs="-F${python_PYTHONFRAMEWORKPREFIX} -framework Python"
1256 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001257 else
Bram Moolenaar9ce42132018-04-11 22:19:36 +02001258 vi_cv_path_python_plibs="-L${PYTHON_CONFDIR} -lpython${vi_cv_var_python_version}"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001259 dnl -- Check if the path contained in python_LINKFORSHARED is
1260 dnl usable for vim build. If not, make and try other
1261 dnl candidates.
Bram Moolenaara161e262015-03-24 15:14:27 +01001262 if test -n "${python_LINKFORSHARED}" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
Bram Moolenaar6c927552015-03-24 12:21:33 +01001263 python_link_symbol=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]].*/\1/'`
1264 python_link_path=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]][[ \t]]*\(.*\)/\2/'`
1265 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1266 dnl -- The path looks relative. Guess the absolute one using
1267 dnl the prefix and try that.
1268 python_link_path="${python_PYTHONFRAMEWORKPREFIX}/${python_link_path}"
1269 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1270 dnl -- A last resort.
1271 python_link_path="${python_PYTHONFRAMEWORKINSTALLDIR}/Versions/${vi_cv_var_python_version}/${python_PYTHONFRAMEWORK}"
1272 dnl -- No check is done. The last word is left to the
1273 dnl "sanity" test on link flags that follows shortly.
1274 fi
1275 python_LINKFORSHARED="${python_link_symbol} ${python_link_path}"
1276 fi
1277 fi
Bram Moolenaar218116c2010-05-20 21:46:00 +02001278 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 +00001279 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1280 vi_cv_path_python_plibs=`echo $vi_cv_path_python_plibs | sed s/-ltermcap//`
1281 fi
1282 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001283 AC_CACHE_CHECK(Python's dll name,vi_cv_dll_name_python,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001284 [
1285 if test "X$python_DLLLIBRARY" != "X"; then
1286 vi_cv_dll_name_python="$python_DLLLIBRARY"
1287 else
1288 vi_cv_dll_name_python="$python_INSTSONAME"
1289 fi
1290 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00001291
1292 PYTHON_LIBS="${vi_cv_path_python_plibs}"
1293 if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001294 PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001295 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001296 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 +00001297 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001298 if test "X$have_python_config_dir" = "X1" -a "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001299 dnl Define PYTHON_HOME if --with-python-config-dir was used
1300 PYTHON_CFLAGS="${PYTHON_CFLAGS} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'"
1301
1302 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001303 PYTHON_SRC="if_python.c"
Bram Moolenaar9bdb9a02012-07-25 16:32:08 +02001304 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001305
1306 dnl On FreeBSD linking with "-pthread" is required to use threads.
1307 dnl _THREAD_SAFE must be used for compiling then.
1308 dnl The "-pthread" is added to $LIBS, so that the following check for
1309 dnl sigaltstack() will look in libc_r (it's there in libc!).
1310 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1311 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1312 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1313 AC_MSG_CHECKING([if -pthread should be used])
1314 threadsafe_flag=
1315 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001316 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00001317 if test "`(uname) 2>/dev/null`" != Darwin; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001318 test "$GCC" = yes && threadsafe_flag="-pthread"
1319 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1320 threadsafe_flag="-D_THREAD_SAFE"
1321 thread_lib="-pthread"
1322 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001323 if test "`(uname) 2>/dev/null`" = SunOS; then
1324 threadsafe_flag="-pthreads"
1325 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001326 fi
1327 libs_save_old=$LIBS
1328 if test -n "$threadsafe_flag"; then
1329 cflags_save=$CFLAGS
1330 CFLAGS="$CFLAGS $threadsafe_flag"
1331 LIBS="$LIBS $thread_lib"
1332 AC_TRY_LINK(,[ ],
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001333 AC_MSG_RESULT(yes); PYTHON_CFLAGS="$PYTHON_CFLAGS $threadsafe_flag",
Bram Moolenaar071d4272004-06-13 20:20:40 +00001334 AC_MSG_RESULT(no); LIBS=$libs_save_old
1335 )
1336 CFLAGS=$cflags_save
1337 else
1338 AC_MSG_RESULT(no)
1339 fi
1340
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001341 dnl Check that compiling a simple program still works with the flags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001342 dnl added for Python.
1343 AC_MSG_CHECKING([if compile and link flags for Python are sane])
1344 cflags_save=$CFLAGS
1345 libs_save=$LIBS
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001346 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001347 LIBS="$LIBS $PYTHON_LIBS"
1348 AC_TRY_LINK(,[ ],
1349 AC_MSG_RESULT(yes); python_ok=yes,
1350 AC_MSG_RESULT(no: PYTHON DISABLED); python_ok=no)
1351 CFLAGS=$cflags_save
1352 LIBS=$libs_save
1353 if test $python_ok = yes; then
1354 AC_DEFINE(FEAT_PYTHON)
1355 else
1356 LIBS=$libs_save_old
1357 PYTHON_SRC=
1358 PYTHON_OBJ=
1359 PYTHON_LIBS=
1360 PYTHON_CFLAGS=
1361 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001362 fi
1363 else
1364 AC_MSG_RESULT(too old)
1365 fi
1366 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001367
1368 if test "$fail_if_missing" = "yes" -a "$python_ok" != "yes"; then
1369 AC_MSG_ERROR([could not configure python])
1370 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001371fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001372
Bram Moolenaar071d4272004-06-13 20:20:40 +00001373AC_SUBST(PYTHON_LIBS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001374AC_SUBST(PYTHON_CFLAGS)
1375AC_SUBST(PYTHON_SRC)
1376AC_SUBST(PYTHON_OBJ)
1377
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001378
1379AC_MSG_CHECKING(--enable-python3interp argument)
1380AC_ARG_ENABLE(python3interp,
Bram Moolenaar8008b632017-07-18 21:33:20 +02001381 [ --enable-python3interp[=OPTS] Include Python3 interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001382 [enable_python3interp="no"])
1383AC_MSG_RESULT($enable_python3interp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001384if test "$enable_python3interp" = "yes" -o "$enable_python3interp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001385 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1386 AC_MSG_ERROR([cannot use Python with tiny or small features])
1387 fi
1388
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001389 dnl -- find the python3 executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001390 AC_MSG_CHECKING(--with-python3-command argument)
1391 AC_SUBST(vi_cv_path_python3)
1392 AC_ARG_WITH(python3-command, [ --with-python3-command=NAME name of the Python 3 command (default: python3 or python)],
1393 vi_cv_path_python3="$withval"; AC_MSG_RESULT($vi_cv_path_python3),
1394 AC_MSG_RESULT(no))
1395
1396 if test "X$vi_cv_path_python3" = "X"; then
1397 AC_PATH_PROGS(vi_cv_path_python3, python3 python)
1398 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001399 if test "X$vi_cv_path_python3" != "X"; then
1400
1401 dnl -- get its version number
1402 AC_CACHE_CHECK(Python version,vi_cv_var_python3_version,
1403 [[vi_cv_var_python3_version=`
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001404 ${vi_cv_path_python3} -c 'import sys; print(sys.version[:3])'`
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001405 ]])
1406
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001407 dnl -- it must be at least version 3
1408 AC_MSG_CHECKING(Python is 3.0 or better)
1409 if ${vi_cv_path_python3} -c \
1410 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.0)"
1411 then
1412 AC_MSG_RESULT(yep)
Bram Moolenaar456f2bb2011-06-12 21:37:13 +02001413
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001414 dnl -- get abiflags for python 3.2 or higher (PEP 3149)
1415 AC_CACHE_CHECK(Python's abiflags,vi_cv_var_python3_abiflags,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001416 [
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001417 vi_cv_var_python3_abiflags=
1418 if ${vi_cv_path_python3} -c \
1419 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)"
1420 then
1421 vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \
1422 "import sys; print(sys.abiflags)"`
1423 fi ])
1424
1425 dnl -- find where python3 thinks it was installed
1426 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx,
1427 [ vi_cv_path_python3_pfx=`
1428 ${vi_cv_path_python3} -c \
1429 "import sys; print(sys.prefix)"` ])
1430
1431 dnl -- and where it thinks it runs
1432 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx,
1433 [ vi_cv_path_python3_epfx=`
1434 ${vi_cv_path_python3} -c \
1435 "import sys; print(sys.exec_prefix)"` ])
1436
1437 dnl -- python3's internal library path
1438
1439 AC_CACHE_VAL(vi_cv_path_python3path,
1440 [ vi_cv_path_python3path=`
1441 unset PYTHONPATH;
1442 ${vi_cv_path_python3} -c \
1443 "import sys, string; print(':'.join(sys.path))"` ])
1444
1445 dnl -- where the Python implementation library archives are
1446
1447 AC_ARG_WITH(python3-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001448 [ --with-python3-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001449 [ vi_cv_path_python3_conf="${withval}"; have_python3_config_dir=1 ] )
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001450
1451 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf,
1452 [
1453 vi_cv_path_python3_conf=
Bram Moolenaarfee496d2013-07-12 20:07:24 +02001454 config_dir="config-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001455 d=`${vi_cv_path_python3} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBPL'))"`
1456 if test -d "$d" && test -f "$d/config.c"; then
1457 vi_cv_path_python3_conf="$d"
1458 else
1459 for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do
1460 for subdir in lib64 lib share; do
1461 d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}"
1462 if test -d "$d" && test -f "$d/config.c"; then
1463 vi_cv_path_python3_conf="$d"
1464 fi
1465 done
1466 done
1467 fi
1468 ])
1469
1470 PYTHON3_CONFDIR="${vi_cv_path_python3_conf}"
1471
1472 if test "X$PYTHON3_CONFDIR" = "X"; then
1473 AC_MSG_RESULT([can't find it!])
1474 else
1475
1476 dnl -- we need to examine Python's config/Makefile too
1477 dnl see what the interpreter is built from
1478 AC_CACHE_VAL(vi_cv_path_python3_plibs,
1479 [
1480 pwd=`pwd`
1481 tmp_mkf="$pwd/config-PyMake$$"
1482 cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001483__:
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001484 @echo "python3_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001485 @echo "python3_LIBS='$(LIBS)'"
1486 @echo "python3_SYSLIBS='$(SYSLIBS)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001487 @echo "python3_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001488 @echo "python3_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001489eof
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001490 dnl -- delete the lines from make about Entering/Leaving directory
1491 eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1492 rm -f -- "${tmp_mkf}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001493 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 +02001494 vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}"
1495 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1496 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//`
1497 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//`
1498 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001499 AC_CACHE_CHECK(Python3's dll name,vi_cv_dll_name_python3,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001500 [
1501 if test "X$python3_DLLLIBRARY" != "X"; then
1502 vi_cv_dll_name_python3="$python3_DLLLIBRARY"
1503 else
1504 vi_cv_dll_name_python3="$python3_INSTSONAME"
1505 fi
1506 ])
1507
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001508 PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
1509 if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001510 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 +02001511 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001512 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 +02001513 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001514 if test "X$have_python3_config_dir" = "X1" -a "$enable_python3interp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001515 dnl Define PYTHON3_HOME if --with-python-config-dir was used
1516 PYTHON3_CFLAGS="${PYTHON3_CFLAGS} -DPYTHON3_HOME='L\"${vi_cv_path_python3_pfx}\"'"
1517 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001518 PYTHON3_SRC="if_python3.c"
1519 PYTHON3_OBJ="objects/if_python3.o"
1520
1521 dnl On FreeBSD linking with "-pthread" is required to use threads.
1522 dnl _THREAD_SAFE must be used for compiling then.
1523 dnl The "-pthread" is added to $LIBS, so that the following check for
1524 dnl sigaltstack() will look in libc_r (it's there in libc!).
1525 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1526 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1527 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1528 AC_MSG_CHECKING([if -pthread should be used])
1529 threadsafe_flag=
1530 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001531 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001532 if test "`(uname) 2>/dev/null`" != Darwin; then
1533 test "$GCC" = yes && threadsafe_flag="-pthread"
1534 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1535 threadsafe_flag="-D_THREAD_SAFE"
1536 thread_lib="-pthread"
1537 fi
1538 if test "`(uname) 2>/dev/null`" = SunOS; then
1539 threadsafe_flag="-pthreads"
1540 fi
1541 fi
1542 libs_save_old=$LIBS
1543 if test -n "$threadsafe_flag"; then
1544 cflags_save=$CFLAGS
1545 CFLAGS="$CFLAGS $threadsafe_flag"
1546 LIBS="$LIBS $thread_lib"
1547 AC_TRY_LINK(,[ ],
1548 AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag",
1549 AC_MSG_RESULT(no); LIBS=$libs_save_old
1550 )
1551 CFLAGS=$cflags_save
1552 else
1553 AC_MSG_RESULT(no)
1554 fi
1555
1556 dnl check that compiling a simple program still works with the flags
1557 dnl added for Python.
1558 AC_MSG_CHECKING([if compile and link flags for Python 3 are sane])
1559 cflags_save=$CFLAGS
1560 libs_save=$LIBS
1561 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1562 LIBS="$LIBS $PYTHON3_LIBS"
1563 AC_TRY_LINK(,[ ],
1564 AC_MSG_RESULT(yes); python3_ok=yes,
1565 AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no)
1566 CFLAGS=$cflags_save
1567 LIBS=$libs_save
1568 if test "$python3_ok" = yes; then
1569 AC_DEFINE(FEAT_PYTHON3)
1570 else
1571 LIBS=$libs_save_old
1572 PYTHON3_SRC=
1573 PYTHON3_OBJ=
1574 PYTHON3_LIBS=
1575 PYTHON3_CFLAGS=
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001576 fi
1577 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001578 else
1579 AC_MSG_RESULT(too old)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001580 fi
1581 fi
Bram Moolenaar1612b1a2013-06-14 21:22:39 +02001582 if test "$fail_if_missing" = "yes" -a "$python3_ok" != "yes"; then
1583 AC_MSG_ERROR([could not configure python3])
1584 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001585fi
1586
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001587AC_SUBST(PYTHON3_LIBS)
1588AC_SUBST(PYTHON3_CFLAGS)
1589AC_SUBST(PYTHON3_SRC)
1590AC_SUBST(PYTHON3_OBJ)
1591
1592dnl if python2.x and python3.x are enabled one can only link in code
1593dnl with dlopen(), dlsym(), dlclose()
1594if test "$python_ok" = yes && test "$python3_ok" = yes; then
1595 AC_DEFINE(DYNAMIC_PYTHON)
1596 AC_DEFINE(DYNAMIC_PYTHON3)
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001597 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001598 cflags_save=$CFLAGS
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001599 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001600 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001601 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001602 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001603 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001604 #include <dlfcn.h>
1605 /* If this program fails, then RTLD_GLOBAL is needed.
1606 * RTLD_GLOBAL will be used and then it is not possible to
1607 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001608 * Only the first python version used will be switched on.
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001609 */
1610
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001611 int no_rtl_global_needed_for(char *python_instsoname, char *prefix)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001612 {
1613 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001614 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001615 if (pylib != 0)
1616 {
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001617 void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome");
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001618 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1619 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1620 void (*final)(void) = dlsym(pylib, "Py_Finalize");
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001621 (*pfx)(prefix);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001622 (*init)();
1623 needed = (*simple)("import termios") == -1;
1624 (*final)();
1625 dlclose(pylib);
1626 }
1627 return !needed;
1628 }
1629
1630 int main(int argc, char** argv)
1631 {
1632 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001633 if (no_rtl_global_needed_for("${vi_cv_dll_name_python}", "${vi_cv_path_python_pfx}"))
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001634 not_needed = 1;
1635 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001636 }])],
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001637 [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001638
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001639 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001640 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001641
1642 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python3)
1643 cflags_save=$CFLAGS
1644 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001645 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001646 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001647 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001648 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001649 #include <dlfcn.h>
1650 #include <wchar.h>
1651 /* If this program fails, then RTLD_GLOBAL is needed.
1652 * RTLD_GLOBAL will be used and then it is not possible to
1653 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001654 * Only the first python version used will be switched on.
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001655 */
1656
1657 int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix)
1658 {
1659 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001660 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001661 if (pylib != 0)
1662 {
1663 void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome");
1664 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1665 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1666 void (*final)(void) = dlsym(pylib, "Py_Finalize");
1667 (*pfx)(prefix);
1668 (*init)();
1669 needed = (*simple)("import termios") == -1;
1670 (*final)();
1671 dlclose(pylib);
1672 }
1673 return !needed;
1674 }
1675
1676 int main(int argc, char** argv)
1677 {
1678 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001679 if (no_rtl_global_needed_for("${vi_cv_dll_name_python3}", L"${vi_cv_path_python3_pfx}"))
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001680 not_needed = 1;
1681 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001682 }])],
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001683 [AC_MSG_RESULT(yes);AC_DEFINE(PY3_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
1684
1685 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001686 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001687
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001688 PYTHON_SRC="if_python.c"
1689 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001690 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001691 PYTHON_LIBS=
1692 PYTHON3_SRC="if_python3.c"
1693 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001694 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001695 PYTHON3_LIBS=
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001696elif test "$python_ok" = yes && test "$enable_pythoninterp" = "dynamic"; then
1697 AC_DEFINE(DYNAMIC_PYTHON)
1698 PYTHON_SRC="if_python.c"
1699 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001700 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001701 PYTHON_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001702elif test "$python_ok" = yes; then
1703 dnl Check that adding -fPIE works. It may be needed when using a static
1704 dnl Python library.
1705 AC_MSG_CHECKING([if -fPIE can be added for Python])
1706 cflags_save=$CFLAGS
1707 libs_save=$LIBS
1708 CFLAGS="$CFLAGS $PYTHON_CFLAGS -fPIE"
1709 LIBS="$LIBS $PYTHON_LIBS"
1710 AC_TRY_LINK(,[ ],
1711 AC_MSG_RESULT(yes); fpie_ok=yes,
1712 AC_MSG_RESULT(no); fpie_ok=no)
1713 CFLAGS=$cflags_save
1714 LIBS=$libs_save
1715 if test $fpie_ok = yes; then
1716 PYTHON_CFLAGS="$PYTHON_CFLAGS -fPIE"
1717 fi
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001718elif test "$python3_ok" = yes && test "$enable_python3interp" = "dynamic"; then
1719 AC_DEFINE(DYNAMIC_PYTHON3)
1720 PYTHON3_SRC="if_python3.c"
1721 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001722 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001723 PYTHON3_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001724elif test "$python3_ok" = yes; then
1725 dnl Check that adding -fPIE works. It may be needed when using a static
1726 dnl Python library.
1727 AC_MSG_CHECKING([if -fPIE can be added for Python3])
1728 cflags_save=$CFLAGS
1729 libs_save=$LIBS
1730 CFLAGS="$CFLAGS $PYTHON3_CFLAGS -fPIE"
1731 LIBS="$LIBS $PYTHON3_LIBS"
1732 AC_TRY_LINK(,[ ],
1733 AC_MSG_RESULT(yes); fpie_ok=yes,
1734 AC_MSG_RESULT(no); fpie_ok=no)
1735 CFLAGS=$cflags_save
1736 LIBS=$libs_save
1737 if test $fpie_ok = yes; then
1738 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -fPIE"
1739 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001740fi
1741
Bram Moolenaar071d4272004-06-13 20:20:40 +00001742AC_MSG_CHECKING(--enable-tclinterp argument)
1743AC_ARG_ENABLE(tclinterp,
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001744 [ --enable-tclinterp[=OPTS] Include Tcl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001745 [enable_tclinterp="no"])
1746AC_MSG_RESULT($enable_tclinterp)
1747
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001748if test "$enable_tclinterp" = "yes" -o "$enable_tclinterp" = "dynamic"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001749
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001750 dnl on FreeBSD tclsh is a silly script, look for tclsh8.[5420]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001751 AC_MSG_CHECKING(--with-tclsh argument)
1752 AC_ARG_WITH(tclsh, [ --with-tclsh=PATH which tclsh to use (default: tclsh8.0)],
1753 tclsh_name="$withval"; AC_MSG_RESULT($tclsh_name),
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001754 tclsh_name="tclsh8.5"; AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00001755 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1756 AC_SUBST(vi_cv_path_tcl)
1757
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001758 dnl when no specific version specified, also try 8.4, 8.2 and 8.0
1759 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.5"; then
1760 tclsh_name="tclsh8.4"
1761 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1762 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001763 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.4"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001764 tclsh_name="tclsh8.2"
1765 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1766 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001767 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.2"; then
1768 tclsh_name="tclsh8.0"
1769 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1770 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001771 dnl still didn't find it, try without version number
1772 if test "X$vi_cv_path_tcl" = "X"; then
1773 tclsh_name="tclsh"
1774 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1775 fi
1776 if test "X$vi_cv_path_tcl" != "X"; then
1777 AC_MSG_CHECKING(Tcl version)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001778 if echo 'exit [[expr [info tclversion] < 8.0]]' | "$vi_cv_path_tcl" - ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001779 tclver=`echo 'puts [[info tclversion]]' | $vi_cv_path_tcl -`
1780 AC_MSG_RESULT($tclver - OK);
1781 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 +01001782 tcldll=`echo 'puts libtcl[[info tclversion]][[info sharedlibextension]]' | $vi_cv_path_tcl -`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001783
1784 AC_MSG_CHECKING(for location of Tcl include)
Bram Moolenaard0573012017-10-28 21:11:06 +02001785 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001786 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 +00001787 else
1788 dnl For Mac OS X 10.3, use the OS-provided framework location
1789 tclinc="/System/Library/Frameworks/Tcl.framework/Headers"
1790 fi
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001791 TCL_INC=
Bram Moolenaar071d4272004-06-13 20:20:40 +00001792 for try in $tclinc; do
1793 if test -f "$try/tcl.h"; then
1794 AC_MSG_RESULT($try/tcl.h)
1795 TCL_INC=$try
1796 break
1797 fi
1798 done
1799 if test -z "$TCL_INC"; then
1800 AC_MSG_RESULT(<not found>)
1801 SKIP_TCL=YES
1802 fi
1803 if test -z "$SKIP_TCL"; then
1804 AC_MSG_CHECKING(for location of tclConfig.sh script)
Bram Moolenaard0573012017-10-28 21:11:06 +02001805 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001806 tclcnf=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001807 tclcnf="$tclcnf `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001808 else
1809 dnl For Mac OS X 10.3, use the OS-provided framework location
1810 tclcnf="/System/Library/Frameworks/Tcl.framework"
1811 fi
1812 for try in $tclcnf; do
Bram Moolenaar49222be2015-12-11 18:11:30 +01001813 if test -f "$try/tclConfig.sh"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001814 AC_MSG_RESULT($try/tclConfig.sh)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001815 . "$try/tclConfig.sh"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001816 dnl use eval, because tcl 8.2 includes ${TCL_DBGX}
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001817 if test "$enable_tclinterp" = "dynamic"; then
1818 TCL_LIBS=`eval echo "$TCL_STUB_LIB_SPEC $TCL_LIBS"`
1819 else
1820 TCL_LIBS=`eval echo "$TCL_LIB_SPEC $TCL_LIBS"`
1821 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001822 dnl Use $TCL_DEFS for -D_THREAD_SAFE et al. But only use the
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001823 dnl "-D_ABC" items. Watch out for -DFOO=long\ long.
Bram Moolenaar4394bff2008-07-24 11:21:31 +00001824 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 +00001825 break
1826 fi
1827 done
1828 if test -z "$TCL_LIBS"; then
1829 AC_MSG_RESULT(<not found>)
1830 AC_MSG_CHECKING(for Tcl library by myself)
1831 tcllib=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001832 tcllib="$tcllib `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001833 for ext in .so .a ; do
1834 for ver in "" $tclver ; do
1835 for try in $tcllib ; do
1836 trylib=tcl$ver$ext
Bram Moolenaar49222be2015-12-11 18:11:30 +01001837 if test -f "$try/lib$trylib" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001838 AC_MSG_RESULT($try/lib$trylib)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001839 TCL_LIBS="-L\"$try\" -ltcl$ver -ldl -lm"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001840 if test "`(uname) 2>/dev/null`" = SunOS &&
1841 uname -r | grep '^5' >/dev/null; then
1842 TCL_LIBS="$TCL_LIBS -R $try"
1843 fi
1844 break 3
1845 fi
1846 done
1847 done
1848 done
1849 if test -z "$TCL_LIBS"; then
1850 AC_MSG_RESULT(<not found>)
1851 SKIP_TCL=YES
1852 fi
1853 fi
1854 if test -z "$SKIP_TCL"; then
1855 AC_DEFINE(FEAT_TCL)
1856 TCL_SRC=if_tcl.c
1857 TCL_OBJ=objects/if_tcl.o
1858 TCL_PRO=if_tcl.pro
1859 TCL_CFLAGS="-I$TCL_INC $TCL_DEFS"
1860 fi
1861 fi
1862 else
1863 AC_MSG_RESULT(too old; need Tcl version 8.0 or later)
1864 fi
1865 fi
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001866 if test "$enable_tclinterp" = "dynamic"; then
1867 if test "X$TCL_SRC" != "X" -a "X$tcldll" != "X"; then
1868 AC_DEFINE(DYNAMIC_TCL)
1869 TCL_CFLAGS="-DDYNAMIC_TCL_DLL=\\\"$tcldll\\\" -DDYNAMIC_TCL_VER=\\\"$tclver\\\" $TCL_CFLAGS"
1870 fi
1871 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001872 if test "$fail_if_missing" = "yes" -a -z "$TCL_SRC"; then
1873 AC_MSG_ERROR([could not configure Tcl])
1874 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001875fi
1876AC_SUBST(TCL_SRC)
1877AC_SUBST(TCL_OBJ)
1878AC_SUBST(TCL_PRO)
1879AC_SUBST(TCL_CFLAGS)
1880AC_SUBST(TCL_LIBS)
1881
1882AC_MSG_CHECKING(--enable-rubyinterp argument)
1883AC_ARG_ENABLE(rubyinterp,
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001884 [ --enable-rubyinterp[=OPTS] Include Ruby interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001885 [enable_rubyinterp="no"])
1886AC_MSG_RESULT($enable_rubyinterp)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001887if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001888 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1889 AC_MSG_ERROR([cannot use Ruby with tiny or small features])
1890 fi
1891
Bram Moolenaar165641d2010-02-17 16:23:09 +01001892 AC_MSG_CHECKING(--with-ruby-command argument)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001893 AC_SUBST(vi_cv_path_ruby)
Bram Moolenaar948733a2011-05-05 18:10:16 +02001894 AC_ARG_WITH(ruby-command, [ --with-ruby-command=RUBY name of the Ruby command (default: ruby)],
1895 RUBY_CMD="$withval"; vi_cv_path_ruby="$withval"; AC_MSG_RESULT($RUBY_CMD),
1896 RUBY_CMD="ruby"; AC_MSG_RESULT(defaulting to $RUBY_CMD))
Bram Moolenaar165641d2010-02-17 16:23:09 +01001897 AC_PATH_PROG(vi_cv_path_ruby, $RUBY_CMD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001898 if test "X$vi_cv_path_ruby" != "X"; then
1899 AC_MSG_CHECKING(Ruby version)
Bram Moolenaare4efc3b2005-03-07 23:16:51 +00001900 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 +00001901 AC_MSG_RESULT(OK)
Bram Moolenaar81398892012-10-03 21:09:35 +02001902 AC_MSG_CHECKING(Ruby rbconfig)
1903 ruby_rbconfig="RbConfig"
1904 if ! $vi_cv_path_ruby -r rbconfig -e 'RbConfig' >/dev/null 2>/dev/null; then
1905 ruby_rbconfig="Config"
1906 fi
1907 AC_MSG_RESULT($ruby_rbconfig)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001908 AC_MSG_CHECKING(Ruby header files)
Bram Moolenaar81398892012-10-03 21:09:35 +02001909 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 +00001910 if test "X$rubyhdrdir" != "X"; then
1911 AC_MSG_RESULT($rubyhdrdir)
1912 RUBY_CFLAGS="-I$rubyhdrdir"
Bram Moolenaara6fd37b2014-03-27 17:19:09 +01001913 rubyarchdir=`$vi_cv_path_ruby -r rbconfig -e "print ($ruby_rbconfig::CONFIG.has_key? 'rubyarchhdrdir') ? $ruby_rbconfig::CONFIG[['rubyarchhdrdir']] : '$rubyhdrdir/'+$ruby_rbconfig::CONFIG[['arch']]"`
1914 if test -d "$rubyarchdir"; then
1915 RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyarchdir"
Bram Moolenaar165641d2010-02-17 16:23:09 +01001916 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001917 rubyversion=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['ruby_version']].gsub(/\./, '')[[0,2]]"`
Bram Moolenaar026a4452013-08-07 15:22:23 +02001918 if test "X$rubyversion" = "X"; then
1919 rubyversion=`$vi_cv_path_ruby -e "print ((VERSION rescue RUBY_VERSION)).gsub(/\./, '')[[0,2]]"`
1920 fi
Bram Moolenaar165641d2010-02-17 16:23:09 +01001921 RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
Bram Moolenaar81398892012-10-03 21:09:35 +02001922 rubylibs=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LIBS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001923 if test "X$rubylibs" != "X"; then
1924 RUBY_LIBS="$rubylibs"
1925 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001926 librubyarg=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBYARG']])"`
1927 librubya=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBY_A']])"`
Bram Moolenaarac499e32013-06-02 19:14:17 +02001928 rubylibdir=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['libdir']])"`
Bram Moolenaar948733a2011-05-05 18:10:16 +02001929 if test -f "$rubylibdir/$librubya"; then
1930 librubyarg="$librubyarg"
Bram Moolenaarac499e32013-06-02 19:14:17 +02001931 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
1932 elif test "$librubyarg" = "libruby.a"; then
1933 dnl required on Mac OS 10.3 where libruby.a doesn't exist
1934 librubyarg="-lruby"
1935 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001936 fi
1937
1938 if test "X$librubyarg" != "X"; then
1939 RUBY_LIBS="$librubyarg $RUBY_LIBS"
1940 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001941 rubyldflags=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LDFLAGS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001942 if test "X$rubyldflags" != "X"; then
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001943 dnl Ruby on Mac OS X 10.5 adds "-arch" flags but these should only
1944 dnl be included if requested by passing --with-mac-arch to
1945 dnl configure, so strip these flags first (if present)
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001946 rubyldflags=`echo "$rubyldflags" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001947 if test "X$rubyldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001948 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$rubyldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001949 LDFLAGS="$rubyldflags $LDFLAGS"
1950 fi
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001951 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001952 fi
1953 RUBY_SRC="if_ruby.c"
1954 RUBY_OBJ="objects/if_ruby.o"
1955 RUBY_PRO="if_ruby.pro"
1956 AC_DEFINE(FEAT_RUBY)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001957 if test "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar92021622017-10-12 12:33:43 +02001958 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_ALIASES']].split[[0]]"`
Bram Moolenaar87ea64c2018-08-04 15:13:34 +02001959 if test -z "$libruby_soname"; then
1960 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_SO']]"`
1961 fi
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001962 AC_DEFINE(DYNAMIC_RUBY)
Bram Moolenaar92021622017-10-12 12:33:43 +02001963 RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby_soname\\\" -DDYNAMIC_RUBY_VER=$rubyversion $RUBY_CFLAGS"
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001964 RUBY_LIBS=
1965 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001966 else
Bram Moolenaar165641d2010-02-17 16:23:09 +01001967 AC_MSG_RESULT(not found; disabling Ruby)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001968 fi
1969 else
1970 AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
1971 fi
1972 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001973
1974 if test "$fail_if_missing" = "yes" -a -z "$RUBY_OBJ"; then
1975 AC_MSG_ERROR([could not configure Ruby])
1976 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001977fi
1978AC_SUBST(RUBY_SRC)
1979AC_SUBST(RUBY_OBJ)
1980AC_SUBST(RUBY_PRO)
1981AC_SUBST(RUBY_CFLAGS)
1982AC_SUBST(RUBY_LIBS)
1983
1984AC_MSG_CHECKING(--enable-cscope argument)
1985AC_ARG_ENABLE(cscope,
1986 [ --enable-cscope Include cscope interface.], ,
1987 [enable_cscope="no"])
1988AC_MSG_RESULT($enable_cscope)
1989if test "$enable_cscope" = "yes"; then
1990 AC_DEFINE(FEAT_CSCOPE)
1991fi
1992
1993AC_MSG_CHECKING(--enable-workshop argument)
1994AC_ARG_ENABLE(workshop,
1995 [ --enable-workshop Include Sun Visual Workshop support.], ,
1996 [enable_workshop="no"])
1997AC_MSG_RESULT($enable_workshop)
1998if test "$enable_workshop" = "yes"; then
1999 AC_DEFINE(FEAT_SUN_WORKSHOP)
2000 WORKSHOP_SRC="workshop.c integration.c"
2001 AC_SUBST(WORKSHOP_SRC)
2002 WORKSHOP_OBJ="objects/workshop.o objects/integration.o"
2003 AC_SUBST(WORKSHOP_OBJ)
2004 if test "${enable_gui-xxx}" = xxx; then
2005 enable_gui=motif
2006 fi
2007fi
2008
2009AC_MSG_CHECKING(--disable-netbeans argument)
2010AC_ARG_ENABLE(netbeans,
2011 [ --disable-netbeans Disable NetBeans integration support.],
2012 , [enable_netbeans="yes"])
2013if test "$enable_netbeans" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002014 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2015 AC_MSG_RESULT([cannot use NetBeans with tiny or small features])
2016 enable_netbeans="no"
2017 else
2018 AC_MSG_RESULT(no)
2019 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002020else
2021 AC_MSG_RESULT(yes)
2022fi
2023
2024AC_MSG_CHECKING(--disable-channel argument)
2025AC_ARG_ENABLE(channel,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002026 [ --disable-channel Disable process communication support.],
Bram Moolenaare0874f82016-01-24 20:36:41 +01002027 , [enable_channel="yes"])
2028if test "$enable_channel" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002029 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2030 AC_MSG_RESULT([cannot use channels with tiny or small features])
2031 enable_channel="no"
2032 else
2033 AC_MSG_RESULT(no)
2034 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002035else
2036 if test "$enable_netbeans" = "yes"; then
Bram Moolenaar16435482016-01-24 21:31:54 +01002037 AC_MSG_RESULT([yes, netbeans also disabled])
Bram Moolenaare0874f82016-01-24 20:36:41 +01002038 enable_netbeans="no"
2039 else
2040 AC_MSG_RESULT(yes)
2041 fi
2042fi
2043
Bram Moolenaar16435482016-01-24 21:31:54 +01002044if test "$enable_channel" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002045 dnl On Solaris we need the socket and nsl library.
2046 AC_CHECK_LIB(socket, socket)
2047 AC_CHECK_LIB(nsl, gethostbyname)
Bram Moolenaare0874f82016-01-24 20:36:41 +01002048 AC_MSG_CHECKING(whether compiling with process communication is possible)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002049 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;
Bram Moolenaar63de19e2016-12-09 20:11:26 +01002062 unsigned short signmaplen;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002063 };
2064 ], [
2065 /* Check creating a socket. */
2066 struct sockaddr_in server;
2067 (void)socket(AF_INET, SOCK_STREAM, 0);
2068 (void)htons(100);
2069 (void)gethostbyname("microsoft.com");
2070 if (errno == ECONNREFUSED)
2071 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
2072 ],
2073 AC_MSG_RESULT(yes),
Bram Moolenaare0874f82016-01-24 20:36:41 +01002074 AC_MSG_RESULT(no); enable_netbeans="no"; enable_channel="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00002075fi
2076if test "$enable_netbeans" = "yes"; then
2077 AC_DEFINE(FEAT_NETBEANS_INTG)
2078 NETBEANS_SRC="netbeans.c"
2079 AC_SUBST(NETBEANS_SRC)
2080 NETBEANS_OBJ="objects/netbeans.o"
2081 AC_SUBST(NETBEANS_OBJ)
2082fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002083if test "$enable_channel" = "yes"; then
Bram Moolenaar509ce2a2016-03-11 22:52:15 +01002084 AC_DEFINE(FEAT_JOB_CHANNEL)
Bram Moolenaare0874f82016-01-24 20:36:41 +01002085 CHANNEL_SRC="channel.c"
2086 AC_SUBST(CHANNEL_SRC)
2087 CHANNEL_OBJ="objects/channel.o"
2088 AC_SUBST(CHANNEL_OBJ)
2089fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002090
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002091AC_MSG_CHECKING(--enable-terminal argument)
2092AC_ARG_ENABLE(terminal,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002093 [ --enable-terminal Enable terminal emulation support.],
Bram Moolenaaref839562017-10-28 20:28:23 +02002094 , [enable_terminal="auto"])
Bram Moolenaar595a4022017-09-03 19:15:57 +02002095if test "$enable_terminal" = "yes" || test "$enable_terminal" = "auto" -a "x$features" = "xhuge" ; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002096 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2097 AC_MSG_RESULT([cannot use terminal emulator with tiny or small features])
2098 enable_terminal="no"
2099 else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002100 if test "$enable_terminal" = "auto"; then
2101 enable_terminal="yes"
2102 AC_MSG_RESULT(defaulting to yes)
2103 else
2104 AC_MSG_RESULT(yes)
2105 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002106 fi
2107else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002108 if test "$enable_terminal" = "auto"; then
2109 enable_terminal="no"
2110 AC_MSG_RESULT(defaulting to no)
2111 else
2112 AC_MSG_RESULT(no)
2113 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002114fi
Bram Moolenaar8b423282017-12-16 14:37:06 +01002115if test "$enable_terminal" = "yes" -a "$enable_channel" = "yes"; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002116 AC_DEFINE(FEAT_TERMINAL)
Bram Moolenaar78dcd4f2018-09-13 17:23:28 +02002117 TERM_SRC="libvterm/src/encoding.c libvterm/src/keyboard.c libvterm/src/mouse.c libvterm/src/parser.c libvterm/src/pen.c libvterm/src/termscreen.c libvterm/src/state.c libvterm/src/unicode.c libvterm/src/vterm.c"
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002118 AC_SUBST(TERM_SRC)
Bram Moolenaar78dcd4f2018-09-13 17:23:28 +02002119 TERM_OBJ="objects/encoding.o objects/keyboard.o objects/mouse.o objects/parser.o objects/pen.o objects/termscreen.o objects/state.o objects/unicode.o objects/vterm.o"
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002120 AC_SUBST(TERM_OBJ)
2121fi
2122
Bram Moolenaare42a6d22017-11-12 19:21:51 +01002123AC_MSG_CHECKING(--enable-autoservername argument)
2124AC_ARG_ENABLE(autoservername,
2125 [ --enable-autoservername Automatically define servername at vim startup.], ,
2126 [enable_autoservername="no"])
2127AC_MSG_RESULT($enable_autoservername)
2128if test "$enable_autoservername" = "yes"; then
2129 AC_DEFINE(FEAT_AUTOSERVERNAME)
2130fi
2131
Bram Moolenaar071d4272004-06-13 20:20:40 +00002132AC_MSG_CHECKING(--enable-multibyte argument)
2133AC_ARG_ENABLE(multibyte,
2134 [ --enable-multibyte Include multibyte editing support.], ,
2135 [enable_multibyte="no"])
2136AC_MSG_RESULT($enable_multibyte)
2137if test "$enable_multibyte" = "yes"; then
2138 AC_DEFINE(FEAT_MBYTE)
2139fi
2140
2141AC_MSG_CHECKING(--enable-hangulinput argument)
2142AC_ARG_ENABLE(hangulinput,
2143 [ --enable-hangulinput Include Hangul input support.], ,
2144 [enable_hangulinput="no"])
2145AC_MSG_RESULT($enable_hangulinput)
2146
2147AC_MSG_CHECKING(--enable-xim argument)
2148AC_ARG_ENABLE(xim,
2149 [ --enable-xim Include XIM input support.],
2150 AC_MSG_RESULT($enable_xim),
2151 [enable_xim="auto"; AC_MSG_RESULT(defaulting to auto)])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002152
2153AC_MSG_CHECKING(--enable-fontset argument)
2154AC_ARG_ENABLE(fontset,
2155 [ --enable-fontset Include X fontset output support.], ,
2156 [enable_fontset="no"])
2157AC_MSG_RESULT($enable_fontset)
2158dnl defining FEAT_XFONTSET is delayed, so that it can be disabled for no GUI
2159
2160test -z "$with_x" && with_x=yes
Bram Moolenaard0573012017-10-28 21:11:06 +02002161test "${enable_gui-yes}" != no -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && with_x=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002162if test "$with_x" = no; then
2163 AC_MSG_RESULT(defaulting to: don't HAVE_X11)
2164else
2165 dnl Do this check early, so that its failure can override user requests.
2166
2167 AC_PATH_PROG(xmkmfpath, xmkmf)
2168
2169 AC_PATH_XTRA
2170
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002171 dnl On z/OS Unix the X libraries are DLLs. To use them the code must
Bram Moolenaar071d4272004-06-13 20:20:40 +00002172 dnl be compiled with a special option.
2173 dnl Also add SM, ICE and Xmu to X_EXTRA_LIBS.
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002174 if test "$zOSUnix" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002175 CFLAGS="$CFLAGS -W c,dll"
2176 LDFLAGS="$LDFLAGS -W l,dll"
2177 X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE -lXmu"
2178 fi
2179
2180 dnl On my HPUX system the X include dir is found, but the lib dir not.
2181 dnl This is a desparate try to fix this.
2182
2183 if test -d "$x_includes" && test ! -d "$x_libraries"; then
2184 x_libraries=`echo "$x_includes" | sed s/include/lib/`
2185 AC_MSG_RESULT(Corrected X libraries to $x_libraries)
2186 X_LIBS="$X_LIBS -L$x_libraries"
2187 if test "`(uname) 2>/dev/null`" = SunOS &&
2188 uname -r | grep '^5' >/dev/null; then
2189 X_LIBS="$X_LIBS -R $x_libraries"
2190 fi
2191 fi
2192
2193 if test -d "$x_libraries" && test ! -d "$x_includes"; then
2194 x_includes=`echo "$x_libraries" | sed s/lib/include/`
2195 AC_MSG_RESULT(Corrected X includes to $x_includes)
2196 X_CFLAGS="$X_CFLAGS -I$x_includes"
2197 fi
2198
2199 dnl Remove "-I/usr/include " from X_CFLAGS, should not be needed.
2200 X_CFLAGS="`echo $X_CFLAGS\ | sed 's%-I/usr/include %%'`"
2201 dnl Remove "-L/usr/lib " from X_LIBS, should not be needed.
2202 X_LIBS="`echo $X_LIBS\ | sed 's%-L/usr/lib %%'`"
2203 dnl Same for "-R/usr/lib ".
2204 X_LIBS="`echo $X_LIBS\ | sed -e 's%-R/usr/lib %%' -e 's%-R /usr/lib %%'`"
2205
2206
2207 dnl Check if the X11 header files are correctly installed. On some systems
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002208 dnl Xlib.h includes files that don't exist. On some systems X11/Intrinsic.h
2209 dnl is missing.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002210 AC_MSG_CHECKING(if X11 header files can be found)
2211 cflags_save=$CFLAGS
2212 CFLAGS="$CFLAGS $X_CFLAGS"
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002213 AC_TRY_COMPILE([#include <X11/Xlib.h>
2214#include <X11/Intrinsic.h>], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002215 AC_MSG_RESULT(yes),
2216 AC_MSG_RESULT(no); no_x=yes)
2217 CFLAGS=$cflags_save
2218
2219 if test "${no_x-no}" = yes; then
2220 with_x=no
2221 else
2222 AC_DEFINE(HAVE_X11)
2223 X_LIB="-lXt -lX11";
2224 AC_SUBST(X_LIB)
2225
2226 ac_save_LDFLAGS="$LDFLAGS"
2227 LDFLAGS="-L$x_libraries $LDFLAGS"
2228
2229 dnl Check for -lXdmcp (needed on SunOS 4.1.4)
2230 dnl For HP-UX 10.20 it must be before -lSM -lICE
2231 AC_CHECK_LIB(Xdmcp, _XdmcpAuthDoIt, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lXdmcp"],,
2232 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXdmcp])
2233
2234 dnl Some systems need -lnsl -lsocket when testing for ICE.
2235 dnl The check above doesn't do this, try here (again). Also needed to get
2236 dnl them after Xdmcp. link.sh will remove them when not needed.
2237 dnl Check for other function than above to avoid the cached value
2238 AC_CHECK_LIB(ICE, IceOpenConnection,
2239 [X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE"],, [$X_EXTRA_LIBS])
2240
2241 dnl Check for -lXpm (needed for some versions of Motif)
2242 LDFLAGS="$X_LIBS $ac_save_LDFLAGS"
2243 AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [X_PRE_LIBS="$X_PRE_LIBS -lXpm"],,
2244 [-lXt $X_PRE_LIBS -lXpm -lX11 $X_EXTRA_LIBS])
2245
2246 dnl Check that the X11 header files don't use implicit declarations
2247 AC_MSG_CHECKING(if X11 header files implicitly declare return values)
2248 cflags_save=$CFLAGS
Bram Moolenaard1864592013-05-04 04:40:15 +02002249 dnl -Werror is GCC only, others like Solaris Studio might not like it
2250 if test "$GCC" = yes; then
2251 CFLAGS="$CFLAGS $X_CFLAGS -Werror"
2252 else
2253 CFLAGS="$CFLAGS $X_CFLAGS"
2254 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002255 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2256 AC_MSG_RESULT(no),
2257 CFLAGS="$CFLAGS -Wno-implicit-int"
2258 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2259 AC_MSG_RESULT(yes); cflags_save="$cflags_save -Wno-implicit-int",
2260 AC_MSG_RESULT(test failed)
2261 )
2262 )
2263 CFLAGS=$cflags_save
2264
2265 LDFLAGS="$ac_save_LDFLAGS"
2266
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002267 AC_MSG_CHECKING(size of wchar_t is 2 bytes)
2268 AC_CACHE_VAL(ac_cv_small_wchar_t,
2269 [AC_TRY_RUN([
2270#include <X11/Xlib.h>
2271#if STDC_HEADERS
2272# include <stdlib.h>
2273# include <stddef.h>
2274#endif
2275 main()
2276 {
2277 if (sizeof(wchar_t) <= 2)
2278 exit(1);
2279 exit(0);
2280 }],
2281 ac_cv_small_wchar_t="no",
2282 ac_cv_small_wchar_t="yes",
2283 AC_MSG_ERROR(failed to compile test program))])
2284 AC_MSG_RESULT($ac_cv_small_wchar_t)
2285 if test "x$ac_cv_small_wchar_t" = "xyes" ; then
2286 AC_DEFINE(SMALL_WCHAR_T)
2287 fi
2288
Bram Moolenaar071d4272004-06-13 20:20:40 +00002289 fi
2290fi
2291
Bram Moolenaard2a05492018-07-27 22:35:15 +02002292dnl Check if --with-x was given but it doesn't work.
2293if test "x$with_x" = xno -a "x$with_x_arg" = xyes; then
2294 AC_MSG_ERROR([could not configure X])
2295fi
2296
Bram Moolenaard0573012017-10-28 21:11:06 +02002297test "x$with_x" = xno -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && enable_gui=no
Bram Moolenaar071d4272004-06-13 20:20:40 +00002298
2299AC_MSG_CHECKING(--enable-gui argument)
2300AC_ARG_ENABLE(gui,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002301 [ --enable-gui[=OPTS] X11 GUI. [default=auto] [OPTS=auto/no/gtk2/gnome2/gtk3/motif/athena/neXtaw/photon/carbon]], , enable_gui="auto")
Bram Moolenaar071d4272004-06-13 20:20:40 +00002302
2303dnl Canonicalize the --enable-gui= argument so that it can be easily compared.
2304dnl Do not use character classes for portability with old tools.
2305enable_gui_canon=`echo "_$enable_gui" | \
2306 sed 's/[[ _+-]]//g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
2307
2308dnl Skip everything by default.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002309SKIP_GTK2=YES
Bram Moolenaar1858a842016-02-23 22:30:31 +01002310SKIP_GTK3=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002311SKIP_GNOME=YES
2312SKIP_MOTIF=YES
2313SKIP_ATHENA=YES
2314SKIP_NEXTAW=YES
2315SKIP_PHOTON=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002316SKIP_CARBON=YES
2317GUITYPE=NONE
2318
Bram Moolenaarb11160e2005-01-04 21:31:43 +00002319if test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002320 SKIP_PHOTON=
2321 case "$enable_gui_canon" in
2322 no) AC_MSG_RESULT(no GUI support)
2323 SKIP_PHOTON=YES ;;
2324 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
2325 auto) AC_MSG_RESULT(auto - automatic GUI support) ;;
2326 photon) AC_MSG_RESULT(Photon GUI support) ;;
2327 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2328 SKIP_PHOTON=YES ;;
2329 esac
2330
Bram Moolenaard0573012017-10-28 21:11:06 +02002331elif test "x$MACOS_X" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002332 SKIP_CARBON=
2333 case "$enable_gui_canon" in
2334 no) AC_MSG_RESULT(no GUI support)
2335 SKIP_CARBON=YES ;;
2336 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
Bram Moolenaar164fca32010-07-14 13:58:07 +02002337 auto) AC_MSG_RESULT(auto - Carbon GUI is outdated - disable GUI support)
2338 SKIP_CARBON=YES ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002339 carbon) AC_MSG_RESULT(Carbon GUI support) ;;
2340 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2341 SKIP_CARBON=YES ;;
2342 esac
2343
2344else
2345
Bram Moolenaar071d4272004-06-13 20:20:40 +00002346 case "$enable_gui_canon" in
2347 no|none) AC_MSG_RESULT(no GUI support) ;;
2348 yes|""|auto) AC_MSG_RESULT(yes/auto - automatic GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002349 SKIP_GTK2=
2350 SKIP_GNOME=
2351 SKIP_MOTIF=
2352 SKIP_ATHENA=
2353 SKIP_NEXTAW=
2354 SKIP_CARBON=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002355 gtk2) AC_MSG_RESULT(GTK+ 2.x GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002356 SKIP_GTK2=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002357 gnome2) AC_MSG_RESULT(GNOME 2.x GUI support)
2358 SKIP_GNOME=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002359 SKIP_GTK2=;;
Bram Moolenaar98921892016-02-23 17:14:37 +01002360 gtk3) AC_MSG_RESULT(GTK+ 3.x GUI support)
2361 SKIP_GTK3=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002362 motif) AC_MSG_RESULT(Motif GUI support)
2363 SKIP_MOTIF=;;
2364 athena) AC_MSG_RESULT(Athena GUI support)
2365 SKIP_ATHENA=;;
2366 nextaw) AC_MSG_RESULT(neXtaw GUI support)
2367 SKIP_NEXTAW=;;
2368 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
2369 esac
2370
2371fi
2372
Bram Moolenaar071d4272004-06-13 20:20:40 +00002373if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \
2374 -a "$enable_gui_canon" != "gnome2"; then
2375 AC_MSG_CHECKING(whether or not to look for GTK+ 2)
2376 AC_ARG_ENABLE(gtk2-check,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002377 [ --enable-gtk2-check If auto-select GUI, check for GTK+ 2 [default=yes]],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002378 , enable_gtk2_check="yes")
2379 AC_MSG_RESULT($enable_gtk2_check)
2380 if test "x$enable_gtk2_check" = "xno"; then
2381 SKIP_GTK2=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002382 SKIP_GNOME=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002383 fi
2384fi
2385
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002386if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002387 AC_MSG_CHECKING(whether or not to look for GNOME)
2388 AC_ARG_ENABLE(gnome-check,
2389 [ --enable-gnome-check If GTK GUI, check for GNOME [default=no]],
2390 , enable_gnome_check="no")
2391 AC_MSG_RESULT($enable_gnome_check)
2392 if test "x$enable_gnome_check" = "xno"; then
2393 SKIP_GNOME=YES
2394 fi
2395fi
2396
Bram Moolenaar98921892016-02-23 17:14:37 +01002397if test "x$SKIP_GTK3" != "xYES" -a "$enable_gui_canon" != "gtk3"; then
2398 AC_MSG_CHECKING(whether or not to look for GTK+ 3)
2399 AC_ARG_ENABLE(gtk3-check,
2400 [ --enable-gtk3-check If auto-select GUI, check for GTK+ 3 [default=yes]],
2401 , enable_gtk3_check="yes")
2402 AC_MSG_RESULT($enable_gtk3_check)
2403 if test "x$enable_gtk3_check" = "xno"; then
2404 SKIP_GTK3=YES
2405 fi
2406fi
2407
Bram Moolenaar071d4272004-06-13 20:20:40 +00002408if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then
2409 AC_MSG_CHECKING(whether or not to look for Motif)
2410 AC_ARG_ENABLE(motif-check,
2411 [ --enable-motif-check If auto-select GUI, check for Motif [default=yes]],
2412 , enable_motif_check="yes")
2413 AC_MSG_RESULT($enable_motif_check)
2414 if test "x$enable_motif_check" = "xno"; then
2415 SKIP_MOTIF=YES
2416 fi
2417fi
2418
2419if test "x$SKIP_ATHENA" != "xYES" -a "$enable_gui_canon" != "athena"; then
2420 AC_MSG_CHECKING(whether or not to look for Athena)
2421 AC_ARG_ENABLE(athena-check,
2422 [ --enable-athena-check If auto-select GUI, check for Athena [default=yes]],
2423 , enable_athena_check="yes")
2424 AC_MSG_RESULT($enable_athena_check)
2425 if test "x$enable_athena_check" = "xno"; then
2426 SKIP_ATHENA=YES
2427 fi
2428fi
2429
2430if test "x$SKIP_NEXTAW" != "xYES" -a "$enable_gui_canon" != "nextaw"; then
2431 AC_MSG_CHECKING(whether or not to look for neXtaw)
2432 AC_ARG_ENABLE(nextaw-check,
2433 [ --enable-nextaw-check If auto-select GUI, check for neXtaw [default=yes]],
2434 , enable_nextaw_check="yes")
2435 AC_MSG_RESULT($enable_nextaw_check);
2436 if test "x$enable_nextaw_check" = "xno"; then
2437 SKIP_NEXTAW=YES
2438 fi
2439fi
2440
2441if test "x$SKIP_CARBON" != "xYES" -a "$enable_gui_canon" != "carbon"; then
2442 AC_MSG_CHECKING(whether or not to look for Carbon)
2443 AC_ARG_ENABLE(carbon-check,
2444 [ --enable-carbon-check If auto-select GUI, check for Carbon [default=yes]],
2445 , enable_carbon_check="yes")
2446 AC_MSG_RESULT($enable_carbon_check);
2447 if test "x$enable_carbon_check" = "xno"; then
2448 SKIP_CARBON=YES
2449 fi
2450fi
2451
Bram Moolenaar843ee412004-06-30 16:16:41 +00002452
Bram Moolenaard0573012017-10-28 21:11:06 +02002453if test "x$MACOS_X" = "xyes" -a -z "$SKIP_CARBON" -a "x$CARBON" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002454 AC_MSG_CHECKING(for Carbon GUI)
Bram Moolenaar14716812006-05-04 21:54:08 +00002455 dnl already did the check, just give the message
Bram Moolenaar071d4272004-06-13 20:20:40 +00002456 AC_MSG_RESULT(yes);
2457 GUITYPE=CARBONGUI
Bram Moolenaare344bea2005-09-01 20:46:49 +00002458 if test "$VIMNAME" = "vim"; then
2459 VIMNAME=Vim
2460 fi
Bram Moolenaar14716812006-05-04 21:54:08 +00002461
Bram Moolenaar164fca32010-07-14 13:58:07 +02002462 if test "x$MACARCH" = "xboth"; then
2463 CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk/Developer/Headers/FlatCarbon"
2464 else
2465 CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/Headers/FlatCarbon"
2466 fi
2467
Bram Moolenaar14716812006-05-04 21:54:08 +00002468 dnl Default install directory is not /usr/local
2469 if test x$prefix = xNONE; then
2470 prefix=/Applications
2471 fi
2472
2473 dnl Sorry for the hard coded default
2474 datadir='${prefix}/Vim.app/Contents/Resources'
2475
Bram Moolenaar071d4272004-06-13 20:20:40 +00002476 dnl skip everything else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002477 SKIP_GTK2=YES;
2478 SKIP_GNOME=YES;
2479 SKIP_MOTIF=YES;
2480 SKIP_ATHENA=YES;
2481 SKIP_NEXTAW=YES;
2482 SKIP_PHOTON=YES;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002483 SKIP_CARBON=YES
2484fi
2485
Bram Moolenaar071d4272004-06-13 20:20:40 +00002486dnl define an autoconf function to check for a specified version of GTK, and
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002487dnl try to compile/link a GTK program.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002488dnl
2489dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002490dnl Test for GTK, and define GTK_CFLAGS, GTK_LIBDIR and GTK_LIBS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002491dnl
2492AC_DEFUN(AM_PATH_GTK,
2493[
2494 if test "X$GTK_CONFIG" != "Xno" -o "X$PKG_CONFIG" != "Xno"; then
2495 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00002496 no_gtk=""
2497 if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2498 && $PKG_CONFIG --exists gtk+-2.0; then
2499 {
Bram Moolenaar98921892016-02-23 17:14:37 +01002500 min_gtk_version=ifelse([$1], ,2.2.0,$1)
2501 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002502 dnl We should be using PKG_CHECK_MODULES() instead of this hack.
2503 dnl But I guess the dependency on pkgconfig.m4 is not wanted or
2504 dnl something like that.
2505 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0`
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002506 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-2.0`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002507 GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0`
2508 gtk_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2509 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2510 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2511 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2512 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2513 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2514 }
Bram Moolenaar98921892016-02-23 17:14:37 +01002515 elif (test "X$SKIP_GTK3" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2516 && $PKG_CONFIG --exists gtk+-3.0; then
2517 {
2518 min_gtk_version=ifelse([$1], ,3.0.0,$1)
2519 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
2520
2521 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-3.0`
2522 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-3.0`
2523 GTK_LIBS=`$PKG_CONFIG --libs gtk+-3.0`
2524 gtk_major_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2525 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2526 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2527 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2528 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2529 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2530 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002531 else
2532 no_gtk=yes
2533 fi
2534
2535 if test "x$enable_gtktest" = "xyes" -a "x$no_gtk" = "x"; then
2536 {
2537 ac_save_CFLAGS="$CFLAGS"
2538 ac_save_LIBS="$LIBS"
2539 CFLAGS="$CFLAGS $GTK_CFLAGS"
2540 LIBS="$LIBS $GTK_LIBS"
2541
2542 dnl
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002543 dnl Now check if the installed GTK is sufficiently new.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002544 dnl
2545 rm -f conf.gtktest
2546 AC_TRY_RUN([
2547#include <gtk/gtk.h>
2548#include <stdio.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00002549#if STDC_HEADERS
2550# include <stdlib.h>
2551# include <stddef.h>
2552#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002553
2554int
2555main ()
2556{
2557int major, minor, micro;
2558char *tmp_version;
2559
2560system ("touch conf.gtktest");
2561
2562/* HP/UX 9 (%@#!) writes to sscanf strings */
2563tmp_version = g_strdup("$min_gtk_version");
2564if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
2565 printf("%s, bad version string\n", "$min_gtk_version");
2566 exit(1);
2567 }
2568
2569if ((gtk_major_version > major) ||
2570 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
2571 ((gtk_major_version == major) && (gtk_minor_version == minor) &&
2572 (gtk_micro_version >= micro)))
2573{
2574 return 0;
2575}
2576return 1;
2577}
2578],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
2579 CFLAGS="$ac_save_CFLAGS"
2580 LIBS="$ac_save_LIBS"
2581 }
2582 fi
2583 if test "x$no_gtk" = x ; then
2584 if test "x$enable_gtktest" = "xyes"; then
2585 AC_MSG_RESULT(yes; found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2586 else
2587 AC_MSG_RESULT(found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2588 fi
2589 ifelse([$2], , :, [$2])
2590 else
2591 {
2592 AC_MSG_RESULT(no)
2593 GTK_CFLAGS=""
2594 GTK_LIBS=""
2595 ifelse([$3], , :, [$3])
2596 }
2597 fi
2598 }
2599 else
2600 GTK_CFLAGS=""
2601 GTK_LIBS=""
2602 ifelse([$3], , :, [$3])
2603 fi
2604 AC_SUBST(GTK_CFLAGS)
2605 AC_SUBST(GTK_LIBS)
2606 rm -f conf.gtktest
2607])
2608
2609dnl ---------------------------------------------------------------------------
2610dnl gnome
2611dnl ---------------------------------------------------------------------------
2612AC_DEFUN([GNOME_INIT_HOOK],
2613[
2614 AC_SUBST(GNOME_LIBS)
2615 AC_SUBST(GNOME_LIBDIR)
2616 AC_SUBST(GNOME_INCLUDEDIR)
2617
2618 AC_ARG_WITH(gnome-includes,
2619 [ --with-gnome-includes=DIR Specify location of GNOME headers],
2620 [CFLAGS="$CFLAGS -I$withval"]
2621 )
2622
2623 AC_ARG_WITH(gnome-libs,
2624 [ --with-gnome-libs=DIR Specify location of GNOME libs],
2625 [LDFLAGS="$LDFLAGS -L$withval" gnome_prefix=$withval]
2626 )
2627
2628 AC_ARG_WITH(gnome,
2629 [ --with-gnome Specify prefix for GNOME files],
2630 if test x$withval = xyes; then
2631 want_gnome=yes
2632 ifelse([$1], [], :, [$1])
2633 else
2634 if test "x$withval" = xno; then
2635 want_gnome=no
2636 else
2637 want_gnome=yes
2638 LDFLAGS="$LDFLAGS -L$withval/lib"
2639 CFLAGS="$CFLAGS -I$withval/include"
2640 gnome_prefix=$withval/lib
2641 fi
2642 fi,
2643 want_gnome=yes)
2644
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002645 if test "x$want_gnome" = xyes; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002646 {
2647 AC_MSG_CHECKING(for libgnomeui-2.0)
2648 if $PKG_CONFIG --exists libgnomeui-2.0; then
2649 AC_MSG_RESULT(yes)
2650 GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0`
2651 GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0`
2652 GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0`
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002653
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002654 dnl On FreeBSD we need -pthread but pkg-config doesn't include it.
2655 dnl This might not be the right way but it works for me...
2656 AC_MSG_CHECKING(for FreeBSD)
2657 if test "`(uname) 2>/dev/null`" = FreeBSD; then
2658 AC_MSG_RESULT(yes, adding -pthread)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002659 GNOME_INCLUDEDIR="$GNOME_INCLUDEDIR -D_THREAD_SAFE"
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002660 GNOME_LIBS="$GNOME_LIBS -pthread"
2661 else
2662 AC_MSG_RESULT(no)
2663 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002664 $1
2665 else
2666 AC_MSG_RESULT(not found)
2667 if test "x$2" = xfail; then
2668 AC_MSG_ERROR(Could not find libgnomeui-2.0 via pkg-config)
2669 fi
2670 fi
2671 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002672 fi
2673])
2674
2675AC_DEFUN([GNOME_INIT],[
2676 GNOME_INIT_HOOK([],fail)
2677])
2678
2679
2680dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002681dnl Check for GTK2. If it fails, then continue on for Motif as before...
Bram Moolenaar071d4272004-06-13 20:20:40 +00002682dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002683if test -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002684
2685 AC_MSG_CHECKING(--disable-gtktest argument)
2686 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2687 , enable_gtktest=yes)
2688 if test "x$enable_gtktest" = "xyes" ; then
2689 AC_MSG_RESULT(gtk test enabled)
2690 else
2691 AC_MSG_RESULT(gtk test disabled)
2692 fi
2693
Bram Moolenaar071d4272004-06-13 20:20:40 +00002694 if test "X$PKG_CONFIG" = "X"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01002695 AC_PATH_TOOL(PKG_CONFIG, pkg-config, no)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002696 fi
2697
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002698 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002699 dnl First try finding version 2.2.0 or later. The 2.0.x series has
2700 dnl problems (bold fonts, --remote doesn't work).
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002701 AM_PATH_GTK(2.2.0,
2702 [GUI_LIB_LOC="$GTK_LIBDIR"
2703 GTK_LIBNAME="$GTK_LIBS"
2704 GUI_INC_LOC="$GTK_CFLAGS"], )
2705 if test "x$GTK_CFLAGS" != "x"; then
Bram Moolenaar98921892016-02-23 17:14:37 +01002706 SKIP_GTK3=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002707 SKIP_ATHENA=YES
2708 SKIP_NEXTAW=YES
2709 SKIP_MOTIF=YES
2710 GUITYPE=GTK
2711 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002712 fi
2713 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002714 if test "x$GUITYPE" = "xGTK"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002715 dnl
2716 dnl if GTK exists, then check for GNOME.
2717 dnl
2718 if test -z "$SKIP_GNOME"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002719 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002720 GNOME_INIT_HOOK([have_gnome=yes])
2721 if test "x$have_gnome" = xyes ; then
2722 AC_DEFINE(FEAT_GUI_GNOME)
2723 GUI_INC_LOC="$GUI_INC_LOC $GNOME_INCLUDEDIR"
2724 GTK_LIBNAME="$GTK_LIBNAME $GNOME_LIBDIR $GNOME_LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002725 fi
2726 }
2727 fi
2728 fi
2729fi
2730
Bram Moolenaar98921892016-02-23 17:14:37 +01002731
2732dnl ---------------------------------------------------------------------------
2733dnl Check for GTK3.
2734dnl ---------------------------------------------------------------------------
2735if test -z "$SKIP_GTK3"; then
2736
2737 AC_MSG_CHECKING(--disable-gtktest argument)
2738 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2739 , enable_gtktest=yes)
2740 if test "x$enable_gtktest" = "xyes" ; then
2741 AC_MSG_RESULT(gtk test enabled)
2742 else
2743 AC_MSG_RESULT(gtk test disabled)
2744 fi
2745
2746 if test "X$PKG_CONFIG" = "X"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01002747 AC_PATH_TOOL(PKG_CONFIG, pkg-config, no)
Bram Moolenaar98921892016-02-23 17:14:37 +01002748 fi
2749
2750 if test "x$PKG_CONFIG" != "xno"; then
2751 AM_PATH_GTK(3.0.0,
2752 [GUI_LIB_LOC="$GTK_LIBDIR"
2753 GTK_LIBNAME="$GTK_LIBS"
2754 GUI_INC_LOC="$GTK_CFLAGS"], )
2755 if test "x$GTK_CFLAGS" != "x"; then
2756 SKIP_GTK2=YES
2757 SKIP_GNOME=YES
2758 SKIP_ATHENA=YES
2759 SKIP_NEXTAW=YES
2760 SKIP_MOTIF=YES
2761 GUITYPE=GTK
2762 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar98921892016-02-23 17:14:37 +01002763 AC_DEFINE(USE_GTK3)
2764 fi
2765 fi
2766fi
2767
Bram Moolenaard2e03f02016-01-02 22:46:36 +01002768dnl Check the version of Gdk-Pixbuf. If the version is 2.31 or later and
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002769dnl glib-compile-resources is found in PATH, use GResource.
2770if test "x$GUITYPE" = "xGTK"; then
2771 AC_MSG_CHECKING([version of Gdk-Pixbuf])
2772 gdk_pixbuf_version=`$PKG_CONFIG --modversion gdk-pixbuf-2.0`
2773 if test "x$gdk_pixbuf_version" != x ; then
2774 gdk_pixbuf_version_minor=`echo $gdk_pixbuf_version | \
2775 sed -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/'`
2776 if test "x$gdk_pixbuf_version_minor" != x -a \
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002777 $gdk_pixbuf_version_minor -ge 31 ; then
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002778 AC_MSG_RESULT([OK.])
2779 AC_PATH_PROG(GLIB_COMPILE_RESOURCES,[glib-compile-resources],no)
2780 AC_MSG_CHECKING([glib-compile-resources])
2781 if test "x$GLIB_COMPILE_RESOURCES" = xno ; then
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002782 GLIB_COMPILE_RESOURCES=""
2783 AC_MSG_RESULT([cannot be found in PATH.])
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002784 else
2785 AC_MSG_RESULT([usable.])
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002786 AC_DEFINE(USE_GRESOURCE)
2787 GRESOURCE_SRC="auto/gui_gtk_gresources.c"
2788 GRESOURCE_OBJ="objects/gui_gtk_gresources.o"
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002789 fi
2790 else
2791 AC_MSG_RESULT([not usable.])
2792 fi
2793 else
2794 AC_MSG_RESULT([cannot obtain from pkg_config.])
2795 fi
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002796
2797 AC_MSG_CHECKING([--disable-icon-cache-update argument])
2798 AC_ARG_ENABLE(icon_cache_update,
2799 [ --disable-icon-cache-update update disabled],
2800 [],
2801 [enable_icon_cache_update="yes"])
2802 if test "$enable_icon_cache_update" = "yes"; then
2803 AC_MSG_RESULT([not set])
2804 AC_PATH_PROG(GTK_UPDATE_ICON_CACHE,[gtk-update-icon-cache],no)
2805 if test "x$GTK_UPDATE_ICON_CACHE" = "xno" ; then
2806 AC_MSG_RESULT([not found in PATH.])
2807 fi
2808 else
2809 AC_MSG_RESULT([update disabled])
2810 fi
2811
2812 AC_MSG_CHECKING([--disable-desktop-database-update argument])
2813 AC_ARG_ENABLE(desktop_database_update,
2814 [ --disable-desktop-database-update update disabled],
2815 [],
2816 [enable_desktop_database_update="yes"])
2817 if test "$enable_desktop_database_update" = "yes"; then
2818 AC_MSG_RESULT([not set])
2819 AC_PATH_PROG(UPDATE_DESKTOP_DATABASE,[update-desktop-database],no)
2820 if test "x$UPDATE_DESKTOP_DATABASE" = "xno" ; then
2821 AC_MSG_RESULT([not found in PATH.])
2822 fi
2823 else
2824 AC_MSG_RESULT([update disabled])
2825 fi
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002826fi
2827AC_SUBST(GLIB_COMPILE_RESOURCES)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002828AC_SUBST(GRESOURCE_SRC)
2829AC_SUBST(GRESOURCE_OBJ)
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002830AC_SUBST(GTK_UPDATE_ICON_CACHE)
2831AC_SUBST(UPDATE_DESKTOP_DATABASE)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002832
Bram Moolenaar071d4272004-06-13 20:20:40 +00002833dnl Check for Motif include files location.
2834dnl The LAST one found is used, this makes the highest version to be used,
2835dnl e.g. when Motif1.2 and Motif2.0 are both present.
2836
2837if test -z "$SKIP_MOTIF"; then
2838 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"
2839 dnl Remove "-I" from before $GUI_INC_LOC if it's there
2840 GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`"
2841
2842 AC_MSG_CHECKING(for location of Motif GUI includes)
2843 gui_includes="`echo $x_includes|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC"
2844 GUI_INC_LOC=
2845 for try in $gui_includes; do
2846 if test -f "$try/Xm/Xm.h"; then
2847 GUI_INC_LOC=$try
2848 fi
2849 done
2850 if test -n "$GUI_INC_LOC"; then
2851 if test "$GUI_INC_LOC" = /usr/include; then
2852 GUI_INC_LOC=
2853 AC_MSG_RESULT(in default path)
2854 else
2855 AC_MSG_RESULT($GUI_INC_LOC)
2856 fi
2857 else
2858 AC_MSG_RESULT(<not found>)
2859 SKIP_MOTIF=YES
2860 fi
2861fi
2862
2863dnl Check for Motif library files location. In the same order as the include
2864dnl files, to avoid a mixup if several versions are present
2865
2866if test -z "$SKIP_MOTIF"; then
2867 AC_MSG_CHECKING(--with-motif-lib argument)
2868 AC_ARG_WITH(motif-lib,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002869 [ --with-motif-lib=STRING Library for Motif ],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002870 [ MOTIF_LIBNAME="${withval}" ] )
2871
2872 if test -n "$MOTIF_LIBNAME"; then
2873 AC_MSG_RESULT($MOTIF_LIBNAME)
2874 GUI_LIB_LOC=
2875 else
2876 AC_MSG_RESULT(no)
2877
2878 dnl Remove "-L" from before $GUI_LIB_LOC if it's there
2879 GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
2880
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002881 dnl Ubuntu has libXm.so in /usr/lib/i386-linux-gnu and elsewhere. The
2882 dnl linker will figure out which one to use, we only check if one exists.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002883 AC_MSG_CHECKING(for location of Motif GUI libs)
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002884 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 +00002885 GUI_LIB_LOC=
2886 for try in $gui_libs; do
Bram Moolenaar325b7a22004-07-05 15:58:32 +00002887 for libtry in "$try"/libXm.a "$try"/libXm.so* "$try"/libXm.sl "$try"/libXm.dylib; do
Bram Moolenaar071d4272004-06-13 20:20:40 +00002888 if test -f "$libtry"; then
2889 GUI_LIB_LOC=$try
2890 fi
2891 done
2892 done
2893 if test -n "$GUI_LIB_LOC"; then
2894 dnl Remove /usr/lib, it causes trouble on some systems
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002895 if test "$GUI_LIB_LOC" = /usr/lib \
2896 -o "$GUI_LIB_LOC" = /usr/lib/i386-linux-gnu \
2897 -o "$GUI_LIB_LOC" = /usr/lib/x86_64-linux-gnu; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002898 GUI_LIB_LOC=
2899 AC_MSG_RESULT(in default path)
2900 else
2901 if test -n "$GUI_LIB_LOC"; then
2902 AC_MSG_RESULT($GUI_LIB_LOC)
2903 if test "`(uname) 2>/dev/null`" = SunOS &&
2904 uname -r | grep '^5' >/dev/null; then
2905 GUI_LIB_LOC="$GUI_LIB_LOC -R $GUI_LIB_LOC"
2906 fi
2907 fi
2908 fi
2909 MOTIF_LIBNAME=-lXm
2910 else
2911 AC_MSG_RESULT(<not found>)
2912 SKIP_MOTIF=YES
2913 fi
2914 fi
2915fi
2916
2917if test -z "$SKIP_MOTIF"; then
2918 SKIP_ATHENA=YES
2919 SKIP_NEXTAW=YES
2920 GUITYPE=MOTIF
2921 AC_SUBST(MOTIF_LIBNAME)
2922fi
2923
2924dnl Check if the Athena files can be found
2925
2926GUI_X_LIBS=
2927
2928if test -z "$SKIP_ATHENA"; then
2929 AC_MSG_CHECKING(if Athena header files can be found)
2930 cflags_save=$CFLAGS
2931 CFLAGS="$CFLAGS $X_CFLAGS"
2932 AC_TRY_COMPILE([
2933#include <X11/Intrinsic.h>
2934#include <X11/Xaw/Paned.h>], ,
2935 AC_MSG_RESULT(yes),
2936 AC_MSG_RESULT(no); SKIP_ATHENA=YES )
2937 CFLAGS=$cflags_save
2938fi
2939
2940if test -z "$SKIP_ATHENA"; then
2941 GUITYPE=ATHENA
2942fi
2943
2944if test -z "$SKIP_NEXTAW"; then
2945 AC_MSG_CHECKING(if neXtaw header files can be found)
2946 cflags_save=$CFLAGS
2947 CFLAGS="$CFLAGS $X_CFLAGS"
2948 AC_TRY_COMPILE([
2949#include <X11/Intrinsic.h>
2950#include <X11/neXtaw/Paned.h>], ,
2951 AC_MSG_RESULT(yes),
2952 AC_MSG_RESULT(no); SKIP_NEXTAW=YES )
2953 CFLAGS=$cflags_save
2954fi
2955
2956if test -z "$SKIP_NEXTAW"; then
2957 GUITYPE=NEXTAW
2958fi
2959
2960if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
2961 dnl Prepend -I and -L to $GUI_INC_LOC and $GUI_LIB_LOC if not empty
2962 dnl Avoid adding it when it twice
2963 if test -n "$GUI_INC_LOC"; then
2964 GUI_INC_LOC=-I"`echo $GUI_INC_LOC|sed 's%-I%%'`"
2965 fi
2966 if test -n "$GUI_LIB_LOC"; then
2967 GUI_LIB_LOC=-L"`echo $GUI_LIB_LOC|sed 's%-L%%'`"
2968 fi
2969
2970 dnl Check for -lXext and then for -lXmu
2971 ldflags_save=$LDFLAGS
2972 LDFLAGS="$X_LIBS $LDFLAGS"
2973 AC_CHECK_LIB(Xext, XShapeQueryExtension, [GUI_X_LIBS="-lXext"],,
2974 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2975 dnl For Solaris we need -lw and -ldl before linking with -lXmu works.
2976 AC_CHECK_LIB(w, wslen, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lw"],,
2977 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2978 AC_CHECK_LIB(dl, dlsym, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldl"],,
2979 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2980 AC_CHECK_LIB(Xmu, XmuCreateStippledPixmap, [GUI_X_LIBS="-lXmu $GUI_X_LIBS"],,
2981 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2982 if test -z "$SKIP_MOTIF"; then
2983 AC_CHECK_LIB(Xp, XpEndJob, [GUI_X_LIBS="-lXp $GUI_X_LIBS"],,
2984 [$GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2985 fi
2986 LDFLAGS=$ldflags_save
2987
2988 dnl Execute xmkmf to figure out if -DNARROWPROTO is needed.
2989 AC_MSG_CHECKING(for extra X11 defines)
2990 NARROW_PROTO=
2991 rm -fr conftestdir
2992 if mkdir conftestdir; then
2993 cd conftestdir
2994 cat > Imakefile <<'EOF'
2995acfindx:
2996 @echo 'NARROW_PROTO="${PROTO_DEFINES}"'
2997EOF
2998 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
2999 eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
3000 fi
3001 cd ..
3002 rm -fr conftestdir
3003 fi
3004 if test -z "$NARROW_PROTO"; then
3005 AC_MSG_RESULT(no)
3006 else
3007 AC_MSG_RESULT($NARROW_PROTO)
3008 fi
3009 AC_SUBST(NARROW_PROTO)
3010fi
3011
3012dnl Look for XSMP support - but don't necessarily restrict it to X11 GUIs
3013dnl use the X11 include path
3014if test "$enable_xsmp" = "yes"; then
3015 cppflags_save=$CPPFLAGS
3016 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3017 AC_CHECK_HEADERS(X11/SM/SMlib.h)
3018 CPPFLAGS=$cppflags_save
3019fi
3020
3021
Bram Moolenaar98921892016-02-23 17:14:37 +01003022if 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 +00003023 dnl Check for X11/xpm.h and X11/Sunkeysym.h with the GUI include path
3024 cppflags_save=$CPPFLAGS
3025 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3026 AC_CHECK_HEADERS(X11/xpm.h X11/Sunkeysym.h)
3027
3028 dnl automatically disable XIM when XIMtext isn't in X11/Xlib.h
3029 if test ! "$enable_xim" = "no"; then
3030 AC_MSG_CHECKING(for XIMText in X11/Xlib.h)
3031 AC_EGREP_CPP(XIMText, [#include <X11/Xlib.h>],
3032 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +02003033 AC_MSG_RESULT(no; xim has been disabled); enable_xim="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00003034 fi
3035 CPPFLAGS=$cppflags_save
3036
3037 dnl automatically enable XIM when hangul input isn't enabled
3038 if test "$enable_xim" = "auto" -a "$enable_hangulinput" != "yes" \
3039 -a "x$GUITYPE" != "xNONE" ; then
3040 AC_MSG_RESULT(X GUI selected; xim has been enabled)
3041 enable_xim="yes"
3042 fi
3043fi
3044
3045if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
3046 cppflags_save=$CPPFLAGS
3047 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00003048dnl Xmu/Editres.h may exist but can only be used after including Intrinsic.h
3049 AC_MSG_CHECKING([for X11/Xmu/Editres.h])
3050 AC_TRY_COMPILE([
3051#include <X11/Intrinsic.h>
3052#include <X11/Xmu/Editres.h>],
3053 [int i; i = 0;],
3054 AC_MSG_RESULT(yes)
3055 AC_DEFINE(HAVE_X11_XMU_EDITRES_H),
3056 AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003057 CPPFLAGS=$cppflags_save
3058fi
3059
3060dnl Only use the Xm directory when compiling Motif, don't use it for Athena
3061if test -z "$SKIP_MOTIF"; then
3062 cppflags_save=$CPPFLAGS
3063 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003064 if test "$zOSUnix" = "yes"; then
3065 xmheader="Xm/Xm.h"
3066 else
3067 xmheader="Xm/Xm.h Xm/XpmP.h Xm/JoinSideT.h Xm/TraitP.h Xm/Manager.h
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02003068 Xm/UnhighlightT.h Xm/Notebook.h"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003069 fi
3070 AC_CHECK_HEADERS($xmheader)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003071
Bram Moolenaar77c19352012-06-13 19:19:41 +02003072 if test "x$ac_cv_header_Xm_XpmP_h" = "xyes"; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003073 dnl Solaris uses XpmAttributes_21, very annoying.
3074 AC_MSG_CHECKING([for XpmAttributes_21 in Xm/XpmP.h])
3075 AC_TRY_COMPILE([#include <Xm/XpmP.h>], [XpmAttributes_21 attr;],
3076 AC_MSG_RESULT(yes); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes_21),
3077 AC_MSG_RESULT(no); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
3078 )
3079 else
Bram Moolenaar57657d82006-04-21 22:12:41 +00003080 AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003081 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003082 CPPFLAGS=$cppflags_save
3083fi
3084
3085if test "x$GUITYPE" = "xNONE" -a "$enable_xim" = "yes"; then
3086 AC_MSG_RESULT(no GUI selected; xim has been disabled)
3087 enable_xim="no"
3088fi
3089if test "x$GUITYPE" = "xNONE" -a "$enable_fontset" = "yes"; then
3090 AC_MSG_RESULT(no GUI selected; fontset has been disabled)
3091 enable_fontset="no"
3092fi
Bram Moolenaar182c5be2010-06-25 05:37:59 +02003093if test "x$GUITYPE:$enable_fontset" = "xGTK:yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003094 AC_MSG_RESULT(GTK+ 2 GUI selected; fontset has been disabled)
3095 enable_fontset="no"
3096fi
3097
Bram Moolenaar071d4272004-06-13 20:20:40 +00003098if test -z "$SKIP_PHOTON"; then
3099 GUITYPE=PHOTONGUI
3100fi
3101
3102AC_SUBST(GUI_INC_LOC)
3103AC_SUBST(GUI_LIB_LOC)
3104AC_SUBST(GUITYPE)
3105AC_SUBST(GUI_X_LIBS)
3106
3107if test "$enable_workshop" = "yes" -a -n "$SKIP_MOTIF"; then
3108 AC_MSG_ERROR([cannot use workshop without Motif])
3109fi
3110
3111dnl defining FEAT_XIM and FEAT_XFONTSET is delayed, so that they can be disabled
3112if test "$enable_xim" = "yes"; then
3113 AC_DEFINE(FEAT_XIM)
3114fi
3115if test "$enable_fontset" = "yes"; then
3116 AC_DEFINE(FEAT_XFONTSET)
3117fi
3118
3119
3120dnl ---------------------------------------------------------------------------
3121dnl end of GUI-checking
3122dnl ---------------------------------------------------------------------------
3123
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003124AC_MSG_CHECKING([for /proc link to executable])
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003125if test -L "/proc/self/exe"; then
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003126 dnl Linux
3127 AC_MSG_RESULT([/proc/self/exe])
3128 AC_DEFINE(PROC_EXE_LINK, "/proc/self/exe")
3129elif test -L "/proc/self/path/a.out"; then
3130 dnl Solaris
3131 AC_MSG_RESULT([/proc/self/path/a.out])
3132 AC_DEFINE(PROC_EXE_LINK, "/proc/self/path/a.out")
3133elif test -L "/proc/curproc/file"; then
3134 dnl FreeBSD
3135 AC_MSG_RESULT([/proc/curproc/file])
3136 AC_DEFINE(PROC_EXE_LINK, "/proc/curproc/file")
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003137else
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003138 AC_MSG_RESULT(no)
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003139fi
3140
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003141dnl Check for Cygwin, which needs an extra source file if not using X11
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003142AC_MSG_CHECKING(for CYGWIN or MSYS environment)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003143case `uname` in
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003144 CYGWIN*|MSYS*) CYGWIN=yes; AC_MSG_RESULT(yes)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003145 AC_MSG_CHECKING(for CYGWIN clipboard support)
3146 if test "x$with_x" = "xno" ; then
3147 OS_EXTRA_SRC=winclip.c; OS_EXTRA_OBJ=objects/winclip.o
3148 AC_MSG_RESULT(yes)
3149 AC_DEFINE(FEAT_CYGWIN_WIN32_CLIPBOARD)
3150 else
3151 AC_MSG_RESULT(no - using X11)
3152 fi ;;
3153
3154 *) CYGWIN=no; AC_MSG_RESULT(no);;
3155esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00003156
3157dnl Only really enable hangul input when GUI and XFONTSET are available
3158if test "$enable_hangulinput" = "yes"; then
3159 if test "x$GUITYPE" = "xNONE"; then
3160 AC_MSG_RESULT(no GUI selected; hangul input has been disabled)
3161 enable_hangulinput=no
3162 else
3163 AC_DEFINE(FEAT_HANGULIN)
3164 HANGULIN_SRC=hangulin.c
3165 AC_SUBST(HANGULIN_SRC)
3166 HANGULIN_OBJ=objects/hangulin.o
3167 AC_SUBST(HANGULIN_OBJ)
3168 fi
3169fi
3170
3171dnl Checks for libraries and include files.
3172
Bram Moolenaar446cb832008-06-24 21:56:24 +00003173AC_CACHE_CHECK([whether toupper is broken], [vim_cv_toupper_broken],
3174 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003175 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003176#include "confdefs.h"
3177#include <ctype.h>
3178#if STDC_HEADERS
3179# include <stdlib.h>
3180# include <stddef.h>
3181#endif
3182main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003183 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003184 vim_cv_toupper_broken=yes
3185 ],[
3186 vim_cv_toupper_broken=no
3187 ],[
3188 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_toupper_broken')
3189 ])])
3190
3191if test "x$vim_cv_toupper_broken" = "xyes" ; then
3192 AC_DEFINE(BROKEN_TOUPPER)
3193fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003194
3195AC_MSG_CHECKING(whether __DATE__ and __TIME__ work)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003196AC_TRY_COMPILE([#include <stdio.h>], [printf("(" __DATE__ " " __TIME__ ")");],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003197 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DATE_TIME),
3198 AC_MSG_RESULT(no))
3199
Bram Moolenaar0c094b92009-05-14 20:20:33 +00003200AC_MSG_CHECKING(whether __attribute__((unused)) is allowed)
3201AC_TRY_COMPILE([#include <stdio.h>], [int x __attribute__((unused));],
3202 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ATTRIBUTE_UNUSED),
3203 AC_MSG_RESULT(no))
3204
Bram Moolenaar071d4272004-06-13 20:20:40 +00003205dnl Checks for header files.
3206AC_CHECK_HEADER(elf.h, HAS_ELF=1)
3207dnl AC_CHECK_HEADER(dwarf.h, SVR4=1)
3208if test "$HAS_ELF" = 1; then
3209 AC_CHECK_LIB(elf, main)
3210fi
3211
3212AC_HEADER_DIRENT
3213
Bram Moolenaar071d4272004-06-13 20:20:40 +00003214dnl If sys/wait.h is not found it might still exist but not be POSIX
3215dnl compliant. In that case we define HAVE_UNION_WAIT (for NeXT)
3216if test $ac_cv_header_sys_wait_h = no; then
3217 AC_MSG_CHECKING([for sys/wait.h that defines union wait])
3218 AC_TRY_COMPILE([#include <sys/wait.h>],
3219 [union wait xx, yy; xx = yy],
3220 AC_MSG_RESULT(yes)
3221 AC_DEFINE(HAVE_SYS_WAIT_H)
3222 AC_DEFINE(HAVE_UNION_WAIT),
3223 AC_MSG_RESULT(no))
3224fi
3225
Bram Moolenaar779a7752016-01-30 23:26:34 +01003226AC_CHECK_HEADERS(stdint.h stdlib.h string.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003227 sys/select.h sys/utsname.h termcap.h fcntl.h \
3228 sgtty.h sys/ioctl.h sys/time.h sys/types.h \
3229 termio.h iconv.h inttypes.h langinfo.h math.h \
3230 unistd.h stropts.h errno.h sys/resource.h \
3231 sys/systeminfo.h locale.h sys/stream.h termios.h \
3232 libc.h sys/statfs.h poll.h sys/poll.h pwd.h \
3233 utime.h sys/param.h libintl.h libgen.h \
3234 util/debug.h util/msg18n.h frame.h sys/acl.h \
3235 sys/access.h sys/sysinfo.h wchar.h wctype.h)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003236
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003237dnl sys/ptem.h depends on sys/stream.h on Solaris
3238AC_CHECK_HEADERS(sys/ptem.h, [], [],
3239[#if defined HAVE_SYS_STREAM_H
3240# include <sys/stream.h>
3241#endif])
3242
Bram Moolenaar32f31b12009-05-21 13:20:59 +00003243dnl sys/sysctl.h depends on sys/param.h on OpenBSD
3244AC_CHECK_HEADERS(sys/sysctl.h, [], [],
3245[#if defined HAVE_SYS_PARAM_H
3246# include <sys/param.h>
3247#endif])
3248
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003249
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003250dnl pthread_np.h may exist but can only be used after including pthread.h
3251AC_MSG_CHECKING([for pthread_np.h])
3252AC_TRY_COMPILE([
3253#include <pthread.h>
3254#include <pthread_np.h>],
3255 [int i; i = 0;],
3256 AC_MSG_RESULT(yes)
3257 AC_DEFINE(HAVE_PTHREAD_NP_H),
3258 AC_MSG_RESULT(no))
3259
Bram Moolenaare344bea2005-09-01 20:46:49 +00003260AC_CHECK_HEADERS(strings.h)
Bram Moolenaard0573012017-10-28 21:11:06 +02003261if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00003262 dnl The strings.h file on OS/X contains a warning and nothing useful.
3263 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3264else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003265
3266dnl Check if strings.h and string.h can both be included when defined.
3267AC_MSG_CHECKING([if strings.h can be included after string.h])
3268cppflags_save=$CPPFLAGS
3269CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3270AC_TRY_COMPILE([
3271#if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO)
3272# define _NO_PROTO /* like in os_unix.h, causes conflict for AIX (Winn) */
3273 /* but don't do it on AIX 5.1 (Uribarri) */
3274#endif
3275#ifdef HAVE_XM_XM_H
3276# include <Xm/Xm.h> /* This breaks it for HP-UX 11 (Squassabia) */
3277#endif
3278#ifdef HAVE_STRING_H
3279# include <string.h>
3280#endif
3281#if defined(HAVE_STRINGS_H)
3282# include <strings.h>
3283#endif
3284 ], [int i; i = 0;],
3285 AC_MSG_RESULT(yes),
3286 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3287 AC_MSG_RESULT(no))
3288CPPFLAGS=$cppflags_save
Bram Moolenaar9372a112005-12-06 19:59:18 +00003289fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003290
3291dnl Checks for typedefs, structures, and compiler characteristics.
3292AC_PROG_GCC_TRADITIONAL
3293AC_C_CONST
Bram Moolenaar76243bd2009-03-02 01:47:02 +00003294AC_C_VOLATILE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003295AC_TYPE_MODE_T
3296AC_TYPE_OFF_T
3297AC_TYPE_PID_T
3298AC_TYPE_SIZE_T
3299AC_TYPE_UID_T
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003300AC_TYPE_UINT32_T
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003301
Bram Moolenaar071d4272004-06-13 20:20:40 +00003302AC_HEADER_TIME
3303AC_CHECK_TYPE(ino_t, long)
3304AC_CHECK_TYPE(dev_t, unsigned)
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003305AC_C_BIGENDIAN(,,,)
Bram Moolenaar136f29a2016-02-27 20:14:15 +01003306AC_C_INLINE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003307
3308AC_MSG_CHECKING(for rlim_t)
3309if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
3310 AC_MSG_RESULT([(cached) $ac_cv_type_rlim_t])
3311else
3312 AC_EGREP_CPP(dnl
3313changequote(<<,>>)dnl
3314<<(^|[^a-zA-Z_0-9])rlim_t[^a-zA-Z_0-9]>>dnl
3315changequote([,]),
3316 [
3317#include <sys/types.h>
3318#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003319# include <stdlib.h>
3320# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003321#endif
3322#ifdef HAVE_SYS_RESOURCE_H
Bram Moolenaar446cb832008-06-24 21:56:24 +00003323# include <sys/resource.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003324#endif
3325 ], ac_cv_type_rlim_t=yes, ac_cv_type_rlim_t=no)
3326 AC_MSG_RESULT($ac_cv_type_rlim_t)
3327fi
3328if test $ac_cv_type_rlim_t = no; then
3329 cat >> confdefs.h <<\EOF
3330#define rlim_t unsigned long
3331EOF
3332fi
3333
3334AC_MSG_CHECKING(for stack_t)
3335if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then
3336 AC_MSG_RESULT([(cached) $ac_cv_type_stack_t])
3337else
3338 AC_EGREP_CPP(stack_t,
3339 [
3340#include <sys/types.h>
3341#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003342# include <stdlib.h>
3343# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003344#endif
3345#include <signal.h>
3346 ], ac_cv_type_stack_t=yes, ac_cv_type_stack_t=no)
3347 AC_MSG_RESULT($ac_cv_type_stack_t)
3348fi
3349if test $ac_cv_type_stack_t = no; then
3350 cat >> confdefs.h <<\EOF
3351#define stack_t struct sigaltstack
3352EOF
3353fi
3354
3355dnl BSDI uses ss_base while others use ss_sp for the stack pointer.
3356AC_MSG_CHECKING(whether stack_t has an ss_base field)
3357AC_TRY_COMPILE([
3358#include <sys/types.h>
3359#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003360# include <stdlib.h>
3361# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003362#endif
3363#include <signal.h>
3364#include "confdefs.h"
3365 ], [stack_t sigstk; sigstk.ss_base = 0; ],
3366 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SS_BASE),
3367 AC_MSG_RESULT(no))
3368
3369olibs="$LIBS"
3370AC_MSG_CHECKING(--with-tlib argument)
3371AC_ARG_WITH(tlib, [ --with-tlib=library terminal library to be used ],)
3372if test -n "$with_tlib"; then
3373 AC_MSG_RESULT($with_tlib)
3374 LIBS="$LIBS -l$with_tlib"
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003375 AC_MSG_CHECKING(for linking with $with_tlib library)
3376 AC_TRY_LINK([], [], AC_MSG_RESULT(OK), AC_MSG_ERROR(FAILED))
3377 dnl Need to check for tgetent() below.
3378 olibs="$LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003379else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003380 AC_MSG_RESULT([empty: automatic terminal library selection])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003381 dnl On HP-UX 10.10 termcap or termlib should be used instead of
3382 dnl curses, because curses is much slower.
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003383 dnl Newer versions of ncurses are preferred over anything, except
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02003384 dnl when tinfo has been split off, it contains all we need.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003385 dnl Older versions of ncurses have bugs, get a new one!
3386 dnl Digital Unix (OSF1) should use curses (Ronald Schild).
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00003387 dnl On SCO Openserver should prefer termlib (Roger Cornelius).
Bram Moolenaar071d4272004-06-13 20:20:40 +00003388 case "`uname -s 2>/dev/null`" in
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003389 OSF1|SCO_SV) tlibs="tinfo ncurses curses termlib termcap";;
3390 *) tlibs="tinfo ncurses termlib termcap curses";;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003391 esac
3392 for libname in $tlibs; do
3393 AC_CHECK_LIB(${libname}, tgetent,,)
3394 if test "x$olibs" != "x$LIBS"; then
3395 dnl It's possible that a library is found but it doesn't work
3396 dnl e.g., shared library that cannot be found
3397 dnl compile and run a test program to be sure
3398 AC_TRY_RUN([
3399#ifdef HAVE_TERMCAP_H
3400# include <termcap.h>
3401#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003402#if STDC_HEADERS
3403# include <stdlib.h>
3404# include <stddef.h>
3405#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003406main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }],
3407 res="OK", res="FAIL", res="FAIL")
3408 if test "$res" = "OK"; then
3409 break
3410 fi
3411 AC_MSG_RESULT($libname library is not usable)
3412 LIBS="$olibs"
3413 fi
3414 done
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003415 if test "x$olibs" = "x$LIBS"; then
3416 AC_MSG_RESULT(no terminal library found)
3417 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003418fi
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003419
3420if test "x$olibs" = "x$LIBS"; then
3421 AC_MSG_CHECKING([for tgetent()])
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00003422 AC_TRY_LINK([],
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003423 [char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");],
3424 AC_MSG_RESULT(yes),
3425 AC_MSG_ERROR([NOT FOUND!
3426 You need to install a terminal library; for example ncurses.
3427 Or specify the name of the library with --with-tlib.]))
3428fi
3429
Bram Moolenaar446cb832008-06-24 21:56:24 +00003430AC_CACHE_CHECK([whether we talk terminfo], [vim_cv_terminfo],
3431 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003432 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003433#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003434#ifdef HAVE_TERMCAP_H
3435# include <termcap.h>
3436#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003437#ifdef HAVE_STRING_H
3438# include <string.h>
3439#endif
3440#if STDC_HEADERS
3441# include <stdlib.h>
3442# include <stddef.h>
3443#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003444main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003445{char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003446 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003447 vim_cv_terminfo=no
3448 ],[
3449 vim_cv_terminfo=yes
3450 ],[
3451 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_terminfo')
3452 ])
3453 ])
3454
3455if test "x$vim_cv_terminfo" = "xyes" ; then
3456 AC_DEFINE(TERMINFO)
3457fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003458
Bram Moolenaara88254f2017-11-02 23:04:14 +01003459AC_CACHE_CHECK([what tgetent() returns for an unknown terminal], [vim_cv_tgetent],
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003460 [
3461 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003462#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003463#ifdef HAVE_TERMCAP_H
3464# include <termcap.h>
3465#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003466#if STDC_HEADERS
3467# include <stdlib.h>
3468# include <stddef.h>
3469#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003470main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003471{char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003472 ]])],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003473 vim_cv_tgetent=zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003474 ],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003475 vim_cv_tgetent=non-zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003476 ],[
3477 AC_MSG_ERROR(failed to compile test program.)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003478 ])
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003479 ])
3480
Bram Moolenaara88254f2017-11-02 23:04:14 +01003481if test "x$vim_cv_tgetent" = "xzero" ; then
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003482 AC_DEFINE(TGETENT_ZERO_ERR, 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003483fi
3484
3485AC_MSG_CHECKING(whether termcap.h contains ospeed)
3486AC_TRY_LINK([
3487#ifdef HAVE_TERMCAP_H
3488# include <termcap.h>
3489#endif
3490 ], [ospeed = 20000],
3491 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED),
3492 [AC_MSG_RESULT(no)
3493 AC_MSG_CHECKING(whether ospeed can be extern)
3494 AC_TRY_LINK([
3495#ifdef HAVE_TERMCAP_H
3496# include <termcap.h>
3497#endif
3498extern short ospeed;
3499 ], [ospeed = 20000],
3500 AC_MSG_RESULT(yes); AC_DEFINE(OSPEED_EXTERN),
3501 AC_MSG_RESULT(no))]
3502 )
3503
3504AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC])
3505AC_TRY_LINK([
3506#ifdef HAVE_TERMCAP_H
3507# include <termcap.h>
3508#endif
3509 ], [if (UP == 0 && BC == 0) PC = 1],
3510 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UP_BC_PC),
3511 [AC_MSG_RESULT(no)
3512 AC_MSG_CHECKING([whether UP, BC and PC can be extern])
3513 AC_TRY_LINK([
3514#ifdef HAVE_TERMCAP_H
3515# include <termcap.h>
3516#endif
3517extern char *UP, *BC, PC;
3518 ], [if (UP == 0 && BC == 0) PC = 1],
3519 AC_MSG_RESULT(yes); AC_DEFINE(UP_BC_PC_EXTERN),
3520 AC_MSG_RESULT(no))]
3521 )
3522
3523AC_MSG_CHECKING(whether tputs() uses outfuntype)
3524AC_TRY_COMPILE([
3525#ifdef HAVE_TERMCAP_H
3526# include <termcap.h>
3527#endif
3528 ], [extern int xx(); tputs("test", 1, (outfuntype)xx)],
3529 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OUTFUNTYPE),
3530 AC_MSG_RESULT(no))
3531
3532dnl On some SCO machines sys/select redefines struct timeval
3533AC_MSG_CHECKING([whether sys/select.h and sys/time.h may both be included])
3534AC_TRY_COMPILE([
3535#include <sys/types.h>
3536#include <sys/time.h>
3537#include <sys/select.h>], ,
3538 AC_MSG_RESULT(yes)
3539 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME),
3540 AC_MSG_RESULT(no))
3541
3542dnl AC_DECL_SYS_SIGLIST
3543
3544dnl Checks for pty.c (copied from screen) ==========================
3545AC_MSG_CHECKING(for /dev/ptc)
3546if test -r /dev/ptc; then
3547 AC_DEFINE(HAVE_DEV_PTC)
3548 AC_MSG_RESULT(yes)
3549else
3550 AC_MSG_RESULT(no)
3551fi
3552
3553AC_MSG_CHECKING(for SVR4 ptys)
3554if test -c /dev/ptmx ; then
3555 AC_TRY_LINK([], [ptsname(0);grantpt(0);unlockpt(0);],
3556 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SVR4_PTYS),
3557 AC_MSG_RESULT(no))
3558else
3559 AC_MSG_RESULT(no)
3560fi
3561
3562AC_MSG_CHECKING(for ptyranges)
3563if test -d /dev/ptym ; then
3564 pdir='/dev/ptym'
3565else
3566 pdir='/dev'
3567fi
3568dnl SCO uses ptyp%d
3569AC_EGREP_CPP(yes,
3570[#ifdef M_UNIX
3571 yes;
3572#endif
3573 ], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
3574dnl if test -c /dev/ptyp19; then
3575dnl ptys=`echo /dev/ptyp??`
3576dnl else
3577dnl ptys=`echo $pdir/pty??`
3578dnl fi
3579if test "$ptys" != "$pdir/pty??" ; then
3580 p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
3581 p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'`
3582 AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
3583 AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
3584 AC_MSG_RESULT([$p0 / $p1])
3585else
3586 AC_MSG_RESULT([don't know])
3587fi
3588
3589dnl **** pty mode/group handling ****
3590dnl
3591dnl support provided by Luke Mewburn <lm@rmit.edu.au>, 931222
Bram Moolenaar071d4272004-06-13 20:20:40 +00003592rm -f conftest_grp
Bram Moolenaar446cb832008-06-24 21:56:24 +00003593AC_CACHE_CHECK([default tty permissions/group], [vim_cv_tty_group],
3594 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003595 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003596#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003597#include <sys/types.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003598#if STDC_HEADERS
3599# include <stdlib.h>
3600# include <stddef.h>
3601#endif
3602#ifdef HAVE_UNISTD_H
3603#include <unistd.h>
3604#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003605#include <sys/stat.h>
3606#include <stdio.h>
3607main()
3608{
3609 struct stat sb;
3610 char *x,*ttyname();
3611 int om, m;
3612 FILE *fp;
3613
3614 if (!(x = ttyname(0))) exit(1);
3615 if (stat(x, &sb)) exit(1);
3616 om = sb.st_mode;
3617 if (om & 002) exit(0);
3618 m = system("mesg y");
3619 if (m == -1 || m == 127) exit(1);
3620 if (stat(x, &sb)) exit(1);
3621 m = sb.st_mode;
3622 if (chmod(x, om)) exit(1);
3623 if (m & 002) exit(0);
3624 if (sb.st_gid == getgid()) exit(1);
3625 if (!(fp=fopen("conftest_grp", "w")))
3626 exit(1);
3627 fprintf(fp, "%d\n", sb.st_gid);
3628 fclose(fp);
3629 exit(0);
3630}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003631 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003632 if test -f conftest_grp; then
3633 vim_cv_tty_group=`cat conftest_grp`
3634 if test "x$vim_cv_tty_mode" = "x" ; then
3635 vim_cv_tty_mode=0620
3636 fi
3637 AC_MSG_RESULT([pty mode: $vim_cv_tty_mode, group: $vim_cv_tty_group])
3638 else
3639 vim_cv_tty_group=world
Bram Moolenaar72951072009-12-02 16:58:33 +00003640 AC_MSG_RESULT([ptys are world accessible])
Bram Moolenaar446cb832008-06-24 21:56:24 +00003641 fi
3642 ],[
3643 vim_cv_tty_group=world
Bram Moolenaar72951072009-12-02 16:58:33 +00003644 AC_MSG_RESULT([can't determine - assume ptys are world accessible])
Bram Moolenaar446cb832008-06-24 21:56:24 +00003645 ],[
3646 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_tty_group' and 'vim_cv_tty_mode')
3647 ])
3648 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003649rm -f conftest_grp
3650
Bram Moolenaar446cb832008-06-24 21:56:24 +00003651if test "x$vim_cv_tty_group" != "xworld" ; then
3652 AC_DEFINE_UNQUOTED(PTYGROUP,$vim_cv_tty_group)
3653 if test "x$vim_cv_tty_mode" = "x" ; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02003654 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 +00003655 else
3656 AC_DEFINE(PTYMODE, 0620)
3657 fi
3658fi
3659
Bram Moolenaar071d4272004-06-13 20:20:40 +00003660dnl Checks for library functions. ===================================
3661
3662AC_TYPE_SIGNAL
3663
3664dnl find out what to use at the end of a signal function
3665if test $ac_cv_type_signal = void; then
3666 AC_DEFINE(SIGRETURN, [return])
3667else
3668 AC_DEFINE(SIGRETURN, [return 0])
3669fi
3670
3671dnl check if struct sigcontext is defined (used for SGI only)
3672AC_MSG_CHECKING(for struct sigcontext)
3673AC_TRY_COMPILE([
3674#include <signal.h>
3675test_sig()
3676{
3677 struct sigcontext *scont;
3678 scont = (struct sigcontext *)0;
3679 return 1;
3680} ], ,
3681 AC_MSG_RESULT(yes)
3682 AC_DEFINE(HAVE_SIGCONTEXT),
3683 AC_MSG_RESULT(no))
3684
3685dnl tricky stuff: try to find out if getcwd() is implemented with
3686dnl system("sh -c pwd")
Bram Moolenaar446cb832008-06-24 21:56:24 +00003687AC_CACHE_CHECK([getcwd implementation is broken], [vim_cv_getcwd_broken],
3688 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003689 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003690#include "confdefs.h"
3691#ifdef HAVE_UNISTD_H
3692#include <unistd.h>
3693#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003694char *dagger[] = { "IFS=pwd", 0 };
3695main()
3696{
3697 char buffer[500];
3698 extern char **environ;
3699 environ = dagger;
3700 return getcwd(buffer, 500) ? 0 : 1;
Bram Moolenaar446cb832008-06-24 21:56:24 +00003701}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003702 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003703 vim_cv_getcwd_broken=no
3704 ],[
3705 vim_cv_getcwd_broken=yes
3706 ],[
3707 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_getcwd_broken')
3708 ])
3709 ])
3710
3711if test "x$vim_cv_getcwd_broken" = "xyes" ; then
3712 AC_DEFINE(BAD_GETCWD)
3713fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003714
Bram Moolenaar25153e12010-02-24 14:47:08 +01003715dnl Check for functions in one big call, to reduce the size of configure.
3716dnl Can only be used for functions that do not require any include.
Bram Moolenaarcd142e32017-11-16 17:03:45 +01003717AC_CHECK_FUNCS(fchdir fchown fchmod fsync getcwd getpseudotty \
Bram Moolenaarb129a442016-12-01 17:25:20 +01003718 getpwent getpwnam getpwuid getrlimit gettimeofday getwd lstat \
Bram Moolenaareaf03392009-11-17 11:08:52 +00003719 memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
Bram Moolenaar2fcf6682017-03-11 20:03:42 +01003720 getpgid setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
Bram Moolenaarbb09ceb2016-10-18 16:27:23 +02003721 sigprocmask sigvec strcasecmp strerror strftime stricmp strncasecmp \
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00003722 strnicmp strpbrk strtol tgetent towlower towupper iswupper \
Bram Moolenaar137374f2018-05-13 15:59:50 +02003723 usleep utime utimes mblen ftruncate unsetenv)
Bram Moolenaar643b6142018-09-12 20:29:09 +02003724AC_FUNC_SELECT_ARGTYPES
Bram Moolenaar25153e12010-02-24 14:47:08 +01003725AC_FUNC_FSEEKO
Bram Moolenaar071d4272004-06-13 20:20:40 +00003726
Bram Moolenaar317fd3a2010-05-07 16:05:55 +02003727dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when
3728dnl appropriate, so that off_t is 64 bits when needed.
3729AC_SYS_LARGEFILE
3730
Bram Moolenaar071d4272004-06-13 20:20:40 +00003731dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible
3732AC_MSG_CHECKING(for st_blksize)
3733AC_TRY_COMPILE(
3734[#include <sys/types.h>
3735#include <sys/stat.h>],
3736[ struct stat st;
3737 int n;
3738
3739 stat("/", &st);
3740 n = (int)st.st_blksize;],
3741 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ST_BLKSIZE),
3742 AC_MSG_RESULT(no))
3743
Bram Moolenaar446cb832008-06-24 21:56:24 +00003744AC_CACHE_CHECK([whether stat() ignores a trailing slash], [vim_cv_stat_ignores_slash],
3745 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003746 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003747#include "confdefs.h"
3748#if STDC_HEADERS
3749# include <stdlib.h>
3750# include <stddef.h>
3751#endif
3752#include <sys/types.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003753#include <sys/stat.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003754main() {struct stat st; exit(stat("configure/", &st) != 0); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003755 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003756 vim_cv_stat_ignores_slash=yes
3757 ],[
3758 vim_cv_stat_ignores_slash=no
3759 ],[
3760 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_stat_ignores_slash')
3761 ])
3762 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003763
Bram Moolenaar446cb832008-06-24 21:56:24 +00003764if test "x$vim_cv_stat_ignores_slash" = "xyes" ; then
3765 AC_DEFINE(STAT_IGNORES_SLASH)
3766fi
3767
Bram Moolenaar071d4272004-06-13 20:20:40 +00003768dnl Link with iconv for charset translation, if not found without library.
3769dnl check for iconv() requires including iconv.h
3770dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
3771dnl has been installed.
3772AC_MSG_CHECKING(for iconv_open())
3773save_LIBS="$LIBS"
3774LIBS="$LIBS -liconv"
3775AC_TRY_LINK([
3776#ifdef HAVE_ICONV_H
3777# include <iconv.h>
3778#endif
3779 ], [iconv_open("fr", "to");],
3780 AC_MSG_RESULT(yes; with -liconv); AC_DEFINE(HAVE_ICONV),
3781 LIBS="$save_LIBS"
3782 AC_TRY_LINK([
3783#ifdef HAVE_ICONV_H
3784# include <iconv.h>
3785#endif
3786 ], [iconv_open("fr", "to");],
3787 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ICONV),
3788 AC_MSG_RESULT(no)))
3789
3790
3791AC_MSG_CHECKING(for nl_langinfo(CODESET))
3792AC_TRY_LINK([
3793#ifdef HAVE_LANGINFO_H
3794# include <langinfo.h>
3795#endif
3796], [char *cs = nl_langinfo(CODESET);],
3797 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET),
3798 AC_MSG_RESULT(no))
3799
Bram Moolenaar446cb832008-06-24 21:56:24 +00003800dnl Need various functions for floating point support. Only enable
3801dnl floating point when they are all present.
3802AC_CHECK_LIB(m, strtod)
3803AC_MSG_CHECKING([for strtod() and other floating point functions])
3804AC_TRY_LINK([
3805#ifdef HAVE_MATH_H
3806# include <math.h>
3807#endif
3808#if STDC_HEADERS
3809# include <stdlib.h>
3810# include <stddef.h>
3811#endif
3812], [char *s; double d;
3813 d = strtod("1.1", &s);
3814 d = fabs(1.11);
3815 d = ceil(1.11);
3816 d = floor(1.11);
3817 d = log10(1.11);
3818 d = pow(1.11, 2.22);
3819 d = sqrt(1.11);
3820 d = sin(1.11);
3821 d = cos(1.11);
3822 d = atan(1.11);
3823 ],
3824 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT_FUNCS),
3825 AC_MSG_RESULT(no))
3826
Bram Moolenaara6b89762016-02-29 21:38:26 +01003827dnl isinf() and isnan() need to include header files and may need -lm.
3828AC_MSG_CHECKING([for isinf()])
3829AC_TRY_LINK([
3830#ifdef HAVE_MATH_H
3831# include <math.h>
3832#endif
3833#if STDC_HEADERS
3834# include <stdlib.h>
3835# include <stddef.h>
3836#endif
3837], [int r = isinf(1.11); ],
3838 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISINF),
3839 AC_MSG_RESULT(no))
3840
3841AC_MSG_CHECKING([for isnan()])
3842AC_TRY_LINK([
3843#ifdef HAVE_MATH_H
3844# include <math.h>
3845#endif
3846#if STDC_HEADERS
3847# include <stdlib.h>
3848# include <stddef.h>
3849#endif
3850], [int r = isnan(1.11); ],
3851 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISNAN),
3852 AC_MSG_RESULT(no))
3853
Bram Moolenaar071d4272004-06-13 20:20:40 +00003854dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI
3855dnl when -lacl works, also try to use -lattr (required for Debian).
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003856dnl On Solaris, use the acl_get/set functions in libsec, if present.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003857AC_MSG_CHECKING(--disable-acl argument)
3858AC_ARG_ENABLE(acl,
Bram Moolenaard6d30422018-01-28 22:48:55 +01003859 [ --disable-acl No check for ACL support.],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003860 , [enable_acl="yes"])
3861if test "$enable_acl" = "yes"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01003862 AC_MSG_RESULT(no)
3863 AC_CHECK_LIB(posix1e, acl_get_file, [LIBS="$LIBS -lposix1e"],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003864 AC_CHECK_LIB(acl, acl_get_file, [LIBS="$LIBS -lacl"
3865 AC_CHECK_LIB(attr, fgetxattr, LIBS="$LIBS -lattr",,)],,),)
3866
Bram Moolenaard6d30422018-01-28 22:48:55 +01003867 AC_MSG_CHECKING(for POSIX ACL support)
3868 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003869#include <sys/types.h>
3870#ifdef HAVE_SYS_ACL_H
3871# include <sys/acl.h>
3872#endif
3873acl_t acl;], [acl = acl_get_file("foo", ACL_TYPE_ACCESS);
3874 acl_set_file("foo", ACL_TYPE_ACCESS, acl);
3875 acl_free(acl);],
3876 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_ACL),
3877 AC_MSG_RESULT(no))
3878
Bram Moolenaard6d30422018-01-28 22:48:55 +01003879 AC_CHECK_LIB(sec, acl_get, [LIBS="$LIBS -lsec"; AC_DEFINE(HAVE_SOLARIS_ZFS_ACL)],
3880 AC_MSG_CHECKING(for Solaris ACL support)
3881 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003882#ifdef HAVE_SYS_ACL_H
3883# include <sys/acl.h>
3884#endif], [acl("foo", GETACLCNT, 0, NULL);
3885 ],
3886 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOLARIS_ACL),
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003887 AC_MSG_RESULT(no)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003888
Bram Moolenaard6d30422018-01-28 22:48:55 +01003889 AC_MSG_CHECKING(for AIX ACL support)
3890 AC_TRY_LINK([
Bram Moolenaar446cb832008-06-24 21:56:24 +00003891#if STDC_HEADERS
3892# include <stdlib.h>
3893# include <stddef.h>
3894#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003895#ifdef HAVE_SYS_ACL_H
3896# include <sys/acl.h>
3897#endif
3898#ifdef HAVE_SYS_ACCESS_H
3899# include <sys/access.h>
3900#endif
3901#define _ALL_SOURCE
3902
3903#include <sys/stat.h>
3904
3905int aclsize;
3906struct acl *aclent;], [aclsize = sizeof(struct acl);
3907 aclent = (void *)malloc(aclsize);
3908 statacl("foo", STX_NORMAL, aclent, aclsize);
3909 ],
3910 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_AIX_ACL),
3911 AC_MSG_RESULT(no))
3912else
3913 AC_MSG_RESULT(yes)
3914fi
3915
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02003916if test "x$GTK_CFLAGS" != "x"; then
3917 dnl pango_shape_full() is new, fall back to pango_shape().
3918 AC_MSG_CHECKING(for pango_shape_full)
3919 ac_save_CFLAGS="$CFLAGS"
3920 ac_save_LIBS="$LIBS"
3921 CFLAGS="$CFLAGS $GTK_CFLAGS"
3922 LIBS="$LIBS $GTK_LIBS"
Bram Moolenaar5325b9b2015-09-09 20:27:02 +02003923 AC_TRY_LINK(
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02003924 [#include <gtk/gtk.h>],
3925 [ pango_shape_full(NULL, 0, NULL, 0, NULL, NULL); ],
3926 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_PANGO_SHAPE_FULL),
3927 AC_MSG_RESULT(no))
3928 CFLAGS="$ac_save_CFLAGS"
3929 LIBS="$ac_save_LIBS"
3930fi
3931
Bram Moolenaar071d4272004-06-13 20:20:40 +00003932AC_MSG_CHECKING(--disable-gpm argument)
3933AC_ARG_ENABLE(gpm,
3934 [ --disable-gpm Don't use gpm (Linux mouse daemon).], ,
3935 [enable_gpm="yes"])
3936
3937if test "$enable_gpm" = "yes"; then
3938 AC_MSG_RESULT(no)
3939 dnl Checking if gpm support can be compiled
3940 AC_CACHE_CHECK([for gpm], vi_cv_have_gpm,
3941 [olibs="$LIBS" ; LIBS="-lgpm"]
3942 AC_TRY_LINK(
3943 [#include <gpm.h>
3944 #include <linux/keyboard.h>],
3945 [Gpm_GetLibVersion(NULL);],
3946 dnl Configure defines HAVE_GPM, if it is defined feature.h defines
3947 dnl FEAT_MOUSE_GPM if mouse support is included
3948 [vi_cv_have_gpm=yes],
3949 [vi_cv_have_gpm=no])
3950 [LIBS="$olibs"]
3951 )
3952 if test $vi_cv_have_gpm = yes; then
3953 LIBS="$LIBS -lgpm"
3954 AC_DEFINE(HAVE_GPM)
3955 fi
3956else
3957 AC_MSG_RESULT(yes)
3958fi
3959
Bram Moolenaar446cb832008-06-24 21:56:24 +00003960AC_MSG_CHECKING(--disable-sysmouse argument)
3961AC_ARG_ENABLE(sysmouse,
Bram Moolenaar8008b632017-07-18 21:33:20 +02003962 [ --disable-sysmouse Don't use sysmouse (mouse in *BSD console).], ,
Bram Moolenaar446cb832008-06-24 21:56:24 +00003963 [enable_sysmouse="yes"])
3964
3965if test "$enable_sysmouse" = "yes"; then
3966 AC_MSG_RESULT(no)
3967 dnl Checking if sysmouse support can be compiled
3968 dnl Configure defines HAVE_SYSMOUSE, if it is defined feature.h
3969 dnl defines FEAT_SYSMOUSE if mouse support is included
3970 AC_CACHE_CHECK([for sysmouse], vi_cv_have_sysmouse,
3971 AC_TRY_LINK(
3972 [#include <sys/consio.h>
3973 #include <signal.h>
3974 #include <sys/fbio.h>],
3975 [struct mouse_info mouse;
3976 mouse.operation = MOUSE_MODE;
3977 mouse.operation = MOUSE_SHOW;
3978 mouse.u.mode.mode = 0;
3979 mouse.u.mode.signal = SIGUSR2;],
3980 [vi_cv_have_sysmouse=yes],
3981 [vi_cv_have_sysmouse=no])
3982 )
3983 if test $vi_cv_have_sysmouse = yes; then
3984 AC_DEFINE(HAVE_SYSMOUSE)
3985 fi
3986else
3987 AC_MSG_RESULT(yes)
3988fi
3989
Bram Moolenaarf05da212009-11-17 16:13:15 +00003990dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
3991AC_MSG_CHECKING(for FD_CLOEXEC)
3992AC_TRY_COMPILE(
3993[#if HAVE_FCNTL_H
3994# include <fcntl.h>
3995#endif],
3996[ int flag = FD_CLOEXEC;],
3997 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
3998 AC_MSG_RESULT(not usable))
3999
Bram Moolenaar071d4272004-06-13 20:20:40 +00004000dnl rename needs to be checked separately to work on Nextstep with cc
4001AC_MSG_CHECKING(for rename)
4002AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
4003 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
4004 AC_MSG_RESULT(no))
4005
4006dnl sysctl() may exist but not the arguments we use
4007AC_MSG_CHECKING(for sysctl)
4008AC_TRY_COMPILE(
4009[#include <sys/types.h>
4010#include <sys/sysctl.h>],
4011[ int mib[2], r;
4012 size_t len;
4013
4014 mib[0] = CTL_HW;
4015 mib[1] = HW_USERMEM;
4016 len = sizeof(r);
4017 (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
4018 ],
4019 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL),
4020 AC_MSG_RESULT(not usable))
4021
4022dnl sysinfo() may exist but not be Linux compatible
4023AC_MSG_CHECKING(for sysinfo)
4024AC_TRY_COMPILE(
4025[#include <sys/types.h>
4026#include <sys/sysinfo.h>],
4027[ struct sysinfo sinfo;
4028 int t;
4029
4030 (void)sysinfo(&sinfo);
4031 t = sinfo.totalram;
4032 ],
4033 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
4034 AC_MSG_RESULT(not usable))
4035
Bram Moolenaar914572a2007-05-01 11:37:47 +00004036dnl struct sysinfo may have the mem_unit field or not
4037AC_MSG_CHECKING(for sysinfo.mem_unit)
4038AC_TRY_COMPILE(
4039[#include <sys/types.h>
4040#include <sys/sysinfo.h>],
4041[ struct sysinfo sinfo;
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02004042 sinfo.mem_unit = 1;
Bram Moolenaar914572a2007-05-01 11:37:47 +00004043 ],
4044 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_MEM_UNIT),
4045 AC_MSG_RESULT(no))
4046
Bram Moolenaar071d4272004-06-13 20:20:40 +00004047dnl sysconf() may exist but not support what we want to use
4048AC_MSG_CHECKING(for sysconf)
4049AC_TRY_COMPILE(
4050[#include <unistd.h>],
4051[ (void)sysconf(_SC_PAGESIZE);
4052 (void)sysconf(_SC_PHYS_PAGES);
4053 ],
4054 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
4055 AC_MSG_RESULT(not usable))
4056
Bram Moolenaar914703b2010-05-31 21:59:46 +02004057AC_CHECK_SIZEOF([int])
4058AC_CHECK_SIZEOF([long])
4059AC_CHECK_SIZEOF([time_t])
4060AC_CHECK_SIZEOF([off_t])
Bram Moolenaar644fdff2010-05-30 13:26:21 +02004061
Bram Moolenaara2aa31a2014-02-23 22:52:40 +01004062dnl Use different names to avoid clashing with other header files.
4063AC_DEFINE_UNQUOTED(VIM_SIZEOF_INT, [$ac_cv_sizeof_int])
4064AC_DEFINE_UNQUOTED(VIM_SIZEOF_LONG, [$ac_cv_sizeof_long])
4065
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004066dnl Make sure that uint32_t is really 32 bits unsigned.
4067AC_MSG_CHECKING([uint32_t is 32 bits])
4068AC_TRY_RUN([
4069#ifdef HAVE_STDINT_H
4070# include <stdint.h>
4071#endif
4072#ifdef HAVE_INTTYPES_H
4073# include <inttypes.h>
4074#endif
4075main() {
4076 uint32_t nr1 = (uint32_t)-1;
4077 uint32_t nr2 = (uint32_t)0xffffffffUL;
4078 if (sizeof(uint32_t) != 4 || nr1 != 0xffffffffUL || nr2 + 1 != 0) exit(1);
4079 exit(0);
4080}],
4081AC_MSG_RESULT(ok),
4082AC_MSG_ERROR([WRONG! uint32_t not defined correctly.]),
Bram Moolenaar323cb952011-12-14 19:22:34 +01004083AC_MSG_WARN([cannot check uint32_t when cross-compiling.]))
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004084
Bram Moolenaar446cb832008-06-24 21:56:24 +00004085dnl Check for memmove() before bcopy(), makes memmove() be used when both are
4086dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
4087
Bram Moolenaar071d4272004-06-13 20:20:40 +00004088[bcopy_test_prog='
Bram Moolenaar446cb832008-06-24 21:56:24 +00004089#include "confdefs.h"
4090#ifdef HAVE_STRING_H
4091# include <string.h>
4092#endif
4093#if STDC_HEADERS
4094# include <stdlib.h>
4095# include <stddef.h>
4096#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004097main() {
4098 char buf[10];
4099 strcpy(buf, "abcdefghi");
4100 mch_memmove(buf, buf + 2, 3);
4101 if (strncmp(buf, "ababcf", 6))
4102 exit(1);
4103 strcpy(buf, "abcdefghi");
4104 mch_memmove(buf + 2, buf, 3);
4105 if (strncmp(buf, "cdedef", 6))
4106 exit(1);
4107 exit(0); /* libc version works properly. */
4108}']
4109
Bram Moolenaar446cb832008-06-24 21:56:24 +00004110AC_CACHE_CHECK([whether memmove handles overlaps],[vim_cv_memmove_handles_overlap],
4111 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004112 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 +00004113 [
4114 vim_cv_memmove_handles_overlap=yes
4115 ],[
4116 vim_cv_memmove_handles_overlap=no
4117 ],[
4118 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memmove_handles_overlap')
4119 ])
4120 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00004121
Bram Moolenaar446cb832008-06-24 21:56:24 +00004122if test "x$vim_cv_memmove_handles_overlap" = "xyes" ; then
4123 AC_DEFINE(USEMEMMOVE)
4124else
4125 AC_CACHE_CHECK([whether bcopy handles overlaps],[vim_cv_bcopy_handles_overlap],
4126 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004127 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 +00004128 [
4129 vim_cv_bcopy_handles_overlap=yes
4130 ],[
4131 vim_cv_bcopy_handles_overlap=no
4132 ],[
4133 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_bcopy_handles_overlap')
4134 ])
4135 ])
4136
4137 if test "x$vim_cv_bcopy_handles_overlap" = "xyes" ; then
4138 AC_DEFINE(USEBCOPY)
4139 else
4140 AC_CACHE_CHECK([whether memcpy handles overlaps],[vim_cv_memcpy_handles_overlap],
4141 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004142 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 +00004143 [
4144 vim_cv_memcpy_handles_overlap=yes
4145 ],[
4146 vim_cv_memcpy_handles_overlap=no
4147 ],[
4148 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memcpy_handles_overlap')
4149 ])
4150 ])
4151
4152 if test "x$vim_cv_memcpy_handles_overlap" = "xyes" ; then
4153 AC_DEFINE(USEMEMCPY)
4154 fi
4155 fi
4156fi
4157
Bram Moolenaar071d4272004-06-13 20:20:40 +00004158
4159dnl Check for multibyte locale functions
4160dnl Find out if _Xsetlocale() is supported by libX11.
4161dnl Check if X_LOCALE should be defined.
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004162if test "x$with_x" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004163 cflags_save=$CFLAGS
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004164 libs_save=$LIBS
4165 LIBS="$LIBS $X_LIBS $GUI_LIB_LOC $GUI_X_LIBS $X_PRE_LIBS $X_LIB $X_EXTRA_LIBS"
4166 CFLAGS="$CFLAGS $X_CFLAGS"
4167
4168 AC_MSG_CHECKING(whether X_LOCALE needed)
4169 AC_TRY_COMPILE([#include <X11/Xlocale.h>],,
4170 AC_TRY_LINK_FUNC([_Xsetlocale], [AC_MSG_RESULT(yes)
4171 AC_DEFINE(X_LOCALE)], AC_MSG_RESULT(no)),
4172 AC_MSG_RESULT(no))
4173
4174 AC_MSG_CHECKING(whether Xutf8SetWMProperties() can be used)
4175 AC_TRY_LINK_FUNC([Xutf8SetWMProperties], [AC_MSG_RESULT(yes)
4176 AC_DEFINE(HAVE_XUTF8SETWMPROPERTIES)], AC_MSG_RESULT(no))
4177
Bram Moolenaar071d4272004-06-13 20:20:40 +00004178 CFLAGS=$cflags_save
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004179 LIBS=$libs_save
Bram Moolenaar071d4272004-06-13 20:20:40 +00004180fi
4181
4182dnl Link with xpg4, it is said to make Korean locale working
4183AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,)
4184
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004185dnl Check how we can run ctags. Default to "ctags" when nothing works.
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02004186dnl Use --version to detect Exuberant ctags (preferred)
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004187dnl Add --fields=+S to get function signatures for omni completion.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004188dnl -t for typedefs (many ctags have this)
4189dnl -s for static functions (Elvis ctags only?)
4190dnl -v for variables. Dangerous, most ctags take this for 'vgrind style'.
4191dnl -i+m to test for older Exuberant ctags
4192AC_MSG_CHECKING(how to create tags)
4193test -f tags && mv tags tags.save
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004194if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004195 TAGPRG="ctags -I INIT+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004196elif (eval exctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
4197 TAGPRG="exctags -I INIT+ --fields=+S"
4198elif (eval exuberant-ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
4199 TAGPRG="exuberant-ctags -I INIT+ --fields=+S"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004200else
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004201 TAGPRG="ctags"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004202 (eval etags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags"
4203 (eval etags -c /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags -c"
4204 (eval ctags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags"
4205 (eval ctags -t /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -t"
4206 (eval ctags -ts /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -ts"
4207 (eval ctags -tvs /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -tvs"
4208 (eval ctags -i+m /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -i+m"
4209fi
4210test -f tags.save && mv tags.save tags
4211AC_MSG_RESULT($TAGPRG) AC_SUBST(TAGPRG)
4212
4213dnl Check how we can run man with a section number
4214AC_MSG_CHECKING(how to run man with a section nr)
4215MANDEF="man"
Bram Moolenaar8b131502008-02-13 09:28:19 +00004216(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 +00004217AC_MSG_RESULT($MANDEF)
4218if test "$MANDEF" = "man -s"; then
4219 AC_DEFINE(USEMAN_S)
4220fi
4221
4222dnl Check if gettext() is working and if it needs -lintl
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004223dnl We take care to base this on an empty LIBS: on some systems libelf would be
4224dnl in LIBS and implicitly take along libintl. The final LIBS would then not
4225dnl contain libintl, and the link step would fail due to -Wl,--as-needed.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004226AC_MSG_CHECKING(--disable-nls argument)
4227AC_ARG_ENABLE(nls,
4228 [ --disable-nls Don't support NLS (gettext()).], ,
4229 [enable_nls="yes"])
4230
4231if test "$enable_nls" = "yes"; then
4232 AC_MSG_RESULT(no)
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00004233
4234 INSTALL_LANGS=install-languages
4235 AC_SUBST(INSTALL_LANGS)
4236 INSTALL_TOOL_LANGS=install-tool-languages
4237 AC_SUBST(INSTALL_TOOL_LANGS)
4238
Bram Moolenaar071d4272004-06-13 20:20:40 +00004239 AC_CHECK_PROG(MSGFMT, msgfmt, msgfmt, )
4240 AC_MSG_CHECKING([for NLS])
4241 if test -f po/Makefile; then
4242 have_gettext="no"
4243 if test -n "$MSGFMT"; then
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004244 olibs=$LIBS
4245 LIBS=""
Bram Moolenaar071d4272004-06-13 20:20:40 +00004246 AC_TRY_LINK(
4247 [#include <libintl.h>],
4248 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004249 AC_MSG_RESULT([gettext() works]); have_gettext="yes"; LIBS=$olibs,
4250 LIBS="-lintl"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004251 AC_TRY_LINK(
4252 [#include <libintl.h>],
4253 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004254 AC_MSG_RESULT([gettext() works with -lintl]); have_gettext="yes";
4255 LIBS="$olibs -lintl",
Bram Moolenaar071d4272004-06-13 20:20:40 +00004256 AC_MSG_RESULT([gettext() doesn't work]);
4257 LIBS=$olibs))
4258 else
4259 AC_MSG_RESULT([msgfmt not found - disabled]);
4260 fi
Bram Moolenaar278eb582014-07-30 13:22:52 +02004261 if test $have_gettext = "yes" -a "x$features" != "xtiny" -a "x$features" != "xsmall"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004262 AC_DEFINE(HAVE_GETTEXT)
4263 MAKEMO=yes
4264 AC_SUBST(MAKEMO)
4265 dnl this was added in GNU gettext 0.10.36
4266 AC_CHECK_FUNCS(bind_textdomain_codeset)
4267 dnl _nl_msg_cat_cntr is required for GNU gettext
4268 AC_MSG_CHECKING([for _nl_msg_cat_cntr])
4269 AC_TRY_LINK(
4270 [#include <libintl.h>
4271 extern int _nl_msg_cat_cntr;],
4272 [++_nl_msg_cat_cntr;],
4273 AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_NL_MSG_CAT_CNTR),
4274 AC_MSG_RESULT([no]))
4275 fi
4276 else
4277 AC_MSG_RESULT([no "po/Makefile" - disabled]);
4278 fi
4279else
4280 AC_MSG_RESULT(yes)
4281fi
4282
4283dnl Check for dynamic linking loader
4284AC_CHECK_HEADER(dlfcn.h, DLL=dlfcn.h, [AC_CHECK_HEADER(dl.h, DLL=dl.h)])
4285if test x${DLL} = xdlfcn.h; then
4286 AC_DEFINE(HAVE_DLFCN_H, 1, [ Define if we have dlfcn.h. ])
4287 AC_MSG_CHECKING([for dlopen()])
4288 AC_TRY_LINK(,[
4289 extern void* dlopen();
4290 dlopen();
4291 ],
4292 AC_MSG_RESULT(yes);
4293 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4294 AC_MSG_RESULT(no);
4295 AC_MSG_CHECKING([for dlopen() in -ldl])
4296 olibs=$LIBS
4297 LIBS="$LIBS -ldl"
4298 AC_TRY_LINK(,[
4299 extern void* dlopen();
4300 dlopen();
4301 ],
4302 AC_MSG_RESULT(yes);
4303 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4304 AC_MSG_RESULT(no);
4305 LIBS=$olibs))
4306 dnl ReliantUNIX has dlopen() in libc but everything else in libdl
4307 dnl ick :-)
4308 AC_MSG_CHECKING([for dlsym()])
4309 AC_TRY_LINK(,[
4310 extern void* dlsym();
4311 dlsym();
4312 ],
4313 AC_MSG_RESULT(yes);
4314 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4315 AC_MSG_RESULT(no);
4316 AC_MSG_CHECKING([for dlsym() in -ldl])
4317 olibs=$LIBS
4318 LIBS="$LIBS -ldl"
4319 AC_TRY_LINK(,[
4320 extern void* dlsym();
4321 dlsym();
4322 ],
4323 AC_MSG_RESULT(yes);
4324 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4325 AC_MSG_RESULT(no);
4326 LIBS=$olibs))
4327elif test x${DLL} = xdl.h; then
4328 AC_DEFINE(HAVE_DL_H, 1, [ Define if we have dl.h. ])
4329 AC_MSG_CHECKING([for shl_load()])
4330 AC_TRY_LINK(,[
4331 extern void* shl_load();
4332 shl_load();
4333 ],
4334 AC_MSG_RESULT(yes);
4335 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4336 AC_MSG_RESULT(no);
4337 AC_MSG_CHECKING([for shl_load() in -ldld])
4338 olibs=$LIBS
4339 LIBS="$LIBS -ldld"
4340 AC_TRY_LINK(,[
4341 extern void* shl_load();
4342 shl_load();
4343 ],
4344 AC_MSG_RESULT(yes);
4345 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4346 AC_MSG_RESULT(no);
4347 LIBS=$olibs))
4348fi
4349AC_CHECK_HEADERS(setjmp.h)
4350
Bram Moolenaard0573012017-10-28 21:11:06 +02004351if test "x$MACOS_X" = "xyes" -a -n "$PERL"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004352 dnl -ldl must come after DynaLoader.a
4353 if echo $LIBS | grep -e '-ldl' >/dev/null; then
4354 LIBS=`echo $LIBS | sed s/-ldl//`
4355 PERL_LIBS="$PERL_LIBS -ldl"
4356 fi
4357fi
4358
Bram Moolenaard0573012017-10-28 21:11:06 +02004359if test "$MACOS_X" = "yes"; then
4360 AC_MSG_CHECKING([whether we need macOS frameworks])
4361 if test "$GUITYPE" = "CARBONGUI"; then
4362 AC_MSG_RESULT([yes, we need Carbon])
4363 LIBS="$LIBS -framework Carbon"
4364 elif test "$MACOS_X_DARWIN" = "yes"; then
4365 if test "$features" = "tiny"; then
4366 dnl Since no FEAT_CLIPBOARD, no longer need for os_macosx.m.
4367 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_macosx.m++'`
4368 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_macosx.o++'`
4369 if test "$enable_multibyte" = "yes"; then
4370 AC_MSG_RESULT([yes, we need CoreServices])
4371 LIBS="$LIBS -framework CoreServices"
4372 else
4373 dnl Since no FEAT_MBYTE, no longer need for os_mac_conv.c.
4374 AC_MSG_RESULT([no])
4375 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_mac_conv.c++'`
4376 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_mac_conv.o++'`
4377 CPPFLAGS=`echo "$CPPFLAGS" | sed -e 's+-DMACOS_X_DARWIN++'`
4378 fi
4379 else
4380 AC_MSG_RESULT([yes, we need AppKit])
4381 LIBS="$LIBS -framework AppKit"
4382 if test "$features" = "small" -a "$enable_multibyte" = "no"; then
4383 dnl Since FEAT_CLIPBOARD is to be defined in vim.h for FEAT_SMALL, define
4384 dnl FEAT_MBYTE in order not to compromise the interoperability of the
4385 dnl clipboard.
4386 AC_MSG_NOTICE([+multi_byte will be set in favor of +clipboard])
4387 enable_multibyte=yes
4388 AC_DEFINE(FEAT_MBYTE)
4389 fi
4390 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004391 else
Bram Moolenaard0573012017-10-28 21:11:06 +02004392 AC_MSG_RESULT([no])
Bram Moolenaar3437b912013-07-03 19:52:53 +02004393 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004394fi
Bram Moolenaar164fca32010-07-14 13:58:07 +02004395if test "x$MACARCH" = "xboth" && test "x$GUITYPE" = "xCARBONGUI"; then
Bram Moolenaar595a7be2010-03-10 16:28:12 +01004396 LDFLAGS="$LDFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +00004397fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004398
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004399dnl gcc 3.1 changed the meaning of -MM. The only solution appears to be to
4400dnl use "-isystem" instead of "-I" for all non-Vim include dirs.
4401dnl But only when making dependencies, cproto and lint don't take "-isystem".
Bram Moolenaar32466aa2006-02-24 23:53:04 +00004402dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
4403dnl the number before the version number.
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004404DEPEND_CFLAGS_FILTER=
4405if test "$GCC" = yes; then
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004406 AC_MSG_CHECKING(for GCC 3 or later)
Bram Moolenaar2217cae2006-03-25 21:55:52 +00004407 gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]]\)\..*$/\1/g'`
Bram Moolenaarf740b292006-02-16 22:11:02 +00004408 if test "$gccmajor" -gt "2"; then
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004409 DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004410 AC_MSG_RESULT(yes)
4411 else
4412 AC_MSG_RESULT(no)
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004413 fi
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004414 dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
4415 dnl declared as char x[1] but actually longer. Introduced in gcc 4.0.
Bram Moolenaar56d1db32009-12-16 16:14:51 +00004416 dnl Also remove duplicate _FORTIFY_SOURCE arguments.
Bram Moolenaaraeabe052011-12-08 15:17:34 +01004417 dnl And undefine it first to avoid a warning.
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004418 AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
4419 if test "$gccmajor" -gt "3"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02004420 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 Moolenaar0cd49302008-11-20 09:37:01 +00004421 AC_MSG_RESULT(yes)
4422 else
4423 AC_MSG_RESULT(no)
4424 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +00004425fi
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004426AC_SUBST(DEPEND_CFLAGS_FILTER)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004427
Bram Moolenaarec0557f2018-01-31 14:41:37 +01004428dnl On some systems AC_SYS_LARGEFILE determines that -D_FILE_OFFSET_BITS=64
4429dnl isn't required, but the CFLAGS for some of the libraries we're using
4430dnl include the define. Since the define changes the size of some datatypes
4431dnl (e.g. ino_t and off_t), all of Vim's modules must be compiled with a
4432dnl consistent value. It's therefore safest to force the use of the define
4433dnl if it's present in any of the *_CFLAGS variables.
4434AC_MSG_CHECKING(whether we need to force -D_FILE_OFFSET_BITS=64)
Bram Moolenaar9ce42132018-04-11 22:19:36 +02004435if 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 +01004436 AC_MSG_RESULT(yes)
4437 AC_DEFINE(_FILE_OFFSET_BITS, 64)
4438else
4439 AC_MSG_RESULT(no)
4440fi
4441
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004442dnl link.sh tries to avoid overlinking in a hackish way.
4443dnl At least GNU ld supports --as-needed which provides the same functionality
4444dnl at linker level. Let's use it.
4445AC_MSG_CHECKING(linker --as-needed support)
4446LINK_AS_NEEDED=
4447# Check if linker supports --as-needed and --no-as-needed options
4448if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02004449 LDFLAGS=`echo "$LDFLAGS" | sed -e 's/ *-Wl,--as-needed//g' | sed -e 's/$/ -Wl,--as-needed/'`
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004450 LINK_AS_NEEDED=yes
4451fi
4452if test "$LINK_AS_NEEDED" = yes; then
4453 AC_MSG_RESULT(yes)
4454else
4455 AC_MSG_RESULT(no)
4456fi
4457AC_SUBST(LINK_AS_NEEDED)
4458
Bram Moolenaar77c19352012-06-13 19:19:41 +02004459# IBM z/OS reset CFLAGS for config.mk
4460if test "$zOSUnix" = "yes"; then
4461 CFLAGS="-D_ALL_SOURCE -Wc,float\(ieee\),dll"
4462fi
4463
Bram Moolenaar071d4272004-06-13 20:20:40 +00004464dnl write output files
4465AC_OUTPUT(auto/config.mk:config.mk.in)
4466
4467dnl vim: set sw=2 tw=78 fo+=l: