Build Fix -- compatibility issue with newer autoconf
[sxemacs] / configure.ac
index 9a8192e..9264d1a 100644 (file)
@@ -9,11 +9,11 @@ dnl Autoconf startup.
 dnl -------------------------------------------------------------------------
 
 AC_PREREQ([2.62])
-AC_INIT([SXEmacs], [SXEM4CS_VERSION], [http://issues.sxemacs.org/])
+AC_INIT([SXEmacs], [SXEM4CS_VERSION], [https://issues.sxemacs.org/])
 AC_CONFIG_HEADER([src/config.h])
 AC_CONFIG_SRCDIR([src/lisp.h])
 AC_CONFIG_AUX_DIR([.])
-AC_CONFIG_MACRO_DIR([m4])
+AC_CONFIG_MACRO_DIRS([m4])
 
 dnl -------------------------------------------------------------------------
 dnl Local copyright notices.
@@ -295,21 +295,11 @@ OG_ARG_WITH([rel-alloc],
                [Relocating allocator for buffers.]),
        [default], [Autodetect])
 
-OG_ARG_WITH([dlmalloc],
-       AS_HELP_STRING([--with-dlmalloc],
-               [Use Doug Lea's malloc.]),
-       [default], [Autodetect])
-
 OG_ARG_WITH([debug-malloc],
        AS_HELP_STRING([--with-debug-malloc],
                [Use a debugging malloc.]),
        [no], [NO])
 
-OG_ARG_WITH([system-malloc],
-       AS_HELP_STRING([--with-system-malloc],
-               [Use a system malloc instead of GNU.]),
-       [default], [YES if using quantify or purify; NO otherwise])
-
 OG_ARG_WITH([regex-malloc],
        AS_HELP_STRING([--with-regex-malloc],
                [Use malloc for regex failure stack.]),
@@ -575,6 +565,13 @@ OG_ARG_WITH([termcap],
                [Use the termcap library for tty support.]),
        [auto], [Autodetect])
 
+OG_ARG_WITH([builtin-tty],
+       AS_HELP_STRING([--with-builtin-tty],
+               [Use builtin termcap like code. LEGACY CODE. Please consider
+               installing ncurses. Requires /etc/termcap or TERMCAP
+               environment variable to work.]),
+       [no], [No])
+
 
 OG_ARG_WITH([gpm],
        AS_HELP_STRING([--with-gpm],
@@ -764,12 +761,17 @@ AS_IF([test -f "$0.ac" -a "$0.ac" -nt "$0"],
 #
 # Turn off core generation. We are already verifying the program fails, no need
 # poluting the workspace. Of course if you are a SXEmacs developer you may want
-# to comemnt this on occasion :-)
+# to comment this on occasion :-)
 ulimit -c 0
 
 ## initialise our nestable msg funs
 SXE_INIT_MSG_LEVEL
 
+AC_PROG_SED
+AC_PROG_AWK
+
+ECHO=echo
+
 dnl Small snippet to make echo -n work on solaris
 ECHO_N= ECHO_C=
 case `echo -n x` in
@@ -803,7 +805,19 @@ dnl Check for bogus options
 dnl -------------------------------------------------------------------------
 SXE_CHECK_COMMAND_LINE
 
-AM_INIT_AUTOMAKE([foreign -Wall])
+test -z "$AUTOMAKE" || AUTOMAKE=automake
+
+AM_INIT_AUTOMAKE(m4_esyscmd([
+   automake_ver=`$AUTOMAKE --version 2>/dev/null | head -n1`
+   automake_major=`echo "$automake_ver" | sed -e 's/^.* \([0-9]*\).*/\1/'`
+   automake_minor=`echo "$automake_ver" | sed -e 's/^.* [0-9]*\.\([0-9]*\).*/\1/'`
+   if test "$automake_major" = "1" -a "$automake_minor" -lt "14"
+   then
+      echo "foreign -Wall -Wno-override -Wno-portability"
+   else
+      echo "info-in-builddir foreign -Wall -Wno-override -Wno-portability"
+   fi]))
+
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])
 SXE_CHECK_BUILDCHAIN
 AC_SUBST(EGREP)
@@ -1541,7 +1555,7 @@ AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
 int main (int argc, char *argv[])
 {
   int fd = -1;
-  caddr_t p;
+
 #ifndef MAP_ANONYMOUS
   fd = open ("/dev/zero", O_RDWR);
   if (fd < 0)
@@ -1559,26 +1573,22 @@ esac
 AC_MSG_RESULT($have_mmap)
 test "$have_mmap" = "yes" && AC_DEFINE([HAVE_MMAP], [1], [Description here!])
 
-dnl rel_alloc requires either GNU malloc or system malloc with mmap
+dnl rel_alloc requires a malloc with mmap
 dnl We only turn rel_alloc on by default if mmap is available.
-test "$GNU_MALLOC" != "yes" -a "$have_mmap" != "yes" && with_rel_alloc=no
+test "$have_mmap" != "yes" && with_rel_alloc=no
 if test "$with_rel_alloc $have_mmap" = "default yes"; then
-       if test "$doug_lea_malloc" = "yes"; then
-               dnl Check if malloc() calls mmap(), making rel_alloc pointless.
-               AC_MSG_CHECKING(for M_MMAP_THRESHOLD)
-               AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <malloc.h>]],[[
+       dnl Check if malloc() calls mmap(), making rel_alloc pointless.
+       AC_MSG_CHECKING(for M_MMAP_THRESHOLD)
+       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <malloc.h>]],[[
 #ifndef M_MMAP_THRESHOLD
 #error No M_MMAP_THRESHOLD :-(
 !@+$%^&*_)(_ - unlikely to compile...
 #endif
-                       ]])], [
-                       with_rel_alloc=no
-                       AC_MSG_RESULT(yes)], [
-                       with_rel_alloc=yes
-                       AC_MSG_RESULT(no)])
-       else
+               ]])], [
+               with_rel_alloc=no
+               AC_MSG_RESULT(yes)], [
                with_rel_alloc=yes
-       fi
+               AC_MSG_RESULT(no)])
 fi
 if test "$with_rel_alloc" = "yes"; then
        AC_DEFINE([REL_ALLOC], [1], [Description here!])
@@ -1685,7 +1695,7 @@ dnl Check for POSIX functions.
 dnl ----------------------------------------------------------------
 
 SXE_CHECK_BASIC_FUNS
-AC_CHECK_FUNCS([alarm cbrt closedir dup2 eaccess endpwent floor fmod fpathconf frexp fsync ftime ftruncate getaddrinfo getcwd gethostbyname gethostname getnameinfo getpagesize getrlimit gettimeofday getwd isascii isatty link logb lrand48 matherr memchr memmove memset mkdir mktime munmap perror poll pow putenv random re_comp readlink regcomp rename res_init rint rmdir select setitimer setlocale setpgid setsid sigblock sighold sigprocmask snprintf socket sqrt stpcpy strncpy strncat strcasecmp strchr strdup strerror strlwr strrchr strspn strtol strupr symlink ttyname tzset ulimit umask uname usleep utime vlimit vsnprintf waitpid wcscmp wcslen])
+AC_CHECK_FUNCS([alarm cbrt closedir dup2 eaccess endpwent floor fmod fpathconf frexp fsync ftime ftruncate getaddrinfo getcwd gethostbyname gethostname getnameinfo getpagesize getrlimit gettimeofday getwd isascii isatty link logb log2 log2f log2l log10 log10f log10l log logf logl lrand48 matherr memchr memmove memset mkdir mktime munmap perror poll pow putenv random re_comp readlink regcomp rename res_init rint rmdir select setitimer setlocale setpgid setsid sigblock sighold sigprocmask snprintf socket sqrt stpcpy strncpy strncat strcasecmp strchr strdup strerror strlwr strrchr strspn strtol strupr symlink ttyname tzset ulimit umask uname usleep utime vlimit vsnprintf waitpid wcscmp wcslen])
 
 AS_IF([test "$have_isatty" = "yes"],
        AC_DEFINE([HAVE_ISATTY], [1], [isatty is available]))
@@ -1705,58 +1715,39 @@ dnl -----------------------------------
 dnl Do some misc autoconf-special tests
 dnl -----------------------------------
 
-dnl Do the opsystem or machine files prohibit the use of the GNU malloc?
-dnl Assume not, until told otherwise.
-GNU_MALLOC=yes
-if test "$with_dlmalloc" != "no"; then
-       doug_lea_malloc=yes
-else
-       doug_lea_malloc=no
-fi
 after_morecore_hook_exists=yes
-AC_CHECK_FUNC(malloc_set_state, ,doug_lea_malloc=no)
 AC_MSG_CHECKING(whether __after_morecore_hook exists)
-AC_LINK_IFELSE([AC_LANG_SOURCE([[extern void (* __after_morecore_hook)();],[__after_morecore_hook = 0]])],
+AC_LINK_IFELSE([AC_LANG_SOURCE([
+       [extern void (* __after_morecore_hook)();]
+       [main() {__after_morecore_hook = 0;}]
+       ])],
   [AC_MSG_RESULT(yes)],
   [AC_MSG_RESULT(no)
    after_morecore_hook_exists=no])
-if test "$system_malloc" = "yes" ; then
-  GNU_MALLOC=no
-  GNU_MALLOC_reason="
-    - The GNU allocators don't work with this system configuration."
-elif test "$with_system_malloc" = "yes" ; then
-  GNU_MALLOC=no
-  GNU_MALLOC_reason="
-    - User chose not to use GNU allocators."
-elif test "$with_debug_malloc" = "yes" ; then
-  GNU_MALLOC=no
-  GNU_MALLOC_reason="
-    - User chose to use Debugging Malloc."
+if test "$after_morecore_hook_exists" = "yes" ; then
+       AC_DEFINE([HAVE_MORECORE_HOOK], [1],
+               [Define if __after_morecore_hook is available])
+       AC_DEFINE([HAVE_MALLOC_WARNING], [1],
+               [Define if __after_morecore_hook is available])
 fi
+AC_SUBST(HAVE_MORECORE_HOOK)
 
-if test "$doug_lea_malloc" = "yes" -a "$GNU_MALLOC" = "yes" ; then
-       GNU_MALLOC_reason="
-    - Using Doug Lea's new malloc from the GNU C Library."
-       AC_DEFINE([DOUG_LEA_MALLOC], [1], [Description here!])
-       if test "$after_morecore_hook_exists" = "no" ; then
-               GNU_MALLOC_reason="
-    - Using Doug Lea's new malloc from the Linux C Library."
-       AC_DEFINE([_NO_MALLOC_WARNING_], [1], [Description here!])
-       fi
-fi
 AM_CONDITIONAL([USE_MEMALLOC], [test -n "${libmemalloc_objs}"])
 
-dnl #### mcheck is broken in all versions of Linux libc and glibc.
-dnl Try this again when 2.1 hits the streets.
-dnl Avoid using free-hook.c if support exists for malloc debugging in libc
+dnl Use the support for for malloc debugging in libc if available.
 have_libmcheck=no
 if test "$with_error_checking_malloc" = "yes" -a \
-   "$have_glibc" = "yes" -a \
-   "$doug_lea_malloc" = "yes"; then
+   "$have_glibc" = "yes" -a; then
        AC_CHECK_HEADERS(mcheck.h)
        AC_CHECK_LIB(mcheck, mcheck, [have_libmcheck=yes], [have_libmcheck=no])
 fi
 
+if test "have_libmcheck" = "yes"; then
+       AC_DEFINE([HAVE_LIBMCHECK], [1],
+               [Define if malloc debugging via libmcheck is available])
+       SXE_PREPEND(-lmcheck, MEMALLOC_LIBS)
+fi
+
 if test "$with_module_support" != "no"; then
        AS_MESSAGE([checking for module support])
        if test "$sxe_cv_feat_libltdl" = "yes"; then
@@ -1855,7 +1846,7 @@ SXE_CHECK_SUFFICIENCY([ffi], [FFI support], [
        ## additional actions
        AC_DEFINE([HAVE_LIBFFI], [1], [Description here!])
        HAVE_LIBFFI=yes
-       FFI_LIBS="-lffi"
+       FFI_LIBS="-lffi -ldl"
        SXE_ADD_CRUFT_OBJS([effi.o])
 ])
 
@@ -2480,7 +2471,7 @@ dnl   fi
 
        dnl make sure we can find Intrinsic.h
        AC_CHECK_HEADER([X11/Intrinsic.h], [],
-               [AC_MSG_ERROR([Unable to find X11 header files. Try using --x-includes=<path> if you know the path, or --with-x=no to disable X11 support.])])
+               [AC_MSG_ERROR([Unable to find X11 and/or Xt header files. Try using --x-includes=<path> if you know the path, or --with-x=no to disable X11 support.])])
 
        dnl Check some more headers
        AC_CHECK_HEADERS([X11/Intrinsic.h X11/StringDefs.h X11/Shell.h X11/ShellP.h],
@@ -2722,144 +2713,343 @@ AC_CHECK_HEADERS([libintl.h nlist.h sgtty.h termio.h termios.h])
 AS_IF([test "$with_tty" != "no"],[
    AS_MESSAGE(checking for TTY-related features)
    dnl Check if needed calls are available at all...
-   tty_libs="ncurses curses terminfo termlib termcap"
-   tty_funcs="tgetent tgetstr tgetflag tparm tgoto tputs"
-   for func in $tty_funcs; do
-       AC_SEARCH_LIBS($func,$tty_libs)
+   
+   with_tty_libs=""
+   detect_tty_libs=""
+   for lib in ncurses curses tinfo terminfo termlib termcap
+   do
+       eval "with=\$with_${lib}"
+       if test "$with" = no
+       then
+          AC_MSG_WARN(["Ignoring available ${lib} due to --with-${lib}=no"])
+       elif test "$with" = "yes"
+       then
+          with_tty_libs="$with_tty_libs $lib"
+       else
+          detect_tty_libs="$detect_tty_libs $lib"
+       fi
    done
-   AS_IF([test "$ac_cv_search_tgetent"  = "no" -a \
-              "$ac_cv_search_tgetflag" = "no" -a \
-              "$ac_cv_search_tgetstr"  = "no" -a \
-              "$ac_cv_search_tgoto"    = "no" -a \
-              "$ac_cv_search_tparm"    = "no" -a \
-              "$ac_cv_search_tputs"    = "no" ], 
-                  have_tty=no)
-   AS_IF([test "$with_tty" = "yes" -a "$have_tty" = "no" ],[
-      AC_MSG_ERROR([Your system lacks necessary functions for requested TTY support])])
-],[
-  for feature in ncurses curses termcap terminfo termlib gpm; do
-    if eval "test -n \"\$with_${feature}\" -a \"\$with_${feature}\" != no" ; then
-      AC_MSG_WARN([--with-${feature} ignored:  Not valid without TTY support])
-    fi
-    eval "with_${feature}=no"
-  done
-])
 
-AS_IF([test "$with_tty" != "no" -a "$have_tty" != "no" ],[
-   for lib in $tty_libs; do 
-      SXE_CHECK_LINK_LIB($lib, , eval have_${lib}=no)
-      with_lib_eval=`eval echo \\$with_$lib`
-      have_lib_eval=`eval echo \\$have_$lib`
-      AS_IF([test "$have_lib_eval" = "yes" ], [
-        for func in $tty_funcs; do
-            AC_CHECK_LIB($lib, tgetent)
-            AC_CHECK_LIB($lib, tgetstr)
-            AC_CHECK_LIB($lib, tgetflags)
-            AC_CHECK_LIB($lib, tparm)
-            AC_CHECK_LIB($lib, tgoto)
-            AC_CHECK_LIB($lib, tputs)
-        done
-      ])
-      have_lib_eval=`eval echo \\$have_$lib`
-      AS_IF([test "$with_lib_eval" = "yes" -a \
-                 "$have_lib_eval" = "no" ],
-       AC_MSG_WARN([Errors detected trying to use requested $lib. Continuing with autodetection.]))
+   # All terminal info functions needed
+   tty_funcs="tgetent tgetstr tgetflag tgetnum tparm tgoto tputs"
+   tty_libs=""
+   # Filter by existing libs, printf is sure to be available with libc, so failure
+   # would come from lib not find
+   for lib in $with_tty_libs $detect_tty_libs
+   do
+       SXE_CHECK_LINK_LIB($lib)
+       if eval "test \"\$sxe_cv_c_lib_${lib}\" != yes"
+       then
+         if eval "test \"\$with_${lib}\" = yes"
+         then
+            AC_MSG_WARN(["Ignoring --with-${lib}=yes due to library not linkable"])
+            eval "with_${lib}=no"
+         fi
+          continue
+       fi
+
+       AC_CHECK_LIB([$lib], [$tty_funcs])
+
+       # Lets verify we have all functions
+       for func in $tty_func
+       do
+           if eval "test \"\$ac_cv_lib_${lib}_${func}\" = no"
+          then
+              AS_MESSAGE(["Skipping ${lib}, does not support to all TTY functions"])
+              lib=""
+             break
+          fi
+       done
+
+       tty_libs="$tty_libs $lib"
    done
-   AS_IF([test "$sxe_cv_c_lib_ncurses"  = "no" -a \
-               "$sxe_cv_c_lib_curses"   = "no" -a \
-              "$sxe_cv_c_lib_termcap"  = "no" -a \
-              "$sxe_cv_c_lib_terminfo" = "no" -a \
-              "$sxe_cv_c_lib_termlib"  = "no"], 
-                  have_tty=no)
-   AS_IF([test "$with_tty" = "yes" -a "$have_tty" = "no"],
-      AC_MSG_ERROR([Your system lacks necessary libraries for requested TTY support.]))
-])
-
 
-AS_IF([test "$with_tty" != "no" -a "$have_tty" != "no" ],[
-    AC_DEFINE([HAVE_NCURSES], [1], [Description here!])
-    with_ncurses=yes
-    AC_CHECK_HEADER(ncurses/ncurses.h, curses_h_file=ncurses/ncurses.h)
-    if test -z "$curses_h_file"; then
-           AC_CHECK_HEADER(ncurses/curses.h,  curses_h_file=ncurses/curses.h)
-    fi
-    if test -n "$curses_h_file"; then
-           AC_CHECK_HEADER(ncurses/termcap.h, termcap_h_file=ncurses/termcap.h)
-           AC_CHECK_HEADER(ncurses/term.h, term_h_file=ncurses/term.h)
-    else
-           AC_CHECK_HEADER(ncurses.h, curses_h_file=ncurses.h)
-           AC_CHECK_HEADER(termcap.h, termcap_h_file=termcap.h)
-           AC_CHECK_HEADER(term.h,    term_h_file=term.h)
-    fi
-    SXE_ADD_SXEUITTY_OBJS(terminfo.o)
-    SXE_PREPEND(-lncurses, LIBS)
-
-    if test -z "$curses_h_file" ; then
-      dnl Try again, and check for the bogus ncurses/ include bug.
-      dnl (i.e. ncurses/curses.h bogusly includes <unctrl.h> instead of
-      dnl <ncurses/unctrl.h>)
-      save_c_switch_site="$c_switch_site"
-      c_switch_site="$c_switch_site -I/usr/include/ncurses"
+   if test -n "$tty_libs"
+   then
+      AS_MESSAGE(["Considering libraries: $tty_libs"])
+   
+      # Check which preferred lib can be used
+      for func in $tty_funcs
+      do
+         # Make sure no flags are harmed during the search
+         sxe_save_LIBS=$LIBS
+         AC_SEARCH_LIBS($func, $tty_libs)
+         LIBS=$sxe_save_LIBS
+      done
+
+      # Minimize the set of libraries
+      tty_feature=""
+      tty_fun=""
+      for func in $tty_funcs
+      do
+          eval lib=\$ac_cv_search_${func}
+          if test "$lib" != no -a "$lib" != "none required"
+          then
+              for feature in $tty_feature
+              do
+                         if test "$feature" = "$lib"
+                 then
+                    lib=""
+                    func=""
+                    break;
+                  fi
+              done
+             tty_feature="$tty_feature $lib"
+             tty_fun="$tty_fun $func"
+          fi
+       done
+   fi
+
+   if test -n "$tty_feature"
+   then
+      # Check all the expected functions still compile with all the added
+      # libraries
+      sxe_save_LIBS=$LIBS
+      LIBS="$LIBS $tty_feature"
+      AC_CHECK_FUNCS($tty_funcs)
+      for func in $tty_fun
+      do
+       if eval "test \"\$ac_cv_func_${func}\" = no"
+       then
+           tty_feature=""
+           break
+       fi
+      done
+      LIBS=$sxe_save_LIBS
+   fi
+
+   if test -n "$tty_feature"
+   then
+      SXE_PREPEND($tty_feature, LIBS)
+      for lib in $tty_feature
+      do
+         l=`echo $lib | sed -e 's/^-l//g'`
+         eval "with_${l}=yes"
+      done
+      with_builtin_tty=no
+      have_tty=yes
+   else
+      AC_MSG_WARN([Could not link all needed tty functions.]
+                  [Please consider installing ncurses.])
+      if test "$with_builtin_tty" = yes
+      then
+          AC_MSG_WARN([Using builtin tty support.])
+         have_tty=yes
+      else
+          AC_MSG_WARN([Use --with-builtin-tty=yes if you cannot use ncurses.])
+         have_tty=no
+      fi
+   fi
+
+   if test "$with_builtin_tty" = yes
+   then
+      # Add our own wrappers using termcap
+      SXE_ADD_SXEUITTY_OBJS(termcap.o)
+      SXE_ADD_SXEUITTY_OBJS(tparam.o)
+      have_tty=yes
+   elif test "$have_tty" = yes
+   then
+      # Terminfo interface, since tgetent etc are available
+      SXE_ADD_SXEUITTY_OBJS(terminfo.o)
+   fi
+
+   # Check headers, first generally
+   AC_CHECK_HEADER(termcap.h, termcap_h_file=termcap.h)
+   AC_CHECK_HEADER(term.h,    term_h_file=term.h)
+   
+   if test "$have_ncurses" = yes; then
+      # Verify how ncurses overrides them
       AC_CHECK_HEADER(ncurses/ncurses.h, curses_h_file=ncurses/ncurses.h)
       if test -z "$curses_h_file"; then
            AC_CHECK_HEADER(ncurses/curses.h,  curses_h_file=ncurses/curses.h)
       fi
       if test -n "$curses_h_file"; then
            AC_CHECK_HEADER(ncurses/termcap.h, termcap_h_file=ncurses/termcap.h)
-           AC_CHECK_HEADER(ncurses/term.h, term_h_file=ncurses/term.h)
+           AC_CHECK_HEADER(ncurses/term.h,    term_h_file=ncurses/term.h)
       else
-           AC_CHECK_HEADER(ncurses.h, curses_h_file=ncurses.h)
-           AC_CHECK_HEADER(termcap.h, curses_h_file=termcap.h)
-           AC_CHECK_HEADER(term.h,    curses_h_file=term.h)
+           AC_CHECK_HEADER(ncurses.h,         curses_h_file=ncurses.h)
       fi
-      if test -n "$curses_h_file"
-       then AC_MSG_WARN([Your system has the bogus ncurses include bug.])
-       else c_switch_site="$save_c_switch_site"
+      
+      if test -z "$curses_h_file" ; then
+          dnl Try again, and check for the bogus ncurses/ include bug.
+          dnl (i.e. ncurses/curses.h bogusly includes <unctrl.h> instead of
+          dnl <ncurses/unctrl.h>)
+          save_c_switch_site="$c_switch_site"
+          c_switch_site="$c_switch_site -I/usr/include/ncurses"
+          AC_CHECK_HEADER(ncurses/ncurses.h,   curses_h_file=ncurses/ncurses.h)
+          if test -z "$curses_h_file"; then
+           AC_CHECK_HEADER(ncurses/curses.h,  curses_h_file=ncurses/curses.h)
+          fi
+          if test -n "$curses_h_file"; then
+           AC_CHECK_HEADER(ncurses/termcap.h, termcap_h_file=ncurses/termcap.h)
+           AC_CHECK_HEADER(ncurses/term.h,    term_h_file=ncurses/term.h)
+          else
+           AC_CHECK_HEADER(ncurses.h,         curses_h_file=ncurses.h)
+          fi
+          if test -n "$curses_h_file"
+         then
+               AC_MSG_WARN([Your system has the bogus ncurses include bug.])
+               AC_CHECK_HEADER(termcap.h,         curses_h_file=termcap.h)
+               AC_CHECK_HEADER(term.h,            curses_h_file=term.h)
+         else c_switch_site="$save_c_switch_site"
+          fi
       fi
+   fi
+   
+   if test -n "$curses_h_file"; then
+       AC_DEFINE_UNQUOTED([HAVE_CURSES_H], [1],
+                          [There is a curses.h header file available])
+       AC_DEFINE_UNQUOTED([CURSES_H_FILE], ["${curses_h_file}"],
+                          [The curses.h header file])
+   fi
+
+   if test -n "$termcap_h_file"; then
+       AC_DEFINE_UNQUOTED([HAVE_TERMCAP_H], [1],
+                          [There is a termcap.h header available])
+       AC_DEFINE_UNQUOTED([TERMCAP_H_FILE], ["${termcap_h_file}"],
+                          [The termcap.h header file])
+   fi
+
+   if test -n "$term_h_file"; then
+       AC_DEFINE_UNQUOTED([HAVE_TERM_H], [1],
+                          [There is a term.h header available])
+       AC_DEFINE_UNQUOTED([TERM_H_FILE], ["${term_h_file}"],
+                          [The term.h header file])
+   fi
+
+   # Finally let's see if we have prototype for the elusive tparm
+   AC_MSG_CHECKING(for tparm prototype)
+   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#ifdef TERM_H_FILE
+#include TERM_H_FILE
+#endif
+#ifdef TERMCAP_H_FILE
+#include TERMCAP_H_FILE
+#endif
+#ifdef CURSES_H_FILE
+#include CURSES_H_FILE
+#endif
+/* Completely incompatible prototype with all tparm ones
+   if files above define it, compilation should fail
+*/
+extern void tparm(void);
+       ]], [[ tparm(); ]])],
+       [AC_MSG_RESULT(no)],
+       [AC_MSG_RESULT(yes)
+         AC_DEFINE_UNQUOTED([HAVE_TPARM_PROTOTYPE], [1],
+                           [tparm has a prototype defined])])
+
+   # Finally let's see if we have prototype for tgetent
+   AC_MSG_CHECKING(for tgetent prototype)
+   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#ifdef TERM_H_FILE
+#include TERM_H_FILE
+#endif
+#ifdef TERMCAP_H_FILE
+#include TERMCAP_H_FILE
+#endif
+#ifdef CURSES_H_FILE
+#include CURSES_H_FILE
+#endif
+extern void tgetent(void);
+       ]], [[ tgetent(); ]])],
+       [AC_MSG_RESULT(no)],
+       [AC_MSG_RESULT(yes)
+         AC_DEFINE_UNQUOTED([HAVE_TGETENT_PROTOTYPE], [1],
+                           [tgetent has a prototype defined])])
+
+
+   # Finally let's see if we have prototype for tgetflag
+   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#ifdef TERM_H_FILE
+#include TERM_H_FILE
+#endif
+#ifdef TERMCAP_H_FILE
+#include TERMCAP_H_FILE
+#endif
+#ifdef CURSES_H_FILE
+#include CURSES_H_FILE
+#endif
+extern void tgetflag(void);
+       ]], [[ tgetflag(); ]])],
+       [AC_MSG_RESULT(no)],
+       [AC_MSG_RESULT(yes)
+         AC_DEFINE_UNQUOTED([HAVE_TGETFLAG_PROTOTYPE], [1],
+                                [tgetflag has a prototype defined])])
+
+   # Finally let's see if we have prototype for tgetnum
+   AC_MSG_CHECKING(for tgetnum prototype)
+   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#ifdef TERM_H_FILE
+#include TERM_H_FILE
+#endif
+#ifdef TERMCAP_H_FILE
+#include TERMCAP_H_FILE
+#endif
+#ifdef CURSES_H_FILE
+#include CURSES_H_FILE
+#endif
+extern void tgetnum(void);
+       ]], [[ tgetnum(); ]])],
+       [AC_MSG_RESULT(no)],
+       [AC_MSG_RESULT(yes)
+        AC_DEFINE_UNQUOTED([HAVE_TGETNUM_PROTOTYPE], [1],
+                           [tgetnum has a prototype defined])])
+
+   # Finally let's see if we have prototype for tgetnum
+   AC_MSG_CHECKING(for tgetstr prototype)
+   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#ifdef TERM_H_FILE
+#include TERM_H_FILE
+#endif
+#ifdef TERMCAP_H_FILE
+#include TERMCAP_H_FILE
+#endif
+#ifdef CURSES_H_FILE
+#include CURSES_H_FILE
+#endif
+extern void tgetstr(void);
+       ]], [[ tgetstr(); ]])],
+       [AC_MSG_RESULT(no)],
+        [AC_MSG_RESULT(yes)
+        AC_DEFINE_UNQUOTED([HAVE_TGETSTR_PROTOTYPE], [1],
+                           [tgetstr has a prototype defined])])
+
+   # Finally let's see if we have prototype for tgetnum
+   AC_MSG_CHECKING(for tputs prototype)
+   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#ifdef TERM_H_FILE
+#include TERM_H_FILE
+#endif
+#ifdef TERMCAP_H_FILE
+#include TERMCAP_H_FILE
+#endif
+#ifdef CURSES_H_FILE
+#include CURSES_H_FILE
+#endif
+extern void tputs(void);
+       ]], [[ tputs(); ]])],
+       [AC_MSG_RESULT(no)],
+       [AC_MSG_RESULT(yes)
+         AC_DEFINE_UNQUOTED([HAVE_TPUTS_PROTOTYPE], [1],
+                           [tputs has a prototype defined])])
+],[
+  for feature in ncurses curses termcap terminfo termlib gpm; do
+    if eval "test -n \"\$with_${feature}\" -a \"\$with_${feature}\" != no" ; then
+      AC_MSG_WARN([--with-${feature} ignored:  Not valid without TTY support])
     fi
-])
-
-AS_IF([test "$with_tty" != "no" -a "$have_ncurses" != "no" ],[
-  if test "$with_ncurses" = "no" -o -z "$curses_h_file" ; then
-
-    # Check alternate library includes
-    for lib in curses term terminfo termcap; do
-       AC_CHECK_HEADER(${lib}.h, [
-               eval ${lib}_h_file=${lib}.h
-               AC_CHECK_LIB($lib, tgetent, eval have_${lib}=yes, eval have_${lib}=no)
-               AC_CHECK_LIB($lib, tgetstr, , eval have_${lib}=no)])
-    done
-
-    for lib in curses terminfo termlib termcap; do
-         have_lib_eval=`eval echo \\$have_$lib`
-         if test "$have_lib_eval" = "yes"; then
-               AC_CHECK_LIB($lib, tparm,
-                         SXE_ADD_SXEUITTY_OBJS(terminfo.o),
-                         SXE_ADD_SXEUITTY_OBJS(tparam.o))
-               SXE_PREPEND(-l${lib}, LIBS)
-               break
-         fi
-    done
-  fi
-  if test -n "$curses_h_file"; then
-       AC_DEFINE_UNQUOTED([HAVE_CURSES_H], [1], [There is a curses.h header file available])
-  fi
-  if test -n "$termcap_h_file"; then
-       AC_DEFINE_UNQUOTED([HAVE_TERMCAP_H], [1], [There is a termcap.h header available])
-  fi
-  if test -n "$term_h_file"; then
-       AC_DEFINE_UNQUOTED([HAVE_TERM_H], [1], [There is a term.h header available])
-  fi
-  AC_DEFINE_UNQUOTED([CURSES_H_FILE], ["${curses_h_file-curses.h}"], [The curses.h header file])
-  AC_DEFINE_UNQUOTED([TERMCAP_H_FILE], ["${termcap_h_file-termcap.h}"], [The termcap.h header file])
-  AC_DEFINE_UNQUOTED([TERM_H_FILE], ["${term_h_file-term.h}"], [The term.h header file])
+    eval "with_${feature}=\"\""
+  done
 ])
 
 AS_IF([test "$with_tty" != "no" -a "$have_tty" != no], [
-       AC_DEFINE([HAVE_TTY], [1], [Include TTY support for SXEmacs])
-       AC_DEFINE([HAVE_UNIXOID_EVENT_LOOP], [1], [Include Unixoid event loop - TTY provided])
+       AC_DEFINE([HAVE_TTY], [1],
+                 [Include TTY support for SXEmacs])
+       AC_DEFINE([HAVE_UNIXOID_EVENT_LOOP], [1],
+                 [Include Unixoid event loop - TTY provided])
        SXE_ADD_SXEUITTY_OBJS([console-tty.o device-tty.o event-tty.o frame-tty.o objects-tty.o redisplay-tty.o cm.o])
 ])
+
 AS_IF([test "$with_tty" != "no" -a "$have_tty" != no], [
   dnl General Purpose Mouse (libgpm) support
   AS_IF([test "$with_gpm" != "no"], [
@@ -3069,8 +3259,8 @@ if test "$with_media_ffmpeg" != "no"; then
 
        if test "$have_media_ffmpeg" = "yes"; then
                AC_MSG_RESULT([yes])
-               FFMPEG_LIBS=`$PKG_CONFIG --libs libavformat`
-               FFMPEG_CPPFLAGS=`$PKG_CONFIG --cflags libavformat`
+               FFMPEG_LIBS=`$PKG_CONFIG --libs libavformat libavcodec libavutil`
+               FFMPEG_CPPFLAGS=`$PKG_CONFIG --cflags libavformat libavcodec libavutil`
                SXE_PREPEND($FFMPEG_LIBS, MM_LIBS)
                SXE_PREPEND_UNDUP($FFMPEG_CPPFLAGS, MM_CPPFLAGS)
                SXE_ADD_MM_OBJS([media-ffmpeg.o])
@@ -3656,7 +3846,7 @@ done
 AC_SUBST(INFOPATH)
 
 if test -z "$with_module_path"; then
-    with_module_path="~/.sxemacs/${configuration}/modules:${libdir}/${PROGNAME}/${configuration}/site-modules:${libdir}/${instvardir}/${configuration}/modules"
+    with_module_path="~/.config/sxemacs/${configuration}/modules:${libdir}/${PROGNAME}/${configuration}/site-modules:${libdir}/${instvardir}/${configuration}/modules"
 fi
 
 AC_SUBST(module_path,$with_module_path)
@@ -3676,10 +3866,10 @@ fi
 
 if test -z "$with_package_path" && test -n "$with_package_prefix" ; then
   if test "$with_mule" = "yes" ; then
-    with_package_path="~/.sxemacs/site-packages:~/.sxemacs/sxemacs-packages:~/.sxemacs/xemacs-packages:~/.sxemacs/mule-packages"
+    with_package_path="~/.local/share/sxemacs/site-packages:~/.local/share/sxemacs/sxemacs-packages:~/.local/share/sxemacs/xemacs-packages:~/.local/share/sxemacs/mule-packages"
     with_package_path="${with_package_path}:${with_package_prefix}/site-packages:${with_package_prefix}/sxemacs-packages:${with_package_prefix}/xemacs-packages:${with_package_prefix}/mule-packages"
   else
-    with_package_path="~/.sxemacs/site-packages:~/.sxemacs/sxemacs-packages:~/.sxemacs/xemacs-packages"
+    with_package_path="~/.local/share/sxemacs/site-packages:~/.local/share/sxemacs/sxemacs-packages:~/.local/share/sxemacs/xemacs-packages"
     with_package_path="${with_package_path}:${with_package_prefix}/site-packages:${with_package_prefix}/sxemacs-packages:${with_package_prefix}/xemacs-packages"
   fi
 fi
@@ -3859,26 +4049,12 @@ dnl at the point where the autodetection occurs or would occur,
 dnl so that the user gets immediate feedback on the results of the
 dnl autodetection.
 
-if test "$GNU_MALLOC" = "yes"; then
-       AC_DEFINE([GNU_MALLOC], [1], [Description here!])
+AC_DEFINE([SYSTEM_MALLOC], [1], [Description here!])
+test "$after_morecore_hook_exists" = "yes" && \
        SXE_ADD_MEMALLOC_OBJS(vm-limit.o)
-       if test "$doug_lea_malloc" != "yes"; then
-               SXE_ADD_MEMALLOC_OBJS(gmalloc.o)
-       fi
-       if test "$with_error_checking_malloc" = "yes"; then
-               dnl SXE_ADD_MEMALLOC_OBJS(free-hook.o)
-               :
-       fi
-elif test "$with_system_malloc" = "yes" -o "$system_malloc" = "yes"; then
-       AC_DEFINE([USE_SYSTEM_MALLOC], [1], [Description here!])
-       AC_DEFINE([SYSTEM_MALLOC], [1], [Description here!])
-elif test "$with_debug_malloc"  = "yes"; then
+if test "$with_debug_malloc"  = "yes"; then
        AC_DEFINE([USE_DEBUG_MALLOC], [1], [Description here!])
-       AC_DEFINE([USE_SYSTEM_MALLOC], [1], [Description here!])
-       AC_DEFINE([SYSTEM_MALLOC], [1], [Description here!])
        SXE_APPEND(-ldmalloc, MEMALLOC_LIBS)
-else
-       SXE_ADD_MEMALLOC_OBJS([malloc.o])
 fi
 test "$GCC" = "yes" && \
        AC_DEFINE([USE_GCC], [1], [Description here!])