]> git.lyx.org Git - lyx.git/blobdiff - acinclude.m4
fixes because of SUN CC warnings, bmtable now compiled with C compilator, countChar...
[lyx.git] / acinclude.m4
index 75dbd24073d1b336000c72744faf8f12bcaa6ae8..3362b4c385f592d380a8774acb7299503a87c729 100644 (file)
@@ -286,6 +286,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,[
@@ -1065,28 +1089,47 @@ case "$host" in
 esac
 ])
 
+
+### 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
-###
-### 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_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)])
 ])