/src/configure.in

https://bitbucket.org/ultra_iter/vim-qt · Autoconf · 3806 lines · 2900 code · 341 blank · 565 comment · 519 complexity · 3055817faa3ce25a05873cf8685f5136 MD5 · raw file

  1. dnl configure.in: autoconf script for Vim
  2. dnl Process this file with autoconf 2.12 or 2.13 to produce "configure".
  3. dnl Should also work with autoconf 2.54 and later.
  4. AC_INIT(vim.h)
  5. AC_CONFIG_HEADER(auto/config.h:config.h.in)
  6. dnl Being able to run configure means the system is Unix (compatible).
  7. AC_DEFINE(UNIX)
  8. AC_PROG_MAKE_SET
  9. dnl Checks for programs.
  10. AC_PROG_CC dnl required by almost everything
  11. AC_PROG_CPP dnl required by header file checks
  12. AC_PROGRAM_EGREP dnl required by AC_EGREP_CPP
  13. AC_ISC_POSIX dnl required by AC_C_CROSS
  14. AC_PROG_AWK dnl required for "make html" in ../doc
  15. dnl Don't strip if we don't have it
  16. AC_CHECK_PROG(STRIP, strip, strip, :)
  17. dnl Check for extension of executables
  18. AC_EXEEXT
  19. dnl Check for standard headers. We don't use this in Vim but other stuff
  20. dnl in autoconf needs it, where it uses STDC_HEADERS.
  21. AC_HEADER_STDC
  22. AC_HEADER_SYS_WAIT
  23. dnl Check for the flag that fails if stuff are missing.
  24. AC_MSG_CHECKING(--enable-fail-if-missing argument)
  25. AC_ARG_ENABLE(fail_if_missing,
  26. [ --enable-fail-if-missing Fail if dependencies on additional features
  27. specified on the command line are missing.],
  28. [fail_if_missing="yes"],
  29. [fail_if_missing="no"])
  30. AC_MSG_RESULT($fail_if_missing)
  31. dnl Set default value for CFLAGS if none is defined or it's empty
  32. if test -z "$CFLAGS"; then
  33. CFLAGS="-O"
  34. test "$GCC" = yes && CFLAGS="-O2 -fno-strength-reduce -Wall"
  35. fi
  36. if test "$GCC" = yes; then
  37. dnl method that should work for nearly all versions
  38. gccversion=`"$CC" -dumpversion`
  39. if test "x$gccversion" = "x"; then
  40. dnl old method; fall-back for when -dumpversion doesn't work
  41. gccversion=`"$CC" --version | sed -e '2,$d' -e 's/darwin.//' -e 's/^[[^0-9]]*\([[0-9]]\.[[0-9.]]*\).*$/\1/g'`
  42. fi
  43. dnl version 4.0.1 was reported to cause trouble on Macintosh by Marcin Dalecki
  44. if test "$gccversion" = "3.0.1" -o "$gccversion" = "3.0.2" -o "$gccversion" = "4.0.1"; then
  45. echo 'GCC [[34]].0.[[12]] has a bug in the optimizer, disabling "-O#"'
  46. CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-O/'`
  47. else
  48. if test "$gccversion" = "3.1" -o "$gccversion" = "3.2" -o "$gccversion" = "3.2.1" && `echo "$CFLAGS" | grep -v fno-strength-reduce >/dev/null`; then
  49. echo 'GCC 3.1 and 3.2 have a bug in the optimizer, adding "-fno-strength-reduce"'
  50. CFLAGS="$CFLAGS -fno-strength-reduce"
  51. fi
  52. fi
  53. fi
  54. dnl If configure thinks we are cross compiling, there might be something
  55. dnl wrong with the CC or CFLAGS settings, give a useful warning message
  56. if test "$cross_compiling" = yes; then
  57. AC_MSG_RESULT([cannot compile a simple program; if not cross compiling check CC and CFLAGS])
  58. fi
  59. dnl gcc-cpp has the wonderful -MM option to produce nicer dependencies.
  60. dnl But gcc 3.1 changed the meaning! See near the end.
  61. test "$GCC" = yes && CPP_MM=M; AC_SUBST(CPP_MM)
  62. if test -f ./toolcheck; then
  63. AC_CHECKING(for buggy tools)
  64. sh ./toolcheck 1>&AC_FD_MSG
  65. fi
  66. OS_EXTRA_SRC=""; OS_EXTRA_OBJ=""
  67. dnl Check for BeOS, which needs an extra source file
  68. AC_MSG_CHECKING(for BeOS)
  69. case `uname` in
  70. BeOS) OS_EXTRA_SRC=os_beos.c; OS_EXTRA_OBJ=objects/os_beos.o
  71. BEOS=yes; AC_MSG_RESULT(yes);;
  72. *) BEOS=no; AC_MSG_RESULT(no);;
  73. esac
  74. dnl If QNX is found, assume we don't want to use Xphoton
  75. dnl unless it was specifically asked for (--with-x)
  76. AC_MSG_CHECKING(for QNX)
  77. case `uname` in
  78. QNX) OS_EXTRA_SRC=os_qnx.c; OS_EXTRA_OBJ=objects/os_qnx.o
  79. test -z "$with_x" && with_x=no
  80. QNX=yes; AC_MSG_RESULT(yes);;
  81. *) QNX=no; AC_MSG_RESULT(no);;
  82. esac
  83. dnl Check for Darwin and MacOS X
  84. dnl We do a check for MacOS X in the very beginning because there
  85. dnl are a lot of other things we need to change besides GUI stuff
  86. AC_MSG_CHECKING([for Darwin (Mac OS X)])
  87. if test "`(uname) 2>/dev/null`" = Darwin; then
  88. AC_MSG_RESULT(yes)
  89. AC_MSG_CHECKING(--disable-darwin argument)
  90. AC_ARG_ENABLE(darwin,
  91. [ --disable-darwin Disable Darwin (Mac OS X) support.],
  92. , [enable_darwin="yes"])
  93. if test "$enable_darwin" = "yes"; then
  94. AC_MSG_RESULT(no)
  95. AC_MSG_CHECKING(if Darwin files are there)
  96. if test -f os_macosx.m; then
  97. AC_MSG_RESULT(yes)
  98. else
  99. AC_MSG_RESULT([no, Darwin support disabled])
  100. enable_darwin=no
  101. fi
  102. else
  103. AC_MSG_RESULT([yes, Darwin support excluded])
  104. fi
  105. AC_MSG_CHECKING(--with-mac-arch argument)
  106. AC_ARG_WITH(mac-arch, [ --with-mac-arch=ARCH current, intel, ppc or both],
  107. MACARCH="$withval"; AC_MSG_RESULT($MACARCH),
  108. MACARCH="current"; AC_MSG_RESULT(defaulting to $MACARCH))
  109. AC_MSG_CHECKING(--with-developer-dir argument)
  110. AC_ARG_WITH(developer-dir, [ --with-developer-dir=PATH use PATH as location for Xcode developer tools],
  111. DEVELOPER_DIR="$withval"; AC_MSG_RESULT($DEVELOPER_DIR),
  112. DEVELOPER_DIR=""; AC_MSG_RESULT(not present))
  113. if test "x$DEVELOPER_DIR" = "x"; then
  114. AC_PATH_PROG(XCODE_SELECT, xcode-select)
  115. if test "x$XCODE_SELECT" != "x"; then
  116. AC_MSG_CHECKING(for developer dir using xcode-select)
  117. DEVELOPER_DIR=`$XCODE_SELECT -print-path`
  118. AC_MSG_RESULT([$DEVELOPER_DIR])
  119. else
  120. DEVELOPER_DIR=/Developer
  121. fi
  122. fi
  123. if test "x$MACARCH" = "xboth"; then
  124. AC_MSG_CHECKING(for 10.4 universal SDK)
  125. dnl There is a terrible inconsistency (but we appear to get away with it):
  126. dnl $CFLAGS uses the 10.4u SDK library for the headers, while $CPPFLAGS
  127. dnl doesn't, because "gcc -E" doesn't grok it. That means the configure
  128. dnl tests using the preprocessor are actually done with the wrong header
  129. dnl files. $LDFLAGS is set at the end, because configure uses it together
  130. dnl with $CFLAGS and we can only have one -sysroot argument.
  131. save_cppflags="$CPPFLAGS"
  132. save_cflags="$CFLAGS"
  133. save_ldflags="$LDFLAGS"
  134. CFLAGS="$CFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
  135. AC_TRY_LINK([ ], [ ],
  136. AC_MSG_RESULT(found, will make universal binary),
  137. AC_MSG_RESULT(not found)
  138. CFLAGS="$save_cflags"
  139. AC_MSG_CHECKING(if Intel architecture is supported)
  140. CPPFLAGS="$CPPFLAGS -arch i386"
  141. LDFLAGS="$save_ldflags -arch i386"
  142. AC_TRY_LINK([ ], [ ],
  143. AC_MSG_RESULT(yes); MACARCH="intel",
  144. AC_MSG_RESULT(no, using PowerPC)
  145. MACARCH="ppc"
  146. CPPFLAGS="$save_cppflags -arch ppc"
  147. LDFLAGS="$save_ldflags -arch ppc"))
  148. elif test "x$MACARCH" = "xintel"; then
  149. CPPFLAGS="$CPPFLAGS -arch intel"
  150. LDFLAGS="$LDFLAGS -arch intel"
  151. elif test "x$MACARCH" = "xppc"; then
  152. CPPFLAGS="$CPPFLAGS -arch ppc"
  153. LDFLAGS="$LDFLAGS -arch ppc"
  154. fi
  155. if test "$enable_darwin" = "yes"; then
  156. MACOSX=yes
  157. OS_EXTRA_SRC="os_macosx.m os_mac_conv.c";
  158. OS_EXTRA_OBJ="objects/os_macosx.o objects/os_mac_conv.o"
  159. dnl TODO: use -arch i386 on Intel machines
  160. CPPFLAGS="$CPPFLAGS -DMACOS_X_UNIX -no-cpp-precomp"
  161. dnl If Carbon is found, assume we don't want X11
  162. dnl unless it was specifically asked for (--with-x)
  163. dnl or Motif, Athena or GTK GUI is used.
  164. AC_CHECK_HEADER(Carbon/Carbon.h, CARBON=yes)
  165. if test "x$CARBON" = "xyes"; then
  166. if test -z "$with_x" -a "X$enable_gui" != Xmotif -a "X$enable_gui" != Xathena -a "X$enable_gui" != Xgtk2; then
  167. with_x=no
  168. fi
  169. fi
  170. fi
  171. dnl Avoid a bug with -O2 with gcc 4.0.1. Symptom: malloc() reports double
  172. dnl free. This happens in expand_filename(), because the optimizer swaps
  173. dnl two blocks of code, both using "repl", that can't be swapped.
  174. if test "$MACARCH" = "intel" -o "$MACARCH" = "both"; then
  175. CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-Oz/'`
  176. fi
  177. else
  178. AC_MSG_RESULT(no)
  179. fi
  180. AC_SUBST(OS_EXTRA_SRC)
  181. AC_SUBST(OS_EXTRA_OBJ)
  182. dnl Add /usr/local/lib to $LDFLAGS and /usr/local/include to CFLAGS.
  183. dnl Only when the directory exists and it wasn't there yet.
  184. dnl For gcc don't do this when it is already in the default search path.
  185. dnl Skip all of this when cross-compiling.
  186. if test "$cross_compiling" = no; then
  187. AC_MSG_CHECKING(--with-local-dir argument)
  188. have_local_include=''
  189. have_local_lib=''
  190. AC_ARG_WITH([local-dir], [ --with-local-dir=PATH search PATH instead of /usr/local for local libraries.
  191. --without-local-dir do not search /usr/local for local libraries.], [
  192. local_dir="$withval"
  193. case "$withval" in
  194. */*) ;;
  195. no)
  196. # avoid adding local dir to LDFLAGS and CPPFLAGS
  197. have_local_include=yes
  198. have_local_lib=yes
  199. ;;
  200. *) AC_MSG_ERROR(must pass path argument to --with-local-dir) ;;
  201. esac
  202. AC_MSG_RESULT($local_dir)
  203. ], [
  204. local_dir=/usr/local
  205. AC_MSG_RESULT(Defaulting to $local_dir)
  206. ])
  207. if test "$GCC" = yes -a "$local_dir" != no; then
  208. echo 'void f(){}' > conftest.c
  209. dnl -no-cpp-precomp is needed for OS X 10.2 (Ben Fowler)
  210. have_local_include=`${CC-cc} -no-cpp-precomp -c -v conftest.c 2>&1 | grep "${local_dir}/include"`
  211. have_local_lib=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/lib"`
  212. rm -f conftest.c conftest.o
  213. fi
  214. if test -z "$have_local_lib" -a -d "${local_dir}/lib"; then
  215. tt=`echo "$LDFLAGS" | sed -e "s+-L${local_dir}/lib ++g" -e "s+-L${local_dir}/lib$++g"`
  216. if test "$tt" = "$LDFLAGS"; then
  217. LDFLAGS="$LDFLAGS -L${local_dir}/lib"
  218. fi
  219. fi
  220. if test -z "$have_local_include" -a -d "${local_dir}/include"; then
  221. tt=`echo "$CPPFLAGS" | sed -e "s+-I${local_dir}/include ++g" -e "s+-I${local_dir}/include$++g"`
  222. if test "$tt" = "$CPPFLAGS"; then
  223. CPPFLAGS="$CPPFLAGS -I${local_dir}/include"
  224. fi
  225. fi
  226. fi
  227. AC_MSG_CHECKING(--with-vim-name argument)
  228. AC_ARG_WITH(vim-name, [ --with-vim-name=NAME what to call the Vim executable],
  229. VIMNAME="$withval"; AC_MSG_RESULT($VIMNAME),
  230. VIMNAME="vim"; AC_MSG_RESULT(Defaulting to $VIMNAME))
  231. AC_SUBST(VIMNAME)
  232. AC_MSG_CHECKING(--with-ex-name argument)
  233. AC_ARG_WITH(ex-name, [ --with-ex-name=NAME what to call the Ex executable],
  234. EXNAME="$withval"; AC_MSG_RESULT($EXNAME),
  235. EXNAME="ex"; AC_MSG_RESULT(Defaulting to ex))
  236. AC_SUBST(EXNAME)
  237. AC_MSG_CHECKING(--with-view-name argument)
  238. AC_ARG_WITH(view-name, [ --with-view-name=NAME what to call the View executable],
  239. VIEWNAME="$withval"; AC_MSG_RESULT($VIEWNAME),
  240. VIEWNAME="view"; AC_MSG_RESULT(Defaulting to view))
  241. AC_SUBST(VIEWNAME)
  242. AC_MSG_CHECKING(--with-global-runtime argument)
  243. AC_ARG_WITH(global-runtime, [ --with-global-runtime=DIR global runtime directory in 'runtimepath'],
  244. AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL, "$withval"),
  245. AC_MSG_RESULT(no))
  246. AC_MSG_CHECKING(--with-modified-by argument)
  247. AC_ARG_WITH(modified-by, [ --with-modified-by=NAME name of who modified a release version],
  248. AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(MODIFIED_BY, "$withval"),
  249. AC_MSG_RESULT(no))
  250. dnl Check for EBCDIC stolen from the LYNX port to z/OS Unix
  251. AC_MSG_CHECKING(if character set is EBCDIC)
  252. AC_TRY_COMPILE([ ],
  253. [ /* TryCompile function for CharSet.
  254. Treat any failure as ASCII for compatibility with existing art.
  255. Use compile-time rather than run-time tests for cross-compiler
  256. tolerance. */
  257. #if '0'!=240
  258. make an error "Character set is not EBCDIC"
  259. #endif ],
  260. [ # TryCompile action if true
  261. cf_cv_ebcdic=yes ],
  262. [ # TryCompile action if false
  263. cf_cv_ebcdic=no])
  264. # end of TryCompile ])
  265. # end of CacheVal CvEbcdic
  266. AC_MSG_RESULT($cf_cv_ebcdic)
  267. case "$cf_cv_ebcdic" in #(vi
  268. yes) AC_DEFINE(EBCDIC)
  269. line_break='"\\n"'
  270. ;;
  271. *) line_break='"\\012"';;
  272. esac
  273. AC_SUBST(line_break)
  274. if test "$cf_cv_ebcdic" = "yes"; then
  275. dnl If we have EBCDIC we most likley have z/OS Unix, let's test it!
  276. AC_MSG_CHECKING(for z/OS Unix)
  277. case `uname` in
  278. OS/390) zOSUnix="yes";
  279. dnl If using cc the environment variable _CC_CCMODE must be
  280. dnl set to "1", so that some compiler extensions are enabled.
  281. dnl If using c89 the environment variable is named _CC_C89MODE.
  282. dnl Note: compile with c89 never tested.
  283. if test "$CC" = "cc"; then
  284. ccm="$_CC_CCMODE"
  285. ccn="CC"
  286. else
  287. if test "$CC" = "c89"; then
  288. ccm="$_CC_C89MODE"
  289. ccn="C89"
  290. else
  291. ccm=1
  292. fi
  293. fi
  294. if test "$ccm" != "1"; then
  295. echo ""
  296. echo "------------------------------------------"
  297. echo " On z/OS Unix, the environment variable"
  298. echo " __CC_${ccn}MODE must be set to \"1\"!"
  299. echo " Do:"
  300. echo " export _CC_${ccn}MODE=1"
  301. echo " and then call configure again."
  302. echo "------------------------------------------"
  303. exit 1
  304. fi
  305. CFLAGS="$CFLAGS -D_ALL_SOURCE -Wc,float\\(IEEE\\)";
  306. LDFLAGS="$LDFLAGS -Wl,EDIT=NO"
  307. AC_MSG_RESULT(yes)
  308. ;;
  309. *) zOSUnix="no";
  310. AC_MSG_RESULT(no)
  311. ;;
  312. esac
  313. fi
  314. dnl Set QUOTESED. Needs additional backslashes on zOS
  315. if test "$zOSUnix" = "yes"; then
  316. QUOTESED="sed -e 's/[[\\\\\"]]/\\\\\\\\&/g' -e 's/\\\\\\\\\"/\"/' -e 's/\\\\\\\\\";\$\$/\";/'"
  317. else
  318. QUOTESED="sed -e 's/[[\\\\\"]]/\\\\&/g' -e 's/\\\\\"/\"/' -e 's/\\\\\";\$\$/\";/'"
  319. fi
  320. AC_SUBST(QUOTESED)
  321. dnl Link with -lselinux for SELinux stuff; if not found
  322. AC_MSG_CHECKING(--disable-selinux argument)
  323. AC_ARG_ENABLE(selinux,
  324. [ --disable-selinux Don't check for SELinux support.],
  325. , enable_selinux="yes")
  326. if test "$enable_selinux" = "yes"; then
  327. AC_MSG_RESULT(no)
  328. AC_CHECK_LIB(selinux, is_selinux_enabled,
  329. [LIBS="$LIBS -lselinux"
  330. AC_DEFINE(HAVE_SELINUX)])
  331. else
  332. AC_MSG_RESULT(yes)
  333. fi
  334. dnl Check user requested features.
  335. AC_MSG_CHECKING(--with-features argument)
  336. AC_ARG_WITH(features, [ --with-features=TYPE tiny, small, normal, big or huge (default: normal)],
  337. features="$withval"; AC_MSG_RESULT($features),
  338. features="normal"; AC_MSG_RESULT(Defaulting to normal))
  339. dovimdiff=""
  340. dogvimdiff=""
  341. case "$features" in
  342. tiny) AC_DEFINE(FEAT_TINY) ;;
  343. small) AC_DEFINE(FEAT_SMALL) ;;
  344. normal) AC_DEFINE(FEAT_NORMAL) dovimdiff="installvimdiff";
  345. dogvimdiff="installgvimdiff" ;;
  346. big) AC_DEFINE(FEAT_BIG) dovimdiff="installvimdiff";
  347. dogvimdiff="installgvimdiff" ;;
  348. huge) AC_DEFINE(FEAT_HUGE) dovimdiff="installvimdiff";
  349. dogvimdiff="installgvimdiff" ;;
  350. *) AC_MSG_RESULT([Sorry, $features is not supported]) ;;
  351. esac
  352. AC_SUBST(dovimdiff)
  353. AC_SUBST(dogvimdiff)
  354. AC_MSG_CHECKING(--with-compiledby argument)
  355. AC_ARG_WITH(compiledby, [ --with-compiledby=NAME name to show in :version message],
  356. compiledby="$withval"; AC_MSG_RESULT($withval),
  357. compiledby=""; AC_MSG_RESULT(no))
  358. AC_SUBST(compiledby)
  359. AC_MSG_CHECKING(--disable-xsmp argument)
  360. AC_ARG_ENABLE(xsmp,
  361. [ --disable-xsmp Disable XSMP session management],
  362. , enable_xsmp="yes")
  363. if test "$enable_xsmp" = "yes"; then
  364. AC_MSG_RESULT(no)
  365. AC_MSG_CHECKING(--disable-xsmp-interact argument)
  366. AC_ARG_ENABLE(xsmp-interact,
  367. [ --disable-xsmp-interact Disable XSMP interaction],
  368. , enable_xsmp_interact="yes")
  369. if test "$enable_xsmp_interact" = "yes"; then
  370. AC_MSG_RESULT(no)
  371. AC_DEFINE(USE_XSMP_INTERACT)
  372. else
  373. AC_MSG_RESULT(yes)
  374. fi
  375. else
  376. AC_MSG_RESULT(yes)
  377. fi
  378. dnl Check for Lua feature.
  379. AC_MSG_CHECKING(--enable-luainterp argument)
  380. AC_ARG_ENABLE(luainterp,
  381. [ --enable-luainterp[=OPTS] Include Lua interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
  382. [enable_luainterp="no"])
  383. AC_MSG_RESULT($enable_luainterp)
  384. if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then
  385. dnl -- find the lua executable
  386. AC_SUBST(vi_cv_path_lua)
  387. AC_MSG_CHECKING(--with-lua-prefix argument)
  388. AC_ARG_WITH(lua_prefix,
  389. [ --with-lua-prefix=PFX Prefix where Lua is installed.],
  390. with_lua_prefix="$withval"; AC_MSG_RESULT($with_lua_prefix),
  391. with_lua_prefix="";AC_MSG_RESULT(no))
  392. if test "X$with_lua_prefix" != "X"; then
  393. vi_cv_path_lua_pfx="$with_lua_prefix"
  394. else
  395. AC_MSG_CHECKING(LUA_PREFIX environment var)
  396. if test "X$LUA_PREFIX" != "X"; then
  397. AC_MSG_RESULT("$LUA_PREFIX")
  398. vi_cv_path_lua_pfx="$LUA_PREFIX"
  399. else
  400. AC_MSG_RESULT([not set, default to /usr])
  401. vi_cv_path_lua_pfx="/usr"
  402. fi
  403. fi
  404. LUA_INC=
  405. if test "X$vi_cv_path_lua_pfx" != "X"; then
  406. AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)
  407. if test -f $vi_cv_path_lua_pfx/include/lua.h; then
  408. AC_MSG_RESULT(yes)
  409. else
  410. AC_MSG_RESULT(no)
  411. dnl -- try to find Lua executable
  412. AC_PATH_PROG(vi_cv_path_lua, lua)
  413. if test "X$vi_cv_path_lua" != "X"; then
  414. dnl -- find Lua version
  415. AC_CACHE_CHECK(Lua version, vi_cv_version_lua,
  416. [ vi_cv_version_lua=`${vi_cv_path_lua} -e "print(_VERSION)" | sed 's/.* //'` ])
  417. AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua)
  418. if test -f $vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h; then
  419. AC_MSG_RESULT(yes)
  420. LUA_INC=/lua$vi_cv_version_lua
  421. else
  422. AC_MSG_RESULT(no)
  423. vi_cv_path_lua_pfx=
  424. fi
  425. fi
  426. fi
  427. fi
  428. if test "X$vi_cv_path_lua_pfx" != "X"; then
  429. if test "X$vi_cv_version_lua" != "X"; then
  430. dnl Test alternate location using version
  431. LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua$vi_cv_version_lua"
  432. else
  433. LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua"
  434. fi
  435. LUA_CFLAGS="-I${vi_cv_path_lua_pfx}/include${LUA_INC}"
  436. LUA_SRC="if_lua.c"
  437. LUA_OBJ="objects/if_lua.o"
  438. LUA_PRO="if_lua.pro"
  439. AC_DEFINE(FEAT_LUA)
  440. if test "$enable_luainterp" = "dynamic"; then
  441. dnl Determine the SONAME for the current version, but fallback to
  442. dnl liblua${vi_cv_version_lua}.so if no SONAME-versioned file is found.
  443. for i in 0 1 2 3 4 5 6 7 8 9; do
  444. if test -f "${vi_cv_path_lua_pfx}/lib/liblua${vi_cv_version_lua}.so.$i"; then
  445. LUA_SONAME=".$i"
  446. break
  447. fi
  448. done
  449. AC_DEFINE(DYNAMIC_LUA)
  450. LUA_LIBS=""
  451. LUA_CFLAGS="-DDYNAMIC_LUA_DLL=\\\"liblua${vi_cv_version_lua}.so$LUA_SONAME\\\" $LUA_CFLAGS"
  452. fi
  453. fi
  454. if test "$fail_if_missing" = "yes" -a -z "$LUA_SRC"; then
  455. AC_MSG_ERROR([could not configure lua])
  456. fi
  457. AC_SUBST(LUA_SRC)
  458. AC_SUBST(LUA_OBJ)
  459. AC_SUBST(LUA_PRO)
  460. AC_SUBST(LUA_LIBS)
  461. AC_SUBST(LUA_CFLAGS)
  462. fi
  463. dnl Check for MzScheme feature.
  464. AC_MSG_CHECKING(--enable-mzschemeinterp argument)
  465. AC_ARG_ENABLE(mzschemeinterp,
  466. [ --enable-mzschemeinterp Include MzScheme interpreter.], ,
  467. [enable_mzschemeinterp="no"])
  468. AC_MSG_RESULT($enable_mzschemeinterp)
  469. if test "$enable_mzschemeinterp" = "yes"; then
  470. dnl -- find the mzscheme executable
  471. AC_SUBST(vi_cv_path_mzscheme)
  472. AC_MSG_CHECKING(--with-plthome argument)
  473. AC_ARG_WITH(plthome,
  474. [ --with-plthome=PLTHOME Use PLTHOME.],
  475. with_plthome="$withval"; AC_MSG_RESULT($with_plthome),
  476. with_plthome="";AC_MSG_RESULT("no"))
  477. if test "X$with_plthome" != "X"; then
  478. vi_cv_path_mzscheme_pfx="$with_plthome"
  479. else
  480. AC_MSG_CHECKING(PLTHOME environment var)
  481. if test "X$PLTHOME" != "X"; then
  482. AC_MSG_RESULT("$PLTHOME")
  483. vi_cv_path_mzscheme_pfx="$PLTHOME"
  484. else
  485. AC_MSG_RESULT(not set)
  486. dnl -- try to find MzScheme executable
  487. AC_PATH_PROG(vi_cv_path_mzscheme, mzscheme)
  488. dnl resolve symbolic link, the executable is often elsewhere and there
  489. dnl are no links for the include files.
  490. if test "X$vi_cv_path_mzscheme" != "X"; then
  491. lsout=`ls -l $vi_cv_path_mzscheme`
  492. if echo "$lsout" | grep -e '->' >/dev/null 2>/dev/null; then
  493. vi_cv_path_mzscheme=`echo "$lsout" | sed 's/.*-> \(.*\)/\1/'`
  494. fi
  495. fi
  496. if test "X$vi_cv_path_mzscheme" != "X"; then
  497. dnl -- find where MzScheme thinks it was installed
  498. AC_CACHE_CHECK(MzScheme install prefix,vi_cv_path_mzscheme_pfx,
  499. dnl different versions of MzScheme differ in command line processing
  500. dnl use universal approach
  501. echo "(display (simplify-path \
  502. (build-path (call-with-values \
  503. (lambda () (split-path (find-system-path (quote exec-file)))) \
  504. (lambda (base name must-be-dir?) base)) (quote up))))" > mzdirs.scm
  505. dnl Remove a trailing slash
  506. [ vi_cv_path_mzscheme_pfx=`${vi_cv_path_mzscheme} -r mzdirs.scm | \
  507. sed -e 's+/$++'` ])
  508. rm -f mzdirs.scm
  509. fi
  510. fi
  511. fi
  512. SCHEME_INC=
  513. if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
  514. AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include)
  515. if test -f $vi_cv_path_mzscheme_pfx/include/scheme.h; then
  516. SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include
  517. AC_MSG_RESULT(yes)
  518. else
  519. AC_MSG_RESULT(no)
  520. AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt)
  521. if test -f $vi_cv_path_mzscheme_pfx/include/plt/scheme.h; then
  522. AC_MSG_RESULT(yes)
  523. SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt
  524. else
  525. AC_MSG_RESULT(no)
  526. AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket)
  527. if test -f $vi_cv_path_mzscheme_pfx/include/racket/scheme.h; then
  528. AC_MSG_RESULT(yes)
  529. SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket
  530. else
  531. AC_MSG_RESULT(no)
  532. AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/)
  533. if test -f /usr/include/plt/scheme.h; then
  534. AC_MSG_RESULT(yes)
  535. SCHEME_INC=/usr/include/plt
  536. else
  537. AC_MSG_RESULT(no)
  538. AC_MSG_CHECKING(if scheme.h can be found in /usr/include/racket/)
  539. if test -f /usr/include/racket/scheme.h; then
  540. AC_MSG_RESULT(yes)
  541. SCHEME_INC=/usr/include/racket
  542. else
  543. AC_MSG_RESULT(no)
  544. vi_cv_path_mzscheme_pfx=
  545. fi
  546. fi
  547. fi
  548. fi
  549. fi
  550. fi
  551. if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
  552. if test "x$MACOSX" = "xyes"; then
  553. MZSCHEME_LIBS="-framework PLT_MzScheme"
  554. elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"; then
  555. MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"
  556. MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
  557. elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket3m.a"; then
  558. MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libracket3m.a"
  559. MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
  560. elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket.a"; then
  561. MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libracket.a ${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a"
  562. elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme.a"; then
  563. MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libmzscheme.a ${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a"
  564. else
  565. dnl Using shared objects
  566. if test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.so"; then
  567. MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lmzscheme3m"
  568. MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
  569. elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket3m.so"; then
  570. MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lracket3m"
  571. MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
  572. elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libracket.so"; then
  573. MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lracket -lmzgc"
  574. else
  575. MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lmzscheme -lmzgc"
  576. fi
  577. if test "$GCC" = yes; then
  578. dnl Make Vim remember the path to the library. For when it's not in
  579. dnl $LD_LIBRARY_PATH.
  580. MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${vi_cv_path_mzscheme_pfx}/lib"
  581. elif test "`(uname) 2>/dev/null`" = SunOS &&
  582. uname -r | grep '^5' >/dev/null; then
  583. MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${vi_cv_path_mzscheme_pfx}/lib"
  584. fi
  585. fi
  586. if test -d $vi_cv_path_mzscheme_pfx/lib/plt/collects; then
  587. SCHEME_COLLECTS=lib/plt/
  588. else
  589. if test -d $vi_cv_path_mzscheme_pfx/lib/racket/collects; then
  590. SCHEME_COLLECTS=lib/racket/
  591. fi
  592. fi
  593. if test -f "${vi_cv_path_mzscheme_pfx}/${SCHEME_COLLECTS}collects/scheme/base.ss" ; then
  594. MZSCHEME_EXTRA="mzscheme_base.c"
  595. else
  596. if test -f "${vi_cv_path_mzscheme_pfx}/${SCHEME_COLLECTS}collects/scheme/base.rkt" ; then
  597. MZSCHEME_EXTRA="mzscheme_base.c"
  598. fi
  599. fi
  600. if test "X$MZSCHEME_EXTRA" != "X" ; then
  601. dnl need to generate bytecode for MzScheme base
  602. MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE"
  603. MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
  604. fi
  605. MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -I${SCHEME_INC} \
  606. -DMZSCHEME_COLLECTS='\"${vi_cv_path_mzscheme_pfx}/${SCHEME_COLLECTS}collects\"'"
  607. MZSCHEME_SRC="if_mzsch.c"
  608. MZSCHEME_OBJ="objects/if_mzsch.o"
  609. MZSCHEME_PRO="if_mzsch.pro"
  610. AC_DEFINE(FEAT_MZSCHEME)
  611. fi
  612. AC_SUBST(MZSCHEME_SRC)
  613. AC_SUBST(MZSCHEME_OBJ)
  614. AC_SUBST(MZSCHEME_PRO)
  615. AC_SUBST(MZSCHEME_LIBS)
  616. AC_SUBST(MZSCHEME_CFLAGS)
  617. AC_SUBST(MZSCHEME_EXTRA)
  618. AC_SUBST(MZSCHEME_MZC)
  619. fi
  620. AC_MSG_CHECKING(--enable-perlinterp argument)
  621. AC_ARG_ENABLE(perlinterp,
  622. [ --enable-perlinterp[=OPTS] Include Perl interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
  623. [enable_perlinterp="no"])
  624. AC_MSG_RESULT($enable_perlinterp)
  625. if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then
  626. AC_SUBST(vi_cv_path_perl)
  627. AC_PATH_PROG(vi_cv_path_perl, perl)
  628. if test "X$vi_cv_path_perl" != "X"; then
  629. AC_MSG_CHECKING(Perl version)
  630. if $vi_cv_path_perl -e 'require 5.003_01' >/dev/null 2>/dev/null; then
  631. eval `$vi_cv_path_perl -V:usethreads`
  632. eval `$vi_cv_path_perl -V:libperl`
  633. if test "X$usethreads" = "XUNKNOWN" -o "X$usethreads" = "Xundef"; then
  634. badthreads=no
  635. else
  636. if $vi_cv_path_perl -e 'require 5.6.0' >/dev/null 2>/dev/null; then
  637. eval `$vi_cv_path_perl -V:use5005threads`
  638. if test "X$use5005threads" = "XUNKNOWN" -o "X$use5005threads" = "Xundef"; then
  639. badthreads=no
  640. else
  641. badthreads=yes
  642. AC_MSG_RESULT(>>> Perl > 5.6 with 5.5 threads cannot be used <<<)
  643. fi
  644. else
  645. badthreads=yes
  646. AC_MSG_RESULT(>>> Perl 5.5 with threads cannot be used <<<)
  647. fi
  648. fi
  649. if test $badthreads = no; then
  650. AC_MSG_RESULT(OK)
  651. eval `$vi_cv_path_perl -V:shrpenv`
  652. if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04
  653. shrpenv=""
  654. fi
  655. vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlibexp}'`
  656. AC_SUBST(vi_cv_perllib)
  657. dnl Remove "-fno-something", it breaks using cproto.
  658. perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
  659. -e 'ccflags;perl_inc;print"\n"' | sed -e 's/-fno[[^ ]]*//'`
  660. dnl Remove "-lc", it breaks on FreeBSD when using "-pthread".
  661. perllibs=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed -e 'ldopts' | \
  662. sed -e '/Warning/d' -e '/Note (probably harmless)/d' \
  663. -e 's/-bE:perl.exp//' -e 's/-lc //'`
  664. dnl Don't add perl lib to $LIBS: if it's not in LD_LIBRARY_PATH
  665. dnl a test in configure may fail because of that.
  666. perlldflags=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed \
  667. -e 'ccdlflags' | sed -e 's/-bE:perl.exp//'`
  668. dnl check that compiling a simple program still works with the flags
  669. dnl added for Perl.
  670. AC_MSG_CHECKING([if compile and link flags for Perl are sane])
  671. cflags_save=$CFLAGS
  672. libs_save=$LIBS
  673. ldflags_save=$LDFLAGS
  674. CFLAGS="$CFLAGS $perlcppflags"
  675. LIBS="$LIBS $perllibs"
  676. LDFLAGS="$perlldflags $LDFLAGS"
  677. AC_TRY_LINK(,[ ],
  678. AC_MSG_RESULT(yes); perl_ok=yes,
  679. AC_MSG_RESULT(no: PERL DISABLED); perl_ok=no)
  680. CFLAGS=$cflags_save
  681. LIBS=$libs_save
  682. LDFLAGS=$ldflags_save
  683. if test $perl_ok = yes; then
  684. if test "X$perlcppflags" != "X"; then
  685. dnl remove -pipe and -Wxxx, it confuses cproto
  686. PERL_CFLAGS=`echo "$perlcppflags" | sed -e 's/-pipe //' -e 's/-W[[^ ]]*//'`
  687. fi
  688. if test "X$perlldflags" != "X"; then
  689. LDFLAGS="$perlldflags $LDFLAGS"
  690. fi
  691. PERL_LIBS=$perllibs
  692. PERL_SRC="auto/if_perl.c if_perlsfio.c"
  693. PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o"
  694. PERL_PRO="if_perl.pro if_perlsfio.pro"
  695. AC_DEFINE(FEAT_PERL)
  696. fi
  697. fi
  698. else
  699. AC_MSG_RESULT(>>> too old; need Perl version 5.003_01 or later <<<)
  700. fi
  701. fi
  702. if test "x$MACOSX" = "xyes"; then
  703. dnl Mac OS X 10.2 or later
  704. dir=/System/Library/Perl
  705. darwindir=$dir/darwin
  706. if test -d $darwindir; then
  707. PERL=/usr/bin/perl
  708. else
  709. dnl Mac OS X 10.3
  710. dir=/System/Library/Perl/5.8.1
  711. darwindir=$dir/darwin-thread-multi-2level
  712. if test -d $darwindir; then
  713. PERL=/usr/bin/perl
  714. fi
  715. fi
  716. if test -n "$PERL"; then
  717. PERL_DIR="$dir"
  718. PERL_CFLAGS="-DFEAT_PERL -I$darwindir/CORE"
  719. PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o $darwindir/auto/DynaLoader/DynaLoader.a"
  720. PERL_LIBS="-L$darwindir/CORE -lperl"
  721. fi
  722. dnl Perl on Mac OS X 10.5 adds "-arch" flags but these should only
  723. dnl be included if requested by passing --with-mac-arch to
  724. dnl configure, so strip these flags first (if present)
  725. PERL_LIBS=`echo "$PERL_LIBS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
  726. PERL_CFLAGS=`echo "$PERL_CFLAGS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
  727. fi
  728. if test "$enable_perlinterp" = "dynamic"; then
  729. if test "$perl_ok" = "yes" -a "X$libperl" != "X"; then
  730. AC_DEFINE(DYNAMIC_PERL)
  731. PERL_CFLAGS="-DDYNAMIC_PERL_DLL=\\\"$libperl\\\" $PERL_CFLAGS"
  732. fi
  733. fi
  734. if test "$fail_if_missing" = "yes" -a "$perl_ok" != "yes"; then
  735. AC_MSG_ERROR([could not configure perl])
  736. fi
  737. fi
  738. AC_SUBST(shrpenv)
  739. AC_SUBST(PERL_SRC)
  740. AC_SUBST(PERL_OBJ)
  741. AC_SUBST(PERL_PRO)
  742. AC_SUBST(PERL_CFLAGS)
  743. AC_SUBST(PERL_LIBS)
  744. AC_MSG_CHECKING(--enable-pythoninterp argument)
  745. AC_ARG_ENABLE(pythoninterp,
  746. [ --enable-pythoninterp[=OPTS] Include Python interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
  747. [enable_pythoninterp="no"])
  748. AC_MSG_RESULT($enable_pythoninterp)
  749. if test "$enable_pythoninterp" = "yes" -o "$enable_pythoninterp" = "dynamic"; then
  750. dnl -- find the python executable
  751. AC_PATH_PROG(vi_cv_path_python, python)
  752. if test "X$vi_cv_path_python" != "X"; then
  753. dnl -- get its version number
  754. AC_CACHE_CHECK(Python version,vi_cv_var_python_version,
  755. [[vi_cv_var_python_version=`
  756. ${vi_cv_path_python} -c 'import sys; print sys.version[:3]'`
  757. ]])
  758. dnl -- it must be at least version 1.4
  759. AC_MSG_CHECKING(Python is 1.4 or better)
  760. if ${vi_cv_path_python} -c \
  761. "import sys; sys.exit(${vi_cv_var_python_version} < 1.4)"
  762. then
  763. AC_MSG_RESULT(yep)
  764. dnl -- find where python thinks it was installed
  765. AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python_pfx,
  766. [ vi_cv_path_python_pfx=`
  767. ${vi_cv_path_python} -c \
  768. "import sys; print sys.prefix"` ])
  769. dnl -- and where it thinks it runs
  770. AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python_epfx,
  771. [ vi_cv_path_python_epfx=`
  772. ${vi_cv_path_python} -c \
  773. "import sys; print sys.exec_prefix"` ])
  774. dnl -- python's internal library path
  775. AC_CACHE_VAL(vi_cv_path_pythonpath,
  776. [ vi_cv_path_pythonpath=`
  777. unset PYTHONPATH;
  778. ${vi_cv_path_python} -c \
  779. "import sys, string; print string.join(sys.path,':')"` ])
  780. dnl -- where the Python implementation library archives are
  781. AC_ARG_WITH(python-config-dir,
  782. [ --with-python-config-dir=PATH Python's config directory],
  783. [ vi_cv_path_python_conf="${withval}" ] )
  784. AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python_conf,
  785. [
  786. vi_cv_path_python_conf=
  787. for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
  788. for subdir in lib64 lib share; do
  789. d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
  790. if test -d "$d" && test -f "$d/config.c"; then
  791. vi_cv_path_python_conf="$d"
  792. fi
  793. done
  794. done
  795. ])
  796. PYTHON_CONFDIR="${vi_cv_path_python_conf}"
  797. if test "X$PYTHON_CONFDIR" = "X"; then
  798. AC_MSG_RESULT([can't find it!])
  799. else
  800. dnl -- we need to examine Python's config/Makefile too
  801. dnl see what the interpreter is built from
  802. AC_CACHE_VAL(vi_cv_path_python_plibs,
  803. [
  804. pwd=`pwd`
  805. tmp_mkf="$pwd/config-PyMake$$"
  806. cat -- "${PYTHON_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
  807. __:
  808. @echo "python_BASEMODLIBS='$(BASEMODLIBS)'"
  809. @echo "python_LIBS='$(LIBS)'"
  810. @echo "python_SYSLIBS='$(SYSLIBS)'"
  811. @echo "python_LINKFORSHARED='$(LINKFORSHARED)'"
  812. @echo "python_INSTSONAME='$(INSTSONAME)'"
  813. eof
  814. dnl -- delete the lines from make about Entering/Leaving directory
  815. eval "`cd ${PYTHON_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
  816. rm -f -- "${tmp_mkf}"
  817. if test "x$MACOSX" = "xyes" && ${vi_cv_path_python} -c \
  818. "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then
  819. vi_cv_path_python_plibs="-framework Python"
  820. else
  821. if test "${vi_cv_var_python_version}" = "1.4"; then
  822. vi_cv_path_python_plibs="${PYTHON_CONFDIR}/libModules.a ${PYTHON_CONFDIR}/libPython.a ${PYTHON_CONFDIR}/libObjects.a ${PYTHON_CONFDIR}/libParser.a"
  823. else
  824. vi_cv_path_python_plibs="-L${PYTHON_CONFDIR} -lpython${vi_cv_var_python_version}"
  825. fi
  826. vi_cv_path_python_plibs="${vi_cv_path_python_plibs} ${python_BASEMODLIBS} ${python_LIBS} ${python_SYSLIBS} ${python_LINKFORSHARED}"
  827. dnl remove -ltermcap, it can conflict with an earlier -lncurses
  828. vi_cv_path_python_plibs=`echo $vi_cv_path_python_plibs | sed s/-ltermcap//`
  829. fi
  830. ])
  831. PYTHON_LIBS="${vi_cv_path_python_plibs}"
  832. if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
  833. PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME=\\\"${vi_cv_path_python_pfx}\\\""
  834. else
  835. 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}\\\""
  836. fi
  837. PYTHON_SRC="if_python.c"
  838. dnl For Mac OSX 10.2 config.o is included in the Python library.
  839. if test "x$MACOSX" = "xyes"; then
  840. PYTHON_OBJ="objects/if_python.o"
  841. else
  842. PYTHON_OBJ="objects/if_python.o objects/py_config.o"
  843. fi
  844. if test "${vi_cv_var_python_version}" = "1.4"; then
  845. PYTHON_OBJ="$PYTHON_OBJ objects/py_getpath.o"
  846. fi
  847. PYTHON_GETPATH_CFLAGS="-DPYTHONPATH='\"${vi_cv_path_pythonpath}\"' -DPREFIX='\"${vi_cv_path_python_pfx}\"' -DEXEC_PREFIX='\"${vi_cv_path_python_epfx}\"'"
  848. dnl On FreeBSD linking with "-pthread" is required to use threads.
  849. dnl _THREAD_SAFE must be used for compiling then.
  850. dnl The "-pthread" is added to $LIBS, so that the following check for
  851. dnl sigaltstack() will look in libc_r (it's there in libc!).
  852. dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
  853. dnl will then define target-specific defines, e.g., -D_REENTRANT.
  854. dnl Don't do this for Mac OSX, -pthread will generate a warning.
  855. AC_MSG_CHECKING([if -pthread should be used])
  856. threadsafe_flag=
  857. thread_lib=
  858. dnl if test "x$MACOSX" != "xyes"; then
  859. if test "`(uname) 2>/dev/null`" != Darwin; then
  860. test "$GCC" = yes && threadsafe_flag="-pthread"
  861. if test "`(uname) 2>/dev/null`" = FreeBSD; then
  862. threadsafe_flag="-D_THREAD_SAFE"
  863. thread_lib="-pthread"
  864. fi
  865. fi
  866. libs_save_old=$LIBS
  867. if test -n "$threadsafe_flag"; then
  868. cflags_save=$CFLAGS
  869. CFLAGS="$CFLAGS $threadsafe_flag"
  870. LIBS="$LIBS $thread_lib"
  871. AC_TRY_LINK(,[ ],
  872. AC_MSG_RESULT(yes); PYTHON_CFLAGS="$PYTHON_CFLAGS $threadsafe_flag",
  873. AC_MSG_RESULT(no); LIBS=$libs_save_old
  874. )
  875. CFLAGS=$cflags_save
  876. else
  877. AC_MSG_RESULT(no)
  878. fi
  879. dnl Check that compiling a simple program still works with the flags
  880. dnl added for Python.
  881. AC_MSG_CHECKING([if compile and link flags for Python are sane])
  882. cflags_save=$CFLAGS
  883. libs_save=$LIBS
  884. CFLAGS="$CFLAGS $PYTHON_CFLAGS"
  885. LIBS="$LIBS $PYTHON_LIBS"
  886. AC_TRY_LINK(,[ ],
  887. AC_MSG_RESULT(yes); python_ok=yes,
  888. AC_MSG_RESULT(no: PYTHON DISABLED); python_ok=no)
  889. CFLAGS=$cflags_save
  890. LIBS=$libs_save
  891. if test $python_ok = yes; then
  892. AC_DEFINE(FEAT_PYTHON)
  893. else
  894. LIBS=$libs_save_old
  895. PYTHON_SRC=
  896. PYTHON_OBJ=
  897. PYTHON_LIBS=
  898. PYTHON_CFLAGS=
  899. fi
  900. fi
  901. else
  902. AC_MSG_RESULT(too old)
  903. fi
  904. fi
  905. if test "$fail_if_missing" = "yes" -a "$python_ok" != "yes"; then
  906. AC_MSG_ERROR([could not configure python])
  907. fi
  908. fi
  909. AC_SUBST(PYTHON_CONFDIR)
  910. AC_SUBST(PYTHON_LIBS)
  911. AC_SUBST(PYTHON_GETPATH_CFLAGS)
  912. AC_SUBST(PYTHON_CFLAGS)
  913. AC_SUBST(PYTHON_SRC)
  914. AC_SUBST(PYTHON_OBJ)
  915. AC_MSG_CHECKING(--enable-python3interp argument)
  916. AC_ARG_ENABLE(python3interp,
  917. [ --enable-python3interp[=OPTS] Include Python3 interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
  918. [enable_python3interp="no"])
  919. AC_MSG_RESULT($enable_python3interp)
  920. if test "$enable_python3interp" = "yes" -o "$enable_python3interp" = "dynamic"; then
  921. dnl -- find the python3 executable
  922. AC_PATH_PROG(vi_cv_path_python3, python3)
  923. if test "X$vi_cv_path_python3" != "X"; then
  924. dnl -- get its version number
  925. AC_CACHE_CHECK(Python version,vi_cv_var_python3_version,
  926. [[vi_cv_var_python3_version=`
  927. ${vi_cv_path_python3} -c 'import sys; print(sys.version[:3])'`
  928. ]])
  929. dnl -- get abiflags for python 3.2 or higher (PEP 3149)
  930. AC_CACHE_CHECK(Python's abiflags,vi_cv_var_python3_abiflags,
  931. [
  932. vi_cv_var_python3_abiflags=
  933. if ${vi_cv_path_python3} -c \
  934. "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)"
  935. then
  936. vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \
  937. "import sys; print(sys.abiflags)"`
  938. fi ])
  939. dnl -- find where python3 thinks it was installed
  940. AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx,
  941. [ vi_cv_path_python3_pfx=`
  942. ${vi_cv_path_python3} -c \
  943. "import sys; print(sys.prefix)"` ])
  944. dnl -- and where it thinks it runs
  945. AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx,
  946. [ vi_cv_path_python3_epfx=`
  947. ${vi_cv_path_python3} -c \
  948. "import sys; print(sys.exec_prefix)"` ])
  949. dnl -- python3's internal library path
  950. AC_CACHE_VAL(vi_cv_path_python3path,
  951. [ vi_cv_path_python3path=`
  952. unset PYTHONPATH;
  953. ${vi_cv_path_python3} -c \
  954. "import sys, string; print(':'.join(sys.path))"` ])
  955. dnl -- where the Python implementation library archives are
  956. AC_ARG_WITH(python3-config-dir,
  957. [ --with-python3-config-dir=PATH Python's config directory],
  958. [ vi_cv_path_python3_conf="${withval}" ] )
  959. AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf,
  960. [
  961. vi_cv_path_python3_conf=
  962. config_dir="config"
  963. if test "${vi_cv_var_python3_abiflags}" != ""; then
  964. config_dir="${config_dir}-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
  965. fi
  966. for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do
  967. for subdir in lib64 lib share; do
  968. d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}"
  969. if test -d "$d" && test -f "$d/config.c"; then
  970. vi_cv_path_python3_conf="$d"
  971. fi
  972. done
  973. done
  974. ])
  975. PYTHON3_CONFDIR="${vi_cv_path_python3_conf}"
  976. if test "X$PYTHON3_CONFDIR" = "X"; then
  977. AC_MSG_RESULT([can't find it!])
  978. else
  979. dnl -- we need to examine Python's config/Makefile too
  980. dnl see what the interpreter is built from
  981. AC_CACHE_VAL(vi_cv_path_python3_plibs,
  982. [
  983. pwd=`pwd`
  984. tmp_mkf="$pwd/config-PyMake$$"
  985. cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
  986. __:
  987. @echo "python3_BASEMODLIBS='$(BASEMODLIBS)'"
  988. @echo "python3_LIBS='$(LIBS)'"
  989. @echo "python3_SYSLIBS='$(SYSLIBS)'"
  990. @echo "python3_INSTSONAME='$(INSTSONAME)'"
  991. eof
  992. dnl -- delete the lines from make about Entering/Leaving directory
  993. eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
  994. rm -f -- "${tmp_mkf}"
  995. vi_cv_path_python3_plibs="-L${PYTHON3_CONFDIR} -lpython${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}"
  996. vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}"
  997. dnl remove -ltermcap, it can conflict with an earlier -lncurses
  998. vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//`
  999. vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//`
  1000. ])
  1001. PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
  1002. if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
  1003. 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}\\\""
  1004. else
  1005. 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}\\\""
  1006. fi
  1007. PYTHON3_SRC="if_python3.c"
  1008. dnl For Mac OSX 10.2 config.o is included in the Python library.
  1009. if test "x$MACOSX" = "xyes"; then
  1010. PYTHON3_OBJ="objects/if_python3.o"
  1011. else
  1012. PYTHON3_OBJ="objects/if_python3.o objects/py3_config.o"
  1013. fi
  1014. dnl On FreeBSD linking with "-pthread" is required to use threads.
  1015. dnl _THREAD_SAFE must be used for compiling then.
  1016. dnl The "-pthread" is added to $LIBS, so that the following check for
  1017. dnl sigaltstack() will look in libc_r (it's there in libc!).
  1018. dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
  1019. dnl will then define target-specific defines, e.g., -D_REENTRANT.
  1020. dnl Don't do this for Mac OSX, -pthread will generate a warning.
  1021. AC_MSG_CHECKING([if -pthread should be used])
  1022. threadsafe_flag=
  1023. thread_lib=
  1024. dnl if test "x$MACOSX" != "xyes"; then
  1025. if test "`(uname) 2>/dev/null`" != Darwin; then
  1026. test "$GCC" = yes && threadsafe_flag="-pthread"
  1027. if test "`(uname) 2>/dev/null`" = FreeBSD; then
  1028. threadsafe_flag="-D_THREAD_SAFE"
  1029. thread_lib="-pthread"
  1030. fi
  1031. fi
  1032. libs_save_old=$LIBS
  1033. if test -n "$threadsafe_flag"; then
  1034. cflags_save=$CFLAGS
  1035. CFLAGS="$CFLAGS $threadsafe_flag"
  1036. LIBS="$LIBS $thread_lib"
  1037. AC_TRY_LINK(,[ ],
  1038. AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag",
  1039. AC_MSG_RESULT(no); LIBS=$libs_save_old
  1040. )
  1041. CFLAGS=$cflags_save
  1042. else
  1043. AC_MSG_RESULT(no)
  1044. fi
  1045. dnl check that compiling a simple program still works with the flags
  1046. dnl added for Python.
  1047. AC_MSG_CHECKING([if compile and link flags for Python 3 are sane])
  1048. cflags_save=$CFLAGS
  1049. libs_save=$LIBS
  1050. CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
  1051. LIBS="$LIBS $PYTHON3_LIBS"
  1052. AC_TRY_LINK(,[ ],
  1053. AC_MSG_RESULT(yes); python3_ok=yes,
  1054. AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no)
  1055. CFLAGS=$cflags_save
  1056. LIBS=$libs_save
  1057. if test "$python3_ok" = yes; then
  1058. AC_DEFINE(FEAT_PYTHON3)
  1059. else
  1060. LIBS=$libs_save_old
  1061. PYTHON3_SRC=
  1062. PYTHON3_OBJ=
  1063. PYTHON3_LIBS=
  1064. PYTHON3_CFLAGS=
  1065. fi
  1066. fi
  1067. fi
  1068. fi
  1069. AC_SUBST(PYTHON3_CONFDIR)
  1070. AC_SUBST(PYTHON3_LIBS)
  1071. AC_SUBST(PYTHON3_CFLAGS)
  1072. AC_SUBST(PYTHON3_SRC)
  1073. AC_SUBST(PYTHON3_OBJ)
  1074. dnl if python2.x and python3.x are enabled one can only link in code
  1075. dnl with dlopen(), dlsym(), dlclose()
  1076. if test "$python_ok" = yes && test "$python3_ok" = yes; then
  1077. AC_DEFINE(DYNAMIC_PYTHON)
  1078. AC_DEFINE(DYNAMIC_PYTHON3)
  1079. AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python)
  1080. cflags_save=$CFLAGS
  1081. CFLAGS="$CFLAGS $PYTHON_CFLAGS"
  1082. ldflags_save=$LDFLAGS
  1083. dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
  1084. LDFLAGS="-ldl $LDFLAGS"
  1085. AC_RUN_IFELSE([
  1086. #include <dlfcn.h>
  1087. /* If this program fails, then RTLD_GLOBAL is needed.
  1088. * RTLD_GLOBAL will be used and then it is not possible to
  1089. * have both python versions enabled in the same vim instance.
  1090. * Only the first pyhton version used will be switched on.
  1091. */
  1092. int no_rtl_global_needed_for(char *python_instsoname, char *prefix)
  1093. {
  1094. int needed = 0;
  1095. void* pylib = dlopen(python_instsoname, RTLD_LAZY);
  1096. if (pylib != 0)
  1097. {
  1098. void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome");
  1099. void (*init)(void) = dlsym(pylib, "Py_Initialize");
  1100. int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
  1101. void (*final)(void) = dlsym(pylib, "Py_Finalize");
  1102. (*pfx)(prefix);
  1103. (*init)();
  1104. needed = (*simple)("import termios") == -1;
  1105. (*final)();
  1106. dlclose(pylib);
  1107. }
  1108. return !needed;
  1109. }
  1110. int main(int argc, char** argv)
  1111. {
  1112. int not_needed = 0;
  1113. if (no_rtl_global_needed_for("${python_INSTSONAME}", "${vi_cv_path_python_pfx}"))
  1114. not_needed = 1;
  1115. return !not_needed;
  1116. }],
  1117. [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
  1118. CFLAGS=$cflags_save
  1119. LDFLAGS=$ldflags_save
  1120. AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python3)
  1121. cflags_save=$CFLAGS
  1122. CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
  1123. ldflags_save=$LDFLAGS
  1124. dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
  1125. LDFLAGS="-ldl $LDFLAGS"
  1126. AC_RUN_IFELSE([
  1127. #include <dlfcn.h>
  1128. #include <wchar.h>
  1129. /* If this program fails, then RTLD_GLOBAL is needed.
  1130. * RTLD_GLOBAL will be used and then it is not possible to
  1131. * have both python versions enabled in the same vim instance.
  1132. * Only the first pyhton version used will be switched on.
  1133. */
  1134. int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix)
  1135. {
  1136. int needed = 0;
  1137. void* pylib = dlopen(python_instsoname, RTLD_LAZY);
  1138. if (pylib != 0)
  1139. {
  1140. void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome");
  1141. void (*init)(void) = dlsym(pylib, "Py_Initialize");
  1142. int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
  1143. void (*final)(void) = dlsym(pylib, "Py_Finalize");
  1144. (*pfx)(prefix);
  1145. (*init)();
  1146. needed = (*simple)("import termios") == -1;
  1147. (*final)();
  1148. dlclose(pylib);
  1149. }
  1150. return !needed;
  1151. }
  1152. int main(int argc, char** argv)
  1153. {
  1154. int not_needed = 0;
  1155. if (no_rtl_global_needed_for("${python3_INSTSONAME}", L"${vi_cv_path_python3_pfx}"))
  1156. not_needed = 1;
  1157. return !not_needed;
  1158. }],
  1159. [AC_MSG_RESULT(yes);AC_DEFINE(PY3_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
  1160. CFLAGS=$cflags_save
  1161. LDFLAGS=$ldflags_save
  1162. PYTHON_SRC="if_python.c"
  1163. PYTHON_OBJ="objects/if_python.o"
  1164. PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${python_INSTSONAME}\\\""
  1165. PYTHON_LIBS=
  1166. PYTHON3_SRC="if_python3.c"
  1167. PYTHON3_OBJ="objects/if_python3.o"
  1168. PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${python3_INSTSONAME}\\\""
  1169. PYTHON3_LIBS=
  1170. elif test "$python_ok" = yes && test "$enable_pythoninterp" = "dynamic"; then
  1171. AC_DEFINE(DYNAMIC_PYTHON)
  1172. PYTHON_SRC="if_python.c"
  1173. PYTHON_OBJ="objects/if_python.o"
  1174. PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${python_INSTSONAME}\\\""
  1175. PYTHON_LIBS=
  1176. elif test "$python3_ok" = yes && test "$enable_python3interp" = "dynamic"; then
  1177. AC_DEFINE(DYNAMIC_PYTHON3)
  1178. PYTHON3_SRC="if_python3.c"
  1179. PYTHON3_OBJ="objects/if_python3.o"
  1180. PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"${python3_INSTSONAME}\\\""
  1181. PYTHON3_LIBS=
  1182. fi
  1183. AC_MSG_CHECKING(--enable-tclinterp argument)
  1184. AC_ARG_ENABLE(tclinterp,
  1185. [ --enable-tclinterp Include Tcl interpreter.], ,
  1186. [enable_tclinterp="no"])
  1187. AC_MSG_RESULT($enable_tclinterp)
  1188. if test "$enable_tclinterp" = "yes"; then
  1189. dnl on FreeBSD tclsh is a silly script, look for tclsh8.[5420]
  1190. AC_MSG_CHECKING(--with-tclsh argument)
  1191. AC_ARG_WITH(tclsh, [ --with-tclsh=PATH which tclsh to use (default: tclsh8.0)],
  1192. tclsh_name="$withval"; AC_MSG_RESULT($tclsh_name),
  1193. tclsh_name="tclsh8.5"; AC_MSG_RESULT(no))
  1194. AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
  1195. AC_SUBST(vi_cv_path_tcl)
  1196. dnl when no specific version specified, also try 8.4, 8.2 and 8.0
  1197. if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.5"; then
  1198. tclsh_name="tclsh8.4"
  1199. AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
  1200. fi
  1201. if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.4"; then
  1202. tclsh_name="tclsh8.2"
  1203. AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
  1204. fi
  1205. if test "X$vi_cv_path_tcl" = "X" -a $tclsh_name = "tclsh8.2"; then
  1206. tclsh_name="tclsh8.0"
  1207. AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
  1208. fi
  1209. dnl still didn't find it, try without version number
  1210. if test "X$vi_cv_path_tcl" = "X"; then
  1211. tclsh_name="tclsh"
  1212. AC_PATH_PROG(vi_cv_path_tcl, $tclsh_name)
  1213. fi
  1214. if test "X$vi_cv_path_tcl" != "X"; then
  1215. AC_MSG_CHECKING(Tcl version)
  1216. if echo 'exit [[expr [info tclversion] < 8.0]]' | $vi_cv_path_tcl - ; then
  1217. tclver=`echo 'puts [[info tclversion]]' | $vi_cv_path_tcl -`
  1218. AC_MSG_RESULT($tclver - OK);
  1219. 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 -`
  1220. AC_MSG_CHECKING(for location of Tcl include)
  1221. if test "x$MACOSX" != "xyes"; then
  1222. tclinc="$tclloc/include $tclloc/include/tcl $tclloc/include/tcl$tclver /usr/local/include /usr/local/include/tcl$tclver /usr/include /usr/include/tcl$tclver"
  1223. else
  1224. dnl For Mac OS X 10.3, use the OS-provided framework location
  1225. tclinc="/System/Library/Frameworks/Tcl.framework/Headers"
  1226. fi
  1227. TCL_INC=
  1228. for try in $tclinc; do
  1229. if test -f "$try/tcl.h"; then
  1230. AC_MSG_RESULT($try/tcl.h)
  1231. TCL_INC=$try
  1232. break
  1233. fi
  1234. done
  1235. if test -z "$TCL_INC"; then
  1236. AC_MSG_RESULT(<not found>)
  1237. SKIP_TCL=YES
  1238. fi
  1239. if test -z "$SKIP_TCL"; then
  1240. AC_MSG_CHECKING(for location of tclConfig.sh script)
  1241. if test "x$MACOSX" != "xyes"; then
  1242. tclcnf=`echo $tclinc | sed s/include/lib/g`
  1243. tclcnf="$tclcnf `echo $tclinc | sed s/include/lib64/g`"
  1244. else
  1245. dnl For Mac OS X 10.3, use the OS-provided framework location
  1246. tclcnf="/System/Library/Frameworks/Tcl.framework"
  1247. fi
  1248. for try in $tclcnf; do
  1249. if test -f $try/tclConfig.sh; then
  1250. AC_MSG_RESULT($try/tclConfig.sh)
  1251. . $try/tclConfig.sh
  1252. dnl use eval, because tcl 8.2 includes ${TCL_DBGX}
  1253. TCL_LIBS=`eval echo "$TCL_LIB_SPEC $TCL_LIBS"`
  1254. dnl Use $TCL_DEFS for -D_THREAD_SAFE et al. But only use the
  1255. dnl "-D_ABC" items. Watch out for -DFOO=long\ long.
  1256. 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'`
  1257. break
  1258. fi
  1259. done
  1260. if test -z "$TCL_LIBS"; then
  1261. AC_MSG_RESULT(<not found>)
  1262. AC_MSG_CHECKING(for Tcl library by myself)
  1263. tcllib=`echo $tclinc | sed s/include/lib/g`
  1264. tcllib="$tcllib `echo $tclinc | sed s/include/lib64/g`"
  1265. for ext in .so .a ; do
  1266. for ver in "" $tclver ; do
  1267. for try in $tcllib ; do
  1268. trylib=tcl$ver$ext
  1269. if test -f $try/lib$trylib ; then
  1270. AC_MSG_RESULT($try/lib$trylib)
  1271. TCL_LIBS="-L$try -ltcl$ver -ldl -lm"
  1272. if test "`(uname) 2>/dev/null`" = SunOS &&
  1273. uname -r | grep '^5' >/dev/null; then
  1274. TCL_LIBS="$TCL_LIBS -R $try"
  1275. fi
  1276. break 3
  1277. fi
  1278. done
  1279. done
  1280. done
  1281. if test -z "$TCL_LIBS"; then
  1282. AC_MSG_RESULT(<not found>)
  1283. SKIP_TCL=YES
  1284. fi
  1285. fi
  1286. if test -z "$SKIP_TCL"; then
  1287. AC_DEFINE(FEAT_TCL)
  1288. TCL_SRC=if_tcl.c
  1289. TCL_OBJ=objects/if_tcl.o
  1290. TCL_PRO=if_tcl.pro
  1291. TCL_CFLAGS="-I$TCL_INC $TCL_DEFS"
  1292. fi
  1293. fi
  1294. else
  1295. AC_MSG_RESULT(too old; need Tcl version 8.0 or later)
  1296. fi
  1297. fi
  1298. if test "$fail_if_missing" = "yes" -a -z "$TCL_SRC"; then
  1299. AC_MSG_ERROR([could not configure Tcl])
  1300. fi
  1301. fi
  1302. AC_SUBST(TCL_SRC)
  1303. AC_SUBST(TCL_OBJ)
  1304. AC_SUBST(TCL_PRO)
  1305. AC_SUBST(TCL_CFLAGS)
  1306. AC_SUBST(TCL_LIBS)
  1307. AC_MSG_CHECKING(--enable-rubyinterp argument)
  1308. AC_ARG_ENABLE(rubyinterp,
  1309. [ --enable-rubyinterp[=OPTS] Include Ruby interpreter. [default=no] [OPTS=no/yes/dynamic]], ,
  1310. [enable_rubyinterp="no"])
  1311. AC_MSG_RESULT($enable_rubyinterp)
  1312. if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then
  1313. AC_MSG_CHECKING(--with-ruby-command argument)
  1314. AC_SUBST(vi_cv_path_ruby)
  1315. AC_ARG_WITH(ruby-command, [ --with-ruby-command=RUBY name of the Ruby command (default: ruby)],
  1316. RUBY_CMD="$withval"; vi_cv_path_ruby="$withval"; AC_MSG_RESULT($RUBY_CMD),
  1317. RUBY_CMD="ruby"; AC_MSG_RESULT(defaulting to $RUBY_CMD))
  1318. AC_PATH_PROG(vi_cv_path_ruby, $RUBY_CMD)
  1319. if test "X$vi_cv_path_ruby" != "X"; then
  1320. AC_MSG_CHECKING(Ruby version)
  1321. if $vi_cv_path_ruby -e '(VERSION rescue RUBY_VERSION) >= "1.6.0" or exit 1' >/dev/null 2>/dev/null; then
  1322. AC_MSG_RESULT(OK)
  1323. AC_MSG_CHECKING(Ruby header files)
  1324. rubyhdrdir=`$vi_cv_path_ruby -r mkmf -e 'print Config::CONFIG[["rubyhdrdir"]] || Config::CONFIG[["archdir"]] || $hdrdir' 2>/dev/null`
  1325. if test "X$rubyhdrdir" != "X"; then
  1326. AC_MSG_RESULT($rubyhdrdir)
  1327. RUBY_CFLAGS="-I$rubyhdrdir"
  1328. rubyarch=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG[["arch"]]'`
  1329. if test -d "$rubyhdrdir/$rubyarch"; then
  1330. RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyhdrdir/$rubyarch"
  1331. fi
  1332. rubyversion=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG[["ruby_version"]].gsub(/\./, "")[[0,2]]'`
  1333. RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
  1334. rubylibs=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG[["LIBS"]]'`
  1335. if test "X$rubylibs" != "X"; then
  1336. RUBY_LIBS="$rubylibs"
  1337. fi
  1338. librubyarg=`$vi_cv_path_ruby -r rbconfig -e 'print Config.expand(Config::CONFIG[["LIBRUBYARG"]])'`
  1339. librubya=`$vi_cv_path_ruby -r rbconfig -e 'print Config.expand(Config::CONFIG[["LIBRUBY_A"]])'`
  1340. rubylibdir=`$vi_cv_path_ruby -r rbconfig -e 'print Config.expand(Config::CONFIG[["libdir"]])'`
  1341. if test -f "$rubylibdir/$librubya"; then
  1342. librubyarg="$librubyarg"
  1343. RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
  1344. elif test "$librubyarg" = "libruby.a"; then
  1345. dnl required on Mac OS 10.3 where libruby.a doesn't exist
  1346. librubyarg="-lruby"
  1347. RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
  1348. fi
  1349. if test "X$librubyarg" != "X"; then
  1350. RUBY_LIBS="$librubyarg $RUBY_LIBS"
  1351. fi
  1352. rubyldflags=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG[["LDFLAGS"]]'`
  1353. if test "X$rubyldflags" != "X"; then
  1354. dnl Ruby on Mac OS X 10.5 adds "-arch" flags but these should only
  1355. dnl be included if requested by passing --with-mac-arch to
  1356. dnl configure, so strip these flags first (if present)
  1357. rubyldflags=`echo "$rubyldflags" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
  1358. if test "X$rubyldflags" != "X"; then
  1359. LDFLAGS="$rubyldflags $LDFLAGS"
  1360. fi
  1361. fi
  1362. RUBY_SRC="if_ruby.c"
  1363. RUBY_OBJ="objects/if_ruby.o"
  1364. RUBY_PRO="if_ruby.pro"
  1365. AC_DEFINE(FEAT_RUBY)
  1366. if test "$enable_rubyinterp" = "dynamic"; then
  1367. libruby=`$vi_cv_path_ruby -r rbconfig -e 'printf "lib%s.%s\n", Config::CONFIG[["RUBY_SO_NAME"]], Config::CONFIG[["DLEXT"]]'`
  1368. AC_DEFINE(DYNAMIC_RUBY)
  1369. RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby\\\" -DDYNAMIC_RUBY_VER=$rubyversion $RUBY_CFLAGS"
  1370. RUBY_LIBS=
  1371. fi
  1372. else
  1373. AC_MSG_RESULT(not found; disabling Ruby)
  1374. fi
  1375. else
  1376. AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
  1377. fi
  1378. fi
  1379. if test "$fail_if_missing" = "yes" -a -z "$RUBY_OBJ"; then
  1380. AC_MSG_ERROR([could not configure Ruby])
  1381. fi
  1382. fi
  1383. AC_SUBST(RUBY_SRC)
  1384. AC_SUBST(RUBY_OBJ)
  1385. AC_SUBST(RUBY_PRO)
  1386. AC_SUBST(RUBY_CFLAGS)
  1387. AC_SUBST(RUBY_LIBS)
  1388. AC_MSG_CHECKING(--enable-cscope argument)
  1389. AC_ARG_ENABLE(cscope,
  1390. [ --enable-cscope Include cscope interface.], ,
  1391. [enable_cscope="no"])
  1392. AC_MSG_RESULT($enable_cscope)
  1393. if test "$enable_cscope" = "yes"; then
  1394. AC_DEFINE(FEAT_CSCOPE)
  1395. fi
  1396. AC_MSG_CHECKING(--enable-workshop argument)
  1397. AC_ARG_ENABLE(workshop,
  1398. [ --enable-workshop Include Sun Visual Workshop support.], ,
  1399. [enable_workshop="no"])
  1400. AC_MSG_RESULT($enable_workshop)
  1401. if test "$enable_workshop" = "yes"; then
  1402. AC_DEFINE(FEAT_SUN_WORKSHOP)
  1403. WORKSHOP_SRC="workshop.c integration.c"
  1404. AC_SUBST(WORKSHOP_SRC)
  1405. WORKSHOP_OBJ="objects/workshop.o objects/integration.o"
  1406. AC_SUBST(WORKSHOP_OBJ)
  1407. if test "${enable_gui-xxx}" = xxx; then
  1408. enable_gui=motif
  1409. fi
  1410. fi
  1411. AC_MSG_CHECKING(--disable-netbeans argument)
  1412. AC_ARG_ENABLE(netbeans,
  1413. [ --disable-netbeans Disable NetBeans integration support.],
  1414. , [enable_netbeans="yes"])
  1415. if test "$enable_netbeans" = "yes"; then
  1416. AC_MSG_RESULT(no)
  1417. dnl On Solaris we need the socket and nsl library.
  1418. AC_CHECK_LIB(socket, socket)
  1419. AC_CHECK_LIB(nsl, gethostbyname)
  1420. AC_MSG_CHECKING(whether compiling netbeans integration is possible)
  1421. AC_TRY_LINK([
  1422. #include <stdio.h>
  1423. #include <stdlib.h>
  1424. #include <stdarg.h>
  1425. #include <fcntl.h>
  1426. #include <netdb.h>
  1427. #include <netinet/in.h>
  1428. #include <errno.h>
  1429. #include <sys/types.h>
  1430. #include <sys/socket.h>
  1431. /* Check bitfields */
  1432. struct nbbuf {
  1433. unsigned int initDone:1;
  1434. ushort signmaplen;
  1435. };
  1436. ], [
  1437. /* Check creating a socket. */
  1438. struct sockaddr_in server;
  1439. (void)socket(AF_INET, SOCK_STREAM, 0);
  1440. (void)htons(100);
  1441. (void)gethostbyname("microsoft.com");
  1442. if (errno == ECONNREFUSED)
  1443. (void)connect(1, (struct sockaddr *)&server, sizeof(server));
  1444. ],
  1445. AC_MSG_RESULT(yes),
  1446. AC_MSG_RESULT(no); enable_netbeans="no")
  1447. else
  1448. AC_MSG_RESULT(yes)
  1449. fi
  1450. if test "$enable_netbeans" = "yes"; then
  1451. AC_DEFINE(FEAT_NETBEANS_INTG)
  1452. NETBEANS_SRC="netbeans.c"
  1453. AC_SUBST(NETBEANS_SRC)
  1454. NETBEANS_OBJ="objects/netbeans.o"
  1455. AC_SUBST(NETBEANS_OBJ)
  1456. fi
  1457. AC_MSG_CHECKING(--enable-sniff argument)
  1458. AC_ARG_ENABLE(sniff,
  1459. [ --enable-sniff Include Sniff interface.], ,
  1460. [enable_sniff="no"])
  1461. AC_MSG_RESULT($enable_sniff)
  1462. if test "$enable_sniff" = "yes"; then
  1463. AC_DEFINE(FEAT_SNIFF)
  1464. SNIFF_SRC="if_sniff.c"
  1465. AC_SUBST(SNIFF_SRC)
  1466. SNIFF_OBJ="objects/if_sniff.o"
  1467. AC_SUBST(SNIFF_OBJ)
  1468. fi
  1469. AC_MSG_CHECKING(--enable-multibyte argument)
  1470. AC_ARG_ENABLE(multibyte,
  1471. [ --enable-multibyte Include multibyte editing support.], ,
  1472. [enable_multibyte="no"])
  1473. AC_MSG_RESULT($enable_multibyte)
  1474. if test "$enable_multibyte" = "yes"; then
  1475. AC_DEFINE(FEAT_MBYTE)
  1476. fi
  1477. AC_MSG_CHECKING(--enable-hangulinput argument)
  1478. AC_ARG_ENABLE(hangulinput,
  1479. [ --enable-hangulinput Include Hangul input support.], ,
  1480. [enable_hangulinput="no"])
  1481. AC_MSG_RESULT($enable_hangulinput)
  1482. AC_MSG_CHECKING(--enable-xim argument)
  1483. AC_ARG_ENABLE(xim,
  1484. [ --enable-xim Include XIM input support.],
  1485. AC_MSG_RESULT($enable_xim),
  1486. [enable_xim="auto"; AC_MSG_RESULT(defaulting to auto)])
  1487. AC_MSG_CHECKING(--enable-fontset argument)
  1488. AC_ARG_ENABLE(fontset,
  1489. [ --enable-fontset Include X fontset output support.], ,
  1490. [enable_fontset="no"])
  1491. AC_MSG_RESULT($enable_fontset)
  1492. dnl defining FEAT_XFONTSET is delayed, so that it can be disabled for no GUI
  1493. test -z "$with_x" && with_x=yes
  1494. test "${enable_gui-yes}" != no -a "x$MACOSX" != "xyes" -a "x$QNX" != "xyes" && with_x=yes
  1495. if test "$with_x" = no; then
  1496. AC_MSG_RESULT(defaulting to: don't HAVE_X11)
  1497. else
  1498. dnl Do this check early, so that its failure can override user requests.
  1499. AC_PATH_PROG(xmkmfpath, xmkmf)
  1500. AC_PATH_XTRA
  1501. dnl On z/OS Unix the X libraries are DLLs. To use them the code must
  1502. dnl be compiled with a special option.
  1503. dnl Also add SM, ICE and Xmu to X_EXTRA_LIBS.
  1504. if test "$zOSUnix" = "yes"; then
  1505. CFLAGS="$CFLAGS -W c,dll"
  1506. LDFLAGS="$LDFLAGS -W l,dll"
  1507. X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE -lXmu"
  1508. fi
  1509. dnl On my HPUX system the X include dir is found, but the lib dir not.
  1510. dnl This is a desparate try to fix this.
  1511. if test -d "$x_includes" && test ! -d "$x_libraries"; then
  1512. x_libraries=`echo "$x_includes" | sed s/include/lib/`
  1513. AC_MSG_RESULT(Corrected X libraries to $x_libraries)
  1514. X_LIBS="$X_LIBS -L$x_libraries"
  1515. if test "`(uname) 2>/dev/null`" = SunOS &&
  1516. uname -r | grep '^5' >/dev/null; then
  1517. X_LIBS="$X_LIBS -R $x_libraries"
  1518. fi
  1519. fi
  1520. if test -d "$x_libraries" && test ! -d "$x_includes"; then
  1521. x_includes=`echo "$x_libraries" | sed s/lib/include/`
  1522. AC_MSG_RESULT(Corrected X includes to $x_includes)
  1523. X_CFLAGS="$X_CFLAGS -I$x_includes"
  1524. fi
  1525. dnl Remove "-I/usr/include " from X_CFLAGS, should not be needed.
  1526. X_CFLAGS="`echo $X_CFLAGS\ | sed 's%-I/usr/include %%'`"
  1527. dnl Remove "-L/usr/lib " from X_LIBS, should not be needed.
  1528. X_LIBS="`echo $X_LIBS\ | sed 's%-L/usr/lib %%'`"
  1529. dnl Same for "-R/usr/lib ".
  1530. X_LIBS="`echo $X_LIBS\ | sed -e 's%-R/usr/lib %%' -e 's%-R /usr/lib %%'`"
  1531. dnl Check if the X11 header files are correctly installed. On some systems
  1532. dnl Xlib.h includes files that don't exist. On some systems X11/Intrinsic.h
  1533. dnl is missing.
  1534. AC_MSG_CHECKING(if X11 header files can be found)
  1535. cflags_save=$CFLAGS
  1536. CFLAGS="$CFLAGS $X_CFLAGS"
  1537. AC_TRY_COMPILE([#include <X11/Xlib.h>
  1538. #include <X11/Intrinsic.h>], ,
  1539. AC_MSG_RESULT(yes),
  1540. AC_MSG_RESULT(no); no_x=yes)
  1541. CFLAGS=$cflags_save
  1542. if test "${no_x-no}" = yes; then
  1543. with_x=no
  1544. else
  1545. AC_DEFINE(HAVE_X11)
  1546. X_LIB="-lXt -lX11";
  1547. AC_SUBST(X_LIB)
  1548. ac_save_LDFLAGS="$LDFLAGS"
  1549. LDFLAGS="-L$x_libraries $LDFLAGS"
  1550. dnl Check for -lXdmcp (needed on SunOS 4.1.4)
  1551. dnl For HP-UX 10.20 it must be before -lSM -lICE
  1552. AC_CHECK_LIB(Xdmcp, _XdmcpAuthDoIt, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lXdmcp"],,
  1553. [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXdmcp])
  1554. dnl Some systems need -lnsl -lsocket when testing for ICE.
  1555. dnl The check above doesn't do this, try here (again). Also needed to get
  1556. dnl them after Xdmcp. link.sh will remove them when not needed.
  1557. dnl Check for other function than above to avoid the cached value
  1558. AC_CHECK_LIB(ICE, IceOpenConnection,
  1559. [X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE"],, [$X_EXTRA_LIBS])
  1560. dnl Check for -lXpm (needed for some versions of Motif)
  1561. LDFLAGS="$X_LIBS $ac_save_LDFLAGS"
  1562. AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [X_PRE_LIBS="$X_PRE_LIBS -lXpm"],,
  1563. [-lXt $X_PRE_LIBS -lXpm -lX11 $X_EXTRA_LIBS])
  1564. dnl Check that the X11 header files don't use implicit declarations
  1565. AC_MSG_CHECKING(if X11 header files implicitly declare return values)
  1566. cflags_save=$CFLAGS
  1567. CFLAGS="$CFLAGS $X_CFLAGS -Werror"
  1568. AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
  1569. AC_MSG_RESULT(no),
  1570. CFLAGS="$CFLAGS -Wno-implicit-int"
  1571. AC_TRY_COMPILE([#include <X11/Xlib.h>], ,
  1572. AC_MSG_RESULT(yes); cflags_save="$cflags_save -Wno-implicit-int",
  1573. AC_MSG_RESULT(test failed)
  1574. )
  1575. )
  1576. CFLAGS=$cflags_save
  1577. LDFLAGS="$ac_save_LDFLAGS"
  1578. AC_MSG_CHECKING(size of wchar_t is 2 bytes)
  1579. AC_CACHE_VAL(ac_cv_small_wchar_t,
  1580. [AC_TRY_RUN([
  1581. #include <X11/Xlib.h>
  1582. #if STDC_HEADERS
  1583. # include <stdlib.h>
  1584. # include <stddef.h>
  1585. #endif
  1586. main()
  1587. {
  1588. if (sizeof(wchar_t) <= 2)
  1589. exit(1);
  1590. exit(0);
  1591. }],
  1592. ac_cv_small_wchar_t="no",
  1593. ac_cv_small_wchar_t="yes",
  1594. AC_MSG_ERROR(failed to compile test program))])
  1595. AC_MSG_RESULT($ac_cv_small_wchar_t)
  1596. if test "x$ac_cv_small_wchar_t" = "xyes" ; then
  1597. AC_DEFINE(SMALL_WCHAR_T)
  1598. fi
  1599. fi
  1600. fi
  1601. test "x$with_x" = xno -a "x$MACOSX" != "xyes" -a "x$QNX" != "xyes" -a "x$enable_gui" != "xqt" && enable_gui=no
  1602. AC_MSG_CHECKING(--enable-gui argument)
  1603. AC_ARG_ENABLE(gui,
  1604. [ --enable-gui[=OPTS] X11 GUI [default=auto] [OPTS=auto/no/gtk2/gnome2/motif/athena/neXtaw/photon/carbon/qt]], , enable_gui="auto")
  1605. dnl Canonicalize the --enable-gui= argument so that it can be easily compared.
  1606. dnl Do not use character classes for portability with old tools.
  1607. enable_gui_canon=`echo "_$enable_gui" | \
  1608. sed 's/[[ _+-]]//g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
  1609. dnl Skip everything by default.
  1610. SKIP_GTK2=YES
  1611. SKIP_GNOME=YES
  1612. SKIP_MOTIF=YES
  1613. SKIP_ATHENA=YES
  1614. SKIP_NEXTAW=YES
  1615. SKIP_PHOTON=YES
  1616. SKIP_CARBON=YES
  1617. SKIP_QT=YES
  1618. GUITYPE=NONE
  1619. if test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
  1620. SKIP_PHOTON=
  1621. case "$enable_gui_canon" in
  1622. no) AC_MSG_RESULT(no GUI support)
  1623. SKIP_PHOTON=YES ;;
  1624. yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
  1625. auto) AC_MSG_RESULT(auto - automatic GUI support) ;;
  1626. photon) AC_MSG_RESULT(Photon GUI support) ;;
  1627. *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
  1628. SKIP_PHOTON=YES ;;
  1629. esac
  1630. elif test "x$MACOSX" = "xyes" -a "x$with_x" = "xno" ; then
  1631. SKIP_CARBON=
  1632. case "$enable_gui_canon" in
  1633. no) AC_MSG_RESULT(no GUI support)
  1634. SKIP_CARBON=YES ;;
  1635. yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
  1636. auto) AC_MSG_RESULT(auto - Carbon GUI is outdated - disable GUI support)
  1637. SKIP_CARBON=YES ;;
  1638. carbon) AC_MSG_RESULT(Carbon GUI support) ;;
  1639. *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
  1640. SKIP_CARBON=YES ;;
  1641. esac
  1642. else
  1643. case "$enable_gui_canon" in
  1644. no|none) AC_MSG_RESULT(no GUI support) ;;
  1645. yes|""|auto) AC_MSG_RESULT(yes/auto - automatic GUI support)
  1646. SKIP_GTK2=
  1647. SKIP_GNOME=
  1648. SKIP_MOTIF=
  1649. SKIP_ATHENA=
  1650. SKIP_NEXTAW=
  1651. SKIP_CARBON=
  1652. SKIP_QT=;;
  1653. gtk2) AC_MSG_RESULT(GTK+ 2.x GUI support)
  1654. SKIP_GTK2=;;
  1655. gnome2) AC_MSG_RESULT(GNOME 2.x GUI support)
  1656. SKIP_GNOME=
  1657. SKIP_GTK2=;;
  1658. motif) AC_MSG_RESULT(Motif GUI support)
  1659. SKIP_MOTIF=;;
  1660. athena) AC_MSG_RESULT(Athena GUI support)
  1661. SKIP_ATHENA=;;
  1662. nextaw) AC_MSG_RESULT(neXtaw GUI support)
  1663. SKIP_NEXTAW=;;
  1664. qt) AC_MSG_RESULT(Qt GUI support)
  1665. SKIP_QT=;;
  1666. *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported]) ;;
  1667. esac
  1668. fi
  1669. if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \
  1670. -a "$enable_gui_canon" != "gnome2"; then
  1671. AC_MSG_CHECKING(whether or not to look for GTK+ 2)
  1672. AC_ARG_ENABLE(gtk2-check,
  1673. [ --enable-gtk2-check If auto-select GUI, check for GTK+ 2 [default=yes]],
  1674. , enable_gtk2_check="yes")
  1675. AC_MSG_RESULT($enable_gtk2_check)
  1676. if test "x$enable_gtk2_check" = "xno"; then
  1677. SKIP_GTK2=YES
  1678. SKIP_GNOME=YES
  1679. fi
  1680. fi
  1681. if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome2"; then
  1682. AC_MSG_CHECKING(whether or not to look for GNOME)
  1683. AC_ARG_ENABLE(gnome-check,
  1684. [ --enable-gnome-check If GTK GUI, check for GNOME [default=no]],
  1685. , enable_gnome_check="no")
  1686. AC_MSG_RESULT($enable_gnome_check)
  1687. if test "x$enable_gnome_check" = "xno"; then
  1688. SKIP_GNOME=YES
  1689. fi
  1690. fi
  1691. if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then
  1692. AC_MSG_CHECKING(whether or not to look for Motif)
  1693. AC_ARG_ENABLE(motif-check,
  1694. [ --enable-motif-check If auto-select GUI, check for Motif [default=yes]],
  1695. , enable_motif_check="yes")
  1696. AC_MSG_RESULT($enable_motif_check)
  1697. if test "x$enable_motif_check" = "xno"; then
  1698. SKIP_MOTIF=YES
  1699. fi
  1700. fi
  1701. if test "x$SKIP_ATHENA" != "xYES" -a "$enable_gui_canon" != "athena"; then
  1702. AC_MSG_CHECKING(whether or not to look for Athena)
  1703. AC_ARG_ENABLE(athena-check,
  1704. [ --enable-athena-check If auto-select GUI, check for Athena [default=yes]],
  1705. , enable_athena_check="yes")
  1706. AC_MSG_RESULT($enable_athena_check)
  1707. if test "x$enable_athena_check" = "xno"; then
  1708. SKIP_ATHENA=YES
  1709. fi
  1710. fi
  1711. if test "x$SKIP_NEXTAW" != "xYES" -a "$enable_gui_canon" != "nextaw"; then
  1712. AC_MSG_CHECKING(whether or not to look for neXtaw)
  1713. AC_ARG_ENABLE(nextaw-check,
  1714. [ --enable-nextaw-check If auto-select GUI, check for neXtaw [default=yes]],
  1715. , enable_nextaw_check="yes")
  1716. AC_MSG_RESULT($enable_nextaw_check);
  1717. if test "x$enable_nextaw_check" = "xno"; then
  1718. SKIP_NEXTAW=YES
  1719. fi
  1720. fi
  1721. if test "x$SKIP_CARBON" != "xYES" -a "$enable_gui_canon" != "carbon"; then
  1722. AC_MSG_CHECKING(whether or not to look for Carbon)
  1723. AC_ARG_ENABLE(carbon-check,
  1724. [ --enable-carbon-check If auto-select GUI, check for Carbon [default=yes]],
  1725. , enable_carbon_check="yes")
  1726. AC_MSG_RESULT($enable_carbon_check);
  1727. if test "x$enable_carbon_check" = "xno"; then
  1728. SKIP_CARBON=YES
  1729. fi
  1730. fi
  1731. if test "x$MACOSX" = "xyes" -a -z "$SKIP_CARBON" -a "x$CARBON" = "xyes"; then
  1732. AC_MSG_CHECKING(for Carbon GUI)
  1733. dnl already did the check, just give the message
  1734. AC_MSG_RESULT(yes);
  1735. GUITYPE=CARBONGUI
  1736. if test "$VIMNAME" = "vim"; then
  1737. VIMNAME=Vim
  1738. fi
  1739. if test "x$MACARCH" = "xboth"; then
  1740. CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk/Developer/Headers/FlatCarbon"
  1741. else
  1742. CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/Headers/FlatCarbon"
  1743. fi
  1744. dnl Default install directory is not /usr/local
  1745. if test x$prefix = xNONE; then
  1746. prefix=/Applications
  1747. fi
  1748. dnl Sorry for the hard coded default
  1749. datadir='${prefix}/Vim.app/Contents/Resources'
  1750. dnl skip everything else
  1751. SKIP_GTK2=YES;
  1752. SKIP_GNOME=YES;
  1753. SKIP_MOTIF=YES;
  1754. SKIP_ATHENA=YES;
  1755. SKIP_NEXTAW=YES;
  1756. SKIP_PHOTON=YES;
  1757. SKIP_CARBON=YES;
  1758. SKIP_QT=YES;
  1759. fi
  1760. dnl define an autoconf function to check for a specified version of GTK, and
  1761. dnl try to compile/link a GTK program.
  1762. dnl
  1763. dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
  1764. dnl Test for GTK, and define GTK_CFLAGS, GTK_LIBDIR and GTK_LIBS
  1765. dnl
  1766. AC_DEFUN(AM_PATH_GTK,
  1767. [
  1768. if test "X$GTK_CONFIG" != "Xno" -o "X$PKG_CONFIG" != "Xno"; then
  1769. {
  1770. min_gtk_version=ifelse([$1], ,2.2.0,$1)
  1771. AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
  1772. no_gtk=""
  1773. if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
  1774. && $PKG_CONFIG --exists gtk+-2.0; then
  1775. {
  1776. dnl We should be using PKG_CHECK_MODULES() instead of this hack.
  1777. dnl But I guess the dependency on pkgconfig.m4 is not wanted or
  1778. dnl something like that.
  1779. GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0`
  1780. GTK_LIBDIR=`$PKG_CONFIG --libs-only-L gtk+-2.0`
  1781. GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0`
  1782. gtk_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
  1783. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
  1784. gtk_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
  1785. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
  1786. gtk_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
  1787. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
  1788. }
  1789. else
  1790. no_gtk=yes
  1791. fi
  1792. if test "x$enable_gtktest" = "xyes" -a "x$no_gtk" = "x"; then
  1793. {
  1794. ac_save_CFLAGS="$CFLAGS"
  1795. ac_save_LIBS="$LIBS"
  1796. CFLAGS="$CFLAGS $GTK_CFLAGS"
  1797. LIBS="$LIBS $GTK_LIBS"
  1798. dnl
  1799. dnl Now check if the installed GTK is sufficiently new.
  1800. dnl
  1801. rm -f conf.gtktest
  1802. AC_TRY_RUN([
  1803. #include <gtk/gtk.h>
  1804. #include <stdio.h>
  1805. #if STDC_HEADERS
  1806. # include <stdlib.h>
  1807. # include <stddef.h>
  1808. #endif
  1809. int
  1810. main ()
  1811. {
  1812. int major, minor, micro;
  1813. char *tmp_version;
  1814. system ("touch conf.gtktest");
  1815. /* HP/UX 9 (%@#!) writes to sscanf strings */
  1816. tmp_version = g_strdup("$min_gtk_version");
  1817. if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
  1818. printf("%s, bad version string\n", "$min_gtk_version");
  1819. exit(1);
  1820. }
  1821. if ((gtk_major_version > major) ||
  1822. ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
  1823. ((gtk_major_version == major) && (gtk_minor_version == minor) &&
  1824. (gtk_micro_version >= micro)))
  1825. {
  1826. return 0;
  1827. }
  1828. return 1;
  1829. }
  1830. ],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
  1831. CFLAGS="$ac_save_CFLAGS"
  1832. LIBS="$ac_save_LIBS"
  1833. }
  1834. fi
  1835. if test "x$no_gtk" = x ; then
  1836. if test "x$enable_gtktest" = "xyes"; then
  1837. AC_MSG_RESULT(yes; found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
  1838. else
  1839. AC_MSG_RESULT(found version $gtk_major_version.$gtk_minor_version.$gtk_micro_version)
  1840. fi
  1841. ifelse([$2], , :, [$2])
  1842. else
  1843. {
  1844. AC_MSG_RESULT(no)
  1845. GTK_CFLAGS=""
  1846. GTK_LIBS=""
  1847. ifelse([$3], , :, [$3])
  1848. }
  1849. fi
  1850. }
  1851. else
  1852. GTK_CFLAGS=""
  1853. GTK_LIBS=""
  1854. ifelse([$3], , :, [$3])
  1855. fi
  1856. AC_SUBST(GTK_CFLAGS)
  1857. AC_SUBST(GTK_LIBS)
  1858. rm -f conf.gtktest
  1859. ])
  1860. dnl ---------------------------------------------------------------------------
  1861. dnl gnome
  1862. dnl ---------------------------------------------------------------------------
  1863. AC_DEFUN([GNOME_INIT_HOOK],
  1864. [
  1865. AC_SUBST(GNOME_LIBS)
  1866. AC_SUBST(GNOME_LIBDIR)
  1867. AC_SUBST(GNOME_INCLUDEDIR)
  1868. AC_ARG_WITH(gnome-includes,
  1869. [ --with-gnome-includes=DIR Specify location of GNOME headers],
  1870. [CFLAGS="$CFLAGS -I$withval"]
  1871. )
  1872. AC_ARG_WITH(gnome-libs,
  1873. [ --with-gnome-libs=DIR Specify location of GNOME libs],
  1874. [LDFLAGS="$LDFLAGS -L$withval" gnome_prefix=$withval]
  1875. )
  1876. AC_ARG_WITH(gnome,
  1877. [ --with-gnome Specify prefix for GNOME files],
  1878. if test x$withval = xyes; then
  1879. want_gnome=yes
  1880. ifelse([$1], [], :, [$1])
  1881. else
  1882. if test "x$withval" = xno; then
  1883. want_gnome=no
  1884. else
  1885. want_gnome=yes
  1886. LDFLAGS="$LDFLAGS -L$withval/lib"
  1887. CFLAGS="$CFLAGS -I$withval/include"
  1888. gnome_prefix=$withval/lib
  1889. fi
  1890. fi,
  1891. want_gnome=yes)
  1892. if test "x$want_gnome" = xyes; then
  1893. {
  1894. AC_MSG_CHECKING(for libgnomeui-2.0)
  1895. if $PKG_CONFIG --exists libgnomeui-2.0; then
  1896. AC_MSG_RESULT(yes)
  1897. GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0`
  1898. GNOME_LIBDIR=`$PKG_CONFIG --libs-only-L libgnomeui-2.0`
  1899. GNOME_INCLUDEDIR=`$PKG_CONFIG --cflags libgnomeui-2.0`
  1900. dnl On FreeBSD we need -pthread but pkg-config doesn't include it.
  1901. dnl This might not be the right way but it works for me...
  1902. AC_MSG_CHECKING(for FreeBSD)
  1903. if test "`(uname) 2>/dev/null`" = FreeBSD; then
  1904. AC_MSG_RESULT(yes, adding -pthread)
  1905. GNOME_INCLUDEDIR="$GNOME_INCLUDEDIR -D_THREAD_SAFE"
  1906. GNOME_LIBS="$GNOME_LIBS -pthread"
  1907. else
  1908. AC_MSG_RESULT(no)
  1909. fi
  1910. $1
  1911. else
  1912. AC_MSG_RESULT(not found)
  1913. if test "x$2" = xfail; then
  1914. AC_MSG_ERROR(Could not find libgnomeui-2.0 via pkg-config)
  1915. fi
  1916. fi
  1917. }
  1918. fi
  1919. ])
  1920. AC_DEFUN([GNOME_INIT],[
  1921. GNOME_INIT_HOOK([],fail)
  1922. ])
  1923. dnl ---------------------------------------------------------------------------
  1924. dnl Check for GTK2. If it fails, then continue on for Motif as before...
  1925. dnl ---------------------------------------------------------------------------
  1926. if test -z "$SKIP_GTK2"; then
  1927. AC_MSG_CHECKING(--disable-gtktest argument)
  1928. AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
  1929. , enable_gtktest=yes)
  1930. if test "x$enable_gtktest" = "xyes" ; then
  1931. AC_MSG_RESULT(gtk test enabled)
  1932. else
  1933. AC_MSG_RESULT(gtk test disabled)
  1934. fi
  1935. if test "X$PKG_CONFIG" = "X"; then
  1936. AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  1937. fi
  1938. if test "x$PKG_CONFIG" != "xno"; then
  1939. dnl First try finding version 2.2.0 or later. The 2.0.x series has
  1940. dnl problems (bold fonts, --remote doesn't work).
  1941. AM_PATH_GTK(2.2.0,
  1942. [GUI_LIB_LOC="$GTK_LIBDIR"
  1943. GTK_LIBNAME="$GTK_LIBS"
  1944. GUI_INC_LOC="$GTK_CFLAGS"], )
  1945. if test "x$GTK_CFLAGS" != "x"; then
  1946. SKIP_ATHENA=YES
  1947. SKIP_NEXTAW=YES
  1948. SKIP_MOTIF=YES
  1949. SKIP_QT=YES
  1950. GUITYPE=GTK
  1951. AC_SUBST(GTK_LIBNAME)
  1952. fi
  1953. fi
  1954. if test "x$GUITYPE" = "xGTK"; then
  1955. if test "$gtk_minor_version" = 1 -a "0$gtk_micro_version" -ge 1 \
  1956. || test "0$gtk_minor_version" -ge 2; then
  1957. AC_DEFINE(HAVE_GTK_MULTIHEAD)
  1958. fi
  1959. dnl
  1960. dnl if GTK exists, then check for GNOME.
  1961. dnl
  1962. if test -z "$SKIP_GNOME"; then
  1963. {
  1964. GNOME_INIT_HOOK([have_gnome=yes])
  1965. if test "x$have_gnome" = xyes ; then
  1966. AC_DEFINE(FEAT_GUI_GNOME)
  1967. GUI_INC_LOC="$GUI_INC_LOC $GNOME_INCLUDEDIR"
  1968. GTK_LIBNAME="$GTK_LIBNAME $GNOME_LIBDIR $GNOME_LIBS"
  1969. fi
  1970. }
  1971. fi
  1972. fi
  1973. fi
  1974. dnl Check for Motif include files location.
  1975. dnl The LAST one found is used, this makes the highest version to be used,
  1976. dnl e.g. when Motif1.2 and Motif2.0 are both present.
  1977. if test -z "$SKIP_MOTIF"; then
  1978. 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"
  1979. dnl Remove "-I" from before $GUI_INC_LOC if it's there
  1980. GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`"
  1981. AC_MSG_CHECKING(for location of Motif GUI includes)
  1982. gui_includes="`echo $x_includes|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC"
  1983. GUI_INC_LOC=
  1984. for try in $gui_includes; do
  1985. if test -f "$try/Xm/Xm.h"; then
  1986. GUI_INC_LOC=$try
  1987. fi
  1988. done
  1989. if test -n "$GUI_INC_LOC"; then
  1990. if test "$GUI_INC_LOC" = /usr/include; then
  1991. GUI_INC_LOC=
  1992. AC_MSG_RESULT(in default path)
  1993. else
  1994. AC_MSG_RESULT($GUI_INC_LOC)
  1995. fi
  1996. else
  1997. AC_MSG_RESULT(<not found>)
  1998. SKIP_MOTIF=YES
  1999. fi
  2000. fi
  2001. dnl Check for Motif library files location. In the same order as the include
  2002. dnl files, to avoid a mixup if several versions are present
  2003. if test -z "$SKIP_MOTIF"; then
  2004. AC_MSG_CHECKING(--with-motif-lib argument)
  2005. AC_ARG_WITH(motif-lib,
  2006. [ --with-motif-lib=STRING Library for Motif ],
  2007. [ MOTIF_LIBNAME="${withval}" ] )
  2008. if test -n "$MOTIF_LIBNAME"; then
  2009. AC_MSG_RESULT($MOTIF_LIBNAME)
  2010. GUI_LIB_LOC=
  2011. else
  2012. AC_MSG_RESULT(no)
  2013. dnl Remove "-L" from before $GUI_LIB_LOC if it's there
  2014. GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
  2015. AC_MSG_CHECKING(for location of Motif GUI libs)
  2016. gui_libs="`echo $x_libraries|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/lib/g` `echo "$GUI_INC_LOC" | sed s/include/lib/` $GUI_LIB_LOC"
  2017. GUI_LIB_LOC=
  2018. for try in $gui_libs; do
  2019. for libtry in "$try"/libXm.a "$try"/libXm.so* "$try"/libXm.sl "$try"/libXm.dylib; do
  2020. if test -f "$libtry"; then
  2021. GUI_LIB_LOC=$try
  2022. fi
  2023. done
  2024. done
  2025. if test -n "$GUI_LIB_LOC"; then
  2026. dnl Remove /usr/lib, it causes trouble on some systems
  2027. if test "$GUI_LIB_LOC" = /usr/lib; then
  2028. GUI_LIB_LOC=
  2029. AC_MSG_RESULT(in default path)
  2030. else
  2031. if test -n "$GUI_LIB_LOC"; then
  2032. AC_MSG_RESULT($GUI_LIB_LOC)
  2033. if test "`(uname) 2>/dev/null`" = SunOS &&
  2034. uname -r | grep '^5' >/dev/null; then
  2035. GUI_LIB_LOC="$GUI_LIB_LOC -R $GUI_LIB_LOC"
  2036. fi
  2037. fi
  2038. fi
  2039. MOTIF_LIBNAME=-lXm
  2040. else
  2041. AC_MSG_RESULT(<not found>)
  2042. SKIP_MOTIF=YES
  2043. fi
  2044. fi
  2045. fi
  2046. if test -z "$SKIP_MOTIF"; then
  2047. SKIP_ATHENA=YES
  2048. SKIP_NEXTAW=YES
  2049. SKIP_QT=YES
  2050. GUITYPE=MOTIF
  2051. AC_SUBST(MOTIF_LIBNAME)
  2052. fi
  2053. dnl Check if the Athena files can be found
  2054. GUI_X_LIBS=
  2055. if test -z "$SKIP_ATHENA"; then
  2056. AC_MSG_CHECKING(if Athena header files can be found)
  2057. cflags_save=$CFLAGS
  2058. CFLAGS="$CFLAGS $X_CFLAGS"
  2059. AC_TRY_COMPILE([
  2060. #include <X11/Intrinsic.h>
  2061. #include <X11/Xaw/Paned.h>], ,
  2062. AC_MSG_RESULT(yes),
  2063. AC_MSG_RESULT(no); SKIP_ATHENA=YES )
  2064. CFLAGS=$cflags_save
  2065. fi
  2066. if test -z "$SKIP_ATHENA"; then
  2067. GUITYPE=ATHENA
  2068. fi
  2069. if test -z "$SKIP_NEXTAW"; then
  2070. AC_MSG_CHECKING(if neXtaw header files can be found)
  2071. cflags_save=$CFLAGS
  2072. CFLAGS="$CFLAGS $X_CFLAGS"
  2073. AC_TRY_COMPILE([
  2074. #include <X11/Intrinsic.h>
  2075. #include <X11/neXtaw/Paned.h>], ,
  2076. AC_MSG_RESULT(yes),
  2077. AC_MSG_RESULT(no); SKIP_NEXTAW=YES )
  2078. CFLAGS=$cflags_save
  2079. fi
  2080. if test -z "$SKIP_NEXTAW"; then
  2081. GUITYPE=NEXTAW
  2082. fi
  2083. if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
  2084. dnl Prepend -I and -L to $GUI_INC_LOC and $GUI_LIB_LOC if not empty
  2085. dnl Avoid adding it when it twice
  2086. if test -n "$GUI_INC_LOC"; then
  2087. GUI_INC_LOC=-I"`echo $GUI_INC_LOC|sed 's%-I%%'`"
  2088. fi
  2089. if test -n "$GUI_LIB_LOC"; then
  2090. GUI_LIB_LOC=-L"`echo $GUI_LIB_LOC|sed 's%-L%%'`"
  2091. fi
  2092. dnl Check for -lXext and then for -lXmu
  2093. ldflags_save=$LDFLAGS
  2094. LDFLAGS="$X_LIBS $LDFLAGS"
  2095. AC_CHECK_LIB(Xext, XShapeQueryExtension, [GUI_X_LIBS="-lXext"],,
  2096. [-lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
  2097. dnl For Solaris we need -lw and -ldl before linking with -lXmu works.
  2098. AC_CHECK_LIB(w, wslen, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lw"],,
  2099. [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
  2100. AC_CHECK_LIB(dl, dlsym, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldl"],,
  2101. [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
  2102. AC_CHECK_LIB(Xmu, XmuCreateStippledPixmap, [GUI_X_LIBS="-lXmu $GUI_X_LIBS"],,
  2103. [$GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
  2104. if test -z "$SKIP_MOTIF"; then
  2105. AC_CHECK_LIB(Xp, XpEndJob, [GUI_X_LIBS="-lXp $GUI_X_LIBS"],,
  2106. [$GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
  2107. fi
  2108. LDFLAGS=$ldflags_save
  2109. dnl Execute xmkmf to figure out if -DNARROWPROTO is needed.
  2110. AC_MSG_CHECKING(for extra X11 defines)
  2111. NARROW_PROTO=
  2112. rm -fr conftestdir
  2113. if mkdir conftestdir; then
  2114. cd conftestdir
  2115. cat > Imakefile <<'EOF'
  2116. acfindx:
  2117. @echo 'NARROW_PROTO="${PROTO_DEFINES}"'
  2118. EOF
  2119. if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
  2120. eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
  2121. fi
  2122. cd ..
  2123. rm -fr conftestdir
  2124. fi
  2125. if test -z "$NARROW_PROTO"; then
  2126. AC_MSG_RESULT(no)
  2127. else
  2128. AC_MSG_RESULT($NARROW_PROTO)
  2129. fi
  2130. AC_SUBST(NARROW_PROTO)
  2131. fi
  2132. dnl Look for XSMP support - but don't necessarily restrict it to X11 GUIs
  2133. dnl use the X11 include path
  2134. if test "$enable_xsmp" = "yes"; then
  2135. cppflags_save=$CPPFLAGS
  2136. CPPFLAGS="$CPPFLAGS $X_CFLAGS"
  2137. AC_CHECK_HEADERS(X11/SM/SMlib.h)
  2138. CPPFLAGS=$cppflags_save
  2139. fi
  2140. dnl Check if the Qt files can be found
  2141. if test -z "$SKIP_QT" -a -z "$DONT_FIND_QT"; then
  2142. AC_LANG_PUSH(C++)
  2143. AC_PROG_CXX
  2144. QT_FOUND="no"
  2145. AC_MSG_CHECKING(--with-qt-dir argument)
  2146. AC_ARG_WITH(qt-dir,
  2147. [ --with-qt-dir=PATH Qt prefix path (ex: /usr/ or /usr/lib/qt4)],
  2148. [ QT_DIR="${withval}" ] )
  2149. if test -n "$QT_DIR"; then
  2150. AC_MSG_RESULT($QT_DIR)
  2151. #
  2152. # Use the prefix given by --with-qt-dir
  2153. #
  2154. QMAKE="$QT_DIR/bin/qmake"
  2155. QT_MOC="$QT_DIR/bin/moc"
  2156. AC_MSG_CHECKING(for $QMAKE)
  2157. if test ! -x "$QMAKE"; then
  2158. AC_MSG_ERROR("Unable to find qmake")
  2159. fi
  2160. AC_MSG_CHECKING(for $QT_MOC)
  2161. if test ! -x "$QT_MOC"; then
  2162. AC_MSG_ERROR("Unable to find moc")
  2163. fi
  2164. else
  2165. AC_MSG_RESULT(no)
  2166. #
  2167. # Find qmake
  2168. # 1. First look for "qmake4" in the PATH - some systems use the name qmake(Qt3) and qmake4(Qt4)
  2169. # 2. If qmake4 is not found then look for qmake-qt4 in the PATH
  2170. # 3. Look for qmake in the PATH
  2171. # 4. Look for "qmake", outside the path, in the following locations
  2172. QT_BIN_PATH="/usr/lib64/qt4/bin:/usr/local/lib64/qt4/bin:/usr/lib/qt4/bin:/usr/local/lib/qt4/bin"
  2173. AC_PATH_PROG(QMAKE, qmake4)
  2174. if test -z "$QMAKE"; then
  2175. AC_PATH_PROG(QMAKE, qmake-qt4)
  2176. fi
  2177. if test -z "$QMAKE"; then
  2178. AC_PATH_PROG(QMAKE, qmake)
  2179. fi
  2180. if test -z "$QMAKE"; then
  2181. AC_PATH_PROG(QMAKE, qmake, , $QT_BIN_PATH)
  2182. fi
  2183. if test -z "$QMAKE"; then
  2184. AC_MSG_ERROR("Unable to find qmake")
  2185. fi
  2186. #
  2187. # Find moc
  2188. # - Exactly the same as previous case with qmake
  2189. #
  2190. AC_PATH_PROG(QT_MOC, moc4)
  2191. if test -z "$QT_MOC"; then
  2192. AC_PATH_PROG(QT_MOC, moc-qt4)
  2193. fi
  2194. if test -z "$QT_MOC"; then
  2195. AC_PATH_PROG(QT_MOC, moc)
  2196. fi
  2197. if test -z "$QT_MOC"; then
  2198. AC_PATH_PROG(QT_MOC, moc, , $QT_BIN_PATH)
  2199. fi
  2200. if test -z "$QT_MOC"; then
  2201. AC_MSG_ERROR("Unable to find moc")
  2202. fi
  2203. fi
  2204. #
  2205. # Call qmake to generate bogus project
  2206. #
  2207. # What we do here is call qmake to generate a valid Makefile and
  2208. # then extract the Qt compiler flags from the generated Makefile
  2209. #
  2210. TMPDIR=/tmp
  2211. tmp=`(umask 077 && mktemp -d -q "$TMPDIR/test-vim-qt-XXXXXXXX") 2>/dev/null`;
  2212. if test -z "$tmp" -a -d "$tmp"; then
  2213. AC_MSG_ERROR(Unable to create temporary directory)
  2214. fi
  2215. cat > $tmp/qttest.cpp << EOF
  2216. #include <QApplication>
  2217. int main(int ac, char **av) {
  2218. QApplication app(ac, av);
  2219. return app.exec();
  2220. }
  2221. EOF
  2222. # Generate qmake project
  2223. qmake_try=`cd $tmp; $QMAKE -project -o test.pro`
  2224. AC_TRY_EVAL(qt_try)
  2225. if test x"$ac_status" != x0; then
  2226. AC_MSG_ERROR(qmake failed)
  2227. fi
  2228. # add options
  2229. echo "QT += network" >> $tmp/test.pro
  2230. # generate Makefile
  2231. qmake_try=`cd $tmp; $QMAKE`
  2232. AC_TRY_EVAL(qt_try)
  2233. if test x"$ac_status" != x0; then
  2234. AC_MSG_ERROR(qmake failed)
  2235. fi
  2236. # LIBS
  2237. QT_LIBS=`grep LIBS.*= $tmp/Makefile | awk '{sub(/^LIBS +=/, ""); print}'`
  2238. if test -z "$QT_LIBS"; then
  2239. AC_MSG_ERROR(Unable to find Qt libraries)
  2240. fi
  2241. # Include directives
  2242. QT_INCPATH=`grep INCPATH.*= $tmp/Makefile | awk '{sub(/^INCPATH +=/, ""); print}'`
  2243. if test -z "$QT_LIBS"; then
  2244. AC_MSG_ERROR(Unable to find Qt include path)
  2245. fi
  2246. # LFLAGS
  2247. QT_LFLAGS=`grep LFLAGS.*= $tmp/Makefile | awk '{sub(/^LFLAGS +=/, ""); print}'`
  2248. if test -z "$QT_LFLAGS"; then
  2249. AC_MSG_ERROR(Unable to find Qt link flags)
  2250. fi
  2251. LDFLAGS="$LDFLAGS $QT_LFLAGS -lstdc++"
  2252. AC_SUBST(QT_LIBS)
  2253. AC_SUBST(QT_MOC)
  2254. AC_SUBST(QT_INCPATH)
  2255. AC_LANG_POP(C++)
  2256. # Remove temp directory
  2257. rm $tmp/Makefile
  2258. rm $tmp/qttest.cpp
  2259. rm $tmp/test.pro
  2260. rmdir $tmp
  2261. fi
  2262. if test -z "$SKIP_QT"; then
  2263. GUITYPE=QT
  2264. GUI_X_LIBS=
  2265. fi
  2266. if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF" -o -z "$SKIP_GTK2"; then
  2267. dnl Check for X11/xpm.h and X11/Sunkeysym.h with the GUI include path
  2268. cppflags_save=$CPPFLAGS
  2269. CPPFLAGS="$CPPFLAGS $X_CFLAGS"
  2270. AC_CHECK_HEADERS(X11/xpm.h X11/Sunkeysym.h)
  2271. dnl automatically disable XIM when XIMtext isn't in X11/Xlib.h
  2272. if test ! "$enable_xim" = "no"; then
  2273. AC_MSG_CHECKING(for XIMText in X11/Xlib.h)
  2274. AC_EGREP_CPP(XIMText, [#include <X11/Xlib.h>],
  2275. AC_MSG_RESULT(yes),
  2276. AC_MSG_RESULT(no; xim has been disabled); enable_xim = "no")
  2277. fi
  2278. CPPFLAGS=$cppflags_save
  2279. dnl automatically enable XIM when hangul input isn't enabled
  2280. if test "$enable_xim" = "auto" -a "$enable_hangulinput" != "yes" \
  2281. -a "x$GUITYPE" != "xNONE" ; then
  2282. AC_MSG_RESULT(X GUI selected; xim has been enabled)
  2283. enable_xim="yes"
  2284. fi
  2285. fi
  2286. if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then
  2287. cppflags_save=$CPPFLAGS
  2288. CPPFLAGS="$CPPFLAGS $X_CFLAGS"
  2289. dnl Xmu/Editres.h may exist but can only be used after including Intrinsic.h
  2290. AC_MSG_CHECKING([for X11/Xmu/Editres.h])
  2291. AC_TRY_COMPILE([
  2292. #include <X11/Intrinsic.h>
  2293. #include <X11/Xmu/Editres.h>],
  2294. [int i; i = 0;],
  2295. AC_MSG_RESULT(yes)
  2296. AC_DEFINE(HAVE_X11_XMU_EDITRES_H),
  2297. AC_MSG_RESULT(no))
  2298. CPPFLAGS=$cppflags_save
  2299. fi
  2300. dnl Only use the Xm directory when compiling Motif, don't use it for Athena
  2301. if test -z "$SKIP_MOTIF"; then
  2302. cppflags_save=$CPPFLAGS
  2303. CPPFLAGS="$CPPFLAGS $X_CFLAGS"
  2304. AC_CHECK_HEADERS(Xm/Xm.h Xm/XpmP.h Xm/JoinSideT.h Xm/TraitP.h Xm/Manager.h \
  2305. Xm/UnhighlightT.h Xm/Notebook.h)
  2306. if test $ac_cv_header_Xm_XpmP_h = yes; then
  2307. dnl Solaris uses XpmAttributes_21, very annoying.
  2308. AC_MSG_CHECKING([for XpmAttributes_21 in Xm/XpmP.h])
  2309. AC_TRY_COMPILE([#include <Xm/XpmP.h>], [XpmAttributes_21 attr;],
  2310. AC_MSG_RESULT(yes); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes_21),
  2311. AC_MSG_RESULT(no); AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
  2312. )
  2313. else
  2314. AC_DEFINE(XPMATTRIBUTES_TYPE, XpmAttributes)
  2315. fi
  2316. CPPFLAGS=$cppflags_save
  2317. fi
  2318. if test "x$GUITYPE" = "xNONE" -a "$enable_xim" = "yes"; then
  2319. AC_MSG_RESULT(no GUI selected; xim has been disabled)
  2320. enable_xim="no"
  2321. fi
  2322. if test "x$GUITYPE" = "xNONE" -a "$enable_fontset" = "yes"; then
  2323. AC_MSG_RESULT(no GUI selected; fontset has been disabled)
  2324. enable_fontset="no"
  2325. fi
  2326. if test "x$GUITYPE:$enable_fontset" = "xGTK:yes"; then
  2327. AC_MSG_RESULT(GTK+ 2 GUI selected; fontset has been disabled)
  2328. enable_fontset="no"
  2329. fi
  2330. if test -z "$SKIP_PHOTON"; then
  2331. GUITYPE=PHOTONGUI
  2332. fi
  2333. AC_SUBST(GUI_INC_LOC)
  2334. AC_SUBST(GUI_LIB_LOC)
  2335. AC_SUBST(GUITYPE)
  2336. AC_SUBST(GUI_X_LIBS)
  2337. if test "$enable_workshop" = "yes" -a -n "$SKIP_MOTIF"; then
  2338. AC_MSG_ERROR([cannot use workshop without Motif])
  2339. fi
  2340. dnl defining FEAT_XIM and FEAT_XFONTSET is delayed, so that they can be disabled
  2341. if test "$enable_xim" = "yes"; then
  2342. AC_DEFINE(FEAT_XIM)
  2343. fi
  2344. if test "$enable_fontset" = "yes"; then
  2345. AC_DEFINE(FEAT_XFONTSET)
  2346. fi
  2347. dnl ---------------------------------------------------------------------------
  2348. dnl end of GUI-checking
  2349. dnl ---------------------------------------------------------------------------
  2350. dnl Only really enable hangul input when GUI and XFONTSET are available
  2351. if test "$enable_hangulinput" = "yes"; then
  2352. if test "x$GUITYPE" = "xNONE"; then
  2353. AC_MSG_RESULT(no GUI selected; hangul input has been disabled)
  2354. enable_hangulinput=no
  2355. else
  2356. AC_DEFINE(FEAT_HANGULIN)
  2357. HANGULIN_SRC=hangulin.c
  2358. AC_SUBST(HANGULIN_SRC)
  2359. HANGULIN_OBJ=objects/hangulin.o
  2360. AC_SUBST(HANGULIN_OBJ)
  2361. fi
  2362. fi
  2363. dnl Checks for libraries and include files.
  2364. AC_CACHE_CHECK([whether toupper is broken], [vim_cv_toupper_broken],
  2365. [
  2366. AC_RUN_IFELSE([[
  2367. #include "confdefs.h"
  2368. #include <ctype.h>
  2369. #if STDC_HEADERS
  2370. # include <stdlib.h>
  2371. # include <stddef.h>
  2372. #endif
  2373. main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); }
  2374. ]],[
  2375. vim_cv_toupper_broken=yes
  2376. ],[
  2377. vim_cv_toupper_broken=no
  2378. ],[
  2379. AC_MSG_ERROR(cross-compiling: please set 'vim_cv_toupper_broken')
  2380. ])])
  2381. if test "x$vim_cv_toupper_broken" = "xyes" ; then
  2382. AC_DEFINE(BROKEN_TOUPPER)
  2383. fi
  2384. AC_MSG_CHECKING(whether __DATE__ and __TIME__ work)
  2385. AC_TRY_COMPILE([#include <stdio.h>], [printf("(" __DATE__ " " __TIME__ ")");],
  2386. AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DATE_TIME),
  2387. AC_MSG_RESULT(no))
  2388. AC_MSG_CHECKING(whether __attribute__((unused)) is allowed)
  2389. AC_TRY_COMPILE([#include <stdio.h>], [int x __attribute__((unused));],
  2390. AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ATTRIBUTE_UNUSED),
  2391. AC_MSG_RESULT(no))
  2392. dnl Checks for header files.
  2393. AC_CHECK_HEADER(elf.h, HAS_ELF=1)
  2394. dnl AC_CHECK_HEADER(dwarf.h, SVR4=1)
  2395. if test "$HAS_ELF" = 1; then
  2396. AC_CHECK_LIB(elf, main)
  2397. fi
  2398. AC_HEADER_DIRENT
  2399. dnl If sys/wait.h is not found it might still exist but not be POSIX
  2400. dnl compliant. In that case we define HAVE_UNION_WAIT (for NeXT)
  2401. if test $ac_cv_header_sys_wait_h = no; then
  2402. AC_MSG_CHECKING([for sys/wait.h that defines union wait])
  2403. AC_TRY_COMPILE([#include <sys/wait.h>],
  2404. [union wait xx, yy; xx = yy],
  2405. AC_MSG_RESULT(yes)
  2406. AC_DEFINE(HAVE_SYS_WAIT_H)
  2407. AC_DEFINE(HAVE_UNION_WAIT),
  2408. AC_MSG_RESULT(no))
  2409. fi
  2410. AC_CHECK_HEADERS(stdarg.h stdint.h stdlib.h string.h \
  2411. sys/select.h sys/utsname.h termcap.h fcntl.h \
  2412. sgtty.h sys/ioctl.h sys/time.h sys/types.h \
  2413. termio.h iconv.h inttypes.h langinfo.h math.h \
  2414. unistd.h stropts.h errno.h sys/resource.h \
  2415. sys/systeminfo.h locale.h sys/stream.h termios.h \
  2416. libc.h sys/statfs.h poll.h sys/poll.h pwd.h \
  2417. utime.h sys/param.h libintl.h libgen.h \
  2418. util/debug.h util/msg18n.h frame.h sys/acl.h \
  2419. sys/access.h sys/sysinfo.h wchar.h wctype.h)
  2420. dnl sys/ptem.h depends on sys/stream.h on Solaris
  2421. AC_CHECK_HEADERS(sys/ptem.h, [], [],
  2422. [#if defined HAVE_SYS_STREAM_H
  2423. # include <sys/stream.h>
  2424. #endif])
  2425. dnl sys/sysctl.h depends on sys/param.h on OpenBSD
  2426. AC_CHECK_HEADERS(sys/sysctl.h, [], [],
  2427. [#if defined HAVE_SYS_PARAM_H
  2428. # include <sys/param.h>
  2429. #endif])
  2430. dnl pthread_np.h may exist but can only be used after including pthread.h
  2431. AC_MSG_CHECKING([for pthread_np.h])
  2432. AC_TRY_COMPILE([
  2433. #include <pthread.h>
  2434. #include <pthread_np.h>],
  2435. [int i; i = 0;],
  2436. AC_MSG_RESULT(yes)
  2437. AC_DEFINE(HAVE_PTHREAD_NP_H),
  2438. AC_MSG_RESULT(no))
  2439. AC_CHECK_HEADERS(strings.h)
  2440. if test "x$MACOSX" = "xyes"; then
  2441. dnl The strings.h file on OS/X contains a warning and nothing useful.
  2442. AC_DEFINE(NO_STRINGS_WITH_STRING_H)
  2443. else
  2444. dnl Check if strings.h and string.h can both be included when defined.
  2445. AC_MSG_CHECKING([if strings.h can be included after string.h])
  2446. cppflags_save=$CPPFLAGS
  2447. CPPFLAGS="$CPPFLAGS $X_CFLAGS"
  2448. AC_TRY_COMPILE([
  2449. #if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO)
  2450. # define _NO_PROTO /* like in os_unix.h, causes conflict for AIX (Winn) */
  2451. /* but don't do it on AIX 5.1 (Uribarri) */
  2452. #endif
  2453. #ifdef HAVE_XM_XM_H
  2454. # include <Xm/Xm.h> /* This breaks it for HP-UX 11 (Squassabia) */
  2455. #endif
  2456. #ifdef HAVE_STRING_H
  2457. # include <string.h>
  2458. #endif
  2459. #if defined(HAVE_STRINGS_H)
  2460. # include <strings.h>
  2461. #endif
  2462. ], [int i; i = 0;],
  2463. AC_MSG_RESULT(yes),
  2464. AC_DEFINE(NO_STRINGS_WITH_STRING_H)
  2465. AC_MSG_RESULT(no))
  2466. CPPFLAGS=$cppflags_save
  2467. fi
  2468. dnl Checks for typedefs, structures, and compiler characteristics.
  2469. AC_PROG_GCC_TRADITIONAL
  2470. AC_C_CONST
  2471. AC_C_VOLATILE
  2472. AC_TYPE_MODE_T
  2473. AC_TYPE_OFF_T
  2474. AC_TYPE_PID_T
  2475. AC_TYPE_SIZE_T
  2476. AC_TYPE_UID_T
  2477. AC_TYPE_UINT32_T
  2478. AC_HEADER_TIME
  2479. AC_CHECK_TYPE(ino_t, long)
  2480. AC_CHECK_TYPE(dev_t, unsigned)
  2481. AC_C_BIGENDIAN(,,,)
  2482. AC_MSG_CHECKING(for rlim_t)
  2483. if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
  2484. AC_MSG_RESULT([(cached) $ac_cv_type_rlim_t])
  2485. else
  2486. AC_EGREP_CPP(dnl
  2487. changequote(<<,>>)dnl
  2488. <<(^|[^a-zA-Z_0-9])rlim_t[^a-zA-Z_0-9]>>dnl
  2489. changequote([,]),
  2490. [
  2491. #include <sys/types.h>
  2492. #if STDC_HEADERS
  2493. # include <stdlib.h>
  2494. # include <stddef.h>
  2495. #endif
  2496. #ifdef HAVE_SYS_RESOURCE_H
  2497. # include <sys/resource.h>
  2498. #endif
  2499. ], ac_cv_type_rlim_t=yes, ac_cv_type_rlim_t=no)
  2500. AC_MSG_RESULT($ac_cv_type_rlim_t)
  2501. fi
  2502. if test $ac_cv_type_rlim_t = no; then
  2503. cat >> confdefs.h <<\EOF
  2504. #define rlim_t unsigned long
  2505. EOF
  2506. fi
  2507. AC_MSG_CHECKING(for stack_t)
  2508. if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then
  2509. AC_MSG_RESULT([(cached) $ac_cv_type_stack_t])
  2510. else
  2511. AC_EGREP_CPP(stack_t,
  2512. [
  2513. #include <sys/types.h>
  2514. #if STDC_HEADERS
  2515. # include <stdlib.h>
  2516. # include <stddef.h>
  2517. #endif
  2518. #include <signal.h>
  2519. ], ac_cv_type_stack_t=yes, ac_cv_type_stack_t=no)
  2520. AC_MSG_RESULT($ac_cv_type_stack_t)
  2521. fi
  2522. if test $ac_cv_type_stack_t = no; then
  2523. cat >> confdefs.h <<\EOF
  2524. #define stack_t struct sigaltstack
  2525. EOF
  2526. fi
  2527. dnl BSDI uses ss_base while others use ss_sp for the stack pointer.
  2528. AC_MSG_CHECKING(whether stack_t has an ss_base field)
  2529. AC_TRY_COMPILE([
  2530. #include <sys/types.h>
  2531. #if STDC_HEADERS
  2532. # include <stdlib.h>
  2533. # include <stddef.h>
  2534. #endif
  2535. #include <signal.h>
  2536. #include "confdefs.h"
  2537. ], [stack_t sigstk; sigstk.ss_base = 0; ],
  2538. AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SS_BASE),
  2539. AC_MSG_RESULT(no))
  2540. olibs="$LIBS"
  2541. AC_MSG_CHECKING(--with-tlib argument)
  2542. AC_ARG_WITH(tlib, [ --with-tlib=library terminal library to be used ],)
  2543. if test -n "$with_tlib"; then
  2544. AC_MSG_RESULT($with_tlib)
  2545. LIBS="$LIBS -l$with_tlib"
  2546. AC_MSG_CHECKING(for linking with $with_tlib library)
  2547. AC_TRY_LINK([], [], AC_MSG_RESULT(OK), AC_MSG_ERROR(FAILED))
  2548. dnl Need to check for tgetent() below.
  2549. olibs="$LIBS"
  2550. else
  2551. AC_MSG_RESULT([empty: automatic terminal library selection])
  2552. dnl On HP-UX 10.10 termcap or termlib should be used instead of
  2553. dnl curses, because curses is much slower.
  2554. dnl Newer versions of ncurses are preferred over anything, except
  2555. dnl when tinfo has been split off, it contains all we need.
  2556. dnl Older versions of ncurses have bugs, get a new one!
  2557. dnl Digital Unix (OSF1) should use curses (Ronald Schild).
  2558. dnl On SCO Openserver should prefer termlib (Roger Cornelius).
  2559. case "`uname -s 2>/dev/null`" in
  2560. OSF1|SCO_SV) tlibs="tinfo ncurses curses termlib termcap";;
  2561. *) tlibs="tinfo ncurses termlib termcap curses";;
  2562. esac
  2563. for libname in $tlibs; do
  2564. AC_CHECK_LIB(${libname}, tgetent,,)
  2565. if test "x$olibs" != "x$LIBS"; then
  2566. dnl It's possible that a library is found but it doesn't work
  2567. dnl e.g., shared library that cannot be found
  2568. dnl compile and run a test program to be sure
  2569. AC_TRY_RUN([
  2570. #ifdef HAVE_TERMCAP_H
  2571. # include <termcap.h>
  2572. #endif
  2573. #if STDC_HEADERS
  2574. # include <stdlib.h>
  2575. # include <stddef.h>
  2576. #endif
  2577. main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }],
  2578. res="OK", res="FAIL", res="FAIL")
  2579. if test "$res" = "OK"; then
  2580. break
  2581. fi
  2582. AC_MSG_RESULT($libname library is not usable)
  2583. LIBS="$olibs"
  2584. fi
  2585. done
  2586. if test "x$olibs" = "x$LIBS"; then
  2587. AC_MSG_RESULT(no terminal library found)
  2588. fi
  2589. fi
  2590. if test "x$olibs" = "x$LIBS"; then
  2591. AC_MSG_CHECKING([for tgetent()])
  2592. AC_TRY_LINK([],
  2593. [char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");],
  2594. AC_MSG_RESULT(yes),
  2595. AC_MSG_ERROR([NOT FOUND!
  2596. You need to install a terminal library; for example ncurses.
  2597. Or specify the name of the library with --with-tlib.]))
  2598. fi
  2599. AC_CACHE_CHECK([whether we talk terminfo], [vim_cv_terminfo],
  2600. [
  2601. AC_RUN_IFELSE([[
  2602. #include "confdefs.h"
  2603. #ifdef HAVE_TERMCAP_H
  2604. # include <termcap.h>
  2605. #endif
  2606. #ifdef HAVE_STRING_H
  2607. # include <string.h>
  2608. #endif
  2609. #if STDC_HEADERS
  2610. # include <stdlib.h>
  2611. # include <stddef.h>
  2612. #endif
  2613. main()
  2614. {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }
  2615. ]],[
  2616. vim_cv_terminfo=no
  2617. ],[
  2618. vim_cv_terminfo=yes
  2619. ],[
  2620. AC_MSG_ERROR(cross-compiling: please set 'vim_cv_terminfo')
  2621. ])
  2622. ])
  2623. if test "x$vim_cv_terminfo" = "xyes" ; then
  2624. AC_DEFINE(TERMINFO)
  2625. fi
  2626. if test "x$olibs" != "x$LIBS"; then
  2627. AC_CACHE_CHECK([what tgetent() returns for an unknown terminal], [vim_cv_tgent],
  2628. [
  2629. AC_RUN_IFELSE([[
  2630. #include "confdefs.h"
  2631. #ifdef HAVE_TERMCAP_H
  2632. # include <termcap.h>
  2633. #endif
  2634. #if STDC_HEADERS
  2635. # include <stdlib.h>
  2636. # include <stddef.h>
  2637. #endif
  2638. main()
  2639. {char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
  2640. ]],[
  2641. vim_cv_tgent=zero
  2642. ],[
  2643. vim_cv_tgent=non-zero
  2644. ],[
  2645. AC_MSG_ERROR(failed to compile test program.)
  2646. ])
  2647. ])
  2648. if test "x$vim_cv_tgent" = "xzero" ; then
  2649. AC_DEFINE(TGETENT_ZERO_ERR, 0)
  2650. fi
  2651. fi
  2652. AC_MSG_CHECKING(whether termcap.h contains ospeed)
  2653. AC_TRY_LINK([
  2654. #ifdef HAVE_TERMCAP_H
  2655. # include <termcap.h>
  2656. #endif
  2657. ], [ospeed = 20000],
  2658. AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED),
  2659. [AC_MSG_RESULT(no)
  2660. AC_MSG_CHECKING(whether ospeed can be extern)
  2661. AC_TRY_LINK([
  2662. #ifdef HAVE_TERMCAP_H
  2663. # include <termcap.h>
  2664. #endif
  2665. extern short ospeed;
  2666. ], [ospeed = 20000],
  2667. AC_MSG_RESULT(yes); AC_DEFINE(OSPEED_EXTERN),
  2668. AC_MSG_RESULT(no))]
  2669. )
  2670. AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC])
  2671. AC_TRY_LINK([
  2672. #ifdef HAVE_TERMCAP_H
  2673. # include <termcap.h>
  2674. #endif
  2675. ], [if (UP == 0 && BC == 0) PC = 1],
  2676. AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UP_BC_PC),
  2677. [AC_MSG_RESULT(no)
  2678. AC_MSG_CHECKING([whether UP, BC and PC can be extern])
  2679. AC_TRY_LINK([
  2680. #ifdef HAVE_TERMCAP_H
  2681. # include <termcap.h>
  2682. #endif
  2683. extern char *UP, *BC, PC;
  2684. ], [if (UP == 0 && BC == 0) PC = 1],
  2685. AC_MSG_RESULT(yes); AC_DEFINE(UP_BC_PC_EXTERN),
  2686. AC_MSG_RESULT(no))]
  2687. )
  2688. AC_MSG_CHECKING(whether tputs() uses outfuntype)
  2689. AC_TRY_COMPILE([
  2690. #ifdef HAVE_TERMCAP_H
  2691. # include <termcap.h>
  2692. #endif
  2693. ], [extern int xx(); tputs("test", 1, (outfuntype)xx)],
  2694. AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OUTFUNTYPE),
  2695. AC_MSG_RESULT(no))
  2696. dnl On some SCO machines sys/select redefines struct timeval
  2697. AC_MSG_CHECKING([whether sys/select.h and sys/time.h may both be included])
  2698. AC_TRY_COMPILE([
  2699. #include <sys/types.h>
  2700. #include <sys/time.h>
  2701. #include <sys/select.h>], ,
  2702. AC_MSG_RESULT(yes)
  2703. AC_DEFINE(SYS_SELECT_WITH_SYS_TIME),
  2704. AC_MSG_RESULT(no))
  2705. dnl AC_DECL_SYS_SIGLIST
  2706. dnl Checks for pty.c (copied from screen) ==========================
  2707. AC_MSG_CHECKING(for /dev/ptc)
  2708. if test -r /dev/ptc; then
  2709. AC_DEFINE(HAVE_DEV_PTC)
  2710. AC_MSG_RESULT(yes)
  2711. else
  2712. AC_MSG_RESULT(no)
  2713. fi
  2714. AC_MSG_CHECKING(for SVR4 ptys)
  2715. if test -c /dev/ptmx ; then
  2716. AC_TRY_LINK([], [ptsname(0);grantpt(0);unlockpt(0);],
  2717. AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SVR4_PTYS),
  2718. AC_MSG_RESULT(no))
  2719. else
  2720. AC_MSG_RESULT(no)
  2721. fi
  2722. AC_MSG_CHECKING(for ptyranges)
  2723. if test -d /dev/ptym ; then
  2724. pdir='/dev/ptym'
  2725. else
  2726. pdir='/dev'
  2727. fi
  2728. dnl SCO uses ptyp%d
  2729. AC_EGREP_CPP(yes,
  2730. [#ifdef M_UNIX
  2731. yes;
  2732. #endif
  2733. ], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
  2734. dnl if test -c /dev/ptyp19; then
  2735. dnl ptys=`echo /dev/ptyp??`
  2736. dnl else
  2737. dnl ptys=`echo $pdir/pty??`
  2738. dnl fi
  2739. if test "$ptys" != "$pdir/pty??" ; then
  2740. p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
  2741. p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'`
  2742. AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
  2743. AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
  2744. AC_MSG_RESULT([$p0 / $p1])
  2745. else
  2746. AC_MSG_RESULT([don't know])
  2747. fi
  2748. dnl **** pty mode/group handling ****
  2749. dnl
  2750. dnl support provided by Luke Mewburn <lm@rmit.edu.au>, 931222
  2751. rm -f conftest_grp
  2752. AC_CACHE_CHECK([default tty permissions/group], [vim_cv_tty_group],
  2753. [
  2754. AC_RUN_IFELSE([[
  2755. #include "confdefs.h"
  2756. #include <sys/types.h>
  2757. #if STDC_HEADERS
  2758. # include <stdlib.h>
  2759. # include <stddef.h>
  2760. #endif
  2761. #ifdef HAVE_UNISTD_H
  2762. #include <unistd.h>
  2763. #endif
  2764. #include <sys/stat.h>
  2765. #include <stdio.h>
  2766. main()
  2767. {
  2768. struct stat sb;
  2769. char *x,*ttyname();
  2770. int om, m;
  2771. FILE *fp;
  2772. if (!(x = ttyname(0))) exit(1);
  2773. if (stat(x, &sb)) exit(1);
  2774. om = sb.st_mode;
  2775. if (om & 002) exit(0);
  2776. m = system("mesg y");
  2777. if (m == -1 || m == 127) exit(1);
  2778. if (stat(x, &sb)) exit(1);
  2779. m = sb.st_mode;
  2780. if (chmod(x, om)) exit(1);
  2781. if (m & 002) exit(0);
  2782. if (sb.st_gid == getgid()) exit(1);
  2783. if (!(fp=fopen("conftest_grp", "w")))
  2784. exit(1);
  2785. fprintf(fp, "%d\n", sb.st_gid);
  2786. fclose(fp);
  2787. exit(0);
  2788. }
  2789. ]],[
  2790. if test -f conftest_grp; then
  2791. vim_cv_tty_group=`cat conftest_grp`
  2792. if test "x$vim_cv_tty_mode" = "x" ; then
  2793. vim_cv_tty_mode=0620
  2794. fi
  2795. AC_MSG_RESULT([pty mode: $vim_cv_tty_mode, group: $vim_cv_tty_group])
  2796. else
  2797. vim_cv_tty_group=world
  2798. AC_MSG_RESULT([ptys are world accessible])
  2799. fi
  2800. ],[
  2801. vim_cv_tty_group=world
  2802. AC_MSG_RESULT([can't determine - assume ptys are world accessible])
  2803. ],[
  2804. AC_MSG_ERROR(cross-compiling: please set 'vim_cv_tty_group' and 'vim_cv_tty_mode')
  2805. ])
  2806. ])
  2807. rm -f conftest_grp
  2808. if test "x$vim_cv_tty_group" != "xworld" ; then
  2809. AC_DEFINE_UNQUOTED(PTYGROUP,$vim_cv_tty_group)
  2810. if test "x$vim_cv_tty_mode" = "x" ; then
  2811. 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 (propably 0620)])
  2812. else
  2813. AC_DEFINE(PTYMODE, 0620)
  2814. fi
  2815. fi
  2816. dnl Checks for library functions. ===================================
  2817. AC_TYPE_SIGNAL
  2818. dnl find out what to use at the end of a signal function
  2819. if test $ac_cv_type_signal = void; then
  2820. AC_DEFINE(SIGRETURN, [return])
  2821. else
  2822. AC_DEFINE(SIGRETURN, [return 0])
  2823. fi
  2824. dnl check if struct sigcontext is defined (used for SGI only)
  2825. AC_MSG_CHECKING(for struct sigcontext)
  2826. AC_TRY_COMPILE([
  2827. #include <signal.h>
  2828. test_sig()
  2829. {
  2830. struct sigcontext *scont;
  2831. scont = (struct sigcontext *)0;
  2832. return 1;
  2833. } ], ,
  2834. AC_MSG_RESULT(yes)
  2835. AC_DEFINE(HAVE_SIGCONTEXT),
  2836. AC_MSG_RESULT(no))
  2837. dnl tricky stuff: try to find out if getcwd() is implemented with
  2838. dnl system("sh -c pwd")
  2839. AC_CACHE_CHECK([getcwd implementation is broken], [vim_cv_getcwd_broken],
  2840. [
  2841. AC_RUN_IFELSE([[
  2842. #include "confdefs.h"
  2843. #ifdef HAVE_UNISTD_H
  2844. #include <unistd.h>
  2845. #endif
  2846. char *dagger[] = { "IFS=pwd", 0 };
  2847. main()
  2848. {
  2849. char buffer[500];
  2850. extern char **environ;
  2851. environ = dagger;
  2852. return getcwd(buffer, 500) ? 0 : 1;
  2853. }
  2854. ]],[
  2855. vim_cv_getcwd_broken=no
  2856. ],[
  2857. vim_cv_getcwd_broken=yes
  2858. ],[
  2859. AC_MSG_ERROR(cross-compiling: please set 'vim_cv_getcwd_broken')
  2860. ])
  2861. ])
  2862. if test "x$vim_cv_getcwd_broken" = "xyes" ; then
  2863. AC_DEFINE(BAD_GETCWD)
  2864. fi
  2865. dnl Check for functions in one big call, to reduce the size of configure.
  2866. dnl Can only be used for functions that do not require any include.
  2867. AC_CHECK_FUNCS(bcmp fchdir fchown fsync getcwd getpseudotty \
  2868. getpwnam getpwuid getrlimit gettimeofday getwd lstat memcmp \
  2869. memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
  2870. setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
  2871. sigvec strcasecmp strerror strftime stricmp strncasecmp \
  2872. strnicmp strpbrk strtol tgetent towlower towupper iswupper \
  2873. usleep utime utimes)
  2874. AC_FUNC_FSEEKO
  2875. dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when
  2876. dnl appropriate, so that off_t is 64 bits when needed.
  2877. AC_SYS_LARGEFILE
  2878. dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible
  2879. AC_MSG_CHECKING(for st_blksize)
  2880. AC_TRY_COMPILE(
  2881. [#include <sys/types.h>
  2882. #include <sys/stat.h>],
  2883. [ struct stat st;
  2884. int n;
  2885. stat("/", &st);
  2886. n = (int)st.st_blksize;],
  2887. AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ST_BLKSIZE),
  2888. AC_MSG_RESULT(no))
  2889. AC_CACHE_CHECK([whether stat() ignores a trailing slash], [vim_cv_stat_ignores_slash],
  2890. [
  2891. AC_RUN_IFELSE([[
  2892. #include "confdefs.h"
  2893. #if STDC_HEADERS
  2894. # include <stdlib.h>
  2895. # include <stddef.h>
  2896. #endif
  2897. #include <sys/types.h>
  2898. #include <sys/stat.h>
  2899. main() {struct stat st; exit(stat("configure/", &st) != 0); }
  2900. ]],[
  2901. vim_cv_stat_ignores_slash=yes
  2902. ],[
  2903. vim_cv_stat_ignores_slash=no
  2904. ],[
  2905. AC_MSG_ERROR(cross-compiling: please set 'vim_cv_stat_ignores_slash')
  2906. ])
  2907. ])
  2908. if test "x$vim_cv_stat_ignores_slash" = "xyes" ; then
  2909. AC_DEFINE(STAT_IGNORES_SLASH)
  2910. fi
  2911. dnl Link with iconv for charset translation, if not found without library.
  2912. dnl check for iconv() requires including iconv.h
  2913. dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
  2914. dnl has been installed.
  2915. AC_MSG_CHECKING(for iconv_open())
  2916. save_LIBS="$LIBS"
  2917. LIBS="$LIBS -liconv"
  2918. AC_TRY_LINK([
  2919. #ifdef HAVE_ICONV_H
  2920. # include <iconv.h>
  2921. #endif
  2922. ], [iconv_open("fr", "to");],
  2923. AC_MSG_RESULT(yes; with -liconv); AC_DEFINE(HAVE_ICONV),
  2924. LIBS="$save_LIBS"
  2925. AC_TRY_LINK([
  2926. #ifdef HAVE_ICONV_H
  2927. # include <iconv.h>
  2928. #endif
  2929. ], [iconv_open("fr", "to");],
  2930. AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ICONV),
  2931. AC_MSG_RESULT(no)))
  2932. AC_MSG_CHECKING(for nl_langinfo(CODESET))
  2933. AC_TRY_LINK([
  2934. #ifdef HAVE_LANGINFO_H
  2935. # include <langinfo.h>
  2936. #endif
  2937. ], [char *cs = nl_langinfo(CODESET);],
  2938. AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET),
  2939. AC_MSG_RESULT(no))
  2940. dnl Need various functions for floating point support. Only enable
  2941. dnl floating point when they are all present.
  2942. AC_CHECK_LIB(m, strtod)
  2943. AC_MSG_CHECKING([for strtod() and other floating point functions])
  2944. AC_TRY_LINK([
  2945. #ifdef HAVE_MATH_H
  2946. # include <math.h>
  2947. #endif
  2948. #if STDC_HEADERS
  2949. # include <stdlib.h>
  2950. # include <stddef.h>
  2951. #endif
  2952. ], [char *s; double d;
  2953. d = strtod("1.1", &s);
  2954. d = fabs(1.11);
  2955. d = ceil(1.11);
  2956. d = floor(1.11);
  2957. d = log10(1.11);
  2958. d = pow(1.11, 2.22);
  2959. d = sqrt(1.11);
  2960. d = sin(1.11);
  2961. d = cos(1.11);
  2962. d = atan(1.11);
  2963. ],
  2964. AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT_FUNCS),
  2965. AC_MSG_RESULT(no))
  2966. dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI
  2967. dnl when -lacl works, also try to use -lattr (required for Debian).
  2968. dnl On Solaris, use the acl_get/set functions in libsec, if present.
  2969. AC_MSG_CHECKING(--disable-acl argument)
  2970. AC_ARG_ENABLE(acl,
  2971. [ --disable-acl Don't check for ACL support.],
  2972. , [enable_acl="yes"])
  2973. if test "$enable_acl" = "yes"; then
  2974. AC_MSG_RESULT(no)
  2975. AC_CHECK_LIB(posix1e, acl_get_file, [LIBS="$LIBS -lposix1e"],
  2976. AC_CHECK_LIB(acl, acl_get_file, [LIBS="$LIBS -lacl"
  2977. AC_CHECK_LIB(attr, fgetxattr, LIBS="$LIBS -lattr",,)],,),)
  2978. AC_MSG_CHECKING(for POSIX ACL support)
  2979. AC_TRY_LINK([
  2980. #include <sys/types.h>
  2981. #ifdef HAVE_SYS_ACL_H
  2982. # include <sys/acl.h>
  2983. #endif
  2984. acl_t acl;], [acl = acl_get_file("foo", ACL_TYPE_ACCESS);
  2985. acl_set_file("foo", ACL_TYPE_ACCESS, acl);
  2986. acl_free(acl);],
  2987. AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_ACL),
  2988. AC_MSG_RESULT(no))
  2989. AC_CHECK_LIB(sec, acl_get, [LIBS="$LIBS -lsec"; AC_DEFINE(HAVE_SOLARIS_ZFS_ACL)],
  2990. AC_MSG_CHECKING(for Solaris ACL support)
  2991. AC_TRY_LINK([
  2992. #ifdef HAVE_SYS_ACL_H
  2993. # include <sys/acl.h>
  2994. #endif], [acl("foo", GETACLCNT, 0, NULL);
  2995. ],
  2996. AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOLARIS_ACL),
  2997. AC_MSG_RESULT(no)))
  2998. AC_MSG_CHECKING(for AIX ACL support)
  2999. AC_TRY_LINK([
  3000. #if STDC_HEADERS
  3001. # include <stdlib.h>
  3002. # include <stddef.h>
  3003. #endif
  3004. #ifdef HAVE_SYS_ACL_H
  3005. # include <sys/acl.h>
  3006. #endif
  3007. #ifdef HAVE_SYS_ACCESS_H
  3008. # include <sys/access.h>
  3009. #endif
  3010. #define _ALL_SOURCE
  3011. #include <sys/stat.h>
  3012. int aclsize;
  3013. struct acl *aclent;], [aclsize = sizeof(struct acl);
  3014. aclent = (void *)malloc(aclsize);
  3015. statacl("foo", STX_NORMAL, aclent, aclsize);
  3016. ],
  3017. AC_MSG_RESULT(yes); AC_DEFINE(HAVE_AIX_ACL),
  3018. AC_MSG_RESULT(no))
  3019. else
  3020. AC_MSG_RESULT(yes)
  3021. fi
  3022. AC_MSG_CHECKING(--disable-gpm argument)
  3023. AC_ARG_ENABLE(gpm,
  3024. [ --disable-gpm Don't use gpm (Linux mouse daemon).], ,
  3025. [enable_gpm="yes"])
  3026. if test "$enable_gpm" = "yes"; then
  3027. AC_MSG_RESULT(no)
  3028. dnl Checking if gpm support can be compiled
  3029. AC_CACHE_CHECK([for gpm], vi_cv_have_gpm,
  3030. [olibs="$LIBS" ; LIBS="-lgpm"]
  3031. AC_TRY_LINK(
  3032. [#include <gpm.h>
  3033. #include <linux/keyboard.h>],
  3034. [Gpm_GetLibVersion(NULL);],
  3035. dnl Configure defines HAVE_GPM, if it is defined feature.h defines
  3036. dnl FEAT_MOUSE_GPM if mouse support is included
  3037. [vi_cv_have_gpm=yes],
  3038. [vi_cv_have_gpm=no])
  3039. [LIBS="$olibs"]
  3040. )
  3041. if test $vi_cv_have_gpm = yes; then
  3042. LIBS="$LIBS -lgpm"
  3043. AC_DEFINE(HAVE_GPM)
  3044. fi
  3045. else
  3046. AC_MSG_RESULT(yes)
  3047. fi
  3048. AC_MSG_CHECKING(--disable-sysmouse argument)
  3049. AC_ARG_ENABLE(sysmouse,
  3050. [ --disable-sysmouse Don't use sysmouse (mouse in *BSD console).], ,
  3051. [enable_sysmouse="yes"])
  3052. if test "$enable_sysmouse" = "yes"; then
  3053. AC_MSG_RESULT(no)
  3054. dnl Checking if sysmouse support can be compiled
  3055. dnl Configure defines HAVE_SYSMOUSE, if it is defined feature.h
  3056. dnl defines FEAT_SYSMOUSE if mouse support is included
  3057. AC_CACHE_CHECK([for sysmouse], vi_cv_have_sysmouse,
  3058. AC_TRY_LINK(
  3059. [#include <sys/consio.h>
  3060. #include <signal.h>
  3061. #include <sys/fbio.h>],
  3062. [struct mouse_info mouse;
  3063. mouse.operation = MOUSE_MODE;
  3064. mouse.operation = MOUSE_SHOW;
  3065. mouse.u.mode.mode = 0;
  3066. mouse.u.mode.signal = SIGUSR2;],
  3067. [vi_cv_have_sysmouse=yes],
  3068. [vi_cv_have_sysmouse=no])
  3069. )
  3070. if test $vi_cv_have_sysmouse = yes; then
  3071. AC_DEFINE(HAVE_SYSMOUSE)
  3072. fi
  3073. else
  3074. AC_MSG_RESULT(yes)
  3075. fi
  3076. dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
  3077. AC_MSG_CHECKING(for FD_CLOEXEC)
  3078. AC_TRY_COMPILE(
  3079. [#if HAVE_FCNTL_H
  3080. # include <fcntl.h>
  3081. #endif],
  3082. [ int flag = FD_CLOEXEC;],
  3083. AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
  3084. AC_MSG_RESULT(not usable))
  3085. dnl rename needs to be checked separately to work on Nextstep with cc
  3086. AC_MSG_CHECKING(for rename)
  3087. AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
  3088. AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
  3089. AC_MSG_RESULT(no))
  3090. dnl sysctl() may exist but not the arguments we use
  3091. AC_MSG_CHECKING(for sysctl)
  3092. AC_TRY_COMPILE(
  3093. [#include <sys/types.h>
  3094. #include <sys/sysctl.h>],
  3095. [ int mib[2], r;
  3096. size_t len;
  3097. mib[0] = CTL_HW;
  3098. mib[1] = HW_USERMEM;
  3099. len = sizeof(r);
  3100. (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
  3101. ],
  3102. AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL),
  3103. AC_MSG_RESULT(not usable))
  3104. dnl sysinfo() may exist but not be Linux compatible
  3105. AC_MSG_CHECKING(for sysinfo)
  3106. AC_TRY_COMPILE(
  3107. [#include <sys/types.h>
  3108. #include <sys/sysinfo.h>],
  3109. [ struct sysinfo sinfo;
  3110. int t;
  3111. (void)sysinfo(&sinfo);
  3112. t = sinfo.totalram;
  3113. ],
  3114. AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
  3115. AC_MSG_RESULT(not usable))
  3116. dnl struct sysinfo may have the mem_unit field or not
  3117. AC_MSG_CHECKING(for sysinfo.mem_unit)
  3118. AC_TRY_COMPILE(
  3119. [#include <sys/types.h>
  3120. #include <sys/sysinfo.h>],
  3121. [ struct sysinfo sinfo;
  3122. sinfo.mem_unit = 1;
  3123. ],
  3124. AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_MEM_UNIT),
  3125. AC_MSG_RESULT(no))
  3126. dnl sysconf() may exist but not support what we want to use
  3127. AC_MSG_CHECKING(for sysconf)
  3128. AC_TRY_COMPILE(
  3129. [#include <unistd.h>],
  3130. [ (void)sysconf(_SC_PAGESIZE);
  3131. (void)sysconf(_SC_PHYS_PAGES);
  3132. ],
  3133. AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
  3134. AC_MSG_RESULT(not usable))
  3135. AC_CHECK_SIZEOF([int])
  3136. AC_CHECK_SIZEOF([long])
  3137. AC_CHECK_SIZEOF([time_t])
  3138. AC_CHECK_SIZEOF([off_t])
  3139. dnl Make sure that uint32_t is really 32 bits unsigned.
  3140. AC_MSG_CHECKING([uint32_t is 32 bits])
  3141. AC_TRY_RUN([
  3142. #ifdef HAVE_STDINT_H
  3143. # include <stdint.h>
  3144. #endif
  3145. #ifdef HAVE_INTTYPES_H
  3146. # include <inttypes.h>
  3147. #endif
  3148. main() {
  3149. uint32_t nr1 = (uint32_t)-1;
  3150. uint32_t nr2 = (uint32_t)0xffffffffUL;
  3151. if (sizeof(uint32_t) != 4 || nr1 != 0xffffffffUL || nr2 + 1 != 0) exit(1);
  3152. exit(0);
  3153. }],
  3154. AC_MSG_RESULT(ok),
  3155. AC_MSG_ERROR([WRONG! uint32_t not defined correctly.]),
  3156. AC_MSG_WARN([cannot check uint32_t when cross-compiling.]))
  3157. dnl Check for memmove() before bcopy(), makes memmove() be used when both are
  3158. dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
  3159. [bcopy_test_prog='
  3160. #include "confdefs.h"
  3161. #ifdef HAVE_STRING_H
  3162. # include <string.h>
  3163. #endif
  3164. #if STDC_HEADERS
  3165. # include <stdlib.h>
  3166. # include <stddef.h>
  3167. #endif
  3168. main() {
  3169. char buf[10];
  3170. strcpy(buf, "abcdefghi");
  3171. mch_memmove(buf, buf + 2, 3);
  3172. if (strncmp(buf, "ababcf", 6))
  3173. exit(1);
  3174. strcpy(buf, "abcdefghi");
  3175. mch_memmove(buf + 2, buf, 3);
  3176. if (strncmp(buf, "cdedef", 6))
  3177. exit(1);
  3178. exit(0); /* libc version works properly. */
  3179. }']
  3180. AC_CACHE_CHECK([whether memmove handles overlaps],[vim_cv_memmove_handles_overlap],
  3181. [
  3182. AC_RUN_IFELSE([[#define mch_memmove(s,d,l) memmove(d,s,l) $bcopy_test_prog]],
  3183. [
  3184. vim_cv_memmove_handles_overlap=yes
  3185. ],[
  3186. vim_cv_memmove_handles_overlap=no
  3187. ],[
  3188. AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memmove_handles_overlap')
  3189. ])
  3190. ])
  3191. if test "x$vim_cv_memmove_handles_overlap" = "xyes" ; then
  3192. AC_DEFINE(USEMEMMOVE)
  3193. else
  3194. AC_CACHE_CHECK([whether bcopy handles overlaps],[vim_cv_bcopy_handles_overlap],
  3195. [
  3196. AC_RUN_IFELSE([[#define mch_bcopy(s,d,l) bcopy(d,s,l) $bcopy_test_prog]],
  3197. [
  3198. vim_cv_bcopy_handles_overlap=yes
  3199. ],[
  3200. vim_cv_bcopy_handles_overlap=no
  3201. ],[
  3202. AC_MSG_ERROR(cross-compiling: please set 'vim_cv_bcopy_handles_overlap')
  3203. ])
  3204. ])
  3205. if test "x$vim_cv_bcopy_handles_overlap" = "xyes" ; then
  3206. AC_DEFINE(USEBCOPY)
  3207. else
  3208. AC_CACHE_CHECK([whether memcpy handles overlaps],[vim_cv_memcpy_handles_overlap],
  3209. [
  3210. AC_RUN_IFELSE([[#define mch_memcpy(s,d,l) memcpy(d,s,l) $bcopy_test_prog]],
  3211. [
  3212. vim_cv_memcpy_handles_overlap=yes
  3213. ],[
  3214. vim_cv_memcpy_handles_overlap=no
  3215. ],[
  3216. AC_MSG_ERROR(cross-compiling: please set 'vim_cv_memcpy_handles_overlap')
  3217. ])
  3218. ])
  3219. if test "x$vim_cv_memcpy_handles_overlap" = "xyes" ; then
  3220. AC_DEFINE(USEMEMCPY)
  3221. fi
  3222. fi
  3223. fi
  3224. dnl Check for multibyte locale functions
  3225. dnl Find out if _Xsetlocale() is supported by libX11.
  3226. dnl Check if X_LOCALE should be defined.
  3227. if test "$enable_multibyte" = "yes"; then
  3228. cflags_save=$CFLAGS
  3229. ldflags_save=$LDFLAGS
  3230. if test "x$x_includes" != "xNONE" ; then
  3231. CFLAGS="$CFLAGS -I$x_includes"
  3232. LDFLAGS="$X_LIBS $LDFLAGS -lX11"
  3233. AC_MSG_CHECKING(whether X_LOCALE needed)
  3234. AC_TRY_COMPILE([#include <X11/Xlocale.h>],,
  3235. AC_TRY_LINK_FUNC([_Xsetlocale], [AC_MSG_RESULT(yes)
  3236. AC_DEFINE(X_LOCALE)], AC_MSG_RESULT(no)),
  3237. AC_MSG_RESULT(no))
  3238. fi
  3239. CFLAGS=$cflags_save
  3240. LDFLAGS=$ldflags_save
  3241. fi
  3242. dnl Link with xpg4, it is said to make Korean locale working
  3243. AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,)
  3244. dnl Check how we can run ctags. Default to "ctags" when nothing works.
  3245. dnl Use --version to detect Exuberant ctags (preferred)
  3246. dnl Add --fields=+S to get function signatures for omni completion.
  3247. dnl -t for typedefs (many ctags have this)
  3248. dnl -s for static functions (Elvis ctags only?)
  3249. dnl -v for variables. Dangerous, most ctags take this for 'vgrind style'.
  3250. dnl -i+m to test for older Exuberant ctags
  3251. AC_MSG_CHECKING(how to create tags)
  3252. test -f tags && mv tags tags.save
  3253. if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
  3254. TAGPRG="ctags -I INIT+ --fields=+S"
  3255. elif (eval exctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
  3256. TAGPRG="exctags -I INIT+ --fields=+S"
  3257. elif (eval exuberant-ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
  3258. TAGPRG="exuberant-ctags -I INIT+ --fields=+S"
  3259. else
  3260. TAGPRG="ctags"
  3261. (eval etags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags"
  3262. (eval etags -c /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags -c"
  3263. (eval ctags /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags"
  3264. (eval ctags -t /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -t"
  3265. (eval ctags -ts /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -ts"
  3266. (eval ctags -tvs /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -tvs"
  3267. (eval ctags -i+m /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -i+m"
  3268. fi
  3269. test -f tags.save && mv tags.save tags
  3270. AC_MSG_RESULT($TAGPRG) AC_SUBST(TAGPRG)
  3271. dnl Check how we can run man with a section number
  3272. AC_MSG_CHECKING(how to run man with a section nr)
  3273. MANDEF="man"
  3274. (eval MANPAGER=cat PAGER=cat man -s 2 read) < /dev/null > /dev/null 2>&AC_FD_CC && MANDEF="man -s"
  3275. AC_MSG_RESULT($MANDEF)
  3276. if test "$MANDEF" = "man -s"; then
  3277. AC_DEFINE(USEMAN_S)
  3278. fi
  3279. dnl Check if gettext() is working and if it needs -lintl
  3280. AC_MSG_CHECKING(--disable-nls argument)
  3281. AC_ARG_ENABLE(nls,
  3282. [ --disable-nls Don't support NLS (gettext()).], ,
  3283. [enable_nls="yes"])
  3284. if test "$enable_nls" = "yes"; then
  3285. AC_MSG_RESULT(no)
  3286. INSTALL_LANGS=install-languages
  3287. AC_SUBST(INSTALL_LANGS)
  3288. INSTALL_TOOL_LANGS=install-tool-languages
  3289. AC_SUBST(INSTALL_TOOL_LANGS)
  3290. AC_CHECK_PROG(MSGFMT, msgfmt, msgfmt, )
  3291. AC_MSG_CHECKING([for NLS])
  3292. if test -f po/Makefile; then
  3293. have_gettext="no"
  3294. if test -n "$MSGFMT"; then
  3295. AC_TRY_LINK(
  3296. [#include <libintl.h>],
  3297. [gettext("Test");],
  3298. AC_MSG_RESULT([gettext() works]); have_gettext="yes",
  3299. olibs=$LIBS
  3300. LIBS="$LIBS -lintl"
  3301. AC_TRY_LINK(
  3302. [#include <libintl.h>],
  3303. [gettext("Test");],
  3304. AC_MSG_RESULT([gettext() works with -lintl]); have_gettext="yes",
  3305. AC_MSG_RESULT([gettext() doesn't work]);
  3306. LIBS=$olibs))
  3307. else
  3308. AC_MSG_RESULT([msgfmt not found - disabled]);
  3309. fi
  3310. if test $have_gettext = "yes"; then
  3311. AC_DEFINE(HAVE_GETTEXT)
  3312. MAKEMO=yes
  3313. AC_SUBST(MAKEMO)
  3314. dnl this was added in GNU gettext 0.10.36
  3315. AC_CHECK_FUNCS(bind_textdomain_codeset)
  3316. dnl _nl_msg_cat_cntr is required for GNU gettext
  3317. AC_MSG_CHECKING([for _nl_msg_cat_cntr])
  3318. AC_TRY_LINK(
  3319. [#include <libintl.h>
  3320. extern int _nl_msg_cat_cntr;],
  3321. [++_nl_msg_cat_cntr;],
  3322. AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_NL_MSG_CAT_CNTR),
  3323. AC_MSG_RESULT([no]))
  3324. fi
  3325. else
  3326. AC_MSG_RESULT([no "po/Makefile" - disabled]);
  3327. fi
  3328. else
  3329. AC_MSG_RESULT(yes)
  3330. fi
  3331. dnl Check for dynamic linking loader
  3332. AC_CHECK_HEADER(dlfcn.h, DLL=dlfcn.h, [AC_CHECK_HEADER(dl.h, DLL=dl.h)])
  3333. if test x${DLL} = xdlfcn.h; then
  3334. AC_DEFINE(HAVE_DLFCN_H, 1, [ Define if we have dlfcn.h. ])
  3335. AC_MSG_CHECKING([for dlopen()])
  3336. AC_TRY_LINK(,[
  3337. extern void* dlopen();
  3338. dlopen();
  3339. ],
  3340. AC_MSG_RESULT(yes);
  3341. AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
  3342. AC_MSG_RESULT(no);
  3343. AC_MSG_CHECKING([for dlopen() in -ldl])
  3344. olibs=$LIBS
  3345. LIBS="$LIBS -ldl"
  3346. AC_TRY_LINK(,[
  3347. extern void* dlopen();
  3348. dlopen();
  3349. ],
  3350. AC_MSG_RESULT(yes);
  3351. AC_DEFINE(HAVE_DLOPEN, 1, [ Define if we have dlopen() ]),
  3352. AC_MSG_RESULT(no);
  3353. LIBS=$olibs))
  3354. dnl ReliantUNIX has dlopen() in libc but everything else in libdl
  3355. dnl ick :-)
  3356. AC_MSG_CHECKING([for dlsym()])
  3357. AC_TRY_LINK(,[
  3358. extern void* dlsym();
  3359. dlsym();
  3360. ],
  3361. AC_MSG_RESULT(yes);
  3362. AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
  3363. AC_MSG_RESULT(no);
  3364. AC_MSG_CHECKING([for dlsym() in -ldl])
  3365. olibs=$LIBS
  3366. LIBS="$LIBS -ldl"
  3367. AC_TRY_LINK(,[
  3368. extern void* dlsym();
  3369. dlsym();
  3370. ],
  3371. AC_MSG_RESULT(yes);
  3372. AC_DEFINE(HAVE_DLSYM, 1, [ Define if we have dlsym() ]),
  3373. AC_MSG_RESULT(no);
  3374. LIBS=$olibs))
  3375. elif test x${DLL} = xdl.h; then
  3376. AC_DEFINE(HAVE_DL_H, 1, [ Define if we have dl.h. ])
  3377. AC_MSG_CHECKING([for shl_load()])
  3378. AC_TRY_LINK(,[
  3379. extern void* shl_load();
  3380. shl_load();
  3381. ],
  3382. AC_MSG_RESULT(yes);
  3383. AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
  3384. AC_MSG_RESULT(no);
  3385. AC_MSG_CHECKING([for shl_load() in -ldld])
  3386. olibs=$LIBS
  3387. LIBS="$LIBS -ldld"
  3388. AC_TRY_LINK(,[
  3389. extern void* shl_load();
  3390. shl_load();
  3391. ],
  3392. AC_MSG_RESULT(yes);
  3393. AC_DEFINE(HAVE_SHL_LOAD, 1, [ Define if we have shl_load() ]),
  3394. AC_MSG_RESULT(no);
  3395. LIBS=$olibs))
  3396. fi
  3397. AC_CHECK_HEADERS(setjmp.h)
  3398. if test "x$MACOSX" = "xyes" -a -n "$PERL"; then
  3399. dnl -ldl must come after DynaLoader.a
  3400. if echo $LIBS | grep -e '-ldl' >/dev/null; then
  3401. LIBS=`echo $LIBS | sed s/-ldl//`
  3402. PERL_LIBS="$PERL_LIBS -ldl"
  3403. fi
  3404. fi
  3405. if test "x$MACOSX" = "xyes"; then
  3406. AC_MSG_CHECKING(whether we need -framework Cocoa)
  3407. dnl Cocoa is needed with FEAT_CLIPBOARD or FEAT_MBYTE (the former is
  3408. dnl disabled during tiny build)
  3409. if test "x$features" != "xtiny" || test "x$enable_multibyte" = "xyes"; then
  3410. LIBS=$"$LIBS -framework Cocoa"
  3411. AC_MSG_RESULT(yes)
  3412. else
  3413. AC_MSG_RESULT(no)
  3414. fi
  3415. fi
  3416. if test "x$MACARCH" = "xboth" && test "x$GUITYPE" = "xCARBONGUI"; then
  3417. LDFLAGS="$LDFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
  3418. fi
  3419. dnl gcc 3.1 changed the meaning of -MM. The only solution appears to be to
  3420. dnl use "-isystem" instead of "-I" for all non-Vim include dirs.
  3421. dnl But only when making dependencies, cproto and lint don't take "-isystem".
  3422. dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
  3423. dnl the number before the version number.
  3424. DEPEND_CFLAGS_FILTER=
  3425. if test "$GCC" = yes; then
  3426. AC_MSG_CHECKING(for GCC 3 or later)
  3427. gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]]\)\..*$/\1/g'`
  3428. if test "$gccmajor" -gt "2"; then
  3429. DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
  3430. AC_MSG_RESULT(yes)
  3431. else
  3432. AC_MSG_RESULT(no)
  3433. fi
  3434. dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
  3435. dnl declared as char x[1] but actually longer. Introduced in gcc 4.0.
  3436. dnl Also remove duplicate _FORTIFY_SOURCE arguments.
  3437. dnl And undefine it first to avoid a warning.
  3438. AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
  3439. if test "$gccmajor" -gt "3"; then
  3440. CFLAGS=`echo "$CFLAGS" | sed -e 's/-Wp,-D_FORTIFY_SOURCE=.//g' -e 's/-D_FORTIFY_SOURCE=.//g' -e 's/$/ -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1/'`
  3441. AC_MSG_RESULT(yes)
  3442. else
  3443. AC_MSG_RESULT(no)
  3444. fi
  3445. fi
  3446. AC_SUBST(DEPEND_CFLAGS_FILTER)
  3447. dnl link.sh tries to avoid overlinking in a hackish way.
  3448. dnl At least GNU ld supports --as-needed which provides the same functionality
  3449. dnl at linker level. Let's use it.
  3450. AC_MSG_CHECKING(linker --as-needed support)
  3451. LINK_AS_NEEDED=
  3452. # Check if linker supports --as-needed and --no-as-needed options
  3453. if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
  3454. LDFLAGS="$LDFLAGS -Wl,--as-needed"
  3455. LINK_AS_NEEDED=yes
  3456. fi
  3457. if test "$LINK_AS_NEEDED" = yes; then
  3458. AC_MSG_RESULT(yes)
  3459. else
  3460. AC_MSG_RESULT(no)
  3461. fi
  3462. AC_SUBST(LINK_AS_NEEDED)
  3463. dnl write output files
  3464. AC_OUTPUT(auto/config.mk:config.mk.in)
  3465. dnl vim: set sw=2 tw=78 fo+=l: