blob: e17a74c9a76e5fe69e071267769903ec6c080c64 [file] [log] [blame]
Bram Moolenaar3f7d0902016-11-12 21:13:42 +01001dnl configure.ac: autoconf script for Vim
Bram Moolenaar071d4272004-06-13 20:20:40 +00002
3dnl Process this file with autoconf 2.12 or 2.13 to produce "configure".
4dnl Should also work with autoconf 2.54 and later.
5
6AC_INIT(vim.h)
7AC_CONFIG_HEADER(auto/config.h:config.h.in)
8
9dnl Being able to run configure means the system is Unix (compatible).
10AC_DEFINE(UNIX)
11AC_PROG_MAKE_SET
12
13dnl Checks for programs.
Bram Moolenaar22640082018-04-19 20:39:41 +020014AC_PROG_CC_C99 dnl required by almost everything
Bram Moolenaarc0394412017-04-20 20:20:23 +020015AC_PROG_CPP dnl required by header file checks
16AC_PROGRAM_EGREP dnl required by AC_EGREP_CPP
17AC_PROG_FGREP dnl finds working grep -F
18AC_ISC_POSIX dnl required by AC_C_CROSS
19AC_PROG_AWK dnl required for "make html" in ../doc
Bram Moolenaar071d4272004-06-13 20:20:40 +000020
21dnl Don't strip if we don't have it
22AC_CHECK_PROG(STRIP, strip, strip, :)
23
Bram Moolenaar325b7a22004-07-05 15:58:32 +000024dnl Check for extension of executables
Bram Moolenaar071d4272004-06-13 20:20:40 +000025AC_EXEEXT
26
Bram Moolenaar446cb832008-06-24 21:56:24 +000027dnl Check for standard headers. We don't use this in Vim but other stuff
28dnl in autoconf needs it, where it uses STDC_HEADERS.
29AC_HEADER_STDC
30AC_HEADER_SYS_WAIT
31
Bram Moolenaar561f8a52018-04-17 22:02:45 +020032dnl Check that the C99 features that Vim uses are supported:
Bram Moolenaar22640082018-04-19 20:39:41 +020033if test x"$ac_cv_prog_cc_c99" != xno; then
34 dnl If the compiler doesn't explicitly support C99, then check
35 dnl for the specific features Vim uses
36
37 AC_TYPE_LONG_LONG_INT
38 if test "$ac_cv_type_long_long_int" = no; then
39 AC_MSG_FAILURE([Compiler does not support long long int])
40 fi
41
42 AC_MSG_CHECKING([if the compiler supports trailing commas])
43 trailing_commas=no
44 AC_TRY_COMPILE([], [
45 enum {
46 one,
47 };],
48 [AC_MSG_RESULT(yes); trailing_commas=yes],
49 [AC_MSG_RESULT(no)])
50 if test "$trailing_commas" = no; then
51 AC_MSG_FAILURE([Compiler does not support trailing comma in enum])
52 fi
53
54 AC_MSG_CHECKING([if the compiler supports C++ comments])
55 slash_comments=no
56 AC_TRY_COMPILE([],
57 [// C++ comments?],
58 [AC_MSG_RESULT(yes); slash_comments=yes],
59 [AC_MSG_RESULT(no)])
60 if test "$slash_comments" = no; then
61 AC_MSG_FAILURE([Compiler does not support C++ comments])
62 fi
63fi
Bram Moolenaar561f8a52018-04-17 22:02:45 +020064
Bram Moolenaar8f1dde52020-06-05 23:16:29 +020065dnl If $SOURCE_DATE_EPOCH is present in the environment, use that as the
66dnl "compiled" timestamp in :version's output. Attempt to get the formatted
67dnl date using GNU date syntax, BSD date syntax, and finally falling back to
68dnl just using the current time.
69if test -n "$SOURCE_DATE_EPOCH"; then
70 DATE_FMT="%b %d %Y %H:%M:%S"
71 BUILD_DATE=$(LC_ALL=C date -u -d "@$SOURCE_DATE_EPOCH" "+$DATE_FMT" 2>/dev/null || LC_ALL=C date -u -r "$SOURCE_DATE_EPOCH" "+$DATE_FMT" 2>/dev/null || LC_ALL=C date -u "+$DATE_FMT")
72 AC_DEFINE_UNQUOTED(BUILD_DATE, ["$BUILD_DATE"])
73 BUILD_DATE_MSG=-"echo -e '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\nNOTE: build date/time is fixed: $BUILD_DATE\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='"
74 AC_SUBST(BUILD_DATE_MSG)
75fi
76
Bram Moolenaarf788a062011-12-14 20:51:25 +010077dnl Check for the flag that fails if stuff are missing.
78
79AC_MSG_CHECKING(--enable-fail-if-missing argument)
80AC_ARG_ENABLE(fail_if_missing,
81 [ --enable-fail-if-missing Fail if dependencies on additional features
82 specified on the command line are missing.],
83 [fail_if_missing="yes"],
84 [fail_if_missing="no"])
85AC_MSG_RESULT($fail_if_missing)
86
Bram Moolenaard2a05492018-07-27 22:35:15 +020087dnl Keep original value to check later.
88with_x_arg="$with_x"
89
Bram Moolenaar071d4272004-06-13 20:20:40 +000090dnl Set default value for CFLAGS if none is defined or it's empty
91if test -z "$CFLAGS"; then
92 CFLAGS="-O"
93 test "$GCC" = yes && CFLAGS="-O2 -fno-strength-reduce -Wall"
94fi
95if test "$GCC" = yes; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +000096 dnl method that should work for nearly all versions
Bram Moolenaarc8836f72014-04-12 13:12:24 +020097 gccversion=`$CC -dumpversion`
Bram Moolenaar910f66f2006-04-05 20:41:53 +000098 if test "x$gccversion" = "x"; then
99 dnl old method; fall-back for when -dumpversion doesn't work
Bram Moolenaarc8836f72014-04-12 13:12:24 +0200100 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 +0000101 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +0000102 dnl version 4.0.1 was reported to cause trouble on Macintosh by Marcin Dalecki
103 if test "$gccversion" = "3.0.1" -o "$gccversion" = "3.0.2" -o "$gccversion" = "4.0.1"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000104 echo 'GCC [[34]].0.[[12]] has a bug in the optimizer, disabling "-O#"'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000105 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-O/'`
106 else
107 if test "$gccversion" = "3.1" -o "$gccversion" = "3.2" -o "$gccversion" = "3.2.1" && `echo "$CFLAGS" | grep -v fno-strength-reduce >/dev/null`; then
108 echo 'GCC 3.1 and 3.2 have a bug in the optimizer, adding "-fno-strength-reduce"'
109 CFLAGS="$CFLAGS -fno-strength-reduce"
110 fi
111 fi
112fi
113
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200114dnl clang-500.2.75 or around has abandoned -f[no-]strength-reduce and issues a
115dnl warning when that flag is passed to. Accordingly, adjust CFLAGS based on
116dnl the version number of the clang in use.
117dnl Note that this does not work to get the version of clang 3.1 or 3.2.
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100118AC_MSG_CHECKING(for clang version)
119CLANG_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 +0200120if test x"$CLANG_VERSION_STRING" != x"" ; then
121 CLANG_MAJOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*/\1/p'`
122 CLANG_MINOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/p'`
123 CLANG_REVISION=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)/\1/p'`
124 CLANG_VERSION=`expr $CLANG_MAJOR '*' 1000000 '+' $CLANG_MINOR '*' 1000 '+' $CLANG_REVISION`
125 AC_MSG_RESULT($CLANG_VERSION)
126 dnl If you find the same issue with versions earlier than 500.2.75,
127 dnl change the constant 500002075 below appropriately. To get the
128 dnl integer corresponding to a version number, refer to the
129 dnl definition of CLANG_VERSION above.
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100130 AC_MSG_CHECKING(if clang supports -fno-strength-reduce)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200131 if test "$CLANG_VERSION" -ge 500002075 ; then
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100132 AC_MSG_RESULT(no)
133 CFLAGS=`echo "$CFLAGS" | sed -e 's/-fno-strength-reduce/ /'`
134 else
135 AC_MSG_RESULT(yes)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200136 fi
137else
Bram Moolenaar5f69fee2017-03-09 11:58:40 +0100138 AC_MSG_RESULT(N/A)
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +0200139fi
140
Bram Moolenaar446cb832008-06-24 21:56:24 +0000141dnl If configure thinks we are cross compiling, there might be something
142dnl wrong with the CC or CFLAGS settings, give a useful warning message
Bram Moolenaar839e9542016-04-14 16:46:02 +0200143CROSS_COMPILING=
Bram Moolenaar071d4272004-06-13 20:20:40 +0000144if test "$cross_compiling" = yes; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000145 AC_MSG_RESULT([cannot compile a simple program; if not cross compiling check CC and CFLAGS])
Bram Moolenaar839e9542016-04-14 16:46:02 +0200146 CROSS_COMPILING=1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000147fi
Bram Moolenaar839e9542016-04-14 16:46:02 +0200148AC_SUBST(CROSS_COMPILING)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000149
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +0000150dnl gcc-cpp has the wonderful -MM option to produce nicer dependencies.
151dnl But gcc 3.1 changed the meaning! See near the end.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000152test "$GCC" = yes && CPP_MM=M; AC_SUBST(CPP_MM)
153
154if test -f ./toolcheck; then
155 AC_CHECKING(for buggy tools)
156 sh ./toolcheck 1>&AC_FD_MSG
157fi
158
159OS_EXTRA_SRC=""; OS_EXTRA_OBJ=""
160
Bram Moolenaarb3f74062020-02-26 16:16:53 +0100161AC_MSG_CHECKING(for Haiku)
162case `uname` in
163 Haiku) HAIKU=yes; AC_MSG_RESULT(yes);;
164 *) HAIKU=no; AC_MSG_RESULT(no);;
165esac
166
Bram Moolenaar071d4272004-06-13 20:20:40 +0000167dnl If QNX is found, assume we don't want to use Xphoton
168dnl unless it was specifically asked for (--with-x)
169AC_MSG_CHECKING(for QNX)
170case `uname` in
171 QNX) OS_EXTRA_SRC=os_qnx.c; OS_EXTRA_OBJ=objects/os_qnx.o
172 test -z "$with_x" && with_x=no
173 QNX=yes; AC_MSG_RESULT(yes);;
174 *) QNX=no; AC_MSG_RESULT(no);;
175esac
176
177dnl Check for Darwin and MacOS X
178dnl We do a check for MacOS X in the very beginning because there
179dnl are a lot of other things we need to change besides GUI stuff
Bram Moolenaar071d4272004-06-13 20:20:40 +0000180AC_MSG_CHECKING([for Darwin (Mac OS X)])
181if test "`(uname) 2>/dev/null`" = Darwin; then
182 AC_MSG_RESULT(yes)
Bram Moolenaard0573012017-10-28 21:11:06 +0200183 MACOS_X=yes
Bram Moolenaar52ecaaa2018-05-12 21:38:13 +0200184 CPPFLAGS="$CPPFLAGS -DMACOS_X"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000185
186 AC_MSG_CHECKING(--disable-darwin argument)
187 AC_ARG_ENABLE(darwin,
188 [ --disable-darwin Disable Darwin (Mac OS X) support.],
189 , [enable_darwin="yes"])
190 if test "$enable_darwin" = "yes"; then
191 AC_MSG_RESULT(no)
192 AC_MSG_CHECKING(if Darwin files are there)
Bram Moolenaar164fca32010-07-14 13:58:07 +0200193 if test -f os_macosx.m; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000194 AC_MSG_RESULT(yes)
195 else
196 AC_MSG_RESULT([no, Darwin support disabled])
197 enable_darwin=no
198 fi
199 else
200 AC_MSG_RESULT([yes, Darwin support excluded])
201 fi
202
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000203 AC_MSG_CHECKING(--with-mac-arch argument)
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000204 AC_ARG_WITH(mac-arch, [ --with-mac-arch=ARCH current, intel, ppc or both],
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000205 MACARCH="$withval"; AC_MSG_RESULT($MACARCH),
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000206 MACARCH="current"; AC_MSG_RESULT(defaulting to $MACARCH))
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000207
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100208 AC_MSG_CHECKING(--with-developer-dir argument)
209 AC_ARG_WITH(developer-dir, [ --with-developer-dir=PATH use PATH as location for Xcode developer tools],
210 DEVELOPER_DIR="$withval"; AC_MSG_RESULT($DEVELOPER_DIR),
Bram Moolenaar32d03b32015-11-19 13:46:48 +0100211 AC_MSG_RESULT(not present))
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100212
213 if test "x$DEVELOPER_DIR" = "x"; then
214 AC_PATH_PROG(XCODE_SELECT, xcode-select)
215 if test "x$XCODE_SELECT" != "x"; then
216 AC_MSG_CHECKING(for developer dir using xcode-select)
217 DEVELOPER_DIR=`$XCODE_SELECT -print-path`
218 AC_MSG_RESULT([$DEVELOPER_DIR])
219 else
220 DEVELOPER_DIR=/Developer
221 fi
222 fi
223
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000224 if test "x$MACARCH" = "xboth"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000225 AC_MSG_CHECKING(for 10.4 universal SDK)
226 dnl There is a terrible inconsistency (but we appear to get away with it):
227 dnl $CFLAGS uses the 10.4u SDK library for the headers, while $CPPFLAGS
228 dnl doesn't, because "gcc -E" doesn't grok it. That means the configure
229 dnl tests using the preprocessor are actually done with the wrong header
230 dnl files. $LDFLAGS is set at the end, because configure uses it together
231 dnl with $CFLAGS and we can only have one -sysroot argument.
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000232 save_cppflags="$CPPFLAGS"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000233 save_cflags="$CFLAGS"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000234 save_ldflags="$LDFLAGS"
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100235 CFLAGS="$CFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000236 AC_TRY_LINK([ ], [ ],
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000237 AC_MSG_RESULT(found, will make universal binary),
238
239 AC_MSG_RESULT(not found)
Bram Moolenaar1f35bf92006-03-07 22:38:47 +0000240 CFLAGS="$save_cflags"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000241 AC_MSG_CHECKING(if Intel architecture is supported)
242 CPPFLAGS="$CPPFLAGS -arch i386"
243 LDFLAGS="$save_ldflags -arch i386"
244 AC_TRY_LINK([ ], [ ],
245 AC_MSG_RESULT(yes); MACARCH="intel",
246 AC_MSG_RESULT(no, using PowerPC)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000247 MACARCH="ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000248 CPPFLAGS="$save_cppflags -arch ppc"
249 LDFLAGS="$save_ldflags -arch ppc"))
250 elif test "x$MACARCH" = "xintel"; then
251 CPPFLAGS="$CPPFLAGS -arch intel"
252 LDFLAGS="$LDFLAGS -arch intel"
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000253 elif test "x$MACARCH" = "xppc"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000254 CPPFLAGS="$CPPFLAGS -arch ppc"
255 LDFLAGS="$LDFLAGS -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000256 fi
257
Bram Moolenaar071d4272004-06-13 20:20:40 +0000258 if test "$enable_darwin" = "yes"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200259 MACOS_X_DARWIN=yes
Bram Moolenaar164fca32010-07-14 13:58:07 +0200260 OS_EXTRA_SRC="os_macosx.m os_mac_conv.c";
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000261 OS_EXTRA_OBJ="objects/os_macosx.o objects/os_mac_conv.o"
Bram Moolenaar32466aa2006-02-24 23:53:04 +0000262 dnl TODO: use -arch i386 on Intel machines
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100263 dnl Removed -no-cpp-precomp, only for very old compilers.
Bram Moolenaard0573012017-10-28 21:11:06 +0200264 CPPFLAGS="$CPPFLAGS -DMACOS_X_DARWIN"
Bram Moolenaar040f9752020-08-11 23:08:48 +0200265
266 dnl Assume we don't want X11 unless it was specifically asked for
267 dnl (--with-x) or Motif, Athena or GTK GUI is used.
268 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
269 with_x=no
270 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000271 fi
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000272
Bram Moolenaardb552d602006-03-23 22:59:57 +0000273 dnl Avoid a bug with -O2 with gcc 4.0.1. Symptom: malloc() reports double
Bram Moolenaarfd2ac762006-03-01 22:09:21 +0000274 dnl free. This happens in expand_filename(), because the optimizer swaps
Bram Moolenaardb552d602006-03-23 22:59:57 +0000275 dnl two blocks of code, both using "repl", that can't be swapped.
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000276 if test "$MACARCH" = "intel" -o "$MACARCH" = "both"; then
277 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-Oz/'`
278 fi
279
Bram Moolenaar071d4272004-06-13 20:20:40 +0000280else
281 AC_MSG_RESULT(no)
282fi
283
Bram Moolenaar39766a72013-11-03 00:41:00 +0100284dnl Mac OS X 10.9+ no longer include AvailabilityMacros.h in Carbon
285dnl so we need to include it to have access to version macros.
Bram Moolenaar18e54692013-11-03 20:26:31 +0100286AC_CHECK_HEADERS(AvailabilityMacros.h)
Bram Moolenaar39766a72013-11-03 00:41:00 +0100287
Bram Moolenaar071d4272004-06-13 20:20:40 +0000288AC_SUBST(OS_EXTRA_SRC)
289AC_SUBST(OS_EXTRA_OBJ)
290
291dnl Add /usr/local/lib to $LDFLAGS and /usr/local/include to CFLAGS.
292dnl Only when the directory exists and it wasn't there yet.
293dnl For gcc don't do this when it is already in the default search path.
Bram Moolenaar446cb832008-06-24 21:56:24 +0000294dnl Skip all of this when cross-compiling.
295if test "$cross_compiling" = no; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000296 AC_MSG_CHECKING(--with-local-dir argument)
Bram Moolenaar446cb832008-06-24 21:56:24 +0000297 have_local_include=''
298 have_local_lib=''
Bram Moolenaarc236c162008-07-13 17:41:49 +0000299 AC_ARG_WITH([local-dir], [ --with-local-dir=PATH search PATH instead of /usr/local for local libraries.
300 --without-local-dir do not search /usr/local for local libraries.], [
301 local_dir="$withval"
302 case "$withval" in
303 */*) ;;
304 no)
305 # avoid adding local dir to LDFLAGS and CPPFLAGS
Bram Moolenaare06c1882010-07-21 22:05:20 +0200306 have_local_include=yes
Bram Moolenaarc236c162008-07-13 17:41:49 +0000307 have_local_lib=yes
308 ;;
309 *) AC_MSG_ERROR(must pass path argument to --with-local-dir) ;;
310 esac
311 AC_MSG_RESULT($local_dir)
312 ], [
313 local_dir=/usr/local
314 AC_MSG_RESULT(Defaulting to $local_dir)
315 ])
316 if test "$GCC" = yes -a "$local_dir" != no; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000317 echo 'void f(){}' > conftest.c
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100318 dnl Removed -no-cpp-precomp, only needed for OS X 10.2 (Ben Fowler)
319 have_local_include=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/include"`
Bram Moolenaarc236c162008-07-13 17:41:49 +0000320 have_local_lib=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/lib"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000321 rm -f conftest.c conftest.o
Bram Moolenaar071d4272004-06-13 20:20:40 +0000322 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000323 if test -z "$have_local_lib" -a -d "${local_dir}/lib"; then
324 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 +0000325 if test "$tt" = "$LDFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000326 LDFLAGS="$LDFLAGS -L${local_dir}/lib"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000327 fi
328 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000329 if test -z "$have_local_include" -a -d "${local_dir}/include"; then
330 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 +0000331 if test "$tt" = "$CPPFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000332 CPPFLAGS="$CPPFLAGS -I${local_dir}/include"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000333 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000334 fi
335fi
336
337AC_MSG_CHECKING(--with-vim-name argument)
338AC_ARG_WITH(vim-name, [ --with-vim-name=NAME what to call the Vim executable],
339 VIMNAME="$withval"; AC_MSG_RESULT($VIMNAME),
Bram Moolenaare344bea2005-09-01 20:46:49 +0000340 VIMNAME="vim"; AC_MSG_RESULT(Defaulting to $VIMNAME))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000341AC_SUBST(VIMNAME)
342AC_MSG_CHECKING(--with-ex-name argument)
343AC_ARG_WITH(ex-name, [ --with-ex-name=NAME what to call the Ex executable],
344 EXNAME="$withval"; AC_MSG_RESULT($EXNAME),
345 EXNAME="ex"; AC_MSG_RESULT(Defaulting to ex))
346AC_SUBST(EXNAME)
347AC_MSG_CHECKING(--with-view-name argument)
348AC_ARG_WITH(view-name, [ --with-view-name=NAME what to call the View executable],
349 VIEWNAME="$withval"; AC_MSG_RESULT($VIEWNAME),
350 VIEWNAME="view"; AC_MSG_RESULT(Defaulting to view))
351AC_SUBST(VIEWNAME)
352
353AC_MSG_CHECKING(--with-global-runtime argument)
Bram Moolenaar9d302ad2018-12-21 11:48:51 +0100354AC_ARG_WITH(global-runtime, [ --with-global-runtime=DIR global runtime directory in 'runtimepath', comma-separated for multiple directories],
355 RUNTIME_GLOBAL="$withval"; AC_MSG_RESULT($withval),
Bram Moolenaar071d4272004-06-13 20:20:40 +0000356 AC_MSG_RESULT(no))
357
Bram Moolenaar9d302ad2018-12-21 11:48:51 +0100358if test "X$RUNTIME_GLOBAL" != "X"; then
359 RUNTIME_GLOBAL_AFTER=$(printf -- "$RUNTIME_GLOBAL\\n" | $AWK -F, 'BEGIN { comma=0 } { for (i = NF; i > 0; i--) { if (comma) { printf ",%s/after", $i } else { printf "%s/after", $i; comma=1 } } } END { printf "\n" }')
360 AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL, "$RUNTIME_GLOBAL")
361 AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL_AFTER, "$RUNTIME_GLOBAL_AFTER")
362fi
363
Bram Moolenaar071d4272004-06-13 20:20:40 +0000364AC_MSG_CHECKING(--with-modified-by argument)
365AC_ARG_WITH(modified-by, [ --with-modified-by=NAME name of who modified a release version],
366 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(MODIFIED_BY, "$withval"),
367 AC_MSG_RESULT(no))
368
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200369dnl Check for EBCDIC stolen from the LYNX port to z/OS Unix
Bram Moolenaar071d4272004-06-13 20:20:40 +0000370AC_MSG_CHECKING(if character set is EBCDIC)
371AC_TRY_COMPILE([ ],
372[ /* TryCompile function for CharSet.
373 Treat any failure as ASCII for compatibility with existing art.
374 Use compile-time rather than run-time tests for cross-compiler
375 tolerance. */
376#if '0'!=240
377make an error "Character set is not EBCDIC"
378#endif ],
379[ # TryCompile action if true
380cf_cv_ebcdic=yes ],
381[ # TryCompile action if false
382cf_cv_ebcdic=no])
383# end of TryCompile ])
384# end of CacheVal CvEbcdic
385AC_MSG_RESULT($cf_cv_ebcdic)
386case "$cf_cv_ebcdic" in #(vi
387 yes) AC_DEFINE(EBCDIC)
388 line_break='"\\n"'
389 ;;
390 *) line_break='"\\012"';;
391esac
392AC_SUBST(line_break)
393
394if test "$cf_cv_ebcdic" = "yes"; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +0200395dnl If we have EBCDIC we most likely have z/OS Unix, let's test it!
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200396AC_MSG_CHECKING(for z/OS Unix)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000397case `uname` in
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200398 OS/390) zOSUnix="yes";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000399 dnl If using cc the environment variable _CC_CCMODE must be
400 dnl set to "1", so that some compiler extensions are enabled.
401 dnl If using c89 the environment variable is named _CC_C89MODE.
402 dnl Note: compile with c89 never tested.
403 if test "$CC" = "cc"; then
404 ccm="$_CC_CCMODE"
405 ccn="CC"
406 else
407 if test "$CC" = "c89"; then
408 ccm="$_CC_C89MODE"
409 ccn="C89"
410 else
411 ccm=1
412 fi
413 fi
414 if test "$ccm" != "1"; then
415 echo ""
416 echo "------------------------------------------"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200417 echo " On z/OS Unix, the environment variable"
Bram Moolenaar77c19352012-06-13 19:19:41 +0200418 echo " _CC_${ccn}MODE must be set to \"1\"!"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000419 echo " Do:"
420 echo " export _CC_${ccn}MODE=1"
421 echo " and then call configure again."
422 echo "------------------------------------------"
423 exit 1
424 fi
Bram Moolenaar77c19352012-06-13 19:19:41 +0200425 # Set CFLAGS for configure process.
426 # This will be reset later for config.mk.
427 # Use haltonmsg to force error for missing H files.
428 CFLAGS="$CFLAGS -D_ALL_SOURCE -Wc,float(ieee),haltonmsg(3296)";
429 LDFLAGS="$LDFLAGS -Wl,EDIT=NO"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000430 AC_MSG_RESULT(yes)
431 ;;
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200432 *) zOSUnix="no";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000433 AC_MSG_RESULT(no)
434 ;;
435esac
436fi
437
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200438dnl Set QUOTESED. Needs additional backslashes on zOS
439if test "$zOSUnix" = "yes"; then
440 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\\\\\&/g' -e 's/\\\\\\\\\"/\"/' -e 's/\\\\\\\\\";\$\$/\";/'"
441else
442 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\&/g' -e 's/\\\\\"/\"/' -e 's/\\\\\";\$\$/\";/'"
443fi
444AC_SUBST(QUOTESED)
445
446
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200447dnl Link with -lsmack for Smack stuff; if not found
448AC_MSG_CHECKING(--disable-smack argument)
449AC_ARG_ENABLE(smack,
450 [ --disable-smack Do not check for Smack support.],
451 , enable_smack="yes")
452if test "$enable_smack" = "yes"; then
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200453 AC_MSG_RESULT(no)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200454 AC_CHECK_HEADER([linux/xattr.h], true, enable_smack="no")
Bram Moolenaar4ed89cd2014-04-05 12:02:25 +0200455else
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200456 AC_MSG_RESULT(yes)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200457fi
458if test "$enable_smack" = "yes"; then
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200459 AC_CHECK_HEADER([attr/xattr.h], true, enable_smack="no")
460fi
461if test "$enable_smack" = "yes"; then
462 AC_MSG_CHECKING(for XATTR_NAME_SMACKEXEC in linux/xattr.h)
463 AC_EGREP_CPP(XATTR_NAME_SMACKEXEC, [#include <linux/xattr.h>],
464 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +0200465 AC_MSG_RESULT(no); enable_smack="no")
Bram Moolenaarc09551a2014-04-10 11:09:17 +0200466fi
467if test "$enable_smack" = "yes"; then
468 AC_CHECK_LIB(attr, setxattr,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200469 [LIBS="$LIBS -lattr"
470 found_smack="yes"
471 AC_DEFINE(HAVE_SMACK)])
Bram Moolenaar588ebeb2008-05-07 17:09:24 +0000472fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000473
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200474dnl When smack was found don't search for SELinux
475if test "x$found_smack" = "x"; then
476 dnl Link with -lselinux for SELinux stuff; if not found
477 AC_MSG_CHECKING(--disable-selinux argument)
478 AC_ARG_ENABLE(selinux,
479 [ --disable-selinux Do not check for SELinux support.],
480 , enable_selinux="yes")
481 if test "$enable_selinux" = "yes"; then
482 AC_MSG_RESULT(no)
483 AC_CHECK_LIB(selinux, is_selinux_enabled,
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100484 [AC_CHECK_HEADER(selinux/selinux.h,
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200485 [LIBS="$LIBS -lselinux"
Bram Moolenaare4b78e22017-12-07 22:29:11 +0100486 AC_DEFINE(HAVE_SELINUX)])])
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200487 else
488 AC_MSG_RESULT(yes)
489 fi
490fi
491
Bram Moolenaar071d4272004-06-13 20:20:40 +0000492dnl Check user requested features.
493
494AC_MSG_CHECKING(--with-features argument)
Bram Moolenaareec29812016-07-26 21:27:36 +0200495AC_ARG_WITH(features, [ --with-features=TYPE tiny, small, normal, big or huge (default: huge)],
Bram Moolenaar071d4272004-06-13 20:20:40 +0000496 features="$withval"; AC_MSG_RESULT($features),
Bram Moolenaar23c4f712016-01-20 22:11:59 +0100497 features="huge"; AC_MSG_RESULT(Defaulting to huge))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000498
499dovimdiff=""
500dogvimdiff=""
501case "$features" in
502 tiny) AC_DEFINE(FEAT_TINY) ;;
503 small) AC_DEFINE(FEAT_SMALL) ;;
504 normal) AC_DEFINE(FEAT_NORMAL) dovimdiff="installvimdiff";
505 dogvimdiff="installgvimdiff" ;;
506 big) AC_DEFINE(FEAT_BIG) dovimdiff="installvimdiff";
507 dogvimdiff="installgvimdiff" ;;
508 huge) AC_DEFINE(FEAT_HUGE) dovimdiff="installvimdiff";
509 dogvimdiff="installgvimdiff" ;;
510 *) AC_MSG_RESULT([Sorry, $features is not supported]) ;;
511esac
512
513AC_SUBST(dovimdiff)
514AC_SUBST(dogvimdiff)
515
516AC_MSG_CHECKING(--with-compiledby argument)
517AC_ARG_WITH(compiledby, [ --with-compiledby=NAME name to show in :version message],
518 compiledby="$withval"; AC_MSG_RESULT($withval),
519 compiledby=""; AC_MSG_RESULT(no))
520AC_SUBST(compiledby)
521
522AC_MSG_CHECKING(--disable-xsmp argument)
523AC_ARG_ENABLE(xsmp,
524 [ --disable-xsmp Disable XSMP session management],
525 , enable_xsmp="yes")
526
527if test "$enable_xsmp" = "yes"; then
528 AC_MSG_RESULT(no)
529 AC_MSG_CHECKING(--disable-xsmp-interact argument)
530 AC_ARG_ENABLE(xsmp-interact,
531 [ --disable-xsmp-interact Disable XSMP interaction],
532 , enable_xsmp_interact="yes")
533 if test "$enable_xsmp_interact" = "yes"; then
534 AC_MSG_RESULT(no)
535 AC_DEFINE(USE_XSMP_INTERACT)
536 else
537 AC_MSG_RESULT(yes)
538 fi
539else
540 AC_MSG_RESULT(yes)
541fi
542
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200543dnl Check for Lua feature.
544AC_MSG_CHECKING(--enable-luainterp argument)
545AC_ARG_ENABLE(luainterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200546 [ --enable-luainterp[=OPTS] Include Lua interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200547 [enable_luainterp="no"])
548AC_MSG_RESULT($enable_luainterp)
549
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200550if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +0100551 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
552 AC_MSG_ERROR([cannot use Lua with tiny or small features])
553 fi
554
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200555 dnl -- find the lua executable
556 AC_SUBST(vi_cv_path_lua)
557
558 AC_MSG_CHECKING(--with-lua-prefix argument)
559 AC_ARG_WITH(lua_prefix,
560 [ --with-lua-prefix=PFX Prefix where Lua is installed.],
561 with_lua_prefix="$withval"; AC_MSG_RESULT($with_lua_prefix),
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200562 with_lua_prefix="";AC_MSG_RESULT(no))
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200563
564 if test "X$with_lua_prefix" != "X"; then
565 vi_cv_path_lua_pfx="$with_lua_prefix"
566 else
567 AC_MSG_CHECKING(LUA_PREFIX environment var)
568 if test "X$LUA_PREFIX" != "X"; then
569 AC_MSG_RESULT("$LUA_PREFIX")
570 vi_cv_path_lua_pfx="$LUA_PREFIX"
571 else
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200572 AC_MSG_RESULT([not set, default to /usr])
573 vi_cv_path_lua_pfx="/usr"
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200574 fi
575 fi
576
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200577 AC_MSG_CHECKING(--with-luajit)
578 AC_ARG_WITH(luajit,
579 [ --with-luajit Link with LuaJIT instead of Lua.],
580 [vi_cv_with_luajit="$withval"],
581 [vi_cv_with_luajit="no"])
582 AC_MSG_RESULT($vi_cv_with_luajit)
583
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200584 LUA_INC=
585 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200586 if test "x$vi_cv_with_luajit" != "xno"; then
587 dnl -- try to find LuaJIT executable
588 AC_PATH_PROG(vi_cv_path_luajit, luajit)
589 if test "X$vi_cv_path_luajit" != "X"; then
590 dnl -- find LuaJIT version
591 AC_CACHE_CHECK(LuaJIT version, vi_cv_version_luajit,
Bram Moolenaar49b10272013-11-21 12:17:51 +0100592 [ 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 +0200593 AC_CACHE_CHECK(Lua version of LuaJIT, vi_cv_version_lua_luajit,
594 [ vi_cv_version_lua_luajit=`${vi_cv_path_luajit} -e "print(_VERSION)" | sed 's/.* //'` ])
595 vi_cv_path_lua="$vi_cv_path_luajit"
596 vi_cv_version_lua="$vi_cv_version_lua_luajit"
597 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200598 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200599 dnl -- try to find Lua executable
600 AC_PATH_PROG(vi_cv_path_plain_lua, lua)
601 if test "X$vi_cv_path_plain_lua" != "X"; then
602 dnl -- find Lua version
603 AC_CACHE_CHECK(Lua version, vi_cv_version_plain_lua,
604 [ vi_cv_version_plain_lua=`${vi_cv_path_plain_lua} -e "print(_VERSION)" | sed 's/.* //'` ])
605 fi
606 vi_cv_path_lua="$vi_cv_path_plain_lua"
607 vi_cv_version_lua="$vi_cv_version_plain_lua"
608 fi
609 if test "x$vi_cv_with_luajit" != "xno" && test "X$vi_cv_version_luajit" != "X"; then
610 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 +0100611 if test -f "$vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200612 AC_MSG_RESULT(yes)
613 LUA_INC=/luajit-$vi_cv_version_luajit
614 fi
615 fi
616 if test "X$LUA_INC" = "X"; then
617 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)
Bram Moolenaar49222be2015-12-11 18:11:30 +0100618 if test -f "$vi_cv_path_lua_pfx/include/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200619 AC_MSG_RESULT(yes)
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200620 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200621 AC_MSG_RESULT(no)
622 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 +0100623 if test -f "$vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200624 AC_MSG_RESULT(yes)
625 LUA_INC=/lua$vi_cv_version_lua
626 else
627 AC_MSG_RESULT(no)
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200628
629 # Detect moonjit:
630 # https://groups.google.com/forum/#!topic/vim_use/O0vek60WuTk
631 lua_suf=/moonjit-2.3
632 inc_path="$vi_cv_path_lua_pfx/include"
Bram Moolenaarad4dc832020-04-20 16:21:53 +0200633 for dir in "$inc_path"/moonjit-[[0-9]]* ; do
Bram Moolenaarf49e5642020-04-19 17:46:53 +0200634 if test -d "$dir" ; then
635 lua_suf=`basename '$dir'`
636 lua_suf="/$lua_suf"
637 break
638 fi
639 done
640 AC_MSG_CHECKING(if lua.h can be found in $inc_path$lua_suf)
641 if test -f "$inc_path$lua_suf/lua.h"; then
642 AC_MSG_RESULT(yes)
643 LUA_INC=$lua_suf
644 else
645 AC_MSG_RESULT(no)
646 vi_cv_path_lua_pfx=
647 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200648 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200649 fi
650 fi
651 fi
652
653 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200654 if test "x$vi_cv_with_luajit" != "xno"; then
655 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
656 if test "X$multiarch" != "X"; then
657 lib_multiarch="lib/${multiarch}"
658 else
659 lib_multiarch="lib"
660 fi
661 if test "X$vi_cv_version_lua" = "X"; then
662 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit"
663 else
664 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit-$vi_cv_version_lua"
665 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200666 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200667 if test "X$LUA_INC" != "X"; then
668 dnl Test alternate location using version
669 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua$vi_cv_version_lua"
670 else
671 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua"
672 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200673 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200674 if test "$enable_luainterp" = "dynamic"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200675 lua_ok="yes"
676 else
677 AC_MSG_CHECKING([if link with ${LUA_LIBS} is sane])
678 libs_save=$LIBS
679 LIBS="$LIBS $LUA_LIBS"
680 AC_TRY_LINK(,[ ],
681 AC_MSG_RESULT(yes); lua_ok="yes",
682 AC_MSG_RESULT(no); lua_ok="no"; LUA_LIBS="")
683 LIBS=$libs_save
684 fi
685 if test "x$lua_ok" = "xyes"; then
686 LUA_CFLAGS="-I${vi_cv_path_lua_pfx}/include${LUA_INC}"
687 LUA_SRC="if_lua.c"
688 LUA_OBJ="objects/if_lua.o"
689 LUA_PRO="if_lua.pro"
690 AC_DEFINE(FEAT_LUA)
691 fi
692 if test "$enable_luainterp" = "dynamic"; then
693 if test "x$vi_cv_with_luajit" != "xno"; then
694 luajit="jit"
695 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200696 if test -f "${vi_cv_path_lua_pfx}/bin/cyglua-${vi_cv_version_lua}.dll"; then
697 vi_cv_dll_name_lua="cyglua-${vi_cv_version_lua}.dll"
698 else
Bram Moolenaard0573012017-10-28 21:11:06 +0200699 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200700 ext="dylib"
701 indexes=""
702 else
703 ext="so"
704 indexes=".0 .1 .2 .3 .4 .5 .6 .7 .8 .9"
705 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
706 if test "X$multiarch" != "X"; then
707 lib_multiarch="lib/${multiarch}"
708 fi
Bram Moolenaar768baac2013-04-15 14:44:57 +0200709 fi
710 dnl Determine the sover for the current version, but fallback to
711 dnl liblua${vi_cv_version_lua}.so if no sover-versioned file is found.
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200712 AC_MSG_CHECKING(if liblua${luajit}*.${ext}* can be found in $vi_cv_path_lua_pfx)
Bram Moolenaar768baac2013-04-15 14:44:57 +0200713 for subdir in "${lib_multiarch}" lib64 lib; do
714 if test -z "$subdir"; then
715 continue
716 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200717 for sover in "${vi_cv_version_lua}.${ext}" "-${vi_cv_version_lua}.${ext}" \
718 ".${vi_cv_version_lua}.${ext}" ".${ext}.${vi_cv_version_lua}"; do
719 for i in $indexes ""; do
720 if test -f "${vi_cv_path_lua_pfx}/${subdir}/liblua${luajit}${sover}$i"; then
Bram Moolenaar768baac2013-04-15 14:44:57 +0200721 sover2="$i"
722 break 3
723 fi
724 done
Bram Moolenaar07e1da62013-02-06 19:49:43 +0100725 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200726 sover=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200727 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200728 if test "X$sover" = "X"; then
729 AC_MSG_RESULT(no)
730 lua_ok="no"
731 vi_cv_dll_name_lua="liblua${luajit}.${ext}"
732 else
733 AC_MSG_RESULT(yes)
734 lua_ok="yes"
735 vi_cv_dll_name_lua="liblua${luajit}${sover}$sover2"
736 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200737 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200738 AC_DEFINE(DYNAMIC_LUA)
739 LUA_LIBS=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200740 LUA_CFLAGS="-DDYNAMIC_LUA_DLL=\\\"${vi_cv_dll_name_lua}\\\" $LUA_CFLAGS"
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200741 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200742 if test "X$LUA_CFLAGS$LUA_LIBS" != "X" && \
Bram Moolenaard0573012017-10-28 21:11:06 +0200743 test "x$MACOS_X" = "xyes" && test "x$vi_cv_with_luajit" != "xno" && \
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200744 test "`(uname -m) 2>/dev/null`" = "x86_64"; then
745 dnl OSX/x64 requires these flags. See http://luajit.org/install.html
746 LUA_LIBS="-pagezero_size 10000 -image_base 100000000 $LUA_LIBS"
747 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200748 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200749 if test "$fail_if_missing" = "yes" -a "$lua_ok" != "yes"; then
Bram Moolenaarf788a062011-12-14 20:51:25 +0100750 AC_MSG_ERROR([could not configure lua])
751 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200752 AC_SUBST(LUA_SRC)
753 AC_SUBST(LUA_OBJ)
754 AC_SUBST(LUA_PRO)
755 AC_SUBST(LUA_LIBS)
756 AC_SUBST(LUA_CFLAGS)
757fi
758
759
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000760dnl Check for MzScheme feature.
761AC_MSG_CHECKING(--enable-mzschemeinterp argument)
762AC_ARG_ENABLE(mzschemeinterp,
Bram Moolenaar8008b632017-07-18 21:33:20 +0200763 [ --enable-mzschemeinterp Include MzScheme interpreter.], ,
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000764 [enable_mzschemeinterp="no"])
765AC_MSG_RESULT($enable_mzschemeinterp)
766
767if test "$enable_mzschemeinterp" = "yes"; then
768 dnl -- find the mzscheme executable
769 AC_SUBST(vi_cv_path_mzscheme)
770
771 AC_MSG_CHECKING(--with-plthome argument)
772 AC_ARG_WITH(plthome,
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000773 [ --with-plthome=PLTHOME Use PLTHOME.],
774 with_plthome="$withval"; AC_MSG_RESULT($with_plthome),
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000775 with_plthome="";AC_MSG_RESULT("no"))
776
777 if test "X$with_plthome" != "X"; then
778 vi_cv_path_mzscheme_pfx="$with_plthome"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100779 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000780 else
781 AC_MSG_CHECKING(PLTHOME environment var)
782 if test "X$PLTHOME" != "X"; then
783 AC_MSG_RESULT("$PLTHOME")
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000784 vi_cv_path_mzscheme_pfx="$PLTHOME"
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100785 vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000786 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000787 AC_MSG_RESULT(not set)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000788 dnl -- try to find MzScheme executable
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000789 AC_PATH_PROG(vi_cv_path_mzscheme, mzscheme)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000790
791 dnl resolve symbolic link, the executable is often elsewhere and there
792 dnl are no links for the include files.
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000793 if test "X$vi_cv_path_mzscheme" != "X"; then
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000794 lsout=`ls -l $vi_cv_path_mzscheme`
795 if echo "$lsout" | grep -e '->' >/dev/null 2>/dev/null; then
796 vi_cv_path_mzscheme=`echo "$lsout" | sed 's/.*-> \(.*\)/\1/'`
797 fi
798 fi
799
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000800 if test "X$vi_cv_path_mzscheme" != "X"; then
801 dnl -- find where MzScheme thinks it was installed
802 AC_CACHE_CHECK(MzScheme install prefix,vi_cv_path_mzscheme_pfx,
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000803 dnl different versions of MzScheme differ in command line processing
804 dnl use universal approach
805 echo "(display (simplify-path \
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000806 (build-path (call-with-values \
807 (lambda () (split-path (find-system-path (quote exec-file)))) \
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000808 (lambda (base name must-be-dir?) base)) (quote up))))" > mzdirs.scm
809 dnl Remove a trailing slash
810 [ vi_cv_path_mzscheme_pfx=`${vi_cv_path_mzscheme} -r mzdirs.scm | \
811 sed -e 's+/$++'` ])
812 rm -f mzdirs.scm
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000813 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000814 fi
815 fi
816
817 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100818 AC_MSG_CHECKING(for racket include directory)
819 SCHEME_INC=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-include-dir))) (when (path? p) (display p)))'`
820 if test "X$SCHEME_INC" != "X"; then
821 AC_MSG_RESULT(${SCHEME_INC})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000822 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100823 AC_MSG_RESULT(not found)
824 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include)
825 if test -f "$vi_cv_path_mzscheme_pfx/include/scheme.h"; then
826 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000827 AC_MSG_RESULT(yes)
Bram Moolenaard7afed32007-05-06 13:26:41 +0000828 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000829 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100830 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt)
831 if test -f "$vi_cv_path_mzscheme_pfx/include/plt/scheme.h"; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000832 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100833 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000834 else
835 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100836 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket)
837 if test -f "$vi_cv_path_mzscheme_pfx/include/racket/scheme.h"; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100838 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100839 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100840 else
841 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100842 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/)
843 if test -f /usr/include/plt/scheme.h; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100844 AC_MSG_RESULT(yes)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100845 SCHEME_INC=/usr/include/plt
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100846 else
847 AC_MSG_RESULT(no)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100848 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/racket/)
849 if test -f /usr/include/racket/scheme.h; then
850 AC_MSG_RESULT(yes)
851 SCHEME_INC=/usr/include/racket
852 else
853 AC_MSG_RESULT(no)
854 vi_cv_path_mzscheme_pfx=
855 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100856 fi
857 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000858 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000859 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000860 fi
861 fi
862
863 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100864
865 AC_MSG_CHECKING(for racket lib directory)
866 SCHEME_LIB=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-lib-dir))) (when (path? p) (display p)))'`
867 if test "X$SCHEME_LIB" != "X"; then
868 AC_MSG_RESULT(${SCHEME_LIB})
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000869 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100870 AC_MSG_RESULT(not found)
871 fi
872
873 for path in "${vi_cv_path_mzscheme_pfx}/lib" "${SCHEME_LIB}"; do
874 if test "X$path" != "X"; then
Bram Moolenaard0573012017-10-28 21:11:06 +0200875 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100876 MZSCHEME_LIBS="-framework Racket"
877 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
878 elif test -f "${path}/libmzscheme3m.a"; then
879 MZSCHEME_LIBS="${path}/libmzscheme3m.a"
880 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
881 elif test -f "${path}/libracket3m.a"; then
882 MZSCHEME_LIBS="${path}/libracket3m.a"
883 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
884 elif test -f "${path}/libracket.a"; then
885 MZSCHEME_LIBS="${path}/libracket.a ${path}/libmzgc.a"
886 elif test -f "${path}/libmzscheme.a"; then
887 MZSCHEME_LIBS="${path}/libmzscheme.a ${path}/libmzgc.a"
888 else
889 dnl Using shared objects
890 if test -f "${path}/libmzscheme3m.so"; then
891 MZSCHEME_LIBS="-L${path} -lmzscheme3m"
892 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
893 elif test -f "${path}/libracket3m.so"; then
894 MZSCHEME_LIBS="-L${path} -lracket3m"
895 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
896 elif test -f "${path}/libracket.so"; then
897 MZSCHEME_LIBS="-L${path} -lracket -lmzgc"
898 else
899 dnl try next until last
900 if test "$path" != "$SCHEME_LIB"; then
901 continue
902 fi
903 MZSCHEME_LIBS="-L${path} -lmzscheme -lmzgc"
904 fi
905 if test "$GCC" = yes; then
906 dnl Make Vim remember the path to the library. For when it's not in
907 dnl $LD_LIBRARY_PATH.
908 MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${path}"
909 elif test "`(uname) 2>/dev/null`" = SunOS &&
910 uname -r | grep '^5' >/dev/null; then
911 MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${path}"
912 fi
913 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000914 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100915 if test "X$MZSCHEME_LIBS" != "X"; then
916 break
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +0000917 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100918 done
919
920 AC_MSG_CHECKING([if racket requires -pthread])
921 if test "X$SCHEME_LIB" != "X" && $FGREP -e -pthread "$SCHEME_LIB/buildinfo" >/dev/null ; then
922 AC_MSG_RESULT(yes)
923 MZSCHEME_LIBS="${MZSCHEME_LIBS} -pthread"
924 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -pthread"
925 else
926 AC_MSG_RESULT(no)
927 fi
928
929 AC_MSG_CHECKING(for racket config directory)
930 SCHEME_CONFIGDIR=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-config-dir))) (when (path? p) (display p)))'`
931 if test "X$SCHEME_CONFIGDIR" != "X"; then
932 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DMZSCHEME_CONFIGDIR='\"${SCHEME_CONFIGDIR}\"'"
933 AC_MSG_RESULT(${SCHEME_CONFIGDIR})
934 else
935 AC_MSG_RESULT(not found)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000936 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100937
938 AC_MSG_CHECKING(for racket collects directory)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100939 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))))'`
940 if test "X$SCHEME_COLLECTS" = "X"; then
941 if test -d "$vi_cv_path_mzscheme_pfx/lib/plt/collects"; then
942 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/plt/
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100943 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100944 if test -d "$vi_cv_path_mzscheme_pfx/lib/racket/collects"; then
945 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/racket/
Bram Moolenaar75676462013-01-30 14:55:42 +0100946 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100947 if test -d "$vi_cv_path_mzscheme_pfx/share/racket/collects"; then
948 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/
949 else
950 if test -d "$vi_cv_path_mzscheme_pfx/collects"; then
951 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/
952 fi
Bram Moolenaar75676462013-01-30 14:55:42 +0100953 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100954 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100955 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000956 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100957 if test "X$SCHEME_COLLECTS" != "X" ; then
958 AC_MSG_RESULT(${SCHEME_COLLECTS})
959 else
960 AC_MSG_RESULT(not found)
961 fi
962
963 AC_MSG_CHECKING(for mzscheme_base.c)
964 if test -f "${SCHEME_COLLECTS}collects/scheme/base.ss" ; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000965 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +0100966 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
967 MZSCHEME_MOD="++lib scheme/base"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100968 else
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100969 if test -f "${SCHEME_COLLECTS}collects/scheme/base.rkt" ; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100970 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +0100971 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
972 MZSCHEME_MOD="++lib scheme/base"
973 else
974 if test -f "${SCHEME_COLLECTS}collects/racket/base.rkt" ; then
975 MZSCHEME_EXTRA="mzscheme_base.c"
976 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/raco ctool"
977 MZSCHEME_MOD=""
978 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100979 fi
980 fi
981 if test "X$MZSCHEME_EXTRA" != "X" ; then
982 dnl need to generate bytecode for MzScheme base
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000983 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE"
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100984 AC_MSG_RESULT(needed)
985 else
986 AC_MSG_RESULT(not needed)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000987 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100988
Bram Moolenaar9e902192013-07-17 18:58:11 +0200989 dnl On Ubuntu this fixes "undefined reference to symbol 'ffi_type_void'".
990 AC_CHECK_LIB(ffi, ffi_type_void, [MZSCHEME_LIBS="$MZSCHEME_LIBS -lffi"])
991
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000992 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -I${SCHEME_INC} \
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100993 -DMZSCHEME_COLLECTS='\"${SCHEME_COLLECTS}collects\"'"
Bram Moolenaar9e902192013-07-17 18:58:11 +0200994
995 dnl Test that we can compile a simple program with these CFLAGS and LIBS.
996 AC_MSG_CHECKING([if compile and link flags for MzScheme are sane])
997 cflags_save=$CFLAGS
998 libs_save=$LIBS
999 CFLAGS="$CFLAGS $MZSCHEME_CFLAGS"
1000 LIBS="$LIBS $MZSCHEME_LIBS"
1001 AC_TRY_LINK(,[ ],
1002 AC_MSG_RESULT(yes); mzs_ok=yes,
1003 AC_MSG_RESULT(no: MZSCHEME DISABLED); mzs_ok=no)
1004 CFLAGS=$cflags_save
1005 LIBS=$libs_save
1006 if test $mzs_ok = yes; then
1007 MZSCHEME_SRC="if_mzsch.c"
1008 MZSCHEME_OBJ="objects/if_mzsch.o"
1009 MZSCHEME_PRO="if_mzsch.pro"
1010 AC_DEFINE(FEAT_MZSCHEME)
1011 else
1012 MZSCHEME_CFLAGS=
1013 MZSCHEME_LIBS=
1014 MZSCHEME_EXTRA=
1015 MZSCHEME_MZC=
1016 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001017 fi
1018 AC_SUBST(MZSCHEME_SRC)
1019 AC_SUBST(MZSCHEME_OBJ)
1020 AC_SUBST(MZSCHEME_PRO)
1021 AC_SUBST(MZSCHEME_LIBS)
1022 AC_SUBST(MZSCHEME_CFLAGS)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001023 AC_SUBST(MZSCHEME_EXTRA)
1024 AC_SUBST(MZSCHEME_MZC)
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001025fi
1026
1027
Bram Moolenaar071d4272004-06-13 20:20:40 +00001028AC_MSG_CHECKING(--enable-perlinterp argument)
1029AC_ARG_ENABLE(perlinterp,
Bram Moolenaare06c1882010-07-21 22:05:20 +02001030 [ --enable-perlinterp[=OPTS] Include Perl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001031 [enable_perlinterp="no"])
1032AC_MSG_RESULT($enable_perlinterp)
Bram Moolenaare06c1882010-07-21 22:05:20 +02001033if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01001034 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1035 AC_MSG_ERROR([cannot use Perl with tiny or small features])
1036 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001037 AC_SUBST(vi_cv_path_perl)
1038 AC_PATH_PROG(vi_cv_path_perl, perl)
1039 if test "X$vi_cv_path_perl" != "X"; then
1040 AC_MSG_CHECKING(Perl version)
1041 if $vi_cv_path_perl -e 'require 5.003_01' >/dev/null 2>/dev/null; then
1042 eval `$vi_cv_path_perl -V:usethreads`
Bram Moolenaare06c1882010-07-21 22:05:20 +02001043 eval `$vi_cv_path_perl -V:libperl`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001044 if test "X$usethreads" = "XUNKNOWN" -o "X$usethreads" = "Xundef"; then
1045 badthreads=no
1046 else
1047 if $vi_cv_path_perl -e 'require 5.6.0' >/dev/null 2>/dev/null; then
1048 eval `$vi_cv_path_perl -V:use5005threads`
1049 if test "X$use5005threads" = "XUNKNOWN" -o "X$use5005threads" = "Xundef"; then
1050 badthreads=no
1051 else
1052 badthreads=yes
1053 AC_MSG_RESULT(>>> Perl > 5.6 with 5.5 threads cannot be used <<<)
1054 fi
1055 else
1056 badthreads=yes
1057 AC_MSG_RESULT(>>> Perl 5.5 with threads cannot be used <<<)
1058 fi
1059 fi
1060 if test $badthreads = no; then
1061 AC_MSG_RESULT(OK)
1062 eval `$vi_cv_path_perl -V:shrpenv`
1063 if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04
1064 shrpenv=""
1065 fi
1066 vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlibexp}'`
1067 AC_SUBST(vi_cv_perllib)
Bram Moolenaard5f62b12014-08-17 17:05:44 +02001068 vi_cv_perl_extutils=unknown_perl_extutils_path
1069 for extutils_rel_path in ExtUtils vendor_perl/ExtUtils; do
1070 xsubpp_path="$vi_cv_perllib/$extutils_rel_path/xsubpp"
1071 if test -f "$xsubpp_path"; then
1072 vi_cv_perl_xsubpp="$xsubpp_path"
1073 fi
1074 done
1075 AC_SUBST(vi_cv_perl_xsubpp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001076 dnl Remove "-fno-something", it breaks using cproto.
Bram Moolenaar280a8682015-06-21 13:41:08 +02001077 dnl Remove "-fdebug-prefix-map", it isn't supported by clang.
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001078 dnl Remove "FORTIFY_SOURCE", it will be defined twice.
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001079 dnl remove -pipe and -Wxxx, it confuses cproto
Bram Moolenaar071d4272004-06-13 20:20:40 +00001080 perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001081 -e 'ccflags;perl_inc;print"\n"' | sed -e 's/-fno[[^ ]]*//' \
1082 -e 's/-fdebug-prefix-map[[^ ]]*//g' \
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001083 -e 's/-pipe //' \
1084 -e 's/-W[[^ ]]*//g' \
1085 -e 's/-D_FORTIFY_SOURCE=.//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001086 dnl Remove "-lc", it breaks on FreeBSD when using "-pthread".
1087 perllibs=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed -e 'ldopts' | \
1088 sed -e '/Warning/d' -e '/Note (probably harmless)/d' \
1089 -e 's/-bE:perl.exp//' -e 's/-lc //'`
1090 dnl Don't add perl lib to $LIBS: if it's not in LD_LIBRARY_PATH
1091 dnl a test in configure may fail because of that.
1092 perlldflags=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed \
1093 -e 'ccdlflags' | sed -e 's/-bE:perl.exp//'`
1094
1095 dnl check that compiling a simple program still works with the flags
1096 dnl added for Perl.
1097 AC_MSG_CHECKING([if compile and link flags for Perl are sane])
1098 cflags_save=$CFLAGS
1099 libs_save=$LIBS
1100 ldflags_save=$LDFLAGS
1101 CFLAGS="$CFLAGS $perlcppflags"
1102 LIBS="$LIBS $perllibs"
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001103 perlldflags=`echo "$perlldflags" | sed -e 's/^ *//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001104 LDFLAGS="$perlldflags $LDFLAGS"
1105 AC_TRY_LINK(,[ ],
1106 AC_MSG_RESULT(yes); perl_ok=yes,
1107 AC_MSG_RESULT(no: PERL DISABLED); perl_ok=no)
1108 CFLAGS=$cflags_save
1109 LIBS=$libs_save
1110 LDFLAGS=$ldflags_save
1111 if test $perl_ok = yes; then
1112 if test "X$perlcppflags" != "X"; then
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001113 PERL_CFLAGS=$perlcppflags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001114 fi
1115 if test "X$perlldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001116 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$perlldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001117 LDFLAGS="$perlldflags $LDFLAGS"
1118 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001119 fi
1120 PERL_LIBS=$perllibs
1121 PERL_SRC="auto/if_perl.c if_perlsfio.c"
1122 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o"
1123 PERL_PRO="if_perl.pro if_perlsfio.pro"
1124 AC_DEFINE(FEAT_PERL)
1125 fi
1126 fi
1127 else
1128 AC_MSG_RESULT(>>> too old; need Perl version 5.003_01 or later <<<)
1129 fi
1130 fi
1131
Bram Moolenaard0573012017-10-28 21:11:06 +02001132 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00001133 dnl Mac OS X 10.2 or later
Bram Moolenaar071d4272004-06-13 20:20:40 +00001134 dir=/System/Library/Perl
1135 darwindir=$dir/darwin
1136 if test -d $darwindir; then
1137 PERL=/usr/bin/perl
1138 else
1139 dnl Mac OS X 10.3
1140 dir=/System/Library/Perl/5.8.1
1141 darwindir=$dir/darwin-thread-multi-2level
1142 if test -d $darwindir; then
1143 PERL=/usr/bin/perl
1144 fi
1145 fi
1146 if test -n "$PERL"; then
1147 PERL_DIR="$dir"
1148 PERL_CFLAGS="-DFEAT_PERL -I$darwindir/CORE"
1149 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o $darwindir/auto/DynaLoader/DynaLoader.a"
1150 PERL_LIBS="-L$darwindir/CORE -lperl"
1151 fi
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001152 dnl Perl on Mac OS X 10.5 adds "-arch" flags but these should only
1153 dnl be included if requested by passing --with-mac-arch to
1154 dnl configure, so strip these flags first (if present)
1155 PERL_LIBS=`echo "$PERL_LIBS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
1156 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 +00001157 fi
Bram Moolenaare06c1882010-07-21 22:05:20 +02001158 if test "$enable_perlinterp" = "dynamic"; then
1159 if test "$perl_ok" = "yes" -a "X$libperl" != "X"; then
1160 AC_DEFINE(DYNAMIC_PERL)
1161 PERL_CFLAGS="-DDYNAMIC_PERL_DLL=\\\"$libperl\\\" $PERL_CFLAGS"
1162 fi
1163 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001164
1165 if test "$fail_if_missing" = "yes" -a "$perl_ok" != "yes"; then
1166 AC_MSG_ERROR([could not configure perl])
1167 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001168fi
1169AC_SUBST(shrpenv)
1170AC_SUBST(PERL_SRC)
1171AC_SUBST(PERL_OBJ)
1172AC_SUBST(PERL_PRO)
1173AC_SUBST(PERL_CFLAGS)
1174AC_SUBST(PERL_LIBS)
1175
1176AC_MSG_CHECKING(--enable-pythoninterp argument)
1177AC_ARG_ENABLE(pythoninterp,
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001178 [ --enable-pythoninterp[=OPTS] Include Python interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001179 [enable_pythoninterp="no"])
1180AC_MSG_RESULT($enable_pythoninterp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001181if test "$enable_pythoninterp" = "yes" -o "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001182 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1183 AC_MSG_ERROR([cannot use Python with tiny or small features])
1184 fi
1185
Bram Moolenaar071d4272004-06-13 20:20:40 +00001186 dnl -- find the python executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001187 AC_MSG_CHECKING(--with-python-command argument)
1188 AC_SUBST(vi_cv_path_python)
1189 AC_ARG_WITH(python-command, [ --with-python-command=NAME name of the Python 2 command (default: python2 or python)],
1190 vi_cv_path_python="$withval"; AC_MSG_RESULT($vi_cv_path_python),
1191 AC_MSG_RESULT(no))
1192
1193 if test "X$vi_cv_path_python" = "X"; then
1194 AC_PATH_PROGS(vi_cv_path_python, python2 python)
1195 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001196 if test "X$vi_cv_path_python" != "X"; then
1197
1198 dnl -- get its version number
1199 AC_CACHE_CHECK(Python version,vi_cv_var_python_version,
1200 [[vi_cv_var_python_version=`
1201 ${vi_cv_path_python} -c 'import sys; print sys.version[:3]'`
1202 ]])
1203
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001204 dnl -- it must be at least version 2.3
1205 AC_MSG_CHECKING(Python is 2.3 or better)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001206 if ${vi_cv_path_python} -c \
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001207 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001208 then
1209 AC_MSG_RESULT(yep)
1210
1211 dnl -- find where python thinks it was installed
1212 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python_pfx,
1213 [ vi_cv_path_python_pfx=`
1214 ${vi_cv_path_python} -c \
1215 "import sys; print sys.prefix"` ])
1216
1217 dnl -- and where it thinks it runs
1218 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python_epfx,
1219 [ vi_cv_path_python_epfx=`
1220 ${vi_cv_path_python} -c \
1221 "import sys; print sys.exec_prefix"` ])
1222
1223 dnl -- python's internal library path
1224
1225 AC_CACHE_VAL(vi_cv_path_pythonpath,
1226 [ vi_cv_path_pythonpath=`
1227 unset PYTHONPATH;
1228 ${vi_cv_path_python} -c \
1229 "import sys, string; print string.join(sys.path,':')"` ])
1230
1231 dnl -- where the Python implementation library archives are
1232
1233 AC_ARG_WITH(python-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001234 [ --with-python-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001235 [ vi_cv_path_python_conf="${withval}"; have_python_config_dir=1 ] )
Bram Moolenaar071d4272004-06-13 20:20:40 +00001236
1237 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python_conf,
1238 [
1239 vi_cv_path_python_conf=
Bram Moolenaarac499e32013-06-02 19:14:17 +02001240 d=`${vi_cv_path_python} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBPL')"`
1241 if test -d "$d" && test -f "$d/config.c"; then
1242 vi_cv_path_python_conf="$d"
1243 else
1244 for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
1245 for subdir in lib64 lib share; do
1246 d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
1247 if test -d "$d" && test -f "$d/config.c"; then
1248 vi_cv_path_python_conf="$d"
1249 fi
1250 done
Bram Moolenaar071d4272004-06-13 20:20:40 +00001251 done
Bram Moolenaarac499e32013-06-02 19:14:17 +02001252 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001253 ])
1254
1255 PYTHON_CONFDIR="${vi_cv_path_python_conf}"
1256
1257 if test "X$PYTHON_CONFDIR" = "X"; then
1258 AC_MSG_RESULT([can't find it!])
1259 else
1260
1261 dnl -- we need to examine Python's config/Makefile too
1262 dnl see what the interpreter is built from
1263 AC_CACHE_VAL(vi_cv_path_python_plibs,
1264 [
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001265 pwd=`pwd`
1266 tmp_mkf="$pwd/config-PyMake$$"
1267 cat -- "${PYTHON_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001268__:
Bram Moolenaar218116c2010-05-20 21:46:00 +02001269 @echo "python_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001270 @echo "python_LIBS='$(LIBS)'"
1271 @echo "python_SYSLIBS='$(SYSLIBS)'"
1272 @echo "python_LINKFORSHARED='$(LINKFORSHARED)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001273 @echo "python_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001274 @echo "python_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001275 @echo "python_PYTHONFRAMEWORK='$(PYTHONFRAMEWORK)'"
1276 @echo "python_PYTHONFRAMEWORKPREFIX='$(PYTHONFRAMEWORKPREFIX)'"
1277 @echo "python_PYTHONFRAMEWORKINSTALLDIR='$(PYTHONFRAMEWORKINSTALLDIR)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001278eof
1279 dnl -- delete the lines from make about Entering/Leaving directory
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001280 eval "`cd ${PYTHON_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1281 rm -f -- "${tmp_mkf}"
Bram Moolenaard0573012017-10-28 21:11:06 +02001282 if test "x$MACOS_X" = "xyes" && test -n "${python_PYTHONFRAMEWORK}" && ${vi_cv_path_python} -c \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001283 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then
1284 vi_cv_path_python_plibs="-framework Python"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001285 if test "x${vi_cv_path_python}" != "x/usr/bin/python" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
1286 vi_cv_path_python_plibs="-F${python_PYTHONFRAMEWORKPREFIX} -framework Python"
1287 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001288 else
Bram Moolenaar9ce42132018-04-11 22:19:36 +02001289 vi_cv_path_python_plibs="-L${PYTHON_CONFDIR} -lpython${vi_cv_var_python_version}"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001290 dnl -- Check if the path contained in python_LINKFORSHARED is
1291 dnl usable for vim build. If not, make and try other
1292 dnl candidates.
Bram Moolenaara161e262015-03-24 15:14:27 +01001293 if test -n "${python_LINKFORSHARED}" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
Bram Moolenaar6c927552015-03-24 12:21:33 +01001294 python_link_symbol=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]].*/\1/'`
1295 python_link_path=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]][[ \t]]*\(.*\)/\2/'`
1296 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1297 dnl -- The path looks relative. Guess the absolute one using
1298 dnl the prefix and try that.
1299 python_link_path="${python_PYTHONFRAMEWORKPREFIX}/${python_link_path}"
1300 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1301 dnl -- A last resort.
1302 python_link_path="${python_PYTHONFRAMEWORKINSTALLDIR}/Versions/${vi_cv_var_python_version}/${python_PYTHONFRAMEWORK}"
1303 dnl -- No check is done. The last word is left to the
1304 dnl "sanity" test on link flags that follows shortly.
1305 fi
1306 python_LINKFORSHARED="${python_link_symbol} ${python_link_path}"
1307 fi
1308 fi
Bram Moolenaar218116c2010-05-20 21:46:00 +02001309 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 +00001310 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1311 vi_cv_path_python_plibs=`echo $vi_cv_path_python_plibs | sed s/-ltermcap//`
1312 fi
1313 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001314 AC_CACHE_CHECK(Python's dll name,vi_cv_dll_name_python,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001315 [
1316 if test "X$python_DLLLIBRARY" != "X"; then
1317 vi_cv_dll_name_python="$python_DLLLIBRARY"
1318 else
1319 vi_cv_dll_name_python="$python_INSTSONAME"
1320 fi
1321 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00001322
1323 PYTHON_LIBS="${vi_cv_path_python_plibs}"
1324 if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001325 PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001326 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001327 PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -I${vi_cv_path_python_epfx}/include/python${vi_cv_var_python_version}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001328 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001329 if test "X$have_python_config_dir" = "X1" -a "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001330 dnl Define PYTHON_HOME if --with-python-config-dir was used
1331 PYTHON_CFLAGS="${PYTHON_CFLAGS} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'"
1332
1333 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001334 PYTHON_SRC="if_python.c"
Bram Moolenaar9bdb9a02012-07-25 16:32:08 +02001335 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001336
1337 dnl On FreeBSD linking with "-pthread" is required to use threads.
1338 dnl _THREAD_SAFE must be used for compiling then.
1339 dnl The "-pthread" is added to $LIBS, so that the following check for
1340 dnl sigaltstack() will look in libc_r (it's there in libc!).
1341 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1342 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1343 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1344 AC_MSG_CHECKING([if -pthread should be used])
1345 threadsafe_flag=
1346 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001347 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00001348 if test "`(uname) 2>/dev/null`" != Darwin; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001349 test "$GCC" = yes && threadsafe_flag="-pthread"
1350 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1351 threadsafe_flag="-D_THREAD_SAFE"
1352 thread_lib="-pthread"
1353 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001354 if test "`(uname) 2>/dev/null`" = SunOS; then
1355 threadsafe_flag="-pthreads"
1356 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001357 fi
1358 libs_save_old=$LIBS
1359 if test -n "$threadsafe_flag"; then
1360 cflags_save=$CFLAGS
1361 CFLAGS="$CFLAGS $threadsafe_flag"
1362 LIBS="$LIBS $thread_lib"
1363 AC_TRY_LINK(,[ ],
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001364 AC_MSG_RESULT(yes); PYTHON_CFLAGS="$PYTHON_CFLAGS $threadsafe_flag",
Bram Moolenaar071d4272004-06-13 20:20:40 +00001365 AC_MSG_RESULT(no); LIBS=$libs_save_old
1366 )
1367 CFLAGS=$cflags_save
1368 else
1369 AC_MSG_RESULT(no)
1370 fi
1371
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001372 dnl Check that compiling a simple program still works with the flags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001373 dnl added for Python.
1374 AC_MSG_CHECKING([if compile and link flags for Python are sane])
1375 cflags_save=$CFLAGS
1376 libs_save=$LIBS
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001377 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001378 LIBS="$LIBS $PYTHON_LIBS"
1379 AC_TRY_LINK(,[ ],
1380 AC_MSG_RESULT(yes); python_ok=yes,
1381 AC_MSG_RESULT(no: PYTHON DISABLED); python_ok=no)
1382 CFLAGS=$cflags_save
1383 LIBS=$libs_save
1384 if test $python_ok = yes; then
1385 AC_DEFINE(FEAT_PYTHON)
1386 else
1387 LIBS=$libs_save_old
1388 PYTHON_SRC=
1389 PYTHON_OBJ=
1390 PYTHON_LIBS=
1391 PYTHON_CFLAGS=
1392 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001393 fi
1394 else
1395 AC_MSG_RESULT(too old)
1396 fi
1397 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001398
1399 if test "$fail_if_missing" = "yes" -a "$python_ok" != "yes"; then
1400 AC_MSG_ERROR([could not configure python])
1401 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001402fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001403
Bram Moolenaar071d4272004-06-13 20:20:40 +00001404AC_SUBST(PYTHON_LIBS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001405AC_SUBST(PYTHON_CFLAGS)
1406AC_SUBST(PYTHON_SRC)
1407AC_SUBST(PYTHON_OBJ)
1408
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001409
1410AC_MSG_CHECKING(--enable-python3interp argument)
1411AC_ARG_ENABLE(python3interp,
Bram Moolenaar8008b632017-07-18 21:33:20 +02001412 [ --enable-python3interp[=OPTS] Include Python3 interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001413 [enable_python3interp="no"])
1414AC_MSG_RESULT($enable_python3interp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001415if test "$enable_python3interp" = "yes" -o "$enable_python3interp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001416 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1417 AC_MSG_ERROR([cannot use Python with tiny or small features])
1418 fi
1419
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001420 dnl -- find the python3 executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001421 AC_MSG_CHECKING(--with-python3-command argument)
1422 AC_SUBST(vi_cv_path_python3)
1423 AC_ARG_WITH(python3-command, [ --with-python3-command=NAME name of the Python 3 command (default: python3 or python)],
1424 vi_cv_path_python3="$withval"; AC_MSG_RESULT($vi_cv_path_python3),
1425 AC_MSG_RESULT(no))
1426
1427 if test "X$vi_cv_path_python3" = "X"; then
1428 AC_PATH_PROGS(vi_cv_path_python3, python3 python)
1429 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001430 if test "X$vi_cv_path_python3" != "X"; then
1431
1432 dnl -- get its version number
1433 AC_CACHE_CHECK(Python version,vi_cv_var_python3_version,
1434 [[vi_cv_var_python3_version=`
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001435 ${vi_cv_path_python3} -c 'import sys; print(sys.version[:3])'`
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001436 ]])
1437
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001438 dnl -- it must be at least version 3
1439 AC_MSG_CHECKING(Python is 3.0 or better)
1440 if ${vi_cv_path_python3} -c \
1441 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.0)"
1442 then
1443 AC_MSG_RESULT(yep)
Bram Moolenaar456f2bb2011-06-12 21:37:13 +02001444
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001445 dnl -- get abiflags for python 3.2 or higher (PEP 3149)
1446 AC_CACHE_CHECK(Python's abiflags,vi_cv_var_python3_abiflags,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001447 [
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001448 vi_cv_var_python3_abiflags=
1449 if ${vi_cv_path_python3} -c \
1450 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)"
1451 then
1452 vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \
1453 "import sys; print(sys.abiflags)"`
1454 fi ])
1455
1456 dnl -- find where python3 thinks it was installed
1457 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx,
1458 [ vi_cv_path_python3_pfx=`
1459 ${vi_cv_path_python3} -c \
1460 "import sys; print(sys.prefix)"` ])
1461
1462 dnl -- and where it thinks it runs
1463 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx,
1464 [ vi_cv_path_python3_epfx=`
1465 ${vi_cv_path_python3} -c \
1466 "import sys; print(sys.exec_prefix)"` ])
1467
1468 dnl -- python3's internal library path
1469
1470 AC_CACHE_VAL(vi_cv_path_python3path,
1471 [ vi_cv_path_python3path=`
1472 unset PYTHONPATH;
1473 ${vi_cv_path_python3} -c \
1474 "import sys, string; print(':'.join(sys.path))"` ])
1475
1476 dnl -- where the Python implementation library archives are
1477
1478 AC_ARG_WITH(python3-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001479 [ --with-python3-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001480 [ vi_cv_path_python3_conf="${withval}"; have_python3_config_dir=1 ] )
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001481
1482 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf,
1483 [
1484 vi_cv_path_python3_conf=
Bram Moolenaarfee496d2013-07-12 20:07:24 +02001485 config_dir="config-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001486 d=`${vi_cv_path_python3} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBPL'))"`
1487 if test -d "$d" && test -f "$d/config.c"; then
1488 vi_cv_path_python3_conf="$d"
1489 else
1490 for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do
1491 for subdir in lib64 lib share; do
1492 d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}"
1493 if test -d "$d" && test -f "$d/config.c"; then
1494 vi_cv_path_python3_conf="$d"
1495 fi
1496 done
1497 done
1498 fi
1499 ])
1500
1501 PYTHON3_CONFDIR="${vi_cv_path_python3_conf}"
1502
1503 if test "X$PYTHON3_CONFDIR" = "X"; then
1504 AC_MSG_RESULT([can't find it!])
1505 else
1506
1507 dnl -- we need to examine Python's config/Makefile too
1508 dnl see what the interpreter is built from
1509 AC_CACHE_VAL(vi_cv_path_python3_plibs,
1510 [
1511 pwd=`pwd`
1512 tmp_mkf="$pwd/config-PyMake$$"
1513 cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001514__:
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001515 @echo "python3_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001516 @echo "python3_LIBS='$(LIBS)'"
1517 @echo "python3_SYSLIBS='$(SYSLIBS)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001518 @echo "python3_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001519 @echo "python3_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001520eof
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001521 dnl -- delete the lines from make about Entering/Leaving directory
1522 eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1523 rm -f -- "${tmp_mkf}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001524 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 +02001525 vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}"
1526 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1527 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//`
1528 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//`
1529 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001530 AC_CACHE_CHECK(Python3's dll name,vi_cv_dll_name_python3,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001531 [
1532 if test "X$python3_DLLLIBRARY" != "X"; then
1533 vi_cv_dll_name_python3="$python3_DLLLIBRARY"
1534 else
1535 vi_cv_dll_name_python3="$python3_INSTSONAME"
1536 fi
1537 ])
1538
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001539 PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
1540 if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001541 PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001542 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001543 PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -I${vi_cv_path_python3_epfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001544 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001545 if test "X$have_python3_config_dir" = "X1" -a "$enable_python3interp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001546 dnl Define PYTHON3_HOME if --with-python-config-dir was used
1547 PYTHON3_CFLAGS="${PYTHON3_CFLAGS} -DPYTHON3_HOME='L\"${vi_cv_path_python3_pfx}\"'"
1548 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001549 PYTHON3_SRC="if_python3.c"
1550 PYTHON3_OBJ="objects/if_python3.o"
1551
1552 dnl On FreeBSD linking with "-pthread" is required to use threads.
1553 dnl _THREAD_SAFE must be used for compiling then.
1554 dnl The "-pthread" is added to $LIBS, so that the following check for
1555 dnl sigaltstack() will look in libc_r (it's there in libc!).
1556 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1557 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1558 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1559 AC_MSG_CHECKING([if -pthread should be used])
1560 threadsafe_flag=
1561 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001562 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001563 if test "`(uname) 2>/dev/null`" != Darwin; then
1564 test "$GCC" = yes && threadsafe_flag="-pthread"
1565 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1566 threadsafe_flag="-D_THREAD_SAFE"
1567 thread_lib="-pthread"
1568 fi
1569 if test "`(uname) 2>/dev/null`" = SunOS; then
1570 threadsafe_flag="-pthreads"
1571 fi
1572 fi
1573 libs_save_old=$LIBS
1574 if test -n "$threadsafe_flag"; then
1575 cflags_save=$CFLAGS
1576 CFLAGS="$CFLAGS $threadsafe_flag"
1577 LIBS="$LIBS $thread_lib"
1578 AC_TRY_LINK(,[ ],
1579 AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag",
1580 AC_MSG_RESULT(no); LIBS=$libs_save_old
1581 )
1582 CFLAGS=$cflags_save
1583 else
1584 AC_MSG_RESULT(no)
1585 fi
1586
1587 dnl check that compiling a simple program still works with the flags
1588 dnl added for Python.
1589 AC_MSG_CHECKING([if compile and link flags for Python 3 are sane])
1590 cflags_save=$CFLAGS
1591 libs_save=$LIBS
1592 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1593 LIBS="$LIBS $PYTHON3_LIBS"
1594 AC_TRY_LINK(,[ ],
1595 AC_MSG_RESULT(yes); python3_ok=yes,
1596 AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no)
1597 CFLAGS=$cflags_save
1598 LIBS=$libs_save
1599 if test "$python3_ok" = yes; then
1600 AC_DEFINE(FEAT_PYTHON3)
1601 else
1602 LIBS=$libs_save_old
1603 PYTHON3_SRC=
1604 PYTHON3_OBJ=
1605 PYTHON3_LIBS=
1606 PYTHON3_CFLAGS=
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001607 fi
1608 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001609 else
1610 AC_MSG_RESULT(too old)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001611 fi
1612 fi
Bram Moolenaar1612b1a2013-06-14 21:22:39 +02001613 if test "$fail_if_missing" = "yes" -a "$python3_ok" != "yes"; then
1614 AC_MSG_ERROR([could not configure python3])
1615 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001616fi
1617
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001618AC_SUBST(PYTHON3_LIBS)
1619AC_SUBST(PYTHON3_CFLAGS)
1620AC_SUBST(PYTHON3_SRC)
1621AC_SUBST(PYTHON3_OBJ)
1622
1623dnl if python2.x and python3.x are enabled one can only link in code
1624dnl with dlopen(), dlsym(), dlclose()
1625if test "$python_ok" = yes && test "$python3_ok" = yes; then
1626 AC_DEFINE(DYNAMIC_PYTHON)
1627 AC_DEFINE(DYNAMIC_PYTHON3)
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001628 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001629 cflags_save=$CFLAGS
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001630 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001631 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001632 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001633 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001634 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001635 #include <dlfcn.h>
1636 /* If this program fails, then RTLD_GLOBAL is needed.
1637 * RTLD_GLOBAL will be used and then it is not possible to
1638 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001639 * Only the first python version used will be switched on.
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001640 */
1641
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001642 int no_rtl_global_needed_for(char *python_instsoname, char *prefix)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001643 {
1644 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001645 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001646 if (pylib != 0)
1647 {
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001648 void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome");
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001649 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1650 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1651 void (*final)(void) = dlsym(pylib, "Py_Finalize");
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001652 (*pfx)(prefix);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001653 (*init)();
1654 needed = (*simple)("import termios") == -1;
1655 (*final)();
1656 dlclose(pylib);
1657 }
1658 return !needed;
1659 }
1660
1661 int main(int argc, char** argv)
1662 {
1663 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001664 if (no_rtl_global_needed_for("${vi_cv_dll_name_python}", "${vi_cv_path_python_pfx}"))
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001665 not_needed = 1;
1666 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001667 }])],
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001668 [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001669
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001670 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001671 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001672
1673 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python3)
1674 cflags_save=$CFLAGS
1675 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001676 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001677 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001678 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001679 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001680 #include <dlfcn.h>
1681 #include <wchar.h>
1682 /* If this program fails, then RTLD_GLOBAL is needed.
1683 * RTLD_GLOBAL will be used and then it is not possible to
1684 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001685 * Only the first python version used will be switched on.
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001686 */
1687
1688 int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix)
1689 {
1690 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001691 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001692 if (pylib != 0)
1693 {
1694 void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome");
1695 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1696 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1697 void (*final)(void) = dlsym(pylib, "Py_Finalize");
1698 (*pfx)(prefix);
1699 (*init)();
1700 needed = (*simple)("import termios") == -1;
1701 (*final)();
1702 dlclose(pylib);
1703 }
1704 return !needed;
1705 }
1706
1707 int main(int argc, char** argv)
1708 {
1709 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001710 if (no_rtl_global_needed_for("${vi_cv_dll_name_python3}", L"${vi_cv_path_python3_pfx}"))
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001711 not_needed = 1;
1712 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001713 }])],
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001714 [AC_MSG_RESULT(yes);AC_DEFINE(PY3_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
1715
1716 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001717 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001718
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001719 PYTHON_SRC="if_python.c"
1720 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001721 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001722 PYTHON_LIBS=
1723 PYTHON3_SRC="if_python3.c"
1724 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001725 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001726 PYTHON3_LIBS=
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001727elif test "$python_ok" = yes && test "$enable_pythoninterp" = "dynamic"; then
1728 AC_DEFINE(DYNAMIC_PYTHON)
1729 PYTHON_SRC="if_python.c"
1730 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001731 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001732 PYTHON_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001733elif test "$python_ok" = yes; then
1734 dnl Check that adding -fPIE works. It may be needed when using a static
1735 dnl Python library.
1736 AC_MSG_CHECKING([if -fPIE can be added for Python])
1737 cflags_save=$CFLAGS
1738 libs_save=$LIBS
1739 CFLAGS="$CFLAGS $PYTHON_CFLAGS -fPIE"
1740 LIBS="$LIBS $PYTHON_LIBS"
1741 AC_TRY_LINK(,[ ],
1742 AC_MSG_RESULT(yes); fpie_ok=yes,
1743 AC_MSG_RESULT(no); fpie_ok=no)
1744 CFLAGS=$cflags_save
1745 LIBS=$libs_save
1746 if test $fpie_ok = yes; then
1747 PYTHON_CFLAGS="$PYTHON_CFLAGS -fPIE"
1748 fi
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001749elif test "$python3_ok" = yes && test "$enable_python3interp" = "dynamic"; then
1750 AC_DEFINE(DYNAMIC_PYTHON3)
1751 PYTHON3_SRC="if_python3.c"
1752 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001753 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001754 PYTHON3_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001755elif test "$python3_ok" = yes; then
1756 dnl Check that adding -fPIE works. It may be needed when using a static
1757 dnl Python library.
1758 AC_MSG_CHECKING([if -fPIE can be added for Python3])
1759 cflags_save=$CFLAGS
1760 libs_save=$LIBS
1761 CFLAGS="$CFLAGS $PYTHON3_CFLAGS -fPIE"
1762 LIBS="$LIBS $PYTHON3_LIBS"
1763 AC_TRY_LINK(,[ ],
1764 AC_MSG_RESULT(yes); fpie_ok=yes,
1765 AC_MSG_RESULT(no); fpie_ok=no)
1766 CFLAGS=$cflags_save
1767 LIBS=$libs_save
1768 if test $fpie_ok = yes; then
1769 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -fPIE"
1770 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001771fi
1772
Bram Moolenaar071d4272004-06-13 20:20:40 +00001773AC_MSG_CHECKING(--enable-tclinterp argument)
1774AC_ARG_ENABLE(tclinterp,
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001775 [ --enable-tclinterp[=OPTS] Include Tcl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001776 [enable_tclinterp="no"])
1777AC_MSG_RESULT($enable_tclinterp)
1778
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001779if test "$enable_tclinterp" = "yes" -o "$enable_tclinterp" = "dynamic"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001780
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001781 dnl on FreeBSD tclsh is a silly script, look for tclsh8.[5420]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001782 AC_MSG_CHECKING(--with-tclsh argument)
1783 AC_ARG_WITH(tclsh, [ --with-tclsh=PATH which tclsh to use (default: tclsh8.0)],
1784 tclsh_name="$withval"; AC_MSG_RESULT($tclsh_name),
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001785 tclsh_name="tclsh8.5"; AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00001786 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1787 AC_SUBST(vi_cv_path_tcl)
1788
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001789 dnl when no specific version specified, also try 8.4, 8.2 and 8.0
1790 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.5"; then
1791 tclsh_name="tclsh8.4"
1792 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1793 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001794 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.4"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001795 tclsh_name="tclsh8.2"
1796 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1797 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001798 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.2"; then
1799 tclsh_name="tclsh8.0"
1800 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1801 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001802 dnl still didn't find it, try without version number
1803 if test "X$vi_cv_path_tcl" = "X"; then
1804 tclsh_name="tclsh"
1805 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1806 fi
1807 if test "X$vi_cv_path_tcl" != "X"; then
1808 AC_MSG_CHECKING(Tcl version)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001809 if echo 'exit [[expr [info tclversion] < 8.0]]' | "$vi_cv_path_tcl" - ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001810 tclver=`echo 'puts [[info tclversion]]' | $vi_cv_path_tcl -`
1811 AC_MSG_RESULT($tclver - OK);
1812 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 +01001813 tcldll=`echo 'puts libtcl[[info tclversion]][[info sharedlibextension]]' | $vi_cv_path_tcl -`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001814
1815 AC_MSG_CHECKING(for location of Tcl include)
Bram Moolenaard0573012017-10-28 21:11:06 +02001816 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001817 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 +00001818 else
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001819 dnl For all macOS, use the value from TCL in case use of, say, homebrew
Bram Moolenaar071d4272004-06-13 20:20:40 +00001820 dnl For Mac OS X 10.3, use the OS-provided framework location
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001821 dnl For Mac OS X 10.14, the OS-provided framework location doesn't contain the headers, so also check the Xcode SDK
1822 tclinc="$tclloc/include $tclloc/include/tcl $tclloc/include/tcl$tclver /System/Library/Frameworks/Tcl.framework/Headers `xcrun --show-sdk-path`/System/Library/Frameworks/Tcl.framework/Versions/Current/Headers"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001823 fi
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001824 TCL_INC=
Bram Moolenaar071d4272004-06-13 20:20:40 +00001825 for try in $tclinc; do
1826 if test -f "$try/tcl.h"; then
1827 AC_MSG_RESULT($try/tcl.h)
1828 TCL_INC=$try
1829 break
1830 fi
1831 done
1832 if test -z "$TCL_INC"; then
1833 AC_MSG_RESULT(<not found>)
1834 SKIP_TCL=YES
1835 fi
1836 if test -z "$SKIP_TCL"; then
1837 AC_MSG_CHECKING(for location of tclConfig.sh script)
Bram Moolenaard0573012017-10-28 21:11:06 +02001838 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001839 tclcnf=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001840 tclcnf="$tclcnf `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001841 else
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001842 dnl For all macOS, use the value from TCL in case use of, say, homebrew
Bram Moolenaar071d4272004-06-13 20:20:40 +00001843 dnl For Mac OS X 10.3, use the OS-provided framework location
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001844 dnl For Mac OS X 10.14, the OS-provided framework location doesn't contain the headers, so also check the Xcode SDK
1845 tclcnf=`echo $tclinc | sed s/include/lib/g`
1846 tclcnf="$tclcnf /System/Library/Frameworks/Tcl.framework `xcrun --show-sdk-path`/System/Library/Frameworks/Tcl.framework"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001847 fi
1848 for try in $tclcnf; do
Bram Moolenaar49222be2015-12-11 18:11:30 +01001849 if test -f "$try/tclConfig.sh"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001850 AC_MSG_RESULT($try/tclConfig.sh)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001851 . "$try/tclConfig.sh"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001852 dnl use eval, because tcl 8.2 includes ${TCL_DBGX}
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001853 if test "$enable_tclinterp" = "dynamic"; then
1854 TCL_LIBS=`eval echo "$TCL_STUB_LIB_SPEC $TCL_LIBS"`
1855 else
1856 TCL_LIBS=`eval echo "$TCL_LIB_SPEC $TCL_LIBS"`
1857 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001858 dnl Use $TCL_DEFS for -D_THREAD_SAFE et al. But only use the
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001859 dnl "-D_ABC" items. Watch out for -DFOO=long\ long.
Bram Moolenaar4394bff2008-07-24 11:21:31 +00001860 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 +00001861 break
1862 fi
1863 done
1864 if test -z "$TCL_LIBS"; then
1865 AC_MSG_RESULT(<not found>)
1866 AC_MSG_CHECKING(for Tcl library by myself)
1867 tcllib=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001868 tcllib="$tcllib `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001869 for ext in .so .a ; do
1870 for ver in "" $tclver ; do
1871 for try in $tcllib ; do
1872 trylib=tcl$ver$ext
Bram Moolenaar49222be2015-12-11 18:11:30 +01001873 if test -f "$try/lib$trylib" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001874 AC_MSG_RESULT($try/lib$trylib)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001875 TCL_LIBS="-L\"$try\" -ltcl$ver -ldl -lm"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001876 if test "`(uname) 2>/dev/null`" = SunOS &&
1877 uname -r | grep '^5' >/dev/null; then
1878 TCL_LIBS="$TCL_LIBS -R $try"
1879 fi
1880 break 3
1881 fi
1882 done
1883 done
1884 done
1885 if test -z "$TCL_LIBS"; then
1886 AC_MSG_RESULT(<not found>)
1887 SKIP_TCL=YES
1888 fi
1889 fi
1890 if test -z "$SKIP_TCL"; then
1891 AC_DEFINE(FEAT_TCL)
1892 TCL_SRC=if_tcl.c
1893 TCL_OBJ=objects/if_tcl.o
1894 TCL_PRO=if_tcl.pro
1895 TCL_CFLAGS="-I$TCL_INC $TCL_DEFS"
1896 fi
1897 fi
1898 else
1899 AC_MSG_RESULT(too old; need Tcl version 8.0 or later)
1900 fi
1901 fi
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001902 if test "$enable_tclinterp" = "dynamic"; then
1903 if test "X$TCL_SRC" != "X" -a "X$tcldll" != "X"; then
1904 AC_DEFINE(DYNAMIC_TCL)
1905 TCL_CFLAGS="-DDYNAMIC_TCL_DLL=\\\"$tcldll\\\" -DDYNAMIC_TCL_VER=\\\"$tclver\\\" $TCL_CFLAGS"
1906 fi
1907 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001908 if test "$fail_if_missing" = "yes" -a -z "$TCL_SRC"; then
1909 AC_MSG_ERROR([could not configure Tcl])
1910 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001911fi
1912AC_SUBST(TCL_SRC)
1913AC_SUBST(TCL_OBJ)
1914AC_SUBST(TCL_PRO)
1915AC_SUBST(TCL_CFLAGS)
1916AC_SUBST(TCL_LIBS)
1917
1918AC_MSG_CHECKING(--enable-rubyinterp argument)
1919AC_ARG_ENABLE(rubyinterp,
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001920 [ --enable-rubyinterp[=OPTS] Include Ruby interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001921 [enable_rubyinterp="no"])
1922AC_MSG_RESULT($enable_rubyinterp)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001923if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001924 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1925 AC_MSG_ERROR([cannot use Ruby with tiny or small features])
1926 fi
1927
Bram Moolenaar165641d2010-02-17 16:23:09 +01001928 AC_MSG_CHECKING(--with-ruby-command argument)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001929 AC_SUBST(vi_cv_path_ruby)
Bram Moolenaar948733a2011-05-05 18:10:16 +02001930 AC_ARG_WITH(ruby-command, [ --with-ruby-command=RUBY name of the Ruby command (default: ruby)],
1931 RUBY_CMD="$withval"; vi_cv_path_ruby="$withval"; AC_MSG_RESULT($RUBY_CMD),
1932 RUBY_CMD="ruby"; AC_MSG_RESULT(defaulting to $RUBY_CMD))
Bram Moolenaar165641d2010-02-17 16:23:09 +01001933 AC_PATH_PROG(vi_cv_path_ruby, $RUBY_CMD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001934 if test "X$vi_cv_path_ruby" != "X"; then
1935 AC_MSG_CHECKING(Ruby version)
Bram Moolenaare4efc3b2005-03-07 23:16:51 +00001936 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 +00001937 AC_MSG_RESULT(OK)
Bram Moolenaar81398892012-10-03 21:09:35 +02001938 AC_MSG_CHECKING(Ruby rbconfig)
1939 ruby_rbconfig="RbConfig"
1940 if ! $vi_cv_path_ruby -r rbconfig -e 'RbConfig' >/dev/null 2>/dev/null; then
1941 ruby_rbconfig="Config"
1942 fi
1943 AC_MSG_RESULT($ruby_rbconfig)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001944 AC_MSG_CHECKING(Ruby header files)
Bram Moolenaar81398892012-10-03 21:09:35 +02001945 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 +00001946 if test "X$rubyhdrdir" != "X"; then
1947 AC_MSG_RESULT($rubyhdrdir)
1948 RUBY_CFLAGS="-I$rubyhdrdir"
Bram Moolenaara6fd37b2014-03-27 17:19:09 +01001949 rubyarchdir=`$vi_cv_path_ruby -r rbconfig -e "print ($ruby_rbconfig::CONFIG.has_key? 'rubyarchhdrdir') ? $ruby_rbconfig::CONFIG[['rubyarchhdrdir']] : '$rubyhdrdir/'+$ruby_rbconfig::CONFIG[['arch']]"`
1950 if test -d "$rubyarchdir"; then
1951 RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyarchdir"
Bram Moolenaar165641d2010-02-17 16:23:09 +01001952 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001953 rubyversion=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['ruby_version']].gsub(/\./, '')[[0,2]]"`
Bram Moolenaar026a4452013-08-07 15:22:23 +02001954 if test "X$rubyversion" = "X"; then
1955 rubyversion=`$vi_cv_path_ruby -e "print ((VERSION rescue RUBY_VERSION)).gsub(/\./, '')[[0,2]]"`
1956 fi
Bram Moolenaar165641d2010-02-17 16:23:09 +01001957 RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
Bram Moolenaar81398892012-10-03 21:09:35 +02001958 rubylibs=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LIBS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001959 if test "X$rubylibs" != "X"; then
1960 RUBY_LIBS="$rubylibs"
1961 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001962 librubyarg=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBYARG']])"`
1963 librubya=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBY_A']])"`
Bram Moolenaarac499e32013-06-02 19:14:17 +02001964 rubylibdir=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['libdir']])"`
Bram Moolenaar948733a2011-05-05 18:10:16 +02001965 if test -f "$rubylibdir/$librubya"; then
1966 librubyarg="$librubyarg"
Bram Moolenaarac499e32013-06-02 19:14:17 +02001967 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
1968 elif test "$librubyarg" = "libruby.a"; then
1969 dnl required on Mac OS 10.3 where libruby.a doesn't exist
1970 librubyarg="-lruby"
1971 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001972 fi
1973
1974 if test "X$librubyarg" != "X"; then
1975 RUBY_LIBS="$librubyarg $RUBY_LIBS"
1976 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001977 rubyldflags=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LDFLAGS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001978 if test "X$rubyldflags" != "X"; then
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001979 dnl Ruby on Mac OS X 10.5 adds "-arch" flags but these should only
1980 dnl be included if requested by passing --with-mac-arch to
1981 dnl configure, so strip these flags first (if present)
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001982 rubyldflags=`echo "$rubyldflags" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001983 if test "X$rubyldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001984 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$rubyldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001985 LDFLAGS="$rubyldflags $LDFLAGS"
1986 fi
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001987 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001988 fi
1989 RUBY_SRC="if_ruby.c"
1990 RUBY_OBJ="objects/if_ruby.o"
1991 RUBY_PRO="if_ruby.pro"
1992 AC_DEFINE(FEAT_RUBY)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001993 if test "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar92021622017-10-12 12:33:43 +02001994 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_ALIASES']].split[[0]]"`
Bram Moolenaar87ea64c2018-08-04 15:13:34 +02001995 if test -z "$libruby_soname"; then
1996 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_SO']]"`
1997 fi
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001998 AC_DEFINE(DYNAMIC_RUBY)
Bram Moolenaar41a41412020-01-07 21:32:19 +01001999 RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby_soname\\\" $RUBY_CFLAGS"
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002000 RUBY_LIBS=
2001 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002002 else
Bram Moolenaar165641d2010-02-17 16:23:09 +01002003 AC_MSG_RESULT(not found; disabling Ruby)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002004 fi
2005 else
2006 AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
2007 fi
2008 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01002009
2010 if test "$fail_if_missing" = "yes" -a -z "$RUBY_OBJ"; then
2011 AC_MSG_ERROR([could not configure Ruby])
2012 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002013fi
2014AC_SUBST(RUBY_SRC)
2015AC_SUBST(RUBY_OBJ)
2016AC_SUBST(RUBY_PRO)
2017AC_SUBST(RUBY_CFLAGS)
2018AC_SUBST(RUBY_LIBS)
2019
2020AC_MSG_CHECKING(--enable-cscope argument)
2021AC_ARG_ENABLE(cscope,
2022 [ --enable-cscope Include cscope interface.], ,
2023 [enable_cscope="no"])
2024AC_MSG_RESULT($enable_cscope)
2025if test "$enable_cscope" = "yes"; then
2026 AC_DEFINE(FEAT_CSCOPE)
2027fi
2028
Bram Moolenaar071d4272004-06-13 20:20:40 +00002029AC_MSG_CHECKING(--disable-netbeans argument)
2030AC_ARG_ENABLE(netbeans,
2031 [ --disable-netbeans Disable NetBeans integration support.],
2032 , [enable_netbeans="yes"])
2033if test "$enable_netbeans" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002034 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2035 AC_MSG_RESULT([cannot use NetBeans with tiny or small features])
2036 enable_netbeans="no"
2037 else
2038 AC_MSG_RESULT(no)
2039 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002040else
2041 AC_MSG_RESULT(yes)
2042fi
2043
2044AC_MSG_CHECKING(--disable-channel argument)
2045AC_ARG_ENABLE(channel,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002046 [ --disable-channel Disable process communication support.],
Bram Moolenaare0874f82016-01-24 20:36:41 +01002047 , [enable_channel="yes"])
2048if test "$enable_channel" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002049 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2050 AC_MSG_RESULT([cannot use channels with tiny or small features])
2051 enable_channel="no"
2052 else
2053 AC_MSG_RESULT(no)
2054 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002055else
2056 if test "$enable_netbeans" = "yes"; then
Bram Moolenaar16435482016-01-24 21:31:54 +01002057 AC_MSG_RESULT([yes, netbeans also disabled])
Bram Moolenaare0874f82016-01-24 20:36:41 +01002058 enable_netbeans="no"
2059 else
2060 AC_MSG_RESULT(yes)
2061 fi
2062fi
2063
Bram Moolenaar16435482016-01-24 21:31:54 +01002064if test "$enable_channel" = "yes"; then
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002065 dnl On Solaris we need the socket library, or on Haiku the network library.
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002066 if test "x$HAIKU" = "xyes"; then
2067 AC_CHECK_LIB(network, socket)
2068 else
2069 AC_CHECK_LIB(socket, socket)
2070 fi
2071
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002072 AC_CACHE_CHECK([whether compiling with IPv6 networking is possible], [vim_cv_ipv6_networking],
2073 [AC_TRY_LINK([
2074#include <stdio.h>
2075#include <stdlib.h>
2076#include <stdarg.h>
2077#include <fcntl.h>
2078#include <netdb.h>
2079#include <netinet/in.h>
2080#include <errno.h>
2081#include <sys/types.h>
2082#include <sys/socket.h>
2083 /* Check bitfields */
2084 struct nbbuf {
2085 unsigned int initDone:1;
2086 unsigned short signmaplen;
2087 };
2088 ], [
2089 /* Check creating a socket. */
2090 struct sockaddr_in server;
2091 struct addrinfo *res;
2092 (void)socket(AF_INET, SOCK_STREAM, 0);
2093 (void)htons(100);
2094 (void)getaddrinfo("microsoft.com", NULL, NULL, &res);
2095 if (errno == ECONNREFUSED)
2096 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
2097 (void)freeaddrinfo(res);
2098 ],
2099 [vim_cv_ipv6_networking="yes"],
2100 [vim_cv_ipv6_networking="no"])])
2101
2102 if test "x$vim_cv_ipv6_networking" = "xyes"; then
2103 AC_DEFINE(FEAT_IPV6)
Bram Moolenaarb6fb0512020-04-18 18:24:18 +02002104 AC_CHECK_FUNCS(inet_ntop)
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002105 else
2106 dnl On Solaris we need the nsl library.
2107 AC_CHECK_LIB(nsl, gethostbyname)
2108 AC_CACHE_CHECK([whether compiling with IPv4 networking is possible], [vim_cv_ipv4_networking],
2109 [AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00002110#include <stdio.h>
2111#include <stdlib.h>
2112#include <stdarg.h>
2113#include <fcntl.h>
2114#include <netdb.h>
2115#include <netinet/in.h>
2116#include <errno.h>
2117#include <sys/types.h>
2118#include <sys/socket.h>
2119 /* Check bitfields */
2120 struct nbbuf {
2121 unsigned int initDone:1;
Bram Moolenaar63de19e2016-12-09 20:11:26 +01002122 unsigned short signmaplen;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002123 };
2124 ], [
2125 /* Check creating a socket. */
2126 struct sockaddr_in server;
2127 (void)socket(AF_INET, SOCK_STREAM, 0);
2128 (void)htons(100);
2129 (void)gethostbyname("microsoft.com");
2130 if (errno == ECONNREFUSED)
2131 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
2132 ],
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002133 [vim_cv_ipv4_networking="yes"],
2134 [vim_cv_ipv4_networking="no"; enable_netbeans="no"; enable_channel="no"])])
2135 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002136fi
2137if test "$enable_netbeans" = "yes"; then
2138 AC_DEFINE(FEAT_NETBEANS_INTG)
2139 NETBEANS_SRC="netbeans.c"
2140 AC_SUBST(NETBEANS_SRC)
2141 NETBEANS_OBJ="objects/netbeans.o"
2142 AC_SUBST(NETBEANS_OBJ)
2143fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002144if test "$enable_channel" = "yes"; then
Bram Moolenaar509ce2a2016-03-11 22:52:15 +01002145 AC_DEFINE(FEAT_JOB_CHANNEL)
Bram Moolenaare0874f82016-01-24 20:36:41 +01002146 CHANNEL_SRC="channel.c"
2147 AC_SUBST(CHANNEL_SRC)
2148 CHANNEL_OBJ="objects/channel.o"
2149 AC_SUBST(CHANNEL_OBJ)
2150fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002151
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002152AC_MSG_CHECKING(--enable-terminal argument)
2153AC_ARG_ENABLE(terminal,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002154 [ --enable-terminal Enable terminal emulation support.],
Bram Moolenaaref839562017-10-28 20:28:23 +02002155 , [enable_terminal="auto"])
Bram Moolenaar595a4022017-09-03 19:15:57 +02002156if test "$enable_terminal" = "yes" || test "$enable_terminal" = "auto" -a "x$features" = "xhuge" ; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002157 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2158 AC_MSG_RESULT([cannot use terminal emulator with tiny or small features])
2159 enable_terminal="no"
2160 else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002161 if test "$enable_terminal" = "auto"; then
2162 enable_terminal="yes"
2163 AC_MSG_RESULT(defaulting to yes)
2164 else
2165 AC_MSG_RESULT(yes)
2166 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002167 fi
2168else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002169 if test "$enable_terminal" = "auto"; then
2170 enable_terminal="no"
2171 AC_MSG_RESULT(defaulting to no)
2172 else
2173 AC_MSG_RESULT(no)
2174 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002175fi
Bram Moolenaar8b423282017-12-16 14:37:06 +01002176if test "$enable_terminal" = "yes" -a "$enable_channel" = "yes"; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002177 AC_DEFINE(FEAT_TERMINAL)
Bram Moolenaar93268052019-10-10 13:22:54 +02002178 TERM_SRC="libvterm/src/encoding.c libvterm/src/keyboard.c libvterm/src/mouse.c libvterm/src/parser.c libvterm/src/pen.c libvterm/src/creen.c libvterm/src/state.c libvterm/src/unicode.c libvterm/src/vterm.c"
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002179 AC_SUBST(TERM_SRC)
Bram Moolenaar93268052019-10-10 13:22:54 +02002180 TERM_OBJ="objects/vterm_encoding.o objects/vterm_keyboard.o objects/vterm_mouse.o objects/vterm_parser.o objects/vterm_pen.o objects/vterm_screen.o objects/vterm_state.o objects/vterm_unicode.o objects/vterm_vterm.o"
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002181 AC_SUBST(TERM_OBJ)
Bram Moolenaar823edd12019-10-23 22:35:36 +02002182 TERM_TEST="test_libvterm"
2183 AC_SUBST(TERM_TEST)
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002184fi
2185
Bram Moolenaare42a6d22017-11-12 19:21:51 +01002186AC_MSG_CHECKING(--enable-autoservername argument)
2187AC_ARG_ENABLE(autoservername,
2188 [ --enable-autoservername Automatically define servername at vim startup.], ,
2189 [enable_autoservername="no"])
2190AC_MSG_RESULT($enable_autoservername)
2191if test "$enable_autoservername" = "yes"; then
2192 AC_DEFINE(FEAT_AUTOSERVERNAME)
2193fi
2194
Bram Moolenaar071d4272004-06-13 20:20:40 +00002195AC_MSG_CHECKING(--enable-multibyte argument)
2196AC_ARG_ENABLE(multibyte,
2197 [ --enable-multibyte Include multibyte editing support.], ,
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01002198 [enable_multibyte="yes"])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002199AC_MSG_RESULT($enable_multibyte)
Bram Moolenaar30276f22019-01-24 17:59:39 +01002200if test "$enable_multibyte" != "yes"; then
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01002201 AC_MSG_ERROR([The multi-byte feature can no longer be disabled. If you have
2202 a problem with this, discuss on the Vim mailing list.])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002203fi
2204
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002205dnl Right-to-Left language support for Vim will be included with big features,
2206dnl unless ENABLE_RIGHTLEFT is undefined.
2207AC_MSG_CHECKING(--disable-rightleft argument)
2208AC_ARG_ENABLE(rightleft,
2209 [ --disable-rightleft Do not include Right-to-Left language support.],
2210 , [enable_rightleft="yes"])
2211if test "$enable_rightleft" = "yes"; then
2212 AC_MSG_RESULT(no)
2213else
2214 AC_MSG_RESULT(yes)
2215 AC_DEFINE(DISABLE_RIGHTLEFT)
2216fi
2217
2218dnl Arabic language support for Vim will be included with big features,
2219dnl unless ENABLE_ARABIC is undefined.
2220AC_MSG_CHECKING(--disable-arabic argument)
2221AC_ARG_ENABLE(arabic,
2222 [ --disable-arabic Do not include Arabic language support.],
2223 , [enable_arabic="yes"])
2224if test "$enable_arabic" = "yes"; then
2225 AC_MSG_RESULT(no)
2226else
2227 AC_MSG_RESULT(yes)
2228 AC_DEFINE(DISABLE_ARABIC)
2229fi
2230
Bram Moolenaar14184a32019-02-16 15:10:30 +01002231dnl Farsi language support has been removed, ignore --disable-farsi
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002232AC_ARG_ENABLE(farsi,
Bram Moolenaar14184a32019-02-16 15:10:30 +01002233 [ --disable-farsi Deprecated.],,)
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002234
Bram Moolenaar071d4272004-06-13 20:20:40 +00002235AC_MSG_CHECKING(--enable-xim argument)
2236AC_ARG_ENABLE(xim,
2237 [ --enable-xim Include XIM input support.],
2238 AC_MSG_RESULT($enable_xim),
2239 [enable_xim="auto"; AC_MSG_RESULT(defaulting to auto)])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002240
2241AC_MSG_CHECKING(--enable-fontset argument)
2242AC_ARG_ENABLE(fontset,
2243 [ --enable-fontset Include X fontset output support.], ,
2244 [enable_fontset="no"])
2245AC_MSG_RESULT($enable_fontset)
2246dnl defining FEAT_XFONTSET is delayed, so that it can be disabled for no GUI
2247
2248test -z "$with_x" && with_x=yes
Bram Moolenaard0573012017-10-28 21:11:06 +02002249test "${enable_gui-yes}" != no -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && with_x=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002250if test "$with_x" = no; then
2251 AC_MSG_RESULT(defaulting to: don't HAVE_X11)
2252else
2253 dnl Do this check early, so that its failure can override user requests.
2254
2255 AC_PATH_PROG(xmkmfpath, xmkmf)
2256
2257 AC_PATH_XTRA
2258
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002259 dnl On z/OS Unix the X libraries are DLLs. To use them the code must
Bram Moolenaar071d4272004-06-13 20:20:40 +00002260 dnl be compiled with a special option.
2261 dnl Also add SM, ICE and Xmu to X_EXTRA_LIBS.
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002262 if test "$zOSUnix" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002263 CFLAGS="$CFLAGS -W c,dll"
2264 LDFLAGS="$LDFLAGS -W l,dll"
2265 X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE -lXmu"
2266 fi
2267
2268 dnl On my HPUX system the X include dir is found, but the lib dir not.
Bram Moolenaar70778922020-02-05 20:44:24 +01002269 dnl This is a desperate try to fix this.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002270
2271 if test -d "$x_includes" && test ! -d "$x_libraries"; then
2272 x_libraries=`echo "$x_includes" | sed s/include/lib/`
2273 AC_MSG_RESULT(Corrected X libraries to $x_libraries)
2274 X_LIBS="$X_LIBS -L$x_libraries"
2275 if test "`(uname) 2>/dev/null`" = SunOS &&
2276 uname -r | grep '^5' >/dev/null; then
2277 X_LIBS="$X_LIBS -R $x_libraries"
2278 fi
2279 fi
2280
2281 if test -d "$x_libraries" && test ! -d "$x_includes"; then
2282 x_includes=`echo "$x_libraries" | sed s/lib/include/`
2283 AC_MSG_RESULT(Corrected X includes to $x_includes)
2284 X_CFLAGS="$X_CFLAGS -I$x_includes"
2285 fi
2286
2287 dnl Remove "-I/usr/include " from X_CFLAGS, should not be needed.
2288 X_CFLAGS="`echo $X_CFLAGS\ | sed 's%-I/usr/include %%'`"
2289 dnl Remove "-L/usr/lib " from X_LIBS, should not be needed.
2290 X_LIBS="`echo $X_LIBS\ | sed 's%-L/usr/lib %%'`"
2291 dnl Same for "-R/usr/lib ".
2292 X_LIBS="`echo $X_LIBS\ | sed -e 's%-R/usr/lib %%' -e 's%-R /usr/lib %%'`"
2293
2294
2295 dnl Check if the X11 header files are correctly installed. On some systems
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002296 dnl Xlib.h includes files that don't exist. On some systems X11/Intrinsic.h
2297 dnl is missing.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002298 AC_MSG_CHECKING(if X11 header files can be found)
2299 cflags_save=$CFLAGS
2300 CFLAGS="$CFLAGS $X_CFLAGS"
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002301 AC_TRY_COMPILE([#include <X11/Xlib.h>
2302#include <X11/Intrinsic.h>], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002303 AC_MSG_RESULT(yes),
2304 AC_MSG_RESULT(no); no_x=yes)
2305 CFLAGS=$cflags_save
2306
2307 if test "${no_x-no}" = yes; then
2308 with_x=no
2309 else
2310 AC_DEFINE(HAVE_X11)
2311 X_LIB="-lXt -lX11";
2312 AC_SUBST(X_LIB)
2313
2314 ac_save_LDFLAGS="$LDFLAGS"
2315 LDFLAGS="-L$x_libraries $LDFLAGS"
2316
2317 dnl Check for -lXdmcp (needed on SunOS 4.1.4)
2318 dnl For HP-UX 10.20 it must be before -lSM -lICE
2319 AC_CHECK_LIB(Xdmcp, _XdmcpAuthDoIt, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lXdmcp"],,
2320 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXdmcp])
2321
2322 dnl Some systems need -lnsl -lsocket when testing for ICE.
2323 dnl The check above doesn't do this, try here (again). Also needed to get
2324 dnl them after Xdmcp. link.sh will remove them when not needed.
2325 dnl Check for other function than above to avoid the cached value
2326 AC_CHECK_LIB(ICE, IceOpenConnection,
2327 [X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE"],, [$X_EXTRA_LIBS])
2328
2329 dnl Check for -lXpm (needed for some versions of Motif)
2330 LDFLAGS="$X_LIBS $ac_save_LDFLAGS"
2331 AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [X_PRE_LIBS="$X_PRE_LIBS -lXpm"],,
2332 [-lXt $X_PRE_LIBS -lXpm -lX11 $X_EXTRA_LIBS])
2333
2334 dnl Check that the X11 header files don't use implicit declarations
2335 AC_MSG_CHECKING(if X11 header files implicitly declare return values)
2336 cflags_save=$CFLAGS
Bram Moolenaard1864592013-05-04 04:40:15 +02002337 dnl -Werror is GCC only, others like Solaris Studio might not like it
2338 if test "$GCC" = yes; then
2339 CFLAGS="$CFLAGS $X_CFLAGS -Werror"
2340 else
2341 CFLAGS="$CFLAGS $X_CFLAGS"
2342 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002343 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2344 AC_MSG_RESULT(no),
2345 CFLAGS="$CFLAGS -Wno-implicit-int"
2346 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2347 AC_MSG_RESULT(yes); cflags_save="$cflags_save -Wno-implicit-int",
2348 AC_MSG_RESULT(test failed)
2349 )
2350 )
2351 CFLAGS=$cflags_save
2352
2353 LDFLAGS="$ac_save_LDFLAGS"
2354
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002355 AC_MSG_CHECKING(size of wchar_t is 2 bytes)
2356 AC_CACHE_VAL(ac_cv_small_wchar_t,
2357 [AC_TRY_RUN([
2358#include <X11/Xlib.h>
2359#if STDC_HEADERS
2360# include <stdlib.h>
2361# include <stddef.h>
2362#endif
2363 main()
2364 {
2365 if (sizeof(wchar_t) <= 2)
2366 exit(1);
2367 exit(0);
2368 }],
2369 ac_cv_small_wchar_t="no",
2370 ac_cv_small_wchar_t="yes",
2371 AC_MSG_ERROR(failed to compile test program))])
2372 AC_MSG_RESULT($ac_cv_small_wchar_t)
2373 if test "x$ac_cv_small_wchar_t" = "xyes" ; then
2374 AC_DEFINE(SMALL_WCHAR_T)
2375 fi
2376
Bram Moolenaar071d4272004-06-13 20:20:40 +00002377 fi
2378fi
2379
Bram Moolenaard2a05492018-07-27 22:35:15 +02002380dnl Check if --with-x was given but it doesn't work.
2381if test "x$with_x" = xno -a "x$with_x_arg" = xyes; then
2382 AC_MSG_ERROR([could not configure X])
2383fi
2384
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002385test "x$with_x" = xno -a "x$HAIKU" != "xyes" -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && enable_gui=no
Bram Moolenaar071d4272004-06-13 20:20:40 +00002386
2387AC_MSG_CHECKING(--enable-gui argument)
2388AC_ARG_ENABLE(gui,
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002389 [ --enable-gui[=OPTS] X11 GUI. [default=auto] [OPTS=auto/no/gtk2/gnome2/gtk3/motif/athena/neXtaw/haiku/photon/carbon]], , enable_gui="auto")
Bram Moolenaar071d4272004-06-13 20:20:40 +00002390
2391dnl Canonicalize the --enable-gui= argument so that it can be easily compared.
2392dnl Do not use character classes for portability with old tools.
2393enable_gui_canon=`echo "_$enable_gui" | \
2394 sed 's/[[ _+-]]//g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
2395
2396dnl Skip everything by default.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002397SKIP_GTK2=YES
Bram Moolenaar1858a842016-02-23 22:30:31 +01002398SKIP_GTK3=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002399SKIP_GNOME=YES
2400SKIP_MOTIF=YES
2401SKIP_ATHENA=YES
2402SKIP_NEXTAW=YES
2403SKIP_PHOTON=YES
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002404SKIP_HAIKU=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002405GUITYPE=NONE
2406
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002407if test "x$HAIKU" = "xyes"; then
2408 SKIP_HAIKU=
2409 case "$enable_gui_canon" in
2410 no) AC_MSG_RESULT(no GUI support)
2411 SKIP_HAIKU=YES ;;
2412 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
2413 auto) AC_MSG_RESULT(auto - automatic GUI support) ;;
2414 haiku) AC_MSG_RESULT(Haiku GUI support) ;;
2415 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2416 SKIP_HAIKU=YES ;;
2417 esac
2418elif test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002419 SKIP_PHOTON=
2420 case "$enable_gui_canon" in
2421 no) AC_MSG_RESULT(no GUI support)
2422 SKIP_PHOTON=YES ;;
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002423 yes|""|auto) AC_MSG_RESULT(automatic GUI support)
2424 gui_auto=yes ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002425 photon) AC_MSG_RESULT(Photon GUI support) ;;
2426 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2427 SKIP_PHOTON=YES ;;
2428 esac
2429
Bram Moolenaar040f9752020-08-11 23:08:48 +02002430elif test "x$MACOS_X" = "xyes" -a "x$with_x" = "xno" ; then
2431 case "$enable_gui_canon" in
2432 no) AC_MSG_RESULT(no GUI support) ;;
2433 yes|"") AC_MSG_RESULT(yes - automatic GUI support)
2434 gui_auto=yes ;;
2435 auto) AC_MSG_RESULT(auto - disable GUI support for Mac OS) ;;
2436 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2437 SKIP_CARBON=YES ;;
2438 esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00002439else
2440
Bram Moolenaar071d4272004-06-13 20:20:40 +00002441 case "$enable_gui_canon" in
2442 no|none) AC_MSG_RESULT(no GUI support) ;;
2443 yes|""|auto) AC_MSG_RESULT(yes/auto - automatic GUI support)
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002444 gui_auto=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002445 SKIP_GTK2=
2446 SKIP_GNOME=
2447 SKIP_MOTIF=
2448 SKIP_ATHENA=
Bram Moolenaar097148e2020-08-11 21:58:20 +02002449 SKIP_NEXTAW=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002450 gtk2) AC_MSG_RESULT(GTK+ 2.x GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002451 SKIP_GTK2=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002452 gnome2) AC_MSG_RESULT(GNOME 2.x GUI support)
2453 SKIP_GNOME=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002454 SKIP_GTK2=;;
Bram Moolenaar98921892016-02-23 17:14:37 +01002455 gtk3) AC_MSG_RESULT(GTK+ 3.x GUI support)
2456 SKIP_GTK3=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002457 motif) AC_MSG_RESULT(Motif GUI support)
2458 SKIP_MOTIF=;;
2459 athena) AC_MSG_RESULT(Athena GUI support)
2460 SKIP_ATHENA=;;
2461 nextaw) AC_MSG_RESULT(neXtaw GUI support)
2462 SKIP_NEXTAW=;;
2463 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
2464 esac
2465
2466fi
2467
Bram Moolenaar071d4272004-06-13 20:20:40 +00002468if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \
2469 -a "$enable_gui_canon" != "gnome2"; then
2470 AC_MSG_CHECKING(whether or not to look for GTK+ 2)
2471 AC_ARG_ENABLE(gtk2-check,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002472 [ --enable-gtk2-check If auto-select GUI, check for GTK+ 2 [default=yes]],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002473 , enable_gtk2_check="yes")
2474 AC_MSG_RESULT($enable_gtk2_check)
2475 if test "x$enable_gtk2_check" = "xno"; then
2476 SKIP_GTK2=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002477 SKIP_GNOME=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002478 fi
2479fi
2480
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002481if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002482 AC_MSG_CHECKING(whether or not to look for GNOME)
2483 AC_ARG_ENABLE(gnome-check,
2484 [ --enable-gnome-check If GTK GUI, check for GNOME [default=no]],
2485 , enable_gnome_check="no")
2486 AC_MSG_RESULT($enable_gnome_check)
2487 if test "x$enable_gnome_check" = "xno"; then
2488 SKIP_GNOME=YES
2489 fi
2490fi
2491
Bram Moolenaar98921892016-02-23 17:14:37 +01002492if test "x$SKIP_GTK3" != "xYES" -a "$enable_gui_canon" != "gtk3"; then
2493 AC_MSG_CHECKING(whether or not to look for GTK+ 3)
2494 AC_ARG_ENABLE(gtk3-check,
2495 [ --enable-gtk3-check If auto-select GUI, check for GTK+ 3 [default=yes]],
2496 , enable_gtk3_check="yes")
2497 AC_MSG_RESULT($enable_gtk3_check)
2498 if test "x$enable_gtk3_check" = "xno"; then
2499 SKIP_GTK3=YES
2500 fi
2501fi
2502
Bram Moolenaar071d4272004-06-13 20:20:40 +00002503if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then
2504 AC_MSG_CHECKING(whether or not to look for Motif)
2505 AC_ARG_ENABLE(motif-check,
2506 [ --enable-motif-check If auto-select GUI, check for Motif [default=yes]],
2507 , enable_motif_check="yes")
2508 AC_MSG_RESULT($enable_motif_check)
2509 if test "x$enable_motif_check" = "xno"; then
2510 SKIP_MOTIF=YES
2511 fi
2512fi
2513
2514if test "x$SKIP_ATHENA" != "xYES" -a "$enable_gui_canon" != "athena"; then
2515 AC_MSG_CHECKING(whether or not to look for Athena)
2516 AC_ARG_ENABLE(athena-check,
2517 [ --enable-athena-check If auto-select GUI, check for Athena [default=yes]],
2518 , enable_athena_check="yes")
2519 AC_MSG_RESULT($enable_athena_check)
2520 if test "x$enable_athena_check" = "xno"; then
2521 SKIP_ATHENA=YES
2522 fi
2523fi
2524
2525if test "x$SKIP_NEXTAW" != "xYES" -a "$enable_gui_canon" != "nextaw"; then
2526 AC_MSG_CHECKING(whether or not to look for neXtaw)
2527 AC_ARG_ENABLE(nextaw-check,
2528 [ --enable-nextaw-check If auto-select GUI, check for neXtaw [default=yes]],
2529 , enable_nextaw_check="yes")
2530 AC_MSG_RESULT($enable_nextaw_check);
2531 if test "x$enable_nextaw_check" = "xno"; then
2532 SKIP_NEXTAW=YES
2533 fi
2534fi
2535
Bram Moolenaar071d4272004-06-13 20:20:40 +00002536dnl define an autoconf function to check for a specified version of GTK, and
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002537dnl try to compile/link a GTK program.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002538dnl
2539dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002540dnl Test for GTK, and define GTK_CFLAGS, GTK_LIBDIR and GTK_LIBS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002541dnl
2542AC_DEFUN(AM_PATH_GTK,
2543[
2544 if test "X$GTK_CONFIG" != "Xno" -o "X$PKG_CONFIG" != "Xno"; then
2545 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00002546 no_gtk=""
2547 if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2548 && $PKG_CONFIG --exists gtk+-2.0; then
2549 {
Bram Moolenaar98921892016-02-23 17:14:37 +01002550 min_gtk_version=ifelse([$1], ,2.2.0,$1)
2551 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002552 dnl We should be using PKG_CHECK_MODULES() instead of this hack.
2553 dnl But I guess the dependency on pkgconfig.m4 is not wanted or
2554 dnl something like that.
2555 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0`
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002556 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-2.0`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002557 GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0`
2558 gtk_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2559 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2560 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2561 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2562 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2563 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2564 }
Bram Moolenaar98921892016-02-23 17:14:37 +01002565 elif (test "X$SKIP_GTK3" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2566 && $PKG_CONFIG --exists gtk+-3.0; then
2567 {
2568 min_gtk_version=ifelse([$1], ,3.0.0,$1)
2569 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
2570
2571 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-3.0`
2572 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-3.0`
2573 GTK_LIBS=`$PKG_CONFIG --libs gtk+-3.0`
2574 gtk_major_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2575 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2576 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2577 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2578 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2579 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2580 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002581 else
2582 no_gtk=yes
2583 fi
2584
2585 if test "x$enable_gtktest" = "xyes" -a "x$no_gtk" = "x"; then
2586 {
2587 ac_save_CFLAGS="$CFLAGS"
2588 ac_save_LIBS="$LIBS"
2589 CFLAGS="$CFLAGS $GTK_CFLAGS"
2590 LIBS="$LIBS $GTK_LIBS"
2591
2592 dnl
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002593 dnl Now check if the installed GTK is sufficiently new.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002594 dnl
2595 rm -f conf.gtktest
2596 AC_TRY_RUN([
2597#include <gtk/gtk.h>
2598#include <stdio.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00002599#if STDC_HEADERS
2600# include <stdlib.h>
2601# include <stddef.h>
2602#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002603
2604int
2605main ()
2606{
2607int major, minor, micro;
2608char *tmp_version;
2609
2610system ("touch conf.gtktest");
2611
2612/* HP/UX 9 (%@#!) writes to sscanf strings */
2613tmp_version = g_strdup("$min_gtk_version");
2614if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
2615 printf("%s, bad version string\n", "$min_gtk_version");
2616 exit(1);
2617 }
2618
2619if ((gtk_major_version > major) ||
2620 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
2621 ((gtk_major_version == major) && (gtk_minor_version == minor) &&
2622 (gtk_micro_version >= micro)))
2623{
2624 return 0;
2625}
2626return 1;
2627}
2628],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
2629 CFLAGS="$ac_save_CFLAGS"
2630 LIBS="$ac_save_LIBS"
2631 }
2632 fi
2633 if test "x$no_gtk" = x ; then
2634 if test "x$enable_gtktest" = "xyes"; then
2635 AC_MSG_RESULT(yes; found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2636 else
2637 AC_MSG_RESULT(found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2638 fi
2639 ifelse([$2], , :, [$2])
2640 else
2641 {
2642 AC_MSG_RESULT(no)
2643 GTK_CFLAGS=""
2644 GTK_LIBS=""
2645 ifelse([$3], , :, [$3])
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002646 if test "$fail_if_missing" = "yes" -a "X$gui_auto" != "Xyes"; then
2647 AC_MSG_ERROR([could not configure GTK])
2648 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002649 }
2650 fi
2651 }
2652 else
2653 GTK_CFLAGS=""
2654 GTK_LIBS=""
2655 ifelse([$3], , :, [$3])
2656 fi
2657 AC_SUBST(GTK_CFLAGS)
2658 AC_SUBST(GTK_LIBS)
2659 rm -f conf.gtktest
2660])
2661
2662dnl ---------------------------------------------------------------------------
2663dnl gnome
2664dnl ---------------------------------------------------------------------------
2665AC_DEFUN([GNOME_INIT_HOOK],
2666[
2667 AC_SUBST(GNOME_LIBS)
2668 AC_SUBST(GNOME_LIBDIR)
2669 AC_SUBST(GNOME_INCLUDEDIR)
2670
2671 AC_ARG_WITH(gnome-includes,
2672 [ --with-gnome-includes=DIR Specify location of GNOME headers],
2673 [CFLAGS="$CFLAGS -I$withval"]
2674 )
2675
2676 AC_ARG_WITH(gnome-libs,
2677 [ --with-gnome-libs=DIR Specify location of GNOME libs],
2678 [LDFLAGS="$LDFLAGS -L$withval" gnome_prefix=$withval]
2679 )
2680
2681 AC_ARG_WITH(gnome,
2682 [ --with-gnome Specify prefix for GNOME files],
2683 if test x$withval = xyes; then
2684 want_gnome=yes
2685 ifelse([$1], [], :, [$1])
2686 else
2687 if test "x$withval" = xno; then
2688 want_gnome=no
2689 else
2690 want_gnome=yes
2691 LDFLAGS="$LDFLAGS -L$withval/lib"
2692 CFLAGS="$CFLAGS -I$withval/include"
2693 gnome_prefix=$withval/lib
2694 fi
2695 fi,
2696 want_gnome=yes)
2697
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002698 if test "x$want_gnome" = xyes; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002699 {
2700 AC_MSG_CHECKING(for libgnomeui-2.0)
2701 if $PKG_CONFIG --exists libgnomeui-2.0; then
2702 AC_MSG_RESULT(yes)
2703 GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0`
2704 GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0`
2705 GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0`
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002706
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002707 dnl On FreeBSD we need -pthread but pkg-config doesn't include it.
2708 dnl This might not be the right way but it works for me...
2709 AC_MSG_CHECKING(for FreeBSD)
2710 if test "`(uname) 2>/dev/null`" = FreeBSD; then
2711 AC_MSG_RESULT(yes, adding -pthread)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002712 GNOME_INCLUDEDIR="$GNOME_INCLUDEDIR -D_THREAD_SAFE"
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002713 GNOME_LIBS="$GNOME_LIBS -pthread"
2714 else
2715 AC_MSG_RESULT(no)
2716 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002717 $1
2718 else
2719 AC_MSG_RESULT(not found)
2720 if test "x$2" = xfail; then
2721 AC_MSG_ERROR(Could not find libgnomeui-2.0 via pkg-config)
2722 fi
2723 fi
2724 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002725 fi
2726])
2727
2728AC_DEFUN([GNOME_INIT],[
2729 GNOME_INIT_HOOK([],fail)
2730])
2731
Bram Moolenaar427f5b62019-06-09 13:43:51 +02002732if test "X$PKG_CONFIG" = "X"; then
2733 AC_PATH_TOOL(PKG_CONFIG, pkg-config, no)
2734fi
2735
Bram Moolenaar071d4272004-06-13 20:20:40 +00002736
2737dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002738dnl Check for GTK2. If it fails, then continue on for Motif as before...
Bram Moolenaar071d4272004-06-13 20:20:40 +00002739dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002740if test -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002741
2742 AC_MSG_CHECKING(--disable-gtktest argument)
2743 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2744 , enable_gtktest=yes)
2745 if test "x$enable_gtktest" = "xyes" ; then
2746 AC_MSG_RESULT(gtk test enabled)
2747 else
2748 AC_MSG_RESULT(gtk test disabled)
2749 fi
2750
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002751 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002752 dnl First try finding version 2.2.0 or later. The 2.0.x series has
2753 dnl problems (bold fonts, --remote doesn't work).
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002754 AM_PATH_GTK(2.2.0,
2755 [GUI_LIB_LOC="$GTK_LIBDIR"
2756 GTK_LIBNAME="$GTK_LIBS"
2757 GUI_INC_LOC="$GTK_CFLAGS"], )
2758 if test "x$GTK_CFLAGS" != "x"; then
Bram Moolenaar98921892016-02-23 17:14:37 +01002759 SKIP_GTK3=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002760 SKIP_ATHENA=YES
2761 SKIP_NEXTAW=YES
2762 SKIP_MOTIF=YES
2763 GUITYPE=GTK
2764 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002765 fi
2766 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002767 if test "x$GUITYPE" = "xGTK"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002768 dnl
2769 dnl if GTK exists, then check for GNOME.
2770 dnl
2771 if test -z "$SKIP_GNOME"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002772 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002773 GNOME_INIT_HOOK([have_gnome=yes])
2774 if test "x$have_gnome" = xyes ; then
2775 AC_DEFINE(FEAT_GUI_GNOME)
2776 GUI_INC_LOC="$GUI_INC_LOC $GNOME_INCLUDEDIR"
2777 GTK_LIBNAME="$GTK_LIBNAME $GNOME_LIBDIR $GNOME_LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002778 fi
2779 }
2780 fi
2781 fi
2782fi
2783
Bram Moolenaar98921892016-02-23 17:14:37 +01002784
2785dnl ---------------------------------------------------------------------------
2786dnl Check for GTK3.
2787dnl ---------------------------------------------------------------------------
2788if test -z "$SKIP_GTK3"; then
2789
2790 AC_MSG_CHECKING(--disable-gtktest argument)
2791 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2792 , enable_gtktest=yes)
2793 if test "x$enable_gtktest" = "xyes" ; then
2794 AC_MSG_RESULT(gtk test enabled)
2795 else
2796 AC_MSG_RESULT(gtk test disabled)
2797 fi
2798
Bram Moolenaar98921892016-02-23 17:14:37 +01002799 if test "x$PKG_CONFIG" != "xno"; then
2800 AM_PATH_GTK(3.0.0,
2801 [GUI_LIB_LOC="$GTK_LIBDIR"
2802 GTK_LIBNAME="$GTK_LIBS"
2803 GUI_INC_LOC="$GTK_CFLAGS"], )
2804 if test "x$GTK_CFLAGS" != "x"; then
2805 SKIP_GTK2=YES
2806 SKIP_GNOME=YES
2807 SKIP_ATHENA=YES
2808 SKIP_NEXTAW=YES
2809 SKIP_MOTIF=YES
2810 GUITYPE=GTK
2811 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar98921892016-02-23 17:14:37 +01002812 AC_DEFINE(USE_GTK3)
2813 fi
2814 fi
2815fi
2816
Bram Moolenaard2e03f02016-01-02 22:46:36 +01002817dnl Check the version of Gdk-Pixbuf. If the version is 2.31 or later and
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002818dnl glib-compile-resources is found in PATH, use GResource.
2819if test "x$GUITYPE" = "xGTK"; then
2820 AC_MSG_CHECKING([version of Gdk-Pixbuf])
2821 gdk_pixbuf_version=`$PKG_CONFIG --modversion gdk-pixbuf-2.0`
2822 if test "x$gdk_pixbuf_version" != x ; then
2823 gdk_pixbuf_version_minor=`echo $gdk_pixbuf_version | \
2824 sed -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/'`
2825 if test "x$gdk_pixbuf_version_minor" != x -a \
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002826 $gdk_pixbuf_version_minor -ge 31 ; then
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002827 AC_MSG_RESULT([OK.])
2828 AC_PATH_PROG(GLIB_COMPILE_RESOURCES,[glib-compile-resources],no)
2829 AC_MSG_CHECKING([glib-compile-resources])
2830 if test "x$GLIB_COMPILE_RESOURCES" = xno ; then
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002831 GLIB_COMPILE_RESOURCES=""
2832 AC_MSG_RESULT([cannot be found in PATH.])
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002833 else
2834 AC_MSG_RESULT([usable.])
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002835 AC_DEFINE(USE_GRESOURCE)
2836 GRESOURCE_SRC="auto/gui_gtk_gresources.c"
2837 GRESOURCE_OBJ="objects/gui_gtk_gresources.o"
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002838 fi
2839 else
2840 AC_MSG_RESULT([not usable.])
2841 fi
2842 else
2843 AC_MSG_RESULT([cannot obtain from pkg_config.])
2844 fi
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002845
2846 AC_MSG_CHECKING([--disable-icon-cache-update argument])
2847 AC_ARG_ENABLE(icon_cache_update,
2848 [ --disable-icon-cache-update update disabled],
2849 [],
2850 [enable_icon_cache_update="yes"])
2851 if test "$enable_icon_cache_update" = "yes"; then
2852 AC_MSG_RESULT([not set])
2853 AC_PATH_PROG(GTK_UPDATE_ICON_CACHE,[gtk-update-icon-cache],no)
2854 if test "x$GTK_UPDATE_ICON_CACHE" = "xno" ; then
2855 AC_MSG_RESULT([not found in PATH.])
2856 fi
2857 else
2858 AC_MSG_RESULT([update disabled])
2859 fi
2860
2861 AC_MSG_CHECKING([--disable-desktop-database-update argument])
2862 AC_ARG_ENABLE(desktop_database_update,
2863 [ --disable-desktop-database-update update disabled],
2864 [],
2865 [enable_desktop_database_update="yes"])
2866 if test "$enable_desktop_database_update" = "yes"; then
2867 AC_MSG_RESULT([not set])
2868 AC_PATH_PROG(UPDATE_DESKTOP_DATABASE,[update-desktop-database],no)
2869 if test "x$UPDATE_DESKTOP_DATABASE" = "xno" ; then
2870 AC_MSG_RESULT([not found in PATH.])
2871 fi
2872 else
2873 AC_MSG_RESULT([update disabled])
2874 fi
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002875fi
2876AC_SUBST(GLIB_COMPILE_RESOURCES)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002877AC_SUBST(GRESOURCE_SRC)
2878AC_SUBST(GRESOURCE_OBJ)
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002879AC_SUBST(GTK_UPDATE_ICON_CACHE)
2880AC_SUBST(UPDATE_DESKTOP_DATABASE)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002881
Bram Moolenaar071d4272004-06-13 20:20:40 +00002882dnl Check for Motif include files location.
2883dnl The LAST one found is used, this makes the highest version to be used,
2884dnl e.g. when Motif1.2 and Motif2.0 are both present.
2885
2886if test -z "$SKIP_MOTIF"; then
2887 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"
2888 dnl Remove "-I" from before $GUI_INC_LOC if it's there
2889 GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`"
2890
2891 AC_MSG_CHECKING(for location of Motif GUI includes)
2892 gui_includes="`echo $x_includes|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC"
2893 GUI_INC_LOC=
2894 for try in $gui_includes; do
2895 if test -f "$try/Xm/Xm.h"; then
2896 GUI_INC_LOC=$try
2897 fi
2898 done
2899 if test -n "$GUI_INC_LOC"; then
2900 if test "$GUI_INC_LOC" = /usr/include; then
2901 GUI_INC_LOC=
2902 AC_MSG_RESULT(in default path)
2903 else
2904 AC_MSG_RESULT($GUI_INC_LOC)
2905 fi
2906 else
2907 AC_MSG_RESULT(<not found>)
2908 SKIP_MOTIF=YES
2909 fi
2910fi
2911
2912dnl Check for Motif library files location. In the same order as the include
2913dnl files, to avoid a mixup if several versions are present
2914
2915if test -z "$SKIP_MOTIF"; then
2916 AC_MSG_CHECKING(--with-motif-lib argument)
2917 AC_ARG_WITH(motif-lib,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002918 [ --with-motif-lib=STRING Library for Motif ],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002919 [ MOTIF_LIBNAME="${withval}" ] )
2920
2921 if test -n "$MOTIF_LIBNAME"; then
2922 AC_MSG_RESULT($MOTIF_LIBNAME)
2923 GUI_LIB_LOC=
2924 else
2925 AC_MSG_RESULT(no)
2926
2927 dnl Remove "-L" from before $GUI_LIB_LOC if it's there
2928 GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
2929
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002930 dnl Ubuntu has libXm.so in /usr/lib/i386-linux-gnu and elsewhere. The
2931 dnl linker will figure out which one to use, we only check if one exists.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002932 AC_MSG_CHECKING(for location of Motif GUI libs)
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002933 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 +00002934 GUI_LIB_LOC=
2935 for try in $gui_libs; do
Bram Moolenaar325b7a22004-07-05 15:58:32 +00002936 for libtry in "$try"/libXm.a "$try"/libXm.so* "$try"/libXm.sl "$try"/libXm.dylib; do
Bram Moolenaar071d4272004-06-13 20:20:40 +00002937 if test -f "$libtry"; then
2938 GUI_LIB_LOC=$try
2939 fi
2940 done
2941 done
2942 if test -n "$GUI_LIB_LOC"; then
2943 dnl Remove /usr/lib, it causes trouble on some systems
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002944 if test "$GUI_LIB_LOC" = /usr/lib \
2945 -o "$GUI_LIB_LOC" = /usr/lib/i386-linux-gnu \
2946 -o "$GUI_LIB_LOC" = /usr/lib/x86_64-linux-gnu; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002947 GUI_LIB_LOC=
2948 AC_MSG_RESULT(in default path)
2949 else
2950 if test -n "$GUI_LIB_LOC"; then
2951 AC_MSG_RESULT($GUI_LIB_LOC)
2952 if test "`(uname) 2>/dev/null`" = SunOS &&
2953 uname -r | grep '^5' >/dev/null; then
2954 GUI_LIB_LOC="$GUI_LIB_LOC -R $GUI_LIB_LOC"
2955 fi
2956 fi
2957 fi
2958 MOTIF_LIBNAME=-lXm
2959 else
2960 AC_MSG_RESULT(<not found>)
2961 SKIP_MOTIF=YES
2962 fi
2963 fi
2964fi
2965
2966if test -z "$SKIP_MOTIF"; then
2967 SKIP_ATHENA=YES
2968 SKIP_NEXTAW=YES
2969 GUITYPE=MOTIF
2970 AC_SUBST(MOTIF_LIBNAME)
2971fi
2972
2973dnl Check if the Athena files can be found
2974
2975GUI_X_LIBS=
2976
2977if test -z "$SKIP_ATHENA"; then
2978 AC_MSG_CHECKING(if Athena header files can be found)
2979 cflags_save=$CFLAGS
2980 CFLAGS="$CFLAGS $X_CFLAGS"
2981 AC_TRY_COMPILE([
2982#include <X11/Intrinsic.h>
2983#include <X11/Xaw/Paned.h>], ,
2984 AC_MSG_RESULT(yes),
2985 AC_MSG_RESULT(no); SKIP_ATHENA=YES )
2986 CFLAGS=$cflags_save
2987fi
2988
2989if test -z "$SKIP_ATHENA"; then
2990 GUITYPE=ATHENA
2991fi
2992
2993if test -z "$SKIP_NEXTAW"; then
2994 AC_MSG_CHECKING(if neXtaw header files can be found)
2995 cflags_save=$CFLAGS
2996 CFLAGS="$CFLAGS $X_CFLAGS"
2997 AC_TRY_COMPILE([
2998#include <X11/Intrinsic.h>
2999#include <X11/neXtaw/Paned.h>], ,
3000 AC_MSG_RESULT(yes),
3001 AC_MSG_RESULT(no); SKIP_NEXTAW=YES )
3002 CFLAGS=$cflags_save
3003fi
3004
3005if test -z "$SKIP_NEXTAW"; then
3006 GUITYPE=NEXTAW
3007fi
3008
3009if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
3010 dnl Prepend -I and -L to $GUI_INC_LOC and $GUI_LIB_LOC if not empty
3011 dnl Avoid adding it when it twice
3012 if test -n "$GUI_INC_LOC"; then
3013 GUI_INC_LOC=-I"`echo $GUI_INC_LOC|sed 's%-I%%'`"
3014 fi
3015 if test -n "$GUI_LIB_LOC"; then
3016 GUI_LIB_LOC=-L"`echo $GUI_LIB_LOC|sed 's%-L%%'`"
3017 fi
3018
3019 dnl Check for -lXext and then for -lXmu
3020 ldflags_save=$LDFLAGS
3021 LDFLAGS="$X_LIBS $LDFLAGS"
3022 AC_CHECK_LIB(Xext, XShapeQueryExtension, [GUI_X_LIBS="-lXext"],,
3023 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3024 dnl For Solaris we need -lw and -ldl before linking with -lXmu works.
3025 AC_CHECK_LIB(w, wslen, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lw"],,
3026 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3027 AC_CHECK_LIB(dl, dlsym, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldl"],,
3028 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3029 AC_CHECK_LIB(Xmu, XmuCreateStippledPixmap, [GUI_X_LIBS="-lXmu $GUI_X_LIBS"],,
3030 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3031 if test -z "$SKIP_MOTIF"; then
3032 AC_CHECK_LIB(Xp, XpEndJob, [GUI_X_LIBS="-lXp $GUI_X_LIBS"],,
3033 [$GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3034 fi
3035 LDFLAGS=$ldflags_save
3036
3037 dnl Execute xmkmf to figure out if -DNARROWPROTO is needed.
3038 AC_MSG_CHECKING(for extra X11 defines)
3039 NARROW_PROTO=
3040 rm -fr conftestdir
3041 if mkdir conftestdir; then
3042 cd conftestdir
3043 cat > Imakefile <<'EOF'
3044acfindx:
3045 @echo 'NARROW_PROTO="${PROTO_DEFINES}"'
3046EOF
3047 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
3048 eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
3049 fi
3050 cd ..
3051 rm -fr conftestdir
3052 fi
3053 if test -z "$NARROW_PROTO"; then
3054 AC_MSG_RESULT(no)
3055 else
3056 AC_MSG_RESULT($NARROW_PROTO)
3057 fi
3058 AC_SUBST(NARROW_PROTO)
3059fi
3060
3061dnl Look for XSMP support - but don't necessarily restrict it to X11 GUIs
3062dnl use the X11 include path
3063if test "$enable_xsmp" = "yes"; then
3064 cppflags_save=$CPPFLAGS
3065 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3066 AC_CHECK_HEADERS(X11/SM/SMlib.h)
3067 CPPFLAGS=$cppflags_save
3068fi
3069
3070
Bram Moolenaar98921892016-02-23 17:14:37 +01003071if 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 +00003072 dnl Check for X11/xpm.h and X11/Sunkeysym.h with the GUI include path
3073 cppflags_save=$CPPFLAGS
3074 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3075 AC_CHECK_HEADERS(X11/xpm.h X11/Sunkeysym.h)
3076
3077 dnl automatically disable XIM when XIMtext isn't in X11/Xlib.h
3078 if test ! "$enable_xim" = "no"; then
3079 AC_MSG_CHECKING(for XIMText in X11/Xlib.h)
3080 AC_EGREP_CPP(XIMText, [#include <X11/Xlib.h>],
3081 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +02003082 AC_MSG_RESULT(no; xim has been disabled); enable_xim="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00003083 fi
3084 CPPFLAGS=$cppflags_save
3085
Bram Moolenaar54612582019-11-21 17:13:31 +01003086 dnl automatically enable XIM in the GUI
3087 if test "$enable_xim" = "auto" -a "x$GUITYPE" != "xNONE" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003088 AC_MSG_RESULT(X GUI selected; xim has been enabled)
3089 enable_xim="yes"
3090 fi
3091fi
3092
3093if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
3094 cppflags_save=$CPPFLAGS
3095 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00003096dnl Xmu/Editres.h may exist but can only be used after including Intrinsic.h
3097 AC_MSG_CHECKING([for X11/Xmu/Editres.h])
3098 AC_TRY_COMPILE([
3099#include <X11/Intrinsic.h>
3100#include <X11/Xmu/Editres.h>],
3101 [int i; i = 0;],
3102 AC_MSG_RESULT(yes)
3103 AC_DEFINE(HAVE_X11_XMU_EDITRES_H),
3104 AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003105 CPPFLAGS=$cppflags_save
3106fi
3107
3108dnl Only use the Xm directory when compiling Motif, don't use it for Athena
3109if test -z "$SKIP_MOTIF"; then
3110 cppflags_save=$CPPFLAGS
3111 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003112 if test "$zOSUnix" = "yes"; then
3113 xmheader="Xm/Xm.h"
3114 else
3115 xmheader="Xm/Xm.h Xm/XpmP.h Xm/JoinSideT.h Xm/TraitP.h Xm/Manager.h
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02003116 Xm/UnhighlightT.h Xm/Notebook.h"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003117 fi
3118 AC_CHECK_HEADERS($xmheader)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003119
Bram Moolenaar77c19352012-06-13 19:19:41 +02003120 if test "x$ac_cv_header_Xm_XpmP_h" = "xyes"; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003121 dnl Solaris uses XpmAttributes_21, very annoying.
3122 AC_MSG_CHECKING([for XpmAttributes_21 in Xm/XpmP.h])
3123 AC_TRY_COMPILE([#include <Xm/XpmP.h>], [XpmAttributes_21 attr;],
3124 AC_MSG_RESULT(yes); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes_21),
3125 AC_MSG_RESULT(no); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
3126 )
3127 else
Bram Moolenaar57657d82006-04-21 22:12:41 +00003128 AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003129 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003130 CPPFLAGS=$cppflags_save
3131fi
3132
3133if test "x$GUITYPE" = "xNONE" -a "$enable_xim" = "yes"; then
3134 AC_MSG_RESULT(no GUI selected; xim has been disabled)
3135 enable_xim="no"
3136fi
3137if test "x$GUITYPE" = "xNONE" -a "$enable_fontset" = "yes"; then
3138 AC_MSG_RESULT(no GUI selected; fontset has been disabled)
3139 enable_fontset="no"
3140fi
Bram Moolenaar182c5be2010-06-25 05:37:59 +02003141if test "x$GUITYPE:$enable_fontset" = "xGTK:yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003142 AC_MSG_RESULT(GTK+ 2 GUI selected; fontset has been disabled)
3143 enable_fontset="no"
3144fi
3145
Bram Moolenaarb3f74062020-02-26 16:16:53 +01003146dnl There is no test for the Haiku GUI, if it's selected it's used
3147if test -z "$SKIP_HAIKU"; then
3148 GUITYPE=HAIKUGUI
3149fi
3150
Bram Moolenaar071d4272004-06-13 20:20:40 +00003151if test -z "$SKIP_PHOTON"; then
3152 GUITYPE=PHOTONGUI
3153fi
3154
3155AC_SUBST(GUI_INC_LOC)
3156AC_SUBST(GUI_LIB_LOC)
3157AC_SUBST(GUITYPE)
3158AC_SUBST(GUI_X_LIBS)
3159
3160if test "$enable_workshop" = "yes" -a -n "$SKIP_MOTIF"; then
3161 AC_MSG_ERROR([cannot use workshop without Motif])
3162fi
3163
3164dnl defining FEAT_XIM and FEAT_XFONTSET is delayed, so that they can be disabled
3165if test "$enable_xim" = "yes"; then
3166 AC_DEFINE(FEAT_XIM)
3167fi
3168if test "$enable_fontset" = "yes"; then
3169 AC_DEFINE(FEAT_XFONTSET)
3170fi
3171
3172
3173dnl ---------------------------------------------------------------------------
3174dnl end of GUI-checking
3175dnl ---------------------------------------------------------------------------
3176
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003177AC_MSG_CHECKING([for /proc link to executable])
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003178if test -L "/proc/self/exe"; then
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003179 dnl Linux
3180 AC_MSG_RESULT([/proc/self/exe])
3181 AC_DEFINE(PROC_EXE_LINK, "/proc/self/exe")
3182elif test -L "/proc/self/path/a.out"; then
3183 dnl Solaris
3184 AC_MSG_RESULT([/proc/self/path/a.out])
3185 AC_DEFINE(PROC_EXE_LINK, "/proc/self/path/a.out")
3186elif test -L "/proc/curproc/file"; then
3187 dnl FreeBSD
3188 AC_MSG_RESULT([/proc/curproc/file])
3189 AC_DEFINE(PROC_EXE_LINK, "/proc/curproc/file")
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003190else
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003191 AC_MSG_RESULT(no)
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003192fi
3193
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003194dnl Check for Cygwin, which needs an extra source file if not using X11
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003195AC_MSG_CHECKING(for CYGWIN or MSYS environment)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003196case `uname` in
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003197 CYGWIN*|MSYS*) CYGWIN=yes; AC_MSG_RESULT(yes)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003198 AC_MSG_CHECKING(for CYGWIN clipboard support)
3199 if test "x$with_x" = "xno" ; then
3200 OS_EXTRA_SRC=winclip.c; OS_EXTRA_OBJ=objects/winclip.o
3201 AC_MSG_RESULT(yes)
3202 AC_DEFINE(FEAT_CYGWIN_WIN32_CLIPBOARD)
3203 else
3204 AC_MSG_RESULT(no - using X11)
3205 fi ;;
3206
3207 *) CYGWIN=no; AC_MSG_RESULT(no);;
3208esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00003209
Bram Moolenaar071d4272004-06-13 20:20:40 +00003210dnl Checks for libraries and include files.
3211
Bram Moolenaar446cb832008-06-24 21:56:24 +00003212AC_CACHE_CHECK([whether toupper is broken], [vim_cv_toupper_broken],
3213 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003214 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003215#include "confdefs.h"
3216#include <ctype.h>
3217#if STDC_HEADERS
3218# include <stdlib.h>
3219# include <stddef.h>
3220#endif
3221main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003222 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003223 vim_cv_toupper_broken=yes
3224 ],[
3225 vim_cv_toupper_broken=no
3226 ],[
3227 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_toupper_broken')
3228 ])])
3229
3230if test "x$vim_cv_toupper_broken" = "xyes" ; then
3231 AC_DEFINE(BROKEN_TOUPPER)
3232fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003233
3234AC_MSG_CHECKING(whether __DATE__ and __TIME__ work)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003235AC_TRY_COMPILE([#include <stdio.h>], [printf("(" __DATE__ " " __TIME__ ")");],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003236 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DATE_TIME),
3237 AC_MSG_RESULT(no))
3238
Bram Moolenaar0c094b92009-05-14 20:20:33 +00003239AC_MSG_CHECKING(whether __attribute__((unused)) is allowed)
3240AC_TRY_COMPILE([#include <stdio.h>], [int x __attribute__((unused));],
3241 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ATTRIBUTE_UNUSED),
3242 AC_MSG_RESULT(no))
3243
Bram Moolenaar071d4272004-06-13 20:20:40 +00003244dnl Checks for header files.
3245AC_CHECK_HEADER(elf.h, HAS_ELF=1)
3246dnl AC_CHECK_HEADER(dwarf.h, SVR4=1)
3247if test "$HAS_ELF" = 1; then
3248 AC_CHECK_LIB(elf, main)
3249fi
3250
3251AC_HEADER_DIRENT
3252
Bram Moolenaar071d4272004-06-13 20:20:40 +00003253dnl If sys/wait.h is not found it might still exist but not be POSIX
3254dnl compliant. In that case we define HAVE_UNION_WAIT (for NeXT)
3255if test $ac_cv_header_sys_wait_h = no; then
3256 AC_MSG_CHECKING([for sys/wait.h that defines union wait])
3257 AC_TRY_COMPILE([#include <sys/wait.h>],
3258 [union wait xx, yy; xx = yy],
3259 AC_MSG_RESULT(yes)
3260 AC_DEFINE(HAVE_SYS_WAIT_H)
3261 AC_DEFINE(HAVE_UNION_WAIT),
3262 AC_MSG_RESULT(no))
3263fi
3264
Bram Moolenaar779a7752016-01-30 23:26:34 +01003265AC_CHECK_HEADERS(stdint.h stdlib.h string.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003266 sys/select.h sys/utsname.h termcap.h fcntl.h \
3267 sgtty.h sys/ioctl.h sys/time.h sys/types.h \
3268 termio.h iconv.h inttypes.h langinfo.h math.h \
3269 unistd.h stropts.h errno.h sys/resource.h \
3270 sys/systeminfo.h locale.h sys/stream.h termios.h \
3271 libc.h sys/statfs.h poll.h sys/poll.h pwd.h \
Bram Moolenaar1ecc5e42019-01-26 15:12:55 +01003272 utime.h sys/param.h sys/ptms.h libintl.h libgen.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003273 util/debug.h util/msg18n.h frame.h sys/acl.h \
3274 sys/access.h sys/sysinfo.h wchar.h wctype.h)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003275
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003276dnl sys/ptem.h depends on sys/stream.h on Solaris
3277AC_CHECK_HEADERS(sys/ptem.h, [], [],
3278[#if defined HAVE_SYS_STREAM_H
3279# include <sys/stream.h>
3280#endif])
3281
Bram Moolenaar32f31b12009-05-21 13:20:59 +00003282dnl sys/sysctl.h depends on sys/param.h on OpenBSD
3283AC_CHECK_HEADERS(sys/sysctl.h, [], [],
3284[#if defined HAVE_SYS_PARAM_H
3285# include <sys/param.h>
3286#endif])
3287
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003288
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003289dnl pthread_np.h may exist but can only be used after including pthread.h
3290AC_MSG_CHECKING([for pthread_np.h])
3291AC_TRY_COMPILE([
3292#include <pthread.h>
3293#include <pthread_np.h>],
3294 [int i; i = 0;],
3295 AC_MSG_RESULT(yes)
3296 AC_DEFINE(HAVE_PTHREAD_NP_H),
3297 AC_MSG_RESULT(no))
3298
Bram Moolenaare344bea2005-09-01 20:46:49 +00003299AC_CHECK_HEADERS(strings.h)
Bram Moolenaard0573012017-10-28 21:11:06 +02003300if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00003301 dnl The strings.h file on OS/X contains a warning and nothing useful.
3302 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3303else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003304
3305dnl Check if strings.h and string.h can both be included when defined.
3306AC_MSG_CHECKING([if strings.h can be included after string.h])
3307cppflags_save=$CPPFLAGS
3308CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3309AC_TRY_COMPILE([
3310#if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO)
3311# define _NO_PROTO /* like in os_unix.h, causes conflict for AIX (Winn) */
3312 /* but don't do it on AIX 5.1 (Uribarri) */
3313#endif
3314#ifdef HAVE_XM_XM_H
3315# include <Xm/Xm.h> /* This breaks it for HP-UX 11 (Squassabia) */
3316#endif
3317#ifdef HAVE_STRING_H
3318# include <string.h>
3319#endif
3320#if defined(HAVE_STRINGS_H)
3321# include <strings.h>
3322#endif
3323 ], [int i; i = 0;],
3324 AC_MSG_RESULT(yes),
3325 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3326 AC_MSG_RESULT(no))
3327CPPFLAGS=$cppflags_save
Bram Moolenaar9372a112005-12-06 19:59:18 +00003328fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003329
3330dnl Checks for typedefs, structures, and compiler characteristics.
3331AC_PROG_GCC_TRADITIONAL
3332AC_C_CONST
Bram Moolenaar76243bd2009-03-02 01:47:02 +00003333AC_C_VOLATILE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003334AC_TYPE_MODE_T
3335AC_TYPE_OFF_T
3336AC_TYPE_PID_T
3337AC_TYPE_SIZE_T
3338AC_TYPE_UID_T
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003339AC_TYPE_UINT32_T
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003340
Bram Moolenaar071d4272004-06-13 20:20:40 +00003341AC_HEADER_TIME
3342AC_CHECK_TYPE(ino_t, long)
3343AC_CHECK_TYPE(dev_t, unsigned)
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003344AC_C_BIGENDIAN(,,,)
Bram Moolenaar136f29a2016-02-27 20:14:15 +01003345AC_C_INLINE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003346
3347AC_MSG_CHECKING(for rlim_t)
3348if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
3349 AC_MSG_RESULT([(cached) $ac_cv_type_rlim_t])
3350else
3351 AC_EGREP_CPP(dnl
3352changequote(<<,>>)dnl
3353<<(^|[^a-zA-Z_0-9])rlim_t[^a-zA-Z_0-9]>>dnl
3354changequote([,]),
3355 [
3356#include <sys/types.h>
3357#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003358# include <stdlib.h>
3359# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003360#endif
3361#ifdef HAVE_SYS_RESOURCE_H
Bram Moolenaar446cb832008-06-24 21:56:24 +00003362# include <sys/resource.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003363#endif
3364 ], ac_cv_type_rlim_t=yes, ac_cv_type_rlim_t=no)
3365 AC_MSG_RESULT($ac_cv_type_rlim_t)
3366fi
3367if test $ac_cv_type_rlim_t = no; then
3368 cat >> confdefs.h <<\EOF
3369#define rlim_t unsigned long
3370EOF
3371fi
3372
3373AC_MSG_CHECKING(for stack_t)
3374if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then
3375 AC_MSG_RESULT([(cached) $ac_cv_type_stack_t])
3376else
3377 AC_EGREP_CPP(stack_t,
3378 [
3379#include <sys/types.h>
3380#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003381# include <stdlib.h>
3382# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003383#endif
3384#include <signal.h>
3385 ], ac_cv_type_stack_t=yes, ac_cv_type_stack_t=no)
3386 AC_MSG_RESULT($ac_cv_type_stack_t)
3387fi
3388if test $ac_cv_type_stack_t = no; then
3389 cat >> confdefs.h <<\EOF
3390#define stack_t struct sigaltstack
3391EOF
3392fi
3393
3394dnl BSDI uses ss_base while others use ss_sp for the stack pointer.
3395AC_MSG_CHECKING(whether stack_t has an ss_base field)
3396AC_TRY_COMPILE([
3397#include <sys/types.h>
3398#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003399# include <stdlib.h>
3400# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003401#endif
3402#include <signal.h>
3403#include "confdefs.h"
3404 ], [stack_t sigstk; sigstk.ss_base = 0; ],
3405 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SS_BASE),
3406 AC_MSG_RESULT(no))
3407
3408olibs="$LIBS"
3409AC_MSG_CHECKING(--with-tlib argument)
3410AC_ARG_WITH(tlib, [ --with-tlib=library terminal library to be used ],)
3411if test -n "$with_tlib"; then
3412 AC_MSG_RESULT($with_tlib)
3413 LIBS="$LIBS -l$with_tlib"
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003414 AC_MSG_CHECKING(for linking with $with_tlib library)
3415 AC_TRY_LINK([], [], AC_MSG_RESULT(OK), AC_MSG_ERROR(FAILED))
3416 dnl Need to check for tgetent() below.
3417 olibs="$LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003418else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003419 AC_MSG_RESULT([empty: automatic terminal library selection])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003420 dnl On HP-UX 10.10 termcap or termlib should be used instead of
3421 dnl curses, because curses is much slower.
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003422 dnl Newer versions of ncurses are preferred over anything, except
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02003423 dnl when tinfo has been split off, it contains all we need.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003424 dnl Older versions of ncurses have bugs, get a new one!
3425 dnl Digital Unix (OSF1) should use curses (Ronald Schild).
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00003426 dnl On SCO Openserver should prefer termlib (Roger Cornelius).
Bram Moolenaar071d4272004-06-13 20:20:40 +00003427 case "`uname -s 2>/dev/null`" in
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003428 OSF1|SCO_SV) tlibs="tinfo ncurses curses termlib termcap";;
3429 *) tlibs="tinfo ncurses termlib termcap curses";;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003430 esac
3431 for libname in $tlibs; do
3432 AC_CHECK_LIB(${libname}, tgetent,,)
3433 if test "x$olibs" != "x$LIBS"; then
3434 dnl It's possible that a library is found but it doesn't work
3435 dnl e.g., shared library that cannot be found
3436 dnl compile and run a test program to be sure
3437 AC_TRY_RUN([
3438#ifdef HAVE_TERMCAP_H
3439# include <termcap.h>
3440#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003441#if STDC_HEADERS
3442# include <stdlib.h>
3443# include <stddef.h>
3444#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003445main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }],
3446 res="OK", res="FAIL", res="FAIL")
3447 if test "$res" = "OK"; then
3448 break
3449 fi
3450 AC_MSG_RESULT($libname library is not usable)
3451 LIBS="$olibs"
3452 fi
3453 done
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003454 if test "x$olibs" = "x$LIBS"; then
3455 AC_MSG_RESULT(no terminal library found)
3456 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003457fi
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003458
3459if test "x$olibs" = "x$LIBS"; then
3460 AC_MSG_CHECKING([for tgetent()])
Bram Moolenaarbd7f7c12020-07-28 21:03:37 +02003461 AC_TRY_LINK([int tgetent(char *, const char *);],
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003462 [char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");],
3463 AC_MSG_RESULT(yes),
3464 AC_MSG_ERROR([NOT FOUND!
3465 You need to install a terminal library; for example ncurses.
3466 Or specify the name of the library with --with-tlib.]))
3467fi
3468
Bram Moolenaar446cb832008-06-24 21:56:24 +00003469AC_CACHE_CHECK([whether we talk terminfo], [vim_cv_terminfo],
3470 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003471 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003472#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003473#ifdef HAVE_TERMCAP_H
3474# include <termcap.h>
3475#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003476#ifdef HAVE_STRING_H
3477# include <string.h>
3478#endif
3479#if STDC_HEADERS
3480# include <stdlib.h>
3481# include <stddef.h>
3482#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003483main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003484{char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003485 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003486 vim_cv_terminfo=no
3487 ],[
3488 vim_cv_terminfo=yes
3489 ],[
3490 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_terminfo')
3491 ])
3492 ])
3493
3494if test "x$vim_cv_terminfo" = "xyes" ; then
3495 AC_DEFINE(TERMINFO)
3496fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003497
Bram Moolenaara88254f2017-11-02 23:04:14 +01003498AC_CACHE_CHECK([what tgetent() returns for an unknown terminal], [vim_cv_tgetent],
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003499 [
3500 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003501#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003502#ifdef HAVE_TERMCAP_H
3503# include <termcap.h>
3504#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003505#if STDC_HEADERS
3506# include <stdlib.h>
3507# include <stddef.h>
3508#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003509main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003510{char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003511 ]])],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003512 vim_cv_tgetent=zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003513 ],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003514 vim_cv_tgetent=non-zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003515 ],[
3516 AC_MSG_ERROR(failed to compile test program.)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003517 ])
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003518 ])
3519
Bram Moolenaara88254f2017-11-02 23:04:14 +01003520if test "x$vim_cv_tgetent" = "xzero" ; then
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003521 AC_DEFINE(TGETENT_ZERO_ERR, 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003522fi
3523
3524AC_MSG_CHECKING(whether termcap.h contains ospeed)
3525AC_TRY_LINK([
3526#ifdef HAVE_TERMCAP_H
3527# include <termcap.h>
3528#endif
3529 ], [ospeed = 20000],
3530 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED),
3531 [AC_MSG_RESULT(no)
3532 AC_MSG_CHECKING(whether ospeed can be extern)
3533 AC_TRY_LINK([
3534#ifdef HAVE_TERMCAP_H
3535# include <termcap.h>
3536#endif
3537extern short ospeed;
3538 ], [ospeed = 20000],
3539 AC_MSG_RESULT(yes); AC_DEFINE(OSPEED_EXTERN),
3540 AC_MSG_RESULT(no))]
3541 )
3542
3543AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC])
3544AC_TRY_LINK([
3545#ifdef HAVE_TERMCAP_H
3546# include <termcap.h>
3547#endif
3548 ], [if (UP == 0 && BC == 0) PC = 1],
3549 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UP_BC_PC),
3550 [AC_MSG_RESULT(no)
3551 AC_MSG_CHECKING([whether UP, BC and PC can be extern])
3552 AC_TRY_LINK([
3553#ifdef HAVE_TERMCAP_H
3554# include <termcap.h>
3555#endif
3556extern char *UP, *BC, PC;
3557 ], [if (UP == 0 && BC == 0) PC = 1],
3558 AC_MSG_RESULT(yes); AC_DEFINE(UP_BC_PC_EXTERN),
3559 AC_MSG_RESULT(no))]
3560 )
3561
3562AC_MSG_CHECKING(whether tputs() uses outfuntype)
3563AC_TRY_COMPILE([
3564#ifdef HAVE_TERMCAP_H
3565# include <termcap.h>
3566#endif
3567 ], [extern int xx(); tputs("test", 1, (outfuntype)xx)],
3568 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OUTFUNTYPE),
3569 AC_MSG_RESULT(no))
3570
3571dnl On some SCO machines sys/select redefines struct timeval
3572AC_MSG_CHECKING([whether sys/select.h and sys/time.h may both be included])
3573AC_TRY_COMPILE([
3574#include <sys/types.h>
3575#include <sys/time.h>
3576#include <sys/select.h>], ,
3577 AC_MSG_RESULT(yes)
3578 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME),
3579 AC_MSG_RESULT(no))
3580
3581dnl AC_DECL_SYS_SIGLIST
3582
3583dnl Checks for pty.c (copied from screen) ==========================
3584AC_MSG_CHECKING(for /dev/ptc)
3585if test -r /dev/ptc; then
3586 AC_DEFINE(HAVE_DEV_PTC)
3587 AC_MSG_RESULT(yes)
3588else
3589 AC_MSG_RESULT(no)
3590fi
3591
3592AC_MSG_CHECKING(for SVR4 ptys)
3593if test -c /dev/ptmx ; then
3594 AC_TRY_LINK([], [ptsname(0);grantpt(0);unlockpt(0);],
3595 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SVR4_PTYS),
3596 AC_MSG_RESULT(no))
3597else
3598 AC_MSG_RESULT(no)
3599fi
3600
3601AC_MSG_CHECKING(for ptyranges)
3602if test -d /dev/ptym ; then
3603 pdir='/dev/ptym'
3604else
3605 pdir='/dev'
3606fi
3607dnl SCO uses ptyp%d
3608AC_EGREP_CPP(yes,
3609[#ifdef M_UNIX
3610 yes;
3611#endif
3612 ], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
3613dnl if test -c /dev/ptyp19; then
3614dnl ptys=`echo /dev/ptyp??`
3615dnl else
3616dnl ptys=`echo $pdir/pty??`
3617dnl fi
3618if test "$ptys" != "$pdir/pty??" ; then
3619 p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
3620 p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'`
3621 AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
3622 AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
3623 AC_MSG_RESULT([$p0 / $p1])
3624else
3625 AC_MSG_RESULT([don't know])
3626fi
3627
Bram Moolenaar071d4272004-06-13 20:20:40 +00003628dnl Checks for library functions. ===================================
3629
3630AC_TYPE_SIGNAL
3631
3632dnl find out what to use at the end of a signal function
3633if test $ac_cv_type_signal = void; then
3634 AC_DEFINE(SIGRETURN, [return])
3635else
3636 AC_DEFINE(SIGRETURN, [return 0])
3637fi
3638
3639dnl check if struct sigcontext is defined (used for SGI only)
3640AC_MSG_CHECKING(for struct sigcontext)
3641AC_TRY_COMPILE([
3642#include <signal.h>
3643test_sig()
3644{
3645 struct sigcontext *scont;
3646 scont = (struct sigcontext *)0;
3647 return 1;
3648} ], ,
3649 AC_MSG_RESULT(yes)
3650 AC_DEFINE(HAVE_SIGCONTEXT),
3651 AC_MSG_RESULT(no))
3652
3653dnl tricky stuff: try to find out if getcwd() is implemented with
3654dnl system("sh -c pwd")
Bram Moolenaar446cb832008-06-24 21:56:24 +00003655AC_CACHE_CHECK([getcwd implementation is broken], [vim_cv_getcwd_broken],
3656 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003657 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003658#include "confdefs.h"
3659#ifdef HAVE_UNISTD_H
3660#include <unistd.h>
3661#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003662char *dagger[] = { "IFS=pwd", 0 };
3663main()
3664{
3665 char buffer[500];
3666 extern char **environ;
3667 environ = dagger;
3668 return getcwd(buffer, 500) ? 0 : 1;
Bram Moolenaar446cb832008-06-24 21:56:24 +00003669}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003670 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003671 vim_cv_getcwd_broken=no
3672 ],[
3673 vim_cv_getcwd_broken=yes
3674 ],[
3675 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_getcwd_broken')
3676 ])
3677 ])
3678
3679if test "x$vim_cv_getcwd_broken" = "xyes" ; then
3680 AC_DEFINE(BAD_GETCWD)
Bram Moolenaar63d25552019-05-10 21:28:38 +02003681 AC_CHECK_FUNCS(getwd)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003682fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003683
Bram Moolenaar25153e12010-02-24 14:47:08 +01003684dnl Check for functions in one big call, to reduce the size of configure.
3685dnl Can only be used for functions that do not require any include.
Bram Moolenaarcd142e32017-11-16 17:03:45 +01003686AC_CHECK_FUNCS(fchdir fchown fchmod fsync getcwd getpseudotty \
Bram Moolenaar63d25552019-05-10 21:28:38 +02003687 getpwent getpwnam getpwuid getrlimit gettimeofday localtime_r lstat \
Bram Moolenaareaf03392009-11-17 11:08:52 +00003688 memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
Bram Moolenaar2fcf6682017-03-11 20:03:42 +01003689 getpgid setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
Bram Moolenaar84cf6bd2020-06-16 20:03:43 +02003690 sigprocmask sigvec strcasecmp strcoll strerror strftime stricmp strncasecmp \
Bram Moolenaar10455d42019-11-21 15:36:18 +01003691 strnicmp strpbrk strptime strtol tgetent towlower towupper iswupper \
3692 tzset usleep utime utimes mblen ftruncate unsetenv posix_openpt)
Bram Moolenaar643b6142018-09-12 20:29:09 +02003693AC_FUNC_SELECT_ARGTYPES
Bram Moolenaar25153e12010-02-24 14:47:08 +01003694AC_FUNC_FSEEKO
Bram Moolenaar071d4272004-06-13 20:20:40 +00003695
Bram Moolenaar317fd3a2010-05-07 16:05:55 +02003696dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when
3697dnl appropriate, so that off_t is 64 bits when needed.
3698AC_SYS_LARGEFILE
3699
Bram Moolenaar21606672019-06-14 20:40:58 +02003700AC_MSG_CHECKING(--enable-canberra argument)
3701AC_ARG_ENABLE(canberra,
3702 [ --disable-canberra Do not use libcanberra.],
3703 , [enable_canberra="maybe"])
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003704
Bram Moolenaar21606672019-06-14 20:40:58 +02003705if test "$enable_canberra" = "maybe"; then
3706 if test "$features" = "big" -o "$features" = "huge"; then
3707 AC_MSG_RESULT(Defaulting to yes)
3708 enable_canberra="yes"
3709 else
3710 AC_MSG_RESULT(Defaulting to no)
3711 enable_canberra="no"
3712 fi
3713else
3714 AC_MSG_RESULT($enable_canberra)
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003715fi
Bram Moolenaar21606672019-06-14 20:40:58 +02003716if test "$enable_canberra" = "yes"; then
3717 if test "x$PKG_CONFIG" != "xno"; then
3718 canberra_lib=`$PKG_CONFIG --libs libcanberra 2>/dev/null`
3719 canberra_cflags=`$PKG_CONFIG --cflags libcanberra 2>/dev/null`
3720 fi
3721 if test "x$canberra_lib" = "x"; then
3722 canberra_lib=-lcanberra
3723 canberra_cflags=-D_REENTRANT
3724 fi
3725 AC_MSG_CHECKING(for libcanberra)
3726 ac_save_CFLAGS="$CFLAGS"
3727 ac_save_LIBS="$LIBS"
3728 CFLAGS="$CFLAGS $canberra_cflags"
3729 LIBS="$LIBS $canberra_lib"
3730 AC_TRY_LINK([
3731 # include <canberra.h>
3732 ], [
3733 ca_context *hello;
3734 ca_context_create(&hello);],
3735 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_CANBERRA),
Bram Moolenaar91b992c2019-11-17 19:07:42 +01003736 AC_MSG_RESULT(no; try installing libcanberra-dev); CFLAGS="$ac_save_CFLAGS"; LIBS="$ac_save_LIBS")
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003737fi
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003738
3739
Bram Moolenaar071d4272004-06-13 20:20:40 +00003740dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible
3741AC_MSG_CHECKING(for st_blksize)
3742AC_TRY_COMPILE(
3743[#include <sys/types.h>
3744#include <sys/stat.h>],
3745[ struct stat st;
3746 int n;
3747
3748 stat("/", &st);
3749 n = (int)st.st_blksize;],
3750 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ST_BLKSIZE),
3751 AC_MSG_RESULT(no))
3752
Bram Moolenaar446cb832008-06-24 21:56:24 +00003753AC_CACHE_CHECK([whether stat() ignores a trailing slash], [vim_cv_stat_ignores_slash],
3754 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003755 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003756#include "confdefs.h"
3757#if STDC_HEADERS
3758# include <stdlib.h>
3759# include <stddef.h>
3760#endif
3761#include <sys/types.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003762#include <sys/stat.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003763main() {struct stat st; exit(stat("configure/", &st) != 0); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003764 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003765 vim_cv_stat_ignores_slash=yes
3766 ],[
3767 vim_cv_stat_ignores_slash=no
3768 ],[
3769 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_stat_ignores_slash')
3770 ])
3771 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003772
Bram Moolenaar446cb832008-06-24 21:56:24 +00003773if test "x$vim_cv_stat_ignores_slash" = "xyes" ; then
3774 AC_DEFINE(STAT_IGNORES_SLASH)
3775fi
3776
Bram Moolenaar071d4272004-06-13 20:20:40 +00003777dnl Link with iconv for charset translation, if not found without library.
3778dnl check for iconv() requires including iconv.h
3779dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
3780dnl has been installed.
3781AC_MSG_CHECKING(for iconv_open())
3782save_LIBS="$LIBS"
3783LIBS="$LIBS -liconv"
3784AC_TRY_LINK([
3785#ifdef HAVE_ICONV_H
3786# include <iconv.h>
3787#endif
3788 ], [iconv_open("fr", "to");],
3789 AC_MSG_RESULT(yes; with -liconv); AC_DEFINE(HAVE_ICONV),
3790 LIBS="$save_LIBS"
3791 AC_TRY_LINK([
3792#ifdef HAVE_ICONV_H
3793# include <iconv.h>
3794#endif
3795 ], [iconv_open("fr", "to");],
3796 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ICONV),
3797 AC_MSG_RESULT(no)))
3798
3799
3800AC_MSG_CHECKING(for nl_langinfo(CODESET))
3801AC_TRY_LINK([
3802#ifdef HAVE_LANGINFO_H
3803# include <langinfo.h>
3804#endif
3805], [char *cs = nl_langinfo(CODESET);],
3806 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET),
3807 AC_MSG_RESULT(no))
3808
Bram Moolenaar446cb832008-06-24 21:56:24 +00003809dnl Need various functions for floating point support. Only enable
3810dnl floating point when they are all present.
3811AC_CHECK_LIB(m, strtod)
3812AC_MSG_CHECKING([for strtod() and other floating point functions])
3813AC_TRY_LINK([
3814#ifdef HAVE_MATH_H
3815# include <math.h>
3816#endif
3817#if STDC_HEADERS
3818# include <stdlib.h>
3819# include <stddef.h>
3820#endif
3821], [char *s; double d;
3822 d = strtod("1.1", &s);
3823 d = fabs(1.11);
3824 d = ceil(1.11);
3825 d = floor(1.11);
3826 d = log10(1.11);
3827 d = pow(1.11, 2.22);
3828 d = sqrt(1.11);
3829 d = sin(1.11);
3830 d = cos(1.11);
3831 d = atan(1.11);
3832 ],
3833 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT_FUNCS),
3834 AC_MSG_RESULT(no))
3835
Bram Moolenaara6b89762016-02-29 21:38:26 +01003836dnl isinf() and isnan() need to include header files and may need -lm.
3837AC_MSG_CHECKING([for isinf()])
3838AC_TRY_LINK([
3839#ifdef HAVE_MATH_H
3840# include <math.h>
3841#endif
3842#if STDC_HEADERS
3843# include <stdlib.h>
3844# include <stddef.h>
3845#endif
3846], [int r = isinf(1.11); ],
3847 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISINF),
3848 AC_MSG_RESULT(no))
3849
3850AC_MSG_CHECKING([for isnan()])
3851AC_TRY_LINK([
3852#ifdef HAVE_MATH_H
3853# include <math.h>
3854#endif
3855#if STDC_HEADERS
3856# include <stdlib.h>
3857# include <stddef.h>
3858#endif
3859], [int r = isnan(1.11); ],
3860 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISNAN),
3861 AC_MSG_RESULT(no))
3862
Bram Moolenaar071d4272004-06-13 20:20:40 +00003863dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI
3864dnl when -lacl works, also try to use -lattr (required for Debian).
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003865dnl On Solaris, use the acl_get/set functions in libsec, if present.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003866AC_MSG_CHECKING(--disable-acl argument)
3867AC_ARG_ENABLE(acl,
Bram Moolenaard6d30422018-01-28 22:48:55 +01003868 [ --disable-acl No check for ACL support.],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003869 , [enable_acl="yes"])
3870if test "$enable_acl" = "yes"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01003871 AC_MSG_RESULT(no)
3872 AC_CHECK_LIB(posix1e, acl_get_file, [LIBS="$LIBS -lposix1e"],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003873 AC_CHECK_LIB(acl, acl_get_file, [LIBS="$LIBS -lacl"
3874 AC_CHECK_LIB(attr, fgetxattr, LIBS="$LIBS -lattr",,)],,),)
3875
Bram Moolenaard6d30422018-01-28 22:48:55 +01003876 AC_MSG_CHECKING(for POSIX ACL support)
3877 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003878#include <sys/types.h>
3879#ifdef HAVE_SYS_ACL_H
3880# include <sys/acl.h>
3881#endif
3882acl_t acl;], [acl = acl_get_file("foo", ACL_TYPE_ACCESS);
3883 acl_set_file("foo", ACL_TYPE_ACCESS, acl);
3884 acl_free(acl);],
3885 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_ACL),
3886 AC_MSG_RESULT(no))
3887
Bram Moolenaard6d30422018-01-28 22:48:55 +01003888 AC_CHECK_LIB(sec, acl_get, [LIBS="$LIBS -lsec"; AC_DEFINE(HAVE_SOLARIS_ZFS_ACL)],
3889 AC_MSG_CHECKING(for Solaris ACL support)
3890 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003891#ifdef HAVE_SYS_ACL_H
3892# include <sys/acl.h>
3893#endif], [acl("foo", GETACLCNT, 0, NULL);
3894 ],
3895 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOLARIS_ACL),
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003896 AC_MSG_RESULT(no)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003897
Bram Moolenaard6d30422018-01-28 22:48:55 +01003898 AC_MSG_CHECKING(for AIX ACL support)
3899 AC_TRY_LINK([
Bram Moolenaar446cb832008-06-24 21:56:24 +00003900#if STDC_HEADERS
3901# include <stdlib.h>
3902# include <stddef.h>
3903#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003904#ifdef HAVE_SYS_ACL_H
3905# include <sys/acl.h>
3906#endif
3907#ifdef HAVE_SYS_ACCESS_H
3908# include <sys/access.h>
3909#endif
3910#define _ALL_SOURCE
3911
3912#include <sys/stat.h>
3913
3914int aclsize;
3915struct acl *aclent;], [aclsize = sizeof(struct acl);
3916 aclent = (void *)malloc(aclsize);
3917 statacl("foo", STX_NORMAL, aclent, aclsize);
3918 ],
3919 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_AIX_ACL),
3920 AC_MSG_RESULT(no))
3921else
3922 AC_MSG_RESULT(yes)
3923fi
3924
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02003925if test "x$GTK_CFLAGS" != "x"; then
3926 dnl pango_shape_full() is new, fall back to pango_shape().
3927 AC_MSG_CHECKING(for pango_shape_full)
3928 ac_save_CFLAGS="$CFLAGS"
3929 ac_save_LIBS="$LIBS"
3930 CFLAGS="$CFLAGS $GTK_CFLAGS"
3931 LIBS="$LIBS $GTK_LIBS"
Bram Moolenaar5325b9b2015-09-09 20:27:02 +02003932 AC_TRY_LINK(
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02003933 [#include <gtk/gtk.h>],
3934 [ pango_shape_full(NULL, 0, NULL, 0, NULL, NULL); ],
3935 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_PANGO_SHAPE_FULL),
3936 AC_MSG_RESULT(no))
3937 CFLAGS="$ac_save_CFLAGS"
3938 LIBS="$ac_save_LIBS"
3939fi
3940
Bram Moolenaar071d4272004-06-13 20:20:40 +00003941AC_MSG_CHECKING(--disable-gpm argument)
3942AC_ARG_ENABLE(gpm,
3943 [ --disable-gpm Don't use gpm (Linux mouse daemon).], ,
3944 [enable_gpm="yes"])
3945
3946if test "$enable_gpm" = "yes"; then
3947 AC_MSG_RESULT(no)
3948 dnl Checking if gpm support can be compiled
3949 AC_CACHE_CHECK([for gpm], vi_cv_have_gpm,
3950 [olibs="$LIBS" ; LIBS="-lgpm"]
3951 AC_TRY_LINK(
3952 [#include <gpm.h>
3953 #include <linux/keyboard.h>],
3954 [Gpm_GetLibVersion(NULL);],
3955 dnl Configure defines HAVE_GPM, if it is defined feature.h defines
3956 dnl FEAT_MOUSE_GPM if mouse support is included
3957 [vi_cv_have_gpm=yes],
3958 [vi_cv_have_gpm=no])
3959 [LIBS="$olibs"]
3960 )
3961 if test $vi_cv_have_gpm = yes; then
3962 LIBS="$LIBS -lgpm"
3963 AC_DEFINE(HAVE_GPM)
3964 fi
3965else
3966 AC_MSG_RESULT(yes)
3967fi
3968
Bram Moolenaar446cb832008-06-24 21:56:24 +00003969AC_MSG_CHECKING(--disable-sysmouse argument)
3970AC_ARG_ENABLE(sysmouse,
Bram Moolenaar8008b632017-07-18 21:33:20 +02003971 [ --disable-sysmouse Don't use sysmouse (mouse in *BSD console).], ,
Bram Moolenaar446cb832008-06-24 21:56:24 +00003972 [enable_sysmouse="yes"])
3973
3974if test "$enable_sysmouse" = "yes"; then
3975 AC_MSG_RESULT(no)
3976 dnl Checking if sysmouse support can be compiled
3977 dnl Configure defines HAVE_SYSMOUSE, if it is defined feature.h
3978 dnl defines FEAT_SYSMOUSE if mouse support is included
3979 AC_CACHE_CHECK([for sysmouse], vi_cv_have_sysmouse,
3980 AC_TRY_LINK(
3981 [#include <sys/consio.h>
3982 #include <signal.h>
3983 #include <sys/fbio.h>],
3984 [struct mouse_info mouse;
3985 mouse.operation = MOUSE_MODE;
3986 mouse.operation = MOUSE_SHOW;
3987 mouse.u.mode.mode = 0;
3988 mouse.u.mode.signal = SIGUSR2;],
3989 [vi_cv_have_sysmouse=yes],
3990 [vi_cv_have_sysmouse=no])
3991 )
3992 if test $vi_cv_have_sysmouse = yes; then
3993 AC_DEFINE(HAVE_SYSMOUSE)
3994 fi
3995else
3996 AC_MSG_RESULT(yes)
3997fi
3998
Bram Moolenaarf05da212009-11-17 16:13:15 +00003999dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
4000AC_MSG_CHECKING(for FD_CLOEXEC)
4001AC_TRY_COMPILE(
4002[#if HAVE_FCNTL_H
4003# include <fcntl.h>
4004#endif],
4005[ int flag = FD_CLOEXEC;],
4006 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
4007 AC_MSG_RESULT(not usable))
4008
Bram Moolenaar071d4272004-06-13 20:20:40 +00004009dnl rename needs to be checked separately to work on Nextstep with cc
4010AC_MSG_CHECKING(for rename)
4011AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
4012 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
4013 AC_MSG_RESULT(no))
4014
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004015dnl check for dirfd()
4016AC_MSG_CHECKING(for dirfd)
4017AC_TRY_COMPILE(
4018[#include <sys/types.h>
4019#include <dirent.h>],
4020[DIR * dir=opendir("dirname"); dirfd(dir);],
4021AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DIRFD), AC_MSG_RESULT(not usable))
4022
4023dnl check for flock()
4024AC_MSG_CHECKING(for flock)
4025AC_TRY_COMPILE(
4026[#include <sys/file.h>],
4027[flock(10, LOCK_SH);],
4028AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOCK), AC_MSG_RESULT(not usable))
4029
Bram Moolenaar071d4272004-06-13 20:20:40 +00004030dnl sysctl() may exist but not the arguments we use
4031AC_MSG_CHECKING(for sysctl)
4032AC_TRY_COMPILE(
4033[#include <sys/types.h>
4034#include <sys/sysctl.h>],
4035[ int mib[2], r;
4036 size_t len;
4037
4038 mib[0] = CTL_HW;
4039 mib[1] = HW_USERMEM;
4040 len = sizeof(r);
4041 (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
4042 ],
4043 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL),
4044 AC_MSG_RESULT(not usable))
4045
4046dnl sysinfo() may exist but not be Linux compatible
4047AC_MSG_CHECKING(for sysinfo)
4048AC_TRY_COMPILE(
4049[#include <sys/types.h>
4050#include <sys/sysinfo.h>],
4051[ struct sysinfo sinfo;
4052 int t;
4053
4054 (void)sysinfo(&sinfo);
4055 t = sinfo.totalram;
4056 ],
4057 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
4058 AC_MSG_RESULT(not usable))
4059
Bram Moolenaar914572a2007-05-01 11:37:47 +00004060dnl struct sysinfo may have the mem_unit field or not
4061AC_MSG_CHECKING(for sysinfo.mem_unit)
4062AC_TRY_COMPILE(
4063[#include <sys/types.h>
4064#include <sys/sysinfo.h>],
4065[ struct sysinfo sinfo;
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02004066 sinfo.mem_unit = 1;
Bram Moolenaar914572a2007-05-01 11:37:47 +00004067 ],
4068 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_MEM_UNIT),
4069 AC_MSG_RESULT(no))
4070
Bram Moolenaar071d4272004-06-13 20:20:40 +00004071dnl sysconf() may exist but not support what we want to use
4072AC_MSG_CHECKING(for sysconf)
4073AC_TRY_COMPILE(
4074[#include <unistd.h>],
4075[ (void)sysconf(_SC_PAGESIZE);
4076 (void)sysconf(_SC_PHYS_PAGES);
4077 ],
4078 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
4079 AC_MSG_RESULT(not usable))
4080
Bram Moolenaar914703b2010-05-31 21:59:46 +02004081AC_CHECK_SIZEOF([int])
4082AC_CHECK_SIZEOF([long])
4083AC_CHECK_SIZEOF([time_t])
4084AC_CHECK_SIZEOF([off_t])
Bram Moolenaar644fdff2010-05-30 13:26:21 +02004085
Bram Moolenaara2aa31a2014-02-23 22:52:40 +01004086dnl Use different names to avoid clashing with other header files.
4087AC_DEFINE_UNQUOTED(VIM_SIZEOF_INT, [$ac_cv_sizeof_int])
4088AC_DEFINE_UNQUOTED(VIM_SIZEOF_LONG, [$ac_cv_sizeof_long])
4089
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004090dnl Make sure that uint32_t is really 32 bits unsigned.
4091AC_MSG_CHECKING([uint32_t is 32 bits])
4092AC_TRY_RUN([
4093#ifdef HAVE_STDINT_H
4094# include <stdint.h>
4095#endif
4096#ifdef HAVE_INTTYPES_H
4097# include <inttypes.h>
4098#endif
4099main() {
4100 uint32_t nr1 = (uint32_t)-1;
4101 uint32_t nr2 = (uint32_t)0xffffffffUL;
Bram Moolenaar52897832020-07-02 22:50:37 +02004102 if (sizeof(uint32_t) != 4 || nr1 != 0xffffffffUL || nr2 + 1 != 0) return 1;
4103 return 0;
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004104}],
4105AC_MSG_RESULT(ok),
4106AC_MSG_ERROR([WRONG! uint32_t not defined correctly.]),
Bram Moolenaar323cb952011-12-14 19:22:34 +01004107AC_MSG_WARN([cannot check uint32_t when cross-compiling.]))
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004108
Bram Moolenaar446cb832008-06-24 21:56:24 +00004109dnl Check for memmove() before bcopy(), makes memmove() be used when both are
4110dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
4111
Bram Moolenaar071d4272004-06-13 20:20:40 +00004112[bcopy_test_prog='
Bram Moolenaar446cb832008-06-24 21:56:24 +00004113#include "confdefs.h"
4114#ifdef HAVE_STRING_H
4115# include <string.h>
4116#endif
4117#if STDC_HEADERS
4118# include <stdlib.h>
4119# include <stddef.h>
4120#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004121main() {
4122 char buf[10];
4123 strcpy(buf, "abcdefghi");
4124 mch_memmove(buf, buf + 2, 3);
4125 if (strncmp(buf, "ababcf", 6))
4126 exit(1);
4127 strcpy(buf, "abcdefghi");
4128 mch_memmove(buf + 2, buf, 3);
4129 if (strncmp(buf, "cdedef", 6))
4130 exit(1);
4131 exit(0); /* libc version works properly. */
4132}']
4133
Bram Moolenaar446cb832008-06-24 21:56:24 +00004134AC_CACHE_CHECK([whether memmove handles overlaps],[vim_cv_memmove_handles_overlap],
4135 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004136 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 +00004137 [
4138 vim_cv_memmove_handles_overlap=yes
4139 ],[
4140 vim_cv_memmove_handles_overlap=no
4141 ],[
4142 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memmove_handles_overlap')
4143 ])
4144 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00004145
Bram Moolenaar446cb832008-06-24 21:56:24 +00004146if test "x$vim_cv_memmove_handles_overlap" = "xyes" ; then
4147 AC_DEFINE(USEMEMMOVE)
4148else
4149 AC_CACHE_CHECK([whether bcopy handles overlaps],[vim_cv_bcopy_handles_overlap],
4150 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004151 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 +00004152 [
4153 vim_cv_bcopy_handles_overlap=yes
4154 ],[
4155 vim_cv_bcopy_handles_overlap=no
4156 ],[
4157 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_bcopy_handles_overlap')
4158 ])
4159 ])
4160
4161 if test "x$vim_cv_bcopy_handles_overlap" = "xyes" ; then
4162 AC_DEFINE(USEBCOPY)
4163 else
4164 AC_CACHE_CHECK([whether memcpy handles overlaps],[vim_cv_memcpy_handles_overlap],
4165 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004166 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 +00004167 [
4168 vim_cv_memcpy_handles_overlap=yes
4169 ],[
4170 vim_cv_memcpy_handles_overlap=no
4171 ],[
4172 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memcpy_handles_overlap')
4173 ])
4174 ])
4175
4176 if test "x$vim_cv_memcpy_handles_overlap" = "xyes" ; then
4177 AC_DEFINE(USEMEMCPY)
4178 fi
4179 fi
4180fi
4181
Bram Moolenaar071d4272004-06-13 20:20:40 +00004182
4183dnl Check for multibyte locale functions
4184dnl Find out if _Xsetlocale() is supported by libX11.
4185dnl Check if X_LOCALE should be defined.
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004186if test "x$with_x" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004187 cflags_save=$CFLAGS
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004188 libs_save=$LIBS
4189 LIBS="$LIBS $X_LIBS $GUI_LIB_LOC $GUI_X_LIBS $X_PRE_LIBS $X_LIB $X_EXTRA_LIBS"
4190 CFLAGS="$CFLAGS $X_CFLAGS"
4191
4192 AC_MSG_CHECKING(whether X_LOCALE needed)
4193 AC_TRY_COMPILE([#include <X11/Xlocale.h>],,
4194 AC_TRY_LINK_FUNC([_Xsetlocale], [AC_MSG_RESULT(yes)
4195 AC_DEFINE(X_LOCALE)], AC_MSG_RESULT(no)),
4196 AC_MSG_RESULT(no))
4197
4198 AC_MSG_CHECKING(whether Xutf8SetWMProperties() can be used)
4199 AC_TRY_LINK_FUNC([Xutf8SetWMProperties], [AC_MSG_RESULT(yes)
4200 AC_DEFINE(HAVE_XUTF8SETWMPROPERTIES)], AC_MSG_RESULT(no))
4201
Bram Moolenaar071d4272004-06-13 20:20:40 +00004202 CFLAGS=$cflags_save
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004203 LIBS=$libs_save
Bram Moolenaar071d4272004-06-13 20:20:40 +00004204fi
4205
4206dnl Link with xpg4, it is said to make Korean locale working
4207AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,)
4208
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004209dnl Check how we can run ctags. Default to "ctags" when nothing works.
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02004210dnl Use --version to detect Exuberant ctags (preferred)
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004211dnl Add --fields=+S to get function signatures for omni completion.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004212dnl -t for typedefs (many ctags have this)
4213dnl -s for static functions (Elvis ctags only?)
4214dnl -v for variables. Dangerous, most ctags take this for 'vgrind style'.
4215dnl -i+m to test for older Exuberant ctags
4216AC_MSG_CHECKING(how to create tags)
4217test -f tags && mv tags tags.save
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004218if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004219 TAGPRG="ctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004220elif (eval exctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004221 TAGPRG="exctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004222elif (eval exuberant-ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004223 TAGPRG="exuberant-ctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004224else
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004225 TAGPRG="ctags"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004226 (eval etags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags"
4227 (eval etags -c /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags -c"
4228 (eval ctags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags"
4229 (eval ctags -t /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -t"
4230 (eval ctags -ts /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -ts"
4231 (eval ctags -tvs /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -tvs"
4232 (eval ctags -i+m /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -i+m"
4233fi
4234test -f tags.save && mv tags.save tags
4235AC_MSG_RESULT($TAGPRG) AC_SUBST(TAGPRG)
4236
4237dnl Check how we can run man with a section number
4238AC_MSG_CHECKING(how to run man with a section nr)
4239MANDEF="man"
Bram Moolenaar8b131502008-02-13 09:28:19 +00004240(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 +00004241AC_MSG_RESULT($MANDEF)
4242if test "$MANDEF" = "man -s"; then
4243 AC_DEFINE(USEMAN_S)
4244fi
4245
4246dnl Check if gettext() is working and if it needs -lintl
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004247dnl We take care to base this on an empty LIBS: on some systems libelf would be
4248dnl in LIBS and implicitly take along libintl. The final LIBS would then not
4249dnl contain libintl, and the link step would fail due to -Wl,--as-needed.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004250AC_MSG_CHECKING(--disable-nls argument)
4251AC_ARG_ENABLE(nls,
4252 [ --disable-nls Don't support NLS (gettext()).], ,
4253 [enable_nls="yes"])
4254
4255if test "$enable_nls" = "yes"; then
4256 AC_MSG_RESULT(no)
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00004257
4258 INSTALL_LANGS=install-languages
4259 AC_SUBST(INSTALL_LANGS)
4260 INSTALL_TOOL_LANGS=install-tool-languages
4261 AC_SUBST(INSTALL_TOOL_LANGS)
4262
Bram Moolenaar071d4272004-06-13 20:20:40 +00004263 AC_CHECK_PROG(MSGFMT, msgfmt, msgfmt, )
4264 AC_MSG_CHECKING([for NLS])
4265 if test -f po/Makefile; then
4266 have_gettext="no"
4267 if test -n "$MSGFMT"; then
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004268 olibs=$LIBS
4269 LIBS=""
Bram Moolenaar071d4272004-06-13 20:20:40 +00004270 AC_TRY_LINK(
4271 [#include <libintl.h>],
4272 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004273 AC_MSG_RESULT([gettext() works]); have_gettext="yes"; LIBS=$olibs,
4274 LIBS="-lintl"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004275 AC_TRY_LINK(
4276 [#include <libintl.h>],
4277 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004278 AC_MSG_RESULT([gettext() works with -lintl]); have_gettext="yes";
4279 LIBS="$olibs -lintl",
Bram Moolenaar071d4272004-06-13 20:20:40 +00004280 AC_MSG_RESULT([gettext() doesn't work]);
4281 LIBS=$olibs))
4282 else
4283 AC_MSG_RESULT([msgfmt not found - disabled]);
4284 fi
Bram Moolenaar278eb582014-07-30 13:22:52 +02004285 if test $have_gettext = "yes" -a "x$features" != "xtiny" -a "x$features" != "xsmall"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004286 AC_DEFINE(HAVE_GETTEXT)
4287 MAKEMO=yes
4288 AC_SUBST(MAKEMO)
4289 dnl this was added in GNU gettext 0.10.36
4290 AC_CHECK_FUNCS(bind_textdomain_codeset)
4291 dnl _nl_msg_cat_cntr is required for GNU gettext
4292 AC_MSG_CHECKING([for _nl_msg_cat_cntr])
4293 AC_TRY_LINK(
4294 [#include <libintl.h>
4295 extern int _nl_msg_cat_cntr;],
4296 [++_nl_msg_cat_cntr;],
4297 AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_NL_MSG_CAT_CNTR),
4298 AC_MSG_RESULT([no]))
Bram Moolenaar26096cc2019-04-11 15:25:40 +02004299 AC_MSG_CHECKING([if msgfmt supports --desktop])
4300 MSGFMT_DESKTOP=
4301 if "$MSGFMT" --help | grep -e '--desktop' >/dev/null; then
Bram Moolenaar62a88f42019-06-07 20:44:40 +02004302 if "$MSGFMT" --version | grep '0.19.[[3-7]]$' >/dev/null; then
4303 dnl GNU gettext 0.19.7's --desktop is broken. We assume back to
4304 dnl 0.19.3 is also broken.
4305 AC_MSG_RESULT([broken])
4306 else
4307 AC_MSG_RESULT([yes])
4308 MSGFMT_DESKTOP="gvim.desktop vim.desktop"
4309 fi
Bram Moolenaar26096cc2019-04-11 15:25:40 +02004310 else
4311 AC_MSG_RESULT([no])
4312 fi
4313 AC_SUBST(MSGFMT_DESKTOP)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004314 fi
4315 else
4316 AC_MSG_RESULT([no "po/Makefile" - disabled]);
4317 fi
4318else
4319 AC_MSG_RESULT(yes)
4320fi
4321
4322dnl Check for dynamic linking loader
4323AC_CHECK_HEADER(dlfcn.h, DLL=dlfcn.h, [AC_CHECK_HEADER(dl.h, DLL=dl.h)])
4324if test x${DLL} = xdlfcn.h; then
4325 AC_DEFINE(HAVE_DLFCN_H, 1, [ Define if we have dlfcn.h. ])
4326 AC_MSG_CHECKING([for dlopen()])
4327 AC_TRY_LINK(,[
4328 extern void* dlopen();
4329 dlopen();
4330 ],
4331 AC_MSG_RESULT(yes);
4332 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4333 AC_MSG_RESULT(no);
4334 AC_MSG_CHECKING([for dlopen() in -ldl])
4335 olibs=$LIBS
4336 LIBS="$LIBS -ldl"
4337 AC_TRY_LINK(,[
4338 extern void* dlopen();
4339 dlopen();
4340 ],
4341 AC_MSG_RESULT(yes);
4342 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4343 AC_MSG_RESULT(no);
4344 LIBS=$olibs))
4345 dnl ReliantUNIX has dlopen() in libc but everything else in libdl
4346 dnl ick :-)
4347 AC_MSG_CHECKING([for dlsym()])
4348 AC_TRY_LINK(,[
4349 extern void* dlsym();
4350 dlsym();
4351 ],
4352 AC_MSG_RESULT(yes);
4353 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4354 AC_MSG_RESULT(no);
4355 AC_MSG_CHECKING([for dlsym() in -ldl])
4356 olibs=$LIBS
4357 LIBS="$LIBS -ldl"
4358 AC_TRY_LINK(,[
4359 extern void* dlsym();
4360 dlsym();
4361 ],
4362 AC_MSG_RESULT(yes);
4363 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4364 AC_MSG_RESULT(no);
4365 LIBS=$olibs))
4366elif test x${DLL} = xdl.h; then
4367 AC_DEFINE(HAVE_DL_H, 1, [ Define if we have dl.h. ])
4368 AC_MSG_CHECKING([for shl_load()])
4369 AC_TRY_LINK(,[
4370 extern void* shl_load();
4371 shl_load();
4372 ],
4373 AC_MSG_RESULT(yes);
4374 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4375 AC_MSG_RESULT(no);
4376 AC_MSG_CHECKING([for shl_load() in -ldld])
4377 olibs=$LIBS
4378 LIBS="$LIBS -ldld"
4379 AC_TRY_LINK(,[
4380 extern void* shl_load();
4381 shl_load();
4382 ],
4383 AC_MSG_RESULT(yes);
4384 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4385 AC_MSG_RESULT(no);
4386 LIBS=$olibs))
4387fi
4388AC_CHECK_HEADERS(setjmp.h)
4389
Bram Moolenaard0573012017-10-28 21:11:06 +02004390if test "x$MACOS_X" = "xyes" -a -n "$PERL"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004391 dnl -ldl must come after DynaLoader.a
4392 if echo $LIBS | grep -e '-ldl' >/dev/null; then
4393 LIBS=`echo $LIBS | sed s/-ldl//`
4394 PERL_LIBS="$PERL_LIBS -ldl"
4395 fi
4396fi
4397
Bram Moolenaard0573012017-10-28 21:11:06 +02004398if test "$MACOS_X" = "yes"; then
4399 AC_MSG_CHECKING([whether we need macOS frameworks])
Bram Moolenaar097148e2020-08-11 21:58:20 +02004400 if test "$MACOS_X_DARWIN" = "yes"; then
Bram Moolenaard0573012017-10-28 21:11:06 +02004401 if test "$features" = "tiny"; then
4402 dnl Since no FEAT_CLIPBOARD, no longer need for os_macosx.m.
4403 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_macosx.m++'`
4404 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_macosx.o++'`
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01004405 AC_MSG_RESULT([yes, we need CoreServices])
4406 LIBS="$LIBS -framework CoreServices"
Bram Moolenaard0573012017-10-28 21:11:06 +02004407 else
4408 AC_MSG_RESULT([yes, we need AppKit])
4409 LIBS="$LIBS -framework AppKit"
Bram Moolenaard0573012017-10-28 21:11:06 +02004410 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004411 else
Bram Moolenaard0573012017-10-28 21:11:06 +02004412 AC_MSG_RESULT([no])
Bram Moolenaar3437b912013-07-03 19:52:53 +02004413 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004414fi
4415
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004416dnl gcc 3.1 changed the meaning of -MM. The only solution appears to be to
4417dnl use "-isystem" instead of "-I" for all non-Vim include dirs.
4418dnl But only when making dependencies, cproto and lint don't take "-isystem".
Bram Moolenaar32466aa2006-02-24 23:53:04 +00004419dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
4420dnl the number before the version number.
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004421DEPEND_CFLAGS_FILTER=
4422if test "$GCC" = yes; then
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004423 AC_MSG_CHECKING(for GCC 3 or later)
Bram Moolenaar348808f2020-02-07 20:50:07 +01004424 gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]][[0-9]]*\)\..*$/\1/g'`
Bram Moolenaarf740b292006-02-16 22:11:02 +00004425 if test "$gccmajor" -gt "2"; then
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004426 DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004427 AC_MSG_RESULT(yes)
4428 else
4429 AC_MSG_RESULT(no)
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004430 fi
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004431 dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
4432 dnl declared as char x[1] but actually longer. Introduced in gcc 4.0.
Bram Moolenaar56d1db32009-12-16 16:14:51 +00004433 dnl Also remove duplicate _FORTIFY_SOURCE arguments.
Bram Moolenaaraeabe052011-12-08 15:17:34 +01004434 dnl And undefine it first to avoid a warning.
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004435 AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
4436 if test "$gccmajor" -gt "3"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02004437 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 Moolenaar91b992c2019-11-17 19:07:42 +01004438 CPPFLAGS=`echo "$CPPFLAGS" | sed -e 's/ *-Wp,-D_FORTIFY_SOURCE=.//g' -e 's/ *-D_FORTIFY_SOURCE=.//g' -e 's/ *-U_FORTIFY_SOURCE//g'`
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004439 AC_MSG_RESULT(yes)
4440 else
4441 AC_MSG_RESULT(no)
4442 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +00004443fi
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004444AC_SUBST(DEPEND_CFLAGS_FILTER)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004445
Bram Moolenaarec0557f2018-01-31 14:41:37 +01004446dnl On some systems AC_SYS_LARGEFILE determines that -D_FILE_OFFSET_BITS=64
4447dnl isn't required, but the CFLAGS for some of the libraries we're using
4448dnl include the define. Since the define changes the size of some datatypes
4449dnl (e.g. ino_t and off_t), all of Vim's modules must be compiled with a
4450dnl consistent value. It's therefore safest to force the use of the define
4451dnl if it's present in any of the *_CFLAGS variables.
4452AC_MSG_CHECKING(whether we need to force -D_FILE_OFFSET_BITS=64)
Bram Moolenaar9ce42132018-04-11 22:19:36 +02004453if echo "$CFLAGS $LUA_CFLAGS $MZSCHEME_CFLAGS $PERL_CFLAGS $PYTHON_CFLAGS $PYTHON3_CFLAGS $TCL_CFLAGS $RUBY_CFLAGS $GTK_CFLAGS" | grep -q D_FILE_OFFSET_BITS 2>/dev/null; then
Bram Moolenaarec0557f2018-01-31 14:41:37 +01004454 AC_MSG_RESULT(yes)
4455 AC_DEFINE(_FILE_OFFSET_BITS, 64)
4456else
4457 AC_MSG_RESULT(no)
4458fi
4459
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004460dnl link.sh tries to avoid overlinking in a hackish way.
4461dnl At least GNU ld supports --as-needed which provides the same functionality
4462dnl at linker level. Let's use it.
4463AC_MSG_CHECKING(linker --as-needed support)
4464LINK_AS_NEEDED=
4465# Check if linker supports --as-needed and --no-as-needed options
4466if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02004467 LDFLAGS=`echo "$LDFLAGS" | sed -e 's/ *-Wl,--as-needed//g' | sed -e 's/$/ -Wl,--as-needed/'`
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004468 LINK_AS_NEEDED=yes
4469fi
4470if test "$LINK_AS_NEEDED" = yes; then
4471 AC_MSG_RESULT(yes)
4472else
4473 AC_MSG_RESULT(no)
4474fi
4475AC_SUBST(LINK_AS_NEEDED)
4476
Bram Moolenaar77c19352012-06-13 19:19:41 +02004477# IBM z/OS reset CFLAGS for config.mk
4478if test "$zOSUnix" = "yes"; then
4479 CFLAGS="-D_ALL_SOURCE -Wc,float\(ieee\),dll"
4480fi
4481
Bram Moolenaar071d4272004-06-13 20:20:40 +00004482dnl write output files
4483AC_OUTPUT(auto/config.mk:config.mk.in)
4484
4485dnl vim: set sw=2 tw=78 fo+=l: