From 3f7d0907269558cb3ea184a3083640f9e20bb21e Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 12 Nov 2016 21:13:42 +0100 Subject: patch 8.0.0082 Problem: Extension for configure should be ".ac". Solution: Rename configure.in to configure.ac. (James McCoy, closes #1173) --- src/INSTALL | 4 +- src/Makefile | 6 +- src/blowfish.c | 2 +- src/channel.c | 2 +- src/config.h.in | 4 +- src/configure.ac | 4314 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/configure.in | 4314 ------------------------------------------------------ src/main.aap | 4 +- src/mysign | 2 +- src/os_unix.c | 2 +- src/version.c | 2 + 11 files changed, 4329 insertions(+), 4327 deletions(-) create mode 100644 src/configure.ac delete mode 100644 src/configure.in (limited to 'src') diff --git a/src/INSTALL b/src/INSTALL index a827fa1bd9..99f1047a48 100644 --- a/src/INSTALL +++ b/src/INSTALL @@ -221,8 +221,8 @@ diffs or instructions to the address given in the `README' so they can be considered for the next release. If at some point `config.cache' contains results you don't want to keep, you may remove or edit it. - The file `configure.in' is used to create `configure' by a program -called `autoconf'. You only need `configure.in' if you want to change + The file `configure.ac' is used to create `configure' by a program +called `autoconf'. You only need `configure.ac' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: diff --git a/src/Makefile b/src/Makefile index fef53af432..5c788cc207 100644 --- a/src/Makefile +++ b/src/Makefile @@ -690,8 +690,8 @@ SANITIZER_LIBS = $(SANITIZER_CFLAGS) ##################################################### ### Uncomment things here only if the values chosen by configure are wrong. -### It's better to adjust configure.in and "make autoconf", if you can! -### Then send the required changes to configure.in to the bugs list. +### It's better to adjust configure.ac and "make autoconf", if you can! +### Then send the required changes to configure.ac to the bugs list. ### (1) BSD/OS 2.0.1, 2.1 or 3.0 using shared libraries ### @@ -1832,7 +1832,7 @@ reconfig: scratch clean # - DO NOT RUN autoconf MANUALLY! It will overwrite ./configure instead of # producing auto/configure. # - autoconf is not run automatically, because a patch usually changes both -# configure.in and auto/configure but can't update the timestamps. People +# configure.ac and auto/configure but can't update the timestamps. People # who do not have (the correct version of) autoconf would run into trouble. # # Two tricks are required to make autoconf put its output in the "auto" dir: diff --git a/src/blowfish.c b/src/blowfish.c index ac9b088d66..eaf0b9ed56 100644 --- a/src/blowfish.c +++ b/src/blowfish.c @@ -38,7 +38,7 @@ typedef union { /* MS-Windows is always little endian */ #else # ifdef HAVE_CONFIG_H - /* in configure.in AC_C_BIGENDIAN() defines WORDS_BIGENDIAN when needed */ + /* in configure.ac AC_C_BIGENDIAN() defines WORDS_BIGENDIAN when needed */ # else error! Please change this code to define WORDS_BIGENDIAN for big-endian machines. diff --git a/src/channel.c b/src/channel.c index aa82d717d4..1ddb1ece35 100644 --- a/src/channel.c +++ b/src/channel.c @@ -19,7 +19,7 @@ # define CH_HAS_GUI (gui.in_use || gui.starting) #endif -/* Note: when making changes here also adjust configure.in. */ +/* Note: when making changes here also adjust configure.ac. */ #ifdef WIN32 /* WinSock API is separated from C API, thus we can't use read(), write(), * errno... */ diff --git a/src/config.h.in b/src/config.h.in index 62427e28eb..5baac7d6b5 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -1,6 +1,6 @@ /* - * config.h.in. Generated automatically from configure.in by autoheader, and - * manually changed after that. + * config.h.in. Originally generated automatically from configure.ac by + * autoheader and manually changed after that. */ /* Define if we have EBCDIC code */ diff --git a/src/configure.ac b/src/configure.ac new file mode 100644 index 0000000000..f6a44691f0 --- /dev/null +++ b/src/configure.ac @@ -0,0 +1,4314 @@ +dnl configure.ac: autoconf script for Vim + +dnl Process this file with autoconf 2.12 or 2.13 to produce "configure". +dnl Should also work with autoconf 2.54 and later. + +AC_INIT(vim.h) +AC_CONFIG_HEADER(auto/config.h:config.h.in) + +dnl Being able to run configure means the system is Unix (compatible). +AC_DEFINE(UNIX) +AC_PROG_MAKE_SET + +dnl Checks for programs. +AC_PROG_CC dnl required by almost everything +AC_PROG_CPP dnl required by header file checks +AC_PROGRAM_EGREP dnl required by AC_EGREP_CPP +AC_PROG_FGREP dnl finds working grep -F +AC_ISC_POSIX dnl required by AC_C_CROSS +AC_PROG_AWK dnl required for "make html" in ../doc + +dnl Don't strip if we don't have it +AC_CHECK_PROG(STRIP, strip, strip, :) + +dnl Check for extension of executables +AC_EXEEXT + +dnl Check for standard headers. We don't use this in Vim but other stuff +dnl in autoconf needs it, where it uses STDC_HEADERS. +AC_HEADER_STDC +AC_HEADER_SYS_WAIT + +dnl Check for the flag that fails if stuff are missing. + +AC_MSG_CHECKING(--enable-fail-if-missing argument) +AC_ARG_ENABLE(fail_if_missing, + [ --enable-fail-if-missing Fail if dependencies on additional features + specified on the command line are missing.], + [fail_if_missing="yes"], + [fail_if_missing="no"]) +AC_MSG_RESULT($fail_if_missing) + +dnl Set default value for CFLAGS if none is defined or it's empty +if test -z "$CFLAGS"; then + CFLAGS="-O" + test "$GCC" = yes && CFLAGS="-O2 -fno-strength-reduce -Wall" +fi +if test "$GCC" = yes; then + dnl method that should work for nearly all versions + gccversion=`$CC -dumpversion` + if test "x$gccversion" = "x"; then + dnl old method; fall-back for when -dumpversion doesn't work + gccversion=`$CC --version | sed -e '2,$d' -e 's/darwin.//' -e 's/^[[^0-9]]*\([[0-9]]\.[[0-9.]]*\).*$/\1/g'` + fi + dnl version 4.0.1 was reported to cause trouble on Macintosh by Marcin Dalecki + if test "$gccversion" = "3.0.1" -o "$gccversion" = "3.0.2" -o "$gccversion" = "4.0.1"; then + echo 'GCC [[34]].0.[[12]] has a bug in the optimizer, disabling "-O#"' + CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-O/'` + else + if test "$gccversion" = "3.1" -o "$gccversion" = "3.2" -o "$gccversion" = "3.2.1" && `echo "$CFLAGS" | grep -v fno-strength-reduce >/dev/null`; then + echo 'GCC 3.1 and 3.2 have a bug in the optimizer, adding "-fno-strength-reduce"' + CFLAGS="$CFLAGS -fno-strength-reduce" + fi + fi +fi + +dnl clang-500.2.75 or around has abandoned -f[no-]strength-reduce and issues a +dnl warning when that flag is passed to. Accordingly, adjust CFLAGS based on +dnl the version number of the clang in use. +dnl Note that this does not work to get the version of clang 3.1 or 3.2. +AC_MSG_CHECKING(for recent clang version) +CLANG_VERSION_STRING=`$CC --version 2>/dev/null | sed -n -e 's/^.*clang.*\([[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\).*$/\1/p'` +if test x"$CLANG_VERSION_STRING" != x"" ; then + CLANG_MAJOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*/\1/p'` + CLANG_MINOR=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/p'` + CLANG_REVISION=`echo "$CLANG_VERSION_STRING" | sed -n -e 's/[[0-9]][[0-9]]*\.[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)/\1/p'` + CLANG_VERSION=`expr $CLANG_MAJOR '*' 1000000 '+' $CLANG_MINOR '*' 1000 '+' $CLANG_REVISION` + AC_MSG_RESULT($CLANG_VERSION) + dnl If you find the same issue with versions earlier than 500.2.75, + dnl change the constant 500002075 below appropriately. To get the + dnl integer corresponding to a version number, refer to the + dnl definition of CLANG_VERSION above. + if test "$CLANG_VERSION" -ge 500002075 ; then + CFLAGS=`echo "$CFLAGS" | sed -n -e 's/-fno-strength-reduce/ /p'` + fi +else + AC_MSG_RESULT(no) +fi + +dnl If configure thinks we are cross compiling, there might be something +dnl wrong with the CC or CFLAGS settings, give a useful warning message +CROSS_COMPILING= +if test "$cross_compiling" = yes; then + AC_MSG_RESULT([cannot compile a simple program; if not cross compiling check CC and CFLAGS]) + CROSS_COMPILING=1 +fi +AC_SUBST(CROSS_COMPILING) + +dnl gcc-cpp has the wonderful -MM option to produce nicer dependencies. +dnl But gcc 3.1 changed the meaning! See near the end. +test "$GCC" = yes && CPP_MM=M; AC_SUBST(CPP_MM) + +if test -f ./toolcheck; then + AC_CHECKING(for buggy tools) + sh ./toolcheck 1>&AC_FD_MSG +fi + +OS_EXTRA_SRC=""; OS_EXTRA_OBJ="" + +dnl Check for BeOS, which needs an extra source file +AC_MSG_CHECKING(for BeOS) +case `uname` in + BeOS) OS_EXTRA_SRC=os_beos.c; OS_EXTRA_OBJ=objects/os_beos.o + BEOS=yes; AC_MSG_RESULT(yes);; + *) BEOS=no; AC_MSG_RESULT(no);; +esac + +dnl If QNX is found, assume we don't want to use Xphoton +dnl unless it was specifically asked for (--with-x) +AC_MSG_CHECKING(for QNX) +case `uname` in + QNX) OS_EXTRA_SRC=os_qnx.c; OS_EXTRA_OBJ=objects/os_qnx.o + test -z "$with_x" && with_x=no + QNX=yes; AC_MSG_RESULT(yes);; + *) QNX=no; AC_MSG_RESULT(no);; +esac + +dnl Check for Darwin and MacOS X +dnl We do a check for MacOS X in the very beginning because there +dnl are a lot of other things we need to change besides GUI stuff +AC_MSG_CHECKING([for Darwin (Mac OS X)]) +if test "`(uname) 2>/dev/null`" = Darwin; then + AC_MSG_RESULT(yes) + + AC_MSG_CHECKING(--disable-darwin argument) + AC_ARG_ENABLE(darwin, + [ --disable-darwin Disable Darwin (Mac OS X) support.], + , [enable_darwin="yes"]) + if test "$enable_darwin" = "yes"; then + AC_MSG_RESULT(no) + AC_MSG_CHECKING(if Darwin files are there) + if test -f os_macosx.m; then + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT([no, Darwin support disabled]) + enable_darwin=no + fi + else + AC_MSG_RESULT([yes, Darwin support excluded]) + fi + + AC_MSG_CHECKING(--with-mac-arch argument) + AC_ARG_WITH(mac-arch, [ --with-mac-arch=ARCH current, intel, ppc or both], + MACARCH="$withval"; AC_MSG_RESULT($MACARCH), + MACARCH="current"; AC_MSG_RESULT(defaulting to $MACARCH)) + + AC_MSG_CHECKING(--with-developer-dir argument) + AC_ARG_WITH(developer-dir, [ --with-developer-dir=PATH use PATH as location for Xcode developer tools], + DEVELOPER_DIR="$withval"; AC_MSG_RESULT($DEVELOPER_DIR), + AC_MSG_RESULT(not present)) + + if test "x$DEVELOPER_DIR" = "x"; then + AC_PATH_PROG(XCODE_SELECT, xcode-select) + if test "x$XCODE_SELECT" != "x"; then + AC_MSG_CHECKING(for developer dir using xcode-select) + DEVELOPER_DIR=`$XCODE_SELECT -print-path` + AC_MSG_RESULT([$DEVELOPER_DIR]) + else + DEVELOPER_DIR=/Developer + fi + fi + + if test "x$MACARCH" = "xboth"; then + AC_MSG_CHECKING(for 10.4 universal SDK) + dnl There is a terrible inconsistency (but we appear to get away with it): + dnl $CFLAGS uses the 10.4u SDK library for the headers, while $CPPFLAGS + dnl doesn't, because "gcc -E" doesn't grok it. That means the configure + dnl tests using the preprocessor are actually done with the wrong header + dnl files. $LDFLAGS is set at the end, because configure uses it together + dnl with $CFLAGS and we can only have one -sysroot argument. + save_cppflags="$CPPFLAGS" + save_cflags="$CFLAGS" + save_ldflags="$LDFLAGS" + CFLAGS="$CFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc" + AC_TRY_LINK([ ], [ ], + AC_MSG_RESULT(found, will make universal binary), + + AC_MSG_RESULT(not found) + CFLAGS="$save_cflags" + AC_MSG_CHECKING(if Intel architecture is supported) + CPPFLAGS="$CPPFLAGS -arch i386" + LDFLAGS="$save_ldflags -arch i386" + AC_TRY_LINK([ ], [ ], + AC_MSG_RESULT(yes); MACARCH="intel", + AC_MSG_RESULT(no, using PowerPC) + MACARCH="ppc" + CPPFLAGS="$save_cppflags -arch ppc" + LDFLAGS="$save_ldflags -arch ppc")) + elif test "x$MACARCH" = "xintel"; then + CPPFLAGS="$CPPFLAGS -arch intel" + LDFLAGS="$LDFLAGS -arch intel" + elif test "x$MACARCH" = "xppc"; then + CPPFLAGS="$CPPFLAGS -arch ppc" + LDFLAGS="$LDFLAGS -arch ppc" + fi + + if test "$enable_darwin" = "yes"; then + MACOSX=yes + OS_EXTRA_SRC="os_macosx.m os_mac_conv.c"; + OS_EXTRA_OBJ="objects/os_macosx.o objects/os_mac_conv.o" + dnl TODO: use -arch i386 on Intel machines + dnl Removed -no-cpp-precomp, only for very old compilers. + CPPFLAGS="$CPPFLAGS -DMACOS_X_UNIX" + + dnl If Carbon is found, assume we don't want X11 + dnl unless it was specifically asked for (--with-x) + dnl or Motif, Athena or GTK GUI is used. + AC_CHECK_HEADER(Carbon/Carbon.h, CARBON=yes) + if test "x$CARBON" = "xyes"; then + if test -z "$with_x" -a "X$enable_gui" != Xmotif -a "X$enable_gui" != Xathena -a "X$enable_gui" != Xgtk2 -a "X$enable_gui" != Xgtk3; then + with_x=no + fi + fi + fi + + dnl Avoid a bug with -O2 with gcc 4.0.1. Symptom: malloc() reports double + dnl free. This happens in expand_filename(), because the optimizer swaps + dnl two blocks of code, both using "repl", that can't be swapped. + if test "$MACARCH" = "intel" -o "$MACARCH" = "both"; then + CFLAGS=`echo "$CFLAGS" | sed 's/-O[[23456789]]/-Oz/'` + fi + +else + AC_MSG_RESULT(no) +fi + +dnl Mac OS X 10.9+ no longer include AvailabilityMacros.h in Carbon +dnl so we need to include it to have access to version macros. +AC_CHECK_HEADERS(AvailabilityMacros.h) + +AC_SUBST(OS_EXTRA_SRC) +AC_SUBST(OS_EXTRA_OBJ) + +dnl Add /usr/local/lib to $LDFLAGS and /usr/local/include to CFLAGS. +dnl Only when the directory exists and it wasn't there yet. +dnl For gcc don't do this when it is already in the default search path. +dnl Skip all of this when cross-compiling. +if test "$cross_compiling" = no; then + AC_MSG_CHECKING(--with-local-dir argument) + have_local_include='' + have_local_lib='' + AC_ARG_WITH([local-dir], [ --with-local-dir=PATH search PATH instead of /usr/local for local libraries. + --without-local-dir do not search /usr/local for local libraries.], [ + local_dir="$withval" + case "$withval" in + */*) ;; + no) + # avoid adding local dir to LDFLAGS and CPPFLAGS + have_local_include=yes + have_local_lib=yes + ;; + *) AC_MSG_ERROR(must pass path argument to --with-local-dir) ;; + esac + AC_MSG_RESULT($local_dir) + ], [ + local_dir=/usr/local + AC_MSG_RESULT(Defaulting to $local_dir) + ]) + if test "$GCC" = yes -a "$local_dir" != no; then + echo 'void f(){}' > conftest.c + dnl Removed -no-cpp-precomp, only needed for OS X 10.2 (Ben Fowler) + have_local_include=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/include"` + have_local_lib=`${CC-cc} -c -v conftest.c 2>&1 | grep "${local_dir}/lib"` + rm -f conftest.c conftest.o + fi + if test -z "$have_local_lib" -a -d "${local_dir}/lib"; then + tt=`echo "$LDFLAGS" | sed -e "s+-L${local_dir}/lib ++g" -e "s+-L${local_dir}/lib$++g"` + if test "$tt" = "$LDFLAGS"; then + LDFLAGS="$LDFLAGS -L${local_dir}/lib" + fi + fi + if test -z "$have_local_include" -a -d "${local_dir}/include"; then + tt=`echo "$CPPFLAGS" | sed -e "s+-I${local_dir}/include ++g" -e "s+-I${local_dir}/include$++g"` + if test "$tt" = "$CPPFLAGS"; then + CPPFLAGS="$CPPFLAGS -I${local_dir}/include" + fi + fi +fi + +AC_MSG_CHECKING(--with-vim-name argument) +AC_ARG_WITH(vim-name, [ --with-vim-name=NAME what to call the Vim executable], + VIMNAME="$withval"; AC_MSG_RESULT($VIMNAME), + VIMNAME="vim"; AC_MSG_RESULT(Defaulting to $VIMNAME)) +AC_SUBST(VIMNAME) +AC_MSG_CHECKING(--with-ex-name argument) +AC_ARG_WITH(ex-name, [ --with-ex-name=NAME what to call the Ex executable], + EXNAME="$withval"; AC_MSG_RESULT($EXNAME), + EXNAME="ex"; AC_MSG_RESULT(Defaulting to ex)) +AC_SUBST(EXNAME) +AC_MSG_CHECKING(--with-view-name argument) +AC_ARG_WITH(view-name, [ --with-view-name=NAME what to call the View executable], + VIEWNAME="$withval"; AC_MSG_RESULT($VIEWNAME), + VIEWNAME="view"; AC_MSG_RESULT(Defaulting to view)) +AC_SUBST(VIEWNAME) + +AC_MSG_CHECKING(--with-global-runtime argument) +AC_ARG_WITH(global-runtime, [ --with-global-runtime=DIR global runtime directory in 'runtimepath'], + AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(RUNTIME_GLOBAL, "$withval"), + AC_MSG_RESULT(no)) + +AC_MSG_CHECKING(--with-modified-by argument) +AC_ARG_WITH(modified-by, [ --with-modified-by=NAME name of who modified a release version], + AC_MSG_RESULT($withval); AC_DEFINE_UNQUOTED(MODIFIED_BY, "$withval"), + AC_MSG_RESULT(no)) + +dnl Check for EBCDIC stolen from the LYNX port to z/OS Unix +AC_MSG_CHECKING(if character set is EBCDIC) +AC_TRY_COMPILE([ ], +[ /* TryCompile function for CharSet. + Treat any failure as ASCII for compatibility with existing art. + Use compile-time rather than run-time tests for cross-compiler + tolerance. */ +#if '0'!=240 +make an error "Character set is not EBCDIC" +#endif ], +[ # TryCompile action if true +cf_cv_ebcdic=yes ], +[ # TryCompile action if false +cf_cv_ebcdic=no]) +# end of TryCompile ]) +# end of CacheVal CvEbcdic +AC_MSG_RESULT($cf_cv_ebcdic) +case "$cf_cv_ebcdic" in #(vi + yes) AC_DEFINE(EBCDIC) + line_break='"\\n"' + ;; + *) line_break='"\\012"';; +esac +AC_SUBST(line_break) + +if test "$cf_cv_ebcdic" = "yes"; then +dnl If we have EBCDIC we most likely have z/OS Unix, let's test it! +AC_MSG_CHECKING(for z/OS Unix) +case `uname` in + OS/390) zOSUnix="yes"; + dnl If using cc the environment variable _CC_CCMODE must be + dnl set to "1", so that some compiler extensions are enabled. + dnl If using c89 the environment variable is named _CC_C89MODE. + dnl Note: compile with c89 never tested. + if test "$CC" = "cc"; then + ccm="$_CC_CCMODE" + ccn="CC" + else + if test "$CC" = "c89"; then + ccm="$_CC_C89MODE" + ccn="C89" + else + ccm=1 + fi + fi + if test "$ccm" != "1"; then + echo "" + echo "------------------------------------------" + echo " On z/OS Unix, the environment variable" + echo " _CC_${ccn}MODE must be set to \"1\"!" + echo " Do:" + echo " export _CC_${ccn}MODE=1" + echo " and then call configure again." + echo "------------------------------------------" + exit 1 + fi + # Set CFLAGS for configure process. + # This will be reset later for config.mk. + # Use haltonmsg to force error for missing H files. + CFLAGS="$CFLAGS -D_ALL_SOURCE -Wc,float(ieee),haltonmsg(3296)"; + LDFLAGS="$LDFLAGS -Wl,EDIT=NO" + AC_MSG_RESULT(yes) + ;; + *) zOSUnix="no"; + AC_MSG_RESULT(no) + ;; +esac +fi + +dnl Set QUOTESED. Needs additional backslashes on zOS +if test "$zOSUnix" = "yes"; then + QUOTESED="sed -e 's/[[\\\\\"]]/\\\\\\\\&/g' -e 's/\\\\\\\\\"/\"/' -e 's/\\\\\\\\\";\$\$/\";/'" +else + QUOTESED="sed -e 's/[[\\\\\"]]/\\\\&/g' -e 's/\\\\\"/\"/' -e 's/\\\\\";\$\$/\";/'" +fi +AC_SUBST(QUOTESED) + + +dnl Link with -lsmack for Smack stuff; if not found +AC_MSG_CHECKING(--disable-smack argument) +AC_ARG_ENABLE(smack, + [ --disable-smack Do not check for Smack support.], + , enable_smack="yes") +if test "$enable_smack" = "yes"; then + AC_MSG_RESULT(no) + AC_CHECK_HEADER([linux/xattr.h], true, enable_smack="no") +else + AC_MSG_RESULT(yes) +fi +if test "$enable_smack" = "yes"; then + AC_CHECK_HEADER([attr/xattr.h], true, enable_smack="no") +fi +if test "$enable_smack" = "yes"; then + AC_MSG_CHECKING(for XATTR_NAME_SMACKEXEC in linux/xattr.h) + AC_EGREP_CPP(XATTR_NAME_SMACKEXEC, [#include ], + AC_MSG_RESULT(yes), + AC_MSG_RESULT(no); enable_smack="no") +fi +if test "$enable_smack" = "yes"; then + AC_CHECK_LIB(attr, setxattr, + [LIBS="$LIBS -lattr" + found_smack="yes" + AC_DEFINE(HAVE_SMACK)]) +fi + +dnl When smack was found don't search for SELinux +if test "x$found_smack" = "x"; then + dnl Link with -lselinux for SELinux stuff; if not found + AC_MSG_CHECKING(--disable-selinux argument) + AC_ARG_ENABLE(selinux, + [ --disable-selinux Do not check for SELinux support.], + , enable_selinux="yes") + if test "$enable_selinux" = "yes"; then + AC_MSG_RESULT(no) + AC_CHECK_LIB(selinux, is_selinux_enabled, + [LIBS="$LIBS -lselinux" + AC_DEFINE(HAVE_SELINUX)]) + else + AC_MSG_RESULT(yes) + fi +fi + +dnl Check user requested features. + +AC_MSG_CHECKING(--with-features argument) +AC_ARG_WITH(features, [ --with-features=TYPE tiny, small, normal, big or huge (default: huge)], + features="$withval"; AC_MSG_RESULT($features), + features="huge"; AC_MSG_RESULT(Defaulting to huge)) + +dovimdiff="" +dogvimdiff="" +case "$features" in + tiny) AC_DEFINE(FEAT_TINY) ;; + small) AC_DEFINE(FEAT_SMALL) ;; + normal) AC_DEFINE(FEAT_NORMAL) dovimdiff="installvimdiff"; + dogvimdiff="installgvimdiff" ;; + big) AC_DEFINE(FEAT_BIG) dovimdiff="installvimdiff"; + dogvimdiff="installgvimdiff" ;; + huge) AC_DEFINE(FEAT_HUGE) dovimdiff="installvimdiff"; + dogvimdiff="installgvimdiff" ;; + *) AC_MSG_RESULT([Sorry, $features is not supported]) ;; +esac + +AC_SUBST(dovimdiff) +AC_SUBST(dogvimdiff) + +AC_MSG_CHECKING(--with-compiledby argument) +AC_ARG_WITH(compiledby, [ --with-compiledby=NAME name to show in :version message], + compiledby="$withval"; AC_MSG_RESULT($withval), + compiledby=""; AC_MSG_RESULT(no)) +AC_SUBST(compiledby) + +AC_MSG_CHECKING(--disable-xsmp argument) +AC_ARG_ENABLE(xsmp, + [ --disable-xsmp Disable XSMP session management], + , enable_xsmp="yes") + +if test "$enable_xsmp" = "yes"; then + AC_MSG_RESULT(no) + AC_MSG_CHECKING(--disable-xsmp-interact argument) + AC_ARG_ENABLE(xsmp-interact, + [ --disable-xsmp-interact Disable XSMP interaction], + , enable_xsmp_interact="yes") + if test "$enable_xsmp_interact" = "yes"; then + AC_MSG_RESULT(no) + AC_DEFINE(USE_XSMP_INTERACT) + else + AC_MSG_RESULT(yes) + fi +else + AC_MSG_RESULT(yes) +fi + +dnl Check for Lua feature. +AC_MSG_CHECKING(--enable-luainterp argument) +AC_ARG_ENABLE(luainterp, + [ --enable-luainterp[=OPTS] Include Lua interpreter. [default=no] [OPTS=no/yes/dynamic]], , + [enable_luainterp="no"]) +AC_MSG_RESULT($enable_luainterp) + +if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then + if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then + AC_MSG_ERROR([cannot use Lua with tiny or small features]) + fi + + dnl -- find the lua executable + AC_SUBST(vi_cv_path_lua) + + AC_MSG_CHECKING(--with-lua-prefix argument) + AC_ARG_WITH(lua_prefix, + [ --with-lua-prefix=PFX Prefix where Lua is installed.], + with_lua_prefix="$withval"; AC_MSG_RESULT($with_lua_prefix), + with_lua_prefix="";AC_MSG_RESULT(no)) + + if test "X$with_lua_prefix" != "X"; then + vi_cv_path_lua_pfx="$with_lua_prefix" + else + AC_MSG_CHECKING(LUA_PREFIX environment var) + if test "X$LUA_PREFIX" != "X"; then + AC_MSG_RESULT("$LUA_PREFIX") + vi_cv_path_lua_pfx="$LUA_PREFIX" + else + AC_MSG_RESULT([not set, default to /usr]) + vi_cv_path_lua_pfx="/usr" + fi + fi + + AC_MSG_CHECKING(--with-luajit) + AC_ARG_WITH(luajit, + [ --with-luajit Link with LuaJIT instead of Lua.], + [vi_cv_with_luajit="$withval"], + [vi_cv_with_luajit="no"]) + AC_MSG_RESULT($vi_cv_with_luajit) + + LUA_INC= + if test "X$vi_cv_path_lua_pfx" != "X"; then + if test "x$vi_cv_with_luajit" != "xno"; then + dnl -- try to find LuaJIT executable + AC_PATH_PROG(vi_cv_path_luajit, luajit) + if test "X$vi_cv_path_luajit" != "X"; then + dnl -- find LuaJIT version + AC_CACHE_CHECK(LuaJIT version, vi_cv_version_luajit, + [ vi_cv_version_luajit=`${vi_cv_path_luajit} -v 2>&1 | sed 's/LuaJIT \([[0-9.]]*\)\.[[0-9]]\(-[[a-z0-9]]*\)* .*/\1/'` ]) + AC_CACHE_CHECK(Lua version of LuaJIT, vi_cv_version_lua_luajit, + [ vi_cv_version_lua_luajit=`${vi_cv_path_luajit} -e "print(_VERSION)" | sed 's/.* //'` ]) + vi_cv_path_lua="$vi_cv_path_luajit" + vi_cv_version_lua="$vi_cv_version_lua_luajit" + fi + else + dnl -- try to find Lua executable + AC_PATH_PROG(vi_cv_path_plain_lua, lua) + if test "X$vi_cv_path_plain_lua" != "X"; then + dnl -- find Lua version + AC_CACHE_CHECK(Lua version, vi_cv_version_plain_lua, + [ vi_cv_version_plain_lua=`${vi_cv_path_plain_lua} -e "print(_VERSION)" | sed 's/.* //'` ]) + fi + vi_cv_path_lua="$vi_cv_path_plain_lua" + vi_cv_version_lua="$vi_cv_version_plain_lua" + fi + if test "x$vi_cv_with_luajit" != "xno" && test "X$vi_cv_version_luajit" != "X"; then + AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit) + if test -f "$vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit/lua.h"; then + AC_MSG_RESULT(yes) + LUA_INC=/luajit-$vi_cv_version_luajit + fi + fi + if test "X$LUA_INC" = "X"; then + AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include) + if test -f "$vi_cv_path_lua_pfx/include/lua.h"; then + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) + AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua) + if test -f "$vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h"; then + AC_MSG_RESULT(yes) + LUA_INC=/lua$vi_cv_version_lua + else + AC_MSG_RESULT(no) + vi_cv_path_lua_pfx= + fi + fi + fi + fi + + if test "X$vi_cv_path_lua_pfx" != "X"; then + if test "x$vi_cv_with_luajit" != "xno"; then + multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null` + if test "X$multiarch" != "X"; then + lib_multiarch="lib/${multiarch}" + else + lib_multiarch="lib" + fi + if test "X$vi_cv_version_lua" = "X"; then + LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit" + else + LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit-$vi_cv_version_lua" + fi + else + if test "X$LUA_INC" != "X"; then + dnl Test alternate location using version + LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua$vi_cv_version_lua" + else + LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua" + fi + fi + if test "$enable_luainterp" = "dynamic"; then + lua_ok="yes" + else + AC_MSG_CHECKING([if link with ${LUA_LIBS} is sane]) + libs_save=$LIBS + LIBS="$LIBS $LUA_LIBS" + AC_TRY_LINK(,[ ], + AC_MSG_RESULT(yes); lua_ok="yes", + AC_MSG_RESULT(no); lua_ok="no"; LUA_LIBS="") + LIBS=$libs_save + fi + if test "x$lua_ok" = "xyes"; then + LUA_CFLAGS="-I${vi_cv_path_lua_pfx}/include${LUA_INC}" + LUA_SRC="if_lua.c" + LUA_OBJ="objects/if_lua.o" + LUA_PRO="if_lua.pro" + AC_DEFINE(FEAT_LUA) + fi + if test "$enable_luainterp" = "dynamic"; then + if test "x$vi_cv_with_luajit" != "xno"; then + luajit="jit" + fi + if test -f "${vi_cv_path_lua_pfx}/bin/cyglua-${vi_cv_version_lua}.dll"; then + vi_cv_dll_name_lua="cyglua-${vi_cv_version_lua}.dll" + else + if test "x$MACOSX" = "xyes"; then + ext="dylib" + indexes="" + else + ext="so" + indexes=".0 .1 .2 .3 .4 .5 .6 .7 .8 .9" + multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null` + if test "X$multiarch" != "X"; then + lib_multiarch="lib/${multiarch}" + fi + fi + dnl Determine the sover for the current version, but fallback to + dnl liblua${vi_cv_version_lua}.so if no sover-versioned file is found. + AC_MSG_CHECKING(if liblua${luajit}*.${ext}* can be found in $vi_cv_path_lua_pfx) + for subdir in "${lib_multiarch}" lib64 lib; do + if test -z "$subdir"; then + continue + fi + for sover in "${vi_cv_version_lua}.${ext}" "-${vi_cv_version_lua}.${ext}" \ + ".${vi_cv_version_lua}.${ext}" ".${ext}.${vi_cv_version_lua}"; do + for i in $indexes ""; do + if test -f "${vi_cv_path_lua_pfx}/${subdir}/liblua${luajit}${sover}$i"; then + sover2="$i" + break 3 + fi + done + done + sover="" + done + if test "X$sover" = "X"; then + AC_MSG_RESULT(no) + lua_ok="no" + vi_cv_dll_name_lua="liblua${luajit}.${ext}" + else + AC_MSG_RESULT(yes) + lua_ok="yes" + vi_cv_dll_name_lua="liblua${luajit}${sover}$sover2" + fi + fi + AC_DEFINE(DYNAMIC_LUA) + LUA_LIBS="" + LUA_CFLAGS="-DDYNAMIC_LUA_DLL=\\\"${vi_cv_dll_name_lua}\\\" $LUA_CFLAGS" + fi + if test "X$LUA_CFLAGS$LUA_LIBS" != "X" && \ + test "x$MACOSX" = "xyes" && test "x$vi_cv_with_luajit" != "xno" && \ + test "`(uname -m) 2>/dev/null`" = "x86_64"; then + dnl OSX/x64 requires these flags. See http://luajit.org/install.html + LUA_LIBS="-pagezero_size 10000 -image_base 100000000 $LUA_LIBS" + fi + fi + if test "$fail_if_missing" = "yes" -a "$lua_ok" != "yes"; then + AC_MSG_ERROR([could not configure lua]) + fi + AC_SUBST(LUA_SRC) + AC_SUBST(LUA_OBJ) + AC_SUBST(LUA_PRO) + AC_SUBST(LUA_LIBS) + AC_SUBST(LUA_CFLAGS) +fi + + +dnl Check for MzScheme feature. +AC_MSG_CHECKING(--enable-mzschemeinterp argument) +AC_ARG_ENABLE(mzschemeinterp, + [ --enable-mzschemeinterp Include MzScheme interpreter.], , + [enable_mzschemeinterp="no"]) +AC_MSG_RESULT($enable_mzschemeinterp) + +if test "$enable_mzschemeinterp" = "yes"; then + dnl -- find the mzscheme executable + AC_SUBST(vi_cv_path_mzscheme) + + AC_MSG_CHECKING(--with-plthome argument) + AC_ARG_WITH(plthome, + [ --with-plthome=PLTHOME Use PLTHOME.], + with_plthome="$withval"; AC_MSG_RESULT($with_plthome), + with_plthome="";AC_MSG_RESULT("no")) + + if test "X$with_plthome" != "X"; then + vi_cv_path_mzscheme_pfx="$with_plthome" + vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme" + else + AC_MSG_CHECKING(PLTHOME environment var) + if test "X$PLTHOME" != "X"; then + AC_MSG_RESULT("$PLTHOME") + vi_cv_path_mzscheme_pfx="$PLTHOME" + vi_cv_path_mzscheme="${vi_cv_path_mzscheme_pfx}/bin/mzscheme" + else + AC_MSG_RESULT(not set) + dnl -- try to find MzScheme executable + AC_PATH_PROG(vi_cv_path_mzscheme, mzscheme) + + dnl resolve symbolic link, the executable is often elsewhere and there + dnl are no links for the include files. + if test "X$vi_cv_path_mzscheme" != "X"; then + lsout=`ls -l $vi_cv_path_mzscheme` + if echo "$lsout" | grep -e '->' >/dev/null 2>/dev/null; then + vi_cv_path_mzscheme=`echo "$lsout" | sed 's/.*-> \(.*\)/\1/'` + fi + fi + + if test "X$vi_cv_path_mzscheme" != "X"; then + dnl -- find where MzScheme thinks it was installed + AC_CACHE_CHECK(MzScheme install prefix,vi_cv_path_mzscheme_pfx, + dnl different versions of MzScheme differ in command line processing + dnl use universal approach + echo "(display (simplify-path \ + (build-path (call-with-values \ + (lambda () (split-path (find-system-path (quote exec-file)))) \ + (lambda (base name must-be-dir?) base)) (quote up))))" > mzdirs.scm + dnl Remove a trailing slash + [ vi_cv_path_mzscheme_pfx=`${vi_cv_path_mzscheme} -r mzdirs.scm | \ + sed -e 's+/$++'` ]) + rm -f mzdirs.scm + fi + fi + fi + + if test "X$vi_cv_path_mzscheme_pfx" != "X"; then + AC_MSG_CHECKING(for racket include directory) + SCHEME_INC=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-include-dir))) (when (path? p) (display p)))'` + if test "X$SCHEME_INC" != "X"; then + AC_MSG_RESULT(${SCHEME_INC}) + else + AC_MSG_RESULT(not found) + AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include) + if test -f "$vi_cv_path_mzscheme_pfx/include/scheme.h"; then + SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) + AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt) + if test -f "$vi_cv_path_mzscheme_pfx/include/plt/scheme.h"; then + AC_MSG_RESULT(yes) + SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt + else + AC_MSG_RESULT(no) + AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket) + if test -f "$vi_cv_path_mzscheme_pfx/include/racket/scheme.h"; then + AC_MSG_RESULT(yes) + SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket + else + AC_MSG_RESULT(no) + AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/) + if test -f /usr/include/plt/scheme.h; then + AC_MSG_RESULT(yes) + SCHEME_INC=/usr/include/plt + else + AC_MSG_RESULT(no) + AC_MSG_CHECKING(if scheme.h can be found in /usr/include/racket/) + if test -f /usr/include/racket/scheme.h; then + AC_MSG_RESULT(yes) + SCHEME_INC=/usr/include/racket + else + AC_MSG_RESULT(no) + vi_cv_path_mzscheme_pfx= + fi + fi + fi + fi + fi + fi + fi + + if test "X$vi_cv_path_mzscheme_pfx" != "X"; then + + AC_MSG_CHECKING(for racket lib directory) + SCHEME_LIB=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-lib-dir))) (when (path? p) (display p)))'` + if test "X$SCHEME_LIB" != "X"; then + AC_MSG_RESULT(${SCHEME_LIB}) + else + AC_MSG_RESULT(not found) + fi + + for path in "${vi_cv_path_mzscheme_pfx}/lib" "${SCHEME_LIB}"; do + if test "X$path" != "X"; then + if test "x$MACOSX" = "xyes"; then + MZSCHEME_LIBS="-framework Racket" + MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" + elif test -f "${path}/libmzscheme3m.a"; then + MZSCHEME_LIBS="${path}/libmzscheme3m.a" + MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" + elif test -f "${path}/libracket3m.a"; then + MZSCHEME_LIBS="${path}/libracket3m.a" + MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" + elif test -f "${path}/libracket.a"; then + MZSCHEME_LIBS="${path}/libracket.a ${path}/libmzgc.a" + elif test -f "${path}/libmzscheme.a"; then + MZSCHEME_LIBS="${path}/libmzscheme.a ${path}/libmzgc.a" + else + dnl Using shared objects + if test -f "${path}/libmzscheme3m.so"; then + MZSCHEME_LIBS="-L${path} -lmzscheme3m" + MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" + elif test -f "${path}/libracket3m.so"; then + MZSCHEME_LIBS="-L${path} -lracket3m" + MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" + elif test -f "${path}/libracket.so"; then + MZSCHEME_LIBS="-L${path} -lracket -lmzgc" + else + dnl try next until last + if test "$path" != "$SCHEME_LIB"; then + continue + fi + MZSCHEME_LIBS="-L${path} -lmzscheme -lmzgc" + fi + if test "$GCC" = yes; then + dnl Make Vim remember the path to the library. For when it's not in + dnl $LD_LIBRARY_PATH. + MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${path}" + elif test "`(uname) 2>/dev/null`" = SunOS && + uname -r | grep '^5' >/dev/null; then + MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${path}" + fi + fi + fi + if test "X$MZSCHEME_LIBS" != "X"; then + break + fi + done + + AC_MSG_CHECKING([if racket requires -pthread]) + if test "X$SCHEME_LIB" != "X" && $FGREP -e -pthread "$SCHEME_LIB/buildinfo" >/dev/null ; then + AC_MSG_RESULT(yes) + MZSCHEME_LIBS="${MZSCHEME_LIBS} -pthread" + MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -pthread" + else + AC_MSG_RESULT(no) + fi + + AC_MSG_CHECKING(for racket config directory) + SCHEME_CONFIGDIR=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-config-dir))) (when (path? p) (display p)))'` + if test "X$SCHEME_CONFIGDIR" != "X"; then + MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DMZSCHEME_CONFIGDIR='\"${SCHEME_CONFIGDIR}\"'" + AC_MSG_RESULT(${SCHEME_CONFIGDIR}) + else + AC_MSG_RESULT(not found) + fi + + AC_MSG_CHECKING(for racket collects directory) + SCHEME_COLLECTS=`${vi_cv_path_mzscheme} -e '(require setup/dirs)(let ((p (find-collects-dir))) (when (path? p) (let-values (((base _1 _2) (split-path p))) (display base))))'` + if test "X$SCHEME_COLLECTS" = "X"; then + if test -d "$vi_cv_path_mzscheme_pfx/lib/plt/collects"; then + SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/plt/ + else + if test -d "$vi_cv_path_mzscheme_pfx/lib/racket/collects"; then + SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/racket/ + else + if test -d "$vi_cv_path_mzscheme_pfx/share/racket/collects"; then + SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/ + else + if test -d "$vi_cv_path_mzscheme_pfx/collects"; then + SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/ + fi + fi + fi + fi + fi + if test "X$SCHEME_COLLECTS" != "X" ; then + AC_MSG_RESULT(${SCHEME_COLLECTS}) + else + AC_MSG_RESULT(not found) + fi + + AC_MSG_CHECKING(for mzscheme_base.c) + if test -f "${SCHEME_COLLECTS}collects/scheme/base.ss" ; then + MZSCHEME_EXTRA="mzscheme_base.c" + MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc" + MZSCHEME_MOD="++lib scheme/base" + else + if test -f "${SCHEME_COLLECTS}collects/scheme/base.rkt" ; then + MZSCHEME_EXTRA="mzscheme_base.c" + MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc" + MZSCHEME_MOD="++lib scheme/base" + else + if test -f "${SCHEME_COLLECTS}collects/racket/base.rkt" ; then + MZSCHEME_EXTRA="mzscheme_base.c" + MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/raco ctool" + MZSCHEME_MOD="" + fi + fi + fi + if test "X$MZSCHEME_EXTRA" != "X" ; then + dnl need to generate bytecode for MzScheme base + MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE" + AC_MSG_RESULT(needed) + else + AC_MSG_RESULT(not needed) + fi + + dnl On Ubuntu this fixes "undefined reference to symbol 'ffi_type_void'". + AC_CHECK_LIB(ffi, ffi_type_void, [MZSCHEME_LIBS="$MZSCHEME_LIBS -lffi"]) + + MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -I${SCHEME_INC} \ + -DMZSCHEME_COLLECTS='\"${SCHEME_COLLECTS}collects\"'" + + dnl Test that we can compile a simple program with these CFLAGS and LIBS. + AC_MSG_CHECKING([if compile and link flags for MzScheme are sane]) + cflags_save=$CFLAGS + libs_save=$LIBS + CFLAGS="$CFLAGS $MZSCHEME_CFLAGS" + LIBS="$LIBS $MZSCHEME_LIBS" + AC_TRY_LINK(,[ ], + AC_MSG_RESULT(yes); mzs_ok=yes, + AC_MSG_RESULT(no: MZSCHEME DISABLED); mzs_ok=no) + CFLAGS=$cflags_save + LIBS=$libs_save + if test $mzs_ok = yes; then + MZSCHEME_SRC="if_mzsch.c" + MZSCHEME_OBJ="objects/if_mzsch.o" + MZSCHEME_PRO="if_mzsch.pro" + AC_DEFINE(FEAT_MZSCHEME) + else + MZSCHEME_CFLAGS= + MZSCHEME_LIBS= + MZSCHEME_EXTRA= + MZSCHEME_MZC= + fi + fi + AC_SUBST(MZSCHEME_SRC) + AC_SUBST(MZSCHEME_OBJ) + AC_SUBST(MZSCHEME_PRO) + AC_SUBST(MZSCHEME_LIBS) + AC_SUBST(MZSCHEME_CFLAGS) + AC_SUBST(MZSCHEME_EXTRA) + AC_SUBST(MZSCHEME_MZC) +fi + + +AC_MSG_CHECKING(--enable-perlinterp argument) +AC_ARG_ENABLE(perlinterp, + [ --enable-perlinterp[=OPTS] Include Perl interpreter. [default=no] [OPTS=no/yes/dynamic]], , + [enable_perlinterp="no"]) +AC_MSG_RESULT($enable_perlinterp) +if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then + if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then + AC_MSG_ERROR([cannot use Perl with tiny or small features]) + fi + AC_SUBST(vi_cv_path_perl) + AC_PATH_PROG(vi_cv_path_perl, perl) + if test "X$vi_cv_path_perl" != "X"; then + AC_MSG_CHECKING(Perl version) + if $vi_cv_path_perl -e 'require 5.003_01' >/dev/null 2>/dev/null; then + eval `$vi_cv_path_perl -V:usethreads` + eval `$vi_cv_path_perl -V:libperl` + if test "X$usethreads" = "XUNKNOWN" -o "X$usethreads" = "Xundef"; then + badthreads=no + else + if $vi_cv_path_perl -e 'require 5.6.0' >/dev/null 2>/dev/null; then + eval `$vi_cv_path_perl -V:use5005threads` + if test "X$use5005threads" = "XUNKNOWN" -o "X$use5005threads" = "Xundef"; then + badthreads=no + else + badthreads=yes + AC_MSG_RESULT(>>> Perl > 5.6 with 5.5 threads cannot be used <<<) + fi + else + badthreads=yes + AC_MSG_RESULT(>>> Perl 5.5 with threads cannot be used <<<) + fi + fi + if test $badthreads = no; then + AC_MSG_RESULT(OK) + eval `$vi_cv_path_perl -V:shrpenv` + if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04 + shrpenv="" + fi + vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlibexp}'` + AC_SUBST(vi_cv_perllib) + vi_cv_perl_extutils=unknown_perl_extutils_path + for extutils_rel_path in ExtUtils vendor_perl/ExtUtils; do + xsubpp_path="$vi_cv_perllib/$extutils_rel_path/xsubpp" + if test -f "$xsubpp_path"; then + vi_cv_perl_xsubpp="$xsubpp_path" + fi + done + AC_SUBST(vi_cv_perl_xsubpp) + dnl Remove "-fno-something", it breaks using cproto. + dnl Remove "-fdebug-prefix-map", it isn't supported by clang. + perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \ + -e 'ccflags;perl_inc;print"\n"' | sed -e 's/-fno[[^ ]]*//' \ + -e 's/-fdebug-prefix-map[[^ ]]*//g'` + dnl Remove "-lc", it breaks on FreeBSD when using "-pthread". + perllibs=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed -e 'ldopts' | \ + sed -e '/Warning/d' -e '/Note (probably harmless)/d' \ + -e 's/-bE:perl.exp//' -e 's/-lc //'` + dnl Don't add perl lib to $LIBS: if it's not in LD_LIBRARY_PATH + dnl a test in configure may fail because of that. + perlldflags=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed \ + -e 'ccdlflags' | sed -e 's/-bE:perl.exp//'` + + dnl check that compiling a simple program still works with the flags + dnl added for Perl. + AC_MSG_CHECKING([if compile and link flags for Perl are sane]) + cflags_save=$CFLAGS + libs_save=$LIBS + ldflags_save=$LDFLAGS + CFLAGS="$CFLAGS $perlcppflags" + LIBS="$LIBS $perllibs" + perlldflags=`echo "$perlldflags" | sed -e 's/^ *//g'` + LDFLAGS="$perlldflags $LDFLAGS" + AC_TRY_LINK(,[ ], + AC_MSG_RESULT(yes); perl_ok=yes, + AC_MSG_RESULT(no: PERL DISABLED); perl_ok=no) + CFLAGS=$cflags_save + LIBS=$libs_save + LDFLAGS=$ldflags_save + if test $perl_ok = yes; then + if test "X$perlcppflags" != "X"; then + dnl remove -pipe and -Wxxx, it confuses cproto + PERL_CFLAGS=`echo "$perlcppflags" | sed -e 's/-pipe //' -e 's/-W[[^ ]]*//'` + fi + if test "X$perlldflags" != "X"; then + if test "X`echo \"$LDFLAGS\" | $FGREP -e \"$perlldflags\"`" = "X"; then + LDFLAGS="$perlldflags $LDFLAGS" + fi + fi + PERL_LIBS=$perllibs + PERL_SRC="auto/if_perl.c if_perlsfio.c" + PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o" + PERL_PRO="if_perl.pro if_perlsfio.pro" + AC_DEFINE(FEAT_PERL) + fi + fi + else + AC_MSG_RESULT(>>> too old; need Perl version 5.003_01 or later <<<) + fi + fi + + if test "x$MACOSX" = "xyes"; then + dnl Mac OS X 10.2 or later + dir=/System/Library/Perl + darwindir=$dir/darwin + if test -d $darwindir; then + PERL=/usr/bin/perl + else + dnl Mac OS X 10.3 + dir=/System/Library/Perl/5.8.1 + darwindir=$dir/darwin-thread-multi-2level + if test -d $darwindir; then + PERL=/usr/bin/perl + fi + fi + if test -n "$PERL"; then + PERL_DIR="$dir" + PERL_CFLAGS="-DFEAT_PERL -I$darwindir/CORE" + PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o $darwindir/auto/DynaLoader/DynaLoader.a" + PERL_LIBS="-L$darwindir/CORE -lperl" + fi + dnl Perl on Mac OS X 10.5 adds "-arch" flags but these should only + dnl be included if requested by passing --with-mac-arch to + dnl configure, so strip these flags first (if present) + PERL_LIBS=`echo "$PERL_LIBS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'` + PERL_CFLAGS=`echo "$PERL_CFLAGS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'` + fi + if test "$enable_perlinterp" = "dynamic"; then + if test "$perl_ok" = "yes" -a "X$libperl" != "X"; then + AC_DEFINE(DYNAMIC_PERL) + PERL_CFLAGS="-DDYNAMIC_PERL_DLL=\\\"$libperl\\\" $PERL_CFLAGS" + fi + fi + + if test "$fail_if_missing" = "yes" -a "$perl_ok" != "yes"; then + AC_MSG_ERROR([could not configure perl]) + fi +fi +AC_SUBST(shrpenv) +AC_SUBST(PERL_SRC) +AC_SUBST(PERL_OBJ) +AC_SUBST(PERL_PRO) +AC_SUBST(PERL_CFLAGS) +AC_SUBST(PERL_LIBS) + +AC_MSG_CHECKING(--enable-pythoninterp argument) +AC_ARG_ENABLE(pythoninterp, + [ --enable-pythoninterp[=OPTS] Include Python interpreter. [default=no] [OPTS=no/yes/dynamic]], , + [enable_pythoninterp="no"]) +AC_MSG_RESULT($enable_pythoninterp) +if test "$enable_pythoninterp" = "yes" -o "$enable_pythoninterp" = "dynamic"; then + if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then + AC_MSG_ERROR([cannot use Python with tiny or small features]) + fi + + dnl -- find the python executable + AC_PATH_PROGS(vi_cv_path_python, python2 python) + if test "X$vi_cv_path_python" != "X"; then + + dnl -- get its version number + AC_CACHE_CHECK(Python version,vi_cv_var_python_version, + [[vi_cv_var_python_version=` + ${vi_cv_path_python} -c 'import sys; print sys.version[:3]'` + ]]) + + dnl -- it must be at least version 2.3 + AC_MSG_CHECKING(Python is 2.3 or better) + if ${vi_cv_path_python} -c \ + "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)" + then + AC_MSG_RESULT(yep) + + dnl -- find where python thinks it was installed + AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python_pfx, + [ vi_cv_path_python_pfx=` + ${vi_cv_path_python} -c \ + "import sys; print sys.prefix"` ]) + + dnl -- and where it thinks it runs + AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python_epfx, + [ vi_cv_path_python_epfx=` + ${vi_cv_path_python} -c \ + "import sys; print sys.exec_prefix"` ]) + + dnl -- python's internal library path + + AC_CACHE_VAL(vi_cv_path_pythonpath, + [ vi_cv_path_pythonpath=` + unset PYTHONPATH; + ${vi_cv_path_python} -c \ + "import sys, string; print string.join(sys.path,':')"` ]) + + dnl -- where the Python implementation library archives are + + AC_ARG_WITH(python-config-dir, + [ --with-python-config-dir=PATH Python's config directory], + [ vi_cv_path_python_conf="${withval}" ] ) + + AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python_conf, + [ + vi_cv_path_python_conf= + d=`${vi_cv_path_python} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBPL')"` + if test -d "$d" && test -f "$d/config.c"; then + vi_cv_path_python_conf="$d" + else + for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do + for subdir in lib64 lib share; do + d="${path}/${subdir}/python${vi_cv_var_python_version}/config" + if test -d "$d" && test -f "$d/config.c"; then + vi_cv_path_python_conf="$d" + fi + done + done + fi + ]) + + PYTHON_CONFDIR="${vi_cv_path_python_conf}" + + if test "X$PYTHON_CONFDIR" = "X"; then + AC_MSG_RESULT([can't find it!]) + else + + dnl -- we need to examine Python's config/Makefile too + dnl see what the interpreter is built from + AC_CACHE_VAL(vi_cv_path_python_plibs, + [ + pwd=`pwd` + tmp_mkf="$pwd/config-PyMake$$" + cat -- "${PYTHON_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}" +__: + @echo "python_BASEMODLIBS='$(BASEMODLIBS)'" + @echo "python_LIBS='$(LIBS)'" + @echo "python_SYSLIBS='$(SYSLIBS)'" + @echo "python_LINKFORSHARED='$(LINKFORSHARED)'" + @echo "python_DLLLIBRARY='$(DLLLIBRARY)'" + @echo "python_INSTSONAME='$(INSTSONAME)'" + @echo "python_PYTHONFRAMEWORK='$(PYTHONFRAMEWORK)'" + @echo "python_PYTHONFRAMEWORKPREFIX='$(PYTHONFRAMEWORKPREFIX)'" + @echo "python_PYTHONFRAMEWORKINSTALLDIR='$(PYTHONFRAMEWORKINSTALLDIR)'" +eof + dnl -- delete the lines from make about Entering/Leaving directory + eval "`cd ${PYTHON_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`" + rm -f -- "${tmp_mkf}" + if test "x$MACOSX" = "xyes" && test -n "${python_PYTHONFRAMEWORK}" && ${vi_cv_path_python} -c \ + "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then + vi_cv_path_python_plibs="-framework Python" + if test "x${vi_cv_path_python}" != "x/usr/bin/python" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then + vi_cv_path_python_plibs="-F${python_PYTHONFRAMEWORKPREFIX} -framework Python" + fi + else + if test "${vi_cv_var_python_version}" = "1.4"; then + vi_cv_path_python_plibs="${PYTHON_CONFDIR}/libModules.a ${PYTHON_CONFDIR}/libPython.a ${PYTHON_CONFDIR}/libObjects.a ${PYTHON_CONFDIR}/libParser.a" + else + vi_cv_path_python_plibs="-L${PYTHON_CONFDIR} -lpython${vi_cv_var_python_version}" + fi + dnl -- Check if the path contained in python_LINKFORSHARED is + dnl usable for vim build. If not, make and try other + dnl candidates. + if test -n "${python_LINKFORSHARED}" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then + python_link_symbol=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]].*/\1/'` + python_link_path=`echo ${python_LINKFORSHARED} | sed 's/\([[^ \t]][[^ \t]]*[[ \t]][[ \t]]*[[^ \t]][[^ \t]]*\)[[ \t]][[ \t]]*\(.*\)/\2/'` + if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then + dnl -- The path looks relative. Guess the absolute one using + dnl the prefix and try that. + python_link_path="${python_PYTHONFRAMEWORKPREFIX}/${python_link_path}" + if test -n "${python_link_path}" && ! test -x "${python_link_path}"; then + dnl -- A last resort. + python_link_path="${python_PYTHONFRAMEWORKINSTALLDIR}/Versions/${vi_cv_var_python_version}/${python_PYTHONFRAMEWORK}" + dnl -- No check is done. The last word is left to the + dnl "sanity" test on link flags that follows shortly. + fi + python_LINKFORSHARED="${python_link_symbol} ${python_link_path}" + fi + fi + vi_cv_path_python_plibs="${vi_cv_path_python_plibs} ${python_BASEMODLIBS} ${python_LIBS} ${python_SYSLIBS} ${python_LINKFORSHARED}" + dnl remove -ltermcap, it can conflict with an earlier -lncurses + vi_cv_path_python_plibs=`echo $vi_cv_path_python_plibs | sed s/-ltermcap//` + fi + ]) + AC_CACHE_CHECK(Python's dll name,vi_cv_dll_name_python, + [ + if test "X$python_DLLLIBRARY" != "X"; then + vi_cv_dll_name_python="$python_DLLLIBRARY" + else + vi_cv_dll_name_python="$python_INSTSONAME" + fi + ]) + + PYTHON_LIBS="${vi_cv_path_python_plibs}" + if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then + PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'" + else + 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}\"'" + fi + PYTHON_SRC="if_python.c" + PYTHON_OBJ="objects/if_python.o" + if test "${vi_cv_var_python_version}" = "1.4"; then + PYTHON_OBJ="$PYTHON_OBJ objects/py_getpath.o" + fi + PYTHON_GETPATH_CFLAGS="-DPYTHONPATH='\"${vi_cv_path_pythonpath}\"' -DPREFIX='\"${vi_cv_path_python_pfx}\"' -DEXEC_PREFIX='\"${vi_cv_path_python_epfx}\"'" + + dnl On FreeBSD linking with "-pthread" is required to use threads. + dnl _THREAD_SAFE must be used for compiling then. + dnl The "-pthread" is added to $LIBS, so that the following check for + dnl sigaltstack() will look in libc_r (it's there in libc!). + dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC + dnl will then define target-specific defines, e.g., -D_REENTRANT. + dnl Don't do this for Mac OSX, -pthread will generate a warning. + AC_MSG_CHECKING([if -pthread should be used]) + threadsafe_flag= + thread_lib= + dnl if test "x$MACOSX" != "xyes"; then + if test "`(uname) 2>/dev/null`" != Darwin; then + test "$GCC" = yes && threadsafe_flag="-pthread" + if test "`(uname) 2>/dev/null`" = FreeBSD; then + threadsafe_flag="-D_THREAD_SAFE" + thread_lib="-pthread" + fi + if test "`(uname) 2>/dev/null`" = SunOS; then + threadsafe_flag="-pthreads" + fi + fi + libs_save_old=$LIBS + if test -n "$threadsafe_flag"; then + cflags_save=$CFLAGS + CFLAGS="$CFLAGS $threadsafe_flag" + LIBS="$LIBS $thread_lib" + AC_TRY_LINK(,[ ], + AC_MSG_RESULT(yes); PYTHON_CFLAGS="$PYTHON_CFLAGS $threadsafe_flag", + AC_MSG_RESULT(no); LIBS=$libs_save_old + ) + CFLAGS=$cflags_save + else + AC_MSG_RESULT(no) + fi + + dnl Check that compiling a simple program still works with the flags + dnl added for Python. + AC_MSG_CHECKING([if compile and link flags for Python are sane]) + cflags_save=$CFLAGS + libs_save=$LIBS + CFLAGS="$CFLAGS $PYTHON_CFLAGS" + LIBS="$LIBS $PYTHON_LIBS" + AC_TRY_LINK(,[ ], + AC_MSG_RESULT(yes); python_ok=yes, + AC_MSG_RESULT(no: PYTHON DISABLED); python_ok=no) + CFLAGS=$cflags_save + LIBS=$libs_save + if test $python_ok = yes; then + AC_DEFINE(FEAT_PYTHON) + else + LIBS=$libs_save_old + PYTHON_SRC= + PYTHON_OBJ= + PYTHON_LIBS= + PYTHON_CFLAGS= + fi + fi + else + AC_MSG_RESULT(too old) + fi + fi + + if test "$fail_if_missing" = "yes" -a "$python_ok" != "yes"; then + AC_MSG_ERROR([could not configure python]) + fi +fi + +AC_SUBST(PYTHON_CONFDIR) +AC_SUBST(PYTHON_LIBS) +AC_SUBST(PYTHON_GETPATH_CFLAGS) +AC_SUBST(PYTHON_CFLAGS) +AC_SUBST(PYTHON_SRC) +AC_SUBST(PYTHON_OBJ) + + +AC_MSG_CHECKING(--enable-python3interp argument) +AC_ARG_ENABLE(python3interp, + [ --enable-python3interp[=OPTS] Include Python3 interpreter. [default=no] [OPTS=no/yes/dynamic]], , + [enable_python3interp="no"]) +AC_MSG_RESULT($enable_python3interp) +if test "$enable_python3interp" = "yes" -o "$enable_python3interp" = "dynamic"; then + if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then + AC_MSG_ERROR([cannot use Python with tiny or small features]) + fi + + dnl -- find the python3 executable + AC_PATH_PROGS(vi_cv_path_python3, python3 python) + if test "X$vi_cv_path_python3" != "X"; then + + dnl -- get its version number + AC_CACHE_CHECK(Python version,vi_cv_var_python3_version, + [[vi_cv_var_python3_version=` + ${vi_cv_path_python3} -c 'import sys; print(sys.version[:3])'` + ]]) + + dnl -- it must be at least version 3 + AC_MSG_CHECKING(Python is 3.0 or better) + if ${vi_cv_path_python3} -c \ + "import sys; sys.exit(${vi_cv_var_python3_version} < 3.0)" + then + AC_MSG_RESULT(yep) + + dnl -- get abiflags for python 3.2 or higher (PEP 3149) + AC_CACHE_CHECK(Python's abiflags,vi_cv_var_python3_abiflags, + [ + vi_cv_var_python3_abiflags= + if ${vi_cv_path_python3} -c \ + "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)" + then + vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \ + "import sys; print(sys.abiflags)"` + fi ]) + + dnl -- find where python3 thinks it was installed + AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx, + [ vi_cv_path_python3_pfx=` + ${vi_cv_path_python3} -c \ + "import sys; print(sys.prefix)"` ]) + + dnl -- and where it thinks it runs + AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx, + [ vi_cv_path_python3_epfx=` + ${vi_cv_path_python3} -c \ + "import sys; print(sys.exec_prefix)"` ]) + + dnl -- python3's internal library path + + AC_CACHE_VAL(vi_cv_path_python3path, + [ vi_cv_path_python3path=` + unset PYTHONPATH; + ${vi_cv_path_python3} -c \ + "import sys, string; print(':'.join(sys.path))"` ]) + + dnl -- where the Python implementation library archives are + + AC_ARG_WITH(python3-config-dir, + [ --with-python3-config-dir=PATH Python's config directory], + [ vi_cv_path_python3_conf="${withval}" ] ) + + AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf, + [ + vi_cv_path_python3_conf= + config_dir="config-${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}" + d=`${vi_cv_path_python3} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBPL'))"` + if test -d "$d" && test -f "$d/config.c"; then + vi_cv_path_python3_conf="$d" + else + for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do + for subdir in lib64 lib share; do + d="${path}/${subdir}/python${vi_cv_var_python3_version}/${config_dir}" + if test -d "$d" && test -f "$d/config.c"; then + vi_cv_path_python3_conf="$d" + fi + done + done + fi + ]) + + PYTHON3_CONFDIR="${vi_cv_path_python3_conf}" + + if test "X$PYTHON3_CONFDIR" = "X"; then + AC_MSG_RESULT([can't find it!]) + else + + dnl -- we need to examine Python's config/Makefile too + dnl see what the interpreter is built from + AC_CACHE_VAL(vi_cv_path_python3_plibs, + [ + pwd=`pwd` + tmp_mkf="$pwd/config-PyMake$$" + cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}" +__: + @echo "python3_BASEMODLIBS='$(BASEMODLIBS)'" + @echo "python3_LIBS='$(LIBS)'" + @echo "python3_SYSLIBS='$(SYSLIBS)'" + @echo "python3_DLLLIBRARY='$(DLLLIBRARY)'" + @echo "python3_INSTSONAME='$(INSTSONAME)'" +eof + dnl -- delete the lines from make about Entering/Leaving directory + eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`" + rm -f -- "${tmp_mkf}" + vi_cv_path_python3_plibs="-L${PYTHON3_CONFDIR} -lpython${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags}" + vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_BASEMODLIBS} ${python3_LIBS} ${python3_SYSLIBS}" + dnl remove -ltermcap, it can conflict with an earlier -lncurses + vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//` + vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//` + ]) + AC_CACHE_CHECK(Python3's dll name,vi_cv_dll_name_python3, + [ + if test "X$python3_DLLLIBRARY" != "X"; then + vi_cv_dll_name_python3="$python3_DLLLIBRARY" + else + vi_cv_dll_name_python3="$python3_INSTSONAME" + fi + ]) + + PYTHON3_LIBS="${vi_cv_path_python3_plibs}" + if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then + 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}\"'" + else + 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}\"'" + fi + PYTHON3_SRC="if_python3.c" + PYTHON3_OBJ="objects/if_python3.o" + + dnl On FreeBSD linking with "-pthread" is required to use threads. + dnl _THREAD_SAFE must be used for compiling then. + dnl The "-pthread" is added to $LIBS, so that the following check for + dnl sigaltstack() will look in libc_r (it's there in libc!). + dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC + dnl will then define target-specific defines, e.g., -D_REENTRANT. + dnl Don't do this for Mac OSX, -pthread will generate a warning. + AC_MSG_CHECKING([if -pthread should be used]) + threadsafe_flag= + thread_lib= + dnl if test "x$MACOSX" != "xyes"; then + if test "`(uname) 2>/dev/null`" != Darwin; then + test "$GCC" = yes && threadsafe_flag="-pthread" + if test "`(uname) 2>/dev/null`" = FreeBSD; then + threadsafe_flag="-D_THREAD_SAFE" + thread_lib="-pthread" + fi + if test "`(uname) 2>/dev/null`" = SunOS; then + threadsafe_flag="-pthreads" + fi + fi + libs_save_old=$LIBS + if test -n "$threadsafe_flag"; then + cflags_save=$CFLAGS + CFLAGS="$CFLAGS $threadsafe_flag" + LIBS="$LIBS $thread_lib" + AC_TRY_LINK(,[ ], + AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag", + AC_MSG_RESULT(no); LIBS=$libs_save_old + ) + CFLAGS=$cflags_save + else + AC_MSG_RESULT(no) + fi + + dnl check that compiling a simple program still works with the flags + dnl added for Python. + AC_MSG_CHECKING([if compile and link flags for Python 3 are sane]) + cflags_save=$CFLAGS + libs_save=$LIBS + CFLAGS="$CFLAGS $PYTHON3_CFLAGS" + LIBS="$LIBS $PYTHON3_LIBS" + AC_TRY_LINK(,[ ], + AC_MSG_RESULT(yes); python3_ok=yes, + AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no) + CFLAGS=$cflags_save + LIBS=$libs_save + if test "$python3_ok" = yes; then + AC_DEFINE(FEAT_PYTHON3) + else + LIBS=$libs_save_old + PYTHON3_SRC= + PYTHON3_OBJ= + PYTHON3_LIBS= + PYTHON3_CFLAGS= + fi + fi + else + AC_MSG_RESULT(too old) + fi + fi + if test "$fail_if_missing" = "yes" -a "$python3_ok" != "yes"; then + AC_MSG_ERROR([could not configure python3]) + fi +fi + +AC_SUBST(PYTHON3_CONFDIR) +AC_SUBST(PYTHON3_LIBS) +AC_SUBST(PYTHON3_CFLAGS) +AC_SUBST(PYTHON3_SRC) +AC_SUBST(PYTHON3_OBJ) + +dnl if python2.x and python3.x are enabled one can only link in code +dnl with dlopen(), dlsym(), dlclose() +if test "$python_ok" = yes && test "$python3_ok" = yes; then + AC_DEFINE(DYNAMIC_PYTHON) + AC_DEFINE(DYNAMIC_PYTHON3) + AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python) + cflags_save=$CFLAGS + CFLAGS="$CFLAGS $PYTHON_CFLAGS" + libs_save=$LIBS + dnl -ldl must go first to make this work on Archlinux (Roland Puntaier) + LIBS="-ldl $LIBS" + AC_RUN_IFELSE([AC_LANG_SOURCE([ + #include + /* If this program fails, then RTLD_GLOBAL is needed. + * RTLD_GLOBAL will be used and then it is not possible to + * have both python versions enabled in the same vim instance. + * Only the first python version used will be switched on. + */ + + int no_rtl_global_needed_for(char *python_instsoname, char *prefix) + { + int needed = 0; + void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL); + if (pylib != 0) + { + void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome"); + void (*init)(void) = dlsym(pylib, "Py_Initialize"); + int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString"); + void (*final)(void) = dlsym(pylib, "Py_Finalize"); + (*pfx)(prefix); + (*init)(); + needed = (*simple)("import termios") == -1; + (*final)(); + dlclose(pylib); + } + return !needed; + } + + int main(int argc, char** argv) + { + int not_needed = 0; + if (no_rtl_global_needed_for("${vi_cv_dll_name_python}", "${vi_cv_path_python_pfx}")) + not_needed = 1; + return !not_needed; + }])], + [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)]) + + CFLAGS=$cflags_save + LIBS=$libs_save + + AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python3) + cflags_save=$CFLAGS + CFLAGS="$CFLAGS $PYTHON3_CFLAGS" + libs_save=$LIBS + dnl -ldl must go first to make this work on Archlinux (Roland Puntaier) + LIBS="-ldl $LIBS" + AC_RUN_IFELSE([AC_LANG_SOURCE([ + #include + #include + /* If this program fails, then RTLD_GLOBAL is needed. + * RTLD_GLOBAL will be used and then it is not possible to + * have both python versions enabled in the same vim instance. + * Only the first python version used will be switched on. + */ + + int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix) + { + int needed = 0; + void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL); + if (pylib != 0) + { + void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome"); + void (*init)(void) = dlsym(pylib, "Py_Initialize"); + int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString"); + void (*final)(void) = dlsym(pylib, "Py_Finalize"); + (*pfx)(prefix); + (*init)(); + needed = (*simple)("import termios") == -1; + (*final)(); + dlclose(pylib); + } + return !needed; + } + + int main(int argc, char** argv) + { + int not_needed = 0; + if (no_rtl_global_needed_for("${vi_cv_dll_name_python3}", L"${vi_cv_path_python3_pfx}")) + not_needed = 1; + return !not_needed; + }])], + [AC_MSG_RESULT(yes);AC_DEFINE(PY3_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)]) + + CFLAGS=$cflags_save + LIBS=$libs_save + + PYTHON_SRC="if_python.c" + PYTHON_OBJ="objects/if_python.o" + PYTHON_CFLAGS="$