blob: 27309b205deab42b5efb8730190866020e0bb10a [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 Moolenaar2e324952018-04-14 14:37:07 +020014AC_PROG_CC_C89 dnl required by almost everything
Bram Moolenaarc0394412017-04-20 20:20:23 +020015AC_PROG_CPP dnl required by header file checks
16AC_PROGRAM_EGREP dnl required by AC_EGREP_CPP
17AC_PROG_FGREP dnl finds working grep -F
18AC_ISC_POSIX dnl required by AC_C_CROSS
19AC_PROG_AWK dnl required for "make html" in ../doc
Bram Moolenaar071d4272004-06-13 20:20:40 +000020
21dnl Don't strip if we don't have it
22AC_CHECK_PROG(STRIP, strip, strip, :)
23
Bram Moolenaar325b7a22004-07-05 15:58:32 +000024dnl Check for extension of executables
Bram Moolenaar071d4272004-06-13 20:20:40 +000025AC_EXEEXT
26
Bram Moolenaar446cb832008-06-24 21:56:24 +000027dnl Check for standard headers. We don't use this in Vim but other stuff
28dnl in autoconf needs it, where it uses STDC_HEADERS.
29AC_HEADER_STDC
30AC_HEADER_SYS_WAIT
31
Bram 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
Bram Moolenaar2e324952018-04-14 14:37:07 +020064
65 dnl Declare what standards the code should comply with
66 CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700"
Bram Moolenaar071d4272004-06-13 20:20:40 +000067fi
68
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +020069dnl clang-500.2.75 or around has abandoned -f[no-]strength-reduce and issues a
70dnl warning when that flag is passed to. Accordingly, adjust CFLAGS based on
71dnl the version number of the clang in use.
72dnl Note that this does not work to get the version of clang 3.1 or 3.2.
Bram Moolenaar5f69fee2017-03-09 11:58:40 +010073AC_MSG_CHECKING(for clang version)
74CLANG_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 +020075if test x"$CLANG_VERSION_STRING" != x"" ; then
76 CLANG_MAJOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*/\1/p'`
77 CLANG_MINOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/p'`
78 CLANG_REVISION=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)/\1/p'`
79 CLANG_VERSION=`expr $CLANG_MAJOR '*' 1000000 '+' $CLANG_MINOR '*' 1000 '+' $CLANG_REVISION`
80 AC_MSG_RESULT($CLANG_VERSION)
81 dnl If you find the same issue with versions earlier than 500.2.75,
82 dnl change the constant 500002075 below appropriately. To get the
83 dnl integer corresponding to a version number, refer to the
84 dnl definition of CLANG_VERSION above.
Bram Moolenaar5f69fee2017-03-09 11:58:40 +010085 AC_MSG_CHECKING(if clang supports -fno-strength-reduce)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +020086 if test "$CLANG_VERSION" -ge 500002075 ; then
Bram Moolenaar5f69fee2017-03-09 11:58:40 +010087 AC_MSG_RESULT(no)
88 CFLAGS=`echo "$CFLAGS" | sed -e 's/-fno-strength-reduce/ /'`
89 else
90 AC_MSG_RESULT(yes)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +020091 fi
92else
Bram Moolenaar5f69fee2017-03-09 11:58:40 +010093 AC_MSG_RESULT(N/A)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +020094fi
95
Bram Moolenaar446cb832008-06-24 21:56:24 +000096dnl If configure thinks we are cross compiling, there might be something
97dnl wrong with the CC or CFLAGS settings, give a useful warning message
Bram Moolenaar839e9542016-04-14 16:46:02 +020098CROSS_COMPILING=
Bram Moolenaar071d4272004-06-13 20:20:40 +000099if test "$cross_compiling" = yes; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000100 AC_MSG_RESULT([cannot compile a simple program; if not cross compiling check CC and CFLAGS])
Bram Moolenaar839e9542016-04-14 16:46:02 +0200101 CROSS_COMPILING=1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000102fi
Bram Moolenaar839e9542016-04-14 16:46:02 +0200103AC_SUBST(CROSS_COMPILING)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000104
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +0000105dnl gcc-cpp has the wonderful -MM option to produce nicer dependencies.
106dnl But gcc 3.1 changed the meaning! See near the end.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000107test "$GCC" = yes && CPP_MM=M; AC_SUBST(CPP_MM)
108
109if test -f ./toolcheck; then
110 AC_CHECKING(for buggy tools)
111 sh ./toolcheck 1>&AC_FD_MSG
112fi
113
114OS_EXTRA_SRC=""; OS_EXTRA_OBJ=""
115
116dnl Check for BeOS, which needs an extra source file
117AC_MSG_CHECKING(for BeOS)
118case `uname` in
119 BeOS) OS_EXTRA_SRC=os_beos.c; OS_EXTRA_OBJ=objects/os_beos.o
120 BEOS=yes; AC_MSG_RESULT(yes);;
121 *) BEOS=no; AC_MSG_RESULT(no);;
122esac
123
124dnl If QNX is found, assume we don't want to use Xphoton
125dnl unless it was specifically asked for (--with-x)
126AC_MSG_CHECKING(for QNX)
127case `uname` in
128 QNX) OS_EXTRA_SRC=os_qnx.c; OS_EXTRA_OBJ=objects/os_qnx.o
129 test -z "$with_x" && with_x=no
130 QNX=yes; AC_MSG_RESULT(yes);;
131 *) QNX=no; AC_MSG_RESULT(no);;
132esac
133
134dnl Check for Darwin and MacOS X
135dnl We do a check for MacOS X in the very beginning because there
136dnl are a lot of other things we need to change besides GUI stuff
Bram Moolenaar071d4272004-06-13 20:20:40 +0000137AC_MSG_CHECKING([for Darwin (Mac OS X)])
138if test "`(uname) 2>/dev/null`" = Darwin; then
139 AC_MSG_RESULT(yes)
Bram Moolenaard0573012017-10-28 21:11:06 +0200140 MACOS_X=yes
Bram Moolenaar2e324952018-04-14 14:37:07 +0200141 CPPFLAGS="$CPPFLAGS -D_DARWIN_C_SOURCE -DMACOS_X"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000142
143 AC_MSG_CHECKING(--disable-darwin argument)
144 AC_ARG_ENABLE(darwin,
145 [ --disable-darwin Disable Darwin (Mac OS X) support.],
146 , [enable_darwin="yes"])
147 if test "$enable_darwin" = "yes"; then
148 AC_MSG_RESULT(no)
149 AC_MSG_CHECKING(if Darwin files are there)
Bram Moolenaar164fca32010-07-14 13:58:07 +0200150 if test -f os_macosx.m; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000151 AC_MSG_RESULT(yes)
152 else
153 AC_MSG_RESULT([no, Darwin support disabled])
154 enable_darwin=no
155 fi
156 else
157 AC_MSG_RESULT([yes, Darwin support excluded])
158 fi
159
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000160 AC_MSG_CHECKING(--with-mac-arch argument)
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000161 AC_ARG_WITH(mac-arch, [ --with-mac-arch=ARCH current, intel, ppc or both],
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000162 MACARCH="$withval"; AC_MSG_RESULT($MACARCH),
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000163 MACARCH="current"; AC_MSG_RESULT(defaulting to $MACARCH))
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000164
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100165 AC_MSG_CHECKING(--with-developer-dir argument)
166 AC_ARG_WITH(developer-dir, [ --with-developer-dir=PATH use PATH as location for Xcode developer tools],
167 DEVELOPER_DIR="$withval"; AC_MSG_RESULT($DEVELOPER_DIR),
Bram Moolenaar32d03b32015-11-19 13:46:48 +0100168 AC_MSG_RESULT(not present))
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100169
170 if test "x$DEVELOPER_DIR" = "x"; then
171 AC_PATH_PROG(XCODE_SELECT, xcode-select)
172 if test "x$XCODE_SELECT" != "x"; then
173 AC_MSG_CHECKING(for developer dir using xcode-select)
174 DEVELOPER_DIR=`$XCODE_SELECT -print-path`
175 AC_MSG_RESULT([$DEVELOPER_DIR])
176 else
177 DEVELOPER_DIR=/Developer
178 fi
179 fi
180
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000181 if test "x$MACARCH" = "xboth"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000182 AC_MSG_CHECKING(for 10.4 universal SDK)
183 dnl There is a terrible inconsistency (but we appear to get away with it):
184 dnl $CFLAGS uses the 10.4u SDK library for the headers, while $CPPFLAGS
185 dnl doesn't, because "gcc -E" doesn't grok it. That means the configure
186 dnl tests using the preprocessor are actually done with the wrong header
187 dnl files. $LDFLAGS is set at the end, because configure uses it together
188 dnl with $CFLAGS and we can only have one -sysroot argument.
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000189 save_cppflags="$CPPFLAGS"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000190 save_cflags="$CFLAGS"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000191 save_ldflags="$LDFLAGS"
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100192 CFLAGS="$CFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000193 AC_TRY_LINK([ ], [ ],
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000194 AC_MSG_RESULT(found, will make universal binary),
195
196 AC_MSG_RESULT(not found)
Bram Moolenaar1f35bf92006-03-07 22:38:47 +0000197 CFLAGS="$save_cflags"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000198 AC_MSG_CHECKING(if Intel architecture is supported)
199 CPPFLAGS="$CPPFLAGS -arch i386"
200 LDFLAGS="$save_ldflags -arch i386"
201 AC_TRY_LINK([ ], [ ],
202 AC_MSG_RESULT(yes); MACARCH="intel",
203 AC_MSG_RESULT(no, using PowerPC)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000204 MACARCH="ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000205 CPPFLAGS="$save_cppflags -arch ppc"
206 LDFLAGS="$save_ldflags -arch ppc"))
207 elif test "x$MACARCH" = "xintel"; then
208 CPPFLAGS="$CPPFLAGS -arch intel"
209 LDFLAGS="$LDFLAGS -arch intel"
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000210 elif test "x$MACARCH" = "xppc"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000211 CPPFLAGS="$CPPFLAGS -arch ppc"
212 LDFLAGS="$LDFLAGS -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000213 fi
214
Bram Moolenaar071d4272004-06-13 20:20:40 +0000215 if test "$enable_darwin" = "yes"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200216 MACOS_X_DARWIN=yes
Bram Moolenaar164fca32010-07-14 13:58:07 +0200217 OS_EXTRA_SRC="os_macosx.m os_mac_conv.c";
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000218 OS_EXTRA_OBJ="objects/os_macosx.o objects/os_mac_conv.o"
Bram Moolenaar32466aa2006-02-24 23:53:04 +0000219 dnl TODO: use -arch i386 on Intel machines
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100220 dnl Removed -no-cpp-precomp, only for very old compilers.
Bram Moolenaard0573012017-10-28 21:11:06 +0200221 CPPFLAGS="$CPPFLAGS -DMACOS_X_DARWIN"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000222
223 dnl If Carbon is found, assume we don't want X11
224 dnl unless it was specifically asked for (--with-x)
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000225 dnl or Motif, Athena or GTK GUI is used.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000226 AC_CHECK_HEADER(Carbon/Carbon.h, CARBON=yes)
227 if test "x$CARBON" = "xyes"; then
Bram Moolenaar98921892016-02-23 17:14:37 +0100228 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 +0000229 with_x=no
Bram Moolenaar071d4272004-06-13 20:20:40 +0000230 fi
231 fi
232 fi
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000233
Bram Moolenaardb552d602006-03-23 22:59:57 +0000234 dnl Avoid a bug with -O2 with gcc 4.0.1. Symptom: malloc() reports double
Bram Moolenaarfd2ac762006-03-01 22:09:21 +0000235 dnl free. This happens in expand_filename(), because the optimizer swaps
Bram Moolenaardb552d602006-03-23 22:59:57 +0000236 dnl two blocks of code, both using "repl", that can't be swapped.
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000237 if test "$MACARCH" = "intel" -o "$MACARCH" = "both"; then
238 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-Oz/'`
239 fi
240
Bram Moolenaar071d4272004-06-13 20:20:40 +0000241else
242 AC_MSG_RESULT(no)
243fi
244
Bram Moolenaar39766a72013-11-03 00:41:00 +0100245dnl Mac OS X 10.9+ no longer include AvailabilityMacros.h in Carbon
246dnl so we need to include it to have access to version macros.
Bram Moolenaar18e54692013-11-03 20:26:31 +0100247AC_CHECK_HEADERS(AvailabilityMacros.h)
Bram Moolenaar39766a72013-11-03 00:41:00 +0100248
Bram Moolenaar071d4272004-06-13 20:20:40 +0000249AC_SUBST(OS_EXTRA_SRC)
250AC_SUBST(OS_EXTRA_OBJ)
251
252dnl Add /usr/local/lib to $LDFLAGS and /usr/local/include to CFLAGS.
253dnl Only when the directory exists and it wasn't there yet.
254dnl For gcc don't do this when it is already in the default search path.
Bram Moolenaar446cb832008-06-24 21:56:24 +0000255dnl Skip all of this when cross-compiling.
256if test "$cross_compiling" = no; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000257 AC_MSG_CHECKING(--with-local-dir argument)
Bram Moolenaar446cb832008-06-24 21:56:24 +0000258 have_local_include=''
259 have_local_lib=''
Bram Moolenaarc236c162008-07-13 17:41:49 +0000260 AC_ARG_WITH([local-dir], [ --with-local-dir=PATH search PATH instead of /usr/local for local libraries.
261 --without-local-dir do not search /usr/local for local libraries.], [
262 local_dir="$withval"
263 case "$withval" in
264 */*) ;;
265 no)
266 # avoid adding local dir to LDFLAGS and CPPFLAGS
Bram Moolenaare06c1882010-07-21 22:05:20 +0200267 have_local_include=yes
Bram Moolenaarc236c162008-07-13 17:41:49 +0000268 have_local_lib=yes
269 ;;
270 *) AC_MSG_ERROR(must pass path argument to --with-local-dir) ;;
271 esac
272 AC_MSG_RESULT($local_dir)
273 ], [
274 local_dir=/usr/local
275 AC_MSG_RESULT(Defaulting to $local_dir)
276 ])
277 if test "$GCC" = yes -a "$local_dir" != no; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000278 echo 'void f(){}' > conftest.c
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100279 dnl Removed -no-cpp-precomp, only needed for OS X 10.2 (Ben Fowler)
280 have_local_include=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/include"`
Bram Moolenaarc236c162008-07-13 17:41:49 +0000281 have_local_lib=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/lib"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000282 rm -f conftest.c conftest.o
Bram Moolenaar071d4272004-06-13 20:20:40 +0000283 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000284 if test -z "$have_local_lib" -a -d "${local_dir}/lib"; then
285 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 +0000286 if test "$tt" = "$LDFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000287 LDFLAGS="$LDFLAGS -L${local_dir}/lib"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000288 fi
289 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000290 if test -z "$have_local_include" -a -d "${local_dir}/include"; then
291 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 +0000292 if test "$tt" = "$CPPFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000293 CPPFLAGS="$CPPFLAGS -I${local_dir}/include"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000294 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000295 fi
296fi
297
298AC_MSG_CHECKING(--with-vim-name argument)
299AC_ARG_WITH(vim-name, [ --with-vim-name=NAME what to call the Vim executable],
300 VIMNAME="$withval"; AC_MSG_RESULT($VIMNAME),
Bram Moolenaare344bea2005-09-01 20:46:49 +0000301 VIMNAME="vim"; AC_MSG_RESULT(Defaulting to $VIMNAME))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000302AC_SUBST(VIMNAME)
303AC_MSG_CHECKING(--with-ex-name argument)
304AC_ARG_WITH(ex-name, [ --with-ex-name=NAME what to call the Ex executable],
305 EXNAME="$withval"; AC_MSG_RESULT($EXNAME),
306 EXNAME="ex"; AC_MSG_RESULT(Defaulting to ex))
307AC_SUBST(EXNAME)
308AC_MSG_CHECKING(--with-view-name argument)
309AC_ARG_WITH(view-name, [ --with-view-name=NAME what to call the View executable],
310 VIEWNAME="$withval"; AC_MSG_RESULT($VIEWNAME),
311 VIEWNAME="view"; AC_MSG_RESULT(Defaulting to view))
312AC_SUBST(VIEWNAME)
313
314AC_MSG_CHECKING(--with-global-runtime argument)
315AC_ARG_WITH(global-runtime, [ --with-global-runtime=DIR global runtime directory in 'runtimepath'],
316 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL, "$withval"),
317 AC_MSG_RESULT(no))
318
319AC_MSG_CHECKING(--with-modified-by argument)
320AC_ARG_WITH(modified-by, [ --with-modified-by=NAME name of who modified a release version],
321 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(MODIFIED_BY, "$withval"),
322 AC_MSG_RESULT(no))
323
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200324dnl Check for EBCDIC stolen from the LYNX port to z/OS Unix
Bram Moolenaar071d4272004-06-13 20:20:40 +0000325AC_MSG_CHECKING(if character set is EBCDIC)
326AC_TRY_COMPILE([ ],
327[ /* TryCompile function for CharSet.
328 Treat any failure as ASCII for compatibility with existing art.
329 Use compile-time rather than run-time tests for cross-compiler
330 tolerance. */
331#if '0'!=240
332make an error "Character set is not EBCDIC"
333#endif ],
334[ # TryCompile action if true
335cf_cv_ebcdic=yes ],
336[ # TryCompile action if false
337cf_cv_ebcdic=no])
338# end of TryCompile ])
339# end of CacheVal CvEbcdic
340AC_MSG_RESULT($cf_cv_ebcdic)
341case "$cf_cv_ebcdic" in #(vi
342 yes) AC_DEFINE(EBCDIC)
343 line_break='"\\n"'
344 ;;
345 *) line_break='"\\012"';;
346esac
347AC_SUBST(line_break)
348
349if test "$cf_cv_ebcdic" = "yes"; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +0200350dnl If we have EBCDIC we most likely have z/OS Unix, let's test it!
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200351AC_MSG_CHECKING(for z/OS Unix)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000352case `uname` in
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200353 OS/390) zOSUnix="yes";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000354 dnl If using cc the environment variable _CC_CCMODE must be
355 dnl set to "1", so that some compiler extensions are enabled.
356 dnl If using c89 the environment variable is named _CC_C89MODE.
357 dnl Note: compile with c89 never tested.
358 if test "$CC" = "cc"; then
359 ccm="$_CC_CCMODE"
360 ccn="CC"
361 else
362 if test "$CC" = "c89"; then
363 ccm="$_CC_C89MODE"
364 ccn="C89"
365 else
366 ccm=1
367 fi
368 fi
369 if test "$ccm" != "1"; then
370 echo ""
371 echo "------------------------------------------"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200372 echo " On z/OS Unix, the environment variable"
Bram Moolenaar77c19352012-06-13 19:19:41 +0200373 echo " _CC_${ccn}MODE must be set to \"1\"!"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000374 echo " Do:"
375 echo " export _CC_${ccn}MODE=1"
376 echo " and then call configure again."
377 echo "------------------------------------------"
378 exit 1
379 fi
Bram Moolenaar77c19352012-06-13 19:19:41 +0200380 # Set CFLAGS for configure process.
381 # This will be reset later for config.mk.
382 # Use haltonmsg to force error for missing H files.
383 CFLAGS="$CFLAGS -D_ALL_SOURCE -Wc,float(ieee),haltonmsg(3296)";
384 LDFLAGS="$LDFLAGS -Wl,EDIT=NO"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000385 AC_MSG_RESULT(yes)
386 ;;
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200387 *) zOSUnix="no";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000388 AC_MSG_RESULT(no)
389 ;;
390esac
391fi
392
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200393dnl Set QUOTESED. Needs additional backslashes on zOS
394if test "$zOSUnix" = "yes"; then
395 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\\\\\&/g' -e 's/\\\\\\\\\"/\"/' -e 's/\\\\\\\\\";\$\$/\";/'"
396else
397 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\&/g' -e 's/\\\\\"/\"/' -e 's/\\\\\";\$\$/\";/'"
398fi
399AC_SUBST(QUOTESED)
400
401
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200402dnl Link with -lsmack for Smack stuff; if not found
403AC_MSG_CHECKING(--disable-smack argument)
404AC_ARG_ENABLE(smack,
405 [ --disable-smack Do not check for Smack support.],
406 , enable_smack="yes")
407if test "$enable_smack" = "yes"; then
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200408 AC_MSG_RESULT(no)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200409 AC_CHECK_HEADER([linux/xattr.h], true, enable_smack="no")
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200410else
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200411 AC_MSG_RESULT(yes)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200412fi
413if test "$enable_smack" = "yes"; then
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200414 AC_CHECK_HEADER([attr/xattr.h], true, enable_smack="no")
415fi
416if test "$enable_smack" = "yes"; then
417 AC_MSG_CHECKING(for XATTR_NAME_SMACKEXEC in linux/xattr.h)
418 AC_EGREP_CPP(XATTR_NAME_SMACKEXEC, [#include <linux/xattr.h>],
419 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +0200420 AC_MSG_RESULT(no); enable_smack="no")
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200421fi
422if test "$enable_smack" = "yes"; then
423 AC_CHECK_LIB(attr, setxattr,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200424 [LIBS="$LIBS -lattr"
425 found_smack="yes"
426 AC_DEFINE(HAVE_SMACK)])
Bram Moolenaar588ebeb2008-05-07 17:09:24 +0000427fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000428
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200429dnl When smack was found don't search for SELinux
430if test "x$found_smack" = "x"; then
431 dnl Link with -lselinux for SELinux stuff; if not found
432 AC_MSG_CHECKING(--disable-selinux argument)
433 AC_ARG_ENABLE(selinux,
434 [ --disable-selinux Do not check for SELinux support.],
435 , enable_selinux="yes")
436 if test "$enable_selinux" = "yes"; then
437 AC_MSG_RESULT(no)
438 AC_CHECK_LIB(selinux, is_selinux_enabled,
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100439 [AC_CHECK_HEADER(selinux/selinux.h,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200440 [LIBS="$LIBS -lselinux"
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100441 AC_DEFINE(HAVE_SELINUX)])])
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200442 else
443 AC_MSG_RESULT(yes)
444 fi
445fi
446
Bram Moolenaar071d4272004-06-13 20:20:40 +0000447dnl Check user requested features.
448
449AC_MSG_CHECKING(--with-features argument)
Bram Moolenaareec29812016-07-26 21:27:36 +0200450AC_ARG_WITH(features, [ --with-features=TYPE tiny, small, normal, big or huge (default: huge)],
Bram Moolenaar071d4272004-06-13 20:20:40 +0000451 features="$withval"; AC_MSG_RESULT($features),
Bram Moolenaar23c4f712016-01-20 22:11:59 +0100452 features="huge"; AC_MSG_RESULT(Defaulting to huge))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000453
454dovimdiff=""
455dogvimdiff=""
456case "$features" in
457 tiny) AC_DEFINE(FEAT_TINY) ;;
458 small) AC_DEFINE(FEAT_SMALL) ;;
459 normal) AC_DEFINE(FEAT_NORMAL) dovimdiff="installvimdiff";
460 dogvimdiff="installgvimdiff" ;;
461 big) AC_DEFINE(FEAT_BIG) dovimdiff="installvimdiff";
462 dogvimdiff="installgvimdiff" ;;
463 huge) AC_DEFINE(FEAT_HUGE) dovimdiff="installvimdiff";
464 dogvimdiff="installgvimdiff" ;;
465 *) AC_MSG_RESULT([Sorry, $features is not supported]) ;;
466esac
467
468AC_SUBST(dovimdiff)
469AC_SUBST(dogvimdiff)
470
471AC_MSG_CHECKING(--with-compiledby argument)
472AC_ARG_WITH(compiledby, [ --with-compiledby=NAME name to show in :version message],
473 compiledby="$withval"; AC_MSG_RESULT($withval),
474 compiledby=""; AC_MSG_RESULT(no))
475AC_SUBST(compiledby)
476
477AC_MSG_CHECKING(--disable-xsmp argument)
478AC_ARG_ENABLE(xsmp,
479 [ --disable-xsmp Disable XSMP session management],
480 , enable_xsmp="yes")
481
482if test "$enable_xsmp" = "yes"; then
483 AC_MSG_RESULT(no)
484 AC_MSG_CHECKING(--disable-xsmp-interact argument)
485 AC_ARG_ENABLE(xsmp-interact,
486 [ --disable-xsmp-interact Disable XSMP interaction],
487 , enable_xsmp_interact="yes")
488 if test "$enable_xsmp_interact" = "yes"; then
489 AC_MSG_RESULT(no)
490 AC_DEFINE(USE_XSMP_INTERACT)
491 else
492 AC_MSG_RESULT(yes)
493 fi
494else
495 AC_MSG_RESULT(yes)
496fi
497
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200498dnl Check for Lua feature.
499AC_MSG_CHECKING(--enable-luainterp argument)
500AC_ARG_ENABLE(luainterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200501 [ --enable-luainterp[=OPTS] Include Lua interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200502 [enable_luainterp="no"])
503AC_MSG_RESULT($enable_luainterp)
504
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200505if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +0100506 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
507 AC_MSG_ERROR([cannot use Lua with tiny or small features])
508 fi
509
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200510 dnl -- find the lua executable
511 AC_SUBST(vi_cv_path_lua)
512
513 AC_MSG_CHECKING(--with-lua-prefix argument)
514 AC_ARG_WITH(lua_prefix,
515 [ --with-lua-prefix=PFX Prefix where Lua is installed.],
516 with_lua_prefix="$withval"; AC_MSG_RESULT($with_lua_prefix),
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200517 with_lua_prefix="";AC_MSG_RESULT(no))
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200518
519 if test "X$with_lua_prefix" != "X"; then
520 vi_cv_path_lua_pfx="$with_lua_prefix"
521 else
522 AC_MSG_CHECKING(LUA_PREFIX environment var)
523 if test "X$LUA_PREFIX" != "X"; then
524 AC_MSG_RESULT("$LUA_PREFIX")
525 vi_cv_path_lua_pfx="$LUA_PREFIX"
526 else
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200527 AC_MSG_RESULT([not set, default to /usr])
528 vi_cv_path_lua_pfx="/usr"
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200529 fi
530 fi
531
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200532 AC_MSG_CHECKING(--with-luajit)
533 AC_ARG_WITH(luajit,
534 [ --with-luajit Link with LuaJIT instead of Lua.],
535 [vi_cv_with_luajit="$withval"],
536 [vi_cv_with_luajit="no"])
537 AC_MSG_RESULT($vi_cv_with_luajit)
538
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200539 LUA_INC=
540 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200541 if test "x$vi_cv_with_luajit" != "xno"; then
542 dnl -- try to find LuaJIT executable
543 AC_PATH_PROG(vi_cv_path_luajit, luajit)
544 if test "X$vi_cv_path_luajit" != "X"; then
545 dnl -- find LuaJIT version
546 AC_CACHE_CHECK(LuaJIT version, vi_cv_version_luajit,
Bram Moolenaar49b10272013-11-21 12:17:51 +0100547 [ 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 +0200548 AC_CACHE_CHECK(Lua version of LuaJIT, vi_cv_version_lua_luajit,
549 [ vi_cv_version_lua_luajit=`${vi_cv_path_luajit} -e "print(_VERSION)" | sed 's/.* //'` ])
550 vi_cv_path_lua="$vi_cv_path_luajit"
551 vi_cv_version_lua="$vi_cv_version_lua_luajit"
552 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200553 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200554 dnl -- try to find Lua executable
555 AC_PATH_PROG(vi_cv_path_plain_lua, lua)
556 if test "X$vi_cv_path_plain_lua" != "X"; then
557 dnl -- find Lua version
558 AC_CACHE_CHECK(Lua version, vi_cv_version_plain_lua,
559 [ vi_cv_version_plain_lua=`${vi_cv_path_plain_lua} -e "print(_VERSION)" | sed 's/.* //'` ])
560 fi
561 vi_cv_path_lua="$vi_cv_path_plain_lua"
562 vi_cv_version_lua="$vi_cv_version_plain_lua"
563 fi
564 if test "x$vi_cv_with_luajit" != "xno" && test "X$vi_cv_version_luajit" != "X"; then
565 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 +0100566 if test -f "$vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200567 AC_MSG_RESULT(yes)
568 LUA_INC=/luajit-$vi_cv_version_luajit
569 fi
570 fi
571 if test "X$LUA_INC" = "X"; then
572 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)
Bram Moolenaar49222be2015-12-11 18:11:30 +0100573 if test -f "$vi_cv_path_lua_pfx/include/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200574 AC_MSG_RESULT(yes)
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200575 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200576 AC_MSG_RESULT(no)
577 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 +0100578 if test -f "$vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200579 AC_MSG_RESULT(yes)
580 LUA_INC=/lua$vi_cv_version_lua
581 else
582 AC_MSG_RESULT(no)
583 vi_cv_path_lua_pfx=
584 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200585 fi
586 fi
587 fi
588
589 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200590 if test "x$vi_cv_with_luajit" != "xno"; then
591 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
592 if test "X$multiarch" != "X"; then
593 lib_multiarch="lib/${multiarch}"
594 else
595 lib_multiarch="lib"
596 fi
597 if test "X$vi_cv_version_lua" = "X"; then
598 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit"
599 else
600 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit-$vi_cv_version_lua"
601 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200602 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200603 if test "X$LUA_INC" != "X"; then
604 dnl Test alternate location using version
605 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua$vi_cv_version_lua"
606 else
607 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua"
608 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200609 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200610 if test "$enable_luainterp" = "dynamic"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200611 lua_ok="yes"
612 else
613 AC_MSG_CHECKING([if link with ${LUA_LIBS} is sane])
614 libs_save=$LIBS
615 LIBS="$LIBS $LUA_LIBS"
616 AC_TRY_LINK(,[ ],
617 AC_MSG_RESULT(yes); lua_ok="yes",
618 AC_MSG_RESULT(no); lua_ok="no"; LUA_LIBS="")
619 LIBS=$libs_save
620 fi
621 if test "x$lua_ok" = "xyes"; then
622 LUA_CFLAGS="-I${vi_cv_path_lua_pfx}/include${LUA_INC}"
623 LUA_SRC="if_lua.c"
624 LUA_OBJ="objects/if_lua.o"
625 LUA_PRO="if_lua.pro"
626 AC_DEFINE(FEAT_LUA)
627 fi
628 if test "$enable_luainterp" = "dynamic"; then
629 if test "x$vi_cv_with_luajit" != "xno"; then
630 luajit="jit"
631 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200632 if test -f "${vi_cv_path_lua_pfx}/bin/cyglua-${vi_cv_version_lua}.dll"; then
633 vi_cv_dll_name_lua="cyglua-${vi_cv_version_lua}.dll"
634 else
Bram Moolenaard0573012017-10-28 21:11:06 +0200635 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200636 ext="dylib"
637 indexes=""
638 else
639 ext="so"
640 indexes=".0 .1 .2 .3 .4 .5 .6 .7 .8 .9"
641 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
642 if test "X$multiarch" != "X"; then
643 lib_multiarch="lib/${multiarch}"
644 fi
Bram Moolenaar768baac2013-04-15 14:44:57 +0200645 fi
646 dnl Determine the sover for the current version, but fallback to
647 dnl liblua${vi_cv_version_lua}.so if no sover-versioned file is found.
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200648 AC_MSG_CHECKING(if liblua${luajit}*.${ext}* can be found in $vi_cv_path_lua_pfx)
Bram Moolenaar768baac2013-04-15 14:44:57 +0200649 for subdir in "${lib_multiarch}" lib64 lib; do
650 if test -z "$subdir"; then
651 continue
652 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200653 for sover in "${vi_cv_version_lua}.${ext}" "-${vi_cv_version_lua}.${ext}" \
654 ".${vi_cv_version_lua}.${ext}" ".${ext}.${vi_cv_version_lua}"; do
655 for i in $indexes ""; do
656 if test -f "${vi_cv_path_lua_pfx}/${subdir}/liblua${luajit}${sover}$i"; then
Bram Moolenaar768baac2013-04-15 14:44:57 +0200657 sover2="$i"
658 break 3
659 fi
660 done
Bram Moolenaar07e1da62013-02-06 19:49:43 +0100661 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200662 sover=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200663 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200664 if test "X$sover" = "X"; then
665 AC_MSG_RESULT(no)
666 lua_ok="no"
667 vi_cv_dll_name_lua="liblua${luajit}.${ext}"
668 else
669 AC_MSG_RESULT(yes)
670 lua_ok="yes"
671 vi_cv_dll_name_lua="liblua${luajit}${sover}$sover2"
672 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200673 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200674 AC_DEFINE(DYNAMIC_LUA)
675 LUA_LIBS=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200676 LUA_CFLAGS="-DDYNAMIC_LUA_DLL=\\\"${vi_cv_dll_name_lua}\\\" $LUA_CFLAGS"
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200677 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200678 if test "X$LUA_CFLAGS$LUA_LIBS" != "X" && \
Bram Moolenaard0573012017-10-28 21:11:06 +0200679 test "x$MACOS_X" = "xyes" && test "x$vi_cv_with_luajit" != "xno" && \
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200680 test "`(uname -m) 2>/dev/null`" = "x86_64"; then
681 dnl OSX/x64 requires these flags. See http://luajit.org/install.html
682 LUA_LIBS="-pagezero_size 10000 -image_base 100000000 $LUA_LIBS"
683 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200684 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200685 if test "$fail_if_missing" = "yes" -a "$lua_ok" != "yes"; then
Bram Moolenaarf788a062011-12-14 20:51:25 +0100686 AC_MSG_ERROR([could not configure lua])
687 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200688 AC_SUBST(LUA_SRC)
689 AC_SUBST(LUA_OBJ)
690 AC_SUBST(LUA_PRO)
691 AC_SUBST(LUA_LIBS)
692 AC_SUBST(LUA_CFLAGS)
693fi
694
695
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000696dnl Check for MzScheme feature.
697AC_MSG_CHECKING(--enable-mzschemeinterp argument)
698AC_ARG_ENABLE(mzschemeinterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200699 [ --enable-mzschemeinterp Include MzScheme interpreter.], ,
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000700 [enable_mzschemeinterp="no"])
701AC_MSG_RESULT($enable_mzschemeinterp)
702
703if test "$enable_mzschemeinterp" = "yes"; then
704 dnl -- find the mzscheme executable
705 AC_SUBST(vi_cv_path_mzscheme)
706
707 AC_MSG_CHECKING(--with-plthome argument)
708 AC_ARG_WITH(plthome,
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000709 [ --with-plthome=PLTHOME Use PLTHOME.],
710 with_plthome="$withval"; AC_MSG_RESULT($with_plthome),
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000711 with_plthome="";AC_MSG_RESULT("no"))
712
713 if test "X$with_plthome" != "X"; then
714 vi_cv_path_mzscheme_pfx="$with_plthome"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100715 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000716 else
717 AC_MSG_CHECKING(PLTHOME environment var)
718 if test "X$PLTHOME" != "X"; then
719 AC_MSG_RESULT("$PLTHOME")
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000720 vi_cv_path_mzscheme_pfx="$PLTHOME"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100721 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000722 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000723 AC_MSG_RESULT(not set)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000724 dnl -- try to find MzScheme executable
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000725 AC_PATH_PROG(vi_cv_path_mzscheme, mzscheme)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000726
727 dnl resolve symbolic link, the executable is often elsewhere and there
728 dnl are no links for the include files.
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000729 if test "X$vi_cv_path_mzscheme" != "X"; then
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000730 lsout=`ls -l $vi_cv_path_mzscheme`
731 if echo "$lsout" | grep -e '->' >/dev/null 2>/dev/null; then
732 vi_cv_path_mzscheme=`echo "$lsout" | sed 's/.*-> \(.*\)/\1/'`
733 fi
734 fi
735
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000736 if test "X$vi_cv_path_mzscheme" != "X"; then
737 dnl -- find where MzScheme thinks it was installed
738 AC_CACHE_CHECK(MzScheme install prefix,vi_cv_path_mzscheme_pfx,
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000739 dnl different versions of MzScheme differ in command line processing
740 dnl use universal approach
741 echo "(display (simplify-path \
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000742 (build-path (call-with-values \
743 (lambda () (split-path (find-system-path (quote exec-file)))) \
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000744 (lambda (base name must-be-dir?) base)) (quote up))))" > mzdirs.scm
745 dnl Remove a trailing slash
746 [ vi_cv_path_mzscheme_pfx=`${vi_cv_path_mzscheme} -r mzdirs.scm | \
747 sed -e 's+/$++'` ])
748 rm -f mzdirs.scm
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000749 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000750 fi
751 fi
752
753 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100754 AC_MSG_CHECKING(for racket include directory)
755 SCHEME_INC=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-include-dir))) (when (path? p) (display p)))'`
756 if test "X$SCHEME_INC" != "X"; then
757 AC_MSG_RESULT(${SCHEME_INC})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000758 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100759 AC_MSG_RESULT(not found)
760 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include)
761 if test -f "$vi_cv_path_mzscheme_pfx/include/scheme.h"; then
762 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000763 AC_MSG_RESULT(yes)
Bram Moolenaard7afed32007-05-06 13:26:41 +0000764 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000765 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100766 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt)
767 if test -f "$vi_cv_path_mzscheme_pfx/include/plt/scheme.h"; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000768 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100769 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000770 else
771 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100772 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket)
773 if test -f "$vi_cv_path_mzscheme_pfx/include/racket/scheme.h"; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100774 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100775 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100776 else
777 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100778 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/)
779 if test -f /usr/include/plt/scheme.h; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100780 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100781 SCHEME_INC=/usr/include/plt
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100782 else
783 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100784 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/racket/)
785 if test -f /usr/include/racket/scheme.h; then
786 AC_MSG_RESULT(yes)
787 SCHEME_INC=/usr/include/racket
788 else
789 AC_MSG_RESULT(no)
790 vi_cv_path_mzscheme_pfx=
791 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100792 fi
793 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000794 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000795 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000796 fi
797 fi
798
799 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100800
801 AC_MSG_CHECKING(for racket lib directory)
802 SCHEME_LIB=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-lib-dir))) (when (path? p) (display p)))'`
803 if test "X$SCHEME_LIB" != "X"; then
804 AC_MSG_RESULT(${SCHEME_LIB})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000805 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100806 AC_MSG_RESULT(not found)
807 fi
808
809 for path in "${vi_cv_path_mzscheme_pfx}/lib" "${SCHEME_LIB}"; do
810 if test "X$path" != "X"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200811 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100812 MZSCHEME_LIBS="-framework Racket"
813 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
814 elif test -f "${path}/libmzscheme3m.a"; then
815 MZSCHEME_LIBS="${path}/libmzscheme3m.a"
816 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
817 elif test -f "${path}/libracket3m.a"; then
818 MZSCHEME_LIBS="${path}/libracket3m.a"
819 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
820 elif test -f "${path}/libracket.a"; then
821 MZSCHEME_LIBS="${path}/libracket.a ${path}/libmzgc.a"
822 elif test -f "${path}/libmzscheme.a"; then
823 MZSCHEME_LIBS="${path}/libmzscheme.a ${path}/libmzgc.a"
824 else
825 dnl Using shared objects
826 if test -f "${path}/libmzscheme3m.so"; then
827 MZSCHEME_LIBS="-L${path} -lmzscheme3m"
828 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
829 elif test -f "${path}/libracket3m.so"; then
830 MZSCHEME_LIBS="-L${path} -lracket3m"
831 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
832 elif test -f "${path}/libracket.so"; then
833 MZSCHEME_LIBS="-L${path} -lracket -lmzgc"
834 else
835 dnl try next until last
836 if test "$path" != "$SCHEME_LIB"; then
837 continue
838 fi
839 MZSCHEME_LIBS="-L${path} -lmzscheme -lmzgc"
840 fi
841 if test "$GCC" = yes; then
842 dnl Make Vim remember the path to the library. For when it's not in
843 dnl $LD_LIBRARY_PATH.
844 MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${path}"
845 elif test "`(uname) 2>/dev/null`" = SunOS &&
846 uname -r | grep '^5' >/dev/null; then
847 MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${path}"
848 fi
849 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000850 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100851 if test "X$MZSCHEME_LIBS" != "X"; then
852 break
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +0000853 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100854 done
855
856 AC_MSG_CHECKING([if racket requires -pthread])
857 if test "X$SCHEME_LIB" != "X" && $FGREP -e -pthread "$SCHEME_LIB/buildinfo" >/dev/null ; then
858 AC_MSG_RESULT(yes)
859 MZSCHEME_LIBS="${MZSCHEME_LIBS} -pthread"
860 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -pthread"
861 else
862 AC_MSG_RESULT(no)
863 fi
864
865 AC_MSG_CHECKING(for racket config directory)
866 SCHEME_CONFIGDIR=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-config-dir))) (when (path? p) (display p)))'`
867 if test "X$SCHEME_CONFIGDIR" != "X"; then
868 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DMZSCHEME_CONFIGDIR='\"${SCHEME_CONFIGDIR}\"'"
869 AC_MSG_RESULT(${SCHEME_CONFIGDIR})
870 else
871 AC_MSG_RESULT(not found)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000872 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100873
874 AC_MSG_CHECKING(for racket collects directory)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100875 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))))'`
876 if test "X$SCHEME_COLLECTS" = "X"; then
877 if test -d "$vi_cv_path_mzscheme_pfx/lib/plt/collects"; then
878 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/plt/
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100879 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100880 if test -d "$vi_cv_path_mzscheme_pfx/lib/racket/collects"; then
881 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/racket/
Bram Moolenaar75676462013-01-30 14:55:42 +0100882 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100883 if test -d "$vi_cv_path_mzscheme_pfx/share/racket/collects"; then
884 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/
885 else
886 if test -d "$vi_cv_path_mzscheme_pfx/collects"; then
887 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/
888 fi
Bram Moolenaar75676462013-01-30 14:55:42 +0100889 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100890 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100891 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000892 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100893 if test "X$SCHEME_COLLECTS" != "X" ; then
894 AC_MSG_RESULT(${SCHEME_COLLECTS})
895 else
896 AC_MSG_RESULT(not found)
897 fi
898
899 AC_MSG_CHECKING(for mzscheme_base.c)
900 if test -f "${SCHEME_COLLECTS}collects/scheme/base.ss" ; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000901 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +0100902 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
903 MZSCHEME_MOD="++lib scheme/base"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100904 else
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100905 if test -f "${SCHEME_COLLECTS}collects/scheme/base.rkt" ; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100906 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +0100907 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
908 MZSCHEME_MOD="++lib scheme/base"
909 else
910 if test -f "${SCHEME_COLLECTS}collects/racket/base.rkt" ; then
911 MZSCHEME_EXTRA="mzscheme_base.c"
912 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/raco ctool"
913 MZSCHEME_MOD=""
914 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100915 fi
916 fi
917 if test "X$MZSCHEME_EXTRA" != "X" ; then
918 dnl need to generate bytecode for MzScheme base
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000919 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE"
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100920 AC_MSG_RESULT(needed)
921 else
922 AC_MSG_RESULT(not needed)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000923 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100924
Bram Moolenaar9e902192013-07-17 18:58:11 +0200925 dnl On Ubuntu this fixes "undefined reference to symbol 'ffi_type_void'".
926 AC_CHECK_LIB(ffi, ffi_type_void, [MZSCHEME_LIBS="$MZSCHEME_LIBS -lffi"])
927
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000928 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -I${SCHEME_INC} \
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100929 -DMZSCHEME_COLLECTS='\"${SCHEME_COLLECTS}collects\"'"
Bram Moolenaar9e902192013-07-17 18:58:11 +0200930
931 dnl Test that we can compile a simple program with these CFLAGS and LIBS.
932 AC_MSG_CHECKING([if compile and link flags for MzScheme are sane])
933 cflags_save=$CFLAGS
934 libs_save=$LIBS
935 CFLAGS="$CFLAGS $MZSCHEME_CFLAGS"
936 LIBS="$LIBS $MZSCHEME_LIBS"
937 AC_TRY_LINK(,[ ],
938 AC_MSG_RESULT(yes); mzs_ok=yes,
939 AC_MSG_RESULT(no: MZSCHEME DISABLED); mzs_ok=no)
940 CFLAGS=$cflags_save
941 LIBS=$libs_save
942 if test $mzs_ok = yes; then
943 MZSCHEME_SRC="if_mzsch.c"
944 MZSCHEME_OBJ="objects/if_mzsch.o"
945 MZSCHEME_PRO="if_mzsch.pro"
946 AC_DEFINE(FEAT_MZSCHEME)
947 else
948 MZSCHEME_CFLAGS=
949 MZSCHEME_LIBS=
950 MZSCHEME_EXTRA=
951 MZSCHEME_MZC=
952 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000953 fi
954 AC_SUBST(MZSCHEME_SRC)
955 AC_SUBST(MZSCHEME_OBJ)
956 AC_SUBST(MZSCHEME_PRO)
957 AC_SUBST(MZSCHEME_LIBS)
958 AC_SUBST(MZSCHEME_CFLAGS)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000959 AC_SUBST(MZSCHEME_EXTRA)
960 AC_SUBST(MZSCHEME_MZC)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000961fi
962
963
Bram Moolenaar071d4272004-06-13 20:20:40 +0000964AC_MSG_CHECKING(--enable-perlinterp argument)
965AC_ARG_ENABLE(perlinterp,
Bram Moolenaare06c1882010-07-21 22:05:20 +0200966 [ --enable-perlinterp[=OPTS] Include Perl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000967 [enable_perlinterp="no"])
968AC_MSG_RESULT($enable_perlinterp)
Bram Moolenaare06c1882010-07-21 22:05:20 +0200969if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +0100970 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
971 AC_MSG_ERROR([cannot use Perl with tiny or small features])
972 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000973 AC_SUBST(vi_cv_path_perl)
974 AC_PATH_PROG(vi_cv_path_perl, perl)
975 if test "X$vi_cv_path_perl" != "X"; then
976 AC_MSG_CHECKING(Perl version)
977 if $vi_cv_path_perl -e 'require 5.003_01' >/dev/null 2>/dev/null; then
978 eval `$vi_cv_path_perl -V:usethreads`
Bram Moolenaare06c1882010-07-21 22:05:20 +0200979 eval `$vi_cv_path_perl -V:libperl`
Bram Moolenaar071d4272004-06-13 20:20:40 +0000980 if test "X$usethreads" = "XUNKNOWN" -o "X$usethreads" = "Xundef"; then
981 badthreads=no
982 else
983 if $vi_cv_path_perl -e 'require 5.6.0' >/dev/null 2>/dev/null; then
984 eval `$vi_cv_path_perl -V:use5005threads`
985 if test "X$use5005threads" = "XUNKNOWN" -o "X$use5005threads" = "Xundef"; then
986 badthreads=no
987 else
988 badthreads=yes
989 AC_MSG_RESULT(>>> Perl > 5.6 with 5.5 threads cannot be used <<<)
990 fi
991 else
992 badthreads=yes
993 AC_MSG_RESULT(>>> Perl 5.5 with threads cannot be used <<<)
994 fi
995 fi
996 if test $badthreads = no; then
997 AC_MSG_RESULT(OK)
998 eval `$vi_cv_path_perl -V:shrpenv`
999 if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04
1000 shrpenv=""
1001 fi
1002 vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlibexp}'`
1003 AC_SUBST(vi_cv_perllib)
Bram Moolenaard5f62b12014-08-17 17:05:44 +02001004 vi_cv_perl_extutils=unknown_perl_extutils_path
1005 for extutils_rel_path in ExtUtils vendor_perl/ExtUtils; do
1006 xsubpp_path="$vi_cv_perllib/$extutils_rel_path/xsubpp"
1007 if test -f "$xsubpp_path"; then
1008 vi_cv_perl_xsubpp="$xsubpp_path"
1009 fi
1010 done
1011 AC_SUBST(vi_cv_perl_xsubpp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001012 dnl Remove "-fno-something", it breaks using cproto.
Bram Moolenaar280a8682015-06-21 13:41:08 +02001013 dnl Remove "-fdebug-prefix-map", it isn't supported by clang.
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001014 dnl Remove "FORTIFY_SOURCE", it will be defined twice.
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001015 dnl remove -pipe and -Wxxx, it confuses cproto
Bram Moolenaar071d4272004-06-13 20:20:40 +00001016 perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001017 -e 'ccflags;perl_inc;print"\n"' | sed -e 's/-fno[[^ ]]*//' \
1018 -e 's/-fdebug-prefix-map[[^ ]]*//g' \
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001019 -e 's/-pipe //' \
1020 -e 's/-W[[^ ]]*//g' \
1021 -e 's/-D_FORTIFY_SOURCE=.//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001022 dnl Remove "-lc", it breaks on FreeBSD when using "-pthread".
1023 perllibs=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed -e 'ldopts' | \
1024 sed -e '/Warning/d' -e '/Note (probably harmless)/d' \
1025 -e 's/-bE:perl.exp//' -e 's/-lc //'`
1026 dnl Don't add perl lib to $LIBS: if it's not in LD_LIBRARY_PATH
1027 dnl a test in configure may fail because of that.
1028 perlldflags=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed \
1029 -e 'ccdlflags' | sed -e 's/-bE:perl.exp//'`
1030
1031 dnl check that compiling a simple program still works with the flags
1032 dnl added for Perl.
1033 AC_MSG_CHECKING([if compile and link flags for Perl are sane])
1034 cflags_save=$CFLAGS
1035 libs_save=$LIBS
1036 ldflags_save=$LDFLAGS
1037 CFLAGS="$CFLAGS $perlcppflags"
1038 LIBS="$LIBS $perllibs"
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001039 perlldflags=`echo "$perlldflags" | sed -e 's/^ *//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001040 LDFLAGS="$perlldflags $LDFLAGS"
1041 AC_TRY_LINK(,[ ],
1042 AC_MSG_RESULT(yes); perl_ok=yes,
1043 AC_MSG_RESULT(no: PERL DISABLED); perl_ok=no)
1044 CFLAGS=$cflags_save
1045 LIBS=$libs_save
1046 LDFLAGS=$ldflags_save
1047 if test $perl_ok = yes; then
1048 if test "X$perlcppflags" != "X"; then
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001049 PERL_CFLAGS=$perlcppflags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001050 fi
1051 if test "X$perlldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001052 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$perlldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001053 LDFLAGS="$perlldflags $LDFLAGS"
1054 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001055 fi
1056 PERL_LIBS=$perllibs
1057 PERL_SRC="auto/if_perl.c if_perlsfio.c"
1058 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o"
1059 PERL_PRO="if_perl.pro if_perlsfio.pro"
1060 AC_DEFINE(FEAT_PERL)
1061 fi
1062 fi
1063 else
1064 AC_MSG_RESULT(>>> too old; need Perl version 5.003_01 or later <<<)
1065 fi
1066 fi
1067
Bram Moolenaard0573012017-10-28 21:11:06 +02001068 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00001069 dnl Mac OS X 10.2 or later
Bram Moolenaar071d4272004-06-13 20:20:40 +00001070 dir=/System/Library/Perl
1071 darwindir=$dir/darwin
1072 if test -d $darwindir; then
1073 PERL=/usr/bin/perl
1074 else
1075 dnl Mac OS X 10.3
1076 dir=/System/Library/Perl/5.8.1
1077 darwindir=$dir/darwin-thread-multi-2level
1078 if test -d $darwindir; then
1079 PERL=/usr/bin/perl
1080 fi
1081 fi
1082 if test -n "$PERL"; then
1083 PERL_DIR="$dir"
1084 PERL_CFLAGS="-DFEAT_PERL -I$darwindir/CORE"
1085 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o $darwindir/auto/DynaLoader/DynaLoader.a"
1086 PERL_LIBS="-L$darwindir/CORE -lperl"
1087 fi
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001088 dnl Perl on Mac OS X 10.5 adds "-arch" flags but these should only
1089 dnl be included if requested by passing --with-mac-arch to
1090 dnl configure, so strip these flags first (if present)
1091 PERL_LIBS=`echo "$PERL_LIBS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
1092 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 +00001093 fi
Bram Moolenaare06c1882010-07-21 22:05:20 +02001094 if test "$enable_perlinterp" = "dynamic"; then
1095 if test "$perl_ok" = "yes" -a "X$libperl" != "X"; then
1096 AC_DEFINE(DYNAMIC_PERL)
1097 PERL_CFLAGS="-DDYNAMIC_PERL_DLL=\\\"$libperl\\\" $PERL_CFLAGS"
1098 fi
1099 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001100
1101 if test "$fail_if_missing" = "yes" -a "$perl_ok" != "yes"; then
1102 AC_MSG_ERROR([could not configure perl])
1103 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001104fi
1105AC_SUBST(shrpenv)
1106AC_SUBST(PERL_SRC)
1107AC_SUBST(PERL_OBJ)
1108AC_SUBST(PERL_PRO)
1109AC_SUBST(PERL_CFLAGS)
1110AC_SUBST(PERL_LIBS)
1111
1112AC_MSG_CHECKING(--enable-pythoninterp argument)
1113AC_ARG_ENABLE(pythoninterp,
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001114 [ --enable-pythoninterp[=OPTS] Include Python interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001115 [enable_pythoninterp="no"])
1116AC_MSG_RESULT($enable_pythoninterp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001117if test "$enable_pythoninterp" = "yes" -o "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001118 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1119 AC_MSG_ERROR([cannot use Python with tiny or small features])
1120 fi
1121
Bram Moolenaar071d4272004-06-13 20:20:40 +00001122 dnl -- find the python executable
Bram Moolenaar09ba6d72012-12-12 14:25:05 +01001123 AC_PATH_PROGS(vi_cv_path_python, python2 python)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001124 if test "X$vi_cv_path_python" != "X"; then
1125
1126 dnl -- get its version number
1127 AC_CACHE_CHECK(Python version,vi_cv_var_python_version,
1128 [[vi_cv_var_python_version=`
1129 ${vi_cv_path_python} -c 'import sys; print sys.version[:3]'`
1130 ]])
1131
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001132 dnl -- it must be at least version 2.3
1133 AC_MSG_CHECKING(Python is 2.3 or better)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001134 if ${vi_cv_path_python} -c \
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001135 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001136 then
1137 AC_MSG_RESULT(yep)
1138
1139 dnl -- find where python thinks it was installed
1140 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python_pfx,
1141 [ vi_cv_path_python_pfx=`
1142 ${vi_cv_path_python} -c \
1143 "import sys; print sys.prefix"` ])
1144
1145 dnl -- and where it thinks it runs
1146 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python_epfx,
1147 [ vi_cv_path_python_epfx=`
1148 ${vi_cv_path_python} -c \
1149 "import sys; print sys.exec_prefix"` ])
1150
1151 dnl -- python's internal library path
1152
1153 AC_CACHE_VAL(vi_cv_path_pythonpath,
1154 [ vi_cv_path_pythonpath=`
1155 unset PYTHONPATH;
1156 ${vi_cv_path_python} -c \
1157 "import sys, string; print string.join(sys.path,':')"` ])
1158
1159 dnl -- where the Python implementation library archives are
1160
1161 AC_ARG_WITH(python-config-dir,
1162 [ --with-python-config-dir=PATH Python's config directory],
Bram Moolenaard0882402018-04-10 18:13:05 +02001163 [ vi_cv_path_python_conf="${withval}"; have_python_config_dir=1 ] )
Bram Moolenaar071d4272004-06-13 20:20:40 +00001164
1165 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python_conf,
1166 [
1167 vi_cv_path_python_conf=
Bram Moolenaarac499e32013-06-02 19:14:17 +02001168 d=`${vi_cv_path_python} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBPL')"`
1169 if test -d "$d" && test -f "$d/config.c"; then
1170 vi_cv_path_python_conf="$d"
1171 else
1172 for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
1173 for subdir in lib64 lib share; do
1174 d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
1175 if test -d "$d" && test -f "$d/config.c"; then
1176 vi_cv_path_python_conf="$d"
1177 fi
1178 done
Bram Moolenaar071d4272004-06-13 20:20:40 +00001179 done
Bram Moolenaarac499e32013-06-02 19:14:17 +02001180 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001181 ])
1182
1183 PYTHON_CONFDIR="${vi_cv_path_python_conf}"
1184
1185 if test "X$PYTHON_CONFDIR" = "X"; then
1186 AC_MSG_RESULT([can't find it!])
1187 else
1188
1189 dnl -- we need to examine Python's config/Makefile too
1190 dnl see what the interpreter is built from
1191 AC_CACHE_VAL(vi_cv_path_python_plibs,
1192 [
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001193 pwd=`pwd`
1194 tmp_mkf="$pwd/config-PyMake$$"
1195 cat -- "${PYTHON_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001196__:
Bram Moolenaar218116c2010-05-20 21:46:00 +02001197 @echo "python_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001198 @echo "python_LIBS='$(LIBS)'"
1199 @echo "python_SYSLIBS='$(SYSLIBS)'"
1200 @echo "python_LINKFORSHARED='$(LINKFORSHARED)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001201 @echo "python_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001202 @echo "python_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001203 @echo "python_PYTHONFRAMEWORK='$(PYTHONFRAMEWORK)'"
1204 @echo "python_PYTHONFRAMEWORKPREFIX='$(PYTHONFRAMEWORKPREFIX)'"
1205 @echo "python_PYTHONFRAMEWORKINSTALLDIR='$(PYTHONFRAMEWORKINSTALLDIR)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001206eof
1207 dnl -- delete the lines from make about Entering/Leaving directory
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001208 eval "`cd ${PYTHON_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1209 rm -f -- "${tmp_mkf}"
Bram Moolenaard0573012017-10-28 21:11:06 +02001210 if test "x$MACOS_X" = "xyes" && test -n "${python_PYTHONFRAMEWORK}" && ${vi_cv_path_python} -c \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001211 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then
1212 vi_cv_path_python_plibs="-framework Python"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001213 if test "x${vi_cv_path_python}" != "x/usr/bin/python" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
1214 vi_cv_path_python_plibs="-F${python_PYTHONFRAMEWORKPREFIX} -framework Python"
1215 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001216 else
Bram Moolenaar9ce42132018-04-11 22:19:36 +02001217 vi_cv_path_python_plibs="-L${PYTHON_CONFDIR} -lpython${vi_cv_var_python_version}"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001218 dnl -- Check if the path contained in python_LINKFORSHARED is
1219 dnl usable for vim build. If not, make and try other
1220 dnl candidates.
Bram Moolenaara161e262015-03-24 15:14:27 +01001221 if test -n "${python_LINKFORSHARED}" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
Bram Moolenaar6c927552015-03-24 12:21:33 +01001222 python_link_symbol=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]].*/\1/'`
1223 python_link_path=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]][[ \t]]*\(.*\)/\2/'`
1224 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1225 dnl -- The path looks relative. Guess the absolute one using
1226 dnl the prefix and try that.
1227 python_link_path="${python_PYTHONFRAMEWORKPREFIX}/${python_link_path}"
1228 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1229 dnl -- A last resort.
1230 python_link_path="${python_PYTHONFRAMEWORKINSTALLDIR}/Versions/${vi_cv_var_python_version}/${python_PYTHONFRAMEWORK}"
1231 dnl -- No check is done. The last word is left to the
1232 dnl "sanity" test on link flags that follows shortly.
1233 fi
1234 python_LINKFORSHARED="${python_link_symbol} ${python_link_path}"
1235 fi
1236 fi
Bram Moolenaar218116c2010-05-20 21:46:00 +02001237 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 +00001238 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1239 vi_cv_path_python_plibs=`echo $vi_cv_path_python_plibs | sed s/-ltermcap//`
1240 fi
1241 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001242 AC_CACHE_CHECK(Python's dll name,vi_cv_dll_name_python,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001243 [
1244 if test "X$python_DLLLIBRARY" != "X"; then
1245 vi_cv_dll_name_python="$python_DLLLIBRARY"
1246 else
1247 vi_cv_dll_name_python="$python_INSTSONAME"
1248 fi
1249 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00001250
1251 PYTHON_LIBS="${vi_cv_path_python_plibs}"
1252 if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001253 PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001254 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001255 PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -I${vi_cv_path_python_epfx}/include/python${vi_cv_var_python_version}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001256 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001257 if test "X$have_python_config_dir" = "X1" -a "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001258 dnl Define PYTHON_HOME if --with-python-config-dir was used
1259 PYTHON_CFLAGS="${PYTHON_CFLAGS} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'"
1260
1261 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001262 PYTHON_SRC="if_python.c"
Bram Moolenaar9bdb9a02012-07-25 16:32:08 +02001263 PYTHON_OBJ="objects/if_python.o"
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_LIBS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001333AC_SUBST(PYTHON_CFLAGS)
1334AC_SUBST(PYTHON_SRC)
1335AC_SUBST(PYTHON_OBJ)
1336
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001337
1338AC_MSG_CHECKING(--enable-python3interp argument)
1339AC_ARG_ENABLE(python3interp,
Bram Moolenaar8008b632017-07-18 21:33:20 +02001340 [ --enable-python3interp[=OPTS] Include Python3 interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001341 [enable_python3interp="no"])
1342AC_MSG_RESULT($enable_python3interp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001343if test "$enable_python3interp" = "yes" -o "$enable_python3interp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001344 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1345 AC_MSG_ERROR([cannot use Python with tiny or small features])
1346 fi
1347
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001348 dnl -- find the python3 executable
Bram Moolenaar09ba6d72012-12-12 14:25:05 +01001349 AC_PATH_PROGS(vi_cv_path_python3, python3 python)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001350 if test "X$vi_cv_path_python3" != "X"; then
1351
1352 dnl -- get its version number
1353 AC_CACHE_CHECK(Python version,vi_cv_var_python3_version,
1354 [[vi_cv_var_python3_version=`
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001355 ${vi_cv_path_python3} -c 'import sys; print(sys.version[:3])'`
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001356 ]])
1357
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001358 dnl -- it must be at least version 3
1359 AC_MSG_CHECKING(Python is 3.0 or better)
1360 if ${vi_cv_path_python3} -c \
1361 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.0)"
1362 then
1363 AC_MSG_RESULT(yep)
Bram Moolenaar456f2bb2011-06-12 21:37:13 +02001364
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001365 dnl -- get abiflags for python 3.2 or higher (PEP 3149)
1366 AC_CACHE_CHECK(Python's abiflags,vi_cv_var_python3_abiflags,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001367 [
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001368 vi_cv_var_python3_abiflags=
1369 if ${vi_cv_path_python3} -c \
1370 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)"
1371 then
1372 vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \
1373 "import sys; print(sys.abiflags)"`
1374 fi ])
1375
1376 dnl -- find where python3 thinks it was installed
1377 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx,
1378 [ vi_cv_path_python3_pfx=`
1379 ${vi_cv_path_python3} -c \
1380 "import sys; print(sys.prefix)"` ])
1381
1382 dnl -- and where it thinks it runs
1383 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx,
1384 [ vi_cv_path_python3_epfx=`
1385 ${vi_cv_path_python3} -c \
1386 "import sys; print(sys.exec_prefix)"` ])
1387
1388 dnl -- python3's internal library path
1389
1390 AC_CACHE_VAL(vi_cv_path_python3path,
1391 [ vi_cv_path_python3path=`
1392 unset PYTHONPATH;
1393 ${vi_cv_path_python3} -c \
1394 "import sys, string; print(':'.join(sys.path))"` ])
1395
1396 dnl -- where the Python implementation library archives are
1397
1398 AC_ARG_WITH(python3-config-dir,
1399 [ --with-python3-config-dir=PATH Python's config directory],
Bram Moolenaard0882402018-04-10 18:13:05 +02001400 [ vi_cv_path_python3_conf="${withval}"; have_python3_config_dir=1 ] )
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001401
1402 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf,
1403 [
1404 vi_cv_path_python3_conf=
Bram Moolenaarfee496d2013-07-12 20:07:24 +02001405 config_dir="config-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001406 d=`${vi_cv_path_python3} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBPL'))"`
1407 if test -d "$d" && test -f "$d/config.c"; then
1408 vi_cv_path_python3_conf="$d"
1409 else
1410 for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do
1411 for subdir in lib64 lib share; do
1412 d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}"
1413 if test -d "$d" && test -f "$d/config.c"; then
1414 vi_cv_path_python3_conf="$d"
1415 fi
1416 done
1417 done
1418 fi
1419 ])
1420
1421 PYTHON3_CONFDIR="${vi_cv_path_python3_conf}"
1422
1423 if test "X$PYTHON3_CONFDIR" = "X"; then
1424 AC_MSG_RESULT([can't find it!])
1425 else
1426
1427 dnl -- we need to examine Python's config/Makefile too
1428 dnl see what the interpreter is built from
1429 AC_CACHE_VAL(vi_cv_path_python3_plibs,
1430 [
1431 pwd=`pwd`
1432 tmp_mkf="$pwd/config-PyMake$$"
1433 cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001434__:
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001435 @echo "python3_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001436 @echo "python3_LIBS='$(LIBS)'"
1437 @echo "python3_SYSLIBS='$(SYSLIBS)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001438 @echo "python3_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001439 @echo "python3_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001440eof
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001441 dnl -- delete the lines from make about Entering/Leaving directory
1442 eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1443 rm -f -- "${tmp_mkf}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001444 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 +02001445 vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}"
1446 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1447 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//`
1448 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//`
1449 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001450 AC_CACHE_CHECK(Python3's dll name,vi_cv_dll_name_python3,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001451 [
1452 if test "X$python3_DLLLIBRARY" != "X"; then
1453 vi_cv_dll_name_python3="$python3_DLLLIBRARY"
1454 else
1455 vi_cv_dll_name_python3="$python3_INSTSONAME"
1456 fi
1457 ])
1458
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001459 PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
1460 if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001461 PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001462 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001463 PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -I${vi_cv_path_python3_epfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001464 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001465 if test "X$have_python3_config_dir" = "X1" -a "$enable_python3interp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001466 dnl Define PYTHON3_HOME if --with-python-config-dir was used
1467 PYTHON3_CFLAGS="${PYTHON3_CFLAGS} -DPYTHON3_HOME='L\"${vi_cv_path_python3_pfx}\"'"
1468 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001469 PYTHON3_SRC="if_python3.c"
1470 PYTHON3_OBJ="objects/if_python3.o"
1471
1472 dnl On FreeBSD linking with "-pthread" is required to use threads.
1473 dnl _THREAD_SAFE must be used for compiling then.
1474 dnl The "-pthread" is added to $LIBS, so that the following check for
1475 dnl sigaltstack() will look in libc_r (it's there in libc!).
1476 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1477 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1478 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1479 AC_MSG_CHECKING([if -pthread should be used])
1480 threadsafe_flag=
1481 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001482 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001483 if test "`(uname) 2>/dev/null`" != Darwin; then
1484 test "$GCC" = yes && threadsafe_flag="-pthread"
1485 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1486 threadsafe_flag="-D_THREAD_SAFE"
1487 thread_lib="-pthread"
1488 fi
1489 if test "`(uname) 2>/dev/null`" = SunOS; then
1490 threadsafe_flag="-pthreads"
1491 fi
1492 fi
1493 libs_save_old=$LIBS
1494 if test -n "$threadsafe_flag"; then
1495 cflags_save=$CFLAGS
1496 CFLAGS="$CFLAGS $threadsafe_flag"
1497 LIBS="$LIBS $thread_lib"
1498 AC_TRY_LINK(,[ ],
1499 AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag",
1500 AC_MSG_RESULT(no); LIBS=$libs_save_old
1501 )
1502 CFLAGS=$cflags_save
1503 else
1504 AC_MSG_RESULT(no)
1505 fi
1506
1507 dnl check that compiling a simple program still works with the flags
1508 dnl added for Python.
1509 AC_MSG_CHECKING([if compile and link flags for Python 3 are sane])
1510 cflags_save=$CFLAGS
1511 libs_save=$LIBS
1512 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1513 LIBS="$LIBS $PYTHON3_LIBS"
1514 AC_TRY_LINK(,[ ],
1515 AC_MSG_RESULT(yes); python3_ok=yes,
1516 AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no)
1517 CFLAGS=$cflags_save
1518 LIBS=$libs_save
1519 if test "$python3_ok" = yes; then
1520 AC_DEFINE(FEAT_PYTHON3)
1521 else
1522 LIBS=$libs_save_old
1523 PYTHON3_SRC=
1524 PYTHON3_OBJ=
1525 PYTHON3_LIBS=
1526 PYTHON3_CFLAGS=
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001527 fi
1528 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001529 else
1530 AC_MSG_RESULT(too old)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001531 fi
1532 fi
Bram Moolenaar1612b1a2013-06-14 21:22:39 +02001533 if test "$fail_if_missing" = "yes" -a "$python3_ok" != "yes"; then
1534 AC_MSG_ERROR([could not configure python3])
1535 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001536fi
1537
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001538AC_SUBST(PYTHON3_LIBS)
1539AC_SUBST(PYTHON3_CFLAGS)
1540AC_SUBST(PYTHON3_SRC)
1541AC_SUBST(PYTHON3_OBJ)
1542
1543dnl if python2.x and python3.x are enabled one can only link in code
1544dnl with dlopen(), dlsym(), dlclose()
1545if test "$python_ok" = yes && test "$python3_ok" = yes; then
1546 AC_DEFINE(DYNAMIC_PYTHON)
1547 AC_DEFINE(DYNAMIC_PYTHON3)
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001548 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001549 cflags_save=$CFLAGS
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001550 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001551 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001552 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001553 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001554 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001555 #include <dlfcn.h>
1556 /* If this program fails, then RTLD_GLOBAL is needed.
1557 * RTLD_GLOBAL will be used and then it is not possible to
1558 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001559 * Only the first python version used will be switched on.
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001560 */
1561
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001562 int no_rtl_global_needed_for(char *python_instsoname, char *prefix)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001563 {
1564 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001565 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001566 if (pylib != 0)
1567 {
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001568 void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome");
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001569 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1570 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1571 void (*final)(void) = dlsym(pylib, "Py_Finalize");
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001572 (*pfx)(prefix);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001573 (*init)();
1574 needed = (*simple)("import termios") == -1;
1575 (*final)();
1576 dlclose(pylib);
1577 }
1578 return !needed;
1579 }
1580
1581 int main(int argc, char** argv)
1582 {
1583 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001584 if (no_rtl_global_needed_for("${vi_cv_dll_name_python}", "${vi_cv_path_python_pfx}"))
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001585 not_needed = 1;
1586 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001587 }])],
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001588 [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001589
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001590 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001591 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001592
1593 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python3)
1594 cflags_save=$CFLAGS
1595 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001596 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001597 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001598 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001599 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001600 #include <dlfcn.h>
1601 #include <wchar.h>
1602 /* If this program fails, then RTLD_GLOBAL is needed.
1603 * RTLD_GLOBAL will be used and then it is not possible to
1604 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001605 * Only the first python version used will be switched on.
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001606 */
1607
1608 int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix)
1609 {
1610 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001611 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001612 if (pylib != 0)
1613 {
1614 void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome");
1615 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1616 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1617 void (*final)(void) = dlsym(pylib, "Py_Finalize");
1618 (*pfx)(prefix);
1619 (*init)();
1620 needed = (*simple)("import termios") == -1;
1621 (*final)();
1622 dlclose(pylib);
1623 }
1624 return !needed;
1625 }
1626
1627 int main(int argc, char** argv)
1628 {
1629 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001630 if (no_rtl_global_needed_for("${vi_cv_dll_name_python3}", L"${vi_cv_path_python3_pfx}"))
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001631 not_needed = 1;
1632 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001633 }])],
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001634 [AC_MSG_RESULT(yes);AC_DEFINE(PY3_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
1635
1636 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001637 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001638
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001639 PYTHON_SRC="if_python.c"
1640 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001641 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001642 PYTHON_LIBS=
1643 PYTHON3_SRC="if_python3.c"
1644 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001645 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001646 PYTHON3_LIBS=
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001647elif test "$python_ok" = yes && test "$enable_pythoninterp" = "dynamic"; then
1648 AC_DEFINE(DYNAMIC_PYTHON)
1649 PYTHON_SRC="if_python.c"
1650 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001651 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001652 PYTHON_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001653elif test "$python_ok" = yes; then
1654 dnl Check that adding -fPIE works. It may be needed when using a static
1655 dnl Python library.
1656 AC_MSG_CHECKING([if -fPIE can be added for Python])
1657 cflags_save=$CFLAGS
1658 libs_save=$LIBS
1659 CFLAGS="$CFLAGS $PYTHON_CFLAGS -fPIE"
1660 LIBS="$LIBS $PYTHON_LIBS"
1661 AC_TRY_LINK(,[ ],
1662 AC_MSG_RESULT(yes); fpie_ok=yes,
1663 AC_MSG_RESULT(no); fpie_ok=no)
1664 CFLAGS=$cflags_save
1665 LIBS=$libs_save
1666 if test $fpie_ok = yes; then
1667 PYTHON_CFLAGS="$PYTHON_CFLAGS -fPIE"
1668 fi
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001669elif test "$python3_ok" = yes && test "$enable_python3interp" = "dynamic"; then
1670 AC_DEFINE(DYNAMIC_PYTHON3)
1671 PYTHON3_SRC="if_python3.c"
1672 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001673 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001674 PYTHON3_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001675elif test "$python3_ok" = yes; then
1676 dnl Check that adding -fPIE works. It may be needed when using a static
1677 dnl Python library.
1678 AC_MSG_CHECKING([if -fPIE can be added for Python3])
1679 cflags_save=$CFLAGS
1680 libs_save=$LIBS
1681 CFLAGS="$CFLAGS $PYTHON3_CFLAGS -fPIE"
1682 LIBS="$LIBS $PYTHON3_LIBS"
1683 AC_TRY_LINK(,[ ],
1684 AC_MSG_RESULT(yes); fpie_ok=yes,
1685 AC_MSG_RESULT(no); fpie_ok=no)
1686 CFLAGS=$cflags_save
1687 LIBS=$libs_save
1688 if test $fpie_ok = yes; then
1689 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -fPIE"
1690 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001691fi
1692
Bram Moolenaar071d4272004-06-13 20:20:40 +00001693AC_MSG_CHECKING(--enable-tclinterp argument)
1694AC_ARG_ENABLE(tclinterp,
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001695 [ --enable-tclinterp[=OPTS] Include Tcl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001696 [enable_tclinterp="no"])
1697AC_MSG_RESULT($enable_tclinterp)
1698
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001699if test "$enable_tclinterp" = "yes" -o "$enable_tclinterp" = "dynamic"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001700
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001701 dnl on FreeBSD tclsh is a silly script, look for tclsh8.[5420]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001702 AC_MSG_CHECKING(--with-tclsh argument)
1703 AC_ARG_WITH(tclsh, [ --with-tclsh=PATH which tclsh to use (default: tclsh8.0)],
1704 tclsh_name="$withval"; AC_MSG_RESULT($tclsh_name),
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001705 tclsh_name="tclsh8.5"; AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00001706 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1707 AC_SUBST(vi_cv_path_tcl)
1708
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001709 dnl when no specific version specified, also try 8.4, 8.2 and 8.0
1710 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.5"; then
1711 tclsh_name="tclsh8.4"
1712 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1713 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001714 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.4"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001715 tclsh_name="tclsh8.2"
1716 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1717 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001718 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.2"; then
1719 tclsh_name="tclsh8.0"
1720 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1721 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001722 dnl still didn't find it, try without version number
1723 if test "X$vi_cv_path_tcl" = "X"; then
1724 tclsh_name="tclsh"
1725 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1726 fi
1727 if test "X$vi_cv_path_tcl" != "X"; then
1728 AC_MSG_CHECKING(Tcl version)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001729 if echo 'exit [[expr [info tclversion] < 8.0]]' | "$vi_cv_path_tcl" - ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001730 tclver=`echo 'puts [[info tclversion]]' | $vi_cv_path_tcl -`
1731 AC_MSG_RESULT($tclver - OK);
1732 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 +01001733 tcldll=`echo 'puts libtcl[[info tclversion]][[info sharedlibextension]]' | $vi_cv_path_tcl -`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001734
1735 AC_MSG_CHECKING(for location of Tcl include)
Bram Moolenaard0573012017-10-28 21:11:06 +02001736 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001737 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 +00001738 else
1739 dnl For Mac OS X 10.3, use the OS-provided framework location
1740 tclinc="/System/Library/Frameworks/Tcl.framework/Headers"
1741 fi
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001742 TCL_INC=
Bram Moolenaar071d4272004-06-13 20:20:40 +00001743 for try in $tclinc; do
1744 if test -f "$try/tcl.h"; then
1745 AC_MSG_RESULT($try/tcl.h)
1746 TCL_INC=$try
1747 break
1748 fi
1749 done
1750 if test -z "$TCL_INC"; then
1751 AC_MSG_RESULT(<not found>)
1752 SKIP_TCL=YES
1753 fi
1754 if test -z "$SKIP_TCL"; then
1755 AC_MSG_CHECKING(for location of tclConfig.sh script)
Bram Moolenaard0573012017-10-28 21:11:06 +02001756 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001757 tclcnf=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001758 tclcnf="$tclcnf `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001759 else
1760 dnl For Mac OS X 10.3, use the OS-provided framework location
1761 tclcnf="/System/Library/Frameworks/Tcl.framework"
1762 fi
1763 for try in $tclcnf; do
Bram Moolenaar49222be2015-12-11 18:11:30 +01001764 if test -f "$try/tclConfig.sh"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001765 AC_MSG_RESULT($try/tclConfig.sh)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001766 . "$try/tclConfig.sh"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001767 dnl use eval, because tcl 8.2 includes ${TCL_DBGX}
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001768 if test "$enable_tclinterp" = "dynamic"; then
1769 TCL_LIBS=`eval echo "$TCL_STUB_LIB_SPEC $TCL_LIBS"`
1770 else
1771 TCL_LIBS=`eval echo "$TCL_LIB_SPEC $TCL_LIBS"`
1772 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001773 dnl Use $TCL_DEFS for -D_THREAD_SAFE et al. But only use the
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001774 dnl "-D_ABC" items. Watch out for -DFOO=long\ long.
Bram Moolenaar4394bff2008-07-24 11:21:31 +00001775 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 +00001776 break
1777 fi
1778 done
1779 if test -z "$TCL_LIBS"; then
1780 AC_MSG_RESULT(<not found>)
1781 AC_MSG_CHECKING(for Tcl library by myself)
1782 tcllib=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001783 tcllib="$tcllib `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001784 for ext in .so .a ; do
1785 for ver in "" $tclver ; do
1786 for try in $tcllib ; do
1787 trylib=tcl$ver$ext
Bram Moolenaar49222be2015-12-11 18:11:30 +01001788 if test -f "$try/lib$trylib" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001789 AC_MSG_RESULT($try/lib$trylib)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001790 TCL_LIBS="-L\"$try\" -ltcl$ver -ldl -lm"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001791 if test "`(uname) 2>/dev/null`" = SunOS &&
1792 uname -r | grep '^5' >/dev/null; then
1793 TCL_LIBS="$TCL_LIBS -R $try"
1794 fi
1795 break 3
1796 fi
1797 done
1798 done
1799 done
1800 if test -z "$TCL_LIBS"; then
1801 AC_MSG_RESULT(<not found>)
1802 SKIP_TCL=YES
1803 fi
1804 fi
1805 if test -z "$SKIP_TCL"; then
1806 AC_DEFINE(FEAT_TCL)
1807 TCL_SRC=if_tcl.c
1808 TCL_OBJ=objects/if_tcl.o
1809 TCL_PRO=if_tcl.pro
1810 TCL_CFLAGS="-I$TCL_INC $TCL_DEFS"
1811 fi
1812 fi
1813 else
1814 AC_MSG_RESULT(too old; need Tcl version 8.0 or later)
1815 fi
1816 fi
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001817 if test "$enable_tclinterp" = "dynamic"; then
1818 if test "X$TCL_SRC" != "X" -a "X$tcldll" != "X"; then
1819 AC_DEFINE(DYNAMIC_TCL)
1820 TCL_CFLAGS="-DDYNAMIC_TCL_DLL=\\\"$tcldll\\\" -DDYNAMIC_TCL_VER=\\\"$tclver\\\" $TCL_CFLAGS"
1821 fi
1822 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001823 if test "$fail_if_missing" = "yes" -a -z "$TCL_SRC"; then
1824 AC_MSG_ERROR([could not configure Tcl])
1825 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001826fi
1827AC_SUBST(TCL_SRC)
1828AC_SUBST(TCL_OBJ)
1829AC_SUBST(TCL_PRO)
1830AC_SUBST(TCL_CFLAGS)
1831AC_SUBST(TCL_LIBS)
1832
1833AC_MSG_CHECKING(--enable-rubyinterp argument)
1834AC_ARG_ENABLE(rubyinterp,
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001835 [ --enable-rubyinterp[=OPTS] Include Ruby interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001836 [enable_rubyinterp="no"])
1837AC_MSG_RESULT($enable_rubyinterp)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001838if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001839 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1840 AC_MSG_ERROR([cannot use Ruby with tiny or small features])
1841 fi
1842
Bram Moolenaar165641d2010-02-17 16:23:09 +01001843 AC_MSG_CHECKING(--with-ruby-command argument)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001844 AC_SUBST(vi_cv_path_ruby)
Bram Moolenaar948733a2011-05-05 18:10:16 +02001845 AC_ARG_WITH(ruby-command, [ --with-ruby-command=RUBY name of the Ruby command (default: ruby)],
1846 RUBY_CMD="$withval"; vi_cv_path_ruby="$withval"; AC_MSG_RESULT($RUBY_CMD),
1847 RUBY_CMD="ruby"; AC_MSG_RESULT(defaulting to $RUBY_CMD))
Bram Moolenaar165641d2010-02-17 16:23:09 +01001848 AC_PATH_PROG(vi_cv_path_ruby, $RUBY_CMD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001849 if test "X$vi_cv_path_ruby" != "X"; then
1850 AC_MSG_CHECKING(Ruby version)
Bram Moolenaare4efc3b2005-03-07 23:16:51 +00001851 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 +00001852 AC_MSG_RESULT(OK)
Bram Moolenaar81398892012-10-03 21:09:35 +02001853 AC_MSG_CHECKING(Ruby rbconfig)
1854 ruby_rbconfig="RbConfig"
1855 if ! $vi_cv_path_ruby -r rbconfig -e 'RbConfig' >/dev/null 2>/dev/null; then
1856 ruby_rbconfig="Config"
1857 fi
1858 AC_MSG_RESULT($ruby_rbconfig)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001859 AC_MSG_CHECKING(Ruby header files)
Bram Moolenaar81398892012-10-03 21:09:35 +02001860 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 +00001861 if test "X$rubyhdrdir" != "X"; then
1862 AC_MSG_RESULT($rubyhdrdir)
1863 RUBY_CFLAGS="-I$rubyhdrdir"
Bram Moolenaara6fd37b2014-03-27 17:19:09 +01001864 rubyarchdir=`$vi_cv_path_ruby -r rbconfig -e "print ($ruby_rbconfig::CONFIG.has_key? 'rubyarchhdrdir') ? $ruby_rbconfig::CONFIG[['rubyarchhdrdir']] : '$rubyhdrdir/'+$ruby_rbconfig::CONFIG[['arch']]"`
1865 if test -d "$rubyarchdir"; then
1866 RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyarchdir"
Bram Moolenaar165641d2010-02-17 16:23:09 +01001867 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001868 rubyversion=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['ruby_version']].gsub(/\./, '')[[0,2]]"`
Bram Moolenaar026a4452013-08-07 15:22:23 +02001869 if test "X$rubyversion" = "X"; then
1870 rubyversion=`$vi_cv_path_ruby -e "print ((VERSION rescue RUBY_VERSION)).gsub(/\./, '')[[0,2]]"`
1871 fi
Bram Moolenaar165641d2010-02-17 16:23:09 +01001872 RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
Bram Moolenaar81398892012-10-03 21:09:35 +02001873 rubylibs=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LIBS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001874 if test "X$rubylibs" != "X"; then
1875 RUBY_LIBS="$rubylibs"
1876 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001877 librubyarg=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBYARG']])"`
1878 librubya=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBY_A']])"`
Bram Moolenaarac499e32013-06-02 19:14:17 +02001879 rubylibdir=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['libdir']])"`
Bram Moolenaar948733a2011-05-05 18:10:16 +02001880 if test -f "$rubylibdir/$librubya"; then
1881 librubyarg="$librubyarg"
Bram Moolenaarac499e32013-06-02 19:14:17 +02001882 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
1883 elif test "$librubyarg" = "libruby.a"; then
1884 dnl required on Mac OS 10.3 where libruby.a doesn't exist
1885 librubyarg="-lruby"
1886 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001887 fi
1888
1889 if test "X$librubyarg" != "X"; then
1890 RUBY_LIBS="$librubyarg $RUBY_LIBS"
1891 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001892 rubyldflags=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LDFLAGS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001893 if test "X$rubyldflags" != "X"; then
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001894 dnl Ruby on Mac OS X 10.5 adds "-arch" flags but these should only
1895 dnl be included if requested by passing --with-mac-arch to
1896 dnl configure, so strip these flags first (if present)
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001897 rubyldflags=`echo "$rubyldflags" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001898 if test "X$rubyldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001899 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$rubyldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001900 LDFLAGS="$rubyldflags $LDFLAGS"
1901 fi
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001902 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001903 fi
1904 RUBY_SRC="if_ruby.c"
1905 RUBY_OBJ="objects/if_ruby.o"
1906 RUBY_PRO="if_ruby.pro"
1907 AC_DEFINE(FEAT_RUBY)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001908 if test "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar92021622017-10-12 12:33:43 +02001909 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_ALIASES']].split[[0]]"`
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001910 AC_DEFINE(DYNAMIC_RUBY)
Bram Moolenaar92021622017-10-12 12:33:43 +02001911 RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby_soname\\\" -DDYNAMIC_RUBY_VER=$rubyversion $RUBY_CFLAGS"
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001912 RUBY_LIBS=
1913 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001914 else
Bram Moolenaar165641d2010-02-17 16:23:09 +01001915 AC_MSG_RESULT(not found; disabling Ruby)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001916 fi
1917 else
1918 AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
1919 fi
1920 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001921
1922 if test "$fail_if_missing" = "yes" -a -z "$RUBY_OBJ"; then
1923 AC_MSG_ERROR([could not configure Ruby])
1924 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001925fi
1926AC_SUBST(RUBY_SRC)
1927AC_SUBST(RUBY_OBJ)
1928AC_SUBST(RUBY_PRO)
1929AC_SUBST(RUBY_CFLAGS)
1930AC_SUBST(RUBY_LIBS)
1931
1932AC_MSG_CHECKING(--enable-cscope argument)
1933AC_ARG_ENABLE(cscope,
1934 [ --enable-cscope Include cscope interface.], ,
1935 [enable_cscope="no"])
1936AC_MSG_RESULT($enable_cscope)
1937if test "$enable_cscope" = "yes"; then
1938 AC_DEFINE(FEAT_CSCOPE)
1939fi
1940
1941AC_MSG_CHECKING(--enable-workshop argument)
1942AC_ARG_ENABLE(workshop,
1943 [ --enable-workshop Include Sun Visual Workshop support.], ,
1944 [enable_workshop="no"])
1945AC_MSG_RESULT($enable_workshop)
1946if test "$enable_workshop" = "yes"; then
1947 AC_DEFINE(FEAT_SUN_WORKSHOP)
1948 WORKSHOP_SRC="workshop.c integration.c"
1949 AC_SUBST(WORKSHOP_SRC)
1950 WORKSHOP_OBJ="objects/workshop.o objects/integration.o"
1951 AC_SUBST(WORKSHOP_OBJ)
1952 if test "${enable_gui-xxx}" = xxx; then
1953 enable_gui=motif
1954 fi
1955fi
1956
1957AC_MSG_CHECKING(--disable-netbeans argument)
1958AC_ARG_ENABLE(netbeans,
1959 [ --disable-netbeans Disable NetBeans integration support.],
1960 , [enable_netbeans="yes"])
1961if test "$enable_netbeans" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01001962 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1963 AC_MSG_RESULT([cannot use NetBeans with tiny or small features])
1964 enable_netbeans="no"
1965 else
1966 AC_MSG_RESULT(no)
1967 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01001968else
1969 AC_MSG_RESULT(yes)
1970fi
1971
1972AC_MSG_CHECKING(--disable-channel argument)
1973AC_ARG_ENABLE(channel,
Bram Moolenaar8008b632017-07-18 21:33:20 +02001974 [ --disable-channel Disable process communication support.],
Bram Moolenaare0874f82016-01-24 20:36:41 +01001975 , [enable_channel="yes"])
1976if test "$enable_channel" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01001977 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1978 AC_MSG_RESULT([cannot use channels with tiny or small features])
1979 enable_channel="no"
1980 else
1981 AC_MSG_RESULT(no)
1982 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01001983else
1984 if test "$enable_netbeans" = "yes"; then
Bram Moolenaar16435482016-01-24 21:31:54 +01001985 AC_MSG_RESULT([yes, netbeans also disabled])
Bram Moolenaare0874f82016-01-24 20:36:41 +01001986 enable_netbeans="no"
1987 else
1988 AC_MSG_RESULT(yes)
1989 fi
1990fi
1991
Bram Moolenaar16435482016-01-24 21:31:54 +01001992if test "$enable_channel" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001993 dnl On Solaris we need the socket and nsl library.
1994 AC_CHECK_LIB(socket, socket)
1995 AC_CHECK_LIB(nsl, gethostbyname)
Bram Moolenaare0874f82016-01-24 20:36:41 +01001996 AC_MSG_CHECKING(whether compiling with process communication is possible)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001997 AC_TRY_LINK([
1998#include <stdio.h>
1999#include <stdlib.h>
2000#include <stdarg.h>
2001#include <fcntl.h>
2002#include <netdb.h>
2003#include <netinet/in.h>
2004#include <errno.h>
2005#include <sys/types.h>
2006#include <sys/socket.h>
2007 /* Check bitfields */
2008 struct nbbuf {
2009 unsigned int initDone:1;
Bram Moolenaar63de19e2016-12-09 20:11:26 +01002010 unsigned short signmaplen;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002011 };
2012 ], [
2013 /* Check creating a socket. */
2014 struct sockaddr_in server;
2015 (void)socket(AF_INET, SOCK_STREAM, 0);
2016 (void)htons(100);
2017 (void)gethostbyname("microsoft.com");
2018 if (errno == ECONNREFUSED)
2019 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
2020 ],
2021 AC_MSG_RESULT(yes),
Bram Moolenaare0874f82016-01-24 20:36:41 +01002022 AC_MSG_RESULT(no); enable_netbeans="no"; enable_channel="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00002023fi
2024if test "$enable_netbeans" = "yes"; then
2025 AC_DEFINE(FEAT_NETBEANS_INTG)
2026 NETBEANS_SRC="netbeans.c"
2027 AC_SUBST(NETBEANS_SRC)
2028 NETBEANS_OBJ="objects/netbeans.o"
2029 AC_SUBST(NETBEANS_OBJ)
2030fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002031if test "$enable_channel" = "yes"; then
Bram Moolenaar509ce2a2016-03-11 22:52:15 +01002032 AC_DEFINE(FEAT_JOB_CHANNEL)
Bram Moolenaare0874f82016-01-24 20:36:41 +01002033 CHANNEL_SRC="channel.c"
2034 AC_SUBST(CHANNEL_SRC)
2035 CHANNEL_OBJ="objects/channel.o"
2036 AC_SUBST(CHANNEL_OBJ)
2037fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002038
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002039AC_MSG_CHECKING(--enable-terminal argument)
2040AC_ARG_ENABLE(terminal,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002041 [ --enable-terminal Enable terminal emulation support.],
Bram Moolenaaref839562017-10-28 20:28:23 +02002042 , [enable_terminal="auto"])
Bram Moolenaar595a4022017-09-03 19:15:57 +02002043if test "$enable_terminal" = "yes" || test "$enable_terminal" = "auto" -a "x$features" = "xhuge" ; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002044 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2045 AC_MSG_RESULT([cannot use terminal emulator with tiny or small features])
2046 enable_terminal="no"
2047 else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002048 if test "$enable_terminal" = "auto"; then
2049 enable_terminal="yes"
2050 AC_MSG_RESULT(defaulting to yes)
2051 else
2052 AC_MSG_RESULT(yes)
2053 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002054 fi
2055else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002056 if test "$enable_terminal" = "auto"; then
2057 enable_terminal="no"
2058 AC_MSG_RESULT(defaulting to no)
2059 else
2060 AC_MSG_RESULT(no)
2061 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002062fi
Bram Moolenaar8b423282017-12-16 14:37:06 +01002063if test "$enable_terminal" = "yes" -a "$enable_channel" = "yes"; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002064 AC_DEFINE(FEAT_TERMINAL)
2065 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"
2066 AC_SUBST(TERM_SRC)
2067 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"
2068 AC_SUBST(TERM_OBJ)
2069fi
2070
Bram Moolenaare42a6d22017-11-12 19:21:51 +01002071AC_MSG_CHECKING(--enable-autoservername argument)
2072AC_ARG_ENABLE(autoservername,
2073 [ --enable-autoservername Automatically define servername at vim startup.], ,
2074 [enable_autoservername="no"])
2075AC_MSG_RESULT($enable_autoservername)
2076if test "$enable_autoservername" = "yes"; then
2077 AC_DEFINE(FEAT_AUTOSERVERNAME)
2078fi
2079
Bram Moolenaar071d4272004-06-13 20:20:40 +00002080AC_MSG_CHECKING(--enable-multibyte argument)
2081AC_ARG_ENABLE(multibyte,
2082 [ --enable-multibyte Include multibyte editing support.], ,
2083 [enable_multibyte="no"])
2084AC_MSG_RESULT($enable_multibyte)
2085if test "$enable_multibyte" = "yes"; then
2086 AC_DEFINE(FEAT_MBYTE)
2087fi
2088
2089AC_MSG_CHECKING(--enable-hangulinput argument)
2090AC_ARG_ENABLE(hangulinput,
2091 [ --enable-hangulinput Include Hangul input support.], ,
2092 [enable_hangulinput="no"])
2093AC_MSG_RESULT($enable_hangulinput)
2094
2095AC_MSG_CHECKING(--enable-xim argument)
2096AC_ARG_ENABLE(xim,
2097 [ --enable-xim Include XIM input support.],
2098 AC_MSG_RESULT($enable_xim),
2099 [enable_xim="auto"; AC_MSG_RESULT(defaulting to auto)])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002100
2101AC_MSG_CHECKING(--enable-fontset argument)
2102AC_ARG_ENABLE(fontset,
2103 [ --enable-fontset Include X fontset output support.], ,
2104 [enable_fontset="no"])
2105AC_MSG_RESULT($enable_fontset)
2106dnl defining FEAT_XFONTSET is delayed, so that it can be disabled for no GUI
2107
2108test -z "$with_x" && with_x=yes
Bram Moolenaard0573012017-10-28 21:11:06 +02002109test "${enable_gui-yes}" != no -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && with_x=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002110if test "$with_x" = no; then
2111 AC_MSG_RESULT(defaulting to: don't HAVE_X11)
2112else
2113 dnl Do this check early, so that its failure can override user requests.
2114
2115 AC_PATH_PROG(xmkmfpath, xmkmf)
2116
2117 AC_PATH_XTRA
2118
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002119 dnl On z/OS Unix the X libraries are DLLs. To use them the code must
Bram Moolenaar071d4272004-06-13 20:20:40 +00002120 dnl be compiled with a special option.
2121 dnl Also add SM, ICE and Xmu to X_EXTRA_LIBS.
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002122 if test "$zOSUnix" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002123 CFLAGS="$CFLAGS -W c,dll"
2124 LDFLAGS="$LDFLAGS -W l,dll"
2125 X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE -lXmu"
2126 fi
2127
2128 dnl On my HPUX system the X include dir is found, but the lib dir not.
2129 dnl This is a desparate try to fix this.
2130
2131 if test -d "$x_includes" && test ! -d "$x_libraries"; then
2132 x_libraries=`echo "$x_includes" | sed s/include/lib/`
2133 AC_MSG_RESULT(Corrected X libraries to $x_libraries)
2134 X_LIBS="$X_LIBS -L$x_libraries"
2135 if test "`(uname) 2>/dev/null`" = SunOS &&
2136 uname -r | grep '^5' >/dev/null; then
2137 X_LIBS="$X_LIBS -R $x_libraries"
2138 fi
2139 fi
2140
2141 if test -d "$x_libraries" && test ! -d "$x_includes"; then
2142 x_includes=`echo "$x_libraries" | sed s/lib/include/`
2143 AC_MSG_RESULT(Corrected X includes to $x_includes)
2144 X_CFLAGS="$X_CFLAGS -I$x_includes"
2145 fi
2146
2147 dnl Remove "-I/usr/include " from X_CFLAGS, should not be needed.
2148 X_CFLAGS="`echo $X_CFLAGS\ | sed 's%-I/usr/include %%'`"
2149 dnl Remove "-L/usr/lib " from X_LIBS, should not be needed.
2150 X_LIBS="`echo $X_LIBS\ | sed 's%-L/usr/lib %%'`"
2151 dnl Same for "-R/usr/lib ".
2152 X_LIBS="`echo $X_LIBS\ | sed -e 's%-R/usr/lib %%' -e 's%-R /usr/lib %%'`"
2153
2154
2155 dnl Check if the X11 header files are correctly installed. On some systems
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002156 dnl Xlib.h includes files that don't exist. On some systems X11/Intrinsic.h
2157 dnl is missing.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002158 AC_MSG_CHECKING(if X11 header files can be found)
2159 cflags_save=$CFLAGS
2160 CFLAGS="$CFLAGS $X_CFLAGS"
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002161 AC_TRY_COMPILE([#include <X11/Xlib.h>
2162#include <X11/Intrinsic.h>], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002163 AC_MSG_RESULT(yes),
2164 AC_MSG_RESULT(no); no_x=yes)
2165 CFLAGS=$cflags_save
2166
2167 if test "${no_x-no}" = yes; then
2168 with_x=no
2169 else
2170 AC_DEFINE(HAVE_X11)
2171 X_LIB="-lXt -lX11";
2172 AC_SUBST(X_LIB)
2173
2174 ac_save_LDFLAGS="$LDFLAGS"
2175 LDFLAGS="-L$x_libraries $LDFLAGS"
2176
2177 dnl Check for -lXdmcp (needed on SunOS 4.1.4)
2178 dnl For HP-UX 10.20 it must be before -lSM -lICE
2179 AC_CHECK_LIB(Xdmcp, _XdmcpAuthDoIt, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lXdmcp"],,
2180 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXdmcp])
2181
2182 dnl Some systems need -lnsl -lsocket when testing for ICE.
2183 dnl The check above doesn't do this, try here (again). Also needed to get
2184 dnl them after Xdmcp. link.sh will remove them when not needed.
2185 dnl Check for other function than above to avoid the cached value
2186 AC_CHECK_LIB(ICE, IceOpenConnection,
2187 [X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE"],, [$X_EXTRA_LIBS])
2188
2189 dnl Check for -lXpm (needed for some versions of Motif)
2190 LDFLAGS="$X_LIBS $ac_save_LDFLAGS"
2191 AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [X_PRE_LIBS="$X_PRE_LIBS -lXpm"],,
2192 [-lXt $X_PRE_LIBS -lXpm -lX11 $X_EXTRA_LIBS])
2193
2194 dnl Check that the X11 header files don't use implicit declarations
2195 AC_MSG_CHECKING(if X11 header files implicitly declare return values)
2196 cflags_save=$CFLAGS
Bram Moolenaard1864592013-05-04 04:40:15 +02002197 dnl -Werror is GCC only, others like Solaris Studio might not like it
2198 if test "$GCC" = yes; then
2199 CFLAGS="$CFLAGS $X_CFLAGS -Werror"
2200 else
2201 CFLAGS="$CFLAGS $X_CFLAGS"
2202 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002203 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2204 AC_MSG_RESULT(no),
2205 CFLAGS="$CFLAGS -Wno-implicit-int"
2206 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2207 AC_MSG_RESULT(yes); cflags_save="$cflags_save -Wno-implicit-int",
2208 AC_MSG_RESULT(test failed)
2209 )
2210 )
2211 CFLAGS=$cflags_save
2212
2213 LDFLAGS="$ac_save_LDFLAGS"
2214
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002215 AC_MSG_CHECKING(size of wchar_t is 2 bytes)
2216 AC_CACHE_VAL(ac_cv_small_wchar_t,
2217 [AC_TRY_RUN([
2218#include <X11/Xlib.h>
2219#if STDC_HEADERS
2220# include <stdlib.h>
2221# include <stddef.h>
2222#endif
2223 main()
2224 {
2225 if (sizeof(wchar_t) <= 2)
2226 exit(1);
2227 exit(0);
2228 }],
2229 ac_cv_small_wchar_t="no",
2230 ac_cv_small_wchar_t="yes",
2231 AC_MSG_ERROR(failed to compile test program))])
2232 AC_MSG_RESULT($ac_cv_small_wchar_t)
2233 if test "x$ac_cv_small_wchar_t" = "xyes" ; then
2234 AC_DEFINE(SMALL_WCHAR_T)
2235 fi
2236
Bram Moolenaar071d4272004-06-13 20:20:40 +00002237 fi
2238fi
2239
Bram Moolenaard0573012017-10-28 21:11:06 +02002240test "x$with_x" = xno -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && enable_gui=no
Bram Moolenaar071d4272004-06-13 20:20:40 +00002241
2242AC_MSG_CHECKING(--enable-gui argument)
2243AC_ARG_ENABLE(gui,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002244 [ --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 +00002245
2246dnl Canonicalize the --enable-gui= argument so that it can be easily compared.
2247dnl Do not use character classes for portability with old tools.
2248enable_gui_canon=`echo "_$enable_gui" | \
2249 sed 's/[[ _+-]]//g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
2250
2251dnl Skip everything by default.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002252SKIP_GTK2=YES
Bram Moolenaar1858a842016-02-23 22:30:31 +01002253SKIP_GTK3=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002254SKIP_GNOME=YES
2255SKIP_MOTIF=YES
2256SKIP_ATHENA=YES
2257SKIP_NEXTAW=YES
2258SKIP_PHOTON=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002259SKIP_CARBON=YES
2260GUITYPE=NONE
2261
Bram Moolenaarb11160e2005-01-04 21:31:43 +00002262if test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002263 SKIP_PHOTON=
2264 case "$enable_gui_canon" in
2265 no) AC_MSG_RESULT(no GUI support)
2266 SKIP_PHOTON=YES ;;
2267 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
2268 auto) AC_MSG_RESULT(auto - automatic GUI support) ;;
2269 photon) AC_MSG_RESULT(Photon GUI support) ;;
2270 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2271 SKIP_PHOTON=YES ;;
2272 esac
2273
Bram Moolenaard0573012017-10-28 21:11:06 +02002274elif test "x$MACOS_X" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002275 SKIP_CARBON=
2276 case "$enable_gui_canon" in
2277 no) AC_MSG_RESULT(no GUI support)
2278 SKIP_CARBON=YES ;;
2279 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
Bram Moolenaar164fca32010-07-14 13:58:07 +02002280 auto) AC_MSG_RESULT(auto - Carbon GUI is outdated - disable GUI support)
2281 SKIP_CARBON=YES ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002282 carbon) AC_MSG_RESULT(Carbon GUI support) ;;
2283 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2284 SKIP_CARBON=YES ;;
2285 esac
2286
2287else
2288
Bram Moolenaar071d4272004-06-13 20:20:40 +00002289 case "$enable_gui_canon" in
2290 no|none) AC_MSG_RESULT(no GUI support) ;;
2291 yes|""|auto) AC_MSG_RESULT(yes/auto - automatic GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002292 SKIP_GTK2=
2293 SKIP_GNOME=
2294 SKIP_MOTIF=
2295 SKIP_ATHENA=
2296 SKIP_NEXTAW=
2297 SKIP_CARBON=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002298 gtk2) AC_MSG_RESULT(GTK+ 2.x GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002299 SKIP_GTK2=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002300 gnome2) AC_MSG_RESULT(GNOME 2.x GUI support)
2301 SKIP_GNOME=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002302 SKIP_GTK2=;;
Bram Moolenaar98921892016-02-23 17:14:37 +01002303 gtk3) AC_MSG_RESULT(GTK+ 3.x GUI support)
2304 SKIP_GTK3=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002305 motif) AC_MSG_RESULT(Motif GUI support)
2306 SKIP_MOTIF=;;
2307 athena) AC_MSG_RESULT(Athena GUI support)
2308 SKIP_ATHENA=;;
2309 nextaw) AC_MSG_RESULT(neXtaw GUI support)
2310 SKIP_NEXTAW=;;
2311 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
2312 esac
2313
2314fi
2315
Bram Moolenaar071d4272004-06-13 20:20:40 +00002316if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \
2317 -a "$enable_gui_canon" != "gnome2"; then
2318 AC_MSG_CHECKING(whether or not to look for GTK+ 2)
2319 AC_ARG_ENABLE(gtk2-check,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002320 [ --enable-gtk2-check If auto-select GUI, check for GTK+ 2 [default=yes]],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002321 , enable_gtk2_check="yes")
2322 AC_MSG_RESULT($enable_gtk2_check)
2323 if test "x$enable_gtk2_check" = "xno"; then
2324 SKIP_GTK2=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002325 SKIP_GNOME=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002326 fi
2327fi
2328
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002329if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002330 AC_MSG_CHECKING(whether or not to look for GNOME)
2331 AC_ARG_ENABLE(gnome-check,
2332 [ --enable-gnome-check If GTK GUI, check for GNOME [default=no]],
2333 , enable_gnome_check="no")
2334 AC_MSG_RESULT($enable_gnome_check)
2335 if test "x$enable_gnome_check" = "xno"; then
2336 SKIP_GNOME=YES
2337 fi
2338fi
2339
Bram Moolenaar98921892016-02-23 17:14:37 +01002340if test "x$SKIP_GTK3" != "xYES" -a "$enable_gui_canon" != "gtk3"; then
2341 AC_MSG_CHECKING(whether or not to look for GTK+ 3)
2342 AC_ARG_ENABLE(gtk3-check,
2343 [ --enable-gtk3-check If auto-select GUI, check for GTK+ 3 [default=yes]],
2344 , enable_gtk3_check="yes")
2345 AC_MSG_RESULT($enable_gtk3_check)
2346 if test "x$enable_gtk3_check" = "xno"; then
2347 SKIP_GTK3=YES
2348 fi
2349fi
2350
Bram Moolenaar071d4272004-06-13 20:20:40 +00002351if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then
2352 AC_MSG_CHECKING(whether or not to look for Motif)
2353 AC_ARG_ENABLE(motif-check,
2354 [ --enable-motif-check If auto-select GUI, check for Motif [default=yes]],
2355 , enable_motif_check="yes")
2356 AC_MSG_RESULT($enable_motif_check)
2357 if test "x$enable_motif_check" = "xno"; then
2358 SKIP_MOTIF=YES
2359 fi
2360fi
2361
2362if test "x$SKIP_ATHENA" != "xYES" -a "$enable_gui_canon" != "athena"; then
2363 AC_MSG_CHECKING(whether or not to look for Athena)
2364 AC_ARG_ENABLE(athena-check,
2365 [ --enable-athena-check If auto-select GUI, check for Athena [default=yes]],
2366 , enable_athena_check="yes")
2367 AC_MSG_RESULT($enable_athena_check)
2368 if test "x$enable_athena_check" = "xno"; then
2369 SKIP_ATHENA=YES
2370 fi
2371fi
2372
2373if test "x$SKIP_NEXTAW" != "xYES" -a "$enable_gui_canon" != "nextaw"; then
2374 AC_MSG_CHECKING(whether or not to look for neXtaw)
2375 AC_ARG_ENABLE(nextaw-check,
2376 [ --enable-nextaw-check If auto-select GUI, check for neXtaw [default=yes]],
2377 , enable_nextaw_check="yes")
2378 AC_MSG_RESULT($enable_nextaw_check);
2379 if test "x$enable_nextaw_check" = "xno"; then
2380 SKIP_NEXTAW=YES
2381 fi
2382fi
2383
2384if test "x$SKIP_CARBON" != "xYES" -a "$enable_gui_canon" != "carbon"; then
2385 AC_MSG_CHECKING(whether or not to look for Carbon)
2386 AC_ARG_ENABLE(carbon-check,
2387 [ --enable-carbon-check If auto-select GUI, check for Carbon [default=yes]],
2388 , enable_carbon_check="yes")
2389 AC_MSG_RESULT($enable_carbon_check);
2390 if test "x$enable_carbon_check" = "xno"; then
2391 SKIP_CARBON=YES
2392 fi
2393fi
2394
Bram Moolenaar843ee412004-06-30 16:16:41 +00002395
Bram Moolenaard0573012017-10-28 21:11:06 +02002396if test "x$MACOS_X" = "xyes" -a -z "$SKIP_CARBON" -a "x$CARBON" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002397 AC_MSG_CHECKING(for Carbon GUI)
Bram Moolenaar14716812006-05-04 21:54:08 +00002398 dnl already did the check, just give the message
Bram Moolenaar071d4272004-06-13 20:20:40 +00002399 AC_MSG_RESULT(yes);
2400 GUITYPE=CARBONGUI
Bram Moolenaare344bea2005-09-01 20:46:49 +00002401 if test "$VIMNAME" = "vim"; then
2402 VIMNAME=Vim
2403 fi
Bram Moolenaar14716812006-05-04 21:54:08 +00002404
Bram Moolenaar164fca32010-07-14 13:58:07 +02002405 if test "x$MACARCH" = "xboth"; then
2406 CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk/Developer/Headers/FlatCarbon"
2407 else
2408 CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/Headers/FlatCarbon"
2409 fi
2410
Bram Moolenaar14716812006-05-04 21:54:08 +00002411 dnl Default install directory is not /usr/local
2412 if test x$prefix = xNONE; then
2413 prefix=/Applications
2414 fi
2415
2416 dnl Sorry for the hard coded default
2417 datadir='${prefix}/Vim.app/Contents/Resources'
2418
Bram Moolenaar071d4272004-06-13 20:20:40 +00002419 dnl skip everything else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002420 SKIP_GTK2=YES;
2421 SKIP_GNOME=YES;
2422 SKIP_MOTIF=YES;
2423 SKIP_ATHENA=YES;
2424 SKIP_NEXTAW=YES;
2425 SKIP_PHOTON=YES;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002426 SKIP_CARBON=YES
2427fi
2428
Bram Moolenaar071d4272004-06-13 20:20:40 +00002429dnl define an autoconf function to check for a specified version of GTK, and
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002430dnl try to compile/link a GTK program.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002431dnl
2432dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002433dnl Test for GTK, and define GTK_CFLAGS, GTK_LIBDIR and GTK_LIBS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002434dnl
2435AC_DEFUN(AM_PATH_GTK,
2436[
2437 if test "X$GTK_CONFIG" != "Xno" -o "X$PKG_CONFIG" != "Xno"; then
2438 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00002439 no_gtk=""
2440 if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2441 && $PKG_CONFIG --exists gtk+-2.0; then
2442 {
Bram Moolenaar98921892016-02-23 17:14:37 +01002443 min_gtk_version=ifelse([$1], ,2.2.0,$1)
2444 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002445 dnl We should be using PKG_CHECK_MODULES() instead of this hack.
2446 dnl But I guess the dependency on pkgconfig.m4 is not wanted or
2447 dnl something like that.
2448 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0`
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002449 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-2.0`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002450 GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0`
2451 gtk_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2452 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2453 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2454 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2455 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2456 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2457 }
Bram Moolenaar98921892016-02-23 17:14:37 +01002458 elif (test "X$SKIP_GTK3" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2459 && $PKG_CONFIG --exists gtk+-3.0; then
2460 {
2461 min_gtk_version=ifelse([$1], ,3.0.0,$1)
2462 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
2463
2464 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-3.0`
2465 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-3.0`
2466 GTK_LIBS=`$PKG_CONFIG --libs gtk+-3.0`
2467 gtk_major_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2468 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2469 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2470 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2471 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2472 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2473 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002474 else
2475 no_gtk=yes
2476 fi
2477
2478 if test "x$enable_gtktest" = "xyes" -a "x$no_gtk" = "x"; then
2479 {
2480 ac_save_CFLAGS="$CFLAGS"
2481 ac_save_LIBS="$LIBS"
2482 CFLAGS="$CFLAGS $GTK_CFLAGS"
2483 LIBS="$LIBS $GTK_LIBS"
2484
2485 dnl
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002486 dnl Now check if the installed GTK is sufficiently new.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002487 dnl
2488 rm -f conf.gtktest
2489 AC_TRY_RUN([
2490#include <gtk/gtk.h>
2491#include <stdio.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00002492#if STDC_HEADERS
2493# include <stdlib.h>
2494# include <stddef.h>
2495#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002496
2497int
2498main ()
2499{
2500int major, minor, micro;
2501char *tmp_version;
2502
2503system ("touch conf.gtktest");
2504
2505/* HP/UX 9 (%@#!) writes to sscanf strings */
2506tmp_version = g_strdup("$min_gtk_version");
2507if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
2508 printf("%s, bad version string\n", "$min_gtk_version");
2509 exit(1);
2510 }
2511
2512if ((gtk_major_version > major) ||
2513 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
2514 ((gtk_major_version == major) && (gtk_minor_version == minor) &&
2515 (gtk_micro_version >= micro)))
2516{
2517 return 0;
2518}
2519return 1;
2520}
2521],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
2522 CFLAGS="$ac_save_CFLAGS"
2523 LIBS="$ac_save_LIBS"
2524 }
2525 fi
2526 if test "x$no_gtk" = x ; then
2527 if test "x$enable_gtktest" = "xyes"; then
2528 AC_MSG_RESULT(yes; found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2529 else
2530 AC_MSG_RESULT(found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2531 fi
2532 ifelse([$2], , :, [$2])
2533 else
2534 {
2535 AC_MSG_RESULT(no)
2536 GTK_CFLAGS=""
2537 GTK_LIBS=""
2538 ifelse([$3], , :, [$3])
2539 }
2540 fi
2541 }
2542 else
2543 GTK_CFLAGS=""
2544 GTK_LIBS=""
2545 ifelse([$3], , :, [$3])
2546 fi
2547 AC_SUBST(GTK_CFLAGS)
2548 AC_SUBST(GTK_LIBS)
2549 rm -f conf.gtktest
2550])
2551
2552dnl ---------------------------------------------------------------------------
2553dnl gnome
2554dnl ---------------------------------------------------------------------------
2555AC_DEFUN([GNOME_INIT_HOOK],
2556[
2557 AC_SUBST(GNOME_LIBS)
2558 AC_SUBST(GNOME_LIBDIR)
2559 AC_SUBST(GNOME_INCLUDEDIR)
2560
2561 AC_ARG_WITH(gnome-includes,
2562 [ --with-gnome-includes=DIR Specify location of GNOME headers],
2563 [CFLAGS="$CFLAGS -I$withval"]
2564 )
2565
2566 AC_ARG_WITH(gnome-libs,
2567 [ --with-gnome-libs=DIR Specify location of GNOME libs],
2568 [LDFLAGS="$LDFLAGS -L$withval" gnome_prefix=$withval]
2569 )
2570
2571 AC_ARG_WITH(gnome,
2572 [ --with-gnome Specify prefix for GNOME files],
2573 if test x$withval = xyes; then
2574 want_gnome=yes
2575 ifelse([$1], [], :, [$1])
2576 else
2577 if test "x$withval" = xno; then
2578 want_gnome=no
2579 else
2580 want_gnome=yes
2581 LDFLAGS="$LDFLAGS -L$withval/lib"
2582 CFLAGS="$CFLAGS -I$withval/include"
2583 gnome_prefix=$withval/lib
2584 fi
2585 fi,
2586 want_gnome=yes)
2587
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002588 if test "x$want_gnome" = xyes; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002589 {
2590 AC_MSG_CHECKING(for libgnomeui-2.0)
2591 if $PKG_CONFIG --exists libgnomeui-2.0; then
2592 AC_MSG_RESULT(yes)
2593 GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0`
2594 GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0`
2595 GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0`
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002596
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002597 dnl On FreeBSD we need -pthread but pkg-config doesn't include it.
2598 dnl This might not be the right way but it works for me...
2599 AC_MSG_CHECKING(for FreeBSD)
2600 if test "`(uname) 2>/dev/null`" = FreeBSD; then
2601 AC_MSG_RESULT(yes, adding -pthread)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002602 GNOME_INCLUDEDIR="$GNOME_INCLUDEDIR -D_THREAD_SAFE"
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002603 GNOME_LIBS="$GNOME_LIBS -pthread"
2604 else
2605 AC_MSG_RESULT(no)
2606 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002607 $1
2608 else
2609 AC_MSG_RESULT(not found)
2610 if test "x$2" = xfail; then
2611 AC_MSG_ERROR(Could not find libgnomeui-2.0 via pkg-config)
2612 fi
2613 fi
2614 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002615 fi
2616])
2617
2618AC_DEFUN([GNOME_INIT],[
2619 GNOME_INIT_HOOK([],fail)
2620])
2621
2622
2623dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002624dnl Check for GTK2. If it fails, then continue on for Motif as before...
Bram Moolenaar071d4272004-06-13 20:20:40 +00002625dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002626if test -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002627
2628 AC_MSG_CHECKING(--disable-gtktest argument)
2629 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2630 , enable_gtktest=yes)
2631 if test "x$enable_gtktest" = "xyes" ; then
2632 AC_MSG_RESULT(gtk test enabled)
2633 else
2634 AC_MSG_RESULT(gtk test disabled)
2635 fi
2636
Bram Moolenaar071d4272004-06-13 20:20:40 +00002637 if test "X$PKG_CONFIG" = "X"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01002638 AC_PATH_TOOL(PKG_CONFIG, pkg-config, no)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002639 fi
2640
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002641 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002642 dnl First try finding version 2.2.0 or later. The 2.0.x series has
2643 dnl problems (bold fonts, --remote doesn't work).
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002644 AM_PATH_GTK(2.2.0,
2645 [GUI_LIB_LOC="$GTK_LIBDIR"
2646 GTK_LIBNAME="$GTK_LIBS"
2647 GUI_INC_LOC="$GTK_CFLAGS"], )
2648 if test "x$GTK_CFLAGS" != "x"; then
Bram Moolenaar98921892016-02-23 17:14:37 +01002649 SKIP_GTK3=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002650 SKIP_ATHENA=YES
2651 SKIP_NEXTAW=YES
2652 SKIP_MOTIF=YES
2653 GUITYPE=GTK
2654 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002655 fi
2656 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002657 if test "x$GUITYPE" = "xGTK"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002658 dnl
2659 dnl if GTK exists, then check for GNOME.
2660 dnl
2661 if test -z "$SKIP_GNOME"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002662 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002663 GNOME_INIT_HOOK([have_gnome=yes])
2664 if test "x$have_gnome" = xyes ; then
2665 AC_DEFINE(FEAT_GUI_GNOME)
2666 GUI_INC_LOC="$GUI_INC_LOC $GNOME_INCLUDEDIR"
2667 GTK_LIBNAME="$GTK_LIBNAME $GNOME_LIBDIR $GNOME_LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002668 fi
2669 }
2670 fi
2671 fi
2672fi
2673
Bram Moolenaar98921892016-02-23 17:14:37 +01002674
2675dnl ---------------------------------------------------------------------------
2676dnl Check for GTK3.
2677dnl ---------------------------------------------------------------------------
2678if test -z "$SKIP_GTK3"; then
2679
2680 AC_MSG_CHECKING(--disable-gtktest argument)
2681 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2682 , enable_gtktest=yes)
2683 if test "x$enable_gtktest" = "xyes" ; then
2684 AC_MSG_RESULT(gtk test enabled)
2685 else
2686 AC_MSG_RESULT(gtk test disabled)
2687 fi
2688
2689 if test "X$PKG_CONFIG" = "X"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01002690 AC_PATH_TOOL(PKG_CONFIG, pkg-config, no)
Bram Moolenaar98921892016-02-23 17:14:37 +01002691 fi
2692
2693 if test "x$PKG_CONFIG" != "xno"; then
2694 AM_PATH_GTK(3.0.0,
2695 [GUI_LIB_LOC="$GTK_LIBDIR"
2696 GTK_LIBNAME="$GTK_LIBS"
2697 GUI_INC_LOC="$GTK_CFLAGS"], )
2698 if test "x$GTK_CFLAGS" != "x"; then
2699 SKIP_GTK2=YES
2700 SKIP_GNOME=YES
2701 SKIP_ATHENA=YES
2702 SKIP_NEXTAW=YES
2703 SKIP_MOTIF=YES
2704 GUITYPE=GTK
2705 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar98921892016-02-23 17:14:37 +01002706 AC_DEFINE(USE_GTK3)
2707 fi
2708 fi
2709fi
2710
Bram Moolenaard2e03f02016-01-02 22:46:36 +01002711dnl Check the version of Gdk-Pixbuf. If the version is 2.31 or later and
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002712dnl glib-compile-resources is found in PATH, use GResource.
2713if test "x$GUITYPE" = "xGTK"; then
2714 AC_MSG_CHECKING([version of Gdk-Pixbuf])
2715 gdk_pixbuf_version=`$PKG_CONFIG --modversion gdk-pixbuf-2.0`
2716 if test "x$gdk_pixbuf_version" != x ; then
2717 gdk_pixbuf_version_minor=`echo $gdk_pixbuf_version | \
2718 sed -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/'`
2719 if test "x$gdk_pixbuf_version_minor" != x -a \
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002720 $gdk_pixbuf_version_minor -ge 31 ; then
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002721 AC_MSG_RESULT([OK.])
2722 AC_PATH_PROG(GLIB_COMPILE_RESOURCES,[glib-compile-resources],no)
2723 AC_MSG_CHECKING([glib-compile-resources])
2724 if test "x$GLIB_COMPILE_RESOURCES" = xno ; then
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002725 GLIB_COMPILE_RESOURCES=""
2726 AC_MSG_RESULT([cannot be found in PATH.])
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002727 else
2728 AC_MSG_RESULT([usable.])
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002729 AC_DEFINE(USE_GRESOURCE)
2730 GRESOURCE_SRC="auto/gui_gtk_gresources.c"
2731 GRESOURCE_OBJ="objects/gui_gtk_gresources.o"
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002732 fi
2733 else
2734 AC_MSG_RESULT([not usable.])
2735 fi
2736 else
2737 AC_MSG_RESULT([cannot obtain from pkg_config.])
2738 fi
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002739
2740 AC_MSG_CHECKING([--disable-icon-cache-update argument])
2741 AC_ARG_ENABLE(icon_cache_update,
2742 [ --disable-icon-cache-update update disabled],
2743 [],
2744 [enable_icon_cache_update="yes"])
2745 if test "$enable_icon_cache_update" = "yes"; then
2746 AC_MSG_RESULT([not set])
2747 AC_PATH_PROG(GTK_UPDATE_ICON_CACHE,[gtk-update-icon-cache],no)
2748 if test "x$GTK_UPDATE_ICON_CACHE" = "xno" ; then
2749 AC_MSG_RESULT([not found in PATH.])
2750 fi
2751 else
2752 AC_MSG_RESULT([update disabled])
2753 fi
2754
2755 AC_MSG_CHECKING([--disable-desktop-database-update argument])
2756 AC_ARG_ENABLE(desktop_database_update,
2757 [ --disable-desktop-database-update update disabled],
2758 [],
2759 [enable_desktop_database_update="yes"])
2760 if test "$enable_desktop_database_update" = "yes"; then
2761 AC_MSG_RESULT([not set])
2762 AC_PATH_PROG(UPDATE_DESKTOP_DATABASE,[update-desktop-database],no)
2763 if test "x$UPDATE_DESKTOP_DATABASE" = "xno" ; then
2764 AC_MSG_RESULT([not found in PATH.])
2765 fi
2766 else
2767 AC_MSG_RESULT([update disabled])
2768 fi
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002769fi
2770AC_SUBST(GLIB_COMPILE_RESOURCES)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002771AC_SUBST(GRESOURCE_SRC)
2772AC_SUBST(GRESOURCE_OBJ)
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002773AC_SUBST(GTK_UPDATE_ICON_CACHE)
2774AC_SUBST(UPDATE_DESKTOP_DATABASE)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002775
Bram Moolenaar071d4272004-06-13 20:20:40 +00002776dnl Check for Motif include files location.
2777dnl The LAST one found is used, this makes the highest version to be used,
2778dnl e.g. when Motif1.2 and Motif2.0 are both present.
2779
2780if test -z "$SKIP_MOTIF"; then
2781 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"
2782 dnl Remove "-I" from before $GUI_INC_LOC if it's there
2783 GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`"
2784
2785 AC_MSG_CHECKING(for location of Motif GUI includes)
2786 gui_includes="`echo $x_includes|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC"
2787 GUI_INC_LOC=
2788 for try in $gui_includes; do
2789 if test -f "$try/Xm/Xm.h"; then
2790 GUI_INC_LOC=$try
2791 fi
2792 done
2793 if test -n "$GUI_INC_LOC"; then
2794 if test "$GUI_INC_LOC" = /usr/include; then
2795 GUI_INC_LOC=
2796 AC_MSG_RESULT(in default path)
2797 else
2798 AC_MSG_RESULT($GUI_INC_LOC)
2799 fi
2800 else
2801 AC_MSG_RESULT(<not found>)
2802 SKIP_MOTIF=YES
2803 fi
2804fi
2805
2806dnl Check for Motif library files location. In the same order as the include
2807dnl files, to avoid a mixup if several versions are present
2808
2809if test -z "$SKIP_MOTIF"; then
2810 AC_MSG_CHECKING(--with-motif-lib argument)
2811 AC_ARG_WITH(motif-lib,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002812 [ --with-motif-lib=STRING Library for Motif ],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002813 [ MOTIF_LIBNAME="${withval}" ] )
2814
2815 if test -n "$MOTIF_LIBNAME"; then
2816 AC_MSG_RESULT($MOTIF_LIBNAME)
2817 GUI_LIB_LOC=
2818 else
2819 AC_MSG_RESULT(no)
2820
2821 dnl Remove "-L" from before $GUI_LIB_LOC if it's there
2822 GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
2823
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002824 dnl Ubuntu has libXm.so in /usr/lib/i386-linux-gnu and elsewhere. The
2825 dnl linker will figure out which one to use, we only check if one exists.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002826 AC_MSG_CHECKING(for location of Motif GUI libs)
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002827 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 +00002828 GUI_LIB_LOC=
2829 for try in $gui_libs; do
Bram Moolenaar325b7a22004-07-05 15:58:32 +00002830 for libtry in "$try"/libXm.a "$try"/libXm.so* "$try"/libXm.sl "$try"/libXm.dylib; do
Bram Moolenaar071d4272004-06-13 20:20:40 +00002831 if test -f "$libtry"; then
2832 GUI_LIB_LOC=$try
2833 fi
2834 done
2835 done
2836 if test -n "$GUI_LIB_LOC"; then
2837 dnl Remove /usr/lib, it causes trouble on some systems
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002838 if test "$GUI_LIB_LOC" = /usr/lib \
2839 -o "$GUI_LIB_LOC" = /usr/lib/i386-linux-gnu \
2840 -o "$GUI_LIB_LOC" = /usr/lib/x86_64-linux-gnu; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002841 GUI_LIB_LOC=
2842 AC_MSG_RESULT(in default path)
2843 else
2844 if test -n "$GUI_LIB_LOC"; then
2845 AC_MSG_RESULT($GUI_LIB_LOC)
2846 if test "`(uname) 2>/dev/null`" = SunOS &&
2847 uname -r | grep '^5' >/dev/null; then
2848 GUI_LIB_LOC="$GUI_LIB_LOC -R $GUI_LIB_LOC"
2849 fi
2850 fi
2851 fi
2852 MOTIF_LIBNAME=-lXm
2853 else
2854 AC_MSG_RESULT(<not found>)
2855 SKIP_MOTIF=YES
2856 fi
2857 fi
2858fi
2859
2860if test -z "$SKIP_MOTIF"; then
2861 SKIP_ATHENA=YES
2862 SKIP_NEXTAW=YES
2863 GUITYPE=MOTIF
2864 AC_SUBST(MOTIF_LIBNAME)
2865fi
2866
2867dnl Check if the Athena files can be found
2868
2869GUI_X_LIBS=
2870
2871if test -z "$SKIP_ATHENA"; then
2872 AC_MSG_CHECKING(if Athena header files can be found)
2873 cflags_save=$CFLAGS
2874 CFLAGS="$CFLAGS $X_CFLAGS"
2875 AC_TRY_COMPILE([
2876#include <X11/Intrinsic.h>
2877#include <X11/Xaw/Paned.h>], ,
2878 AC_MSG_RESULT(yes),
2879 AC_MSG_RESULT(no); SKIP_ATHENA=YES )
2880 CFLAGS=$cflags_save
2881fi
2882
2883if test -z "$SKIP_ATHENA"; then
2884 GUITYPE=ATHENA
2885fi
2886
2887if test -z "$SKIP_NEXTAW"; then
2888 AC_MSG_CHECKING(if neXtaw header files can be found)
2889 cflags_save=$CFLAGS
2890 CFLAGS="$CFLAGS $X_CFLAGS"
2891 AC_TRY_COMPILE([
2892#include <X11/Intrinsic.h>
2893#include <X11/neXtaw/Paned.h>], ,
2894 AC_MSG_RESULT(yes),
2895 AC_MSG_RESULT(no); SKIP_NEXTAW=YES )
2896 CFLAGS=$cflags_save
2897fi
2898
2899if test -z "$SKIP_NEXTAW"; then
2900 GUITYPE=NEXTAW
2901fi
2902
2903if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
2904 dnl Prepend -I and -L to $GUI_INC_LOC and $GUI_LIB_LOC if not empty
2905 dnl Avoid adding it when it twice
2906 if test -n "$GUI_INC_LOC"; then
2907 GUI_INC_LOC=-I"`echo $GUI_INC_LOC|sed 's%-I%%'`"
2908 fi
2909 if test -n "$GUI_LIB_LOC"; then
2910 GUI_LIB_LOC=-L"`echo $GUI_LIB_LOC|sed 's%-L%%'`"
2911 fi
2912
2913 dnl Check for -lXext and then for -lXmu
2914 ldflags_save=$LDFLAGS
2915 LDFLAGS="$X_LIBS $LDFLAGS"
2916 AC_CHECK_LIB(Xext, XShapeQueryExtension, [GUI_X_LIBS="-lXext"],,
2917 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2918 dnl For Solaris we need -lw and -ldl before linking with -lXmu works.
2919 AC_CHECK_LIB(w, wslen, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lw"],,
2920 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2921 AC_CHECK_LIB(dl, dlsym, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldl"],,
2922 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2923 AC_CHECK_LIB(Xmu, XmuCreateStippledPixmap, [GUI_X_LIBS="-lXmu $GUI_X_LIBS"],,
2924 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2925 if test -z "$SKIP_MOTIF"; then
2926 AC_CHECK_LIB(Xp, XpEndJob, [GUI_X_LIBS="-lXp $GUI_X_LIBS"],,
2927 [$GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2928 fi
2929 LDFLAGS=$ldflags_save
2930
2931 dnl Execute xmkmf to figure out if -DNARROWPROTO is needed.
2932 AC_MSG_CHECKING(for extra X11 defines)
2933 NARROW_PROTO=
2934 rm -fr conftestdir
2935 if mkdir conftestdir; then
2936 cd conftestdir
2937 cat > Imakefile <<'EOF'
2938acfindx:
2939 @echo 'NARROW_PROTO="${PROTO_DEFINES}"'
2940EOF
2941 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
2942 eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
2943 fi
2944 cd ..
2945 rm -fr conftestdir
2946 fi
2947 if test -z "$NARROW_PROTO"; then
2948 AC_MSG_RESULT(no)
2949 else
2950 AC_MSG_RESULT($NARROW_PROTO)
2951 fi
2952 AC_SUBST(NARROW_PROTO)
2953fi
2954
2955dnl Look for XSMP support - but don't necessarily restrict it to X11 GUIs
2956dnl use the X11 include path
2957if test "$enable_xsmp" = "yes"; then
2958 cppflags_save=$CPPFLAGS
2959 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2960 AC_CHECK_HEADERS(X11/SM/SMlib.h)
2961 CPPFLAGS=$cppflags_save
2962fi
2963
2964
Bram Moolenaar98921892016-02-23 17:14:37 +01002965if 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 +00002966 dnl Check for X11/xpm.h and X11/Sunkeysym.h with the GUI include path
2967 cppflags_save=$CPPFLAGS
2968 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2969 AC_CHECK_HEADERS(X11/xpm.h X11/Sunkeysym.h)
2970
2971 dnl automatically disable XIM when XIMtext isn't in X11/Xlib.h
2972 if test ! "$enable_xim" = "no"; then
2973 AC_MSG_CHECKING(for XIMText in X11/Xlib.h)
2974 AC_EGREP_CPP(XIMText, [#include <X11/Xlib.h>],
2975 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +02002976 AC_MSG_RESULT(no; xim has been disabled); enable_xim="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00002977 fi
2978 CPPFLAGS=$cppflags_save
2979
2980 dnl automatically enable XIM when hangul input isn't enabled
2981 if test "$enable_xim" = "auto" -a "$enable_hangulinput" != "yes" \
2982 -a "x$GUITYPE" != "xNONE" ; then
2983 AC_MSG_RESULT(X GUI selected; xim has been enabled)
2984 enable_xim="yes"
2985 fi
2986fi
2987
2988if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
2989 cppflags_save=$CPPFLAGS
2990 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00002991dnl Xmu/Editres.h may exist but can only be used after including Intrinsic.h
2992 AC_MSG_CHECKING([for X11/Xmu/Editres.h])
2993 AC_TRY_COMPILE([
2994#include <X11/Intrinsic.h>
2995#include <X11/Xmu/Editres.h>],
2996 [int i; i = 0;],
2997 AC_MSG_RESULT(yes)
2998 AC_DEFINE(HAVE_X11_XMU_EDITRES_H),
2999 AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003000 CPPFLAGS=$cppflags_save
3001fi
3002
3003dnl Only use the Xm directory when compiling Motif, don't use it for Athena
3004if test -z "$SKIP_MOTIF"; then
3005 cppflags_save=$CPPFLAGS
3006 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003007 if test "$zOSUnix" = "yes"; then
3008 xmheader="Xm/Xm.h"
3009 else
3010 xmheader="Xm/Xm.h Xm/XpmP.h Xm/JoinSideT.h Xm/TraitP.h Xm/Manager.h
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02003011 Xm/UnhighlightT.h Xm/Notebook.h"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003012 fi
3013 AC_CHECK_HEADERS($xmheader)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003014
Bram Moolenaar77c19352012-06-13 19:19:41 +02003015 if test "x$ac_cv_header_Xm_XpmP_h" = "xyes"; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003016 dnl Solaris uses XpmAttributes_21, very annoying.
3017 AC_MSG_CHECKING([for XpmAttributes_21 in Xm/XpmP.h])
3018 AC_TRY_COMPILE([#include <Xm/XpmP.h>], [XpmAttributes_21 attr;],
3019 AC_MSG_RESULT(yes); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes_21),
3020 AC_MSG_RESULT(no); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
3021 )
3022 else
Bram Moolenaar57657d82006-04-21 22:12:41 +00003023 AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003024 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003025 CPPFLAGS=$cppflags_save
3026fi
3027
3028if test "x$GUITYPE" = "xNONE" -a "$enable_xim" = "yes"; then
3029 AC_MSG_RESULT(no GUI selected; xim has been disabled)
3030 enable_xim="no"
3031fi
3032if test "x$GUITYPE" = "xNONE" -a "$enable_fontset" = "yes"; then
3033 AC_MSG_RESULT(no GUI selected; fontset has been disabled)
3034 enable_fontset="no"
3035fi
Bram Moolenaar182c5be2010-06-25 05:37:59 +02003036if test "x$GUITYPE:$enable_fontset" = "xGTK:yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003037 AC_MSG_RESULT(GTK+ 2 GUI selected; fontset has been disabled)
3038 enable_fontset="no"
3039fi
3040
Bram Moolenaar071d4272004-06-13 20:20:40 +00003041if test -z "$SKIP_PHOTON"; then
3042 GUITYPE=PHOTONGUI
3043fi
3044
3045AC_SUBST(GUI_INC_LOC)
3046AC_SUBST(GUI_LIB_LOC)
3047AC_SUBST(GUITYPE)
3048AC_SUBST(GUI_X_LIBS)
3049
3050if test "$enable_workshop" = "yes" -a -n "$SKIP_MOTIF"; then
3051 AC_MSG_ERROR([cannot use workshop without Motif])
3052fi
3053
3054dnl defining FEAT_XIM and FEAT_XFONTSET is delayed, so that they can be disabled
3055if test "$enable_xim" = "yes"; then
3056 AC_DEFINE(FEAT_XIM)
3057fi
3058if test "$enable_fontset" = "yes"; then
3059 AC_DEFINE(FEAT_XFONTSET)
3060fi
3061
3062
3063dnl ---------------------------------------------------------------------------
3064dnl end of GUI-checking
3065dnl ---------------------------------------------------------------------------
3066
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003067AC_MSG_CHECKING([for /proc link to executable])
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003068if test -L "/proc/self/exe"; then
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003069 dnl Linux
3070 AC_MSG_RESULT([/proc/self/exe])
3071 AC_DEFINE(PROC_EXE_LINK, "/proc/self/exe")
3072elif test -L "/proc/self/path/a.out"; then
3073 dnl Solaris
3074 AC_MSG_RESULT([/proc/self/path/a.out])
3075 AC_DEFINE(PROC_EXE_LINK, "/proc/self/path/a.out")
3076elif test -L "/proc/curproc/file"; then
3077 dnl FreeBSD
3078 AC_MSG_RESULT([/proc/curproc/file])
3079 AC_DEFINE(PROC_EXE_LINK, "/proc/curproc/file")
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003080else
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003081 AC_MSG_RESULT(no)
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003082fi
3083
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003084dnl Check for Cygwin, which needs an extra source file if not using X11
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003085AC_MSG_CHECKING(for CYGWIN or MSYS environment)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003086case `uname` in
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003087 CYGWIN*|MSYS*) CYGWIN=yes; AC_MSG_RESULT(yes)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003088 AC_MSG_CHECKING(for CYGWIN clipboard support)
3089 if test "x$with_x" = "xno" ; then
3090 OS_EXTRA_SRC=winclip.c; OS_EXTRA_OBJ=objects/winclip.o
3091 AC_MSG_RESULT(yes)
3092 AC_DEFINE(FEAT_CYGWIN_WIN32_CLIPBOARD)
3093 else
3094 AC_MSG_RESULT(no - using X11)
3095 fi ;;
3096
3097 *) CYGWIN=no; AC_MSG_RESULT(no);;
3098esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00003099
3100dnl Only really enable hangul input when GUI and XFONTSET are available
3101if test "$enable_hangulinput" = "yes"; then
3102 if test "x$GUITYPE" = "xNONE"; then
3103 AC_MSG_RESULT(no GUI selected; hangul input has been disabled)
3104 enable_hangulinput=no
3105 else
3106 AC_DEFINE(FEAT_HANGULIN)
3107 HANGULIN_SRC=hangulin.c
3108 AC_SUBST(HANGULIN_SRC)
3109 HANGULIN_OBJ=objects/hangulin.o
3110 AC_SUBST(HANGULIN_OBJ)
3111 fi
3112fi
3113
3114dnl Checks for libraries and include files.
3115
Bram Moolenaar446cb832008-06-24 21:56:24 +00003116AC_CACHE_CHECK([whether toupper is broken], [vim_cv_toupper_broken],
3117 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003118 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003119#include "confdefs.h"
3120#include <ctype.h>
3121#if STDC_HEADERS
3122# include <stdlib.h>
3123# include <stddef.h>
3124#endif
3125main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003126 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003127 vim_cv_toupper_broken=yes
3128 ],[
3129 vim_cv_toupper_broken=no
3130 ],[
3131 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_toupper_broken')
3132 ])])
3133
3134if test "x$vim_cv_toupper_broken" = "xyes" ; then
3135 AC_DEFINE(BROKEN_TOUPPER)
3136fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003137
3138AC_MSG_CHECKING(whether __DATE__ and __TIME__ work)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003139AC_TRY_COMPILE([#include <stdio.h>], [printf("(" __DATE__ " " __TIME__ ")");],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003140 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DATE_TIME),
3141 AC_MSG_RESULT(no))
3142
Bram Moolenaar0c094b92009-05-14 20:20:33 +00003143AC_MSG_CHECKING(whether __attribute__((unused)) is allowed)
3144AC_TRY_COMPILE([#include <stdio.h>], [int x __attribute__((unused));],
3145 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ATTRIBUTE_UNUSED),
3146 AC_MSG_RESULT(no))
3147
Bram Moolenaar071d4272004-06-13 20:20:40 +00003148dnl Checks for header files.
3149AC_CHECK_HEADER(elf.h, HAS_ELF=1)
3150dnl AC_CHECK_HEADER(dwarf.h, SVR4=1)
3151if test "$HAS_ELF" = 1; then
3152 AC_CHECK_LIB(elf, main)
3153fi
3154
3155AC_HEADER_DIRENT
3156
Bram Moolenaar071d4272004-06-13 20:20:40 +00003157dnl If sys/wait.h is not found it might still exist but not be POSIX
3158dnl compliant. In that case we define HAVE_UNION_WAIT (for NeXT)
3159if test $ac_cv_header_sys_wait_h = no; then
3160 AC_MSG_CHECKING([for sys/wait.h that defines union wait])
3161 AC_TRY_COMPILE([#include <sys/wait.h>],
3162 [union wait xx, yy; xx = yy],
3163 AC_MSG_RESULT(yes)
3164 AC_DEFINE(HAVE_SYS_WAIT_H)
3165 AC_DEFINE(HAVE_UNION_WAIT),
3166 AC_MSG_RESULT(no))
3167fi
3168
Bram Moolenaar779a7752016-01-30 23:26:34 +01003169AC_CHECK_HEADERS(stdint.h stdlib.h string.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003170 sys/select.h sys/utsname.h termcap.h fcntl.h \
3171 sgtty.h sys/ioctl.h sys/time.h sys/types.h \
3172 termio.h iconv.h inttypes.h langinfo.h math.h \
3173 unistd.h stropts.h errno.h sys/resource.h \
3174 sys/systeminfo.h locale.h sys/stream.h termios.h \
3175 libc.h sys/statfs.h poll.h sys/poll.h pwd.h \
3176 utime.h sys/param.h libintl.h libgen.h \
3177 util/debug.h util/msg18n.h frame.h sys/acl.h \
3178 sys/access.h sys/sysinfo.h wchar.h wctype.h)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003179
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003180dnl sys/ptem.h depends on sys/stream.h on Solaris
3181AC_CHECK_HEADERS(sys/ptem.h, [], [],
3182[#if defined HAVE_SYS_STREAM_H
3183# include <sys/stream.h>
3184#endif])
3185
Bram Moolenaar32f31b12009-05-21 13:20:59 +00003186dnl sys/sysctl.h depends on sys/param.h on OpenBSD
3187AC_CHECK_HEADERS(sys/sysctl.h, [], [],
3188[#if defined HAVE_SYS_PARAM_H
3189# include <sys/param.h>
3190#endif])
3191
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003192
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003193dnl pthread_np.h may exist but can only be used after including pthread.h
3194AC_MSG_CHECKING([for pthread_np.h])
3195AC_TRY_COMPILE([
3196#include <pthread.h>
3197#include <pthread_np.h>],
3198 [int i; i = 0;],
3199 AC_MSG_RESULT(yes)
3200 AC_DEFINE(HAVE_PTHREAD_NP_H),
3201 AC_MSG_RESULT(no))
3202
Bram Moolenaare344bea2005-09-01 20:46:49 +00003203AC_CHECK_HEADERS(strings.h)
Bram Moolenaard0573012017-10-28 21:11:06 +02003204if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00003205 dnl The strings.h file on OS/X contains a warning and nothing useful.
3206 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3207else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003208
3209dnl Check if strings.h and string.h can both be included when defined.
3210AC_MSG_CHECKING([if strings.h can be included after string.h])
3211cppflags_save=$CPPFLAGS
3212CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3213AC_TRY_COMPILE([
3214#if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO)
3215# define _NO_PROTO /* like in os_unix.h, causes conflict for AIX (Winn) */
3216 /* but don't do it on AIX 5.1 (Uribarri) */
3217#endif
3218#ifdef HAVE_XM_XM_H
3219# include <Xm/Xm.h> /* This breaks it for HP-UX 11 (Squassabia) */
3220#endif
3221#ifdef HAVE_STRING_H
3222# include <string.h>
3223#endif
3224#if defined(HAVE_STRINGS_H)
3225# include <strings.h>
3226#endif
3227 ], [int i; i = 0;],
3228 AC_MSG_RESULT(yes),
3229 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3230 AC_MSG_RESULT(no))
3231CPPFLAGS=$cppflags_save
Bram Moolenaar9372a112005-12-06 19:59:18 +00003232fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003233
3234dnl Checks for typedefs, structures, and compiler characteristics.
3235AC_PROG_GCC_TRADITIONAL
3236AC_C_CONST
Bram Moolenaar76243bd2009-03-02 01:47:02 +00003237AC_C_VOLATILE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003238AC_TYPE_MODE_T
3239AC_TYPE_OFF_T
3240AC_TYPE_PID_T
3241AC_TYPE_SIZE_T
3242AC_TYPE_UID_T
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003243AC_TYPE_UINT32_T
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003244
Bram Moolenaar071d4272004-06-13 20:20:40 +00003245AC_HEADER_TIME
3246AC_CHECK_TYPE(ino_t, long)
3247AC_CHECK_TYPE(dev_t, unsigned)
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003248AC_C_BIGENDIAN(,,,)
Bram Moolenaar136f29a2016-02-27 20:14:15 +01003249AC_C_INLINE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003250
3251AC_MSG_CHECKING(for rlim_t)
3252if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
3253 AC_MSG_RESULT([(cached) $ac_cv_type_rlim_t])
3254else
3255 AC_EGREP_CPP(dnl
3256changequote(<<,>>)dnl
3257<<(^|[^a-zA-Z_0-9])rlim_t[^a-zA-Z_0-9]>>dnl
3258changequote([,]),
3259 [
3260#include <sys/types.h>
3261#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003262# include <stdlib.h>
3263# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003264#endif
3265#ifdef HAVE_SYS_RESOURCE_H
Bram Moolenaar446cb832008-06-24 21:56:24 +00003266# include <sys/resource.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003267#endif
3268 ], ac_cv_type_rlim_t=yes, ac_cv_type_rlim_t=no)
3269 AC_MSG_RESULT($ac_cv_type_rlim_t)
3270fi
3271if test $ac_cv_type_rlim_t = no; then
3272 cat >> confdefs.h <<\EOF
3273#define rlim_t unsigned long
3274EOF
3275fi
3276
3277AC_MSG_CHECKING(for stack_t)
3278if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then
3279 AC_MSG_RESULT([(cached) $ac_cv_type_stack_t])
3280else
3281 AC_EGREP_CPP(stack_t,
3282 [
3283#include <sys/types.h>
3284#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003285# include <stdlib.h>
3286# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003287#endif
3288#include <signal.h>
3289 ], ac_cv_type_stack_t=yes, ac_cv_type_stack_t=no)
3290 AC_MSG_RESULT($ac_cv_type_stack_t)
3291fi
3292if test $ac_cv_type_stack_t = no; then
3293 cat >> confdefs.h <<\EOF
3294#define stack_t struct sigaltstack
3295EOF
3296fi
3297
3298dnl BSDI uses ss_base while others use ss_sp for the stack pointer.
3299AC_MSG_CHECKING(whether stack_t has an ss_base field)
3300AC_TRY_COMPILE([
3301#include <sys/types.h>
3302#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003303# include <stdlib.h>
3304# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003305#endif
3306#include <signal.h>
3307#include "confdefs.h"
3308 ], [stack_t sigstk; sigstk.ss_base = 0; ],
3309 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SS_BASE),
3310 AC_MSG_RESULT(no))
3311
3312olibs="$LIBS"
3313AC_MSG_CHECKING(--with-tlib argument)
3314AC_ARG_WITH(tlib, [ --with-tlib=library terminal library to be used ],)
3315if test -n "$with_tlib"; then
3316 AC_MSG_RESULT($with_tlib)
3317 LIBS="$LIBS -l$with_tlib"
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003318 AC_MSG_CHECKING(for linking with $with_tlib library)
3319 AC_TRY_LINK([], [], AC_MSG_RESULT(OK), AC_MSG_ERROR(FAILED))
3320 dnl Need to check for tgetent() below.
3321 olibs="$LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003322else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003323 AC_MSG_RESULT([empty: automatic terminal library selection])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003324 dnl On HP-UX 10.10 termcap or termlib should be used instead of
3325 dnl curses, because curses is much slower.
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003326 dnl Newer versions of ncurses are preferred over anything, except
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02003327 dnl when tinfo has been split off, it contains all we need.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003328 dnl Older versions of ncurses have bugs, get a new one!
3329 dnl Digital Unix (OSF1) should use curses (Ronald Schild).
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00003330 dnl On SCO Openserver should prefer termlib (Roger Cornelius).
Bram Moolenaar071d4272004-06-13 20:20:40 +00003331 case "`uname -s 2>/dev/null`" in
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003332 OSF1|SCO_SV) tlibs="tinfo ncurses curses termlib termcap";;
3333 *) tlibs="tinfo ncurses termlib termcap curses";;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003334 esac
3335 for libname in $tlibs; do
3336 AC_CHECK_LIB(${libname}, tgetent,,)
3337 if test "x$olibs" != "x$LIBS"; then
3338 dnl It's possible that a library is found but it doesn't work
3339 dnl e.g., shared library that cannot be found
3340 dnl compile and run a test program to be sure
3341 AC_TRY_RUN([
3342#ifdef HAVE_TERMCAP_H
3343# include <termcap.h>
3344#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003345#if STDC_HEADERS
3346# include <stdlib.h>
3347# include <stddef.h>
3348#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003349main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }],
3350 res="OK", res="FAIL", res="FAIL")
3351 if test "$res" = "OK"; then
3352 break
3353 fi
3354 AC_MSG_RESULT($libname library is not usable)
3355 LIBS="$olibs"
3356 fi
3357 done
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003358 if test "x$olibs" = "x$LIBS"; then
3359 AC_MSG_RESULT(no terminal library found)
3360 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003361fi
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003362
3363if test "x$olibs" = "x$LIBS"; then
3364 AC_MSG_CHECKING([for tgetent()])
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00003365 AC_TRY_LINK([],
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003366 [char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");],
3367 AC_MSG_RESULT(yes),
3368 AC_MSG_ERROR([NOT FOUND!
3369 You need to install a terminal library; for example ncurses.
3370 Or specify the name of the library with --with-tlib.]))
3371fi
3372
Bram Moolenaar446cb832008-06-24 21:56:24 +00003373AC_CACHE_CHECK([whether we talk terminfo], [vim_cv_terminfo],
3374 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003375 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003376#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003377#ifdef HAVE_TERMCAP_H
3378# include <termcap.h>
3379#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003380#ifdef HAVE_STRING_H
3381# include <string.h>
3382#endif
3383#if STDC_HEADERS
3384# include <stdlib.h>
3385# include <stddef.h>
3386#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003387main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003388{char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003389 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003390 vim_cv_terminfo=no
3391 ],[
3392 vim_cv_terminfo=yes
3393 ],[
3394 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_terminfo')
3395 ])
3396 ])
3397
3398if test "x$vim_cv_terminfo" = "xyes" ; then
3399 AC_DEFINE(TERMINFO)
3400fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003401
Bram Moolenaara88254f2017-11-02 23:04:14 +01003402AC_CACHE_CHECK([what tgetent() returns for an unknown terminal], [vim_cv_tgetent],
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003403 [
3404 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003405#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003406#ifdef HAVE_TERMCAP_H
3407# include <termcap.h>
3408#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003409#if STDC_HEADERS
3410# include <stdlib.h>
3411# include <stddef.h>
3412#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003413main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003414{char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003415 ]])],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003416 vim_cv_tgetent=zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003417 ],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003418 vim_cv_tgetent=non-zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003419 ],[
3420 AC_MSG_ERROR(failed to compile test program.)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003421 ])
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003422 ])
3423
Bram Moolenaara88254f2017-11-02 23:04:14 +01003424if test "x$vim_cv_tgetent" = "xzero" ; then
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003425 AC_DEFINE(TGETENT_ZERO_ERR, 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003426fi
3427
3428AC_MSG_CHECKING(whether termcap.h contains ospeed)
3429AC_TRY_LINK([
3430#ifdef HAVE_TERMCAP_H
3431# include <termcap.h>
3432#endif
3433 ], [ospeed = 20000],
3434 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED),
3435 [AC_MSG_RESULT(no)
3436 AC_MSG_CHECKING(whether ospeed can be extern)
3437 AC_TRY_LINK([
3438#ifdef HAVE_TERMCAP_H
3439# include <termcap.h>
3440#endif
3441extern short ospeed;
3442 ], [ospeed = 20000],
3443 AC_MSG_RESULT(yes); AC_DEFINE(OSPEED_EXTERN),
3444 AC_MSG_RESULT(no))]
3445 )
3446
3447AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC])
3448AC_TRY_LINK([
3449#ifdef HAVE_TERMCAP_H
3450# include <termcap.h>
3451#endif
3452 ], [if (UP == 0 && BC == 0) PC = 1],
3453 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UP_BC_PC),
3454 [AC_MSG_RESULT(no)
3455 AC_MSG_CHECKING([whether UP, BC and PC can be extern])
3456 AC_TRY_LINK([
3457#ifdef HAVE_TERMCAP_H
3458# include <termcap.h>
3459#endif
3460extern char *UP, *BC, PC;
3461 ], [if (UP == 0 && BC == 0) PC = 1],
3462 AC_MSG_RESULT(yes); AC_DEFINE(UP_BC_PC_EXTERN),
3463 AC_MSG_RESULT(no))]
3464 )
3465
3466AC_MSG_CHECKING(whether tputs() uses outfuntype)
3467AC_TRY_COMPILE([
3468#ifdef HAVE_TERMCAP_H
3469# include <termcap.h>
3470#endif
3471 ], [extern int xx(); tputs("test", 1, (outfuntype)xx)],
3472 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OUTFUNTYPE),
3473 AC_MSG_RESULT(no))
3474
3475dnl On some SCO machines sys/select redefines struct timeval
3476AC_MSG_CHECKING([whether sys/select.h and sys/time.h may both be included])
3477AC_TRY_COMPILE([
3478#include <sys/types.h>
3479#include <sys/time.h>
3480#include <sys/select.h>], ,
3481 AC_MSG_RESULT(yes)
3482 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME),
3483 AC_MSG_RESULT(no))
3484
3485dnl AC_DECL_SYS_SIGLIST
3486
3487dnl Checks for pty.c (copied from screen) ==========================
3488AC_MSG_CHECKING(for /dev/ptc)
3489if test -r /dev/ptc; then
3490 AC_DEFINE(HAVE_DEV_PTC)
3491 AC_MSG_RESULT(yes)
3492else
3493 AC_MSG_RESULT(no)
3494fi
3495
3496AC_MSG_CHECKING(for SVR4 ptys)
3497if test -c /dev/ptmx ; then
3498 AC_TRY_LINK([], [ptsname(0);grantpt(0);unlockpt(0);],
3499 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SVR4_PTYS),
3500 AC_MSG_RESULT(no))
3501else
3502 AC_MSG_RESULT(no)
3503fi
3504
3505AC_MSG_CHECKING(for ptyranges)
3506if test -d /dev/ptym ; then
3507 pdir='/dev/ptym'
3508else
3509 pdir='/dev'
3510fi
3511dnl SCO uses ptyp%d
3512AC_EGREP_CPP(yes,
3513[#ifdef M_UNIX
3514 yes;
3515#endif
3516 ], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
3517dnl if test -c /dev/ptyp19; then
3518dnl ptys=`echo /dev/ptyp??`
3519dnl else
3520dnl ptys=`echo $pdir/pty??`
3521dnl fi
3522if test "$ptys" != "$pdir/pty??" ; then
3523 p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
3524 p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'`
3525 AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
3526 AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
3527 AC_MSG_RESULT([$p0 / $p1])
3528else
3529 AC_MSG_RESULT([don't know])
3530fi
3531
3532dnl **** pty mode/group handling ****
3533dnl
3534dnl support provided by Luke Mewburn <lm@rmit.edu.au>, 931222
Bram Moolenaar071d4272004-06-13 20:20:40 +00003535rm -f conftest_grp
Bram Moolenaar446cb832008-06-24 21:56:24 +00003536AC_CACHE_CHECK([default tty permissions/group], [vim_cv_tty_group],
3537 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003538 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003539#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003540#include <sys/types.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003541#if STDC_HEADERS
3542# include <stdlib.h>
3543# include <stddef.h>
3544#endif
3545#ifdef HAVE_UNISTD_H
3546#include <unistd.h>
3547#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003548#include <sys/stat.h>
3549#include <stdio.h>
3550main()
3551{
3552 struct stat sb;
3553 char *x,*ttyname();
3554 int om, m;
3555 FILE *fp;
3556
3557 if (!(x = ttyname(0))) exit(1);
3558 if (stat(x, &sb)) exit(1);
3559 om = sb.st_mode;
3560 if (om & 002) exit(0);
3561 m = system("mesg y");
3562 if (m == -1 || m == 127) exit(1);
3563 if (stat(x, &sb)) exit(1);
3564 m = sb.st_mode;
3565 if (chmod(x, om)) exit(1);
3566 if (m & 002) exit(0);
3567 if (sb.st_gid == getgid()) exit(1);
3568 if (!(fp=fopen("conftest_grp", "w")))
3569 exit(1);
3570 fprintf(fp, "%d\n", sb.st_gid);
3571 fclose(fp);
3572 exit(0);
3573}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003574 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003575 if test -f conftest_grp; then
3576 vim_cv_tty_group=`cat conftest_grp`
3577 if test "x$vim_cv_tty_mode" = "x" ; then
3578 vim_cv_tty_mode=0620
3579 fi
3580 AC_MSG_RESULT([pty mode: $vim_cv_tty_mode, group: $vim_cv_tty_group])
3581 else
3582 vim_cv_tty_group=world
Bram Moolenaar72951072009-12-02 16:58:33 +00003583 AC_MSG_RESULT([ptys are world accessible])
Bram Moolenaar446cb832008-06-24 21:56:24 +00003584 fi
3585 ],[
3586 vim_cv_tty_group=world
Bram Moolenaar72951072009-12-02 16:58:33 +00003587 AC_MSG_RESULT([can't determine - assume ptys are world accessible])
Bram Moolenaar446cb832008-06-24 21:56:24 +00003588 ],[
3589 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_tty_group' and 'vim_cv_tty_mode')
3590 ])
3591 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003592rm -f conftest_grp
3593
Bram Moolenaar446cb832008-06-24 21:56:24 +00003594if test "x$vim_cv_tty_group" != "xworld" ; then
3595 AC_DEFINE_UNQUOTED(PTYGROUP,$vim_cv_tty_group)
3596 if test "x$vim_cv_tty_mode" = "x" ; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02003597 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 +00003598 else
3599 AC_DEFINE(PTYMODE, 0620)
3600 fi
3601fi
3602
Bram Moolenaar071d4272004-06-13 20:20:40 +00003603dnl Checks for library functions. ===================================
3604
3605AC_TYPE_SIGNAL
3606
3607dnl find out what to use at the end of a signal function
3608if test $ac_cv_type_signal = void; then
3609 AC_DEFINE(SIGRETURN, [return])
3610else
3611 AC_DEFINE(SIGRETURN, [return 0])
3612fi
3613
3614dnl check if struct sigcontext is defined (used for SGI only)
3615AC_MSG_CHECKING(for struct sigcontext)
3616AC_TRY_COMPILE([
3617#include <signal.h>
3618test_sig()
3619{
3620 struct sigcontext *scont;
3621 scont = (struct sigcontext *)0;
3622 return 1;
3623} ], ,
3624 AC_MSG_RESULT(yes)
3625 AC_DEFINE(HAVE_SIGCONTEXT),
3626 AC_MSG_RESULT(no))
3627
3628dnl tricky stuff: try to find out if getcwd() is implemented with
3629dnl system("sh -c pwd")
Bram Moolenaar446cb832008-06-24 21:56:24 +00003630AC_CACHE_CHECK([getcwd implementation is broken], [vim_cv_getcwd_broken],
3631 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003632 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003633#include "confdefs.h"
3634#ifdef HAVE_UNISTD_H
3635#include <unistd.h>
3636#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003637char *dagger[] = { "IFS=pwd", 0 };
3638main()
3639{
3640 char buffer[500];
3641 extern char **environ;
3642 environ = dagger;
3643 return getcwd(buffer, 500) ? 0 : 1;
Bram Moolenaar446cb832008-06-24 21:56:24 +00003644}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003645 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003646 vim_cv_getcwd_broken=no
3647 ],[
3648 vim_cv_getcwd_broken=yes
3649 ],[
3650 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_getcwd_broken')
3651 ])
3652 ])
3653
3654if test "x$vim_cv_getcwd_broken" = "xyes" ; then
3655 AC_DEFINE(BAD_GETCWD)
3656fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003657
Bram Moolenaar25153e12010-02-24 14:47:08 +01003658dnl Check for functions in one big call, to reduce the size of configure.
3659dnl Can only be used for functions that do not require any include.
Bram Moolenaarcd142e32017-11-16 17:03:45 +01003660AC_CHECK_FUNCS(fchdir fchown fchmod fsync getcwd getpseudotty \
Bram Moolenaarb129a442016-12-01 17:25:20 +01003661 getpwent getpwnam getpwuid getrlimit gettimeofday getwd lstat \
Bram Moolenaareaf03392009-11-17 11:08:52 +00003662 memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
Bram Moolenaar2fcf6682017-03-11 20:03:42 +01003663 getpgid setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
Bram Moolenaarbb09ceb2016-10-18 16:27:23 +02003664 sigprocmask sigvec strcasecmp strerror strftime stricmp strncasecmp \
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00003665 strnicmp strpbrk strtol tgetent towlower towupper iswupper \
Bram Moolenaarcd142e32017-11-16 17:03:45 +01003666 usleep utime utimes mblen ftruncate)
Bram Moolenaar25153e12010-02-24 14:47:08 +01003667AC_FUNC_FSEEKO
Bram Moolenaar071d4272004-06-13 20:20:40 +00003668
Bram Moolenaar317fd3a2010-05-07 16:05:55 +02003669dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when
3670dnl appropriate, so that off_t is 64 bits when needed.
3671AC_SYS_LARGEFILE
3672
Bram Moolenaar071d4272004-06-13 20:20:40 +00003673dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible
3674AC_MSG_CHECKING(for st_blksize)
3675AC_TRY_COMPILE(
3676[#include <sys/types.h>
3677#include <sys/stat.h>],
3678[ struct stat st;
3679 int n;
3680
3681 stat("/", &st);
3682 n = (int)st.st_blksize;],
3683 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ST_BLKSIZE),
3684 AC_MSG_RESULT(no))
3685
Bram Moolenaar446cb832008-06-24 21:56:24 +00003686AC_CACHE_CHECK([whether stat() ignores a trailing slash], [vim_cv_stat_ignores_slash],
3687 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003688 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003689#include "confdefs.h"
3690#if STDC_HEADERS
3691# include <stdlib.h>
3692# include <stddef.h>
3693#endif
3694#include <sys/types.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003695#include <sys/stat.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003696main() {struct stat st; exit(stat("configure/", &st) != 0); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003697 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003698 vim_cv_stat_ignores_slash=yes
3699 ],[
3700 vim_cv_stat_ignores_slash=no
3701 ],[
3702 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_stat_ignores_slash')
3703 ])
3704 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003705
Bram Moolenaar446cb832008-06-24 21:56:24 +00003706if test "x$vim_cv_stat_ignores_slash" = "xyes" ; then
3707 AC_DEFINE(STAT_IGNORES_SLASH)
3708fi
3709
Bram Moolenaar071d4272004-06-13 20:20:40 +00003710dnl Link with iconv for charset translation, if not found without library.
3711dnl check for iconv() requires including iconv.h
3712dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
3713dnl has been installed.
3714AC_MSG_CHECKING(for iconv_open())
3715save_LIBS="$LIBS"
3716LIBS="$LIBS -liconv"
3717AC_TRY_LINK([
3718#ifdef HAVE_ICONV_H
3719# include <iconv.h>
3720#endif
3721 ], [iconv_open("fr", "to");],
3722 AC_MSG_RESULT(yes; with -liconv); AC_DEFINE(HAVE_ICONV),
3723 LIBS="$save_LIBS"
3724 AC_TRY_LINK([
3725#ifdef HAVE_ICONV_H
3726# include <iconv.h>
3727#endif
3728 ], [iconv_open("fr", "to");],
3729 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ICONV),
3730 AC_MSG_RESULT(no)))
3731
3732
3733AC_MSG_CHECKING(for nl_langinfo(CODESET))
3734AC_TRY_LINK([
3735#ifdef HAVE_LANGINFO_H
3736# include <langinfo.h>
3737#endif
3738], [char *cs = nl_langinfo(CODESET);],
3739 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET),
3740 AC_MSG_RESULT(no))
3741
Bram Moolenaar446cb832008-06-24 21:56:24 +00003742dnl Need various functions for floating point support. Only enable
3743dnl floating point when they are all present.
3744AC_CHECK_LIB(m, strtod)
3745AC_MSG_CHECKING([for strtod() and other floating point functions])
3746AC_TRY_LINK([
3747#ifdef HAVE_MATH_H
3748# include <math.h>
3749#endif
3750#if STDC_HEADERS
3751# include <stdlib.h>
3752# include <stddef.h>
3753#endif
3754], [char *s; double d;
3755 d = strtod("1.1", &s);
3756 d = fabs(1.11);
3757 d = ceil(1.11);
3758 d = floor(1.11);
3759 d = log10(1.11);
3760 d = pow(1.11, 2.22);
3761 d = sqrt(1.11);
3762 d = sin(1.11);
3763 d = cos(1.11);
3764 d = atan(1.11);
3765 ],
3766 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT_FUNCS),
3767 AC_MSG_RESULT(no))
3768
Bram Moolenaara6b89762016-02-29 21:38:26 +01003769dnl isinf() and isnan() need to include header files and may need -lm.
3770AC_MSG_CHECKING([for isinf()])
3771AC_TRY_LINK([
3772#ifdef HAVE_MATH_H
3773# include <math.h>
3774#endif
3775#if STDC_HEADERS
3776# include <stdlib.h>
3777# include <stddef.h>
3778#endif
3779], [int r = isinf(1.11); ],
3780 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISINF),
3781 AC_MSG_RESULT(no))
3782
3783AC_MSG_CHECKING([for isnan()])
3784AC_TRY_LINK([
3785#ifdef HAVE_MATH_H
3786# include <math.h>
3787#endif
3788#if STDC_HEADERS
3789# include <stdlib.h>
3790# include <stddef.h>
3791#endif
3792], [int r = isnan(1.11); ],
3793 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISNAN),
3794 AC_MSG_RESULT(no))
3795
Bram Moolenaar071d4272004-06-13 20:20:40 +00003796dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI
3797dnl when -lacl works, also try to use -lattr (required for Debian).
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003798dnl On Solaris, use the acl_get/set functions in libsec, if present.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003799AC_MSG_CHECKING(--disable-acl argument)
3800AC_ARG_ENABLE(acl,
Bram Moolenaard6d30422018-01-28 22:48:55 +01003801 [ --disable-acl No check for ACL support.],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003802 , [enable_acl="yes"])
3803if test "$enable_acl" = "yes"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01003804 AC_MSG_RESULT(no)
3805 AC_CHECK_LIB(posix1e, acl_get_file, [LIBS="$LIBS -lposix1e"],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003806 AC_CHECK_LIB(acl, acl_get_file, [LIBS="$LIBS -lacl"
3807 AC_CHECK_LIB(attr, fgetxattr, LIBS="$LIBS -lattr",,)],,),)
3808
Bram Moolenaard6d30422018-01-28 22:48:55 +01003809 AC_MSG_CHECKING(for POSIX ACL support)
3810 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003811#include <sys/types.h>
3812#ifdef HAVE_SYS_ACL_H
3813# include <sys/acl.h>
3814#endif
3815acl_t acl;], [acl = acl_get_file("foo", ACL_TYPE_ACCESS);
3816 acl_set_file("foo", ACL_TYPE_ACCESS, acl);
3817 acl_free(acl);],
3818 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_ACL),
3819 AC_MSG_RESULT(no))
3820
Bram Moolenaard6d30422018-01-28 22:48:55 +01003821 AC_CHECK_LIB(sec, acl_get, [LIBS="$LIBS -lsec"; AC_DEFINE(HAVE_SOLARIS_ZFS_ACL)],
3822 AC_MSG_CHECKING(for Solaris ACL support)
3823 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003824#ifdef HAVE_SYS_ACL_H
3825# include <sys/acl.h>
3826#endif], [acl("foo", GETACLCNT, 0, NULL);
3827 ],
3828 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOLARIS_ACL),
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003829 AC_MSG_RESULT(no)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003830
Bram Moolenaard6d30422018-01-28 22:48:55 +01003831 AC_MSG_CHECKING(for AIX ACL support)
3832 AC_TRY_LINK([
Bram Moolenaar446cb832008-06-24 21:56:24 +00003833#if STDC_HEADERS
3834# include <stdlib.h>
3835# include <stddef.h>
3836#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003837#ifdef HAVE_SYS_ACL_H
3838# include <sys/acl.h>
3839#endif
3840#ifdef HAVE_SYS_ACCESS_H
3841# include <sys/access.h>
3842#endif
3843#define _ALL_SOURCE
3844
3845#include <sys/stat.h>
3846
3847int aclsize;
3848struct acl *aclent;], [aclsize = sizeof(struct acl);
3849 aclent = (void *)malloc(aclsize);
3850 statacl("foo", STX_NORMAL, aclent, aclsize);
3851 ],
3852 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_AIX_ACL),
3853 AC_MSG_RESULT(no))
3854else
3855 AC_MSG_RESULT(yes)
3856fi
3857
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02003858if test "x$GTK_CFLAGS" != "x"; then
3859 dnl pango_shape_full() is new, fall back to pango_shape().
3860 AC_MSG_CHECKING(for pango_shape_full)
3861 ac_save_CFLAGS="$CFLAGS"
3862 ac_save_LIBS="$LIBS"
3863 CFLAGS="$CFLAGS $GTK_CFLAGS"
3864 LIBS="$LIBS $GTK_LIBS"
Bram Moolenaar5325b9b2015-09-09 20:27:02 +02003865 AC_TRY_LINK(
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02003866 [#include <gtk/gtk.h>],
3867 [ pango_shape_full(NULL, 0, NULL, 0, NULL, NULL); ],
3868 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_PANGO_SHAPE_FULL),
3869 AC_MSG_RESULT(no))
3870 CFLAGS="$ac_save_CFLAGS"
3871 LIBS="$ac_save_LIBS"
3872fi
3873
Bram Moolenaar071d4272004-06-13 20:20:40 +00003874AC_MSG_CHECKING(--disable-gpm argument)
3875AC_ARG_ENABLE(gpm,
3876 [ --disable-gpm Don't use gpm (Linux mouse daemon).], ,
3877 [enable_gpm="yes"])
3878
3879if test "$enable_gpm" = "yes"; then
3880 AC_MSG_RESULT(no)
3881 dnl Checking if gpm support can be compiled
3882 AC_CACHE_CHECK([for gpm], vi_cv_have_gpm,
3883 [olibs="$LIBS" ; LIBS="-lgpm"]
3884 AC_TRY_LINK(
3885 [#include <gpm.h>
3886 #include <linux/keyboard.h>],
3887 [Gpm_GetLibVersion(NULL);],
3888 dnl Configure defines HAVE_GPM, if it is defined feature.h defines
3889 dnl FEAT_MOUSE_GPM if mouse support is included
3890 [vi_cv_have_gpm=yes],
3891 [vi_cv_have_gpm=no])
3892 [LIBS="$olibs"]
3893 )
3894 if test $vi_cv_have_gpm = yes; then
3895 LIBS="$LIBS -lgpm"
3896 AC_DEFINE(HAVE_GPM)
3897 fi
3898else
3899 AC_MSG_RESULT(yes)
3900fi
3901
Bram Moolenaar446cb832008-06-24 21:56:24 +00003902AC_MSG_CHECKING(--disable-sysmouse argument)
3903AC_ARG_ENABLE(sysmouse,
Bram Moolenaar8008b632017-07-18 21:33:20 +02003904 [ --disable-sysmouse Don't use sysmouse (mouse in *BSD console).], ,
Bram Moolenaar446cb832008-06-24 21:56:24 +00003905 [enable_sysmouse="yes"])
3906
3907if test "$enable_sysmouse" = "yes"; then
3908 AC_MSG_RESULT(no)
3909 dnl Checking if sysmouse support can be compiled
3910 dnl Configure defines HAVE_SYSMOUSE, if it is defined feature.h
3911 dnl defines FEAT_SYSMOUSE if mouse support is included
3912 AC_CACHE_CHECK([for sysmouse], vi_cv_have_sysmouse,
3913 AC_TRY_LINK(
3914 [#include <sys/consio.h>
3915 #include <signal.h>
3916 #include <sys/fbio.h>],
3917 [struct mouse_info mouse;
3918 mouse.operation = MOUSE_MODE;
3919 mouse.operation = MOUSE_SHOW;
3920 mouse.u.mode.mode = 0;
3921 mouse.u.mode.signal = SIGUSR2;],
3922 [vi_cv_have_sysmouse=yes],
3923 [vi_cv_have_sysmouse=no])
3924 )
3925 if test $vi_cv_have_sysmouse = yes; then
3926 AC_DEFINE(HAVE_SYSMOUSE)
3927 fi
3928else
3929 AC_MSG_RESULT(yes)
3930fi
3931
Bram Moolenaarf05da212009-11-17 16:13:15 +00003932dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
3933AC_MSG_CHECKING(for FD_CLOEXEC)
3934AC_TRY_COMPILE(
3935[#if HAVE_FCNTL_H
3936# include <fcntl.h>
3937#endif],
3938[ int flag = FD_CLOEXEC;],
3939 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
3940 AC_MSG_RESULT(not usable))
3941
Bram Moolenaar071d4272004-06-13 20:20:40 +00003942dnl rename needs to be checked separately to work on Nextstep with cc
3943AC_MSG_CHECKING(for rename)
3944AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
3945 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
3946 AC_MSG_RESULT(no))
3947
3948dnl sysctl() may exist but not the arguments we use
3949AC_MSG_CHECKING(for sysctl)
3950AC_TRY_COMPILE(
3951[#include <sys/types.h>
3952#include <sys/sysctl.h>],
3953[ int mib[2], r;
3954 size_t len;
3955
3956 mib[0] = CTL_HW;
3957 mib[1] = HW_USERMEM;
3958 len = sizeof(r);
3959 (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
3960 ],
3961 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL),
3962 AC_MSG_RESULT(not usable))
3963
3964dnl sysinfo() may exist but not be Linux compatible
3965AC_MSG_CHECKING(for sysinfo)
3966AC_TRY_COMPILE(
3967[#include <sys/types.h>
3968#include <sys/sysinfo.h>],
3969[ struct sysinfo sinfo;
3970 int t;
3971
3972 (void)sysinfo(&sinfo);
3973 t = sinfo.totalram;
3974 ],
3975 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
3976 AC_MSG_RESULT(not usable))
3977
Bram Moolenaar914572a2007-05-01 11:37:47 +00003978dnl struct sysinfo may have the mem_unit field or not
3979AC_MSG_CHECKING(for sysinfo.mem_unit)
3980AC_TRY_COMPILE(
3981[#include <sys/types.h>
3982#include <sys/sysinfo.h>],
3983[ struct sysinfo sinfo;
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02003984 sinfo.mem_unit = 1;
Bram Moolenaar914572a2007-05-01 11:37:47 +00003985 ],
3986 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_MEM_UNIT),
3987 AC_MSG_RESULT(no))
3988
Bram Moolenaar071d4272004-06-13 20:20:40 +00003989dnl sysconf() may exist but not support what we want to use
3990AC_MSG_CHECKING(for sysconf)
3991AC_TRY_COMPILE(
3992[#include <unistd.h>],
3993[ (void)sysconf(_SC_PAGESIZE);
3994 (void)sysconf(_SC_PHYS_PAGES);
3995 ],
3996 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
3997 AC_MSG_RESULT(not usable))
3998
Bram Moolenaar914703b2010-05-31 21:59:46 +02003999AC_CHECK_SIZEOF([int])
4000AC_CHECK_SIZEOF([long])
4001AC_CHECK_SIZEOF([time_t])
4002AC_CHECK_SIZEOF([off_t])
Bram Moolenaar644fdff2010-05-30 13:26:21 +02004003
Bram Moolenaara2aa31a2014-02-23 22:52:40 +01004004dnl Use different names to avoid clashing with other header files.
4005AC_DEFINE_UNQUOTED(VIM_SIZEOF_INT, [$ac_cv_sizeof_int])
4006AC_DEFINE_UNQUOTED(VIM_SIZEOF_LONG, [$ac_cv_sizeof_long])
4007
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004008dnl Make sure that uint32_t is really 32 bits unsigned.
4009AC_MSG_CHECKING([uint32_t is 32 bits])
4010AC_TRY_RUN([
4011#ifdef HAVE_STDINT_H
4012# include <stdint.h>
4013#endif
4014#ifdef HAVE_INTTYPES_H
4015# include <inttypes.h>
4016#endif
4017main() {
4018 uint32_t nr1 = (uint32_t)-1;
4019 uint32_t nr2 = (uint32_t)0xffffffffUL;
4020 if (sizeof(uint32_t) != 4 || nr1 != 0xffffffffUL || nr2 + 1 != 0) exit(1);
4021 exit(0);
4022}],
4023AC_MSG_RESULT(ok),
4024AC_MSG_ERROR([WRONG! uint32_t not defined correctly.]),
Bram Moolenaar323cb952011-12-14 19:22:34 +01004025AC_MSG_WARN([cannot check uint32_t when cross-compiling.]))
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004026
Bram Moolenaar446cb832008-06-24 21:56:24 +00004027dnl Check for memmove() before bcopy(), makes memmove() be used when both are
4028dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
4029
Bram Moolenaar071d4272004-06-13 20:20:40 +00004030[bcopy_test_prog='
Bram Moolenaar446cb832008-06-24 21:56:24 +00004031#include "confdefs.h"
4032#ifdef HAVE_STRING_H
4033# include <string.h>
4034#endif
4035#if STDC_HEADERS
4036# include <stdlib.h>
4037# include <stddef.h>
4038#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004039main() {
4040 char buf[10];
4041 strcpy(buf, "abcdefghi");
4042 mch_memmove(buf, buf + 2, 3);
4043 if (strncmp(buf, "ababcf", 6))
4044 exit(1);
4045 strcpy(buf, "abcdefghi");
4046 mch_memmove(buf + 2, buf, 3);
4047 if (strncmp(buf, "cdedef", 6))
4048 exit(1);
4049 exit(0); /* libc version works properly. */
4050}']
4051
Bram Moolenaar446cb832008-06-24 21:56:24 +00004052AC_CACHE_CHECK([whether memmove handles overlaps],[vim_cv_memmove_handles_overlap],
4053 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004054 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 +00004055 [
4056 vim_cv_memmove_handles_overlap=yes
4057 ],[
4058 vim_cv_memmove_handles_overlap=no
4059 ],[
4060 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memmove_handles_overlap')
4061 ])
4062 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00004063
Bram Moolenaar446cb832008-06-24 21:56:24 +00004064if test "x$vim_cv_memmove_handles_overlap" = "xyes" ; then
4065 AC_DEFINE(USEMEMMOVE)
4066else
4067 AC_CACHE_CHECK([whether bcopy handles overlaps],[vim_cv_bcopy_handles_overlap],
4068 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004069 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 +00004070 [
4071 vim_cv_bcopy_handles_overlap=yes
4072 ],[
4073 vim_cv_bcopy_handles_overlap=no
4074 ],[
4075 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_bcopy_handles_overlap')
4076 ])
4077 ])
4078
4079 if test "x$vim_cv_bcopy_handles_overlap" = "xyes" ; then
4080 AC_DEFINE(USEBCOPY)
4081 else
4082 AC_CACHE_CHECK([whether memcpy handles overlaps],[vim_cv_memcpy_handles_overlap],
4083 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004084 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 +00004085 [
4086 vim_cv_memcpy_handles_overlap=yes
4087 ],[
4088 vim_cv_memcpy_handles_overlap=no
4089 ],[
4090 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memcpy_handles_overlap')
4091 ])
4092 ])
4093
4094 if test "x$vim_cv_memcpy_handles_overlap" = "xyes" ; then
4095 AC_DEFINE(USEMEMCPY)
4096 fi
4097 fi
4098fi
4099
Bram Moolenaar071d4272004-06-13 20:20:40 +00004100
4101dnl Check for multibyte locale functions
4102dnl Find out if _Xsetlocale() is supported by libX11.
4103dnl Check if X_LOCALE should be defined.
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004104if test "x$with_x" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004105 cflags_save=$CFLAGS
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004106 libs_save=$LIBS
4107 LIBS="$LIBS $X_LIBS $GUI_LIB_LOC $GUI_X_LIBS $X_PRE_LIBS $X_LIB $X_EXTRA_LIBS"
4108 CFLAGS="$CFLAGS $X_CFLAGS"
4109
4110 AC_MSG_CHECKING(whether X_LOCALE needed)
4111 AC_TRY_COMPILE([#include <X11/Xlocale.h>],,
4112 AC_TRY_LINK_FUNC([_Xsetlocale], [AC_MSG_RESULT(yes)
4113 AC_DEFINE(X_LOCALE)], AC_MSG_RESULT(no)),
4114 AC_MSG_RESULT(no))
4115
4116 AC_MSG_CHECKING(whether Xutf8SetWMProperties() can be used)
4117 AC_TRY_LINK_FUNC([Xutf8SetWMProperties], [AC_MSG_RESULT(yes)
4118 AC_DEFINE(HAVE_XUTF8SETWMPROPERTIES)], AC_MSG_RESULT(no))
4119
Bram Moolenaar071d4272004-06-13 20:20:40 +00004120 CFLAGS=$cflags_save
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004121 LIBS=$libs_save
Bram Moolenaar071d4272004-06-13 20:20:40 +00004122fi
4123
4124dnl Link with xpg4, it is said to make Korean locale working
4125AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,)
4126
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004127dnl Check how we can run ctags. Default to "ctags" when nothing works.
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02004128dnl Use --version to detect Exuberant ctags (preferred)
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004129dnl Add --fields=+S to get function signatures for omni completion.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004130dnl -t for typedefs (many ctags have this)
4131dnl -s for static functions (Elvis ctags only?)
4132dnl -v for variables. Dangerous, most ctags take this for 'vgrind style'.
4133dnl -i+m to test for older Exuberant ctags
4134AC_MSG_CHECKING(how to create tags)
4135test -f tags && mv tags tags.save
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004136if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004137 TAGPRG="ctags -I INIT+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004138elif (eval exctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
4139 TAGPRG="exctags -I INIT+ --fields=+S"
4140elif (eval exuberant-ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
4141 TAGPRG="exuberant-ctags -I INIT+ --fields=+S"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004142else
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004143 TAGPRG="ctags"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004144 (eval etags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags"
4145 (eval etags -c /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags -c"
4146 (eval ctags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags"
4147 (eval ctags -t /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -t"
4148 (eval ctags -ts /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -ts"
4149 (eval ctags -tvs /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -tvs"
4150 (eval ctags -i+m /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -i+m"
4151fi
4152test -f tags.save && mv tags.save tags
4153AC_MSG_RESULT($TAGPRG) AC_SUBST(TAGPRG)
4154
4155dnl Check how we can run man with a section number
4156AC_MSG_CHECKING(how to run man with a section nr)
4157MANDEF="man"
Bram Moolenaar8b131502008-02-13 09:28:19 +00004158(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 +00004159AC_MSG_RESULT($MANDEF)
4160if test "$MANDEF" = "man -s"; then
4161 AC_DEFINE(USEMAN_S)
4162fi
4163
4164dnl Check if gettext() is working and if it needs -lintl
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004165dnl We take care to base this on an empty LIBS: on some systems libelf would be
4166dnl in LIBS and implicitly take along libintl. The final LIBS would then not
4167dnl contain libintl, and the link step would fail due to -Wl,--as-needed.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004168AC_MSG_CHECKING(--disable-nls argument)
4169AC_ARG_ENABLE(nls,
4170 [ --disable-nls Don't support NLS (gettext()).], ,
4171 [enable_nls="yes"])
4172
4173if test "$enable_nls" = "yes"; then
4174 AC_MSG_RESULT(no)
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00004175
4176 INSTALL_LANGS=install-languages
4177 AC_SUBST(INSTALL_LANGS)
4178 INSTALL_TOOL_LANGS=install-tool-languages
4179 AC_SUBST(INSTALL_TOOL_LANGS)
4180
Bram Moolenaar071d4272004-06-13 20:20:40 +00004181 AC_CHECK_PROG(MSGFMT, msgfmt, msgfmt, )
4182 AC_MSG_CHECKING([for NLS])
4183 if test -f po/Makefile; then
4184 have_gettext="no"
4185 if test -n "$MSGFMT"; then
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004186 olibs=$LIBS
4187 LIBS=""
Bram Moolenaar071d4272004-06-13 20:20:40 +00004188 AC_TRY_LINK(
4189 [#include <libintl.h>],
4190 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004191 AC_MSG_RESULT([gettext() works]); have_gettext="yes"; LIBS=$olibs,
4192 LIBS="-lintl"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004193 AC_TRY_LINK(
4194 [#include <libintl.h>],
4195 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004196 AC_MSG_RESULT([gettext() works with -lintl]); have_gettext="yes";
4197 LIBS="$olibs -lintl",
Bram Moolenaar071d4272004-06-13 20:20:40 +00004198 AC_MSG_RESULT([gettext() doesn't work]);
4199 LIBS=$olibs))
4200 else
4201 AC_MSG_RESULT([msgfmt not found - disabled]);
4202 fi
Bram Moolenaar278eb582014-07-30 13:22:52 +02004203 if test $have_gettext = "yes" -a "x$features" != "xtiny" -a "x$features" != "xsmall"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004204 AC_DEFINE(HAVE_GETTEXT)
4205 MAKEMO=yes
4206 AC_SUBST(MAKEMO)
4207 dnl this was added in GNU gettext 0.10.36
4208 AC_CHECK_FUNCS(bind_textdomain_codeset)
4209 dnl _nl_msg_cat_cntr is required for GNU gettext
4210 AC_MSG_CHECKING([for _nl_msg_cat_cntr])
4211 AC_TRY_LINK(
4212 [#include <libintl.h>
4213 extern int _nl_msg_cat_cntr;],
4214 [++_nl_msg_cat_cntr;],
4215 AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_NL_MSG_CAT_CNTR),
4216 AC_MSG_RESULT([no]))
4217 fi
4218 else
4219 AC_MSG_RESULT([no "po/Makefile" - disabled]);
4220 fi
4221else
4222 AC_MSG_RESULT(yes)
4223fi
4224
4225dnl Check for dynamic linking loader
4226AC_CHECK_HEADER(dlfcn.h, DLL=dlfcn.h, [AC_CHECK_HEADER(dl.h, DLL=dl.h)])
4227if test x${DLL} = xdlfcn.h; then
4228 AC_DEFINE(HAVE_DLFCN_H, 1, [ Define if we have dlfcn.h. ])
4229 AC_MSG_CHECKING([for dlopen()])
4230 AC_TRY_LINK(,[
4231 extern void* dlopen();
4232 dlopen();
4233 ],
4234 AC_MSG_RESULT(yes);
4235 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4236 AC_MSG_RESULT(no);
4237 AC_MSG_CHECKING([for dlopen() in -ldl])
4238 olibs=$LIBS
4239 LIBS="$LIBS -ldl"
4240 AC_TRY_LINK(,[
4241 extern void* dlopen();
4242 dlopen();
4243 ],
4244 AC_MSG_RESULT(yes);
4245 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4246 AC_MSG_RESULT(no);
4247 LIBS=$olibs))
4248 dnl ReliantUNIX has dlopen() in libc but everything else in libdl
4249 dnl ick :-)
4250 AC_MSG_CHECKING([for dlsym()])
4251 AC_TRY_LINK(,[
4252 extern void* dlsym();
4253 dlsym();
4254 ],
4255 AC_MSG_RESULT(yes);
4256 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4257 AC_MSG_RESULT(no);
4258 AC_MSG_CHECKING([for dlsym() in -ldl])
4259 olibs=$LIBS
4260 LIBS="$LIBS -ldl"
4261 AC_TRY_LINK(,[
4262 extern void* dlsym();
4263 dlsym();
4264 ],
4265 AC_MSG_RESULT(yes);
4266 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4267 AC_MSG_RESULT(no);
4268 LIBS=$olibs))
4269elif test x${DLL} = xdl.h; then
4270 AC_DEFINE(HAVE_DL_H, 1, [ Define if we have dl.h. ])
4271 AC_MSG_CHECKING([for shl_load()])
4272 AC_TRY_LINK(,[
4273 extern void* shl_load();
4274 shl_load();
4275 ],
4276 AC_MSG_RESULT(yes);
4277 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4278 AC_MSG_RESULT(no);
4279 AC_MSG_CHECKING([for shl_load() in -ldld])
4280 olibs=$LIBS
4281 LIBS="$LIBS -ldld"
4282 AC_TRY_LINK(,[
4283 extern void* shl_load();
4284 shl_load();
4285 ],
4286 AC_MSG_RESULT(yes);
4287 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4288 AC_MSG_RESULT(no);
4289 LIBS=$olibs))
4290fi
4291AC_CHECK_HEADERS(setjmp.h)
4292
Bram Moolenaard0573012017-10-28 21:11:06 +02004293if test "x$MACOS_X" = "xyes" -a -n "$PERL"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004294 dnl -ldl must come after DynaLoader.a
4295 if echo $LIBS | grep -e '-ldl' >/dev/null; then
4296 LIBS=`echo $LIBS | sed s/-ldl//`
4297 PERL_LIBS="$PERL_LIBS -ldl"
4298 fi
4299fi
4300
Bram Moolenaard0573012017-10-28 21:11:06 +02004301if test "$MACOS_X" = "yes"; then
4302 AC_MSG_CHECKING([whether we need macOS frameworks])
4303 if test "$GUITYPE" = "CARBONGUI"; then
4304 AC_MSG_RESULT([yes, we need Carbon])
4305 LIBS="$LIBS -framework Carbon"
4306 elif test "$MACOS_X_DARWIN" = "yes"; then
4307 if test "$features" = "tiny"; then
4308 dnl Since no FEAT_CLIPBOARD, no longer need for os_macosx.m.
4309 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_macosx.m++'`
4310 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_macosx.o++'`
4311 if test "$enable_multibyte" = "yes"; then
4312 AC_MSG_RESULT([yes, we need CoreServices])
4313 LIBS="$LIBS -framework CoreServices"
4314 else
4315 dnl Since no FEAT_MBYTE, no longer need for os_mac_conv.c.
4316 AC_MSG_RESULT([no])
4317 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_mac_conv.c++'`
4318 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_mac_conv.o++'`
4319 CPPFLAGS=`echo "$CPPFLAGS" | sed -e 's+-DMACOS_X_DARWIN++'`
4320 fi
4321 else
4322 AC_MSG_RESULT([yes, we need AppKit])
4323 LIBS="$LIBS -framework AppKit"
4324 if test "$features" = "small" -a "$enable_multibyte" = "no"; then
4325 dnl Since FEAT_CLIPBOARD is to be defined in vim.h for FEAT_SMALL, define
4326 dnl FEAT_MBYTE in order not to compromise the interoperability of the
4327 dnl clipboard.
4328 AC_MSG_NOTICE([+multi_byte will be set in favor of +clipboard])
4329 enable_multibyte=yes
4330 AC_DEFINE(FEAT_MBYTE)
4331 fi
4332 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004333 else
Bram Moolenaard0573012017-10-28 21:11:06 +02004334 AC_MSG_RESULT([no])
Bram Moolenaar3437b912013-07-03 19:52:53 +02004335 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004336fi
Bram Moolenaar164fca32010-07-14 13:58:07 +02004337if test "x$MACARCH" = "xboth" && test "x$GUITYPE" = "xCARBONGUI"; then
Bram Moolenaar595a7be2010-03-10 16:28:12 +01004338 LDFLAGS="$LDFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +00004339fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004340
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004341dnl gcc 3.1 changed the meaning of -MM. The only solution appears to be to
4342dnl use "-isystem" instead of "-I" for all non-Vim include dirs.
4343dnl But only when making dependencies, cproto and lint don't take "-isystem".
Bram Moolenaar32466aa2006-02-24 23:53:04 +00004344dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
4345dnl the number before the version number.
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004346DEPEND_CFLAGS_FILTER=
4347if test "$GCC" = yes; then
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004348 AC_MSG_CHECKING(for GCC 3 or later)
Bram Moolenaar2217cae2006-03-25 21:55:52 +00004349 gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]]\)\..*$/\1/g'`
Bram Moolenaarf740b292006-02-16 22:11:02 +00004350 if test "$gccmajor" -gt "2"; then
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004351 DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004352 AC_MSG_RESULT(yes)
4353 else
4354 AC_MSG_RESULT(no)
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004355 fi
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004356 dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
4357 dnl declared as char x[1] but actually longer. Introduced in gcc 4.0.
Bram Moolenaar56d1db32009-12-16 16:14:51 +00004358 dnl Also remove duplicate _FORTIFY_SOURCE arguments.
Bram Moolenaaraeabe052011-12-08 15:17:34 +01004359 dnl And undefine it first to avoid a warning.
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004360 AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
4361 if test "$gccmajor" -gt "3"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02004362 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 +00004363 AC_MSG_RESULT(yes)
4364 else
4365 AC_MSG_RESULT(no)
4366 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +00004367fi
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004368AC_SUBST(DEPEND_CFLAGS_FILTER)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004369
Bram Moolenaarec0557f2018-01-31 14:41:37 +01004370dnl On some systems AC_SYS_LARGEFILE determines that -D_FILE_OFFSET_BITS=64
4371dnl isn't required, but the CFLAGS for some of the libraries we're using
4372dnl include the define. Since the define changes the size of some datatypes
4373dnl (e.g. ino_t and off_t), all of Vim's modules must be compiled with a
4374dnl consistent value. It's therefore safest to force the use of the define
4375dnl if it's present in any of the *_CFLAGS variables.
4376AC_MSG_CHECKING(whether we need to force -D_FILE_OFFSET_BITS=64)
Bram Moolenaar9ce42132018-04-11 22:19:36 +02004377if echo "$CFLAGS $LUA_CFLAGS $MZSCHEME_CFLAGS $PERL_CFLAGS $PYTHON_CFLAGS $PYTHON3_CFLAGS $TCL_CFLAGS $RUBY_CFLAGS $GTK_CFLAGS" | grep -q D_FILE_OFFSET_BITS 2>/dev/null; then
Bram Moolenaarec0557f2018-01-31 14:41:37 +01004378 AC_MSG_RESULT(yes)
4379 AC_DEFINE(_FILE_OFFSET_BITS, 64)
4380else
4381 AC_MSG_RESULT(no)
4382fi
4383
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004384dnl link.sh tries to avoid overlinking in a hackish way.
4385dnl At least GNU ld supports --as-needed which provides the same functionality
4386dnl at linker level. Let's use it.
4387AC_MSG_CHECKING(linker --as-needed support)
4388LINK_AS_NEEDED=
4389# Check if linker supports --as-needed and --no-as-needed options
4390if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02004391 LDFLAGS=`echo "$LDFLAGS" | sed -e 's/ *-Wl,--as-needed//g' | sed -e 's/$/ -Wl,--as-needed/'`
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004392 LINK_AS_NEEDED=yes
4393fi
4394if test "$LINK_AS_NEEDED" = yes; then
4395 AC_MSG_RESULT(yes)
4396else
4397 AC_MSG_RESULT(no)
4398fi
4399AC_SUBST(LINK_AS_NEEDED)
4400
Bram Moolenaar77c19352012-06-13 19:19:41 +02004401# IBM z/OS reset CFLAGS for config.mk
4402if test "$zOSUnix" = "yes"; then
4403 CFLAGS="-D_ALL_SOURCE -Wc,float\(ieee\),dll"
4404fi
4405
Bram Moolenaar2e324952018-04-14 14:37:07 +02004406dnl Declare what standards the code should comply with. But not when using
4407dnl GTK, the header files cause all kinds of warnings.
4408if test "$GCC" = yes -a "$GUITYPE" != "GTK"; then
4409 CFLAGS="$CFLAGS -ansi"
4410fi
4411
Bram Moolenaar071d4272004-06-13 20:20:40 +00004412dnl write output files
4413AC_OUTPUT(auto/config.mk:config.mk.in)
4414
4415dnl vim: set sw=2 tw=78 fo+=l: