blob: 22ff9fd8ac8677d9382578d3f5db0e70d84285bd [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001dnl configure.in: autoconf script for Vim
2
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.
14AC_PROG_CC dnl required by almost everything
15AC_PROG_CPP dnl required by header file checks
16AC_PROGRAM_EGREP dnl required by AC_EGREP_CPP
Bram Moolenaar2bcaec32014-03-27 18:51:11 +010017AC_PROG_FGREP dnl finds working grep -F
Bram Moolenaar071d4272004-06-13 20:20:40 +000018AC_ISC_POSIX dnl required by AC_C_CROSS
19AC_PROG_AWK dnl required for "make html" in ../doc
20
21dnl Don't strip if we don't have it
22AC_CHECK_PROG(STRIP, strip, strip, :)
23
Bram Moolenaar325b7a22004-07-05 15:58:32 +000024dnl Check for extension of executables
Bram Moolenaar071d4272004-06-13 20:20:40 +000025AC_EXEEXT
26
Bram Moolenaar446cb832008-06-24 21:56:24 +000027dnl Check for standard headers. We don't use this in Vim but other stuff
28dnl in autoconf needs it, where it uses STDC_HEADERS.
29AC_HEADER_STDC
30AC_HEADER_SYS_WAIT
31
Bram Moolenaarf788a062011-12-14 20:51:25 +010032dnl Check for the flag that fails if stuff are missing.
33
34AC_MSG_CHECKING(--enable-fail-if-missing argument)
35AC_ARG_ENABLE(fail_if_missing,
36 [ --enable-fail-if-missing Fail if dependencies on additional features
37 specified on the command line are missing.],
38 [fail_if_missing="yes"],
39 [fail_if_missing="no"])
40AC_MSG_RESULT($fail_if_missing)
41
Bram Moolenaar071d4272004-06-13 20:20:40 +000042dnl Set default value for CFLAGS if none is defined or it's empty
43if test -z "$CFLAGS"; then
44 CFLAGS="-O"
45 test "$GCC" = yes && CFLAGS="-O2 -fno-strength-reduce -Wall"
46fi
47if test "$GCC" = yes; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +000048 dnl method that should work for nearly all versions
49 gccversion=`"$CC" -dumpversion`
50 if test "x$gccversion" = "x"; then
51 dnl old method; fall-back for when -dumpversion doesn't work
52 gccversion=`"$CC" --version | sed -e '2,$d' -e 's/darwin.//' -e 's/^[[^0-9]]*\([[0-9]]\.[[0-9.]]*\).*$/\1/g'`
53 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +000054 dnl version 4.0.1 was reported to cause trouble on Macintosh by Marcin Dalecki
55 if test "$gccversion" = "3.0.1" -o "$gccversion" = "3.0.2" -o "$gccversion" = "4.0.1"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +000056 echo 'GCC [[34]].0.[[12]] has a bug in the optimizer, disabling "-O#"'
Bram Moolenaar071d4272004-06-13 20:20:40 +000057 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-O/'`
58 else
59 if test "$gccversion" = "3.1" -o "$gccversion" = "3.2" -o "$gccversion" = "3.2.1" && `echo "$CFLAGS" | grep -v fno-strength-reduce >/dev/null`; then
60 echo 'GCC 3.1 and 3.2 have a bug in the optimizer, adding "-fno-strength-reduce"'
61 CFLAGS="$CFLAGS -fno-strength-reduce"
62 fi
63 fi
64fi
65
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +020066dnl clang-500.2.75 or around has abandoned -f[no-]strength-reduce and issues a
67dnl warning when that flag is passed to. Accordingly, adjust CFLAGS based on
68dnl the version number of the clang in use.
69dnl Note that this does not work to get the version of clang 3.1 or 3.2.
70AC_MSG_CHECKING(for recent clang version)
71CLANG_VERSION_STRING=`"$CC" --version 2>/dev/null | sed -n -e 's/^.*clang.*\([[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\).*$/\1/p'`
72if test x"$CLANG_VERSION_STRING" != x"" ; then
73 CLANG_MAJOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*/\1/p'`
74 CLANG_MINOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/p'`
75 CLANG_REVISION=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)/\1/p'`
76 CLANG_VERSION=`expr $CLANG_MAJOR '*' 1000000 '+' $CLANG_MINOR '*' 1000 '+' $CLANG_REVISION`
77 AC_MSG_RESULT($CLANG_VERSION)
78 dnl If you find the same issue with versions earlier than 500.2.75,
79 dnl change the constant 500002075 below appropriately. To get the
80 dnl integer corresponding to a version number, refer to the
81 dnl definition of CLANG_VERSION above.
82 if test "$CLANG_VERSION" -ge 500002075 ; then
83 CFLAGS=`echo "$CFLAGS" | sed -n -e 's/-fno-strength-reduce/ /p'`
84 fi
85else
86 AC_MSG_RESULT(no)
87fi
88
Bram Moolenaar446cb832008-06-24 21:56:24 +000089dnl If configure thinks we are cross compiling, there might be something
90dnl wrong with the CC or CFLAGS settings, give a useful warning message
Bram Moolenaar071d4272004-06-13 20:20:40 +000091if test "$cross_compiling" = yes; then
Bram Moolenaar446cb832008-06-24 21:56:24 +000092 AC_MSG_RESULT([cannot compile a simple program; if not cross compiling check CC and CFLAGS])
Bram Moolenaar071d4272004-06-13 20:20:40 +000093fi
94
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +000095dnl gcc-cpp has the wonderful -MM option to produce nicer dependencies.
96dnl But gcc 3.1 changed the meaning! See near the end.
Bram Moolenaar071d4272004-06-13 20:20:40 +000097test "$GCC" = yes && CPP_MM=M; AC_SUBST(CPP_MM)
98
99if test -f ./toolcheck; then
100 AC_CHECKING(for buggy tools)
101 sh ./toolcheck 1>&AC_FD_MSG
102fi
103
104OS_EXTRA_SRC=""; OS_EXTRA_OBJ=""
105
106dnl Check for BeOS, which needs an extra source file
107AC_MSG_CHECKING(for BeOS)
108case `uname` in
109 BeOS) OS_EXTRA_SRC=os_beos.c; OS_EXTRA_OBJ=objects/os_beos.o
110 BEOS=yes; AC_MSG_RESULT(yes);;
111 *) BEOS=no; AC_MSG_RESULT(no);;
112esac
113
114dnl If QNX is found, assume we don't want to use Xphoton
115dnl unless it was specifically asked for (--with-x)
116AC_MSG_CHECKING(for QNX)
117case `uname` in
118 QNX) OS_EXTRA_SRC=os_qnx.c; OS_EXTRA_OBJ=objects/os_qnx.o
119 test -z "$with_x" && with_x=no
120 QNX=yes; AC_MSG_RESULT(yes);;
121 *) QNX=no; AC_MSG_RESULT(no);;
122esac
123
124dnl Check for Darwin and MacOS X
125dnl We do a check for MacOS X in the very beginning because there
126dnl are a lot of other things we need to change besides GUI stuff
Bram Moolenaar071d4272004-06-13 20:20:40 +0000127AC_MSG_CHECKING([for Darwin (Mac OS X)])
128if test "`(uname) 2>/dev/null`" = Darwin; then
129 AC_MSG_RESULT(yes)
130
131 AC_MSG_CHECKING(--disable-darwin argument)
132 AC_ARG_ENABLE(darwin,
133 [ --disable-darwin Disable Darwin (Mac OS X) support.],
134 , [enable_darwin="yes"])
135 if test "$enable_darwin" = "yes"; then
136 AC_MSG_RESULT(no)
137 AC_MSG_CHECKING(if Darwin files are there)
Bram Moolenaar164fca32010-07-14 13:58:07 +0200138 if test -f os_macosx.m; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000139 AC_MSG_RESULT(yes)
140 else
141 AC_MSG_RESULT([no, Darwin support disabled])
142 enable_darwin=no
143 fi
144 else
145 AC_MSG_RESULT([yes, Darwin support excluded])
146 fi
147
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000148 AC_MSG_CHECKING(--with-mac-arch argument)
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000149 AC_ARG_WITH(mac-arch, [ --with-mac-arch=ARCH current, intel, ppc or both],
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000150 MACARCH="$withval"; AC_MSG_RESULT($MACARCH),
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000151 MACARCH="current"; AC_MSG_RESULT(defaulting to $MACARCH))
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000152
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100153 AC_MSG_CHECKING(--with-developer-dir argument)
154 AC_ARG_WITH(developer-dir, [ --with-developer-dir=PATH use PATH as location for Xcode developer tools],
155 DEVELOPER_DIR="$withval"; AC_MSG_RESULT($DEVELOPER_DIR),
156 DEVELOPER_DIR=""; AC_MSG_RESULT(not present))
157
158 if test "x$DEVELOPER_DIR" = "x"; then
159 AC_PATH_PROG(XCODE_SELECT, xcode-select)
160 if test "x$XCODE_SELECT" != "x"; then
161 AC_MSG_CHECKING(for developer dir using xcode-select)
162 DEVELOPER_DIR=`$XCODE_SELECT -print-path`
163 AC_MSG_RESULT([$DEVELOPER_DIR])
164 else
165 DEVELOPER_DIR=/Developer
166 fi
167 fi
168
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000169 if test "x$MACARCH" = "xboth"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000170 AC_MSG_CHECKING(for 10.4 universal SDK)
171 dnl There is a terrible inconsistency (but we appear to get away with it):
172 dnl $CFLAGS uses the 10.4u SDK library for the headers, while $CPPFLAGS
173 dnl doesn't, because "gcc -E" doesn't grok it. That means the configure
174 dnl tests using the preprocessor are actually done with the wrong header
175 dnl files. $LDFLAGS is set at the end, because configure uses it together
176 dnl with $CFLAGS and we can only have one -sysroot argument.
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000177 save_cppflags="$CPPFLAGS"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000178 save_cflags="$CFLAGS"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000179 save_ldflags="$LDFLAGS"
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100180 CFLAGS="$CFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000181 AC_TRY_LINK([ ], [ ],
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000182 AC_MSG_RESULT(found, will make universal binary),
183
184 AC_MSG_RESULT(not found)
Bram Moolenaar1f35bf92006-03-07 22:38:47 +0000185 CFLAGS="$save_cflags"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000186 AC_MSG_CHECKING(if Intel architecture is supported)
187 CPPFLAGS="$CPPFLAGS -arch i386"
188 LDFLAGS="$save_ldflags -arch i386"
189 AC_TRY_LINK([ ], [ ],
190 AC_MSG_RESULT(yes); MACARCH="intel",
191 AC_MSG_RESULT(no, using PowerPC)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000192 MACARCH="ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000193 CPPFLAGS="$save_cppflags -arch ppc"
194 LDFLAGS="$save_ldflags -arch ppc"))
195 elif test "x$MACARCH" = "xintel"; then
196 CPPFLAGS="$CPPFLAGS -arch intel"
197 LDFLAGS="$LDFLAGS -arch intel"
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000198 elif test "x$MACARCH" = "xppc"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000199 CPPFLAGS="$CPPFLAGS -arch ppc"
200 LDFLAGS="$LDFLAGS -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000201 fi
202
Bram Moolenaar071d4272004-06-13 20:20:40 +0000203 if test "$enable_darwin" = "yes"; then
204 MACOSX=yes
Bram Moolenaar164fca32010-07-14 13:58:07 +0200205 OS_EXTRA_SRC="os_macosx.m os_mac_conv.c";
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000206 OS_EXTRA_OBJ="objects/os_macosx.o objects/os_mac_conv.o"
Bram Moolenaar32466aa2006-02-24 23:53:04 +0000207 dnl TODO: use -arch i386 on Intel machines
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100208 dnl Removed -no-cpp-precomp, only for very old compilers.
209 CPPFLAGS="$CPPFLAGS -DMACOS_X_UNIX"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000210
211 dnl If Carbon is found, assume we don't want X11
212 dnl unless it was specifically asked for (--with-x)
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000213 dnl or Motif, Athena or GTK GUI is used.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000214 AC_CHECK_HEADER(Carbon/Carbon.h, CARBON=yes)
215 if test "x$CARBON" = "xyes"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +0200216 if test -z "$with_x" -a "X$enable_gui" != Xmotif -a "X$enable_gui" != Xathena -a "X$enable_gui" != Xgtk2; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000217 with_x=no
Bram Moolenaar071d4272004-06-13 20:20:40 +0000218 fi
219 fi
220 fi
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000221
Bram Moolenaardb552d602006-03-23 22:59:57 +0000222 dnl Avoid a bug with -O2 with gcc 4.0.1. Symptom: malloc() reports double
Bram Moolenaarfd2ac762006-03-01 22:09:21 +0000223 dnl free. This happens in expand_filename(), because the optimizer swaps
Bram Moolenaardb552d602006-03-23 22:59:57 +0000224 dnl two blocks of code, both using "repl", that can't be swapped.
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000225 if test "$MACARCH" = "intel" -o "$MACARCH" = "both"; then
226 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-Oz/'`
227 fi
228
Bram Moolenaar071d4272004-06-13 20:20:40 +0000229else
230 AC_MSG_RESULT(no)
231fi
232
Bram Moolenaar39766a72013-11-03 00:41:00 +0100233dnl Mac OS X 10.9+ no longer include AvailabilityMacros.h in Carbon
234dnl so we need to include it to have access to version macros.
Bram Moolenaar18e54692013-11-03 20:26:31 +0100235AC_CHECK_HEADERS(AvailabilityMacros.h)
Bram Moolenaar39766a72013-11-03 00:41:00 +0100236
Bram Moolenaar071d4272004-06-13 20:20:40 +0000237AC_SUBST(OS_EXTRA_SRC)
238AC_SUBST(OS_EXTRA_OBJ)
239
240dnl Add /usr/local/lib to $LDFLAGS and /usr/local/include to CFLAGS.
241dnl Only when the directory exists and it wasn't there yet.
242dnl For gcc don't do this when it is already in the default search path.
Bram Moolenaar446cb832008-06-24 21:56:24 +0000243dnl Skip all of this when cross-compiling.
244if test "$cross_compiling" = no; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000245 AC_MSG_CHECKING(--with-local-dir argument)
Bram Moolenaar446cb832008-06-24 21:56:24 +0000246 have_local_include=''
247 have_local_lib=''
Bram Moolenaarc236c162008-07-13 17:41:49 +0000248 AC_ARG_WITH([local-dir], [ --with-local-dir=PATH search PATH instead of /usr/local for local libraries.
249 --without-local-dir do not search /usr/local for local libraries.], [
250 local_dir="$withval"
251 case "$withval" in
252 */*) ;;
253 no)
254 # avoid adding local dir to LDFLAGS and CPPFLAGS
Bram Moolenaare06c1882010-07-21 22:05:20 +0200255 have_local_include=yes
Bram Moolenaarc236c162008-07-13 17:41:49 +0000256 have_local_lib=yes
257 ;;
258 *) AC_MSG_ERROR(must pass path argument to --with-local-dir) ;;
259 esac
260 AC_MSG_RESULT($local_dir)
261 ], [
262 local_dir=/usr/local
263 AC_MSG_RESULT(Defaulting to $local_dir)
264 ])
265 if test "$GCC" = yes -a "$local_dir" != no; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000266 echo 'void f(){}' > conftest.c
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100267 dnl Removed -no-cpp-precomp, only needed for OS X 10.2 (Ben Fowler)
268 have_local_include=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/include"`
Bram Moolenaarc236c162008-07-13 17:41:49 +0000269 have_local_lib=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/lib"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000270 rm -f conftest.c conftest.o
Bram Moolenaar071d4272004-06-13 20:20:40 +0000271 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000272 if test -z "$have_local_lib" -a -d "${local_dir}/lib"; then
273 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 +0000274 if test "$tt" = "$LDFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000275 LDFLAGS="$LDFLAGS -L${local_dir}/lib"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000276 fi
277 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000278 if test -z "$have_local_include" -a -d "${local_dir}/include"; then
279 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 +0000280 if test "$tt" = "$CPPFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000281 CPPFLAGS="$CPPFLAGS -I${local_dir}/include"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000282 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000283 fi
284fi
285
286AC_MSG_CHECKING(--with-vim-name argument)
287AC_ARG_WITH(vim-name, [ --with-vim-name=NAME what to call the Vim executable],
288 VIMNAME="$withval"; AC_MSG_RESULT($VIMNAME),
Bram Moolenaare344bea2005-09-01 20:46:49 +0000289 VIMNAME="vim"; AC_MSG_RESULT(Defaulting to $VIMNAME))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000290AC_SUBST(VIMNAME)
291AC_MSG_CHECKING(--with-ex-name argument)
292AC_ARG_WITH(ex-name, [ --with-ex-name=NAME what to call the Ex executable],
293 EXNAME="$withval"; AC_MSG_RESULT($EXNAME),
294 EXNAME="ex"; AC_MSG_RESULT(Defaulting to ex))
295AC_SUBST(EXNAME)
296AC_MSG_CHECKING(--with-view-name argument)
297AC_ARG_WITH(view-name, [ --with-view-name=NAME what to call the View executable],
298 VIEWNAME="$withval"; AC_MSG_RESULT($VIEWNAME),
299 VIEWNAME="view"; AC_MSG_RESULT(Defaulting to view))
300AC_SUBST(VIEWNAME)
301
302AC_MSG_CHECKING(--with-global-runtime argument)
303AC_ARG_WITH(global-runtime, [ --with-global-runtime=DIR global runtime directory in 'runtimepath'],
304 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL, "$withval"),
305 AC_MSG_RESULT(no))
306
307AC_MSG_CHECKING(--with-modified-by argument)
308AC_ARG_WITH(modified-by, [ --with-modified-by=NAME name of who modified a release version],
309 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(MODIFIED_BY, "$withval"),
310 AC_MSG_RESULT(no))
311
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200312dnl Check for EBCDIC stolen from the LYNX port to z/OS Unix
Bram Moolenaar071d4272004-06-13 20:20:40 +0000313AC_MSG_CHECKING(if character set is EBCDIC)
314AC_TRY_COMPILE([ ],
315[ /* TryCompile function for CharSet.
316 Treat any failure as ASCII for compatibility with existing art.
317 Use compile-time rather than run-time tests for cross-compiler
318 tolerance. */
319#if '0'!=240
320make an error "Character set is not EBCDIC"
321#endif ],
322[ # TryCompile action if true
323cf_cv_ebcdic=yes ],
324[ # TryCompile action if false
325cf_cv_ebcdic=no])
326# end of TryCompile ])
327# end of CacheVal CvEbcdic
328AC_MSG_RESULT($cf_cv_ebcdic)
329case "$cf_cv_ebcdic" in #(vi
330 yes) AC_DEFINE(EBCDIC)
331 line_break='"\\n"'
332 ;;
333 *) line_break='"\\012"';;
334esac
335AC_SUBST(line_break)
336
337if test "$cf_cv_ebcdic" = "yes"; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +0200338dnl If we have EBCDIC we most likely have z/OS Unix, let's test it!
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200339AC_MSG_CHECKING(for z/OS Unix)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000340case `uname` in
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200341 OS/390) zOSUnix="yes";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000342 dnl If using cc the environment variable _CC_CCMODE must be
343 dnl set to "1", so that some compiler extensions are enabled.
344 dnl If using c89 the environment variable is named _CC_C89MODE.
345 dnl Note: compile with c89 never tested.
346 if test "$CC" = "cc"; then
347 ccm="$_CC_CCMODE"
348 ccn="CC"
349 else
350 if test "$CC" = "c89"; then
351 ccm="$_CC_C89MODE"
352 ccn="C89"
353 else
354 ccm=1
355 fi
356 fi
357 if test "$ccm" != "1"; then
358 echo ""
359 echo "------------------------------------------"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200360 echo " On z/OS Unix, the environment variable"
Bram Moolenaar77c19352012-06-13 19:19:41 +0200361 echo " _CC_${ccn}MODE must be set to \"1\"!"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000362 echo " Do:"
363 echo " export _CC_${ccn}MODE=1"
364 echo " and then call configure again."
365 echo "------------------------------------------"
366 exit 1
367 fi
Bram Moolenaar77c19352012-06-13 19:19:41 +0200368 # Set CFLAGS for configure process.
369 # This will be reset later for config.mk.
370 # Use haltonmsg to force error for missing H files.
371 CFLAGS="$CFLAGS -D_ALL_SOURCE -Wc,float(ieee),haltonmsg(3296)";
372 LDFLAGS="$LDFLAGS -Wl,EDIT=NO"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000373 AC_MSG_RESULT(yes)
374 ;;
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200375 *) zOSUnix="no";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000376 AC_MSG_RESULT(no)
377 ;;
378esac
379fi
380
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200381dnl Set QUOTESED. Needs additional backslashes on zOS
382if test "$zOSUnix" = "yes"; then
383 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\\\\\&/g' -e 's/\\\\\\\\\"/\"/' -e 's/\\\\\\\\\";\$\$/\";/'"
384else
385 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\&/g' -e 's/\\\\\"/\"/' -e 's/\\\\\";\$\$/\";/'"
386fi
387AC_SUBST(QUOTESED)
388
389
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200390dnl Link with -lsmack for Smack stuff; if not found
391AC_MSG_CHECKING(--disable-smack argument)
392AC_ARG_ENABLE(smack,
393 [ --disable-smack Do not check for Smack support.],
394 , enable_smack="yes")
395if test "$enable_smack" = "yes"; then
396 AC_CHECK_HEADER([linux/xattr.h], true, enable_smack="no")
397fi
398if test "$enable_smack" = "yes"; then
Bram Moolenaar588ebeb2008-05-07 17:09:24 +0000399 AC_MSG_RESULT(no)
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200400 AC_CHECK_LIB(attr, llistxattr,
401 [LIBS="$LIBS -lattr"
402 found_smack="yes"
403 AC_DEFINE(HAVE_SMACK)])
Bram Moolenaar588ebeb2008-05-07 17:09:24 +0000404else
405 AC_MSG_RESULT(yes)
406fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000407
Bram Moolenaar5bd32f42014-04-02 14:05:38 +0200408dnl When smack was found don't search for SELinux
409if test "x$found_smack" = "x"; then
410 dnl Link with -lselinux for SELinux stuff; if not found
411 AC_MSG_CHECKING(--disable-selinux argument)
412 AC_ARG_ENABLE(selinux,
413 [ --disable-selinux Do not check for SELinux support.],
414 , enable_selinux="yes")
415 if test "$enable_selinux" = "yes"; then
416 AC_MSG_RESULT(no)
417 AC_CHECK_LIB(selinux, is_selinux_enabled,
418 [LIBS="$LIBS -lselinux"
419 AC_DEFINE(HAVE_SELINUX)])
420 else
421 AC_MSG_RESULT(yes)
422 fi
423fi
424
Bram Moolenaar071d4272004-06-13 20:20:40 +0000425dnl Check user requested features.
426
427AC_MSG_CHECKING(--with-features argument)
428AC_ARG_WITH(features, [ --with-features=TYPE tiny, small, normal, big or huge (default: normal)],
429 features="$withval"; AC_MSG_RESULT($features),
430 features="normal"; AC_MSG_RESULT(Defaulting to normal))
431
432dovimdiff=""
433dogvimdiff=""
434case "$features" in
435 tiny) AC_DEFINE(FEAT_TINY) ;;
436 small) AC_DEFINE(FEAT_SMALL) ;;
437 normal) AC_DEFINE(FEAT_NORMAL) dovimdiff="installvimdiff";
438 dogvimdiff="installgvimdiff" ;;
439 big) AC_DEFINE(FEAT_BIG) dovimdiff="installvimdiff";
440 dogvimdiff="installgvimdiff" ;;
441 huge) AC_DEFINE(FEAT_HUGE) dovimdiff="installvimdiff";
442 dogvimdiff="installgvimdiff" ;;
443 *) AC_MSG_RESULT([Sorry, $features is not supported]) ;;
444esac
445
446AC_SUBST(dovimdiff)
447AC_SUBST(dogvimdiff)
448
449AC_MSG_CHECKING(--with-compiledby argument)
450AC_ARG_WITH(compiledby, [ --with-compiledby=NAME name to show in :version message],
451 compiledby="$withval"; AC_MSG_RESULT($withval),
452 compiledby=""; AC_MSG_RESULT(no))
453AC_SUBST(compiledby)
454
455AC_MSG_CHECKING(--disable-xsmp argument)
456AC_ARG_ENABLE(xsmp,
457 [ --disable-xsmp Disable XSMP session management],
458 , enable_xsmp="yes")
459
460if test "$enable_xsmp" = "yes"; then
461 AC_MSG_RESULT(no)
462 AC_MSG_CHECKING(--disable-xsmp-interact argument)
463 AC_ARG_ENABLE(xsmp-interact,
464 [ --disable-xsmp-interact Disable XSMP interaction],
465 , enable_xsmp_interact="yes")
466 if test "$enable_xsmp_interact" = "yes"; then
467 AC_MSG_RESULT(no)
468 AC_DEFINE(USE_XSMP_INTERACT)
469 else
470 AC_MSG_RESULT(yes)
471 fi
472else
473 AC_MSG_RESULT(yes)
474fi
475
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200476dnl Check for Lua feature.
477AC_MSG_CHECKING(--enable-luainterp argument)
478AC_ARG_ENABLE(luainterp,
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200479 [ --enable-luainterp[=OPTS] Include Lua interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200480 [enable_luainterp="no"])
481AC_MSG_RESULT($enable_luainterp)
482
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200483if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200484 dnl -- find the lua executable
485 AC_SUBST(vi_cv_path_lua)
486
487 AC_MSG_CHECKING(--with-lua-prefix argument)
488 AC_ARG_WITH(lua_prefix,
489 [ --with-lua-prefix=PFX Prefix where Lua is installed.],
490 with_lua_prefix="$withval"; AC_MSG_RESULT($with_lua_prefix),
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200491 with_lua_prefix="";AC_MSG_RESULT(no))
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200492
493 if test "X$with_lua_prefix" != "X"; then
494 vi_cv_path_lua_pfx="$with_lua_prefix"
495 else
496 AC_MSG_CHECKING(LUA_PREFIX environment var)
497 if test "X$LUA_PREFIX" != "X"; then
498 AC_MSG_RESULT("$LUA_PREFIX")
499 vi_cv_path_lua_pfx="$LUA_PREFIX"
500 else
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200501 AC_MSG_RESULT([not set, default to /usr])
502 vi_cv_path_lua_pfx="/usr"
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200503 fi
504 fi
505
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200506 AC_MSG_CHECKING(--with-luajit)
507 AC_ARG_WITH(luajit,
508 [ --with-luajit Link with LuaJIT instead of Lua.],
509 [vi_cv_with_luajit="$withval"],
510 [vi_cv_with_luajit="no"])
511 AC_MSG_RESULT($vi_cv_with_luajit)
512
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200513 LUA_INC=
514 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200515 if test "x$vi_cv_with_luajit" != "xno"; then
516 dnl -- try to find LuaJIT executable
517 AC_PATH_PROG(vi_cv_path_luajit, luajit)
518 if test "X$vi_cv_path_luajit" != "X"; then
519 dnl -- find LuaJIT version
520 AC_CACHE_CHECK(LuaJIT version, vi_cv_version_luajit,
Bram Moolenaar49b10272013-11-21 12:17:51 +0100521 [ 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 +0200522 AC_CACHE_CHECK(Lua version of LuaJIT, vi_cv_version_lua_luajit,
523 [ vi_cv_version_lua_luajit=`${vi_cv_path_luajit} -e "print(_VERSION)" | sed 's/.* //'` ])
524 vi_cv_path_lua="$vi_cv_path_luajit"
525 vi_cv_version_lua="$vi_cv_version_lua_luajit"
526 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200527 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200528 dnl -- try to find Lua executable
529 AC_PATH_PROG(vi_cv_path_plain_lua, lua)
530 if test "X$vi_cv_path_plain_lua" != "X"; then
531 dnl -- find Lua version
532 AC_CACHE_CHECK(Lua version, vi_cv_version_plain_lua,
533 [ vi_cv_version_plain_lua=`${vi_cv_path_plain_lua} -e "print(_VERSION)" | sed 's/.* //'` ])
534 fi
535 vi_cv_path_lua="$vi_cv_path_plain_lua"
536 vi_cv_version_lua="$vi_cv_version_plain_lua"
537 fi
538 if test "x$vi_cv_with_luajit" != "xno" && test "X$vi_cv_version_luajit" != "X"; then
539 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit)
540 if test -f $vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit/lua.h; then
541 AC_MSG_RESULT(yes)
542 LUA_INC=/luajit-$vi_cv_version_luajit
543 fi
544 fi
545 if test "X$LUA_INC" = "X"; then
546 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)
547 if test -f $vi_cv_path_lua_pfx/include/lua.h; then
548 AC_MSG_RESULT(yes)
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200549 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200550 AC_MSG_RESULT(no)
551 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua)
552 if test -f $vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h; then
553 AC_MSG_RESULT(yes)
554 LUA_INC=/lua$vi_cv_version_lua
555 else
556 AC_MSG_RESULT(no)
557 vi_cv_path_lua_pfx=
558 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200559 fi
560 fi
561 fi
562
563 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200564 if test "x$vi_cv_with_luajit" != "xno"; then
565 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
566 if test "X$multiarch" != "X"; then
567 lib_multiarch="lib/${multiarch}"
568 else
569 lib_multiarch="lib"
570 fi
571 if test "X$vi_cv_version_lua" = "X"; then
572 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit"
573 else
574 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit-$vi_cv_version_lua"
575 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200576 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200577 if test "X$LUA_INC" != "X"; then
578 dnl Test alternate location using version
579 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua$vi_cv_version_lua"
580 else
581 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua"
582 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200583 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200584 if test "$enable_luainterp" = "dynamic"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200585 lua_ok="yes"
586 else
587 AC_MSG_CHECKING([if link with ${LUA_LIBS} is sane])
588 libs_save=$LIBS
589 LIBS="$LIBS $LUA_LIBS"
590 AC_TRY_LINK(,[ ],
591 AC_MSG_RESULT(yes); lua_ok="yes",
592 AC_MSG_RESULT(no); lua_ok="no"; LUA_LIBS="")
593 LIBS=$libs_save
594 fi
595 if test "x$lua_ok" = "xyes"; then
596 LUA_CFLAGS="-I${vi_cv_path_lua_pfx}/include${LUA_INC}"
597 LUA_SRC="if_lua.c"
598 LUA_OBJ="objects/if_lua.o"
599 LUA_PRO="if_lua.pro"
600 AC_DEFINE(FEAT_LUA)
601 fi
602 if test "$enable_luainterp" = "dynamic"; then
603 if test "x$vi_cv_with_luajit" != "xno"; then
604 luajit="jit"
605 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200606 if test -f "${vi_cv_path_lua_pfx}/bin/cyglua-${vi_cv_version_lua}.dll"; then
607 vi_cv_dll_name_lua="cyglua-${vi_cv_version_lua}.dll"
608 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200609 if test "x$MACOSX" = "xyes"; then
610 ext="dylib"
611 indexes=""
612 else
613 ext="so"
614 indexes=".0 .1 .2 .3 .4 .5 .6 .7 .8 .9"
615 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
616 if test "X$multiarch" != "X"; then
617 lib_multiarch="lib/${multiarch}"
618 fi
Bram Moolenaar768baac2013-04-15 14:44:57 +0200619 fi
620 dnl Determine the sover for the current version, but fallback to
621 dnl liblua${vi_cv_version_lua}.so if no sover-versioned file is found.
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200622 AC_MSG_CHECKING(if liblua${luajit}*.${ext}* can be found in $vi_cv_path_lua_pfx)
Bram Moolenaar768baac2013-04-15 14:44:57 +0200623 for subdir in "${lib_multiarch}" lib64 lib; do
624 if test -z "$subdir"; then
625 continue
626 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200627 for sover in "${vi_cv_version_lua}.${ext}" "-${vi_cv_version_lua}.${ext}" \
628 ".${vi_cv_version_lua}.${ext}" ".${ext}.${vi_cv_version_lua}"; do
629 for i in $indexes ""; do
630 if test -f "${vi_cv_path_lua_pfx}/${subdir}/liblua${luajit}${sover}$i"; then
Bram Moolenaar768baac2013-04-15 14:44:57 +0200631 sover2="$i"
632 break 3
633 fi
634 done
Bram Moolenaar07e1da62013-02-06 19:49:43 +0100635 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200636 sover=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200637 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200638 if test "X$sover" = "X"; then
639 AC_MSG_RESULT(no)
640 lua_ok="no"
641 vi_cv_dll_name_lua="liblua${luajit}.${ext}"
642 else
643 AC_MSG_RESULT(yes)
644 lua_ok="yes"
645 vi_cv_dll_name_lua="liblua${luajit}${sover}$sover2"
646 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200647 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200648 AC_DEFINE(DYNAMIC_LUA)
649 LUA_LIBS=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200650 LUA_CFLAGS="-DDYNAMIC_LUA_DLL=\\\"${vi_cv_dll_name_lua}\\\" $LUA_CFLAGS"
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200651 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200652 if test "X$LUA_CFLAGS$LUA_LIBS" != "X" && \
653 test "x$MACOSX" = "xyes" && test "x$vi_cv_with_luajit" != "xno" && \
654 test "`(uname -m) 2>/dev/null`" = "x86_64"; then
655 dnl OSX/x64 requires these flags. See http://luajit.org/install.html
656 LUA_LIBS="-pagezero_size 10000 -image_base 100000000 $LUA_LIBS"
657 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200658 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200659 if test "$fail_if_missing" = "yes" -a "$lua_ok" != "yes"; then
Bram Moolenaarf788a062011-12-14 20:51:25 +0100660 AC_MSG_ERROR([could not configure lua])
661 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200662 AC_SUBST(LUA_SRC)
663 AC_SUBST(LUA_OBJ)
664 AC_SUBST(LUA_PRO)
665 AC_SUBST(LUA_LIBS)
666 AC_SUBST(LUA_CFLAGS)
667fi
668
669
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000670dnl Check for MzScheme feature.
671AC_MSG_CHECKING(--enable-mzschemeinterp argument)
672AC_ARG_ENABLE(mzschemeinterp,
673 [ --enable-mzschemeinterp Include MzScheme interpreter.], ,
674 [enable_mzschemeinterp="no"])
675AC_MSG_RESULT($enable_mzschemeinterp)
676
677if test "$enable_mzschemeinterp" = "yes"; then
678 dnl -- find the mzscheme executable
679 AC_SUBST(vi_cv_path_mzscheme)
680
681 AC_MSG_CHECKING(--with-plthome argument)
682 AC_ARG_WITH(plthome,
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000683 [ --with-plthome=PLTHOME Use PLTHOME.],
684 with_plthome="$withval"; AC_MSG_RESULT($with_plthome),
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000685 with_plthome="";AC_MSG_RESULT("no"))
686
687 if test "X$with_plthome" != "X"; then
688 vi_cv_path_mzscheme_pfx="$with_plthome"
689 else
690 AC_MSG_CHECKING(PLTHOME environment var)
691 if test "X$PLTHOME" != "X"; then
692 AC_MSG_RESULT("$PLTHOME")
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000693 vi_cv_path_mzscheme_pfx="$PLTHOME"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000694 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000695 AC_MSG_RESULT(not set)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000696 dnl -- try to find MzScheme executable
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000697 AC_PATH_PROG(vi_cv_path_mzscheme, mzscheme)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000698
699 dnl resolve symbolic link, the executable is often elsewhere and there
700 dnl are no links for the include files.
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000701 if test "X$vi_cv_path_mzscheme" != "X"; then
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000702 lsout=`ls -l $vi_cv_path_mzscheme`
703 if echo "$lsout" | grep -e '->' >/dev/null 2>/dev/null; then
704 vi_cv_path_mzscheme=`echo "$lsout" | sed 's/.*-> \(.*\)/\1/'`
705 fi
706 fi
707
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000708 if test "X$vi_cv_path_mzscheme" != "X"; then
709 dnl -- find where MzScheme thinks it was installed
710 AC_CACHE_CHECK(MzScheme install prefix,vi_cv_path_mzscheme_pfx,
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000711 dnl different versions of MzScheme differ in command line processing
712 dnl use universal approach
713 echo "(display (simplify-path \
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000714 (build-path (call-with-values \
715 (lambda () (split-path (find-system-path (quote exec-file)))) \
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000716 (lambda (base name must-be-dir?) base)) (quote up))))" > mzdirs.scm
717 dnl Remove a trailing slash
718 [ vi_cv_path_mzscheme_pfx=`${vi_cv_path_mzscheme} -r mzdirs.scm | \
719 sed -e 's+/$++'` ])
720 rm -f mzdirs.scm
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000721 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000722 fi
723 fi
724
Bram Moolenaard7afed32007-05-06 13:26:41 +0000725 SCHEME_INC=
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000726 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
727 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include)
728 if test -f $vi_cv_path_mzscheme_pfx/include/scheme.h; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000729 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include
730 AC_MSG_RESULT(yes)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000731 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000732 AC_MSG_RESULT(no)
733 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt)
Bram Moolenaard7afed32007-05-06 13:26:41 +0000734 if test -f $vi_cv_path_mzscheme_pfx/include/plt/scheme.h; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000735 AC_MSG_RESULT(yes)
736 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt
Bram Moolenaard7afed32007-05-06 13:26:41 +0000737 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000738 AC_MSG_RESULT(no)
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100739 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket)
740 if test -f $vi_cv_path_mzscheme_pfx/include/racket/scheme.h; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000741 AC_MSG_RESULT(yes)
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100742 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000743 else
744 AC_MSG_RESULT(no)
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100745 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/)
746 if test -f /usr/include/plt/scheme.h; then
747 AC_MSG_RESULT(yes)
748 SCHEME_INC=/usr/include/plt
749 else
750 AC_MSG_RESULT(no)
751 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/racket/)
752 if test -f /usr/include/racket/scheme.h; then
753 AC_MSG_RESULT(yes)
754 SCHEME_INC=/usr/include/racket
755 else
756 AC_MSG_RESULT(no)
757 vi_cv_path_mzscheme_pfx=
758 fi
759 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000760 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000761 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000762 fi
763 fi
764
765 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaarf15f9432007-06-28 11:07:21 +0000766 if test "x$MACOSX" = "xyes"; then
Bram Moolenaar75676462013-01-30 14:55:42 +0100767 MZSCHEME_LIBS="-framework Racket"
768 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000769 elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"; then
770 MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"
771 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100772 elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket3m.a"; then
773 MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libracket3m.a"
774 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
775 elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket.a"; then
776 MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libracket.a ${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a"
777 elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme.a"; then
Bram Moolenaar9048f942007-05-12 14:32:25 +0000778 MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libmzscheme.a ${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000779 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000780 dnl Using shared objects
781 if test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.so"; then
782 MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lmzscheme3m"
783 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100784 elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket3m.so"; then
785 MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lracket3m"
786 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
787 elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket.so"; then
788 MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lracket -lmzgc"
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000789 else
790 MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lmzscheme -lmzgc"
791 fi
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +0000792 if test "$GCC" = yes; then
793 dnl Make Vim remember the path to the library. For when it's not in
794 dnl $LD_LIBRARY_PATH.
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000795 MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${vi_cv_path_mzscheme_pfx}/lib"
Bram Moolenaar21cf8232004-07-16 20:18:37 +0000796 elif test "`(uname) 2>/dev/null`" = SunOS &&
797 uname -r | grep '^5' >/dev/null; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000798 MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${vi_cv_path_mzscheme_pfx}/lib"
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +0000799 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000800 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100801
802 AC_MSG_CHECKING(for racket collects directory)
Bram Moolenaard7afed32007-05-06 13:26:41 +0000803 if test -d $vi_cv_path_mzscheme_pfx/lib/plt/collects; then
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100804 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/plt/
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100805 else
806 if test -d $vi_cv_path_mzscheme_pfx/lib/racket/collects; then
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100807 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/racket/
808 else
809 if test -d $vi_cv_path_mzscheme_pfx/share/racket/collects; then
810 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/
Bram Moolenaar75676462013-01-30 14:55:42 +0100811 else
812 if test -d $vi_cv_path_mzscheme_pfx/collects; then
813 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/
814 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100815 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100816 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000817 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100818 if test "X$SCHEME_COLLECTS" != "X" ; then
819 AC_MSG_RESULT(${SCHEME_COLLECTS})
820 else
821 AC_MSG_RESULT(not found)
822 fi
823
824 AC_MSG_CHECKING(for mzscheme_base.c)
825 if test -f "${SCHEME_COLLECTS}collects/scheme/base.ss" ; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000826 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +0100827 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
828 MZSCHEME_MOD="++lib scheme/base"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100829 else
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100830 if test -f "${SCHEME_COLLECTS}collects/scheme/base.rkt" ; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100831 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar45e2bcc2014-02-15 17:19:00 +0100832 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
833 MZSCHEME_MOD="++lib scheme/base"
834 else
835 if test -f "${SCHEME_COLLECTS}collects/racket/base.rkt" ; then
836 MZSCHEME_EXTRA="mzscheme_base.c"
837 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/raco ctool"
838 MZSCHEME_MOD=""
839 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100840 fi
841 fi
842 if test "X$MZSCHEME_EXTRA" != "X" ; then
843 dnl need to generate bytecode for MzScheme base
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000844 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE"
845 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100846 AC_MSG_RESULT(needed)
847 else
848 AC_MSG_RESULT(not needed)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000849 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100850
Bram Moolenaar9e902192013-07-17 18:58:11 +0200851 dnl On Ubuntu this fixes "undefined reference to symbol 'ffi_type_void'".
852 AC_CHECK_LIB(ffi, ffi_type_void, [MZSCHEME_LIBS="$MZSCHEME_LIBS -lffi"])
853
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000854 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -I${SCHEME_INC} \
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100855 -DMZSCHEME_COLLECTS='\"${SCHEME_COLLECTS}collects\"'"
Bram Moolenaar9e902192013-07-17 18:58:11 +0200856
857 dnl Test that we can compile a simple program with these CFLAGS and LIBS.
858 AC_MSG_CHECKING([if compile and link flags for MzScheme are sane])
859 cflags_save=$CFLAGS
860 libs_save=$LIBS
861 CFLAGS="$CFLAGS $MZSCHEME_CFLAGS"
862 LIBS="$LIBS $MZSCHEME_LIBS"
863 AC_TRY_LINK(,[ ],
864 AC_MSG_RESULT(yes); mzs_ok=yes,
865 AC_MSG_RESULT(no: MZSCHEME DISABLED); mzs_ok=no)
866 CFLAGS=$cflags_save
867 LIBS=$libs_save
868 if test $mzs_ok = yes; then
869 MZSCHEME_SRC="if_mzsch.c"
870 MZSCHEME_OBJ="objects/if_mzsch.o"
871 MZSCHEME_PRO="if_mzsch.pro"
872 AC_DEFINE(FEAT_MZSCHEME)
873 else
874 MZSCHEME_CFLAGS=
875 MZSCHEME_LIBS=
876 MZSCHEME_EXTRA=
877 MZSCHEME_MZC=
878 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000879 fi
880 AC_SUBST(MZSCHEME_SRC)
881 AC_SUBST(MZSCHEME_OBJ)
882 AC_SUBST(MZSCHEME_PRO)
883 AC_SUBST(MZSCHEME_LIBS)
884 AC_SUBST(MZSCHEME_CFLAGS)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000885 AC_SUBST(MZSCHEME_EXTRA)
886 AC_SUBST(MZSCHEME_MZC)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000887fi
888
889
Bram Moolenaar071d4272004-06-13 20:20:40 +0000890AC_MSG_CHECKING(--enable-perlinterp argument)
891AC_ARG_ENABLE(perlinterp,
Bram Moolenaare06c1882010-07-21 22:05:20 +0200892 [ --enable-perlinterp[=OPTS] Include Perl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000893 [enable_perlinterp="no"])
894AC_MSG_RESULT($enable_perlinterp)
Bram Moolenaare06c1882010-07-21 22:05:20 +0200895if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000896 AC_SUBST(vi_cv_path_perl)
897 AC_PATH_PROG(vi_cv_path_perl, perl)
898 if test "X$vi_cv_path_perl" != "X"; then
899 AC_MSG_CHECKING(Perl version)
900 if $vi_cv_path_perl -e 'require 5.003_01' >/dev/null 2>/dev/null; then
901 eval `$vi_cv_path_perl -V:usethreads`
Bram Moolenaare06c1882010-07-21 22:05:20 +0200902 eval `$vi_cv_path_perl -V:libperl`
Bram Moolenaar071d4272004-06-13 20:20:40 +0000903 if test "X$usethreads" = "XUNKNOWN" -o "X$usethreads" = "Xundef"; then
904 badthreads=no
905 else
906 if $vi_cv_path_perl -e 'require 5.6.0' >/dev/null 2>/dev/null; then
907 eval `$vi_cv_path_perl -V:use5005threads`
908 if test "X$use5005threads" = "XUNKNOWN" -o "X$use5005threads" = "Xundef"; then
909 badthreads=no
910 else
911 badthreads=yes
912 AC_MSG_RESULT(>>> Perl > 5.6 with 5.5 threads cannot be used <<<)
913 fi
914 else
915 badthreads=yes
916 AC_MSG_RESULT(>>> Perl 5.5 with threads cannot be used <<<)
917 fi
918 fi
919 if test $badthreads = no; then
920 AC_MSG_RESULT(OK)
921 eval `$vi_cv_path_perl -V:shrpenv`
922 if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04
923 shrpenv=""
924 fi
925 vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlibexp}'`
926 AC_SUBST(vi_cv_perllib)
927 dnl Remove "-fno-something", it breaks using cproto.
928 perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
929 -e 'ccflags;perl_inc;print"\n"' | sed -e 's/-fno[[^ ]]*//'`
930 dnl Remove "-lc", it breaks on FreeBSD when using "-pthread".
931 perllibs=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed -e 'ldopts' | \
932 sed -e '/Warning/d' -e '/Note (probably harmless)/d' \
933 -e 's/-bE:perl.exp//' -e 's/-lc //'`
934 dnl Don't add perl lib to $LIBS: if it's not in LD_LIBRARY_PATH
935 dnl a test in configure may fail because of that.
936 perlldflags=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed \
937 -e 'ccdlflags' | sed -e 's/-bE:perl.exp//'`
938
939 dnl check that compiling a simple program still works with the flags
940 dnl added for Perl.
941 AC_MSG_CHECKING([if compile and link flags for Perl are sane])
942 cflags_save=$CFLAGS
943 libs_save=$LIBS
944 ldflags_save=$LDFLAGS
945 CFLAGS="$CFLAGS $perlcppflags"
946 LIBS="$LIBS $perllibs"
Bram Moolenaara6cc0312013-06-18 23:31:55 +0200947 perlldflags=`echo "$perlldflags" | sed -e 's/^ *//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +0000948 LDFLAGS="$perlldflags $LDFLAGS"
949 AC_TRY_LINK(,[ ],
950 AC_MSG_RESULT(yes); perl_ok=yes,
951 AC_MSG_RESULT(no: PERL DISABLED); perl_ok=no)
952 CFLAGS=$cflags_save
953 LIBS=$libs_save
954 LDFLAGS=$ldflags_save
955 if test $perl_ok = yes; then
956 if test "X$perlcppflags" != "X"; then
Bram Moolenaard7afed32007-05-06 13:26:41 +0000957 dnl remove -pipe and -Wxxx, it confuses cproto
958 PERL_CFLAGS=`echo "$perlcppflags" | sed -e 's/-pipe //' -e 's/-W[[^ ]]*//'`
Bram Moolenaar071d4272004-06-13 20:20:40 +0000959 fi
960 if test "X$perlldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +0100961 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$perlldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +0200962 LDFLAGS="$perlldflags $LDFLAGS"
963 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000964 fi
965 PERL_LIBS=$perllibs
966 PERL_SRC="auto/if_perl.c if_perlsfio.c"
967 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o"
968 PERL_PRO="if_perl.pro if_perlsfio.pro"
969 AC_DEFINE(FEAT_PERL)
970 fi
971 fi
972 else
973 AC_MSG_RESULT(>>> too old; need Perl version 5.003_01 or later <<<)
974 fi
975 fi
976
977 if test "x$MACOSX" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +0000978 dnl Mac OS X 10.2 or later
Bram Moolenaar071d4272004-06-13 20:20:40 +0000979 dir=/System/Library/Perl
980 darwindir=$dir/darwin
981 if test -d $darwindir; then
982 PERL=/usr/bin/perl
983 else
984 dnl Mac OS X 10.3
985 dir=/System/Library/Perl/5.8.1
986 darwindir=$dir/darwin-thread-multi-2level
987 if test -d $darwindir; then
988 PERL=/usr/bin/perl
989 fi
990 fi
991 if test -n "$PERL"; then
992 PERL_DIR="$dir"
993 PERL_CFLAGS="-DFEAT_PERL -I$darwindir/CORE"
994 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o $darwindir/auto/DynaLoader/DynaLoader.a"
995 PERL_LIBS="-L$darwindir/CORE -lperl"
996 fi
Bram Moolenaar5dff57d2010-07-24 16:19:44 +0200997 dnl Perl on Mac OS X 10.5 adds "-arch" flags but these should only
998 dnl be included if requested by passing --with-mac-arch to
999 dnl configure, so strip these flags first (if present)
1000 PERL_LIBS=`echo "$PERL_LIBS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
1001 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 +00001002 fi
Bram Moolenaare06c1882010-07-21 22:05:20 +02001003 if test "$enable_perlinterp" = "dynamic"; then
1004 if test "$perl_ok" = "yes" -a "X$libperl" != "X"; then
1005 AC_DEFINE(DYNAMIC_PERL)
1006 PERL_CFLAGS="-DDYNAMIC_PERL_DLL=\\\"$libperl\\\" $PERL_CFLAGS"
1007 fi
1008 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001009
1010 if test "$fail_if_missing" = "yes" -a "$perl_ok" != "yes"; then
1011 AC_MSG_ERROR([could not configure perl])
1012 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001013fi
1014AC_SUBST(shrpenv)
1015AC_SUBST(PERL_SRC)
1016AC_SUBST(PERL_OBJ)
1017AC_SUBST(PERL_PRO)
1018AC_SUBST(PERL_CFLAGS)
1019AC_SUBST(PERL_LIBS)
1020
1021AC_MSG_CHECKING(--enable-pythoninterp argument)
1022AC_ARG_ENABLE(pythoninterp,
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001023 [ --enable-pythoninterp[=OPTS] Include Python interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001024 [enable_pythoninterp="no"])
1025AC_MSG_RESULT($enable_pythoninterp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001026if test "$enable_pythoninterp" = "yes" -o "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001027 dnl -- find the python executable
Bram Moolenaar09ba6d72012-12-12 14:25:05 +01001028 AC_PATH_PROGS(vi_cv_path_python, python2 python)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001029 if test "X$vi_cv_path_python" != "X"; then
1030
1031 dnl -- get its version number
1032 AC_CACHE_CHECK(Python version,vi_cv_var_python_version,
1033 [[vi_cv_var_python_version=`
1034 ${vi_cv_path_python} -c 'import sys; print sys.version[:3]'`
1035 ]])
1036
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001037 dnl -- it must be at least version 2.3
1038 AC_MSG_CHECKING(Python is 2.3 or better)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001039 if ${vi_cv_path_python} -c \
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001040 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001041 then
1042 AC_MSG_RESULT(yep)
1043
1044 dnl -- find where python thinks it was installed
1045 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python_pfx,
1046 [ vi_cv_path_python_pfx=`
1047 ${vi_cv_path_python} -c \
1048 "import sys; print sys.prefix"` ])
1049
1050 dnl -- and where it thinks it runs
1051 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python_epfx,
1052 [ vi_cv_path_python_epfx=`
1053 ${vi_cv_path_python} -c \
1054 "import sys; print sys.exec_prefix"` ])
1055
1056 dnl -- python's internal library path
1057
1058 AC_CACHE_VAL(vi_cv_path_pythonpath,
1059 [ vi_cv_path_pythonpath=`
1060 unset PYTHONPATH;
1061 ${vi_cv_path_python} -c \
1062 "import sys, string; print string.join(sys.path,':')"` ])
1063
1064 dnl -- where the Python implementation library archives are
1065
1066 AC_ARG_WITH(python-config-dir,
1067 [ --with-python-config-dir=PATH Python's config directory],
1068 [ vi_cv_path_python_conf="${withval}" ] )
1069
1070 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python_conf,
1071 [
1072 vi_cv_path_python_conf=
Bram Moolenaarac499e32013-06-02 19:14:17 +02001073 d=`${vi_cv_path_python} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBPL')"`
1074 if test -d "$d" && test -f "$d/config.c"; then
1075 vi_cv_path_python_conf="$d"
1076 else
1077 for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
1078 for subdir in lib64 lib share; do
1079 d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
1080 if test -d "$d" && test -f "$d/config.c"; then
1081 vi_cv_path_python_conf="$d"
1082 fi
1083 done
Bram Moolenaar071d4272004-06-13 20:20:40 +00001084 done
Bram Moolenaarac499e32013-06-02 19:14:17 +02001085 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001086 ])
1087
1088 PYTHON_CONFDIR="${vi_cv_path_python_conf}"
1089
1090 if test "X$PYTHON_CONFDIR" = "X"; then
1091 AC_MSG_RESULT([can't find it!])
1092 else
1093
1094 dnl -- we need to examine Python's config/Makefile too
1095 dnl see what the interpreter is built from
1096 AC_CACHE_VAL(vi_cv_path_python_plibs,
1097 [
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001098 pwd=`pwd`
1099 tmp_mkf="$pwd/config-PyMake$$"
1100 cat -- "${PYTHON_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001101__:
Bram Moolenaar218116c2010-05-20 21:46:00 +02001102 @echo "python_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001103 @echo "python_LIBS='$(LIBS)'"
1104 @echo "python_SYSLIBS='$(SYSLIBS)'"
1105 @echo "python_LINKFORSHARED='$(LINKFORSHARED)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001106 @echo "python_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001107 @echo "python_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001108eof
1109 dnl -- delete the lines from make about Entering/Leaving directory
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001110 eval "`cd ${PYTHON_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1111 rm -f -- "${tmp_mkf}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001112 if test "x$MACOSX" = "xyes" && ${vi_cv_path_python} -c \
1113 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then
1114 vi_cv_path_python_plibs="-framework Python"
1115 else
1116 if test "${vi_cv_var_python_version}" = "1.4"; then
1117 vi_cv_path_python_plibs="${PYTHON_CONFDIR}/libModules.a ${PYTHON_CONFDIR}/libPython.a ${PYTHON_CONFDIR}/libObjects.a ${PYTHON_CONFDIR}/libParser.a"
1118 else
1119 vi_cv_path_python_plibs="-L${PYTHON_CONFDIR} -lpython${vi_cv_var_python_version}"
1120 fi
Bram Moolenaar218116c2010-05-20 21:46:00 +02001121 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 +00001122 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1123 vi_cv_path_python_plibs=`echo $vi_cv_path_python_plibs | sed s/-ltermcap//`
1124 fi
1125 ])
1126
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001127 if test "X$python_DLLLIBRARY" != "X"; then
1128 python_INSTSONAME="$python_DLLLIBRARY"
1129 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001130 PYTHON_LIBS="${vi_cv_path_python_plibs}"
1131 if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
Bram Moolenaar780c3e92013-06-11 20:53:28 +02001132 PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001133 else
Bram Moolenaar780c3e92013-06-11 20:53:28 +02001134 PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -I${vi_cv_path_python_epfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001135 fi
1136 PYTHON_SRC="if_python.c"
Bram Moolenaar9bdb9a02012-07-25 16:32:08 +02001137 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001138 if test "${vi_cv_var_python_version}" = "1.4"; then
1139 PYTHON_OBJ="$PYTHON_OBJ objects/py_getpath.o"
1140 fi
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001141 PYTHON_GETPATH_CFLAGS="-DPYTHONPATH='\"${vi_cv_path_pythonpath}\"' -DPREFIX='\"${vi_cv_path_python_pfx}\"' -DEXEC_PREFIX='\"${vi_cv_path_python_epfx}\"'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001142
1143 dnl On FreeBSD linking with "-pthread" is required to use threads.
1144 dnl _THREAD_SAFE must be used for compiling then.
1145 dnl The "-pthread" is added to $LIBS, so that the following check for
1146 dnl sigaltstack() will look in libc_r (it's there in libc!).
1147 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1148 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1149 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1150 AC_MSG_CHECKING([if -pthread should be used])
1151 threadsafe_flag=
1152 thread_lib=
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00001153 dnl if test "x$MACOSX" != "xyes"; then
1154 if test "`(uname) 2>/dev/null`" != Darwin; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001155 test "$GCC" = yes && threadsafe_flag="-pthread"
1156 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1157 threadsafe_flag="-D_THREAD_SAFE"
1158 thread_lib="-pthread"
1159 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001160 if test "`(uname) 2>/dev/null`" = SunOS; then
1161 threadsafe_flag="-pthreads"
1162 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001163 fi
1164 libs_save_old=$LIBS
1165 if test -n "$threadsafe_flag"; then
1166 cflags_save=$CFLAGS
1167 CFLAGS="$CFLAGS $threadsafe_flag"
1168 LIBS="$LIBS $thread_lib"
1169 AC_TRY_LINK(,[ ],
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001170 AC_MSG_RESULT(yes); PYTHON_CFLAGS="$PYTHON_CFLAGS $threadsafe_flag",
Bram Moolenaar071d4272004-06-13 20:20:40 +00001171 AC_MSG_RESULT(no); LIBS=$libs_save_old
1172 )
1173 CFLAGS=$cflags_save
1174 else
1175 AC_MSG_RESULT(no)
1176 fi
1177
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001178 dnl Check that compiling a simple program still works with the flags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001179 dnl added for Python.
1180 AC_MSG_CHECKING([if compile and link flags for Python are sane])
1181 cflags_save=$CFLAGS
1182 libs_save=$LIBS
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001183 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001184 LIBS="$LIBS $PYTHON_LIBS"
1185 AC_TRY_LINK(,[ ],
1186 AC_MSG_RESULT(yes); python_ok=yes,
1187 AC_MSG_RESULT(no: PYTHON DISABLED); python_ok=no)
1188 CFLAGS=$cflags_save
1189 LIBS=$libs_save
1190 if test $python_ok = yes; then
1191 AC_DEFINE(FEAT_PYTHON)
1192 else
1193 LIBS=$libs_save_old
1194 PYTHON_SRC=
1195 PYTHON_OBJ=
1196 PYTHON_LIBS=
1197 PYTHON_CFLAGS=
1198 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001199 fi
1200 else
1201 AC_MSG_RESULT(too old)
1202 fi
1203 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001204
1205 if test "$fail_if_missing" = "yes" -a "$python_ok" != "yes"; then
1206 AC_MSG_ERROR([could not configure python])
1207 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001208fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001209
Bram Moolenaar071d4272004-06-13 20:20:40 +00001210AC_SUBST(PYTHON_CONFDIR)
1211AC_SUBST(PYTHON_LIBS)
1212AC_SUBST(PYTHON_GETPATH_CFLAGS)
1213AC_SUBST(PYTHON_CFLAGS)
1214AC_SUBST(PYTHON_SRC)
1215AC_SUBST(PYTHON_OBJ)
1216
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001217
1218AC_MSG_CHECKING(--enable-python3interp argument)
1219AC_ARG_ENABLE(python3interp,
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001220 [ --enable-python3interp[=OPTS] Include Python3 interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001221 [enable_python3interp="no"])
1222AC_MSG_RESULT($enable_python3interp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001223if test "$enable_python3interp" = "yes" -o "$enable_python3interp" = "dynamic"; then
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001224 dnl -- find the python3 executable
Bram Moolenaar09ba6d72012-12-12 14:25:05 +01001225 AC_PATH_PROGS(vi_cv_path_python3, python3 python)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001226 if test "X$vi_cv_path_python3" != "X"; then
1227
1228 dnl -- get its version number
1229 AC_CACHE_CHECK(Python version,vi_cv_var_python3_version,
1230 [[vi_cv_var_python3_version=`
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001231 ${vi_cv_path_python3} -c 'import sys; print(sys.version[:3])'`
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001232 ]])
1233
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001234 dnl -- it must be at least version 3
1235 AC_MSG_CHECKING(Python is 3.0 or better)
1236 if ${vi_cv_path_python3} -c \
1237 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.0)"
1238 then
1239 AC_MSG_RESULT(yep)
Bram Moolenaar456f2bb2011-06-12 21:37:13 +02001240
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001241 dnl -- get abiflags for python 3.2 or higher (PEP 3149)
1242 AC_CACHE_CHECK(Python's abiflags,vi_cv_var_python3_abiflags,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001243 [
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001244 vi_cv_var_python3_abiflags=
1245 if ${vi_cv_path_python3} -c \
1246 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)"
1247 then
1248 vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \
1249 "import sys; print(sys.abiflags)"`
1250 fi ])
1251
1252 dnl -- find where python3 thinks it was installed
1253 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx,
1254 [ vi_cv_path_python3_pfx=`
1255 ${vi_cv_path_python3} -c \
1256 "import sys; print(sys.prefix)"` ])
1257
1258 dnl -- and where it thinks it runs
1259 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx,
1260 [ vi_cv_path_python3_epfx=`
1261 ${vi_cv_path_python3} -c \
1262 "import sys; print(sys.exec_prefix)"` ])
1263
1264 dnl -- python3's internal library path
1265
1266 AC_CACHE_VAL(vi_cv_path_python3path,
1267 [ vi_cv_path_python3path=`
1268 unset PYTHONPATH;
1269 ${vi_cv_path_python3} -c \
1270 "import sys, string; print(':'.join(sys.path))"` ])
1271
1272 dnl -- where the Python implementation library archives are
1273
1274 AC_ARG_WITH(python3-config-dir,
1275 [ --with-python3-config-dir=PATH Python's config directory],
1276 [ vi_cv_path_python3_conf="${withval}" ] )
1277
1278 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf,
1279 [
1280 vi_cv_path_python3_conf=
Bram Moolenaarfee496d2013-07-12 20:07:24 +02001281 config_dir="config-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001282 d=`${vi_cv_path_python3} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBPL'))"`
1283 if test -d "$d" && test -f "$d/config.c"; then
1284 vi_cv_path_python3_conf="$d"
1285 else
1286 for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do
1287 for subdir in lib64 lib share; do
1288 d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}"
1289 if test -d "$d" && test -f "$d/config.c"; then
1290 vi_cv_path_python3_conf="$d"
1291 fi
1292 done
1293 done
1294 fi
1295 ])
1296
1297 PYTHON3_CONFDIR="${vi_cv_path_python3_conf}"
1298
1299 if test "X$PYTHON3_CONFDIR" = "X"; then
1300 AC_MSG_RESULT([can't find it!])
1301 else
1302
1303 dnl -- we need to examine Python's config/Makefile too
1304 dnl see what the interpreter is built from
1305 AC_CACHE_VAL(vi_cv_path_python3_plibs,
1306 [
1307 pwd=`pwd`
1308 tmp_mkf="$pwd/config-PyMake$$"
1309 cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001310__:
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001311 @echo "python3_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001312 @echo "python3_LIBS='$(LIBS)'"
1313 @echo "python3_SYSLIBS='$(SYSLIBS)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001314 @echo "python3_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001315 @echo "python3_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001316eof
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001317 dnl -- delete the lines from make about Entering/Leaving directory
1318 eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1319 rm -f -- "${tmp_mkf}"
1320 vi_cv_path_python3_plibs="-L${PYTHON3_CONFDIR} -lpython${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
1321 vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}"
1322 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1323 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//`
1324 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//`
1325 ])
1326
1327 if test "X$python3_DLLLIBRARY" != "X"; then
1328 python3_INSTSONAME="$python3_DLLLIBRARY"
1329 fi
1330 PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
1331 if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
Bram Moolenaar780c3e92013-06-11 20:53:28 +02001332 PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -DPYTHON3_HOME='L\"${vi_cv_path_python3_pfx}\"'"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001333 else
Bram Moolenaar780c3e92013-06-11 20:53:28 +02001334 PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -I${vi_cv_path_python3_epfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -DPYTHON3_HOME='L\"${vi_cv_path_python3_pfx}\"'"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001335 fi
1336 PYTHON3_SRC="if_python3.c"
1337 PYTHON3_OBJ="objects/if_python3.o"
1338
1339 dnl On FreeBSD linking with "-pthread" is required to use threads.
1340 dnl _THREAD_SAFE must be used for compiling then.
1341 dnl The "-pthread" is added to $LIBS, so that the following check for
1342 dnl sigaltstack() will look in libc_r (it's there in libc!).
1343 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1344 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1345 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1346 AC_MSG_CHECKING([if -pthread should be used])
1347 threadsafe_flag=
1348 thread_lib=
1349 dnl if test "x$MACOSX" != "xyes"; then
1350 if test "`(uname) 2>/dev/null`" != Darwin; then
1351 test "$GCC" = yes && threadsafe_flag="-pthread"
1352 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1353 threadsafe_flag="-D_THREAD_SAFE"
1354 thread_lib="-pthread"
1355 fi
1356 if test "`(uname) 2>/dev/null`" = SunOS; then
1357 threadsafe_flag="-pthreads"
1358 fi
1359 fi
1360 libs_save_old=$LIBS
1361 if test -n "$threadsafe_flag"; then
1362 cflags_save=$CFLAGS
1363 CFLAGS="$CFLAGS $threadsafe_flag"
1364 LIBS="$LIBS $thread_lib"
1365 AC_TRY_LINK(,[ ],
1366 AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag",
1367 AC_MSG_RESULT(no); LIBS=$libs_save_old
1368 )
1369 CFLAGS=$cflags_save
1370 else
1371 AC_MSG_RESULT(no)
1372 fi
1373
1374 dnl check that compiling a simple program still works with the flags
1375 dnl added for Python.
1376 AC_MSG_CHECKING([if compile and link flags for Python 3 are sane])
1377 cflags_save=$CFLAGS
1378 libs_save=$LIBS
1379 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1380 LIBS="$LIBS $PYTHON3_LIBS"
1381 AC_TRY_LINK(,[ ],
1382 AC_MSG_RESULT(yes); python3_ok=yes,
1383 AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no)
1384 CFLAGS=$cflags_save
1385 LIBS=$libs_save
1386 if test "$python3_ok" = yes; then
1387 AC_DEFINE(FEAT_PYTHON3)
1388 else
1389 LIBS=$libs_save_old
1390 PYTHON3_SRC=
1391 PYTHON3_OBJ=
1392 PYTHON3_LIBS=
1393 PYTHON3_CFLAGS=
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001394 fi
1395 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001396 else
1397 AC_MSG_RESULT(too old)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001398 fi
1399 fi
Bram Moolenaar1612b1a2013-06-14 21:22:39 +02001400 if test "$fail_if_missing" = "yes" -a "$python3_ok" != "yes"; then
1401 AC_MSG_ERROR([could not configure python3])
1402 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001403fi
1404
1405AC_SUBST(PYTHON3_CONFDIR)
1406AC_SUBST(PYTHON3_LIBS)
1407AC_SUBST(PYTHON3_CFLAGS)
1408AC_SUBST(PYTHON3_SRC)
1409AC_SUBST(PYTHON3_OBJ)
1410
1411dnl if python2.x and python3.x are enabled one can only link in code
1412dnl with dlopen(), dlsym(), dlclose()
1413if test "$python_ok" = yes && test "$python3_ok" = yes; then
1414 AC_DEFINE(DYNAMIC_PYTHON)
1415 AC_DEFINE(DYNAMIC_PYTHON3)
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001416 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001417 cflags_save=$CFLAGS
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001418 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001419 ldflags_save=$LDFLAGS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001420 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
1421 LDFLAGS="-ldl $LDFLAGS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001422 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001423 #include <dlfcn.h>
1424 /* If this program fails, then RTLD_GLOBAL is needed.
1425 * RTLD_GLOBAL will be used and then it is not possible to
1426 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001427 * Only the first python version used will be switched on.
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001428 */
1429
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001430 int no_rtl_global_needed_for(char *python_instsoname, char *prefix)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001431 {
1432 int needed = 0;
1433 void* pylib = dlopen(python_instsoname, RTLD_LAZY);
1434 if (pylib != 0)
1435 {
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001436 void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome");
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001437 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1438 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1439 void (*final)(void) = dlsym(pylib, "Py_Finalize");
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001440 (*pfx)(prefix);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001441 (*init)();
1442 needed = (*simple)("import termios") == -1;
1443 (*final)();
1444 dlclose(pylib);
1445 }
1446 return !needed;
1447 }
1448
1449 int main(int argc, char** argv)
1450 {
1451 int not_needed = 0;
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001452 if (no_rtl_global_needed_for("${python_INSTSONAME}", "${vi_cv_path_python_pfx}"))
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001453 not_needed = 1;
1454 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001455 }])],
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001456 [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001457
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001458 CFLAGS=$cflags_save
1459 LDFLAGS=$ldflags_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001460
1461 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python3)
1462 cflags_save=$CFLAGS
1463 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1464 ldflags_save=$LDFLAGS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001465 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
1466 LDFLAGS="-ldl $LDFLAGS"
Bram Moolenaar7db77842014-03-27 17:40:59 +01001467 AC_RUN_IFELSE([AC_LANG_SOURCE([
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001468 #include <dlfcn.h>
1469 #include <wchar.h>
1470 /* If this program fails, then RTLD_GLOBAL is needed.
1471 * RTLD_GLOBAL will be used and then it is not possible to
1472 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001473 * Only the first python version used will be switched on.
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001474 */
1475
1476 int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix)
1477 {
1478 int needed = 0;
1479 void* pylib = dlopen(python_instsoname, RTLD_LAZY);
1480 if (pylib != 0)
1481 {
1482 void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome");
1483 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1484 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1485 void (*final)(void) = dlsym(pylib, "Py_Finalize");
1486 (*pfx)(prefix);
1487 (*init)();
1488 needed = (*simple)("import termios") == -1;
1489 (*final)();
1490 dlclose(pylib);
1491 }
1492 return !needed;
1493 }
1494
1495 int main(int argc, char** argv)
1496 {
1497 int not_needed = 0;
1498 if (no_rtl_global_needed_for("${python3_INSTSONAME}", L"${vi_cv_path_python3_pfx}"))
1499 not_needed = 1;
1500 return !not_needed;
Bram Moolenaar7db77842014-03-27 17:40:59 +01001501 }])],
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001502 [AC_MSG_RESULT(yes);AC_DEFINE(PY3_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
1503
1504 CFLAGS=$cflags_save
1505 LDFLAGS=$ldflags_save
1506
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001507 PYTHON_SRC="if_python.c"
1508 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001509 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${python_INSTSONAME}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001510 PYTHON_LIBS=
1511 PYTHON3_SRC="if_python3.c"
1512 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001513 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${python3_INSTSONAME}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001514 PYTHON3_LIBS=
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001515elif test "$python_ok" = yes && test "$enable_pythoninterp" = "dynamic"; then
1516 AC_DEFINE(DYNAMIC_PYTHON)
1517 PYTHON_SRC="if_python.c"
1518 PYTHON_OBJ="objects/if_python.o"
1519 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${python_INSTSONAME}\\\""
1520 PYTHON_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001521elif test "$python_ok" = yes; then
1522 dnl Check that adding -fPIE works. It may be needed when using a static
1523 dnl Python library.
1524 AC_MSG_CHECKING([if -fPIE can be added for Python])
1525 cflags_save=$CFLAGS
1526 libs_save=$LIBS
1527 CFLAGS="$CFLAGS $PYTHON_CFLAGS -fPIE"
1528 LIBS="$LIBS $PYTHON_LIBS"
1529 AC_TRY_LINK(,[ ],
1530 AC_MSG_RESULT(yes); fpie_ok=yes,
1531 AC_MSG_RESULT(no); fpie_ok=no)
1532 CFLAGS=$cflags_save
1533 LIBS=$libs_save
1534 if test $fpie_ok = yes; then
1535 PYTHON_CFLAGS="$PYTHON_CFLAGS -fPIE"
1536 fi
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001537elif test "$python3_ok" = yes && test "$enable_python3interp" = "dynamic"; then
1538 AC_DEFINE(DYNAMIC_PYTHON3)
1539 PYTHON3_SRC="if_python3.c"
1540 PYTHON3_OBJ="objects/if_python3.o"
1541 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${python3_INSTSONAME}\\\""
1542 PYTHON3_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001543elif test "$python3_ok" = yes; then
1544 dnl Check that adding -fPIE works. It may be needed when using a static
1545 dnl Python library.
1546 AC_MSG_CHECKING([if -fPIE can be added for Python3])
1547 cflags_save=$CFLAGS
1548 libs_save=$LIBS
1549 CFLAGS="$CFLAGS $PYTHON3_CFLAGS -fPIE"
1550 LIBS="$LIBS $PYTHON3_LIBS"
1551 AC_TRY_LINK(,[ ],
1552 AC_MSG_RESULT(yes); fpie_ok=yes,
1553 AC_MSG_RESULT(no); fpie_ok=no)
1554 CFLAGS=$cflags_save
1555 LIBS=$libs_save
1556 if test $fpie_ok = yes; then
1557 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -fPIE"
1558 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001559fi
1560
Bram Moolenaar071d4272004-06-13 20:20:40 +00001561AC_MSG_CHECKING(--enable-tclinterp argument)
1562AC_ARG_ENABLE(tclinterp,
1563 [ --enable-tclinterp Include Tcl interpreter.], ,
1564 [enable_tclinterp="no"])
1565AC_MSG_RESULT($enable_tclinterp)
1566
1567if test "$enable_tclinterp" = "yes"; then
1568
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001569 dnl on FreeBSD tclsh is a silly script, look for tclsh8.[5420]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001570 AC_MSG_CHECKING(--with-tclsh argument)
1571 AC_ARG_WITH(tclsh, [ --with-tclsh=PATH which tclsh to use (default: tclsh8.0)],
1572 tclsh_name="$withval"; AC_MSG_RESULT($tclsh_name),
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001573 tclsh_name="tclsh8.5"; AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00001574 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1575 AC_SUBST(vi_cv_path_tcl)
1576
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001577 dnl when no specific version specified, also try 8.4, 8.2 and 8.0
1578 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.5"; then
1579 tclsh_name="tclsh8.4"
1580 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1581 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001582 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.4"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001583 tclsh_name="tclsh8.2"
1584 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1585 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001586 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.2"; then
1587 tclsh_name="tclsh8.0"
1588 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1589 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001590 dnl still didn't find it, try without version number
1591 if test "X$vi_cv_path_tcl" = "X"; then
1592 tclsh_name="tclsh"
1593 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1594 fi
1595 if test "X$vi_cv_path_tcl" != "X"; then
1596 AC_MSG_CHECKING(Tcl version)
1597 if echo 'exit [[expr [info tclversion] < 8.0]]' | $vi_cv_path_tcl - ; then
1598 tclver=`echo 'puts [[info tclversion]]' | $vi_cv_path_tcl -`
1599 AC_MSG_RESULT($tclver - OK);
1600 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 -`
1601
1602 AC_MSG_CHECKING(for location of Tcl include)
1603 if test "x$MACOSX" != "xyes"; then
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001604 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 +00001605 else
1606 dnl For Mac OS X 10.3, use the OS-provided framework location
1607 tclinc="/System/Library/Frameworks/Tcl.framework/Headers"
1608 fi
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001609 TCL_INC=
Bram Moolenaar071d4272004-06-13 20:20:40 +00001610 for try in $tclinc; do
1611 if test -f "$try/tcl.h"; then
1612 AC_MSG_RESULT($try/tcl.h)
1613 TCL_INC=$try
1614 break
1615 fi
1616 done
1617 if test -z "$TCL_INC"; then
1618 AC_MSG_RESULT(<not found>)
1619 SKIP_TCL=YES
1620 fi
1621 if test -z "$SKIP_TCL"; then
1622 AC_MSG_CHECKING(for location of tclConfig.sh script)
1623 if test "x$MACOSX" != "xyes"; then
1624 tclcnf=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001625 tclcnf="$tclcnf `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001626 else
1627 dnl For Mac OS X 10.3, use the OS-provided framework location
1628 tclcnf="/System/Library/Frameworks/Tcl.framework"
1629 fi
1630 for try in $tclcnf; do
1631 if test -f $try/tclConfig.sh; then
1632 AC_MSG_RESULT($try/tclConfig.sh)
1633 . $try/tclConfig.sh
1634 dnl use eval, because tcl 8.2 includes ${TCL_DBGX}
1635 TCL_LIBS=`eval echo "$TCL_LIB_SPEC $TCL_LIBS"`
1636 dnl Use $TCL_DEFS for -D_THREAD_SAFE et al. But only use the
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001637 dnl "-D_ABC" items. Watch out for -DFOO=long\ long.
Bram Moolenaar4394bff2008-07-24 11:21:31 +00001638 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 +00001639 break
1640 fi
1641 done
1642 if test -z "$TCL_LIBS"; then
1643 AC_MSG_RESULT(<not found>)
1644 AC_MSG_CHECKING(for Tcl library by myself)
1645 tcllib=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001646 tcllib="$tcllib `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001647 for ext in .so .a ; do
1648 for ver in "" $tclver ; do
1649 for try in $tcllib ; do
1650 trylib=tcl$ver$ext
1651 if test -f $try/lib$trylib ; then
1652 AC_MSG_RESULT($try/lib$trylib)
1653 TCL_LIBS="-L$try -ltcl$ver -ldl -lm"
1654 if test "`(uname) 2>/dev/null`" = SunOS &&
1655 uname -r | grep '^5' >/dev/null; then
1656 TCL_LIBS="$TCL_LIBS -R $try"
1657 fi
1658 break 3
1659 fi
1660 done
1661 done
1662 done
1663 if test -z "$TCL_LIBS"; then
1664 AC_MSG_RESULT(<not found>)
1665 SKIP_TCL=YES
1666 fi
1667 fi
1668 if test -z "$SKIP_TCL"; then
1669 AC_DEFINE(FEAT_TCL)
1670 TCL_SRC=if_tcl.c
1671 TCL_OBJ=objects/if_tcl.o
1672 TCL_PRO=if_tcl.pro
1673 TCL_CFLAGS="-I$TCL_INC $TCL_DEFS"
1674 fi
1675 fi
1676 else
1677 AC_MSG_RESULT(too old; need Tcl version 8.0 or later)
1678 fi
1679 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001680 if test "$fail_if_missing" = "yes" -a -z "$TCL_SRC"; then
1681 AC_MSG_ERROR([could not configure Tcl])
1682 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001683fi
1684AC_SUBST(TCL_SRC)
1685AC_SUBST(TCL_OBJ)
1686AC_SUBST(TCL_PRO)
1687AC_SUBST(TCL_CFLAGS)
1688AC_SUBST(TCL_LIBS)
1689
1690AC_MSG_CHECKING(--enable-rubyinterp argument)
1691AC_ARG_ENABLE(rubyinterp,
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001692 [ --enable-rubyinterp[=OPTS] Include Ruby interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001693 [enable_rubyinterp="no"])
1694AC_MSG_RESULT($enable_rubyinterp)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001695if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar165641d2010-02-17 16:23:09 +01001696 AC_MSG_CHECKING(--with-ruby-command argument)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001697 AC_SUBST(vi_cv_path_ruby)
Bram Moolenaar948733a2011-05-05 18:10:16 +02001698 AC_ARG_WITH(ruby-command, [ --with-ruby-command=RUBY name of the Ruby command (default: ruby)],
1699 RUBY_CMD="$withval"; vi_cv_path_ruby="$withval"; AC_MSG_RESULT($RUBY_CMD),
1700 RUBY_CMD="ruby"; AC_MSG_RESULT(defaulting to $RUBY_CMD))
Bram Moolenaar165641d2010-02-17 16:23:09 +01001701 AC_PATH_PROG(vi_cv_path_ruby, $RUBY_CMD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001702 if test "X$vi_cv_path_ruby" != "X"; then
1703 AC_MSG_CHECKING(Ruby version)
Bram Moolenaare4efc3b2005-03-07 23:16:51 +00001704 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 +00001705 AC_MSG_RESULT(OK)
Bram Moolenaar81398892012-10-03 21:09:35 +02001706 AC_MSG_CHECKING(Ruby rbconfig)
1707 ruby_rbconfig="RbConfig"
1708 if ! $vi_cv_path_ruby -r rbconfig -e 'RbConfig' >/dev/null 2>/dev/null; then
1709 ruby_rbconfig="Config"
1710 fi
1711 AC_MSG_RESULT($ruby_rbconfig)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001712 AC_MSG_CHECKING(Ruby header files)
Bram Moolenaar81398892012-10-03 21:09:35 +02001713 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 +00001714 if test "X$rubyhdrdir" != "X"; then
1715 AC_MSG_RESULT($rubyhdrdir)
1716 RUBY_CFLAGS="-I$rubyhdrdir"
Bram Moolenaara6fd37b2014-03-27 17:19:09 +01001717 rubyarchdir=`$vi_cv_path_ruby -r rbconfig -e "print ($ruby_rbconfig::CONFIG.has_key? 'rubyarchhdrdir') ? $ruby_rbconfig::CONFIG[['rubyarchhdrdir']] : '$rubyhdrdir/'+$ruby_rbconfig::CONFIG[['arch']]"`
1718 if test -d "$rubyarchdir"; then
1719 RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyarchdir"
Bram Moolenaar165641d2010-02-17 16:23:09 +01001720 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001721 rubyversion=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['ruby_version']].gsub(/\./, '')[[0,2]]"`
Bram Moolenaar026a4452013-08-07 15:22:23 +02001722 if test "X$rubyversion" = "X"; then
1723 rubyversion=`$vi_cv_path_ruby -e "print ((VERSION rescue RUBY_VERSION)).gsub(/\./, '')[[0,2]]"`
1724 fi
Bram Moolenaar165641d2010-02-17 16:23:09 +01001725 RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
Bram Moolenaar81398892012-10-03 21:09:35 +02001726 rubylibs=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LIBS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001727 if test "X$rubylibs" != "X"; then
1728 RUBY_LIBS="$rubylibs"
1729 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001730 librubyarg=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBYARG']])"`
1731 librubya=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBY_A']])"`
Bram Moolenaarac499e32013-06-02 19:14:17 +02001732 rubylibdir=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['libdir']])"`
Bram Moolenaar948733a2011-05-05 18:10:16 +02001733 if test -f "$rubylibdir/$librubya"; then
1734 librubyarg="$librubyarg"
Bram Moolenaarac499e32013-06-02 19:14:17 +02001735 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
1736 elif test "$librubyarg" = "libruby.a"; then
1737 dnl required on Mac OS 10.3 where libruby.a doesn't exist
1738 librubyarg="-lruby"
1739 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001740 fi
1741
1742 if test "X$librubyarg" != "X"; then
1743 RUBY_LIBS="$librubyarg $RUBY_LIBS"
1744 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001745 rubyldflags=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LDFLAGS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001746 if test "X$rubyldflags" != "X"; then
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001747 dnl Ruby on Mac OS X 10.5 adds "-arch" flags but these should only
1748 dnl be included if requested by passing --with-mac-arch to
1749 dnl configure, so strip these flags first (if present)
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001750 rubyldflags=`echo "$rubyldflags" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001751 if test "X$rubyldflags" != "X"; then
Bram Moolenaar2bcaec32014-03-27 18:51:11 +01001752 if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$rubyldflags\"`" = "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001753 LDFLAGS="$rubyldflags $LDFLAGS"
1754 fi
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001755 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001756 fi
1757 RUBY_SRC="if_ruby.c"
1758 RUBY_OBJ="objects/if_ruby.o"
1759 RUBY_PRO="if_ruby.pro"
1760 AC_DEFINE(FEAT_RUBY)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001761 if test "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar81398892012-10-03 21:09:35 +02001762 libruby=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_SO']]"`
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001763 AC_DEFINE(DYNAMIC_RUBY)
1764 RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby\\\" -DDYNAMIC_RUBY_VER=$rubyversion $RUBY_CFLAGS"
1765 RUBY_LIBS=
1766 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001767 else
Bram Moolenaar165641d2010-02-17 16:23:09 +01001768 AC_MSG_RESULT(not found; disabling Ruby)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001769 fi
1770 else
1771 AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
1772 fi
1773 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001774
1775 if test "$fail_if_missing" = "yes" -a -z "$RUBY_OBJ"; then
1776 AC_MSG_ERROR([could not configure Ruby])
1777 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001778fi
1779AC_SUBST(RUBY_SRC)
1780AC_SUBST(RUBY_OBJ)
1781AC_SUBST(RUBY_PRO)
1782AC_SUBST(RUBY_CFLAGS)
1783AC_SUBST(RUBY_LIBS)
1784
1785AC_MSG_CHECKING(--enable-cscope argument)
1786AC_ARG_ENABLE(cscope,
1787 [ --enable-cscope Include cscope interface.], ,
1788 [enable_cscope="no"])
1789AC_MSG_RESULT($enable_cscope)
1790if test "$enable_cscope" = "yes"; then
1791 AC_DEFINE(FEAT_CSCOPE)
1792fi
1793
1794AC_MSG_CHECKING(--enable-workshop argument)
1795AC_ARG_ENABLE(workshop,
1796 [ --enable-workshop Include Sun Visual Workshop support.], ,
1797 [enable_workshop="no"])
1798AC_MSG_RESULT($enable_workshop)
1799if test "$enable_workshop" = "yes"; then
1800 AC_DEFINE(FEAT_SUN_WORKSHOP)
1801 WORKSHOP_SRC="workshop.c integration.c"
1802 AC_SUBST(WORKSHOP_SRC)
1803 WORKSHOP_OBJ="objects/workshop.o objects/integration.o"
1804 AC_SUBST(WORKSHOP_OBJ)
1805 if test "${enable_gui-xxx}" = xxx; then
1806 enable_gui=motif
1807 fi
1808fi
1809
1810AC_MSG_CHECKING(--disable-netbeans argument)
1811AC_ARG_ENABLE(netbeans,
1812 [ --disable-netbeans Disable NetBeans integration support.],
1813 , [enable_netbeans="yes"])
1814if test "$enable_netbeans" = "yes"; then
1815 AC_MSG_RESULT(no)
1816 dnl On Solaris we need the socket and nsl library.
1817 AC_CHECK_LIB(socket, socket)
1818 AC_CHECK_LIB(nsl, gethostbyname)
1819 AC_MSG_CHECKING(whether compiling netbeans integration is possible)
1820 AC_TRY_LINK([
1821#include <stdio.h>
1822#include <stdlib.h>
1823#include <stdarg.h>
1824#include <fcntl.h>
1825#include <netdb.h>
1826#include <netinet/in.h>
1827#include <errno.h>
1828#include <sys/types.h>
1829#include <sys/socket.h>
1830 /* Check bitfields */
1831 struct nbbuf {
1832 unsigned int initDone:1;
1833 ushort signmaplen;
1834 };
1835 ], [
1836 /* Check creating a socket. */
1837 struct sockaddr_in server;
1838 (void)socket(AF_INET, SOCK_STREAM, 0);
1839 (void)htons(100);
1840 (void)gethostbyname("microsoft.com");
1841 if (errno == ECONNREFUSED)
1842 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
1843 ],
1844 AC_MSG_RESULT(yes),
1845 AC_MSG_RESULT(no); enable_netbeans="no")
1846else
1847 AC_MSG_RESULT(yes)
1848fi
1849if test "$enable_netbeans" = "yes"; then
1850 AC_DEFINE(FEAT_NETBEANS_INTG)
1851 NETBEANS_SRC="netbeans.c"
1852 AC_SUBST(NETBEANS_SRC)
1853 NETBEANS_OBJ="objects/netbeans.o"
1854 AC_SUBST(NETBEANS_OBJ)
1855fi
1856
1857AC_MSG_CHECKING(--enable-sniff argument)
1858AC_ARG_ENABLE(sniff,
1859 [ --enable-sniff Include Sniff interface.], ,
1860 [enable_sniff="no"])
1861AC_MSG_RESULT($enable_sniff)
1862if test "$enable_sniff" = "yes"; then
1863 AC_DEFINE(FEAT_SNIFF)
1864 SNIFF_SRC="if_sniff.c"
1865 AC_SUBST(SNIFF_SRC)
1866 SNIFF_OBJ="objects/if_sniff.o"
1867 AC_SUBST(SNIFF_OBJ)
1868fi
1869
1870AC_MSG_CHECKING(--enable-multibyte argument)
1871AC_ARG_ENABLE(multibyte,
1872 [ --enable-multibyte Include multibyte editing support.], ,
1873 [enable_multibyte="no"])
1874AC_MSG_RESULT($enable_multibyte)
1875if test "$enable_multibyte" = "yes"; then
1876 AC_DEFINE(FEAT_MBYTE)
1877fi
1878
1879AC_MSG_CHECKING(--enable-hangulinput argument)
1880AC_ARG_ENABLE(hangulinput,
1881 [ --enable-hangulinput Include Hangul input support.], ,
1882 [enable_hangulinput="no"])
1883AC_MSG_RESULT($enable_hangulinput)
1884
1885AC_MSG_CHECKING(--enable-xim argument)
1886AC_ARG_ENABLE(xim,
1887 [ --enable-xim Include XIM input support.],
1888 AC_MSG_RESULT($enable_xim),
1889 [enable_xim="auto"; AC_MSG_RESULT(defaulting to auto)])
Bram Moolenaar071d4272004-06-13 20:20:40 +00001890
1891AC_MSG_CHECKING(--enable-fontset argument)
1892AC_ARG_ENABLE(fontset,
1893 [ --enable-fontset Include X fontset output support.], ,
1894 [enable_fontset="no"])
1895AC_MSG_RESULT($enable_fontset)
1896dnl defining FEAT_XFONTSET is delayed, so that it can be disabled for no GUI
1897
1898test -z "$with_x" && with_x=yes
1899test "${enable_gui-yes}" != no -a "x$MACOSX" != "xyes" -a "x$QNX" != "xyes" && with_x=yes
1900if test "$with_x" = no; then
1901 AC_MSG_RESULT(defaulting to: don't HAVE_X11)
1902else
1903 dnl Do this check early, so that its failure can override user requests.
1904
1905 AC_PATH_PROG(xmkmfpath, xmkmf)
1906
1907 AC_PATH_XTRA
1908
Bram Moolenaar2c704a72010-06-03 21:17:25 +02001909 dnl On z/OS Unix the X libraries are DLLs. To use them the code must
Bram Moolenaar071d4272004-06-13 20:20:40 +00001910 dnl be compiled with a special option.
1911 dnl Also add SM, ICE and Xmu to X_EXTRA_LIBS.
Bram Moolenaar2c704a72010-06-03 21:17:25 +02001912 if test "$zOSUnix" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001913 CFLAGS="$CFLAGS -W c,dll"
1914 LDFLAGS="$LDFLAGS -W l,dll"
1915 X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE -lXmu"
1916 fi
1917
1918 dnl On my HPUX system the X include dir is found, but the lib dir not.
1919 dnl This is a desparate try to fix this.
1920
1921 if test -d "$x_includes" && test ! -d "$x_libraries"; then
1922 x_libraries=`echo "$x_includes" | sed s/include/lib/`
1923 AC_MSG_RESULT(Corrected X libraries to $x_libraries)
1924 X_LIBS="$X_LIBS -L$x_libraries"
1925 if test "`(uname) 2>/dev/null`" = SunOS &&
1926 uname -r | grep '^5' >/dev/null; then
1927 X_LIBS="$X_LIBS -R $x_libraries"
1928 fi
1929 fi
1930
1931 if test -d "$x_libraries" && test ! -d "$x_includes"; then
1932 x_includes=`echo "$x_libraries" | sed s/lib/include/`
1933 AC_MSG_RESULT(Corrected X includes to $x_includes)
1934 X_CFLAGS="$X_CFLAGS -I$x_includes"
1935 fi
1936
1937 dnl Remove "-I/usr/include " from X_CFLAGS, should not be needed.
1938 X_CFLAGS="`echo $X_CFLAGS\ | sed 's%-I/usr/include %%'`"
1939 dnl Remove "-L/usr/lib " from X_LIBS, should not be needed.
1940 X_LIBS="`echo $X_LIBS\ | sed 's%-L/usr/lib %%'`"
1941 dnl Same for "-R/usr/lib ".
1942 X_LIBS="`echo $X_LIBS\ | sed -e 's%-R/usr/lib %%' -e 's%-R /usr/lib %%'`"
1943
1944
1945 dnl Check if the X11 header files are correctly installed. On some systems
Bram Moolenaar00ca2842008-06-26 20:14:00 +00001946 dnl Xlib.h includes files that don't exist. On some systems X11/Intrinsic.h
1947 dnl is missing.
Bram Moolenaar071d4272004-06-13 20:20:40 +00001948 AC_MSG_CHECKING(if X11 header files can be found)
1949 cflags_save=$CFLAGS
1950 CFLAGS="$CFLAGS $X_CFLAGS"
Bram Moolenaar00ca2842008-06-26 20:14:00 +00001951 AC_TRY_COMPILE([#include <X11/Xlib.h>
1952#include <X11/Intrinsic.h>], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001953 AC_MSG_RESULT(yes),
1954 AC_MSG_RESULT(no); no_x=yes)
1955 CFLAGS=$cflags_save
1956
1957 if test "${no_x-no}" = yes; then
1958 with_x=no
1959 else
1960 AC_DEFINE(HAVE_X11)
1961 X_LIB="-lXt -lX11";
1962 AC_SUBST(X_LIB)
1963
1964 ac_save_LDFLAGS="$LDFLAGS"
1965 LDFLAGS="-L$x_libraries $LDFLAGS"
1966
1967 dnl Check for -lXdmcp (needed on SunOS 4.1.4)
1968 dnl For HP-UX 10.20 it must be before -lSM -lICE
1969 AC_CHECK_LIB(Xdmcp, _XdmcpAuthDoIt, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lXdmcp"],,
1970 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXdmcp])
1971
1972 dnl Some systems need -lnsl -lsocket when testing for ICE.
1973 dnl The check above doesn't do this, try here (again). Also needed to get
1974 dnl them after Xdmcp. link.sh will remove them when not needed.
1975 dnl Check for other function than above to avoid the cached value
1976 AC_CHECK_LIB(ICE, IceOpenConnection,
1977 [X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE"],, [$X_EXTRA_LIBS])
1978
1979 dnl Check for -lXpm (needed for some versions of Motif)
1980 LDFLAGS="$X_LIBS $ac_save_LDFLAGS"
1981 AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [X_PRE_LIBS="$X_PRE_LIBS -lXpm"],,
1982 [-lXt $X_PRE_LIBS -lXpm -lX11 $X_EXTRA_LIBS])
1983
1984 dnl Check that the X11 header files don't use implicit declarations
1985 AC_MSG_CHECKING(if X11 header files implicitly declare return values)
1986 cflags_save=$CFLAGS
Bram Moolenaard1864592013-05-04 04:40:15 +02001987 dnl -Werror is GCC only, others like Solaris Studio might not like it
1988 if test "$GCC" = yes; then
1989 CFLAGS="$CFLAGS $X_CFLAGS -Werror"
1990 else
1991 CFLAGS="$CFLAGS $X_CFLAGS"
1992 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001993 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
1994 AC_MSG_RESULT(no),
1995 CFLAGS="$CFLAGS -Wno-implicit-int"
1996 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
1997 AC_MSG_RESULT(yes); cflags_save="$cflags_save -Wno-implicit-int",
1998 AC_MSG_RESULT(test failed)
1999 )
2000 )
2001 CFLAGS=$cflags_save
2002
2003 LDFLAGS="$ac_save_LDFLAGS"
2004
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00002005 AC_MSG_CHECKING(size of wchar_t is 2 bytes)
2006 AC_CACHE_VAL(ac_cv_small_wchar_t,
2007 [AC_TRY_RUN([
2008#include <X11/Xlib.h>
2009#if STDC_HEADERS
2010# include <stdlib.h>
2011# include <stddef.h>
2012#endif
2013 main()
2014 {
2015 if (sizeof(wchar_t) <= 2)
2016 exit(1);
2017 exit(0);
2018 }],
2019 ac_cv_small_wchar_t="no",
2020 ac_cv_small_wchar_t="yes",
2021 AC_MSG_ERROR(failed to compile test program))])
2022 AC_MSG_RESULT($ac_cv_small_wchar_t)
2023 if test "x$ac_cv_small_wchar_t" = "xyes" ; then
2024 AC_DEFINE(SMALL_WCHAR_T)
2025 fi
2026
Bram Moolenaar071d4272004-06-13 20:20:40 +00002027 fi
2028fi
2029
Bram Moolenaara7fc0102005-05-18 22:17:12 +00002030test "x$with_x" = xno -a "x$MACOSX" != "xyes" -a "x$QNX" != "xyes" && enable_gui=no
Bram Moolenaar071d4272004-06-13 20:20:40 +00002031
2032AC_MSG_CHECKING(--enable-gui argument)
2033AC_ARG_ENABLE(gui,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002034 [ --enable-gui[=OPTS] X11 GUI [default=auto] [OPTS=auto/no/gtk2/gnome2/motif/athena/neXtaw/photon/carbon]], , enable_gui="auto")
Bram Moolenaar071d4272004-06-13 20:20:40 +00002035
2036dnl Canonicalize the --enable-gui= argument so that it can be easily compared.
2037dnl Do not use character classes for portability with old tools.
2038enable_gui_canon=`echo "_$enable_gui" | \
2039 sed 's/[[ _+-]]//g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
2040
2041dnl Skip everything by default.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002042SKIP_GTK2=YES
2043SKIP_GNOME=YES
2044SKIP_MOTIF=YES
2045SKIP_ATHENA=YES
2046SKIP_NEXTAW=YES
2047SKIP_PHOTON=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002048SKIP_CARBON=YES
2049GUITYPE=NONE
2050
Bram Moolenaarb11160e2005-01-04 21:31:43 +00002051if test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002052 SKIP_PHOTON=
2053 case "$enable_gui_canon" in
2054 no) AC_MSG_RESULT(no GUI support)
2055 SKIP_PHOTON=YES ;;
2056 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
2057 auto) AC_MSG_RESULT(auto - automatic GUI support) ;;
2058 photon) AC_MSG_RESULT(Photon GUI support) ;;
2059 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2060 SKIP_PHOTON=YES ;;
2061 esac
2062
2063elif test "x$MACOSX" = "xyes" -a "x$with_x" = "xno" ; then
2064 SKIP_CARBON=
2065 case "$enable_gui_canon" in
2066 no) AC_MSG_RESULT(no GUI support)
2067 SKIP_CARBON=YES ;;
2068 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
Bram Moolenaar164fca32010-07-14 13:58:07 +02002069 auto) AC_MSG_RESULT(auto - Carbon GUI is outdated - disable GUI support)
2070 SKIP_CARBON=YES ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002071 carbon) AC_MSG_RESULT(Carbon GUI support) ;;
2072 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2073 SKIP_CARBON=YES ;;
2074 esac
2075
2076else
2077
Bram Moolenaar071d4272004-06-13 20:20:40 +00002078 case "$enable_gui_canon" in
2079 no|none) AC_MSG_RESULT(no GUI support) ;;
2080 yes|""|auto) AC_MSG_RESULT(yes/auto - automatic GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002081 SKIP_GTK2=
2082 SKIP_GNOME=
2083 SKIP_MOTIF=
2084 SKIP_ATHENA=
2085 SKIP_NEXTAW=
2086 SKIP_CARBON=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002087 gtk2) AC_MSG_RESULT(GTK+ 2.x GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002088 SKIP_GTK2=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002089 gnome2) AC_MSG_RESULT(GNOME 2.x GUI support)
2090 SKIP_GNOME=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002091 SKIP_GTK2=;;
2092 motif) AC_MSG_RESULT(Motif GUI support)
2093 SKIP_MOTIF=;;
2094 athena) AC_MSG_RESULT(Athena GUI support)
2095 SKIP_ATHENA=;;
2096 nextaw) AC_MSG_RESULT(neXtaw GUI support)
2097 SKIP_NEXTAW=;;
2098 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
2099 esac
2100
2101fi
2102
Bram Moolenaar071d4272004-06-13 20:20:40 +00002103if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \
2104 -a "$enable_gui_canon" != "gnome2"; then
2105 AC_MSG_CHECKING(whether or not to look for GTK+ 2)
2106 AC_ARG_ENABLE(gtk2-check,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002107 [ --enable-gtk2-check If auto-select GUI, check for GTK+ 2 [default=yes]],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002108 , enable_gtk2_check="yes")
2109 AC_MSG_RESULT($enable_gtk2_check)
2110 if test "x$enable_gtk2_check" = "xno"; then
2111 SKIP_GTK2=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002112 SKIP_GNOME=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002113 fi
2114fi
2115
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002116if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002117 AC_MSG_CHECKING(whether or not to look for GNOME)
2118 AC_ARG_ENABLE(gnome-check,
2119 [ --enable-gnome-check If GTK GUI, check for GNOME [default=no]],
2120 , enable_gnome_check="no")
2121 AC_MSG_RESULT($enable_gnome_check)
2122 if test "x$enable_gnome_check" = "xno"; then
2123 SKIP_GNOME=YES
2124 fi
2125fi
2126
2127if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then
2128 AC_MSG_CHECKING(whether or not to look for Motif)
2129 AC_ARG_ENABLE(motif-check,
2130 [ --enable-motif-check If auto-select GUI, check for Motif [default=yes]],
2131 , enable_motif_check="yes")
2132 AC_MSG_RESULT($enable_motif_check)
2133 if test "x$enable_motif_check" = "xno"; then
2134 SKIP_MOTIF=YES
2135 fi
2136fi
2137
2138if test "x$SKIP_ATHENA" != "xYES" -a "$enable_gui_canon" != "athena"; then
2139 AC_MSG_CHECKING(whether or not to look for Athena)
2140 AC_ARG_ENABLE(athena-check,
2141 [ --enable-athena-check If auto-select GUI, check for Athena [default=yes]],
2142 , enable_athena_check="yes")
2143 AC_MSG_RESULT($enable_athena_check)
2144 if test "x$enable_athena_check" = "xno"; then
2145 SKIP_ATHENA=YES
2146 fi
2147fi
2148
2149if test "x$SKIP_NEXTAW" != "xYES" -a "$enable_gui_canon" != "nextaw"; then
2150 AC_MSG_CHECKING(whether or not to look for neXtaw)
2151 AC_ARG_ENABLE(nextaw-check,
2152 [ --enable-nextaw-check If auto-select GUI, check for neXtaw [default=yes]],
2153 , enable_nextaw_check="yes")
2154 AC_MSG_RESULT($enable_nextaw_check);
2155 if test "x$enable_nextaw_check" = "xno"; then
2156 SKIP_NEXTAW=YES
2157 fi
2158fi
2159
2160if test "x$SKIP_CARBON" != "xYES" -a "$enable_gui_canon" != "carbon"; then
2161 AC_MSG_CHECKING(whether or not to look for Carbon)
2162 AC_ARG_ENABLE(carbon-check,
2163 [ --enable-carbon-check If auto-select GUI, check for Carbon [default=yes]],
2164 , enable_carbon_check="yes")
2165 AC_MSG_RESULT($enable_carbon_check);
2166 if test "x$enable_carbon_check" = "xno"; then
2167 SKIP_CARBON=YES
2168 fi
2169fi
2170
Bram Moolenaar843ee412004-06-30 16:16:41 +00002171
Bram Moolenaar071d4272004-06-13 20:20:40 +00002172if test "x$MACOSX" = "xyes" -a -z "$SKIP_CARBON" -a "x$CARBON" = "xyes"; then
2173 AC_MSG_CHECKING(for Carbon GUI)
Bram Moolenaar14716812006-05-04 21:54:08 +00002174 dnl already did the check, just give the message
Bram Moolenaar071d4272004-06-13 20:20:40 +00002175 AC_MSG_RESULT(yes);
2176 GUITYPE=CARBONGUI
Bram Moolenaare344bea2005-09-01 20:46:49 +00002177 if test "$VIMNAME" = "vim"; then
2178 VIMNAME=Vim
2179 fi
Bram Moolenaar14716812006-05-04 21:54:08 +00002180
Bram Moolenaar164fca32010-07-14 13:58:07 +02002181 if test "x$MACARCH" = "xboth"; then
2182 CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk/Developer/Headers/FlatCarbon"
2183 else
2184 CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/Headers/FlatCarbon"
2185 fi
2186
Bram Moolenaar14716812006-05-04 21:54:08 +00002187 dnl Default install directory is not /usr/local
2188 if test x$prefix = xNONE; then
2189 prefix=/Applications
2190 fi
2191
2192 dnl Sorry for the hard coded default
2193 datadir='${prefix}/Vim.app/Contents/Resources'
2194
Bram Moolenaar071d4272004-06-13 20:20:40 +00002195 dnl skip everything else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002196 SKIP_GTK2=YES;
2197 SKIP_GNOME=YES;
2198 SKIP_MOTIF=YES;
2199 SKIP_ATHENA=YES;
2200 SKIP_NEXTAW=YES;
2201 SKIP_PHOTON=YES;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002202 SKIP_CARBON=YES
2203fi
2204
Bram Moolenaar071d4272004-06-13 20:20:40 +00002205dnl define an autoconf function to check for a specified version of GTK, and
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002206dnl try to compile/link a GTK program.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002207dnl
2208dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002209dnl Test for GTK, and define GTK_CFLAGS, GTK_LIBDIR and GTK_LIBS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002210dnl
2211AC_DEFUN(AM_PATH_GTK,
2212[
2213 if test "X$GTK_CONFIG" != "Xno" -o "X$PKG_CONFIG" != "Xno"; then
2214 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002215 min_gtk_version=ifelse([$1], ,2.2.0,$1)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002216 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
2217 no_gtk=""
2218 if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2219 && $PKG_CONFIG --exists gtk+-2.0; then
2220 {
2221 dnl We should be using PKG_CHECK_MODULES() instead of this hack.
2222 dnl But I guess the dependency on pkgconfig.m4 is not wanted or
2223 dnl something like that.
2224 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0`
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002225 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-2.0`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002226 GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0`
2227 gtk_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2228 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2229 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2230 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2231 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2232 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2233 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002234 else
2235 no_gtk=yes
2236 fi
2237
2238 if test "x$enable_gtktest" = "xyes" -a "x$no_gtk" = "x"; then
2239 {
2240 ac_save_CFLAGS="$CFLAGS"
2241 ac_save_LIBS="$LIBS"
2242 CFLAGS="$CFLAGS $GTK_CFLAGS"
2243 LIBS="$LIBS $GTK_LIBS"
2244
2245 dnl
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002246 dnl Now check if the installed GTK is sufficiently new.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002247 dnl
2248 rm -f conf.gtktest
2249 AC_TRY_RUN([
2250#include <gtk/gtk.h>
2251#include <stdio.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00002252#if STDC_HEADERS
2253# include <stdlib.h>
2254# include <stddef.h>
2255#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002256
2257int
2258main ()
2259{
2260int major, minor, micro;
2261char *tmp_version;
2262
2263system ("touch conf.gtktest");
2264
2265/* HP/UX 9 (%@#!) writes to sscanf strings */
2266tmp_version = g_strdup("$min_gtk_version");
2267if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
2268 printf("%s, bad version string\n", "$min_gtk_version");
2269 exit(1);
2270 }
2271
2272if ((gtk_major_version > major) ||
2273 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
2274 ((gtk_major_version == major) && (gtk_minor_version == minor) &&
2275 (gtk_micro_version >= micro)))
2276{
2277 return 0;
2278}
2279return 1;
2280}
2281],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
2282 CFLAGS="$ac_save_CFLAGS"
2283 LIBS="$ac_save_LIBS"
2284 }
2285 fi
2286 if test "x$no_gtk" = x ; then
2287 if test "x$enable_gtktest" = "xyes"; then
2288 AC_MSG_RESULT(yes; found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2289 else
2290 AC_MSG_RESULT(found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2291 fi
2292 ifelse([$2], , :, [$2])
2293 else
2294 {
2295 AC_MSG_RESULT(no)
2296 GTK_CFLAGS=""
2297 GTK_LIBS=""
2298 ifelse([$3], , :, [$3])
2299 }
2300 fi
2301 }
2302 else
2303 GTK_CFLAGS=""
2304 GTK_LIBS=""
2305 ifelse([$3], , :, [$3])
2306 fi
2307 AC_SUBST(GTK_CFLAGS)
2308 AC_SUBST(GTK_LIBS)
2309 rm -f conf.gtktest
2310])
2311
2312dnl ---------------------------------------------------------------------------
2313dnl gnome
2314dnl ---------------------------------------------------------------------------
2315AC_DEFUN([GNOME_INIT_HOOK],
2316[
2317 AC_SUBST(GNOME_LIBS)
2318 AC_SUBST(GNOME_LIBDIR)
2319 AC_SUBST(GNOME_INCLUDEDIR)
2320
2321 AC_ARG_WITH(gnome-includes,
2322 [ --with-gnome-includes=DIR Specify location of GNOME headers],
2323 [CFLAGS="$CFLAGS -I$withval"]
2324 )
2325
2326 AC_ARG_WITH(gnome-libs,
2327 [ --with-gnome-libs=DIR Specify location of GNOME libs],
2328 [LDFLAGS="$LDFLAGS -L$withval" gnome_prefix=$withval]
2329 )
2330
2331 AC_ARG_WITH(gnome,
2332 [ --with-gnome Specify prefix for GNOME files],
2333 if test x$withval = xyes; then
2334 want_gnome=yes
2335 ifelse([$1], [], :, [$1])
2336 else
2337 if test "x$withval" = xno; then
2338 want_gnome=no
2339 else
2340 want_gnome=yes
2341 LDFLAGS="$LDFLAGS -L$withval/lib"
2342 CFLAGS="$CFLAGS -I$withval/include"
2343 gnome_prefix=$withval/lib
2344 fi
2345 fi,
2346 want_gnome=yes)
2347
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002348 if test "x$want_gnome" = xyes; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002349 {
2350 AC_MSG_CHECKING(for libgnomeui-2.0)
2351 if $PKG_CONFIG --exists libgnomeui-2.0; then
2352 AC_MSG_RESULT(yes)
2353 GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0`
2354 GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0`
2355 GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0`
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002356
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002357 dnl On FreeBSD we need -pthread but pkg-config doesn't include it.
2358 dnl This might not be the right way but it works for me...
2359 AC_MSG_CHECKING(for FreeBSD)
2360 if test "`(uname) 2>/dev/null`" = FreeBSD; then
2361 AC_MSG_RESULT(yes, adding -pthread)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002362 GNOME_INCLUDEDIR="$GNOME_INCLUDEDIR -D_THREAD_SAFE"
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002363 GNOME_LIBS="$GNOME_LIBS -pthread"
2364 else
2365 AC_MSG_RESULT(no)
2366 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002367 $1
2368 else
2369 AC_MSG_RESULT(not found)
2370 if test "x$2" = xfail; then
2371 AC_MSG_ERROR(Could not find libgnomeui-2.0 via pkg-config)
2372 fi
2373 fi
2374 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002375 fi
2376])
2377
2378AC_DEFUN([GNOME_INIT],[
2379 GNOME_INIT_HOOK([],fail)
2380])
2381
2382
2383dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002384dnl Check for GTK2. If it fails, then continue on for Motif as before...
Bram Moolenaar071d4272004-06-13 20:20:40 +00002385dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002386if test -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002387
2388 AC_MSG_CHECKING(--disable-gtktest argument)
2389 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2390 , enable_gtktest=yes)
2391 if test "x$enable_gtktest" = "xyes" ; then
2392 AC_MSG_RESULT(gtk test enabled)
2393 else
2394 AC_MSG_RESULT(gtk test disabled)
2395 fi
2396
Bram Moolenaar071d4272004-06-13 20:20:40 +00002397 if test "X$PKG_CONFIG" = "X"; then
2398 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
2399 fi
2400
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002401 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002402 dnl First try finding version 2.2.0 or later. The 2.0.x series has
2403 dnl problems (bold fonts, --remote doesn't work).
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002404 AM_PATH_GTK(2.2.0,
2405 [GUI_LIB_LOC="$GTK_LIBDIR"
2406 GTK_LIBNAME="$GTK_LIBS"
2407 GUI_INC_LOC="$GTK_CFLAGS"], )
2408 if test "x$GTK_CFLAGS" != "x"; then
2409 SKIP_ATHENA=YES
2410 SKIP_NEXTAW=YES
2411 SKIP_MOTIF=YES
2412 GUITYPE=GTK
2413 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002414 fi
2415 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002416 if test "x$GUITYPE" = "xGTK"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002417 if test "$gtk_minor_version" = 1 -a "0$gtk_micro_version" -ge 1 \
2418 || test "0$gtk_minor_version" -ge 2; then
2419 AC_DEFINE(HAVE_GTK_MULTIHEAD)
2420 fi
2421 dnl
2422 dnl if GTK exists, then check for GNOME.
2423 dnl
2424 if test -z "$SKIP_GNOME"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002425 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002426 GNOME_INIT_HOOK([have_gnome=yes])
2427 if test "x$have_gnome" = xyes ; then
2428 AC_DEFINE(FEAT_GUI_GNOME)
2429 GUI_INC_LOC="$GUI_INC_LOC $GNOME_INCLUDEDIR"
2430 GTK_LIBNAME="$GTK_LIBNAME $GNOME_LIBDIR $GNOME_LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002431 fi
2432 }
2433 fi
2434 fi
2435fi
2436
2437dnl Check for Motif include files location.
2438dnl The LAST one found is used, this makes the highest version to be used,
2439dnl e.g. when Motif1.2 and Motif2.0 are both present.
2440
2441if test -z "$SKIP_MOTIF"; then
2442 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"
2443 dnl Remove "-I" from before $GUI_INC_LOC if it's there
2444 GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`"
2445
2446 AC_MSG_CHECKING(for location of Motif GUI includes)
2447 gui_includes="`echo $x_includes|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC"
2448 GUI_INC_LOC=
2449 for try in $gui_includes; do
2450 if test -f "$try/Xm/Xm.h"; then
2451 GUI_INC_LOC=$try
2452 fi
2453 done
2454 if test -n "$GUI_INC_LOC"; then
2455 if test "$GUI_INC_LOC" = /usr/include; then
2456 GUI_INC_LOC=
2457 AC_MSG_RESULT(in default path)
2458 else
2459 AC_MSG_RESULT($GUI_INC_LOC)
2460 fi
2461 else
2462 AC_MSG_RESULT(<not found>)
2463 SKIP_MOTIF=YES
2464 fi
2465fi
2466
2467dnl Check for Motif library files location. In the same order as the include
2468dnl files, to avoid a mixup if several versions are present
2469
2470if test -z "$SKIP_MOTIF"; then
2471 AC_MSG_CHECKING(--with-motif-lib argument)
2472 AC_ARG_WITH(motif-lib,
2473 [ --with-motif-lib=STRING Library for Motif ],
2474 [ MOTIF_LIBNAME="${withval}" ] )
2475
2476 if test -n "$MOTIF_LIBNAME"; then
2477 AC_MSG_RESULT($MOTIF_LIBNAME)
2478 GUI_LIB_LOC=
2479 else
2480 AC_MSG_RESULT(no)
2481
2482 dnl Remove "-L" from before $GUI_LIB_LOC if it's there
2483 GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
2484
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002485 dnl Ubuntu has libXm.so in /usr/lib/i386-linux-gnu and elsewhere. The
2486 dnl linker will figure out which one to use, we only check if one exists.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002487 AC_MSG_CHECKING(for location of Motif GUI libs)
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002488 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 +00002489 GUI_LIB_LOC=
2490 for try in $gui_libs; do
Bram Moolenaar325b7a22004-07-05 15:58:32 +00002491 for libtry in "$try"/libXm.a "$try"/libXm.so* "$try"/libXm.sl "$try"/libXm.dylib; do
Bram Moolenaar071d4272004-06-13 20:20:40 +00002492 if test -f "$libtry"; then
2493 GUI_LIB_LOC=$try
2494 fi
2495 done
2496 done
2497 if test -n "$GUI_LIB_LOC"; then
2498 dnl Remove /usr/lib, it causes trouble on some systems
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002499 if test "$GUI_LIB_LOC" = /usr/lib \
2500 -o "$GUI_LIB_LOC" = /usr/lib/i386-linux-gnu \
2501 -o "$GUI_LIB_LOC" = /usr/lib/x86_64-linux-gnu; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002502 GUI_LIB_LOC=
2503 AC_MSG_RESULT(in default path)
2504 else
2505 if test -n "$GUI_LIB_LOC"; then
2506 AC_MSG_RESULT($GUI_LIB_LOC)
2507 if test "`(uname) 2>/dev/null`" = SunOS &&
2508 uname -r | grep '^5' >/dev/null; then
2509 GUI_LIB_LOC="$GUI_LIB_LOC -R $GUI_LIB_LOC"
2510 fi
2511 fi
2512 fi
2513 MOTIF_LIBNAME=-lXm
2514 else
2515 AC_MSG_RESULT(<not found>)
2516 SKIP_MOTIF=YES
2517 fi
2518 fi
2519fi
2520
2521if test -z "$SKIP_MOTIF"; then
2522 SKIP_ATHENA=YES
2523 SKIP_NEXTAW=YES
2524 GUITYPE=MOTIF
2525 AC_SUBST(MOTIF_LIBNAME)
2526fi
2527
2528dnl Check if the Athena files can be found
2529
2530GUI_X_LIBS=
2531
2532if test -z "$SKIP_ATHENA"; then
2533 AC_MSG_CHECKING(if Athena header files can be found)
2534 cflags_save=$CFLAGS
2535 CFLAGS="$CFLAGS $X_CFLAGS"
2536 AC_TRY_COMPILE([
2537#include <X11/Intrinsic.h>
2538#include <X11/Xaw/Paned.h>], ,
2539 AC_MSG_RESULT(yes),
2540 AC_MSG_RESULT(no); SKIP_ATHENA=YES )
2541 CFLAGS=$cflags_save
2542fi
2543
2544if test -z "$SKIP_ATHENA"; then
2545 GUITYPE=ATHENA
2546fi
2547
2548if test -z "$SKIP_NEXTAW"; then
2549 AC_MSG_CHECKING(if neXtaw header files can be found)
2550 cflags_save=$CFLAGS
2551 CFLAGS="$CFLAGS $X_CFLAGS"
2552 AC_TRY_COMPILE([
2553#include <X11/Intrinsic.h>
2554#include <X11/neXtaw/Paned.h>], ,
2555 AC_MSG_RESULT(yes),
2556 AC_MSG_RESULT(no); SKIP_NEXTAW=YES )
2557 CFLAGS=$cflags_save
2558fi
2559
2560if test -z "$SKIP_NEXTAW"; then
2561 GUITYPE=NEXTAW
2562fi
2563
2564if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
2565 dnl Prepend -I and -L to $GUI_INC_LOC and $GUI_LIB_LOC if not empty
2566 dnl Avoid adding it when it twice
2567 if test -n "$GUI_INC_LOC"; then
2568 GUI_INC_LOC=-I"`echo $GUI_INC_LOC|sed 's%-I%%'`"
2569 fi
2570 if test -n "$GUI_LIB_LOC"; then
2571 GUI_LIB_LOC=-L"`echo $GUI_LIB_LOC|sed 's%-L%%'`"
2572 fi
2573
2574 dnl Check for -lXext and then for -lXmu
2575 ldflags_save=$LDFLAGS
2576 LDFLAGS="$X_LIBS $LDFLAGS"
2577 AC_CHECK_LIB(Xext, XShapeQueryExtension, [GUI_X_LIBS="-lXext"],,
2578 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2579 dnl For Solaris we need -lw and -ldl before linking with -lXmu works.
2580 AC_CHECK_LIB(w, wslen, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lw"],,
2581 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2582 AC_CHECK_LIB(dl, dlsym, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldl"],,
2583 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2584 AC_CHECK_LIB(Xmu, XmuCreateStippledPixmap, [GUI_X_LIBS="-lXmu $GUI_X_LIBS"],,
2585 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2586 if test -z "$SKIP_MOTIF"; then
2587 AC_CHECK_LIB(Xp, XpEndJob, [GUI_X_LIBS="-lXp $GUI_X_LIBS"],,
2588 [$GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2589 fi
2590 LDFLAGS=$ldflags_save
2591
2592 dnl Execute xmkmf to figure out if -DNARROWPROTO is needed.
2593 AC_MSG_CHECKING(for extra X11 defines)
2594 NARROW_PROTO=
2595 rm -fr conftestdir
2596 if mkdir conftestdir; then
2597 cd conftestdir
2598 cat > Imakefile <<'EOF'
2599acfindx:
2600 @echo 'NARROW_PROTO="${PROTO_DEFINES}"'
2601EOF
2602 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
2603 eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
2604 fi
2605 cd ..
2606 rm -fr conftestdir
2607 fi
2608 if test -z "$NARROW_PROTO"; then
2609 AC_MSG_RESULT(no)
2610 else
2611 AC_MSG_RESULT($NARROW_PROTO)
2612 fi
2613 AC_SUBST(NARROW_PROTO)
2614fi
2615
2616dnl Look for XSMP support - but don't necessarily restrict it to X11 GUIs
2617dnl use the X11 include path
2618if test "$enable_xsmp" = "yes"; then
2619 cppflags_save=$CPPFLAGS
2620 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2621 AC_CHECK_HEADERS(X11/SM/SMlib.h)
2622 CPPFLAGS=$cppflags_save
2623fi
2624
2625
Bram Moolenaare667c952010-07-05 22:57:59 +02002626if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF" -o -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002627 dnl Check for X11/xpm.h and X11/Sunkeysym.h with the GUI include path
2628 cppflags_save=$CPPFLAGS
2629 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2630 AC_CHECK_HEADERS(X11/xpm.h X11/Sunkeysym.h)
2631
2632 dnl automatically disable XIM when XIMtext isn't in X11/Xlib.h
2633 if test ! "$enable_xim" = "no"; then
2634 AC_MSG_CHECKING(for XIMText in X11/Xlib.h)
2635 AC_EGREP_CPP(XIMText, [#include <X11/Xlib.h>],
2636 AC_MSG_RESULT(yes),
2637 AC_MSG_RESULT(no; xim has been disabled); enable_xim = "no")
2638 fi
2639 CPPFLAGS=$cppflags_save
2640
2641 dnl automatically enable XIM when hangul input isn't enabled
2642 if test "$enable_xim" = "auto" -a "$enable_hangulinput" != "yes" \
2643 -a "x$GUITYPE" != "xNONE" ; then
2644 AC_MSG_RESULT(X GUI selected; xim has been enabled)
2645 enable_xim="yes"
2646 fi
2647fi
2648
2649if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
2650 cppflags_save=$CPPFLAGS
2651 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00002652dnl Xmu/Editres.h may exist but can only be used after including Intrinsic.h
2653 AC_MSG_CHECKING([for X11/Xmu/Editres.h])
2654 AC_TRY_COMPILE([
2655#include <X11/Intrinsic.h>
2656#include <X11/Xmu/Editres.h>],
2657 [int i; i = 0;],
2658 AC_MSG_RESULT(yes)
2659 AC_DEFINE(HAVE_X11_XMU_EDITRES_H),
2660 AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00002661 CPPFLAGS=$cppflags_save
2662fi
2663
2664dnl Only use the Xm directory when compiling Motif, don't use it for Athena
2665if test -z "$SKIP_MOTIF"; then
2666 cppflags_save=$CPPFLAGS
2667 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar77c19352012-06-13 19:19:41 +02002668 if test "$zOSUnix" = "yes"; then
2669 xmheader="Xm/Xm.h"
2670 else
2671 xmheader="Xm/Xm.h Xm/XpmP.h Xm/JoinSideT.h Xm/TraitP.h Xm/Manager.h
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02002672 Xm/UnhighlightT.h Xm/Notebook.h"
Bram Moolenaar77c19352012-06-13 19:19:41 +02002673 fi
2674 AC_CHECK_HEADERS($xmheader)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00002675
Bram Moolenaar77c19352012-06-13 19:19:41 +02002676 if test "x$ac_cv_header_Xm_XpmP_h" = "xyes"; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +00002677 dnl Solaris uses XpmAttributes_21, very annoying.
2678 AC_MSG_CHECKING([for XpmAttributes_21 in Xm/XpmP.h])
2679 AC_TRY_COMPILE([#include <Xm/XpmP.h>], [XpmAttributes_21 attr;],
2680 AC_MSG_RESULT(yes); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes_21),
2681 AC_MSG_RESULT(no); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
2682 )
2683 else
Bram Moolenaar57657d82006-04-21 22:12:41 +00002684 AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00002685 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002686 CPPFLAGS=$cppflags_save
2687fi
2688
2689if test "x$GUITYPE" = "xNONE" -a "$enable_xim" = "yes"; then
2690 AC_MSG_RESULT(no GUI selected; xim has been disabled)
2691 enable_xim="no"
2692fi
2693if test "x$GUITYPE" = "xNONE" -a "$enable_fontset" = "yes"; then
2694 AC_MSG_RESULT(no GUI selected; fontset has been disabled)
2695 enable_fontset="no"
2696fi
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002697if test "x$GUITYPE:$enable_fontset" = "xGTK:yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002698 AC_MSG_RESULT(GTK+ 2 GUI selected; fontset has been disabled)
2699 enable_fontset="no"
2700fi
2701
Bram Moolenaar071d4272004-06-13 20:20:40 +00002702if test -z "$SKIP_PHOTON"; then
2703 GUITYPE=PHOTONGUI
2704fi
2705
2706AC_SUBST(GUI_INC_LOC)
2707AC_SUBST(GUI_LIB_LOC)
2708AC_SUBST(GUITYPE)
2709AC_SUBST(GUI_X_LIBS)
2710
2711if test "$enable_workshop" = "yes" -a -n "$SKIP_MOTIF"; then
2712 AC_MSG_ERROR([cannot use workshop without Motif])
2713fi
2714
2715dnl defining FEAT_XIM and FEAT_XFONTSET is delayed, so that they can be disabled
2716if test "$enable_xim" = "yes"; then
2717 AC_DEFINE(FEAT_XIM)
2718fi
2719if test "$enable_fontset" = "yes"; then
2720 AC_DEFINE(FEAT_XFONTSET)
2721fi
2722
2723
2724dnl ---------------------------------------------------------------------------
2725dnl end of GUI-checking
2726dnl ---------------------------------------------------------------------------
2727
Bram Moolenaar693e40c2013-02-26 14:56:42 +01002728dnl Check for Cygwin, which needs an extra source file if not using X11
2729AC_MSG_CHECKING(for CYGWIN environment)
2730case `uname` in
2731 CYGWIN*) CYGWIN=yes; AC_MSG_RESULT(yes)
2732 AC_MSG_CHECKING(for CYGWIN clipboard support)
2733 if test "x$with_x" = "xno" ; then
2734 OS_EXTRA_SRC=winclip.c; OS_EXTRA_OBJ=objects/winclip.o
2735 AC_MSG_RESULT(yes)
2736 AC_DEFINE(FEAT_CYGWIN_WIN32_CLIPBOARD)
2737 else
2738 AC_MSG_RESULT(no - using X11)
2739 fi ;;
2740
2741 *) CYGWIN=no; AC_MSG_RESULT(no);;
2742esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00002743
2744dnl Only really enable hangul input when GUI and XFONTSET are available
2745if test "$enable_hangulinput" = "yes"; then
2746 if test "x$GUITYPE" = "xNONE"; then
2747 AC_MSG_RESULT(no GUI selected; hangul input has been disabled)
2748 enable_hangulinput=no
2749 else
2750 AC_DEFINE(FEAT_HANGULIN)
2751 HANGULIN_SRC=hangulin.c
2752 AC_SUBST(HANGULIN_SRC)
2753 HANGULIN_OBJ=objects/hangulin.o
2754 AC_SUBST(HANGULIN_OBJ)
2755 fi
2756fi
2757
2758dnl Checks for libraries and include files.
2759
Bram Moolenaar446cb832008-06-24 21:56:24 +00002760AC_CACHE_CHECK([whether toupper is broken], [vim_cv_toupper_broken],
2761 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01002762 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00002763#include "confdefs.h"
2764#include <ctype.h>
2765#if STDC_HEADERS
2766# include <stdlib.h>
2767# include <stddef.h>
2768#endif
2769main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01002770 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00002771 vim_cv_toupper_broken=yes
2772 ],[
2773 vim_cv_toupper_broken=no
2774 ],[
2775 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_toupper_broken')
2776 ])])
2777
2778if test "x$vim_cv_toupper_broken" = "xyes" ; then
2779 AC_DEFINE(BROKEN_TOUPPER)
2780fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002781
2782AC_MSG_CHECKING(whether __DATE__ and __TIME__ work)
Bram Moolenaar446cb832008-06-24 21:56:24 +00002783AC_TRY_COMPILE([#include <stdio.h>], [printf("(" __DATE__ " " __TIME__ ")");],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002784 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DATE_TIME),
2785 AC_MSG_RESULT(no))
2786
Bram Moolenaar0c094b92009-05-14 20:20:33 +00002787AC_MSG_CHECKING(whether __attribute__((unused)) is allowed)
2788AC_TRY_COMPILE([#include <stdio.h>], [int x __attribute__((unused));],
2789 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ATTRIBUTE_UNUSED),
2790 AC_MSG_RESULT(no))
2791
Bram Moolenaar071d4272004-06-13 20:20:40 +00002792dnl Checks for header files.
2793AC_CHECK_HEADER(elf.h, HAS_ELF=1)
2794dnl AC_CHECK_HEADER(dwarf.h, SVR4=1)
2795if test "$HAS_ELF" = 1; then
2796 AC_CHECK_LIB(elf, main)
2797fi
2798
2799AC_HEADER_DIRENT
2800
Bram Moolenaar071d4272004-06-13 20:20:40 +00002801dnl If sys/wait.h is not found it might still exist but not be POSIX
2802dnl compliant. In that case we define HAVE_UNION_WAIT (for NeXT)
2803if test $ac_cv_header_sys_wait_h = no; then
2804 AC_MSG_CHECKING([for sys/wait.h that defines union wait])
2805 AC_TRY_COMPILE([#include <sys/wait.h>],
2806 [union wait xx, yy; xx = yy],
2807 AC_MSG_RESULT(yes)
2808 AC_DEFINE(HAVE_SYS_WAIT_H)
2809 AC_DEFINE(HAVE_UNION_WAIT),
2810 AC_MSG_RESULT(no))
2811fi
2812
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02002813AC_CHECK_HEADERS(stdarg.h stdint.h stdlib.h string.h \
2814 sys/select.h sys/utsname.h termcap.h fcntl.h \
2815 sgtty.h sys/ioctl.h sys/time.h sys/types.h \
2816 termio.h iconv.h inttypes.h langinfo.h math.h \
2817 unistd.h stropts.h errno.h sys/resource.h \
2818 sys/systeminfo.h locale.h sys/stream.h termios.h \
2819 libc.h sys/statfs.h poll.h sys/poll.h pwd.h \
2820 utime.h sys/param.h libintl.h libgen.h \
2821 util/debug.h util/msg18n.h frame.h sys/acl.h \
2822 sys/access.h sys/sysinfo.h wchar.h wctype.h)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002823
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002824dnl sys/ptem.h depends on sys/stream.h on Solaris
2825AC_CHECK_HEADERS(sys/ptem.h, [], [],
2826[#if defined HAVE_SYS_STREAM_H
2827# include <sys/stream.h>
2828#endif])
2829
Bram Moolenaar32f31b12009-05-21 13:20:59 +00002830dnl sys/sysctl.h depends on sys/param.h on OpenBSD
2831AC_CHECK_HEADERS(sys/sysctl.h, [], [],
2832[#if defined HAVE_SYS_PARAM_H
2833# include <sys/param.h>
2834#endif])
2835
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002836
Bram Moolenaardf3267e2005-01-25 22:07:05 +00002837dnl pthread_np.h may exist but can only be used after including pthread.h
2838AC_MSG_CHECKING([for pthread_np.h])
2839AC_TRY_COMPILE([
2840#include <pthread.h>
2841#include <pthread_np.h>],
2842 [int i; i = 0;],
2843 AC_MSG_RESULT(yes)
2844 AC_DEFINE(HAVE_PTHREAD_NP_H),
2845 AC_MSG_RESULT(no))
2846
Bram Moolenaare344bea2005-09-01 20:46:49 +00002847AC_CHECK_HEADERS(strings.h)
Bram Moolenaar9372a112005-12-06 19:59:18 +00002848if test "x$MACOSX" = "xyes"; then
2849 dnl The strings.h file on OS/X contains a warning and nothing useful.
2850 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
2851else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002852
2853dnl Check if strings.h and string.h can both be included when defined.
2854AC_MSG_CHECKING([if strings.h can be included after string.h])
2855cppflags_save=$CPPFLAGS
2856CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2857AC_TRY_COMPILE([
2858#if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO)
2859# define _NO_PROTO /* like in os_unix.h, causes conflict for AIX (Winn) */
2860 /* but don't do it on AIX 5.1 (Uribarri) */
2861#endif
2862#ifdef HAVE_XM_XM_H
2863# include <Xm/Xm.h> /* This breaks it for HP-UX 11 (Squassabia) */
2864#endif
2865#ifdef HAVE_STRING_H
2866# include <string.h>
2867#endif
2868#if defined(HAVE_STRINGS_H)
2869# include <strings.h>
2870#endif
2871 ], [int i; i = 0;],
2872 AC_MSG_RESULT(yes),
2873 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
2874 AC_MSG_RESULT(no))
2875CPPFLAGS=$cppflags_save
Bram Moolenaar9372a112005-12-06 19:59:18 +00002876fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002877
2878dnl Checks for typedefs, structures, and compiler characteristics.
2879AC_PROG_GCC_TRADITIONAL
2880AC_C_CONST
Bram Moolenaar76243bd2009-03-02 01:47:02 +00002881AC_C_VOLATILE
Bram Moolenaar071d4272004-06-13 20:20:40 +00002882AC_TYPE_MODE_T
2883AC_TYPE_OFF_T
2884AC_TYPE_PID_T
2885AC_TYPE_SIZE_T
2886AC_TYPE_UID_T
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02002887AC_TYPE_UINT32_T
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02002888
Bram Moolenaar071d4272004-06-13 20:20:40 +00002889AC_HEADER_TIME
2890AC_CHECK_TYPE(ino_t, long)
2891AC_CHECK_TYPE(dev_t, unsigned)
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02002892AC_C_BIGENDIAN(,,,)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002893
2894AC_MSG_CHECKING(for rlim_t)
2895if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
2896 AC_MSG_RESULT([(cached) $ac_cv_type_rlim_t])
2897else
2898 AC_EGREP_CPP(dnl
2899changequote(<<,>>)dnl
2900<<(^|[^a-zA-Z_0-9])rlim_t[^a-zA-Z_0-9]>>dnl
2901changequote([,]),
2902 [
2903#include <sys/types.h>
2904#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00002905# include <stdlib.h>
2906# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00002907#endif
2908#ifdef HAVE_SYS_RESOURCE_H
Bram Moolenaar446cb832008-06-24 21:56:24 +00002909# include <sys/resource.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00002910#endif
2911 ], ac_cv_type_rlim_t=yes, ac_cv_type_rlim_t=no)
2912 AC_MSG_RESULT($ac_cv_type_rlim_t)
2913fi
2914if test $ac_cv_type_rlim_t = no; then
2915 cat >> confdefs.h <<\EOF
2916#define rlim_t unsigned long
2917EOF
2918fi
2919
2920AC_MSG_CHECKING(for stack_t)
2921if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then
2922 AC_MSG_RESULT([(cached) $ac_cv_type_stack_t])
2923else
2924 AC_EGREP_CPP(stack_t,
2925 [
2926#include <sys/types.h>
2927#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00002928# include <stdlib.h>
2929# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00002930#endif
2931#include <signal.h>
2932 ], ac_cv_type_stack_t=yes, ac_cv_type_stack_t=no)
2933 AC_MSG_RESULT($ac_cv_type_stack_t)
2934fi
2935if test $ac_cv_type_stack_t = no; then
2936 cat >> confdefs.h <<\EOF
2937#define stack_t struct sigaltstack
2938EOF
2939fi
2940
2941dnl BSDI uses ss_base while others use ss_sp for the stack pointer.
2942AC_MSG_CHECKING(whether stack_t has an ss_base field)
2943AC_TRY_COMPILE([
2944#include <sys/types.h>
2945#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00002946# include <stdlib.h>
2947# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00002948#endif
2949#include <signal.h>
2950#include "confdefs.h"
2951 ], [stack_t sigstk; sigstk.ss_base = 0; ],
2952 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SS_BASE),
2953 AC_MSG_RESULT(no))
2954
2955olibs="$LIBS"
2956AC_MSG_CHECKING(--with-tlib argument)
2957AC_ARG_WITH(tlib, [ --with-tlib=library terminal library to be used ],)
2958if test -n "$with_tlib"; then
2959 AC_MSG_RESULT($with_tlib)
2960 LIBS="$LIBS -l$with_tlib"
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00002961 AC_MSG_CHECKING(for linking with $with_tlib library)
2962 AC_TRY_LINK([], [], AC_MSG_RESULT(OK), AC_MSG_ERROR(FAILED))
2963 dnl Need to check for tgetent() below.
2964 olibs="$LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002965else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00002966 AC_MSG_RESULT([empty: automatic terminal library selection])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002967 dnl On HP-UX 10.10 termcap or termlib should be used instead of
2968 dnl curses, because curses is much slower.
Bram Moolenaar4e509b62011-02-09 17:42:57 +01002969 dnl Newer versions of ncurses are preferred over anything, except
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02002970 dnl when tinfo has been split off, it contains all we need.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002971 dnl Older versions of ncurses have bugs, get a new one!
2972 dnl Digital Unix (OSF1) should use curses (Ronald Schild).
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00002973 dnl On SCO Openserver should prefer termlib (Roger Cornelius).
Bram Moolenaar071d4272004-06-13 20:20:40 +00002974 case "`uname -s 2>/dev/null`" in
Bram Moolenaar4e509b62011-02-09 17:42:57 +01002975 OSF1|SCO_SV) tlibs="tinfo ncurses curses termlib termcap";;
2976 *) tlibs="tinfo ncurses termlib termcap curses";;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002977 esac
2978 for libname in $tlibs; do
2979 AC_CHECK_LIB(${libname}, tgetent,,)
2980 if test "x$olibs" != "x$LIBS"; then
2981 dnl It's possible that a library is found but it doesn't work
2982 dnl e.g., shared library that cannot be found
2983 dnl compile and run a test program to be sure
2984 AC_TRY_RUN([
2985#ifdef HAVE_TERMCAP_H
2986# include <termcap.h>
2987#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00002988#if STDC_HEADERS
2989# include <stdlib.h>
2990# include <stddef.h>
2991#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002992main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }],
2993 res="OK", res="FAIL", res="FAIL")
2994 if test "$res" = "OK"; then
2995 break
2996 fi
2997 AC_MSG_RESULT($libname library is not usable)
2998 LIBS="$olibs"
2999 fi
3000 done
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003001 if test "x$olibs" = "x$LIBS"; then
3002 AC_MSG_RESULT(no terminal library found)
3003 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003004fi
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003005
3006if test "x$olibs" = "x$LIBS"; then
3007 AC_MSG_CHECKING([for tgetent()])
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00003008 AC_TRY_LINK([],
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00003009 [char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");],
3010 AC_MSG_RESULT(yes),
3011 AC_MSG_ERROR([NOT FOUND!
3012 You need to install a terminal library; for example ncurses.
3013 Or specify the name of the library with --with-tlib.]))
3014fi
3015
Bram Moolenaar446cb832008-06-24 21:56:24 +00003016AC_CACHE_CHECK([whether we talk terminfo], [vim_cv_terminfo],
3017 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003018 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003019#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003020#ifdef HAVE_TERMCAP_H
3021# include <termcap.h>
3022#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003023#ifdef HAVE_STRING_H
3024# include <string.h>
3025#endif
3026#if STDC_HEADERS
3027# include <stdlib.h>
3028# include <stddef.h>
3029#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003030main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003031{char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003032 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003033 vim_cv_terminfo=no
3034 ],[
3035 vim_cv_terminfo=yes
3036 ],[
3037 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_terminfo')
3038 ])
3039 ])
3040
3041if test "x$vim_cv_terminfo" = "xyes" ; then
3042 AC_DEFINE(TERMINFO)
3043fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003044
3045if test "x$olibs" != "x$LIBS"; then
Bram Moolenaar446cb832008-06-24 21:56:24 +00003046 AC_CACHE_CHECK([what tgetent() returns for an unknown terminal], [vim_cv_tgent],
3047 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003048 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003049#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003050#ifdef HAVE_TERMCAP_H
3051# include <termcap.h>
3052#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003053#if STDC_HEADERS
3054# include <stdlib.h>
3055# include <stddef.h>
3056#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003057main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003058{char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003059 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003060 vim_cv_tgent=zero
3061 ],[
3062 vim_cv_tgent=non-zero
3063 ],[
3064 AC_MSG_ERROR(failed to compile test program.)
3065 ])
3066 ])
3067
3068 if test "x$vim_cv_tgent" = "xzero" ; then
3069 AC_DEFINE(TGETENT_ZERO_ERR, 0)
3070 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003071fi
3072
3073AC_MSG_CHECKING(whether termcap.h contains ospeed)
3074AC_TRY_LINK([
3075#ifdef HAVE_TERMCAP_H
3076# include <termcap.h>
3077#endif
3078 ], [ospeed = 20000],
3079 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED),
3080 [AC_MSG_RESULT(no)
3081 AC_MSG_CHECKING(whether ospeed can be extern)
3082 AC_TRY_LINK([
3083#ifdef HAVE_TERMCAP_H
3084# include <termcap.h>
3085#endif
3086extern short ospeed;
3087 ], [ospeed = 20000],
3088 AC_MSG_RESULT(yes); AC_DEFINE(OSPEED_EXTERN),
3089 AC_MSG_RESULT(no))]
3090 )
3091
3092AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC])
3093AC_TRY_LINK([
3094#ifdef HAVE_TERMCAP_H
3095# include <termcap.h>
3096#endif
3097 ], [if (UP == 0 && BC == 0) PC = 1],
3098 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UP_BC_PC),
3099 [AC_MSG_RESULT(no)
3100 AC_MSG_CHECKING([whether UP, BC and PC can be extern])
3101 AC_TRY_LINK([
3102#ifdef HAVE_TERMCAP_H
3103# include <termcap.h>
3104#endif
3105extern char *UP, *BC, PC;
3106 ], [if (UP == 0 && BC == 0) PC = 1],
3107 AC_MSG_RESULT(yes); AC_DEFINE(UP_BC_PC_EXTERN),
3108 AC_MSG_RESULT(no))]
3109 )
3110
3111AC_MSG_CHECKING(whether tputs() uses outfuntype)
3112AC_TRY_COMPILE([
3113#ifdef HAVE_TERMCAP_H
3114# include <termcap.h>
3115#endif
3116 ], [extern int xx(); tputs("test", 1, (outfuntype)xx)],
3117 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OUTFUNTYPE),
3118 AC_MSG_RESULT(no))
3119
3120dnl On some SCO machines sys/select redefines struct timeval
3121AC_MSG_CHECKING([whether sys/select.h and sys/time.h may both be included])
3122AC_TRY_COMPILE([
3123#include <sys/types.h>
3124#include <sys/time.h>
3125#include <sys/select.h>], ,
3126 AC_MSG_RESULT(yes)
3127 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME),
3128 AC_MSG_RESULT(no))
3129
3130dnl AC_DECL_SYS_SIGLIST
3131
3132dnl Checks for pty.c (copied from screen) ==========================
3133AC_MSG_CHECKING(for /dev/ptc)
3134if test -r /dev/ptc; then
3135 AC_DEFINE(HAVE_DEV_PTC)
3136 AC_MSG_RESULT(yes)
3137else
3138 AC_MSG_RESULT(no)
3139fi
3140
3141AC_MSG_CHECKING(for SVR4 ptys)
3142if test -c /dev/ptmx ; then
3143 AC_TRY_LINK([], [ptsname(0);grantpt(0);unlockpt(0);],
3144 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SVR4_PTYS),
3145 AC_MSG_RESULT(no))
3146else
3147 AC_MSG_RESULT(no)
3148fi
3149
3150AC_MSG_CHECKING(for ptyranges)
3151if test -d /dev/ptym ; then
3152 pdir='/dev/ptym'
3153else
3154 pdir='/dev'
3155fi
3156dnl SCO uses ptyp%d
3157AC_EGREP_CPP(yes,
3158[#ifdef M_UNIX
3159 yes;
3160#endif
3161 ], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
3162dnl if test -c /dev/ptyp19; then
3163dnl ptys=`echo /dev/ptyp??`
3164dnl else
3165dnl ptys=`echo $pdir/pty??`
3166dnl fi
3167if test "$ptys" != "$pdir/pty??" ; then
3168 p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
3169 p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'`
3170 AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
3171 AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
3172 AC_MSG_RESULT([$p0 / $p1])
3173else
3174 AC_MSG_RESULT([don't know])
3175fi
3176
3177dnl **** pty mode/group handling ****
3178dnl
3179dnl support provided by Luke Mewburn <lm@rmit.edu.au>, 931222
Bram Moolenaar071d4272004-06-13 20:20:40 +00003180rm -f conftest_grp
Bram Moolenaar446cb832008-06-24 21:56:24 +00003181AC_CACHE_CHECK([default tty permissions/group], [vim_cv_tty_group],
3182 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003183 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003184#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003185#include <sys/types.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003186#if STDC_HEADERS
3187# include <stdlib.h>
3188# include <stddef.h>
3189#endif
3190#ifdef HAVE_UNISTD_H
3191#include <unistd.h>
3192#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003193#include <sys/stat.h>
3194#include <stdio.h>
3195main()
3196{
3197 struct stat sb;
3198 char *x,*ttyname();
3199 int om, m;
3200 FILE *fp;
3201
3202 if (!(x = ttyname(0))) exit(1);
3203 if (stat(x, &sb)) exit(1);
3204 om = sb.st_mode;
3205 if (om & 002) exit(0);
3206 m = system("mesg y");
3207 if (m == -1 || m == 127) exit(1);
3208 if (stat(x, &sb)) exit(1);
3209 m = sb.st_mode;
3210 if (chmod(x, om)) exit(1);
3211 if (m & 002) exit(0);
3212 if (sb.st_gid == getgid()) exit(1);
3213 if (!(fp=fopen("conftest_grp", "w")))
3214 exit(1);
3215 fprintf(fp, "%d\n", sb.st_gid);
3216 fclose(fp);
3217 exit(0);
3218}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003219 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003220 if test -f conftest_grp; then
3221 vim_cv_tty_group=`cat conftest_grp`
3222 if test "x$vim_cv_tty_mode" = "x" ; then
3223 vim_cv_tty_mode=0620
3224 fi
3225 AC_MSG_RESULT([pty mode: $vim_cv_tty_mode, group: $vim_cv_tty_group])
3226 else
3227 vim_cv_tty_group=world
Bram Moolenaar72951072009-12-02 16:58:33 +00003228 AC_MSG_RESULT([ptys are world accessible])
Bram Moolenaar446cb832008-06-24 21:56:24 +00003229 fi
3230 ],[
3231 vim_cv_tty_group=world
Bram Moolenaar72951072009-12-02 16:58:33 +00003232 AC_MSG_RESULT([can't determine - assume ptys are world accessible])
Bram Moolenaar446cb832008-06-24 21:56:24 +00003233 ],[
3234 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_tty_group' and 'vim_cv_tty_mode')
3235 ])
3236 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003237rm -f conftest_grp
3238
Bram Moolenaar446cb832008-06-24 21:56:24 +00003239if test "x$vim_cv_tty_group" != "xworld" ; then
3240 AC_DEFINE_UNQUOTED(PTYGROUP,$vim_cv_tty_group)
3241 if test "x$vim_cv_tty_mode" = "x" ; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02003242 AC_MSG_ERROR([It seems you're cross compiling and have 'vim_cv_tty_group' set, please also set the environment variable 'vim_cv_tty_mode' to the correct mode (probably 0620)])
Bram Moolenaar446cb832008-06-24 21:56:24 +00003243 else
3244 AC_DEFINE(PTYMODE, 0620)
3245 fi
3246fi
3247
Bram Moolenaar071d4272004-06-13 20:20:40 +00003248dnl Checks for library functions. ===================================
3249
3250AC_TYPE_SIGNAL
3251
3252dnl find out what to use at the end of a signal function
3253if test $ac_cv_type_signal = void; then
3254 AC_DEFINE(SIGRETURN, [return])
3255else
3256 AC_DEFINE(SIGRETURN, [return 0])
3257fi
3258
3259dnl check if struct sigcontext is defined (used for SGI only)
3260AC_MSG_CHECKING(for struct sigcontext)
3261AC_TRY_COMPILE([
3262#include <signal.h>
3263test_sig()
3264{
3265 struct sigcontext *scont;
3266 scont = (struct sigcontext *)0;
3267 return 1;
3268} ], ,
3269 AC_MSG_RESULT(yes)
3270 AC_DEFINE(HAVE_SIGCONTEXT),
3271 AC_MSG_RESULT(no))
3272
3273dnl tricky stuff: try to find out if getcwd() is implemented with
3274dnl system("sh -c pwd")
Bram Moolenaar446cb832008-06-24 21:56:24 +00003275AC_CACHE_CHECK([getcwd implementation is broken], [vim_cv_getcwd_broken],
3276 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003277 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003278#include "confdefs.h"
3279#ifdef HAVE_UNISTD_H
3280#include <unistd.h>
3281#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003282char *dagger[] = { "IFS=pwd", 0 };
3283main()
3284{
3285 char buffer[500];
3286 extern char **environ;
3287 environ = dagger;
3288 return getcwd(buffer, 500) ? 0 : 1;
Bram Moolenaar446cb832008-06-24 21:56:24 +00003289}
Bram Moolenaar7db77842014-03-27 17:40:59 +01003290 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003291 vim_cv_getcwd_broken=no
3292 ],[
3293 vim_cv_getcwd_broken=yes
3294 ],[
3295 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_getcwd_broken')
3296 ])
3297 ])
3298
3299if test "x$vim_cv_getcwd_broken" = "xyes" ; then
3300 AC_DEFINE(BAD_GETCWD)
3301fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003302
Bram Moolenaar25153e12010-02-24 14:47:08 +01003303dnl Check for functions in one big call, to reduce the size of configure.
3304dnl Can only be used for functions that do not require any include.
3305AC_CHECK_FUNCS(bcmp fchdir fchown fsync getcwd getpseudotty \
Bram Moolenaar24305862012-08-15 14:05:05 +02003306 getpwent getpwnam getpwuid getrlimit gettimeofday getwd lstat memcmp \
Bram Moolenaareaf03392009-11-17 11:08:52 +00003307 memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
Bram Moolenaar071d4272004-06-13 20:20:40 +00003308 setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
Bram Moolenaar051b7822005-05-19 21:00:46 +00003309 sigvec strcasecmp strerror strftime stricmp strncasecmp \
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00003310 strnicmp strpbrk strtol tgetent towlower towupper iswupper \
3311 usleep utime utimes)
Bram Moolenaar25153e12010-02-24 14:47:08 +01003312AC_FUNC_FSEEKO
Bram Moolenaar071d4272004-06-13 20:20:40 +00003313
Bram Moolenaar317fd3a2010-05-07 16:05:55 +02003314dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when
3315dnl appropriate, so that off_t is 64 bits when needed.
3316AC_SYS_LARGEFILE
3317
Bram Moolenaar071d4272004-06-13 20:20:40 +00003318dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible
3319AC_MSG_CHECKING(for st_blksize)
3320AC_TRY_COMPILE(
3321[#include <sys/types.h>
3322#include <sys/stat.h>],
3323[ struct stat st;
3324 int n;
3325
3326 stat("/", &st);
3327 n = (int)st.st_blksize;],
3328 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ST_BLKSIZE),
3329 AC_MSG_RESULT(no))
3330
Bram Moolenaar446cb832008-06-24 21:56:24 +00003331AC_CACHE_CHECK([whether stat() ignores a trailing slash], [vim_cv_stat_ignores_slash],
3332 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003333 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003334#include "confdefs.h"
3335#if STDC_HEADERS
3336# include <stdlib.h>
3337# include <stddef.h>
3338#endif
3339#include <sys/types.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003340#include <sys/stat.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003341main() {struct stat st; exit(stat("configure/", &st) != 0); }
Bram Moolenaar7db77842014-03-27 17:40:59 +01003342 ]])],[
Bram Moolenaar446cb832008-06-24 21:56:24 +00003343 vim_cv_stat_ignores_slash=yes
3344 ],[
3345 vim_cv_stat_ignores_slash=no
3346 ],[
3347 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_stat_ignores_slash')
3348 ])
3349 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003350
Bram Moolenaar446cb832008-06-24 21:56:24 +00003351if test "x$vim_cv_stat_ignores_slash" = "xyes" ; then
3352 AC_DEFINE(STAT_IGNORES_SLASH)
3353fi
3354
Bram Moolenaar071d4272004-06-13 20:20:40 +00003355dnl Link with iconv for charset translation, if not found without library.
3356dnl check for iconv() requires including iconv.h
3357dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
3358dnl has been installed.
3359AC_MSG_CHECKING(for iconv_open())
3360save_LIBS="$LIBS"
3361LIBS="$LIBS -liconv"
3362AC_TRY_LINK([
3363#ifdef HAVE_ICONV_H
3364# include <iconv.h>
3365#endif
3366 ], [iconv_open("fr", "to");],
3367 AC_MSG_RESULT(yes; with -liconv); AC_DEFINE(HAVE_ICONV),
3368 LIBS="$save_LIBS"
3369 AC_TRY_LINK([
3370#ifdef HAVE_ICONV_H
3371# include <iconv.h>
3372#endif
3373 ], [iconv_open("fr", "to");],
3374 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ICONV),
3375 AC_MSG_RESULT(no)))
3376
3377
3378AC_MSG_CHECKING(for nl_langinfo(CODESET))
3379AC_TRY_LINK([
3380#ifdef HAVE_LANGINFO_H
3381# include <langinfo.h>
3382#endif
3383], [char *cs = nl_langinfo(CODESET);],
3384 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET),
3385 AC_MSG_RESULT(no))
3386
Bram Moolenaar446cb832008-06-24 21:56:24 +00003387dnl Need various functions for floating point support. Only enable
3388dnl floating point when they are all present.
3389AC_CHECK_LIB(m, strtod)
3390AC_MSG_CHECKING([for strtod() and other floating point functions])
3391AC_TRY_LINK([
3392#ifdef HAVE_MATH_H
3393# include <math.h>
3394#endif
3395#if STDC_HEADERS
3396# include <stdlib.h>
3397# include <stddef.h>
3398#endif
3399], [char *s; double d;
3400 d = strtod("1.1", &s);
3401 d = fabs(1.11);
3402 d = ceil(1.11);
3403 d = floor(1.11);
3404 d = log10(1.11);
3405 d = pow(1.11, 2.22);
3406 d = sqrt(1.11);
3407 d = sin(1.11);
3408 d = cos(1.11);
3409 d = atan(1.11);
3410 ],
3411 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT_FUNCS),
3412 AC_MSG_RESULT(no))
3413
Bram Moolenaar071d4272004-06-13 20:20:40 +00003414dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI
3415dnl when -lacl works, also try to use -lattr (required for Debian).
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003416dnl On Solaris, use the acl_get/set functions in libsec, if present.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003417AC_MSG_CHECKING(--disable-acl argument)
3418AC_ARG_ENABLE(acl,
3419 [ --disable-acl Don't check for ACL support.],
3420 , [enable_acl="yes"])
3421if test "$enable_acl" = "yes"; then
3422AC_MSG_RESULT(no)
3423AC_CHECK_LIB(posix1e, acl_get_file, [LIBS="$LIBS -lposix1e"],
3424 AC_CHECK_LIB(acl, acl_get_file, [LIBS="$LIBS -lacl"
3425 AC_CHECK_LIB(attr, fgetxattr, LIBS="$LIBS -lattr",,)],,),)
3426
3427AC_MSG_CHECKING(for POSIX ACL support)
3428AC_TRY_LINK([
3429#include <sys/types.h>
3430#ifdef HAVE_SYS_ACL_H
3431# include <sys/acl.h>
3432#endif
3433acl_t acl;], [acl = acl_get_file("foo", ACL_TYPE_ACCESS);
3434 acl_set_file("foo", ACL_TYPE_ACCESS, acl);
3435 acl_free(acl);],
3436 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_ACL),
3437 AC_MSG_RESULT(no))
3438
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003439AC_CHECK_LIB(sec, acl_get, [LIBS="$LIBS -lsec"; AC_DEFINE(HAVE_SOLARIS_ZFS_ACL)],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003440AC_MSG_CHECKING(for Solaris ACL support)
3441AC_TRY_LINK([
3442#ifdef HAVE_SYS_ACL_H
3443# include <sys/acl.h>
3444#endif], [acl("foo", GETACLCNT, 0, NULL);
3445 ],
3446 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOLARIS_ACL),
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003447 AC_MSG_RESULT(no)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003448
3449AC_MSG_CHECKING(for AIX ACL support)
3450AC_TRY_LINK([
Bram Moolenaar446cb832008-06-24 21:56:24 +00003451#if STDC_HEADERS
3452# include <stdlib.h>
3453# include <stddef.h>
3454#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003455#ifdef HAVE_SYS_ACL_H
3456# include <sys/acl.h>
3457#endif
3458#ifdef HAVE_SYS_ACCESS_H
3459# include <sys/access.h>
3460#endif
3461#define _ALL_SOURCE
3462
3463#include <sys/stat.h>
3464
3465int aclsize;
3466struct acl *aclent;], [aclsize = sizeof(struct acl);
3467 aclent = (void *)malloc(aclsize);
3468 statacl("foo", STX_NORMAL, aclent, aclsize);
3469 ],
3470 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_AIX_ACL),
3471 AC_MSG_RESULT(no))
3472else
3473 AC_MSG_RESULT(yes)
3474fi
3475
3476AC_MSG_CHECKING(--disable-gpm argument)
3477AC_ARG_ENABLE(gpm,
3478 [ --disable-gpm Don't use gpm (Linux mouse daemon).], ,
3479 [enable_gpm="yes"])
3480
3481if test "$enable_gpm" = "yes"; then
3482 AC_MSG_RESULT(no)
3483 dnl Checking if gpm support can be compiled
3484 AC_CACHE_CHECK([for gpm], vi_cv_have_gpm,
3485 [olibs="$LIBS" ; LIBS="-lgpm"]
3486 AC_TRY_LINK(
3487 [#include <gpm.h>
3488 #include <linux/keyboard.h>],
3489 [Gpm_GetLibVersion(NULL);],
3490 dnl Configure defines HAVE_GPM, if it is defined feature.h defines
3491 dnl FEAT_MOUSE_GPM if mouse support is included
3492 [vi_cv_have_gpm=yes],
3493 [vi_cv_have_gpm=no])
3494 [LIBS="$olibs"]
3495 )
3496 if test $vi_cv_have_gpm = yes; then
3497 LIBS="$LIBS -lgpm"
3498 AC_DEFINE(HAVE_GPM)
3499 fi
3500else
3501 AC_MSG_RESULT(yes)
3502fi
3503
Bram Moolenaar446cb832008-06-24 21:56:24 +00003504AC_MSG_CHECKING(--disable-sysmouse argument)
3505AC_ARG_ENABLE(sysmouse,
3506 [ --disable-sysmouse Don't use sysmouse (mouse in *BSD console).], ,
3507 [enable_sysmouse="yes"])
3508
3509if test "$enable_sysmouse" = "yes"; then
3510 AC_MSG_RESULT(no)
3511 dnl Checking if sysmouse support can be compiled
3512 dnl Configure defines HAVE_SYSMOUSE, if it is defined feature.h
3513 dnl defines FEAT_SYSMOUSE if mouse support is included
3514 AC_CACHE_CHECK([for sysmouse], vi_cv_have_sysmouse,
3515 AC_TRY_LINK(
3516 [#include <sys/consio.h>
3517 #include <signal.h>
3518 #include <sys/fbio.h>],
3519 [struct mouse_info mouse;
3520 mouse.operation = MOUSE_MODE;
3521 mouse.operation = MOUSE_SHOW;
3522 mouse.u.mode.mode = 0;
3523 mouse.u.mode.signal = SIGUSR2;],
3524 [vi_cv_have_sysmouse=yes],
3525 [vi_cv_have_sysmouse=no])
3526 )
3527 if test $vi_cv_have_sysmouse = yes; then
3528 AC_DEFINE(HAVE_SYSMOUSE)
3529 fi
3530else
3531 AC_MSG_RESULT(yes)
3532fi
3533
Bram Moolenaarf05da212009-11-17 16:13:15 +00003534dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
3535AC_MSG_CHECKING(for FD_CLOEXEC)
3536AC_TRY_COMPILE(
3537[#if HAVE_FCNTL_H
3538# include <fcntl.h>
3539#endif],
3540[ int flag = FD_CLOEXEC;],
3541 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
3542 AC_MSG_RESULT(not usable))
3543
Bram Moolenaar071d4272004-06-13 20:20:40 +00003544dnl rename needs to be checked separately to work on Nextstep with cc
3545AC_MSG_CHECKING(for rename)
3546AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
3547 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
3548 AC_MSG_RESULT(no))
3549
3550dnl sysctl() may exist but not the arguments we use
3551AC_MSG_CHECKING(for sysctl)
3552AC_TRY_COMPILE(
3553[#include <sys/types.h>
3554#include <sys/sysctl.h>],
3555[ int mib[2], r;
3556 size_t len;
3557
3558 mib[0] = CTL_HW;
3559 mib[1] = HW_USERMEM;
3560 len = sizeof(r);
3561 (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
3562 ],
3563 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL),
3564 AC_MSG_RESULT(not usable))
3565
3566dnl sysinfo() may exist but not be Linux compatible
3567AC_MSG_CHECKING(for sysinfo)
3568AC_TRY_COMPILE(
3569[#include <sys/types.h>
3570#include <sys/sysinfo.h>],
3571[ struct sysinfo sinfo;
3572 int t;
3573
3574 (void)sysinfo(&sinfo);
3575 t = sinfo.totalram;
3576 ],
3577 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
3578 AC_MSG_RESULT(not usable))
3579
Bram Moolenaar914572a2007-05-01 11:37:47 +00003580dnl struct sysinfo may have the mem_unit field or not
3581AC_MSG_CHECKING(for sysinfo.mem_unit)
3582AC_TRY_COMPILE(
3583[#include <sys/types.h>
3584#include <sys/sysinfo.h>],
3585[ struct sysinfo sinfo;
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02003586 sinfo.mem_unit = 1;
Bram Moolenaar914572a2007-05-01 11:37:47 +00003587 ],
3588 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_MEM_UNIT),
3589 AC_MSG_RESULT(no))
3590
Bram Moolenaar071d4272004-06-13 20:20:40 +00003591dnl sysconf() may exist but not support what we want to use
3592AC_MSG_CHECKING(for sysconf)
3593AC_TRY_COMPILE(
3594[#include <unistd.h>],
3595[ (void)sysconf(_SC_PAGESIZE);
3596 (void)sysconf(_SC_PHYS_PAGES);
3597 ],
3598 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
3599 AC_MSG_RESULT(not usable))
3600
Bram Moolenaar914703b2010-05-31 21:59:46 +02003601AC_CHECK_SIZEOF([int])
3602AC_CHECK_SIZEOF([long])
3603AC_CHECK_SIZEOF([time_t])
3604AC_CHECK_SIZEOF([off_t])
Bram Moolenaar644fdff2010-05-30 13:26:21 +02003605
Bram Moolenaara2aa31a2014-02-23 22:52:40 +01003606dnl Use different names to avoid clashing with other header files.
3607AC_DEFINE_UNQUOTED(VIM_SIZEOF_INT, [$ac_cv_sizeof_int])
3608AC_DEFINE_UNQUOTED(VIM_SIZEOF_LONG, [$ac_cv_sizeof_long])
3609
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003610dnl Make sure that uint32_t is really 32 bits unsigned.
3611AC_MSG_CHECKING([uint32_t is 32 bits])
3612AC_TRY_RUN([
3613#ifdef HAVE_STDINT_H
3614# include <stdint.h>
3615#endif
3616#ifdef HAVE_INTTYPES_H
3617# include <inttypes.h>
3618#endif
3619main() {
3620 uint32_t nr1 = (uint32_t)-1;
3621 uint32_t nr2 = (uint32_t)0xffffffffUL;
3622 if (sizeof(uint32_t) != 4 || nr1 != 0xffffffffUL || nr2 + 1 != 0) exit(1);
3623 exit(0);
3624}],
3625AC_MSG_RESULT(ok),
3626AC_MSG_ERROR([WRONG! uint32_t not defined correctly.]),
Bram Moolenaar323cb952011-12-14 19:22:34 +01003627AC_MSG_WARN([cannot check uint32_t when cross-compiling.]))
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003628
Bram Moolenaar446cb832008-06-24 21:56:24 +00003629dnl Check for memmove() before bcopy(), makes memmove() be used when both are
3630dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
3631
Bram Moolenaar071d4272004-06-13 20:20:40 +00003632[bcopy_test_prog='
Bram Moolenaar446cb832008-06-24 21:56:24 +00003633#include "confdefs.h"
3634#ifdef HAVE_STRING_H
3635# include <string.h>
3636#endif
3637#if STDC_HEADERS
3638# include <stdlib.h>
3639# include <stddef.h>
3640#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003641main() {
3642 char buf[10];
3643 strcpy(buf, "abcdefghi");
3644 mch_memmove(buf, buf + 2, 3);
3645 if (strncmp(buf, "ababcf", 6))
3646 exit(1);
3647 strcpy(buf, "abcdefghi");
3648 mch_memmove(buf + 2, buf, 3);
3649 if (strncmp(buf, "cdedef", 6))
3650 exit(1);
3651 exit(0); /* libc version works properly. */
3652}']
3653
Bram Moolenaar446cb832008-06-24 21:56:24 +00003654AC_CACHE_CHECK([whether memmove handles overlaps],[vim_cv_memmove_handles_overlap],
3655 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003656 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 +00003657 [
3658 vim_cv_memmove_handles_overlap=yes
3659 ],[
3660 vim_cv_memmove_handles_overlap=no
3661 ],[
3662 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memmove_handles_overlap')
3663 ])
3664 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003665
Bram Moolenaar446cb832008-06-24 21:56:24 +00003666if test "x$vim_cv_memmove_handles_overlap" = "xyes" ; then
3667 AC_DEFINE(USEMEMMOVE)
3668else
3669 AC_CACHE_CHECK([whether bcopy handles overlaps],[vim_cv_bcopy_handles_overlap],
3670 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003671 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 +00003672 [
3673 vim_cv_bcopy_handles_overlap=yes
3674 ],[
3675 vim_cv_bcopy_handles_overlap=no
3676 ],[
3677 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_bcopy_handles_overlap')
3678 ])
3679 ])
3680
3681 if test "x$vim_cv_bcopy_handles_overlap" = "xyes" ; then
3682 AC_DEFINE(USEBCOPY)
3683 else
3684 AC_CACHE_CHECK([whether memcpy handles overlaps],[vim_cv_memcpy_handles_overlap],
3685 [
Bram Moolenaar7db77842014-03-27 17:40:59 +01003686 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 +00003687 [
3688 vim_cv_memcpy_handles_overlap=yes
3689 ],[
3690 vim_cv_memcpy_handles_overlap=no
3691 ],[
3692 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memcpy_handles_overlap')
3693 ])
3694 ])
3695
3696 if test "x$vim_cv_memcpy_handles_overlap" = "xyes" ; then
3697 AC_DEFINE(USEMEMCPY)
3698 fi
3699 fi
3700fi
3701
Bram Moolenaar071d4272004-06-13 20:20:40 +00003702
3703dnl Check for multibyte locale functions
3704dnl Find out if _Xsetlocale() is supported by libX11.
3705dnl Check if X_LOCALE should be defined.
3706
3707if test "$enable_multibyte" = "yes"; then
3708 cflags_save=$CFLAGS
3709 ldflags_save=$LDFLAGS
Bram Moolenaar94ba1ce2009-04-22 15:53:09 +00003710 if test "x$x_includes" != "xNONE" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003711 CFLAGS="$CFLAGS -I$x_includes"
3712 LDFLAGS="$X_LIBS $LDFLAGS -lX11"
3713 AC_MSG_CHECKING(whether X_LOCALE needed)
3714 AC_TRY_COMPILE([#include <X11/Xlocale.h>],,
3715 AC_TRY_LINK_FUNC([_Xsetlocale], [AC_MSG_RESULT(yes)
3716 AC_DEFINE(X_LOCALE)], AC_MSG_RESULT(no)),
3717 AC_MSG_RESULT(no))
3718 fi
3719 CFLAGS=$cflags_save
3720 LDFLAGS=$ldflags_save
3721fi
3722
3723dnl Link with xpg4, it is said to make Korean locale working
3724AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,)
3725
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00003726dnl Check how we can run ctags. Default to "ctags" when nothing works.
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02003727dnl Use --version to detect Exuberant ctags (preferred)
Bram Moolenaarb21e5842006-04-16 18:30:08 +00003728dnl Add --fields=+S to get function signatures for omni completion.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003729dnl -t for typedefs (many ctags have this)
3730dnl -s for static functions (Elvis ctags only?)
3731dnl -v for variables. Dangerous, most ctags take this for 'vgrind style'.
3732dnl -i+m to test for older Exuberant ctags
3733AC_MSG_CHECKING(how to create tags)
3734test -f tags && mv tags tags.save
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02003735if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaarb21e5842006-04-16 18:30:08 +00003736 TAGPRG="ctags -I INIT+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02003737elif (eval exctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
3738 TAGPRG="exctags -I INIT+ --fields=+S"
3739elif (eval exuberant-ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
3740 TAGPRG="exuberant-ctags -I INIT+ --fields=+S"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003741else
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00003742 TAGPRG="ctags"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003743 (eval etags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags"
3744 (eval etags -c /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags -c"
3745 (eval ctags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags"
3746 (eval ctags -t /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -t"
3747 (eval ctags -ts /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -ts"
3748 (eval ctags -tvs /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -tvs"
3749 (eval ctags -i+m /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -i+m"
3750fi
3751test -f tags.save && mv tags.save tags
3752AC_MSG_RESULT($TAGPRG) AC_SUBST(TAGPRG)
3753
3754dnl Check how we can run man with a section number
3755AC_MSG_CHECKING(how to run man with a section nr)
3756MANDEF="man"
Bram Moolenaar8b131502008-02-13 09:28:19 +00003757(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 +00003758AC_MSG_RESULT($MANDEF)
3759if test "$MANDEF" = "man -s"; then
3760 AC_DEFINE(USEMAN_S)
3761fi
3762
3763dnl Check if gettext() is working and if it needs -lintl
Bram Moolenaar49b6a572013-11-17 20:32:54 +01003764dnl We take care to base this on an empty LIBS: on some systems libelf would be
3765dnl in LIBS and implicitly take along libintl. The final LIBS would then not
3766dnl contain libintl, and the link step would fail due to -Wl,--as-needed.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003767AC_MSG_CHECKING(--disable-nls argument)
3768AC_ARG_ENABLE(nls,
3769 [ --disable-nls Don't support NLS (gettext()).], ,
3770 [enable_nls="yes"])
3771
3772if test "$enable_nls" = "yes"; then
3773 AC_MSG_RESULT(no)
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00003774
3775 INSTALL_LANGS=install-languages
3776 AC_SUBST(INSTALL_LANGS)
3777 INSTALL_TOOL_LANGS=install-tool-languages
3778 AC_SUBST(INSTALL_TOOL_LANGS)
3779
Bram Moolenaar071d4272004-06-13 20:20:40 +00003780 AC_CHECK_PROG(MSGFMT, msgfmt, msgfmt, )
3781 AC_MSG_CHECKING([for NLS])
3782 if test -f po/Makefile; then
3783 have_gettext="no"
3784 if test -n "$MSGFMT"; then
Bram Moolenaar49b6a572013-11-17 20:32:54 +01003785 olibs=$LIBS
3786 LIBS=""
Bram Moolenaar071d4272004-06-13 20:20:40 +00003787 AC_TRY_LINK(
3788 [#include <libintl.h>],
3789 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01003790 AC_MSG_RESULT([gettext() works]); have_gettext="yes"; LIBS=$olibs,
3791 LIBS="-lintl"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003792 AC_TRY_LINK(
3793 [#include <libintl.h>],
3794 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01003795 AC_MSG_RESULT([gettext() works with -lintl]); have_gettext="yes";
3796 LIBS="$olibs -lintl",
Bram Moolenaar071d4272004-06-13 20:20:40 +00003797 AC_MSG_RESULT([gettext() doesn't work]);
3798 LIBS=$olibs))
3799 else
3800 AC_MSG_RESULT([msgfmt not found - disabled]);
3801 fi
3802 if test $have_gettext = "yes"; then
3803 AC_DEFINE(HAVE_GETTEXT)
3804 MAKEMO=yes
3805 AC_SUBST(MAKEMO)
3806 dnl this was added in GNU gettext 0.10.36
3807 AC_CHECK_FUNCS(bind_textdomain_codeset)
3808 dnl _nl_msg_cat_cntr is required for GNU gettext
3809 AC_MSG_CHECKING([for _nl_msg_cat_cntr])
3810 AC_TRY_LINK(
3811 [#include <libintl.h>
3812 extern int _nl_msg_cat_cntr;],
3813 [++_nl_msg_cat_cntr;],
3814 AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_NL_MSG_CAT_CNTR),
3815 AC_MSG_RESULT([no]))
3816 fi
3817 else
3818 AC_MSG_RESULT([no "po/Makefile" - disabled]);
3819 fi
3820else
3821 AC_MSG_RESULT(yes)
3822fi
3823
3824dnl Check for dynamic linking loader
3825AC_CHECK_HEADER(dlfcn.h, DLL=dlfcn.h, [AC_CHECK_HEADER(dl.h, DLL=dl.h)])
3826if test x${DLL} = xdlfcn.h; then
3827 AC_DEFINE(HAVE_DLFCN_H, 1, [ Define if we have dlfcn.h. ])
3828 AC_MSG_CHECKING([for dlopen()])
3829 AC_TRY_LINK(,[
3830 extern void* dlopen();
3831 dlopen();
3832 ],
3833 AC_MSG_RESULT(yes);
3834 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
3835 AC_MSG_RESULT(no);
3836 AC_MSG_CHECKING([for dlopen() in -ldl])
3837 olibs=$LIBS
3838 LIBS="$LIBS -ldl"
3839 AC_TRY_LINK(,[
3840 extern void* dlopen();
3841 dlopen();
3842 ],
3843 AC_MSG_RESULT(yes);
3844 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
3845 AC_MSG_RESULT(no);
3846 LIBS=$olibs))
3847 dnl ReliantUNIX has dlopen() in libc but everything else in libdl
3848 dnl ick :-)
3849 AC_MSG_CHECKING([for dlsym()])
3850 AC_TRY_LINK(,[
3851 extern void* dlsym();
3852 dlsym();
3853 ],
3854 AC_MSG_RESULT(yes);
3855 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
3856 AC_MSG_RESULT(no);
3857 AC_MSG_CHECKING([for dlsym() in -ldl])
3858 olibs=$LIBS
3859 LIBS="$LIBS -ldl"
3860 AC_TRY_LINK(,[
3861 extern void* dlsym();
3862 dlsym();
3863 ],
3864 AC_MSG_RESULT(yes);
3865 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
3866 AC_MSG_RESULT(no);
3867 LIBS=$olibs))
3868elif test x${DLL} = xdl.h; then
3869 AC_DEFINE(HAVE_DL_H, 1, [ Define if we have dl.h. ])
3870 AC_MSG_CHECKING([for shl_load()])
3871 AC_TRY_LINK(,[
3872 extern void* shl_load();
3873 shl_load();
3874 ],
3875 AC_MSG_RESULT(yes);
3876 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
3877 AC_MSG_RESULT(no);
3878 AC_MSG_CHECKING([for shl_load() in -ldld])
3879 olibs=$LIBS
3880 LIBS="$LIBS -ldld"
3881 AC_TRY_LINK(,[
3882 extern void* shl_load();
3883 shl_load();
3884 ],
3885 AC_MSG_RESULT(yes);
3886 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
3887 AC_MSG_RESULT(no);
3888 LIBS=$olibs))
3889fi
3890AC_CHECK_HEADERS(setjmp.h)
3891
3892if test "x$MACOSX" = "xyes" -a -n "$PERL"; then
3893 dnl -ldl must come after DynaLoader.a
3894 if echo $LIBS | grep -e '-ldl' >/dev/null; then
3895 LIBS=`echo $LIBS | sed s/-ldl//`
3896 PERL_LIBS="$PERL_LIBS -ldl"
3897 fi
3898fi
3899
Bram Moolenaar164fca32010-07-14 13:58:07 +02003900if test "x$MACOSX" = "xyes"; then
3901 AC_MSG_CHECKING(whether we need -framework Cocoa)
3902 dnl Cocoa is needed with FEAT_CLIPBOARD or FEAT_MBYTE (the former is
3903 dnl disabled during tiny build)
3904 if test "x$features" != "xtiny" || test "x$enable_multibyte" = "xyes"; then
3905 LIBS=$"$LIBS -framework Cocoa"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003906 AC_MSG_RESULT(yes)
3907 else
3908 AC_MSG_RESULT(no)
3909 fi
Bram Moolenaar3437b912013-07-03 19:52:53 +02003910 dnl As mentioned above, tiny build implies os_macosx.m isn't needed.
3911 dnl Exclude it from OS_EXTRA_SRC so that linker won't complain about
3912 dnl missing Objective-C symbols.
3913 if test "x$features" = "xtiny"; then
3914 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_macosx.m++'`
3915 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_macosx.o++'`
3916 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003917fi
Bram Moolenaar164fca32010-07-14 13:58:07 +02003918if test "x$MACARCH" = "xboth" && test "x$GUITYPE" = "xCARBONGUI"; then
Bram Moolenaar595a7be2010-03-10 16:28:12 +01003919 LDFLAGS="$LDFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +00003920fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003921
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00003922dnl gcc 3.1 changed the meaning of -MM. The only solution appears to be to
3923dnl use "-isystem" instead of "-I" for all non-Vim include dirs.
3924dnl But only when making dependencies, cproto and lint don't take "-isystem".
Bram Moolenaar32466aa2006-02-24 23:53:04 +00003925dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
3926dnl the number before the version number.
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00003927DEPEND_CFLAGS_FILTER=
3928if test "$GCC" = yes; then
Bram Moolenaar0cd49302008-11-20 09:37:01 +00003929 AC_MSG_CHECKING(for GCC 3 or later)
Bram Moolenaar2217cae2006-03-25 21:55:52 +00003930 gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]]\)\..*$/\1/g'`
Bram Moolenaarf740b292006-02-16 22:11:02 +00003931 if test "$gccmajor" -gt "2"; then
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00003932 DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
Bram Moolenaar0cd49302008-11-20 09:37:01 +00003933 AC_MSG_RESULT(yes)
3934 else
3935 AC_MSG_RESULT(no)
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00003936 fi
Bram Moolenaar0cd49302008-11-20 09:37:01 +00003937 dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
3938 dnl declared as char x[1] but actually longer. Introduced in gcc 4.0.
Bram Moolenaar56d1db32009-12-16 16:14:51 +00003939 dnl Also remove duplicate _FORTIFY_SOURCE arguments.
Bram Moolenaaraeabe052011-12-08 15:17:34 +01003940 dnl And undefine it first to avoid a warning.
Bram Moolenaar0cd49302008-11-20 09:37:01 +00003941 AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
3942 if test "$gccmajor" -gt "3"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02003943 CFLAGS=`echo "$CFLAGS" | sed -e 's/ *-Wp,-D_FORTIFY_SOURCE=.//g' -e 's/ *-D_FORTIFY_SOURCE=.//g' -e 's/ *-U_FORTIFY_SOURCE//g' -e 's/$/ -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1/'`
Bram Moolenaar0cd49302008-11-20 09:37:01 +00003944 AC_MSG_RESULT(yes)
3945 else
3946 AC_MSG_RESULT(no)
3947 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +00003948fi
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00003949AC_SUBST(DEPEND_CFLAGS_FILTER)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003950
Bram Moolenaar22e193d2010-11-03 22:32:24 +01003951dnl link.sh tries to avoid overlinking in a hackish way.
3952dnl At least GNU ld supports --as-needed which provides the same functionality
3953dnl at linker level. Let's use it.
3954AC_MSG_CHECKING(linker --as-needed support)
3955LINK_AS_NEEDED=
3956# Check if linker supports --as-needed and --no-as-needed options
3957if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02003958 LDFLAGS=`echo "$LDFLAGS" | sed -e 's/ *-Wl,--as-needed//g' | sed -e 's/$/ -Wl,--as-needed/'`
Bram Moolenaar22e193d2010-11-03 22:32:24 +01003959 LINK_AS_NEEDED=yes
3960fi
3961if test "$LINK_AS_NEEDED" = yes; then
3962 AC_MSG_RESULT(yes)
3963else
3964 AC_MSG_RESULT(no)
3965fi
3966AC_SUBST(LINK_AS_NEEDED)
3967
Bram Moolenaar77c19352012-06-13 19:19:41 +02003968# IBM z/OS reset CFLAGS for config.mk
3969if test "$zOSUnix" = "yes"; then
3970 CFLAGS="-D_ALL_SOURCE -Wc,float\(ieee\),dll"
3971fi
3972
Bram Moolenaar071d4272004-06-13 20:20:40 +00003973dnl write output files
3974AC_OUTPUT(auto/config.mk:config.mk.in)
3975
3976dnl vim: set sw=2 tw=78 fo+=l: