]> git.lyx.org Git - lyx.git/blobdiff - acinclude.m4
patch from Dekel
[lyx.git] / acinclude.m4
index 75dbd24073d1b336000c72744faf8f12bcaa6ae8..ac8165def8da673ab01613e99fda1a5e1e0e6dd8 100644 (file)
@@ -176,29 +176,33 @@ dnl normal versions of a library), tasteless as that idea is.
   ac_save_CXXFLAGS="$CXXFLAGS"
   CXXFLAGS=
 dnl Check the version of g++
-  gxx_version=`g++ --version`
+  gxx_version=`${CXX} --version`
   
   AC_PROG_CXX_G
   if test "$ac_test_CXXFLAGS" = set; then
     CXXFLAGS="$ac_save_CXXFLAGS"
   elif test $ac_cv_prog_cxx_g = yes; then
     case $gxx_version in
-      2.7*) CXXFLAGS="$lyx_opt";;
-      2.95.1) CXXFLAGS="-g $lyx_opt -fpermissive -fno-rtti";;
-      2.95.*) CXXFLAGS="-g $lyx_opt -fno-rtti";;
-      *)    CXXFLAGS="-g $lyx_opt -fno-exceptions -fno-rtti";;
+      2.95.1)  CXXFLAGS="-g $lyx_opt -fpermissive -fno-rtti -fno-exceptions";;
+      2.95.*)  CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
+      2.96*)   CXXFLAGS="-g $lyx_opt -fhonor-std";;
+      *2.91.*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
+      *)       CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
     esac
   else
     CXXFLAGS="$lyx_opt"
   fi
   if test x$with_warnings = xyes ; then
     case $gxx_version in
-       2.95.*) CXXFLAGS="$CXXFLAGS -Wall -W -Wconversion";;
-       *) CXXFLAGS="$CXXFLAGS -ansi -Wall -W";;
+       2.95.*) CXXFLAGS="$CXXFLAGS -W -Wall -Wconversion -Winline";;
+       2.96*)  CXXFLAGS="$CXXFLAGS -W -Wall -Wconversion -Winline";;
+       *)      CXXFLAGS="$CXXFLAGS -ansi -W -Wall -Wno-return-type";;
     esac
     if test $lyx_devel_version = yes ; then
        case $gxx_version in
            2.95.*) ;;
+           2.96*) ;;
+           *2.91*) ;;
            *) CXXFLAGS="$CXXFLAGS -pedantic";;
         esac
     fi
@@ -286,6 +290,30 @@ if test $lyx_cv_broken_stack = yes ; then
 fi])
 
 
+dnl Usage: LYX_STD_COUNT : checks wherer the C++ library have a conforming
+dnl    count template, if not the old HP version is assumed.
+AC_DEFUN(LYX_STD_COUNT,[
+AC_CACHE_CHECK(for conforming std::count,lyx_cv_std_count,
+ [AC_TRY_COMPILE([
+#include <string>
+#include <algorithm>
+using std::string;
+using std::count;
+int countChar(string const & a, char const c)
+{
+        return count(a.begin(), a.end(), c);
+}
+],[
+    string a("hello");
+    int i = countChar(a, 'l');
+],lyx_cv_std_count=yes,lyx_cv_std_count=no)
+])
+if test $lyx_cv_std_count = yes ; then
+    AC_DEFINE(HAVE_STD_COUNT, 1,
+    [Define if you have a conforming std::count template, otherwise HP version of count template is assumed.])
+fi])
+
+
 dnl Usage: LYX_CXX_STL_MODERN_STREAMS : checks whether the C++ compiler
 dnl   supports modern STL streams
 AC_DEFUN(LYX_CXX_STL_MODERN_STREAMS,[
@@ -317,8 +345,10 @@ AC_DEFUN(LYX_CXX_STL_STRING,[
            using std::string;
        ],[
            string a("hello there");
-           a.clear();
+           a.erase();
            a = "hey";
+           char s[] = "y";
+           int t = a.compare(a.length() - 1, 1, s);
            a.erase();
        ],[
            with_included_string=no
@@ -337,6 +367,15 @@ AC_DEFUN(LYX_CXX_STL_STRING,[
 ])
 
 
+dnl Usage: LYX_REGEX : checks if the header regex.h is available
+dnl   if it is not available the automake variable USE_REGEX will be
+dnl   defined and the regex.h and regex.c that we provide will be used.
+AC_DEFUN(LYX_REGEX,[
+    AC_CHECK_HEADERS(regex.h, lyx_regex=no, lyx_regex=yes)
+    AM_CONDITIONAL(USE_REGEX, test x$lyx_regex = xyes)
+])
+
+
 dnl LYX_CXX_MUTABLE
 AC_DEFUN(LYX_CXX_MUTABLE, [
 AC_REQUIRE([LYX_PROG_CXX])
@@ -392,10 +431,11 @@ dnl   good enough to suit our needs.
 AC_DEFUN(LYX_CXX_NAMESPACES,[
 AC_CACHE_CHECK(for correct namespaces support,lyx_cv_cxx_namespace,
  [AC_TRY_COMPILE([
-  #include <vector>
-  using std::vector;
+  namespace foo {
+    int bar;
+  }
 ],[
-       vector<int> test;
+        foo::bar = 0;
        return 0;
 ],lyx_cv_cxx_namespace=yes,lyx_cv_cxx_namespace=no)
 ])
@@ -507,23 +547,18 @@ lyx_cv_xfversion=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
   sed -e 's/^"%%%"\(.*\)"%%%"/\1/' -e 's/ //g'`
 rm -f conftest*])
 case "$lyx_cv_xfversion" in 
-  "(unknown)"|0.82|0.83|0.84|0.85
-     LYX_ERROR(dnl
+  "(unknown)"|0.8[1-7]
+         LYX_ERROR(dnl
 Version $lyx_cv_xfversion of xforms is not compatible with LyX. 
-   This version of LyX works best with version 0.88[,] although it
-   supports also versions 0.81[,] 0.86 and 0.87.) ;;
-  0.81|0.86|0.87) 
-     LYX_WARNING(dnl
-While LyX is compatible with version $lyx_cv_xfversion of xforms[,] 
-   it is recommended that you upgrade to version 0.88.) ;;
-     0.88) ;;
-     0.89) LYX_WARNING(dnl
+   This version of LyX works best with versions 0.88 (recommended) and later.) ;;
+    0.88) ;;
+    0.89) LYX_WARNING(dnl
 LyX should work ok with version $lyx_cv_xfversion of xforms[,] but
 it is an unproven version and might still have some bugs. If you
 have problems[,] please use version 0.88 instead.) ;;
-          *) LYX_WARNING(dnl
+       *) LYX_WARNING(dnl
 Version $lyx_cv_xfversion of xforms might not be compatible with LyX[,] 
  since it is newer than 0.88. You might have slight problems with it.);;
+ since it is newer than 0.88. You might have slight problems with it.);;
 esac
 fi])
 
@@ -575,6 +610,22 @@ if test "$ac_cv_sco" = yes; then
  test "x$GXX" = xyes && lyx_broken_headers=yes
 fi])
 
+dnl Usage: LYX_FUNC_PUTENV_ARGTYPE
+dnl Checks whether putenv() takes 'char const *' or 'char *' as
+dnl argument. This is needed because Solaris 7 (wrongly?) uses 'char *', 
+dnl while everybody else uses the former...
+AC_DEFUN(LYX_FUNC_PUTENV_ARGTYPE,
+[AC_MSG_CHECKING([type of argument for putenv()])
+ AC_CACHE_VAL(lyx_cv_func_putenv_arg,dnl
+  [AC_TRY_COMPILE(dnl
+[#include <cstdlib>],
+[char const * foo = "bar";
+ putenv(foo);],dnl
+   [lyx_cv_func_putenv_arg='char const *'],[lyx_cv_func_putenv_arg='char *'])])
+ AC_MSG_RESULT($lyx_cv_func_putenv_arg)
+ AC_DEFINE_UNQUOTED(PUTENV_TYPE_ARG,$lyx_cv_func_putenv_arg,dnl
+   [Define to the type of the argument of putenv(). Needed on Solaris 7.])])
+
 
 dnl Usage: LYX_WITH_DIR(dir-name,desc,dir-var-name,default-value, 
 dnl                       [default-yes-value])  
@@ -625,6 +676,52 @@ dnl Usage: LYX_ADD_INC_DIR(var-name,dir) Adds a -I directive to variable
 dnl var-name. 
 AC_DEFUN(LYX_ADD_INC_DIR,[$1="${$1} -I$2 "])
 
+### Check for a headers existence and location iff it exists
+## This is supposed to be a generalised version of LYX_STL_STRING_FWD
+## It almost works.  I've tried a few variations but they give errors
+## of one sort or other: bad substitution or file not found etc.  The
+## actual header _is_ found though and the cache variable is set however
+## the reported setting (on screen) is equal to $ac_safe for some unknown
+## reason.
+AC_DEFUN(LYX_PATH_HEADER,
+[ AC_CHECK_HEADER($1,[
+  ac_tr_safe=PATH_`echo $ac_safe | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+  AC_CACHE_CHECK([path to $1],lyx_cv_path_$ac_safe,
+  [ cat > conftest.$ac_ext <<EOF
+#line __oline__ "configure"
+#include "confdefs.h"
+
+#include <$1>
+EOF
+lyx_cv_path_$ac_safe=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
+  grep $1  2>/dev/null | \
+  sed -e 's/.*\(".*$1"\).*/\1/' -e "1q"`
+rm -f conftest*])
+  AC_DEFINE_UNQUOTED(${ac_tr_safe},${lyx_cv_path_$ac_safe})])
+])
+### end of LYX_PATH_HEADER
+
+### Check for stl_string_fwd.h existence and location if it exists
+AC_DEFUN(LYX_STL_STRING_FWD,
+[ AC_CHECK_HEADER(stl_string_fwd.h,[
+  AC_CACHE_CHECK([path to stl_string_fwd.h],lyx_cv_path_stl_string_fwd_h,
+  [ cat > conftest.$ac_ext <<EOF
+#line __oline__ "configure"
+#include "confdefs.h"
+
+#include <stl_string_fwd.h>
+EOF
+lyx_cv_path_stl_string_fwd_h=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
+  grep 'stl_string_fwd.h'  2>/dev/null | \
+  sed -e 's/.*\(".*stl_string_fwd.h"\).*/\1/' -e "1q"`
+rm -f conftest*])
+  AC_DEFINE_UNQUOTED(STL_STRING_FWD_H_LOCATION,$lyx_cv_path_stl_string_fwd_h,
+[define this to the location of stl_string_fwd.h to be used with #include,
+  NOTE: Do not set it to <stl_string_fwd.h> as that will find the LyX
+       supplied version of the header.
+  e.g. <../include/stl_string_fwd.h> or better yet use an absolute path])])
+])
+
 
 dnl AC_VALIDATE_CACHE_SYSTEM_TYPE[(cmd)]
 dnl if the cache file is inconsistent with the current host,
@@ -650,7 +747,6 @@ AC_DEFUN(AC_VALIDATE_CACHE_SYSTEM_TYPE, [
     ac_cv_target_system_type="$target"
 ])
 
-
 dnl We use this until autoconf fixes its version.
 AC_DEFUN(LYX_FUNC_SELECT_ARGTYPES,
 [AC_MSG_CHECKING([types of arguments for select()])
@@ -727,7 +823,7 @@ LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
 LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \
 DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \
 ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
-$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \
+$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \
 || AC_MSG_ERROR([libtool configure failed])
 
 # Reload cache, that may have been modified by ltconfig
@@ -759,13 +855,13 @@ AC_REQUIRE([AC_PROG_NM])dnl
 AC_REQUIRE([AC_PROG_LN_S])dnl
 dnl
 
+case "$target" in
+NONE) lt_target="$host" ;;
+*) lt_target="$target" ;;
+esac
+
 # Check for any special flags to pass to ltconfig.
-#
-# the following will cause an existing older ltconfig to fail, so
-# we ignore this at the expense of the cache file... Checking this 
-# will just take longer ... bummer!
-#libtool_flags="--cache-file=$cache_file"
-#
+libtool_flags="--cache-file=$cache_file"
 test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
 test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
 test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install"
@@ -782,7 +878,7 @@ test x"$silent" = xyes && libtool_flags="$libtool_flags --silent"
 
 # Some flags need to be propagated to the compiler or linker for good
 # libtool support.
-case "$host" in
+case "$lt_target" in
 *-*-irix6*)
   # Find out which ABI we are using.
   echo '[#]line __oline__ "configure"' > conftest.$ac_ext
@@ -998,7 +1094,6 @@ else
   AC_MSG_RESULT(no)
 fi
 test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
-AC_SUBST(LD)
 AC_PROG_LD_GNU
 ])
 
@@ -1044,14 +1139,13 @@ else
 fi])
 NM="$ac_cv_path_NM"
 AC_MSG_RESULT([$NM])
-AC_SUBST(NM)
 ])
 
 # AC_CHECK_LIBM - check for math library
 AC_DEFUN(AC_CHECK_LIBM,
 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
 LIBM=
-case "$host" in
+case "$lt_target" in
 *-*-beos* | *-*-cygwin*)
   # These system don't have libm
   ;;
@@ -1065,31 +1159,6 @@ case "$host" in
 esac
 ])
 
-### Check for stl_string_fwd.h existence and location if it exists
-###
-### Three problems remain:
-###   1.  I don't check if $lyx_cv_extra_inc has a value before testing it.
-###   2.  I don't issue a warning/error if AC_CHECK_HEADERS finds it but I
-###       don't.  The warning should only need to be something like:
-###       "Can't find path to stl_string_fwd.h please define
-###        STL_STRING_FWD_H_LOCATION in src/config.h or supply the path
-###        using --with-extra-inc"
-###   3. Multiple extra include dirs? and I don't check --with-extra-prefix yet
-###
-AC_DEFUN(LYX_STL_STRING_FWD,
-[AC_CHECK_HEADERS(stl_string_fwd.h,[
-  lyx_cv_stl_string_fwd_h_location="<../include/stl_string_fwd.h>"
-  AC_CHECK_HEADER(../include/stl_string_fwd.h,[
-    ac_cv_header_stl_string_fwd_h=yes
-    lyx_cv_stl_string_fwd_h_location="<../include/stl_string_fwd.h>"],[
-  AC_CHECK_HEADER($lyx_cv_extra_inc/stl_string_fwd.h,[
-    ac_cv_header_stl_string_fwd_h=yes
-    lyx_cv_stl_string_fwd_h_location="<$lyx_cv_extra_inc/stl_string_fwd.h>"],[
-    ac_cv_header_stl_string_fwd_h=no])])
-  AC_DEFINE_UNQUOTED(STL_STRING_FWD_H_LOCATION,$lyx_cv_stl_string_fwd_h_location)])
-])
-
-
 # AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for
 # the libltdl convenience library, adds --enable-ltdl-convenience to
 # the configure arguments.  Note that LIBLTDL is not AC_SUBSTed, nor
@@ -1148,7 +1217,6 @@ AC_DEFUN(AM_PROG_NM, [indir([AC_PROG_NM])])dnl
 
 dnl This is just to silence aclocal about the macro not being used
 ifelse([AC_DISABLE_FAST_INSTALL])dnl
-
 # Macro to add for using GNU gettext.
 # Ulrich Drepper <drepper@cygnus.com>, 1995.
 #
@@ -1200,7 +1268,11 @@ AC_DEFUN(AM_WITH_NLS,
               [AC_CACHE_CHECK([for gettext in libintl],
                 gt_cv_func_gettext_libintl,
                 [AC_CHECK_LIB(intl, gettext,
-                 gt_cv_func_gettext_libintl=yes,
+dnl ============== A fix is here! ======================
+dnl -lintl was not added to the LIBS variable in this case
+                 [gt_cv_func_gettext_libintl=yes
+                  INTLLIBS="-lintl"],
+dnl ==== end of fix
                  gt_cv_func_gettext_libintl=no)],
                 gt_cv_func_gettext_libintl=no)])
           fi
@@ -1378,11 +1450,12 @@ strdup __argz_count __argz_stringify __argz_next])
      else
        AC_MSG_CHECKING(for catalogs to be installed)
        NEW_LINGUAS=
-dnl ============== Fix is here! =======================
+dnl ============== Fix is here! ======================
 dnl Some sh do not like substitution in bounds of for loops
-dnl       for lang in ${LINGUAS=$ALL_LINGUAS}; do
+dnl    for lang in ${LINGUAS=$ALL_LINGUAS}; do
     tmplinguas=${LINGUAS=$ALL_LINGUAS}
     for lang in ${tmplinguas}; do
+dnl ==== end of fix
          case "$ALL_LINGUAS" in
           *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
          esac
@@ -1468,3 +1541,69 @@ dnl       for lang in ${LINGUAS=$ALL_LINGUAS}; do
    sed -e "/^#/d" -e "/^\$/d" -e "s,.*,        $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
        < $srcdir/po/POTFILES.in > po/POTFILES
   ])
+# Check whether LC_MESSAGES is available in <locale.h>.
+# Ulrich Drepper <drepper@cygnus.com>, 1995.
+#
+# This file can be copied and used freely without restrictions.  It can
+# be used in projects which are not available under the GNU Public License
+# but which still want to provide support for the GNU gettext functionality.
+# Please note that the actual code is *not* freely available.
+
+# serial 1
+
+AC_DEFUN(AM_LC_MESSAGES,
+  [if test $ac_cv_header_locale_h = yes; then
+    AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
+      [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
+       am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
+    if test $am_cv_val_LC_MESSAGES = yes; then
+      AC_DEFINE(HAVE_LC_MESSAGES)
+    fi
+  fi])
+# Search path for a program which passes the given test.
+# Ulrich Drepper <drepper@cygnus.com>, 1996.
+#
+# This file can be copied and used freely without restrictions.  It can
+# be used in projects which are not available under the GNU Public License
+# but which still want to provide support for the GNU gettext functionality.
+# Please note that the actual code is *not* freely available.
+
+# serial 1
+
+dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
+dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
+AC_DEFUN(AM_PATH_PROG_WITH_TEST,
+[# Extract the first word of "$2", so it can be a program name with args.
+set dummy $2; ac_word=[$]2
+AC_MSG_CHECKING([for $ac_word])
+AC_CACHE_VAL(ac_cv_path_$1,
+[case "[$]$1" in
+  /*)
+  ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
+  ;;
+  *)
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+  for ac_dir in ifelse([$5], , $PATH, [$5]); do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      if [$3]; then
+       ac_cv_path_$1="$ac_dir/$ac_word"
+       break
+      fi
+    fi
+  done
+  IFS="$ac_save_ifs"
+dnl If no 4th arg is given, leave the cache variable unset,
+dnl so AC_PATH_PROGS will keep looking.
+ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
+])dnl
+  ;;
+esac])dnl
+$1="$ac_cv_path_$1"
+if test -n "[$]$1"; then
+  AC_MSG_RESULT([$]$1)
+else
+  AC_MSG_RESULT(no)
+fi
+AC_SUBST($1)dnl
+])