]> git.lyx.org Git - features.git/blobdiff - acinclude.m4
my changes during the holidyas...i expect some compilers to have some problems, but...
[features.git] / acinclude.m4
index 75dbd24073d1b336000c72744faf8f12bcaa6ae8..ae6c60eb41c9f385d730f331ef2cd37836e4db93 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,[
@@ -337,6 +361,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])
@@ -575,6 +608,21 @@ 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>
+extern int putenv(const char *);],,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])  
@@ -650,7 +698,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()])
@@ -1065,28 +1112,51 @@ 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,
+[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])])
 ])