blob: 7f552818392288a305719982563f01f45488fecd [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 Moolenaar071d4272004-06-13 20:20:40 +000075dnl Set default value for CFLAGS if none is defined or it's empty
76if test -z "$CFLAGS"; then
77 CFLAGS="-O"
78 test "$GCC" = yes && CFLAGS="-O2 -fno-strength-reduce -Wall"
79fi
80if test "$GCC" = yes; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +000081 dnl method that should work for nearly all versions
Bram Moolenaarc8836f72014-04-12 13:12:24 +020082 gccversion=`$CC -dumpversion`
Bram Moolenaar910f66f2006-04-05 20:41:53 +000083 if test "x$gccversion" = "x"; then
84 dnl old method; fall-back for when -dumpversion doesn't work
Bram Moolenaarc8836f72014-04-12 13:12:24 +020085 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 +000086 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +000087 dnl version 4.0.1 was reported to cause trouble on Macintosh by Marcin Dalecki
88 if test "$gccversion" = "3.0.1" -o "$gccversion" = "3.0.2" -o "$gccversion" = "4.0.1"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +000089 echo 'GCC [[34]].0.[[12]] has a bug in the optimizer, disabling "-O#"'
Bram Moolenaar071d4272004-06-13 20:20:40 +000090 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-O/'`
91 else
92 if test "$gccversion" = "3.1" -o "$gccversion" = "3.2" -o "$gccversion" = "3.2.1" && `echo "$CFLAGS" | grep -v fno-strength-reduce >/dev/null`; then
93 echo 'GCC 3.1 and 3.2 have a bug in the optimizer, adding "-fno-strength-reduce"'
94 CFLAGS="$CFLAGS -fno-strength-reduce"
95 fi
96 fi
97fi
98
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +020099dnl clang-500.2.75 or around has abandoned -f[no-]strength-reduce and issues a
100dnl warning when that flag is passed to. Accordingly, adjust CFLAGS based on
101dnl the version number of the clang in use.
102dnl Note that this does not work to get the version of clang 3.1 or 3.2.
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100103AC_MSG_CHECKING(for clang version)
104CLANG_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 +0200105if test x"$CLANG_VERSION_STRING" != x"" ; then
106 CLANG_MAJOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*/\1/p'`
107 CLANG_MINOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/p'`
108 CLANG_REVISION=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)/\1/p'`
109 CLANG_VERSION=`expr $CLANG_MAJOR '*' 1000000 '+' $CLANG_MINOR '*' 1000 '+' $CLANG_REVISION`
110 AC_MSG_RESULT($CLANG_VERSION)
111 dnl If you find the same issue with versions earlier than 500.2.75,
112 dnl change the constant 500002075 below appropriately. To get the
113 dnl integer corresponding to a version number, refer to the
114 dnl definition of CLANG_VERSION above.
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100115 AC_MSG_CHECKING(if clang supports -fno-strength-reduce)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200116 if test "$CLANG_VERSION" -ge 500002075 ; then
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100117 AC_MSG_RESULT(no)
118 CFLAGS=`echo "$CFLAGS" | sed -e 's/-fno-strength-reduce/ /'`
119 else
120 AC_MSG_RESULT(yes)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200121 fi
122else
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100123 AC_MSG_RESULT(N/A)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200124fi
125
Bram Moolenaar446cb832008-06-24 21:56:24 +0000126dnl If configure thinks we are cross compiling, there might be something
127dnl wrong with the CC or CFLAGS settings, give a useful warning message
Bram Moolenaar839e9542016-04-14 16:46:02 +0200128CROSS_COMPILING=
Bram Moolenaar071d4272004-06-13 20:20:40 +0000129if test "$cross_compiling" = yes; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000130 AC_MSG_RESULT([cannot compile a simple program; if not cross compiling check CC and CFLAGS])
Bram Moolenaar839e9542016-04-14 16:46:02 +0200131 CROSS_COMPILING=1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000132fi
Bram Moolenaar839e9542016-04-14 16:46:02 +0200133AC_SUBST(CROSS_COMPILING)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000134
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +0000135dnl gcc-cpp has the wonderful -MM option to produce nicer dependencies.
136dnl But gcc 3.1 changed the meaning! See near the end.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000137test "$GCC" = yes && CPP_MM=M; AC_SUBST(CPP_MM)
138
139if test -f ./toolcheck; then
140 AC_CHECKING(for buggy tools)
141 sh ./toolcheck 1>&AC_FD_MSG
142fi
143
144OS_EXTRA_SRC=""; OS_EXTRA_OBJ=""
145
146dnl Check for BeOS, which needs an extra source file
147AC_MSG_CHECKING(for BeOS)
148case `uname` in
149 BeOS) OS_EXTRA_SRC=os_beos.c; OS_EXTRA_OBJ=objects/os_beos.o
150 BEOS=yes; AC_MSG_RESULT(yes);;
151 *) BEOS=no; AC_MSG_RESULT(no);;
152esac
153
154dnl If QNX is found, assume we don't want to use Xphoton
155dnl unless it was specifically asked for (--with-x)
156AC_MSG_CHECKING(for QNX)
157case `uname` in
158 QNX) OS_EXTRA_SRC=os_qnx.c; OS_EXTRA_OBJ=objects/os_qnx.o
159 test -z "$with_x" && with_x=no
160 QNX=yes; AC_MSG_RESULT(yes);;
161 *) QNX=no; AC_MSG_RESULT(no);;
162esac
163
164dnl Check for Darwin and MacOS X
165dnl We do a check for MacOS X in the very beginning because there
166dnl are a lot of other things we need to change besides GUI stuff
Bram Moolenaar071d4272004-06-13 20:20:40 +0000167AC_MSG_CHECKING([for Darwin (Mac OS X)])
168if test "`(uname) 2>/dev/null`" = Darwin; then
169 AC_MSG_RESULT(yes)
Bram Moolenaard0573012017-10-28 21:11:06 +0200170 MACOS_X=yes
Bram Moolenaar2e324952018-04-14 14:37:07 +0200171 CPPFLAGS="$CPPFLAGS -D_DARWIN_C_SOURCE -DMACOS_X"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000172
173 AC_MSG_CHECKING(--disable-darwin argument)
174 AC_ARG_ENABLE(darwin,
175 [ --disable-darwin Disable Darwin (Mac OS X) support.],
176 , [enable_darwin="yes"])
177 if test "$enable_darwin" = "yes"; then
178 AC_MSG_RESULT(no)
179 AC_MSG_CHECKING(if Darwin files are there)
Bram Moolenaar164fca32010-07-14 13:58:07 +0200180 if test -f os_macosx.m; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000181 AC_MSG_RESULT(yes)
182 else
183 AC_MSG_RESULT([no, Darwin support disabled])
184 enable_darwin=no
185 fi
186 else
187 AC_MSG_RESULT([yes, Darwin support excluded])
188 fi
189
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000190 AC_MSG_CHECKING(--with-mac-arch argument)
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000191 AC_ARG_WITH(mac-arch, [ --with-mac-arch=ARCH current, intel, ppc or both],
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000192 MACARCH="$withval"; AC_MSG_RESULT($MACARCH),
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000193 MACARCH="current"; AC_MSG_RESULT(defaulting to $MACARCH))
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000194
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100195 AC_MSG_CHECKING(--with-developer-dir argument)
196 AC_ARG_WITH(developer-dir, [ --with-developer-dir=PATH use PATH as location for Xcode developer tools],
197 DEVELOPER_DIR="$withval"; AC_MSG_RESULT($DEVELOPER_DIR),
Bram Moolenaar32d03b32015-11-19 13:46:48 +0100198 AC_MSG_RESULT(not present))
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100199
200 if test "x$DEVELOPER_DIR" = "x"; then
201 AC_PATH_PROG(XCODE_SELECT, xcode-select)
202 if test "x$XCODE_SELECT" != "x"; then
203 AC_MSG_CHECKING(for developer dir using xcode-select)
204 DEVELOPER_DIR=`$XCODE_SELECT -print-path`
205 AC_MSG_RESULT([$DEVELOPER_DIR])
206 else
207 DEVELOPER_DIR=/Developer
208 fi
209 fi
210
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000211 if test "x$MACARCH" = "xboth"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000212 AC_MSG_CHECKING(for 10.4 universal SDK)
213 dnl There is a terrible inconsistency (but we appear to get away with it):
214 dnl $CFLAGS uses the 10.4u SDK library for the headers, while $CPPFLAGS
215 dnl doesn't, because "gcc -E" doesn't grok it. That means the configure
216 dnl tests using the preprocessor are actually done with the wrong header
217 dnl files. $LDFLAGS is set at the end, because configure uses it together
218 dnl with $CFLAGS and we can only have one -sysroot argument.
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000219 save_cppflags="$CPPFLAGS"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000220 save_cflags="$CFLAGS"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000221 save_ldflags="$LDFLAGS"
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100222 CFLAGS="$CFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000223 AC_TRY_LINK([ ], [ ],
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000224 AC_MSG_RESULT(found, will make universal binary),
225
226 AC_MSG_RESULT(not found)
Bram Moolenaar1f35bf92006-03-07 22:38:47 +0000227 CFLAGS="$save_cflags"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000228 AC_MSG_CHECKING(if Intel architecture is supported)
229 CPPFLAGS="$CPPFLAGS -arch i386"
230 LDFLAGS="$save_ldflags -arch i386"
231 AC_TRY_LINK([ ], [ ],
232 AC_MSG_RESULT(yes); MACARCH="intel",
233 AC_MSG_RESULT(no, using PowerPC)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000234 MACARCH="ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000235 CPPFLAGS="$save_cppflags -arch ppc"
236 LDFLAGS="$save_ldflags -arch ppc"))
237 elif test "x$MACARCH" = "xintel"; then
238 CPPFLAGS="$CPPFLAGS -arch intel"
239 LDFLAGS="$LDFLAGS -arch intel"
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000240 elif test "x$MACARCH" = "xppc"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000241 CPPFLAGS="$CPPFLAGS -arch ppc"
242 LDFLAGS="$LDFLAGS -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000243 fi
244
Bram Moolenaar071d4272004-06-13 20:20:40 +0000245 if test "$enable_darwin" = "yes"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200246 MACOS_X_DARWIN=yes
Bram Moolenaar164fca32010-07-14 13:58:07 +0200247 OS_EXTRA_SRC="os_macosx.m os_mac_conv.c";
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000248 OS_EXTRA_OBJ="objects/os_macosx.o objects/os_mac_conv.o"
Bram Moolenaar32466aa2006-02-24 23:53:04 +0000249 dnl TODO: use -arch i386 on Intel machines
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100250 dnl Removed -no-cpp-precomp, only for very old compilers.
Bram Moolenaard0573012017-10-28 21:11:06 +0200251 CPPFLAGS="$CPPFLAGS -DMACOS_X_DARWIN"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000252
253 dnl If Carbon is found, assume we don't want X11
254 dnl unless it was specifically asked for (--with-x)
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000255 dnl or Motif, Athena or GTK GUI is used.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000256 AC_CHECK_HEADER(Carbon/Carbon.h, CARBON=yes)
257 if test "x$CARBON" = "xyes"; then
Bram Moolenaar98921892016-02-23 17:14:37 +0100258 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 +0000259 with_x=no
Bram Moolenaar071d4272004-06-13 20:20:40 +0000260 fi
261 fi
262 fi
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000263
Bram Moolenaardb552d602006-03-23 22:59:57 +0000264 dnl Avoid a bug with -O2 with gcc 4.0.1. Symptom: malloc() reports double
Bram Moolenaarfd2ac762006-03-01 22:09:21 +0000265 dnl free. This happens in expand_filename(), because the optimizer swaps
Bram Moolenaardb552d602006-03-23 22:59:57 +0000266 dnl two blocks of code, both using "repl", that can't be swapped.
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000267 if test "$MACARCH" = "intel" -o "$MACARCH" = "both"; then
268 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-Oz/'`
269 fi
270
Bram Moolenaar071d4272004-06-13 20:20:40 +0000271else
272 AC_MSG_RESULT(no)
273fi
274
Bram Moolenaar39766a72013-11-03 00:41:00 +0100275dnl Mac OS X 10.9+ no longer include AvailabilityMacros.h in Carbon
276dnl so we need to include it to have access to version macros.
Bram Moolenaar18e54692013-11-03 20:26:31 +0100277AC_CHECK_HEADERS(AvailabilityMacros.h)
Bram Moolenaar39766a72013-11-03 00:41:00 +0100278
Bram Moolenaar071d4272004-06-13 20:20:40 +0000279AC_SUBST(OS_EXTRA_SRC)
280AC_SUBST(OS_EXTRA_OBJ)
281
282dnl Add /usr/local/lib to $LDFLAGS and /usr/local/include to CFLAGS.
283dnl Only when the directory exists and it wasn't there yet.
284dnl For gcc don't do this when it is already in the default search path.
Bram Moolenaar446cb832008-06-24 21:56:24 +0000285dnl Skip all of this when cross-compiling.
286if test "$cross_compiling" = no; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000287 AC_MSG_CHECKING(--with-local-dir argument)
Bram Moolenaar446cb832008-06-24 21:56:24 +0000288 have_local_include=''
289 have_local_lib=''
Bram Moolenaarc236c162008-07-13 17:41:49 +0000290 AC_ARG_WITH([local-dir], [ --with-local-dir=PATH search PATH instead of /usr/local for local libraries.
291 --without-local-dir do not search /usr/local for local libraries.], [
292 local_dir="$withval"
293 case "$withval" in
294 */*) ;;
295 no)
296 # avoid adding local dir to LDFLAGS and CPPFLAGS
Bram Moolenaare06c1882010-07-21 22:05:20 +0200297 have_local_include=yes
Bram Moolenaarc236c162008-07-13 17:41:49 +0000298 have_local_lib=yes
299 ;;
300 *) AC_MSG_ERROR(must pass path argument to --with-local-dir) ;;
301 esac
302 AC_MSG_RESULT($local_dir)
303 ], [
304 local_dir=/usr/local
305 AC_MSG_RESULT(Defaulting to $local_dir)
306 ])
307 if test "$GCC" = yes -a "$local_dir" != no; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000308 echo 'void f(){}' > conftest.c
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100309 dnl Removed -no-cpp-precomp, only needed for OS X 10.2 (Ben Fowler)
310 have_local_include=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/include"`
Bram Moolenaarc236c162008-07-13 17:41:49 +0000311 have_local_lib=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/lib"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000312 rm -f conftest.c conftest.o
Bram Moolenaar071d4272004-06-13 20:20:40 +0000313 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000314 if test -z "$have_local_lib" -a -d "${local_dir}/lib"; then
315 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 +0000316 if test "$tt" = "$LDFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000317 LDFLAGS="$LDFLAGS -L${local_dir}/lib"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000318 fi
319 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000320 if test -z "$have_local_include" -a -d "${local_dir}/include"; then
321 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 +0000322 if test "$tt" = "$CPPFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000323 CPPFLAGS="$CPPFLAGS -I${local_dir}/include"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000324 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000325 fi
326fi
327
328AC_MSG_CHECKING(--with-vim-name argument)
329AC_ARG_WITH(vim-name, [ --with-vim-name=NAME what to call the Vim executable],
330 VIMNAME="$withval"; AC_MSG_RESULT($VIMNAME),
Bram Moolenaare344bea2005-09-01 20:46:49 +0000331 VIMNAME="vim"; AC_MSG_RESULT(Defaulting to $VIMNAME))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000332AC_SUBST(VIMNAME)
333AC_MSG_CHECKING(--with-ex-name argument)
334AC_ARG_WITH(ex-name, [ --with-ex-name=NAME what to call the Ex executable],
335 EXNAME="$withval"; AC_MSG_RESULT($EXNAME),
336 EXNAME="ex"; AC_MSG_RESULT(Defaulting to ex))
337AC_SUBST(EXNAME)
338AC_MSG_CHECKING(--with-view-name argument)
339AC_ARG_WITH(view-name, [ --with-view-name=NAME what to call the View executable],
340 VIEWNAME="$withval"; AC_MSG_RESULT($VIEWNAME),
341 VIEWNAME="view"; AC_MSG_RESULT(Defaulting to view))
342AC_SUBST(VIEWNAME)
343
344AC_MSG_CHECKING(--with-global-runtime argument)
345AC_ARG_WITH(global-runtime, [ --with-global-runtime=DIR global runtime directory in 'runtimepath'],
346 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL, "$withval"),
347 AC_MSG_RESULT(no))
348
349AC_MSG_CHECKING(--with-modified-by argument)
350AC_ARG_WITH(modified-by, [ --with-modified-by=NAME name of who modified a release version],
351 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(MODIFIED_BY, "$withval"),
352 AC_MSG_RESULT(no))
353
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200354dnl Check for EBCDIC stolen from the LYNX port to z/OS Unix
Bram Moolenaar071d4272004-06-13 20:20:40 +0000355AC_MSG_CHECKING(if character set is EBCDIC)
356AC_TRY_COMPILE([ ],
357[ /* TryCompile function for CharSet.
358 Treat any failure as ASCII for compatibility with existing art.
359 Use compile-time rather than run-time tests for cross-compiler
360 tolerance. */
361#if '0'!=240
362make an error "Character set is not EBCDIC"
363#endif ],
364[ # TryCompile action if true
365cf_cv_ebcdic=yes ],
366[ # TryCompile action if false
367cf_cv_ebcdic=no])
368# end of TryCompile ])
369# end of CacheVal CvEbcdic
370AC_MSG_RESULT($cf_cv_ebcdic)
371case "$cf_cv_ebcdic" in #(vi
372 yes) AC_DEFINE(EBCDIC)
373 line_break='"\\n"'
374 ;;
375 *) line_break='"\\012"';;
376esac
377AC_SUBST(line_break)
378
379if test "$cf_cv_ebcdic" = "yes"; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +0200380dnl If we have EBCDIC we most likely have z/OS Unix, let's test it!
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200381AC_MSG_CHECKING(for z/OS Unix)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000382case `uname` in
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200383 OS/390) zOSUnix="yes";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000384 dnl If using cc the environment variable _CC_CCMODE must be
385 dnl set to "1", so that some compiler extensions are enabled.
386 dnl If using c89 the environment variable is named _CC_C89MODE.
387 dnl Note: compile with c89 never tested.
388 if test "$CC" = "cc"; then
389 ccm="$_CC_CCMODE"
390 ccn="CC"
391 else
392 if test "$CC" = "c89"; then
393 ccm="$_CC_C89MODE"
394 ccn="C89"
395 else
396 ccm=1
397 fi
398 fi
399 if test "$ccm" != "1"; then
400 echo ""
401 echo "------------------------------------------"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200402 echo " On z/OS Unix, the environment variable"
Bram Moolenaar77c19352012-06-13 19:19:41 +0200403 echo " _CC_${ccn}MODE must be set to \"1\"!"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000404 echo " Do:"
405 echo " export _CC_${ccn}MODE=1"
406 echo " and then call configure again."
407 echo "------------------------------------------"
408 exit 1
409 fi
Bram Moolenaar77c19352012-06-13 19:19:41 +0200410 # Set CFLAGS for configure process.
411 # This will be reset later for config.mk.
412 # Use haltonmsg to force error for missing H files.
413 CFLAGS="$CFLAGS -D_ALL_SOURCE -Wc,float(ieee),haltonmsg(3296)";
414 LDFLAGS="$LDFLAGS -Wl,EDIT=NO"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000415 AC_MSG_RESULT(yes)
416 ;;
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200417 *) zOSUnix="no";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000418 AC_MSG_RESULT(no)
419 ;;
420esac
421fi
422
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200423dnl Set QUOTESED. Needs additional backslashes on zOS
424if test "$zOSUnix" = "yes"; then
425 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\\\\\&/g' -e 's/\\\\\\\\\"/\"/' -e 's/\\\\\\\\\";\$\$/\";/'"
426else
427 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\&/g' -e 's/\\\\\"/\"/' -e 's/\\\\\";\$\$/\";/'"
428fi
429AC_SUBST(QUOTESED)
430
431
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200432dnl Link with -lsmack for Smack stuff; if not found
433AC_MSG_CHECKING(--disable-smack argument)
434AC_ARG_ENABLE(smack,
435 [ --disable-smack Do not check for Smack support.],
436 , enable_smack="yes")
437if test "$enable_smack" = "yes"; then
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200438 AC_MSG_RESULT(no)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200439 AC_CHECK_HEADER([linux/xattr.h], true, enable_smack="no")
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200440else
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200441 AC_MSG_RESULT(yes)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200442fi
443if test "$enable_smack" = "yes"; then
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200444 AC_CHECK_HEADER([attr/xattr.h], true, enable_smack="no")
445fi
446if test "$enable_smack" = "yes"; then
447 AC_MSG_CHECKING(for XATTR_NAME_SMACKEXEC in linux/xattr.h)
448 AC_EGREP_CPP(XATTR_NAME_SMACKEXEC, [#include <linux/xattr.h>],
449 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +0200450 AC_MSG_RESULT(no); enable_smack="no")
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200451fi
452if test "$enable_smack" = "yes"; then
453 AC_CHECK_LIB(attr, setxattr,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200454 [LIBS="$LIBS -lattr"
455 found_smack="yes"
456 AC_DEFINE(HAVE_SMACK)])
Bram Moolenaar588ebeb2008-05-07 17:09:24 +0000457fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000458
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200459dnl When smack was found don't search for SELinux
460if test "x$found_smack" = "x"; then
461 dnl Link with -lselinux for SELinux stuff; if not found
462 AC_MSG_CHECKING(--disable-selinux argument)
463 AC_ARG_ENABLE(selinux,
464 [ --disable-selinux Do not check for SELinux support.],
465 , enable_selinux="yes")
466 if test "$enable_selinux" = "yes"; then
467 AC_MSG_RESULT(no)
468 AC_CHECK_LIB(selinux, is_selinux_enabled,
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100469 [AC_CHECK_HEADER(selinux/selinux.h,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200470 [LIBS="$LIBS -lselinux"
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100471 AC_DEFINE(HAVE_SELINUX)])])
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200472 else
473 AC_MSG_RESULT(yes)
474 fi
475fi
476
Bram Moolenaar071d4272004-06-13 20:20:40 +0000477dnl Check user requested features.
478
479AC_MSG_CHECKING(--with-features argument)
Bram Moolenaareec29812016-07-26 21:27:36 +0200480AC_ARG_WITH(features, [ --with-features=TYPE tiny, small, normal, big or huge (default: huge)],
Bram Moolenaar071d4272004-06-13 20:20:40 +0000481 features="$withval"; AC_MSG_RESULT($features),
Bram Moolenaar23c4f712016-01-20 22:11:59 +0100482 features="huge"; AC_MSG_RESULT(Defaulting to huge))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000483
484dovimdiff=""
485dogvimdiff=""
486case "$features" in
487 tiny) AC_DEFINE(FEAT_TINY) ;;
488 small) AC_DEFINE(FEAT_SMALL) ;;
489 normal) AC_DEFINE(FEAT_NORMAL) dovimdiff="installvimdiff";
490 dogvimdiff="installgvimdiff" ;;
491 big) AC_DEFINE(FEAT_BIG) dovimdiff="installvimdiff";
492 dogvimdiff="installgvimdiff" ;;
493 huge) AC_DEFINE(FEAT_HUGE) dovimdiff="installvimdiff";
494 dogvimdiff="installgvimdiff" ;;
495 *) AC_MSG_RESULT([Sorry, $features is not supported]) ;;
496esac
497
498AC_SUBST(dovimdiff)
499AC_SUBST(dogvimdiff)
500
501AC_MSG_CHECKING(--with-compiledby argument)
502AC_ARG_WITH(compiledby, [ --with-compiledby=NAME name to show in :version message],
503 compiledby="$withval"; AC_MSG_RESULT($withval),
504 compiledby=""; AC_MSG_RESULT(no))
505AC_SUBST(compiledby)
506
507AC_MSG_CHECKING(--disable-xsmp argument)
508AC_ARG_ENABLE(xsmp,
509 [ --disable-xsmp Disable XSMP session management],
510 , enable_xsmp="yes")
511
512if test "$enable_xsmp" = "yes"; then
513 AC_MSG_RESULT(no)
514 AC_MSG_CHECKING(--disable-xsmp-interact argument)
515 AC_ARG_ENABLE(xsmp-interact,
516 [ --disable-xsmp-interact Disable XSMP interaction],
517 , enable_xsmp_interact="yes")
518 if test "$enable_xsmp_interact" = "yes"; then
519 AC_MSG_RESULT(no)
520 AC_DEFINE(USE_XSMP_INTERACT)
521 else
522 AC_MSG_RESULT(yes)
523 fi
524else
525 AC_MSG_RESULT(yes)
526fi
527
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200528dnl Check for Lua feature.
529AC_MSG_CHECKING(--enable-luainterp argument)
530AC_ARG_ENABLE(luainterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200531 [ --enable-luainterp[=OPTS] Include Lua interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200532 [enable_luainterp="no"])
533AC_MSG_RESULT($enable_luainterp)
534
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200535if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +0100536 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
537 AC_MSG_ERROR([cannot use Lua with tiny or small features])
538 fi
539
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200540 dnl -- find the lua executable
541 AC_SUBST(vi_cv_path_lua)
542
543 AC_MSG_CHECKING(--with-lua-prefix argument)
544 AC_ARG_WITH(lua_prefix,
545 [ --with-lua-prefix=PFX Prefix where Lua is installed.],
546 with_lua_prefix="$withval"; AC_MSG_RESULT($with_lua_prefix),
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200547 with_lua_prefix="";AC_MSG_RESULT(no))
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200548
549 if test "X$with_lua_prefix" != "X"; then
550 vi_cv_path_lua_pfx="$with_lua_prefix"
551 else
552 AC_MSG_CHECKING(LUA_PREFIX environment var)
553 if test "X$LUA_PREFIX" != "X"; then
554 AC_MSG_RESULT("$LUA_PREFIX")
555 vi_cv_path_lua_pfx="$LUA_PREFIX"
556 else
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200557 AC_MSG_RESULT([not set, default to /usr])
558 vi_cv_path_lua_pfx="/usr"
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200559 fi
560 fi
561
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200562 AC_MSG_CHECKING(--with-luajit)
563 AC_ARG_WITH(luajit,
564 [ --with-luajit Link with LuaJIT instead of Lua.],
565 [vi_cv_with_luajit="$withval"],
566 [vi_cv_with_luajit="no"])
567 AC_MSG_RESULT($vi_cv_with_luajit)
568
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200569 LUA_INC=
570 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200571 if test "x$vi_cv_with_luajit" != "xno"; then
572 dnl -- try to find LuaJIT executable
573 AC_PATH_PROG(vi_cv_path_luajit, luajit)
574 if test "X$vi_cv_path_luajit" != "X"; then
575 dnl -- find LuaJIT version
576 AC_CACHE_CHECK(LuaJIT version, vi_cv_version_luajit,
Bram Moolenaar49b10272013-11-21 12:17:51 +0100577 [ 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 +0200578 AC_CACHE_CHECK(Lua version of LuaJIT, vi_cv_version_lua_luajit,
579 [ vi_cv_version_lua_luajit=`${vi_cv_path_luajit} -e "print(_VERSION)" | sed 's/.* //'` ])
580 vi_cv_path_lua="$vi_cv_path_luajit"
581 vi_cv_version_lua="$vi_cv_version_lua_luajit"
582 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200583 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200584 dnl -- try to find Lua executable
585 AC_PATH_PROG(vi_cv_path_plain_lua, lua)
586 if test "X$vi_cv_path_plain_lua" != "X"; then
587 dnl -- find Lua version
588 AC_CACHE_CHECK(Lua version, vi_cv_version_plain_lua,
589 [ vi_cv_version_plain_lua=`${vi_cv_path_plain_lua} -e "print(_VERSION)" | sed 's/.* //'` ])
590 fi
591 vi_cv_path_lua="$vi_cv_path_plain_lua"
592 vi_cv_version_lua="$vi_cv_version_plain_lua"
593 fi
594 if test "x$vi_cv_with_luajit" != "xno" && test "X$vi_cv_version_luajit" != "X"; then
595 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 +0100596 if test -f "$vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200597 AC_MSG_RESULT(yes)
598 LUA_INC=/luajit-$vi_cv_version_luajit
599 fi
600 fi
601 if test "X$LUA_INC" = "X"; then
602 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)
Bram Moolenaar49222be2015-12-11 18:11:30 +0100603 if test -f "$vi_cv_path_lua_pfx/include/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200604 AC_MSG_RESULT(yes)
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200605 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200606 AC_MSG_RESULT(no)
607 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 +0100608 if test -f "$vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200609 AC_MSG_RESULT(yes)
610 LUA_INC=/lua$vi_cv_version_lua
611 else
612 AC_MSG_RESULT(no)
613 vi_cv_path_lua_pfx=
614 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200615 fi
616 fi
617 fi
618
619 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200620 if test "x$vi_cv_with_luajit" != "xno"; then
621 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
622 if test "X$multiarch" != "X"; then
623 lib_multiarch="lib/${multiarch}"
624 else
625 lib_multiarch="lib"
626 fi
627 if test "X$vi_cv_version_lua" = "X"; then
628 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit"
629 else
630 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit-$vi_cv_version_lua"
631 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200632 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200633 if test "X$LUA_INC" != "X"; then
634 dnl Test alternate location using version
635 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua$vi_cv_version_lua"
636 else
637 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua"
638 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200639 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200640 if test "$enable_luainterp" = "dynamic"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200641 lua_ok="yes"
642 else
643 AC_MSG_CHECKING([if link with ${LUA_LIBS} is sane])
644 libs_save=$LIBS
645 LIBS="$LIBS $LUA_LIBS"
646 AC_TRY_LINK(,[ ],
647 AC_MSG_RESULT(yes); lua_ok="yes",
648 AC_MSG_RESULT(no); lua_ok="no"; LUA_LIBS="")
649 LIBS=$libs_save
650 fi
651 if test "x$lua_ok" = "xyes"; then
652 LUA_CFLAGS="-I${vi_cv_path_lua_pfx}/include${LUA_INC}"
653 LUA_SRC="if_lua.c"
654 LUA_OBJ="objects/if_lua.o"
655 LUA_PRO="if_lua.pro"
656 AC_DEFINE(FEAT_LUA)
657 fi
658 if test "$enable_luainterp" = "dynamic"; then
659 if test "x$vi_cv_with_luajit" != "xno"; then
660 luajit="jit"
661 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200662 if test -f "${vi_cv_path_lua_pfx}/bin/cyglua-${vi_cv_version_lua}.dll"; then
663 vi_cv_dll_name_lua="cyglua-${vi_cv_version_lua}.dll"
664 else
Bram Moolenaard0573012017-10-28 21:11:06 +0200665 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200666 ext="dylib"
667 indexes=""
668 else
669 ext="so"
670 indexes=".0 .1 .2 .3 .4 .5 .6 .7 .8 .9"
671 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
672 if test "X$multiarch" != "X"; then
673 lib_multiarch="lib/${multiarch}"
674 fi
Bram Moolenaar768baac2013-04-15 14:44:57 +0200675 fi
676 dnl Determine the sover for the current version, but fallback to
677 dnl liblua${vi_cv_version_lua}.so if no sover-versioned file is found.
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200678 AC_MSG_CHECKING(if liblua${luajit}*.${ext}* can be found in $vi_cv_path_lua_pfx)
Bram Moolenaar768baac2013-04-15 14:44:57 +0200679 for subdir in "${lib_multiarch}" lib64 lib; do
680 if test -z "$subdir"; then
681 continue
682 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200683 for sover in "${vi_cv_version_lua}.${ext}" "-${vi_cv_version_lua}.${ext}" \
684 ".${vi_cv_version_lua}.${ext}" ".${ext}.${vi_cv_version_lua}"; do
685 for i in $indexes ""; do
686 if test -f "${vi_cv_path_lua_pfx}/${subdir}/liblua${luajit}${sover}$i"; then
Bram Moolenaar768baac2013-04-15 14:44:57 +0200687 sover2="$i"
688 break 3
689 fi
690 done
Bram Moolenaar07e1da62013-02-06 19:49:43 +0100691 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200692 sover=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200693 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200694 if test "X$sover" = "X"; then
695 AC_MSG_RESULT(no)
696 lua_ok="no"
697 vi_cv_dll_name_lua="liblua${luajit}.${ext}"
698 else
699 AC_MSG_RESULT(yes)
700 lua_ok="yes"
701 vi_cv_dll_name_lua="liblua${luajit}${sover}$sover2"
702 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200703 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200704 AC_DEFINE(DYNAMIC_LUA)
705 LUA_LIBS=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200706 LUA_CFLAGS="-DDYNAMIC_LUA_DLL=\\\"${vi_cv_dll_name_lua}\\\" $LUA_CFLAGS"
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200707 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200708 if test "X$LUA_CFLAGS$LUA_LIBS" != "X" && \
Bram Moolenaard0573012017-10-28 21:11:06 +0200709 test "x$MACOS_X" = "xyes" && test "x$vi_cv_with_luajit" != "xno" && \
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200710 test "`(uname -m) 2>/dev/null`" = "x86_64"; then
711 dnl OSX/x64 requires these flags. See http://luajit.org/install.html
712 LUA_LIBS="-pagezero_size 10000 -image_base 100000000 $LUA_LIBS"
713 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200714 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200715 if test "$fail_if_missing" = "yes" -a "$lua_ok" != "yes"; then
Bram Moolenaarf788a062011-12-14 20:51:25 +0100716 AC_MSG_ERROR([could not configure lua])
717 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200718 AC_SUBST(LUA_SRC)
719 AC_SUBST(LUA_OBJ)
720 AC_SUBST(LUA_PRO)
721 AC_SUBST(LUA_LIBS)
722 AC_SUBST(LUA_CFLAGS)
723fi
724
725
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000726dnl Check for MzScheme feature.
727AC_MSG_CHECKING(--enable-mzschemeinterp argument)
728AC_ARG_ENABLE(mzschemeinterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200729 [ --enable-mzschemeinterp Include MzScheme interpreter.], ,
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000730 [enable_mzschemeinterp="no"])
731AC_MSG_RESULT($enable_mzschemeinterp)
732
733if test "$enable_mzschemeinterp" = "yes"; then
734 dnl -- find the mzscheme executable
735 AC_SUBST(vi_cv_path_mzscheme)
736
737 AC_MSG_CHECKING(--with-plthome argument)
738 AC_ARG_WITH(plthome,
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000739 [ --with-plthome=PLTHOME Use PLTHOME.],
740 with_plthome="$withval"; AC_MSG_RESULT($with_plthome),
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000741 with_plthome="";AC_MSG_RESULT("no"))
742
743 if test "X$with_plthome" != "X"; then
744 vi_cv_path_mzscheme_pfx="$with_plthome"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100745 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000746 else
747 AC_MSG_CHECKING(PLTHOME environment var)
748 if test "X$PLTHOME" != "X"; then
749 AC_MSG_RESULT("$PLTHOME")
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000750 vi_cv_path_mzscheme_pfx="$PLTHOME"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100751 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000752 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000753 AC_MSG_RESULT(not set)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000754 dnl -- try to find MzScheme executable
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000755 AC_PATH_PROG(vi_cv_path_mzscheme, mzscheme)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000756
757 dnl resolve symbolic link, the executable is often elsewhere and there
758 dnl are no links for the include files.
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000759 if test "X$vi_cv_path_mzscheme" != "X"; then
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000760 lsout=`ls -l $vi_cv_path_mzscheme`
761 if echo "$lsout" | grep -e '->' >/dev/null 2>/dev/null; then
762 vi_cv_path_mzscheme=`echo "$lsout" | sed 's/.*-> \(.*\)/\1/'`
763 fi
764 fi
765
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000766 if test "X$vi_cv_path_mzscheme" != "X"; then
767 dnl -- find where MzScheme thinks it was installed
768 AC_CACHE_CHECK(MzScheme install prefix,vi_cv_path_mzscheme_pfx,
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000769 dnl different versions of MzScheme differ in command line processing
770 dnl use universal approach
771 echo "(display (simplify-path \
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000772 (build-path (call-with-values \
773 (lambda () (split-path (find-system-path (quote exec-file)))) \
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000774 (lambda (base name must-be-dir?) base)) (quote up))))" > mzdirs.scm
775 dnl Remove a trailing slash
776 [ vi_cv_path_mzscheme_pfx=`${vi_cv_path_mzscheme} -r mzdirs.scm | \
777 sed -e 's+/$++'` ])
778 rm -f mzdirs.scm
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000779 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000780 fi
781 fi
782
783 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100784 AC_MSG_CHECKING(for racket include directory)
785 SCHEME_INC=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-include-dir))) (when (path? p) (display p)))'`
786 if test "X$SCHEME_INC" != "X"; then
787 AC_MSG_RESULT(${SCHEME_INC})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000788 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100789 AC_MSG_RESULT(not found)
790 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include)
791 if test -f "$vi_cv_path_mzscheme_pfx/include/scheme.h"; then
792 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000793 AC_MSG_RESULT(yes)
Bram Moolenaard7afed32007-05-06 13:26:41 +0000794 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000795 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100796 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt)
797 if test -f "$vi_cv_path_mzscheme_pfx/include/plt/scheme.h"; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000798 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100799 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000800 else
801 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100802 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket)
803 if test -f "$vi_cv_path_mzscheme_pfx/include/racket/scheme.h"; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100804 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100805 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100806 else
807 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100808 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/)
809 if test -f /usr/include/plt/scheme.h; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100810 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100811 SCHEME_INC=/usr/include/plt
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100812 else
813 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100814 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/racket/)
815 if test -f /usr/include/racket/scheme.h; then
816 AC_MSG_RESULT(yes)
817 SCHEME_INC=/usr/include/racket
818 else
819 AC_MSG_RESULT(no)
820 vi_cv_path_mzscheme_pfx=
821 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100822 fi
823 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000824 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000825 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000826 fi
827 fi
828
829 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100830
831 AC_MSG_CHECKING(for racket lib directory)
832 SCHEME_LIB=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-lib-dir))) (when (path? p) (display p)))'`
833 if test "X$SCHEME_LIB" != "X"; then
834 AC_MSG_RESULT(${SCHEME_LIB})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000835 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100836 AC_MSG_RESULT(not found)
837 fi
838
839 for path in "${vi_cv_path_mzscheme_pfx}/lib" "${SCHEME_LIB}"; do
840 if test "X$path" != "X"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200841 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100842 MZSCHEME_LIBS="-framework Racket"
843 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
844 elif test -f "${path}/libmzscheme3m.a"; then
845 MZSCHEME_LIBS="${path}/libmzscheme3m.a"
846 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
847 elif test -f "${path}/libracket3m.a"; then
848 MZSCHEME_LIBS="${path}/libracket3m.a"
849 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
850 elif test -f "${path}/libracket.a"; then
851 MZSCHEME_LIBS="${path}/libracket.a ${path}/libmzgc.a"
852 elif test -f "${path}/libmzscheme.a"; then
853 MZSCHEME_LIBS="${path}/libmzscheme.a ${path}/libmzgc.a"
854 else
855 dnl Using shared objects
856 if test -f "${path}/libmzscheme3m.so"; then
857 MZSCHEME_LIBS="-L${path} -lmzscheme3m"
858 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
859 elif test -f "${path}/libracket3m.so"; then
860 MZSCHEME_LIBS="-L${path} -lracket3m"
861 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
862 elif test -f "${path}/libracket.so"; then
863 MZSCHEME_LIBS="-L${path} -lracket -lmzgc"
864 else
865 dnl try next until last
866 if test "$path" != "$SCHEME_LIB"; then
867 continue
868 fi
869 MZSCHEME_LIBS="-L${path} -lmzscheme -lmzgc"
870 fi
871 if test "$GCC" = yes; then
872 dnl Make Vim remember the path to the library. For when it's not in
873 dnl $LD_LIBRARY_PATH.
874 MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${path}"
875 elif test "`(uname) 2>/dev/null`" = SunOS &&
876 uname -r | grep '^5' >/dev/null; then
877 MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${path}"
878 fi
879 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000880 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100881 if test "X$MZSCHEME_LIBS" != "X"; then
882 break
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +0000883 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100884 done
885
886 AC_MSG_CHECKING([if racket requires -pthread])
887 if test "X$SCHEME_LIB" != "X" && $FGREP -e -pthread "$SCHEME_LIB/buildinfo" >/dev/null ; then
888 AC_MSG_RESULT(yes)
889 MZSCHEME_LIBS="${MZSCHEME_LIBS} -pthread"
890 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -pthread"
891 else
892 AC_MSG_RESULT(no)
893 fi
894
895 AC_MSG_CHECKING(for racket config directory)
896 SCHEME_CONFIGDIR=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-config-dir))) (when (path? p) (display p)))'`
897 if test "X$SCHEME_CONFIGDIR" != "X"; then
898 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DMZSCHEME_CONFIGDIR='\"${SCHEME_CONFIGDIR}\"'"
899 AC_MSG_RESULT(${SCHEME_CONFIGDIR})
900 else
901 AC_MSG_RESULT(not found)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000902 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100903
904 AC_MSG_CHECKING(for racket collects directory)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100905 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))))'`
906 if test "X$SCHEME_COLLECTS" = "X"; then
907 if test -d "$vi_cv_path_mzscheme_pfx/lib/plt/collects"; then
908 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/plt/
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100909 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100910 if test -d "$vi_cv_path_mzscheme_pfx/lib/racket/collects"; then
911 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/racket/
Bram Moolenaar75676462013-01-30 14:55:42 +0100912 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100913 if test -d "$vi_cv_path_mzscheme_pfx/share/racket/collects"; then
914 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/
915 else
916 if test -d "$vi_cv_path_mzscheme_pfx/collects"; then
917 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/
918 fi
Bram Moolenaar75676462013-01-30 14:55:42 +0100919 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100920 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100921 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000922 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100923 if test "X$SCHEME_COLLECTS" != "X" ; then
924 AC_MSG_RESULT(${SCHEME_COLLECTS})
925 else
926 AC_MSG_RESULT(not found)
927 fi
928
929 AC_MSG_CHECKING(for mzscheme_base.c)
930 if test -f "${SCHEME_COLLECTS}collects/scheme/base.ss" ; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000931 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +0100932 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
933 MZSCHEME_MOD="++lib scheme/base"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100934 else
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100935 if test -f "${SCHEME_COLLECTS}collects/scheme/base.rkt" ; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100936 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +0100937 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
938 MZSCHEME_MOD="++lib scheme/base"
939 else
940 if test -f "${SCHEME_COLLECTS}collects/racket/base.rkt" ; then
941 MZSCHEME_EXTRA="mzscheme_base.c"
942 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/raco ctool"
943 MZSCHEME_MOD=""
944 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100945 fi
946 fi
947 if test "X$MZSCHEME_EXTRA" != "X" ; then
948 dnl need to generate bytecode for MzScheme base
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000949 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE"
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100950 AC_MSG_RESULT(needed)
951 else
952 AC_MSG_RESULT(not needed)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000953 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100954
Bram Moolenaar9e902192013-07-17 18:58:11 +0200955 dnl On Ubuntu this fixes "undefined reference to symbol 'ffi_type_void'".
956 AC_CHECK_LIB(ffi, ffi_type_void, [MZSCHEME_LIBS="$MZSCHEME_LIBS -lffi"])
957
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000958 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -I${SCHEME_INC} \
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100959 -DMZSCHEME_COLLECTS='\"${SCHEME_COLLECTS}collects\"'"
Bram Moolenaar9e902192013-07-17 18:58:11 +0200960
961 dnl Test that we can compile a simple program with these CFLAGS and LIBS.
962 AC_MSG_CHECKING([if compile and link flags for MzScheme are sane])
963 cflags_save=$CFLAGS
964 libs_save=$LIBS
965 CFLAGS="$CFLAGS $MZSCHEME_CFLAGS"
966 LIBS="$LIBS $MZSCHEME_LIBS"
967 AC_TRY_LINK(,[ ],
968 AC_MSG_RESULT(yes); mzs_ok=yes,
969 AC_MSG_RESULT(no: MZSCHEME DISABLED); mzs_ok=no)
970 CFLAGS=$cflags_save
971 LIBS=$libs_save
972 if test $mzs_ok = yes; then
973 MZSCHEME_SRC="if_mzsch.c"
974 MZSCHEME_OBJ="objects/if_mzsch.o"
975 MZSCHEME_PRO="if_mzsch.pro"
976 AC_DEFINE(FEAT_MZSCHEME)
977 else
978 MZSCHEME_CFLAGS=
979 MZSCHEME_LIBS=
980 MZSCHEME_EXTRA=
981 MZSCHEME_MZC=
982 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000983 fi
984 AC_SUBST(MZSCHEME_SRC)
985 AC_SUBST(MZSCHEME_OBJ)
986 AC_SUBST(MZSCHEME_PRO)
987 AC_SUBST(MZSCHEME_LIBS)
988 AC_SUBST(MZSCHEME_CFLAGS)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000989 AC_SUBST(MZSCHEME_EXTRA)
990 AC_SUBST(MZSCHEME_MZC)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000991fi
992
993
Bram Moolenaar071d4272004-06-13 20:20:40 +0000994AC_MSG_CHECKING(--enable-perlinterp argument)
995AC_ARG_ENABLE(perlinterp,
Bram Moolenaare06c1882010-07-21 22:05:20 +0200996 [ --enable-perlinterp[=OPTS] Include Perl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000997 [enable_perlinterp="no"])
998AC_MSG_RESULT($enable_perlinterp)
Bram Moolenaare06c1882010-07-21 22:05:20 +0200999if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01001000 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1001 AC_MSG_ERROR([cannot use Perl with tiny or small features])
1002 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001003 AC_SUBST(vi_cv_path_perl)
1004 AC_PATH_PROG(vi_cv_path_perl, perl)
1005 if test "X$vi_cv_path_perl" != "X"; then
1006 AC_MSG_CHECKING(Perl version)
1007 if $vi_cv_path_perl -e 'require 5.003_01' >/dev/null 2>/dev/null; then
1008 eval `$vi_cv_path_perl -V:usethreads`
Bram Moolenaare06c1882010-07-21 22:05:20 +02001009 eval `$vi_cv_path_perl -V:libperl`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001010 if test "X$usethreads" = "XUNKNOWN" -o "X$usethreads" = "Xundef"; then
1011 badthreads=no
1012 else
1013 if $vi_cv_path_perl -e 'require 5.6.0' >/dev/null 2>/dev/null; then
1014 eval `$vi_cv_path_perl -V:use5005threads`
1015 if test "X$use5005threads" = "XUNKNOWN" -o "X$use5005threads" = "Xundef"; then
1016 badthreads=no
1017 else
1018 badthreads=yes
1019 AC_MSG_RESULT(>>> Perl > 5.6 with 5.5 threads cannot be used <<<)
1020 fi
1021 else
1022 badthreads=yes
1023 AC_MSG_RESULT(>>> Perl 5.5 with threads cannot be used <<<)
1024 fi
1025 fi
1026 if test $badthreads = no; then
1027 AC_MSG_RESULT(OK)
1028 eval `$vi_cv_path_perl -V:shrpenv`
1029 if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04
1030 shrpenv=""
1031 fi
1032 vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlibexp}'`
1033 AC_SUBST(vi_cv_perllib)
Bram Moolenaard5f62b12014-08-17 17:05:44 +02001034 vi_cv_perl_extutils=unknown_perl_extutils_path
1035 for extutils_rel_path in ExtUtils vendor_perl/ExtUtils; do
1036 xsubpp_path="$vi_cv_perllib/$extutils_rel_path/xsubpp"
1037 if test -f "$xsubpp_path"; then
1038 vi_cv_perl_xsubpp="$xsubpp_path"
1039 fi
1040 done
1041 AC_SUBST(vi_cv_perl_xsubpp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001042 dnl Remove "-fno-something", it breaks using cproto.
Bram Moolenaar280a8682015-06-21 13:41:08 +02001043 dnl Remove "-fdebug-prefix-map", it isn't supported by clang.
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001044 dnl Remove "FORTIFY_SOURCE", it will be defined twice.
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001045 dnl remove -pipe and -Wxxx, it confuses cproto
Bram Moolenaar071d4272004-06-13 20:20:40 +00001046 perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001047 -e 'ccflags;perl_inc;print"\n"' | sed -e 's/-fno[[^ ]]*//' \
1048 -e 's/-fdebug-prefix-map[[^ ]]*//g' \
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001049 -e 's/-pipe //' \
1050 -e 's/-W[[^ ]]*//g' \
1051 -e 's/-D_FORTIFY_SOURCE=.//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001052 dnl Remove "-lc", it breaks on FreeBSD when using "-pthread".
1053 perllibs=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed -e 'ldopts' | \
1054 sed -e '/Warning/d' -e '/Note (probably harmless)/d' \
1055 -e 's/-bE:perl.exp//' -e 's/-lc //'`
1056 dnl Don't add perl lib to $LIBS: if it's not in LD_LIBRARY_PATH
1057 dnl a test in configure may fail because of that.
1058 perlldflags=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed \
1059 -e 'ccdlflags' | sed -e 's/-bE:perl.exp//'`
1060
1061 dnl check that compiling a simple program still works with the flags
1062 dnl added for Perl.
1063 AC_MSG_CHECKING([if compile and link flags for Perl are sane])
1064 cflags_save=$CFLAGS
1065 libs_save=$LIBS
1066 ldflags_save=$LDFLAGS
1067 CFLAGS="$CFLAGS $perlcppflags"
1068 LIBS="$LIBS $perllibs"
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001069 perlldflags=`echo "$perlldflags" | sed -e 's/^ *//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001070 LDFLAGS="$perlldflags $LDFLAGS"
1071 AC_TRY_LINK(,[ ],
1072 AC_MSG_RESULT(yes); perl_ok=yes,
1073 AC_MSG_RESULT(no: PERL DISABLED); perl_ok=no)
1074 CFLAGS=$cflags_save
1075 LIBS=$libs_save
1076 LDFLAGS=$ldflags_save
1077 if test $perl_ok = yes; then
1078 if test "X$perlcppflags" != "X"; then
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001079 PERL_CFLAGS=$perlcppflags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001080 fi
1081 if test "X$perlldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001082 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$perlldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001083 LDFLAGS="$perlldflags $LDFLAGS"
1084 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001085 fi
1086 PERL_LIBS=$perllibs
1087 PERL_SRC="auto/if_perl.c if_perlsfio.c"
1088 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o"
1089 PERL_PRO="if_perl.pro if_perlsfio.pro"
1090 AC_DEFINE(FEAT_PERL)
1091 fi
1092 fi
1093 else
1094 AC_MSG_RESULT(>>> too old; need Perl version 5.003_01 or later <<<)
1095 fi
1096 fi
1097
Bram Moolenaard0573012017-10-28 21:11:06 +02001098 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00001099 dnl Mac OS X 10.2 or later
Bram Moolenaar071d4272004-06-13 20:20:40 +00001100 dir=/System/Library/Perl
1101 darwindir=$dir/darwin
1102 if test -d $darwindir; then
1103 PERL=/usr/bin/perl
1104 else
1105 dnl Mac OS X 10.3
1106 dir=/System/Library/Perl/5.8.1
1107 darwindir=$dir/darwin-thread-multi-2level
1108 if test -d $darwindir; then
1109 PERL=/usr/bin/perl
1110 fi
1111 fi
1112 if test -n "$PERL"; then
1113 PERL_DIR="$dir"
1114 PERL_CFLAGS="-DFEAT_PERL -I$darwindir/CORE"
1115 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o $darwindir/auto/DynaLoader/DynaLoader.a"
1116 PERL_LIBS="-L$darwindir/CORE -lperl"
1117 fi
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001118 dnl Perl on Mac OS X 10.5 adds "-arch" flags but these should only
1119 dnl be included if requested by passing --with-mac-arch to
1120 dnl configure, so strip these flags first (if present)
1121 PERL_LIBS=`echo "$PERL_LIBS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
1122 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 +00001123 fi
Bram Moolenaare06c1882010-07-21 22:05:20 +02001124 if test "$enable_perlinterp" = "dynamic"; then
1125 if test "$perl_ok" = "yes" -a "X$libperl" != "X"; then
1126 AC_DEFINE(DYNAMIC_PERL)
1127 PERL_CFLAGS="-DDYNAMIC_PERL_DLL=\\\"$libperl\\\" $PERL_CFLAGS"
1128 fi
1129 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001130
1131 if test "$fail_if_missing" = "yes" -a "$perl_ok" != "yes"; then
1132 AC_MSG_ERROR([could not configure perl])
1133 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001134fi
1135AC_SUBST(shrpenv)
1136AC_SUBST(PERL_SRC)
1137AC_SUBST(PERL_OBJ)
1138AC_SUBST(PERL_PRO)
1139AC_SUBST(PERL_CFLAGS)
1140AC_SUBST(PERL_LIBS)
1141
1142AC_MSG_CHECKING(--enable-pythoninterp argument)
1143AC_ARG_ENABLE(pythoninterp,
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001144 [ --enable-pythoninterp[=OPTS] Include Python interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001145 [enable_pythoninterp="no"])
1146AC_MSG_RESULT($enable_pythoninterp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001147if test "$enable_pythoninterp" = "yes" -o "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001148 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1149 AC_MSG_ERROR([cannot use Python with tiny or small features])
1150 fi
1151
Bram Moolenaar071d4272004-06-13 20:20:40 +00001152 dnl -- find the python executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001153 AC_MSG_CHECKING(--with-python-command argument)
1154 AC_SUBST(vi_cv_path_python)
1155 AC_ARG_WITH(python-command, [ --with-python-command=NAME name of the Python 2 command (default: python2 or python)],
1156 vi_cv_path_python="$withval"; AC_MSG_RESULT($vi_cv_path_python),
1157 AC_MSG_RESULT(no))
1158
1159 if test "X$vi_cv_path_python" = "X"; then
1160 AC_PATH_PROGS(vi_cv_path_python, python2 python)
1161 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001162 if test "X$vi_cv_path_python" != "X"; then
1163
1164 dnl -- get its version number
1165 AC_CACHE_CHECK(Python version,vi_cv_var_python_version,
1166 [[vi_cv_var_python_version=`
1167 ${vi_cv_path_python} -c 'import sys; print sys.version[:3]'`
1168 ]])
1169
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001170 dnl -- it must be at least version 2.3
1171 AC_MSG_CHECKING(Python is 2.3 or better)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001172 if ${vi_cv_path_python} -c \
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001173 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001174 then
1175 AC_MSG_RESULT(yep)
1176
1177 dnl -- find where python thinks it was installed
1178 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python_pfx,
1179 [ vi_cv_path_python_pfx=`
1180 ${vi_cv_path_python} -c \
1181 "import sys; print sys.prefix"` ])
1182
1183 dnl -- and where it thinks it runs
1184 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python_epfx,
1185 [ vi_cv_path_python_epfx=`
1186 ${vi_cv_path_python} -c \
1187 "import sys; print sys.exec_prefix"` ])
1188
1189 dnl -- python's internal library path
1190
1191 AC_CACHE_VAL(vi_cv_path_pythonpath,
1192 [ vi_cv_path_pythonpath=`
1193 unset PYTHONPATH;
1194 ${vi_cv_path_python} -c \
1195 "import sys, string; print string.join(sys.path,':')"` ])
1196
1197 dnl -- where the Python implementation library archives are
1198
1199 AC_ARG_WITH(python-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001200 [ --with-python-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001201 [ vi_cv_path_python_conf="${withval}"; have_python_config_dir=1 ] )
Bram Moolenaar071d4272004-06-13 20:20:40 +00001202
1203 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python_conf,
1204 [
1205 vi_cv_path_python_conf=
Bram Moolenaarac499e32013-06-02 19:14:17 +02001206 d=`${vi_cv_path_python} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBPL')"`
1207 if test -d "$d" && test -f "$d/config.c"; then
1208 vi_cv_path_python_conf="$d"
1209 else
1210 for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
1211 for subdir in lib64 lib share; do
1212 d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
1213 if test -d "$d" && test -f "$d/config.c"; then
1214 vi_cv_path_python_conf="$d"
1215 fi
1216 done
Bram Moolenaar071d4272004-06-13 20:20:40 +00001217 done
Bram Moolenaarac499e32013-06-02 19:14:17 +02001218 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001219 ])
1220
1221 PYTHON_CONFDIR="${vi_cv_path_python_conf}"
1222
1223 if test "X$PYTHON_CONFDIR" = "X"; then
1224 AC_MSG_RESULT([can't find it!])
1225 else
1226
1227 dnl -- we need to examine Python's config/Makefile too
1228 dnl see what the interpreter is built from
1229 AC_CACHE_VAL(vi_cv_path_python_plibs,
1230 [
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001231 pwd=`pwd`
1232 tmp_mkf="$pwd/config-PyMake$$"
1233 cat -- "${PYTHON_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001234__:
Bram Moolenaar218116c2010-05-20 21:46:00 +02001235 @echo "python_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001236 @echo "python_LIBS='$(LIBS)'"
1237 @echo "python_SYSLIBS='$(SYSLIBS)'"
1238 @echo "python_LINKFORSHARED='$(LINKFORSHARED)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001239 @echo "python_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001240 @echo "python_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001241 @echo "python_PYTHONFRAMEWORK='$(PYTHONFRAMEWORK)'"
1242 @echo "python_PYTHONFRAMEWORKPREFIX='$(PYTHONFRAMEWORKPREFIX)'"
1243 @echo "python_PYTHONFRAMEWORKINSTALLDIR='$(PYTHONFRAMEWORKINSTALLDIR)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001244eof
1245 dnl -- delete the lines from make about Entering/Leaving directory
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001246 eval "`cd ${PYTHON_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1247 rm -f -- "${tmp_mkf}"
Bram Moolenaard0573012017-10-28 21:11:06 +02001248 if test "x$MACOS_X" = "xyes" && test -n "${python_PYTHONFRAMEWORK}" && ${vi_cv_path_python} -c \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001249 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then
1250 vi_cv_path_python_plibs="-framework Python"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001251 if test "x${vi_cv_path_python}" != "x/usr/bin/python" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
1252 vi_cv_path_python_plibs="-F${python_PYTHONFRAMEWORKPREFIX} -framework Python"
1253 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001254 else
Bram Moolenaar9ce42132018-04-11 22:19:36 +02001255 vi_cv_path_python_plibs="-L${PYTHON_CONFDIR} -lpython${vi_cv_var_python_version}"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001256 dnl -- Check if the path contained in python_LINKFORSHARED is
1257 dnl usable for vim build. If not, make and try other
1258 dnl candidates.
Bram Moolenaara161e262015-03-24 15:14:27 +01001259 if test -n "${python_LINKFORSHARED}" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
Bram Moolenaar6c927552015-03-24 12:21:33 +01001260 python_link_symbol=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]].*/\1/'`
1261 python_link_path=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]][[ \t]]*\(.*\)/\2/'`
1262 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1263 dnl -- The path looks relative. Guess the absolute one using
1264 dnl the prefix and try that.
1265 python_link_path="${python_PYTHONFRAMEWORKPREFIX}/${python_link_path}"
1266 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1267 dnl -- A last resort.
1268 python_link_path="${python_PYTHONFRAMEWORKINSTALLDIR}/Versions/${vi_cv_var_python_version}/${python_PYTHONFRAMEWORK}"
1269 dnl -- No check is done. The last word is left to the
1270 dnl "sanity" test on link flags that follows shortly.
1271 fi
1272 python_LINKFORSHARED="${python_link_symbol} ${python_link_path}"
1273 fi
1274 fi
Bram Moolenaar218116c2010-05-20 21:46:00 +02001275 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 +00001276 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1277 vi_cv_path_python_plibs=`echo $vi_cv_path_python_plibs | sed s/-ltermcap//`
1278 fi
1279 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001280 AC_CACHE_CHECK(Python's dll name,vi_cv_dll_name_python,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001281 [
1282 if test "X$python_DLLLIBRARY" != "X"; then
1283 vi_cv_dll_name_python="$python_DLLLIBRARY"
1284 else
1285 vi_cv_dll_name_python="$python_INSTSONAME"
1286 fi
1287 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00001288
1289 PYTHON_LIBS="${vi_cv_path_python_plibs}"
1290 if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001291 PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001292 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001293 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 +00001294 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001295 if test "X$have_python_config_dir" = "X1" -a "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001296 dnl Define PYTHON_HOME if --with-python-config-dir was used
1297 PYTHON_CFLAGS="${PYTHON_CFLAGS} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'"
1298
1299 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001300 PYTHON_SRC="if_python.c"
Bram Moolenaar9bdb9a02012-07-25 16:32:08 +02001301 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001302
1303 dnl On FreeBSD linking with "-pthread" is required to use threads.
1304 dnl _THREAD_SAFE must be used for compiling then.
1305 dnl The "-pthread" is added to $LIBS, so that the following check for
1306 dnl sigaltstack() will look in libc_r (it's there in libc!).
1307 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1308 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1309 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1310 AC_MSG_CHECKING([if -pthread should be used])
1311 threadsafe_flag=
1312 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001313 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00001314 if test "`(uname) 2>/dev/null`" != Darwin; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001315 test "$GCC" = yes && threadsafe_flag="-pthread"
1316 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1317 threadsafe_flag="-D_THREAD_SAFE"
1318 thread_lib="-pthread"
1319 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001320 if test "`(uname) 2>/dev/null`" = SunOS; then
1321 threadsafe_flag="-pthreads"
1322 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001323 fi
1324 libs_save_old=$LIBS
1325 if test -n "$threadsafe_flag"; then
1326 cflags_save=$CFLAGS
1327 CFLAGS="$CFLAGS $threadsafe_flag"
1328 LIBS="$LIBS $thread_lib"
1329 AC_TRY_LINK(,[ ],
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001330 AC_MSG_RESULT(yes); PYTHON_CFLAGS="$PYTHON_CFLAGS $threadsafe_flag",
Bram Moolenaar071d4272004-06-13 20:20:40 +00001331 AC_MSG_RESULT(no); LIBS=$libs_save_old
1332 )
1333 CFLAGS=$cflags_save
1334 else
1335 AC_MSG_RESULT(no)
1336 fi
1337
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001338 dnl Check that compiling a simple program still works with the flags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001339 dnl added for Python.
1340 AC_MSG_CHECKING([if compile and link flags for Python are sane])
1341 cflags_save=$CFLAGS
1342 libs_save=$LIBS
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001343 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001344 LIBS="$LIBS $PYTHON_LIBS"
1345 AC_TRY_LINK(,[ ],
1346 AC_MSG_RESULT(yes); python_ok=yes,
1347 AC_MSG_RESULT(no: PYTHON DISABLED); python_ok=no)
1348 CFLAGS=$cflags_save
1349 LIBS=$libs_save
1350 if test $python_ok = yes; then
1351 AC_DEFINE(FEAT_PYTHON)
1352 else
1353 LIBS=$libs_save_old
1354 PYTHON_SRC=
1355 PYTHON_OBJ=
1356 PYTHON_LIBS=
1357 PYTHON_CFLAGS=
1358 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001359 fi
1360 else
1361 AC_MSG_RESULT(too old)
1362 fi
1363 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001364
1365 if test "$fail_if_missing" = "yes" -a "$python_ok" != "yes"; then
1366 AC_MSG_ERROR([could not configure python])
1367 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001368fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001369
Bram Moolenaar071d4272004-06-13 20:20:40 +00001370AC_SUBST(PYTHON_LIBS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001371AC_SUBST(PYTHON_CFLAGS)
1372AC_SUBST(PYTHON_SRC)
1373AC_SUBST(PYTHON_OBJ)
1374
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001375
1376AC_MSG_CHECKING(--enable-python3interp argument)
1377AC_ARG_ENABLE(python3interp,
Bram Moolenaar8008b632017-07-18 21:33:20 +02001378 [ --enable-python3interp[=OPTS] Include Python3 interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001379 [enable_python3interp="no"])
1380AC_MSG_RESULT($enable_python3interp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001381if test "$enable_python3interp" = "yes" -o "$enable_python3interp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001382 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1383 AC_MSG_ERROR([cannot use Python with tiny or small features])
1384 fi
1385
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001386 dnl -- find the python3 executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001387 AC_MSG_CHECKING(--with-python3-command argument)
1388 AC_SUBST(vi_cv_path_python3)
1389 AC_ARG_WITH(python3-command, [ --with-python3-command=NAME name of the Python 3 command (default: python3 or python)],
1390 vi_cv_path_python3="$withval"; AC_MSG_RESULT($vi_cv_path_python3),
1391 AC_MSG_RESULT(no))
1392
1393 if test "X$vi_cv_path_python3" = "X"; then
1394 AC_PATH_PROGS(vi_cv_path_python3, python3 python)
1395 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001396 if test "X$vi_cv_path_python3" != "X"; then
1397
1398 dnl -- get its version number
1399 AC_CACHE_CHECK(Python version,vi_cv_var_python3_version,
1400 [[vi_cv_var_python3_version=`
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001401 ${vi_cv_path_python3} -c 'import sys; print(sys.version[:3])'`
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001402 ]])
1403
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001404 dnl -- it must be at least version 3
1405 AC_MSG_CHECKING(Python is 3.0 or better)
1406 if ${vi_cv_path_python3} -c \
1407 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.0)"
1408 then
1409 AC_MSG_RESULT(yep)
Bram Moolenaar456f2bb2011-06-12 21:37:13 +02001410
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001411 dnl -- get abiflags for python 3.2 or higher (PEP 3149)
1412 AC_CACHE_CHECK(Python's abiflags,vi_cv_var_python3_abiflags,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001413 [
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001414 vi_cv_var_python3_abiflags=
1415 if ${vi_cv_path_python3} -c \
1416 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)"
1417 then
1418 vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \
1419 "import sys; print(sys.abiflags)"`
1420 fi ])
1421
1422 dnl -- find where python3 thinks it was installed
1423 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx,
1424 [ vi_cv_path_python3_pfx=`
1425 ${vi_cv_path_python3} -c \
1426 "import sys; print(sys.prefix)"` ])
1427
1428 dnl -- and where it thinks it runs
1429 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx,
1430 [ vi_cv_path_python3_epfx=`
1431 ${vi_cv_path_python3} -c \
1432 "import sys; print(sys.exec_prefix)"` ])
1433
1434 dnl -- python3's internal library path
1435
1436 AC_CACHE_VAL(vi_cv_path_python3path,
1437 [ vi_cv_path_python3path=`
1438 unset PYTHONPATH;
1439 ${vi_cv_path_python3} -c \
1440 "import sys, string; print(':'.join(sys.path))"` ])
1441
1442 dnl -- where the Python implementation library archives are
1443
1444 AC_ARG_WITH(python3-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001445 [ --with-python3-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001446 [ vi_cv_path_python3_conf="${withval}"; have_python3_config_dir=1 ] )
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001447
1448 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf,
1449 [
1450 vi_cv_path_python3_conf=
Bram Moolenaarfee496d2013-07-12 20:07:24 +02001451 config_dir="config-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001452 d=`${vi_cv_path_python3} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBPL'))"`
1453 if test -d "$d" && test -f "$d/config.c"; then
1454 vi_cv_path_python3_conf="$d"
1455 else
1456 for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do
1457 for subdir in lib64 lib share; do
1458 d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}"
1459 if test -d "$d" && test -f "$d/config.c"; then
1460 vi_cv_path_python3_conf="$d"
1461 fi
1462 done
1463 done
1464 fi
1465 ])
1466
1467 PYTHON3_CONFDIR="${vi_cv_path_python3_conf}"
1468
1469 if test "X$PYTHON3_CONFDIR" = "X"; then
1470 AC_MSG_RESULT([can't find it!])
1471 else
1472
1473 dnl -- we need to examine Python's config/Makefile too
1474 dnl see what the interpreter is built from
1475 AC_CACHE_VAL(vi_cv_path_python3_plibs,
1476 [
1477 pwd=`pwd`
1478 tmp_mkf="$pwd/config-PyMake$$"
1479 cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001480__:
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001481 @echo "python3_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001482 @echo "python3_LIBS='$(LIBS)'"
1483 @echo "python3_SYSLIBS='$(SYSLIBS)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001484 @echo "python3_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001485 @echo "python3_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001486eof
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001487 dnl -- delete the lines from make about Entering/Leaving directory
1488 eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1489 rm -f -- "${tmp_mkf}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001490 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 +02001491 vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}"
1492 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1493 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//`
1494 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//`
1495 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001496 AC_CACHE_CHECK(Python3's dll name,vi_cv_dll_name_python3,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001497 [
1498 if test "X$python3_DLLLIBRARY" != "X"; then
1499 vi_cv_dll_name_python3="$python3_DLLLIBRARY"
1500 else
1501 vi_cv_dll_name_python3="$python3_INSTSONAME"
1502 fi
1503 ])
1504
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001505 PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
1506 if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001507 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 +02001508 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001509 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 +02001510 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001511 if test "X$have_python3_config_dir" = "X1" -a "$enable_python3interp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001512 dnl Define PYTHON3_HOME if --with-python-config-dir was used
1513 PYTHON3_CFLAGS="${PYTHON3_CFLAGS} -DPYTHON3_HOME='L\"${vi_cv_path_python3_pfx}\"'"
1514 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001515 PYTHON3_SRC="if_python3.c"
1516 PYTHON3_OBJ="objects/if_python3.o"
1517
1518 dnl On FreeBSD linking with "-pthread" is required to use threads.
1519 dnl _THREAD_SAFE must be used for compiling then.
1520 dnl The "-pthread" is added to $LIBS, so that the following check for
1521 dnl sigaltstack() will look in libc_r (it's there in libc!).
1522 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1523 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1524 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1525 AC_MSG_CHECKING([if -pthread should be used])
1526 threadsafe_flag=
1527 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001528 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001529 if test "`(uname) 2>/dev/null`" != Darwin; then
1530 test "$GCC" = yes && threadsafe_flag="-pthread"
1531 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1532 threadsafe_flag="-D_THREAD_SAFE"
1533 thread_lib="-pthread"
1534 fi
1535 if test "`(uname) 2>/dev/null`" = SunOS; then
1536 threadsafe_flag="-pthreads"
1537 fi
1538 fi
1539 libs_save_old=$LIBS
1540 if test -n "$threadsafe_flag"; then
1541 cflags_save=$CFLAGS
1542 CFLAGS="$CFLAGS $threadsafe_flag"
1543 LIBS="$LIBS $thread_lib"
1544 AC_TRY_LINK(,[ ],
1545 AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag",
1546 AC_MSG_RESULT(no); LIBS=$libs_save_old
1547 )
1548 CFLAGS=$cflags_save
1549 else
1550 AC_MSG_RESULT(no)
1551 fi
1552
1553 dnl check that compiling a simple program still works with the flags
1554 dnl added for Python.
1555 AC_MSG_CHECKING([if compile and link flags for Python 3 are sane])
1556 cflags_save=$CFLAGS
1557 libs_save=$LIBS
1558 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1559 LIBS="$LIBS $PYTHON3_LIBS"
1560 AC_TRY_LINK(,[ ],
1561 AC_MSG_RESULT(yes); python3_ok=yes,
1562 AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no)
1563 CFLAGS=$cflags_save
1564 LIBS=$libs_save
1565 if test "$python3_ok" = yes; then
1566 AC_DEFINE(FEAT_PYTHON3)
1567 else
1568 LIBS=$libs_save_old
1569 PYTHON3_SRC=
1570 PYTHON3_OBJ=
1571 PYTHON3_LIBS=
1572 PYTHON3_CFLAGS=
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001573 fi
1574 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001575 else
1576 AC_MSG_RESULT(too old)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001577 fi
1578 fi
Bram Moolenaar1612b1a2013-06-14 21:22:39 +02001579 if test "$fail_if_missing" = "yes" -a "$python3_ok" != "yes"; then
1580 AC_MSG_ERROR([could not configure python3])
1581 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001582fi
1583
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001584AC_SUBST(PYTHON3_LIBS)
1585AC_SUBST(PYTHON3_CFLAGS)
1586AC_SUBST(PYTHON3_SRC)
1587AC_SUBST(PYTHON3_OBJ)
1588
1589dnl if python2.x and python3.x are enabled one can only link in code
1590dnl with dlopen(), dlsym(), dlclose()
1591if test "$python_ok" = yes && test "$python3_ok" = yes; then
1592 AC_DEFINE(DYNAMIC_PYTHON)
1593 AC_DEFINE(DYNAMIC_PYTHON3)
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001594 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001595 cflags_save=$CFLAGS
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001596 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001597 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001598 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001599 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001600 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001601 #include <dlfcn.h>
1602 /* If this program fails, then RTLD_GLOBAL is needed.
1603 * RTLD_GLOBAL will be used and then it is not possible to
1604 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001605 * Only the first python version used will be switched on.
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001606 */
1607
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001608 int no_rtl_global_needed_for(char *python_instsoname, char *prefix)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001609 {
1610 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001611 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001612 if (pylib != 0)
1613 {
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001614 void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome");
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001615 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1616 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1617 void (*final)(void) = dlsym(pylib, "Py_Finalize");
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001618 (*pfx)(prefix);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001619 (*init)();
1620 needed = (*simple)("import termios") == -1;
1621 (*final)();
1622 dlclose(pylib);
1623 }
1624 return !needed;
1625 }
1626
1627 int main(int argc, char** argv)
1628 {
1629 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001630 if (no_rtl_global_needed_for("${vi_cv_dll_name_python}", "${vi_cv_path_python_pfx}"))
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001631 not_needed = 1;
1632 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001633 }])],
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001634 [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001635
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001636 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001637 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001638
1639 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python3)
1640 cflags_save=$CFLAGS
1641 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001642 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001643 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001644 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001645 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001646 #include <dlfcn.h>
1647 #include <wchar.h>
1648 /* If this program fails, then RTLD_GLOBAL is needed.
1649 * RTLD_GLOBAL will be used and then it is not possible to
1650 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001651 * Only the first python version used will be switched on.
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001652 */
1653
1654 int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix)
1655 {
1656 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001657 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001658 if (pylib != 0)
1659 {
1660 void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome");
1661 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1662 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1663 void (*final)(void) = dlsym(pylib, "Py_Finalize");
1664 (*pfx)(prefix);
1665 (*init)();
1666 needed = (*simple)("import termios") == -1;
1667 (*final)();
1668 dlclose(pylib);
1669 }
1670 return !needed;
1671 }
1672
1673 int main(int argc, char** argv)
1674 {
1675 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001676 if (no_rtl_global_needed_for("${vi_cv_dll_name_python3}", L"${vi_cv_path_python3_pfx}"))
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001677 not_needed = 1;
1678 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001679 }])],
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001680 [AC_MSG_RESULT(yes);AC_DEFINE(PY3_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
1681
1682 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001683 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001684
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001685 PYTHON_SRC="if_python.c"
1686 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001687 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001688 PYTHON_LIBS=
1689 PYTHON3_SRC="if_python3.c"
1690 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001691 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001692 PYTHON3_LIBS=
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001693elif test "$python_ok" = yes && test "$enable_pythoninterp" = "dynamic"; then
1694 AC_DEFINE(DYNAMIC_PYTHON)
1695 PYTHON_SRC="if_python.c"
1696 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001697 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001698 PYTHON_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001699elif test "$python_ok" = yes; then
1700 dnl Check that adding -fPIE works. It may be needed when using a static
1701 dnl Python library.
1702 AC_MSG_CHECKING([if -fPIE can be added for Python])
1703 cflags_save=$CFLAGS
1704 libs_save=$LIBS
1705 CFLAGS="$CFLAGS $PYTHON_CFLAGS -fPIE"
1706 LIBS="$LIBS $PYTHON_LIBS"
1707 AC_TRY_LINK(,[ ],
1708 AC_MSG_RESULT(yes); fpie_ok=yes,
1709 AC_MSG_RESULT(no); fpie_ok=no)
1710 CFLAGS=$cflags_save
1711 LIBS=$libs_save
1712 if test $fpie_ok = yes; then
1713 PYTHON_CFLAGS="$PYTHON_CFLAGS -fPIE"
1714 fi
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001715elif test "$python3_ok" = yes && test "$enable_python3interp" = "dynamic"; then
1716 AC_DEFINE(DYNAMIC_PYTHON3)
1717 PYTHON3_SRC="if_python3.c"
1718 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001719 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001720 PYTHON3_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001721elif test "$python3_ok" = yes; then
1722 dnl Check that adding -fPIE works. It may be needed when using a static
1723 dnl Python library.
1724 AC_MSG_CHECKING([if -fPIE can be added for Python3])
1725 cflags_save=$CFLAGS
1726 libs_save=$LIBS
1727 CFLAGS="$CFLAGS $PYTHON3_CFLAGS -fPIE"
1728 LIBS="$LIBS $PYTHON3_LIBS"
1729 AC_TRY_LINK(,[ ],
1730 AC_MSG_RESULT(yes); fpie_ok=yes,
1731 AC_MSG_RESULT(no); fpie_ok=no)
1732 CFLAGS=$cflags_save
1733 LIBS=$libs_save
1734 if test $fpie_ok = yes; then
1735 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -fPIE"
1736 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001737fi
1738
Bram Moolenaar071d4272004-06-13 20:20:40 +00001739AC_MSG_CHECKING(--enable-tclinterp argument)
1740AC_ARG_ENABLE(tclinterp,
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001741 [ --enable-tclinterp[=OPTS] Include Tcl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001742 [enable_tclinterp="no"])
1743AC_MSG_RESULT($enable_tclinterp)
1744
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001745if test "$enable_tclinterp" = "yes" -o "$enable_tclinterp" = "dynamic"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001746
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001747 dnl on FreeBSD tclsh is a silly script, look for tclsh8.[5420]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001748 AC_MSG_CHECKING(--with-tclsh argument)
1749 AC_ARG_WITH(tclsh, [ --with-tclsh=PATH which tclsh to use (default: tclsh8.0)],
1750 tclsh_name="$withval"; AC_MSG_RESULT($tclsh_name),
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001751 tclsh_name="tclsh8.5"; AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00001752 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1753 AC_SUBST(vi_cv_path_tcl)
1754
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001755 dnl when no specific version specified, also try 8.4, 8.2 and 8.0
1756 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.5"; then
1757 tclsh_name="tclsh8.4"
1758 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1759 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001760 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.4"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001761 tclsh_name="tclsh8.2"
1762 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1763 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001764 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.2"; then
1765 tclsh_name="tclsh8.0"
1766 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1767 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001768 dnl still didn't find it, try without version number
1769 if test "X$vi_cv_path_tcl" = "X"; then
1770 tclsh_name="tclsh"
1771 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1772 fi
1773 if test "X$vi_cv_path_tcl" != "X"; then
1774 AC_MSG_CHECKING(Tcl version)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001775 if echo 'exit [[expr [info tclversion] < 8.0]]' | "$vi_cv_path_tcl" - ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001776 tclver=`echo 'puts [[info tclversion]]' | $vi_cv_path_tcl -`
1777 AC_MSG_RESULT($tclver - OK);
1778 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 +01001779 tcldll=`echo 'puts libtcl[[info tclversion]][[info sharedlibextension]]' | $vi_cv_path_tcl -`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001780
1781 AC_MSG_CHECKING(for location of Tcl include)
Bram Moolenaard0573012017-10-28 21:11:06 +02001782 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001783 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 +00001784 else
1785 dnl For Mac OS X 10.3, use the OS-provided framework location
1786 tclinc="/System/Library/Frameworks/Tcl.framework/Headers"
1787 fi
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001788 TCL_INC=
Bram Moolenaar071d4272004-06-13 20:20:40 +00001789 for try in $tclinc; do
1790 if test -f "$try/tcl.h"; then
1791 AC_MSG_RESULT($try/tcl.h)
1792 TCL_INC=$try
1793 break
1794 fi
1795 done
1796 if test -z "$TCL_INC"; then
1797 AC_MSG_RESULT(<not found>)
1798 SKIP_TCL=YES
1799 fi
1800 if test -z "$SKIP_TCL"; then
1801 AC_MSG_CHECKING(for location of tclConfig.sh script)
Bram Moolenaard0573012017-10-28 21:11:06 +02001802 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001803 tclcnf=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001804 tclcnf="$tclcnf `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001805 else
1806 dnl For Mac OS X 10.3, use the OS-provided framework location
1807 tclcnf="/System/Library/Frameworks/Tcl.framework"
1808 fi
1809 for try in $tclcnf; do
Bram Moolenaar49222be2015-12-11 18:11:30 +01001810 if test -f "$try/tclConfig.sh"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001811 AC_MSG_RESULT($try/tclConfig.sh)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001812 . "$try/tclConfig.sh"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001813 dnl use eval, because tcl 8.2 includes ${TCL_DBGX}
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001814 if test "$enable_tclinterp" = "dynamic"; then
1815 TCL_LIBS=`eval echo "$TCL_STUB_LIB_SPEC $TCL_LIBS"`
1816 else
1817 TCL_LIBS=`eval echo "$TCL_LIB_SPEC $TCL_LIBS"`
1818 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001819 dnl Use $TCL_DEFS for -D_THREAD_SAFE et al. But only use the
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001820 dnl "-D_ABC" items. Watch out for -DFOO=long\ long.
Bram Moolenaar4394bff2008-07-24 11:21:31 +00001821 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 +00001822 break
1823 fi
1824 done
1825 if test -z "$TCL_LIBS"; then
1826 AC_MSG_RESULT(<not found>)
1827 AC_MSG_CHECKING(for Tcl library by myself)
1828 tcllib=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001829 tcllib="$tcllib `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001830 for ext in .so .a ; do
1831 for ver in "" $tclver ; do
1832 for try in $tcllib ; do
1833 trylib=tcl$ver$ext
Bram Moolenaar49222be2015-12-11 18:11:30 +01001834 if test -f "$try/lib$trylib" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001835 AC_MSG_RESULT($try/lib$trylib)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001836 TCL_LIBS="-L\"$try\" -ltcl$ver -ldl -lm"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001837 if test "`(uname) 2>/dev/null`" = SunOS &&
1838 uname -r | grep '^5' >/dev/null; then
1839 TCL_LIBS="$TCL_LIBS -R $try"
1840 fi
1841 break 3
1842 fi
1843 done
1844 done
1845 done
1846 if test -z "$TCL_LIBS"; then
1847 AC_MSG_RESULT(<not found>)
1848 SKIP_TCL=YES
1849 fi
1850 fi
1851 if test -z "$SKIP_TCL"; then
1852 AC_DEFINE(FEAT_TCL)
1853 TCL_SRC=if_tcl.c
1854 TCL_OBJ=objects/if_tcl.o
1855 TCL_PRO=if_tcl.pro
1856 TCL_CFLAGS="-I$TCL_INC $TCL_DEFS"
1857 fi
1858 fi
1859 else
1860 AC_MSG_RESULT(too old; need Tcl version 8.0 or later)
1861 fi
1862 fi
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001863 if test "$enable_tclinterp" = "dynamic"; then
1864 if test "X$TCL_SRC" != "X" -a "X$tcldll" != "X"; then
1865 AC_DEFINE(DYNAMIC_TCL)
1866 TCL_CFLAGS="-DDYNAMIC_TCL_DLL=\\\"$tcldll\\\" -DDYNAMIC_TCL_VER=\\\"$tclver\\\" $TCL_CFLAGS"
1867 fi
1868 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001869 if test "$fail_if_missing" = "yes" -a -z "$TCL_SRC"; then
1870 AC_MSG_ERROR([could not configure Tcl])
1871 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001872fi
1873AC_SUBST(TCL_SRC)
1874AC_SUBST(TCL_OBJ)
1875AC_SUBST(TCL_PRO)
1876AC_SUBST(TCL_CFLAGS)
1877AC_SUBST(TCL_LIBS)
1878
1879AC_MSG_CHECKING(--enable-rubyinterp argument)
1880AC_ARG_ENABLE(rubyinterp,
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001881 [ --enable-rubyinterp[=OPTS] Include Ruby interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001882 [enable_rubyinterp="no"])
1883AC_MSG_RESULT($enable_rubyinterp)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001884if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001885 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1886 AC_MSG_ERROR([cannot use Ruby with tiny or small features])
1887 fi
1888
Bram Moolenaar165641d2010-02-17 16:23:09 +01001889 AC_MSG_CHECKING(--with-ruby-command argument)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001890 AC_SUBST(vi_cv_path_ruby)
Bram Moolenaar948733a2011-05-05 18:10:16 +02001891 AC_ARG_WITH(ruby-command, [ --with-ruby-command=RUBY name of the Ruby command (default: ruby)],
1892 RUBY_CMD="$withval"; vi_cv_path_ruby="$withval"; AC_MSG_RESULT($RUBY_CMD),
1893 RUBY_CMD="ruby"; AC_MSG_RESULT(defaulting to $RUBY_CMD))
Bram Moolenaar165641d2010-02-17 16:23:09 +01001894 AC_PATH_PROG(vi_cv_path_ruby, $RUBY_CMD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001895 if test "X$vi_cv_path_ruby" != "X"; then
1896 AC_MSG_CHECKING(Ruby version)
Bram Moolenaare4efc3b2005-03-07 23:16:51 +00001897 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 +00001898 AC_MSG_RESULT(OK)
Bram Moolenaar81398892012-10-03 21:09:35 +02001899 AC_MSG_CHECKING(Ruby rbconfig)
1900 ruby_rbconfig="RbConfig"
1901 if ! $vi_cv_path_ruby -r rbconfig -e 'RbConfig' >/dev/null 2>/dev/null; then
1902 ruby_rbconfig="Config"
1903 fi
1904 AC_MSG_RESULT($ruby_rbconfig)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001905 AC_MSG_CHECKING(Ruby header files)
Bram Moolenaar81398892012-10-03 21:09:35 +02001906 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 +00001907 if test "X$rubyhdrdir" != "X"; then
1908 AC_MSG_RESULT($rubyhdrdir)
1909 RUBY_CFLAGS="-I$rubyhdrdir"
Bram Moolenaara6fd37b2014-03-27 17:19:09 +01001910 rubyarchdir=`$vi_cv_path_ruby -r rbconfig -e "print ($ruby_rbconfig::CONFIG.has_key? 'rubyarchhdrdir') ? $ruby_rbconfig::CONFIG[['rubyarchhdrdir']] : '$rubyhdrdir/'+$ruby_rbconfig::CONFIG[['arch']]"`
1911 if test -d "$rubyarchdir"; then
1912 RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyarchdir"
Bram Moolenaar165641d2010-02-17 16:23:09 +01001913 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001914 rubyversion=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['ruby_version']].gsub(/\./, '')[[0,2]]"`
Bram Moolenaar026a4452013-08-07 15:22:23 +02001915 if test "X$rubyversion" = "X"; then
1916 rubyversion=`$vi_cv_path_ruby -e "print ((VERSION rescue RUBY_VERSION)).gsub(/\./, '')[[0,2]]"`
1917 fi
Bram Moolenaar165641d2010-02-17 16:23:09 +01001918 RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
Bram Moolenaar81398892012-10-03 21:09:35 +02001919 rubylibs=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LIBS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001920 if test "X$rubylibs" != "X"; then
1921 RUBY_LIBS="$rubylibs"
1922 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001923 librubyarg=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBYARG']])"`
1924 librubya=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBY_A']])"`
Bram Moolenaarac499e32013-06-02 19:14:17 +02001925 rubylibdir=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['libdir']])"`
Bram Moolenaar948733a2011-05-05 18:10:16 +02001926 if test -f "$rubylibdir/$librubya"; then
1927 librubyarg="$librubyarg"
Bram Moolenaarac499e32013-06-02 19:14:17 +02001928 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
1929 elif test "$librubyarg" = "libruby.a"; then
1930 dnl required on Mac OS 10.3 where libruby.a doesn't exist
1931 librubyarg="-lruby"
1932 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001933 fi
1934
1935 if test "X$librubyarg" != "X"; then
1936 RUBY_LIBS="$librubyarg $RUBY_LIBS"
1937 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001938 rubyldflags=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LDFLAGS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001939 if test "X$rubyldflags" != "X"; then
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001940 dnl Ruby on Mac OS X 10.5 adds "-arch" flags but these should only
1941 dnl be included if requested by passing --with-mac-arch to
1942 dnl configure, so strip these flags first (if present)
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001943 rubyldflags=`echo "$rubyldflags" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001944 if test "X$rubyldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001945 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$rubyldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001946 LDFLAGS="$rubyldflags $LDFLAGS"
1947 fi
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001948 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001949 fi
1950 RUBY_SRC="if_ruby.c"
1951 RUBY_OBJ="objects/if_ruby.o"
1952 RUBY_PRO="if_ruby.pro"
1953 AC_DEFINE(FEAT_RUBY)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001954 if test "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar92021622017-10-12 12:33:43 +02001955 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_ALIASES']].split[[0]]"`
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001956 AC_DEFINE(DYNAMIC_RUBY)
Bram Moolenaar92021622017-10-12 12:33:43 +02001957 RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby_soname\\\" -DDYNAMIC_RUBY_VER=$rubyversion $RUBY_CFLAGS"
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001958 RUBY_LIBS=
1959 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001960 else
Bram Moolenaar165641d2010-02-17 16:23:09 +01001961 AC_MSG_RESULT(not found; disabling Ruby)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001962 fi
1963 else
1964 AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
1965 fi
1966 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001967
1968 if test "$fail_if_missing" = "yes" -a -z "$RUBY_OBJ"; then
1969 AC_MSG_ERROR([could not configure Ruby])
1970 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001971fi
1972AC_SUBST(RUBY_SRC)
1973AC_SUBST(RUBY_OBJ)
1974AC_SUBST(RUBY_PRO)
1975AC_SUBST(RUBY_CFLAGS)
1976AC_SUBST(RUBY_LIBS)
1977
1978AC_MSG_CHECKING(--enable-cscope argument)
1979AC_ARG_ENABLE(cscope,
1980 [ --enable-cscope Include cscope interface.], ,
1981 [enable_cscope="no"])
1982AC_MSG_RESULT($enable_cscope)
1983if test "$enable_cscope" = "yes"; then
1984 AC_DEFINE(FEAT_CSCOPE)
1985fi
1986
1987AC_MSG_CHECKING(--enable-workshop argument)
1988AC_ARG_ENABLE(workshop,
1989 [ --enable-workshop Include Sun Visual Workshop support.], ,
1990 [enable_workshop="no"])
1991AC_MSG_RESULT($enable_workshop)
1992if test "$enable_workshop" = "yes"; then
1993 AC_DEFINE(FEAT_SUN_WORKSHOP)
1994 WORKSHOP_SRC="workshop.c integration.c"
1995 AC_SUBST(WORKSHOP_SRC)
1996 WORKSHOP_OBJ="objects/workshop.o objects/integration.o"
1997 AC_SUBST(WORKSHOP_OBJ)
1998 if test "${enable_gui-xxx}" = xxx; then
1999 enable_gui=motif
2000 fi
2001fi
2002
2003AC_MSG_CHECKING(--disable-netbeans argument)
2004AC_ARG_ENABLE(netbeans,
2005 [ --disable-netbeans Disable NetBeans integration support.],
2006 , [enable_netbeans="yes"])
2007if test "$enable_netbeans" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002008 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2009 AC_MSG_RESULT([cannot use NetBeans with tiny or small features])
2010 enable_netbeans="no"
2011 else
2012 AC_MSG_RESULT(no)
2013 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002014else
2015 AC_MSG_RESULT(yes)
2016fi
2017
2018AC_MSG_CHECKING(--disable-channel argument)
2019AC_ARG_ENABLE(channel,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002020 [ --disable-channel Disable process communication support.],
Bram Moolenaare0874f82016-01-24 20:36:41 +01002021 , [enable_channel="yes"])
2022if test "$enable_channel" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002023 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2024 AC_MSG_RESULT([cannot use channels with tiny or small features])
2025 enable_channel="no"
2026 else
2027 AC_MSG_RESULT(no)
2028 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002029else
2030 if test "$enable_netbeans" = "yes"; then
Bram Moolenaar16435482016-01-24 21:31:54 +01002031 AC_MSG_RESULT([yes, netbeans also disabled])
Bram Moolenaare0874f82016-01-24 20:36:41 +01002032 enable_netbeans="no"
2033 else
2034 AC_MSG_RESULT(yes)
2035 fi
2036fi
2037
Bram Moolenaar16435482016-01-24 21:31:54 +01002038if test "$enable_channel" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002039 dnl On Solaris we need the socket and nsl library.
2040 AC_CHECK_LIB(socket, socket)
2041 AC_CHECK_LIB(nsl, gethostbyname)
Bram Moolenaare0874f82016-01-24 20:36:41 +01002042 AC_MSG_CHECKING(whether compiling with process communication is possible)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002043 AC_TRY_LINK([
2044#include <stdio.h>
2045#include <stdlib.h>
2046#include <stdarg.h>
2047#include <fcntl.h>
2048#include <netdb.h>
2049#include <netinet/in.h>
2050#include <errno.h>
2051#include <sys/types.h>
2052#include <sys/socket.h>
2053 /* Check bitfields */
2054 struct nbbuf {
2055 unsigned int initDone:1;
Bram Moolenaar63de19e2016-12-09 20:11:26 +01002056 unsigned short signmaplen;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002057 };
2058 ], [
2059 /* Check creating a socket. */
2060 struct sockaddr_in server;
2061 (void)socket(AF_INET, SOCK_STREAM, 0);
2062 (void)htons(100);
2063 (void)gethostbyname("microsoft.com");
2064 if (errno == ECONNREFUSED)
2065 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
2066 ],
2067 AC_MSG_RESULT(yes),
Bram Moolenaare0874f82016-01-24 20:36:41 +01002068 AC_MSG_RESULT(no); enable_netbeans="no"; enable_channel="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00002069fi
2070if test "$enable_netbeans" = "yes"; then
2071 AC_DEFINE(FEAT_NETBEANS_INTG)
2072 NETBEANS_SRC="netbeans.c"
2073 AC_SUBST(NETBEANS_SRC)
2074 NETBEANS_OBJ="objects/netbeans.o"
2075 AC_SUBST(NETBEANS_OBJ)
2076fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002077if test "$enable_channel" = "yes"; then
Bram Moolenaar509ce2a2016-03-11 22:52:15 +01002078 AC_DEFINE(FEAT_JOB_CHANNEL)
Bram Moolenaare0874f82016-01-24 20:36:41 +01002079 CHANNEL_SRC="channel.c"
2080 AC_SUBST(CHANNEL_SRC)
2081 CHANNEL_OBJ="objects/channel.o"
2082 AC_SUBST(CHANNEL_OBJ)
2083fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002084
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002085AC_MSG_CHECKING(--enable-terminal argument)
2086AC_ARG_ENABLE(terminal,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002087 [ --enable-terminal Enable terminal emulation support.],
Bram Moolenaaref839562017-10-28 20:28:23 +02002088 , [enable_terminal="auto"])
Bram Moolenaar595a4022017-09-03 19:15:57 +02002089if test "$enable_terminal" = "yes" || test "$enable_terminal" = "auto" -a "x$features" = "xhuge" ; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002090 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2091 AC_MSG_RESULT([cannot use terminal emulator with tiny or small features])
2092 enable_terminal="no"
2093 else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002094 if test "$enable_terminal" = "auto"; then
2095 enable_terminal="yes"
2096 AC_MSG_RESULT(defaulting to yes)
2097 else
2098 AC_MSG_RESULT(yes)
2099 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002100 fi
2101else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002102 if test "$enable_terminal" = "auto"; then
2103 enable_terminal="no"
2104 AC_MSG_RESULT(defaulting to no)
2105 else
2106 AC_MSG_RESULT(no)
2107 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002108fi
Bram Moolenaar8b423282017-12-16 14:37:06 +01002109if test "$enable_terminal" = "yes" -a "$enable_channel" = "yes"; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002110 AC_DEFINE(FEAT_TERMINAL)
2111 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"
2112 AC_SUBST(TERM_SRC)
2113 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"
2114 AC_SUBST(TERM_OBJ)
2115fi
2116
Bram Moolenaare42a6d22017-11-12 19:21:51 +01002117AC_MSG_CHECKING(--enable-autoservername argument)
2118AC_ARG_ENABLE(autoservername,
2119 [ --enable-autoservername Automatically define servername at vim startup.], ,
2120 [enable_autoservername="no"])
2121AC_MSG_RESULT($enable_autoservername)
2122if test "$enable_autoservername" = "yes"; then
2123 AC_DEFINE(FEAT_AUTOSERVERNAME)
2124fi
2125
Bram Moolenaar071d4272004-06-13 20:20:40 +00002126AC_MSG_CHECKING(--enable-multibyte argument)
2127AC_ARG_ENABLE(multibyte,
2128 [ --enable-multibyte Include multibyte editing support.], ,
2129 [enable_multibyte="no"])
2130AC_MSG_RESULT($enable_multibyte)
2131if test "$enable_multibyte" = "yes"; then
2132 AC_DEFINE(FEAT_MBYTE)
2133fi
2134
2135AC_MSG_CHECKING(--enable-hangulinput argument)
2136AC_ARG_ENABLE(hangulinput,
2137 [ --enable-hangulinput Include Hangul input support.], ,
2138 [enable_hangulinput="no"])
2139AC_MSG_RESULT($enable_hangulinput)
2140
2141AC_MSG_CHECKING(--enable-xim argument)
2142AC_ARG_ENABLE(xim,
2143 [ --enable-xim Include XIM input support.],
2144 AC_MSG_RESULT($enable_xim),
2145 [enable_xim="auto"; AC_MSG_RESULT(defaulting to auto)])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002146
2147AC_MSG_CHECKING(--enable-fontset argument)
2148AC_ARG_ENABLE(fontset,
2149 [ --enable-fontset Include X fontset output support.], ,
2150 [enable_fontset="no"])
2151AC_MSG_RESULT($enable_fontset)
2152dnl defining FEAT_XFONTSET is delayed, so that it can be disabled for no GUI
2153
2154test -z "$with_x" && with_x=yes
Bram Moolenaard0573012017-10-28 21:11:06 +02002155test "${enable_gui-yes}" != no -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && with_x=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002156if test "$with_x" = no; then
2157 AC_MSG_RESULT(defaulting to: don't HAVE_X11)
2158else
2159 dnl Do this check early, so that its failure can override user requests.
2160
2161 AC_PATH_PROG(xmkmfpath, xmkmf)
2162
2163 AC_PATH_XTRA
2164
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002165 dnl On z/OS Unix the X libraries are DLLs. To use them the code must
Bram Moolenaar071d4272004-06-13 20:20:40 +00002166 dnl be compiled with a special option.
2167 dnl Also add SM, ICE and Xmu to X_EXTRA_LIBS.
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002168 if test "$zOSUnix" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002169 CFLAGS="$CFLAGS -W c,dll"
2170 LDFLAGS="$LDFLAGS -W l,dll"
2171 X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE -lXmu"
2172 fi
2173
2174 dnl On my HPUX system the X include dir is found, but the lib dir not.
2175 dnl This is a desparate try to fix this.
2176
2177 if test -d "$x_includes" && test ! -d "$x_libraries"; then
2178 x_libraries=`echo "$x_includes" | sed s/include/lib/`
2179 AC_MSG_RESULT(Corrected X libraries to $x_libraries)
2180 X_LIBS="$X_LIBS -L$x_libraries"
2181 if test "`(uname) 2>/dev/null`" = SunOS &&
2182 uname -r | grep '^5' >/dev/null; then
2183 X_LIBS="$X_LIBS -R $x_libraries"
2184 fi
2185 fi
2186
2187 if test -d "$x_libraries" && test ! -d "$x_includes"; then
2188 x_includes=`echo "$x_libraries" | sed s/lib/include/`
2189 AC_MSG_RESULT(Corrected X includes to $x_includes)
2190 X_CFLAGS="$X_CFLAGS -I$x_includes"
2191 fi
2192
2193 dnl Remove "-I/usr/include " from X_CFLAGS, should not be needed.
2194 X_CFLAGS="`echo $X_CFLAGS\ | sed 's%-I/usr/include %%'`"
2195 dnl Remove "-L/usr/lib " from X_LIBS, should not be needed.
2196 X_LIBS="`echo $X_LIBS\ | sed 's%-L/usr/lib %%'`"
2197 dnl Same for "-R/usr/lib ".
2198 X_LIBS="`echo $X_LIBS\ | sed -e 's%-R/usr/lib %%' -e 's%-R /usr/lib %%'`"
2199
2200
2201 dnl Check if the X11 header files are correctly installed. On some systems
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002202 dnl Xlib.h includes files that don't exist. On some systems X11/Intrinsic.h
2203 dnl is missing.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002204 AC_MSG_CHECKING(if X11 header files can be found)
2205 cflags_save=$CFLAGS
2206 CFLAGS="$CFLAGS $X_CFLAGS"
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002207 AC_TRY_COMPILE([#include <X11/Xlib.h>
2208#include <X11/Intrinsic.h>], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002209 AC_MSG_RESULT(yes),
2210 AC_MSG_RESULT(no); no_x=yes)
2211 CFLAGS=$cflags_save
2212
2213 if test "${no_x-no}" = yes; then
2214 with_x=no
2215 else
2216 AC_DEFINE(HAVE_X11)
2217 X_LIB="-lXt -lX11";
2218 AC_SUBST(X_LIB)
2219
2220 ac_save_LDFLAGS="$LDFLAGS"
2221 LDFLAGS="-L$x_libraries $LDFLAGS"
2222
2223 dnl Check for -lXdmcp (needed on SunOS 4.1.4)
2224 dnl For HP-UX 10.20 it must be before -lSM -lICE
2225 AC_CHECK_LIB(Xdmcp, _XdmcpAuthDoIt, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lXdmcp"],,
2226 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXdmcp])
2227
2228 dnl Some systems need -lnsl -lsocket when testing for ICE.
2229 dnl The check above doesn't do this, try here (again). Also needed to get
2230 dnl them after Xdmcp. link.sh will remove them when not needed.
2231 dnl Check for other function than above to avoid the cached value
2232 AC_CHECK_LIB(ICE, IceOpenConnection,
2233 [X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE"],, [$X_EXTRA_LIBS])
2234
2235 dnl Check for -lXpm (needed for some versions of Motif)
2236 LDFLAGS="$X_LIBS $ac_save_LDFLAGS"
2237 AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [X_PRE_LIBS="$X_PRE_LIBS -lXpm"],,
2238 [-lXt $X_PRE_LIBS -lXpm -lX11 $X_EXTRA_LIBS])
2239
2240 dnl Check that the X11 header files don't use implicit declarations
2241 AC_MSG_CHECKING(if X11 header files implicitly declare return values)
2242 cflags_save=$CFLAGS
Bram Moolenaard1864592013-05-04 04:40:15 +02002243 dnl -Werror is GCC only, others like Solaris Studio might not like it
2244 if test "$GCC" = yes; then
2245 CFLAGS="$CFLAGS $X_CFLAGS -Werror"
2246 else
2247 CFLAGS="$CFLAGS $X_CFLAGS"
2248 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002249 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2250 AC_MSG_RESULT(no),
2251 CFLAGS="$CFLAGS -Wno-implicit-int"
2252 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2253 AC_MSG_RESULT(yes); cflags_save="$cflags_save -Wno-implicit-int",
2254 AC_MSG_RESULT(test failed)
2255 )
2256 )
2257 CFLAGS=$cflags_save
2258
2259 LDFLAGS="$ac_save_LDFLAGS"
2260
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002261 AC_MSG_CHECKING(size of wchar_t is 2 bytes)
2262 AC_CACHE_VAL(ac_cv_small_wchar_t,
2263 [AC_TRY_RUN([
2264#include <X11/Xlib.h>
2265#if STDC_HEADERS
2266# include <stdlib.h>
2267# include <stddef.h>
2268#endif
2269 main()
2270 {
2271 if (sizeof(wchar_t) <= 2)
2272 exit(1);
2273 exit(0);
2274 }],
2275 ac_cv_small_wchar_t="no",
2276 ac_cv_small_wchar_t="yes",
2277 AC_MSG_ERROR(failed to compile test program))])
2278 AC_MSG_RESULT($ac_cv_small_wchar_t)
2279 if test "x$ac_cv_small_wchar_t" = "xyes" ; then
2280 AC_DEFINE(SMALL_WCHAR_T)
2281 fi
2282
Bram Moolenaar071d4272004-06-13 20:20:40 +00002283 fi
2284fi
2285
Bram Moolenaard0573012017-10-28 21:11:06 +02002286test "x$with_x" = xno -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && enable_gui=no
Bram Moolenaar071d4272004-06-13 20:20:40 +00002287
2288AC_MSG_CHECKING(--enable-gui argument)
2289AC_ARG_ENABLE(gui,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002290 [ --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 +00002291
2292dnl Canonicalize the --enable-gui= argument so that it can be easily compared.
2293dnl Do not use character classes for portability with old tools.
2294enable_gui_canon=`echo "_$enable_gui" | \
2295 sed 's/[[ _+-]]//g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
2296
2297dnl Skip everything by default.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002298SKIP_GTK2=YES
Bram Moolenaar1858a842016-02-23 22:30:31 +01002299SKIP_GTK3=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002300SKIP_GNOME=YES
2301SKIP_MOTIF=YES
2302SKIP_ATHENA=YES
2303SKIP_NEXTAW=YES
2304SKIP_PHOTON=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002305SKIP_CARBON=YES
2306GUITYPE=NONE
2307
Bram Moolenaarb11160e2005-01-04 21:31:43 +00002308if test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002309 SKIP_PHOTON=
2310 case "$enable_gui_canon" in
2311 no) AC_MSG_RESULT(no GUI support)
2312 SKIP_PHOTON=YES ;;
2313 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
2314 auto) AC_MSG_RESULT(auto - automatic GUI support) ;;
2315 photon) AC_MSG_RESULT(Photon GUI support) ;;
2316 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2317 SKIP_PHOTON=YES ;;
2318 esac
2319
Bram Moolenaard0573012017-10-28 21:11:06 +02002320elif test "x$MACOS_X" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002321 SKIP_CARBON=
2322 case "$enable_gui_canon" in
2323 no) AC_MSG_RESULT(no GUI support)
2324 SKIP_CARBON=YES ;;
2325 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
Bram Moolenaar164fca32010-07-14 13:58:07 +02002326 auto) AC_MSG_RESULT(auto - Carbon GUI is outdated - disable GUI support)
2327 SKIP_CARBON=YES ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002328 carbon) AC_MSG_RESULT(Carbon GUI support) ;;
2329 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2330 SKIP_CARBON=YES ;;
2331 esac
2332
2333else
2334
Bram Moolenaar071d4272004-06-13 20:20:40 +00002335 case "$enable_gui_canon" in
2336 no|none) AC_MSG_RESULT(no GUI support) ;;
2337 yes|""|auto) AC_MSG_RESULT(yes/auto - automatic GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002338 SKIP_GTK2=
2339 SKIP_GNOME=
2340 SKIP_MOTIF=
2341 SKIP_ATHENA=
2342 SKIP_NEXTAW=
2343 SKIP_CARBON=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002344 gtk2) AC_MSG_RESULT(GTK+ 2.x GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002345 SKIP_GTK2=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002346 gnome2) AC_MSG_RESULT(GNOME 2.x GUI support)
2347 SKIP_GNOME=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002348 SKIP_GTK2=;;
Bram Moolenaar98921892016-02-23 17:14:37 +01002349 gtk3) AC_MSG_RESULT(GTK+ 3.x GUI support)
2350 SKIP_GTK3=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002351 motif) AC_MSG_RESULT(Motif GUI support)
2352 SKIP_MOTIF=;;
2353 athena) AC_MSG_RESULT(Athena GUI support)
2354 SKIP_ATHENA=;;
2355 nextaw) AC_MSG_RESULT(neXtaw GUI support)
2356 SKIP_NEXTAW=;;
2357 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
2358 esac
2359
2360fi
2361
Bram Moolenaar071d4272004-06-13 20:20:40 +00002362if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \
2363 -a "$enable_gui_canon" != "gnome2"; then
2364 AC_MSG_CHECKING(whether or not to look for GTK+ 2)
2365 AC_ARG_ENABLE(gtk2-check,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002366 [ --enable-gtk2-check If auto-select GUI, check for GTK+ 2 [default=yes]],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002367 , enable_gtk2_check="yes")
2368 AC_MSG_RESULT($enable_gtk2_check)
2369 if test "x$enable_gtk2_check" = "xno"; then
2370 SKIP_GTK2=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002371 SKIP_GNOME=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002372 fi
2373fi
2374
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002375if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002376 AC_MSG_CHECKING(whether or not to look for GNOME)
2377 AC_ARG_ENABLE(gnome-check,
2378 [ --enable-gnome-check If GTK GUI, check for GNOME [default=no]],
2379 , enable_gnome_check="no")
2380 AC_MSG_RESULT($enable_gnome_check)
2381 if test "x$enable_gnome_check" = "xno"; then
2382 SKIP_GNOME=YES
2383 fi
2384fi
2385
Bram Moolenaar98921892016-02-23 17:14:37 +01002386if test "x$SKIP_GTK3" != "xYES" -a "$enable_gui_canon" != "gtk3"; then
2387 AC_MSG_CHECKING(whether or not to look for GTK+ 3)
2388 AC_ARG_ENABLE(gtk3-check,
2389 [ --enable-gtk3-check If auto-select GUI, check for GTK+ 3 [default=yes]],
2390 , enable_gtk3_check="yes")
2391 AC_MSG_RESULT($enable_gtk3_check)
2392 if test "x$enable_gtk3_check" = "xno"; then
2393 SKIP_GTK3=YES
2394 fi
2395fi
2396
Bram Moolenaar071d4272004-06-13 20:20:40 +00002397if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then
2398 AC_MSG_CHECKING(whether or not to look for Motif)
2399 AC_ARG_ENABLE(motif-check,
2400 [ --enable-motif-check If auto-select GUI, check for Motif [default=yes]],
2401 , enable_motif_check="yes")
2402 AC_MSG_RESULT($enable_motif_check)
2403 if test "x$enable_motif_check" = "xno"; then
2404 SKIP_MOTIF=YES
2405 fi
2406fi
2407
2408if test "x$SKIP_ATHENA" != "xYES" -a "$enable_gui_canon" != "athena"; then
2409 AC_MSG_CHECKING(whether or not to look for Athena)
2410 AC_ARG_ENABLE(athena-check,
2411 [ --enable-athena-check If auto-select GUI, check for Athena [default=yes]],
2412 , enable_athena_check="yes")
2413 AC_MSG_RESULT($enable_athena_check)
2414 if test "x$enable_athena_check" = "xno"; then
2415 SKIP_ATHENA=YES
2416 fi
2417fi
2418
2419if test "x$SKIP_NEXTAW" != "xYES" -a "$enable_gui_canon" != "nextaw"; then
2420 AC_MSG_CHECKING(whether or not to look for neXtaw)
2421 AC_ARG_ENABLE(nextaw-check,
2422 [ --enable-nextaw-check If auto-select GUI, check for neXtaw [default=yes]],
2423 , enable_nextaw_check="yes")
2424 AC_MSG_RESULT($enable_nextaw_check);
2425 if test "x$enable_nextaw_check" = "xno"; then
2426 SKIP_NEXTAW=YES
2427 fi
2428fi
2429
2430if test "x$SKIP_CARBON" != "xYES" -a "$enable_gui_canon" != "carbon"; then
2431 AC_MSG_CHECKING(whether or not to look for Carbon)
2432 AC_ARG_ENABLE(carbon-check,
2433 [ --enable-carbon-check If auto-select GUI, check for Carbon [default=yes]],
2434 , enable_carbon_check="yes")
2435 AC_MSG_RESULT($enable_carbon_check);
2436 if test "x$enable_carbon_check" = "xno"; then
2437 SKIP_CARBON=YES
2438 fi
2439fi
2440
Bram Moolenaar843ee412004-06-30 16:16:41 +00002441
Bram Moolenaard0573012017-10-28 21:11:06 +02002442if test "x$MACOS_X" = "xyes" -a -z "$SKIP_CARBON" -a "x$CARBON" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002443 AC_MSG_CHECKING(for Carbon GUI)
Bram Moolenaar14716812006-05-04 21:54:08 +00002444 dnl already did the check, just give the message
Bram Moolenaar071d4272004-06-13 20:20:40 +00002445 AC_MSG_RESULT(yes);
2446 GUITYPE=CARBONGUI
Bram Moolenaare344bea2005-09-01 20:46:49 +00002447 if test "$VIMNAME" = "vim"; then
2448 VIMNAME=Vim
2449 fi
Bram Moolenaar14716812006-05-04 21:54:08 +00002450
Bram Moolenaar164fca32010-07-14 13:58:07 +02002451 if test "x$MACARCH" = "xboth"; then
2452 CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk/Developer/Headers/FlatCarbon"
2453 else
2454 CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/Headers/FlatCarbon"
2455 fi
2456
Bram Moolenaar14716812006-05-04 21:54:08 +00002457 dnl Default install directory is not /usr/local
2458 if test x$prefix = xNONE; then
2459 prefix=/Applications
2460 fi
2461
2462 dnl Sorry for the hard coded default
2463 datadir='${prefix}/Vim.app/Contents/Resources'
2464
Bram Moolenaar071d4272004-06-13 20:20:40 +00002465 dnl skip everything else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002466 SKIP_GTK2=YES;
2467 SKIP_GNOME=YES;
2468 SKIP_MOTIF=YES;
2469 SKIP_ATHENA=YES;
2470 SKIP_NEXTAW=YES;
2471 SKIP_PHOTON=YES;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002472 SKIP_CARBON=YES
2473fi
2474
Bram Moolenaar071d4272004-06-13 20:20:40 +00002475dnl define an autoconf function to check for a specified version of GTK, and
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002476dnl try to compile/link a GTK program.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002477dnl
2478dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002479dnl Test for GTK, and define GTK_CFLAGS, GTK_LIBDIR and GTK_LIBS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002480dnl
2481AC_DEFUN(AM_PATH_GTK,
2482[
2483 if test "X$GTK_CONFIG" != "Xno" -o "X$PKG_CONFIG" != "Xno"; then
2484 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00002485 no_gtk=""
2486 if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2487 && $PKG_CONFIG --exists gtk+-2.0; then
2488 {
Bram Moolenaar98921892016-02-23 17:14:37 +01002489 min_gtk_version=ifelse([$1], ,2.2.0,$1)
2490 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002491 dnl We should be using PKG_CHECK_MODULES() instead of this hack.
2492 dnl But I guess the dependency on pkgconfig.m4 is not wanted or
2493 dnl something like that.
2494 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0`
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002495 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-2.0`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002496 GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0`
2497 gtk_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2498 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2499 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2500 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2501 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2502 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2503 }
Bram Moolenaar98921892016-02-23 17:14:37 +01002504 elif (test "X$SKIP_GTK3" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2505 && $PKG_CONFIG --exists gtk+-3.0; then
2506 {
2507 min_gtk_version=ifelse([$1], ,3.0.0,$1)
2508 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
2509
2510 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-3.0`
2511 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-3.0`
2512 GTK_LIBS=`$PKG_CONFIG --libs gtk+-3.0`
2513 gtk_major_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2514 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2515 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2516 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2517 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2518 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2519 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002520 else
2521 no_gtk=yes
2522 fi
2523
2524 if test "x$enable_gtktest" = "xyes" -a "x$no_gtk" = "x"; then
2525 {
2526 ac_save_CFLAGS="$CFLAGS"
2527 ac_save_LIBS="$LIBS"
2528 CFLAGS="$CFLAGS $GTK_CFLAGS"
2529 LIBS="$LIBS $GTK_LIBS"
2530
2531 dnl
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002532 dnl Now check if the installed GTK is sufficiently new.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002533 dnl
2534 rm -f conf.gtktest
2535 AC_TRY_RUN([
2536#include <gtk/gtk.h>
2537#include <stdio.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00002538#if STDC_HEADERS
2539# include <stdlib.h>
2540# include <stddef.h>
2541#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002542
2543int
2544main ()
2545{
2546int major, minor, micro;
2547char *tmp_version;
2548
2549system ("touch conf.gtktest");
2550
2551/* HP/UX 9 (%@#!) writes to sscanf strings */
2552tmp_version = g_strdup("$min_gtk_version");
2553if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
2554 printf("%s, bad version string\n", "$min_gtk_version");
2555 exit(1);
2556 }
2557
2558if ((gtk_major_version > major) ||
2559 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
2560 ((gtk_major_version == major) && (gtk_minor_version == minor) &&
2561 (gtk_micro_version >= micro)))
2562{
2563 return 0;
2564}
2565return 1;
2566}
2567],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
2568 CFLAGS="$ac_save_CFLAGS"
2569 LIBS="$ac_save_LIBS"
2570 }
2571 fi
2572 if test "x$no_gtk" = x ; then
2573 if test "x$enable_gtktest" = "xyes"; then
2574 AC_MSG_RESULT(yes; found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2575 else
2576 AC_MSG_RESULT(found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2577 fi
2578 ifelse([$2], , :, [$2])
2579 else
2580 {
2581 AC_MSG_RESULT(no)
2582 GTK_CFLAGS=""
2583 GTK_LIBS=""
2584 ifelse([$3], , :, [$3])
2585 }
2586 fi
2587 }
2588 else
2589 GTK_CFLAGS=""
2590 GTK_LIBS=""
2591 ifelse([$3], , :, [$3])
2592 fi
2593 AC_SUBST(GTK_CFLAGS)
2594 AC_SUBST(GTK_LIBS)
2595 rm -f conf.gtktest
2596])
2597
2598dnl ---------------------------------------------------------------------------
2599dnl gnome
2600dnl ---------------------------------------------------------------------------
2601AC_DEFUN([GNOME_INIT_HOOK],
2602[
2603 AC_SUBST(GNOME_LIBS)
2604 AC_SUBST(GNOME_LIBDIR)
2605 AC_SUBST(GNOME_INCLUDEDIR)
2606
2607 AC_ARG_WITH(gnome-includes,
2608 [ --with-gnome-includes=DIR Specify location of GNOME headers],
2609 [CFLAGS="$CFLAGS -I$withval"]
2610 )
2611
2612 AC_ARG_WITH(gnome-libs,
2613 [ --with-gnome-libs=DIR Specify location of GNOME libs],
2614 [LDFLAGS="$LDFLAGS -L$withval" gnome_prefix=$withval]
2615 )
2616
2617 AC_ARG_WITH(gnome,
2618 [ --with-gnome Specify prefix for GNOME files],
2619 if test x$withval = xyes; then
2620 want_gnome=yes
2621 ifelse([$1], [], :, [$1])
2622 else
2623 if test "x$withval" = xno; then
2624 want_gnome=no
2625 else
2626 want_gnome=yes
2627 LDFLAGS="$LDFLAGS -L$withval/lib"
2628 CFLAGS="$CFLAGS -I$withval/include"
2629 gnome_prefix=$withval/lib
2630 fi
2631 fi,
2632 want_gnome=yes)
2633
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002634 if test "x$want_gnome" = xyes; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002635 {
2636 AC_MSG_CHECKING(for libgnomeui-2.0)
2637 if $PKG_CONFIG --exists libgnomeui-2.0; then
2638 AC_MSG_RESULT(yes)
2639 GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0`
2640 GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0`
2641 GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0`
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002642
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002643 dnl On FreeBSD we need -pthread but pkg-config doesn't include it.
2644 dnl This might not be the right way but it works for me...
2645 AC_MSG_CHECKING(for FreeBSD)
2646 if test "`(uname) 2>/dev/null`" = FreeBSD; then
2647 AC_MSG_RESULT(yes, adding -pthread)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002648 GNOME_INCLUDEDIR="$GNOME_INCLUDEDIR -D_THREAD_SAFE"
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002649 GNOME_LIBS="$GNOME_LIBS -pthread"
2650 else
2651 AC_MSG_RESULT(no)
2652 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002653 $1
2654 else
2655 AC_MSG_RESULT(not found)
2656 if test "x$2" = xfail; then
2657 AC_MSG_ERROR(Could not find libgnomeui-2.0 via pkg-config)
2658 fi
2659 fi
2660 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002661 fi
2662])
2663
2664AC_DEFUN([GNOME_INIT],[
2665 GNOME_INIT_HOOK([],fail)
2666])
2667
2668
2669dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002670dnl Check for GTK2. If it fails, then continue on for Motif as before...
Bram Moolenaar071d4272004-06-13 20:20:40 +00002671dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002672if test -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002673
2674 AC_MSG_CHECKING(--disable-gtktest argument)
2675 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2676 , enable_gtktest=yes)
2677 if test "x$enable_gtktest" = "xyes" ; then
2678 AC_MSG_RESULT(gtk test enabled)
2679 else
2680 AC_MSG_RESULT(gtk test disabled)
2681 fi
2682
Bram Moolenaar071d4272004-06-13 20:20:40 +00002683 if test "X$PKG_CONFIG" = "X"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01002684 AC_PATH_TOOL(PKG_CONFIG, pkg-config, no)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002685 fi
2686
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002687 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002688 dnl First try finding version 2.2.0 or later. The 2.0.x series has
2689 dnl problems (bold fonts, --remote doesn't work).
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002690 AM_PATH_GTK(2.2.0,
2691 [GUI_LIB_LOC="$GTK_LIBDIR"
2692 GTK_LIBNAME="$GTK_LIBS"
2693 GUI_INC_LOC="$GTK_CFLAGS"], )
2694 if test "x$GTK_CFLAGS" != "x"; then
Bram Moolenaar98921892016-02-23 17:14:37 +01002695 SKIP_GTK3=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002696 SKIP_ATHENA=YES
2697 SKIP_NEXTAW=YES
2698 SKIP_MOTIF=YES
2699 GUITYPE=GTK
2700 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002701 fi
2702 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002703 if test "x$GUITYPE" = "xGTK"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002704 dnl
2705 dnl if GTK exists, then check for GNOME.
2706 dnl
2707 if test -z "$SKIP_GNOME"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002708 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002709 GNOME_INIT_HOOK([have_gnome=yes])
2710 if test "x$have_gnome" = xyes ; then
2711 AC_DEFINE(FEAT_GUI_GNOME)
2712 GUI_INC_LOC="$GUI_INC_LOC $GNOME_INCLUDEDIR"
2713 GTK_LIBNAME="$GTK_LIBNAME $GNOME_LIBDIR $GNOME_LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002714 fi
2715 }
2716 fi
2717 fi
2718fi
2719
Bram Moolenaar98921892016-02-23 17:14:37 +01002720
2721dnl ---------------------------------------------------------------------------
2722dnl Check for GTK3.
2723dnl ---------------------------------------------------------------------------
2724if test -z "$SKIP_GTK3"; then
2725
2726 AC_MSG_CHECKING(--disable-gtktest argument)
2727 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2728 , enable_gtktest=yes)
2729 if test "x$enable_gtktest" = "xyes" ; then
2730 AC_MSG_RESULT(gtk test enabled)
2731 else
2732 AC_MSG_RESULT(gtk test disabled)
2733 fi
2734
2735 if test "X$PKG_CONFIG" = "X"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01002736 AC_PATH_TOOL(PKG_CONFIG, pkg-config, no)
Bram Moolenaar98921892016-02-23 17:14:37 +01002737 fi
2738
2739 if test "x$PKG_CONFIG" != "xno"; then
2740 AM_PATH_GTK(3.0.0,
2741 [GUI_LIB_LOC="$GTK_LIBDIR"
2742 GTK_LIBNAME="$GTK_LIBS"
2743 GUI_INC_LOC="$GTK_CFLAGS"], )
2744 if test "x$GTK_CFLAGS" != "x"; then
2745 SKIP_GTK2=YES
2746 SKIP_GNOME=YES
2747 SKIP_ATHENA=YES
2748 SKIP_NEXTAW=YES
2749 SKIP_MOTIF=YES
2750 GUITYPE=GTK
2751 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar98921892016-02-23 17:14:37 +01002752 AC_DEFINE(USE_GTK3)
2753 fi
2754 fi
2755fi
2756
Bram Moolenaard2e03f02016-01-02 22:46:36 +01002757dnl Check the version of Gdk-Pixbuf. If the version is 2.31 or later and
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002758dnl glib-compile-resources is found in PATH, use GResource.
2759if test "x$GUITYPE" = "xGTK"; then
2760 AC_MSG_CHECKING([version of Gdk-Pixbuf])
2761 gdk_pixbuf_version=`$PKG_CONFIG --modversion gdk-pixbuf-2.0`
2762 if test "x$gdk_pixbuf_version" != x ; then
2763 gdk_pixbuf_version_minor=`echo $gdk_pixbuf_version | \
2764 sed -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/'`
2765 if test "x$gdk_pixbuf_version_minor" != x -a \
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002766 $gdk_pixbuf_version_minor -ge 31 ; then
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002767 AC_MSG_RESULT([OK.])
2768 AC_PATH_PROG(GLIB_COMPILE_RESOURCES,[glib-compile-resources],no)
2769 AC_MSG_CHECKING([glib-compile-resources])
2770 if test "x$GLIB_COMPILE_RESOURCES" = xno ; then
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002771 GLIB_COMPILE_RESOURCES=""
2772 AC_MSG_RESULT([cannot be found in PATH.])
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002773 else
2774 AC_MSG_RESULT([usable.])
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002775 AC_DEFINE(USE_GRESOURCE)
2776 GRESOURCE_SRC="auto/gui_gtk_gresources.c"
2777 GRESOURCE_OBJ="objects/gui_gtk_gresources.o"
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002778 fi
2779 else
2780 AC_MSG_RESULT([not usable.])
2781 fi
2782 else
2783 AC_MSG_RESULT([cannot obtain from pkg_config.])
2784 fi
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002785
2786 AC_MSG_CHECKING([--disable-icon-cache-update argument])
2787 AC_ARG_ENABLE(icon_cache_update,
2788 [ --disable-icon-cache-update update disabled],
2789 [],
2790 [enable_icon_cache_update="yes"])
2791 if test "$enable_icon_cache_update" = "yes"; then
2792 AC_MSG_RESULT([not set])
2793 AC_PATH_PROG(GTK_UPDATE_ICON_CACHE,[gtk-update-icon-cache],no)
2794 if test "x$GTK_UPDATE_ICON_CACHE" = "xno" ; then
2795 AC_MSG_RESULT([not found in PATH.])
2796 fi
2797 else
2798 AC_MSG_RESULT([update disabled])
2799 fi
2800
2801 AC_MSG_CHECKING([--disable-desktop-database-update argument])
2802 AC_ARG_ENABLE(desktop_database_update,
2803 [ --disable-desktop-database-update update disabled],
2804 [],
2805 [enable_desktop_database_update="yes"])
2806 if test "$enable_desktop_database_update" = "yes"; then
2807 AC_MSG_RESULT([not set])
2808 AC_PATH_PROG(UPDATE_DESKTOP_DATABASE,[update-desktop-database],no)
2809 if test "x$UPDATE_DESKTOP_DATABASE" = "xno" ; then
2810 AC_MSG_RESULT([not found in PATH.])
2811 fi
2812 else
2813 AC_MSG_RESULT([update disabled])
2814 fi
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002815fi
2816AC_SUBST(GLIB_COMPILE_RESOURCES)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002817AC_SUBST(GRESOURCE_SRC)
2818AC_SUBST(GRESOURCE_OBJ)
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002819AC_SUBST(GTK_UPDATE_ICON_CACHE)
2820AC_SUBST(UPDATE_DESKTOP_DATABASE)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002821
Bram Moolenaar071d4272004-06-13 20:20:40 +00002822dnl Check for Motif include files location.
2823dnl The LAST one found is used, this makes the highest version to be used,
2824dnl e.g. when Motif1.2 and Motif2.0 are both present.
2825
2826if test -z "$SKIP_MOTIF"; then
2827 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"
2828 dnl Remove "-I" from before $GUI_INC_LOC if it's there
2829 GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`"
2830
2831 AC_MSG_CHECKING(for location of Motif GUI includes)
2832 gui_includes="`echo $x_includes|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC"
2833 GUI_INC_LOC=
2834 for try in $gui_includes; do
2835 if test -f "$try/Xm/Xm.h"; then
2836 GUI_INC_LOC=$try
2837 fi
2838 done
2839 if test -n "$GUI_INC_LOC"; then
2840 if test "$GUI_INC_LOC" = /usr/include; then
2841 GUI_INC_LOC=
2842 AC_MSG_RESULT(in default path)
2843 else
2844 AC_MSG_RESULT($GUI_INC_LOC)
2845 fi
2846 else
2847 AC_MSG_RESULT(<not found>)
2848 SKIP_MOTIF=YES
2849 fi
2850fi
2851
2852dnl Check for Motif library files location. In the same order as the include
2853dnl files, to avoid a mixup if several versions are present
2854
2855if test -z "$SKIP_MOTIF"; then
2856 AC_MSG_CHECKING(--with-motif-lib argument)
2857 AC_ARG_WITH(motif-lib,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002858 [ --with-motif-lib=STRING Library for Motif ],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002859 [ MOTIF_LIBNAME="${withval}" ] )
2860
2861 if test -n "$MOTIF_LIBNAME"; then
2862 AC_MSG_RESULT($MOTIF_LIBNAME)
2863 GUI_LIB_LOC=
2864 else
2865 AC_MSG_RESULT(no)
2866
2867 dnl Remove "-L" from before $GUI_LIB_LOC if it's there
2868 GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
2869
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002870 dnl Ubuntu has libXm.so in /usr/lib/i386-linux-gnu and elsewhere. The
2871 dnl linker will figure out which one to use, we only check if one exists.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002872 AC_MSG_CHECKING(for location of Motif GUI libs)
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002873 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 +00002874 GUI_LIB_LOC=
2875 for try in $gui_libs; do
Bram Moolenaar325b7a22004-07-05 15:58:32 +00002876 for libtry in "$try"/libXm.a "$try"/libXm.so* "$try"/libXm.sl "$try"/libXm.dylib; do
Bram Moolenaar071d4272004-06-13 20:20:40 +00002877 if test -f "$libtry"; then
2878 GUI_LIB_LOC=$try
2879 fi
2880 done
2881 done
2882 if test -n "$GUI_LIB_LOC"; then
2883 dnl Remove /usr/lib, it causes trouble on some systems
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002884 if test "$GUI_LIB_LOC" = /usr/lib \
2885 -o "$GUI_LIB_LOC" = /usr/lib/i386-linux-gnu \
2886 -o "$GUI_LIB_LOC" = /usr/lib/x86_64-linux-gnu; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002887 GUI_LIB_LOC=
2888 AC_MSG_RESULT(in default path)
2889 else
2890 if test -n "$GUI_LIB_LOC"; then
2891 AC_MSG_RESULT($GUI_LIB_LOC)
2892 if test "`(uname) 2>/dev/null`" = SunOS &&
2893 uname -r | grep '^5' >/dev/null; then
2894 GUI_LIB_LOC="$GUI_LIB_LOC -R $GUI_LIB_LOC"
2895 fi
2896 fi
2897 fi
2898 MOTIF_LIBNAME=-lXm
2899 else
2900 AC_MSG_RESULT(<not found>)
2901 SKIP_MOTIF=YES
2902 fi
2903 fi
2904fi
2905
2906if test -z "$SKIP_MOTIF"; then
2907 SKIP_ATHENA=YES
2908 SKIP_NEXTAW=YES
2909 GUITYPE=MOTIF
2910 AC_SUBST(MOTIF_LIBNAME)
2911fi
2912
2913dnl Check if the Athena files can be found
2914
2915GUI_X_LIBS=
2916
2917if test -z "$SKIP_ATHENA"; then
2918 AC_MSG_CHECKING(if Athena header files can be found)
2919 cflags_save=$CFLAGS
2920 CFLAGS="$CFLAGS $X_CFLAGS"
2921 AC_TRY_COMPILE([
2922#include <X11/Intrinsic.h>
2923#include <X11/Xaw/Paned.h>], ,
2924 AC_MSG_RESULT(yes),
2925 AC_MSG_RESULT(no); SKIP_ATHENA=YES )
2926 CFLAGS=$cflags_save
2927fi
2928
2929if test -z "$SKIP_ATHENA"; then
2930 GUITYPE=ATHENA
2931fi
2932
2933if test -z "$SKIP_NEXTAW"; then
2934 AC_MSG_CHECKING(if neXtaw header files can be found)
2935 cflags_save=$CFLAGS
2936 CFLAGS="$CFLAGS $X_CFLAGS"
2937 AC_TRY_COMPILE([
2938#include <X11/Intrinsic.h>
2939#include <X11/neXtaw/Paned.h>], ,
2940 AC_MSG_RESULT(yes),
2941 AC_MSG_RESULT(no); SKIP_NEXTAW=YES )
2942 CFLAGS=$cflags_save
2943fi
2944
2945if test -z "$SKIP_NEXTAW"; then
2946 GUITYPE=NEXTAW
2947fi
2948
2949if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
2950 dnl Prepend -I and -L to $GUI_INC_LOC and $GUI_LIB_LOC if not empty
2951 dnl Avoid adding it when it twice
2952 if test -n "$GUI_INC_LOC"; then
2953 GUI_INC_LOC=-I"`echo $GUI_INC_LOC|sed 's%-I%%'`"
2954 fi
2955 if test -n "$GUI_LIB_LOC"; then
2956 GUI_LIB_LOC=-L"`echo $GUI_LIB_LOC|sed 's%-L%%'`"
2957 fi
2958
2959 dnl Check for -lXext and then for -lXmu
2960 ldflags_save=$LDFLAGS
2961 LDFLAGS="$X_LIBS $LDFLAGS"
2962 AC_CHECK_LIB(Xext, XShapeQueryExtension, [GUI_X_LIBS="-lXext"],,
2963 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2964 dnl For Solaris we need -lw and -ldl before linking with -lXmu works.
2965 AC_CHECK_LIB(w, wslen, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lw"],,
2966 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2967 AC_CHECK_LIB(dl, dlsym, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldl"],,
2968 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2969 AC_CHECK_LIB(Xmu, XmuCreateStippledPixmap, [GUI_X_LIBS="-lXmu $GUI_X_LIBS"],,
2970 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2971 if test -z "$SKIP_MOTIF"; then
2972 AC_CHECK_LIB(Xp, XpEndJob, [GUI_X_LIBS="-lXp $GUI_X_LIBS"],,
2973 [$GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2974 fi
2975 LDFLAGS=$ldflags_save
2976
2977 dnl Execute xmkmf to figure out if -DNARROWPROTO is needed.
2978 AC_MSG_CHECKING(for extra X11 defines)
2979 NARROW_PROTO=
2980 rm -fr conftestdir
2981 if mkdir conftestdir; then
2982 cd conftestdir
2983 cat > Imakefile <<'EOF'
2984acfindx:
2985 @echo 'NARROW_PROTO="${PROTO_DEFINES}"'
2986EOF
2987 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
2988 eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
2989 fi
2990 cd ..
2991 rm -fr conftestdir
2992 fi
2993 if test -z "$NARROW_PROTO"; then
2994 AC_MSG_RESULT(no)
2995 else
2996 AC_MSG_RESULT($NARROW_PROTO)
2997 fi
2998 AC_SUBST(NARROW_PROTO)
2999fi
3000
3001dnl Look for XSMP support - but don't necessarily restrict it to X11 GUIs
3002dnl use the X11 include path
3003if test "$enable_xsmp" = "yes"; then
3004 cppflags_save=$CPPFLAGS
3005 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3006 AC_CHECK_HEADERS(X11/SM/SMlib.h)
3007 CPPFLAGS=$cppflags_save
3008fi
3009
3010
Bram Moolenaar98921892016-02-23 17:14:37 +01003011if 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 +00003012 dnl Check for X11/xpm.h and X11/Sunkeysym.h with the GUI include path
3013 cppflags_save=$CPPFLAGS
3014 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3015 AC_CHECK_HEADERS(X11/xpm.h X11/Sunkeysym.h)
3016
3017 dnl automatically disable XIM when XIMtext isn't in X11/Xlib.h
3018 if test ! "$enable_xim" = "no"; then
3019 AC_MSG_CHECKING(for XIMText in X11/Xlib.h)
3020 AC_EGREP_CPP(XIMText, [#include <X11/Xlib.h>],
3021 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +02003022 AC_MSG_RESULT(no; xim has been disabled); enable_xim="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00003023 fi
3024 CPPFLAGS=$cppflags_save
3025
3026 dnl automatically enable XIM when hangul input isn't enabled
3027 if test "$enable_xim" = "auto" -a "$enable_hangulinput" != "yes" \
3028 -a "x$GUITYPE" != "xNONE" ; then
3029 AC_MSG_RESULT(X GUI selected; xim has been enabled)
3030 enable_xim="yes"
3031 fi
3032fi
3033
3034if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
3035 cppflags_save=$CPPFLAGS
3036 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00003037dnl Xmu/Editres.h may exist but can only be used after including Intrinsic.h
3038 AC_MSG_CHECKING([for X11/Xmu/Editres.h])
3039 AC_TRY_COMPILE([
3040#include <X11/Intrinsic.h>
3041#include <X11/Xmu/Editres.h>],
3042 [int i; i = 0;],
3043 AC_MSG_RESULT(yes)
3044 AC_DEFINE(HAVE_X11_XMU_EDITRES_H),
3045 AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003046 CPPFLAGS=$cppflags_save
3047fi
3048
3049dnl Only use the Xm directory when compiling Motif, don't use it for Athena
3050if test -z "$SKIP_MOTIF"; then
3051 cppflags_save=$CPPFLAGS
3052 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003053 if test "$zOSUnix" = "yes"; then
3054 xmheader="Xm/Xm.h"
3055 else
3056 xmheader="Xm/Xm.h Xm/XpmP.h Xm/JoinSideT.h Xm/TraitP.h Xm/Manager.h
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02003057 Xm/UnhighlightT.h Xm/Notebook.h"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003058 fi
3059 AC_CHECK_HEADERS($xmheader)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003060
Bram Moolenaar77c19352012-06-13 19:19:41 +02003061 if test "x$ac_cv_header_Xm_XpmP_h" = "xyes"; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003062 dnl Solaris uses XpmAttributes_21, very annoying.
3063 AC_MSG_CHECKING([for XpmAttributes_21 in Xm/XpmP.h])
3064 AC_TRY_COMPILE([#include <Xm/XpmP.h>], [XpmAttributes_21 attr;],
3065 AC_MSG_RESULT(yes); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes_21),
3066 AC_MSG_RESULT(no); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
3067 )
3068 else
Bram Moolenaar57657d82006-04-21 22:12:41 +00003069 AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003070 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003071 CPPFLAGS=$cppflags_save
3072fi
3073
3074if test "x$GUITYPE" = "xNONE" -a "$enable_xim" = "yes"; then
3075 AC_MSG_RESULT(no GUI selected; xim has been disabled)
3076 enable_xim="no"
3077fi
3078if test "x$GUITYPE" = "xNONE" -a "$enable_fontset" = "yes"; then
3079 AC_MSG_RESULT(no GUI selected; fontset has been disabled)
3080 enable_fontset="no"
3081fi
Bram Moolenaar182c5be2010-06-25 05:37:59 +02003082if test "x$GUITYPE:$enable_fontset" = "xGTK:yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003083 AC_MSG_RESULT(GTK+ 2 GUI selected; fontset has been disabled)
3084 enable_fontset="no"
3085fi
3086
Bram Moolenaar071d4272004-06-13 20:20:40 +00003087if test -z "$SKIP_PHOTON"; then
3088 GUITYPE=PHOTONGUI
3089fi
3090
3091AC_SUBST(GUI_INC_LOC)
3092AC_SUBST(GUI_LIB_LOC)
3093AC_SUBST(GUITYPE)
3094AC_SUBST(GUI_X_LIBS)
3095
3096if test "$enable_workshop" = "yes" -a -n "$SKIP_MOTIF"; then
3097 AC_MSG_ERROR([cannot use workshop without Motif])
3098fi
3099
3100dnl defining FEAT_XIM and FEAT_XFONTSET is delayed, so that they can be disabled
3101if test "$enable_xim" = "yes"; then
3102 AC_DEFINE(FEAT_XIM)
3103fi
3104if test "$enable_fontset" = "yes"; then
3105 AC_DEFINE(FEAT_XFONTSET)
3106fi
3107
3108
3109dnl ---------------------------------------------------------------------------
3110dnl end of GUI-checking
3111dnl ---------------------------------------------------------------------------
3112
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003113AC_MSG_CHECKING([for /proc link to executable])
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003114if test -L "/proc/self/exe"; then
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003115 dnl Linux
3116 AC_MSG_RESULT([/proc/self/exe])
3117 AC_DEFINE(PROC_EXE_LINK, "/proc/self/exe")
3118elif test -L "/proc/self/path/a.out"; then
3119 dnl Solaris
3120 AC_MSG_RESULT([/proc/self/path/a.out])
3121 AC_DEFINE(PROC_EXE_LINK, "/proc/self/path/a.out")
3122elif test -L "/proc/curproc/file"; then
3123 dnl FreeBSD
3124 AC_MSG_RESULT([/proc/curproc/file])
3125 AC_DEFINE(PROC_EXE_LINK, "/proc/curproc/file")
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003126else
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003127 AC_MSG_RESULT(no)
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003128fi
3129
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003130dnl Check for Cygwin, which needs an extra source file if not using X11
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003131AC_MSG_CHECKING(for CYGWIN or MSYS environment)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003132case `uname` in
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003133 CYGWIN*|MSYS*) CYGWIN=yes; AC_MSG_RESULT(yes)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003134 AC_MSG_CHECKING(for CYGWIN clipboard support)
3135 if test "x$with_x" = "xno" ; then
3136 OS_EXTRA_SRC=winclip.c; OS_EXTRA_OBJ=objects/winclip.o
3137 AC_MSG_RESULT(yes)
3138 AC_DEFINE(FEAT_CYGWIN_WIN32_CLIPBOARD)
3139 else
3140 AC_MSG_RESULT(no - using X11)
3141 fi ;;
3142
3143 *) CYGWIN=no; AC_MSG_RESULT(no);;
3144esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00003145
3146dnl Only really enable hangul input when GUI and XFONTSET are available
3147if test "$enable_hangulinput" = "yes"; then
3148 if test "x$GUITYPE" = "xNONE"; then
3149 AC_MSG_RESULT(no GUI selected; hangul input has been disabled)
3150 enable_hangulinput=no
3151 else
3152 AC_DEFINE(FEAT_HANGULIN)
3153 HANGULIN_SRC=hangulin.c
3154 AC_SUBST(HANGULIN_SRC)
3155 HANGULIN_OBJ=objects/hangulin.o
3156 AC_SUBST(HANGULIN_OBJ)
3157 fi
3158fi
3159
3160dnl Checks for libraries and include files.
3161
Bram Moolenaar446cb832008-06-24 21:56:24 +00003162AC_CACHE_CHECK([whether toupper is broken], [vim_cv_toupper_broken],
3163 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003164 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003165#include "confdefs.h"
3166#include <ctype.h>
3167#if STDC_HEADERS
3168# include <stdlib.h>
3169# include <stddef.h>
3170#endif
3171main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003172 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003173 vim_cv_toupper_broken=yes
3174 ],[
3175 vim_cv_toupper_broken=no
3176 ],[
3177 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_toupper_broken')
3178 ])])
3179
3180if test "x$vim_cv_toupper_broken" = "xyes" ; then
3181 AC_DEFINE(BROKEN_TOUPPER)
3182fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003183
3184AC_MSG_CHECKING(whether __DATE__ and __TIME__ work)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003185AC_TRY_COMPILE([#include <stdio.h>], [printf("(" __DATE__ " " __TIME__ ")");],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003186 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DATE_TIME),
3187 AC_MSG_RESULT(no))
3188
Bram Moolenaar0c094b92009-05-14 20:20:33 +00003189AC_MSG_CHECKING(whether __attribute__((unused)) is allowed)
3190AC_TRY_COMPILE([#include <stdio.h>], [int x __attribute__((unused));],
3191 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ATTRIBUTE_UNUSED),
3192 AC_MSG_RESULT(no))
3193
Bram Moolenaar071d4272004-06-13 20:20:40 +00003194dnl Checks for header files.
3195AC_CHECK_HEADER(elf.h, HAS_ELF=1)
3196dnl AC_CHECK_HEADER(dwarf.h, SVR4=1)
3197if test "$HAS_ELF" = 1; then
3198 AC_CHECK_LIB(elf, main)
3199fi
3200
3201AC_HEADER_DIRENT
3202
Bram Moolenaar071d4272004-06-13 20:20:40 +00003203dnl If sys/wait.h is not found it might still exist but not be POSIX
3204dnl compliant. In that case we define HAVE_UNION_WAIT (for NeXT)
3205if test $ac_cv_header_sys_wait_h = no; then
3206 AC_MSG_CHECKING([for sys/wait.h that defines union wait])
3207 AC_TRY_COMPILE([#include <sys/wait.h>],
3208 [union wait xx, yy; xx = yy],
3209 AC_MSG_RESULT(yes)
3210 AC_DEFINE(HAVE_SYS_WAIT_H)
3211 AC_DEFINE(HAVE_UNION_WAIT),
3212 AC_MSG_RESULT(no))
3213fi
3214
Bram Moolenaar779a7752016-01-30 23:26:34 +01003215AC_CHECK_HEADERS(stdint.h stdlib.h string.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003216 sys/select.h sys/utsname.h termcap.h fcntl.h \
3217 sgtty.h sys/ioctl.h sys/time.h sys/types.h \
3218 termio.h iconv.h inttypes.h langinfo.h math.h \
3219 unistd.h stropts.h errno.h sys/resource.h \
3220 sys/systeminfo.h locale.h sys/stream.h termios.h \
3221 libc.h sys/statfs.h poll.h sys/poll.h pwd.h \
3222 utime.h sys/param.h libintl.h libgen.h \
3223 util/debug.h util/msg18n.h frame.h sys/acl.h \
3224 sys/access.h sys/sysinfo.h wchar.h wctype.h)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003225
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003226dnl sys/ptem.h depends on sys/stream.h on Solaris
3227AC_CHECK_HEADERS(sys/ptem.h, [], [],
3228[#if defined HAVE_SYS_STREAM_H
3229# include <sys/stream.h>
3230#endif])
3231
Bram Moolenaar32f31b12009-05-21 13:20:59 +00003232dnl sys/sysctl.h depends on sys/param.h on OpenBSD
3233AC_CHECK_HEADERS(sys/sysctl.h, [], [],
3234[#if defined HAVE_SYS_PARAM_H
3235# include <sys/param.h>
3236#endif])
3237
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003238
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003239dnl pthread_np.h may exist but can only be used after including pthread.h
3240AC_MSG_CHECKING([for pthread_np.h])
3241AC_TRY_COMPILE([
3242#include <pthread.h>
3243#include <pthread_np.h>],
3244 [int i; i = 0;],
3245 AC_MSG_RESULT(yes)
3246 AC_DEFINE(HAVE_PTHREAD_NP_H),
3247 AC_MSG_RESULT(no))
3248
Bram Moolenaare344bea2005-09-01 20:46:49 +00003249AC_CHECK_HEADERS(strings.h)
Bram Moolenaard0573012017-10-28 21:11:06 +02003250if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00003251 dnl The strings.h file on OS/X contains a warning and nothing useful.
3252 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3253else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003254
3255dnl Check if strings.h and string.h can both be included when defined.
3256AC_MSG_CHECKING([if strings.h can be included after string.h])
3257cppflags_save=$CPPFLAGS
3258CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3259AC_TRY_COMPILE([
3260#if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO)
3261# define _NO_PROTO /* like in os_unix.h, causes conflict for AIX (Winn) */
3262 /* but don't do it on AIX 5.1 (Uribarri) */
3263#endif
3264#ifdef HAVE_XM_XM_H
3265# include <Xm/Xm.h> /* This breaks it for HP-UX 11 (Squassabia) */
3266#endif
3267#ifdef HAVE_STRING_H
3268# include <string.h>
3269#endif
3270#if defined(HAVE_STRINGS_H)
3271# include <strings.h>
3272#endif
3273 ], [int i; i = 0;],
3274 AC_MSG_RESULT(yes),
3275 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3276 AC_MSG_RESULT(no))
3277CPPFLAGS=$cppflags_save
Bram Moolenaar9372a112005-12-06 19:59:18 +00003278fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003279
3280dnl Checks for typedefs, structures, and compiler characteristics.
3281AC_PROG_GCC_TRADITIONAL
3282AC_C_CONST
Bram Moolenaar76243bd2009-03-02 01:47:02 +00003283AC_C_VOLATILE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003284AC_TYPE_MODE_T
3285AC_TYPE_OFF_T
3286AC_TYPE_PID_T
3287AC_TYPE_SIZE_T
3288AC_TYPE_UID_T
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003289AC_TYPE_UINT32_T
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003290
Bram Moolenaar071d4272004-06-13 20:20:40 +00003291AC_HEADER_TIME
3292AC_CHECK_TYPE(ino_t, long)
3293AC_CHECK_TYPE(dev_t, unsigned)
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003294AC_C_BIGENDIAN(,,,)
Bram Moolenaar136f29a2016-02-27 20:14:15 +01003295AC_C_INLINE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003296
3297AC_MSG_CHECKING(for rlim_t)
3298if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
3299 AC_MSG_RESULT([(cached) $ac_cv_type_rlim_t])
3300else
3301 AC_EGREP_CPP(dnl
3302changequote(<<,>>)dnl
3303<<(^|[^a-zA-Z_0-9])rlim_t[^a-zA-Z_0-9]>>dnl
3304changequote([,]),
3305 [
3306#include <sys/types.h>
3307#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003308# include <stdlib.h>
3309# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003310#endif
3311#ifdef HAVE_SYS_RESOURCE_H
Bram Moolenaar446cb832008-06-24 21:56:24 +00003312# include <sys/resource.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003313#endif
3314 ], ac_cv_type_rlim_t=yes, ac_cv_type_rlim_t=no)
3315 AC_MSG_RESULT($ac_cv_type_rlim_t)
3316fi
3317if test $ac_cv_type_rlim_t = no; then
3318 cat >> confdefs.h <<\EOF
3319#define rlim_t unsigned long
3320EOF
3321fi
3322
3323AC_MSG_CHECKING(for stack_t)
3324if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then
3325 AC_MSG_RESULT([(cached) $ac_cv_type_stack_t])
3326else
3327 AC_EGREP_CPP(stack_t,
3328 [
3329#include <sys/types.h>
3330#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003331# include <stdlib.h>
3332# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003333#endif
3334#include <signal.h>
3335 ], ac_cv_type_stack_t=yes, ac_cv_type_stack_t=no)
3336 AC_MSG_RESULT($ac_cv_type_stack_t)
3337fi
3338if test $ac_cv_type_stack_t = no; then
3339 cat >> confdefs.h <<\EOF
3340#define stack_t struct sigaltstack
3341EOF
3342fi
3343
3344dnl BSDI uses ss_base while others use ss_sp for the stack pointer.
3345AC_MSG_CHECKING(whether stack_t has an ss_base field)
3346AC_TRY_COMPILE([
3347#include <sys/types.h>
3348#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003349# include <stdlib.h>
3350# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003351#endif
3352#include <signal.h>
3353#include "confdefs.h"
3354 ], [stack_t sigstk; sigstk.ss_base = 0; ],
3355 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SS_BASE),
3356 AC_MSG_RESULT(no))
3357
3358olibs="$LIBS"
3359AC_MSG_CHECKING(--with-tlib argument)
3360AC_ARG_WITH(tlib, [ --with-tlib=library terminal library to be used ],)
3361if test -n "$with_tlib"; then
3362 AC_MSG_RESULT($with_tlib)
3363 LIBS="$LIBS -l$with_tlib"
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003364 AC_MSG_CHECKING(for linking with $with_tlib library)
3365 AC_TRY_LINK([], [], AC_MSG_RESULT(OK), AC_MSG_ERROR(FAILED))
3366 dnl Need to check for tgetent() below.
3367 olibs="$LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003368else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003369 AC_MSG_RESULT([empty: automatic terminal library selection])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003370 dnl On HP-UX 10.10 termcap or termlib should be used instead of
3371 dnl curses, because curses is much slower.
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003372 dnl Newer versions of ncurses are preferred over anything, except
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02003373 dnl when tinfo has been split off, it contains all we need.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003374 dnl Older versions of ncurses have bugs, get a new one!
3375 dnl Digital Unix (OSF1) should use curses (Ronald Schild).
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00003376 dnl On SCO Openserver should prefer termlib (Roger Cornelius).
Bram Moolenaar071d4272004-06-13 20:20:40 +00003377 case "`uname -s 2>/dev/null`" in
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003378 OSF1|SCO_SV) tlibs="tinfo ncurses curses termlib termcap";;
3379 *) tlibs="tinfo ncurses termlib termcap curses";;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003380 esac
3381 for libname in $tlibs; do
3382 AC_CHECK_LIB(${libname}, tgetent,,)
3383 if test "x$olibs" != "x$LIBS"; then
3384 dnl It's possible that a library is found but it doesn't work
3385 dnl e.g., shared library that cannot be found
3386 dnl compile and run a test program to be sure
3387 AC_TRY_RUN([
3388#ifdef HAVE_TERMCAP_H
3389# include <termcap.h>
3390#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003391#if STDC_HEADERS
3392# include <stdlib.h>
3393# include <stddef.h>
3394#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003395main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }],
3396 res="OK", res="FAIL", res="FAIL")
3397 if test "$res" = "OK"; then
3398 break
3399 fi
3400 AC_MSG_RESULT($libname library is not usable)
3401 LIBS="$olibs"
3402 fi
3403 done
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003404 if test "x$olibs" = "x$LIBS"; then
3405 AC_MSG_RESULT(no terminal library found)
3406 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003407fi
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003408
3409if test "x$olibs" = "x$LIBS"; then
3410 AC_MSG_CHECKING([for tgetent()])
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00003411 AC_TRY_LINK([],
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003412 [char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");],
3413 AC_MSG_RESULT(yes),
3414 AC_MSG_ERROR([NOT FOUND!
3415 You need to install a terminal library; for example ncurses.
3416 Or specify the name of the library with --with-tlib.]))
3417fi
3418
Bram Moolenaar446cb832008-06-24 21:56:24 +00003419AC_CACHE_CHECK([whether we talk terminfo], [vim_cv_terminfo],
3420 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003421 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003422#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003423#ifdef HAVE_TERMCAP_H
3424# include <termcap.h>
3425#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003426#ifdef HAVE_STRING_H
3427# include <string.h>
3428#endif
3429#if STDC_HEADERS
3430# include <stdlib.h>
3431# include <stddef.h>
3432#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003433main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003434{char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003435 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003436 vim_cv_terminfo=no
3437 ],[
3438 vim_cv_terminfo=yes
3439 ],[
3440 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_terminfo')
3441 ])
3442 ])
3443
3444if test "x$vim_cv_terminfo" = "xyes" ; then
3445 AC_DEFINE(TERMINFO)
3446fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003447
Bram Moolenaara88254f2017-11-02 23:04:14 +01003448AC_CACHE_CHECK([what tgetent() returns for an unknown terminal], [vim_cv_tgetent],
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003449 [
3450 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003451#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003452#ifdef HAVE_TERMCAP_H
3453# include <termcap.h>
3454#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003455#if STDC_HEADERS
3456# include <stdlib.h>
3457# include <stddef.h>
3458#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003459main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003460{char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003461 ]])],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003462 vim_cv_tgetent=zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003463 ],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003464 vim_cv_tgetent=non-zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003465 ],[
3466 AC_MSG_ERROR(failed to compile test program.)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003467 ])
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003468 ])
3469
Bram Moolenaara88254f2017-11-02 23:04:14 +01003470if test "x$vim_cv_tgetent" = "xzero" ; then
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003471 AC_DEFINE(TGETENT_ZERO_ERR, 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003472fi
3473
3474AC_MSG_CHECKING(whether termcap.h contains ospeed)
3475AC_TRY_LINK([
3476#ifdef HAVE_TERMCAP_H
3477# include <termcap.h>
3478#endif
3479 ], [ospeed = 20000],
3480 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED),
3481 [AC_MSG_RESULT(no)
3482 AC_MSG_CHECKING(whether ospeed can be extern)
3483 AC_TRY_LINK([
3484#ifdef HAVE_TERMCAP_H
3485# include <termcap.h>
3486#endif
3487extern short ospeed;
3488 ], [ospeed = 20000],
3489 AC_MSG_RESULT(yes); AC_DEFINE(OSPEED_EXTERN),
3490 AC_MSG_RESULT(no))]
3491 )
3492
3493AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC])
3494AC_TRY_LINK([
3495#ifdef HAVE_TERMCAP_H
3496# include <termcap.h>
3497#endif
3498 ], [if (UP == 0 && BC == 0) PC = 1],
3499 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UP_BC_PC),
3500 [AC_MSG_RESULT(no)
3501 AC_MSG_CHECKING([whether UP, BC and PC can be extern])
3502 AC_TRY_LINK([
3503#ifdef HAVE_TERMCAP_H
3504# include <termcap.h>
3505#endif
3506extern char *UP, *BC, PC;
3507 ], [if (UP == 0 && BC == 0) PC = 1],
3508 AC_MSG_RESULT(yes); AC_DEFINE(UP_BC_PC_EXTERN),
3509 AC_MSG_RESULT(no))]
3510 )
3511
3512AC_MSG_CHECKING(whether tputs() uses outfuntype)
3513AC_TRY_COMPILE([
3514#ifdef HAVE_TERMCAP_H
3515# include <termcap.h>
3516#endif
3517 ], [extern int xx(); tputs("test", 1, (outfuntype)xx)],
3518 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OUTFUNTYPE),
3519 AC_MSG_RESULT(no))
3520
3521dnl On some SCO machines sys/select redefines struct timeval
3522AC_MSG_CHECKING([whether sys/select.h and sys/time.h may both be included])
3523AC_TRY_COMPILE([
3524#include <sys/types.h>
3525#include <sys/time.h>
3526#include <sys/select.h>], ,
3527 AC_MSG_RESULT(yes)
3528 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME),
3529 AC_MSG_RESULT(no))
3530
3531dnl AC_DECL_SYS_SIGLIST
3532
3533dnl Checks for pty.c (copied from screen) ==========================
3534AC_MSG_CHECKING(for /dev/ptc)
3535if test -r /dev/ptc; then
3536 AC_DEFINE(HAVE_DEV_PTC)
3537 AC_MSG_RESULT(yes)
3538else
3539 AC_MSG_RESULT(no)
3540fi
3541
3542AC_MSG_CHECKING(for SVR4 ptys)
3543if test -c /dev/ptmx ; then
3544 AC_TRY_LINK([], [ptsname(0);grantpt(0);unlockpt(0);],
3545 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SVR4_PTYS),
3546 AC_MSG_RESULT(no))
3547else
3548 AC_MSG_RESULT(no)
3549fi
3550
3551AC_MSG_CHECKING(for ptyranges)
3552if test -d /dev/ptym ; then
3553 pdir='/dev/ptym'
3554else
3555 pdir='/dev'
3556fi
3557dnl SCO uses ptyp%d
3558AC_EGREP_CPP(yes,
3559[#ifdef M_UNIX
3560 yes;
3561#endif
3562 ], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
3563dnl if test -c /dev/ptyp19; then
3564dnl ptys=`echo /dev/ptyp??`
3565dnl else
3566dnl ptys=`echo $pdir/pty??`
3567dnl fi
3568if test "$ptys" != "$pdir/pty??" ; then
3569 p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
3570 p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'`
3571 AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
3572 AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
3573 AC_MSG_RESULT([$p0 / $p1])
3574else
3575 AC_MSG_RESULT([don't know])
3576fi
3577
3578dnl **** pty mode/group handling ****
3579dnl
3580dnl support provided by Luke Mewburn <lm@rmit.edu.au>, 931222
Bram Moolenaar071d4272004-06-13 20:20:40 +00003581rm -f conftest_grp
Bram Moolenaar446cb832008-06-24 21:56:24 +00003582AC_CACHE_CHECK([default tty permissions/group], [vim_cv_tty_group],
3583 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003584 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003585#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003586#include <sys/types.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003587#if STDC_HEADERS
3588# include <stdlib.h>
3589# include <stddef.h>
3590#endif
3591#ifdef HAVE_UNISTD_H
3592#include <unistd.h>
3593#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003594#include <sys/stat.h>
3595#include <stdio.h>
3596main()
3597{
3598 struct stat sb;
3599 char *x,*ttyname();
3600 int om, m;
3601 FILE *fp;
3602
3603 if (!(x = ttyname(0))) exit(1);
3604 if (stat(x, &sb)) exit(1);
3605 om = sb.st_mode;
3606 if (om & 002) exit(0);
3607 m = system("mesg y");
3608 if (m == -1 || m == 127) exit(1);
3609 if (stat(x, &sb)) exit(1);
3610 m = sb.st_mode;
3611 if (chmod(x, om)) exit(1);
3612 if (m & 002) exit(0);
3613 if (sb.st_gid == getgid()) exit(1);
3614 if (!(fp=fopen("conftest_grp", "w")))
3615 exit(1);
3616 fprintf(fp, "%d\n", sb.st_gid);
3617 fclose(fp);
3618 exit(0);
3619}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003620 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003621 if test -f conftest_grp; then
3622 vim_cv_tty_group=`cat conftest_grp`
3623 if test "x$vim_cv_tty_mode" = "x" ; then
3624 vim_cv_tty_mode=0620
3625 fi
3626 AC_MSG_RESULT([pty mode: $vim_cv_tty_mode, group: $vim_cv_tty_group])
3627 else
3628 vim_cv_tty_group=world
Bram Moolenaar72951072009-12-02 16:58:33 +00003629 AC_MSG_RESULT([ptys are world accessible])
Bram Moolenaar446cb832008-06-24 21:56:24 +00003630 fi
3631 ],[
3632 vim_cv_tty_group=world
Bram Moolenaar72951072009-12-02 16:58:33 +00003633 AC_MSG_RESULT([can't determine - assume ptys are world accessible])
Bram Moolenaar446cb832008-06-24 21:56:24 +00003634 ],[
3635 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_tty_group' and 'vim_cv_tty_mode')
3636 ])
3637 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003638rm -f conftest_grp
3639
Bram Moolenaar446cb832008-06-24 21:56:24 +00003640if test "x$vim_cv_tty_group" != "xworld" ; then
3641 AC_DEFINE_UNQUOTED(PTYGROUP,$vim_cv_tty_group)
3642 if test "x$vim_cv_tty_mode" = "x" ; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02003643 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 +00003644 else
3645 AC_DEFINE(PTYMODE, 0620)
3646 fi
3647fi
3648
Bram Moolenaar071d4272004-06-13 20:20:40 +00003649dnl Checks for library functions. ===================================
3650
3651AC_TYPE_SIGNAL
3652
3653dnl find out what to use at the end of a signal function
3654if test $ac_cv_type_signal = void; then
3655 AC_DEFINE(SIGRETURN, [return])
3656else
3657 AC_DEFINE(SIGRETURN, [return 0])
3658fi
3659
3660dnl check if struct sigcontext is defined (used for SGI only)
3661AC_MSG_CHECKING(for struct sigcontext)
3662AC_TRY_COMPILE([
3663#include <signal.h>
3664test_sig()
3665{
3666 struct sigcontext *scont;
3667 scont = (struct sigcontext *)0;
3668 return 1;
3669} ], ,
3670 AC_MSG_RESULT(yes)
3671 AC_DEFINE(HAVE_SIGCONTEXT),
3672 AC_MSG_RESULT(no))
3673
3674dnl tricky stuff: try to find out if getcwd() is implemented with
3675dnl system("sh -c pwd")
Bram Moolenaar446cb832008-06-24 21:56:24 +00003676AC_CACHE_CHECK([getcwd implementation is broken], [vim_cv_getcwd_broken],
3677 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003678 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003679#include "confdefs.h"
3680#ifdef HAVE_UNISTD_H
3681#include <unistd.h>
3682#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003683char *dagger[] = { "IFS=pwd", 0 };
3684main()
3685{
3686 char buffer[500];
3687 extern char **environ;
3688 environ = dagger;
3689 return getcwd(buffer, 500) ? 0 : 1;
Bram Moolenaar446cb832008-06-24 21:56:24 +00003690}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003691 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003692 vim_cv_getcwd_broken=no
3693 ],[
3694 vim_cv_getcwd_broken=yes
3695 ],[
3696 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_getcwd_broken')
3697 ])
3698 ])
3699
3700if test "x$vim_cv_getcwd_broken" = "xyes" ; then
3701 AC_DEFINE(BAD_GETCWD)
3702fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003703
Bram Moolenaar25153e12010-02-24 14:47:08 +01003704dnl Check for functions in one big call, to reduce the size of configure.
3705dnl Can only be used for functions that do not require any include.
Bram Moolenaarcd142e32017-11-16 17:03:45 +01003706AC_CHECK_FUNCS(fchdir fchown fchmod fsync getcwd getpseudotty \
Bram Moolenaarb129a442016-12-01 17:25:20 +01003707 getpwent getpwnam getpwuid getrlimit gettimeofday getwd lstat \
Bram Moolenaareaf03392009-11-17 11:08:52 +00003708 memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
Bram Moolenaar2fcf6682017-03-11 20:03:42 +01003709 getpgid setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
Bram Moolenaarbb09ceb2016-10-18 16:27:23 +02003710 sigprocmask sigvec strcasecmp strerror strftime stricmp strncasecmp \
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00003711 strnicmp strpbrk strtol tgetent towlower towupper iswupper \
Bram Moolenaarcd142e32017-11-16 17:03:45 +01003712 usleep utime utimes mblen ftruncate)
Bram Moolenaar25153e12010-02-24 14:47:08 +01003713AC_FUNC_FSEEKO
Bram Moolenaar071d4272004-06-13 20:20:40 +00003714
Bram Moolenaar317fd3a2010-05-07 16:05:55 +02003715dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when
3716dnl appropriate, so that off_t is 64 bits when needed.
3717AC_SYS_LARGEFILE
3718
Bram Moolenaar071d4272004-06-13 20:20:40 +00003719dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible
3720AC_MSG_CHECKING(for st_blksize)
3721AC_TRY_COMPILE(
3722[#include <sys/types.h>
3723#include <sys/stat.h>],
3724[ struct stat st;
3725 int n;
3726
3727 stat("/", &st);
3728 n = (int)st.st_blksize;],
3729 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ST_BLKSIZE),
3730 AC_MSG_RESULT(no))
3731
Bram Moolenaar446cb832008-06-24 21:56:24 +00003732AC_CACHE_CHECK([whether stat() ignores a trailing slash], [vim_cv_stat_ignores_slash],
3733 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003734 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003735#include "confdefs.h"
3736#if STDC_HEADERS
3737# include <stdlib.h>
3738# include <stddef.h>
3739#endif
3740#include <sys/types.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003741#include <sys/stat.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003742main() {struct stat st; exit(stat("configure/", &st) != 0); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003743 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003744 vim_cv_stat_ignores_slash=yes
3745 ],[
3746 vim_cv_stat_ignores_slash=no
3747 ],[
3748 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_stat_ignores_slash')
3749 ])
3750 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003751
Bram Moolenaar446cb832008-06-24 21:56:24 +00003752if test "x$vim_cv_stat_ignores_slash" = "xyes" ; then
3753 AC_DEFINE(STAT_IGNORES_SLASH)
3754fi
3755
Bram Moolenaar071d4272004-06-13 20:20:40 +00003756dnl Link with iconv for charset translation, if not found without library.
3757dnl check for iconv() requires including iconv.h
3758dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
3759dnl has been installed.
3760AC_MSG_CHECKING(for iconv_open())
3761save_LIBS="$LIBS"
3762LIBS="$LIBS -liconv"
3763AC_TRY_LINK([
3764#ifdef HAVE_ICONV_H
3765# include <iconv.h>
3766#endif
3767 ], [iconv_open("fr", "to");],
3768 AC_MSG_RESULT(yes; with -liconv); AC_DEFINE(HAVE_ICONV),
3769 LIBS="$save_LIBS"
3770 AC_TRY_LINK([
3771#ifdef HAVE_ICONV_H
3772# include <iconv.h>
3773#endif
3774 ], [iconv_open("fr", "to");],
3775 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ICONV),
3776 AC_MSG_RESULT(no)))
3777
3778
3779AC_MSG_CHECKING(for nl_langinfo(CODESET))
3780AC_TRY_LINK([
3781#ifdef HAVE_LANGINFO_H
3782# include <langinfo.h>
3783#endif
3784], [char *cs = nl_langinfo(CODESET);],
3785 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET),
3786 AC_MSG_RESULT(no))
3787
Bram Moolenaar446cb832008-06-24 21:56:24 +00003788dnl Need various functions for floating point support. Only enable
3789dnl floating point when they are all present.
3790AC_CHECK_LIB(m, strtod)
3791AC_MSG_CHECKING([for strtod() and other floating point functions])
3792AC_TRY_LINK([
3793#ifdef HAVE_MATH_H
3794# include <math.h>
3795#endif
3796#if STDC_HEADERS
3797# include <stdlib.h>
3798# include <stddef.h>
3799#endif
3800], [char *s; double d;
3801 d = strtod("1.1", &s);
3802 d = fabs(1.11);
3803 d = ceil(1.11);
3804 d = floor(1.11);
3805 d = log10(1.11);
3806 d = pow(1.11, 2.22);
3807 d = sqrt(1.11);
3808 d = sin(1.11);
3809 d = cos(1.11);
3810 d = atan(1.11);
3811 ],
3812 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT_FUNCS),
3813 AC_MSG_RESULT(no))
3814
Bram Moolenaara6b89762016-02-29 21:38:26 +01003815dnl isinf() and isnan() need to include header files and may need -lm.
3816AC_MSG_CHECKING([for isinf()])
3817AC_TRY_LINK([
3818#ifdef HAVE_MATH_H
3819# include <math.h>
3820#endif
3821#if STDC_HEADERS
3822# include <stdlib.h>
3823# include <stddef.h>
3824#endif
3825], [int r = isinf(1.11); ],
3826 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISINF),
3827 AC_MSG_RESULT(no))
3828
3829AC_MSG_CHECKING([for isnan()])
3830AC_TRY_LINK([
3831#ifdef HAVE_MATH_H
3832# include <math.h>
3833#endif
3834#if STDC_HEADERS
3835# include <stdlib.h>
3836# include <stddef.h>
3837#endif
3838], [int r = isnan(1.11); ],
3839 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISNAN),
3840 AC_MSG_RESULT(no))
3841
Bram Moolenaar071d4272004-06-13 20:20:40 +00003842dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI
3843dnl when -lacl works, also try to use -lattr (required for Debian).
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003844dnl On Solaris, use the acl_get/set functions in libsec, if present.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003845AC_MSG_CHECKING(--disable-acl argument)
3846AC_ARG_ENABLE(acl,
Bram Moolenaard6d30422018-01-28 22:48:55 +01003847 [ --disable-acl No check for ACL support.],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003848 , [enable_acl="yes"])
3849if test "$enable_acl" = "yes"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01003850 AC_MSG_RESULT(no)
3851 AC_CHECK_LIB(posix1e, acl_get_file, [LIBS="$LIBS -lposix1e"],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003852 AC_CHECK_LIB(acl, acl_get_file, [LIBS="$LIBS -lacl"
3853 AC_CHECK_LIB(attr, fgetxattr, LIBS="$LIBS -lattr",,)],,),)
3854
Bram Moolenaard6d30422018-01-28 22:48:55 +01003855 AC_MSG_CHECKING(for POSIX ACL support)
3856 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003857#include <sys/types.h>
3858#ifdef HAVE_SYS_ACL_H
3859# include <sys/acl.h>
3860#endif
3861acl_t acl;], [acl = acl_get_file("foo", ACL_TYPE_ACCESS);
3862 acl_set_file("foo", ACL_TYPE_ACCESS, acl);
3863 acl_free(acl);],
3864 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_ACL),
3865 AC_MSG_RESULT(no))
3866
Bram Moolenaard6d30422018-01-28 22:48:55 +01003867 AC_CHECK_LIB(sec, acl_get, [LIBS="$LIBS -lsec"; AC_DEFINE(HAVE_SOLARIS_ZFS_ACL)],
3868 AC_MSG_CHECKING(for Solaris ACL support)
3869 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003870#ifdef HAVE_SYS_ACL_H
3871# include <sys/acl.h>
3872#endif], [acl("foo", GETACLCNT, 0, NULL);
3873 ],
3874 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOLARIS_ACL),
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003875 AC_MSG_RESULT(no)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003876
Bram Moolenaard6d30422018-01-28 22:48:55 +01003877 AC_MSG_CHECKING(for AIX ACL support)
3878 AC_TRY_LINK([
Bram Moolenaar446cb832008-06-24 21:56:24 +00003879#if STDC_HEADERS
3880# include <stdlib.h>
3881# include <stddef.h>
3882#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003883#ifdef HAVE_SYS_ACL_H
3884# include <sys/acl.h>
3885#endif
3886#ifdef HAVE_SYS_ACCESS_H
3887# include <sys/access.h>
3888#endif
3889#define _ALL_SOURCE
3890
3891#include <sys/stat.h>
3892
3893int aclsize;
3894struct acl *aclent;], [aclsize = sizeof(struct acl);
3895 aclent = (void *)malloc(aclsize);
3896 statacl("foo", STX_NORMAL, aclent, aclsize);
3897 ],
3898 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_AIX_ACL),
3899 AC_MSG_RESULT(no))
3900else
3901 AC_MSG_RESULT(yes)
3902fi
3903
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02003904if test "x$GTK_CFLAGS" != "x"; then
3905 dnl pango_shape_full() is new, fall back to pango_shape().
3906 AC_MSG_CHECKING(for pango_shape_full)
3907 ac_save_CFLAGS="$CFLAGS"
3908 ac_save_LIBS="$LIBS"
3909 CFLAGS="$CFLAGS $GTK_CFLAGS"
3910 LIBS="$LIBS $GTK_LIBS"
Bram Moolenaar5325b9b2015-09-09 20:27:02 +02003911 AC_TRY_LINK(
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02003912 [#include <gtk/gtk.h>],
3913 [ pango_shape_full(NULL, 0, NULL, 0, NULL, NULL); ],
3914 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_PANGO_SHAPE_FULL),
3915 AC_MSG_RESULT(no))
3916 CFLAGS="$ac_save_CFLAGS"
3917 LIBS="$ac_save_LIBS"
3918fi
3919
Bram Moolenaar071d4272004-06-13 20:20:40 +00003920AC_MSG_CHECKING(--disable-gpm argument)
3921AC_ARG_ENABLE(gpm,
3922 [ --disable-gpm Don't use gpm (Linux mouse daemon).], ,
3923 [enable_gpm="yes"])
3924
3925if test "$enable_gpm" = "yes"; then
3926 AC_MSG_RESULT(no)
3927 dnl Checking if gpm support can be compiled
3928 AC_CACHE_CHECK([for gpm], vi_cv_have_gpm,
3929 [olibs="$LIBS" ; LIBS="-lgpm"]
3930 AC_TRY_LINK(
3931 [#include <gpm.h>
3932 #include <linux/keyboard.h>],
3933 [Gpm_GetLibVersion(NULL);],
3934 dnl Configure defines HAVE_GPM, if it is defined feature.h defines
3935 dnl FEAT_MOUSE_GPM if mouse support is included
3936 [vi_cv_have_gpm=yes],
3937 [vi_cv_have_gpm=no])
3938 [LIBS="$olibs"]
3939 )
3940 if test $vi_cv_have_gpm = yes; then
3941 LIBS="$LIBS -lgpm"
3942 AC_DEFINE(HAVE_GPM)
3943 fi
3944else
3945 AC_MSG_RESULT(yes)
3946fi
3947
Bram Moolenaar446cb832008-06-24 21:56:24 +00003948AC_MSG_CHECKING(--disable-sysmouse argument)
3949AC_ARG_ENABLE(sysmouse,
Bram Moolenaar8008b632017-07-18 21:33:20 +02003950 [ --disable-sysmouse Don't use sysmouse (mouse in *BSD console).], ,
Bram Moolenaar446cb832008-06-24 21:56:24 +00003951 [enable_sysmouse="yes"])
3952
3953if test "$enable_sysmouse" = "yes"; then
3954 AC_MSG_RESULT(no)
3955 dnl Checking if sysmouse support can be compiled
3956 dnl Configure defines HAVE_SYSMOUSE, if it is defined feature.h
3957 dnl defines FEAT_SYSMOUSE if mouse support is included
3958 AC_CACHE_CHECK([for sysmouse], vi_cv_have_sysmouse,
3959 AC_TRY_LINK(
3960 [#include <sys/consio.h>
3961 #include <signal.h>
3962 #include <sys/fbio.h>],
3963 [struct mouse_info mouse;
3964 mouse.operation = MOUSE_MODE;
3965 mouse.operation = MOUSE_SHOW;
3966 mouse.u.mode.mode = 0;
3967 mouse.u.mode.signal = SIGUSR2;],
3968 [vi_cv_have_sysmouse=yes],
3969 [vi_cv_have_sysmouse=no])
3970 )
3971 if test $vi_cv_have_sysmouse = yes; then
3972 AC_DEFINE(HAVE_SYSMOUSE)
3973 fi
3974else
3975 AC_MSG_RESULT(yes)
3976fi
3977
Bram Moolenaarf05da212009-11-17 16:13:15 +00003978dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
3979AC_MSG_CHECKING(for FD_CLOEXEC)
3980AC_TRY_COMPILE(
3981[#if HAVE_FCNTL_H
3982# include <fcntl.h>
3983#endif],
3984[ int flag = FD_CLOEXEC;],
3985 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
3986 AC_MSG_RESULT(not usable))
3987
Bram Moolenaar071d4272004-06-13 20:20:40 +00003988dnl rename needs to be checked separately to work on Nextstep with cc
3989AC_MSG_CHECKING(for rename)
3990AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
3991 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
3992 AC_MSG_RESULT(no))
3993
3994dnl sysctl() may exist but not the arguments we use
3995AC_MSG_CHECKING(for sysctl)
3996AC_TRY_COMPILE(
3997[#include <sys/types.h>
3998#include <sys/sysctl.h>],
3999[ int mib[2], r;
4000 size_t len;
4001
4002 mib[0] = CTL_HW;
4003 mib[1] = HW_USERMEM;
4004 len = sizeof(r);
4005 (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
4006 ],
4007 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL),
4008 AC_MSG_RESULT(not usable))
4009
4010dnl sysinfo() may exist but not be Linux compatible
4011AC_MSG_CHECKING(for sysinfo)
4012AC_TRY_COMPILE(
4013[#include <sys/types.h>
4014#include <sys/sysinfo.h>],
4015[ struct sysinfo sinfo;
4016 int t;
4017
4018 (void)sysinfo(&sinfo);
4019 t = sinfo.totalram;
4020 ],
4021 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
4022 AC_MSG_RESULT(not usable))
4023
Bram Moolenaar914572a2007-05-01 11:37:47 +00004024dnl struct sysinfo may have the mem_unit field or not
4025AC_MSG_CHECKING(for sysinfo.mem_unit)
4026AC_TRY_COMPILE(
4027[#include <sys/types.h>
4028#include <sys/sysinfo.h>],
4029[ struct sysinfo sinfo;
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02004030 sinfo.mem_unit = 1;
Bram Moolenaar914572a2007-05-01 11:37:47 +00004031 ],
4032 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_MEM_UNIT),
4033 AC_MSG_RESULT(no))
4034
Bram Moolenaar071d4272004-06-13 20:20:40 +00004035dnl sysconf() may exist but not support what we want to use
4036AC_MSG_CHECKING(for sysconf)
4037AC_TRY_COMPILE(
4038[#include <unistd.h>],
4039[ (void)sysconf(_SC_PAGESIZE);
4040 (void)sysconf(_SC_PHYS_PAGES);
4041 ],
4042 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
4043 AC_MSG_RESULT(not usable))
4044
Bram Moolenaar914703b2010-05-31 21:59:46 +02004045AC_CHECK_SIZEOF([int])
4046AC_CHECK_SIZEOF([long])
4047AC_CHECK_SIZEOF([time_t])
4048AC_CHECK_SIZEOF([off_t])
Bram Moolenaar644fdff2010-05-30 13:26:21 +02004049
Bram Moolenaara2aa31a2014-02-23 22:52:40 +01004050dnl Use different names to avoid clashing with other header files.
4051AC_DEFINE_UNQUOTED(VIM_SIZEOF_INT, [$ac_cv_sizeof_int])
4052AC_DEFINE_UNQUOTED(VIM_SIZEOF_LONG, [$ac_cv_sizeof_long])
4053
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004054dnl Make sure that uint32_t is really 32 bits unsigned.
4055AC_MSG_CHECKING([uint32_t is 32 bits])
4056AC_TRY_RUN([
4057#ifdef HAVE_STDINT_H
4058# include <stdint.h>
4059#endif
4060#ifdef HAVE_INTTYPES_H
4061# include <inttypes.h>
4062#endif
4063main() {
4064 uint32_t nr1 = (uint32_t)-1;
4065 uint32_t nr2 = (uint32_t)0xffffffffUL;
4066 if (sizeof(uint32_t) != 4 || nr1 != 0xffffffffUL || nr2 + 1 != 0) exit(1);
4067 exit(0);
4068}],
4069AC_MSG_RESULT(ok),
4070AC_MSG_ERROR([WRONG! uint32_t not defined correctly.]),
Bram Moolenaar323cb952011-12-14 19:22:34 +01004071AC_MSG_WARN([cannot check uint32_t when cross-compiling.]))
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004072
Bram Moolenaar446cb832008-06-24 21:56:24 +00004073dnl Check for memmove() before bcopy(), makes memmove() be used when both are
4074dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
4075
Bram Moolenaar071d4272004-06-13 20:20:40 +00004076[bcopy_test_prog='
Bram Moolenaar446cb832008-06-24 21:56:24 +00004077#include "confdefs.h"
4078#ifdef HAVE_STRING_H
4079# include <string.h>
4080#endif
4081#if STDC_HEADERS
4082# include <stdlib.h>
4083# include <stddef.h>
4084#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004085main() {
4086 char buf[10];
4087 strcpy(buf, "abcdefghi");
4088 mch_memmove(buf, buf + 2, 3);
4089 if (strncmp(buf, "ababcf", 6))
4090 exit(1);
4091 strcpy(buf, "abcdefghi");
4092 mch_memmove(buf + 2, buf, 3);
4093 if (strncmp(buf, "cdedef", 6))
4094 exit(1);
4095 exit(0); /* libc version works properly. */
4096}']
4097
Bram Moolenaar446cb832008-06-24 21:56:24 +00004098AC_CACHE_CHECK([whether memmove handles overlaps],[vim_cv_memmove_handles_overlap],
4099 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004100 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 +00004101 [
4102 vim_cv_memmove_handles_overlap=yes
4103 ],[
4104 vim_cv_memmove_handles_overlap=no
4105 ],[
4106 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memmove_handles_overlap')
4107 ])
4108 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00004109
Bram Moolenaar446cb832008-06-24 21:56:24 +00004110if test "x$vim_cv_memmove_handles_overlap" = "xyes" ; then
4111 AC_DEFINE(USEMEMMOVE)
4112else
4113 AC_CACHE_CHECK([whether bcopy handles overlaps],[vim_cv_bcopy_handles_overlap],
4114 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004115 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 +00004116 [
4117 vim_cv_bcopy_handles_overlap=yes
4118 ],[
4119 vim_cv_bcopy_handles_overlap=no
4120 ],[
4121 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_bcopy_handles_overlap')
4122 ])
4123 ])
4124
4125 if test "x$vim_cv_bcopy_handles_overlap" = "xyes" ; then
4126 AC_DEFINE(USEBCOPY)
4127 else
4128 AC_CACHE_CHECK([whether memcpy handles overlaps],[vim_cv_memcpy_handles_overlap],
4129 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004130 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 +00004131 [
4132 vim_cv_memcpy_handles_overlap=yes
4133 ],[
4134 vim_cv_memcpy_handles_overlap=no
4135 ],[
4136 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memcpy_handles_overlap')
4137 ])
4138 ])
4139
4140 if test "x$vim_cv_memcpy_handles_overlap" = "xyes" ; then
4141 AC_DEFINE(USEMEMCPY)
4142 fi
4143 fi
4144fi
4145
Bram Moolenaar071d4272004-06-13 20:20:40 +00004146
4147dnl Check for multibyte locale functions
4148dnl Find out if _Xsetlocale() is supported by libX11.
4149dnl Check if X_LOCALE should be defined.
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004150if test "x$with_x" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004151 cflags_save=$CFLAGS
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004152 libs_save=$LIBS
4153 LIBS="$LIBS $X_LIBS $GUI_LIB_LOC $GUI_X_LIBS $X_PRE_LIBS $X_LIB $X_EXTRA_LIBS"
4154 CFLAGS="$CFLAGS $X_CFLAGS"
4155
4156 AC_MSG_CHECKING(whether X_LOCALE needed)
4157 AC_TRY_COMPILE([#include <X11/Xlocale.h>],,
4158 AC_TRY_LINK_FUNC([_Xsetlocale], [AC_MSG_RESULT(yes)
4159 AC_DEFINE(X_LOCALE)], AC_MSG_RESULT(no)),
4160 AC_MSG_RESULT(no))
4161
4162 AC_MSG_CHECKING(whether Xutf8SetWMProperties() can be used)
4163 AC_TRY_LINK_FUNC([Xutf8SetWMProperties], [AC_MSG_RESULT(yes)
4164 AC_DEFINE(HAVE_XUTF8SETWMPROPERTIES)], AC_MSG_RESULT(no))
4165
Bram Moolenaar071d4272004-06-13 20:20:40 +00004166 CFLAGS=$cflags_save
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004167 LIBS=$libs_save
Bram Moolenaar071d4272004-06-13 20:20:40 +00004168fi
4169
4170dnl Link with xpg4, it is said to make Korean locale working
4171AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,)
4172
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004173dnl Check how we can run ctags. Default to "ctags" when nothing works.
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02004174dnl Use --version to detect Exuberant ctags (preferred)
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004175dnl Add --fields=+S to get function signatures for omni completion.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004176dnl -t for typedefs (many ctags have this)
4177dnl -s for static functions (Elvis ctags only?)
4178dnl -v for variables. Dangerous, most ctags take this for 'vgrind style'.
4179dnl -i+m to test for older Exuberant ctags
4180AC_MSG_CHECKING(how to create tags)
4181test -f tags && mv tags tags.save
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004182if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004183 TAGPRG="ctags -I INIT+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004184elif (eval exctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
4185 TAGPRG="exctags -I INIT+ --fields=+S"
4186elif (eval exuberant-ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
4187 TAGPRG="exuberant-ctags -I INIT+ --fields=+S"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004188else
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004189 TAGPRG="ctags"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004190 (eval etags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags"
4191 (eval etags -c /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags -c"
4192 (eval ctags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags"
4193 (eval ctags -t /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -t"
4194 (eval ctags -ts /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -ts"
4195 (eval ctags -tvs /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -tvs"
4196 (eval ctags -i+m /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -i+m"
4197fi
4198test -f tags.save && mv tags.save tags
4199AC_MSG_RESULT($TAGPRG) AC_SUBST(TAGPRG)
4200
4201dnl Check how we can run man with a section number
4202AC_MSG_CHECKING(how to run man with a section nr)
4203MANDEF="man"
Bram Moolenaar8b131502008-02-13 09:28:19 +00004204(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 +00004205AC_MSG_RESULT($MANDEF)
4206if test "$MANDEF" = "man -s"; then
4207 AC_DEFINE(USEMAN_S)
4208fi
4209
4210dnl Check if gettext() is working and if it needs -lintl
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004211dnl We take care to base this on an empty LIBS: on some systems libelf would be
4212dnl in LIBS and implicitly take along libintl. The final LIBS would then not
4213dnl contain libintl, and the link step would fail due to -Wl,--as-needed.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004214AC_MSG_CHECKING(--disable-nls argument)
4215AC_ARG_ENABLE(nls,
4216 [ --disable-nls Don't support NLS (gettext()).], ,
4217 [enable_nls="yes"])
4218
4219if test "$enable_nls" = "yes"; then
4220 AC_MSG_RESULT(no)
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00004221
4222 INSTALL_LANGS=install-languages
4223 AC_SUBST(INSTALL_LANGS)
4224 INSTALL_TOOL_LANGS=install-tool-languages
4225 AC_SUBST(INSTALL_TOOL_LANGS)
4226
Bram Moolenaar071d4272004-06-13 20:20:40 +00004227 AC_CHECK_PROG(MSGFMT, msgfmt, msgfmt, )
4228 AC_MSG_CHECKING([for NLS])
4229 if test -f po/Makefile; then
4230 have_gettext="no"
4231 if test -n "$MSGFMT"; then
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004232 olibs=$LIBS
4233 LIBS=""
Bram Moolenaar071d4272004-06-13 20:20:40 +00004234 AC_TRY_LINK(
4235 [#include <libintl.h>],
4236 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004237 AC_MSG_RESULT([gettext() works]); have_gettext="yes"; LIBS=$olibs,
4238 LIBS="-lintl"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004239 AC_TRY_LINK(
4240 [#include <libintl.h>],
4241 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004242 AC_MSG_RESULT([gettext() works with -lintl]); have_gettext="yes";
4243 LIBS="$olibs -lintl",
Bram Moolenaar071d4272004-06-13 20:20:40 +00004244 AC_MSG_RESULT([gettext() doesn't work]);
4245 LIBS=$olibs))
4246 else
4247 AC_MSG_RESULT([msgfmt not found - disabled]);
4248 fi
Bram Moolenaar278eb582014-07-30 13:22:52 +02004249 if test $have_gettext = "yes" -a "x$features" != "xtiny" -a "x$features" != "xsmall"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004250 AC_DEFINE(HAVE_GETTEXT)
4251 MAKEMO=yes
4252 AC_SUBST(MAKEMO)
4253 dnl this was added in GNU gettext 0.10.36
4254 AC_CHECK_FUNCS(bind_textdomain_codeset)
4255 dnl _nl_msg_cat_cntr is required for GNU gettext
4256 AC_MSG_CHECKING([for _nl_msg_cat_cntr])
4257 AC_TRY_LINK(
4258 [#include <libintl.h>
4259 extern int _nl_msg_cat_cntr;],
4260 [++_nl_msg_cat_cntr;],
4261 AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_NL_MSG_CAT_CNTR),
4262 AC_MSG_RESULT([no]))
4263 fi
4264 else
4265 AC_MSG_RESULT([no "po/Makefile" - disabled]);
4266 fi
4267else
4268 AC_MSG_RESULT(yes)
4269fi
4270
4271dnl Check for dynamic linking loader
4272AC_CHECK_HEADER(dlfcn.h, DLL=dlfcn.h, [AC_CHECK_HEADER(dl.h, DLL=dl.h)])
4273if test x${DLL} = xdlfcn.h; then
4274 AC_DEFINE(HAVE_DLFCN_H, 1, [ Define if we have dlfcn.h. ])
4275 AC_MSG_CHECKING([for dlopen()])
4276 AC_TRY_LINK(,[
4277 extern void* dlopen();
4278 dlopen();
4279 ],
4280 AC_MSG_RESULT(yes);
4281 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4282 AC_MSG_RESULT(no);
4283 AC_MSG_CHECKING([for dlopen() in -ldl])
4284 olibs=$LIBS
4285 LIBS="$LIBS -ldl"
4286 AC_TRY_LINK(,[
4287 extern void* dlopen();
4288 dlopen();
4289 ],
4290 AC_MSG_RESULT(yes);
4291 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4292 AC_MSG_RESULT(no);
4293 LIBS=$olibs))
4294 dnl ReliantUNIX has dlopen() in libc but everything else in libdl
4295 dnl ick :-)
4296 AC_MSG_CHECKING([for dlsym()])
4297 AC_TRY_LINK(,[
4298 extern void* dlsym();
4299 dlsym();
4300 ],
4301 AC_MSG_RESULT(yes);
4302 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4303 AC_MSG_RESULT(no);
4304 AC_MSG_CHECKING([for dlsym() in -ldl])
4305 olibs=$LIBS
4306 LIBS="$LIBS -ldl"
4307 AC_TRY_LINK(,[
4308 extern void* dlsym();
4309 dlsym();
4310 ],
4311 AC_MSG_RESULT(yes);
4312 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4313 AC_MSG_RESULT(no);
4314 LIBS=$olibs))
4315elif test x${DLL} = xdl.h; then
4316 AC_DEFINE(HAVE_DL_H, 1, [ Define if we have dl.h. ])
4317 AC_MSG_CHECKING([for shl_load()])
4318 AC_TRY_LINK(,[
4319 extern void* shl_load();
4320 shl_load();
4321 ],
4322 AC_MSG_RESULT(yes);
4323 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4324 AC_MSG_RESULT(no);
4325 AC_MSG_CHECKING([for shl_load() in -ldld])
4326 olibs=$LIBS
4327 LIBS="$LIBS -ldld"
4328 AC_TRY_LINK(,[
4329 extern void* shl_load();
4330 shl_load();
4331 ],
4332 AC_MSG_RESULT(yes);
4333 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4334 AC_MSG_RESULT(no);
4335 LIBS=$olibs))
4336fi
4337AC_CHECK_HEADERS(setjmp.h)
4338
Bram Moolenaard0573012017-10-28 21:11:06 +02004339if test "x$MACOS_X" = "xyes" -a -n "$PERL"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004340 dnl -ldl must come after DynaLoader.a
4341 if echo $LIBS | grep -e '-ldl' >/dev/null; then
4342 LIBS=`echo $LIBS | sed s/-ldl//`
4343 PERL_LIBS="$PERL_LIBS -ldl"
4344 fi
4345fi
4346
Bram Moolenaard0573012017-10-28 21:11:06 +02004347if test "$MACOS_X" = "yes"; then
4348 AC_MSG_CHECKING([whether we need macOS frameworks])
4349 if test "$GUITYPE" = "CARBONGUI"; then
4350 AC_MSG_RESULT([yes, we need Carbon])
4351 LIBS="$LIBS -framework Carbon"
4352 elif test "$MACOS_X_DARWIN" = "yes"; then
4353 if test "$features" = "tiny"; then
4354 dnl Since no FEAT_CLIPBOARD, no longer need for os_macosx.m.
4355 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_macosx.m++'`
4356 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_macosx.o++'`
4357 if test "$enable_multibyte" = "yes"; then
4358 AC_MSG_RESULT([yes, we need CoreServices])
4359 LIBS="$LIBS -framework CoreServices"
4360 else
4361 dnl Since no FEAT_MBYTE, no longer need for os_mac_conv.c.
4362 AC_MSG_RESULT([no])
4363 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_mac_conv.c++'`
4364 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_mac_conv.o++'`
4365 CPPFLAGS=`echo "$CPPFLAGS" | sed -e 's+-DMACOS_X_DARWIN++'`
4366 fi
4367 else
4368 AC_MSG_RESULT([yes, we need AppKit])
4369 LIBS="$LIBS -framework AppKit"
4370 if test "$features" = "small" -a "$enable_multibyte" = "no"; then
4371 dnl Since FEAT_CLIPBOARD is to be defined in vim.h for FEAT_SMALL, define
4372 dnl FEAT_MBYTE in order not to compromise the interoperability of the
4373 dnl clipboard.
4374 AC_MSG_NOTICE([+multi_byte will be set in favor of +clipboard])
4375 enable_multibyte=yes
4376 AC_DEFINE(FEAT_MBYTE)
4377 fi
4378 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004379 else
Bram Moolenaard0573012017-10-28 21:11:06 +02004380 AC_MSG_RESULT([no])
Bram Moolenaar3437b912013-07-03 19:52:53 +02004381 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004382fi
Bram Moolenaar164fca32010-07-14 13:58:07 +02004383if test "x$MACARCH" = "xboth" && test "x$GUITYPE" = "xCARBONGUI"; then
Bram Moolenaar595a7be2010-03-10 16:28:12 +01004384 LDFLAGS="$LDFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +00004385fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004386
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004387dnl gcc 3.1 changed the meaning of -MM. The only solution appears to be to
4388dnl use "-isystem" instead of "-I" for all non-Vim include dirs.
4389dnl But only when making dependencies, cproto and lint don't take "-isystem".
Bram Moolenaar32466aa2006-02-24 23:53:04 +00004390dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
4391dnl the number before the version number.
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004392DEPEND_CFLAGS_FILTER=
4393if test "$GCC" = yes; then
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004394 AC_MSG_CHECKING(for GCC 3 or later)
Bram Moolenaar2217cae2006-03-25 21:55:52 +00004395 gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]]\)\..*$/\1/g'`
Bram Moolenaarf740b292006-02-16 22:11:02 +00004396 if test "$gccmajor" -gt "2"; then
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004397 DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004398 AC_MSG_RESULT(yes)
4399 else
4400 AC_MSG_RESULT(no)
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004401 fi
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004402 dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
4403 dnl declared as char x[1] but actually longer. Introduced in gcc 4.0.
Bram Moolenaar56d1db32009-12-16 16:14:51 +00004404 dnl Also remove duplicate _FORTIFY_SOURCE arguments.
Bram Moolenaaraeabe052011-12-08 15:17:34 +01004405 dnl And undefine it first to avoid a warning.
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004406 AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
4407 if test "$gccmajor" -gt "3"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02004408 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 +00004409 AC_MSG_RESULT(yes)
4410 else
4411 AC_MSG_RESULT(no)
4412 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +00004413fi
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004414AC_SUBST(DEPEND_CFLAGS_FILTER)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004415
Bram Moolenaarec0557f2018-01-31 14:41:37 +01004416dnl On some systems AC_SYS_LARGEFILE determines that -D_FILE_OFFSET_BITS=64
4417dnl isn't required, but the CFLAGS for some of the libraries we're using
4418dnl include the define. Since the define changes the size of some datatypes
4419dnl (e.g. ino_t and off_t), all of Vim's modules must be compiled with a
4420dnl consistent value. It's therefore safest to force the use of the define
4421dnl if it's present in any of the *_CFLAGS variables.
4422AC_MSG_CHECKING(whether we need to force -D_FILE_OFFSET_BITS=64)
Bram Moolenaar9ce42132018-04-11 22:19:36 +02004423if 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 +01004424 AC_MSG_RESULT(yes)
4425 AC_DEFINE(_FILE_OFFSET_BITS, 64)
4426else
4427 AC_MSG_RESULT(no)
4428fi
4429
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004430dnl link.sh tries to avoid overlinking in a hackish way.
4431dnl At least GNU ld supports --as-needed which provides the same functionality
4432dnl at linker level. Let's use it.
4433AC_MSG_CHECKING(linker --as-needed support)
4434LINK_AS_NEEDED=
4435# Check if linker supports --as-needed and --no-as-needed options
4436if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02004437 LDFLAGS=`echo "$LDFLAGS" | sed -e 's/ *-Wl,--as-needed//g' | sed -e 's/$/ -Wl,--as-needed/'`
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004438 LINK_AS_NEEDED=yes
4439fi
4440if test "$LINK_AS_NEEDED" = yes; then
4441 AC_MSG_RESULT(yes)
4442else
4443 AC_MSG_RESULT(no)
4444fi
4445AC_SUBST(LINK_AS_NEEDED)
4446
Bram Moolenaar77c19352012-06-13 19:19:41 +02004447# IBM z/OS reset CFLAGS for config.mk
4448if test "$zOSUnix" = "yes"; then
4449 CFLAGS="-D_ALL_SOURCE -Wc,float\(ieee\),dll"
4450fi
4451
Bram Moolenaar071d4272004-06-13 20:20:40 +00004452dnl write output files
4453AC_OUTPUT(auto/config.mk:config.mk.in)
4454
4455dnl vim: set sw=2 tw=78 fo+=l: