blob: 2718d315214213da6ecd53cfc1043c0a2499dc28 [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 Moolenaar0958e0f2013-11-04 04:57:50 +0100207 dnl Removed -no-cpp-precomp, only for very old compilers.
208 CPPFLAGS="$CPPFLAGS -DMACOS_X_UNIX"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000209
210 dnl If Carbon is found, assume we don't want X11
211 dnl unless it was specifically asked for (--with-x)
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000212 dnl or Motif, Athena or GTK GUI is used.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000213 AC_CHECK_HEADER(Carbon/Carbon.h, CARBON=yes)
214 if test "x$CARBON" = "xyes"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +0200215 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 +0000216 with_x=no
Bram Moolenaar071d4272004-06-13 20:20:40 +0000217 fi
218 fi
219 fi
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000220
Bram Moolenaardb552d602006-03-23 22:59:57 +0000221 dnl Avoid a bug with -O2 with gcc 4.0.1. Symptom: malloc() reports double
Bram Moolenaarfd2ac762006-03-01 22:09:21 +0000222 dnl free. This happens in expand_filename(), because the optimizer swaps
Bram Moolenaardb552d602006-03-23 22:59:57 +0000223 dnl two blocks of code, both using "repl", that can't be swapped.
Bram Moolenaare224ffa2006-03-01 00:01:28 +0000224 if test "$MACARCH" = "intel" -o "$MACARCH" = "both"; then
225 CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-Oz/'`
226 fi
227
Bram Moolenaar071d4272004-06-13 20:20:40 +0000228else
229 AC_MSG_RESULT(no)
230fi
231
Bram Moolenaar39766a72013-11-03 00:41:00 +0100232dnl Mac OS X 10.9+ no longer include AvailabilityMacros.h in Carbon
233dnl so we need to include it to have access to version macros.
Bram Moolenaar18e54692013-11-03 20:26:31 +0100234AC_CHECK_HEADERS(AvailabilityMacros.h)
Bram Moolenaar39766a72013-11-03 00:41:00 +0100235
Bram Moolenaar071d4272004-06-13 20:20:40 +0000236AC_SUBST(OS_EXTRA_SRC)
237AC_SUBST(OS_EXTRA_OBJ)
238
239dnl Add /usr/local/lib to $LDFLAGS and /usr/local/include to CFLAGS.
240dnl Only when the directory exists and it wasn't there yet.
241dnl For gcc don't do this when it is already in the default search path.
Bram Moolenaar446cb832008-06-24 21:56:24 +0000242dnl Skip all of this when cross-compiling.
243if test "$cross_compiling" = no; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000244 AC_MSG_CHECKING(--with-local-dir argument)
Bram Moolenaar446cb832008-06-24 21:56:24 +0000245 have_local_include=''
246 have_local_lib=''
Bram Moolenaarc236c162008-07-13 17:41:49 +0000247 AC_ARG_WITH([local-dir], [ --with-local-dir=PATH search PATH instead of /usr/local for local libraries.
248 --without-local-dir do not search /usr/local for local libraries.], [
249 local_dir="$withval"
250 case "$withval" in
251 */*) ;;
252 no)
253 # avoid adding local dir to LDFLAGS and CPPFLAGS
Bram Moolenaare06c1882010-07-21 22:05:20 +0200254 have_local_include=yes
Bram Moolenaarc236c162008-07-13 17:41:49 +0000255 have_local_lib=yes
256 ;;
257 *) AC_MSG_ERROR(must pass path argument to --with-local-dir) ;;
258 esac
259 AC_MSG_RESULT($local_dir)
260 ], [
261 local_dir=/usr/local
262 AC_MSG_RESULT(Defaulting to $local_dir)
263 ])
264 if test "$GCC" = yes -a "$local_dir" != no; then
Bram Moolenaar446cb832008-06-24 21:56:24 +0000265 echo 'void f(){}' > conftest.c
Bram Moolenaar0958e0f2013-11-04 04:57:50 +0100266 dnl Removed -no-cpp-precomp, only needed for OS X 10.2 (Ben Fowler)
267 have_local_include=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/include"`
Bram Moolenaarc236c162008-07-13 17:41:49 +0000268 have_local_lib=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/lib"`
Bram Moolenaar446cb832008-06-24 21:56:24 +0000269 rm -f conftest.c conftest.o
Bram Moolenaar071d4272004-06-13 20:20:40 +0000270 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000271 if test -z "$have_local_lib" -a -d "${local_dir}/lib"; then
272 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 +0000273 if test "$tt" = "$LDFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000274 LDFLAGS="$LDFLAGS -L${local_dir}/lib"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000275 fi
276 fi
Bram Moolenaarc236c162008-07-13 17:41:49 +0000277 if test -z "$have_local_include" -a -d "${local_dir}/include"; then
278 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 +0000279 if test "$tt" = "$CPPFLAGS"; then
Bram Moolenaarc236c162008-07-13 17:41:49 +0000280 CPPFLAGS="$CPPFLAGS -I${local_dir}/include"
Bram Moolenaar446cb832008-06-24 21:56:24 +0000281 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000282 fi
283fi
284
285AC_MSG_CHECKING(--with-vim-name argument)
286AC_ARG_WITH(vim-name, [ --with-vim-name=NAME what to call the Vim executable],
287 VIMNAME="$withval"; AC_MSG_RESULT($VIMNAME),
Bram Moolenaare344bea2005-09-01 20:46:49 +0000288 VIMNAME="vim"; AC_MSG_RESULT(Defaulting to $VIMNAME))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000289AC_SUBST(VIMNAME)
290AC_MSG_CHECKING(--with-ex-name argument)
291AC_ARG_WITH(ex-name, [ --with-ex-name=NAME what to call the Ex executable],
292 EXNAME="$withval"; AC_MSG_RESULT($EXNAME),
293 EXNAME="ex"; AC_MSG_RESULT(Defaulting to ex))
294AC_SUBST(EXNAME)
295AC_MSG_CHECKING(--with-view-name argument)
296AC_ARG_WITH(view-name, [ --with-view-name=NAME what to call the View executable],
297 VIEWNAME="$withval"; AC_MSG_RESULT($VIEWNAME),
298 VIEWNAME="view"; AC_MSG_RESULT(Defaulting to view))
299AC_SUBST(VIEWNAME)
300
301AC_MSG_CHECKING(--with-global-runtime argument)
302AC_ARG_WITH(global-runtime, [ --with-global-runtime=DIR global runtime directory in 'runtimepath'],
303 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL, "$withval"),
304 AC_MSG_RESULT(no))
305
306AC_MSG_CHECKING(--with-modified-by argument)
307AC_ARG_WITH(modified-by, [ --with-modified-by=NAME name of who modified a release version],
308 AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(MODIFIED_BY, "$withval"),
309 AC_MSG_RESULT(no))
310
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200311dnl Check for EBCDIC stolen from the LYNX port to z/OS Unix
Bram Moolenaar071d4272004-06-13 20:20:40 +0000312AC_MSG_CHECKING(if character set is EBCDIC)
313AC_TRY_COMPILE([ ],
314[ /* TryCompile function for CharSet.
315 Treat any failure as ASCII for compatibility with existing art.
316 Use compile-time rather than run-time tests for cross-compiler
317 tolerance. */
318#if '0'!=240
319make an error "Character set is not EBCDIC"
320#endif ],
321[ # TryCompile action if true
322cf_cv_ebcdic=yes ],
323[ # TryCompile action if false
324cf_cv_ebcdic=no])
325# end of TryCompile ])
326# end of CacheVal CvEbcdic
327AC_MSG_RESULT($cf_cv_ebcdic)
328case "$cf_cv_ebcdic" in #(vi
329 yes) AC_DEFINE(EBCDIC)
330 line_break='"\\n"'
331 ;;
332 *) line_break='"\\012"';;
333esac
334AC_SUBST(line_break)
335
336if test "$cf_cv_ebcdic" = "yes"; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +0200337dnl If we have EBCDIC we most likely have z/OS Unix, let's test it!
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200338AC_MSG_CHECKING(for z/OS Unix)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000339case `uname` in
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200340 OS/390) zOSUnix="yes";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000341 dnl If using cc the environment variable _CC_CCMODE must be
342 dnl set to "1", so that some compiler extensions are enabled.
343 dnl If using c89 the environment variable is named _CC_C89MODE.
344 dnl Note: compile with c89 never tested.
345 if test "$CC" = "cc"; then
346 ccm="$_CC_CCMODE"
347 ccn="CC"
348 else
349 if test "$CC" = "c89"; then
350 ccm="$_CC_C89MODE"
351 ccn="C89"
352 else
353 ccm=1
354 fi
355 fi
356 if test "$ccm" != "1"; then
357 echo ""
358 echo "------------------------------------------"
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200359 echo " On z/OS Unix, the environment variable"
Bram Moolenaar77c19352012-06-13 19:19:41 +0200360 echo " _CC_${ccn}MODE must be set to \"1\"!"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000361 echo " Do:"
362 echo " export _CC_${ccn}MODE=1"
363 echo " and then call configure again."
364 echo "------------------------------------------"
365 exit 1
366 fi
Bram Moolenaar77c19352012-06-13 19:19:41 +0200367 # Set CFLAGS for configure process.
368 # This will be reset later for config.mk.
369 # Use haltonmsg to force error for missing H files.
370 CFLAGS="$CFLAGS -D_ALL_SOURCE -Wc,float(ieee),haltonmsg(3296)";
371 LDFLAGS="$LDFLAGS -Wl,EDIT=NO"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000372 AC_MSG_RESULT(yes)
373 ;;
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200374 *) zOSUnix="no";
Bram Moolenaar071d4272004-06-13 20:20:40 +0000375 AC_MSG_RESULT(no)
376 ;;
377esac
378fi
379
Bram Moolenaar2c704a72010-06-03 21:17:25 +0200380dnl Set QUOTESED. Needs additional backslashes on zOS
381if test "$zOSUnix" = "yes"; then
382 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\\\\\&/g' -e 's/\\\\\\\\\"/\"/' -e 's/\\\\\\\\\";\$\$/\";/'"
383else
384 QUOTESED="sed -e 's/[[\\\\\"]]/\\\\&/g' -e 's/\\\\\"/\"/' -e 's/\\\\\";\$\$/\";/'"
385fi
386AC_SUBST(QUOTESED)
387
388
Bram Moolenaar588ebeb2008-05-07 17:09:24 +0000389dnl Link with -lselinux for SELinux stuff; if not found
390AC_MSG_CHECKING(--disable-selinux argument)
391AC_ARG_ENABLE(selinux,
392 [ --disable-selinux Don't check for SELinux support.],
393 , enable_selinux="yes")
394if test "$enable_selinux" = "yes"; then
395 AC_MSG_RESULT(no)
396 AC_CHECK_LIB(selinux, is_selinux_enabled,
397 [LIBS="$LIBS -lselinux"
398 AC_DEFINE(HAVE_SELINUX)])
399else
400 AC_MSG_RESULT(yes)
401fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000402
403dnl Check user requested features.
404
405AC_MSG_CHECKING(--with-features argument)
406AC_ARG_WITH(features, [ --with-features=TYPE tiny, small, normal, big or huge (default: normal)],
407 features="$withval"; AC_MSG_RESULT($features),
408 features="normal"; AC_MSG_RESULT(Defaulting to normal))
409
410dovimdiff=""
411dogvimdiff=""
412case "$features" in
413 tiny) AC_DEFINE(FEAT_TINY) ;;
414 small) AC_DEFINE(FEAT_SMALL) ;;
415 normal) AC_DEFINE(FEAT_NORMAL) dovimdiff="installvimdiff";
416 dogvimdiff="installgvimdiff" ;;
417 big) AC_DEFINE(FEAT_BIG) dovimdiff="installvimdiff";
418 dogvimdiff="installgvimdiff" ;;
419 huge) AC_DEFINE(FEAT_HUGE) dovimdiff="installvimdiff";
420 dogvimdiff="installgvimdiff" ;;
421 *) AC_MSG_RESULT([Sorry, $features is not supported]) ;;
422esac
423
424AC_SUBST(dovimdiff)
425AC_SUBST(dogvimdiff)
426
427AC_MSG_CHECKING(--with-compiledby argument)
428AC_ARG_WITH(compiledby, [ --with-compiledby=NAME name to show in :version message],
429 compiledby="$withval"; AC_MSG_RESULT($withval),
430 compiledby=""; AC_MSG_RESULT(no))
431AC_SUBST(compiledby)
432
433AC_MSG_CHECKING(--disable-xsmp argument)
434AC_ARG_ENABLE(xsmp,
435 [ --disable-xsmp Disable XSMP session management],
436 , enable_xsmp="yes")
437
438if test "$enable_xsmp" = "yes"; then
439 AC_MSG_RESULT(no)
440 AC_MSG_CHECKING(--disable-xsmp-interact argument)
441 AC_ARG_ENABLE(xsmp-interact,
442 [ --disable-xsmp-interact Disable XSMP interaction],
443 , enable_xsmp_interact="yes")
444 if test "$enable_xsmp_interact" = "yes"; then
445 AC_MSG_RESULT(no)
446 AC_DEFINE(USE_XSMP_INTERACT)
447 else
448 AC_MSG_RESULT(yes)
449 fi
450else
451 AC_MSG_RESULT(yes)
452fi
453
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200454dnl Check for Lua feature.
455AC_MSG_CHECKING(--enable-luainterp argument)
456AC_ARG_ENABLE(luainterp,
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200457 [ --enable-luainterp[=OPTS] Include Lua interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200458 [enable_luainterp="no"])
459AC_MSG_RESULT($enable_luainterp)
460
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200461if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200462 dnl -- find the lua executable
463 AC_SUBST(vi_cv_path_lua)
464
465 AC_MSG_CHECKING(--with-lua-prefix argument)
466 AC_ARG_WITH(lua_prefix,
467 [ --with-lua-prefix=PFX Prefix where Lua is installed.],
468 with_lua_prefix="$withval"; AC_MSG_RESULT($with_lua_prefix),
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200469 with_lua_prefix="";AC_MSG_RESULT(no))
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200470
471 if test "X$with_lua_prefix" != "X"; then
472 vi_cv_path_lua_pfx="$with_lua_prefix"
473 else
474 AC_MSG_CHECKING(LUA_PREFIX environment var)
475 if test "X$LUA_PREFIX" != "X"; then
476 AC_MSG_RESULT("$LUA_PREFIX")
477 vi_cv_path_lua_pfx="$LUA_PREFIX"
478 else
Bram Moolenaar0d2e4fc2010-07-18 12:35:47 +0200479 AC_MSG_RESULT([not set, default to /usr])
480 vi_cv_path_lua_pfx="/usr"
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200481 fi
482 fi
483
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200484 AC_MSG_CHECKING(--with-luajit)
485 AC_ARG_WITH(luajit,
486 [ --with-luajit Link with LuaJIT instead of Lua.],
487 [vi_cv_with_luajit="$withval"],
488 [vi_cv_with_luajit="no"])
489 AC_MSG_RESULT($vi_cv_with_luajit)
490
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200491 LUA_INC=
492 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200493 if test "x$vi_cv_with_luajit" != "xno"; then
494 dnl -- try to find LuaJIT executable
495 AC_PATH_PROG(vi_cv_path_luajit, luajit)
496 if test "X$vi_cv_path_luajit" != "X"; then
497 dnl -- find LuaJIT version
498 AC_CACHE_CHECK(LuaJIT version, vi_cv_version_luajit,
Bram Moolenaar49b10272013-11-21 12:17:51 +0100499 [ vi_cv_version_luajit=`${vi_cv_path_luajit} -v 2>&1 | sed 's/LuaJIT \([[0-9.]]*\)\.[[0-9]]\(-[[a-z0-9]]*\)* .*/\1/'` ])
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200500 AC_CACHE_CHECK(Lua version of LuaJIT, vi_cv_version_lua_luajit,
501 [ vi_cv_version_lua_luajit=`${vi_cv_path_luajit} -e "print(_VERSION)" | sed 's/.* //'` ])
502 vi_cv_path_lua="$vi_cv_path_luajit"
503 vi_cv_version_lua="$vi_cv_version_lua_luajit"
504 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200505 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200506 dnl -- try to find Lua executable
507 AC_PATH_PROG(vi_cv_path_plain_lua, lua)
508 if test "X$vi_cv_path_plain_lua" != "X"; then
509 dnl -- find Lua version
510 AC_CACHE_CHECK(Lua version, vi_cv_version_plain_lua,
511 [ vi_cv_version_plain_lua=`${vi_cv_path_plain_lua} -e "print(_VERSION)" | sed 's/.* //'` ])
512 fi
513 vi_cv_path_lua="$vi_cv_path_plain_lua"
514 vi_cv_version_lua="$vi_cv_version_plain_lua"
515 fi
516 if test "x$vi_cv_with_luajit" != "xno" && test "X$vi_cv_version_luajit" != "X"; then
517 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit)
518 if test -f $vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit/lua.h; then
519 AC_MSG_RESULT(yes)
520 LUA_INC=/luajit-$vi_cv_version_luajit
521 fi
522 fi
523 if test "X$LUA_INC" = "X"; then
524 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)
525 if test -f $vi_cv_path_lua_pfx/include/lua.h; then
526 AC_MSG_RESULT(yes)
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200527 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200528 AC_MSG_RESULT(no)
529 AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua)
530 if test -f $vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h; then
531 AC_MSG_RESULT(yes)
532 LUA_INC=/lua$vi_cv_version_lua
533 else
534 AC_MSG_RESULT(no)
535 vi_cv_path_lua_pfx=
536 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200537 fi
538 fi
539 fi
540
541 if test "X$vi_cv_path_lua_pfx" != "X"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200542 if test "x$vi_cv_with_luajit" != "xno"; then
543 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
544 if test "X$multiarch" != "X"; then
545 lib_multiarch="lib/${multiarch}"
546 else
547 lib_multiarch="lib"
548 fi
549 if test "X$vi_cv_version_lua" = "X"; then
550 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit"
551 else
552 LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit-$vi_cv_version_lua"
553 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200554 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200555 if test "X$LUA_INC" != "X"; then
556 dnl Test alternate location using version
557 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua$vi_cv_version_lua"
558 else
559 LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua"
560 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200561 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200562 if test "$enable_luainterp" = "dynamic"; then
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200563 lua_ok="yes"
564 else
565 AC_MSG_CHECKING([if link with ${LUA_LIBS} is sane])
566 libs_save=$LIBS
567 LIBS="$LIBS $LUA_LIBS"
568 AC_TRY_LINK(,[ ],
569 AC_MSG_RESULT(yes); lua_ok="yes",
570 AC_MSG_RESULT(no); lua_ok="no"; LUA_LIBS="")
571 LIBS=$libs_save
572 fi
573 if test "x$lua_ok" = "xyes"; then
574 LUA_CFLAGS="-I${vi_cv_path_lua_pfx}/include${LUA_INC}"
575 LUA_SRC="if_lua.c"
576 LUA_OBJ="objects/if_lua.o"
577 LUA_PRO="if_lua.pro"
578 AC_DEFINE(FEAT_LUA)
579 fi
580 if test "$enable_luainterp" = "dynamic"; then
581 if test "x$vi_cv_with_luajit" != "xno"; then
582 luajit="jit"
583 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200584 if test -f "${vi_cv_path_lua_pfx}/bin/cyglua-${vi_cv_version_lua}.dll"; then
585 vi_cv_dll_name_lua="cyglua-${vi_cv_version_lua}.dll"
586 else
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200587 if test "x$MACOSX" = "xyes"; then
588 ext="dylib"
589 indexes=""
590 else
591 ext="so"
592 indexes=".0 .1 .2 .3 .4 .5 .6 .7 .8 .9"
593 multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
594 if test "X$multiarch" != "X"; then
595 lib_multiarch="lib/${multiarch}"
596 fi
Bram Moolenaar768baac2013-04-15 14:44:57 +0200597 fi
598 dnl Determine the sover for the current version, but fallback to
599 dnl liblua${vi_cv_version_lua}.so if no sover-versioned file is found.
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200600 AC_MSG_CHECKING(if liblua${luajit}*.${ext}* can be found in $vi_cv_path_lua_pfx)
Bram Moolenaar768baac2013-04-15 14:44:57 +0200601 for subdir in "${lib_multiarch}" lib64 lib; do
602 if test -z "$subdir"; then
603 continue
604 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200605 for sover in "${vi_cv_version_lua}.${ext}" "-${vi_cv_version_lua}.${ext}" \
606 ".${vi_cv_version_lua}.${ext}" ".${ext}.${vi_cv_version_lua}"; do
607 for i in $indexes ""; do
608 if test -f "${vi_cv_path_lua_pfx}/${subdir}/liblua${luajit}${sover}$i"; then
Bram Moolenaar768baac2013-04-15 14:44:57 +0200609 sover2="$i"
610 break 3
611 fi
612 done
Bram Moolenaar07e1da62013-02-06 19:49:43 +0100613 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200614 sover=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200615 done
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200616 if test "X$sover" = "X"; then
617 AC_MSG_RESULT(no)
618 lua_ok="no"
619 vi_cv_dll_name_lua="liblua${luajit}.${ext}"
620 else
621 AC_MSG_RESULT(yes)
622 lua_ok="yes"
623 vi_cv_dll_name_lua="liblua${luajit}${sover}$sover2"
624 fi
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200625 fi
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200626 AC_DEFINE(DYNAMIC_LUA)
627 LUA_LIBS=""
Bram Moolenaar1e91f262012-10-03 14:48:08 +0200628 LUA_CFLAGS="-DDYNAMIC_LUA_DLL=\\\"${vi_cv_dll_name_lua}\\\" $LUA_CFLAGS"
Bram Moolenaar2334b6d2010-07-22 21:32:16 +0200629 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200630 if test "X$LUA_CFLAGS$LUA_LIBS" != "X" && \
631 test "x$MACOSX" = "xyes" && test "x$vi_cv_with_luajit" != "xno" && \
632 test "`(uname -m) 2>/dev/null`" = "x86_64"; then
633 dnl OSX/x64 requires these flags. See http://luajit.org/install.html
634 LUA_LIBS="-pagezero_size 10000 -image_base 100000000 $LUA_LIBS"
635 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200636 fi
Bram Moolenaare855ccf2013-07-28 13:32:15 +0200637 if test "$fail_if_missing" = "yes" -a "$lua_ok" != "yes"; then
Bram Moolenaarf788a062011-12-14 20:51:25 +0100638 AC_MSG_ERROR([could not configure lua])
639 fi
Bram Moolenaar0ba04292010-07-14 23:23:17 +0200640 AC_SUBST(LUA_SRC)
641 AC_SUBST(LUA_OBJ)
642 AC_SUBST(LUA_PRO)
643 AC_SUBST(LUA_LIBS)
644 AC_SUBST(LUA_CFLAGS)
645fi
646
647
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000648dnl Check for MzScheme feature.
649AC_MSG_CHECKING(--enable-mzschemeinterp argument)
650AC_ARG_ENABLE(mzschemeinterp,
651 [ --enable-mzschemeinterp Include MzScheme interpreter.], ,
652 [enable_mzschemeinterp="no"])
653AC_MSG_RESULT($enable_mzschemeinterp)
654
655if test "$enable_mzschemeinterp" = "yes"; then
656 dnl -- find the mzscheme executable
657 AC_SUBST(vi_cv_path_mzscheme)
658
659 AC_MSG_CHECKING(--with-plthome argument)
660 AC_ARG_WITH(plthome,
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000661 [ --with-plthome=PLTHOME Use PLTHOME.],
662 with_plthome="$withval"; AC_MSG_RESULT($with_plthome),
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000663 with_plthome="";AC_MSG_RESULT("no"))
664
665 if test "X$with_plthome" != "X"; then
666 vi_cv_path_mzscheme_pfx="$with_plthome"
667 else
668 AC_MSG_CHECKING(PLTHOME environment var)
669 if test "X$PLTHOME" != "X"; then
670 AC_MSG_RESULT("$PLTHOME")
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000671 vi_cv_path_mzscheme_pfx="$PLTHOME"
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000672 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000673 AC_MSG_RESULT(not set)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000674 dnl -- try to find MzScheme executable
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000675 AC_PATH_PROG(vi_cv_path_mzscheme, mzscheme)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000676
677 dnl resolve symbolic link, the executable is often elsewhere and there
678 dnl are no links for the include files.
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000679 if test "X$vi_cv_path_mzscheme" != "X"; then
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000680 lsout=`ls -l $vi_cv_path_mzscheme`
681 if echo "$lsout" | grep -e '->' >/dev/null 2>/dev/null; then
682 vi_cv_path_mzscheme=`echo "$lsout" | sed 's/.*-> \(.*\)/\1/'`
683 fi
684 fi
685
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000686 if test "X$vi_cv_path_mzscheme" != "X"; then
687 dnl -- find where MzScheme thinks it was installed
688 AC_CACHE_CHECK(MzScheme install prefix,vi_cv_path_mzscheme_pfx,
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000689 dnl different versions of MzScheme differ in command line processing
690 dnl use universal approach
691 echo "(display (simplify-path \
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000692 (build-path (call-with-values \
693 (lambda () (split-path (find-system-path (quote exec-file)))) \
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000694 (lambda (base name must-be-dir?) base)) (quote up))))" > mzdirs.scm
695 dnl Remove a trailing slash
696 [ vi_cv_path_mzscheme_pfx=`${vi_cv_path_mzscheme} -r mzdirs.scm | \
697 sed -e 's+/$++'` ])
698 rm -f mzdirs.scm
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000699 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000700 fi
701 fi
702
Bram Moolenaard7afed32007-05-06 13:26:41 +0000703 SCHEME_INC=
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000704 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
705 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include)
706 if test -f $vi_cv_path_mzscheme_pfx/include/scheme.h; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000707 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include
708 AC_MSG_RESULT(yes)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000709 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000710 AC_MSG_RESULT(no)
711 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt)
Bram Moolenaard7afed32007-05-06 13:26:41 +0000712 if test -f $vi_cv_path_mzscheme_pfx/include/plt/scheme.h; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000713 AC_MSG_RESULT(yes)
714 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt
Bram Moolenaard7afed32007-05-06 13:26:41 +0000715 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000716 AC_MSG_RESULT(no)
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100717 AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket)
718 if test -f $vi_cv_path_mzscheme_pfx/include/racket/scheme.h; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000719 AC_MSG_RESULT(yes)
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100720 SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000721 else
722 AC_MSG_RESULT(no)
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100723 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/)
724 if test -f /usr/include/plt/scheme.h; then
725 AC_MSG_RESULT(yes)
726 SCHEME_INC=/usr/include/plt
727 else
728 AC_MSG_RESULT(no)
729 AC_MSG_CHECKING(if scheme.h can be found in /usr/include/racket/)
730 if test -f /usr/include/racket/scheme.h; then
731 AC_MSG_RESULT(yes)
732 SCHEME_INC=/usr/include/racket
733 else
734 AC_MSG_RESULT(no)
735 vi_cv_path_mzscheme_pfx=
736 fi
737 fi
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000738 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000739 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000740 fi
741 fi
742
743 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Bram Moolenaarf15f9432007-06-28 11:07:21 +0000744 if test "x$MACOSX" = "xyes"; then
Bram Moolenaar75676462013-01-30 14:55:42 +0100745 MZSCHEME_LIBS="-framework Racket"
746 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000747 elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"; then
748 MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"
749 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100750 elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket3m.a"; then
751 MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libracket3m.a"
752 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
753 elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket.a"; then
754 MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libracket.a ${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a"
755 elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme.a"; then
Bram Moolenaar9048f942007-05-12 14:32:25 +0000756 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 +0000757 else
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000758 dnl Using shared objects
759 if test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.so"; then
760 MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lmzscheme3m"
761 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100762 elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket3m.so"; then
763 MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lracket3m"
764 MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
765 elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket.so"; then
766 MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lracket -lmzgc"
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000767 else
768 MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lmzscheme -lmzgc"
769 fi
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +0000770 if test "$GCC" = yes; then
771 dnl Make Vim remember the path to the library. For when it's not in
772 dnl $LD_LIBRARY_PATH.
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000773 MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${vi_cv_path_mzscheme_pfx}/lib"
Bram Moolenaar21cf8232004-07-16 20:18:37 +0000774 elif test "`(uname) 2>/dev/null`" = SunOS &&
775 uname -r | grep '^5' >/dev/null; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000776 MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${vi_cv_path_mzscheme_pfx}/lib"
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +0000777 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000778 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100779
780 AC_MSG_CHECKING(for racket collects directory)
Bram Moolenaard7afed32007-05-06 13:26:41 +0000781 if test -d $vi_cv_path_mzscheme_pfx/lib/plt/collects; then
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100782 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/plt/
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100783 else
784 if test -d $vi_cv_path_mzscheme_pfx/lib/racket/collects; then
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100785 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/racket/
786 else
787 if test -d $vi_cv_path_mzscheme_pfx/share/racket/collects; then
788 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/
Bram Moolenaar75676462013-01-30 14:55:42 +0100789 else
790 if test -d $vi_cv_path_mzscheme_pfx/collects; then
791 SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/
792 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100793 fi
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100794 fi
Bram Moolenaard7afed32007-05-06 13:26:41 +0000795 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100796 if test "X$SCHEME_COLLECTS" != "X" ; then
797 AC_MSG_RESULT(${SCHEME_COLLECTS})
798 else
799 AC_MSG_RESULT(not found)
800 fi
801
802 AC_MSG_CHECKING(for mzscheme_base.c)
803 if test -f "${SCHEME_COLLECTS}collects/scheme/base.ss" ; then
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000804 MZSCHEME_EXTRA="mzscheme_base.c"
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100805 else
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100806 if test -f "${SCHEME_COLLECTS}collects/scheme/base.rkt" ; then
Bram Moolenaar2d0860d2010-11-03 21:59:30 +0100807 MZSCHEME_EXTRA="mzscheme_base.c"
808 fi
809 fi
810 if test "X$MZSCHEME_EXTRA" != "X" ; then
811 dnl need to generate bytecode for MzScheme base
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000812 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE"
813 MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100814 AC_MSG_RESULT(needed)
815 else
816 AC_MSG_RESULT(not needed)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000817 fi
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100818
Bram Moolenaar9e902192013-07-17 18:58:11 +0200819 dnl On Ubuntu this fixes "undefined reference to symbol 'ffi_type_void'".
820 AC_CHECK_LIB(ffi, ffi_type_void, [MZSCHEME_LIBS="$MZSCHEME_LIBS -lffi"])
821
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000822 MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -I${SCHEME_INC} \
Bram Moolenaarfe9fb922012-11-23 21:54:48 +0100823 -DMZSCHEME_COLLECTS='\"${SCHEME_COLLECTS}collects\"'"
Bram Moolenaar9e902192013-07-17 18:58:11 +0200824
825 dnl Test that we can compile a simple program with these CFLAGS and LIBS.
826 AC_MSG_CHECKING([if compile and link flags for MzScheme are sane])
827 cflags_save=$CFLAGS
828 libs_save=$LIBS
829 CFLAGS="$CFLAGS $MZSCHEME_CFLAGS"
830 LIBS="$LIBS $MZSCHEME_LIBS"
831 AC_TRY_LINK(,[ ],
832 AC_MSG_RESULT(yes); mzs_ok=yes,
833 AC_MSG_RESULT(no: MZSCHEME DISABLED); mzs_ok=no)
834 CFLAGS=$cflags_save
835 LIBS=$libs_save
836 if test $mzs_ok = yes; then
837 MZSCHEME_SRC="if_mzsch.c"
838 MZSCHEME_OBJ="objects/if_mzsch.o"
839 MZSCHEME_PRO="if_mzsch.pro"
840 AC_DEFINE(FEAT_MZSCHEME)
841 else
842 MZSCHEME_CFLAGS=
843 MZSCHEME_LIBS=
844 MZSCHEME_EXTRA=
845 MZSCHEME_MZC=
846 fi
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000847 fi
848 AC_SUBST(MZSCHEME_SRC)
849 AC_SUBST(MZSCHEME_OBJ)
850 AC_SUBST(MZSCHEME_PRO)
851 AC_SUBST(MZSCHEME_LIBS)
852 AC_SUBST(MZSCHEME_CFLAGS)
Bram Moolenaar9e70cf12009-05-26 20:59:55 +0000853 AC_SUBST(MZSCHEME_EXTRA)
854 AC_SUBST(MZSCHEME_MZC)
Bram Moolenaar325b7a22004-07-05 15:58:32 +0000855fi
856
857
Bram Moolenaar071d4272004-06-13 20:20:40 +0000858AC_MSG_CHECKING(--enable-perlinterp argument)
859AC_ARG_ENABLE(perlinterp,
Bram Moolenaare06c1882010-07-21 22:05:20 +0200860 [ --enable-perlinterp[=OPTS] Include Perl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000861 [enable_perlinterp="no"])
862AC_MSG_RESULT($enable_perlinterp)
Bram Moolenaare06c1882010-07-21 22:05:20 +0200863if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000864 AC_SUBST(vi_cv_path_perl)
865 AC_PATH_PROG(vi_cv_path_perl, perl)
866 if test "X$vi_cv_path_perl" != "X"; then
867 AC_MSG_CHECKING(Perl version)
868 if $vi_cv_path_perl -e 'require 5.003_01' >/dev/null 2>/dev/null; then
869 eval `$vi_cv_path_perl -V:usethreads`
Bram Moolenaare06c1882010-07-21 22:05:20 +0200870 eval `$vi_cv_path_perl -V:libperl`
Bram Moolenaar071d4272004-06-13 20:20:40 +0000871 if test "X$usethreads" = "XUNKNOWN" -o "X$usethreads" = "Xundef"; then
872 badthreads=no
873 else
874 if $vi_cv_path_perl -e 'require 5.6.0' >/dev/null 2>/dev/null; then
875 eval `$vi_cv_path_perl -V:use5005threads`
876 if test "X$use5005threads" = "XUNKNOWN" -o "X$use5005threads" = "Xundef"; then
877 badthreads=no
878 else
879 badthreads=yes
880 AC_MSG_RESULT(>>> Perl > 5.6 with 5.5 threads cannot be used <<<)
881 fi
882 else
883 badthreads=yes
884 AC_MSG_RESULT(>>> Perl 5.5 with threads cannot be used <<<)
885 fi
886 fi
887 if test $badthreads = no; then
888 AC_MSG_RESULT(OK)
889 eval `$vi_cv_path_perl -V:shrpenv`
890 if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04
891 shrpenv=""
892 fi
893 vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlibexp}'`
894 AC_SUBST(vi_cv_perllib)
895 dnl Remove "-fno-something", it breaks using cproto.
896 perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
897 -e 'ccflags;perl_inc;print"\n"' | sed -e 's/-fno[[^ ]]*//'`
898 dnl Remove "-lc", it breaks on FreeBSD when using "-pthread".
899 perllibs=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed -e 'ldopts' | \
900 sed -e '/Warning/d' -e '/Note (probably harmless)/d' \
901 -e 's/-bE:perl.exp//' -e 's/-lc //'`
902 dnl Don't add perl lib to $LIBS: if it's not in LD_LIBRARY_PATH
903 dnl a test in configure may fail because of that.
904 perlldflags=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed \
905 -e 'ccdlflags' | sed -e 's/-bE:perl.exp//'`
906
907 dnl check that compiling a simple program still works with the flags
908 dnl added for Perl.
909 AC_MSG_CHECKING([if compile and link flags for Perl are sane])
910 cflags_save=$CFLAGS
911 libs_save=$LIBS
912 ldflags_save=$LDFLAGS
913 CFLAGS="$CFLAGS $perlcppflags"
914 LIBS="$LIBS $perllibs"
Bram Moolenaara6cc0312013-06-18 23:31:55 +0200915 perlldflags=`echo "$perlldflags" | sed -e 's/^ *//g'`
Bram Moolenaar071d4272004-06-13 20:20:40 +0000916 LDFLAGS="$perlldflags $LDFLAGS"
917 AC_TRY_LINK(,[ ],
918 AC_MSG_RESULT(yes); perl_ok=yes,
919 AC_MSG_RESULT(no: PERL DISABLED); perl_ok=no)
920 CFLAGS=$cflags_save
921 LIBS=$libs_save
922 LDFLAGS=$ldflags_save
923 if test $perl_ok = yes; then
924 if test "X$perlcppflags" != "X"; then
Bram Moolenaard7afed32007-05-06 13:26:41 +0000925 dnl remove -pipe and -Wxxx, it confuses cproto
926 PERL_CFLAGS=`echo "$perlcppflags" | sed -e 's/-pipe //' -e 's/-W[[^ ]]*//'`
Bram Moolenaar071d4272004-06-13 20:20:40 +0000927 fi
928 if test "X$perlldflags" != "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +0200929 if test "X`echo \"$LDFLAGS\" | grep -F -e \"$perlldflags\"`" = "X"; then
930 LDFLAGS="$perlldflags $LDFLAGS"
931 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000932 fi
933 PERL_LIBS=$perllibs
934 PERL_SRC="auto/if_perl.c if_perlsfio.c"
935 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o"
936 PERL_PRO="if_perl.pro if_perlsfio.pro"
937 AC_DEFINE(FEAT_PERL)
938 fi
939 fi
940 else
941 AC_MSG_RESULT(>>> too old; need Perl version 5.003_01 or later <<<)
942 fi
943 fi
944
945 if test "x$MACOSX" = "xyes"; then
Bram Moolenaar9372a112005-12-06 19:59:18 +0000946 dnl Mac OS X 10.2 or later
Bram Moolenaar071d4272004-06-13 20:20:40 +0000947 dir=/System/Library/Perl
948 darwindir=$dir/darwin
949 if test -d $darwindir; then
950 PERL=/usr/bin/perl
951 else
952 dnl Mac OS X 10.3
953 dir=/System/Library/Perl/5.8.1
954 darwindir=$dir/darwin-thread-multi-2level
955 if test -d $darwindir; then
956 PERL=/usr/bin/perl
957 fi
958 fi
959 if test -n "$PERL"; then
960 PERL_DIR="$dir"
961 PERL_CFLAGS="-DFEAT_PERL -I$darwindir/CORE"
962 PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o $darwindir/auto/DynaLoader/DynaLoader.a"
963 PERL_LIBS="-L$darwindir/CORE -lperl"
964 fi
Bram Moolenaar5dff57d2010-07-24 16:19:44 +0200965 dnl Perl on Mac OS X 10.5 adds "-arch" flags but these should only
966 dnl be included if requested by passing --with-mac-arch to
967 dnl configure, so strip these flags first (if present)
968 PERL_LIBS=`echo "$PERL_LIBS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
969 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 +0000970 fi
Bram Moolenaare06c1882010-07-21 22:05:20 +0200971 if test "$enable_perlinterp" = "dynamic"; then
972 if test "$perl_ok" = "yes" -a "X$libperl" != "X"; then
973 AC_DEFINE(DYNAMIC_PERL)
974 PERL_CFLAGS="-DDYNAMIC_PERL_DLL=\\\"$libperl\\\" $PERL_CFLAGS"
975 fi
976 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +0100977
978 if test "$fail_if_missing" = "yes" -a "$perl_ok" != "yes"; then
979 AC_MSG_ERROR([could not configure perl])
980 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +0000981fi
982AC_SUBST(shrpenv)
983AC_SUBST(PERL_SRC)
984AC_SUBST(PERL_OBJ)
985AC_SUBST(PERL_PRO)
986AC_SUBST(PERL_CFLAGS)
987AC_SUBST(PERL_LIBS)
988
989AC_MSG_CHECKING(--enable-pythoninterp argument)
990AC_ARG_ENABLE(pythoninterp,
Bram Moolenaarb744b2f2010-08-13 16:22:57 +0200991 [ --enable-pythoninterp[=OPTS] Include Python interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000992 [enable_pythoninterp="no"])
993AC_MSG_RESULT($enable_pythoninterp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +0200994if test "$enable_pythoninterp" = "yes" -o "$enable_pythoninterp" = "dynamic"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +0000995 dnl -- find the python executable
Bram Moolenaar09ba6d72012-12-12 14:25:05 +0100996 AC_PATH_PROGS(vi_cv_path_python, python2 python)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000997 if test "X$vi_cv_path_python" != "X"; then
998
999 dnl -- get its version number
1000 AC_CACHE_CHECK(Python version,vi_cv_var_python_version,
1001 [[vi_cv_var_python_version=`
1002 ${vi_cv_path_python} -c 'import sys; print sys.version[:3]'`
1003 ]])
1004
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001005 dnl -- it must be at least version 2.3
1006 AC_MSG_CHECKING(Python is 2.3 or better)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001007 if ${vi_cv_path_python} -c \
Bram Moolenaarc09a6d62013-06-10 21:27:29 +02001008 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001009 then
1010 AC_MSG_RESULT(yep)
1011
1012 dnl -- find where python thinks it was installed
1013 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python_pfx,
1014 [ vi_cv_path_python_pfx=`
1015 ${vi_cv_path_python} -c \
1016 "import sys; print sys.prefix"` ])
1017
1018 dnl -- and where it thinks it runs
1019 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python_epfx,
1020 [ vi_cv_path_python_epfx=`
1021 ${vi_cv_path_python} -c \
1022 "import sys; print sys.exec_prefix"` ])
1023
1024 dnl -- python's internal library path
1025
1026 AC_CACHE_VAL(vi_cv_path_pythonpath,
1027 [ vi_cv_path_pythonpath=`
1028 unset PYTHONPATH;
1029 ${vi_cv_path_python} -c \
1030 "import sys, string; print string.join(sys.path,':')"` ])
1031
1032 dnl -- where the Python implementation library archives are
1033
1034 AC_ARG_WITH(python-config-dir,
1035 [ --with-python-config-dir=PATH Python's config directory],
1036 [ vi_cv_path_python_conf="${withval}" ] )
1037
1038 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python_conf,
1039 [
1040 vi_cv_path_python_conf=
Bram Moolenaarac499e32013-06-02 19:14:17 +02001041 d=`${vi_cv_path_python} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBPL')"`
1042 if test -d "$d" && test -f "$d/config.c"; then
1043 vi_cv_path_python_conf="$d"
1044 else
1045 for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
1046 for subdir in lib64 lib share; do
1047 d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
1048 if test -d "$d" && test -f "$d/config.c"; then
1049 vi_cv_path_python_conf="$d"
1050 fi
1051 done
Bram Moolenaar071d4272004-06-13 20:20:40 +00001052 done
Bram Moolenaarac499e32013-06-02 19:14:17 +02001053 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001054 ])
1055
1056 PYTHON_CONFDIR="${vi_cv_path_python_conf}"
1057
1058 if test "X$PYTHON_CONFDIR" = "X"; then
1059 AC_MSG_RESULT([can't find it!])
1060 else
1061
1062 dnl -- we need to examine Python's config/Makefile too
1063 dnl see what the interpreter is built from
1064 AC_CACHE_VAL(vi_cv_path_python_plibs,
1065 [
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001066 pwd=`pwd`
1067 tmp_mkf="$pwd/config-PyMake$$"
1068 cat -- "${PYTHON_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001069__:
Bram Moolenaar218116c2010-05-20 21:46:00 +02001070 @echo "python_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001071 @echo "python_LIBS='$(LIBS)'"
1072 @echo "python_SYSLIBS='$(SYSLIBS)'"
1073 @echo "python_LINKFORSHARED='$(LINKFORSHARED)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001074 @echo "python_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001075 @echo "python_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001076eof
1077 dnl -- delete the lines from make about Entering/Leaving directory
Bram Moolenaar01dd60c2008-07-24 14:24:48 +00001078 eval "`cd ${PYTHON_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1079 rm -f -- "${tmp_mkf}"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001080 if test "x$MACOSX" = "xyes" && ${vi_cv_path_python} -c \
1081 "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then
1082 vi_cv_path_python_plibs="-framework Python"
1083 else
1084 if test "${vi_cv_var_python_version}" = "1.4"; then
1085 vi_cv_path_python_plibs="${PYTHON_CONFDIR}/libModules.a ${PYTHON_CONFDIR}/libPython.a ${PYTHON_CONFDIR}/libObjects.a ${PYTHON_CONFDIR}/libParser.a"
1086 else
1087 vi_cv_path_python_plibs="-L${PYTHON_CONFDIR} -lpython${vi_cv_var_python_version}"
1088 fi
Bram Moolenaar218116c2010-05-20 21:46:00 +02001089 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 +00001090 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1091 vi_cv_path_python_plibs=`echo $vi_cv_path_python_plibs | sed s/-ltermcap//`
1092 fi
1093 ])
1094
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001095 if test "X$python_DLLLIBRARY" != "X"; then
1096 python_INSTSONAME="$python_DLLLIBRARY"
1097 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001098 PYTHON_LIBS="${vi_cv_path_python_plibs}"
1099 if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
Bram Moolenaar780c3e92013-06-11 20:53:28 +02001100 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 +00001101 else
Bram Moolenaar780c3e92013-06-11 20:53:28 +02001102 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 +00001103 fi
1104 PYTHON_SRC="if_python.c"
Bram Moolenaar9bdb9a02012-07-25 16:32:08 +02001105 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001106 if test "${vi_cv_var_python_version}" = "1.4"; then
1107 PYTHON_OBJ="$PYTHON_OBJ objects/py_getpath.o"
1108 fi
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001109 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 +00001110
1111 dnl On FreeBSD linking with "-pthread" is required to use threads.
1112 dnl _THREAD_SAFE must be used for compiling then.
1113 dnl The "-pthread" is added to $LIBS, so that the following check for
1114 dnl sigaltstack() will look in libc_r (it's there in libc!).
1115 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1116 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1117 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1118 AC_MSG_CHECKING([if -pthread should be used])
1119 threadsafe_flag=
1120 thread_lib=
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00001121 dnl if test "x$MACOSX" != "xyes"; then
1122 if test "`(uname) 2>/dev/null`" != Darwin; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001123 test "$GCC" = yes && threadsafe_flag="-pthread"
1124 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1125 threadsafe_flag="-D_THREAD_SAFE"
1126 thread_lib="-pthread"
1127 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001128 if test "`(uname) 2>/dev/null`" = SunOS; then
1129 threadsafe_flag="-pthreads"
1130 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001131 fi
1132 libs_save_old=$LIBS
1133 if test -n "$threadsafe_flag"; then
1134 cflags_save=$CFLAGS
1135 CFLAGS="$CFLAGS $threadsafe_flag"
1136 LIBS="$LIBS $thread_lib"
1137 AC_TRY_LINK(,[ ],
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001138 AC_MSG_RESULT(yes); PYTHON_CFLAGS="$PYTHON_CFLAGS $threadsafe_flag",
Bram Moolenaar071d4272004-06-13 20:20:40 +00001139 AC_MSG_RESULT(no); LIBS=$libs_save_old
1140 )
1141 CFLAGS=$cflags_save
1142 else
1143 AC_MSG_RESULT(no)
1144 fi
1145
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001146 dnl Check that compiling a simple program still works with the flags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001147 dnl added for Python.
1148 AC_MSG_CHECKING([if compile and link flags for Python are sane])
1149 cflags_save=$CFLAGS
1150 libs_save=$LIBS
Bram Moolenaar69f787a2010-07-11 20:52:58 +02001151 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001152 LIBS="$LIBS $PYTHON_LIBS"
1153 AC_TRY_LINK(,[ ],
1154 AC_MSG_RESULT(yes); python_ok=yes,
1155 AC_MSG_RESULT(no: PYTHON DISABLED); python_ok=no)
1156 CFLAGS=$cflags_save
1157 LIBS=$libs_save
1158 if test $python_ok = yes; then
1159 AC_DEFINE(FEAT_PYTHON)
1160 else
1161 LIBS=$libs_save_old
1162 PYTHON_SRC=
1163 PYTHON_OBJ=
1164 PYTHON_LIBS=
1165 PYTHON_CFLAGS=
1166 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001167 fi
1168 else
1169 AC_MSG_RESULT(too old)
1170 fi
1171 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001172
1173 if test "$fail_if_missing" = "yes" -a "$python_ok" != "yes"; then
1174 AC_MSG_ERROR([could not configure python])
1175 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001176fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001177
Bram Moolenaar071d4272004-06-13 20:20:40 +00001178AC_SUBST(PYTHON_CONFDIR)
1179AC_SUBST(PYTHON_LIBS)
1180AC_SUBST(PYTHON_GETPATH_CFLAGS)
1181AC_SUBST(PYTHON_CFLAGS)
1182AC_SUBST(PYTHON_SRC)
1183AC_SUBST(PYTHON_OBJ)
1184
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001185
1186AC_MSG_CHECKING(--enable-python3interp argument)
1187AC_ARG_ENABLE(python3interp,
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001188 [ --enable-python3interp[=OPTS] Include Python3 interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001189 [enable_python3interp="no"])
1190AC_MSG_RESULT($enable_python3interp)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001191if test "$enable_python3interp" = "yes" -o "$enable_python3interp" = "dynamic"; then
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001192 dnl -- find the python3 executable
Bram Moolenaar09ba6d72012-12-12 14:25:05 +01001193 AC_PATH_PROGS(vi_cv_path_python3, python3 python)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001194 if test "X$vi_cv_path_python3" != "X"; then
1195
1196 dnl -- get its version number
1197 AC_CACHE_CHECK(Python version,vi_cv_var_python3_version,
1198 [[vi_cv_var_python3_version=`
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001199 ${vi_cv_path_python3} -c 'import sys; print(sys.version[:3])'`
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001200 ]])
1201
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001202 dnl -- it must be at least version 3
1203 AC_MSG_CHECKING(Python is 3.0 or better)
1204 if ${vi_cv_path_python3} -c \
1205 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.0)"
1206 then
1207 AC_MSG_RESULT(yep)
Bram Moolenaar456f2bb2011-06-12 21:37:13 +02001208
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001209 dnl -- get abiflags for python 3.2 or higher (PEP 3149)
1210 AC_CACHE_CHECK(Python's abiflags,vi_cv_var_python3_abiflags,
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001211 [
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001212 vi_cv_var_python3_abiflags=
1213 if ${vi_cv_path_python3} -c \
1214 "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)"
1215 then
1216 vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \
1217 "import sys; print(sys.abiflags)"`
1218 fi ])
1219
1220 dnl -- find where python3 thinks it was installed
1221 AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx,
1222 [ vi_cv_path_python3_pfx=`
1223 ${vi_cv_path_python3} -c \
1224 "import sys; print(sys.prefix)"` ])
1225
1226 dnl -- and where it thinks it runs
1227 AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx,
1228 [ vi_cv_path_python3_epfx=`
1229 ${vi_cv_path_python3} -c \
1230 "import sys; print(sys.exec_prefix)"` ])
1231
1232 dnl -- python3's internal library path
1233
1234 AC_CACHE_VAL(vi_cv_path_python3path,
1235 [ vi_cv_path_python3path=`
1236 unset PYTHONPATH;
1237 ${vi_cv_path_python3} -c \
1238 "import sys, string; print(':'.join(sys.path))"` ])
1239
1240 dnl -- where the Python implementation library archives are
1241
1242 AC_ARG_WITH(python3-config-dir,
1243 [ --with-python3-config-dir=PATH Python's config directory],
1244 [ vi_cv_path_python3_conf="${withval}" ] )
1245
1246 AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf,
1247 [
1248 vi_cv_path_python3_conf=
Bram Moolenaarfee496d2013-07-12 20:07:24 +02001249 config_dir="config-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001250 d=`${vi_cv_path_python3} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBPL'))"`
1251 if test -d "$d" && test -f "$d/config.c"; then
1252 vi_cv_path_python3_conf="$d"
1253 else
1254 for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do
1255 for subdir in lib64 lib share; do
1256 d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}"
1257 if test -d "$d" && test -f "$d/config.c"; then
1258 vi_cv_path_python3_conf="$d"
1259 fi
1260 done
1261 done
1262 fi
1263 ])
1264
1265 PYTHON3_CONFDIR="${vi_cv_path_python3_conf}"
1266
1267 if test "X$PYTHON3_CONFDIR" = "X"; then
1268 AC_MSG_RESULT([can't find it!])
1269 else
1270
1271 dnl -- we need to examine Python's config/Makefile too
1272 dnl see what the interpreter is built from
1273 AC_CACHE_VAL(vi_cv_path_python3_plibs,
1274 [
1275 pwd=`pwd`
1276 tmp_mkf="$pwd/config-PyMake$$"
1277 cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001278__:
Bram Moolenaar3804aeb2010-07-19 21:18:54 +02001279 @echo "python3_BASEMODLIBS='$(BASEMODLIBS)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001280 @echo "python3_LIBS='$(LIBS)'"
1281 @echo "python3_SYSLIBS='$(SYSLIBS)'"
Bram Moolenaarf94a13c2012-09-21 13:26:49 +02001282 @echo "python3_DLLLIBRARY='$(DLLLIBRARY)'"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001283 @echo "python3_INSTSONAME='$(INSTSONAME)'"
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001284eof
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001285 dnl -- delete the lines from make about Entering/Leaving directory
1286 eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
1287 rm -f -- "${tmp_mkf}"
1288 vi_cv_path_python3_plibs="-L${PYTHON3_CONFDIR} -lpython${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
1289 vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}"
1290 dnl remove -ltermcap, it can conflict with an earlier -lncurses
1291 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//`
1292 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//`
1293 ])
1294
1295 if test "X$python3_DLLLIBRARY" != "X"; then
1296 python3_INSTSONAME="$python3_DLLLIBRARY"
1297 fi
1298 PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
1299 if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
Bram Moolenaar780c3e92013-06-11 20:53:28 +02001300 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 +02001301 else
Bram Moolenaar780c3e92013-06-11 20:53:28 +02001302 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 +02001303 fi
1304 PYTHON3_SRC="if_python3.c"
1305 PYTHON3_OBJ="objects/if_python3.o"
1306
1307 dnl On FreeBSD linking with "-pthread" is required to use threads.
1308 dnl _THREAD_SAFE must be used for compiling then.
1309 dnl The "-pthread" is added to $LIBS, so that the following check for
1310 dnl sigaltstack() will look in libc_r (it's there in libc!).
1311 dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
1312 dnl will then define target-specific defines, e.g., -D_REENTRANT.
1313 dnl Don't do this for Mac OSX, -pthread will generate a warning.
1314 AC_MSG_CHECKING([if -pthread should be used])
1315 threadsafe_flag=
1316 thread_lib=
1317 dnl if test "x$MACOSX" != "xyes"; then
1318 if test "`(uname) 2>/dev/null`" != Darwin; then
1319 test "$GCC" = yes && threadsafe_flag="-pthread"
1320 if test "`(uname) 2>/dev/null`" = FreeBSD; then
1321 threadsafe_flag="-D_THREAD_SAFE"
1322 thread_lib="-pthread"
1323 fi
1324 if test "`(uname) 2>/dev/null`" = SunOS; then
1325 threadsafe_flag="-pthreads"
1326 fi
1327 fi
1328 libs_save_old=$LIBS
1329 if test -n "$threadsafe_flag"; then
1330 cflags_save=$CFLAGS
1331 CFLAGS="$CFLAGS $threadsafe_flag"
1332 LIBS="$LIBS $thread_lib"
1333 AC_TRY_LINK(,[ ],
1334 AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag",
1335 AC_MSG_RESULT(no); LIBS=$libs_save_old
1336 )
1337 CFLAGS=$cflags_save
1338 else
1339 AC_MSG_RESULT(no)
1340 fi
1341
1342 dnl check that compiling a simple program still works with the flags
1343 dnl added for Python.
1344 AC_MSG_CHECKING([if compile and link flags for Python 3 are sane])
1345 cflags_save=$CFLAGS
1346 libs_save=$LIBS
1347 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1348 LIBS="$LIBS $PYTHON3_LIBS"
1349 AC_TRY_LINK(,[ ],
1350 AC_MSG_RESULT(yes); python3_ok=yes,
1351 AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no)
1352 CFLAGS=$cflags_save
1353 LIBS=$libs_save
1354 if test "$python3_ok" = yes; then
1355 AC_DEFINE(FEAT_PYTHON3)
1356 else
1357 LIBS=$libs_save_old
1358 PYTHON3_SRC=
1359 PYTHON3_OBJ=
1360 PYTHON3_LIBS=
1361 PYTHON3_CFLAGS=
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001362 fi
1363 fi
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02001364 else
1365 AC_MSG_RESULT(too old)
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001366 fi
1367 fi
Bram Moolenaar1612b1a2013-06-14 21:22:39 +02001368 if test "$fail_if_missing" = "yes" -a "$python3_ok" != "yes"; then
1369 AC_MSG_ERROR([could not configure python3])
1370 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001371fi
1372
1373AC_SUBST(PYTHON3_CONFDIR)
1374AC_SUBST(PYTHON3_LIBS)
1375AC_SUBST(PYTHON3_CFLAGS)
1376AC_SUBST(PYTHON3_SRC)
1377AC_SUBST(PYTHON3_OBJ)
1378
1379dnl if python2.x and python3.x are enabled one can only link in code
1380dnl with dlopen(), dlsym(), dlclose()
1381if test "$python_ok" = yes && test "$python3_ok" = yes; then
1382 AC_DEFINE(DYNAMIC_PYTHON)
1383 AC_DEFINE(DYNAMIC_PYTHON3)
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001384 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001385 cflags_save=$CFLAGS
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001386 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001387 ldflags_save=$LDFLAGS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001388 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
1389 LDFLAGS="-ldl $LDFLAGS"
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001390 AC_RUN_IFELSE([
1391 #include <dlfcn.h>
1392 /* If this program fails, then RTLD_GLOBAL is needed.
1393 * RTLD_GLOBAL will be used and then it is not possible to
1394 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001395 * Only the first python version used will be switched on.
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001396 */
1397
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001398 int no_rtl_global_needed_for(char *python_instsoname, char *prefix)
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001399 {
1400 int needed = 0;
1401 void* pylib = dlopen(python_instsoname, RTLD_LAZY);
1402 if (pylib != 0)
1403 {
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001404 void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome");
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001405 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1406 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1407 void (*final)(void) = dlsym(pylib, "Py_Finalize");
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001408 (*pfx)(prefix);
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001409 (*init)();
1410 needed = (*simple)("import termios") == -1;
1411 (*final)();
1412 dlclose(pylib);
1413 }
1414 return !needed;
1415 }
1416
1417 int main(int argc, char** argv)
1418 {
1419 int not_needed = 0;
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001420 if (no_rtl_global_needed_for("${python_INSTSONAME}", "${vi_cv_path_python_pfx}"))
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001421 not_needed = 1;
1422 return !not_needed;
1423 }],
1424 [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001425
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001426 CFLAGS=$cflags_save
1427 LDFLAGS=$ldflags_save
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001428
1429 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python3)
1430 cflags_save=$CFLAGS
1431 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1432 ldflags_save=$LDFLAGS
Bram Moolenaar6fabcbe2011-09-02 12:27:25 +02001433 dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
1434 LDFLAGS="-ldl $LDFLAGS"
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001435 AC_RUN_IFELSE([
1436 #include <dlfcn.h>
1437 #include <wchar.h>
1438 /* If this program fails, then RTLD_GLOBAL is needed.
1439 * RTLD_GLOBAL will be used and then it is not possible to
1440 * have both python versions enabled in the same vim instance.
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02001441 * Only the first python version used will be switched on.
Bram Moolenaar644d37b2010-11-16 19:26:02 +01001442 */
1443
1444 int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix)
1445 {
1446 int needed = 0;
1447 void* pylib = dlopen(python_instsoname, RTLD_LAZY);
1448 if (pylib != 0)
1449 {
1450 void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome");
1451 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1452 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1453 void (*final)(void) = dlsym(pylib, "Py_Finalize");
1454 (*pfx)(prefix);
1455 (*init)();
1456 needed = (*simple)("import termios") == -1;
1457 (*final)();
1458 dlclose(pylib);
1459 }
1460 return !needed;
1461 }
1462
1463 int main(int argc, char** argv)
1464 {
1465 int not_needed = 0;
1466 if (no_rtl_global_needed_for("${python3_INSTSONAME}", L"${vi_cv_path_python3_pfx}"))
1467 not_needed = 1;
1468 return !not_needed;
1469 }],
1470 [AC_MSG_RESULT(yes);AC_DEFINE(PY3_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
1471
1472 CFLAGS=$cflags_save
1473 LDFLAGS=$ldflags_save
1474
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001475 PYTHON_SRC="if_python.c"
1476 PYTHON_OBJ="objects/if_python.o"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001477 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${python_INSTSONAME}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001478 PYTHON_LIBS=
1479 PYTHON3_SRC="if_python3.c"
1480 PYTHON3_OBJ="objects/if_python3.o"
Bram Moolenaar2a7e2a62010-07-24 15:19:11 +02001481 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${python3_INSTSONAME}\\\""
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001482 PYTHON3_LIBS=
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001483elif test "$python_ok" = yes && test "$enable_pythoninterp" = "dynamic"; then
1484 AC_DEFINE(DYNAMIC_PYTHON)
1485 PYTHON_SRC="if_python.c"
1486 PYTHON_OBJ="objects/if_python.o"
1487 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${python_INSTSONAME}\\\""
1488 PYTHON_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001489elif test "$python_ok" = yes; then
1490 dnl Check that adding -fPIE works. It may be needed when using a static
1491 dnl Python library.
1492 AC_MSG_CHECKING([if -fPIE can be added for Python])
1493 cflags_save=$CFLAGS
1494 libs_save=$LIBS
1495 CFLAGS="$CFLAGS $PYTHON_CFLAGS -fPIE"
1496 LIBS="$LIBS $PYTHON_LIBS"
1497 AC_TRY_LINK(,[ ],
1498 AC_MSG_RESULT(yes); fpie_ok=yes,
1499 AC_MSG_RESULT(no); fpie_ok=no)
1500 CFLAGS=$cflags_save
1501 LIBS=$libs_save
1502 if test $fpie_ok = yes; then
1503 PYTHON_CFLAGS="$PYTHON_CFLAGS -fPIE"
1504 fi
Bram Moolenaarb744b2f2010-08-13 16:22:57 +02001505elif test "$python3_ok" = yes && test "$enable_python3interp" = "dynamic"; then
1506 AC_DEFINE(DYNAMIC_PYTHON3)
1507 PYTHON3_SRC="if_python3.c"
1508 PYTHON3_OBJ="objects/if_python3.o"
1509 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${python3_INSTSONAME}\\\""
1510 PYTHON3_LIBS=
Bram Moolenaare741f272013-07-09 21:57:52 +02001511elif test "$python3_ok" = yes; then
1512 dnl Check that adding -fPIE works. It may be needed when using a static
1513 dnl Python library.
1514 AC_MSG_CHECKING([if -fPIE can be added for Python3])
1515 cflags_save=$CFLAGS
1516 libs_save=$LIBS
1517 CFLAGS="$CFLAGS $PYTHON3_CFLAGS -fPIE"
1518 LIBS="$LIBS $PYTHON3_LIBS"
1519 AC_TRY_LINK(,[ ],
1520 AC_MSG_RESULT(yes); fpie_ok=yes,
1521 AC_MSG_RESULT(no); fpie_ok=no)
1522 CFLAGS=$cflags_save
1523 LIBS=$libs_save
1524 if test $fpie_ok = yes; then
1525 PYTHON3_CFLAGS="$PYTHON3_CFLAGS -fPIE"
1526 fi
Bram Moolenaarbd5e15f2010-07-17 21:19:38 +02001527fi
1528
Bram Moolenaar071d4272004-06-13 20:20:40 +00001529AC_MSG_CHECKING(--enable-tclinterp argument)
1530AC_ARG_ENABLE(tclinterp,
1531 [ --enable-tclinterp Include Tcl interpreter.], ,
1532 [enable_tclinterp="no"])
1533AC_MSG_RESULT($enable_tclinterp)
1534
1535if test "$enable_tclinterp" = "yes"; then
1536
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001537 dnl on FreeBSD tclsh is a silly script, look for tclsh8.[5420]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001538 AC_MSG_CHECKING(--with-tclsh argument)
1539 AC_ARG_WITH(tclsh, [ --with-tclsh=PATH which tclsh to use (default: tclsh8.0)],
1540 tclsh_name="$withval"; AC_MSG_RESULT($tclsh_name),
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001541 tclsh_name="tclsh8.5"; AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00001542 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1543 AC_SUBST(vi_cv_path_tcl)
1544
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001545 dnl when no specific version specified, also try 8.4, 8.2 and 8.0
1546 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.5"; then
1547 tclsh_name="tclsh8.4"
1548 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1549 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001550 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.4"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001551 tclsh_name="tclsh8.2"
1552 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1553 fi
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001554 if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.2"; then
1555 tclsh_name="tclsh8.0"
1556 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1557 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001558 dnl still didn't find it, try without version number
1559 if test "X$vi_cv_path_tcl" = "X"; then
1560 tclsh_name="tclsh"
1561 AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
1562 fi
1563 if test "X$vi_cv_path_tcl" != "X"; then
1564 AC_MSG_CHECKING(Tcl version)
1565 if echo 'exit [[expr [info tclversion] < 8.0]]' | $vi_cv_path_tcl - ; then
1566 tclver=`echo 'puts [[info tclversion]]' | $vi_cv_path_tcl -`
1567 AC_MSG_RESULT($tclver - OK);
1568 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 -`
1569
1570 AC_MSG_CHECKING(for location of Tcl include)
1571 if test "x$MACOSX" != "xyes"; then
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001572 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 +00001573 else
1574 dnl For Mac OS X 10.3, use the OS-provided framework location
1575 tclinc="/System/Library/Frameworks/Tcl.framework/Headers"
1576 fi
Bram Moolenaar0ff8f602008-02-20 11:44:03 +00001577 TCL_INC=
Bram Moolenaar071d4272004-06-13 20:20:40 +00001578 for try in $tclinc; do
1579 if test -f "$try/tcl.h"; then
1580 AC_MSG_RESULT($try/tcl.h)
1581 TCL_INC=$try
1582 break
1583 fi
1584 done
1585 if test -z "$TCL_INC"; then
1586 AC_MSG_RESULT(<not found>)
1587 SKIP_TCL=YES
1588 fi
1589 if test -z "$SKIP_TCL"; then
1590 AC_MSG_CHECKING(for location of tclConfig.sh script)
1591 if test "x$MACOSX" != "xyes"; then
1592 tclcnf=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001593 tclcnf="$tclcnf `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001594 else
1595 dnl For Mac OS X 10.3, use the OS-provided framework location
1596 tclcnf="/System/Library/Frameworks/Tcl.framework"
1597 fi
1598 for try in $tclcnf; do
1599 if test -f $try/tclConfig.sh; then
1600 AC_MSG_RESULT($try/tclConfig.sh)
1601 . $try/tclConfig.sh
1602 dnl use eval, because tcl 8.2 includes ${TCL_DBGX}
1603 TCL_LIBS=`eval echo "$TCL_LIB_SPEC $TCL_LIBS"`
1604 dnl Use $TCL_DEFS for -D_THREAD_SAFE et al. But only use the
Bram Moolenaardf3267e2005-01-25 22:07:05 +00001605 dnl "-D_ABC" items. Watch out for -DFOO=long\ long.
Bram Moolenaar4394bff2008-07-24 11:21:31 +00001606 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 +00001607 break
1608 fi
1609 done
1610 if test -z "$TCL_LIBS"; then
1611 AC_MSG_RESULT(<not found>)
1612 AC_MSG_CHECKING(for Tcl library by myself)
1613 tcllib=`echo $tclinc | sed s/include/lib/g`
Bram Moolenaar9b5d4dd2008-01-01 15:26:45 +00001614 tcllib="$tcllib `echo $tclinc | sed s/include/lib64/g`"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001615 for ext in .so .a ; do
1616 for ver in "" $tclver ; do
1617 for try in $tcllib ; do
1618 trylib=tcl$ver$ext
1619 if test -f $try/lib$trylib ; then
1620 AC_MSG_RESULT($try/lib$trylib)
1621 TCL_LIBS="-L$try -ltcl$ver -ldl -lm"
1622 if test "`(uname) 2>/dev/null`" = SunOS &&
1623 uname -r | grep '^5' >/dev/null; then
1624 TCL_LIBS="$TCL_LIBS -R $try"
1625 fi
1626 break 3
1627 fi
1628 done
1629 done
1630 done
1631 if test -z "$TCL_LIBS"; then
1632 AC_MSG_RESULT(<not found>)
1633 SKIP_TCL=YES
1634 fi
1635 fi
1636 if test -z "$SKIP_TCL"; then
1637 AC_DEFINE(FEAT_TCL)
1638 TCL_SRC=if_tcl.c
1639 TCL_OBJ=objects/if_tcl.o
1640 TCL_PRO=if_tcl.pro
1641 TCL_CFLAGS="-I$TCL_INC $TCL_DEFS"
1642 fi
1643 fi
1644 else
1645 AC_MSG_RESULT(too old; need Tcl version 8.0 or later)
1646 fi
1647 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001648 if test "$fail_if_missing" = "yes" -a -z "$TCL_SRC"; then
1649 AC_MSG_ERROR([could not configure Tcl])
1650 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001651fi
1652AC_SUBST(TCL_SRC)
1653AC_SUBST(TCL_OBJ)
1654AC_SUBST(TCL_PRO)
1655AC_SUBST(TCL_CFLAGS)
1656AC_SUBST(TCL_LIBS)
1657
1658AC_MSG_CHECKING(--enable-rubyinterp argument)
1659AC_ARG_ENABLE(rubyinterp,
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001660 [ --enable-rubyinterp[=OPTS] Include Ruby interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001661 [enable_rubyinterp="no"])
1662AC_MSG_RESULT($enable_rubyinterp)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001663if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar165641d2010-02-17 16:23:09 +01001664 AC_MSG_CHECKING(--with-ruby-command argument)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001665 AC_SUBST(vi_cv_path_ruby)
Bram Moolenaar948733a2011-05-05 18:10:16 +02001666 AC_ARG_WITH(ruby-command, [ --with-ruby-command=RUBY name of the Ruby command (default: ruby)],
1667 RUBY_CMD="$withval"; vi_cv_path_ruby="$withval"; AC_MSG_RESULT($RUBY_CMD),
1668 RUBY_CMD="ruby"; AC_MSG_RESULT(defaulting to $RUBY_CMD))
Bram Moolenaar165641d2010-02-17 16:23:09 +01001669 AC_PATH_PROG(vi_cv_path_ruby, $RUBY_CMD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001670 if test "X$vi_cv_path_ruby" != "X"; then
1671 AC_MSG_CHECKING(Ruby version)
Bram Moolenaare4efc3b2005-03-07 23:16:51 +00001672 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 +00001673 AC_MSG_RESULT(OK)
Bram Moolenaar81398892012-10-03 21:09:35 +02001674 AC_MSG_CHECKING(Ruby rbconfig)
1675 ruby_rbconfig="RbConfig"
1676 if ! $vi_cv_path_ruby -r rbconfig -e 'RbConfig' >/dev/null 2>/dev/null; then
1677 ruby_rbconfig="Config"
1678 fi
1679 AC_MSG_RESULT($ruby_rbconfig)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001680 AC_MSG_CHECKING(Ruby header files)
Bram Moolenaar81398892012-10-03 21:09:35 +02001681 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 +00001682 if test "X$rubyhdrdir" != "X"; then
1683 AC_MSG_RESULT($rubyhdrdir)
1684 RUBY_CFLAGS="-I$rubyhdrdir"
Bram Moolenaar81398892012-10-03 21:09:35 +02001685 rubyarch=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['arch']]"`
Bram Moolenaar165641d2010-02-17 16:23:09 +01001686 if test -d "$rubyhdrdir/$rubyarch"; then
1687 RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyhdrdir/$rubyarch"
1688 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001689 rubyversion=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['ruby_version']].gsub(/\./, '')[[0,2]]"`
Bram Moolenaar026a4452013-08-07 15:22:23 +02001690 if test "X$rubyversion" = "X"; then
1691 rubyversion=`$vi_cv_path_ruby -e "print ((VERSION rescue RUBY_VERSION)).gsub(/\./, '')[[0,2]]"`
1692 fi
Bram Moolenaar165641d2010-02-17 16:23:09 +01001693 RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
Bram Moolenaar81398892012-10-03 21:09:35 +02001694 rubylibs=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LIBS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001695 if test "X$rubylibs" != "X"; then
1696 RUBY_LIBS="$rubylibs"
1697 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001698 librubyarg=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBYARG']])"`
1699 librubya=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['LIBRUBY_A']])"`
Bram Moolenaarac499e32013-06-02 19:14:17 +02001700 rubylibdir=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG[['libdir']])"`
Bram Moolenaar948733a2011-05-05 18:10:16 +02001701 if test -f "$rubylibdir/$librubya"; then
1702 librubyarg="$librubyarg"
Bram Moolenaarac499e32013-06-02 19:14:17 +02001703 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
1704 elif test "$librubyarg" = "libruby.a"; then
1705 dnl required on Mac OS 10.3 where libruby.a doesn't exist
1706 librubyarg="-lruby"
1707 RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001708 fi
1709
1710 if test "X$librubyarg" != "X"; then
1711 RUBY_LIBS="$librubyarg $RUBY_LIBS"
1712 fi
Bram Moolenaar81398892012-10-03 21:09:35 +02001713 rubyldflags=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG[['LDFLAGS']]"`
Bram Moolenaar071d4272004-06-13 20:20:40 +00001714 if test "X$rubyldflags" != "X"; then
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001715 dnl Ruby on Mac OS X 10.5 adds "-arch" flags but these should only
1716 dnl be included if requested by passing --with-mac-arch to
1717 dnl configure, so strip these flags first (if present)
Bram Moolenaar5dff57d2010-07-24 16:19:44 +02001718 rubyldflags=`echo "$rubyldflags" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001719 if test "X$rubyldflags" != "X"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02001720 if test "X`echo \"$LDFLAGS\" | grep -F -e \"$rubyldflags\"`" = "X"; then
1721 LDFLAGS="$rubyldflags $LDFLAGS"
1722 fi
Bram Moolenaar996b6d82009-07-22 09:17:23 +00001723 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001724 fi
1725 RUBY_SRC="if_ruby.c"
1726 RUBY_OBJ="objects/if_ruby.o"
1727 RUBY_PRO="if_ruby.pro"
1728 AC_DEFINE(FEAT_RUBY)
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001729 if test "$enable_rubyinterp" = "dynamic"; then
Bram Moolenaar81398892012-10-03 21:09:35 +02001730 libruby=`$vi_cv_path_ruby -r rbconfig -e "puts $ruby_rbconfig::CONFIG[['LIBRUBY_SO']]"`
Bram Moolenaar3ca71f12010-10-27 16:49:47 +02001731 AC_DEFINE(DYNAMIC_RUBY)
1732 RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby\\\" -DDYNAMIC_RUBY_VER=$rubyversion $RUBY_CFLAGS"
1733 RUBY_LIBS=
1734 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001735 else
Bram Moolenaar165641d2010-02-17 16:23:09 +01001736 AC_MSG_RESULT(not found; disabling Ruby)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001737 fi
1738 else
1739 AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
1740 fi
1741 fi
Bram Moolenaarf788a062011-12-14 20:51:25 +01001742
1743 if test "$fail_if_missing" = "yes" -a -z "$RUBY_OBJ"; then
1744 AC_MSG_ERROR([could not configure Ruby])
1745 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001746fi
1747AC_SUBST(RUBY_SRC)
1748AC_SUBST(RUBY_OBJ)
1749AC_SUBST(RUBY_PRO)
1750AC_SUBST(RUBY_CFLAGS)
1751AC_SUBST(RUBY_LIBS)
1752
1753AC_MSG_CHECKING(--enable-cscope argument)
1754AC_ARG_ENABLE(cscope,
1755 [ --enable-cscope Include cscope interface.], ,
1756 [enable_cscope="no"])
1757AC_MSG_RESULT($enable_cscope)
1758if test "$enable_cscope" = "yes"; then
1759 AC_DEFINE(FEAT_CSCOPE)
1760fi
1761
1762AC_MSG_CHECKING(--enable-workshop argument)
1763AC_ARG_ENABLE(workshop,
1764 [ --enable-workshop Include Sun Visual Workshop support.], ,
1765 [enable_workshop="no"])
1766AC_MSG_RESULT($enable_workshop)
1767if test "$enable_workshop" = "yes"; then
1768 AC_DEFINE(FEAT_SUN_WORKSHOP)
1769 WORKSHOP_SRC="workshop.c integration.c"
1770 AC_SUBST(WORKSHOP_SRC)
1771 WORKSHOP_OBJ="objects/workshop.o objects/integration.o"
1772 AC_SUBST(WORKSHOP_OBJ)
1773 if test "${enable_gui-xxx}" = xxx; then
1774 enable_gui=motif
1775 fi
1776fi
1777
1778AC_MSG_CHECKING(--disable-netbeans argument)
1779AC_ARG_ENABLE(netbeans,
1780 [ --disable-netbeans Disable NetBeans integration support.],
1781 , [enable_netbeans="yes"])
1782if test "$enable_netbeans" = "yes"; then
1783 AC_MSG_RESULT(no)
1784 dnl On Solaris we need the socket and nsl library.
1785 AC_CHECK_LIB(socket, socket)
1786 AC_CHECK_LIB(nsl, gethostbyname)
1787 AC_MSG_CHECKING(whether compiling netbeans integration is possible)
1788 AC_TRY_LINK([
1789#include <stdio.h>
1790#include <stdlib.h>
1791#include <stdarg.h>
1792#include <fcntl.h>
1793#include <netdb.h>
1794#include <netinet/in.h>
1795#include <errno.h>
1796#include <sys/types.h>
1797#include <sys/socket.h>
1798 /* Check bitfields */
1799 struct nbbuf {
1800 unsigned int initDone:1;
1801 ushort signmaplen;
1802 };
1803 ], [
1804 /* Check creating a socket. */
1805 struct sockaddr_in server;
1806 (void)socket(AF_INET, SOCK_STREAM, 0);
1807 (void)htons(100);
1808 (void)gethostbyname("microsoft.com");
1809 if (errno == ECONNREFUSED)
1810 (void)connect(1, (struct sockaddr *)&server, sizeof(server));
1811 ],
1812 AC_MSG_RESULT(yes),
1813 AC_MSG_RESULT(no); enable_netbeans="no")
1814else
1815 AC_MSG_RESULT(yes)
1816fi
1817if test "$enable_netbeans" = "yes"; then
1818 AC_DEFINE(FEAT_NETBEANS_INTG)
1819 NETBEANS_SRC="netbeans.c"
1820 AC_SUBST(NETBEANS_SRC)
1821 NETBEANS_OBJ="objects/netbeans.o"
1822 AC_SUBST(NETBEANS_OBJ)
1823fi
1824
1825AC_MSG_CHECKING(--enable-sniff argument)
1826AC_ARG_ENABLE(sniff,
1827 [ --enable-sniff Include Sniff interface.], ,
1828 [enable_sniff="no"])
1829AC_MSG_RESULT($enable_sniff)
1830if test "$enable_sniff" = "yes"; then
1831 AC_DEFINE(FEAT_SNIFF)
1832 SNIFF_SRC="if_sniff.c"
1833 AC_SUBST(SNIFF_SRC)
1834 SNIFF_OBJ="objects/if_sniff.o"
1835 AC_SUBST(SNIFF_OBJ)
1836fi
1837
1838AC_MSG_CHECKING(--enable-multibyte argument)
1839AC_ARG_ENABLE(multibyte,
1840 [ --enable-multibyte Include multibyte editing support.], ,
1841 [enable_multibyte="no"])
1842AC_MSG_RESULT($enable_multibyte)
1843if test "$enable_multibyte" = "yes"; then
1844 AC_DEFINE(FEAT_MBYTE)
1845fi
1846
1847AC_MSG_CHECKING(--enable-hangulinput argument)
1848AC_ARG_ENABLE(hangulinput,
1849 [ --enable-hangulinput Include Hangul input support.], ,
1850 [enable_hangulinput="no"])
1851AC_MSG_RESULT($enable_hangulinput)
1852
1853AC_MSG_CHECKING(--enable-xim argument)
1854AC_ARG_ENABLE(xim,
1855 [ --enable-xim Include XIM input support.],
1856 AC_MSG_RESULT($enable_xim),
1857 [enable_xim="auto"; AC_MSG_RESULT(defaulting to auto)])
Bram Moolenaar071d4272004-06-13 20:20:40 +00001858
1859AC_MSG_CHECKING(--enable-fontset argument)
1860AC_ARG_ENABLE(fontset,
1861 [ --enable-fontset Include X fontset output support.], ,
1862 [enable_fontset="no"])
1863AC_MSG_RESULT($enable_fontset)
1864dnl defining FEAT_XFONTSET is delayed, so that it can be disabled for no GUI
1865
1866test -z "$with_x" && with_x=yes
1867test "${enable_gui-yes}" != no -a "x$MACOSX" != "xyes" -a "x$QNX" != "xyes" && with_x=yes
1868if test "$with_x" = no; then
1869 AC_MSG_RESULT(defaulting to: don't HAVE_X11)
1870else
1871 dnl Do this check early, so that its failure can override user requests.
1872
1873 AC_PATH_PROG(xmkmfpath, xmkmf)
1874
1875 AC_PATH_XTRA
1876
Bram Moolenaar2c704a72010-06-03 21:17:25 +02001877 dnl On z/OS Unix the X libraries are DLLs. To use them the code must
Bram Moolenaar071d4272004-06-13 20:20:40 +00001878 dnl be compiled with a special option.
1879 dnl Also add SM, ICE and Xmu to X_EXTRA_LIBS.
Bram Moolenaar2c704a72010-06-03 21:17:25 +02001880 if test "$zOSUnix" = "yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00001881 CFLAGS="$CFLAGS -W c,dll"
1882 LDFLAGS="$LDFLAGS -W l,dll"
1883 X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE -lXmu"
1884 fi
1885
1886 dnl On my HPUX system the X include dir is found, but the lib dir not.
1887 dnl This is a desparate try to fix this.
1888
1889 if test -d "$x_includes" && test ! -d "$x_libraries"; then
1890 x_libraries=`echo "$x_includes" | sed s/include/lib/`
1891 AC_MSG_RESULT(Corrected X libraries to $x_libraries)
1892 X_LIBS="$X_LIBS -L$x_libraries"
1893 if test "`(uname) 2>/dev/null`" = SunOS &&
1894 uname -r | grep '^5' >/dev/null; then
1895 X_LIBS="$X_LIBS -R $x_libraries"
1896 fi
1897 fi
1898
1899 if test -d "$x_libraries" && test ! -d "$x_includes"; then
1900 x_includes=`echo "$x_libraries" | sed s/lib/include/`
1901 AC_MSG_RESULT(Corrected X includes to $x_includes)
1902 X_CFLAGS="$X_CFLAGS -I$x_includes"
1903 fi
1904
1905 dnl Remove "-I/usr/include " from X_CFLAGS, should not be needed.
1906 X_CFLAGS="`echo $X_CFLAGS\ | sed 's%-I/usr/include %%'`"
1907 dnl Remove "-L/usr/lib " from X_LIBS, should not be needed.
1908 X_LIBS="`echo $X_LIBS\ | sed 's%-L/usr/lib %%'`"
1909 dnl Same for "-R/usr/lib ".
1910 X_LIBS="`echo $X_LIBS\ | sed -e 's%-R/usr/lib %%' -e 's%-R /usr/lib %%'`"
1911
1912
1913 dnl Check if the X11 header files are correctly installed. On some systems
Bram Moolenaar00ca2842008-06-26 20:14:00 +00001914 dnl Xlib.h includes files that don't exist. On some systems X11/Intrinsic.h
1915 dnl is missing.
Bram Moolenaar071d4272004-06-13 20:20:40 +00001916 AC_MSG_CHECKING(if X11 header files can be found)
1917 cflags_save=$CFLAGS
1918 CFLAGS="$CFLAGS $X_CFLAGS"
Bram Moolenaar00ca2842008-06-26 20:14:00 +00001919 AC_TRY_COMPILE([#include <X11/Xlib.h>
1920#include <X11/Intrinsic.h>], ,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001921 AC_MSG_RESULT(yes),
1922 AC_MSG_RESULT(no); no_x=yes)
1923 CFLAGS=$cflags_save
1924
1925 if test "${no_x-no}" = yes; then
1926 with_x=no
1927 else
1928 AC_DEFINE(HAVE_X11)
1929 X_LIB="-lXt -lX11";
1930 AC_SUBST(X_LIB)
1931
1932 ac_save_LDFLAGS="$LDFLAGS"
1933 LDFLAGS="-L$x_libraries $LDFLAGS"
1934
1935 dnl Check for -lXdmcp (needed on SunOS 4.1.4)
1936 dnl For HP-UX 10.20 it must be before -lSM -lICE
1937 AC_CHECK_LIB(Xdmcp, _XdmcpAuthDoIt, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lXdmcp"],,
1938 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXdmcp])
1939
1940 dnl Some systems need -lnsl -lsocket when testing for ICE.
1941 dnl The check above doesn't do this, try here (again). Also needed to get
1942 dnl them after Xdmcp. link.sh will remove them when not needed.
1943 dnl Check for other function than above to avoid the cached value
1944 AC_CHECK_LIB(ICE, IceOpenConnection,
1945 [X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE"],, [$X_EXTRA_LIBS])
1946
1947 dnl Check for -lXpm (needed for some versions of Motif)
1948 LDFLAGS="$X_LIBS $ac_save_LDFLAGS"
1949 AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [X_PRE_LIBS="$X_PRE_LIBS -lXpm"],,
1950 [-lXt $X_PRE_LIBS -lXpm -lX11 $X_EXTRA_LIBS])
1951
1952 dnl Check that the X11 header files don't use implicit declarations
1953 AC_MSG_CHECKING(if X11 header files implicitly declare return values)
1954 cflags_save=$CFLAGS
Bram Moolenaard1864592013-05-04 04:40:15 +02001955 dnl -Werror is GCC only, others like Solaris Studio might not like it
1956 if test "$GCC" = yes; then
1957 CFLAGS="$CFLAGS $X_CFLAGS -Werror"
1958 else
1959 CFLAGS="$CFLAGS $X_CFLAGS"
1960 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00001961 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
1962 AC_MSG_RESULT(no),
1963 CFLAGS="$CFLAGS -Wno-implicit-int"
1964 AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
1965 AC_MSG_RESULT(yes); cflags_save="$cflags_save -Wno-implicit-int",
1966 AC_MSG_RESULT(test failed)
1967 )
1968 )
1969 CFLAGS=$cflags_save
1970
1971 LDFLAGS="$ac_save_LDFLAGS"
1972
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +00001973 AC_MSG_CHECKING(size of wchar_t is 2 bytes)
1974 AC_CACHE_VAL(ac_cv_small_wchar_t,
1975 [AC_TRY_RUN([
1976#include <X11/Xlib.h>
1977#if STDC_HEADERS
1978# include <stdlib.h>
1979# include <stddef.h>
1980#endif
1981 main()
1982 {
1983 if (sizeof(wchar_t) <= 2)
1984 exit(1);
1985 exit(0);
1986 }],
1987 ac_cv_small_wchar_t="no",
1988 ac_cv_small_wchar_t="yes",
1989 AC_MSG_ERROR(failed to compile test program))])
1990 AC_MSG_RESULT($ac_cv_small_wchar_t)
1991 if test "x$ac_cv_small_wchar_t" = "xyes" ; then
1992 AC_DEFINE(SMALL_WCHAR_T)
1993 fi
1994
Bram Moolenaar071d4272004-06-13 20:20:40 +00001995 fi
1996fi
1997
Bram Moolenaara7fc0102005-05-18 22:17:12 +00001998test "x$with_x" = xno -a "x$MACOSX" != "xyes" -a "x$QNX" != "xyes" && enable_gui=no
Bram Moolenaar071d4272004-06-13 20:20:40 +00001999
2000AC_MSG_CHECKING(--enable-gui argument)
2001AC_ARG_ENABLE(gui,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002002 [ --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 +00002003
2004dnl Canonicalize the --enable-gui= argument so that it can be easily compared.
2005dnl Do not use character classes for portability with old tools.
2006enable_gui_canon=`echo "_$enable_gui" | \
2007 sed 's/[[ _+-]]//g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
2008
2009dnl Skip everything by default.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002010SKIP_GTK2=YES
2011SKIP_GNOME=YES
2012SKIP_MOTIF=YES
2013SKIP_ATHENA=YES
2014SKIP_NEXTAW=YES
2015SKIP_PHOTON=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002016SKIP_CARBON=YES
2017GUITYPE=NONE
2018
Bram Moolenaarb11160e2005-01-04 21:31:43 +00002019if test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002020 SKIP_PHOTON=
2021 case "$enable_gui_canon" in
2022 no) AC_MSG_RESULT(no GUI support)
2023 SKIP_PHOTON=YES ;;
2024 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
2025 auto) AC_MSG_RESULT(auto - automatic GUI support) ;;
2026 photon) AC_MSG_RESULT(Photon GUI support) ;;
2027 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2028 SKIP_PHOTON=YES ;;
2029 esac
2030
2031elif test "x$MACOSX" = "xyes" -a "x$with_x" = "xno" ; then
2032 SKIP_CARBON=
2033 case "$enable_gui_canon" in
2034 no) AC_MSG_RESULT(no GUI support)
2035 SKIP_CARBON=YES ;;
2036 yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
Bram Moolenaar164fca32010-07-14 13:58:07 +02002037 auto) AC_MSG_RESULT(auto - Carbon GUI is outdated - disable GUI support)
2038 SKIP_CARBON=YES ;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002039 carbon) AC_MSG_RESULT(Carbon GUI support) ;;
2040 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
2041 SKIP_CARBON=YES ;;
2042 esac
2043
2044else
2045
Bram Moolenaar071d4272004-06-13 20:20:40 +00002046 case "$enable_gui_canon" in
2047 no|none) AC_MSG_RESULT(no GUI support) ;;
2048 yes|""|auto) AC_MSG_RESULT(yes/auto - automatic GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002049 SKIP_GTK2=
2050 SKIP_GNOME=
2051 SKIP_MOTIF=
2052 SKIP_ATHENA=
2053 SKIP_NEXTAW=
2054 SKIP_CARBON=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002055 gtk2) AC_MSG_RESULT(GTK+ 2.x GUI support)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002056 SKIP_GTK2=;;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002057 gnome2) AC_MSG_RESULT(GNOME 2.x GUI support)
2058 SKIP_GNOME=
Bram Moolenaar071d4272004-06-13 20:20:40 +00002059 SKIP_GTK2=;;
2060 motif) AC_MSG_RESULT(Motif GUI support)
2061 SKIP_MOTIF=;;
2062 athena) AC_MSG_RESULT(Athena GUI support)
2063 SKIP_ATHENA=;;
2064 nextaw) AC_MSG_RESULT(neXtaw GUI support)
2065 SKIP_NEXTAW=;;
2066 *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
2067 esac
2068
2069fi
2070
Bram Moolenaar071d4272004-06-13 20:20:40 +00002071if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \
2072 -a "$enable_gui_canon" != "gnome2"; then
2073 AC_MSG_CHECKING(whether or not to look for GTK+ 2)
2074 AC_ARG_ENABLE(gtk2-check,
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002075 [ --enable-gtk2-check If auto-select GUI, check for GTK+ 2 [default=yes]],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002076 , enable_gtk2_check="yes")
2077 AC_MSG_RESULT($enable_gtk2_check)
2078 if test "x$enable_gtk2_check" = "xno"; then
2079 SKIP_GTK2=YES
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002080 SKIP_GNOME=YES
Bram Moolenaar071d4272004-06-13 20:20:40 +00002081 fi
2082fi
2083
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002084if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002085 AC_MSG_CHECKING(whether or not to look for GNOME)
2086 AC_ARG_ENABLE(gnome-check,
2087 [ --enable-gnome-check If GTK GUI, check for GNOME [default=no]],
2088 , enable_gnome_check="no")
2089 AC_MSG_RESULT($enable_gnome_check)
2090 if test "x$enable_gnome_check" = "xno"; then
2091 SKIP_GNOME=YES
2092 fi
2093fi
2094
2095if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then
2096 AC_MSG_CHECKING(whether or not to look for Motif)
2097 AC_ARG_ENABLE(motif-check,
2098 [ --enable-motif-check If auto-select GUI, check for Motif [default=yes]],
2099 , enable_motif_check="yes")
2100 AC_MSG_RESULT($enable_motif_check)
2101 if test "x$enable_motif_check" = "xno"; then
2102 SKIP_MOTIF=YES
2103 fi
2104fi
2105
2106if test "x$SKIP_ATHENA" != "xYES" -a "$enable_gui_canon" != "athena"; then
2107 AC_MSG_CHECKING(whether or not to look for Athena)
2108 AC_ARG_ENABLE(athena-check,
2109 [ --enable-athena-check If auto-select GUI, check for Athena [default=yes]],
2110 , enable_athena_check="yes")
2111 AC_MSG_RESULT($enable_athena_check)
2112 if test "x$enable_athena_check" = "xno"; then
2113 SKIP_ATHENA=YES
2114 fi
2115fi
2116
2117if test "x$SKIP_NEXTAW" != "xYES" -a "$enable_gui_canon" != "nextaw"; then
2118 AC_MSG_CHECKING(whether or not to look for neXtaw)
2119 AC_ARG_ENABLE(nextaw-check,
2120 [ --enable-nextaw-check If auto-select GUI, check for neXtaw [default=yes]],
2121 , enable_nextaw_check="yes")
2122 AC_MSG_RESULT($enable_nextaw_check);
2123 if test "x$enable_nextaw_check" = "xno"; then
2124 SKIP_NEXTAW=YES
2125 fi
2126fi
2127
2128if test "x$SKIP_CARBON" != "xYES" -a "$enable_gui_canon" != "carbon"; then
2129 AC_MSG_CHECKING(whether or not to look for Carbon)
2130 AC_ARG_ENABLE(carbon-check,
2131 [ --enable-carbon-check If auto-select GUI, check for Carbon [default=yes]],
2132 , enable_carbon_check="yes")
2133 AC_MSG_RESULT($enable_carbon_check);
2134 if test "x$enable_carbon_check" = "xno"; then
2135 SKIP_CARBON=YES
2136 fi
2137fi
2138
Bram Moolenaar843ee412004-06-30 16:16:41 +00002139
Bram Moolenaar071d4272004-06-13 20:20:40 +00002140if test "x$MACOSX" = "xyes" -a -z "$SKIP_CARBON" -a "x$CARBON" = "xyes"; then
2141 AC_MSG_CHECKING(for Carbon GUI)
Bram Moolenaar14716812006-05-04 21:54:08 +00002142 dnl already did the check, just give the message
Bram Moolenaar071d4272004-06-13 20:20:40 +00002143 AC_MSG_RESULT(yes);
2144 GUITYPE=CARBONGUI
Bram Moolenaare344bea2005-09-01 20:46:49 +00002145 if test "$VIMNAME" = "vim"; then
2146 VIMNAME=Vim
2147 fi
Bram Moolenaar14716812006-05-04 21:54:08 +00002148
Bram Moolenaar164fca32010-07-14 13:58:07 +02002149 if test "x$MACARCH" = "xboth"; then
2150 CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk/Developer/Headers/FlatCarbon"
2151 else
2152 CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/Headers/FlatCarbon"
2153 fi
2154
Bram Moolenaar14716812006-05-04 21:54:08 +00002155 dnl Default install directory is not /usr/local
2156 if test x$prefix = xNONE; then
2157 prefix=/Applications
2158 fi
2159
2160 dnl Sorry for the hard coded default
2161 datadir='${prefix}/Vim.app/Contents/Resources'
2162
Bram Moolenaar071d4272004-06-13 20:20:40 +00002163 dnl skip everything else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002164 SKIP_GTK2=YES;
2165 SKIP_GNOME=YES;
2166 SKIP_MOTIF=YES;
2167 SKIP_ATHENA=YES;
2168 SKIP_NEXTAW=YES;
2169 SKIP_PHOTON=YES;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002170 SKIP_CARBON=YES
2171fi
2172
Bram Moolenaar071d4272004-06-13 20:20:40 +00002173dnl define an autoconf function to check for a specified version of GTK, and
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002174dnl try to compile/link a GTK program.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002175dnl
2176dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002177dnl Test for GTK, and define GTK_CFLAGS, GTK_LIBDIR and GTK_LIBS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002178dnl
2179AC_DEFUN(AM_PATH_GTK,
2180[
2181 if test "X$GTK_CONFIG" != "Xno" -o "X$PKG_CONFIG" != "Xno"; then
2182 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002183 min_gtk_version=ifelse([$1], ,2.2.0,$1)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002184 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
2185 no_gtk=""
2186 if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
2187 && $PKG_CONFIG --exists gtk+-2.0; then
2188 {
2189 dnl We should be using PKG_CHECK_MODULES() instead of this hack.
2190 dnl But I guess the dependency on pkgconfig.m4 is not wanted or
2191 dnl something like that.
2192 GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0`
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00002193 GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-2.0`
Bram Moolenaar071d4272004-06-13 20:20:40 +00002194 GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0`
2195 gtk_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2196 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
2197 gtk_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2198 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
2199 gtk_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2200 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
2201 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002202 else
2203 no_gtk=yes
2204 fi
2205
2206 if test "x$enable_gtktest" = "xyes" -a "x$no_gtk" = "x"; then
2207 {
2208 ac_save_CFLAGS="$CFLAGS"
2209 ac_save_LIBS="$LIBS"
2210 CFLAGS="$CFLAGS $GTK_CFLAGS"
2211 LIBS="$LIBS $GTK_LIBS"
2212
2213 dnl
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002214 dnl Now check if the installed GTK is sufficiently new.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002215 dnl
2216 rm -f conf.gtktest
2217 AC_TRY_RUN([
2218#include <gtk/gtk.h>
2219#include <stdio.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00002220#if STDC_HEADERS
2221# include <stdlib.h>
2222# include <stddef.h>
2223#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002224
2225int
2226main ()
2227{
2228int major, minor, micro;
2229char *tmp_version;
2230
2231system ("touch conf.gtktest");
2232
2233/* HP/UX 9 (%@#!) writes to sscanf strings */
2234tmp_version = g_strdup("$min_gtk_version");
2235if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
2236 printf("%s, bad version string\n", "$min_gtk_version");
2237 exit(1);
2238 }
2239
2240if ((gtk_major_version > major) ||
2241 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
2242 ((gtk_major_version == major) && (gtk_minor_version == minor) &&
2243 (gtk_micro_version >= micro)))
2244{
2245 return 0;
2246}
2247return 1;
2248}
2249],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
2250 CFLAGS="$ac_save_CFLAGS"
2251 LIBS="$ac_save_LIBS"
2252 }
2253 fi
2254 if test "x$no_gtk" = x ; then
2255 if test "x$enable_gtktest" = "xyes"; then
2256 AC_MSG_RESULT(yes; found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2257 else
2258 AC_MSG_RESULT(found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
2259 fi
2260 ifelse([$2], , :, [$2])
2261 else
2262 {
2263 AC_MSG_RESULT(no)
2264 GTK_CFLAGS=""
2265 GTK_LIBS=""
2266 ifelse([$3], , :, [$3])
2267 }
2268 fi
2269 }
2270 else
2271 GTK_CFLAGS=""
2272 GTK_LIBS=""
2273 ifelse([$3], , :, [$3])
2274 fi
2275 AC_SUBST(GTK_CFLAGS)
2276 AC_SUBST(GTK_LIBS)
2277 rm -f conf.gtktest
2278])
2279
2280dnl ---------------------------------------------------------------------------
2281dnl gnome
2282dnl ---------------------------------------------------------------------------
2283AC_DEFUN([GNOME_INIT_HOOK],
2284[
2285 AC_SUBST(GNOME_LIBS)
2286 AC_SUBST(GNOME_LIBDIR)
2287 AC_SUBST(GNOME_INCLUDEDIR)
2288
2289 AC_ARG_WITH(gnome-includes,
2290 [ --with-gnome-includes=DIR Specify location of GNOME headers],
2291 [CFLAGS="$CFLAGS -I$withval"]
2292 )
2293
2294 AC_ARG_WITH(gnome-libs,
2295 [ --with-gnome-libs=DIR Specify location of GNOME libs],
2296 [LDFLAGS="$LDFLAGS -L$withval" gnome_prefix=$withval]
2297 )
2298
2299 AC_ARG_WITH(gnome,
2300 [ --with-gnome Specify prefix for GNOME files],
2301 if test x$withval = xyes; then
2302 want_gnome=yes
2303 ifelse([$1], [], :, [$1])
2304 else
2305 if test "x$withval" = xno; then
2306 want_gnome=no
2307 else
2308 want_gnome=yes
2309 LDFLAGS="$LDFLAGS -L$withval/lib"
2310 CFLAGS="$CFLAGS -I$withval/include"
2311 gnome_prefix=$withval/lib
2312 fi
2313 fi,
2314 want_gnome=yes)
2315
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002316 if test "x$want_gnome" = xyes; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002317 {
2318 AC_MSG_CHECKING(for libgnomeui-2.0)
2319 if $PKG_CONFIG --exists libgnomeui-2.0; then
2320 AC_MSG_RESULT(yes)
2321 GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0`
2322 GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0`
2323 GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0`
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002324
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002325 dnl On FreeBSD we need -pthread but pkg-config doesn't include it.
2326 dnl This might not be the right way but it works for me...
2327 AC_MSG_CHECKING(for FreeBSD)
2328 if test "`(uname) 2>/dev/null`" = FreeBSD; then
2329 AC_MSG_RESULT(yes, adding -pthread)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002330 GNOME_INCLUDEDIR="$GNOME_INCLUDEDIR -D_THREAD_SAFE"
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002331 GNOME_LIBS="$GNOME_LIBS -pthread"
2332 else
2333 AC_MSG_RESULT(no)
2334 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002335 $1
2336 else
2337 AC_MSG_RESULT(not found)
2338 if test "x$2" = xfail; then
2339 AC_MSG_ERROR(Could not find libgnomeui-2.0 via pkg-config)
2340 fi
2341 fi
2342 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00002343 fi
2344])
2345
2346AC_DEFUN([GNOME_INIT],[
2347 GNOME_INIT_HOOK([],fail)
2348])
2349
2350
2351dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002352dnl Check for GTK2. If it fails, then continue on for Motif as before...
Bram Moolenaar071d4272004-06-13 20:20:40 +00002353dnl ---------------------------------------------------------------------------
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002354if test -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002355
2356 AC_MSG_CHECKING(--disable-gtktest argument)
2357 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
2358 , enable_gtktest=yes)
2359 if test "x$enable_gtktest" = "xyes" ; then
2360 AC_MSG_RESULT(gtk test enabled)
2361 else
2362 AC_MSG_RESULT(gtk test disabled)
2363 fi
2364
Bram Moolenaar071d4272004-06-13 20:20:40 +00002365 if test "X$PKG_CONFIG" = "X"; then
2366 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
2367 fi
2368
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002369 if test "x$PKG_CONFIG" != "xno"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002370 dnl First try finding version 2.2.0 or later. The 2.0.x series has
2371 dnl problems (bold fonts, --remote doesn't work).
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002372 AM_PATH_GTK(2.2.0,
2373 [GUI_LIB_LOC="$GTK_LIBDIR"
2374 GTK_LIBNAME="$GTK_LIBS"
2375 GUI_INC_LOC="$GTK_CFLAGS"], )
2376 if test "x$GTK_CFLAGS" != "x"; then
2377 SKIP_ATHENA=YES
2378 SKIP_NEXTAW=YES
2379 SKIP_MOTIF=YES
2380 GUITYPE=GTK
2381 AC_SUBST(GTK_LIBNAME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002382 fi
2383 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002384 if test "x$GUITYPE" = "xGTK"; then
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002385 if test "$gtk_minor_version" = 1 -a "0$gtk_micro_version" -ge 1 \
2386 || test "0$gtk_minor_version" -ge 2; then
2387 AC_DEFINE(HAVE_GTK_MULTIHEAD)
2388 fi
2389 dnl
2390 dnl if GTK exists, then check for GNOME.
2391 dnl
2392 if test -z "$SKIP_GNOME"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002393 {
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002394 GNOME_INIT_HOOK([have_gnome=yes])
2395 if test "x$have_gnome" = xyes ; then
2396 AC_DEFINE(FEAT_GUI_GNOME)
2397 GUI_INC_LOC="$GUI_INC_LOC $GNOME_INCLUDEDIR"
2398 GTK_LIBNAME="$GTK_LIBNAME $GNOME_LIBDIR $GNOME_LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002399 fi
2400 }
2401 fi
2402 fi
2403fi
2404
2405dnl Check for Motif include files location.
2406dnl The LAST one found is used, this makes the highest version to be used,
2407dnl e.g. when Motif1.2 and Motif2.0 are both present.
2408
2409if test -z "$SKIP_MOTIF"; then
2410 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"
2411 dnl Remove "-I" from before $GUI_INC_LOC if it's there
2412 GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`"
2413
2414 AC_MSG_CHECKING(for location of Motif GUI includes)
2415 gui_includes="`echo $x_includes|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC"
2416 GUI_INC_LOC=
2417 for try in $gui_includes; do
2418 if test -f "$try/Xm/Xm.h"; then
2419 GUI_INC_LOC=$try
2420 fi
2421 done
2422 if test -n "$GUI_INC_LOC"; then
2423 if test "$GUI_INC_LOC" = /usr/include; then
2424 GUI_INC_LOC=
2425 AC_MSG_RESULT(in default path)
2426 else
2427 AC_MSG_RESULT($GUI_INC_LOC)
2428 fi
2429 else
2430 AC_MSG_RESULT(<not found>)
2431 SKIP_MOTIF=YES
2432 fi
2433fi
2434
2435dnl Check for Motif library files location. In the same order as the include
2436dnl files, to avoid a mixup if several versions are present
2437
2438if test -z "$SKIP_MOTIF"; then
2439 AC_MSG_CHECKING(--with-motif-lib argument)
2440 AC_ARG_WITH(motif-lib,
2441 [ --with-motif-lib=STRING Library for Motif ],
2442 [ MOTIF_LIBNAME="${withval}" ] )
2443
2444 if test -n "$MOTIF_LIBNAME"; then
2445 AC_MSG_RESULT($MOTIF_LIBNAME)
2446 GUI_LIB_LOC=
2447 else
2448 AC_MSG_RESULT(no)
2449
2450 dnl Remove "-L" from before $GUI_LIB_LOC if it's there
2451 GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
2452
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002453 dnl Ubuntu has libXm.so in /usr/lib/i386-linux-gnu and elsewhere. The
2454 dnl linker will figure out which one to use, we only check if one exists.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002455 AC_MSG_CHECKING(for location of Motif GUI libs)
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002456 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 +00002457 GUI_LIB_LOC=
2458 for try in $gui_libs; do
Bram Moolenaar325b7a22004-07-05 15:58:32 +00002459 for libtry in "$try"/libXm.a "$try"/libXm.so* "$try"/libXm.sl "$try"/libXm.dylib; do
Bram Moolenaar071d4272004-06-13 20:20:40 +00002460 if test -f "$libtry"; then
2461 GUI_LIB_LOC=$try
2462 fi
2463 done
2464 done
2465 if test -n "$GUI_LIB_LOC"; then
2466 dnl Remove /usr/lib, it causes trouble on some systems
Bram Moolenaar6324c3b2013-06-17 20:27:18 +02002467 if test "$GUI_LIB_LOC" = /usr/lib \
2468 -o "$GUI_LIB_LOC" = /usr/lib/i386-linux-gnu \
2469 -o "$GUI_LIB_LOC" = /usr/lib/x86_64-linux-gnu; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002470 GUI_LIB_LOC=
2471 AC_MSG_RESULT(in default path)
2472 else
2473 if test -n "$GUI_LIB_LOC"; then
2474 AC_MSG_RESULT($GUI_LIB_LOC)
2475 if test "`(uname) 2>/dev/null`" = SunOS &&
2476 uname -r | grep '^5' >/dev/null; then
2477 GUI_LIB_LOC="$GUI_LIB_LOC -R $GUI_LIB_LOC"
2478 fi
2479 fi
2480 fi
2481 MOTIF_LIBNAME=-lXm
2482 else
2483 AC_MSG_RESULT(<not found>)
2484 SKIP_MOTIF=YES
2485 fi
2486 fi
2487fi
2488
2489if test -z "$SKIP_MOTIF"; then
2490 SKIP_ATHENA=YES
2491 SKIP_NEXTAW=YES
2492 GUITYPE=MOTIF
2493 AC_SUBST(MOTIF_LIBNAME)
2494fi
2495
2496dnl Check if the Athena files can be found
2497
2498GUI_X_LIBS=
2499
2500if test -z "$SKIP_ATHENA"; then
2501 AC_MSG_CHECKING(if Athena header files can be found)
2502 cflags_save=$CFLAGS
2503 CFLAGS="$CFLAGS $X_CFLAGS"
2504 AC_TRY_COMPILE([
2505#include <X11/Intrinsic.h>
2506#include <X11/Xaw/Paned.h>], ,
2507 AC_MSG_RESULT(yes),
2508 AC_MSG_RESULT(no); SKIP_ATHENA=YES )
2509 CFLAGS=$cflags_save
2510fi
2511
2512if test -z "$SKIP_ATHENA"; then
2513 GUITYPE=ATHENA
2514fi
2515
2516if test -z "$SKIP_NEXTAW"; then
2517 AC_MSG_CHECKING(if neXtaw header files can be found)
2518 cflags_save=$CFLAGS
2519 CFLAGS="$CFLAGS $X_CFLAGS"
2520 AC_TRY_COMPILE([
2521#include <X11/Intrinsic.h>
2522#include <X11/neXtaw/Paned.h>], ,
2523 AC_MSG_RESULT(yes),
2524 AC_MSG_RESULT(no); SKIP_NEXTAW=YES )
2525 CFLAGS=$cflags_save
2526fi
2527
2528if test -z "$SKIP_NEXTAW"; then
2529 GUITYPE=NEXTAW
2530fi
2531
2532if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
2533 dnl Prepend -I and -L to $GUI_INC_LOC and $GUI_LIB_LOC if not empty
2534 dnl Avoid adding it when it twice
2535 if test -n "$GUI_INC_LOC"; then
2536 GUI_INC_LOC=-I"`echo $GUI_INC_LOC|sed 's%-I%%'`"
2537 fi
2538 if test -n "$GUI_LIB_LOC"; then
2539 GUI_LIB_LOC=-L"`echo $GUI_LIB_LOC|sed 's%-L%%'`"
2540 fi
2541
2542 dnl Check for -lXext and then for -lXmu
2543 ldflags_save=$LDFLAGS
2544 LDFLAGS="$X_LIBS $LDFLAGS"
2545 AC_CHECK_LIB(Xext, XShapeQueryExtension, [GUI_X_LIBS="-lXext"],,
2546 [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2547 dnl For Solaris we need -lw and -ldl before linking with -lXmu works.
2548 AC_CHECK_LIB(w, wslen, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lw"],,
2549 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2550 AC_CHECK_LIB(dl, dlsym, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldl"],,
2551 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2552 AC_CHECK_LIB(Xmu, XmuCreateStippledPixmap, [GUI_X_LIBS="-lXmu $GUI_X_LIBS"],,
2553 [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2554 if test -z "$SKIP_MOTIF"; then
2555 AC_CHECK_LIB(Xp, XpEndJob, [GUI_X_LIBS="-lXp $GUI_X_LIBS"],,
2556 [$GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
2557 fi
2558 LDFLAGS=$ldflags_save
2559
2560 dnl Execute xmkmf to figure out if -DNARROWPROTO is needed.
2561 AC_MSG_CHECKING(for extra X11 defines)
2562 NARROW_PROTO=
2563 rm -fr conftestdir
2564 if mkdir conftestdir; then
2565 cd conftestdir
2566 cat > Imakefile <<'EOF'
2567acfindx:
2568 @echo 'NARROW_PROTO="${PROTO_DEFINES}"'
2569EOF
2570 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
2571 eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
2572 fi
2573 cd ..
2574 rm -fr conftestdir
2575 fi
2576 if test -z "$NARROW_PROTO"; then
2577 AC_MSG_RESULT(no)
2578 else
2579 AC_MSG_RESULT($NARROW_PROTO)
2580 fi
2581 AC_SUBST(NARROW_PROTO)
2582fi
2583
2584dnl Look for XSMP support - but don't necessarily restrict it to X11 GUIs
2585dnl use the X11 include path
2586if test "$enable_xsmp" = "yes"; then
2587 cppflags_save=$CPPFLAGS
2588 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2589 AC_CHECK_HEADERS(X11/SM/SMlib.h)
2590 CPPFLAGS=$cppflags_save
2591fi
2592
2593
Bram Moolenaare667c952010-07-05 22:57:59 +02002594if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF" -o -z "$SKIP_GTK2"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002595 dnl Check for X11/xpm.h and X11/Sunkeysym.h with the GUI include path
2596 cppflags_save=$CPPFLAGS
2597 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2598 AC_CHECK_HEADERS(X11/xpm.h X11/Sunkeysym.h)
2599
2600 dnl automatically disable XIM when XIMtext isn't in X11/Xlib.h
2601 if test ! "$enable_xim" = "no"; then
2602 AC_MSG_CHECKING(for XIMText in X11/Xlib.h)
2603 AC_EGREP_CPP(XIMText, [#include <X11/Xlib.h>],
2604 AC_MSG_RESULT(yes),
2605 AC_MSG_RESULT(no; xim has been disabled); enable_xim = "no")
2606 fi
2607 CPPFLAGS=$cppflags_save
2608
2609 dnl automatically enable XIM when hangul input isn't enabled
2610 if test "$enable_xim" = "auto" -a "$enable_hangulinput" != "yes" \
2611 -a "x$GUITYPE" != "xNONE" ; then
2612 AC_MSG_RESULT(X GUI selected; xim has been enabled)
2613 enable_xim="yes"
2614 fi
2615fi
2616
2617if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
2618 cppflags_save=$CPPFLAGS
2619 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00002620dnl Xmu/Editres.h may exist but can only be used after including Intrinsic.h
2621 AC_MSG_CHECKING([for X11/Xmu/Editres.h])
2622 AC_TRY_COMPILE([
2623#include <X11/Intrinsic.h>
2624#include <X11/Xmu/Editres.h>],
2625 [int i; i = 0;],
2626 AC_MSG_RESULT(yes)
2627 AC_DEFINE(HAVE_X11_XMU_EDITRES_H),
2628 AC_MSG_RESULT(no))
Bram Moolenaar071d4272004-06-13 20:20:40 +00002629 CPPFLAGS=$cppflags_save
2630fi
2631
2632dnl Only use the Xm directory when compiling Motif, don't use it for Athena
2633if test -z "$SKIP_MOTIF"; then
2634 cppflags_save=$CPPFLAGS
2635 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
Bram Moolenaar77c19352012-06-13 19:19:41 +02002636 if test "$zOSUnix" = "yes"; then
2637 xmheader="Xm/Xm.h"
2638 else
2639 xmheader="Xm/Xm.h Xm/XpmP.h Xm/JoinSideT.h Xm/TraitP.h Xm/Manager.h
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02002640 Xm/UnhighlightT.h Xm/Notebook.h"
Bram Moolenaar77c19352012-06-13 19:19:41 +02002641 fi
2642 AC_CHECK_HEADERS($xmheader)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00002643
Bram Moolenaar77c19352012-06-13 19:19:41 +02002644 if test "x$ac_cv_header_Xm_XpmP_h" = "xyes"; then
Bram Moolenaar910f66f2006-04-05 20:41:53 +00002645 dnl Solaris uses XpmAttributes_21, very annoying.
2646 AC_MSG_CHECKING([for XpmAttributes_21 in Xm/XpmP.h])
2647 AC_TRY_COMPILE([#include <Xm/XpmP.h>], [XpmAttributes_21 attr;],
2648 AC_MSG_RESULT(yes); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes_21),
2649 AC_MSG_RESULT(no); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
2650 )
2651 else
Bram Moolenaar57657d82006-04-21 22:12:41 +00002652 AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
Bram Moolenaar910f66f2006-04-05 20:41:53 +00002653 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002654 CPPFLAGS=$cppflags_save
2655fi
2656
2657if test "x$GUITYPE" = "xNONE" -a "$enable_xim" = "yes"; then
2658 AC_MSG_RESULT(no GUI selected; xim has been disabled)
2659 enable_xim="no"
2660fi
2661if test "x$GUITYPE" = "xNONE" -a "$enable_fontset" = "yes"; then
2662 AC_MSG_RESULT(no GUI selected; fontset has been disabled)
2663 enable_fontset="no"
2664fi
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002665if test "x$GUITYPE:$enable_fontset" = "xGTK:yes"; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00002666 AC_MSG_RESULT(GTK+ 2 GUI selected; fontset has been disabled)
2667 enable_fontset="no"
2668fi
2669
Bram Moolenaar071d4272004-06-13 20:20:40 +00002670if test -z "$SKIP_PHOTON"; then
2671 GUITYPE=PHOTONGUI
2672fi
2673
2674AC_SUBST(GUI_INC_LOC)
2675AC_SUBST(GUI_LIB_LOC)
2676AC_SUBST(GUITYPE)
2677AC_SUBST(GUI_X_LIBS)
2678
2679if test "$enable_workshop" = "yes" -a -n "$SKIP_MOTIF"; then
2680 AC_MSG_ERROR([cannot use workshop without Motif])
2681fi
2682
2683dnl defining FEAT_XIM and FEAT_XFONTSET is delayed, so that they can be disabled
2684if test "$enable_xim" = "yes"; then
2685 AC_DEFINE(FEAT_XIM)
2686fi
2687if test "$enable_fontset" = "yes"; then
2688 AC_DEFINE(FEAT_XFONTSET)
2689fi
2690
2691
2692dnl ---------------------------------------------------------------------------
2693dnl end of GUI-checking
2694dnl ---------------------------------------------------------------------------
2695
Bram Moolenaar693e40c2013-02-26 14:56:42 +01002696dnl Check for Cygwin, which needs an extra source file if not using X11
2697AC_MSG_CHECKING(for CYGWIN environment)
2698case `uname` in
2699 CYGWIN*) CYGWIN=yes; AC_MSG_RESULT(yes)
2700 AC_MSG_CHECKING(for CYGWIN clipboard support)
2701 if test "x$with_x" = "xno" ; then
2702 OS_EXTRA_SRC=winclip.c; OS_EXTRA_OBJ=objects/winclip.o
2703 AC_MSG_RESULT(yes)
2704 AC_DEFINE(FEAT_CYGWIN_WIN32_CLIPBOARD)
2705 else
2706 AC_MSG_RESULT(no - using X11)
2707 fi ;;
2708
2709 *) CYGWIN=no; AC_MSG_RESULT(no);;
2710esac
Bram Moolenaar071d4272004-06-13 20:20:40 +00002711
2712dnl Only really enable hangul input when GUI and XFONTSET are available
2713if test "$enable_hangulinput" = "yes"; then
2714 if test "x$GUITYPE" = "xNONE"; then
2715 AC_MSG_RESULT(no GUI selected; hangul input has been disabled)
2716 enable_hangulinput=no
2717 else
2718 AC_DEFINE(FEAT_HANGULIN)
2719 HANGULIN_SRC=hangulin.c
2720 AC_SUBST(HANGULIN_SRC)
2721 HANGULIN_OBJ=objects/hangulin.o
2722 AC_SUBST(HANGULIN_OBJ)
2723 fi
2724fi
2725
2726dnl Checks for libraries and include files.
2727
Bram Moolenaar446cb832008-06-24 21:56:24 +00002728AC_CACHE_CHECK([whether toupper is broken], [vim_cv_toupper_broken],
2729 [
2730 AC_RUN_IFELSE([[
2731#include "confdefs.h"
2732#include <ctype.h>
2733#if STDC_HEADERS
2734# include <stdlib.h>
2735# include <stddef.h>
2736#endif
2737main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); }
2738 ]],[
2739 vim_cv_toupper_broken=yes
2740 ],[
2741 vim_cv_toupper_broken=no
2742 ],[
2743 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_toupper_broken')
2744 ])])
2745
2746if test "x$vim_cv_toupper_broken" = "xyes" ; then
2747 AC_DEFINE(BROKEN_TOUPPER)
2748fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002749
2750AC_MSG_CHECKING(whether __DATE__ and __TIME__ work)
Bram Moolenaar446cb832008-06-24 21:56:24 +00002751AC_TRY_COMPILE([#include <stdio.h>], [printf("(" __DATE__ " " __TIME__ ")");],
Bram Moolenaar071d4272004-06-13 20:20:40 +00002752 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DATE_TIME),
2753 AC_MSG_RESULT(no))
2754
Bram Moolenaar0c094b92009-05-14 20:20:33 +00002755AC_MSG_CHECKING(whether __attribute__((unused)) is allowed)
2756AC_TRY_COMPILE([#include <stdio.h>], [int x __attribute__((unused));],
2757 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ATTRIBUTE_UNUSED),
2758 AC_MSG_RESULT(no))
2759
Bram Moolenaar071d4272004-06-13 20:20:40 +00002760dnl Checks for header files.
2761AC_CHECK_HEADER(elf.h, HAS_ELF=1)
2762dnl AC_CHECK_HEADER(dwarf.h, SVR4=1)
2763if test "$HAS_ELF" = 1; then
2764 AC_CHECK_LIB(elf, main)
2765fi
2766
2767AC_HEADER_DIRENT
2768
Bram Moolenaar071d4272004-06-13 20:20:40 +00002769dnl If sys/wait.h is not found it might still exist but not be POSIX
2770dnl compliant. In that case we define HAVE_UNION_WAIT (for NeXT)
2771if test $ac_cv_header_sys_wait_h = no; then
2772 AC_MSG_CHECKING([for sys/wait.h that defines union wait])
2773 AC_TRY_COMPILE([#include <sys/wait.h>],
2774 [union wait xx, yy; xx = yy],
2775 AC_MSG_RESULT(yes)
2776 AC_DEFINE(HAVE_SYS_WAIT_H)
2777 AC_DEFINE(HAVE_UNION_WAIT),
2778 AC_MSG_RESULT(no))
2779fi
2780
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02002781AC_CHECK_HEADERS(stdarg.h stdint.h stdlib.h string.h \
2782 sys/select.h sys/utsname.h termcap.h fcntl.h \
2783 sgtty.h sys/ioctl.h sys/time.h sys/types.h \
2784 termio.h iconv.h inttypes.h langinfo.h math.h \
2785 unistd.h stropts.h errno.h sys/resource.h \
2786 sys/systeminfo.h locale.h sys/stream.h termios.h \
2787 libc.h sys/statfs.h poll.h sys/poll.h pwd.h \
2788 utime.h sys/param.h libintl.h libgen.h \
2789 util/debug.h util/msg18n.h frame.h sys/acl.h \
2790 sys/access.h sys/sysinfo.h wchar.h wctype.h)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002791
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002792dnl sys/ptem.h depends on sys/stream.h on Solaris
2793AC_CHECK_HEADERS(sys/ptem.h, [], [],
2794[#if defined HAVE_SYS_STREAM_H
2795# include <sys/stream.h>
2796#endif])
2797
Bram Moolenaar32f31b12009-05-21 13:20:59 +00002798dnl sys/sysctl.h depends on sys/param.h on OpenBSD
2799AC_CHECK_HEADERS(sys/sysctl.h, [], [],
2800[#if defined HAVE_SYS_PARAM_H
2801# include <sys/param.h>
2802#endif])
2803
Bram Moolenaar00ca2842008-06-26 20:14:00 +00002804
Bram Moolenaardf3267e2005-01-25 22:07:05 +00002805dnl pthread_np.h may exist but can only be used after including pthread.h
2806AC_MSG_CHECKING([for pthread_np.h])
2807AC_TRY_COMPILE([
2808#include <pthread.h>
2809#include <pthread_np.h>],
2810 [int i; i = 0;],
2811 AC_MSG_RESULT(yes)
2812 AC_DEFINE(HAVE_PTHREAD_NP_H),
2813 AC_MSG_RESULT(no))
2814
Bram Moolenaare344bea2005-09-01 20:46:49 +00002815AC_CHECK_HEADERS(strings.h)
Bram Moolenaar9372a112005-12-06 19:59:18 +00002816if test "x$MACOSX" = "xyes"; then
2817 dnl The strings.h file on OS/X contains a warning and nothing useful.
2818 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
2819else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002820
2821dnl Check if strings.h and string.h can both be included when defined.
2822AC_MSG_CHECKING([if strings.h can be included after string.h])
2823cppflags_save=$CPPFLAGS
2824CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2825AC_TRY_COMPILE([
2826#if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO)
2827# define _NO_PROTO /* like in os_unix.h, causes conflict for AIX (Winn) */
2828 /* but don't do it on AIX 5.1 (Uribarri) */
2829#endif
2830#ifdef HAVE_XM_XM_H
2831# include <Xm/Xm.h> /* This breaks it for HP-UX 11 (Squassabia) */
2832#endif
2833#ifdef HAVE_STRING_H
2834# include <string.h>
2835#endif
2836#if defined(HAVE_STRINGS_H)
2837# include <strings.h>
2838#endif
2839 ], [int i; i = 0;],
2840 AC_MSG_RESULT(yes),
2841 AC_DEFINE(NO_STRINGS_WITH_STRING_H)
2842 AC_MSG_RESULT(no))
2843CPPFLAGS=$cppflags_save
Bram Moolenaar9372a112005-12-06 19:59:18 +00002844fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002845
2846dnl Checks for typedefs, structures, and compiler characteristics.
2847AC_PROG_GCC_TRADITIONAL
2848AC_C_CONST
Bram Moolenaar76243bd2009-03-02 01:47:02 +00002849AC_C_VOLATILE
Bram Moolenaar071d4272004-06-13 20:20:40 +00002850AC_TYPE_MODE_T
2851AC_TYPE_OFF_T
2852AC_TYPE_PID_T
2853AC_TYPE_SIZE_T
2854AC_TYPE_UID_T
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02002855AC_TYPE_UINT32_T
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02002856
Bram Moolenaar071d4272004-06-13 20:20:40 +00002857AC_HEADER_TIME
2858AC_CHECK_TYPE(ino_t, long)
2859AC_CHECK_TYPE(dev_t, unsigned)
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02002860AC_C_BIGENDIAN(,,,)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002861
2862AC_MSG_CHECKING(for rlim_t)
2863if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
2864 AC_MSG_RESULT([(cached) $ac_cv_type_rlim_t])
2865else
2866 AC_EGREP_CPP(dnl
2867changequote(<<,>>)dnl
2868<<(^|[^a-zA-Z_0-9])rlim_t[^a-zA-Z_0-9]>>dnl
2869changequote([,]),
2870 [
2871#include <sys/types.h>
2872#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00002873# include <stdlib.h>
2874# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00002875#endif
2876#ifdef HAVE_SYS_RESOURCE_H
Bram Moolenaar446cb832008-06-24 21:56:24 +00002877# include <sys/resource.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00002878#endif
2879 ], ac_cv_type_rlim_t=yes, ac_cv_type_rlim_t=no)
2880 AC_MSG_RESULT($ac_cv_type_rlim_t)
2881fi
2882if test $ac_cv_type_rlim_t = no; then
2883 cat >> confdefs.h <<\EOF
2884#define rlim_t unsigned long
2885EOF
2886fi
2887
2888AC_MSG_CHECKING(for stack_t)
2889if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then
2890 AC_MSG_RESULT([(cached) $ac_cv_type_stack_t])
2891else
2892 AC_EGREP_CPP(stack_t,
2893 [
2894#include <sys/types.h>
2895#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00002896# include <stdlib.h>
2897# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00002898#endif
2899#include <signal.h>
2900 ], ac_cv_type_stack_t=yes, ac_cv_type_stack_t=no)
2901 AC_MSG_RESULT($ac_cv_type_stack_t)
2902fi
2903if test $ac_cv_type_stack_t = no; then
2904 cat >> confdefs.h <<\EOF
2905#define stack_t struct sigaltstack
2906EOF
2907fi
2908
2909dnl BSDI uses ss_base while others use ss_sp for the stack pointer.
2910AC_MSG_CHECKING(whether stack_t has an ss_base field)
2911AC_TRY_COMPILE([
2912#include <sys/types.h>
2913#if STDC_HEADERS
Bram Moolenaar446cb832008-06-24 21:56:24 +00002914# include <stdlib.h>
2915# include <stddef.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00002916#endif
2917#include <signal.h>
2918#include "confdefs.h"
2919 ], [stack_t sigstk; sigstk.ss_base = 0; ],
2920 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SS_BASE),
2921 AC_MSG_RESULT(no))
2922
2923olibs="$LIBS"
2924AC_MSG_CHECKING(--with-tlib argument)
2925AC_ARG_WITH(tlib, [ --with-tlib=library terminal library to be used ],)
2926if test -n "$with_tlib"; then
2927 AC_MSG_RESULT($with_tlib)
2928 LIBS="$LIBS -l$with_tlib"
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00002929 AC_MSG_CHECKING(for linking with $with_tlib library)
2930 AC_TRY_LINK([], [], AC_MSG_RESULT(OK), AC_MSG_ERROR(FAILED))
2931 dnl Need to check for tgetent() below.
2932 olibs="$LIBS"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002933else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00002934 AC_MSG_RESULT([empty: automatic terminal library selection])
Bram Moolenaar071d4272004-06-13 20:20:40 +00002935 dnl On HP-UX 10.10 termcap or termlib should be used instead of
2936 dnl curses, because curses is much slower.
Bram Moolenaar4e509b62011-02-09 17:42:57 +01002937 dnl Newer versions of ncurses are preferred over anything, except
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02002938 dnl when tinfo has been split off, it contains all we need.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002939 dnl Older versions of ncurses have bugs, get a new one!
2940 dnl Digital Unix (OSF1) should use curses (Ronald Schild).
Bram Moolenaara1b5aa52006-10-10 09:41:28 +00002941 dnl On SCO Openserver should prefer termlib (Roger Cornelius).
Bram Moolenaar071d4272004-06-13 20:20:40 +00002942 case "`uname -s 2>/dev/null`" in
Bram Moolenaar4e509b62011-02-09 17:42:57 +01002943 OSF1|SCO_SV) tlibs="tinfo ncurses curses termlib termcap";;
2944 *) tlibs="tinfo ncurses termlib termcap curses";;
Bram Moolenaar071d4272004-06-13 20:20:40 +00002945 esac
2946 for libname in $tlibs; do
2947 AC_CHECK_LIB(${libname}, tgetent,,)
2948 if test "x$olibs" != "x$LIBS"; then
2949 dnl It's possible that a library is found but it doesn't work
2950 dnl e.g., shared library that cannot be found
2951 dnl compile and run a test program to be sure
2952 AC_TRY_RUN([
2953#ifdef HAVE_TERMCAP_H
2954# include <termcap.h>
2955#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00002956#if STDC_HEADERS
2957# include <stdlib.h>
2958# include <stddef.h>
2959#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002960main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }],
2961 res="OK", res="FAIL", res="FAIL")
2962 if test "$res" = "OK"; then
2963 break
2964 fi
2965 AC_MSG_RESULT($libname library is not usable)
2966 LIBS="$olibs"
2967 fi
2968 done
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00002969 if test "x$olibs" = "x$LIBS"; then
2970 AC_MSG_RESULT(no terminal library found)
2971 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00002972fi
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00002973
2974if test "x$olibs" = "x$LIBS"; then
2975 AC_MSG_CHECKING([for tgetent()])
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00002976 AC_TRY_LINK([],
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00002977 [char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");],
2978 AC_MSG_RESULT(yes),
2979 AC_MSG_ERROR([NOT FOUND!
2980 You need to install a terminal library; for example ncurses.
2981 Or specify the name of the library with --with-tlib.]))
2982fi
2983
Bram Moolenaar446cb832008-06-24 21:56:24 +00002984AC_CACHE_CHECK([whether we talk terminfo], [vim_cv_terminfo],
2985 [
2986 AC_RUN_IFELSE([[
2987#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00002988#ifdef HAVE_TERMCAP_H
2989# include <termcap.h>
2990#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00002991#ifdef HAVE_STRING_H
2992# include <string.h>
2993#endif
2994#if STDC_HEADERS
2995# include <stdlib.h>
2996# include <stddef.h>
2997#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002998main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00002999{char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }
3000 ]],[
3001 vim_cv_terminfo=no
3002 ],[
3003 vim_cv_terminfo=yes
3004 ],[
3005 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_terminfo')
3006 ])
3007 ])
3008
3009if test "x$vim_cv_terminfo" = "xyes" ; then
3010 AC_DEFINE(TERMINFO)
3011fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003012
3013if test "x$olibs" != "x$LIBS"; then
Bram Moolenaar446cb832008-06-24 21:56:24 +00003014 AC_CACHE_CHECK([what tgetent() returns for an unknown terminal], [vim_cv_tgent],
3015 [
3016 AC_RUN_IFELSE([[
3017#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003018#ifdef HAVE_TERMCAP_H
3019# include <termcap.h>
3020#endif
Bram Moolenaar446cb832008-06-24 21:56:24 +00003021#if STDC_HEADERS
3022# include <stdlib.h>
3023# include <stddef.h>
3024#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003025main()
Bram Moolenaar446cb832008-06-24 21:56:24 +00003026{char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
3027 ]],[
3028 vim_cv_tgent=zero
3029 ],[
3030 vim_cv_tgent=non-zero
3031 ],[
3032 AC_MSG_ERROR(failed to compile test program.)
3033 ])
3034 ])
3035
3036 if test "x$vim_cv_tgent" = "xzero" ; then
3037 AC_DEFINE(TGETENT_ZERO_ERR, 0)
3038 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003039fi
3040
3041AC_MSG_CHECKING(whether termcap.h contains ospeed)
3042AC_TRY_LINK([
3043#ifdef HAVE_TERMCAP_H
3044# include <termcap.h>
3045#endif
3046 ], [ospeed = 20000],
3047 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED),
3048 [AC_MSG_RESULT(no)
3049 AC_MSG_CHECKING(whether ospeed can be extern)
3050 AC_TRY_LINK([
3051#ifdef HAVE_TERMCAP_H
3052# include <termcap.h>
3053#endif
3054extern short ospeed;
3055 ], [ospeed = 20000],
3056 AC_MSG_RESULT(yes); AC_DEFINE(OSPEED_EXTERN),
3057 AC_MSG_RESULT(no))]
3058 )
3059
3060AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC])
3061AC_TRY_LINK([
3062#ifdef HAVE_TERMCAP_H
3063# include <termcap.h>
3064#endif
3065 ], [if (UP == 0 && BC == 0) PC = 1],
3066 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UP_BC_PC),
3067 [AC_MSG_RESULT(no)
3068 AC_MSG_CHECKING([whether UP, BC and PC can be extern])
3069 AC_TRY_LINK([
3070#ifdef HAVE_TERMCAP_H
3071# include <termcap.h>
3072#endif
3073extern char *UP, *BC, PC;
3074 ], [if (UP == 0 && BC == 0) PC = 1],
3075 AC_MSG_RESULT(yes); AC_DEFINE(UP_BC_PC_EXTERN),
3076 AC_MSG_RESULT(no))]
3077 )
3078
3079AC_MSG_CHECKING(whether tputs() uses outfuntype)
3080AC_TRY_COMPILE([
3081#ifdef HAVE_TERMCAP_H
3082# include <termcap.h>
3083#endif
3084 ], [extern int xx(); tputs("test", 1, (outfuntype)xx)],
3085 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OUTFUNTYPE),
3086 AC_MSG_RESULT(no))
3087
3088dnl On some SCO machines sys/select redefines struct timeval
3089AC_MSG_CHECKING([whether sys/select.h and sys/time.h may both be included])
3090AC_TRY_COMPILE([
3091#include <sys/types.h>
3092#include <sys/time.h>
3093#include <sys/select.h>], ,
3094 AC_MSG_RESULT(yes)
3095 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME),
3096 AC_MSG_RESULT(no))
3097
3098dnl AC_DECL_SYS_SIGLIST
3099
3100dnl Checks for pty.c (copied from screen) ==========================
3101AC_MSG_CHECKING(for /dev/ptc)
3102if test -r /dev/ptc; then
3103 AC_DEFINE(HAVE_DEV_PTC)
3104 AC_MSG_RESULT(yes)
3105else
3106 AC_MSG_RESULT(no)
3107fi
3108
3109AC_MSG_CHECKING(for SVR4 ptys)
3110if test -c /dev/ptmx ; then
3111 AC_TRY_LINK([], [ptsname(0);grantpt(0);unlockpt(0);],
3112 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SVR4_PTYS),
3113 AC_MSG_RESULT(no))
3114else
3115 AC_MSG_RESULT(no)
3116fi
3117
3118AC_MSG_CHECKING(for ptyranges)
3119if test -d /dev/ptym ; then
3120 pdir='/dev/ptym'
3121else
3122 pdir='/dev'
3123fi
3124dnl SCO uses ptyp%d
3125AC_EGREP_CPP(yes,
3126[#ifdef M_UNIX
3127 yes;
3128#endif
3129 ], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
3130dnl if test -c /dev/ptyp19; then
3131dnl ptys=`echo /dev/ptyp??`
3132dnl else
3133dnl ptys=`echo $pdir/pty??`
3134dnl fi
3135if test "$ptys" != "$pdir/pty??" ; then
3136 p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
3137 p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'`
3138 AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
3139 AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
3140 AC_MSG_RESULT([$p0 / $p1])
3141else
3142 AC_MSG_RESULT([don't know])
3143fi
3144
3145dnl **** pty mode/group handling ****
3146dnl
3147dnl support provided by Luke Mewburn <lm@rmit.edu.au>, 931222
Bram Moolenaar071d4272004-06-13 20:20:40 +00003148rm -f conftest_grp
Bram Moolenaar446cb832008-06-24 21:56:24 +00003149AC_CACHE_CHECK([default tty permissions/group], [vim_cv_tty_group],
3150 [
3151 AC_RUN_IFELSE([[
3152#include "confdefs.h"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003153#include <sys/types.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003154#if STDC_HEADERS
3155# include <stdlib.h>
3156# include <stddef.h>
3157#endif
3158#ifdef HAVE_UNISTD_H
3159#include <unistd.h>
3160#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003161#include <sys/stat.h>
3162#include <stdio.h>
3163main()
3164{
3165 struct stat sb;
3166 char *x,*ttyname();
3167 int om, m;
3168 FILE *fp;
3169
3170 if (!(x = ttyname(0))) exit(1);
3171 if (stat(x, &sb)) exit(1);
3172 om = sb.st_mode;
3173 if (om & 002) exit(0);
3174 m = system("mesg y");
3175 if (m == -1 || m == 127) exit(1);
3176 if (stat(x, &sb)) exit(1);
3177 m = sb.st_mode;
3178 if (chmod(x, om)) exit(1);
3179 if (m & 002) exit(0);
3180 if (sb.st_gid == getgid()) exit(1);
3181 if (!(fp=fopen("conftest_grp", "w")))
3182 exit(1);
3183 fprintf(fp, "%d\n", sb.st_gid);
3184 fclose(fp);
3185 exit(0);
3186}
Bram Moolenaar446cb832008-06-24 21:56:24 +00003187 ]],[
3188 if test -f conftest_grp; then
3189 vim_cv_tty_group=`cat conftest_grp`
3190 if test "x$vim_cv_tty_mode" = "x" ; then
3191 vim_cv_tty_mode=0620
3192 fi
3193 AC_MSG_RESULT([pty mode: $vim_cv_tty_mode, group: $vim_cv_tty_group])
3194 else
3195 vim_cv_tty_group=world
Bram Moolenaar72951072009-12-02 16:58:33 +00003196 AC_MSG_RESULT([ptys are world accessible])
Bram Moolenaar446cb832008-06-24 21:56:24 +00003197 fi
3198 ],[
3199 vim_cv_tty_group=world
Bram Moolenaar72951072009-12-02 16:58:33 +00003200 AC_MSG_RESULT([can't determine - assume ptys are world accessible])
Bram Moolenaar446cb832008-06-24 21:56:24 +00003201 ],[
3202 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_tty_group' and 'vim_cv_tty_mode')
3203 ])
3204 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003205rm -f conftest_grp
3206
Bram Moolenaar446cb832008-06-24 21:56:24 +00003207if test "x$vim_cv_tty_group" != "xworld" ; then
3208 AC_DEFINE_UNQUOTED(PTYGROUP,$vim_cv_tty_group)
3209 if test "x$vim_cv_tty_mode" = "x" ; then
Bram Moolenaar84a05ac2013-05-06 04:24:17 +02003210 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 +00003211 else
3212 AC_DEFINE(PTYMODE, 0620)
3213 fi
3214fi
3215
Bram Moolenaar071d4272004-06-13 20:20:40 +00003216dnl Checks for library functions. ===================================
3217
3218AC_TYPE_SIGNAL
3219
3220dnl find out what to use at the end of a signal function
3221if test $ac_cv_type_signal = void; then
3222 AC_DEFINE(SIGRETURN, [return])
3223else
3224 AC_DEFINE(SIGRETURN, [return 0])
3225fi
3226
3227dnl check if struct sigcontext is defined (used for SGI only)
3228AC_MSG_CHECKING(for struct sigcontext)
3229AC_TRY_COMPILE([
3230#include <signal.h>
3231test_sig()
3232{
3233 struct sigcontext *scont;
3234 scont = (struct sigcontext *)0;
3235 return 1;
3236} ], ,
3237 AC_MSG_RESULT(yes)
3238 AC_DEFINE(HAVE_SIGCONTEXT),
3239 AC_MSG_RESULT(no))
3240
3241dnl tricky stuff: try to find out if getcwd() is implemented with
3242dnl system("sh -c pwd")
Bram Moolenaar446cb832008-06-24 21:56:24 +00003243AC_CACHE_CHECK([getcwd implementation is broken], [vim_cv_getcwd_broken],
3244 [
3245 AC_RUN_IFELSE([[
3246#include "confdefs.h"
3247#ifdef HAVE_UNISTD_H
3248#include <unistd.h>
3249#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003250char *dagger[] = { "IFS=pwd", 0 };
3251main()
3252{
3253 char buffer[500];
3254 extern char **environ;
3255 environ = dagger;
3256 return getcwd(buffer, 500) ? 0 : 1;
Bram Moolenaar446cb832008-06-24 21:56:24 +00003257}
3258 ]],[
3259 vim_cv_getcwd_broken=no
3260 ],[
3261 vim_cv_getcwd_broken=yes
3262 ],[
3263 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_getcwd_broken')
3264 ])
3265 ])
3266
3267if test "x$vim_cv_getcwd_broken" = "xyes" ; then
3268 AC_DEFINE(BAD_GETCWD)
3269fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003270
Bram Moolenaar25153e12010-02-24 14:47:08 +01003271dnl Check for functions in one big call, to reduce the size of configure.
3272dnl Can only be used for functions that do not require any include.
3273AC_CHECK_FUNCS(bcmp fchdir fchown fsync getcwd getpseudotty \
Bram Moolenaar24305862012-08-15 14:05:05 +02003274 getpwent getpwnam getpwuid getrlimit gettimeofday getwd lstat memcmp \
Bram Moolenaareaf03392009-11-17 11:08:52 +00003275 memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
Bram Moolenaar071d4272004-06-13 20:20:40 +00003276 setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
Bram Moolenaar051b7822005-05-19 21:00:46 +00003277 sigvec strcasecmp strerror strftime stricmp strncasecmp \
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00003278 strnicmp strpbrk strtol tgetent towlower towupper iswupper \
3279 usleep utime utimes)
Bram Moolenaar25153e12010-02-24 14:47:08 +01003280AC_FUNC_FSEEKO
Bram Moolenaar071d4272004-06-13 20:20:40 +00003281
Bram Moolenaar317fd3a2010-05-07 16:05:55 +02003282dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when
3283dnl appropriate, so that off_t is 64 bits when needed.
3284AC_SYS_LARGEFILE
3285
Bram Moolenaar071d4272004-06-13 20:20:40 +00003286dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible
3287AC_MSG_CHECKING(for st_blksize)
3288AC_TRY_COMPILE(
3289[#include <sys/types.h>
3290#include <sys/stat.h>],
3291[ struct stat st;
3292 int n;
3293
3294 stat("/", &st);
3295 n = (int)st.st_blksize;],
3296 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ST_BLKSIZE),
3297 AC_MSG_RESULT(no))
3298
Bram Moolenaar446cb832008-06-24 21:56:24 +00003299AC_CACHE_CHECK([whether stat() ignores a trailing slash], [vim_cv_stat_ignores_slash],
3300 [
3301 AC_RUN_IFELSE([[
3302#include "confdefs.h"
3303#if STDC_HEADERS
3304# include <stdlib.h>
3305# include <stddef.h>
3306#endif
3307#include <sys/types.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +00003308#include <sys/stat.h>
Bram Moolenaar446cb832008-06-24 21:56:24 +00003309main() {struct stat st; exit(stat("configure/", &st) != 0); }
3310 ]],[
3311 vim_cv_stat_ignores_slash=yes
3312 ],[
3313 vim_cv_stat_ignores_slash=no
3314 ],[
3315 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_stat_ignores_slash')
3316 ])
3317 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003318
Bram Moolenaar446cb832008-06-24 21:56:24 +00003319if test "x$vim_cv_stat_ignores_slash" = "xyes" ; then
3320 AC_DEFINE(STAT_IGNORES_SLASH)
3321fi
3322
Bram Moolenaar071d4272004-06-13 20:20:40 +00003323dnl Link with iconv for charset translation, if not found without library.
3324dnl check for iconv() requires including iconv.h
3325dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
3326dnl has been installed.
3327AC_MSG_CHECKING(for iconv_open())
3328save_LIBS="$LIBS"
3329LIBS="$LIBS -liconv"
3330AC_TRY_LINK([
3331#ifdef HAVE_ICONV_H
3332# include <iconv.h>
3333#endif
3334 ], [iconv_open("fr", "to");],
3335 AC_MSG_RESULT(yes; with -liconv); AC_DEFINE(HAVE_ICONV),
3336 LIBS="$save_LIBS"
3337 AC_TRY_LINK([
3338#ifdef HAVE_ICONV_H
3339# include <iconv.h>
3340#endif
3341 ], [iconv_open("fr", "to");],
3342 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ICONV),
3343 AC_MSG_RESULT(no)))
3344
3345
3346AC_MSG_CHECKING(for nl_langinfo(CODESET))
3347AC_TRY_LINK([
3348#ifdef HAVE_LANGINFO_H
3349# include <langinfo.h>
3350#endif
3351], [char *cs = nl_langinfo(CODESET);],
3352 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET),
3353 AC_MSG_RESULT(no))
3354
Bram Moolenaar446cb832008-06-24 21:56:24 +00003355dnl Need various functions for floating point support. Only enable
3356dnl floating point when they are all present.
3357AC_CHECK_LIB(m, strtod)
3358AC_MSG_CHECKING([for strtod() and other floating point functions])
3359AC_TRY_LINK([
3360#ifdef HAVE_MATH_H
3361# include <math.h>
3362#endif
3363#if STDC_HEADERS
3364# include <stdlib.h>
3365# include <stddef.h>
3366#endif
3367], [char *s; double d;
3368 d = strtod("1.1", &s);
3369 d = fabs(1.11);
3370 d = ceil(1.11);
3371 d = floor(1.11);
3372 d = log10(1.11);
3373 d = pow(1.11, 2.22);
3374 d = sqrt(1.11);
3375 d = sin(1.11);
3376 d = cos(1.11);
3377 d = atan(1.11);
3378 ],
3379 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT_FUNCS),
3380 AC_MSG_RESULT(no))
3381
Bram Moolenaar071d4272004-06-13 20:20:40 +00003382dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI
3383dnl when -lacl works, also try to use -lattr (required for Debian).
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003384dnl On Solaris, use the acl_get/set functions in libsec, if present.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003385AC_MSG_CHECKING(--disable-acl argument)
3386AC_ARG_ENABLE(acl,
3387 [ --disable-acl Don't check for ACL support.],
3388 , [enable_acl="yes"])
3389if test "$enable_acl" = "yes"; then
3390AC_MSG_RESULT(no)
3391AC_CHECK_LIB(posix1e, acl_get_file, [LIBS="$LIBS -lposix1e"],
3392 AC_CHECK_LIB(acl, acl_get_file, [LIBS="$LIBS -lacl"
3393 AC_CHECK_LIB(attr, fgetxattr, LIBS="$LIBS -lattr",,)],,),)
3394
3395AC_MSG_CHECKING(for POSIX ACL support)
3396AC_TRY_LINK([
3397#include <sys/types.h>
3398#ifdef HAVE_SYS_ACL_H
3399# include <sys/acl.h>
3400#endif
3401acl_t acl;], [acl = acl_get_file("foo", ACL_TYPE_ACCESS);
3402 acl_set_file("foo", ACL_TYPE_ACCESS, acl);
3403 acl_free(acl);],
3404 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_ACL),
3405 AC_MSG_RESULT(no))
3406
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003407AC_CHECK_LIB(sec, acl_get, [LIBS="$LIBS -lsec"; AC_DEFINE(HAVE_SOLARIS_ZFS_ACL)],
Bram Moolenaar071d4272004-06-13 20:20:40 +00003408AC_MSG_CHECKING(for Solaris ACL support)
3409AC_TRY_LINK([
3410#ifdef HAVE_SYS_ACL_H
3411# include <sys/acl.h>
3412#endif], [acl("foo", GETACLCNT, 0, NULL);
3413 ],
3414 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOLARIS_ACL),
Bram Moolenaar8d462f92012-02-05 22:51:33 +01003415 AC_MSG_RESULT(no)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003416
3417AC_MSG_CHECKING(for AIX ACL support)
3418AC_TRY_LINK([
Bram Moolenaar446cb832008-06-24 21:56:24 +00003419#if STDC_HEADERS
3420# include <stdlib.h>
3421# include <stddef.h>
3422#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003423#ifdef HAVE_SYS_ACL_H
3424# include <sys/acl.h>
3425#endif
3426#ifdef HAVE_SYS_ACCESS_H
3427# include <sys/access.h>
3428#endif
3429#define _ALL_SOURCE
3430
3431#include <sys/stat.h>
3432
3433int aclsize;
3434struct acl *aclent;], [aclsize = sizeof(struct acl);
3435 aclent = (void *)malloc(aclsize);
3436 statacl("foo", STX_NORMAL, aclent, aclsize);
3437 ],
3438 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_AIX_ACL),
3439 AC_MSG_RESULT(no))
3440else
3441 AC_MSG_RESULT(yes)
3442fi
3443
3444AC_MSG_CHECKING(--disable-gpm argument)
3445AC_ARG_ENABLE(gpm,
3446 [ --disable-gpm Don't use gpm (Linux mouse daemon).], ,
3447 [enable_gpm="yes"])
3448
3449if test "$enable_gpm" = "yes"; then
3450 AC_MSG_RESULT(no)
3451 dnl Checking if gpm support can be compiled
3452 AC_CACHE_CHECK([for gpm], vi_cv_have_gpm,
3453 [olibs="$LIBS" ; LIBS="-lgpm"]
3454 AC_TRY_LINK(
3455 [#include <gpm.h>
3456 #include <linux/keyboard.h>],
3457 [Gpm_GetLibVersion(NULL);],
3458 dnl Configure defines HAVE_GPM, if it is defined feature.h defines
3459 dnl FEAT_MOUSE_GPM if mouse support is included
3460 [vi_cv_have_gpm=yes],
3461 [vi_cv_have_gpm=no])
3462 [LIBS="$olibs"]
3463 )
3464 if test $vi_cv_have_gpm = yes; then
3465 LIBS="$LIBS -lgpm"
3466 AC_DEFINE(HAVE_GPM)
3467 fi
3468else
3469 AC_MSG_RESULT(yes)
3470fi
3471
Bram Moolenaar446cb832008-06-24 21:56:24 +00003472AC_MSG_CHECKING(--disable-sysmouse argument)
3473AC_ARG_ENABLE(sysmouse,
3474 [ --disable-sysmouse Don't use sysmouse (mouse in *BSD console).], ,
3475 [enable_sysmouse="yes"])
3476
3477if test "$enable_sysmouse" = "yes"; then
3478 AC_MSG_RESULT(no)
3479 dnl Checking if sysmouse support can be compiled
3480 dnl Configure defines HAVE_SYSMOUSE, if it is defined feature.h
3481 dnl defines FEAT_SYSMOUSE if mouse support is included
3482 AC_CACHE_CHECK([for sysmouse], vi_cv_have_sysmouse,
3483 AC_TRY_LINK(
3484 [#include <sys/consio.h>
3485 #include <signal.h>
3486 #include <sys/fbio.h>],
3487 [struct mouse_info mouse;
3488 mouse.operation = MOUSE_MODE;
3489 mouse.operation = MOUSE_SHOW;
3490 mouse.u.mode.mode = 0;
3491 mouse.u.mode.signal = SIGUSR2;],
3492 [vi_cv_have_sysmouse=yes],
3493 [vi_cv_have_sysmouse=no])
3494 )
3495 if test $vi_cv_have_sysmouse = yes; then
3496 AC_DEFINE(HAVE_SYSMOUSE)
3497 fi
3498else
3499 AC_MSG_RESULT(yes)
3500fi
3501
Bram Moolenaarf05da212009-11-17 16:13:15 +00003502dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
3503AC_MSG_CHECKING(for FD_CLOEXEC)
3504AC_TRY_COMPILE(
3505[#if HAVE_FCNTL_H
3506# include <fcntl.h>
3507#endif],
3508[ int flag = FD_CLOEXEC;],
3509 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
3510 AC_MSG_RESULT(not usable))
3511
Bram Moolenaar071d4272004-06-13 20:20:40 +00003512dnl rename needs to be checked separately to work on Nextstep with cc
3513AC_MSG_CHECKING(for rename)
3514AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
3515 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
3516 AC_MSG_RESULT(no))
3517
3518dnl sysctl() may exist but not the arguments we use
3519AC_MSG_CHECKING(for sysctl)
3520AC_TRY_COMPILE(
3521[#include <sys/types.h>
3522#include <sys/sysctl.h>],
3523[ int mib[2], r;
3524 size_t len;
3525
3526 mib[0] = CTL_HW;
3527 mib[1] = HW_USERMEM;
3528 len = sizeof(r);
3529 (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
3530 ],
3531 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL),
3532 AC_MSG_RESULT(not usable))
3533
3534dnl sysinfo() may exist but not be Linux compatible
3535AC_MSG_CHECKING(for sysinfo)
3536AC_TRY_COMPILE(
3537[#include <sys/types.h>
3538#include <sys/sysinfo.h>],
3539[ struct sysinfo sinfo;
3540 int t;
3541
3542 (void)sysinfo(&sinfo);
3543 t = sinfo.totalram;
3544 ],
3545 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
3546 AC_MSG_RESULT(not usable))
3547
Bram Moolenaar914572a2007-05-01 11:37:47 +00003548dnl struct sysinfo may have the mem_unit field or not
3549AC_MSG_CHECKING(for sysinfo.mem_unit)
3550AC_TRY_COMPILE(
3551[#include <sys/types.h>
3552#include <sys/sysinfo.h>],
3553[ struct sysinfo sinfo;
Bram Moolenaar3c7ad012013-06-11 19:53:45 +02003554 sinfo.mem_unit = 1;
Bram Moolenaar914572a2007-05-01 11:37:47 +00003555 ],
3556 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_MEM_UNIT),
3557 AC_MSG_RESULT(no))
3558
Bram Moolenaar071d4272004-06-13 20:20:40 +00003559dnl sysconf() may exist but not support what we want to use
3560AC_MSG_CHECKING(for sysconf)
3561AC_TRY_COMPILE(
3562[#include <unistd.h>],
3563[ (void)sysconf(_SC_PAGESIZE);
3564 (void)sysconf(_SC_PHYS_PAGES);
3565 ],
3566 AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
3567 AC_MSG_RESULT(not usable))
3568
Bram Moolenaar914703b2010-05-31 21:59:46 +02003569AC_CHECK_SIZEOF([int])
3570AC_CHECK_SIZEOF([long])
3571AC_CHECK_SIZEOF([time_t])
3572AC_CHECK_SIZEOF([off_t])
Bram Moolenaar644fdff2010-05-30 13:26:21 +02003573
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003574dnl Make sure that uint32_t is really 32 bits unsigned.
3575AC_MSG_CHECKING([uint32_t is 32 bits])
3576AC_TRY_RUN([
3577#ifdef HAVE_STDINT_H
3578# include <stdint.h>
3579#endif
3580#ifdef HAVE_INTTYPES_H
3581# include <inttypes.h>
3582#endif
3583main() {
3584 uint32_t nr1 = (uint32_t)-1;
3585 uint32_t nr2 = (uint32_t)0xffffffffUL;
3586 if (sizeof(uint32_t) != 4 || nr1 != 0xffffffffUL || nr2 + 1 != 0) exit(1);
3587 exit(0);
3588}],
3589AC_MSG_RESULT(ok),
3590AC_MSG_ERROR([WRONG! uint32_t not defined correctly.]),
Bram Moolenaar323cb952011-12-14 19:22:34 +01003591AC_MSG_WARN([cannot check uint32_t when cross-compiling.]))
Bram Moolenaarfa7584c2010-05-19 21:57:45 +02003592
Bram Moolenaar446cb832008-06-24 21:56:24 +00003593dnl Check for memmove() before bcopy(), makes memmove() be used when both are
3594dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
3595
Bram Moolenaar071d4272004-06-13 20:20:40 +00003596[bcopy_test_prog='
Bram Moolenaar446cb832008-06-24 21:56:24 +00003597#include "confdefs.h"
3598#ifdef HAVE_STRING_H
3599# include <string.h>
3600#endif
3601#if STDC_HEADERS
3602# include <stdlib.h>
3603# include <stddef.h>
3604#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003605main() {
3606 char buf[10];
3607 strcpy(buf, "abcdefghi");
3608 mch_memmove(buf, buf + 2, 3);
3609 if (strncmp(buf, "ababcf", 6))
3610 exit(1);
3611 strcpy(buf, "abcdefghi");
3612 mch_memmove(buf + 2, buf, 3);
3613 if (strncmp(buf, "cdedef", 6))
3614 exit(1);
3615 exit(0); /* libc version works properly. */
3616}']
3617
Bram Moolenaar446cb832008-06-24 21:56:24 +00003618AC_CACHE_CHECK([whether memmove handles overlaps],[vim_cv_memmove_handles_overlap],
3619 [
3620 AC_RUN_IFELSE([[#define mch_memmove(s,d,l) memmove(d,s,l) $bcopy_test_prog]],
3621 [
3622 vim_cv_memmove_handles_overlap=yes
3623 ],[
3624 vim_cv_memmove_handles_overlap=no
3625 ],[
3626 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memmove_handles_overlap')
3627 ])
3628 ])
Bram Moolenaar071d4272004-06-13 20:20:40 +00003629
Bram Moolenaar446cb832008-06-24 21:56:24 +00003630if test "x$vim_cv_memmove_handles_overlap" = "xyes" ; then
3631 AC_DEFINE(USEMEMMOVE)
3632else
3633 AC_CACHE_CHECK([whether bcopy handles overlaps],[vim_cv_bcopy_handles_overlap],
3634 [
3635 AC_RUN_IFELSE([[#define mch_bcopy(s,d,l) bcopy(d,s,l) $bcopy_test_prog]],
3636 [
3637 vim_cv_bcopy_handles_overlap=yes
3638 ],[
3639 vim_cv_bcopy_handles_overlap=no
3640 ],[
3641 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_bcopy_handles_overlap')
3642 ])
3643 ])
3644
3645 if test "x$vim_cv_bcopy_handles_overlap" = "xyes" ; then
3646 AC_DEFINE(USEBCOPY)
3647 else
3648 AC_CACHE_CHECK([whether memcpy handles overlaps],[vim_cv_memcpy_handles_overlap],
3649 [
3650 AC_RUN_IFELSE([[#define mch_memcpy(s,d,l) memcpy(d,s,l) $bcopy_test_prog]],
3651 [
3652 vim_cv_memcpy_handles_overlap=yes
3653 ],[
3654 vim_cv_memcpy_handles_overlap=no
3655 ],[
3656 AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memcpy_handles_overlap')
3657 ])
3658 ])
3659
3660 if test "x$vim_cv_memcpy_handles_overlap" = "xyes" ; then
3661 AC_DEFINE(USEMEMCPY)
3662 fi
3663 fi
3664fi
3665
Bram Moolenaar071d4272004-06-13 20:20:40 +00003666
3667dnl Check for multibyte locale functions
3668dnl Find out if _Xsetlocale() is supported by libX11.
3669dnl Check if X_LOCALE should be defined.
3670
3671if test "$enable_multibyte" = "yes"; then
3672 cflags_save=$CFLAGS
3673 ldflags_save=$LDFLAGS
Bram Moolenaar94ba1ce2009-04-22 15:53:09 +00003674 if test "x$x_includes" != "xNONE" ; then
Bram Moolenaar071d4272004-06-13 20:20:40 +00003675 CFLAGS="$CFLAGS -I$x_includes"
3676 LDFLAGS="$X_LIBS $LDFLAGS -lX11"
3677 AC_MSG_CHECKING(whether X_LOCALE needed)
3678 AC_TRY_COMPILE([#include <X11/Xlocale.h>],,
3679 AC_TRY_LINK_FUNC([_Xsetlocale], [AC_MSG_RESULT(yes)
3680 AC_DEFINE(X_LOCALE)], AC_MSG_RESULT(no)),
3681 AC_MSG_RESULT(no))
3682 fi
3683 CFLAGS=$cflags_save
3684 LDFLAGS=$ldflags_save
3685fi
3686
3687dnl Link with xpg4, it is said to make Korean locale working
3688AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,)
3689
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00003690dnl Check how we can run ctags. Default to "ctags" when nothing works.
Bram Moolenaar8f4ba692011-05-05 17:24:27 +02003691dnl Use --version to detect Exuberant ctags (preferred)
Bram Moolenaarb21e5842006-04-16 18:30:08 +00003692dnl Add --fields=+S to get function signatures for omni completion.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003693dnl -t for typedefs (many ctags have this)
3694dnl -s for static functions (Elvis ctags only?)
3695dnl -v for variables. Dangerous, most ctags take this for 'vgrind style'.
3696dnl -i+m to test for older Exuberant ctags
3697AC_MSG_CHECKING(how to create tags)
3698test -f tags && mv tags tags.save
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02003699if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
Bram Moolenaarb21e5842006-04-16 18:30:08 +00003700 TAGPRG="ctags -I INIT+ --fields=+S"
Bram Moolenaar5897e0c2011-05-10 15:42:03 +02003701elif (eval exctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
3702 TAGPRG="exctags -I INIT+ --fields=+S"
3703elif (eval exuberant-ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
3704 TAGPRG="exuberant-ctags -I INIT+ --fields=+S"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003705else
Bram Moolenaar0c7ce772009-05-13 12:49:39 +00003706 TAGPRG="ctags"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003707 (eval etags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags"
3708 (eval etags -c /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags -c"
3709 (eval ctags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags"
3710 (eval ctags -t /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -t"
3711 (eval ctags -ts /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -ts"
3712 (eval ctags -tvs /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -tvs"
3713 (eval ctags -i+m /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -i+m"
3714fi
3715test -f tags.save && mv tags.save tags
3716AC_MSG_RESULT($TAGPRG) AC_SUBST(TAGPRG)
3717
3718dnl Check how we can run man with a section number
3719AC_MSG_CHECKING(how to run man with a section nr)
3720MANDEF="man"
Bram Moolenaar8b131502008-02-13 09:28:19 +00003721(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 +00003722AC_MSG_RESULT($MANDEF)
3723if test "$MANDEF" = "man -s"; then
3724 AC_DEFINE(USEMAN_S)
3725fi
3726
3727dnl Check if gettext() is working and if it needs -lintl
Bram Moolenaar49b6a572013-11-17 20:32:54 +01003728dnl We take care to base this on an empty LIBS: on some systems libelf would be
3729dnl in LIBS and implicitly take along libintl. The final LIBS would then not
3730dnl contain libintl, and the link step would fail due to -Wl,--as-needed.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003731AC_MSG_CHECKING(--disable-nls argument)
3732AC_ARG_ENABLE(nls,
3733 [ --disable-nls Don't support NLS (gettext()).], ,
3734 [enable_nls="yes"])
3735
3736if test "$enable_nls" = "yes"; then
3737 AC_MSG_RESULT(no)
Bram Moolenaar2389c3c2005-05-22 22:07:59 +00003738
3739 INSTALL_LANGS=install-languages
3740 AC_SUBST(INSTALL_LANGS)
3741 INSTALL_TOOL_LANGS=install-tool-languages
3742 AC_SUBST(INSTALL_TOOL_LANGS)
3743
Bram Moolenaar071d4272004-06-13 20:20:40 +00003744 AC_CHECK_PROG(MSGFMT, msgfmt, msgfmt, )
3745 AC_MSG_CHECKING([for NLS])
3746 if test -f po/Makefile; then
3747 have_gettext="no"
3748 if test -n "$MSGFMT"; then
Bram Moolenaar49b6a572013-11-17 20:32:54 +01003749 olibs=$LIBS
3750 LIBS=""
Bram Moolenaar071d4272004-06-13 20:20:40 +00003751 AC_TRY_LINK(
3752 [#include <libintl.h>],
3753 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01003754 AC_MSG_RESULT([gettext() works]); have_gettext="yes"; LIBS=$olibs,
3755 LIBS="-lintl"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003756 AC_TRY_LINK(
3757 [#include <libintl.h>],
3758 [gettext("Test");],
Bram Moolenaar49b6a572013-11-17 20:32:54 +01003759 AC_MSG_RESULT([gettext() works with -lintl]); have_gettext="yes";
3760 LIBS="$olibs -lintl",
Bram Moolenaar071d4272004-06-13 20:20:40 +00003761 AC_MSG_RESULT([gettext() doesn't work]);
3762 LIBS=$olibs))
3763 else
3764 AC_MSG_RESULT([msgfmt not found - disabled]);
3765 fi
3766 if test $have_gettext = "yes"; then
3767 AC_DEFINE(HAVE_GETTEXT)
3768 MAKEMO=yes
3769 AC_SUBST(MAKEMO)
3770 dnl this was added in GNU gettext 0.10.36
3771 AC_CHECK_FUNCS(bind_textdomain_codeset)
3772 dnl _nl_msg_cat_cntr is required for GNU gettext
3773 AC_MSG_CHECKING([for _nl_msg_cat_cntr])
3774 AC_TRY_LINK(
3775 [#include <libintl.h>
3776 extern int _nl_msg_cat_cntr;],
3777 [++_nl_msg_cat_cntr;],
3778 AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_NL_MSG_CAT_CNTR),
3779 AC_MSG_RESULT([no]))
3780 fi
3781 else
3782 AC_MSG_RESULT([no "po/Makefile" - disabled]);
3783 fi
3784else
3785 AC_MSG_RESULT(yes)
3786fi
3787
3788dnl Check for dynamic linking loader
3789AC_CHECK_HEADER(dlfcn.h, DLL=dlfcn.h, [AC_CHECK_HEADER(dl.h, DLL=dl.h)])
3790if test x${DLL} = xdlfcn.h; then
3791 AC_DEFINE(HAVE_DLFCN_H, 1, [ Define if we have dlfcn.h. ])
3792 AC_MSG_CHECKING([for dlopen()])
3793 AC_TRY_LINK(,[
3794 extern void* dlopen();
3795 dlopen();
3796 ],
3797 AC_MSG_RESULT(yes);
3798 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
3799 AC_MSG_RESULT(no);
3800 AC_MSG_CHECKING([for dlopen() in -ldl])
3801 olibs=$LIBS
3802 LIBS="$LIBS -ldl"
3803 AC_TRY_LINK(,[
3804 extern void* dlopen();
3805 dlopen();
3806 ],
3807 AC_MSG_RESULT(yes);
3808 AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
3809 AC_MSG_RESULT(no);
3810 LIBS=$olibs))
3811 dnl ReliantUNIX has dlopen() in libc but everything else in libdl
3812 dnl ick :-)
3813 AC_MSG_CHECKING([for dlsym()])
3814 AC_TRY_LINK(,[
3815 extern void* dlsym();
3816 dlsym();
3817 ],
3818 AC_MSG_RESULT(yes);
3819 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
3820 AC_MSG_RESULT(no);
3821 AC_MSG_CHECKING([for dlsym() in -ldl])
3822 olibs=$LIBS
3823 LIBS="$LIBS -ldl"
3824 AC_TRY_LINK(,[
3825 extern void* dlsym();
3826 dlsym();
3827 ],
3828 AC_MSG_RESULT(yes);
3829 AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
3830 AC_MSG_RESULT(no);
3831 LIBS=$olibs))
3832elif test x${DLL} = xdl.h; then
3833 AC_DEFINE(HAVE_DL_H, 1, [ Define if we have dl.h. ])
3834 AC_MSG_CHECKING([for shl_load()])
3835 AC_TRY_LINK(,[
3836 extern void* shl_load();
3837 shl_load();
3838 ],
3839 AC_MSG_RESULT(yes);
3840 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
3841 AC_MSG_RESULT(no);
3842 AC_MSG_CHECKING([for shl_load() in -ldld])
3843 olibs=$LIBS
3844 LIBS="$LIBS -ldld"
3845 AC_TRY_LINK(,[
3846 extern void* shl_load();
3847 shl_load();
3848 ],
3849 AC_MSG_RESULT(yes);
3850 AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
3851 AC_MSG_RESULT(no);
3852 LIBS=$olibs))
3853fi
3854AC_CHECK_HEADERS(setjmp.h)
3855
3856if test "x$MACOSX" = "xyes" -a -n "$PERL"; then
3857 dnl -ldl must come after DynaLoader.a
3858 if echo $LIBS | grep -e '-ldl' >/dev/null; then
3859 LIBS=`echo $LIBS | sed s/-ldl//`
3860 PERL_LIBS="$PERL_LIBS -ldl"
3861 fi
3862fi
3863
Bram Moolenaar164fca32010-07-14 13:58:07 +02003864if test "x$MACOSX" = "xyes"; then
3865 AC_MSG_CHECKING(whether we need -framework Cocoa)
3866 dnl Cocoa is needed with FEAT_CLIPBOARD or FEAT_MBYTE (the former is
3867 dnl disabled during tiny build)
3868 if test "x$features" != "xtiny" || test "x$enable_multibyte" = "xyes"; then
3869 LIBS=$"$LIBS -framework Cocoa"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003870 AC_MSG_RESULT(yes)
3871 else
3872 AC_MSG_RESULT(no)
3873 fi
Bram Moolenaar3437b912013-07-03 19:52:53 +02003874 dnl As mentioned above, tiny build implies os_macosx.m isn't needed.
3875 dnl Exclude it from OS_EXTRA_SRC so that linker won't complain about
3876 dnl missing Objective-C symbols.
3877 if test "x$features" = "xtiny"; then
3878 OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_macosx.m++'`
3879 OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_macosx.o++'`
3880 fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003881fi
Bram Moolenaar164fca32010-07-14 13:58:07 +02003882if test "x$MACARCH" = "xboth" && test "x$GUITYPE" = "xCARBONGUI"; then
Bram Moolenaar595a7be2010-03-10 16:28:12 +01003883 LDFLAGS="$LDFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
Bram Moolenaare224ffa2006-03-01 00:01:28 +00003884fi
Bram Moolenaar071d4272004-06-13 20:20:40 +00003885
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00003886dnl gcc 3.1 changed the meaning of -MM. The only solution appears to be to
3887dnl use "-isystem" instead of "-I" for all non-Vim include dirs.
3888dnl But only when making dependencies, cproto and lint don't take "-isystem".
Bram Moolenaar32466aa2006-02-24 23:53:04 +00003889dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
3890dnl the number before the version number.
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00003891DEPEND_CFLAGS_FILTER=
3892if test "$GCC" = yes; then
Bram Moolenaar0cd49302008-11-20 09:37:01 +00003893 AC_MSG_CHECKING(for GCC 3 or later)
Bram Moolenaar2217cae2006-03-25 21:55:52 +00003894 gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]]\)\..*$/\1/g'`
Bram Moolenaarf740b292006-02-16 22:11:02 +00003895 if test "$gccmajor" -gt "2"; then
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00003896 DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
Bram Moolenaar0cd49302008-11-20 09:37:01 +00003897 AC_MSG_RESULT(yes)
3898 else
3899 AC_MSG_RESULT(no)
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00003900 fi
Bram Moolenaar0cd49302008-11-20 09:37:01 +00003901 dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
3902 dnl declared as char x[1] but actually longer. Introduced in gcc 4.0.
Bram Moolenaar56d1db32009-12-16 16:14:51 +00003903 dnl Also remove duplicate _FORTIFY_SOURCE arguments.
Bram Moolenaaraeabe052011-12-08 15:17:34 +01003904 dnl And undefine it first to avoid a warning.
Bram Moolenaar0cd49302008-11-20 09:37:01 +00003905 AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
3906 if test "$gccmajor" -gt "3"; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02003907 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 +00003908 AC_MSG_RESULT(yes)
3909 else
3910 AC_MSG_RESULT(no)
3911 fi
Bram Moolenaara5792f52005-11-23 21:25:05 +00003912fi
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00003913AC_SUBST(DEPEND_CFLAGS_FILTER)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003914
Bram Moolenaar22e193d2010-11-03 22:32:24 +01003915dnl link.sh tries to avoid overlinking in a hackish way.
3916dnl At least GNU ld supports --as-needed which provides the same functionality
3917dnl at linker level. Let's use it.
3918AC_MSG_CHECKING(linker --as-needed support)
3919LINK_AS_NEEDED=
3920# Check if linker supports --as-needed and --no-as-needed options
3921if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
Bram Moolenaara6cc0312013-06-18 23:31:55 +02003922 LDFLAGS=`echo "$LDFLAGS" | sed -e 's/ *-Wl,--as-needed//g' | sed -e 's/$/ -Wl,--as-needed/'`
Bram Moolenaar22e193d2010-11-03 22:32:24 +01003923 LINK_AS_NEEDED=yes
3924fi
3925if test "$LINK_AS_NEEDED" = yes; then
3926 AC_MSG_RESULT(yes)
3927else
3928 AC_MSG_RESULT(no)
3929fi
3930AC_SUBST(LINK_AS_NEEDED)
3931
Bram Moolenaar77c19352012-06-13 19:19:41 +02003932# IBM z/OS reset CFLAGS for config.mk
3933if test "$zOSUnix" = "yes"; then
3934 CFLAGS="-D_ALL_SOURCE -Wc,float\(ieee\),dll"
3935fi
3936
Bram Moolenaar071d4272004-06-13 20:20:40 +00003937dnl write output files
3938AC_OUTPUT(auto/config.mk:config.mk.in)
3939
3940dnl vim: set sw=2 tw=78 fo+=l: