blob: 0d8ea32d34340a556db0a004e6dce2b0c6335800 [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 Moolenaar3ca71f12010-10-27 16:49:47 +02001959 AC_DEFINE(DYNAMIC_RUBY)
Bram Moolenaar92021622017-10-12 12:33:43 +02001960 RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby_soname\\\" -DDYNAMIC_RUBY_VER=$rubyversion $RUBY_CFLAGS"
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001961 RUBY_LIBS=
1962 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001963 else
Bram Moolenaar165641d2010-02-17 16:23:09 +01001964 AC_MSG_RESULT(not found; disabling Ruby)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001965 fi
1966 else
1967 AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
1968 fi
1969 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001970
1971 if test "$fail_if_missing" = "yes" -a -z "$RUBY_OBJ"; then
1972 AC_MSG_ERROR([could not configure Ruby])
1973 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001974fi
1975AC_SUBST(RUBY_SRC)
1976AC_SUBST(RUBY_OBJ)
1977AC_SUBST(RUBY_PRO)
1978AC_SUBST(RUBY_CFLAGS)
1979AC_SUBST(RUBY_LIBS)
1980
1981AC_MSG_CHECKING(--enable-cscope argument)
1982AC_ARG_ENABLE(cscope,
1983 [ --enable-cscope Include cscope interface.], ,
1984 [enable_cscope="no"])
1985AC_MSG_RESULT($enable_cscope)
1986if test "$enable_cscope" = "yes"; then
1987 AC_DEFINE(FEAT_CSCOPE)
1988fi
1989
1990AC_MSG_CHECKING(--enable-workshop argument)
1991AC_ARG_ENABLE(workshop,
1992 [ --enable-workshop Include Sun Visual Workshop support.], ,
1993 [enable_workshop="no"])
1994AC_MSG_RESULT($enable_workshop)
1995if test "$enable_workshop" = "yes"; then
1996 AC_DEFINE(FEAT_SUN_WORKSHOP)
1997 WORKSHOP_SRC="workshop.c integration.c"
1998 AC_SUBST(WORKSHOP_SRC)
1999 WORKSHOP_OBJ="objects/workshop.o objects/integration.o"
2000 AC_SUBST(WORKSHOP_OBJ)
2001 if test "${enable_gui-xxx}" = xxx; then
2002 enable_gui=motif
2003 fi
2004fi
2005
2006AC_MSG_CHECKING(--disable-netbeans argument)
2007AC_ARG_ENABLE(netbeans,
2008 [ --disable-netbeans Disable NetBeans integration support.],
2009 , [enable_netbeans="yes"])
2010if test "$enable_netbeans" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002011 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2012 AC_MSG_RESULT([cannot use NetBeans with tiny or small features])
2013 enable_netbeans="no"
2014 else
2015 AC_MSG_RESULT(no)
2016 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002017else
2018 AC_MSG_RESULT(yes)
2019fi
2020
2021AC_MSG_CHECKING(--disable-channel argument)
2022AC_ARG_ENABLE(channel,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002023 [ --disable-channel Disable process communication support.],
Bram Moolenaare0874f82016-01-24 20:36:41 +01002024 , [enable_channel="yes"])
2025if test "$enable_channel" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002026 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2027 AC_MSG_RESULT([cannot use channels with tiny or small features])
2028 enable_channel="no"
2029 else
2030 AC_MSG_RESULT(no)
2031 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002032else
2033 if test "$enable_netbeans" = "yes"; then
Bram Moolenaar16435482016-01-24 21:31:54 +01002034 AC_MSG_RESULT([yes, netbeans also disabled])
Bram Moolenaare0874f82016-01-24 20:36:41 +01002035 enable_netbeans="no"
2036 else
2037 AC_MSG_RESULT(yes)
2038 fi
2039fi
2040
Bram Moolenaar16435482016-01-24 21:31:54 +01002041if test "$enable_channel" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002042 dnl On Solaris we need the socket and nsl library.
2043 AC_CHECK_LIB(socket, socket)
2044 AC_CHECK_LIB(nsl, gethostbyname)
Bram Moolenaare0874f82016-01-24 20:36:41 +01002045 AC_MSG_CHECKING(whether compiling with process communication is possible)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002046 AC_TRY_LINK([
2047#include <stdio.h>
2048#include <stdlib.h>
2049#include <stdarg.h>
2050#include <fcntl.h>
2051#include <netdb.h>
2052#include <netinet/in.h>
2053#include <errno.h>
2054#include <sys/types.h>
2055#include <sys/socket.h>
2056 /* Check bitfields */
2057 struct nbbuf {
2058 unsigned int initDone:1;
Bram Moolenaar63de19e2016-12-09 20:11:26 +01002059 unsigned short signmaplen;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002060 };
2061 ], [
2062 /* Check creating a socket. */
2063 struct sockaddr_in server;
2064 (void)socket(AF_INET, SOCK_STREAM, 0);
2065 (void)htons(100);
2066 (void)gethostbyname("microsoft.com");
2067 if (errno == ECONNREFUSED)
2068 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
2069 ],
2070 AC_MSG_RESULT(yes),
Bram Moolenaare0874f82016-01-24 20:36:41 +01002071 AC_MSG_RESULT(no); enable_netbeans="no"; enable_channel="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00002072fi
2073if test "$enable_netbeans" = "yes"; then
2074 AC_DEFINE(FEAT_NETBEANS_INTG)
2075 NETBEANS_SRC="netbeans.c"
2076 AC_SUBST(NETBEANS_SRC)
2077 NETBEANS_OBJ="objects/netbeans.o"
2078 AC_SUBST(NETBEANS_OBJ)
2079fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002080if test "$enable_channel" = "yes"; then
Bram Moolenaar509ce2a2016-03-11 22:52:15 +01002081 AC_DEFINE(FEAT_JOB_CHANNEL)
Bram Moolenaare0874f82016-01-24 20:36:41 +01002082 CHANNEL_SRC="channel.c"
2083 AC_SUBST(CHANNEL_SRC)
2084 CHANNEL_OBJ="objects/channel.o"
2085 AC_SUBST(CHANNEL_OBJ)
2086fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002087
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002088AC_MSG_CHECKING(--enable-terminal argument)
2089AC_ARG_ENABLE(terminal,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002090 [ --enable-terminal Enable terminal emulation support.],
Bram Moolenaaref839562017-10-28 20:28:23 +02002091 , [enable_terminal="auto"])
Bram Moolenaar595a4022017-09-03 19:15:57 +02002092if test "$enable_terminal" = "yes" || test "$enable_terminal" = "auto" -a "x$features" = "xhuge" ; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002093 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2094 AC_MSG_RESULT([cannot use terminal emulator with tiny or small features])
2095 enable_terminal="no"
2096 else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002097 if test "$enable_terminal" = "auto"; then
2098 enable_terminal="yes"
2099 AC_MSG_RESULT(defaulting to yes)
2100 else
2101 AC_MSG_RESULT(yes)
2102 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002103 fi
2104else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002105 if test "$enable_terminal" = "auto"; then
2106 enable_terminal="no"
2107 AC_MSG_RESULT(defaulting to no)
2108 else
2109 AC_MSG_RESULT(no)
2110 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002111fi
Bram Moolenaar8b423282017-12-16 14:37:06 +01002112if test "$enable_terminal" = "yes" -a "$enable_channel" = "yes"; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002113 AC_DEFINE(FEAT_TERMINAL)
2114 TERM_SRC="libvterm/src/encoding.c libvterm/src/keyboard.c libvterm/src/mouse.c libvterm/src/parser.c libvterm/src/pen.c libvterm/src/screen.c libvterm/src/state.c libvterm/src/unicode.c libvterm/src/vterm.c"
2115 AC_SUBST(TERM_SRC)
2116 TERM_OBJ="objects/term_encoding.o objects/term_keyboard.o objects/term_mouse.o objects/term_parser.o objects/term_pen.o objects/term_screen.o objects/term_state.o objects/term_unicode.o objects/term_vterm.o"
2117 AC_SUBST(TERM_OBJ)
2118fi
2119
Bram Moolenaare42a6d22017-11-12 19:21:51 +01002120AC_MSG_CHECKING(--enable-autoservername argument)
2121AC_ARG_ENABLE(autoservername,
2122 [ --enable-autoservername Automatically define servername at vim startup.], ,
2123 [enable_autoservername="no"])
2124AC_MSG_RESULT($enable_autoservername)
2125if test "$enable_autoservername" = "yes"; then
2126 AC_DEFINE(FEAT_AUTOSERVERNAME)
2127fi
2128
Bram Moolenaar071d4272004-06-13 20:20:40 +00002129AC_MSG_CHECKING(--enable-multibyte argument)
2130AC_ARG_ENABLE(multibyte,
2131 [ --enable-multibyte Include multibyte editing support.], ,
2132 [enable_multibyte="no"])
2133AC_MSG_RESULT($enable_multibyte)
2134if test "$enable_multibyte" = "yes"; then
2135 AC_DEFINE(FEAT_MBYTE)
2136fi
2137
2138AC_MSG_CHECKING(--enable-hangulinput argument)
2139AC_ARG_ENABLE(hangulinput,
2140 [ --enable-hangulinput Include Hangul input support.], ,
2141 [enable_hangulinput="no"])
2142AC_MSG_RESULT($enable_hangulinput)
2143
2144AC_MSG_CHECKING(--enable-xim argument)
2145AC_ARG_ENABLE(xim,
2146 [ --enable-xim Include XIM input support.],
2147 AC_MSG_RESULT($enable_xim),
2148 [enable_xim="auto"; AC_MSG_RESULT(defaulting to auto)])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002149
2150AC_MSG_CHECKING(--enable-fontset argument)
2151AC_ARG_ENABLE(fontset,
2152 [ --enable-fontset Include X fontset output support.], ,
2153 [enable_fontset="no"])
2154AC_MSG_RESULT($enable_fontset)
2155dnl defining FEAT_XFONTSET is delayed, so that it can be disabled for no GUI
2156
2157test -z "$with_x" && with_x=yes
Bram Moolenaard0573012017-10-28 21:11:06 +02002158test "${enable_gui-yes}" != no -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && with_x=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002159if test "$with_x" = no; then
2160 AC_MSG_RESULT(defaulting to: don't HAVE_X11)
2161else
2162 dnl Do this check early, so that its failure can override user requests.
2163
2164 AC_PATH_PROG(xmkmfpath, xmkmf)
2165
2166 AC_PATH_XTRA
2167
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002168 dnl On z/OS Unix the X libraries are DLLs. To use them the code must
Bram Moolenaar071d4272004-06-13 20:20:40 +00002169 dnl be compiled with a special option.
2170 dnl Also add SM, ICE and Xmu to X_EXTRA_LIBS.
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002171 if test "$zOSUnix" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002172 CFLAGS="$CFLAGS -W c,dll"
2173 LDFLAGS="$LDFLAGS -W l,dll"
2174 X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE -lXmu"
2175 fi
2176
2177 dnl On my HPUX system the X include dir is found, but the lib dir not.
2178 dnl This is a desparate try to fix this.
2179
2180 if test -d "$x_includes" && test ! -d "$x_libraries"; then
2181 x_libraries=`echo "$x_includes" | sed s/include/lib/`
2182 AC_MSG_RESULT(Corrected X libraries to $x_libraries)
2183 X_LIBS="$X_LIBS -L$x_libraries"
2184 if test "`(uname) 2>/dev/null`" = SunOS &&
2185 uname -r | grep '^5' >/dev/null; then
2186 X_LIBS="$X_LIBS -R $x_libraries"
2187 fi
2188 fi
2189
2190 if test -d "$x_libraries" && test ! -d "$x_includes"; then
2191 x_includes=`echo "$x_libraries" | sed s/lib/include/`
2192 AC_MSG_RESULT(Corrected X includes to $x_includes)
2193 X_CFLAGS="$X_CFLAGS -I$x_includes"
2194 fi
2195
2196 dnl Remove "-I/usr/include " from X_CFLAGS, should not be needed.
2197 X_CFLAGS="`echo $X_CFLAGS\ | sed 's%-I/usr/include %%'`"
2198 dnl Remove "-L/usr/lib " from X_LIBS, should not be needed.
2199 X_LIBS="`echo $X_LIBS\ | sed 's%-L/usr/lib %%'`"
2200 dnl Same for "-R/usr/lib ".
2201 X_LIBS="`echo $X_LIBS\ | sed -e 's%-R/usr/lib %%' -e 's%-R /usr/lib %%'`"
2202
2203
2204 dnl Check if the X11 header files are correctly installed. On some systems
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002205 dnl Xlib.h includes files that don't exist. On some systems X11/Intrinsic.h
2206 dnl is missing.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002207 AC_MSG_CHECKING(if X11 header files can be found)
2208 cflags_save=$CFLAGS
2209 CFLAGS="$CFLAGS $X_CFLAGS"
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002210 AC_TRY_COMPILE([#include <X11/Xlib.h>
2211#include <X11/Intrinsic.h>], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002212 AC_MSG_RESULT(yes),
2213 AC_MSG_RESULT(no); no_x=yes)
2214 CFLAGS=$cflags_save
2215
2216 if test "${no_x-no}" = yes; then
2217 with_x=no
2218 else
2219 AC_DEFINE(HAVE_X11)
2220 X_LIB="-lXt -lX11";
2221 AC_SUBST(X_LIB)
2222
2223 ac_save_LDFLAGS="$LDFLAGS"
2224 LDFLAGS="-L$x_libraries $LDFLAGS"
2225
2226 dnl Check for -lXdmcp (needed on SunOS 4.1.4)
2227 dnl For HP-UX 10.20 it must be before -lSM -lICE
2228 AC_CHECK_LIB(Xdmcp, _XdmcpAuthDoIt, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lXdmcp"],,
2229 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXdmcp])
2230
2231 dnl Some systems need -lnsl -lsocket when testing for ICE.
2232 dnl The check above doesn't do this, try here (again). Also needed to get
2233 dnl them after Xdmcp. link.sh will remove them when not needed.
2234 dnl Check for other function than above to avoid the cached value
2235 AC_CHECK_LIB(ICE, IceOpenConnection,
2236 [X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE"],, [$X_EXTRA_LIBS])
2237
2238 dnl Check for -lXpm (needed for some versions of Motif)
2239 LDFLAGS="$X_LIBS $ac_save_LDFLAGS"
2240 AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [X_PRE_LIBS="$X_PRE_LIBS -lXpm"],,
2241 [-lXt $X_PRE_LIBS -lXpm -lX11 $X_EXTRA_LIBS])
2242
2243 dnl Check that the X11 header files don't use implicit declarations
2244 AC_MSG_CHECKING(if X11 header files implicitly declare return values)
2245 cflags_save=$CFLAGS
Bram Moolenaard1864592013-05-04 04:40:15 +02002246 dnl -Werror is GCC only, others like Solaris Studio might not like it
2247 if test "$GCC" = yes; then
2248 CFLAGS="$CFLAGS $X_CFLAGS -Werror"
2249 else
2250 CFLAGS="$CFLAGS $X_CFLAGS"
2251 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002252 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2253 AC_MSG_RESULT(no),
2254 CFLAGS="$CFLAGS -Wno-implicit-int"
2255 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2256 AC_MSG_RESULT(yes); cflags_save="$cflags_save -Wno-implicit-int",
2257 AC_MSG_RESULT(test failed)
2258 )
2259 )
2260 CFLAGS=$cflags_save
2261
2262 LDFLAGS="$ac_save_LDFLAGS"
2263
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002264 AC_MSG_CHECKING(size of wchar_t is 2 bytes)
2265 AC_CACHE_VAL(ac_cv_small_wchar_t,
2266 [AC_TRY_RUN([
2267#include <X11/Xlib.h>
2268#if STDC_HEADERS
2269# include <stdlib.h>
2270# include <stddef.h>
2271#endif
2272 main()
2273 {
2274 if (sizeof(wchar_t) <= 2)
2275 exit(1);
2276 exit(0);
2277 }],
2278 ac_cv_small_wchar_t="no",
2279 ac_cv_small_wchar_t="yes",
2280 AC_MSG_ERROR(failed to compile test program))])
2281 AC_MSG_RESULT($ac_cv_small_wchar_t)
2282 if test "x$ac_cv_small_wchar_t" = "xyes" ; then
2283 AC_DEFINE(SMALL_WCHAR_T)
2284 fi
2285
Bram Moolenaar071d4272004-06-13 20:20:40 +00002286 fi
2287fi
2288
Bram Moolenaard2a05492018-07-27 22:35:15 +02002289dnl Check if --with-x was given but it doesn't work.
2290if test "x$with_x" = xno -a "x$with_x_arg" = xyes; then
2291 AC_MSG_ERROR([could not configure X])
2292fi
2293
Bram Moolenaard0573012017-10-28 21:11:06 +02002294test "x$with_x" = xno -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && enable_gui=no
Bram Moolenaar071d4272004-06-13 20:20:40 +00002295
2296AC_MSG_CHECKING(--enable-gui argument)
2297AC_ARG_ENABLE(gui,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002298 [ --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 +00002299
2300dnl Canonicalize the --enable-gui= argument so that it can be easily compared.
2301dnl Do not use character classes for portability with old tools.
2302enable_gui_canon=`echo "_$enable_gui" | \
2303 sed 's/[[ _+-]]//g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
2304
2305dnl Skip everything by default.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002306SKIP_GTK2=YES
Bram Moolenaar1858a842016-02-23 22:30:31 +01002307SKIP_GTK3=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002308SKIP_GNOME=YES
2309SKIP_MOTIF=YES
2310SKIP_ATHENA=YES
2311SKIP_NEXTAW=YES
2312SKIP_PHOTON=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002313SKIP_CARBON=YES
2314GUITYPE=NONE
2315
Bram Moolenaarb11160e2005-01-04 21:31:43 +00002316if test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002317 SKIP_PHOTON=
2318 case "$enable_gui_canon" in
2319 no) AC_MSG_RESULT(no GUI support)
2320 SKIP_PHOTON=YES ;;
2321 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
2322 auto) AC_MSG_RESULT(auto - automatic GUI support) ;;
2323 photon) AC_MSG_RESULT(Photon GUI support) ;;
2324 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2325 SKIP_PHOTON=YES ;;
2326 esac
2327
Bram Moolenaard0573012017-10-28 21:11:06 +02002328elif test "x$MACOS_X" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002329 SKIP_CARBON=
2330 case "$enable_gui_canon" in
2331 no) AC_MSG_RESULT(no GUI support)
2332 SKIP_CARBON=YES ;;
2333 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
Bram Moolenaar164fca32010-07-14 13:58:07 +02002334 auto) AC_MSG_RESULT(auto - Carbon GUI is outdated - disable GUI support)
2335 SKIP_CARBON=YES ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002336 carbon) AC_MSG_RESULT(Carbon GUI support) ;;
2337 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2338 SKIP_CARBON=YES ;;
2339 esac
2340
2341else
2342
Bram Moolenaar071d4272004-06-13 20:20:40 +00002343 case "$enable_gui_canon" in
2344 no|none) AC_MSG_RESULT(no GUI support) ;;
2345 yes|""|auto) AC_MSG_RESULT(yes/auto - automatic GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002346 SKIP_GTK2=
2347 SKIP_GNOME=
2348 SKIP_MOTIF=
2349 SKIP_ATHENA=
2350 SKIP_NEXTAW=
2351 SKIP_CARBON=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002352 gtk2) AC_MSG_RESULT(GTK+ 2.x GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002353 SKIP_GTK2=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002354 gnome2) AC_MSG_RESULT(GNOME 2.x GUI support)
2355 SKIP_GNOME=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002356 SKIP_GTK2=;;
Bram Moolenaar98921892016-02-23 17:14:37 +01002357 gtk3) AC_MSG_RESULT(GTK+ 3.x GUI support)
2358 SKIP_GTK3=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002359 motif) AC_MSG_RESULT(Motif GUI support)
2360 SKIP_MOTIF=;;
2361 athena) AC_MSG_RESULT(Athena GUI support)
2362 SKIP_ATHENA=;;
2363 nextaw) AC_MSG_RESULT(neXtaw GUI support)
2364 SKIP_NEXTAW=;;
2365 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
2366 esac
2367
2368fi
2369
Bram Moolenaar071d4272004-06-13 20:20:40 +00002370if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \
2371 -a "$enable_gui_canon" != "gnome2"; then
2372 AC_MSG_CHECKING(whether or not to look for GTK+ 2)
2373 AC_ARG_ENABLE(gtk2-check,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002374 [ --enable-gtk2-check If auto-select GUI, check for GTK+ 2 [default=yes]],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002375 , enable_gtk2_check="yes")
2376 AC_MSG_RESULT($enable_gtk2_check)
2377 if test "x$enable_gtk2_check" = "xno"; then
2378 SKIP_GTK2=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002379 SKIP_GNOME=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002380 fi
2381fi
2382
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002383if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002384 AC_MSG_CHECKING(whether or not to look for GNOME)
2385 AC_ARG_ENABLE(gnome-check,
2386 [ --enable-gnome-check If GTK GUI, check for GNOME [default=no]],
2387 , enable_gnome_check="no")
2388 AC_MSG_RESULT($enable_gnome_check)
2389 if test "x$enable_gnome_check" = "xno"; then
2390 SKIP_GNOME=YES
2391 fi
2392fi
2393
Bram Moolenaar98921892016-02-23 17:14:37 +01002394if test "x$SKIP_GTK3" != "xYES" -a "$enable_gui_canon" != "gtk3"; then
2395 AC_MSG_CHECKING(whether or not to look for GTK+ 3)
2396 AC_ARG_ENABLE(gtk3-check,
2397 [ --enable-gtk3-check If auto-select GUI, check for GTK+ 3 [default=yes]],
2398 , enable_gtk3_check="yes")
2399 AC_MSG_RESULT($enable_gtk3_check)
2400 if test "x$enable_gtk3_check" = "xno"; then
2401 SKIP_GTK3=YES
2402 fi
2403fi
2404
Bram Moolenaar071d4272004-06-13 20:20:40 +00002405if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then
2406 AC_MSG_CHECKING(whether or not to look for Motif)
2407 AC_ARG_ENABLE(motif-check,
2408 [ --enable-motif-check If auto-select GUI, check for Motif [default=yes]],
2409 , enable_motif_check="yes")
2410 AC_MSG_RESULT($enable_motif_check)
2411 if test "x$enable_motif_check" = "xno"; then
2412 SKIP_MOTIF=YES
2413 fi
2414fi
2415
2416if test "x$SKIP_ATHENA" != "xYES" -a "$enable_gui_canon" != "athena"; then
2417 AC_MSG_CHECKING(whether or not to look for Athena)
2418 AC_ARG_ENABLE(athena-check,
2419 [ --enable-athena-check If auto-select GUI, check for Athena [default=yes]],
2420 , enable_athena_check="yes")
2421 AC_MSG_RESULT($enable_athena_check)
2422 if test "x$enable_athena_check" = "xno"; then
2423 SKIP_ATHENA=YES
2424 fi
2425fi
2426
2427if test "x$SKIP_NEXTAW" != "xYES" -a "$enable_gui_canon" != "nextaw"; then
2428 AC_MSG_CHECKING(whether or not to look for neXtaw)
2429 AC_ARG_ENABLE(nextaw-check,
2430 [ --enable-nextaw-check If auto-select GUI, check for neXtaw [default=yes]],
2431 , enable_nextaw_check="yes")
2432 AC_MSG_RESULT($enable_nextaw_check);
2433 if test "x$enable_nextaw_check" = "xno"; then
2434 SKIP_NEXTAW=YES
2435 fi
2436fi
2437
2438if test "x$SKIP_CARBON" != "xYES" -a "$enable_gui_canon" != "carbon"; then
2439 AC_MSG_CHECKING(whether or not to look for Carbon)
2440 AC_ARG_ENABLE(carbon-check,
2441 [ --enable-carbon-check If auto-select GUI, check for Carbon [default=yes]],
2442 , enable_carbon_check="yes")
2443 AC_MSG_RESULT($enable_carbon_check);
2444 if test "x$enable_carbon_check" = "xno"; then
2445 SKIP_CARBON=YES
2446 fi
2447fi
2448
Bram Moolenaar843ee412004-06-30 16:16:41 +00002449
Bram Moolenaard0573012017-10-28 21:11:06 +02002450if test "x$MACOS_X" = "xyes" -a -z "$SKIP_CARBON" -a "x$CARBON" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002451 AC_MSG_CHECKING(for Carbon GUI)
Bram Moolenaar14716812006-05-04 21:54:08 +00002452 dnl already did the check, just give the message
Bram Moolenaar071d4272004-06-13 20:20:40 +00002453 AC_MSG_RESULT(yes);
2454 GUITYPE=CARBONGUI
Bram Moolenaare344bea2005-09-01 20:46:49 +00002455 if test "$VIMNAME" = "vim"; then
2456 VIMNAME=Vim
2457 fi
Bram Moolenaar14716812006-05-04 21:54:08 +00002458
Bram Moolenaar164fca32010-07-14 13:58:07 +02002459 if test "x$MACARCH" = "xboth"; then
2460 CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk/Developer/Headers/FlatCarbon"
2461 else
2462 CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/Headers/FlatCarbon"
2463 fi
2464
Bram Moolenaar14716812006-05-04 21:54:08 +00002465 dnl Default install directory is not /usr/local
2466 if test x$prefix = xNONE; then
2467 prefix=/Applications
2468 fi
2469
2470 dnl Sorry for the hard coded default
2471 datadir='${prefix}/Vim.app/Contents/Resources'
2472
Bram Moolenaar071d4272004-06-13 20:20:40 +00002473 dnl skip everything else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002474 SKIP_GTK2=YES;
2475 SKIP_GNOME=YES;
2476 SKIP_MOTIF=YES;
2477 SKIP_ATHENA=YES;
2478 SKIP_NEXTAW=YES;
2479 SKIP_PHOTON=YES;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002480 SKIP_CARBON=YES
2481fi
2482
Bram Moolenaar071d4272004-06-13 20:20:40 +00002483dnl define an autoconf function to check for a specified version of GTK, and
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002484dnl try to compile/link a GTK program.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002485dnl
2486dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002487dnl Test for GTK, and define GTK_CFLAGS, GTK_LIBDIR and GTK_LIBS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002488dnl
2489AC_DEFUN(AM_PATH_GTK,
2490[
2491 if test "X$GTK_CONFIG" != "Xno" -o "X$PKG_CONFIG" != "Xno"; then
2492 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00002493 no_gtk=""
2494 if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2495 && $PKG_CONFIG --exists gtk+-2.0; then
2496 {
Bram Moolenaar98921892016-02-23 17:14:37 +01002497 min_gtk_version=ifelse([$1], ,2.2.0,$1)
2498 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002499 dnl We should be using PKG_CHECK_MODULES() instead of this hack.
2500 dnl But I guess the dependency on pkgconfig.m4 is not wanted or
2501 dnl something like that.
2502 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0`
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002503 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-2.0`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002504 GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0`
2505 gtk_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2506 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2507 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2508 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2509 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2510 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2511 }
Bram Moolenaar98921892016-02-23 17:14:37 +01002512 elif (test "X$SKIP_GTK3" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2513 && $PKG_CONFIG --exists gtk+-3.0; then
2514 {
2515 min_gtk_version=ifelse([$1], ,3.0.0,$1)
2516 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
2517
2518 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-3.0`
2519 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-3.0`
2520 GTK_LIBS=`$PKG_CONFIG --libs gtk+-3.0`
2521 gtk_major_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2522 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2523 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2524 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2525 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2526 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2527 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002528 else
2529 no_gtk=yes
2530 fi
2531
2532 if test "x$enable_gtktest" = "xyes" -a "x$no_gtk" = "x"; then
2533 {
2534 ac_save_CFLAGS="$CFLAGS"
2535 ac_save_LIBS="$LIBS"
2536 CFLAGS="$CFLAGS $GTK_CFLAGS"
2537 LIBS="$LIBS $GTK_LIBS"
2538
2539 dnl
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002540 dnl Now check if the installed GTK is sufficiently new.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002541 dnl
2542 rm -f conf.gtktest
2543 AC_TRY_RUN([
2544#include <gtk/gtk.h>
2545#include <stdio.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00002546#if STDC_HEADERS
2547# include <stdlib.h>
2548# include <stddef.h>
2549#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002550
2551int
2552main ()
2553{
2554int major, minor, micro;
2555char *tmp_version;
2556
2557system ("touch conf.gtktest");
2558
2559/* HP/UX 9 (%@#!) writes to sscanf strings */
2560tmp_version = g_strdup("$min_gtk_version");
2561if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
2562 printf("%s, bad version string\n", "$min_gtk_version");
2563 exit(1);
2564 }
2565
2566if ((gtk_major_version > major) ||
2567 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
2568 ((gtk_major_version == major) && (gtk_minor_version == minor) &&
2569 (gtk_micro_version >= micro)))
2570{
2571 return 0;
2572}
2573return 1;
2574}
2575],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
2576 CFLAGS="$ac_save_CFLAGS"
2577 LIBS="$ac_save_LIBS"
2578 }
2579 fi
2580 if test "x$no_gtk" = x ; then
2581 if test "x$enable_gtktest" = "xyes"; then
2582 AC_MSG_RESULT(yes; found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2583 else
2584 AC_MSG_RESULT(found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2585 fi
2586 ifelse([$2], , :, [$2])
2587 else
2588 {
2589 AC_MSG_RESULT(no)
2590 GTK_CFLAGS=""
2591 GTK_LIBS=""
2592 ifelse([$3], , :, [$3])
2593 }
2594 fi
2595 }
2596 else
2597 GTK_CFLAGS=""
2598 GTK_LIBS=""
2599 ifelse([$3], , :, [$3])
2600 fi
2601 AC_SUBST(GTK_CFLAGS)
2602 AC_SUBST(GTK_LIBS)
2603 rm -f conf.gtktest
2604])
2605
2606dnl ---------------------------------------------------------------------------
2607dnl gnome
2608dnl ---------------------------------------------------------------------------
2609AC_DEFUN([GNOME_INIT_HOOK],
2610[
2611 AC_SUBST(GNOME_LIBS)
2612 AC_SUBST(GNOME_LIBDIR)
2613 AC_SUBST(GNOME_INCLUDEDIR)
2614
2615 AC_ARG_WITH(gnome-includes,
2616 [ --with-gnome-includes=DIR Specify location of GNOME headers],
2617 [CFLAGS="$CFLAGS -I$withval"]
2618 )
2619
2620 AC_ARG_WITH(gnome-libs,
2621 [ --with-gnome-libs=DIR Specify location of GNOME libs],
2622 [LDFLAGS="$LDFLAGS -L$withval" gnome_prefix=$withval]
2623 )
2624
2625 AC_ARG_WITH(gnome,
2626 [ --with-gnome Specify prefix for GNOME files],
2627 if test x$withval = xyes; then
2628 want_gnome=yes
2629 ifelse([$1], [], :, [$1])
2630 else
2631 if test "x$withval" = xno; then
2632 want_gnome=no
2633 else
2634 want_gnome=yes
2635 LDFLAGS="$LDFLAGS -L$withval/lib"
2636 CFLAGS="$CFLAGS -I$withval/include"
2637 gnome_prefix=$withval/lib
2638 fi
2639 fi,
2640 want_gnome=yes)
2641
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002642 if test "x$want_gnome" = xyes; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002643 {
2644 AC_MSG_CHECKING(for libgnomeui-2.0)
2645 if $PKG_CONFIG --exists libgnomeui-2.0; then
2646 AC_MSG_RESULT(yes)
2647 GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0`
2648 GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0`
2649 GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0`
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002650
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002651 dnl On FreeBSD we need -pthread but pkg-config doesn't include it.
2652 dnl This might not be the right way but it works for me...
2653 AC_MSG_CHECKING(for FreeBSD)
2654 if test "`(uname) 2>/dev/null`" = FreeBSD; then
2655 AC_MSG_RESULT(yes, adding -pthread)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002656 GNOME_INCLUDEDIR="$GNOME_INCLUDEDIR -D_THREAD_SAFE"
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002657 GNOME_LIBS="$GNOME_LIBS -pthread"
2658 else
2659 AC_MSG_RESULT(no)
2660 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002661 $1
2662 else
2663 AC_MSG_RESULT(not found)
2664 if test "x$2" = xfail; then
2665 AC_MSG_ERROR(Could not find libgnomeui-2.0 via pkg-config)
2666 fi
2667 fi
2668 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002669 fi
2670])
2671
2672AC_DEFUN([GNOME_INIT],[
2673 GNOME_INIT_HOOK([],fail)
2674])
2675
2676
2677dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002678dnl Check for GTK2. If it fails, then continue on for Motif as before...
Bram Moolenaar071d4272004-06-13 20:20:40 +00002679dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002680if test -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002681
2682 AC_MSG_CHECKING(--disable-gtktest argument)
2683 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2684 , enable_gtktest=yes)
2685 if test "x$enable_gtktest" = "xyes" ; then
2686 AC_MSG_RESULT(gtk test enabled)
2687 else
2688 AC_MSG_RESULT(gtk test disabled)
2689 fi
2690
Bram Moolenaar071d4272004-06-13 20:20:40 +00002691 if test "X$PKG_CONFIG" = "X"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01002692 AC_PATH_TOOL(PKG_CONFIG, pkg-config, no)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002693 fi
2694
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002695 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002696 dnl First try finding version 2.2.0 or later. The 2.0.x series has
2697 dnl problems (bold fonts, --remote doesn't work).
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002698 AM_PATH_GTK(2.2.0,
2699 [GUI_LIB_LOC="$GTK_LIBDIR"
2700 GTK_LIBNAME="$GTK_LIBS"
2701 GUI_INC_LOC="$GTK_CFLAGS"], )
2702 if test "x$GTK_CFLAGS" != "x"; then
Bram Moolenaar98921892016-02-23 17:14:37 +01002703 SKIP_GTK3=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002704 SKIP_ATHENA=YES
2705 SKIP_NEXTAW=YES
2706 SKIP_MOTIF=YES
2707 GUITYPE=GTK
2708 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002709 fi
2710 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002711 if test "x$GUITYPE" = "xGTK"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002712 dnl
2713 dnl if GTK exists, then check for GNOME.
2714 dnl
2715 if test -z "$SKIP_GNOME"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002716 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002717 GNOME_INIT_HOOK([have_gnome=yes])
2718 if test "x$have_gnome" = xyes ; then
2719 AC_DEFINE(FEAT_GUI_GNOME)
2720 GUI_INC_LOC="$GUI_INC_LOC $GNOME_INCLUDEDIR"
2721 GTK_LIBNAME="$GTK_LIBNAME $GNOME_LIBDIR $GNOME_LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002722 fi
2723 }
2724 fi
2725 fi
2726fi
2727
Bram Moolenaar98921892016-02-23 17:14:37 +01002728
2729dnl ---------------------------------------------------------------------------
2730dnl Check for GTK3.
2731dnl ---------------------------------------------------------------------------
2732if test -z "$SKIP_GTK3"; then
2733
2734 AC_MSG_CHECKING(--disable-gtktest argument)
2735 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2736 , enable_gtktest=yes)
2737 if test "x$enable_gtktest" = "xyes" ; then
2738 AC_MSG_RESULT(gtk test enabled)
2739 else
2740 AC_MSG_RESULT(gtk test disabled)
2741 fi
2742
2743 if test "X$PKG_CONFIG" = "X"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01002744 AC_PATH_TOOL(PKG_CONFIG, pkg-config, no)
Bram Moolenaar98921892016-02-23 17:14:37 +01002745 fi
2746
2747 if test "x$PKG_CONFIG" != "xno"; then
2748 AM_PATH_GTK(3.0.0,
2749 [GUI_LIB_LOC="$GTK_LIBDIR"
2750 GTK_LIBNAME="$GTK_LIBS"
2751 GUI_INC_LOC="$GTK_CFLAGS"], )
2752 if test "x$GTK_CFLAGS" != "x"; then
2753 SKIP_GTK2=YES
2754 SKIP_GNOME=YES
2755 SKIP_ATHENA=YES
2756 SKIP_NEXTAW=YES
2757 SKIP_MOTIF=YES
2758 GUITYPE=GTK
2759 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar98921892016-02-23 17:14:37 +01002760 AC_DEFINE(USE_GTK3)
2761 fi
2762 fi
2763fi
2764
Bram Moolenaard2e03f02016-01-02 22:46:36 +01002765dnl Check the version of Gdk-Pixbuf. If the version is 2.31 or later and
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002766dnl glib-compile-resources is found in PATH, use GResource.
2767if test "x$GUITYPE" = "xGTK"; then
2768 AC_MSG_CHECKING([version of Gdk-Pixbuf])
2769 gdk_pixbuf_version=`$PKG_CONFIG --modversion gdk-pixbuf-2.0`
2770 if test "x$gdk_pixbuf_version" != x ; then
2771 gdk_pixbuf_version_minor=`echo $gdk_pixbuf_version | \
2772 sed -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/'`
2773 if test "x$gdk_pixbuf_version_minor" != x -a \
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002774 $gdk_pixbuf_version_minor -ge 31 ; then
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002775 AC_MSG_RESULT([OK.])
2776 AC_PATH_PROG(GLIB_COMPILE_RESOURCES,[glib-compile-resources],no)
2777 AC_MSG_CHECKING([glib-compile-resources])
2778 if test "x$GLIB_COMPILE_RESOURCES" = xno ; then
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002779 GLIB_COMPILE_RESOURCES=""
2780 AC_MSG_RESULT([cannot be found in PATH.])
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002781 else
2782 AC_MSG_RESULT([usable.])
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002783 AC_DEFINE(USE_GRESOURCE)
2784 GRESOURCE_SRC="auto/gui_gtk_gresources.c"
2785 GRESOURCE_OBJ="objects/gui_gtk_gresources.o"
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002786 fi
2787 else
2788 AC_MSG_RESULT([not usable.])
2789 fi
2790 else
2791 AC_MSG_RESULT([cannot obtain from pkg_config.])
2792 fi
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002793
2794 AC_MSG_CHECKING([--disable-icon-cache-update argument])
2795 AC_ARG_ENABLE(icon_cache_update,
2796 [ --disable-icon-cache-update update disabled],
2797 [],
2798 [enable_icon_cache_update="yes"])
2799 if test "$enable_icon_cache_update" = "yes"; then
2800 AC_MSG_RESULT([not set])
2801 AC_PATH_PROG(GTK_UPDATE_ICON_CACHE,[gtk-update-icon-cache],no)
2802 if test "x$GTK_UPDATE_ICON_CACHE" = "xno" ; then
2803 AC_MSG_RESULT([not found in PATH.])
2804 fi
2805 else
2806 AC_MSG_RESULT([update disabled])
2807 fi
2808
2809 AC_MSG_CHECKING([--disable-desktop-database-update argument])
2810 AC_ARG_ENABLE(desktop_database_update,
2811 [ --disable-desktop-database-update update disabled],
2812 [],
2813 [enable_desktop_database_update="yes"])
2814 if test "$enable_desktop_database_update" = "yes"; then
2815 AC_MSG_RESULT([not set])
2816 AC_PATH_PROG(UPDATE_DESKTOP_DATABASE,[update-desktop-database],no)
2817 if test "x$UPDATE_DESKTOP_DATABASE" = "xno" ; then
2818 AC_MSG_RESULT([not found in PATH.])
2819 fi
2820 else
2821 AC_MSG_RESULT([update disabled])
2822 fi
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002823fi
2824AC_SUBST(GLIB_COMPILE_RESOURCES)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002825AC_SUBST(GRESOURCE_SRC)
2826AC_SUBST(GRESOURCE_OBJ)
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002827AC_SUBST(GTK_UPDATE_ICON_CACHE)
2828AC_SUBST(UPDATE_DESKTOP_DATABASE)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002829
Bram Moolenaar071d4272004-06-13 20:20:40 +00002830dnl Check for Motif include files location.
2831dnl The LAST one found is used, this makes the highest version to be used,
2832dnl e.g. when Motif1.2 and Motif2.0 are both present.
2833
2834if test -z "$SKIP_MOTIF"; then
2835 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"
2836 dnl Remove "-I" from before $GUI_INC_LOC if it's there
2837 GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`"
2838
2839 AC_MSG_CHECKING(for location of Motif GUI includes)
2840 gui_includes="`echo $x_includes|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC"
2841 GUI_INC_LOC=
2842 for try in $gui_includes; do
2843 if test -f "$try/Xm/Xm.h"; then
2844 GUI_INC_LOC=$try
2845 fi
2846 done
2847 if test -n "$GUI_INC_LOC"; then
2848 if test "$GUI_INC_LOC" = /usr/include; then
2849 GUI_INC_LOC=
2850 AC_MSG_RESULT(in default path)
2851 else
2852 AC_MSG_RESULT($GUI_INC_LOC)
2853 fi
2854 else
2855 AC_MSG_RESULT(<not found>)
2856 SKIP_MOTIF=YES
2857 fi
2858fi
2859
2860dnl Check for Motif library files location. In the same order as the include
2861dnl files, to avoid a mixup if several versions are present
2862
2863if test -z "$SKIP_MOTIF"; then
2864 AC_MSG_CHECKING(--with-motif-lib argument)
2865 AC_ARG_WITH(motif-lib,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002866 [ --with-motif-lib=STRING Library for Motif ],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002867 [ MOTIF_LIBNAME="${withval}" ] )
2868
2869 if test -n "$MOTIF_LIBNAME"; then
2870 AC_MSG_RESULT($MOTIF_LIBNAME)
2871 GUI_LIB_LOC=
2872 else
2873 AC_MSG_RESULT(no)
2874
2875 dnl Remove "-L" from before $GUI_LIB_LOC if it's there
2876 GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
2877
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002878 dnl Ubuntu has libXm.so in /usr/lib/i386-linux-gnu and elsewhere. The
2879 dnl linker will figure out which one to use, we only check if one exists.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002880 AC_MSG_CHECKING(for location of Motif GUI libs)
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002881 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 +00002882 GUI_LIB_LOC=
2883 for try in $gui_libs; do
Bram Moolenaar325b7a22004-07-05 15:58:32 +00002884 for libtry in "$try"/libXm.a "$try"/libXm.so* "$try"/libXm.sl "$try"/libXm.dylib; do
Bram Moolenaar071d4272004-06-13 20:20:40 +00002885 if test -f "$libtry"; then
2886 GUI_LIB_LOC=$try
2887 fi
2888 done
2889 done
2890 if test -n "$GUI_LIB_LOC"; then
2891 dnl Remove /usr/lib, it causes trouble on some systems
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002892 if test "$GUI_LIB_LOC" = /usr/lib \
2893 -o "$GUI_LIB_LOC" = /usr/lib/i386-linux-gnu \
2894 -o "$GUI_LIB_LOC" = /usr/lib/x86_64-linux-gnu; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002895 GUI_LIB_LOC=
2896 AC_MSG_RESULT(in default path)
2897 else
2898 if test -n "$GUI_LIB_LOC"; then
2899 AC_MSG_RESULT($GUI_LIB_LOC)
2900 if test "`(uname) 2>/dev/null`" = SunOS &&
2901 uname -r | grep '^5' >/dev/null; then
2902 GUI_LIB_LOC="$GUI_LIB_LOC -R $GUI_LIB_LOC"
2903 fi
2904 fi
2905 fi
2906 MOTIF_LIBNAME=-lXm
2907 else
2908 AC_MSG_RESULT(<not found>)
2909 SKIP_MOTIF=YES
2910 fi
2911 fi
2912fi
2913
2914if test -z "$SKIP_MOTIF"; then
2915 SKIP_ATHENA=YES
2916 SKIP_NEXTAW=YES
2917 GUITYPE=MOTIF
2918 AC_SUBST(MOTIF_LIBNAME)
2919fi
2920
2921dnl Check if the Athena files can be found
2922
2923GUI_X_LIBS=
2924
2925if test -z "$SKIP_ATHENA"; then
2926 AC_MSG_CHECKING(if Athena header files can be found)
2927 cflags_save=$CFLAGS
2928 CFLAGS="$CFLAGS $X_CFLAGS"
2929 AC_TRY_COMPILE([
2930#include <X11/Intrinsic.h>
2931#include <X11/Xaw/Paned.h>], ,
2932 AC_MSG_RESULT(yes),
2933 AC_MSG_RESULT(no); SKIP_ATHENA=YES )
2934 CFLAGS=$cflags_save
2935fi
2936
2937if test -z "$SKIP_ATHENA"; then
2938 GUITYPE=ATHENA
2939fi
2940
2941if test -z "$SKIP_NEXTAW"; then
2942 AC_MSG_CHECKING(if neXtaw header files can be found)
2943 cflags_save=$CFLAGS
2944 CFLAGS="$CFLAGS $X_CFLAGS"
2945 AC_TRY_COMPILE([
2946#include <X11/Intrinsic.h>
2947#include <X11/neXtaw/Paned.h>], ,
2948 AC_MSG_RESULT(yes),
2949 AC_MSG_RESULT(no); SKIP_NEXTAW=YES )
2950 CFLAGS=$cflags_save
2951fi
2952
2953if test -z "$SKIP_NEXTAW"; then
2954 GUITYPE=NEXTAW
2955fi
2956
2957if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
2958 dnl Prepend -I and -L to $GUI_INC_LOC and $GUI_LIB_LOC if not empty
2959 dnl Avoid adding it when it twice
2960 if test -n "$GUI_INC_LOC"; then
2961 GUI_INC_LOC=-I"`echo $GUI_INC_LOC|sed 's%-I%%'`"
2962 fi
2963 if test -n "$GUI_LIB_LOC"; then
2964 GUI_LIB_LOC=-L"`echo $GUI_LIB_LOC|sed 's%-L%%'`"
2965 fi
2966
2967 dnl Check for -lXext and then for -lXmu
2968 ldflags_save=$LDFLAGS
2969 LDFLAGS="$X_LIBS $LDFLAGS"
2970 AC_CHECK_LIB(Xext, XShapeQueryExtension, [GUI_X_LIBS="-lXext"],,
2971 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2972 dnl For Solaris we need -lw and -ldl before linking with -lXmu works.
2973 AC_CHECK_LIB(w, wslen, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lw"],,
2974 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2975 AC_CHECK_LIB(dl, dlsym, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldl"],,
2976 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2977 AC_CHECK_LIB(Xmu, XmuCreateStippledPixmap, [GUI_X_LIBS="-lXmu $GUI_X_LIBS"],,
2978 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2979 if test -z "$SKIP_MOTIF"; then
2980 AC_CHECK_LIB(Xp, XpEndJob, [GUI_X_LIBS="-lXp $GUI_X_LIBS"],,
2981 [$GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2982 fi
2983 LDFLAGS=$ldflags_save
2984
2985 dnl Execute xmkmf to figure out if -DNARROWPROTO is needed.
2986 AC_MSG_CHECKING(for extra X11 defines)
2987 NARROW_PROTO=
2988 rm -fr conftestdir
2989 if mkdir conftestdir; then
2990 cd conftestdir
2991 cat > Imakefile <<'EOF'
2992acfindx:
2993 @echo 'NARROW_PROTO="${PROTO_DEFINES}"'
2994EOF
2995 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
2996 eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
2997 fi
2998 cd ..
2999 rm -fr conftestdir
3000 fi
3001 if test -z "$NARROW_PROTO"; then
3002 AC_MSG_RESULT(no)
3003 else
3004 AC_MSG_RESULT($NARROW_PROTO)
3005 fi
3006 AC_SUBST(NARROW_PROTO)
3007fi
3008
3009dnl Look for XSMP support - but don't necessarily restrict it to X11 GUIs
3010dnl use the X11 include path
3011if test "$enable_xsmp" = "yes"; then
3012 cppflags_save=$CPPFLAGS
3013 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3014 AC_CHECK_HEADERS(X11/SM/SMlib.h)
3015 CPPFLAGS=$cppflags_save
3016fi
3017
3018
Bram Moolenaar98921892016-02-23 17:14:37 +01003019if 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 +00003020 dnl Check for X11/xpm.h and X11/Sunkeysym.h with the GUI include path
3021 cppflags_save=$CPPFLAGS
3022 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3023 AC_CHECK_HEADERS(X11/xpm.h X11/Sunkeysym.h)
3024
3025 dnl automatically disable XIM when XIMtext isn't in X11/Xlib.h
3026 if test ! "$enable_xim" = "no"; then
3027 AC_MSG_CHECKING(for XIMText in X11/Xlib.h)
3028 AC_EGREP_CPP(XIMText, [#include <X11/Xlib.h>],
3029 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +02003030 AC_MSG_RESULT(no; xim has been disabled); enable_xim="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00003031 fi
3032 CPPFLAGS=$cppflags_save
3033
3034 dnl automatically enable XIM when hangul input isn't enabled
3035 if test "$enable_xim" = "auto" -a "$enable_hangulinput" != "yes" \
3036 -a "x$GUITYPE" != "xNONE" ; then
3037 AC_MSG_RESULT(X GUI selected; xim has been enabled)
3038 enable_xim="yes"
3039 fi
3040fi
3041
3042if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
3043 cppflags_save=$CPPFLAGS
3044 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00003045dnl Xmu/Editres.h may exist but can only be used after including Intrinsic.h
3046 AC_MSG_CHECKING([for X11/Xmu/Editres.h])
3047 AC_TRY_COMPILE([
3048#include <X11/Intrinsic.h>
3049#include <X11/Xmu/Editres.h>],
3050 [int i; i = 0;],
3051 AC_MSG_RESULT(yes)
3052 AC_DEFINE(HAVE_X11_XMU_EDITRES_H),
3053 AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003054 CPPFLAGS=$cppflags_save
3055fi
3056
3057dnl Only use the Xm directory when compiling Motif, don't use it for Athena
3058if test -z "$SKIP_MOTIF"; then
3059 cppflags_save=$CPPFLAGS
3060 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003061 if test "$zOSUnix" = "yes"; then
3062 xmheader="Xm/Xm.h"
3063 else
3064 xmheader="Xm/Xm.h Xm/XpmP.h Xm/JoinSideT.h Xm/TraitP.h Xm/Manager.h
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02003065 Xm/UnhighlightT.h Xm/Notebook.h"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003066 fi
3067 AC_CHECK_HEADERS($xmheader)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003068
Bram Moolenaar77c19352012-06-13 19:19:41 +02003069 if test "x$ac_cv_header_Xm_XpmP_h" = "xyes"; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003070 dnl Solaris uses XpmAttributes_21, very annoying.
3071 AC_MSG_CHECKING([for XpmAttributes_21 in Xm/XpmP.h])
3072 AC_TRY_COMPILE([#include <Xm/XpmP.h>], [XpmAttributes_21 attr;],
3073 AC_MSG_RESULT(yes); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes_21),
3074 AC_MSG_RESULT(no); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
3075 )
3076 else
Bram Moolenaar57657d82006-04-21 22:12:41 +00003077 AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003078 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003079 CPPFLAGS=$cppflags_save
3080fi
3081
3082if test "x$GUITYPE" = "xNONE" -a "$enable_xim" = "yes"; then
3083 AC_MSG_RESULT(no GUI selected; xim has been disabled)
3084 enable_xim="no"
3085fi
3086if test "x$GUITYPE" = "xNONE" -a "$enable_fontset" = "yes"; then
3087 AC_MSG_RESULT(no GUI selected; fontset has been disabled)
3088 enable_fontset="no"
3089fi
Bram Moolenaar182c5be2010-06-25 05:37:59 +02003090if test "x$GUITYPE:$enable_fontset" = "xGTK:yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003091 AC_MSG_RESULT(GTK+ 2 GUI selected; fontset has been disabled)
3092 enable_fontset="no"
3093fi
3094
Bram Moolenaar071d4272004-06-13 20:20:40 +00003095if test -z "$SKIP_PHOTON"; then
3096 GUITYPE=PHOTONGUI
3097fi
3098
3099AC_SUBST(GUI_INC_LOC)
3100AC_SUBST(GUI_LIB_LOC)
3101AC_SUBST(GUITYPE)
3102AC_SUBST(GUI_X_LIBS)
3103
3104if test "$enable_workshop" = "yes" -a -n "$SKIP_MOTIF"; then
3105 AC_MSG_ERROR([cannot use workshop without Motif])
3106fi
3107
3108dnl defining FEAT_XIM and FEAT_XFONTSET is delayed, so that they can be disabled
3109if test "$enable_xim" = "yes"; then
3110 AC_DEFINE(FEAT_XIM)
3111fi
3112if test "$enable_fontset" = "yes"; then
3113 AC_DEFINE(FEAT_XFONTSET)
3114fi
3115
3116
3117dnl ---------------------------------------------------------------------------
3118dnl end of GUI-checking
3119dnl ---------------------------------------------------------------------------
3120
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003121AC_MSG_CHECKING([for /proc link to executable])
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003122if test -L "/proc/self/exe"; then
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003123 dnl Linux
3124 AC_MSG_RESULT([/proc/self/exe])
3125 AC_DEFINE(PROC_EXE_LINK, "/proc/self/exe")
3126elif test -L "/proc/self/path/a.out"; then
3127 dnl Solaris
3128 AC_MSG_RESULT([/proc/self/path/a.out])
3129 AC_DEFINE(PROC_EXE_LINK, "/proc/self/path/a.out")
3130elif test -L "/proc/curproc/file"; then
3131 dnl FreeBSD
3132 AC_MSG_RESULT([/proc/curproc/file])
3133 AC_DEFINE(PROC_EXE_LINK, "/proc/curproc/file")
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003134else
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003135 AC_MSG_RESULT(no)
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003136fi
3137
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003138dnl Check for Cygwin, which needs an extra source file if not using X11
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003139AC_MSG_CHECKING(for CYGWIN or MSYS environment)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003140case `uname` in
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003141 CYGWIN*|MSYS*) CYGWIN=yes; AC_MSG_RESULT(yes)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003142 AC_MSG_CHECKING(for CYGWIN clipboard support)
3143 if test "x$with_x" = "xno" ; then
3144 OS_EXTRA_SRC=winclip.c; OS_EXTRA_OBJ=objects/winclip.o
3145 AC_MSG_RESULT(yes)
3146 AC_DEFINE(FEAT_CYGWIN_WIN32_CLIPBOARD)
3147 else
3148 AC_MSG_RESULT(no - using X11)
3149 fi ;;
3150
3151 *) CYGWIN=no; AC_MSG_RESULT(no);;
3152esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00003153
3154dnl Only really enable hangul input when GUI and XFONTSET are available
3155if test "$enable_hangulinput" = "yes"; then
3156 if test "x$GUITYPE" = "xNONE"; then
3157 AC_MSG_RESULT(no GUI selected; hangul input has been disabled)
3158 enable_hangulinput=no
3159 else
3160 AC_DEFINE(FEAT_HANGULIN)
3161 HANGULIN_SRC=hangulin.c
3162 AC_SUBST(HANGULIN_SRC)
3163 HANGULIN_OBJ=objects/hangulin.o
3164 AC_SUBST(HANGULIN_OBJ)
3165 fi
3166fi
3167
3168dnl Checks for libraries and include files.
3169
Bram Moolenaar446cb832008-06-24 21:56:24 +00003170AC_CACHE_CHECK([whether toupper is broken], [vim_cv_toupper_broken],
3171 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003172 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003173#include "confdefs.h"
3174#include <ctype.h>
3175#if STDC_HEADERS
3176# include <stdlib.h>
3177# include <stddef.h>
3178#endif
3179main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003180 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003181 vim_cv_toupper_broken=yes
3182 ],[
3183 vim_cv_toupper_broken=no
3184 ],[
3185 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_toupper_broken')
3186 ])])
3187
3188if test "x$vim_cv_toupper_broken" = "xyes" ; then
3189 AC_DEFINE(BROKEN_TOUPPER)
3190fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003191
3192AC_MSG_CHECKING(whether __DATE__ and __TIME__ work)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003193AC_TRY_COMPILE([#include <stdio.h>], [printf("(" __DATE__ " " __TIME__ ")");],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003194 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DATE_TIME),
3195 AC_MSG_RESULT(no))
3196
Bram Moolenaar0c094b92009-05-14 20:20:33 +00003197AC_MSG_CHECKING(whether __attribute__((unused)) is allowed)
3198AC_TRY_COMPILE([#include <stdio.h>], [int x __attribute__((unused));],
3199 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ATTRIBUTE_UNUSED),
3200 AC_MSG_RESULT(no))
3201
Bram Moolenaar071d4272004-06-13 20:20:40 +00003202dnl Checks for header files.
3203AC_CHECK_HEADER(elf.h, HAS_ELF=1)
3204dnl AC_CHECK_HEADER(dwarf.h, SVR4=1)
3205if test "$HAS_ELF" = 1; then
3206 AC_CHECK_LIB(elf, main)
3207fi
3208
3209AC_HEADER_DIRENT
3210
Bram Moolenaar071d4272004-06-13 20:20:40 +00003211dnl If sys/wait.h is not found it might still exist but not be POSIX
3212dnl compliant. In that case we define HAVE_UNION_WAIT (for NeXT)
3213if test $ac_cv_header_sys_wait_h = no; then
3214 AC_MSG_CHECKING([for sys/wait.h that defines union wait])
3215 AC_TRY_COMPILE([#include <sys/wait.h>],
3216 [union wait xx, yy; xx = yy],
3217 AC_MSG_RESULT(yes)
3218 AC_DEFINE(HAVE_SYS_WAIT_H)
3219 AC_DEFINE(HAVE_UNION_WAIT),
3220 AC_MSG_RESULT(no))
3221fi
3222
Bram Moolenaar779a7752016-01-30 23:26:34 +01003223AC_CHECK_HEADERS(stdint.h stdlib.h string.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003224 sys/select.h sys/utsname.h termcap.h fcntl.h \
3225 sgtty.h sys/ioctl.h sys/time.h sys/types.h \
3226 termio.h iconv.h inttypes.h langinfo.h math.h \
3227 unistd.h stropts.h errno.h sys/resource.h \
3228 sys/systeminfo.h locale.h sys/stream.h termios.h \
3229 libc.h sys/statfs.h poll.h sys/poll.h pwd.h \
3230 utime.h sys/param.h libintl.h libgen.h \
3231 util/debug.h util/msg18n.h frame.h sys/acl.h \
3232 sys/access.h sys/sysinfo.h wchar.h wctype.h)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003233
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003234dnl sys/ptem.h depends on sys/stream.h on Solaris
3235AC_CHECK_HEADERS(sys/ptem.h, [], [],
3236[#if defined HAVE_SYS_STREAM_H
3237# include <sys/stream.h>
3238#endif])
3239
Bram Moolenaar32f31b12009-05-21 13:20:59 +00003240dnl sys/sysctl.h depends on sys/param.h on OpenBSD
3241AC_CHECK_HEADERS(sys/sysctl.h, [], [],
3242[#if defined HAVE_SYS_PARAM_H
3243# include <sys/param.h>
3244#endif])
3245
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003246
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003247dnl pthread_np.h may exist but can only be used after including pthread.h
3248AC_MSG_CHECKING([for pthread_np.h])
3249AC_TRY_COMPILE([
3250#include <pthread.h>
3251#include <pthread_np.h>],
3252 [int i; i = 0;],
3253 AC_MSG_RESULT(yes)
3254 AC_DEFINE(HAVE_PTHREAD_NP_H),
3255 AC_MSG_RESULT(no))
3256
Bram Moolenaare344bea2005-09-01 20:46:49 +00003257AC_CHECK_HEADERS(strings.h)
Bram Moolenaard0573012017-10-28 21:11:06 +02003258if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00003259 dnl The strings.h file on OS/X contains a warning and nothing useful.
3260 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3261else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003262
3263dnl Check if strings.h and string.h can both be included when defined.
3264AC_MSG_CHECKING([if strings.h can be included after string.h])
3265cppflags_save=$CPPFLAGS
3266CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3267AC_TRY_COMPILE([
3268#if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO)
3269# define _NO_PROTO /* like in os_unix.h, causes conflict for AIX (Winn) */
3270 /* but don't do it on AIX 5.1 (Uribarri) */
3271#endif
3272#ifdef HAVE_XM_XM_H
3273# include <Xm/Xm.h> /* This breaks it for HP-UX 11 (Squassabia) */
3274#endif
3275#ifdef HAVE_STRING_H
3276# include <string.h>
3277#endif
3278#if defined(HAVE_STRINGS_H)
3279# include <strings.h>
3280#endif
3281 ], [int i; i = 0;],
3282 AC_MSG_RESULT(yes),
3283 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3284 AC_MSG_RESULT(no))
3285CPPFLAGS=$cppflags_save
Bram Moolenaar9372a112005-12-06 19:59:18 +00003286fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003287
3288dnl Checks for typedefs, structures, and compiler characteristics.
3289AC_PROG_GCC_TRADITIONAL
3290AC_C_CONST
Bram Moolenaar76243bd2009-03-02 01:47:02 +00003291AC_C_VOLATILE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003292AC_TYPE_MODE_T
3293AC_TYPE_OFF_T
3294AC_TYPE_PID_T
3295AC_TYPE_SIZE_T
3296AC_TYPE_UID_T
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003297AC_TYPE_UINT32_T
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003298
Bram Moolenaar071d4272004-06-13 20:20:40 +00003299AC_HEADER_TIME
3300AC_CHECK_TYPE(ino_t, long)
3301AC_CHECK_TYPE(dev_t, unsigned)
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003302AC_C_BIGENDIAN(,,,)
Bram Moolenaar136f29a2016-02-27 20:14:15 +01003303AC_C_INLINE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003304
3305AC_MSG_CHECKING(for rlim_t)
3306if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
3307 AC_MSG_RESULT([(cached) $ac_cv_type_rlim_t])
3308else
3309 AC_EGREP_CPP(dnl
3310changequote(<<,>>)dnl
3311<<(^|[^a-zA-Z_0-9])rlim_t[^a-zA-Z_0-9]>>dnl
3312changequote([,]),
3313 [
3314#include <sys/types.h>
3315#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003316# include <stdlib.h>
3317# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003318#endif
3319#ifdef HAVE_SYS_RESOURCE_H
Bram Moolenaar446cb832008-06-24 21:56:24 +00003320# include <sys/resource.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003321#endif
3322 ], ac_cv_type_rlim_t=yes, ac_cv_type_rlim_t=no)
3323 AC_MSG_RESULT($ac_cv_type_rlim_t)
3324fi
3325if test $ac_cv_type_rlim_t = no; then
3326 cat >> confdefs.h <<\EOF
3327#define rlim_t unsigned long
3328EOF
3329fi
3330
3331AC_MSG_CHECKING(for stack_t)
3332if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then
3333 AC_MSG_RESULT([(cached) $ac_cv_type_stack_t])
3334else
3335 AC_EGREP_CPP(stack_t,
3336 [
3337#include <sys/types.h>
3338#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003339# include <stdlib.h>
3340# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003341#endif
3342#include <signal.h>
3343 ], ac_cv_type_stack_t=yes, ac_cv_type_stack_t=no)
3344 AC_MSG_RESULT($ac_cv_type_stack_t)
3345fi
3346if test $ac_cv_type_stack_t = no; then
3347 cat >> confdefs.h <<\EOF
3348#define stack_t struct sigaltstack
3349EOF
3350fi
3351
3352dnl BSDI uses ss_base while others use ss_sp for the stack pointer.
3353AC_MSG_CHECKING(whether stack_t has an ss_base field)
3354AC_TRY_COMPILE([
3355#include <sys/types.h>
3356#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003357# include <stdlib.h>
3358# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003359#endif
3360#include <signal.h>
3361#include "confdefs.h"
3362 ], [stack_t sigstk; sigstk.ss_base = 0; ],
3363 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SS_BASE),
3364 AC_MSG_RESULT(no))
3365
3366olibs="$LIBS"
3367AC_MSG_CHECKING(--with-tlib argument)
3368AC_ARG_WITH(tlib, [ --with-tlib=library terminal library to be used ],)
3369if test -n "$with_tlib"; then
3370 AC_MSG_RESULT($with_tlib)
3371 LIBS="$LIBS -l$with_tlib"
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003372 AC_MSG_CHECKING(for linking with $with_tlib library)
3373 AC_TRY_LINK([], [], AC_MSG_RESULT(OK), AC_MSG_ERROR(FAILED))
3374 dnl Need to check for tgetent() below.
3375 olibs="$LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003376else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003377 AC_MSG_RESULT([empty: automatic terminal library selection])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003378 dnl On HP-UX 10.10 termcap or termlib should be used instead of
3379 dnl curses, because curses is much slower.
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003380 dnl Newer versions of ncurses are preferred over anything, except
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02003381 dnl when tinfo has been split off, it contains all we need.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003382 dnl Older versions of ncurses have bugs, get a new one!
3383 dnl Digital Unix (OSF1) should use curses (Ronald Schild).
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00003384 dnl On SCO Openserver should prefer termlib (Roger Cornelius).
Bram Moolenaar071d4272004-06-13 20:20:40 +00003385 case "`uname -s 2>/dev/null`" in
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003386 OSF1|SCO_SV) tlibs="tinfo ncurses curses termlib termcap";;
3387 *) tlibs="tinfo ncurses termlib termcap curses";;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003388 esac
3389 for libname in $tlibs; do
3390 AC_CHECK_LIB(${libname}, tgetent,,)
3391 if test "x$olibs" != "x$LIBS"; then
3392 dnl It's possible that a library is found but it doesn't work
3393 dnl e.g., shared library that cannot be found
3394 dnl compile and run a test program to be sure
3395 AC_TRY_RUN([
3396#ifdef HAVE_TERMCAP_H
3397# include <termcap.h>
3398#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003399#if STDC_HEADERS
3400# include <stdlib.h>
3401# include <stddef.h>
3402#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003403main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }],
3404 res="OK", res="FAIL", res="FAIL")
3405 if test "$res" = "OK"; then
3406 break
3407 fi
3408 AC_MSG_RESULT($libname library is not usable)
3409 LIBS="$olibs"
3410 fi
3411 done
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003412 if test "x$olibs" = "x$LIBS"; then
3413 AC_MSG_RESULT(no terminal library found)
3414 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003415fi
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003416
3417if test "x$olibs" = "x$LIBS"; then
3418 AC_MSG_CHECKING([for tgetent()])
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00003419 AC_TRY_LINK([],
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003420 [char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");],
3421 AC_MSG_RESULT(yes),
3422 AC_MSG_ERROR([NOT FOUND!
3423 You need to install a terminal library; for example ncurses.
3424 Or specify the name of the library with --with-tlib.]))
3425fi
3426
Bram Moolenaar446cb832008-06-24 21:56:24 +00003427AC_CACHE_CHECK([whether we talk terminfo], [vim_cv_terminfo],
3428 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003429 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003430#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003431#ifdef HAVE_TERMCAP_H
3432# include <termcap.h>
3433#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003434#ifdef HAVE_STRING_H
3435# include <string.h>
3436#endif
3437#if STDC_HEADERS
3438# include <stdlib.h>
3439# include <stddef.h>
3440#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003441main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003442{char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003443 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003444 vim_cv_terminfo=no
3445 ],[
3446 vim_cv_terminfo=yes
3447 ],[
3448 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_terminfo')
3449 ])
3450 ])
3451
3452if test "x$vim_cv_terminfo" = "xyes" ; then
3453 AC_DEFINE(TERMINFO)
3454fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003455
Bram Moolenaara88254f2017-11-02 23:04:14 +01003456AC_CACHE_CHECK([what tgetent() returns for an unknown terminal], [vim_cv_tgetent],
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003457 [
3458 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003459#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003460#ifdef HAVE_TERMCAP_H
3461# include <termcap.h>
3462#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003463#if STDC_HEADERS
3464# include <stdlib.h>
3465# include <stddef.h>
3466#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003467main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003468{char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003469 ]])],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003470 vim_cv_tgetent=zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003471 ],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003472 vim_cv_tgetent=non-zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003473 ],[
3474 AC_MSG_ERROR(failed to compile test program.)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003475 ])
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003476 ])
3477
Bram Moolenaara88254f2017-11-02 23:04:14 +01003478if test "x$vim_cv_tgetent" = "xzero" ; then
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003479 AC_DEFINE(TGETENT_ZERO_ERR, 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003480fi
3481
3482AC_MSG_CHECKING(whether termcap.h contains ospeed)
3483AC_TRY_LINK([
3484#ifdef HAVE_TERMCAP_H
3485# include <termcap.h>
3486#endif
3487 ], [ospeed = 20000],
3488 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED),
3489 [AC_MSG_RESULT(no)
3490 AC_MSG_CHECKING(whether ospeed can be extern)
3491 AC_TRY_LINK([
3492#ifdef HAVE_TERMCAP_H
3493# include <termcap.h>
3494#endif
3495extern short ospeed;
3496 ], [ospeed = 20000],
3497 AC_MSG_RESULT(yes); AC_DEFINE(OSPEED_EXTERN),
3498 AC_MSG_RESULT(no))]
3499 )
3500
3501AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC])
3502AC_TRY_LINK([
3503#ifdef HAVE_TERMCAP_H
3504# include <termcap.h>
3505#endif
3506 ], [if (UP == 0 && BC == 0) PC = 1],
3507 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UP_BC_PC),
3508 [AC_MSG_RESULT(no)
3509 AC_MSG_CHECKING([whether UP, BC and PC can be extern])
3510 AC_TRY_LINK([
3511#ifdef HAVE_TERMCAP_H
3512# include <termcap.h>
3513#endif
3514extern char *UP, *BC, PC;
3515 ], [if (UP == 0 && BC == 0) PC = 1],
3516 AC_MSG_RESULT(yes); AC_DEFINE(UP_BC_PC_EXTERN),
3517 AC_MSG_RESULT(no))]
3518 )
3519
3520AC_MSG_CHECKING(whether tputs() uses outfuntype)
3521AC_TRY_COMPILE([
3522#ifdef HAVE_TERMCAP_H
3523# include <termcap.h>
3524#endif
3525 ], [extern int xx(); tputs("test", 1, (outfuntype)xx)],
3526 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OUTFUNTYPE),
3527 AC_MSG_RESULT(no))
3528
3529dnl On some SCO machines sys/select redefines struct timeval
3530AC_MSG_CHECKING([whether sys/select.h and sys/time.h may both be included])
3531AC_TRY_COMPILE([
3532#include <sys/types.h>
3533#include <sys/time.h>
3534#include <sys/select.h>], ,
3535 AC_MSG_RESULT(yes)
3536 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME),
3537 AC_MSG_RESULT(no))
3538
3539dnl AC_DECL_SYS_SIGLIST
3540
3541dnl Checks for pty.c (copied from screen) ==========================
3542AC_MSG_CHECKING(for /dev/ptc)
3543if test -r /dev/ptc; then
3544 AC_DEFINE(HAVE_DEV_PTC)
3545 AC_MSG_RESULT(yes)
3546else
3547 AC_MSG_RESULT(no)
3548fi
3549
3550AC_MSG_CHECKING(for SVR4 ptys)
3551if test -c /dev/ptmx ; then
3552 AC_TRY_LINK([], [ptsname(0);grantpt(0);unlockpt(0);],
3553 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SVR4_PTYS),
3554 AC_MSG_RESULT(no))
3555else
3556 AC_MSG_RESULT(no)
3557fi
3558
3559AC_MSG_CHECKING(for ptyranges)
3560if test -d /dev/ptym ; then
3561 pdir='/dev/ptym'
3562else
3563 pdir='/dev'
3564fi
3565dnl SCO uses ptyp%d
3566AC_EGREP_CPP(yes,
3567[#ifdef M_UNIX
3568 yes;
3569#endif
3570 ], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
3571dnl if test -c /dev/ptyp19; then
3572dnl ptys=`echo /dev/ptyp??`
3573dnl else
3574dnl ptys=`echo $pdir/pty??`
3575dnl fi
3576if test "$ptys" != "$pdir/pty??" ; then
3577 p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
3578 p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'`
3579 AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
3580 AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
3581 AC_MSG_RESULT([$p0 / $p1])
3582else
3583 AC_MSG_RESULT([don't know])
3584fi
3585
3586dnl **** pty mode/group handling ****
3587dnl
3588dnl support provided by Luke Mewburn <lm@rmit.edu.au>, 931222
Bram Moolenaar071d4272004-06-13 20:20:40 +00003589rm -f conftest_grp
Bram Moolenaar446cb832008-06-24 21:56:24 +00003590AC_CACHE_CHECK([default tty permissions/group], [vim_cv_tty_group],
3591 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003592 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003593#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003594#include <sys/types.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003595#if STDC_HEADERS
3596# include <stdlib.h>
3597# include <stddef.h>
3598#endif
3599#ifdef HAVE_UNISTD_H
3600#include <unistd.h>
3601#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003602#include <sys/stat.h>
3603#include <stdio.h>
3604main()
3605{
3606 struct stat sb;
3607 char *x,*ttyname();
3608 int om, m;
3609 FILE *fp;
3610
3611 if (!(x = ttyname(0))) exit(1);
3612 if (stat(x, &sb)) exit(1);
3613 om = sb.st_mode;
3614 if (om & 002) exit(0);
3615 m = system("mesg y");
3616 if (m == -1 || m == 127) exit(1);
3617 if (stat(x, &sb)) exit(1);
3618 m = sb.st_mode;
3619 if (chmod(x, om)) exit(1);
3620 if (m & 002) exit(0);
3621 if (sb.st_gid == getgid()) exit(1);
3622 if (!(fp=fopen("conftest_grp", "w")))
3623 exit(1);
3624 fprintf(fp, "%d\n", sb.st_gid);
3625 fclose(fp);
3626 exit(0);
3627}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003628 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003629 if test -f conftest_grp; then
3630 vim_cv_tty_group=`cat conftest_grp`
3631 if test "x$vim_cv_tty_mode" = "x" ; then
3632 vim_cv_tty_mode=0620
3633 fi
3634 AC_MSG_RESULT([pty mode: $vim_cv_tty_mode, group: $vim_cv_tty_group])
3635 else
3636 vim_cv_tty_group=world
Bram Moolenaar72951072009-12-02 16:58:33 +00003637 AC_MSG_RESULT([ptys are world accessible])
Bram Moolenaar446cb832008-06-24 21:56:24 +00003638 fi
3639 ],[
3640 vim_cv_tty_group=world
Bram Moolenaar72951072009-12-02 16:58:33 +00003641 AC_MSG_RESULT([can't determine - assume ptys are world accessible])
Bram Moolenaar446cb832008-06-24 21:56:24 +00003642 ],[
3643 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_tty_group' and 'vim_cv_tty_mode')
3644 ])
3645 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003646rm -f conftest_grp
3647
Bram Moolenaar446cb832008-06-24 21:56:24 +00003648if test "x$vim_cv_tty_group" != "xworld" ; then
3649 AC_DEFINE_UNQUOTED(PTYGROUP,$vim_cv_tty_group)
3650 if test "x$vim_cv_tty_mode" = "x" ; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02003651 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 +00003652 else
3653 AC_DEFINE(PTYMODE, 0620)
3654 fi
3655fi
3656
Bram Moolenaar071d4272004-06-13 20:20:40 +00003657dnl Checks for library functions. ===================================
3658
3659AC_TYPE_SIGNAL
3660
3661dnl find out what to use at the end of a signal function
3662if test $ac_cv_type_signal = void; then
3663 AC_DEFINE(SIGRETURN, [return])
3664else
3665 AC_DEFINE(SIGRETURN, [return 0])
3666fi
3667
3668dnl check if struct sigcontext is defined (used for SGI only)
3669AC_MSG_CHECKING(for struct sigcontext)
3670AC_TRY_COMPILE([
3671#include <signal.h>
3672test_sig()
3673{
3674 struct sigcontext *scont;
3675 scont = (struct sigcontext *)0;
3676 return 1;
3677} ], ,
3678 AC_MSG_RESULT(yes)
3679 AC_DEFINE(HAVE_SIGCONTEXT),
3680 AC_MSG_RESULT(no))
3681
3682dnl tricky stuff: try to find out if getcwd() is implemented with
3683dnl system("sh -c pwd")
Bram Moolenaar446cb832008-06-24 21:56:24 +00003684AC_CACHE_CHECK([getcwd implementation is broken], [vim_cv_getcwd_broken],
3685 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003686 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003687#include "confdefs.h"
3688#ifdef HAVE_UNISTD_H
3689#include <unistd.h>
3690#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003691char *dagger[] = { "IFS=pwd", 0 };
3692main()
3693{
3694 char buffer[500];
3695 extern char **environ;
3696 environ = dagger;
3697 return getcwd(buffer, 500) ? 0 : 1;
Bram Moolenaar446cb832008-06-24 21:56:24 +00003698}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003699 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003700 vim_cv_getcwd_broken=no
3701 ],[
3702 vim_cv_getcwd_broken=yes
3703 ],[
3704 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_getcwd_broken')
3705 ])
3706 ])
3707
3708if test "x$vim_cv_getcwd_broken" = "xyes" ; then
3709 AC_DEFINE(BAD_GETCWD)
3710fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003711
Bram Moolenaar25153e12010-02-24 14:47:08 +01003712dnl Check for functions in one big call, to reduce the size of configure.
3713dnl Can only be used for functions that do not require any include.
Bram Moolenaarcd142e32017-11-16 17:03:45 +01003714AC_CHECK_FUNCS(fchdir fchown fchmod fsync getcwd getpseudotty \
Bram Moolenaarb129a442016-12-01 17:25:20 +01003715 getpwent getpwnam getpwuid getrlimit gettimeofday getwd lstat \
Bram Moolenaareaf03392009-11-17 11:08:52 +00003716 memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
Bram Moolenaar2fcf6682017-03-11 20:03:42 +01003717 getpgid setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
Bram Moolenaarbb09ceb2016-10-18 16:27:23 +02003718 sigprocmask sigvec strcasecmp strerror strftime stricmp strncasecmp \
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00003719 strnicmp strpbrk strtol tgetent towlower towupper iswupper \
Bram Moolenaar137374f2018-05-13 15:59:50 +02003720 usleep utime utimes mblen ftruncate unsetenv)
Bram Moolenaar25153e12010-02-24 14:47:08 +01003721AC_FUNC_FSEEKO
Bram Moolenaar071d4272004-06-13 20:20:40 +00003722
Bram Moolenaar317fd3a2010-05-07 16:05:55 +02003723dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when
3724dnl appropriate, so that off_t is 64 bits when needed.
3725AC_SYS_LARGEFILE
3726
Bram Moolenaar071d4272004-06-13 20:20:40 +00003727dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible
3728AC_MSG_CHECKING(for st_blksize)
3729AC_TRY_COMPILE(
3730[#include <sys/types.h>
3731#include <sys/stat.h>],
3732[ struct stat st;
3733 int n;
3734
3735 stat("/", &st);
3736 n = (int)st.st_blksize;],
3737 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ST_BLKSIZE),
3738 AC_MSG_RESULT(no))
3739
Bram Moolenaar446cb832008-06-24 21:56:24 +00003740AC_CACHE_CHECK([whether stat() ignores a trailing slash], [vim_cv_stat_ignores_slash],
3741 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003742 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003743#include "confdefs.h"
3744#if STDC_HEADERS
3745# include <stdlib.h>
3746# include <stddef.h>
3747#endif
3748#include <sys/types.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003749#include <sys/stat.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003750main() {struct stat st; exit(stat("configure/", &st) != 0); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003751 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003752 vim_cv_stat_ignores_slash=yes
3753 ],[
3754 vim_cv_stat_ignores_slash=no
3755 ],[
3756 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_stat_ignores_slash')
3757 ])
3758 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003759
Bram Moolenaar446cb832008-06-24 21:56:24 +00003760if test "x$vim_cv_stat_ignores_slash" = "xyes" ; then
3761 AC_DEFINE(STAT_IGNORES_SLASH)
3762fi
3763
Bram Moolenaar071d4272004-06-13 20:20:40 +00003764dnl Link with iconv for charset translation, if not found without library.
3765dnl check for iconv() requires including iconv.h
3766dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
3767dnl has been installed.
3768AC_MSG_CHECKING(for iconv_open())
3769save_LIBS="$LIBS"
3770LIBS="$LIBS -liconv"
3771AC_TRY_LINK([
3772#ifdef HAVE_ICONV_H
3773# include <iconv.h>
3774#endif
3775 ], [iconv_open("fr", "to");],
3776 AC_MSG_RESULT(yes; with -liconv); AC_DEFINE(HAVE_ICONV),
3777 LIBS="$save_LIBS"
3778 AC_TRY_LINK([
3779#ifdef HAVE_ICONV_H
3780# include <iconv.h>
3781#endif
3782 ], [iconv_open("fr", "to");],
3783 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ICONV),
3784 AC_MSG_RESULT(no)))
3785
3786
3787AC_MSG_CHECKING(for nl_langinfo(CODESET))
3788AC_TRY_LINK([
3789#ifdef HAVE_LANGINFO_H
3790# include <langinfo.h>
3791#endif
3792], [char *cs = nl_langinfo(CODESET);],
3793 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET),
3794 AC_MSG_RESULT(no))
3795
Bram Moolenaar446cb832008-06-24 21:56:24 +00003796dnl Need various functions for floating point support. Only enable
3797dnl floating point when they are all present.
3798AC_CHECK_LIB(m, strtod)
3799AC_MSG_CHECKING([for strtod() and other floating point functions])
3800AC_TRY_LINK([
3801#ifdef HAVE_MATH_H
3802# include <math.h>
3803#endif
3804#if STDC_HEADERS
3805# include <stdlib.h>
3806# include <stddef.h>
3807#endif
3808], [char *s; double d;
3809 d = strtod("1.1", &s);
3810 d = fabs(1.11);
3811 d = ceil(1.11);
3812 d = floor(1.11);
3813 d = log10(1.11);
3814 d = pow(1.11, 2.22);
3815 d = sqrt(1.11);
3816 d = sin(1.11);
3817 d = cos(1.11);
3818 d = atan(1.11);
3819 ],
3820 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT_FUNCS),
3821 AC_MSG_RESULT(no))
3822
Bram Moolenaara6b89762016-02-29 21:38:26 +01003823dnl isinf() and isnan() need to include header files and may need -lm.
3824AC_MSG_CHECKING([for isinf()])
3825AC_TRY_LINK([
3826#ifdef HAVE_MATH_H
3827# include <math.h>
3828#endif
3829#if STDC_HEADERS
3830# include <stdlib.h>
3831# include <stddef.h>
3832#endif
3833], [int r = isinf(1.11); ],
3834 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISINF),
3835 AC_MSG_RESULT(no))
3836
3837AC_MSG_CHECKING([for isnan()])
3838AC_TRY_LINK([
3839#ifdef HAVE_MATH_H
3840# include <math.h>
3841#endif
3842#if STDC_HEADERS
3843# include <stdlib.h>
3844# include <stddef.h>
3845#endif
3846], [int r = isnan(1.11); ],
3847 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISNAN),
3848 AC_MSG_RESULT(no))
3849
Bram Moolenaar071d4272004-06-13 20:20:40 +00003850dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI
3851dnl when -lacl works, also try to use -lattr (required for Debian).
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003852dnl On Solaris, use the acl_get/set functions in libsec, if present.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003853AC_MSG_CHECKING(--disable-acl argument)
3854AC_ARG_ENABLE(acl,
Bram Moolenaard6d30422018-01-28 22:48:55 +01003855 [ --disable-acl No check for ACL support.],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003856 , [enable_acl="yes"])
3857if test "$enable_acl" = "yes"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01003858 AC_MSG_RESULT(no)
3859 AC_CHECK_LIB(posix1e, acl_get_file, [LIBS="$LIBS -lposix1e"],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003860 AC_CHECK_LIB(acl, acl_get_file, [LIBS="$LIBS -lacl"
3861 AC_CHECK_LIB(attr, fgetxattr, LIBS="$LIBS -lattr",,)],,),)
3862
Bram Moolenaard6d30422018-01-28 22:48:55 +01003863 AC_MSG_CHECKING(for POSIX ACL support)
3864 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003865#include <sys/types.h>
3866#ifdef HAVE_SYS_ACL_H
3867# include <sys/acl.h>
3868#endif
3869acl_t acl;], [acl = acl_get_file("foo", ACL_TYPE_ACCESS);
3870 acl_set_file("foo", ACL_TYPE_ACCESS, acl);
3871 acl_free(acl);],
3872 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_ACL),
3873 AC_MSG_RESULT(no))
3874
Bram Moolenaard6d30422018-01-28 22:48:55 +01003875 AC_CHECK_LIB(sec, acl_get, [LIBS="$LIBS -lsec"; AC_DEFINE(HAVE_SOLARIS_ZFS_ACL)],
3876 AC_MSG_CHECKING(for Solaris ACL support)
3877 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003878#ifdef HAVE_SYS_ACL_H
3879# include <sys/acl.h>
3880#endif], [acl("foo", GETACLCNT, 0, NULL);
3881 ],
3882 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOLARIS_ACL),
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003883 AC_MSG_RESULT(no)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003884
Bram Moolenaard6d30422018-01-28 22:48:55 +01003885 AC_MSG_CHECKING(for AIX ACL support)
3886 AC_TRY_LINK([
Bram Moolenaar446cb832008-06-24 21:56:24 +00003887#if STDC_HEADERS
3888# include <stdlib.h>
3889# include <stddef.h>
3890#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003891#ifdef HAVE_SYS_ACL_H
3892# include <sys/acl.h>
3893#endif
3894#ifdef HAVE_SYS_ACCESS_H
3895# include <sys/access.h>
3896#endif
3897#define _ALL_SOURCE
3898
3899#include <sys/stat.h>
3900
3901int aclsize;
3902struct acl *aclent;], [aclsize = sizeof(struct acl);
3903 aclent = (void *)malloc(aclsize);
3904 statacl("foo", STX_NORMAL, aclent, aclsize);
3905 ],
3906 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_AIX_ACL),
3907 AC_MSG_RESULT(no))
3908else
3909 AC_MSG_RESULT(yes)
3910fi
3911
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02003912if test "x$GTK_CFLAGS" != "x"; then
3913 dnl pango_shape_full() is new, fall back to pango_shape().
3914 AC_MSG_CHECKING(for pango_shape_full)
3915 ac_save_CFLAGS="$CFLAGS"
3916 ac_save_LIBS="$LIBS"
3917 CFLAGS="$CFLAGS $GTK_CFLAGS"
3918 LIBS="$LIBS $GTK_LIBS"
Bram Moolenaar5325b9b2015-09-09 20:27:02 +02003919 AC_TRY_LINK(
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02003920 [#include <gtk/gtk.h>],
3921 [ pango_shape_full(NULL, 0, NULL, 0, NULL, NULL); ],
3922 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_PANGO_SHAPE_FULL),
3923 AC_MSG_RESULT(no))
3924 CFLAGS="$ac_save_CFLAGS"
3925 LIBS="$ac_save_LIBS"
3926fi
3927
Bram Moolenaar071d4272004-06-13 20:20:40 +00003928AC_MSG_CHECKING(--disable-gpm argument)
3929AC_ARG_ENABLE(gpm,
3930 [ --disable-gpm Don't use gpm (Linux mouse daemon).], ,
3931 [enable_gpm="yes"])
3932
3933if test "$enable_gpm" = "yes"; then
3934 AC_MSG_RESULT(no)
3935 dnl Checking if gpm support can be compiled
3936 AC_CACHE_CHECK([for gpm], vi_cv_have_gpm,
3937 [olibs="$LIBS" ; LIBS="-lgpm"]
3938 AC_TRY_LINK(
3939 [#include <gpm.h>
3940 #include <linux/keyboard.h>],
3941 [Gpm_GetLibVersion(NULL);],
3942 dnl Configure defines HAVE_GPM, if it is defined feature.h defines
3943 dnl FEAT_MOUSE_GPM if mouse support is included
3944 [vi_cv_have_gpm=yes],
3945 [vi_cv_have_gpm=no])
3946 [LIBS="$olibs"]
3947 )
3948 if test $vi_cv_have_gpm = yes; then
3949 LIBS="$LIBS -lgpm"
3950 AC_DEFINE(HAVE_GPM)
3951 fi
3952else
3953 AC_MSG_RESULT(yes)
3954fi
3955
Bram Moolenaar446cb832008-06-24 21:56:24 +00003956AC_MSG_CHECKING(--disable-sysmouse argument)
3957AC_ARG_ENABLE(sysmouse,
Bram Moolenaar8008b632017-07-18 21:33:20 +02003958 [ --disable-sysmouse Don't use sysmouse (mouse in *BSD console).], ,
Bram Moolenaar446cb832008-06-24 21:56:24 +00003959 [enable_sysmouse="yes"])
3960
3961if test "$enable_sysmouse" = "yes"; then
3962 AC_MSG_RESULT(no)
3963 dnl Checking if sysmouse support can be compiled
3964 dnl Configure defines HAVE_SYSMOUSE, if it is defined feature.h
3965 dnl defines FEAT_SYSMOUSE if mouse support is included
3966 AC_CACHE_CHECK([for sysmouse], vi_cv_have_sysmouse,
3967 AC_TRY_LINK(
3968 [#include <sys/consio.h>
3969 #include <signal.h>
3970 #include <sys/fbio.h>],
3971 [struct mouse_info mouse;
3972 mouse.operation = MOUSE_MODE;
3973 mouse.operation = MOUSE_SHOW;
3974 mouse.u.mode.mode = 0;
3975 mouse.u.mode.signal = SIGUSR2;],
3976 [vi_cv_have_sysmouse=yes],
3977 [vi_cv_have_sysmouse=no])
3978 )
3979 if test $vi_cv_have_sysmouse = yes; then
3980 AC_DEFINE(HAVE_SYSMOUSE)
3981 fi
3982else
3983 AC_MSG_RESULT(yes)
3984fi
3985
Bram Moolenaarf05da212009-11-17 16:13:15 +00003986dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
3987AC_MSG_CHECKING(for FD_CLOEXEC)
3988AC_TRY_COMPILE(
3989[#if HAVE_FCNTL_H
3990# include <fcntl.h>
3991#endif],
3992[ int flag = FD_CLOEXEC;],
3993 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
3994 AC_MSG_RESULT(not usable))
3995
Bram Moolenaar071d4272004-06-13 20:20:40 +00003996dnl rename needs to be checked separately to work on Nextstep with cc
3997AC_MSG_CHECKING(for rename)
3998AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
3999 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
4000 AC_MSG_RESULT(no))
4001
4002dnl sysctl() may exist but not the arguments we use
4003AC_MSG_CHECKING(for sysctl)
4004AC_TRY_COMPILE(
4005[#include <sys/types.h>
4006#include <sys/sysctl.h>],
4007[ int mib[2], r;
4008 size_t len;
4009
4010 mib[0] = CTL_HW;
4011 mib[1] = HW_USERMEM;
4012 len = sizeof(r);
4013 (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
4014 ],
4015 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL),
4016 AC_MSG_RESULT(not usable))
4017
4018dnl sysinfo() may exist but not be Linux compatible
4019AC_MSG_CHECKING(for sysinfo)
4020AC_TRY_COMPILE(
4021[#include <sys/types.h>
4022#include <sys/sysinfo.h>],
4023[ struct sysinfo sinfo;
4024 int t;
4025
4026 (void)sysinfo(&sinfo);
4027 t = sinfo.totalram;
4028 ],
4029 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
4030 AC_MSG_RESULT(not usable))
4031
Bram Moolenaar914572a2007-05-01 11:37:47 +00004032dnl struct sysinfo may have the mem_unit field or not
4033AC_MSG_CHECKING(for sysinfo.mem_unit)
4034AC_TRY_COMPILE(
4035[#include <sys/types.h>
4036#include <sys/sysinfo.h>],
4037[ struct sysinfo sinfo;
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02004038 sinfo.mem_unit = 1;
Bram Moolenaar914572a2007-05-01 11:37:47 +00004039 ],
4040 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_MEM_UNIT),
4041 AC_MSG_RESULT(no))
4042
Bram Moolenaar071d4272004-06-13 20:20:40 +00004043dnl sysconf() may exist but not support what we want to use
4044AC_MSG_CHECKING(for sysconf)
4045AC_TRY_COMPILE(
4046[#include <unistd.h>],
4047[ (void)sysconf(_SC_PAGESIZE);
4048 (void)sysconf(_SC_PHYS_PAGES);
4049 ],
4050 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
4051 AC_MSG_RESULT(not usable))
4052
Bram Moolenaar914703b2010-05-31 21:59:46 +02004053AC_CHECK_SIZEOF([int])
4054AC_CHECK_SIZEOF([long])
4055AC_CHECK_SIZEOF([time_t])
4056AC_CHECK_SIZEOF([off_t])
Bram Moolenaar644fdff2010-05-30 13:26:21 +02004057
Bram Moolenaara2aa31a2014-02-23 22:52:40 +01004058dnl Use different names to avoid clashing with other header files.
4059AC_DEFINE_UNQUOTED(VIM_SIZEOF_INT, [$ac_cv_sizeof_int])
4060AC_DEFINE_UNQUOTED(VIM_SIZEOF_LONG, [$ac_cv_sizeof_long])
4061
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004062dnl Make sure that uint32_t is really 32 bits unsigned.
4063AC_MSG_CHECKING([uint32_t is 32 bits])
4064AC_TRY_RUN([
4065#ifdef HAVE_STDINT_H
4066# include <stdint.h>
4067#endif
4068#ifdef HAVE_INTTYPES_H
4069# include <inttypes.h>
4070#endif
4071main() {
4072 uint32_t nr1 = (uint32_t)-1;
4073 uint32_t nr2 = (uint32_t)0xffffffffUL;
4074 if (sizeof(uint32_t) != 4 || nr1 != 0xffffffffUL || nr2 + 1 != 0) exit(1);
4075 exit(0);
4076}],
4077AC_MSG_RESULT(ok),
4078AC_MSG_ERROR([WRONG! uint32_t not defined correctly.]),
Bram Moolenaar323cb952011-12-14 19:22:34 +01004079AC_MSG_WARN([cannot check uint32_t when cross-compiling.]))
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004080
Bram Moolenaar446cb832008-06-24 21:56:24 +00004081dnl Check for memmove() before bcopy(), makes memmove() be used when both are
4082dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
4083
Bram Moolenaar071d4272004-06-13 20:20:40 +00004084[bcopy_test_prog='
Bram Moolenaar446cb832008-06-24 21:56:24 +00004085#include "confdefs.h"
4086#ifdef HAVE_STRING_H
4087# include <string.h>
4088#endif
4089#if STDC_HEADERS
4090# include <stdlib.h>
4091# include <stddef.h>
4092#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004093main() {
4094 char buf[10];
4095 strcpy(buf, "abcdefghi");
4096 mch_memmove(buf, buf + 2, 3);
4097 if (strncmp(buf, "ababcf", 6))
4098 exit(1);
4099 strcpy(buf, "abcdefghi");
4100 mch_memmove(buf + 2, buf, 3);
4101 if (strncmp(buf, "cdedef", 6))
4102 exit(1);
4103 exit(0); /* libc version works properly. */
4104}']
4105
Bram Moolenaar446cb832008-06-24 21:56:24 +00004106AC_CACHE_CHECK([whether memmove handles overlaps],[vim_cv_memmove_handles_overlap],
4107 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004108 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 +00004109 [
4110 vim_cv_memmove_handles_overlap=yes
4111 ],[
4112 vim_cv_memmove_handles_overlap=no
4113 ],[
4114 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memmove_handles_overlap')
4115 ])
4116 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00004117
Bram Moolenaar446cb832008-06-24 21:56:24 +00004118if test "x$vim_cv_memmove_handles_overlap" = "xyes" ; then
4119 AC_DEFINE(USEMEMMOVE)
4120else
4121 AC_CACHE_CHECK([whether bcopy handles overlaps],[vim_cv_bcopy_handles_overlap],
4122 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004123 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 +00004124 [
4125 vim_cv_bcopy_handles_overlap=yes
4126 ],[
4127 vim_cv_bcopy_handles_overlap=no
4128 ],[
4129 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_bcopy_handles_overlap')
4130 ])
4131 ])
4132
4133 if test "x$vim_cv_bcopy_handles_overlap" = "xyes" ; then
4134 AC_DEFINE(USEBCOPY)
4135 else
4136 AC_CACHE_CHECK([whether memcpy handles overlaps],[vim_cv_memcpy_handles_overlap],
4137 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004138 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 +00004139 [
4140 vim_cv_memcpy_handles_overlap=yes
4141 ],[
4142 vim_cv_memcpy_handles_overlap=no
4143 ],[
4144 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memcpy_handles_overlap')
4145 ])
4146 ])
4147
4148 if test "x$vim_cv_memcpy_handles_overlap" = "xyes" ; then
4149 AC_DEFINE(USEMEMCPY)
4150 fi
4151 fi
4152fi
4153
Bram Moolenaar071d4272004-06-13 20:20:40 +00004154
4155dnl Check for multibyte locale functions
4156dnl Find out if _Xsetlocale() is supported by libX11.
4157dnl Check if X_LOCALE should be defined.
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004158if test "x$with_x" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004159 cflags_save=$CFLAGS
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004160 libs_save=$LIBS
4161 LIBS="$LIBS $X_LIBS $GUI_LIB_LOC $GUI_X_LIBS $X_PRE_LIBS $X_LIB $X_EXTRA_LIBS"
4162 CFLAGS="$CFLAGS $X_CFLAGS"
4163
4164 AC_MSG_CHECKING(whether X_LOCALE needed)
4165 AC_TRY_COMPILE([#include <X11/Xlocale.h>],,
4166 AC_TRY_LINK_FUNC([_Xsetlocale], [AC_MSG_RESULT(yes)
4167 AC_DEFINE(X_LOCALE)], AC_MSG_RESULT(no)),
4168 AC_MSG_RESULT(no))
4169
4170 AC_MSG_CHECKING(whether Xutf8SetWMProperties() can be used)
4171 AC_TRY_LINK_FUNC([Xutf8SetWMProperties], [AC_MSG_RESULT(yes)
4172 AC_DEFINE(HAVE_XUTF8SETWMPROPERTIES)], AC_MSG_RESULT(no))
4173
Bram Moolenaar071d4272004-06-13 20:20:40 +00004174 CFLAGS=$cflags_save
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004175 LIBS=$libs_save
Bram Moolenaar071d4272004-06-13 20:20:40 +00004176fi
4177
4178dnl Link with xpg4, it is said to make Korean locale working
4179AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,)
4180
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004181dnl Check how we can run ctags. Default to "ctags" when nothing works.
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02004182dnl Use --version to detect Exuberant ctags (preferred)
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004183dnl Add --fields=+S to get function signatures for omni completion.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004184dnl -t for typedefs (many ctags have this)
4185dnl -s for static functions (Elvis ctags only?)
4186dnl -v for variables. Dangerous, most ctags take this for 'vgrind style'.
4187dnl -i+m to test for older Exuberant ctags
4188AC_MSG_CHECKING(how to create tags)
4189test -f tags && mv tags tags.save
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004190if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004191 TAGPRG="ctags -I INIT+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004192elif (eval exctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
4193 TAGPRG="exctags -I INIT+ --fields=+S"
4194elif (eval exuberant-ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
4195 TAGPRG="exuberant-ctags -I INIT+ --fields=+S"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004196else
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004197 TAGPRG="ctags"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004198 (eval etags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags"
4199 (eval etags -c /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags -c"
4200 (eval ctags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags"
4201 (eval ctags -t /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -t"
4202 (eval ctags -ts /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -ts"
4203 (eval ctags -tvs /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -tvs"
4204 (eval ctags -i+m /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -i+m"
4205fi
4206test -f tags.save && mv tags.save tags
4207AC_MSG_RESULT($TAGPRG) AC_SUBST(TAGPRG)
4208
4209dnl Check how we can run man with a section number
4210AC_MSG_CHECKING(how to run man with a section nr)
4211MANDEF="man"
Bram Moolenaar8b131502008-02-13 09:28:19 +00004212(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 +00004213AC_MSG_RESULT($MANDEF)
4214if test "$MANDEF" = "man -s"; then
4215 AC_DEFINE(USEMAN_S)
4216fi
4217
4218dnl Check if gettext() is working and if it needs -lintl
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004219dnl We take care to base this on an empty LIBS: on some systems libelf would be
4220dnl in LIBS and implicitly take along libintl. The final LIBS would then not
4221dnl contain libintl, and the link step would fail due to -Wl,--as-needed.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004222AC_MSG_CHECKING(--disable-nls argument)
4223AC_ARG_ENABLE(nls,
4224 [ --disable-nls Don't support NLS (gettext()).], ,
4225 [enable_nls="yes"])
4226
4227if test "$enable_nls" = "yes"; then
4228 AC_MSG_RESULT(no)
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00004229
4230 INSTALL_LANGS=install-languages
4231 AC_SUBST(INSTALL_LANGS)
4232 INSTALL_TOOL_LANGS=install-tool-languages
4233 AC_SUBST(INSTALL_TOOL_LANGS)
4234
Bram Moolenaar071d4272004-06-13 20:20:40 +00004235 AC_CHECK_PROG(MSGFMT, msgfmt, msgfmt, )
4236 AC_MSG_CHECKING([for NLS])
4237 if test -f po/Makefile; then
4238 have_gettext="no"
4239 if test -n "$MSGFMT"; then
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004240 olibs=$LIBS
4241 LIBS=""
Bram Moolenaar071d4272004-06-13 20:20:40 +00004242 AC_TRY_LINK(
4243 [#include <libintl.h>],
4244 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004245 AC_MSG_RESULT([gettext() works]); have_gettext="yes"; LIBS=$olibs,
4246 LIBS="-lintl"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004247 AC_TRY_LINK(
4248 [#include <libintl.h>],
4249 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004250 AC_MSG_RESULT([gettext() works with -lintl]); have_gettext="yes";
4251 LIBS="$olibs -lintl",
Bram Moolenaar071d4272004-06-13 20:20:40 +00004252 AC_MSG_RESULT([gettext() doesn't work]);
4253 LIBS=$olibs))
4254 else
4255 AC_MSG_RESULT([msgfmt not found - disabled]);
4256 fi
Bram Moolenaar278eb582014-07-30 13:22:52 +02004257 if test $have_gettext = "yes" -a "x$features" != "xtiny" -a "x$features" != "xsmall"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004258 AC_DEFINE(HAVE_GETTEXT)
4259 MAKEMO=yes
4260 AC_SUBST(MAKEMO)
4261 dnl this was added in GNU gettext 0.10.36
4262 AC_CHECK_FUNCS(bind_textdomain_codeset)
4263 dnl _nl_msg_cat_cntr is required for GNU gettext
4264 AC_MSG_CHECKING([for _nl_msg_cat_cntr])
4265 AC_TRY_LINK(
4266 [#include <libintl.h>
4267 extern int _nl_msg_cat_cntr;],
4268 [++_nl_msg_cat_cntr;],
4269 AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_NL_MSG_CAT_CNTR),
4270 AC_MSG_RESULT([no]))
4271 fi
4272 else
4273 AC_MSG_RESULT([no "po/Makefile" - disabled]);
4274 fi
4275else
4276 AC_MSG_RESULT(yes)
4277fi
4278
4279dnl Check for dynamic linking loader
4280AC_CHECK_HEADER(dlfcn.h, DLL=dlfcn.h, [AC_CHECK_HEADER(dl.h, DLL=dl.h)])
4281if test x${DLL} = xdlfcn.h; then
4282 AC_DEFINE(HAVE_DLFCN_H, 1, [ Define if we have dlfcn.h. ])
4283 AC_MSG_CHECKING([for dlopen()])
4284 AC_TRY_LINK(,[
4285 extern void* dlopen();
4286 dlopen();
4287 ],
4288 AC_MSG_RESULT(yes);
4289 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4290 AC_MSG_RESULT(no);
4291 AC_MSG_CHECKING([for dlopen() in -ldl])
4292 olibs=$LIBS
4293 LIBS="$LIBS -ldl"
4294 AC_TRY_LINK(,[
4295 extern void* dlopen();
4296 dlopen();
4297 ],
4298 AC_MSG_RESULT(yes);
4299 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4300 AC_MSG_RESULT(no);
4301 LIBS=$olibs))
4302 dnl ReliantUNIX has dlopen() in libc but everything else in libdl
4303 dnl ick :-)
4304 AC_MSG_CHECKING([for dlsym()])
4305 AC_TRY_LINK(,[
4306 extern void* dlsym();
4307 dlsym();
4308 ],
4309 AC_MSG_RESULT(yes);
4310 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4311 AC_MSG_RESULT(no);
4312 AC_MSG_CHECKING([for dlsym() in -ldl])
4313 olibs=$LIBS
4314 LIBS="$LIBS -ldl"
4315 AC_TRY_LINK(,[
4316 extern void* dlsym();
4317 dlsym();
4318 ],
4319 AC_MSG_RESULT(yes);
4320 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4321 AC_MSG_RESULT(no);
4322 LIBS=$olibs))
4323elif test x${DLL} = xdl.h; then
4324 AC_DEFINE(HAVE_DL_H, 1, [ Define if we have dl.h. ])
4325 AC_MSG_CHECKING([for shl_load()])
4326 AC_TRY_LINK(,[
4327 extern void* shl_load();
4328 shl_load();
4329 ],
4330 AC_MSG_RESULT(yes);
4331 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4332 AC_MSG_RESULT(no);
4333 AC_MSG_CHECKING([for shl_load() in -ldld])
4334 olibs=$LIBS
4335 LIBS="$LIBS -ldld"
4336 AC_TRY_LINK(,[
4337 extern void* shl_load();
4338 shl_load();
4339 ],
4340 AC_MSG_RESULT(yes);
4341 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4342 AC_MSG_RESULT(no);
4343 LIBS=$olibs))
4344fi
4345AC_CHECK_HEADERS(setjmp.h)
4346
Bram Moolenaard0573012017-10-28 21:11:06 +02004347if test "x$MACOS_X" = "xyes" -a -n "$PERL"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004348 dnl -ldl must come after DynaLoader.a
4349 if echo $LIBS | grep -e '-ldl' >/dev/null; then
4350 LIBS=`echo $LIBS | sed s/-ldl//`
4351 PERL_LIBS="$PERL_LIBS -ldl"
4352 fi
4353fi
4354
Bram Moolenaard0573012017-10-28 21:11:06 +02004355if test "$MACOS_X" = "yes"; then
4356 AC_MSG_CHECKING([whether we need macOS frameworks])
4357 if test "$GUITYPE" = "CARBONGUI"; then
4358 AC_MSG_RESULT([yes, we need Carbon])
4359 LIBS="$LIBS -framework Carbon"
4360 elif test "$MACOS_X_DARWIN" = "yes"; then
4361 if test "$features" = "tiny"; then
4362 dnl Since no FEAT_CLIPBOARD, no longer need for os_macosx.m.
4363 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_macosx.m++'`
4364 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_macosx.o++'`
4365 if test "$enable_multibyte" = "yes"; then
4366 AC_MSG_RESULT([yes, we need CoreServices])
4367 LIBS="$LIBS -framework CoreServices"
4368 else
4369 dnl Since no FEAT_MBYTE, no longer need for os_mac_conv.c.
4370 AC_MSG_RESULT([no])
4371 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_mac_conv.c++'`
4372 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_mac_conv.o++'`
4373 CPPFLAGS=`echo "$CPPFLAGS" | sed -e 's+-DMACOS_X_DARWIN++'`
4374 fi
4375 else
4376 AC_MSG_RESULT([yes, we need AppKit])
4377 LIBS="$LIBS -framework AppKit"
4378 if test "$features" = "small" -a "$enable_multibyte" = "no"; then
4379 dnl Since FEAT_CLIPBOARD is to be defined in vim.h for FEAT_SMALL, define
4380 dnl FEAT_MBYTE in order not to compromise the interoperability of the
4381 dnl clipboard.
4382 AC_MSG_NOTICE([+multi_byte will be set in favor of +clipboard])
4383 enable_multibyte=yes
4384 AC_DEFINE(FEAT_MBYTE)
4385 fi
4386 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004387 else
Bram Moolenaard0573012017-10-28 21:11:06 +02004388 AC_MSG_RESULT([no])
Bram Moolenaar3437b912013-07-03 19:52:53 +02004389 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004390fi
Bram Moolenaar164fca32010-07-14 13:58:07 +02004391if test "x$MACARCH" = "xboth" && test "x$GUITYPE" = "xCARBONGUI"; then
Bram Moolenaar595a7be2010-03-10 16:28:12 +01004392 LDFLAGS="$LDFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +00004393fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004394
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004395dnl gcc 3.1 changed the meaning of -MM. The only solution appears to be to
4396dnl use "-isystem" instead of "-I" for all non-Vim include dirs.
4397dnl But only when making dependencies, cproto and lint don't take "-isystem".
Bram Moolenaar32466aa2006-02-24 23:53:04 +00004398dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
4399dnl the number before the version number.
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004400DEPEND_CFLAGS_FILTER=
4401if test "$GCC" = yes; then
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004402 AC_MSG_CHECKING(for GCC 3 or later)
Bram Moolenaar2217cae2006-03-25 21:55:52 +00004403 gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]]\)\..*$/\1/g'`
Bram Moolenaarf740b292006-02-16 22:11:02 +00004404 if test "$gccmajor" -gt "2"; then
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004405 DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004406 AC_MSG_RESULT(yes)
4407 else
4408 AC_MSG_RESULT(no)
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004409 fi
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004410 dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
4411 dnl declared as char x[1] but actually longer. Introduced in gcc 4.0.
Bram Moolenaar56d1db32009-12-16 16:14:51 +00004412 dnl Also remove duplicate _FORTIFY_SOURCE arguments.
Bram Moolenaaraeabe052011-12-08 15:17:34 +01004413 dnl And undefine it first to avoid a warning.
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004414 AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
4415 if test "$gccmajor" -gt "3"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02004416 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 +00004417 AC_MSG_RESULT(yes)
4418 else
4419 AC_MSG_RESULT(no)
4420 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +00004421fi
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004422AC_SUBST(DEPEND_CFLAGS_FILTER)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004423
Bram Moolenaarec0557f2018-01-31 14:41:37 +01004424dnl On some systems AC_SYS_LARGEFILE determines that -D_FILE_OFFSET_BITS=64
4425dnl isn't required, but the CFLAGS for some of the libraries we're using
4426dnl include the define. Since the define changes the size of some datatypes
4427dnl (e.g. ino_t and off_t), all of Vim's modules must be compiled with a
4428dnl consistent value. It's therefore safest to force the use of the define
4429dnl if it's present in any of the *_CFLAGS variables.
4430AC_MSG_CHECKING(whether we need to force -D_FILE_OFFSET_BITS=64)
Bram Moolenaar9ce42132018-04-11 22:19:36 +02004431if 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 +01004432 AC_MSG_RESULT(yes)
4433 AC_DEFINE(_FILE_OFFSET_BITS, 64)
4434else
4435 AC_MSG_RESULT(no)
4436fi
4437
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004438dnl link.sh tries to avoid overlinking in a hackish way.
4439dnl At least GNU ld supports --as-needed which provides the same functionality
4440dnl at linker level. Let's use it.
4441AC_MSG_CHECKING(linker --as-needed support)
4442LINK_AS_NEEDED=
4443# Check if linker supports --as-needed and --no-as-needed options
4444if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02004445 LDFLAGS=`echo "$LDFLAGS" | sed -e 's/ *-Wl,--as-needed//g' | sed -e 's/$/ -Wl,--as-needed/'`
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004446 LINK_AS_NEEDED=yes
4447fi
4448if test "$LINK_AS_NEEDED" = yes; then
4449 AC_MSG_RESULT(yes)
4450else
4451 AC_MSG_RESULT(no)
4452fi
4453AC_SUBST(LINK_AS_NEEDED)
4454
Bram Moolenaar77c19352012-06-13 19:19:41 +02004455# IBM z/OS reset CFLAGS for config.mk
4456if test "$zOSUnix" = "yes"; then
4457 CFLAGS="-D_ALL_SOURCE -Wc,float\(ieee\),dll"
4458fi
4459
Bram Moolenaar071d4272004-06-13 20:20:40 +00004460dnl write output files
4461AC_OUTPUT(auto/config.mk:config.mk.in)
4462
4463dnl vim: set sw=2 tw=78 fo+=l: