blob: 010cc8f09ca6c0e20a781435c66d797e5ee4b1da [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"
Bram Moolenaar588d2412020-10-03 14:24:19 +0200883 if test -f "${path}/librktio.a"; then
884 MZSCHEME_LIBS="${MZSCHEME_LIBS} ${path}/librktio.a"
885 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100886 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
887 elif test -f "${path}/libracket.a"; then
888 MZSCHEME_LIBS="${path}/libracket.a ${path}/libmzgc.a"
889 elif test -f "${path}/libmzscheme.a"; then
890 MZSCHEME_LIBS="${path}/libmzscheme.a ${path}/libmzgc.a"
891 else
892 dnl Using shared objects
893 if test -f "${path}/libmzscheme3m.so"; then
894 MZSCHEME_LIBS="-L${path} -lmzscheme3m"
895 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
896 elif test -f "${path}/libracket3m.so"; then
897 MZSCHEME_LIBS="-L${path} -lracket3m"
898 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
899 elif test -f "${path}/libracket.so"; then
900 MZSCHEME_LIBS="-L${path} -lracket -lmzgc"
901 else
902 dnl try next until last
903 if test "$path" != "$SCHEME_LIB"; then
904 continue
905 fi
906 MZSCHEME_LIBS="-L${path} -lmzscheme -lmzgc"
907 fi
908 if test "$GCC" = yes; then
909 dnl Make Vim remember the path to the library. For when it's not in
910 dnl $LD_LIBRARY_PATH.
911 MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${path}"
912 elif test "`(uname) 2>/dev/null`" = SunOS &&
913 uname -r | grep '^5' >/dev/null; then
914 MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${path}"
915 fi
916 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000917 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100918 if test "X$MZSCHEME_LIBS" != "X"; then
919 break
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +0000920 fi
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100921 done
922
923 AC_MSG_CHECKING([if racket requires -pthread])
924 if test "X$SCHEME_LIB" != "X" && $FGREP -e -pthread "$SCHEME_LIB/buildinfo" >/dev/null ; then
925 AC_MSG_RESULT(yes)
926 MZSCHEME_LIBS="${MZSCHEME_LIBS} -pthread"
927 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -pthread"
928 else
929 AC_MSG_RESULT(no)
930 fi
931
932 AC_MSG_CHECKING(for racket config directory)
933 SCHEME_CONFIGDIR=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-config-dir))) (when (path? p) (display p)))'`
934 if test "X$SCHEME_CONFIGDIR" != "X"; then
935 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DMZSCHEME_CONFIGDIR='\"${SCHEME_CONFIGDIR}\"'"
936 AC_MSG_RESULT(${SCHEME_CONFIGDIR})
937 else
938 AC_MSG_RESULT(not found)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000939 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100940
941 AC_MSG_CHECKING(for racket collects directory)
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100942 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))))'`
943 if test "X$SCHEME_COLLECTS" = "X"; then
944 if test -d "$vi_cv_path_mzscheme_pfx/lib/plt/collects"; then
945 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/plt/
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100946 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100947 if test -d "$vi_cv_path_mzscheme_pfx/lib/racket/collects"; then
948 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/racket/
Bram Moolenaar75676462013-01-30 14:55:42 +0100949 else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100950 if test -d "$vi_cv_path_mzscheme_pfx/share/racket/collects"; then
951 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/
952 else
953 if test -d "$vi_cv_path_mzscheme_pfx/collects"; then
954 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/
955 fi
Bram Moolenaar75676462013-01-30 14:55:42 +0100956 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100957 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100958 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000959 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100960 if test "X$SCHEME_COLLECTS" != "X" ; then
961 AC_MSG_RESULT(${SCHEME_COLLECTS})
962 else
963 AC_MSG_RESULT(not found)
964 fi
965
966 AC_MSG_CHECKING(for mzscheme_base.c)
967 if test -f "${SCHEME_COLLECTS}collects/scheme/base.ss" ; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000968 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +0100969 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
970 MZSCHEME_MOD="++lib scheme/base"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100971 else
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100972 if test -f "${SCHEME_COLLECTS}collects/scheme/base.rkt" ; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100973 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +0100974 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
975 MZSCHEME_MOD="++lib scheme/base"
976 else
977 if test -f "${SCHEME_COLLECTS}collects/racket/base.rkt" ; then
978 MZSCHEME_EXTRA="mzscheme_base.c"
979 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/raco ctool"
980 MZSCHEME_MOD=""
981 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100982 fi
983 fi
984 if test "X$MZSCHEME_EXTRA" != "X" ; then
985 dnl need to generate bytecode for MzScheme base
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000986 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE"
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100987 AC_MSG_RESULT(needed)
988 else
989 AC_MSG_RESULT(not needed)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000990 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100991
Bram Moolenaar9e902192013-07-17 18:58:11 +0200992 dnl On Ubuntu this fixes "undefined reference to symbol 'ffi_type_void'".
993 AC_CHECK_LIB(ffi, ffi_type_void, [MZSCHEME_LIBS="$MZSCHEME_LIBS -lffi"])
994
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000995 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -I${SCHEME_INC} \
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100996 -DMZSCHEME_COLLECTS='\"${SCHEME_COLLECTS}collects\"'"
Bram Moolenaar9e902192013-07-17 18:58:11 +0200997
998 dnl Test that we can compile a simple program with these CFLAGS and LIBS.
999 AC_MSG_CHECKING([if compile and link flags for MzScheme are sane])
1000 cflags_save=$CFLAGS
1001 libs_save=$LIBS
1002 CFLAGS="$CFLAGS $MZSCHEME_CFLAGS"
1003 LIBS="$LIBS $MZSCHEME_LIBS"
1004 AC_TRY_LINK(,[ ],
1005 AC_MSG_RESULT(yes); mzs_ok=yes,
1006 AC_MSG_RESULT(no: MZSCHEME DISABLED); mzs_ok=no)
1007 CFLAGS=$cflags_save
1008 LIBS=$libs_save
1009 if test $mzs_ok = yes; then
1010 MZSCHEME_SRC="if_mzsch.c"
1011 MZSCHEME_OBJ="objects/if_mzsch.o"
1012 MZSCHEME_PRO="if_mzsch.pro"
1013 AC_DEFINE(FEAT_MZSCHEME)
1014 else
1015 MZSCHEME_CFLAGS=
1016 MZSCHEME_LIBS=
1017 MZSCHEME_EXTRA=
1018 MZSCHEME_MZC=
1019 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001020 fi
1021 AC_SUBST(MZSCHEME_SRC)
1022 AC_SUBST(MZSCHEME_OBJ)
1023 AC_SUBST(MZSCHEME_PRO)
1024 AC_SUBST(MZSCHEME_LIBS)
1025 AC_SUBST(MZSCHEME_CFLAGS)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +00001026 AC_SUBST(MZSCHEME_EXTRA)
1027 AC_SUBST(MZSCHEME_MZC)
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001028fi
1029
1030
Bram Moolenaar071d4272004-06-13 20:20:40 +00001031AC_MSG_CHECKING(--enable-perlinterp argument)
1032AC_ARG_ENABLE(perlinterp,
Bram Moolenaare06c1882010-07-21 22:05:20 +02001033 [ --enable-perlinterp[=OPTS] Include Perl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001034 [enable_perlinterp="no"])
1035AC_MSG_RESULT($enable_perlinterp)
Bram Moolenaare06c1882010-07-21 22:05:20 +02001036if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01001037 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1038 AC_MSG_ERROR([cannot use Perl with tiny or small features])
1039 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001040 AC_SUBST(vi_cv_path_perl)
1041 AC_PATH_PROG(vi_cv_path_perl, perl)
1042 if test "X$vi_cv_path_perl" != "X"; then
1043 AC_MSG_CHECKING(Perl version)
1044 if $vi_cv_path_perl -e 'require 5.003_01' >/dev/null 2>/dev/null; then
1045 eval `$vi_cv_path_perl -V:usethreads`
Bram Moolenaare06c1882010-07-21 22:05:20 +02001046 eval `$vi_cv_path_perl -V:libperl`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001047 if test "X$usethreads" = "XUNKNOWN" -o "X$usethreads" = "Xundef"; then
1048 badthreads=no
1049 else
1050 if $vi_cv_path_perl -e 'require 5.6.0' >/dev/null 2>/dev/null; then
1051 eval `$vi_cv_path_perl -V:use5005threads`
1052 if test "X$use5005threads" = "XUNKNOWN" -o "X$use5005threads" = "Xundef"; then
1053 badthreads=no
1054 else
1055 badthreads=yes
1056 AC_MSG_RESULT(>>> Perl > 5.6 with 5.5 threads cannot be used <<<)
1057 fi
1058 else
1059 badthreads=yes
1060 AC_MSG_RESULT(>>> Perl 5.5 with threads cannot be used <<<)
1061 fi
1062 fi
1063 if test $badthreads = no; then
1064 AC_MSG_RESULT(OK)
1065 eval `$vi_cv_path_perl -V:shrpenv`
1066 if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04
1067 shrpenv=""
1068 fi
1069 vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlibexp}'`
1070 AC_SUBST(vi_cv_perllib)
Bram Moolenaard5f62b12014-08-17 17:05:44 +02001071 vi_cv_perl_extutils=unknown_perl_extutils_path
1072 for extutils_rel_path in ExtUtils vendor_perl/ExtUtils; do
1073 xsubpp_path="$vi_cv_perllib/$extutils_rel_path/xsubpp"
1074 if test -f "$xsubpp_path"; then
1075 vi_cv_perl_xsubpp="$xsubpp_path"
1076 fi
1077 done
1078 AC_SUBST(vi_cv_perl_xsubpp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001079 dnl Remove "-fno-something", it breaks using cproto.
Bram Moolenaar280a8682015-06-21 13:41:08 +02001080 dnl Remove "-fdebug-prefix-map", it isn't supported by clang.
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001081 dnl Remove "FORTIFY_SOURCE", it will be defined twice.
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001082 dnl remove -pipe and -Wxxx, it confuses cproto
Bram Moolenaar071d4272004-06-13 20:20:40 +00001083 perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
Bram Moolenaare8ff56b2017-09-14 23:06:23 +02001084 -e 'ccflags;perl_inc;print"\n"' | sed -e 's/-fno[[^ ]]*//' \
1085 -e 's/-fdebug-prefix-map[[^ ]]*//g' \
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001086 -e 's/-pipe //' \
1087 -e 's/-W[[^ ]]*//g' \
1088 -e 's/-D_FORTIFY_SOURCE=.//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001089 dnl Remove "-lc", it breaks on FreeBSD when using "-pthread".
1090 perllibs=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed -e 'ldopts' | \
1091 sed -e '/Warning/d' -e '/Note (probably harmless)/d' \
1092 -e 's/-bE:perl.exp//' -e 's/-lc //'`
1093 dnl Don't add perl lib to $LIBS: if it's not in LD_LIBRARY_PATH
1094 dnl a test in configure may fail because of that.
1095 perlldflags=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed \
1096 -e 'ccdlflags' | sed -e 's/-bE:perl.exp//'`
1097
1098 dnl check that compiling a simple program still works with the flags
1099 dnl added for Perl.
1100 AC_MSG_CHECKING([if compile and link flags for Perl are sane])
1101 cflags_save=$CFLAGS
1102 libs_save=$LIBS
1103 ldflags_save=$LDFLAGS
1104 CFLAGS="$CFLAGS $perlcppflags"
1105 LIBS="$LIBS $perllibs"
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001106 perlldflags=`echo "$perlldflags" | sed -e 's/^ *//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001107 LDFLAGS="$perlldflags $LDFLAGS"
1108 AC_TRY_LINK(,[ ],
1109 AC_MSG_RESULT(yes); perl_ok=yes,
1110 AC_MSG_RESULT(no: PERL DISABLED); perl_ok=no)
1111 CFLAGS=$cflags_save
1112 LIBS=$libs_save
1113 LDFLAGS=$ldflags_save
1114 if test $perl_ok = yes; then
1115 if test "X$perlcppflags" != "X"; then
Bram Moolenaar1ec96c92017-09-27 21:42:08 +02001116 PERL_CFLAGS=$perlcppflags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001117 fi
1118 if test "X$perlldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001119 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$perlldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001120 LDFLAGS="$perlldflags $LDFLAGS"
1121 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001122 fi
1123 PERL_LIBS=$perllibs
1124 PERL_SRC="auto/if_perl.c if_perlsfio.c"
1125 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o"
1126 PERL_PRO="if_perl.pro if_perlsfio.pro"
1127 AC_DEFINE(FEAT_PERL)
1128 fi
1129 fi
1130 else
1131 AC_MSG_RESULT(>>> too old; need Perl version 5.003_01 or later <<<)
1132 fi
1133 fi
1134
Bram Moolenaard0573012017-10-28 21:11:06 +02001135 if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00001136 dnl Mac OS X 10.2 or later
Bram Moolenaar071d4272004-06-13 20:20:40 +00001137 dir=/System/Library/Perl
1138 darwindir=$dir/darwin
1139 if test -d $darwindir; then
1140 PERL=/usr/bin/perl
1141 else
1142 dnl Mac OS X 10.3
1143 dir=/System/Library/Perl/5.8.1
1144 darwindir=$dir/darwin-thread-multi-2level
1145 if test -d $darwindir; then
1146 PERL=/usr/bin/perl
1147 fi
1148 fi
1149 if test -n "$PERL"; then
1150 PERL_DIR="$dir"
1151 PERL_CFLAGS="-DFEAT_PERL -I$darwindir/CORE"
1152 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o $darwindir/auto/DynaLoader/DynaLoader.a"
1153 PERL_LIBS="-L$darwindir/CORE -lperl"
1154 fi
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001155 dnl Perl on Mac OS X 10.5 adds "-arch" flags but these should only
1156 dnl be included if requested by passing --with-mac-arch to
1157 dnl configure, so strip these flags first (if present)
1158 PERL_LIBS=`echo "$PERL_LIBS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
1159 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 +00001160 fi
Bram Moolenaare06c1882010-07-21 22:05:20 +02001161 if test "$enable_perlinterp" = "dynamic"; then
1162 if test "$perl_ok" = "yes" -a "X$libperl" != "X"; then
1163 AC_DEFINE(DYNAMIC_PERL)
1164 PERL_CFLAGS="-DDYNAMIC_PERL_DLL=\\\"$libperl\\\" $PERL_CFLAGS"
1165 fi
1166 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001167
1168 if test "$fail_if_missing" = "yes" -a "$perl_ok" != "yes"; then
1169 AC_MSG_ERROR([could not configure perl])
1170 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001171fi
1172AC_SUBST(shrpenv)
1173AC_SUBST(PERL_SRC)
1174AC_SUBST(PERL_OBJ)
1175AC_SUBST(PERL_PRO)
1176AC_SUBST(PERL_CFLAGS)
1177AC_SUBST(PERL_LIBS)
1178
1179AC_MSG_CHECKING(--enable-pythoninterp argument)
1180AC_ARG_ENABLE(pythoninterp,
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001181 [ --enable-pythoninterp[=OPTS] Include Python interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001182 [enable_pythoninterp="no"])
1183AC_MSG_RESULT($enable_pythoninterp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001184if test "$enable_pythoninterp" = "yes" -o "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001185 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1186 AC_MSG_ERROR([cannot use Python with tiny or small features])
1187 fi
1188
Bram Moolenaar071d4272004-06-13 20:20:40 +00001189 dnl -- find the python executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001190 AC_MSG_CHECKING(--with-python-command argument)
1191 AC_SUBST(vi_cv_path_python)
1192 AC_ARG_WITH(python-command, [ --with-python-command=NAME name of the Python 2 command (default: python2 or python)],
1193 vi_cv_path_python="$withval"; AC_MSG_RESULT($vi_cv_path_python),
1194 AC_MSG_RESULT(no))
1195
1196 if test "X$vi_cv_path_python" = "X"; then
1197 AC_PATH_PROGS(vi_cv_path_python, python2 python)
1198 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001199 if test "X$vi_cv_path_python" != "X"; then
1200
1201 dnl -- get its version number
1202 AC_CACHE_CHECK(Python version,vi_cv_var_python_version,
1203 [[vi_cv_var_python_version=`
1204 ${vi_cv_path_python} -c 'import sys; print sys.version[:3]'`
1205 ]])
1206
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001207 dnl -- it must be at least version 2.3
1208 AC_MSG_CHECKING(Python is 2.3 or better)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001209 if ${vi_cv_path_python} -c \
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001210 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001211 then
1212 AC_MSG_RESULT(yep)
1213
1214 dnl -- find where python thinks it was installed
1215 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python_pfx,
1216 [ vi_cv_path_python_pfx=`
1217 ${vi_cv_path_python} -c \
1218 "import sys; print sys.prefix"` ])
1219
1220 dnl -- and where it thinks it runs
1221 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python_epfx,
1222 [ vi_cv_path_python_epfx=`
1223 ${vi_cv_path_python} -c \
1224 "import sys; print sys.exec_prefix"` ])
1225
1226 dnl -- python's internal library path
1227
1228 AC_CACHE_VAL(vi_cv_path_pythonpath,
1229 [ vi_cv_path_pythonpath=`
1230 unset PYTHONPATH;
1231 ${vi_cv_path_python} -c \
1232 "import sys, string; print string.join(sys.path,':')"` ])
1233
1234 dnl -- where the Python implementation library archives are
1235
1236 AC_ARG_WITH(python-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001237 [ --with-python-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001238 [ vi_cv_path_python_conf="${withval}"; have_python_config_dir=1 ] )
Bram Moolenaar071d4272004-06-13 20:20:40 +00001239
1240 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python_conf,
1241 [
1242 vi_cv_path_python_conf=
Bram Moolenaarac499e32013-06-02 19:14:17 +02001243 d=`${vi_cv_path_python} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBPL')"`
1244 if test -d "$d" && test -f "$d/config.c"; then
1245 vi_cv_path_python_conf="$d"
1246 else
1247 for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
1248 for subdir in lib64 lib share; do
1249 d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
1250 if test -d "$d" && test -f "$d/config.c"; then
1251 vi_cv_path_python_conf="$d"
1252 fi
1253 done
Bram Moolenaar071d4272004-06-13 20:20:40 +00001254 done
Bram Moolenaarac499e32013-06-02 19:14:17 +02001255 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001256 ])
1257
1258 PYTHON_CONFDIR="${vi_cv_path_python_conf}"
1259
1260 if test "X$PYTHON_CONFDIR" = "X"; then
1261 AC_MSG_RESULT([can't find it!])
1262 else
1263
1264 dnl -- we need to examine Python's config/Makefile too
1265 dnl see what the interpreter is built from
1266 AC_CACHE_VAL(vi_cv_path_python_plibs,
1267 [
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001268 pwd=`pwd`
1269 tmp_mkf="$pwd/config-PyMake$$"
1270 cat -- "${PYTHON_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001271__:
Bram Moolenaar218116c2010-05-20 21:46:00 +02001272 @echo "python_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001273 @echo "python_LIBS='$(LIBS)'"
1274 @echo "python_SYSLIBS='$(SYSLIBS)'"
1275 @echo "python_LINKFORSHARED='$(LINKFORSHARED)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001276 @echo "python_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001277 @echo "python_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001278 @echo "python_PYTHONFRAMEWORK='$(PYTHONFRAMEWORK)'"
1279 @echo "python_PYTHONFRAMEWORKPREFIX='$(PYTHONFRAMEWORKPREFIX)'"
1280 @echo "python_PYTHONFRAMEWORKINSTALLDIR='$(PYTHONFRAMEWORKINSTALLDIR)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001281eof
1282 dnl -- delete the lines from make about Entering/Leaving directory
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001283 eval "`cd ${PYTHON_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1284 rm -f -- "${tmp_mkf}"
Bram Moolenaard0573012017-10-28 21:11:06 +02001285 if test "x$MACOS_X" = "xyes" && test -n "${python_PYTHONFRAMEWORK}" && ${vi_cv_path_python} -c \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001286 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then
1287 vi_cv_path_python_plibs="-framework Python"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001288 if test "x${vi_cv_path_python}" != "x/usr/bin/python" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
1289 vi_cv_path_python_plibs="-F${python_PYTHONFRAMEWORKPREFIX} -framework Python"
1290 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001291 else
Bram Moolenaar9ce42132018-04-11 22:19:36 +02001292 vi_cv_path_python_plibs="-L${PYTHON_CONFDIR} -lpython${vi_cv_var_python_version}"
Bram Moolenaar6c927552015-03-24 12:21:33 +01001293 dnl -- Check if the path contained in python_LINKFORSHARED is
1294 dnl usable for vim build. If not, make and try other
1295 dnl candidates.
Bram Moolenaara161e262015-03-24 15:14:27 +01001296 if test -n "${python_LINKFORSHARED}" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then
Bram Moolenaar6c927552015-03-24 12:21:33 +01001297 python_link_symbol=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]].*/\1/'`
1298 python_link_path=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]][[ \t]]*\(.*\)/\2/'`
1299 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1300 dnl -- The path looks relative. Guess the absolute one using
1301 dnl the prefix and try that.
1302 python_link_path="${python_PYTHONFRAMEWORKPREFIX}/${python_link_path}"
1303 if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then
1304 dnl -- A last resort.
1305 python_link_path="${python_PYTHONFRAMEWORKINSTALLDIR}/Versions/${vi_cv_var_python_version}/${python_PYTHONFRAMEWORK}"
1306 dnl -- No check is done. The last word is left to the
1307 dnl "sanity" test on link flags that follows shortly.
1308 fi
1309 python_LINKFORSHARED="${python_link_symbol} ${python_link_path}"
1310 fi
1311 fi
Bram Moolenaar218116c2010-05-20 21:46:00 +02001312 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 +00001313 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1314 vi_cv_path_python_plibs=`echo $vi_cv_path_python_plibs | sed s/-ltermcap//`
1315 fi
1316 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001317 AC_CACHE_CHECK(Python's dll name,vi_cv_dll_name_python,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001318 [
1319 if test "X$python_DLLLIBRARY" != "X"; then
1320 vi_cv_dll_name_python="$python_DLLLIBRARY"
1321 else
1322 vi_cv_dll_name_python="$python_INSTSONAME"
1323 fi
1324 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00001325
1326 PYTHON_LIBS="${vi_cv_path_python_plibs}"
1327 if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001328 PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001329 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001330 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 +00001331 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001332 if test "X$have_python_config_dir" = "X1" -a "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001333 dnl Define PYTHON_HOME if --with-python-config-dir was used
1334 PYTHON_CFLAGS="${PYTHON_CFLAGS} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'"
1335
1336 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001337 PYTHON_SRC="if_python.c"
Bram Moolenaar9bdb9a02012-07-25 16:32:08 +02001338 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001339
1340 dnl On FreeBSD linking with "-pthread" is required to use threads.
1341 dnl _THREAD_SAFE must be used for compiling then.
1342 dnl The "-pthread" is added to $LIBS, so that the following check for
1343 dnl sigaltstack() will look in libc_r (it's there in libc!).
1344 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1345 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1346 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1347 AC_MSG_CHECKING([if -pthread should be used])
1348 threadsafe_flag=
1349 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001350 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00001351 if test "`(uname) 2>/dev/null`" != Darwin; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001352 test "$GCC" = yes && threadsafe_flag="-pthread"
1353 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1354 threadsafe_flag="-D_THREAD_SAFE"
1355 thread_lib="-pthread"
1356 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001357 if test "`(uname) 2>/dev/null`" = SunOS; then
1358 threadsafe_flag="-pthreads"
1359 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001360 fi
1361 libs_save_old=$LIBS
1362 if test -n "$threadsafe_flag"; then
1363 cflags_save=$CFLAGS
1364 CFLAGS="$CFLAGS $threadsafe_flag"
1365 LIBS="$LIBS $thread_lib"
1366 AC_TRY_LINK(,[ ],
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001367 AC_MSG_RESULT(yes); PYTHON_CFLAGS="$PYTHON_CFLAGS $threadsafe_flag",
Bram Moolenaar071d4272004-06-13 20:20:40 +00001368 AC_MSG_RESULT(no); LIBS=$libs_save_old
1369 )
1370 CFLAGS=$cflags_save
1371 else
1372 AC_MSG_RESULT(no)
1373 fi
1374
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001375 dnl Check that compiling a simple program still works with the flags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001376 dnl added for Python.
1377 AC_MSG_CHECKING([if compile and link flags for Python are sane])
1378 cflags_save=$CFLAGS
1379 libs_save=$LIBS
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001380 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001381 LIBS="$LIBS $PYTHON_LIBS"
1382 AC_TRY_LINK(,[ ],
1383 AC_MSG_RESULT(yes); python_ok=yes,
1384 AC_MSG_RESULT(no: PYTHON DISABLED); python_ok=no)
1385 CFLAGS=$cflags_save
1386 LIBS=$libs_save
1387 if test $python_ok = yes; then
1388 AC_DEFINE(FEAT_PYTHON)
1389 else
1390 LIBS=$libs_save_old
1391 PYTHON_SRC=
1392 PYTHON_OBJ=
1393 PYTHON_LIBS=
1394 PYTHON_CFLAGS=
1395 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001396 fi
1397 else
1398 AC_MSG_RESULT(too old)
1399 fi
1400 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001401
1402 if test "$fail_if_missing" = "yes" -a "$python_ok" != "yes"; then
1403 AC_MSG_ERROR([could not configure python])
1404 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001405fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001406
Bram Moolenaar071d4272004-06-13 20:20:40 +00001407AC_SUBST(PYTHON_LIBS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001408AC_SUBST(PYTHON_CFLAGS)
1409AC_SUBST(PYTHON_SRC)
1410AC_SUBST(PYTHON_OBJ)
1411
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001412
1413AC_MSG_CHECKING(--enable-python3interp argument)
1414AC_ARG_ENABLE(python3interp,
Bram Moolenaar8008b632017-07-18 21:33:20 +02001415 [ --enable-python3interp[=OPTS] Include Python3 interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001416 [enable_python3interp="no"])
1417AC_MSG_RESULT($enable_python3interp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001418if test "$enable_python3interp" = "yes" -o "$enable_python3interp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001419 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1420 AC_MSG_ERROR([cannot use Python with tiny or small features])
1421 fi
1422
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001423 dnl -- find the python3 executable
Bram Moolenaare1a32312018-04-15 16:03:25 +02001424 AC_MSG_CHECKING(--with-python3-command argument)
1425 AC_SUBST(vi_cv_path_python3)
1426 AC_ARG_WITH(python3-command, [ --with-python3-command=NAME name of the Python 3 command (default: python3 or python)],
1427 vi_cv_path_python3="$withval"; AC_MSG_RESULT($vi_cv_path_python3),
1428 AC_MSG_RESULT(no))
1429
1430 if test "X$vi_cv_path_python3" = "X"; then
1431 AC_PATH_PROGS(vi_cv_path_python3, python3 python)
1432 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001433 if test "X$vi_cv_path_python3" != "X"; then
1434
1435 dnl -- get its version number
1436 AC_CACHE_CHECK(Python version,vi_cv_var_python3_version,
1437 [[vi_cv_var_python3_version=`
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001438 ${vi_cv_path_python3} -c 'import sys; print(sys.version[:3])'`
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001439 ]])
1440
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001441 dnl -- it must be at least version 3
1442 AC_MSG_CHECKING(Python is 3.0 or better)
1443 if ${vi_cv_path_python3} -c \
1444 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.0)"
1445 then
1446 AC_MSG_RESULT(yep)
Bram Moolenaar456f2bb2011-06-12 21:37:13 +02001447
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001448 dnl -- get abiflags for python 3.2 or higher (PEP 3149)
1449 AC_CACHE_CHECK(Python's abiflags,vi_cv_var_python3_abiflags,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001450 [
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001451 vi_cv_var_python3_abiflags=
1452 if ${vi_cv_path_python3} -c \
1453 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)"
1454 then
1455 vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \
1456 "import sys; print(sys.abiflags)"`
1457 fi ])
1458
1459 dnl -- find where python3 thinks it was installed
1460 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx,
1461 [ vi_cv_path_python3_pfx=`
1462 ${vi_cv_path_python3} -c \
1463 "import sys; print(sys.prefix)"` ])
1464
1465 dnl -- and where it thinks it runs
1466 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx,
1467 [ vi_cv_path_python3_epfx=`
1468 ${vi_cv_path_python3} -c \
1469 "import sys; print(sys.exec_prefix)"` ])
1470
1471 dnl -- python3's internal library path
1472
1473 AC_CACHE_VAL(vi_cv_path_python3path,
1474 [ vi_cv_path_python3path=`
1475 unset PYTHONPATH;
1476 ${vi_cv_path_python3} -c \
1477 "import sys, string; print(':'.join(sys.path))"` ])
1478
1479 dnl -- where the Python implementation library archives are
1480
1481 AC_ARG_WITH(python3-config-dir,
Bram Moolenaare1a32312018-04-15 16:03:25 +02001482 [ --with-python3-config-dir=PATH Python's config directory (deprecated)],
Bram Moolenaard0882402018-04-10 18:13:05 +02001483 [ vi_cv_path_python3_conf="${withval}"; have_python3_config_dir=1 ] )
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001484
1485 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf,
1486 [
1487 vi_cv_path_python3_conf=
Bram Moolenaarfee496d2013-07-12 20:07:24 +02001488 config_dir="config-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001489 d=`${vi_cv_path_python3} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBPL'))"`
1490 if test -d "$d" && test -f "$d/config.c"; then
1491 vi_cv_path_python3_conf="$d"
1492 else
1493 for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do
1494 for subdir in lib64 lib share; do
1495 d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}"
1496 if test -d "$d" && test -f "$d/config.c"; then
1497 vi_cv_path_python3_conf="$d"
1498 fi
1499 done
1500 done
1501 fi
1502 ])
1503
1504 PYTHON3_CONFDIR="${vi_cv_path_python3_conf}"
1505
1506 if test "X$PYTHON3_CONFDIR" = "X"; then
1507 AC_MSG_RESULT([can't find it!])
1508 else
1509
1510 dnl -- we need to examine Python's config/Makefile too
1511 dnl see what the interpreter is built from
1512 AC_CACHE_VAL(vi_cv_path_python3_plibs,
1513 [
1514 pwd=`pwd`
1515 tmp_mkf="$pwd/config-PyMake$$"
1516 cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001517__:
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001518 @echo "python3_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001519 @echo "python3_LIBS='$(LIBS)'"
1520 @echo "python3_SYSLIBS='$(SYSLIBS)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001521 @echo "python3_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001522 @echo "python3_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001523eof
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001524 dnl -- delete the lines from make about Entering/Leaving directory
1525 eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1526 rm -f -- "${tmp_mkf}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001527 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 +02001528 vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}"
1529 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1530 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//`
1531 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//`
1532 ])
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001533 AC_CACHE_CHECK(Python3's dll name,vi_cv_dll_name_python3,
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001534 [
1535 if test "X$python3_DLLLIBRARY" != "X"; then
1536 vi_cv_dll_name_python3="$python3_DLLLIBRARY"
1537 else
1538 vi_cv_dll_name_python3="$python3_INSTSONAME"
1539 fi
1540 ])
1541
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001542 PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
1543 if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
Bram Moolenaar04249582018-04-10 13:29:34 +02001544 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 +02001545 else
Bram Moolenaar04249582018-04-10 13:29:34 +02001546 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 +02001547 fi
Bram Moolenaar3a21d9c2018-04-10 20:26:20 +02001548 if test "X$have_python3_config_dir" = "X1" -a "$enable_python3interp" = "dynamic"; then
Bram Moolenaard0882402018-04-10 18:13:05 +02001549 dnl Define PYTHON3_HOME if --with-python-config-dir was used
1550 PYTHON3_CFLAGS="${PYTHON3_CFLAGS} -DPYTHON3_HOME='L\"${vi_cv_path_python3_pfx}\"'"
1551 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001552 PYTHON3_SRC="if_python3.c"
1553 PYTHON3_OBJ="objects/if_python3.o"
1554
1555 dnl On FreeBSD linking with "-pthread" is required to use threads.
1556 dnl _THREAD_SAFE must be used for compiling then.
1557 dnl The "-pthread" is added to $LIBS, so that the following check for
1558 dnl sigaltstack() will look in libc_r (it's there in libc!).
1559 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1560 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1561 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1562 AC_MSG_CHECKING([if -pthread should be used])
1563 threadsafe_flag=
1564 thread_lib=
Bram Moolenaard0573012017-10-28 21:11:06 +02001565 dnl if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001566 if test "`(uname) 2>/dev/null`" != Darwin; then
1567 test "$GCC" = yes && threadsafe_flag="-pthread"
1568 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1569 threadsafe_flag="-D_THREAD_SAFE"
1570 thread_lib="-pthread"
1571 fi
1572 if test "`(uname) 2>/dev/null`" = SunOS; then
1573 threadsafe_flag="-pthreads"
1574 fi
1575 fi
1576 libs_save_old=$LIBS
1577 if test -n "$threadsafe_flag"; then
1578 cflags_save=$CFLAGS
1579 CFLAGS="$CFLAGS $threadsafe_flag"
1580 LIBS="$LIBS $thread_lib"
1581 AC_TRY_LINK(,[ ],
1582 AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag",
1583 AC_MSG_RESULT(no); LIBS=$libs_save_old
1584 )
1585 CFLAGS=$cflags_save
1586 else
1587 AC_MSG_RESULT(no)
1588 fi
1589
1590 dnl check that compiling a simple program still works with the flags
1591 dnl added for Python.
1592 AC_MSG_CHECKING([if compile and link flags for Python 3 are sane])
1593 cflags_save=$CFLAGS
1594 libs_save=$LIBS
1595 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1596 LIBS="$LIBS $PYTHON3_LIBS"
1597 AC_TRY_LINK(,[ ],
1598 AC_MSG_RESULT(yes); python3_ok=yes,
1599 AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no)
1600 CFLAGS=$cflags_save
1601 LIBS=$libs_save
1602 if test "$python3_ok" = yes; then
1603 AC_DEFINE(FEAT_PYTHON3)
1604 else
1605 LIBS=$libs_save_old
1606 PYTHON3_SRC=
1607 PYTHON3_OBJ=
1608 PYTHON3_LIBS=
1609 PYTHON3_CFLAGS=
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001610 fi
1611 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001612 else
1613 AC_MSG_RESULT(too old)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001614 fi
1615 fi
Bram Moolenaar1612b1a2013-06-14 21:22:39 +02001616 if test "$fail_if_missing" = "yes" -a "$python3_ok" != "yes"; then
1617 AC_MSG_ERROR([could not configure python3])
1618 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001619fi
1620
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001621AC_SUBST(PYTHON3_LIBS)
1622AC_SUBST(PYTHON3_CFLAGS)
1623AC_SUBST(PYTHON3_SRC)
1624AC_SUBST(PYTHON3_OBJ)
1625
1626dnl if python2.x and python3.x are enabled one can only link in code
1627dnl with dlopen(), dlsym(), dlclose()
1628if test "$python_ok" = yes && test "$python3_ok" = yes; then
1629 AC_DEFINE(DYNAMIC_PYTHON)
1630 AC_DEFINE(DYNAMIC_PYTHON3)
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001631 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001632 cflags_save=$CFLAGS
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001633 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001634 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001635 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001636 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001637 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001638 #include <dlfcn.h>
1639 /* If this program fails, then RTLD_GLOBAL is needed.
1640 * RTLD_GLOBAL will be used and then it is not possible to
1641 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001642 * Only the first python version used will be switched on.
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001643 */
1644
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001645 int no_rtl_global_needed_for(char *python_instsoname, char *prefix)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001646 {
1647 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001648 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001649 if (pylib != 0)
1650 {
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001651 void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome");
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001652 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1653 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1654 void (*final)(void) = dlsym(pylib, "Py_Finalize");
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001655 (*pfx)(prefix);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001656 (*init)();
1657 needed = (*simple)("import termios") == -1;
1658 (*final)();
1659 dlclose(pylib);
1660 }
1661 return !needed;
1662 }
1663
1664 int main(int argc, char** argv)
1665 {
1666 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001667 if (no_rtl_global_needed_for("${vi_cv_dll_name_python}", "${vi_cv_path_python_pfx}"))
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001668 not_needed = 1;
1669 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001670 }])],
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001671 [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001672
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001673 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001674 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001675
1676 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python3)
1677 cflags_save=$CFLAGS
1678 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001679 libs_save=$LIBS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001680 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001681 LIBS="-ldl $LIBS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001682 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001683 #include <dlfcn.h>
1684 #include <wchar.h>
1685 /* If this program fails, then RTLD_GLOBAL is needed.
1686 * RTLD_GLOBAL will be used and then it is not possible to
1687 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001688 * Only the first python version used will be switched on.
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001689 */
1690
1691 int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix)
1692 {
1693 int needed = 0;
Bram Moolenaarba59ddb2016-01-28 15:34:25 +01001694 void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001695 if (pylib != 0)
1696 {
1697 void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome");
1698 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1699 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1700 void (*final)(void) = dlsym(pylib, "Py_Finalize");
1701 (*pfx)(prefix);
1702 (*init)();
1703 needed = (*simple)("import termios") == -1;
1704 (*final)();
1705 dlclose(pylib);
1706 }
1707 return !needed;
1708 }
1709
1710 int main(int argc, char** argv)
1711 {
1712 int not_needed = 0;
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001713 if (no_rtl_global_needed_for("${vi_cv_dll_name_python3}", L"${vi_cv_path_python3_pfx}"))
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001714 not_needed = 1;
1715 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001716 }])],
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001717 [AC_MSG_RESULT(yes);AC_DEFINE(PY3_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
1718
1719 CFLAGS=$cflags_save
Bram Moolenaar5d3fbf32015-03-05 16:47:20 +01001720 LIBS=$libs_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001721
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001722 PYTHON_SRC="if_python.c"
1723 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001724 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001725 PYTHON_LIBS=
1726 PYTHON3_SRC="if_python3.c"
1727 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001728 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001729 PYTHON3_LIBS=
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001730elif test "$python_ok" = yes && test "$enable_pythoninterp" = "dynamic"; then
1731 AC_DEFINE(DYNAMIC_PYTHON)
1732 PYTHON_SRC="if_python.c"
1733 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001734 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${vi_cv_dll_name_python}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001735 PYTHON_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001736elif test "$python_ok" = yes; then
1737 dnl Check that adding -fPIE works. It may be needed when using a static
1738 dnl Python library.
1739 AC_MSG_CHECKING([if -fPIE can be added for Python])
1740 cflags_save=$CFLAGS
1741 libs_save=$LIBS
1742 CFLAGS="$CFLAGS $PYTHON_CFLAGS -fPIE"
1743 LIBS="$LIBS $PYTHON_LIBS"
1744 AC_TRY_LINK(,[ ],
1745 AC_MSG_RESULT(yes); fpie_ok=yes,
1746 AC_MSG_RESULT(no); fpie_ok=no)
1747 CFLAGS=$cflags_save
1748 LIBS=$libs_save
1749 if test $fpie_ok = yes; then
1750 PYTHON_CFLAGS="$PYTHON_CFLAGS -fPIE"
1751 fi
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001752elif test "$python3_ok" = yes && test "$enable_python3interp" = "dynamic"; then
1753 AC_DEFINE(DYNAMIC_PYTHON3)
1754 PYTHON3_SRC="if_python3.c"
1755 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaarcf1b0572014-05-22 14:44:22 +02001756 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${vi_cv_dll_name_python3}\\\""
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001757 PYTHON3_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001758elif test "$python3_ok" = yes; then
1759 dnl Check that adding -fPIE works. It may be needed when using a static
1760 dnl Python library.
1761 AC_MSG_CHECKING([if -fPIE can be added for Python3])
1762 cflags_save=$CFLAGS
1763 libs_save=$LIBS
1764 CFLAGS="$CFLAGS $PYTHON3_CFLAGS -fPIE"
1765 LIBS="$LIBS $PYTHON3_LIBS"
1766 AC_TRY_LINK(,[ ],
1767 AC_MSG_RESULT(yes); fpie_ok=yes,
1768 AC_MSG_RESULT(no); fpie_ok=no)
1769 CFLAGS=$cflags_save
1770 LIBS=$libs_save
1771 if test $fpie_ok = yes; then
1772 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -fPIE"
1773 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001774fi
1775
Bram Moolenaar071d4272004-06-13 20:20:40 +00001776AC_MSG_CHECKING(--enable-tclinterp argument)
1777AC_ARG_ENABLE(tclinterp,
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001778 [ --enable-tclinterp[=OPTS] Include Tcl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001779 [enable_tclinterp="no"])
1780AC_MSG_RESULT($enable_tclinterp)
1781
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001782if test "$enable_tclinterp" = "yes" -o "$enable_tclinterp" = "dynamic"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001783
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001784 dnl on FreeBSD tclsh is a silly script, look for tclsh8.[5420]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001785 AC_MSG_CHECKING(--with-tclsh argument)
1786 AC_ARG_WITH(tclsh, [ --with-tclsh=PATH which tclsh to use (default: tclsh8.0)],
1787 tclsh_name="$withval"; AC_MSG_RESULT($tclsh_name),
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001788 tclsh_name="tclsh8.5"; AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00001789 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1790 AC_SUBST(vi_cv_path_tcl)
1791
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001792 dnl when no specific version specified, also try 8.4, 8.2 and 8.0
1793 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.5"; then
1794 tclsh_name="tclsh8.4"
1795 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1796 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001797 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.4"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001798 tclsh_name="tclsh8.2"
1799 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1800 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001801 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.2"; then
1802 tclsh_name="tclsh8.0"
1803 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1804 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001805 dnl still didn't find it, try without version number
1806 if test "X$vi_cv_path_tcl" = "X"; then
1807 tclsh_name="tclsh"
1808 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1809 fi
1810 if test "X$vi_cv_path_tcl" != "X"; then
1811 AC_MSG_CHECKING(Tcl version)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001812 if echo 'exit [[expr [info tclversion] < 8.0]]' | "$vi_cv_path_tcl" - ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001813 tclver=`echo 'puts [[info tclversion]]' | $vi_cv_path_tcl -`
1814 AC_MSG_RESULT($tclver - OK);
1815 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 +01001816 tcldll=`echo 'puts libtcl[[info tclversion]][[info sharedlibextension]]' | $vi_cv_path_tcl -`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001817
1818 AC_MSG_CHECKING(for location of Tcl include)
Bram Moolenaard0573012017-10-28 21:11:06 +02001819 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001820 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 +00001821 else
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001822 dnl For all macOS, use the value from TCL in case use of, say, homebrew
Bram Moolenaar071d4272004-06-13 20:20:40 +00001823 dnl For Mac OS X 10.3, use the OS-provided framework location
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001824 dnl For Mac OS X 10.14, the OS-provided framework location doesn't contain the headers, so also check the Xcode SDK
1825 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 +00001826 fi
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001827 TCL_INC=
Bram Moolenaar071d4272004-06-13 20:20:40 +00001828 for try in $tclinc; do
1829 if test -f "$try/tcl.h"; then
1830 AC_MSG_RESULT($try/tcl.h)
1831 TCL_INC=$try
1832 break
1833 fi
1834 done
1835 if test -z "$TCL_INC"; then
1836 AC_MSG_RESULT(<not found>)
1837 SKIP_TCL=YES
1838 fi
1839 if test -z "$SKIP_TCL"; then
1840 AC_MSG_CHECKING(for location of tclConfig.sh script)
Bram Moolenaard0573012017-10-28 21:11:06 +02001841 if test "x$MACOS_X" != "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001842 tclcnf=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001843 tclcnf="$tclcnf `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001844 else
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001845 dnl For all macOS, use the value from TCL in case use of, say, homebrew
Bram Moolenaar071d4272004-06-13 20:20:40 +00001846 dnl For Mac OS X 10.3, use the OS-provided framework location
Bram Moolenaarf4ee5282020-07-30 20:18:08 +02001847 dnl For Mac OS X 10.14, the OS-provided framework location doesn't contain the headers, so also check the Xcode SDK
1848 tclcnf=`echo $tclinc | sed s/include/lib/g`
1849 tclcnf="$tclcnf /System/Library/Frameworks/Tcl.framework `xcrun --show-sdk-path`/System/Library/Frameworks/Tcl.framework"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001850 fi
1851 for try in $tclcnf; do
Bram Moolenaar49222be2015-12-11 18:11:30 +01001852 if test -f "$try/tclConfig.sh"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001853 AC_MSG_RESULT($try/tclConfig.sh)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001854 . "$try/tclConfig.sh"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001855 dnl use eval, because tcl 8.2 includes ${TCL_DBGX}
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001856 if test "$enable_tclinterp" = "dynamic"; then
1857 TCL_LIBS=`eval echo "$TCL_STUB_LIB_SPEC $TCL_LIBS"`
1858 else
1859 TCL_LIBS=`eval echo "$TCL_LIB_SPEC $TCL_LIBS"`
1860 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001861 dnl Use $TCL_DEFS for -D_THREAD_SAFE et al. But only use the
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001862 dnl "-D_ABC" items. Watch out for -DFOO=long\ long.
Bram Moolenaar4394bff2008-07-24 11:21:31 +00001863 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 +00001864 break
1865 fi
1866 done
1867 if test -z "$TCL_LIBS"; then
1868 AC_MSG_RESULT(<not found>)
1869 AC_MSG_CHECKING(for Tcl library by myself)
1870 tcllib=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001871 tcllib="$tcllib `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001872 for ext in .so .a ; do
1873 for ver in "" $tclver ; do
1874 for try in $tcllib ; do
1875 trylib=tcl$ver$ext
Bram Moolenaar49222be2015-12-11 18:11:30 +01001876 if test -f "$try/lib$trylib" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001877 AC_MSG_RESULT($try/lib$trylib)
Bram Moolenaar49222be2015-12-11 18:11:30 +01001878 TCL_LIBS="-L\"$try\" -ltcl$ver -ldl -lm"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001879 if test "`(uname) 2>/dev/null`" = SunOS &&
1880 uname -r | grep '^5' >/dev/null; then
1881 TCL_LIBS="$TCL_LIBS -R $try"
1882 fi
1883 break 3
1884 fi
1885 done
1886 done
1887 done
1888 if test -z "$TCL_LIBS"; then
1889 AC_MSG_RESULT(<not found>)
1890 SKIP_TCL=YES
1891 fi
1892 fi
1893 if test -z "$SKIP_TCL"; then
1894 AC_DEFINE(FEAT_TCL)
1895 TCL_SRC=if_tcl.c
1896 TCL_OBJ=objects/if_tcl.o
1897 TCL_PRO=if_tcl.pro
1898 TCL_CFLAGS="-I$TCL_INC $TCL_DEFS"
1899 fi
1900 fi
1901 else
1902 AC_MSG_RESULT(too old; need Tcl version 8.0 or later)
1903 fi
1904 fi
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01001905 if test "$enable_tclinterp" = "dynamic"; then
1906 if test "X$TCL_SRC" != "X" -a "X$tcldll" != "X"; then
1907 AC_DEFINE(DYNAMIC_TCL)
1908 TCL_CFLAGS="-DDYNAMIC_TCL_DLL=\\\"$tcldll\\\" -DDYNAMIC_TCL_VER=\\\"$tclver\\\" $TCL_CFLAGS"
1909 fi
1910 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001911 if test "$fail_if_missing" = "yes" -a -z "$TCL_SRC"; then
1912 AC_MSG_ERROR([could not configure Tcl])
1913 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001914fi
1915AC_SUBST(TCL_SRC)
1916AC_SUBST(TCL_OBJ)
1917AC_SUBST(TCL_PRO)
1918AC_SUBST(TCL_CFLAGS)
1919AC_SUBST(TCL_LIBS)
1920
1921AC_MSG_CHECKING(--enable-rubyinterp argument)
1922AC_ARG_ENABLE(rubyinterp,
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001923 [ --enable-rubyinterp[=OPTS] Include Ruby interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001924 [enable_rubyinterp="no"])
1925AC_MSG_RESULT($enable_rubyinterp)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001926if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar0b105412014-11-30 13:34:23 +01001927 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
1928 AC_MSG_ERROR([cannot use Ruby with tiny or small features])
1929 fi
1930
Bram Moolenaar165641d2010-02-17 16:23:09 +01001931 AC_MSG_CHECKING(--with-ruby-command argument)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001932 AC_SUBST(vi_cv_path_ruby)
Bram Moolenaar948733a2011-05-05 18:10:16 +02001933 AC_ARG_WITH(ruby-command, [ --with-ruby-command=RUBY name of the Ruby command (default: ruby)],
1934 RUBY_CMD="$withval"; vi_cv_path_ruby="$withval"; AC_MSG_RESULT($RUBY_CMD),
1935 RUBY_CMD="ruby"; AC_MSG_RESULT(defaulting to $RUBY_CMD))
Bram Moolenaar165641d2010-02-17 16:23:09 +01001936 AC_PATH_PROG(vi_cv_path_ruby, $RUBY_CMD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001937 if test "X$vi_cv_path_ruby" != "X"; then
1938 AC_MSG_CHECKING(Ruby version)
Bram Moolenaare4efc3b2005-03-07 23:16:51 +00001939 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 +00001940 AC_MSG_RESULT(OK)
Bram Moolenaar81398892012-10-03 21:09:35 +02001941 AC_MSG_CHECKING(Ruby rbconfig)
1942 ruby_rbconfig="RbConfig"
1943 if ! $vi_cv_path_ruby -r rbconfig -e 'RbConfig' >/dev/null 2>/dev/null; then
1944 ruby_rbconfig="Config"
1945 fi
1946 AC_MSG_RESULT($ruby_rbconfig)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001947 AC_MSG_CHECKING(Ruby header files)
Bram Moolenaar81398892012-10-03 21:09:35 +02001948 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 +00001949 if test "X$rubyhdrdir" != "X"; then
1950 AC_MSG_RESULT($rubyhdrdir)
1951 RUBY_CFLAGS="-I$rubyhdrdir"
Bram Moolenaara6fd37b2014-03-27 17:19:09 +01001952 rubyarchdir=`$vi_cv_path_ruby -r rbconfig -e "print ($ruby_rbconfig::CONFIG.has_key? 'rubyarchhdrdir') ? $ruby_rbconfig::CONFIG[['rubyarchhdrdir']] : '$rubyhdrdir/'+$ruby_rbconfig::CONFIG[['arch']]"`
1953 if test -d "$rubyarchdir"; then
1954 RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyarchdir"
Bram Moolenaar165641d2010-02-17 16:23:09 +01001955 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001956 rubyversion=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['ruby_version']].gsub(/\./, '')[[0,2]]"`
Bram Moolenaar026a4452013-08-07 15:22:23 +02001957 if test "X$rubyversion" = "X"; then
1958 rubyversion=`$vi_cv_path_ruby -e "print ((VERSION rescue RUBY_VERSION)).gsub(/\./, '')[[0,2]]"`
1959 fi
Bram Moolenaar165641d2010-02-17 16:23:09 +01001960 RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
Bram Moolenaar81398892012-10-03 21:09:35 +02001961 rubylibs=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LIBS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001962 if test "X$rubylibs" != "X"; then
1963 RUBY_LIBS="$rubylibs"
1964 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001965 librubyarg=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBYARG']])"`
1966 librubya=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBY_A']])"`
Bram Moolenaarac499e32013-06-02 19:14:17 +02001967 rubylibdir=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['libdir']])"`
Bram Moolenaar948733a2011-05-05 18:10:16 +02001968 if test -f "$rubylibdir/$librubya"; then
1969 librubyarg="$librubyarg"
Bram Moolenaarac499e32013-06-02 19:14:17 +02001970 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
1971 elif test "$librubyarg" = "libruby.a"; then
1972 dnl required on Mac OS 10.3 where libruby.a doesn't exist
1973 librubyarg="-lruby"
1974 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001975 fi
1976
1977 if test "X$librubyarg" != "X"; then
1978 RUBY_LIBS="$librubyarg $RUBY_LIBS"
1979 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001980 rubyldflags=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LDFLAGS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001981 if test "X$rubyldflags" != "X"; then
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001982 dnl Ruby on Mac OS X 10.5 adds "-arch" flags but these should only
1983 dnl be included if requested by passing --with-mac-arch to
1984 dnl configure, so strip these flags first (if present)
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001985 rubyldflags=`echo "$rubyldflags" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001986 if test "X$rubyldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001987 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$rubyldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001988 LDFLAGS="$rubyldflags $LDFLAGS"
1989 fi
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001990 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001991 fi
1992 RUBY_SRC="if_ruby.c"
1993 RUBY_OBJ="objects/if_ruby.o"
1994 RUBY_PRO="if_ruby.pro"
1995 AC_DEFINE(FEAT_RUBY)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001996 if test "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar92021622017-10-12 12:33:43 +02001997 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_ALIASES']].split[[0]]"`
Bram Moolenaar87ea64c2018-08-04 15:13:34 +02001998 if test -z "$libruby_soname"; then
1999 libruby_soname=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_SO']]"`
2000 fi
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002001 AC_DEFINE(DYNAMIC_RUBY)
Bram Moolenaar41a41412020-01-07 21:32:19 +01002002 RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby_soname\\\" $RUBY_CFLAGS"
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02002003 RUBY_LIBS=
2004 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002005 else
Bram Moolenaar165641d2010-02-17 16:23:09 +01002006 AC_MSG_RESULT(not found; disabling Ruby)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002007 fi
2008 else
2009 AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
2010 fi
2011 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01002012
2013 if test "$fail_if_missing" = "yes" -a -z "$RUBY_OBJ"; then
2014 AC_MSG_ERROR([could not configure Ruby])
2015 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002016fi
2017AC_SUBST(RUBY_SRC)
2018AC_SUBST(RUBY_OBJ)
2019AC_SUBST(RUBY_PRO)
2020AC_SUBST(RUBY_CFLAGS)
2021AC_SUBST(RUBY_LIBS)
2022
2023AC_MSG_CHECKING(--enable-cscope argument)
2024AC_ARG_ENABLE(cscope,
2025 [ --enable-cscope Include cscope interface.], ,
2026 [enable_cscope="no"])
2027AC_MSG_RESULT($enable_cscope)
2028if test "$enable_cscope" = "yes"; then
2029 AC_DEFINE(FEAT_CSCOPE)
2030fi
2031
Bram Moolenaar071d4272004-06-13 20:20:40 +00002032AC_MSG_CHECKING(--disable-netbeans argument)
2033AC_ARG_ENABLE(netbeans,
2034 [ --disable-netbeans Disable NetBeans integration support.],
2035 , [enable_netbeans="yes"])
2036if test "$enable_netbeans" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002037 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2038 AC_MSG_RESULT([cannot use NetBeans with tiny or small features])
2039 enable_netbeans="no"
2040 else
2041 AC_MSG_RESULT(no)
2042 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002043else
2044 AC_MSG_RESULT(yes)
2045fi
2046
2047AC_MSG_CHECKING(--disable-channel argument)
2048AC_ARG_ENABLE(channel,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002049 [ --disable-channel Disable process communication support.],
Bram Moolenaare0874f82016-01-24 20:36:41 +01002050 , [enable_channel="yes"])
2051if test "$enable_channel" = "yes"; then
Bram Moolenaar3c124e32016-01-31 14:36:58 +01002052 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2053 AC_MSG_RESULT([cannot use channels with tiny or small features])
2054 enable_channel="no"
2055 else
2056 AC_MSG_RESULT(no)
2057 fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002058else
2059 if test "$enable_netbeans" = "yes"; then
Bram Moolenaar16435482016-01-24 21:31:54 +01002060 AC_MSG_RESULT([yes, netbeans also disabled])
Bram Moolenaare0874f82016-01-24 20:36:41 +01002061 enable_netbeans="no"
2062 else
2063 AC_MSG_RESULT(yes)
2064 fi
2065fi
2066
Bram Moolenaar16435482016-01-24 21:31:54 +01002067if test "$enable_channel" = "yes"; then
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002068 dnl On Solaris we need the socket library, or on Haiku the network library.
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002069 if test "x$HAIKU" = "xyes"; then
2070 AC_CHECK_LIB(network, socket)
2071 else
2072 AC_CHECK_LIB(socket, socket)
2073 fi
2074
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002075 AC_CACHE_CHECK([whether compiling with IPv6 networking is possible], [vim_cv_ipv6_networking],
2076 [AC_TRY_LINK([
2077#include <stdio.h>
2078#include <stdlib.h>
2079#include <stdarg.h>
2080#include <fcntl.h>
2081#include <netdb.h>
2082#include <netinet/in.h>
2083#include <errno.h>
2084#include <sys/types.h>
2085#include <sys/socket.h>
2086 /* Check bitfields */
2087 struct nbbuf {
2088 unsigned int initDone:1;
2089 unsigned short signmaplen;
2090 };
2091 ], [
2092 /* Check creating a socket. */
2093 struct sockaddr_in server;
2094 struct addrinfo *res;
2095 (void)socket(AF_INET, SOCK_STREAM, 0);
2096 (void)htons(100);
2097 (void)getaddrinfo("microsoft.com", NULL, NULL, &res);
2098 if (errno == ECONNREFUSED)
2099 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
2100 (void)freeaddrinfo(res);
2101 ],
2102 [vim_cv_ipv6_networking="yes"],
2103 [vim_cv_ipv6_networking="no"])])
2104
2105 if test "x$vim_cv_ipv6_networking" = "xyes"; then
2106 AC_DEFINE(FEAT_IPV6)
Bram Moolenaarb6fb0512020-04-18 18:24:18 +02002107 AC_CHECK_FUNCS(inet_ntop)
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002108 else
2109 dnl On Solaris we need the nsl library.
2110 AC_CHECK_LIB(nsl, gethostbyname)
2111 AC_CACHE_CHECK([whether compiling with IPv4 networking is possible], [vim_cv_ipv4_networking],
2112 [AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00002113#include <stdio.h>
2114#include <stdlib.h>
2115#include <stdarg.h>
2116#include <fcntl.h>
2117#include <netdb.h>
2118#include <netinet/in.h>
2119#include <errno.h>
2120#include <sys/types.h>
2121#include <sys/socket.h>
2122 /* Check bitfields */
2123 struct nbbuf {
2124 unsigned int initDone:1;
Bram Moolenaar63de19e2016-12-09 20:11:26 +01002125 unsigned short signmaplen;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002126 };
2127 ], [
2128 /* Check creating a socket. */
2129 struct sockaddr_in server;
2130 (void)socket(AF_INET, SOCK_STREAM, 0);
2131 (void)htons(100);
2132 (void)gethostbyname("microsoft.com");
2133 if (errno == ECONNREFUSED)
2134 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
2135 ],
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02002136 [vim_cv_ipv4_networking="yes"],
2137 [vim_cv_ipv4_networking="no"; enable_netbeans="no"; enable_channel="no"])])
2138 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002139fi
2140if test "$enable_netbeans" = "yes"; then
2141 AC_DEFINE(FEAT_NETBEANS_INTG)
2142 NETBEANS_SRC="netbeans.c"
2143 AC_SUBST(NETBEANS_SRC)
2144 NETBEANS_OBJ="objects/netbeans.o"
2145 AC_SUBST(NETBEANS_OBJ)
2146fi
Bram Moolenaare0874f82016-01-24 20:36:41 +01002147if test "$enable_channel" = "yes"; then
Bram Moolenaar509ce2a2016-03-11 22:52:15 +01002148 AC_DEFINE(FEAT_JOB_CHANNEL)
Bram Moolenaar8b5866d2020-09-05 15:48:51 +02002149 CHANNEL_SRC="job.c channel.c"
Bram Moolenaare0874f82016-01-24 20:36:41 +01002150 AC_SUBST(CHANNEL_SRC)
Bram Moolenaar8b5866d2020-09-05 15:48:51 +02002151 CHANNEL_OBJ="objects/job.o objects/channel.o"
Bram Moolenaare0874f82016-01-24 20:36:41 +01002152 AC_SUBST(CHANNEL_OBJ)
2153fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002154
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002155AC_MSG_CHECKING(--enable-terminal argument)
2156AC_ARG_ENABLE(terminal,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002157 [ --enable-terminal Enable terminal emulation support.],
Bram Moolenaaref839562017-10-28 20:28:23 +02002158 , [enable_terminal="auto"])
Bram Moolenaar595a4022017-09-03 19:15:57 +02002159if test "$enable_terminal" = "yes" || test "$enable_terminal" = "auto" -a "x$features" = "xhuge" ; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002160 if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then
2161 AC_MSG_RESULT([cannot use terminal emulator with tiny or small features])
2162 enable_terminal="no"
2163 else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002164 if test "$enable_terminal" = "auto"; then
2165 enable_terminal="yes"
2166 AC_MSG_RESULT(defaulting to yes)
2167 else
2168 AC_MSG_RESULT(yes)
2169 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002170 fi
2171else
Bram Moolenaar595a4022017-09-03 19:15:57 +02002172 if test "$enable_terminal" = "auto"; then
2173 enable_terminal="no"
2174 AC_MSG_RESULT(defaulting to no)
2175 else
2176 AC_MSG_RESULT(no)
2177 fi
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002178fi
Bram Moolenaar8b423282017-12-16 14:37:06 +01002179if test "$enable_terminal" = "yes" -a "$enable_channel" = "yes"; then
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002180 AC_DEFINE(FEAT_TERMINAL)
Bram Moolenaar93268052019-10-10 13:22:54 +02002181 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 +02002182 AC_SUBST(TERM_SRC)
Bram Moolenaar93268052019-10-10 13:22:54 +02002183 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 +02002184 AC_SUBST(TERM_OBJ)
Bram Moolenaar823edd12019-10-23 22:35:36 +02002185 TERM_TEST="test_libvterm"
2186 AC_SUBST(TERM_TEST)
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002187fi
2188
Bram Moolenaare42a6d22017-11-12 19:21:51 +01002189AC_MSG_CHECKING(--enable-autoservername argument)
2190AC_ARG_ENABLE(autoservername,
2191 [ --enable-autoservername Automatically define servername at vim startup.], ,
2192 [enable_autoservername="no"])
2193AC_MSG_RESULT($enable_autoservername)
2194if test "$enable_autoservername" = "yes"; then
2195 AC_DEFINE(FEAT_AUTOSERVERNAME)
2196fi
2197
Bram Moolenaar071d4272004-06-13 20:20:40 +00002198AC_MSG_CHECKING(--enable-multibyte argument)
2199AC_ARG_ENABLE(multibyte,
2200 [ --enable-multibyte Include multibyte editing support.], ,
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01002201 [enable_multibyte="yes"])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002202AC_MSG_RESULT($enable_multibyte)
Bram Moolenaar30276f22019-01-24 17:59:39 +01002203if test "$enable_multibyte" != "yes"; then
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01002204 AC_MSG_ERROR([The multi-byte feature can no longer be disabled. If you have
2205 a problem with this, discuss on the Vim mailing list.])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002206fi
2207
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002208dnl Right-to-Left language support for Vim will be included with big features,
2209dnl unless ENABLE_RIGHTLEFT is undefined.
2210AC_MSG_CHECKING(--disable-rightleft argument)
2211AC_ARG_ENABLE(rightleft,
2212 [ --disable-rightleft Do not include Right-to-Left language support.],
2213 , [enable_rightleft="yes"])
2214if test "$enable_rightleft" = "yes"; then
2215 AC_MSG_RESULT(no)
2216else
2217 AC_MSG_RESULT(yes)
2218 AC_DEFINE(DISABLE_RIGHTLEFT)
2219fi
2220
2221dnl Arabic language support for Vim will be included with big features,
2222dnl unless ENABLE_ARABIC is undefined.
2223AC_MSG_CHECKING(--disable-arabic argument)
2224AC_ARG_ENABLE(arabic,
2225 [ --disable-arabic Do not include Arabic language support.],
2226 , [enable_arabic="yes"])
2227if test "$enable_arabic" = "yes"; then
2228 AC_MSG_RESULT(no)
2229else
2230 AC_MSG_RESULT(yes)
2231 AC_DEFINE(DISABLE_ARABIC)
2232fi
2233
Bram Moolenaar14184a32019-02-16 15:10:30 +01002234dnl Farsi language support has been removed, ignore --disable-farsi
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002235AC_ARG_ENABLE(farsi,
Bram Moolenaar14184a32019-02-16 15:10:30 +01002236 [ --disable-farsi Deprecated.],,)
Bram Moolenaar5c5697f2018-12-12 20:34:09 +01002237
Bram Moolenaar071d4272004-06-13 20:20:40 +00002238AC_MSG_CHECKING(--enable-xim argument)
2239AC_ARG_ENABLE(xim,
2240 [ --enable-xim Include XIM input support.],
2241 AC_MSG_RESULT($enable_xim),
2242 [enable_xim="auto"; AC_MSG_RESULT(defaulting to auto)])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002243
2244AC_MSG_CHECKING(--enable-fontset argument)
2245AC_ARG_ENABLE(fontset,
2246 [ --enable-fontset Include X fontset output support.], ,
2247 [enable_fontset="no"])
2248AC_MSG_RESULT($enable_fontset)
2249dnl defining FEAT_XFONTSET is delayed, so that it can be disabled for no GUI
2250
2251test -z "$with_x" && with_x=yes
Bram Moolenaard0573012017-10-28 21:11:06 +02002252test "${enable_gui-yes}" != no -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && with_x=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002253if test "$with_x" = no; then
2254 AC_MSG_RESULT(defaulting to: don't HAVE_X11)
2255else
2256 dnl Do this check early, so that its failure can override user requests.
2257
2258 AC_PATH_PROG(xmkmfpath, xmkmf)
2259
2260 AC_PATH_XTRA
2261
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002262 dnl On z/OS Unix the X libraries are DLLs. To use them the code must
Bram Moolenaar071d4272004-06-13 20:20:40 +00002263 dnl be compiled with a special option.
2264 dnl Also add SM, ICE and Xmu to X_EXTRA_LIBS.
Bram Moolenaar2c704a72010-06-03 21:17:25 +02002265 if test "$zOSUnix" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002266 CFLAGS="$CFLAGS -W c,dll"
2267 LDFLAGS="$LDFLAGS -W l,dll"
2268 X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE -lXmu"
2269 fi
2270
2271 dnl On my HPUX system the X include dir is found, but the lib dir not.
Bram Moolenaar70778922020-02-05 20:44:24 +01002272 dnl This is a desperate try to fix this.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002273
2274 if test -d "$x_includes" && test ! -d "$x_libraries"; then
2275 x_libraries=`echo "$x_includes" | sed s/include/lib/`
2276 AC_MSG_RESULT(Corrected X libraries to $x_libraries)
2277 X_LIBS="$X_LIBS -L$x_libraries"
2278 if test "`(uname) 2>/dev/null`" = SunOS &&
2279 uname -r | grep '^5' >/dev/null; then
2280 X_LIBS="$X_LIBS -R $x_libraries"
2281 fi
2282 fi
2283
2284 if test -d "$x_libraries" && test ! -d "$x_includes"; then
2285 x_includes=`echo "$x_libraries" | sed s/lib/include/`
2286 AC_MSG_RESULT(Corrected X includes to $x_includes)
2287 X_CFLAGS="$X_CFLAGS -I$x_includes"
2288 fi
2289
2290 dnl Remove "-I/usr/include " from X_CFLAGS, should not be needed.
2291 X_CFLAGS="`echo $X_CFLAGS\ | sed 's%-I/usr/include %%'`"
2292 dnl Remove "-L/usr/lib " from X_LIBS, should not be needed.
2293 X_LIBS="`echo $X_LIBS\ | sed 's%-L/usr/lib %%'`"
2294 dnl Same for "-R/usr/lib ".
2295 X_LIBS="`echo $X_LIBS\ | sed -e 's%-R/usr/lib %%' -e 's%-R /usr/lib %%'`"
2296
2297
2298 dnl Check if the X11 header files are correctly installed. On some systems
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002299 dnl Xlib.h includes files that don't exist. On some systems X11/Intrinsic.h
2300 dnl is missing.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002301 AC_MSG_CHECKING(if X11 header files can be found)
2302 cflags_save=$CFLAGS
2303 CFLAGS="$CFLAGS $X_CFLAGS"
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002304 AC_TRY_COMPILE([#include <X11/Xlib.h>
2305#include <X11/Intrinsic.h>], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002306 AC_MSG_RESULT(yes),
2307 AC_MSG_RESULT(no); no_x=yes)
2308 CFLAGS=$cflags_save
2309
2310 if test "${no_x-no}" = yes; then
2311 with_x=no
2312 else
2313 AC_DEFINE(HAVE_X11)
2314 X_LIB="-lXt -lX11";
2315 AC_SUBST(X_LIB)
2316
2317 ac_save_LDFLAGS="$LDFLAGS"
2318 LDFLAGS="-L$x_libraries $LDFLAGS"
2319
2320 dnl Check for -lXdmcp (needed on SunOS 4.1.4)
2321 dnl For HP-UX 10.20 it must be before -lSM -lICE
2322 AC_CHECK_LIB(Xdmcp, _XdmcpAuthDoIt, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lXdmcp"],,
2323 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXdmcp])
2324
2325 dnl Some systems need -lnsl -lsocket when testing for ICE.
2326 dnl The check above doesn't do this, try here (again). Also needed to get
2327 dnl them after Xdmcp. link.sh will remove them when not needed.
2328 dnl Check for other function than above to avoid the cached value
2329 AC_CHECK_LIB(ICE, IceOpenConnection,
2330 [X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE"],, [$X_EXTRA_LIBS])
2331
2332 dnl Check for -lXpm (needed for some versions of Motif)
2333 LDFLAGS="$X_LIBS $ac_save_LDFLAGS"
2334 AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [X_PRE_LIBS="$X_PRE_LIBS -lXpm"],,
2335 [-lXt $X_PRE_LIBS -lXpm -lX11 $X_EXTRA_LIBS])
2336
2337 dnl Check that the X11 header files don't use implicit declarations
2338 AC_MSG_CHECKING(if X11 header files implicitly declare return values)
2339 cflags_save=$CFLAGS
Bram Moolenaard1864592013-05-04 04:40:15 +02002340 dnl -Werror is GCC only, others like Solaris Studio might not like it
2341 if test "$GCC" = yes; then
2342 CFLAGS="$CFLAGS $X_CFLAGS -Werror"
2343 else
2344 CFLAGS="$CFLAGS $X_CFLAGS"
2345 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002346 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2347 AC_MSG_RESULT(no),
2348 CFLAGS="$CFLAGS -Wno-implicit-int"
2349 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
2350 AC_MSG_RESULT(yes); cflags_save="$cflags_save -Wno-implicit-int",
2351 AC_MSG_RESULT(test failed)
2352 )
2353 )
2354 CFLAGS=$cflags_save
2355
2356 LDFLAGS="$ac_save_LDFLAGS"
2357
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002358 AC_MSG_CHECKING(size of wchar_t is 2 bytes)
2359 AC_CACHE_VAL(ac_cv_small_wchar_t,
2360 [AC_TRY_RUN([
2361#include <X11/Xlib.h>
2362#if STDC_HEADERS
2363# include <stdlib.h>
2364# include <stddef.h>
2365#endif
2366 main()
2367 {
2368 if (sizeof(wchar_t) <= 2)
2369 exit(1);
2370 exit(0);
2371 }],
2372 ac_cv_small_wchar_t="no",
2373 ac_cv_small_wchar_t="yes",
2374 AC_MSG_ERROR(failed to compile test program))])
2375 AC_MSG_RESULT($ac_cv_small_wchar_t)
2376 if test "x$ac_cv_small_wchar_t" = "xyes" ; then
2377 AC_DEFINE(SMALL_WCHAR_T)
2378 fi
2379
Bram Moolenaar071d4272004-06-13 20:20:40 +00002380 fi
2381fi
2382
Bram Moolenaard2a05492018-07-27 22:35:15 +02002383dnl Check if --with-x was given but it doesn't work.
2384if test "x$with_x" = xno -a "x$with_x_arg" = xyes; then
2385 AC_MSG_ERROR([could not configure X])
2386fi
2387
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002388test "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 +00002389
2390AC_MSG_CHECKING(--enable-gui argument)
2391AC_ARG_ENABLE(gui,
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002392 [ --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 +00002393
2394dnl Canonicalize the --enable-gui= argument so that it can be easily compared.
2395dnl Do not use character classes for portability with old tools.
2396enable_gui_canon=`echo "_$enable_gui" | \
2397 sed 's/[[ _+-]]//g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
2398
2399dnl Skip everything by default.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002400SKIP_GTK2=YES
Bram Moolenaar1858a842016-02-23 22:30:31 +01002401SKIP_GTK3=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002402SKIP_GNOME=YES
2403SKIP_MOTIF=YES
2404SKIP_ATHENA=YES
2405SKIP_NEXTAW=YES
2406SKIP_PHOTON=YES
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002407SKIP_HAIKU=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002408GUITYPE=NONE
2409
Bram Moolenaarb3f74062020-02-26 16:16:53 +01002410if test "x$HAIKU" = "xyes"; then
2411 SKIP_HAIKU=
2412 case "$enable_gui_canon" in
2413 no) AC_MSG_RESULT(no GUI support)
2414 SKIP_HAIKU=YES ;;
2415 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
2416 auto) AC_MSG_RESULT(auto - automatic GUI support) ;;
2417 haiku) AC_MSG_RESULT(Haiku GUI support) ;;
2418 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2419 SKIP_HAIKU=YES ;;
2420 esac
2421elif test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002422 SKIP_PHOTON=
2423 case "$enable_gui_canon" in
2424 no) AC_MSG_RESULT(no GUI support)
2425 SKIP_PHOTON=YES ;;
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002426 yes|""|auto) AC_MSG_RESULT(automatic GUI support)
2427 gui_auto=yes ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002428 photon) AC_MSG_RESULT(Photon GUI support) ;;
2429 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2430 SKIP_PHOTON=YES ;;
2431 esac
2432
Bram Moolenaar040f9752020-08-11 23:08:48 +02002433elif test "x$MACOS_X" = "xyes" -a "x$with_x" = "xno" ; then
2434 case "$enable_gui_canon" in
2435 no) AC_MSG_RESULT(no GUI support) ;;
2436 yes|"") AC_MSG_RESULT(yes - automatic GUI support)
2437 gui_auto=yes ;;
2438 auto) AC_MSG_RESULT(auto - disable GUI support for Mac OS) ;;
Bram Moolenaarbe7529e2020-08-13 21:05:39 +02002439 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
Bram Moolenaar040f9752020-08-11 23:08:48 +02002440 esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00002441else
2442
Bram Moolenaar071d4272004-06-13 20:20:40 +00002443 case "$enable_gui_canon" in
2444 no|none) AC_MSG_RESULT(no GUI support) ;;
2445 yes|""|auto) AC_MSG_RESULT(yes/auto - automatic GUI support)
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002446 gui_auto=yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00002447 SKIP_GTK2=
2448 SKIP_GNOME=
2449 SKIP_MOTIF=
2450 SKIP_ATHENA=
Bram Moolenaar097148e2020-08-11 21:58:20 +02002451 SKIP_NEXTAW=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002452 gtk2) AC_MSG_RESULT(GTK+ 2.x GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002453 SKIP_GTK2=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002454 gnome2) AC_MSG_RESULT(GNOME 2.x GUI support)
2455 SKIP_GNOME=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002456 SKIP_GTK2=;;
Bram Moolenaar98921892016-02-23 17:14:37 +01002457 gtk3) AC_MSG_RESULT(GTK+ 3.x GUI support)
2458 SKIP_GTK3=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002459 motif) AC_MSG_RESULT(Motif GUI support)
2460 SKIP_MOTIF=;;
2461 athena) AC_MSG_RESULT(Athena GUI support)
2462 SKIP_ATHENA=;;
2463 nextaw) AC_MSG_RESULT(neXtaw GUI support)
2464 SKIP_NEXTAW=;;
2465 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
2466 esac
2467
2468fi
2469
Bram Moolenaar071d4272004-06-13 20:20:40 +00002470if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \
2471 -a "$enable_gui_canon" != "gnome2"; then
2472 AC_MSG_CHECKING(whether or not to look for GTK+ 2)
2473 AC_ARG_ENABLE(gtk2-check,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002474 [ --enable-gtk2-check If auto-select GUI, check for GTK+ 2 [default=yes]],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002475 , enable_gtk2_check="yes")
2476 AC_MSG_RESULT($enable_gtk2_check)
2477 if test "x$enable_gtk2_check" = "xno"; then
2478 SKIP_GTK2=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002479 SKIP_GNOME=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002480 fi
2481fi
2482
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002483if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002484 AC_MSG_CHECKING(whether or not to look for GNOME)
2485 AC_ARG_ENABLE(gnome-check,
2486 [ --enable-gnome-check If GTK GUI, check for GNOME [default=no]],
2487 , enable_gnome_check="no")
2488 AC_MSG_RESULT($enable_gnome_check)
2489 if test "x$enable_gnome_check" = "xno"; then
2490 SKIP_GNOME=YES
2491 fi
2492fi
2493
Bram Moolenaar98921892016-02-23 17:14:37 +01002494if test "x$SKIP_GTK3" != "xYES" -a "$enable_gui_canon" != "gtk3"; then
2495 AC_MSG_CHECKING(whether or not to look for GTK+ 3)
2496 AC_ARG_ENABLE(gtk3-check,
2497 [ --enable-gtk3-check If auto-select GUI, check for GTK+ 3 [default=yes]],
2498 , enable_gtk3_check="yes")
2499 AC_MSG_RESULT($enable_gtk3_check)
2500 if test "x$enable_gtk3_check" = "xno"; then
2501 SKIP_GTK3=YES
2502 fi
2503fi
2504
Bram Moolenaar071d4272004-06-13 20:20:40 +00002505if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then
2506 AC_MSG_CHECKING(whether or not to look for Motif)
2507 AC_ARG_ENABLE(motif-check,
2508 [ --enable-motif-check If auto-select GUI, check for Motif [default=yes]],
2509 , enable_motif_check="yes")
2510 AC_MSG_RESULT($enable_motif_check)
2511 if test "x$enable_motif_check" = "xno"; then
2512 SKIP_MOTIF=YES
2513 fi
2514fi
2515
2516if test "x$SKIP_ATHENA" != "xYES" -a "$enable_gui_canon" != "athena"; then
2517 AC_MSG_CHECKING(whether or not to look for Athena)
2518 AC_ARG_ENABLE(athena-check,
2519 [ --enable-athena-check If auto-select GUI, check for Athena [default=yes]],
2520 , enable_athena_check="yes")
2521 AC_MSG_RESULT($enable_athena_check)
2522 if test "x$enable_athena_check" = "xno"; then
2523 SKIP_ATHENA=YES
2524 fi
2525fi
2526
2527if test "x$SKIP_NEXTAW" != "xYES" -a "$enable_gui_canon" != "nextaw"; then
2528 AC_MSG_CHECKING(whether or not to look for neXtaw)
2529 AC_ARG_ENABLE(nextaw-check,
2530 [ --enable-nextaw-check If auto-select GUI, check for neXtaw [default=yes]],
2531 , enable_nextaw_check="yes")
2532 AC_MSG_RESULT($enable_nextaw_check);
2533 if test "x$enable_nextaw_check" = "xno"; then
2534 SKIP_NEXTAW=YES
2535 fi
2536fi
2537
Bram Moolenaar071d4272004-06-13 20:20:40 +00002538dnl define an autoconf function to check for a specified version of GTK, and
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002539dnl try to compile/link a GTK program.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002540dnl
2541dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002542dnl Test for GTK, and define GTK_CFLAGS, GTK_LIBDIR and GTK_LIBS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002543dnl
2544AC_DEFUN(AM_PATH_GTK,
2545[
2546 if test "X$GTK_CONFIG" != "Xno" -o "X$PKG_CONFIG" != "Xno"; then
2547 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00002548 no_gtk=""
2549 if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2550 && $PKG_CONFIG --exists gtk+-2.0; then
2551 {
Bram Moolenaar98921892016-02-23 17:14:37 +01002552 min_gtk_version=ifelse([$1], ,2.2.0,$1)
2553 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002554 dnl We should be using PKG_CHECK_MODULES() instead of this hack.
2555 dnl But I guess the dependency on pkgconfig.m4 is not wanted or
2556 dnl something like that.
2557 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0`
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002558 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-2.0`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002559 GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0`
2560 gtk_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2561 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2562 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2563 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2564 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2565 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2566 }
Bram Moolenaar98921892016-02-23 17:14:37 +01002567 elif (test "X$SKIP_GTK3" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2568 && $PKG_CONFIG --exists gtk+-3.0; then
2569 {
2570 min_gtk_version=ifelse([$1], ,3.0.0,$1)
2571 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
2572
2573 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-3.0`
2574 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-3.0`
2575 GTK_LIBS=`$PKG_CONFIG --libs gtk+-3.0`
2576 gtk_major_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2577 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2578 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2579 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2580 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
2581 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2582 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002583 else
2584 no_gtk=yes
2585 fi
2586
2587 if test "x$enable_gtktest" = "xyes" -a "x$no_gtk" = "x"; then
2588 {
2589 ac_save_CFLAGS="$CFLAGS"
2590 ac_save_LIBS="$LIBS"
2591 CFLAGS="$CFLAGS $GTK_CFLAGS"
2592 LIBS="$LIBS $GTK_LIBS"
2593
2594 dnl
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002595 dnl Now check if the installed GTK is sufficiently new.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002596 dnl
2597 rm -f conf.gtktest
2598 AC_TRY_RUN([
2599#include <gtk/gtk.h>
2600#include <stdio.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00002601#if STDC_HEADERS
2602# include <stdlib.h>
2603# include <stddef.h>
2604#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002605
2606int
2607main ()
2608{
2609int major, minor, micro;
2610char *tmp_version;
2611
2612system ("touch conf.gtktest");
2613
2614/* HP/UX 9 (%@#!) writes to sscanf strings */
2615tmp_version = g_strdup("$min_gtk_version");
2616if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
2617 printf("%s, bad version string\n", "$min_gtk_version");
2618 exit(1);
2619 }
2620
2621if ((gtk_major_version > major) ||
2622 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
2623 ((gtk_major_version == major) && (gtk_minor_version == minor) &&
2624 (gtk_micro_version >= micro)))
2625{
2626 return 0;
2627}
2628return 1;
2629}
2630],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
2631 CFLAGS="$ac_save_CFLAGS"
2632 LIBS="$ac_save_LIBS"
2633 }
2634 fi
2635 if test "x$no_gtk" = x ; then
2636 if test "x$enable_gtktest" = "xyes"; then
2637 AC_MSG_RESULT(yes; found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2638 else
2639 AC_MSG_RESULT(found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2640 fi
2641 ifelse([$2], , :, [$2])
2642 else
2643 {
2644 AC_MSG_RESULT(no)
2645 GTK_CFLAGS=""
2646 GTK_LIBS=""
2647 ifelse([$3], , :, [$3])
Bram Moolenaaraf0839a2018-12-30 22:55:47 +01002648 if test "$fail_if_missing" = "yes" -a "X$gui_auto" != "Xyes"; then
2649 AC_MSG_ERROR([could not configure GTK])
2650 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002651 }
2652 fi
2653 }
2654 else
2655 GTK_CFLAGS=""
2656 GTK_LIBS=""
2657 ifelse([$3], , :, [$3])
2658 fi
2659 AC_SUBST(GTK_CFLAGS)
2660 AC_SUBST(GTK_LIBS)
2661 rm -f conf.gtktest
2662])
2663
2664dnl ---------------------------------------------------------------------------
2665dnl gnome
2666dnl ---------------------------------------------------------------------------
2667AC_DEFUN([GNOME_INIT_HOOK],
2668[
2669 AC_SUBST(GNOME_LIBS)
2670 AC_SUBST(GNOME_LIBDIR)
2671 AC_SUBST(GNOME_INCLUDEDIR)
2672
2673 AC_ARG_WITH(gnome-includes,
2674 [ --with-gnome-includes=DIR Specify location of GNOME headers],
2675 [CFLAGS="$CFLAGS -I$withval"]
2676 )
2677
2678 AC_ARG_WITH(gnome-libs,
2679 [ --with-gnome-libs=DIR Specify location of GNOME libs],
2680 [LDFLAGS="$LDFLAGS -L$withval" gnome_prefix=$withval]
2681 )
2682
2683 AC_ARG_WITH(gnome,
2684 [ --with-gnome Specify prefix for GNOME files],
2685 if test x$withval = xyes; then
2686 want_gnome=yes
2687 ifelse([$1], [], :, [$1])
2688 else
2689 if test "x$withval" = xno; then
2690 want_gnome=no
2691 else
2692 want_gnome=yes
2693 LDFLAGS="$LDFLAGS -L$withval/lib"
2694 CFLAGS="$CFLAGS -I$withval/include"
2695 gnome_prefix=$withval/lib
2696 fi
2697 fi,
2698 want_gnome=yes)
2699
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002700 if test "x$want_gnome" = xyes; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002701 {
2702 AC_MSG_CHECKING(for libgnomeui-2.0)
2703 if $PKG_CONFIG --exists libgnomeui-2.0; then
2704 AC_MSG_RESULT(yes)
2705 GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0`
2706 GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0`
2707 GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0`
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002708
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002709 dnl On FreeBSD we need -pthread but pkg-config doesn't include it.
2710 dnl This might not be the right way but it works for me...
2711 AC_MSG_CHECKING(for FreeBSD)
2712 if test "`(uname) 2>/dev/null`" = FreeBSD; then
2713 AC_MSG_RESULT(yes, adding -pthread)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002714 GNOME_INCLUDEDIR="$GNOME_INCLUDEDIR -D_THREAD_SAFE"
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002715 GNOME_LIBS="$GNOME_LIBS -pthread"
2716 else
2717 AC_MSG_RESULT(no)
2718 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002719 $1
2720 else
2721 AC_MSG_RESULT(not found)
2722 if test "x$2" = xfail; then
2723 AC_MSG_ERROR(Could not find libgnomeui-2.0 via pkg-config)
2724 fi
2725 fi
2726 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002727 fi
2728])
2729
2730AC_DEFUN([GNOME_INIT],[
2731 GNOME_INIT_HOOK([],fail)
2732])
2733
Bram Moolenaar427f5b62019-06-09 13:43:51 +02002734if test "X$PKG_CONFIG" = "X"; then
2735 AC_PATH_TOOL(PKG_CONFIG, pkg-config, no)
2736fi
2737
Bram Moolenaar071d4272004-06-13 20:20:40 +00002738
2739dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002740dnl Check for GTK2. If it fails, then continue on for Motif as before...
Bram Moolenaar071d4272004-06-13 20:20:40 +00002741dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002742if test -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002743
2744 AC_MSG_CHECKING(--disable-gtktest argument)
2745 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2746 , enable_gtktest=yes)
2747 if test "x$enable_gtktest" = "xyes" ; then
2748 AC_MSG_RESULT(gtk test enabled)
2749 else
2750 AC_MSG_RESULT(gtk test disabled)
2751 fi
2752
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002753 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002754 dnl First try finding version 2.2.0 or later. The 2.0.x series has
2755 dnl problems (bold fonts, --remote doesn't work).
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002756 AM_PATH_GTK(2.2.0,
2757 [GUI_LIB_LOC="$GTK_LIBDIR"
2758 GTK_LIBNAME="$GTK_LIBS"
2759 GUI_INC_LOC="$GTK_CFLAGS"], )
2760 if test "x$GTK_CFLAGS" != "x"; then
Bram Moolenaar98921892016-02-23 17:14:37 +01002761 SKIP_GTK3=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002762 SKIP_ATHENA=YES
2763 SKIP_NEXTAW=YES
2764 SKIP_MOTIF=YES
2765 GUITYPE=GTK
2766 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002767 fi
2768 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002769 if test "x$GUITYPE" = "xGTK"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002770 dnl
2771 dnl if GTK exists, then check for GNOME.
2772 dnl
2773 if test -z "$SKIP_GNOME"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002774 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002775 GNOME_INIT_HOOK([have_gnome=yes])
2776 if test "x$have_gnome" = xyes ; then
2777 AC_DEFINE(FEAT_GUI_GNOME)
2778 GUI_INC_LOC="$GUI_INC_LOC $GNOME_INCLUDEDIR"
2779 GTK_LIBNAME="$GTK_LIBNAME $GNOME_LIBDIR $GNOME_LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002780 fi
2781 }
2782 fi
2783 fi
2784fi
2785
Bram Moolenaar98921892016-02-23 17:14:37 +01002786
2787dnl ---------------------------------------------------------------------------
2788dnl Check for GTK3.
2789dnl ---------------------------------------------------------------------------
2790if test -z "$SKIP_GTK3"; then
2791
2792 AC_MSG_CHECKING(--disable-gtktest argument)
2793 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2794 , enable_gtktest=yes)
2795 if test "x$enable_gtktest" = "xyes" ; then
2796 AC_MSG_RESULT(gtk test enabled)
2797 else
2798 AC_MSG_RESULT(gtk test disabled)
2799 fi
2800
Bram Moolenaar98921892016-02-23 17:14:37 +01002801 if test "x$PKG_CONFIG" != "xno"; then
2802 AM_PATH_GTK(3.0.0,
2803 [GUI_LIB_LOC="$GTK_LIBDIR"
2804 GTK_LIBNAME="$GTK_LIBS"
2805 GUI_INC_LOC="$GTK_CFLAGS"], )
2806 if test "x$GTK_CFLAGS" != "x"; then
2807 SKIP_GTK2=YES
2808 SKIP_GNOME=YES
2809 SKIP_ATHENA=YES
2810 SKIP_NEXTAW=YES
2811 SKIP_MOTIF=YES
2812 GUITYPE=GTK
2813 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar98921892016-02-23 17:14:37 +01002814 AC_DEFINE(USE_GTK3)
2815 fi
2816 fi
2817fi
2818
Bram Moolenaard2e03f02016-01-02 22:46:36 +01002819dnl Check the version of Gdk-Pixbuf. If the version is 2.31 or later and
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002820dnl glib-compile-resources is found in PATH, use GResource.
2821if test "x$GUITYPE" = "xGTK"; then
2822 AC_MSG_CHECKING([version of Gdk-Pixbuf])
2823 gdk_pixbuf_version=`$PKG_CONFIG --modversion gdk-pixbuf-2.0`
2824 if test "x$gdk_pixbuf_version" != x ; then
2825 gdk_pixbuf_version_minor=`echo $gdk_pixbuf_version | \
2826 sed -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/'`
2827 if test "x$gdk_pixbuf_version_minor" != x -a \
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002828 $gdk_pixbuf_version_minor -ge 31 ; then
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002829 AC_MSG_RESULT([OK.])
2830 AC_PATH_PROG(GLIB_COMPILE_RESOURCES,[glib-compile-resources],no)
2831 AC_MSG_CHECKING([glib-compile-resources])
2832 if test "x$GLIB_COMPILE_RESOURCES" = xno ; then
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002833 GLIB_COMPILE_RESOURCES=""
2834 AC_MSG_RESULT([cannot be found in PATH.])
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002835 else
2836 AC_MSG_RESULT([usable.])
Bram Moolenaar33c31d52016-02-22 21:07:06 +01002837 AC_DEFINE(USE_GRESOURCE)
2838 GRESOURCE_SRC="auto/gui_gtk_gresources.c"
2839 GRESOURCE_OBJ="objects/gui_gtk_gresources.o"
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002840 fi
2841 else
2842 AC_MSG_RESULT([not usable.])
2843 fi
2844 else
2845 AC_MSG_RESULT([cannot obtain from pkg_config.])
2846 fi
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002847
2848 AC_MSG_CHECKING([--disable-icon-cache-update argument])
2849 AC_ARG_ENABLE(icon_cache_update,
2850 [ --disable-icon-cache-update update disabled],
2851 [],
2852 [enable_icon_cache_update="yes"])
2853 if test "$enable_icon_cache_update" = "yes"; then
2854 AC_MSG_RESULT([not set])
2855 AC_PATH_PROG(GTK_UPDATE_ICON_CACHE,[gtk-update-icon-cache],no)
2856 if test "x$GTK_UPDATE_ICON_CACHE" = "xno" ; then
2857 AC_MSG_RESULT([not found in PATH.])
2858 fi
2859 else
2860 AC_MSG_RESULT([update disabled])
2861 fi
2862
2863 AC_MSG_CHECKING([--disable-desktop-database-update argument])
2864 AC_ARG_ENABLE(desktop_database_update,
2865 [ --disable-desktop-database-update update disabled],
2866 [],
2867 [enable_desktop_database_update="yes"])
2868 if test "$enable_desktop_database_update" = "yes"; then
2869 AC_MSG_RESULT([not set])
2870 AC_PATH_PROG(UPDATE_DESKTOP_DATABASE,[update-desktop-database],no)
2871 if test "x$UPDATE_DESKTOP_DATABASE" = "xno" ; then
2872 AC_MSG_RESULT([not found in PATH.])
2873 fi
2874 else
2875 AC_MSG_RESULT([update disabled])
2876 fi
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002877fi
2878AC_SUBST(GLIB_COMPILE_RESOURCES)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002879AC_SUBST(GRESOURCE_SRC)
2880AC_SUBST(GRESOURCE_OBJ)
Bram Moolenaar4adfaab2016-04-21 18:20:11 +02002881AC_SUBST(GTK_UPDATE_ICON_CACHE)
2882AC_SUBST(UPDATE_DESKTOP_DATABASE)
Bram Moolenaar36e294c2015-12-29 18:55:46 +01002883
Bram Moolenaar071d4272004-06-13 20:20:40 +00002884dnl Check for Motif include files location.
2885dnl The LAST one found is used, this makes the highest version to be used,
2886dnl e.g. when Motif1.2 and Motif2.0 are both present.
2887
2888if test -z "$SKIP_MOTIF"; then
2889 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"
2890 dnl Remove "-I" from before $GUI_INC_LOC if it's there
2891 GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`"
2892
2893 AC_MSG_CHECKING(for location of Motif GUI includes)
2894 gui_includes="`echo $x_includes|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC"
2895 GUI_INC_LOC=
2896 for try in $gui_includes; do
2897 if test -f "$try/Xm/Xm.h"; then
2898 GUI_INC_LOC=$try
2899 fi
2900 done
2901 if test -n "$GUI_INC_LOC"; then
2902 if test "$GUI_INC_LOC" = /usr/include; then
2903 GUI_INC_LOC=
2904 AC_MSG_RESULT(in default path)
2905 else
2906 AC_MSG_RESULT($GUI_INC_LOC)
2907 fi
2908 else
2909 AC_MSG_RESULT(<not found>)
2910 SKIP_MOTIF=YES
2911 fi
2912fi
2913
2914dnl Check for Motif library files location. In the same order as the include
2915dnl files, to avoid a mixup if several versions are present
2916
2917if test -z "$SKIP_MOTIF"; then
2918 AC_MSG_CHECKING(--with-motif-lib argument)
2919 AC_ARG_WITH(motif-lib,
Bram Moolenaar8008b632017-07-18 21:33:20 +02002920 [ --with-motif-lib=STRING Library for Motif ],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002921 [ MOTIF_LIBNAME="${withval}" ] )
2922
2923 if test -n "$MOTIF_LIBNAME"; then
2924 AC_MSG_RESULT($MOTIF_LIBNAME)
2925 GUI_LIB_LOC=
2926 else
2927 AC_MSG_RESULT(no)
2928
2929 dnl Remove "-L" from before $GUI_LIB_LOC if it's there
2930 GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
2931
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002932 dnl Ubuntu has libXm.so in /usr/lib/i386-linux-gnu and elsewhere. The
2933 dnl linker will figure out which one to use, we only check if one exists.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002934 AC_MSG_CHECKING(for location of Motif GUI libs)
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002935 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 +00002936 GUI_LIB_LOC=
2937 for try in $gui_libs; do
Bram Moolenaar325b7a22004-07-05 15:58:32 +00002938 for libtry in "$try"/libXm.a "$try"/libXm.so* "$try"/libXm.sl "$try"/libXm.dylib; do
Bram Moolenaar071d4272004-06-13 20:20:40 +00002939 if test -f "$libtry"; then
2940 GUI_LIB_LOC=$try
2941 fi
2942 done
2943 done
2944 if test -n "$GUI_LIB_LOC"; then
2945 dnl Remove /usr/lib, it causes trouble on some systems
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002946 if test "$GUI_LIB_LOC" = /usr/lib \
2947 -o "$GUI_LIB_LOC" = /usr/lib/i386-linux-gnu \
2948 -o "$GUI_LIB_LOC" = /usr/lib/x86_64-linux-gnu; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002949 GUI_LIB_LOC=
2950 AC_MSG_RESULT(in default path)
2951 else
2952 if test -n "$GUI_LIB_LOC"; then
2953 AC_MSG_RESULT($GUI_LIB_LOC)
2954 if test "`(uname) 2>/dev/null`" = SunOS &&
2955 uname -r | grep '^5' >/dev/null; then
2956 GUI_LIB_LOC="$GUI_LIB_LOC -R $GUI_LIB_LOC"
2957 fi
2958 fi
2959 fi
2960 MOTIF_LIBNAME=-lXm
2961 else
2962 AC_MSG_RESULT(<not found>)
2963 SKIP_MOTIF=YES
2964 fi
2965 fi
2966fi
2967
2968if test -z "$SKIP_MOTIF"; then
2969 SKIP_ATHENA=YES
2970 SKIP_NEXTAW=YES
2971 GUITYPE=MOTIF
2972 AC_SUBST(MOTIF_LIBNAME)
2973fi
2974
2975dnl Check if the Athena files can be found
2976
2977GUI_X_LIBS=
2978
2979if test -z "$SKIP_ATHENA"; then
2980 AC_MSG_CHECKING(if Athena header files can be found)
2981 cflags_save=$CFLAGS
2982 CFLAGS="$CFLAGS $X_CFLAGS"
2983 AC_TRY_COMPILE([
2984#include <X11/Intrinsic.h>
2985#include <X11/Xaw/Paned.h>], ,
2986 AC_MSG_RESULT(yes),
2987 AC_MSG_RESULT(no); SKIP_ATHENA=YES )
2988 CFLAGS=$cflags_save
2989fi
2990
2991if test -z "$SKIP_ATHENA"; then
2992 GUITYPE=ATHENA
2993fi
2994
2995if test -z "$SKIP_NEXTAW"; then
2996 AC_MSG_CHECKING(if neXtaw header files can be found)
2997 cflags_save=$CFLAGS
2998 CFLAGS="$CFLAGS $X_CFLAGS"
2999 AC_TRY_COMPILE([
3000#include <X11/Intrinsic.h>
3001#include <X11/neXtaw/Paned.h>], ,
3002 AC_MSG_RESULT(yes),
3003 AC_MSG_RESULT(no); SKIP_NEXTAW=YES )
3004 CFLAGS=$cflags_save
3005fi
3006
3007if test -z "$SKIP_NEXTAW"; then
3008 GUITYPE=NEXTAW
3009fi
3010
3011if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
3012 dnl Prepend -I and -L to $GUI_INC_LOC and $GUI_LIB_LOC if not empty
3013 dnl Avoid adding it when it twice
3014 if test -n "$GUI_INC_LOC"; then
3015 GUI_INC_LOC=-I"`echo $GUI_INC_LOC|sed 's%-I%%'`"
3016 fi
3017 if test -n "$GUI_LIB_LOC"; then
3018 GUI_LIB_LOC=-L"`echo $GUI_LIB_LOC|sed 's%-L%%'`"
3019 fi
3020
3021 dnl Check for -lXext and then for -lXmu
3022 ldflags_save=$LDFLAGS
3023 LDFLAGS="$X_LIBS $LDFLAGS"
3024 AC_CHECK_LIB(Xext, XShapeQueryExtension, [GUI_X_LIBS="-lXext"],,
3025 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3026 dnl For Solaris we need -lw and -ldl before linking with -lXmu works.
3027 AC_CHECK_LIB(w, wslen, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lw"],,
3028 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3029 AC_CHECK_LIB(dl, dlsym, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldl"],,
3030 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3031 AC_CHECK_LIB(Xmu, XmuCreateStippledPixmap, [GUI_X_LIBS="-lXmu $GUI_X_LIBS"],,
3032 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3033 if test -z "$SKIP_MOTIF"; then
3034 AC_CHECK_LIB(Xp, XpEndJob, [GUI_X_LIBS="-lXp $GUI_X_LIBS"],,
3035 [$GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
3036 fi
3037 LDFLAGS=$ldflags_save
3038
3039 dnl Execute xmkmf to figure out if -DNARROWPROTO is needed.
3040 AC_MSG_CHECKING(for extra X11 defines)
3041 NARROW_PROTO=
3042 rm -fr conftestdir
3043 if mkdir conftestdir; then
3044 cd conftestdir
3045 cat > Imakefile <<'EOF'
3046acfindx:
3047 @echo 'NARROW_PROTO="${PROTO_DEFINES}"'
3048EOF
3049 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
3050 eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
3051 fi
3052 cd ..
3053 rm -fr conftestdir
3054 fi
3055 if test -z "$NARROW_PROTO"; then
3056 AC_MSG_RESULT(no)
3057 else
3058 AC_MSG_RESULT($NARROW_PROTO)
3059 fi
3060 AC_SUBST(NARROW_PROTO)
3061fi
3062
3063dnl Look for XSMP support - but don't necessarily restrict it to X11 GUIs
3064dnl use the X11 include path
3065if test "$enable_xsmp" = "yes"; then
3066 cppflags_save=$CPPFLAGS
3067 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3068 AC_CHECK_HEADERS(X11/SM/SMlib.h)
3069 CPPFLAGS=$cppflags_save
3070fi
3071
3072
Bram Moolenaar98921892016-02-23 17:14:37 +01003073if 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 +00003074 dnl Check for X11/xpm.h and X11/Sunkeysym.h with the GUI include path
3075 cppflags_save=$CPPFLAGS
3076 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3077 AC_CHECK_HEADERS(X11/xpm.h X11/Sunkeysym.h)
3078
3079 dnl automatically disable XIM when XIMtext isn't in X11/Xlib.h
3080 if test ! "$enable_xim" = "no"; then
3081 AC_MSG_CHECKING(for XIMText in X11/Xlib.h)
3082 AC_EGREP_CPP(XIMText, [#include <X11/Xlib.h>],
3083 AC_MSG_RESULT(yes),
Bram Moolenaare29b1fe2014-04-10 20:00:15 +02003084 AC_MSG_RESULT(no; xim has been disabled); enable_xim="no")
Bram Moolenaar071d4272004-06-13 20:20:40 +00003085 fi
3086 CPPFLAGS=$cppflags_save
3087
Bram Moolenaar54612582019-11-21 17:13:31 +01003088 dnl automatically enable XIM in the GUI
3089 if test "$enable_xim" = "auto" -a "x$GUITYPE" != "xNONE" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003090 AC_MSG_RESULT(X GUI selected; xim has been enabled)
3091 enable_xim="yes"
3092 fi
3093fi
3094
3095if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
3096 cppflags_save=$CPPFLAGS
3097 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00003098dnl Xmu/Editres.h may exist but can only be used after including Intrinsic.h
3099 AC_MSG_CHECKING([for X11/Xmu/Editres.h])
3100 AC_TRY_COMPILE([
3101#include <X11/Intrinsic.h>
3102#include <X11/Xmu/Editres.h>],
3103 [int i; i = 0;],
3104 AC_MSG_RESULT(yes)
3105 AC_DEFINE(HAVE_X11_XMU_EDITRES_H),
3106 AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003107 CPPFLAGS=$cppflags_save
3108fi
3109
3110dnl Only use the Xm directory when compiling Motif, don't use it for Athena
3111if test -z "$SKIP_MOTIF"; then
3112 cppflags_save=$CPPFLAGS
3113 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003114 if test "$zOSUnix" = "yes"; then
3115 xmheader="Xm/Xm.h"
3116 else
3117 xmheader="Xm/Xm.h Xm/XpmP.h Xm/JoinSideT.h Xm/TraitP.h Xm/Manager.h
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02003118 Xm/UnhighlightT.h Xm/Notebook.h"
Bram Moolenaar77c19352012-06-13 19:19:41 +02003119 fi
3120 AC_CHECK_HEADERS($xmheader)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003121
Bram Moolenaar77c19352012-06-13 19:19:41 +02003122 if test "x$ac_cv_header_Xm_XpmP_h" = "xyes"; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003123 dnl Solaris uses XpmAttributes_21, very annoying.
3124 AC_MSG_CHECKING([for XpmAttributes_21 in Xm/XpmP.h])
3125 AC_TRY_COMPILE([#include <Xm/XpmP.h>], [XpmAttributes_21 attr;],
3126 AC_MSG_RESULT(yes); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes_21),
3127 AC_MSG_RESULT(no); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
3128 )
3129 else
Bram Moolenaar57657d82006-04-21 22:12:41 +00003130 AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003131 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003132 CPPFLAGS=$cppflags_save
3133fi
3134
3135if test "x$GUITYPE" = "xNONE" -a "$enable_xim" = "yes"; then
3136 AC_MSG_RESULT(no GUI selected; xim has been disabled)
3137 enable_xim="no"
3138fi
3139if test "x$GUITYPE" = "xNONE" -a "$enable_fontset" = "yes"; then
3140 AC_MSG_RESULT(no GUI selected; fontset has been disabled)
3141 enable_fontset="no"
3142fi
Bram Moolenaar182c5be2010-06-25 05:37:59 +02003143if test "x$GUITYPE:$enable_fontset" = "xGTK:yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003144 AC_MSG_RESULT(GTK+ 2 GUI selected; fontset has been disabled)
3145 enable_fontset="no"
3146fi
3147
Bram Moolenaarb3f74062020-02-26 16:16:53 +01003148dnl There is no test for the Haiku GUI, if it's selected it's used
3149if test -z "$SKIP_HAIKU"; then
3150 GUITYPE=HAIKUGUI
3151fi
3152
Bram Moolenaar071d4272004-06-13 20:20:40 +00003153if test -z "$SKIP_PHOTON"; then
3154 GUITYPE=PHOTONGUI
3155fi
3156
3157AC_SUBST(GUI_INC_LOC)
3158AC_SUBST(GUI_LIB_LOC)
3159AC_SUBST(GUITYPE)
3160AC_SUBST(GUI_X_LIBS)
3161
3162if test "$enable_workshop" = "yes" -a -n "$SKIP_MOTIF"; then
3163 AC_MSG_ERROR([cannot use workshop without Motif])
3164fi
3165
3166dnl defining FEAT_XIM and FEAT_XFONTSET is delayed, so that they can be disabled
3167if test "$enable_xim" = "yes"; then
3168 AC_DEFINE(FEAT_XIM)
3169fi
3170if test "$enable_fontset" = "yes"; then
3171 AC_DEFINE(FEAT_XFONTSET)
3172fi
3173
3174
3175dnl ---------------------------------------------------------------------------
3176dnl end of GUI-checking
3177dnl ---------------------------------------------------------------------------
3178
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003179AC_MSG_CHECKING([for /proc link to executable])
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003180if test -L "/proc/self/exe"; then
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003181 dnl Linux
3182 AC_MSG_RESULT([/proc/self/exe])
3183 AC_DEFINE(PROC_EXE_LINK, "/proc/self/exe")
3184elif test -L "/proc/self/path/a.out"; then
3185 dnl Solaris
3186 AC_MSG_RESULT([/proc/self/path/a.out])
3187 AC_DEFINE(PROC_EXE_LINK, "/proc/self/path/a.out")
3188elif test -L "/proc/curproc/file"; then
3189 dnl FreeBSD
3190 AC_MSG_RESULT([/proc/curproc/file])
3191 AC_DEFINE(PROC_EXE_LINK, "/proc/curproc/file")
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003192else
Bram Moolenaarf3757f02017-03-16 15:13:45 +01003193 AC_MSG_RESULT(no)
Bram Moolenaar5f69fee2017-03-09 11:58:40 +01003194fi
3195
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003196dnl Check for Cygwin, which needs an extra source file if not using X11
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003197AC_MSG_CHECKING(for CYGWIN or MSYS environment)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003198case `uname` in
Bram Moolenaar8def26a2015-12-17 15:34:53 +01003199 CYGWIN*|MSYS*) CYGWIN=yes; AC_MSG_RESULT(yes)
Bram Moolenaar693e40c2013-02-26 14:56:42 +01003200 AC_MSG_CHECKING(for CYGWIN clipboard support)
3201 if test "x$with_x" = "xno" ; then
3202 OS_EXTRA_SRC=winclip.c; OS_EXTRA_OBJ=objects/winclip.o
3203 AC_MSG_RESULT(yes)
3204 AC_DEFINE(FEAT_CYGWIN_WIN32_CLIPBOARD)
3205 else
3206 AC_MSG_RESULT(no - using X11)
3207 fi ;;
3208
3209 *) CYGWIN=no; AC_MSG_RESULT(no);;
3210esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00003211
Bram Moolenaar071d4272004-06-13 20:20:40 +00003212dnl Checks for libraries and include files.
3213
Bram Moolenaar446cb832008-06-24 21:56:24 +00003214AC_CACHE_CHECK([whether toupper is broken], [vim_cv_toupper_broken],
3215 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003216 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003217#include "confdefs.h"
3218#include <ctype.h>
3219#if STDC_HEADERS
3220# include <stdlib.h>
3221# include <stddef.h>
3222#endif
3223main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003224 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003225 vim_cv_toupper_broken=yes
3226 ],[
3227 vim_cv_toupper_broken=no
3228 ],[
3229 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_toupper_broken')
3230 ])])
3231
3232if test "x$vim_cv_toupper_broken" = "xyes" ; then
3233 AC_DEFINE(BROKEN_TOUPPER)
3234fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003235
3236AC_MSG_CHECKING(whether __DATE__ and __TIME__ work)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003237AC_TRY_COMPILE([#include <stdio.h>], [printf("(" __DATE__ " " __TIME__ ")");],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003238 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DATE_TIME),
3239 AC_MSG_RESULT(no))
3240
Bram Moolenaar0c094b92009-05-14 20:20:33 +00003241AC_MSG_CHECKING(whether __attribute__((unused)) is allowed)
3242AC_TRY_COMPILE([#include <stdio.h>], [int x __attribute__((unused));],
3243 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ATTRIBUTE_UNUSED),
3244 AC_MSG_RESULT(no))
3245
Bram Moolenaar071d4272004-06-13 20:20:40 +00003246dnl Checks for header files.
3247AC_CHECK_HEADER(elf.h, HAS_ELF=1)
3248dnl AC_CHECK_HEADER(dwarf.h, SVR4=1)
3249if test "$HAS_ELF" = 1; then
3250 AC_CHECK_LIB(elf, main)
3251fi
3252
3253AC_HEADER_DIRENT
3254
Bram Moolenaar071d4272004-06-13 20:20:40 +00003255dnl If sys/wait.h is not found it might still exist but not be POSIX
3256dnl compliant. In that case we define HAVE_UNION_WAIT (for NeXT)
3257if test $ac_cv_header_sys_wait_h = no; then
3258 AC_MSG_CHECKING([for sys/wait.h that defines union wait])
3259 AC_TRY_COMPILE([#include <sys/wait.h>],
3260 [union wait xx, yy; xx = yy],
3261 AC_MSG_RESULT(yes)
3262 AC_DEFINE(HAVE_SYS_WAIT_H)
3263 AC_DEFINE(HAVE_UNION_WAIT),
3264 AC_MSG_RESULT(no))
3265fi
3266
Bram Moolenaar779a7752016-01-30 23:26:34 +01003267AC_CHECK_HEADERS(stdint.h stdlib.h string.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003268 sys/select.h sys/utsname.h termcap.h fcntl.h \
3269 sgtty.h sys/ioctl.h sys/time.h sys/types.h \
3270 termio.h iconv.h inttypes.h langinfo.h math.h \
3271 unistd.h stropts.h errno.h sys/resource.h \
3272 sys/systeminfo.h locale.h sys/stream.h termios.h \
3273 libc.h sys/statfs.h poll.h sys/poll.h pwd.h \
Bram Moolenaar1ecc5e42019-01-26 15:12:55 +01003274 utime.h sys/param.h sys/ptms.h libintl.h libgen.h \
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003275 util/debug.h util/msg18n.h frame.h sys/acl.h \
3276 sys/access.h sys/sysinfo.h wchar.h wctype.h)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003277
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003278dnl sys/ptem.h depends on sys/stream.h on Solaris
3279AC_CHECK_HEADERS(sys/ptem.h, [], [],
3280[#if defined HAVE_SYS_STREAM_H
3281# include <sys/stream.h>
3282#endif])
3283
Bram Moolenaar32f31b12009-05-21 13:20:59 +00003284dnl sys/sysctl.h depends on sys/param.h on OpenBSD
3285AC_CHECK_HEADERS(sys/sysctl.h, [], [],
3286[#if defined HAVE_SYS_PARAM_H
3287# include <sys/param.h>
3288#endif])
3289
Bram Moolenaar00ca2842008-06-26 20:14:00 +00003290
Bram Moolenaardf3267e2005-01-25 22:07:05 +00003291dnl pthread_np.h may exist but can only be used after including pthread.h
3292AC_MSG_CHECKING([for pthread_np.h])
3293AC_TRY_COMPILE([
3294#include <pthread.h>
3295#include <pthread_np.h>],
3296 [int i; i = 0;],
3297 AC_MSG_RESULT(yes)
3298 AC_DEFINE(HAVE_PTHREAD_NP_H),
3299 AC_MSG_RESULT(no))
3300
Bram Moolenaare344bea2005-09-01 20:46:49 +00003301AC_CHECK_HEADERS(strings.h)
Bram Moolenaard0573012017-10-28 21:11:06 +02003302if test "x$MACOS_X" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +00003303 dnl The strings.h file on OS/X contains a warning and nothing useful.
3304 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3305else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003306
3307dnl Check if strings.h and string.h can both be included when defined.
3308AC_MSG_CHECKING([if strings.h can be included after string.h])
3309cppflags_save=$CPPFLAGS
3310CPPFLAGS="$CPPFLAGS $X_CFLAGS"
3311AC_TRY_COMPILE([
3312#if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO)
3313# define _NO_PROTO /* like in os_unix.h, causes conflict for AIX (Winn) */
3314 /* but don't do it on AIX 5.1 (Uribarri) */
3315#endif
3316#ifdef HAVE_XM_XM_H
3317# include <Xm/Xm.h> /* This breaks it for HP-UX 11 (Squassabia) */
3318#endif
3319#ifdef HAVE_STRING_H
3320# include <string.h>
3321#endif
3322#if defined(HAVE_STRINGS_H)
3323# include <strings.h>
3324#endif
3325 ], [int i; i = 0;],
3326 AC_MSG_RESULT(yes),
3327 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
3328 AC_MSG_RESULT(no))
3329CPPFLAGS=$cppflags_save
Bram Moolenaar9372a112005-12-06 19:59:18 +00003330fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003331
3332dnl Checks for typedefs, structures, and compiler characteristics.
3333AC_PROG_GCC_TRADITIONAL
3334AC_C_CONST
Bram Moolenaar76243bd2009-03-02 01:47:02 +00003335AC_C_VOLATILE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003336AC_TYPE_MODE_T
3337AC_TYPE_OFF_T
3338AC_TYPE_PID_T
3339AC_TYPE_SIZE_T
3340AC_TYPE_UID_T
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003341AC_TYPE_UINT32_T
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003342
Bram Moolenaar071d4272004-06-13 20:20:40 +00003343AC_HEADER_TIME
3344AC_CHECK_TYPE(ino_t, long)
3345AC_CHECK_TYPE(dev_t, unsigned)
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02003346AC_C_BIGENDIAN(,,,)
Bram Moolenaar136f29a2016-02-27 20:14:15 +01003347AC_C_INLINE
Bram Moolenaar071d4272004-06-13 20:20:40 +00003348
3349AC_MSG_CHECKING(for rlim_t)
3350if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
3351 AC_MSG_RESULT([(cached) $ac_cv_type_rlim_t])
3352else
3353 AC_EGREP_CPP(dnl
3354changequote(<<,>>)dnl
3355<<(^|[^a-zA-Z_0-9])rlim_t[^a-zA-Z_0-9]>>dnl
3356changequote([,]),
3357 [
3358#include <sys/types.h>
3359#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003360# include <stdlib.h>
3361# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003362#endif
3363#ifdef HAVE_SYS_RESOURCE_H
Bram Moolenaar446cb832008-06-24 21:56:24 +00003364# include <sys/resource.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003365#endif
3366 ], ac_cv_type_rlim_t=yes, ac_cv_type_rlim_t=no)
3367 AC_MSG_RESULT($ac_cv_type_rlim_t)
3368fi
3369if test $ac_cv_type_rlim_t = no; then
3370 cat >> confdefs.h <<\EOF
3371#define rlim_t unsigned long
3372EOF
3373fi
3374
3375AC_MSG_CHECKING(for stack_t)
3376if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then
3377 AC_MSG_RESULT([(cached) $ac_cv_type_stack_t])
3378else
3379 AC_EGREP_CPP(stack_t,
3380 [
3381#include <sys/types.h>
3382#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003383# include <stdlib.h>
3384# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003385#endif
3386#include <signal.h>
3387 ], ac_cv_type_stack_t=yes, ac_cv_type_stack_t=no)
3388 AC_MSG_RESULT($ac_cv_type_stack_t)
3389fi
3390if test $ac_cv_type_stack_t = no; then
3391 cat >> confdefs.h <<\EOF
3392#define stack_t struct sigaltstack
3393EOF
3394fi
3395
3396dnl BSDI uses ss_base while others use ss_sp for the stack pointer.
3397AC_MSG_CHECKING(whether stack_t has an ss_base field)
3398AC_TRY_COMPILE([
3399#include <sys/types.h>
3400#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00003401# include <stdlib.h>
3402# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003403#endif
3404#include <signal.h>
3405#include "confdefs.h"
3406 ], [stack_t sigstk; sigstk.ss_base = 0; ],
3407 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SS_BASE),
3408 AC_MSG_RESULT(no))
3409
3410olibs="$LIBS"
3411AC_MSG_CHECKING(--with-tlib argument)
3412AC_ARG_WITH(tlib, [ --with-tlib=library terminal library to be used ],)
3413if test -n "$with_tlib"; then
3414 AC_MSG_RESULT($with_tlib)
3415 LIBS="$LIBS -l$with_tlib"
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003416 AC_MSG_CHECKING(for linking with $with_tlib library)
3417 AC_TRY_LINK([], [], AC_MSG_RESULT(OK), AC_MSG_ERROR(FAILED))
3418 dnl Need to check for tgetent() below.
3419 olibs="$LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003420else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003421 AC_MSG_RESULT([empty: automatic terminal library selection])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003422 dnl On HP-UX 10.10 termcap or termlib should be used instead of
3423 dnl curses, because curses is much slower.
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003424 dnl Newer versions of ncurses are preferred over anything, except
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02003425 dnl when tinfo has been split off, it contains all we need.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003426 dnl Older versions of ncurses have bugs, get a new one!
3427 dnl Digital Unix (OSF1) should use curses (Ronald Schild).
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00003428 dnl On SCO Openserver should prefer termlib (Roger Cornelius).
Bram Moolenaar071d4272004-06-13 20:20:40 +00003429 case "`uname -s 2>/dev/null`" in
Bram Moolenaar4e509b62011-02-09 17:42:57 +01003430 OSF1|SCO_SV) tlibs="tinfo ncurses curses termlib termcap";;
3431 *) tlibs="tinfo ncurses termlib termcap curses";;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003432 esac
3433 for libname in $tlibs; do
3434 AC_CHECK_LIB(${libname}, tgetent,,)
3435 if test "x$olibs" != "x$LIBS"; then
3436 dnl It's possible that a library is found but it doesn't work
3437 dnl e.g., shared library that cannot be found
3438 dnl compile and run a test program to be sure
3439 AC_TRY_RUN([
3440#ifdef HAVE_TERMCAP_H
3441# include <termcap.h>
3442#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003443#if STDC_HEADERS
3444# include <stdlib.h>
3445# include <stddef.h>
3446#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003447main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }],
3448 res="OK", res="FAIL", res="FAIL")
3449 if test "$res" = "OK"; then
3450 break
3451 fi
3452 AC_MSG_RESULT($libname library is not usable)
3453 LIBS="$olibs"
3454 fi
3455 done
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003456 if test "x$olibs" = "x$LIBS"; then
3457 AC_MSG_RESULT(no terminal library found)
3458 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003459fi
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003460
3461if test "x$olibs" = "x$LIBS"; then
3462 AC_MSG_CHECKING([for tgetent()])
Bram Moolenaarbd7f7c12020-07-28 21:03:37 +02003463 AC_TRY_LINK([int tgetent(char *, const char *);],
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003464 [char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");],
3465 AC_MSG_RESULT(yes),
3466 AC_MSG_ERROR([NOT FOUND!
3467 You need to install a terminal library; for example ncurses.
3468 Or specify the name of the library with --with-tlib.]))
3469fi
3470
Bram Moolenaar446cb832008-06-24 21:56:24 +00003471AC_CACHE_CHECK([whether we talk terminfo], [vim_cv_terminfo],
3472 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003473 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003474#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003475#ifdef HAVE_TERMCAP_H
3476# include <termcap.h>
3477#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003478#ifdef HAVE_STRING_H
3479# include <string.h>
3480#endif
3481#if STDC_HEADERS
3482# include <stdlib.h>
3483# include <stddef.h>
3484#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003485main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003486{char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003487 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003488 vim_cv_terminfo=no
3489 ],[
3490 vim_cv_terminfo=yes
3491 ],[
3492 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_terminfo')
3493 ])
3494 ])
3495
3496if test "x$vim_cv_terminfo" = "xyes" ; then
3497 AC_DEFINE(TERMINFO)
3498fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003499
Bram Moolenaara88254f2017-11-02 23:04:14 +01003500AC_CACHE_CHECK([what tgetent() returns for an unknown terminal], [vim_cv_tgetent],
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003501 [
3502 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003503#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003504#ifdef HAVE_TERMCAP_H
3505# include <termcap.h>
3506#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003507#if STDC_HEADERS
3508# include <stdlib.h>
3509# include <stddef.h>
3510#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003511main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003512{char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003513 ]])],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003514 vim_cv_tgetent=zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003515 ],[
Bram Moolenaara88254f2017-11-02 23:04:14 +01003516 vim_cv_tgetent=non-zero
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003517 ],[
3518 AC_MSG_ERROR(failed to compile test program.)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003519 ])
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003520 ])
3521
Bram Moolenaara88254f2017-11-02 23:04:14 +01003522if test "x$vim_cv_tgetent" = "xzero" ; then
Bram Moolenaar696cbd22017-04-28 15:45:46 +02003523 AC_DEFINE(TGETENT_ZERO_ERR, 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003524fi
3525
3526AC_MSG_CHECKING(whether termcap.h contains ospeed)
3527AC_TRY_LINK([
3528#ifdef HAVE_TERMCAP_H
3529# include <termcap.h>
3530#endif
3531 ], [ospeed = 20000],
3532 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED),
3533 [AC_MSG_RESULT(no)
3534 AC_MSG_CHECKING(whether ospeed can be extern)
3535 AC_TRY_LINK([
3536#ifdef HAVE_TERMCAP_H
3537# include <termcap.h>
3538#endif
3539extern short ospeed;
3540 ], [ospeed = 20000],
3541 AC_MSG_RESULT(yes); AC_DEFINE(OSPEED_EXTERN),
3542 AC_MSG_RESULT(no))]
3543 )
3544
3545AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC])
3546AC_TRY_LINK([
3547#ifdef HAVE_TERMCAP_H
3548# include <termcap.h>
3549#endif
3550 ], [if (UP == 0 && BC == 0) PC = 1],
3551 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UP_BC_PC),
3552 [AC_MSG_RESULT(no)
3553 AC_MSG_CHECKING([whether UP, BC and PC can be extern])
3554 AC_TRY_LINK([
3555#ifdef HAVE_TERMCAP_H
3556# include <termcap.h>
3557#endif
3558extern char *UP, *BC, PC;
3559 ], [if (UP == 0 && BC == 0) PC = 1],
3560 AC_MSG_RESULT(yes); AC_DEFINE(UP_BC_PC_EXTERN),
3561 AC_MSG_RESULT(no))]
3562 )
3563
3564AC_MSG_CHECKING(whether tputs() uses outfuntype)
3565AC_TRY_COMPILE([
3566#ifdef HAVE_TERMCAP_H
3567# include <termcap.h>
3568#endif
3569 ], [extern int xx(); tputs("test", 1, (outfuntype)xx)],
3570 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OUTFUNTYPE),
3571 AC_MSG_RESULT(no))
3572
3573dnl On some SCO machines sys/select redefines struct timeval
3574AC_MSG_CHECKING([whether sys/select.h and sys/time.h may both be included])
3575AC_TRY_COMPILE([
3576#include <sys/types.h>
3577#include <sys/time.h>
3578#include <sys/select.h>], ,
3579 AC_MSG_RESULT(yes)
3580 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME),
3581 AC_MSG_RESULT(no))
3582
3583dnl AC_DECL_SYS_SIGLIST
3584
3585dnl Checks for pty.c (copied from screen) ==========================
3586AC_MSG_CHECKING(for /dev/ptc)
3587if test -r /dev/ptc; then
3588 AC_DEFINE(HAVE_DEV_PTC)
3589 AC_MSG_RESULT(yes)
3590else
3591 AC_MSG_RESULT(no)
3592fi
3593
3594AC_MSG_CHECKING(for SVR4 ptys)
3595if test -c /dev/ptmx ; then
Bram Moolenaarce7be3a2020-11-26 20:11:11 +01003596 AC_TRY_LINK([
3597// These should be in stdlib.h, but it depends on _XOPEN_SOURCE.
3598char *ptsname(int);
3599int unlockpt(int);
3600int grantpt(int);
3601 ], [
3602 ptsname(0);
3603 grantpt(0);
3604 unlockpt(0);],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003605 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SVR4_PTYS),
3606 AC_MSG_RESULT(no))
3607else
3608 AC_MSG_RESULT(no)
3609fi
3610
3611AC_MSG_CHECKING(for ptyranges)
3612if test -d /dev/ptym ; then
3613 pdir='/dev/ptym'
3614else
3615 pdir='/dev'
3616fi
3617dnl SCO uses ptyp%d
3618AC_EGREP_CPP(yes,
3619[#ifdef M_UNIX
3620 yes;
3621#endif
3622 ], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
3623dnl if test -c /dev/ptyp19; then
3624dnl ptys=`echo /dev/ptyp??`
3625dnl else
3626dnl ptys=`echo $pdir/pty??`
3627dnl fi
3628if test "$ptys" != "$pdir/pty??" ; then
3629 p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
3630 p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'`
3631 AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
3632 AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
3633 AC_MSG_RESULT([$p0 / $p1])
3634else
3635 AC_MSG_RESULT([don't know])
3636fi
3637
Bram Moolenaar071d4272004-06-13 20:20:40 +00003638dnl Checks for library functions. ===================================
3639
3640AC_TYPE_SIGNAL
3641
3642dnl find out what to use at the end of a signal function
3643if test $ac_cv_type_signal = void; then
3644 AC_DEFINE(SIGRETURN, [return])
3645else
3646 AC_DEFINE(SIGRETURN, [return 0])
3647fi
3648
3649dnl check if struct sigcontext is defined (used for SGI only)
3650AC_MSG_CHECKING(for struct sigcontext)
3651AC_TRY_COMPILE([
3652#include <signal.h>
3653test_sig()
3654{
3655 struct sigcontext *scont;
3656 scont = (struct sigcontext *)0;
3657 return 1;
3658} ], ,
3659 AC_MSG_RESULT(yes)
3660 AC_DEFINE(HAVE_SIGCONTEXT),
3661 AC_MSG_RESULT(no))
3662
3663dnl tricky stuff: try to find out if getcwd() is implemented with
3664dnl system("sh -c pwd")
Bram Moolenaar446cb832008-06-24 21:56:24 +00003665AC_CACHE_CHECK([getcwd implementation is broken], [vim_cv_getcwd_broken],
3666 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003667 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003668#include "confdefs.h"
3669#ifdef HAVE_UNISTD_H
3670#include <unistd.h>
3671#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003672char *dagger[] = { "IFS=pwd", 0 };
3673main()
3674{
3675 char buffer[500];
3676 extern char **environ;
3677 environ = dagger;
3678 return getcwd(buffer, 500) ? 0 : 1;
Bram Moolenaar446cb832008-06-24 21:56:24 +00003679}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003680 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003681 vim_cv_getcwd_broken=no
3682 ],[
3683 vim_cv_getcwd_broken=yes
3684 ],[
3685 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_getcwd_broken')
3686 ])
3687 ])
3688
3689if test "x$vim_cv_getcwd_broken" = "xyes" ; then
3690 AC_DEFINE(BAD_GETCWD)
Bram Moolenaar63d25552019-05-10 21:28:38 +02003691 AC_CHECK_FUNCS(getwd)
Bram Moolenaar446cb832008-06-24 21:56:24 +00003692fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003693
Bram Moolenaar25153e12010-02-24 14:47:08 +01003694dnl Check for functions in one big call, to reduce the size of configure.
3695dnl Can only be used for functions that do not require any include.
Bram Moolenaarcd142e32017-11-16 17:03:45 +01003696AC_CHECK_FUNCS(fchdir fchown fchmod fsync getcwd getpseudotty \
Bram Moolenaar63d25552019-05-10 21:28:38 +02003697 getpwent getpwnam getpwuid getrlimit gettimeofday localtime_r lstat \
Bram Moolenaareaf03392009-11-17 11:08:52 +00003698 memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
Bram Moolenaar2fcf6682017-03-11 20:03:42 +01003699 getpgid setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
Bram Moolenaar84cf6bd2020-06-16 20:03:43 +02003700 sigprocmask sigvec strcasecmp strcoll strerror strftime stricmp strncasecmp \
Bram Moolenaar10455d42019-11-21 15:36:18 +01003701 strnicmp strpbrk strptime strtol tgetent towlower towupper iswupper \
3702 tzset usleep utime utimes mblen ftruncate unsetenv posix_openpt)
Bram Moolenaar643b6142018-09-12 20:29:09 +02003703AC_FUNC_SELECT_ARGTYPES
Bram Moolenaar25153e12010-02-24 14:47:08 +01003704AC_FUNC_FSEEKO
Bram Moolenaar071d4272004-06-13 20:20:40 +00003705
Bram Moolenaar317fd3a2010-05-07 16:05:55 +02003706dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when
3707dnl appropriate, so that off_t is 64 bits when needed.
3708AC_SYS_LARGEFILE
3709
Bram Moolenaar21606672019-06-14 20:40:58 +02003710AC_MSG_CHECKING(--enable-canberra argument)
3711AC_ARG_ENABLE(canberra,
3712 [ --disable-canberra Do not use libcanberra.],
3713 , [enable_canberra="maybe"])
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003714
Bram Moolenaar21606672019-06-14 20:40:58 +02003715if test "$enable_canberra" = "maybe"; then
3716 if test "$features" = "big" -o "$features" = "huge"; then
3717 AC_MSG_RESULT(Defaulting to yes)
3718 enable_canberra="yes"
3719 else
3720 AC_MSG_RESULT(Defaulting to no)
3721 enable_canberra="no"
3722 fi
3723else
3724 AC_MSG_RESULT($enable_canberra)
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003725fi
Bram Moolenaar21606672019-06-14 20:40:58 +02003726if test "$enable_canberra" = "yes"; then
3727 if test "x$PKG_CONFIG" != "xno"; then
3728 canberra_lib=`$PKG_CONFIG --libs libcanberra 2>/dev/null`
3729 canberra_cflags=`$PKG_CONFIG --cflags libcanberra 2>/dev/null`
3730 fi
3731 if test "x$canberra_lib" = "x"; then
3732 canberra_lib=-lcanberra
3733 canberra_cflags=-D_REENTRANT
3734 fi
3735 AC_MSG_CHECKING(for libcanberra)
3736 ac_save_CFLAGS="$CFLAGS"
3737 ac_save_LIBS="$LIBS"
3738 CFLAGS="$CFLAGS $canberra_cflags"
3739 LIBS="$LIBS $canberra_lib"
3740 AC_TRY_LINK([
3741 # include <canberra.h>
3742 ], [
3743 ca_context *hello;
3744 ca_context_create(&hello);],
3745 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_CANBERRA),
Bram Moolenaar91b992c2019-11-17 19:07:42 +01003746 AC_MSG_RESULT(no; try installing libcanberra-dev); CFLAGS="$ac_save_CFLAGS"; LIBS="$ac_save_LIBS")
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003747fi
Bram Moolenaar427f5b62019-06-09 13:43:51 +02003748
3749
Bram Moolenaar071d4272004-06-13 20:20:40 +00003750dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible
3751AC_MSG_CHECKING(for st_blksize)
3752AC_TRY_COMPILE(
3753[#include <sys/types.h>
3754#include <sys/stat.h>],
3755[ struct stat st;
3756 int n;
3757
3758 stat("/", &st);
3759 n = (int)st.st_blksize;],
3760 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ST_BLKSIZE),
3761 AC_MSG_RESULT(no))
3762
Bram Moolenaar446cb832008-06-24 21:56:24 +00003763AC_CACHE_CHECK([whether stat() ignores a trailing slash], [vim_cv_stat_ignores_slash],
3764 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003765 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003766#include "confdefs.h"
3767#if STDC_HEADERS
3768# include <stdlib.h>
3769# include <stddef.h>
3770#endif
3771#include <sys/types.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003772#include <sys/stat.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003773main() {struct stat st; exit(stat("configure/", &st) != 0); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003774 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003775 vim_cv_stat_ignores_slash=yes
3776 ],[
3777 vim_cv_stat_ignores_slash=no
3778 ],[
3779 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_stat_ignores_slash')
3780 ])
3781 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003782
Bram Moolenaar446cb832008-06-24 21:56:24 +00003783if test "x$vim_cv_stat_ignores_slash" = "xyes" ; then
3784 AC_DEFINE(STAT_IGNORES_SLASH)
3785fi
3786
Bram Moolenaar071d4272004-06-13 20:20:40 +00003787dnl Link with iconv for charset translation, if not found without library.
3788dnl check for iconv() requires including iconv.h
3789dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
3790dnl has been installed.
3791AC_MSG_CHECKING(for iconv_open())
3792save_LIBS="$LIBS"
3793LIBS="$LIBS -liconv"
3794AC_TRY_LINK([
3795#ifdef HAVE_ICONV_H
3796# include <iconv.h>
3797#endif
3798 ], [iconv_open("fr", "to");],
3799 AC_MSG_RESULT(yes; with -liconv); AC_DEFINE(HAVE_ICONV),
3800 LIBS="$save_LIBS"
3801 AC_TRY_LINK([
3802#ifdef HAVE_ICONV_H
3803# include <iconv.h>
3804#endif
3805 ], [iconv_open("fr", "to");],
3806 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ICONV),
3807 AC_MSG_RESULT(no)))
3808
3809
3810AC_MSG_CHECKING(for nl_langinfo(CODESET))
3811AC_TRY_LINK([
3812#ifdef HAVE_LANGINFO_H
3813# include <langinfo.h>
3814#endif
3815], [char *cs = nl_langinfo(CODESET);],
3816 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET),
3817 AC_MSG_RESULT(no))
3818
Bram Moolenaar446cb832008-06-24 21:56:24 +00003819dnl Need various functions for floating point support. Only enable
3820dnl floating point when they are all present.
3821AC_CHECK_LIB(m, strtod)
3822AC_MSG_CHECKING([for strtod() and other floating point functions])
3823AC_TRY_LINK([
3824#ifdef HAVE_MATH_H
3825# include <math.h>
3826#endif
3827#if STDC_HEADERS
3828# include <stdlib.h>
3829# include <stddef.h>
3830#endif
3831], [char *s; double d;
3832 d = strtod("1.1", &s);
3833 d = fabs(1.11);
3834 d = ceil(1.11);
3835 d = floor(1.11);
3836 d = log10(1.11);
3837 d = pow(1.11, 2.22);
3838 d = sqrt(1.11);
3839 d = sin(1.11);
3840 d = cos(1.11);
3841 d = atan(1.11);
3842 ],
3843 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT_FUNCS),
3844 AC_MSG_RESULT(no))
3845
Bram Moolenaara6b89762016-02-29 21:38:26 +01003846dnl isinf() and isnan() need to include header files and may need -lm.
3847AC_MSG_CHECKING([for isinf()])
3848AC_TRY_LINK([
3849#ifdef HAVE_MATH_H
3850# include <math.h>
3851#endif
3852#if STDC_HEADERS
3853# include <stdlib.h>
3854# include <stddef.h>
3855#endif
3856], [int r = isinf(1.11); ],
3857 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISINF),
3858 AC_MSG_RESULT(no))
3859
3860AC_MSG_CHECKING([for isnan()])
3861AC_TRY_LINK([
3862#ifdef HAVE_MATH_H
3863# include <math.h>
3864#endif
3865#if STDC_HEADERS
3866# include <stdlib.h>
3867# include <stddef.h>
3868#endif
3869], [int r = isnan(1.11); ],
3870 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISNAN),
3871 AC_MSG_RESULT(no))
3872
Bram Moolenaar071d4272004-06-13 20:20:40 +00003873dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI
3874dnl when -lacl works, also try to use -lattr (required for Debian).
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003875dnl On Solaris, use the acl_get/set functions in libsec, if present.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003876AC_MSG_CHECKING(--disable-acl argument)
3877AC_ARG_ENABLE(acl,
Bram Moolenaard6d30422018-01-28 22:48:55 +01003878 [ --disable-acl No check for ACL support.],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003879 , [enable_acl="yes"])
3880if test "$enable_acl" = "yes"; then
Bram Moolenaard6d30422018-01-28 22:48:55 +01003881 AC_MSG_RESULT(no)
3882 AC_CHECK_LIB(posix1e, acl_get_file, [LIBS="$LIBS -lposix1e"],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003883 AC_CHECK_LIB(acl, acl_get_file, [LIBS="$LIBS -lacl"
3884 AC_CHECK_LIB(attr, fgetxattr, LIBS="$LIBS -lattr",,)],,),)
3885
Bram Moolenaard6d30422018-01-28 22:48:55 +01003886 AC_MSG_CHECKING(for POSIX ACL support)
3887 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003888#include <sys/types.h>
3889#ifdef HAVE_SYS_ACL_H
3890# include <sys/acl.h>
3891#endif
3892acl_t acl;], [acl = acl_get_file("foo", ACL_TYPE_ACCESS);
3893 acl_set_file("foo", ACL_TYPE_ACCESS, acl);
3894 acl_free(acl);],
3895 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_ACL),
3896 AC_MSG_RESULT(no))
3897
Bram Moolenaard6d30422018-01-28 22:48:55 +01003898 AC_CHECK_LIB(sec, acl_get, [LIBS="$LIBS -lsec"; AC_DEFINE(HAVE_SOLARIS_ZFS_ACL)],
3899 AC_MSG_CHECKING(for Solaris ACL support)
3900 AC_TRY_LINK([
Bram Moolenaar071d4272004-06-13 20:20:40 +00003901#ifdef HAVE_SYS_ACL_H
3902# include <sys/acl.h>
3903#endif], [acl("foo", GETACLCNT, 0, NULL);
3904 ],
3905 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOLARIS_ACL),
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003906 AC_MSG_RESULT(no)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003907
Bram Moolenaard6d30422018-01-28 22:48:55 +01003908 AC_MSG_CHECKING(for AIX ACL support)
3909 AC_TRY_LINK([
Bram Moolenaar446cb832008-06-24 21:56:24 +00003910#if STDC_HEADERS
3911# include <stdlib.h>
3912# include <stddef.h>
3913#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003914#ifdef HAVE_SYS_ACL_H
3915# include <sys/acl.h>
3916#endif
3917#ifdef HAVE_SYS_ACCESS_H
3918# include <sys/access.h>
3919#endif
3920#define _ALL_SOURCE
3921
3922#include <sys/stat.h>
3923
3924int aclsize;
3925struct acl *aclent;], [aclsize = sizeof(struct acl);
3926 aclent = (void *)malloc(aclsize);
3927 statacl("foo", STX_NORMAL, aclent, aclsize);
3928 ],
3929 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_AIX_ACL),
3930 AC_MSG_RESULT(no))
3931else
3932 AC_MSG_RESULT(yes)
3933fi
3934
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02003935if test "x$GTK_CFLAGS" != "x"; then
3936 dnl pango_shape_full() is new, fall back to pango_shape().
3937 AC_MSG_CHECKING(for pango_shape_full)
3938 ac_save_CFLAGS="$CFLAGS"
3939 ac_save_LIBS="$LIBS"
3940 CFLAGS="$CFLAGS $GTK_CFLAGS"
3941 LIBS="$LIBS $GTK_LIBS"
Bram Moolenaar5325b9b2015-09-09 20:27:02 +02003942 AC_TRY_LINK(
Bram Moolenaar3cbe0c02015-09-08 20:00:22 +02003943 [#include <gtk/gtk.h>],
3944 [ pango_shape_full(NULL, 0, NULL, 0, NULL, NULL); ],
3945 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_PANGO_SHAPE_FULL),
3946 AC_MSG_RESULT(no))
3947 CFLAGS="$ac_save_CFLAGS"
3948 LIBS="$ac_save_LIBS"
3949fi
3950
Bram Moolenaar071d4272004-06-13 20:20:40 +00003951AC_MSG_CHECKING(--disable-gpm argument)
3952AC_ARG_ENABLE(gpm,
3953 [ --disable-gpm Don't use gpm (Linux mouse daemon).], ,
3954 [enable_gpm="yes"])
3955
3956if test "$enable_gpm" = "yes"; then
3957 AC_MSG_RESULT(no)
3958 dnl Checking if gpm support can be compiled
3959 AC_CACHE_CHECK([for gpm], vi_cv_have_gpm,
3960 [olibs="$LIBS" ; LIBS="-lgpm"]
3961 AC_TRY_LINK(
3962 [#include <gpm.h>
3963 #include <linux/keyboard.h>],
3964 [Gpm_GetLibVersion(NULL);],
3965 dnl Configure defines HAVE_GPM, if it is defined feature.h defines
3966 dnl FEAT_MOUSE_GPM if mouse support is included
3967 [vi_cv_have_gpm=yes],
3968 [vi_cv_have_gpm=no])
3969 [LIBS="$olibs"]
3970 )
3971 if test $vi_cv_have_gpm = yes; then
3972 LIBS="$LIBS -lgpm"
3973 AC_DEFINE(HAVE_GPM)
3974 fi
3975else
3976 AC_MSG_RESULT(yes)
3977fi
3978
Bram Moolenaar446cb832008-06-24 21:56:24 +00003979AC_MSG_CHECKING(--disable-sysmouse argument)
3980AC_ARG_ENABLE(sysmouse,
Bram Moolenaar8008b632017-07-18 21:33:20 +02003981 [ --disable-sysmouse Don't use sysmouse (mouse in *BSD console).], ,
Bram Moolenaar446cb832008-06-24 21:56:24 +00003982 [enable_sysmouse="yes"])
3983
3984if test "$enable_sysmouse" = "yes"; then
3985 AC_MSG_RESULT(no)
3986 dnl Checking if sysmouse support can be compiled
3987 dnl Configure defines HAVE_SYSMOUSE, if it is defined feature.h
3988 dnl defines FEAT_SYSMOUSE if mouse support is included
3989 AC_CACHE_CHECK([for sysmouse], vi_cv_have_sysmouse,
3990 AC_TRY_LINK(
3991 [#include <sys/consio.h>
3992 #include <signal.h>
3993 #include <sys/fbio.h>],
3994 [struct mouse_info mouse;
3995 mouse.operation = MOUSE_MODE;
3996 mouse.operation = MOUSE_SHOW;
3997 mouse.u.mode.mode = 0;
3998 mouse.u.mode.signal = SIGUSR2;],
3999 [vi_cv_have_sysmouse=yes],
4000 [vi_cv_have_sysmouse=no])
4001 )
4002 if test $vi_cv_have_sysmouse = yes; then
4003 AC_DEFINE(HAVE_SYSMOUSE)
4004 fi
4005else
4006 AC_MSG_RESULT(yes)
4007fi
4008
Bram Moolenaarf05da212009-11-17 16:13:15 +00004009dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
4010AC_MSG_CHECKING(for FD_CLOEXEC)
4011AC_TRY_COMPILE(
4012[#if HAVE_FCNTL_H
4013# include <fcntl.h>
4014#endif],
4015[ int flag = FD_CLOEXEC;],
4016 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
4017 AC_MSG_RESULT(not usable))
4018
Bram Moolenaar071d4272004-06-13 20:20:40 +00004019dnl rename needs to be checked separately to work on Nextstep with cc
4020AC_MSG_CHECKING(for rename)
4021AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
4022 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
4023 AC_MSG_RESULT(no))
4024
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004025dnl check for dirfd()
4026AC_MSG_CHECKING(for dirfd)
Bram Moolenaar9d8bfae2020-09-02 21:21:35 +02004027AC_TRY_LINK(
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004028[#include <sys/types.h>
4029#include <dirent.h>],
4030[DIR * dir=opendir("dirname"); dirfd(dir);],
4031AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DIRFD), AC_MSG_RESULT(not usable))
4032
4033dnl check for flock()
4034AC_MSG_CHECKING(for flock)
Bram Moolenaar9d8bfae2020-09-02 21:21:35 +02004035AC_TRY_LINK(
Bram Moolenaarb2d0e512020-05-07 18:37:03 +02004036[#include <sys/file.h>],
4037[flock(10, LOCK_SH);],
4038AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOCK), AC_MSG_RESULT(not usable))
4039
Bram Moolenaar071d4272004-06-13 20:20:40 +00004040dnl sysctl() may exist but not the arguments we use
4041AC_MSG_CHECKING(for sysctl)
4042AC_TRY_COMPILE(
4043[#include <sys/types.h>
4044#include <sys/sysctl.h>],
4045[ int mib[2], r;
4046 size_t len;
4047
4048 mib[0] = CTL_HW;
4049 mib[1] = HW_USERMEM;
4050 len = sizeof(r);
4051 (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
4052 ],
4053 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL),
4054 AC_MSG_RESULT(not usable))
4055
4056dnl sysinfo() may exist but not be Linux compatible
4057AC_MSG_CHECKING(for sysinfo)
4058AC_TRY_COMPILE(
4059[#include <sys/types.h>
4060#include <sys/sysinfo.h>],
4061[ struct sysinfo sinfo;
4062 int t;
4063
4064 (void)sysinfo(&sinfo);
4065 t = sinfo.totalram;
4066 ],
4067 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
4068 AC_MSG_RESULT(not usable))
4069
Bram Moolenaar914572a2007-05-01 11:37:47 +00004070dnl struct sysinfo may have the mem_unit field or not
4071AC_MSG_CHECKING(for sysinfo.mem_unit)
4072AC_TRY_COMPILE(
4073[#include <sys/types.h>
4074#include <sys/sysinfo.h>],
4075[ struct sysinfo sinfo;
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02004076 sinfo.mem_unit = 1;
Bram Moolenaar914572a2007-05-01 11:37:47 +00004077 ],
4078 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_MEM_UNIT),
4079 AC_MSG_RESULT(no))
4080
Bram Moolenaar071d4272004-06-13 20:20:40 +00004081dnl sysconf() may exist but not support what we want to use
4082AC_MSG_CHECKING(for sysconf)
4083AC_TRY_COMPILE(
4084[#include <unistd.h>],
4085[ (void)sysconf(_SC_PAGESIZE);
4086 (void)sysconf(_SC_PHYS_PAGES);
4087 ],
4088 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
4089 AC_MSG_RESULT(not usable))
4090
Bram Moolenaar914703b2010-05-31 21:59:46 +02004091AC_CHECK_SIZEOF([int])
4092AC_CHECK_SIZEOF([long])
4093AC_CHECK_SIZEOF([time_t])
4094AC_CHECK_SIZEOF([off_t])
Bram Moolenaar644fdff2010-05-30 13:26:21 +02004095
Bram Moolenaara2aa31a2014-02-23 22:52:40 +01004096dnl Use different names to avoid clashing with other header files.
4097AC_DEFINE_UNQUOTED(VIM_SIZEOF_INT, [$ac_cv_sizeof_int])
4098AC_DEFINE_UNQUOTED(VIM_SIZEOF_LONG, [$ac_cv_sizeof_long])
4099
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004100dnl Make sure that uint32_t is really 32 bits unsigned.
4101AC_MSG_CHECKING([uint32_t is 32 bits])
4102AC_TRY_RUN([
4103#ifdef HAVE_STDINT_H
4104# include <stdint.h>
4105#endif
4106#ifdef HAVE_INTTYPES_H
4107# include <inttypes.h>
4108#endif
4109main() {
4110 uint32_t nr1 = (uint32_t)-1;
4111 uint32_t nr2 = (uint32_t)0xffffffffUL;
Bram Moolenaar52897832020-07-02 22:50:37 +02004112 if (sizeof(uint32_t) != 4 || nr1 != 0xffffffffUL || nr2 + 1 != 0) return 1;
4113 return 0;
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004114}],
4115AC_MSG_RESULT(ok),
4116AC_MSG_ERROR([WRONG! uint32_t not defined correctly.]),
Bram Moolenaar323cb952011-12-14 19:22:34 +01004117AC_MSG_WARN([cannot check uint32_t when cross-compiling.]))
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02004118
Bram Moolenaar446cb832008-06-24 21:56:24 +00004119dnl Check for memmove() before bcopy(), makes memmove() be used when both are
4120dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
4121
Bram Moolenaar071d4272004-06-13 20:20:40 +00004122[bcopy_test_prog='
Bram Moolenaar446cb832008-06-24 21:56:24 +00004123#include "confdefs.h"
4124#ifdef HAVE_STRING_H
4125# include <string.h>
4126#endif
4127#if STDC_HEADERS
4128# include <stdlib.h>
4129# include <stddef.h>
4130#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004131main() {
4132 char buf[10];
4133 strcpy(buf, "abcdefghi");
4134 mch_memmove(buf, buf + 2, 3);
4135 if (strncmp(buf, "ababcf", 6))
4136 exit(1);
4137 strcpy(buf, "abcdefghi");
4138 mch_memmove(buf + 2, buf, 3);
4139 if (strncmp(buf, "cdedef", 6))
4140 exit(1);
4141 exit(0); /* libc version works properly. */
4142}']
4143
Bram Moolenaar446cb832008-06-24 21:56:24 +00004144AC_CACHE_CHECK([whether memmove handles overlaps],[vim_cv_memmove_handles_overlap],
4145 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004146 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 +00004147 [
4148 vim_cv_memmove_handles_overlap=yes
4149 ],[
4150 vim_cv_memmove_handles_overlap=no
4151 ],[
4152 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memmove_handles_overlap')
4153 ])
4154 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00004155
Bram Moolenaar446cb832008-06-24 21:56:24 +00004156if test "x$vim_cv_memmove_handles_overlap" = "xyes" ; then
4157 AC_DEFINE(USEMEMMOVE)
4158else
4159 AC_CACHE_CHECK([whether bcopy handles overlaps],[vim_cv_bcopy_handles_overlap],
4160 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004161 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 +00004162 [
4163 vim_cv_bcopy_handles_overlap=yes
4164 ],[
4165 vim_cv_bcopy_handles_overlap=no
4166 ],[
4167 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_bcopy_handles_overlap')
4168 ])
4169 ])
4170
4171 if test "x$vim_cv_bcopy_handles_overlap" = "xyes" ; then
4172 AC_DEFINE(USEBCOPY)
4173 else
4174 AC_CACHE_CHECK([whether memcpy handles overlaps],[vim_cv_memcpy_handles_overlap],
4175 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01004176 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 +00004177 [
4178 vim_cv_memcpy_handles_overlap=yes
4179 ],[
4180 vim_cv_memcpy_handles_overlap=no
4181 ],[
4182 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memcpy_handles_overlap')
4183 ])
4184 ])
4185
4186 if test "x$vim_cv_memcpy_handles_overlap" = "xyes" ; then
4187 AC_DEFINE(USEMEMCPY)
4188 fi
4189 fi
4190fi
4191
Bram Moolenaar071d4272004-06-13 20:20:40 +00004192
4193dnl Check for multibyte locale functions
4194dnl Find out if _Xsetlocale() is supported by libX11.
4195dnl Check if X_LOCALE should be defined.
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004196if test "x$with_x" = "xyes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004197 cflags_save=$CFLAGS
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004198 libs_save=$LIBS
4199 LIBS="$LIBS $X_LIBS $GUI_LIB_LOC $GUI_X_LIBS $X_PRE_LIBS $X_LIB $X_EXTRA_LIBS"
4200 CFLAGS="$CFLAGS $X_CFLAGS"
4201
4202 AC_MSG_CHECKING(whether X_LOCALE needed)
4203 AC_TRY_COMPILE([#include <X11/Xlocale.h>],,
4204 AC_TRY_LINK_FUNC([_Xsetlocale], [AC_MSG_RESULT(yes)
4205 AC_DEFINE(X_LOCALE)], AC_MSG_RESULT(no)),
4206 AC_MSG_RESULT(no))
4207
4208 AC_MSG_CHECKING(whether Xutf8SetWMProperties() can be used)
4209 AC_TRY_LINK_FUNC([Xutf8SetWMProperties], [AC_MSG_RESULT(yes)
4210 AC_DEFINE(HAVE_XUTF8SETWMPROPERTIES)], AC_MSG_RESULT(no))
4211
Bram Moolenaar071d4272004-06-13 20:20:40 +00004212 CFLAGS=$cflags_save
Bram Moolenaarcbc246a2014-10-11 14:47:26 +02004213 LIBS=$libs_save
Bram Moolenaar071d4272004-06-13 20:20:40 +00004214fi
4215
4216dnl Link with xpg4, it is said to make Korean locale working
4217AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,)
4218
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004219dnl Check how we can run ctags. Default to "ctags" when nothing works.
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02004220dnl Use --version to detect Exuberant ctags (preferred)
Bram Moolenaarb21e5842006-04-16 18:30:08 +00004221dnl Add --fields=+S to get function signatures for omni completion.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004222dnl -t for typedefs (many ctags have this)
4223dnl -s for static functions (Elvis ctags only?)
4224dnl -v for variables. Dangerous, most ctags take this for 'vgrind style'.
4225dnl -i+m to test for older Exuberant ctags
4226AC_MSG_CHECKING(how to create tags)
4227test -f tags && mv tags tags.save
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004228if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004229 TAGPRG="ctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004230elif (eval exctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004231 TAGPRG="exctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02004232elif (eval exuberant-ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaar509ff062020-01-02 22:38:49 +01004233 TAGPRG="exuberant-ctags -I INIT+,INIT2+,INIT3+,INIT4+,INIT5+ --fields=+S"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004234else
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00004235 TAGPRG="ctags"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004236 (eval etags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags"
4237 (eval etags -c /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags -c"
4238 (eval ctags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags"
4239 (eval ctags -t /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -t"
4240 (eval ctags -ts /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -ts"
4241 (eval ctags -tvs /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -tvs"
4242 (eval ctags -i+m /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -i+m"
4243fi
4244test -f tags.save && mv tags.save tags
4245AC_MSG_RESULT($TAGPRG) AC_SUBST(TAGPRG)
4246
4247dnl Check how we can run man with a section number
4248AC_MSG_CHECKING(how to run man with a section nr)
4249MANDEF="man"
Bram Moolenaar8b131502008-02-13 09:28:19 +00004250(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 +00004251AC_MSG_RESULT($MANDEF)
4252if test "$MANDEF" = "man -s"; then
4253 AC_DEFINE(USEMAN_S)
4254fi
4255
4256dnl Check if gettext() is working and if it needs -lintl
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004257dnl We take care to base this on an empty LIBS: on some systems libelf would be
4258dnl in LIBS and implicitly take along libintl. The final LIBS would then not
4259dnl contain libintl, and the link step would fail due to -Wl,--as-needed.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004260AC_MSG_CHECKING(--disable-nls argument)
4261AC_ARG_ENABLE(nls,
4262 [ --disable-nls Don't support NLS (gettext()).], ,
4263 [enable_nls="yes"])
4264
4265if test "$enable_nls" = "yes"; then
4266 AC_MSG_RESULT(no)
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00004267
4268 INSTALL_LANGS=install-languages
4269 AC_SUBST(INSTALL_LANGS)
4270 INSTALL_TOOL_LANGS=install-tool-languages
4271 AC_SUBST(INSTALL_TOOL_LANGS)
4272
Bram Moolenaar071d4272004-06-13 20:20:40 +00004273 AC_CHECK_PROG(MSGFMT, msgfmt, msgfmt, )
4274 AC_MSG_CHECKING([for NLS])
4275 if test -f po/Makefile; then
4276 have_gettext="no"
4277 if test -n "$MSGFMT"; then
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004278 olibs=$LIBS
4279 LIBS=""
Bram Moolenaar071d4272004-06-13 20:20:40 +00004280 AC_TRY_LINK(
4281 [#include <libintl.h>],
4282 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004283 AC_MSG_RESULT([gettext() works]); have_gettext="yes"; LIBS=$olibs,
4284 LIBS="-lintl"
Bram Moolenaar071d4272004-06-13 20:20:40 +00004285 AC_TRY_LINK(
4286 [#include <libintl.h>],
4287 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01004288 AC_MSG_RESULT([gettext() works with -lintl]); have_gettext="yes";
4289 LIBS="$olibs -lintl",
Bram Moolenaar071d4272004-06-13 20:20:40 +00004290 AC_MSG_RESULT([gettext() doesn't work]);
4291 LIBS=$olibs))
4292 else
4293 AC_MSG_RESULT([msgfmt not found - disabled]);
4294 fi
Bram Moolenaar278eb582014-07-30 13:22:52 +02004295 if test $have_gettext = "yes" -a "x$features" != "xtiny" -a "x$features" != "xsmall"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004296 AC_DEFINE(HAVE_GETTEXT)
4297 MAKEMO=yes
4298 AC_SUBST(MAKEMO)
4299 dnl this was added in GNU gettext 0.10.36
4300 AC_CHECK_FUNCS(bind_textdomain_codeset)
4301 dnl _nl_msg_cat_cntr is required for GNU gettext
4302 AC_MSG_CHECKING([for _nl_msg_cat_cntr])
4303 AC_TRY_LINK(
4304 [#include <libintl.h>
4305 extern int _nl_msg_cat_cntr;],
4306 [++_nl_msg_cat_cntr;],
4307 AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_NL_MSG_CAT_CNTR),
4308 AC_MSG_RESULT([no]))
Bram Moolenaar26096cc2019-04-11 15:25:40 +02004309 AC_MSG_CHECKING([if msgfmt supports --desktop])
4310 MSGFMT_DESKTOP=
4311 if "$MSGFMT" --help | grep -e '--desktop' >/dev/null; then
Bram Moolenaar62a88f42019-06-07 20:44:40 +02004312 if "$MSGFMT" --version | grep '0.19.[[3-7]]$' >/dev/null; then
4313 dnl GNU gettext 0.19.7's --desktop is broken. We assume back to
4314 dnl 0.19.3 is also broken.
4315 AC_MSG_RESULT([broken])
4316 else
4317 AC_MSG_RESULT([yes])
4318 MSGFMT_DESKTOP="gvim.desktop vim.desktop"
4319 fi
Bram Moolenaar26096cc2019-04-11 15:25:40 +02004320 else
4321 AC_MSG_RESULT([no])
4322 fi
4323 AC_SUBST(MSGFMT_DESKTOP)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004324 fi
4325 else
4326 AC_MSG_RESULT([no "po/Makefile" - disabled]);
4327 fi
4328else
4329 AC_MSG_RESULT(yes)
4330fi
4331
4332dnl Check for dynamic linking loader
4333AC_CHECK_HEADER(dlfcn.h, DLL=dlfcn.h, [AC_CHECK_HEADER(dl.h, DLL=dl.h)])
4334if test x${DLL} = xdlfcn.h; then
4335 AC_DEFINE(HAVE_DLFCN_H, 1, [ Define if we have dlfcn.h. ])
4336 AC_MSG_CHECKING([for dlopen()])
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 AC_MSG_CHECKING([for dlopen() in -ldl])
4345 olibs=$LIBS
4346 LIBS="$LIBS -ldl"
4347 AC_TRY_LINK(,[
4348 extern void* dlopen();
4349 dlopen();
4350 ],
4351 AC_MSG_RESULT(yes);
4352 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
4353 AC_MSG_RESULT(no);
4354 LIBS=$olibs))
4355 dnl ReliantUNIX has dlopen() in libc but everything else in libdl
4356 dnl ick :-)
4357 AC_MSG_CHECKING([for dlsym()])
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 AC_MSG_CHECKING([for dlsym() in -ldl])
4366 olibs=$LIBS
4367 LIBS="$LIBS -ldl"
4368 AC_TRY_LINK(,[
4369 extern void* dlsym();
4370 dlsym();
4371 ],
4372 AC_MSG_RESULT(yes);
4373 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
4374 AC_MSG_RESULT(no);
4375 LIBS=$olibs))
4376elif test x${DLL} = xdl.h; then
4377 AC_DEFINE(HAVE_DL_H, 1, [ Define if we have dl.h. ])
4378 AC_MSG_CHECKING([for shl_load()])
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 AC_MSG_CHECKING([for shl_load() in -ldld])
4387 olibs=$LIBS
4388 LIBS="$LIBS -ldld"
4389 AC_TRY_LINK(,[
4390 extern void* shl_load();
4391 shl_load();
4392 ],
4393 AC_MSG_RESULT(yes);
4394 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
4395 AC_MSG_RESULT(no);
4396 LIBS=$olibs))
4397fi
4398AC_CHECK_HEADERS(setjmp.h)
4399
Bram Moolenaard0573012017-10-28 21:11:06 +02004400if test "x$MACOS_X" = "xyes" -a -n "$PERL"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00004401 dnl -ldl must come after DynaLoader.a
4402 if echo $LIBS | grep -e '-ldl' >/dev/null; then
4403 LIBS=`echo $LIBS | sed s/-ldl//`
4404 PERL_LIBS="$PERL_LIBS -ldl"
4405 fi
4406fi
4407
Bram Moolenaard0573012017-10-28 21:11:06 +02004408if test "$MACOS_X" = "yes"; then
4409 AC_MSG_CHECKING([whether we need macOS frameworks])
Bram Moolenaar097148e2020-08-11 21:58:20 +02004410 if test "$MACOS_X_DARWIN" = "yes"; then
Bram Moolenaard0573012017-10-28 21:11:06 +02004411 if test "$features" = "tiny"; then
4412 dnl Since no FEAT_CLIPBOARD, no longer need for os_macosx.m.
4413 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_macosx.m++'`
4414 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_macosx.o++'`
Bram Moolenaar2be7cb72019-01-12 16:10:51 +01004415 AC_MSG_RESULT([yes, we need CoreServices])
4416 LIBS="$LIBS -framework CoreServices"
Bram Moolenaard0573012017-10-28 21:11:06 +02004417 else
4418 AC_MSG_RESULT([yes, we need AppKit])
4419 LIBS="$LIBS -framework AppKit"
Bram Moolenaard0573012017-10-28 21:11:06 +02004420 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004421 else
Bram Moolenaard0573012017-10-28 21:11:06 +02004422 AC_MSG_RESULT([no])
Bram Moolenaar3437b912013-07-03 19:52:53 +02004423 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00004424fi
4425
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004426dnl gcc 3.1 changed the meaning of -MM. The only solution appears to be to
4427dnl use "-isystem" instead of "-I" for all non-Vim include dirs.
4428dnl But only when making dependencies, cproto and lint don't take "-isystem".
Bram Moolenaar32466aa2006-02-24 23:53:04 +00004429dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
4430dnl the number before the version number.
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004431DEPEND_CFLAGS_FILTER=
4432if test "$GCC" = yes; then
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004433 AC_MSG_CHECKING(for GCC 3 or later)
Bram Moolenaar348808f2020-02-07 20:50:07 +01004434 gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]][[0-9]]*\)\..*$/\1/g'`
Bram Moolenaarf740b292006-02-16 22:11:02 +00004435 if test "$gccmajor" -gt "2"; then
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004436 DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004437 AC_MSG_RESULT(yes)
4438 else
4439 AC_MSG_RESULT(no)
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004440 fi
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004441 dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
4442 dnl declared as char x[1] but actually longer. Introduced in gcc 4.0.
Bram Moolenaar56d1db32009-12-16 16:14:51 +00004443 dnl Also remove duplicate _FORTIFY_SOURCE arguments.
Bram Moolenaaraeabe052011-12-08 15:17:34 +01004444 dnl And undefine it first to avoid a warning.
Bram Moolenaar0cd49302008-11-20 09:37:01 +00004445 AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
4446 if test "$gccmajor" -gt "3"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02004447 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 +01004448 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 +00004449 AC_MSG_RESULT(yes)
4450 else
4451 AC_MSG_RESULT(no)
4452 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +00004453fi
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00004454AC_SUBST(DEPEND_CFLAGS_FILTER)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004455
Bram Moolenaarec0557f2018-01-31 14:41:37 +01004456dnl On some systems AC_SYS_LARGEFILE determines that -D_FILE_OFFSET_BITS=64
4457dnl isn't required, but the CFLAGS for some of the libraries we're using
4458dnl include the define. Since the define changes the size of some datatypes
4459dnl (e.g. ino_t and off_t), all of Vim's modules must be compiled with a
4460dnl consistent value. It's therefore safest to force the use of the define
4461dnl if it's present in any of the *_CFLAGS variables.
4462AC_MSG_CHECKING(whether we need to force -D_FILE_OFFSET_BITS=64)
Bram Moolenaar9ce42132018-04-11 22:19:36 +02004463if 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 +01004464 AC_MSG_RESULT(yes)
4465 AC_DEFINE(_FILE_OFFSET_BITS, 64)
4466else
4467 AC_MSG_RESULT(no)
4468fi
4469
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004470dnl link.sh tries to avoid overlinking in a hackish way.
4471dnl At least GNU ld supports --as-needed which provides the same functionality
4472dnl at linker level. Let's use it.
4473AC_MSG_CHECKING(linker --as-needed support)
4474LINK_AS_NEEDED=
4475# Check if linker supports --as-needed and --no-as-needed options
4476if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02004477 LDFLAGS=`echo "$LDFLAGS" | sed -e 's/ *-Wl,--as-needed//g' | sed -e 's/$/ -Wl,--as-needed/'`
Bram Moolenaar22e193d2010-11-03 22:32:24 +01004478 LINK_AS_NEEDED=yes
4479fi
4480if test "$LINK_AS_NEEDED" = yes; then
4481 AC_MSG_RESULT(yes)
4482else
4483 AC_MSG_RESULT(no)
4484fi
4485AC_SUBST(LINK_AS_NEEDED)
4486
Bram Moolenaar77c19352012-06-13 19:19:41 +02004487# IBM z/OS reset CFLAGS for config.mk
4488if test "$zOSUnix" = "yes"; then
4489 CFLAGS="-D_ALL_SOURCE -Wc,float\(ieee\),dll"
4490fi
4491
Bram Moolenaar071d4272004-06-13 20:20:40 +00004492dnl write output files
4493AC_OUTPUT(auto/config.mk:config.mk.in)
4494
4495dnl vim: set sw=2 tw=78 fo+=l: