blob: 2185c9e889a8096d8c0c6794ac18c659a0686a4a [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 Moolenaarc0394412017-04-20 20:20:23 +020014AC_PROG_CC dnl required by almost everything
15AC_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 Moolenaarf788a062011-12-14 20:51:25 +010032dnl Check for the flag that fails if stuff are missing.
33
34AC_MSG_CHECKING(--enable-fail-if-missing argument)
35AC_ARG_ENABLE(fail_if_missing,
36 [ --enable-fail-if-missing Fail if dependencies on additional features
37 specified on the command line are missing.],
38 [fail_if_missing="yes"],
39 [fail_if_missing="no"])
40AC_MSG_RESULT($fail_if_missing)
41
Bram Moolenaar071d4272004-06-13 20:20:40 +000042dnl Set default value for CFLAGS if none is defined or it's empty
43if test -z "$CFLAGS"; then
44 CFLAGS="-O"
45 test "$GCC" = yes && CFLAGS="-O2 -fno-strength-reduce -Wall"
46fi
47if test "$GCC" = yes; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +000048 dnl method that should work for nearly all versions
Bram Moolenaarc8836f72014-04-12 13:12:24 +020049 gccversion=`$CC -dumpversion`
Bram Moolenaar910f66f2006-04-05 20:41:53 +000050 if test "x$gccversion" = "x"; then
51 dnl old method; fall-back for when -dumpversion doesn't work
Bram Moolenaarc8836f72014-04-12 13:12:24 +020052 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 +000053 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +000054 dnl version 4.0.1 was reported to cause trouble on Macintosh by Marcin Dalecki
55 if test "$gccversion" = "3.0.1" -o "$gccversion" = "3.0.2" -o "$gccversion" = "4.0.1"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +000056 echo 'GCC [[34]].0.[[12]] has a bug in the optimizer, disabling "-O#"'
Bram Moolenaar071d4272004-06-13 20:20:40 +000057 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-O/'`
58 else
59 if test "$gccversion" = "3.1" -o "$gccversion" = "3.2" -o "$gccversion" = "3.2.1" && `echo "$CFLAGS" | grep -v fno-strength-reduce >/dev/null`; then
60 echo 'GCC 3.1 and 3.2 have a bug in the optimizer, adding "-fno-strength-reduce"'
61 CFLAGS="$CFLAGS -fno-strength-reduce"
62 fi
63 fi
64fi
65
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +020066dnl clang-500.2.75 or around has abandoned -f[no-]strength-reduce and issues a
67dnl warning when that flag is passed to. Accordingly, adjust CFLAGS based on
68dnl the version number of the clang in use.
69dnl Note that this does not work to get the version of clang 3.1 or 3.2.
Bram Moolenaar5f69fee2017-03-09 11:58:40 +010070AC_MSG_CHECKING(for clang version)
71CLANG_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 +020072if test x"$CLANG_VERSION_STRING" != x"" ; then
73 CLANG_MAJOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*/\1/p'`
74 CLANG_MINOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/p'`
75 CLANG_REVISION=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)/\1/p'`
76 CLANG_VERSION=`expr $CLANG_MAJOR '*' 1000000 '+' $CLANG_MINOR '*' 1000 '+' $CLANG_REVISION`
77 AC_MSG_RESULT($CLANG_VERSION)
78 dnl If you find the same issue with versions earlier than 500.2.75,
79 dnl change the constant 500002075 below appropriately. To get the
80 dnl integer corresponding to a version number, refer to the
81 dnl definition of CLANG_VERSION above.
Bram Moolenaar5f69fee2017-03-09 11:58:40 +010082 AC_MSG_CHECKING(if clang supports -fno-strength-reduce)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +020083 if test "$CLANG_VERSION" -ge 500002075 ; then
Bram Moolenaar5f69fee2017-03-09 11:58:40 +010084 AC_MSG_RESULT(no)
85 CFLAGS=`echo "$CFLAGS" | sed -e 's/-fno-strength-reduce/ /'`
86 else
87 AC_MSG_RESULT(yes)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +020088 fi
89else
Bram Moolenaar5f69fee2017-03-09 11:58:40 +010090 AC_MSG_RESULT(N/A)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +020091fi
92
Bram Moolenaar446cb832008-06-24 21:56:24 +000093dnl If configure thinks we are cross compiling, there might be something
94dnl wrong with the CC or CFLAGS settings, give a useful warning message
Bram Moolenaar839e9542016-04-14 16:46:02 +020095CROSS_COMPILING=
Bram Moolenaar071d4272004-06-13 20:20:40 +000096if test "$cross_compiling" = yes; then
Bram Moolenaar446cb832008-06-24 21:56:24 +000097 AC_MSG_RESULT([cannot compile a simple program; if not cross compiling check CC and CFLAGS])
Bram Moolenaar839e9542016-04-14 16:46:02 +020098 CROSS_COMPILING=1
Bram Moolenaar071d4272004-06-13 20:20:40 +000099fi
Bram Moolenaar839e9542016-04-14 16:46:02 +0200100AC_SUBST(CROSS_COMPILING)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000101
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +0000102dnl gcc-cpp has the wonderful -MM option to produce nicer dependencies.
103dnl But gcc 3.1 changed the meaning! See near the end.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000104test "$GCC" = yes && CPP_MM=M; AC_SUBST(CPP_MM)
105
106if test -f ./toolcheck; then
107 AC_CHECKING(for buggy tools)
108 sh ./toolcheck 1>&AC_FD_MSG
109fi
110
111OS_EXTRA_SRC=""; OS_EXTRA_OBJ=""
112
113dnl Check for BeOS, which needs an extra source file
114AC_MSG_CHECKING(for BeOS)
115case `uname` in
116 BeOS) OS_EXTRA_SRC=os_beos.c; OS_EXTRA_OBJ=objects/os_beos.o
117 BEOS=yes; AC_MSG_RESULT(yes);;
118 *) BEOS=no; AC_MSG_RESULT(no);;
119esac
120
121dnl If QNX is found, assume we don't want to use Xphoton
122dnl unless it was specifically asked for (--with-x)
123AC_MSG_CHECKING(for QNX)
124case `uname` in
125 QNX) OS_EXTRA_SRC=os_qnx.c; OS_EXTRA_OBJ=objects/os_qnx.o
126 test -z "$with_x" && with_x=no
127 QNX=yes; AC_MSG_RESULT(yes);;
128 *) QNX=no; AC_MSG_RESULT(no);;
129esac
130
131dnl Check for Darwin and MacOS X
132dnl We do a check for MacOS X in the very beginning because there
133dnl are a lot of other things we need to change besides GUI stuff
Bram Moolenaar071d4272004-06-13 20:20:40 +0000134AC_MSG_CHECKING([for Darwin (Mac OS X)])
135if test "`(uname) 2>/dev/null`" = Darwin; then
136 AC_MSG_RESULT(yes)
137
138 AC_MSG_CHECKING(--disable-darwin argument)
139 AC_ARG_ENABLE(darwin,
140 [ --disable-darwin Disable Darwin (Mac OS X) support.],
141 , [enable_darwin="yes"])
142 if test "$enable_darwin" = "yes"; then
143 AC_MSG_RESULT(no)
144 AC_MSG_CHECKING(if Darwin files are there)
Bram Moolenaar164fca32010-07-14 13:58:07 +0200145 if test -f os_macosx.m; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000146 AC_MSG_RESULT(yes)
147 else
148 AC_MSG_RESULT([no, Darwin support disabled])
149 enable_darwin=no
150 fi
151 else
152 AC_MSG_RESULT([yes, Darwin support excluded])
153 fi
154
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000155 AC_MSG_CHECKING(--with-mac-arch argument)
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000156 AC_ARG_WITH(mac-arch, [ --with-mac-arch=ARCH current, intel, ppc or both],
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000157 MACARCH="$withval"; AC_MSG_RESULT($MACARCH),
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000158 MACARCH="current"; AC_MSG_RESULT(defaulting to $MACARCH))
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000159
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100160 AC_MSG_CHECKING(--with-developer-dir argument)
161 AC_ARG_WITH(developer-dir, [ --with-developer-dir=PATH use PATH as location for Xcode developer tools],
162 DEVELOPER_DIR="$withval"; AC_MSG_RESULT($DEVELOPER_DIR),
Bram Moolenaar32d03b32015-11-19 13:46:48 +0100163 AC_MSG_RESULT(not present))
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100164
165 if test "x$DEVELOPER_DIR" = "x"; then
166 AC_PATH_PROG(XCODE_SELECT, xcode-select)
167 if test "x$XCODE_SELECT" != "x"; then
168 AC_MSG_CHECKING(for developer dir using xcode-select)
169 DEVELOPER_DIR=`$XCODE_SELECT -print-path`
170 AC_MSG_RESULT([$DEVELOPER_DIR])
171 else
172 DEVELOPER_DIR=/Developer
173 fi
174 fi
175
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000176 if test "x$MACARCH" = "xboth"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000177 AC_MSG_CHECKING(for 10.4 universal SDK)
178 dnl There is a terrible inconsistency (but we appear to get away with it):
179 dnl $CFLAGS uses the 10.4u SDK library for the headers, while $CPPFLAGS
180 dnl doesn't, because "gcc -E" doesn't grok it. That means the configure
181 dnl tests using the preprocessor are actually done with the wrong header
182 dnl files. $LDFLAGS is set at the end, because configure uses it together
183 dnl with $CFLAGS and we can only have one -sysroot argument.
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000184 save_cppflags="$CPPFLAGS"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000185 save_cflags="$CFLAGS"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000186 save_ldflags="$LDFLAGS"
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100187 CFLAGS="$CFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000188 AC_TRY_LINK([ ], [ ],
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000189 AC_MSG_RESULT(found, will make universal binary),
190
191 AC_MSG_RESULT(not found)
Bram Moolenaar1f35bf92006-03-07 22:38:47 +0000192 CFLAGS="$save_cflags"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000193 AC_MSG_CHECKING(if Intel architecture is supported)
194 CPPFLAGS="$CPPFLAGS -arch i386"
195 LDFLAGS="$save_ldflags -arch i386"
196 AC_TRY_LINK([ ], [ ],
197 AC_MSG_RESULT(yes); MACARCH="intel",
198 AC_MSG_RESULT(no, using PowerPC)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000199 MACARCH="ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000200 CPPFLAGS="$save_cppflags -arch ppc"
201 LDFLAGS="$save_ldflags -arch ppc"))
202 elif test "x$MACARCH" = "xintel"; then
203 CPPFLAGS="$CPPFLAGS -arch intel"
204 LDFLAGS="$LDFLAGS -arch intel"
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000205 elif test "x$MACARCH" = "xppc"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000206 CPPFLAGS="$CPPFLAGS -arch ppc"
207 LDFLAGS="$LDFLAGS -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000208 fi
209
Bram Moolenaar071d4272004-06-13 20:20:40 +0000210 if test "$enable_darwin" = "yes"; then
211 MACOSX=yes
Bram Moolenaar164fca32010-07-14 13:58:07 +0200212 OS_EXTRA_SRC="os_macosx.m os_mac_conv.c";
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000213 OS_EXTRA_OBJ="objects/os_macosx.o objects/os_mac_conv.o"
Bram Moolenaar32466aa2006-02-24 23:53:04 +0000214 dnl TODO: use -arch i386 on Intel machines
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100215 dnl Removed -no-cpp-precomp, only for very old compilers.
216 CPPFLAGS="$CPPFLAGS -DMACOS_X_UNIX"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000217
218 dnl If Carbon is found, assume we don't want X11
219 dnl unless it was specifically asked for (--with-x)
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000220 dnl or Motif, Athena or GTK GUI is used.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000221 AC_CHECK_HEADER(Carbon/Carbon.h, CARBON=yes)
222 if test "x$CARBON" = "xyes"; then
Bram Moolenaar98921892016-02-23 17:14:37 +0100223 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 +0000224 with_x=no
Bram Moolenaar071d4272004-06-13 20:20:40 +0000225 fi
226 fi
227 fi
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000228
Bram Moolenaardb552d602006-03-23 22:59:57 +0000229 dnl Avoid a bug with -O2 with gcc 4.0.1. Symptom: malloc() reports double
Bram Moolenaarfd2ac762006-03-01 22:09:21 +0000230 dnl free. This happens in expand_filename(), because the optimizer swaps
Bram Moolenaardb552d602006-03-23 22:59:57 +0000231 dnl two blocks of code, both using "repl", that can't be swapped.
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000232 if test "$MACARCH" = "intel" -o "$MACARCH" = "both"; then
233 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-Oz/'`
234 fi
235
Bram Moolenaar071d4272004-06-13 20:20:40 +0000236else
237 AC_MSG_RESULT(no)
238fi
239
Bram Moolenaar39766a72013-11-03 00:41:00 +0100240dnl Mac OS X 10.9+ no longer include AvailabilityMacros.h in Carbon
241dnl so we need to include it to have access to version macros.
Bram Moolenaar18e54692013-11-03 20:26:31 +0100242AC_CHECK_HEADERS(AvailabilityMacros.h)
Bram Moolenaar39766a72013-11-03 00:41:00 +0100243
Bram Moolenaar071d4272004-06-13 20:20:40 +0000244AC_SUBST(OS_EXTRA_SRC)
245AC_SUBST(OS_EXTRA_OBJ)
246
247dnl Add /usr/local/lib to $LDFLAGS and /usr/local/include to CFLAGS.
248dnl Only when the directory exists and it wasn't there yet.
249dnl For gcc don't do this when it is already in the default search path.
Bram Moolenaar446cb832008-06-24 21:56:24 +0000250dnl Skip all of this when cross-compiling.
251if test "$cross_compiling" = no; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000252 AC_MSG_CHECKING(--with-local-dir argument)
Bram Moolenaar446cb832008-06-24 21:56:24 +0000253 have_local_include=''
254 have_local_lib=''
Bram Moolenaarc236c162008-07-13 17:41:49 +0000255 AC_ARG_WITH([local-dir], [ --with-local-dir=PATH search PATH instead of /usr/local for local libraries.
256 --without-local-dir do not search /usr/local for local libraries.], [
257 local_dir="$withval"
258 case "$withval" in
259 */*) ;;
260 no)
261 # avoid adding local dir to LDFLAGS and CPPFLAGS
Bram Moolenaare06c1882010-07-21 22:05:20 +0200262 have_local_include=yes
Bram Moolenaarc236c162008-07-13 17:41:49 +0000263 have_local_lib=yes
264 ;;
265 *) AC_MSG_ERROR(must pass path argument to --with-local-dir) ;;
266 esac
267 AC_MSG_RESULT($local_dir)
268 ], [
269 local_dir=/usr/local
270 AC_MSG_RESULT(Defaulting to $local_dir)
271 ])
272 if test "$GCC" = yes -a "$local_dir" != no; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000273 echo 'void f(){}' > conftest.c
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100274 dnl Removed -no-cpp-precomp, only needed for OS X 10.2 (Ben Fowler)
275 have_local_include=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/include"`
Bram Moolenaarc236c162008-07-13 17:41:49 +0000276 have_local_lib=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/lib"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000277 rm -f conftest.c conftest.o
Bram Moolenaar071d4272004-06-13 20:20:40 +0000278 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000279 if test -z "$have_local_lib" -a -d "${local_dir}/lib"; then
280 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 +0000281 if test "$tt" = "$LDFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000282 LDFLAGS="$LDFLAGS -L${local_dir}/lib"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000283 fi
284 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000285 if test -z "$have_local_include" -a -d "${local_dir}/include"; then
286 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 +0000287 if test "$tt" = "$CPPFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000288 CPPFLAGS="$CPPFLAGS -I${local_dir}/include"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000289 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000290 fi
291fi
292
293AC_MSG_CHECKING(--with-vim-name argument)
294AC_ARG_WITH(vim-name, [ --with-vim-name=NAME what to call the Vim executable],
295 VIMNAME="$withval"; AC_MSG_RESULT($VIMNAME),
Bram Moolenaare344bea2005-09-01 20:46:49 +0000296 VIMNAME="vim"; AC_MSG_RESULT(Defaulting to $VIMNAME))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000297AC_SUBST(VIMNAME)
298AC_MSG_CHECKING(--with-ex-name argument)
299AC_ARG_WITH(ex-name, [ --with-ex-name=NAME what to call the Ex executable],
300 EXNAME="$withval"; AC_MSG_RESULT($EXNAME),
301 EXNAME="ex"; AC_MSG_RESULT(Defaulting to ex))
302AC_SUBST(EXNAME)
303AC_MSG_CHECKING(--with-view-name argument)
304AC_ARG_WITH(view-name, [ --with-view-name=NAME what to call the View executable],
305 VIEWNAME="$withval"; AC_MSG_RESULT($VIEWNAME),
306 VIEWNAME="view"; AC_MSG_RESULT(Defaulting to view))
307AC_SUBST(VIEWNAME)
308
309AC_MSG_CHECKING(--with-global-runtime argument)
310AC_ARG_WITH(global-runtime, [ --with-global-runtime=DIR global runtime directory in 'runtimepath'],
311 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL, "$withval"),
312 AC_MSG_RESULT(no))
313
314AC_MSG_CHECKING(--with-modified-by argument)
315AC_ARG_WITH(modified-by, [ --with-modified-by=NAME name of who modified a release version],
316 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(MODIFIED_BY, "$withval"),
317 AC_MSG_RESULT(no))
318
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200319dnl Check for EBCDIC stolen from the LYNX port to z/OS Unix
Bram Moolenaar071d4272004-06-13 20:20:40 +0000320AC_MSG_CHECKING(if character set is EBCDIC)
321AC_TRY_COMPILE([ ],
322[ /* TryCompile function for CharSet.
323 Treat any failure as ASCII for compatibility with existing art.
324 Use compile-time rather than run-time tests for cross-compiler
325 tolerance. */
326#if '0'!=240
327make an error "Character set is not EBCDIC"
328#endif ],
329[ # TryCompile action if true
330cf_cv_ebcdic=yes ],
331[ # TryCompile action if false
332cf_cv_ebcdic=no])
333# end of TryCompile ])
334# end of CacheVal CvEbcdic
335AC_MSG_RESULT($cf_cv_ebcdic)
336case "$cf_cv_ebcdic" in #(vi
337 yes) AC_DEFINE(EBCDIC)
338 line_break='"\\n"'
339 ;;
340 *) line_break='"\\012"';;
341esac
342AC_SUBST(line_break)
343
344if test "$cf_cv_ebcdic" = "yes"; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +0200345dnl If we have EBCDIC we most likely have z/OS Unix, let's test it!
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200346AC_MSG_CHECKING(for z/OS Unix)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000347case `uname` in
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200348 OS/390) zOSUnix="yes";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000349 dnl If using cc the environment variable _CC_CCMODE must be
350 dnl set to "1", so that some compiler extensions are enabled.
351 dnl If using c89 the environment variable is named _CC_C89MODE.
352 dnl Note: compile with c89 never tested.
353 if test "$CC" = "cc"; then
354 ccm="$_CC_CCMODE"
355 ccn="CC"
356 else
357 if test "$CC" = "c89"; then
358 ccm="$_CC_C89MODE"
359 ccn="C89"
360 else
361 ccm=1
362 fi
363 fi
364 if test "$ccm" != "1"; then
365 echo ""
366 echo "------------------------------------------"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200367 echo " On z/OS Unix, the environment variable"
Bram Moolenaar77c19352012-06-13 19:19:41 +0200368 echo " _CC_${ccn}MODE must be set to \"1\"!"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000369 echo " Do:"
370 echo " export _CC_${ccn}MODE=1"
371 echo " and then call configure again."
372 echo "------------------------------------------"
373 exit 1
374 fi
Bram Moolenaar77c19352012-06-13 19:19:41 +0200375 # Set CFLAGS for configure process.
376 # This will be reset later for config.mk.
377 # Use haltonmsg to force error for missing H files.
378 CFLAGS="$CFLAGS -D_ALL_SOURCE -Wc,float(ieee),haltonmsg(3296)";
379 LDFLAGS="$LDFLAGS -Wl,EDIT=NO"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000380 AC_MSG_RESULT(yes)
381 ;;
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200382 *) zOSUnix="no";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000383 AC_MSG_RESULT(no)
384 ;;
385esac
386fi
387
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200388dnl Set QUOTESED. Needs additional backslashes on zOS
389if test "$zOSUnix" = "yes"; then
390 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\\\\\&/g' -e 's/\\\\\\\\\"/\"/' -e 's/\\\\\\\\\";\$\$/\";/'"
391else
392 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\&/g' -e 's/\\\\\"/\"/' -e 's/\\\\\";\$\$/\";/'"
393fi
394AC_SUBST(QUOTESED)
395
396
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200397dnl Link with -lsmack for Smack stuff; if not found
398AC_MSG_CHECKING(--disable-smack argument)
399AC_ARG_ENABLE(smack,
400 [ --disable-smack Do not check for Smack support.],
401 , enable_smack="yes")
402if test "$enable_smack" = "yes"; then
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200403 AC_MSG_RESULT(no)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200404 AC_CHECK_HEADER([linux/xattr.h], true, enable_smack="no")
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200405else
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200406 AC_MSG_RESULT(yes)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200407fi
408if test "$enable_smack" = "yes"; then
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200409 AC_CHECK_HEADER([attr/xattr.h], true, enable_smack="no")
410fi
411if test "$enable_smack" = "yes"; then
412 AC_MSG_CHECKING(for XATTR_NAME_SMACKEXEC in linux/xattr.h)
413 AC_EGREP_CPP(XATTR_NAME_SMACKEXEC, [#include <linux/xattr.h>],
414 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +0200415 AC_MSG_RESULT(no); enable_smack="no")
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200416fi
417if test "$enable_smack" = "yes"; then
418 AC_CHECK_LIB(attr, setxattr,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200419 [LIBS="$LIBS -lattr"
420 found_smack="yes"
421 AC_DEFINE(HAVE_SMACK)])
Bram Moolenaar588ebeb2008-05-07 17:09:24 +0000422fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000423
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200424dnl When smack was found don't search for SELinux
425if test "x$found_smack" = "x"; then
426 dnl Link with -lselinux for SELinux stuff; if not found
427 AC_MSG_CHECKING(--disable-selinux argument)
428 AC_ARG_ENABLE(selinux,
429 [ --disable-selinux Do not check for SELinux support.],
430 , enable_selinux="yes")
431 if test "$enable_selinux" = "yes"; then
432 AC_MSG_RESULT(no)
433 AC_CHECK_LIB(selinux, is_selinux_enabled,
434 [LIBS="$LIBS -lselinux"
435 AC_DEFINE(HAVE_SELINUX)])
436 else
437 AC_MSG_RESULT(yes)
438 fi
439fi
440
Bram Moolenaar071d4272004-06-13 20:20:40 +0000441dnl Check user requested features.
442
443AC_MSG_CHECKING(--with-features argument)
Bram Moolenaareec29812016-07-26 21:27:36 +0200444AC_ARG_WITH(features, [ --with-features=TYPE tiny, small, normal, big or huge (default: huge)],
Bram Moolenaar071d4272004-06-13 20:20:40 +0000445 features="$withval"; AC_MSG_RESULT($features),
Bram Moolenaar23c4f712016-01-20 22:11:59 +0100446 features="huge"; AC_MSG_RESULT(Defaulting to huge))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000447
448dovimdiff=""
449dogvimdiff=""
450case "$features" in
451 tiny) AC_DEFINE(FEAT_TINY) ;;
452 small) AC_DEFINE(FEAT_SMALL) ;;
453 normal) AC_DEFINE(FEAT_NORMAL) dovimdiff="installvimdiff";
454 dogvimdiff="installgvimdiff" ;;
455 big) AC_DEFINE(FEAT_BIG) dovimdiff="installvimdiff";
456 dogvimdiff="installgvimdiff" ;;
457 huge) AC_DEFINE(FEAT_HUGE) dovimdiff="installvimdiff";
458 dogvimdiff="installgvimdiff" ;;
459 *) AC_MSG_RESULT([Sorry, $features is not supported]) ;;
460esac
461
462AC_SUBST(dovimdiff)
463AC_SUBST(dogvimdiff)
464
465AC_MSG_CHECKING(--with-compiledby argument)
466AC_ARG_WITH(compiledby, [ --with-compiledby=NAME name to show in :version message],
467 compiledby="$withval"; AC_MSG_RESULT($withval),
468 compiledby=""; AC_MSG_RESULT(no))
469AC_SUBST(compiledby)
470
471AC_MSG_CHECKING(--disable-xsmp argument)
472AC_ARG_ENABLE(xsmp,
473 [ --disable-xsmp Disable XSMP session management],
474 , enable_xsmp="yes")
475
476if test "$enable_xsmp" = "yes"; then
477 AC_MSG_RESULT(no)
478 AC_MSG_CHECKING(--disable-xsmp-interact argument)
479 AC_ARG_ENABLE(xsmp-interact,
480 [ --disable-xsmp-interact Disable XSMP interaction],
481 , enable_xsmp_interact="yes")
482 if test "$enable_xsmp_interact" = "yes"; then
483 AC_MSG_RESULT(no)
484 AC_DEFINE(USE_XSMP_INTERACT)
485 else
486 AC_MSG_RESULT(yes)
487 fi
488else
489 AC_MSG_RESULT(yes)
490fi
491
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200492dnl Check for Lua feature.
493AC_MSG_CHECKING(--enable-luainterp argument)
494AC_ARG_ENABLE(luainterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200495 [ --enable-luainterp[=OPTS] Include Lua interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200496 [enable_luainterp="no"])
497AC_MSG_RESULT($enable_luainterp)
498
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200499if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +0100500 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
501 AC_MSG_ERROR([cannot use Lua with tiny or small features])
502 fi
503
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200504 dnl -- find the lua executable
505 AC_SUBST(vi_cv_path_lua)
506
507 AC_MSG_CHECKING(--with-lua-prefix argument)
508 AC_ARG_WITH(lua_prefix,
509 [ --with-lua-prefix=PFX Prefix where Lua is installed.],
510 with_lua_prefix="$withval"; AC_MSG_RESULT($with_lua_prefix),
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200511 with_lua_prefix="";AC_MSG_RESULT(no))
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200512
513 if test "X$with_lua_prefix" != "X"; then
514 vi_cv_path_lua_pfx="$with_lua_prefix"
515 else
516 AC_MSG_CHECKING(LUA_PREFIX environment var)
517 if test "X$LUA_PREFIX" != "X"; then
518 AC_MSG_RESULT("$LUA_PREFIX")
519 vi_cv_path_lua_pfx="$LUA_PREFIX"
520 else
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200521 AC_MSG_RESULT([not set, default to /usr])
522 vi_cv_path_lua_pfx="/usr"
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200523 fi
524 fi
525
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200526 AC_MSG_CHECKING(--with-luajit)
527 AC_ARG_WITH(luajit,
528 [ --with-luajit Link with LuaJIT instead of Lua.],
529 [vi_cv_with_luajit="$withval"],
530 [vi_cv_with_luajit="no"])
531 AC_MSG_RESULT($vi_cv_with_luajit)
532
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200533 LUA_INC=
534 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200535 if test "x$vi_cv_with_luajit" != "xno"; then
536 dnl -- try to find LuaJIT executable
537 AC_PATH_PROG(vi_cv_path_luajit, luajit)
538 if test "X$vi_cv_path_luajit" != "X"; then
539 dnl -- find LuaJIT version
540 AC_CACHE_CHECK(LuaJIT version, vi_cv_version_luajit,
Bram Moolenaar49b10272013-11-21 12:17:51 +0100541 [ 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 +0200542 AC_CACHE_CHECK(Lua version of LuaJIT, vi_cv_version_lua_luajit,
543 [ vi_cv_version_lua_luajit=`${vi_cv_path_luajit} -e "print(_VERSION)" | sed 's/.* //'` ])
544 vi_cv_path_lua="$vi_cv_path_luajit"
545 vi_cv_version_lua="$vi_cv_version_lua_luajit"
546 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200547 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200548 dnl -- try to find Lua executable
549 AC_PATH_PROG(vi_cv_path_plain_lua, lua)
550 if test "X$vi_cv_path_plain_lua" != "X"; then
551 dnl -- find Lua version
552 AC_CACHE_CHECK(Lua version, vi_cv_version_plain_lua,
553 [ vi_cv_version_plain_lua=`${vi_cv_path_plain_lua} -e "print(_VERSION)" | sed 's/.* //'` ])
554 fi
555 vi_cv_path_lua="$vi_cv_path_plain_lua"
556 vi_cv_version_lua="$vi_cv_version_plain_lua"
557 fi
558 if test "x$vi_cv_with_luajit" != "xno" && test "X$vi_cv_version_luajit" != "X"; then
559 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 +0100560 if test -f "$vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200561 AC_MSG_RESULT(yes)
562 LUA_INC=/luajit-$vi_cv_version_luajit
563 fi
564 fi
565 if test "X$LUA_INC" = "X"; then
566 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)
Bram Moolenaar49222be2015-12-11 18:11:30 +0100567 if test -f "$vi_cv_path_lua_pfx/include/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200568 AC_MSG_RESULT(yes)
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200569 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200570 AC_MSG_RESULT(no)
571 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 +0100572 if test -f "$vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200573 AC_MSG_RESULT(yes)
574 LUA_INC=/lua$vi_cv_version_lua
575 else
576 AC_MSG_RESULT(no)
577 vi_cv_path_lua_pfx=
578 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200579 fi
580 fi
581 fi
582
583 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200584 if test "x$vi_cv_with_luajit" != "xno"; then
585 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
586 if test "X$multiarch" != "X"; then
587 lib_multiarch="lib/${multiarch}"
588 else
589 lib_multiarch="lib"
590 fi
591 if test "X$vi_cv_version_lua" = "X"; then
592 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit"
593 else
594 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit-$vi_cv_version_lua"
595 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200596 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200597 if test "X$LUA_INC" != "X"; then
598 dnl Test alternate location using version
599 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua$vi_cv_version_lua"
600 else
601 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua"
602 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200603 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200604 if test "$enable_luainterp" = "dynamic"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200605 lua_ok="yes"
606 else
607 AC_MSG_CHECKING([if link with ${LUA_LIBS} is sane])
608 libs_save=$LIBS
609 LIBS="$LIBS $LUA_LIBS"
610 AC_TRY_LINK(,[ ],
611 AC_MSG_RESULT(yes); lua_ok="yes",
612 AC_MSG_RESULT(no); lua_ok="no"; LUA_LIBS="")
613 LIBS=$libs_save
614 fi
615 if test "x$lua_ok" = "xyes"; then
616 LUA_CFLAGS="-I${vi_cv_path_lua_pfx}/include${LUA_INC}"
617 LUA_SRC="if_lua.c"
618 LUA_OBJ="objects/if_lua.o"
619 LUA_PRO="if_lua.pro"
620 AC_DEFINE(FEAT_LUA)
621 fi
622 if test "$enable_luainterp" = "dynamic"; then
623 if test "x$vi_cv_with_luajit" != "xno"; then
624 luajit="jit"
625 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200626 if test -f "${vi_cv_path_lua_pfx}/bin/cyglua-${vi_cv_version_lua}.dll"; then
627 vi_cv_dll_name_lua="cyglua-${vi_cv_version_lua}.dll"
628 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200629 if test "x$MACOSX" = "xyes"; then
630 ext="dylib"
631 indexes=""
632 else
633 ext="so"
634 indexes=".0 .1 .2 .3 .4 .5 .6 .7 .8 .9"
635 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
636 if test "X$multiarch" != "X"; then
637 lib_multiarch="lib/${multiarch}"
638 fi
Bram Moolenaar768baac2013-04-15 14:44:57 +0200639 fi
640 dnl Determine the sover for the current version, but fallback to
641 dnl liblua${vi_cv_version_lua}.so if no sover-versioned file is found.
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200642 AC_MSG_CHECKING(if liblua${luajit}*.${ext}* can be found in $vi_cv_path_lua_pfx)
Bram Moolenaar768baac2013-04-15 14:44:57 +0200643 for subdir in "${lib_multiarch}" lib64 lib; do
644 if test -z "$subdir"; then
645 continue
646 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200647 for sover in "${vi_cv_version_lua}.${ext}" "-${vi_cv_version_lua}.${ext}" \
648 ".${vi_cv_version_lua}.${ext}" ".${ext}.${vi_cv_version_lua}"; do
649 for i in $indexes ""; do
650 if test -f "${vi_cv_path_lua_pfx}/${subdir}/liblua${luajit}${sover}$i"; then
Bram Moolenaar768baac2013-04-15 14:44:57 +0200651 sover2="$i"
652 break 3
653 fi
654 done
Bram Moolenaar07e1da62013-02-06 19:49:43 +0100655 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200656 sover=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200657 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200658 if test "X$sover" = "X"; then
659 AC_MSG_RESULT(no)
660 lua_ok="no"
661 vi_cv_dll_name_lua="liblua${luajit}.${ext}"
662 else
663 AC_MSG_RESULT(yes)
664 lua_ok="yes"
665 vi_cv_dll_name_lua="liblua${luajit}${sover}$sover2"
666 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200667 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200668 AC_DEFINE(DYNAMIC_LUA)
669 LUA_LIBS=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200670 LUA_CFLAGS="-DDYNAMIC_LUA_DLL=\\\"${vi_cv_dll_name_lua}\\\" $LUA_CFLAGS"
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200671 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200672 if test "X$LUA_CFLAGS$LUA_LIBS" != "X" && \
673 test "x$MACOSX" = "xyes" && test "x$vi_cv_with_luajit" != "xno" && \
674 test "`(uname -m) 2>/dev/null`" = "x86_64"; then
675 dnl OSX/x64 requires these flags. See http://luajit.org/install.html
676 LUA_LIBS="-pagezero_size 10000 -image_base 100000000 $LUA_LIBS"
677 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200678 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200679 if test "$fail_if_missing" = "yes" -a "$lua_ok" != "yes"; then
Bram Moolenaarf788a062011-12-14 20:51:25 +0100680 AC_MSG_ERROR([could not configure lua])
681 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200682 AC_SUBST(LUA_SRC)
683 AC_SUBST(LUA_OBJ)
684 AC_SUBST(LUA_PRO)
685 AC_SUBST(LUA_LIBS)
686 AC_SUBST(LUA_CFLAGS)
687fi
688
689
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000690dnl Check for MzScheme feature.
691AC_MSG_CHECKING(--enable-mzschemeinterp argument)
692AC_ARG_ENABLE(mzschemeinterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200693 [ --enable-mzschemeinterp Include MzScheme interpreter.], ,
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000694 [enable_mzschemeinterp="no"])
695AC_MSG_RESULT($enable_mzschemeinterp)
696
697if test "$enable_mzschemeinterp" = "yes"; then
698 dnl -- find the mzscheme executable
699 AC_SUBST(vi_cv_path_mzscheme)
700
701 AC_MSG_CHECKING(--with-plthome argument)
702 AC_ARG_WITH(plthome,
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000703 [ --with-plthome=PLTHOME Use PLTHOME.],
704 with_plthome="$withval"; AC_MSG_RESULT($with_plthome),
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000705 with_plthome="";AC_MSG_RESULT("no"))
706
707 if test "X$with_plthome" != "X"; then
708 vi_cv_path_mzscheme_pfx="$with_plthome"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100709 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000710 else
711 AC_MSG_CHECKING(PLTHOME environment var)
712 if test "X$PLTHOME" != "X"; then
713 AC_MSG_RESULT("$PLTHOME")
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000714 vi_cv_path_mzscheme_pfx="$PLTHOME"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100715 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000716 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000717 AC_MSG_RESULT(not set)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000718 dnl -- try to find MzScheme executable
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000719 AC_PATH_PROG(vi_cv_path_mzscheme, mzscheme)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000720
721 dnl resolve symbolic link, the executable is often elsewhere and there
722 dnl are no links for the include files.
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000723 if test "X$vi_cv_path_mzscheme" != "X"; then
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000724 lsout=`ls -l $vi_cv_path_mzscheme`
725 if echo "$lsout" | grep -e '->' >/dev/null 2>/dev/null; then
726 vi_cv_path_mzscheme=`echo "$lsout" | sed 's/.*-> \(.*\)/\1/'`
727 fi
728 fi
729
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000730 if test "X$vi_cv_path_mzscheme" != "X"; then
731 dnl -- find where MzScheme thinks it was installed
732 AC_CACHE_CHECK(MzScheme install prefix,vi_cv_path_mzscheme_pfx,
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000733 dnl different versions of MzScheme differ in command line processing
734 dnl use universal approach
735 echo "(display (simplify-path \
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000736 (build-path (call-with-values \
737 (lambda () (split-path (find-system-path (quote exec-file)))) \
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000738 (lambda (base name must-be-dir?) base)) (quote up))))" > mzdirs.scm
739 dnl Remove a trailing slash
740 [ vi_cv_path_mzscheme_pfx=`${vi_cv_path_mzscheme} -r mzdirs.scm | \
741 sed -e 's+/$++'` ])
742 rm -f mzdirs.scm
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000743 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000744 fi
745 fi
746
747 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100748 AC_MSG_CHECKING(for racket include directory)
749 SCHEME_INC=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-include-dir))) (when (path? p) (display p)))'`
750 if test "X$SCHEME_INC" != "X"; then
751 AC_MSG_RESULT(${SCHEME_INC})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000752 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100753 AC_MSG_RESULT(not found)
754 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include)
755 if test -f "$vi_cv_path_mzscheme_pfx/include/scheme.h"; then
756 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000757 AC_MSG_RESULT(yes)
Bram Moolenaard7afed32007-05-06 13:26:41 +0000758 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000759 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100760 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt)
761 if test -f "$vi_cv_path_mzscheme_pfx/include/plt/scheme.h"; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000762 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100763 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000764 else
765 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100766 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket)
767 if test -f "$vi_cv_path_mzscheme_pfx/include/racket/scheme.h"; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100768 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100769 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100770 else
771 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100772 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/)
773 if test -f /usr/include/plt/scheme.h; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100774 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100775 SCHEME_INC=/usr/include/plt
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100776 else
777 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100778 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/racket/)
779 if test -f /usr/include/racket/scheme.h; then
780 AC_MSG_RESULT(yes)
781 SCHEME_INC=/usr/include/racket
782 else
783 AC_MSG_RESULT(no)
784 vi_cv_path_mzscheme_pfx=
785 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100786 fi
787 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000788 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000789 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000790 fi
791 fi
792
793 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100794
795 AC_MSG_CHECKING(for racket lib directory)
796 SCHEME_LIB=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-lib-dir))) (when (path? p) (display p)))'`
797 if test "X$SCHEME_LIB" != "X"; then
798 AC_MSG_RESULT(${SCHEME_LIB})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000799 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100800 AC_MSG_RESULT(not found)
801 fi
802
803 for path in "${vi_cv_path_mzscheme_pfx}/lib" "${SCHEME_LIB}"; do
804 if test "X$path" != "X"; then
805 if test "x$MACOSX" = "xyes"; then
806 MZSCHEME_LIBS="-framework Racket"
807 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
808 elif test -f "${path}/libmzscheme3m.a"; then
809 MZSCHEME_LIBS="${path}/libmzscheme3m.a"
810 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
811 elif test -f "${path}/libracket3m.a"; then
812 MZSCHEME_LIBS="${path}/libracket3m.a"
813 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
814 elif test -f "${path}/libracket.a"; then
815 MZSCHEME_LIBS="${path}/libracket.a ${path}/libmzgc.a"
816 elif test -f "${path}/libmzscheme.a"; then
817 MZSCHEME_LIBS="${path}/libmzscheme.a ${path}/libmzgc.a"
818 else
819 dnl Using shared objects
820 if test -f "${path}/libmzscheme3m.so"; then
821 MZSCHEME_LIBS="-L${path} -lmzscheme3m"
822 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
823 elif test -f "${path}/libracket3m.so"; then
824 MZSCHEME_LIBS="-L${path} -lracket3m"
825 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
826 elif test -f "${path}/libracket.so"; then
827 MZSCHEME_LIBS="-L${path} -lracket -lmzgc"
828 else
829 dnl try next until last
830 if test "$path" != "$SCHEME_LIB"; then
831 continue
832 fi
833 MZSCHEME_LIBS="-L${path} -lmzscheme -lmzgc"
834 fi
835 if test "$GCC" = yes; then
836 dnl Make Vim remember the path to the library. For when it's not in
837 dnl $LD_LIBRARY_PATH.
838 MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${path}"
839 elif test "`(uname) 2>/dev/null`" = SunOS &&
840 uname -r | grep '^5' >/dev/null; then
841 MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${path}"
842 fi
843 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000844 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100845 if test "X$MZSCHEME_LIBS" != "X"; then
846 break
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +0000847 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100848 done
849
850 AC_MSG_CHECKING([if racket requires -pthread])
851 if test "X$SCHEME_LIB" != "X" && $FGREP -e -pthread "$SCHEME_LIB/buildinfo" >/dev/null ; then
852 AC_MSG_RESULT(yes)
853 MZSCHEME_LIBS="${MZSCHEME_LIBS} -pthread"
854 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -pthread"
855 else
856 AC_MSG_RESULT(no)
857 fi
858
859 AC_MSG_CHECKING(for racket config directory)
860 SCHEME_CONFIGDIR=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-config-dir))) (when (path? p) (display p)))'`
861 if test "X$SCHEME_CONFIGDIR" != "X"; then
862 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DMZSCHEME_CONFIGDIR='\"${SCHEME_CONFIGDIR}\"'"
863 AC_MSG_RESULT(${SCHEME_CONFIGDIR})
864 else
865 AC_MSG_RESULT(not found)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000866 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100867
868 AC_MSG_CHECKING(for racket collects directory)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100869 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))))'`
870 if test "X$SCHEME_COLLECTS" = "X"; then
871 if test -d "$vi_cv_path_mzscheme_pfx/lib/plt/collects"; then
872 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/plt/
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100873 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100874 if test -d "$vi_cv_path_mzscheme_pfx/lib/racket/collects"; then
875 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/racket/
Bram Moolenaar75676462013-01-30 14:55:42 +0100876 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100877 if test -d "$vi_cv_path_mzscheme_pfx/share/racket/collects"; then
878 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/
879 else
880 if test -d "$vi_cv_path_mzscheme_pfx/collects"; then
881 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/
882 fi
Bram Moolenaar75676462013-01-30 14:55:42 +0100883 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100884 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100885 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000886 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100887 if test "X$SCHEME_COLLECTS" != "X" ; then
888 AC_MSG_RESULT(${SCHEME_COLLECTS})
889 else
890 AC_MSG_RESULT(not found)
891 fi
892
893 AC_MSG_CHECKING(for mzscheme_base.c)
894 if test -f "${SCHEME_COLLECTS}collects/scheme/base.ss" ; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000895 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +0100896 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
897 MZSCHEME_MOD="++lib scheme/base"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100898 else
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100899 if test -f "${SCHEME_COLLECTS}collects/scheme/base.rkt" ; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100900 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +0100901 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
902 MZSCHEME_MOD="++lib scheme/base"
903 else
904 if test -f "${SCHEME_COLLECTS}collects/racket/base.rkt" ; then
905 MZSCHEME_EXTRA="mzscheme_base.c"
906 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/raco ctool"
907 MZSCHEME_MOD=""
908 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100909 fi
910 fi
911 if test "X$MZSCHEME_EXTRA" != "X" ; then
912 dnl need to generate bytecode for MzScheme base
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000913 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE"
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100914 AC_MSG_RESULT(needed)
915 else
916 AC_MSG_RESULT(not needed)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000917 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100918
Bram Moolenaar9e902192013-07-17 18:58:11 +0200919 dnl On Ubuntu this fixes "undefined reference to symbol 'ffi_type_void'".
920 AC_CHECK_LIB(ffi, ffi_type_void, [MZSCHEME_LIBS="$MZSCHEME_LIBS -lffi"])
921
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000922 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -I${SCHEME_INC} \
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100923 -DMZSCHEME_COLLECTS='\"${SCHEME_COLLECTS}collects\"'"
Bram Moolenaar9e902192013-07-17 18:58:11 +0200924
925 dnl Test that we can compile a simple program with these CFLAGS and LIBS.
926 AC_MSG_CHECKING([if compile and link flags for MzScheme are sane])
927 cflags_save=$CFLAGS
928 libs_save=$LIBS
929 CFLAGS="$CFLAGS $MZSCHEME_CFLAGS"
930 LIBS="$LIBS $MZSCHEME_LIBS"
931 AC_TRY_LINK(,[ ],
932 AC_MSG_RESULT(yes); mzs_ok=yes,
933 AC_MSG_RESULT(no: MZSCHEME DISABLED); mzs_ok=no)
934 CFLAGS=$cflags_save
935 LIBS=$libs_save
936 if test $mzs_ok = yes; then
937 MZSCHEME_SRC="if_mzsch.c"
938 MZSCHEME_OBJ="objects/if_mzsch.o"
939 MZSCHEME_PRO="if_mzsch.pro"
940 AC_DEFINE(FEAT_MZSCHEME)
941 else
942 MZSCHEME_CFLAGS=
943 MZSCHEME_LIBS=
944 MZSCHEME_EXTRA=
945 MZSCHEME_MZC=
946 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000947 fi
948 AC_SUBST(MZSCHEME_SRC)
949 AC_SUBST(MZSCHEME_OBJ)
950 AC_SUBST(MZSCHEME_PRO)
951 AC_SUBST(MZSCHEME_LIBS)
952 AC_SUBST(MZSCHEME_CFLAGS)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000953 AC_SUBST(MZSCHEME_EXTRA)
954 AC_SUBST(MZSCHEME_MZC)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000955fi
956
957
Bram Moolenaar071d4272004-06-13 20:20:40 +0000958AC_MSG_CHECKING(--enable-perlinterp argument)
959AC_ARG_ENABLE(perlinterp,
Bram Moolenaare06c1882010-07-21 22:05:20 +0200960 [ --enable-perlinterp[=OPTS] Include Perl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000961 [enable_perlinterp="no"])
962AC_MSG_RESULT($enable_perlinterp)
Bram Moolenaare06c1882010-07-21 22:05:20 +0200963if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +0100964 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
965 AC_MSG_ERROR([cannot use Perl with tiny or small features])
966 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000967 AC_SUBST(vi_cv_path_perl)
968 AC_PATH_PROG(vi_cv_path_perl, perl)
969 if test "X$vi_cv_path_perl" != "X"; then
970 AC_MSG_CHECKING(Perl version)
971 if $vi_cv_path_perl -e 'require 5.003_01' >/dev/null 2>/dev/null; then
972 eval `$vi_cv_path_perl -V:usethreads`
Bram Moolenaare06c1882010-07-21 22:05:20 +0200973 eval `$vi_cv_path_perl -V:libperl`
Bram Moolenaar071d4272004-06-13 20:20:40 +0000974 if test "X$usethreads" = "XUNKNOWN" -o "X$usethreads" = "Xundef"; then
975 badthreads=no
976 else
977 if $vi_cv_path_perl -e 'require 5.6.0' >/dev/null 2>/dev/null; then
978 eval `$vi_cv_path_perl -V:use5005threads`
979 if test "X$use5005threads" = "XUNKNOWN" -o "X$use5005threads" = "Xundef"; then
980 badthreads=no
981 else
982 badthreads=yes
983 AC_MSG_RESULT(>>> Perl > 5.6 with 5.5 threads cannot be used <<<)
984 fi
985 else
986 badthreads=yes
987 AC_MSG_RESULT(>>> Perl 5.5 with threads cannot be used <<<)
988 fi
989 fi
990 if test $badthreads = no; then
991 AC_MSG_RESULT(OK)
992 eval `$vi_cv_path_perl -V:shrpenv`
993 if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04
994 shrpenv=""
995 fi
996 vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlibexp}'`
997 AC_SUBST(vi_cv_perllib)
Bram Moolenaard5f62b12014-08-17 17:05:44 +0200998 vi_cv_perl_extutils=unknown_perl_extutils_path
999 for extutils_rel_path in ExtUtils vendor_perl/ExtUtils; do
1000 xsubpp_path="$vi_cv_perllib/$extutils_rel_path/xsubpp"
1001 if test -f "$xsubpp_path"; then
1002 vi_cv_perl_xsubpp="$xsubpp_path"
1003 fi
1004 done
1005 AC_SUBST(vi_cv_perl_xsubpp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001006 dnl Remove "-fno-something", it breaks using cproto.
Bram Moolenaar280a8682015-06-21 13:41:08 +02001007 dnl Remove "-fdebug-prefix-map", it isn't supported by clang.
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001008 dnl Remove "FORTIFY_SOURCE", it will be defined twice.
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001009 dnl remove -pipe and -Wxxx, it confuses cproto
Bram Moolenaar071d4272004-06-13 20:20:40 +00001010 perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001011 -e 'ccflags;perl_inc;print"\n"' | sed -e 's/-fno[[^ ]]*//' \
1012 -e 's/-fdebug-prefix-map[[^ ]]*//g' \
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001013 -e 's/-pipe //' \
1014 -e 's/-W[[^ ]]*//g' \
1015 -e 's/-D_FORTIFY_SOURCE=.//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001016 dnl Remove "-lc", it breaks on FreeBSD when using "-pthread".
1017 perllibs=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed -e 'ldopts' | \
1018 sed -e '/Warning/d' -e '/Note (probably harmless)/d' \
1019 -e 's/-bE:perl.exp//' -e 's/-lc //'`
1020 dnl Don't add perl lib to $LIBS: if it's not in LD_LIBRARY_PATH
1021 dnl a test in configure may fail because of that.
1022 perlldflags=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed \
1023 -e 'ccdlflags' | sed -e 's/-bE:perl.exp//'`
1024
1025 dnl check that compiling a simple program still works with the flags
1026 dnl added for Perl.
1027 AC_MSG_CHECKING([if compile and link flags for Perl are sane])
1028 cflags_save=$CFLAGS
1029 libs_save=$LIBS
1030 ldflags_save=$LDFLAGS
1031 CFLAGS="$CFLAGS $perlcppflags"
1032 LIBS="$LIBS $perllibs"
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001033 perlldflags=`echo "$perlldflags" | sed -e 's/^ *//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001034 LDFLAGS="$perlldflags $LDFLAGS"
1035 AC_TRY_LINK(,[ ],
1036 AC_MSG_RESULT(yes); perl_ok=yes,
1037 AC_MSG_RESULT(no: PERL DISABLED); perl_ok=no)
1038 CFLAGS=$cflags_save
1039 LIBS=$libs_save
1040 LDFLAGS=$ldflags_save
1041 if test $perl_ok = yes; then
1042 if test "X$perlcppflags" != "X"; then
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001043 PERL_CFLAGS=$perlcppflags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001044 fi
1045 if test "X$perlldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001046 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$perlldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001047 LDFLAGS="$perlldflags $LDFLAGS"
1048 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001049 fi
1050 PERL_LIBS=$perllibs
1051 PERL_SRC="auto/if_perl.c if_perlsfio.c"
1052 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o"
1053 PERL_PRO="if_perl.pro if_perlsfio.pro"
1054 AC_DEFINE(FEAT_PERL)
1055 fi
1056 fi
1057 else
1058 AC_MSG_RESULT(>>> too old; need Perl version 5.003_01 or later <<<)
1059 fi
1060 fi
1061
1062 if test "x$MACOSX" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00001063 dnl Mac OS X 10.2 or later
Bram Moolenaar071d4272004-06-13 20:20:40 +00001064 dir=/System/Library/Perl
1065 darwindir=$dir/darwin
1066 if test -d $darwindir; then
1067 PERL=/usr/bin/perl
1068 else
1069 dnl Mac OS X 10.3
1070 dir=/System/Library/Perl/5.8.1
1071 darwindir=$dir/darwin-thread-multi-2level
1072 if test -d $darwindir; then
1073 PERL=/usr/bin/perl
1074 fi
1075 fi
1076 if test -n "$PERL"; then
1077 PERL_DIR="$dir"
1078 PERL_CFLAGS="-DFEAT_PERL -I$darwindir/CORE"
1079 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o $darwindir/auto/DynaLoader/DynaLoader.a"
1080 PERL_LIBS="-L$darwindir/CORE -lperl"
1081 fi
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001082 dnl Perl on Mac OS X 10.5 adds "-arch" flags but these should only
1083 dnl be included if requested by passing --with-mac-arch to
1084 dnl configure, so strip these flags first (if present)
1085 PERL_LIBS=`echo "$PERL_LIBS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
1086 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 +00001087 fi
Bram Moolenaare06c1882010-07-21 22:05:20 +02001088 if test "$enable_perlinterp" = "dynamic"; then
1089 if test "$perl_ok" = "yes" -a "X$libperl" != "X"; then
1090 AC_DEFINE(DYNAMIC_PERL)
1091 PERL_CFLAGS="-DDYNAMIC_PERL_DLL=\\\"$libperl\\\" $PERL_CFLAGS"
1092 fi
1093 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001094
1095 if test "$fail_if_missing" = "yes" -a "$perl_ok" != "yes"; then
1096 AC_MSG_ERROR([could not configure perl])
1097 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001098fi
1099AC_SUBST(shrpenv)
1100AC_SUBST(PERL_SRC)
1101AC_SUBST(PERL_OBJ)
1102AC_SUBST(PERL_PRO)
1103AC_SUBST(PERL_CFLAGS)
1104AC_SUBST(PERL_LIBS)
1105
1106AC_MSG_CHECKING(--enable-pythoninterp argument)
1107AC_ARG_ENABLE(pythoninterp,
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001108 [ --enable-pythoninterp[=OPTS] Include Python interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001109 [enable_pythoninterp="no"])
1110AC_MSG_RESULT($enable_pythoninterp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001111if test "$enable_pythoninterp" = "yes" -o "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001112 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1113 AC_MSG_ERROR([cannot use Python with tiny or small features])
1114 fi
1115
Bram Moolenaar071d4272004-06-13 20:20:40 +00001116 dnl -- find the python executable
Bram Moolenaar09ba6d72012-12-12 14:25:05 +01001117 AC_PATH_PROGS(vi_cv_path_python, python2 python)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001118 if test "X$vi_cv_path_python" != "X"; then
1119
1120 dnl -- get its version number
1121 AC_CACHE_CHECK(Python version,vi_cv_var_python_version,
1122 [[vi_cv_var_python_version=`
1123 ${vi_cv_path_python} -c 'import sys; print sys.version[:3]'`
1124 ]])
1125
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001126 dnl -- it must be at least version 2.3
1127 AC_MSG_CHECKING(Python is 2.3 or better)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001128 if ${vi_cv_path_python} -c \
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001129 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001130 then
1131 AC_MSG_RESULT(yep)
1132
1133 dnl -- find where python thinks it was installed
1134 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python_pfx,
1135 [ vi_cv_path_python_pfx=`
1136 ${vi_cv_path_python} -c \
1137 "import sys; print sys.prefix"` ])
1138
1139 dnl -- and where it thinks it runs
1140 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python_epfx,
1141 [ vi_cv_path_python_epfx=`
1142 ${vi_cv_path_python} -c \
1143 "import sys; print sys.exec_prefix"` ])
1144
1145 dnl -- python's internal library path
1146
1147 AC_CACHE_VAL(vi_cv_path_pythonpath,
1148 [ vi_cv_path_pythonpath=`
1149 unset PYTHONPATH;
1150 ${vi_cv_path_python} -c \
1151 "import sys, string; print string.join(sys.path,':')"` ])
1152
1153 dnl -- where the Python implementation library archives are
1154
1155 AC_ARG_WITH(python-config-dir,
1156 [ --with-python-config-dir=PATH Python's config directory],
1157 [ vi_cv_path_python_conf="${withval}" ] )
1158
1159 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python_conf,
1160 [
1161 vi_cv_path_python_conf=
Bram Moolenaarac499e32013-06-02 19:14:17 +02001162 d=`${vi_cv_path_python} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBPL')"`
1163 if test -d "$d" && test -f "$d/config.c"; then
1164 vi_cv_path_python_conf="$d"
1165 else
1166 for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
1167 for subdir in lib64 lib share; do
1168 d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
1169 if test -d "$d" && test -f "$d/config.c"; then
1170 vi_cv_path_python_conf="$d"
1171 fi
1172 done
Bram Moolenaar071d4272004-06-13 20:20:40 +00001173 done
Bram Moolenaarac499e32013-06-02 19:14:17 +02001174 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001175 ])
1176
1177 PYTHON_CONFDIR="${vi_cv_path_python_conf}"
1178
1179 if test "X$PYTHON_CONFDIR" = "X"; then
1180 AC_MSG_RESULT([can't find it!])
1181 else
1182
1183 dnl -- we need to examine Python's config/Makefile too
1184 dnl see what the interpreter is built from
1185 AC_CACHE_VAL(vi_cv_path_python_plibs,
1186 [
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001187 pwd=`pwd`
1188 tmp_mkf="$pwd/config-PyMake$$"
1189 cat -- "${PYTHON_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001190__:
Bram Moolenaar218116c2010-05-20 21:46:00 +02001191 @echo "python_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001192 @echo "python_LIBS='$(LIBS)'"
1193 @echo "python_SYSLIBS='$(SYSLIBS)'"
1194 @echo "python_LINKFORSHARED='$(LINKFORSHARED)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001195 @echo "python_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001196 @echo "python_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001197 @echo "python_PYTHONFRAMEWORK='$(PYTHONFRAMEWORK)'"
1198 @echo "python_PYTHONFRAMEWORKPREFIX='$(PYTHONFRAMEWORKPREFIX)'"
1199 @echo "python_PYTHONFRAMEWORKINSTALLDIR='$(PYTHONFRAMEWORKINSTALLDIR)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001200eof
1201 dnl -- delete the lines from make about Entering/Leaving directory
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001202 eval "`cd ${PYTHON_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1203 rm -f -- "${tmp_mkf}"
Bram Moolenaarcff50f52016-08-14 17:32:52 +02001204 if test "x$MACOSX" = "xyes" && test -n "${python_PYTHONFRAMEWORK}" && ${vi_cv_path_python} -c \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001205 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then
1206 vi_cv_path_python_plibs="-framework Python"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001207 if test "x${vi_cv_path_python}" != "x/usr/bin/python" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
1208 vi_cv_path_python_plibs="-F${python_PYTHONFRAMEWORKPREFIX} -framework Python"
1209 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001210 else
1211 if test "${vi_cv_var_python_version}" = "1.4"; then
1212 vi_cv_path_python_plibs="${PYTHON_CONFDIR}/libModules.a ${PYTHON_CONFDIR}/libPython.a ${PYTHON_CONFDIR}/libObjects.a ${PYTHON_CONFDIR}/libParser.a"
1213 else
1214 vi_cv_path_python_plibs="-L${PYTHON_CONFDIR} -lpython${vi_cv_var_python_version}"
1215 fi
Bram Moolenaar6c927552015-03-24 12:21:33 +01001216 dnl -- Check if the path contained in python_LINKFORSHARED is
1217 dnl usable for vim build. If not, make and try other
1218 dnl candidates.
Bram Moolenaara161e262015-03-24 15:14:27 +01001219 if test -n "${python_LINKFORSHARED}" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
Bram Moolenaar6c927552015-03-24 12:21:33 +01001220 python_link_symbol=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]].*/\1/'`
1221 python_link_path=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]][[ \t]]*\(.*\)/\2/'`
1222 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1223 dnl -- The path looks relative. Guess the absolute one using
1224 dnl the prefix and try that.
1225 python_link_path="${python_PYTHONFRAMEWORKPREFIX}/${python_link_path}"
1226 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1227 dnl -- A last resort.
1228 python_link_path="${python_PYTHONFRAMEWORKINSTALLDIR}/Versions/${vi_cv_var_python_version}/${python_PYTHONFRAMEWORK}"
1229 dnl -- No check is done. The last word is left to the
1230 dnl "sanity" test on link flags that follows shortly.
1231 fi
1232 python_LINKFORSHARED="${python_link_symbol} ${python_link_path}"
1233 fi
1234 fi
Bram Moolenaar218116c2010-05-20 21:46:00 +02001235 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 +00001236 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1237 vi_cv_path_python_plibs=`echo $vi_cv_path_python_plibs | sed s/-ltermcap//`
1238 fi
1239 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001240 AC_CACHE_CHECK(Python's dll name,vi_cv_dll_name_python,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001241 [
1242 if test "X$python_DLLLIBRARY" != "X"; then
1243 vi_cv_dll_name_python="$python_DLLLIBRARY"
1244 else
1245 vi_cv_dll_name_python="$python_INSTSONAME"
1246 fi
1247 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00001248
1249 PYTHON_LIBS="${vi_cv_path_python_plibs}"
1250 if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
Bram Moolenaar780c3e92013-06-11 20:53:28 +02001251 PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001252 else
Bram Moolenaar780c3e92013-06-11 20:53:28 +02001253 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} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001254 fi
1255 PYTHON_SRC="if_python.c"
Bram Moolenaar9bdb9a02012-07-25 16:32:08 +02001256 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001257 if test "${vi_cv_var_python_version}" = "1.4"; then
1258 PYTHON_OBJ="$PYTHON_OBJ objects/py_getpath.o"
1259 fi
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001260 PYTHON_GETPATH_CFLAGS="-DPYTHONPATH='\"${vi_cv_path_pythonpath}\"' -DPREFIX='\"${vi_cv_path_python_pfx}\"' -DEXEC_PREFIX='\"${vi_cv_path_python_epfx}\"'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001261
1262 dnl On FreeBSD linking with "-pthread" is required to use threads.
1263 dnl _THREAD_SAFE must be used for compiling then.
1264 dnl The "-pthread" is added to $LIBS, so that the following check for
1265 dnl sigaltstack() will look in libc_r (it's there in libc!).
1266 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1267 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1268 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1269 AC_MSG_CHECKING([if -pthread should be used])
1270 threadsafe_flag=
1271 thread_lib=
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00001272 dnl if test "x$MACOSX" != "xyes"; then
1273 if test "`(uname) 2>/dev/null`" != Darwin; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001274 test "$GCC" = yes && threadsafe_flag="-pthread"
1275 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1276 threadsafe_flag="-D_THREAD_SAFE"
1277 thread_lib="-pthread"
1278 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001279 if test "`(uname) 2>/dev/null`" = SunOS; then
1280 threadsafe_flag="-pthreads"
1281 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001282 fi
1283 libs_save_old=$LIBS
1284 if test -n "$threadsafe_flag"; then
1285 cflags_save=$CFLAGS
1286 CFLAGS="$CFLAGS $threadsafe_flag"
1287 LIBS="$LIBS $thread_lib"
1288 AC_TRY_LINK(,[ ],
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001289 AC_MSG_RESULT(yes); PYTHON_CFLAGS="$PYTHON_CFLAGS $threadsafe_flag",
Bram Moolenaar071d4272004-06-13 20:20:40 +00001290 AC_MSG_RESULT(no); LIBS=$libs_save_old
1291 )
1292 CFLAGS=$cflags_save
1293 else
1294 AC_MSG_RESULT(no)
1295 fi
1296
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001297 dnl Check that compiling a simple program still works with the flags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001298 dnl added for Python.
1299 AC_MSG_CHECKING([if compile and link flags for Python are sane])
1300 cflags_save=$CFLAGS
1301 libs_save=$LIBS
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001302 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001303 LIBS="$LIBS $PYTHON_LIBS"
1304 AC_TRY_LINK(,[ ],
1305 AC_MSG_RESULT(yes); python_ok=yes,
1306 AC_MSG_RESULT(no: PYTHON DISABLED); python_ok=no)
1307 CFLAGS=$cflags_save
1308 LIBS=$libs_save
1309 if test $python_ok = yes; then
1310 AC_DEFINE(FEAT_PYTHON)
1311 else
1312 LIBS=$libs_save_old
1313 PYTHON_SRC=
1314 PYTHON_OBJ=
1315 PYTHON_LIBS=
1316 PYTHON_CFLAGS=
1317 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001318 fi
1319 else
1320 AC_MSG_RESULT(too old)
1321 fi
1322 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001323
1324 if test "$fail_if_missing" = "yes" -a "$python_ok" != "yes"; then
1325 AC_MSG_ERROR([could not configure python])
1326 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001327fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001328
Bram Moolenaar071d4272004-06-13 20:20:40 +00001329AC_SUBST(PYTHON_CONFDIR)
1330AC_SUBST(PYTHON_LIBS)
1331AC_SUBST(PYTHON_GETPATH_CFLAGS)
1332AC_SUBST(PYTHON_CFLAGS)
1333AC_SUBST(PYTHON_SRC)
1334AC_SUBST(PYTHON_OBJ)
1335
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001336
1337AC_MSG_CHECKING(--enable-python3interp argument)
1338AC_ARG_ENABLE(python3interp,
Bram Moolenaar8008b632017-07-18 21:33:20 +02001339 [ --enable-python3interp[=OPTS] Include Python3 interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001340 [enable_python3interp="no"])
1341AC_MSG_RESULT($enable_python3interp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001342if test "$enable_python3interp" = "yes" -o "$enable_python3interp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001343 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1344 AC_MSG_ERROR([cannot use Python with tiny or small features])
1345 fi
1346
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001347 dnl -- find the python3 executable
Bram Moolenaar09ba6d72012-12-12 14:25:05 +01001348 AC_PATH_PROGS(vi_cv_path_python3, python3 python)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001349 if test "X$vi_cv_path_python3" != "X"; then
1350
1351 dnl -- get its version number
1352 AC_CACHE_CHECK(Python version,vi_cv_var_python3_version,
1353 [[vi_cv_var_python3_version=`
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001354 ${vi_cv_path_python3} -c 'import sys; print(sys.version[:3])'`
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001355 ]])
1356
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001357 dnl -- it must be at least version 3
1358 AC_MSG_CHECKING(Python is 3.0 or better)
1359 if ${vi_cv_path_python3} -c \
1360 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.0)"
1361 then
1362 AC_MSG_RESULT(yep)
Bram Moolenaar456f2bb2011-06-12 21:37:13 +02001363
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001364 dnl -- get abiflags for python 3.2 or higher (PEP 3149)
1365 AC_CACHE_CHECK(Python's abiflags,vi_cv_var_python3_abiflags,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001366 [
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001367 vi_cv_var_python3_abiflags=
1368 if ${vi_cv_path_python3} -c \
1369 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)"
1370 then
1371 vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \
1372 "import sys; print(sys.abiflags)"`
1373 fi ])
1374
1375 dnl -- find where python3 thinks it was installed
1376 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx,
1377 [ vi_cv_path_python3_pfx=`
1378 ${vi_cv_path_python3} -c \
1379 "import sys; print(sys.prefix)"` ])
1380
1381 dnl -- and where it thinks it runs
1382 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx,
1383 [ vi_cv_path_python3_epfx=`
1384 ${vi_cv_path_python3} -c \
1385 "import sys; print(sys.exec_prefix)"` ])
1386
1387 dnl -- python3's internal library path
1388
1389 AC_CACHE_VAL(vi_cv_path_python3path,
1390 [ vi_cv_path_python3path=`
1391 unset PYTHONPATH;
1392 ${vi_cv_path_python3} -c \
1393 "import sys, string; print(':'.join(sys.path))"` ])
1394
1395 dnl -- where the Python implementation library archives are
1396
1397 AC_ARG_WITH(python3-config-dir,
1398 [ --with-python3-config-dir=PATH Python's config directory],
1399 [ vi_cv_path_python3_conf="${withval}" ] )
1400
1401 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf,
1402 [
1403 vi_cv_path_python3_conf=
Bram Moolenaarfee496d2013-07-12 20:07:24 +02001404 config_dir="config-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001405 d=`${vi_cv_path_python3} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBPL'))"`
1406 if test -d "$d" && test -f "$d/config.c"; then
1407 vi_cv_path_python3_conf="$d"
1408 else
1409 for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do
1410 for subdir in lib64 lib share; do
1411 d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}"
1412 if test -d "$d" && test -f "$d/config.c"; then
1413 vi_cv_path_python3_conf="$d"
1414 fi
1415 done
1416 done
1417 fi
1418 ])
1419
1420 PYTHON3_CONFDIR="${vi_cv_path_python3_conf}"
1421
1422 if test "X$PYTHON3_CONFDIR" = "X"; then
1423 AC_MSG_RESULT([can't find it!])
1424 else
1425
1426 dnl -- we need to examine Python's config/Makefile too
1427 dnl see what the interpreter is built from
1428 AC_CACHE_VAL(vi_cv_path_python3_plibs,
1429 [
1430 pwd=`pwd`
1431 tmp_mkf="$pwd/config-PyMake$$"
1432 cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001433__:
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001434 @echo "python3_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001435 @echo "python3_LIBS='$(LIBS)'"
1436 @echo "python3_SYSLIBS='$(SYSLIBS)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001437 @echo "python3_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001438 @echo "python3_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001439eof
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001440 dnl -- delete the lines from make about Entering/Leaving directory
1441 eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1442 rm -f -- "${tmp_mkf}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001443 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 +02001444 vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}"
1445 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1446 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//`
1447 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//`
1448 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001449 AC_CACHE_CHECK(Python3's dll name,vi_cv_dll_name_python3,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001450 [
1451 if test "X$python3_DLLLIBRARY" != "X"; then
1452 vi_cv_dll_name_python3="$python3_DLLLIBRARY"
1453 else
1454 vi_cv_dll_name_python3="$python3_INSTSONAME"
1455 fi
1456 ])
1457
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001458 PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
1459 if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
Bram Moolenaar780c3e92013-06-11 20:53:28 +02001460 PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -DPYTHON3_HOME='L\"${vi_cv_path_python3_pfx}\"'"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001461 else
Bram Moolenaar780c3e92013-06-11 20:53:28 +02001462 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} -DPYTHON3_HOME='L\"${vi_cv_path_python3_pfx}\"'"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001463 fi
1464 PYTHON3_SRC="if_python3.c"
1465 PYTHON3_OBJ="objects/if_python3.o"
1466
1467 dnl On FreeBSD linking with "-pthread" is required to use threads.
1468 dnl _THREAD_SAFE must be used for compiling then.
1469 dnl The "-pthread" is added to $LIBS, so that the following check for
1470 dnl sigaltstack() will look in libc_r (it's there in libc!).
1471 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1472 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1473 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1474 AC_MSG_CHECKING([if -pthread should be used])
1475 threadsafe_flag=
1476 thread_lib=
1477 dnl if test "x$MACOSX" != "xyes"; then
1478 if test "`(uname) 2>/dev/null`" != Darwin; then
1479 test "$GCC" = yes && threadsafe_flag="-pthread"
1480 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1481 threadsafe_flag="-D_THREAD_SAFE"
1482 thread_lib="-pthread"
1483 fi
1484 if test "`(uname) 2>/dev/null`" = SunOS; then
1485 threadsafe_flag="-pthreads"
1486 fi
1487 fi
1488 libs_save_old=$LIBS
1489 if test -n "$threadsafe_flag"; then
1490 cflags_save=$CFLAGS
1491 CFLAGS="$CFLAGS $threadsafe_flag"
1492 LIBS="$LIBS $thread_lib"
1493 AC_TRY_LINK(,[ ],
1494 AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag",
1495 AC_MSG_RESULT(no); LIBS=$libs_save_old
1496 )
1497 CFLAGS=$cflags_save
1498 else
1499 AC_MSG_RESULT(no)
1500 fi
1501
1502 dnl check that compiling a simple program still works with the flags
1503 dnl added for Python.
1504 AC_MSG_CHECKING([if compile and link flags for Python 3 are sane])
1505 cflags_save=$CFLAGS
1506 libs_save=$LIBS
1507 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1508 LIBS="$LIBS $PYTHON3_LIBS"
1509 AC_TRY_LINK(,[ ],
1510 AC_MSG_RESULT(yes); python3_ok=yes,
1511 AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no)
1512 CFLAGS=$cflags_save
1513 LIBS=$libs_save
1514 if test "$python3_ok" = yes; then
1515 AC_DEFINE(FEAT_PYTHON3)
1516 else
1517 LIBS=$libs_save_old
1518 PYTHON3_SRC=
1519 PYTHON3_OBJ=
1520 PYTHON3_LIBS=
1521 PYTHON3_CFLAGS=
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001522 fi
1523 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001524 else
1525 AC_MSG_RESULT(too old)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001526 fi
1527 fi
Bram Moolenaar1612b1a2013-06-14 21:22:39 +02001528 if test "$fail_if_missing" = "yes" -a "$python3_ok" != "yes"; then
1529 AC_MSG_ERROR([could not configure python3])
1530 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001531fi
1532
1533AC_SUBST(PYTHON3_CONFDIR)
1534AC_SUBST(PYTHON3_LIBS)
1535AC_SUBST(PYTHON3_CFLAGS)
1536AC_SUBST(PYTHON3_SRC)
1537AC_SUBST(PYTHON3_OBJ)
1538
1539dnl if python2.x and python3.x are enabled one can only link in code
1540dnl with dlopen(), dlsym(), dlclose()
1541if test "$python_ok" = yes && test "$python3_ok" = yes; then
1542 AC_DEFINE(DYNAMIC_PYTHON)
1543 AC_DEFINE(DYNAMIC_PYTHON3)
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001544 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001545 cflags_save=$CFLAGS
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001546 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001547 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001548 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001549 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001550 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001551 #include <dlfcn.h>
1552 /* If this program fails, then RTLD_GLOBAL is needed.
1553 * RTLD_GLOBAL will be used and then it is not possible to
1554 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001555 * Only the first python version used will be switched on.
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001556 */
1557
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001558 int no_rtl_global_needed_for(char *python_instsoname, char *prefix)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001559 {
1560 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001561 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001562 if (pylib != 0)
1563 {
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001564 void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome");
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001565 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1566 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1567 void (*final)(void) = dlsym(pylib, "Py_Finalize");
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001568 (*pfx)(prefix);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001569 (*init)();
1570 needed = (*simple)("import termios") == -1;
1571 (*final)();
1572 dlclose(pylib);
1573 }
1574 return !needed;
1575 }
1576
1577 int main(int argc, char** argv)
1578 {
1579 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001580 if (no_rtl_global_needed_for("${vi_cv_dll_name_python}", "${vi_cv_path_python_pfx}"))
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001581 not_needed = 1;
1582 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001583 }])],
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001584 [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001585
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001586 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001587 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001588
1589 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python3)
1590 cflags_save=$CFLAGS
1591 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001592 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001593 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001594 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001595 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001596 #include <dlfcn.h>
1597 #include <wchar.h>
1598 /* If this program fails, then RTLD_GLOBAL is needed.
1599 * RTLD_GLOBAL will be used and then it is not possible to
1600 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001601 * Only the first python version used will be switched on.
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001602 */
1603
1604 int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix)
1605 {
1606 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001607 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001608 if (pylib != 0)
1609 {
1610 void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome");
1611 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1612 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1613 void (*final)(void) = dlsym(pylib, "Py_Finalize");
1614 (*pfx)(prefix);
1615 (*init)();
1616 needed = (*simple)("import termios") == -1;
1617 (*final)();
1618 dlclose(pylib);
1619 }
1620 return !needed;
1621 }
1622
1623 int main(int argc, char** argv)
1624 {
1625 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001626 if (no_rtl_global_needed_for("${vi_cv_dll_name_python3}", L"${vi_cv_path_python3_pfx}"))
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001627 not_needed = 1;
1628 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001629 }])],
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001630 [AC_MSG_RESULT(yes);AC_DEFINE(PY3_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
1631
1632 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001633 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001634
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001635 PYTHON_SRC="if_python.c"
1636 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001637 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001638 PYTHON_LIBS=
1639 PYTHON3_SRC="if_python3.c"
1640 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001641 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001642 PYTHON3_LIBS=
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001643elif test "$python_ok" = yes && test "$enable_pythoninterp" = "dynamic"; then
1644 AC_DEFINE(DYNAMIC_PYTHON)
1645 PYTHON_SRC="if_python.c"
1646 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001647 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001648 PYTHON_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001649elif test "$python_ok" = yes; then
1650 dnl Check that adding -fPIE works. It may be needed when using a static
1651 dnl Python library.
1652 AC_MSG_CHECKING([if -fPIE can be added for Python])
1653 cflags_save=$CFLAGS
1654 libs_save=$LIBS
1655 CFLAGS="$CFLAGS $PYTHON_CFLAGS -fPIE"
1656 LIBS="$LIBS $PYTHON_LIBS"
1657 AC_TRY_LINK(,[ ],
1658 AC_MSG_RESULT(yes); fpie_ok=yes,
1659 AC_MSG_RESULT(no); fpie_ok=no)
1660 CFLAGS=$cflags_save
1661 LIBS=$libs_save
1662 if test $fpie_ok = yes; then
1663 PYTHON_CFLAGS="$PYTHON_CFLAGS -fPIE"
1664 fi
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001665elif test "$python3_ok" = yes && test "$enable_python3interp" = "dynamic"; then
1666 AC_DEFINE(DYNAMIC_PYTHON3)
1667 PYTHON3_SRC="if_python3.c"
1668 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001669 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001670 PYTHON3_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001671elif test "$python3_ok" = yes; then
1672 dnl Check that adding -fPIE works. It may be needed when using a static
1673 dnl Python library.
1674 AC_MSG_CHECKING([if -fPIE can be added for Python3])
1675 cflags_save=$CFLAGS
1676 libs_save=$LIBS
1677 CFLAGS="$CFLAGS $PYTHON3_CFLAGS -fPIE"
1678 LIBS="$LIBS $PYTHON3_LIBS"
1679 AC_TRY_LINK(,[ ],
1680 AC_MSG_RESULT(yes); fpie_ok=yes,
1681 AC_MSG_RESULT(no); fpie_ok=no)
1682 CFLAGS=$cflags_save
1683 LIBS=$libs_save
1684 if test $fpie_ok = yes; then
1685 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -fPIE"
1686 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001687fi
1688
Bram Moolenaar071d4272004-06-13 20:20:40 +00001689AC_MSG_CHECKING(--enable-tclinterp argument)
1690AC_ARG_ENABLE(tclinterp,
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001691 [ --enable-tclinterp[=OPTS] Include Tcl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001692 [enable_tclinterp="no"])
1693AC_MSG_RESULT($enable_tclinterp)
1694
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001695if test "$enable_tclinterp" = "yes" -o "$enable_tclinterp" = "dynamic"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001696
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001697 dnl on FreeBSD tclsh is a silly script, look for tclsh8.[5420]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001698 AC_MSG_CHECKING(--with-tclsh argument)
1699 AC_ARG_WITH(tclsh, [ --with-tclsh=PATH which tclsh to use (default: tclsh8.0)],
1700 tclsh_name="$withval"; AC_MSG_RESULT($tclsh_name),
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001701 tclsh_name="tclsh8.5"; AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00001702 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1703 AC_SUBST(vi_cv_path_tcl)
1704
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001705 dnl when no specific version specified, also try 8.4, 8.2 and 8.0
1706 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.5"; then
1707 tclsh_name="tclsh8.4"
1708 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1709 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001710 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.4"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001711 tclsh_name="tclsh8.2"
1712 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1713 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001714 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.2"; then
1715 tclsh_name="tclsh8.0"
1716 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1717 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001718 dnl still didn't find it, try without version number
1719 if test "X$vi_cv_path_tcl" = "X"; then
1720 tclsh_name="tclsh"
1721 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1722 fi
1723 if test "X$vi_cv_path_tcl" != "X"; then
1724 AC_MSG_CHECKING(Tcl version)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001725 if echo 'exit [[expr [info tclversion] < 8.0]]' | "$vi_cv_path_tcl" - ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001726 tclver=`echo 'puts [[info tclversion]]' | $vi_cv_path_tcl -`
1727 AC_MSG_RESULT($tclver - OK);
1728 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 +01001729 tcldll=`echo 'puts libtcl[[info tclversion]][[info sharedlibextension]]' | $vi_cv_path_tcl -`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001730
1731 AC_MSG_CHECKING(for location of Tcl include)
1732 if test "x$MACOSX" != "xyes"; then
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001733 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 +00001734 else
1735 dnl For Mac OS X 10.3, use the OS-provided framework location
1736 tclinc="/System/Library/Frameworks/Tcl.framework/Headers"
1737 fi
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001738 TCL_INC=
Bram Moolenaar071d4272004-06-13 20:20:40 +00001739 for try in $tclinc; do
1740 if test -f "$try/tcl.h"; then
1741 AC_MSG_RESULT($try/tcl.h)
1742 TCL_INC=$try
1743 break
1744 fi
1745 done
1746 if test -z "$TCL_INC"; then
1747 AC_MSG_RESULT(<not found>)
1748 SKIP_TCL=YES
1749 fi
1750 if test -z "$SKIP_TCL"; then
1751 AC_MSG_CHECKING(for location of tclConfig.sh script)
1752 if test "x$MACOSX" != "xyes"; then
1753 tclcnf=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001754 tclcnf="$tclcnf `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001755 else
1756 dnl For Mac OS X 10.3, use the OS-provided framework location
1757 tclcnf="/System/Library/Frameworks/Tcl.framework"
1758 fi
1759 for try in $tclcnf; do
Bram Moolenaar49222be2015-12-11 18:11:30 +01001760 if test -f "$try/tclConfig.sh"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001761 AC_MSG_RESULT($try/tclConfig.sh)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001762 . "$try/tclConfig.sh"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001763 dnl use eval, because tcl 8.2 includes ${TCL_DBGX}
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001764 if test "$enable_tclinterp" = "dynamic"; then
1765 TCL_LIBS=`eval echo "$TCL_STUB_LIB_SPEC $TCL_LIBS"`
1766 else
1767 TCL_LIBS=`eval echo "$TCL_LIB_SPEC $TCL_LIBS"`
1768 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001769 dnl Use $TCL_DEFS for -D_THREAD_SAFE et al. But only use the
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001770 dnl "-D_ABC" items. Watch out for -DFOO=long\ long.
Bram Moolenaar4394bff2008-07-24 11:21:31 +00001771 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 +00001772 break
1773 fi
1774 done
1775 if test -z "$TCL_LIBS"; then
1776 AC_MSG_RESULT(<not found>)
1777 AC_MSG_CHECKING(for Tcl library by myself)
1778 tcllib=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001779 tcllib="$tcllib `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001780 for ext in .so .a ; do
1781 for ver in "" $tclver ; do
1782 for try in $tcllib ; do
1783 trylib=tcl$ver$ext
Bram Moolenaar49222be2015-12-11 18:11:30 +01001784 if test -f "$try/lib$trylib" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001785 AC_MSG_RESULT($try/lib$trylib)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001786 TCL_LIBS="-L\"$try\" -ltcl$ver -ldl -lm"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001787 if test "`(uname) 2>/dev/null`" = SunOS &&
1788 uname -r | grep '^5' >/dev/null; then
1789 TCL_LIBS="$TCL_LIBS -R $try"
1790 fi
1791 break 3
1792 fi
1793 done
1794 done
1795 done
1796 if test -z "$TCL_LIBS"; then
1797 AC_MSG_RESULT(<not found>)
1798 SKIP_TCL=YES
1799 fi
1800 fi
1801 if test -z "$SKIP_TCL"; then
1802 AC_DEFINE(FEAT_TCL)
1803 TCL_SRC=if_tcl.c
1804 TCL_OBJ=objects/if_tcl.o
1805 TCL_PRO=if_tcl.pro
1806 TCL_CFLAGS="-I$TCL_INC $TCL_DEFS"
1807 fi
1808 fi
1809 else
1810 AC_MSG_RESULT(too old; need Tcl version 8.0 or later)
1811 fi
1812 fi
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001813 if test "$enable_tclinterp" = "dynamic"; then
1814 if test "X$TCL_SRC" != "X" -a "X$tcldll" != "X"; then
1815 AC_DEFINE(DYNAMIC_TCL)
1816 TCL_CFLAGS="-DDYNAMIC_TCL_DLL=\\\"$tcldll\\\" -DDYNAMIC_TCL_VER=\\\"$tclver\\\" $TCL_CFLAGS"
1817 fi
1818 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001819 if test "$fail_if_missing" = "yes" -a -z "$TCL_SRC"; then
1820 AC_MSG_ERROR([could not configure Tcl])
1821 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001822fi
1823AC_SUBST(TCL_SRC)
1824AC_SUBST(TCL_OBJ)
1825AC_SUBST(TCL_PRO)
1826AC_SUBST(TCL_CFLAGS)
1827AC_SUBST(TCL_LIBS)
1828
1829AC_MSG_CHECKING(--enable-rubyinterp argument)
1830AC_ARG_ENABLE(rubyinterp,
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001831 [ --enable-rubyinterp[=OPTS] Include Ruby interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001832 [enable_rubyinterp="no"])
1833AC_MSG_RESULT($enable_rubyinterp)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001834if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001835 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1836 AC_MSG_ERROR([cannot use Ruby with tiny or small features])
1837 fi
1838
Bram Moolenaar165641d2010-02-17 16:23:09 +01001839 AC_MSG_CHECKING(--with-ruby-command argument)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001840 AC_SUBST(vi_cv_path_ruby)
Bram Moolenaar948733a2011-05-05 18:10:16 +02001841 AC_ARG_WITH(ruby-command, [ --with-ruby-command=RUBY name of the Ruby command (default: ruby)],
1842 RUBY_CMD="$withval"; vi_cv_path_ruby="$withval"; AC_MSG_RESULT($RUBY_CMD),
1843 RUBY_CMD="ruby"; AC_MSG_RESULT(defaulting to $RUBY_CMD))
Bram Moolenaar165641d2010-02-17 16:23:09 +01001844 AC_PATH_PROG(vi_cv_path_ruby, $RUBY_CMD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001845 if test "X$vi_cv_path_ruby" != "X"; then
1846 AC_MSG_CHECKING(Ruby version)
Bram Moolenaare4efc3b2005-03-07 23:16:51 +00001847 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 +00001848 AC_MSG_RESULT(OK)
Bram Moolenaar81398892012-10-03 21:09:35 +02001849 AC_MSG_CHECKING(Ruby rbconfig)
1850 ruby_rbconfig="RbConfig"
1851 if ! $vi_cv_path_ruby -r rbconfig -e 'RbConfig' >/dev/null 2>/dev/null; then
1852 ruby_rbconfig="Config"
1853 fi
1854 AC_MSG_RESULT($ruby_rbconfig)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001855 AC_MSG_CHECKING(Ruby header files)
Bram Moolenaar81398892012-10-03 21:09:35 +02001856 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 +00001857 if test "X$rubyhdrdir" != "X"; then
1858 AC_MSG_RESULT($rubyhdrdir)
1859 RUBY_CFLAGS="-I$rubyhdrdir"
Bram Moolenaara6fd37b2014-03-27 17:19:09 +01001860 rubyarchdir=`$vi_cv_path_ruby -r rbconfig -e "print ($ruby_rbconfig::CONFIG.has_key? 'rubyarchhdrdir') ? $ruby_rbconfig::CONFIG[['rubyarchhdrdir']] : '$rubyhdrdir/'+$ruby_rbconfig::CONFIG[['arch']]"`
1861 if test -d "$rubyarchdir"; then
1862 RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyarchdir"
Bram Moolenaar165641d2010-02-17 16:23:09 +01001863 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001864 rubyversion=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['ruby_version']].gsub(/\./, '')[[0,2]]"`
Bram Moolenaar026a4452013-08-07 15:22:23 +02001865 if test "X$rubyversion" = "X"; then
1866 rubyversion=`$vi_cv_path_ruby -e "print ((VERSION rescue RUBY_VERSION)).gsub(/\./, '')[[0,2]]"`
1867 fi
Bram Moolenaar165641d2010-02-17 16:23:09 +01001868 RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
Bram Moolenaar81398892012-10-03 21:09:35 +02001869 rubylibs=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LIBS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001870 if test "X$rubylibs" != "X"; then
1871 RUBY_LIBS="$rubylibs"
1872 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001873 librubyarg=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBYARG']])"`
1874 librubya=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBY_A']])"`
Bram Moolenaarac499e32013-06-02 19:14:17 +02001875 rubylibdir=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['libdir']])"`
Bram Moolenaar948733a2011-05-05 18:10:16 +02001876 if test -f "$rubylibdir/$librubya"; then
1877 librubyarg="$librubyarg"
Bram Moolenaarac499e32013-06-02 19:14:17 +02001878 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
1879 elif test "$librubyarg" = "libruby.a"; then
1880 dnl required on Mac OS 10.3 where libruby.a doesn't exist
1881 librubyarg="-lruby"
1882 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001883 fi
1884
1885 if test "X$librubyarg" != "X"; then
1886 RUBY_LIBS="$librubyarg $RUBY_LIBS"
1887 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001888 rubyldflags=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LDFLAGS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001889 if test "X$rubyldflags" != "X"; then
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001890 dnl Ruby on Mac OS X 10.5 adds "-arch" flags but these should only
1891 dnl be included if requested by passing --with-mac-arch to
1892 dnl configure, so strip these flags first (if present)
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001893 rubyldflags=`echo "$rubyldflags" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001894 if test "X$rubyldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001895 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$rubyldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001896 LDFLAGS="$rubyldflags $LDFLAGS"
1897 fi
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001898 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001899 fi
1900 RUBY_SRC="if_ruby.c"
1901 RUBY_OBJ="objects/if_ruby.o"
1902 RUBY_PRO="if_ruby.pro"
1903 AC_DEFINE(FEAT_RUBY)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001904 if test "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar92021622017-10-12 12:33:43 +02001905 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_ALIASES']].split[[0]]"`
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001906 AC_DEFINE(DYNAMIC_RUBY)
Bram Moolenaar92021622017-10-12 12:33:43 +02001907 RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby_soname\\\" -DDYNAMIC_RUBY_VER=$rubyversion $RUBY_CFLAGS"
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001908 RUBY_LIBS=
1909 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001910 else
Bram Moolenaar165641d2010-02-17 16:23:09 +01001911 AC_MSG_RESULT(not found; disabling Ruby)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001912 fi
1913 else
1914 AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
1915 fi
1916 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001917
1918 if test "$fail_if_missing" = "yes" -a -z "$RUBY_OBJ"; then
1919 AC_MSG_ERROR([could not configure Ruby])
1920 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001921fi
1922AC_SUBST(RUBY_SRC)
1923AC_SUBST(RUBY_OBJ)
1924AC_SUBST(RUBY_PRO)
1925AC_SUBST(RUBY_CFLAGS)
1926AC_SUBST(RUBY_LIBS)
1927
1928AC_MSG_CHECKING(--enable-cscope argument)
1929AC_ARG_ENABLE(cscope,
1930 [ --enable-cscope Include cscope interface.], ,
1931 [enable_cscope="no"])
1932AC_MSG_RESULT($enable_cscope)
1933if test "$enable_cscope" = "yes"; then
1934 AC_DEFINE(FEAT_CSCOPE)
1935fi
1936
1937AC_MSG_CHECKING(--enable-workshop argument)
1938AC_ARG_ENABLE(workshop,
1939 [ --enable-workshop Include Sun Visual Workshop support.], ,
1940 [enable_workshop="no"])
1941AC_MSG_RESULT($enable_workshop)
1942if test "$enable_workshop" = "yes"; then
1943 AC_DEFINE(FEAT_SUN_WORKSHOP)
1944 WORKSHOP_SRC="workshop.c integration.c"
1945 AC_SUBST(WORKSHOP_SRC)
1946 WORKSHOP_OBJ="objects/workshop.o objects/integration.o"
1947 AC_SUBST(WORKSHOP_OBJ)
1948 if test "${enable_gui-xxx}" = xxx; then
1949 enable_gui=motif
1950 fi
1951fi
1952
1953AC_MSG_CHECKING(--disable-netbeans argument)
1954AC_ARG_ENABLE(netbeans,
1955 [ --disable-netbeans Disable NetBeans integration support.],
1956 , [enable_netbeans="yes"])
1957if test "$enable_netbeans" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01001958 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1959 AC_MSG_RESULT([cannot use NetBeans with tiny or small features])
1960 enable_netbeans="no"
1961 else
1962 AC_MSG_RESULT(no)
1963 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01001964else
1965 AC_MSG_RESULT(yes)
1966fi
1967
1968AC_MSG_CHECKING(--disable-channel argument)
1969AC_ARG_ENABLE(channel,
Bram Moolenaar8008b632017-07-18 21:33:20 +02001970 [ --disable-channel Disable process communication support.],
Bram Moolenaare0874f82016-01-24 20:36:41 +01001971 , [enable_channel="yes"])
1972if test "$enable_channel" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01001973 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1974 AC_MSG_RESULT([cannot use channels with tiny or small features])
1975 enable_channel="no"
1976 else
1977 AC_MSG_RESULT(no)
1978 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01001979else
1980 if test "$enable_netbeans" = "yes"; then
Bram Moolenaar16435482016-01-24 21:31:54 +01001981 AC_MSG_RESULT([yes, netbeans also disabled])
Bram Moolenaare0874f82016-01-24 20:36:41 +01001982 enable_netbeans="no"
1983 else
1984 AC_MSG_RESULT(yes)
1985 fi
1986fi
1987
Bram Moolenaar16435482016-01-24 21:31:54 +01001988if test "$enable_channel" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001989 dnl On Solaris we need the socket and nsl library.
1990 AC_CHECK_LIB(socket, socket)
1991 AC_CHECK_LIB(nsl, gethostbyname)
Bram Moolenaare0874f82016-01-24 20:36:41 +01001992 AC_MSG_CHECKING(whether compiling with process communication is possible)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001993 AC_TRY_LINK([
1994#include <stdio.h>
1995#include <stdlib.h>
1996#include <stdarg.h>
1997#include <fcntl.h>
1998#include <netdb.h>
1999#include <netinet/in.h>
2000#include <errno.h>
2001#include <sys/types.h>
2002#include <sys/socket.h>
2003 /* Check bitfields */
2004 struct nbbuf {
2005 unsigned int initDone:1;
Bram Moolenaar63de19e2016-12-09 20:11:26 +01002006 unsigned short signmaplen;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002007 };
2008 ], [
2009 /* Check creating a socket. */
2010 struct sockaddr_in server;
2011 (void)socket(AF_INET, SOCK_STREAM, 0);
2012 (void)htons(100);
2013 (void)gethostbyname("microsoft.com");
2014 if (errno == ECONNREFUSED)
2015 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
2016 ],
2017 AC_MSG_RESULT(yes),
Bram Moolenaare0874f82016-01-24 20:36:41 +01002018 AC_MSG_RESULT(no); enable_netbeans="no"; enable_channel="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00002019fi
2020if test "$enable_netbeans" = "yes"; then
2021 AC_DEFINE(FEAT_NETBEANS_INTG)
2022 NETBEANS_SRC="netbeans.c"
2023 AC_SUBST(NETBEANS_SRC)
2024 NETBEANS_OBJ="objects/netbeans.o"
2025 AC_SUBST(NETBEANS_OBJ)
2026fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002027if test "$enable_channel" = "yes"; then
Bram Moolenaar509ce2a2016-03-11 22:52:15 +01002028 AC_DEFINE(FEAT_JOB_CHANNEL)
Bram Moolenaare0874f82016-01-24 20:36:41 +01002029 CHANNEL_SRC="channel.c"
2030 AC_SUBST(CHANNEL_SRC)
2031 CHANNEL_OBJ="objects/channel.o"
2032 AC_SUBST(CHANNEL_OBJ)
2033fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002034
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002035AC_MSG_CHECKING(--enable-terminal argument)
2036AC_ARG_ENABLE(terminal,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002037 [ --enable-terminal Enable terminal emulation support.],
Bram Moolenaaref839562017-10-28 20:28:23 +02002038 , [enable_terminal="auto"])
Bram Moolenaar595a4022017-09-03 19:15:57 +02002039if test "$enable_terminal" = "yes" || test "$enable_terminal" = "auto" -a "x$features" = "xhuge" ; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002040 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2041 AC_MSG_RESULT([cannot use terminal emulator with tiny or small features])
2042 enable_terminal="no"
2043 else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002044 if test "$enable_terminal" = "auto"; then
2045 enable_terminal="yes"
2046 AC_MSG_RESULT(defaulting to yes)
2047 else
2048 AC_MSG_RESULT(yes)
2049 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002050 fi
2051else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002052 if test "$enable_terminal" = "auto"; then
2053 enable_terminal="no"
2054 AC_MSG_RESULT(defaulting to no)
2055 else
2056 AC_MSG_RESULT(no)
2057 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002058fi
2059if test "$enable_terminal" = "yes"; then
2060 AC_DEFINE(FEAT_TERMINAL)
2061 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"
2062 AC_SUBST(TERM_SRC)
2063 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"
2064 AC_SUBST(TERM_OBJ)
2065fi
2066
Bram Moolenaar071d4272004-06-13 20:20:40 +00002067AC_MSG_CHECKING(--enable-multibyte argument)
2068AC_ARG_ENABLE(multibyte,
2069 [ --enable-multibyte Include multibyte editing support.], ,
2070 [enable_multibyte="no"])
2071AC_MSG_RESULT($enable_multibyte)
2072if test "$enable_multibyte" = "yes"; then
2073 AC_DEFINE(FEAT_MBYTE)
2074fi
2075
2076AC_MSG_CHECKING(--enable-hangulinput argument)
2077AC_ARG_ENABLE(hangulinput,
2078 [ --enable-hangulinput Include Hangul input support.], ,
2079 [enable_hangulinput="no"])
2080AC_MSG_RESULT($enable_hangulinput)
2081
2082AC_MSG_CHECKING(--enable-xim argument)
2083AC_ARG_ENABLE(xim,
2084 [ --enable-xim Include XIM input support.],
2085 AC_MSG_RESULT($enable_xim),
2086 [enable_xim="auto"; AC_MSG_RESULT(defaulting to auto)])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002087
2088AC_MSG_CHECKING(--enable-fontset argument)
2089AC_ARG_ENABLE(fontset,
2090 [ --enable-fontset Include X fontset output support.], ,
2091 [enable_fontset="no"])
2092AC_MSG_RESULT($enable_fontset)
2093dnl defining FEAT_XFONTSET is delayed, so that it can be disabled for no GUI
2094
2095test -z "$with_x" && with_x=yes
2096test "${enable_gui-yes}" != no -a "x$MACOSX" != "xyes" -a "x$QNX" != "xyes" && with_x=yes
2097if test "$with_x" = no; then
2098 AC_MSG_RESULT(defaulting to: don't HAVE_X11)
2099else
2100 dnl Do this check early, so that its failure can override user requests.
2101
2102 AC_PATH_PROG(xmkmfpath, xmkmf)
2103
2104 AC_PATH_XTRA
2105
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002106 dnl On z/OS Unix the X libraries are DLLs. To use them the code must
Bram Moolenaar071d4272004-06-13 20:20:40 +00002107 dnl be compiled with a special option.
2108 dnl Also add SM, ICE and Xmu to X_EXTRA_LIBS.
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002109 if test "$zOSUnix" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002110 CFLAGS="$CFLAGS -W c,dll"
2111 LDFLAGS="$LDFLAGS -W l,dll"
2112 X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE -lXmu"
2113 fi
2114
2115 dnl On my HPUX system the X include dir is found, but the lib dir not.
2116 dnl This is a desparate try to fix this.
2117
2118 if test -d "$x_includes" && test ! -d "$x_libraries"; then
2119 x_libraries=`echo "$x_includes" | sed s/include/lib/`
2120 AC_MSG_RESULT(Corrected X libraries to $x_libraries)
2121 X_LIBS="$X_LIBS -L$x_libraries"
2122 if test "`(uname) 2>/dev/null`" = SunOS &&
2123 uname -r | grep '^5' >/dev/null; then
2124 X_LIBS="$X_LIBS -R $x_libraries"
2125 fi
2126 fi
2127
2128 if test -d "$x_libraries" && test ! -d "$x_includes"; then
2129 x_includes=`echo "$x_libraries" | sed s/lib/include/`
2130 AC_MSG_RESULT(Corrected X includes to $x_includes)
2131 X_CFLAGS="$X_CFLAGS -I$x_includes"
2132 fi
2133
2134 dnl Remove "-I/usr/include " from X_CFLAGS, should not be needed.
2135 X_CFLAGS="`echo $X_CFLAGS\ | sed 's%-I/usr/include %%'`"
2136 dnl Remove "-L/usr/lib " from X_LIBS, should not be needed.
2137 X_LIBS="`echo $X_LIBS\ | sed 's%-L/usr/lib %%'`"
2138 dnl Same for "-R/usr/lib ".
2139 X_LIBS="`echo $X_LIBS\ | sed -e 's%-R/usr/lib %%' -e 's%-R /usr/lib %%'`"
2140
2141
2142 dnl Check if the X11 header files are correctly installed. On some systems
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002143 dnl Xlib.h includes files that don't exist. On some systems X11/Intrinsic.h
2144 dnl is missing.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002145 AC_MSG_CHECKING(if X11 header files can be found)
2146 cflags_save=$CFLAGS
2147 CFLAGS="$CFLAGS $X_CFLAGS"
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002148 AC_TRY_COMPILE([#include <X11/Xlib.h>
2149#include <X11/Intrinsic.h>], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002150 AC_MSG_RESULT(yes),
2151 AC_MSG_RESULT(no); no_x=yes)
2152 CFLAGS=$cflags_save
2153
2154 if test "${no_x-no}" = yes; then
2155 with_x=no
2156 else
2157 AC_DEFINE(HAVE_X11)
2158 X_LIB="-lXt -lX11";
2159 AC_SUBST(X_LIB)
2160
2161 ac_save_LDFLAGS="$LDFLAGS"
2162 LDFLAGS="-L$x_libraries $LDFLAGS"
2163
2164 dnl Check for -lXdmcp (needed on SunOS 4.1.4)
2165 dnl For HP-UX 10.20 it must be before -lSM -lICE
2166 AC_CHECK_LIB(Xdmcp, _XdmcpAuthDoIt, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lXdmcp"],,
2167 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXdmcp])
2168
2169 dnl Some systems need -lnsl -lsocket when testing for ICE.
2170 dnl The check above doesn't do this, try here (again). Also needed to get
2171 dnl them after Xdmcp. link.sh will remove them when not needed.
2172 dnl Check for other function than above to avoid the cached value
2173 AC_CHECK_LIB(ICE, IceOpenConnection,
2174 [X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE"],, [$X_EXTRA_LIBS])
2175
2176 dnl Check for -lXpm (needed for some versions of Motif)
2177 LDFLAGS="$X_LIBS $ac_save_LDFLAGS"
2178 AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [X_PRE_LIBS="$X_PRE_LIBS -lXpm"],,
2179 [-lXt $X_PRE_LIBS -lXpm -lX11 $X_EXTRA_LIBS])
2180
2181 dnl Check that the X11 header files don't use implicit declarations
2182 AC_MSG_CHECKING(if X11 header files implicitly declare return values)
2183 cflags_save=$CFLAGS
Bram Moolenaard1864592013-05-04 04:40:15 +02002184 dnl -Werror is GCC only, others like Solaris Studio might not like it
2185 if test "$GCC" = yes; then
2186 CFLAGS="$CFLAGS $X_CFLAGS -Werror"
2187 else
2188 CFLAGS="$CFLAGS $X_CFLAGS"
2189 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002190 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2191 AC_MSG_RESULT(no),
2192 CFLAGS="$CFLAGS -Wno-implicit-int"
2193 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2194 AC_MSG_RESULT(yes); cflags_save="$cflags_save -Wno-implicit-int",
2195 AC_MSG_RESULT(test failed)
2196 )
2197 )
2198 CFLAGS=$cflags_save
2199
2200 LDFLAGS="$ac_save_LDFLAGS"
2201
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002202 AC_MSG_CHECKING(size of wchar_t is 2 bytes)
2203 AC_CACHE_VAL(ac_cv_small_wchar_t,
2204 [AC_TRY_RUN([
2205#include <X11/Xlib.h>
2206#if STDC_HEADERS
2207# include <stdlib.h>
2208# include <stddef.h>
2209#endif
2210 main()
2211 {
2212 if (sizeof(wchar_t) <= 2)
2213 exit(1);
2214 exit(0);
2215 }],
2216 ac_cv_small_wchar_t="no",
2217 ac_cv_small_wchar_t="yes",
2218 AC_MSG_ERROR(failed to compile test program))])
2219 AC_MSG_RESULT($ac_cv_small_wchar_t)
2220 if test "x$ac_cv_small_wchar_t" = "xyes" ; then
2221 AC_DEFINE(SMALL_WCHAR_T)
2222 fi
2223
Bram Moolenaar071d4272004-06-13 20:20:40 +00002224 fi
2225fi
2226
Bram Moolenaara7fc0102005-05-18 22:17:12 +00002227test "x$with_x" = xno -a "x$MACOSX" != "xyes" -a "x$QNX" != "xyes" && enable_gui=no
Bram Moolenaar071d4272004-06-13 20:20:40 +00002228
2229AC_MSG_CHECKING(--enable-gui argument)
2230AC_ARG_ENABLE(gui,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002231 [ --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 +00002232
2233dnl Canonicalize the --enable-gui= argument so that it can be easily compared.
2234dnl Do not use character classes for portability with old tools.
2235enable_gui_canon=`echo "_$enable_gui" | \
2236 sed 's/[[ _+-]]//g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
2237
2238dnl Skip everything by default.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002239SKIP_GTK2=YES
Bram Moolenaar1858a842016-02-23 22:30:31 +01002240SKIP_GTK3=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002241SKIP_GNOME=YES
2242SKIP_MOTIF=YES
2243SKIP_ATHENA=YES
2244SKIP_NEXTAW=YES
2245SKIP_PHOTON=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002246SKIP_CARBON=YES
2247GUITYPE=NONE
2248
Bram Moolenaarb11160e2005-01-04 21:31:43 +00002249if test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002250 SKIP_PHOTON=
2251 case "$enable_gui_canon" in
2252 no) AC_MSG_RESULT(no GUI support)
2253 SKIP_PHOTON=YES ;;
2254 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
2255 auto) AC_MSG_RESULT(auto - automatic GUI support) ;;
2256 photon) AC_MSG_RESULT(Photon GUI support) ;;
2257 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2258 SKIP_PHOTON=YES ;;
2259 esac
2260
2261elif test "x$MACOSX" = "xyes" -a "x$with_x" = "xno" ; then
2262 SKIP_CARBON=
2263 case "$enable_gui_canon" in
2264 no) AC_MSG_RESULT(no GUI support)
2265 SKIP_CARBON=YES ;;
2266 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
Bram Moolenaar164fca32010-07-14 13:58:07 +02002267 auto) AC_MSG_RESULT(auto - Carbon GUI is outdated - disable GUI support)
2268 SKIP_CARBON=YES ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002269 carbon) AC_MSG_RESULT(Carbon GUI support) ;;
2270 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2271 SKIP_CARBON=YES ;;
2272 esac
2273
2274else
2275
Bram Moolenaar071d4272004-06-13 20:20:40 +00002276 case "$enable_gui_canon" in
2277 no|none) AC_MSG_RESULT(no GUI support) ;;
2278 yes|""|auto) AC_MSG_RESULT(yes/auto - automatic GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002279 SKIP_GTK2=
2280 SKIP_GNOME=
2281 SKIP_MOTIF=
2282 SKIP_ATHENA=
2283 SKIP_NEXTAW=
2284 SKIP_CARBON=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002285 gtk2) AC_MSG_RESULT(GTK+ 2.x GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002286 SKIP_GTK2=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002287 gnome2) AC_MSG_RESULT(GNOME 2.x GUI support)
2288 SKIP_GNOME=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002289 SKIP_GTK2=;;
Bram Moolenaar98921892016-02-23 17:14:37 +01002290 gtk3) AC_MSG_RESULT(GTK+ 3.x GUI support)
2291 SKIP_GTK3=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002292 motif) AC_MSG_RESULT(Motif GUI support)
2293 SKIP_MOTIF=;;
2294 athena) AC_MSG_RESULT(Athena GUI support)
2295 SKIP_ATHENA=;;
2296 nextaw) AC_MSG_RESULT(neXtaw GUI support)
2297 SKIP_NEXTAW=;;
2298 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
2299 esac
2300
2301fi
2302
Bram Moolenaar071d4272004-06-13 20:20:40 +00002303if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \
2304 -a "$enable_gui_canon" != "gnome2"; then
2305 AC_MSG_CHECKING(whether or not to look for GTK+ 2)
2306 AC_ARG_ENABLE(gtk2-check,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002307 [ --enable-gtk2-check If auto-select GUI, check for GTK+ 2 [default=yes]],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002308 , enable_gtk2_check="yes")
2309 AC_MSG_RESULT($enable_gtk2_check)
2310 if test "x$enable_gtk2_check" = "xno"; then
2311 SKIP_GTK2=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002312 SKIP_GNOME=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002313 fi
2314fi
2315
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002316if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002317 AC_MSG_CHECKING(whether or not to look for GNOME)
2318 AC_ARG_ENABLE(gnome-check,
2319 [ --enable-gnome-check If GTK GUI, check for GNOME [default=no]],
2320 , enable_gnome_check="no")
2321 AC_MSG_RESULT($enable_gnome_check)
2322 if test "x$enable_gnome_check" = "xno"; then
2323 SKIP_GNOME=YES
2324 fi
2325fi
2326
Bram Moolenaar98921892016-02-23 17:14:37 +01002327if test "x$SKIP_GTK3" != "xYES" -a "$enable_gui_canon" != "gtk3"; then
2328 AC_MSG_CHECKING(whether or not to look for GTK+ 3)
2329 AC_ARG_ENABLE(gtk3-check,
2330 [ --enable-gtk3-check If auto-select GUI, check for GTK+ 3 [default=yes]],
2331 , enable_gtk3_check="yes")
2332 AC_MSG_RESULT($enable_gtk3_check)
2333 if test "x$enable_gtk3_check" = "xno"; then
2334 SKIP_GTK3=YES
2335 fi
2336fi
2337
Bram Moolenaar071d4272004-06-13 20:20:40 +00002338if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then
2339 AC_MSG_CHECKING(whether or not to look for Motif)
2340 AC_ARG_ENABLE(motif-check,
2341 [ --enable-motif-check If auto-select GUI, check for Motif [default=yes]],
2342 , enable_motif_check="yes")
2343 AC_MSG_RESULT($enable_motif_check)
2344 if test "x$enable_motif_check" = "xno"; then
2345 SKIP_MOTIF=YES
2346 fi
2347fi
2348
2349if test "x$SKIP_ATHENA" != "xYES" -a "$enable_gui_canon" != "athena"; then
2350 AC_MSG_CHECKING(whether or not to look for Athena)
2351 AC_ARG_ENABLE(athena-check,
2352 [ --enable-athena-check If auto-select GUI, check for Athena [default=yes]],
2353 , enable_athena_check="yes")
2354 AC_MSG_RESULT($enable_athena_check)
2355 if test "x$enable_athena_check" = "xno"; then
2356 SKIP_ATHENA=YES
2357 fi
2358fi
2359
2360if test "x$SKIP_NEXTAW" != "xYES" -a "$enable_gui_canon" != "nextaw"; then
2361 AC_MSG_CHECKING(whether or not to look for neXtaw)
2362 AC_ARG_ENABLE(nextaw-check,
2363 [ --enable-nextaw-check If auto-select GUI, check for neXtaw [default=yes]],
2364 , enable_nextaw_check="yes")
2365 AC_MSG_RESULT($enable_nextaw_check);
2366 if test "x$enable_nextaw_check" = "xno"; then
2367 SKIP_NEXTAW=YES
2368 fi
2369fi
2370
2371if test "x$SKIP_CARBON" != "xYES" -a "$enable_gui_canon" != "carbon"; then
2372 AC_MSG_CHECKING(whether or not to look for Carbon)
2373 AC_ARG_ENABLE(carbon-check,
2374 [ --enable-carbon-check If auto-select GUI, check for Carbon [default=yes]],
2375 , enable_carbon_check="yes")
2376 AC_MSG_RESULT($enable_carbon_check);
2377 if test "x$enable_carbon_check" = "xno"; then
2378 SKIP_CARBON=YES
2379 fi
2380fi
2381
Bram Moolenaar843ee412004-06-30 16:16:41 +00002382
Bram Moolenaar071d4272004-06-13 20:20:40 +00002383if test "x$MACOSX" = "xyes" -a -z "$SKIP_CARBON" -a "x$CARBON" = "xyes"; then
2384 AC_MSG_CHECKING(for Carbon GUI)
Bram Moolenaar14716812006-05-04 21:54:08 +00002385 dnl already did the check, just give the message
Bram Moolenaar071d4272004-06-13 20:20:40 +00002386 AC_MSG_RESULT(yes);
2387 GUITYPE=CARBONGUI
Bram Moolenaare344bea2005-09-01 20:46:49 +00002388 if test "$VIMNAME" = "vim"; then
2389 VIMNAME=Vim
2390 fi
Bram Moolenaar14716812006-05-04 21:54:08 +00002391
Bram Moolenaar164fca32010-07-14 13:58:07 +02002392 if test "x$MACARCH" = "xboth"; then
2393 CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk/Developer/Headers/FlatCarbon"
2394 else
2395 CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/Headers/FlatCarbon"
2396 fi
2397
Bram Moolenaar14716812006-05-04 21:54:08 +00002398 dnl Default install directory is not /usr/local
2399 if test x$prefix = xNONE; then
2400 prefix=/Applications
2401 fi
2402
2403 dnl Sorry for the hard coded default
2404 datadir='${prefix}/Vim.app/Contents/Resources'
2405
Bram Moolenaar071d4272004-06-13 20:20:40 +00002406 dnl skip everything else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002407 SKIP_GTK2=YES;
2408 SKIP_GNOME=YES;
2409 SKIP_MOTIF=YES;
2410 SKIP_ATHENA=YES;
2411 SKIP_NEXTAW=YES;
2412 SKIP_PHOTON=YES;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002413 SKIP_CARBON=YES
2414fi
2415
Bram Moolenaar071d4272004-06-13 20:20:40 +00002416dnl define an autoconf function to check for a specified version of GTK, and
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002417dnl try to compile/link a GTK program.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002418dnl
2419dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002420dnl Test for GTK, and define GTK_CFLAGS, GTK_LIBDIR and GTK_LIBS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002421dnl
2422AC_DEFUN(AM_PATH_GTK,
2423[
2424 if test "X$GTK_CONFIG" != "Xno" -o "X$PKG_CONFIG" != "Xno"; then
2425 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00002426 no_gtk=""
2427 if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2428 && $PKG_CONFIG --exists gtk+-2.0; then
2429 {
Bram Moolenaar98921892016-02-23 17:14:37 +01002430 min_gtk_version=ifelse([$1], ,2.2.0,$1)
2431 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002432 dnl We should be using PKG_CHECK_MODULES() instead of this hack.
2433 dnl But I guess the dependency on pkgconfig.m4 is not wanted or
2434 dnl something like that.
2435 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0`
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002436 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-2.0`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002437 GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0`
2438 gtk_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2439 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2440 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2441 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2442 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2443 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2444 }
Bram Moolenaar98921892016-02-23 17:14:37 +01002445 elif (test "X$SKIP_GTK3" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2446 && $PKG_CONFIG --exists gtk+-3.0; then
2447 {
2448 min_gtk_version=ifelse([$1], ,3.0.0,$1)
2449 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
2450
2451 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-3.0`
2452 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-3.0`
2453 GTK_LIBS=`$PKG_CONFIG --libs gtk+-3.0`
2454 gtk_major_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2455 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2456 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2457 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2458 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2459 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2460 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002461 else
2462 no_gtk=yes
2463 fi
2464
2465 if test "x$enable_gtktest" = "xyes" -a "x$no_gtk" = "x"; then
2466 {
2467 ac_save_CFLAGS="$CFLAGS"
2468 ac_save_LIBS="$LIBS"
2469 CFLAGS="$CFLAGS $GTK_CFLAGS"
2470 LIBS="$LIBS $GTK_LIBS"
2471
2472 dnl
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002473 dnl Now check if the installed GTK is sufficiently new.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002474 dnl
2475 rm -f conf.gtktest
2476 AC_TRY_RUN([
2477#include <gtk/gtk.h>
2478#include <stdio.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00002479#if STDC_HEADERS
2480# include <stdlib.h>
2481# include <stddef.h>
2482#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002483
2484int
2485main ()
2486{
2487int major, minor, micro;
2488char *tmp_version;
2489
2490system ("touch conf.gtktest");
2491
2492/* HP/UX 9 (%@#!) writes to sscanf strings */
2493tmp_version = g_strdup("$min_gtk_version");
2494if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
2495 printf("%s, bad version string\n", "$min_gtk_version");
2496 exit(1);
2497 }
2498
2499if ((gtk_major_version > major) ||
2500 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
2501 ((gtk_major_version == major) && (gtk_minor_version == minor) &&
2502 (gtk_micro_version >= micro)))
2503{
2504 return 0;
2505}
2506return 1;
2507}
2508],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
2509 CFLAGS="$ac_save_CFLAGS"
2510 LIBS="$ac_save_LIBS"
2511 }
2512 fi
2513 if test "x$no_gtk" = x ; then
2514 if test "x$enable_gtktest" = "xyes"; then
2515 AC_MSG_RESULT(yes; found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2516 else
2517 AC_MSG_RESULT(found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2518 fi
2519 ifelse([$2], , :, [$2])
2520 else
2521 {
2522 AC_MSG_RESULT(no)
2523 GTK_CFLAGS=""
2524 GTK_LIBS=""
2525 ifelse([$3], , :, [$3])
2526 }
2527 fi
2528 }
2529 else
2530 GTK_CFLAGS=""
2531 GTK_LIBS=""
2532 ifelse([$3], , :, [$3])
2533 fi
2534 AC_SUBST(GTK_CFLAGS)
2535 AC_SUBST(GTK_LIBS)
2536 rm -f conf.gtktest
2537])
2538
2539dnl ---------------------------------------------------------------------------
2540dnl gnome
2541dnl ---------------------------------------------------------------------------
2542AC_DEFUN([GNOME_INIT_HOOK],
2543[
2544 AC_SUBST(GNOME_LIBS)
2545 AC_SUBST(GNOME_LIBDIR)
2546 AC_SUBST(GNOME_INCLUDEDIR)
2547
2548 AC_ARG_WITH(gnome-includes,
2549 [ --with-gnome-includes=DIR Specify location of GNOME headers],
2550 [CFLAGS="$CFLAGS -I$withval"]
2551 )
2552
2553 AC_ARG_WITH(gnome-libs,
2554 [ --with-gnome-libs=DIR Specify location of GNOME libs],
2555 [LDFLAGS="$LDFLAGS -L$withval" gnome_prefix=$withval]
2556 )
2557
2558 AC_ARG_WITH(gnome,
2559 [ --with-gnome Specify prefix for GNOME files],
2560 if test x$withval = xyes; then
2561 want_gnome=yes
2562 ifelse([$1], [], :, [$1])
2563 else
2564 if test "x$withval" = xno; then
2565 want_gnome=no
2566 else
2567 want_gnome=yes
2568 LDFLAGS="$LDFLAGS -L$withval/lib"
2569 CFLAGS="$CFLAGS -I$withval/include"
2570 gnome_prefix=$withval/lib
2571 fi
2572 fi,
2573 want_gnome=yes)
2574
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002575 if test "x$want_gnome" = xyes; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002576 {
2577 AC_MSG_CHECKING(for libgnomeui-2.0)
2578 if $PKG_CONFIG --exists libgnomeui-2.0; then
2579 AC_MSG_RESULT(yes)
2580 GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0`
2581 GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0`
2582 GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0`
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002583
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002584 dnl On FreeBSD we need -pthread but pkg-config doesn't include it.
2585 dnl This might not be the right way but it works for me...
2586 AC_MSG_CHECKING(for FreeBSD)
2587 if test "`(uname) 2>/dev/null`" = FreeBSD; then
2588 AC_MSG_RESULT(yes, adding -pthread)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002589 GNOME_INCLUDEDIR="$GNOME_INCLUDEDIR -D_THREAD_SAFE"
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002590 GNOME_LIBS="$GNOME_LIBS -pthread"
2591 else
2592 AC_MSG_RESULT(no)
2593 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002594 $1
2595 else
2596 AC_MSG_RESULT(not found)
2597 if test "x$2" = xfail; then
2598 AC_MSG_ERROR(Could not find libgnomeui-2.0 via pkg-config)
2599 fi
2600 fi
2601 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002602 fi
2603])
2604
2605AC_DEFUN([GNOME_INIT],[
2606 GNOME_INIT_HOOK([],fail)
2607])
2608
2609
2610dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002611dnl Check for GTK2. If it fails, then continue on for Motif as before...
Bram Moolenaar071d4272004-06-13 20:20:40 +00002612dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002613if test -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002614
2615 AC_MSG_CHECKING(--disable-gtktest argument)
2616 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2617 , enable_gtktest=yes)
2618 if test "x$enable_gtktest" = "xyes" ; then
2619 AC_MSG_RESULT(gtk test enabled)
2620 else
2621 AC_MSG_RESULT(gtk test disabled)
2622 fi
2623
Bram Moolenaar071d4272004-06-13 20:20:40 +00002624 if test "X$PKG_CONFIG" = "X"; then
2625 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
2626 fi
2627
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002628 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002629 dnl First try finding version 2.2.0 or later. The 2.0.x series has
2630 dnl problems (bold fonts, --remote doesn't work).
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002631 AM_PATH_GTK(2.2.0,
2632 [GUI_LIB_LOC="$GTK_LIBDIR"
2633 GTK_LIBNAME="$GTK_LIBS"
2634 GUI_INC_LOC="$GTK_CFLAGS"], )
2635 if test "x$GTK_CFLAGS" != "x"; then
Bram Moolenaar98921892016-02-23 17:14:37 +01002636 SKIP_GTK3=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002637 SKIP_ATHENA=YES
2638 SKIP_NEXTAW=YES
2639 SKIP_MOTIF=YES
2640 GUITYPE=GTK
2641 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002642 fi
2643 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002644 if test "x$GUITYPE" = "xGTK"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002645 dnl
2646 dnl if GTK exists, then check for GNOME.
2647 dnl
2648 if test -z "$SKIP_GNOME"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002649 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002650 GNOME_INIT_HOOK([have_gnome=yes])
2651 if test "x$have_gnome" = xyes ; then
2652 AC_DEFINE(FEAT_GUI_GNOME)
2653 GUI_INC_LOC="$GUI_INC_LOC $GNOME_INCLUDEDIR"
2654 GTK_LIBNAME="$GTK_LIBNAME $GNOME_LIBDIR $GNOME_LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002655 fi
2656 }
2657 fi
2658 fi
2659fi
2660
Bram Moolenaar98921892016-02-23 17:14:37 +01002661
2662dnl ---------------------------------------------------------------------------
2663dnl Check for GTK3.
2664dnl ---------------------------------------------------------------------------
2665if test -z "$SKIP_GTK3"; then
2666
2667 AC_MSG_CHECKING(--disable-gtktest argument)
2668 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2669 , enable_gtktest=yes)
2670 if test "x$enable_gtktest" = "xyes" ; then
2671 AC_MSG_RESULT(gtk test enabled)
2672 else
2673 AC_MSG_RESULT(gtk test disabled)
2674 fi
2675
2676 if test "X$PKG_CONFIG" = "X"; then
2677 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
2678 fi
2679
2680 if test "x$PKG_CONFIG" != "xno"; then
2681 AM_PATH_GTK(3.0.0,
2682 [GUI_LIB_LOC="$GTK_LIBDIR"
2683 GTK_LIBNAME="$GTK_LIBS"
2684 GUI_INC_LOC="$GTK_CFLAGS"], )
2685 if test "x$GTK_CFLAGS" != "x"; then
2686 SKIP_GTK2=YES
2687 SKIP_GNOME=YES
2688 SKIP_ATHENA=YES
2689 SKIP_NEXTAW=YES
2690 SKIP_MOTIF=YES
2691 GUITYPE=GTK
2692 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar98921892016-02-23 17:14:37 +01002693 AC_DEFINE(USE_GTK3)
2694 fi
2695 fi
2696fi
2697
Bram Moolenaard2e03f02016-01-02 22:46:36 +01002698dnl Check the version of Gdk-Pixbuf. If the version is 2.31 or later and
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002699dnl glib-compile-resources is found in PATH, use GResource.
2700if test "x$GUITYPE" = "xGTK"; then
2701 AC_MSG_CHECKING([version of Gdk-Pixbuf])
2702 gdk_pixbuf_version=`$PKG_CONFIG --modversion gdk-pixbuf-2.0`
2703 if test "x$gdk_pixbuf_version" != x ; then
2704 gdk_pixbuf_version_minor=`echo $gdk_pixbuf_version | \
2705 sed -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/'`
2706 if test "x$gdk_pixbuf_version_minor" != x -a \
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002707 $gdk_pixbuf_version_minor -ge 31 ; then
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002708 AC_MSG_RESULT([OK.])
2709 AC_PATH_PROG(GLIB_COMPILE_RESOURCES,[glib-compile-resources],no)
2710 AC_MSG_CHECKING([glib-compile-resources])
2711 if test "x$GLIB_COMPILE_RESOURCES" = xno ; then
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002712 GLIB_COMPILE_RESOURCES=""
2713 AC_MSG_RESULT([cannot be found in PATH.])
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002714 else
2715 AC_MSG_RESULT([usable.])
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002716 AC_DEFINE(USE_GRESOURCE)
2717 GRESOURCE_SRC="auto/gui_gtk_gresources.c"
2718 GRESOURCE_OBJ="objects/gui_gtk_gresources.o"
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002719 fi
2720 else
2721 AC_MSG_RESULT([not usable.])
2722 fi
2723 else
2724 AC_MSG_RESULT([cannot obtain from pkg_config.])
2725 fi
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002726
2727 AC_MSG_CHECKING([--disable-icon-cache-update argument])
2728 AC_ARG_ENABLE(icon_cache_update,
2729 [ --disable-icon-cache-update update disabled],
2730 [],
2731 [enable_icon_cache_update="yes"])
2732 if test "$enable_icon_cache_update" = "yes"; then
2733 AC_MSG_RESULT([not set])
2734 AC_PATH_PROG(GTK_UPDATE_ICON_CACHE,[gtk-update-icon-cache],no)
2735 if test "x$GTK_UPDATE_ICON_CACHE" = "xno" ; then
2736 AC_MSG_RESULT([not found in PATH.])
2737 fi
2738 else
2739 AC_MSG_RESULT([update disabled])
2740 fi
2741
2742 AC_MSG_CHECKING([--disable-desktop-database-update argument])
2743 AC_ARG_ENABLE(desktop_database_update,
2744 [ --disable-desktop-database-update update disabled],
2745 [],
2746 [enable_desktop_database_update="yes"])
2747 if test "$enable_desktop_database_update" = "yes"; then
2748 AC_MSG_RESULT([not set])
2749 AC_PATH_PROG(UPDATE_DESKTOP_DATABASE,[update-desktop-database],no)
2750 if test "x$UPDATE_DESKTOP_DATABASE" = "xno" ; then
2751 AC_MSG_RESULT([not found in PATH.])
2752 fi
2753 else
2754 AC_MSG_RESULT([update disabled])
2755 fi
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002756fi
2757AC_SUBST(GLIB_COMPILE_RESOURCES)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002758AC_SUBST(GRESOURCE_SRC)
2759AC_SUBST(GRESOURCE_OBJ)
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002760AC_SUBST(GTK_UPDATE_ICON_CACHE)
2761AC_SUBST(UPDATE_DESKTOP_DATABASE)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002762
Bram Moolenaar071d4272004-06-13 20:20:40 +00002763dnl Check for Motif include files location.
2764dnl The LAST one found is used, this makes the highest version to be used,
2765dnl e.g. when Motif1.2 and Motif2.0 are both present.
2766
2767if test -z "$SKIP_MOTIF"; then
2768 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"
2769 dnl Remove "-I" from before $GUI_INC_LOC if it's there
2770 GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`"
2771
2772 AC_MSG_CHECKING(for location of Motif GUI includes)
2773 gui_includes="`echo $x_includes|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC"
2774 GUI_INC_LOC=
2775 for try in $gui_includes; do
2776 if test -f "$try/Xm/Xm.h"; then
2777 GUI_INC_LOC=$try
2778 fi
2779 done
2780 if test -n "$GUI_INC_LOC"; then
2781 if test "$GUI_INC_LOC" = /usr/include; then
2782 GUI_INC_LOC=
2783 AC_MSG_RESULT(in default path)
2784 else
2785 AC_MSG_RESULT($GUI_INC_LOC)
2786 fi
2787 else
2788 AC_MSG_RESULT(<not found>)
2789 SKIP_MOTIF=YES
2790 fi
2791fi
2792
2793dnl Check for Motif library files location. In the same order as the include
2794dnl files, to avoid a mixup if several versions are present
2795
2796if test -z "$SKIP_MOTIF"; then
2797 AC_MSG_CHECKING(--with-motif-lib argument)
2798 AC_ARG_WITH(motif-lib,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002799 [ --with-motif-lib=STRING Library for Motif ],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002800 [ MOTIF_LIBNAME="${withval}" ] )
2801
2802 if test -n "$MOTIF_LIBNAME"; then
2803 AC_MSG_RESULT($MOTIF_LIBNAME)
2804 GUI_LIB_LOC=
2805 else
2806 AC_MSG_RESULT(no)
2807
2808 dnl Remove "-L" from before $GUI_LIB_LOC if it's there
2809 GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
2810
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002811 dnl Ubuntu has libXm.so in /usr/lib/i386-linux-gnu and elsewhere. The
2812 dnl linker will figure out which one to use, we only check if one exists.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002813 AC_MSG_CHECKING(for location of Motif GUI libs)
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002814 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 +00002815 GUI_LIB_LOC=
2816 for try in $gui_libs; do
Bram Moolenaar325b7a22004-07-05 15:58:32 +00002817 for libtry in "$try"/libXm.a "$try"/libXm.so* "$try"/libXm.sl "$try"/libXm.dylib; do
Bram Moolenaar071d4272004-06-13 20:20:40 +00002818 if test -f "$libtry"; then
2819 GUI_LIB_LOC=$try
2820 fi
2821 done
2822 done
2823 if test -n "$GUI_LIB_LOC"; then
2824 dnl Remove /usr/lib, it causes trouble on some systems
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002825 if test "$GUI_LIB_LOC" = /usr/lib \
2826 -o "$GUI_LIB_LOC" = /usr/lib/i386-linux-gnu \
2827 -o "$GUI_LIB_LOC" = /usr/lib/x86_64-linux-gnu; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002828 GUI_LIB_LOC=
2829 AC_MSG_RESULT(in default path)
2830 else
2831 if test -n "$GUI_LIB_LOC"; then
2832 AC_MSG_RESULT($GUI_LIB_LOC)
2833 if test "`(uname) 2>/dev/null`" = SunOS &&
2834 uname -r | grep '^5' >/dev/null; then
2835 GUI_LIB_LOC="$GUI_LIB_LOC -R $GUI_LIB_LOC"
2836 fi
2837 fi
2838 fi
2839 MOTIF_LIBNAME=-lXm
2840 else
2841 AC_MSG_RESULT(<not found>)
2842 SKIP_MOTIF=YES
2843 fi
2844 fi
2845fi
2846
2847if test -z "$SKIP_MOTIF"; then
2848 SKIP_ATHENA=YES
2849 SKIP_NEXTAW=YES
2850 GUITYPE=MOTIF
2851 AC_SUBST(MOTIF_LIBNAME)
2852fi
2853
2854dnl Check if the Athena files can be found
2855
2856GUI_X_LIBS=
2857
2858if test -z "$SKIP_ATHENA"; then
2859 AC_MSG_CHECKING(if Athena header files can be found)
2860 cflags_save=$CFLAGS
2861 CFLAGS="$CFLAGS $X_CFLAGS"
2862 AC_TRY_COMPILE([
2863#include <X11/Intrinsic.h>
2864#include <X11/Xaw/Paned.h>], ,
2865 AC_MSG_RESULT(yes),
2866 AC_MSG_RESULT(no); SKIP_ATHENA=YES )
2867 CFLAGS=$cflags_save
2868fi
2869
2870if test -z "$SKIP_ATHENA"; then
2871 GUITYPE=ATHENA
2872fi
2873
2874if test -z "$SKIP_NEXTAW"; then
2875 AC_MSG_CHECKING(if neXtaw header files can be found)
2876 cflags_save=$CFLAGS
2877 CFLAGS="$CFLAGS $X_CFLAGS"
2878 AC_TRY_COMPILE([
2879#include <X11/Intrinsic.h>
2880#include <X11/neXtaw/Paned.h>], ,
2881 AC_MSG_RESULT(yes),
2882 AC_MSG_RESULT(no); SKIP_NEXTAW=YES )
2883 CFLAGS=$cflags_save
2884fi
2885
2886if test -z "$SKIP_NEXTAW"; then
2887 GUITYPE=NEXTAW
2888fi
2889
2890if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
2891 dnl Prepend -I and -L to $GUI_INC_LOC and $GUI_LIB_LOC if not empty
2892 dnl Avoid adding it when it twice
2893 if test -n "$GUI_INC_LOC"; then
2894 GUI_INC_LOC=-I"`echo $GUI_INC_LOC|sed 's%-I%%'`"
2895 fi
2896 if test -n "$GUI_LIB_LOC"; then
2897 GUI_LIB_LOC=-L"`echo $GUI_LIB_LOC|sed 's%-L%%'`"
2898 fi
2899
2900 dnl Check for -lXext and then for -lXmu
2901 ldflags_save=$LDFLAGS
2902 LDFLAGS="$X_LIBS $LDFLAGS"
2903 AC_CHECK_LIB(Xext, XShapeQueryExtension, [GUI_X_LIBS="-lXext"],,
2904 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2905 dnl For Solaris we need -lw and -ldl before linking with -lXmu works.
2906 AC_CHECK_LIB(w, wslen, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lw"],,
2907 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2908 AC_CHECK_LIB(dl, dlsym, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldl"],,
2909 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2910 AC_CHECK_LIB(Xmu, XmuCreateStippledPixmap, [GUI_X_LIBS="-lXmu $GUI_X_LIBS"],,
2911 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2912 if test -z "$SKIP_MOTIF"; then
2913 AC_CHECK_LIB(Xp, XpEndJob, [GUI_X_LIBS="-lXp $GUI_X_LIBS"],,
2914 [$GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2915 fi
2916 LDFLAGS=$ldflags_save
2917
2918 dnl Execute xmkmf to figure out if -DNARROWPROTO is needed.
2919 AC_MSG_CHECKING(for extra X11 defines)
2920 NARROW_PROTO=
2921 rm -fr conftestdir
2922 if mkdir conftestdir; then
2923 cd conftestdir
2924 cat > Imakefile <<'EOF'
2925acfindx:
2926 @echo 'NARROW_PROTO="${PROTO_DEFINES}"'
2927EOF
2928 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
2929 eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
2930 fi
2931 cd ..
2932 rm -fr conftestdir
2933 fi
2934 if test -z "$NARROW_PROTO"; then
2935 AC_MSG_RESULT(no)
2936 else
2937 AC_MSG_RESULT($NARROW_PROTO)
2938 fi
2939 AC_SUBST(NARROW_PROTO)
2940fi
2941
2942dnl Look for XSMP support - but don't necessarily restrict it to X11 GUIs
2943dnl use the X11 include path
2944if test "$enable_xsmp" = "yes"; then
2945 cppflags_save=$CPPFLAGS
2946 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2947 AC_CHECK_HEADERS(X11/SM/SMlib.h)
2948 CPPFLAGS=$cppflags_save
2949fi
2950
2951
Bram Moolenaar98921892016-02-23 17:14:37 +01002952if 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 +00002953 dnl Check for X11/xpm.h and X11/Sunkeysym.h with the GUI include path
2954 cppflags_save=$CPPFLAGS
2955 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2956 AC_CHECK_HEADERS(X11/xpm.h X11/Sunkeysym.h)
2957
2958 dnl automatically disable XIM when XIMtext isn't in X11/Xlib.h
2959 if test ! "$enable_xim" = "no"; then
2960 AC_MSG_CHECKING(for XIMText in X11/Xlib.h)
2961 AC_EGREP_CPP(XIMText, [#include <X11/Xlib.h>],
2962 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +02002963 AC_MSG_RESULT(no; xim has been disabled); enable_xim="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00002964 fi
2965 CPPFLAGS=$cppflags_save
2966
2967 dnl automatically enable XIM when hangul input isn't enabled
2968 if test "$enable_xim" = "auto" -a "$enable_hangulinput" != "yes" \
2969 -a "x$GUITYPE" != "xNONE" ; then
2970 AC_MSG_RESULT(X GUI selected; xim has been enabled)
2971 enable_xim="yes"
2972 fi
2973fi
2974
2975if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
2976 cppflags_save=$CPPFLAGS
2977 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00002978dnl Xmu/Editres.h may exist but can only be used after including Intrinsic.h
2979 AC_MSG_CHECKING([for X11/Xmu/Editres.h])
2980 AC_TRY_COMPILE([
2981#include <X11/Intrinsic.h>
2982#include <X11/Xmu/Editres.h>],
2983 [int i; i = 0;],
2984 AC_MSG_RESULT(yes)
2985 AC_DEFINE(HAVE_X11_XMU_EDITRES_H),
2986 AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00002987 CPPFLAGS=$cppflags_save
2988fi
2989
2990dnl Only use the Xm directory when compiling Motif, don't use it for Athena
2991if test -z "$SKIP_MOTIF"; then
2992 cppflags_save=$CPPFLAGS
2993 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar77c19352012-06-13 19:19:41 +02002994 if test "$zOSUnix" = "yes"; then
2995 xmheader="Xm/Xm.h"
2996 else
2997 xmheader="Xm/Xm.h Xm/XpmP.h Xm/JoinSideT.h Xm/TraitP.h Xm/Manager.h
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02002998 Xm/UnhighlightT.h Xm/Notebook.h"
Bram Moolenaar77c19352012-06-13 19:19:41 +02002999 fi
3000 AC_CHECK_HEADERS($xmheader)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003001
Bram Moolenaar77c19352012-06-13 19:19:41 +02003002 if test "x$ac_cv_header_Xm_XpmP_h" = "xyes"; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003003 dnl Solaris uses XpmAttributes_21, very annoying.
3004 AC_MSG_CHECKING([for XpmAttributes_21 in Xm/XpmP.h])
3005 AC_TRY_COMPILE([#include <Xm/XpmP.h>], [XpmAttributes_21 attr;],
3006 AC_MSG_RESULT(yes); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes_21),
3007 AC_MSG_RESULT(no); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
3008 )
3009 else
Bram Moolenaar57657d82006-04-21 22:12:41 +00003010 AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003011 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003012 CPPFLAGS=$cppflags_save
3013fi
3014
3015if test "x$GUITYPE" = "xNONE" -a "$enable_xim" = "yes"; then
3016 AC_MSG_RESULT(no GUI selected; xim has been disabled)
3017 enable_xim="no"
3018fi
3019if test "x$GUITYPE" = "xNONE" -a "$enable_fontset" = "yes"; then
3020 AC_MSG_RESULT(no GUI selected; fontset has been disabled)
3021 enable_fontset="no"
3022fi
Bram Moolenaar182c5be2010-06-25 05:37:59 +02003023if test "x$GUITYPE:$enable_fontset" = "xGTK:yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003024 AC_MSG_RESULT(GTK+ 2 GUI selected; fontset has been disabled)
3025 enable_fontset="no"
3026fi
3027
Bram Moolenaar071d4272004-06-13 20:20:40 +00003028if test -z "$SKIP_PHOTON"; then
3029 GUITYPE=PHOTONGUI
3030fi
3031
3032AC_SUBST(GUI_INC_LOC)
3033AC_SUBST(GUI_LIB_LOC)
3034AC_SUBST(GUITYPE)
3035AC_SUBST(GUI_X_LIBS)
3036
3037if test "$enable_workshop" = "yes" -a -n "$SKIP_MOTIF"; then
3038 AC_MSG_ERROR([cannot use workshop without Motif])
3039fi
3040
3041dnl defining FEAT_XIM and FEAT_XFONTSET is delayed, so that they can be disabled
3042if test "$enable_xim" = "yes"; then
3043 AC_DEFINE(FEAT_XIM)
3044fi
3045if test "$enable_fontset" = "yes"; then
3046 AC_DEFINE(FEAT_XFONTSET)
3047fi
3048
3049
3050dnl ---------------------------------------------------------------------------
3051dnl end of GUI-checking
3052dnl ---------------------------------------------------------------------------
3053
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003054AC_MSG_CHECKING([for /proc link to executable])
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003055if test -L "/proc/self/exe"; then
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003056 dnl Linux
3057 AC_MSG_RESULT([/proc/self/exe])
3058 AC_DEFINE(PROC_EXE_LINK, "/proc/self/exe")
3059elif test -L "/proc/self/path/a.out"; then
3060 dnl Solaris
3061 AC_MSG_RESULT([/proc/self/path/a.out])
3062 AC_DEFINE(PROC_EXE_LINK, "/proc/self/path/a.out")
3063elif test -L "/proc/curproc/file"; then
3064 dnl FreeBSD
3065 AC_MSG_RESULT([/proc/curproc/file])
3066 AC_DEFINE(PROC_EXE_LINK, "/proc/curproc/file")
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003067else
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003068 AC_MSG_RESULT(no)
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003069fi
3070
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003071dnl Check for Cygwin, which needs an extra source file if not using X11
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003072AC_MSG_CHECKING(for CYGWIN or MSYS environment)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003073case `uname` in
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003074 CYGWIN*|MSYS*) CYGWIN=yes; AC_MSG_RESULT(yes)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003075 AC_MSG_CHECKING(for CYGWIN clipboard support)
3076 if test "x$with_x" = "xno" ; then
3077 OS_EXTRA_SRC=winclip.c; OS_EXTRA_OBJ=objects/winclip.o
3078 AC_MSG_RESULT(yes)
3079 AC_DEFINE(FEAT_CYGWIN_WIN32_CLIPBOARD)
3080 else
3081 AC_MSG_RESULT(no - using X11)
3082 fi ;;
3083
3084 *) CYGWIN=no; AC_MSG_RESULT(no);;
3085esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00003086
3087dnl Only really enable hangul input when GUI and XFONTSET are available
3088if test "$enable_hangulinput" = "yes"; then
3089 if test "x$GUITYPE" = "xNONE"; then
3090 AC_MSG_RESULT(no GUI selected; hangul input has been disabled)
3091 enable_hangulinput=no
3092 else
3093 AC_DEFINE(FEAT_HANGULIN)
3094 HANGULIN_SRC=hangulin.c
3095 AC_SUBST(HANGULIN_SRC)
3096 HANGULIN_OBJ=objects/hangulin.o
3097 AC_SUBST(HANGULIN_OBJ)
3098 fi
3099fi
3100
3101dnl Checks for libraries and include files.
3102
Bram Moolenaar446cb832008-06-24 21:56:24 +00003103AC_CACHE_CHECK([whether toupper is broken], [vim_cv_toupper_broken],
3104 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003105 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003106#include "confdefs.h"
3107#include <ctype.h>
3108#if STDC_HEADERS
3109# include <stdlib.h>
3110# include <stddef.h>
3111#endif
3112main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003113 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003114 vim_cv_toupper_broken=yes
3115 ],[
3116 vim_cv_toupper_broken=no
3117 ],[
3118 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_toupper_broken')
3119 ])])
3120
3121if test "x$vim_cv_toupper_broken" = "xyes" ; then
3122 AC_DEFINE(BROKEN_TOUPPER)
3123fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003124
3125AC_MSG_CHECKING(whether __DATE__ and __TIME__ work)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003126AC_TRY_COMPILE([#include <stdio.h>], [printf("(" __DATE__ " " __TIME__ ")");],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003127 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DATE_TIME),
3128 AC_MSG_RESULT(no))
3129
Bram Moolenaar0c094b92009-05-14 20:20:33 +00003130AC_MSG_CHECKING(whether __attribute__((unused)) is allowed)
3131AC_TRY_COMPILE([#include <stdio.h>], [int x __attribute__((unused));],
3132 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ATTRIBUTE_UNUSED),
3133 AC_MSG_RESULT(no))
3134
Bram Moolenaar071d4272004-06-13 20:20:40 +00003135dnl Checks for header files.
3136AC_CHECK_HEADER(elf.h, HAS_ELF=1)
3137dnl AC_CHECK_HEADER(dwarf.h, SVR4=1)
3138if test "$HAS_ELF" = 1; then
3139 AC_CHECK_LIB(elf, main)
3140fi
3141
3142AC_HEADER_DIRENT
3143
Bram Moolenaar071d4272004-06-13 20:20:40 +00003144dnl If sys/wait.h is not found it might still exist but not be POSIX
3145dnl compliant. In that case we define HAVE_UNION_WAIT (for NeXT)
3146if test $ac_cv_header_sys_wait_h = no; then
3147 AC_MSG_CHECKING([for sys/wait.h that defines union wait])
3148 AC_TRY_COMPILE([#include <sys/wait.h>],
3149 [union wait xx, yy; xx = yy],
3150 AC_MSG_RESULT(yes)
3151 AC_DEFINE(HAVE_SYS_WAIT_H)
3152 AC_DEFINE(HAVE_UNION_WAIT),
3153 AC_MSG_RESULT(no))
3154fi
3155
Bram Moolenaar779a7752016-01-30 23:26:34 +01003156AC_CHECK_HEADERS(stdint.h stdlib.h string.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003157 sys/select.h sys/utsname.h termcap.h fcntl.h \
3158 sgtty.h sys/ioctl.h sys/time.h sys/types.h \
3159 termio.h iconv.h inttypes.h langinfo.h math.h \
3160 unistd.h stropts.h errno.h sys/resource.h \
3161 sys/systeminfo.h locale.h sys/stream.h termios.h \
3162 libc.h sys/statfs.h poll.h sys/poll.h pwd.h \
3163 utime.h sys/param.h libintl.h libgen.h \
3164 util/debug.h util/msg18n.h frame.h sys/acl.h \
3165 sys/access.h sys/sysinfo.h wchar.h wctype.h)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003166
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003167dnl sys/ptem.h depends on sys/stream.h on Solaris
3168AC_CHECK_HEADERS(sys/ptem.h, [], [],
3169[#if defined HAVE_SYS_STREAM_H
3170# include <sys/stream.h>
3171#endif])
3172
Bram Moolenaar32f31b12009-05-21 13:20:59 +00003173dnl sys/sysctl.h depends on sys/param.h on OpenBSD
3174AC_CHECK_HEADERS(sys/sysctl.h, [], [],
3175[#if defined HAVE_SYS_PARAM_H
3176# include <sys/param.h>
3177#endif])
3178
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003179
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003180dnl pthread_np.h may exist but can only be used after including pthread.h
3181AC_MSG_CHECKING([for pthread_np.h])
3182AC_TRY_COMPILE([
3183#include <pthread.h>
3184#include <pthread_np.h>],
3185 [int i; i = 0;],
3186 AC_MSG_RESULT(yes)
3187 AC_DEFINE(HAVE_PTHREAD_NP_H),
3188 AC_MSG_RESULT(no))
3189
Bram Moolenaare344bea2005-09-01 20:46:49 +00003190AC_CHECK_HEADERS(strings.h)
Bram Moolenaar9372a112005-12-06 19:59:18 +00003191if test "x$MACOSX" = "xyes"; then
3192 dnl The strings.h file on OS/X contains a warning and nothing useful.
3193 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3194else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003195
3196dnl Check if strings.h and string.h can both be included when defined.
3197AC_MSG_CHECKING([if strings.h can be included after string.h])
3198cppflags_save=$CPPFLAGS
3199CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3200AC_TRY_COMPILE([
3201#if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO)
3202# define _NO_PROTO /* like in os_unix.h, causes conflict for AIX (Winn) */
3203 /* but don't do it on AIX 5.1 (Uribarri) */
3204#endif
3205#ifdef HAVE_XM_XM_H
3206# include <Xm/Xm.h> /* This breaks it for HP-UX 11 (Squassabia) */
3207#endif
3208#ifdef HAVE_STRING_H
3209# include <string.h>
3210#endif
3211#if defined(HAVE_STRINGS_H)
3212# include <strings.h>
3213#endif
3214 ], [int i; i = 0;],
3215 AC_MSG_RESULT(yes),
3216 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3217 AC_MSG_RESULT(no))
3218CPPFLAGS=$cppflags_save
Bram Moolenaar9372a112005-12-06 19:59:18 +00003219fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003220
3221dnl Checks for typedefs, structures, and compiler characteristics.
3222AC_PROG_GCC_TRADITIONAL
3223AC_C_CONST
Bram Moolenaar76243bd2009-03-02 01:47:02 +00003224AC_C_VOLATILE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003225AC_TYPE_MODE_T
3226AC_TYPE_OFF_T
3227AC_TYPE_PID_T
3228AC_TYPE_SIZE_T
3229AC_TYPE_UID_T
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003230AC_TYPE_UINT32_T
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003231
Bram Moolenaar071d4272004-06-13 20:20:40 +00003232AC_HEADER_TIME
3233AC_CHECK_TYPE(ino_t, long)
3234AC_CHECK_TYPE(dev_t, unsigned)
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003235AC_C_BIGENDIAN(,,,)
Bram Moolenaar136f29a2016-02-27 20:14:15 +01003236AC_C_INLINE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003237
3238AC_MSG_CHECKING(for rlim_t)
3239if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
3240 AC_MSG_RESULT([(cached) $ac_cv_type_rlim_t])
3241else
3242 AC_EGREP_CPP(dnl
3243changequote(<<,>>)dnl
3244<<(^|[^a-zA-Z_0-9])rlim_t[^a-zA-Z_0-9]>>dnl
3245changequote([,]),
3246 [
3247#include <sys/types.h>
3248#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003249# include <stdlib.h>
3250# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003251#endif
3252#ifdef HAVE_SYS_RESOURCE_H
Bram Moolenaar446cb832008-06-24 21:56:24 +00003253# include <sys/resource.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003254#endif
3255 ], ac_cv_type_rlim_t=yes, ac_cv_type_rlim_t=no)
3256 AC_MSG_RESULT($ac_cv_type_rlim_t)
3257fi
3258if test $ac_cv_type_rlim_t = no; then
3259 cat >> confdefs.h <<\EOF
3260#define rlim_t unsigned long
3261EOF
3262fi
3263
3264AC_MSG_CHECKING(for stack_t)
3265if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then
3266 AC_MSG_RESULT([(cached) $ac_cv_type_stack_t])
3267else
3268 AC_EGREP_CPP(stack_t,
3269 [
3270#include <sys/types.h>
3271#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003272# include <stdlib.h>
3273# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003274#endif
3275#include <signal.h>
3276 ], ac_cv_type_stack_t=yes, ac_cv_type_stack_t=no)
3277 AC_MSG_RESULT($ac_cv_type_stack_t)
3278fi
3279if test $ac_cv_type_stack_t = no; then
3280 cat >> confdefs.h <<\EOF
3281#define stack_t struct sigaltstack
3282EOF
3283fi
3284
3285dnl BSDI uses ss_base while others use ss_sp for the stack pointer.
3286AC_MSG_CHECKING(whether stack_t has an ss_base field)
3287AC_TRY_COMPILE([
3288#include <sys/types.h>
3289#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003290# include <stdlib.h>
3291# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003292#endif
3293#include <signal.h>
3294#include "confdefs.h"
3295 ], [stack_t sigstk; sigstk.ss_base = 0; ],
3296 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SS_BASE),
3297 AC_MSG_RESULT(no))
3298
3299olibs="$LIBS"
3300AC_MSG_CHECKING(--with-tlib argument)
3301AC_ARG_WITH(tlib, [ --with-tlib=library terminal library to be used ],)
3302if test -n "$with_tlib"; then
3303 AC_MSG_RESULT($with_tlib)
3304 LIBS="$LIBS -l$with_tlib"
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003305 AC_MSG_CHECKING(for linking with $with_tlib library)
3306 AC_TRY_LINK([], [], AC_MSG_RESULT(OK), AC_MSG_ERROR(FAILED))
3307 dnl Need to check for tgetent() below.
3308 olibs="$LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003309else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003310 AC_MSG_RESULT([empty: automatic terminal library selection])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003311 dnl On HP-UX 10.10 termcap or termlib should be used instead of
3312 dnl curses, because curses is much slower.
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003313 dnl Newer versions of ncurses are preferred over anything, except
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02003314 dnl when tinfo has been split off, it contains all we need.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003315 dnl Older versions of ncurses have bugs, get a new one!
3316 dnl Digital Unix (OSF1) should use curses (Ronald Schild).
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00003317 dnl On SCO Openserver should prefer termlib (Roger Cornelius).
Bram Moolenaar071d4272004-06-13 20:20:40 +00003318 case "`uname -s 2>/dev/null`" in
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003319 OSF1|SCO_SV) tlibs="tinfo ncurses curses termlib termcap";;
3320 *) tlibs="tinfo ncurses termlib termcap curses";;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003321 esac
3322 for libname in $tlibs; do
3323 AC_CHECK_LIB(${libname}, tgetent,,)
3324 if test "x$olibs" != "x$LIBS"; then
3325 dnl It's possible that a library is found but it doesn't work
3326 dnl e.g., shared library that cannot be found
3327 dnl compile and run a test program to be sure
3328 AC_TRY_RUN([
3329#ifdef HAVE_TERMCAP_H
3330# include <termcap.h>
3331#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003332#if STDC_HEADERS
3333# include <stdlib.h>
3334# include <stddef.h>
3335#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003336main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }],
3337 res="OK", res="FAIL", res="FAIL")
3338 if test "$res" = "OK"; then
3339 break
3340 fi
3341 AC_MSG_RESULT($libname library is not usable)
3342 LIBS="$olibs"
3343 fi
3344 done
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003345 if test "x$olibs" = "x$LIBS"; then
3346 AC_MSG_RESULT(no terminal library found)
3347 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003348fi
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003349
3350if test "x$olibs" = "x$LIBS"; then
3351 AC_MSG_CHECKING([for tgetent()])
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00003352 AC_TRY_LINK([],
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003353 [char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");],
3354 AC_MSG_RESULT(yes),
3355 AC_MSG_ERROR([NOT FOUND!
3356 You need to install a terminal library; for example ncurses.
3357 Or specify the name of the library with --with-tlib.]))
3358fi
3359
Bram Moolenaar446cb832008-06-24 21:56:24 +00003360AC_CACHE_CHECK([whether we talk terminfo], [vim_cv_terminfo],
3361 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003362 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003363#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003364#ifdef HAVE_TERMCAP_H
3365# include <termcap.h>
3366#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003367#ifdef HAVE_STRING_H
3368# include <string.h>
3369#endif
3370#if STDC_HEADERS
3371# include <stdlib.h>
3372# include <stddef.h>
3373#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003374main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003375{char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003376 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003377 vim_cv_terminfo=no
3378 ],[
3379 vim_cv_terminfo=yes
3380 ],[
3381 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_terminfo')
3382 ])
3383 ])
3384
3385if test "x$vim_cv_terminfo" = "xyes" ; then
3386 AC_DEFINE(TERMINFO)
3387fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003388
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003389AC_CACHE_CHECK([what tgetent() returns for an unknown terminal], [vim_cv_tgent],
3390 [
3391 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003392#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003393#ifdef HAVE_TERMCAP_H
3394# include <termcap.h>
3395#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003396#if STDC_HEADERS
3397# include <stdlib.h>
3398# include <stddef.h>
3399#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003400main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003401{char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003402 ]])],[
3403 vim_cv_tgent=zero
3404 ],[
3405 vim_cv_tgent=non-zero
3406 ],[
3407 AC_MSG_ERROR(failed to compile test program.)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003408 ])
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003409 ])
3410
3411if test "x$vim_cv_tgent" = "xzero" ; then
3412 AC_DEFINE(TGETENT_ZERO_ERR, 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003413fi
3414
3415AC_MSG_CHECKING(whether termcap.h contains ospeed)
3416AC_TRY_LINK([
3417#ifdef HAVE_TERMCAP_H
3418# include <termcap.h>
3419#endif
3420 ], [ospeed = 20000],
3421 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED),
3422 [AC_MSG_RESULT(no)
3423 AC_MSG_CHECKING(whether ospeed can be extern)
3424 AC_TRY_LINK([
3425#ifdef HAVE_TERMCAP_H
3426# include <termcap.h>
3427#endif
3428extern short ospeed;
3429 ], [ospeed = 20000],
3430 AC_MSG_RESULT(yes); AC_DEFINE(OSPEED_EXTERN),
3431 AC_MSG_RESULT(no))]
3432 )
3433
3434AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC])
3435AC_TRY_LINK([
3436#ifdef HAVE_TERMCAP_H
3437# include <termcap.h>
3438#endif
3439 ], [if (UP == 0 && BC == 0) PC = 1],
3440 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UP_BC_PC),
3441 [AC_MSG_RESULT(no)
3442 AC_MSG_CHECKING([whether UP, BC and PC can be extern])
3443 AC_TRY_LINK([
3444#ifdef HAVE_TERMCAP_H
3445# include <termcap.h>
3446#endif
3447extern char *UP, *BC, PC;
3448 ], [if (UP == 0 && BC == 0) PC = 1],
3449 AC_MSG_RESULT(yes); AC_DEFINE(UP_BC_PC_EXTERN),
3450 AC_MSG_RESULT(no))]
3451 )
3452
3453AC_MSG_CHECKING(whether tputs() uses outfuntype)
3454AC_TRY_COMPILE([
3455#ifdef HAVE_TERMCAP_H
3456# include <termcap.h>
3457#endif
3458 ], [extern int xx(); tputs("test", 1, (outfuntype)xx)],
3459 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OUTFUNTYPE),
3460 AC_MSG_RESULT(no))
3461
3462dnl On some SCO machines sys/select redefines struct timeval
3463AC_MSG_CHECKING([whether sys/select.h and sys/time.h may both be included])
3464AC_TRY_COMPILE([
3465#include <sys/types.h>
3466#include <sys/time.h>
3467#include <sys/select.h>], ,
3468 AC_MSG_RESULT(yes)
3469 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME),
3470 AC_MSG_RESULT(no))
3471
3472dnl AC_DECL_SYS_SIGLIST
3473
3474dnl Checks for pty.c (copied from screen) ==========================
3475AC_MSG_CHECKING(for /dev/ptc)
3476if test -r /dev/ptc; then
3477 AC_DEFINE(HAVE_DEV_PTC)
3478 AC_MSG_RESULT(yes)
3479else
3480 AC_MSG_RESULT(no)
3481fi
3482
3483AC_MSG_CHECKING(for SVR4 ptys)
3484if test -c /dev/ptmx ; then
3485 AC_TRY_LINK([], [ptsname(0);grantpt(0);unlockpt(0);],
3486 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SVR4_PTYS),
3487 AC_MSG_RESULT(no))
3488else
3489 AC_MSG_RESULT(no)
3490fi
3491
3492AC_MSG_CHECKING(for ptyranges)
3493if test -d /dev/ptym ; then
3494 pdir='/dev/ptym'
3495else
3496 pdir='/dev'
3497fi
3498dnl SCO uses ptyp%d
3499AC_EGREP_CPP(yes,
3500[#ifdef M_UNIX
3501 yes;
3502#endif
3503 ], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
3504dnl if test -c /dev/ptyp19; then
3505dnl ptys=`echo /dev/ptyp??`
3506dnl else
3507dnl ptys=`echo $pdir/pty??`
3508dnl fi
3509if test "$ptys" != "$pdir/pty??" ; then
3510 p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
3511 p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'`
3512 AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
3513 AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
3514 AC_MSG_RESULT([$p0 / $p1])
3515else
3516 AC_MSG_RESULT([don't know])
3517fi
3518
3519dnl **** pty mode/group handling ****
3520dnl
3521dnl support provided by Luke Mewburn <lm@rmit.edu.au>, 931222
Bram Moolenaar071d4272004-06-13 20:20:40 +00003522rm -f conftest_grp
Bram Moolenaar446cb832008-06-24 21:56:24 +00003523AC_CACHE_CHECK([default tty permissions/group], [vim_cv_tty_group],
3524 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003525 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003526#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003527#include <sys/types.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003528#if STDC_HEADERS
3529# include <stdlib.h>
3530# include <stddef.h>
3531#endif
3532#ifdef HAVE_UNISTD_H
3533#include <unistd.h>
3534#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003535#include <sys/stat.h>
3536#include <stdio.h>
3537main()
3538{
3539 struct stat sb;
3540 char *x,*ttyname();
3541 int om, m;
3542 FILE *fp;
3543
3544 if (!(x = ttyname(0))) exit(1);
3545 if (stat(x, &sb)) exit(1);
3546 om = sb.st_mode;
3547 if (om & 002) exit(0);
3548 m = system("mesg y");
3549 if (m == -1 || m == 127) exit(1);
3550 if (stat(x, &sb)) exit(1);
3551 m = sb.st_mode;
3552 if (chmod(x, om)) exit(1);
3553 if (m & 002) exit(0);
3554 if (sb.st_gid == getgid()) exit(1);
3555 if (!(fp=fopen("conftest_grp", "w")))
3556 exit(1);
3557 fprintf(fp, "%d\n", sb.st_gid);
3558 fclose(fp);
3559 exit(0);
3560}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003561 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003562 if test -f conftest_grp; then
3563 vim_cv_tty_group=`cat conftest_grp`
3564 if test "x$vim_cv_tty_mode" = "x" ; then
3565 vim_cv_tty_mode=0620
3566 fi
3567 AC_MSG_RESULT([pty mode: $vim_cv_tty_mode, group: $vim_cv_tty_group])
3568 else
3569 vim_cv_tty_group=world
Bram Moolenaar72951072009-12-02 16:58:33 +00003570 AC_MSG_RESULT([ptys are world accessible])
Bram Moolenaar446cb832008-06-24 21:56:24 +00003571 fi
3572 ],[
3573 vim_cv_tty_group=world
Bram Moolenaar72951072009-12-02 16:58:33 +00003574 AC_MSG_RESULT([can't determine - assume ptys are world accessible])
Bram Moolenaar446cb832008-06-24 21:56:24 +00003575 ],[
3576 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_tty_group' and 'vim_cv_tty_mode')
3577 ])
3578 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003579rm -f conftest_grp
3580
Bram Moolenaar446cb832008-06-24 21:56:24 +00003581if test "x$vim_cv_tty_group" != "xworld" ; then
3582 AC_DEFINE_UNQUOTED(PTYGROUP,$vim_cv_tty_group)
3583 if test "x$vim_cv_tty_mode" = "x" ; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02003584 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 +00003585 else
3586 AC_DEFINE(PTYMODE, 0620)
3587 fi
3588fi
3589
Bram Moolenaar071d4272004-06-13 20:20:40 +00003590dnl Checks for library functions. ===================================
3591
3592AC_TYPE_SIGNAL
3593
3594dnl find out what to use at the end of a signal function
3595if test $ac_cv_type_signal = void; then
3596 AC_DEFINE(SIGRETURN, [return])
3597else
3598 AC_DEFINE(SIGRETURN, [return 0])
3599fi
3600
3601dnl check if struct sigcontext is defined (used for SGI only)
3602AC_MSG_CHECKING(for struct sigcontext)
3603AC_TRY_COMPILE([
3604#include <signal.h>
3605test_sig()
3606{
3607 struct sigcontext *scont;
3608 scont = (struct sigcontext *)0;
3609 return 1;
3610} ], ,
3611 AC_MSG_RESULT(yes)
3612 AC_DEFINE(HAVE_SIGCONTEXT),
3613 AC_MSG_RESULT(no))
3614
3615dnl tricky stuff: try to find out if getcwd() is implemented with
3616dnl system("sh -c pwd")
Bram Moolenaar446cb832008-06-24 21:56:24 +00003617AC_CACHE_CHECK([getcwd implementation is broken], [vim_cv_getcwd_broken],
3618 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003619 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003620#include "confdefs.h"
3621#ifdef HAVE_UNISTD_H
3622#include <unistd.h>
3623#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003624char *dagger[] = { "IFS=pwd", 0 };
3625main()
3626{
3627 char buffer[500];
3628 extern char **environ;
3629 environ = dagger;
3630 return getcwd(buffer, 500) ? 0 : 1;
Bram Moolenaar446cb832008-06-24 21:56:24 +00003631}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003632 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003633 vim_cv_getcwd_broken=no
3634 ],[
3635 vim_cv_getcwd_broken=yes
3636 ],[
3637 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_getcwd_broken')
3638 ])
3639 ])
3640
3641if test "x$vim_cv_getcwd_broken" = "xyes" ; then
3642 AC_DEFINE(BAD_GETCWD)
3643fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003644
Bram Moolenaar25153e12010-02-24 14:47:08 +01003645dnl Check for functions in one big call, to reduce the size of configure.
3646dnl Can only be used for functions that do not require any include.
Bram Moolenaarb129a442016-12-01 17:25:20 +01003647AC_CHECK_FUNCS(fchdir fchown fsync getcwd getpseudotty \
3648 getpwent getpwnam getpwuid getrlimit gettimeofday getwd lstat \
Bram Moolenaareaf03392009-11-17 11:08:52 +00003649 memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
Bram Moolenaar2fcf6682017-03-11 20:03:42 +01003650 getpgid setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
Bram Moolenaarbb09ceb2016-10-18 16:27:23 +02003651 sigprocmask sigvec strcasecmp strerror strftime stricmp strncasecmp \
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00003652 strnicmp strpbrk strtol tgetent towlower towupper iswupper \
Bram Moolenaara6b89762016-02-29 21:38:26 +01003653 usleep utime utimes)
Bram Moolenaar25153e12010-02-24 14:47:08 +01003654AC_FUNC_FSEEKO
Bram Moolenaar071d4272004-06-13 20:20:40 +00003655
Bram Moolenaar317fd3a2010-05-07 16:05:55 +02003656dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when
3657dnl appropriate, so that off_t is 64 bits when needed.
3658AC_SYS_LARGEFILE
3659
Bram Moolenaar071d4272004-06-13 20:20:40 +00003660dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible
3661AC_MSG_CHECKING(for st_blksize)
3662AC_TRY_COMPILE(
3663[#include <sys/types.h>
3664#include <sys/stat.h>],
3665[ struct stat st;
3666 int n;
3667
3668 stat("/", &st);
3669 n = (int)st.st_blksize;],
3670 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ST_BLKSIZE),
3671 AC_MSG_RESULT(no))
3672
Bram Moolenaar446cb832008-06-24 21:56:24 +00003673AC_CACHE_CHECK([whether stat() ignores a trailing slash], [vim_cv_stat_ignores_slash],
3674 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003675 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003676#include "confdefs.h"
3677#if STDC_HEADERS
3678# include <stdlib.h>
3679# include <stddef.h>
3680#endif
3681#include <sys/types.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003682#include <sys/stat.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003683main() {struct stat st; exit(stat("configure/", &st) != 0); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003684 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003685 vim_cv_stat_ignores_slash=yes
3686 ],[
3687 vim_cv_stat_ignores_slash=no
3688 ],[
3689 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_stat_ignores_slash')
3690 ])
3691 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003692
Bram Moolenaar446cb832008-06-24 21:56:24 +00003693if test "x$vim_cv_stat_ignores_slash" = "xyes" ; then
3694 AC_DEFINE(STAT_IGNORES_SLASH)
3695fi
3696
Bram Moolenaar071d4272004-06-13 20:20:40 +00003697dnl Link with iconv for charset translation, if not found without library.
3698dnl check for iconv() requires including iconv.h
3699dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
3700dnl has been installed.
3701AC_MSG_CHECKING(for iconv_open())
3702save_LIBS="$LIBS"
3703LIBS="$LIBS -liconv"
3704AC_TRY_LINK([
3705#ifdef HAVE_ICONV_H
3706# include <iconv.h>
3707#endif
3708 ], [iconv_open("fr", "to");],
3709 AC_MSG_RESULT(yes; with -liconv); AC_DEFINE(HAVE_ICONV),
3710 LIBS="$save_LIBS"
3711 AC_TRY_LINK([
3712#ifdef HAVE_ICONV_H
3713# include <iconv.h>
3714#endif
3715 ], [iconv_open("fr", "to");],
3716 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ICONV),
3717 AC_MSG_RESULT(no)))
3718
3719
3720AC_MSG_CHECKING(for nl_langinfo(CODESET))
3721AC_TRY_LINK([
3722#ifdef HAVE_LANGINFO_H
3723# include <langinfo.h>
3724#endif
3725], [char *cs = nl_langinfo(CODESET);],
3726 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET),
3727 AC_MSG_RESULT(no))
3728
Bram Moolenaar446cb832008-06-24 21:56:24 +00003729dnl Need various functions for floating point support. Only enable
3730dnl floating point when they are all present.
3731AC_CHECK_LIB(m, strtod)
3732AC_MSG_CHECKING([for strtod() and other floating point functions])
3733AC_TRY_LINK([
3734#ifdef HAVE_MATH_H
3735# include <math.h>
3736#endif
3737#if STDC_HEADERS
3738# include <stdlib.h>
3739# include <stddef.h>
3740#endif
3741], [char *s; double d;
3742 d = strtod("1.1", &s);
3743 d = fabs(1.11);
3744 d = ceil(1.11);
3745 d = floor(1.11);
3746 d = log10(1.11);
3747 d = pow(1.11, 2.22);
3748 d = sqrt(1.11);
3749 d = sin(1.11);
3750 d = cos(1.11);
3751 d = atan(1.11);
3752 ],
3753 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT_FUNCS),
3754 AC_MSG_RESULT(no))
3755
Bram Moolenaara6b89762016-02-29 21:38:26 +01003756dnl isinf() and isnan() need to include header files and may need -lm.
3757AC_MSG_CHECKING([for isinf()])
3758AC_TRY_LINK([
3759#ifdef HAVE_MATH_H
3760# include <math.h>
3761#endif
3762#if STDC_HEADERS
3763# include <stdlib.h>
3764# include <stddef.h>
3765#endif
3766], [int r = isinf(1.11); ],
3767 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISINF),
3768 AC_MSG_RESULT(no))
3769
3770AC_MSG_CHECKING([for isnan()])
3771AC_TRY_LINK([
3772#ifdef HAVE_MATH_H
3773# include <math.h>
3774#endif
3775#if STDC_HEADERS
3776# include <stdlib.h>
3777# include <stddef.h>
3778#endif
3779], [int r = isnan(1.11); ],
3780 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISNAN),
3781 AC_MSG_RESULT(no))
3782
Bram Moolenaar071d4272004-06-13 20:20:40 +00003783dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI
3784dnl when -lacl works, also try to use -lattr (required for Debian).
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003785dnl On Solaris, use the acl_get/set functions in libsec, if present.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003786AC_MSG_CHECKING(--disable-acl argument)
3787AC_ARG_ENABLE(acl,
3788 [ --disable-acl Don't check for ACL support.],
3789 , [enable_acl="yes"])
3790if test "$enable_acl" = "yes"; then
3791AC_MSG_RESULT(no)
3792AC_CHECK_LIB(posix1e, acl_get_file, [LIBS="$LIBS -lposix1e"],
3793 AC_CHECK_LIB(acl, acl_get_file, [LIBS="$LIBS -lacl"
3794 AC_CHECK_LIB(attr, fgetxattr, LIBS="$LIBS -lattr",,)],,),)
3795
3796AC_MSG_CHECKING(for POSIX ACL support)
3797AC_TRY_LINK([
3798#include <sys/types.h>
3799#ifdef HAVE_SYS_ACL_H
3800# include <sys/acl.h>
3801#endif
3802acl_t acl;], [acl = acl_get_file("foo", ACL_TYPE_ACCESS);
3803 acl_set_file("foo", ACL_TYPE_ACCESS, acl);
3804 acl_free(acl);],
3805 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_ACL),
3806 AC_MSG_RESULT(no))
3807
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003808AC_CHECK_LIB(sec, acl_get, [LIBS="$LIBS -lsec"; AC_DEFINE(HAVE_SOLARIS_ZFS_ACL)],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003809AC_MSG_CHECKING(for Solaris ACL support)
3810AC_TRY_LINK([
3811#ifdef HAVE_SYS_ACL_H
3812# include <sys/acl.h>
3813#endif], [acl("foo", GETACLCNT, 0, NULL);
3814 ],
3815 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOLARIS_ACL),
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003816 AC_MSG_RESULT(no)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003817
3818AC_MSG_CHECKING(for AIX ACL support)
3819AC_TRY_LINK([
Bram Moolenaar446cb832008-06-24 21:56:24 +00003820#if STDC_HEADERS
3821# include <stdlib.h>
3822# include <stddef.h>
3823#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003824#ifdef HAVE_SYS_ACL_H
3825# include <sys/acl.h>
3826#endif
3827#ifdef HAVE_SYS_ACCESS_H
3828# include <sys/access.h>
3829#endif
3830#define _ALL_SOURCE
3831
3832#include <sys/stat.h>
3833
3834int aclsize;
3835struct acl *aclent;], [aclsize = sizeof(struct acl);
3836 aclent = (void *)malloc(aclsize);
3837 statacl("foo", STX_NORMAL, aclent, aclsize);
3838 ],
3839 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_AIX_ACL),
3840 AC_MSG_RESULT(no))
3841else
3842 AC_MSG_RESULT(yes)
3843fi
3844
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02003845if test "x$GTK_CFLAGS" != "x"; then
3846 dnl pango_shape_full() is new, fall back to pango_shape().
3847 AC_MSG_CHECKING(for pango_shape_full)
3848 ac_save_CFLAGS="$CFLAGS"
3849 ac_save_LIBS="$LIBS"
3850 CFLAGS="$CFLAGS $GTK_CFLAGS"
3851 LIBS="$LIBS $GTK_LIBS"
Bram Moolenaar5325b9b2015-09-09 20:27:02 +02003852 AC_TRY_LINK(
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02003853 [#include <gtk/gtk.h>],
3854 [ pango_shape_full(NULL, 0, NULL, 0, NULL, NULL); ],
3855 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_PANGO_SHAPE_FULL),
3856 AC_MSG_RESULT(no))
3857 CFLAGS="$ac_save_CFLAGS"
3858 LIBS="$ac_save_LIBS"
3859fi
3860
Bram Moolenaar071d4272004-06-13 20:20:40 +00003861AC_MSG_CHECKING(--disable-gpm argument)
3862AC_ARG_ENABLE(gpm,
3863 [ --disable-gpm Don't use gpm (Linux mouse daemon).], ,
3864 [enable_gpm="yes"])
3865
3866if test "$enable_gpm" = "yes"; then
3867 AC_MSG_RESULT(no)
3868 dnl Checking if gpm support can be compiled
3869 AC_CACHE_CHECK([for gpm], vi_cv_have_gpm,
3870 [olibs="$LIBS" ; LIBS="-lgpm"]
3871 AC_TRY_LINK(
3872 [#include <gpm.h>
3873 #include <linux/keyboard.h>],
3874 [Gpm_GetLibVersion(NULL);],
3875 dnl Configure defines HAVE_GPM, if it is defined feature.h defines
3876 dnl FEAT_MOUSE_GPM if mouse support is included
3877 [vi_cv_have_gpm=yes],
3878 [vi_cv_have_gpm=no])
3879 [LIBS="$olibs"]
3880 )
3881 if test $vi_cv_have_gpm = yes; then
3882 LIBS="$LIBS -lgpm"
3883 AC_DEFINE(HAVE_GPM)
3884 fi
3885else
3886 AC_MSG_RESULT(yes)
3887fi
3888
Bram Moolenaar446cb832008-06-24 21:56:24 +00003889AC_MSG_CHECKING(--disable-sysmouse argument)
3890AC_ARG_ENABLE(sysmouse,
Bram Moolenaar8008b632017-07-18 21:33:20 +02003891 [ --disable-sysmouse Don't use sysmouse (mouse in *BSD console).], ,
Bram Moolenaar446cb832008-06-24 21:56:24 +00003892 [enable_sysmouse="yes"])
3893
3894if test "$enable_sysmouse" = "yes"; then
3895 AC_MSG_RESULT(no)
3896 dnl Checking if sysmouse support can be compiled
3897 dnl Configure defines HAVE_SYSMOUSE, if it is defined feature.h
3898 dnl defines FEAT_SYSMOUSE if mouse support is included
3899 AC_CACHE_CHECK([for sysmouse], vi_cv_have_sysmouse,
3900 AC_TRY_LINK(
3901 [#include <sys/consio.h>
3902 #include <signal.h>
3903 #include <sys/fbio.h>],
3904 [struct mouse_info mouse;
3905 mouse.operation = MOUSE_MODE;
3906 mouse.operation = MOUSE_SHOW;
3907 mouse.u.mode.mode = 0;
3908 mouse.u.mode.signal = SIGUSR2;],
3909 [vi_cv_have_sysmouse=yes],
3910 [vi_cv_have_sysmouse=no])
3911 )
3912 if test $vi_cv_have_sysmouse = yes; then
3913 AC_DEFINE(HAVE_SYSMOUSE)
3914 fi
3915else
3916 AC_MSG_RESULT(yes)
3917fi
3918
Bram Moolenaarf05da212009-11-17 16:13:15 +00003919dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
3920AC_MSG_CHECKING(for FD_CLOEXEC)
3921AC_TRY_COMPILE(
3922[#if HAVE_FCNTL_H
3923# include <fcntl.h>
3924#endif],
3925[ int flag = FD_CLOEXEC;],
3926 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
3927 AC_MSG_RESULT(not usable))
3928
Bram Moolenaar071d4272004-06-13 20:20:40 +00003929dnl rename needs to be checked separately to work on Nextstep with cc
3930AC_MSG_CHECKING(for rename)
3931AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
3932 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
3933 AC_MSG_RESULT(no))
3934
3935dnl sysctl() may exist but not the arguments we use
3936AC_MSG_CHECKING(for sysctl)
3937AC_TRY_COMPILE(
3938[#include <sys/types.h>
3939#include <sys/sysctl.h>],
3940[ int mib[2], r;
3941 size_t len;
3942
3943 mib[0] = CTL_HW;
3944 mib[1] = HW_USERMEM;
3945 len = sizeof(r);
3946 (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
3947 ],
3948 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL),
3949 AC_MSG_RESULT(not usable))
3950
3951dnl sysinfo() may exist but not be Linux compatible
3952AC_MSG_CHECKING(for sysinfo)
3953AC_TRY_COMPILE(
3954[#include <sys/types.h>
3955#include <sys/sysinfo.h>],
3956[ struct sysinfo sinfo;
3957 int t;
3958
3959 (void)sysinfo(&sinfo);
3960 t = sinfo.totalram;
3961 ],
3962 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
3963 AC_MSG_RESULT(not usable))
3964
Bram Moolenaar914572a2007-05-01 11:37:47 +00003965dnl struct sysinfo may have the mem_unit field or not
3966AC_MSG_CHECKING(for sysinfo.mem_unit)
3967AC_TRY_COMPILE(
3968[#include <sys/types.h>
3969#include <sys/sysinfo.h>],
3970[ struct sysinfo sinfo;
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02003971 sinfo.mem_unit = 1;
Bram Moolenaar914572a2007-05-01 11:37:47 +00003972 ],
3973 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_MEM_UNIT),
3974 AC_MSG_RESULT(no))
3975
Bram Moolenaar071d4272004-06-13 20:20:40 +00003976dnl sysconf() may exist but not support what we want to use
3977AC_MSG_CHECKING(for sysconf)
3978AC_TRY_COMPILE(
3979[#include <unistd.h>],
3980[ (void)sysconf(_SC_PAGESIZE);
3981 (void)sysconf(_SC_PHYS_PAGES);
3982 ],
3983 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
3984 AC_MSG_RESULT(not usable))
3985
Bram Moolenaar914703b2010-05-31 21:59:46 +02003986AC_CHECK_SIZEOF([int])
3987AC_CHECK_SIZEOF([long])
3988AC_CHECK_SIZEOF([time_t])
3989AC_CHECK_SIZEOF([off_t])
Bram Moolenaar644fdff2010-05-30 13:26:21 +02003990
Bram Moolenaara2aa31a2014-02-23 22:52:40 +01003991dnl Use different names to avoid clashing with other header files.
3992AC_DEFINE_UNQUOTED(VIM_SIZEOF_INT, [$ac_cv_sizeof_int])
3993AC_DEFINE_UNQUOTED(VIM_SIZEOF_LONG, [$ac_cv_sizeof_long])
3994
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003995dnl Make sure that uint32_t is really 32 bits unsigned.
3996AC_MSG_CHECKING([uint32_t is 32 bits])
3997AC_TRY_RUN([
3998#ifdef HAVE_STDINT_H
3999# include <stdint.h>
4000#endif
4001#ifdef HAVE_INTTYPES_H
4002# include <inttypes.h>
4003#endif
4004main() {
4005 uint32_t nr1 = (uint32_t)-1;
4006 uint32_t nr2 = (uint32_t)0xffffffffUL;
4007 if (sizeof(uint32_t) != 4 || nr1 != 0xffffffffUL || nr2 + 1 != 0) exit(1);
4008 exit(0);
4009}],
4010AC_MSG_RESULT(ok),
4011AC_MSG_ERROR([WRONG! uint32_t not defined correctly.]),
Bram Moolenaar323cb952011-12-14 19:22:34 +01004012AC_MSG_WARN([cannot check uint32_t when cross-compiling.]))
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004013
Bram Moolenaar446cb832008-06-24 21:56:24 +00004014dnl Check for memmove() before bcopy(), makes memmove() be used when both are
4015dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
4016
Bram Moolenaar071d4272004-06-13 20:20:40 +00004017[bcopy_test_prog='
Bram Moolenaar446cb832008-06-24 21:56:24 +00004018#include "confdefs.h"
4019#ifdef HAVE_STRING_H
4020# include <string.h>
4021#endif
4022#if STDC_HEADERS
4023# include <stdlib.h>
4024# include <stddef.h>
4025#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004026main() {
4027 char buf[10];
4028 strcpy(buf, "abcdefghi");
4029 mch_memmove(buf, buf + 2, 3);
4030 if (strncmp(buf, "ababcf", 6))
4031 exit(1);
4032 strcpy(buf, "abcdefghi");
4033 mch_memmove(buf + 2, buf, 3);
4034 if (strncmp(buf, "cdedef", 6))
4035 exit(1);
4036 exit(0); /* libc version works properly. */
4037}']
4038
Bram Moolenaar446cb832008-06-24 21:56:24 +00004039AC_CACHE_CHECK([whether memmove handles overlaps],[vim_cv_memmove_handles_overlap],
4040 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004041 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 +00004042 [
4043 vim_cv_memmove_handles_overlap=yes
4044 ],[
4045 vim_cv_memmove_handles_overlap=no
4046 ],[
4047 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memmove_handles_overlap')
4048 ])
4049 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00004050
Bram Moolenaar446cb832008-06-24 21:56:24 +00004051if test "x$vim_cv_memmove_handles_overlap" = "xyes" ; then
4052 AC_DEFINE(USEMEMMOVE)
4053else
4054 AC_CACHE_CHECK([whether bcopy handles overlaps],[vim_cv_bcopy_handles_overlap],
4055 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004056 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 +00004057 [
4058 vim_cv_bcopy_handles_overlap=yes
4059 ],[
4060 vim_cv_bcopy_handles_overlap=no
4061 ],[
4062 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_bcopy_handles_overlap')
4063 ])
4064 ])
4065
4066 if test "x$vim_cv_bcopy_handles_overlap" = "xyes" ; then
4067 AC_DEFINE(USEBCOPY)
4068 else
4069 AC_CACHE_CHECK([whether memcpy handles overlaps],[vim_cv_memcpy_handles_overlap],
4070 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004071 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 +00004072 [
4073 vim_cv_memcpy_handles_overlap=yes
4074 ],[
4075 vim_cv_memcpy_handles_overlap=no
4076 ],[
4077 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memcpy_handles_overlap')
4078 ])
4079 ])
4080
4081 if test "x$vim_cv_memcpy_handles_overlap" = "xyes" ; then
4082 AC_DEFINE(USEMEMCPY)
4083 fi
4084 fi
4085fi
4086
Bram Moolenaar071d4272004-06-13 20:20:40 +00004087
4088dnl Check for multibyte locale functions
4089dnl Find out if _Xsetlocale() is supported by libX11.
4090dnl Check if X_LOCALE should be defined.
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004091if test "x$with_x" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004092 cflags_save=$CFLAGS
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004093 libs_save=$LIBS
4094 LIBS="$LIBS $X_LIBS $GUI_LIB_LOC $GUI_X_LIBS $X_PRE_LIBS $X_LIB $X_EXTRA_LIBS"
4095 CFLAGS="$CFLAGS $X_CFLAGS"
4096
4097 AC_MSG_CHECKING(whether X_LOCALE needed)
4098 AC_TRY_COMPILE([#include <X11/Xlocale.h>],,
4099 AC_TRY_LINK_FUNC([_Xsetlocale], [AC_MSG_RESULT(yes)
4100 AC_DEFINE(X_LOCALE)], AC_MSG_RESULT(no)),
4101 AC_MSG_RESULT(no))
4102
4103 AC_MSG_CHECKING(whether Xutf8SetWMProperties() can be used)
4104 AC_TRY_LINK_FUNC([Xutf8SetWMProperties], [AC_MSG_RESULT(yes)
4105 AC_DEFINE(HAVE_XUTF8SETWMPROPERTIES)], AC_MSG_RESULT(no))
4106
Bram Moolenaar071d4272004-06-13 20:20:40 +00004107 CFLAGS=$cflags_save
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004108 LIBS=$libs_save
Bram Moolenaar071d4272004-06-13 20:20:40 +00004109fi
4110
4111dnl Link with xpg4, it is said to make Korean locale working
4112AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,)
4113
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004114dnl Check how we can run ctags. Default to "ctags" when nothing works.
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02004115dnl Use --version to detect Exuberant ctags (preferred)
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004116dnl Add --fields=+S to get function signatures for omni completion.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004117dnl -t for typedefs (many ctags have this)
4118dnl -s for static functions (Elvis ctags only?)
4119dnl -v for variables. Dangerous, most ctags take this for 'vgrind style'.
4120dnl -i+m to test for older Exuberant ctags
4121AC_MSG_CHECKING(how to create tags)
4122test -f tags && mv tags tags.save
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004123if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004124 TAGPRG="ctags -I INIT+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004125elif (eval exctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
4126 TAGPRG="exctags -I INIT+ --fields=+S"
4127elif (eval exuberant-ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
4128 TAGPRG="exuberant-ctags -I INIT+ --fields=+S"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004129else
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004130 TAGPRG="ctags"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004131 (eval etags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags"
4132 (eval etags -c /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags -c"
4133 (eval ctags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags"
4134 (eval ctags -t /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -t"
4135 (eval ctags -ts /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -ts"
4136 (eval ctags -tvs /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -tvs"
4137 (eval ctags -i+m /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -i+m"
4138fi
4139test -f tags.save && mv tags.save tags
4140AC_MSG_RESULT($TAGPRG) AC_SUBST(TAGPRG)
4141
4142dnl Check how we can run man with a section number
4143AC_MSG_CHECKING(how to run man with a section nr)
4144MANDEF="man"
Bram Moolenaar8b131502008-02-13 09:28:19 +00004145(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 +00004146AC_MSG_RESULT($MANDEF)
4147if test "$MANDEF" = "man -s"; then
4148 AC_DEFINE(USEMAN_S)
4149fi
4150
4151dnl Check if gettext() is working and if it needs -lintl
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004152dnl We take care to base this on an empty LIBS: on some systems libelf would be
4153dnl in LIBS and implicitly take along libintl. The final LIBS would then not
4154dnl contain libintl, and the link step would fail due to -Wl,--as-needed.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004155AC_MSG_CHECKING(--disable-nls argument)
4156AC_ARG_ENABLE(nls,
4157 [ --disable-nls Don't support NLS (gettext()).], ,
4158 [enable_nls="yes"])
4159
4160if test "$enable_nls" = "yes"; then
4161 AC_MSG_RESULT(no)
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00004162
4163 INSTALL_LANGS=install-languages
4164 AC_SUBST(INSTALL_LANGS)
4165 INSTALL_TOOL_LANGS=install-tool-languages
4166 AC_SUBST(INSTALL_TOOL_LANGS)
4167
Bram Moolenaar071d4272004-06-13 20:20:40 +00004168 AC_CHECK_PROG(MSGFMT, msgfmt, msgfmt, )
4169 AC_MSG_CHECKING([for NLS])
4170 if test -f po/Makefile; then
4171 have_gettext="no"
4172 if test -n "$MSGFMT"; then
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004173 olibs=$LIBS
4174 LIBS=""
Bram Moolenaar071d4272004-06-13 20:20:40 +00004175 AC_TRY_LINK(
4176 [#include <libintl.h>],
4177 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004178 AC_MSG_RESULT([gettext() works]); have_gettext="yes"; LIBS=$olibs,
4179 LIBS="-lintl"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004180 AC_TRY_LINK(
4181 [#include <libintl.h>],
4182 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004183 AC_MSG_RESULT([gettext() works with -lintl]); have_gettext="yes";
4184 LIBS="$olibs -lintl",
Bram Moolenaar071d4272004-06-13 20:20:40 +00004185 AC_MSG_RESULT([gettext() doesn't work]);
4186 LIBS=$olibs))
4187 else
4188 AC_MSG_RESULT([msgfmt not found - disabled]);
4189 fi
Bram Moolenaar278eb582014-07-30 13:22:52 +02004190 if test $have_gettext = "yes" -a "x$features" != "xtiny" -a "x$features" != "xsmall"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004191 AC_DEFINE(HAVE_GETTEXT)
4192 MAKEMO=yes
4193 AC_SUBST(MAKEMO)
4194 dnl this was added in GNU gettext 0.10.36
4195 AC_CHECK_FUNCS(bind_textdomain_codeset)
4196 dnl _nl_msg_cat_cntr is required for GNU gettext
4197 AC_MSG_CHECKING([for _nl_msg_cat_cntr])
4198 AC_TRY_LINK(
4199 [#include <libintl.h>
4200 extern int _nl_msg_cat_cntr;],
4201 [++_nl_msg_cat_cntr;],
4202 AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_NL_MSG_CAT_CNTR),
4203 AC_MSG_RESULT([no]))
4204 fi
4205 else
4206 AC_MSG_RESULT([no "po/Makefile" - disabled]);
4207 fi
4208else
4209 AC_MSG_RESULT(yes)
4210fi
4211
4212dnl Check for dynamic linking loader
4213AC_CHECK_HEADER(dlfcn.h, DLL=dlfcn.h, [AC_CHECK_HEADER(dl.h, DLL=dl.h)])
4214if test x${DLL} = xdlfcn.h; then
4215 AC_DEFINE(HAVE_DLFCN_H, 1, [ Define if we have dlfcn.h. ])
4216 AC_MSG_CHECKING([for dlopen()])
4217 AC_TRY_LINK(,[
4218 extern void* dlopen();
4219 dlopen();
4220 ],
4221 AC_MSG_RESULT(yes);
4222 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4223 AC_MSG_RESULT(no);
4224 AC_MSG_CHECKING([for dlopen() in -ldl])
4225 olibs=$LIBS
4226 LIBS="$LIBS -ldl"
4227 AC_TRY_LINK(,[
4228 extern void* dlopen();
4229 dlopen();
4230 ],
4231 AC_MSG_RESULT(yes);
4232 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4233 AC_MSG_RESULT(no);
4234 LIBS=$olibs))
4235 dnl ReliantUNIX has dlopen() in libc but everything else in libdl
4236 dnl ick :-)
4237 AC_MSG_CHECKING([for dlsym()])
4238 AC_TRY_LINK(,[
4239 extern void* dlsym();
4240 dlsym();
4241 ],
4242 AC_MSG_RESULT(yes);
4243 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4244 AC_MSG_RESULT(no);
4245 AC_MSG_CHECKING([for dlsym() in -ldl])
4246 olibs=$LIBS
4247 LIBS="$LIBS -ldl"
4248 AC_TRY_LINK(,[
4249 extern void* dlsym();
4250 dlsym();
4251 ],
4252 AC_MSG_RESULT(yes);
4253 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4254 AC_MSG_RESULT(no);
4255 LIBS=$olibs))
4256elif test x${DLL} = xdl.h; then
4257 AC_DEFINE(HAVE_DL_H, 1, [ Define if we have dl.h. ])
4258 AC_MSG_CHECKING([for shl_load()])
4259 AC_TRY_LINK(,[
4260 extern void* shl_load();
4261 shl_load();
4262 ],
4263 AC_MSG_RESULT(yes);
4264 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4265 AC_MSG_RESULT(no);
4266 AC_MSG_CHECKING([for shl_load() in -ldld])
4267 olibs=$LIBS
4268 LIBS="$LIBS -ldld"
4269 AC_TRY_LINK(,[
4270 extern void* shl_load();
4271 shl_load();
4272 ],
4273 AC_MSG_RESULT(yes);
4274 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4275 AC_MSG_RESULT(no);
4276 LIBS=$olibs))
4277fi
4278AC_CHECK_HEADERS(setjmp.h)
4279
4280if test "x$MACOSX" = "xyes" -a -n "$PERL"; then
4281 dnl -ldl must come after DynaLoader.a
4282 if echo $LIBS | grep -e '-ldl' >/dev/null; then
4283 LIBS=`echo $LIBS | sed s/-ldl//`
4284 PERL_LIBS="$PERL_LIBS -ldl"
4285 fi
4286fi
4287
Bram Moolenaar164fca32010-07-14 13:58:07 +02004288if test "x$MACOSX" = "xyes"; then
4289 AC_MSG_CHECKING(whether we need -framework Cocoa)
4290 dnl Cocoa is needed with FEAT_CLIPBOARD or FEAT_MBYTE (the former is
4291 dnl disabled during tiny build)
4292 if test "x$features" != "xtiny" || test "x$enable_multibyte" = "xyes"; then
4293 LIBS=$"$LIBS -framework Cocoa"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004294 AC_MSG_RESULT(yes)
4295 else
4296 AC_MSG_RESULT(no)
4297 fi
Bram Moolenaar3437b912013-07-03 19:52:53 +02004298 dnl As mentioned above, tiny build implies os_macosx.m isn't needed.
4299 dnl Exclude it from OS_EXTRA_SRC so that linker won't complain about
4300 dnl missing Objective-C symbols.
4301 if test "x$features" = "xtiny"; then
4302 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_macosx.m++'`
4303 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_macosx.o++'`
4304 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004305fi
Bram Moolenaar164fca32010-07-14 13:58:07 +02004306if test "x$MACARCH" = "xboth" && test "x$GUITYPE" = "xCARBONGUI"; then
Bram Moolenaar595a7be2010-03-10 16:28:12 +01004307 LDFLAGS="$LDFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +00004308fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004309
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004310dnl gcc 3.1 changed the meaning of -MM. The only solution appears to be to
4311dnl use "-isystem" instead of "-I" for all non-Vim include dirs.
4312dnl But only when making dependencies, cproto and lint don't take "-isystem".
Bram Moolenaar32466aa2006-02-24 23:53:04 +00004313dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
4314dnl the number before the version number.
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004315DEPEND_CFLAGS_FILTER=
4316if test "$GCC" = yes; then
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004317 AC_MSG_CHECKING(for GCC 3 or later)
Bram Moolenaar2217cae2006-03-25 21:55:52 +00004318 gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]]\)\..*$/\1/g'`
Bram Moolenaarf740b292006-02-16 22:11:02 +00004319 if test "$gccmajor" -gt "2"; then
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004320 DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004321 AC_MSG_RESULT(yes)
4322 else
4323 AC_MSG_RESULT(no)
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004324 fi
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004325 dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
4326 dnl declared as char x[1] but actually longer. Introduced in gcc 4.0.
Bram Moolenaar56d1db32009-12-16 16:14:51 +00004327 dnl Also remove duplicate _FORTIFY_SOURCE arguments.
Bram Moolenaaraeabe052011-12-08 15:17:34 +01004328 dnl And undefine it first to avoid a warning.
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004329 AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
4330 if test "$gccmajor" -gt "3"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02004331 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 +00004332 AC_MSG_RESULT(yes)
4333 else
4334 AC_MSG_RESULT(no)
4335 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +00004336fi
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004337AC_SUBST(DEPEND_CFLAGS_FILTER)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004338
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004339dnl link.sh tries to avoid overlinking in a hackish way.
4340dnl At least GNU ld supports --as-needed which provides the same functionality
4341dnl at linker level. Let's use it.
4342AC_MSG_CHECKING(linker --as-needed support)
4343LINK_AS_NEEDED=
4344# Check if linker supports --as-needed and --no-as-needed options
4345if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02004346 LDFLAGS=`echo "$LDFLAGS" | sed -e 's/ *-Wl,--as-needed//g' | sed -e 's/$/ -Wl,--as-needed/'`
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004347 LINK_AS_NEEDED=yes
4348fi
4349if test "$LINK_AS_NEEDED" = yes; then
4350 AC_MSG_RESULT(yes)
4351else
4352 AC_MSG_RESULT(no)
4353fi
4354AC_SUBST(LINK_AS_NEEDED)
4355
Bram Moolenaar77c19352012-06-13 19:19:41 +02004356# IBM z/OS reset CFLAGS for config.mk
4357if test "$zOSUnix" = "yes"; then
4358 CFLAGS="-D_ALL_SOURCE -Wc,float\(ieee\),dll"
4359fi
4360
Bram Moolenaar071d4272004-06-13 20:20:40 +00004361dnl write output files
4362AC_OUTPUT(auto/config.mk:config.mk.in)
4363
4364dnl vim: set sw=2 tw=78 fo+=l: