blob: 0883cb7d872ef5b9e33f8fc3fa18a66884ff9dc5 [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)
Bram Moolenaard0573012017-10-28 21:11:06 +0200137 MACOS_X=yes
138 CPPFLAGS="$CPPFLAGS -DMACOS_X"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000139
140 AC_MSG_CHECKING(--disable-darwin argument)
141 AC_ARG_ENABLE(darwin,
142 [ --disable-darwin Disable Darwin (Mac OS X) support.],
143 , [enable_darwin="yes"])
144 if test "$enable_darwin" = "yes"; then
145 AC_MSG_RESULT(no)
146 AC_MSG_CHECKING(if Darwin files are there)
Bram Moolenaar164fca32010-07-14 13:58:07 +0200147 if test -f os_macosx.m; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000148 AC_MSG_RESULT(yes)
149 else
150 AC_MSG_RESULT([no, Darwin support disabled])
151 enable_darwin=no
152 fi
153 else
154 AC_MSG_RESULT([yes, Darwin support excluded])
155 fi
156
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000157 AC_MSG_CHECKING(--with-mac-arch argument)
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000158 AC_ARG_WITH(mac-arch, [ --with-mac-arch=ARCH current, intel, ppc or both],
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000159 MACARCH="$withval"; AC_MSG_RESULT($MACARCH),
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000160 MACARCH="current"; AC_MSG_RESULT(defaulting to $MACARCH))
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000161
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100162 AC_MSG_CHECKING(--with-developer-dir argument)
163 AC_ARG_WITH(developer-dir, [ --with-developer-dir=PATH use PATH as location for Xcode developer tools],
164 DEVELOPER_DIR="$withval"; AC_MSG_RESULT($DEVELOPER_DIR),
Bram Moolenaar32d03b32015-11-19 13:46:48 +0100165 AC_MSG_RESULT(not present))
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100166
167 if test "x$DEVELOPER_DIR" = "x"; then
168 AC_PATH_PROG(XCODE_SELECT, xcode-select)
169 if test "x$XCODE_SELECT" != "x"; then
170 AC_MSG_CHECKING(for developer dir using xcode-select)
171 DEVELOPER_DIR=`$XCODE_SELECT -print-path`
172 AC_MSG_RESULT([$DEVELOPER_DIR])
173 else
174 DEVELOPER_DIR=/Developer
175 fi
176 fi
177
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000178 if test "x$MACARCH" = "xboth"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000179 AC_MSG_CHECKING(for 10.4 universal SDK)
180 dnl There is a terrible inconsistency (but we appear to get away with it):
181 dnl $CFLAGS uses the 10.4u SDK library for the headers, while $CPPFLAGS
182 dnl doesn't, because "gcc -E" doesn't grok it. That means the configure
183 dnl tests using the preprocessor are actually done with the wrong header
184 dnl files. $LDFLAGS is set at the end, because configure uses it together
185 dnl with $CFLAGS and we can only have one -sysroot argument.
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000186 save_cppflags="$CPPFLAGS"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000187 save_cflags="$CFLAGS"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000188 save_ldflags="$LDFLAGS"
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100189 CFLAGS="$CFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000190 AC_TRY_LINK([ ], [ ],
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000191 AC_MSG_RESULT(found, will make universal binary),
192
193 AC_MSG_RESULT(not found)
Bram Moolenaar1f35bf92006-03-07 22:38:47 +0000194 CFLAGS="$save_cflags"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000195 AC_MSG_CHECKING(if Intel architecture is supported)
196 CPPFLAGS="$CPPFLAGS -arch i386"
197 LDFLAGS="$save_ldflags -arch i386"
198 AC_TRY_LINK([ ], [ ],
199 AC_MSG_RESULT(yes); MACARCH="intel",
200 AC_MSG_RESULT(no, using PowerPC)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000201 MACARCH="ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000202 CPPFLAGS="$save_cppflags -arch ppc"
203 LDFLAGS="$save_ldflags -arch ppc"))
204 elif test "x$MACARCH" = "xintel"; then
205 CPPFLAGS="$CPPFLAGS -arch intel"
206 LDFLAGS="$LDFLAGS -arch intel"
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000207 elif test "x$MACARCH" = "xppc"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000208 CPPFLAGS="$CPPFLAGS -arch ppc"
209 LDFLAGS="$LDFLAGS -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000210 fi
211
Bram Moolenaar071d4272004-06-13 20:20:40 +0000212 if test "$enable_darwin" = "yes"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200213 MACOS_X_DARWIN=yes
Bram Moolenaar164fca32010-07-14 13:58:07 +0200214 OS_EXTRA_SRC="os_macosx.m os_mac_conv.c";
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000215 OS_EXTRA_OBJ="objects/os_macosx.o objects/os_mac_conv.o"
Bram Moolenaar32466aa2006-02-24 23:53:04 +0000216 dnl TODO: use -arch i386 on Intel machines
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100217 dnl Removed -no-cpp-precomp, only for very old compilers.
Bram Moolenaard0573012017-10-28 21:11:06 +0200218 CPPFLAGS="$CPPFLAGS -DMACOS_X_DARWIN"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000219
220 dnl If Carbon is found, assume we don't want X11
221 dnl unless it was specifically asked for (--with-x)
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000222 dnl or Motif, Athena or GTK GUI is used.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000223 AC_CHECK_HEADER(Carbon/Carbon.h, CARBON=yes)
224 if test "x$CARBON" = "xyes"; then
Bram Moolenaar98921892016-02-23 17:14:37 +0100225 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 +0000226 with_x=no
Bram Moolenaar071d4272004-06-13 20:20:40 +0000227 fi
228 fi
229 fi
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000230
Bram Moolenaardb552d602006-03-23 22:59:57 +0000231 dnl Avoid a bug with -O2 with gcc 4.0.1. Symptom: malloc() reports double
Bram Moolenaarfd2ac762006-03-01 22:09:21 +0000232 dnl free. This happens in expand_filename(), because the optimizer swaps
Bram Moolenaardb552d602006-03-23 22:59:57 +0000233 dnl two blocks of code, both using "repl", that can't be swapped.
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000234 if test "$MACARCH" = "intel" -o "$MACARCH" = "both"; then
235 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-Oz/'`
236 fi
237
Bram Moolenaar071d4272004-06-13 20:20:40 +0000238else
239 AC_MSG_RESULT(no)
240fi
241
Bram Moolenaar39766a72013-11-03 00:41:00 +0100242dnl Mac OS X 10.9+ no longer include AvailabilityMacros.h in Carbon
243dnl so we need to include it to have access to version macros.
Bram Moolenaar18e54692013-11-03 20:26:31 +0100244AC_CHECK_HEADERS(AvailabilityMacros.h)
Bram Moolenaar39766a72013-11-03 00:41:00 +0100245
Bram Moolenaar071d4272004-06-13 20:20:40 +0000246AC_SUBST(OS_EXTRA_SRC)
247AC_SUBST(OS_EXTRA_OBJ)
248
249dnl Add /usr/local/lib to $LDFLAGS and /usr/local/include to CFLAGS.
250dnl Only when the directory exists and it wasn't there yet.
251dnl For gcc don't do this when it is already in the default search path.
Bram Moolenaar446cb832008-06-24 21:56:24 +0000252dnl Skip all of this when cross-compiling.
253if test "$cross_compiling" = no; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000254 AC_MSG_CHECKING(--with-local-dir argument)
Bram Moolenaar446cb832008-06-24 21:56:24 +0000255 have_local_include=''
256 have_local_lib=''
Bram Moolenaarc236c162008-07-13 17:41:49 +0000257 AC_ARG_WITH([local-dir], [ --with-local-dir=PATH search PATH instead of /usr/local for local libraries.
258 --without-local-dir do not search /usr/local for local libraries.], [
259 local_dir="$withval"
260 case "$withval" in
261 */*) ;;
262 no)
263 # avoid adding local dir to LDFLAGS and CPPFLAGS
Bram Moolenaare06c1882010-07-21 22:05:20 +0200264 have_local_include=yes
Bram Moolenaarc236c162008-07-13 17:41:49 +0000265 have_local_lib=yes
266 ;;
267 *) AC_MSG_ERROR(must pass path argument to --with-local-dir) ;;
268 esac
269 AC_MSG_RESULT($local_dir)
270 ], [
271 local_dir=/usr/local
272 AC_MSG_RESULT(Defaulting to $local_dir)
273 ])
274 if test "$GCC" = yes -a "$local_dir" != no; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000275 echo 'void f(){}' > conftest.c
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100276 dnl Removed -no-cpp-precomp, only needed for OS X 10.2 (Ben Fowler)
277 have_local_include=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/include"`
Bram Moolenaarc236c162008-07-13 17:41:49 +0000278 have_local_lib=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/lib"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000279 rm -f conftest.c conftest.o
Bram Moolenaar071d4272004-06-13 20:20:40 +0000280 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000281 if test -z "$have_local_lib" -a -d "${local_dir}/lib"; then
282 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 +0000283 if test "$tt" = "$LDFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000284 LDFLAGS="$LDFLAGS -L${local_dir}/lib"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000285 fi
286 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000287 if test -z "$have_local_include" -a -d "${local_dir}/include"; then
288 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 +0000289 if test "$tt" = "$CPPFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000290 CPPFLAGS="$CPPFLAGS -I${local_dir}/include"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000291 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000292 fi
293fi
294
295AC_MSG_CHECKING(--with-vim-name argument)
296AC_ARG_WITH(vim-name, [ --with-vim-name=NAME what to call the Vim executable],
297 VIMNAME="$withval"; AC_MSG_RESULT($VIMNAME),
Bram Moolenaare344bea2005-09-01 20:46:49 +0000298 VIMNAME="vim"; AC_MSG_RESULT(Defaulting to $VIMNAME))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000299AC_SUBST(VIMNAME)
300AC_MSG_CHECKING(--with-ex-name argument)
301AC_ARG_WITH(ex-name, [ --with-ex-name=NAME what to call the Ex executable],
302 EXNAME="$withval"; AC_MSG_RESULT($EXNAME),
303 EXNAME="ex"; AC_MSG_RESULT(Defaulting to ex))
304AC_SUBST(EXNAME)
305AC_MSG_CHECKING(--with-view-name argument)
306AC_ARG_WITH(view-name, [ --with-view-name=NAME what to call the View executable],
307 VIEWNAME="$withval"; AC_MSG_RESULT($VIEWNAME),
308 VIEWNAME="view"; AC_MSG_RESULT(Defaulting to view))
309AC_SUBST(VIEWNAME)
310
311AC_MSG_CHECKING(--with-global-runtime argument)
312AC_ARG_WITH(global-runtime, [ --with-global-runtime=DIR global runtime directory in 'runtimepath'],
313 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL, "$withval"),
314 AC_MSG_RESULT(no))
315
316AC_MSG_CHECKING(--with-modified-by argument)
317AC_ARG_WITH(modified-by, [ --with-modified-by=NAME name of who modified a release version],
318 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(MODIFIED_BY, "$withval"),
319 AC_MSG_RESULT(no))
320
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200321dnl Check for EBCDIC stolen from the LYNX port to z/OS Unix
Bram Moolenaar071d4272004-06-13 20:20:40 +0000322AC_MSG_CHECKING(if character set is EBCDIC)
323AC_TRY_COMPILE([ ],
324[ /* TryCompile function for CharSet.
325 Treat any failure as ASCII for compatibility with existing art.
326 Use compile-time rather than run-time tests for cross-compiler
327 tolerance. */
328#if '0'!=240
329make an error "Character set is not EBCDIC"
330#endif ],
331[ # TryCompile action if true
332cf_cv_ebcdic=yes ],
333[ # TryCompile action if false
334cf_cv_ebcdic=no])
335# end of TryCompile ])
336# end of CacheVal CvEbcdic
337AC_MSG_RESULT($cf_cv_ebcdic)
338case "$cf_cv_ebcdic" in #(vi
339 yes) AC_DEFINE(EBCDIC)
340 line_break='"\\n"'
341 ;;
342 *) line_break='"\\012"';;
343esac
344AC_SUBST(line_break)
345
346if test "$cf_cv_ebcdic" = "yes"; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +0200347dnl If we have EBCDIC we most likely have z/OS Unix, let's test it!
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200348AC_MSG_CHECKING(for z/OS Unix)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000349case `uname` in
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200350 OS/390) zOSUnix="yes";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000351 dnl If using cc the environment variable _CC_CCMODE must be
352 dnl set to "1", so that some compiler extensions are enabled.
353 dnl If using c89 the environment variable is named _CC_C89MODE.
354 dnl Note: compile with c89 never tested.
355 if test "$CC" = "cc"; then
356 ccm="$_CC_CCMODE"
357 ccn="CC"
358 else
359 if test "$CC" = "c89"; then
360 ccm="$_CC_C89MODE"
361 ccn="C89"
362 else
363 ccm=1
364 fi
365 fi
366 if test "$ccm" != "1"; then
367 echo ""
368 echo "------------------------------------------"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200369 echo " On z/OS Unix, the environment variable"
Bram Moolenaar77c19352012-06-13 19:19:41 +0200370 echo " _CC_${ccn}MODE must be set to \"1\"!"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000371 echo " Do:"
372 echo " export _CC_${ccn}MODE=1"
373 echo " and then call configure again."
374 echo "------------------------------------------"
375 exit 1
376 fi
Bram Moolenaar77c19352012-06-13 19:19:41 +0200377 # Set CFLAGS for configure process.
378 # This will be reset later for config.mk.
379 # Use haltonmsg to force error for missing H files.
380 CFLAGS="$CFLAGS -D_ALL_SOURCE -Wc,float(ieee),haltonmsg(3296)";
381 LDFLAGS="$LDFLAGS -Wl,EDIT=NO"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000382 AC_MSG_RESULT(yes)
383 ;;
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200384 *) zOSUnix="no";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000385 AC_MSG_RESULT(no)
386 ;;
387esac
388fi
389
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200390dnl Set QUOTESED. Needs additional backslashes on zOS
391if test "$zOSUnix" = "yes"; then
392 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\\\\\&/g' -e 's/\\\\\\\\\"/\"/' -e 's/\\\\\\\\\";\$\$/\";/'"
393else
394 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\&/g' -e 's/\\\\\"/\"/' -e 's/\\\\\";\$\$/\";/'"
395fi
396AC_SUBST(QUOTESED)
397
398
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200399dnl Link with -lsmack for Smack stuff; if not found
400AC_MSG_CHECKING(--disable-smack argument)
401AC_ARG_ENABLE(smack,
402 [ --disable-smack Do not check for Smack support.],
403 , enable_smack="yes")
404if test "$enable_smack" = "yes"; then
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200405 AC_MSG_RESULT(no)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200406 AC_CHECK_HEADER([linux/xattr.h], true, enable_smack="no")
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200407else
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200408 AC_MSG_RESULT(yes)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200409fi
410if test "$enable_smack" = "yes"; then
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200411 AC_CHECK_HEADER([attr/xattr.h], true, enable_smack="no")
412fi
413if test "$enable_smack" = "yes"; then
414 AC_MSG_CHECKING(for XATTR_NAME_SMACKEXEC in linux/xattr.h)
415 AC_EGREP_CPP(XATTR_NAME_SMACKEXEC, [#include <linux/xattr.h>],
416 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +0200417 AC_MSG_RESULT(no); enable_smack="no")
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200418fi
419if test "$enable_smack" = "yes"; then
420 AC_CHECK_LIB(attr, setxattr,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200421 [LIBS="$LIBS -lattr"
422 found_smack="yes"
423 AC_DEFINE(HAVE_SMACK)])
Bram Moolenaar588ebeb2008-05-07 17:09:24 +0000424fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000425
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200426dnl When smack was found don't search for SELinux
427if test "x$found_smack" = "x"; then
428 dnl Link with -lselinux for SELinux stuff; if not found
429 AC_MSG_CHECKING(--disable-selinux argument)
430 AC_ARG_ENABLE(selinux,
431 [ --disable-selinux Do not check for SELinux support.],
432 , enable_selinux="yes")
433 if test "$enable_selinux" = "yes"; then
434 AC_MSG_RESULT(no)
435 AC_CHECK_LIB(selinux, is_selinux_enabled,
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100436 [AC_CHECK_HEADER(selinux/selinux.h,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200437 [LIBS="$LIBS -lselinux"
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100438 AC_DEFINE(HAVE_SELINUX)])])
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200439 else
440 AC_MSG_RESULT(yes)
441 fi
442fi
443
Bram Moolenaar071d4272004-06-13 20:20:40 +0000444dnl Check user requested features.
445
446AC_MSG_CHECKING(--with-features argument)
Bram Moolenaareec29812016-07-26 21:27:36 +0200447AC_ARG_WITH(features, [ --with-features=TYPE tiny, small, normal, big or huge (default: huge)],
Bram Moolenaar071d4272004-06-13 20:20:40 +0000448 features="$withval"; AC_MSG_RESULT($features),
Bram Moolenaar23c4f712016-01-20 22:11:59 +0100449 features="huge"; AC_MSG_RESULT(Defaulting to huge))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000450
451dovimdiff=""
452dogvimdiff=""
453case "$features" in
454 tiny) AC_DEFINE(FEAT_TINY) ;;
455 small) AC_DEFINE(FEAT_SMALL) ;;
456 normal) AC_DEFINE(FEAT_NORMAL) dovimdiff="installvimdiff";
457 dogvimdiff="installgvimdiff" ;;
458 big) AC_DEFINE(FEAT_BIG) dovimdiff="installvimdiff";
459 dogvimdiff="installgvimdiff" ;;
460 huge) AC_DEFINE(FEAT_HUGE) dovimdiff="installvimdiff";
461 dogvimdiff="installgvimdiff" ;;
462 *) AC_MSG_RESULT([Sorry, $features is not supported]) ;;
463esac
464
465AC_SUBST(dovimdiff)
466AC_SUBST(dogvimdiff)
467
468AC_MSG_CHECKING(--with-compiledby argument)
469AC_ARG_WITH(compiledby, [ --with-compiledby=NAME name to show in :version message],
470 compiledby="$withval"; AC_MSG_RESULT($withval),
471 compiledby=""; AC_MSG_RESULT(no))
472AC_SUBST(compiledby)
473
474AC_MSG_CHECKING(--disable-xsmp argument)
475AC_ARG_ENABLE(xsmp,
476 [ --disable-xsmp Disable XSMP session management],
477 , enable_xsmp="yes")
478
479if test "$enable_xsmp" = "yes"; then
480 AC_MSG_RESULT(no)
481 AC_MSG_CHECKING(--disable-xsmp-interact argument)
482 AC_ARG_ENABLE(xsmp-interact,
483 [ --disable-xsmp-interact Disable XSMP interaction],
484 , enable_xsmp_interact="yes")
485 if test "$enable_xsmp_interact" = "yes"; then
486 AC_MSG_RESULT(no)
487 AC_DEFINE(USE_XSMP_INTERACT)
488 else
489 AC_MSG_RESULT(yes)
490 fi
491else
492 AC_MSG_RESULT(yes)
493fi
494
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200495dnl Check for Lua feature.
496AC_MSG_CHECKING(--enable-luainterp argument)
497AC_ARG_ENABLE(luainterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200498 [ --enable-luainterp[=OPTS] Include Lua interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200499 [enable_luainterp="no"])
500AC_MSG_RESULT($enable_luainterp)
501
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200502if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +0100503 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
504 AC_MSG_ERROR([cannot use Lua with tiny or small features])
505 fi
506
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200507 dnl -- find the lua executable
508 AC_SUBST(vi_cv_path_lua)
509
510 AC_MSG_CHECKING(--with-lua-prefix argument)
511 AC_ARG_WITH(lua_prefix,
512 [ --with-lua-prefix=PFX Prefix where Lua is installed.],
513 with_lua_prefix="$withval"; AC_MSG_RESULT($with_lua_prefix),
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200514 with_lua_prefix="";AC_MSG_RESULT(no))
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200515
516 if test "X$with_lua_prefix" != "X"; then
517 vi_cv_path_lua_pfx="$with_lua_prefix"
518 else
519 AC_MSG_CHECKING(LUA_PREFIX environment var)
520 if test "X$LUA_PREFIX" != "X"; then
521 AC_MSG_RESULT("$LUA_PREFIX")
522 vi_cv_path_lua_pfx="$LUA_PREFIX"
523 else
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200524 AC_MSG_RESULT([not set, default to /usr])
525 vi_cv_path_lua_pfx="/usr"
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200526 fi
527 fi
528
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200529 AC_MSG_CHECKING(--with-luajit)
530 AC_ARG_WITH(luajit,
531 [ --with-luajit Link with LuaJIT instead of Lua.],
532 [vi_cv_with_luajit="$withval"],
533 [vi_cv_with_luajit="no"])
534 AC_MSG_RESULT($vi_cv_with_luajit)
535
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200536 LUA_INC=
537 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200538 if test "x$vi_cv_with_luajit" != "xno"; then
539 dnl -- try to find LuaJIT executable
540 AC_PATH_PROG(vi_cv_path_luajit, luajit)
541 if test "X$vi_cv_path_luajit" != "X"; then
542 dnl -- find LuaJIT version
543 AC_CACHE_CHECK(LuaJIT version, vi_cv_version_luajit,
Bram Moolenaar49b10272013-11-21 12:17:51 +0100544 [ 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 +0200545 AC_CACHE_CHECK(Lua version of LuaJIT, vi_cv_version_lua_luajit,
546 [ vi_cv_version_lua_luajit=`${vi_cv_path_luajit} -e "print(_VERSION)" | sed 's/.* //'` ])
547 vi_cv_path_lua="$vi_cv_path_luajit"
548 vi_cv_version_lua="$vi_cv_version_lua_luajit"
549 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200550 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200551 dnl -- try to find Lua executable
552 AC_PATH_PROG(vi_cv_path_plain_lua, lua)
553 if test "X$vi_cv_path_plain_lua" != "X"; then
554 dnl -- find Lua version
555 AC_CACHE_CHECK(Lua version, vi_cv_version_plain_lua,
556 [ vi_cv_version_plain_lua=`${vi_cv_path_plain_lua} -e "print(_VERSION)" | sed 's/.* //'` ])
557 fi
558 vi_cv_path_lua="$vi_cv_path_plain_lua"
559 vi_cv_version_lua="$vi_cv_version_plain_lua"
560 fi
561 if test "x$vi_cv_with_luajit" != "xno" && test "X$vi_cv_version_luajit" != "X"; then
562 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 +0100563 if test -f "$vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200564 AC_MSG_RESULT(yes)
565 LUA_INC=/luajit-$vi_cv_version_luajit
566 fi
567 fi
568 if test "X$LUA_INC" = "X"; then
569 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)
Bram Moolenaar49222be2015-12-11 18:11:30 +0100570 if test -f "$vi_cv_path_lua_pfx/include/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200571 AC_MSG_RESULT(yes)
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200572 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200573 AC_MSG_RESULT(no)
574 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 +0100575 if test -f "$vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200576 AC_MSG_RESULT(yes)
577 LUA_INC=/lua$vi_cv_version_lua
578 else
579 AC_MSG_RESULT(no)
580 vi_cv_path_lua_pfx=
581 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200582 fi
583 fi
584 fi
585
586 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200587 if test "x$vi_cv_with_luajit" != "xno"; then
588 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
589 if test "X$multiarch" != "X"; then
590 lib_multiarch="lib/${multiarch}"
591 else
592 lib_multiarch="lib"
593 fi
594 if test "X$vi_cv_version_lua" = "X"; then
595 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit"
596 else
597 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit-$vi_cv_version_lua"
598 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200599 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200600 if test "X$LUA_INC" != "X"; then
601 dnl Test alternate location using version
602 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua$vi_cv_version_lua"
603 else
604 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua"
605 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200606 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200607 if test "$enable_luainterp" = "dynamic"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200608 lua_ok="yes"
609 else
610 AC_MSG_CHECKING([if link with ${LUA_LIBS} is sane])
611 libs_save=$LIBS
612 LIBS="$LIBS $LUA_LIBS"
613 AC_TRY_LINK(,[ ],
614 AC_MSG_RESULT(yes); lua_ok="yes",
615 AC_MSG_RESULT(no); lua_ok="no"; LUA_LIBS="")
616 LIBS=$libs_save
617 fi
618 if test "x$lua_ok" = "xyes"; then
619 LUA_CFLAGS="-I${vi_cv_path_lua_pfx}/include${LUA_INC}"
620 LUA_SRC="if_lua.c"
621 LUA_OBJ="objects/if_lua.o"
622 LUA_PRO="if_lua.pro"
623 AC_DEFINE(FEAT_LUA)
624 fi
625 if test "$enable_luainterp" = "dynamic"; then
626 if test "x$vi_cv_with_luajit" != "xno"; then
627 luajit="jit"
628 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200629 if test -f "${vi_cv_path_lua_pfx}/bin/cyglua-${vi_cv_version_lua}.dll"; then
630 vi_cv_dll_name_lua="cyglua-${vi_cv_version_lua}.dll"
631 else
Bram Moolenaard0573012017-10-28 21:11:06 +0200632 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200633 ext="dylib"
634 indexes=""
635 else
636 ext="so"
637 indexes=".0 .1 .2 .3 .4 .5 .6 .7 .8 .9"
638 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
639 if test "X$multiarch" != "X"; then
640 lib_multiarch="lib/${multiarch}"
641 fi
Bram Moolenaar768baac2013-04-15 14:44:57 +0200642 fi
643 dnl Determine the sover for the current version, but fallback to
644 dnl liblua${vi_cv_version_lua}.so if no sover-versioned file is found.
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200645 AC_MSG_CHECKING(if liblua${luajit}*.${ext}* can be found in $vi_cv_path_lua_pfx)
Bram Moolenaar768baac2013-04-15 14:44:57 +0200646 for subdir in "${lib_multiarch}" lib64 lib; do
647 if test -z "$subdir"; then
648 continue
649 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200650 for sover in "${vi_cv_version_lua}.${ext}" "-${vi_cv_version_lua}.${ext}" \
651 ".${vi_cv_version_lua}.${ext}" ".${ext}.${vi_cv_version_lua}"; do
652 for i in $indexes ""; do
653 if test -f "${vi_cv_path_lua_pfx}/${subdir}/liblua${luajit}${sover}$i"; then
Bram Moolenaar768baac2013-04-15 14:44:57 +0200654 sover2="$i"
655 break 3
656 fi
657 done
Bram Moolenaar07e1da62013-02-06 19:49:43 +0100658 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200659 sover=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200660 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200661 if test "X$sover" = "X"; then
662 AC_MSG_RESULT(no)
663 lua_ok="no"
664 vi_cv_dll_name_lua="liblua${luajit}.${ext}"
665 else
666 AC_MSG_RESULT(yes)
667 lua_ok="yes"
668 vi_cv_dll_name_lua="liblua${luajit}${sover}$sover2"
669 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200670 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200671 AC_DEFINE(DYNAMIC_LUA)
672 LUA_LIBS=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200673 LUA_CFLAGS="-DDYNAMIC_LUA_DLL=\\\"${vi_cv_dll_name_lua}\\\" $LUA_CFLAGS"
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200674 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200675 if test "X$LUA_CFLAGS$LUA_LIBS" != "X" && \
Bram Moolenaard0573012017-10-28 21:11:06 +0200676 test "x$MACOS_X" = "xyes" && test "x$vi_cv_with_luajit" != "xno" && \
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200677 test "`(uname -m) 2>/dev/null`" = "x86_64"; then
678 dnl OSX/x64 requires these flags. See http://luajit.org/install.html
679 LUA_LIBS="-pagezero_size 10000 -image_base 100000000 $LUA_LIBS"
680 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200681 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200682 if test "$fail_if_missing" = "yes" -a "$lua_ok" != "yes"; then
Bram Moolenaarf788a062011-12-14 20:51:25 +0100683 AC_MSG_ERROR([could not configure lua])
684 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200685 AC_SUBST(LUA_SRC)
686 AC_SUBST(LUA_OBJ)
687 AC_SUBST(LUA_PRO)
688 AC_SUBST(LUA_LIBS)
689 AC_SUBST(LUA_CFLAGS)
690fi
691
692
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000693dnl Check for MzScheme feature.
694AC_MSG_CHECKING(--enable-mzschemeinterp argument)
695AC_ARG_ENABLE(mzschemeinterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200696 [ --enable-mzschemeinterp Include MzScheme interpreter.], ,
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000697 [enable_mzschemeinterp="no"])
698AC_MSG_RESULT($enable_mzschemeinterp)
699
700if test "$enable_mzschemeinterp" = "yes"; then
701 dnl -- find the mzscheme executable
702 AC_SUBST(vi_cv_path_mzscheme)
703
704 AC_MSG_CHECKING(--with-plthome argument)
705 AC_ARG_WITH(plthome,
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000706 [ --with-plthome=PLTHOME Use PLTHOME.],
707 with_plthome="$withval"; AC_MSG_RESULT($with_plthome),
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000708 with_plthome="";AC_MSG_RESULT("no"))
709
710 if test "X$with_plthome" != "X"; then
711 vi_cv_path_mzscheme_pfx="$with_plthome"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100712 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000713 else
714 AC_MSG_CHECKING(PLTHOME environment var)
715 if test "X$PLTHOME" != "X"; then
716 AC_MSG_RESULT("$PLTHOME")
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000717 vi_cv_path_mzscheme_pfx="$PLTHOME"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100718 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000719 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000720 AC_MSG_RESULT(not set)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000721 dnl -- try to find MzScheme executable
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000722 AC_PATH_PROG(vi_cv_path_mzscheme, mzscheme)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000723
724 dnl resolve symbolic link, the executable is often elsewhere and there
725 dnl are no links for the include files.
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000726 if test "X$vi_cv_path_mzscheme" != "X"; then
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000727 lsout=`ls -l $vi_cv_path_mzscheme`
728 if echo "$lsout" | grep -e '->' >/dev/null 2>/dev/null; then
729 vi_cv_path_mzscheme=`echo "$lsout" | sed 's/.*-> \(.*\)/\1/'`
730 fi
731 fi
732
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000733 if test "X$vi_cv_path_mzscheme" != "X"; then
734 dnl -- find where MzScheme thinks it was installed
735 AC_CACHE_CHECK(MzScheme install prefix,vi_cv_path_mzscheme_pfx,
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000736 dnl different versions of MzScheme differ in command line processing
737 dnl use universal approach
738 echo "(display (simplify-path \
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000739 (build-path (call-with-values \
740 (lambda () (split-path (find-system-path (quote exec-file)))) \
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000741 (lambda (base name must-be-dir?) base)) (quote up))))" > mzdirs.scm
742 dnl Remove a trailing slash
743 [ vi_cv_path_mzscheme_pfx=`${vi_cv_path_mzscheme} -r mzdirs.scm | \
744 sed -e 's+/$++'` ])
745 rm -f mzdirs.scm
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000746 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000747 fi
748 fi
749
750 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100751 AC_MSG_CHECKING(for racket include directory)
752 SCHEME_INC=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-include-dir))) (when (path? p) (display p)))'`
753 if test "X$SCHEME_INC" != "X"; then
754 AC_MSG_RESULT(${SCHEME_INC})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000755 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100756 AC_MSG_RESULT(not found)
757 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include)
758 if test -f "$vi_cv_path_mzscheme_pfx/include/scheme.h"; then
759 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000760 AC_MSG_RESULT(yes)
Bram Moolenaard7afed32007-05-06 13:26:41 +0000761 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000762 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100763 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt)
764 if test -f "$vi_cv_path_mzscheme_pfx/include/plt/scheme.h"; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000765 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100766 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000767 else
768 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100769 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket)
770 if test -f "$vi_cv_path_mzscheme_pfx/include/racket/scheme.h"; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100771 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100772 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100773 else
774 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100775 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/)
776 if test -f /usr/include/plt/scheme.h; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100777 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100778 SCHEME_INC=/usr/include/plt
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100779 else
780 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100781 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/racket/)
782 if test -f /usr/include/racket/scheme.h; then
783 AC_MSG_RESULT(yes)
784 SCHEME_INC=/usr/include/racket
785 else
786 AC_MSG_RESULT(no)
787 vi_cv_path_mzscheme_pfx=
788 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100789 fi
790 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000791 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000792 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000793 fi
794 fi
795
796 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100797
798 AC_MSG_CHECKING(for racket lib directory)
799 SCHEME_LIB=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-lib-dir))) (when (path? p) (display p)))'`
800 if test "X$SCHEME_LIB" != "X"; then
801 AC_MSG_RESULT(${SCHEME_LIB})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000802 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100803 AC_MSG_RESULT(not found)
804 fi
805
806 for path in "${vi_cv_path_mzscheme_pfx}/lib" "${SCHEME_LIB}"; do
807 if test "X$path" != "X"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200808 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100809 MZSCHEME_LIBS="-framework Racket"
810 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
811 elif test -f "${path}/libmzscheme3m.a"; then
812 MZSCHEME_LIBS="${path}/libmzscheme3m.a"
813 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
814 elif test -f "${path}/libracket3m.a"; then
815 MZSCHEME_LIBS="${path}/libracket3m.a"
816 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
817 elif test -f "${path}/libracket.a"; then
818 MZSCHEME_LIBS="${path}/libracket.a ${path}/libmzgc.a"
819 elif test -f "${path}/libmzscheme.a"; then
820 MZSCHEME_LIBS="${path}/libmzscheme.a ${path}/libmzgc.a"
821 else
822 dnl Using shared objects
823 if test -f "${path}/libmzscheme3m.so"; then
824 MZSCHEME_LIBS="-L${path} -lmzscheme3m"
825 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
826 elif test -f "${path}/libracket3m.so"; then
827 MZSCHEME_LIBS="-L${path} -lracket3m"
828 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
829 elif test -f "${path}/libracket.so"; then
830 MZSCHEME_LIBS="-L${path} -lracket -lmzgc"
831 else
832 dnl try next until last
833 if test "$path" != "$SCHEME_LIB"; then
834 continue
835 fi
836 MZSCHEME_LIBS="-L${path} -lmzscheme -lmzgc"
837 fi
838 if test "$GCC" = yes; then
839 dnl Make Vim remember the path to the library. For when it's not in
840 dnl $LD_LIBRARY_PATH.
841 MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${path}"
842 elif test "`(uname) 2>/dev/null`" = SunOS &&
843 uname -r | grep '^5' >/dev/null; then
844 MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${path}"
845 fi
846 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000847 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100848 if test "X$MZSCHEME_LIBS" != "X"; then
849 break
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +0000850 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100851 done
852
853 AC_MSG_CHECKING([if racket requires -pthread])
854 if test "X$SCHEME_LIB" != "X" && $FGREP -e -pthread "$SCHEME_LIB/buildinfo" >/dev/null ; then
855 AC_MSG_RESULT(yes)
856 MZSCHEME_LIBS="${MZSCHEME_LIBS} -pthread"
857 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -pthread"
858 else
859 AC_MSG_RESULT(no)
860 fi
861
862 AC_MSG_CHECKING(for racket config directory)
863 SCHEME_CONFIGDIR=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-config-dir))) (when (path? p) (display p)))'`
864 if test "X$SCHEME_CONFIGDIR" != "X"; then
865 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DMZSCHEME_CONFIGDIR='\"${SCHEME_CONFIGDIR}\"'"
866 AC_MSG_RESULT(${SCHEME_CONFIGDIR})
867 else
868 AC_MSG_RESULT(not found)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000869 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100870
871 AC_MSG_CHECKING(for racket collects directory)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100872 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))))'`
873 if test "X$SCHEME_COLLECTS" = "X"; then
874 if test -d "$vi_cv_path_mzscheme_pfx/lib/plt/collects"; then
875 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/plt/
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100876 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100877 if test -d "$vi_cv_path_mzscheme_pfx/lib/racket/collects"; then
878 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/racket/
Bram Moolenaar75676462013-01-30 14:55:42 +0100879 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100880 if test -d "$vi_cv_path_mzscheme_pfx/share/racket/collects"; then
881 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/
882 else
883 if test -d "$vi_cv_path_mzscheme_pfx/collects"; then
884 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/
885 fi
Bram Moolenaar75676462013-01-30 14:55:42 +0100886 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100887 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100888 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000889 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100890 if test "X$SCHEME_COLLECTS" != "X" ; then
891 AC_MSG_RESULT(${SCHEME_COLLECTS})
892 else
893 AC_MSG_RESULT(not found)
894 fi
895
896 AC_MSG_CHECKING(for mzscheme_base.c)
897 if test -f "${SCHEME_COLLECTS}collects/scheme/base.ss" ; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000898 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +0100899 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
900 MZSCHEME_MOD="++lib scheme/base"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100901 else
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100902 if test -f "${SCHEME_COLLECTS}collects/scheme/base.rkt" ; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100903 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +0100904 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
905 MZSCHEME_MOD="++lib scheme/base"
906 else
907 if test -f "${SCHEME_COLLECTS}collects/racket/base.rkt" ; then
908 MZSCHEME_EXTRA="mzscheme_base.c"
909 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/raco ctool"
910 MZSCHEME_MOD=""
911 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100912 fi
913 fi
914 if test "X$MZSCHEME_EXTRA" != "X" ; then
915 dnl need to generate bytecode for MzScheme base
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000916 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE"
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100917 AC_MSG_RESULT(needed)
918 else
919 AC_MSG_RESULT(not needed)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000920 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100921
Bram Moolenaar9e902192013-07-17 18:58:11 +0200922 dnl On Ubuntu this fixes "undefined reference to symbol 'ffi_type_void'".
923 AC_CHECK_LIB(ffi, ffi_type_void, [MZSCHEME_LIBS="$MZSCHEME_LIBS -lffi"])
924
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000925 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -I${SCHEME_INC} \
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100926 -DMZSCHEME_COLLECTS='\"${SCHEME_COLLECTS}collects\"'"
Bram Moolenaar9e902192013-07-17 18:58:11 +0200927
928 dnl Test that we can compile a simple program with these CFLAGS and LIBS.
929 AC_MSG_CHECKING([if compile and link flags for MzScheme are sane])
930 cflags_save=$CFLAGS
931 libs_save=$LIBS
932 CFLAGS="$CFLAGS $MZSCHEME_CFLAGS"
933 LIBS="$LIBS $MZSCHEME_LIBS"
934 AC_TRY_LINK(,[ ],
935 AC_MSG_RESULT(yes); mzs_ok=yes,
936 AC_MSG_RESULT(no: MZSCHEME DISABLED); mzs_ok=no)
937 CFLAGS=$cflags_save
938 LIBS=$libs_save
939 if test $mzs_ok = yes; then
940 MZSCHEME_SRC="if_mzsch.c"
941 MZSCHEME_OBJ="objects/if_mzsch.o"
942 MZSCHEME_PRO="if_mzsch.pro"
943 AC_DEFINE(FEAT_MZSCHEME)
944 else
945 MZSCHEME_CFLAGS=
946 MZSCHEME_LIBS=
947 MZSCHEME_EXTRA=
948 MZSCHEME_MZC=
949 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000950 fi
951 AC_SUBST(MZSCHEME_SRC)
952 AC_SUBST(MZSCHEME_OBJ)
953 AC_SUBST(MZSCHEME_PRO)
954 AC_SUBST(MZSCHEME_LIBS)
955 AC_SUBST(MZSCHEME_CFLAGS)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000956 AC_SUBST(MZSCHEME_EXTRA)
957 AC_SUBST(MZSCHEME_MZC)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000958fi
959
960
Bram Moolenaar071d4272004-06-13 20:20:40 +0000961AC_MSG_CHECKING(--enable-perlinterp argument)
962AC_ARG_ENABLE(perlinterp,
Bram Moolenaare06c1882010-07-21 22:05:20 +0200963 [ --enable-perlinterp[=OPTS] Include Perl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000964 [enable_perlinterp="no"])
965AC_MSG_RESULT($enable_perlinterp)
Bram Moolenaare06c1882010-07-21 22:05:20 +0200966if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +0100967 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
968 AC_MSG_ERROR([cannot use Perl with tiny or small features])
969 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000970 AC_SUBST(vi_cv_path_perl)
971 AC_PATH_PROG(vi_cv_path_perl, perl)
972 if test "X$vi_cv_path_perl" != "X"; then
973 AC_MSG_CHECKING(Perl version)
974 if $vi_cv_path_perl -e 'require 5.003_01' >/dev/null 2>/dev/null; then
975 eval `$vi_cv_path_perl -V:usethreads`
Bram Moolenaare06c1882010-07-21 22:05:20 +0200976 eval `$vi_cv_path_perl -V:libperl`
Bram Moolenaar071d4272004-06-13 20:20:40 +0000977 if test "X$usethreads" = "XUNKNOWN" -o "X$usethreads" = "Xundef"; then
978 badthreads=no
979 else
980 if $vi_cv_path_perl -e 'require 5.6.0' >/dev/null 2>/dev/null; then
981 eval `$vi_cv_path_perl -V:use5005threads`
982 if test "X$use5005threads" = "XUNKNOWN" -o "X$use5005threads" = "Xundef"; then
983 badthreads=no
984 else
985 badthreads=yes
986 AC_MSG_RESULT(>>> Perl > 5.6 with 5.5 threads cannot be used <<<)
987 fi
988 else
989 badthreads=yes
990 AC_MSG_RESULT(>>> Perl 5.5 with threads cannot be used <<<)
991 fi
992 fi
993 if test $badthreads = no; then
994 AC_MSG_RESULT(OK)
995 eval `$vi_cv_path_perl -V:shrpenv`
996 if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04
997 shrpenv=""
998 fi
999 vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlibexp}'`
1000 AC_SUBST(vi_cv_perllib)
Bram Moolenaard5f62b12014-08-17 17:05:44 +02001001 vi_cv_perl_extutils=unknown_perl_extutils_path
1002 for extutils_rel_path in ExtUtils vendor_perl/ExtUtils; do
1003 xsubpp_path="$vi_cv_perllib/$extutils_rel_path/xsubpp"
1004 if test -f "$xsubpp_path"; then
1005 vi_cv_perl_xsubpp="$xsubpp_path"
1006 fi
1007 done
1008 AC_SUBST(vi_cv_perl_xsubpp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001009 dnl Remove "-fno-something", it breaks using cproto.
Bram Moolenaar280a8682015-06-21 13:41:08 +02001010 dnl Remove "-fdebug-prefix-map", it isn't supported by clang.
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001011 dnl Remove "FORTIFY_SOURCE", it will be defined twice.
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001012 dnl remove -pipe and -Wxxx, it confuses cproto
Bram Moolenaar071d4272004-06-13 20:20:40 +00001013 perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001014 -e 'ccflags;perl_inc;print"\n"' | sed -e 's/-fno[[^ ]]*//' \
1015 -e 's/-fdebug-prefix-map[[^ ]]*//g' \
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001016 -e 's/-pipe //' \
1017 -e 's/-W[[^ ]]*//g' \
1018 -e 's/-D_FORTIFY_SOURCE=.//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001019 dnl Remove "-lc", it breaks on FreeBSD when using "-pthread".
1020 perllibs=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed -e 'ldopts' | \
1021 sed -e '/Warning/d' -e '/Note (probably harmless)/d' \
1022 -e 's/-bE:perl.exp//' -e 's/-lc //'`
1023 dnl Don't add perl lib to $LIBS: if it's not in LD_LIBRARY_PATH
1024 dnl a test in configure may fail because of that.
1025 perlldflags=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed \
1026 -e 'ccdlflags' | sed -e 's/-bE:perl.exp//'`
1027
1028 dnl check that compiling a simple program still works with the flags
1029 dnl added for Perl.
1030 AC_MSG_CHECKING([if compile and link flags for Perl are sane])
1031 cflags_save=$CFLAGS
1032 libs_save=$LIBS
1033 ldflags_save=$LDFLAGS
1034 CFLAGS="$CFLAGS $perlcppflags"
1035 LIBS="$LIBS $perllibs"
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001036 perlldflags=`echo "$perlldflags" | sed -e 's/^ *//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001037 LDFLAGS="$perlldflags $LDFLAGS"
1038 AC_TRY_LINK(,[ ],
1039 AC_MSG_RESULT(yes); perl_ok=yes,
1040 AC_MSG_RESULT(no: PERL DISABLED); perl_ok=no)
1041 CFLAGS=$cflags_save
1042 LIBS=$libs_save
1043 LDFLAGS=$ldflags_save
1044 if test $perl_ok = yes; then
1045 if test "X$perlcppflags" != "X"; then
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001046 PERL_CFLAGS=$perlcppflags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001047 fi
1048 if test "X$perlldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001049 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$perlldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001050 LDFLAGS="$perlldflags $LDFLAGS"
1051 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001052 fi
1053 PERL_LIBS=$perllibs
1054 PERL_SRC="auto/if_perl.c if_perlsfio.c"
1055 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o"
1056 PERL_PRO="if_perl.pro if_perlsfio.pro"
1057 AC_DEFINE(FEAT_PERL)
1058 fi
1059 fi
1060 else
1061 AC_MSG_RESULT(>>> too old; need Perl version 5.003_01 or later <<<)
1062 fi
1063 fi
1064
Bram Moolenaard0573012017-10-28 21:11:06 +02001065 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00001066 dnl Mac OS X 10.2 or later
Bram Moolenaar071d4272004-06-13 20:20:40 +00001067 dir=/System/Library/Perl
1068 darwindir=$dir/darwin
1069 if test -d $darwindir; then
1070 PERL=/usr/bin/perl
1071 else
1072 dnl Mac OS X 10.3
1073 dir=/System/Library/Perl/5.8.1
1074 darwindir=$dir/darwin-thread-multi-2level
1075 if test -d $darwindir; then
1076 PERL=/usr/bin/perl
1077 fi
1078 fi
1079 if test -n "$PERL"; then
1080 PERL_DIR="$dir"
1081 PERL_CFLAGS="-DFEAT_PERL -I$darwindir/CORE"
1082 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o $darwindir/auto/DynaLoader/DynaLoader.a"
1083 PERL_LIBS="-L$darwindir/CORE -lperl"
1084 fi
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001085 dnl Perl on Mac OS X 10.5 adds "-arch" flags but these should only
1086 dnl be included if requested by passing --with-mac-arch to
1087 dnl configure, so strip these flags first (if present)
1088 PERL_LIBS=`echo "$PERL_LIBS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
1089 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 +00001090 fi
Bram Moolenaare06c1882010-07-21 22:05:20 +02001091 if test "$enable_perlinterp" = "dynamic"; then
1092 if test "$perl_ok" = "yes" -a "X$libperl" != "X"; then
1093 AC_DEFINE(DYNAMIC_PERL)
1094 PERL_CFLAGS="-DDYNAMIC_PERL_DLL=\\\"$libperl\\\" $PERL_CFLAGS"
1095 fi
1096 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001097
1098 if test "$fail_if_missing" = "yes" -a "$perl_ok" != "yes"; then
1099 AC_MSG_ERROR([could not configure perl])
1100 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001101fi
1102AC_SUBST(shrpenv)
1103AC_SUBST(PERL_SRC)
1104AC_SUBST(PERL_OBJ)
1105AC_SUBST(PERL_PRO)
1106AC_SUBST(PERL_CFLAGS)
1107AC_SUBST(PERL_LIBS)
1108
1109AC_MSG_CHECKING(--enable-pythoninterp argument)
1110AC_ARG_ENABLE(pythoninterp,
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001111 [ --enable-pythoninterp[=OPTS] Include Python interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001112 [enable_pythoninterp="no"])
1113AC_MSG_RESULT($enable_pythoninterp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001114if test "$enable_pythoninterp" = "yes" -o "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001115 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1116 AC_MSG_ERROR([cannot use Python with tiny or small features])
1117 fi
1118
Bram Moolenaar071d4272004-06-13 20:20:40 +00001119 dnl -- find the python executable
Bram Moolenaar09ba6d72012-12-12 14:25:05 +01001120 AC_PATH_PROGS(vi_cv_path_python, python2 python)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001121 if test "X$vi_cv_path_python" != "X"; then
1122
1123 dnl -- get its version number
1124 AC_CACHE_CHECK(Python version,vi_cv_var_python_version,
1125 [[vi_cv_var_python_version=`
1126 ${vi_cv_path_python} -c 'import sys; print sys.version[:3]'`
1127 ]])
1128
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001129 dnl -- it must be at least version 2.3
1130 AC_MSG_CHECKING(Python is 2.3 or better)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001131 if ${vi_cv_path_python} -c \
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001132 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001133 then
1134 AC_MSG_RESULT(yep)
1135
1136 dnl -- find where python thinks it was installed
1137 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python_pfx,
1138 [ vi_cv_path_python_pfx=`
1139 ${vi_cv_path_python} -c \
1140 "import sys; print sys.prefix"` ])
1141
1142 dnl -- and where it thinks it runs
1143 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python_epfx,
1144 [ vi_cv_path_python_epfx=`
1145 ${vi_cv_path_python} -c \
1146 "import sys; print sys.exec_prefix"` ])
1147
1148 dnl -- python's internal library path
1149
1150 AC_CACHE_VAL(vi_cv_path_pythonpath,
1151 [ vi_cv_path_pythonpath=`
1152 unset PYTHONPATH;
1153 ${vi_cv_path_python} -c \
1154 "import sys, string; print string.join(sys.path,':')"` ])
1155
1156 dnl -- where the Python implementation library archives are
1157
1158 AC_ARG_WITH(python-config-dir,
1159 [ --with-python-config-dir=PATH Python's config directory],
1160 [ vi_cv_path_python_conf="${withval}" ] )
1161
1162 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python_conf,
1163 [
1164 vi_cv_path_python_conf=
Bram Moolenaarac499e32013-06-02 19:14:17 +02001165 d=`${vi_cv_path_python} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBPL')"`
1166 if test -d "$d" && test -f "$d/config.c"; then
1167 vi_cv_path_python_conf="$d"
1168 else
1169 for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
1170 for subdir in lib64 lib share; do
1171 d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
1172 if test -d "$d" && test -f "$d/config.c"; then
1173 vi_cv_path_python_conf="$d"
1174 fi
1175 done
Bram Moolenaar071d4272004-06-13 20:20:40 +00001176 done
Bram Moolenaarac499e32013-06-02 19:14:17 +02001177 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001178 ])
1179
1180 PYTHON_CONFDIR="${vi_cv_path_python_conf}"
1181
1182 if test "X$PYTHON_CONFDIR" = "X"; then
1183 AC_MSG_RESULT([can't find it!])
1184 else
1185
1186 dnl -- we need to examine Python's config/Makefile too
1187 dnl see what the interpreter is built from
1188 AC_CACHE_VAL(vi_cv_path_python_plibs,
1189 [
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001190 pwd=`pwd`
1191 tmp_mkf="$pwd/config-PyMake$$"
1192 cat -- "${PYTHON_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001193__:
Bram Moolenaar218116c2010-05-20 21:46:00 +02001194 @echo "python_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001195 @echo "python_LIBS='$(LIBS)'"
1196 @echo "python_SYSLIBS='$(SYSLIBS)'"
1197 @echo "python_LINKFORSHARED='$(LINKFORSHARED)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001198 @echo "python_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001199 @echo "python_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001200 @echo "python_PYTHONFRAMEWORK='$(PYTHONFRAMEWORK)'"
1201 @echo "python_PYTHONFRAMEWORKPREFIX='$(PYTHONFRAMEWORKPREFIX)'"
1202 @echo "python_PYTHONFRAMEWORKINSTALLDIR='$(PYTHONFRAMEWORKINSTALLDIR)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001203eof
1204 dnl -- delete the lines from make about Entering/Leaving directory
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001205 eval "`cd ${PYTHON_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1206 rm -f -- "${tmp_mkf}"
Bram Moolenaard0573012017-10-28 21:11:06 +02001207 if test "x$MACOS_X" = "xyes" && test -n "${python_PYTHONFRAMEWORK}" && ${vi_cv_path_python} -c \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001208 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then
1209 vi_cv_path_python_plibs="-framework Python"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001210 if test "x${vi_cv_path_python}" != "x/usr/bin/python" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
1211 vi_cv_path_python_plibs="-F${python_PYTHONFRAMEWORKPREFIX} -framework Python"
1212 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001213 else
1214 if test "${vi_cv_var_python_version}" = "1.4"; then
1215 vi_cv_path_python_plibs="${PYTHON_CONFDIR}/libModules.a ${PYTHON_CONFDIR}/libPython.a ${PYTHON_CONFDIR}/libObjects.a ${PYTHON_CONFDIR}/libParser.a"
1216 else
1217 vi_cv_path_python_plibs="-L${PYTHON_CONFDIR} -lpython${vi_cv_var_python_version}"
1218 fi
Bram Moolenaar6c927552015-03-24 12:21:33 +01001219 dnl -- Check if the path contained in python_LINKFORSHARED is
1220 dnl usable for vim build. If not, make and try other
1221 dnl candidates.
Bram Moolenaara161e262015-03-24 15:14:27 +01001222 if test -n "${python_LINKFORSHARED}" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
Bram Moolenaar6c927552015-03-24 12:21:33 +01001223 python_link_symbol=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]].*/\1/'`
1224 python_link_path=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]][[ \t]]*\(.*\)/\2/'`
1225 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1226 dnl -- The path looks relative. Guess the absolute one using
1227 dnl the prefix and try that.
1228 python_link_path="${python_PYTHONFRAMEWORKPREFIX}/${python_link_path}"
1229 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1230 dnl -- A last resort.
1231 python_link_path="${python_PYTHONFRAMEWORKINSTALLDIR}/Versions/${vi_cv_var_python_version}/${python_PYTHONFRAMEWORK}"
1232 dnl -- No check is done. The last word is left to the
1233 dnl "sanity" test on link flags that follows shortly.
1234 fi
1235 python_LINKFORSHARED="${python_link_symbol} ${python_link_path}"
1236 fi
1237 fi
Bram Moolenaar218116c2010-05-20 21:46:00 +02001238 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 +00001239 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1240 vi_cv_path_python_plibs=`echo $vi_cv_path_python_plibs | sed s/-ltermcap//`
1241 fi
1242 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001243 AC_CACHE_CHECK(Python's dll name,vi_cv_dll_name_python,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001244 [
1245 if test "X$python_DLLLIBRARY" != "X"; then
1246 vi_cv_dll_name_python="$python_DLLLIBRARY"
1247 else
1248 vi_cv_dll_name_python="$python_INSTSONAME"
1249 fi
1250 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00001251
1252 PYTHON_LIBS="${vi_cv_path_python_plibs}"
1253 if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
Bram Moolenaar780c3e92013-06-11 20:53:28 +02001254 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 +00001255 else
Bram Moolenaar780c3e92013-06-11 20:53:28 +02001256 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 +00001257 fi
1258 PYTHON_SRC="if_python.c"
Bram Moolenaar9bdb9a02012-07-25 16:32:08 +02001259 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001260 if test "${vi_cv_var_python_version}" = "1.4"; then
1261 PYTHON_OBJ="$PYTHON_OBJ objects/py_getpath.o"
1262 fi
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001263 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 +00001264
1265 dnl On FreeBSD linking with "-pthread" is required to use threads.
1266 dnl _THREAD_SAFE must be used for compiling then.
1267 dnl The "-pthread" is added to $LIBS, so that the following check for
1268 dnl sigaltstack() will look in libc_r (it's there in libc!).
1269 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1270 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1271 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1272 AC_MSG_CHECKING([if -pthread should be used])
1273 threadsafe_flag=
1274 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001275 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00001276 if test "`(uname) 2>/dev/null`" != Darwin; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001277 test "$GCC" = yes && threadsafe_flag="-pthread"
1278 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1279 threadsafe_flag="-D_THREAD_SAFE"
1280 thread_lib="-pthread"
1281 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001282 if test "`(uname) 2>/dev/null`" = SunOS; then
1283 threadsafe_flag="-pthreads"
1284 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001285 fi
1286 libs_save_old=$LIBS
1287 if test -n "$threadsafe_flag"; then
1288 cflags_save=$CFLAGS
1289 CFLAGS="$CFLAGS $threadsafe_flag"
1290 LIBS="$LIBS $thread_lib"
1291 AC_TRY_LINK(,[ ],
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001292 AC_MSG_RESULT(yes); PYTHON_CFLAGS="$PYTHON_CFLAGS $threadsafe_flag",
Bram Moolenaar071d4272004-06-13 20:20:40 +00001293 AC_MSG_RESULT(no); LIBS=$libs_save_old
1294 )
1295 CFLAGS=$cflags_save
1296 else
1297 AC_MSG_RESULT(no)
1298 fi
1299
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001300 dnl Check that compiling a simple program still works with the flags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001301 dnl added for Python.
1302 AC_MSG_CHECKING([if compile and link flags for Python are sane])
1303 cflags_save=$CFLAGS
1304 libs_save=$LIBS
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001305 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001306 LIBS="$LIBS $PYTHON_LIBS"
1307 AC_TRY_LINK(,[ ],
1308 AC_MSG_RESULT(yes); python_ok=yes,
1309 AC_MSG_RESULT(no: PYTHON DISABLED); python_ok=no)
1310 CFLAGS=$cflags_save
1311 LIBS=$libs_save
1312 if test $python_ok = yes; then
1313 AC_DEFINE(FEAT_PYTHON)
1314 else
1315 LIBS=$libs_save_old
1316 PYTHON_SRC=
1317 PYTHON_OBJ=
1318 PYTHON_LIBS=
1319 PYTHON_CFLAGS=
1320 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001321 fi
1322 else
1323 AC_MSG_RESULT(too old)
1324 fi
1325 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001326
1327 if test "$fail_if_missing" = "yes" -a "$python_ok" != "yes"; then
1328 AC_MSG_ERROR([could not configure python])
1329 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001330fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001331
Bram Moolenaar071d4272004-06-13 20:20:40 +00001332AC_SUBST(PYTHON_CONFDIR)
1333AC_SUBST(PYTHON_LIBS)
1334AC_SUBST(PYTHON_GETPATH_CFLAGS)
1335AC_SUBST(PYTHON_CFLAGS)
1336AC_SUBST(PYTHON_SRC)
1337AC_SUBST(PYTHON_OBJ)
1338
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001339
1340AC_MSG_CHECKING(--enable-python3interp argument)
1341AC_ARG_ENABLE(python3interp,
Bram Moolenaar8008b632017-07-18 21:33:20 +02001342 [ --enable-python3interp[=OPTS] Include Python3 interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001343 [enable_python3interp="no"])
1344AC_MSG_RESULT($enable_python3interp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001345if test "$enable_python3interp" = "yes" -o "$enable_python3interp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001346 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1347 AC_MSG_ERROR([cannot use Python with tiny or small features])
1348 fi
1349
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001350 dnl -- find the python3 executable
Bram Moolenaar09ba6d72012-12-12 14:25:05 +01001351 AC_PATH_PROGS(vi_cv_path_python3, python3 python)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001352 if test "X$vi_cv_path_python3" != "X"; then
1353
1354 dnl -- get its version number
1355 AC_CACHE_CHECK(Python version,vi_cv_var_python3_version,
1356 [[vi_cv_var_python3_version=`
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001357 ${vi_cv_path_python3} -c 'import sys; print(sys.version[:3])'`
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001358 ]])
1359
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001360 dnl -- it must be at least version 3
1361 AC_MSG_CHECKING(Python is 3.0 or better)
1362 if ${vi_cv_path_python3} -c \
1363 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.0)"
1364 then
1365 AC_MSG_RESULT(yep)
Bram Moolenaar456f2bb2011-06-12 21:37:13 +02001366
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001367 dnl -- get abiflags for python 3.2 or higher (PEP 3149)
1368 AC_CACHE_CHECK(Python's abiflags,vi_cv_var_python3_abiflags,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001369 [
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001370 vi_cv_var_python3_abiflags=
1371 if ${vi_cv_path_python3} -c \
1372 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)"
1373 then
1374 vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \
1375 "import sys; print(sys.abiflags)"`
1376 fi ])
1377
1378 dnl -- find where python3 thinks it was installed
1379 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx,
1380 [ vi_cv_path_python3_pfx=`
1381 ${vi_cv_path_python3} -c \
1382 "import sys; print(sys.prefix)"` ])
1383
1384 dnl -- and where it thinks it runs
1385 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx,
1386 [ vi_cv_path_python3_epfx=`
1387 ${vi_cv_path_python3} -c \
1388 "import sys; print(sys.exec_prefix)"` ])
1389
1390 dnl -- python3's internal library path
1391
1392 AC_CACHE_VAL(vi_cv_path_python3path,
1393 [ vi_cv_path_python3path=`
1394 unset PYTHONPATH;
1395 ${vi_cv_path_python3} -c \
1396 "import sys, string; print(':'.join(sys.path))"` ])
1397
1398 dnl -- where the Python implementation library archives are
1399
1400 AC_ARG_WITH(python3-config-dir,
1401 [ --with-python3-config-dir=PATH Python's config directory],
1402 [ vi_cv_path_python3_conf="${withval}" ] )
1403
1404 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf,
1405 [
1406 vi_cv_path_python3_conf=
Bram Moolenaarfee496d2013-07-12 20:07:24 +02001407 config_dir="config-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001408 d=`${vi_cv_path_python3} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBPL'))"`
1409 if test -d "$d" && test -f "$d/config.c"; then
1410 vi_cv_path_python3_conf="$d"
1411 else
1412 for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do
1413 for subdir in lib64 lib share; do
1414 d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}"
1415 if test -d "$d" && test -f "$d/config.c"; then
1416 vi_cv_path_python3_conf="$d"
1417 fi
1418 done
1419 done
1420 fi
1421 ])
1422
1423 PYTHON3_CONFDIR="${vi_cv_path_python3_conf}"
1424
1425 if test "X$PYTHON3_CONFDIR" = "X"; then
1426 AC_MSG_RESULT([can't find it!])
1427 else
1428
1429 dnl -- we need to examine Python's config/Makefile too
1430 dnl see what the interpreter is built from
1431 AC_CACHE_VAL(vi_cv_path_python3_plibs,
1432 [
1433 pwd=`pwd`
1434 tmp_mkf="$pwd/config-PyMake$$"
1435 cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001436__:
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001437 @echo "python3_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001438 @echo "python3_LIBS='$(LIBS)'"
1439 @echo "python3_SYSLIBS='$(SYSLIBS)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001440 @echo "python3_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001441 @echo "python3_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001442eof
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001443 dnl -- delete the lines from make about Entering/Leaving directory
1444 eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1445 rm -f -- "${tmp_mkf}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001446 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 +02001447 vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}"
1448 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1449 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//`
1450 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//`
1451 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001452 AC_CACHE_CHECK(Python3's dll name,vi_cv_dll_name_python3,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001453 [
1454 if test "X$python3_DLLLIBRARY" != "X"; then
1455 vi_cv_dll_name_python3="$python3_DLLLIBRARY"
1456 else
1457 vi_cv_dll_name_python3="$python3_INSTSONAME"
1458 fi
1459 ])
1460
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001461 PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
1462 if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
Bram Moolenaar780c3e92013-06-11 20:53:28 +02001463 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 +02001464 else
Bram Moolenaar780c3e92013-06-11 20:53:28 +02001465 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 +02001466 fi
1467 PYTHON3_SRC="if_python3.c"
1468 PYTHON3_OBJ="objects/if_python3.o"
1469
1470 dnl On FreeBSD linking with "-pthread" is required to use threads.
1471 dnl _THREAD_SAFE must be used for compiling then.
1472 dnl The "-pthread" is added to $LIBS, so that the following check for
1473 dnl sigaltstack() will look in libc_r (it's there in libc!).
1474 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1475 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1476 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1477 AC_MSG_CHECKING([if -pthread should be used])
1478 threadsafe_flag=
1479 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001480 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001481 if test "`(uname) 2>/dev/null`" != Darwin; then
1482 test "$GCC" = yes && threadsafe_flag="-pthread"
1483 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1484 threadsafe_flag="-D_THREAD_SAFE"
1485 thread_lib="-pthread"
1486 fi
1487 if test "`(uname) 2>/dev/null`" = SunOS; then
1488 threadsafe_flag="-pthreads"
1489 fi
1490 fi
1491 libs_save_old=$LIBS
1492 if test -n "$threadsafe_flag"; then
1493 cflags_save=$CFLAGS
1494 CFLAGS="$CFLAGS $threadsafe_flag"
1495 LIBS="$LIBS $thread_lib"
1496 AC_TRY_LINK(,[ ],
1497 AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag",
1498 AC_MSG_RESULT(no); LIBS=$libs_save_old
1499 )
1500 CFLAGS=$cflags_save
1501 else
1502 AC_MSG_RESULT(no)
1503 fi
1504
1505 dnl check that compiling a simple program still works with the flags
1506 dnl added for Python.
1507 AC_MSG_CHECKING([if compile and link flags for Python 3 are sane])
1508 cflags_save=$CFLAGS
1509 libs_save=$LIBS
1510 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1511 LIBS="$LIBS $PYTHON3_LIBS"
1512 AC_TRY_LINK(,[ ],
1513 AC_MSG_RESULT(yes); python3_ok=yes,
1514 AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no)
1515 CFLAGS=$cflags_save
1516 LIBS=$libs_save
1517 if test "$python3_ok" = yes; then
1518 AC_DEFINE(FEAT_PYTHON3)
1519 else
1520 LIBS=$libs_save_old
1521 PYTHON3_SRC=
1522 PYTHON3_OBJ=
1523 PYTHON3_LIBS=
1524 PYTHON3_CFLAGS=
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001525 fi
1526 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001527 else
1528 AC_MSG_RESULT(too old)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001529 fi
1530 fi
Bram Moolenaar1612b1a2013-06-14 21:22:39 +02001531 if test "$fail_if_missing" = "yes" -a "$python3_ok" != "yes"; then
1532 AC_MSG_ERROR([could not configure python3])
1533 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001534fi
1535
1536AC_SUBST(PYTHON3_CONFDIR)
1537AC_SUBST(PYTHON3_LIBS)
1538AC_SUBST(PYTHON3_CFLAGS)
1539AC_SUBST(PYTHON3_SRC)
1540AC_SUBST(PYTHON3_OBJ)
1541
1542dnl if python2.x and python3.x are enabled one can only link in code
1543dnl with dlopen(), dlsym(), dlclose()
1544if test "$python_ok" = yes && test "$python3_ok" = yes; then
1545 AC_DEFINE(DYNAMIC_PYTHON)
1546 AC_DEFINE(DYNAMIC_PYTHON3)
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001547 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001548 cflags_save=$CFLAGS
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001549 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001550 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001551 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001552 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001553 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001554 #include <dlfcn.h>
1555 /* If this program fails, then RTLD_GLOBAL is needed.
1556 * RTLD_GLOBAL will be used and then it is not possible to
1557 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001558 * Only the first python version used will be switched on.
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001559 */
1560
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001561 int no_rtl_global_needed_for(char *python_instsoname, char *prefix)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001562 {
1563 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001564 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001565 if (pylib != 0)
1566 {
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001567 void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome");
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001568 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1569 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1570 void (*final)(void) = dlsym(pylib, "Py_Finalize");
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001571 (*pfx)(prefix);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001572 (*init)();
1573 needed = (*simple)("import termios") == -1;
1574 (*final)();
1575 dlclose(pylib);
1576 }
1577 return !needed;
1578 }
1579
1580 int main(int argc, char** argv)
1581 {
1582 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001583 if (no_rtl_global_needed_for("${vi_cv_dll_name_python}", "${vi_cv_path_python_pfx}"))
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001584 not_needed = 1;
1585 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001586 }])],
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001587 [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001588
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001589 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001590 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001591
1592 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python3)
1593 cflags_save=$CFLAGS
1594 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001595 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001596 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001597 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001598 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001599 #include <dlfcn.h>
1600 #include <wchar.h>
1601 /* If this program fails, then RTLD_GLOBAL is needed.
1602 * RTLD_GLOBAL will be used and then it is not possible to
1603 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001604 * Only the first python version used will be switched on.
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001605 */
1606
1607 int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix)
1608 {
1609 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001610 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001611 if (pylib != 0)
1612 {
1613 void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome");
1614 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1615 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1616 void (*final)(void) = dlsym(pylib, "Py_Finalize");
1617 (*pfx)(prefix);
1618 (*init)();
1619 needed = (*simple)("import termios") == -1;
1620 (*final)();
1621 dlclose(pylib);
1622 }
1623 return !needed;
1624 }
1625
1626 int main(int argc, char** argv)
1627 {
1628 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001629 if (no_rtl_global_needed_for("${vi_cv_dll_name_python3}", L"${vi_cv_path_python3_pfx}"))
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001630 not_needed = 1;
1631 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001632 }])],
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001633 [AC_MSG_RESULT(yes);AC_DEFINE(PY3_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
1634
1635 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001636 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001637
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001638 PYTHON_SRC="if_python.c"
1639 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001640 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001641 PYTHON_LIBS=
1642 PYTHON3_SRC="if_python3.c"
1643 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001644 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001645 PYTHON3_LIBS=
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001646elif test "$python_ok" = yes && test "$enable_pythoninterp" = "dynamic"; then
1647 AC_DEFINE(DYNAMIC_PYTHON)
1648 PYTHON_SRC="if_python.c"
1649 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001650 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001651 PYTHON_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001652elif test "$python_ok" = yes; then
1653 dnl Check that adding -fPIE works. It may be needed when using a static
1654 dnl Python library.
1655 AC_MSG_CHECKING([if -fPIE can be added for Python])
1656 cflags_save=$CFLAGS
1657 libs_save=$LIBS
1658 CFLAGS="$CFLAGS $PYTHON_CFLAGS -fPIE"
1659 LIBS="$LIBS $PYTHON_LIBS"
1660 AC_TRY_LINK(,[ ],
1661 AC_MSG_RESULT(yes); fpie_ok=yes,
1662 AC_MSG_RESULT(no); fpie_ok=no)
1663 CFLAGS=$cflags_save
1664 LIBS=$libs_save
1665 if test $fpie_ok = yes; then
1666 PYTHON_CFLAGS="$PYTHON_CFLAGS -fPIE"
1667 fi
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001668elif test "$python3_ok" = yes && test "$enable_python3interp" = "dynamic"; then
1669 AC_DEFINE(DYNAMIC_PYTHON3)
1670 PYTHON3_SRC="if_python3.c"
1671 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001672 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001673 PYTHON3_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001674elif test "$python3_ok" = yes; then
1675 dnl Check that adding -fPIE works. It may be needed when using a static
1676 dnl Python library.
1677 AC_MSG_CHECKING([if -fPIE can be added for Python3])
1678 cflags_save=$CFLAGS
1679 libs_save=$LIBS
1680 CFLAGS="$CFLAGS $PYTHON3_CFLAGS -fPIE"
1681 LIBS="$LIBS $PYTHON3_LIBS"
1682 AC_TRY_LINK(,[ ],
1683 AC_MSG_RESULT(yes); fpie_ok=yes,
1684 AC_MSG_RESULT(no); fpie_ok=no)
1685 CFLAGS=$cflags_save
1686 LIBS=$libs_save
1687 if test $fpie_ok = yes; then
1688 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -fPIE"
1689 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001690fi
1691
Bram Moolenaar071d4272004-06-13 20:20:40 +00001692AC_MSG_CHECKING(--enable-tclinterp argument)
1693AC_ARG_ENABLE(tclinterp,
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001694 [ --enable-tclinterp[=OPTS] Include Tcl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001695 [enable_tclinterp="no"])
1696AC_MSG_RESULT($enable_tclinterp)
1697
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001698if test "$enable_tclinterp" = "yes" -o "$enable_tclinterp" = "dynamic"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001699
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001700 dnl on FreeBSD tclsh is a silly script, look for tclsh8.[5420]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001701 AC_MSG_CHECKING(--with-tclsh argument)
1702 AC_ARG_WITH(tclsh, [ --with-tclsh=PATH which tclsh to use (default: tclsh8.0)],
1703 tclsh_name="$withval"; AC_MSG_RESULT($tclsh_name),
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001704 tclsh_name="tclsh8.5"; AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00001705 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1706 AC_SUBST(vi_cv_path_tcl)
1707
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001708 dnl when no specific version specified, also try 8.4, 8.2 and 8.0
1709 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.5"; then
1710 tclsh_name="tclsh8.4"
1711 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1712 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001713 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.4"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001714 tclsh_name="tclsh8.2"
1715 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1716 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001717 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.2"; then
1718 tclsh_name="tclsh8.0"
1719 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1720 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001721 dnl still didn't find it, try without version number
1722 if test "X$vi_cv_path_tcl" = "X"; then
1723 tclsh_name="tclsh"
1724 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1725 fi
1726 if test "X$vi_cv_path_tcl" != "X"; then
1727 AC_MSG_CHECKING(Tcl version)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001728 if echo 'exit [[expr [info tclversion] < 8.0]]' | "$vi_cv_path_tcl" - ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001729 tclver=`echo 'puts [[info tclversion]]' | $vi_cv_path_tcl -`
1730 AC_MSG_RESULT($tclver - OK);
1731 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 +01001732 tcldll=`echo 'puts libtcl[[info tclversion]][[info sharedlibextension]]' | $vi_cv_path_tcl -`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001733
1734 AC_MSG_CHECKING(for location of Tcl include)
Bram Moolenaard0573012017-10-28 21:11:06 +02001735 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001736 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 +00001737 else
1738 dnl For Mac OS X 10.3, use the OS-provided framework location
1739 tclinc="/System/Library/Frameworks/Tcl.framework/Headers"
1740 fi
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001741 TCL_INC=
Bram Moolenaar071d4272004-06-13 20:20:40 +00001742 for try in $tclinc; do
1743 if test -f "$try/tcl.h"; then
1744 AC_MSG_RESULT($try/tcl.h)
1745 TCL_INC=$try
1746 break
1747 fi
1748 done
1749 if test -z "$TCL_INC"; then
1750 AC_MSG_RESULT(<not found>)
1751 SKIP_TCL=YES
1752 fi
1753 if test -z "$SKIP_TCL"; then
1754 AC_MSG_CHECKING(for location of tclConfig.sh script)
Bram Moolenaard0573012017-10-28 21:11:06 +02001755 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001756 tclcnf=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001757 tclcnf="$tclcnf `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001758 else
1759 dnl For Mac OS X 10.3, use the OS-provided framework location
1760 tclcnf="/System/Library/Frameworks/Tcl.framework"
1761 fi
1762 for try in $tclcnf; do
Bram Moolenaar49222be2015-12-11 18:11:30 +01001763 if test -f "$try/tclConfig.sh"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001764 AC_MSG_RESULT($try/tclConfig.sh)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001765 . "$try/tclConfig.sh"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001766 dnl use eval, because tcl 8.2 includes ${TCL_DBGX}
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001767 if test "$enable_tclinterp" = "dynamic"; then
1768 TCL_LIBS=`eval echo "$TCL_STUB_LIB_SPEC $TCL_LIBS"`
1769 else
1770 TCL_LIBS=`eval echo "$TCL_LIB_SPEC $TCL_LIBS"`
1771 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001772 dnl Use $TCL_DEFS for -D_THREAD_SAFE et al. But only use the
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001773 dnl "-D_ABC" items. Watch out for -DFOO=long\ long.
Bram Moolenaar4394bff2008-07-24 11:21:31 +00001774 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 +00001775 break
1776 fi
1777 done
1778 if test -z "$TCL_LIBS"; then
1779 AC_MSG_RESULT(<not found>)
1780 AC_MSG_CHECKING(for Tcl library by myself)
1781 tcllib=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001782 tcllib="$tcllib `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001783 for ext in .so .a ; do
1784 for ver in "" $tclver ; do
1785 for try in $tcllib ; do
1786 trylib=tcl$ver$ext
Bram Moolenaar49222be2015-12-11 18:11:30 +01001787 if test -f "$try/lib$trylib" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001788 AC_MSG_RESULT($try/lib$trylib)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001789 TCL_LIBS="-L\"$try\" -ltcl$ver -ldl -lm"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001790 if test "`(uname) 2>/dev/null`" = SunOS &&
1791 uname -r | grep '^5' >/dev/null; then
1792 TCL_LIBS="$TCL_LIBS -R $try"
1793 fi
1794 break 3
1795 fi
1796 done
1797 done
1798 done
1799 if test -z "$TCL_LIBS"; then
1800 AC_MSG_RESULT(<not found>)
1801 SKIP_TCL=YES
1802 fi
1803 fi
1804 if test -z "$SKIP_TCL"; then
1805 AC_DEFINE(FEAT_TCL)
1806 TCL_SRC=if_tcl.c
1807 TCL_OBJ=objects/if_tcl.o
1808 TCL_PRO=if_tcl.pro
1809 TCL_CFLAGS="-I$TCL_INC $TCL_DEFS"
1810 fi
1811 fi
1812 else
1813 AC_MSG_RESULT(too old; need Tcl version 8.0 or later)
1814 fi
1815 fi
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001816 if test "$enable_tclinterp" = "dynamic"; then
1817 if test "X$TCL_SRC" != "X" -a "X$tcldll" != "X"; then
1818 AC_DEFINE(DYNAMIC_TCL)
1819 TCL_CFLAGS="-DDYNAMIC_TCL_DLL=\\\"$tcldll\\\" -DDYNAMIC_TCL_VER=\\\"$tclver\\\" $TCL_CFLAGS"
1820 fi
1821 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001822 if test "$fail_if_missing" = "yes" -a -z "$TCL_SRC"; then
1823 AC_MSG_ERROR([could not configure Tcl])
1824 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001825fi
1826AC_SUBST(TCL_SRC)
1827AC_SUBST(TCL_OBJ)
1828AC_SUBST(TCL_PRO)
1829AC_SUBST(TCL_CFLAGS)
1830AC_SUBST(TCL_LIBS)
1831
1832AC_MSG_CHECKING(--enable-rubyinterp argument)
1833AC_ARG_ENABLE(rubyinterp,
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001834 [ --enable-rubyinterp[=OPTS] Include Ruby interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001835 [enable_rubyinterp="no"])
1836AC_MSG_RESULT($enable_rubyinterp)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001837if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001838 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1839 AC_MSG_ERROR([cannot use Ruby with tiny or small features])
1840 fi
1841
Bram Moolenaar165641d2010-02-17 16:23:09 +01001842 AC_MSG_CHECKING(--with-ruby-command argument)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001843 AC_SUBST(vi_cv_path_ruby)
Bram Moolenaar948733a2011-05-05 18:10:16 +02001844 AC_ARG_WITH(ruby-command, [ --with-ruby-command=RUBY name of the Ruby command (default: ruby)],
1845 RUBY_CMD="$withval"; vi_cv_path_ruby="$withval"; AC_MSG_RESULT($RUBY_CMD),
1846 RUBY_CMD="ruby"; AC_MSG_RESULT(defaulting to $RUBY_CMD))
Bram Moolenaar165641d2010-02-17 16:23:09 +01001847 AC_PATH_PROG(vi_cv_path_ruby, $RUBY_CMD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001848 if test "X$vi_cv_path_ruby" != "X"; then
1849 AC_MSG_CHECKING(Ruby version)
Bram Moolenaare4efc3b2005-03-07 23:16:51 +00001850 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 +00001851 AC_MSG_RESULT(OK)
Bram Moolenaar81398892012-10-03 21:09:35 +02001852 AC_MSG_CHECKING(Ruby rbconfig)
1853 ruby_rbconfig="RbConfig"
1854 if ! $vi_cv_path_ruby -r rbconfig -e 'RbConfig' >/dev/null 2>/dev/null; then
1855 ruby_rbconfig="Config"
1856 fi
1857 AC_MSG_RESULT($ruby_rbconfig)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001858 AC_MSG_CHECKING(Ruby header files)
Bram Moolenaar81398892012-10-03 21:09:35 +02001859 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 +00001860 if test "X$rubyhdrdir" != "X"; then
1861 AC_MSG_RESULT($rubyhdrdir)
1862 RUBY_CFLAGS="-I$rubyhdrdir"
Bram Moolenaara6fd37b2014-03-27 17:19:09 +01001863 rubyarchdir=`$vi_cv_path_ruby -r rbconfig -e "print ($ruby_rbconfig::CONFIG.has_key? 'rubyarchhdrdir') ? $ruby_rbconfig::CONFIG[['rubyarchhdrdir']] : '$rubyhdrdir/'+$ruby_rbconfig::CONFIG[['arch']]"`
1864 if test -d "$rubyarchdir"; then
1865 RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyarchdir"
Bram Moolenaar165641d2010-02-17 16:23:09 +01001866 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001867 rubyversion=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['ruby_version']].gsub(/\./, '')[[0,2]]"`
Bram Moolenaar026a4452013-08-07 15:22:23 +02001868 if test "X$rubyversion" = "X"; then
1869 rubyversion=`$vi_cv_path_ruby -e "print ((VERSION rescue RUBY_VERSION)).gsub(/\./, '')[[0,2]]"`
1870 fi
Bram Moolenaar165641d2010-02-17 16:23:09 +01001871 RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
Bram Moolenaar81398892012-10-03 21:09:35 +02001872 rubylibs=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LIBS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001873 if test "X$rubylibs" != "X"; then
1874 RUBY_LIBS="$rubylibs"
1875 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001876 librubyarg=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBYARG']])"`
1877 librubya=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBY_A']])"`
Bram Moolenaarac499e32013-06-02 19:14:17 +02001878 rubylibdir=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['libdir']])"`
Bram Moolenaar948733a2011-05-05 18:10:16 +02001879 if test -f "$rubylibdir/$librubya"; then
1880 librubyarg="$librubyarg"
Bram Moolenaarac499e32013-06-02 19:14:17 +02001881 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
1882 elif test "$librubyarg" = "libruby.a"; then
1883 dnl required on Mac OS 10.3 where libruby.a doesn't exist
1884 librubyarg="-lruby"
1885 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001886 fi
1887
1888 if test "X$librubyarg" != "X"; then
1889 RUBY_LIBS="$librubyarg $RUBY_LIBS"
1890 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001891 rubyldflags=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LDFLAGS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001892 if test "X$rubyldflags" != "X"; then
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001893 dnl Ruby on Mac OS X 10.5 adds "-arch" flags but these should only
1894 dnl be included if requested by passing --with-mac-arch to
1895 dnl configure, so strip these flags first (if present)
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001896 rubyldflags=`echo "$rubyldflags" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001897 if test "X$rubyldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001898 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$rubyldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001899 LDFLAGS="$rubyldflags $LDFLAGS"
1900 fi
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001901 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001902 fi
1903 RUBY_SRC="if_ruby.c"
1904 RUBY_OBJ="objects/if_ruby.o"
1905 RUBY_PRO="if_ruby.pro"
1906 AC_DEFINE(FEAT_RUBY)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001907 if test "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar92021622017-10-12 12:33:43 +02001908 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_ALIASES']].split[[0]]"`
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001909 AC_DEFINE(DYNAMIC_RUBY)
Bram Moolenaar92021622017-10-12 12:33:43 +02001910 RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby_soname\\\" -DDYNAMIC_RUBY_VER=$rubyversion $RUBY_CFLAGS"
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001911 RUBY_LIBS=
1912 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001913 else
Bram Moolenaar165641d2010-02-17 16:23:09 +01001914 AC_MSG_RESULT(not found; disabling Ruby)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001915 fi
1916 else
1917 AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
1918 fi
1919 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001920
1921 if test "$fail_if_missing" = "yes" -a -z "$RUBY_OBJ"; then
1922 AC_MSG_ERROR([could not configure Ruby])
1923 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001924fi
1925AC_SUBST(RUBY_SRC)
1926AC_SUBST(RUBY_OBJ)
1927AC_SUBST(RUBY_PRO)
1928AC_SUBST(RUBY_CFLAGS)
1929AC_SUBST(RUBY_LIBS)
1930
1931AC_MSG_CHECKING(--enable-cscope argument)
1932AC_ARG_ENABLE(cscope,
1933 [ --enable-cscope Include cscope interface.], ,
1934 [enable_cscope="no"])
1935AC_MSG_RESULT($enable_cscope)
1936if test "$enable_cscope" = "yes"; then
1937 AC_DEFINE(FEAT_CSCOPE)
1938fi
1939
1940AC_MSG_CHECKING(--enable-workshop argument)
1941AC_ARG_ENABLE(workshop,
1942 [ --enable-workshop Include Sun Visual Workshop support.], ,
1943 [enable_workshop="no"])
1944AC_MSG_RESULT($enable_workshop)
1945if test "$enable_workshop" = "yes"; then
1946 AC_DEFINE(FEAT_SUN_WORKSHOP)
1947 WORKSHOP_SRC="workshop.c integration.c"
1948 AC_SUBST(WORKSHOP_SRC)
1949 WORKSHOP_OBJ="objects/workshop.o objects/integration.o"
1950 AC_SUBST(WORKSHOP_OBJ)
1951 if test "${enable_gui-xxx}" = xxx; then
1952 enable_gui=motif
1953 fi
1954fi
1955
1956AC_MSG_CHECKING(--disable-netbeans argument)
1957AC_ARG_ENABLE(netbeans,
1958 [ --disable-netbeans Disable NetBeans integration support.],
1959 , [enable_netbeans="yes"])
1960if test "$enable_netbeans" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01001961 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1962 AC_MSG_RESULT([cannot use NetBeans with tiny or small features])
1963 enable_netbeans="no"
1964 else
1965 AC_MSG_RESULT(no)
1966 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01001967else
1968 AC_MSG_RESULT(yes)
1969fi
1970
1971AC_MSG_CHECKING(--disable-channel argument)
1972AC_ARG_ENABLE(channel,
Bram Moolenaar8008b632017-07-18 21:33:20 +02001973 [ --disable-channel Disable process communication support.],
Bram Moolenaare0874f82016-01-24 20:36:41 +01001974 , [enable_channel="yes"])
1975if test "$enable_channel" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01001976 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1977 AC_MSG_RESULT([cannot use channels with tiny or small features])
1978 enable_channel="no"
1979 else
1980 AC_MSG_RESULT(no)
1981 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01001982else
1983 if test "$enable_netbeans" = "yes"; then
Bram Moolenaar16435482016-01-24 21:31:54 +01001984 AC_MSG_RESULT([yes, netbeans also disabled])
Bram Moolenaare0874f82016-01-24 20:36:41 +01001985 enable_netbeans="no"
1986 else
1987 AC_MSG_RESULT(yes)
1988 fi
1989fi
1990
Bram Moolenaar16435482016-01-24 21:31:54 +01001991if test "$enable_channel" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001992 dnl On Solaris we need the socket and nsl library.
1993 AC_CHECK_LIB(socket, socket)
1994 AC_CHECK_LIB(nsl, gethostbyname)
Bram Moolenaare0874f82016-01-24 20:36:41 +01001995 AC_MSG_CHECKING(whether compiling with process communication is possible)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001996 AC_TRY_LINK([
1997#include <stdio.h>
1998#include <stdlib.h>
1999#include <stdarg.h>
2000#include <fcntl.h>
2001#include <netdb.h>
2002#include <netinet/in.h>
2003#include <errno.h>
2004#include <sys/types.h>
2005#include <sys/socket.h>
2006 /* Check bitfields */
2007 struct nbbuf {
2008 unsigned int initDone:1;
Bram Moolenaar63de19e2016-12-09 20:11:26 +01002009 unsigned short signmaplen;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002010 };
2011 ], [
2012 /* Check creating a socket. */
2013 struct sockaddr_in server;
2014 (void)socket(AF_INET, SOCK_STREAM, 0);
2015 (void)htons(100);
2016 (void)gethostbyname("microsoft.com");
2017 if (errno == ECONNREFUSED)
2018 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
2019 ],
2020 AC_MSG_RESULT(yes),
Bram Moolenaare0874f82016-01-24 20:36:41 +01002021 AC_MSG_RESULT(no); enable_netbeans="no"; enable_channel="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00002022fi
2023if test "$enable_netbeans" = "yes"; then
2024 AC_DEFINE(FEAT_NETBEANS_INTG)
2025 NETBEANS_SRC="netbeans.c"
2026 AC_SUBST(NETBEANS_SRC)
2027 NETBEANS_OBJ="objects/netbeans.o"
2028 AC_SUBST(NETBEANS_OBJ)
2029fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002030if test "$enable_channel" = "yes"; then
Bram Moolenaar509ce2a2016-03-11 22:52:15 +01002031 AC_DEFINE(FEAT_JOB_CHANNEL)
Bram Moolenaare0874f82016-01-24 20:36:41 +01002032 CHANNEL_SRC="channel.c"
2033 AC_SUBST(CHANNEL_SRC)
2034 CHANNEL_OBJ="objects/channel.o"
2035 AC_SUBST(CHANNEL_OBJ)
2036fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002037
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002038AC_MSG_CHECKING(--enable-terminal argument)
2039AC_ARG_ENABLE(terminal,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002040 [ --enable-terminal Enable terminal emulation support.],
Bram Moolenaaref839562017-10-28 20:28:23 +02002041 , [enable_terminal="auto"])
Bram Moolenaar595a4022017-09-03 19:15:57 +02002042if test "$enable_terminal" = "yes" || test "$enable_terminal" = "auto" -a "x$features" = "xhuge" ; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002043 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2044 AC_MSG_RESULT([cannot use terminal emulator with tiny or small features])
2045 enable_terminal="no"
2046 else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002047 if test "$enable_terminal" = "auto"; then
2048 enable_terminal="yes"
2049 AC_MSG_RESULT(defaulting to yes)
2050 else
2051 AC_MSG_RESULT(yes)
2052 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002053 fi
2054else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002055 if test "$enable_terminal" = "auto"; then
2056 enable_terminal="no"
2057 AC_MSG_RESULT(defaulting to no)
2058 else
2059 AC_MSG_RESULT(no)
2060 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002061fi
Bram Moolenaar8b423282017-12-16 14:37:06 +01002062if test "$enable_terminal" = "yes" -a "$enable_channel" = "yes"; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002063 AC_DEFINE(FEAT_TERMINAL)
2064 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"
2065 AC_SUBST(TERM_SRC)
2066 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"
2067 AC_SUBST(TERM_OBJ)
2068fi
2069
Bram Moolenaare42a6d22017-11-12 19:21:51 +01002070AC_MSG_CHECKING(--enable-autoservername argument)
2071AC_ARG_ENABLE(autoservername,
2072 [ --enable-autoservername Automatically define servername at vim startup.], ,
2073 [enable_autoservername="no"])
2074AC_MSG_RESULT($enable_autoservername)
2075if test "$enable_autoservername" = "yes"; then
2076 AC_DEFINE(FEAT_AUTOSERVERNAME)
2077fi
2078
Bram Moolenaar071d4272004-06-13 20:20:40 +00002079AC_MSG_CHECKING(--enable-multibyte argument)
2080AC_ARG_ENABLE(multibyte,
2081 [ --enable-multibyte Include multibyte editing support.], ,
2082 [enable_multibyte="no"])
2083AC_MSG_RESULT($enable_multibyte)
2084if test "$enable_multibyte" = "yes"; then
2085 AC_DEFINE(FEAT_MBYTE)
2086fi
2087
2088AC_MSG_CHECKING(--enable-hangulinput argument)
2089AC_ARG_ENABLE(hangulinput,
2090 [ --enable-hangulinput Include Hangul input support.], ,
2091 [enable_hangulinput="no"])
2092AC_MSG_RESULT($enable_hangulinput)
2093
2094AC_MSG_CHECKING(--enable-xim argument)
2095AC_ARG_ENABLE(xim,
2096 [ --enable-xim Include XIM input support.],
2097 AC_MSG_RESULT($enable_xim),
2098 [enable_xim="auto"; AC_MSG_RESULT(defaulting to auto)])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002099
2100AC_MSG_CHECKING(--enable-fontset argument)
2101AC_ARG_ENABLE(fontset,
2102 [ --enable-fontset Include X fontset output support.], ,
2103 [enable_fontset="no"])
2104AC_MSG_RESULT($enable_fontset)
2105dnl defining FEAT_XFONTSET is delayed, so that it can be disabled for no GUI
2106
2107test -z "$with_x" && with_x=yes
Bram Moolenaard0573012017-10-28 21:11:06 +02002108test "${enable_gui-yes}" != no -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && with_x=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002109if test "$with_x" = no; then
2110 AC_MSG_RESULT(defaulting to: don't HAVE_X11)
2111else
2112 dnl Do this check early, so that its failure can override user requests.
2113
2114 AC_PATH_PROG(xmkmfpath, xmkmf)
2115
2116 AC_PATH_XTRA
2117
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002118 dnl On z/OS Unix the X libraries are DLLs. To use them the code must
Bram Moolenaar071d4272004-06-13 20:20:40 +00002119 dnl be compiled with a special option.
2120 dnl Also add SM, ICE and Xmu to X_EXTRA_LIBS.
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002121 if test "$zOSUnix" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002122 CFLAGS="$CFLAGS -W c,dll"
2123 LDFLAGS="$LDFLAGS -W l,dll"
2124 X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE -lXmu"
2125 fi
2126
2127 dnl On my HPUX system the X include dir is found, but the lib dir not.
2128 dnl This is a desparate try to fix this.
2129
2130 if test -d "$x_includes" && test ! -d "$x_libraries"; then
2131 x_libraries=`echo "$x_includes" | sed s/include/lib/`
2132 AC_MSG_RESULT(Corrected X libraries to $x_libraries)
2133 X_LIBS="$X_LIBS -L$x_libraries"
2134 if test "`(uname) 2>/dev/null`" = SunOS &&
2135 uname -r | grep '^5' >/dev/null; then
2136 X_LIBS="$X_LIBS -R $x_libraries"
2137 fi
2138 fi
2139
2140 if test -d "$x_libraries" && test ! -d "$x_includes"; then
2141 x_includes=`echo "$x_libraries" | sed s/lib/include/`
2142 AC_MSG_RESULT(Corrected X includes to $x_includes)
2143 X_CFLAGS="$X_CFLAGS -I$x_includes"
2144 fi
2145
2146 dnl Remove "-I/usr/include " from X_CFLAGS, should not be needed.
2147 X_CFLAGS="`echo $X_CFLAGS\ | sed 's%-I/usr/include %%'`"
2148 dnl Remove "-L/usr/lib " from X_LIBS, should not be needed.
2149 X_LIBS="`echo $X_LIBS\ | sed 's%-L/usr/lib %%'`"
2150 dnl Same for "-R/usr/lib ".
2151 X_LIBS="`echo $X_LIBS\ | sed -e 's%-R/usr/lib %%' -e 's%-R /usr/lib %%'`"
2152
2153
2154 dnl Check if the X11 header files are correctly installed. On some systems
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002155 dnl Xlib.h includes files that don't exist. On some systems X11/Intrinsic.h
2156 dnl is missing.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002157 AC_MSG_CHECKING(if X11 header files can be found)
2158 cflags_save=$CFLAGS
2159 CFLAGS="$CFLAGS $X_CFLAGS"
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002160 AC_TRY_COMPILE([#include <X11/Xlib.h>
2161#include <X11/Intrinsic.h>], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002162 AC_MSG_RESULT(yes),
2163 AC_MSG_RESULT(no); no_x=yes)
2164 CFLAGS=$cflags_save
2165
2166 if test "${no_x-no}" = yes; then
2167 with_x=no
2168 else
2169 AC_DEFINE(HAVE_X11)
2170 X_LIB="-lXt -lX11";
2171 AC_SUBST(X_LIB)
2172
2173 ac_save_LDFLAGS="$LDFLAGS"
2174 LDFLAGS="-L$x_libraries $LDFLAGS"
2175
2176 dnl Check for -lXdmcp (needed on SunOS 4.1.4)
2177 dnl For HP-UX 10.20 it must be before -lSM -lICE
2178 AC_CHECK_LIB(Xdmcp, _XdmcpAuthDoIt, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lXdmcp"],,
2179 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXdmcp])
2180
2181 dnl Some systems need -lnsl -lsocket when testing for ICE.
2182 dnl The check above doesn't do this, try here (again). Also needed to get
2183 dnl them after Xdmcp. link.sh will remove them when not needed.
2184 dnl Check for other function than above to avoid the cached value
2185 AC_CHECK_LIB(ICE, IceOpenConnection,
2186 [X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE"],, [$X_EXTRA_LIBS])
2187
2188 dnl Check for -lXpm (needed for some versions of Motif)
2189 LDFLAGS="$X_LIBS $ac_save_LDFLAGS"
2190 AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [X_PRE_LIBS="$X_PRE_LIBS -lXpm"],,
2191 [-lXt $X_PRE_LIBS -lXpm -lX11 $X_EXTRA_LIBS])
2192
2193 dnl Check that the X11 header files don't use implicit declarations
2194 AC_MSG_CHECKING(if X11 header files implicitly declare return values)
2195 cflags_save=$CFLAGS
Bram Moolenaard1864592013-05-04 04:40:15 +02002196 dnl -Werror is GCC only, others like Solaris Studio might not like it
2197 if test "$GCC" = yes; then
2198 CFLAGS="$CFLAGS $X_CFLAGS -Werror"
2199 else
2200 CFLAGS="$CFLAGS $X_CFLAGS"
2201 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002202 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2203 AC_MSG_RESULT(no),
2204 CFLAGS="$CFLAGS -Wno-implicit-int"
2205 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2206 AC_MSG_RESULT(yes); cflags_save="$cflags_save -Wno-implicit-int",
2207 AC_MSG_RESULT(test failed)
2208 )
2209 )
2210 CFLAGS=$cflags_save
2211
2212 LDFLAGS="$ac_save_LDFLAGS"
2213
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002214 AC_MSG_CHECKING(size of wchar_t is 2 bytes)
2215 AC_CACHE_VAL(ac_cv_small_wchar_t,
2216 [AC_TRY_RUN([
2217#include <X11/Xlib.h>
2218#if STDC_HEADERS
2219# include <stdlib.h>
2220# include <stddef.h>
2221#endif
2222 main()
2223 {
2224 if (sizeof(wchar_t) <= 2)
2225 exit(1);
2226 exit(0);
2227 }],
2228 ac_cv_small_wchar_t="no",
2229 ac_cv_small_wchar_t="yes",
2230 AC_MSG_ERROR(failed to compile test program))])
2231 AC_MSG_RESULT($ac_cv_small_wchar_t)
2232 if test "x$ac_cv_small_wchar_t" = "xyes" ; then
2233 AC_DEFINE(SMALL_WCHAR_T)
2234 fi
2235
Bram Moolenaar071d4272004-06-13 20:20:40 +00002236 fi
2237fi
2238
Bram Moolenaard0573012017-10-28 21:11:06 +02002239test "x$with_x" = xno -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && enable_gui=no
Bram Moolenaar071d4272004-06-13 20:20:40 +00002240
2241AC_MSG_CHECKING(--enable-gui argument)
2242AC_ARG_ENABLE(gui,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002243 [ --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 +00002244
2245dnl Canonicalize the --enable-gui= argument so that it can be easily compared.
2246dnl Do not use character classes for portability with old tools.
2247enable_gui_canon=`echo "_$enable_gui" | \
2248 sed 's/[[ _+-]]//g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
2249
2250dnl Skip everything by default.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002251SKIP_GTK2=YES
Bram Moolenaar1858a842016-02-23 22:30:31 +01002252SKIP_GTK3=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002253SKIP_GNOME=YES
2254SKIP_MOTIF=YES
2255SKIP_ATHENA=YES
2256SKIP_NEXTAW=YES
2257SKIP_PHOTON=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002258SKIP_CARBON=YES
2259GUITYPE=NONE
2260
Bram Moolenaarb11160e2005-01-04 21:31:43 +00002261if test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002262 SKIP_PHOTON=
2263 case "$enable_gui_canon" in
2264 no) AC_MSG_RESULT(no GUI support)
2265 SKIP_PHOTON=YES ;;
2266 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
2267 auto) AC_MSG_RESULT(auto - automatic GUI support) ;;
2268 photon) AC_MSG_RESULT(Photon GUI support) ;;
2269 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2270 SKIP_PHOTON=YES ;;
2271 esac
2272
Bram Moolenaard0573012017-10-28 21:11:06 +02002273elif test "x$MACOS_X" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002274 SKIP_CARBON=
2275 case "$enable_gui_canon" in
2276 no) AC_MSG_RESULT(no GUI support)
2277 SKIP_CARBON=YES ;;
2278 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
Bram Moolenaar164fca32010-07-14 13:58:07 +02002279 auto) AC_MSG_RESULT(auto - Carbon GUI is outdated - disable GUI support)
2280 SKIP_CARBON=YES ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002281 carbon) AC_MSG_RESULT(Carbon GUI support) ;;
2282 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2283 SKIP_CARBON=YES ;;
2284 esac
2285
2286else
2287
Bram Moolenaar071d4272004-06-13 20:20:40 +00002288 case "$enable_gui_canon" in
2289 no|none) AC_MSG_RESULT(no GUI support) ;;
2290 yes|""|auto) AC_MSG_RESULT(yes/auto - automatic GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002291 SKIP_GTK2=
2292 SKIP_GNOME=
2293 SKIP_MOTIF=
2294 SKIP_ATHENA=
2295 SKIP_NEXTAW=
2296 SKIP_CARBON=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002297 gtk2) AC_MSG_RESULT(GTK+ 2.x GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002298 SKIP_GTK2=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002299 gnome2) AC_MSG_RESULT(GNOME 2.x GUI support)
2300 SKIP_GNOME=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002301 SKIP_GTK2=;;
Bram Moolenaar98921892016-02-23 17:14:37 +01002302 gtk3) AC_MSG_RESULT(GTK+ 3.x GUI support)
2303 SKIP_GTK3=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002304 motif) AC_MSG_RESULT(Motif GUI support)
2305 SKIP_MOTIF=;;
2306 athena) AC_MSG_RESULT(Athena GUI support)
2307 SKIP_ATHENA=;;
2308 nextaw) AC_MSG_RESULT(neXtaw GUI support)
2309 SKIP_NEXTAW=;;
2310 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
2311 esac
2312
2313fi
2314
Bram Moolenaar071d4272004-06-13 20:20:40 +00002315if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \
2316 -a "$enable_gui_canon" != "gnome2"; then
2317 AC_MSG_CHECKING(whether or not to look for GTK+ 2)
2318 AC_ARG_ENABLE(gtk2-check,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002319 [ --enable-gtk2-check If auto-select GUI, check for GTK+ 2 [default=yes]],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002320 , enable_gtk2_check="yes")
2321 AC_MSG_RESULT($enable_gtk2_check)
2322 if test "x$enable_gtk2_check" = "xno"; then
2323 SKIP_GTK2=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002324 SKIP_GNOME=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002325 fi
2326fi
2327
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002328if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002329 AC_MSG_CHECKING(whether or not to look for GNOME)
2330 AC_ARG_ENABLE(gnome-check,
2331 [ --enable-gnome-check If GTK GUI, check for GNOME [default=no]],
2332 , enable_gnome_check="no")
2333 AC_MSG_RESULT($enable_gnome_check)
2334 if test "x$enable_gnome_check" = "xno"; then
2335 SKIP_GNOME=YES
2336 fi
2337fi
2338
Bram Moolenaar98921892016-02-23 17:14:37 +01002339if test "x$SKIP_GTK3" != "xYES" -a "$enable_gui_canon" != "gtk3"; then
2340 AC_MSG_CHECKING(whether or not to look for GTK+ 3)
2341 AC_ARG_ENABLE(gtk3-check,
2342 [ --enable-gtk3-check If auto-select GUI, check for GTK+ 3 [default=yes]],
2343 , enable_gtk3_check="yes")
2344 AC_MSG_RESULT($enable_gtk3_check)
2345 if test "x$enable_gtk3_check" = "xno"; then
2346 SKIP_GTK3=YES
2347 fi
2348fi
2349
Bram Moolenaar071d4272004-06-13 20:20:40 +00002350if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then
2351 AC_MSG_CHECKING(whether or not to look for Motif)
2352 AC_ARG_ENABLE(motif-check,
2353 [ --enable-motif-check If auto-select GUI, check for Motif [default=yes]],
2354 , enable_motif_check="yes")
2355 AC_MSG_RESULT($enable_motif_check)
2356 if test "x$enable_motif_check" = "xno"; then
2357 SKIP_MOTIF=YES
2358 fi
2359fi
2360
2361if test "x$SKIP_ATHENA" != "xYES" -a "$enable_gui_canon" != "athena"; then
2362 AC_MSG_CHECKING(whether or not to look for Athena)
2363 AC_ARG_ENABLE(athena-check,
2364 [ --enable-athena-check If auto-select GUI, check for Athena [default=yes]],
2365 , enable_athena_check="yes")
2366 AC_MSG_RESULT($enable_athena_check)
2367 if test "x$enable_athena_check" = "xno"; then
2368 SKIP_ATHENA=YES
2369 fi
2370fi
2371
2372if test "x$SKIP_NEXTAW" != "xYES" -a "$enable_gui_canon" != "nextaw"; then
2373 AC_MSG_CHECKING(whether or not to look for neXtaw)
2374 AC_ARG_ENABLE(nextaw-check,
2375 [ --enable-nextaw-check If auto-select GUI, check for neXtaw [default=yes]],
2376 , enable_nextaw_check="yes")
2377 AC_MSG_RESULT($enable_nextaw_check);
2378 if test "x$enable_nextaw_check" = "xno"; then
2379 SKIP_NEXTAW=YES
2380 fi
2381fi
2382
2383if test "x$SKIP_CARBON" != "xYES" -a "$enable_gui_canon" != "carbon"; then
2384 AC_MSG_CHECKING(whether or not to look for Carbon)
2385 AC_ARG_ENABLE(carbon-check,
2386 [ --enable-carbon-check If auto-select GUI, check for Carbon [default=yes]],
2387 , enable_carbon_check="yes")
2388 AC_MSG_RESULT($enable_carbon_check);
2389 if test "x$enable_carbon_check" = "xno"; then
2390 SKIP_CARBON=YES
2391 fi
2392fi
2393
Bram Moolenaar843ee412004-06-30 16:16:41 +00002394
Bram Moolenaard0573012017-10-28 21:11:06 +02002395if test "x$MACOS_X" = "xyes" -a -z "$SKIP_CARBON" -a "x$CARBON" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002396 AC_MSG_CHECKING(for Carbon GUI)
Bram Moolenaar14716812006-05-04 21:54:08 +00002397 dnl already did the check, just give the message
Bram Moolenaar071d4272004-06-13 20:20:40 +00002398 AC_MSG_RESULT(yes);
2399 GUITYPE=CARBONGUI
Bram Moolenaare344bea2005-09-01 20:46:49 +00002400 if test "$VIMNAME" = "vim"; then
2401 VIMNAME=Vim
2402 fi
Bram Moolenaar14716812006-05-04 21:54:08 +00002403
Bram Moolenaar164fca32010-07-14 13:58:07 +02002404 if test "x$MACARCH" = "xboth"; then
2405 CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk/Developer/Headers/FlatCarbon"
2406 else
2407 CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/Headers/FlatCarbon"
2408 fi
2409
Bram Moolenaar14716812006-05-04 21:54:08 +00002410 dnl Default install directory is not /usr/local
2411 if test x$prefix = xNONE; then
2412 prefix=/Applications
2413 fi
2414
2415 dnl Sorry for the hard coded default
2416 datadir='${prefix}/Vim.app/Contents/Resources'
2417
Bram Moolenaar071d4272004-06-13 20:20:40 +00002418 dnl skip everything else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002419 SKIP_GTK2=YES;
2420 SKIP_GNOME=YES;
2421 SKIP_MOTIF=YES;
2422 SKIP_ATHENA=YES;
2423 SKIP_NEXTAW=YES;
2424 SKIP_PHOTON=YES;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002425 SKIP_CARBON=YES
2426fi
2427
Bram Moolenaar071d4272004-06-13 20:20:40 +00002428dnl define an autoconf function to check for a specified version of GTK, and
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002429dnl try to compile/link a GTK program.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002430dnl
2431dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002432dnl Test for GTK, and define GTK_CFLAGS, GTK_LIBDIR and GTK_LIBS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002433dnl
2434AC_DEFUN(AM_PATH_GTK,
2435[
2436 if test "X$GTK_CONFIG" != "Xno" -o "X$PKG_CONFIG" != "Xno"; then
2437 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00002438 no_gtk=""
2439 if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2440 && $PKG_CONFIG --exists gtk+-2.0; then
2441 {
Bram Moolenaar98921892016-02-23 17:14:37 +01002442 min_gtk_version=ifelse([$1], ,2.2.0,$1)
2443 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002444 dnl We should be using PKG_CHECK_MODULES() instead of this hack.
2445 dnl But I guess the dependency on pkgconfig.m4 is not wanted or
2446 dnl something like that.
2447 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0`
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002448 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-2.0`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002449 GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0`
2450 gtk_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2451 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2452 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2453 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2454 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2455 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2456 }
Bram Moolenaar98921892016-02-23 17:14:37 +01002457 elif (test "X$SKIP_GTK3" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2458 && $PKG_CONFIG --exists gtk+-3.0; then
2459 {
2460 min_gtk_version=ifelse([$1], ,3.0.0,$1)
2461 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
2462
2463 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-3.0`
2464 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-3.0`
2465 GTK_LIBS=`$PKG_CONFIG --libs gtk+-3.0`
2466 gtk_major_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2467 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2468 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2469 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2470 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2471 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2472 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002473 else
2474 no_gtk=yes
2475 fi
2476
2477 if test "x$enable_gtktest" = "xyes" -a "x$no_gtk" = "x"; then
2478 {
2479 ac_save_CFLAGS="$CFLAGS"
2480 ac_save_LIBS="$LIBS"
2481 CFLAGS="$CFLAGS $GTK_CFLAGS"
2482 LIBS="$LIBS $GTK_LIBS"
2483
2484 dnl
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002485 dnl Now check if the installed GTK is sufficiently new.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002486 dnl
2487 rm -f conf.gtktest
2488 AC_TRY_RUN([
2489#include <gtk/gtk.h>
2490#include <stdio.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00002491#if STDC_HEADERS
2492# include <stdlib.h>
2493# include <stddef.h>
2494#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002495
2496int
2497main ()
2498{
2499int major, minor, micro;
2500char *tmp_version;
2501
2502system ("touch conf.gtktest");
2503
2504/* HP/UX 9 (%@#!) writes to sscanf strings */
2505tmp_version = g_strdup("$min_gtk_version");
2506if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
2507 printf("%s, bad version string\n", "$min_gtk_version");
2508 exit(1);
2509 }
2510
2511if ((gtk_major_version > major) ||
2512 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
2513 ((gtk_major_version == major) && (gtk_minor_version == minor) &&
2514 (gtk_micro_version >= micro)))
2515{
2516 return 0;
2517}
2518return 1;
2519}
2520],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
2521 CFLAGS="$ac_save_CFLAGS"
2522 LIBS="$ac_save_LIBS"
2523 }
2524 fi
2525 if test "x$no_gtk" = x ; then
2526 if test "x$enable_gtktest" = "xyes"; then
2527 AC_MSG_RESULT(yes; found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2528 else
2529 AC_MSG_RESULT(found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2530 fi
2531 ifelse([$2], , :, [$2])
2532 else
2533 {
2534 AC_MSG_RESULT(no)
2535 GTK_CFLAGS=""
2536 GTK_LIBS=""
2537 ifelse([$3], , :, [$3])
2538 }
2539 fi
2540 }
2541 else
2542 GTK_CFLAGS=""
2543 GTK_LIBS=""
2544 ifelse([$3], , :, [$3])
2545 fi
2546 AC_SUBST(GTK_CFLAGS)
2547 AC_SUBST(GTK_LIBS)
2548 rm -f conf.gtktest
2549])
2550
2551dnl ---------------------------------------------------------------------------
2552dnl gnome
2553dnl ---------------------------------------------------------------------------
2554AC_DEFUN([GNOME_INIT_HOOK],
2555[
2556 AC_SUBST(GNOME_LIBS)
2557 AC_SUBST(GNOME_LIBDIR)
2558 AC_SUBST(GNOME_INCLUDEDIR)
2559
2560 AC_ARG_WITH(gnome-includes,
2561 [ --with-gnome-includes=DIR Specify location of GNOME headers],
2562 [CFLAGS="$CFLAGS -I$withval"]
2563 )
2564
2565 AC_ARG_WITH(gnome-libs,
2566 [ --with-gnome-libs=DIR Specify location of GNOME libs],
2567 [LDFLAGS="$LDFLAGS -L$withval" gnome_prefix=$withval]
2568 )
2569
2570 AC_ARG_WITH(gnome,
2571 [ --with-gnome Specify prefix for GNOME files],
2572 if test x$withval = xyes; then
2573 want_gnome=yes
2574 ifelse([$1], [], :, [$1])
2575 else
2576 if test "x$withval" = xno; then
2577 want_gnome=no
2578 else
2579 want_gnome=yes
2580 LDFLAGS="$LDFLAGS -L$withval/lib"
2581 CFLAGS="$CFLAGS -I$withval/include"
2582 gnome_prefix=$withval/lib
2583 fi
2584 fi,
2585 want_gnome=yes)
2586
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002587 if test "x$want_gnome" = xyes; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002588 {
2589 AC_MSG_CHECKING(for libgnomeui-2.0)
2590 if $PKG_CONFIG --exists libgnomeui-2.0; then
2591 AC_MSG_RESULT(yes)
2592 GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0`
2593 GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0`
2594 GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0`
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002595
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002596 dnl On FreeBSD we need -pthread but pkg-config doesn't include it.
2597 dnl This might not be the right way but it works for me...
2598 AC_MSG_CHECKING(for FreeBSD)
2599 if test "`(uname) 2>/dev/null`" = FreeBSD; then
2600 AC_MSG_RESULT(yes, adding -pthread)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002601 GNOME_INCLUDEDIR="$GNOME_INCLUDEDIR -D_THREAD_SAFE"
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002602 GNOME_LIBS="$GNOME_LIBS -pthread"
2603 else
2604 AC_MSG_RESULT(no)
2605 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002606 $1
2607 else
2608 AC_MSG_RESULT(not found)
2609 if test "x$2" = xfail; then
2610 AC_MSG_ERROR(Could not find libgnomeui-2.0 via pkg-config)
2611 fi
2612 fi
2613 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002614 fi
2615])
2616
2617AC_DEFUN([GNOME_INIT],[
2618 GNOME_INIT_HOOK([],fail)
2619])
2620
2621
2622dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002623dnl Check for GTK2. If it fails, then continue on for Motif as before...
Bram Moolenaar071d4272004-06-13 20:20:40 +00002624dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002625if test -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002626
2627 AC_MSG_CHECKING(--disable-gtktest argument)
2628 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2629 , enable_gtktest=yes)
2630 if test "x$enable_gtktest" = "xyes" ; then
2631 AC_MSG_RESULT(gtk test enabled)
2632 else
2633 AC_MSG_RESULT(gtk test disabled)
2634 fi
2635
Bram Moolenaar071d4272004-06-13 20:20:40 +00002636 if test "X$PKG_CONFIG" = "X"; then
2637 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
2638 fi
2639
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002640 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002641 dnl First try finding version 2.2.0 or later. The 2.0.x series has
2642 dnl problems (bold fonts, --remote doesn't work).
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002643 AM_PATH_GTK(2.2.0,
2644 [GUI_LIB_LOC="$GTK_LIBDIR"
2645 GTK_LIBNAME="$GTK_LIBS"
2646 GUI_INC_LOC="$GTK_CFLAGS"], )
2647 if test "x$GTK_CFLAGS" != "x"; then
Bram Moolenaar98921892016-02-23 17:14:37 +01002648 SKIP_GTK3=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002649 SKIP_ATHENA=YES
2650 SKIP_NEXTAW=YES
2651 SKIP_MOTIF=YES
2652 GUITYPE=GTK
2653 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002654 fi
2655 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002656 if test "x$GUITYPE" = "xGTK"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002657 dnl
2658 dnl if GTK exists, then check for GNOME.
2659 dnl
2660 if test -z "$SKIP_GNOME"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002661 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002662 GNOME_INIT_HOOK([have_gnome=yes])
2663 if test "x$have_gnome" = xyes ; then
2664 AC_DEFINE(FEAT_GUI_GNOME)
2665 GUI_INC_LOC="$GUI_INC_LOC $GNOME_INCLUDEDIR"
2666 GTK_LIBNAME="$GTK_LIBNAME $GNOME_LIBDIR $GNOME_LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002667 fi
2668 }
2669 fi
2670 fi
2671fi
2672
Bram Moolenaar98921892016-02-23 17:14:37 +01002673
2674dnl ---------------------------------------------------------------------------
2675dnl Check for GTK3.
2676dnl ---------------------------------------------------------------------------
2677if test -z "$SKIP_GTK3"; then
2678
2679 AC_MSG_CHECKING(--disable-gtktest argument)
2680 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2681 , enable_gtktest=yes)
2682 if test "x$enable_gtktest" = "xyes" ; then
2683 AC_MSG_RESULT(gtk test enabled)
2684 else
2685 AC_MSG_RESULT(gtk test disabled)
2686 fi
2687
2688 if test "X$PKG_CONFIG" = "X"; then
2689 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
2690 fi
2691
2692 if test "x$PKG_CONFIG" != "xno"; then
2693 AM_PATH_GTK(3.0.0,
2694 [GUI_LIB_LOC="$GTK_LIBDIR"
2695 GTK_LIBNAME="$GTK_LIBS"
2696 GUI_INC_LOC="$GTK_CFLAGS"], )
2697 if test "x$GTK_CFLAGS" != "x"; then
2698 SKIP_GTK2=YES
2699 SKIP_GNOME=YES
2700 SKIP_ATHENA=YES
2701 SKIP_NEXTAW=YES
2702 SKIP_MOTIF=YES
2703 GUITYPE=GTK
2704 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar98921892016-02-23 17:14:37 +01002705 AC_DEFINE(USE_GTK3)
2706 fi
2707 fi
2708fi
2709
Bram Moolenaard2e03f02016-01-02 22:46:36 +01002710dnl Check the version of Gdk-Pixbuf. If the version is 2.31 or later and
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002711dnl glib-compile-resources is found in PATH, use GResource.
2712if test "x$GUITYPE" = "xGTK"; then
2713 AC_MSG_CHECKING([version of Gdk-Pixbuf])
2714 gdk_pixbuf_version=`$PKG_CONFIG --modversion gdk-pixbuf-2.0`
2715 if test "x$gdk_pixbuf_version" != x ; then
2716 gdk_pixbuf_version_minor=`echo $gdk_pixbuf_version | \
2717 sed -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/'`
2718 if test "x$gdk_pixbuf_version_minor" != x -a \
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002719 $gdk_pixbuf_version_minor -ge 31 ; then
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002720 AC_MSG_RESULT([OK.])
2721 AC_PATH_PROG(GLIB_COMPILE_RESOURCES,[glib-compile-resources],no)
2722 AC_MSG_CHECKING([glib-compile-resources])
2723 if test "x$GLIB_COMPILE_RESOURCES" = xno ; then
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002724 GLIB_COMPILE_RESOURCES=""
2725 AC_MSG_RESULT([cannot be found in PATH.])
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002726 else
2727 AC_MSG_RESULT([usable.])
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002728 AC_DEFINE(USE_GRESOURCE)
2729 GRESOURCE_SRC="auto/gui_gtk_gresources.c"
2730 GRESOURCE_OBJ="objects/gui_gtk_gresources.o"
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002731 fi
2732 else
2733 AC_MSG_RESULT([not usable.])
2734 fi
2735 else
2736 AC_MSG_RESULT([cannot obtain from pkg_config.])
2737 fi
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002738
2739 AC_MSG_CHECKING([--disable-icon-cache-update argument])
2740 AC_ARG_ENABLE(icon_cache_update,
2741 [ --disable-icon-cache-update update disabled],
2742 [],
2743 [enable_icon_cache_update="yes"])
2744 if test "$enable_icon_cache_update" = "yes"; then
2745 AC_MSG_RESULT([not set])
2746 AC_PATH_PROG(GTK_UPDATE_ICON_CACHE,[gtk-update-icon-cache],no)
2747 if test "x$GTK_UPDATE_ICON_CACHE" = "xno" ; then
2748 AC_MSG_RESULT([not found in PATH.])
2749 fi
2750 else
2751 AC_MSG_RESULT([update disabled])
2752 fi
2753
2754 AC_MSG_CHECKING([--disable-desktop-database-update argument])
2755 AC_ARG_ENABLE(desktop_database_update,
2756 [ --disable-desktop-database-update update disabled],
2757 [],
2758 [enable_desktop_database_update="yes"])
2759 if test "$enable_desktop_database_update" = "yes"; then
2760 AC_MSG_RESULT([not set])
2761 AC_PATH_PROG(UPDATE_DESKTOP_DATABASE,[update-desktop-database],no)
2762 if test "x$UPDATE_DESKTOP_DATABASE" = "xno" ; then
2763 AC_MSG_RESULT([not found in PATH.])
2764 fi
2765 else
2766 AC_MSG_RESULT([update disabled])
2767 fi
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002768fi
2769AC_SUBST(GLIB_COMPILE_RESOURCES)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002770AC_SUBST(GRESOURCE_SRC)
2771AC_SUBST(GRESOURCE_OBJ)
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002772AC_SUBST(GTK_UPDATE_ICON_CACHE)
2773AC_SUBST(UPDATE_DESKTOP_DATABASE)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002774
Bram Moolenaar071d4272004-06-13 20:20:40 +00002775dnl Check for Motif include files location.
2776dnl The LAST one found is used, this makes the highest version to be used,
2777dnl e.g. when Motif1.2 and Motif2.0 are both present.
2778
2779if test -z "$SKIP_MOTIF"; then
2780 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"
2781 dnl Remove "-I" from before $GUI_INC_LOC if it's there
2782 GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`"
2783
2784 AC_MSG_CHECKING(for location of Motif GUI includes)
2785 gui_includes="`echo $x_includes|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC"
2786 GUI_INC_LOC=
2787 for try in $gui_includes; do
2788 if test -f "$try/Xm/Xm.h"; then
2789 GUI_INC_LOC=$try
2790 fi
2791 done
2792 if test -n "$GUI_INC_LOC"; then
2793 if test "$GUI_INC_LOC" = /usr/include; then
2794 GUI_INC_LOC=
2795 AC_MSG_RESULT(in default path)
2796 else
2797 AC_MSG_RESULT($GUI_INC_LOC)
2798 fi
2799 else
2800 AC_MSG_RESULT(<not found>)
2801 SKIP_MOTIF=YES
2802 fi
2803fi
2804
2805dnl Check for Motif library files location. In the same order as the include
2806dnl files, to avoid a mixup if several versions are present
2807
2808if test -z "$SKIP_MOTIF"; then
2809 AC_MSG_CHECKING(--with-motif-lib argument)
2810 AC_ARG_WITH(motif-lib,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002811 [ --with-motif-lib=STRING Library for Motif ],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002812 [ MOTIF_LIBNAME="${withval}" ] )
2813
2814 if test -n "$MOTIF_LIBNAME"; then
2815 AC_MSG_RESULT($MOTIF_LIBNAME)
2816 GUI_LIB_LOC=
2817 else
2818 AC_MSG_RESULT(no)
2819
2820 dnl Remove "-L" from before $GUI_LIB_LOC if it's there
2821 GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
2822
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002823 dnl Ubuntu has libXm.so in /usr/lib/i386-linux-gnu and elsewhere. The
2824 dnl linker will figure out which one to use, we only check if one exists.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002825 AC_MSG_CHECKING(for location of Motif GUI libs)
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002826 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 +00002827 GUI_LIB_LOC=
2828 for try in $gui_libs; do
Bram Moolenaar325b7a22004-07-05 15:58:32 +00002829 for libtry in "$try"/libXm.a "$try"/libXm.so* "$try"/libXm.sl "$try"/libXm.dylib; do
Bram Moolenaar071d4272004-06-13 20:20:40 +00002830 if test -f "$libtry"; then
2831 GUI_LIB_LOC=$try
2832 fi
2833 done
2834 done
2835 if test -n "$GUI_LIB_LOC"; then
2836 dnl Remove /usr/lib, it causes trouble on some systems
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002837 if test "$GUI_LIB_LOC" = /usr/lib \
2838 -o "$GUI_LIB_LOC" = /usr/lib/i386-linux-gnu \
2839 -o "$GUI_LIB_LOC" = /usr/lib/x86_64-linux-gnu; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002840 GUI_LIB_LOC=
2841 AC_MSG_RESULT(in default path)
2842 else
2843 if test -n "$GUI_LIB_LOC"; then
2844 AC_MSG_RESULT($GUI_LIB_LOC)
2845 if test "`(uname) 2>/dev/null`" = SunOS &&
2846 uname -r | grep '^5' >/dev/null; then
2847 GUI_LIB_LOC="$GUI_LIB_LOC -R $GUI_LIB_LOC"
2848 fi
2849 fi
2850 fi
2851 MOTIF_LIBNAME=-lXm
2852 else
2853 AC_MSG_RESULT(<not found>)
2854 SKIP_MOTIF=YES
2855 fi
2856 fi
2857fi
2858
2859if test -z "$SKIP_MOTIF"; then
2860 SKIP_ATHENA=YES
2861 SKIP_NEXTAW=YES
2862 GUITYPE=MOTIF
2863 AC_SUBST(MOTIF_LIBNAME)
2864fi
2865
2866dnl Check if the Athena files can be found
2867
2868GUI_X_LIBS=
2869
2870if test -z "$SKIP_ATHENA"; then
2871 AC_MSG_CHECKING(if Athena header files can be found)
2872 cflags_save=$CFLAGS
2873 CFLAGS="$CFLAGS $X_CFLAGS"
2874 AC_TRY_COMPILE([
2875#include <X11/Intrinsic.h>
2876#include <X11/Xaw/Paned.h>], ,
2877 AC_MSG_RESULT(yes),
2878 AC_MSG_RESULT(no); SKIP_ATHENA=YES )
2879 CFLAGS=$cflags_save
2880fi
2881
2882if test -z "$SKIP_ATHENA"; then
2883 GUITYPE=ATHENA
2884fi
2885
2886if test -z "$SKIP_NEXTAW"; then
2887 AC_MSG_CHECKING(if neXtaw header files can be found)
2888 cflags_save=$CFLAGS
2889 CFLAGS="$CFLAGS $X_CFLAGS"
2890 AC_TRY_COMPILE([
2891#include <X11/Intrinsic.h>
2892#include <X11/neXtaw/Paned.h>], ,
2893 AC_MSG_RESULT(yes),
2894 AC_MSG_RESULT(no); SKIP_NEXTAW=YES )
2895 CFLAGS=$cflags_save
2896fi
2897
2898if test -z "$SKIP_NEXTAW"; then
2899 GUITYPE=NEXTAW
2900fi
2901
2902if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
2903 dnl Prepend -I and -L to $GUI_INC_LOC and $GUI_LIB_LOC if not empty
2904 dnl Avoid adding it when it twice
2905 if test -n "$GUI_INC_LOC"; then
2906 GUI_INC_LOC=-I"`echo $GUI_INC_LOC|sed 's%-I%%'`"
2907 fi
2908 if test -n "$GUI_LIB_LOC"; then
2909 GUI_LIB_LOC=-L"`echo $GUI_LIB_LOC|sed 's%-L%%'`"
2910 fi
2911
2912 dnl Check for -lXext and then for -lXmu
2913 ldflags_save=$LDFLAGS
2914 LDFLAGS="$X_LIBS $LDFLAGS"
2915 AC_CHECK_LIB(Xext, XShapeQueryExtension, [GUI_X_LIBS="-lXext"],,
2916 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2917 dnl For Solaris we need -lw and -ldl before linking with -lXmu works.
2918 AC_CHECK_LIB(w, wslen, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lw"],,
2919 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2920 AC_CHECK_LIB(dl, dlsym, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldl"],,
2921 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2922 AC_CHECK_LIB(Xmu, XmuCreateStippledPixmap, [GUI_X_LIBS="-lXmu $GUI_X_LIBS"],,
2923 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2924 if test -z "$SKIP_MOTIF"; then
2925 AC_CHECK_LIB(Xp, XpEndJob, [GUI_X_LIBS="-lXp $GUI_X_LIBS"],,
2926 [$GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2927 fi
2928 LDFLAGS=$ldflags_save
2929
2930 dnl Execute xmkmf to figure out if -DNARROWPROTO is needed.
2931 AC_MSG_CHECKING(for extra X11 defines)
2932 NARROW_PROTO=
2933 rm -fr conftestdir
2934 if mkdir conftestdir; then
2935 cd conftestdir
2936 cat > Imakefile <<'EOF'
2937acfindx:
2938 @echo 'NARROW_PROTO="${PROTO_DEFINES}"'
2939EOF
2940 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
2941 eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
2942 fi
2943 cd ..
2944 rm -fr conftestdir
2945 fi
2946 if test -z "$NARROW_PROTO"; then
2947 AC_MSG_RESULT(no)
2948 else
2949 AC_MSG_RESULT($NARROW_PROTO)
2950 fi
2951 AC_SUBST(NARROW_PROTO)
2952fi
2953
2954dnl Look for XSMP support - but don't necessarily restrict it to X11 GUIs
2955dnl use the X11 include path
2956if test "$enable_xsmp" = "yes"; then
2957 cppflags_save=$CPPFLAGS
2958 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2959 AC_CHECK_HEADERS(X11/SM/SMlib.h)
2960 CPPFLAGS=$cppflags_save
2961fi
2962
2963
Bram Moolenaar98921892016-02-23 17:14:37 +01002964if 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 +00002965 dnl Check for X11/xpm.h and X11/Sunkeysym.h with the GUI include path
2966 cppflags_save=$CPPFLAGS
2967 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2968 AC_CHECK_HEADERS(X11/xpm.h X11/Sunkeysym.h)
2969
2970 dnl automatically disable XIM when XIMtext isn't in X11/Xlib.h
2971 if test ! "$enable_xim" = "no"; then
2972 AC_MSG_CHECKING(for XIMText in X11/Xlib.h)
2973 AC_EGREP_CPP(XIMText, [#include <X11/Xlib.h>],
2974 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +02002975 AC_MSG_RESULT(no; xim has been disabled); enable_xim="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00002976 fi
2977 CPPFLAGS=$cppflags_save
2978
2979 dnl automatically enable XIM when hangul input isn't enabled
2980 if test "$enable_xim" = "auto" -a "$enable_hangulinput" != "yes" \
2981 -a "x$GUITYPE" != "xNONE" ; then
2982 AC_MSG_RESULT(X GUI selected; xim has been enabled)
2983 enable_xim="yes"
2984 fi
2985fi
2986
2987if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
2988 cppflags_save=$CPPFLAGS
2989 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00002990dnl Xmu/Editres.h may exist but can only be used after including Intrinsic.h
2991 AC_MSG_CHECKING([for X11/Xmu/Editres.h])
2992 AC_TRY_COMPILE([
2993#include <X11/Intrinsic.h>
2994#include <X11/Xmu/Editres.h>],
2995 [int i; i = 0;],
2996 AC_MSG_RESULT(yes)
2997 AC_DEFINE(HAVE_X11_XMU_EDITRES_H),
2998 AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00002999 CPPFLAGS=$cppflags_save
3000fi
3001
3002dnl Only use the Xm directory when compiling Motif, don't use it for Athena
3003if test -z "$SKIP_MOTIF"; then
3004 cppflags_save=$CPPFLAGS
3005 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003006 if test "$zOSUnix" = "yes"; then
3007 xmheader="Xm/Xm.h"
3008 else
3009 xmheader="Xm/Xm.h Xm/XpmP.h Xm/JoinSideT.h Xm/TraitP.h Xm/Manager.h
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02003010 Xm/UnhighlightT.h Xm/Notebook.h"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003011 fi
3012 AC_CHECK_HEADERS($xmheader)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003013
Bram Moolenaar77c19352012-06-13 19:19:41 +02003014 if test "x$ac_cv_header_Xm_XpmP_h" = "xyes"; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003015 dnl Solaris uses XpmAttributes_21, very annoying.
3016 AC_MSG_CHECKING([for XpmAttributes_21 in Xm/XpmP.h])
3017 AC_TRY_COMPILE([#include <Xm/XpmP.h>], [XpmAttributes_21 attr;],
3018 AC_MSG_RESULT(yes); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes_21),
3019 AC_MSG_RESULT(no); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
3020 )
3021 else
Bram Moolenaar57657d82006-04-21 22:12:41 +00003022 AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003023 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003024 CPPFLAGS=$cppflags_save
3025fi
3026
3027if test "x$GUITYPE" = "xNONE" -a "$enable_xim" = "yes"; then
3028 AC_MSG_RESULT(no GUI selected; xim has been disabled)
3029 enable_xim="no"
3030fi
3031if test "x$GUITYPE" = "xNONE" -a "$enable_fontset" = "yes"; then
3032 AC_MSG_RESULT(no GUI selected; fontset has been disabled)
3033 enable_fontset="no"
3034fi
Bram Moolenaar182c5be2010-06-25 05:37:59 +02003035if test "x$GUITYPE:$enable_fontset" = "xGTK:yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003036 AC_MSG_RESULT(GTK+ 2 GUI selected; fontset has been disabled)
3037 enable_fontset="no"
3038fi
3039
Bram Moolenaar071d4272004-06-13 20:20:40 +00003040if test -z "$SKIP_PHOTON"; then
3041 GUITYPE=PHOTONGUI
3042fi
3043
3044AC_SUBST(GUI_INC_LOC)
3045AC_SUBST(GUI_LIB_LOC)
3046AC_SUBST(GUITYPE)
3047AC_SUBST(GUI_X_LIBS)
3048
3049if test "$enable_workshop" = "yes" -a -n "$SKIP_MOTIF"; then
3050 AC_MSG_ERROR([cannot use workshop without Motif])
3051fi
3052
3053dnl defining FEAT_XIM and FEAT_XFONTSET is delayed, so that they can be disabled
3054if test "$enable_xim" = "yes"; then
3055 AC_DEFINE(FEAT_XIM)
3056fi
3057if test "$enable_fontset" = "yes"; then
3058 AC_DEFINE(FEAT_XFONTSET)
3059fi
3060
3061
3062dnl ---------------------------------------------------------------------------
3063dnl end of GUI-checking
3064dnl ---------------------------------------------------------------------------
3065
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003066AC_MSG_CHECKING([for /proc link to executable])
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003067if test -L "/proc/self/exe"; then
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003068 dnl Linux
3069 AC_MSG_RESULT([/proc/self/exe])
3070 AC_DEFINE(PROC_EXE_LINK, "/proc/self/exe")
3071elif test -L "/proc/self/path/a.out"; then
3072 dnl Solaris
3073 AC_MSG_RESULT([/proc/self/path/a.out])
3074 AC_DEFINE(PROC_EXE_LINK, "/proc/self/path/a.out")
3075elif test -L "/proc/curproc/file"; then
3076 dnl FreeBSD
3077 AC_MSG_RESULT([/proc/curproc/file])
3078 AC_DEFINE(PROC_EXE_LINK, "/proc/curproc/file")
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003079else
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003080 AC_MSG_RESULT(no)
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003081fi
3082
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003083dnl Check for Cygwin, which needs an extra source file if not using X11
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003084AC_MSG_CHECKING(for CYGWIN or MSYS environment)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003085case `uname` in
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003086 CYGWIN*|MSYS*) CYGWIN=yes; AC_MSG_RESULT(yes)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003087 AC_MSG_CHECKING(for CYGWIN clipboard support)
3088 if test "x$with_x" = "xno" ; then
3089 OS_EXTRA_SRC=winclip.c; OS_EXTRA_OBJ=objects/winclip.o
3090 AC_MSG_RESULT(yes)
3091 AC_DEFINE(FEAT_CYGWIN_WIN32_CLIPBOARD)
3092 else
3093 AC_MSG_RESULT(no - using X11)
3094 fi ;;
3095
3096 *) CYGWIN=no; AC_MSG_RESULT(no);;
3097esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00003098
3099dnl Only really enable hangul input when GUI and XFONTSET are available
3100if test "$enable_hangulinput" = "yes"; then
3101 if test "x$GUITYPE" = "xNONE"; then
3102 AC_MSG_RESULT(no GUI selected; hangul input has been disabled)
3103 enable_hangulinput=no
3104 else
3105 AC_DEFINE(FEAT_HANGULIN)
3106 HANGULIN_SRC=hangulin.c
3107 AC_SUBST(HANGULIN_SRC)
3108 HANGULIN_OBJ=objects/hangulin.o
3109 AC_SUBST(HANGULIN_OBJ)
3110 fi
3111fi
3112
3113dnl Checks for libraries and include files.
3114
Bram Moolenaar446cb832008-06-24 21:56:24 +00003115AC_CACHE_CHECK([whether toupper is broken], [vim_cv_toupper_broken],
3116 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003117 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003118#include "confdefs.h"
3119#include <ctype.h>
3120#if STDC_HEADERS
3121# include <stdlib.h>
3122# include <stddef.h>
3123#endif
3124main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003125 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003126 vim_cv_toupper_broken=yes
3127 ],[
3128 vim_cv_toupper_broken=no
3129 ],[
3130 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_toupper_broken')
3131 ])])
3132
3133if test "x$vim_cv_toupper_broken" = "xyes" ; then
3134 AC_DEFINE(BROKEN_TOUPPER)
3135fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003136
3137AC_MSG_CHECKING(whether __DATE__ and __TIME__ work)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003138AC_TRY_COMPILE([#include <stdio.h>], [printf("(" __DATE__ " " __TIME__ ")");],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003139 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DATE_TIME),
3140 AC_MSG_RESULT(no))
3141
Bram Moolenaar0c094b92009-05-14 20:20:33 +00003142AC_MSG_CHECKING(whether __attribute__((unused)) is allowed)
3143AC_TRY_COMPILE([#include <stdio.h>], [int x __attribute__((unused));],
3144 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ATTRIBUTE_UNUSED),
3145 AC_MSG_RESULT(no))
3146
Bram Moolenaar071d4272004-06-13 20:20:40 +00003147dnl Checks for header files.
3148AC_CHECK_HEADER(elf.h, HAS_ELF=1)
3149dnl AC_CHECK_HEADER(dwarf.h, SVR4=1)
3150if test "$HAS_ELF" = 1; then
3151 AC_CHECK_LIB(elf, main)
3152fi
3153
3154AC_HEADER_DIRENT
3155
Bram Moolenaar071d4272004-06-13 20:20:40 +00003156dnl If sys/wait.h is not found it might still exist but not be POSIX
3157dnl compliant. In that case we define HAVE_UNION_WAIT (for NeXT)
3158if test $ac_cv_header_sys_wait_h = no; then
3159 AC_MSG_CHECKING([for sys/wait.h that defines union wait])
3160 AC_TRY_COMPILE([#include <sys/wait.h>],
3161 [union wait xx, yy; xx = yy],
3162 AC_MSG_RESULT(yes)
3163 AC_DEFINE(HAVE_SYS_WAIT_H)
3164 AC_DEFINE(HAVE_UNION_WAIT),
3165 AC_MSG_RESULT(no))
3166fi
3167
Bram Moolenaar779a7752016-01-30 23:26:34 +01003168AC_CHECK_HEADERS(stdint.h stdlib.h string.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003169 sys/select.h sys/utsname.h termcap.h fcntl.h \
3170 sgtty.h sys/ioctl.h sys/time.h sys/types.h \
3171 termio.h iconv.h inttypes.h langinfo.h math.h \
3172 unistd.h stropts.h errno.h sys/resource.h \
3173 sys/systeminfo.h locale.h sys/stream.h termios.h \
3174 libc.h sys/statfs.h poll.h sys/poll.h pwd.h \
3175 utime.h sys/param.h libintl.h libgen.h \
3176 util/debug.h util/msg18n.h frame.h sys/acl.h \
3177 sys/access.h sys/sysinfo.h wchar.h wctype.h)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003178
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003179dnl sys/ptem.h depends on sys/stream.h on Solaris
3180AC_CHECK_HEADERS(sys/ptem.h, [], [],
3181[#if defined HAVE_SYS_STREAM_H
3182# include <sys/stream.h>
3183#endif])
3184
Bram Moolenaar32f31b12009-05-21 13:20:59 +00003185dnl sys/sysctl.h depends on sys/param.h on OpenBSD
3186AC_CHECK_HEADERS(sys/sysctl.h, [], [],
3187[#if defined HAVE_SYS_PARAM_H
3188# include <sys/param.h>
3189#endif])
3190
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003191
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003192dnl pthread_np.h may exist but can only be used after including pthread.h
3193AC_MSG_CHECKING([for pthread_np.h])
3194AC_TRY_COMPILE([
3195#include <pthread.h>
3196#include <pthread_np.h>],
3197 [int i; i = 0;],
3198 AC_MSG_RESULT(yes)
3199 AC_DEFINE(HAVE_PTHREAD_NP_H),
3200 AC_MSG_RESULT(no))
3201
Bram Moolenaare344bea2005-09-01 20:46:49 +00003202AC_CHECK_HEADERS(strings.h)
Bram Moolenaard0573012017-10-28 21:11:06 +02003203if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00003204 dnl The strings.h file on OS/X contains a warning and nothing useful.
3205 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3206else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003207
3208dnl Check if strings.h and string.h can both be included when defined.
3209AC_MSG_CHECKING([if strings.h can be included after string.h])
3210cppflags_save=$CPPFLAGS
3211CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3212AC_TRY_COMPILE([
3213#if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO)
3214# define _NO_PROTO /* like in os_unix.h, causes conflict for AIX (Winn) */
3215 /* but don't do it on AIX 5.1 (Uribarri) */
3216#endif
3217#ifdef HAVE_XM_XM_H
3218# include <Xm/Xm.h> /* This breaks it for HP-UX 11 (Squassabia) */
3219#endif
3220#ifdef HAVE_STRING_H
3221# include <string.h>
3222#endif
3223#if defined(HAVE_STRINGS_H)
3224# include <strings.h>
3225#endif
3226 ], [int i; i = 0;],
3227 AC_MSG_RESULT(yes),
3228 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3229 AC_MSG_RESULT(no))
3230CPPFLAGS=$cppflags_save
Bram Moolenaar9372a112005-12-06 19:59:18 +00003231fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003232
3233dnl Checks for typedefs, structures, and compiler characteristics.
3234AC_PROG_GCC_TRADITIONAL
3235AC_C_CONST
Bram Moolenaar76243bd2009-03-02 01:47:02 +00003236AC_C_VOLATILE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003237AC_TYPE_MODE_T
3238AC_TYPE_OFF_T
3239AC_TYPE_PID_T
3240AC_TYPE_SIZE_T
3241AC_TYPE_UID_T
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003242AC_TYPE_UINT32_T
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003243
Bram Moolenaar071d4272004-06-13 20:20:40 +00003244AC_HEADER_TIME
3245AC_CHECK_TYPE(ino_t, long)
3246AC_CHECK_TYPE(dev_t, unsigned)
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003247AC_C_BIGENDIAN(,,,)
Bram Moolenaar136f29a2016-02-27 20:14:15 +01003248AC_C_INLINE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003249
3250AC_MSG_CHECKING(for rlim_t)
3251if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
3252 AC_MSG_RESULT([(cached) $ac_cv_type_rlim_t])
3253else
3254 AC_EGREP_CPP(dnl
3255changequote(<<,>>)dnl
3256<<(^|[^a-zA-Z_0-9])rlim_t[^a-zA-Z_0-9]>>dnl
3257changequote([,]),
3258 [
3259#include <sys/types.h>
3260#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003261# include <stdlib.h>
3262# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003263#endif
3264#ifdef HAVE_SYS_RESOURCE_H
Bram Moolenaar446cb832008-06-24 21:56:24 +00003265# include <sys/resource.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003266#endif
3267 ], ac_cv_type_rlim_t=yes, ac_cv_type_rlim_t=no)
3268 AC_MSG_RESULT($ac_cv_type_rlim_t)
3269fi
3270if test $ac_cv_type_rlim_t = no; then
3271 cat >> confdefs.h <<\EOF
3272#define rlim_t unsigned long
3273EOF
3274fi
3275
3276AC_MSG_CHECKING(for stack_t)
3277if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then
3278 AC_MSG_RESULT([(cached) $ac_cv_type_stack_t])
3279else
3280 AC_EGREP_CPP(stack_t,
3281 [
3282#include <sys/types.h>
3283#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003284# include <stdlib.h>
3285# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003286#endif
3287#include <signal.h>
3288 ], ac_cv_type_stack_t=yes, ac_cv_type_stack_t=no)
3289 AC_MSG_RESULT($ac_cv_type_stack_t)
3290fi
3291if test $ac_cv_type_stack_t = no; then
3292 cat >> confdefs.h <<\EOF
3293#define stack_t struct sigaltstack
3294EOF
3295fi
3296
3297dnl BSDI uses ss_base while others use ss_sp for the stack pointer.
3298AC_MSG_CHECKING(whether stack_t has an ss_base field)
3299AC_TRY_COMPILE([
3300#include <sys/types.h>
3301#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003302# include <stdlib.h>
3303# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003304#endif
3305#include <signal.h>
3306#include "confdefs.h"
3307 ], [stack_t sigstk; sigstk.ss_base = 0; ],
3308 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SS_BASE),
3309 AC_MSG_RESULT(no))
3310
3311olibs="$LIBS"
3312AC_MSG_CHECKING(--with-tlib argument)
3313AC_ARG_WITH(tlib, [ --with-tlib=library terminal library to be used ],)
3314if test -n "$with_tlib"; then
3315 AC_MSG_RESULT($with_tlib)
3316 LIBS="$LIBS -l$with_tlib"
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003317 AC_MSG_CHECKING(for linking with $with_tlib library)
3318 AC_TRY_LINK([], [], AC_MSG_RESULT(OK), AC_MSG_ERROR(FAILED))
3319 dnl Need to check for tgetent() below.
3320 olibs="$LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003321else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003322 AC_MSG_RESULT([empty: automatic terminal library selection])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003323 dnl On HP-UX 10.10 termcap or termlib should be used instead of
3324 dnl curses, because curses is much slower.
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003325 dnl Newer versions of ncurses are preferred over anything, except
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02003326 dnl when tinfo has been split off, it contains all we need.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003327 dnl Older versions of ncurses have bugs, get a new one!
3328 dnl Digital Unix (OSF1) should use curses (Ronald Schild).
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00003329 dnl On SCO Openserver should prefer termlib (Roger Cornelius).
Bram Moolenaar071d4272004-06-13 20:20:40 +00003330 case "`uname -s 2>/dev/null`" in
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003331 OSF1|SCO_SV) tlibs="tinfo ncurses curses termlib termcap";;
3332 *) tlibs="tinfo ncurses termlib termcap curses";;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003333 esac
3334 for libname in $tlibs; do
3335 AC_CHECK_LIB(${libname}, tgetent,,)
3336 if test "x$olibs" != "x$LIBS"; then
3337 dnl It's possible that a library is found but it doesn't work
3338 dnl e.g., shared library that cannot be found
3339 dnl compile and run a test program to be sure
3340 AC_TRY_RUN([
3341#ifdef HAVE_TERMCAP_H
3342# include <termcap.h>
3343#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003344#if STDC_HEADERS
3345# include <stdlib.h>
3346# include <stddef.h>
3347#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003348main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }],
3349 res="OK", res="FAIL", res="FAIL")
3350 if test "$res" = "OK"; then
3351 break
3352 fi
3353 AC_MSG_RESULT($libname library is not usable)
3354 LIBS="$olibs"
3355 fi
3356 done
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003357 if test "x$olibs" = "x$LIBS"; then
3358 AC_MSG_RESULT(no terminal library found)
3359 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003360fi
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003361
3362if test "x$olibs" = "x$LIBS"; then
3363 AC_MSG_CHECKING([for tgetent()])
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00003364 AC_TRY_LINK([],
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003365 [char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");],
3366 AC_MSG_RESULT(yes),
3367 AC_MSG_ERROR([NOT FOUND!
3368 You need to install a terminal library; for example ncurses.
3369 Or specify the name of the library with --with-tlib.]))
3370fi
3371
Bram Moolenaar446cb832008-06-24 21:56:24 +00003372AC_CACHE_CHECK([whether we talk terminfo], [vim_cv_terminfo],
3373 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003374 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003375#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003376#ifdef HAVE_TERMCAP_H
3377# include <termcap.h>
3378#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003379#ifdef HAVE_STRING_H
3380# include <string.h>
3381#endif
3382#if STDC_HEADERS
3383# include <stdlib.h>
3384# include <stddef.h>
3385#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003386main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003387{char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003388 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003389 vim_cv_terminfo=no
3390 ],[
3391 vim_cv_terminfo=yes
3392 ],[
3393 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_terminfo')
3394 ])
3395 ])
3396
3397if test "x$vim_cv_terminfo" = "xyes" ; then
3398 AC_DEFINE(TERMINFO)
3399fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003400
Bram Moolenaara88254f2017-11-02 23:04:14 +01003401AC_CACHE_CHECK([what tgetent() returns for an unknown terminal], [vim_cv_tgetent],
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003402 [
3403 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003404#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003405#ifdef HAVE_TERMCAP_H
3406# include <termcap.h>
3407#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003408#if STDC_HEADERS
3409# include <stdlib.h>
3410# include <stddef.h>
3411#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003412main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003413{char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003414 ]])],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003415 vim_cv_tgetent=zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003416 ],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003417 vim_cv_tgetent=non-zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003418 ],[
3419 AC_MSG_ERROR(failed to compile test program.)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003420 ])
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003421 ])
3422
Bram Moolenaara88254f2017-11-02 23:04:14 +01003423if test "x$vim_cv_tgetent" = "xzero" ; then
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003424 AC_DEFINE(TGETENT_ZERO_ERR, 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003425fi
3426
3427AC_MSG_CHECKING(whether termcap.h contains ospeed)
3428AC_TRY_LINK([
3429#ifdef HAVE_TERMCAP_H
3430# include <termcap.h>
3431#endif
3432 ], [ospeed = 20000],
3433 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED),
3434 [AC_MSG_RESULT(no)
3435 AC_MSG_CHECKING(whether ospeed can be extern)
3436 AC_TRY_LINK([
3437#ifdef HAVE_TERMCAP_H
3438# include <termcap.h>
3439#endif
3440extern short ospeed;
3441 ], [ospeed = 20000],
3442 AC_MSG_RESULT(yes); AC_DEFINE(OSPEED_EXTERN),
3443 AC_MSG_RESULT(no))]
3444 )
3445
3446AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC])
3447AC_TRY_LINK([
3448#ifdef HAVE_TERMCAP_H
3449# include <termcap.h>
3450#endif
3451 ], [if (UP == 0 && BC == 0) PC = 1],
3452 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UP_BC_PC),
3453 [AC_MSG_RESULT(no)
3454 AC_MSG_CHECKING([whether UP, BC and PC can be extern])
3455 AC_TRY_LINK([
3456#ifdef HAVE_TERMCAP_H
3457# include <termcap.h>
3458#endif
3459extern char *UP, *BC, PC;
3460 ], [if (UP == 0 && BC == 0) PC = 1],
3461 AC_MSG_RESULT(yes); AC_DEFINE(UP_BC_PC_EXTERN),
3462 AC_MSG_RESULT(no))]
3463 )
3464
3465AC_MSG_CHECKING(whether tputs() uses outfuntype)
3466AC_TRY_COMPILE([
3467#ifdef HAVE_TERMCAP_H
3468# include <termcap.h>
3469#endif
3470 ], [extern int xx(); tputs("test", 1, (outfuntype)xx)],
3471 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OUTFUNTYPE),
3472 AC_MSG_RESULT(no))
3473
3474dnl On some SCO machines sys/select redefines struct timeval
3475AC_MSG_CHECKING([whether sys/select.h and sys/time.h may both be included])
3476AC_TRY_COMPILE([
3477#include <sys/types.h>
3478#include <sys/time.h>
3479#include <sys/select.h>], ,
3480 AC_MSG_RESULT(yes)
3481 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME),
3482 AC_MSG_RESULT(no))
3483
3484dnl AC_DECL_SYS_SIGLIST
3485
3486dnl Checks for pty.c (copied from screen) ==========================
3487AC_MSG_CHECKING(for /dev/ptc)
3488if test -r /dev/ptc; then
3489 AC_DEFINE(HAVE_DEV_PTC)
3490 AC_MSG_RESULT(yes)
3491else
3492 AC_MSG_RESULT(no)
3493fi
3494
3495AC_MSG_CHECKING(for SVR4 ptys)
3496if test -c /dev/ptmx ; then
3497 AC_TRY_LINK([], [ptsname(0);grantpt(0);unlockpt(0);],
3498 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SVR4_PTYS),
3499 AC_MSG_RESULT(no))
3500else
3501 AC_MSG_RESULT(no)
3502fi
3503
3504AC_MSG_CHECKING(for ptyranges)
3505if test -d /dev/ptym ; then
3506 pdir='/dev/ptym'
3507else
3508 pdir='/dev'
3509fi
3510dnl SCO uses ptyp%d
3511AC_EGREP_CPP(yes,
3512[#ifdef M_UNIX
3513 yes;
3514#endif
3515 ], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
3516dnl if test -c /dev/ptyp19; then
3517dnl ptys=`echo /dev/ptyp??`
3518dnl else
3519dnl ptys=`echo $pdir/pty??`
3520dnl fi
3521if test "$ptys" != "$pdir/pty??" ; then
3522 p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
3523 p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'`
3524 AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
3525 AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
3526 AC_MSG_RESULT([$p0 / $p1])
3527else
3528 AC_MSG_RESULT([don't know])
3529fi
3530
3531dnl **** pty mode/group handling ****
3532dnl
3533dnl support provided by Luke Mewburn <lm@rmit.edu.au>, 931222
Bram Moolenaar071d4272004-06-13 20:20:40 +00003534rm -f conftest_grp
Bram Moolenaar446cb832008-06-24 21:56:24 +00003535AC_CACHE_CHECK([default tty permissions/group], [vim_cv_tty_group],
3536 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003537 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003538#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003539#include <sys/types.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003540#if STDC_HEADERS
3541# include <stdlib.h>
3542# include <stddef.h>
3543#endif
3544#ifdef HAVE_UNISTD_H
3545#include <unistd.h>
3546#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003547#include <sys/stat.h>
3548#include <stdio.h>
3549main()
3550{
3551 struct stat sb;
3552 char *x,*ttyname();
3553 int om, m;
3554 FILE *fp;
3555
3556 if (!(x = ttyname(0))) exit(1);
3557 if (stat(x, &sb)) exit(1);
3558 om = sb.st_mode;
3559 if (om & 002) exit(0);
3560 m = system("mesg y");
3561 if (m == -1 || m == 127) exit(1);
3562 if (stat(x, &sb)) exit(1);
3563 m = sb.st_mode;
3564 if (chmod(x, om)) exit(1);
3565 if (m & 002) exit(0);
3566 if (sb.st_gid == getgid()) exit(1);
3567 if (!(fp=fopen("conftest_grp", "w")))
3568 exit(1);
3569 fprintf(fp, "%d\n", sb.st_gid);
3570 fclose(fp);
3571 exit(0);
3572}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003573 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003574 if test -f conftest_grp; then
3575 vim_cv_tty_group=`cat conftest_grp`
3576 if test "x$vim_cv_tty_mode" = "x" ; then
3577 vim_cv_tty_mode=0620
3578 fi
3579 AC_MSG_RESULT([pty mode: $vim_cv_tty_mode, group: $vim_cv_tty_group])
3580 else
3581 vim_cv_tty_group=world
Bram Moolenaar72951072009-12-02 16:58:33 +00003582 AC_MSG_RESULT([ptys are world accessible])
Bram Moolenaar446cb832008-06-24 21:56:24 +00003583 fi
3584 ],[
3585 vim_cv_tty_group=world
Bram Moolenaar72951072009-12-02 16:58:33 +00003586 AC_MSG_RESULT([can't determine - assume ptys are world accessible])
Bram Moolenaar446cb832008-06-24 21:56:24 +00003587 ],[
3588 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_tty_group' and 'vim_cv_tty_mode')
3589 ])
3590 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003591rm -f conftest_grp
3592
Bram Moolenaar446cb832008-06-24 21:56:24 +00003593if test "x$vim_cv_tty_group" != "xworld" ; then
3594 AC_DEFINE_UNQUOTED(PTYGROUP,$vim_cv_tty_group)
3595 if test "x$vim_cv_tty_mode" = "x" ; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02003596 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 +00003597 else
3598 AC_DEFINE(PTYMODE, 0620)
3599 fi
3600fi
3601
Bram Moolenaar071d4272004-06-13 20:20:40 +00003602dnl Checks for library functions. ===================================
3603
3604AC_TYPE_SIGNAL
3605
3606dnl find out what to use at the end of a signal function
3607if test $ac_cv_type_signal = void; then
3608 AC_DEFINE(SIGRETURN, [return])
3609else
3610 AC_DEFINE(SIGRETURN, [return 0])
3611fi
3612
3613dnl check if struct sigcontext is defined (used for SGI only)
3614AC_MSG_CHECKING(for struct sigcontext)
3615AC_TRY_COMPILE([
3616#include <signal.h>
3617test_sig()
3618{
3619 struct sigcontext *scont;
3620 scont = (struct sigcontext *)0;
3621 return 1;
3622} ], ,
3623 AC_MSG_RESULT(yes)
3624 AC_DEFINE(HAVE_SIGCONTEXT),
3625 AC_MSG_RESULT(no))
3626
3627dnl tricky stuff: try to find out if getcwd() is implemented with
3628dnl system("sh -c pwd")
Bram Moolenaar446cb832008-06-24 21:56:24 +00003629AC_CACHE_CHECK([getcwd implementation is broken], [vim_cv_getcwd_broken],
3630 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003631 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003632#include "confdefs.h"
3633#ifdef HAVE_UNISTD_H
3634#include <unistd.h>
3635#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003636char *dagger[] = { "IFS=pwd", 0 };
3637main()
3638{
3639 char buffer[500];
3640 extern char **environ;
3641 environ = dagger;
3642 return getcwd(buffer, 500) ? 0 : 1;
Bram Moolenaar446cb832008-06-24 21:56:24 +00003643}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003644 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003645 vim_cv_getcwd_broken=no
3646 ],[
3647 vim_cv_getcwd_broken=yes
3648 ],[
3649 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_getcwd_broken')
3650 ])
3651 ])
3652
3653if test "x$vim_cv_getcwd_broken" = "xyes" ; then
3654 AC_DEFINE(BAD_GETCWD)
3655fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003656
Bram Moolenaar25153e12010-02-24 14:47:08 +01003657dnl Check for functions in one big call, to reduce the size of configure.
3658dnl Can only be used for functions that do not require any include.
Bram Moolenaarcd142e32017-11-16 17:03:45 +01003659AC_CHECK_FUNCS(fchdir fchown fchmod fsync getcwd getpseudotty \
Bram Moolenaarb129a442016-12-01 17:25:20 +01003660 getpwent getpwnam getpwuid getrlimit gettimeofday getwd lstat \
Bram Moolenaareaf03392009-11-17 11:08:52 +00003661 memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
Bram Moolenaar2fcf6682017-03-11 20:03:42 +01003662 getpgid setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
Bram Moolenaarbb09ceb2016-10-18 16:27:23 +02003663 sigprocmask sigvec strcasecmp strerror strftime stricmp strncasecmp \
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00003664 strnicmp strpbrk strtol tgetent towlower towupper iswupper \
Bram Moolenaarcd142e32017-11-16 17:03:45 +01003665 usleep utime utimes mblen ftruncate)
Bram Moolenaar25153e12010-02-24 14:47:08 +01003666AC_FUNC_FSEEKO
Bram Moolenaar071d4272004-06-13 20:20:40 +00003667
Bram Moolenaar317fd3a2010-05-07 16:05:55 +02003668dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when
3669dnl appropriate, so that off_t is 64 bits when needed.
3670AC_SYS_LARGEFILE
3671
Bram Moolenaar071d4272004-06-13 20:20:40 +00003672dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible
3673AC_MSG_CHECKING(for st_blksize)
3674AC_TRY_COMPILE(
3675[#include <sys/types.h>
3676#include <sys/stat.h>],
3677[ struct stat st;
3678 int n;
3679
3680 stat("/", &st);
3681 n = (int)st.st_blksize;],
3682 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ST_BLKSIZE),
3683 AC_MSG_RESULT(no))
3684
Bram Moolenaar446cb832008-06-24 21:56:24 +00003685AC_CACHE_CHECK([whether stat() ignores a trailing slash], [vim_cv_stat_ignores_slash],
3686 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003687 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003688#include "confdefs.h"
3689#if STDC_HEADERS
3690# include <stdlib.h>
3691# include <stddef.h>
3692#endif
3693#include <sys/types.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003694#include <sys/stat.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003695main() {struct stat st; exit(stat("configure/", &st) != 0); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003696 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003697 vim_cv_stat_ignores_slash=yes
3698 ],[
3699 vim_cv_stat_ignores_slash=no
3700 ],[
3701 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_stat_ignores_slash')
3702 ])
3703 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003704
Bram Moolenaar446cb832008-06-24 21:56:24 +00003705if test "x$vim_cv_stat_ignores_slash" = "xyes" ; then
3706 AC_DEFINE(STAT_IGNORES_SLASH)
3707fi
3708
Bram Moolenaar071d4272004-06-13 20:20:40 +00003709dnl Link with iconv for charset translation, if not found without library.
3710dnl check for iconv() requires including iconv.h
3711dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
3712dnl has been installed.
3713AC_MSG_CHECKING(for iconv_open())
3714save_LIBS="$LIBS"
3715LIBS="$LIBS -liconv"
3716AC_TRY_LINK([
3717#ifdef HAVE_ICONV_H
3718# include <iconv.h>
3719#endif
3720 ], [iconv_open("fr", "to");],
3721 AC_MSG_RESULT(yes; with -liconv); AC_DEFINE(HAVE_ICONV),
3722 LIBS="$save_LIBS"
3723 AC_TRY_LINK([
3724#ifdef HAVE_ICONV_H
3725# include <iconv.h>
3726#endif
3727 ], [iconv_open("fr", "to");],
3728 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ICONV),
3729 AC_MSG_RESULT(no)))
3730
3731
3732AC_MSG_CHECKING(for nl_langinfo(CODESET))
3733AC_TRY_LINK([
3734#ifdef HAVE_LANGINFO_H
3735# include <langinfo.h>
3736#endif
3737], [char *cs = nl_langinfo(CODESET);],
3738 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET),
3739 AC_MSG_RESULT(no))
3740
Bram Moolenaar446cb832008-06-24 21:56:24 +00003741dnl Need various functions for floating point support. Only enable
3742dnl floating point when they are all present.
3743AC_CHECK_LIB(m, strtod)
3744AC_MSG_CHECKING([for strtod() and other floating point functions])
3745AC_TRY_LINK([
3746#ifdef HAVE_MATH_H
3747# include <math.h>
3748#endif
3749#if STDC_HEADERS
3750# include <stdlib.h>
3751# include <stddef.h>
3752#endif
3753], [char *s; double d;
3754 d = strtod("1.1", &s);
3755 d = fabs(1.11);
3756 d = ceil(1.11);
3757 d = floor(1.11);
3758 d = log10(1.11);
3759 d = pow(1.11, 2.22);
3760 d = sqrt(1.11);
3761 d = sin(1.11);
3762 d = cos(1.11);
3763 d = atan(1.11);
3764 ],
3765 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT_FUNCS),
3766 AC_MSG_RESULT(no))
3767
Bram Moolenaara6b89762016-02-29 21:38:26 +01003768dnl isinf() and isnan() need to include header files and may need -lm.
3769AC_MSG_CHECKING([for isinf()])
3770AC_TRY_LINK([
3771#ifdef HAVE_MATH_H
3772# include <math.h>
3773#endif
3774#if STDC_HEADERS
3775# include <stdlib.h>
3776# include <stddef.h>
3777#endif
3778], [int r = isinf(1.11); ],
3779 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISINF),
3780 AC_MSG_RESULT(no))
3781
3782AC_MSG_CHECKING([for isnan()])
3783AC_TRY_LINK([
3784#ifdef HAVE_MATH_H
3785# include <math.h>
3786#endif
3787#if STDC_HEADERS
3788# include <stdlib.h>
3789# include <stddef.h>
3790#endif
3791], [int r = isnan(1.11); ],
3792 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISNAN),
3793 AC_MSG_RESULT(no))
3794
Bram Moolenaar071d4272004-06-13 20:20:40 +00003795dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI
3796dnl when -lacl works, also try to use -lattr (required for Debian).
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003797dnl On Solaris, use the acl_get/set functions in libsec, if present.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003798AC_MSG_CHECKING(--disable-acl argument)
3799AC_ARG_ENABLE(acl,
3800 [ --disable-acl Don't check for ACL support.],
3801 , [enable_acl="yes"])
3802if test "$enable_acl" = "yes"; then
3803AC_MSG_RESULT(no)
3804AC_CHECK_LIB(posix1e, acl_get_file, [LIBS="$LIBS -lposix1e"],
3805 AC_CHECK_LIB(acl, acl_get_file, [LIBS="$LIBS -lacl"
3806 AC_CHECK_LIB(attr, fgetxattr, LIBS="$LIBS -lattr",,)],,),)
3807
3808AC_MSG_CHECKING(for POSIX ACL support)
3809AC_TRY_LINK([
3810#include <sys/types.h>
3811#ifdef HAVE_SYS_ACL_H
3812# include <sys/acl.h>
3813#endif
3814acl_t acl;], [acl = acl_get_file("foo", ACL_TYPE_ACCESS);
3815 acl_set_file("foo", ACL_TYPE_ACCESS, acl);
3816 acl_free(acl);],
3817 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_ACL),
3818 AC_MSG_RESULT(no))
3819
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003820AC_CHECK_LIB(sec, acl_get, [LIBS="$LIBS -lsec"; AC_DEFINE(HAVE_SOLARIS_ZFS_ACL)],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003821AC_MSG_CHECKING(for Solaris ACL support)
3822AC_TRY_LINK([
3823#ifdef HAVE_SYS_ACL_H
3824# include <sys/acl.h>
3825#endif], [acl("foo", GETACLCNT, 0, NULL);
3826 ],
3827 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOLARIS_ACL),
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003828 AC_MSG_RESULT(no)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003829
3830AC_MSG_CHECKING(for AIX ACL support)
3831AC_TRY_LINK([
Bram Moolenaar446cb832008-06-24 21:56:24 +00003832#if STDC_HEADERS
3833# include <stdlib.h>
3834# include <stddef.h>
3835#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003836#ifdef HAVE_SYS_ACL_H
3837# include <sys/acl.h>
3838#endif
3839#ifdef HAVE_SYS_ACCESS_H
3840# include <sys/access.h>
3841#endif
3842#define _ALL_SOURCE
3843
3844#include <sys/stat.h>
3845
3846int aclsize;
3847struct acl *aclent;], [aclsize = sizeof(struct acl);
3848 aclent = (void *)malloc(aclsize);
3849 statacl("foo", STX_NORMAL, aclent, aclsize);
3850 ],
3851 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_AIX_ACL),
3852 AC_MSG_RESULT(no))
3853else
3854 AC_MSG_RESULT(yes)
3855fi
3856
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02003857if test "x$GTK_CFLAGS" != "x"; then
3858 dnl pango_shape_full() is new, fall back to pango_shape().
3859 AC_MSG_CHECKING(for pango_shape_full)
3860 ac_save_CFLAGS="$CFLAGS"
3861 ac_save_LIBS="$LIBS"
3862 CFLAGS="$CFLAGS $GTK_CFLAGS"
3863 LIBS="$LIBS $GTK_LIBS"
Bram Moolenaar5325b9b2015-09-09 20:27:02 +02003864 AC_TRY_LINK(
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02003865 [#include <gtk/gtk.h>],
3866 [ pango_shape_full(NULL, 0, NULL, 0, NULL, NULL); ],
3867 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_PANGO_SHAPE_FULL),
3868 AC_MSG_RESULT(no))
3869 CFLAGS="$ac_save_CFLAGS"
3870 LIBS="$ac_save_LIBS"
3871fi
3872
Bram Moolenaar071d4272004-06-13 20:20:40 +00003873AC_MSG_CHECKING(--disable-gpm argument)
3874AC_ARG_ENABLE(gpm,
3875 [ --disable-gpm Don't use gpm (Linux mouse daemon).], ,
3876 [enable_gpm="yes"])
3877
3878if test "$enable_gpm" = "yes"; then
3879 AC_MSG_RESULT(no)
3880 dnl Checking if gpm support can be compiled
3881 AC_CACHE_CHECK([for gpm], vi_cv_have_gpm,
3882 [olibs="$LIBS" ; LIBS="-lgpm"]
3883 AC_TRY_LINK(
3884 [#include <gpm.h>
3885 #include <linux/keyboard.h>],
3886 [Gpm_GetLibVersion(NULL);],
3887 dnl Configure defines HAVE_GPM, if it is defined feature.h defines
3888 dnl FEAT_MOUSE_GPM if mouse support is included
3889 [vi_cv_have_gpm=yes],
3890 [vi_cv_have_gpm=no])
3891 [LIBS="$olibs"]
3892 )
3893 if test $vi_cv_have_gpm = yes; then
3894 LIBS="$LIBS -lgpm"
3895 AC_DEFINE(HAVE_GPM)
3896 fi
3897else
3898 AC_MSG_RESULT(yes)
3899fi
3900
Bram Moolenaar446cb832008-06-24 21:56:24 +00003901AC_MSG_CHECKING(--disable-sysmouse argument)
3902AC_ARG_ENABLE(sysmouse,
Bram Moolenaar8008b632017-07-18 21:33:20 +02003903 [ --disable-sysmouse Don't use sysmouse (mouse in *BSD console).], ,
Bram Moolenaar446cb832008-06-24 21:56:24 +00003904 [enable_sysmouse="yes"])
3905
3906if test "$enable_sysmouse" = "yes"; then
3907 AC_MSG_RESULT(no)
3908 dnl Checking if sysmouse support can be compiled
3909 dnl Configure defines HAVE_SYSMOUSE, if it is defined feature.h
3910 dnl defines FEAT_SYSMOUSE if mouse support is included
3911 AC_CACHE_CHECK([for sysmouse], vi_cv_have_sysmouse,
3912 AC_TRY_LINK(
3913 [#include <sys/consio.h>
3914 #include <signal.h>
3915 #include <sys/fbio.h>],
3916 [struct mouse_info mouse;
3917 mouse.operation = MOUSE_MODE;
3918 mouse.operation = MOUSE_SHOW;
3919 mouse.u.mode.mode = 0;
3920 mouse.u.mode.signal = SIGUSR2;],
3921 [vi_cv_have_sysmouse=yes],
3922 [vi_cv_have_sysmouse=no])
3923 )
3924 if test $vi_cv_have_sysmouse = yes; then
3925 AC_DEFINE(HAVE_SYSMOUSE)
3926 fi
3927else
3928 AC_MSG_RESULT(yes)
3929fi
3930
Bram Moolenaarf05da212009-11-17 16:13:15 +00003931dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
3932AC_MSG_CHECKING(for FD_CLOEXEC)
3933AC_TRY_COMPILE(
3934[#if HAVE_FCNTL_H
3935# include <fcntl.h>
3936#endif],
3937[ int flag = FD_CLOEXEC;],
3938 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
3939 AC_MSG_RESULT(not usable))
3940
Bram Moolenaar071d4272004-06-13 20:20:40 +00003941dnl rename needs to be checked separately to work on Nextstep with cc
3942AC_MSG_CHECKING(for rename)
3943AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
3944 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
3945 AC_MSG_RESULT(no))
3946
3947dnl sysctl() may exist but not the arguments we use
3948AC_MSG_CHECKING(for sysctl)
3949AC_TRY_COMPILE(
3950[#include <sys/types.h>
3951#include <sys/sysctl.h>],
3952[ int mib[2], r;
3953 size_t len;
3954
3955 mib[0] = CTL_HW;
3956 mib[1] = HW_USERMEM;
3957 len = sizeof(r);
3958 (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
3959 ],
3960 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL),
3961 AC_MSG_RESULT(not usable))
3962
3963dnl sysinfo() may exist but not be Linux compatible
3964AC_MSG_CHECKING(for sysinfo)
3965AC_TRY_COMPILE(
3966[#include <sys/types.h>
3967#include <sys/sysinfo.h>],
3968[ struct sysinfo sinfo;
3969 int t;
3970
3971 (void)sysinfo(&sinfo);
3972 t = sinfo.totalram;
3973 ],
3974 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
3975 AC_MSG_RESULT(not usable))
3976
Bram Moolenaar914572a2007-05-01 11:37:47 +00003977dnl struct sysinfo may have the mem_unit field or not
3978AC_MSG_CHECKING(for sysinfo.mem_unit)
3979AC_TRY_COMPILE(
3980[#include <sys/types.h>
3981#include <sys/sysinfo.h>],
3982[ struct sysinfo sinfo;
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02003983 sinfo.mem_unit = 1;
Bram Moolenaar914572a2007-05-01 11:37:47 +00003984 ],
3985 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_MEM_UNIT),
3986 AC_MSG_RESULT(no))
3987
Bram Moolenaar071d4272004-06-13 20:20:40 +00003988dnl sysconf() may exist but not support what we want to use
3989AC_MSG_CHECKING(for sysconf)
3990AC_TRY_COMPILE(
3991[#include <unistd.h>],
3992[ (void)sysconf(_SC_PAGESIZE);
3993 (void)sysconf(_SC_PHYS_PAGES);
3994 ],
3995 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
3996 AC_MSG_RESULT(not usable))
3997
Bram Moolenaar914703b2010-05-31 21:59:46 +02003998AC_CHECK_SIZEOF([int])
3999AC_CHECK_SIZEOF([long])
4000AC_CHECK_SIZEOF([time_t])
4001AC_CHECK_SIZEOF([off_t])
Bram Moolenaar644fdff2010-05-30 13:26:21 +02004002
Bram Moolenaara2aa31a2014-02-23 22:52:40 +01004003dnl Use different names to avoid clashing with other header files.
4004AC_DEFINE_UNQUOTED(VIM_SIZEOF_INT, [$ac_cv_sizeof_int])
4005AC_DEFINE_UNQUOTED(VIM_SIZEOF_LONG, [$ac_cv_sizeof_long])
4006
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004007dnl Make sure that uint32_t is really 32 bits unsigned.
4008AC_MSG_CHECKING([uint32_t is 32 bits])
4009AC_TRY_RUN([
4010#ifdef HAVE_STDINT_H
4011# include <stdint.h>
4012#endif
4013#ifdef HAVE_INTTYPES_H
4014# include <inttypes.h>
4015#endif
4016main() {
4017 uint32_t nr1 = (uint32_t)-1;
4018 uint32_t nr2 = (uint32_t)0xffffffffUL;
4019 if (sizeof(uint32_t) != 4 || nr1 != 0xffffffffUL || nr2 + 1 != 0) exit(1);
4020 exit(0);
4021}],
4022AC_MSG_RESULT(ok),
4023AC_MSG_ERROR([WRONG! uint32_t not defined correctly.]),
Bram Moolenaar323cb952011-12-14 19:22:34 +01004024AC_MSG_WARN([cannot check uint32_t when cross-compiling.]))
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004025
Bram Moolenaar446cb832008-06-24 21:56:24 +00004026dnl Check for memmove() before bcopy(), makes memmove() be used when both are
4027dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
4028
Bram Moolenaar071d4272004-06-13 20:20:40 +00004029[bcopy_test_prog='
Bram Moolenaar446cb832008-06-24 21:56:24 +00004030#include "confdefs.h"
4031#ifdef HAVE_STRING_H
4032# include <string.h>
4033#endif
4034#if STDC_HEADERS
4035# include <stdlib.h>
4036# include <stddef.h>
4037#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004038main() {
4039 char buf[10];
4040 strcpy(buf, "abcdefghi");
4041 mch_memmove(buf, buf + 2, 3);
4042 if (strncmp(buf, "ababcf", 6))
4043 exit(1);
4044 strcpy(buf, "abcdefghi");
4045 mch_memmove(buf + 2, buf, 3);
4046 if (strncmp(buf, "cdedef", 6))
4047 exit(1);
4048 exit(0); /* libc version works properly. */
4049}']
4050
Bram Moolenaar446cb832008-06-24 21:56:24 +00004051AC_CACHE_CHECK([whether memmove handles overlaps],[vim_cv_memmove_handles_overlap],
4052 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004053 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 +00004054 [
4055 vim_cv_memmove_handles_overlap=yes
4056 ],[
4057 vim_cv_memmove_handles_overlap=no
4058 ],[
4059 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memmove_handles_overlap')
4060 ])
4061 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00004062
Bram Moolenaar446cb832008-06-24 21:56:24 +00004063if test "x$vim_cv_memmove_handles_overlap" = "xyes" ; then
4064 AC_DEFINE(USEMEMMOVE)
4065else
4066 AC_CACHE_CHECK([whether bcopy handles overlaps],[vim_cv_bcopy_handles_overlap],
4067 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004068 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 +00004069 [
4070 vim_cv_bcopy_handles_overlap=yes
4071 ],[
4072 vim_cv_bcopy_handles_overlap=no
4073 ],[
4074 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_bcopy_handles_overlap')
4075 ])
4076 ])
4077
4078 if test "x$vim_cv_bcopy_handles_overlap" = "xyes" ; then
4079 AC_DEFINE(USEBCOPY)
4080 else
4081 AC_CACHE_CHECK([whether memcpy handles overlaps],[vim_cv_memcpy_handles_overlap],
4082 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004083 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 +00004084 [
4085 vim_cv_memcpy_handles_overlap=yes
4086 ],[
4087 vim_cv_memcpy_handles_overlap=no
4088 ],[
4089 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memcpy_handles_overlap')
4090 ])
4091 ])
4092
4093 if test "x$vim_cv_memcpy_handles_overlap" = "xyes" ; then
4094 AC_DEFINE(USEMEMCPY)
4095 fi
4096 fi
4097fi
4098
Bram Moolenaar071d4272004-06-13 20:20:40 +00004099
4100dnl Check for multibyte locale functions
4101dnl Find out if _Xsetlocale() is supported by libX11.
4102dnl Check if X_LOCALE should be defined.
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004103if test "x$with_x" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004104 cflags_save=$CFLAGS
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004105 libs_save=$LIBS
4106 LIBS="$LIBS $X_LIBS $GUI_LIB_LOC $GUI_X_LIBS $X_PRE_LIBS $X_LIB $X_EXTRA_LIBS"
4107 CFLAGS="$CFLAGS $X_CFLAGS"
4108
4109 AC_MSG_CHECKING(whether X_LOCALE needed)
4110 AC_TRY_COMPILE([#include <X11/Xlocale.h>],,
4111 AC_TRY_LINK_FUNC([_Xsetlocale], [AC_MSG_RESULT(yes)
4112 AC_DEFINE(X_LOCALE)], AC_MSG_RESULT(no)),
4113 AC_MSG_RESULT(no))
4114
4115 AC_MSG_CHECKING(whether Xutf8SetWMProperties() can be used)
4116 AC_TRY_LINK_FUNC([Xutf8SetWMProperties], [AC_MSG_RESULT(yes)
4117 AC_DEFINE(HAVE_XUTF8SETWMPROPERTIES)], AC_MSG_RESULT(no))
4118
Bram Moolenaar071d4272004-06-13 20:20:40 +00004119 CFLAGS=$cflags_save
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004120 LIBS=$libs_save
Bram Moolenaar071d4272004-06-13 20:20:40 +00004121fi
4122
4123dnl Link with xpg4, it is said to make Korean locale working
4124AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,)
4125
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004126dnl Check how we can run ctags. Default to "ctags" when nothing works.
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02004127dnl Use --version to detect Exuberant ctags (preferred)
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004128dnl Add --fields=+S to get function signatures for omni completion.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004129dnl -t for typedefs (many ctags have this)
4130dnl -s for static functions (Elvis ctags only?)
4131dnl -v for variables. Dangerous, most ctags take this for 'vgrind style'.
4132dnl -i+m to test for older Exuberant ctags
4133AC_MSG_CHECKING(how to create tags)
4134test -f tags && mv tags tags.save
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004135if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004136 TAGPRG="ctags -I INIT+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004137elif (eval exctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
4138 TAGPRG="exctags -I INIT+ --fields=+S"
4139elif (eval exuberant-ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
4140 TAGPRG="exuberant-ctags -I INIT+ --fields=+S"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004141else
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004142 TAGPRG="ctags"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004143 (eval etags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags"
4144 (eval etags -c /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags -c"
4145 (eval ctags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags"
4146 (eval ctags -t /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -t"
4147 (eval ctags -ts /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -ts"
4148 (eval ctags -tvs /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -tvs"
4149 (eval ctags -i+m /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -i+m"
4150fi
4151test -f tags.save && mv tags.save tags
4152AC_MSG_RESULT($TAGPRG) AC_SUBST(TAGPRG)
4153
4154dnl Check how we can run man with a section number
4155AC_MSG_CHECKING(how to run man with a section nr)
4156MANDEF="man"
Bram Moolenaar8b131502008-02-13 09:28:19 +00004157(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 +00004158AC_MSG_RESULT($MANDEF)
4159if test "$MANDEF" = "man -s"; then
4160 AC_DEFINE(USEMAN_S)
4161fi
4162
4163dnl Check if gettext() is working and if it needs -lintl
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004164dnl We take care to base this on an empty LIBS: on some systems libelf would be
4165dnl in LIBS and implicitly take along libintl. The final LIBS would then not
4166dnl contain libintl, and the link step would fail due to -Wl,--as-needed.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004167AC_MSG_CHECKING(--disable-nls argument)
4168AC_ARG_ENABLE(nls,
4169 [ --disable-nls Don't support NLS (gettext()).], ,
4170 [enable_nls="yes"])
4171
4172if test "$enable_nls" = "yes"; then
4173 AC_MSG_RESULT(no)
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00004174
4175 INSTALL_LANGS=install-languages
4176 AC_SUBST(INSTALL_LANGS)
4177 INSTALL_TOOL_LANGS=install-tool-languages
4178 AC_SUBST(INSTALL_TOOL_LANGS)
4179
Bram Moolenaar071d4272004-06-13 20:20:40 +00004180 AC_CHECK_PROG(MSGFMT, msgfmt, msgfmt, )
4181 AC_MSG_CHECKING([for NLS])
4182 if test -f po/Makefile; then
4183 have_gettext="no"
4184 if test -n "$MSGFMT"; then
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004185 olibs=$LIBS
4186 LIBS=""
Bram Moolenaar071d4272004-06-13 20:20:40 +00004187 AC_TRY_LINK(
4188 [#include <libintl.h>],
4189 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004190 AC_MSG_RESULT([gettext() works]); have_gettext="yes"; LIBS=$olibs,
4191 LIBS="-lintl"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004192 AC_TRY_LINK(
4193 [#include <libintl.h>],
4194 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004195 AC_MSG_RESULT([gettext() works with -lintl]); have_gettext="yes";
4196 LIBS="$olibs -lintl",
Bram Moolenaar071d4272004-06-13 20:20:40 +00004197 AC_MSG_RESULT([gettext() doesn't work]);
4198 LIBS=$olibs))
4199 else
4200 AC_MSG_RESULT([msgfmt not found - disabled]);
4201 fi
Bram Moolenaar278eb582014-07-30 13:22:52 +02004202 if test $have_gettext = "yes" -a "x$features" != "xtiny" -a "x$features" != "xsmall"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004203 AC_DEFINE(HAVE_GETTEXT)
4204 MAKEMO=yes
4205 AC_SUBST(MAKEMO)
4206 dnl this was added in GNU gettext 0.10.36
4207 AC_CHECK_FUNCS(bind_textdomain_codeset)
4208 dnl _nl_msg_cat_cntr is required for GNU gettext
4209 AC_MSG_CHECKING([for _nl_msg_cat_cntr])
4210 AC_TRY_LINK(
4211 [#include <libintl.h>
4212 extern int _nl_msg_cat_cntr;],
4213 [++_nl_msg_cat_cntr;],
4214 AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_NL_MSG_CAT_CNTR),
4215 AC_MSG_RESULT([no]))
4216 fi
4217 else
4218 AC_MSG_RESULT([no "po/Makefile" - disabled]);
4219 fi
4220else
4221 AC_MSG_RESULT(yes)
4222fi
4223
4224dnl Check for dynamic linking loader
4225AC_CHECK_HEADER(dlfcn.h, DLL=dlfcn.h, [AC_CHECK_HEADER(dl.h, DLL=dl.h)])
4226if test x${DLL} = xdlfcn.h; then
4227 AC_DEFINE(HAVE_DLFCN_H, 1, [ Define if we have dlfcn.h. ])
4228 AC_MSG_CHECKING([for dlopen()])
4229 AC_TRY_LINK(,[
4230 extern void* dlopen();
4231 dlopen();
4232 ],
4233 AC_MSG_RESULT(yes);
4234 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4235 AC_MSG_RESULT(no);
4236 AC_MSG_CHECKING([for dlopen() in -ldl])
4237 olibs=$LIBS
4238 LIBS="$LIBS -ldl"
4239 AC_TRY_LINK(,[
4240 extern void* dlopen();
4241 dlopen();
4242 ],
4243 AC_MSG_RESULT(yes);
4244 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4245 AC_MSG_RESULT(no);
4246 LIBS=$olibs))
4247 dnl ReliantUNIX has dlopen() in libc but everything else in libdl
4248 dnl ick :-)
4249 AC_MSG_CHECKING([for dlsym()])
4250 AC_TRY_LINK(,[
4251 extern void* dlsym();
4252 dlsym();
4253 ],
4254 AC_MSG_RESULT(yes);
4255 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4256 AC_MSG_RESULT(no);
4257 AC_MSG_CHECKING([for dlsym() in -ldl])
4258 olibs=$LIBS
4259 LIBS="$LIBS -ldl"
4260 AC_TRY_LINK(,[
4261 extern void* dlsym();
4262 dlsym();
4263 ],
4264 AC_MSG_RESULT(yes);
4265 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4266 AC_MSG_RESULT(no);
4267 LIBS=$olibs))
4268elif test x${DLL} = xdl.h; then
4269 AC_DEFINE(HAVE_DL_H, 1, [ Define if we have dl.h. ])
4270 AC_MSG_CHECKING([for shl_load()])
4271 AC_TRY_LINK(,[
4272 extern void* shl_load();
4273 shl_load();
4274 ],
4275 AC_MSG_RESULT(yes);
4276 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4277 AC_MSG_RESULT(no);
4278 AC_MSG_CHECKING([for shl_load() in -ldld])
4279 olibs=$LIBS
4280 LIBS="$LIBS -ldld"
4281 AC_TRY_LINK(,[
4282 extern void* shl_load();
4283 shl_load();
4284 ],
4285 AC_MSG_RESULT(yes);
4286 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4287 AC_MSG_RESULT(no);
4288 LIBS=$olibs))
4289fi
4290AC_CHECK_HEADERS(setjmp.h)
4291
Bram Moolenaard0573012017-10-28 21:11:06 +02004292if test "x$MACOS_X" = "xyes" -a -n "$PERL"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004293 dnl -ldl must come after DynaLoader.a
4294 if echo $LIBS | grep -e '-ldl' >/dev/null; then
4295 LIBS=`echo $LIBS | sed s/-ldl//`
4296 PERL_LIBS="$PERL_LIBS -ldl"
4297 fi
4298fi
4299
Bram Moolenaard0573012017-10-28 21:11:06 +02004300if test "$MACOS_X" = "yes"; then
4301 AC_MSG_CHECKING([whether we need macOS frameworks])
4302 if test "$GUITYPE" = "CARBONGUI"; then
4303 AC_MSG_RESULT([yes, we need Carbon])
4304 LIBS="$LIBS -framework Carbon"
4305 elif test "$MACOS_X_DARWIN" = "yes"; then
4306 if test "$features" = "tiny"; then
4307 dnl Since no FEAT_CLIPBOARD, no longer need for os_macosx.m.
4308 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_macosx.m++'`
4309 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_macosx.o++'`
4310 if test "$enable_multibyte" = "yes"; then
4311 AC_MSG_RESULT([yes, we need CoreServices])
4312 LIBS="$LIBS -framework CoreServices"
4313 else
4314 dnl Since no FEAT_MBYTE, no longer need for os_mac_conv.c.
4315 AC_MSG_RESULT([no])
4316 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_mac_conv.c++'`
4317 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_mac_conv.o++'`
4318 CPPFLAGS=`echo "$CPPFLAGS" | sed -e 's+-DMACOS_X_DARWIN++'`
4319 fi
4320 else
4321 AC_MSG_RESULT([yes, we need AppKit])
4322 LIBS="$LIBS -framework AppKit"
4323 if test "$features" = "small" -a "$enable_multibyte" = "no"; then
4324 dnl Since FEAT_CLIPBOARD is to be defined in vim.h for FEAT_SMALL, define
4325 dnl FEAT_MBYTE in order not to compromise the interoperability of the
4326 dnl clipboard.
4327 AC_MSG_NOTICE([+multi_byte will be set in favor of +clipboard])
4328 enable_multibyte=yes
4329 AC_DEFINE(FEAT_MBYTE)
4330 fi
4331 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004332 else
Bram Moolenaard0573012017-10-28 21:11:06 +02004333 AC_MSG_RESULT([no])
Bram Moolenaar3437b912013-07-03 19:52:53 +02004334 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004335fi
Bram Moolenaar164fca32010-07-14 13:58:07 +02004336if test "x$MACARCH" = "xboth" && test "x$GUITYPE" = "xCARBONGUI"; then
Bram Moolenaar595a7be2010-03-10 16:28:12 +01004337 LDFLAGS="$LDFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +00004338fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004339
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004340dnl gcc 3.1 changed the meaning of -MM. The only solution appears to be to
4341dnl use "-isystem" instead of "-I" for all non-Vim include dirs.
4342dnl But only when making dependencies, cproto and lint don't take "-isystem".
Bram Moolenaar32466aa2006-02-24 23:53:04 +00004343dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
4344dnl the number before the version number.
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004345DEPEND_CFLAGS_FILTER=
4346if test "$GCC" = yes; then
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004347 AC_MSG_CHECKING(for GCC 3 or later)
Bram Moolenaar2217cae2006-03-25 21:55:52 +00004348 gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]]\)\..*$/\1/g'`
Bram Moolenaarf740b292006-02-16 22:11:02 +00004349 if test "$gccmajor" -gt "2"; then
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004350 DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004351 AC_MSG_RESULT(yes)
4352 else
4353 AC_MSG_RESULT(no)
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004354 fi
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004355 dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
4356 dnl declared as char x[1] but actually longer. Introduced in gcc 4.0.
Bram Moolenaar56d1db32009-12-16 16:14:51 +00004357 dnl Also remove duplicate _FORTIFY_SOURCE arguments.
Bram Moolenaaraeabe052011-12-08 15:17:34 +01004358 dnl And undefine it first to avoid a warning.
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004359 AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
4360 if test "$gccmajor" -gt "3"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02004361 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 +00004362 AC_MSG_RESULT(yes)
4363 else
4364 AC_MSG_RESULT(no)
4365 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +00004366fi
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004367AC_SUBST(DEPEND_CFLAGS_FILTER)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004368
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004369dnl link.sh tries to avoid overlinking in a hackish way.
4370dnl At least GNU ld supports --as-needed which provides the same functionality
4371dnl at linker level. Let's use it.
4372AC_MSG_CHECKING(linker --as-needed support)
4373LINK_AS_NEEDED=
4374# Check if linker supports --as-needed and --no-as-needed options
4375if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02004376 LDFLAGS=`echo "$LDFLAGS" | sed -e 's/ *-Wl,--as-needed//g' | sed -e 's/$/ -Wl,--as-needed/'`
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004377 LINK_AS_NEEDED=yes
4378fi
4379if test "$LINK_AS_NEEDED" = yes; then
4380 AC_MSG_RESULT(yes)
4381else
4382 AC_MSG_RESULT(no)
4383fi
4384AC_SUBST(LINK_AS_NEEDED)
4385
Bram Moolenaar77c19352012-06-13 19:19:41 +02004386# IBM z/OS reset CFLAGS for config.mk
4387if test "$zOSUnix" = "yes"; then
4388 CFLAGS="-D_ALL_SOURCE -Wc,float\(ieee\),dll"
4389fi
4390
Bram Moolenaar071d4272004-06-13 20:20:40 +00004391dnl write output files
4392AC_OUTPUT(auto/config.mk:config.mk.in)
4393
4394dnl vim: set sw=2 tw=78 fo+=l: