blob: df28a246b792906a639d5fd54d9fb2a6f1fd4c40 [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
Bram Moolenaar39766a72013-11-03 00:41:00 +0100231dnl Mac OS X 10.9+ no longer include AvailabilityMacros.h in Carbon
232dnl so we need to include it to have access to version macros.
Bram Moolenaar18e54692013-11-03 20:26:31 +0100233AC_CHECK_HEADERS(AvailabilityMacros.h)
Bram Moolenaar39766a72013-11-03 00:41:00 +0100234
Bram Moolenaar071d4272004-06-13 20:20:40 +0000235AC_SUBST(OS_EXTRA_SRC)
236AC_SUBST(OS_EXTRA_OBJ)
237
238dnl Add /usr/local/lib to $LDFLAGS and /usr/local/include to CFLAGS.
239dnl Only when the directory exists and it wasn't there yet.
240dnl For gcc don't do this when it is already in the default search path.
Bram Moolenaar446cb832008-06-24 21:56:24 +0000241dnl Skip all of this when cross-compiling.
242if test "$cross_compiling" = no; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000243 AC_MSG_CHECKING(--with-local-dir argument)
Bram Moolenaar446cb832008-06-24 21:56:24 +0000244 have_local_include=''
245 have_local_lib=''
Bram Moolenaarc236c162008-07-13 17:41:49 +0000246 AC_ARG_WITH([local-dir], [ --with-local-dir=PATH search PATH instead of /usr/local for local libraries.
247 --without-local-dir do not search /usr/local for local libraries.], [
248 local_dir="$withval"
249 case "$withval" in
250 */*) ;;
251 no)
252 # avoid adding local dir to LDFLAGS and CPPFLAGS
Bram Moolenaare06c1882010-07-21 22:05:20 +0200253 have_local_include=yes
Bram Moolenaarc236c162008-07-13 17:41:49 +0000254 have_local_lib=yes
255 ;;
256 *) AC_MSG_ERROR(must pass path argument to --with-local-dir) ;;
257 esac
258 AC_MSG_RESULT($local_dir)
259 ], [
260 local_dir=/usr/local
261 AC_MSG_RESULT(Defaulting to $local_dir)
262 ])
263 if test "$GCC" = yes -a "$local_dir" != no; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000264 echo 'void f(){}' > conftest.c
265 dnl -no-cpp-precomp is needed for OS X 10.2 (Ben Fowler)
Bram Moolenaarc236c162008-07-13 17:41:49 +0000266 have_local_include=`${CC-cc} -no-cpp-precomp -c -v conftest.c 2>&1 | grep "${local_dir}/include"`
267 have_local_lib=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/lib"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000268 rm -f conftest.c conftest.o
Bram Moolenaar071d4272004-06-13 20:20:40 +0000269 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000270 if test -z "$have_local_lib" -a -d "${local_dir}/lib"; then
271 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 +0000272 if test "$tt" = "$LDFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000273 LDFLAGS="$LDFLAGS -L${local_dir}/lib"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000274 fi
275 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000276 if test -z "$have_local_include" -a -d "${local_dir}/include"; then
277 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 +0000278 if test "$tt" = "$CPPFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000279 CPPFLAGS="$CPPFLAGS -I${local_dir}/include"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000280 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000281 fi
282fi
283
284AC_MSG_CHECKING(--with-vim-name argument)
285AC_ARG_WITH(vim-name, [ --with-vim-name=NAME what to call the Vim executable],
286 VIMNAME="$withval"; AC_MSG_RESULT($VIMNAME),
Bram Moolenaare344bea2005-09-01 20:46:49 +0000287 VIMNAME="vim"; AC_MSG_RESULT(Defaulting to $VIMNAME))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000288AC_SUBST(VIMNAME)
289AC_MSG_CHECKING(--with-ex-name argument)
290AC_ARG_WITH(ex-name, [ --with-ex-name=NAME what to call the Ex executable],
291 EXNAME="$withval"; AC_MSG_RESULT($EXNAME),
292 EXNAME="ex"; AC_MSG_RESULT(Defaulting to ex))
293AC_SUBST(EXNAME)
294AC_MSG_CHECKING(--with-view-name argument)
295AC_ARG_WITH(view-name, [ --with-view-name=NAME what to call the View executable],
296 VIEWNAME="$withval"; AC_MSG_RESULT($VIEWNAME),
297 VIEWNAME="view"; AC_MSG_RESULT(Defaulting to view))
298AC_SUBST(VIEWNAME)
299
300AC_MSG_CHECKING(--with-global-runtime argument)
301AC_ARG_WITH(global-runtime, [ --with-global-runtime=DIR global runtime directory in 'runtimepath'],
302 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL, "$withval"),
303 AC_MSG_RESULT(no))
304
305AC_MSG_CHECKING(--with-modified-by argument)
306AC_ARG_WITH(modified-by, [ --with-modified-by=NAME name of who modified a release version],
307 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(MODIFIED_BY, "$withval"),
308 AC_MSG_RESULT(no))
309
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200310dnl Check for EBCDIC stolen from the LYNX port to z/OS Unix
Bram Moolenaar071d4272004-06-13 20:20:40 +0000311AC_MSG_CHECKING(if character set is EBCDIC)
312AC_TRY_COMPILE([ ],
313[ /* TryCompile function for CharSet.
314 Treat any failure as ASCII for compatibility with existing art.
315 Use compile-time rather than run-time tests for cross-compiler
316 tolerance. */
317#if '0'!=240
318make an error "Character set is not EBCDIC"
319#endif ],
320[ # TryCompile action if true
321cf_cv_ebcdic=yes ],
322[ # TryCompile action if false
323cf_cv_ebcdic=no])
324# end of TryCompile ])
325# end of CacheVal CvEbcdic
326AC_MSG_RESULT($cf_cv_ebcdic)
327case "$cf_cv_ebcdic" in #(vi
328 yes) AC_DEFINE(EBCDIC)
329 line_break='"\\n"'
330 ;;
331 *) line_break='"\\012"';;
332esac
333AC_SUBST(line_break)
334
335if test "$cf_cv_ebcdic" = "yes"; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +0200336dnl If we have EBCDIC we most likely have z/OS Unix, let's test it!
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200337AC_MSG_CHECKING(for z/OS Unix)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000338case `uname` in
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200339 OS/390) zOSUnix="yes";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000340 dnl If using cc the environment variable _CC_CCMODE must be
341 dnl set to "1", so that some compiler extensions are enabled.
342 dnl If using c89 the environment variable is named _CC_C89MODE.
343 dnl Note: compile with c89 never tested.
344 if test "$CC" = "cc"; then
345 ccm="$_CC_CCMODE"
346 ccn="CC"
347 else
348 if test "$CC" = "c89"; then
349 ccm="$_CC_C89MODE"
350 ccn="C89"
351 else
352 ccm=1
353 fi
354 fi
355 if test "$ccm" != "1"; then
356 echo ""
357 echo "------------------------------------------"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200358 echo " On z/OS Unix, the environment variable"
Bram Moolenaar77c19352012-06-13 19:19:41 +0200359 echo " _CC_${ccn}MODE must be set to \"1\"!"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000360 echo " Do:"
361 echo " export _CC_${ccn}MODE=1"
362 echo " and then call configure again."
363 echo "------------------------------------------"
364 exit 1
365 fi
Bram Moolenaar77c19352012-06-13 19:19:41 +0200366 # Set CFLAGS for configure process.
367 # This will be reset later for config.mk.
368 # Use haltonmsg to force error for missing H files.
369 CFLAGS="$CFLAGS -D_ALL_SOURCE -Wc,float(ieee),haltonmsg(3296)";
370 LDFLAGS="$LDFLAGS -Wl,EDIT=NO"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000371 AC_MSG_RESULT(yes)
372 ;;
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200373 *) zOSUnix="no";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000374 AC_MSG_RESULT(no)
375 ;;
376esac
377fi
378
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200379dnl Set QUOTESED. Needs additional backslashes on zOS
380if test "$zOSUnix" = "yes"; then
381 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\\\\\&/g' -e 's/\\\\\\\\\"/\"/' -e 's/\\\\\\\\\";\$\$/\";/'"
382else
383 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\&/g' -e 's/\\\\\"/\"/' -e 's/\\\\\";\$\$/\";/'"
384fi
385AC_SUBST(QUOTESED)
386
387
Bram Moolenaar588ebeb2008-05-07 17:09:24 +0000388dnl Link with -lselinux for SELinux stuff; if not found
389AC_MSG_CHECKING(--disable-selinux argument)
390AC_ARG_ENABLE(selinux,
391 [ --disable-selinux Don't check for SELinux support.],
392 , enable_selinux="yes")
393if test "$enable_selinux" = "yes"; then
394 AC_MSG_RESULT(no)
395 AC_CHECK_LIB(selinux, is_selinux_enabled,
396 [LIBS="$LIBS -lselinux"
397 AC_DEFINE(HAVE_SELINUX)])
398else
399 AC_MSG_RESULT(yes)
400fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000401
402dnl Check user requested features.
403
404AC_MSG_CHECKING(--with-features argument)
405AC_ARG_WITH(features, [ --with-features=TYPE tiny, small, normal, big or huge (default: normal)],
406 features="$withval"; AC_MSG_RESULT($features),
407 features="normal"; AC_MSG_RESULT(Defaulting to normal))
408
409dovimdiff=""
410dogvimdiff=""
411case "$features" in
412 tiny) AC_DEFINE(FEAT_TINY) ;;
413 small) AC_DEFINE(FEAT_SMALL) ;;
414 normal) AC_DEFINE(FEAT_NORMAL) dovimdiff="installvimdiff";
415 dogvimdiff="installgvimdiff" ;;
416 big) AC_DEFINE(FEAT_BIG) dovimdiff="installvimdiff";
417 dogvimdiff="installgvimdiff" ;;
418 huge) AC_DEFINE(FEAT_HUGE) dovimdiff="installvimdiff";
419 dogvimdiff="installgvimdiff" ;;
420 *) AC_MSG_RESULT([Sorry, $features is not supported]) ;;
421esac
422
423AC_SUBST(dovimdiff)
424AC_SUBST(dogvimdiff)
425
426AC_MSG_CHECKING(--with-compiledby argument)
427AC_ARG_WITH(compiledby, [ --with-compiledby=NAME name to show in :version message],
428 compiledby="$withval"; AC_MSG_RESULT($withval),
429 compiledby=""; AC_MSG_RESULT(no))
430AC_SUBST(compiledby)
431
432AC_MSG_CHECKING(--disable-xsmp argument)
433AC_ARG_ENABLE(xsmp,
434 [ --disable-xsmp Disable XSMP session management],
435 , enable_xsmp="yes")
436
437if test "$enable_xsmp" = "yes"; then
438 AC_MSG_RESULT(no)
439 AC_MSG_CHECKING(--disable-xsmp-interact argument)
440 AC_ARG_ENABLE(xsmp-interact,
441 [ --disable-xsmp-interact Disable XSMP interaction],
442 , enable_xsmp_interact="yes")
443 if test "$enable_xsmp_interact" = "yes"; then
444 AC_MSG_RESULT(no)
445 AC_DEFINE(USE_XSMP_INTERACT)
446 else
447 AC_MSG_RESULT(yes)
448 fi
449else
450 AC_MSG_RESULT(yes)
451fi
452
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200453dnl Check for Lua feature.
454AC_MSG_CHECKING(--enable-luainterp argument)
455AC_ARG_ENABLE(luainterp,
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200456 [ --enable-luainterp[=OPTS] Include Lua interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200457 [enable_luainterp="no"])
458AC_MSG_RESULT($enable_luainterp)
459
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200460if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200461 dnl -- find the lua executable
462 AC_SUBST(vi_cv_path_lua)
463
464 AC_MSG_CHECKING(--with-lua-prefix argument)
465 AC_ARG_WITH(lua_prefix,
466 [ --with-lua-prefix=PFX Prefix where Lua is installed.],
467 with_lua_prefix="$withval"; AC_MSG_RESULT($with_lua_prefix),
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200468 with_lua_prefix="";AC_MSG_RESULT(no))
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200469
470 if test "X$with_lua_prefix" != "X"; then
471 vi_cv_path_lua_pfx="$with_lua_prefix"
472 else
473 AC_MSG_CHECKING(LUA_PREFIX environment var)
474 if test "X$LUA_PREFIX" != "X"; then
475 AC_MSG_RESULT("$LUA_PREFIX")
476 vi_cv_path_lua_pfx="$LUA_PREFIX"
477 else
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200478 AC_MSG_RESULT([not set, default to /usr])
479 vi_cv_path_lua_pfx="/usr"
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200480 fi
481 fi
482
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200483 AC_MSG_CHECKING(--with-luajit)
484 AC_ARG_WITH(luajit,
485 [ --with-luajit Link with LuaJIT instead of Lua.],
486 [vi_cv_with_luajit="$withval"],
487 [vi_cv_with_luajit="no"])
488 AC_MSG_RESULT($vi_cv_with_luajit)
489
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200490 LUA_INC=
491 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200492 if test "x$vi_cv_with_luajit" != "xno"; then
493 dnl -- try to find LuaJIT executable
494 AC_PATH_PROG(vi_cv_path_luajit, luajit)
495 if test "X$vi_cv_path_luajit" != "X"; then
496 dnl -- find LuaJIT version
497 AC_CACHE_CHECK(LuaJIT version, vi_cv_version_luajit,
498 [ vi_cv_version_luajit=`${vi_cv_path_luajit} -v | sed 's/LuaJIT \([[0-9.]]*\)\.[[0-9]] .*/\1/'` ])
499 AC_CACHE_CHECK(Lua version of LuaJIT, vi_cv_version_lua_luajit,
500 [ vi_cv_version_lua_luajit=`${vi_cv_path_luajit} -e "print(_VERSION)" | sed 's/.* //'` ])
501 vi_cv_path_lua="$vi_cv_path_luajit"
502 vi_cv_version_lua="$vi_cv_version_lua_luajit"
503 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200504 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200505 dnl -- try to find Lua executable
506 AC_PATH_PROG(vi_cv_path_plain_lua, lua)
507 if test "X$vi_cv_path_plain_lua" != "X"; then
508 dnl -- find Lua version
509 AC_CACHE_CHECK(Lua version, vi_cv_version_plain_lua,
510 [ vi_cv_version_plain_lua=`${vi_cv_path_plain_lua} -e "print(_VERSION)" | sed 's/.* //'` ])
511 fi
512 vi_cv_path_lua="$vi_cv_path_plain_lua"
513 vi_cv_version_lua="$vi_cv_version_plain_lua"
514 fi
515 if test "x$vi_cv_with_luajit" != "xno" && test "X$vi_cv_version_luajit" != "X"; then
516 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit)
517 if test -f $vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit/lua.h; then
518 AC_MSG_RESULT(yes)
519 LUA_INC=/luajit-$vi_cv_version_luajit
520 fi
521 fi
522 if test "X$LUA_INC" = "X"; then
523 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)
524 if test -f $vi_cv_path_lua_pfx/include/lua.h; then
525 AC_MSG_RESULT(yes)
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200526 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200527 AC_MSG_RESULT(no)
528 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua)
529 if test -f $vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h; then
530 AC_MSG_RESULT(yes)
531 LUA_INC=/lua$vi_cv_version_lua
532 else
533 AC_MSG_RESULT(no)
534 vi_cv_path_lua_pfx=
535 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200536 fi
537 fi
538 fi
539
540 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200541 if test "x$vi_cv_with_luajit" != "xno"; then
542 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
543 if test "X$multiarch" != "X"; then
544 lib_multiarch="lib/${multiarch}"
545 else
546 lib_multiarch="lib"
547 fi
548 if test "X$vi_cv_version_lua" = "X"; then
549 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit"
550 else
551 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit-$vi_cv_version_lua"
552 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200553 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200554 if test "X$LUA_INC" != "X"; then
555 dnl Test alternate location using version
556 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua$vi_cv_version_lua"
557 else
558 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua"
559 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200560 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200561 if test "$enable_luainterp" = "dynamic"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200562 lua_ok="yes"
563 else
564 AC_MSG_CHECKING([if link with ${LUA_LIBS} is sane])
565 libs_save=$LIBS
566 LIBS="$LIBS $LUA_LIBS"
567 AC_TRY_LINK(,[ ],
568 AC_MSG_RESULT(yes); lua_ok="yes",
569 AC_MSG_RESULT(no); lua_ok="no"; LUA_LIBS="")
570 LIBS=$libs_save
571 fi
572 if test "x$lua_ok" = "xyes"; then
573 LUA_CFLAGS="-I${vi_cv_path_lua_pfx}/include${LUA_INC}"
574 LUA_SRC="if_lua.c"
575 LUA_OBJ="objects/if_lua.o"
576 LUA_PRO="if_lua.pro"
577 AC_DEFINE(FEAT_LUA)
578 fi
579 if test "$enable_luainterp" = "dynamic"; then
580 if test "x$vi_cv_with_luajit" != "xno"; then
581 luajit="jit"
582 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200583 if test -f "${vi_cv_path_lua_pfx}/bin/cyglua-${vi_cv_version_lua}.dll"; then
584 vi_cv_dll_name_lua="cyglua-${vi_cv_version_lua}.dll"
585 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200586 if test "x$MACOSX" = "xyes"; then
587 ext="dylib"
588 indexes=""
589 else
590 ext="so"
591 indexes=".0 .1 .2 .3 .4 .5 .6 .7 .8 .9"
592 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
593 if test "X$multiarch" != "X"; then
594 lib_multiarch="lib/${multiarch}"
595 fi
Bram Moolenaar768baac2013-04-15 14:44:57 +0200596 fi
597 dnl Determine the sover for the current version, but fallback to
598 dnl liblua${vi_cv_version_lua}.so if no sover-versioned file is found.
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200599 AC_MSG_CHECKING(if liblua${luajit}*.${ext}* can be found in $vi_cv_path_lua_pfx)
Bram Moolenaar768baac2013-04-15 14:44:57 +0200600 for subdir in "${lib_multiarch}" lib64 lib; do
601 if test -z "$subdir"; then
602 continue
603 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200604 for sover in "${vi_cv_version_lua}.${ext}" "-${vi_cv_version_lua}.${ext}" \
605 ".${vi_cv_version_lua}.${ext}" ".${ext}.${vi_cv_version_lua}"; do
606 for i in $indexes ""; do
607 if test -f "${vi_cv_path_lua_pfx}/${subdir}/liblua${luajit}${sover}$i"; then
Bram Moolenaar768baac2013-04-15 14:44:57 +0200608 sover2="$i"
609 break 3
610 fi
611 done
Bram Moolenaar07e1da62013-02-06 19:49:43 +0100612 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200613 sover=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200614 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200615 if test "X$sover" = "X"; then
616 AC_MSG_RESULT(no)
617 lua_ok="no"
618 vi_cv_dll_name_lua="liblua${luajit}.${ext}"
619 else
620 AC_MSG_RESULT(yes)
621 lua_ok="yes"
622 vi_cv_dll_name_lua="liblua${luajit}${sover}$sover2"
623 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200624 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200625 AC_DEFINE(DYNAMIC_LUA)
626 LUA_LIBS=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200627 LUA_CFLAGS="-DDYNAMIC_LUA_DLL=\\\"${vi_cv_dll_name_lua}\\\" $LUA_CFLAGS"
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200628 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200629 if test "X$LUA_CFLAGS$LUA_LIBS" != "X" && \
630 test "x$MACOSX" = "xyes" && test "x$vi_cv_with_luajit" != "xno" && \
631 test "`(uname -m) 2>/dev/null`" = "x86_64"; then
632 dnl OSX/x64 requires these flags. See http://luajit.org/install.html
633 LUA_LIBS="-pagezero_size 10000 -image_base 100000000 $LUA_LIBS"
634 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200635 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200636 if test "$fail_if_missing" = "yes" -a "$lua_ok" != "yes"; then
Bram Moolenaarf788a062011-12-14 20:51:25 +0100637 AC_MSG_ERROR([could not configure lua])
638 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200639 AC_SUBST(LUA_SRC)
640 AC_SUBST(LUA_OBJ)
641 AC_SUBST(LUA_PRO)
642 AC_SUBST(LUA_LIBS)
643 AC_SUBST(LUA_CFLAGS)
644fi
645
646
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000647dnl Check for MzScheme feature.
648AC_MSG_CHECKING(--enable-mzschemeinterp argument)
649AC_ARG_ENABLE(mzschemeinterp,
650 [ --enable-mzschemeinterp Include MzScheme interpreter.], ,
651 [enable_mzschemeinterp="no"])
652AC_MSG_RESULT($enable_mzschemeinterp)
653
654if test "$enable_mzschemeinterp" = "yes"; then
655 dnl -- find the mzscheme executable
656 AC_SUBST(vi_cv_path_mzscheme)
657
658 AC_MSG_CHECKING(--with-plthome argument)
659 AC_ARG_WITH(plthome,
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000660 [ --with-plthome=PLTHOME Use PLTHOME.],
661 with_plthome="$withval"; AC_MSG_RESULT($with_plthome),
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000662 with_plthome="";AC_MSG_RESULT("no"))
663
664 if test "X$with_plthome" != "X"; then
665 vi_cv_path_mzscheme_pfx="$with_plthome"
666 else
667 AC_MSG_CHECKING(PLTHOME environment var)
668 if test "X$PLTHOME" != "X"; then
669 AC_MSG_RESULT("$PLTHOME")
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000670 vi_cv_path_mzscheme_pfx="$PLTHOME"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000671 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000672 AC_MSG_RESULT(not set)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000673 dnl -- try to find MzScheme executable
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000674 AC_PATH_PROG(vi_cv_path_mzscheme, mzscheme)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000675
676 dnl resolve symbolic link, the executable is often elsewhere and there
677 dnl are no links for the include files.
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000678 if test "X$vi_cv_path_mzscheme" != "X"; then
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000679 lsout=`ls -l $vi_cv_path_mzscheme`
680 if echo "$lsout" | grep -e '->' >/dev/null 2>/dev/null; then
681 vi_cv_path_mzscheme=`echo "$lsout" | sed 's/.*-> \(.*\)/\1/'`
682 fi
683 fi
684
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000685 if test "X$vi_cv_path_mzscheme" != "X"; then
686 dnl -- find where MzScheme thinks it was installed
687 AC_CACHE_CHECK(MzScheme install prefix,vi_cv_path_mzscheme_pfx,
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000688 dnl different versions of MzScheme differ in command line processing
689 dnl use universal approach
690 echo "(display (simplify-path \
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000691 (build-path (call-with-values \
692 (lambda () (split-path (find-system-path (quote exec-file)))) \
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000693 (lambda (base name must-be-dir?) base)) (quote up))))" > mzdirs.scm
694 dnl Remove a trailing slash
695 [ vi_cv_path_mzscheme_pfx=`${vi_cv_path_mzscheme} -r mzdirs.scm | \
696 sed -e 's+/$++'` ])
697 rm -f mzdirs.scm
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000698 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000699 fi
700 fi
701
Bram Moolenaard7afed32007-05-06 13:26:41 +0000702 SCHEME_INC=
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000703 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
704 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include)
705 if test -f $vi_cv_path_mzscheme_pfx/include/scheme.h; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000706 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include
707 AC_MSG_RESULT(yes)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000708 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000709 AC_MSG_RESULT(no)
710 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt)
Bram Moolenaard7afed32007-05-06 13:26:41 +0000711 if test -f $vi_cv_path_mzscheme_pfx/include/plt/scheme.h; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000712 AC_MSG_RESULT(yes)
713 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt
Bram Moolenaard7afed32007-05-06 13:26:41 +0000714 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000715 AC_MSG_RESULT(no)
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100716 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket)
717 if test -f $vi_cv_path_mzscheme_pfx/include/racket/scheme.h; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000718 AC_MSG_RESULT(yes)
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100719 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000720 else
721 AC_MSG_RESULT(no)
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100722 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/)
723 if test -f /usr/include/plt/scheme.h; then
724 AC_MSG_RESULT(yes)
725 SCHEME_INC=/usr/include/plt
726 else
727 AC_MSG_RESULT(no)
728 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/racket/)
729 if test -f /usr/include/racket/scheme.h; then
730 AC_MSG_RESULT(yes)
731 SCHEME_INC=/usr/include/racket
732 else
733 AC_MSG_RESULT(no)
734 vi_cv_path_mzscheme_pfx=
735 fi
736 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000737 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000738 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000739 fi
740 fi
741
742 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaarf15f9432007-06-28 11:07:21 +0000743 if test "x$MACOSX" = "xyes"; then
Bram Moolenaar75676462013-01-30 14:55:42 +0100744 MZSCHEME_LIBS="-framework Racket"
745 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000746 elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"; then
747 MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"
748 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100749 elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket3m.a"; then
750 MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libracket3m.a"
751 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
752 elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket.a"; then
753 MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libracket.a ${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a"
754 elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme.a"; then
Bram Moolenaar9048f942007-05-12 14:32:25 +0000755 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 +0000756 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000757 dnl Using shared objects
758 if test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.so"; then
759 MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lmzscheme3m"
760 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100761 elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket3m.so"; then
762 MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lracket3m"
763 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
764 elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket.so"; then
765 MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lracket -lmzgc"
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000766 else
767 MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lmzscheme -lmzgc"
768 fi
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +0000769 if test "$GCC" = yes; then
770 dnl Make Vim remember the path to the library. For when it's not in
771 dnl $LD_LIBRARY_PATH.
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000772 MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${vi_cv_path_mzscheme_pfx}/lib"
Bram Moolenaar21cf8232004-07-16 20:18:37 +0000773 elif test "`(uname) 2>/dev/null`" = SunOS &&
774 uname -r | grep '^5' >/dev/null; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000775 MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${vi_cv_path_mzscheme_pfx}/lib"
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +0000776 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000777 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100778
779 AC_MSG_CHECKING(for racket collects directory)
Bram Moolenaard7afed32007-05-06 13:26:41 +0000780 if test -d $vi_cv_path_mzscheme_pfx/lib/plt/collects; then
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100781 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/plt/
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100782 else
783 if test -d $vi_cv_path_mzscheme_pfx/lib/racket/collects; then
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100784 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/racket/
785 else
786 if test -d $vi_cv_path_mzscheme_pfx/share/racket/collects; then
787 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/
Bram Moolenaar75676462013-01-30 14:55:42 +0100788 else
789 if test -d $vi_cv_path_mzscheme_pfx/collects; then
790 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/
791 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100792 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100793 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000794 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100795 if test "X$SCHEME_COLLECTS" != "X" ; then
796 AC_MSG_RESULT(${SCHEME_COLLECTS})
797 else
798 AC_MSG_RESULT(not found)
799 fi
800
801 AC_MSG_CHECKING(for mzscheme_base.c)
802 if test -f "${SCHEME_COLLECTS}collects/scheme/base.ss" ; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000803 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100804 else
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100805 if test -f "${SCHEME_COLLECTS}collects/scheme/base.rkt" ; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100806 MZSCHEME_EXTRA="mzscheme_base.c"
807 fi
808 fi
809 if test "X$MZSCHEME_EXTRA" != "X" ; then
810 dnl need to generate bytecode for MzScheme base
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000811 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE"
812 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100813 AC_MSG_RESULT(needed)
814 else
815 AC_MSG_RESULT(not needed)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000816 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100817
Bram Moolenaar9e902192013-07-17 18:58:11 +0200818 dnl On Ubuntu this fixes "undefined reference to symbol 'ffi_type_void'".
819 AC_CHECK_LIB(ffi, ffi_type_void, [MZSCHEME_LIBS="$MZSCHEME_LIBS -lffi"])
820
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000821 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -I${SCHEME_INC} \
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100822 -DMZSCHEME_COLLECTS='\"${SCHEME_COLLECTS}collects\"'"
Bram Moolenaar9e902192013-07-17 18:58:11 +0200823
824 dnl Test that we can compile a simple program with these CFLAGS and LIBS.
825 AC_MSG_CHECKING([if compile and link flags for MzScheme are sane])
826 cflags_save=$CFLAGS
827 libs_save=$LIBS
828 CFLAGS="$CFLAGS $MZSCHEME_CFLAGS"
829 LIBS="$LIBS $MZSCHEME_LIBS"
830 AC_TRY_LINK(,[ ],
831 AC_MSG_RESULT(yes); mzs_ok=yes,
832 AC_MSG_RESULT(no: MZSCHEME DISABLED); mzs_ok=no)
833 CFLAGS=$cflags_save
834 LIBS=$libs_save
835 if test $mzs_ok = yes; then
836 MZSCHEME_SRC="if_mzsch.c"
837 MZSCHEME_OBJ="objects/if_mzsch.o"
838 MZSCHEME_PRO="if_mzsch.pro"
839 AC_DEFINE(FEAT_MZSCHEME)
840 else
841 MZSCHEME_CFLAGS=
842 MZSCHEME_LIBS=
843 MZSCHEME_EXTRA=
844 MZSCHEME_MZC=
845 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000846 fi
847 AC_SUBST(MZSCHEME_SRC)
848 AC_SUBST(MZSCHEME_OBJ)
849 AC_SUBST(MZSCHEME_PRO)
850 AC_SUBST(MZSCHEME_LIBS)
851 AC_SUBST(MZSCHEME_CFLAGS)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000852 AC_SUBST(MZSCHEME_EXTRA)
853 AC_SUBST(MZSCHEME_MZC)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000854fi
855
856
Bram Moolenaar071d4272004-06-13 20:20:40 +0000857AC_MSG_CHECKING(--enable-perlinterp argument)
858AC_ARG_ENABLE(perlinterp,
Bram Moolenaare06c1882010-07-21 22:05:20 +0200859 [ --enable-perlinterp[=OPTS] Include Perl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000860 [enable_perlinterp="no"])
861AC_MSG_RESULT($enable_perlinterp)
Bram Moolenaare06c1882010-07-21 22:05:20 +0200862if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000863 AC_SUBST(vi_cv_path_perl)
864 AC_PATH_PROG(vi_cv_path_perl, perl)
865 if test "X$vi_cv_path_perl" != "X"; then
866 AC_MSG_CHECKING(Perl version)
867 if $vi_cv_path_perl -e 'require 5.003_01' >/dev/null 2>/dev/null; then
868 eval `$vi_cv_path_perl -V:usethreads`
Bram Moolenaare06c1882010-07-21 22:05:20 +0200869 eval `$vi_cv_path_perl -V:libperl`
Bram Moolenaar071d4272004-06-13 20:20:40 +0000870 if test "X$usethreads" = "XUNKNOWN" -o "X$usethreads" = "Xundef"; then
871 badthreads=no
872 else
873 if $vi_cv_path_perl -e 'require 5.6.0' >/dev/null 2>/dev/null; then
874 eval `$vi_cv_path_perl -V:use5005threads`
875 if test "X$use5005threads" = "XUNKNOWN" -o "X$use5005threads" = "Xundef"; then
876 badthreads=no
877 else
878 badthreads=yes
879 AC_MSG_RESULT(>>> Perl > 5.6 with 5.5 threads cannot be used <<<)
880 fi
881 else
882 badthreads=yes
883 AC_MSG_RESULT(>>> Perl 5.5 with threads cannot be used <<<)
884 fi
885 fi
886 if test $badthreads = no; then
887 AC_MSG_RESULT(OK)
888 eval `$vi_cv_path_perl -V:shrpenv`
889 if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04
890 shrpenv=""
891 fi
892 vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlibexp}'`
893 AC_SUBST(vi_cv_perllib)
894 dnl Remove "-fno-something", it breaks using cproto.
895 perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
896 -e 'ccflags;perl_inc;print"\n"' | sed -e 's/-fno[[^ ]]*//'`
897 dnl Remove "-lc", it breaks on FreeBSD when using "-pthread".
898 perllibs=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed -e 'ldopts' | \
899 sed -e '/Warning/d' -e '/Note (probably harmless)/d' \
900 -e 's/-bE:perl.exp//' -e 's/-lc //'`
901 dnl Don't add perl lib to $LIBS: if it's not in LD_LIBRARY_PATH
902 dnl a test in configure may fail because of that.
903 perlldflags=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed \
904 -e 'ccdlflags' | sed -e 's/-bE:perl.exp//'`
905
906 dnl check that compiling a simple program still works with the flags
907 dnl added for Perl.
908 AC_MSG_CHECKING([if compile and link flags for Perl are sane])
909 cflags_save=$CFLAGS
910 libs_save=$LIBS
911 ldflags_save=$LDFLAGS
912 CFLAGS="$CFLAGS $perlcppflags"
913 LIBS="$LIBS $perllibs"
Bram Moolenaara6cc0312013-06-18 23:31:55 +0200914 perlldflags=`echo "$perlldflags" | sed -e 's/^ *//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +0000915 LDFLAGS="$perlldflags $LDFLAGS"
916 AC_TRY_LINK(,[ ],
917 AC_MSG_RESULT(yes); perl_ok=yes,
918 AC_MSG_RESULT(no: PERL DISABLED); perl_ok=no)
919 CFLAGS=$cflags_save
920 LIBS=$libs_save
921 LDFLAGS=$ldflags_save
922 if test $perl_ok = yes; then
923 if test "X$perlcppflags" != "X"; then
Bram Moolenaard7afed32007-05-06 13:26:41 +0000924 dnl remove -pipe and -Wxxx, it confuses cproto
925 PERL_CFLAGS=`echo "$perlcppflags" | sed -e 's/-pipe //' -e 's/-W[[^ ]]*//'`
Bram Moolenaar071d4272004-06-13 20:20:40 +0000926 fi
927 if test "X$perlldflags" != "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +0200928 if test "X`echo \"$LDFLAGS\" | grep -F -e \"$perlldflags\"`" = "X"; then
929 LDFLAGS="$perlldflags $LDFLAGS"
930 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000931 fi
932 PERL_LIBS=$perllibs
933 PERL_SRC="auto/if_perl.c if_perlsfio.c"
934 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o"
935 PERL_PRO="if_perl.pro if_perlsfio.pro"
936 AC_DEFINE(FEAT_PERL)
937 fi
938 fi
939 else
940 AC_MSG_RESULT(>>> too old; need Perl version 5.003_01 or later <<<)
941 fi
942 fi
943
944 if test "x$MACOSX" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +0000945 dnl Mac OS X 10.2 or later
Bram Moolenaar071d4272004-06-13 20:20:40 +0000946 dir=/System/Library/Perl
947 darwindir=$dir/darwin
948 if test -d $darwindir; then
949 PERL=/usr/bin/perl
950 else
951 dnl Mac OS X 10.3
952 dir=/System/Library/Perl/5.8.1
953 darwindir=$dir/darwin-thread-multi-2level
954 if test -d $darwindir; then
955 PERL=/usr/bin/perl
956 fi
957 fi
958 if test -n "$PERL"; then
959 PERL_DIR="$dir"
960 PERL_CFLAGS="-DFEAT_PERL -I$darwindir/CORE"
961 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o $darwindir/auto/DynaLoader/DynaLoader.a"
962 PERL_LIBS="-L$darwindir/CORE -lperl"
963 fi
Bram Moolenaar5dff57d2010-07-24 16:19:44 +0200964 dnl Perl on Mac OS X 10.5 adds "-arch" flags but these should only
965 dnl be included if requested by passing --with-mac-arch to
966 dnl configure, so strip these flags first (if present)
967 PERL_LIBS=`echo "$PERL_LIBS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
968 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 +0000969 fi
Bram Moolenaare06c1882010-07-21 22:05:20 +0200970 if test "$enable_perlinterp" = "dynamic"; then
971 if test "$perl_ok" = "yes" -a "X$libperl" != "X"; then
972 AC_DEFINE(DYNAMIC_PERL)
973 PERL_CFLAGS="-DDYNAMIC_PERL_DLL=\\\"$libperl\\\" $PERL_CFLAGS"
974 fi
975 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +0100976
977 if test "$fail_if_missing" = "yes" -a "$perl_ok" != "yes"; then
978 AC_MSG_ERROR([could not configure perl])
979 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000980fi
981AC_SUBST(shrpenv)
982AC_SUBST(PERL_SRC)
983AC_SUBST(PERL_OBJ)
984AC_SUBST(PERL_PRO)
985AC_SUBST(PERL_CFLAGS)
986AC_SUBST(PERL_LIBS)
987
988AC_MSG_CHECKING(--enable-pythoninterp argument)
989AC_ARG_ENABLE(pythoninterp,
Bram Moolenaarb744b2f2010-08-13 16:22:57 +0200990 [ --enable-pythoninterp[=OPTS] Include Python interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000991 [enable_pythoninterp="no"])
992AC_MSG_RESULT($enable_pythoninterp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +0200993if test "$enable_pythoninterp" = "yes" -o "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000994 dnl -- find the python executable
Bram Moolenaar09ba6d72012-12-12 14:25:05 +0100995 AC_PATH_PROGS(vi_cv_path_python, python2 python)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000996 if test "X$vi_cv_path_python" != "X"; then
997
998 dnl -- get its version number
999 AC_CACHE_CHECK(Python version,vi_cv_var_python_version,
1000 [[vi_cv_var_python_version=`
1001 ${vi_cv_path_python} -c 'import sys; print sys.version[:3]'`
1002 ]])
1003
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001004 dnl -- it must be at least version 2.3
1005 AC_MSG_CHECKING(Python is 2.3 or better)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001006 if ${vi_cv_path_python} -c \
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001007 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001008 then
1009 AC_MSG_RESULT(yep)
1010
1011 dnl -- find where python thinks it was installed
1012 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python_pfx,
1013 [ vi_cv_path_python_pfx=`
1014 ${vi_cv_path_python} -c \
1015 "import sys; print sys.prefix"` ])
1016
1017 dnl -- and where it thinks it runs
1018 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python_epfx,
1019 [ vi_cv_path_python_epfx=`
1020 ${vi_cv_path_python} -c \
1021 "import sys; print sys.exec_prefix"` ])
1022
1023 dnl -- python's internal library path
1024
1025 AC_CACHE_VAL(vi_cv_path_pythonpath,
1026 [ vi_cv_path_pythonpath=`
1027 unset PYTHONPATH;
1028 ${vi_cv_path_python} -c \
1029 "import sys, string; print string.join(sys.path,':')"` ])
1030
1031 dnl -- where the Python implementation library archives are
1032
1033 AC_ARG_WITH(python-config-dir,
1034 [ --with-python-config-dir=PATH Python's config directory],
1035 [ vi_cv_path_python_conf="${withval}" ] )
1036
1037 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python_conf,
1038 [
1039 vi_cv_path_python_conf=
Bram Moolenaarac499e32013-06-02 19:14:17 +02001040 d=`${vi_cv_path_python} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBPL')"`
1041 if test -d "$d" && test -f "$d/config.c"; then
1042 vi_cv_path_python_conf="$d"
1043 else
1044 for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
1045 for subdir in lib64 lib share; do
1046 d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
1047 if test -d "$d" && test -f "$d/config.c"; then
1048 vi_cv_path_python_conf="$d"
1049 fi
1050 done
Bram Moolenaar071d4272004-06-13 20:20:40 +00001051 done
Bram Moolenaarac499e32013-06-02 19:14:17 +02001052 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001053 ])
1054
1055 PYTHON_CONFDIR="${vi_cv_path_python_conf}"
1056
1057 if test "X$PYTHON_CONFDIR" = "X"; then
1058 AC_MSG_RESULT([can't find it!])
1059 else
1060
1061 dnl -- we need to examine Python's config/Makefile too
1062 dnl see what the interpreter is built from
1063 AC_CACHE_VAL(vi_cv_path_python_plibs,
1064 [
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001065 pwd=`pwd`
1066 tmp_mkf="$pwd/config-PyMake$$"
1067 cat -- "${PYTHON_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001068__:
Bram Moolenaar218116c2010-05-20 21:46:00 +02001069 @echo "python_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001070 @echo "python_LIBS='$(LIBS)'"
1071 @echo "python_SYSLIBS='$(SYSLIBS)'"
1072 @echo "python_LINKFORSHARED='$(LINKFORSHARED)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001073 @echo "python_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001074 @echo "python_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001075eof
1076 dnl -- delete the lines from make about Entering/Leaving directory
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001077 eval "`cd ${PYTHON_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1078 rm -f -- "${tmp_mkf}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001079 if test "x$MACOSX" = "xyes" && ${vi_cv_path_python} -c \
1080 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then
1081 vi_cv_path_python_plibs="-framework Python"
1082 else
1083 if test "${vi_cv_var_python_version}" = "1.4"; then
1084 vi_cv_path_python_plibs="${PYTHON_CONFDIR}/libModules.a ${PYTHON_CONFDIR}/libPython.a ${PYTHON_CONFDIR}/libObjects.a ${PYTHON_CONFDIR}/libParser.a"
1085 else
1086 vi_cv_path_python_plibs="-L${PYTHON_CONFDIR} -lpython${vi_cv_var_python_version}"
1087 fi
Bram Moolenaar218116c2010-05-20 21:46:00 +02001088 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 +00001089 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1090 vi_cv_path_python_plibs=`echo $vi_cv_path_python_plibs | sed s/-ltermcap//`
1091 fi
1092 ])
1093
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001094 if test "X$python_DLLLIBRARY" != "X"; then
1095 python_INSTSONAME="$python_DLLLIBRARY"
1096 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001097 PYTHON_LIBS="${vi_cv_path_python_plibs}"
1098 if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
Bram Moolenaar780c3e92013-06-11 20:53:28 +02001099 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 +00001100 else
Bram Moolenaar780c3e92013-06-11 20:53:28 +02001101 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 +00001102 fi
1103 PYTHON_SRC="if_python.c"
Bram Moolenaar9bdb9a02012-07-25 16:32:08 +02001104 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001105 if test "${vi_cv_var_python_version}" = "1.4"; then
1106 PYTHON_OBJ="$PYTHON_OBJ objects/py_getpath.o"
1107 fi
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001108 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 +00001109
1110 dnl On FreeBSD linking with "-pthread" is required to use threads.
1111 dnl _THREAD_SAFE must be used for compiling then.
1112 dnl The "-pthread" is added to $LIBS, so that the following check for
1113 dnl sigaltstack() will look in libc_r (it's there in libc!).
1114 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1115 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1116 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1117 AC_MSG_CHECKING([if -pthread should be used])
1118 threadsafe_flag=
1119 thread_lib=
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00001120 dnl if test "x$MACOSX" != "xyes"; then
1121 if test "`(uname) 2>/dev/null`" != Darwin; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001122 test "$GCC" = yes && threadsafe_flag="-pthread"
1123 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1124 threadsafe_flag="-D_THREAD_SAFE"
1125 thread_lib="-pthread"
1126 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001127 if test "`(uname) 2>/dev/null`" = SunOS; then
1128 threadsafe_flag="-pthreads"
1129 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001130 fi
1131 libs_save_old=$LIBS
1132 if test -n "$threadsafe_flag"; then
1133 cflags_save=$CFLAGS
1134 CFLAGS="$CFLAGS $threadsafe_flag"
1135 LIBS="$LIBS $thread_lib"
1136 AC_TRY_LINK(,[ ],
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001137 AC_MSG_RESULT(yes); PYTHON_CFLAGS="$PYTHON_CFLAGS $threadsafe_flag",
Bram Moolenaar071d4272004-06-13 20:20:40 +00001138 AC_MSG_RESULT(no); LIBS=$libs_save_old
1139 )
1140 CFLAGS=$cflags_save
1141 else
1142 AC_MSG_RESULT(no)
1143 fi
1144
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001145 dnl Check that compiling a simple program still works with the flags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001146 dnl added for Python.
1147 AC_MSG_CHECKING([if compile and link flags for Python are sane])
1148 cflags_save=$CFLAGS
1149 libs_save=$LIBS
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001150 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001151 LIBS="$LIBS $PYTHON_LIBS"
1152 AC_TRY_LINK(,[ ],
1153 AC_MSG_RESULT(yes); python_ok=yes,
1154 AC_MSG_RESULT(no: PYTHON DISABLED); python_ok=no)
1155 CFLAGS=$cflags_save
1156 LIBS=$libs_save
1157 if test $python_ok = yes; then
1158 AC_DEFINE(FEAT_PYTHON)
1159 else
1160 LIBS=$libs_save_old
1161 PYTHON_SRC=
1162 PYTHON_OBJ=
1163 PYTHON_LIBS=
1164 PYTHON_CFLAGS=
1165 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001166 fi
1167 else
1168 AC_MSG_RESULT(too old)
1169 fi
1170 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001171
1172 if test "$fail_if_missing" = "yes" -a "$python_ok" != "yes"; then
1173 AC_MSG_ERROR([could not configure python])
1174 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001175fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001176
Bram Moolenaar071d4272004-06-13 20:20:40 +00001177AC_SUBST(PYTHON_CONFDIR)
1178AC_SUBST(PYTHON_LIBS)
1179AC_SUBST(PYTHON_GETPATH_CFLAGS)
1180AC_SUBST(PYTHON_CFLAGS)
1181AC_SUBST(PYTHON_SRC)
1182AC_SUBST(PYTHON_OBJ)
1183
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001184
1185AC_MSG_CHECKING(--enable-python3interp argument)
1186AC_ARG_ENABLE(python3interp,
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001187 [ --enable-python3interp[=OPTS] Include Python3 interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001188 [enable_python3interp="no"])
1189AC_MSG_RESULT($enable_python3interp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001190if test "$enable_python3interp" = "yes" -o "$enable_python3interp" = "dynamic"; then
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001191 dnl -- find the python3 executable
Bram Moolenaar09ba6d72012-12-12 14:25:05 +01001192 AC_PATH_PROGS(vi_cv_path_python3, python3 python)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001193 if test "X$vi_cv_path_python3" != "X"; then
1194
1195 dnl -- get its version number
1196 AC_CACHE_CHECK(Python version,vi_cv_var_python3_version,
1197 [[vi_cv_var_python3_version=`
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001198 ${vi_cv_path_python3} -c 'import sys; print(sys.version[:3])'`
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001199 ]])
1200
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001201 dnl -- it must be at least version 3
1202 AC_MSG_CHECKING(Python is 3.0 or better)
1203 if ${vi_cv_path_python3} -c \
1204 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.0)"
1205 then
1206 AC_MSG_RESULT(yep)
Bram Moolenaar456f2bb2011-06-12 21:37:13 +02001207
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001208 dnl -- get abiflags for python 3.2 or higher (PEP 3149)
1209 AC_CACHE_CHECK(Python's abiflags,vi_cv_var_python3_abiflags,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001210 [
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001211 vi_cv_var_python3_abiflags=
1212 if ${vi_cv_path_python3} -c \
1213 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)"
1214 then
1215 vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \
1216 "import sys; print(sys.abiflags)"`
1217 fi ])
1218
1219 dnl -- find where python3 thinks it was installed
1220 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx,
1221 [ vi_cv_path_python3_pfx=`
1222 ${vi_cv_path_python3} -c \
1223 "import sys; print(sys.prefix)"` ])
1224
1225 dnl -- and where it thinks it runs
1226 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx,
1227 [ vi_cv_path_python3_epfx=`
1228 ${vi_cv_path_python3} -c \
1229 "import sys; print(sys.exec_prefix)"` ])
1230
1231 dnl -- python3's internal library path
1232
1233 AC_CACHE_VAL(vi_cv_path_python3path,
1234 [ vi_cv_path_python3path=`
1235 unset PYTHONPATH;
1236 ${vi_cv_path_python3} -c \
1237 "import sys, string; print(':'.join(sys.path))"` ])
1238
1239 dnl -- where the Python implementation library archives are
1240
1241 AC_ARG_WITH(python3-config-dir,
1242 [ --with-python3-config-dir=PATH Python's config directory],
1243 [ vi_cv_path_python3_conf="${withval}" ] )
1244
1245 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf,
1246 [
1247 vi_cv_path_python3_conf=
Bram Moolenaarfee496d2013-07-12 20:07:24 +02001248 config_dir="config-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001249 d=`${vi_cv_path_python3} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBPL'))"`
1250 if test -d "$d" && test -f "$d/config.c"; then
1251 vi_cv_path_python3_conf="$d"
1252 else
1253 for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do
1254 for subdir in lib64 lib share; do
1255 d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}"
1256 if test -d "$d" && test -f "$d/config.c"; then
1257 vi_cv_path_python3_conf="$d"
1258 fi
1259 done
1260 done
1261 fi
1262 ])
1263
1264 PYTHON3_CONFDIR="${vi_cv_path_python3_conf}"
1265
1266 if test "X$PYTHON3_CONFDIR" = "X"; then
1267 AC_MSG_RESULT([can't find it!])
1268 else
1269
1270 dnl -- we need to examine Python's config/Makefile too
1271 dnl see what the interpreter is built from
1272 AC_CACHE_VAL(vi_cv_path_python3_plibs,
1273 [
1274 pwd=`pwd`
1275 tmp_mkf="$pwd/config-PyMake$$"
1276 cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001277__:
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001278 @echo "python3_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001279 @echo "python3_LIBS='$(LIBS)'"
1280 @echo "python3_SYSLIBS='$(SYSLIBS)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001281 @echo "python3_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001282 @echo "python3_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001283eof
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001284 dnl -- delete the lines from make about Entering/Leaving directory
1285 eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1286 rm -f -- "${tmp_mkf}"
1287 vi_cv_path_python3_plibs="-L${PYTHON3_CONFDIR} -lpython${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
1288 vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}"
1289 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1290 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//`
1291 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//`
1292 ])
1293
1294 if test "X$python3_DLLLIBRARY" != "X"; then
1295 python3_INSTSONAME="$python3_DLLLIBRARY"
1296 fi
1297 PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
1298 if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
Bram Moolenaar780c3e92013-06-11 20:53:28 +02001299 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 +02001300 else
Bram Moolenaar780c3e92013-06-11 20:53:28 +02001301 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 +02001302 fi
1303 PYTHON3_SRC="if_python3.c"
1304 PYTHON3_OBJ="objects/if_python3.o"
1305
1306 dnl On FreeBSD linking with "-pthread" is required to use threads.
1307 dnl _THREAD_SAFE must be used for compiling then.
1308 dnl The "-pthread" is added to $LIBS, so that the following check for
1309 dnl sigaltstack() will look in libc_r (it's there in libc!).
1310 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1311 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1312 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1313 AC_MSG_CHECKING([if -pthread should be used])
1314 threadsafe_flag=
1315 thread_lib=
1316 dnl if test "x$MACOSX" != "xyes"; then
1317 if test "`(uname) 2>/dev/null`" != Darwin; then
1318 test "$GCC" = yes && threadsafe_flag="-pthread"
1319 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1320 threadsafe_flag="-D_THREAD_SAFE"
1321 thread_lib="-pthread"
1322 fi
1323 if test "`(uname) 2>/dev/null`" = SunOS; then
1324 threadsafe_flag="-pthreads"
1325 fi
1326 fi
1327 libs_save_old=$LIBS
1328 if test -n "$threadsafe_flag"; then
1329 cflags_save=$CFLAGS
1330 CFLAGS="$CFLAGS $threadsafe_flag"
1331 LIBS="$LIBS $thread_lib"
1332 AC_TRY_LINK(,[ ],
1333 AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag",
1334 AC_MSG_RESULT(no); LIBS=$libs_save_old
1335 )
1336 CFLAGS=$cflags_save
1337 else
1338 AC_MSG_RESULT(no)
1339 fi
1340
1341 dnl check that compiling a simple program still works with the flags
1342 dnl added for Python.
1343 AC_MSG_CHECKING([if compile and link flags for Python 3 are sane])
1344 cflags_save=$CFLAGS
1345 libs_save=$LIBS
1346 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1347 LIBS="$LIBS $PYTHON3_LIBS"
1348 AC_TRY_LINK(,[ ],
1349 AC_MSG_RESULT(yes); python3_ok=yes,
1350 AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no)
1351 CFLAGS=$cflags_save
1352 LIBS=$libs_save
1353 if test "$python3_ok" = yes; then
1354 AC_DEFINE(FEAT_PYTHON3)
1355 else
1356 LIBS=$libs_save_old
1357 PYTHON3_SRC=
1358 PYTHON3_OBJ=
1359 PYTHON3_LIBS=
1360 PYTHON3_CFLAGS=
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001361 fi
1362 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001363 else
1364 AC_MSG_RESULT(too old)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001365 fi
1366 fi
Bram Moolenaar1612b1a2013-06-14 21:22:39 +02001367 if test "$fail_if_missing" = "yes" -a "$python3_ok" != "yes"; then
1368 AC_MSG_ERROR([could not configure python3])
1369 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001370fi
1371
1372AC_SUBST(PYTHON3_CONFDIR)
1373AC_SUBST(PYTHON3_LIBS)
1374AC_SUBST(PYTHON3_CFLAGS)
1375AC_SUBST(PYTHON3_SRC)
1376AC_SUBST(PYTHON3_OBJ)
1377
1378dnl if python2.x and python3.x are enabled one can only link in code
1379dnl with dlopen(), dlsym(), dlclose()
1380if test "$python_ok" = yes && test "$python3_ok" = yes; then
1381 AC_DEFINE(DYNAMIC_PYTHON)
1382 AC_DEFINE(DYNAMIC_PYTHON3)
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001383 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001384 cflags_save=$CFLAGS
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001385 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001386 ldflags_save=$LDFLAGS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001387 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
1388 LDFLAGS="-ldl $LDFLAGS"
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001389 AC_RUN_IFELSE([
1390 #include <dlfcn.h>
1391 /* If this program fails, then RTLD_GLOBAL is needed.
1392 * RTLD_GLOBAL will be used and then it is not possible to
1393 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001394 * Only the first python version used will be switched on.
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001395 */
1396
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001397 int no_rtl_global_needed_for(char *python_instsoname, char *prefix)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001398 {
1399 int needed = 0;
1400 void* pylib = dlopen(python_instsoname, RTLD_LAZY);
1401 if (pylib != 0)
1402 {
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001403 void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome");
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001404 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1405 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1406 void (*final)(void) = dlsym(pylib, "Py_Finalize");
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001407 (*pfx)(prefix);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001408 (*init)();
1409 needed = (*simple)("import termios") == -1;
1410 (*final)();
1411 dlclose(pylib);
1412 }
1413 return !needed;
1414 }
1415
1416 int main(int argc, char** argv)
1417 {
1418 int not_needed = 0;
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001419 if (no_rtl_global_needed_for("${python_INSTSONAME}", "${vi_cv_path_python_pfx}"))
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001420 not_needed = 1;
1421 return !not_needed;
1422 }],
1423 [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001424
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001425 CFLAGS=$cflags_save
1426 LDFLAGS=$ldflags_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001427
1428 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python3)
1429 cflags_save=$CFLAGS
1430 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1431 ldflags_save=$LDFLAGS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001432 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
1433 LDFLAGS="-ldl $LDFLAGS"
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001434 AC_RUN_IFELSE([
1435 #include <dlfcn.h>
1436 #include <wchar.h>
1437 /* If this program fails, then RTLD_GLOBAL is needed.
1438 * RTLD_GLOBAL will be used and then it is not possible to
1439 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001440 * Only the first python version used will be switched on.
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001441 */
1442
1443 int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix)
1444 {
1445 int needed = 0;
1446 void* pylib = dlopen(python_instsoname, RTLD_LAZY);
1447 if (pylib != 0)
1448 {
1449 void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome");
1450 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1451 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1452 void (*final)(void) = dlsym(pylib, "Py_Finalize");
1453 (*pfx)(prefix);
1454 (*init)();
1455 needed = (*simple)("import termios") == -1;
1456 (*final)();
1457 dlclose(pylib);
1458 }
1459 return !needed;
1460 }
1461
1462 int main(int argc, char** argv)
1463 {
1464 int not_needed = 0;
1465 if (no_rtl_global_needed_for("${python3_INSTSONAME}", L"${vi_cv_path_python3_pfx}"))
1466 not_needed = 1;
1467 return !not_needed;
1468 }],
1469 [AC_MSG_RESULT(yes);AC_DEFINE(PY3_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
1470
1471 CFLAGS=$cflags_save
1472 LDFLAGS=$ldflags_save
1473
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001474 PYTHON_SRC="if_python.c"
1475 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001476 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${python_INSTSONAME}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001477 PYTHON_LIBS=
1478 PYTHON3_SRC="if_python3.c"
1479 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001480 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${python3_INSTSONAME}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001481 PYTHON3_LIBS=
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001482elif test "$python_ok" = yes && test "$enable_pythoninterp" = "dynamic"; then
1483 AC_DEFINE(DYNAMIC_PYTHON)
1484 PYTHON_SRC="if_python.c"
1485 PYTHON_OBJ="objects/if_python.o"
1486 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${python_INSTSONAME}\\\""
1487 PYTHON_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001488elif test "$python_ok" = yes; then
1489 dnl Check that adding -fPIE works. It may be needed when using a static
1490 dnl Python library.
1491 AC_MSG_CHECKING([if -fPIE can be added for Python])
1492 cflags_save=$CFLAGS
1493 libs_save=$LIBS
1494 CFLAGS="$CFLAGS $PYTHON_CFLAGS -fPIE"
1495 LIBS="$LIBS $PYTHON_LIBS"
1496 AC_TRY_LINK(,[ ],
1497 AC_MSG_RESULT(yes); fpie_ok=yes,
1498 AC_MSG_RESULT(no); fpie_ok=no)
1499 CFLAGS=$cflags_save
1500 LIBS=$libs_save
1501 if test $fpie_ok = yes; then
1502 PYTHON_CFLAGS="$PYTHON_CFLAGS -fPIE"
1503 fi
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001504elif test "$python3_ok" = yes && test "$enable_python3interp" = "dynamic"; then
1505 AC_DEFINE(DYNAMIC_PYTHON3)
1506 PYTHON3_SRC="if_python3.c"
1507 PYTHON3_OBJ="objects/if_python3.o"
1508 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${python3_INSTSONAME}\\\""
1509 PYTHON3_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001510elif test "$python3_ok" = yes; then
1511 dnl Check that adding -fPIE works. It may be needed when using a static
1512 dnl Python library.
1513 AC_MSG_CHECKING([if -fPIE can be added for Python3])
1514 cflags_save=$CFLAGS
1515 libs_save=$LIBS
1516 CFLAGS="$CFLAGS $PYTHON3_CFLAGS -fPIE"
1517 LIBS="$LIBS $PYTHON3_LIBS"
1518 AC_TRY_LINK(,[ ],
1519 AC_MSG_RESULT(yes); fpie_ok=yes,
1520 AC_MSG_RESULT(no); fpie_ok=no)
1521 CFLAGS=$cflags_save
1522 LIBS=$libs_save
1523 if test $fpie_ok = yes; then
1524 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -fPIE"
1525 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001526fi
1527
Bram Moolenaar071d4272004-06-13 20:20:40 +00001528AC_MSG_CHECKING(--enable-tclinterp argument)
1529AC_ARG_ENABLE(tclinterp,
1530 [ --enable-tclinterp Include Tcl interpreter.], ,
1531 [enable_tclinterp="no"])
1532AC_MSG_RESULT($enable_tclinterp)
1533
1534if test "$enable_tclinterp" = "yes"; then
1535
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001536 dnl on FreeBSD tclsh is a silly script, look for tclsh8.[5420]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001537 AC_MSG_CHECKING(--with-tclsh argument)
1538 AC_ARG_WITH(tclsh, [ --with-tclsh=PATH which tclsh to use (default: tclsh8.0)],
1539 tclsh_name="$withval"; AC_MSG_RESULT($tclsh_name),
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001540 tclsh_name="tclsh8.5"; AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00001541 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1542 AC_SUBST(vi_cv_path_tcl)
1543
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001544 dnl when no specific version specified, also try 8.4, 8.2 and 8.0
1545 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.5"; then
1546 tclsh_name="tclsh8.4"
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.4"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001550 tclsh_name="tclsh8.2"
1551 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1552 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001553 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.2"; then
1554 tclsh_name="tclsh8.0"
1555 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1556 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001557 dnl still didn't find it, try without version number
1558 if test "X$vi_cv_path_tcl" = "X"; then
1559 tclsh_name="tclsh"
1560 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1561 fi
1562 if test "X$vi_cv_path_tcl" != "X"; then
1563 AC_MSG_CHECKING(Tcl version)
1564 if echo 'exit [[expr [info tclversion] < 8.0]]' | $vi_cv_path_tcl - ; then
1565 tclver=`echo 'puts [[info tclversion]]' | $vi_cv_path_tcl -`
1566 AC_MSG_RESULT($tclver - OK);
1567 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 -`
1568
1569 AC_MSG_CHECKING(for location of Tcl include)
1570 if test "x$MACOSX" != "xyes"; then
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001571 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 +00001572 else
1573 dnl For Mac OS X 10.3, use the OS-provided framework location
1574 tclinc="/System/Library/Frameworks/Tcl.framework/Headers"
1575 fi
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001576 TCL_INC=
Bram Moolenaar071d4272004-06-13 20:20:40 +00001577 for try in $tclinc; do
1578 if test -f "$try/tcl.h"; then
1579 AC_MSG_RESULT($try/tcl.h)
1580 TCL_INC=$try
1581 break
1582 fi
1583 done
1584 if test -z "$TCL_INC"; then
1585 AC_MSG_RESULT(<not found>)
1586 SKIP_TCL=YES
1587 fi
1588 if test -z "$SKIP_TCL"; then
1589 AC_MSG_CHECKING(for location of tclConfig.sh script)
1590 if test "x$MACOSX" != "xyes"; then
1591 tclcnf=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001592 tclcnf="$tclcnf `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001593 else
1594 dnl For Mac OS X 10.3, use the OS-provided framework location
1595 tclcnf="/System/Library/Frameworks/Tcl.framework"
1596 fi
1597 for try in $tclcnf; do
1598 if test -f $try/tclConfig.sh; then
1599 AC_MSG_RESULT($try/tclConfig.sh)
1600 . $try/tclConfig.sh
1601 dnl use eval, because tcl 8.2 includes ${TCL_DBGX}
1602 TCL_LIBS=`eval echo "$TCL_LIB_SPEC $TCL_LIBS"`
1603 dnl Use $TCL_DEFS for -D_THREAD_SAFE et al. But only use the
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001604 dnl "-D_ABC" items. Watch out for -DFOO=long\ long.
Bram Moolenaar4394bff2008-07-24 11:21:31 +00001605 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 +00001606 break
1607 fi
1608 done
1609 if test -z "$TCL_LIBS"; then
1610 AC_MSG_RESULT(<not found>)
1611 AC_MSG_CHECKING(for Tcl library by myself)
1612 tcllib=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001613 tcllib="$tcllib `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001614 for ext in .so .a ; do
1615 for ver in "" $tclver ; do
1616 for try in $tcllib ; do
1617 trylib=tcl$ver$ext
1618 if test -f $try/lib$trylib ; then
1619 AC_MSG_RESULT($try/lib$trylib)
1620 TCL_LIBS="-L$try -ltcl$ver -ldl -lm"
1621 if test "`(uname) 2>/dev/null`" = SunOS &&
1622 uname -r | grep '^5' >/dev/null; then
1623 TCL_LIBS="$TCL_LIBS -R $try"
1624 fi
1625 break 3
1626 fi
1627 done
1628 done
1629 done
1630 if test -z "$TCL_LIBS"; then
1631 AC_MSG_RESULT(<not found>)
1632 SKIP_TCL=YES
1633 fi
1634 fi
1635 if test -z "$SKIP_TCL"; then
1636 AC_DEFINE(FEAT_TCL)
1637 TCL_SRC=if_tcl.c
1638 TCL_OBJ=objects/if_tcl.o
1639 TCL_PRO=if_tcl.pro
1640 TCL_CFLAGS="-I$TCL_INC $TCL_DEFS"
1641 fi
1642 fi
1643 else
1644 AC_MSG_RESULT(too old; need Tcl version 8.0 or later)
1645 fi
1646 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001647 if test "$fail_if_missing" = "yes" -a -z "$TCL_SRC"; then
1648 AC_MSG_ERROR([could not configure Tcl])
1649 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001650fi
1651AC_SUBST(TCL_SRC)
1652AC_SUBST(TCL_OBJ)
1653AC_SUBST(TCL_PRO)
1654AC_SUBST(TCL_CFLAGS)
1655AC_SUBST(TCL_LIBS)
1656
1657AC_MSG_CHECKING(--enable-rubyinterp argument)
1658AC_ARG_ENABLE(rubyinterp,
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001659 [ --enable-rubyinterp[=OPTS] Include Ruby interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001660 [enable_rubyinterp="no"])
1661AC_MSG_RESULT($enable_rubyinterp)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001662if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar165641d2010-02-17 16:23:09 +01001663 AC_MSG_CHECKING(--with-ruby-command argument)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001664 AC_SUBST(vi_cv_path_ruby)
Bram Moolenaar948733a2011-05-05 18:10:16 +02001665 AC_ARG_WITH(ruby-command, [ --with-ruby-command=RUBY name of the Ruby command (default: ruby)],
1666 RUBY_CMD="$withval"; vi_cv_path_ruby="$withval"; AC_MSG_RESULT($RUBY_CMD),
1667 RUBY_CMD="ruby"; AC_MSG_RESULT(defaulting to $RUBY_CMD))
Bram Moolenaar165641d2010-02-17 16:23:09 +01001668 AC_PATH_PROG(vi_cv_path_ruby, $RUBY_CMD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001669 if test "X$vi_cv_path_ruby" != "X"; then
1670 AC_MSG_CHECKING(Ruby version)
Bram Moolenaare4efc3b2005-03-07 23:16:51 +00001671 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 +00001672 AC_MSG_RESULT(OK)
Bram Moolenaar81398892012-10-03 21:09:35 +02001673 AC_MSG_CHECKING(Ruby rbconfig)
1674 ruby_rbconfig="RbConfig"
1675 if ! $vi_cv_path_ruby -r rbconfig -e 'RbConfig' >/dev/null 2>/dev/null; then
1676 ruby_rbconfig="Config"
1677 fi
1678 AC_MSG_RESULT($ruby_rbconfig)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001679 AC_MSG_CHECKING(Ruby header files)
Bram Moolenaar81398892012-10-03 21:09:35 +02001680 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 +00001681 if test "X$rubyhdrdir" != "X"; then
1682 AC_MSG_RESULT($rubyhdrdir)
1683 RUBY_CFLAGS="-I$rubyhdrdir"
Bram Moolenaar81398892012-10-03 21:09:35 +02001684 rubyarch=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['arch']]"`
Bram Moolenaar165641d2010-02-17 16:23:09 +01001685 if test -d "$rubyhdrdir/$rubyarch"; then
1686 RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyhdrdir/$rubyarch"
1687 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001688 rubyversion=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['ruby_version']].gsub(/\./, '')[[0,2]]"`
Bram Moolenaar026a4452013-08-07 15:22:23 +02001689 if test "X$rubyversion" = "X"; then
1690 rubyversion=`$vi_cv_path_ruby -e "print ((VERSION rescue RUBY_VERSION)).gsub(/\./, '')[[0,2]]"`
1691 fi
Bram Moolenaar165641d2010-02-17 16:23:09 +01001692 RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
Bram Moolenaar81398892012-10-03 21:09:35 +02001693 rubylibs=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LIBS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001694 if test "X$rubylibs" != "X"; then
1695 RUBY_LIBS="$rubylibs"
1696 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001697 librubyarg=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBYARG']])"`
1698 librubya=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBY_A']])"`
Bram Moolenaarac499e32013-06-02 19:14:17 +02001699 rubylibdir=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['libdir']])"`
Bram Moolenaar948733a2011-05-05 18:10:16 +02001700 if test -f "$rubylibdir/$librubya"; then
1701 librubyarg="$librubyarg"
Bram Moolenaarac499e32013-06-02 19:14:17 +02001702 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
1703 elif test "$librubyarg" = "libruby.a"; then
1704 dnl required on Mac OS 10.3 where libruby.a doesn't exist
1705 librubyarg="-lruby"
1706 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001707 fi
1708
1709 if test "X$librubyarg" != "X"; then
1710 RUBY_LIBS="$librubyarg $RUBY_LIBS"
1711 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001712 rubyldflags=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LDFLAGS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001713 if test "X$rubyldflags" != "X"; then
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001714 dnl Ruby on Mac OS X 10.5 adds "-arch" flags but these should only
1715 dnl be included if requested by passing --with-mac-arch to
1716 dnl configure, so strip these flags first (if present)
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001717 rubyldflags=`echo "$rubyldflags" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001718 if test "X$rubyldflags" != "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001719 if test "X`echo \"$LDFLAGS\" | grep -F -e \"$rubyldflags\"`" = "X"; then
1720 LDFLAGS="$rubyldflags $LDFLAGS"
1721 fi
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001722 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001723 fi
1724 RUBY_SRC="if_ruby.c"
1725 RUBY_OBJ="objects/if_ruby.o"
1726 RUBY_PRO="if_ruby.pro"
1727 AC_DEFINE(FEAT_RUBY)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001728 if test "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar81398892012-10-03 21:09:35 +02001729 libruby=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_SO']]"`
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001730 AC_DEFINE(DYNAMIC_RUBY)
1731 RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby\\\" -DDYNAMIC_RUBY_VER=$rubyversion $RUBY_CFLAGS"
1732 RUBY_LIBS=
1733 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001734 else
Bram Moolenaar165641d2010-02-17 16:23:09 +01001735 AC_MSG_RESULT(not found; disabling Ruby)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001736 fi
1737 else
1738 AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
1739 fi
1740 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001741
1742 if test "$fail_if_missing" = "yes" -a -z "$RUBY_OBJ"; then
1743 AC_MSG_ERROR([could not configure Ruby])
1744 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001745fi
1746AC_SUBST(RUBY_SRC)
1747AC_SUBST(RUBY_OBJ)
1748AC_SUBST(RUBY_PRO)
1749AC_SUBST(RUBY_CFLAGS)
1750AC_SUBST(RUBY_LIBS)
1751
1752AC_MSG_CHECKING(--enable-cscope argument)
1753AC_ARG_ENABLE(cscope,
1754 [ --enable-cscope Include cscope interface.], ,
1755 [enable_cscope="no"])
1756AC_MSG_RESULT($enable_cscope)
1757if test "$enable_cscope" = "yes"; then
1758 AC_DEFINE(FEAT_CSCOPE)
1759fi
1760
1761AC_MSG_CHECKING(--enable-workshop argument)
1762AC_ARG_ENABLE(workshop,
1763 [ --enable-workshop Include Sun Visual Workshop support.], ,
1764 [enable_workshop="no"])
1765AC_MSG_RESULT($enable_workshop)
1766if test "$enable_workshop" = "yes"; then
1767 AC_DEFINE(FEAT_SUN_WORKSHOP)
1768 WORKSHOP_SRC="workshop.c integration.c"
1769 AC_SUBST(WORKSHOP_SRC)
1770 WORKSHOP_OBJ="objects/workshop.o objects/integration.o"
1771 AC_SUBST(WORKSHOP_OBJ)
1772 if test "${enable_gui-xxx}" = xxx; then
1773 enable_gui=motif
1774 fi
1775fi
1776
1777AC_MSG_CHECKING(--disable-netbeans argument)
1778AC_ARG_ENABLE(netbeans,
1779 [ --disable-netbeans Disable NetBeans integration support.],
1780 , [enable_netbeans="yes"])
1781if test "$enable_netbeans" = "yes"; then
1782 AC_MSG_RESULT(no)
1783 dnl On Solaris we need the socket and nsl library.
1784 AC_CHECK_LIB(socket, socket)
1785 AC_CHECK_LIB(nsl, gethostbyname)
1786 AC_MSG_CHECKING(whether compiling netbeans integration is possible)
1787 AC_TRY_LINK([
1788#include <stdio.h>
1789#include <stdlib.h>
1790#include <stdarg.h>
1791#include <fcntl.h>
1792#include <netdb.h>
1793#include <netinet/in.h>
1794#include <errno.h>
1795#include <sys/types.h>
1796#include <sys/socket.h>
1797 /* Check bitfields */
1798 struct nbbuf {
1799 unsigned int initDone:1;
1800 ushort signmaplen;
1801 };
1802 ], [
1803 /* Check creating a socket. */
1804 struct sockaddr_in server;
1805 (void)socket(AF_INET, SOCK_STREAM, 0);
1806 (void)htons(100);
1807 (void)gethostbyname("microsoft.com");
1808 if (errno == ECONNREFUSED)
1809 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
1810 ],
1811 AC_MSG_RESULT(yes),
1812 AC_MSG_RESULT(no); enable_netbeans="no")
1813else
1814 AC_MSG_RESULT(yes)
1815fi
1816if test "$enable_netbeans" = "yes"; then
1817 AC_DEFINE(FEAT_NETBEANS_INTG)
1818 NETBEANS_SRC="netbeans.c"
1819 AC_SUBST(NETBEANS_SRC)
1820 NETBEANS_OBJ="objects/netbeans.o"
1821 AC_SUBST(NETBEANS_OBJ)
1822fi
1823
1824AC_MSG_CHECKING(--enable-sniff argument)
1825AC_ARG_ENABLE(sniff,
1826 [ --enable-sniff Include Sniff interface.], ,
1827 [enable_sniff="no"])
1828AC_MSG_RESULT($enable_sniff)
1829if test "$enable_sniff" = "yes"; then
1830 AC_DEFINE(FEAT_SNIFF)
1831 SNIFF_SRC="if_sniff.c"
1832 AC_SUBST(SNIFF_SRC)
1833 SNIFF_OBJ="objects/if_sniff.o"
1834 AC_SUBST(SNIFF_OBJ)
1835fi
1836
1837AC_MSG_CHECKING(--enable-multibyte argument)
1838AC_ARG_ENABLE(multibyte,
1839 [ --enable-multibyte Include multibyte editing support.], ,
1840 [enable_multibyte="no"])
1841AC_MSG_RESULT($enable_multibyte)
1842if test "$enable_multibyte" = "yes"; then
1843 AC_DEFINE(FEAT_MBYTE)
1844fi
1845
1846AC_MSG_CHECKING(--enable-hangulinput argument)
1847AC_ARG_ENABLE(hangulinput,
1848 [ --enable-hangulinput Include Hangul input support.], ,
1849 [enable_hangulinput="no"])
1850AC_MSG_RESULT($enable_hangulinput)
1851
1852AC_MSG_CHECKING(--enable-xim argument)
1853AC_ARG_ENABLE(xim,
1854 [ --enable-xim Include XIM input support.],
1855 AC_MSG_RESULT($enable_xim),
1856 [enable_xim="auto"; AC_MSG_RESULT(defaulting to auto)])
Bram Moolenaar071d4272004-06-13 20:20:40 +00001857
1858AC_MSG_CHECKING(--enable-fontset argument)
1859AC_ARG_ENABLE(fontset,
1860 [ --enable-fontset Include X fontset output support.], ,
1861 [enable_fontset="no"])
1862AC_MSG_RESULT($enable_fontset)
1863dnl defining FEAT_XFONTSET is delayed, so that it can be disabled for no GUI
1864
1865test -z "$with_x" && with_x=yes
1866test "${enable_gui-yes}" != no -a "x$MACOSX" != "xyes" -a "x$QNX" != "xyes" && with_x=yes
1867if test "$with_x" = no; then
1868 AC_MSG_RESULT(defaulting to: don't HAVE_X11)
1869else
1870 dnl Do this check early, so that its failure can override user requests.
1871
1872 AC_PATH_PROG(xmkmfpath, xmkmf)
1873
1874 AC_PATH_XTRA
1875
Bram Moolenaar2c704a72010-06-03 21:17:25 +02001876 dnl On z/OS Unix the X libraries are DLLs. To use them the code must
Bram Moolenaar071d4272004-06-13 20:20:40 +00001877 dnl be compiled with a special option.
1878 dnl Also add SM, ICE and Xmu to X_EXTRA_LIBS.
Bram Moolenaar2c704a72010-06-03 21:17:25 +02001879 if test "$zOSUnix" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001880 CFLAGS="$CFLAGS -W c,dll"
1881 LDFLAGS="$LDFLAGS -W l,dll"
1882 X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE -lXmu"
1883 fi
1884
1885 dnl On my HPUX system the X include dir is found, but the lib dir not.
1886 dnl This is a desparate try to fix this.
1887
1888 if test -d "$x_includes" && test ! -d "$x_libraries"; then
1889 x_libraries=`echo "$x_includes" | sed s/include/lib/`
1890 AC_MSG_RESULT(Corrected X libraries to $x_libraries)
1891 X_LIBS="$X_LIBS -L$x_libraries"
1892 if test "`(uname) 2>/dev/null`" = SunOS &&
1893 uname -r | grep '^5' >/dev/null; then
1894 X_LIBS="$X_LIBS -R $x_libraries"
1895 fi
1896 fi
1897
1898 if test -d "$x_libraries" && test ! -d "$x_includes"; then
1899 x_includes=`echo "$x_libraries" | sed s/lib/include/`
1900 AC_MSG_RESULT(Corrected X includes to $x_includes)
1901 X_CFLAGS="$X_CFLAGS -I$x_includes"
1902 fi
1903
1904 dnl Remove "-I/usr/include " from X_CFLAGS, should not be needed.
1905 X_CFLAGS="`echo $X_CFLAGS\ | sed 's%-I/usr/include %%'`"
1906 dnl Remove "-L/usr/lib " from X_LIBS, should not be needed.
1907 X_LIBS="`echo $X_LIBS\ | sed 's%-L/usr/lib %%'`"
1908 dnl Same for "-R/usr/lib ".
1909 X_LIBS="`echo $X_LIBS\ | sed -e 's%-R/usr/lib %%' -e 's%-R /usr/lib %%'`"
1910
1911
1912 dnl Check if the X11 header files are correctly installed. On some systems
Bram Moolenaar00ca2842008-06-26 20:14:00 +00001913 dnl Xlib.h includes files that don't exist. On some systems X11/Intrinsic.h
1914 dnl is missing.
Bram Moolenaar071d4272004-06-13 20:20:40 +00001915 AC_MSG_CHECKING(if X11 header files can be found)
1916 cflags_save=$CFLAGS
1917 CFLAGS="$CFLAGS $X_CFLAGS"
Bram Moolenaar00ca2842008-06-26 20:14:00 +00001918 AC_TRY_COMPILE([#include <X11/Xlib.h>
1919#include <X11/Intrinsic.h>], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001920 AC_MSG_RESULT(yes),
1921 AC_MSG_RESULT(no); no_x=yes)
1922 CFLAGS=$cflags_save
1923
1924 if test "${no_x-no}" = yes; then
1925 with_x=no
1926 else
1927 AC_DEFINE(HAVE_X11)
1928 X_LIB="-lXt -lX11";
1929 AC_SUBST(X_LIB)
1930
1931 ac_save_LDFLAGS="$LDFLAGS"
1932 LDFLAGS="-L$x_libraries $LDFLAGS"
1933
1934 dnl Check for -lXdmcp (needed on SunOS 4.1.4)
1935 dnl For HP-UX 10.20 it must be before -lSM -lICE
1936 AC_CHECK_LIB(Xdmcp, _XdmcpAuthDoIt, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lXdmcp"],,
1937 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXdmcp])
1938
1939 dnl Some systems need -lnsl -lsocket when testing for ICE.
1940 dnl The check above doesn't do this, try here (again). Also needed to get
1941 dnl them after Xdmcp. link.sh will remove them when not needed.
1942 dnl Check for other function than above to avoid the cached value
1943 AC_CHECK_LIB(ICE, IceOpenConnection,
1944 [X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE"],, [$X_EXTRA_LIBS])
1945
1946 dnl Check for -lXpm (needed for some versions of Motif)
1947 LDFLAGS="$X_LIBS $ac_save_LDFLAGS"
1948 AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [X_PRE_LIBS="$X_PRE_LIBS -lXpm"],,
1949 [-lXt $X_PRE_LIBS -lXpm -lX11 $X_EXTRA_LIBS])
1950
1951 dnl Check that the X11 header files don't use implicit declarations
1952 AC_MSG_CHECKING(if X11 header files implicitly declare return values)
1953 cflags_save=$CFLAGS
Bram Moolenaard1864592013-05-04 04:40:15 +02001954 dnl -Werror is GCC only, others like Solaris Studio might not like it
1955 if test "$GCC" = yes; then
1956 CFLAGS="$CFLAGS $X_CFLAGS -Werror"
1957 else
1958 CFLAGS="$CFLAGS $X_CFLAGS"
1959 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001960 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
1961 AC_MSG_RESULT(no),
1962 CFLAGS="$CFLAGS -Wno-implicit-int"
1963 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
1964 AC_MSG_RESULT(yes); cflags_save="$cflags_save -Wno-implicit-int",
1965 AC_MSG_RESULT(test failed)
1966 )
1967 )
1968 CFLAGS=$cflags_save
1969
1970 LDFLAGS="$ac_save_LDFLAGS"
1971
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00001972 AC_MSG_CHECKING(size of wchar_t is 2 bytes)
1973 AC_CACHE_VAL(ac_cv_small_wchar_t,
1974 [AC_TRY_RUN([
1975#include <X11/Xlib.h>
1976#if STDC_HEADERS
1977# include <stdlib.h>
1978# include <stddef.h>
1979#endif
1980 main()
1981 {
1982 if (sizeof(wchar_t) <= 2)
1983 exit(1);
1984 exit(0);
1985 }],
1986 ac_cv_small_wchar_t="no",
1987 ac_cv_small_wchar_t="yes",
1988 AC_MSG_ERROR(failed to compile test program))])
1989 AC_MSG_RESULT($ac_cv_small_wchar_t)
1990 if test "x$ac_cv_small_wchar_t" = "xyes" ; then
1991 AC_DEFINE(SMALL_WCHAR_T)
1992 fi
1993
Bram Moolenaar071d4272004-06-13 20:20:40 +00001994 fi
1995fi
1996
Bram Moolenaara7fc0102005-05-18 22:17:12 +00001997test "x$with_x" = xno -a "x$MACOSX" != "xyes" -a "x$QNX" != "xyes" && enable_gui=no
Bram Moolenaar071d4272004-06-13 20:20:40 +00001998
1999AC_MSG_CHECKING(--enable-gui argument)
2000AC_ARG_ENABLE(gui,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002001 [ --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 +00002002
2003dnl Canonicalize the --enable-gui= argument so that it can be easily compared.
2004dnl Do not use character classes for portability with old tools.
2005enable_gui_canon=`echo "_$enable_gui" | \
2006 sed 's/[[ _+-]]//g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
2007
2008dnl Skip everything by default.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002009SKIP_GTK2=YES
2010SKIP_GNOME=YES
2011SKIP_MOTIF=YES
2012SKIP_ATHENA=YES
2013SKIP_NEXTAW=YES
2014SKIP_PHOTON=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002015SKIP_CARBON=YES
2016GUITYPE=NONE
2017
Bram Moolenaarb11160e2005-01-04 21:31:43 +00002018if test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002019 SKIP_PHOTON=
2020 case "$enable_gui_canon" in
2021 no) AC_MSG_RESULT(no GUI support)
2022 SKIP_PHOTON=YES ;;
2023 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
2024 auto) AC_MSG_RESULT(auto - automatic GUI support) ;;
2025 photon) AC_MSG_RESULT(Photon GUI support) ;;
2026 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2027 SKIP_PHOTON=YES ;;
2028 esac
2029
2030elif test "x$MACOSX" = "xyes" -a "x$with_x" = "xno" ; then
2031 SKIP_CARBON=
2032 case "$enable_gui_canon" in
2033 no) AC_MSG_RESULT(no GUI support)
2034 SKIP_CARBON=YES ;;
2035 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
Bram Moolenaar164fca32010-07-14 13:58:07 +02002036 auto) AC_MSG_RESULT(auto - Carbon GUI is outdated - disable GUI support)
2037 SKIP_CARBON=YES ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002038 carbon) AC_MSG_RESULT(Carbon GUI support) ;;
2039 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2040 SKIP_CARBON=YES ;;
2041 esac
2042
2043else
2044
Bram Moolenaar071d4272004-06-13 20:20:40 +00002045 case "$enable_gui_canon" in
2046 no|none) AC_MSG_RESULT(no GUI support) ;;
2047 yes|""|auto) AC_MSG_RESULT(yes/auto - automatic GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002048 SKIP_GTK2=
2049 SKIP_GNOME=
2050 SKIP_MOTIF=
2051 SKIP_ATHENA=
2052 SKIP_NEXTAW=
2053 SKIP_CARBON=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002054 gtk2) AC_MSG_RESULT(GTK+ 2.x GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002055 SKIP_GTK2=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002056 gnome2) AC_MSG_RESULT(GNOME 2.x GUI support)
2057 SKIP_GNOME=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002058 SKIP_GTK2=;;
2059 motif) AC_MSG_RESULT(Motif GUI support)
2060 SKIP_MOTIF=;;
2061 athena) AC_MSG_RESULT(Athena GUI support)
2062 SKIP_ATHENA=;;
2063 nextaw) AC_MSG_RESULT(neXtaw GUI support)
2064 SKIP_NEXTAW=;;
2065 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
2066 esac
2067
2068fi
2069
Bram Moolenaar071d4272004-06-13 20:20:40 +00002070if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \
2071 -a "$enable_gui_canon" != "gnome2"; then
2072 AC_MSG_CHECKING(whether or not to look for GTK+ 2)
2073 AC_ARG_ENABLE(gtk2-check,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002074 [ --enable-gtk2-check If auto-select GUI, check for GTK+ 2 [default=yes]],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002075 , enable_gtk2_check="yes")
2076 AC_MSG_RESULT($enable_gtk2_check)
2077 if test "x$enable_gtk2_check" = "xno"; then
2078 SKIP_GTK2=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002079 SKIP_GNOME=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002080 fi
2081fi
2082
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002083if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002084 AC_MSG_CHECKING(whether or not to look for GNOME)
2085 AC_ARG_ENABLE(gnome-check,
2086 [ --enable-gnome-check If GTK GUI, check for GNOME [default=no]],
2087 , enable_gnome_check="no")
2088 AC_MSG_RESULT($enable_gnome_check)
2089 if test "x$enable_gnome_check" = "xno"; then
2090 SKIP_GNOME=YES
2091 fi
2092fi
2093
2094if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then
2095 AC_MSG_CHECKING(whether or not to look for Motif)
2096 AC_ARG_ENABLE(motif-check,
2097 [ --enable-motif-check If auto-select GUI, check for Motif [default=yes]],
2098 , enable_motif_check="yes")
2099 AC_MSG_RESULT($enable_motif_check)
2100 if test "x$enable_motif_check" = "xno"; then
2101 SKIP_MOTIF=YES
2102 fi
2103fi
2104
2105if test "x$SKIP_ATHENA" != "xYES" -a "$enable_gui_canon" != "athena"; then
2106 AC_MSG_CHECKING(whether or not to look for Athena)
2107 AC_ARG_ENABLE(athena-check,
2108 [ --enable-athena-check If auto-select GUI, check for Athena [default=yes]],
2109 , enable_athena_check="yes")
2110 AC_MSG_RESULT($enable_athena_check)
2111 if test "x$enable_athena_check" = "xno"; then
2112 SKIP_ATHENA=YES
2113 fi
2114fi
2115
2116if test "x$SKIP_NEXTAW" != "xYES" -a "$enable_gui_canon" != "nextaw"; then
2117 AC_MSG_CHECKING(whether or not to look for neXtaw)
2118 AC_ARG_ENABLE(nextaw-check,
2119 [ --enable-nextaw-check If auto-select GUI, check for neXtaw [default=yes]],
2120 , enable_nextaw_check="yes")
2121 AC_MSG_RESULT($enable_nextaw_check);
2122 if test "x$enable_nextaw_check" = "xno"; then
2123 SKIP_NEXTAW=YES
2124 fi
2125fi
2126
2127if test "x$SKIP_CARBON" != "xYES" -a "$enable_gui_canon" != "carbon"; then
2128 AC_MSG_CHECKING(whether or not to look for Carbon)
2129 AC_ARG_ENABLE(carbon-check,
2130 [ --enable-carbon-check If auto-select GUI, check for Carbon [default=yes]],
2131 , enable_carbon_check="yes")
2132 AC_MSG_RESULT($enable_carbon_check);
2133 if test "x$enable_carbon_check" = "xno"; then
2134 SKIP_CARBON=YES
2135 fi
2136fi
2137
Bram Moolenaar843ee412004-06-30 16:16:41 +00002138
Bram Moolenaar071d4272004-06-13 20:20:40 +00002139if test "x$MACOSX" = "xyes" -a -z "$SKIP_CARBON" -a "x$CARBON" = "xyes"; then
2140 AC_MSG_CHECKING(for Carbon GUI)
Bram Moolenaar14716812006-05-04 21:54:08 +00002141 dnl already did the check, just give the message
Bram Moolenaar071d4272004-06-13 20:20:40 +00002142 AC_MSG_RESULT(yes);
2143 GUITYPE=CARBONGUI
Bram Moolenaare344bea2005-09-01 20:46:49 +00002144 if test "$VIMNAME" = "vim"; then
2145 VIMNAME=Vim
2146 fi
Bram Moolenaar14716812006-05-04 21:54:08 +00002147
Bram Moolenaar164fca32010-07-14 13:58:07 +02002148 if test "x$MACARCH" = "xboth"; then
2149 CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk/Developer/Headers/FlatCarbon"
2150 else
2151 CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/Headers/FlatCarbon"
2152 fi
2153
Bram Moolenaar14716812006-05-04 21:54:08 +00002154 dnl Default install directory is not /usr/local
2155 if test x$prefix = xNONE; then
2156 prefix=/Applications
2157 fi
2158
2159 dnl Sorry for the hard coded default
2160 datadir='${prefix}/Vim.app/Contents/Resources'
2161
Bram Moolenaar071d4272004-06-13 20:20:40 +00002162 dnl skip everything else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002163 SKIP_GTK2=YES;
2164 SKIP_GNOME=YES;
2165 SKIP_MOTIF=YES;
2166 SKIP_ATHENA=YES;
2167 SKIP_NEXTAW=YES;
2168 SKIP_PHOTON=YES;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002169 SKIP_CARBON=YES
2170fi
2171
Bram Moolenaar071d4272004-06-13 20:20:40 +00002172dnl define an autoconf function to check for a specified version of GTK, and
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002173dnl try to compile/link a GTK program.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002174dnl
2175dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002176dnl Test for GTK, and define GTK_CFLAGS, GTK_LIBDIR and GTK_LIBS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002177dnl
2178AC_DEFUN(AM_PATH_GTK,
2179[
2180 if test "X$GTK_CONFIG" != "Xno" -o "X$PKG_CONFIG" != "Xno"; then
2181 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002182 min_gtk_version=ifelse([$1], ,2.2.0,$1)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002183 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
2184 no_gtk=""
2185 if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2186 && $PKG_CONFIG --exists gtk+-2.0; then
2187 {
2188 dnl We should be using PKG_CHECK_MODULES() instead of this hack.
2189 dnl But I guess the dependency on pkgconfig.m4 is not wanted or
2190 dnl something like that.
2191 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0`
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002192 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-2.0`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002193 GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0`
2194 gtk_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2195 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2196 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2197 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2198 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2199 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2200 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002201 else
2202 no_gtk=yes
2203 fi
2204
2205 if test "x$enable_gtktest" = "xyes" -a "x$no_gtk" = "x"; then
2206 {
2207 ac_save_CFLAGS="$CFLAGS"
2208 ac_save_LIBS="$LIBS"
2209 CFLAGS="$CFLAGS $GTK_CFLAGS"
2210 LIBS="$LIBS $GTK_LIBS"
2211
2212 dnl
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002213 dnl Now check if the installed GTK is sufficiently new.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002214 dnl
2215 rm -f conf.gtktest
2216 AC_TRY_RUN([
2217#include <gtk/gtk.h>
2218#include <stdio.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00002219#if STDC_HEADERS
2220# include <stdlib.h>
2221# include <stddef.h>
2222#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002223
2224int
2225main ()
2226{
2227int major, minor, micro;
2228char *tmp_version;
2229
2230system ("touch conf.gtktest");
2231
2232/* HP/UX 9 (%@#!) writes to sscanf strings */
2233tmp_version = g_strdup("$min_gtk_version");
2234if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
2235 printf("%s, bad version string\n", "$min_gtk_version");
2236 exit(1);
2237 }
2238
2239if ((gtk_major_version > major) ||
2240 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
2241 ((gtk_major_version == major) && (gtk_minor_version == minor) &&
2242 (gtk_micro_version >= micro)))
2243{
2244 return 0;
2245}
2246return 1;
2247}
2248],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
2249 CFLAGS="$ac_save_CFLAGS"
2250 LIBS="$ac_save_LIBS"
2251 }
2252 fi
2253 if test "x$no_gtk" = x ; then
2254 if test "x$enable_gtktest" = "xyes"; then
2255 AC_MSG_RESULT(yes; found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2256 else
2257 AC_MSG_RESULT(found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2258 fi
2259 ifelse([$2], , :, [$2])
2260 else
2261 {
2262 AC_MSG_RESULT(no)
2263 GTK_CFLAGS=""
2264 GTK_LIBS=""
2265 ifelse([$3], , :, [$3])
2266 }
2267 fi
2268 }
2269 else
2270 GTK_CFLAGS=""
2271 GTK_LIBS=""
2272 ifelse([$3], , :, [$3])
2273 fi
2274 AC_SUBST(GTK_CFLAGS)
2275 AC_SUBST(GTK_LIBS)
2276 rm -f conf.gtktest
2277])
2278
2279dnl ---------------------------------------------------------------------------
2280dnl gnome
2281dnl ---------------------------------------------------------------------------
2282AC_DEFUN([GNOME_INIT_HOOK],
2283[
2284 AC_SUBST(GNOME_LIBS)
2285 AC_SUBST(GNOME_LIBDIR)
2286 AC_SUBST(GNOME_INCLUDEDIR)
2287
2288 AC_ARG_WITH(gnome-includes,
2289 [ --with-gnome-includes=DIR Specify location of GNOME headers],
2290 [CFLAGS="$CFLAGS -I$withval"]
2291 )
2292
2293 AC_ARG_WITH(gnome-libs,
2294 [ --with-gnome-libs=DIR Specify location of GNOME libs],
2295 [LDFLAGS="$LDFLAGS -L$withval" gnome_prefix=$withval]
2296 )
2297
2298 AC_ARG_WITH(gnome,
2299 [ --with-gnome Specify prefix for GNOME files],
2300 if test x$withval = xyes; then
2301 want_gnome=yes
2302 ifelse([$1], [], :, [$1])
2303 else
2304 if test "x$withval" = xno; then
2305 want_gnome=no
2306 else
2307 want_gnome=yes
2308 LDFLAGS="$LDFLAGS -L$withval/lib"
2309 CFLAGS="$CFLAGS -I$withval/include"
2310 gnome_prefix=$withval/lib
2311 fi
2312 fi,
2313 want_gnome=yes)
2314
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002315 if test "x$want_gnome" = xyes; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002316 {
2317 AC_MSG_CHECKING(for libgnomeui-2.0)
2318 if $PKG_CONFIG --exists libgnomeui-2.0; then
2319 AC_MSG_RESULT(yes)
2320 GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0`
2321 GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0`
2322 GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0`
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002323
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002324 dnl On FreeBSD we need -pthread but pkg-config doesn't include it.
2325 dnl This might not be the right way but it works for me...
2326 AC_MSG_CHECKING(for FreeBSD)
2327 if test "`(uname) 2>/dev/null`" = FreeBSD; then
2328 AC_MSG_RESULT(yes, adding -pthread)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002329 GNOME_INCLUDEDIR="$GNOME_INCLUDEDIR -D_THREAD_SAFE"
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002330 GNOME_LIBS="$GNOME_LIBS -pthread"
2331 else
2332 AC_MSG_RESULT(no)
2333 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002334 $1
2335 else
2336 AC_MSG_RESULT(not found)
2337 if test "x$2" = xfail; then
2338 AC_MSG_ERROR(Could not find libgnomeui-2.0 via pkg-config)
2339 fi
2340 fi
2341 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002342 fi
2343])
2344
2345AC_DEFUN([GNOME_INIT],[
2346 GNOME_INIT_HOOK([],fail)
2347])
2348
2349
2350dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002351dnl Check for GTK2. If it fails, then continue on for Motif as before...
Bram Moolenaar071d4272004-06-13 20:20:40 +00002352dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002353if test -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002354
2355 AC_MSG_CHECKING(--disable-gtktest argument)
2356 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2357 , enable_gtktest=yes)
2358 if test "x$enable_gtktest" = "xyes" ; then
2359 AC_MSG_RESULT(gtk test enabled)
2360 else
2361 AC_MSG_RESULT(gtk test disabled)
2362 fi
2363
Bram Moolenaar071d4272004-06-13 20:20:40 +00002364 if test "X$PKG_CONFIG" = "X"; then
2365 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
2366 fi
2367
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002368 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002369 dnl First try finding version 2.2.0 or later. The 2.0.x series has
2370 dnl problems (bold fonts, --remote doesn't work).
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002371 AM_PATH_GTK(2.2.0,
2372 [GUI_LIB_LOC="$GTK_LIBDIR"
2373 GTK_LIBNAME="$GTK_LIBS"
2374 GUI_INC_LOC="$GTK_CFLAGS"], )
2375 if test "x$GTK_CFLAGS" != "x"; then
2376 SKIP_ATHENA=YES
2377 SKIP_NEXTAW=YES
2378 SKIP_MOTIF=YES
2379 GUITYPE=GTK
2380 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002381 fi
2382 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002383 if test "x$GUITYPE" = "xGTK"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002384 if test "$gtk_minor_version" = 1 -a "0$gtk_micro_version" -ge 1 \
2385 || test "0$gtk_minor_version" -ge 2; then
2386 AC_DEFINE(HAVE_GTK_MULTIHEAD)
2387 fi
2388 dnl
2389 dnl if GTK exists, then check for GNOME.
2390 dnl
2391 if test -z "$SKIP_GNOME"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002392 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002393 GNOME_INIT_HOOK([have_gnome=yes])
2394 if test "x$have_gnome" = xyes ; then
2395 AC_DEFINE(FEAT_GUI_GNOME)
2396 GUI_INC_LOC="$GUI_INC_LOC $GNOME_INCLUDEDIR"
2397 GTK_LIBNAME="$GTK_LIBNAME $GNOME_LIBDIR $GNOME_LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002398 fi
2399 }
2400 fi
2401 fi
2402fi
2403
2404dnl Check for Motif include files location.
2405dnl The LAST one found is used, this makes the highest version to be used,
2406dnl e.g. when Motif1.2 and Motif2.0 are both present.
2407
2408if test -z "$SKIP_MOTIF"; then
2409 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"
2410 dnl Remove "-I" from before $GUI_INC_LOC if it's there
2411 GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`"
2412
2413 AC_MSG_CHECKING(for location of Motif GUI includes)
2414 gui_includes="`echo $x_includes|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC"
2415 GUI_INC_LOC=
2416 for try in $gui_includes; do
2417 if test -f "$try/Xm/Xm.h"; then
2418 GUI_INC_LOC=$try
2419 fi
2420 done
2421 if test -n "$GUI_INC_LOC"; then
2422 if test "$GUI_INC_LOC" = /usr/include; then
2423 GUI_INC_LOC=
2424 AC_MSG_RESULT(in default path)
2425 else
2426 AC_MSG_RESULT($GUI_INC_LOC)
2427 fi
2428 else
2429 AC_MSG_RESULT(<not found>)
2430 SKIP_MOTIF=YES
2431 fi
2432fi
2433
2434dnl Check for Motif library files location. In the same order as the include
2435dnl files, to avoid a mixup if several versions are present
2436
2437if test -z "$SKIP_MOTIF"; then
2438 AC_MSG_CHECKING(--with-motif-lib argument)
2439 AC_ARG_WITH(motif-lib,
2440 [ --with-motif-lib=STRING Library for Motif ],
2441 [ MOTIF_LIBNAME="${withval}" ] )
2442
2443 if test -n "$MOTIF_LIBNAME"; then
2444 AC_MSG_RESULT($MOTIF_LIBNAME)
2445 GUI_LIB_LOC=
2446 else
2447 AC_MSG_RESULT(no)
2448
2449 dnl Remove "-L" from before $GUI_LIB_LOC if it's there
2450 GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
2451
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002452 dnl Ubuntu has libXm.so in /usr/lib/i386-linux-gnu and elsewhere. The
2453 dnl linker will figure out which one to use, we only check if one exists.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002454 AC_MSG_CHECKING(for location of Motif GUI libs)
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002455 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 +00002456 GUI_LIB_LOC=
2457 for try in $gui_libs; do
Bram Moolenaar325b7a22004-07-05 15:58:32 +00002458 for libtry in "$try"/libXm.a "$try"/libXm.so* "$try"/libXm.sl "$try"/libXm.dylib; do
Bram Moolenaar071d4272004-06-13 20:20:40 +00002459 if test -f "$libtry"; then
2460 GUI_LIB_LOC=$try
2461 fi
2462 done
2463 done
2464 if test -n "$GUI_LIB_LOC"; then
2465 dnl Remove /usr/lib, it causes trouble on some systems
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002466 if test "$GUI_LIB_LOC" = /usr/lib \
2467 -o "$GUI_LIB_LOC" = /usr/lib/i386-linux-gnu \
2468 -o "$GUI_LIB_LOC" = /usr/lib/x86_64-linux-gnu; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002469 GUI_LIB_LOC=
2470 AC_MSG_RESULT(in default path)
2471 else
2472 if test -n "$GUI_LIB_LOC"; then
2473 AC_MSG_RESULT($GUI_LIB_LOC)
2474 if test "`(uname) 2>/dev/null`" = SunOS &&
2475 uname -r | grep '^5' >/dev/null; then
2476 GUI_LIB_LOC="$GUI_LIB_LOC -R $GUI_LIB_LOC"
2477 fi
2478 fi
2479 fi
2480 MOTIF_LIBNAME=-lXm
2481 else
2482 AC_MSG_RESULT(<not found>)
2483 SKIP_MOTIF=YES
2484 fi
2485 fi
2486fi
2487
2488if test -z "$SKIP_MOTIF"; then
2489 SKIP_ATHENA=YES
2490 SKIP_NEXTAW=YES
2491 GUITYPE=MOTIF
2492 AC_SUBST(MOTIF_LIBNAME)
2493fi
2494
2495dnl Check if the Athena files can be found
2496
2497GUI_X_LIBS=
2498
2499if test -z "$SKIP_ATHENA"; then
2500 AC_MSG_CHECKING(if Athena header files can be found)
2501 cflags_save=$CFLAGS
2502 CFLAGS="$CFLAGS $X_CFLAGS"
2503 AC_TRY_COMPILE([
2504#include <X11/Intrinsic.h>
2505#include <X11/Xaw/Paned.h>], ,
2506 AC_MSG_RESULT(yes),
2507 AC_MSG_RESULT(no); SKIP_ATHENA=YES )
2508 CFLAGS=$cflags_save
2509fi
2510
2511if test -z "$SKIP_ATHENA"; then
2512 GUITYPE=ATHENA
2513fi
2514
2515if test -z "$SKIP_NEXTAW"; then
2516 AC_MSG_CHECKING(if neXtaw header files can be found)
2517 cflags_save=$CFLAGS
2518 CFLAGS="$CFLAGS $X_CFLAGS"
2519 AC_TRY_COMPILE([
2520#include <X11/Intrinsic.h>
2521#include <X11/neXtaw/Paned.h>], ,
2522 AC_MSG_RESULT(yes),
2523 AC_MSG_RESULT(no); SKIP_NEXTAW=YES )
2524 CFLAGS=$cflags_save
2525fi
2526
2527if test -z "$SKIP_NEXTAW"; then
2528 GUITYPE=NEXTAW
2529fi
2530
2531if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
2532 dnl Prepend -I and -L to $GUI_INC_LOC and $GUI_LIB_LOC if not empty
2533 dnl Avoid adding it when it twice
2534 if test -n "$GUI_INC_LOC"; then
2535 GUI_INC_LOC=-I"`echo $GUI_INC_LOC|sed 's%-I%%'`"
2536 fi
2537 if test -n "$GUI_LIB_LOC"; then
2538 GUI_LIB_LOC=-L"`echo $GUI_LIB_LOC|sed 's%-L%%'`"
2539 fi
2540
2541 dnl Check for -lXext and then for -lXmu
2542 ldflags_save=$LDFLAGS
2543 LDFLAGS="$X_LIBS $LDFLAGS"
2544 AC_CHECK_LIB(Xext, XShapeQueryExtension, [GUI_X_LIBS="-lXext"],,
2545 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2546 dnl For Solaris we need -lw and -ldl before linking with -lXmu works.
2547 AC_CHECK_LIB(w, wslen, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lw"],,
2548 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2549 AC_CHECK_LIB(dl, dlsym, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldl"],,
2550 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2551 AC_CHECK_LIB(Xmu, XmuCreateStippledPixmap, [GUI_X_LIBS="-lXmu $GUI_X_LIBS"],,
2552 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2553 if test -z "$SKIP_MOTIF"; then
2554 AC_CHECK_LIB(Xp, XpEndJob, [GUI_X_LIBS="-lXp $GUI_X_LIBS"],,
2555 [$GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2556 fi
2557 LDFLAGS=$ldflags_save
2558
2559 dnl Execute xmkmf to figure out if -DNARROWPROTO is needed.
2560 AC_MSG_CHECKING(for extra X11 defines)
2561 NARROW_PROTO=
2562 rm -fr conftestdir
2563 if mkdir conftestdir; then
2564 cd conftestdir
2565 cat > Imakefile <<'EOF'
2566acfindx:
2567 @echo 'NARROW_PROTO="${PROTO_DEFINES}"'
2568EOF
2569 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
2570 eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
2571 fi
2572 cd ..
2573 rm -fr conftestdir
2574 fi
2575 if test -z "$NARROW_PROTO"; then
2576 AC_MSG_RESULT(no)
2577 else
2578 AC_MSG_RESULT($NARROW_PROTO)
2579 fi
2580 AC_SUBST(NARROW_PROTO)
2581fi
2582
2583dnl Look for XSMP support - but don't necessarily restrict it to X11 GUIs
2584dnl use the X11 include path
2585if test "$enable_xsmp" = "yes"; then
2586 cppflags_save=$CPPFLAGS
2587 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2588 AC_CHECK_HEADERS(X11/SM/SMlib.h)
2589 CPPFLAGS=$cppflags_save
2590fi
2591
2592
Bram Moolenaare667c952010-07-05 22:57:59 +02002593if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF" -o -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002594 dnl Check for X11/xpm.h and X11/Sunkeysym.h with the GUI include path
2595 cppflags_save=$CPPFLAGS
2596 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2597 AC_CHECK_HEADERS(X11/xpm.h X11/Sunkeysym.h)
2598
2599 dnl automatically disable XIM when XIMtext isn't in X11/Xlib.h
2600 if test ! "$enable_xim" = "no"; then
2601 AC_MSG_CHECKING(for XIMText in X11/Xlib.h)
2602 AC_EGREP_CPP(XIMText, [#include <X11/Xlib.h>],
2603 AC_MSG_RESULT(yes),
2604 AC_MSG_RESULT(no; xim has been disabled); enable_xim = "no")
2605 fi
2606 CPPFLAGS=$cppflags_save
2607
2608 dnl automatically enable XIM when hangul input isn't enabled
2609 if test "$enable_xim" = "auto" -a "$enable_hangulinput" != "yes" \
2610 -a "x$GUITYPE" != "xNONE" ; then
2611 AC_MSG_RESULT(X GUI selected; xim has been enabled)
2612 enable_xim="yes"
2613 fi
2614fi
2615
2616if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
2617 cppflags_save=$CPPFLAGS
2618 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00002619dnl Xmu/Editres.h may exist but can only be used after including Intrinsic.h
2620 AC_MSG_CHECKING([for X11/Xmu/Editres.h])
2621 AC_TRY_COMPILE([
2622#include <X11/Intrinsic.h>
2623#include <X11/Xmu/Editres.h>],
2624 [int i; i = 0;],
2625 AC_MSG_RESULT(yes)
2626 AC_DEFINE(HAVE_X11_XMU_EDITRES_H),
2627 AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00002628 CPPFLAGS=$cppflags_save
2629fi
2630
2631dnl Only use the Xm directory when compiling Motif, don't use it for Athena
2632if test -z "$SKIP_MOTIF"; then
2633 cppflags_save=$CPPFLAGS
2634 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar77c19352012-06-13 19:19:41 +02002635 if test "$zOSUnix" = "yes"; then
2636 xmheader="Xm/Xm.h"
2637 else
2638 xmheader="Xm/Xm.h Xm/XpmP.h Xm/JoinSideT.h Xm/TraitP.h Xm/Manager.h
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02002639 Xm/UnhighlightT.h Xm/Notebook.h"
Bram Moolenaar77c19352012-06-13 19:19:41 +02002640 fi
2641 AC_CHECK_HEADERS($xmheader)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00002642
Bram Moolenaar77c19352012-06-13 19:19:41 +02002643 if test "x$ac_cv_header_Xm_XpmP_h" = "xyes"; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +00002644 dnl Solaris uses XpmAttributes_21, very annoying.
2645 AC_MSG_CHECKING([for XpmAttributes_21 in Xm/XpmP.h])
2646 AC_TRY_COMPILE([#include <Xm/XpmP.h>], [XpmAttributes_21 attr;],
2647 AC_MSG_RESULT(yes); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes_21),
2648 AC_MSG_RESULT(no); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
2649 )
2650 else
Bram Moolenaar57657d82006-04-21 22:12:41 +00002651 AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00002652 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002653 CPPFLAGS=$cppflags_save
2654fi
2655
2656if test "x$GUITYPE" = "xNONE" -a "$enable_xim" = "yes"; then
2657 AC_MSG_RESULT(no GUI selected; xim has been disabled)
2658 enable_xim="no"
2659fi
2660if test "x$GUITYPE" = "xNONE" -a "$enable_fontset" = "yes"; then
2661 AC_MSG_RESULT(no GUI selected; fontset has been disabled)
2662 enable_fontset="no"
2663fi
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002664if test "x$GUITYPE:$enable_fontset" = "xGTK:yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002665 AC_MSG_RESULT(GTK+ 2 GUI selected; fontset has been disabled)
2666 enable_fontset="no"
2667fi
2668
Bram Moolenaar071d4272004-06-13 20:20:40 +00002669if test -z "$SKIP_PHOTON"; then
2670 GUITYPE=PHOTONGUI
2671fi
2672
2673AC_SUBST(GUI_INC_LOC)
2674AC_SUBST(GUI_LIB_LOC)
2675AC_SUBST(GUITYPE)
2676AC_SUBST(GUI_X_LIBS)
2677
2678if test "$enable_workshop" = "yes" -a -n "$SKIP_MOTIF"; then
2679 AC_MSG_ERROR([cannot use workshop without Motif])
2680fi
2681
2682dnl defining FEAT_XIM and FEAT_XFONTSET is delayed, so that they can be disabled
2683if test "$enable_xim" = "yes"; then
2684 AC_DEFINE(FEAT_XIM)
2685fi
2686if test "$enable_fontset" = "yes"; then
2687 AC_DEFINE(FEAT_XFONTSET)
2688fi
2689
2690
2691dnl ---------------------------------------------------------------------------
2692dnl end of GUI-checking
2693dnl ---------------------------------------------------------------------------
2694
Bram Moolenaar693e40c2013-02-26 14:56:42 +01002695dnl Check for Cygwin, which needs an extra source file if not using X11
2696AC_MSG_CHECKING(for CYGWIN environment)
2697case `uname` in
2698 CYGWIN*) CYGWIN=yes; AC_MSG_RESULT(yes)
2699 AC_MSG_CHECKING(for CYGWIN clipboard support)
2700 if test "x$with_x" = "xno" ; then
2701 OS_EXTRA_SRC=winclip.c; OS_EXTRA_OBJ=objects/winclip.o
2702 AC_MSG_RESULT(yes)
2703 AC_DEFINE(FEAT_CYGWIN_WIN32_CLIPBOARD)
2704 else
2705 AC_MSG_RESULT(no - using X11)
2706 fi ;;
2707
2708 *) CYGWIN=no; AC_MSG_RESULT(no);;
2709esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00002710
2711dnl Only really enable hangul input when GUI and XFONTSET are available
2712if test "$enable_hangulinput" = "yes"; then
2713 if test "x$GUITYPE" = "xNONE"; then
2714 AC_MSG_RESULT(no GUI selected; hangul input has been disabled)
2715 enable_hangulinput=no
2716 else
2717 AC_DEFINE(FEAT_HANGULIN)
2718 HANGULIN_SRC=hangulin.c
2719 AC_SUBST(HANGULIN_SRC)
2720 HANGULIN_OBJ=objects/hangulin.o
2721 AC_SUBST(HANGULIN_OBJ)
2722 fi
2723fi
2724
2725dnl Checks for libraries and include files.
2726
Bram Moolenaar446cb832008-06-24 21:56:24 +00002727AC_CACHE_CHECK([whether toupper is broken], [vim_cv_toupper_broken],
2728 [
2729 AC_RUN_IFELSE([[
2730#include "confdefs.h"
2731#include <ctype.h>
2732#if STDC_HEADERS
2733# include <stdlib.h>
2734# include <stddef.h>
2735#endif
2736main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); }
2737 ]],[
2738 vim_cv_toupper_broken=yes
2739 ],[
2740 vim_cv_toupper_broken=no
2741 ],[
2742 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_toupper_broken')
2743 ])])
2744
2745if test "x$vim_cv_toupper_broken" = "xyes" ; then
2746 AC_DEFINE(BROKEN_TOUPPER)
2747fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002748
2749AC_MSG_CHECKING(whether __DATE__ and __TIME__ work)
Bram Moolenaar446cb832008-06-24 21:56:24 +00002750AC_TRY_COMPILE([#include <stdio.h>], [printf("(" __DATE__ " " __TIME__ ")");],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002751 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DATE_TIME),
2752 AC_MSG_RESULT(no))
2753
Bram Moolenaar0c094b92009-05-14 20:20:33 +00002754AC_MSG_CHECKING(whether __attribute__((unused)) is allowed)
2755AC_TRY_COMPILE([#include <stdio.h>], [int x __attribute__((unused));],
2756 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ATTRIBUTE_UNUSED),
2757 AC_MSG_RESULT(no))
2758
Bram Moolenaar071d4272004-06-13 20:20:40 +00002759dnl Checks for header files.
2760AC_CHECK_HEADER(elf.h, HAS_ELF=1)
2761dnl AC_CHECK_HEADER(dwarf.h, SVR4=1)
2762if test "$HAS_ELF" = 1; then
2763 AC_CHECK_LIB(elf, main)
2764fi
2765
2766AC_HEADER_DIRENT
2767
Bram Moolenaar071d4272004-06-13 20:20:40 +00002768dnl If sys/wait.h is not found it might still exist but not be POSIX
2769dnl compliant. In that case we define HAVE_UNION_WAIT (for NeXT)
2770if test $ac_cv_header_sys_wait_h = no; then
2771 AC_MSG_CHECKING([for sys/wait.h that defines union wait])
2772 AC_TRY_COMPILE([#include <sys/wait.h>],
2773 [union wait xx, yy; xx = yy],
2774 AC_MSG_RESULT(yes)
2775 AC_DEFINE(HAVE_SYS_WAIT_H)
2776 AC_DEFINE(HAVE_UNION_WAIT),
2777 AC_MSG_RESULT(no))
2778fi
2779
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02002780AC_CHECK_HEADERS(stdarg.h stdint.h stdlib.h string.h \
2781 sys/select.h sys/utsname.h termcap.h fcntl.h \
2782 sgtty.h sys/ioctl.h sys/time.h sys/types.h \
2783 termio.h iconv.h inttypes.h langinfo.h math.h \
2784 unistd.h stropts.h errno.h sys/resource.h \
2785 sys/systeminfo.h locale.h sys/stream.h termios.h \
2786 libc.h sys/statfs.h poll.h sys/poll.h pwd.h \
2787 utime.h sys/param.h libintl.h libgen.h \
2788 util/debug.h util/msg18n.h frame.h sys/acl.h \
2789 sys/access.h sys/sysinfo.h wchar.h wctype.h)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002790
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002791dnl sys/ptem.h depends on sys/stream.h on Solaris
2792AC_CHECK_HEADERS(sys/ptem.h, [], [],
2793[#if defined HAVE_SYS_STREAM_H
2794# include <sys/stream.h>
2795#endif])
2796
Bram Moolenaar32f31b12009-05-21 13:20:59 +00002797dnl sys/sysctl.h depends on sys/param.h on OpenBSD
2798AC_CHECK_HEADERS(sys/sysctl.h, [], [],
2799[#if defined HAVE_SYS_PARAM_H
2800# include <sys/param.h>
2801#endif])
2802
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002803
Bram Moolenaardf3267e2005-01-25 22:07:05 +00002804dnl pthread_np.h may exist but can only be used after including pthread.h
2805AC_MSG_CHECKING([for pthread_np.h])
2806AC_TRY_COMPILE([
2807#include <pthread.h>
2808#include <pthread_np.h>],
2809 [int i; i = 0;],
2810 AC_MSG_RESULT(yes)
2811 AC_DEFINE(HAVE_PTHREAD_NP_H),
2812 AC_MSG_RESULT(no))
2813
Bram Moolenaare344bea2005-09-01 20:46:49 +00002814AC_CHECK_HEADERS(strings.h)
Bram Moolenaar9372a112005-12-06 19:59:18 +00002815if test "x$MACOSX" = "xyes"; then
2816 dnl The strings.h file on OS/X contains a warning and nothing useful.
2817 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
2818else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002819
2820dnl Check if strings.h and string.h can both be included when defined.
2821AC_MSG_CHECKING([if strings.h can be included after string.h])
2822cppflags_save=$CPPFLAGS
2823CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2824AC_TRY_COMPILE([
2825#if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO)
2826# define _NO_PROTO /* like in os_unix.h, causes conflict for AIX (Winn) */
2827 /* but don't do it on AIX 5.1 (Uribarri) */
2828#endif
2829#ifdef HAVE_XM_XM_H
2830# include <Xm/Xm.h> /* This breaks it for HP-UX 11 (Squassabia) */
2831#endif
2832#ifdef HAVE_STRING_H
2833# include <string.h>
2834#endif
2835#if defined(HAVE_STRINGS_H)
2836# include <strings.h>
2837#endif
2838 ], [int i; i = 0;],
2839 AC_MSG_RESULT(yes),
2840 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
2841 AC_MSG_RESULT(no))
2842CPPFLAGS=$cppflags_save
Bram Moolenaar9372a112005-12-06 19:59:18 +00002843fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002844
2845dnl Checks for typedefs, structures, and compiler characteristics.
2846AC_PROG_GCC_TRADITIONAL
2847AC_C_CONST
Bram Moolenaar76243bd2009-03-02 01:47:02 +00002848AC_C_VOLATILE
Bram Moolenaar071d4272004-06-13 20:20:40 +00002849AC_TYPE_MODE_T
2850AC_TYPE_OFF_T
2851AC_TYPE_PID_T
2852AC_TYPE_SIZE_T
2853AC_TYPE_UID_T
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02002854AC_TYPE_UINT32_T
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02002855
Bram Moolenaar071d4272004-06-13 20:20:40 +00002856AC_HEADER_TIME
2857AC_CHECK_TYPE(ino_t, long)
2858AC_CHECK_TYPE(dev_t, unsigned)
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02002859AC_C_BIGENDIAN(,,,)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002860
2861AC_MSG_CHECKING(for rlim_t)
2862if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
2863 AC_MSG_RESULT([(cached) $ac_cv_type_rlim_t])
2864else
2865 AC_EGREP_CPP(dnl
2866changequote(<<,>>)dnl
2867<<(^|[^a-zA-Z_0-9])rlim_t[^a-zA-Z_0-9]>>dnl
2868changequote([,]),
2869 [
2870#include <sys/types.h>
2871#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00002872# include <stdlib.h>
2873# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00002874#endif
2875#ifdef HAVE_SYS_RESOURCE_H
Bram Moolenaar446cb832008-06-24 21:56:24 +00002876# include <sys/resource.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00002877#endif
2878 ], ac_cv_type_rlim_t=yes, ac_cv_type_rlim_t=no)
2879 AC_MSG_RESULT($ac_cv_type_rlim_t)
2880fi
2881if test $ac_cv_type_rlim_t = no; then
2882 cat >> confdefs.h <<\EOF
2883#define rlim_t unsigned long
2884EOF
2885fi
2886
2887AC_MSG_CHECKING(for stack_t)
2888if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then
2889 AC_MSG_RESULT([(cached) $ac_cv_type_stack_t])
2890else
2891 AC_EGREP_CPP(stack_t,
2892 [
2893#include <sys/types.h>
2894#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00002895# include <stdlib.h>
2896# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00002897#endif
2898#include <signal.h>
2899 ], ac_cv_type_stack_t=yes, ac_cv_type_stack_t=no)
2900 AC_MSG_RESULT($ac_cv_type_stack_t)
2901fi
2902if test $ac_cv_type_stack_t = no; then
2903 cat >> confdefs.h <<\EOF
2904#define stack_t struct sigaltstack
2905EOF
2906fi
2907
2908dnl BSDI uses ss_base while others use ss_sp for the stack pointer.
2909AC_MSG_CHECKING(whether stack_t has an ss_base field)
2910AC_TRY_COMPILE([
2911#include <sys/types.h>
2912#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00002913# include <stdlib.h>
2914# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00002915#endif
2916#include <signal.h>
2917#include "confdefs.h"
2918 ], [stack_t sigstk; sigstk.ss_base = 0; ],
2919 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SS_BASE),
2920 AC_MSG_RESULT(no))
2921
2922olibs="$LIBS"
2923AC_MSG_CHECKING(--with-tlib argument)
2924AC_ARG_WITH(tlib, [ --with-tlib=library terminal library to be used ],)
2925if test -n "$with_tlib"; then
2926 AC_MSG_RESULT($with_tlib)
2927 LIBS="$LIBS -l$with_tlib"
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00002928 AC_MSG_CHECKING(for linking with $with_tlib library)
2929 AC_TRY_LINK([], [], AC_MSG_RESULT(OK), AC_MSG_ERROR(FAILED))
2930 dnl Need to check for tgetent() below.
2931 olibs="$LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002932else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00002933 AC_MSG_RESULT([empty: automatic terminal library selection])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002934 dnl On HP-UX 10.10 termcap or termlib should be used instead of
2935 dnl curses, because curses is much slower.
Bram Moolenaar4e509b62011-02-09 17:42:57 +01002936 dnl Newer versions of ncurses are preferred over anything, except
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02002937 dnl when tinfo has been split off, it contains all we need.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002938 dnl Older versions of ncurses have bugs, get a new one!
2939 dnl Digital Unix (OSF1) should use curses (Ronald Schild).
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00002940 dnl On SCO Openserver should prefer termlib (Roger Cornelius).
Bram Moolenaar071d4272004-06-13 20:20:40 +00002941 case "`uname -s 2>/dev/null`" in
Bram Moolenaar4e509b62011-02-09 17:42:57 +01002942 OSF1|SCO_SV) tlibs="tinfo ncurses curses termlib termcap";;
2943 *) tlibs="tinfo ncurses termlib termcap curses";;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002944 esac
2945 for libname in $tlibs; do
2946 AC_CHECK_LIB(${libname}, tgetent,,)
2947 if test "x$olibs" != "x$LIBS"; then
2948 dnl It's possible that a library is found but it doesn't work
2949 dnl e.g., shared library that cannot be found
2950 dnl compile and run a test program to be sure
2951 AC_TRY_RUN([
2952#ifdef HAVE_TERMCAP_H
2953# include <termcap.h>
2954#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00002955#if STDC_HEADERS
2956# include <stdlib.h>
2957# include <stddef.h>
2958#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002959main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }],
2960 res="OK", res="FAIL", res="FAIL")
2961 if test "$res" = "OK"; then
2962 break
2963 fi
2964 AC_MSG_RESULT($libname library is not usable)
2965 LIBS="$olibs"
2966 fi
2967 done
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00002968 if test "x$olibs" = "x$LIBS"; then
2969 AC_MSG_RESULT(no terminal library found)
2970 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002971fi
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00002972
2973if test "x$olibs" = "x$LIBS"; then
2974 AC_MSG_CHECKING([for tgetent()])
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00002975 AC_TRY_LINK([],
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00002976 [char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");],
2977 AC_MSG_RESULT(yes),
2978 AC_MSG_ERROR([NOT FOUND!
2979 You need to install a terminal library; for example ncurses.
2980 Or specify the name of the library with --with-tlib.]))
2981fi
2982
Bram Moolenaar446cb832008-06-24 21:56:24 +00002983AC_CACHE_CHECK([whether we talk terminfo], [vim_cv_terminfo],
2984 [
2985 AC_RUN_IFELSE([[
2986#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002987#ifdef HAVE_TERMCAP_H
2988# include <termcap.h>
2989#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00002990#ifdef HAVE_STRING_H
2991# include <string.h>
2992#endif
2993#if STDC_HEADERS
2994# include <stdlib.h>
2995# include <stddef.h>
2996#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002997main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00002998{char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }
2999 ]],[
3000 vim_cv_terminfo=no
3001 ],[
3002 vim_cv_terminfo=yes
3003 ],[
3004 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_terminfo')
3005 ])
3006 ])
3007
3008if test "x$vim_cv_terminfo" = "xyes" ; then
3009 AC_DEFINE(TERMINFO)
3010fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003011
3012if test "x$olibs" != "x$LIBS"; then
Bram Moolenaar446cb832008-06-24 21:56:24 +00003013 AC_CACHE_CHECK([what tgetent() returns for an unknown terminal], [vim_cv_tgent],
3014 [
3015 AC_RUN_IFELSE([[
3016#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003017#ifdef HAVE_TERMCAP_H
3018# include <termcap.h>
3019#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003020#if STDC_HEADERS
3021# include <stdlib.h>
3022# include <stddef.h>
3023#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003024main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003025{char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
3026 ]],[
3027 vim_cv_tgent=zero
3028 ],[
3029 vim_cv_tgent=non-zero
3030 ],[
3031 AC_MSG_ERROR(failed to compile test program.)
3032 ])
3033 ])
3034
3035 if test "x$vim_cv_tgent" = "xzero" ; then
3036 AC_DEFINE(TGETENT_ZERO_ERR, 0)
3037 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003038fi
3039
3040AC_MSG_CHECKING(whether termcap.h contains ospeed)
3041AC_TRY_LINK([
3042#ifdef HAVE_TERMCAP_H
3043# include <termcap.h>
3044#endif
3045 ], [ospeed = 20000],
3046 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED),
3047 [AC_MSG_RESULT(no)
3048 AC_MSG_CHECKING(whether ospeed can be extern)
3049 AC_TRY_LINK([
3050#ifdef HAVE_TERMCAP_H
3051# include <termcap.h>
3052#endif
3053extern short ospeed;
3054 ], [ospeed = 20000],
3055 AC_MSG_RESULT(yes); AC_DEFINE(OSPEED_EXTERN),
3056 AC_MSG_RESULT(no))]
3057 )
3058
3059AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC])
3060AC_TRY_LINK([
3061#ifdef HAVE_TERMCAP_H
3062# include <termcap.h>
3063#endif
3064 ], [if (UP == 0 && BC == 0) PC = 1],
3065 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UP_BC_PC),
3066 [AC_MSG_RESULT(no)
3067 AC_MSG_CHECKING([whether UP, BC and PC can be extern])
3068 AC_TRY_LINK([
3069#ifdef HAVE_TERMCAP_H
3070# include <termcap.h>
3071#endif
3072extern char *UP, *BC, PC;
3073 ], [if (UP == 0 && BC == 0) PC = 1],
3074 AC_MSG_RESULT(yes); AC_DEFINE(UP_BC_PC_EXTERN),
3075 AC_MSG_RESULT(no))]
3076 )
3077
3078AC_MSG_CHECKING(whether tputs() uses outfuntype)
3079AC_TRY_COMPILE([
3080#ifdef HAVE_TERMCAP_H
3081# include <termcap.h>
3082#endif
3083 ], [extern int xx(); tputs("test", 1, (outfuntype)xx)],
3084 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OUTFUNTYPE),
3085 AC_MSG_RESULT(no))
3086
3087dnl On some SCO machines sys/select redefines struct timeval
3088AC_MSG_CHECKING([whether sys/select.h and sys/time.h may both be included])
3089AC_TRY_COMPILE([
3090#include <sys/types.h>
3091#include <sys/time.h>
3092#include <sys/select.h>], ,
3093 AC_MSG_RESULT(yes)
3094 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME),
3095 AC_MSG_RESULT(no))
3096
3097dnl AC_DECL_SYS_SIGLIST
3098
3099dnl Checks for pty.c (copied from screen) ==========================
3100AC_MSG_CHECKING(for /dev/ptc)
3101if test -r /dev/ptc; then
3102 AC_DEFINE(HAVE_DEV_PTC)
3103 AC_MSG_RESULT(yes)
3104else
3105 AC_MSG_RESULT(no)
3106fi
3107
3108AC_MSG_CHECKING(for SVR4 ptys)
3109if test -c /dev/ptmx ; then
3110 AC_TRY_LINK([], [ptsname(0);grantpt(0);unlockpt(0);],
3111 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SVR4_PTYS),
3112 AC_MSG_RESULT(no))
3113else
3114 AC_MSG_RESULT(no)
3115fi
3116
3117AC_MSG_CHECKING(for ptyranges)
3118if test -d /dev/ptym ; then
3119 pdir='/dev/ptym'
3120else
3121 pdir='/dev'
3122fi
3123dnl SCO uses ptyp%d
3124AC_EGREP_CPP(yes,
3125[#ifdef M_UNIX
3126 yes;
3127#endif
3128 ], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
3129dnl if test -c /dev/ptyp19; then
3130dnl ptys=`echo /dev/ptyp??`
3131dnl else
3132dnl ptys=`echo $pdir/pty??`
3133dnl fi
3134if test "$ptys" != "$pdir/pty??" ; then
3135 p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
3136 p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'`
3137 AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
3138 AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
3139 AC_MSG_RESULT([$p0 / $p1])
3140else
3141 AC_MSG_RESULT([don't know])
3142fi
3143
3144dnl **** pty mode/group handling ****
3145dnl
3146dnl support provided by Luke Mewburn <lm@rmit.edu.au>, 931222
Bram Moolenaar071d4272004-06-13 20:20:40 +00003147rm -f conftest_grp
Bram Moolenaar446cb832008-06-24 21:56:24 +00003148AC_CACHE_CHECK([default tty permissions/group], [vim_cv_tty_group],
3149 [
3150 AC_RUN_IFELSE([[
3151#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003152#include <sys/types.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003153#if STDC_HEADERS
3154# include <stdlib.h>
3155# include <stddef.h>
3156#endif
3157#ifdef HAVE_UNISTD_H
3158#include <unistd.h>
3159#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003160#include <sys/stat.h>
3161#include <stdio.h>
3162main()
3163{
3164 struct stat sb;
3165 char *x,*ttyname();
3166 int om, m;
3167 FILE *fp;
3168
3169 if (!(x = ttyname(0))) exit(1);
3170 if (stat(x, &sb)) exit(1);
3171 om = sb.st_mode;
3172 if (om & 002) exit(0);
3173 m = system("mesg y");
3174 if (m == -1 || m == 127) exit(1);
3175 if (stat(x, &sb)) exit(1);
3176 m = sb.st_mode;
3177 if (chmod(x, om)) exit(1);
3178 if (m & 002) exit(0);
3179 if (sb.st_gid == getgid()) exit(1);
3180 if (!(fp=fopen("conftest_grp", "w")))
3181 exit(1);
3182 fprintf(fp, "%d\n", sb.st_gid);
3183 fclose(fp);
3184 exit(0);
3185}
Bram Moolenaar446cb832008-06-24 21:56:24 +00003186 ]],[
3187 if test -f conftest_grp; then
3188 vim_cv_tty_group=`cat conftest_grp`
3189 if test "x$vim_cv_tty_mode" = "x" ; then
3190 vim_cv_tty_mode=0620
3191 fi
3192 AC_MSG_RESULT([pty mode: $vim_cv_tty_mode, group: $vim_cv_tty_group])
3193 else
3194 vim_cv_tty_group=world
Bram Moolenaar72951072009-12-02 16:58:33 +00003195 AC_MSG_RESULT([ptys are world accessible])
Bram Moolenaar446cb832008-06-24 21:56:24 +00003196 fi
3197 ],[
3198 vim_cv_tty_group=world
Bram Moolenaar72951072009-12-02 16:58:33 +00003199 AC_MSG_RESULT([can't determine - assume ptys are world accessible])
Bram Moolenaar446cb832008-06-24 21:56:24 +00003200 ],[
3201 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_tty_group' and 'vim_cv_tty_mode')
3202 ])
3203 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003204rm -f conftest_grp
3205
Bram Moolenaar446cb832008-06-24 21:56:24 +00003206if test "x$vim_cv_tty_group" != "xworld" ; then
3207 AC_DEFINE_UNQUOTED(PTYGROUP,$vim_cv_tty_group)
3208 if test "x$vim_cv_tty_mode" = "x" ; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02003209 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 +00003210 else
3211 AC_DEFINE(PTYMODE, 0620)
3212 fi
3213fi
3214
Bram Moolenaar071d4272004-06-13 20:20:40 +00003215dnl Checks for library functions. ===================================
3216
3217AC_TYPE_SIGNAL
3218
3219dnl find out what to use at the end of a signal function
3220if test $ac_cv_type_signal = void; then
3221 AC_DEFINE(SIGRETURN, [return])
3222else
3223 AC_DEFINE(SIGRETURN, [return 0])
3224fi
3225
3226dnl check if struct sigcontext is defined (used for SGI only)
3227AC_MSG_CHECKING(for struct sigcontext)
3228AC_TRY_COMPILE([
3229#include <signal.h>
3230test_sig()
3231{
3232 struct sigcontext *scont;
3233 scont = (struct sigcontext *)0;
3234 return 1;
3235} ], ,
3236 AC_MSG_RESULT(yes)
3237 AC_DEFINE(HAVE_SIGCONTEXT),
3238 AC_MSG_RESULT(no))
3239
3240dnl tricky stuff: try to find out if getcwd() is implemented with
3241dnl system("sh -c pwd")
Bram Moolenaar446cb832008-06-24 21:56:24 +00003242AC_CACHE_CHECK([getcwd implementation is broken], [vim_cv_getcwd_broken],
3243 [
3244 AC_RUN_IFELSE([[
3245#include "confdefs.h"
3246#ifdef HAVE_UNISTD_H
3247#include <unistd.h>
3248#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003249char *dagger[] = { "IFS=pwd", 0 };
3250main()
3251{
3252 char buffer[500];
3253 extern char **environ;
3254 environ = dagger;
3255 return getcwd(buffer, 500) ? 0 : 1;
Bram Moolenaar446cb832008-06-24 21:56:24 +00003256}
3257 ]],[
3258 vim_cv_getcwd_broken=no
3259 ],[
3260 vim_cv_getcwd_broken=yes
3261 ],[
3262 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_getcwd_broken')
3263 ])
3264 ])
3265
3266if test "x$vim_cv_getcwd_broken" = "xyes" ; then
3267 AC_DEFINE(BAD_GETCWD)
3268fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003269
Bram Moolenaar25153e12010-02-24 14:47:08 +01003270dnl Check for functions in one big call, to reduce the size of configure.
3271dnl Can only be used for functions that do not require any include.
3272AC_CHECK_FUNCS(bcmp fchdir fchown fsync getcwd getpseudotty \
Bram Moolenaar24305862012-08-15 14:05:05 +02003273 getpwent getpwnam getpwuid getrlimit gettimeofday getwd lstat memcmp \
Bram Moolenaareaf03392009-11-17 11:08:52 +00003274 memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
Bram Moolenaar071d4272004-06-13 20:20:40 +00003275 setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
Bram Moolenaar051b7822005-05-19 21:00:46 +00003276 sigvec strcasecmp strerror strftime stricmp strncasecmp \
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00003277 strnicmp strpbrk strtol tgetent towlower towupper iswupper \
3278 usleep utime utimes)
Bram Moolenaar25153e12010-02-24 14:47:08 +01003279AC_FUNC_FSEEKO
Bram Moolenaar071d4272004-06-13 20:20:40 +00003280
Bram Moolenaar317fd3a2010-05-07 16:05:55 +02003281dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when
3282dnl appropriate, so that off_t is 64 bits when needed.
3283AC_SYS_LARGEFILE
3284
Bram Moolenaar071d4272004-06-13 20:20:40 +00003285dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible
3286AC_MSG_CHECKING(for st_blksize)
3287AC_TRY_COMPILE(
3288[#include <sys/types.h>
3289#include <sys/stat.h>],
3290[ struct stat st;
3291 int n;
3292
3293 stat("/", &st);
3294 n = (int)st.st_blksize;],
3295 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ST_BLKSIZE),
3296 AC_MSG_RESULT(no))
3297
Bram Moolenaar446cb832008-06-24 21:56:24 +00003298AC_CACHE_CHECK([whether stat() ignores a trailing slash], [vim_cv_stat_ignores_slash],
3299 [
3300 AC_RUN_IFELSE([[
3301#include "confdefs.h"
3302#if STDC_HEADERS
3303# include <stdlib.h>
3304# include <stddef.h>
3305#endif
3306#include <sys/types.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003307#include <sys/stat.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003308main() {struct stat st; exit(stat("configure/", &st) != 0); }
3309 ]],[
3310 vim_cv_stat_ignores_slash=yes
3311 ],[
3312 vim_cv_stat_ignores_slash=no
3313 ],[
3314 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_stat_ignores_slash')
3315 ])
3316 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003317
Bram Moolenaar446cb832008-06-24 21:56:24 +00003318if test "x$vim_cv_stat_ignores_slash" = "xyes" ; then
3319 AC_DEFINE(STAT_IGNORES_SLASH)
3320fi
3321
Bram Moolenaar071d4272004-06-13 20:20:40 +00003322dnl Link with iconv for charset translation, if not found without library.
3323dnl check for iconv() requires including iconv.h
3324dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
3325dnl has been installed.
3326AC_MSG_CHECKING(for iconv_open())
3327save_LIBS="$LIBS"
3328LIBS="$LIBS -liconv"
3329AC_TRY_LINK([
3330#ifdef HAVE_ICONV_H
3331# include <iconv.h>
3332#endif
3333 ], [iconv_open("fr", "to");],
3334 AC_MSG_RESULT(yes; with -liconv); AC_DEFINE(HAVE_ICONV),
3335 LIBS="$save_LIBS"
3336 AC_TRY_LINK([
3337#ifdef HAVE_ICONV_H
3338# include <iconv.h>
3339#endif
3340 ], [iconv_open("fr", "to");],
3341 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ICONV),
3342 AC_MSG_RESULT(no)))
3343
3344
3345AC_MSG_CHECKING(for nl_langinfo(CODESET))
3346AC_TRY_LINK([
3347#ifdef HAVE_LANGINFO_H
3348# include <langinfo.h>
3349#endif
3350], [char *cs = nl_langinfo(CODESET);],
3351 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET),
3352 AC_MSG_RESULT(no))
3353
Bram Moolenaar446cb832008-06-24 21:56:24 +00003354dnl Need various functions for floating point support. Only enable
3355dnl floating point when they are all present.
3356AC_CHECK_LIB(m, strtod)
3357AC_MSG_CHECKING([for strtod() and other floating point functions])
3358AC_TRY_LINK([
3359#ifdef HAVE_MATH_H
3360# include <math.h>
3361#endif
3362#if STDC_HEADERS
3363# include <stdlib.h>
3364# include <stddef.h>
3365#endif
3366], [char *s; double d;
3367 d = strtod("1.1", &s);
3368 d = fabs(1.11);
3369 d = ceil(1.11);
3370 d = floor(1.11);
3371 d = log10(1.11);
3372 d = pow(1.11, 2.22);
3373 d = sqrt(1.11);
3374 d = sin(1.11);
3375 d = cos(1.11);
3376 d = atan(1.11);
3377 ],
3378 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT_FUNCS),
3379 AC_MSG_RESULT(no))
3380
Bram Moolenaar071d4272004-06-13 20:20:40 +00003381dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI
3382dnl when -lacl works, also try to use -lattr (required for Debian).
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003383dnl On Solaris, use the acl_get/set functions in libsec, if present.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003384AC_MSG_CHECKING(--disable-acl argument)
3385AC_ARG_ENABLE(acl,
3386 [ --disable-acl Don't check for ACL support.],
3387 , [enable_acl="yes"])
3388if test "$enable_acl" = "yes"; then
3389AC_MSG_RESULT(no)
3390AC_CHECK_LIB(posix1e, acl_get_file, [LIBS="$LIBS -lposix1e"],
3391 AC_CHECK_LIB(acl, acl_get_file, [LIBS="$LIBS -lacl"
3392 AC_CHECK_LIB(attr, fgetxattr, LIBS="$LIBS -lattr",,)],,),)
3393
3394AC_MSG_CHECKING(for POSIX ACL support)
3395AC_TRY_LINK([
3396#include <sys/types.h>
3397#ifdef HAVE_SYS_ACL_H
3398# include <sys/acl.h>
3399#endif
3400acl_t acl;], [acl = acl_get_file("foo", ACL_TYPE_ACCESS);
3401 acl_set_file("foo", ACL_TYPE_ACCESS, acl);
3402 acl_free(acl);],
3403 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_ACL),
3404 AC_MSG_RESULT(no))
3405
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003406AC_CHECK_LIB(sec, acl_get, [LIBS="$LIBS -lsec"; AC_DEFINE(HAVE_SOLARIS_ZFS_ACL)],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003407AC_MSG_CHECKING(for Solaris ACL support)
3408AC_TRY_LINK([
3409#ifdef HAVE_SYS_ACL_H
3410# include <sys/acl.h>
3411#endif], [acl("foo", GETACLCNT, 0, NULL);
3412 ],
3413 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOLARIS_ACL),
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003414 AC_MSG_RESULT(no)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003415
3416AC_MSG_CHECKING(for AIX ACL support)
3417AC_TRY_LINK([
Bram Moolenaar446cb832008-06-24 21:56:24 +00003418#if STDC_HEADERS
3419# include <stdlib.h>
3420# include <stddef.h>
3421#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003422#ifdef HAVE_SYS_ACL_H
3423# include <sys/acl.h>
3424#endif
3425#ifdef HAVE_SYS_ACCESS_H
3426# include <sys/access.h>
3427#endif
3428#define _ALL_SOURCE
3429
3430#include <sys/stat.h>
3431
3432int aclsize;
3433struct acl *aclent;], [aclsize = sizeof(struct acl);
3434 aclent = (void *)malloc(aclsize);
3435 statacl("foo", STX_NORMAL, aclent, aclsize);
3436 ],
3437 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_AIX_ACL),
3438 AC_MSG_RESULT(no))
3439else
3440 AC_MSG_RESULT(yes)
3441fi
3442
3443AC_MSG_CHECKING(--disable-gpm argument)
3444AC_ARG_ENABLE(gpm,
3445 [ --disable-gpm Don't use gpm (Linux mouse daemon).], ,
3446 [enable_gpm="yes"])
3447
3448if test "$enable_gpm" = "yes"; then
3449 AC_MSG_RESULT(no)
3450 dnl Checking if gpm support can be compiled
3451 AC_CACHE_CHECK([for gpm], vi_cv_have_gpm,
3452 [olibs="$LIBS" ; LIBS="-lgpm"]
3453 AC_TRY_LINK(
3454 [#include <gpm.h>
3455 #include <linux/keyboard.h>],
3456 [Gpm_GetLibVersion(NULL);],
3457 dnl Configure defines HAVE_GPM, if it is defined feature.h defines
3458 dnl FEAT_MOUSE_GPM if mouse support is included
3459 [vi_cv_have_gpm=yes],
3460 [vi_cv_have_gpm=no])
3461 [LIBS="$olibs"]
3462 )
3463 if test $vi_cv_have_gpm = yes; then
3464 LIBS="$LIBS -lgpm"
3465 AC_DEFINE(HAVE_GPM)
3466 fi
3467else
3468 AC_MSG_RESULT(yes)
3469fi
3470
Bram Moolenaar446cb832008-06-24 21:56:24 +00003471AC_MSG_CHECKING(--disable-sysmouse argument)
3472AC_ARG_ENABLE(sysmouse,
3473 [ --disable-sysmouse Don't use sysmouse (mouse in *BSD console).], ,
3474 [enable_sysmouse="yes"])
3475
3476if test "$enable_sysmouse" = "yes"; then
3477 AC_MSG_RESULT(no)
3478 dnl Checking if sysmouse support can be compiled
3479 dnl Configure defines HAVE_SYSMOUSE, if it is defined feature.h
3480 dnl defines FEAT_SYSMOUSE if mouse support is included
3481 AC_CACHE_CHECK([for sysmouse], vi_cv_have_sysmouse,
3482 AC_TRY_LINK(
3483 [#include <sys/consio.h>
3484 #include <signal.h>
3485 #include <sys/fbio.h>],
3486 [struct mouse_info mouse;
3487 mouse.operation = MOUSE_MODE;
3488 mouse.operation = MOUSE_SHOW;
3489 mouse.u.mode.mode = 0;
3490 mouse.u.mode.signal = SIGUSR2;],
3491 [vi_cv_have_sysmouse=yes],
3492 [vi_cv_have_sysmouse=no])
3493 )
3494 if test $vi_cv_have_sysmouse = yes; then
3495 AC_DEFINE(HAVE_SYSMOUSE)
3496 fi
3497else
3498 AC_MSG_RESULT(yes)
3499fi
3500
Bram Moolenaarf05da212009-11-17 16:13:15 +00003501dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
3502AC_MSG_CHECKING(for FD_CLOEXEC)
3503AC_TRY_COMPILE(
3504[#if HAVE_FCNTL_H
3505# include <fcntl.h>
3506#endif],
3507[ int flag = FD_CLOEXEC;],
3508 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
3509 AC_MSG_RESULT(not usable))
3510
Bram Moolenaar071d4272004-06-13 20:20:40 +00003511dnl rename needs to be checked separately to work on Nextstep with cc
3512AC_MSG_CHECKING(for rename)
3513AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
3514 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
3515 AC_MSG_RESULT(no))
3516
3517dnl sysctl() may exist but not the arguments we use
3518AC_MSG_CHECKING(for sysctl)
3519AC_TRY_COMPILE(
3520[#include <sys/types.h>
3521#include <sys/sysctl.h>],
3522[ int mib[2], r;
3523 size_t len;
3524
3525 mib[0] = CTL_HW;
3526 mib[1] = HW_USERMEM;
3527 len = sizeof(r);
3528 (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
3529 ],
3530 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL),
3531 AC_MSG_RESULT(not usable))
3532
3533dnl sysinfo() may exist but not be Linux compatible
3534AC_MSG_CHECKING(for sysinfo)
3535AC_TRY_COMPILE(
3536[#include <sys/types.h>
3537#include <sys/sysinfo.h>],
3538[ struct sysinfo sinfo;
3539 int t;
3540
3541 (void)sysinfo(&sinfo);
3542 t = sinfo.totalram;
3543 ],
3544 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
3545 AC_MSG_RESULT(not usable))
3546
Bram Moolenaar914572a2007-05-01 11:37:47 +00003547dnl struct sysinfo may have the mem_unit field or not
3548AC_MSG_CHECKING(for sysinfo.mem_unit)
3549AC_TRY_COMPILE(
3550[#include <sys/types.h>
3551#include <sys/sysinfo.h>],
3552[ struct sysinfo sinfo;
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02003553 sinfo.mem_unit = 1;
Bram Moolenaar914572a2007-05-01 11:37:47 +00003554 ],
3555 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_MEM_UNIT),
3556 AC_MSG_RESULT(no))
3557
Bram Moolenaar071d4272004-06-13 20:20:40 +00003558dnl sysconf() may exist but not support what we want to use
3559AC_MSG_CHECKING(for sysconf)
3560AC_TRY_COMPILE(
3561[#include <unistd.h>],
3562[ (void)sysconf(_SC_PAGESIZE);
3563 (void)sysconf(_SC_PHYS_PAGES);
3564 ],
3565 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
3566 AC_MSG_RESULT(not usable))
3567
Bram Moolenaar914703b2010-05-31 21:59:46 +02003568AC_CHECK_SIZEOF([int])
3569AC_CHECK_SIZEOF([long])
3570AC_CHECK_SIZEOF([time_t])
3571AC_CHECK_SIZEOF([off_t])
Bram Moolenaar644fdff2010-05-30 13:26:21 +02003572
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003573dnl Make sure that uint32_t is really 32 bits unsigned.
3574AC_MSG_CHECKING([uint32_t is 32 bits])
3575AC_TRY_RUN([
3576#ifdef HAVE_STDINT_H
3577# include <stdint.h>
3578#endif
3579#ifdef HAVE_INTTYPES_H
3580# include <inttypes.h>
3581#endif
3582main() {
3583 uint32_t nr1 = (uint32_t)-1;
3584 uint32_t nr2 = (uint32_t)0xffffffffUL;
3585 if (sizeof(uint32_t) != 4 || nr1 != 0xffffffffUL || nr2 + 1 != 0) exit(1);
3586 exit(0);
3587}],
3588AC_MSG_RESULT(ok),
3589AC_MSG_ERROR([WRONG! uint32_t not defined correctly.]),
Bram Moolenaar323cb952011-12-14 19:22:34 +01003590AC_MSG_WARN([cannot check uint32_t when cross-compiling.]))
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003591
Bram Moolenaar446cb832008-06-24 21:56:24 +00003592dnl Check for memmove() before bcopy(), makes memmove() be used when both are
3593dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
3594
Bram Moolenaar071d4272004-06-13 20:20:40 +00003595[bcopy_test_prog='
Bram Moolenaar446cb832008-06-24 21:56:24 +00003596#include "confdefs.h"
3597#ifdef HAVE_STRING_H
3598# include <string.h>
3599#endif
3600#if STDC_HEADERS
3601# include <stdlib.h>
3602# include <stddef.h>
3603#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003604main() {
3605 char buf[10];
3606 strcpy(buf, "abcdefghi");
3607 mch_memmove(buf, buf + 2, 3);
3608 if (strncmp(buf, "ababcf", 6))
3609 exit(1);
3610 strcpy(buf, "abcdefghi");
3611 mch_memmove(buf + 2, buf, 3);
3612 if (strncmp(buf, "cdedef", 6))
3613 exit(1);
3614 exit(0); /* libc version works properly. */
3615}']
3616
Bram Moolenaar446cb832008-06-24 21:56:24 +00003617AC_CACHE_CHECK([whether memmove handles overlaps],[vim_cv_memmove_handles_overlap],
3618 [
3619 AC_RUN_IFELSE([[#define mch_memmove(s,d,l) memmove(d,s,l) $bcopy_test_prog]],
3620 [
3621 vim_cv_memmove_handles_overlap=yes
3622 ],[
3623 vim_cv_memmove_handles_overlap=no
3624 ],[
3625 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memmove_handles_overlap')
3626 ])
3627 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003628
Bram Moolenaar446cb832008-06-24 21:56:24 +00003629if test "x$vim_cv_memmove_handles_overlap" = "xyes" ; then
3630 AC_DEFINE(USEMEMMOVE)
3631else
3632 AC_CACHE_CHECK([whether bcopy handles overlaps],[vim_cv_bcopy_handles_overlap],
3633 [
3634 AC_RUN_IFELSE([[#define mch_bcopy(s,d,l) bcopy(d,s,l) $bcopy_test_prog]],
3635 [
3636 vim_cv_bcopy_handles_overlap=yes
3637 ],[
3638 vim_cv_bcopy_handles_overlap=no
3639 ],[
3640 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_bcopy_handles_overlap')
3641 ])
3642 ])
3643
3644 if test "x$vim_cv_bcopy_handles_overlap" = "xyes" ; then
3645 AC_DEFINE(USEBCOPY)
3646 else
3647 AC_CACHE_CHECK([whether memcpy handles overlaps],[vim_cv_memcpy_handles_overlap],
3648 [
3649 AC_RUN_IFELSE([[#define mch_memcpy(s,d,l) memcpy(d,s,l) $bcopy_test_prog]],
3650 [
3651 vim_cv_memcpy_handles_overlap=yes
3652 ],[
3653 vim_cv_memcpy_handles_overlap=no
3654 ],[
3655 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memcpy_handles_overlap')
3656 ])
3657 ])
3658
3659 if test "x$vim_cv_memcpy_handles_overlap" = "xyes" ; then
3660 AC_DEFINE(USEMEMCPY)
3661 fi
3662 fi
3663fi
3664
Bram Moolenaar071d4272004-06-13 20:20:40 +00003665
3666dnl Check for multibyte locale functions
3667dnl Find out if _Xsetlocale() is supported by libX11.
3668dnl Check if X_LOCALE should be defined.
3669
3670if test "$enable_multibyte" = "yes"; then
3671 cflags_save=$CFLAGS
3672 ldflags_save=$LDFLAGS
Bram Moolenaar94ba1ce2009-04-22 15:53:09 +00003673 if test "x$x_includes" != "xNONE" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003674 CFLAGS="$CFLAGS -I$x_includes"
3675 LDFLAGS="$X_LIBS $LDFLAGS -lX11"
3676 AC_MSG_CHECKING(whether X_LOCALE needed)
3677 AC_TRY_COMPILE([#include <X11/Xlocale.h>],,
3678 AC_TRY_LINK_FUNC([_Xsetlocale], [AC_MSG_RESULT(yes)
3679 AC_DEFINE(X_LOCALE)], AC_MSG_RESULT(no)),
3680 AC_MSG_RESULT(no))
3681 fi
3682 CFLAGS=$cflags_save
3683 LDFLAGS=$ldflags_save
3684fi
3685
3686dnl Link with xpg4, it is said to make Korean locale working
3687AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,)
3688
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00003689dnl Check how we can run ctags. Default to "ctags" when nothing works.
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02003690dnl Use --version to detect Exuberant ctags (preferred)
Bram Moolenaarb21e5842006-04-16 18:30:08 +00003691dnl Add --fields=+S to get function signatures for omni completion.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003692dnl -t for typedefs (many ctags have this)
3693dnl -s for static functions (Elvis ctags only?)
3694dnl -v for variables. Dangerous, most ctags take this for 'vgrind style'.
3695dnl -i+m to test for older Exuberant ctags
3696AC_MSG_CHECKING(how to create tags)
3697test -f tags && mv tags tags.save
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02003698if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaarb21e5842006-04-16 18:30:08 +00003699 TAGPRG="ctags -I INIT+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02003700elif (eval exctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
3701 TAGPRG="exctags -I INIT+ --fields=+S"
3702elif (eval exuberant-ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
3703 TAGPRG="exuberant-ctags -I INIT+ --fields=+S"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003704else
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00003705 TAGPRG="ctags"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003706 (eval etags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags"
3707 (eval etags -c /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags -c"
3708 (eval ctags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags"
3709 (eval ctags -t /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -t"
3710 (eval ctags -ts /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -ts"
3711 (eval ctags -tvs /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -tvs"
3712 (eval ctags -i+m /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -i+m"
3713fi
3714test -f tags.save && mv tags.save tags
3715AC_MSG_RESULT($TAGPRG) AC_SUBST(TAGPRG)
3716
3717dnl Check how we can run man with a section number
3718AC_MSG_CHECKING(how to run man with a section nr)
3719MANDEF="man"
Bram Moolenaar8b131502008-02-13 09:28:19 +00003720(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 +00003721AC_MSG_RESULT($MANDEF)
3722if test "$MANDEF" = "man -s"; then
3723 AC_DEFINE(USEMAN_S)
3724fi
3725
3726dnl Check if gettext() is working and if it needs -lintl
3727AC_MSG_CHECKING(--disable-nls argument)
3728AC_ARG_ENABLE(nls,
3729 [ --disable-nls Don't support NLS (gettext()).], ,
3730 [enable_nls="yes"])
3731
3732if test "$enable_nls" = "yes"; then
3733 AC_MSG_RESULT(no)
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00003734
3735 INSTALL_LANGS=install-languages
3736 AC_SUBST(INSTALL_LANGS)
3737 INSTALL_TOOL_LANGS=install-tool-languages
3738 AC_SUBST(INSTALL_TOOL_LANGS)
3739
Bram Moolenaar071d4272004-06-13 20:20:40 +00003740 AC_CHECK_PROG(MSGFMT, msgfmt, msgfmt, )
3741 AC_MSG_CHECKING([for NLS])
3742 if test -f po/Makefile; then
3743 have_gettext="no"
3744 if test -n "$MSGFMT"; then
3745 AC_TRY_LINK(
3746 [#include <libintl.h>],
3747 [gettext("Test");],
3748 AC_MSG_RESULT([gettext() works]); have_gettext="yes",
3749 olibs=$LIBS
3750 LIBS="$LIBS -lintl"
3751 AC_TRY_LINK(
3752 [#include <libintl.h>],
3753 [gettext("Test");],
3754 AC_MSG_RESULT([gettext() works with -lintl]); have_gettext="yes",
3755 AC_MSG_RESULT([gettext() doesn't work]);
3756 LIBS=$olibs))
3757 else
3758 AC_MSG_RESULT([msgfmt not found - disabled]);
3759 fi
3760 if test $have_gettext = "yes"; then
3761 AC_DEFINE(HAVE_GETTEXT)
3762 MAKEMO=yes
3763 AC_SUBST(MAKEMO)
3764 dnl this was added in GNU gettext 0.10.36
3765 AC_CHECK_FUNCS(bind_textdomain_codeset)
3766 dnl _nl_msg_cat_cntr is required for GNU gettext
3767 AC_MSG_CHECKING([for _nl_msg_cat_cntr])
3768 AC_TRY_LINK(
3769 [#include <libintl.h>
3770 extern int _nl_msg_cat_cntr;],
3771 [++_nl_msg_cat_cntr;],
3772 AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_NL_MSG_CAT_CNTR),
3773 AC_MSG_RESULT([no]))
3774 fi
3775 else
3776 AC_MSG_RESULT([no "po/Makefile" - disabled]);
3777 fi
3778else
3779 AC_MSG_RESULT(yes)
3780fi
3781
3782dnl Check for dynamic linking loader
3783AC_CHECK_HEADER(dlfcn.h, DLL=dlfcn.h, [AC_CHECK_HEADER(dl.h, DLL=dl.h)])
3784if test x${DLL} = xdlfcn.h; then
3785 AC_DEFINE(HAVE_DLFCN_H, 1, [ Define if we have dlfcn.h. ])
3786 AC_MSG_CHECKING([for dlopen()])
3787 AC_TRY_LINK(,[
3788 extern void* dlopen();
3789 dlopen();
3790 ],
3791 AC_MSG_RESULT(yes);
3792 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
3793 AC_MSG_RESULT(no);
3794 AC_MSG_CHECKING([for dlopen() in -ldl])
3795 olibs=$LIBS
3796 LIBS="$LIBS -ldl"
3797 AC_TRY_LINK(,[
3798 extern void* dlopen();
3799 dlopen();
3800 ],
3801 AC_MSG_RESULT(yes);
3802 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
3803 AC_MSG_RESULT(no);
3804 LIBS=$olibs))
3805 dnl ReliantUNIX has dlopen() in libc but everything else in libdl
3806 dnl ick :-)
3807 AC_MSG_CHECKING([for dlsym()])
3808 AC_TRY_LINK(,[
3809 extern void* dlsym();
3810 dlsym();
3811 ],
3812 AC_MSG_RESULT(yes);
3813 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
3814 AC_MSG_RESULT(no);
3815 AC_MSG_CHECKING([for dlsym() in -ldl])
3816 olibs=$LIBS
3817 LIBS="$LIBS -ldl"
3818 AC_TRY_LINK(,[
3819 extern void* dlsym();
3820 dlsym();
3821 ],
3822 AC_MSG_RESULT(yes);
3823 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
3824 AC_MSG_RESULT(no);
3825 LIBS=$olibs))
3826elif test x${DLL} = xdl.h; then
3827 AC_DEFINE(HAVE_DL_H, 1, [ Define if we have dl.h. ])
3828 AC_MSG_CHECKING([for shl_load()])
3829 AC_TRY_LINK(,[
3830 extern void* shl_load();
3831 shl_load();
3832 ],
3833 AC_MSG_RESULT(yes);
3834 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
3835 AC_MSG_RESULT(no);
3836 AC_MSG_CHECKING([for shl_load() in -ldld])
3837 olibs=$LIBS
3838 LIBS="$LIBS -ldld"
3839 AC_TRY_LINK(,[
3840 extern void* shl_load();
3841 shl_load();
3842 ],
3843 AC_MSG_RESULT(yes);
3844 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
3845 AC_MSG_RESULT(no);
3846 LIBS=$olibs))
3847fi
3848AC_CHECK_HEADERS(setjmp.h)
3849
3850if test "x$MACOSX" = "xyes" -a -n "$PERL"; then
3851 dnl -ldl must come after DynaLoader.a
3852 if echo $LIBS | grep -e '-ldl' >/dev/null; then
3853 LIBS=`echo $LIBS | sed s/-ldl//`
3854 PERL_LIBS="$PERL_LIBS -ldl"
3855 fi
3856fi
3857
Bram Moolenaar164fca32010-07-14 13:58:07 +02003858if test "x$MACOSX" = "xyes"; then
3859 AC_MSG_CHECKING(whether we need -framework Cocoa)
3860 dnl Cocoa is needed with FEAT_CLIPBOARD or FEAT_MBYTE (the former is
3861 dnl disabled during tiny build)
3862 if test "x$features" != "xtiny" || test "x$enable_multibyte" = "xyes"; then
3863 LIBS=$"$LIBS -framework Cocoa"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003864 AC_MSG_RESULT(yes)
3865 else
3866 AC_MSG_RESULT(no)
3867 fi
Bram Moolenaar3437b912013-07-03 19:52:53 +02003868 dnl As mentioned above, tiny build implies os_macosx.m isn't needed.
3869 dnl Exclude it from OS_EXTRA_SRC so that linker won't complain about
3870 dnl missing Objective-C symbols.
3871 if test "x$features" = "xtiny"; then
3872 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_macosx.m++'`
3873 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_macosx.o++'`
3874 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003875fi
Bram Moolenaar164fca32010-07-14 13:58:07 +02003876if test "x$MACARCH" = "xboth" && test "x$GUITYPE" = "xCARBONGUI"; then
Bram Moolenaar595a7be2010-03-10 16:28:12 +01003877 LDFLAGS="$LDFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +00003878fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003879
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00003880dnl gcc 3.1 changed the meaning of -MM. The only solution appears to be to
3881dnl use "-isystem" instead of "-I" for all non-Vim include dirs.
3882dnl But only when making dependencies, cproto and lint don't take "-isystem".
Bram Moolenaar32466aa2006-02-24 23:53:04 +00003883dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
3884dnl the number before the version number.
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00003885DEPEND_CFLAGS_FILTER=
3886if test "$GCC" = yes; then
Bram Moolenaar0cd49302008-11-20 09:37:01 +00003887 AC_MSG_CHECKING(for GCC 3 or later)
Bram Moolenaar2217cae2006-03-25 21:55:52 +00003888 gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]]\)\..*$/\1/g'`
Bram Moolenaarf740b292006-02-16 22:11:02 +00003889 if test "$gccmajor" -gt "2"; then
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00003890 DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
Bram Moolenaar0cd49302008-11-20 09:37:01 +00003891 AC_MSG_RESULT(yes)
3892 else
3893 AC_MSG_RESULT(no)
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00003894 fi
Bram Moolenaar0cd49302008-11-20 09:37:01 +00003895 dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
3896 dnl declared as char x[1] but actually longer. Introduced in gcc 4.0.
Bram Moolenaar56d1db32009-12-16 16:14:51 +00003897 dnl Also remove duplicate _FORTIFY_SOURCE arguments.
Bram Moolenaaraeabe052011-12-08 15:17:34 +01003898 dnl And undefine it first to avoid a warning.
Bram Moolenaar0cd49302008-11-20 09:37:01 +00003899 AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
3900 if test "$gccmajor" -gt "3"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02003901 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 +00003902 AC_MSG_RESULT(yes)
3903 else
3904 AC_MSG_RESULT(no)
3905 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +00003906fi
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00003907AC_SUBST(DEPEND_CFLAGS_FILTER)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003908
Bram Moolenaar22e193d2010-11-03 22:32:24 +01003909dnl link.sh tries to avoid overlinking in a hackish way.
3910dnl At least GNU ld supports --as-needed which provides the same functionality
3911dnl at linker level. Let's use it.
3912AC_MSG_CHECKING(linker --as-needed support)
3913LINK_AS_NEEDED=
3914# Check if linker supports --as-needed and --no-as-needed options
3915if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02003916 LDFLAGS=`echo "$LDFLAGS" | sed -e 's/ *-Wl,--as-needed//g' | sed -e 's/$/ -Wl,--as-needed/'`
Bram Moolenaar22e193d2010-11-03 22:32:24 +01003917 LINK_AS_NEEDED=yes
3918fi
3919if test "$LINK_AS_NEEDED" = yes; then
3920 AC_MSG_RESULT(yes)
3921else
3922 AC_MSG_RESULT(no)
3923fi
3924AC_SUBST(LINK_AS_NEEDED)
3925
Bram Moolenaar77c19352012-06-13 19:19:41 +02003926# IBM z/OS reset CFLAGS for config.mk
3927if test "$zOSUnix" = "yes"; then
3928 CFLAGS="-D_ALL_SOURCE -Wc,float\(ieee\),dll"
3929fi
3930
Bram Moolenaar071d4272004-06-13 20:20:40 +00003931dnl write output files
3932AC_OUTPUT(auto/config.mk:config.mk.in)
3933
3934dnl vim: set sw=2 tw=78 fo+=l: