blob: e59f86be13718320bbdd1c11dbf7f3f11b729ab4 [file] [log] [blame]
Bram Moolenaar3f7d0902016-11-12 21:13:42 +01001dnl configure.ac: autoconf script for Vim
Bram Moolenaar071d4272004-06-13 20:20:40 +00002
3dnl Process this file with autoconf 2.12 or 2.13 to produce "configure".
4dnl Should also work with autoconf 2.54 and later.
5
6AC_INIT(vim.h)
7AC_CONFIG_HEADER(auto/config.h:config.h.in)
8
9dnl Being able to run configure means the system is Unix (compatible).
10AC_DEFINE(UNIX)
11AC_PROG_MAKE_SET
12
13dnl Checks for programs.
Bram Moolenaarc0394412017-04-20 20:20:23 +020014AC_PROG_CC dnl required by almost everything
15AC_PROG_CPP dnl required by header file checks
16AC_PROGRAM_EGREP dnl required by AC_EGREP_CPP
17AC_PROG_FGREP dnl finds working grep -F
18AC_ISC_POSIX dnl required by AC_C_CROSS
19AC_PROG_AWK dnl required for "make html" in ../doc
20AC_PROG_MKDIR_P dnl portable "mkdir -p", also works in parallel
Bram Moolenaar071d4272004-06-13 20:20:40 +000021
22dnl Don't strip if we don't have it
23AC_CHECK_PROG(STRIP, strip, strip, :)
24
Bram Moolenaar325b7a22004-07-05 15:58:32 +000025dnl Check for extension of executables
Bram Moolenaar071d4272004-06-13 20:20:40 +000026AC_EXEEXT
27
Bram Moolenaar446cb832008-06-24 21:56:24 +000028dnl Check for standard headers. We don't use this in Vim but other stuff
29dnl in autoconf needs it, where it uses STDC_HEADERS.
30AC_HEADER_STDC
31AC_HEADER_SYS_WAIT
32
Bram Moolenaarf788a062011-12-14 20:51:25 +010033dnl Check for the flag that fails if stuff are missing.
34
35AC_MSG_CHECKING(--enable-fail-if-missing argument)
36AC_ARG_ENABLE(fail_if_missing,
37 [ --enable-fail-if-missing Fail if dependencies on additional features
38 specified on the command line are missing.],
39 [fail_if_missing="yes"],
40 [fail_if_missing="no"])
41AC_MSG_RESULT($fail_if_missing)
42
Bram Moolenaar071d4272004-06-13 20:20:40 +000043dnl Set default value for CFLAGS if none is defined or it's empty
44if test -z "$CFLAGS"; then
45 CFLAGS="-O"
46 test "$GCC" = yes && CFLAGS="-O2 -fno-strength-reduce -Wall"
47fi
48if test "$GCC" = yes; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +000049 dnl method that should work for nearly all versions
Bram Moolenaarc8836f72014-04-12 13:12:24 +020050 gccversion=`$CC -dumpversion`
Bram Moolenaar910f66f2006-04-05 20:41:53 +000051 if test "x$gccversion" = "x"; then
52 dnl old method; fall-back for when -dumpversion doesn't work
Bram Moolenaarc8836f72014-04-12 13:12:24 +020053 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 +000054 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +000055 dnl version 4.0.1 was reported to cause trouble on Macintosh by Marcin Dalecki
56 if test "$gccversion" = "3.0.1" -o "$gccversion" = "3.0.2" -o "$gccversion" = "4.0.1"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +000057 echo 'GCC [[34]].0.[[12]] has a bug in the optimizer, disabling "-O#"'
Bram Moolenaar071d4272004-06-13 20:20:40 +000058 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-O/'`
59 else
60 if test "$gccversion" = "3.1" -o "$gccversion" = "3.2" -o "$gccversion" = "3.2.1" && `echo "$CFLAGS" | grep -v fno-strength-reduce >/dev/null`; then
61 echo 'GCC 3.1 and 3.2 have a bug in the optimizer, adding "-fno-strength-reduce"'
62 CFLAGS="$CFLAGS -fno-strength-reduce"
63 fi
64 fi
65fi
66
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +020067dnl clang-500.2.75 or around has abandoned -f[no-]strength-reduce and issues a
68dnl warning when that flag is passed to. Accordingly, adjust CFLAGS based on
69dnl the version number of the clang in use.
70dnl Note that this does not work to get the version of clang 3.1 or 3.2.
Bram Moolenaar5f69fee2017-03-09 11:58:40 +010071AC_MSG_CHECKING(for clang version)
72CLANG_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 +020073if test x"$CLANG_VERSION_STRING" != x"" ; then
74 CLANG_MAJOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*/\1/p'`
75 CLANG_MINOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/p'`
76 CLANG_REVISION=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)/\1/p'`
77 CLANG_VERSION=`expr $CLANG_MAJOR '*' 1000000 '+' $CLANG_MINOR '*' 1000 '+' $CLANG_REVISION`
78 AC_MSG_RESULT($CLANG_VERSION)
79 dnl If you find the same issue with versions earlier than 500.2.75,
80 dnl change the constant 500002075 below appropriately. To get the
81 dnl integer corresponding to a version number, refer to the
82 dnl definition of CLANG_VERSION above.
Bram Moolenaar5f69fee2017-03-09 11:58:40 +010083 AC_MSG_CHECKING(if clang supports -fno-strength-reduce)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +020084 if test "$CLANG_VERSION" -ge 500002075 ; then
Bram Moolenaar5f69fee2017-03-09 11:58:40 +010085 AC_MSG_RESULT(no)
86 CFLAGS=`echo "$CFLAGS" | sed -e 's/-fno-strength-reduce/ /'`
87 else
88 AC_MSG_RESULT(yes)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +020089 fi
90else
Bram Moolenaar5f69fee2017-03-09 11:58:40 +010091 AC_MSG_RESULT(N/A)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +020092fi
93
Bram Moolenaar446cb832008-06-24 21:56:24 +000094dnl If configure thinks we are cross compiling, there might be something
95dnl wrong with the CC or CFLAGS settings, give a useful warning message
Bram Moolenaar839e9542016-04-14 16:46:02 +020096CROSS_COMPILING=
Bram Moolenaar071d4272004-06-13 20:20:40 +000097if test "$cross_compiling" = yes; then
Bram Moolenaar446cb832008-06-24 21:56:24 +000098 AC_MSG_RESULT([cannot compile a simple program; if not cross compiling check CC and CFLAGS])
Bram Moolenaar839e9542016-04-14 16:46:02 +020099 CROSS_COMPILING=1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000100fi
Bram Moolenaar839e9542016-04-14 16:46:02 +0200101AC_SUBST(CROSS_COMPILING)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000102
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +0000103dnl gcc-cpp has the wonderful -MM option to produce nicer dependencies.
104dnl But gcc 3.1 changed the meaning! See near the end.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000105test "$GCC" = yes && CPP_MM=M; AC_SUBST(CPP_MM)
106
107if test -f ./toolcheck; then
108 AC_CHECKING(for buggy tools)
109 sh ./toolcheck 1>&AC_FD_MSG
110fi
111
112OS_EXTRA_SRC=""; OS_EXTRA_OBJ=""
113
114dnl Check for BeOS, which needs an extra source file
115AC_MSG_CHECKING(for BeOS)
116case `uname` in
117 BeOS) OS_EXTRA_SRC=os_beos.c; OS_EXTRA_OBJ=objects/os_beos.o
118 BEOS=yes; AC_MSG_RESULT(yes);;
119 *) BEOS=no; AC_MSG_RESULT(no);;
120esac
121
122dnl If QNX is found, assume we don't want to use Xphoton
123dnl unless it was specifically asked for (--with-x)
124AC_MSG_CHECKING(for QNX)
125case `uname` in
126 QNX) OS_EXTRA_SRC=os_qnx.c; OS_EXTRA_OBJ=objects/os_qnx.o
127 test -z "$with_x" && with_x=no
128 QNX=yes; AC_MSG_RESULT(yes);;
129 *) QNX=no; AC_MSG_RESULT(no);;
130esac
131
132dnl Check for Darwin and MacOS X
133dnl We do a check for MacOS X in the very beginning because there
134dnl are a lot of other things we need to change besides GUI stuff
Bram Moolenaar071d4272004-06-13 20:20:40 +0000135AC_MSG_CHECKING([for Darwin (Mac OS X)])
136if test "`(uname) 2>/dev/null`" = Darwin; then
137 AC_MSG_RESULT(yes)
138
139 AC_MSG_CHECKING(--disable-darwin argument)
140 AC_ARG_ENABLE(darwin,
141 [ --disable-darwin Disable Darwin (Mac OS X) support.],
142 , [enable_darwin="yes"])
143 if test "$enable_darwin" = "yes"; then
144 AC_MSG_RESULT(no)
145 AC_MSG_CHECKING(if Darwin files are there)
Bram Moolenaar164fca32010-07-14 13:58:07 +0200146 if test -f os_macosx.m; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000147 AC_MSG_RESULT(yes)
148 else
149 AC_MSG_RESULT([no, Darwin support disabled])
150 enable_darwin=no
151 fi
152 else
153 AC_MSG_RESULT([yes, Darwin support excluded])
154 fi
155
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000156 AC_MSG_CHECKING(--with-mac-arch argument)
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000157 AC_ARG_WITH(mac-arch, [ --with-mac-arch=ARCH current, intel, ppc or both],
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000158 MACARCH="$withval"; AC_MSG_RESULT($MACARCH),
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000159 MACARCH="current"; AC_MSG_RESULT(defaulting to $MACARCH))
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000160
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100161 AC_MSG_CHECKING(--with-developer-dir argument)
162 AC_ARG_WITH(developer-dir, [ --with-developer-dir=PATH use PATH as location for Xcode developer tools],
163 DEVELOPER_DIR="$withval"; AC_MSG_RESULT($DEVELOPER_DIR),
Bram Moolenaar32d03b32015-11-19 13:46:48 +0100164 AC_MSG_RESULT(not present))
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100165
166 if test "x$DEVELOPER_DIR" = "x"; then
167 AC_PATH_PROG(XCODE_SELECT, xcode-select)
168 if test "x$XCODE_SELECT" != "x"; then
169 AC_MSG_CHECKING(for developer dir using xcode-select)
170 DEVELOPER_DIR=`$XCODE_SELECT -print-path`
171 AC_MSG_RESULT([$DEVELOPER_DIR])
172 else
173 DEVELOPER_DIR=/Developer
174 fi
175 fi
176
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000177 if test "x$MACARCH" = "xboth"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000178 AC_MSG_CHECKING(for 10.4 universal SDK)
179 dnl There is a terrible inconsistency (but we appear to get away with it):
180 dnl $CFLAGS uses the 10.4u SDK library for the headers, while $CPPFLAGS
181 dnl doesn't, because "gcc -E" doesn't grok it. That means the configure
182 dnl tests using the preprocessor are actually done with the wrong header
183 dnl files. $LDFLAGS is set at the end, because configure uses it together
184 dnl with $CFLAGS and we can only have one -sysroot argument.
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000185 save_cppflags="$CPPFLAGS"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000186 save_cflags="$CFLAGS"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000187 save_ldflags="$LDFLAGS"
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100188 CFLAGS="$CFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000189 AC_TRY_LINK([ ], [ ],
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000190 AC_MSG_RESULT(found, will make universal binary),
191
192 AC_MSG_RESULT(not found)
Bram Moolenaar1f35bf92006-03-07 22:38:47 +0000193 CFLAGS="$save_cflags"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000194 AC_MSG_CHECKING(if Intel architecture is supported)
195 CPPFLAGS="$CPPFLAGS -arch i386"
196 LDFLAGS="$save_ldflags -arch i386"
197 AC_TRY_LINK([ ], [ ],
198 AC_MSG_RESULT(yes); MACARCH="intel",
199 AC_MSG_RESULT(no, using PowerPC)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000200 MACARCH="ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000201 CPPFLAGS="$save_cppflags -arch ppc"
202 LDFLAGS="$save_ldflags -arch ppc"))
203 elif test "x$MACARCH" = "xintel"; then
204 CPPFLAGS="$CPPFLAGS -arch intel"
205 LDFLAGS="$LDFLAGS -arch intel"
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000206 elif test "x$MACARCH" = "xppc"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000207 CPPFLAGS="$CPPFLAGS -arch ppc"
208 LDFLAGS="$LDFLAGS -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000209 fi
210
Bram Moolenaar071d4272004-06-13 20:20:40 +0000211 if test "$enable_darwin" = "yes"; then
212 MACOSX=yes
Bram Moolenaar164fca32010-07-14 13:58:07 +0200213 OS_EXTRA_SRC="os_macosx.m os_mac_conv.c";
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000214 OS_EXTRA_OBJ="objects/os_macosx.o objects/os_mac_conv.o"
Bram Moolenaar32466aa2006-02-24 23:53:04 +0000215 dnl TODO: use -arch i386 on Intel machines
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100216 dnl Removed -no-cpp-precomp, only for very old compilers.
217 CPPFLAGS="$CPPFLAGS -DMACOS_X_UNIX"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000218
219 dnl If Carbon is found, assume we don't want X11
220 dnl unless it was specifically asked for (--with-x)
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000221 dnl or Motif, Athena or GTK GUI is used.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000222 AC_CHECK_HEADER(Carbon/Carbon.h, CARBON=yes)
223 if test "x$CARBON" = "xyes"; then
Bram Moolenaar98921892016-02-23 17:14:37 +0100224 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 +0000225 with_x=no
Bram Moolenaar071d4272004-06-13 20:20:40 +0000226 fi
227 fi
228 fi
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000229
Bram Moolenaardb552d602006-03-23 22:59:57 +0000230 dnl Avoid a bug with -O2 with gcc 4.0.1. Symptom: malloc() reports double
Bram Moolenaarfd2ac762006-03-01 22:09:21 +0000231 dnl free. This happens in expand_filename(), because the optimizer swaps
Bram Moolenaardb552d602006-03-23 22:59:57 +0000232 dnl two blocks of code, both using "repl", that can't be swapped.
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000233 if test "$MACARCH" = "intel" -o "$MACARCH" = "both"; then
234 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-Oz/'`
235 fi
236
Bram Moolenaar071d4272004-06-13 20:20:40 +0000237else
238 AC_MSG_RESULT(no)
239fi
240
Bram Moolenaar39766a72013-11-03 00:41:00 +0100241dnl Mac OS X 10.9+ no longer include AvailabilityMacros.h in Carbon
242dnl so we need to include it to have access to version macros.
Bram Moolenaar18e54692013-11-03 20:26:31 +0100243AC_CHECK_HEADERS(AvailabilityMacros.h)
Bram Moolenaar39766a72013-11-03 00:41:00 +0100244
Bram Moolenaar071d4272004-06-13 20:20:40 +0000245AC_SUBST(OS_EXTRA_SRC)
246AC_SUBST(OS_EXTRA_OBJ)
247
248dnl Add /usr/local/lib to $LDFLAGS and /usr/local/include to CFLAGS.
249dnl Only when the directory exists and it wasn't there yet.
250dnl For gcc don't do this when it is already in the default search path.
Bram Moolenaar446cb832008-06-24 21:56:24 +0000251dnl Skip all of this when cross-compiling.
252if test "$cross_compiling" = no; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000253 AC_MSG_CHECKING(--with-local-dir argument)
Bram Moolenaar446cb832008-06-24 21:56:24 +0000254 have_local_include=''
255 have_local_lib=''
Bram Moolenaarc236c162008-07-13 17:41:49 +0000256 AC_ARG_WITH([local-dir], [ --with-local-dir=PATH search PATH instead of /usr/local for local libraries.
257 --without-local-dir do not search /usr/local for local libraries.], [
258 local_dir="$withval"
259 case "$withval" in
260 */*) ;;
261 no)
262 # avoid adding local dir to LDFLAGS and CPPFLAGS
Bram Moolenaare06c1882010-07-21 22:05:20 +0200263 have_local_include=yes
Bram Moolenaarc236c162008-07-13 17:41:49 +0000264 have_local_lib=yes
265 ;;
266 *) AC_MSG_ERROR(must pass path argument to --with-local-dir) ;;
267 esac
268 AC_MSG_RESULT($local_dir)
269 ], [
270 local_dir=/usr/local
271 AC_MSG_RESULT(Defaulting to $local_dir)
272 ])
273 if test "$GCC" = yes -a "$local_dir" != no; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000274 echo 'void f(){}' > conftest.c
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100275 dnl Removed -no-cpp-precomp, only needed for OS X 10.2 (Ben Fowler)
276 have_local_include=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/include"`
Bram Moolenaarc236c162008-07-13 17:41:49 +0000277 have_local_lib=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/lib"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000278 rm -f conftest.c conftest.o
Bram Moolenaar071d4272004-06-13 20:20:40 +0000279 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000280 if test -z "$have_local_lib" -a -d "${local_dir}/lib"; then
281 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 +0000282 if test "$tt" = "$LDFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000283 LDFLAGS="$LDFLAGS -L${local_dir}/lib"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000284 fi
285 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000286 if test -z "$have_local_include" -a -d "${local_dir}/include"; then
287 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 +0000288 if test "$tt" = "$CPPFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000289 CPPFLAGS="$CPPFLAGS -I${local_dir}/include"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000290 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000291 fi
292fi
293
294AC_MSG_CHECKING(--with-vim-name argument)
295AC_ARG_WITH(vim-name, [ --with-vim-name=NAME what to call the Vim executable],
296 VIMNAME="$withval"; AC_MSG_RESULT($VIMNAME),
Bram Moolenaare344bea2005-09-01 20:46:49 +0000297 VIMNAME="vim"; AC_MSG_RESULT(Defaulting to $VIMNAME))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000298AC_SUBST(VIMNAME)
299AC_MSG_CHECKING(--with-ex-name argument)
300AC_ARG_WITH(ex-name, [ --with-ex-name=NAME what to call the Ex executable],
301 EXNAME="$withval"; AC_MSG_RESULT($EXNAME),
302 EXNAME="ex"; AC_MSG_RESULT(Defaulting to ex))
303AC_SUBST(EXNAME)
304AC_MSG_CHECKING(--with-view-name argument)
305AC_ARG_WITH(view-name, [ --with-view-name=NAME what to call the View executable],
306 VIEWNAME="$withval"; AC_MSG_RESULT($VIEWNAME),
307 VIEWNAME="view"; AC_MSG_RESULT(Defaulting to view))
308AC_SUBST(VIEWNAME)
309
310AC_MSG_CHECKING(--with-global-runtime argument)
311AC_ARG_WITH(global-runtime, [ --with-global-runtime=DIR global runtime directory in 'runtimepath'],
312 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL, "$withval"),
313 AC_MSG_RESULT(no))
314
315AC_MSG_CHECKING(--with-modified-by argument)
316AC_ARG_WITH(modified-by, [ --with-modified-by=NAME name of who modified a release version],
317 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(MODIFIED_BY, "$withval"),
318 AC_MSG_RESULT(no))
319
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200320dnl Check for EBCDIC stolen from the LYNX port to z/OS Unix
Bram Moolenaar071d4272004-06-13 20:20:40 +0000321AC_MSG_CHECKING(if character set is EBCDIC)
322AC_TRY_COMPILE([ ],
323[ /* TryCompile function for CharSet.
324 Treat any failure as ASCII for compatibility with existing art.
325 Use compile-time rather than run-time tests for cross-compiler
326 tolerance. */
327#if '0'!=240
328make an error "Character set is not EBCDIC"
329#endif ],
330[ # TryCompile action if true
331cf_cv_ebcdic=yes ],
332[ # TryCompile action if false
333cf_cv_ebcdic=no])
334# end of TryCompile ])
335# end of CacheVal CvEbcdic
336AC_MSG_RESULT($cf_cv_ebcdic)
337case "$cf_cv_ebcdic" in #(vi
338 yes) AC_DEFINE(EBCDIC)
339 line_break='"\\n"'
340 ;;
341 *) line_break='"\\012"';;
342esac
343AC_SUBST(line_break)
344
345if test "$cf_cv_ebcdic" = "yes"; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +0200346dnl If we have EBCDIC we most likely have z/OS Unix, let's test it!
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200347AC_MSG_CHECKING(for z/OS Unix)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000348case `uname` in
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200349 OS/390) zOSUnix="yes";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000350 dnl If using cc the environment variable _CC_CCMODE must be
351 dnl set to "1", so that some compiler extensions are enabled.
352 dnl If using c89 the environment variable is named _CC_C89MODE.
353 dnl Note: compile with c89 never tested.
354 if test "$CC" = "cc"; then
355 ccm="$_CC_CCMODE"
356 ccn="CC"
357 else
358 if test "$CC" = "c89"; then
359 ccm="$_CC_C89MODE"
360 ccn="C89"
361 else
362 ccm=1
363 fi
364 fi
365 if test "$ccm" != "1"; then
366 echo ""
367 echo "------------------------------------------"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200368 echo " On z/OS Unix, the environment variable"
Bram Moolenaar77c19352012-06-13 19:19:41 +0200369 echo " _CC_${ccn}MODE must be set to \"1\"!"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000370 echo " Do:"
371 echo " export _CC_${ccn}MODE=1"
372 echo " and then call configure again."
373 echo "------------------------------------------"
374 exit 1
375 fi
Bram Moolenaar77c19352012-06-13 19:19:41 +0200376 # Set CFLAGS for configure process.
377 # This will be reset later for config.mk.
378 # Use haltonmsg to force error for missing H files.
379 CFLAGS="$CFLAGS -D_ALL_SOURCE -Wc,float(ieee),haltonmsg(3296)";
380 LDFLAGS="$LDFLAGS -Wl,EDIT=NO"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000381 AC_MSG_RESULT(yes)
382 ;;
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200383 *) zOSUnix="no";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000384 AC_MSG_RESULT(no)
385 ;;
386esac
387fi
388
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200389dnl Set QUOTESED. Needs additional backslashes on zOS
390if test "$zOSUnix" = "yes"; then
391 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\\\\\&/g' -e 's/\\\\\\\\\"/\"/' -e 's/\\\\\\\\\";\$\$/\";/'"
392else
393 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\&/g' -e 's/\\\\\"/\"/' -e 's/\\\\\";\$\$/\";/'"
394fi
395AC_SUBST(QUOTESED)
396
397
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200398dnl Link with -lsmack for Smack stuff; if not found
399AC_MSG_CHECKING(--disable-smack argument)
400AC_ARG_ENABLE(smack,
401 [ --disable-smack Do not check for Smack support.],
402 , enable_smack="yes")
403if test "$enable_smack" = "yes"; then
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200404 AC_MSG_RESULT(no)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200405 AC_CHECK_HEADER([linux/xattr.h], true, enable_smack="no")
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200406else
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200407 AC_MSG_RESULT(yes)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200408fi
409if test "$enable_smack" = "yes"; then
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200410 AC_CHECK_HEADER([attr/xattr.h], true, enable_smack="no")
411fi
412if test "$enable_smack" = "yes"; then
413 AC_MSG_CHECKING(for XATTR_NAME_SMACKEXEC in linux/xattr.h)
414 AC_EGREP_CPP(XATTR_NAME_SMACKEXEC, [#include <linux/xattr.h>],
415 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +0200416 AC_MSG_RESULT(no); enable_smack="no")
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200417fi
418if test "$enable_smack" = "yes"; then
419 AC_CHECK_LIB(attr, setxattr,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200420 [LIBS="$LIBS -lattr"
421 found_smack="yes"
422 AC_DEFINE(HAVE_SMACK)])
Bram Moolenaar588ebeb2008-05-07 17:09:24 +0000423fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000424
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200425dnl When smack was found don't search for SELinux
426if test "x$found_smack" = "x"; then
427 dnl Link with -lselinux for SELinux stuff; if not found
428 AC_MSG_CHECKING(--disable-selinux argument)
429 AC_ARG_ENABLE(selinux,
430 [ --disable-selinux Do not check for SELinux support.],
431 , enable_selinux="yes")
432 if test "$enable_selinux" = "yes"; then
433 AC_MSG_RESULT(no)
434 AC_CHECK_LIB(selinux, is_selinux_enabled,
435 [LIBS="$LIBS -lselinux"
436 AC_DEFINE(HAVE_SELINUX)])
437 else
438 AC_MSG_RESULT(yes)
439 fi
440fi
441
Bram Moolenaar071d4272004-06-13 20:20:40 +0000442dnl Check user requested features.
443
444AC_MSG_CHECKING(--with-features argument)
Bram Moolenaareec29812016-07-26 21:27:36 +0200445AC_ARG_WITH(features, [ --with-features=TYPE tiny, small, normal, big or huge (default: huge)],
Bram Moolenaar071d4272004-06-13 20:20:40 +0000446 features="$withval"; AC_MSG_RESULT($features),
Bram Moolenaar23c4f712016-01-20 22:11:59 +0100447 features="huge"; AC_MSG_RESULT(Defaulting to huge))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000448
449dovimdiff=""
450dogvimdiff=""
451case "$features" in
452 tiny) AC_DEFINE(FEAT_TINY) ;;
453 small) AC_DEFINE(FEAT_SMALL) ;;
454 normal) AC_DEFINE(FEAT_NORMAL) dovimdiff="installvimdiff";
455 dogvimdiff="installgvimdiff" ;;
456 big) AC_DEFINE(FEAT_BIG) dovimdiff="installvimdiff";
457 dogvimdiff="installgvimdiff" ;;
458 huge) AC_DEFINE(FEAT_HUGE) dovimdiff="installvimdiff";
459 dogvimdiff="installgvimdiff" ;;
460 *) AC_MSG_RESULT([Sorry, $features is not supported]) ;;
461esac
462
463AC_SUBST(dovimdiff)
464AC_SUBST(dogvimdiff)
465
466AC_MSG_CHECKING(--with-compiledby argument)
467AC_ARG_WITH(compiledby, [ --with-compiledby=NAME name to show in :version message],
468 compiledby="$withval"; AC_MSG_RESULT($withval),
469 compiledby=""; AC_MSG_RESULT(no))
470AC_SUBST(compiledby)
471
472AC_MSG_CHECKING(--disable-xsmp argument)
473AC_ARG_ENABLE(xsmp,
474 [ --disable-xsmp Disable XSMP session management],
475 , enable_xsmp="yes")
476
477if test "$enable_xsmp" = "yes"; then
478 AC_MSG_RESULT(no)
479 AC_MSG_CHECKING(--disable-xsmp-interact argument)
480 AC_ARG_ENABLE(xsmp-interact,
481 [ --disable-xsmp-interact Disable XSMP interaction],
482 , enable_xsmp_interact="yes")
483 if test "$enable_xsmp_interact" = "yes"; then
484 AC_MSG_RESULT(no)
485 AC_DEFINE(USE_XSMP_INTERACT)
486 else
487 AC_MSG_RESULT(yes)
488 fi
489else
490 AC_MSG_RESULT(yes)
491fi
492
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200493dnl Check for Lua feature.
494AC_MSG_CHECKING(--enable-luainterp argument)
495AC_ARG_ENABLE(luainterp,
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200496 [ --enable-luainterp[=OPTS] Include Lua interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200497 [enable_luainterp="no"])
498AC_MSG_RESULT($enable_luainterp)
499
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200500if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +0100501 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
502 AC_MSG_ERROR([cannot use Lua with tiny or small features])
503 fi
504
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200505 dnl -- find the lua executable
506 AC_SUBST(vi_cv_path_lua)
507
508 AC_MSG_CHECKING(--with-lua-prefix argument)
509 AC_ARG_WITH(lua_prefix,
510 [ --with-lua-prefix=PFX Prefix where Lua is installed.],
511 with_lua_prefix="$withval"; AC_MSG_RESULT($with_lua_prefix),
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200512 with_lua_prefix="";AC_MSG_RESULT(no))
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200513
514 if test "X$with_lua_prefix" != "X"; then
515 vi_cv_path_lua_pfx="$with_lua_prefix"
516 else
517 AC_MSG_CHECKING(LUA_PREFIX environment var)
518 if test "X$LUA_PREFIX" != "X"; then
519 AC_MSG_RESULT("$LUA_PREFIX")
520 vi_cv_path_lua_pfx="$LUA_PREFIX"
521 else
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200522 AC_MSG_RESULT([not set, default to /usr])
523 vi_cv_path_lua_pfx="/usr"
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200524 fi
525 fi
526
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200527 AC_MSG_CHECKING(--with-luajit)
528 AC_ARG_WITH(luajit,
529 [ --with-luajit Link with LuaJIT instead of Lua.],
530 [vi_cv_with_luajit="$withval"],
531 [vi_cv_with_luajit="no"])
532 AC_MSG_RESULT($vi_cv_with_luajit)
533
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200534 LUA_INC=
535 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200536 if test "x$vi_cv_with_luajit" != "xno"; then
537 dnl -- try to find LuaJIT executable
538 AC_PATH_PROG(vi_cv_path_luajit, luajit)
539 if test "X$vi_cv_path_luajit" != "X"; then
540 dnl -- find LuaJIT version
541 AC_CACHE_CHECK(LuaJIT version, vi_cv_version_luajit,
Bram Moolenaar49b10272013-11-21 12:17:51 +0100542 [ 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 +0200543 AC_CACHE_CHECK(Lua version of LuaJIT, vi_cv_version_lua_luajit,
544 [ vi_cv_version_lua_luajit=`${vi_cv_path_luajit} -e "print(_VERSION)" | sed 's/.* //'` ])
545 vi_cv_path_lua="$vi_cv_path_luajit"
546 vi_cv_version_lua="$vi_cv_version_lua_luajit"
547 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200548 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200549 dnl -- try to find Lua executable
550 AC_PATH_PROG(vi_cv_path_plain_lua, lua)
551 if test "X$vi_cv_path_plain_lua" != "X"; then
552 dnl -- find Lua version
553 AC_CACHE_CHECK(Lua version, vi_cv_version_plain_lua,
554 [ vi_cv_version_plain_lua=`${vi_cv_path_plain_lua} -e "print(_VERSION)" | sed 's/.* //'` ])
555 fi
556 vi_cv_path_lua="$vi_cv_path_plain_lua"
557 vi_cv_version_lua="$vi_cv_version_plain_lua"
558 fi
559 if test "x$vi_cv_with_luajit" != "xno" && test "X$vi_cv_version_luajit" != "X"; then
560 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 +0100561 if test -f "$vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200562 AC_MSG_RESULT(yes)
563 LUA_INC=/luajit-$vi_cv_version_luajit
564 fi
565 fi
566 if test "X$LUA_INC" = "X"; then
567 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)
Bram Moolenaar49222be2015-12-11 18:11:30 +0100568 if test -f "$vi_cv_path_lua_pfx/include/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200569 AC_MSG_RESULT(yes)
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200570 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200571 AC_MSG_RESULT(no)
572 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 +0100573 if test -f "$vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200574 AC_MSG_RESULT(yes)
575 LUA_INC=/lua$vi_cv_version_lua
576 else
577 AC_MSG_RESULT(no)
578 vi_cv_path_lua_pfx=
579 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200580 fi
581 fi
582 fi
583
584 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200585 if test "x$vi_cv_with_luajit" != "xno"; then
586 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
587 if test "X$multiarch" != "X"; then
588 lib_multiarch="lib/${multiarch}"
589 else
590 lib_multiarch="lib"
591 fi
592 if test "X$vi_cv_version_lua" = "X"; then
593 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit"
594 else
595 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit-$vi_cv_version_lua"
596 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200597 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200598 if test "X$LUA_INC" != "X"; then
599 dnl Test alternate location using version
600 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua$vi_cv_version_lua"
601 else
602 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua"
603 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200604 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200605 if test "$enable_luainterp" = "dynamic"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200606 lua_ok="yes"
607 else
608 AC_MSG_CHECKING([if link with ${LUA_LIBS} is sane])
609 libs_save=$LIBS
610 LIBS="$LIBS $LUA_LIBS"
611 AC_TRY_LINK(,[ ],
612 AC_MSG_RESULT(yes); lua_ok="yes",
613 AC_MSG_RESULT(no); lua_ok="no"; LUA_LIBS="")
614 LIBS=$libs_save
615 fi
616 if test "x$lua_ok" = "xyes"; then
617 LUA_CFLAGS="-I${vi_cv_path_lua_pfx}/include${LUA_INC}"
618 LUA_SRC="if_lua.c"
619 LUA_OBJ="objects/if_lua.o"
620 LUA_PRO="if_lua.pro"
621 AC_DEFINE(FEAT_LUA)
622 fi
623 if test "$enable_luainterp" = "dynamic"; then
624 if test "x$vi_cv_with_luajit" != "xno"; then
625 luajit="jit"
626 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200627 if test -f "${vi_cv_path_lua_pfx}/bin/cyglua-${vi_cv_version_lua}.dll"; then
628 vi_cv_dll_name_lua="cyglua-${vi_cv_version_lua}.dll"
629 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200630 if test "x$MACOSX" = "xyes"; then
631 ext="dylib"
632 indexes=""
633 else
634 ext="so"
635 indexes=".0 .1 .2 .3 .4 .5 .6 .7 .8 .9"
636 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
637 if test "X$multiarch" != "X"; then
638 lib_multiarch="lib/${multiarch}"
639 fi
Bram Moolenaar768baac2013-04-15 14:44:57 +0200640 fi
641 dnl Determine the sover for the current version, but fallback to
642 dnl liblua${vi_cv_version_lua}.so if no sover-versioned file is found.
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200643 AC_MSG_CHECKING(if liblua${luajit}*.${ext}* can be found in $vi_cv_path_lua_pfx)
Bram Moolenaar768baac2013-04-15 14:44:57 +0200644 for subdir in "${lib_multiarch}" lib64 lib; do
645 if test -z "$subdir"; then
646 continue
647 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200648 for sover in "${vi_cv_version_lua}.${ext}" "-${vi_cv_version_lua}.${ext}" \
649 ".${vi_cv_version_lua}.${ext}" ".${ext}.${vi_cv_version_lua}"; do
650 for i in $indexes ""; do
651 if test -f "${vi_cv_path_lua_pfx}/${subdir}/liblua${luajit}${sover}$i"; then
Bram Moolenaar768baac2013-04-15 14:44:57 +0200652 sover2="$i"
653 break 3
654 fi
655 done
Bram Moolenaar07e1da62013-02-06 19:49:43 +0100656 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200657 sover=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200658 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200659 if test "X$sover" = "X"; then
660 AC_MSG_RESULT(no)
661 lua_ok="no"
662 vi_cv_dll_name_lua="liblua${luajit}.${ext}"
663 else
664 AC_MSG_RESULT(yes)
665 lua_ok="yes"
666 vi_cv_dll_name_lua="liblua${luajit}${sover}$sover2"
667 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200668 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200669 AC_DEFINE(DYNAMIC_LUA)
670 LUA_LIBS=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200671 LUA_CFLAGS="-DDYNAMIC_LUA_DLL=\\\"${vi_cv_dll_name_lua}\\\" $LUA_CFLAGS"
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200672 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200673 if test "X$LUA_CFLAGS$LUA_LIBS" != "X" && \
674 test "x$MACOSX" = "xyes" && test "x$vi_cv_with_luajit" != "xno" && \
675 test "`(uname -m) 2>/dev/null`" = "x86_64"; then
676 dnl OSX/x64 requires these flags. See http://luajit.org/install.html
677 LUA_LIBS="-pagezero_size 10000 -image_base 100000000 $LUA_LIBS"
678 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200679 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200680 if test "$fail_if_missing" = "yes" -a "$lua_ok" != "yes"; then
Bram Moolenaarf788a062011-12-14 20:51:25 +0100681 AC_MSG_ERROR([could not configure lua])
682 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200683 AC_SUBST(LUA_SRC)
684 AC_SUBST(LUA_OBJ)
685 AC_SUBST(LUA_PRO)
686 AC_SUBST(LUA_LIBS)
687 AC_SUBST(LUA_CFLAGS)
688fi
689
690
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000691dnl Check for MzScheme feature.
692AC_MSG_CHECKING(--enable-mzschemeinterp argument)
693AC_ARG_ENABLE(mzschemeinterp,
694 [ --enable-mzschemeinterp Include MzScheme interpreter.], ,
695 [enable_mzschemeinterp="no"])
696AC_MSG_RESULT($enable_mzschemeinterp)
697
698if test "$enable_mzschemeinterp" = "yes"; then
699 dnl -- find the mzscheme executable
700 AC_SUBST(vi_cv_path_mzscheme)
701
702 AC_MSG_CHECKING(--with-plthome argument)
703 AC_ARG_WITH(plthome,
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000704 [ --with-plthome=PLTHOME Use PLTHOME.],
705 with_plthome="$withval"; AC_MSG_RESULT($with_plthome),
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000706 with_plthome="";AC_MSG_RESULT("no"))
707
708 if test "X$with_plthome" != "X"; then
709 vi_cv_path_mzscheme_pfx="$with_plthome"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100710 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000711 else
712 AC_MSG_CHECKING(PLTHOME environment var)
713 if test "X$PLTHOME" != "X"; then
714 AC_MSG_RESULT("$PLTHOME")
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000715 vi_cv_path_mzscheme_pfx="$PLTHOME"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100716 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000717 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000718 AC_MSG_RESULT(not set)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000719 dnl -- try to find MzScheme executable
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000720 AC_PATH_PROG(vi_cv_path_mzscheme, mzscheme)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000721
722 dnl resolve symbolic link, the executable is often elsewhere and there
723 dnl are no links for the include files.
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000724 if test "X$vi_cv_path_mzscheme" != "X"; then
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000725 lsout=`ls -l $vi_cv_path_mzscheme`
726 if echo "$lsout" | grep -e '->' >/dev/null 2>/dev/null; then
727 vi_cv_path_mzscheme=`echo "$lsout" | sed 's/.*-> \(.*\)/\1/'`
728 fi
729 fi
730
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000731 if test "X$vi_cv_path_mzscheme" != "X"; then
732 dnl -- find where MzScheme thinks it was installed
733 AC_CACHE_CHECK(MzScheme install prefix,vi_cv_path_mzscheme_pfx,
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000734 dnl different versions of MzScheme differ in command line processing
735 dnl use universal approach
736 echo "(display (simplify-path \
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000737 (build-path (call-with-values \
738 (lambda () (split-path (find-system-path (quote exec-file)))) \
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000739 (lambda (base name must-be-dir?) base)) (quote up))))" > mzdirs.scm
740 dnl Remove a trailing slash
741 [ vi_cv_path_mzscheme_pfx=`${vi_cv_path_mzscheme} -r mzdirs.scm | \
742 sed -e 's+/$++'` ])
743 rm -f mzdirs.scm
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000744 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000745 fi
746 fi
747
748 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100749 AC_MSG_CHECKING(for racket include directory)
750 SCHEME_INC=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-include-dir))) (when (path? p) (display p)))'`
751 if test "X$SCHEME_INC" != "X"; then
752 AC_MSG_RESULT(${SCHEME_INC})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000753 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100754 AC_MSG_RESULT(not found)
755 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include)
756 if test -f "$vi_cv_path_mzscheme_pfx/include/scheme.h"; then
757 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000758 AC_MSG_RESULT(yes)
Bram Moolenaard7afed32007-05-06 13:26:41 +0000759 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000760 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100761 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt)
762 if test -f "$vi_cv_path_mzscheme_pfx/include/plt/scheme.h"; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000763 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100764 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000765 else
766 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100767 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket)
768 if test -f "$vi_cv_path_mzscheme_pfx/include/racket/scheme.h"; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100769 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100770 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100771 else
772 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100773 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/)
774 if test -f /usr/include/plt/scheme.h; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100775 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100776 SCHEME_INC=/usr/include/plt
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100777 else
778 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100779 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/racket/)
780 if test -f /usr/include/racket/scheme.h; then
781 AC_MSG_RESULT(yes)
782 SCHEME_INC=/usr/include/racket
783 else
784 AC_MSG_RESULT(no)
785 vi_cv_path_mzscheme_pfx=
786 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100787 fi
788 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000789 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000790 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000791 fi
792 fi
793
794 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100795
796 AC_MSG_CHECKING(for racket lib directory)
797 SCHEME_LIB=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-lib-dir))) (when (path? p) (display p)))'`
798 if test "X$SCHEME_LIB" != "X"; then
799 AC_MSG_RESULT(${SCHEME_LIB})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000800 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100801 AC_MSG_RESULT(not found)
802 fi
803
804 for path in "${vi_cv_path_mzscheme_pfx}/lib" "${SCHEME_LIB}"; do
805 if test "X$path" != "X"; then
806 if test "x$MACOSX" = "xyes"; then
807 MZSCHEME_LIBS="-framework Racket"
808 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
809 elif test -f "${path}/libmzscheme3m.a"; then
810 MZSCHEME_LIBS="${path}/libmzscheme3m.a"
811 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
812 elif test -f "${path}/libracket3m.a"; then
813 MZSCHEME_LIBS="${path}/libracket3m.a"
814 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
815 elif test -f "${path}/libracket.a"; then
816 MZSCHEME_LIBS="${path}/libracket.a ${path}/libmzgc.a"
817 elif test -f "${path}/libmzscheme.a"; then
818 MZSCHEME_LIBS="${path}/libmzscheme.a ${path}/libmzgc.a"
819 else
820 dnl Using shared objects
821 if test -f "${path}/libmzscheme3m.so"; then
822 MZSCHEME_LIBS="-L${path} -lmzscheme3m"
823 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
824 elif test -f "${path}/libracket3m.so"; then
825 MZSCHEME_LIBS="-L${path} -lracket3m"
826 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
827 elif test -f "${path}/libracket.so"; then
828 MZSCHEME_LIBS="-L${path} -lracket -lmzgc"
829 else
830 dnl try next until last
831 if test "$path" != "$SCHEME_LIB"; then
832 continue
833 fi
834 MZSCHEME_LIBS="-L${path} -lmzscheme -lmzgc"
835 fi
836 if test "$GCC" = yes; then
837 dnl Make Vim remember the path to the library. For when it's not in
838 dnl $LD_LIBRARY_PATH.
839 MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${path}"
840 elif test "`(uname) 2>/dev/null`" = SunOS &&
841 uname -r | grep '^5' >/dev/null; then
842 MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${path}"
843 fi
844 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000845 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100846 if test "X$MZSCHEME_LIBS" != "X"; then
847 break
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +0000848 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100849 done
850
851 AC_MSG_CHECKING([if racket requires -pthread])
852 if test "X$SCHEME_LIB" != "X" && $FGREP -e -pthread "$SCHEME_LIB/buildinfo" >/dev/null ; then
853 AC_MSG_RESULT(yes)
854 MZSCHEME_LIBS="${MZSCHEME_LIBS} -pthread"
855 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -pthread"
856 else
857 AC_MSG_RESULT(no)
858 fi
859
860 AC_MSG_CHECKING(for racket config directory)
861 SCHEME_CONFIGDIR=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-config-dir))) (when (path? p) (display p)))'`
862 if test "X$SCHEME_CONFIGDIR" != "X"; then
863 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DMZSCHEME_CONFIGDIR='\"${SCHEME_CONFIGDIR}\"'"
864 AC_MSG_RESULT(${SCHEME_CONFIGDIR})
865 else
866 AC_MSG_RESULT(not found)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000867 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100868
869 AC_MSG_CHECKING(for racket collects directory)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100870 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))))'`
871 if test "X$SCHEME_COLLECTS" = "X"; then
872 if test -d "$vi_cv_path_mzscheme_pfx/lib/plt/collects"; then
873 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/plt/
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100874 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100875 if test -d "$vi_cv_path_mzscheme_pfx/lib/racket/collects"; then
876 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/racket/
Bram Moolenaar75676462013-01-30 14:55:42 +0100877 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100878 if test -d "$vi_cv_path_mzscheme_pfx/share/racket/collects"; then
879 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/
880 else
881 if test -d "$vi_cv_path_mzscheme_pfx/collects"; then
882 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/
883 fi
Bram Moolenaar75676462013-01-30 14:55:42 +0100884 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100885 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100886 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000887 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100888 if test "X$SCHEME_COLLECTS" != "X" ; then
889 AC_MSG_RESULT(${SCHEME_COLLECTS})
890 else
891 AC_MSG_RESULT(not found)
892 fi
893
894 AC_MSG_CHECKING(for mzscheme_base.c)
895 if test -f "${SCHEME_COLLECTS}collects/scheme/base.ss" ; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000896 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +0100897 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
898 MZSCHEME_MOD="++lib scheme/base"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100899 else
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100900 if test -f "${SCHEME_COLLECTS}collects/scheme/base.rkt" ; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100901 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"
904 else
905 if test -f "${SCHEME_COLLECTS}collects/racket/base.rkt" ; then
906 MZSCHEME_EXTRA="mzscheme_base.c"
907 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/raco ctool"
908 MZSCHEME_MOD=""
909 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100910 fi
911 fi
912 if test "X$MZSCHEME_EXTRA" != "X" ; then
913 dnl need to generate bytecode for MzScheme base
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000914 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE"
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100915 AC_MSG_RESULT(needed)
916 else
917 AC_MSG_RESULT(not needed)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000918 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100919
Bram Moolenaar9e902192013-07-17 18:58:11 +0200920 dnl On Ubuntu this fixes "undefined reference to symbol 'ffi_type_void'".
921 AC_CHECK_LIB(ffi, ffi_type_void, [MZSCHEME_LIBS="$MZSCHEME_LIBS -lffi"])
922
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000923 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -I${SCHEME_INC} \
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100924 -DMZSCHEME_COLLECTS='\"${SCHEME_COLLECTS}collects\"'"
Bram Moolenaar9e902192013-07-17 18:58:11 +0200925
926 dnl Test that we can compile a simple program with these CFLAGS and LIBS.
927 AC_MSG_CHECKING([if compile and link flags for MzScheme are sane])
928 cflags_save=$CFLAGS
929 libs_save=$LIBS
930 CFLAGS="$CFLAGS $MZSCHEME_CFLAGS"
931 LIBS="$LIBS $MZSCHEME_LIBS"
932 AC_TRY_LINK(,[ ],
933 AC_MSG_RESULT(yes); mzs_ok=yes,
934 AC_MSG_RESULT(no: MZSCHEME DISABLED); mzs_ok=no)
935 CFLAGS=$cflags_save
936 LIBS=$libs_save
937 if test $mzs_ok = yes; then
938 MZSCHEME_SRC="if_mzsch.c"
939 MZSCHEME_OBJ="objects/if_mzsch.o"
940 MZSCHEME_PRO="if_mzsch.pro"
941 AC_DEFINE(FEAT_MZSCHEME)
942 else
943 MZSCHEME_CFLAGS=
944 MZSCHEME_LIBS=
945 MZSCHEME_EXTRA=
946 MZSCHEME_MZC=
947 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000948 fi
949 AC_SUBST(MZSCHEME_SRC)
950 AC_SUBST(MZSCHEME_OBJ)
951 AC_SUBST(MZSCHEME_PRO)
952 AC_SUBST(MZSCHEME_LIBS)
953 AC_SUBST(MZSCHEME_CFLAGS)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000954 AC_SUBST(MZSCHEME_EXTRA)
955 AC_SUBST(MZSCHEME_MZC)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000956fi
957
958
Bram Moolenaar071d4272004-06-13 20:20:40 +0000959AC_MSG_CHECKING(--enable-perlinterp argument)
960AC_ARG_ENABLE(perlinterp,
Bram Moolenaare06c1882010-07-21 22:05:20 +0200961 [ --enable-perlinterp[=OPTS] Include Perl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000962 [enable_perlinterp="no"])
963AC_MSG_RESULT($enable_perlinterp)
Bram Moolenaare06c1882010-07-21 22:05:20 +0200964if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +0100965 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
966 AC_MSG_ERROR([cannot use Perl with tiny or small features])
967 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000968 AC_SUBST(vi_cv_path_perl)
969 AC_PATH_PROG(vi_cv_path_perl, perl)
970 if test "X$vi_cv_path_perl" != "X"; then
971 AC_MSG_CHECKING(Perl version)
972 if $vi_cv_path_perl -e 'require 5.003_01' >/dev/null 2>/dev/null; then
973 eval `$vi_cv_path_perl -V:usethreads`
Bram Moolenaare06c1882010-07-21 22:05:20 +0200974 eval `$vi_cv_path_perl -V:libperl`
Bram Moolenaar071d4272004-06-13 20:20:40 +0000975 if test "X$usethreads" = "XUNKNOWN" -o "X$usethreads" = "Xundef"; then
976 badthreads=no
977 else
978 if $vi_cv_path_perl -e 'require 5.6.0' >/dev/null 2>/dev/null; then
979 eval `$vi_cv_path_perl -V:use5005threads`
980 if test "X$use5005threads" = "XUNKNOWN" -o "X$use5005threads" = "Xundef"; then
981 badthreads=no
982 else
983 badthreads=yes
984 AC_MSG_RESULT(>>> Perl > 5.6 with 5.5 threads cannot be used <<<)
985 fi
986 else
987 badthreads=yes
988 AC_MSG_RESULT(>>> Perl 5.5 with threads cannot be used <<<)
989 fi
990 fi
991 if test $badthreads = no; then
992 AC_MSG_RESULT(OK)
993 eval `$vi_cv_path_perl -V:shrpenv`
994 if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04
995 shrpenv=""
996 fi
997 vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlibexp}'`
998 AC_SUBST(vi_cv_perllib)
Bram Moolenaard5f62b12014-08-17 17:05:44 +0200999 vi_cv_perl_extutils=unknown_perl_extutils_path
1000 for extutils_rel_path in ExtUtils vendor_perl/ExtUtils; do
1001 xsubpp_path="$vi_cv_perllib/$extutils_rel_path/xsubpp"
1002 if test -f "$xsubpp_path"; then
1003 vi_cv_perl_xsubpp="$xsubpp_path"
1004 fi
1005 done
1006 AC_SUBST(vi_cv_perl_xsubpp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001007 dnl Remove "-fno-something", it breaks using cproto.
Bram Moolenaar280a8682015-06-21 13:41:08 +02001008 dnl Remove "-fdebug-prefix-map", it isn't supported by clang.
Bram Moolenaar071d4272004-06-13 20:20:40 +00001009 perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
Bram Moolenaar280a8682015-06-21 13:41:08 +02001010 -e 'ccflags;perl_inc;print"\n"' | sed -e 's/-fno[[^ ]]*//' \
1011 -e 's/-fdebug-prefix-map[[^ ]]*//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001012 dnl Remove "-lc", it breaks on FreeBSD when using "-pthread".
1013 perllibs=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed -e 'ldopts' | \
1014 sed -e '/Warning/d' -e '/Note (probably harmless)/d' \
1015 -e 's/-bE:perl.exp//' -e 's/-lc //'`
1016 dnl Don't add perl lib to $LIBS: if it's not in LD_LIBRARY_PATH
1017 dnl a test in configure may fail because of that.
1018 perlldflags=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed \
1019 -e 'ccdlflags' | sed -e 's/-bE:perl.exp//'`
1020
1021 dnl check that compiling a simple program still works with the flags
1022 dnl added for Perl.
1023 AC_MSG_CHECKING([if compile and link flags for Perl are sane])
1024 cflags_save=$CFLAGS
1025 libs_save=$LIBS
1026 ldflags_save=$LDFLAGS
1027 CFLAGS="$CFLAGS $perlcppflags"
1028 LIBS="$LIBS $perllibs"
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001029 perlldflags=`echo "$perlldflags" | sed -e 's/^ *//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001030 LDFLAGS="$perlldflags $LDFLAGS"
1031 AC_TRY_LINK(,[ ],
1032 AC_MSG_RESULT(yes); perl_ok=yes,
1033 AC_MSG_RESULT(no: PERL DISABLED); perl_ok=no)
1034 CFLAGS=$cflags_save
1035 LIBS=$libs_save
1036 LDFLAGS=$ldflags_save
1037 if test $perl_ok = yes; then
1038 if test "X$perlcppflags" != "X"; then
Bram Moolenaard7afed32007-05-06 13:26:41 +00001039 dnl remove -pipe and -Wxxx, it confuses cproto
1040 PERL_CFLAGS=`echo "$perlcppflags" | sed -e 's/-pipe //' -e 's/-W[[^ ]]*//'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001041 fi
1042 if test "X$perlldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001043 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$perlldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001044 LDFLAGS="$perlldflags $LDFLAGS"
1045 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001046 fi
1047 PERL_LIBS=$perllibs
1048 PERL_SRC="auto/if_perl.c if_perlsfio.c"
1049 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o"
1050 PERL_PRO="if_perl.pro if_perlsfio.pro"
1051 AC_DEFINE(FEAT_PERL)
1052 fi
1053 fi
1054 else
1055 AC_MSG_RESULT(>>> too old; need Perl version 5.003_01 or later <<<)
1056 fi
1057 fi
1058
1059 if test "x$MACOSX" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00001060 dnl Mac OS X 10.2 or later
Bram Moolenaar071d4272004-06-13 20:20:40 +00001061 dir=/System/Library/Perl
1062 darwindir=$dir/darwin
1063 if test -d $darwindir; then
1064 PERL=/usr/bin/perl
1065 else
1066 dnl Mac OS X 10.3
1067 dir=/System/Library/Perl/5.8.1
1068 darwindir=$dir/darwin-thread-multi-2level
1069 if test -d $darwindir; then
1070 PERL=/usr/bin/perl
1071 fi
1072 fi
1073 if test -n "$PERL"; then
1074 PERL_DIR="$dir"
1075 PERL_CFLAGS="-DFEAT_PERL -I$darwindir/CORE"
1076 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o $darwindir/auto/DynaLoader/DynaLoader.a"
1077 PERL_LIBS="-L$darwindir/CORE -lperl"
1078 fi
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001079 dnl Perl on Mac OS X 10.5 adds "-arch" flags but these should only
1080 dnl be included if requested by passing --with-mac-arch to
1081 dnl configure, so strip these flags first (if present)
1082 PERL_LIBS=`echo "$PERL_LIBS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
1083 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 +00001084 fi
Bram Moolenaare06c1882010-07-21 22:05:20 +02001085 if test "$enable_perlinterp" = "dynamic"; then
1086 if test "$perl_ok" = "yes" -a "X$libperl" != "X"; then
1087 AC_DEFINE(DYNAMIC_PERL)
1088 PERL_CFLAGS="-DDYNAMIC_PERL_DLL=\\\"$libperl\\\" $PERL_CFLAGS"
1089 fi
1090 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001091
1092 if test "$fail_if_missing" = "yes" -a "$perl_ok" != "yes"; then
1093 AC_MSG_ERROR([could not configure perl])
1094 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001095fi
1096AC_SUBST(shrpenv)
1097AC_SUBST(PERL_SRC)
1098AC_SUBST(PERL_OBJ)
1099AC_SUBST(PERL_PRO)
1100AC_SUBST(PERL_CFLAGS)
1101AC_SUBST(PERL_LIBS)
1102
1103AC_MSG_CHECKING(--enable-pythoninterp argument)
1104AC_ARG_ENABLE(pythoninterp,
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001105 [ --enable-pythoninterp[=OPTS] Include Python interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001106 [enable_pythoninterp="no"])
1107AC_MSG_RESULT($enable_pythoninterp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001108if test "$enable_pythoninterp" = "yes" -o "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001109 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1110 AC_MSG_ERROR([cannot use Python with tiny or small features])
1111 fi
1112
Bram Moolenaar071d4272004-06-13 20:20:40 +00001113 dnl -- find the python executable
Bram Moolenaar09ba6d72012-12-12 14:25:05 +01001114 AC_PATH_PROGS(vi_cv_path_python, python2 python)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001115 if test "X$vi_cv_path_python" != "X"; then
1116
1117 dnl -- get its version number
1118 AC_CACHE_CHECK(Python version,vi_cv_var_python_version,
1119 [[vi_cv_var_python_version=`
1120 ${vi_cv_path_python} -c 'import sys; print sys.version[:3]'`
1121 ]])
1122
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001123 dnl -- it must be at least version 2.3
1124 AC_MSG_CHECKING(Python is 2.3 or better)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001125 if ${vi_cv_path_python} -c \
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001126 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001127 then
1128 AC_MSG_RESULT(yep)
1129
1130 dnl -- find where python thinks it was installed
1131 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python_pfx,
1132 [ vi_cv_path_python_pfx=`
1133 ${vi_cv_path_python} -c \
1134 "import sys; print sys.prefix"` ])
1135
1136 dnl -- and where it thinks it runs
1137 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python_epfx,
1138 [ vi_cv_path_python_epfx=`
1139 ${vi_cv_path_python} -c \
1140 "import sys; print sys.exec_prefix"` ])
1141
1142 dnl -- python's internal library path
1143
1144 AC_CACHE_VAL(vi_cv_path_pythonpath,
1145 [ vi_cv_path_pythonpath=`
1146 unset PYTHONPATH;
1147 ${vi_cv_path_python} -c \
1148 "import sys, string; print string.join(sys.path,':')"` ])
1149
1150 dnl -- where the Python implementation library archives are
1151
1152 AC_ARG_WITH(python-config-dir,
1153 [ --with-python-config-dir=PATH Python's config directory],
1154 [ vi_cv_path_python_conf="${withval}" ] )
1155
1156 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python_conf,
1157 [
1158 vi_cv_path_python_conf=
Bram Moolenaarac499e32013-06-02 19:14:17 +02001159 d=`${vi_cv_path_python} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBPL')"`
1160 if test -d "$d" && test -f "$d/config.c"; then
1161 vi_cv_path_python_conf="$d"
1162 else
1163 for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
1164 for subdir in lib64 lib share; do
1165 d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
1166 if test -d "$d" && test -f "$d/config.c"; then
1167 vi_cv_path_python_conf="$d"
1168 fi
1169 done
Bram Moolenaar071d4272004-06-13 20:20:40 +00001170 done
Bram Moolenaarac499e32013-06-02 19:14:17 +02001171 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001172 ])
1173
1174 PYTHON_CONFDIR="${vi_cv_path_python_conf}"
1175
1176 if test "X$PYTHON_CONFDIR" = "X"; then
1177 AC_MSG_RESULT([can't find it!])
1178 else
1179
1180 dnl -- we need to examine Python's config/Makefile too
1181 dnl see what the interpreter is built from
1182 AC_CACHE_VAL(vi_cv_path_python_plibs,
1183 [
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001184 pwd=`pwd`
1185 tmp_mkf="$pwd/config-PyMake$$"
1186 cat -- "${PYTHON_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001187__:
Bram Moolenaar218116c2010-05-20 21:46:00 +02001188 @echo "python_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001189 @echo "python_LIBS='$(LIBS)'"
1190 @echo "python_SYSLIBS='$(SYSLIBS)'"
1191 @echo "python_LINKFORSHARED='$(LINKFORSHARED)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001192 @echo "python_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001193 @echo "python_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001194 @echo "python_PYTHONFRAMEWORK='$(PYTHONFRAMEWORK)'"
1195 @echo "python_PYTHONFRAMEWORKPREFIX='$(PYTHONFRAMEWORKPREFIX)'"
1196 @echo "python_PYTHONFRAMEWORKINSTALLDIR='$(PYTHONFRAMEWORKINSTALLDIR)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001197eof
1198 dnl -- delete the lines from make about Entering/Leaving directory
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001199 eval "`cd ${PYTHON_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1200 rm -f -- "${tmp_mkf}"
Bram Moolenaarcff50f52016-08-14 17:32:52 +02001201 if test "x$MACOSX" = "xyes" && test -n "${python_PYTHONFRAMEWORK}" && ${vi_cv_path_python} -c \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001202 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then
1203 vi_cv_path_python_plibs="-framework Python"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001204 if test "x${vi_cv_path_python}" != "x/usr/bin/python" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
1205 vi_cv_path_python_plibs="-F${python_PYTHONFRAMEWORKPREFIX} -framework Python"
1206 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001207 else
1208 if test "${vi_cv_var_python_version}" = "1.4"; then
1209 vi_cv_path_python_plibs="${PYTHON_CONFDIR}/libModules.a ${PYTHON_CONFDIR}/libPython.a ${PYTHON_CONFDIR}/libObjects.a ${PYTHON_CONFDIR}/libParser.a"
1210 else
1211 vi_cv_path_python_plibs="-L${PYTHON_CONFDIR} -lpython${vi_cv_var_python_version}"
1212 fi
Bram Moolenaar6c927552015-03-24 12:21:33 +01001213 dnl -- Check if the path contained in python_LINKFORSHARED is
1214 dnl usable for vim build. If not, make and try other
1215 dnl candidates.
Bram Moolenaara161e262015-03-24 15:14:27 +01001216 if test -n "${python_LINKFORSHARED}" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
Bram Moolenaar6c927552015-03-24 12:21:33 +01001217 python_link_symbol=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]].*/\1/'`
1218 python_link_path=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]][[ \t]]*\(.*\)/\2/'`
1219 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1220 dnl -- The path looks relative. Guess the absolute one using
1221 dnl the prefix and try that.
1222 python_link_path="${python_PYTHONFRAMEWORKPREFIX}/${python_link_path}"
1223 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1224 dnl -- A last resort.
1225 python_link_path="${python_PYTHONFRAMEWORKINSTALLDIR}/Versions/${vi_cv_var_python_version}/${python_PYTHONFRAMEWORK}"
1226 dnl -- No check is done. The last word is left to the
1227 dnl "sanity" test on link flags that follows shortly.
1228 fi
1229 python_LINKFORSHARED="${python_link_symbol} ${python_link_path}"
1230 fi
1231 fi
Bram Moolenaar218116c2010-05-20 21:46:00 +02001232 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 +00001233 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1234 vi_cv_path_python_plibs=`echo $vi_cv_path_python_plibs | sed s/-ltermcap//`
1235 fi
1236 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001237 AC_CACHE_CHECK(Python's dll name,vi_cv_dll_name_python,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001238 [
1239 if test "X$python_DLLLIBRARY" != "X"; then
1240 vi_cv_dll_name_python="$python_DLLLIBRARY"
1241 else
1242 vi_cv_dll_name_python="$python_INSTSONAME"
1243 fi
1244 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00001245
1246 PYTHON_LIBS="${vi_cv_path_python_plibs}"
1247 if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
Bram Moolenaar780c3e92013-06-11 20:53:28 +02001248 PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001249 else
Bram Moolenaar780c3e92013-06-11 20:53:28 +02001250 PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -I${vi_cv_path_python_epfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001251 fi
1252 PYTHON_SRC="if_python.c"
Bram Moolenaar9bdb9a02012-07-25 16:32:08 +02001253 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001254 if test "${vi_cv_var_python_version}" = "1.4"; then
1255 PYTHON_OBJ="$PYTHON_OBJ objects/py_getpath.o"
1256 fi
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001257 PYTHON_GETPATH_CFLAGS="-DPYTHONPATH='\"${vi_cv_path_pythonpath}\"' -DPREFIX='\"${vi_cv_path_python_pfx}\"' -DEXEC_PREFIX='\"${vi_cv_path_python_epfx}\"'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001258
1259 dnl On FreeBSD linking with "-pthread" is required to use threads.
1260 dnl _THREAD_SAFE must be used for compiling then.
1261 dnl The "-pthread" is added to $LIBS, so that the following check for
1262 dnl sigaltstack() will look in libc_r (it's there in libc!).
1263 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1264 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1265 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1266 AC_MSG_CHECKING([if -pthread should be used])
1267 threadsafe_flag=
1268 thread_lib=
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00001269 dnl if test "x$MACOSX" != "xyes"; then
1270 if test "`(uname) 2>/dev/null`" != Darwin; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001271 test "$GCC" = yes && threadsafe_flag="-pthread"
1272 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1273 threadsafe_flag="-D_THREAD_SAFE"
1274 thread_lib="-pthread"
1275 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001276 if test "`(uname) 2>/dev/null`" = SunOS; then
1277 threadsafe_flag="-pthreads"
1278 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001279 fi
1280 libs_save_old=$LIBS
1281 if test -n "$threadsafe_flag"; then
1282 cflags_save=$CFLAGS
1283 CFLAGS="$CFLAGS $threadsafe_flag"
1284 LIBS="$LIBS $thread_lib"
1285 AC_TRY_LINK(,[ ],
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001286 AC_MSG_RESULT(yes); PYTHON_CFLAGS="$PYTHON_CFLAGS $threadsafe_flag",
Bram Moolenaar071d4272004-06-13 20:20:40 +00001287 AC_MSG_RESULT(no); LIBS=$libs_save_old
1288 )
1289 CFLAGS=$cflags_save
1290 else
1291 AC_MSG_RESULT(no)
1292 fi
1293
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001294 dnl Check that compiling a simple program still works with the flags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001295 dnl added for Python.
1296 AC_MSG_CHECKING([if compile and link flags for Python are sane])
1297 cflags_save=$CFLAGS
1298 libs_save=$LIBS
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001299 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001300 LIBS="$LIBS $PYTHON_LIBS"
1301 AC_TRY_LINK(,[ ],
1302 AC_MSG_RESULT(yes); python_ok=yes,
1303 AC_MSG_RESULT(no: PYTHON DISABLED); python_ok=no)
1304 CFLAGS=$cflags_save
1305 LIBS=$libs_save
1306 if test $python_ok = yes; then
1307 AC_DEFINE(FEAT_PYTHON)
1308 else
1309 LIBS=$libs_save_old
1310 PYTHON_SRC=
1311 PYTHON_OBJ=
1312 PYTHON_LIBS=
1313 PYTHON_CFLAGS=
1314 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001315 fi
1316 else
1317 AC_MSG_RESULT(too old)
1318 fi
1319 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001320
1321 if test "$fail_if_missing" = "yes" -a "$python_ok" != "yes"; then
1322 AC_MSG_ERROR([could not configure python])
1323 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001324fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001325
Bram Moolenaar071d4272004-06-13 20:20:40 +00001326AC_SUBST(PYTHON_CONFDIR)
1327AC_SUBST(PYTHON_LIBS)
1328AC_SUBST(PYTHON_GETPATH_CFLAGS)
1329AC_SUBST(PYTHON_CFLAGS)
1330AC_SUBST(PYTHON_SRC)
1331AC_SUBST(PYTHON_OBJ)
1332
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001333
1334AC_MSG_CHECKING(--enable-python3interp argument)
1335AC_ARG_ENABLE(python3interp,
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001336 [ --enable-python3interp[=OPTS] Include Python3 interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001337 [enable_python3interp="no"])
1338AC_MSG_RESULT($enable_python3interp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001339if test "$enable_python3interp" = "yes" -o "$enable_python3interp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001340 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1341 AC_MSG_ERROR([cannot use Python with tiny or small features])
1342 fi
1343
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001344 dnl -- find the python3 executable
Bram Moolenaar09ba6d72012-12-12 14:25:05 +01001345 AC_PATH_PROGS(vi_cv_path_python3, python3 python)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001346 if test "X$vi_cv_path_python3" != "X"; then
1347
1348 dnl -- get its version number
1349 AC_CACHE_CHECK(Python version,vi_cv_var_python3_version,
1350 [[vi_cv_var_python3_version=`
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001351 ${vi_cv_path_python3} -c 'import sys; print(sys.version[:3])'`
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001352 ]])
1353
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001354 dnl -- it must be at least version 3
1355 AC_MSG_CHECKING(Python is 3.0 or better)
1356 if ${vi_cv_path_python3} -c \
1357 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.0)"
1358 then
1359 AC_MSG_RESULT(yep)
Bram Moolenaar456f2bb2011-06-12 21:37:13 +02001360
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001361 dnl -- get abiflags for python 3.2 or higher (PEP 3149)
1362 AC_CACHE_CHECK(Python's abiflags,vi_cv_var_python3_abiflags,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001363 [
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001364 vi_cv_var_python3_abiflags=
1365 if ${vi_cv_path_python3} -c \
1366 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)"
1367 then
1368 vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \
1369 "import sys; print(sys.abiflags)"`
1370 fi ])
1371
1372 dnl -- find where python3 thinks it was installed
1373 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx,
1374 [ vi_cv_path_python3_pfx=`
1375 ${vi_cv_path_python3} -c \
1376 "import sys; print(sys.prefix)"` ])
1377
1378 dnl -- and where it thinks it runs
1379 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx,
1380 [ vi_cv_path_python3_epfx=`
1381 ${vi_cv_path_python3} -c \
1382 "import sys; print(sys.exec_prefix)"` ])
1383
1384 dnl -- python3's internal library path
1385
1386 AC_CACHE_VAL(vi_cv_path_python3path,
1387 [ vi_cv_path_python3path=`
1388 unset PYTHONPATH;
1389 ${vi_cv_path_python3} -c \
1390 "import sys, string; print(':'.join(sys.path))"` ])
1391
1392 dnl -- where the Python implementation library archives are
1393
1394 AC_ARG_WITH(python3-config-dir,
1395 [ --with-python3-config-dir=PATH Python's config directory],
1396 [ vi_cv_path_python3_conf="${withval}" ] )
1397
1398 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf,
1399 [
1400 vi_cv_path_python3_conf=
Bram Moolenaarfee496d2013-07-12 20:07:24 +02001401 config_dir="config-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001402 d=`${vi_cv_path_python3} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBPL'))"`
1403 if test -d "$d" && test -f "$d/config.c"; then
1404 vi_cv_path_python3_conf="$d"
1405 else
1406 for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do
1407 for subdir in lib64 lib share; do
1408 d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}"
1409 if test -d "$d" && test -f "$d/config.c"; then
1410 vi_cv_path_python3_conf="$d"
1411 fi
1412 done
1413 done
1414 fi
1415 ])
1416
1417 PYTHON3_CONFDIR="${vi_cv_path_python3_conf}"
1418
1419 if test "X$PYTHON3_CONFDIR" = "X"; then
1420 AC_MSG_RESULT([can't find it!])
1421 else
1422
1423 dnl -- we need to examine Python's config/Makefile too
1424 dnl see what the interpreter is built from
1425 AC_CACHE_VAL(vi_cv_path_python3_plibs,
1426 [
1427 pwd=`pwd`
1428 tmp_mkf="$pwd/config-PyMake$$"
1429 cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001430__:
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001431 @echo "python3_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001432 @echo "python3_LIBS='$(LIBS)'"
1433 @echo "python3_SYSLIBS='$(SYSLIBS)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001434 @echo "python3_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001435 @echo "python3_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001436eof
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001437 dnl -- delete the lines from make about Entering/Leaving directory
1438 eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1439 rm -f -- "${tmp_mkf}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001440 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 +02001441 vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}"
1442 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1443 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//`
1444 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//`
1445 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001446 AC_CACHE_CHECK(Python3's dll name,vi_cv_dll_name_python3,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001447 [
1448 if test "X$python3_DLLLIBRARY" != "X"; then
1449 vi_cv_dll_name_python3="$python3_DLLLIBRARY"
1450 else
1451 vi_cv_dll_name_python3="$python3_INSTSONAME"
1452 fi
1453 ])
1454
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001455 PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
1456 if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
Bram Moolenaar780c3e92013-06-11 20:53:28 +02001457 PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -DPYTHON3_HOME='L\"${vi_cv_path_python3_pfx}\"'"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001458 else
Bram Moolenaar780c3e92013-06-11 20:53:28 +02001459 PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -I${vi_cv_path_python3_epfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -DPYTHON3_HOME='L\"${vi_cv_path_python3_pfx}\"'"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001460 fi
1461 PYTHON3_SRC="if_python3.c"
1462 PYTHON3_OBJ="objects/if_python3.o"
1463
1464 dnl On FreeBSD linking with "-pthread" is required to use threads.
1465 dnl _THREAD_SAFE must be used for compiling then.
1466 dnl The "-pthread" is added to $LIBS, so that the following check for
1467 dnl sigaltstack() will look in libc_r (it's there in libc!).
1468 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1469 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1470 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1471 AC_MSG_CHECKING([if -pthread should be used])
1472 threadsafe_flag=
1473 thread_lib=
1474 dnl if test "x$MACOSX" != "xyes"; then
1475 if test "`(uname) 2>/dev/null`" != Darwin; then
1476 test "$GCC" = yes && threadsafe_flag="-pthread"
1477 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1478 threadsafe_flag="-D_THREAD_SAFE"
1479 thread_lib="-pthread"
1480 fi
1481 if test "`(uname) 2>/dev/null`" = SunOS; then
1482 threadsafe_flag="-pthreads"
1483 fi
1484 fi
1485 libs_save_old=$LIBS
1486 if test -n "$threadsafe_flag"; then
1487 cflags_save=$CFLAGS
1488 CFLAGS="$CFLAGS $threadsafe_flag"
1489 LIBS="$LIBS $thread_lib"
1490 AC_TRY_LINK(,[ ],
1491 AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag",
1492 AC_MSG_RESULT(no); LIBS=$libs_save_old
1493 )
1494 CFLAGS=$cflags_save
1495 else
1496 AC_MSG_RESULT(no)
1497 fi
1498
1499 dnl check that compiling a simple program still works with the flags
1500 dnl added for Python.
1501 AC_MSG_CHECKING([if compile and link flags for Python 3 are sane])
1502 cflags_save=$CFLAGS
1503 libs_save=$LIBS
1504 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1505 LIBS="$LIBS $PYTHON3_LIBS"
1506 AC_TRY_LINK(,[ ],
1507 AC_MSG_RESULT(yes); python3_ok=yes,
1508 AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no)
1509 CFLAGS=$cflags_save
1510 LIBS=$libs_save
1511 if test "$python3_ok" = yes; then
1512 AC_DEFINE(FEAT_PYTHON3)
1513 else
1514 LIBS=$libs_save_old
1515 PYTHON3_SRC=
1516 PYTHON3_OBJ=
1517 PYTHON3_LIBS=
1518 PYTHON3_CFLAGS=
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001519 fi
1520 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001521 else
1522 AC_MSG_RESULT(too old)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001523 fi
1524 fi
Bram Moolenaar1612b1a2013-06-14 21:22:39 +02001525 if test "$fail_if_missing" = "yes" -a "$python3_ok" != "yes"; then
1526 AC_MSG_ERROR([could not configure python3])
1527 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001528fi
1529
1530AC_SUBST(PYTHON3_CONFDIR)
1531AC_SUBST(PYTHON3_LIBS)
1532AC_SUBST(PYTHON3_CFLAGS)
1533AC_SUBST(PYTHON3_SRC)
1534AC_SUBST(PYTHON3_OBJ)
1535
1536dnl if python2.x and python3.x are enabled one can only link in code
1537dnl with dlopen(), dlsym(), dlclose()
1538if test "$python_ok" = yes && test "$python3_ok" = yes; then
1539 AC_DEFINE(DYNAMIC_PYTHON)
1540 AC_DEFINE(DYNAMIC_PYTHON3)
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001541 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001542 cflags_save=$CFLAGS
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001543 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001544 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001545 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001546 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001547 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001548 #include <dlfcn.h>
1549 /* If this program fails, then RTLD_GLOBAL is needed.
1550 * RTLD_GLOBAL will be used and then it is not possible to
1551 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001552 * Only the first python version used will be switched on.
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001553 */
1554
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001555 int no_rtl_global_needed_for(char *python_instsoname, char *prefix)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001556 {
1557 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001558 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001559 if (pylib != 0)
1560 {
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001561 void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome");
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001562 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1563 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1564 void (*final)(void) = dlsym(pylib, "Py_Finalize");
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001565 (*pfx)(prefix);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001566 (*init)();
1567 needed = (*simple)("import termios") == -1;
1568 (*final)();
1569 dlclose(pylib);
1570 }
1571 return !needed;
1572 }
1573
1574 int main(int argc, char** argv)
1575 {
1576 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001577 if (no_rtl_global_needed_for("${vi_cv_dll_name_python}", "${vi_cv_path_python_pfx}"))
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001578 not_needed = 1;
1579 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001580 }])],
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001581 [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001582
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001583 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001584 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001585
1586 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python3)
1587 cflags_save=$CFLAGS
1588 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001589 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001590 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001591 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001592 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001593 #include <dlfcn.h>
1594 #include <wchar.h>
1595 /* If this program fails, then RTLD_GLOBAL is needed.
1596 * RTLD_GLOBAL will be used and then it is not possible to
1597 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001598 * Only the first python version used will be switched on.
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001599 */
1600
1601 int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix)
1602 {
1603 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001604 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001605 if (pylib != 0)
1606 {
1607 void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome");
1608 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1609 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1610 void (*final)(void) = dlsym(pylib, "Py_Finalize");
1611 (*pfx)(prefix);
1612 (*init)();
1613 needed = (*simple)("import termios") == -1;
1614 (*final)();
1615 dlclose(pylib);
1616 }
1617 return !needed;
1618 }
1619
1620 int main(int argc, char** argv)
1621 {
1622 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001623 if (no_rtl_global_needed_for("${vi_cv_dll_name_python3}", L"${vi_cv_path_python3_pfx}"))
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001624 not_needed = 1;
1625 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001626 }])],
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001627 [AC_MSG_RESULT(yes);AC_DEFINE(PY3_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
1628
1629 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001630 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001631
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001632 PYTHON_SRC="if_python.c"
1633 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001634 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001635 PYTHON_LIBS=
1636 PYTHON3_SRC="if_python3.c"
1637 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001638 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001639 PYTHON3_LIBS=
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001640elif test "$python_ok" = yes && test "$enable_pythoninterp" = "dynamic"; then
1641 AC_DEFINE(DYNAMIC_PYTHON)
1642 PYTHON_SRC="if_python.c"
1643 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001644 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001645 PYTHON_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001646elif test "$python_ok" = yes; then
1647 dnl Check that adding -fPIE works. It may be needed when using a static
1648 dnl Python library.
1649 AC_MSG_CHECKING([if -fPIE can be added for Python])
1650 cflags_save=$CFLAGS
1651 libs_save=$LIBS
1652 CFLAGS="$CFLAGS $PYTHON_CFLAGS -fPIE"
1653 LIBS="$LIBS $PYTHON_LIBS"
1654 AC_TRY_LINK(,[ ],
1655 AC_MSG_RESULT(yes); fpie_ok=yes,
1656 AC_MSG_RESULT(no); fpie_ok=no)
1657 CFLAGS=$cflags_save
1658 LIBS=$libs_save
1659 if test $fpie_ok = yes; then
1660 PYTHON_CFLAGS="$PYTHON_CFLAGS -fPIE"
1661 fi
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001662elif test "$python3_ok" = yes && test "$enable_python3interp" = "dynamic"; then
1663 AC_DEFINE(DYNAMIC_PYTHON3)
1664 PYTHON3_SRC="if_python3.c"
1665 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001666 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001667 PYTHON3_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001668elif test "$python3_ok" = yes; then
1669 dnl Check that adding -fPIE works. It may be needed when using a static
1670 dnl Python library.
1671 AC_MSG_CHECKING([if -fPIE can be added for Python3])
1672 cflags_save=$CFLAGS
1673 libs_save=$LIBS
1674 CFLAGS="$CFLAGS $PYTHON3_CFLAGS -fPIE"
1675 LIBS="$LIBS $PYTHON3_LIBS"
1676 AC_TRY_LINK(,[ ],
1677 AC_MSG_RESULT(yes); fpie_ok=yes,
1678 AC_MSG_RESULT(no); fpie_ok=no)
1679 CFLAGS=$cflags_save
1680 LIBS=$libs_save
1681 if test $fpie_ok = yes; then
1682 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -fPIE"
1683 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001684fi
1685
Bram Moolenaar071d4272004-06-13 20:20:40 +00001686AC_MSG_CHECKING(--enable-tclinterp argument)
1687AC_ARG_ENABLE(tclinterp,
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001688 [ --enable-tclinterp[=OPTS] Include Tcl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001689 [enable_tclinterp="no"])
1690AC_MSG_RESULT($enable_tclinterp)
1691
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001692if test "$enable_tclinterp" = "yes" -o "$enable_tclinterp" = "dynamic"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001693
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001694 dnl on FreeBSD tclsh is a silly script, look for tclsh8.[5420]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001695 AC_MSG_CHECKING(--with-tclsh argument)
1696 AC_ARG_WITH(tclsh, [ --with-tclsh=PATH which tclsh to use (default: tclsh8.0)],
1697 tclsh_name="$withval"; AC_MSG_RESULT($tclsh_name),
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001698 tclsh_name="tclsh8.5"; AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00001699 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1700 AC_SUBST(vi_cv_path_tcl)
1701
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001702 dnl when no specific version specified, also try 8.4, 8.2 and 8.0
1703 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.5"; then
1704 tclsh_name="tclsh8.4"
1705 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1706 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001707 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.4"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001708 tclsh_name="tclsh8.2"
1709 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1710 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001711 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.2"; then
1712 tclsh_name="tclsh8.0"
1713 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1714 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001715 dnl still didn't find it, try without version number
1716 if test "X$vi_cv_path_tcl" = "X"; then
1717 tclsh_name="tclsh"
1718 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1719 fi
1720 if test "X$vi_cv_path_tcl" != "X"; then
1721 AC_MSG_CHECKING(Tcl version)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001722 if echo 'exit [[expr [info tclversion] < 8.0]]' | "$vi_cv_path_tcl" - ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001723 tclver=`echo 'puts [[info tclversion]]' | $vi_cv_path_tcl -`
1724 AC_MSG_RESULT($tclver - OK);
1725 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 +01001726 tcldll=`echo 'puts libtcl[[info tclversion]][[info sharedlibextension]]' | $vi_cv_path_tcl -`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001727
1728 AC_MSG_CHECKING(for location of Tcl include)
1729 if test "x$MACOSX" != "xyes"; then
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001730 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 +00001731 else
1732 dnl For Mac OS X 10.3, use the OS-provided framework location
1733 tclinc="/System/Library/Frameworks/Tcl.framework/Headers"
1734 fi
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001735 TCL_INC=
Bram Moolenaar071d4272004-06-13 20:20:40 +00001736 for try in $tclinc; do
1737 if test -f "$try/tcl.h"; then
1738 AC_MSG_RESULT($try/tcl.h)
1739 TCL_INC=$try
1740 break
1741 fi
1742 done
1743 if test -z "$TCL_INC"; then
1744 AC_MSG_RESULT(<not found>)
1745 SKIP_TCL=YES
1746 fi
1747 if test -z "$SKIP_TCL"; then
1748 AC_MSG_CHECKING(for location of tclConfig.sh script)
1749 if test "x$MACOSX" != "xyes"; then
1750 tclcnf=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001751 tclcnf="$tclcnf `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001752 else
1753 dnl For Mac OS X 10.3, use the OS-provided framework location
1754 tclcnf="/System/Library/Frameworks/Tcl.framework"
1755 fi
1756 for try in $tclcnf; do
Bram Moolenaar49222be2015-12-11 18:11:30 +01001757 if test -f "$try/tclConfig.sh"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001758 AC_MSG_RESULT($try/tclConfig.sh)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001759 . "$try/tclConfig.sh"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001760 dnl use eval, because tcl 8.2 includes ${TCL_DBGX}
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001761 if test "$enable_tclinterp" = "dynamic"; then
1762 TCL_LIBS=`eval echo "$TCL_STUB_LIB_SPEC $TCL_LIBS"`
1763 else
1764 TCL_LIBS=`eval echo "$TCL_LIB_SPEC $TCL_LIBS"`
1765 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001766 dnl Use $TCL_DEFS for -D_THREAD_SAFE et al. But only use the
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001767 dnl "-D_ABC" items. Watch out for -DFOO=long\ long.
Bram Moolenaar4394bff2008-07-24 11:21:31 +00001768 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 +00001769 break
1770 fi
1771 done
1772 if test -z "$TCL_LIBS"; then
1773 AC_MSG_RESULT(<not found>)
1774 AC_MSG_CHECKING(for Tcl library by myself)
1775 tcllib=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001776 tcllib="$tcllib `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001777 for ext in .so .a ; do
1778 for ver in "" $tclver ; do
1779 for try in $tcllib ; do
1780 trylib=tcl$ver$ext
Bram Moolenaar49222be2015-12-11 18:11:30 +01001781 if test -f "$try/lib$trylib" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001782 AC_MSG_RESULT($try/lib$trylib)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001783 TCL_LIBS="-L\"$try\" -ltcl$ver -ldl -lm"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001784 if test "`(uname) 2>/dev/null`" = SunOS &&
1785 uname -r | grep '^5' >/dev/null; then
1786 TCL_LIBS="$TCL_LIBS -R $try"
1787 fi
1788 break 3
1789 fi
1790 done
1791 done
1792 done
1793 if test -z "$TCL_LIBS"; then
1794 AC_MSG_RESULT(<not found>)
1795 SKIP_TCL=YES
1796 fi
1797 fi
1798 if test -z "$SKIP_TCL"; then
1799 AC_DEFINE(FEAT_TCL)
1800 TCL_SRC=if_tcl.c
1801 TCL_OBJ=objects/if_tcl.o
1802 TCL_PRO=if_tcl.pro
1803 TCL_CFLAGS="-I$TCL_INC $TCL_DEFS"
1804 fi
1805 fi
1806 else
1807 AC_MSG_RESULT(too old; need Tcl version 8.0 or later)
1808 fi
1809 fi
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001810 if test "$enable_tclinterp" = "dynamic"; then
1811 if test "X$TCL_SRC" != "X" -a "X$tcldll" != "X"; then
1812 AC_DEFINE(DYNAMIC_TCL)
1813 TCL_CFLAGS="-DDYNAMIC_TCL_DLL=\\\"$tcldll\\\" -DDYNAMIC_TCL_VER=\\\"$tclver\\\" $TCL_CFLAGS"
1814 fi
1815 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001816 if test "$fail_if_missing" = "yes" -a -z "$TCL_SRC"; then
1817 AC_MSG_ERROR([could not configure Tcl])
1818 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001819fi
1820AC_SUBST(TCL_SRC)
1821AC_SUBST(TCL_OBJ)
1822AC_SUBST(TCL_PRO)
1823AC_SUBST(TCL_CFLAGS)
1824AC_SUBST(TCL_LIBS)
1825
1826AC_MSG_CHECKING(--enable-rubyinterp argument)
1827AC_ARG_ENABLE(rubyinterp,
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001828 [ --enable-rubyinterp[=OPTS] Include Ruby interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001829 [enable_rubyinterp="no"])
1830AC_MSG_RESULT($enable_rubyinterp)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001831if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001832 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1833 AC_MSG_ERROR([cannot use Ruby with tiny or small features])
1834 fi
1835
Bram Moolenaar165641d2010-02-17 16:23:09 +01001836 AC_MSG_CHECKING(--with-ruby-command argument)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001837 AC_SUBST(vi_cv_path_ruby)
Bram Moolenaar948733a2011-05-05 18:10:16 +02001838 AC_ARG_WITH(ruby-command, [ --with-ruby-command=RUBY name of the Ruby command (default: ruby)],
1839 RUBY_CMD="$withval"; vi_cv_path_ruby="$withval"; AC_MSG_RESULT($RUBY_CMD),
1840 RUBY_CMD="ruby"; AC_MSG_RESULT(defaulting to $RUBY_CMD))
Bram Moolenaar165641d2010-02-17 16:23:09 +01001841 AC_PATH_PROG(vi_cv_path_ruby, $RUBY_CMD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001842 if test "X$vi_cv_path_ruby" != "X"; then
1843 AC_MSG_CHECKING(Ruby version)
Bram Moolenaare4efc3b2005-03-07 23:16:51 +00001844 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 +00001845 AC_MSG_RESULT(OK)
Bram Moolenaar81398892012-10-03 21:09:35 +02001846 AC_MSG_CHECKING(Ruby rbconfig)
1847 ruby_rbconfig="RbConfig"
1848 if ! $vi_cv_path_ruby -r rbconfig -e 'RbConfig' >/dev/null 2>/dev/null; then
1849 ruby_rbconfig="Config"
1850 fi
1851 AC_MSG_RESULT($ruby_rbconfig)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001852 AC_MSG_CHECKING(Ruby header files)
Bram Moolenaar81398892012-10-03 21:09:35 +02001853 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 +00001854 if test "X$rubyhdrdir" != "X"; then
1855 AC_MSG_RESULT($rubyhdrdir)
1856 RUBY_CFLAGS="-I$rubyhdrdir"
Bram Moolenaara6fd37b2014-03-27 17:19:09 +01001857 rubyarchdir=`$vi_cv_path_ruby -r rbconfig -e "print ($ruby_rbconfig::CONFIG.has_key? 'rubyarchhdrdir') ? $ruby_rbconfig::CONFIG[['rubyarchhdrdir']] : '$rubyhdrdir/'+$ruby_rbconfig::CONFIG[['arch']]"`
1858 if test -d "$rubyarchdir"; then
1859 RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyarchdir"
Bram Moolenaar165641d2010-02-17 16:23:09 +01001860 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001861 rubyversion=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['ruby_version']].gsub(/\./, '')[[0,2]]"`
Bram Moolenaar026a4452013-08-07 15:22:23 +02001862 if test "X$rubyversion" = "X"; then
1863 rubyversion=`$vi_cv_path_ruby -e "print ((VERSION rescue RUBY_VERSION)).gsub(/\./, '')[[0,2]]"`
1864 fi
Bram Moolenaar165641d2010-02-17 16:23:09 +01001865 RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
Bram Moolenaar81398892012-10-03 21:09:35 +02001866 rubylibs=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LIBS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001867 if test "X$rubylibs" != "X"; then
1868 RUBY_LIBS="$rubylibs"
1869 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001870 librubyarg=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBYARG']])"`
1871 librubya=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBY_A']])"`
Bram Moolenaarac499e32013-06-02 19:14:17 +02001872 rubylibdir=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['libdir']])"`
Bram Moolenaar948733a2011-05-05 18:10:16 +02001873 if test -f "$rubylibdir/$librubya"; then
1874 librubyarg="$librubyarg"
Bram Moolenaarac499e32013-06-02 19:14:17 +02001875 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
1876 elif test "$librubyarg" = "libruby.a"; then
1877 dnl required on Mac OS 10.3 where libruby.a doesn't exist
1878 librubyarg="-lruby"
1879 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001880 fi
1881
1882 if test "X$librubyarg" != "X"; then
1883 RUBY_LIBS="$librubyarg $RUBY_LIBS"
1884 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001885 rubyldflags=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LDFLAGS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001886 if test "X$rubyldflags" != "X"; then
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001887 dnl Ruby on Mac OS X 10.5 adds "-arch" flags but these should only
1888 dnl be included if requested by passing --with-mac-arch to
1889 dnl configure, so strip these flags first (if present)
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001890 rubyldflags=`echo "$rubyldflags" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001891 if test "X$rubyldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001892 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$rubyldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001893 LDFLAGS="$rubyldflags $LDFLAGS"
1894 fi
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001895 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001896 fi
1897 RUBY_SRC="if_ruby.c"
1898 RUBY_OBJ="objects/if_ruby.o"
1899 RUBY_PRO="if_ruby.pro"
1900 AC_DEFINE(FEAT_RUBY)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001901 if test "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar81398892012-10-03 21:09:35 +02001902 libruby=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_SO']]"`
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001903 AC_DEFINE(DYNAMIC_RUBY)
1904 RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby\\\" -DDYNAMIC_RUBY_VER=$rubyversion $RUBY_CFLAGS"
1905 RUBY_LIBS=
1906 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001907 else
Bram Moolenaar165641d2010-02-17 16:23:09 +01001908 AC_MSG_RESULT(not found; disabling Ruby)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001909 fi
1910 else
1911 AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
1912 fi
1913 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001914
1915 if test "$fail_if_missing" = "yes" -a -z "$RUBY_OBJ"; then
1916 AC_MSG_ERROR([could not configure Ruby])
1917 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001918fi
1919AC_SUBST(RUBY_SRC)
1920AC_SUBST(RUBY_OBJ)
1921AC_SUBST(RUBY_PRO)
1922AC_SUBST(RUBY_CFLAGS)
1923AC_SUBST(RUBY_LIBS)
1924
1925AC_MSG_CHECKING(--enable-cscope argument)
1926AC_ARG_ENABLE(cscope,
1927 [ --enable-cscope Include cscope interface.], ,
1928 [enable_cscope="no"])
1929AC_MSG_RESULT($enable_cscope)
1930if test "$enable_cscope" = "yes"; then
1931 AC_DEFINE(FEAT_CSCOPE)
1932fi
1933
1934AC_MSG_CHECKING(--enable-workshop argument)
1935AC_ARG_ENABLE(workshop,
1936 [ --enable-workshop Include Sun Visual Workshop support.], ,
1937 [enable_workshop="no"])
1938AC_MSG_RESULT($enable_workshop)
1939if test "$enable_workshop" = "yes"; then
1940 AC_DEFINE(FEAT_SUN_WORKSHOP)
1941 WORKSHOP_SRC="workshop.c integration.c"
1942 AC_SUBST(WORKSHOP_SRC)
1943 WORKSHOP_OBJ="objects/workshop.o objects/integration.o"
1944 AC_SUBST(WORKSHOP_OBJ)
1945 if test "${enable_gui-xxx}" = xxx; then
1946 enable_gui=motif
1947 fi
1948fi
1949
1950AC_MSG_CHECKING(--disable-netbeans argument)
1951AC_ARG_ENABLE(netbeans,
1952 [ --disable-netbeans Disable NetBeans integration support.],
1953 , [enable_netbeans="yes"])
1954if test "$enable_netbeans" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01001955 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1956 AC_MSG_RESULT([cannot use NetBeans with tiny or small features])
1957 enable_netbeans="no"
1958 else
1959 AC_MSG_RESULT(no)
1960 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01001961else
1962 AC_MSG_RESULT(yes)
1963fi
1964
1965AC_MSG_CHECKING(--disable-channel argument)
1966AC_ARG_ENABLE(channel,
1967 [ --disable-channel Disable process communication support.],
1968 , [enable_channel="yes"])
1969if test "$enable_channel" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01001970 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1971 AC_MSG_RESULT([cannot use channels with tiny or small features])
1972 enable_channel="no"
1973 else
1974 AC_MSG_RESULT(no)
1975 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01001976else
1977 if test "$enable_netbeans" = "yes"; then
Bram Moolenaar16435482016-01-24 21:31:54 +01001978 AC_MSG_RESULT([yes, netbeans also disabled])
Bram Moolenaare0874f82016-01-24 20:36:41 +01001979 enable_netbeans="no"
1980 else
1981 AC_MSG_RESULT(yes)
1982 fi
1983fi
1984
Bram Moolenaar16435482016-01-24 21:31:54 +01001985if test "$enable_channel" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001986 dnl On Solaris we need the socket and nsl library.
1987 AC_CHECK_LIB(socket, socket)
1988 AC_CHECK_LIB(nsl, gethostbyname)
Bram Moolenaare0874f82016-01-24 20:36:41 +01001989 AC_MSG_CHECKING(whether compiling with process communication is possible)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001990 AC_TRY_LINK([
1991#include <stdio.h>
1992#include <stdlib.h>
1993#include <stdarg.h>
1994#include <fcntl.h>
1995#include <netdb.h>
1996#include <netinet/in.h>
1997#include <errno.h>
1998#include <sys/types.h>
1999#include <sys/socket.h>
2000 /* Check bitfields */
2001 struct nbbuf {
2002 unsigned int initDone:1;
Bram Moolenaar63de19e2016-12-09 20:11:26 +01002003 unsigned short signmaplen;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002004 };
2005 ], [
2006 /* Check creating a socket. */
2007 struct sockaddr_in server;
2008 (void)socket(AF_INET, SOCK_STREAM, 0);
2009 (void)htons(100);
2010 (void)gethostbyname("microsoft.com");
2011 if (errno == ECONNREFUSED)
2012 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
2013 ],
2014 AC_MSG_RESULT(yes),
Bram Moolenaare0874f82016-01-24 20:36:41 +01002015 AC_MSG_RESULT(no); enable_netbeans="no"; enable_channel="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00002016fi
2017if test "$enable_netbeans" = "yes"; then
2018 AC_DEFINE(FEAT_NETBEANS_INTG)
2019 NETBEANS_SRC="netbeans.c"
2020 AC_SUBST(NETBEANS_SRC)
2021 NETBEANS_OBJ="objects/netbeans.o"
2022 AC_SUBST(NETBEANS_OBJ)
2023fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002024if test "$enable_channel" = "yes"; then
Bram Moolenaar509ce2a2016-03-11 22:52:15 +01002025 AC_DEFINE(FEAT_JOB_CHANNEL)
Bram Moolenaare0874f82016-01-24 20:36:41 +01002026 CHANNEL_SRC="channel.c"
2027 AC_SUBST(CHANNEL_SRC)
2028 CHANNEL_OBJ="objects/channel.o"
2029 AC_SUBST(CHANNEL_OBJ)
2030fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002031
Bram Moolenaar071d4272004-06-13 20:20:40 +00002032AC_MSG_CHECKING(--enable-multibyte argument)
2033AC_ARG_ENABLE(multibyte,
2034 [ --enable-multibyte Include multibyte editing support.], ,
2035 [enable_multibyte="no"])
2036AC_MSG_RESULT($enable_multibyte)
2037if test "$enable_multibyte" = "yes"; then
2038 AC_DEFINE(FEAT_MBYTE)
2039fi
2040
2041AC_MSG_CHECKING(--enable-hangulinput argument)
2042AC_ARG_ENABLE(hangulinput,
2043 [ --enable-hangulinput Include Hangul input support.], ,
2044 [enable_hangulinput="no"])
2045AC_MSG_RESULT($enable_hangulinput)
2046
2047AC_MSG_CHECKING(--enable-xim argument)
2048AC_ARG_ENABLE(xim,
2049 [ --enable-xim Include XIM input support.],
2050 AC_MSG_RESULT($enable_xim),
2051 [enable_xim="auto"; AC_MSG_RESULT(defaulting to auto)])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002052
2053AC_MSG_CHECKING(--enable-fontset argument)
2054AC_ARG_ENABLE(fontset,
2055 [ --enable-fontset Include X fontset output support.], ,
2056 [enable_fontset="no"])
2057AC_MSG_RESULT($enable_fontset)
2058dnl defining FEAT_XFONTSET is delayed, so that it can be disabled for no GUI
2059
2060test -z "$with_x" && with_x=yes
2061test "${enable_gui-yes}" != no -a "x$MACOSX" != "xyes" -a "x$QNX" != "xyes" && with_x=yes
2062if test "$with_x" = no; then
2063 AC_MSG_RESULT(defaulting to: don't HAVE_X11)
2064else
2065 dnl Do this check early, so that its failure can override user requests.
2066
2067 AC_PATH_PROG(xmkmfpath, xmkmf)
2068
2069 AC_PATH_XTRA
2070
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002071 dnl On z/OS Unix the X libraries are DLLs. To use them the code must
Bram Moolenaar071d4272004-06-13 20:20:40 +00002072 dnl be compiled with a special option.
2073 dnl Also add SM, ICE and Xmu to X_EXTRA_LIBS.
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002074 if test "$zOSUnix" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002075 CFLAGS="$CFLAGS -W c,dll"
2076 LDFLAGS="$LDFLAGS -W l,dll"
2077 X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE -lXmu"
2078 fi
2079
2080 dnl On my HPUX system the X include dir is found, but the lib dir not.
2081 dnl This is a desparate try to fix this.
2082
2083 if test -d "$x_includes" && test ! -d "$x_libraries"; then
2084 x_libraries=`echo "$x_includes" | sed s/include/lib/`
2085 AC_MSG_RESULT(Corrected X libraries to $x_libraries)
2086 X_LIBS="$X_LIBS -L$x_libraries"
2087 if test "`(uname) 2>/dev/null`" = SunOS &&
2088 uname -r | grep '^5' >/dev/null; then
2089 X_LIBS="$X_LIBS -R $x_libraries"
2090 fi
2091 fi
2092
2093 if test -d "$x_libraries" && test ! -d "$x_includes"; then
2094 x_includes=`echo "$x_libraries" | sed s/lib/include/`
2095 AC_MSG_RESULT(Corrected X includes to $x_includes)
2096 X_CFLAGS="$X_CFLAGS -I$x_includes"
2097 fi
2098
2099 dnl Remove "-I/usr/include " from X_CFLAGS, should not be needed.
2100 X_CFLAGS="`echo $X_CFLAGS\ | sed 's%-I/usr/include %%'`"
2101 dnl Remove "-L/usr/lib " from X_LIBS, should not be needed.
2102 X_LIBS="`echo $X_LIBS\ | sed 's%-L/usr/lib %%'`"
2103 dnl Same for "-R/usr/lib ".
2104 X_LIBS="`echo $X_LIBS\ | sed -e 's%-R/usr/lib %%' -e 's%-R /usr/lib %%'`"
2105
2106
2107 dnl Check if the X11 header files are correctly installed. On some systems
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002108 dnl Xlib.h includes files that don't exist. On some systems X11/Intrinsic.h
2109 dnl is missing.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002110 AC_MSG_CHECKING(if X11 header files can be found)
2111 cflags_save=$CFLAGS
2112 CFLAGS="$CFLAGS $X_CFLAGS"
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002113 AC_TRY_COMPILE([#include <X11/Xlib.h>
2114#include <X11/Intrinsic.h>], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002115 AC_MSG_RESULT(yes),
2116 AC_MSG_RESULT(no); no_x=yes)
2117 CFLAGS=$cflags_save
2118
2119 if test "${no_x-no}" = yes; then
2120 with_x=no
2121 else
2122 AC_DEFINE(HAVE_X11)
2123 X_LIB="-lXt -lX11";
2124 AC_SUBST(X_LIB)
2125
2126 ac_save_LDFLAGS="$LDFLAGS"
2127 LDFLAGS="-L$x_libraries $LDFLAGS"
2128
2129 dnl Check for -lXdmcp (needed on SunOS 4.1.4)
2130 dnl For HP-UX 10.20 it must be before -lSM -lICE
2131 AC_CHECK_LIB(Xdmcp, _XdmcpAuthDoIt, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lXdmcp"],,
2132 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXdmcp])
2133
2134 dnl Some systems need -lnsl -lsocket when testing for ICE.
2135 dnl The check above doesn't do this, try here (again). Also needed to get
2136 dnl them after Xdmcp. link.sh will remove them when not needed.
2137 dnl Check for other function than above to avoid the cached value
2138 AC_CHECK_LIB(ICE, IceOpenConnection,
2139 [X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE"],, [$X_EXTRA_LIBS])
2140
2141 dnl Check for -lXpm (needed for some versions of Motif)
2142 LDFLAGS="$X_LIBS $ac_save_LDFLAGS"
2143 AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [X_PRE_LIBS="$X_PRE_LIBS -lXpm"],,
2144 [-lXt $X_PRE_LIBS -lXpm -lX11 $X_EXTRA_LIBS])
2145
2146 dnl Check that the X11 header files don't use implicit declarations
2147 AC_MSG_CHECKING(if X11 header files implicitly declare return values)
2148 cflags_save=$CFLAGS
Bram Moolenaard1864592013-05-04 04:40:15 +02002149 dnl -Werror is GCC only, others like Solaris Studio might not like it
2150 if test "$GCC" = yes; then
2151 CFLAGS="$CFLAGS $X_CFLAGS -Werror"
2152 else
2153 CFLAGS="$CFLAGS $X_CFLAGS"
2154 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002155 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2156 AC_MSG_RESULT(no),
2157 CFLAGS="$CFLAGS -Wno-implicit-int"
2158 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2159 AC_MSG_RESULT(yes); cflags_save="$cflags_save -Wno-implicit-int",
2160 AC_MSG_RESULT(test failed)
2161 )
2162 )
2163 CFLAGS=$cflags_save
2164
2165 LDFLAGS="$ac_save_LDFLAGS"
2166
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002167 AC_MSG_CHECKING(size of wchar_t is 2 bytes)
2168 AC_CACHE_VAL(ac_cv_small_wchar_t,
2169 [AC_TRY_RUN([
2170#include <X11/Xlib.h>
2171#if STDC_HEADERS
2172# include <stdlib.h>
2173# include <stddef.h>
2174#endif
2175 main()
2176 {
2177 if (sizeof(wchar_t) <= 2)
2178 exit(1);
2179 exit(0);
2180 }],
2181 ac_cv_small_wchar_t="no",
2182 ac_cv_small_wchar_t="yes",
2183 AC_MSG_ERROR(failed to compile test program))])
2184 AC_MSG_RESULT($ac_cv_small_wchar_t)
2185 if test "x$ac_cv_small_wchar_t" = "xyes" ; then
2186 AC_DEFINE(SMALL_WCHAR_T)
2187 fi
2188
Bram Moolenaar071d4272004-06-13 20:20:40 +00002189 fi
2190fi
2191
Bram Moolenaara7fc0102005-05-18 22:17:12 +00002192test "x$with_x" = xno -a "x$MACOSX" != "xyes" -a "x$QNX" != "xyes" && enable_gui=no
Bram Moolenaar071d4272004-06-13 20:20:40 +00002193
2194AC_MSG_CHECKING(--enable-gui argument)
2195AC_ARG_ENABLE(gui,
Bram Moolenaar98921892016-02-23 17:14:37 +01002196 [ --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 +00002197
2198dnl Canonicalize the --enable-gui= argument so that it can be easily compared.
2199dnl Do not use character classes for portability with old tools.
2200enable_gui_canon=`echo "_$enable_gui" | \
2201 sed 's/[[ _+-]]//g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
2202
2203dnl Skip everything by default.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002204SKIP_GTK2=YES
Bram Moolenaar1858a842016-02-23 22:30:31 +01002205SKIP_GTK3=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002206SKIP_GNOME=YES
2207SKIP_MOTIF=YES
2208SKIP_ATHENA=YES
2209SKIP_NEXTAW=YES
2210SKIP_PHOTON=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002211SKIP_CARBON=YES
2212GUITYPE=NONE
2213
Bram Moolenaarb11160e2005-01-04 21:31:43 +00002214if test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002215 SKIP_PHOTON=
2216 case "$enable_gui_canon" in
2217 no) AC_MSG_RESULT(no GUI support)
2218 SKIP_PHOTON=YES ;;
2219 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
2220 auto) AC_MSG_RESULT(auto - automatic GUI support) ;;
2221 photon) AC_MSG_RESULT(Photon GUI support) ;;
2222 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2223 SKIP_PHOTON=YES ;;
2224 esac
2225
2226elif test "x$MACOSX" = "xyes" -a "x$with_x" = "xno" ; then
2227 SKIP_CARBON=
2228 case "$enable_gui_canon" in
2229 no) AC_MSG_RESULT(no GUI support)
2230 SKIP_CARBON=YES ;;
2231 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
Bram Moolenaar164fca32010-07-14 13:58:07 +02002232 auto) AC_MSG_RESULT(auto - Carbon GUI is outdated - disable GUI support)
2233 SKIP_CARBON=YES ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002234 carbon) AC_MSG_RESULT(Carbon GUI support) ;;
2235 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2236 SKIP_CARBON=YES ;;
2237 esac
2238
2239else
2240
Bram Moolenaar071d4272004-06-13 20:20:40 +00002241 case "$enable_gui_canon" in
2242 no|none) AC_MSG_RESULT(no GUI support) ;;
2243 yes|""|auto) AC_MSG_RESULT(yes/auto - automatic GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002244 SKIP_GTK2=
2245 SKIP_GNOME=
2246 SKIP_MOTIF=
2247 SKIP_ATHENA=
2248 SKIP_NEXTAW=
2249 SKIP_CARBON=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002250 gtk2) AC_MSG_RESULT(GTK+ 2.x GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002251 SKIP_GTK2=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002252 gnome2) AC_MSG_RESULT(GNOME 2.x GUI support)
2253 SKIP_GNOME=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002254 SKIP_GTK2=;;
Bram Moolenaar98921892016-02-23 17:14:37 +01002255 gtk3) AC_MSG_RESULT(GTK+ 3.x GUI support)
2256 SKIP_GTK3=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002257 motif) AC_MSG_RESULT(Motif GUI support)
2258 SKIP_MOTIF=;;
2259 athena) AC_MSG_RESULT(Athena GUI support)
2260 SKIP_ATHENA=;;
2261 nextaw) AC_MSG_RESULT(neXtaw GUI support)
2262 SKIP_NEXTAW=;;
2263 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
2264 esac
2265
2266fi
2267
Bram Moolenaar071d4272004-06-13 20:20:40 +00002268if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \
2269 -a "$enable_gui_canon" != "gnome2"; then
2270 AC_MSG_CHECKING(whether or not to look for GTK+ 2)
2271 AC_ARG_ENABLE(gtk2-check,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002272 [ --enable-gtk2-check If auto-select GUI, check for GTK+ 2 [default=yes]],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002273 , enable_gtk2_check="yes")
2274 AC_MSG_RESULT($enable_gtk2_check)
2275 if test "x$enable_gtk2_check" = "xno"; then
2276 SKIP_GTK2=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002277 SKIP_GNOME=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002278 fi
2279fi
2280
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002281if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002282 AC_MSG_CHECKING(whether or not to look for GNOME)
2283 AC_ARG_ENABLE(gnome-check,
2284 [ --enable-gnome-check If GTK GUI, check for GNOME [default=no]],
2285 , enable_gnome_check="no")
2286 AC_MSG_RESULT($enable_gnome_check)
2287 if test "x$enable_gnome_check" = "xno"; then
2288 SKIP_GNOME=YES
2289 fi
2290fi
2291
Bram Moolenaar98921892016-02-23 17:14:37 +01002292if test "x$SKIP_GTK3" != "xYES" -a "$enable_gui_canon" != "gtk3"; then
2293 AC_MSG_CHECKING(whether or not to look for GTK+ 3)
2294 AC_ARG_ENABLE(gtk3-check,
2295 [ --enable-gtk3-check If auto-select GUI, check for GTK+ 3 [default=yes]],
2296 , enable_gtk3_check="yes")
2297 AC_MSG_RESULT($enable_gtk3_check)
2298 if test "x$enable_gtk3_check" = "xno"; then
2299 SKIP_GTK3=YES
2300 fi
2301fi
2302
Bram Moolenaar071d4272004-06-13 20:20:40 +00002303if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then
2304 AC_MSG_CHECKING(whether or not to look for Motif)
2305 AC_ARG_ENABLE(motif-check,
2306 [ --enable-motif-check If auto-select GUI, check for Motif [default=yes]],
2307 , enable_motif_check="yes")
2308 AC_MSG_RESULT($enable_motif_check)
2309 if test "x$enable_motif_check" = "xno"; then
2310 SKIP_MOTIF=YES
2311 fi
2312fi
2313
2314if test "x$SKIP_ATHENA" != "xYES" -a "$enable_gui_canon" != "athena"; then
2315 AC_MSG_CHECKING(whether or not to look for Athena)
2316 AC_ARG_ENABLE(athena-check,
2317 [ --enable-athena-check If auto-select GUI, check for Athena [default=yes]],
2318 , enable_athena_check="yes")
2319 AC_MSG_RESULT($enable_athena_check)
2320 if test "x$enable_athena_check" = "xno"; then
2321 SKIP_ATHENA=YES
2322 fi
2323fi
2324
2325if test "x$SKIP_NEXTAW" != "xYES" -a "$enable_gui_canon" != "nextaw"; then
2326 AC_MSG_CHECKING(whether or not to look for neXtaw)
2327 AC_ARG_ENABLE(nextaw-check,
2328 [ --enable-nextaw-check If auto-select GUI, check for neXtaw [default=yes]],
2329 , enable_nextaw_check="yes")
2330 AC_MSG_RESULT($enable_nextaw_check);
2331 if test "x$enable_nextaw_check" = "xno"; then
2332 SKIP_NEXTAW=YES
2333 fi
2334fi
2335
2336if test "x$SKIP_CARBON" != "xYES" -a "$enable_gui_canon" != "carbon"; then
2337 AC_MSG_CHECKING(whether or not to look for Carbon)
2338 AC_ARG_ENABLE(carbon-check,
2339 [ --enable-carbon-check If auto-select GUI, check for Carbon [default=yes]],
2340 , enable_carbon_check="yes")
2341 AC_MSG_RESULT($enable_carbon_check);
2342 if test "x$enable_carbon_check" = "xno"; then
2343 SKIP_CARBON=YES
2344 fi
2345fi
2346
Bram Moolenaar843ee412004-06-30 16:16:41 +00002347
Bram Moolenaar071d4272004-06-13 20:20:40 +00002348if test "x$MACOSX" = "xyes" -a -z "$SKIP_CARBON" -a "x$CARBON" = "xyes"; then
2349 AC_MSG_CHECKING(for Carbon GUI)
Bram Moolenaar14716812006-05-04 21:54:08 +00002350 dnl already did the check, just give the message
Bram Moolenaar071d4272004-06-13 20:20:40 +00002351 AC_MSG_RESULT(yes);
2352 GUITYPE=CARBONGUI
Bram Moolenaare344bea2005-09-01 20:46:49 +00002353 if test "$VIMNAME" = "vim"; then
2354 VIMNAME=Vim
2355 fi
Bram Moolenaar14716812006-05-04 21:54:08 +00002356
Bram Moolenaar164fca32010-07-14 13:58:07 +02002357 if test "x$MACARCH" = "xboth"; then
2358 CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk/Developer/Headers/FlatCarbon"
2359 else
2360 CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/Headers/FlatCarbon"
2361 fi
2362
Bram Moolenaar14716812006-05-04 21:54:08 +00002363 dnl Default install directory is not /usr/local
2364 if test x$prefix = xNONE; then
2365 prefix=/Applications
2366 fi
2367
2368 dnl Sorry for the hard coded default
2369 datadir='${prefix}/Vim.app/Contents/Resources'
2370
Bram Moolenaar071d4272004-06-13 20:20:40 +00002371 dnl skip everything else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002372 SKIP_GTK2=YES;
2373 SKIP_GNOME=YES;
2374 SKIP_MOTIF=YES;
2375 SKIP_ATHENA=YES;
2376 SKIP_NEXTAW=YES;
2377 SKIP_PHOTON=YES;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002378 SKIP_CARBON=YES
2379fi
2380
Bram Moolenaar071d4272004-06-13 20:20:40 +00002381dnl define an autoconf function to check for a specified version of GTK, and
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002382dnl try to compile/link a GTK program.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002383dnl
2384dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002385dnl Test for GTK, and define GTK_CFLAGS, GTK_LIBDIR and GTK_LIBS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002386dnl
2387AC_DEFUN(AM_PATH_GTK,
2388[
2389 if test "X$GTK_CONFIG" != "Xno" -o "X$PKG_CONFIG" != "Xno"; then
2390 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00002391 no_gtk=""
2392 if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2393 && $PKG_CONFIG --exists gtk+-2.0; then
2394 {
Bram Moolenaar98921892016-02-23 17:14:37 +01002395 min_gtk_version=ifelse([$1], ,2.2.0,$1)
2396 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002397 dnl We should be using PKG_CHECK_MODULES() instead of this hack.
2398 dnl But I guess the dependency on pkgconfig.m4 is not wanted or
2399 dnl something like that.
2400 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0`
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002401 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-2.0`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002402 GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0`
2403 gtk_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2404 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2405 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2406 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2407 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2408 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2409 }
Bram Moolenaar98921892016-02-23 17:14:37 +01002410 elif (test "X$SKIP_GTK3" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2411 && $PKG_CONFIG --exists gtk+-3.0; then
2412 {
2413 min_gtk_version=ifelse([$1], ,3.0.0,$1)
2414 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
2415
2416 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-3.0`
2417 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-3.0`
2418 GTK_LIBS=`$PKG_CONFIG --libs gtk+-3.0`
2419 gtk_major_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2420 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2421 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2422 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2423 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2424 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2425 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002426 else
2427 no_gtk=yes
2428 fi
2429
2430 if test "x$enable_gtktest" = "xyes" -a "x$no_gtk" = "x"; then
2431 {
2432 ac_save_CFLAGS="$CFLAGS"
2433 ac_save_LIBS="$LIBS"
2434 CFLAGS="$CFLAGS $GTK_CFLAGS"
2435 LIBS="$LIBS $GTK_LIBS"
2436
2437 dnl
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002438 dnl Now check if the installed GTK is sufficiently new.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002439 dnl
2440 rm -f conf.gtktest
2441 AC_TRY_RUN([
2442#include <gtk/gtk.h>
2443#include <stdio.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00002444#if STDC_HEADERS
2445# include <stdlib.h>
2446# include <stddef.h>
2447#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002448
2449int
2450main ()
2451{
2452int major, minor, micro;
2453char *tmp_version;
2454
2455system ("touch conf.gtktest");
2456
2457/* HP/UX 9 (%@#!) writes to sscanf strings */
2458tmp_version = g_strdup("$min_gtk_version");
2459if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
2460 printf("%s, bad version string\n", "$min_gtk_version");
2461 exit(1);
2462 }
2463
2464if ((gtk_major_version > major) ||
2465 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
2466 ((gtk_major_version == major) && (gtk_minor_version == minor) &&
2467 (gtk_micro_version >= micro)))
2468{
2469 return 0;
2470}
2471return 1;
2472}
2473],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
2474 CFLAGS="$ac_save_CFLAGS"
2475 LIBS="$ac_save_LIBS"
2476 }
2477 fi
2478 if test "x$no_gtk" = x ; then
2479 if test "x$enable_gtktest" = "xyes"; then
2480 AC_MSG_RESULT(yes; found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2481 else
2482 AC_MSG_RESULT(found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2483 fi
2484 ifelse([$2], , :, [$2])
2485 else
2486 {
2487 AC_MSG_RESULT(no)
2488 GTK_CFLAGS=""
2489 GTK_LIBS=""
2490 ifelse([$3], , :, [$3])
2491 }
2492 fi
2493 }
2494 else
2495 GTK_CFLAGS=""
2496 GTK_LIBS=""
2497 ifelse([$3], , :, [$3])
2498 fi
2499 AC_SUBST(GTK_CFLAGS)
2500 AC_SUBST(GTK_LIBS)
2501 rm -f conf.gtktest
2502])
2503
2504dnl ---------------------------------------------------------------------------
2505dnl gnome
2506dnl ---------------------------------------------------------------------------
2507AC_DEFUN([GNOME_INIT_HOOK],
2508[
2509 AC_SUBST(GNOME_LIBS)
2510 AC_SUBST(GNOME_LIBDIR)
2511 AC_SUBST(GNOME_INCLUDEDIR)
2512
2513 AC_ARG_WITH(gnome-includes,
2514 [ --with-gnome-includes=DIR Specify location of GNOME headers],
2515 [CFLAGS="$CFLAGS -I$withval"]
2516 )
2517
2518 AC_ARG_WITH(gnome-libs,
2519 [ --with-gnome-libs=DIR Specify location of GNOME libs],
2520 [LDFLAGS="$LDFLAGS -L$withval" gnome_prefix=$withval]
2521 )
2522
2523 AC_ARG_WITH(gnome,
2524 [ --with-gnome Specify prefix for GNOME files],
2525 if test x$withval = xyes; then
2526 want_gnome=yes
2527 ifelse([$1], [], :, [$1])
2528 else
2529 if test "x$withval" = xno; then
2530 want_gnome=no
2531 else
2532 want_gnome=yes
2533 LDFLAGS="$LDFLAGS -L$withval/lib"
2534 CFLAGS="$CFLAGS -I$withval/include"
2535 gnome_prefix=$withval/lib
2536 fi
2537 fi,
2538 want_gnome=yes)
2539
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002540 if test "x$want_gnome" = xyes; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002541 {
2542 AC_MSG_CHECKING(for libgnomeui-2.0)
2543 if $PKG_CONFIG --exists libgnomeui-2.0; then
2544 AC_MSG_RESULT(yes)
2545 GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0`
2546 GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0`
2547 GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0`
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002548
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002549 dnl On FreeBSD we need -pthread but pkg-config doesn't include it.
2550 dnl This might not be the right way but it works for me...
2551 AC_MSG_CHECKING(for FreeBSD)
2552 if test "`(uname) 2>/dev/null`" = FreeBSD; then
2553 AC_MSG_RESULT(yes, adding -pthread)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002554 GNOME_INCLUDEDIR="$GNOME_INCLUDEDIR -D_THREAD_SAFE"
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002555 GNOME_LIBS="$GNOME_LIBS -pthread"
2556 else
2557 AC_MSG_RESULT(no)
2558 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002559 $1
2560 else
2561 AC_MSG_RESULT(not found)
2562 if test "x$2" = xfail; then
2563 AC_MSG_ERROR(Could not find libgnomeui-2.0 via pkg-config)
2564 fi
2565 fi
2566 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002567 fi
2568])
2569
2570AC_DEFUN([GNOME_INIT],[
2571 GNOME_INIT_HOOK([],fail)
2572])
2573
2574
2575dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002576dnl Check for GTK2. If it fails, then continue on for Motif as before...
Bram Moolenaar071d4272004-06-13 20:20:40 +00002577dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002578if test -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002579
2580 AC_MSG_CHECKING(--disable-gtktest argument)
2581 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2582 , enable_gtktest=yes)
2583 if test "x$enable_gtktest" = "xyes" ; then
2584 AC_MSG_RESULT(gtk test enabled)
2585 else
2586 AC_MSG_RESULT(gtk test disabled)
2587 fi
2588
Bram Moolenaar071d4272004-06-13 20:20:40 +00002589 if test "X$PKG_CONFIG" = "X"; then
2590 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
2591 fi
2592
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002593 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002594 dnl First try finding version 2.2.0 or later. The 2.0.x series has
2595 dnl problems (bold fonts, --remote doesn't work).
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002596 AM_PATH_GTK(2.2.0,
2597 [GUI_LIB_LOC="$GTK_LIBDIR"
2598 GTK_LIBNAME="$GTK_LIBS"
2599 GUI_INC_LOC="$GTK_CFLAGS"], )
2600 if test "x$GTK_CFLAGS" != "x"; then
Bram Moolenaar98921892016-02-23 17:14:37 +01002601 SKIP_GTK3=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002602 SKIP_ATHENA=YES
2603 SKIP_NEXTAW=YES
2604 SKIP_MOTIF=YES
2605 GUITYPE=GTK
2606 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002607 fi
2608 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002609 if test "x$GUITYPE" = "xGTK"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002610 if test "$gtk_minor_version" = 1 -a "0$gtk_micro_version" -ge 1 \
2611 || test "0$gtk_minor_version" -ge 2; then
2612 AC_DEFINE(HAVE_GTK_MULTIHEAD)
2613 fi
2614 dnl
2615 dnl if GTK exists, then check for GNOME.
2616 dnl
2617 if test -z "$SKIP_GNOME"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002618 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002619 GNOME_INIT_HOOK([have_gnome=yes])
2620 if test "x$have_gnome" = xyes ; then
2621 AC_DEFINE(FEAT_GUI_GNOME)
2622 GUI_INC_LOC="$GUI_INC_LOC $GNOME_INCLUDEDIR"
2623 GTK_LIBNAME="$GTK_LIBNAME $GNOME_LIBDIR $GNOME_LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002624 fi
2625 }
2626 fi
2627 fi
2628fi
2629
Bram Moolenaar98921892016-02-23 17:14:37 +01002630
2631dnl ---------------------------------------------------------------------------
2632dnl Check for GTK3.
2633dnl ---------------------------------------------------------------------------
2634if test -z "$SKIP_GTK3"; then
2635
2636 AC_MSG_CHECKING(--disable-gtktest argument)
2637 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2638 , enable_gtktest=yes)
2639 if test "x$enable_gtktest" = "xyes" ; then
2640 AC_MSG_RESULT(gtk test enabled)
2641 else
2642 AC_MSG_RESULT(gtk test disabled)
2643 fi
2644
2645 if test "X$PKG_CONFIG" = "X"; then
2646 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
2647 fi
2648
2649 if test "x$PKG_CONFIG" != "xno"; then
2650 AM_PATH_GTK(3.0.0,
2651 [GUI_LIB_LOC="$GTK_LIBDIR"
2652 GTK_LIBNAME="$GTK_LIBS"
2653 GUI_INC_LOC="$GTK_CFLAGS"], )
2654 if test "x$GTK_CFLAGS" != "x"; then
2655 SKIP_GTK2=YES
2656 SKIP_GNOME=YES
2657 SKIP_ATHENA=YES
2658 SKIP_NEXTAW=YES
2659 SKIP_MOTIF=YES
2660 GUITYPE=GTK
2661 AC_SUBST(GTK_LIBNAME)
2662 AC_DEFINE(HAVE_GTK_MULTIHEAD)
2663 AC_DEFINE(USE_GTK3)
2664 fi
2665 fi
2666fi
2667
Bram Moolenaard2e03f02016-01-02 22:46:36 +01002668dnl Check the version of Gdk-Pixbuf. If the version is 2.31 or later and
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002669dnl glib-compile-resources is found in PATH, use GResource.
2670if test "x$GUITYPE" = "xGTK"; then
2671 AC_MSG_CHECKING([version of Gdk-Pixbuf])
2672 gdk_pixbuf_version=`$PKG_CONFIG --modversion gdk-pixbuf-2.0`
2673 if test "x$gdk_pixbuf_version" != x ; then
2674 gdk_pixbuf_version_minor=`echo $gdk_pixbuf_version | \
2675 sed -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/'`
2676 if test "x$gdk_pixbuf_version_minor" != x -a \
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002677 $gdk_pixbuf_version_minor -ge 31 ; then
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002678 AC_MSG_RESULT([OK.])
2679 AC_PATH_PROG(GLIB_COMPILE_RESOURCES,[glib-compile-resources],no)
2680 AC_MSG_CHECKING([glib-compile-resources])
2681 if test "x$GLIB_COMPILE_RESOURCES" = xno ; then
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002682 GLIB_COMPILE_RESOURCES=""
2683 AC_MSG_RESULT([cannot be found in PATH.])
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002684 else
2685 AC_MSG_RESULT([usable.])
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002686 AC_DEFINE(USE_GRESOURCE)
2687 GRESOURCE_SRC="auto/gui_gtk_gresources.c"
2688 GRESOURCE_OBJ="objects/gui_gtk_gresources.o"
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002689 fi
2690 else
2691 AC_MSG_RESULT([not usable.])
2692 fi
2693 else
2694 AC_MSG_RESULT([cannot obtain from pkg_config.])
2695 fi
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002696
2697 AC_MSG_CHECKING([--disable-icon-cache-update argument])
2698 AC_ARG_ENABLE(icon_cache_update,
2699 [ --disable-icon-cache-update update disabled],
2700 [],
2701 [enable_icon_cache_update="yes"])
2702 if test "$enable_icon_cache_update" = "yes"; then
2703 AC_MSG_RESULT([not set])
2704 AC_PATH_PROG(GTK_UPDATE_ICON_CACHE,[gtk-update-icon-cache],no)
2705 if test "x$GTK_UPDATE_ICON_CACHE" = "xno" ; then
2706 AC_MSG_RESULT([not found in PATH.])
2707 fi
2708 else
2709 AC_MSG_RESULT([update disabled])
2710 fi
2711
2712 AC_MSG_CHECKING([--disable-desktop-database-update argument])
2713 AC_ARG_ENABLE(desktop_database_update,
2714 [ --disable-desktop-database-update update disabled],
2715 [],
2716 [enable_desktop_database_update="yes"])
2717 if test "$enable_desktop_database_update" = "yes"; then
2718 AC_MSG_RESULT([not set])
2719 AC_PATH_PROG(UPDATE_DESKTOP_DATABASE,[update-desktop-database],no)
2720 if test "x$UPDATE_DESKTOP_DATABASE" = "xno" ; then
2721 AC_MSG_RESULT([not found in PATH.])
2722 fi
2723 else
2724 AC_MSG_RESULT([update disabled])
2725 fi
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002726fi
2727AC_SUBST(GLIB_COMPILE_RESOURCES)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002728AC_SUBST(GRESOURCE_SRC)
2729AC_SUBST(GRESOURCE_OBJ)
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002730AC_SUBST(GTK_UPDATE_ICON_CACHE)
2731AC_SUBST(UPDATE_DESKTOP_DATABASE)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002732
Bram Moolenaar071d4272004-06-13 20:20:40 +00002733dnl Check for Motif include files location.
2734dnl The LAST one found is used, this makes the highest version to be used,
2735dnl e.g. when Motif1.2 and Motif2.0 are both present.
2736
2737if test -z "$SKIP_MOTIF"; then
2738 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"
2739 dnl Remove "-I" from before $GUI_INC_LOC if it's there
2740 GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`"
2741
2742 AC_MSG_CHECKING(for location of Motif GUI includes)
2743 gui_includes="`echo $x_includes|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC"
2744 GUI_INC_LOC=
2745 for try in $gui_includes; do
2746 if test -f "$try/Xm/Xm.h"; then
2747 GUI_INC_LOC=$try
2748 fi
2749 done
2750 if test -n "$GUI_INC_LOC"; then
2751 if test "$GUI_INC_LOC" = /usr/include; then
2752 GUI_INC_LOC=
2753 AC_MSG_RESULT(in default path)
2754 else
2755 AC_MSG_RESULT($GUI_INC_LOC)
2756 fi
2757 else
2758 AC_MSG_RESULT(<not found>)
2759 SKIP_MOTIF=YES
2760 fi
2761fi
2762
2763dnl Check for Motif library files location. In the same order as the include
2764dnl files, to avoid a mixup if several versions are present
2765
2766if test -z "$SKIP_MOTIF"; then
2767 AC_MSG_CHECKING(--with-motif-lib argument)
2768 AC_ARG_WITH(motif-lib,
2769 [ --with-motif-lib=STRING Library for Motif ],
2770 [ MOTIF_LIBNAME="${withval}" ] )
2771
2772 if test -n "$MOTIF_LIBNAME"; then
2773 AC_MSG_RESULT($MOTIF_LIBNAME)
2774 GUI_LIB_LOC=
2775 else
2776 AC_MSG_RESULT(no)
2777
2778 dnl Remove "-L" from before $GUI_LIB_LOC if it's there
2779 GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
2780
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002781 dnl Ubuntu has libXm.so in /usr/lib/i386-linux-gnu and elsewhere. The
2782 dnl linker will figure out which one to use, we only check if one exists.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002783 AC_MSG_CHECKING(for location of Motif GUI libs)
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002784 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 +00002785 GUI_LIB_LOC=
2786 for try in $gui_libs; do
Bram Moolenaar325b7a22004-07-05 15:58:32 +00002787 for libtry in "$try"/libXm.a "$try"/libXm.so* "$try"/libXm.sl "$try"/libXm.dylib; do
Bram Moolenaar071d4272004-06-13 20:20:40 +00002788 if test -f "$libtry"; then
2789 GUI_LIB_LOC=$try
2790 fi
2791 done
2792 done
2793 if test -n "$GUI_LIB_LOC"; then
2794 dnl Remove /usr/lib, it causes trouble on some systems
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002795 if test "$GUI_LIB_LOC" = /usr/lib \
2796 -o "$GUI_LIB_LOC" = /usr/lib/i386-linux-gnu \
2797 -o "$GUI_LIB_LOC" = /usr/lib/x86_64-linux-gnu; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002798 GUI_LIB_LOC=
2799 AC_MSG_RESULT(in default path)
2800 else
2801 if test -n "$GUI_LIB_LOC"; then
2802 AC_MSG_RESULT($GUI_LIB_LOC)
2803 if test "`(uname) 2>/dev/null`" = SunOS &&
2804 uname -r | grep '^5' >/dev/null; then
2805 GUI_LIB_LOC="$GUI_LIB_LOC -R $GUI_LIB_LOC"
2806 fi
2807 fi
2808 fi
2809 MOTIF_LIBNAME=-lXm
2810 else
2811 AC_MSG_RESULT(<not found>)
2812 SKIP_MOTIF=YES
2813 fi
2814 fi
2815fi
2816
2817if test -z "$SKIP_MOTIF"; then
2818 SKIP_ATHENA=YES
2819 SKIP_NEXTAW=YES
2820 GUITYPE=MOTIF
2821 AC_SUBST(MOTIF_LIBNAME)
2822fi
2823
2824dnl Check if the Athena files can be found
2825
2826GUI_X_LIBS=
2827
2828if test -z "$SKIP_ATHENA"; then
2829 AC_MSG_CHECKING(if Athena header files can be found)
2830 cflags_save=$CFLAGS
2831 CFLAGS="$CFLAGS $X_CFLAGS"
2832 AC_TRY_COMPILE([
2833#include <X11/Intrinsic.h>
2834#include <X11/Xaw/Paned.h>], ,
2835 AC_MSG_RESULT(yes),
2836 AC_MSG_RESULT(no); SKIP_ATHENA=YES )
2837 CFLAGS=$cflags_save
2838fi
2839
2840if test -z "$SKIP_ATHENA"; then
2841 GUITYPE=ATHENA
2842fi
2843
2844if test -z "$SKIP_NEXTAW"; then
2845 AC_MSG_CHECKING(if neXtaw header files can be found)
2846 cflags_save=$CFLAGS
2847 CFLAGS="$CFLAGS $X_CFLAGS"
2848 AC_TRY_COMPILE([
2849#include <X11/Intrinsic.h>
2850#include <X11/neXtaw/Paned.h>], ,
2851 AC_MSG_RESULT(yes),
2852 AC_MSG_RESULT(no); SKIP_NEXTAW=YES )
2853 CFLAGS=$cflags_save
2854fi
2855
2856if test -z "$SKIP_NEXTAW"; then
2857 GUITYPE=NEXTAW
2858fi
2859
2860if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
2861 dnl Prepend -I and -L to $GUI_INC_LOC and $GUI_LIB_LOC if not empty
2862 dnl Avoid adding it when it twice
2863 if test -n "$GUI_INC_LOC"; then
2864 GUI_INC_LOC=-I"`echo $GUI_INC_LOC|sed 's%-I%%'`"
2865 fi
2866 if test -n "$GUI_LIB_LOC"; then
2867 GUI_LIB_LOC=-L"`echo $GUI_LIB_LOC|sed 's%-L%%'`"
2868 fi
2869
2870 dnl Check for -lXext and then for -lXmu
2871 ldflags_save=$LDFLAGS
2872 LDFLAGS="$X_LIBS $LDFLAGS"
2873 AC_CHECK_LIB(Xext, XShapeQueryExtension, [GUI_X_LIBS="-lXext"],,
2874 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2875 dnl For Solaris we need -lw and -ldl before linking with -lXmu works.
2876 AC_CHECK_LIB(w, wslen, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lw"],,
2877 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2878 AC_CHECK_LIB(dl, dlsym, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldl"],,
2879 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2880 AC_CHECK_LIB(Xmu, XmuCreateStippledPixmap, [GUI_X_LIBS="-lXmu $GUI_X_LIBS"],,
2881 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2882 if test -z "$SKIP_MOTIF"; then
2883 AC_CHECK_LIB(Xp, XpEndJob, [GUI_X_LIBS="-lXp $GUI_X_LIBS"],,
2884 [$GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2885 fi
2886 LDFLAGS=$ldflags_save
2887
2888 dnl Execute xmkmf to figure out if -DNARROWPROTO is needed.
2889 AC_MSG_CHECKING(for extra X11 defines)
2890 NARROW_PROTO=
2891 rm -fr conftestdir
2892 if mkdir conftestdir; then
2893 cd conftestdir
2894 cat > Imakefile <<'EOF'
2895acfindx:
2896 @echo 'NARROW_PROTO="${PROTO_DEFINES}"'
2897EOF
2898 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
2899 eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
2900 fi
2901 cd ..
2902 rm -fr conftestdir
2903 fi
2904 if test -z "$NARROW_PROTO"; then
2905 AC_MSG_RESULT(no)
2906 else
2907 AC_MSG_RESULT($NARROW_PROTO)
2908 fi
2909 AC_SUBST(NARROW_PROTO)
2910fi
2911
2912dnl Look for XSMP support - but don't necessarily restrict it to X11 GUIs
2913dnl use the X11 include path
2914if test "$enable_xsmp" = "yes"; then
2915 cppflags_save=$CPPFLAGS
2916 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2917 AC_CHECK_HEADERS(X11/SM/SMlib.h)
2918 CPPFLAGS=$cppflags_save
2919fi
2920
2921
Bram Moolenaar98921892016-02-23 17:14:37 +01002922if 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 +00002923 dnl Check for X11/xpm.h and X11/Sunkeysym.h with the GUI include path
2924 cppflags_save=$CPPFLAGS
2925 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2926 AC_CHECK_HEADERS(X11/xpm.h X11/Sunkeysym.h)
2927
2928 dnl automatically disable XIM when XIMtext isn't in X11/Xlib.h
2929 if test ! "$enable_xim" = "no"; then
2930 AC_MSG_CHECKING(for XIMText in X11/Xlib.h)
2931 AC_EGREP_CPP(XIMText, [#include <X11/Xlib.h>],
2932 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +02002933 AC_MSG_RESULT(no; xim has been disabled); enable_xim="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00002934 fi
2935 CPPFLAGS=$cppflags_save
2936
2937 dnl automatically enable XIM when hangul input isn't enabled
2938 if test "$enable_xim" = "auto" -a "$enable_hangulinput" != "yes" \
2939 -a "x$GUITYPE" != "xNONE" ; then
2940 AC_MSG_RESULT(X GUI selected; xim has been enabled)
2941 enable_xim="yes"
2942 fi
2943fi
2944
2945if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
2946 cppflags_save=$CPPFLAGS
2947 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00002948dnl Xmu/Editres.h may exist but can only be used after including Intrinsic.h
2949 AC_MSG_CHECKING([for X11/Xmu/Editres.h])
2950 AC_TRY_COMPILE([
2951#include <X11/Intrinsic.h>
2952#include <X11/Xmu/Editres.h>],
2953 [int i; i = 0;],
2954 AC_MSG_RESULT(yes)
2955 AC_DEFINE(HAVE_X11_XMU_EDITRES_H),
2956 AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00002957 CPPFLAGS=$cppflags_save
2958fi
2959
2960dnl Only use the Xm directory when compiling Motif, don't use it for Athena
2961if test -z "$SKIP_MOTIF"; then
2962 cppflags_save=$CPPFLAGS
2963 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar77c19352012-06-13 19:19:41 +02002964 if test "$zOSUnix" = "yes"; then
2965 xmheader="Xm/Xm.h"
2966 else
2967 xmheader="Xm/Xm.h Xm/XpmP.h Xm/JoinSideT.h Xm/TraitP.h Xm/Manager.h
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02002968 Xm/UnhighlightT.h Xm/Notebook.h"
Bram Moolenaar77c19352012-06-13 19:19:41 +02002969 fi
2970 AC_CHECK_HEADERS($xmheader)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00002971
Bram Moolenaar77c19352012-06-13 19:19:41 +02002972 if test "x$ac_cv_header_Xm_XpmP_h" = "xyes"; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +00002973 dnl Solaris uses XpmAttributes_21, very annoying.
2974 AC_MSG_CHECKING([for XpmAttributes_21 in Xm/XpmP.h])
2975 AC_TRY_COMPILE([#include <Xm/XpmP.h>], [XpmAttributes_21 attr;],
2976 AC_MSG_RESULT(yes); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes_21),
2977 AC_MSG_RESULT(no); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
2978 )
2979 else
Bram Moolenaar57657d82006-04-21 22:12:41 +00002980 AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00002981 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002982 CPPFLAGS=$cppflags_save
2983fi
2984
2985if test "x$GUITYPE" = "xNONE" -a "$enable_xim" = "yes"; then
2986 AC_MSG_RESULT(no GUI selected; xim has been disabled)
2987 enable_xim="no"
2988fi
2989if test "x$GUITYPE" = "xNONE" -a "$enable_fontset" = "yes"; then
2990 AC_MSG_RESULT(no GUI selected; fontset has been disabled)
2991 enable_fontset="no"
2992fi
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002993if test "x$GUITYPE:$enable_fontset" = "xGTK:yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002994 AC_MSG_RESULT(GTK+ 2 GUI selected; fontset has been disabled)
2995 enable_fontset="no"
2996fi
2997
Bram Moolenaar071d4272004-06-13 20:20:40 +00002998if test -z "$SKIP_PHOTON"; then
2999 GUITYPE=PHOTONGUI
3000fi
3001
3002AC_SUBST(GUI_INC_LOC)
3003AC_SUBST(GUI_LIB_LOC)
3004AC_SUBST(GUITYPE)
3005AC_SUBST(GUI_X_LIBS)
3006
3007if test "$enable_workshop" = "yes" -a -n "$SKIP_MOTIF"; then
3008 AC_MSG_ERROR([cannot use workshop without Motif])
3009fi
3010
3011dnl defining FEAT_XIM and FEAT_XFONTSET is delayed, so that they can be disabled
3012if test "$enable_xim" = "yes"; then
3013 AC_DEFINE(FEAT_XIM)
3014fi
3015if test "$enable_fontset" = "yes"; then
3016 AC_DEFINE(FEAT_XFONTSET)
3017fi
3018
3019
3020dnl ---------------------------------------------------------------------------
3021dnl end of GUI-checking
3022dnl ---------------------------------------------------------------------------
3023
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003024AC_MSG_CHECKING([for /proc link to executable])
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003025if test -L "/proc/self/exe"; then
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003026 dnl Linux
3027 AC_MSG_RESULT([/proc/self/exe])
3028 AC_DEFINE(PROC_EXE_LINK, "/proc/self/exe")
3029elif test -L "/proc/self/path/a.out"; then
3030 dnl Solaris
3031 AC_MSG_RESULT([/proc/self/path/a.out])
3032 AC_DEFINE(PROC_EXE_LINK, "/proc/self/path/a.out")
3033elif test -L "/proc/curproc/file"; then
3034 dnl FreeBSD
3035 AC_MSG_RESULT([/proc/curproc/file])
3036 AC_DEFINE(PROC_EXE_LINK, "/proc/curproc/file")
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003037else
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003038 AC_MSG_RESULT(no)
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003039fi
3040
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003041dnl Check for Cygwin, which needs an extra source file if not using X11
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003042AC_MSG_CHECKING(for CYGWIN or MSYS environment)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003043case `uname` in
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003044 CYGWIN*|MSYS*) CYGWIN=yes; AC_MSG_RESULT(yes)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003045 AC_MSG_CHECKING(for CYGWIN clipboard support)
3046 if test "x$with_x" = "xno" ; then
3047 OS_EXTRA_SRC=winclip.c; OS_EXTRA_OBJ=objects/winclip.o
3048 AC_MSG_RESULT(yes)
3049 AC_DEFINE(FEAT_CYGWIN_WIN32_CLIPBOARD)
3050 else
3051 AC_MSG_RESULT(no - using X11)
3052 fi ;;
3053
3054 *) CYGWIN=no; AC_MSG_RESULT(no);;
3055esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00003056
3057dnl Only really enable hangul input when GUI and XFONTSET are available
3058if test "$enable_hangulinput" = "yes"; then
3059 if test "x$GUITYPE" = "xNONE"; then
3060 AC_MSG_RESULT(no GUI selected; hangul input has been disabled)
3061 enable_hangulinput=no
3062 else
3063 AC_DEFINE(FEAT_HANGULIN)
3064 HANGULIN_SRC=hangulin.c
3065 AC_SUBST(HANGULIN_SRC)
3066 HANGULIN_OBJ=objects/hangulin.o
3067 AC_SUBST(HANGULIN_OBJ)
3068 fi
3069fi
3070
3071dnl Checks for libraries and include files.
3072
Bram Moolenaar446cb832008-06-24 21:56:24 +00003073AC_CACHE_CHECK([whether toupper is broken], [vim_cv_toupper_broken],
3074 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003075 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003076#include "confdefs.h"
3077#include <ctype.h>
3078#if STDC_HEADERS
3079# include <stdlib.h>
3080# include <stddef.h>
3081#endif
3082main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003083 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003084 vim_cv_toupper_broken=yes
3085 ],[
3086 vim_cv_toupper_broken=no
3087 ],[
3088 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_toupper_broken')
3089 ])])
3090
3091if test "x$vim_cv_toupper_broken" = "xyes" ; then
3092 AC_DEFINE(BROKEN_TOUPPER)
3093fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003094
3095AC_MSG_CHECKING(whether __DATE__ and __TIME__ work)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003096AC_TRY_COMPILE([#include <stdio.h>], [printf("(" __DATE__ " " __TIME__ ")");],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003097 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DATE_TIME),
3098 AC_MSG_RESULT(no))
3099
Bram Moolenaar0c094b92009-05-14 20:20:33 +00003100AC_MSG_CHECKING(whether __attribute__((unused)) is allowed)
3101AC_TRY_COMPILE([#include <stdio.h>], [int x __attribute__((unused));],
3102 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ATTRIBUTE_UNUSED),
3103 AC_MSG_RESULT(no))
3104
Bram Moolenaar071d4272004-06-13 20:20:40 +00003105dnl Checks for header files.
3106AC_CHECK_HEADER(elf.h, HAS_ELF=1)
3107dnl AC_CHECK_HEADER(dwarf.h, SVR4=1)
3108if test "$HAS_ELF" = 1; then
3109 AC_CHECK_LIB(elf, main)
3110fi
3111
3112AC_HEADER_DIRENT
3113
Bram Moolenaar071d4272004-06-13 20:20:40 +00003114dnl If sys/wait.h is not found it might still exist but not be POSIX
3115dnl compliant. In that case we define HAVE_UNION_WAIT (for NeXT)
3116if test $ac_cv_header_sys_wait_h = no; then
3117 AC_MSG_CHECKING([for sys/wait.h that defines union wait])
3118 AC_TRY_COMPILE([#include <sys/wait.h>],
3119 [union wait xx, yy; xx = yy],
3120 AC_MSG_RESULT(yes)
3121 AC_DEFINE(HAVE_SYS_WAIT_H)
3122 AC_DEFINE(HAVE_UNION_WAIT),
3123 AC_MSG_RESULT(no))
3124fi
3125
Bram Moolenaar779a7752016-01-30 23:26:34 +01003126AC_CHECK_HEADERS(stdint.h stdlib.h string.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003127 sys/select.h sys/utsname.h termcap.h fcntl.h \
3128 sgtty.h sys/ioctl.h sys/time.h sys/types.h \
3129 termio.h iconv.h inttypes.h langinfo.h math.h \
3130 unistd.h stropts.h errno.h sys/resource.h \
3131 sys/systeminfo.h locale.h sys/stream.h termios.h \
3132 libc.h sys/statfs.h poll.h sys/poll.h pwd.h \
3133 utime.h sys/param.h libintl.h libgen.h \
3134 util/debug.h util/msg18n.h frame.h sys/acl.h \
3135 sys/access.h sys/sysinfo.h wchar.h wctype.h)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003136
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003137dnl sys/ptem.h depends on sys/stream.h on Solaris
3138AC_CHECK_HEADERS(sys/ptem.h, [], [],
3139[#if defined HAVE_SYS_STREAM_H
3140# include <sys/stream.h>
3141#endif])
3142
Bram Moolenaar32f31b12009-05-21 13:20:59 +00003143dnl sys/sysctl.h depends on sys/param.h on OpenBSD
3144AC_CHECK_HEADERS(sys/sysctl.h, [], [],
3145[#if defined HAVE_SYS_PARAM_H
3146# include <sys/param.h>
3147#endif])
3148
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003149
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003150dnl pthread_np.h may exist but can only be used after including pthread.h
3151AC_MSG_CHECKING([for pthread_np.h])
3152AC_TRY_COMPILE([
3153#include <pthread.h>
3154#include <pthread_np.h>],
3155 [int i; i = 0;],
3156 AC_MSG_RESULT(yes)
3157 AC_DEFINE(HAVE_PTHREAD_NP_H),
3158 AC_MSG_RESULT(no))
3159
Bram Moolenaare344bea2005-09-01 20:46:49 +00003160AC_CHECK_HEADERS(strings.h)
Bram Moolenaar9372a112005-12-06 19:59:18 +00003161if test "x$MACOSX" = "xyes"; then
3162 dnl The strings.h file on OS/X contains a warning and nothing useful.
3163 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3164else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003165
3166dnl Check if strings.h and string.h can both be included when defined.
3167AC_MSG_CHECKING([if strings.h can be included after string.h])
3168cppflags_save=$CPPFLAGS
3169CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3170AC_TRY_COMPILE([
3171#if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO)
3172# define _NO_PROTO /* like in os_unix.h, causes conflict for AIX (Winn) */
3173 /* but don't do it on AIX 5.1 (Uribarri) */
3174#endif
3175#ifdef HAVE_XM_XM_H
3176# include <Xm/Xm.h> /* This breaks it for HP-UX 11 (Squassabia) */
3177#endif
3178#ifdef HAVE_STRING_H
3179# include <string.h>
3180#endif
3181#if defined(HAVE_STRINGS_H)
3182# include <strings.h>
3183#endif
3184 ], [int i; i = 0;],
3185 AC_MSG_RESULT(yes),
3186 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3187 AC_MSG_RESULT(no))
3188CPPFLAGS=$cppflags_save
Bram Moolenaar9372a112005-12-06 19:59:18 +00003189fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003190
3191dnl Checks for typedefs, structures, and compiler characteristics.
3192AC_PROG_GCC_TRADITIONAL
3193AC_C_CONST
Bram Moolenaar76243bd2009-03-02 01:47:02 +00003194AC_C_VOLATILE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003195AC_TYPE_MODE_T
3196AC_TYPE_OFF_T
3197AC_TYPE_PID_T
3198AC_TYPE_SIZE_T
3199AC_TYPE_UID_T
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003200AC_TYPE_UINT32_T
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003201
Bram Moolenaar071d4272004-06-13 20:20:40 +00003202AC_HEADER_TIME
3203AC_CHECK_TYPE(ino_t, long)
3204AC_CHECK_TYPE(dev_t, unsigned)
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003205AC_C_BIGENDIAN(,,,)
Bram Moolenaar136f29a2016-02-27 20:14:15 +01003206AC_C_INLINE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003207
3208AC_MSG_CHECKING(for rlim_t)
3209if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
3210 AC_MSG_RESULT([(cached) $ac_cv_type_rlim_t])
3211else
3212 AC_EGREP_CPP(dnl
3213changequote(<<,>>)dnl
3214<<(^|[^a-zA-Z_0-9])rlim_t[^a-zA-Z_0-9]>>dnl
3215changequote([,]),
3216 [
3217#include <sys/types.h>
3218#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003219# include <stdlib.h>
3220# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003221#endif
3222#ifdef HAVE_SYS_RESOURCE_H
Bram Moolenaar446cb832008-06-24 21:56:24 +00003223# include <sys/resource.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003224#endif
3225 ], ac_cv_type_rlim_t=yes, ac_cv_type_rlim_t=no)
3226 AC_MSG_RESULT($ac_cv_type_rlim_t)
3227fi
3228if test $ac_cv_type_rlim_t = no; then
3229 cat >> confdefs.h <<\EOF
3230#define rlim_t unsigned long
3231EOF
3232fi
3233
3234AC_MSG_CHECKING(for stack_t)
3235if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then
3236 AC_MSG_RESULT([(cached) $ac_cv_type_stack_t])
3237else
3238 AC_EGREP_CPP(stack_t,
3239 [
3240#include <sys/types.h>
3241#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003242# include <stdlib.h>
3243# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003244#endif
3245#include <signal.h>
3246 ], ac_cv_type_stack_t=yes, ac_cv_type_stack_t=no)
3247 AC_MSG_RESULT($ac_cv_type_stack_t)
3248fi
3249if test $ac_cv_type_stack_t = no; then
3250 cat >> confdefs.h <<\EOF
3251#define stack_t struct sigaltstack
3252EOF
3253fi
3254
3255dnl BSDI uses ss_base while others use ss_sp for the stack pointer.
3256AC_MSG_CHECKING(whether stack_t has an ss_base field)
3257AC_TRY_COMPILE([
3258#include <sys/types.h>
3259#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003260# include <stdlib.h>
3261# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003262#endif
3263#include <signal.h>
3264#include "confdefs.h"
3265 ], [stack_t sigstk; sigstk.ss_base = 0; ],
3266 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SS_BASE),
3267 AC_MSG_RESULT(no))
3268
3269olibs="$LIBS"
3270AC_MSG_CHECKING(--with-tlib argument)
3271AC_ARG_WITH(tlib, [ --with-tlib=library terminal library to be used ],)
3272if test -n "$with_tlib"; then
3273 AC_MSG_RESULT($with_tlib)
3274 LIBS="$LIBS -l$with_tlib"
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003275 AC_MSG_CHECKING(for linking with $with_tlib library)
3276 AC_TRY_LINK([], [], AC_MSG_RESULT(OK), AC_MSG_ERROR(FAILED))
3277 dnl Need to check for tgetent() below.
3278 olibs="$LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003279else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003280 AC_MSG_RESULT([empty: automatic terminal library selection])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003281 dnl On HP-UX 10.10 termcap or termlib should be used instead of
3282 dnl curses, because curses is much slower.
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003283 dnl Newer versions of ncurses are preferred over anything, except
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02003284 dnl when tinfo has been split off, it contains all we need.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003285 dnl Older versions of ncurses have bugs, get a new one!
3286 dnl Digital Unix (OSF1) should use curses (Ronald Schild).
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00003287 dnl On SCO Openserver should prefer termlib (Roger Cornelius).
Bram Moolenaar071d4272004-06-13 20:20:40 +00003288 case "`uname -s 2>/dev/null`" in
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003289 OSF1|SCO_SV) tlibs="tinfo ncurses curses termlib termcap";;
3290 *) tlibs="tinfo ncurses termlib termcap curses";;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003291 esac
3292 for libname in $tlibs; do
3293 AC_CHECK_LIB(${libname}, tgetent,,)
3294 if test "x$olibs" != "x$LIBS"; then
3295 dnl It's possible that a library is found but it doesn't work
3296 dnl e.g., shared library that cannot be found
3297 dnl compile and run a test program to be sure
3298 AC_TRY_RUN([
3299#ifdef HAVE_TERMCAP_H
3300# include <termcap.h>
3301#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003302#if STDC_HEADERS
3303# include <stdlib.h>
3304# include <stddef.h>
3305#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003306main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }],
3307 res="OK", res="FAIL", res="FAIL")
3308 if test "$res" = "OK"; then
3309 break
3310 fi
3311 AC_MSG_RESULT($libname library is not usable)
3312 LIBS="$olibs"
3313 fi
3314 done
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003315 if test "x$olibs" = "x$LIBS"; then
3316 AC_MSG_RESULT(no terminal library found)
3317 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003318fi
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003319
3320if test "x$olibs" = "x$LIBS"; then
3321 AC_MSG_CHECKING([for tgetent()])
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00003322 AC_TRY_LINK([],
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003323 [char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");],
3324 AC_MSG_RESULT(yes),
3325 AC_MSG_ERROR([NOT FOUND!
3326 You need to install a terminal library; for example ncurses.
3327 Or specify the name of the library with --with-tlib.]))
3328fi
3329
Bram Moolenaar446cb832008-06-24 21:56:24 +00003330AC_CACHE_CHECK([whether we talk terminfo], [vim_cv_terminfo],
3331 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003332 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003333#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003334#ifdef HAVE_TERMCAP_H
3335# include <termcap.h>
3336#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003337#ifdef HAVE_STRING_H
3338# include <string.h>
3339#endif
3340#if STDC_HEADERS
3341# include <stdlib.h>
3342# include <stddef.h>
3343#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003344main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003345{char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003346 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003347 vim_cv_terminfo=no
3348 ],[
3349 vim_cv_terminfo=yes
3350 ],[
3351 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_terminfo')
3352 ])
3353 ])
3354
3355if test "x$vim_cv_terminfo" = "xyes" ; then
3356 AC_DEFINE(TERMINFO)
3357fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003358
3359if test "x$olibs" != "x$LIBS"; then
Bram Moolenaar446cb832008-06-24 21:56:24 +00003360 AC_CACHE_CHECK([what tgetent() returns for an unknown terminal], [vim_cv_tgent],
3361 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003362 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003363#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003364#ifdef HAVE_TERMCAP_H
3365# include <termcap.h>
3366#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003367#if STDC_HEADERS
3368# include <stdlib.h>
3369# include <stddef.h>
3370#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003371main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003372{char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003373 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003374 vim_cv_tgent=zero
3375 ],[
3376 vim_cv_tgent=non-zero
3377 ],[
3378 AC_MSG_ERROR(failed to compile test program.)
3379 ])
3380 ])
3381
3382 if test "x$vim_cv_tgent" = "xzero" ; then
3383 AC_DEFINE(TGETENT_ZERO_ERR, 0)
3384 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003385fi
3386
3387AC_MSG_CHECKING(whether termcap.h contains ospeed)
3388AC_TRY_LINK([
3389#ifdef HAVE_TERMCAP_H
3390# include <termcap.h>
3391#endif
3392 ], [ospeed = 20000],
3393 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED),
3394 [AC_MSG_RESULT(no)
3395 AC_MSG_CHECKING(whether ospeed can be extern)
3396 AC_TRY_LINK([
3397#ifdef HAVE_TERMCAP_H
3398# include <termcap.h>
3399#endif
3400extern short ospeed;
3401 ], [ospeed = 20000],
3402 AC_MSG_RESULT(yes); AC_DEFINE(OSPEED_EXTERN),
3403 AC_MSG_RESULT(no))]
3404 )
3405
3406AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC])
3407AC_TRY_LINK([
3408#ifdef HAVE_TERMCAP_H
3409# include <termcap.h>
3410#endif
3411 ], [if (UP == 0 && BC == 0) PC = 1],
3412 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UP_BC_PC),
3413 [AC_MSG_RESULT(no)
3414 AC_MSG_CHECKING([whether UP, BC and PC can be extern])
3415 AC_TRY_LINK([
3416#ifdef HAVE_TERMCAP_H
3417# include <termcap.h>
3418#endif
3419extern char *UP, *BC, PC;
3420 ], [if (UP == 0 && BC == 0) PC = 1],
3421 AC_MSG_RESULT(yes); AC_DEFINE(UP_BC_PC_EXTERN),
3422 AC_MSG_RESULT(no))]
3423 )
3424
3425AC_MSG_CHECKING(whether tputs() uses outfuntype)
3426AC_TRY_COMPILE([
3427#ifdef HAVE_TERMCAP_H
3428# include <termcap.h>
3429#endif
3430 ], [extern int xx(); tputs("test", 1, (outfuntype)xx)],
3431 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OUTFUNTYPE),
3432 AC_MSG_RESULT(no))
3433
3434dnl On some SCO machines sys/select redefines struct timeval
3435AC_MSG_CHECKING([whether sys/select.h and sys/time.h may both be included])
3436AC_TRY_COMPILE([
3437#include <sys/types.h>
3438#include <sys/time.h>
3439#include <sys/select.h>], ,
3440 AC_MSG_RESULT(yes)
3441 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME),
3442 AC_MSG_RESULT(no))
3443
3444dnl AC_DECL_SYS_SIGLIST
3445
3446dnl Checks for pty.c (copied from screen) ==========================
3447AC_MSG_CHECKING(for /dev/ptc)
3448if test -r /dev/ptc; then
3449 AC_DEFINE(HAVE_DEV_PTC)
3450 AC_MSG_RESULT(yes)
3451else
3452 AC_MSG_RESULT(no)
3453fi
3454
3455AC_MSG_CHECKING(for SVR4 ptys)
3456if test -c /dev/ptmx ; then
3457 AC_TRY_LINK([], [ptsname(0);grantpt(0);unlockpt(0);],
3458 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SVR4_PTYS),
3459 AC_MSG_RESULT(no))
3460else
3461 AC_MSG_RESULT(no)
3462fi
3463
3464AC_MSG_CHECKING(for ptyranges)
3465if test -d /dev/ptym ; then
3466 pdir='/dev/ptym'
3467else
3468 pdir='/dev'
3469fi
3470dnl SCO uses ptyp%d
3471AC_EGREP_CPP(yes,
3472[#ifdef M_UNIX
3473 yes;
3474#endif
3475 ], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
3476dnl if test -c /dev/ptyp19; then
3477dnl ptys=`echo /dev/ptyp??`
3478dnl else
3479dnl ptys=`echo $pdir/pty??`
3480dnl fi
3481if test "$ptys" != "$pdir/pty??" ; then
3482 p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
3483 p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'`
3484 AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
3485 AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
3486 AC_MSG_RESULT([$p0 / $p1])
3487else
3488 AC_MSG_RESULT([don't know])
3489fi
3490
3491dnl **** pty mode/group handling ****
3492dnl
3493dnl support provided by Luke Mewburn <lm@rmit.edu.au>, 931222
Bram Moolenaar071d4272004-06-13 20:20:40 +00003494rm -f conftest_grp
Bram Moolenaar446cb832008-06-24 21:56:24 +00003495AC_CACHE_CHECK([default tty permissions/group], [vim_cv_tty_group],
3496 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003497 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003498#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003499#include <sys/types.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003500#if STDC_HEADERS
3501# include <stdlib.h>
3502# include <stddef.h>
3503#endif
3504#ifdef HAVE_UNISTD_H
3505#include <unistd.h>
3506#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003507#include <sys/stat.h>
3508#include <stdio.h>
3509main()
3510{
3511 struct stat sb;
3512 char *x,*ttyname();
3513 int om, m;
3514 FILE *fp;
3515
3516 if (!(x = ttyname(0))) exit(1);
3517 if (stat(x, &sb)) exit(1);
3518 om = sb.st_mode;
3519 if (om & 002) exit(0);
3520 m = system("mesg y");
3521 if (m == -1 || m == 127) exit(1);
3522 if (stat(x, &sb)) exit(1);
3523 m = sb.st_mode;
3524 if (chmod(x, om)) exit(1);
3525 if (m & 002) exit(0);
3526 if (sb.st_gid == getgid()) exit(1);
3527 if (!(fp=fopen("conftest_grp", "w")))
3528 exit(1);
3529 fprintf(fp, "%d\n", sb.st_gid);
3530 fclose(fp);
3531 exit(0);
3532}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003533 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003534 if test -f conftest_grp; then
3535 vim_cv_tty_group=`cat conftest_grp`
3536 if test "x$vim_cv_tty_mode" = "x" ; then
3537 vim_cv_tty_mode=0620
3538 fi
3539 AC_MSG_RESULT([pty mode: $vim_cv_tty_mode, group: $vim_cv_tty_group])
3540 else
3541 vim_cv_tty_group=world
Bram Moolenaar72951072009-12-02 16:58:33 +00003542 AC_MSG_RESULT([ptys are world accessible])
Bram Moolenaar446cb832008-06-24 21:56:24 +00003543 fi
3544 ],[
3545 vim_cv_tty_group=world
Bram Moolenaar72951072009-12-02 16:58:33 +00003546 AC_MSG_RESULT([can't determine - assume ptys are world accessible])
Bram Moolenaar446cb832008-06-24 21:56:24 +00003547 ],[
3548 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_tty_group' and 'vim_cv_tty_mode')
3549 ])
3550 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003551rm -f conftest_grp
3552
Bram Moolenaar446cb832008-06-24 21:56:24 +00003553if test "x$vim_cv_tty_group" != "xworld" ; then
3554 AC_DEFINE_UNQUOTED(PTYGROUP,$vim_cv_tty_group)
3555 if test "x$vim_cv_tty_mode" = "x" ; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02003556 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 +00003557 else
3558 AC_DEFINE(PTYMODE, 0620)
3559 fi
3560fi
3561
Bram Moolenaar071d4272004-06-13 20:20:40 +00003562dnl Checks for library functions. ===================================
3563
3564AC_TYPE_SIGNAL
3565
3566dnl find out what to use at the end of a signal function
3567if test $ac_cv_type_signal = void; then
3568 AC_DEFINE(SIGRETURN, [return])
3569else
3570 AC_DEFINE(SIGRETURN, [return 0])
3571fi
3572
3573dnl check if struct sigcontext is defined (used for SGI only)
3574AC_MSG_CHECKING(for struct sigcontext)
3575AC_TRY_COMPILE([
3576#include <signal.h>
3577test_sig()
3578{
3579 struct sigcontext *scont;
3580 scont = (struct sigcontext *)0;
3581 return 1;
3582} ], ,
3583 AC_MSG_RESULT(yes)
3584 AC_DEFINE(HAVE_SIGCONTEXT),
3585 AC_MSG_RESULT(no))
3586
3587dnl tricky stuff: try to find out if getcwd() is implemented with
3588dnl system("sh -c pwd")
Bram Moolenaar446cb832008-06-24 21:56:24 +00003589AC_CACHE_CHECK([getcwd implementation is broken], [vim_cv_getcwd_broken],
3590 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003591 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003592#include "confdefs.h"
3593#ifdef HAVE_UNISTD_H
3594#include <unistd.h>
3595#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003596char *dagger[] = { "IFS=pwd", 0 };
3597main()
3598{
3599 char buffer[500];
3600 extern char **environ;
3601 environ = dagger;
3602 return getcwd(buffer, 500) ? 0 : 1;
Bram Moolenaar446cb832008-06-24 21:56:24 +00003603}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003604 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003605 vim_cv_getcwd_broken=no
3606 ],[
3607 vim_cv_getcwd_broken=yes
3608 ],[
3609 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_getcwd_broken')
3610 ])
3611 ])
3612
3613if test "x$vim_cv_getcwd_broken" = "xyes" ; then
3614 AC_DEFINE(BAD_GETCWD)
3615fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003616
Bram Moolenaar25153e12010-02-24 14:47:08 +01003617dnl Check for functions in one big call, to reduce the size of configure.
3618dnl Can only be used for functions that do not require any include.
Bram Moolenaarb129a442016-12-01 17:25:20 +01003619AC_CHECK_FUNCS(fchdir fchown fsync getcwd getpseudotty \
3620 getpwent getpwnam getpwuid getrlimit gettimeofday getwd lstat \
Bram Moolenaareaf03392009-11-17 11:08:52 +00003621 memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
Bram Moolenaar2fcf6682017-03-11 20:03:42 +01003622 getpgid setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
Bram Moolenaarbb09ceb2016-10-18 16:27:23 +02003623 sigprocmask sigvec strcasecmp strerror strftime stricmp strncasecmp \
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00003624 strnicmp strpbrk strtol tgetent towlower towupper iswupper \
Bram Moolenaara6b89762016-02-29 21:38:26 +01003625 usleep utime utimes)
Bram Moolenaar25153e12010-02-24 14:47:08 +01003626AC_FUNC_FSEEKO
Bram Moolenaar071d4272004-06-13 20:20:40 +00003627
Bram Moolenaar317fd3a2010-05-07 16:05:55 +02003628dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when
3629dnl appropriate, so that off_t is 64 bits when needed.
3630AC_SYS_LARGEFILE
3631
Bram Moolenaar071d4272004-06-13 20:20:40 +00003632dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible
3633AC_MSG_CHECKING(for st_blksize)
3634AC_TRY_COMPILE(
3635[#include <sys/types.h>
3636#include <sys/stat.h>],
3637[ struct stat st;
3638 int n;
3639
3640 stat("/", &st);
3641 n = (int)st.st_blksize;],
3642 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ST_BLKSIZE),
3643 AC_MSG_RESULT(no))
3644
Bram Moolenaar446cb832008-06-24 21:56:24 +00003645AC_CACHE_CHECK([whether stat() ignores a trailing slash], [vim_cv_stat_ignores_slash],
3646 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003647 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003648#include "confdefs.h"
3649#if STDC_HEADERS
3650# include <stdlib.h>
3651# include <stddef.h>
3652#endif
3653#include <sys/types.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003654#include <sys/stat.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003655main() {struct stat st; exit(stat("configure/", &st) != 0); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003656 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003657 vim_cv_stat_ignores_slash=yes
3658 ],[
3659 vim_cv_stat_ignores_slash=no
3660 ],[
3661 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_stat_ignores_slash')
3662 ])
3663 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003664
Bram Moolenaar446cb832008-06-24 21:56:24 +00003665if test "x$vim_cv_stat_ignores_slash" = "xyes" ; then
3666 AC_DEFINE(STAT_IGNORES_SLASH)
3667fi
3668
Bram Moolenaar071d4272004-06-13 20:20:40 +00003669dnl Link with iconv for charset translation, if not found without library.
3670dnl check for iconv() requires including iconv.h
3671dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
3672dnl has been installed.
3673AC_MSG_CHECKING(for iconv_open())
3674save_LIBS="$LIBS"
3675LIBS="$LIBS -liconv"
3676AC_TRY_LINK([
3677#ifdef HAVE_ICONV_H
3678# include <iconv.h>
3679#endif
3680 ], [iconv_open("fr", "to");],
3681 AC_MSG_RESULT(yes; with -liconv); AC_DEFINE(HAVE_ICONV),
3682 LIBS="$save_LIBS"
3683 AC_TRY_LINK([
3684#ifdef HAVE_ICONV_H
3685# include <iconv.h>
3686#endif
3687 ], [iconv_open("fr", "to");],
3688 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ICONV),
3689 AC_MSG_RESULT(no)))
3690
3691
3692AC_MSG_CHECKING(for nl_langinfo(CODESET))
3693AC_TRY_LINK([
3694#ifdef HAVE_LANGINFO_H
3695# include <langinfo.h>
3696#endif
3697], [char *cs = nl_langinfo(CODESET);],
3698 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET),
3699 AC_MSG_RESULT(no))
3700
Bram Moolenaar446cb832008-06-24 21:56:24 +00003701dnl Need various functions for floating point support. Only enable
3702dnl floating point when they are all present.
3703AC_CHECK_LIB(m, strtod)
3704AC_MSG_CHECKING([for strtod() and other floating point functions])
3705AC_TRY_LINK([
3706#ifdef HAVE_MATH_H
3707# include <math.h>
3708#endif
3709#if STDC_HEADERS
3710# include <stdlib.h>
3711# include <stddef.h>
3712#endif
3713], [char *s; double d;
3714 d = strtod("1.1", &s);
3715 d = fabs(1.11);
3716 d = ceil(1.11);
3717 d = floor(1.11);
3718 d = log10(1.11);
3719 d = pow(1.11, 2.22);
3720 d = sqrt(1.11);
3721 d = sin(1.11);
3722 d = cos(1.11);
3723 d = atan(1.11);
3724 ],
3725 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT_FUNCS),
3726 AC_MSG_RESULT(no))
3727
Bram Moolenaara6b89762016-02-29 21:38:26 +01003728dnl isinf() and isnan() need to include header files and may need -lm.
3729AC_MSG_CHECKING([for isinf()])
3730AC_TRY_LINK([
3731#ifdef HAVE_MATH_H
3732# include <math.h>
3733#endif
3734#if STDC_HEADERS
3735# include <stdlib.h>
3736# include <stddef.h>
3737#endif
3738], [int r = isinf(1.11); ],
3739 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISINF),
3740 AC_MSG_RESULT(no))
3741
3742AC_MSG_CHECKING([for isnan()])
3743AC_TRY_LINK([
3744#ifdef HAVE_MATH_H
3745# include <math.h>
3746#endif
3747#if STDC_HEADERS
3748# include <stdlib.h>
3749# include <stddef.h>
3750#endif
3751], [int r = isnan(1.11); ],
3752 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISNAN),
3753 AC_MSG_RESULT(no))
3754
Bram Moolenaar071d4272004-06-13 20:20:40 +00003755dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI
3756dnl when -lacl works, also try to use -lattr (required for Debian).
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003757dnl On Solaris, use the acl_get/set functions in libsec, if present.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003758AC_MSG_CHECKING(--disable-acl argument)
3759AC_ARG_ENABLE(acl,
3760 [ --disable-acl Don't check for ACL support.],
3761 , [enable_acl="yes"])
3762if test "$enable_acl" = "yes"; then
3763AC_MSG_RESULT(no)
3764AC_CHECK_LIB(posix1e, acl_get_file, [LIBS="$LIBS -lposix1e"],
3765 AC_CHECK_LIB(acl, acl_get_file, [LIBS="$LIBS -lacl"
3766 AC_CHECK_LIB(attr, fgetxattr, LIBS="$LIBS -lattr",,)],,),)
3767
3768AC_MSG_CHECKING(for POSIX ACL support)
3769AC_TRY_LINK([
3770#include <sys/types.h>
3771#ifdef HAVE_SYS_ACL_H
3772# include <sys/acl.h>
3773#endif
3774acl_t acl;], [acl = acl_get_file("foo", ACL_TYPE_ACCESS);
3775 acl_set_file("foo", ACL_TYPE_ACCESS, acl);
3776 acl_free(acl);],
3777 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_ACL),
3778 AC_MSG_RESULT(no))
3779
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003780AC_CHECK_LIB(sec, acl_get, [LIBS="$LIBS -lsec"; AC_DEFINE(HAVE_SOLARIS_ZFS_ACL)],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003781AC_MSG_CHECKING(for Solaris ACL support)
3782AC_TRY_LINK([
3783#ifdef HAVE_SYS_ACL_H
3784# include <sys/acl.h>
3785#endif], [acl("foo", GETACLCNT, 0, NULL);
3786 ],
3787 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOLARIS_ACL),
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003788 AC_MSG_RESULT(no)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003789
3790AC_MSG_CHECKING(for AIX ACL support)
3791AC_TRY_LINK([
Bram Moolenaar446cb832008-06-24 21:56:24 +00003792#if STDC_HEADERS
3793# include <stdlib.h>
3794# include <stddef.h>
3795#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003796#ifdef HAVE_SYS_ACL_H
3797# include <sys/acl.h>
3798#endif
3799#ifdef HAVE_SYS_ACCESS_H
3800# include <sys/access.h>
3801#endif
3802#define _ALL_SOURCE
3803
3804#include <sys/stat.h>
3805
3806int aclsize;
3807struct acl *aclent;], [aclsize = sizeof(struct acl);
3808 aclent = (void *)malloc(aclsize);
3809 statacl("foo", STX_NORMAL, aclent, aclsize);
3810 ],
3811 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_AIX_ACL),
3812 AC_MSG_RESULT(no))
3813else
3814 AC_MSG_RESULT(yes)
3815fi
3816
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02003817if test "x$GTK_CFLAGS" != "x"; then
3818 dnl pango_shape_full() is new, fall back to pango_shape().
3819 AC_MSG_CHECKING(for pango_shape_full)
3820 ac_save_CFLAGS="$CFLAGS"
3821 ac_save_LIBS="$LIBS"
3822 CFLAGS="$CFLAGS $GTK_CFLAGS"
3823 LIBS="$LIBS $GTK_LIBS"
Bram Moolenaar5325b9b2015-09-09 20:27:02 +02003824 AC_TRY_LINK(
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02003825 [#include <gtk/gtk.h>],
3826 [ pango_shape_full(NULL, 0, NULL, 0, NULL, NULL); ],
3827 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_PANGO_SHAPE_FULL),
3828 AC_MSG_RESULT(no))
3829 CFLAGS="$ac_save_CFLAGS"
3830 LIBS="$ac_save_LIBS"
3831fi
3832
Bram Moolenaar071d4272004-06-13 20:20:40 +00003833AC_MSG_CHECKING(--disable-gpm argument)
3834AC_ARG_ENABLE(gpm,
3835 [ --disable-gpm Don't use gpm (Linux mouse daemon).], ,
3836 [enable_gpm="yes"])
3837
3838if test "$enable_gpm" = "yes"; then
3839 AC_MSG_RESULT(no)
3840 dnl Checking if gpm support can be compiled
3841 AC_CACHE_CHECK([for gpm], vi_cv_have_gpm,
3842 [olibs="$LIBS" ; LIBS="-lgpm"]
3843 AC_TRY_LINK(
3844 [#include <gpm.h>
3845 #include <linux/keyboard.h>],
3846 [Gpm_GetLibVersion(NULL);],
3847 dnl Configure defines HAVE_GPM, if it is defined feature.h defines
3848 dnl FEAT_MOUSE_GPM if mouse support is included
3849 [vi_cv_have_gpm=yes],
3850 [vi_cv_have_gpm=no])
3851 [LIBS="$olibs"]
3852 )
3853 if test $vi_cv_have_gpm = yes; then
3854 LIBS="$LIBS -lgpm"
3855 AC_DEFINE(HAVE_GPM)
3856 fi
3857else
3858 AC_MSG_RESULT(yes)
3859fi
3860
Bram Moolenaar446cb832008-06-24 21:56:24 +00003861AC_MSG_CHECKING(--disable-sysmouse argument)
3862AC_ARG_ENABLE(sysmouse,
3863 [ --disable-sysmouse Don't use sysmouse (mouse in *BSD console).], ,
3864 [enable_sysmouse="yes"])
3865
3866if test "$enable_sysmouse" = "yes"; then
3867 AC_MSG_RESULT(no)
3868 dnl Checking if sysmouse support can be compiled
3869 dnl Configure defines HAVE_SYSMOUSE, if it is defined feature.h
3870 dnl defines FEAT_SYSMOUSE if mouse support is included
3871 AC_CACHE_CHECK([for sysmouse], vi_cv_have_sysmouse,
3872 AC_TRY_LINK(
3873 [#include <sys/consio.h>
3874 #include <signal.h>
3875 #include <sys/fbio.h>],
3876 [struct mouse_info mouse;
3877 mouse.operation = MOUSE_MODE;
3878 mouse.operation = MOUSE_SHOW;
3879 mouse.u.mode.mode = 0;
3880 mouse.u.mode.signal = SIGUSR2;],
3881 [vi_cv_have_sysmouse=yes],
3882 [vi_cv_have_sysmouse=no])
3883 )
3884 if test $vi_cv_have_sysmouse = yes; then
3885 AC_DEFINE(HAVE_SYSMOUSE)
3886 fi
3887else
3888 AC_MSG_RESULT(yes)
3889fi
3890
Bram Moolenaarf05da212009-11-17 16:13:15 +00003891dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
3892AC_MSG_CHECKING(for FD_CLOEXEC)
3893AC_TRY_COMPILE(
3894[#if HAVE_FCNTL_H
3895# include <fcntl.h>
3896#endif],
3897[ int flag = FD_CLOEXEC;],
3898 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
3899 AC_MSG_RESULT(not usable))
3900
Bram Moolenaar071d4272004-06-13 20:20:40 +00003901dnl rename needs to be checked separately to work on Nextstep with cc
3902AC_MSG_CHECKING(for rename)
3903AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
3904 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
3905 AC_MSG_RESULT(no))
3906
3907dnl sysctl() may exist but not the arguments we use
3908AC_MSG_CHECKING(for sysctl)
3909AC_TRY_COMPILE(
3910[#include <sys/types.h>
3911#include <sys/sysctl.h>],
3912[ int mib[2], r;
3913 size_t len;
3914
3915 mib[0] = CTL_HW;
3916 mib[1] = HW_USERMEM;
3917 len = sizeof(r);
3918 (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
3919 ],
3920 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL),
3921 AC_MSG_RESULT(not usable))
3922
3923dnl sysinfo() may exist but not be Linux compatible
3924AC_MSG_CHECKING(for sysinfo)
3925AC_TRY_COMPILE(
3926[#include <sys/types.h>
3927#include <sys/sysinfo.h>],
3928[ struct sysinfo sinfo;
3929 int t;
3930
3931 (void)sysinfo(&sinfo);
3932 t = sinfo.totalram;
3933 ],
3934 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
3935 AC_MSG_RESULT(not usable))
3936
Bram Moolenaar914572a2007-05-01 11:37:47 +00003937dnl struct sysinfo may have the mem_unit field or not
3938AC_MSG_CHECKING(for sysinfo.mem_unit)
3939AC_TRY_COMPILE(
3940[#include <sys/types.h>
3941#include <sys/sysinfo.h>],
3942[ struct sysinfo sinfo;
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02003943 sinfo.mem_unit = 1;
Bram Moolenaar914572a2007-05-01 11:37:47 +00003944 ],
3945 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_MEM_UNIT),
3946 AC_MSG_RESULT(no))
3947
Bram Moolenaar071d4272004-06-13 20:20:40 +00003948dnl sysconf() may exist but not support what we want to use
3949AC_MSG_CHECKING(for sysconf)
3950AC_TRY_COMPILE(
3951[#include <unistd.h>],
3952[ (void)sysconf(_SC_PAGESIZE);
3953 (void)sysconf(_SC_PHYS_PAGES);
3954 ],
3955 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
3956 AC_MSG_RESULT(not usable))
3957
Bram Moolenaar914703b2010-05-31 21:59:46 +02003958AC_CHECK_SIZEOF([int])
3959AC_CHECK_SIZEOF([long])
3960AC_CHECK_SIZEOF([time_t])
3961AC_CHECK_SIZEOF([off_t])
Bram Moolenaar644fdff2010-05-30 13:26:21 +02003962
Bram Moolenaara2aa31a2014-02-23 22:52:40 +01003963dnl Use different names to avoid clashing with other header files.
3964AC_DEFINE_UNQUOTED(VIM_SIZEOF_INT, [$ac_cv_sizeof_int])
3965AC_DEFINE_UNQUOTED(VIM_SIZEOF_LONG, [$ac_cv_sizeof_long])
3966
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003967dnl Make sure that uint32_t is really 32 bits unsigned.
3968AC_MSG_CHECKING([uint32_t is 32 bits])
3969AC_TRY_RUN([
3970#ifdef HAVE_STDINT_H
3971# include <stdint.h>
3972#endif
3973#ifdef HAVE_INTTYPES_H
3974# include <inttypes.h>
3975#endif
3976main() {
3977 uint32_t nr1 = (uint32_t)-1;
3978 uint32_t nr2 = (uint32_t)0xffffffffUL;
3979 if (sizeof(uint32_t) != 4 || nr1 != 0xffffffffUL || nr2 + 1 != 0) exit(1);
3980 exit(0);
3981}],
3982AC_MSG_RESULT(ok),
3983AC_MSG_ERROR([WRONG! uint32_t not defined correctly.]),
Bram Moolenaar323cb952011-12-14 19:22:34 +01003984AC_MSG_WARN([cannot check uint32_t when cross-compiling.]))
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003985
Bram Moolenaar446cb832008-06-24 21:56:24 +00003986dnl Check for memmove() before bcopy(), makes memmove() be used when both are
3987dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
3988
Bram Moolenaar071d4272004-06-13 20:20:40 +00003989[bcopy_test_prog='
Bram Moolenaar446cb832008-06-24 21:56:24 +00003990#include "confdefs.h"
3991#ifdef HAVE_STRING_H
3992# include <string.h>
3993#endif
3994#if STDC_HEADERS
3995# include <stdlib.h>
3996# include <stddef.h>
3997#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003998main() {
3999 char buf[10];
4000 strcpy(buf, "abcdefghi");
4001 mch_memmove(buf, buf + 2, 3);
4002 if (strncmp(buf, "ababcf", 6))
4003 exit(1);
4004 strcpy(buf, "abcdefghi");
4005 mch_memmove(buf + 2, buf, 3);
4006 if (strncmp(buf, "cdedef", 6))
4007 exit(1);
4008 exit(0); /* libc version works properly. */
4009}']
4010
Bram Moolenaar446cb832008-06-24 21:56:24 +00004011AC_CACHE_CHECK([whether memmove handles overlaps],[vim_cv_memmove_handles_overlap],
4012 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004013 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 +00004014 [
4015 vim_cv_memmove_handles_overlap=yes
4016 ],[
4017 vim_cv_memmove_handles_overlap=no
4018 ],[
4019 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memmove_handles_overlap')
4020 ])
4021 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00004022
Bram Moolenaar446cb832008-06-24 21:56:24 +00004023if test "x$vim_cv_memmove_handles_overlap" = "xyes" ; then
4024 AC_DEFINE(USEMEMMOVE)
4025else
4026 AC_CACHE_CHECK([whether bcopy handles overlaps],[vim_cv_bcopy_handles_overlap],
4027 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004028 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 +00004029 [
4030 vim_cv_bcopy_handles_overlap=yes
4031 ],[
4032 vim_cv_bcopy_handles_overlap=no
4033 ],[
4034 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_bcopy_handles_overlap')
4035 ])
4036 ])
4037
4038 if test "x$vim_cv_bcopy_handles_overlap" = "xyes" ; then
4039 AC_DEFINE(USEBCOPY)
4040 else
4041 AC_CACHE_CHECK([whether memcpy handles overlaps],[vim_cv_memcpy_handles_overlap],
4042 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004043 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 +00004044 [
4045 vim_cv_memcpy_handles_overlap=yes
4046 ],[
4047 vim_cv_memcpy_handles_overlap=no
4048 ],[
4049 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memcpy_handles_overlap')
4050 ])
4051 ])
4052
4053 if test "x$vim_cv_memcpy_handles_overlap" = "xyes" ; then
4054 AC_DEFINE(USEMEMCPY)
4055 fi
4056 fi
4057fi
4058
Bram Moolenaar071d4272004-06-13 20:20:40 +00004059
4060dnl Check for multibyte locale functions
4061dnl Find out if _Xsetlocale() is supported by libX11.
4062dnl Check if X_LOCALE should be defined.
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004063if test "x$with_x" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004064 cflags_save=$CFLAGS
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004065 libs_save=$LIBS
4066 LIBS="$LIBS $X_LIBS $GUI_LIB_LOC $GUI_X_LIBS $X_PRE_LIBS $X_LIB $X_EXTRA_LIBS"
4067 CFLAGS="$CFLAGS $X_CFLAGS"
4068
4069 AC_MSG_CHECKING(whether X_LOCALE needed)
4070 AC_TRY_COMPILE([#include <X11/Xlocale.h>],,
4071 AC_TRY_LINK_FUNC([_Xsetlocale], [AC_MSG_RESULT(yes)
4072 AC_DEFINE(X_LOCALE)], AC_MSG_RESULT(no)),
4073 AC_MSG_RESULT(no))
4074
4075 AC_MSG_CHECKING(whether Xutf8SetWMProperties() can be used)
4076 AC_TRY_LINK_FUNC([Xutf8SetWMProperties], [AC_MSG_RESULT(yes)
4077 AC_DEFINE(HAVE_XUTF8SETWMPROPERTIES)], AC_MSG_RESULT(no))
4078
Bram Moolenaar071d4272004-06-13 20:20:40 +00004079 CFLAGS=$cflags_save
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004080 LIBS=$libs_save
Bram Moolenaar071d4272004-06-13 20:20:40 +00004081fi
4082
4083dnl Link with xpg4, it is said to make Korean locale working
4084AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,)
4085
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004086dnl Check how we can run ctags. Default to "ctags" when nothing works.
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02004087dnl Use --version to detect Exuberant ctags (preferred)
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004088dnl Add --fields=+S to get function signatures for omni completion.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004089dnl -t for typedefs (many ctags have this)
4090dnl -s for static functions (Elvis ctags only?)
4091dnl -v for variables. Dangerous, most ctags take this for 'vgrind style'.
4092dnl -i+m to test for older Exuberant ctags
4093AC_MSG_CHECKING(how to create tags)
4094test -f tags && mv tags tags.save
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004095if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004096 TAGPRG="ctags -I INIT+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004097elif (eval exctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
4098 TAGPRG="exctags -I INIT+ --fields=+S"
4099elif (eval exuberant-ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
4100 TAGPRG="exuberant-ctags -I INIT+ --fields=+S"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004101else
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004102 TAGPRG="ctags"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004103 (eval etags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags"
4104 (eval etags -c /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags -c"
4105 (eval ctags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags"
4106 (eval ctags -t /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -t"
4107 (eval ctags -ts /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -ts"
4108 (eval ctags -tvs /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -tvs"
4109 (eval ctags -i+m /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -i+m"
4110fi
4111test -f tags.save && mv tags.save tags
4112AC_MSG_RESULT($TAGPRG) AC_SUBST(TAGPRG)
4113
4114dnl Check how we can run man with a section number
4115AC_MSG_CHECKING(how to run man with a section nr)
4116MANDEF="man"
Bram Moolenaar8b131502008-02-13 09:28:19 +00004117(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 +00004118AC_MSG_RESULT($MANDEF)
4119if test "$MANDEF" = "man -s"; then
4120 AC_DEFINE(USEMAN_S)
4121fi
4122
4123dnl Check if gettext() is working and if it needs -lintl
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004124dnl We take care to base this on an empty LIBS: on some systems libelf would be
4125dnl in LIBS and implicitly take along libintl. The final LIBS would then not
4126dnl contain libintl, and the link step would fail due to -Wl,--as-needed.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004127AC_MSG_CHECKING(--disable-nls argument)
4128AC_ARG_ENABLE(nls,
4129 [ --disable-nls Don't support NLS (gettext()).], ,
4130 [enable_nls="yes"])
4131
4132if test "$enable_nls" = "yes"; then
4133 AC_MSG_RESULT(no)
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00004134
4135 INSTALL_LANGS=install-languages
4136 AC_SUBST(INSTALL_LANGS)
4137 INSTALL_TOOL_LANGS=install-tool-languages
4138 AC_SUBST(INSTALL_TOOL_LANGS)
4139
Bram Moolenaar071d4272004-06-13 20:20:40 +00004140 AC_CHECK_PROG(MSGFMT, msgfmt, msgfmt, )
4141 AC_MSG_CHECKING([for NLS])
4142 if test -f po/Makefile; then
4143 have_gettext="no"
4144 if test -n "$MSGFMT"; then
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004145 olibs=$LIBS
4146 LIBS=""
Bram Moolenaar071d4272004-06-13 20:20:40 +00004147 AC_TRY_LINK(
4148 [#include <libintl.h>],
4149 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004150 AC_MSG_RESULT([gettext() works]); have_gettext="yes"; LIBS=$olibs,
4151 LIBS="-lintl"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004152 AC_TRY_LINK(
4153 [#include <libintl.h>],
4154 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004155 AC_MSG_RESULT([gettext() works with -lintl]); have_gettext="yes";
4156 LIBS="$olibs -lintl",
Bram Moolenaar071d4272004-06-13 20:20:40 +00004157 AC_MSG_RESULT([gettext() doesn't work]);
4158 LIBS=$olibs))
4159 else
4160 AC_MSG_RESULT([msgfmt not found - disabled]);
4161 fi
Bram Moolenaar278eb582014-07-30 13:22:52 +02004162 if test $have_gettext = "yes" -a "x$features" != "xtiny" -a "x$features" != "xsmall"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004163 AC_DEFINE(HAVE_GETTEXT)
4164 MAKEMO=yes
4165 AC_SUBST(MAKEMO)
4166 dnl this was added in GNU gettext 0.10.36
4167 AC_CHECK_FUNCS(bind_textdomain_codeset)
4168 dnl _nl_msg_cat_cntr is required for GNU gettext
4169 AC_MSG_CHECKING([for _nl_msg_cat_cntr])
4170 AC_TRY_LINK(
4171 [#include <libintl.h>
4172 extern int _nl_msg_cat_cntr;],
4173 [++_nl_msg_cat_cntr;],
4174 AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_NL_MSG_CAT_CNTR),
4175 AC_MSG_RESULT([no]))
4176 fi
4177 else
4178 AC_MSG_RESULT([no "po/Makefile" - disabled]);
4179 fi
4180else
4181 AC_MSG_RESULT(yes)
4182fi
4183
4184dnl Check for dynamic linking loader
4185AC_CHECK_HEADER(dlfcn.h, DLL=dlfcn.h, [AC_CHECK_HEADER(dl.h, DLL=dl.h)])
4186if test x${DLL} = xdlfcn.h; then
4187 AC_DEFINE(HAVE_DLFCN_H, 1, [ Define if we have dlfcn.h. ])
4188 AC_MSG_CHECKING([for dlopen()])
4189 AC_TRY_LINK(,[
4190 extern void* dlopen();
4191 dlopen();
4192 ],
4193 AC_MSG_RESULT(yes);
4194 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4195 AC_MSG_RESULT(no);
4196 AC_MSG_CHECKING([for dlopen() in -ldl])
4197 olibs=$LIBS
4198 LIBS="$LIBS -ldl"
4199 AC_TRY_LINK(,[
4200 extern void* dlopen();
4201 dlopen();
4202 ],
4203 AC_MSG_RESULT(yes);
4204 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4205 AC_MSG_RESULT(no);
4206 LIBS=$olibs))
4207 dnl ReliantUNIX has dlopen() in libc but everything else in libdl
4208 dnl ick :-)
4209 AC_MSG_CHECKING([for dlsym()])
4210 AC_TRY_LINK(,[
4211 extern void* dlsym();
4212 dlsym();
4213 ],
4214 AC_MSG_RESULT(yes);
4215 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4216 AC_MSG_RESULT(no);
4217 AC_MSG_CHECKING([for dlsym() in -ldl])
4218 olibs=$LIBS
4219 LIBS="$LIBS -ldl"
4220 AC_TRY_LINK(,[
4221 extern void* dlsym();
4222 dlsym();
4223 ],
4224 AC_MSG_RESULT(yes);
4225 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4226 AC_MSG_RESULT(no);
4227 LIBS=$olibs))
4228elif test x${DLL} = xdl.h; then
4229 AC_DEFINE(HAVE_DL_H, 1, [ Define if we have dl.h. ])
4230 AC_MSG_CHECKING([for shl_load()])
4231 AC_TRY_LINK(,[
4232 extern void* shl_load();
4233 shl_load();
4234 ],
4235 AC_MSG_RESULT(yes);
4236 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4237 AC_MSG_RESULT(no);
4238 AC_MSG_CHECKING([for shl_load() in -ldld])
4239 olibs=$LIBS
4240 LIBS="$LIBS -ldld"
4241 AC_TRY_LINK(,[
4242 extern void* shl_load();
4243 shl_load();
4244 ],
4245 AC_MSG_RESULT(yes);
4246 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4247 AC_MSG_RESULT(no);
4248 LIBS=$olibs))
4249fi
4250AC_CHECK_HEADERS(setjmp.h)
4251
4252if test "x$MACOSX" = "xyes" -a -n "$PERL"; then
4253 dnl -ldl must come after DynaLoader.a
4254 if echo $LIBS | grep -e '-ldl' >/dev/null; then
4255 LIBS=`echo $LIBS | sed s/-ldl//`
4256 PERL_LIBS="$PERL_LIBS -ldl"
4257 fi
4258fi
4259
Bram Moolenaar164fca32010-07-14 13:58:07 +02004260if test "x$MACOSX" = "xyes"; then
4261 AC_MSG_CHECKING(whether we need -framework Cocoa)
4262 dnl Cocoa is needed with FEAT_CLIPBOARD or FEAT_MBYTE (the former is
4263 dnl disabled during tiny build)
4264 if test "x$features" != "xtiny" || test "x$enable_multibyte" = "xyes"; then
4265 LIBS=$"$LIBS -framework Cocoa"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004266 AC_MSG_RESULT(yes)
4267 else
4268 AC_MSG_RESULT(no)
4269 fi
Bram Moolenaar3437b912013-07-03 19:52:53 +02004270 dnl As mentioned above, tiny build implies os_macosx.m isn't needed.
4271 dnl Exclude it from OS_EXTRA_SRC so that linker won't complain about
4272 dnl missing Objective-C symbols.
4273 if test "x$features" = "xtiny"; then
4274 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_macosx.m++'`
4275 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_macosx.o++'`
4276 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004277fi
Bram Moolenaar164fca32010-07-14 13:58:07 +02004278if test "x$MACARCH" = "xboth" && test "x$GUITYPE" = "xCARBONGUI"; then
Bram Moolenaar595a7be2010-03-10 16:28:12 +01004279 LDFLAGS="$LDFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +00004280fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004281
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004282dnl gcc 3.1 changed the meaning of -MM. The only solution appears to be to
4283dnl use "-isystem" instead of "-I" for all non-Vim include dirs.
4284dnl But only when making dependencies, cproto and lint don't take "-isystem".
Bram Moolenaar32466aa2006-02-24 23:53:04 +00004285dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
4286dnl the number before the version number.
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004287DEPEND_CFLAGS_FILTER=
4288if test "$GCC" = yes; then
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004289 AC_MSG_CHECKING(for GCC 3 or later)
Bram Moolenaar2217cae2006-03-25 21:55:52 +00004290 gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]]\)\..*$/\1/g'`
Bram Moolenaarf740b292006-02-16 22:11:02 +00004291 if test "$gccmajor" -gt "2"; then
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004292 DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004293 AC_MSG_RESULT(yes)
4294 else
4295 AC_MSG_RESULT(no)
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004296 fi
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004297 dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
4298 dnl declared as char x[1] but actually longer. Introduced in gcc 4.0.
Bram Moolenaar56d1db32009-12-16 16:14:51 +00004299 dnl Also remove duplicate _FORTIFY_SOURCE arguments.
Bram Moolenaaraeabe052011-12-08 15:17:34 +01004300 dnl And undefine it first to avoid a warning.
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004301 AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
4302 if test "$gccmajor" -gt "3"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02004303 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 +00004304 AC_MSG_RESULT(yes)
4305 else
4306 AC_MSG_RESULT(no)
4307 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +00004308fi
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004309AC_SUBST(DEPEND_CFLAGS_FILTER)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004310
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004311dnl link.sh tries to avoid overlinking in a hackish way.
4312dnl At least GNU ld supports --as-needed which provides the same functionality
4313dnl at linker level. Let's use it.
4314AC_MSG_CHECKING(linker --as-needed support)
4315LINK_AS_NEEDED=
4316# Check if linker supports --as-needed and --no-as-needed options
4317if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02004318 LDFLAGS=`echo "$LDFLAGS" | sed -e 's/ *-Wl,--as-needed//g' | sed -e 's/$/ -Wl,--as-needed/'`
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004319 LINK_AS_NEEDED=yes
4320fi
4321if test "$LINK_AS_NEEDED" = yes; then
4322 AC_MSG_RESULT(yes)
4323else
4324 AC_MSG_RESULT(no)
4325fi
4326AC_SUBST(LINK_AS_NEEDED)
4327
Bram Moolenaar77c19352012-06-13 19:19:41 +02004328# IBM z/OS reset CFLAGS for config.mk
4329if test "$zOSUnix" = "yes"; then
4330 CFLAGS="-D_ALL_SOURCE -Wc,float\(ieee\),dll"
4331fi
4332
Bram Moolenaar071d4272004-06-13 20:20:40 +00004333dnl write output files
4334AC_OUTPUT(auto/config.mk:config.mk.in)
4335
4336dnl vim: set sw=2 tw=78 fo+=l: