blob: 11e1d63d96d8d79c415e0ba6e2b9397f68be5ed8 [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
17AC_ISC_POSIX dnl required by AC_C_CROSS
18AC_PROG_AWK dnl required for "make html" in ../doc
19
20dnl Don't strip if we don't have it
21AC_CHECK_PROG(STRIP, strip, strip, :)
22
Bram Moolenaar325b7a22004-07-05 15:58:32 +000023dnl Check for extension of executables
Bram Moolenaar071d4272004-06-13 20:20:40 +000024AC_EXEEXT
25
Bram Moolenaar446cb832008-06-24 21:56:24 +000026dnl Check for standard headers. We don't use this in Vim but other stuff
27dnl in autoconf needs it, where it uses STDC_HEADERS.
28AC_HEADER_STDC
29AC_HEADER_SYS_WAIT
30
Bram Moolenaarf788a062011-12-14 20:51:25 +010031dnl Check for the flag that fails if stuff are missing.
32
33AC_MSG_CHECKING(--enable-fail-if-missing argument)
34AC_ARG_ENABLE(fail_if_missing,
35 [ --enable-fail-if-missing Fail if dependencies on additional features
36 specified on the command line are missing.],
37 [fail_if_missing="yes"],
38 [fail_if_missing="no"])
39AC_MSG_RESULT($fail_if_missing)
40
Bram Moolenaar071d4272004-06-13 20:20:40 +000041dnl Set default value for CFLAGS if none is defined or it's empty
42if test -z "$CFLAGS"; then
43 CFLAGS="-O"
44 test "$GCC" = yes && CFLAGS="-O2 -fno-strength-reduce -Wall"
45fi
46if test "$GCC" = yes; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +000047 dnl method that should work for nearly all versions
48 gccversion=`"$CC" -dumpversion`
49 if test "x$gccversion" = "x"; then
50 dnl old method; fall-back for when -dumpversion doesn't work
51 gccversion=`"$CC" --version | sed -e '2,$d' -e 's/darwin.//' -e 's/^[[^0-9]]*\([[0-9]]\.[[0-9.]]*\).*$/\1/g'`
52 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +000053 dnl version 4.0.1 was reported to cause trouble on Macintosh by Marcin Dalecki
54 if test "$gccversion" = "3.0.1" -o "$gccversion" = "3.0.2" -o "$gccversion" = "4.0.1"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +000055 echo 'GCC [[34]].0.[[12]] has a bug in the optimizer, disabling "-O#"'
Bram Moolenaar071d4272004-06-13 20:20:40 +000056 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-O/'`
57 else
58 if test "$gccversion" = "3.1" -o "$gccversion" = "3.2" -o "$gccversion" = "3.2.1" && `echo "$CFLAGS" | grep -v fno-strength-reduce >/dev/null`; then
59 echo 'GCC 3.1 and 3.2 have a bug in the optimizer, adding "-fno-strength-reduce"'
60 CFLAGS="$CFLAGS -fno-strength-reduce"
61 fi
62 fi
63fi
64
Bram Moolenaar0c6ccfd2013-10-02 18:23:07 +020065dnl clang-500.2.75 or around has abandoned -f[no-]strength-reduce and issues a
66dnl warning when that flag is passed to. Accordingly, adjust CFLAGS based on
67dnl the version number of the clang in use.
68dnl Note that this does not work to get the version of clang 3.1 or 3.2.
69AC_MSG_CHECKING(for recent clang version)
70CLANG_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'`
71if test x"$CLANG_VERSION_STRING" != x"" ; then
72 CLANG_MAJOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*/\1/p'`
73 CLANG_MINOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/p'`
74 CLANG_REVISION=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)/\1/p'`
75 CLANG_VERSION=`expr $CLANG_MAJOR '*' 1000000 '+' $CLANG_MINOR '*' 1000 '+' $CLANG_REVISION`
76 AC_MSG_RESULT($CLANG_VERSION)
77 dnl If you find the same issue with versions earlier than 500.2.75,
78 dnl change the constant 500002075 below appropriately. To get the
79 dnl integer corresponding to a version number, refer to the
80 dnl definition of CLANG_VERSION above.
81 if test "$CLANG_VERSION" -ge 500002075 ; then
82 CFLAGS=`echo "$CFLAGS" | sed -n -e 's/-fno-strength-reduce/ /p'`
83 fi
84else
85 AC_MSG_RESULT(no)
86fi
87
Bram Moolenaar446cb832008-06-24 21:56:24 +000088dnl If configure thinks we are cross compiling, there might be something
89dnl wrong with the CC or CFLAGS settings, give a useful warning message
Bram Moolenaar071d4272004-06-13 20:20:40 +000090if test "$cross_compiling" = yes; then
Bram Moolenaar446cb832008-06-24 21:56:24 +000091 AC_MSG_RESULT([cannot compile a simple program; if not cross compiling check CC and CFLAGS])
Bram Moolenaar071d4272004-06-13 20:20:40 +000092fi
93
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +000094dnl gcc-cpp has the wonderful -MM option to produce nicer dependencies.
95dnl But gcc 3.1 changed the meaning! See near the end.
Bram Moolenaar071d4272004-06-13 20:20:40 +000096test "$GCC" = yes && CPP_MM=M; AC_SUBST(CPP_MM)
97
98if test -f ./toolcheck; then
99 AC_CHECKING(for buggy tools)
100 sh ./toolcheck 1>&AC_FD_MSG
101fi
102
103OS_EXTRA_SRC=""; OS_EXTRA_OBJ=""
104
105dnl Check for BeOS, which needs an extra source file
106AC_MSG_CHECKING(for BeOS)
107case `uname` in
108 BeOS) OS_EXTRA_SRC=os_beos.c; OS_EXTRA_OBJ=objects/os_beos.o
109 BEOS=yes; AC_MSG_RESULT(yes);;
110 *) BEOS=no; AC_MSG_RESULT(no);;
111esac
112
113dnl If QNX is found, assume we don't want to use Xphoton
114dnl unless it was specifically asked for (--with-x)
115AC_MSG_CHECKING(for QNX)
116case `uname` in
117 QNX) OS_EXTRA_SRC=os_qnx.c; OS_EXTRA_OBJ=objects/os_qnx.o
118 test -z "$with_x" && with_x=no
119 QNX=yes; AC_MSG_RESULT(yes);;
120 *) QNX=no; AC_MSG_RESULT(no);;
121esac
122
123dnl Check for Darwin and MacOS X
124dnl We do a check for MacOS X in the very beginning because there
125dnl are a lot of other things we need to change besides GUI stuff
Bram Moolenaar071d4272004-06-13 20:20:40 +0000126AC_MSG_CHECKING([for Darwin (Mac OS X)])
127if test "`(uname) 2>/dev/null`" = Darwin; then
128 AC_MSG_RESULT(yes)
129
130 AC_MSG_CHECKING(--disable-darwin argument)
131 AC_ARG_ENABLE(darwin,
132 [ --disable-darwin Disable Darwin (Mac OS X) support.],
133 , [enable_darwin="yes"])
134 if test "$enable_darwin" = "yes"; then
135 AC_MSG_RESULT(no)
136 AC_MSG_CHECKING(if Darwin files are there)
Bram Moolenaar164fca32010-07-14 13:58:07 +0200137 if test -f os_macosx.m; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000138 AC_MSG_RESULT(yes)
139 else
140 AC_MSG_RESULT([no, Darwin support disabled])
141 enable_darwin=no
142 fi
143 else
144 AC_MSG_RESULT([yes, Darwin support excluded])
145 fi
146
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000147 AC_MSG_CHECKING(--with-mac-arch argument)
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000148 AC_ARG_WITH(mac-arch, [ --with-mac-arch=ARCH current, intel, ppc or both],
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000149 MACARCH="$withval"; AC_MSG_RESULT($MACARCH),
Bram Moolenaar899dddf2006-03-26 21:06:50 +0000150 MACARCH="current"; AC_MSG_RESULT(defaulting to $MACARCH))
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000151
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100152 AC_MSG_CHECKING(--with-developer-dir argument)
153 AC_ARG_WITH(developer-dir, [ --with-developer-dir=PATH use PATH as location for Xcode developer tools],
154 DEVELOPER_DIR="$withval"; AC_MSG_RESULT($DEVELOPER_DIR),
155 DEVELOPER_DIR=""; AC_MSG_RESULT(not present))
156
157 if test "x$DEVELOPER_DIR" = "x"; then
158 AC_PATH_PROG(XCODE_SELECT, xcode-select)
159 if test "x$XCODE_SELECT" != "x"; then
160 AC_MSG_CHECKING(for developer dir using xcode-select)
161 DEVELOPER_DIR=`$XCODE_SELECT -print-path`
162 AC_MSG_RESULT([$DEVELOPER_DIR])
163 else
164 DEVELOPER_DIR=/Developer
165 fi
166 fi
167
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000168 if test "x$MACARCH" = "xboth"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000169 AC_MSG_CHECKING(for 10.4 universal SDK)
170 dnl There is a terrible inconsistency (but we appear to get away with it):
171 dnl $CFLAGS uses the 10.4u SDK library for the headers, while $CPPFLAGS
172 dnl doesn't, because "gcc -E" doesn't grok it. That means the configure
173 dnl tests using the preprocessor are actually done with the wrong header
174 dnl files. $LDFLAGS is set at the end, because configure uses it together
175 dnl with $CFLAGS and we can only have one -sysroot argument.
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000176 save_cppflags="$CPPFLAGS"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000177 save_cflags="$CFLAGS"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000178 save_ldflags="$LDFLAGS"
Bram Moolenaar595a7be2010-03-10 16:28:12 +0100179 CFLAGS="$CFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000180 AC_TRY_LINK([ ], [ ],
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000181 AC_MSG_RESULT(found, will make universal binary),
182
183 AC_MSG_RESULT(not found)
Bram Moolenaar1f35bf92006-03-07 22:38:47 +0000184 CFLAGS="$save_cflags"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000185 AC_MSG_CHECKING(if Intel architecture is supported)
186 CPPFLAGS="$CPPFLAGS -arch i386"
187 LDFLAGS="$save_ldflags -arch i386"
188 AC_TRY_LINK([ ], [ ],
189 AC_MSG_RESULT(yes); MACARCH="intel",
190 AC_MSG_RESULT(no, using PowerPC)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000191 MACARCH="ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000192 CPPFLAGS="$save_cppflags -arch ppc"
193 LDFLAGS="$save_ldflags -arch ppc"))
194 elif test "x$MACARCH" = "xintel"; then
195 CPPFLAGS="$CPPFLAGS -arch intel"
196 LDFLAGS="$LDFLAGS -arch intel"
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000197 elif test "x$MACARCH" = "xppc"; then
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000198 CPPFLAGS="$CPPFLAGS -arch ppc"
199 LDFLAGS="$LDFLAGS -arch ppc"
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000200 fi
201
Bram Moolenaar071d4272004-06-13 20:20:40 +0000202 if test "$enable_darwin" = "yes"; then
203 MACOSX=yes
Bram Moolenaar164fca32010-07-14 13:58:07 +0200204 OS_EXTRA_SRC="os_macosx.m os_mac_conv.c";
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000205 OS_EXTRA_OBJ="objects/os_macosx.o objects/os_mac_conv.o"
Bram Moolenaar32466aa2006-02-24 23:53:04 +0000206 dnl TODO: use -arch i386 on Intel machines
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000207 CPPFLAGS="$CPPFLAGS -DMACOS_X_UNIX -no-cpp-precomp"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000208
209 dnl If Carbon is found, assume we don't want X11
210 dnl unless it was specifically asked for (--with-x)
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000211 dnl or Motif, Athena or GTK GUI is used.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000212 AC_CHECK_HEADER(Carbon/Carbon.h, CARBON=yes)
213 if test "x$CARBON" = "xyes"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +0200214 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 +0000215 with_x=no
Bram Moolenaar071d4272004-06-13 20:20:40 +0000216 fi
217 fi
218 fi
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000219
Bram Moolenaardb552d602006-03-23 22:59:57 +0000220 dnl Avoid a bug with -O2 with gcc 4.0.1. Symptom: malloc() reports double
Bram Moolenaarfd2ac762006-03-01 22:09:21 +0000221 dnl free. This happens in expand_filename(), because the optimizer swaps
Bram Moolenaardb552d602006-03-23 22:59:57 +0000222 dnl two blocks of code, both using "repl", that can't be swapped.
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000223 if test "$MACARCH" = "intel" -o "$MACARCH" = "both"; then
224 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-Oz/'`
225 fi
226
Bram Moolenaar071d4272004-06-13 20:20:40 +0000227else
228 AC_MSG_RESULT(no)
229fi
230
231AC_SUBST(OS_EXTRA_SRC)
232AC_SUBST(OS_EXTRA_OBJ)
233
234dnl Add /usr/local/lib to $LDFLAGS and /usr/local/include to CFLAGS.
235dnl Only when the directory exists and it wasn't there yet.
236dnl For gcc don't do this when it is already in the default search path.
Bram Moolenaar446cb832008-06-24 21:56:24 +0000237dnl Skip all of this when cross-compiling.
238if test "$cross_compiling" = no; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000239 AC_MSG_CHECKING(--with-local-dir argument)
Bram Moolenaar446cb832008-06-24 21:56:24 +0000240 have_local_include=''
241 have_local_lib=''
Bram Moolenaarc236c162008-07-13 17:41:49 +0000242 AC_ARG_WITH([local-dir], [ --with-local-dir=PATH search PATH instead of /usr/local for local libraries.
243 --without-local-dir do not search /usr/local for local libraries.], [
244 local_dir="$withval"
245 case "$withval" in
246 */*) ;;
247 no)
248 # avoid adding local dir to LDFLAGS and CPPFLAGS
Bram Moolenaare06c1882010-07-21 22:05:20 +0200249 have_local_include=yes
Bram Moolenaarc236c162008-07-13 17:41:49 +0000250 have_local_lib=yes
251 ;;
252 *) AC_MSG_ERROR(must pass path argument to --with-local-dir) ;;
253 esac
254 AC_MSG_RESULT($local_dir)
255 ], [
256 local_dir=/usr/local
257 AC_MSG_RESULT(Defaulting to $local_dir)
258 ])
259 if test "$GCC" = yes -a "$local_dir" != no; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000260 echo 'void f(){}' > conftest.c
261 dnl -no-cpp-precomp is needed for OS X 10.2 (Ben Fowler)
Bram Moolenaarc236c162008-07-13 17:41:49 +0000262 have_local_include=`${CC-cc} -no-cpp-precomp -c -v conftest.c 2>&1 | grep "${local_dir}/include"`
263 have_local_lib=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/lib"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000264 rm -f conftest.c conftest.o
Bram Moolenaar071d4272004-06-13 20:20:40 +0000265 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000266 if test -z "$have_local_lib" -a -d "${local_dir}/lib"; then
267 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 +0000268 if test "$tt" = "$LDFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000269 LDFLAGS="$LDFLAGS -L${local_dir}/lib"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000270 fi
271 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000272 if test -z "$have_local_include" -a -d "${local_dir}/include"; then
273 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 +0000274 if test "$tt" = "$CPPFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000275 CPPFLAGS="$CPPFLAGS -I${local_dir}/include"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000276 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000277 fi
278fi
279
280AC_MSG_CHECKING(--with-vim-name argument)
281AC_ARG_WITH(vim-name, [ --with-vim-name=NAME what to call the Vim executable],
282 VIMNAME="$withval"; AC_MSG_RESULT($VIMNAME),
Bram Moolenaare344bea2005-09-01 20:46:49 +0000283 VIMNAME="vim"; AC_MSG_RESULT(Defaulting to $VIMNAME))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000284AC_SUBST(VIMNAME)
285AC_MSG_CHECKING(--with-ex-name argument)
286AC_ARG_WITH(ex-name, [ --with-ex-name=NAME what to call the Ex executable],
287 EXNAME="$withval"; AC_MSG_RESULT($EXNAME),
288 EXNAME="ex"; AC_MSG_RESULT(Defaulting to ex))
289AC_SUBST(EXNAME)
290AC_MSG_CHECKING(--with-view-name argument)
291AC_ARG_WITH(view-name, [ --with-view-name=NAME what to call the View executable],
292 VIEWNAME="$withval"; AC_MSG_RESULT($VIEWNAME),
293 VIEWNAME="view"; AC_MSG_RESULT(Defaulting to view))
294AC_SUBST(VIEWNAME)
295
296AC_MSG_CHECKING(--with-global-runtime argument)
297AC_ARG_WITH(global-runtime, [ --with-global-runtime=DIR global runtime directory in 'runtimepath'],
298 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL, "$withval"),
299 AC_MSG_RESULT(no))
300
301AC_MSG_CHECKING(--with-modified-by argument)
302AC_ARG_WITH(modified-by, [ --with-modified-by=NAME name of who modified a release version],
303 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(MODIFIED_BY, "$withval"),
304 AC_MSG_RESULT(no))
305
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200306dnl Check for EBCDIC stolen from the LYNX port to z/OS Unix
Bram Moolenaar071d4272004-06-13 20:20:40 +0000307AC_MSG_CHECKING(if character set is EBCDIC)
308AC_TRY_COMPILE([ ],
309[ /* TryCompile function for CharSet.
310 Treat any failure as ASCII for compatibility with existing art.
311 Use compile-time rather than run-time tests for cross-compiler
312 tolerance. */
313#if '0'!=240
314make an error "Character set is not EBCDIC"
315#endif ],
316[ # TryCompile action if true
317cf_cv_ebcdic=yes ],
318[ # TryCompile action if false
319cf_cv_ebcdic=no])
320# end of TryCompile ])
321# end of CacheVal CvEbcdic
322AC_MSG_RESULT($cf_cv_ebcdic)
323case "$cf_cv_ebcdic" in #(vi
324 yes) AC_DEFINE(EBCDIC)
325 line_break='"\\n"'
326 ;;
327 *) line_break='"\\012"';;
328esac
329AC_SUBST(line_break)
330
331if test "$cf_cv_ebcdic" = "yes"; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +0200332dnl If we have EBCDIC we most likely have z/OS Unix, let's test it!
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200333AC_MSG_CHECKING(for z/OS Unix)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000334case `uname` in
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200335 OS/390) zOSUnix="yes";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000336 dnl If using cc the environment variable _CC_CCMODE must be
337 dnl set to "1", so that some compiler extensions are enabled.
338 dnl If using c89 the environment variable is named _CC_C89MODE.
339 dnl Note: compile with c89 never tested.
340 if test "$CC" = "cc"; then
341 ccm="$_CC_CCMODE"
342 ccn="CC"
343 else
344 if test "$CC" = "c89"; then
345 ccm="$_CC_C89MODE"
346 ccn="C89"
347 else
348 ccm=1
349 fi
350 fi
351 if test "$ccm" != "1"; then
352 echo ""
353 echo "------------------------------------------"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200354 echo " On z/OS Unix, the environment variable"
Bram Moolenaar77c19352012-06-13 19:19:41 +0200355 echo " _CC_${ccn}MODE must be set to \"1\"!"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000356 echo " Do:"
357 echo " export _CC_${ccn}MODE=1"
358 echo " and then call configure again."
359 echo "------------------------------------------"
360 exit 1
361 fi
Bram Moolenaar77c19352012-06-13 19:19:41 +0200362 # Set CFLAGS for configure process.
363 # This will be reset later for config.mk.
364 # Use haltonmsg to force error for missing H files.
365 CFLAGS="$CFLAGS -D_ALL_SOURCE -Wc,float(ieee),haltonmsg(3296)";
366 LDFLAGS="$LDFLAGS -Wl,EDIT=NO"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000367 AC_MSG_RESULT(yes)
368 ;;
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200369 *) zOSUnix="no";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000370 AC_MSG_RESULT(no)
371 ;;
372esac
373fi
374
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200375dnl Set QUOTESED. Needs additional backslashes on zOS
376if test "$zOSUnix" = "yes"; then
377 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\\\\\&/g' -e 's/\\\\\\\\\"/\"/' -e 's/\\\\\\\\\";\$\$/\";/'"
378else
379 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\&/g' -e 's/\\\\\"/\"/' -e 's/\\\\\";\$\$/\";/'"
380fi
381AC_SUBST(QUOTESED)
382
383
Bram Moolenaar588ebeb2008-05-07 17:09:24 +0000384dnl Link with -lselinux for SELinux stuff; if not found
385AC_MSG_CHECKING(--disable-selinux argument)
386AC_ARG_ENABLE(selinux,
387 [ --disable-selinux Don't check for SELinux support.],
388 , enable_selinux="yes")
389if test "$enable_selinux" = "yes"; then
390 AC_MSG_RESULT(no)
391 AC_CHECK_LIB(selinux, is_selinux_enabled,
392 [LIBS="$LIBS -lselinux"
393 AC_DEFINE(HAVE_SELINUX)])
394else
395 AC_MSG_RESULT(yes)
396fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000397
398dnl Check user requested features.
399
400AC_MSG_CHECKING(--with-features argument)
401AC_ARG_WITH(features, [ --with-features=TYPE tiny, small, normal, big or huge (default: normal)],
402 features="$withval"; AC_MSG_RESULT($features),
403 features="normal"; AC_MSG_RESULT(Defaulting to normal))
404
405dovimdiff=""
406dogvimdiff=""
407case "$features" in
408 tiny) AC_DEFINE(FEAT_TINY) ;;
409 small) AC_DEFINE(FEAT_SMALL) ;;
410 normal) AC_DEFINE(FEAT_NORMAL) dovimdiff="installvimdiff";
411 dogvimdiff="installgvimdiff" ;;
412 big) AC_DEFINE(FEAT_BIG) dovimdiff="installvimdiff";
413 dogvimdiff="installgvimdiff" ;;
414 huge) AC_DEFINE(FEAT_HUGE) dovimdiff="installvimdiff";
415 dogvimdiff="installgvimdiff" ;;
416 *) AC_MSG_RESULT([Sorry, $features is not supported]) ;;
417esac
418
419AC_SUBST(dovimdiff)
420AC_SUBST(dogvimdiff)
421
422AC_MSG_CHECKING(--with-compiledby argument)
423AC_ARG_WITH(compiledby, [ --with-compiledby=NAME name to show in :version message],
424 compiledby="$withval"; AC_MSG_RESULT($withval),
425 compiledby=""; AC_MSG_RESULT(no))
426AC_SUBST(compiledby)
427
428AC_MSG_CHECKING(--disable-xsmp argument)
429AC_ARG_ENABLE(xsmp,
430 [ --disable-xsmp Disable XSMP session management],
431 , enable_xsmp="yes")
432
433if test "$enable_xsmp" = "yes"; then
434 AC_MSG_RESULT(no)
435 AC_MSG_CHECKING(--disable-xsmp-interact argument)
436 AC_ARG_ENABLE(xsmp-interact,
437 [ --disable-xsmp-interact Disable XSMP interaction],
438 , enable_xsmp_interact="yes")
439 if test "$enable_xsmp_interact" = "yes"; then
440 AC_MSG_RESULT(no)
441 AC_DEFINE(USE_XSMP_INTERACT)
442 else
443 AC_MSG_RESULT(yes)
444 fi
445else
446 AC_MSG_RESULT(yes)
447fi
448
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200449dnl Check for Lua feature.
450AC_MSG_CHECKING(--enable-luainterp argument)
451AC_ARG_ENABLE(luainterp,
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200452 [ --enable-luainterp[=OPTS] Include Lua interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200453 [enable_luainterp="no"])
454AC_MSG_RESULT($enable_luainterp)
455
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200456if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200457 dnl -- find the lua executable
458 AC_SUBST(vi_cv_path_lua)
459
460 AC_MSG_CHECKING(--with-lua-prefix argument)
461 AC_ARG_WITH(lua_prefix,
462 [ --with-lua-prefix=PFX Prefix where Lua is installed.],
463 with_lua_prefix="$withval"; AC_MSG_RESULT($with_lua_prefix),
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200464 with_lua_prefix="";AC_MSG_RESULT(no))
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200465
466 if test "X$with_lua_prefix" != "X"; then
467 vi_cv_path_lua_pfx="$with_lua_prefix"
468 else
469 AC_MSG_CHECKING(LUA_PREFIX environment var)
470 if test "X$LUA_PREFIX" != "X"; then
471 AC_MSG_RESULT("$LUA_PREFIX")
472 vi_cv_path_lua_pfx="$LUA_PREFIX"
473 else
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200474 AC_MSG_RESULT([not set, default to /usr])
475 vi_cv_path_lua_pfx="/usr"
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200476 fi
477 fi
478
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200479 AC_MSG_CHECKING(--with-luajit)
480 AC_ARG_WITH(luajit,
481 [ --with-luajit Link with LuaJIT instead of Lua.],
482 [vi_cv_with_luajit="$withval"],
483 [vi_cv_with_luajit="no"])
484 AC_MSG_RESULT($vi_cv_with_luajit)
485
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200486 LUA_INC=
487 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200488 if test "x$vi_cv_with_luajit" != "xno"; then
489 dnl -- try to find LuaJIT executable
490 AC_PATH_PROG(vi_cv_path_luajit, luajit)
491 if test "X$vi_cv_path_luajit" != "X"; then
492 dnl -- find LuaJIT version
493 AC_CACHE_CHECK(LuaJIT version, vi_cv_version_luajit,
494 [ vi_cv_version_luajit=`${vi_cv_path_luajit} -v | sed 's/LuaJIT \([[0-9.]]*\)\.[[0-9]] .*/\1/'` ])
495 AC_CACHE_CHECK(Lua version of LuaJIT, vi_cv_version_lua_luajit,
496 [ vi_cv_version_lua_luajit=`${vi_cv_path_luajit} -e "print(_VERSION)" | sed 's/.* //'` ])
497 vi_cv_path_lua="$vi_cv_path_luajit"
498 vi_cv_version_lua="$vi_cv_version_lua_luajit"
499 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200500 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200501 dnl -- try to find Lua executable
502 AC_PATH_PROG(vi_cv_path_plain_lua, lua)
503 if test "X$vi_cv_path_plain_lua" != "X"; then
504 dnl -- find Lua version
505 AC_CACHE_CHECK(Lua version, vi_cv_version_plain_lua,
506 [ vi_cv_version_plain_lua=`${vi_cv_path_plain_lua} -e "print(_VERSION)" | sed 's/.* //'` ])
507 fi
508 vi_cv_path_lua="$vi_cv_path_plain_lua"
509 vi_cv_version_lua="$vi_cv_version_plain_lua"
510 fi
511 if test "x$vi_cv_with_luajit" != "xno" && test "X$vi_cv_version_luajit" != "X"; then
512 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit)
513 if test -f $vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit/lua.h; then
514 AC_MSG_RESULT(yes)
515 LUA_INC=/luajit-$vi_cv_version_luajit
516 fi
517 fi
518 if test "X$LUA_INC" = "X"; then
519 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)
520 if test -f $vi_cv_path_lua_pfx/include/lua.h; then
521 AC_MSG_RESULT(yes)
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200522 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200523 AC_MSG_RESULT(no)
524 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua)
525 if test -f $vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h; then
526 AC_MSG_RESULT(yes)
527 LUA_INC=/lua$vi_cv_version_lua
528 else
529 AC_MSG_RESULT(no)
530 vi_cv_path_lua_pfx=
531 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200532 fi
533 fi
534 fi
535
536 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200537 if test "x$vi_cv_with_luajit" != "xno"; then
538 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
539 if test "X$multiarch" != "X"; then
540 lib_multiarch="lib/${multiarch}"
541 else
542 lib_multiarch="lib"
543 fi
544 if test "X$vi_cv_version_lua" = "X"; then
545 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit"
546 else
547 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit-$vi_cv_version_lua"
548 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200549 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200550 if test "X$LUA_INC" != "X"; then
551 dnl Test alternate location using version
552 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua$vi_cv_version_lua"
553 else
554 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua"
555 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200556 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200557 if test "$enable_luainterp" = "dynamic"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200558 lua_ok="yes"
559 else
560 AC_MSG_CHECKING([if link with ${LUA_LIBS} is sane])
561 libs_save=$LIBS
562 LIBS="$LIBS $LUA_LIBS"
563 AC_TRY_LINK(,[ ],
564 AC_MSG_RESULT(yes); lua_ok="yes",
565 AC_MSG_RESULT(no); lua_ok="no"; LUA_LIBS="")
566 LIBS=$libs_save
567 fi
568 if test "x$lua_ok" = "xyes"; then
569 LUA_CFLAGS="-I${vi_cv_path_lua_pfx}/include${LUA_INC}"
570 LUA_SRC="if_lua.c"
571 LUA_OBJ="objects/if_lua.o"
572 LUA_PRO="if_lua.pro"
573 AC_DEFINE(FEAT_LUA)
574 fi
575 if test "$enable_luainterp" = "dynamic"; then
576 if test "x$vi_cv_with_luajit" != "xno"; then
577 luajit="jit"
578 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200579 if test -f "${vi_cv_path_lua_pfx}/bin/cyglua-${vi_cv_version_lua}.dll"; then
580 vi_cv_dll_name_lua="cyglua-${vi_cv_version_lua}.dll"
581 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200582 if test "x$MACOSX" = "xyes"; then
583 ext="dylib"
584 indexes=""
585 else
586 ext="so"
587 indexes=".0 .1 .2 .3 .4 .5 .6 .7 .8 .9"
588 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
589 if test "X$multiarch" != "X"; then
590 lib_multiarch="lib/${multiarch}"
591 fi
Bram Moolenaar768baac2013-04-15 14:44:57 +0200592 fi
593 dnl Determine the sover for the current version, but fallback to
594 dnl liblua${vi_cv_version_lua}.so if no sover-versioned file is found.
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200595 AC_MSG_CHECKING(if liblua${luajit}*.${ext}* can be found in $vi_cv_path_lua_pfx)
Bram Moolenaar768baac2013-04-15 14:44:57 +0200596 for subdir in "${lib_multiarch}" lib64 lib; do
597 if test -z "$subdir"; then
598 continue
599 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200600 for sover in "${vi_cv_version_lua}.${ext}" "-${vi_cv_version_lua}.${ext}" \
601 ".${vi_cv_version_lua}.${ext}" ".${ext}.${vi_cv_version_lua}"; do
602 for i in $indexes ""; do
603 if test -f "${vi_cv_path_lua_pfx}/${subdir}/liblua${luajit}${sover}$i"; then
Bram Moolenaar768baac2013-04-15 14:44:57 +0200604 sover2="$i"
605 break 3
606 fi
607 done
Bram Moolenaar07e1da62013-02-06 19:49:43 +0100608 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200609 sover=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200610 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200611 if test "X$sover" = "X"; then
612 AC_MSG_RESULT(no)
613 lua_ok="no"
614 vi_cv_dll_name_lua="liblua${luajit}.${ext}"
615 else
616 AC_MSG_RESULT(yes)
617 lua_ok="yes"
618 vi_cv_dll_name_lua="liblua${luajit}${sover}$sover2"
619 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200620 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200621 AC_DEFINE(DYNAMIC_LUA)
622 LUA_LIBS=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200623 LUA_CFLAGS="-DDYNAMIC_LUA_DLL=\\\"${vi_cv_dll_name_lua}\\\" $LUA_CFLAGS"
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200624 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200625 if test "X$LUA_CFLAGS$LUA_LIBS" != "X" && \
626 test "x$MACOSX" = "xyes" && test "x$vi_cv_with_luajit" != "xno" && \
627 test "`(uname -m) 2>/dev/null`" = "x86_64"; then
628 dnl OSX/x64 requires these flags. See http://luajit.org/install.html
629 LUA_LIBS="-pagezero_size 10000 -image_base 100000000 $LUA_LIBS"
630 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200631 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200632 if test "$fail_if_missing" = "yes" -a "$lua_ok" != "yes"; then
Bram Moolenaarf788a062011-12-14 20:51:25 +0100633 AC_MSG_ERROR([could not configure lua])
634 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200635 AC_SUBST(LUA_SRC)
636 AC_SUBST(LUA_OBJ)
637 AC_SUBST(LUA_PRO)
638 AC_SUBST(LUA_LIBS)
639 AC_SUBST(LUA_CFLAGS)
640fi
641
642
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000643dnl Check for MzScheme feature.
644AC_MSG_CHECKING(--enable-mzschemeinterp argument)
645AC_ARG_ENABLE(mzschemeinterp,
646 [ --enable-mzschemeinterp Include MzScheme interpreter.], ,
647 [enable_mzschemeinterp="no"])
648AC_MSG_RESULT($enable_mzschemeinterp)
649
650if test "$enable_mzschemeinterp" = "yes"; then
651 dnl -- find the mzscheme executable
652 AC_SUBST(vi_cv_path_mzscheme)
653
654 AC_MSG_CHECKING(--with-plthome argument)
655 AC_ARG_WITH(plthome,
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000656 [ --with-plthome=PLTHOME Use PLTHOME.],
657 with_plthome="$withval"; AC_MSG_RESULT($with_plthome),
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000658 with_plthome="";AC_MSG_RESULT("no"))
659
660 if test "X$with_plthome" != "X"; then
661 vi_cv_path_mzscheme_pfx="$with_plthome"
662 else
663 AC_MSG_CHECKING(PLTHOME environment var)
664 if test "X$PLTHOME" != "X"; then
665 AC_MSG_RESULT("$PLTHOME")
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000666 vi_cv_path_mzscheme_pfx="$PLTHOME"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000667 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000668 AC_MSG_RESULT(not set)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000669 dnl -- try to find MzScheme executable
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000670 AC_PATH_PROG(vi_cv_path_mzscheme, mzscheme)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000671
672 dnl resolve symbolic link, the executable is often elsewhere and there
673 dnl are no links for the include files.
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000674 if test "X$vi_cv_path_mzscheme" != "X"; then
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000675 lsout=`ls -l $vi_cv_path_mzscheme`
676 if echo "$lsout" | grep -e '->' >/dev/null 2>/dev/null; then
677 vi_cv_path_mzscheme=`echo "$lsout" | sed 's/.*-> \(.*\)/\1/'`
678 fi
679 fi
680
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000681 if test "X$vi_cv_path_mzscheme" != "X"; then
682 dnl -- find where MzScheme thinks it was installed
683 AC_CACHE_CHECK(MzScheme install prefix,vi_cv_path_mzscheme_pfx,
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000684 dnl different versions of MzScheme differ in command line processing
685 dnl use universal approach
686 echo "(display (simplify-path \
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000687 (build-path (call-with-values \
688 (lambda () (split-path (find-system-path (quote exec-file)))) \
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000689 (lambda (base name must-be-dir?) base)) (quote up))))" > mzdirs.scm
690 dnl Remove a trailing slash
691 [ vi_cv_path_mzscheme_pfx=`${vi_cv_path_mzscheme} -r mzdirs.scm | \
692 sed -e 's+/$++'` ])
693 rm -f mzdirs.scm
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000694 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000695 fi
696 fi
697
Bram Moolenaard7afed32007-05-06 13:26:41 +0000698 SCHEME_INC=
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000699 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
700 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include)
701 if test -f $vi_cv_path_mzscheme_pfx/include/scheme.h; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000702 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include
703 AC_MSG_RESULT(yes)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000704 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000705 AC_MSG_RESULT(no)
706 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt)
Bram Moolenaard7afed32007-05-06 13:26:41 +0000707 if test -f $vi_cv_path_mzscheme_pfx/include/plt/scheme.h; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000708 AC_MSG_RESULT(yes)
709 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt
Bram Moolenaard7afed32007-05-06 13:26:41 +0000710 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000711 AC_MSG_RESULT(no)
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100712 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket)
713 if test -f $vi_cv_path_mzscheme_pfx/include/racket/scheme.h; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000714 AC_MSG_RESULT(yes)
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100715 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000716 else
717 AC_MSG_RESULT(no)
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100718 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/)
719 if test -f /usr/include/plt/scheme.h; then
720 AC_MSG_RESULT(yes)
721 SCHEME_INC=/usr/include/plt
722 else
723 AC_MSG_RESULT(no)
724 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/racket/)
725 if test -f /usr/include/racket/scheme.h; then
726 AC_MSG_RESULT(yes)
727 SCHEME_INC=/usr/include/racket
728 else
729 AC_MSG_RESULT(no)
730 vi_cv_path_mzscheme_pfx=
731 fi
732 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000733 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000734 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000735 fi
736 fi
737
738 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaarf15f9432007-06-28 11:07:21 +0000739 if test "x$MACOSX" = "xyes"; then
Bram Moolenaar75676462013-01-30 14:55:42 +0100740 MZSCHEME_LIBS="-framework Racket"
741 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000742 elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"; then
743 MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"
744 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100745 elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket3m.a"; then
746 MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libracket3m.a"
747 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
748 elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket.a"; then
749 MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libracket.a ${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a"
750 elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme.a"; then
Bram Moolenaar9048f942007-05-12 14:32:25 +0000751 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 +0000752 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000753 dnl Using shared objects
754 if test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.so"; then
755 MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lmzscheme3m"
756 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100757 elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket3m.so"; then
758 MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lracket3m"
759 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
760 elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket.so"; then
761 MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lracket -lmzgc"
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000762 else
763 MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lmzscheme -lmzgc"
764 fi
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +0000765 if test "$GCC" = yes; then
766 dnl Make Vim remember the path to the library. For when it's not in
767 dnl $LD_LIBRARY_PATH.
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000768 MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${vi_cv_path_mzscheme_pfx}/lib"
Bram Moolenaar21cf8232004-07-16 20:18:37 +0000769 elif test "`(uname) 2>/dev/null`" = SunOS &&
770 uname -r | grep '^5' >/dev/null; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000771 MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${vi_cv_path_mzscheme_pfx}/lib"
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +0000772 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000773 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100774
775 AC_MSG_CHECKING(for racket collects directory)
Bram Moolenaard7afed32007-05-06 13:26:41 +0000776 if test -d $vi_cv_path_mzscheme_pfx/lib/plt/collects; then
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100777 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/plt/
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100778 else
779 if test -d $vi_cv_path_mzscheme_pfx/lib/racket/collects; then
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100780 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/racket/
781 else
782 if test -d $vi_cv_path_mzscheme_pfx/share/racket/collects; then
783 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/
Bram Moolenaar75676462013-01-30 14:55:42 +0100784 else
785 if test -d $vi_cv_path_mzscheme_pfx/collects; then
786 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/
787 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100788 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100789 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000790 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100791 if test "X$SCHEME_COLLECTS" != "X" ; then
792 AC_MSG_RESULT(${SCHEME_COLLECTS})
793 else
794 AC_MSG_RESULT(not found)
795 fi
796
797 AC_MSG_CHECKING(for mzscheme_base.c)
798 if test -f "${SCHEME_COLLECTS}collects/scheme/base.ss" ; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000799 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100800 else
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100801 if test -f "${SCHEME_COLLECTS}collects/scheme/base.rkt" ; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100802 MZSCHEME_EXTRA="mzscheme_base.c"
803 fi
804 fi
805 if test "X$MZSCHEME_EXTRA" != "X" ; then
806 dnl need to generate bytecode for MzScheme base
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000807 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE"
808 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100809 AC_MSG_RESULT(needed)
810 else
811 AC_MSG_RESULT(not needed)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000812 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100813
Bram Moolenaar9e902192013-07-17 18:58:11 +0200814 dnl On Ubuntu this fixes "undefined reference to symbol 'ffi_type_void'".
815 AC_CHECK_LIB(ffi, ffi_type_void, [MZSCHEME_LIBS="$MZSCHEME_LIBS -lffi"])
816
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000817 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -I${SCHEME_INC} \
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100818 -DMZSCHEME_COLLECTS='\"${SCHEME_COLLECTS}collects\"'"
Bram Moolenaar9e902192013-07-17 18:58:11 +0200819
820 dnl Test that we can compile a simple program with these CFLAGS and LIBS.
821 AC_MSG_CHECKING([if compile and link flags for MzScheme are sane])
822 cflags_save=$CFLAGS
823 libs_save=$LIBS
824 CFLAGS="$CFLAGS $MZSCHEME_CFLAGS"
825 LIBS="$LIBS $MZSCHEME_LIBS"
826 AC_TRY_LINK(,[ ],
827 AC_MSG_RESULT(yes); mzs_ok=yes,
828 AC_MSG_RESULT(no: MZSCHEME DISABLED); mzs_ok=no)
829 CFLAGS=$cflags_save
830 LIBS=$libs_save
831 if test $mzs_ok = yes; then
832 MZSCHEME_SRC="if_mzsch.c"
833 MZSCHEME_OBJ="objects/if_mzsch.o"
834 MZSCHEME_PRO="if_mzsch.pro"
835 AC_DEFINE(FEAT_MZSCHEME)
836 else
837 MZSCHEME_CFLAGS=
838 MZSCHEME_LIBS=
839 MZSCHEME_EXTRA=
840 MZSCHEME_MZC=
841 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000842 fi
843 AC_SUBST(MZSCHEME_SRC)
844 AC_SUBST(MZSCHEME_OBJ)
845 AC_SUBST(MZSCHEME_PRO)
846 AC_SUBST(MZSCHEME_LIBS)
847 AC_SUBST(MZSCHEME_CFLAGS)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000848 AC_SUBST(MZSCHEME_EXTRA)
849 AC_SUBST(MZSCHEME_MZC)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000850fi
851
852
Bram Moolenaar071d4272004-06-13 20:20:40 +0000853AC_MSG_CHECKING(--enable-perlinterp argument)
854AC_ARG_ENABLE(perlinterp,
Bram Moolenaare06c1882010-07-21 22:05:20 +0200855 [ --enable-perlinterp[=OPTS] Include Perl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000856 [enable_perlinterp="no"])
857AC_MSG_RESULT($enable_perlinterp)
Bram Moolenaare06c1882010-07-21 22:05:20 +0200858if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000859 AC_SUBST(vi_cv_path_perl)
860 AC_PATH_PROG(vi_cv_path_perl, perl)
861 if test "X$vi_cv_path_perl" != "X"; then
862 AC_MSG_CHECKING(Perl version)
863 if $vi_cv_path_perl -e 'require 5.003_01' >/dev/null 2>/dev/null; then
864 eval `$vi_cv_path_perl -V:usethreads`
Bram Moolenaare06c1882010-07-21 22:05:20 +0200865 eval `$vi_cv_path_perl -V:libperl`
Bram Moolenaar071d4272004-06-13 20:20:40 +0000866 if test "X$usethreads" = "XUNKNOWN" -o "X$usethreads" = "Xundef"; then
867 badthreads=no
868 else
869 if $vi_cv_path_perl -e 'require 5.6.0' >/dev/null 2>/dev/null; then
870 eval `$vi_cv_path_perl -V:use5005threads`
871 if test "X$use5005threads" = "XUNKNOWN" -o "X$use5005threads" = "Xundef"; then
872 badthreads=no
873 else
874 badthreads=yes
875 AC_MSG_RESULT(>>> Perl > 5.6 with 5.5 threads cannot be used <<<)
876 fi
877 else
878 badthreads=yes
879 AC_MSG_RESULT(>>> Perl 5.5 with threads cannot be used <<<)
880 fi
881 fi
882 if test $badthreads = no; then
883 AC_MSG_RESULT(OK)
884 eval `$vi_cv_path_perl -V:shrpenv`
885 if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04
886 shrpenv=""
887 fi
888 vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlibexp}'`
889 AC_SUBST(vi_cv_perllib)
890 dnl Remove "-fno-something", it breaks using cproto.
891 perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
892 -e 'ccflags;perl_inc;print"\n"' | sed -e 's/-fno[[^ ]]*//'`
893 dnl Remove "-lc", it breaks on FreeBSD when using "-pthread".
894 perllibs=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed -e 'ldopts' | \
895 sed -e '/Warning/d' -e '/Note (probably harmless)/d' \
896 -e 's/-bE:perl.exp//' -e 's/-lc //'`
897 dnl Don't add perl lib to $LIBS: if it's not in LD_LIBRARY_PATH
898 dnl a test in configure may fail because of that.
899 perlldflags=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed \
900 -e 'ccdlflags' | sed -e 's/-bE:perl.exp//'`
901
902 dnl check that compiling a simple program still works with the flags
903 dnl added for Perl.
904 AC_MSG_CHECKING([if compile and link flags for Perl are sane])
905 cflags_save=$CFLAGS
906 libs_save=$LIBS
907 ldflags_save=$LDFLAGS
908 CFLAGS="$CFLAGS $perlcppflags"
909 LIBS="$LIBS $perllibs"
Bram Moolenaara6cc0312013-06-18 23:31:55 +0200910 perlldflags=`echo "$perlldflags" | sed -e 's/^ *//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +0000911 LDFLAGS="$perlldflags $LDFLAGS"
912 AC_TRY_LINK(,[ ],
913 AC_MSG_RESULT(yes); perl_ok=yes,
914 AC_MSG_RESULT(no: PERL DISABLED); perl_ok=no)
915 CFLAGS=$cflags_save
916 LIBS=$libs_save
917 LDFLAGS=$ldflags_save
918 if test $perl_ok = yes; then
919 if test "X$perlcppflags" != "X"; then
Bram Moolenaard7afed32007-05-06 13:26:41 +0000920 dnl remove -pipe and -Wxxx, it confuses cproto
921 PERL_CFLAGS=`echo "$perlcppflags" | sed -e 's/-pipe //' -e 's/-W[[^ ]]*//'`
Bram Moolenaar071d4272004-06-13 20:20:40 +0000922 fi
923 if test "X$perlldflags" != "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +0200924 if test "X`echo \"$LDFLAGS\" | grep -F -e \"$perlldflags\"`" = "X"; then
925 LDFLAGS="$perlldflags $LDFLAGS"
926 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000927 fi
928 PERL_LIBS=$perllibs
929 PERL_SRC="auto/if_perl.c if_perlsfio.c"
930 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o"
931 PERL_PRO="if_perl.pro if_perlsfio.pro"
932 AC_DEFINE(FEAT_PERL)
933 fi
934 fi
935 else
936 AC_MSG_RESULT(>>> too old; need Perl version 5.003_01 or later <<<)
937 fi
938 fi
939
940 if test "x$MACOSX" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +0000941 dnl Mac OS X 10.2 or later
Bram Moolenaar071d4272004-06-13 20:20:40 +0000942 dir=/System/Library/Perl
943 darwindir=$dir/darwin
944 if test -d $darwindir; then
945 PERL=/usr/bin/perl
946 else
947 dnl Mac OS X 10.3
948 dir=/System/Library/Perl/5.8.1
949 darwindir=$dir/darwin-thread-multi-2level
950 if test -d $darwindir; then
951 PERL=/usr/bin/perl
952 fi
953 fi
954 if test -n "$PERL"; then
955 PERL_DIR="$dir"
956 PERL_CFLAGS="-DFEAT_PERL -I$darwindir/CORE"
957 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o $darwindir/auto/DynaLoader/DynaLoader.a"
958 PERL_LIBS="-L$darwindir/CORE -lperl"
959 fi
Bram Moolenaar5dff57d2010-07-24 16:19:44 +0200960 dnl Perl on Mac OS X 10.5 adds "-arch" flags but these should only
961 dnl be included if requested by passing --with-mac-arch to
962 dnl configure, so strip these flags first (if present)
963 PERL_LIBS=`echo "$PERL_LIBS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
964 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 +0000965 fi
Bram Moolenaare06c1882010-07-21 22:05:20 +0200966 if test "$enable_perlinterp" = "dynamic"; then
967 if test "$perl_ok" = "yes" -a "X$libperl" != "X"; then
968 AC_DEFINE(DYNAMIC_PERL)
969 PERL_CFLAGS="-DDYNAMIC_PERL_DLL=\\\"$libperl\\\" $PERL_CFLAGS"
970 fi
971 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +0100972
973 if test "$fail_if_missing" = "yes" -a "$perl_ok" != "yes"; then
974 AC_MSG_ERROR([could not configure perl])
975 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000976fi
977AC_SUBST(shrpenv)
978AC_SUBST(PERL_SRC)
979AC_SUBST(PERL_OBJ)
980AC_SUBST(PERL_PRO)
981AC_SUBST(PERL_CFLAGS)
982AC_SUBST(PERL_LIBS)
983
984AC_MSG_CHECKING(--enable-pythoninterp argument)
985AC_ARG_ENABLE(pythoninterp,
Bram Moolenaarb744b2f2010-08-13 16:22:57 +0200986 [ --enable-pythoninterp[=OPTS] Include Python interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000987 [enable_pythoninterp="no"])
988AC_MSG_RESULT($enable_pythoninterp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +0200989if test "$enable_pythoninterp" = "yes" -o "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000990 dnl -- find the python executable
Bram Moolenaar09ba6d72012-12-12 14:25:05 +0100991 AC_PATH_PROGS(vi_cv_path_python, python2 python)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000992 if test "X$vi_cv_path_python" != "X"; then
993
994 dnl -- get its version number
995 AC_CACHE_CHECK(Python version,vi_cv_var_python_version,
996 [[vi_cv_var_python_version=`
997 ${vi_cv_path_python} -c 'import sys; print sys.version[:3]'`
998 ]])
999
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001000 dnl -- it must be at least version 2.3
1001 AC_MSG_CHECKING(Python is 2.3 or better)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001002 if ${vi_cv_path_python} -c \
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001003 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001004 then
1005 AC_MSG_RESULT(yep)
1006
1007 dnl -- find where python thinks it was installed
1008 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python_pfx,
1009 [ vi_cv_path_python_pfx=`
1010 ${vi_cv_path_python} -c \
1011 "import sys; print sys.prefix"` ])
1012
1013 dnl -- and where it thinks it runs
1014 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python_epfx,
1015 [ vi_cv_path_python_epfx=`
1016 ${vi_cv_path_python} -c \
1017 "import sys; print sys.exec_prefix"` ])
1018
1019 dnl -- python's internal library path
1020
1021 AC_CACHE_VAL(vi_cv_path_pythonpath,
1022 [ vi_cv_path_pythonpath=`
1023 unset PYTHONPATH;
1024 ${vi_cv_path_python} -c \
1025 "import sys, string; print string.join(sys.path,':')"` ])
1026
1027 dnl -- where the Python implementation library archives are
1028
1029 AC_ARG_WITH(python-config-dir,
1030 [ --with-python-config-dir=PATH Python's config directory],
1031 [ vi_cv_path_python_conf="${withval}" ] )
1032
1033 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python_conf,
1034 [
1035 vi_cv_path_python_conf=
Bram Moolenaarac499e32013-06-02 19:14:17 +02001036 d=`${vi_cv_path_python} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBPL')"`
1037 if test -d "$d" && test -f "$d/config.c"; then
1038 vi_cv_path_python_conf="$d"
1039 else
1040 for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
1041 for subdir in lib64 lib share; do
1042 d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
1043 if test -d "$d" && test -f "$d/config.c"; then
1044 vi_cv_path_python_conf="$d"
1045 fi
1046 done
Bram Moolenaar071d4272004-06-13 20:20:40 +00001047 done
Bram Moolenaarac499e32013-06-02 19:14:17 +02001048 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001049 ])
1050
1051 PYTHON_CONFDIR="${vi_cv_path_python_conf}"
1052
1053 if test "X$PYTHON_CONFDIR" = "X"; then
1054 AC_MSG_RESULT([can't find it!])
1055 else
1056
1057 dnl -- we need to examine Python's config/Makefile too
1058 dnl see what the interpreter is built from
1059 AC_CACHE_VAL(vi_cv_path_python_plibs,
1060 [
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001061 pwd=`pwd`
1062 tmp_mkf="$pwd/config-PyMake$$"
1063 cat -- "${PYTHON_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001064__:
Bram Moolenaar218116c2010-05-20 21:46:00 +02001065 @echo "python_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001066 @echo "python_LIBS='$(LIBS)'"
1067 @echo "python_SYSLIBS='$(SYSLIBS)'"
1068 @echo "python_LINKFORSHARED='$(LINKFORSHARED)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001069 @echo "python_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001070 @echo "python_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001071eof
1072 dnl -- delete the lines from make about Entering/Leaving directory
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001073 eval "`cd ${PYTHON_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1074 rm -f -- "${tmp_mkf}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001075 if test "x$MACOSX" = "xyes" && ${vi_cv_path_python} -c \
1076 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then
1077 vi_cv_path_python_plibs="-framework Python"
1078 else
1079 if test "${vi_cv_var_python_version}" = "1.4"; then
1080 vi_cv_path_python_plibs="${PYTHON_CONFDIR}/libModules.a ${PYTHON_CONFDIR}/libPython.a ${PYTHON_CONFDIR}/libObjects.a ${PYTHON_CONFDIR}/libParser.a"
1081 else
1082 vi_cv_path_python_plibs="-L${PYTHON_CONFDIR} -lpython${vi_cv_var_python_version}"
1083 fi
Bram Moolenaar218116c2010-05-20 21:46:00 +02001084 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 +00001085 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1086 vi_cv_path_python_plibs=`echo $vi_cv_path_python_plibs | sed s/-ltermcap//`
1087 fi
1088 ])
1089
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001090 if test "X$python_DLLLIBRARY" != "X"; then
1091 python_INSTSONAME="$python_DLLLIBRARY"
1092 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001093 PYTHON_LIBS="${vi_cv_path_python_plibs}"
1094 if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
Bram Moolenaar780c3e92013-06-11 20:53:28 +02001095 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 +00001096 else
Bram Moolenaar780c3e92013-06-11 20:53:28 +02001097 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 +00001098 fi
1099 PYTHON_SRC="if_python.c"
Bram Moolenaar9bdb9a02012-07-25 16:32:08 +02001100 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001101 if test "${vi_cv_var_python_version}" = "1.4"; then
1102 PYTHON_OBJ="$PYTHON_OBJ objects/py_getpath.o"
1103 fi
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001104 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 +00001105
1106 dnl On FreeBSD linking with "-pthread" is required to use threads.
1107 dnl _THREAD_SAFE must be used for compiling then.
1108 dnl The "-pthread" is added to $LIBS, so that the following check for
1109 dnl sigaltstack() will look in libc_r (it's there in libc!).
1110 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1111 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1112 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1113 AC_MSG_CHECKING([if -pthread should be used])
1114 threadsafe_flag=
1115 thread_lib=
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00001116 dnl if test "x$MACOSX" != "xyes"; then
1117 if test "`(uname) 2>/dev/null`" != Darwin; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001118 test "$GCC" = yes && threadsafe_flag="-pthread"
1119 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1120 threadsafe_flag="-D_THREAD_SAFE"
1121 thread_lib="-pthread"
1122 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001123 if test "`(uname) 2>/dev/null`" = SunOS; then
1124 threadsafe_flag="-pthreads"
1125 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001126 fi
1127 libs_save_old=$LIBS
1128 if test -n "$threadsafe_flag"; then
1129 cflags_save=$CFLAGS
1130 CFLAGS="$CFLAGS $threadsafe_flag"
1131 LIBS="$LIBS $thread_lib"
1132 AC_TRY_LINK(,[ ],
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001133 AC_MSG_RESULT(yes); PYTHON_CFLAGS="$PYTHON_CFLAGS $threadsafe_flag",
Bram Moolenaar071d4272004-06-13 20:20:40 +00001134 AC_MSG_RESULT(no); LIBS=$libs_save_old
1135 )
1136 CFLAGS=$cflags_save
1137 else
1138 AC_MSG_RESULT(no)
1139 fi
1140
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001141 dnl Check that compiling a simple program still works with the flags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001142 dnl added for Python.
1143 AC_MSG_CHECKING([if compile and link flags for Python are sane])
1144 cflags_save=$CFLAGS
1145 libs_save=$LIBS
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001146 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001147 LIBS="$LIBS $PYTHON_LIBS"
1148 AC_TRY_LINK(,[ ],
1149 AC_MSG_RESULT(yes); python_ok=yes,
1150 AC_MSG_RESULT(no: PYTHON DISABLED); python_ok=no)
1151 CFLAGS=$cflags_save
1152 LIBS=$libs_save
1153 if test $python_ok = yes; then
1154 AC_DEFINE(FEAT_PYTHON)
1155 else
1156 LIBS=$libs_save_old
1157 PYTHON_SRC=
1158 PYTHON_OBJ=
1159 PYTHON_LIBS=
1160 PYTHON_CFLAGS=
1161 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001162 fi
1163 else
1164 AC_MSG_RESULT(too old)
1165 fi
1166 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001167
1168 if test "$fail_if_missing" = "yes" -a "$python_ok" != "yes"; then
1169 AC_MSG_ERROR([could not configure python])
1170 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001171fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001172
Bram Moolenaar071d4272004-06-13 20:20:40 +00001173AC_SUBST(PYTHON_CONFDIR)
1174AC_SUBST(PYTHON_LIBS)
1175AC_SUBST(PYTHON_GETPATH_CFLAGS)
1176AC_SUBST(PYTHON_CFLAGS)
1177AC_SUBST(PYTHON_SRC)
1178AC_SUBST(PYTHON_OBJ)
1179
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001180
1181AC_MSG_CHECKING(--enable-python3interp argument)
1182AC_ARG_ENABLE(python3interp,
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001183 [ --enable-python3interp[=OPTS] Include Python3 interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001184 [enable_python3interp="no"])
1185AC_MSG_RESULT($enable_python3interp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001186if test "$enable_python3interp" = "yes" -o "$enable_python3interp" = "dynamic"; then
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001187 dnl -- find the python3 executable
Bram Moolenaar09ba6d72012-12-12 14:25:05 +01001188 AC_PATH_PROGS(vi_cv_path_python3, python3 python)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001189 if test "X$vi_cv_path_python3" != "X"; then
1190
1191 dnl -- get its version number
1192 AC_CACHE_CHECK(Python version,vi_cv_var_python3_version,
1193 [[vi_cv_var_python3_version=`
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001194 ${vi_cv_path_python3} -c 'import sys; print(sys.version[:3])'`
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001195 ]])
1196
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001197 dnl -- it must be at least version 3
1198 AC_MSG_CHECKING(Python is 3.0 or better)
1199 if ${vi_cv_path_python3} -c \
1200 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.0)"
1201 then
1202 AC_MSG_RESULT(yep)
Bram Moolenaar456f2bb2011-06-12 21:37:13 +02001203
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001204 dnl -- get abiflags for python 3.2 or higher (PEP 3149)
1205 AC_CACHE_CHECK(Python's abiflags,vi_cv_var_python3_abiflags,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001206 [
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001207 vi_cv_var_python3_abiflags=
1208 if ${vi_cv_path_python3} -c \
1209 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)"
1210 then
1211 vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \
1212 "import sys; print(sys.abiflags)"`
1213 fi ])
1214
1215 dnl -- find where python3 thinks it was installed
1216 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx,
1217 [ vi_cv_path_python3_pfx=`
1218 ${vi_cv_path_python3} -c \
1219 "import sys; print(sys.prefix)"` ])
1220
1221 dnl -- and where it thinks it runs
1222 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx,
1223 [ vi_cv_path_python3_epfx=`
1224 ${vi_cv_path_python3} -c \
1225 "import sys; print(sys.exec_prefix)"` ])
1226
1227 dnl -- python3's internal library path
1228
1229 AC_CACHE_VAL(vi_cv_path_python3path,
1230 [ vi_cv_path_python3path=`
1231 unset PYTHONPATH;
1232 ${vi_cv_path_python3} -c \
1233 "import sys, string; print(':'.join(sys.path))"` ])
1234
1235 dnl -- where the Python implementation library archives are
1236
1237 AC_ARG_WITH(python3-config-dir,
1238 [ --with-python3-config-dir=PATH Python's config directory],
1239 [ vi_cv_path_python3_conf="${withval}" ] )
1240
1241 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf,
1242 [
1243 vi_cv_path_python3_conf=
Bram Moolenaarfee496d2013-07-12 20:07:24 +02001244 config_dir="config-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001245 d=`${vi_cv_path_python3} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBPL'))"`
1246 if test -d "$d" && test -f "$d/config.c"; then
1247 vi_cv_path_python3_conf="$d"
1248 else
1249 for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do
1250 for subdir in lib64 lib share; do
1251 d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}"
1252 if test -d "$d" && test -f "$d/config.c"; then
1253 vi_cv_path_python3_conf="$d"
1254 fi
1255 done
1256 done
1257 fi
1258 ])
1259
1260 PYTHON3_CONFDIR="${vi_cv_path_python3_conf}"
1261
1262 if test "X$PYTHON3_CONFDIR" = "X"; then
1263 AC_MSG_RESULT([can't find it!])
1264 else
1265
1266 dnl -- we need to examine Python's config/Makefile too
1267 dnl see what the interpreter is built from
1268 AC_CACHE_VAL(vi_cv_path_python3_plibs,
1269 [
1270 pwd=`pwd`
1271 tmp_mkf="$pwd/config-PyMake$$"
1272 cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001273__:
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001274 @echo "python3_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001275 @echo "python3_LIBS='$(LIBS)'"
1276 @echo "python3_SYSLIBS='$(SYSLIBS)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001277 @echo "python3_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001278 @echo "python3_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001279eof
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001280 dnl -- delete the lines from make about Entering/Leaving directory
1281 eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1282 rm -f -- "${tmp_mkf}"
1283 vi_cv_path_python3_plibs="-L${PYTHON3_CONFDIR} -lpython${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
1284 vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}"
1285 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1286 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//`
1287 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//`
1288 ])
1289
1290 if test "X$python3_DLLLIBRARY" != "X"; then
1291 python3_INSTSONAME="$python3_DLLLIBRARY"
1292 fi
1293 PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
1294 if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
Bram Moolenaar780c3e92013-06-11 20:53:28 +02001295 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 +02001296 else
Bram Moolenaar780c3e92013-06-11 20:53:28 +02001297 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 +02001298 fi
1299 PYTHON3_SRC="if_python3.c"
1300 PYTHON3_OBJ="objects/if_python3.o"
1301
1302 dnl On FreeBSD linking with "-pthread" is required to use threads.
1303 dnl _THREAD_SAFE must be used for compiling then.
1304 dnl The "-pthread" is added to $LIBS, so that the following check for
1305 dnl sigaltstack() will look in libc_r (it's there in libc!).
1306 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1307 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1308 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1309 AC_MSG_CHECKING([if -pthread should be used])
1310 threadsafe_flag=
1311 thread_lib=
1312 dnl if test "x$MACOSX" != "xyes"; then
1313 if test "`(uname) 2>/dev/null`" != Darwin; then
1314 test "$GCC" = yes && threadsafe_flag="-pthread"
1315 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1316 threadsafe_flag="-D_THREAD_SAFE"
1317 thread_lib="-pthread"
1318 fi
1319 if test "`(uname) 2>/dev/null`" = SunOS; then
1320 threadsafe_flag="-pthreads"
1321 fi
1322 fi
1323 libs_save_old=$LIBS
1324 if test -n "$threadsafe_flag"; then
1325 cflags_save=$CFLAGS
1326 CFLAGS="$CFLAGS $threadsafe_flag"
1327 LIBS="$LIBS $thread_lib"
1328 AC_TRY_LINK(,[ ],
1329 AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag",
1330 AC_MSG_RESULT(no); LIBS=$libs_save_old
1331 )
1332 CFLAGS=$cflags_save
1333 else
1334 AC_MSG_RESULT(no)
1335 fi
1336
1337 dnl check that compiling a simple program still works with the flags
1338 dnl added for Python.
1339 AC_MSG_CHECKING([if compile and link flags for Python 3 are sane])
1340 cflags_save=$CFLAGS
1341 libs_save=$LIBS
1342 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1343 LIBS="$LIBS $PYTHON3_LIBS"
1344 AC_TRY_LINK(,[ ],
1345 AC_MSG_RESULT(yes); python3_ok=yes,
1346 AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no)
1347 CFLAGS=$cflags_save
1348 LIBS=$libs_save
1349 if test "$python3_ok" = yes; then
1350 AC_DEFINE(FEAT_PYTHON3)
1351 else
1352 LIBS=$libs_save_old
1353 PYTHON3_SRC=
1354 PYTHON3_OBJ=
1355 PYTHON3_LIBS=
1356 PYTHON3_CFLAGS=
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001357 fi
1358 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001359 else
1360 AC_MSG_RESULT(too old)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001361 fi
1362 fi
Bram Moolenaar1612b1a2013-06-14 21:22:39 +02001363 if test "$fail_if_missing" = "yes" -a "$python3_ok" != "yes"; then
1364 AC_MSG_ERROR([could not configure python3])
1365 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001366fi
1367
1368AC_SUBST(PYTHON3_CONFDIR)
1369AC_SUBST(PYTHON3_LIBS)
1370AC_SUBST(PYTHON3_CFLAGS)
1371AC_SUBST(PYTHON3_SRC)
1372AC_SUBST(PYTHON3_OBJ)
1373
1374dnl if python2.x and python3.x are enabled one can only link in code
1375dnl with dlopen(), dlsym(), dlclose()
1376if test "$python_ok" = yes && test "$python3_ok" = yes; then
1377 AC_DEFINE(DYNAMIC_PYTHON)
1378 AC_DEFINE(DYNAMIC_PYTHON3)
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001379 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001380 cflags_save=$CFLAGS
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001381 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001382 ldflags_save=$LDFLAGS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001383 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
1384 LDFLAGS="-ldl $LDFLAGS"
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001385 AC_RUN_IFELSE([
1386 #include <dlfcn.h>
1387 /* If this program fails, then RTLD_GLOBAL is needed.
1388 * RTLD_GLOBAL will be used and then it is not possible to
1389 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001390 * Only the first python version used will be switched on.
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001391 */
1392
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001393 int no_rtl_global_needed_for(char *python_instsoname, char *prefix)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001394 {
1395 int needed = 0;
1396 void* pylib = dlopen(python_instsoname, RTLD_LAZY);
1397 if (pylib != 0)
1398 {
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001399 void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome");
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001400 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1401 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1402 void (*final)(void) = dlsym(pylib, "Py_Finalize");
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001403 (*pfx)(prefix);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001404 (*init)();
1405 needed = (*simple)("import termios") == -1;
1406 (*final)();
1407 dlclose(pylib);
1408 }
1409 return !needed;
1410 }
1411
1412 int main(int argc, char** argv)
1413 {
1414 int not_needed = 0;
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001415 if (no_rtl_global_needed_for("${python_INSTSONAME}", "${vi_cv_path_python_pfx}"))
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001416 not_needed = 1;
1417 return !not_needed;
1418 }],
1419 [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001420
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001421 CFLAGS=$cflags_save
1422 LDFLAGS=$ldflags_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001423
1424 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python3)
1425 cflags_save=$CFLAGS
1426 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1427 ldflags_save=$LDFLAGS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001428 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
1429 LDFLAGS="-ldl $LDFLAGS"
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001430 AC_RUN_IFELSE([
1431 #include <dlfcn.h>
1432 #include <wchar.h>
1433 /* If this program fails, then RTLD_GLOBAL is needed.
1434 * RTLD_GLOBAL will be used and then it is not possible to
1435 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001436 * Only the first python version used will be switched on.
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001437 */
1438
1439 int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix)
1440 {
1441 int needed = 0;
1442 void* pylib = dlopen(python_instsoname, RTLD_LAZY);
1443 if (pylib != 0)
1444 {
1445 void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome");
1446 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1447 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1448 void (*final)(void) = dlsym(pylib, "Py_Finalize");
1449 (*pfx)(prefix);
1450 (*init)();
1451 needed = (*simple)("import termios") == -1;
1452 (*final)();
1453 dlclose(pylib);
1454 }
1455 return !needed;
1456 }
1457
1458 int main(int argc, char** argv)
1459 {
1460 int not_needed = 0;
1461 if (no_rtl_global_needed_for("${python3_INSTSONAME}", L"${vi_cv_path_python3_pfx}"))
1462 not_needed = 1;
1463 return !not_needed;
1464 }],
1465 [AC_MSG_RESULT(yes);AC_DEFINE(PY3_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
1466
1467 CFLAGS=$cflags_save
1468 LDFLAGS=$ldflags_save
1469
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001470 PYTHON_SRC="if_python.c"
1471 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001472 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${python_INSTSONAME}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001473 PYTHON_LIBS=
1474 PYTHON3_SRC="if_python3.c"
1475 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001476 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${python3_INSTSONAME}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001477 PYTHON3_LIBS=
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001478elif test "$python_ok" = yes && test "$enable_pythoninterp" = "dynamic"; then
1479 AC_DEFINE(DYNAMIC_PYTHON)
1480 PYTHON_SRC="if_python.c"
1481 PYTHON_OBJ="objects/if_python.o"
1482 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${python_INSTSONAME}\\\""
1483 PYTHON_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001484elif test "$python_ok" = yes; then
1485 dnl Check that adding -fPIE works. It may be needed when using a static
1486 dnl Python library.
1487 AC_MSG_CHECKING([if -fPIE can be added for Python])
1488 cflags_save=$CFLAGS
1489 libs_save=$LIBS
1490 CFLAGS="$CFLAGS $PYTHON_CFLAGS -fPIE"
1491 LIBS="$LIBS $PYTHON_LIBS"
1492 AC_TRY_LINK(,[ ],
1493 AC_MSG_RESULT(yes); fpie_ok=yes,
1494 AC_MSG_RESULT(no); fpie_ok=no)
1495 CFLAGS=$cflags_save
1496 LIBS=$libs_save
1497 if test $fpie_ok = yes; then
1498 PYTHON_CFLAGS="$PYTHON_CFLAGS -fPIE"
1499 fi
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001500elif test "$python3_ok" = yes && test "$enable_python3interp" = "dynamic"; then
1501 AC_DEFINE(DYNAMIC_PYTHON3)
1502 PYTHON3_SRC="if_python3.c"
1503 PYTHON3_OBJ="objects/if_python3.o"
1504 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${python3_INSTSONAME}\\\""
1505 PYTHON3_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001506elif test "$python3_ok" = yes; then
1507 dnl Check that adding -fPIE works. It may be needed when using a static
1508 dnl Python library.
1509 AC_MSG_CHECKING([if -fPIE can be added for Python3])
1510 cflags_save=$CFLAGS
1511 libs_save=$LIBS
1512 CFLAGS="$CFLAGS $PYTHON3_CFLAGS -fPIE"
1513 LIBS="$LIBS $PYTHON3_LIBS"
1514 AC_TRY_LINK(,[ ],
1515 AC_MSG_RESULT(yes); fpie_ok=yes,
1516 AC_MSG_RESULT(no); fpie_ok=no)
1517 CFLAGS=$cflags_save
1518 LIBS=$libs_save
1519 if test $fpie_ok = yes; then
1520 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -fPIE"
1521 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001522fi
1523
Bram Moolenaar071d4272004-06-13 20:20:40 +00001524AC_MSG_CHECKING(--enable-tclinterp argument)
1525AC_ARG_ENABLE(tclinterp,
1526 [ --enable-tclinterp Include Tcl interpreter.], ,
1527 [enable_tclinterp="no"])
1528AC_MSG_RESULT($enable_tclinterp)
1529
1530if test "$enable_tclinterp" = "yes"; then
1531
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001532 dnl on FreeBSD tclsh is a silly script, look for tclsh8.[5420]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001533 AC_MSG_CHECKING(--with-tclsh argument)
1534 AC_ARG_WITH(tclsh, [ --with-tclsh=PATH which tclsh to use (default: tclsh8.0)],
1535 tclsh_name="$withval"; AC_MSG_RESULT($tclsh_name),
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001536 tclsh_name="tclsh8.5"; AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00001537 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1538 AC_SUBST(vi_cv_path_tcl)
1539
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001540 dnl when no specific version specified, also try 8.4, 8.2 and 8.0
1541 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.5"; then
1542 tclsh_name="tclsh8.4"
1543 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1544 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001545 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.4"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001546 tclsh_name="tclsh8.2"
1547 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1548 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001549 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.2"; then
1550 tclsh_name="tclsh8.0"
1551 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1552 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001553 dnl still didn't find it, try without version number
1554 if test "X$vi_cv_path_tcl" = "X"; then
1555 tclsh_name="tclsh"
1556 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1557 fi
1558 if test "X$vi_cv_path_tcl" != "X"; then
1559 AC_MSG_CHECKING(Tcl version)
1560 if echo 'exit [[expr [info tclversion] < 8.0]]' | $vi_cv_path_tcl - ; then
1561 tclver=`echo 'puts [[info tclversion]]' | $vi_cv_path_tcl -`
1562 AC_MSG_RESULT($tclver - OK);
1563 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 -`
1564
1565 AC_MSG_CHECKING(for location of Tcl include)
1566 if test "x$MACOSX" != "xyes"; then
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001567 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 +00001568 else
1569 dnl For Mac OS X 10.3, use the OS-provided framework location
1570 tclinc="/System/Library/Frameworks/Tcl.framework/Headers"
1571 fi
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001572 TCL_INC=
Bram Moolenaar071d4272004-06-13 20:20:40 +00001573 for try in $tclinc; do
1574 if test -f "$try/tcl.h"; then
1575 AC_MSG_RESULT($try/tcl.h)
1576 TCL_INC=$try
1577 break
1578 fi
1579 done
1580 if test -z "$TCL_INC"; then
1581 AC_MSG_RESULT(<not found>)
1582 SKIP_TCL=YES
1583 fi
1584 if test -z "$SKIP_TCL"; then
1585 AC_MSG_CHECKING(for location of tclConfig.sh script)
1586 if test "x$MACOSX" != "xyes"; then
1587 tclcnf=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001588 tclcnf="$tclcnf `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001589 else
1590 dnl For Mac OS X 10.3, use the OS-provided framework location
1591 tclcnf="/System/Library/Frameworks/Tcl.framework"
1592 fi
1593 for try in $tclcnf; do
1594 if test -f $try/tclConfig.sh; then
1595 AC_MSG_RESULT($try/tclConfig.sh)
1596 . $try/tclConfig.sh
1597 dnl use eval, because tcl 8.2 includes ${TCL_DBGX}
1598 TCL_LIBS=`eval echo "$TCL_LIB_SPEC $TCL_LIBS"`
1599 dnl Use $TCL_DEFS for -D_THREAD_SAFE et al. But only use the
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001600 dnl "-D_ABC" items. Watch out for -DFOO=long\ long.
Bram Moolenaar4394bff2008-07-24 11:21:31 +00001601 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 +00001602 break
1603 fi
1604 done
1605 if test -z "$TCL_LIBS"; then
1606 AC_MSG_RESULT(<not found>)
1607 AC_MSG_CHECKING(for Tcl library by myself)
1608 tcllib=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001609 tcllib="$tcllib `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001610 for ext in .so .a ; do
1611 for ver in "" $tclver ; do
1612 for try in $tcllib ; do
1613 trylib=tcl$ver$ext
1614 if test -f $try/lib$trylib ; then
1615 AC_MSG_RESULT($try/lib$trylib)
1616 TCL_LIBS="-L$try -ltcl$ver -ldl -lm"
1617 if test "`(uname) 2>/dev/null`" = SunOS &&
1618 uname -r | grep '^5' >/dev/null; then
1619 TCL_LIBS="$TCL_LIBS -R $try"
1620 fi
1621 break 3
1622 fi
1623 done
1624 done
1625 done
1626 if test -z "$TCL_LIBS"; then
1627 AC_MSG_RESULT(<not found>)
1628 SKIP_TCL=YES
1629 fi
1630 fi
1631 if test -z "$SKIP_TCL"; then
1632 AC_DEFINE(FEAT_TCL)
1633 TCL_SRC=if_tcl.c
1634 TCL_OBJ=objects/if_tcl.o
1635 TCL_PRO=if_tcl.pro
1636 TCL_CFLAGS="-I$TCL_INC $TCL_DEFS"
1637 fi
1638 fi
1639 else
1640 AC_MSG_RESULT(too old; need Tcl version 8.0 or later)
1641 fi
1642 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001643 if test "$fail_if_missing" = "yes" -a -z "$TCL_SRC"; then
1644 AC_MSG_ERROR([could not configure Tcl])
1645 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001646fi
1647AC_SUBST(TCL_SRC)
1648AC_SUBST(TCL_OBJ)
1649AC_SUBST(TCL_PRO)
1650AC_SUBST(TCL_CFLAGS)
1651AC_SUBST(TCL_LIBS)
1652
1653AC_MSG_CHECKING(--enable-rubyinterp argument)
1654AC_ARG_ENABLE(rubyinterp,
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001655 [ --enable-rubyinterp[=OPTS] Include Ruby interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001656 [enable_rubyinterp="no"])
1657AC_MSG_RESULT($enable_rubyinterp)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001658if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar165641d2010-02-17 16:23:09 +01001659 AC_MSG_CHECKING(--with-ruby-command argument)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001660 AC_SUBST(vi_cv_path_ruby)
Bram Moolenaar948733a2011-05-05 18:10:16 +02001661 AC_ARG_WITH(ruby-command, [ --with-ruby-command=RUBY name of the Ruby command (default: ruby)],
1662 RUBY_CMD="$withval"; vi_cv_path_ruby="$withval"; AC_MSG_RESULT($RUBY_CMD),
1663 RUBY_CMD="ruby"; AC_MSG_RESULT(defaulting to $RUBY_CMD))
Bram Moolenaar165641d2010-02-17 16:23:09 +01001664 AC_PATH_PROG(vi_cv_path_ruby, $RUBY_CMD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001665 if test "X$vi_cv_path_ruby" != "X"; then
1666 AC_MSG_CHECKING(Ruby version)
Bram Moolenaare4efc3b2005-03-07 23:16:51 +00001667 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 +00001668 AC_MSG_RESULT(OK)
Bram Moolenaar81398892012-10-03 21:09:35 +02001669 AC_MSG_CHECKING(Ruby rbconfig)
1670 ruby_rbconfig="RbConfig"
1671 if ! $vi_cv_path_ruby -r rbconfig -e 'RbConfig' >/dev/null 2>/dev/null; then
1672 ruby_rbconfig="Config"
1673 fi
1674 AC_MSG_RESULT($ruby_rbconfig)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001675 AC_MSG_CHECKING(Ruby header files)
Bram Moolenaar81398892012-10-03 21:09:35 +02001676 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 +00001677 if test "X$rubyhdrdir" != "X"; then
1678 AC_MSG_RESULT($rubyhdrdir)
1679 RUBY_CFLAGS="-I$rubyhdrdir"
Bram Moolenaar81398892012-10-03 21:09:35 +02001680 rubyarch=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['arch']]"`
Bram Moolenaar165641d2010-02-17 16:23:09 +01001681 if test -d "$rubyhdrdir/$rubyarch"; then
1682 RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyhdrdir/$rubyarch"
1683 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001684 rubyversion=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['ruby_version']].gsub(/\./, '')[[0,2]]"`
Bram Moolenaar026a4452013-08-07 15:22:23 +02001685 if test "X$rubyversion" = "X"; then
1686 rubyversion=`$vi_cv_path_ruby -e "print ((VERSION rescue RUBY_VERSION)).gsub(/\./, '')[[0,2]]"`
1687 fi
Bram Moolenaar165641d2010-02-17 16:23:09 +01001688 RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
Bram Moolenaar81398892012-10-03 21:09:35 +02001689 rubylibs=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LIBS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001690 if test "X$rubylibs" != "X"; then
1691 RUBY_LIBS="$rubylibs"
1692 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001693 librubyarg=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBYARG']])"`
1694 librubya=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBY_A']])"`
Bram Moolenaarac499e32013-06-02 19:14:17 +02001695 rubylibdir=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['libdir']])"`
Bram Moolenaar948733a2011-05-05 18:10:16 +02001696 if test -f "$rubylibdir/$librubya"; then
1697 librubyarg="$librubyarg"
Bram Moolenaarac499e32013-06-02 19:14:17 +02001698 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
1699 elif test "$librubyarg" = "libruby.a"; then
1700 dnl required on Mac OS 10.3 where libruby.a doesn't exist
1701 librubyarg="-lruby"
1702 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001703 fi
1704
1705 if test "X$librubyarg" != "X"; then
1706 RUBY_LIBS="$librubyarg $RUBY_LIBS"
1707 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001708 rubyldflags=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LDFLAGS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001709 if test "X$rubyldflags" != "X"; then
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001710 dnl Ruby on Mac OS X 10.5 adds "-arch" flags but these should only
1711 dnl be included if requested by passing --with-mac-arch to
1712 dnl configure, so strip these flags first (if present)
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001713 rubyldflags=`echo "$rubyldflags" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001714 if test "X$rubyldflags" != "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001715 if test "X`echo \"$LDFLAGS\" | grep -F -e \"$rubyldflags\"`" = "X"; then
1716 LDFLAGS="$rubyldflags $LDFLAGS"
1717 fi
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001718 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001719 fi
1720 RUBY_SRC="if_ruby.c"
1721 RUBY_OBJ="objects/if_ruby.o"
1722 RUBY_PRO="if_ruby.pro"
1723 AC_DEFINE(FEAT_RUBY)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001724 if test "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar81398892012-10-03 21:09:35 +02001725 libruby=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_SO']]"`
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001726 AC_DEFINE(DYNAMIC_RUBY)
1727 RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby\\\" -DDYNAMIC_RUBY_VER=$rubyversion $RUBY_CFLAGS"
1728 RUBY_LIBS=
1729 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001730 else
Bram Moolenaar165641d2010-02-17 16:23:09 +01001731 AC_MSG_RESULT(not found; disabling Ruby)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001732 fi
1733 else
1734 AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
1735 fi
1736 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001737
1738 if test "$fail_if_missing" = "yes" -a -z "$RUBY_OBJ"; then
1739 AC_MSG_ERROR([could not configure Ruby])
1740 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001741fi
1742AC_SUBST(RUBY_SRC)
1743AC_SUBST(RUBY_OBJ)
1744AC_SUBST(RUBY_PRO)
1745AC_SUBST(RUBY_CFLAGS)
1746AC_SUBST(RUBY_LIBS)
1747
1748AC_MSG_CHECKING(--enable-cscope argument)
1749AC_ARG_ENABLE(cscope,
1750 [ --enable-cscope Include cscope interface.], ,
1751 [enable_cscope="no"])
1752AC_MSG_RESULT($enable_cscope)
1753if test "$enable_cscope" = "yes"; then
1754 AC_DEFINE(FEAT_CSCOPE)
1755fi
1756
1757AC_MSG_CHECKING(--enable-workshop argument)
1758AC_ARG_ENABLE(workshop,
1759 [ --enable-workshop Include Sun Visual Workshop support.], ,
1760 [enable_workshop="no"])
1761AC_MSG_RESULT($enable_workshop)
1762if test "$enable_workshop" = "yes"; then
1763 AC_DEFINE(FEAT_SUN_WORKSHOP)
1764 WORKSHOP_SRC="workshop.c integration.c"
1765 AC_SUBST(WORKSHOP_SRC)
1766 WORKSHOP_OBJ="objects/workshop.o objects/integration.o"
1767 AC_SUBST(WORKSHOP_OBJ)
1768 if test "${enable_gui-xxx}" = xxx; then
1769 enable_gui=motif
1770 fi
1771fi
1772
1773AC_MSG_CHECKING(--disable-netbeans argument)
1774AC_ARG_ENABLE(netbeans,
1775 [ --disable-netbeans Disable NetBeans integration support.],
1776 , [enable_netbeans="yes"])
1777if test "$enable_netbeans" = "yes"; then
1778 AC_MSG_RESULT(no)
1779 dnl On Solaris we need the socket and nsl library.
1780 AC_CHECK_LIB(socket, socket)
1781 AC_CHECK_LIB(nsl, gethostbyname)
1782 AC_MSG_CHECKING(whether compiling netbeans integration is possible)
1783 AC_TRY_LINK([
1784#include <stdio.h>
1785#include <stdlib.h>
1786#include <stdarg.h>
1787#include <fcntl.h>
1788#include <netdb.h>
1789#include <netinet/in.h>
1790#include <errno.h>
1791#include <sys/types.h>
1792#include <sys/socket.h>
1793 /* Check bitfields */
1794 struct nbbuf {
1795 unsigned int initDone:1;
1796 ushort signmaplen;
1797 };
1798 ], [
1799 /* Check creating a socket. */
1800 struct sockaddr_in server;
1801 (void)socket(AF_INET, SOCK_STREAM, 0);
1802 (void)htons(100);
1803 (void)gethostbyname("microsoft.com");
1804 if (errno == ECONNREFUSED)
1805 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
1806 ],
1807 AC_MSG_RESULT(yes),
1808 AC_MSG_RESULT(no); enable_netbeans="no")
1809else
1810 AC_MSG_RESULT(yes)
1811fi
1812if test "$enable_netbeans" = "yes"; then
1813 AC_DEFINE(FEAT_NETBEANS_INTG)
1814 NETBEANS_SRC="netbeans.c"
1815 AC_SUBST(NETBEANS_SRC)
1816 NETBEANS_OBJ="objects/netbeans.o"
1817 AC_SUBST(NETBEANS_OBJ)
1818fi
1819
1820AC_MSG_CHECKING(--enable-sniff argument)
1821AC_ARG_ENABLE(sniff,
1822 [ --enable-sniff Include Sniff interface.], ,
1823 [enable_sniff="no"])
1824AC_MSG_RESULT($enable_sniff)
1825if test "$enable_sniff" = "yes"; then
1826 AC_DEFINE(FEAT_SNIFF)
1827 SNIFF_SRC="if_sniff.c"
1828 AC_SUBST(SNIFF_SRC)
1829 SNIFF_OBJ="objects/if_sniff.o"
1830 AC_SUBST(SNIFF_OBJ)
1831fi
1832
1833AC_MSG_CHECKING(--enable-multibyte argument)
1834AC_ARG_ENABLE(multibyte,
1835 [ --enable-multibyte Include multibyte editing support.], ,
1836 [enable_multibyte="no"])
1837AC_MSG_RESULT($enable_multibyte)
1838if test "$enable_multibyte" = "yes"; then
1839 AC_DEFINE(FEAT_MBYTE)
1840fi
1841
1842AC_MSG_CHECKING(--enable-hangulinput argument)
1843AC_ARG_ENABLE(hangulinput,
1844 [ --enable-hangulinput Include Hangul input support.], ,
1845 [enable_hangulinput="no"])
1846AC_MSG_RESULT($enable_hangulinput)
1847
1848AC_MSG_CHECKING(--enable-xim argument)
1849AC_ARG_ENABLE(xim,
1850 [ --enable-xim Include XIM input support.],
1851 AC_MSG_RESULT($enable_xim),
1852 [enable_xim="auto"; AC_MSG_RESULT(defaulting to auto)])
Bram Moolenaar071d4272004-06-13 20:20:40 +00001853
1854AC_MSG_CHECKING(--enable-fontset argument)
1855AC_ARG_ENABLE(fontset,
1856 [ --enable-fontset Include X fontset output support.], ,
1857 [enable_fontset="no"])
1858AC_MSG_RESULT($enable_fontset)
1859dnl defining FEAT_XFONTSET is delayed, so that it can be disabled for no GUI
1860
1861test -z "$with_x" && with_x=yes
1862test "${enable_gui-yes}" != no -a "x$MACOSX" != "xyes" -a "x$QNX" != "xyes" && with_x=yes
1863if test "$with_x" = no; then
1864 AC_MSG_RESULT(defaulting to: don't HAVE_X11)
1865else
1866 dnl Do this check early, so that its failure can override user requests.
1867
1868 AC_PATH_PROG(xmkmfpath, xmkmf)
1869
1870 AC_PATH_XTRA
1871
Bram Moolenaar2c704a72010-06-03 21:17:25 +02001872 dnl On z/OS Unix the X libraries are DLLs. To use them the code must
Bram Moolenaar071d4272004-06-13 20:20:40 +00001873 dnl be compiled with a special option.
1874 dnl Also add SM, ICE and Xmu to X_EXTRA_LIBS.
Bram Moolenaar2c704a72010-06-03 21:17:25 +02001875 if test "$zOSUnix" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001876 CFLAGS="$CFLAGS -W c,dll"
1877 LDFLAGS="$LDFLAGS -W l,dll"
1878 X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE -lXmu"
1879 fi
1880
1881 dnl On my HPUX system the X include dir is found, but the lib dir not.
1882 dnl This is a desparate try to fix this.
1883
1884 if test -d "$x_includes" && test ! -d "$x_libraries"; then
1885 x_libraries=`echo "$x_includes" | sed s/include/lib/`
1886 AC_MSG_RESULT(Corrected X libraries to $x_libraries)
1887 X_LIBS="$X_LIBS -L$x_libraries"
1888 if test "`(uname) 2>/dev/null`" = SunOS &&
1889 uname -r | grep '^5' >/dev/null; then
1890 X_LIBS="$X_LIBS -R $x_libraries"
1891 fi
1892 fi
1893
1894 if test -d "$x_libraries" && test ! -d "$x_includes"; then
1895 x_includes=`echo "$x_libraries" | sed s/lib/include/`
1896 AC_MSG_RESULT(Corrected X includes to $x_includes)
1897 X_CFLAGS="$X_CFLAGS -I$x_includes"
1898 fi
1899
1900 dnl Remove "-I/usr/include " from X_CFLAGS, should not be needed.
1901 X_CFLAGS="`echo $X_CFLAGS\ | sed 's%-I/usr/include %%'`"
1902 dnl Remove "-L/usr/lib " from X_LIBS, should not be needed.
1903 X_LIBS="`echo $X_LIBS\ | sed 's%-L/usr/lib %%'`"
1904 dnl Same for "-R/usr/lib ".
1905 X_LIBS="`echo $X_LIBS\ | sed -e 's%-R/usr/lib %%' -e 's%-R /usr/lib %%'`"
1906
1907
1908 dnl Check if the X11 header files are correctly installed. On some systems
Bram Moolenaar00ca2842008-06-26 20:14:00 +00001909 dnl Xlib.h includes files that don't exist. On some systems X11/Intrinsic.h
1910 dnl is missing.
Bram Moolenaar071d4272004-06-13 20:20:40 +00001911 AC_MSG_CHECKING(if X11 header files can be found)
1912 cflags_save=$CFLAGS
1913 CFLAGS="$CFLAGS $X_CFLAGS"
Bram Moolenaar00ca2842008-06-26 20:14:00 +00001914 AC_TRY_COMPILE([#include <X11/Xlib.h>
1915#include <X11/Intrinsic.h>], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001916 AC_MSG_RESULT(yes),
1917 AC_MSG_RESULT(no); no_x=yes)
1918 CFLAGS=$cflags_save
1919
1920 if test "${no_x-no}" = yes; then
1921 with_x=no
1922 else
1923 AC_DEFINE(HAVE_X11)
1924 X_LIB="-lXt -lX11";
1925 AC_SUBST(X_LIB)
1926
1927 ac_save_LDFLAGS="$LDFLAGS"
1928 LDFLAGS="-L$x_libraries $LDFLAGS"
1929
1930 dnl Check for -lXdmcp (needed on SunOS 4.1.4)
1931 dnl For HP-UX 10.20 it must be before -lSM -lICE
1932 AC_CHECK_LIB(Xdmcp, _XdmcpAuthDoIt, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lXdmcp"],,
1933 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXdmcp])
1934
1935 dnl Some systems need -lnsl -lsocket when testing for ICE.
1936 dnl The check above doesn't do this, try here (again). Also needed to get
1937 dnl them after Xdmcp. link.sh will remove them when not needed.
1938 dnl Check for other function than above to avoid the cached value
1939 AC_CHECK_LIB(ICE, IceOpenConnection,
1940 [X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE"],, [$X_EXTRA_LIBS])
1941
1942 dnl Check for -lXpm (needed for some versions of Motif)
1943 LDFLAGS="$X_LIBS $ac_save_LDFLAGS"
1944 AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [X_PRE_LIBS="$X_PRE_LIBS -lXpm"],,
1945 [-lXt $X_PRE_LIBS -lXpm -lX11 $X_EXTRA_LIBS])
1946
1947 dnl Check that the X11 header files don't use implicit declarations
1948 AC_MSG_CHECKING(if X11 header files implicitly declare return values)
1949 cflags_save=$CFLAGS
Bram Moolenaard1864592013-05-04 04:40:15 +02001950 dnl -Werror is GCC only, others like Solaris Studio might not like it
1951 if test "$GCC" = yes; then
1952 CFLAGS="$CFLAGS $X_CFLAGS -Werror"
1953 else
1954 CFLAGS="$CFLAGS $X_CFLAGS"
1955 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001956 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
1957 AC_MSG_RESULT(no),
1958 CFLAGS="$CFLAGS -Wno-implicit-int"
1959 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
1960 AC_MSG_RESULT(yes); cflags_save="$cflags_save -Wno-implicit-int",
1961 AC_MSG_RESULT(test failed)
1962 )
1963 )
1964 CFLAGS=$cflags_save
1965
1966 LDFLAGS="$ac_save_LDFLAGS"
1967
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00001968 AC_MSG_CHECKING(size of wchar_t is 2 bytes)
1969 AC_CACHE_VAL(ac_cv_small_wchar_t,
1970 [AC_TRY_RUN([
1971#include <X11/Xlib.h>
1972#if STDC_HEADERS
1973# include <stdlib.h>
1974# include <stddef.h>
1975#endif
1976 main()
1977 {
1978 if (sizeof(wchar_t) <= 2)
1979 exit(1);
1980 exit(0);
1981 }],
1982 ac_cv_small_wchar_t="no",
1983 ac_cv_small_wchar_t="yes",
1984 AC_MSG_ERROR(failed to compile test program))])
1985 AC_MSG_RESULT($ac_cv_small_wchar_t)
1986 if test "x$ac_cv_small_wchar_t" = "xyes" ; then
1987 AC_DEFINE(SMALL_WCHAR_T)
1988 fi
1989
Bram Moolenaar071d4272004-06-13 20:20:40 +00001990 fi
1991fi
1992
Bram Moolenaara7fc0102005-05-18 22:17:12 +00001993test "x$with_x" = xno -a "x$MACOSX" != "xyes" -a "x$QNX" != "xyes" && enable_gui=no
Bram Moolenaar071d4272004-06-13 20:20:40 +00001994
1995AC_MSG_CHECKING(--enable-gui argument)
1996AC_ARG_ENABLE(gui,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02001997 [ --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 +00001998
1999dnl Canonicalize the --enable-gui= argument so that it can be easily compared.
2000dnl Do not use character classes for portability with old tools.
2001enable_gui_canon=`echo "_$enable_gui" | \
2002 sed 's/[[ _+-]]//g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
2003
2004dnl Skip everything by default.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002005SKIP_GTK2=YES
2006SKIP_GNOME=YES
2007SKIP_MOTIF=YES
2008SKIP_ATHENA=YES
2009SKIP_NEXTAW=YES
2010SKIP_PHOTON=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002011SKIP_CARBON=YES
2012GUITYPE=NONE
2013
Bram Moolenaarb11160e2005-01-04 21:31:43 +00002014if test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002015 SKIP_PHOTON=
2016 case "$enable_gui_canon" in
2017 no) AC_MSG_RESULT(no GUI support)
2018 SKIP_PHOTON=YES ;;
2019 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
2020 auto) AC_MSG_RESULT(auto - automatic GUI support) ;;
2021 photon) AC_MSG_RESULT(Photon GUI support) ;;
2022 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2023 SKIP_PHOTON=YES ;;
2024 esac
2025
2026elif test "x$MACOSX" = "xyes" -a "x$with_x" = "xno" ; then
2027 SKIP_CARBON=
2028 case "$enable_gui_canon" in
2029 no) AC_MSG_RESULT(no GUI support)
2030 SKIP_CARBON=YES ;;
2031 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
Bram Moolenaar164fca32010-07-14 13:58:07 +02002032 auto) AC_MSG_RESULT(auto - Carbon GUI is outdated - disable GUI support)
2033 SKIP_CARBON=YES ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002034 carbon) AC_MSG_RESULT(Carbon GUI support) ;;
2035 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2036 SKIP_CARBON=YES ;;
2037 esac
2038
2039else
2040
Bram Moolenaar071d4272004-06-13 20:20:40 +00002041 case "$enable_gui_canon" in
2042 no|none) AC_MSG_RESULT(no GUI support) ;;
2043 yes|""|auto) AC_MSG_RESULT(yes/auto - automatic GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002044 SKIP_GTK2=
2045 SKIP_GNOME=
2046 SKIP_MOTIF=
2047 SKIP_ATHENA=
2048 SKIP_NEXTAW=
2049 SKIP_CARBON=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002050 gtk2) AC_MSG_RESULT(GTK+ 2.x GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002051 SKIP_GTK2=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002052 gnome2) AC_MSG_RESULT(GNOME 2.x GUI support)
2053 SKIP_GNOME=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002054 SKIP_GTK2=;;
2055 motif) AC_MSG_RESULT(Motif GUI support)
2056 SKIP_MOTIF=;;
2057 athena) AC_MSG_RESULT(Athena GUI support)
2058 SKIP_ATHENA=;;
2059 nextaw) AC_MSG_RESULT(neXtaw GUI support)
2060 SKIP_NEXTAW=;;
2061 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
2062 esac
2063
2064fi
2065
Bram Moolenaar071d4272004-06-13 20:20:40 +00002066if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \
2067 -a "$enable_gui_canon" != "gnome2"; then
2068 AC_MSG_CHECKING(whether or not to look for GTK+ 2)
2069 AC_ARG_ENABLE(gtk2-check,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002070 [ --enable-gtk2-check If auto-select GUI, check for GTK+ 2 [default=yes]],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002071 , enable_gtk2_check="yes")
2072 AC_MSG_RESULT($enable_gtk2_check)
2073 if test "x$enable_gtk2_check" = "xno"; then
2074 SKIP_GTK2=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002075 SKIP_GNOME=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002076 fi
2077fi
2078
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002079if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002080 AC_MSG_CHECKING(whether or not to look for GNOME)
2081 AC_ARG_ENABLE(gnome-check,
2082 [ --enable-gnome-check If GTK GUI, check for GNOME [default=no]],
2083 , enable_gnome_check="no")
2084 AC_MSG_RESULT($enable_gnome_check)
2085 if test "x$enable_gnome_check" = "xno"; then
2086 SKIP_GNOME=YES
2087 fi
2088fi
2089
2090if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then
2091 AC_MSG_CHECKING(whether or not to look for Motif)
2092 AC_ARG_ENABLE(motif-check,
2093 [ --enable-motif-check If auto-select GUI, check for Motif [default=yes]],
2094 , enable_motif_check="yes")
2095 AC_MSG_RESULT($enable_motif_check)
2096 if test "x$enable_motif_check" = "xno"; then
2097 SKIP_MOTIF=YES
2098 fi
2099fi
2100
2101if test "x$SKIP_ATHENA" != "xYES" -a "$enable_gui_canon" != "athena"; then
2102 AC_MSG_CHECKING(whether or not to look for Athena)
2103 AC_ARG_ENABLE(athena-check,
2104 [ --enable-athena-check If auto-select GUI, check for Athena [default=yes]],
2105 , enable_athena_check="yes")
2106 AC_MSG_RESULT($enable_athena_check)
2107 if test "x$enable_athena_check" = "xno"; then
2108 SKIP_ATHENA=YES
2109 fi
2110fi
2111
2112if test "x$SKIP_NEXTAW" != "xYES" -a "$enable_gui_canon" != "nextaw"; then
2113 AC_MSG_CHECKING(whether or not to look for neXtaw)
2114 AC_ARG_ENABLE(nextaw-check,
2115 [ --enable-nextaw-check If auto-select GUI, check for neXtaw [default=yes]],
2116 , enable_nextaw_check="yes")
2117 AC_MSG_RESULT($enable_nextaw_check);
2118 if test "x$enable_nextaw_check" = "xno"; then
2119 SKIP_NEXTAW=YES
2120 fi
2121fi
2122
2123if test "x$SKIP_CARBON" != "xYES" -a "$enable_gui_canon" != "carbon"; then
2124 AC_MSG_CHECKING(whether or not to look for Carbon)
2125 AC_ARG_ENABLE(carbon-check,
2126 [ --enable-carbon-check If auto-select GUI, check for Carbon [default=yes]],
2127 , enable_carbon_check="yes")
2128 AC_MSG_RESULT($enable_carbon_check);
2129 if test "x$enable_carbon_check" = "xno"; then
2130 SKIP_CARBON=YES
2131 fi
2132fi
2133
Bram Moolenaar843ee412004-06-30 16:16:41 +00002134
Bram Moolenaar071d4272004-06-13 20:20:40 +00002135if test "x$MACOSX" = "xyes" -a -z "$SKIP_CARBON" -a "x$CARBON" = "xyes"; then
2136 AC_MSG_CHECKING(for Carbon GUI)
Bram Moolenaar14716812006-05-04 21:54:08 +00002137 dnl already did the check, just give the message
Bram Moolenaar071d4272004-06-13 20:20:40 +00002138 AC_MSG_RESULT(yes);
2139 GUITYPE=CARBONGUI
Bram Moolenaare344bea2005-09-01 20:46:49 +00002140 if test "$VIMNAME" = "vim"; then
2141 VIMNAME=Vim
2142 fi
Bram Moolenaar14716812006-05-04 21:54:08 +00002143
Bram Moolenaar164fca32010-07-14 13:58:07 +02002144 if test "x$MACARCH" = "xboth"; then
2145 CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk/Developer/Headers/FlatCarbon"
2146 else
2147 CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/Headers/FlatCarbon"
2148 fi
2149
Bram Moolenaar14716812006-05-04 21:54:08 +00002150 dnl Default install directory is not /usr/local
2151 if test x$prefix = xNONE; then
2152 prefix=/Applications
2153 fi
2154
2155 dnl Sorry for the hard coded default
2156 datadir='${prefix}/Vim.app/Contents/Resources'
2157
Bram Moolenaar071d4272004-06-13 20:20:40 +00002158 dnl skip everything else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002159 SKIP_GTK2=YES;
2160 SKIP_GNOME=YES;
2161 SKIP_MOTIF=YES;
2162 SKIP_ATHENA=YES;
2163 SKIP_NEXTAW=YES;
2164 SKIP_PHOTON=YES;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002165 SKIP_CARBON=YES
2166fi
2167
Bram Moolenaar071d4272004-06-13 20:20:40 +00002168dnl define an autoconf function to check for a specified version of GTK, and
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002169dnl try to compile/link a GTK program.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002170dnl
2171dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002172dnl Test for GTK, and define GTK_CFLAGS, GTK_LIBDIR and GTK_LIBS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002173dnl
2174AC_DEFUN(AM_PATH_GTK,
2175[
2176 if test "X$GTK_CONFIG" != "Xno" -o "X$PKG_CONFIG" != "Xno"; then
2177 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002178 min_gtk_version=ifelse([$1], ,2.2.0,$1)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002179 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
2180 no_gtk=""
2181 if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2182 && $PKG_CONFIG --exists gtk+-2.0; then
2183 {
2184 dnl We should be using PKG_CHECK_MODULES() instead of this hack.
2185 dnl But I guess the dependency on pkgconfig.m4 is not wanted or
2186 dnl something like that.
2187 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0`
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002188 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-2.0`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002189 GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0`
2190 gtk_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2191 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2192 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2193 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2194 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2195 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2196 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002197 else
2198 no_gtk=yes
2199 fi
2200
2201 if test "x$enable_gtktest" = "xyes" -a "x$no_gtk" = "x"; then
2202 {
2203 ac_save_CFLAGS="$CFLAGS"
2204 ac_save_LIBS="$LIBS"
2205 CFLAGS="$CFLAGS $GTK_CFLAGS"
2206 LIBS="$LIBS $GTK_LIBS"
2207
2208 dnl
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002209 dnl Now check if the installed GTK is sufficiently new.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002210 dnl
2211 rm -f conf.gtktest
2212 AC_TRY_RUN([
2213#include <gtk/gtk.h>
2214#include <stdio.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00002215#if STDC_HEADERS
2216# include <stdlib.h>
2217# include <stddef.h>
2218#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002219
2220int
2221main ()
2222{
2223int major, minor, micro;
2224char *tmp_version;
2225
2226system ("touch conf.gtktest");
2227
2228/* HP/UX 9 (%@#!) writes to sscanf strings */
2229tmp_version = g_strdup("$min_gtk_version");
2230if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
2231 printf("%s, bad version string\n", "$min_gtk_version");
2232 exit(1);
2233 }
2234
2235if ((gtk_major_version > major) ||
2236 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
2237 ((gtk_major_version == major) && (gtk_minor_version == minor) &&
2238 (gtk_micro_version >= micro)))
2239{
2240 return 0;
2241}
2242return 1;
2243}
2244],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
2245 CFLAGS="$ac_save_CFLAGS"
2246 LIBS="$ac_save_LIBS"
2247 }
2248 fi
2249 if test "x$no_gtk" = x ; then
2250 if test "x$enable_gtktest" = "xyes"; then
2251 AC_MSG_RESULT(yes; found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2252 else
2253 AC_MSG_RESULT(found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2254 fi
2255 ifelse([$2], , :, [$2])
2256 else
2257 {
2258 AC_MSG_RESULT(no)
2259 GTK_CFLAGS=""
2260 GTK_LIBS=""
2261 ifelse([$3], , :, [$3])
2262 }
2263 fi
2264 }
2265 else
2266 GTK_CFLAGS=""
2267 GTK_LIBS=""
2268 ifelse([$3], , :, [$3])
2269 fi
2270 AC_SUBST(GTK_CFLAGS)
2271 AC_SUBST(GTK_LIBS)
2272 rm -f conf.gtktest
2273])
2274
2275dnl ---------------------------------------------------------------------------
2276dnl gnome
2277dnl ---------------------------------------------------------------------------
2278AC_DEFUN([GNOME_INIT_HOOK],
2279[
2280 AC_SUBST(GNOME_LIBS)
2281 AC_SUBST(GNOME_LIBDIR)
2282 AC_SUBST(GNOME_INCLUDEDIR)
2283
2284 AC_ARG_WITH(gnome-includes,
2285 [ --with-gnome-includes=DIR Specify location of GNOME headers],
2286 [CFLAGS="$CFLAGS -I$withval"]
2287 )
2288
2289 AC_ARG_WITH(gnome-libs,
2290 [ --with-gnome-libs=DIR Specify location of GNOME libs],
2291 [LDFLAGS="$LDFLAGS -L$withval" gnome_prefix=$withval]
2292 )
2293
2294 AC_ARG_WITH(gnome,
2295 [ --with-gnome Specify prefix for GNOME files],
2296 if test x$withval = xyes; then
2297 want_gnome=yes
2298 ifelse([$1], [], :, [$1])
2299 else
2300 if test "x$withval" = xno; then
2301 want_gnome=no
2302 else
2303 want_gnome=yes
2304 LDFLAGS="$LDFLAGS -L$withval/lib"
2305 CFLAGS="$CFLAGS -I$withval/include"
2306 gnome_prefix=$withval/lib
2307 fi
2308 fi,
2309 want_gnome=yes)
2310
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002311 if test "x$want_gnome" = xyes; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002312 {
2313 AC_MSG_CHECKING(for libgnomeui-2.0)
2314 if $PKG_CONFIG --exists libgnomeui-2.0; then
2315 AC_MSG_RESULT(yes)
2316 GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0`
2317 GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0`
2318 GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0`
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002319
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002320 dnl On FreeBSD we need -pthread but pkg-config doesn't include it.
2321 dnl This might not be the right way but it works for me...
2322 AC_MSG_CHECKING(for FreeBSD)
2323 if test "`(uname) 2>/dev/null`" = FreeBSD; then
2324 AC_MSG_RESULT(yes, adding -pthread)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002325 GNOME_INCLUDEDIR="$GNOME_INCLUDEDIR -D_THREAD_SAFE"
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002326 GNOME_LIBS="$GNOME_LIBS -pthread"
2327 else
2328 AC_MSG_RESULT(no)
2329 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002330 $1
2331 else
2332 AC_MSG_RESULT(not found)
2333 if test "x$2" = xfail; then
2334 AC_MSG_ERROR(Could not find libgnomeui-2.0 via pkg-config)
2335 fi
2336 fi
2337 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002338 fi
2339])
2340
2341AC_DEFUN([GNOME_INIT],[
2342 GNOME_INIT_HOOK([],fail)
2343])
2344
2345
2346dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002347dnl Check for GTK2. If it fails, then continue on for Motif as before...
Bram Moolenaar071d4272004-06-13 20:20:40 +00002348dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002349if test -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002350
2351 AC_MSG_CHECKING(--disable-gtktest argument)
2352 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2353 , enable_gtktest=yes)
2354 if test "x$enable_gtktest" = "xyes" ; then
2355 AC_MSG_RESULT(gtk test enabled)
2356 else
2357 AC_MSG_RESULT(gtk test disabled)
2358 fi
2359
Bram Moolenaar071d4272004-06-13 20:20:40 +00002360 if test "X$PKG_CONFIG" = "X"; then
2361 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
2362 fi
2363
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002364 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002365 dnl First try finding version 2.2.0 or later. The 2.0.x series has
2366 dnl problems (bold fonts, --remote doesn't work).
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002367 AM_PATH_GTK(2.2.0,
2368 [GUI_LIB_LOC="$GTK_LIBDIR"
2369 GTK_LIBNAME="$GTK_LIBS"
2370 GUI_INC_LOC="$GTK_CFLAGS"], )
2371 if test "x$GTK_CFLAGS" != "x"; then
2372 SKIP_ATHENA=YES
2373 SKIP_NEXTAW=YES
2374 SKIP_MOTIF=YES
2375 GUITYPE=GTK
2376 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002377 fi
2378 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002379 if test "x$GUITYPE" = "xGTK"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002380 if test "$gtk_minor_version" = 1 -a "0$gtk_micro_version" -ge 1 \
2381 || test "0$gtk_minor_version" -ge 2; then
2382 AC_DEFINE(HAVE_GTK_MULTIHEAD)
2383 fi
2384 dnl
2385 dnl if GTK exists, then check for GNOME.
2386 dnl
2387 if test -z "$SKIP_GNOME"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002388 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002389 GNOME_INIT_HOOK([have_gnome=yes])
2390 if test "x$have_gnome" = xyes ; then
2391 AC_DEFINE(FEAT_GUI_GNOME)
2392 GUI_INC_LOC="$GUI_INC_LOC $GNOME_INCLUDEDIR"
2393 GTK_LIBNAME="$GTK_LIBNAME $GNOME_LIBDIR $GNOME_LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002394 fi
2395 }
2396 fi
2397 fi
2398fi
2399
2400dnl Check for Motif include files location.
2401dnl The LAST one found is used, this makes the highest version to be used,
2402dnl e.g. when Motif1.2 and Motif2.0 are both present.
2403
2404if test -z "$SKIP_MOTIF"; then
2405 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"
2406 dnl Remove "-I" from before $GUI_INC_LOC if it's there
2407 GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`"
2408
2409 AC_MSG_CHECKING(for location of Motif GUI includes)
2410 gui_includes="`echo $x_includes|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC"
2411 GUI_INC_LOC=
2412 for try in $gui_includes; do
2413 if test -f "$try/Xm/Xm.h"; then
2414 GUI_INC_LOC=$try
2415 fi
2416 done
2417 if test -n "$GUI_INC_LOC"; then
2418 if test "$GUI_INC_LOC" = /usr/include; then
2419 GUI_INC_LOC=
2420 AC_MSG_RESULT(in default path)
2421 else
2422 AC_MSG_RESULT($GUI_INC_LOC)
2423 fi
2424 else
2425 AC_MSG_RESULT(<not found>)
2426 SKIP_MOTIF=YES
2427 fi
2428fi
2429
2430dnl Check for Motif library files location. In the same order as the include
2431dnl files, to avoid a mixup if several versions are present
2432
2433if test -z "$SKIP_MOTIF"; then
2434 AC_MSG_CHECKING(--with-motif-lib argument)
2435 AC_ARG_WITH(motif-lib,
2436 [ --with-motif-lib=STRING Library for Motif ],
2437 [ MOTIF_LIBNAME="${withval}" ] )
2438
2439 if test -n "$MOTIF_LIBNAME"; then
2440 AC_MSG_RESULT($MOTIF_LIBNAME)
2441 GUI_LIB_LOC=
2442 else
2443 AC_MSG_RESULT(no)
2444
2445 dnl Remove "-L" from before $GUI_LIB_LOC if it's there
2446 GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
2447
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002448 dnl Ubuntu has libXm.so in /usr/lib/i386-linux-gnu and elsewhere. The
2449 dnl linker will figure out which one to use, we only check if one exists.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002450 AC_MSG_CHECKING(for location of Motif GUI libs)
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002451 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 +00002452 GUI_LIB_LOC=
2453 for try in $gui_libs; do
Bram Moolenaar325b7a22004-07-05 15:58:32 +00002454 for libtry in "$try"/libXm.a "$try"/libXm.so* "$try"/libXm.sl "$try"/libXm.dylib; do
Bram Moolenaar071d4272004-06-13 20:20:40 +00002455 if test -f "$libtry"; then
2456 GUI_LIB_LOC=$try
2457 fi
2458 done
2459 done
2460 if test -n "$GUI_LIB_LOC"; then
2461 dnl Remove /usr/lib, it causes trouble on some systems
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002462 if test "$GUI_LIB_LOC" = /usr/lib \
2463 -o "$GUI_LIB_LOC" = /usr/lib/i386-linux-gnu \
2464 -o "$GUI_LIB_LOC" = /usr/lib/x86_64-linux-gnu; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002465 GUI_LIB_LOC=
2466 AC_MSG_RESULT(in default path)
2467 else
2468 if test -n "$GUI_LIB_LOC"; then
2469 AC_MSG_RESULT($GUI_LIB_LOC)
2470 if test "`(uname) 2>/dev/null`" = SunOS &&
2471 uname -r | grep '^5' >/dev/null; then
2472 GUI_LIB_LOC="$GUI_LIB_LOC -R $GUI_LIB_LOC"
2473 fi
2474 fi
2475 fi
2476 MOTIF_LIBNAME=-lXm
2477 else
2478 AC_MSG_RESULT(<not found>)
2479 SKIP_MOTIF=YES
2480 fi
2481 fi
2482fi
2483
2484if test -z "$SKIP_MOTIF"; then
2485 SKIP_ATHENA=YES
2486 SKIP_NEXTAW=YES
2487 GUITYPE=MOTIF
2488 AC_SUBST(MOTIF_LIBNAME)
2489fi
2490
2491dnl Check if the Athena files can be found
2492
2493GUI_X_LIBS=
2494
2495if test -z "$SKIP_ATHENA"; then
2496 AC_MSG_CHECKING(if Athena header files can be found)
2497 cflags_save=$CFLAGS
2498 CFLAGS="$CFLAGS $X_CFLAGS"
2499 AC_TRY_COMPILE([
2500#include <X11/Intrinsic.h>
2501#include <X11/Xaw/Paned.h>], ,
2502 AC_MSG_RESULT(yes),
2503 AC_MSG_RESULT(no); SKIP_ATHENA=YES )
2504 CFLAGS=$cflags_save
2505fi
2506
2507if test -z "$SKIP_ATHENA"; then
2508 GUITYPE=ATHENA
2509fi
2510
2511if test -z "$SKIP_NEXTAW"; then
2512 AC_MSG_CHECKING(if neXtaw header files can be found)
2513 cflags_save=$CFLAGS
2514 CFLAGS="$CFLAGS $X_CFLAGS"
2515 AC_TRY_COMPILE([
2516#include <X11/Intrinsic.h>
2517#include <X11/neXtaw/Paned.h>], ,
2518 AC_MSG_RESULT(yes),
2519 AC_MSG_RESULT(no); SKIP_NEXTAW=YES )
2520 CFLAGS=$cflags_save
2521fi
2522
2523if test -z "$SKIP_NEXTAW"; then
2524 GUITYPE=NEXTAW
2525fi
2526
2527if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
2528 dnl Prepend -I and -L to $GUI_INC_LOC and $GUI_LIB_LOC if not empty
2529 dnl Avoid adding it when it twice
2530 if test -n "$GUI_INC_LOC"; then
2531 GUI_INC_LOC=-I"`echo $GUI_INC_LOC|sed 's%-I%%'`"
2532 fi
2533 if test -n "$GUI_LIB_LOC"; then
2534 GUI_LIB_LOC=-L"`echo $GUI_LIB_LOC|sed 's%-L%%'`"
2535 fi
2536
2537 dnl Check for -lXext and then for -lXmu
2538 ldflags_save=$LDFLAGS
2539 LDFLAGS="$X_LIBS $LDFLAGS"
2540 AC_CHECK_LIB(Xext, XShapeQueryExtension, [GUI_X_LIBS="-lXext"],,
2541 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2542 dnl For Solaris we need -lw and -ldl before linking with -lXmu works.
2543 AC_CHECK_LIB(w, wslen, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lw"],,
2544 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2545 AC_CHECK_LIB(dl, dlsym, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldl"],,
2546 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2547 AC_CHECK_LIB(Xmu, XmuCreateStippledPixmap, [GUI_X_LIBS="-lXmu $GUI_X_LIBS"],,
2548 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2549 if test -z "$SKIP_MOTIF"; then
2550 AC_CHECK_LIB(Xp, XpEndJob, [GUI_X_LIBS="-lXp $GUI_X_LIBS"],,
2551 [$GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2552 fi
2553 LDFLAGS=$ldflags_save
2554
2555 dnl Execute xmkmf to figure out if -DNARROWPROTO is needed.
2556 AC_MSG_CHECKING(for extra X11 defines)
2557 NARROW_PROTO=
2558 rm -fr conftestdir
2559 if mkdir conftestdir; then
2560 cd conftestdir
2561 cat > Imakefile <<'EOF'
2562acfindx:
2563 @echo 'NARROW_PROTO="${PROTO_DEFINES}"'
2564EOF
2565 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
2566 eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
2567 fi
2568 cd ..
2569 rm -fr conftestdir
2570 fi
2571 if test -z "$NARROW_PROTO"; then
2572 AC_MSG_RESULT(no)
2573 else
2574 AC_MSG_RESULT($NARROW_PROTO)
2575 fi
2576 AC_SUBST(NARROW_PROTO)
2577fi
2578
2579dnl Look for XSMP support - but don't necessarily restrict it to X11 GUIs
2580dnl use the X11 include path
2581if test "$enable_xsmp" = "yes"; then
2582 cppflags_save=$CPPFLAGS
2583 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2584 AC_CHECK_HEADERS(X11/SM/SMlib.h)
2585 CPPFLAGS=$cppflags_save
2586fi
2587
2588
Bram Moolenaare667c952010-07-05 22:57:59 +02002589if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF" -o -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002590 dnl Check for X11/xpm.h and X11/Sunkeysym.h with the GUI include path
2591 cppflags_save=$CPPFLAGS
2592 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2593 AC_CHECK_HEADERS(X11/xpm.h X11/Sunkeysym.h)
2594
2595 dnl automatically disable XIM when XIMtext isn't in X11/Xlib.h
2596 if test ! "$enable_xim" = "no"; then
2597 AC_MSG_CHECKING(for XIMText in X11/Xlib.h)
2598 AC_EGREP_CPP(XIMText, [#include <X11/Xlib.h>],
2599 AC_MSG_RESULT(yes),
2600 AC_MSG_RESULT(no; xim has been disabled); enable_xim = "no")
2601 fi
2602 CPPFLAGS=$cppflags_save
2603
2604 dnl automatically enable XIM when hangul input isn't enabled
2605 if test "$enable_xim" = "auto" -a "$enable_hangulinput" != "yes" \
2606 -a "x$GUITYPE" != "xNONE" ; then
2607 AC_MSG_RESULT(X GUI selected; xim has been enabled)
2608 enable_xim="yes"
2609 fi
2610fi
2611
2612if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
2613 cppflags_save=$CPPFLAGS
2614 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00002615dnl Xmu/Editres.h may exist but can only be used after including Intrinsic.h
2616 AC_MSG_CHECKING([for X11/Xmu/Editres.h])
2617 AC_TRY_COMPILE([
2618#include <X11/Intrinsic.h>
2619#include <X11/Xmu/Editres.h>],
2620 [int i; i = 0;],
2621 AC_MSG_RESULT(yes)
2622 AC_DEFINE(HAVE_X11_XMU_EDITRES_H),
2623 AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00002624 CPPFLAGS=$cppflags_save
2625fi
2626
2627dnl Only use the Xm directory when compiling Motif, don't use it for Athena
2628if test -z "$SKIP_MOTIF"; then
2629 cppflags_save=$CPPFLAGS
2630 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar77c19352012-06-13 19:19:41 +02002631 if test "$zOSUnix" = "yes"; then
2632 xmheader="Xm/Xm.h"
2633 else
2634 xmheader="Xm/Xm.h Xm/XpmP.h Xm/JoinSideT.h Xm/TraitP.h Xm/Manager.h
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02002635 Xm/UnhighlightT.h Xm/Notebook.h"
Bram Moolenaar77c19352012-06-13 19:19:41 +02002636 fi
2637 AC_CHECK_HEADERS($xmheader)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00002638
Bram Moolenaar77c19352012-06-13 19:19:41 +02002639 if test "x$ac_cv_header_Xm_XpmP_h" = "xyes"; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +00002640 dnl Solaris uses XpmAttributes_21, very annoying.
2641 AC_MSG_CHECKING([for XpmAttributes_21 in Xm/XpmP.h])
2642 AC_TRY_COMPILE([#include <Xm/XpmP.h>], [XpmAttributes_21 attr;],
2643 AC_MSG_RESULT(yes); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes_21),
2644 AC_MSG_RESULT(no); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
2645 )
2646 else
Bram Moolenaar57657d82006-04-21 22:12:41 +00002647 AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00002648 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002649 CPPFLAGS=$cppflags_save
2650fi
2651
2652if test "x$GUITYPE" = "xNONE" -a "$enable_xim" = "yes"; then
2653 AC_MSG_RESULT(no GUI selected; xim has been disabled)
2654 enable_xim="no"
2655fi
2656if test "x$GUITYPE" = "xNONE" -a "$enable_fontset" = "yes"; then
2657 AC_MSG_RESULT(no GUI selected; fontset has been disabled)
2658 enable_fontset="no"
2659fi
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002660if test "x$GUITYPE:$enable_fontset" = "xGTK:yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002661 AC_MSG_RESULT(GTK+ 2 GUI selected; fontset has been disabled)
2662 enable_fontset="no"
2663fi
2664
Bram Moolenaar071d4272004-06-13 20:20:40 +00002665if test -z "$SKIP_PHOTON"; then
2666 GUITYPE=PHOTONGUI
2667fi
2668
2669AC_SUBST(GUI_INC_LOC)
2670AC_SUBST(GUI_LIB_LOC)
2671AC_SUBST(GUITYPE)
2672AC_SUBST(GUI_X_LIBS)
2673
2674if test "$enable_workshop" = "yes" -a -n "$SKIP_MOTIF"; then
2675 AC_MSG_ERROR([cannot use workshop without Motif])
2676fi
2677
2678dnl defining FEAT_XIM and FEAT_XFONTSET is delayed, so that they can be disabled
2679if test "$enable_xim" = "yes"; then
2680 AC_DEFINE(FEAT_XIM)
2681fi
2682if test "$enable_fontset" = "yes"; then
2683 AC_DEFINE(FEAT_XFONTSET)
2684fi
2685
2686
2687dnl ---------------------------------------------------------------------------
2688dnl end of GUI-checking
2689dnl ---------------------------------------------------------------------------
2690
Bram Moolenaar693e40c2013-02-26 14:56:42 +01002691dnl Check for Cygwin, which needs an extra source file if not using X11
2692AC_MSG_CHECKING(for CYGWIN environment)
2693case `uname` in
2694 CYGWIN*) CYGWIN=yes; AC_MSG_RESULT(yes)
2695 AC_MSG_CHECKING(for CYGWIN clipboard support)
2696 if test "x$with_x" = "xno" ; then
2697 OS_EXTRA_SRC=winclip.c; OS_EXTRA_OBJ=objects/winclip.o
2698 AC_MSG_RESULT(yes)
2699 AC_DEFINE(FEAT_CYGWIN_WIN32_CLIPBOARD)
2700 else
2701 AC_MSG_RESULT(no - using X11)
2702 fi ;;
2703
2704 *) CYGWIN=no; AC_MSG_RESULT(no);;
2705esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00002706
2707dnl Only really enable hangul input when GUI and XFONTSET are available
2708if test "$enable_hangulinput" = "yes"; then
2709 if test "x$GUITYPE" = "xNONE"; then
2710 AC_MSG_RESULT(no GUI selected; hangul input has been disabled)
2711 enable_hangulinput=no
2712 else
2713 AC_DEFINE(FEAT_HANGULIN)
2714 HANGULIN_SRC=hangulin.c
2715 AC_SUBST(HANGULIN_SRC)
2716 HANGULIN_OBJ=objects/hangulin.o
2717 AC_SUBST(HANGULIN_OBJ)
2718 fi
2719fi
2720
2721dnl Checks for libraries and include files.
2722
Bram Moolenaar446cb832008-06-24 21:56:24 +00002723AC_CACHE_CHECK([whether toupper is broken], [vim_cv_toupper_broken],
2724 [
2725 AC_RUN_IFELSE([[
2726#include "confdefs.h"
2727#include <ctype.h>
2728#if STDC_HEADERS
2729# include <stdlib.h>
2730# include <stddef.h>
2731#endif
2732main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); }
2733 ]],[
2734 vim_cv_toupper_broken=yes
2735 ],[
2736 vim_cv_toupper_broken=no
2737 ],[
2738 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_toupper_broken')
2739 ])])
2740
2741if test "x$vim_cv_toupper_broken" = "xyes" ; then
2742 AC_DEFINE(BROKEN_TOUPPER)
2743fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002744
2745AC_MSG_CHECKING(whether __DATE__ and __TIME__ work)
Bram Moolenaar446cb832008-06-24 21:56:24 +00002746AC_TRY_COMPILE([#include <stdio.h>], [printf("(" __DATE__ " " __TIME__ ")");],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002747 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DATE_TIME),
2748 AC_MSG_RESULT(no))
2749
Bram Moolenaar0c094b92009-05-14 20:20:33 +00002750AC_MSG_CHECKING(whether __attribute__((unused)) is allowed)
2751AC_TRY_COMPILE([#include <stdio.h>], [int x __attribute__((unused));],
2752 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ATTRIBUTE_UNUSED),
2753 AC_MSG_RESULT(no))
2754
Bram Moolenaar071d4272004-06-13 20:20:40 +00002755dnl Checks for header files.
2756AC_CHECK_HEADER(elf.h, HAS_ELF=1)
2757dnl AC_CHECK_HEADER(dwarf.h, SVR4=1)
2758if test "$HAS_ELF" = 1; then
2759 AC_CHECK_LIB(elf, main)
2760fi
2761
2762AC_HEADER_DIRENT
2763
Bram Moolenaar071d4272004-06-13 20:20:40 +00002764dnl If sys/wait.h is not found it might still exist but not be POSIX
2765dnl compliant. In that case we define HAVE_UNION_WAIT (for NeXT)
2766if test $ac_cv_header_sys_wait_h = no; then
2767 AC_MSG_CHECKING([for sys/wait.h that defines union wait])
2768 AC_TRY_COMPILE([#include <sys/wait.h>],
2769 [union wait xx, yy; xx = yy],
2770 AC_MSG_RESULT(yes)
2771 AC_DEFINE(HAVE_SYS_WAIT_H)
2772 AC_DEFINE(HAVE_UNION_WAIT),
2773 AC_MSG_RESULT(no))
2774fi
2775
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02002776AC_CHECK_HEADERS(stdarg.h stdint.h stdlib.h string.h \
2777 sys/select.h sys/utsname.h termcap.h fcntl.h \
2778 sgtty.h sys/ioctl.h sys/time.h sys/types.h \
2779 termio.h iconv.h inttypes.h langinfo.h math.h \
2780 unistd.h stropts.h errno.h sys/resource.h \
2781 sys/systeminfo.h locale.h sys/stream.h termios.h \
2782 libc.h sys/statfs.h poll.h sys/poll.h pwd.h \
2783 utime.h sys/param.h libintl.h libgen.h \
2784 util/debug.h util/msg18n.h frame.h sys/acl.h \
2785 sys/access.h sys/sysinfo.h wchar.h wctype.h)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002786
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002787dnl sys/ptem.h depends on sys/stream.h on Solaris
2788AC_CHECK_HEADERS(sys/ptem.h, [], [],
2789[#if defined HAVE_SYS_STREAM_H
2790# include <sys/stream.h>
2791#endif])
2792
Bram Moolenaar32f31b12009-05-21 13:20:59 +00002793dnl sys/sysctl.h depends on sys/param.h on OpenBSD
2794AC_CHECK_HEADERS(sys/sysctl.h, [], [],
2795[#if defined HAVE_SYS_PARAM_H
2796# include <sys/param.h>
2797#endif])
2798
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002799
Bram Moolenaardf3267e2005-01-25 22:07:05 +00002800dnl pthread_np.h may exist but can only be used after including pthread.h
2801AC_MSG_CHECKING([for pthread_np.h])
2802AC_TRY_COMPILE([
2803#include <pthread.h>
2804#include <pthread_np.h>],
2805 [int i; i = 0;],
2806 AC_MSG_RESULT(yes)
2807 AC_DEFINE(HAVE_PTHREAD_NP_H),
2808 AC_MSG_RESULT(no))
2809
Bram Moolenaare344bea2005-09-01 20:46:49 +00002810AC_CHECK_HEADERS(strings.h)
Bram Moolenaar9372a112005-12-06 19:59:18 +00002811if test "x$MACOSX" = "xyes"; then
2812 dnl The strings.h file on OS/X contains a warning and nothing useful.
2813 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
2814else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002815
2816dnl Check if strings.h and string.h can both be included when defined.
2817AC_MSG_CHECKING([if strings.h can be included after string.h])
2818cppflags_save=$CPPFLAGS
2819CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2820AC_TRY_COMPILE([
2821#if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO)
2822# define _NO_PROTO /* like in os_unix.h, causes conflict for AIX (Winn) */
2823 /* but don't do it on AIX 5.1 (Uribarri) */
2824#endif
2825#ifdef HAVE_XM_XM_H
2826# include <Xm/Xm.h> /* This breaks it for HP-UX 11 (Squassabia) */
2827#endif
2828#ifdef HAVE_STRING_H
2829# include <string.h>
2830#endif
2831#if defined(HAVE_STRINGS_H)
2832# include <strings.h>
2833#endif
2834 ], [int i; i = 0;],
2835 AC_MSG_RESULT(yes),
2836 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
2837 AC_MSG_RESULT(no))
2838CPPFLAGS=$cppflags_save
Bram Moolenaar9372a112005-12-06 19:59:18 +00002839fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002840
2841dnl Checks for typedefs, structures, and compiler characteristics.
2842AC_PROG_GCC_TRADITIONAL
2843AC_C_CONST
Bram Moolenaar76243bd2009-03-02 01:47:02 +00002844AC_C_VOLATILE
Bram Moolenaar071d4272004-06-13 20:20:40 +00002845AC_TYPE_MODE_T
2846AC_TYPE_OFF_T
2847AC_TYPE_PID_T
2848AC_TYPE_SIZE_T
2849AC_TYPE_UID_T
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02002850AC_TYPE_UINT32_T
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02002851
Bram Moolenaar071d4272004-06-13 20:20:40 +00002852AC_HEADER_TIME
2853AC_CHECK_TYPE(ino_t, long)
2854AC_CHECK_TYPE(dev_t, unsigned)
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02002855AC_C_BIGENDIAN(,,,)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002856
2857AC_MSG_CHECKING(for rlim_t)
2858if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
2859 AC_MSG_RESULT([(cached) $ac_cv_type_rlim_t])
2860else
2861 AC_EGREP_CPP(dnl
2862changequote(<<,>>)dnl
2863<<(^|[^a-zA-Z_0-9])rlim_t[^a-zA-Z_0-9]>>dnl
2864changequote([,]),
2865 [
2866#include <sys/types.h>
2867#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00002868# include <stdlib.h>
2869# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00002870#endif
2871#ifdef HAVE_SYS_RESOURCE_H
Bram Moolenaar446cb832008-06-24 21:56:24 +00002872# include <sys/resource.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00002873#endif
2874 ], ac_cv_type_rlim_t=yes, ac_cv_type_rlim_t=no)
2875 AC_MSG_RESULT($ac_cv_type_rlim_t)
2876fi
2877if test $ac_cv_type_rlim_t = no; then
2878 cat >> confdefs.h <<\EOF
2879#define rlim_t unsigned long
2880EOF
2881fi
2882
2883AC_MSG_CHECKING(for stack_t)
2884if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then
2885 AC_MSG_RESULT([(cached) $ac_cv_type_stack_t])
2886else
2887 AC_EGREP_CPP(stack_t,
2888 [
2889#include <sys/types.h>
2890#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00002891# include <stdlib.h>
2892# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00002893#endif
2894#include <signal.h>
2895 ], ac_cv_type_stack_t=yes, ac_cv_type_stack_t=no)
2896 AC_MSG_RESULT($ac_cv_type_stack_t)
2897fi
2898if test $ac_cv_type_stack_t = no; then
2899 cat >> confdefs.h <<\EOF
2900#define stack_t struct sigaltstack
2901EOF
2902fi
2903
2904dnl BSDI uses ss_base while others use ss_sp for the stack pointer.
2905AC_MSG_CHECKING(whether stack_t has an ss_base field)
2906AC_TRY_COMPILE([
2907#include <sys/types.h>
2908#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00002909# include <stdlib.h>
2910# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00002911#endif
2912#include <signal.h>
2913#include "confdefs.h"
2914 ], [stack_t sigstk; sigstk.ss_base = 0; ],
2915 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SS_BASE),
2916 AC_MSG_RESULT(no))
2917
2918olibs="$LIBS"
2919AC_MSG_CHECKING(--with-tlib argument)
2920AC_ARG_WITH(tlib, [ --with-tlib=library terminal library to be used ],)
2921if test -n "$with_tlib"; then
2922 AC_MSG_RESULT($with_tlib)
2923 LIBS="$LIBS -l$with_tlib"
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00002924 AC_MSG_CHECKING(for linking with $with_tlib library)
2925 AC_TRY_LINK([], [], AC_MSG_RESULT(OK), AC_MSG_ERROR(FAILED))
2926 dnl Need to check for tgetent() below.
2927 olibs="$LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002928else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00002929 AC_MSG_RESULT([empty: automatic terminal library selection])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002930 dnl On HP-UX 10.10 termcap or termlib should be used instead of
2931 dnl curses, because curses is much slower.
Bram Moolenaar4e509b62011-02-09 17:42:57 +01002932 dnl Newer versions of ncurses are preferred over anything, except
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02002933 dnl when tinfo has been split off, it contains all we need.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002934 dnl Older versions of ncurses have bugs, get a new one!
2935 dnl Digital Unix (OSF1) should use curses (Ronald Schild).
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00002936 dnl On SCO Openserver should prefer termlib (Roger Cornelius).
Bram Moolenaar071d4272004-06-13 20:20:40 +00002937 case "`uname -s 2>/dev/null`" in
Bram Moolenaar4e509b62011-02-09 17:42:57 +01002938 OSF1|SCO_SV) tlibs="tinfo ncurses curses termlib termcap";;
2939 *) tlibs="tinfo ncurses termlib termcap curses";;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002940 esac
2941 for libname in $tlibs; do
2942 AC_CHECK_LIB(${libname}, tgetent,,)
2943 if test "x$olibs" != "x$LIBS"; then
2944 dnl It's possible that a library is found but it doesn't work
2945 dnl e.g., shared library that cannot be found
2946 dnl compile and run a test program to be sure
2947 AC_TRY_RUN([
2948#ifdef HAVE_TERMCAP_H
2949# include <termcap.h>
2950#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00002951#if STDC_HEADERS
2952# include <stdlib.h>
2953# include <stddef.h>
2954#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002955main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }],
2956 res="OK", res="FAIL", res="FAIL")
2957 if test "$res" = "OK"; then
2958 break
2959 fi
2960 AC_MSG_RESULT($libname library is not usable)
2961 LIBS="$olibs"
2962 fi
2963 done
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00002964 if test "x$olibs" = "x$LIBS"; then
2965 AC_MSG_RESULT(no terminal library found)
2966 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002967fi
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00002968
2969if test "x$olibs" = "x$LIBS"; then
2970 AC_MSG_CHECKING([for tgetent()])
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00002971 AC_TRY_LINK([],
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00002972 [char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");],
2973 AC_MSG_RESULT(yes),
2974 AC_MSG_ERROR([NOT FOUND!
2975 You need to install a terminal library; for example ncurses.
2976 Or specify the name of the library with --with-tlib.]))
2977fi
2978
Bram Moolenaar446cb832008-06-24 21:56:24 +00002979AC_CACHE_CHECK([whether we talk terminfo], [vim_cv_terminfo],
2980 [
2981 AC_RUN_IFELSE([[
2982#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002983#ifdef HAVE_TERMCAP_H
2984# include <termcap.h>
2985#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00002986#ifdef HAVE_STRING_H
2987# include <string.h>
2988#endif
2989#if STDC_HEADERS
2990# include <stdlib.h>
2991# include <stddef.h>
2992#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002993main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00002994{char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }
2995 ]],[
2996 vim_cv_terminfo=no
2997 ],[
2998 vim_cv_terminfo=yes
2999 ],[
3000 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_terminfo')
3001 ])
3002 ])
3003
3004if test "x$vim_cv_terminfo" = "xyes" ; then
3005 AC_DEFINE(TERMINFO)
3006fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003007
3008if test "x$olibs" != "x$LIBS"; then
Bram Moolenaar446cb832008-06-24 21:56:24 +00003009 AC_CACHE_CHECK([what tgetent() returns for an unknown terminal], [vim_cv_tgent],
3010 [
3011 AC_RUN_IFELSE([[
3012#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003013#ifdef HAVE_TERMCAP_H
3014# include <termcap.h>
3015#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003016#if STDC_HEADERS
3017# include <stdlib.h>
3018# include <stddef.h>
3019#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003020main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003021{char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
3022 ]],[
3023 vim_cv_tgent=zero
3024 ],[
3025 vim_cv_tgent=non-zero
3026 ],[
3027 AC_MSG_ERROR(failed to compile test program.)
3028 ])
3029 ])
3030
3031 if test "x$vim_cv_tgent" = "xzero" ; then
3032 AC_DEFINE(TGETENT_ZERO_ERR, 0)
3033 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003034fi
3035
3036AC_MSG_CHECKING(whether termcap.h contains ospeed)
3037AC_TRY_LINK([
3038#ifdef HAVE_TERMCAP_H
3039# include <termcap.h>
3040#endif
3041 ], [ospeed = 20000],
3042 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED),
3043 [AC_MSG_RESULT(no)
3044 AC_MSG_CHECKING(whether ospeed can be extern)
3045 AC_TRY_LINK([
3046#ifdef HAVE_TERMCAP_H
3047# include <termcap.h>
3048#endif
3049extern short ospeed;
3050 ], [ospeed = 20000],
3051 AC_MSG_RESULT(yes); AC_DEFINE(OSPEED_EXTERN),
3052 AC_MSG_RESULT(no))]
3053 )
3054
3055AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC])
3056AC_TRY_LINK([
3057#ifdef HAVE_TERMCAP_H
3058# include <termcap.h>
3059#endif
3060 ], [if (UP == 0 && BC == 0) PC = 1],
3061 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UP_BC_PC),
3062 [AC_MSG_RESULT(no)
3063 AC_MSG_CHECKING([whether UP, BC and PC can be extern])
3064 AC_TRY_LINK([
3065#ifdef HAVE_TERMCAP_H
3066# include <termcap.h>
3067#endif
3068extern char *UP, *BC, PC;
3069 ], [if (UP == 0 && BC == 0) PC = 1],
3070 AC_MSG_RESULT(yes); AC_DEFINE(UP_BC_PC_EXTERN),
3071 AC_MSG_RESULT(no))]
3072 )
3073
3074AC_MSG_CHECKING(whether tputs() uses outfuntype)
3075AC_TRY_COMPILE([
3076#ifdef HAVE_TERMCAP_H
3077# include <termcap.h>
3078#endif
3079 ], [extern int xx(); tputs("test", 1, (outfuntype)xx)],
3080 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OUTFUNTYPE),
3081 AC_MSG_RESULT(no))
3082
3083dnl On some SCO machines sys/select redefines struct timeval
3084AC_MSG_CHECKING([whether sys/select.h and sys/time.h may both be included])
3085AC_TRY_COMPILE([
3086#include <sys/types.h>
3087#include <sys/time.h>
3088#include <sys/select.h>], ,
3089 AC_MSG_RESULT(yes)
3090 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME),
3091 AC_MSG_RESULT(no))
3092
3093dnl AC_DECL_SYS_SIGLIST
3094
3095dnl Checks for pty.c (copied from screen) ==========================
3096AC_MSG_CHECKING(for /dev/ptc)
3097if test -r /dev/ptc; then
3098 AC_DEFINE(HAVE_DEV_PTC)
3099 AC_MSG_RESULT(yes)
3100else
3101 AC_MSG_RESULT(no)
3102fi
3103
3104AC_MSG_CHECKING(for SVR4 ptys)
3105if test -c /dev/ptmx ; then
3106 AC_TRY_LINK([], [ptsname(0);grantpt(0);unlockpt(0);],
3107 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SVR4_PTYS),
3108 AC_MSG_RESULT(no))
3109else
3110 AC_MSG_RESULT(no)
3111fi
3112
3113AC_MSG_CHECKING(for ptyranges)
3114if test -d /dev/ptym ; then
3115 pdir='/dev/ptym'
3116else
3117 pdir='/dev'
3118fi
3119dnl SCO uses ptyp%d
3120AC_EGREP_CPP(yes,
3121[#ifdef M_UNIX
3122 yes;
3123#endif
3124 ], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
3125dnl if test -c /dev/ptyp19; then
3126dnl ptys=`echo /dev/ptyp??`
3127dnl else
3128dnl ptys=`echo $pdir/pty??`
3129dnl fi
3130if test "$ptys" != "$pdir/pty??" ; then
3131 p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
3132 p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'`
3133 AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
3134 AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
3135 AC_MSG_RESULT([$p0 / $p1])
3136else
3137 AC_MSG_RESULT([don't know])
3138fi
3139
3140dnl **** pty mode/group handling ****
3141dnl
3142dnl support provided by Luke Mewburn <lm@rmit.edu.au>, 931222
Bram Moolenaar071d4272004-06-13 20:20:40 +00003143rm -f conftest_grp
Bram Moolenaar446cb832008-06-24 21:56:24 +00003144AC_CACHE_CHECK([default tty permissions/group], [vim_cv_tty_group],
3145 [
3146 AC_RUN_IFELSE([[
3147#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003148#include <sys/types.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003149#if STDC_HEADERS
3150# include <stdlib.h>
3151# include <stddef.h>
3152#endif
3153#ifdef HAVE_UNISTD_H
3154#include <unistd.h>
3155#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003156#include <sys/stat.h>
3157#include <stdio.h>
3158main()
3159{
3160 struct stat sb;
3161 char *x,*ttyname();
3162 int om, m;
3163 FILE *fp;
3164
3165 if (!(x = ttyname(0))) exit(1);
3166 if (stat(x, &sb)) exit(1);
3167 om = sb.st_mode;
3168 if (om & 002) exit(0);
3169 m = system("mesg y");
3170 if (m == -1 || m == 127) exit(1);
3171 if (stat(x, &sb)) exit(1);
3172 m = sb.st_mode;
3173 if (chmod(x, om)) exit(1);
3174 if (m & 002) exit(0);
3175 if (sb.st_gid == getgid()) exit(1);
3176 if (!(fp=fopen("conftest_grp", "w")))
3177 exit(1);
3178 fprintf(fp, "%d\n", sb.st_gid);
3179 fclose(fp);
3180 exit(0);
3181}
Bram Moolenaar446cb832008-06-24 21:56:24 +00003182 ]],[
3183 if test -f conftest_grp; then
3184 vim_cv_tty_group=`cat conftest_grp`
3185 if test "x$vim_cv_tty_mode" = "x" ; then
3186 vim_cv_tty_mode=0620
3187 fi
3188 AC_MSG_RESULT([pty mode: $vim_cv_tty_mode, group: $vim_cv_tty_group])
3189 else
3190 vim_cv_tty_group=world
Bram Moolenaar72951072009-12-02 16:58:33 +00003191 AC_MSG_RESULT([ptys are world accessible])
Bram Moolenaar446cb832008-06-24 21:56:24 +00003192 fi
3193 ],[
3194 vim_cv_tty_group=world
Bram Moolenaar72951072009-12-02 16:58:33 +00003195 AC_MSG_RESULT([can't determine - assume ptys are world accessible])
Bram Moolenaar446cb832008-06-24 21:56:24 +00003196 ],[
3197 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_tty_group' and 'vim_cv_tty_mode')
3198 ])
3199 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003200rm -f conftest_grp
3201
Bram Moolenaar446cb832008-06-24 21:56:24 +00003202if test "x$vim_cv_tty_group" != "xworld" ; then
3203 AC_DEFINE_UNQUOTED(PTYGROUP,$vim_cv_tty_group)
3204 if test "x$vim_cv_tty_mode" = "x" ; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02003205 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 +00003206 else
3207 AC_DEFINE(PTYMODE, 0620)
3208 fi
3209fi
3210
Bram Moolenaar071d4272004-06-13 20:20:40 +00003211dnl Checks for library functions. ===================================
3212
3213AC_TYPE_SIGNAL
3214
3215dnl find out what to use at the end of a signal function
3216if test $ac_cv_type_signal = void; then
3217 AC_DEFINE(SIGRETURN, [return])
3218else
3219 AC_DEFINE(SIGRETURN, [return 0])
3220fi
3221
3222dnl check if struct sigcontext is defined (used for SGI only)
3223AC_MSG_CHECKING(for struct sigcontext)
3224AC_TRY_COMPILE([
3225#include <signal.h>
3226test_sig()
3227{
3228 struct sigcontext *scont;
3229 scont = (struct sigcontext *)0;
3230 return 1;
3231} ], ,
3232 AC_MSG_RESULT(yes)
3233 AC_DEFINE(HAVE_SIGCONTEXT),
3234 AC_MSG_RESULT(no))
3235
3236dnl tricky stuff: try to find out if getcwd() is implemented with
3237dnl system("sh -c pwd")
Bram Moolenaar446cb832008-06-24 21:56:24 +00003238AC_CACHE_CHECK([getcwd implementation is broken], [vim_cv_getcwd_broken],
3239 [
3240 AC_RUN_IFELSE([[
3241#include "confdefs.h"
3242#ifdef HAVE_UNISTD_H
3243#include <unistd.h>
3244#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003245char *dagger[] = { "IFS=pwd", 0 };
3246main()
3247{
3248 char buffer[500];
3249 extern char **environ;
3250 environ = dagger;
3251 return getcwd(buffer, 500) ? 0 : 1;
Bram Moolenaar446cb832008-06-24 21:56:24 +00003252}
3253 ]],[
3254 vim_cv_getcwd_broken=no
3255 ],[
3256 vim_cv_getcwd_broken=yes
3257 ],[
3258 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_getcwd_broken')
3259 ])
3260 ])
3261
3262if test "x$vim_cv_getcwd_broken" = "xyes" ; then
3263 AC_DEFINE(BAD_GETCWD)
3264fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003265
Bram Moolenaar25153e12010-02-24 14:47:08 +01003266dnl Check for functions in one big call, to reduce the size of configure.
3267dnl Can only be used for functions that do not require any include.
3268AC_CHECK_FUNCS(bcmp fchdir fchown fsync getcwd getpseudotty \
Bram Moolenaar24305862012-08-15 14:05:05 +02003269 getpwent getpwnam getpwuid getrlimit gettimeofday getwd lstat memcmp \
Bram Moolenaareaf03392009-11-17 11:08:52 +00003270 memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
Bram Moolenaar071d4272004-06-13 20:20:40 +00003271 setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
Bram Moolenaar051b7822005-05-19 21:00:46 +00003272 sigvec strcasecmp strerror strftime stricmp strncasecmp \
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00003273 strnicmp strpbrk strtol tgetent towlower towupper iswupper \
3274 usleep utime utimes)
Bram Moolenaar25153e12010-02-24 14:47:08 +01003275AC_FUNC_FSEEKO
Bram Moolenaar071d4272004-06-13 20:20:40 +00003276
Bram Moolenaar317fd3a2010-05-07 16:05:55 +02003277dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when
3278dnl appropriate, so that off_t is 64 bits when needed.
3279AC_SYS_LARGEFILE
3280
Bram Moolenaar071d4272004-06-13 20:20:40 +00003281dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible
3282AC_MSG_CHECKING(for st_blksize)
3283AC_TRY_COMPILE(
3284[#include <sys/types.h>
3285#include <sys/stat.h>],
3286[ struct stat st;
3287 int n;
3288
3289 stat("/", &st);
3290 n = (int)st.st_blksize;],
3291 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ST_BLKSIZE),
3292 AC_MSG_RESULT(no))
3293
Bram Moolenaar446cb832008-06-24 21:56:24 +00003294AC_CACHE_CHECK([whether stat() ignores a trailing slash], [vim_cv_stat_ignores_slash],
3295 [
3296 AC_RUN_IFELSE([[
3297#include "confdefs.h"
3298#if STDC_HEADERS
3299# include <stdlib.h>
3300# include <stddef.h>
3301#endif
3302#include <sys/types.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003303#include <sys/stat.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003304main() {struct stat st; exit(stat("configure/", &st) != 0); }
3305 ]],[
3306 vim_cv_stat_ignores_slash=yes
3307 ],[
3308 vim_cv_stat_ignores_slash=no
3309 ],[
3310 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_stat_ignores_slash')
3311 ])
3312 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003313
Bram Moolenaar446cb832008-06-24 21:56:24 +00003314if test "x$vim_cv_stat_ignores_slash" = "xyes" ; then
3315 AC_DEFINE(STAT_IGNORES_SLASH)
3316fi
3317
Bram Moolenaar071d4272004-06-13 20:20:40 +00003318dnl Link with iconv for charset translation, if not found without library.
3319dnl check for iconv() requires including iconv.h
3320dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
3321dnl has been installed.
3322AC_MSG_CHECKING(for iconv_open())
3323save_LIBS="$LIBS"
3324LIBS="$LIBS -liconv"
3325AC_TRY_LINK([
3326#ifdef HAVE_ICONV_H
3327# include <iconv.h>
3328#endif
3329 ], [iconv_open("fr", "to");],
3330 AC_MSG_RESULT(yes; with -liconv); AC_DEFINE(HAVE_ICONV),
3331 LIBS="$save_LIBS"
3332 AC_TRY_LINK([
3333#ifdef HAVE_ICONV_H
3334# include <iconv.h>
3335#endif
3336 ], [iconv_open("fr", "to");],
3337 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ICONV),
3338 AC_MSG_RESULT(no)))
3339
3340
3341AC_MSG_CHECKING(for nl_langinfo(CODESET))
3342AC_TRY_LINK([
3343#ifdef HAVE_LANGINFO_H
3344# include <langinfo.h>
3345#endif
3346], [char *cs = nl_langinfo(CODESET);],
3347 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET),
3348 AC_MSG_RESULT(no))
3349
Bram Moolenaar446cb832008-06-24 21:56:24 +00003350dnl Need various functions for floating point support. Only enable
3351dnl floating point when they are all present.
3352AC_CHECK_LIB(m, strtod)
3353AC_MSG_CHECKING([for strtod() and other floating point functions])
3354AC_TRY_LINK([
3355#ifdef HAVE_MATH_H
3356# include <math.h>
3357#endif
3358#if STDC_HEADERS
3359# include <stdlib.h>
3360# include <stddef.h>
3361#endif
3362], [char *s; double d;
3363 d = strtod("1.1", &s);
3364 d = fabs(1.11);
3365 d = ceil(1.11);
3366 d = floor(1.11);
3367 d = log10(1.11);
3368 d = pow(1.11, 2.22);
3369 d = sqrt(1.11);
3370 d = sin(1.11);
3371 d = cos(1.11);
3372 d = atan(1.11);
3373 ],
3374 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT_FUNCS),
3375 AC_MSG_RESULT(no))
3376
Bram Moolenaar071d4272004-06-13 20:20:40 +00003377dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI
3378dnl when -lacl works, also try to use -lattr (required for Debian).
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003379dnl On Solaris, use the acl_get/set functions in libsec, if present.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003380AC_MSG_CHECKING(--disable-acl argument)
3381AC_ARG_ENABLE(acl,
3382 [ --disable-acl Don't check for ACL support.],
3383 , [enable_acl="yes"])
3384if test "$enable_acl" = "yes"; then
3385AC_MSG_RESULT(no)
3386AC_CHECK_LIB(posix1e, acl_get_file, [LIBS="$LIBS -lposix1e"],
3387 AC_CHECK_LIB(acl, acl_get_file, [LIBS="$LIBS -lacl"
3388 AC_CHECK_LIB(attr, fgetxattr, LIBS="$LIBS -lattr",,)],,),)
3389
3390AC_MSG_CHECKING(for POSIX ACL support)
3391AC_TRY_LINK([
3392#include <sys/types.h>
3393#ifdef HAVE_SYS_ACL_H
3394# include <sys/acl.h>
3395#endif
3396acl_t acl;], [acl = acl_get_file("foo", ACL_TYPE_ACCESS);
3397 acl_set_file("foo", ACL_TYPE_ACCESS, acl);
3398 acl_free(acl);],
3399 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_ACL),
3400 AC_MSG_RESULT(no))
3401
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003402AC_CHECK_LIB(sec, acl_get, [LIBS="$LIBS -lsec"; AC_DEFINE(HAVE_SOLARIS_ZFS_ACL)],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003403AC_MSG_CHECKING(for Solaris ACL support)
3404AC_TRY_LINK([
3405#ifdef HAVE_SYS_ACL_H
3406# include <sys/acl.h>
3407#endif], [acl("foo", GETACLCNT, 0, NULL);
3408 ],
3409 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOLARIS_ACL),
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003410 AC_MSG_RESULT(no)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003411
3412AC_MSG_CHECKING(for AIX ACL support)
3413AC_TRY_LINK([
Bram Moolenaar446cb832008-06-24 21:56:24 +00003414#if STDC_HEADERS
3415# include <stdlib.h>
3416# include <stddef.h>
3417#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003418#ifdef HAVE_SYS_ACL_H
3419# include <sys/acl.h>
3420#endif
3421#ifdef HAVE_SYS_ACCESS_H
3422# include <sys/access.h>
3423#endif
3424#define _ALL_SOURCE
3425
3426#include <sys/stat.h>
3427
3428int aclsize;
3429struct acl *aclent;], [aclsize = sizeof(struct acl);
3430 aclent = (void *)malloc(aclsize);
3431 statacl("foo", STX_NORMAL, aclent, aclsize);
3432 ],
3433 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_AIX_ACL),
3434 AC_MSG_RESULT(no))
3435else
3436 AC_MSG_RESULT(yes)
3437fi
3438
3439AC_MSG_CHECKING(--disable-gpm argument)
3440AC_ARG_ENABLE(gpm,
3441 [ --disable-gpm Don't use gpm (Linux mouse daemon).], ,
3442 [enable_gpm="yes"])
3443
3444if test "$enable_gpm" = "yes"; then
3445 AC_MSG_RESULT(no)
3446 dnl Checking if gpm support can be compiled
3447 AC_CACHE_CHECK([for gpm], vi_cv_have_gpm,
3448 [olibs="$LIBS" ; LIBS="-lgpm"]
3449 AC_TRY_LINK(
3450 [#include <gpm.h>
3451 #include <linux/keyboard.h>],
3452 [Gpm_GetLibVersion(NULL);],
3453 dnl Configure defines HAVE_GPM, if it is defined feature.h defines
3454 dnl FEAT_MOUSE_GPM if mouse support is included
3455 [vi_cv_have_gpm=yes],
3456 [vi_cv_have_gpm=no])
3457 [LIBS="$olibs"]
3458 )
3459 if test $vi_cv_have_gpm = yes; then
3460 LIBS="$LIBS -lgpm"
3461 AC_DEFINE(HAVE_GPM)
3462 fi
3463else
3464 AC_MSG_RESULT(yes)
3465fi
3466
Bram Moolenaar446cb832008-06-24 21:56:24 +00003467AC_MSG_CHECKING(--disable-sysmouse argument)
3468AC_ARG_ENABLE(sysmouse,
3469 [ --disable-sysmouse Don't use sysmouse (mouse in *BSD console).], ,
3470 [enable_sysmouse="yes"])
3471
3472if test "$enable_sysmouse" = "yes"; then
3473 AC_MSG_RESULT(no)
3474 dnl Checking if sysmouse support can be compiled
3475 dnl Configure defines HAVE_SYSMOUSE, if it is defined feature.h
3476 dnl defines FEAT_SYSMOUSE if mouse support is included
3477 AC_CACHE_CHECK([for sysmouse], vi_cv_have_sysmouse,
3478 AC_TRY_LINK(
3479 [#include <sys/consio.h>
3480 #include <signal.h>
3481 #include <sys/fbio.h>],
3482 [struct mouse_info mouse;
3483 mouse.operation = MOUSE_MODE;
3484 mouse.operation = MOUSE_SHOW;
3485 mouse.u.mode.mode = 0;
3486 mouse.u.mode.signal = SIGUSR2;],
3487 [vi_cv_have_sysmouse=yes],
3488 [vi_cv_have_sysmouse=no])
3489 )
3490 if test $vi_cv_have_sysmouse = yes; then
3491 AC_DEFINE(HAVE_SYSMOUSE)
3492 fi
3493else
3494 AC_MSG_RESULT(yes)
3495fi
3496
Bram Moolenaarf05da212009-11-17 16:13:15 +00003497dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
3498AC_MSG_CHECKING(for FD_CLOEXEC)
3499AC_TRY_COMPILE(
3500[#if HAVE_FCNTL_H
3501# include <fcntl.h>
3502#endif],
3503[ int flag = FD_CLOEXEC;],
3504 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
3505 AC_MSG_RESULT(not usable))
3506
Bram Moolenaar071d4272004-06-13 20:20:40 +00003507dnl rename needs to be checked separately to work on Nextstep with cc
3508AC_MSG_CHECKING(for rename)
3509AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
3510 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
3511 AC_MSG_RESULT(no))
3512
3513dnl sysctl() may exist but not the arguments we use
3514AC_MSG_CHECKING(for sysctl)
3515AC_TRY_COMPILE(
3516[#include <sys/types.h>
3517#include <sys/sysctl.h>],
3518[ int mib[2], r;
3519 size_t len;
3520
3521 mib[0] = CTL_HW;
3522 mib[1] = HW_USERMEM;
3523 len = sizeof(r);
3524 (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
3525 ],
3526 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL),
3527 AC_MSG_RESULT(not usable))
3528
3529dnl sysinfo() may exist but not be Linux compatible
3530AC_MSG_CHECKING(for sysinfo)
3531AC_TRY_COMPILE(
3532[#include <sys/types.h>
3533#include <sys/sysinfo.h>],
3534[ struct sysinfo sinfo;
3535 int t;
3536
3537 (void)sysinfo(&sinfo);
3538 t = sinfo.totalram;
3539 ],
3540 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
3541 AC_MSG_RESULT(not usable))
3542
Bram Moolenaar914572a2007-05-01 11:37:47 +00003543dnl struct sysinfo may have the mem_unit field or not
3544AC_MSG_CHECKING(for sysinfo.mem_unit)
3545AC_TRY_COMPILE(
3546[#include <sys/types.h>
3547#include <sys/sysinfo.h>],
3548[ struct sysinfo sinfo;
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02003549 sinfo.mem_unit = 1;
Bram Moolenaar914572a2007-05-01 11:37:47 +00003550 ],
3551 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_MEM_UNIT),
3552 AC_MSG_RESULT(no))
3553
Bram Moolenaar071d4272004-06-13 20:20:40 +00003554dnl sysconf() may exist but not support what we want to use
3555AC_MSG_CHECKING(for sysconf)
3556AC_TRY_COMPILE(
3557[#include <unistd.h>],
3558[ (void)sysconf(_SC_PAGESIZE);
3559 (void)sysconf(_SC_PHYS_PAGES);
3560 ],
3561 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
3562 AC_MSG_RESULT(not usable))
3563
Bram Moolenaar914703b2010-05-31 21:59:46 +02003564AC_CHECK_SIZEOF([int])
3565AC_CHECK_SIZEOF([long])
3566AC_CHECK_SIZEOF([time_t])
3567AC_CHECK_SIZEOF([off_t])
Bram Moolenaar644fdff2010-05-30 13:26:21 +02003568
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003569dnl Make sure that uint32_t is really 32 bits unsigned.
3570AC_MSG_CHECKING([uint32_t is 32 bits])
3571AC_TRY_RUN([
3572#ifdef HAVE_STDINT_H
3573# include <stdint.h>
3574#endif
3575#ifdef HAVE_INTTYPES_H
3576# include <inttypes.h>
3577#endif
3578main() {
3579 uint32_t nr1 = (uint32_t)-1;
3580 uint32_t nr2 = (uint32_t)0xffffffffUL;
3581 if (sizeof(uint32_t) != 4 || nr1 != 0xffffffffUL || nr2 + 1 != 0) exit(1);
3582 exit(0);
3583}],
3584AC_MSG_RESULT(ok),
3585AC_MSG_ERROR([WRONG! uint32_t not defined correctly.]),
Bram Moolenaar323cb952011-12-14 19:22:34 +01003586AC_MSG_WARN([cannot check uint32_t when cross-compiling.]))
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003587
Bram Moolenaar446cb832008-06-24 21:56:24 +00003588dnl Check for memmove() before bcopy(), makes memmove() be used when both are
3589dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
3590
Bram Moolenaar071d4272004-06-13 20:20:40 +00003591[bcopy_test_prog='
Bram Moolenaar446cb832008-06-24 21:56:24 +00003592#include "confdefs.h"
3593#ifdef HAVE_STRING_H
3594# include <string.h>
3595#endif
3596#if STDC_HEADERS
3597# include <stdlib.h>
3598# include <stddef.h>
3599#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003600main() {
3601 char buf[10];
3602 strcpy(buf, "abcdefghi");
3603 mch_memmove(buf, buf + 2, 3);
3604 if (strncmp(buf, "ababcf", 6))
3605 exit(1);
3606 strcpy(buf, "abcdefghi");
3607 mch_memmove(buf + 2, buf, 3);
3608 if (strncmp(buf, "cdedef", 6))
3609 exit(1);
3610 exit(0); /* libc version works properly. */
3611}']
3612
Bram Moolenaar446cb832008-06-24 21:56:24 +00003613AC_CACHE_CHECK([whether memmove handles overlaps],[vim_cv_memmove_handles_overlap],
3614 [
3615 AC_RUN_IFELSE([[#define mch_memmove(s,d,l) memmove(d,s,l) $bcopy_test_prog]],
3616 [
3617 vim_cv_memmove_handles_overlap=yes
3618 ],[
3619 vim_cv_memmove_handles_overlap=no
3620 ],[
3621 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memmove_handles_overlap')
3622 ])
3623 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003624
Bram Moolenaar446cb832008-06-24 21:56:24 +00003625if test "x$vim_cv_memmove_handles_overlap" = "xyes" ; then
3626 AC_DEFINE(USEMEMMOVE)
3627else
3628 AC_CACHE_CHECK([whether bcopy handles overlaps],[vim_cv_bcopy_handles_overlap],
3629 [
3630 AC_RUN_IFELSE([[#define mch_bcopy(s,d,l) bcopy(d,s,l) $bcopy_test_prog]],
3631 [
3632 vim_cv_bcopy_handles_overlap=yes
3633 ],[
3634 vim_cv_bcopy_handles_overlap=no
3635 ],[
3636 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_bcopy_handles_overlap')
3637 ])
3638 ])
3639
3640 if test "x$vim_cv_bcopy_handles_overlap" = "xyes" ; then
3641 AC_DEFINE(USEBCOPY)
3642 else
3643 AC_CACHE_CHECK([whether memcpy handles overlaps],[vim_cv_memcpy_handles_overlap],
3644 [
3645 AC_RUN_IFELSE([[#define mch_memcpy(s,d,l) memcpy(d,s,l) $bcopy_test_prog]],
3646 [
3647 vim_cv_memcpy_handles_overlap=yes
3648 ],[
3649 vim_cv_memcpy_handles_overlap=no
3650 ],[
3651 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memcpy_handles_overlap')
3652 ])
3653 ])
3654
3655 if test "x$vim_cv_memcpy_handles_overlap" = "xyes" ; then
3656 AC_DEFINE(USEMEMCPY)
3657 fi
3658 fi
3659fi
3660
Bram Moolenaar071d4272004-06-13 20:20:40 +00003661
3662dnl Check for multibyte locale functions
3663dnl Find out if _Xsetlocale() is supported by libX11.
3664dnl Check if X_LOCALE should be defined.
3665
3666if test "$enable_multibyte" = "yes"; then
3667 cflags_save=$CFLAGS
3668 ldflags_save=$LDFLAGS
Bram Moolenaar94ba1ce2009-04-22 15:53:09 +00003669 if test "x$x_includes" != "xNONE" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003670 CFLAGS="$CFLAGS -I$x_includes"
3671 LDFLAGS="$X_LIBS $LDFLAGS -lX11"
3672 AC_MSG_CHECKING(whether X_LOCALE needed)
3673 AC_TRY_COMPILE([#include <X11/Xlocale.h>],,
3674 AC_TRY_LINK_FUNC([_Xsetlocale], [AC_MSG_RESULT(yes)
3675 AC_DEFINE(X_LOCALE)], AC_MSG_RESULT(no)),
3676 AC_MSG_RESULT(no))
3677 fi
3678 CFLAGS=$cflags_save
3679 LDFLAGS=$ldflags_save
3680fi
3681
3682dnl Link with xpg4, it is said to make Korean locale working
3683AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,)
3684
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00003685dnl Check how we can run ctags. Default to "ctags" when nothing works.
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02003686dnl Use --version to detect Exuberant ctags (preferred)
Bram Moolenaarb21e5842006-04-16 18:30:08 +00003687dnl Add --fields=+S to get function signatures for omni completion.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003688dnl -t for typedefs (many ctags have this)
3689dnl -s for static functions (Elvis ctags only?)
3690dnl -v for variables. Dangerous, most ctags take this for 'vgrind style'.
3691dnl -i+m to test for older Exuberant ctags
3692AC_MSG_CHECKING(how to create tags)
3693test -f tags && mv tags tags.save
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02003694if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaarb21e5842006-04-16 18:30:08 +00003695 TAGPRG="ctags -I INIT+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02003696elif (eval exctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
3697 TAGPRG="exctags -I INIT+ --fields=+S"
3698elif (eval exuberant-ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
3699 TAGPRG="exuberant-ctags -I INIT+ --fields=+S"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003700else
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00003701 TAGPRG="ctags"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003702 (eval etags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags"
3703 (eval etags -c /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags -c"
3704 (eval ctags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags"
3705 (eval ctags -t /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -t"
3706 (eval ctags -ts /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -ts"
3707 (eval ctags -tvs /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -tvs"
3708 (eval ctags -i+m /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -i+m"
3709fi
3710test -f tags.save && mv tags.save tags
3711AC_MSG_RESULT($TAGPRG) AC_SUBST(TAGPRG)
3712
3713dnl Check how we can run man with a section number
3714AC_MSG_CHECKING(how to run man with a section nr)
3715MANDEF="man"
Bram Moolenaar8b131502008-02-13 09:28:19 +00003716(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 +00003717AC_MSG_RESULT($MANDEF)
3718if test "$MANDEF" = "man -s"; then
3719 AC_DEFINE(USEMAN_S)
3720fi
3721
3722dnl Check if gettext() is working and if it needs -lintl
3723AC_MSG_CHECKING(--disable-nls argument)
3724AC_ARG_ENABLE(nls,
3725 [ --disable-nls Don't support NLS (gettext()).], ,
3726 [enable_nls="yes"])
3727
3728if test "$enable_nls" = "yes"; then
3729 AC_MSG_RESULT(no)
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00003730
3731 INSTALL_LANGS=install-languages
3732 AC_SUBST(INSTALL_LANGS)
3733 INSTALL_TOOL_LANGS=install-tool-languages
3734 AC_SUBST(INSTALL_TOOL_LANGS)
3735
Bram Moolenaar071d4272004-06-13 20:20:40 +00003736 AC_CHECK_PROG(MSGFMT, msgfmt, msgfmt, )
3737 AC_MSG_CHECKING([for NLS])
3738 if test -f po/Makefile; then
3739 have_gettext="no"
3740 if test -n "$MSGFMT"; then
3741 AC_TRY_LINK(
3742 [#include <libintl.h>],
3743 [gettext("Test");],
3744 AC_MSG_RESULT([gettext() works]); have_gettext="yes",
3745 olibs=$LIBS
3746 LIBS="$LIBS -lintl"
3747 AC_TRY_LINK(
3748 [#include <libintl.h>],
3749 [gettext("Test");],
3750 AC_MSG_RESULT([gettext() works with -lintl]); have_gettext="yes",
3751 AC_MSG_RESULT([gettext() doesn't work]);
3752 LIBS=$olibs))
3753 else
3754 AC_MSG_RESULT([msgfmt not found - disabled]);
3755 fi
3756 if test $have_gettext = "yes"; then
3757 AC_DEFINE(HAVE_GETTEXT)
3758 MAKEMO=yes
3759 AC_SUBST(MAKEMO)
3760 dnl this was added in GNU gettext 0.10.36
3761 AC_CHECK_FUNCS(bind_textdomain_codeset)
3762 dnl _nl_msg_cat_cntr is required for GNU gettext
3763 AC_MSG_CHECKING([for _nl_msg_cat_cntr])
3764 AC_TRY_LINK(
3765 [#include <libintl.h>
3766 extern int _nl_msg_cat_cntr;],
3767 [++_nl_msg_cat_cntr;],
3768 AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_NL_MSG_CAT_CNTR),
3769 AC_MSG_RESULT([no]))
3770 fi
3771 else
3772 AC_MSG_RESULT([no "po/Makefile" - disabled]);
3773 fi
3774else
3775 AC_MSG_RESULT(yes)
3776fi
3777
3778dnl Check for dynamic linking loader
3779AC_CHECK_HEADER(dlfcn.h, DLL=dlfcn.h, [AC_CHECK_HEADER(dl.h, DLL=dl.h)])
3780if test x${DLL} = xdlfcn.h; then
3781 AC_DEFINE(HAVE_DLFCN_H, 1, [ Define if we have dlfcn.h. ])
3782 AC_MSG_CHECKING([for dlopen()])
3783 AC_TRY_LINK(,[
3784 extern void* dlopen();
3785 dlopen();
3786 ],
3787 AC_MSG_RESULT(yes);
3788 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
3789 AC_MSG_RESULT(no);
3790 AC_MSG_CHECKING([for dlopen() in -ldl])
3791 olibs=$LIBS
3792 LIBS="$LIBS -ldl"
3793 AC_TRY_LINK(,[
3794 extern void* dlopen();
3795 dlopen();
3796 ],
3797 AC_MSG_RESULT(yes);
3798 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
3799 AC_MSG_RESULT(no);
3800 LIBS=$olibs))
3801 dnl ReliantUNIX has dlopen() in libc but everything else in libdl
3802 dnl ick :-)
3803 AC_MSG_CHECKING([for dlsym()])
3804 AC_TRY_LINK(,[
3805 extern void* dlsym();
3806 dlsym();
3807 ],
3808 AC_MSG_RESULT(yes);
3809 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
3810 AC_MSG_RESULT(no);
3811 AC_MSG_CHECKING([for dlsym() in -ldl])
3812 olibs=$LIBS
3813 LIBS="$LIBS -ldl"
3814 AC_TRY_LINK(,[
3815 extern void* dlsym();
3816 dlsym();
3817 ],
3818 AC_MSG_RESULT(yes);
3819 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
3820 AC_MSG_RESULT(no);
3821 LIBS=$olibs))
3822elif test x${DLL} = xdl.h; then
3823 AC_DEFINE(HAVE_DL_H, 1, [ Define if we have dl.h. ])
3824 AC_MSG_CHECKING([for shl_load()])
3825 AC_TRY_LINK(,[
3826 extern void* shl_load();
3827 shl_load();
3828 ],
3829 AC_MSG_RESULT(yes);
3830 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
3831 AC_MSG_RESULT(no);
3832 AC_MSG_CHECKING([for shl_load() in -ldld])
3833 olibs=$LIBS
3834 LIBS="$LIBS -ldld"
3835 AC_TRY_LINK(,[
3836 extern void* shl_load();
3837 shl_load();
3838 ],
3839 AC_MSG_RESULT(yes);
3840 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
3841 AC_MSG_RESULT(no);
3842 LIBS=$olibs))
3843fi
3844AC_CHECK_HEADERS(setjmp.h)
3845
3846if test "x$MACOSX" = "xyes" -a -n "$PERL"; then
3847 dnl -ldl must come after DynaLoader.a
3848 if echo $LIBS | grep -e '-ldl' >/dev/null; then
3849 LIBS=`echo $LIBS | sed s/-ldl//`
3850 PERL_LIBS="$PERL_LIBS -ldl"
3851 fi
3852fi
3853
Bram Moolenaar164fca32010-07-14 13:58:07 +02003854if test "x$MACOSX" = "xyes"; then
3855 AC_MSG_CHECKING(whether we need -framework Cocoa)
3856 dnl Cocoa is needed with FEAT_CLIPBOARD or FEAT_MBYTE (the former is
3857 dnl disabled during tiny build)
3858 if test "x$features" != "xtiny" || test "x$enable_multibyte" = "xyes"; then
3859 LIBS=$"$LIBS -framework Cocoa"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003860 AC_MSG_RESULT(yes)
3861 else
3862 AC_MSG_RESULT(no)
3863 fi
Bram Moolenaar3437b912013-07-03 19:52:53 +02003864 dnl As mentioned above, tiny build implies os_macosx.m isn't needed.
3865 dnl Exclude it from OS_EXTRA_SRC so that linker won't complain about
3866 dnl missing Objective-C symbols.
3867 if test "x$features" = "xtiny"; then
3868 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_macosx.m++'`
3869 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_macosx.o++'`
3870 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003871fi
Bram Moolenaar164fca32010-07-14 13:58:07 +02003872if test "x$MACARCH" = "xboth" && test "x$GUITYPE" = "xCARBONGUI"; then
Bram Moolenaar595a7be2010-03-10 16:28:12 +01003873 LDFLAGS="$LDFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +00003874fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003875
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00003876dnl gcc 3.1 changed the meaning of -MM. The only solution appears to be to
3877dnl use "-isystem" instead of "-I" for all non-Vim include dirs.
3878dnl But only when making dependencies, cproto and lint don't take "-isystem".
Bram Moolenaar32466aa2006-02-24 23:53:04 +00003879dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
3880dnl the number before the version number.
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00003881DEPEND_CFLAGS_FILTER=
3882if test "$GCC" = yes; then
Bram Moolenaar0cd49302008-11-20 09:37:01 +00003883 AC_MSG_CHECKING(for GCC 3 or later)
Bram Moolenaar2217cae2006-03-25 21:55:52 +00003884 gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]]\)\..*$/\1/g'`
Bram Moolenaarf740b292006-02-16 22:11:02 +00003885 if test "$gccmajor" -gt "2"; then
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00003886 DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
Bram Moolenaar0cd49302008-11-20 09:37:01 +00003887 AC_MSG_RESULT(yes)
3888 else
3889 AC_MSG_RESULT(no)
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00003890 fi
Bram Moolenaar0cd49302008-11-20 09:37:01 +00003891 dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
3892 dnl declared as char x[1] but actually longer. Introduced in gcc 4.0.
Bram Moolenaar56d1db32009-12-16 16:14:51 +00003893 dnl Also remove duplicate _FORTIFY_SOURCE arguments.
Bram Moolenaaraeabe052011-12-08 15:17:34 +01003894 dnl And undefine it first to avoid a warning.
Bram Moolenaar0cd49302008-11-20 09:37:01 +00003895 AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
3896 if test "$gccmajor" -gt "3"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02003897 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 +00003898 AC_MSG_RESULT(yes)
3899 else
3900 AC_MSG_RESULT(no)
3901 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +00003902fi
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00003903AC_SUBST(DEPEND_CFLAGS_FILTER)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003904
Bram Moolenaar22e193d2010-11-03 22:32:24 +01003905dnl link.sh tries to avoid overlinking in a hackish way.
3906dnl At least GNU ld supports --as-needed which provides the same functionality
3907dnl at linker level. Let's use it.
3908AC_MSG_CHECKING(linker --as-needed support)
3909LINK_AS_NEEDED=
3910# Check if linker supports --as-needed and --no-as-needed options
3911if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02003912 LDFLAGS=`echo "$LDFLAGS" | sed -e 's/ *-Wl,--as-needed//g' | sed -e 's/$/ -Wl,--as-needed/'`
Bram Moolenaar22e193d2010-11-03 22:32:24 +01003913 LINK_AS_NEEDED=yes
3914fi
3915if test "$LINK_AS_NEEDED" = yes; then
3916 AC_MSG_RESULT(yes)
3917else
3918 AC_MSG_RESULT(no)
3919fi
3920AC_SUBST(LINK_AS_NEEDED)
3921
Bram Moolenaar77c19352012-06-13 19:19:41 +02003922# IBM z/OS reset CFLAGS for config.mk
3923if test "$zOSUnix" = "yes"; then
3924 CFLAGS="-D_ALL_SOURCE -Wc,float\(ieee\),dll"
3925fi
3926
Bram Moolenaar071d4272004-06-13 20:20:40 +00003927dnl write output files
3928AC_OUTPUT(auto/config.mk:config.mk.in)
3929
3930dnl vim: set sw=2 tw=78 fo+=l: